@@ -4223,17 +4223,7 @@ int mlx5_devlink_port_fn_hw_addr_get(struct devlink_port *port,
42234223 struct netlink_ext_ack * extack )
42244224{
42254225 struct mlx5_eswitch * esw = mlx5_devlink_eswitch_nocheck_get (port -> devlink );
4226- struct mlx5_vport * vport ;
4227- u16 vport_num ;
4228-
4229-
4230- vport_num = mlx5_esw_devlink_port_index_to_vport_num (port -> index );
4231-
4232- vport = mlx5_eswitch_get_vport (esw , vport_num );
4233- if (IS_ERR (vport )) {
4234- NL_SET_ERR_MSG_MOD (extack , "Invalid port" );
4235- return PTR_ERR (vport );
4236- }
4226+ struct mlx5_vport * vport = mlx5_devlink_port_vport_get (port );
42374227
42384228 mutex_lock (& esw -> state_lock );
42394229 ether_addr_copy (hw_addr , vport -> info .mac );
@@ -4247,26 +4237,16 @@ int mlx5_devlink_port_fn_hw_addr_set(struct devlink_port *port,
42474237 struct netlink_ext_ack * extack )
42484238{
42494239 struct mlx5_eswitch * esw = mlx5_devlink_eswitch_nocheck_get (port -> devlink );
4250- u16 vport_num ;
4240+ struct mlx5_vport * vport = mlx5_devlink_port_vport_get ( port ) ;
42514241
4252- vport_num = mlx5_esw_devlink_port_index_to_vport_num (port -> index );
4253- return mlx5_eswitch_set_vport_mac (esw , vport_num , hw_addr );
4254- }
4255-
4256- static struct mlx5_vport *
4257- mlx5_devlink_port_fn_get_vport (struct devlink_port * port , struct mlx5_eswitch * esw )
4258- {
4259- u16 vport_num ;
4260-
4261- vport_num = mlx5_esw_devlink_port_index_to_vport_num (port -> index );
4262- return mlx5_eswitch_get_vport (esw , vport_num );
4242+ return mlx5_eswitch_set_vport_mac (esw , vport -> vport , hw_addr );
42634243}
42644244
42654245int mlx5_devlink_port_fn_migratable_get (struct devlink_port * port , bool * is_enabled ,
42664246 struct netlink_ext_ack * extack )
42674247{
42684248 struct mlx5_eswitch * esw = mlx5_devlink_eswitch_nocheck_get (port -> devlink );
4269- struct mlx5_vport * vport ;
4249+ struct mlx5_vport * vport = mlx5_devlink_port_vport_get ( port ) ;
42704250
42714251 if (!MLX5_CAP_GEN (esw -> dev , migration )) {
42724252 NL_SET_ERR_MSG_MOD (extack , "Device doesn't support migration" );
@@ -4278,12 +4258,6 @@ int mlx5_devlink_port_fn_migratable_get(struct devlink_port *port, bool *is_enab
42784258 return - EOPNOTSUPP ;
42794259 }
42804260
4281- vport = mlx5_devlink_port_fn_get_vport (port , esw );
4282- if (IS_ERR (vport )) {
4283- NL_SET_ERR_MSG_MOD (extack , "Invalid port" );
4284- return PTR_ERR (vport );
4285- }
4286-
42874261 mutex_lock (& esw -> state_lock );
42884262 * is_enabled = vport -> info .mig_enabled ;
42894263 mutex_unlock (& esw -> state_lock );
@@ -4294,8 +4268,8 @@ int mlx5_devlink_port_fn_migratable_set(struct devlink_port *port, bool enable,
42944268 struct netlink_ext_ack * extack )
42954269{
42964270 struct mlx5_eswitch * esw = mlx5_devlink_eswitch_nocheck_get (port -> devlink );
4271+ struct mlx5_vport * vport = mlx5_devlink_port_vport_get (port );
42974272 int query_out_sz = MLX5_ST_SZ_BYTES (query_hca_cap_out );
4298- struct mlx5_vport * vport ;
42994273 void * query_ctx ;
43004274 void * hca_caps ;
43014275 int err ;
@@ -4310,12 +4284,6 @@ int mlx5_devlink_port_fn_migratable_set(struct devlink_port *port, bool enable,
43104284 return - EOPNOTSUPP ;
43114285 }
43124286
4313- vport = mlx5_devlink_port_fn_get_vport (port , esw );
4314- if (IS_ERR (vport )) {
4315- NL_SET_ERR_MSG_MOD (extack , "Invalid port" );
4316- return PTR_ERR (vport );
4317- }
4318-
43194287 mutex_lock (& esw -> state_lock );
43204288
43214289 if (vport -> info .mig_enabled == enable ) {
@@ -4359,19 +4327,13 @@ int mlx5_devlink_port_fn_roce_get(struct devlink_port *port, bool *is_enabled,
43594327 struct netlink_ext_ack * extack )
43604328{
43614329 struct mlx5_eswitch * esw = mlx5_devlink_eswitch_nocheck_get (port -> devlink );
4362- struct mlx5_vport * vport ;
4330+ struct mlx5_vport * vport = mlx5_devlink_port_vport_get ( port ) ;
43634331
43644332 if (!MLX5_CAP_GEN (esw -> dev , vhca_resource_manager )) {
43654333 NL_SET_ERR_MSG_MOD (extack , "Device doesn't support VHCA management" );
43664334 return - EOPNOTSUPP ;
43674335 }
43684336
4369- vport = mlx5_devlink_port_fn_get_vport (port , esw );
4370- if (IS_ERR (vport )) {
4371- NL_SET_ERR_MSG_MOD (extack , "Invalid port" );
4372- return PTR_ERR (vport );
4373- }
4374-
43754337 mutex_lock (& esw -> state_lock );
43764338 * is_enabled = vport -> info .roce_enabled ;
43774339 mutex_unlock (& esw -> state_lock );
@@ -4382,25 +4344,18 @@ int mlx5_devlink_port_fn_roce_set(struct devlink_port *port, bool enable,
43824344 struct netlink_ext_ack * extack )
43834345{
43844346 struct mlx5_eswitch * esw = mlx5_devlink_eswitch_nocheck_get (port -> devlink );
4347+ struct mlx5_vport * vport = mlx5_devlink_port_vport_get (port );
43854348 int query_out_sz = MLX5_ST_SZ_BYTES (query_hca_cap_out );
4386- struct mlx5_vport * vport ;
4349+ u16 vport_num = vport -> vport ;
43874350 void * query_ctx ;
43884351 void * hca_caps ;
4389- u16 vport_num ;
43904352 int err ;
43914353
43924354 if (!MLX5_CAP_GEN (esw -> dev , vhca_resource_manager )) {
43934355 NL_SET_ERR_MSG_MOD (extack , "Device doesn't support VHCA management" );
43944356 return - EOPNOTSUPP ;
43954357 }
43964358
4397- vport = mlx5_devlink_port_fn_get_vport (port , esw );
4398- if (IS_ERR (vport )) {
4399- NL_SET_ERR_MSG_MOD (extack , "Invalid port" );
4400- return PTR_ERR (vport );
4401- }
4402- vport_num = vport -> vport ;
4403-
44044359 mutex_lock (& esw -> state_lock );
44054360
44064361 if (vport -> info .roce_enabled == enable ) {
0 commit comments