Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

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
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -654,7 +654,7 @@ static int bcm_sysport_set_coalesce(struct net_device *dev,
	pkts = priv->rx_max_coalesced_frames;

	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;
		pkts = moder.pkts;
	}
@@ -1064,7 +1064,7 @@ static void bcm_sysport_dim_work(struct work_struct *work)
	struct bcm_sysport_priv *priv =
			container_of(ndim, struct bcm_sysport_priv, dim);
	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);
	dim->state = NET_DIM_START_MEASURE;
@@ -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->use_dim) {
		moder = net_dim_get_def_profile(dim->dim.mode);
		moder = net_dim_get_def_rx_moderation(dim->dim.mode);
		usecs = moder.usec;
		pkts = moder.pkts;
	}
+4 −4
Original line number Diff line number Diff line
@@ -21,11 +21,11 @@ void bnxt_dim_work(struct work_struct *work)
	struct bnxt_napi *bnapi = container_of(cpr,
					       struct bnxt_napi,
					       cp_ring);
	struct net_dim_cq_moder cur_profile = net_dim_get_profile(dim->mode,
								  dim->profile_ix);
	struct net_dim_cq_moder cur_moder =
		net_dim_get_rx_moderation(dim->mode, dim->profile_ix);

	cpr->rx_ring_coal.coal_ticks = cur_profile.usec;
	cpr->rx_ring_coal.coal_bufs = cur_profile.pkts;
	cpr->rx_ring_coal.coal_ticks = cur_moder.usec;
	cpr->rx_ring_coal.coal_bufs = cur_moder.pkts;

	bnxt_hwrm_set_ring_coal(bnapi->bp, bnapi);
	dim->state = NET_DIM_START_MEASURE;
+3 −3
Original line number Diff line number Diff line
@@ -652,7 +652,7 @@ static void bcmgenet_set_ring_rx_coalesce(struct bcmgenet_rx_ring *ring,
	pkts = ring->rx_max_coalesced_frames;

	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;
		pkts = moder.pkts;
	}
@@ -1925,7 +1925,7 @@ static void bcmgenet_dim_work(struct work_struct *work)
	struct bcmgenet_rx_ring *ring =
			container_of(ndim, struct bcmgenet_rx_ring, dim);
	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);
	dim->state = NET_DIM_START_MEASURE;
@@ -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->use_dim) {
		moder = net_dim_get_def_profile(dim->dim.mode);
		moder = net_dim_get_def_rx_moderation(dim->dim.mode);
		usecs = moder.usec;
		pkts = moder.pkts;
	}
+4 −0
Original line number Diff line number Diff line
@@ -241,6 +241,7 @@ struct mlx5e_params {
	bool vlan_strip_disable;
	bool scatter_fcs_en;
	bool rx_dim_enabled;
	bool tx_dim_enabled;
	u32 lro_timeout;
	u32 pflags;
	struct bpf_prog *xdp_prog;
@@ -330,6 +331,7 @@ enum {
	MLX5E_SQ_STATE_ENABLED,
	MLX5E_SQ_STATE_RECOVERING,
	MLX5E_SQ_STATE_IPSEC,
	MLX5E_SQ_STATE_AM,
};

struct mlx5e_sq_wqe_info {
@@ -342,6 +344,7 @@ struct mlx5e_txqsq {
	/* dirtied @completion */
	u16                        cc;
	u32                        dma_fifo_cc;
	struct net_dim             dim; /* Adaptive Moderation */

	/* dirtied @xmit */
	u16                        pc ____cacheline_aligned_in_smp;
@@ -1111,4 +1114,5 @@ void mlx5e_build_nic_params(struct mlx5_core_dev *mdev,
			    u16 max_channels, u16 mtu);
u8 mlx5e_params_calculate_tx_min_inline(struct mlx5_core_dev *mdev);
void mlx5e_rx_dim_work(struct work_struct *work);
void mlx5e_tx_dim_work(struct work_struct *work);
#endif /* __MLX5_EN_H__ */
+21 −7
Original line number Diff line number Diff line
@@ -33,16 +33,30 @@
#include <linux/net_dim.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)
{
	struct net_dim *dim = container_of(work, struct net_dim,
					   work);
	struct net_dim *dim = container_of(work, struct net_dim, work);
	struct mlx5e_rq *rq = container_of(dim, struct mlx5e_rq, dim);
	struct net_dim_cq_moder cur_profile = net_dim_get_profile(dim->mode,
								  dim->profile_ix);
	struct net_dim_cq_moder cur_moder =
		net_dim_get_rx_moderation(dim->mode, dim->profile_ix);

	mlx5_core_modify_cq_moderation(rq->mdev, &rq->cq.mcq,
				       cur_profile.usec, cur_profile.pkts);
	mlx5e_complete_dim_work(dim, cur_moder, rq->mdev, &rq->cq.mcq);
}

	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);
}
Loading