Skip to content

Commit d20e391

Browse files
committed
Merge branch 'mlx5-misc-patches'
Tariq Toukan says: ==================== mlx5 misc patches This series includes patches for the mlx5 driver. Patch 1 by Shay enables LAG with HCAs of 8 ports. Patch 2 by Carolina optimizes the safe switch channels operation for the TX-only changes. Patch 3 by Parav cleans up some unused code. ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents eafbf05 + db5944e commit d20e391

File tree

6 files changed

+48
-114
lines changed

6 files changed

+48
-114
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,6 +1102,7 @@ int mlx5e_safe_switch_params(struct mlx5e_priv *priv,
11021102
void *context, bool reset);
11031103
int mlx5e_update_tx_netdev_queues(struct mlx5e_priv *priv);
11041104
int mlx5e_num_channels_changed_ctx(struct mlx5e_priv *priv, void *context);
1105+
int mlx5e_update_tc_and_tx_queues_ctx(struct mlx5e_priv *priv, void *context);
11051106
void mlx5e_activate_priv_channels(struct mlx5e_priv *priv);
11061107
void mlx5e_deactivate_priv_channels(struct mlx5e_priv *priv);
11071108
int mlx5e_ptp_rx_manage_fs_ctx(struct mlx5e_priv *priv, void *ctx);

drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2292,7 +2292,7 @@ static int set_pflag_tx_port_ts(struct net_device *netdev, bool enable)
22922292
*/
22932293

22942294
err = mlx5e_safe_switch_params(priv, &new_params,
2295-
mlx5e_num_channels_changed_ctx, NULL, true);
2295+
mlx5e_update_tc_and_tx_queues_ctx, NULL, true);
22962296
if (!err)
22972297
priv->tx_ptp_opened = true;
22982298

drivers/net/ethernet/mellanox/mlx5/core/en_main.c

Lines changed: 45 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -3002,7 +3002,28 @@ int mlx5e_update_tx_netdev_queues(struct mlx5e_priv *priv)
30023002
return err;
30033003
}
30043004

3005-
static int mlx5e_update_netdev_queues(struct mlx5e_priv *priv)
3005+
static void mlx5e_set_default_xps_cpumasks(struct mlx5e_priv *priv,
3006+
struct mlx5e_params *params)
3007+
{
3008+
struct mlx5_core_dev *mdev = priv->mdev;
3009+
int num_comp_vectors, ix, irq;
3010+
3011+
num_comp_vectors = mlx5_comp_vectors_max(mdev);
3012+
3013+
for (ix = 0; ix < params->num_channels; ix++) {
3014+
cpumask_clear(priv->scratchpad.cpumask);
3015+
3016+
for (irq = ix; irq < num_comp_vectors; irq += params->num_channels) {
3017+
int cpu = mlx5_comp_vector_get_cpu(mdev, irq);
3018+
3019+
cpumask_set_cpu(cpu, priv->scratchpad.cpumask);
3020+
}
3021+
3022+
netif_set_xps_queue(priv->netdev, priv->scratchpad.cpumask, ix);
3023+
}
3024+
}
3025+
3026+
static int mlx5e_update_tc_and_tx_queues(struct mlx5e_priv *priv)
30063027
{
30073028
struct netdev_tc_txq old_tc_to_txq[TC_MAX_QUEUE], *tc_to_txq;
30083029
struct net_device *netdev = priv->netdev;
@@ -3026,65 +3047,43 @@ static int mlx5e_update_netdev_queues(struct mlx5e_priv *priv)
30263047
err = mlx5e_update_tx_netdev_queues(priv);
30273048
if (err)
30283049
goto err_tcs;
3029-
err = netif_set_real_num_rx_queues(netdev, nch);
3030-
if (err) {
3031-
netdev_warn(netdev, "netif_set_real_num_rx_queues failed, %d\n", err);
3032-
goto err_txqs;
3033-
}
3050+
mlx5e_set_default_xps_cpumasks(priv, &priv->channels.params);
30343051

30353052
return 0;
30363053

3037-
err_txqs:
3038-
/* netif_set_real_num_rx_queues could fail only when nch increased. Only
3039-
* one of nch and ntc is changed in this function. That means, the call
3040-
* to netif_set_real_num_tx_queues below should not fail, because it
3041-
* decreases the number of TX queues.
3042-
*/
3043-
WARN_ON_ONCE(netif_set_real_num_tx_queues(netdev, old_num_txqs));
3044-
30453054
err_tcs:
30463055
WARN_ON_ONCE(mlx5e_netdev_set_tcs(netdev, old_num_txqs / old_ntc, old_ntc,
30473056
old_tc_to_txq));
30483057
err_out:
30493058
return err;
30503059
}
30513060

3052-
static MLX5E_DEFINE_PREACTIVATE_WRAPPER_CTX(mlx5e_update_netdev_queues);
3053-
3054-
static void mlx5e_set_default_xps_cpumasks(struct mlx5e_priv *priv,
3055-
struct mlx5e_params *params)
3056-
{
3057-
int ix;
3058-
3059-
for (ix = 0; ix < params->num_channels; ix++) {
3060-
int num_comp_vectors, irq, vec_ix;
3061-
struct mlx5_core_dev *mdev;
3062-
3063-
mdev = mlx5_sd_ch_ix_get_dev(priv->mdev, ix);
3064-
num_comp_vectors = mlx5_comp_vectors_max(mdev);
3065-
cpumask_clear(priv->scratchpad.cpumask);
3066-
vec_ix = mlx5_sd_ch_ix_get_vec_ix(mdev, ix);
3067-
3068-
for (irq = vec_ix; irq < num_comp_vectors; irq += params->num_channels) {
3069-
int cpu = mlx5_comp_vector_get_cpu(mdev, irq);
3070-
3071-
cpumask_set_cpu(cpu, priv->scratchpad.cpumask);
3072-
}
3073-
3074-
netif_set_xps_queue(priv->netdev, priv->scratchpad.cpumask, ix);
3075-
}
3076-
}
3061+
MLX5E_DEFINE_PREACTIVATE_WRAPPER_CTX(mlx5e_update_tc_and_tx_queues);
30773062

30783063
static int mlx5e_num_channels_changed(struct mlx5e_priv *priv)
30793064
{
30803065
u16 count = priv->channels.params.num_channels;
3066+
struct net_device *netdev = priv->netdev;
3067+
int old_num_rxqs;
30813068
int err;
30823069

3083-
err = mlx5e_update_netdev_queues(priv);
3084-
if (err)
3070+
old_num_rxqs = netdev->real_num_rx_queues;
3071+
err = netif_set_real_num_rx_queues(netdev, count);
3072+
if (err) {
3073+
netdev_warn(netdev, "%s: netif_set_real_num_rx_queues failed, %d\n",
3074+
__func__, err);
30853075
return err;
3086-
3087-
mlx5e_set_default_xps_cpumasks(priv, &priv->channels.params);
3076+
}
3077+
err = mlx5e_update_tc_and_tx_queues(priv);
3078+
if (err) {
3079+
/* mlx5e_update_tc_and_tx_queues can fail if channels or TCs number increases.
3080+
* Since channel number changed, it increased. That means, the call to
3081+
* netif_set_real_num_rx_queues below should not fail, because it
3082+
* decreases the number of RX queues.
3083+
*/
3084+
WARN_ON_ONCE(netif_set_real_num_rx_queues(netdev, old_num_rxqs));
3085+
return err;
3086+
}
30883087

30893088
/* This function may be called on attach, before priv->rx_res is created. */
30903089
if (priv->rx_res) {
@@ -3617,7 +3616,7 @@ static int mlx5e_setup_tc_mqprio_dcb(struct mlx5e_priv *priv,
36173616
mlx5e_params_mqprio_dcb_set(&new_params, tc ? tc : 1);
36183617

36193618
err = mlx5e_safe_switch_params(priv, &new_params,
3620-
mlx5e_num_channels_changed_ctx, NULL, true);
3619+
mlx5e_update_tc_and_tx_queues_ctx, NULL, true);
36213620

36223621
if (!err && priv->mqprio_rl) {
36233622
mlx5e_mqprio_rl_cleanup(priv->mqprio_rl);
@@ -3718,10 +3717,8 @@ static struct mlx5e_mqprio_rl *mlx5e_mqprio_rl_create(struct mlx5_core_dev *mdev
37183717
static int mlx5e_setup_tc_mqprio_channel(struct mlx5e_priv *priv,
37193718
struct tc_mqprio_qopt_offload *mqprio)
37203719
{
3721-
mlx5e_fp_preactivate preactivate;
37223720
struct mlx5e_params new_params;
37233721
struct mlx5e_mqprio_rl *rl;
3724-
bool nch_changed;
37253722
int err;
37263723

37273724
err = mlx5e_mqprio_channel_validate(priv, mqprio);
@@ -3735,10 +3732,8 @@ static int mlx5e_setup_tc_mqprio_channel(struct mlx5e_priv *priv,
37353732
new_params = priv->channels.params;
37363733
mlx5e_params_mqprio_channel_set(&new_params, mqprio, rl);
37373734

3738-
nch_changed = mlx5e_get_dcb_num_tc(&priv->channels.params) > 1;
3739-
preactivate = nch_changed ? mlx5e_num_channels_changed_ctx :
3740-
mlx5e_update_netdev_queues_ctx;
3741-
err = mlx5e_safe_switch_params(priv, &new_params, preactivate, NULL, true);
3735+
err = mlx5e_safe_switch_params(priv, &new_params,
3736+
mlx5e_update_tc_and_tx_queues_ctx, NULL, true);
37423737
if (err) {
37433738
if (rl) {
37443739
mlx5e_mqprio_rl_cleanup(rl);

drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,6 @@ int mlx5_deactivate_lag(struct mlx5_lag *ldev)
713713
return 0;
714714
}
715715

716-
#define MLX5_LAG_OFFLOADS_SUPPORTED_PORTS 4
717716
bool mlx5_lag_check_prereq(struct mlx5_lag *ldev)
718717
{
719718
#ifdef CONFIG_MLX5_ESWITCH
@@ -739,8 +738,6 @@ bool mlx5_lag_check_prereq(struct mlx5_lag *ldev)
739738
if (mlx5_eswitch_mode(ldev->pf[i].dev) != mode)
740739
return false;
741740

742-
if (mode == MLX5_ESWITCH_OFFLOADS && ldev->ports > MLX5_LAG_OFFLOADS_SUPPORTED_PORTS)
743-
return false;
744741
#else
745742
for (i = 0; i < ldev->ports; i++)
746743
if (mlx5_sriov_is_enabled(ldev->pf[i].dev))

drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -507,58 +507,6 @@ struct mlx5_irq *mlx5_irq_request(struct mlx5_core_dev *dev, u16 vecidx,
507507
return irq;
508508
}
509509

510-
/**
511-
* mlx5_msix_alloc - allocate msix interrupt
512-
* @dev: mlx5 device from which to request
513-
* @handler: interrupt handler
514-
* @affdesc: affinity descriptor
515-
* @name: interrupt name
516-
*
517-
* Returns: struct msi_map with result encoded.
518-
* Note: the caller must make sure to release the irq by calling
519-
* mlx5_msix_free() if shutdown was initiated.
520-
*/
521-
struct msi_map mlx5_msix_alloc(struct mlx5_core_dev *dev,
522-
irqreturn_t (*handler)(int, void *),
523-
const struct irq_affinity_desc *affdesc,
524-
const char *name)
525-
{
526-
struct msi_map map;
527-
int err;
528-
529-
if (!dev->pdev) {
530-
map.virq = 0;
531-
map.index = -EINVAL;
532-
return map;
533-
}
534-
535-
map = pci_msix_alloc_irq_at(dev->pdev, MSI_ANY_INDEX, affdesc);
536-
if (!map.virq)
537-
return map;
538-
539-
err = request_irq(map.virq, handler, 0, name, NULL);
540-
if (err) {
541-
mlx5_core_warn(dev, "err %d\n", err);
542-
pci_msix_free_irq(dev->pdev, map);
543-
map.virq = 0;
544-
map.index = -ENOMEM;
545-
}
546-
return map;
547-
}
548-
EXPORT_SYMBOL(mlx5_msix_alloc);
549-
550-
/**
551-
* mlx5_msix_free - free a previously allocated msix interrupt
552-
* @dev: mlx5 device associated with interrupt
553-
* @map: map previously returned by mlx5_msix_alloc()
554-
*/
555-
void mlx5_msix_free(struct mlx5_core_dev *dev, struct msi_map map)
556-
{
557-
free_irq(map.virq, NULL);
558-
pci_msix_free_irq(dev->pdev, map);
559-
}
560-
EXPORT_SYMBOL(mlx5_msix_free);
561-
562510
/**
563511
* mlx5_irq_release_vector - release one IRQ back to the system.
564512
* @irq: the irq to release.

include/linux/mlx5/driver.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ enum mlx5_sqp_t {
8585
};
8686

8787
enum {
88-
MLX5_MAX_PORTS = 4,
88+
MLX5_MAX_PORTS = 8,
8989
};
9090

9191
enum {
@@ -1374,11 +1374,4 @@ static inline bool mlx5_is_macsec_roce_supported(struct mlx5_core_dev *mdev)
13741374
enum {
13751375
MLX5_OCTWORD = 16,
13761376
};
1377-
1378-
struct msi_map mlx5_msix_alloc(struct mlx5_core_dev *dev,
1379-
irqreturn_t (*handler)(int, void *),
1380-
const struct irq_affinity_desc *affdesc,
1381-
const char *name);
1382-
void mlx5_msix_free(struct mlx5_core_dev *dev, struct msi_map map);
1383-
13841377
#endif /* MLX5_DRIVER_H */

0 commit comments

Comments
 (0)