Skip to content

Commit deea427

Browse files
halfboy93anguy11
authored andcommitted
ice: refactor struct ice_vsi_cfg_params to be inside of struct ice_vsi
Refactor struct ice_vsi_cfg_params to be embedded into struct ice_vsi. Prior to that the members of the struct were scattered around ice_vsi, and were copy-pasted for purposes of reinit. Now we have struct handy, and it is easier to have something sticky in the flags field. Suggested-by: Przemek Kitszel <przemyslaw.kitszel@intel.com> Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com> Reviewed-by: Vaishnavi Tipireddy <vaishnavi.tipireddy@intel.com> Signed-off-by: Mateusz Polchlopek <mateusz.polchlopek@intel.com> Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel) Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
1 parent c5e6bd9 commit deea427

File tree

7 files changed

+30
-80
lines changed

7 files changed

+30
-80
lines changed

drivers/net/ethernet/intel/ice/devlink/devlink.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,18 +1193,16 @@ static int ice_devlink_set_parent(struct devlink_rate *devlink_rate,
11931193
static int ice_devlink_reinit_up(struct ice_pf *pf)
11941194
{
11951195
struct ice_vsi *vsi = ice_get_main_vsi(pf);
1196-
struct ice_vsi_cfg_params params;
11971196
int err;
11981197

11991198
err = ice_init_dev(pf);
12001199
if (err)
12011200
return err;
12021201

1203-
params = ice_vsi_to_params(vsi);
1204-
params.flags = ICE_VSI_FLAG_INIT;
1202+
vsi->flags = ICE_VSI_FLAG_INIT;
12051203

12061204
rtnl_lock();
1207-
err = ice_vsi_cfg(vsi, &params);
1205+
err = ice_vsi_cfg(vsi);
12081206
rtnl_unlock();
12091207
if (err)
12101208
goto err_vsi_cfg;

drivers/net/ethernet/intel/ice/ice.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,6 @@ struct ice_vsi {
331331
struct net_device *netdev;
332332
struct ice_sw *vsw; /* switch this VSI is on */
333333
struct ice_pf *back; /* back pointer to PF */
334-
struct ice_port_info *port_info; /* back pointer to port_info */
335334
struct ice_rx_ring **rx_rings; /* Rx ring array */
336335
struct ice_tx_ring **tx_rings; /* Tx ring array */
337336
struct ice_q_vector **q_vectors; /* q_vector array */
@@ -349,12 +348,9 @@ struct ice_vsi {
349348
/* tell if only dynamic irq allocation is allowed */
350349
bool irq_dyn_alloc;
351350

352-
enum ice_vsi_type type;
353351
u16 vsi_num; /* HW (absolute) index of this VSI */
354352
u16 idx; /* software index in pf->vsi[] */
355353

356-
struct ice_vf *vf; /* VF associated with this VSI */
357-
358354
u16 num_gfltr;
359355
u16 num_bfltr;
360356

@@ -446,12 +442,18 @@ struct ice_vsi {
446442
u8 old_numtc;
447443
u16 old_ena_tc;
448444

449-
struct ice_channel *ch;
450-
451445
/* setup back reference, to which aggregator node this VSI
452446
* corresponds to
453447
*/
454448
struct ice_agg_node *agg_node;
449+
450+
struct_group_tagged(ice_vsi_cfg_params, params,
451+
struct ice_port_info *port_info; /* back pointer to port_info */
452+
struct ice_channel *ch; /* VSI's channel structure, may be NULL */
453+
struct ice_vf *vf; /* VF associated with this VSI, may be NULL */
454+
u32 flags; /* VSI flags used for rebuild and configuration */
455+
enum ice_vsi_type type; /* the type of the VSI */
456+
);
455457
} ____cacheline_internodealigned_in_smp;
456458

457459
/* struct that defines an interrupt vector */

drivers/net/ethernet/intel/ice/ice_lib.c

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2227,18 +2227,16 @@ static int ice_vsi_cfg_tc_lan(struct ice_pf *pf, struct ice_vsi *vsi)
22272227
/**
22282228
* ice_vsi_cfg_def - configure default VSI based on the type
22292229
* @vsi: pointer to VSI
2230-
* @params: the parameters to configure this VSI with
22312230
*/
2232-
static int
2233-
ice_vsi_cfg_def(struct ice_vsi *vsi, struct ice_vsi_cfg_params *params)
2231+
static int ice_vsi_cfg_def(struct ice_vsi *vsi)
22342232
{
22352233
struct device *dev = ice_pf_to_dev(vsi->back);
22362234
struct ice_pf *pf = vsi->back;
22372235
int ret;
22382236

22392237
vsi->vsw = pf->first_sw;
22402238

2241-
ret = ice_vsi_alloc_def(vsi, params->ch);
2239+
ret = ice_vsi_alloc_def(vsi, vsi->ch);
22422240
if (ret)
22432241
return ret;
22442242

@@ -2263,7 +2261,7 @@ ice_vsi_cfg_def(struct ice_vsi *vsi, struct ice_vsi_cfg_params *params)
22632261
ice_vsi_set_tc_cfg(vsi);
22642262

22652263
/* create the VSI */
2266-
ret = ice_vsi_init(vsi, params->flags);
2264+
ret = ice_vsi_init(vsi, vsi->flags);
22672265
if (ret)
22682266
goto unroll_get_qs;
22692267

@@ -2383,23 +2381,16 @@ ice_vsi_cfg_def(struct ice_vsi *vsi, struct ice_vsi_cfg_params *params)
23832381
/**
23842382
* ice_vsi_cfg - configure a previously allocated VSI
23852383
* @vsi: pointer to VSI
2386-
* @params: parameters used to configure this VSI
23872384
*/
2388-
int ice_vsi_cfg(struct ice_vsi *vsi, struct ice_vsi_cfg_params *params)
2385+
int ice_vsi_cfg(struct ice_vsi *vsi)
23892386
{
23902387
struct ice_pf *pf = vsi->back;
23912388
int ret;
23922389

2393-
if (WARN_ON(params->type == ICE_VSI_VF && !params->vf))
2390+
if (WARN_ON(vsi->type == ICE_VSI_VF && !vsi->vf))
23942391
return -EINVAL;
23952392

2396-
vsi->type = params->type;
2397-
vsi->port_info = params->pi;
2398-
2399-
/* For VSIs which don't have a connected VF, this will be NULL */
2400-
vsi->vf = params->vf;
2401-
2402-
ret = ice_vsi_cfg_def(vsi, params);
2393+
ret = ice_vsi_cfg_def(vsi);
24032394
if (ret)
24042395
return ret;
24052396

@@ -2485,7 +2476,7 @@ ice_vsi_setup(struct ice_pf *pf, struct ice_vsi_cfg_params *params)
24852476
* a port_info structure for it.
24862477
*/
24872478
if (WARN_ON(!(params->flags & ICE_VSI_FLAG_INIT)) ||
2488-
WARN_ON(!params->pi))
2479+
WARN_ON(!params->port_info))
24892480
return NULL;
24902481

24912482
vsi = ice_vsi_alloc(pf);
@@ -2494,7 +2485,8 @@ ice_vsi_setup(struct ice_pf *pf, struct ice_vsi_cfg_params *params)
24942485
return NULL;
24952486
}
24962487

2497-
ret = ice_vsi_cfg(vsi, params);
2488+
vsi->params = *params;
2489+
ret = ice_vsi_cfg(vsi);
24982490
if (ret)
24992491
goto err_vsi_cfg;
25002492

@@ -3041,7 +3033,6 @@ ice_vsi_realloc_stat_arrays(struct ice_vsi *vsi)
30413033
*/
30423034
int ice_vsi_rebuild(struct ice_vsi *vsi, u32 vsi_flags)
30433035
{
3044-
struct ice_vsi_cfg_params params = {};
30453036
struct ice_coalesce_stored *coalesce;
30463037
int prev_num_q_vectors;
30473038
struct ice_pf *pf;
@@ -3050,9 +3041,7 @@ int ice_vsi_rebuild(struct ice_vsi *vsi, u32 vsi_flags)
30503041
if (!vsi)
30513042
return -EINVAL;
30523043

3053-
params = ice_vsi_to_params(vsi);
3054-
params.flags = vsi_flags;
3055-
3044+
vsi->flags = vsi_flags;
30563045
pf = vsi->back;
30573046
if (WARN_ON(vsi->type == ICE_VSI_VF && !vsi->vf))
30583047
return -EINVAL;
@@ -3062,7 +3051,7 @@ int ice_vsi_rebuild(struct ice_vsi *vsi, u32 vsi_flags)
30623051
goto err_vsi_cfg;
30633052

30643053
ice_vsi_decfg(vsi);
3065-
ret = ice_vsi_cfg_def(vsi, &params);
3054+
ret = ice_vsi_cfg_def(vsi);
30663055
if (ret)
30673056
goto err_vsi_cfg;
30683057

drivers/net/ethernet/intel/ice/ice_lib.h

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -11,43 +11,6 @@
1111
#define ICE_VSI_FLAG_INIT BIT(0)
1212
#define ICE_VSI_FLAG_NO_INIT 0
1313

14-
/**
15-
* struct ice_vsi_cfg_params - VSI configuration parameters
16-
* @pi: pointer to the port_info instance for the VSI
17-
* @ch: pointer to the channel structure for the VSI, may be NULL
18-
* @vf: pointer to the VF associated with this VSI, may be NULL
19-
* @type: the type of VSI to configure
20-
* @flags: VSI flags used for rebuild and configuration
21-
*
22-
* Parameter structure used when configuring a new VSI.
23-
*/
24-
struct ice_vsi_cfg_params {
25-
struct ice_port_info *pi;
26-
struct ice_channel *ch;
27-
struct ice_vf *vf;
28-
enum ice_vsi_type type;
29-
u32 flags;
30-
};
31-
32-
/**
33-
* ice_vsi_to_params - Get parameters for an existing VSI
34-
* @vsi: the VSI to get parameters for
35-
*
36-
* Fill a parameter structure for reconfiguring a VSI with its current
37-
* parameters, such as during a rebuild operation.
38-
*/
39-
static inline struct ice_vsi_cfg_params ice_vsi_to_params(struct ice_vsi *vsi)
40-
{
41-
struct ice_vsi_cfg_params params = {};
42-
43-
params.pi = vsi->port_info;
44-
params.ch = vsi->ch;
45-
params.vf = vsi->vf;
46-
params.type = vsi->type;
47-
48-
return params;
49-
}
50-
5114
const char *ice_vsi_type_str(enum ice_vsi_type vsi_type);
5215

5316
bool ice_pf_state_is_nominal(struct ice_pf *pf);
@@ -101,7 +64,7 @@ void ice_vsi_decfg(struct ice_vsi *vsi);
10164
void ice_dis_vsi(struct ice_vsi *vsi, bool locked);
10265

10366
int ice_vsi_rebuild(struct ice_vsi *vsi, u32 vsi_flags);
104-
int ice_vsi_cfg(struct ice_vsi *vsi, struct ice_vsi_cfg_params *params);
67+
int ice_vsi_cfg(struct ice_vsi *vsi);
10568

10669
bool ice_is_reset_in_progress(unsigned long *state);
10770
int ice_wait_for_reset(struct ice_pf *pf, unsigned long timeout);

drivers/net/ethernet/intel/ice/ice_main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3685,7 +3685,7 @@ ice_pf_vsi_setup(struct ice_pf *pf, struct ice_port_info *pi)
36853685
struct ice_vsi_cfg_params params = {};
36863686

36873687
params.type = ICE_VSI_PF;
3688-
params.pi = pi;
3688+
params.port_info = pi;
36893689
params.flags = ICE_VSI_FLAG_INIT;
36903690

36913691
return ice_vsi_setup(pf, &params);
@@ -3698,7 +3698,7 @@ ice_chnl_vsi_setup(struct ice_pf *pf, struct ice_port_info *pi,
36983698
struct ice_vsi_cfg_params params = {};
36993699

37003700
params.type = ICE_VSI_CHNL;
3701-
params.pi = pi;
3701+
params.port_info = pi;
37023702
params.ch = ch;
37033703
params.flags = ICE_VSI_FLAG_INIT;
37043704

@@ -3719,7 +3719,7 @@ ice_ctrl_vsi_setup(struct ice_pf *pf, struct ice_port_info *pi)
37193719
struct ice_vsi_cfg_params params = {};
37203720

37213721
params.type = ICE_VSI_CTRL;
3722-
params.pi = pi;
3722+
params.port_info = pi;
37233723
params.flags = ICE_VSI_FLAG_INIT;
37243724

37253725
return ice_vsi_setup(pf, &params);
@@ -3739,7 +3739,7 @@ ice_lb_vsi_setup(struct ice_pf *pf, struct ice_port_info *pi)
37393739
struct ice_vsi_cfg_params params = {};
37403740

37413741
params.type = ICE_VSI_LB;
3742-
params.pi = pi;
3742+
params.port_info = pi;
37433743
params.flags = ICE_VSI_FLAG_INIT;
37443744

37453745
return ice_vsi_setup(pf, &params);

drivers/net/ethernet/intel/ice/ice_sriov.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ static struct ice_vsi *ice_vf_vsi_setup(struct ice_vf *vf)
225225
struct ice_vsi *vsi;
226226

227227
params.type = ICE_VSI_VF;
228-
params.pi = ice_vf_get_port_info(vf);
228+
params.port_info = ice_vf_get_port_info(vf);
229229
params.vf = vf;
230230
params.flags = ICE_VSI_FLAG_INIT;
231231

drivers/net/ethernet/intel/ice/ice_vf_lib.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,20 +259,18 @@ static void ice_vf_pre_vsi_rebuild(struct ice_vf *vf)
259259
int ice_vf_reconfig_vsi(struct ice_vf *vf)
260260
{
261261
struct ice_vsi *vsi = ice_get_vf_vsi(vf);
262-
struct ice_vsi_cfg_params params = {};
263262
struct ice_pf *pf = vf->pf;
264263
int err;
265264

266265
if (WARN_ON(!vsi))
267266
return -EINVAL;
268267

269-
params = ice_vsi_to_params(vsi);
270-
params.flags = ICE_VSI_FLAG_NO_INIT;
268+
vsi->flags = ICE_VSI_FLAG_NO_INIT;
271269

272270
ice_vsi_decfg(vsi);
273271
ice_fltr_remove_all(vsi);
274272

275-
err = ice_vsi_cfg(vsi, &params);
273+
err = ice_vsi_cfg(vsi);
276274
if (err) {
277275
dev_err(ice_pf_to_dev(pf),
278276
"Failed to reconfigure the VF%u's VSI, error %d\n",
@@ -1243,7 +1241,7 @@ struct ice_vsi *ice_vf_ctrl_vsi_setup(struct ice_vf *vf)
12431241
struct ice_vsi *vsi;
12441242

12451243
params.type = ICE_VSI_CTRL;
1246-
params.pi = ice_vf_get_port_info(vf);
1244+
params.port_info = ice_vf_get_port_info(vf);
12471245
params.vf = vf;
12481246
params.flags = ICE_VSI_FLAG_INIT;
12491247

0 commit comments

Comments
 (0)