aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bnx2.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/bnx2.c')
-rw-r--r--drivers/net/bnx2.c34
1 files changed, 15 insertions, 19 deletions
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index c56888e66351..8ce5ae84c832 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -359,15 +359,11 @@ bnx2_free_mem(struct bnx2 *bp)
359{ 359{
360 int i; 360 int i;
361 361
362 if (bp->stats_blk) {
363 pci_free_consistent(bp->pdev, sizeof(struct statistics_block),
364 bp->stats_blk, bp->stats_blk_mapping);
365 bp->stats_blk = NULL;
366 }
367 if (bp->status_blk) { 362 if (bp->status_blk) {
368 pci_free_consistent(bp->pdev, sizeof(struct status_block), 363 pci_free_consistent(bp->pdev, bp->status_stats_size,
369 bp->status_blk, bp->status_blk_mapping); 364 bp->status_blk, bp->status_blk_mapping);
370 bp->status_blk = NULL; 365 bp->status_blk = NULL;
366 bp->stats_blk = NULL;
371 } 367 }
372 if (bp->tx_desc_ring) { 368 if (bp->tx_desc_ring) {
373 pci_free_consistent(bp->pdev, 369 pci_free_consistent(bp->pdev,
@@ -392,14 +388,13 @@ bnx2_free_mem(struct bnx2 *bp)
392static int 388static int
393bnx2_alloc_mem(struct bnx2 *bp) 389bnx2_alloc_mem(struct bnx2 *bp)
394{ 390{
395 int i; 391 int i, status_blk_size;
396 392
397 bp->tx_buf_ring = kmalloc(sizeof(struct sw_bd) * TX_DESC_CNT, 393 bp->tx_buf_ring = kzalloc(sizeof(struct sw_bd) * TX_DESC_CNT,
398 GFP_KERNEL); 394 GFP_KERNEL);
399 if (bp->tx_buf_ring == NULL) 395 if (bp->tx_buf_ring == NULL)
400 return -ENOMEM; 396 return -ENOMEM;
401 397
402 memset(bp->tx_buf_ring, 0, sizeof(struct sw_bd) * TX_DESC_CNT);
403 bp->tx_desc_ring = pci_alloc_consistent(bp->pdev, 398 bp->tx_desc_ring = pci_alloc_consistent(bp->pdev,
404 sizeof(struct tx_bd) * 399 sizeof(struct tx_bd) *
405 TX_DESC_CNT, 400 TX_DESC_CNT,
@@ -425,21 +420,22 @@ bnx2_alloc_mem(struct bnx2 *bp)
425 420
426 } 421 }
427 422
428 bp->status_blk = pci_alloc_consistent(bp->pdev, 423 /* Combine status and statistics blocks into one allocation. */
429 sizeof(struct status_block), 424 status_blk_size = L1_CACHE_ALIGN(sizeof(struct status_block));
425 bp->status_stats_size = status_blk_size +
426 sizeof(struct statistics_block);
427
428 bp->status_blk = pci_alloc_consistent(bp->pdev, bp->status_stats_size,
430 &bp->status_blk_mapping); 429 &bp->status_blk_mapping);
431 if (bp->status_blk == NULL) 430 if (bp->status_blk == NULL)
432 goto alloc_mem_err; 431 goto alloc_mem_err;
433 432
434 memset(bp->status_blk, 0, sizeof(struct status_block)); 433 memset(bp->status_blk, 0, bp->status_stats_size);
435 434
436 bp->stats_blk = pci_alloc_consistent(bp->pdev, 435 bp->stats_blk = (void *) ((unsigned long) bp->status_blk +
437 sizeof(struct statistics_block), 436 status_blk_size);
438 &bp->stats_blk_mapping);
439 if (bp->stats_blk == NULL)
440 goto alloc_mem_err;
441 437
442 memset(bp->stats_blk, 0, sizeof(struct statistics_block)); 438 bp->stats_blk_mapping = bp->status_blk_mapping + status_blk_size;
443 439
444 return 0; 440 return 0;
445 441