Skip to content

Commit

Permalink
cnic: Put uio init in separate function.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Michael Chan authored and David S. Miller committed Aug 29, 2009
1 parent ec0248e commit 5e9b2db
Showing 1 changed file with 41 additions and 27 deletions.
68 changes: 41 additions & 27 deletions drivers/net/cnic.c
Original file line number Diff line number Diff line change
Expand Up @@ -762,44 +762,30 @@ 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;
uinfo->mem[0].size = dev->netdev->mem_end - dev->netdev->mem_start;
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;
Expand All @@ -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;

Expand All @@ -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;

Expand Down

0 comments on commit 5e9b2db

Please sign in to comment.