diff options
-rw-r--r-- | drivers/net/cnic.c | 32 | ||||
-rw-r--r-- | drivers/net/cnic.h | 4 |
2 files changed, 21 insertions, 15 deletions
diff --git a/drivers/net/cnic.c b/drivers/net/cnic.c index 04e299f46455..70a53cc7df32 100644 --- a/drivers/net/cnic.c +++ b/drivers/net/cnic.c | |||
@@ -257,7 +257,7 @@ static int cnic_get_l5_cid(struct cnic_local *cp, u32 cid, u32 *l5_cid) | |||
257 | { | 257 | { |
258 | u32 i; | 258 | u32 i; |
259 | 259 | ||
260 | for (i = 0; i < MAX_ISCSI_TBL_SZ; i++) { | 260 | for (i = 0; i < cp->max_cid_space; i++) { |
261 | if (cp->ctx_tbl[i].cid == cid) { | 261 | if (cp->ctx_tbl[i].cid == cid) { |
262 | *l5_cid = i; | 262 | *l5_cid = i; |
263 | return 0; | 263 | return 0; |
@@ -981,17 +981,10 @@ error: | |||
981 | static int cnic_alloc_bnx2x_context(struct cnic_dev *dev) | 981 | static int cnic_alloc_bnx2x_context(struct cnic_dev *dev) |
982 | { | 982 | { |
983 | struct cnic_local *cp = dev->cnic_priv; | 983 | struct cnic_local *cp = dev->cnic_priv; |
984 | struct cnic_eth_dev *ethdev = cp->ethdev; | ||
985 | int ctx_blk_size = cp->ethdev->ctx_blk_size; | 984 | int ctx_blk_size = cp->ethdev->ctx_blk_size; |
986 | int total_mem, blks, i, cid_space; | 985 | int total_mem, blks, i; |
987 | |||
988 | if (BNX2X_ISCSI_START_CID < ethdev->starting_cid) | ||
989 | return -EINVAL; | ||
990 | |||
991 | cid_space = MAX_ISCSI_TBL_SZ + | ||
992 | (BNX2X_ISCSI_START_CID - ethdev->starting_cid); | ||
993 | 986 | ||
994 | total_mem = BNX2X_CONTEXT_MEM_SIZE * cid_space; | 987 | total_mem = BNX2X_CONTEXT_MEM_SIZE * cp->max_cid_space; |
995 | blks = total_mem / ctx_blk_size; | 988 | blks = total_mem / ctx_blk_size; |
996 | if (total_mem % ctx_blk_size) | 989 | if (total_mem % ctx_blk_size) |
997 | blks++; | 990 | blks++; |
@@ -1035,16 +1028,27 @@ static int cnic_alloc_bnx2x_context(struct cnic_dev *dev) | |||
1035 | static int cnic_alloc_bnx2x_resc(struct cnic_dev *dev) | 1028 | static int cnic_alloc_bnx2x_resc(struct cnic_dev *dev) |
1036 | { | 1029 | { |
1037 | struct cnic_local *cp = dev->cnic_priv; | 1030 | struct cnic_local *cp = dev->cnic_priv; |
1031 | struct cnic_eth_dev *ethdev = cp->ethdev; | ||
1032 | u32 start_cid = ethdev->starting_cid; | ||
1038 | int i, j, n, ret, pages; | 1033 | int i, j, n, ret, pages; |
1039 | struct cnic_dma *kwq_16_dma = &cp->kwq_16_data_info; | 1034 | struct cnic_dma *kwq_16_dma = &cp->kwq_16_data_info; |
1040 | 1035 | ||
1036 | cp->max_cid_space = MAX_ISCSI_TBL_SZ; | ||
1037 | cp->iscsi_start_cid = start_cid; | ||
1038 | if (start_cid < BNX2X_ISCSI_START_CID) { | ||
1039 | u32 delta = BNX2X_ISCSI_START_CID - start_cid; | ||
1040 | |||
1041 | cp->iscsi_start_cid = BNX2X_ISCSI_START_CID; | ||
1042 | cp->max_cid_space += delta; | ||
1043 | } | ||
1044 | |||
1041 | cp->iscsi_tbl = kzalloc(sizeof(struct cnic_iscsi) * MAX_ISCSI_TBL_SZ, | 1045 | cp->iscsi_tbl = kzalloc(sizeof(struct cnic_iscsi) * MAX_ISCSI_TBL_SZ, |
1042 | GFP_KERNEL); | 1046 | GFP_KERNEL); |
1043 | if (!cp->iscsi_tbl) | 1047 | if (!cp->iscsi_tbl) |
1044 | goto error; | 1048 | goto error; |
1045 | 1049 | ||
1046 | cp->ctx_tbl = kzalloc(sizeof(struct cnic_context) * | 1050 | cp->ctx_tbl = kzalloc(sizeof(struct cnic_context) * |
1047 | MAX_CNIC_L5_CONTEXT, GFP_KERNEL); | 1051 | cp->max_cid_space, GFP_KERNEL); |
1048 | if (!cp->ctx_tbl) | 1052 | if (!cp->ctx_tbl) |
1049 | goto error; | 1053 | goto error; |
1050 | 1054 | ||
@@ -1053,7 +1057,7 @@ static int cnic_alloc_bnx2x_resc(struct cnic_dev *dev) | |||
1053 | cp->ctx_tbl[i].ulp_proto_id = CNIC_ULP_ISCSI; | 1057 | cp->ctx_tbl[i].ulp_proto_id = CNIC_ULP_ISCSI; |
1054 | } | 1058 | } |
1055 | 1059 | ||
1056 | pages = PAGE_ALIGN(MAX_CNIC_L5_CONTEXT * CNIC_KWQ16_DATA_SIZE) / | 1060 | pages = PAGE_ALIGN(cp->max_cid_space * CNIC_KWQ16_DATA_SIZE) / |
1057 | PAGE_SIZE; | 1061 | PAGE_SIZE; |
1058 | 1062 | ||
1059 | ret = cnic_alloc_dma(dev, kwq_16_dma, pages, 0); | 1063 | ret = cnic_alloc_dma(dev, kwq_16_dma, pages, 0); |
@@ -1061,7 +1065,7 @@ static int cnic_alloc_bnx2x_resc(struct cnic_dev *dev) | |||
1061 | return -ENOMEM; | 1065 | return -ENOMEM; |
1062 | 1066 | ||
1063 | n = PAGE_SIZE / CNIC_KWQ16_DATA_SIZE; | 1067 | n = PAGE_SIZE / CNIC_KWQ16_DATA_SIZE; |
1064 | for (i = 0, j = 0; i < MAX_ISCSI_TBL_SZ; i++) { | 1068 | for (i = 0, j = 0; i < cp->max_cid_space; i++) { |
1065 | long off = CNIC_KWQ16_DATA_SIZE * (i % n); | 1069 | long off = CNIC_KWQ16_DATA_SIZE * (i % n); |
1066 | 1070 | ||
1067 | cp->ctx_tbl[i].kwqe_data = kwq_16_dma->pg_arr[j] + off; | 1071 | cp->ctx_tbl[i].kwqe_data = kwq_16_dma->pg_arr[j] + off; |
@@ -4129,7 +4133,7 @@ static int cnic_start_bnx2x_hw(struct cnic_dev *dev) | |||
4129 | u8 sb_id = cp->status_blk_num; | 4133 | u8 sb_id = cp->status_blk_num; |
4130 | 4134 | ||
4131 | ret = cnic_init_id_tbl(&cp->cid_tbl, MAX_ISCSI_TBL_SZ, | 4135 | ret = cnic_init_id_tbl(&cp->cid_tbl, MAX_ISCSI_TBL_SZ, |
4132 | BNX2X_ISCSI_START_CID); | 4136 | cp->iscsi_start_cid); |
4133 | 4137 | ||
4134 | if (ret) | 4138 | if (ret) |
4135 | return -ENOMEM; | 4139 | return -ENOMEM; |
diff --git a/drivers/net/cnic.h b/drivers/net/cnic.h index 08b1235d987d..b7e2f7fcfb1c 100644 --- a/drivers/net/cnic.h +++ b/drivers/net/cnic.h | |||
@@ -248,8 +248,10 @@ struct cnic_local { | |||
248 | struct cnic_iscsi *iscsi_tbl; | 248 | struct cnic_iscsi *iscsi_tbl; |
249 | struct cnic_context *ctx_tbl; | 249 | struct cnic_context *ctx_tbl; |
250 | struct cnic_id_tbl cid_tbl; | 250 | struct cnic_id_tbl cid_tbl; |
251 | int max_iscsi_conn; | ||
252 | atomic_t iscsi_conn; | 251 | atomic_t iscsi_conn; |
252 | u32 iscsi_start_cid; | ||
253 | |||
254 | u32 max_cid_space; | ||
253 | 255 | ||
254 | /* per connection parameters */ | 256 | /* per connection parameters */ |
255 | int num_iscsi_tasks; | 257 | int num_iscsi_tasks; |