aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMichael Chan <mchan@broadcom.com>2007-12-12 14:16:19 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 17:57:27 -0500
commite343d55c0a624c5bb88cd6821a17586474f20271 (patch)
treeaf9efb9725694bd9d7b8d0b5e88ddf6a7c74e5ad /drivers
parentf5f97b57b5208a7ca270ac86887a2838ab7862f5 (diff)
[BNX2]: Add ring constants.
Define the various ring constants to make the code cleaner. Signed-off-by: Michael Chan <mchan@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/bnx2.c22
-rw-r--r--drivers/net/bnx2.h5
2 files changed, 12 insertions, 15 deletions
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 4e7b46e44874..dfe50c286d95 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -468,8 +468,7 @@ bnx2_free_mem(struct bnx2 *bp)
468 bp->stats_blk = NULL; 468 bp->stats_blk = NULL;
469 } 469 }
470 if (bp->tx_desc_ring) { 470 if (bp->tx_desc_ring) {
471 pci_free_consistent(bp->pdev, 471 pci_free_consistent(bp->pdev, TXBD_RING_SIZE,
472 sizeof(struct tx_bd) * TX_DESC_CNT,
473 bp->tx_desc_ring, bp->tx_desc_mapping); 472 bp->tx_desc_ring, bp->tx_desc_mapping);
474 bp->tx_desc_ring = NULL; 473 bp->tx_desc_ring = NULL;
475 } 474 }
@@ -477,8 +476,7 @@ bnx2_free_mem(struct bnx2 *bp)
477 bp->tx_buf_ring = NULL; 476 bp->tx_buf_ring = NULL;
478 for (i = 0; i < bp->rx_max_ring; i++) { 477 for (i = 0; i < bp->rx_max_ring; i++) {
479 if (bp->rx_desc_ring[i]) 478 if (bp->rx_desc_ring[i])
480 pci_free_consistent(bp->pdev, 479 pci_free_consistent(bp->pdev, RXBD_RING_SIZE,
481 sizeof(struct rx_bd) * RX_DESC_CNT,
482 bp->rx_desc_ring[i], 480 bp->rx_desc_ring[i],
483 bp->rx_desc_mapping[i]); 481 bp->rx_desc_mapping[i]);
484 bp->rx_desc_ring[i] = NULL; 482 bp->rx_desc_ring[i] = NULL;
@@ -492,30 +490,24 @@ bnx2_alloc_mem(struct bnx2 *bp)
492{ 490{
493 int i, status_blk_size; 491 int i, status_blk_size;
494 492
495 bp->tx_buf_ring = kzalloc(sizeof(struct sw_bd) * TX_DESC_CNT, 493 bp->tx_buf_ring = kzalloc(SW_TXBD_RING_SIZE, GFP_KERNEL);
496 GFP_KERNEL);
497 if (bp->tx_buf_ring == NULL) 494 if (bp->tx_buf_ring == NULL)
498 return -ENOMEM; 495 return -ENOMEM;
499 496
500 bp->tx_desc_ring = pci_alloc_consistent(bp->pdev, 497 bp->tx_desc_ring = pci_alloc_consistent(bp->pdev, TXBD_RING_SIZE,
501 sizeof(struct tx_bd) *
502 TX_DESC_CNT,
503 &bp->tx_desc_mapping); 498 &bp->tx_desc_mapping);
504 if (bp->tx_desc_ring == NULL) 499 if (bp->tx_desc_ring == NULL)
505 goto alloc_mem_err; 500 goto alloc_mem_err;
506 501
507 bp->rx_buf_ring = vmalloc(sizeof(struct sw_bd) * RX_DESC_CNT * 502 bp->rx_buf_ring = vmalloc(SW_RXBD_RING_SIZE * bp->rx_max_ring);
508 bp->rx_max_ring);
509 if (bp->rx_buf_ring == NULL) 503 if (bp->rx_buf_ring == NULL)
510 goto alloc_mem_err; 504 goto alloc_mem_err;
511 505
512 memset(bp->rx_buf_ring, 0, sizeof(struct sw_bd) * RX_DESC_CNT * 506 memset(bp->rx_buf_ring, 0, SW_RXBD_RING_SIZE * bp->rx_max_ring);
513 bp->rx_max_ring);
514 507
515 for (i = 0; i < bp->rx_max_ring; i++) { 508 for (i = 0; i < bp->rx_max_ring; i++) {
516 bp->rx_desc_ring[i] = 509 bp->rx_desc_ring[i] =
517 pci_alloc_consistent(bp->pdev, 510 pci_alloc_consistent(bp->pdev, RXBD_RING_SIZE,
518 sizeof(struct rx_bd) * RX_DESC_CNT,
519 &bp->rx_desc_mapping[i]); 511 &bp->rx_desc_mapping[i]);
520 if (bp->rx_desc_ring[i] == NULL) 512 if (bp->rx_desc_ring[i] == NULL)
521 goto alloc_mem_err; 513 goto alloc_mem_err;
diff --git a/drivers/net/bnx2.h b/drivers/net/bnx2.h
index 30ba366608b0..e6a2153e8b95 100644
--- a/drivers/net/bnx2.h
+++ b/drivers/net/bnx2.h
@@ -6408,6 +6408,11 @@ struct sw_bd {
6408 DECLARE_PCI_UNMAP_ADDR(mapping) 6408 DECLARE_PCI_UNMAP_ADDR(mapping)
6409}; 6409};
6410 6410
6411#define SW_RXBD_RING_SIZE (sizeof(struct sw_bd) * RX_DESC_CNT)
6412#define RXBD_RING_SIZE (sizeof(struct rx_bd) * RX_DESC_CNT)
6413#define SW_TXBD_RING_SIZE (sizeof(struct sw_bd) * TX_DESC_CNT)
6414#define TXBD_RING_SIZE (sizeof(struct tx_bd) * TX_DESC_CNT)
6415
6411/* Buffered flash (Atmel: AT45DB011B) specific information */ 6416/* Buffered flash (Atmel: AT45DB011B) specific information */
6412#define SEEPROM_PAGE_BITS 2 6417#define SEEPROM_PAGE_BITS 2
6413#define SEEPROM_PHY_PAGE_SIZE (1 << SEEPROM_PAGE_BITS) 6418#define SEEPROM_PHY_PAGE_SIZE (1 << SEEPROM_PAGE_BITS)