Skip to content

Commit 6933a93

Browse files
author
Saeed Mahameed
committed
net/mlx5: E-Switch, Use async events chain
Remove the explicit call to mlx5_eswitch_vport_event on MLX5_EVENT_TYPE_NIC_VPORT_CHANGE and let the eswitch register its own handler when its ready. Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 4106925 commit 6933a93

File tree

3 files changed

+26
-25
lines changed

3 files changed

+26
-25
lines changed

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -409,10 +409,6 @@ static irqreturn_t mlx5_eq_async_int(int irq, void *eq_ptr)
409409
}
410410
break;
411411

412-
case MLX5_EVENT_TYPE_NIC_VPORT_CHANGE:
413-
mlx5_eswitch_vport_event(dev->priv.eswitch, eqe);
414-
break;
415-
416412
case MLX5_EVENT_TYPE_PORT_MODULE_EVENT:
417413
mlx5_port_module_event(dev, eqe);
418414
break;

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

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include <linux/mlx5/vport.h>
3737
#include <linux/mlx5/fs.h>
3838
#include "mlx5_core.h"
39+
#include "lib/eq.h"
3940
#include "eswitch.h"
4041
#include "fs_core.h"
4142
#include "lib/eq.h"
@@ -1568,7 +1569,6 @@ static void esw_disable_vport(struct mlx5_eswitch *esw, int vport_num)
15681569
/* Mark this vport as disabled to discard new events */
15691570
vport->enabled = false;
15701571

1571-
mlx5_eq_synchronize_async_irq(esw->dev);
15721572
/* Wait for current already scheduled events to complete */
15731573
flush_workqueue(esw->work_queue);
15741574
/* Disable events from this vport */
@@ -1594,10 +1594,25 @@ static void esw_disable_vport(struct mlx5_eswitch *esw, int vport_num)
15941594
mutex_unlock(&esw->state_lock);
15951595
}
15961596

1597+
static int eswitch_vport_event(struct notifier_block *nb,
1598+
unsigned long type, void *data)
1599+
{
1600+
struct mlx5_eswitch *esw = mlx5_nb_cof(nb, struct mlx5_eswitch, nb);
1601+
struct mlx5_eqe *eqe = data;
1602+
struct mlx5_vport *vport;
1603+
u16 vport_num;
1604+
1605+
vport_num = be16_to_cpu(eqe->data.vport_change.vport_num);
1606+
vport = &esw->vports[vport_num];
1607+
if (vport->enabled)
1608+
queue_work(esw->work_queue, &vport->vport_change_handler);
1609+
1610+
return NOTIFY_OK;
1611+
}
1612+
15971613
/* Public E-Switch API */
15981614
#define ESW_ALLOWED(esw) ((esw) && MLX5_ESWITCH_MANAGER((esw)->dev))
15991615

1600-
16011616
int mlx5_eswitch_enable_sriov(struct mlx5_eswitch *esw, int nvfs, int mode)
16021617
{
16031618
int err;
@@ -1641,6 +1656,11 @@ int mlx5_eswitch_enable_sriov(struct mlx5_eswitch *esw, int nvfs, int mode)
16411656
for (i = 0; i <= nvfs; i++)
16421657
esw_enable_vport(esw, i, enabled_events);
16431658

1659+
if (mode == SRIOV_LEGACY) {
1660+
MLX5_NB_INIT(&esw->nb, eswitch_vport_event, NIC_VPORT_CHANGE);
1661+
mlx5_eq_notifier_register(esw->dev, &esw->nb);
1662+
}
1663+
16441664
esw_info(esw->dev, "SRIOV enabled: active vports(%d)\n",
16451665
esw->enabled_vports);
16461666
return 0;
@@ -1670,6 +1690,9 @@ void mlx5_eswitch_disable_sriov(struct mlx5_eswitch *esw)
16701690
mc_promisc = &esw->mc_promisc;
16711691
nvports = esw->enabled_vports;
16721692

1693+
if (esw->mode == SRIOV_LEGACY)
1694+
mlx5_eq_notifier_unregister(esw->dev, &esw->nb);
1695+
16731696
for (i = 0; i < esw->total_vports; i++)
16741697
esw_disable_vport(esw, i);
16751698

@@ -1778,23 +1801,6 @@ void mlx5_eswitch_cleanup(struct mlx5_eswitch *esw)
17781801
kfree(esw);
17791802
}
17801803

1781-
void mlx5_eswitch_vport_event(struct mlx5_eswitch *esw, struct mlx5_eqe *eqe)
1782-
{
1783-
struct mlx5_eqe_vport_change *vc_eqe = &eqe->data.vport_change;
1784-
u16 vport_num = be16_to_cpu(vc_eqe->vport_num);
1785-
struct mlx5_vport *vport;
1786-
1787-
if (!esw) {
1788-
pr_warn("MLX5 E-Switch: vport %d got an event while eswitch is not initialized\n",
1789-
vport_num);
1790-
return;
1791-
}
1792-
1793-
vport = &esw->vports[vport_num];
1794-
if (vport->enabled)
1795-
queue_work(esw->work_queue, &vport->vport_change_handler);
1796-
}
1797-
17981804
/* Vport Administration */
17991805
#define LEGAL_VPORT(esw, vport) (vport >= 0 && vport < esw->total_vports)
18001806

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ struct esw_mc_addr { /* SRIOV only */
181181

182182
struct mlx5_eswitch {
183183
struct mlx5_core_dev *dev;
184+
struct mlx5_nb nb;
184185
struct mlx5_eswitch_fdb fdb_table;
185186
struct hlist_head mc_table[MLX5_L2_ADDR_HASH_SIZE];
186187
struct workqueue_struct *work_queue;
@@ -211,7 +212,6 @@ int esw_offloads_init_reps(struct mlx5_eswitch *esw);
211212
/* E-Switch API */
212213
int mlx5_eswitch_init(struct mlx5_core_dev *dev);
213214
void mlx5_eswitch_cleanup(struct mlx5_eswitch *esw);
214-
void mlx5_eswitch_vport_event(struct mlx5_eswitch *esw, struct mlx5_eqe *eqe);
215215
int mlx5_eswitch_enable_sriov(struct mlx5_eswitch *esw, int nvfs, int mode);
216216
void mlx5_eswitch_disable_sriov(struct mlx5_eswitch *esw);
217217
int mlx5_eswitch_set_vport_mac(struct mlx5_eswitch *esw,
@@ -352,7 +352,6 @@ static inline bool mlx5_eswitch_vlan_actions_supported(struct mlx5_core_dev *dev
352352
/* eswitch API stubs */
353353
static inline int mlx5_eswitch_init(struct mlx5_core_dev *dev) { return 0; }
354354
static inline void mlx5_eswitch_cleanup(struct mlx5_eswitch *esw) {}
355-
static inline void mlx5_eswitch_vport_event(struct mlx5_eswitch *esw, struct mlx5_eqe *eqe) {}
356355
static inline int mlx5_eswitch_enable_sriov(struct mlx5_eswitch *esw, int nvfs, int mode) { return 0; }
357356
static inline void mlx5_eswitch_disable_sriov(struct mlx5_eswitch *esw) {}
358357

0 commit comments

Comments
 (0)