mirror of
https://github.com/torvalds/linux.git
synced 2026-08-01 20:22:08 +02:00
net/mlx5: Embed struct devlink_port into driver structure
Struct devlink_port is usually embedded in a driver-specific struct which allows to carry driver context to devlink port ops. Introduce a container struct to include devlink_port struct in preparation to also include driver context for devlink port ops. Signed-off-by: Jiri Pirko <jiri@nvidia.com> Reviewed-by: Shay Drory <shayd@nvidia.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
This commit is contained in:
parent
13f878a22c
commit
2c5f33f6b9
|
|
@ -56,7 +56,7 @@ static void mlx5_esw_offloads_pf_vf_devlink_port_attrs_set(struct mlx5_eswitch *
|
|||
|
||||
int mlx5_esw_offloads_pf_vf_devlink_port_init(struct mlx5_eswitch *esw, u16 vport_num)
|
||||
{
|
||||
struct devlink_port *dl_port;
|
||||
struct mlx5_devlink_port *dl_port;
|
||||
struct mlx5_vport *vport;
|
||||
|
||||
if (!mlx5_esw_devlink_port_supported(esw, vport_num))
|
||||
|
|
@ -70,7 +70,8 @@ int mlx5_esw_offloads_pf_vf_devlink_port_init(struct mlx5_eswitch *esw, u16 vpor
|
|||
if (!dl_port)
|
||||
return -ENOMEM;
|
||||
|
||||
mlx5_esw_offloads_pf_vf_devlink_port_attrs_set(esw, vport_num, dl_port);
|
||||
mlx5_esw_offloads_pf_vf_devlink_port_attrs_set(esw, vport_num,
|
||||
&dl_port->dl_port);
|
||||
|
||||
vport->dl_port = dl_port;
|
||||
return 0;
|
||||
|
|
@ -113,7 +114,7 @@ static void mlx5_esw_offloads_sf_devlink_port_attrs_set(struct mlx5_eswitch *esw
|
|||
}
|
||||
|
||||
int mlx5_esw_offloads_sf_devlink_port_init(struct mlx5_eswitch *esw, u16 vport_num,
|
||||
struct devlink_port *dl_port,
|
||||
struct mlx5_devlink_port *dl_port,
|
||||
u32 controller, u32 sfnum)
|
||||
{
|
||||
struct mlx5_vport *vport;
|
||||
|
|
@ -122,7 +123,7 @@ int mlx5_esw_offloads_sf_devlink_port_init(struct mlx5_eswitch *esw, u16 vport_n
|
|||
if (IS_ERR(vport))
|
||||
return PTR_ERR(vport);
|
||||
|
||||
mlx5_esw_offloads_sf_devlink_port_attrs_set(esw, dl_port, controller, sfnum);
|
||||
mlx5_esw_offloads_sf_devlink_port_attrs_set(esw, &dl_port->dl_port, controller, sfnum);
|
||||
|
||||
vport->dl_port = dl_port;
|
||||
return 0;
|
||||
|
|
@ -157,7 +158,7 @@ int mlx5_esw_offloads_devlink_port_register(struct mlx5_eswitch *esw, u16 vport_
|
|||
{
|
||||
struct mlx5_core_dev *dev = esw->dev;
|
||||
const struct devlink_port_ops *ops;
|
||||
struct devlink_port *dl_port;
|
||||
struct mlx5_devlink_port *dl_port;
|
||||
unsigned int dl_port_index;
|
||||
struct mlx5_vport *vport;
|
||||
struct devlink *devlink;
|
||||
|
|
@ -180,33 +181,35 @@ int mlx5_esw_offloads_devlink_port_register(struct mlx5_eswitch *esw, u16 vport_
|
|||
|
||||
devlink = priv_to_devlink(dev);
|
||||
dl_port_index = mlx5_esw_vport_to_devlink_port_index(dev, vport_num);
|
||||
err = devl_port_register_with_ops(devlink, dl_port, dl_port_index, ops);
|
||||
err = devl_port_register_with_ops(devlink, &dl_port->dl_port, dl_port_index, ops);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
err = devl_rate_leaf_create(dl_port, vport, NULL);
|
||||
err = devl_rate_leaf_create(&dl_port->dl_port, vport, NULL);
|
||||
if (err)
|
||||
goto rate_err;
|
||||
|
||||
return 0;
|
||||
|
||||
rate_err:
|
||||
devl_port_unregister(dl_port);
|
||||
devl_port_unregister(&dl_port->dl_port);
|
||||
return err;
|
||||
}
|
||||
|
||||
void mlx5_esw_offloads_devlink_port_unregister(struct mlx5_eswitch *esw, u16 vport_num)
|
||||
{
|
||||
struct mlx5_devlink_port *dl_port;
|
||||
struct mlx5_vport *vport;
|
||||
|
||||
vport = mlx5_eswitch_get_vport(esw, vport_num);
|
||||
if (IS_ERR(vport) || !vport->dl_port)
|
||||
return;
|
||||
dl_port = vport->dl_port;
|
||||
|
||||
mlx5_esw_qos_vport_update_group(esw, vport, NULL, NULL);
|
||||
devl_rate_leaf_destroy(vport->dl_port);
|
||||
devl_rate_leaf_destroy(&dl_port->dl_port);
|
||||
|
||||
devl_port_unregister(vport->dl_port);
|
||||
devl_port_unregister(&dl_port->dl_port);
|
||||
}
|
||||
|
||||
struct devlink_port *mlx5_esw_offloads_devlink_port(struct mlx5_eswitch *esw, u16 vport_num)
|
||||
|
|
@ -214,5 +217,5 @@ struct devlink_port *mlx5_esw_offloads_devlink_port(struct mlx5_eswitch *esw, u1
|
|||
struct mlx5_vport *vport;
|
||||
|
||||
vport = mlx5_eswitch_get_vport(esw, vport_num);
|
||||
return IS_ERR(vport) ? ERR_CAST(vport) : vport->dl_port;
|
||||
return IS_ERR(vport) ? ERR_CAST(vport) : &vport->dl_port->dl_port;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1121,7 +1121,7 @@ static void mlx5_eswitch_unload_pf_vf_vport(struct mlx5_eswitch *esw, u16 vport_
|
|||
|
||||
int mlx5_eswitch_load_sf_vport(struct mlx5_eswitch *esw, u16 vport_num,
|
||||
enum mlx5_eswitch_vport_event enabled_events,
|
||||
struct devlink_port *dl_port, u32 controller, u32 sfnum)
|
||||
struct mlx5_devlink_port *dl_port, u32 controller, u32 sfnum)
|
||||
{
|
||||
int err;
|
||||
|
||||
|
|
|
|||
|
|
@ -172,6 +172,10 @@ enum mlx5_eswitch_vport_event {
|
|||
MLX5_VPORT_PROMISC_CHANGE = BIT(3),
|
||||
};
|
||||
|
||||
struct mlx5_devlink_port {
|
||||
struct devlink_port dl_port;
|
||||
};
|
||||
|
||||
struct mlx5_vport {
|
||||
struct mlx5_core_dev *dev;
|
||||
struct hlist_head uc_list[MLX5_L2_ADDR_HASH_SIZE];
|
||||
|
|
@ -200,7 +204,7 @@ struct mlx5_vport {
|
|||
bool enabled;
|
||||
enum mlx5_eswitch_vport_event enabled_events;
|
||||
int index;
|
||||
struct devlink_port *dl_port;
|
||||
struct mlx5_devlink_port *dl_port;
|
||||
};
|
||||
|
||||
struct mlx5_esw_indir_table;
|
||||
|
|
@ -734,7 +738,7 @@ int mlx5_esw_offloads_init_pf_vf_rep(struct mlx5_eswitch *esw, u16 vport_num);
|
|||
void mlx5_esw_offloads_cleanup_pf_vf_rep(struct mlx5_eswitch *esw, u16 vport_num);
|
||||
|
||||
int mlx5_esw_offloads_init_sf_rep(struct mlx5_eswitch *esw, u16 vport_num,
|
||||
struct devlink_port *dl_port,
|
||||
struct mlx5_devlink_port *dl_port,
|
||||
u32 controller, u32 sfnum);
|
||||
void mlx5_esw_offloads_cleanup_sf_rep(struct mlx5_eswitch *esw, u16 vport_num);
|
||||
|
||||
|
|
@ -743,7 +747,7 @@ void mlx5_esw_offloads_unload_rep(struct mlx5_eswitch *esw, u16 vport_num);
|
|||
|
||||
int mlx5_eswitch_load_sf_vport(struct mlx5_eswitch *esw, u16 vport_num,
|
||||
enum mlx5_eswitch_vport_event enabled_events,
|
||||
struct devlink_port *dl_port, u32 controller, u32 sfnum);
|
||||
struct mlx5_devlink_port *dl_port, u32 controller, u32 sfnum);
|
||||
void mlx5_eswitch_unload_sf_vport(struct mlx5_eswitch *esw, u16 vport_num);
|
||||
|
||||
int mlx5_eswitch_load_vf_vports(struct mlx5_eswitch *esw, u16 num_vfs,
|
||||
|
|
@ -754,7 +758,7 @@ int mlx5_esw_offloads_pf_vf_devlink_port_init(struct mlx5_eswitch *esw, u16 vpor
|
|||
void mlx5_esw_offloads_pf_vf_devlink_port_cleanup(struct mlx5_eswitch *esw, u16 vport_num);
|
||||
|
||||
int mlx5_esw_offloads_sf_devlink_port_init(struct mlx5_eswitch *esw, u16 vport_num,
|
||||
struct devlink_port *dl_port,
|
||||
struct mlx5_devlink_port *dl_port,
|
||||
u32 controller, u32 sfnum);
|
||||
void mlx5_esw_offloads_sf_devlink_port_cleanup(struct mlx5_eswitch *esw, u16 vport_num);
|
||||
|
||||
|
|
|
|||
|
|
@ -2552,7 +2552,7 @@ void mlx5_esw_offloads_cleanup_pf_vf_rep(struct mlx5_eswitch *esw, u16 vport_num
|
|||
}
|
||||
|
||||
int mlx5_esw_offloads_init_sf_rep(struct mlx5_eswitch *esw, u16 vport_num,
|
||||
struct devlink_port *dl_port,
|
||||
struct mlx5_devlink_port *dl_port,
|
||||
u32 controller, u32 sfnum)
|
||||
{
|
||||
return mlx5_esw_offloads_sf_devlink_port_init(esw, vport_num, dl_port, controller, sfnum);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
#include "diag/sf_tracepoint.h"
|
||||
|
||||
struct mlx5_sf {
|
||||
struct devlink_port dl_port;
|
||||
struct mlx5_devlink_port dl_port;
|
||||
unsigned int port_index;
|
||||
u32 controller;
|
||||
u16 id;
|
||||
|
|
@ -296,7 +296,7 @@ static int mlx5_sf_add(struct mlx5_core_dev *dev, struct mlx5_sf_table *table,
|
|||
&sf->dl_port, new_attr->controller, new_attr->sfnum);
|
||||
if (err)
|
||||
goto esw_err;
|
||||
*dl_port = &sf->dl_port;
|
||||
*dl_port = &sf->dl_port.dl_port;
|
||||
trace_mlx5_sf_add(dev, sf->port_index, sf->controller, sf->hw_fn_id, new_attr->sfnum);
|
||||
return 0;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user