diff options
author | Michael Chan <mchan@broadcom.com> | 2009-08-26 13:49:22 +0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-08-29 10:47:10 +0400 |
commit | ec0248ea35f6e1fc7426f377a7df071d997bdedd (patch) | |
tree | 1836d5c4f5568a45fbdb4085ebcffff5046f8ead /drivers/net/cnic.c | |
parent | 3d1427f87002735aa54c370558e0c2bacc61f31e (diff) | |
download | linux-ec0248ea35f6e1fc7426f377a7df071d997bdedd.tar.xz |
cnic: Put rx/tx ring allocation in separate function.
This will allow the 10G iSCSI code to reuse the function.
Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/cnic.c')
-rw-r--r-- | drivers/net/cnic.c | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/drivers/net/cnic.c b/drivers/net/cnic.c index 4869d77cbe91..039900c41699 100644 --- a/drivers/net/cnic.c +++ b/drivers/net/cnic.c @@ -742,6 +742,26 @@ static int cnic_alloc_context(struct cnic_dev *dev) return 0; } +static int cnic_alloc_l2_rings(struct cnic_dev *dev, int pages) +{ + struct cnic_local *cp = dev->cnic_priv; + + cp->l2_ring_size = pages * BCM_PAGE_SIZE; + cp->l2_ring = pci_alloc_consistent(dev->pcidev, cp->l2_ring_size, + &cp->l2_ring_map); + if (!cp->l2_ring) + return -ENOMEM; + + cp->l2_buf_size = (cp->l2_rx_ring_size + 1) * cp->l2_single_buf_size; + cp->l2_buf_size = PAGE_ALIGN(cp->l2_buf_size); + cp->l2_buf = pci_alloc_consistent(dev->pcidev, cp->l2_buf_size, + &cp->l2_buf_map); + if (!cp->l2_buf) + return -ENOMEM; + + return 0; +} + static int cnic_alloc_bnx2_resc(struct cnic_dev *dev) { struct cnic_local *cp = dev->cnic_priv; @@ -762,17 +782,8 @@ static int cnic_alloc_bnx2_resc(struct cnic_dev *dev) if (ret) goto error; - cp->l2_ring_size = 2 * BCM_PAGE_SIZE; - cp->l2_ring = pci_alloc_consistent(dev->pcidev, cp->l2_ring_size, - &cp->l2_ring_map); - if (!cp->l2_ring) - goto error; - - cp->l2_buf_size = (cp->l2_rx_ring_size + 1) * cp->l2_single_buf_size; - cp->l2_buf_size = PAGE_ALIGN(cp->l2_buf_size); - cp->l2_buf = pci_alloc_consistent(dev->pcidev, cp->l2_buf_size, - &cp->l2_buf_map); - if (!cp->l2_buf) + ret = cnic_alloc_l2_rings(dev, 2); + if (ret) goto error; uinfo = kzalloc(sizeof(*uinfo), GFP_ATOMIC); |