aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/netxen/netxen_nic_init.c
diff options
context:
space:
mode:
authorDhananjay Phadke <dhananjay@netxen.com>2009-03-09 04:50:55 -0400
committerDavid S. Miller <davem@davemloft.net>2009-03-10 08:10:03 -0400
commitbecf46a012db667c562bbbe589c14e100b62e5a4 (patch)
tree1f6946aac18946fe2df637da385ac1020f755f76 /drivers/net/netxen/netxen_nic_init.c
parent9f5bc7f1908665d7cf379f698c7bdc53bc10da85 (diff)
netxen: cleanup superfluous multi-context code
MAX_RCV_CTX was set to 1, there's only rx context per PCI function. Signed-off-by: Dhananjay Phadke <dhananjay@netxen.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/netxen/netxen_nic_init.c')
-rw-r--r--drivers/net/netxen/netxen_nic_init.c213
1 files changed, 103 insertions, 110 deletions
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c
index 72aba634554a..bd5e0d692230 100644
--- a/drivers/net/netxen/netxen_nic_init.c
+++ b/drivers/net/netxen/netxen_nic_init.c
@@ -49,8 +49,8 @@ static unsigned int crb_addr_xform[NETXEN_MAX_CRB_XFORM];
49 49
50#define NETXEN_NIC_XDMA_RESET 0x8000ff 50#define NETXEN_NIC_XDMA_RESET 0x8000ff
51 51
52static void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, 52static void
53 uint32_t ctx, uint32_t ringid); 53netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, uint32_t ringid);
54 54
55static void crb_addr_transform_setup(void) 55static void crb_addr_transform_setup(void)
56{ 56{
@@ -148,23 +148,21 @@ void netxen_release_rx_buffers(struct netxen_adapter *adapter)
148 struct netxen_recv_context *recv_ctx; 148 struct netxen_recv_context *recv_ctx;
149 struct nx_host_rds_ring *rds_ring; 149 struct nx_host_rds_ring *rds_ring;
150 struct netxen_rx_buffer *rx_buf; 150 struct netxen_rx_buffer *rx_buf;
151 int i, ctxid, ring; 151 int i, ring;
152 152
153 for (ctxid = 0; ctxid < MAX_RCV_CTX; ++ctxid) { 153 recv_ctx = &adapter->recv_ctx;
154 recv_ctx = &adapter->recv_ctx[ctxid]; 154 for (ring = 0; ring < adapter->max_rds_rings; ring++) {
155 for (ring = 0; ring < adapter->max_rds_rings; ring++) { 155 rds_ring = &recv_ctx->rds_rings[ring];
156 rds_ring = &recv_ctx->rds_rings[ring]; 156 for (i = 0; i < rds_ring->max_rx_desc_count; ++i) {
157 for (i = 0; i < rds_ring->max_rx_desc_count; ++i) { 157 rx_buf = &(rds_ring->rx_buf_arr[i]);
158 rx_buf = &(rds_ring->rx_buf_arr[i]); 158 if (rx_buf->state == NETXEN_BUFFER_FREE)
159 if (rx_buf->state == NETXEN_BUFFER_FREE) 159 continue;
160 continue; 160 pci_unmap_single(adapter->pdev,
161 pci_unmap_single(adapter->pdev, 161 rx_buf->dma,
162 rx_buf->dma, 162 rds_ring->dma_size,
163 rds_ring->dma_size, 163 PCI_DMA_FROMDEVICE);
164 PCI_DMA_FROMDEVICE); 164 if (rx_buf->skb != NULL)
165 if (rx_buf->skb != NULL) 165 dev_kfree_skb_any(rx_buf->skb);
166 dev_kfree_skb_any(rx_buf->skb);
167 }
168 } 166 }
169 } 167 }
170} 168}
@@ -205,18 +203,17 @@ void netxen_free_sw_resources(struct netxen_adapter *adapter)
205{ 203{
206 struct netxen_recv_context *recv_ctx; 204 struct netxen_recv_context *recv_ctx;
207 struct nx_host_rds_ring *rds_ring; 205 struct nx_host_rds_ring *rds_ring;
208 int ctx, ring; 206 int ring;
209 207
210 for (ctx = 0; ctx < MAX_RCV_CTX; ctx++) { 208 recv_ctx = &adapter->recv_ctx;
211 recv_ctx = &adapter->recv_ctx[ctx]; 209 for (ring = 0; ring < adapter->max_rds_rings; ring++) {
212 for (ring = 0; ring < adapter->max_rds_rings; ring++) { 210 rds_ring = &recv_ctx->rds_rings[ring];
213 rds_ring = &recv_ctx->rds_rings[ring]; 211 if (rds_ring->rx_buf_arr) {
214 if (rds_ring->rx_buf_arr) { 212 vfree(rds_ring->rx_buf_arr);
215 vfree(rds_ring->rx_buf_arr); 213 rds_ring->rx_buf_arr = NULL;
216 rds_ring->rx_buf_arr = NULL;
217 }
218 } 214 }
219 } 215 }
216
220 if (adapter->cmd_buf_arr) 217 if (adapter->cmd_buf_arr)
221 vfree(adapter->cmd_buf_arr); 218 vfree(adapter->cmd_buf_arr);
222 return; 219 return;
@@ -227,7 +224,7 @@ int netxen_alloc_sw_resources(struct netxen_adapter *adapter)
227 struct netxen_recv_context *recv_ctx; 224 struct netxen_recv_context *recv_ctx;
228 struct nx_host_rds_ring *rds_ring; 225 struct nx_host_rds_ring *rds_ring;
229 struct netxen_rx_buffer *rx_buf; 226 struct netxen_rx_buffer *rx_buf;
230 int ctx, ring, i, num_rx_bufs; 227 int ring, i, num_rx_bufs;
231 228
232 struct netxen_cmd_buffer *cmd_buf_arr; 229 struct netxen_cmd_buffer *cmd_buf_arr;
233 struct net_device *netdev = adapter->netdev; 230 struct net_device *netdev = adapter->netdev;
@@ -241,74 +238,72 @@ int netxen_alloc_sw_resources(struct netxen_adapter *adapter)
241 memset(cmd_buf_arr, 0, TX_RINGSIZE); 238 memset(cmd_buf_arr, 0, TX_RINGSIZE);
242 adapter->cmd_buf_arr = cmd_buf_arr; 239 adapter->cmd_buf_arr = cmd_buf_arr;
243 240
244 for (ctx = 0; ctx < MAX_RCV_CTX; ctx++) { 241 recv_ctx = &adapter->recv_ctx;
245 recv_ctx = &adapter->recv_ctx[ctx]; 242 for (ring = 0; ring < adapter->max_rds_rings; ring++) {
246 for (ring = 0; ring < adapter->max_rds_rings; ring++) { 243 rds_ring = &recv_ctx->rds_rings[ring];
247 rds_ring = &recv_ctx->rds_rings[ring]; 244 switch (RCV_DESC_TYPE(ring)) {
248 switch (RCV_DESC_TYPE(ring)) { 245 case RCV_DESC_NORMAL:
249 case RCV_DESC_NORMAL: 246 rds_ring->max_rx_desc_count =
250 rds_ring->max_rx_desc_count = 247 adapter->max_rx_desc_count;
251 adapter->max_rx_desc_count; 248 rds_ring->flags = RCV_DESC_NORMAL;
252 rds_ring->flags = RCV_DESC_NORMAL; 249 if (adapter->ahw.cut_through) {
253 if (adapter->ahw.cut_through) { 250 rds_ring->dma_size =
254 rds_ring->dma_size = 251 NX_CT_DEFAULT_RX_BUF_LEN;
255 NX_CT_DEFAULT_RX_BUF_LEN;
256 rds_ring->skb_size =
257 NX_CT_DEFAULT_RX_BUF_LEN;
258 } else {
259 rds_ring->dma_size = RX_DMA_MAP_LEN;
260 rds_ring->skb_size =
261 MAX_RX_BUFFER_LENGTH;
262 }
263 break;
264
265 case RCV_DESC_JUMBO:
266 rds_ring->max_rx_desc_count =
267 adapter->max_jumbo_rx_desc_count;
268 rds_ring->flags = RCV_DESC_JUMBO;
269 if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
270 rds_ring->dma_size =
271 NX_P3_RX_JUMBO_BUF_MAX_LEN;
272 else
273 rds_ring->dma_size =
274 NX_P2_RX_JUMBO_BUF_MAX_LEN;
275 rds_ring->skb_size = 252 rds_ring->skb_size =
276 rds_ring->dma_size + NET_IP_ALIGN; 253 NX_CT_DEFAULT_RX_BUF_LEN;
277 break; 254 } else {
255 rds_ring->dma_size = RX_DMA_MAP_LEN;
256 rds_ring->skb_size =
257 MAX_RX_BUFFER_LENGTH;
258 }
259 break;
278 260
279 case RCV_RING_LRO: 261 case RCV_DESC_JUMBO:
280 rds_ring->max_rx_desc_count = 262 rds_ring->max_rx_desc_count =
281 adapter->max_lro_rx_desc_count; 263 adapter->max_jumbo_rx_desc_count;
282 rds_ring->flags = RCV_DESC_LRO; 264 rds_ring->flags = RCV_DESC_JUMBO;
283 rds_ring->dma_size = RX_LRO_DMA_MAP_LEN; 265 if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
284 rds_ring->skb_size = MAX_RX_LRO_BUFFER_LENGTH; 266 rds_ring->dma_size =
285 break; 267 NX_P3_RX_JUMBO_BUF_MAX_LEN;
268 else
269 rds_ring->dma_size =
270 NX_P2_RX_JUMBO_BUF_MAX_LEN;
271 rds_ring->skb_size =
272 rds_ring->dma_size + NET_IP_ALIGN;
273 break;
286 274
287 } 275 case RCV_RING_LRO:
288 rds_ring->rx_buf_arr = (struct netxen_rx_buffer *) 276 rds_ring->max_rx_desc_count =
289 vmalloc(RCV_BUFFSIZE); 277 adapter->max_lro_rx_desc_count;
290 if (rds_ring->rx_buf_arr == NULL) { 278 rds_ring->flags = RCV_DESC_LRO;
291 printk(KERN_ERR "%s: Failed to allocate " 279 rds_ring->dma_size = RX_LRO_DMA_MAP_LEN;
292 "rx buffer ring %d\n", 280 rds_ring->skb_size = MAX_RX_LRO_BUFFER_LENGTH;
293 netdev->name, ring); 281 break;
294 /* free whatever was already allocated */ 282
295 goto err_out; 283 }
296 } 284 rds_ring->rx_buf_arr = (struct netxen_rx_buffer *)
297 memset(rds_ring->rx_buf_arr, 0, RCV_BUFFSIZE); 285 vmalloc(RCV_BUFFSIZE);
298 INIT_LIST_HEAD(&rds_ring->free_list); 286 if (rds_ring->rx_buf_arr == NULL) {
299 /* 287 printk(KERN_ERR "%s: Failed to allocate "
300 * Now go through all of them, set reference handles 288 "rx buffer ring %d\n",
301 * and put them in the queues. 289 netdev->name, ring);
302 */ 290 /* free whatever was already allocated */
303 num_rx_bufs = rds_ring->max_rx_desc_count; 291 goto err_out;
304 rx_buf = rds_ring->rx_buf_arr; 292 }
305 for (i = 0; i < num_rx_bufs; i++) { 293 memset(rds_ring->rx_buf_arr, 0, RCV_BUFFSIZE);
306 list_add_tail(&rx_buf->list, 294 INIT_LIST_HEAD(&rds_ring->free_list);
307 &rds_ring->free_list); 295 /*
308 rx_buf->ref_handle = i; 296 * Now go through all of them, set reference handles
309 rx_buf->state = NETXEN_BUFFER_FREE; 297 * and put them in the queues.
310 rx_buf++; 298 */
311 } 299 num_rx_bufs = rds_ring->max_rx_desc_count;
300 rx_buf = rds_ring->rx_buf_arr;
301 for (i = 0; i < num_rx_bufs; i++) {
302 list_add_tail(&rx_buf->list,
303 &rds_ring->free_list);
304 rx_buf->ref_handle = i;
305 rx_buf->state = NETXEN_BUFFER_FREE;
306 rx_buf++;
312 } 307 }
313 } 308 }
314 309
@@ -838,13 +833,13 @@ no_skb:
838 return skb; 833 return skb;
839} 834}
840 835
841static void netxen_process_rcv(struct netxen_adapter *adapter, int ctxid, 836static void netxen_process_rcv(struct netxen_adapter *adapter,
842 struct status_desc *desc) 837 struct status_desc *desc)
843{ 838{
844 struct net_device *netdev = adapter->netdev; 839 struct net_device *netdev = adapter->netdev;
845 u64 sts_data = le64_to_cpu(desc->status_desc_data); 840 u64 sts_data = le64_to_cpu(desc->status_desc_data);
846 int index = netxen_get_sts_refhandle(sts_data); 841 int index = netxen_get_sts_refhandle(sts_data);
847 struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctxid]); 842 struct netxen_recv_context *recv_ctx = &adapter->recv_ctx;
848 struct netxen_rx_buffer *buffer; 843 struct netxen_rx_buffer *buffer;
849 struct sk_buff *skb; 844 struct sk_buff *skb;
850 u32 length = netxen_get_sts_totallength(sts_data); 845 u32 length = netxen_get_sts_totallength(sts_data);
@@ -902,10 +897,10 @@ static void netxen_process_rcv(struct netxen_adapter *adapter, int ctxid,
902 adapter->stats.rxbytes += length; 897 adapter->stats.rxbytes += length;
903} 898}
904 899
905/* Process Receive status ring */ 900int
906u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max) 901netxen_process_rcv_ring(struct netxen_adapter *adapter, int max)
907{ 902{
908 struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctxid]); 903 struct netxen_recv_context *recv_ctx = &adapter->recv_ctx;
909 struct status_desc *desc_head = recv_ctx->rcv_status_desc_head; 904 struct status_desc *desc_head = recv_ctx->rcv_status_desc_head;
910 struct status_desc *desc; 905 struct status_desc *desc;
911 u32 consumer = recv_ctx->status_rx_consumer; 906 u32 consumer = recv_ctx->status_rx_consumer;
@@ -922,7 +917,7 @@ u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max)
922 917
923 opcode = netxen_get_sts_opcode(sts_data); 918 opcode = netxen_get_sts_opcode(sts_data);
924 919
925 netxen_process_rcv(adapter, ctxid, desc); 920 netxen_process_rcv(adapter, desc);
926 921
927 desc->status_desc_data = cpu_to_le64(STATUS_OWNER_PHANTOM); 922 desc->status_desc_data = cpu_to_le64(STATUS_OWNER_PHANTOM);
928 923
@@ -932,7 +927,7 @@ u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max)
932 } 927 }
933 928
934 for (ring = 0; ring < adapter->max_rds_rings; ring++) 929 for (ring = 0; ring < adapter->max_rds_rings; ring++)
935 netxen_post_rx_buffers_nodb(adapter, ctxid, ring); 930 netxen_post_rx_buffers_nodb(adapter, ring);
936 931
937 if (count) { 932 if (count) {
938 recv_ctx->status_rx_consumer = consumer; 933 recv_ctx->status_rx_consumer = consumer;
@@ -1013,14 +1008,12 @@ int netxen_process_cmd_ring(struct netxen_adapter *adapter)
1013 return (done); 1008 return (done);
1014} 1009}
1015 1010
1016/* 1011void
1017 * netxen_post_rx_buffers puts buffer in the Phantom memory 1012netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ringid)
1018 */
1019void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid)
1020{ 1013{
1021 struct pci_dev *pdev = adapter->pdev; 1014 struct pci_dev *pdev = adapter->pdev;
1022 struct sk_buff *skb; 1015 struct sk_buff *skb;
1023 struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctx]); 1016 struct netxen_recv_context *recv_ctx = &adapter->recv_ctx;
1024 struct nx_host_rds_ring *rds_ring = NULL; 1017 struct nx_host_rds_ring *rds_ring = NULL;
1025 uint producer; 1018 uint producer;
1026 struct rcv_desc *pdesc; 1019 struct rcv_desc *pdesc;
@@ -1098,12 +1091,12 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid)
1098 } 1091 }
1099} 1092}
1100 1093
1101static void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, 1094static void
1102 uint32_t ctx, uint32_t ringid) 1095netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, uint32_t ringid)
1103{ 1096{
1104 struct pci_dev *pdev = adapter->pdev; 1097 struct pci_dev *pdev = adapter->pdev;
1105 struct sk_buff *skb; 1098 struct sk_buff *skb;
1106 struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctx]); 1099 struct netxen_recv_context *recv_ctx = &adapter->recv_ctx;
1107 struct nx_host_rds_ring *rds_ring = NULL; 1100 struct nx_host_rds_ring *rds_ring = NULL;
1108 u32 producer; 1101 u32 producer;
1109 struct rcv_desc *pdesc; 1102 struct rcv_desc *pdesc;