aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/cnic.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/cnic.c')
-rw-r--r--drivers/net/cnic.c84
1 files changed, 43 insertions, 41 deletions
diff --git a/drivers/net/cnic.c b/drivers/net/cnic.c
index 363c7f36890..07f1b13c8dc 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
903static int cnic_alloc_kcq(struct cnic_dev *dev, struct kcq_info *info) 903static u16 cnic_bnx2_next_idx(u16 idx)
904{
905 return idx + 1;
906}
907
908static u16 cnic_bnx2_hw_idx(u16 idx)
909{
910 return idx;
911}
912
913static 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
922static u16 cnic_bnx2x_hw_idx(u16 idx)
923{
924 if ((idx & MAX_KCQE_CNT) == MAX_KCQE_CNT)
925 idx++;
926 return idx;
927}
928
929static 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
2655static u16 cnic_bnx2_next_idx(u16 idx)
2656{
2657 return idx + 1;
2658}
2659
2660static u16 cnic_bnx2_hw_idx(u16 idx)
2661{
2662 return idx;
2663}
2664
2665static 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
2674static u16 cnic_bnx2x_hw_idx(u16 idx)
2675{
2676 if ((idx & MAX_KCQE_CNT) == MAX_KCQE_CNT)
2677 idx++;
2678 return idx;
2679}
2680
2681static int cnic_get_kcqes(struct cnic_dev *dev, struct kcq_info *info) 2687static 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
5234cnic_err: 5238cnic_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