@@ -3634,7 +3634,7 @@ static bool esw_offloads_devlink_ns_eq_netdev_ns(struct devlink *devlink)
36343634 struct net * devl_net , * netdev_net ;
36353635 struct mlx5_eswitch * esw ;
36363636
3637- esw = mlx5_devlink_eswitch_get (devlink );
3637+ esw = mlx5_devlink_eswitch_nocheck_get (devlink );
36383638 netdev_net = dev_net (esw -> dev -> mlx5e_res .uplink_netdev );
36393639 devl_net = devlink_net (devlink );
36403640
@@ -4222,13 +4222,10 @@ int mlx5_devlink_port_fn_hw_addr_get(struct devlink_port *port,
42224222 u8 * hw_addr , int * hw_addr_len ,
42234223 struct netlink_ext_ack * extack )
42244224{
4225- struct mlx5_eswitch * esw ;
4225+ struct mlx5_eswitch * esw = mlx5_devlink_eswitch_nocheck_get ( port -> devlink ) ;
42264226 struct mlx5_vport * vport ;
42274227 u16 vport_num ;
42284228
4229- esw = mlx5_devlink_eswitch_get (port -> devlink );
4230- if (IS_ERR (esw ))
4231- return PTR_ERR (esw );
42324229
42334230 vport_num = mlx5_esw_devlink_port_index_to_vport_num (port -> index );
42344231
@@ -4249,15 +4246,9 @@ int mlx5_devlink_port_fn_hw_addr_set(struct devlink_port *port,
42494246 const u8 * hw_addr , int hw_addr_len ,
42504247 struct netlink_ext_ack * extack )
42514248{
4252- struct mlx5_eswitch * esw ;
4249+ struct mlx5_eswitch * esw = mlx5_devlink_eswitch_nocheck_get ( port -> devlink ) ;
42534250 u16 vport_num ;
42544251
4255- esw = mlx5_devlink_eswitch_get (port -> devlink );
4256- if (IS_ERR (esw )) {
4257- NL_SET_ERR_MSG_MOD (extack , "Eswitch doesn't support set hw_addr" );
4258- return PTR_ERR (esw );
4259- }
4260-
42614252 vport_num = mlx5_esw_devlink_port_index_to_vport_num (port -> index );
42624253 return mlx5_eswitch_set_vport_mac (esw , vport_num , hw_addr );
42634254}
@@ -4277,13 +4268,9 @@ mlx5_devlink_port_fn_get_vport(struct devlink_port *port, struct mlx5_eswitch *e
42774268int mlx5_devlink_port_fn_migratable_get (struct devlink_port * port , bool * is_enabled ,
42784269 struct netlink_ext_ack * extack )
42794270{
4280- struct mlx5_eswitch * esw ;
4271+ struct mlx5_eswitch * esw = mlx5_devlink_eswitch_nocheck_get ( port -> devlink ) ;
42814272 struct mlx5_vport * vport ;
42824273
4283- esw = mlx5_devlink_eswitch_get (port -> devlink );
4284- if (IS_ERR (esw ))
4285- return PTR_ERR (esw );
4286-
42874274 if (!MLX5_CAP_GEN (esw -> dev , migration )) {
42884275 NL_SET_ERR_MSG_MOD (extack , "Device doesn't support migration" );
42894276 return - EOPNOTSUPP ;
@@ -4304,17 +4291,13 @@ int mlx5_devlink_port_fn_migratable_get(struct devlink_port *port, bool *is_enab
43044291int mlx5_devlink_port_fn_migratable_set (struct devlink_port * port , bool enable ,
43054292 struct netlink_ext_ack * extack )
43064293{
4294+ struct mlx5_eswitch * esw = mlx5_devlink_eswitch_nocheck_get (port -> devlink );
43074295 int query_out_sz = MLX5_ST_SZ_BYTES (query_hca_cap_out );
4308- struct mlx5_eswitch * esw ;
43094296 struct mlx5_vport * vport ;
43104297 void * query_ctx ;
43114298 void * hca_caps ;
43124299 int err ;
43134300
4314- esw = mlx5_devlink_eswitch_get (port -> devlink );
4315- if (IS_ERR (esw ))
4316- return PTR_ERR (esw );
4317-
43184301 if (!MLX5_CAP_GEN (esw -> dev , migration )) {
43194302 NL_SET_ERR_MSG_MOD (extack , "Device doesn't support migration" );
43204303 return - EOPNOTSUPP ;
@@ -4368,13 +4351,9 @@ int mlx5_devlink_port_fn_migratable_set(struct devlink_port *port, bool enable,
43684351int mlx5_devlink_port_fn_roce_get (struct devlink_port * port , bool * is_enabled ,
43694352 struct netlink_ext_ack * extack )
43704353{
4371- struct mlx5_eswitch * esw ;
4354+ struct mlx5_eswitch * esw = mlx5_devlink_eswitch_nocheck_get ( port -> devlink ) ;
43724355 struct mlx5_vport * vport ;
43734356
4374- esw = mlx5_devlink_eswitch_get (port -> devlink );
4375- if (IS_ERR (esw ))
4376- return PTR_ERR (esw );
4377-
43784357 vport = mlx5_devlink_port_fn_get_vport (port , esw );
43794358 if (IS_ERR (vport )) {
43804359 NL_SET_ERR_MSG_MOD (extack , "Invalid port" );
@@ -4390,18 +4369,14 @@ int mlx5_devlink_port_fn_roce_get(struct devlink_port *port, bool *is_enabled,
43904369int mlx5_devlink_port_fn_roce_set (struct devlink_port * port , bool enable ,
43914370 struct netlink_ext_ack * extack )
43924371{
4372+ struct mlx5_eswitch * esw = mlx5_devlink_eswitch_nocheck_get (port -> devlink );
43934373 int query_out_sz = MLX5_ST_SZ_BYTES (query_hca_cap_out );
4394- struct mlx5_eswitch * esw ;
43954374 struct mlx5_vport * vport ;
43964375 void * query_ctx ;
43974376 void * hca_caps ;
43984377 u16 vport_num ;
43994378 int err ;
44004379
4401- esw = mlx5_devlink_eswitch_get (port -> devlink );
4402- if (IS_ERR (esw ))
4403- return PTR_ERR (esw );
4404-
44054380 vport = mlx5_devlink_port_fn_get_vport (port , esw );
44064381 if (IS_ERR (vport )) {
44074382 NL_SET_ERR_MSG_MOD (extack , "Invalid port" );
0 commit comments