mlx5e per-queue coalescing
Subsystems (5)
Tariq Toukan
maintainercover mlx5e per-queue coalescing
Hi,
This patchset adds ethtool per-queue coalescing support for the mlx5e driver.
The series introduce some changes needed as preparations for the final patch which adds the support and implements the callbacks. Main changes:
- DIM code movements into its own header file.
- Switch to dynamic allocation of the DIM struct in the RQs/SQs.
- Allow coalescing config change without channels reset when possible.
Series generated against:
commit fdf412374379 ("gve: Remove qpl_cfg struct since qpl_ids map with queues respectively")
Thanks,
Tariq.
Rahul Rameshbabu (5):
net/mlx5e: Move DIM function declarations to en/dim.h net/mlx5e: Use DIM constants for CQ period mode parameter net/mlx5e: Dynamically allocate DIM structure for SQs/RQs net/mlx5e: Support updating coalescing configuration without resetting
channels
net/mlx5e: Implement ethtool callbacks for supporting per-queue
coalescing
drivers/net/ethernet/mellanox/mlx5/core/en.h | 30 +- .../ethernet/mellanox/mlx5/core/en/channels.c | 83 +++++ .../ethernet/mellanox/mlx5/core/en/channels.h | 4 + .../net/ethernet/mellanox/mlx5/core/en/dim.h | 45 +++ .../ethernet/mellanox/mlx5/core/en/params.c | 72 +---- .../ethernet/mellanox/mlx5/core/en/params.h | 5 - .../net/ethernet/mellanox/mlx5/core/en_dim.c | 95 +++++- .../ethernet/mellanox/mlx5/core/en_ethtool.c | 300 ++++++++++++++---- .../net/ethernet/mellanox/mlx5/core/en_main.c | 206 ++++++++++-- .../net/ethernet/mellanox/mlx5/core/en_rep.c | 10 +- .../net/ethernet/mellanox/mlx5/core/en_txrx.c | 4 +- include/linux/mlx5/cq.h | 7 +- include/linux/mlx5/mlx5_ifc.h | 7 +- 13 files changed, 672 insertions(+), 196 deletions(-) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/dim.h
Signature · 1 line
2.31.1
Tariq Toukan
maintainerPATCH 1/5 net/mlx5e: Move DIM function declarations to en/dim.h
From: Rahul Rameshbabu <[email protected]>
Create a header specifically for DIM-related declarations. Move existing DIM-specific functionality from en.h. Future DIM-related functionality will be declared in en/dim.h in subsequent patches.
--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 2 -- drivers/net/ethernet/mellanox/mlx5/core/en/dim.h | 15 +++++++++++++++ drivers/net/ethernet/mellanox/mlx5/core/en_dim.c | 2 +- .../net/ethernet/mellanox/mlx5/core/en_ethtool.c | 1 + drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 1 + 5 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/dim.h
drivers/net/ethernet/mellanox/mlx5/core/en.h +0 -2
@@ -1210,8 +1210,6 @@ int mlx5e_netdev_change_profile(struct mlx5e_priv *priv,void mlx5e_netdev_attach_nic_profile (struct mlx5e_priv *priv);void mlx5e_set_netdev_mtu_boundaries (struct mlx5e_priv *priv);void mlx5e_build_nic_params (struct mlx5e_priv *priv,struct mlx5e_xsk *xsk,u16 mtu); -void mlx5e_rx_dim_work (struct work_struct *work); -void mlx5e_tx_dim_work (struct work_struct *work);void mlx5e_set_xdp_feature (struct net_device *netdev); netdev_features_t mlx5e_features_check(struct sk_buff *skb,
drivers/net/ethernet/mellanox/mlx5/core/en/dim.h new file +15 -0
@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ +/* Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved */ + +#ifndef __MLX5_EN_DIM_H__ +#define __MLX5_EN_DIM_H__ + +#include <linux/types.h> + +/* Forward declarations */ +struct work_struct ; + +void mlx5e_rx_dim_work (struct work_struct *work); +void mlx5e_tx_dim_work (struct work_struct *work); + +#endif /* __MLX5_EN_DIM_H__ */
drivers/net/ethernet/mellanox/mlx5/core/en_dim.c +1 -1
@@ -30,8 +30,8 @@* SOFTWARE. */ -#include <linux/dim.h> #include "en.h" +#include "en/dim.h" static void mlx5e_complete_dim_work(struct dim *dim, struct dim_cq_moder moder,
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +1 -0
@@ -33,6 +33,7 @@#include <linux/ethtool_netlink.h> #include "en.h" +#include "en/dim.h" #include "en/port.h" #include "en/params.h" #include "en/ptp.h"
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +1 -0
@@ -43,6 +43,7 @@#include <net/xdp_sock_drv.h> #include "eswitch.h" #include "en.h" +#include "en/dim.h" #include "en/txrx.h" #include "en_tc.h" #include "en_rep.h"
Signature · 1 line
2.31.1
Tariq Toukan
maintainerPATCH 2/5 net/mlx5e: Use DIM constants for CQ period mode parameter
In reply to Tariq ToukanFrom: Rahul Rameshbabu <[email protected]>
Use core DIM CQ period mode enum values for the CQ parameter for the period mode. Translate the value to the specific mlx5 device constant for the selected period mode when creating a CQ. Avoid needing to translate mlx5 device constants to DIM constants for core DIM functionality.
--- .../net/ethernet/mellanox/mlx5/core/en/dim.h | 26 ++++++++++++++ .../ethernet/mellanox/mlx5/core/en/params.c | 34 ++++++------------- .../ethernet/mellanox/mlx5/core/en_ethtool.c | 16 +++------ .../net/ethernet/mellanox/mlx5/core/en_main.c | 20 ++++------- .../net/ethernet/mellanox/mlx5/core/en_rep.c | 7 ++-- include/linux/mlx5/mlx5_ifc.h | 4 +-- 6 files changed, 53 insertions(+), 54 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/dim.h +26 -0
@@ -4,11 +4,37 @@#ifndef __MLX5_EN_DIM_H__#define __MLX5_EN_DIM_H__ +#include <linux/dim.h> #include <linux/types.h> +#include <linux/mlx5/mlx5_ifc.h> /* Forward declarations */ struct work_struct ; +/* convert a boolean value for cqe mode to appropriate dim constant +* true : DIM_CQ_PERIOD_MODE_START_FROM_CQE +* false : DIM_CQ_PERIOD_MODE_START_FROM_EQE +*/ +static inline int mlx5e_dim_cq_period_mode (bool start_from_cqe) +{ +return start_from_cqe ?DIM_CQ_PERIOD_MODE_START_FROM_CQE : +DIM_CQ_PERIOD_MODE_START_FROM_EQE ; +} + +static inline enum mlx5_cq_period_mode +mlx5e_cq_period_mode (enum dim_cq_period_mode cq_period_mode) +{ +switch (cq_period_mode) { +case DIM_CQ_PERIOD_MODE_START_FROM_EQE : +return MLX5_CQ_PERIOD_MODE_START_FROM_EQE ; +case DIM_CQ_PERIOD_MODE_START_FROM_CQE : +return MLX5_CQ_PERIOD_MODE_START_FROM_CQE ; +default : +WARN_ON_ONCE (true); +return MLX5_CQ_PERIOD_MODE_START_FROM_EQE ; + } +} +void mlx5e_rx_dim_work (struct work_struct *work);void mlx5e_tx_dim_work (struct work_struct *work);
drivers/net/ethernet/mellanox/mlx5/core/en/params.c +11 -23
@@ -6,6 +6,7 @@#include "en/port.h" #include "en_accel/en_accel.h" #include "en_accel/ipsec.h" +#include <linux/dim.h> #include <net/page_pool/types.h> #include <net/xdp_sock_drv.h>
@@ -520,7 +521,7 @@ static struct dim_cq_moder mlx5e_get_def_tx_moderation(u8 cq_period_mode) moder.cq_period_mode = cq_period_mode; moder.pkts =MLX5E_PARAMS_DEFAULT_TX_CQ_MODERATION_PKTS ; moder.usec =MLX5E_PARAMS_DEFAULT_TX_CQ_MODERATION_USEC ; -if (cq_period_mode ==MLX5_CQ_PERIOD_MODE_START_FROM_CQE ) +if (cq_period_mode ==DIM_CQ_PERIOD_MODE_START_FROM_CQE ) moder.usec =MLX5E_PARAMS_DEFAULT_TX_CQ_MODERATION_USEC_FROM_CQE ;return moder;
@@ -533,39 +534,26 @@ static struct dim_cq_moder mlx5e_get_def_rx_moderation(u8 cq_period_mode) moder.cq_period_mode = cq_period_mode; moder.pkts =MLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_PKTS ; moder.usec =MLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_USEC ; -if (cq_period_mode ==MLX5_CQ_PERIOD_MODE_START_FROM_CQE ) +if (cq_period_mode ==DIM_CQ_PERIOD_MODE_START_FROM_CQE ) moder.usec =MLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_USEC_FROM_CQE ;return moder; } -static u8 mlx5_to_net_dim_cq_period_mode (u8 cq_period_mode) -{ -return cq_period_mode ==MLX5_CQ_PERIOD_MODE_START_FROM_CQE ? -DIM_CQ_PERIOD_MODE_START_FROM_CQE : -DIM_CQ_PERIOD_MODE_START_FROM_EQE ; -} -void mlx5e_reset_tx_moderation (struct mlx5e_params *params,u8 cq_period_mode) { -if (params->tx_dim_enabled) { -u8 dim_period_mode =mlx5_to_net_dim_cq_period_mode (cq_period_mode); - - params->tx_cq_moderation =net_dim_get_def_tx_moderation (dim_period_mode); - }else { +if (params->tx_dim_enabled) + params->tx_cq_moderation =net_dim_get_def_tx_moderation (cq_period_mode); +else params->tx_cq_moderation =mlx5e_get_def_tx_moderation (cq_period_mode); - } }void mlx5e_reset_rx_moderation (struct mlx5e_params *params,u8 cq_period_mode) { -if (params->rx_dim_enabled) { -u8 dim_period_mode =mlx5_to_net_dim_cq_period_mode (cq_period_mode); - - params->rx_cq_moderation =net_dim_get_def_rx_moderation (dim_period_mode); - }else { +if (params->rx_dim_enabled) + params->rx_cq_moderation =net_dim_get_def_rx_moderation (cq_period_mode); +else params->rx_cq_moderation =mlx5e_get_def_rx_moderation (cq_period_mode); - } }void mlx5e_set_tx_cq_mode_params (struct mlx5e_params *params,u8 cq_period_mode)
@@ -573,7 +561,7 @@ void mlx5e_set_tx_cq_mode_params(struct mlx5e_params *params, u8 cq_period_mode)mlx5e_reset_tx_moderation (params, cq_period_mode);MLX5E_SET_PFLAG (params,MLX5E_PFLAG_TX_CQE_BASED_MODER , params->tx_cq_moderation.cq_period_mode == -MLX5_CQ_PERIOD_MODE_START_FROM_CQE ); +DIM_CQ_PERIOD_MODE_START_FROM_CQE ); }void mlx5e_set_rx_cq_mode_params (struct mlx5e_params *params,u8 cq_period_mode)
@@ -581,7 +569,7 @@ void mlx5e_set_rx_cq_mode_params(struct mlx5e_params *params, u8 cq_period_mode)mlx5e_reset_rx_moderation (params, cq_period_mode);MLX5E_SET_PFLAG (params,MLX5E_PFLAG_RX_CQE_BASED_MODER , params->rx_cq_moderation.cq_period_mode == -MLX5_CQ_PERIOD_MODE_START_FROM_CQE ); +DIM_CQ_PERIOD_MODE_START_FROM_CQE ); }bool slow_pci_heuristic (struct mlx5_core_dev *mdev)
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +4 -12
@@ -30,6 +30,7 @@* SOFTWARE. */ +#include <linux/dim.h> #include <linux/ethtool_netlink.h> #include "en.h"
@@ -627,15 +628,6 @@ mlx5e_set_priv_channels_rx_coalesce(struct mlx5e_priv *priv, struct ethtool_coal } } -/* convert a boolean value of cq_mode to mlx5 period mode -* true : MLX5_CQ_PERIOD_MODE_START_FROM_CQE -* false : MLX5_CQ_PERIOD_MODE_START_FROM_EQE -*/ -static int cqe_mode_to_period_mode (bool val) -{ -return val ?MLX5_CQ_PERIOD_MODE_START_FROM_CQE :MLX5_CQ_PERIOD_MODE_START_FROM_EQE ; -} - int mlx5e_ethtool_set_coalesce(struct mlx5e_priv *priv, struct ethtool_coalesce *coal, struct kernel_ethtool_coalesce *kernel_coal,
@@ -688,13 +680,13 @@ int mlx5e_ethtool_set_coalesce(struct mlx5e_priv *priv, reset_rx = !!coal->use_adaptive_rx_coalesce != priv->channels.params.rx_dim_enabled; reset_tx = !!coal->use_adaptive_tx_coalesce != priv->channels.params.tx_dim_enabled; - cq_period_mode =cqe_mode_to_period_mode (kernel_coal->use_cqe_mode_rx); + cq_period_mode =mlx5e_dim_cq_period_mode (kernel_coal->use_cqe_mode_rx);if (cq_period_mode != rx_moder->cq_period_mode) {mlx5e_set_rx_cq_mode_params (&new_params, cq_period_mode); reset_rx = true; } - cq_period_mode =cqe_mode_to_period_mode (kernel_coal->use_cqe_mode_tx); + cq_period_mode =mlx5e_dim_cq_period_mode (kernel_coal->use_cqe_mode_tx);if (cq_period_mode != tx_moder->cq_period_mode) {mlx5e_set_tx_cq_mode_params (&new_params, cq_period_mode); reset_tx = true;
@@ -1915,7 +1907,7 @@ static int set_pflag_cqe_based_moder(struct net_device *netdev, bool enable,if (enable && !MLX5_CAP_GEN (priv->mdev, cq_period_start_from_cqe))return -EOPNOTSUPP ; - cq_period_mode =cqe_mode_to_period_mode (enable); + cq_period_mode =mlx5e_dim_cq_period_mode (enable); current_cq_period_mode = is_rx_cq ? priv->channels.params.rx_cq_moderation.cq_period_mode :
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +6 -14
@@ -30,6 +30,7 @@* SOFTWARE. */ +#include <linux/dim.h> #include <net/tc_act/tc_gact.h> #include <linux/mlx5/fs.h> #include <net/vxlan.h>
@@ -962,15 +963,7 @@ static int mlx5e_alloc_rq(struct mlx5e_params *params, }INIT_WORK (&rq->dim.work, mlx5e_rx_dim_work); - -switch (params->rx_cq_moderation.cq_period_mode) { -case MLX5_CQ_PERIOD_MODE_START_FROM_CQE : - rq->dim.mode =DIM_CQ_PERIOD_MODE_START_FROM_CQE ; -break ; -case MLX5_CQ_PERIOD_MODE_START_FROM_EQE : -default : - rq->dim.mode =DIM_CQ_PERIOD_MODE_START_FROM_EQE ; - } + rq->dim.mode = params->rx_cq_moderation.cq_period_mode;return 0 ;
@@ -2090,7 +2083,7 @@ static int mlx5e_create_cq(struct mlx5e_cq *cq, struct mlx5e_cq_param *param)mlx5_fill_page_frag_array (&cq->wq_ctrl.buf, (__be64 *)MLX5_ADDR_OF (create_cq_in, in, pas)); -MLX5_SET (cqc, cqc, cq_period_mode, param->cq_period_mode); +MLX5_SET (cqc, cqc, cq_period_mode,mlx5e_cq_period_mode (param->cq_period_mode));MLX5_SET (cqc, cqc, c_eqn_or_apu_element, eqn);MLX5_SET (cqc, cqc, uar_page, mdev->priv.uar->index); MLX5_SET(cqc, cqc, log_page_size, cq->wq_ctrl.buf.page_shift -
@@ -5059,13 +5052,12 @@ void mlx5e_build_nic_params(struct mlx5e_priv *priv, struct mlx5e_xsk *xsk, u16 params->packet_merge.timeout =mlx5e_choose_lro_timeout (mdev,MLX5E_DEFAULT_LRO_TIMEOUT );/* CQ moderation params */ - rx_cq_period_mode =MLX5_CAP_GEN (mdev, cq_period_start_from_cqe) ? -MLX5_CQ_PERIOD_MODE_START_FROM_CQE : -MLX5_CQ_PERIOD_MODE_START_FROM_EQE ; + rx_cq_period_mode = +mlx5e_dim_cq_period_mode (MLX5_CAP_GEN (mdev, cq_period_start_from_cqe)); params->rx_dim_enabled =MLX5_CAP_GEN (mdev, cq_moderation); params->tx_dim_enabled =MLX5_CAP_GEN (mdev, cq_moderation);mlx5e_set_rx_cq_mode_params (params, rx_cq_period_mode); -mlx5e_set_tx_cq_mode_params (params,MLX5_CQ_PERIOD_MODE_START_FROM_EQE ); +mlx5e_set_tx_cq_mode_params (params,DIM_CQ_PERIOD_MODE_START_FROM_EQE );/* TX inline */ mlx5_query_min_inline (mdev, ¶ms->tx_min_inline_mode);
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +4 -3
@@ -30,6 +30,7 @@* SOFTWARE. */ +#include <linux/dim.h> #include <linux/debugfs.h> #include <linux/mlx5/fs.h> #include <net/switchdev.h>
@@ -40,6 +41,7 @@#include "eswitch.h" #include "en.h" +#include "en/dim.h" #include "en_rep.h" #include "en/params.h" #include "en/txrx.h"
@@ -836,9 +838,8 @@ static void mlx5e_build_rep_params(struct net_device *netdev)struct mlx5_core_dev *mdev = priv->mdev;struct mlx5e_params *params; -u8 cq_period_mode =MLX5_CAP_GEN (mdev, cq_period_start_from_cqe) ? -MLX5_CQ_PERIOD_MODE_START_FROM_CQE : -MLX5_CQ_PERIOD_MODE_START_FROM_EQE ; +u8 cq_period_mode = +mlx5e_dim_cq_period_mode (MLX5_CAP_GEN (mdev, cq_period_start_from_cqe)); params = &priv->channels.params;
include/linux/mlx5/mlx5_ifc.h +2 -2
@@ -4385,10 +4385,10 @@ enum { MLX5_CQC_ST_FIRED = 0xa, }; -enum { +enum mlx5_cq_period_mode {MLX5_CQ_PERIOD_MODE_START_FROM_EQE =0x0 ,MLX5_CQ_PERIOD_MODE_START_FROM_CQE =0x1 , -MLX5_CQ_PERIOD_NUM_MODES +MLX5_CQ_PERIOD_NUM_MODES , };struct mlx5_ifc_cqc_bits {
Signature · 1 line
2.31.1
Tariq Toukan
maintainerPATCH 3/5 net/mlx5e: Dynamically allocate DIM structure for SQs/RQs
In reply to Tariq ToukanFrom: Rahul Rameshbabu <[email protected]>
Make it possible for the DIM structure to be torn down while an SQ or RQ is still active. Changing the CQ period mode is an example where the previous sampling done with the DIM structure would need to be invalidated.
--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 4 +-- .../net/ethernet/mellanox/mlx5/core/en_dim.c | 4 +-- .../net/ethernet/mellanox/mlx5/core/en_main.c | 31 +++++++++++++++---- .../net/ethernet/mellanox/mlx5/core/en_txrx.c | 4 +-- 4 files changed, 31 insertions(+), 12 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en.h +2 -2
@@ -430,7 +430,7 @@ struct mlx5e_txqsq {u16 cc;u16 skb_fifo_cc;u32 dma_fifo_cc; -struct dim dim;/* Adaptive Moderation */ +struct dim *dim;/* Adaptive Moderation */ /* dirtied @xmit */ u16 pc____cacheline_aligned_in_smp ;
@@ -722,7 +722,7 @@ struct mlx5e_rq {int ix;unsigned int hw_mtu; -struct dim dim;/* Dynamic Interrupt Moderation */ +struct dim *dim;/* Dynamic Interrupt Moderation */ /* XDP */ struct bpf_prog __rcu *xdp_prog;
drivers/net/ethernet/mellanox/mlx5/core/en_dim.c +2 -2
@@ -44,7 +44,7 @@ mlx5e_complete_dim_work(struct dim *dim, struct dim_cq_moder moder,void mlx5e_rx_dim_work (struct work_struct *work) { struct dim *dim = container_of(work, struct dim, work); - struct mlx5e_rq *rq = container_of(dim, struct mlx5e_rq, dim); +struct mlx5e_rq *rq = dim->priv;struct dim_cq_moder cur_moder =net_dim_get_rx_moderation (dim->mode, dim->profile_ix);
@@ -54,7 +54,7 @@ void mlx5e_rx_dim_work(struct work_struct *work)void mlx5e_tx_dim_work (struct work_struct *work) { struct dim *dim = container_of(work, struct dim, work); - struct mlx5e_txqsq *sq = container_of(dim, struct mlx5e_txqsq, dim); +struct mlx5e_txqsq *sq = dim->priv;struct dim_cq_moder cur_moder =net_dim_get_tx_moderation (dim->mode, dim->profile_ix);
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +25 -6
@@ -962,11 +962,20 @@ static int mlx5e_alloc_rq(struct mlx5e_params *params, } } -INIT_WORK (&rq->dim.work, mlx5e_rx_dim_work); - rq->dim.mode = params->rx_cq_moderation.cq_period_mode; + rq->dim =kvzalloc_node (sizeof (*rq->dim),GFP_KERNEL , node); +if (!rq->dim) { + err = -ENOMEM ; + goto err_unreg_xdp_rxq_info; + } + + rq->dim->priv = rq; +INIT_WORK (&rq->dim->work, mlx5e_rx_dim_work); + rq->dim->mode = params->rx_cq_moderation.cq_period_mode;return 0 ; +err_unreg_xdp_rxq_info: +xdp_rxq_info_unreg (&rq->xdp_rxq); err_destroy_page_pool:page_pool_destroy (rq->page_pool); err_free_by_rq_type:
@@ -1014,6 +1023,7 @@ static void mlx5e_free_rq(struct mlx5e_rq *rq)mlx5e_free_wqe_alloc_info (rq); } +kvfree (rq->dim);xdp_rxq_info_unreg (&rq->xdp_rxq);page_pool_destroy (rq->page_pool);mlx5_wq_destroy (&rq->wq_ctrl);
@@ -1341,7 +1351,7 @@ void mlx5e_deactivate_rq(struct mlx5e_rq *rq)void mlx5e_close_rq (struct mlx5e_rq *rq) { -cancel_work_sync (&rq->dim.work); +cancel_work_sync (&rq->dim->work);cancel_work_sync (&rq->recover_work);mlx5e_destroy_rq (rq);mlx5e_free_rx_descs (rq);
@@ -1616,12 +1626,20 @@ static int mlx5e_alloc_txqsq(struct mlx5e_channel *c, err =mlx5e_alloc_txqsq_db (sq,cpu_to_node (c->cpu));if (err) goto err_sq_wq_destroy; + sq->dim =kvzalloc_node (sizeof (*sq->dim),GFP_KERNEL ,cpu_to_node (c->cpu)); +if (!sq->dim) { + err = -ENOMEM ; + goto err_free_txqsq_db; + } -INIT_WORK (&sq->dim.work, mlx5e_tx_dim_work); - sq->dim.mode = params->tx_cq_moderation.cq_period_mode; + sq->dim->priv = sq; +INIT_WORK (&sq->dim->work, mlx5e_tx_dim_work); + sq->dim->mode = params->tx_cq_moderation.cq_period_mode;return 0 ; +err_free_txqsq_db: +mlx5e_free_txqsq_db (sq); err_sq_wq_destroy:mlx5_wq_destroy (&sq->wq_ctrl);
@@ -1630,6 +1648,7 @@ static int mlx5e_alloc_txqsq(struct mlx5e_channel *c,void mlx5e_free_txqsq (struct mlx5e_txqsq *sq) { +kvfree (sq->dim);mlx5e_free_txqsq_db (sq);mlx5_wq_destroy (&sq->wq_ctrl); }
@@ -1841,7 +1860,7 @@ void mlx5e_close_txqsq(struct mlx5e_txqsq *sq)struct mlx5_core_dev *mdev = sq->mdev;struct mlx5_rate_limit rl = {0 }; -cancel_work_sync (&sq->dim.work); +cancel_work_sync (&sq->dim->work);cancel_work_sync (&sq->recover_work);mlx5e_destroy_sq (mdev, sq->sqn);if (sq->rate_limit) {
drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c +2 -2
@@ -55,7 +55,7 @@ static void mlx5e_handle_tx_dim(struct mlx5e_txqsq *sq)return ;dim_update_sample (sq->cq.event_ctr, stats->packets, stats->bytes, &dim_sample); -net_dim (&sq->dim, dim_sample); +net_dim (sq->dim, dim_sample); }static void mlx5e_handle_rx_dim (struct mlx5e_rq *rq)
@@ -67,7 +67,7 @@ static void mlx5e_handle_rx_dim(struct mlx5e_rq *rq)return ;dim_update_sample (rq->cq.event_ctr, stats->packets, stats->bytes, &dim_sample); -net_dim (&rq->dim, dim_sample); +net_dim (rq->dim, dim_sample); }void mlx5e_trigger_irq (struct mlx5e_icosq *sq)
Signature · 1 line
2.31.1
Tariq Toukan
maintainerPATCH 4/5 net/mlx5e: Support updating coalescing configuration without resetting channels
In reply to Tariq ToukanFrom: Rahul Rameshbabu <[email protected]>
When CQE mode or DIM state is changed, gracefully reconfigure channels to handle new configuration. Previously, would create new channels that would reflect the changes rather than update the original channels.
--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 20 ++ .../ethernet/mellanox/mlx5/core/en/channels.c | 83 +++++++ .../ethernet/mellanox/mlx5/core/en/channels.h | 4 + .../net/ethernet/mellanox/mlx5/core/en/dim.h | 4 + .../ethernet/mellanox/mlx5/core/en/params.c | 58 ----- .../ethernet/mellanox/mlx5/core/en/params.h | 5 - .../net/ethernet/mellanox/mlx5/core/en_dim.c | 89 +++++++- .../ethernet/mellanox/mlx5/core/en_ethtool.c | 141 +++++++----- .../net/ethernet/mellanox/mlx5/core/en_main.c | 210 ++++++++++++++---- .../net/ethernet/mellanox/mlx5/core/en_rep.c | 5 +- include/linux/mlx5/cq.h | 7 +- include/linux/mlx5/mlx5_ifc.h | 3 +- 12 files changed, 460 insertions(+), 169 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en.h +20 -0
@@ -320,6 +320,8 @@ struct mlx5e_params {bool scatter_fcs_en;bool rx_dim_enabled;bool tx_dim_enabled; +bool rx_moder_use_cqe_mode; +bool tx_moder_use_cqe_mode;u32 pflags;struct bpf_prog *xdp_prog;struct mlx5e_xsk *xsk;
@@ -797,6 +799,10 @@ struct mlx5e_channel {int cpu;/* Sync between icosq recovery and XSK enable/disable. */ struct mutex icosq_recovery_lock; + +/* coalescing configuration */ +struct dim_cq_moder rx_cq_moder; +struct dim_cq_moder tx_cq_moder; };struct mlx5e_ptp ;
@@ -1040,6 +1046,11 @@ void mlx5e_close_rq(struct mlx5e_rq *rq);int mlx5e_create_rq (struct mlx5e_rq *rq,struct mlx5e_rq_param *param,u16 q_counter);void mlx5e_destroy_rq (struct mlx5e_rq *rq); +bool mlx5e_reset_rx_moderation (struct dim_cq_moder *cq_moder,u8 cq_period_mode, +bool dim_enabled); +bool mlx5e_reset_rx_channels_moderation (struct mlx5e_channels *chs,u8 cq_period_mode, +bool dim_enabled,bool keep_dim_state); +struct mlx5e_sq_param ; int mlx5e_open_xdpsq(struct mlx5e_channel *c, struct mlx5e_params *params, struct mlx5e_sq_param *param, struct xsk_buff_pool *xsk_pool,
@@ -1060,6 +1071,10 @@ int mlx5e_open_cq(struct mlx5_core_dev *mdev, struct dim_cq_moder moder, struct mlx5e_cq_param *param, struct mlx5e_create_cq_param *ccp, struct mlx5e_cq *cq);void mlx5e_close_cq (struct mlx5e_cq *cq); +int mlx5e_modify_cq_period_mode (struct mlx5_core_dev *dev,struct mlx5_core_cq *cq, +u8 cq_period_mode); +int mlx5e_modify_cq_moderation (struct mlx5_core_dev *dev,struct mlx5_core_cq *cq, +u16 cq_period,u16 cq_max_count,u8 cq_period_mode);int mlx5e_open_locked (struct net_device *netdev);int mlx5e_close_locked (struct net_device *netdev);
@@ -1118,6 +1133,11 @@ int mlx5e_create_sq_rdy(struct mlx5_core_dev *mdev,void mlx5e_tx_err_cqe_work (struct work_struct *recover_work);void mlx5e_close_txqsq (struct mlx5e_txqsq *sq); +bool mlx5e_reset_tx_moderation (struct dim_cq_moder *cq_moder,u8 cq_period_mode, +bool dim_enabled); +bool mlx5e_reset_tx_channels_moderation (struct mlx5e_channels *chs,u8 cq_period_mode, +bool dim_enabled,bool keep_dim_state); +static inline bool mlx5_tx_swp_supported (struct mlx5_core_dev *mdev) { return MLX5_CAP_ETH(mdev, swp) &&
drivers/net/ethernet/mellanox/mlx5/core/en/channels.c +83 -0
92 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en/channels.h +4 -0
@@ -15,5 +15,9 @@ void mlx5e_channels_get_regular_rqn(struct mlx5e_channels *chs, unsigned int ix,void mlx5e_channels_get_xsk_rqn (struct mlx5e_channels *chs,unsigned int ix,u32 *rqn,u32 *vhca_id);bool mlx5e_channels_get_ptp_rqn (struct mlx5e_channels *chs,u32 *rqn); +int mlx5e_channels_rx_change_dim (struct mlx5e_channels *chs,bool enabled); +int mlx5e_channels_tx_change_dim (struct mlx5e_channels *chs,bool enabled); +int mlx5e_channels_rx_toggle_dim (struct mlx5e_channels *chs); +int mlx5e_channels_tx_toggle_dim (struct mlx5e_channels *chs);#endif /* __MLX5_EN_CHANNELS_H__ */
drivers/net/ethernet/mellanox/mlx5/core/en/dim.h +4 -0
@@ -9,6 +9,8 @@#include <linux/mlx5/mlx5_ifc.h> /* Forward declarations */ +struct mlx5e_rq ; +struct mlx5e_txqsq ;struct work_struct ;/* convert a boolean value for cqe mode to appropriate dim constant
@@ -37,5 +39,7 @@ mlx5e_cq_period_mode(enum dim_cq_period_mode cq_period_mode)void mlx5e_rx_dim_work (struct work_struct *work);void mlx5e_tx_dim_work (struct work_struct *work); +int mlx5e_dim_rx_change (struct mlx5e_rq *rq,bool enabled); +int mlx5e_dim_tx_change (struct mlx5e_txqsq *sq,bool enabled);#endif /* __MLX5_EN_DIM_H__ */
drivers/net/ethernet/mellanox/mlx5/core/en/params.c +0 -58
64 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en/params.h +0 -5
@@ -77,11 +77,6 @@ u8 mlx5e_mpwrq_max_log_rq_pkts(struct mlx5_core_dev *mdev, u8 page_shift,/* Parameter calculations */ -void mlx5e_reset_tx_moderation (struct mlx5e_params *params,u8 cq_period_mode); -void mlx5e_reset_rx_moderation (struct mlx5e_params *params,u8 cq_period_mode); -void mlx5e_set_tx_cq_mode_params (struct mlx5e_params *params,u8 cq_period_mode); -void mlx5e_set_rx_cq_mode_params (struct mlx5e_params *params,u8 cq_period_mode); -bool slow_pci_heuristic (struct mlx5_core_dev *mdev);int mlx5e_mpwrq_validate_regular (struct mlx5_core_dev *mdev,struct mlx5e_params *params); int mlx5e_mpwrq_validate_xsk(struct mlx5_core_dev *mdev, struct mlx5e_params *params,
drivers/net/ethernet/mellanox/mlx5/core/en_dim.c +88 -1
98 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +83 -58
225 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +171 -39
296 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +1 -4
@@ -838,9 +838,6 @@ static void mlx5e_build_rep_params(struct net_device *netdev)struct mlx5_core_dev *mdev = priv->mdev;struct mlx5e_params *params; -u8 cq_period_mode = -mlx5e_dim_cq_period_mode (MLX5_CAP_GEN (mdev, cq_period_start_from_cqe)); - params = &priv->channels.params; params->num_channels =MLX5E_REP_PARAMS_DEF_NUM_CHANNELS ;
@@ -868,7 +865,7 @@ static void mlx5e_build_rep_params(struct net_device *netdev)/* CQ moderation params */ params->rx_dim_enabled =MLX5_CAP_GEN (mdev, cq_moderation); -mlx5e_set_rx_cq_mode_params (params, cq_period_mode); + params->rx_moder_use_cqe_mode = !!MLX5_CAP_GEN (mdev, cq_period_start_from_cqe); params->mqprio.num_tc =1 ;if (rep->vport !=MLX5_VPORT_UPLINK )
include/linux/mlx5/cq.h +4 -3
@@ -95,9 +95,10 @@ enum { };enum { -MLX5_CQ_MODIFY_PERIOD =1 <<0 , -MLX5_CQ_MODIFY_COUNT =1 <<1 , -MLX5_CQ_MODIFY_OVERRUN =1 <<2 , +MLX5_CQ_MODIFY_PERIOD =BIT (0 ), +MLX5_CQ_MODIFY_COUNT =BIT (1 ), +MLX5_CQ_MODIFY_OVERRUN =BIT (2 ), +MLX5_CQ_MODIFY_PERIOD_MODE =BIT (4 ), };enum {
include/linux/mlx5/mlx5_ifc.h +2 -1
@@ -1686,7 +1686,8 @@ struct mlx5_ifc_cmd_hca_cap_bits {u8 cq_oi[0x1 ];u8 cq_resize[0x1 ];u8 cq_moderation[0x1 ]; -u8 reserved_at_223[0x3 ]; +u8 cq_period_mode_modify[0x1 ]; +u8 reserved_at_224[0x2 ];u8 cq_eq_remap[0x1 ];u8 pg[0x1 ];u8 block_lb_mc[0x1 ];
Signature · 1 line
2.31.1
Tariq Toukan
maintainerPATCH 5/5 net/mlx5e: Implement ethtool callbacks for supporting per-queue coalescing
In reply to Tariq ToukanFrom: Rahul Rameshbabu <[email protected]>
Use mlx5 on-the-fly coalescing configuration support to enable individual channel configuration.
--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 4 + .../ethernet/mellanox/mlx5/core/en_ethtool.c | 146 ++++++++++++++++++ .../net/ethernet/mellanox/mlx5/core/en_rep.c | 2 + 3 files changed, 152 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en.h +4 -0
@@ -1199,6 +1199,10 @@ int mlx5e_ethtool_set_coalesce(struct mlx5e_priv *priv,struct ethtool_coalesce *coal, struct kernel_ethtool_coalesce *kernel_coal, struct netlink_ext_ack *extack); +int mlx5e_get_per_queue_coalesce (struct net_device *dev,u32 queue, +struct ethtool_coalesce *coal); +int mlx5e_set_per_queue_coalesce (struct net_device *dev,u32 queue, +struct ethtool_coalesce *coal);u32 mlx5e_ethtool_get_rxfh_key_size (struct mlx5e_priv *priv);u32 mlx5e_ethtool_get_rxfh_indir_size (struct mlx5e_priv *priv); int mlx5e_ethtool_get_ts_info(struct mlx5e_priv *priv,
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +146 -0
164 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +2 -0
@@ -428,6 +428,8 @@ static const struct ethtool_ops mlx5e_rep_ethtool_ops = { .set_channels = mlx5e_rep_set_channels, .get_coalesce = mlx5e_rep_get_coalesce, .set_coalesce = mlx5e_rep_set_coalesce, + .get_per_queue_coalesce = mlx5e_get_per_queue_coalesce, + .set_per_queue_coalesce = mlx5e_set_per_queue_coalesce, .get_rxfh_key_size = mlx5e_rep_get_rxfh_key_size, .get_rxfh_indir_size = mlx5e_rep_get_rxfh_indir_size, };
Signature · 1 line
2.31.1
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 5 lines · On Fri, 19 Apr 2024 11:04:40 +0300 you wrote:
Hi,
This patchset adds ethtool per-queue coalescing support for the mlx5e driver.
Quoted 8 lines
The series introduce some changes needed as preparations for the final patch which adds the support and implements the callbacks. Main changes:
- DIM code movements into its own header file.
- Switch to dynamic allocation of the DIM struct in the RQs/SQs.
- Allow coalescing config change without channels reset when possible.[...]
Here is the summary with links:
- [net-next,1/5] net/mlx5e: Move DIM function declarations to en/dim.h
https://git.kernel.org/netdev/net-next/c/7ec56914d3ac - [net-next,2/5] net/mlx5e: Use DIM constants for CQ period mode parameter https://git.kernel.org/netdev/net-next/c/eca1e8a62888 - [net-next,3/5] net/mlx5e: Dynamically allocate DIM structure for SQs/RQs https://git.kernel.org/netdev/net-next/c/a5e89a3f353b - [net-next,4/5] net/mlx5e: Support updating coalescing configuration without resetting channels https://git.kernel.org/netdev/net-next/c/445a25f6e1a2 - [net-next,5/5] net/mlx5e: Implement ethtool callbacks for supporting per-queue coalescing https://git.kernel.org/netdev/net-next/c/651ebaad6e3c
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html