diff options
author | Michael Chan <mchan@broadcom.com> | 2011-06-13 21:32:38 -0400 |
---|---|---|
committer | David S. Miller <davem@conan.davemloft.net> | 2011-06-15 10:56:12 -0400 |
commit | 59e5137357559ec60b2e72bdc3d5a7e22c47212b (patch) | |
tree | d5656a3545e64020c82166c2933a8e47b375da59 /drivers | |
parent | b7c7deeb4c77538577f0b6a724f10ce8693eb648 (diff) |
cnic: Move indexing function pointers to struct kcq_info
The hardware indexing scheme for the FCoE kcq will change in the upcoming
firmware. This patch will cope with the change easily.
Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: Vladislav Zolotarov <vladz@broadcom.com>
Signed-off-by: David S. Miller <davem@conan.davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/cnic.c | 84 | ||||
-rw-r--r-- | drivers/net/cnic.h | 5 |
2 files changed, 46 insertions, 43 deletions
diff --git a/drivers/net/cnic.c b/drivers/net/cnic.c index 363c7f368909..07f1b13c8dce 100644 --- a/drivers/net/cnic.c +++ b/drivers/net/cnic.c | |||
@@ -900,24 +900,56 @@ static int cnic_alloc_context(struct cnic_dev *dev) | |||
900 | return 0; | 900 | return 0; |
901 | } | 901 | } |
902 | 902 | ||
903 | static int cnic_alloc_kcq(struct cnic_dev *dev, struct kcq_info *info) | 903 | static u16 cnic_bnx2_next_idx(u16 idx) |
904 | { | ||
905 | return idx + 1; | ||
906 | } | ||
907 | |||
908 | static u16 cnic_bnx2_hw_idx(u16 idx) | ||
909 | { | ||
910 | return idx; | ||
911 | } | ||
912 | |||
913 | static u16 cnic_bnx2x_next_idx(u16 idx) | ||
904 | { | 914 | { |
905 | int err, i, is_bnx2 = 0; | 915 | idx++; |
916 | if ((idx & MAX_KCQE_CNT) == MAX_KCQE_CNT) | ||
917 | idx++; | ||
918 | |||
919 | return idx; | ||
920 | } | ||
921 | |||
922 | static u16 cnic_bnx2x_hw_idx(u16 idx) | ||
923 | { | ||
924 | if ((idx & MAX_KCQE_CNT) == MAX_KCQE_CNT) | ||
925 | idx++; | ||
926 | return idx; | ||
927 | } | ||
928 | |||
929 | static int cnic_alloc_kcq(struct cnic_dev *dev, struct kcq_info *info, | ||
930 | bool use_pg_tbl) | ||
931 | { | ||
932 | int err, i, use_page_tbl = 0; | ||
906 | struct kcqe **kcq; | 933 | struct kcqe **kcq; |
907 | 934 | ||
908 | if (test_bit(CNIC_F_BNX2_CLASS, &dev->flags)) | 935 | if (use_pg_tbl) |
909 | is_bnx2 = 1; | 936 | use_page_tbl = 1; |
910 | 937 | ||
911 | err = cnic_alloc_dma(dev, &info->dma, KCQ_PAGE_CNT, is_bnx2); | 938 | err = cnic_alloc_dma(dev, &info->dma, KCQ_PAGE_CNT, use_page_tbl); |
912 | if (err) | 939 | if (err) |
913 | return err; | 940 | return err; |
914 | 941 | ||
915 | kcq = (struct kcqe **) info->dma.pg_arr; | 942 | kcq = (struct kcqe **) info->dma.pg_arr; |
916 | info->kcq = kcq; | 943 | info->kcq = kcq; |
917 | 944 | ||
918 | if (is_bnx2) | 945 | info->next_idx = cnic_bnx2_next_idx; |
946 | info->hw_idx = cnic_bnx2_hw_idx; | ||
947 | if (use_pg_tbl) | ||
919 | return 0; | 948 | return 0; |
920 | 949 | ||
950 | info->next_idx = cnic_bnx2x_next_idx; | ||
951 | info->hw_idx = cnic_bnx2x_hw_idx; | ||
952 | |||
921 | for (i = 0; i < KCQ_PAGE_CNT; i++) { | 953 | for (i = 0; i < KCQ_PAGE_CNT; i++) { |
922 | struct bnx2x_bd_chain_next *next = | 954 | struct bnx2x_bd_chain_next *next = |
923 | (struct bnx2x_bd_chain_next *) &kcq[i][MAX_KCQE_CNT]; | 955 | (struct bnx2x_bd_chain_next *) &kcq[i][MAX_KCQE_CNT]; |
@@ -1060,7 +1092,7 @@ static int cnic_alloc_bnx2_resc(struct cnic_dev *dev) | |||
1060 | goto error; | 1092 | goto error; |
1061 | cp->kwq = (struct kwqe **) cp->kwq_info.pg_arr; | 1093 | cp->kwq = (struct kwqe **) cp->kwq_info.pg_arr; |
1062 | 1094 | ||
1063 | ret = cnic_alloc_kcq(dev, &cp->kcq1); | 1095 | ret = cnic_alloc_kcq(dev, &cp->kcq1, true); |
1064 | if (ret) | 1096 | if (ret) |
1065 | goto error; | 1097 | goto error; |
1066 | 1098 | ||
@@ -1196,12 +1228,12 @@ static int cnic_alloc_bnx2x_resc(struct cnic_dev *dev) | |||
1196 | j++; | 1228 | j++; |
1197 | } | 1229 | } |
1198 | 1230 | ||
1199 | ret = cnic_alloc_kcq(dev, &cp->kcq1); | 1231 | ret = cnic_alloc_kcq(dev, &cp->kcq1, false); |
1200 | if (ret) | 1232 | if (ret) |
1201 | goto error; | 1233 | goto error; |
1202 | 1234 | ||
1203 | if (BNX2X_CHIP_IS_E2(cp->chip_id)) { | 1235 | if (BNX2X_CHIP_IS_E2(cp->chip_id)) { |
1204 | ret = cnic_alloc_kcq(dev, &cp->kcq2); | 1236 | ret = cnic_alloc_kcq(dev, &cp->kcq2, false); |
1205 | if (ret) | 1237 | if (ret) |
1206 | goto error; | 1238 | goto error; |
1207 | } | 1239 | } |
@@ -2652,32 +2684,6 @@ end: | |||
2652 | cnic_spq_completion(dev, DRV_CTL_RET_L5_SPQ_CREDIT_CMD, comp); | 2684 | cnic_spq_completion(dev, DRV_CTL_RET_L5_SPQ_CREDIT_CMD, comp); |
2653 | } | 2685 | } |
2654 | 2686 | ||
2655 | static u16 cnic_bnx2_next_idx(u16 idx) | ||
2656 | { | ||
2657 | return idx + 1; | ||
2658 | } | ||
2659 | |||
2660 | static u16 cnic_bnx2_hw_idx(u16 idx) | ||
2661 | { | ||
2662 | return idx; | ||
2663 | } | ||
2664 | |||
2665 | static u16 cnic_bnx2x_next_idx(u16 idx) | ||
2666 | { | ||
2667 | idx++; | ||
2668 | if ((idx & MAX_KCQE_CNT) == MAX_KCQE_CNT) | ||
2669 | idx++; | ||
2670 | |||
2671 | return idx; | ||
2672 | } | ||
2673 | |||
2674 | static u16 cnic_bnx2x_hw_idx(u16 idx) | ||
2675 | { | ||
2676 | if ((idx & MAX_KCQE_CNT) == MAX_KCQE_CNT) | ||
2677 | idx++; | ||
2678 | return idx; | ||
2679 | } | ||
2680 | |||
2681 | static int cnic_get_kcqes(struct cnic_dev *dev, struct kcq_info *info) | 2687 | static int cnic_get_kcqes(struct cnic_dev *dev, struct kcq_info *info) |
2682 | { | 2688 | { |
2683 | struct cnic_local *cp = dev->cnic_priv; | 2689 | struct cnic_local *cp = dev->cnic_priv; |
@@ -2688,12 +2694,12 @@ static int cnic_get_kcqes(struct cnic_dev *dev, struct kcq_info *info) | |||
2688 | i = ri = last = info->sw_prod_idx; | 2694 | i = ri = last = info->sw_prod_idx; |
2689 | ri &= MAX_KCQ_IDX; | 2695 | ri &= MAX_KCQ_IDX; |
2690 | hw_prod = *info->hw_prod_idx_ptr; | 2696 | hw_prod = *info->hw_prod_idx_ptr; |
2691 | hw_prod = cp->hw_idx(hw_prod); | 2697 | hw_prod = info->hw_idx(hw_prod); |
2692 | 2698 | ||
2693 | while ((i != hw_prod) && (kcqe_cnt < MAX_COMPLETED_KCQE)) { | 2699 | while ((i != hw_prod) && (kcqe_cnt < MAX_COMPLETED_KCQE)) { |
2694 | kcqe = &info->kcq[KCQ_PG(ri)][KCQ_IDX(ri)]; | 2700 | kcqe = &info->kcq[KCQ_PG(ri)][KCQ_IDX(ri)]; |
2695 | cp->completed_kcq[kcqe_cnt++] = kcqe; | 2701 | cp->completed_kcq[kcqe_cnt++] = kcqe; |
2696 | i = cp->next_idx(i); | 2702 | i = info->next_idx(i); |
2697 | ri = i & MAX_KCQ_IDX; | 2703 | ri = i & MAX_KCQ_IDX; |
2698 | if (likely(!(kcqe->kcqe_op_flag & KCQE_FLAGS_NEXT))) { | 2704 | if (likely(!(kcqe->kcqe_op_flag & KCQE_FLAGS_NEXT))) { |
2699 | last_cnt = kcqe_cnt; | 2705 | last_cnt = kcqe_cnt; |
@@ -5227,8 +5233,6 @@ static struct cnic_dev *init_bnx2_cnic(struct net_device *dev) | |||
5227 | cp->enable_int = cnic_enable_bnx2_int; | 5233 | cp->enable_int = cnic_enable_bnx2_int; |
5228 | cp->disable_int_sync = cnic_disable_bnx2_int_sync; | 5234 | cp->disable_int_sync = cnic_disable_bnx2_int_sync; |
5229 | cp->close_conn = cnic_close_bnx2_conn; | 5235 | cp->close_conn = cnic_close_bnx2_conn; |
5230 | cp->next_idx = cnic_bnx2_next_idx; | ||
5231 | cp->hw_idx = cnic_bnx2_hw_idx; | ||
5232 | return cdev; | 5236 | return cdev; |
5233 | 5237 | ||
5234 | cnic_err: | 5238 | cnic_err: |
@@ -5294,8 +5298,6 @@ static struct cnic_dev *init_bnx2x_cnic(struct net_device *dev) | |||
5294 | else | 5298 | else |
5295 | cp->ack_int = cnic_ack_bnx2x_msix; | 5299 | cp->ack_int = cnic_ack_bnx2x_msix; |
5296 | cp->close_conn = cnic_close_bnx2x_conn; | 5300 | cp->close_conn = cnic_close_bnx2x_conn; |
5297 | cp->next_idx = cnic_bnx2x_next_idx; | ||
5298 | cp->hw_idx = cnic_bnx2x_hw_idx; | ||
5299 | return cdev; | 5301 | return cdev; |
5300 | } | 5302 | } |
5301 | 5303 | ||
diff --git a/drivers/net/cnic.h b/drivers/net/cnic.h index 3367a6d3a774..eb11821108a0 100644 --- a/drivers/net/cnic.h +++ b/drivers/net/cnic.h | |||
@@ -185,6 +185,9 @@ struct kcq_info { | |||
185 | u16 sw_prod_idx; | 185 | u16 sw_prod_idx; |
186 | u16 *status_idx_ptr; | 186 | u16 *status_idx_ptr; |
187 | u32 io_addr; | 187 | u32 io_addr; |
188 | |||
189 | u16 (*next_idx)(u16); | ||
190 | u16 (*hw_idx)(u16); | ||
188 | }; | 191 | }; |
189 | 192 | ||
190 | struct iro { | 193 | struct iro { |
@@ -332,8 +335,6 @@ struct cnic_local { | |||
332 | void (*disable_int_sync)(struct cnic_dev *); | 335 | void (*disable_int_sync)(struct cnic_dev *); |
333 | void (*ack_int)(struct cnic_dev *); | 336 | void (*ack_int)(struct cnic_dev *); |
334 | void (*close_conn)(struct cnic_sock *, u32 opcode); | 337 | void (*close_conn)(struct cnic_sock *, u32 opcode); |
335 | u16 (*next_idx)(u16); | ||
336 | u16 (*hw_idx)(u16); | ||
337 | }; | 338 | }; |
338 | 339 | ||
339 | struct bnx2x_bd_chain_next { | 340 | struct bnx2x_bd_chain_next { |