diff options
author | Michael Chan <mchan@broadcom.com> | 2010-10-13 10:06:49 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-10-14 13:45:55 -0400 |
commit | cd801536c236e287f1d3eeee428abf9ffd523ede (patch) | |
tree | 64ab5c454c9e40111da14d8848f39ff6eaca658b /drivers/net/cnic.c | |
parent | c06c0462250a5dbc9e58d00caab4cd7e6675128c (diff) |
cnic: Add cnic_uio_dev struct
and put all uio related structures and ring buffers in it. This allows
uio operations to be done independent of the cnic device structures.
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 | 195 |
1 files changed, 105 insertions, 90 deletions
diff --git a/drivers/net/cnic.c b/drivers/net/cnic.c index 739ffcb9bff..e8f2836b630 100644 --- a/drivers/net/cnic.c +++ b/drivers/net/cnic.c | |||
@@ -89,22 +89,24 @@ static int cnic_cm_set_pg(struct cnic_sock *); | |||
89 | 89 | ||
90 | static int cnic_uio_open(struct uio_info *uinfo, struct inode *inode) | 90 | static int cnic_uio_open(struct uio_info *uinfo, struct inode *inode) |
91 | { | 91 | { |
92 | struct cnic_dev *dev = uinfo->priv; | 92 | struct cnic_uio_dev *udev = uinfo->priv; |
93 | struct cnic_local *cp = dev->cnic_priv; | 93 | struct cnic_dev *dev; |
94 | 94 | ||
95 | if (!capable(CAP_NET_ADMIN)) | 95 | if (!capable(CAP_NET_ADMIN)) |
96 | return -EPERM; | 96 | return -EPERM; |
97 | 97 | ||
98 | if (cp->uio_dev != -1) | 98 | if (udev->uio_dev != -1) |
99 | return -EBUSY; | 99 | return -EBUSY; |
100 | 100 | ||
101 | rtnl_lock(); | 101 | rtnl_lock(); |
102 | dev = udev->dev; | ||
103 | |||
102 | if (!test_bit(CNIC_F_CNIC_UP, &dev->flags)) { | 104 | if (!test_bit(CNIC_F_CNIC_UP, &dev->flags)) { |
103 | rtnl_unlock(); | 105 | rtnl_unlock(); |
104 | return -ENODEV; | 106 | return -ENODEV; |
105 | } | 107 | } |
106 | 108 | ||
107 | cp->uio_dev = iminor(inode); | 109 | udev->uio_dev = iminor(inode); |
108 | 110 | ||
109 | cnic_init_rings(dev); | 111 | cnic_init_rings(dev); |
110 | rtnl_unlock(); | 112 | rtnl_unlock(); |
@@ -114,12 +116,12 @@ static int cnic_uio_open(struct uio_info *uinfo, struct inode *inode) | |||
114 | 116 | ||
115 | static int cnic_uio_close(struct uio_info *uinfo, struct inode *inode) | 117 | static int cnic_uio_close(struct uio_info *uinfo, struct inode *inode) |
116 | { | 118 | { |
117 | struct cnic_dev *dev = uinfo->priv; | 119 | struct cnic_uio_dev *udev = uinfo->priv; |
118 | struct cnic_local *cp = dev->cnic_priv; | 120 | struct cnic_dev *dev = udev->dev; |
119 | 121 | ||
120 | cnic_shutdown_rings(dev); | 122 | cnic_shutdown_rings(dev); |
121 | 123 | ||
122 | cp->uio_dev = -1; | 124 | udev->uio_dev = -1; |
123 | return 0; | 125 | return 0; |
124 | } | 126 | } |
125 | 127 | ||
@@ -276,8 +278,9 @@ static int cnic_send_nlmsg(struct cnic_local *cp, u32 type, | |||
276 | u16 len = 0; | 278 | u16 len = 0; |
277 | u32 msg_type = ISCSI_KEVENT_IF_DOWN; | 279 | u32 msg_type = ISCSI_KEVENT_IF_DOWN; |
278 | struct cnic_ulp_ops *ulp_ops; | 280 | struct cnic_ulp_ops *ulp_ops; |
281 | struct cnic_uio_dev *udev = cp->udev; | ||
279 | 282 | ||
280 | if (cp->uio_dev == -1) | 283 | if (!udev || udev->uio_dev == -1) |
281 | return -ENODEV; | 284 | return -ENODEV; |
282 | 285 | ||
283 | if (csk) { | 286 | if (csk) { |
@@ -408,8 +411,7 @@ static void cnic_uio_stop(void) | |||
408 | list_for_each_entry(dev, &cnic_dev_list, list) { | 411 | list_for_each_entry(dev, &cnic_dev_list, list) { |
409 | struct cnic_local *cp = dev->cnic_priv; | 412 | struct cnic_local *cp = dev->cnic_priv; |
410 | 413 | ||
411 | if (cp->cnic_uinfo) | 414 | cnic_send_nlmsg(cp, ISCSI_KEVENT_IF_DOWN, NULL); |
412 | cnic_send_nlmsg(cp, ISCSI_KEVENT_IF_DOWN, NULL); | ||
413 | } | 415 | } |
414 | read_unlock(&cnic_dev_lock); | 416 | read_unlock(&cnic_dev_lock); |
415 | } | 417 | } |
@@ -770,48 +772,44 @@ static void cnic_free_context(struct cnic_dev *dev) | |||
770 | } | 772 | } |
771 | } | 773 | } |
772 | 774 | ||
773 | static void __cnic_free_uio(struct cnic_dev *dev) | 775 | static void __cnic_free_uio(struct cnic_uio_dev *udev) |
774 | { | 776 | { |
775 | struct cnic_local *cp = dev->cnic_priv; | 777 | uio_unregister_device(&udev->cnic_uinfo); |
776 | |||
777 | if (cp->cnic_uinfo) | ||
778 | uio_unregister_device(cp->cnic_uinfo); | ||
779 | 778 | ||
780 | kfree(cp->cnic_uinfo); | 779 | if (udev->l2_buf) { |
781 | cp->cnic_uinfo = NULL; | 780 | dma_free_coherent(&udev->pdev->dev, udev->l2_buf_size, |
782 | 781 | udev->l2_buf, udev->l2_buf_map); | |
783 | if (cp->l2_buf) { | 782 | udev->l2_buf = NULL; |
784 | dma_free_coherent(&dev->pcidev->dev, cp->l2_buf_size, | ||
785 | cp->l2_buf, cp->l2_buf_map); | ||
786 | cp->l2_buf = NULL; | ||
787 | } | 783 | } |
788 | 784 | ||
789 | if (cp->l2_ring) { | 785 | if (udev->l2_ring) { |
790 | dma_free_coherent(&dev->pcidev->dev, cp->l2_ring_size, | 786 | dma_free_coherent(&udev->pdev->dev, udev->l2_ring_size, |
791 | cp->l2_ring, cp->l2_ring_map); | 787 | udev->l2_ring, udev->l2_ring_map); |
792 | cp->l2_ring = NULL; | 788 | udev->l2_ring = NULL; |
793 | } | 789 | } |
794 | } | 790 | } |
795 | 791 | ||
796 | static void cnic_free_uio(struct cnic_dev *dev) | 792 | static void cnic_free_uio(struct cnic_uio_dev *udev) |
797 | { | 793 | { |
798 | if (!dev) | 794 | if (!udev) |
799 | return; | 795 | return; |
800 | 796 | ||
801 | __cnic_free_uio(dev); | 797 | __cnic_free_uio(udev); |
802 | } | 798 | } |
803 | 799 | ||
804 | static void cnic_free_resc(struct cnic_dev *dev) | 800 | static void cnic_free_resc(struct cnic_dev *dev) |
805 | { | 801 | { |
806 | struct cnic_local *cp = dev->cnic_priv; | 802 | struct cnic_local *cp = dev->cnic_priv; |
803 | struct cnic_uio_dev *udev = cp->udev; | ||
807 | int i = 0; | 804 | int i = 0; |
808 | 805 | ||
809 | if (cp->cnic_uinfo) { | 806 | if (udev) { |
810 | while (cp->uio_dev != -1 && i < 15) { | 807 | while (udev->uio_dev != -1 && i < 15) { |
811 | msleep(100); | 808 | msleep(100); |
812 | i++; | 809 | i++; |
813 | } | 810 | } |
814 | cnic_free_uio(dev); | 811 | cnic_free_uio(udev); |
812 | cp->udev = NULL; | ||
815 | } | 813 | } |
816 | 814 | ||
817 | cnic_free_context(dev); | 815 | cnic_free_context(dev); |
@@ -913,37 +911,53 @@ static int cnic_alloc_kcq(struct cnic_dev *dev, struct kcq_info *info) | |||
913 | return 0; | 911 | return 0; |
914 | } | 912 | } |
915 | 913 | ||
916 | static int cnic_alloc_l2_rings(struct cnic_dev *dev, int pages) | 914 | static int cnic_alloc_uio_rings(struct cnic_dev *dev, int pages) |
917 | { | 915 | { |
918 | struct cnic_local *cp = dev->cnic_priv; | 916 | struct cnic_local *cp = dev->cnic_priv; |
917 | struct cnic_uio_dev *udev; | ||
918 | |||
919 | udev = kzalloc(sizeof(struct cnic_uio_dev), GFP_ATOMIC); | ||
920 | if (!udev) | ||
921 | return -ENOMEM; | ||
922 | |||
923 | udev->uio_dev = -1; | ||
919 | 924 | ||
920 | cp->l2_ring_size = pages * BCM_PAGE_SIZE; | 925 | udev->dev = dev; |
921 | cp->l2_ring = dma_alloc_coherent(&dev->pcidev->dev, cp->l2_ring_size, | 926 | udev->pdev = dev->pcidev; |
922 | &cp->l2_ring_map, | 927 | udev->l2_ring_size = pages * BCM_PAGE_SIZE; |
923 | GFP_KERNEL | __GFP_COMP); | 928 | udev->l2_ring = dma_alloc_coherent(&udev->pdev->dev, udev->l2_ring_size, |
924 | if (!cp->l2_ring) | 929 | &udev->l2_ring_map, |
930 | GFP_KERNEL | __GFP_COMP); | ||
931 | if (!udev->l2_ring) | ||
925 | return -ENOMEM; | 932 | return -ENOMEM; |
926 | 933 | ||
927 | cp->l2_buf_size = (cp->l2_rx_ring_size + 1) * cp->l2_single_buf_size; | 934 | udev->l2_buf_size = (cp->l2_rx_ring_size + 1) * cp->l2_single_buf_size; |
928 | cp->l2_buf_size = PAGE_ALIGN(cp->l2_buf_size); | 935 | udev->l2_buf_size = PAGE_ALIGN(udev->l2_buf_size); |
929 | cp->l2_buf = dma_alloc_coherent(&dev->pcidev->dev, cp->l2_buf_size, | 936 | udev->l2_buf = dma_alloc_coherent(&udev->pdev->dev, udev->l2_buf_size, |
930 | &cp->l2_buf_map, | 937 | &udev->l2_buf_map, |
931 | GFP_KERNEL | __GFP_COMP); | 938 | GFP_KERNEL | __GFP_COMP); |
932 | if (!cp->l2_buf) | 939 | if (!udev->l2_buf) |
933 | return -ENOMEM; | 940 | return -ENOMEM; |
934 | 941 | ||
942 | cp->udev = udev; | ||
943 | |||
935 | return 0; | 944 | return 0; |
936 | } | 945 | } |
937 | 946 | ||
938 | static int cnic_alloc_uio(struct cnic_dev *dev) { | 947 | static int cnic_init_uio(struct cnic_dev *dev) |
948 | { | ||
939 | struct cnic_local *cp = dev->cnic_priv; | 949 | struct cnic_local *cp = dev->cnic_priv; |
950 | struct cnic_uio_dev *udev = cp->udev; | ||
940 | struct uio_info *uinfo; | 951 | struct uio_info *uinfo; |
941 | int ret; | 952 | int ret = 0; |
942 | 953 | ||
943 | uinfo = kzalloc(sizeof(*uinfo), GFP_ATOMIC); | 954 | if (!udev) |
944 | if (!uinfo) | ||
945 | return -ENOMEM; | 955 | return -ENOMEM; |
946 | 956 | ||
957 | udev->uio_dev = -1; | ||
958 | |||
959 | uinfo = &udev->cnic_uinfo; | ||
960 | |||
947 | uinfo->mem[0].addr = dev->netdev->base_addr; | 961 | uinfo->mem[0].addr = dev->netdev->base_addr; |
948 | uinfo->mem[0].internal_addr = dev->regview; | 962 | uinfo->mem[0].internal_addr = dev->regview; |
949 | uinfo->mem[0].size = dev->netdev->mem_end - dev->netdev->mem_start; | 963 | uinfo->mem[0].size = dev->netdev->mem_end - dev->netdev->mem_start; |
@@ -951,7 +965,7 @@ static int cnic_alloc_uio(struct cnic_dev *dev) { | |||
951 | 965 | ||
952 | if (test_bit(CNIC_F_BNX2_CLASS, &dev->flags)) { | 966 | if (test_bit(CNIC_F_BNX2_CLASS, &dev->flags)) { |
953 | uinfo->mem[1].addr = (unsigned long) cp->status_blk.gen & | 967 | uinfo->mem[1].addr = (unsigned long) cp->status_blk.gen & |
954 | PAGE_MASK; | 968 | PAGE_MASK; |
955 | if (cp->ethdev->drv_state & CNIC_DRV_STATE_USING_MSIX) | 969 | if (cp->ethdev->drv_state & CNIC_DRV_STATE_USING_MSIX) |
956 | uinfo->mem[1].size = BNX2_SBLK_MSIX_ALIGN_SIZE * 9; | 970 | uinfo->mem[1].size = BNX2_SBLK_MSIX_ALIGN_SIZE * 9; |
957 | else | 971 | else |
@@ -968,12 +982,12 @@ static int cnic_alloc_uio(struct cnic_dev *dev) { | |||
968 | 982 | ||
969 | uinfo->mem[1].memtype = UIO_MEM_LOGICAL; | 983 | uinfo->mem[1].memtype = UIO_MEM_LOGICAL; |
970 | 984 | ||
971 | uinfo->mem[2].addr = (unsigned long) cp->l2_ring; | 985 | uinfo->mem[2].addr = (unsigned long) udev->l2_ring; |
972 | uinfo->mem[2].size = cp->l2_ring_size; | 986 | uinfo->mem[2].size = udev->l2_ring_size; |
973 | uinfo->mem[2].memtype = UIO_MEM_LOGICAL; | 987 | uinfo->mem[2].memtype = UIO_MEM_LOGICAL; |
974 | 988 | ||
975 | uinfo->mem[3].addr = (unsigned long) cp->l2_buf; | 989 | uinfo->mem[3].addr = (unsigned long) udev->l2_buf; |
976 | uinfo->mem[3].size = cp->l2_buf_size; | 990 | uinfo->mem[3].size = udev->l2_buf_size; |
977 | uinfo->mem[3].memtype = UIO_MEM_LOGICAL; | 991 | uinfo->mem[3].memtype = UIO_MEM_LOGICAL; |
978 | 992 | ||
979 | uinfo->version = CNIC_MODULE_VERSION; | 993 | uinfo->version = CNIC_MODULE_VERSION; |
@@ -982,16 +996,11 @@ static int cnic_alloc_uio(struct cnic_dev *dev) { | |||
982 | uinfo->open = cnic_uio_open; | 996 | uinfo->open = cnic_uio_open; |
983 | uinfo->release = cnic_uio_close; | 997 | uinfo->release = cnic_uio_close; |
984 | 998 | ||
985 | uinfo->priv = dev; | 999 | uinfo->priv = udev; |
986 | 1000 | ||
987 | ret = uio_register_device(&dev->pcidev->dev, uinfo); | 1001 | ret = uio_register_device(&udev->pdev->dev, uinfo); |
988 | if (ret) { | ||
989 | kfree(uinfo); | ||
990 | return ret; | ||
991 | } | ||
992 | 1002 | ||
993 | cp->cnic_uinfo = uinfo; | 1003 | return ret; |
994 | return 0; | ||
995 | } | 1004 | } |
996 | 1005 | ||
997 | static int cnic_alloc_bnx2_resc(struct cnic_dev *dev) | 1006 | static int cnic_alloc_bnx2_resc(struct cnic_dev *dev) |
@@ -1012,11 +1021,11 @@ static int cnic_alloc_bnx2_resc(struct cnic_dev *dev) | |||
1012 | if (ret) | 1021 | if (ret) |
1013 | goto error; | 1022 | goto error; |
1014 | 1023 | ||
1015 | ret = cnic_alloc_l2_rings(dev, 2); | 1024 | ret = cnic_alloc_uio_rings(dev, 2); |
1016 | if (ret) | 1025 | if (ret) |
1017 | goto error; | 1026 | goto error; |
1018 | 1027 | ||
1019 | ret = cnic_alloc_uio(dev); | 1028 | ret = cnic_init_uio(dev); |
1020 | if (ret) | 1029 | if (ret) |
1021 | goto error; | 1030 | goto error; |
1022 | 1031 | ||
@@ -1150,11 +1159,11 @@ static int cnic_alloc_bnx2x_resc(struct cnic_dev *dev) | |||
1150 | 1159 | ||
1151 | cp->l2_rx_ring_size = 15; | 1160 | cp->l2_rx_ring_size = 15; |
1152 | 1161 | ||
1153 | ret = cnic_alloc_l2_rings(dev, 4); | 1162 | ret = cnic_alloc_uio_rings(dev, 4); |
1154 | if (ret) | 1163 | if (ret) |
1155 | goto error; | 1164 | goto error; |
1156 | 1165 | ||
1157 | ret = cnic_alloc_uio(dev); | 1166 | ret = cnic_init_uio(dev); |
1158 | if (ret) | 1167 | if (ret) |
1159 | goto error; | 1168 | goto error; |
1160 | 1169 | ||
@@ -2226,8 +2235,9 @@ static int cnic_get_kcqes(struct cnic_dev *dev, struct kcq_info *info) | |||
2226 | static int cnic_l2_completion(struct cnic_local *cp) | 2235 | static int cnic_l2_completion(struct cnic_local *cp) |
2227 | { | 2236 | { |
2228 | u16 hw_cons, sw_cons; | 2237 | u16 hw_cons, sw_cons; |
2238 | struct cnic_uio_dev *udev = cp->udev; | ||
2229 | union eth_rx_cqe *cqe, *cqe_ring = (union eth_rx_cqe *) | 2239 | union eth_rx_cqe *cqe, *cqe_ring = (union eth_rx_cqe *) |
2230 | (cp->l2_ring + (2 * BCM_PAGE_SIZE)); | 2240 | (udev->l2_ring + (2 * BCM_PAGE_SIZE)); |
2231 | u32 cmd; | 2241 | u32 cmd; |
2232 | int comp = 0; | 2242 | int comp = 0; |
2233 | 2243 | ||
@@ -2273,7 +2283,8 @@ static void cnic_chk_pkt_rings(struct cnic_local *cp) | |||
2273 | cp->tx_cons = tx_cons; | 2283 | cp->tx_cons = tx_cons; |
2274 | cp->rx_cons = rx_cons; | 2284 | cp->rx_cons = rx_cons; |
2275 | 2285 | ||
2276 | uio_event_notify(cp->cnic_uinfo); | 2286 | if (cp->udev) |
2287 | uio_event_notify(&cp->udev->cnic_uinfo); | ||
2277 | } | 2288 | } |
2278 | if (comp) | 2289 | if (comp) |
2279 | clear_bit(CNIC_LCL_FL_L2_WAIT, &cp->cnic_local_flags); | 2290 | clear_bit(CNIC_LCL_FL_L2_WAIT, &cp->cnic_local_flags); |
@@ -2435,8 +2446,7 @@ static void cnic_ulp_stop(struct cnic_dev *dev) | |||
2435 | struct cnic_local *cp = dev->cnic_priv; | 2446 | struct cnic_local *cp = dev->cnic_priv; |
2436 | int if_type; | 2447 | int if_type; |
2437 | 2448 | ||
2438 | if (cp->cnic_uinfo) | 2449 | cnic_send_nlmsg(cp, ISCSI_KEVENT_IF_DOWN, NULL); |
2439 | cnic_send_nlmsg(cp, ISCSI_KEVENT_IF_DOWN, NULL); | ||
2440 | 2450 | ||
2441 | for (if_type = 0; if_type < MAX_CNIC_ULP_TYPE; if_type++) { | 2451 | for (if_type = 0; if_type < MAX_CNIC_ULP_TYPE; if_type++) { |
2442 | struct cnic_ulp_ops *ulp_ops; | 2452 | struct cnic_ulp_ops *ulp_ops; |
@@ -3658,11 +3668,12 @@ static void cnic_init_bnx2_tx_ring(struct cnic_dev *dev) | |||
3658 | { | 3668 | { |
3659 | struct cnic_local *cp = dev->cnic_priv; | 3669 | struct cnic_local *cp = dev->cnic_priv; |
3660 | struct cnic_eth_dev *ethdev = cp->ethdev; | 3670 | struct cnic_eth_dev *ethdev = cp->ethdev; |
3671 | struct cnic_uio_dev *udev = cp->udev; | ||
3661 | u32 cid_addr, tx_cid, sb_id; | 3672 | u32 cid_addr, tx_cid, sb_id; |
3662 | u32 val, offset0, offset1, offset2, offset3; | 3673 | u32 val, offset0, offset1, offset2, offset3; |
3663 | int i; | 3674 | int i; |
3664 | struct tx_bd *txbd; | 3675 | struct tx_bd *txbd; |
3665 | dma_addr_t buf_map; | 3676 | dma_addr_t buf_map, ring_map = udev->l2_ring_map; |
3666 | struct status_block *s_blk = cp->status_blk.gen; | 3677 | struct status_block *s_blk = cp->status_blk.gen; |
3667 | 3678 | ||
3668 | sb_id = cp->status_blk_num; | 3679 | sb_id = cp->status_blk_num; |
@@ -3704,18 +3715,18 @@ static void cnic_init_bnx2_tx_ring(struct cnic_dev *dev) | |||
3704 | val = BNX2_L2CTX_CMD_TYPE_TYPE_L2 | (8 << 16); | 3715 | val = BNX2_L2CTX_CMD_TYPE_TYPE_L2 | (8 << 16); |
3705 | cnic_ctx_wr(dev, cid_addr, offset1, val); | 3716 | cnic_ctx_wr(dev, cid_addr, offset1, val); |
3706 | 3717 | ||
3707 | txbd = (struct tx_bd *) cp->l2_ring; | 3718 | txbd = (struct tx_bd *) udev->l2_ring; |
3708 | 3719 | ||
3709 | buf_map = cp->l2_buf_map; | 3720 | buf_map = udev->l2_buf_map; |
3710 | for (i = 0; i < MAX_TX_DESC_CNT; i++, txbd++) { | 3721 | for (i = 0; i < MAX_TX_DESC_CNT; i++, txbd++) { |
3711 | txbd->tx_bd_haddr_hi = (u64) buf_map >> 32; | 3722 | txbd->tx_bd_haddr_hi = (u64) buf_map >> 32; |
3712 | txbd->tx_bd_haddr_lo = (u64) buf_map & 0xffffffff; | 3723 | txbd->tx_bd_haddr_lo = (u64) buf_map & 0xffffffff; |
3713 | } | 3724 | } |
3714 | val = (u64) cp->l2_ring_map >> 32; | 3725 | val = (u64) ring_map >> 32; |
3715 | cnic_ctx_wr(dev, cid_addr, offset2, val); | 3726 | cnic_ctx_wr(dev, cid_addr, offset2, val); |
3716 | txbd->tx_bd_haddr_hi = val; | 3727 | txbd->tx_bd_haddr_hi = val; |
3717 | 3728 | ||
3718 | val = (u64) cp->l2_ring_map & 0xffffffff; | 3729 | val = (u64) ring_map & 0xffffffff; |
3719 | cnic_ctx_wr(dev, cid_addr, offset3, val); | 3730 | cnic_ctx_wr(dev, cid_addr, offset3, val); |
3720 | txbd->tx_bd_haddr_lo = val; | 3731 | txbd->tx_bd_haddr_lo = val; |
3721 | } | 3732 | } |
@@ -3724,10 +3735,12 @@ static void cnic_init_bnx2_rx_ring(struct cnic_dev *dev) | |||
3724 | { | 3735 | { |
3725 | struct cnic_local *cp = dev->cnic_priv; | 3736 | struct cnic_local *cp = dev->cnic_priv; |
3726 | struct cnic_eth_dev *ethdev = cp->ethdev; | 3737 | struct cnic_eth_dev *ethdev = cp->ethdev; |
3738 | struct cnic_uio_dev *udev = cp->udev; | ||
3727 | u32 cid_addr, sb_id, val, coal_reg, coal_val; | 3739 | u32 cid_addr, sb_id, val, coal_reg, coal_val; |
3728 | int i; | 3740 | int i; |
3729 | struct rx_bd *rxbd; | 3741 | struct rx_bd *rxbd; |
3730 | struct status_block *s_blk = cp->status_blk.gen; | 3742 | struct status_block *s_blk = cp->status_blk.gen; |
3743 | dma_addr_t ring_map = udev->l2_ring_map; | ||
3731 | 3744 | ||
3732 | sb_id = cp->status_blk_num; | 3745 | sb_id = cp->status_blk_num; |
3733 | cnic_init_context(dev, 2); | 3746 | cnic_init_context(dev, 2); |
@@ -3761,22 +3774,22 @@ static void cnic_init_bnx2_rx_ring(struct cnic_dev *dev) | |||
3761 | val = BNX2_L2CTX_L2_STATUSB_NUM(sb_id); | 3774 | val = BNX2_L2CTX_L2_STATUSB_NUM(sb_id); |
3762 | cnic_ctx_wr(dev, cid_addr, BNX2_L2CTX_HOST_BDIDX, val); | 3775 | cnic_ctx_wr(dev, cid_addr, BNX2_L2CTX_HOST_BDIDX, val); |
3763 | 3776 | ||
3764 | rxbd = (struct rx_bd *) (cp->l2_ring + BCM_PAGE_SIZE); | 3777 | rxbd = (struct rx_bd *) (udev->l2_ring + BCM_PAGE_SIZE); |
3765 | for (i = 0; i < MAX_RX_DESC_CNT; i++, rxbd++) { | 3778 | for (i = 0; i < MAX_RX_DESC_CNT; i++, rxbd++) { |
3766 | dma_addr_t buf_map; | 3779 | dma_addr_t buf_map; |
3767 | int n = (i % cp->l2_rx_ring_size) + 1; | 3780 | int n = (i % cp->l2_rx_ring_size) + 1; |
3768 | 3781 | ||
3769 | buf_map = cp->l2_buf_map + (n * cp->l2_single_buf_size); | 3782 | buf_map = udev->l2_buf_map + (n * cp->l2_single_buf_size); |
3770 | rxbd->rx_bd_len = cp->l2_single_buf_size; | 3783 | rxbd->rx_bd_len = cp->l2_single_buf_size; |
3771 | rxbd->rx_bd_flags = RX_BD_FLAGS_START | RX_BD_FLAGS_END; | 3784 | rxbd->rx_bd_flags = RX_BD_FLAGS_START | RX_BD_FLAGS_END; |
3772 | rxbd->rx_bd_haddr_hi = (u64) buf_map >> 32; | 3785 | rxbd->rx_bd_haddr_hi = (u64) buf_map >> 32; |
3773 | rxbd->rx_bd_haddr_lo = (u64) buf_map & 0xffffffff; | 3786 | rxbd->rx_bd_haddr_lo = (u64) buf_map & 0xffffffff; |
3774 | } | 3787 | } |
3775 | val = (u64) (cp->l2_ring_map + BCM_PAGE_SIZE) >> 32; | 3788 | val = (u64) (ring_map + BCM_PAGE_SIZE) >> 32; |
3776 | cnic_ctx_wr(dev, cid_addr, BNX2_L2CTX_NX_BDHADDR_HI, val); | 3789 | cnic_ctx_wr(dev, cid_addr, BNX2_L2CTX_NX_BDHADDR_HI, val); |
3777 | rxbd->rx_bd_haddr_hi = val; | 3790 | rxbd->rx_bd_haddr_hi = val; |
3778 | 3791 | ||
3779 | val = (u64) (cp->l2_ring_map + BCM_PAGE_SIZE) & 0xffffffff; | 3792 | val = (u64) (ring_map + BCM_PAGE_SIZE) & 0xffffffff; |
3780 | cnic_ctx_wr(dev, cid_addr, BNX2_L2CTX_NX_BDHADDR_LO, val); | 3793 | cnic_ctx_wr(dev, cid_addr, BNX2_L2CTX_NX_BDHADDR_LO, val); |
3781 | rxbd->rx_bd_haddr_lo = val; | 3794 | rxbd->rx_bd_haddr_lo = val; |
3782 | 3795 | ||
@@ -4038,8 +4051,9 @@ static void cnic_init_bnx2x_tx_ring(struct cnic_dev *dev, | |||
4038 | struct client_init_ramrod_data *data) | 4051 | struct client_init_ramrod_data *data) |
4039 | { | 4052 | { |
4040 | struct cnic_local *cp = dev->cnic_priv; | 4053 | struct cnic_local *cp = dev->cnic_priv; |
4041 | union eth_tx_bd_types *txbd = (union eth_tx_bd_types *) cp->l2_ring; | 4054 | struct cnic_uio_dev *udev = cp->udev; |
4042 | dma_addr_t buf_map, ring_map = cp->l2_ring_map; | 4055 | union eth_tx_bd_types *txbd = (union eth_tx_bd_types *) udev->l2_ring; |
4056 | dma_addr_t buf_map, ring_map = udev->l2_ring_map; | ||
4043 | struct host_sp_status_block *sb = cp->bnx2x_def_status_blk; | 4057 | struct host_sp_status_block *sb = cp->bnx2x_def_status_blk; |
4044 | int port = CNIC_PORT(cp); | 4058 | int port = CNIC_PORT(cp); |
4045 | int i; | 4059 | int i; |
@@ -4048,7 +4062,7 @@ static void cnic_init_bnx2x_tx_ring(struct cnic_dev *dev, | |||
4048 | 4062 | ||
4049 | memset(txbd, 0, BCM_PAGE_SIZE); | 4063 | memset(txbd, 0, BCM_PAGE_SIZE); |
4050 | 4064 | ||
4051 | buf_map = cp->l2_buf_map; | 4065 | buf_map = udev->l2_buf_map; |
4052 | for (i = 0; i < MAX_TX_DESC_CNT; i += 3, txbd += 3) { | 4066 | for (i = 0; i < MAX_TX_DESC_CNT; i += 3, txbd += 3) { |
4053 | struct eth_tx_start_bd *start_bd = &txbd->start_bd; | 4067 | struct eth_tx_start_bd *start_bd = &txbd->start_bd; |
4054 | struct eth_tx_bd *reg_bd = &((txbd + 2)->reg_bd); | 4068 | struct eth_tx_bd *reg_bd = &((txbd + 2)->reg_bd); |
@@ -4096,17 +4110,18 @@ static void cnic_init_bnx2x_rx_ring(struct cnic_dev *dev, | |||
4096 | struct client_init_ramrod_data *data) | 4110 | struct client_init_ramrod_data *data) |
4097 | { | 4111 | { |
4098 | struct cnic_local *cp = dev->cnic_priv; | 4112 | struct cnic_local *cp = dev->cnic_priv; |
4099 | struct eth_rx_bd *rxbd = (struct eth_rx_bd *) (cp->l2_ring + | 4113 | struct cnic_uio_dev *udev = cp->udev; |
4114 | struct eth_rx_bd *rxbd = (struct eth_rx_bd *) (udev->l2_ring + | ||
4100 | BCM_PAGE_SIZE); | 4115 | BCM_PAGE_SIZE); |
4101 | struct eth_rx_cqe_next_page *rxcqe = (struct eth_rx_cqe_next_page *) | 4116 | struct eth_rx_cqe_next_page *rxcqe = (struct eth_rx_cqe_next_page *) |
4102 | (cp->l2_ring + (2 * BCM_PAGE_SIZE)); | 4117 | (udev->l2_ring + (2 * BCM_PAGE_SIZE)); |
4103 | struct host_sp_status_block *sb = cp->bnx2x_def_status_blk; | 4118 | struct host_sp_status_block *sb = cp->bnx2x_def_status_blk; |
4104 | int i; | 4119 | int i; |
4105 | int port = CNIC_PORT(cp); | 4120 | int port = CNIC_PORT(cp); |
4106 | int cli = BNX2X_ISCSI_CL_ID(CNIC_E1HVN(cp)); | 4121 | int cli = BNX2X_ISCSI_CL_ID(CNIC_E1HVN(cp)); |
4107 | int cl_qzone_id = BNX2X_CL_QZONE_ID(cp, cli); | 4122 | int cl_qzone_id = BNX2X_CL_QZONE_ID(cp, cli); |
4108 | u32 val; | 4123 | u32 val; |
4109 | dma_addr_t ring_map = cp->l2_ring_map; | 4124 | dma_addr_t ring_map = udev->l2_ring_map; |
4110 | 4125 | ||
4111 | /* General data */ | 4126 | /* General data */ |
4112 | data->general.client_id = cli; | 4127 | data->general.client_id = cli; |
@@ -4119,7 +4134,7 @@ static void cnic_init_bnx2x_rx_ring(struct cnic_dev *dev, | |||
4119 | dma_addr_t buf_map; | 4134 | dma_addr_t buf_map; |
4120 | int n = (i % cp->l2_rx_ring_size) + 1; | 4135 | int n = (i % cp->l2_rx_ring_size) + 1; |
4121 | 4136 | ||
4122 | buf_map = cp->l2_buf_map + (n * cp->l2_single_buf_size); | 4137 | buf_map = udev->l2_buf_map + (n * cp->l2_single_buf_size); |
4123 | rxbd->addr_hi = cpu_to_le32((u64) buf_map >> 32); | 4138 | rxbd->addr_hi = cpu_to_le32((u64) buf_map >> 32); |
4124 | rxbd->addr_lo = cpu_to_le32(buf_map & 0xffffffff); | 4139 | rxbd->addr_lo = cpu_to_le32(buf_map & 0xffffffff); |
4125 | } | 4140 | } |
@@ -4320,6 +4335,7 @@ static int cnic_start_bnx2x_hw(struct cnic_dev *dev) | |||
4320 | static void cnic_init_rings(struct cnic_dev *dev) | 4335 | static void cnic_init_rings(struct cnic_dev *dev) |
4321 | { | 4336 | { |
4322 | struct cnic_local *cp = dev->cnic_priv; | 4337 | struct cnic_local *cp = dev->cnic_priv; |
4338 | struct cnic_uio_dev *udev = cp->udev; | ||
4323 | 4339 | ||
4324 | if (test_bit(CNIC_LCL_FL_RINGS_INITED, &cp->cnic_local_flags)) | 4340 | if (test_bit(CNIC_LCL_FL_RINGS_INITED, &cp->cnic_local_flags)) |
4325 | return; | 4341 | return; |
@@ -4350,15 +4366,15 @@ static void cnic_init_rings(struct cnic_dev *dev) | |||
4350 | 4366 | ||
4351 | set_bit(CNIC_LCL_FL_L2_WAIT, &cp->cnic_local_flags); | 4367 | set_bit(CNIC_LCL_FL_L2_WAIT, &cp->cnic_local_flags); |
4352 | 4368 | ||
4353 | data = cp->l2_buf; | 4369 | data = udev->l2_buf; |
4354 | 4370 | ||
4355 | memset(data, 0, sizeof(*data)); | 4371 | memset(data, 0, sizeof(*data)); |
4356 | 4372 | ||
4357 | cnic_init_bnx2x_tx_ring(dev, data); | 4373 | cnic_init_bnx2x_tx_ring(dev, data); |
4358 | cnic_init_bnx2x_rx_ring(dev, data); | 4374 | cnic_init_bnx2x_rx_ring(dev, data); |
4359 | 4375 | ||
4360 | l5_data.phy_address.lo = cp->l2_buf_map & 0xffffffff; | 4376 | l5_data.phy_address.lo = udev->l2_buf_map & 0xffffffff; |
4361 | l5_data.phy_address.hi = (u64) cp->l2_buf_map >> 32; | 4377 | l5_data.phy_address.hi = (u64) udev->l2_buf_map >> 32; |
4362 | 4378 | ||
4363 | type = (ETH_CONNECTION_TYPE << SPE_HDR_CONN_TYPE_SHIFT) | 4379 | type = (ETH_CONNECTION_TYPE << SPE_HDR_CONN_TYPE_SHIFT) |
4364 | & SPE_HDR_CONN_TYPE; | 4380 | & SPE_HDR_CONN_TYPE; |
@@ -4539,7 +4555,7 @@ static void cnic_stop_hw(struct cnic_dev *dev) | |||
4539 | /* Need to wait for the ring shutdown event to complete | 4555 | /* Need to wait for the ring shutdown event to complete |
4540 | * before clearing the CNIC_UP flag. | 4556 | * before clearing the CNIC_UP flag. |
4541 | */ | 4557 | */ |
4542 | while (cp->uio_dev != -1 && i < 15) { | 4558 | while (cp->udev->uio_dev != -1 && i < 15) { |
4543 | msleep(100); | 4559 | msleep(100); |
4544 | i++; | 4560 | i++; |
4545 | } | 4561 | } |
@@ -4591,7 +4607,6 @@ static struct cnic_dev *cnic_alloc_dev(struct net_device *dev, | |||
4591 | 4607 | ||
4592 | cp = cdev->cnic_priv; | 4608 | cp = cdev->cnic_priv; |
4593 | cp->dev = cdev; | 4609 | cp->dev = cdev; |
4594 | cp->uio_dev = -1; | ||
4595 | cp->l2_single_buf_size = 0x400; | 4610 | cp->l2_single_buf_size = 0x400; |
4596 | cp->l2_rx_ring_size = 3; | 4611 | cp->l2_rx_ring_size = 3; |
4597 | 4612 | ||