@@ -82,22 +82,35 @@ static void bnxt_re_ib_unreg(struct bnxt_re_dev *rdev);
82
82
83
83
static void bnxt_re_destroy_chip_ctx (struct bnxt_re_dev * rdev )
84
84
{
85
+ struct bnxt_qplib_chip_ctx * chip_ctx ;
86
+
87
+ if (!rdev -> chip_ctx )
88
+ return ;
89
+ chip_ctx = rdev -> chip_ctx ;
90
+ rdev -> chip_ctx = NULL ;
85
91
rdev -> rcfw .res = NULL ;
86
92
rdev -> qplib_res .cctx = NULL ;
93
+ kfree (chip_ctx );
87
94
}
88
95
89
96
static int bnxt_re_setup_chip_ctx (struct bnxt_re_dev * rdev )
90
97
{
98
+ struct bnxt_qplib_chip_ctx * chip_ctx ;
91
99
struct bnxt_en_dev * en_dev ;
92
100
struct bnxt * bp ;
93
101
94
102
en_dev = rdev -> en_dev ;
95
103
bp = netdev_priv (en_dev -> net );
96
104
97
- rdev -> chip_ctx .chip_num = bp -> chip_num ;
105
+ chip_ctx = kzalloc (sizeof (* chip_ctx ), GFP_KERNEL );
106
+ if (!chip_ctx )
107
+ return - ENOMEM ;
108
+ chip_ctx -> chip_num = bp -> chip_num ;
109
+
110
+ rdev -> chip_ctx = chip_ctx ;
98
111
/* rest members to follow eventually */
99
112
100
- rdev -> qplib_res .cctx = & rdev -> chip_ctx ;
113
+ rdev -> qplib_res .cctx = rdev -> chip_ctx ;
101
114
rdev -> rcfw .res = & rdev -> qplib_res ;
102
115
103
116
return 0 ;
@@ -136,7 +149,7 @@ static void bnxt_re_limit_pf_res(struct bnxt_re_dev *rdev)
136
149
ctx -> srqc_count = min_t (u32 , BNXT_RE_MAX_SRQC_COUNT ,
137
150
attr -> max_srq );
138
151
ctx -> cq_count = min_t (u32 , BNXT_RE_MAX_CQ_COUNT , attr -> max_cq );
139
- if (!bnxt_qplib_is_chip_gen_p5 (& rdev -> chip_ctx ))
152
+ if (!bnxt_qplib_is_chip_gen_p5 (rdev -> chip_ctx ))
140
153
for (i = 0 ; i < MAX_TQM_ALLOC_REQ ; i ++ )
141
154
rdev -> qplib_ctx .tqm_count [i ] =
142
155
rdev -> dev_attr .tqm_alloc_reqs [i ];
@@ -185,7 +198,7 @@ static void bnxt_re_set_resource_limits(struct bnxt_re_dev *rdev)
185
198
memset (& rdev -> qplib_ctx .vf_res , 0 , sizeof (struct bnxt_qplib_vf_res ));
186
199
bnxt_re_limit_pf_res (rdev );
187
200
188
- num_vfs = bnxt_qplib_is_chip_gen_p5 (& rdev -> chip_ctx ) ?
201
+ num_vfs = bnxt_qplib_is_chip_gen_p5 (rdev -> chip_ctx ) ?
189
202
BNXT_RE_GEN_P5_MAX_VF : rdev -> num_vfs ;
190
203
if (num_vfs )
191
204
bnxt_re_limit_vf_res (& rdev -> qplib_ctx , num_vfs );
@@ -208,7 +221,7 @@ static void bnxt_re_sriov_config(void *p, int num_vfs)
208
221
return ;
209
222
210
223
rdev -> num_vfs = num_vfs ;
211
- if (!bnxt_qplib_is_chip_gen_p5 (& rdev -> chip_ctx )) {
224
+ if (!bnxt_qplib_is_chip_gen_p5 (rdev -> chip_ctx )) {
212
225
bnxt_re_set_resource_limits (rdev );
213
226
bnxt_qplib_set_func_resources (& rdev -> qplib_res , & rdev -> rcfw ,
214
227
& rdev -> qplib_ctx );
@@ -916,7 +929,7 @@ static int bnxt_re_cqn_handler(struct bnxt_qplib_nq *nq,
916
929
#define BNXT_RE_GEN_P5_VF_NQ_DB 0x4000
917
930
static u32 bnxt_re_get_nqdb_offset (struct bnxt_re_dev * rdev , u16 indx )
918
931
{
919
- return bnxt_qplib_is_chip_gen_p5 (& rdev -> chip_ctx ) ?
932
+ return bnxt_qplib_is_chip_gen_p5 (rdev -> chip_ctx ) ?
920
933
(rdev -> is_virtfn ? BNXT_RE_GEN_P5_VF_NQ_DB :
921
934
BNXT_RE_GEN_P5_PF_NQ_DB ) :
922
935
rdev -> msix_entries [indx ].db_offset ;
@@ -967,7 +980,7 @@ static void bnxt_re_free_nq_res(struct bnxt_re_dev *rdev)
967
980
int i ;
968
981
969
982
for (i = 0 ; i < rdev -> num_msix - 1 ; i ++ ) {
970
- type = bnxt_qplib_get_ring_type (& rdev -> chip_ctx );
983
+ type = bnxt_qplib_get_ring_type (rdev -> chip_ctx );
971
984
bnxt_re_net_ring_free (rdev , rdev -> nq [i ].ring_id , type );
972
985
rdev -> nq [i ].res = NULL ;
973
986
bnxt_qplib_free_nq (& rdev -> nq [i ]);
@@ -1025,7 +1038,7 @@ static int bnxt_re_alloc_res(struct bnxt_re_dev *rdev)
1025
1038
i , rc );
1026
1039
goto free_nq ;
1027
1040
}
1028
- type = bnxt_qplib_get_ring_type (& rdev -> chip_ctx );
1041
+ type = bnxt_qplib_get_ring_type (rdev -> chip_ctx );
1029
1042
pg_map = rdev -> nq [i ].hwq .pbl [PBL_LVL_0 ].pg_map_arr ;
1030
1043
pages = rdev -> nq [i ].hwq .pbl [rdev -> nq [i ].hwq .level ].pg_count ;
1031
1044
rc = bnxt_re_net_ring_alloc (rdev , pg_map , pages , type ,
@@ -1044,7 +1057,7 @@ static int bnxt_re_alloc_res(struct bnxt_re_dev *rdev)
1044
1057
return 0 ;
1045
1058
free_nq :
1046
1059
for (i = num_vec_created ; i >= 0 ; i -- ) {
1047
- type = bnxt_qplib_get_ring_type (& rdev -> chip_ctx );
1060
+ type = bnxt_qplib_get_ring_type (rdev -> chip_ctx );
1048
1061
bnxt_re_net_ring_free (rdev , rdev -> nq [i ].ring_id , type );
1049
1062
bnxt_qplib_free_nq (& rdev -> nq [i ]);
1050
1063
}
@@ -1324,7 +1337,7 @@ static void bnxt_re_ib_unreg(struct bnxt_re_dev *rdev)
1324
1337
bnxt_re_net_stats_ctx_free (rdev , rdev -> qplib_ctx .stats .fw_id );
1325
1338
bnxt_qplib_free_ctx (rdev -> en_dev -> pdev , & rdev -> qplib_ctx );
1326
1339
bnxt_qplib_disable_rcfw_channel (& rdev -> rcfw );
1327
- type = bnxt_qplib_get_ring_type (& rdev -> chip_ctx );
1340
+ type = bnxt_qplib_get_ring_type (rdev -> chip_ctx );
1328
1341
bnxt_re_net_ring_free (rdev , rdev -> rcfw .creq_ring_id , type );
1329
1342
bnxt_qplib_free_rcfw_channel (& rdev -> rcfw );
1330
1343
}
@@ -1405,7 +1418,8 @@ static int bnxt_re_ib_reg(struct bnxt_re_dev *rdev)
1405
1418
pr_err ("Failed to allocate RCFW Channel: %#x\n" , rc );
1406
1419
goto fail ;
1407
1420
}
1408
- type = bnxt_qplib_get_ring_type (& rdev -> chip_ctx );
1421
+
1422
+ type = bnxt_qplib_get_ring_type (rdev -> chip_ctx );
1409
1423
pg_map = rdev -> rcfw .creq .pbl [PBL_LVL_0 ].pg_map_arr ;
1410
1424
pages = rdev -> rcfw .creq .pbl [rdev -> rcfw .creq .level ].pg_count ;
1411
1425
ridx = rdev -> msix_entries [BNXT_RE_AEQ_IDX ].ring_idx ;
@@ -1434,7 +1448,7 @@ static int bnxt_re_ib_reg(struct bnxt_re_dev *rdev)
1434
1448
bnxt_re_set_resource_limits (rdev );
1435
1449
1436
1450
rc = bnxt_qplib_alloc_ctx (rdev -> en_dev -> pdev , & rdev -> qplib_ctx , 0 ,
1437
- bnxt_qplib_is_chip_gen_p5 (& rdev -> chip_ctx ));
1451
+ bnxt_qplib_is_chip_gen_p5 (rdev -> chip_ctx ));
1438
1452
if (rc ) {
1439
1453
pr_err ("Failed to allocate QPLIB context: %#x\n" , rc );
1440
1454
goto disable_rcfw ;
@@ -1504,7 +1518,7 @@ static int bnxt_re_ib_reg(struct bnxt_re_dev *rdev)
1504
1518
disable_rcfw :
1505
1519
bnxt_qplib_disable_rcfw_channel (& rdev -> rcfw );
1506
1520
free_ring :
1507
- type = bnxt_qplib_get_ring_type (& rdev -> chip_ctx );
1521
+ type = bnxt_qplib_get_ring_type (rdev -> chip_ctx );
1508
1522
bnxt_re_net_ring_free (rdev , rdev -> rcfw .creq_ring_id , type );
1509
1523
free_rcfw :
1510
1524
bnxt_qplib_free_rcfw_channel (& rdev -> rcfw );
0 commit comments