Skip to content

Commit a3832b3

Browse files
idoschdavem330
authored andcommitted
mlxsw: core: Create an ordered workqueue for FIB offload
We're going to start processing FIB entries addition / deletion events in deferred work. These work items must be processed in the order they were submitted or otherwise we can have differences between the kernel's FIB table and the device's. Solve this by creating an ordered workqueue to which these work items will be submitted to. Note that we can't simply convert the current workqueue to be ordered, as EMADs re-transmissions are also processed in deferred work. Later on, we can migrate other work items to this workqueue, such as FDB notification processing and nexthop resolution, since they all take the same lock anyway. Signed-off-by: Ido Schimmel <[email protected]> Signed-off-by: Jiri Pirko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1c677b3 commit a3832b3

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

drivers/net/ethernet/mellanox/mlxsw/core.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ static const char mlxsw_core_driver_name[] = "mlxsw_core";
7777
static struct dentry *mlxsw_core_dbg_root;
7878

7979
static struct workqueue_struct *mlxsw_wq;
80+
static struct workqueue_struct *mlxsw_owq;
8081

8182
struct mlxsw_core_pcpu_stats {
8283
u64 trap_rx_packets[MLXSW_TRAP_ID_MAX];
@@ -1900,13 +1901,31 @@ int mlxsw_core_schedule_dw(struct delayed_work *dwork, unsigned long delay)
19001901
}
19011902
EXPORT_SYMBOL(mlxsw_core_schedule_dw);
19021903

1904+
int mlxsw_core_schedule_odw(struct delayed_work *dwork, unsigned long delay)
1905+
{
1906+
return queue_delayed_work(mlxsw_owq, dwork, delay);
1907+
}
1908+
EXPORT_SYMBOL(mlxsw_core_schedule_odw);
1909+
1910+
void mlxsw_core_flush_owq(void)
1911+
{
1912+
flush_workqueue(mlxsw_owq);
1913+
}
1914+
EXPORT_SYMBOL(mlxsw_core_flush_owq);
1915+
19031916
static int __init mlxsw_core_module_init(void)
19041917
{
19051918
int err;
19061919

19071920
mlxsw_wq = alloc_workqueue(mlxsw_core_driver_name, WQ_MEM_RECLAIM, 0);
19081921
if (!mlxsw_wq)
19091922
return -ENOMEM;
1923+
mlxsw_owq = alloc_ordered_workqueue("%s_ordered", WQ_MEM_RECLAIM,
1924+
mlxsw_core_driver_name);
1925+
if (!mlxsw_owq) {
1926+
err = -ENOMEM;
1927+
goto err_alloc_ordered_workqueue;
1928+
}
19101929
mlxsw_core_dbg_root = debugfs_create_dir(mlxsw_core_driver_name, NULL);
19111930
if (!mlxsw_core_dbg_root) {
19121931
err = -ENOMEM;
@@ -1915,13 +1934,16 @@ static int __init mlxsw_core_module_init(void)
19151934
return 0;
19161935

19171936
err_debugfs_create_dir:
1937+
destroy_workqueue(mlxsw_owq);
1938+
err_alloc_ordered_workqueue:
19181939
destroy_workqueue(mlxsw_wq);
19191940
return err;
19201941
}
19211942

19221943
static void __exit mlxsw_core_module_exit(void)
19231944
{
19241945
debugfs_remove_recursive(mlxsw_core_dbg_root);
1946+
destroy_workqueue(mlxsw_owq);
19251947
destroy_workqueue(mlxsw_wq);
19261948
}
19271949

drivers/net/ethernet/mellanox/mlxsw/core.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ enum devlink_port_type mlxsw_core_port_type_get(struct mlxsw_core *mlxsw_core,
207207
u8 local_port);
208208

209209
int mlxsw_core_schedule_dw(struct delayed_work *dwork, unsigned long delay);
210+
int mlxsw_core_schedule_odw(struct delayed_work *dwork, unsigned long delay);
211+
void mlxsw_core_flush_owq(void);
210212

211213
#define MLXSW_CONFIG_PROFILE_SWID_COUNT 8
212214

0 commit comments

Comments
 (0)