Skip to content

Commit dd9bdb0

Browse files
jpirkodavem330
authored andcommitted
mlxsw: core: Add mlxsw specific workqueue and use it for FDB notif. processing
Follow-up patch is going to need to use delayed work as well and frequently. The FDB notification processing is already using that and also quite frequently. It makes sense to create separate workqueue just for mlxsw driver in this case and do not pollute system_wq. Signed-off-by: Jiri Pirko <[email protected]> Reviewed-by: Ido Schimmel <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 42a7f1d commit dd9bdb0

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

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

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
#include <linux/mutex.h>
5656
#include <linux/rcupdate.h>
5757
#include <linux/slab.h>
58+
#include <linux/workqueue.h>
5859
#include <asm/byteorder.h>
5960
#include <net/devlink.h>
6061

@@ -73,6 +74,8 @@ static const char mlxsw_core_driver_name[] = "mlxsw_core";
7374

7475
static struct dentry *mlxsw_core_dbg_root;
7576

77+
static struct workqueue_struct *mlxsw_wq;
78+
7679
struct mlxsw_core_pcpu_stats {
7780
u64 trap_rx_packets[MLXSW_TRAP_ID_MAX];
7881
u64 trap_rx_bytes[MLXSW_TRAP_ID_MAX];
@@ -1575,17 +1578,35 @@ int mlxsw_cmd_exec(struct mlxsw_core *mlxsw_core, u16 opcode, u8 opcode_mod,
15751578
}
15761579
EXPORT_SYMBOL(mlxsw_cmd_exec);
15771580

1581+
int mlxsw_core_schedule_dw(struct delayed_work *dwork, unsigned long delay)
1582+
{
1583+
return queue_delayed_work(mlxsw_wq, dwork, delay);
1584+
}
1585+
EXPORT_SYMBOL(mlxsw_core_schedule_dw);
1586+
15781587
static int __init mlxsw_core_module_init(void)
15791588
{
1580-
mlxsw_core_dbg_root = debugfs_create_dir(mlxsw_core_driver_name, NULL);
1581-
if (!mlxsw_core_dbg_root)
1589+
int err;
1590+
1591+
mlxsw_wq = create_workqueue(mlxsw_core_driver_name);
1592+
if (!mlxsw_wq)
15821593
return -ENOMEM;
1594+
mlxsw_core_dbg_root = debugfs_create_dir(mlxsw_core_driver_name, NULL);
1595+
if (!mlxsw_core_dbg_root) {
1596+
err = -ENOMEM;
1597+
goto err_debugfs_create_dir;
1598+
}
15831599
return 0;
1600+
1601+
err_debugfs_create_dir:
1602+
destroy_workqueue(mlxsw_wq);
1603+
return err;
15841604
}
15851605

15861606
static void __exit mlxsw_core_module_exit(void)
15871607
{
15881608
debugfs_remove_recursive(mlxsw_core_dbg_root);
1609+
destroy_workqueue(mlxsw_wq);
15891610
}
15901611

15911612
module_init(mlxsw_core_module_init);

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include <linux/gfp.h>
4444
#include <linux/types.h>
4545
#include <linux/skbuff.h>
46+
#include <linux/workqueue.h>
4647
#include <net/devlink.h>
4748

4849
#include "trap.h"
@@ -151,6 +152,8 @@ int mlxsw_core_port_init(struct mlxsw_core *mlxsw_core,
151152
struct net_device *dev, bool split, u32 split_group);
152153
void mlxsw_core_port_fini(struct mlxsw_core_port *mlxsw_core_port);
153154

155+
int mlxsw_core_schedule_dw(struct delayed_work *dwork, unsigned long delay);
156+
154157
#define MLXSW_CONFIG_PROFILE_SWID_COUNT 8
155158

156159
struct mlxsw_swid_config {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,8 +1430,8 @@ static void mlxsw_sp_fdb_notify_rec_process(struct mlxsw_sp *mlxsw_sp,
14301430

14311431
static void mlxsw_sp_fdb_notify_work_schedule(struct mlxsw_sp *mlxsw_sp)
14321432
{
1433-
schedule_delayed_work(&mlxsw_sp->fdb_notify.dw,
1434-
msecs_to_jiffies(mlxsw_sp->fdb_notify.interval));
1433+
mlxsw_core_schedule_dw(&mlxsw_sp->fdb_notify.dw,
1434+
msecs_to_jiffies(mlxsw_sp->fdb_notify.interval));
14351435
}
14361436

14371437
static void mlxsw_sp_fdb_notify_work(struct work_struct *work)

0 commit comments

Comments
 (0)