Skip to contentSkip to conversation

net: dsa: add FIB support

PATCH Superseded John Crispin 3 participants 6 messages Sep 12, 2016

Subsystems (4)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: dsa: add FIB support

Add SWITCHDEV_OBJ_ID_IPV4_FIB support to the DSA layer.

---
 Documentation/networking/dsa/dsa.txt |   18 +++++++++++++++
 include/net/dsa.h                    |   13 +++++++++++
 net/dsa/slave.c                      |   41 ++++++++++++++++++++++++++++++++++
 3 files changed, 72 insertions(+)
Documentation/networking/dsa/dsa.txt +18 -0
index 6d6c07c..6cd5831 100644
@@ -607,6 +607,24 @@ of DSA, would be the its port-based VLAN, used by the associated bridge device.
   function that the driver has to call for each MAC address known to be behind
   the given port. A switchdev object is used to carry the VID and MDB info.
 
+Route offloading
+----------------
+
+- ipv4_fib_prepare: routing layer function invoked to prepare the installation
+  of an ipv4 route into the switches routing database. If the operation is not
+  supported this function should return -EOPNOTSUPP. No hardware setup must be
+  done in this function. See ipv4_fib_add for this and details.
+
+- ipv4_fib_add: routing layer function invoked when a new ipv4 route should be
+  installed into the routing database of the switch, it should be programmed
+  with the route for the specified VLAN ID of the device that the route applies
+  to.
+
+- ipv4_fib_del: routing layer function invoked when an ipv4 route should be
+  removed from the routing database, the switch hardware should be programmed
+  to delete the specified MAC address of the nexthop from the specified VLAN ID
+  if it was mapped into the forwarding database.
+
 TODO
 ====
 
include/net/dsa.h +13 -0
index 7556646..7fdd63e 100644
@@ -237,6 +237,7 @@ struct switchdev_obj;
 struct switchdev_obj_port_fdb;
 struct switchdev_obj_port_mdb;
 struct switchdev_obj_port_vlan;
+struct switchdev_obj_ipv4_fib;
 
 struct dsa_switch_ops {
 	struct list_head	list;
@@ -386,6 +387,18 @@ struct dsa_switch_ops {
 	int	(*port_mdb_dump)(struct dsa_switch *ds, int port,
 				 struct switchdev_obj_port_mdb *mdb,
 				 int (*cb)(struct switchdev_obj *obj));
+
+	/*
+	 * IPV4 routing
+	 */
+	int	(*ipv4_fib_prepare)(struct dsa_switch *ds, int port,
+				    const struct switchdev_obj_ipv4_fib *fib4,
+				    struct switchdev_trans *trans);
+	int	(*ipv4_fib_add)(struct dsa_switch *ds, int port,
+				const struct switchdev_obj_ipv4_fib *fib4,
+				struct switchdev_trans *trans);
+	int	(*ipv4_fib_del)(struct dsa_switch *ds, int port,
+				const struct switchdev_obj_ipv4_fib *fib4);
 };
 
 void register_switch_driver(struct dsa_switch_ops *type);
net/dsa/slave.c +41 -0

59 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#1 lore raw
url: https://github.com/0day-ci/linux/commits/John-Crispin/net-dsa-add-FIB-support/20160912-190416 config: x86_64-randconfig-x006-201637 (attached as .config) compiler: gcc-6 (Debian 6.1.1-9) 6.1.1…

Hi John,

[auto build test ERROR on net-next/master]
[also build test ERROR on next-20160912]
[cannot apply to v4.8-rc6]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
[Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on] [Check https://git-scm.com/docs/git-format-patch for more information]

url: https://github.com/0day-ci/linux/commits/John-Crispin/net-dsa-add-FIB-support/20160912-190416
config: x86_64-randconfig-x006-201637 (attached as .config)
compiler: gcc-6 (Debian 6.1.1-9) 6.1.1 20160705 reproduce:

        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

net/dsa/slave.c: In function 'dsa_slave_ipv4_fib_add':

>> net/dsa/slave.c:345:9: error: 'struct dsa_switch' has no member named 'drv'; did you mean 'dev'?
     if (!ds->drv->ipv4_fib_prepare || !ds->drv->ipv4_fib_add)
            ^~
   net/dsa/slave.c:345:39: error: 'struct dsa_switch' has no member named 'drv'; did you mean 'dev'?
     if (!ds->drv->ipv4_fib_prepare || !ds->drv->ipv4_fib_add)
                                          ^~
   net/dsa/slave.c:349:11: error: 'struct dsa_switch' has no member named 'drv'; did you mean 'dev'?
      ret = ds->drv->ipv4_fib_prepare(ds, p->port, fib4, trans);
              ^~
   net/dsa/slave.c:351:11: error: 'struct dsa_switch' has no member named 'drv'; did you mean 'dev'?
      ret = ds->drv->ipv4_fib_add(ds, p->port, fib4, trans);
              ^~
   net/dsa/slave.c: In function 'dsa_slave_ipv4_fib_del':
   net/dsa/slave.c:363:8: error: 'struct dsa_switch' has no member named 'drv'; did you mean 'dev'?
     if (ds->drv->ipv4_fib_del)
           ^~
   net/dsa/slave.c:364:11: error: 'struct dsa_switch' has no member named 'drv'; did you mean 'dev'?
      ret = ds->drv->ipv4_fib_del(ds, p->port, fib4);
              ^~

vim +345 net/dsa/slave.c

339 struct switchdev_trans *trans)
340 {
341 struct dsa_slave_priv *p = netdev_priv(dev);
342 struct dsa_switch *ds = p->parent;
343 int ret;
344

 > 345		if (!ds->drv->ipv4_fib_prepare || !ds->drv->ipv4_fib_add)

346 return -EOPNOTSUPP;
347
348 if (switchdev_trans_ph_prepare(trans))

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#2 lore raw
In reply to John Crispin
url: https://github.com/0day-ci/linux/commits/John-Crispin/net-dsa-add-FIB-support/20160912-190416 config: i386-randconfig-x011-09112120 (attached as .config) compiler: gcc-6 (Debian 6.1.1-9) 6.1.1…

Hi John,

[auto build test WARNING on net-next/master]
[also build test WARNING on next-20160912]
[cannot apply to v4.8-rc6]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
[Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on] [Check https://git-scm.com/docs/git-format-patch for more information]

url: https://github.com/0day-ci/linux/commits/John-Crispin/net-dsa-add-FIB-support/20160912-190416
config: i386-randconfig-x011-09112120 (attached as .config)
compiler: gcc-6 (Debian 6.1.1-9) 6.1.1 20160705 reproduce:

        # save the attached .config to linux build tree
        make ARCH=i386 

All warnings (new ones prefixed by >>):

In file included from include/uapi/linux/stddef.h:1:0,

                    from include/linux/stddef.h:4,
                    from include/uapi/linux/posix_types.h:4,
                    from include/uapi/linux/types.h:13,
                    from include/linux/types.h:5,
                    from include/linux/list.h:4,
                    from net/dsa/slave.c:11:
   net/dsa/slave.c: In function 'dsa_slave_ipv4_fib_add':
   net/dsa/slave.c:345:9: error: 'struct dsa_switch' has no member named 'drv'; did you mean 'dev'?
     if (!ds->drv->ipv4_fib_prepare || !ds->drv->ipv4_fib_add)
            ^
   include/linux/compiler.h:149:30: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                 ^~~~
>> net/dsa/slave.c:345:2: note: in expansion of macro 'if'
     if (!ds->drv->ipv4_fib_prepare || !ds->drv->ipv4_fib_add)
     ^~
   net/dsa/slave.c:345:39: error: 'struct dsa_switch' has no member named 'drv'; did you mean 'dev'?
     if (!ds->drv->ipv4_fib_prepare || !ds->drv->ipv4_fib_add)
                                          ^
   include/linux/compiler.h:149:30: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                 ^~~~
>> net/dsa/slave.c:345:2: note: in expansion of macro 'if'
     if (!ds->drv->ipv4_fib_prepare || !ds->drv->ipv4_fib_add)
     ^~
   net/dsa/slave.c:345:9: error: 'struct dsa_switch' has no member named 'drv'; did you mean 'dev'?
     if (!ds->drv->ipv4_fib_prepare || !ds->drv->ipv4_fib_add)
            ^
   include/linux/compiler.h:149:42: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                             ^~~~
>> net/dsa/slave.c:345:2: note: in expansion of macro 'if'
     if (!ds->drv->ipv4_fib_prepare || !ds->drv->ipv4_fib_add)
     ^~
   net/dsa/slave.c:345:39: error: 'struct dsa_switch' has no member named 'drv'; did you mean 'dev'?
     if (!ds->drv->ipv4_fib_prepare || !ds->drv->ipv4_fib_add)
                                          ^
   include/linux/compiler.h:149:42: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                             ^~~~
>> net/dsa/slave.c:345:2: note: in expansion of macro 'if'
     if (!ds->drv->ipv4_fib_prepare || !ds->drv->ipv4_fib_add)
     ^~
   net/dsa/slave.c:345:9: error: 'struct dsa_switch' has no member named 'drv'; did you mean 'dev'?
     if (!ds->drv->ipv4_fib_prepare || !ds->drv->ipv4_fib_add)
            ^
   include/linux/compiler.h:160:16: note: in definition of macro '__trace_if'
      ______r = !!(cond);     \
                   ^~~~
>> net/dsa/slave.c:345:2: note: in expansion of macro 'if'
     if (!ds->drv->ipv4_fib_prepare || !ds->drv->ipv4_fib_add)
     ^~
   net/dsa/slave.c:345:39: error: 'struct dsa_switch' has no member named 'drv'; did you mean 'dev'?
     if (!ds->drv->ipv4_fib_prepare || !ds->drv->ipv4_fib_add)
                                          ^
   include/linux/compiler.h:160:16: note: in definition of macro '__trace_if'
      ______r = !!(cond);     \
                   ^~~~
>> net/dsa/slave.c:345:2: note: in expansion of macro 'if'
     if (!ds->drv->ipv4_fib_prepare || !ds->drv->ipv4_fib_add)
     ^~
   net/dsa/slave.c:349:11: error: 'struct dsa_switch' has no member named 'drv'; did you mean 'dev'?
      ret = ds->drv->ipv4_fib_prepare(ds, p->port, fib4, trans);
              ^~
   net/dsa/slave.c:351:11: error: 'struct dsa_switch' has no member named 'drv'; did you mean 'dev'?
      ret = ds->drv->ipv4_fib_add(ds, p->port, fib4, trans);
              ^~
   In file included from include/uapi/linux/stddef.h:1:0,
                    from include/linux/stddef.h:4,
                    from include/uapi/linux/posix_types.h:4,
                    from include/uapi/linux/types.h:13,
                    from include/linux/types.h:5,
                    from include/linux/list.h:4,
                    from net/dsa/slave.c:11:
   net/dsa/slave.c: In function 'dsa_slave_ipv4_fib_del':
   net/dsa/slave.c:363:8: error: 'struct dsa_switch' has no member named 'drv'; did you mean 'dev'?
     if (ds->drv->ipv4_fib_del)
           ^
   include/linux/compiler.h:149:30: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                 ^~~~
   net/dsa/slave.c:363:2: note: in expansion of macro 'if'
     if (ds->drv->ipv4_fib_del)
     ^~
   net/dsa/slave.c:363:8: error: 'struct dsa_switch' has no member named 'drv'; did you mean 'dev'?
     if (ds->drv->ipv4_fib_del)
           ^
   include/linux/compiler.h:149:42: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                             ^~~~
   net/dsa/slave.c:363:2: note: in expansion of macro 'if'
     if (ds->drv->ipv4_fib_del)
     ^~
   net/dsa/slave.c:363:8: error: 'struct dsa_switch' has no member named 'drv'; did you mean 'dev'?
     if (ds->drv->ipv4_fib_del)
           ^
   include/linux/compiler.h:160:16: note: in definition of macro '__trace_if'
      ______r = !!(cond);     \
                   ^~~~
   net/dsa/slave.c:363:2: note: in expansion of macro 'if'
     if (ds->drv->ipv4_fib_del)
     ^~
   net/dsa/slave.c:364:11: error: 'struct dsa_switch' has no member named 'drv'; did you mean 'dev'?
      ret = ds->drv->ipv4_fib_del(ds, p->port, fib4);
              ^~

vim +/if +345 net/dsa/slave.c

329 struct dsa_switch *ds = p->parent;
330
331 if (ds->ops->port_mdb_dump)
332 return ds->ops->port_mdb_dump(ds, p->port, mdb, cb);
333
334 return -EOPNOTSUPP;
335 }
336
337 static int dsa_slave_ipv4_fib_add(struct net_device *dev,
338 const struct switchdev_obj_ipv4_fib *fib4,
339 struct switchdev_trans *trans)
340 {
341 struct dsa_slave_priv *p = netdev_priv(dev);
342 struct dsa_switch *ds = p->parent;
343 int ret;
344

 > 345		if (!ds->drv->ipv4_fib_prepare || !ds->drv->ipv4_fib_add)

346 return -EOPNOTSUPP;
347
348 if (switchdev_trans_ph_prepare(trans))
349 ret = ds->drv->ipv4_fib_prepare(ds, p->port, fib4, trans);
350 else
351 ret = ds->drv->ipv4_fib_add(ds, p->port, fib4, trans);
352
353 return ret;

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#3 lore raw
In reply to John Crispin
url: https://github.com/0day-ci/linux/commits/John-Crispin/net-dsa-add-FIB-support/20160912-190416 config: ia64-allmodconfig (attached as .config) compiler: ia64-linux-gcc (GCC) 4.9.0 reproduce…

Hi John,

[auto build test ERROR on net-next/master]
[cannot apply to v4.8-rc6]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
[Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on] [Check https://git-scm.com/docs/git-format-patch for more information]

url: https://github.com/0day-ci/linux/commits/John-Crispin/net-dsa-add-FIB-support/20160912-190416
config: ia64-allmodconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 4.9.0
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=ia64

All errors (new ones prefixed by >>):

net/dsa/slave.c: In function 'dsa_slave_ipv4_fib_add':

>> net/dsa/slave.c:345:9: error: 'struct dsa_switch' has no member named 'drv'
     if (!ds->drv->ipv4_fib_prepare || !ds->drv->ipv4_fib_add)
            ^
   net/dsa/slave.c:345:39: error: 'struct dsa_switch' has no member named 'drv'
     if (!ds->drv->ipv4_fib_prepare || !ds->drv->ipv4_fib_add)
                                          ^
   net/dsa/slave.c:349:11: error: 'struct dsa_switch' has no member named 'drv'
      ret = ds->drv->ipv4_fib_prepare(ds, p->port, fib4, trans);
              ^
   net/dsa/slave.c:351:11: error: 'struct dsa_switch' has no member named 'drv'
      ret = ds->drv->ipv4_fib_add(ds, p->port, fib4, trans);
              ^
   net/dsa/slave.c: In function 'dsa_slave_ipv4_fib_del':
   net/dsa/slave.c:363:8: error: 'struct dsa_switch' has no member named 'drv'
     if (ds->drv->ipv4_fib_del)
           ^
   net/dsa/slave.c:364:11: error: 'struct dsa_switch' has no member named 'drv'
      ret = ds->drv->ipv4_fib_del(ds, p->port, fib4);
              ^

vim +345 net/dsa/slave.c

339 struct switchdev_trans *trans)
340 {
341 struct dsa_slave_priv *p = netdev_priv(dev);
342 struct dsa_switch *ds = p->parent;
343 int ret;
344

 > 345		if (!ds->drv->ipv4_fib_prepare || !ds->drv->ipv4_fib_add)

346 return -EOPNOTSUPP;
347
348 if (switchdev_trans_ph_prepare(trans))

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

maintainer
#4 lore raw
In reply to John Crispin

Hi John

net/dsa/slave.c static int dsa_slave_port_mdb_dump(struct net_device *dev, · line 345

Quoted 1 line
net/dsa/slave.c +1 -0
+	if (!ds->drv->ipv4_fib_prepare || !ds->drv->ipv4_fib_add)

drv recently got renamed to ops, which is what 0-day is complaining about.

Andrew

#5 lore raw
Quoted 9 lines · Andrew Lunn

Hi John

net/dsa/slave.c static int dsa_slave_port_mdb_dump(struct net_device *dev, · line 345

Quoted 1 line
net/dsa/slave.c +1 -0
+	if (!ds->drv->ipv4_fib_prepare || !ds->drv->ipv4_fib_add)

drv recently got renamed to ops, which is what 0-day is complaining about.

Andrew

i based this on a net-next from 5-6 days ago, will rebase/resend tomorrow.

John