aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/cnic.c
diff options
context:
space:
mode:
authorMichael Chan <mchan@broadcom.com>2009-08-26 05:49:23 -0400
committerDavid S. Miller <davem@davemloft.net>2009-08-29 02:47:12 -0400
commit5e9b2dbfcbc9b180a0064d8a473a4652ee99c9ad (patch)
treec189374d43b77eabc80a16969eec492af6c4d220 /drivers/net/cnic.c
parentec0248ea35f6e1fc7426f377a7df071d997bdedd (diff)
cnic: Put uio init 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.c68
1 files changed, 41 insertions, 27 deletions
diff --git a/drivers/net/cnic.c b/drivers/net/cnic.c
index 039900c41699..f8a09236dc0a 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)
762 return 0; 762 return 0;
763} 763}
764 764
765static int cnic_alloc_bnx2_resc(struct cnic_dev *dev) 765static int cnic_alloc_uio(struct cnic_dev *dev) {
766{
767 struct cnic_local *cp = dev->cnic_priv; 766 struct cnic_local *cp = dev->cnic_priv;
768 struct uio_info *uinfo; 767 struct uio_info *uinfo;
769 int ret; 768 int ret;
770 769
771 ret = cnic_alloc_dma(dev, &cp->kwq_info, KWQ_PAGE_CNT, 1);
772 if (ret)
773 goto error;
774 cp->kwq = (struct kwqe **) cp->kwq_info.pg_arr;
775
776 ret = cnic_alloc_dma(dev, &cp->kcq_info, KCQ_PAGE_CNT, 1);
777 if (ret)
778 goto error;
779 cp->kcq = (struct kcqe **) cp->kcq_info.pg_arr;
780
781 ret = cnic_alloc_context(dev);
782 if (ret)
783 goto error;
784
785 ret = cnic_alloc_l2_rings(dev, 2);
786 if (ret)
787 goto error;
788
789 uinfo = kzalloc(sizeof(*uinfo), GFP_ATOMIC); 770 uinfo = kzalloc(sizeof(*uinfo), GFP_ATOMIC);
790 if (!uinfo) 771 if (!uinfo)
791 goto error; 772 return -ENOMEM;
792 773
793 uinfo->mem[0].addr = dev->netdev->base_addr; 774 uinfo->mem[0].addr = dev->netdev->base_addr;
794 uinfo->mem[0].internal_addr = dev->regview; 775 uinfo->mem[0].internal_addr = dev->regview;
@@ -796,10 +777,15 @@ static int cnic_alloc_bnx2_resc(struct cnic_dev *dev)
796 uinfo->mem[0].memtype = UIO_MEM_PHYS; 777 uinfo->mem[0].memtype = UIO_MEM_PHYS;
797 778
798 uinfo->mem[1].addr = (unsigned long) cp->status_blk & PAGE_MASK; 779 uinfo->mem[1].addr = (unsigned long) cp->status_blk & PAGE_MASK;
799 if (cp->ethdev->drv_state & CNIC_DRV_STATE_USING_MSIX) 780 if (test_bit(CNIC_F_BNX2_CLASS, &dev->flags)) {
800 uinfo->mem[1].size = BNX2_SBLK_MSIX_ALIGN_SIZE * 9; 781 if (cp->ethdev->drv_state & CNIC_DRV_STATE_USING_MSIX)
801 else 782 uinfo->mem[1].size = BNX2_SBLK_MSIX_ALIGN_SIZE * 9;
802 uinfo->mem[1].size = BNX2_SBLK_MSIX_ALIGN_SIZE; 783 else
784 uinfo->mem[1].size = BNX2_SBLK_MSIX_ALIGN_SIZE;
785
786 uinfo->name = "bnx2_cnic";
787 }
788
803 uinfo->mem[1].memtype = UIO_MEM_LOGICAL; 789 uinfo->mem[1].memtype = UIO_MEM_LOGICAL;
804 790
805 uinfo->mem[2].addr = (unsigned long) cp->l2_ring; 791 uinfo->mem[2].addr = (unsigned long) cp->l2_ring;
@@ -810,7 +796,6 @@ static int cnic_alloc_bnx2_resc(struct cnic_dev *dev)
810 uinfo->mem[3].size = cp->l2_buf_size; 796 uinfo->mem[3].size = cp->l2_buf_size;
811 uinfo->mem[3].memtype = UIO_MEM_LOGICAL; 797 uinfo->mem[3].memtype = UIO_MEM_LOGICAL;
812 798
813 uinfo->name = "bnx2_cnic";
814 uinfo->version = CNIC_MODULE_VERSION; 799 uinfo->version = CNIC_MODULE_VERSION;
815 uinfo->irq = UIO_IRQ_CUSTOM; 800 uinfo->irq = UIO_IRQ_CUSTOM;
816 801
@@ -822,10 +807,39 @@ static int cnic_alloc_bnx2_resc(struct cnic_dev *dev)
822 ret = uio_register_device(&dev->pcidev->dev, uinfo); 807 ret = uio_register_device(&dev->pcidev->dev, uinfo);
823 if (ret) { 808 if (ret) {
824 kfree(uinfo); 809 kfree(uinfo);
825 goto error; 810 return ret;
826 } 811 }
827 812
828 cp->cnic_uinfo = uinfo; 813 cp->cnic_uinfo = uinfo;
814 return 0;
815}
816
817static int cnic_alloc_bnx2_resc(struct cnic_dev *dev)
818{
819 struct cnic_local *cp = dev->cnic_priv;
820 int ret;
821
822 ret = cnic_alloc_dma(dev, &cp->kwq_info, KWQ_PAGE_CNT, 1);
823 if (ret)
824 goto error;
825 cp->kwq = (struct kwqe **) cp->kwq_info.pg_arr;
826
827 ret = cnic_alloc_dma(dev, &cp->kcq_info, KCQ_PAGE_CNT, 1);
828 if (ret)
829 goto error;
830 cp->kcq = (struct kcqe **) cp->kcq_info.pg_arr;
831
832 ret = cnic_alloc_context(dev);
833 if (ret)
834 goto error;
835
836 ret = cnic_alloc_l2_rings(dev, 2);
837 if (ret)
838 goto error;
839
840 ret = cnic_alloc_uio(dev);
841 if (ret)
842 goto error;
829 843
830 return 0; 844 return 0;
831 845