Commit 0ddc110c authored by Dhananjay Phadke's avatar Dhananjay Phadke Committed by David S. Miller

netxen: cleanup rx handling

o remove unused rx fragment handling code.
o imporove check for status descriptor ownership.
Signed-off-by: default avatarDhananjay Phadke <dhananjay@netxen.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d5df2a16
...@@ -392,11 +392,8 @@ struct rcv_desc { ...@@ -392,11 +392,8 @@ struct rcv_desc {
#define STATUS_CKSUM_OK (2) #define STATUS_CKSUM_OK (2)
/* owner bits of status_desc */ /* owner bits of status_desc */
#define STATUS_OWNER_HOST (0x1) #define STATUS_OWNER_HOST (0x1ULL << 56)
#define STATUS_OWNER_PHANTOM (0x2) #define STATUS_OWNER_PHANTOM (0x2ULL << 56)
#define NETXEN_PROT_IP (1)
#define NETXEN_PROT_UNKNOWN (0)
/* Note: sizeof(status_desc) should always be a mutliple of 2 */ /* Note: sizeof(status_desc) should always be a mutliple of 2 */
...@@ -422,15 +419,6 @@ struct rcv_desc { ...@@ -422,15 +419,6 @@ struct rcv_desc {
#define netxen_get_sts_opcode(sts_data) \ #define netxen_get_sts_opcode(sts_data) \
(((sts_data) >> 58) & 0x03F) (((sts_data) >> 58) & 0x03F)
#define netxen_get_sts_owner(status_desc) \
((le64_to_cpu((status_desc)->status_desc_data) >> 56) & 0x03)
#define netxen_set_sts_owner(status_desc, val) { \
(status_desc)->status_desc_data = \
((status_desc)->status_desc_data & \
~cpu_to_le64(0x3ULL << 56)) | \
cpu_to_le64((u64)((val) & 0x3) << 56); \
}
struct status_desc { struct status_desc {
/* Bit pattern: 0-3 port, 4-7 status, 8-11 type, 12-27 total_length /* Bit pattern: 0-3 port, 4-7 status, 8-11 type, 12-27 total_length
28-43 reference_handle, 44-47 protocol, 48-52 pkt_offset 28-43 reference_handle, 44-47 protocol, 48-52 pkt_offset
......
...@@ -838,13 +838,8 @@ no_skb: ...@@ -838,13 +838,8 @@ no_skb:
return skb; return skb;
} }
/*
* netxen_process_rcv() send the received packet to the protocol stack.
* and if the number of receives exceeds RX_BUFFERS_REFILL, then we
* invoke the routine to send more rx buffers to the Phantom...
*/
static void netxen_process_rcv(struct netxen_adapter *adapter, int ctxid, static void netxen_process_rcv(struct netxen_adapter *adapter, int ctxid,
struct status_desc *desc, struct status_desc *frag_desc) struct status_desc *desc)
{ {
struct net_device *netdev = adapter->netdev; struct net_device *netdev = adapter->netdev;
u64 sts_data = le64_to_cpu(desc->status_desc_data); u64 sts_data = le64_to_cpu(desc->status_desc_data);
...@@ -859,15 +854,11 @@ static void netxen_process_rcv(struct netxen_adapter *adapter, int ctxid, ...@@ -859,15 +854,11 @@ static void netxen_process_rcv(struct netxen_adapter *adapter, int ctxid,
desc_ctx = netxen_get_sts_type(sts_data); desc_ctx = netxen_get_sts_type(sts_data);
if (unlikely(desc_ctx >= NUM_RCV_DESC_RINGS)) { if (unlikely(desc_ctx >= NUM_RCV_DESC_RINGS)) {
printk("%s: %s Bad Rcv descriptor ring\n",
netxen_nic_driver_name, netdev->name);
return; return;
} }
rds_ring = &recv_ctx->rds_rings[desc_ctx]; rds_ring = &recv_ctx->rds_rings[desc_ctx];
if (unlikely(index > rds_ring->max_rx_desc_count)) { if (unlikely(index > rds_ring->max_rx_desc_count)) {
DPRINTK(ERR, "Got a buffer index:%x Max is %x\n",
index, rds_ring->max_rx_desc_count);
return; return;
} }
buffer = &rds_ring->rx_buf_arr[index]; buffer = &rds_ring->rx_buf_arr[index];
...@@ -879,14 +870,6 @@ static void netxen_process_rcv(struct netxen_adapter *adapter, int ctxid, ...@@ -879,14 +870,6 @@ static void netxen_process_rcv(struct netxen_adapter *adapter, int ctxid,
buffer->lro_length = length; buffer->lro_length = length;
} }
if (buffer->lro_current_frags != buffer->lro_expected_frags) { if (buffer->lro_current_frags != buffer->lro_expected_frags) {
if (buffer->lro_expected_frags != 0) {
printk("LRO: (refhandle:%x) recv frag. "
"wait for last. flags: %x expected:%d "
"have:%d\n", index,
netxen_get_sts_desc_lro_last_frag(desc),
buffer->lro_expected_frags,
buffer->lro_current_frags);
}
return; return;
} }
} }
...@@ -913,28 +896,10 @@ static void netxen_process_rcv(struct netxen_adapter *adapter, int ctxid, ...@@ -913,28 +896,10 @@ static void netxen_process_rcv(struct netxen_adapter *adapter, int ctxid,
skb->protocol = eth_type_trans(skb, netdev); skb->protocol = eth_type_trans(skb, netdev);
/* netif_receive_skb(skb);
* rx buffer chaining is disabled, walk and free
* any spurious rx buffer chain.
*/
if (frag_desc) {
u16 i, nr_frags = desc->nr_frags;
dev_kfree_skb_any(skb);
for (i = 0; i < nr_frags; i++) {
index = le16_to_cpu(frag_desc->frag_handles[i]);
skb = netxen_process_rxbuf(adapter,
rds_ring, index, cksum);
if (skb)
dev_kfree_skb_any(skb);
}
adapter->stats.rxdropped++;
} else {
netif_receive_skb(skb);
adapter->stats.no_rcv++; adapter->stats.no_rcv++;
adapter->stats.rxbytes += length; adapter->stats.rxbytes += length;
}
} }
/* Process Receive status ring */ /* Process Receive status ring */
...@@ -942,7 +907,7 @@ u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max) ...@@ -942,7 +907,7 @@ u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max)
{ {
struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctxid]); struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctxid]);
struct status_desc *desc_head = recv_ctx->rcv_status_desc_head; struct status_desc *desc_head = recv_ctx->rcv_status_desc_head;
struct status_desc *desc, *frag_desc; struct status_desc *desc;
u32 consumer = recv_ctx->status_rx_consumer; u32 consumer = recv_ctx->status_rx_consumer;
int count = 0, ring; int count = 0, ring;
u64 sts_data; u64 sts_data;
...@@ -950,41 +915,27 @@ u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max) ...@@ -950,41 +915,27 @@ u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max)
while (count < max) { while (count < max) {
desc = &desc_head[consumer]; desc = &desc_head[consumer];
if (!(netxen_get_sts_owner(desc) & STATUS_OWNER_HOST)) { sts_data = le64_to_cpu(desc->status_desc_data);
DPRINTK(ERR, "desc %p ownedby %x\n", desc,
netxen_get_sts_owner(desc)); if (!(sts_data & STATUS_OWNER_HOST))
break; break;
}
sts_data = le64_to_cpu(desc->status_desc_data);
opcode = netxen_get_sts_opcode(sts_data); opcode = netxen_get_sts_opcode(sts_data);
frag_desc = NULL;
if (opcode == NETXEN_NIC_RXPKT_DESC) {
if (desc->nr_frags) {
consumer = get_next_index(consumer,
adapter->max_rx_desc_count);
frag_desc = &desc_head[consumer];
netxen_set_sts_owner(frag_desc,
STATUS_OWNER_PHANTOM);
}
}
netxen_process_rcv(adapter, ctxid, desc, frag_desc); netxen_process_rcv(adapter, ctxid, desc);
netxen_set_sts_owner(desc, STATUS_OWNER_PHANTOM); desc->status_desc_data = cpu_to_le64(STATUS_OWNER_PHANTOM);
consumer = get_next_index(consumer, consumer = get_next_index(consumer,
adapter->max_rx_desc_count); adapter->max_rx_desc_count);
count++; count++;
} }
for (ring = 0; ring < adapter->max_rds_rings; ring++) for (ring = 0; ring < adapter->max_rds_rings; ring++)
netxen_post_rx_buffers_nodb(adapter, ctxid, ring); netxen_post_rx_buffers_nodb(adapter, ctxid, ring);
/* update the consumer index in phantom */
if (count) { if (count) {
recv_ctx->status_rx_consumer = consumer; recv_ctx->status_rx_consumer = consumer;
/* Window = 1 */
adapter->pci_write_normalize(adapter, adapter->pci_write_normalize(adapter,
recv_ctx->crb_sts_consumer, consumer); recv_ctx->crb_sts_consumer, consumer);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment