Skip to content

Commit

Permalink
Merge branch 'net-mlx5-qos-refactor-esw-qos-to-support-new-features'
Browse files Browse the repository at this point in the history
Tariq Toukan says:

====================
net/mlx5: qos: Refactor esw qos to support new features

This patch series by Cosmin and Carolina prepares the mlx5 qos infra for
the upcoming feature of cross E-Switch scheduling.

Noop cleanups:
net/mlx5: qos: Flesh out element_attributes in mlx5_ifc.h
net/mlx5: qos: Rename vport 'tsar' into 'sched_elem'.
net/mlx5: qos: Consistently name vport vars as 'vport'
net/mlx5: qos: Refactor and document bw_share calculation
net/mlx5: qos: Rename rate group 'list' as 'parent_entry'

Refactor the code with the goal of moving groups out of E-Switches:
net/mlx5: qos: Maintain rate group vport members in a list
net/mlx5: qos: Always create group0
net/mlx5: qos: Drop 'esw' param from vport qos functions
net/mlx5: qos: Store the eswitch in a mlx5_esw_rate_group

Move groups from an E-Switch into an mlx5_qos_domain:
net/mlx5: qos: Store rate groups in a qos domain

Refactor locking to use a new mutex in the qos domain:
net/mlx5: qos: Refactor locking to a qos domain mutex

In follow-up patchsets, we'll allow qos domains to be shared
between E-Switches of the same NIC.

The two top patches are simple enhancements.
====================

Link: https://patch.msgid.link/20241008183222.137702-1-tariqt@nvidia.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
  • Loading branch information
Paolo Abeni committed Oct 10, 2024
2 parents d9d28b6 + e1013c7 commit 88dc9ae
Show file tree
Hide file tree
Showing 12 changed files with 547 additions and 376 deletions.
4 changes: 2 additions & 2 deletions drivers/net/ethernet/mellanox/mlx5/core/esw/devlink_port.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,15 @@ int mlx5_esw_offloads_devlink_port_register(struct mlx5_eswitch *esw, struct mlx
return err;
}

void mlx5_esw_offloads_devlink_port_unregister(struct mlx5_eswitch *esw, struct mlx5_vport *vport)
void mlx5_esw_offloads_devlink_port_unregister(struct mlx5_vport *vport)
{
struct mlx5_devlink_port *dl_port;

if (!vport->dl_port)
return;
dl_port = vport->dl_port;

mlx5_esw_qos_vport_update_group(esw, vport, NULL, NULL);
mlx5_esw_qos_vport_update_group(vport, NULL, NULL);
devl_rate_leaf_destroy(&dl_port->dl_port);

devl_port_unregister(&dl_port->dl_port);
Expand Down
39 changes: 21 additions & 18 deletions drivers/net/ethernet/mellanox/mlx5/core/esw/diag/qos_tracepoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,52 +11,55 @@
#include "eswitch.h"

TRACE_EVENT(mlx5_esw_vport_qos_destroy,
TP_PROTO(const struct mlx5_vport *vport),
TP_ARGS(vport),
TP_STRUCT__entry(__string(devname, dev_name(vport->dev->device))
TP_PROTO(const struct mlx5_core_dev *dev, const struct mlx5_vport *vport),
TP_ARGS(dev, vport),
TP_STRUCT__entry(__string(devname, dev_name(dev->device))
__field(unsigned short, vport_id)
__field(unsigned int, tsar_ix)
__field(unsigned int, sched_elem_ix)
),
TP_fast_assign(__assign_str(devname);
__entry->vport_id = vport->vport;
__entry->tsar_ix = vport->qos.esw_tsar_ix;
__entry->sched_elem_ix = vport->qos.esw_sched_elem_ix;
),
TP_printk("(%s) vport=%hu tsar_ix=%u\n",
__get_str(devname), __entry->vport_id, __entry->tsar_ix
TP_printk("(%s) vport=%hu sched_elem_ix=%u\n",
__get_str(devname), __entry->vport_id, __entry->sched_elem_ix
)
);

DECLARE_EVENT_CLASS(mlx5_esw_vport_qos_template,
TP_PROTO(const struct mlx5_vport *vport, u32 bw_share, u32 max_rate),
TP_ARGS(vport, bw_share, max_rate),
TP_STRUCT__entry(__string(devname, dev_name(vport->dev->device))
TP_PROTO(const struct mlx5_core_dev *dev, const struct mlx5_vport *vport,
u32 bw_share, u32 max_rate),
TP_ARGS(dev, vport, bw_share, max_rate),
TP_STRUCT__entry(__string(devname, dev_name(dev->device))
__field(unsigned short, vport_id)
__field(unsigned int, tsar_ix)
__field(unsigned int, sched_elem_ix)
__field(unsigned int, bw_share)
__field(unsigned int, max_rate)
__field(void *, group)
),
TP_fast_assign(__assign_str(devname);
__entry->vport_id = vport->vport;
__entry->tsar_ix = vport->qos.esw_tsar_ix;
__entry->sched_elem_ix = vport->qos.esw_sched_elem_ix;
__entry->bw_share = bw_share;
__entry->max_rate = max_rate;
__entry->group = vport->qos.group;
),
TP_printk("(%s) vport=%hu tsar_ix=%u bw_share=%u, max_rate=%u group=%p\n",
__get_str(devname), __entry->vport_id, __entry->tsar_ix,
TP_printk("(%s) vport=%hu sched_elem_ix=%u bw_share=%u, max_rate=%u group=%p\n",
__get_str(devname), __entry->vport_id, __entry->sched_elem_ix,
__entry->bw_share, __entry->max_rate, __entry->group
)
);

DEFINE_EVENT(mlx5_esw_vport_qos_template, mlx5_esw_vport_qos_create,
TP_PROTO(const struct mlx5_vport *vport, u32 bw_share, u32 max_rate),
TP_ARGS(vport, bw_share, max_rate)
TP_PROTO(const struct mlx5_core_dev *dev, const struct mlx5_vport *vport,
u32 bw_share, u32 max_rate),
TP_ARGS(dev, vport, bw_share, max_rate)
);

DEFINE_EVENT(mlx5_esw_vport_qos_template, mlx5_esw_vport_qos_config,
TP_PROTO(const struct mlx5_vport *vport, u32 bw_share, u32 max_rate),
TP_ARGS(vport, bw_share, max_rate)
TP_PROTO(const struct mlx5_core_dev *dev, const struct mlx5_vport *vport,
u32 bw_share, u32 max_rate),
TP_ARGS(dev, vport, bw_share, max_rate)
);

DECLARE_EVENT_CLASS(mlx5_esw_group_qos_template,
Expand Down
6 changes: 1 addition & 5 deletions drivers/net/ethernet/mellanox/mlx5/core/esw/legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,15 +513,11 @@ int mlx5_eswitch_set_vport_rate(struct mlx5_eswitch *esw, u16 vport,
u32 max_rate, u32 min_rate)
{
struct mlx5_vport *evport = mlx5_eswitch_get_vport(esw, vport);
int err;

if (!mlx5_esw_allowed(esw))
return -EPERM;
if (IS_ERR(evport))
return PTR_ERR(evport);

mutex_lock(&esw->state_lock);
err = mlx5_esw_qos_set_vport_rate(esw, evport, max_rate, min_rate);
mutex_unlock(&esw->state_lock);
return err;
return mlx5_esw_qos_set_vport_rate(evport, max_rate, min_rate);
}
Loading

0 comments on commit 88dc9ae

Please sign in to comment.