netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: sfeldma@gmail.com
To: netdev@vger.kernel.org
Cc: jiri@resnulli.us, jhs@mojatatu.com, roopa@cumulusnetworks.com
Subject: [PATCH net-next] switchdev: add netlink flags to IPv4 FIB add op
Date: Mon,  9 Mar 2015 13:59:09 -0700	[thread overview]
Message-ID: <1425934749-18567-1-git-send-email-sfeldma@gmail.com> (raw)

From: Scott Feldman <sfeldma@gmail.com>

Pass in the netlink flags (NLM_F_*) into switchdev driver for IPv4 FIB add op
to allow driver to 1) optimize hardware updates, 2) handle ip route prepend
and append commands correctly.

Suggested-by: Jamal Hadi Salim <jhs@mojatatu.com>
Suggested-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: Scott Feldman <sfeldma@gmail.com>
---
 drivers/net/ethernet/rocker/rocker.c |    3 ++-
 include/linux/netdevice.h            |    3 ++-
 include/net/switchdev.h              |    6 ++++--
 net/ipv4/fib_trie.c                  |    5 ++++-
 net/switchdev/switchdev.c            |    7 +++++--
 5 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/rocker/rocker.c b/drivers/net/ethernet/rocker/rocker.c
index 65e1403..223348d 100644
--- a/drivers/net/ethernet/rocker/rocker.c
+++ b/drivers/net/ethernet/rocker/rocker.c
@@ -4152,7 +4152,8 @@ static int rocker_port_switch_port_stp_update(struct net_device *dev, u8 state)
 static int rocker_port_switch_fib_ipv4_add(struct net_device *dev,
 					   __be32 dst, int dst_len,
 					   struct fib_info *fi,
-					   u8 tos, u8 type, u32 tb_id)
+					   u8 tos, u8 type,
+					   u32 nlflags, u32 tb_id)
 {
 	struct rocker_port *rocker_port = netdev_priv(dev);
 	int flags = 0;
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 4541378..1354ae8 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1035,7 +1035,7 @@ struct fib_info;
  *	state change.
  * int (*ndo_sw_parent_fib_ipv4_add)(struct net_device *dev, __be32 dst,
  *				     int dst_len, struct fib_info *fi,
- *				     u8 tos, u8 type, u32 tb_id);
+ *				     u8 tos, u8 type, u32 nlflags, u32 tb_id);
  *	Called to add/modify IPv4 route to switch device.
  * int (*ndo_sw_parent_fib_ipv4_del)(struct net_device *dev, __be32 dst,
  *				     int dst_len, struct fib_info *fi,
@@ -1207,6 +1207,7 @@ struct net_device_ops {
 							   int dst_len,
 							   struct fib_info *fi,
 							   u8 tos, u8 type,
+							   u32 nlflags,
 							   u32 tb_id);
 	int			(*ndo_switch_fib_ipv4_del)(struct net_device *dev,
 							   __be32 dst,
diff --git a/include/net/switchdev.h b/include/net/switchdev.h
index 933fac4..1a9382f 100644
--- a/include/net/switchdev.h
+++ b/include/net/switchdev.h
@@ -1,6 +1,7 @@
 /*
  * include/net/switchdev.h - Switch device API
  * Copyright (c) 2014 Jiri Pirko <jiri@resnulli.us>
+ * Copyright (c) 2014-2015 Scott Feldman <sfeldma@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -52,7 +53,7 @@ int ndo_dflt_netdev_switch_port_bridge_dellink(struct net_device *dev,
 int ndo_dflt_netdev_switch_port_bridge_setlink(struct net_device *dev,
 					       struct nlmsghdr *nlh, u16 flags);
 int netdev_switch_fib_ipv4_add(u32 dst, int dst_len, struct fib_info *fi,
-			       u8 tos, u8 type, u32 tb_id);
+			       u8 tos, u8 type, u32 nlflags, u32 tb_id);
 int netdev_switch_fib_ipv4_del(u32 dst, int dst_len, struct fib_info *fi,
 			       u8 tos, u8 type, u32 tb_id);
 void netdev_switch_fib_ipv4_abort(struct fib_info *fi);
@@ -117,7 +118,8 @@ static inline int ndo_dflt_netdev_switch_port_bridge_setlink(struct net_device *
 
 static inline int netdev_switch_fib_ipv4_add(u32 dst, int dst_len,
 					     struct fib_info *fi,
-					     u8 tos, u8 type, u32 tb_id)
+					     u8 tos, u8 type,
+					     u32 nlflags, u32 tb_id)
 {
 	return 0;
 }
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index 9095545..fcfa982 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -1155,6 +1155,7 @@ int fib_table_insert(struct fib_table *tb, struct fib_config *cfg)
 			err = netdev_switch_fib_ipv4_add(key, plen, fi,
 							 new_fa->fa_tos,
 							 cfg->fc_type,
+							 cfg->fc_nlflags,
 							 tb->tb_id);
 			if (err) {
 				netdev_switch_fib_ipv4_abort(fi);
@@ -1201,7 +1202,9 @@ int fib_table_insert(struct fib_table *tb, struct fib_config *cfg)
 
 	/* (Optionally) offload fib entry to switch hardware. */
 	err = netdev_switch_fib_ipv4_add(key, plen, fi, tos,
-					 cfg->fc_type, tb->tb_id);
+					 cfg->fc_type,
+					 cfg->fc_nlflags,
+					 tb->tb_id);
 	if (err) {
 		netdev_switch_fib_ipv4_abort(fi);
 		goto out_free_new_fa;
diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c
index 19e4e72..c9f6200 100644
--- a/net/switchdev/switchdev.c
+++ b/net/switchdev/switchdev.c
@@ -1,6 +1,7 @@
 /*
  * net/switchdev/switchdev.c - Switch device API
  * Copyright (c) 2014 Jiri Pirko <jiri@resnulli.us>
+ * Copyright (c) 2014-2015 Scott Feldman <sfeldma@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -294,12 +295,13 @@ static struct net_device *netdev_switch_get_dev_by_nhs(struct fib_info *fi)
  *	@fi: route FIB info structure
  *	@tos: route TOS
  *	@type: route type
+ *	@nlflags: netlink flags passed in (NLM_F_*)
  *	@tb_id: route table ID
  *
  *	Add IPv4 route entry to switch device.
  */
 int netdev_switch_fib_ipv4_add(u32 dst, int dst_len, struct fib_info *fi,
-			       u8 tos, u8 type, u32 tb_id)
+			       u8 tos, u8 type, u32 nlflags, u32 tb_id)
 {
 	struct net_device *dev;
 	const struct net_device_ops *ops;
@@ -324,7 +326,8 @@ int netdev_switch_fib_ipv4_add(u32 dst, int dst_len, struct fib_info *fi,
 
 	if (ops->ndo_switch_fib_ipv4_add) {
 		err = ops->ndo_switch_fib_ipv4_add(dev, htonl(dst), dst_len,
-						   fi, tos, type, tb_id);
+						   fi, tos, type, nlflags,
+						   tb_id);
 		if (!err)
 			fi->fib_flags |= RTNH_F_EXTERNAL;
 	}
-- 
1.7.10.4

             reply	other threads:[~2015-03-09 20:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-09 20:59 sfeldma [this message]
2015-03-10  2:26 ` [PATCH net-next] switchdev: add netlink flags to IPv4 FIB add op Simon Horman
2015-03-10  2:27 ` Roopa Prabhu
2015-03-10  3:57 ` David Miller

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=1425934749-18567-1-git-send-email-sfeldma@gmail.com \
    --to=sfeldma@gmail.com \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=netdev@vger.kernel.org \
    --cc=roopa@cumulusnetworks.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).