netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Pirko <jiri@resnulli.us>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, idosch@mellanox.com, eladr@mellanox.com,
	yotamg@mellanox.com, nogahf@mellanox.com, arkadis@mellanox.com,
	ogerlitz@mellanox.com, roopa@cumulusnetworks.com,
	dsa@cumulusnetworks.com, nikolay@cumulusnetworks.com,
	andy@greyhouse.net, vivien.didelot@savoirfairelinux.com,
	andrew@lunn.ch, f.fainelli@gmail.com,
	alexander.h.duyck@intel.com, hannes@stressinduktion.org,
	kaber@trash.net
Subject: [patch net-next v3 03/12] mlxsw: core: Create an ordered workqueue for FIB offload
Date: Wed, 30 Nov 2016 11:08:57 +0100	[thread overview]
Message-ID: <1480500546-2544-4-git-send-email-jiri@resnulli.us> (raw)
In-Reply-To: <1480500546-2544-1-git-send-email-jiri@resnulli.us>

From: Ido Schimmel <idosch@mellanox.com>

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 <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlxsw/core.c | 22 ++++++++++++++++++++++
 drivers/net/ethernet/mellanox/mlxsw/core.h |  2 ++
 2 files changed, 24 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c
index 4dc028b..57a9884 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.c
@@ -77,6 +77,7 @@ static const char mlxsw_core_driver_name[] = "mlxsw_core";
 static struct dentry *mlxsw_core_dbg_root;
 
 static struct workqueue_struct *mlxsw_wq;
+static struct workqueue_struct *mlxsw_owq;
 
 struct mlxsw_core_pcpu_stats {
 	u64			trap_rx_packets[MLXSW_TRAP_ID_MAX];
@@ -1900,6 +1901,18 @@ int mlxsw_core_schedule_dw(struct delayed_work *dwork, unsigned long delay)
 }
 EXPORT_SYMBOL(mlxsw_core_schedule_dw);
 
+int mlxsw_core_schedule_odw(struct delayed_work *dwork, unsigned long delay)
+{
+	return queue_delayed_work(mlxsw_owq, dwork, delay);
+}
+EXPORT_SYMBOL(mlxsw_core_schedule_odw);
+
+void mlxsw_core_flush_owq(void)
+{
+	flush_workqueue(mlxsw_owq);
+}
+EXPORT_SYMBOL(mlxsw_core_flush_owq);
+
 static int __init mlxsw_core_module_init(void)
 {
 	int err;
@@ -1907,6 +1920,12 @@ static int __init mlxsw_core_module_init(void)
 	mlxsw_wq = alloc_workqueue(mlxsw_core_driver_name, WQ_MEM_RECLAIM, 0);
 	if (!mlxsw_wq)
 		return -ENOMEM;
+	mlxsw_owq = alloc_ordered_workqueue("%s_ordered", WQ_MEM_RECLAIM,
+					    mlxsw_core_driver_name);
+	if (!mlxsw_owq) {
+		err = -ENOMEM;
+		goto err_alloc_ordered_workqueue;
+	}
 	mlxsw_core_dbg_root = debugfs_create_dir(mlxsw_core_driver_name, NULL);
 	if (!mlxsw_core_dbg_root) {
 		err = -ENOMEM;
@@ -1915,6 +1934,8 @@ static int __init mlxsw_core_module_init(void)
 	return 0;
 
 err_debugfs_create_dir:
+	destroy_workqueue(mlxsw_owq);
+err_alloc_ordered_workqueue:
 	destroy_workqueue(mlxsw_wq);
 	return err;
 }
@@ -1922,6 +1943,7 @@ static int __init mlxsw_core_module_init(void)
 static void __exit mlxsw_core_module_exit(void)
 {
 	debugfs_remove_recursive(mlxsw_core_dbg_root);
+	destroy_workqueue(mlxsw_owq);
 	destroy_workqueue(mlxsw_wq);
 }
 
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.h b/drivers/net/ethernet/mellanox/mlxsw/core.h
index e856b49..a7f94fb 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.h
@@ -207,6 +207,8 @@ enum devlink_port_type mlxsw_core_port_type_get(struct mlxsw_core *mlxsw_core,
 						u8 local_port);
 
 int mlxsw_core_schedule_dw(struct delayed_work *dwork, unsigned long delay);
+int mlxsw_core_schedule_odw(struct delayed_work *dwork, unsigned long delay);
+void mlxsw_core_flush_owq(void);
 
 #define MLXSW_CONFIG_PROFILE_SWID_COUNT 8
 
-- 
2.7.4

  parent reply	other threads:[~2016-11-30 10:09 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-30 10:08 [patch net-next v3 00/12] ipv4: fib: Allow modules to dump FIB tables Jiri Pirko
2016-11-30 10:08 ` [patch net-next v3 01/12] ipv4: fib: Export free_fib_info() Jiri Pirko
2016-11-30 10:08 ` [patch net-next v3 02/12] ipv4: fib: Add fib_info_hold() helper Jiri Pirko
2016-11-30 10:08 ` Jiri Pirko [this message]
2016-11-30 10:08 ` [patch net-next v3 04/12] mlxsw: spectrum_router: Implement FIB offload in deferred work Jiri Pirko
2016-11-30 10:08 ` [patch net-next v3 05/12] rocker: Create an ordered workqueue for FIB offload Jiri Pirko
2016-11-30 10:09 ` [patch net-next v3 06/12] rocker: Implement FIB offload in deferred work Jiri Pirko
2016-11-30 10:09 ` [patch net-next v3 07/12] ipv4: fib: Convert FIB notification chain to be atomic Jiri Pirko
2016-11-30 10:09 ` [patch net-next v3 08/12] ipv4: fib: Allow for consistent FIB dumping Jiri Pirko
2016-11-30 10:09 ` [patch net-next v3 09/12] ipv4: fib: Add sysctl to limit number of FIB dump retries Jiri Pirko
2016-11-30 10:09 ` [patch net-next v3 10/12] ipv4: fib: Add an API to request a FIB dump Jiri Pirko
2016-11-30 10:09 ` [patch net-next v3 11/12] mlxsw: spectrum_router: Request a dump of FIB tables during init Jiri Pirko
2016-11-30 15:37   ` Hannes Frederic Sowa
2016-11-30 16:32     ` Ido Schimmel
2016-11-30 16:49       ` Hannes Frederic Sowa
2016-11-30 18:22         ` Ido Schimmel
2016-12-01 21:57           ` Hannes Frederic Sowa
2016-12-01 23:14             ` Ido Schimmel
2016-12-01 23:27               ` Hannes Frederic Sowa
2016-12-02  9:34                 ` Ido Schimmel
2016-12-01 20:04       ` David Miller
2016-12-01 20:40         ` Hannes Frederic Sowa
2016-12-01 20:54           ` Ido Schimmel
2016-12-01 21:09             ` Hannes Frederic Sowa
2016-12-01 21:21               ` Ido Schimmel
2016-12-01 21:09       ` Hannes Frederic Sowa
2016-11-30 10:09 ` [patch net-next v3 12/12] rocker: Register FIB notifier before creating ports Jiri Pirko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1480500546-2544-4-git-send-email-jiri@resnulli.us \
    --to=jiri@resnulli.us \
    --cc=alexander.h.duyck@intel.com \
    --cc=andrew@lunn.ch \
    --cc=andy@greyhouse.net \
    --cc=arkadis@mellanox.com \
    --cc=davem@davemloft.net \
    --cc=dsa@cumulusnetworks.com \
    --cc=eladr@mellanox.com \
    --cc=f.fainelli@gmail.com \
    --cc=hannes@stressinduktion.org \
    --cc=idosch@mellanox.com \
    --cc=kaber@trash.net \
    --cc=netdev@vger.kernel.org \
    --cc=nikolay@cumulusnetworks.com \
    --cc=nogahf@mellanox.com \
    --cc=ogerlitz@mellanox.com \
    --cc=roopa@cumulusnetworks.com \
    --cc=vivien.didelot@savoirfairelinux.com \
    --cc=yotamg@mellanox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).