Add support for modifying coalescing parameters runtime.
MFC after: 1 week Sponsored by: Mellanox Technologies
This commit is contained in:
parent
4fbd91a5af
commit
f03f517b5e
@ -787,5 +787,6 @@ void mlx5e_create_stats(struct sysctl_ctx_list *,
|
||||
struct sysctl_oid_list *, const char *,
|
||||
const char **, unsigned, u64 *);
|
||||
void mlx5e_send_nop(struct mlx5e_sq *, u32, bool);
|
||||
int mlx5e_refresh_channel_params(struct mlx5e_priv *);
|
||||
|
||||
#endif /* _MLX5_EN_H_ */
|
||||
|
@ -69,12 +69,49 @@ mlx5e_ethtool_handler(SYSCTL_HANDLER_ARGS)
|
||||
} else {
|
||||
error = 0;
|
||||
}
|
||||
|
||||
/* check if device is gone */
|
||||
if (priv->gone) {
|
||||
error = ENXIO;
|
||||
goto done;
|
||||
}
|
||||
/* import RX coal time */
|
||||
if (priv->params_ethtool.rx_coalesce_usecs < 1)
|
||||
priv->params_ethtool.rx_coalesce_usecs = 0;
|
||||
else if (priv->params_ethtool.rx_coalesce_usecs >
|
||||
MLX5E_FLD_MAX(cqc, cq_period)) {
|
||||
priv->params_ethtool.rx_coalesce_usecs =
|
||||
MLX5E_FLD_MAX(cqc, cq_period);
|
||||
}
|
||||
priv->params.rx_cq_moderation_usec = priv->params_ethtool.rx_coalesce_usecs;
|
||||
|
||||
/* import RX coal pkts */
|
||||
if (priv->params_ethtool.rx_coalesce_pkts < 1)
|
||||
priv->params_ethtool.rx_coalesce_pkts = 0;
|
||||
else if (priv->params_ethtool.rx_coalesce_pkts >
|
||||
MLX5E_FLD_MAX(cqc, cq_max_count)) {
|
||||
priv->params_ethtool.rx_coalesce_pkts =
|
||||
MLX5E_FLD_MAX(cqc, cq_max_count);
|
||||
}
|
||||
priv->params.rx_cq_moderation_pkts = priv->params_ethtool.rx_coalesce_pkts;
|
||||
|
||||
/* import TX coal time */
|
||||
if (priv->params_ethtool.tx_coalesce_usecs < 1)
|
||||
priv->params_ethtool.tx_coalesce_usecs = 0;
|
||||
else if (priv->params_ethtool.tx_coalesce_usecs >
|
||||
MLX5E_FLD_MAX(cqc, cq_period)) {
|
||||
priv->params_ethtool.tx_coalesce_usecs =
|
||||
MLX5E_FLD_MAX(cqc, cq_period);
|
||||
}
|
||||
priv->params.tx_cq_moderation_usec = priv->params_ethtool.tx_coalesce_usecs;
|
||||
|
||||
/* import TX coal pkts */
|
||||
if (priv->params_ethtool.tx_coalesce_pkts < 1)
|
||||
priv->params_ethtool.tx_coalesce_pkts = 0;
|
||||
else if (priv->params_ethtool.tx_coalesce_pkts >
|
||||
MLX5E_FLD_MAX(cqc, cq_max_count)) {
|
||||
priv->params_ethtool.tx_coalesce_pkts = MLX5E_FLD_MAX(cqc, cq_max_count);
|
||||
}
|
||||
priv->params.tx_cq_moderation_pkts = priv->params_ethtool.tx_coalesce_pkts;
|
||||
|
||||
if (&priv->params_ethtool.arg[arg2] == &priv->params_ethtool.rx_pauseframe_control ||
|
||||
&priv->params_ethtool.arg[arg2] == &priv->params_ethtool.tx_pauseframe_control) {
|
||||
@ -92,9 +129,19 @@ mlx5e_ethtool_handler(SYSCTL_HANDLER_ARGS)
|
||||
}
|
||||
|
||||
was_opened = test_bit(MLX5E_STATE_OPENED, &priv->state);
|
||||
if (was_opened)
|
||||
mlx5e_close_locked(priv->ifp);
|
||||
if (was_opened) {
|
||||
u64 *xarg = priv->params_ethtool.arg + arg2;
|
||||
|
||||
if (xarg == &priv->params_ethtool.tx_coalesce_pkts ||
|
||||
xarg == &priv->params_ethtool.rx_coalesce_pkts ||
|
||||
xarg == &priv->params_ethtool.tx_coalesce_usecs ||
|
||||
xarg == &priv->params_ethtool.rx_coalesce_usecs) {
|
||||
/* avoid downing and upping the network interface */
|
||||
error = mlx5e_refresh_channel_params(priv);
|
||||
goto done;
|
||||
}
|
||||
mlx5e_close_locked(priv->ifp);
|
||||
}
|
||||
/* import TX queue size */
|
||||
if (priv->params_ethtool.tx_queue_size <
|
||||
(1 << MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE)) {
|
||||
@ -145,45 +192,6 @@ mlx5e_ethtool_handler(SYSCTL_HANDLER_ARGS)
|
||||
priv->params_ethtool.tx_coalesce_mode = 1;
|
||||
priv->params.tx_cq_moderation_mode = priv->params_ethtool.tx_coalesce_mode;
|
||||
|
||||
/* import RX coal time */
|
||||
if (priv->params_ethtool.rx_coalesce_usecs < 1)
|
||||
priv->params_ethtool.rx_coalesce_usecs = 0;
|
||||
else if (priv->params_ethtool.rx_coalesce_usecs >
|
||||
MLX5E_FLD_MAX(cqc, cq_period)) {
|
||||
priv->params_ethtool.rx_coalesce_usecs =
|
||||
MLX5E_FLD_MAX(cqc, cq_period);
|
||||
}
|
||||
priv->params.rx_cq_moderation_usec = priv->params_ethtool.rx_coalesce_usecs;
|
||||
|
||||
/* import RX coal pkts */
|
||||
if (priv->params_ethtool.rx_coalesce_pkts < 1)
|
||||
priv->params_ethtool.rx_coalesce_pkts = 0;
|
||||
else if (priv->params_ethtool.rx_coalesce_pkts >
|
||||
MLX5E_FLD_MAX(cqc, cq_max_count)) {
|
||||
priv->params_ethtool.rx_coalesce_pkts =
|
||||
MLX5E_FLD_MAX(cqc, cq_max_count);
|
||||
}
|
||||
priv->params.rx_cq_moderation_pkts = priv->params_ethtool.rx_coalesce_pkts;
|
||||
|
||||
/* import TX coal time */
|
||||
if (priv->params_ethtool.tx_coalesce_usecs < 1)
|
||||
priv->params_ethtool.tx_coalesce_usecs = 0;
|
||||
else if (priv->params_ethtool.tx_coalesce_usecs >
|
||||
MLX5E_FLD_MAX(cqc, cq_period)) {
|
||||
priv->params_ethtool.tx_coalesce_usecs =
|
||||
MLX5E_FLD_MAX(cqc, cq_period);
|
||||
}
|
||||
priv->params.tx_cq_moderation_usec = priv->params_ethtool.tx_coalesce_usecs;
|
||||
|
||||
/* import TX coal pkts */
|
||||
if (priv->params_ethtool.tx_coalesce_pkts < 1)
|
||||
priv->params_ethtool.tx_coalesce_pkts = 0;
|
||||
else if (priv->params_ethtool.tx_coalesce_pkts >
|
||||
MLX5E_FLD_MAX(cqc, cq_max_count)) {
|
||||
priv->params_ethtool.tx_coalesce_pkts = MLX5E_FLD_MAX(cqc, cq_max_count);
|
||||
}
|
||||
priv->params.tx_cq_moderation_pkts = priv->params_ethtool.tx_coalesce_pkts;
|
||||
|
||||
/* we always agree to turn off HW LRO - but not always to turn on */
|
||||
if (priv->params_ethtool.hw_lro) {
|
||||
if (priv->params_ethtool.hw_lro != 1) {
|
||||
|
@ -1711,6 +1711,62 @@ mlx5e_close_channels(struct mlx5e_priv *priv)
|
||||
free(ptr, M_MLX5EN);
|
||||
}
|
||||
|
||||
static int
|
||||
mlx5e_refresh_sq_params(struct mlx5e_priv *priv, struct mlx5e_sq *sq)
|
||||
{
|
||||
return (mlx5_core_modify_cq_moderation(priv->mdev, &sq->cq.mcq,
|
||||
priv->params.tx_cq_moderation_usec,
|
||||
priv->params.tx_cq_moderation_pkts));
|
||||
}
|
||||
|
||||
static int
|
||||
mlx5e_refresh_rq_params(struct mlx5e_priv *priv, struct mlx5e_rq *rq)
|
||||
{
|
||||
return (mlx5_core_modify_cq_moderation(priv->mdev, &rq->cq.mcq,
|
||||
priv->params.rx_cq_moderation_usec,
|
||||
priv->params.rx_cq_moderation_pkts));
|
||||
}
|
||||
|
||||
static int
|
||||
mlx5e_refresh_channel_params_sub(struct mlx5e_priv *priv, struct mlx5e_channel *c)
|
||||
{
|
||||
int err;
|
||||
int i;
|
||||
|
||||
if (c == NULL)
|
||||
return (EINVAL);
|
||||
|
||||
err = mlx5e_refresh_rq_params(priv, &c->rq);
|
||||
if (err)
|
||||
goto done;
|
||||
|
||||
for (i = 0; i != c->num_tc; i++) {
|
||||
err = mlx5e_refresh_sq_params(priv, &c->sq[i]);
|
||||
if (err)
|
||||
goto done;
|
||||
}
|
||||
done:
|
||||
return (err);
|
||||
}
|
||||
|
||||
int
|
||||
mlx5e_refresh_channel_params(struct mlx5e_priv *priv)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (priv->channel == NULL)
|
||||
return (EINVAL);
|
||||
|
||||
for (i = 0; i < priv->params.num_channels; i++) {
|
||||
int err;
|
||||
|
||||
err = mlx5e_refresh_channel_params_sub(priv, priv->channel[i]);
|
||||
if (err)
|
||||
return (err);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
mlx5e_open_tis(struct mlx5e_priv *priv, int tc)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user