Commit 88dc9aeb authored by Paolo Abeni's avatar Paolo Abeni
Browse files

Merge branch 'net-mlx5-qos-refactor-esw-qos-to-support-new-features'

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: default avatarPaolo Abeni <pabeni@redhat.com>
parents d9d28b6f e1013c79
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -187,7 +187,7 @@ 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;

@@ -195,7 +195,7 @@ void mlx5_esw_offloads_devlink_port_unregister(struct mlx5_eswitch *esw, struct
		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);
+21 −18
Original line number Diff line number Diff line
@@ -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,
+1 −5
Original line number Diff line number Diff line
@@ -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);
}
+374 −294

File changed.

Preview size limit exceeded, changes collapsed.

+6 −3
Original line number Diff line number Diff line
@@ -6,9 +6,12 @@

#ifdef CONFIG_MLX5_ESWITCH

int mlx5_esw_qos_set_vport_rate(struct mlx5_eswitch *esw, struct mlx5_vport *evport,
				u32 max_rate, u32 min_rate);
void mlx5_esw_qos_vport_disable(struct mlx5_eswitch *esw, struct mlx5_vport *vport);
int mlx5_esw_qos_init(struct mlx5_eswitch *esw);
void mlx5_esw_qos_cleanup(struct mlx5_eswitch *esw);

int mlx5_esw_qos_set_vport_rate(struct mlx5_vport *evport, u32 max_rate, u32 min_rate);
bool mlx5_esw_qos_get_vport_rate(struct mlx5_vport *vport, u32 *max_rate, u32 *min_rate);
void mlx5_esw_qos_vport_disable(struct mlx5_vport *vport);

int mlx5_esw_devlink_rate_leaf_tx_share_set(struct devlink_rate *rate_leaf, void *priv,
					    u64 tx_share, struct netlink_ext_ack *extack);
Loading