Skip to content

Commit

Permalink
Merge branch 'mlx5-misc-patches-2024-10-31'
Browse files Browse the repository at this point in the history
Tariq Toukan says:

====================
mlx5 misc patches 2024-10-31

First patch by Cosmin fixes an issue in a recent commit.

Followed by 2 patches by Yevgeny that organize and rename the files
under the steering directory.

Finally, 2 patches by William that save the creation of the unused
egress-XDP_REDIRECT send queue on non-uplink representor.
====================

Link: https://patch.msgid.link/20241031125856.530927-1-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
kuba-moo committed Nov 3, 2024
2 parents 9ff75a2 + 355cf27 commit 8d1807a
Show file tree
Hide file tree
Showing 69 changed files with 177 additions and 121 deletions.
63 changes: 38 additions & 25 deletions drivers/net/ethernet/mellanox/mlx5/core/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -109,35 +109,48 @@ mlx5_core-$(CONFIG_MLX5_EN_TLS) += en_accel/ktls_stats.o \
en_accel/fs_tcp.o en_accel/ktls.o en_accel/ktls_txrx.o \
en_accel/ktls_tx.o en_accel/ktls_rx.o

mlx5_core-$(CONFIG_MLX5_SW_STEERING) += steering/dr_domain.o steering/dr_table.o \
steering/dr_matcher.o steering/dr_rule.o \
steering/dr_icm_pool.o steering/dr_buddy.o \
steering/dr_ste.o steering/dr_send.o \
steering/dr_ste_v0.o steering/dr_ste_v1.o \
steering/dr_ste_v2.o \
steering/dr_cmd.o steering/dr_fw.o \
steering/dr_action.o steering/fs_dr.o \
steering/dr_definer.o steering/dr_ptrn.o \
steering/dr_arg.o steering/dr_dbg.o lib/smfs.o
#
# SW Steering
#
mlx5_core-$(CONFIG_MLX5_SW_STEERING) += steering/sws/dr_domain.o \
steering/sws/dr_table.o \
steering/sws/dr_matcher.o \
steering/sws/dr_rule.o \
steering/sws/dr_icm_pool.o \
steering/sws/dr_buddy.o \
steering/sws/dr_ste.o \
steering/sws/dr_send.o \
steering/sws/dr_ste_v0.o \
steering/sws/dr_ste_v1.o \
steering/sws/dr_ste_v2.o \
steering/sws/dr_cmd.o \
steering/sws/dr_fw.o \
steering/sws/dr_action.o \
steering/sws/dr_definer.o \
steering/sws/dr_ptrn.o \
steering/sws/dr_arg.o \
steering/sws/dr_dbg.o \
steering/sws/fs_dr.o \
lib/smfs.o

#
# HW Steering
#
mlx5_core-$(CONFIG_MLX5_HW_STEERING) += steering/hws/mlx5hws_cmd.o \
steering/hws/mlx5hws_context.o \
steering/hws/mlx5hws_pat_arg.o \
steering/hws/mlx5hws_buddy.o \
steering/hws/mlx5hws_pool.o \
steering/hws/mlx5hws_table.o \
steering/hws/mlx5hws_action.o \
steering/hws/mlx5hws_rule.o \
steering/hws/mlx5hws_matcher.o \
steering/hws/mlx5hws_send.o \
steering/hws/mlx5hws_definer.o \
steering/hws/mlx5hws_bwc.o \
steering/hws/mlx5hws_debug.o \
steering/hws/mlx5hws_vport.o \
steering/hws/mlx5hws_bwc_complex.o
mlx5_core-$(CONFIG_MLX5_HW_STEERING) += steering/hws/cmd.o \
steering/hws/context.o \
steering/hws/pat_arg.o \
steering/hws/buddy.o \
steering/hws/pool.o \
steering/hws/table.o \
steering/hws/action.o \
steering/hws/rule.o \
steering/hws/matcher.o \
steering/hws/send.o \
steering/hws/definer.o \
steering/hws/bwc.o \
steering/hws/debug.o \
steering/hws/vport.o \
steering/hws/bwc_complex.o


#
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/mellanox/mlx5/core/en.h
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ struct mlx5e_channel {
u8 lag_port;

/* XDP_REDIRECT */
struct mlx5e_xdpsq xdpsq;
struct mlx5e_xdpsq *xdpsq;

/* AF_XDP zero-copy */
struct mlx5e_rq xskrq;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ int mlx5e_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **frames,
if (unlikely(sq_num >= priv->channels.num))
return -ENXIO;

sq = &priv->channels.c[sq_num]->xdpsq;
sq = priv->channels.c[sq_num]->xdpsq;

for (i = 0; i < n; i++) {
struct mlx5e_xmit_data_frags xdptxdf = {};
Expand Down
73 changes: 54 additions & 19 deletions drivers/net/ethernet/mellanox/mlx5/core/en_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2086,6 +2086,44 @@ void mlx5e_close_xdpsq(struct mlx5e_xdpsq *sq)
mlx5e_free_xdpsq(sq);
}

static struct mlx5e_xdpsq *mlx5e_open_xdpredirect_sq(struct mlx5e_channel *c,
struct mlx5e_params *params,
struct mlx5e_channel_param *cparam,
struct mlx5e_create_cq_param *ccp)
{
struct mlx5e_xdpsq *xdpsq;
int err;

xdpsq = kvzalloc_node(sizeof(*xdpsq), GFP_KERNEL, c->cpu);
if (!xdpsq)
return ERR_PTR(-ENOMEM);

err = mlx5e_open_cq(c->mdev, params->tx_cq_moderation,
&cparam->xdp_sq.cqp, ccp, &xdpsq->cq);
if (err)
goto err_free_xdpsq;

err = mlx5e_open_xdpsq(c, params, &cparam->xdp_sq, NULL, xdpsq, true);
if (err)
goto err_close_xdpsq_cq;

return xdpsq;

err_close_xdpsq_cq:
mlx5e_close_cq(&xdpsq->cq);
err_free_xdpsq:
kvfree(xdpsq);

return ERR_PTR(err);
}

static void mlx5e_close_xdpredirect_sq(struct mlx5e_xdpsq *xdpsq)
{
mlx5e_close_xdpsq(xdpsq);
mlx5e_close_cq(&xdpsq->cq);
kvfree(xdpsq);
}

static int mlx5e_alloc_cq_common(struct mlx5_core_dev *mdev,
struct net_device *netdev,
struct workqueue_struct *workqueue,
Expand Down Expand Up @@ -2476,6 +2514,7 @@ static int mlx5e_open_queues(struct mlx5e_channel *c,
struct mlx5e_params *params,
struct mlx5e_channel_param *cparam)
{
const struct net_device_ops *netdev_ops = c->netdev->netdev_ops;
struct dim_cq_moder icocq_moder = {0, 0};
struct mlx5e_create_cq_param ccp;
int err;
Expand All @@ -2496,15 +2535,18 @@ static int mlx5e_open_queues(struct mlx5e_channel *c,
if (err)
goto err_close_icosq_cq;

err = mlx5e_open_cq(c->mdev, params->tx_cq_moderation, &cparam->xdp_sq.cqp, &ccp,
&c->xdpsq.cq);
if (err)
goto err_close_tx_cqs;
if (netdev_ops->ndo_xdp_xmit) {
c->xdpsq = mlx5e_open_xdpredirect_sq(c, params, cparam, &ccp);
if (IS_ERR(c->xdpsq)) {
err = PTR_ERR(c->xdpsq);
goto err_close_tx_cqs;
}
}

err = mlx5e_open_cq(c->mdev, params->rx_cq_moderation, &cparam->rq.cqp, &ccp,
&c->rq.cq);
if (err)
goto err_close_xdp_tx_cqs;
goto err_close_xdpredirect_sq;

err = c->xdp ? mlx5e_open_cq(c->mdev, params->tx_cq_moderation, &cparam->xdp_sq.cqp,
&ccp, &c->rq_xdpsq.cq) : 0;
Expand All @@ -2516,7 +2558,7 @@ static int mlx5e_open_queues(struct mlx5e_channel *c,
err = mlx5e_open_icosq(c, params, &cparam->async_icosq, &c->async_icosq,
mlx5e_async_icosq_err_cqe_work);
if (err)
goto err_close_xdpsq_cq;
goto err_close_rq_xdpsq_cq;

mutex_init(&c->icosq_recovery_lock);

Expand All @@ -2540,16 +2582,8 @@ static int mlx5e_open_queues(struct mlx5e_channel *c,
goto err_close_rq;
}

err = mlx5e_open_xdpsq(c, params, &cparam->xdp_sq, NULL, &c->xdpsq, true);
if (err)
goto err_close_xdp_sq;

return 0;

err_close_xdp_sq:
if (c->xdp)
mlx5e_close_xdpsq(&c->rq_xdpsq);

err_close_rq:
mlx5e_close_rq(&c->rq);

Expand All @@ -2562,15 +2596,16 @@ static int mlx5e_open_queues(struct mlx5e_channel *c,
err_close_async_icosq:
mlx5e_close_icosq(&c->async_icosq);

err_close_xdpsq_cq:
err_close_rq_xdpsq_cq:
if (c->xdp)
mlx5e_close_cq(&c->rq_xdpsq.cq);

err_close_rx_cq:
mlx5e_close_cq(&c->rq.cq);

err_close_xdp_tx_cqs:
mlx5e_close_cq(&c->xdpsq.cq);
err_close_xdpredirect_sq:
if (c->xdpsq)
mlx5e_close_xdpredirect_sq(c->xdpsq);

err_close_tx_cqs:
mlx5e_close_tx_cqs(c);
Expand All @@ -2586,7 +2621,6 @@ static int mlx5e_open_queues(struct mlx5e_channel *c,

static void mlx5e_close_queues(struct mlx5e_channel *c)
{
mlx5e_close_xdpsq(&c->xdpsq);
if (c->xdp)
mlx5e_close_xdpsq(&c->rq_xdpsq);
/* The same ICOSQ is used for UMRs for both RQ and XSKRQ. */
Expand All @@ -2599,7 +2633,8 @@ static void mlx5e_close_queues(struct mlx5e_channel *c)
if (c->xdp)
mlx5e_close_cq(&c->rq_xdpsq.cq);
mlx5e_close_cq(&c->rq.cq);
mlx5e_close_cq(&c->xdpsq.cq);
if (c->xdpsq)
mlx5e_close_xdpredirect_sq(c->xdpsq);
mlx5e_close_tx_cqs(c);
mlx5e_close_cq(&c->icosq.cq);
mlx5e_close_cq(&c->async_icosq.cq);
Expand Down
3 changes: 2 additions & 1 deletion drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,8 @@ mlx5e_add_sqs_fwd_rules(struct mlx5e_priv *priv)
if (c->xdp)
sqs[num_sqs++] = c->rq_xdpsq.sqn;

sqs[num_sqs++] = c->xdpsq.sqn;
if (c->xdpsq)
sqs[num_sqs++] = c->xdpsq->sqn;
}
}
if (ptp_sq) {
Expand Down
6 changes: 4 additions & 2 deletions drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget)
if (unlikely(!budget))
goto out;

busy |= mlx5e_poll_xdpsq_cq(&c->xdpsq.cq);
if (c->xdpsq)
busy |= mlx5e_poll_xdpsq_cq(&c->xdpsq->cq);

if (c->xdp)
busy |= mlx5e_poll_xdpsq_cq(&c->rq_xdpsq.cq);
Expand Down Expand Up @@ -236,7 +237,8 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget)
mlx5e_cq_arm(&rq->cq);
mlx5e_cq_arm(&c->icosq.cq);
mlx5e_cq_arm(&c->async_icosq.cq);
mlx5e_cq_arm(&c->xdpsq.cq);
if (c->xdpsq)
mlx5e_cq_arm(&c->xdpsq->cq);

if (xsk_open) {
mlx5e_handle_rx_dim(xskrq);
Expand Down
3 changes: 3 additions & 0 deletions drivers/net/ethernet/mellanox/mlx5/core/esw/qos.c
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,9 @@ static int esw_qos_devlink_rate_to_mbps(struct mlx5_core_dev *mdev, const char *

int mlx5_esw_qos_init(struct mlx5_eswitch *esw)
{
if (esw->qos.domain)
return 0; /* Nothing to change. */

return esw_qos_domain_init(esw);
}

Expand Down
16 changes: 9 additions & 7 deletions drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
Original file line number Diff line number Diff line change
Expand Up @@ -1485,7 +1485,7 @@ int mlx5_eswitch_enable_locked(struct mlx5_eswitch *esw, int num_vfs)

err = mlx5_esw_qos_init(esw);
if (err)
goto err_qos_init;
goto err_esw_init;

if (esw->mode == MLX5_ESWITCH_LEGACY) {
err = esw_legacy_enable(esw);
Expand All @@ -1495,7 +1495,7 @@ int mlx5_eswitch_enable_locked(struct mlx5_eswitch *esw, int num_vfs)
}

if (err)
goto err_esw_enable;
goto err_esw_init;

esw->fdb_table.flags |= MLX5_ESW_FDB_CREATED;

Expand All @@ -1509,9 +1509,7 @@ int mlx5_eswitch_enable_locked(struct mlx5_eswitch *esw, int num_vfs)

return 0;

err_esw_enable:
mlx5_esw_qos_cleanup(esw);
err_qos_init:
err_esw_init:
mlx5_eq_notifier_unregister(esw->dev, &esw->nb);
mlx5_esw_acls_ns_cleanup(esw);
return err;
Expand Down Expand Up @@ -1640,7 +1638,6 @@ void mlx5_eswitch_disable_locked(struct mlx5_eswitch *esw)

if (esw->mode == MLX5_ESWITCH_OFFLOADS)
devl_rate_nodes_destroy(devlink);
mlx5_esw_qos_cleanup(esw);
}

void mlx5_eswitch_disable(struct mlx5_eswitch *esw)
Expand Down Expand Up @@ -1884,6 +1881,11 @@ int mlx5_eswitch_init(struct mlx5_core_dev *dev)
if (err)
goto reps_err;

esw->mode = MLX5_ESWITCH_LEGACY;
err = mlx5_esw_qos_init(esw);
if (err)
goto reps_err;

mutex_init(&esw->offloads.encap_tbl_lock);
hash_init(esw->offloads.encap_tbl);
mutex_init(&esw->offloads.decap_tbl_lock);
Expand All @@ -1897,7 +1899,6 @@ int mlx5_eswitch_init(struct mlx5_core_dev *dev)
refcount_set(&esw->qos.refcnt, 0);

esw->enabled_vports = 0;
esw->mode = MLX5_ESWITCH_LEGACY;
esw->offloads.inline_mode = MLX5_INLINE_MODE_NONE;
if (MLX5_CAP_ESW_FLOWTABLE_FDB(dev, reformat) &&
MLX5_CAP_ESW_FLOWTABLE_FDB(dev, decap))
Expand Down Expand Up @@ -1934,6 +1935,7 @@ void mlx5_eswitch_cleanup(struct mlx5_eswitch *esw)

esw_info(esw->dev, "cleanup\n");

mlx5_esw_qos_cleanup(esw);
destroy_workqueue(esw->work_queue);
WARN_ON(refcount_read(&esw->qos.refcnt));
mutex_destroy(&esw->state_lock);
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/mellanox/mlx5/core/fs_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#include <linux/mlx5/fs.h>
#include <linux/rhashtable.h>
#include <linux/llist.h>
#include <steering/fs_dr.h>
#include <steering/sws/fs_dr.h>

#define FDB_TC_MAX_CHAIN 3
#define FDB_FT_CHAIN (FDB_TC_MAX_CHAIN + 1)
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ethernet/mellanox/mlx5/core/lib/smfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#ifndef __MLX5_LIB_SMFS_H__
#define __MLX5_LIB_SMFS_H__

#include "steering/mlx5dr.h"
#include "steering/dr_types.h"
#include "steering/sws/mlx5dr.h"
#include "steering/sws/dr_types.h"

struct mlx5dr_matcher *
mlx5_smfs_matcher_create(struct mlx5dr_table *table, u32 priority, struct mlx5_flow_spec *spec);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
/* Copyright (c) 2024 NVIDIA Corporation & Affiliates */

#include "mlx5hws_internal.h"
#include "internal.h"

#define MLX5HWS_ACTION_METER_INIT_COLOR_OFFSET 1

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
/* Copyright (c) 2024 NVIDIA Corporation & Affiliates */

#ifndef MLX5HWS_ACTION_H_
#define MLX5HWS_ACTION_H_
#ifndef HWS_ACTION_H_
#define HWS_ACTION_H_

/* Max number of STEs needed for a rule (including match) */
#define MLX5HWS_ACTION_MAX_STE 20
Expand Down Expand Up @@ -304,4 +304,4 @@ mlx5hws_action_apply_setter(struct mlx5hws_actions_apply_data *apply,
htonl(num_of_actions << 29);
}

#endif /* MLX5HWS_ACTION_H_ */
#endif /* HWS_ACTION_H_ */
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
/* Copyright (c) 2024 NVIDIA Corporation & Affiliates */

#include "mlx5hws_internal.h"
#include "mlx5hws_buddy.h"
#include "internal.h"
#include "buddy.h"

static int hws_buddy_init(struct mlx5hws_buddy_mem *buddy, u32 max_order)
{
Expand Down
Loading

0 comments on commit 8d1807a

Please sign in to comment.