Skip to content

Commit dc3a200

Browse files
committed
Merge tag 'mlx5-updates-2022-05-09' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux
Saeed Mahameed says: ==================== mlx5-updates-2022-05-09 1) Gavin Li, adds exit route from waiting for FW init on device boot and increases FW init timeout on health recovery flow 2) Support 4 ports HCAs LAG mode Mark Bloch Says: ================ This series adds to mlx5 drivers support for 4 ports HCAs. Starting with ConnectX-7 HCAs with 4 ports are possible. As most driver parts aren't affected by such configuration most driver code is unchanged. Specially the only affected areas are: - Lag - Devcom - Merged E-Switch - Single FDB E-Switch Lag was chosen to be converted first. Creating hardware LAG when all 4 ports are added to the same bond device. Devom, merge E-Switch and single FDB E-Switch, are marked as supporting only 2 ports HCAs and future patches will add support for 4 ports HCAs. In order to activate the hardware lag a user can execute the: ip link add bond0 type bond ip link set bond0 type bond miimon 100 mode 2 ip link set eth2 master bond0 ip link set eth3 master bond0 ip link set eth4 master bond0 ip link set eth5 master bond0 Where eth2, eth3, eth4 and eth5 are the PFs of the same HCA. ================ ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 53a332f + 7f46a0b commit dc3a200

File tree

22 files changed

+720
-302
lines changed

22 files changed

+720
-302
lines changed

drivers/infiniband/hw/mlx5/gsi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ int mlx5_ib_create_gsi(struct ib_pd *pd, struct mlx5_ib_qp *mqp,
100100
port_type) == MLX5_CAP_PORT_TYPE_IB)
101101
num_qps = pd->device->attrs.max_pkeys;
102102
else if (dev->lag_active)
103-
num_qps = MLX5_MAX_PORTS;
103+
num_qps = dev->lag_ports;
104104
}
105105

106106
gsi = &mqp->gsi;

drivers/infiniband/hw/mlx5/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2991,6 +2991,7 @@ static int mlx5_eth_lag_init(struct mlx5_ib_dev *dev)
29912991
}
29922992

29932993
dev->flow_db->lag_demux_ft = ft;
2994+
dev->lag_ports = mlx5_lag_get_num_ports(mdev);
29942995
dev->lag_active = true;
29952996
return 0;
29962997

drivers/infiniband/hw/mlx5/mlx5_ib.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,7 @@ struct mlx5_ib_dev {
11311131
struct xarray sig_mrs;
11321132
struct mlx5_port_caps port_caps[MLX5_MAX_PORTS];
11331133
u16 pkey_table_len;
1134+
u8 lag_ports;
11341135
};
11351136

11361137
static inline struct mlx5_ib_cq *to_mibcq(struct mlx5_core_cq *mcq)

drivers/infiniband/hw/mlx5/qp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3907,7 +3907,7 @@ static unsigned int get_tx_affinity_rr(struct mlx5_ib_dev *dev,
39073907
tx_port_affinity = &dev->port[port_num].roce.tx_port_affinity;
39083908

39093909
return (unsigned int)atomic_add_return(1, tx_port_affinity) %
3910-
MLX5_MAX_PORTS + 1;
3910+
(dev->lag_active ? dev->lag_ports : MLX5_CAP_GEN(dev->mdev, num_lag_ports)) + 1;
39113911
}
39123912

39133913
static bool qp_supports_affinity(struct mlx5_ib_qp *qp)

drivers/net/ethernet/mellanox/mlx5/core/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ obj-$(CONFIG_MLX5_CORE) += mlx5_core.o
1414
mlx5_core-y := main.o cmd.o debugfs.o fw.o eq.o uar.o pagealloc.o \
1515
health.o mcg.o cq.o alloc.o port.o mr.o pd.o \
1616
transobj.o vport.o sriov.o fs_cmd.o fs_core.o pci_irq.o \
17-
fs_counters.o fs_ft_pool.o rl.o lag/lag.o dev.o events.o wq.o lib/gid.o \
17+
fs_counters.o fs_ft_pool.o rl.o lag/debugfs.o lag/lag.o dev.o events.o wq.o lib/gid.o \
1818
lib/devcom.o lib/pci_vsc.o lib/dm.o lib/fs_ttc.o diag/fs_tracepoint.o \
1919
diag/fw_tracer.o diag/crdump.o devlink.o diag/rsc_dump.o \
2020
fw_reset.o qos.o lib/tout.o

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

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -555,12 +555,9 @@ static u32 mlx5_gen_pci_id(const struct mlx5_core_dev *dev)
555555
PCI_SLOT(dev->pdev->devfn));
556556
}
557557

558-
static int next_phys_dev(struct device *dev, const void *data)
558+
static int _next_phys_dev(struct mlx5_core_dev *mdev,
559+
const struct mlx5_core_dev *curr)
559560
{
560-
struct mlx5_adev *madev = container_of(dev, struct mlx5_adev, adev.dev);
561-
struct mlx5_core_dev *mdev = madev->mdev;
562-
const struct mlx5_core_dev *curr = data;
563-
564561
if (!mlx5_core_is_pf(mdev))
565562
return 0;
566563

@@ -574,16 +571,38 @@ static int next_phys_dev(struct device *dev, const void *data)
574571
return 1;
575572
}
576573

577-
/* Must be called with intf_mutex held */
578-
struct mlx5_core_dev *mlx5_get_next_phys_dev(struct mlx5_core_dev *dev)
574+
static int next_phys_dev(struct device *dev, const void *data)
575+
{
576+
struct mlx5_adev *madev = container_of(dev, struct mlx5_adev, adev.dev);
577+
struct mlx5_core_dev *mdev = madev->mdev;
578+
579+
return _next_phys_dev(mdev, data);
580+
}
581+
582+
static int next_phys_dev_lag(struct device *dev, const void *data)
583+
{
584+
struct mlx5_adev *madev = container_of(dev, struct mlx5_adev, adev.dev);
585+
struct mlx5_core_dev *mdev = madev->mdev;
586+
587+
if (!MLX5_CAP_GEN(mdev, vport_group_manager) ||
588+
!MLX5_CAP_GEN(mdev, lag_master) ||
589+
(MLX5_CAP_GEN(mdev, num_lag_ports) > MLX5_MAX_PORTS ||
590+
MLX5_CAP_GEN(mdev, num_lag_ports) <= 1))
591+
return 0;
592+
593+
return _next_phys_dev(mdev, data);
594+
}
595+
596+
static struct mlx5_core_dev *mlx5_get_next_dev(struct mlx5_core_dev *dev,
597+
int (*match)(struct device *dev, const void *data))
579598
{
580599
struct auxiliary_device *adev;
581600
struct mlx5_adev *madev;
582601

583602
if (!mlx5_core_is_pf(dev))
584603
return NULL;
585604

586-
adev = auxiliary_find_device(NULL, dev, &next_phys_dev);
605+
adev = auxiliary_find_device(NULL, dev, match);
587606
if (!adev)
588607
return NULL;
589608

@@ -592,6 +611,20 @@ struct mlx5_core_dev *mlx5_get_next_phys_dev(struct mlx5_core_dev *dev)
592611
return madev->mdev;
593612
}
594613

614+
/* Must be called with intf_mutex held */
615+
struct mlx5_core_dev *mlx5_get_next_phys_dev(struct mlx5_core_dev *dev)
616+
{
617+
lockdep_assert_held(&mlx5_intf_mutex);
618+
return mlx5_get_next_dev(dev, &next_phys_dev);
619+
}
620+
621+
/* Must be called with intf_mutex held */
622+
struct mlx5_core_dev *mlx5_get_next_phys_dev_lag(struct mlx5_core_dev *dev)
623+
{
624+
lockdep_assert_held(&mlx5_intf_mutex);
625+
return mlx5_get_next_dev(dev, &next_phys_dev_lag);
626+
}
627+
595628
void mlx5_dev_list_lock(void)
596629
{
597630
mutex_lock(&mlx5_intf_mutex);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,13 @@ static int mlx5_devlink_reload_up(struct devlink *devlink, enum devlink_reload_a
178178
*actions_performed = BIT(action);
179179
switch (action) {
180180
case DEVLINK_RELOAD_ACTION_DRIVER_REINIT:
181-
return mlx5_load_one(dev);
181+
return mlx5_load_one(dev, false);
182182
case DEVLINK_RELOAD_ACTION_FW_ACTIVATE:
183183
if (limit == DEVLINK_RELOAD_LIMIT_NO_RESET)
184184
break;
185185
/* On fw_activate action, also driver is reloaded and reinit performed */
186186
*actions_performed |= BIT(DEVLINK_RELOAD_ACTION_DRIVER_REINIT);
187-
return mlx5_load_one(dev);
187+
return mlx5_load_one(dev, false);
188188
default:
189189
/* Unsupported action should not get to this function */
190190
WARN_ON(1);

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

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,9 +1569,7 @@ int mlx5_eswitch_init(struct mlx5_core_dev *dev)
15691569
ida_init(&esw->offloads.vport_metadata_ida);
15701570
xa_init_flags(&esw->offloads.vhca_map, XA_FLAGS_ALLOC);
15711571
mutex_init(&esw->state_lock);
1572-
lockdep_register_key(&esw->mode_lock_key);
15731572
init_rwsem(&esw->mode_lock);
1574-
lockdep_set_class(&esw->mode_lock, &esw->mode_lock_key);
15751573
refcount_set(&esw->qos.refcnt, 0);
15761574

15771575
esw->enabled_vports = 0;
@@ -1615,7 +1613,6 @@ void mlx5_eswitch_cleanup(struct mlx5_eswitch *esw)
16151613
esw->dev->priv.eswitch = NULL;
16161614
destroy_workqueue(esw->work_queue);
16171615
WARN_ON(refcount_read(&esw->qos.refcnt));
1618-
lockdep_unregister_key(&esw->mode_lock_key);
16191616
mutex_destroy(&esw->state_lock);
16201617
WARN_ON(!xa_empty(&esw->offloads.vhca_map));
16211618
xa_destroy(&esw->offloads.vhca_map);
@@ -1893,17 +1890,6 @@ mlx5_eswitch_get_encap_mode(const struct mlx5_core_dev *dev)
18931890
}
18941891
EXPORT_SYMBOL(mlx5_eswitch_get_encap_mode);
18951892

1896-
bool mlx5_esw_lag_prereq(struct mlx5_core_dev *dev0, struct mlx5_core_dev *dev1)
1897-
{
1898-
if ((dev0->priv.eswitch->mode == MLX5_ESWITCH_NONE &&
1899-
dev1->priv.eswitch->mode == MLX5_ESWITCH_NONE) ||
1900-
(dev0->priv.eswitch->mode == MLX5_ESWITCH_OFFLOADS &&
1901-
dev1->priv.eswitch->mode == MLX5_ESWITCH_OFFLOADS))
1902-
return true;
1903-
1904-
return false;
1905-
}
1906-
19071893
bool mlx5_esw_multipath_prereq(struct mlx5_core_dev *dev0,
19081894
struct mlx5_core_dev *dev1)
19091895
{
@@ -2014,17 +2000,6 @@ void mlx5_esw_unlock(struct mlx5_eswitch *esw)
20142000
up_write(&esw->mode_lock);
20152001
}
20162002

2017-
/**
2018-
* mlx5_esw_lock() - Take write lock on esw mode lock
2019-
* @esw: eswitch device.
2020-
*/
2021-
void mlx5_esw_lock(struct mlx5_eswitch *esw)
2022-
{
2023-
if (!mlx5_esw_allowed(esw))
2024-
return;
2025-
down_write(&esw->mode_lock);
2026-
}
2027-
20282003
/**
20292004
* mlx5_eswitch_get_total_vports - Get total vports of the eswitch
20302005
*

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,6 @@ struct mlx5_eswitch {
331331
u32 large_group_num;
332332
} params;
333333
struct blocking_notifier_head n_head;
334-
struct lock_class_key mode_lock_key;
335334
};
336335

337336
void esw_offloads_disable(struct mlx5_eswitch *esw);
@@ -518,8 +517,6 @@ static inline bool mlx5_eswitch_vlan_actions_supported(struct mlx5_core_dev *dev
518517
MLX5_CAP_ESW_FLOWTABLE_FDB(dev, push_vlan_2);
519518
}
520519

521-
bool mlx5_esw_lag_prereq(struct mlx5_core_dev *dev0,
522-
struct mlx5_core_dev *dev1);
523520
bool mlx5_esw_multipath_prereq(struct mlx5_core_dev *dev0,
524521
struct mlx5_core_dev *dev1);
525522

@@ -706,7 +703,6 @@ void mlx5_esw_get(struct mlx5_core_dev *dev);
706703
void mlx5_esw_put(struct mlx5_core_dev *dev);
707704
int mlx5_esw_try_lock(struct mlx5_eswitch *esw);
708705
void mlx5_esw_unlock(struct mlx5_eswitch *esw);
709-
void mlx5_esw_lock(struct mlx5_eswitch *esw);
710706

711707
void esw_vport_change_handle_locked(struct mlx5_vport *vport);
712708

@@ -724,7 +720,6 @@ static inline int mlx5_eswitch_init(struct mlx5_core_dev *dev) { return 0; }
724720
static inline void mlx5_eswitch_cleanup(struct mlx5_eswitch *esw) {}
725721
static inline int mlx5_eswitch_enable(struct mlx5_eswitch *esw, int num_vfs) { return 0; }
726722
static inline void mlx5_eswitch_disable(struct mlx5_eswitch *esw, bool clear_vf) {}
727-
static inline bool mlx5_esw_lag_prereq(struct mlx5_core_dev *dev0, struct mlx5_core_dev *dev1) { return true; }
728723
static inline bool mlx5_eswitch_is_funcs_handler(struct mlx5_core_dev *dev) { return false; }
729724
static inline
730725
int mlx5_eswitch_set_vport_state(struct mlx5_eswitch *esw, u16 vport, int link_state) { return 0; }
@@ -733,9 +728,6 @@ static inline const u32 *mlx5_esw_query_functions(struct mlx5_core_dev *dev)
733728
return ERR_PTR(-EOPNOTSUPP);
734729
}
735730

736-
static inline void mlx5_esw_unlock(struct mlx5_eswitch *esw) { return; }
737-
static inline void mlx5_esw_lock(struct mlx5_eswitch *esw) { return; }
738-
739731
static inline struct mlx5_flow_handle *
740732
esw_add_restore_rule(struct mlx5_eswitch *esw, u32 tag)
741733
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ static void mlx5_fw_reset_complete_reload(struct mlx5_core_dev *dev)
148148
if (test_bit(MLX5_FW_RESET_FLAGS_PENDING_COMP, &fw_reset->reset_flags)) {
149149
complete(&fw_reset->done);
150150
} else {
151-
mlx5_load_one(dev);
151+
mlx5_load_one(dev, false);
152152
devlink_remote_reload_actions_performed(priv_to_devlink(dev), 0,
153153
BIT(DEVLINK_RELOAD_ACTION_DRIVER_REINIT) |
154154
BIT(DEVLINK_RELOAD_ACTION_FW_ACTIVATE));

0 commit comments

Comments
 (0)