aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/netxen
diff options
context:
space:
mode:
authorDhananjay Phadke <dhananjay@netxen.com>2009-03-13 10:52:03 -0400
committerDavid S. Miller <davem@davemloft.net>2009-03-14 17:00:32 -0400
commit438627c77b877e445a4b918a50ff910a5ea2a12d (patch)
tree254abcb0c57f6c57947428f9c8ec38b6904801fc /drivers/net/netxen
parent0b72e659a10ec50acbef90756bf04177b66c8266 (diff)
netxen: sanitize variable names
o remove max_ prefix from ring sizes, since they don't really represent max possible sizes. o cleanup naming of rx ring types (normal, jumbo, lro). o simplify logic to choose rx ring size, gig ports get half rx ring of 10 gig ports. Signed-off-by: Dhananjay Phadke <dhananjay@netxen.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/netxen')
-rw-r--r--drivers/net/netxen/netxen_nic.h47
-rw-r--r--drivers/net/netxen/netxen_nic_ctx.c16
-rw-r--r--drivers/net/netxen/netxen_nic_ethtool.c6
-rw-r--r--drivers/net/netxen/netxen_nic_hw.c2
-rw-r--r--drivers/net/netxen/netxen_nic_init.c54
-rw-r--r--drivers/net/netxen/netxen_nic_main.c73
6 files changed, 62 insertions, 136 deletions
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index 75cb30f27ae2..f00efe84744f 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -79,15 +79,15 @@
79#define PHAN_VENDOR_ID 0x4040 79#define PHAN_VENDOR_ID 0x4040
80 80
81#define RCV_DESC_RINGSIZE \ 81#define RCV_DESC_RINGSIZE \
82 (sizeof(struct rcv_desc) * adapter->max_rx_desc_count) 82 (sizeof(struct rcv_desc) * adapter->num_rxd)
83#define STATUS_DESC_RINGSIZE \ 83#define STATUS_DESC_RINGSIZE \
84 (sizeof(struct status_desc)* adapter->max_rx_desc_count) 84 (sizeof(struct status_desc) * adapter->num_rxd)
85#define LRO_DESC_RINGSIZE \ 85#define LRO_DESC_RINGSIZE \
86 (sizeof(rcvDesc_t) * adapter->max_lro_rx_desc_count) 86 (sizeof(rcvDesc_t) * adapter->num_lro_rxd)
87#define TX_RINGSIZE \ 87#define TX_RINGSIZE \
88 (sizeof(struct netxen_cmd_buffer) * adapter->max_tx_desc_count) 88 (sizeof(struct netxen_cmd_buffer) * adapter->num_txd)
89#define RCV_BUFFSIZE \ 89#define RCV_BUFFSIZE \
90 (sizeof(struct netxen_rx_buffer) * rds_ring->max_rx_desc_count) 90 (sizeof(struct netxen_rx_buffer) * rds_ring->num_desc)
91#define find_diff_among(a,b,range) ((a)<(b)?((b)-(a)):((b)+(range)-(a))) 91#define find_diff_among(a,b,range) ((a)<(b)?((b)-(a)):((b)+(range)-(a)))
92 92
93#define NETXEN_RCV_PRODUCER_OFFSET 0 93#define NETXEN_RCV_PRODUCER_OFFSET 0
@@ -190,20 +190,9 @@
190 190
191#define NUM_RCV_DESC_RINGS 3 /* No of Rcv Descriptor contexts */ 191#define NUM_RCV_DESC_RINGS 3 /* No of Rcv Descriptor contexts */
192 192
193/* descriptor types */ 193#define RCV_RING_NORMAL 0
194#define RCV_DESC_NORMAL 0x01 194#define RCV_RING_JUMBO 1
195#define RCV_DESC_JUMBO 0x02 195#define RCV_RING_LRO 2
196#define RCV_DESC_LRO 0x04
197#define RCV_DESC_NORMAL_CTXID 0
198#define RCV_DESC_JUMBO_CTXID 1
199#define RCV_DESC_LRO_CTXID 2
200
201#define RCV_DESC_TYPE(ID) \
202 ((ID == RCV_DESC_JUMBO_CTXID) \
203 ? RCV_DESC_JUMBO \
204 : ((ID == RCV_DESC_LRO_CTXID) \
205 ? RCV_DESC_LRO : \
206 (RCV_DESC_NORMAL)))
207 196
208#define MAX_CMD_DESCRIPTORS 4096 197#define MAX_CMD_DESCRIPTORS 4096
209#define MAX_RCV_DESCRIPTORS 16384 198#define MAX_RCV_DESCRIPTORS 16384
@@ -815,8 +804,6 @@ struct netxen_hardware_context {
815 int pci_func; 804 int pci_func;
816}; 805};
817 806
818#define RCV_RING_LRO RCV_DESC_LRO
819
820#define MINIMUM_ETHERNET_FRAME_SIZE 64 /* With FCS */ 807#define MINIMUM_ETHERNET_FRAME_SIZE 64 /* With FCS */
821#define ETHERNET_FCS_SIZE 4 808#define ETHERNET_FCS_SIZE 4
822 809
@@ -842,16 +829,16 @@ struct netxen_adapter_stats {
842 * be one Rcv Descriptor for normal packets, one for jumbo and may be others. 829 * be one Rcv Descriptor for normal packets, one for jumbo and may be others.
843 */ 830 */
844struct nx_host_rds_ring { 831struct nx_host_rds_ring {
845 u32 flags;
846 u32 producer; 832 u32 producer;
847 dma_addr_t phys_addr;
848 u32 crb_rcv_producer; /* reg offset */ 833 u32 crb_rcv_producer; /* reg offset */
849 struct rcv_desc *desc_head; /* address of rx ring in Phantom */ 834 struct rcv_desc *desc_head; /* address of rx ring in Phantom */
850 u32 max_rx_desc_count;
851 u32 dma_size;
852 u32 skb_size;
853 struct netxen_rx_buffer *rx_buf_arr; /* rx buffers for receive */ 835 struct netxen_rx_buffer *rx_buf_arr; /* rx buffers for receive */
854 struct list_head free_list; 836 struct list_head free_list;
837 u32 num_desc;
838 u32 dma_size;
839 u32 skb_size;
840 u32 flags;
841 dma_addr_t phys_addr;
855}; 842};
856 843
857/* 844/*
@@ -1244,10 +1231,10 @@ struct netxen_adapter {
1244 u32 crb_addr_cmd_producer; 1231 u32 crb_addr_cmd_producer;
1245 u32 crb_addr_cmd_consumer; 1232 u32 crb_addr_cmd_consumer;
1246 1233
1247 u32 max_tx_desc_count; 1234 u32 num_txd;
1248 u32 max_rx_desc_count; 1235 u32 num_rxd;
1249 u32 max_jumbo_rx_desc_count; 1236 u32 num_jumbo_rxd;
1250 u32 max_lro_rx_desc_count; 1237 u32 num_lro_rxd;
1251 1238
1252 int max_rds_rings; 1239 int max_rds_rings;
1253 1240
diff --git a/drivers/net/netxen/netxen_nic_ctx.c b/drivers/net/netxen/netxen_nic_ctx.c
index d125dca0131a..2e66335bd000 100644
--- a/drivers/net/netxen/netxen_nic_ctx.c
+++ b/drivers/net/netxen/netxen_nic_ctx.c
@@ -231,7 +231,7 @@ nx_fw_cmd_create_rx_ctx(struct netxen_adapter *adapter)
231 rds_ring = &recv_ctx->rds_rings[i]; 231 rds_ring = &recv_ctx->rds_rings[i];
232 232
233 prq_rds[i].host_phys_addr = cpu_to_le64(rds_ring->phys_addr); 233 prq_rds[i].host_phys_addr = cpu_to_le64(rds_ring->phys_addr);
234 prq_rds[i].ring_size = cpu_to_le32(rds_ring->max_rx_desc_count); 234 prq_rds[i].ring_size = cpu_to_le32(rds_ring->num_desc);
235 prq_rds[i].ring_kind = cpu_to_le32(i); 235 prq_rds[i].ring_kind = cpu_to_le32(i);
236 prq_rds[i].buff_size = cpu_to_le64(rds_ring->dma_size); 236 prq_rds[i].buff_size = cpu_to_le64(rds_ring->dma_size);
237 } 237 }
@@ -241,7 +241,7 @@ nx_fw_cmd_create_rx_ctx(struct netxen_adapter *adapter)
241 241
242 prq_sds[0].host_phys_addr = 242 prq_sds[0].host_phys_addr =
243 cpu_to_le64(recv_ctx->rcv_status_desc_phys_addr); 243 cpu_to_le64(recv_ctx->rcv_status_desc_phys_addr);
244 prq_sds[0].ring_size = cpu_to_le32(adapter->max_rx_desc_count); 244 prq_sds[0].ring_size = cpu_to_le32(adapter->num_rxd);
245 /* only one msix vector for now */ 245 /* only one msix vector for now */
246 prq_sds[0].msi_index = cpu_to_le16(0); 246 prq_sds[0].msi_index = cpu_to_le16(0);
247 247
@@ -362,7 +362,7 @@ nx_fw_cmd_create_tx_ctx(struct netxen_adapter *adapter)
362 prq_cds->host_phys_addr = 362 prq_cds->host_phys_addr =
363 cpu_to_le64(adapter->ahw.cmd_desc_phys_addr); 363 cpu_to_le64(adapter->ahw.cmd_desc_phys_addr);
364 364
365 prq_cds->ring_size = cpu_to_le32(adapter->max_tx_desc_count); 365 prq_cds->ring_size = cpu_to_le32(adapter->num_txd);
366 366
367 phys_addr = rq_phys_addr; 367 phys_addr = rq_phys_addr;
368 err = netxen_issue_cmd(adapter, 368 err = netxen_issue_cmd(adapter,
@@ -494,7 +494,7 @@ netxen_init_old_ctx(struct netxen_adapter *adapter)
494 adapter->ctx_desc->cmd_ring_addr = 494 adapter->ctx_desc->cmd_ring_addr =
495 cpu_to_le64(adapter->ahw.cmd_desc_phys_addr); 495 cpu_to_le64(adapter->ahw.cmd_desc_phys_addr);
496 adapter->ctx_desc->cmd_ring_size = 496 adapter->ctx_desc->cmd_ring_size =
497 cpu_to_le32(adapter->max_tx_desc_count); 497 cpu_to_le32(adapter->num_txd);
498 498
499 recv_ctx = &adapter->recv_ctx; 499 recv_ctx = &adapter->recv_ctx;
500 500
@@ -504,12 +504,12 @@ netxen_init_old_ctx(struct netxen_adapter *adapter)
504 adapter->ctx_desc->rcv_ctx[ring].rcv_ring_addr = 504 adapter->ctx_desc->rcv_ctx[ring].rcv_ring_addr =
505 cpu_to_le64(rds_ring->phys_addr); 505 cpu_to_le64(rds_ring->phys_addr);
506 adapter->ctx_desc->rcv_ctx[ring].rcv_ring_size = 506 adapter->ctx_desc->rcv_ctx[ring].rcv_ring_size =
507 cpu_to_le32(rds_ring->max_rx_desc_count); 507 cpu_to_le32(rds_ring->num_desc);
508 } 508 }
509 adapter->ctx_desc->sts_ring_addr = 509 adapter->ctx_desc->sts_ring_addr =
510 cpu_to_le64(recv_ctx->rcv_status_desc_phys_addr); 510 cpu_to_le64(recv_ctx->rcv_status_desc_phys_addr);
511 adapter->ctx_desc->sts_ring_size = 511 adapter->ctx_desc->sts_ring_size =
512 cpu_to_le32(adapter->max_rx_desc_count); 512 cpu_to_le32(adapter->num_rxd);
513 513
514 adapter->pci_write_normalize(adapter, CRB_CTX_ADDR_REG_LO(func_id), 514 adapter->pci_write_normalize(adapter, CRB_CTX_ADDR_REG_LO(func_id),
515 lower32(adapter->ctx_desc_phys_addr)); 515 lower32(adapter->ctx_desc_phys_addr));
@@ -562,7 +562,7 @@ int netxen_alloc_hw_resources(struct netxen_adapter *adapter)
562 /* cmd desc ring */ 562 /* cmd desc ring */
563 addr = pci_alloc_consistent(adapter->pdev, 563 addr = pci_alloc_consistent(adapter->pdev,
564 sizeof(struct cmd_desc_type0) * 564 sizeof(struct cmd_desc_type0) *
565 adapter->max_tx_desc_count, 565 adapter->num_txd,
566 &hw->cmd_desc_phys_addr); 566 &hw->cmd_desc_phys_addr);
567 567
568 if (addr == NULL) { 568 if (addr == NULL) {
@@ -669,7 +669,7 @@ void netxen_free_hw_resources(struct netxen_adapter *adapter)
669 if (adapter->ahw.cmd_desc_head != NULL) { 669 if (adapter->ahw.cmd_desc_head != NULL) {
670 pci_free_consistent(adapter->pdev, 670 pci_free_consistent(adapter->pdev,
671 sizeof(struct cmd_desc_type0) * 671 sizeof(struct cmd_desc_type0) *
672 adapter->max_tx_desc_count, 672 adapter->num_txd,
673 adapter->ahw.cmd_desc_head, 673 adapter->ahw.cmd_desc_head,
674 adapter->ahw.cmd_desc_phys_addr); 674 adapter->ahw.cmd_desc_phys_addr);
675 adapter->ahw.cmd_desc_head = NULL; 675 adapter->ahw.cmd_desc_head = NULL;
diff --git a/drivers/net/netxen/netxen_nic_ethtool.c b/drivers/net/netxen/netxen_nic_ethtool.c
index 8b4bdfd6a117..a677ff895184 100644
--- a/drivers/net/netxen/netxen_nic_ethtool.c
+++ b/drivers/net/netxen/netxen_nic_ethtool.c
@@ -477,10 +477,10 @@ netxen_nic_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring)
477 ring->rx_pending = 0; 477 ring->rx_pending = 0;
478 ring->rx_jumbo_pending = 0; 478 ring->rx_jumbo_pending = 0;
479 ring->rx_pending += adapter->recv_ctx. 479 ring->rx_pending += adapter->recv_ctx.
480 rds_rings[RCV_DESC_NORMAL_CTXID].max_rx_desc_count; 480 rds_rings[RCV_RING_NORMAL].num_desc;
481 ring->rx_jumbo_pending += adapter->recv_ctx. 481 ring->rx_jumbo_pending += adapter->recv_ctx.
482 rds_rings[RCV_DESC_JUMBO_CTXID].max_rx_desc_count; 482 rds_rings[RCV_RING_JUMBO].num_desc;
483 ring->tx_pending = adapter->max_tx_desc_count; 483 ring->tx_pending = adapter->num_txd;
484 484
485 if (adapter->ahw.port_type == NETXEN_NIC_GBE) 485 if (adapter->ahw.port_type == NETXEN_NIC_GBE)
486 ring->rx_max_pending = MAX_RCV_DESCRIPTORS_1G; 486 ring->rx_max_pending = MAX_RCV_DESCRIPTORS_1G;
diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c
index c8faa53d27af..cea7300426b4 100644
--- a/drivers/net/netxen/netxen_nic_hw.c
+++ b/drivers/net/netxen/netxen_nic_hw.c
@@ -515,7 +515,7 @@ netxen_send_cmd_descs(struct netxen_adapter *adapter,
515 &cmd_desc_arr[i], sizeof(struct cmd_desc_type0)); 515 &cmd_desc_arr[i], sizeof(struct cmd_desc_type0));
516 516
517 producer = get_next_index(producer, 517 producer = get_next_index(producer,
518 adapter->max_tx_desc_count); 518 adapter->num_txd);
519 i++; 519 i++;
520 520
521 } while (i != nr_elements); 521 } while (i != nr_elements);
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c
index 120b480c1e82..d722589b1ce9 100644
--- a/drivers/net/netxen/netxen_nic_init.c
+++ b/drivers/net/netxen/netxen_nic_init.c
@@ -153,7 +153,7 @@ void netxen_release_rx_buffers(struct netxen_adapter *adapter)
153 recv_ctx = &adapter->recv_ctx; 153 recv_ctx = &adapter->recv_ctx;
154 for (ring = 0; ring < adapter->max_rds_rings; ring++) { 154 for (ring = 0; ring < adapter->max_rds_rings; ring++) {
155 rds_ring = &recv_ctx->rds_rings[ring]; 155 rds_ring = &recv_ctx->rds_rings[ring];
156 for (i = 0; i < rds_ring->max_rx_desc_count; ++i) { 156 for (i = 0; i < rds_ring->num_desc; ++i) {
157 rx_buf = &(rds_ring->rx_buf_arr[i]); 157 rx_buf = &(rds_ring->rx_buf_arr[i]);
158 if (rx_buf->state == NETXEN_BUFFER_FREE) 158 if (rx_buf->state == NETXEN_BUFFER_FREE)
159 continue; 159 continue;
@@ -174,7 +174,7 @@ void netxen_release_tx_buffers(struct netxen_adapter *adapter)
174 int i, j; 174 int i, j;
175 175
176 cmd_buf = adapter->cmd_buf_arr; 176 cmd_buf = adapter->cmd_buf_arr;
177 for (i = 0; i < adapter->max_tx_desc_count; i++) { 177 for (i = 0; i < adapter->num_txd; i++) {
178 buffrag = cmd_buf->frag_array; 178 buffrag = cmd_buf->frag_array;
179 if (buffrag->dma) { 179 if (buffrag->dma) {
180 pci_unmap_single(adapter->pdev, buffrag->dma, 180 pci_unmap_single(adapter->pdev, buffrag->dma,
@@ -190,7 +190,6 @@ void netxen_release_tx_buffers(struct netxen_adapter *adapter)
190 buffrag->dma = 0ULL; 190 buffrag->dma = 0ULL;
191 } 191 }
192 } 192 }
193 /* Free the skb we received in netxen_nic_xmit_frame */
194 if (cmd_buf->skb) { 193 if (cmd_buf->skb) {
195 dev_kfree_skb_any(cmd_buf->skb); 194 dev_kfree_skb_any(cmd_buf->skb);
196 cmd_buf->skb = NULL; 195 cmd_buf->skb = NULL;
@@ -241,11 +240,9 @@ int netxen_alloc_sw_resources(struct netxen_adapter *adapter)
241 recv_ctx = &adapter->recv_ctx; 240 recv_ctx = &adapter->recv_ctx;
242 for (ring = 0; ring < adapter->max_rds_rings; ring++) { 241 for (ring = 0; ring < adapter->max_rds_rings; ring++) {
243 rds_ring = &recv_ctx->rds_rings[ring]; 242 rds_ring = &recv_ctx->rds_rings[ring];
244 switch (RCV_DESC_TYPE(ring)) { 243 switch (ring) {
245 case RCV_DESC_NORMAL: 244 case RCV_RING_NORMAL:
246 rds_ring->max_rx_desc_count = 245 rds_ring->num_desc = adapter->num_rxd;
247 adapter->max_rx_desc_count;
248 rds_ring->flags = RCV_DESC_NORMAL;
249 if (adapter->ahw.cut_through) { 246 if (adapter->ahw.cut_through) {
250 rds_ring->dma_size = 247 rds_ring->dma_size =
251 NX_CT_DEFAULT_RX_BUF_LEN; 248 NX_CT_DEFAULT_RX_BUF_LEN;
@@ -258,10 +255,8 @@ int netxen_alloc_sw_resources(struct netxen_adapter *adapter)
258 } 255 }
259 break; 256 break;
260 257
261 case RCV_DESC_JUMBO: 258 case RCV_RING_JUMBO:
262 rds_ring->max_rx_desc_count = 259 rds_ring->num_desc = adapter->num_jumbo_rxd;
263 adapter->max_jumbo_rx_desc_count;
264 rds_ring->flags = RCV_DESC_JUMBO;
265 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) 260 if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
266 rds_ring->dma_size = 261 rds_ring->dma_size =
267 NX_P3_RX_JUMBO_BUF_MAX_LEN; 262 NX_P3_RX_JUMBO_BUF_MAX_LEN;
@@ -273,9 +268,7 @@ int netxen_alloc_sw_resources(struct netxen_adapter *adapter)
273 break; 268 break;
274 269
275 case RCV_RING_LRO: 270 case RCV_RING_LRO:
276 rds_ring->max_rx_desc_count = 271 rds_ring->num_desc = adapter->num_lro_rxd;
277 adapter->max_lro_rx_desc_count;
278 rds_ring->flags = RCV_DESC_LRO;
279 rds_ring->dma_size = RX_LRO_DMA_MAP_LEN; 272 rds_ring->dma_size = RX_LRO_DMA_MAP_LEN;
280 rds_ring->skb_size = MAX_RX_LRO_BUFFER_LENGTH; 273 rds_ring->skb_size = MAX_RX_LRO_BUFFER_LENGTH;
281 break; 274 break;
@@ -296,7 +289,7 @@ int netxen_alloc_sw_resources(struct netxen_adapter *adapter)
296 * Now go through all of them, set reference handles 289 * Now go through all of them, set reference handles
297 * and put them in the queues. 290 * and put them in the queues.
298 */ 291 */
299 num_rx_bufs = rds_ring->max_rx_desc_count; 292 num_rx_bufs = rds_ring->num_desc;
300 rx_buf = rds_ring->rx_buf_arr; 293 rx_buf = rds_ring->rx_buf_arr;
301 for (i = 0; i < num_rx_bufs; i++) { 294 for (i = 0; i < num_rx_bufs; i++) {
302 list_add_tail(&rx_buf->list, 295 list_add_tail(&rx_buf->list,
@@ -848,16 +841,15 @@ static void netxen_process_rcv(struct netxen_adapter *adapter,
848 struct nx_host_rds_ring *rds_ring; 841 struct nx_host_rds_ring *rds_ring;
849 842
850 desc_ctx = netxen_get_sts_type(sts_data); 843 desc_ctx = netxen_get_sts_type(sts_data);
851 if (unlikely(desc_ctx >= NUM_RCV_DESC_RINGS)) { 844 if (unlikely(desc_ctx >= adapter->max_rds_rings))
852 return; 845 return;
853 }
854 846
855 rds_ring = &recv_ctx->rds_rings[desc_ctx]; 847 rds_ring = &recv_ctx->rds_rings[desc_ctx];
856 if (unlikely(index > rds_ring->max_rx_desc_count)) { 848 if (unlikely(index > rds_ring->num_desc))
857 return; 849 return;
858 } 850
859 buffer = &rds_ring->rx_buf_arr[index]; 851 buffer = &rds_ring->rx_buf_arr[index];
860 if (desc_ctx == RCV_DESC_LRO_CTXID) { 852 if (desc_ctx == RCV_RING_LRO) {
861 buffer->lro_current_frags++; 853 buffer->lro_current_frags++;
862 if (netxen_get_sts_desc_lro_last_frag(desc)) { 854 if (netxen_get_sts_desc_lro_last_frag(desc)) {
863 buffer->lro_expected_frags = 855 buffer->lro_expected_frags =
@@ -875,7 +867,7 @@ static void netxen_process_rcv(struct netxen_adapter *adapter,
875 if (!skb) 867 if (!skb)
876 return; 868 return;
877 869
878 if (desc_ctx == RCV_DESC_LRO_CTXID) { 870 if (desc_ctx == RCV_RING_LRO) {
879 /* True length was only available on the last pkt */ 871 /* True length was only available on the last pkt */
880 skb_put(skb, buffer->lro_length); 872 skb_put(skb, buffer->lro_length);
881 } else { 873 } else {
@@ -921,8 +913,7 @@ netxen_process_rcv_ring(struct netxen_adapter *adapter, int max)
921 913
922 desc->status_desc_data = cpu_to_le64(STATUS_OWNER_PHANTOM); 914 desc->status_desc_data = cpu_to_le64(STATUS_OWNER_PHANTOM);
923 915
924 consumer = get_next_index(consumer, 916 consumer = get_next_index(consumer, adapter->num_rxd);
925 adapter->max_rx_desc_count);
926 count++; 917 count++;
927 } 918 }
928 919
@@ -973,7 +964,7 @@ int netxen_process_cmd_ring(struct netxen_adapter *adapter)
973 } 964 }
974 965
975 last_consumer = get_next_index(last_consumer, 966 last_consumer = get_next_index(last_consumer,
976 adapter->max_tx_desc_count); 967 adapter->num_txd);
977 if (++count >= MAX_STATUS_HANDLE) 968 if (++count >= MAX_STATUS_HANDLE)
978 break; 969 break;
979 } 970 }
@@ -1060,7 +1051,7 @@ netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ringid)
1060 pdesc->reference_handle = cpu_to_le16(buffer->ref_handle); 1051 pdesc->reference_handle = cpu_to_le16(buffer->ref_handle);
1061 pdesc->buffer_length = cpu_to_le32(rds_ring->dma_size); 1052 pdesc->buffer_length = cpu_to_le32(rds_ring->dma_size);
1062 1053
1063 producer = get_next_index(producer, rds_ring->max_rx_desc_count); 1054 producer = get_next_index(producer, rds_ring->num_desc);
1064 } 1055 }
1065 /* if we did allocate buffers, then write the count to Phantom */ 1056 /* if we did allocate buffers, then write the count to Phantom */
1066 if (count) { 1057 if (count) {
@@ -1068,7 +1059,7 @@ netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ringid)
1068 /* Window = 1 */ 1059 /* Window = 1 */
1069 adapter->pci_write_normalize(adapter, 1060 adapter->pci_write_normalize(adapter,
1070 rds_ring->crb_rcv_producer, 1061 rds_ring->crb_rcv_producer,
1071 (producer-1) & (rds_ring->max_rx_desc_count-1)); 1062 (producer-1) & (rds_ring->num_desc-1));
1072 1063
1073 if (adapter->fw_major < 4) { 1064 if (adapter->fw_major < 4) {
1074 /* 1065 /*
@@ -1079,9 +1070,8 @@ netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ringid)
1079 netxen_set_msg_peg_id(msg, NETXEN_RCV_PEG_DB_ID); 1070 netxen_set_msg_peg_id(msg, NETXEN_RCV_PEG_DB_ID);
1080 netxen_set_msg_privid(msg); 1071 netxen_set_msg_privid(msg);
1081 netxen_set_msg_count(msg, 1072 netxen_set_msg_count(msg,
1082 ((producer - 1073 ((producer - 1) &
1083 1) & (rds_ring-> 1074 (rds_ring->num_desc - 1)));
1084 max_rx_desc_count - 1)));
1085 netxen_set_msg_ctxid(msg, adapter->portnum); 1075 netxen_set_msg_ctxid(msg, adapter->portnum);
1086 netxen_set_msg_opcode(msg, NETXEN_RCV_PRODUCER(ringid)); 1076 netxen_set_msg_opcode(msg, NETXEN_RCV_PRODUCER(ringid));
1087 writel(msg, 1077 writel(msg,
@@ -1141,7 +1131,7 @@ netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, uint32_t ringid)
1141 pdesc->buffer_length = cpu_to_le32(rds_ring->dma_size); 1131 pdesc->buffer_length = cpu_to_le32(rds_ring->dma_size);
1142 pdesc->addr_buffer = cpu_to_le64(buffer->dma); 1132 pdesc->addr_buffer = cpu_to_le64(buffer->dma);
1143 1133
1144 producer = get_next_index(producer, rds_ring->max_rx_desc_count); 1134 producer = get_next_index(producer, rds_ring->num_desc);
1145 } 1135 }
1146 1136
1147 /* if we did allocate buffers, then write the count to Phantom */ 1137 /* if we did allocate buffers, then write the count to Phantom */
@@ -1150,7 +1140,7 @@ netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, uint32_t ringid)
1150 /* Window = 1 */ 1140 /* Window = 1 */
1151 adapter->pci_write_normalize(adapter, 1141 adapter->pci_write_normalize(adapter,
1152 rds_ring->crb_rcv_producer, 1142 rds_ring->crb_rcv_producer,
1153 (producer-1) & (rds_ring->max_rx_desc_count-1)); 1143 (producer - 1) & (rds_ring->num_desc - 1));
1154 wmb(); 1144 wmb();
1155 } 1145 }
1156} 1146}
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c
index 555b4596b0fe..00eaeee235ef 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -212,62 +212,19 @@ nx_update_dma_mask(struct netxen_adapter *adapter)
212 212
213static void netxen_check_options(struct netxen_adapter *adapter) 213static void netxen_check_options(struct netxen_adapter *adapter)
214{ 214{
215 switch (adapter->ahw.board_type) { 215 if (adapter->ahw.port_type == NETXEN_NIC_XGBE)
216 case NETXEN_BRDTYPE_P3_HMEZ: 216 adapter->num_rxd = MAX_RCV_DESCRIPTORS_10G;
217 case NETXEN_BRDTYPE_P3_XG_LOM: 217 else if (adapter->ahw.port_type == NETXEN_NIC_GBE)
218 case NETXEN_BRDTYPE_P3_10G_CX4: 218 adapter->num_rxd = MAX_RCV_DESCRIPTORS_1G;
219 case NETXEN_BRDTYPE_P3_10G_CX4_LP:
220 case NETXEN_BRDTYPE_P3_IMEZ:
221 case NETXEN_BRDTYPE_P3_10G_SFP_PLUS:
222 case NETXEN_BRDTYPE_P3_10G_SFP_QT:
223 case NETXEN_BRDTYPE_P3_10G_SFP_CT:
224 case NETXEN_BRDTYPE_P3_10G_XFP:
225 case NETXEN_BRDTYPE_P3_10000_BASE_T:
226 adapter->msix_supported = !!use_msi_x;
227 adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS_10G;
228 break;
229
230 case NETXEN_BRDTYPE_P2_SB31_10G:
231 case NETXEN_BRDTYPE_P2_SB31_10G_CX4:
232 case NETXEN_BRDTYPE_P2_SB31_10G_IMEZ:
233 case NETXEN_BRDTYPE_P2_SB31_10G_HMEZ:
234 adapter->msix_supported = 0;
235 adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS_10G;
236 break;
237 219
238 case NETXEN_BRDTYPE_P3_REF_QG: 220 if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
239 case NETXEN_BRDTYPE_P3_4_GB:
240 case NETXEN_BRDTYPE_P3_4_GB_MM:
241 adapter->msix_supported = !!use_msi_x;
242 adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS_1G;
243 break;
244
245 case NETXEN_BRDTYPE_P2_SB35_4G:
246 case NETXEN_BRDTYPE_P2_SB31_2G:
247 adapter->msix_supported = 0;
248 adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS_1G;
249 break;
250
251 case NETXEN_BRDTYPE_P3_10G_TP:
252 adapter->msix_supported = !!use_msi_x; 221 adapter->msix_supported = !!use_msi_x;
253 if (adapter->ahw.port_type == NETXEN_NIC_XGBE) 222 else
254 adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS_10G;
255 else
256 adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS_1G;
257 break;
258
259 default:
260 adapter->msix_supported = 0; 223 adapter->msix_supported = 0;
261 adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS_1G;
262
263 printk(KERN_WARNING "Unknown board type(0x%x)\n",
264 adapter->ahw.board_type);
265 break;
266 }
267 224
268 adapter->max_tx_desc_count = MAX_CMD_DESCRIPTORS_HOST; 225 adapter->num_txd = MAX_CMD_DESCRIPTORS_HOST;
269 adapter->max_jumbo_rx_desc_count = MAX_JUMBO_RCV_DESCRIPTORS; 226 adapter->num_jumbo_rxd = MAX_JUMBO_RCV_DESCRIPTORS;
270 adapter->max_lro_rx_desc_count = MAX_LRO_RCV_DESCRIPTORS; 227 adapter->num_lro_rxd = MAX_LRO_RCV_DESCRIPTORS;
271 228
272 adapter->max_possible_rss_rings = 1; 229 adapter->max_possible_rss_rings = 1;
273 return; 230 return;
@@ -983,12 +940,6 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
983 break; 940 break;
984 } 941 }
985 942
986 /*
987 * This call will setup various max rx/tx counts.
988 * It must be done before any buffer/ring allocations.
989 */
990 netxen_check_options(adapter);
991
992 err = netxen_start_firmware(adapter); 943 err = netxen_start_firmware(adapter);
993 if (err) 944 if (err)
994 goto err_out_iounmap; 945 goto err_out_iounmap;
@@ -1008,9 +959,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1008 adapter->physical_port = i; 959 adapter->physical_port = i;
1009 } 960 }
1010 961
1011 adapter->flags &= ~(NETXEN_NIC_MSI_ENABLED | NETXEN_NIC_MSIX_ENABLED); 962 netxen_check_options(adapter);
1012
1013 netxen_set_msix_bit(pdev, 0);
1014 963
1015 netxen_setup_intr(adapter); 964 netxen_setup_intr(adapter);
1016 965
@@ -1307,7 +1256,7 @@ netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1307 1256
1308 u32 producer, consumer; 1257 u32 producer, consumer;
1309 int frag_count, no_of_desc; 1258 int frag_count, no_of_desc;
1310 u32 num_txd = adapter->max_tx_desc_count; 1259 u32 num_txd = adapter->num_txd;
1311 bool is_tso = false; 1260 bool is_tso = false;
1312 1261
1313 frag_count = skb_shinfo(skb)->nr_frags + 1; 1262 frag_count = skb_shinfo(skb)->nr_frags + 1;