Skip to content

Commit

Permalink
Merge tag 'mlx5-updates-2020-02-25' of git://git.kernel.org/pub/scm/l…
Browse files Browse the repository at this point in the history
…inux/kernel/git/saeed/linux

Saeed Mahameed says:

====================
mlx5-updates-2020-02-25

The following series provides some misc updates to mlx5 driver:

1) From Maxim, Refactoring for mlx5e netdev channels recreation flow.
  - Add error handling
  - Add context to the preactivate hook
  - Use preactivate hook with context where it can be used
    and subsequently unify channel recreation flow everywhere.
  - Fix XPS cpumask to not reset upon channel recreation.

2) From Tariq:
  - Use indirect calls wrapper on RX.
  - Check LRO capability bit

3) Multiple small cleanups
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Feb 27, 2020
2 parents 06baf4b + 586ee9e commit 165b94f
Show file tree
Hide file tree
Showing 13 changed files with 216 additions and 128 deletions.
2 changes: 1 addition & 1 deletion Documentation/networking/device_drivers/mellanox/mlx5.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Enabling the driver and kconfig options
**External options** ( Choose if the corresponding mlx5 feature is required )

- CONFIG_PTP_1588_CLOCK: When chosen, mlx5 ptp support will be enabled
- CONFIG_VXLAN: When chosen, mlx5 vxaln support will be enabled.
- CONFIG_VXLAN: When chosen, mlx5 vxlan support will be enabled.
- CONFIG_MLXFW: When chosen, mlx5 firmware flashing support will be enabled (via devlink and ethtool).

Devlink info
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/mellanox/mlx5/core/diag/fw_tracer.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ static int mlx5_fw_tracer_create_mkey(struct mlx5_fw_tracer *tracer)

MLX5_SET(create_mkey_in, in, translations_octword_actual_size,
DIV_ROUND_UP(TRACER_BUFFER_PAGE_NUM, 2));
mtt = (u64 *)MLX5_ADDR_OF(create_mkey_in, in, klm_pas_mtt);
mtt = (__be64 *)MLX5_ADDR_OF(create_mkey_in, in, klm_pas_mtt);
for (i = 0 ; i < TRACER_BUFFER_PAGE_NUM ; i++)
mtt[i] = cpu_to_be64(tracer->buff.dma + i * PAGE_SIZE);

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/mellanox/mlx5/core/diag/rsc_dump.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* Copyright (c) 2019 Mellanox Technologies. */

#ifndef __MLX5_RSC_DUMP_H
#define __MLX5_RSC_DUMP__H
#define __MLX5_RSC_DUMP_H

#include <linux/mlx5/driver.h>
#include "mlx5_core.h"
Expand Down
29 changes: 23 additions & 6 deletions drivers/net/ethernet/mellanox/mlx5/core/en.h
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,6 @@ struct mlx5e_channel {
DECLARE_BITMAP(state, MLX5E_CHANNEL_NUM_STATES);
int ix;
int cpu;
cpumask_var_t xps_cpumask;
};

struct mlx5e_channels {
Expand Down Expand Up @@ -813,6 +812,15 @@ struct mlx5e_xsk {
bool ever_used;
};

/* Temporary storage for variables that are allocated when struct mlx5e_priv is
* initialized, and used where we can't allocate them because that functions
* must not fail. Use with care and make sure the same variable is not used
* simultaneously by multiple users.
*/
struct mlx5e_scratchpad {
cpumask_var_t cpumask;
};

struct mlx5e_priv {
/* priv data path fields - start */
struct mlx5e_txqsq *txq2sq[MLX5E_MAX_NUM_CHANNELS * MLX5E_MAX_NUM_TC];
Expand Down Expand Up @@ -876,6 +884,7 @@ struct mlx5e_priv {
#if IS_ENABLED(CONFIG_PCI_HYPERV_INTERFACE)
struct mlx5e_hv_vhca_stats_agent stats_agent;
#endif
struct mlx5e_scratchpad scratchpad;
};

struct mlx5e_profile {
Expand Down Expand Up @@ -1035,14 +1044,22 @@ int mlx5e_open_channels(struct mlx5e_priv *priv,
struct mlx5e_channels *chs);
void mlx5e_close_channels(struct mlx5e_channels *chs);

/* Function pointer to be used to modify WH settings while
/* Function pointer to be used to modify HW or kernel settings while
* switching channels
*/
typedef int (*mlx5e_fp_hw_modify)(struct mlx5e_priv *priv);
typedef int (*mlx5e_fp_preactivate)(struct mlx5e_priv *priv, void *context);
#define MLX5E_DEFINE_PREACTIVATE_WRAPPER_CTX(fn) \
int fn##_ctx(struct mlx5e_priv *priv, void *context) \
{ \
return fn(priv); \
}
int mlx5e_safe_reopen_channels(struct mlx5e_priv *priv);
int mlx5e_safe_switch_channels(struct mlx5e_priv *priv,
struct mlx5e_channels *new_chs,
mlx5e_fp_hw_modify hw_modify);
mlx5e_fp_preactivate preactivate,
void *context);
int mlx5e_num_channels_changed(struct mlx5e_priv *priv);
int mlx5e_num_channels_changed_ctx(struct mlx5e_priv *priv, void *context);
void mlx5e_activate_priv_channels(struct mlx5e_priv *priv);
void mlx5e_deactivate_priv_channels(struct mlx5e_priv *priv);

Expand Down Expand Up @@ -1122,10 +1139,10 @@ void mlx5e_update_ndo_stats(struct mlx5e_priv *priv);
void mlx5e_queue_update_stats(struct mlx5e_priv *priv);
int mlx5e_bits_invert(unsigned long a, int size);

typedef int (*change_hw_mtu_cb)(struct mlx5e_priv *priv);
int mlx5e_set_dev_port_mtu(struct mlx5e_priv *priv);
int mlx5e_set_dev_port_mtu_ctx(struct mlx5e_priv *priv, void *context);
int mlx5e_change_mtu(struct net_device *netdev, int new_mtu,
change_hw_mtu_cb set_mtu_cb);
mlx5e_fp_preactivate preactivate);

/* ethtool helpers */
void mlx5e_ethtool_get_drvinfo(struct mlx5e_priv *priv,
Expand Down
55 changes: 33 additions & 22 deletions drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1098,49 +1098,59 @@ void mlx5e_dcbnl_delete_app(struct mlx5e_priv *priv)
mlx5e_dcbnl_dscp_app(priv, DELETE);
}

static void mlx5e_trust_update_tx_min_inline_mode(struct mlx5e_priv *priv,
struct mlx5e_params *params)
static void mlx5e_params_calc_trust_tx_min_inline_mode(struct mlx5_core_dev *mdev,
struct mlx5e_params *params,
u8 trust_state)
{
mlx5_query_min_inline(priv->mdev, &params->tx_min_inline_mode);
if (priv->dcbx_dp.trust_state == MLX5_QPTS_TRUST_DSCP &&
mlx5_query_min_inline(mdev, &params->tx_min_inline_mode);
if (trust_state == MLX5_QPTS_TRUST_DSCP &&
params->tx_min_inline_mode == MLX5_INLINE_MODE_L2)
params->tx_min_inline_mode = MLX5_INLINE_MODE_IP;
}

static void mlx5e_trust_update_sq_inline_mode(struct mlx5e_priv *priv)
static int mlx5e_update_trust_state_hw(struct mlx5e_priv *priv, void *context)
{
u8 *trust_state = context;
int err;

err = mlx5_set_trust_state(priv->mdev, *trust_state);
if (err)
return err;
priv->dcbx_dp.trust_state = *trust_state;

return 0;
}

static int mlx5e_set_trust_state(struct mlx5e_priv *priv, u8 trust_state)
{
struct mlx5e_channels new_channels = {};
bool reset_channels = true;
int err = 0;

mutex_lock(&priv->state_lock);

new_channels.params = priv->channels.params;
mlx5e_trust_update_tx_min_inline_mode(priv, &new_channels.params);
mlx5e_params_calc_trust_tx_min_inline_mode(priv->mdev, &new_channels.params,
trust_state);

if (!test_bit(MLX5E_STATE_OPENED, &priv->state)) {
priv->channels.params = new_channels.params;
goto out;
reset_channels = false;
}

/* Skip if tx_min_inline is the same */
if (new_channels.params.tx_min_inline_mode ==
priv->channels.params.tx_min_inline_mode)
goto out;
reset_channels = false;

mlx5e_safe_switch_channels(priv, &new_channels, NULL);
if (reset_channels)
err = mlx5e_safe_switch_channels(priv, &new_channels,
mlx5e_update_trust_state_hw,
&trust_state);
else
err = mlx5e_update_trust_state_hw(priv, &trust_state);

out:
mutex_unlock(&priv->state_lock);
}

static int mlx5e_set_trust_state(struct mlx5e_priv *priv, u8 trust_state)
{
int err;

err = mlx5_set_trust_state(priv->mdev, trust_state);
if (err)
return err;
priv->dcbx_dp.trust_state = trust_state;
mlx5e_trust_update_sq_inline_mode(priv);

return err;
}
Expand Down Expand Up @@ -1171,7 +1181,8 @@ static int mlx5e_trust_initialize(struct mlx5e_priv *priv)
if (err)
return err;

mlx5e_trust_update_tx_min_inline_mode(priv, &priv->channels.params);
mlx5e_params_calc_trust_tx_min_inline_mode(priv->mdev, &priv->channels.params,
priv->dcbx_dp.trust_state);

err = mlx5_query_dscp2prio(priv->mdev, priv->dcbx_dp.dscp2prio);
if (err)
Expand Down
23 changes: 9 additions & 14 deletions drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ int mlx5e_ethtool_set_ringparam(struct mlx5e_priv *priv,
goto unlock;
}

err = mlx5e_safe_switch_channels(priv, &new_channels, NULL);
err = mlx5e_safe_switch_channels(priv, &new_channels, NULL, NULL);

unlock:
mutex_unlock(&priv->state_lock);
Expand Down Expand Up @@ -432,22 +432,17 @@ int mlx5e_ethtool_set_channels(struct mlx5e_priv *priv,

if (!test_bit(MLX5E_STATE_OPENED, &priv->state)) {
*cur_params = new_channels.params;
if (!netif_is_rxfh_configured(priv->netdev))
mlx5e_build_default_indir_rqt(priv->rss_params.indirection_rqt,
MLX5E_INDIR_RQT_SIZE, count);
mlx5e_num_channels_changed(priv);
goto out;
}

arfs_enabled = priv->netdev->features & NETIF_F_NTUPLE;
if (arfs_enabled)
mlx5e_arfs_disable(priv);

if (!netif_is_rxfh_configured(priv->netdev))
mlx5e_build_default_indir_rqt(priv->rss_params.indirection_rqt,
MLX5E_INDIR_RQT_SIZE, count);

/* Switch to new channels, set new parameters and close old ones */
err = mlx5e_safe_switch_channels(priv, &new_channels, NULL);
err = mlx5e_safe_switch_channels(priv, &new_channels,
mlx5e_num_channels_changed_ctx, NULL);

if (arfs_enabled) {
int err2 = mlx5e_arfs_enable(priv);
Expand Down Expand Up @@ -580,7 +575,7 @@ int mlx5e_ethtool_set_coalesce(struct mlx5e_priv *priv,
goto out;
}

err = mlx5e_safe_switch_channels(priv, &new_channels, NULL);
err = mlx5e_safe_switch_channels(priv, &new_channels, NULL, NULL);

out:
mutex_unlock(&priv->state_lock);
Expand Down Expand Up @@ -1748,7 +1743,7 @@ static int set_pflag_cqe_based_moder(struct net_device *netdev, bool enable,
return 0;
}

return mlx5e_safe_switch_channels(priv, &new_channels, NULL);
return mlx5e_safe_switch_channels(priv, &new_channels, NULL, NULL);
}

static int set_pflag_tx_cqe_based_moder(struct net_device *netdev, bool enable)
Expand Down Expand Up @@ -1781,7 +1776,7 @@ int mlx5e_modify_rx_cqe_compression_locked(struct mlx5e_priv *priv, bool new_val
return 0;
}

err = mlx5e_safe_switch_channels(priv, &new_channels, NULL);
err = mlx5e_safe_switch_channels(priv, &new_channels, NULL, NULL);
if (err)
return err;

Expand Down Expand Up @@ -1838,7 +1833,7 @@ static int set_pflag_rx_striding_rq(struct net_device *netdev, bool enable)
return 0;
}

return mlx5e_safe_switch_channels(priv, &new_channels, NULL);
return mlx5e_safe_switch_channels(priv, &new_channels, NULL, NULL);
}

static int set_pflag_rx_no_csum_complete(struct net_device *netdev, bool enable)
Expand Down Expand Up @@ -1882,7 +1877,7 @@ static int set_pflag_xdp_tx_mpwqe(struct net_device *netdev, bool enable)
return 0;
}

err = mlx5e_safe_switch_channels(priv, &new_channels, NULL);
err = mlx5e_safe_switch_channels(priv, &new_channels, NULL, NULL);
return err;
}

Expand Down
Loading

0 comments on commit 165b94f

Please sign in to comment.