* [PATCH net-next 1/2] cnic: Put rx/tx ring allocation in separate function.
@ 2009-08-26 19:49 Michael Chan
2009-08-26 19:49 ` [PATCH net-next 2/2] cnic: Put uio init " Michael Chan
2009-08-29 6:47 ` [PATCH net-next 1/2] cnic: Put rx/tx ring allocation " David Miller
0 siblings, 2 replies; 4+ messages in thread
From: Michael Chan @ 2009-08-26 19:49 UTC (permalink / raw)
To: davem; +Cc: netdev, Michael Chan
This will allow the 10G iSCSI code to reuse the function.
Signed-off-by: Michael Chan <mchan@broadcom.com>
---
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 4869d77..039900c 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);
--
1.6.4.GIT
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH net-next 2/2] cnic: Put uio init in separate function.
2009-08-26 19:49 [PATCH net-next 1/2] cnic: Put rx/tx ring allocation in separate function Michael Chan
@ 2009-08-26 19:49 ` Michael Chan
2009-08-29 6:47 ` David Miller
2009-08-29 6:47 ` [PATCH net-next 1/2] cnic: Put rx/tx ring allocation " David Miller
1 sibling, 1 reply; 4+ messages in thread
From: Michael Chan @ 2009-08-26 19:49 UTC (permalink / raw)
To: davem; +Cc: netdev, Michael Chan
This will allow the 10G iSCSI code to reuse the function.
Signed-off-by: Michael Chan <mchan@broadcom.com>
---
drivers/net/cnic.c | 68 +++++++++++++++++++++++++++++++--------------------
1 files changed, 41 insertions(+), 27 deletions(-)
diff --git a/drivers/net/cnic.c b/drivers/net/cnic.c
index 039900c..f8a0923 100644
--- a/drivers/net/cnic.c
+++ b/drivers/net/cnic.c
@@ -762,33 +762,14 @@ static int cnic_alloc_l2_rings(struct cnic_dev *dev, int pages)
return 0;
}
-static int cnic_alloc_bnx2_resc(struct cnic_dev *dev)
-{
+static int cnic_alloc_uio(struct cnic_dev *dev) {
struct cnic_local *cp = dev->cnic_priv;
struct uio_info *uinfo;
int ret;
- ret = cnic_alloc_dma(dev, &cp->kwq_info, KWQ_PAGE_CNT, 1);
- if (ret)
- goto error;
- cp->kwq = (struct kwqe **) cp->kwq_info.pg_arr;
-
- ret = cnic_alloc_dma(dev, &cp->kcq_info, KCQ_PAGE_CNT, 1);
- if (ret)
- goto error;
- cp->kcq = (struct kcqe **) cp->kcq_info.pg_arr;
-
- ret = cnic_alloc_context(dev);
- if (ret)
- goto error;
-
- ret = cnic_alloc_l2_rings(dev, 2);
- if (ret)
- goto error;
-
uinfo = kzalloc(sizeof(*uinfo), GFP_ATOMIC);
if (!uinfo)
- goto error;
+ return -ENOMEM;
uinfo->mem[0].addr = dev->netdev->base_addr;
uinfo->mem[0].internal_addr = dev->regview;
@@ -796,10 +777,15 @@ static int cnic_alloc_bnx2_resc(struct cnic_dev *dev)
uinfo->mem[0].memtype = UIO_MEM_PHYS;
uinfo->mem[1].addr = (unsigned long) cp->status_blk & PAGE_MASK;
- if (cp->ethdev->drv_state & CNIC_DRV_STATE_USING_MSIX)
- uinfo->mem[1].size = BNX2_SBLK_MSIX_ALIGN_SIZE * 9;
- else
- uinfo->mem[1].size = BNX2_SBLK_MSIX_ALIGN_SIZE;
+ if (test_bit(CNIC_F_BNX2_CLASS, &dev->flags)) {
+ if (cp->ethdev->drv_state & CNIC_DRV_STATE_USING_MSIX)
+ uinfo->mem[1].size = BNX2_SBLK_MSIX_ALIGN_SIZE * 9;
+ else
+ uinfo->mem[1].size = BNX2_SBLK_MSIX_ALIGN_SIZE;
+
+ uinfo->name = "bnx2_cnic";
+ }
+
uinfo->mem[1].memtype = UIO_MEM_LOGICAL;
uinfo->mem[2].addr = (unsigned long) cp->l2_ring;
@@ -810,7 +796,6 @@ static int cnic_alloc_bnx2_resc(struct cnic_dev *dev)
uinfo->mem[3].size = cp->l2_buf_size;
uinfo->mem[3].memtype = UIO_MEM_LOGICAL;
- uinfo->name = "bnx2_cnic";
uinfo->version = CNIC_MODULE_VERSION;
uinfo->irq = UIO_IRQ_CUSTOM;
@@ -822,10 +807,39 @@ static int cnic_alloc_bnx2_resc(struct cnic_dev *dev)
ret = uio_register_device(&dev->pcidev->dev, uinfo);
if (ret) {
kfree(uinfo);
- goto error;
+ return ret;
}
cp->cnic_uinfo = uinfo;
+ return 0;
+}
+
+static int cnic_alloc_bnx2_resc(struct cnic_dev *dev)
+{
+ struct cnic_local *cp = dev->cnic_priv;
+ int ret;
+
+ ret = cnic_alloc_dma(dev, &cp->kwq_info, KWQ_PAGE_CNT, 1);
+ if (ret)
+ goto error;
+ cp->kwq = (struct kwqe **) cp->kwq_info.pg_arr;
+
+ ret = cnic_alloc_dma(dev, &cp->kcq_info, KCQ_PAGE_CNT, 1);
+ if (ret)
+ goto error;
+ cp->kcq = (struct kcqe **) cp->kcq_info.pg_arr;
+
+ ret = cnic_alloc_context(dev);
+ if (ret)
+ goto error;
+
+ ret = cnic_alloc_l2_rings(dev, 2);
+ if (ret)
+ goto error;
+
+ ret = cnic_alloc_uio(dev);
+ if (ret)
+ goto error;
return 0;
--
1.6.4.GIT
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next 1/2] cnic: Put rx/tx ring allocation in separate function.
2009-08-26 19:49 [PATCH net-next 1/2] cnic: Put rx/tx ring allocation in separate function Michael Chan
2009-08-26 19:49 ` [PATCH net-next 2/2] cnic: Put uio init " Michael Chan
@ 2009-08-29 6:47 ` David Miller
1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2009-08-29 6:47 UTC (permalink / raw)
To: mchan; +Cc: netdev
From: "Michael Chan" <mchan@broadcom.com>
Date: Wed, 26 Aug 2009 12:49:22 -0700
> This will allow the 10G iSCSI code to reuse the function.
>
> Signed-off-by: Michael Chan <mchan@broadcom.com>
Applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next 2/2] cnic: Put uio init in separate function.
2009-08-26 19:49 ` [PATCH net-next 2/2] cnic: Put uio init " Michael Chan
@ 2009-08-29 6:47 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2009-08-29 6:47 UTC (permalink / raw)
To: mchan; +Cc: netdev
From: "Michael Chan" <mchan@broadcom.com>
Date: Wed, 26 Aug 2009 12:49:23 -0700
> This will allow the 10G iSCSI code to reuse the function.
>
> Signed-off-by: Michael Chan <mchan@broadcom.com>
Applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-08-29 6:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-26 19:49 [PATCH net-next 1/2] cnic: Put rx/tx ring allocation in separate function Michael Chan
2009-08-26 19:49 ` [PATCH net-next 2/2] cnic: Put uio init " Michael Chan
2009-08-29 6:47 ` David Miller
2009-08-29 6:47 ` [PATCH net-next 1/2] cnic: Put rx/tx ring allocation " David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).