aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDhananjay Phadke <dhananjay@netxen.com>2009-03-09 04:50:52 -0400
committerDavid S. Miller <davem@davemloft.net>2009-03-10 08:10:01 -0400
commit0ddc110c6fef34c554999448cdffe9c174a15fc9 (patch)
tree92edb728e2424f9b58c12e755b0035643d3da0bb
parentd5df2a16133f4eb22f9a6bbc07723443568d362f (diff)
netxen: cleanup rx handling
o remove unused rx fragment handling code. o imporove check for status descriptor ownership. Signed-off-by: Dhananjay Phadke <dhananjay@netxen.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/netxen/netxen_nic.h16
-rw-r--r--drivers/net/netxen/netxen_nic_init.c71
2 files changed, 13 insertions, 74 deletions
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index bd5fbb4ce865..73cb1164457f 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -392,11 +392,8 @@ struct rcv_desc {
392#define STATUS_CKSUM_OK (2) 392#define STATUS_CKSUM_OK (2)
393 393
394/* owner bits of status_desc */ 394/* owner bits of status_desc */
395#define STATUS_OWNER_HOST (0x1) 395#define STATUS_OWNER_HOST (0x1ULL << 56)
396#define STATUS_OWNER_PHANTOM (0x2) 396#define STATUS_OWNER_PHANTOM (0x2ULL << 56)
397
398#define NETXEN_PROT_IP (1)
399#define NETXEN_PROT_UNKNOWN (0)
400 397
401/* Note: sizeof(status_desc) should always be a mutliple of 2 */ 398/* Note: sizeof(status_desc) should always be a mutliple of 2 */
402 399
@@ -422,15 +419,6 @@ struct rcv_desc {
422#define netxen_get_sts_opcode(sts_data) \ 419#define netxen_get_sts_opcode(sts_data) \
423 (((sts_data) >> 58) & 0x03F) 420 (((sts_data) >> 58) & 0x03F)
424 421
425#define netxen_get_sts_owner(status_desc) \
426 ((le64_to_cpu((status_desc)->status_desc_data) >> 56) & 0x03)
427#define netxen_set_sts_owner(status_desc, val) { \
428 (status_desc)->status_desc_data = \
429 ((status_desc)->status_desc_data & \
430 ~cpu_to_le64(0x3ULL << 56)) | \
431 cpu_to_le64((u64)((val) & 0x3) << 56); \
432}
433
434struct status_desc { 422struct status_desc {
435 /* Bit pattern: 0-3 port, 4-7 status, 8-11 type, 12-27 total_length 423 /* Bit pattern: 0-3 port, 4-7 status, 8-11 type, 12-27 total_length
436 28-43 reference_handle, 44-47 protocol, 48-52 pkt_offset 424 28-43 reference_handle, 44-47 protocol, 48-52 pkt_offset
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c
index f323cee1b95a..f8164345e3b3 100644
--- a/drivers/net/netxen/netxen_nic_init.c
+++ b/drivers/net/netxen/netxen_nic_init.c
@@ -838,13 +838,8 @@ no_skb:
838 return skb; 838 return skb;
839} 839}
840 840
841/*
842 * netxen_process_rcv() send the received packet to the protocol stack.
843 * and if the number of receives exceeds RX_BUFFERS_REFILL, then we
844 * invoke the routine to send more rx buffers to the Phantom...
845 */
846static void netxen_process_rcv(struct netxen_adapter *adapter, int ctxid, 841static void netxen_process_rcv(struct netxen_adapter *adapter, int ctxid,
847 struct status_desc *desc, struct status_desc *frag_desc) 842 struct status_desc *desc)
848{ 843{
849 struct net_device *netdev = adapter->netdev; 844 struct net_device *netdev = adapter->netdev;
850 u64 sts_data = le64_to_cpu(desc->status_desc_data); 845 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 854
860 desc_ctx = netxen_get_sts_type(sts_data); 855 desc_ctx = netxen_get_sts_type(sts_data);
861 if (unlikely(desc_ctx >= NUM_RCV_DESC_RINGS)) { 856 if (unlikely(desc_ctx >= NUM_RCV_DESC_RINGS)) {
862 printk("%s: %s Bad Rcv descriptor ring\n",
863 netxen_nic_driver_name, netdev->name);
864 return; 857 return;
865 } 858 }
866 859
867 rds_ring = &recv_ctx->rds_rings[desc_ctx]; 860 rds_ring = &recv_ctx->rds_rings[desc_ctx];
868 if (unlikely(index > rds_ring->max_rx_desc_count)) { 861 if (unlikely(index > rds_ring->max_rx_desc_count)) {
869 DPRINTK(ERR, "Got a buffer index:%x Max is %x\n",
870 index, rds_ring->max_rx_desc_count);
871 return; 862 return;
872 } 863 }
873 buffer = &rds_ring->rx_buf_arr[index]; 864 buffer = &rds_ring->rx_buf_arr[index];
@@ -879,14 +870,6 @@ static void netxen_process_rcv(struct netxen_adapter *adapter, int ctxid,
879 buffer->lro_length = length; 870 buffer->lro_length = length;
880 } 871 }
881 if (buffer->lro_current_frags != buffer->lro_expected_frags) { 872 if (buffer->lro_current_frags != buffer->lro_expected_frags) {
882 if (buffer->lro_expected_frags != 0) {
883 printk("LRO: (refhandle:%x) recv frag. "
884 "wait for last. flags: %x expected:%d "
885 "have:%d\n", index,
886 netxen_get_sts_desc_lro_last_frag(desc),
887 buffer->lro_expected_frags,
888 buffer->lro_current_frags);
889 }
890 return; 873 return;
891 } 874 }
892 } 875 }
@@ -913,28 +896,10 @@ static void netxen_process_rcv(struct netxen_adapter *adapter, int ctxid,
913 896
914 skb->protocol = eth_type_trans(skb, netdev); 897 skb->protocol = eth_type_trans(skb, netdev);
915 898
916 /* 899 netif_receive_skb(skb);
917 * rx buffer chaining is disabled, walk and free
918 * any spurious rx buffer chain.
919 */
920 if (frag_desc) {
921 u16 i, nr_frags = desc->nr_frags;
922
923 dev_kfree_skb_any(skb);
924 for (i = 0; i < nr_frags; i++) {
925 index = le16_to_cpu(frag_desc->frag_handles[i]);
926 skb = netxen_process_rxbuf(adapter,
927 rds_ring, index, cksum);
928 if (skb)
929 dev_kfree_skb_any(skb);
930 }
931 adapter->stats.rxdropped++;
932 } else {
933 netif_receive_skb(skb);
934 900
935 adapter->stats.no_rcv++; 901 adapter->stats.no_rcv++;
936 adapter->stats.rxbytes += length; 902 adapter->stats.rxbytes += length;
937 }
938} 903}
939 904
940/* Process Receive status ring */ 905/* Process Receive status ring */
@@ -942,7 +907,7 @@ u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max)
942{ 907{
943 struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctxid]); 908 struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctxid]);
944 struct status_desc *desc_head = recv_ctx->rcv_status_desc_head; 909 struct status_desc *desc_head = recv_ctx->rcv_status_desc_head;
945 struct status_desc *desc, *frag_desc; 910 struct status_desc *desc;
946 u32 consumer = recv_ctx->status_rx_consumer; 911 u32 consumer = recv_ctx->status_rx_consumer;
947 int count = 0, ring; 912 int count = 0, ring;
948 u64 sts_data; 913 u64 sts_data;
@@ -950,41 +915,27 @@ u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max)
950 915
951 while (count < max) { 916 while (count < max) {
952 desc = &desc_head[consumer]; 917 desc = &desc_head[consumer];
953 if (!(netxen_get_sts_owner(desc) & STATUS_OWNER_HOST)) { 918 sts_data = le64_to_cpu(desc->status_desc_data);
954 DPRINTK(ERR, "desc %p ownedby %x\n", desc, 919
955 netxen_get_sts_owner(desc)); 920 if (!(sts_data & STATUS_OWNER_HOST))
956 break; 921 break;
957 }
958 922
959 sts_data = le64_to_cpu(desc->status_desc_data);
960 opcode = netxen_get_sts_opcode(sts_data); 923 opcode = netxen_get_sts_opcode(sts_data);
961 frag_desc = NULL;
962 if (opcode == NETXEN_NIC_RXPKT_DESC) {
963 if (desc->nr_frags) {
964 consumer = get_next_index(consumer,
965 adapter->max_rx_desc_count);
966 frag_desc = &desc_head[consumer];
967 netxen_set_sts_owner(frag_desc,
968 STATUS_OWNER_PHANTOM);
969 }
970 }
971 924
972 netxen_process_rcv(adapter, ctxid, desc, frag_desc); 925 netxen_process_rcv(adapter, ctxid, desc);
973 926
974 netxen_set_sts_owner(desc, STATUS_OWNER_PHANTOM); 927 desc->status_desc_data = cpu_to_le64(STATUS_OWNER_PHANTOM);
975 928
976 consumer = get_next_index(consumer, 929 consumer = get_next_index(consumer,
977 adapter->max_rx_desc_count); 930 adapter->max_rx_desc_count);
978 count++; 931 count++;
979 } 932 }
933
980 for (ring = 0; ring < adapter->max_rds_rings; ring++) 934 for (ring = 0; ring < adapter->max_rds_rings; ring++)
981 netxen_post_rx_buffers_nodb(adapter, ctxid, ring); 935 netxen_post_rx_buffers_nodb(adapter, ctxid, ring);
982 936
983 /* update the consumer index in phantom */
984 if (count) { 937 if (count) {
985 recv_ctx->status_rx_consumer = consumer; 938 recv_ctx->status_rx_consumer = consumer;
986
987 /* Window = 1 */
988 adapter->pci_write_normalize(adapter, 939 adapter->pci_write_normalize(adapter,
989 recv_ctx->crb_sts_consumer, consumer); 940 recv_ctx->crb_sts_consumer, consumer);
990 } 941 }