Commit 8399743a authored by David S. Miller's avatar David S. Miller

Merge branch 'net-DIM-tx'

Tal Gilboa says:

====================
Introduce adaptive TX interrupt moderation to net DIM

Net DIM is a library designed for dynamic interrupt moderation. It was
implemented and optimized with receive side interrupts in mind, since these
are usually the CPU expensive ones. This patch-set introduces adaptive transmit
interrupt moderation to net DIM, complete with a usage in the mlx5e driver.
Using adaptive TX behavior would reduce interrupt rate for multiple scenarios.
Furthermore, it is essential for increasing bandwidth on cases where payload
aggregation is required.

v3: Remove "inline" from functions in .c files (requested by DaveM). Revert
adding "enabled" field from struct net_dim and applied mlx5e structural
suggestions (suggested by SaeedM).

v2: Rebase over proper tree.

v1: Fix compilation issues due to missed function renaming.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents db688c24 cbce4f44
...@@ -654,7 +654,7 @@ static int bcm_sysport_set_coalesce(struct net_device *dev, ...@@ -654,7 +654,7 @@ static int bcm_sysport_set_coalesce(struct net_device *dev,
pkts = priv->rx_max_coalesced_frames; pkts = priv->rx_max_coalesced_frames;
if (ec->use_adaptive_rx_coalesce && !priv->dim.use_dim) { if (ec->use_adaptive_rx_coalesce && !priv->dim.use_dim) {
moder = net_dim_get_def_profile(priv->dim.dim.mode); moder = net_dim_get_def_rx_moderation(priv->dim.dim.mode);
usecs = moder.usec; usecs = moder.usec;
pkts = moder.pkts; pkts = moder.pkts;
} }
...@@ -1064,7 +1064,7 @@ static void bcm_sysport_dim_work(struct work_struct *work) ...@@ -1064,7 +1064,7 @@ static void bcm_sysport_dim_work(struct work_struct *work)
struct bcm_sysport_priv *priv = struct bcm_sysport_priv *priv =
container_of(ndim, struct bcm_sysport_priv, dim); container_of(ndim, struct bcm_sysport_priv, dim);
struct net_dim_cq_moder cur_profile = struct net_dim_cq_moder cur_profile =
net_dim_get_profile(dim->mode, dim->profile_ix); net_dim_get_rx_moderation(dim->mode, dim->profile_ix);
bcm_sysport_set_rx_coalesce(priv, cur_profile.usec, cur_profile.pkts); bcm_sysport_set_rx_coalesce(priv, cur_profile.usec, cur_profile.pkts);
dim->state = NET_DIM_START_MEASURE; dim->state = NET_DIM_START_MEASURE;
...@@ -1437,7 +1437,7 @@ static void bcm_sysport_init_rx_coalesce(struct bcm_sysport_priv *priv) ...@@ -1437,7 +1437,7 @@ static void bcm_sysport_init_rx_coalesce(struct bcm_sysport_priv *priv)
/* If DIM was enabled, re-apply default parameters */ /* If DIM was enabled, re-apply default parameters */
if (dim->use_dim) { if (dim->use_dim) {
moder = net_dim_get_def_profile(dim->dim.mode); moder = net_dim_get_def_rx_moderation(dim->dim.mode);
usecs = moder.usec; usecs = moder.usec;
pkts = moder.pkts; pkts = moder.pkts;
} }
......
...@@ -21,11 +21,11 @@ void bnxt_dim_work(struct work_struct *work) ...@@ -21,11 +21,11 @@ void bnxt_dim_work(struct work_struct *work)
struct bnxt_napi *bnapi = container_of(cpr, struct bnxt_napi *bnapi = container_of(cpr,
struct bnxt_napi, struct bnxt_napi,
cp_ring); cp_ring);
struct net_dim_cq_moder cur_profile = net_dim_get_profile(dim->mode, struct net_dim_cq_moder cur_moder =
dim->profile_ix); net_dim_get_rx_moderation(dim->mode, dim->profile_ix);
cpr->rx_ring_coal.coal_ticks = cur_profile.usec; cpr->rx_ring_coal.coal_ticks = cur_moder.usec;
cpr->rx_ring_coal.coal_bufs = cur_profile.pkts; cpr->rx_ring_coal.coal_bufs = cur_moder.pkts;
bnxt_hwrm_set_ring_coal(bnapi->bp, bnapi); bnxt_hwrm_set_ring_coal(bnapi->bp, bnapi);
dim->state = NET_DIM_START_MEASURE; dim->state = NET_DIM_START_MEASURE;
......
...@@ -652,7 +652,7 @@ static void bcmgenet_set_ring_rx_coalesce(struct bcmgenet_rx_ring *ring, ...@@ -652,7 +652,7 @@ static void bcmgenet_set_ring_rx_coalesce(struct bcmgenet_rx_ring *ring,
pkts = ring->rx_max_coalesced_frames; pkts = ring->rx_max_coalesced_frames;
if (ec->use_adaptive_rx_coalesce && !ring->dim.use_dim) { if (ec->use_adaptive_rx_coalesce && !ring->dim.use_dim) {
moder = net_dim_get_def_profile(ring->dim.dim.mode); moder = net_dim_get_def_rx_moderation(ring->dim.dim.mode);
usecs = moder.usec; usecs = moder.usec;
pkts = moder.pkts; pkts = moder.pkts;
} }
...@@ -1925,7 +1925,7 @@ static void bcmgenet_dim_work(struct work_struct *work) ...@@ -1925,7 +1925,7 @@ static void bcmgenet_dim_work(struct work_struct *work)
struct bcmgenet_rx_ring *ring = struct bcmgenet_rx_ring *ring =
container_of(ndim, struct bcmgenet_rx_ring, dim); container_of(ndim, struct bcmgenet_rx_ring, dim);
struct net_dim_cq_moder cur_profile = struct net_dim_cq_moder cur_profile =
net_dim_get_profile(dim->mode, dim->profile_ix); net_dim_get_rx_moderation(dim->mode, dim->profile_ix);
bcmgenet_set_rx_coalesce(ring, cur_profile.usec, cur_profile.pkts); bcmgenet_set_rx_coalesce(ring, cur_profile.usec, cur_profile.pkts);
dim->state = NET_DIM_START_MEASURE; dim->state = NET_DIM_START_MEASURE;
...@@ -2102,7 +2102,7 @@ static void bcmgenet_init_rx_coalesce(struct bcmgenet_rx_ring *ring) ...@@ -2102,7 +2102,7 @@ static void bcmgenet_init_rx_coalesce(struct bcmgenet_rx_ring *ring)
/* If DIM was enabled, re-apply default parameters */ /* If DIM was enabled, re-apply default parameters */
if (dim->use_dim) { if (dim->use_dim) {
moder = net_dim_get_def_profile(dim->dim.mode); moder = net_dim_get_def_rx_moderation(dim->dim.mode);
usecs = moder.usec; usecs = moder.usec;
pkts = moder.pkts; pkts = moder.pkts;
} }
......
...@@ -241,6 +241,7 @@ struct mlx5e_params { ...@@ -241,6 +241,7 @@ struct mlx5e_params {
bool vlan_strip_disable; bool vlan_strip_disable;
bool scatter_fcs_en; bool scatter_fcs_en;
bool rx_dim_enabled; bool rx_dim_enabled;
bool tx_dim_enabled;
u32 lro_timeout; u32 lro_timeout;
u32 pflags; u32 pflags;
struct bpf_prog *xdp_prog; struct bpf_prog *xdp_prog;
...@@ -330,6 +331,7 @@ enum { ...@@ -330,6 +331,7 @@ enum {
MLX5E_SQ_STATE_ENABLED, MLX5E_SQ_STATE_ENABLED,
MLX5E_SQ_STATE_RECOVERING, MLX5E_SQ_STATE_RECOVERING,
MLX5E_SQ_STATE_IPSEC, MLX5E_SQ_STATE_IPSEC,
MLX5E_SQ_STATE_AM,
}; };
struct mlx5e_sq_wqe_info { struct mlx5e_sq_wqe_info {
...@@ -342,6 +344,7 @@ struct mlx5e_txqsq { ...@@ -342,6 +344,7 @@ struct mlx5e_txqsq {
/* dirtied @completion */ /* dirtied @completion */
u16 cc; u16 cc;
u32 dma_fifo_cc; u32 dma_fifo_cc;
struct net_dim dim; /* Adaptive Moderation */
/* dirtied @xmit */ /* dirtied @xmit */
u16 pc ____cacheline_aligned_in_smp; u16 pc ____cacheline_aligned_in_smp;
...@@ -1111,4 +1114,5 @@ void mlx5e_build_nic_params(struct mlx5_core_dev *mdev, ...@@ -1111,4 +1114,5 @@ void mlx5e_build_nic_params(struct mlx5_core_dev *mdev,
u16 max_channels, u16 mtu); u16 max_channels, u16 mtu);
u8 mlx5e_params_calculate_tx_min_inline(struct mlx5_core_dev *mdev); u8 mlx5e_params_calculate_tx_min_inline(struct mlx5_core_dev *mdev);
void mlx5e_rx_dim_work(struct work_struct *work); void mlx5e_rx_dim_work(struct work_struct *work);
void mlx5e_tx_dim_work(struct work_struct *work);
#endif /* __MLX5_EN_H__ */ #endif /* __MLX5_EN_H__ */
...@@ -33,16 +33,30 @@ ...@@ -33,16 +33,30 @@
#include <linux/net_dim.h> #include <linux/net_dim.h>
#include "en.h" #include "en.h"
static void
mlx5e_complete_dim_work(struct net_dim *dim, struct net_dim_cq_moder moder,
struct mlx5_core_dev *mdev, struct mlx5_core_cq *mcq)
{
mlx5_core_modify_cq_moderation(mdev, mcq, moder.usec, moder.pkts);
dim->state = NET_DIM_START_MEASURE;
}
void mlx5e_rx_dim_work(struct work_struct *work) void mlx5e_rx_dim_work(struct work_struct *work)
{ {
struct net_dim *dim = container_of(work, struct net_dim, struct net_dim *dim = container_of(work, struct net_dim, work);
work);
struct mlx5e_rq *rq = container_of(dim, struct mlx5e_rq, dim); struct mlx5e_rq *rq = container_of(dim, struct mlx5e_rq, dim);
struct net_dim_cq_moder cur_profile = net_dim_get_profile(dim->mode, struct net_dim_cq_moder cur_moder =
dim->profile_ix); net_dim_get_rx_moderation(dim->mode, dim->profile_ix);
mlx5_core_modify_cq_moderation(rq->mdev, &rq->cq.mcq, mlx5e_complete_dim_work(dim, cur_moder, rq->mdev, &rq->cq.mcq);
cur_profile.usec, cur_profile.pkts); }
dim->state = NET_DIM_START_MEASURE; void mlx5e_tx_dim_work(struct work_struct *work)
{
struct net_dim *dim = container_of(work, struct net_dim, work);
struct mlx5e_txqsq *sq = container_of(dim, struct mlx5e_txqsq, dim);
struct net_dim_cq_moder cur_moder =
net_dim_get_tx_moderation(dim->mode, dim->profile_ix);
mlx5e_complete_dim_work(dim, cur_moder, sq->cq.mdev, &sq->cq.mcq);
} }
...@@ -389,15 +389,21 @@ static int mlx5e_set_channels(struct net_device *dev, ...@@ -389,15 +389,21 @@ static int mlx5e_set_channels(struct net_device *dev,
int mlx5e_ethtool_get_coalesce(struct mlx5e_priv *priv, int mlx5e_ethtool_get_coalesce(struct mlx5e_priv *priv,
struct ethtool_coalesce *coal) struct ethtool_coalesce *coal)
{ {
struct net_dim_cq_moder *rx_moder, *tx_moder;
if (!MLX5_CAP_GEN(priv->mdev, cq_moderation)) if (!MLX5_CAP_GEN(priv->mdev, cq_moderation))
return -EOPNOTSUPP; return -EOPNOTSUPP;
coal->rx_coalesce_usecs = priv->channels.params.rx_cq_moderation.usec; rx_moder = &priv->channels.params.rx_cq_moderation;
coal->rx_max_coalesced_frames = priv->channels.params.rx_cq_moderation.pkts; coal->rx_coalesce_usecs = rx_moder->usec;
coal->tx_coalesce_usecs = priv->channels.params.tx_cq_moderation.usec; coal->rx_max_coalesced_frames = rx_moder->pkts;
coal->tx_max_coalesced_frames = priv->channels.params.tx_cq_moderation.pkts;
coal->use_adaptive_rx_coalesce = priv->channels.params.rx_dim_enabled; coal->use_adaptive_rx_coalesce = priv->channels.params.rx_dim_enabled;
tx_moder = &priv->channels.params.tx_cq_moderation;
coal->tx_coalesce_usecs = tx_moder->usec;
coal->tx_max_coalesced_frames = tx_moder->pkts;
coal->use_adaptive_tx_coalesce = priv->channels.params.tx_dim_enabled;
return 0; return 0;
} }
...@@ -438,6 +444,7 @@ mlx5e_set_priv_channels_coalesce(struct mlx5e_priv *priv, struct ethtool_coalesc ...@@ -438,6 +444,7 @@ mlx5e_set_priv_channels_coalesce(struct mlx5e_priv *priv, struct ethtool_coalesc
int mlx5e_ethtool_set_coalesce(struct mlx5e_priv *priv, int mlx5e_ethtool_set_coalesce(struct mlx5e_priv *priv,
struct ethtool_coalesce *coal) struct ethtool_coalesce *coal)
{ {
struct net_dim_cq_moder *rx_moder, *tx_moder;
struct mlx5_core_dev *mdev = priv->mdev; struct mlx5_core_dev *mdev = priv->mdev;
struct mlx5e_channels new_channels = {}; struct mlx5e_channels new_channels = {};
int err = 0; int err = 0;
...@@ -463,19 +470,25 @@ int mlx5e_ethtool_set_coalesce(struct mlx5e_priv *priv, ...@@ -463,19 +470,25 @@ int mlx5e_ethtool_set_coalesce(struct mlx5e_priv *priv,
mutex_lock(&priv->state_lock); mutex_lock(&priv->state_lock);
new_channels.params = priv->channels.params; new_channels.params = priv->channels.params;
new_channels.params.tx_cq_moderation.usec = coal->tx_coalesce_usecs; rx_moder = &new_channels.params.rx_cq_moderation;
new_channels.params.tx_cq_moderation.pkts = coal->tx_max_coalesced_frames; rx_moder->usec = coal->rx_coalesce_usecs;
new_channels.params.rx_cq_moderation.usec = coal->rx_coalesce_usecs; rx_moder->pkts = coal->rx_max_coalesced_frames;
new_channels.params.rx_cq_moderation.pkts = coal->rx_max_coalesced_frames;
new_channels.params.rx_dim_enabled = !!coal->use_adaptive_rx_coalesce; new_channels.params.rx_dim_enabled = !!coal->use_adaptive_rx_coalesce;
tx_moder = &new_channels.params.tx_cq_moderation;
tx_moder->usec = coal->tx_coalesce_usecs;
tx_moder->pkts = coal->tx_max_coalesced_frames;
new_channels.params.tx_dim_enabled = !!coal->use_adaptive_tx_coalesce;
if (!test_bit(MLX5E_STATE_OPENED, &priv->state)) { if (!test_bit(MLX5E_STATE_OPENED, &priv->state)) {
priv->channels.params = new_channels.params; priv->channels.params = new_channels.params;
goto out; goto out;
} }
/* we are opened */ /* we are opened */
reset = !!coal->use_adaptive_rx_coalesce != priv->channels.params.rx_dim_enabled; reset = (!!coal->use_adaptive_rx_coalesce != priv->channels.params.rx_dim_enabled) ||
(!!coal->use_adaptive_tx_coalesce != priv->channels.params.tx_dim_enabled);
if (!reset) { if (!reset) {
mlx5e_set_priv_channels_coalesce(priv, coal); mlx5e_set_priv_channels_coalesce(priv, coal);
priv->channels.params = new_channels.params; priv->channels.params = new_channels.params;
......
...@@ -1025,6 +1025,9 @@ static int mlx5e_alloc_txqsq(struct mlx5e_channel *c, ...@@ -1025,6 +1025,9 @@ static int mlx5e_alloc_txqsq(struct mlx5e_channel *c,
if (err) if (err)
goto err_sq_wq_destroy; goto err_sq_wq_destroy;
INIT_WORK(&sq->dim.work, mlx5e_tx_dim_work);
sq->dim.mode = params->tx_cq_moderation.cq_period_mode;
sq->edge = (sq->wq.sz_m1 + 1) - MLX5_SEND_WQE_MAX_WQEBBS; sq->edge = (sq->wq.sz_m1 + 1) - MLX5_SEND_WQE_MAX_WQEBBS;
return 0; return 0;
...@@ -1188,6 +1191,9 @@ static int mlx5e_open_txqsq(struct mlx5e_channel *c, ...@@ -1188,6 +1191,9 @@ static int mlx5e_open_txqsq(struct mlx5e_channel *c,
if (tx_rate) if (tx_rate)
mlx5e_set_sq_maxrate(c->netdev, sq, tx_rate); mlx5e_set_sq_maxrate(c->netdev, sq, tx_rate);
if (params->tx_dim_enabled)
sq->state |= BIT(MLX5E_SQ_STATE_AM);
return 0; return 0;
err_free_txqsq: err_free_txqsq:
...@@ -4084,18 +4090,48 @@ static bool slow_pci_heuristic(struct mlx5_core_dev *mdev) ...@@ -4084,18 +4090,48 @@ static bool slow_pci_heuristic(struct mlx5_core_dev *mdev)
link_speed > MLX5E_SLOW_PCI_RATIO * pci_bw; link_speed > MLX5E_SLOW_PCI_RATIO * pci_bw;
} }
void mlx5e_set_tx_cq_mode_params(struct mlx5e_params *params, u8 cq_period_mode) static struct net_dim_cq_moder mlx5e_get_def_tx_moderation(u8 cq_period_mode)
{ {
params->tx_cq_moderation.cq_period_mode = cq_period_mode; struct net_dim_cq_moder moder;
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)
moder.usec = MLX5E_PARAMS_DEFAULT_TX_CQ_MODERATION_USEC_FROM_CQE;
return moder;
}
params->tx_cq_moderation.pkts = static struct net_dim_cq_moder mlx5e_get_def_rx_moderation(u8 cq_period_mode)
MLX5E_PARAMS_DEFAULT_TX_CQ_MODERATION_PKTS; {
params->tx_cq_moderation.usec = struct net_dim_cq_moder moder;
MLX5E_PARAMS_DEFAULT_TX_CQ_MODERATION_USEC;
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 == MLX5_CQ_PERIOD_MODE_START_FROM_CQE)
params->tx_cq_moderation.usec = moder.usec = MLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_USEC_FROM_CQE;
MLX5E_PARAMS_DEFAULT_TX_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 ?
NET_DIM_CQ_PERIOD_MODE_START_FROM_CQE :
NET_DIM_CQ_PERIOD_MODE_START_FROM_EQE;
}
void mlx5e_set_tx_cq_mode_params(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 {
params->tx_cq_moderation = mlx5e_get_def_tx_moderation(cq_period_mode);
}
MLX5E_SET_PFLAG(params, MLX5E_PFLAG_TX_CQE_BASED_MODER, MLX5E_SET_PFLAG(params, MLX5E_PFLAG_TX_CQE_BASED_MODER,
params->tx_cq_moderation.cq_period_mode == params->tx_cq_moderation.cq_period_mode ==
...@@ -4104,28 +4140,12 @@ void mlx5e_set_tx_cq_mode_params(struct mlx5e_params *params, u8 cq_period_mode) ...@@ -4104,28 +4140,12 @@ 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) void mlx5e_set_rx_cq_mode_params(struct mlx5e_params *params, u8 cq_period_mode)
{ {
params->rx_cq_moderation.cq_period_mode = cq_period_mode;
params->rx_cq_moderation.pkts =
MLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_PKTS;
params->rx_cq_moderation.usec =
MLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_USEC;
if (cq_period_mode == MLX5_CQ_PERIOD_MODE_START_FROM_CQE)
params->rx_cq_moderation.usec =
MLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_USEC_FROM_CQE;
if (params->rx_dim_enabled) { if (params->rx_dim_enabled) {
switch (cq_period_mode) { u8 dim_period_mode = mlx5_to_net_dim_cq_period_mode(cq_period_mode);
case MLX5_CQ_PERIOD_MODE_START_FROM_CQE:
params->rx_cq_moderation = params->rx_cq_moderation = net_dim_get_def_rx_moderation(dim_period_mode);
net_dim_get_def_profile(NET_DIM_CQ_PERIOD_MODE_START_FROM_CQE); } else {
break; params->rx_cq_moderation = mlx5e_get_def_rx_moderation(cq_period_mode);
case MLX5_CQ_PERIOD_MODE_START_FROM_EQE:
default:
params->rx_cq_moderation =
net_dim_get_def_profile(NET_DIM_CQ_PERIOD_MODE_START_FROM_EQE);
}
} }
MLX5E_SET_PFLAG(params, MLX5E_PFLAG_RX_CQE_BASED_MODER, MLX5E_SET_PFLAG(params, MLX5E_PFLAG_RX_CQE_BASED_MODER,
...@@ -4189,6 +4209,7 @@ void mlx5e_build_nic_params(struct mlx5_core_dev *mdev, ...@@ -4189,6 +4209,7 @@ void mlx5e_build_nic_params(struct mlx5_core_dev *mdev,
MLX5_CQ_PERIOD_MODE_START_FROM_CQE : MLX5_CQ_PERIOD_MODE_START_FROM_CQE :
MLX5_CQ_PERIOD_MODE_START_FROM_EQE; MLX5_CQ_PERIOD_MODE_START_FROM_EQE;
params->rx_dim_enabled = MLX5_CAP_GEN(mdev, cq_moderation); 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_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, MLX5_CQ_PERIOD_MODE_START_FROM_EQE);
......
...@@ -44,6 +44,30 @@ static inline bool mlx5e_channel_no_affinity_change(struct mlx5e_channel *c) ...@@ -44,6 +44,30 @@ static inline bool mlx5e_channel_no_affinity_change(struct mlx5e_channel *c)
return cpumask_test_cpu(current_cpu, aff); return cpumask_test_cpu(current_cpu, aff);
} }
static void mlx5e_handle_tx_dim(struct mlx5e_txqsq *sq)
{
struct net_dim_sample dim_sample;
if (unlikely(!MLX5E_TEST_BIT(sq->state, MLX5E_SQ_STATE_AM)))
return;
net_dim_sample(sq->cq.event_ctr, sq->stats.packets, sq->stats.bytes,
&dim_sample);
net_dim(&sq->dim, dim_sample);
}
static void mlx5e_handle_rx_dim(struct mlx5e_rq *rq)
{
struct net_dim_sample dim_sample;
if (unlikely(!MLX5E_TEST_BIT(rq->state, MLX5E_RQ_STATE_AM)))
return;
net_dim_sample(rq->cq.event_ctr, rq->stats.packets, rq->stats.bytes,
&dim_sample);
net_dim(&rq->dim, dim_sample);
}
int mlx5e_napi_poll(struct napi_struct *napi, int budget) int mlx5e_napi_poll(struct napi_struct *napi, int budget)
{ {
struct mlx5e_channel *c = container_of(napi, struct mlx5e_channel, struct mlx5e_channel *c = container_of(napi, struct mlx5e_channel,
...@@ -75,18 +99,13 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget) ...@@ -75,18 +99,13 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget)
if (unlikely(!napi_complete_done(napi, work_done))) if (unlikely(!napi_complete_done(napi, work_done)))
return work_done; return work_done;
for (i = 0; i < c->num_tc; i++) for (i = 0; i < c->num_tc; i++) {
mlx5e_handle_tx_dim(&c->sq[i]);
mlx5e_cq_arm(&c->sq[i].cq); mlx5e_cq_arm(&c->sq[i].cq);
if (MLX5E_TEST_BIT(c->rq.state, MLX5E_RQ_STATE_AM)) {
struct net_dim_sample dim_sample;
net_dim_sample(c->rq.cq.event_ctr,
c->rq.stats.packets,
c->rq.stats.bytes,
&dim_sample);
net_dim(&c->rq.dim, dim_sample);
} }
mlx5e_handle_rx_dim(&c->rq);
mlx5e_cq_arm(&c->rq.cq); mlx5e_cq_arm(&c->rq.cq);
mlx5e_cq_arm(&c->icosq.cq); mlx5e_cq_arm(&c->icosq.cq);
......
...@@ -103,11 +103,12 @@ enum { ...@@ -103,11 +103,12 @@ enum {
#define NET_DIM_PARAMS_NUM_PROFILES 5 #define NET_DIM_PARAMS_NUM_PROFILES 5
/* Adaptive moderation profiles */ /* Adaptive moderation profiles */
#define NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE 256 #define NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE 256
#define NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE 128
#define NET_DIM_DEF_PROFILE_CQE 1 #define NET_DIM_DEF_PROFILE_CQE 1
#define NET_DIM_DEF_PROFILE_EQE 1 #define NET_DIM_DEF_PROFILE_EQE 1
/* All profiles sizes must be NET_PARAMS_DIM_NUM_PROFILES */ /* All profiles sizes must be NET_PARAMS_DIM_NUM_PROFILES */
#define NET_DIM_EQE_PROFILES { \ #define NET_DIM_RX_EQE_PROFILES { \
{1, NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE}, \ {1, NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE}, \
{8, NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE}, \ {8, NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE}, \
{64, NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE}, \ {64, NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE}, \
...@@ -115,7 +116,7 @@ enum { ...@@ -115,7 +116,7 @@ enum {
{256, NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE}, \ {256, NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE}, \
} }
#define NET_DIM_CQE_PROFILES { \ #define NET_DIM_RX_CQE_PROFILES { \
{2, 256}, \ {2, 256}, \
{8, 128}, \ {8, 128}, \
{16, 64}, \ {16, 64}, \
...@@ -123,32 +124,68 @@ enum { ...@@ -123,32 +124,68 @@ enum {
{64, 64} \ {64, 64} \
} }
#define NET_DIM_TX_EQE_PROFILES { \
{1, NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE}, \
{8, NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE}, \
{32, NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE}, \
{64, NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE}, \
{128, NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE} \
}
#define NET_DIM_TX_CQE_PROFILES { \
{5, 128}, \
{8, 64}, \
{16, 32}, \
{32, 32}, \
{64, 32} \
}
static const struct net_dim_cq_moder static const struct net_dim_cq_moder
profile[NET_DIM_CQ_PERIOD_NUM_MODES][NET_DIM_PARAMS_NUM_PROFILES] = { rx_profile[NET_DIM_CQ_PERIOD_NUM_MODES][NET_DIM_PARAMS_NUM_PROFILES] = {
NET_DIM_EQE_PROFILES, NET_DIM_RX_EQE_PROFILES,
NET_DIM_CQE_PROFILES, NET_DIM_RX_CQE_PROFILES,
}; };
static inline struct net_dim_cq_moder net_dim_get_profile(u8 cq_period_mode, static const struct net_dim_cq_moder
int ix) tx_profile[NET_DIM_CQ_PERIOD_NUM_MODES][NET_DIM_PARAMS_NUM_PROFILES] = {
NET_DIM_TX_EQE_PROFILES,
NET_DIM_TX_CQE_PROFILES,
};
static inline struct net_dim_cq_moder
net_dim_get_rx_moderation(u8 cq_period_mode, int ix)
{ {
struct net_dim_cq_moder cq_moder; struct net_dim_cq_moder cq_moder = rx_profile[cq_period_mode][ix];
cq_moder = profile[cq_period_mode][ix];
cq_moder.cq_period_mode = cq_period_mode; cq_moder.cq_period_mode = cq_period_mode;
return cq_moder; return cq_moder;
} }
static inline struct net_dim_cq_moder net_dim_get_def_profile(u8 rx_cq_period_mode) static inline struct net_dim_cq_moder
net_dim_get_def_rx_moderation(u8 cq_period_mode)
{
u8 profile_ix = cq_period_mode == NET_DIM_CQ_PERIOD_MODE_START_FROM_CQE ?
NET_DIM_DEF_PROFILE_CQE : NET_DIM_DEF_PROFILE_EQE;
return net_dim_get_rx_moderation(cq_period_mode, profile_ix);
}
static inline struct net_dim_cq_moder
net_dim_get_tx_moderation(u8 cq_period_mode, int ix)
{ {
int default_profile_ix; struct net_dim_cq_moder cq_moder = tx_profile[cq_period_mode][ix];
cq_moder.cq_period_mode = cq_period_mode;
return cq_moder;
}
if (rx_cq_period_mode == NET_DIM_CQ_PERIOD_MODE_START_FROM_CQE) static inline struct net_dim_cq_moder
default_profile_ix = NET_DIM_DEF_PROFILE_CQE; net_dim_get_def_tx_moderation(u8 cq_period_mode)
else /* NET_DIM_CQ_PERIOD_MODE_START_FROM_EQE */ {
default_profile_ix = NET_DIM_DEF_PROFILE_EQE; u8 profile_ix = cq_period_mode == NET_DIM_CQ_PERIOD_MODE_START_FROM_CQE ?
NET_DIM_DEF_PROFILE_CQE : NET_DIM_DEF_PROFILE_EQE;
return net_dim_get_profile(rx_cq_period_mode, default_profile_ix); return net_dim_get_tx_moderation(cq_period_mode, profile_ix);
} }
static inline bool net_dim_on_top(struct net_dim *dim) static inline bool net_dim_on_top(struct net_dim *dim)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment