aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/qlcnic
diff options
context:
space:
mode:
authorAmit Kumar Salecha <amit.salecha@qlogic.com>2010-06-21 23:18:58 -0400
committerDavid S. Miller <davem@davemloft.net>2010-06-23 16:16:28 -0400
commit9665982885f0e11ea9e3c5d9bfc7ead48d08c83f (patch)
tree2b58902a183a9733cfd8862277540734c68b5234 /drivers/net/qlcnic
parent406818ff347cbbdae2fb21fafd1939d00cf479c5 (diff)
qlcnic: cleanup skb allocation
No need to maintian separate state for alloced and freed skb. This can be done by null check. Signed-off-by: Amit Kumar Salecha <amit.salecha@qlogic.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/qlcnic')
-rw-r--r--drivers/net/qlcnic/qlcnic.h2
-rw-r--r--drivers/net/qlcnic/qlcnic_ethtool.c2
-rw-r--r--drivers/net/qlcnic/qlcnic_init.c30
3 files changed, 13 insertions, 21 deletions
diff --git a/drivers/net/qlcnic/qlcnic.h b/drivers/net/qlcnic/qlcnic.h
index 99ccdd8ac41..86e47811c25 100644
--- a/drivers/net/qlcnic/qlcnic.h
+++ b/drivers/net/qlcnic/qlcnic.h
@@ -381,7 +381,6 @@ struct qlcnic_rx_buffer {
381 struct sk_buff *skb; 381 struct sk_buff *skb;
382 u64 dma; 382 u64 dma;
383 u16 ref_handle; 383 u16 ref_handle;
384 u16 state;
385}; 384};
386 385
387/* Board types */ 386/* Board types */
@@ -423,7 +422,6 @@ struct qlcnic_adapter_stats {
423 u64 xmit_on; 422 u64 xmit_on;
424 u64 xmit_off; 423 u64 xmit_off;
425 u64 skb_alloc_failure; 424 u64 skb_alloc_failure;
426 u64 null_skb;
427 u64 null_rxbuf; 425 u64 null_rxbuf;
428 u64 rx_dma_map_error; 426 u64 rx_dma_map_error;
429 u64 tx_dma_map_error; 427 u64 tx_dma_map_error;
diff --git a/drivers/net/qlcnic/qlcnic_ethtool.c b/drivers/net/qlcnic/qlcnic_ethtool.c
index 3e4822ad5a8..a4f11202271 100644
--- a/drivers/net/qlcnic/qlcnic_ethtool.c
+++ b/drivers/net/qlcnic/qlcnic_ethtool.c
@@ -69,8 +69,6 @@ static const struct qlcnic_stats qlcnic_gstrings_stats[] = {
69 QLC_SIZEOF(stats.xmit_off), QLC_OFF(stats.xmit_off)}, 69 QLC_SIZEOF(stats.xmit_off), QLC_OFF(stats.xmit_off)},
70 {"skb_alloc_failure", QLC_SIZEOF(stats.skb_alloc_failure), 70 {"skb_alloc_failure", QLC_SIZEOF(stats.skb_alloc_failure),
71 QLC_OFF(stats.skb_alloc_failure)}, 71 QLC_OFF(stats.skb_alloc_failure)},
72 {"null skb",
73 QLC_SIZEOF(stats.null_skb), QLC_OFF(stats.null_skb)},
74 {"null rxbuf", 72 {"null rxbuf",
75 QLC_SIZEOF(stats.null_rxbuf), QLC_OFF(stats.null_rxbuf)}, 73 QLC_SIZEOF(stats.null_rxbuf), QLC_OFF(stats.null_rxbuf)},
76 {"rx dma map error", QLC_SIZEOF(stats.rx_dma_map_error), 74 {"rx dma map error", QLC_SIZEOF(stats.rx_dma_map_error),
diff --git a/drivers/net/qlcnic/qlcnic_init.c b/drivers/net/qlcnic/qlcnic_init.c
index 058ce61501c..1c3d5a90d21 100644
--- a/drivers/net/qlcnic/qlcnic_init.c
+++ b/drivers/net/qlcnic/qlcnic_init.c
@@ -112,14 +112,15 @@ void qlcnic_release_rx_buffers(struct qlcnic_adapter *adapter)
112 rds_ring = &recv_ctx->rds_rings[ring]; 112 rds_ring = &recv_ctx->rds_rings[ring];
113 for (i = 0; i < rds_ring->num_desc; ++i) { 113 for (i = 0; i < rds_ring->num_desc; ++i) {
114 rx_buf = &(rds_ring->rx_buf_arr[i]); 114 rx_buf = &(rds_ring->rx_buf_arr[i]);
115 if (rx_buf->state == QLCNIC_BUFFER_FREE) 115 if (rx_buf->skb == NULL)
116 continue; 116 continue;
117
117 pci_unmap_single(adapter->pdev, 118 pci_unmap_single(adapter->pdev,
118 rx_buf->dma, 119 rx_buf->dma,
119 rds_ring->dma_size, 120 rds_ring->dma_size,
120 PCI_DMA_FROMDEVICE); 121 PCI_DMA_FROMDEVICE);
121 if (rx_buf->skb != NULL) 122
122 dev_kfree_skb_any(rx_buf->skb); 123 dev_kfree_skb_any(rx_buf->skb);
123 } 124 }
124 } 125 }
125} 126}
@@ -266,7 +267,6 @@ int qlcnic_alloc_sw_resources(struct qlcnic_adapter *adapter)
266 list_add_tail(&rx_buf->list, 267 list_add_tail(&rx_buf->list,
267 &rds_ring->free_list); 268 &rds_ring->free_list);
268 rx_buf->ref_handle = i; 269 rx_buf->ref_handle = i;
269 rx_buf->state = QLCNIC_BUFFER_FREE;
270 rx_buf++; 270 rx_buf++;
271 } 271 }
272 spin_lock_init(&rds_ring->lock); 272 spin_lock_init(&rds_ring->lock);
@@ -1281,14 +1281,12 @@ qlcnic_alloc_rx_skb(struct qlcnic_adapter *adapter,
1281 dma_addr_t dma; 1281 dma_addr_t dma;
1282 struct pci_dev *pdev = adapter->pdev; 1282 struct pci_dev *pdev = adapter->pdev;
1283 1283
1284 buffer->skb = dev_alloc_skb(rds_ring->skb_size); 1284 skb = dev_alloc_skb(rds_ring->skb_size);
1285 if (!buffer->skb) { 1285 if (!skb) {
1286 adapter->stats.skb_alloc_failure++; 1286 adapter->stats.skb_alloc_failure++;
1287 return -ENOMEM; 1287 return -ENOMEM;
1288 } 1288 }
1289 1289
1290 skb = buffer->skb;
1291
1292 skb_reserve(skb, 2); 1290 skb_reserve(skb, 2);
1293 1291
1294 dma = pci_map_single(pdev, skb->data, 1292 dma = pci_map_single(pdev, skb->data,
@@ -1297,13 +1295,11 @@ qlcnic_alloc_rx_skb(struct qlcnic_adapter *adapter,
1297 if (pci_dma_mapping_error(pdev, dma)) { 1295 if (pci_dma_mapping_error(pdev, dma)) {
1298 adapter->stats.rx_dma_map_error++; 1296 adapter->stats.rx_dma_map_error++;
1299 dev_kfree_skb_any(skb); 1297 dev_kfree_skb_any(skb);
1300 buffer->skb = NULL;
1301 return -ENOMEM; 1298 return -ENOMEM;
1302 } 1299 }
1303 1300
1304 buffer->skb = skb; 1301 buffer->skb = skb;
1305 buffer->dma = dma; 1302 buffer->dma = dma;
1306 buffer->state = QLCNIC_BUFFER_BUSY;
1307 1303
1308 return 0; 1304 return 0;
1309} 1305}
@@ -1316,14 +1312,15 @@ static struct sk_buff *qlcnic_process_rxbuf(struct qlcnic_adapter *adapter,
1316 1312
1317 buffer = &rds_ring->rx_buf_arr[index]; 1313 buffer = &rds_ring->rx_buf_arr[index];
1318 1314
1315 if (unlikely(buffer->skb == NULL)) {
1316 WARN_ON(1);
1317 return NULL;
1318 }
1319
1319 pci_unmap_single(adapter->pdev, buffer->dma, rds_ring->dma_size, 1320 pci_unmap_single(adapter->pdev, buffer->dma, rds_ring->dma_size,
1320 PCI_DMA_FROMDEVICE); 1321 PCI_DMA_FROMDEVICE);
1321 1322
1322 skb = buffer->skb; 1323 skb = buffer->skb;
1323 if (!skb) {
1324 adapter->stats.null_skb++;
1325 goto no_skb;
1326 }
1327 1324
1328 if (likely(adapter->rx_csum && cksum == STATUS_CKSUM_OK)) { 1325 if (likely(adapter->rx_csum && cksum == STATUS_CKSUM_OK)) {
1329 adapter->stats.csummed++; 1326 adapter->stats.csummed++;
@@ -1335,8 +1332,7 @@ static struct sk_buff *qlcnic_process_rxbuf(struct qlcnic_adapter *adapter,
1335 skb->dev = adapter->netdev; 1332 skb->dev = adapter->netdev;
1336 1333
1337 buffer->skb = NULL; 1334 buffer->skb = NULL;
1338no_skb: 1335
1339 buffer->state = QLCNIC_BUFFER_FREE;
1340 return skb; 1336 return skb;
1341} 1337}
1342 1338
@@ -1511,7 +1507,7 @@ qlcnic_process_rcv_ring(struct qlcnic_host_sds_ring *sds_ring, int max)
1511 1507
1512 WARN_ON(desc_cnt > 1); 1508 WARN_ON(desc_cnt > 1);
1513 1509
1514 if (rxbuf) 1510 if (likely(rxbuf))
1515 list_add_tail(&rxbuf->list, &sds_ring->free_list[ring]); 1511 list_add_tail(&rxbuf->list, &sds_ring->free_list[ring]);
1516 else 1512 else
1517 adapter->stats.null_rxbuf++; 1513 adapter->stats.null_rxbuf++;