Skip to contentSkip to conversation

introduce rocker switch driver with hardware accelerated datapath api

PATCH In review Jiri Pirko 21 participants 65 messages Sep 19, 2014 – Sep 26, 2014 9 messages not in the archive

Subsystems (10)
lore
Share & tools
lore

Jiri Pirko

author
#0 lore raw

v2 cover introduce rocker switch driver with hardware accelerated datapath api

This patchset can be divided into 3 main sections:
- introduce switchdev api for implementing switch drivers
- introduce switchdev generic netlink api for userspace manipulation
- introduce rocker switch driver which implements switchdev api

More info in separate patches.

So now there is possible to create ovs bridge over rocker
switch ports. ovs daemon can decide which flows to offload to hw and uses switchdev genl api to tell driver. For now the easiest way it to do it by hand via "sw" tool (https://github.com/jpirko/switchdev).

v1->v2 changes:
- removed DSA phys switch id implementation for now per Florian's request
- introduced own match key structure so the internal ovs flow struct stays untouched
- extended the flow match in order to easily add more match types (hope that Jamal will like this :)
- per ovs maintainers' request, removed ovs offload bits - that will be handled in ovs userspace using switchdev genl interface.
- added switchdev features so that driver can indicate what it supports
- little renames/fixes here and there

RFC->v1 changes:
- moved include/linux/*.h -> include/net/
- moved net/core/switchdev.c -> net/switchdev/
- moved drivers/net/rocker.* -> drivers/net/ethernet/rocker/
- fixed couple of little bugs and typos
- in dsa the switch id is generated randomly
- fixed rocker schedule in atomic context bug in rocker_port_set_rx_mode
- added switchdev Netlink API

Jiri Pirko (9):
net: rename netdev_phys_port_id to more generic name
net: introduce generic switch devices support
rtnl: expose physical switch id for particular device
net-sysfs: expose physical switch id for particular device
net: introduce dummy switch
switchdev: add basic support for flow matching and actions
switchdev: add swdev features
switchdev: introduce Netlink API
rocker: introduce rocker switch driver

 Documentation/networking/switchdev.txt           |   53 +
 MAINTAINERS                                      |   14 +
 drivers/net/Kconfig                              |    7 +
 drivers/net/Makefile                             |    1 +
 drivers/net/dummyswitch.c                        |  130 +
 drivers/net/ethernet/Kconfig                     |    1 +
 drivers/net/ethernet/Makefile                    |    1 +
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c |    2 +-
 drivers/net/ethernet/intel/i40e/i40e_main.c      |    2 +-
 drivers/net/ethernet/mellanox/mlx4/en_netdev.c   |    2 +-
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c |    2 +-
 drivers/net/ethernet/rocker/Kconfig              |   29 +
 drivers/net/ethernet/rocker/Makefile             |    5 +
 drivers/net/ethernet/rocker/rocker.c             | 3561 ++++++++++++++++++++++
 drivers/net/ethernet/rocker/rocker.h             |  465 +++
 include/linux/netdevice.h                        |   49 +-
 include/net/switchdev.h                          |  160 +
 include/uapi/linux/if_link.h                     |   10 +
 include/uapi/linux/switchdev.h                   |  113 +
 net/Kconfig                                      |    1 +
 net/Makefile                                     |    3 +
 net/core/dev.c                                   |    2 +-
 net/core/net-sysfs.c                             |   26 +-
 net/core/rtnetlink.c                             |   30 +-
 net/switchdev/Kconfig                            |   20 +
 net/switchdev/Makefile                           |    6 +
 net/switchdev/switchdev.c                        |  188 ++
 net/switchdev/switchdev_netlink.c                |  441 +++
 28 files changed, 5307 insertions(+), 17 deletions(-)
 create mode 100644 Documentation/networking/switchdev.txt
 create mode 100644 drivers/net/dummyswitch.c
 create mode 100644 drivers/net/ethernet/rocker/Kconfig
 create mode 100644 drivers/net/ethernet/rocker/Makefile
 create mode 100644 drivers/net/ethernet/rocker/rocker.c
 create mode 100644 drivers/net/ethernet/rocker/rocker.h
 create mode 100644 include/net/switchdev.h
 create mode 100644 include/uapi/linux/switchdev.h
 create mode 100644 net/switchdev/Kconfig
 create mode 100644 net/switchdev/Makefile
 create mode 100644 net/switchdev/switchdev.c
 create mode 100644 net/switchdev/switchdev_netlink.c
Signature · 1 line
1.9.3

A message that is not in the archive (sent off-list or not yet received): 1411134590-4586-1-git-send-email-jiri-rHqAuBHg3fBzbRFIqnYvSA@public.gmane.org

author
#2 lore raw

PATCH v2 2/9 net: introduce generic switch devices support

The goal of this is to provide a possibility to suport various switch chips. Drivers should implement relevant ndos to do so. Now there is only one ndo defined:
- for getting physical switch id is in place.

Note that user can use random port netdevice to access the switch.

---
 Documentation/networking/switchdev.txt | 53 ++++++++++++++++++++++++++++++++++
 MAINTAINERS                            |  7 +++++
 include/linux/netdevice.h              | 12 ++++++++
 include/net/switchdev.h                | 29 +++++++++++++++++++
 net/Kconfig                            |  1 +
 net/Makefile                           |  3 ++
 net/switchdev/Kconfig                  |  9 ++++++
 net/switchdev/Makefile                 |  5 ++++
 net/switchdev/switchdev.c              | 32 ++++++++++++++++++++
 9 files changed, 151 insertions(+)
 create mode 100644 Documentation/networking/switchdev.txt
 create mode 100644 include/net/switchdev.h
 create mode 100644 net/switchdev/Kconfig
 create mode 100644 net/switchdev/Makefile
 create mode 100644 net/switchdev/switchdev.c
Documentation/networking/switchdev.txt new file +53 -0
new file mode 100644
index 0000000..435746a
@@ -0,0 +1,53 @@
+Switch device drivers HOWTO
+===========================
+
+First lets describe a topology a bit. Imagine the following example:
+
+       +----------------------------+    +---------------+
+       |     SOME switch chip       |    |      CPU      |
+       +----------------------------+    +---------------+
+       port1 port2 port3 port4 MNGMNT    |     PCI-E     |
+         |     |     |     |     |       +---------------+
+        PHY   PHY    |     |     |         |  NIC0 NIC1
+                     |     |     |         |   |    |
+                     |     |     +- PCI-E -+   |    |
+                     |     +------- MII -------+    |
+                     +------------- MII ------------+
+
+In this example, there are two independent lines between the switch silicon
+and CPU. NIC0 and NIC1 drivers are not aware of a switch presence. They are
+separate from the switch driver. SOME switch chip is by managed by a driver
+via PCI-E device MNGMNT. Note that MNGMNT device, NIC0 and NIC1 may be
+connected to some other type of bus.
+
+Now, for the previous example show the representation in kernel:
+
+       +----------------------------+    +---------------+
+       |     SOME switch chip       |    |      CPU      |
+       +----------------------------+    +---------------+
+       sw0p0 sw0p1 sw0p2 sw0p3 MNGMNT    |     PCI-E     |
+         |     |     |     |     |       +---------------+
+        PHY   PHY    |     |     |         |  eth0 eth1
+                     |     |     |         |   |    |
+                     |     |     +- PCI-E -+   |    |
+                     |     +------- MII -------+    |
+                     +------------- MII ------------+
+
+Lets call the example switch driver for SOME switch chip "SOMEswitch". This
+driver takes care of PCI-E device MNGMNT. There is a netdevice instance sw0pX
+created for each port of a switch. These netdevices are instances
+of "SOMEswitch" driver. sw0pX netdevices serve as a "representation"
+of the switch chip. eth0 and eth1 are instances of some other existing driver.
+
+The only difference of the switch-port netdevice from the ordinary netdevice
+is that is implements couple more NDOs:
+
+	ndo_swdev_get_id - This returns the same ID for two port netdevices of
+			   the same physical switch chip. This is mandatory to
+			   be implemented by all switch drivers and serves
+			   the caller for recognition of a port netdevice.
+	ndo_swdev_* - Functions that serve for a manipulation of the switch chip
+		      itself. They are not port-specific. Caller might use
+		      arbitrary port netdevice of the same switch and it will
+		      make no difference.
+	ndo_swportdev_* - Functions that serve for a port-specific manipulation.
MAINTAINERS +7 -0
index 5e3709e..f1f26db 100644
@@ -8826,6 +8826,13 @@ F:	lib/swiotlb.c
 F:	arch/*/kernel/pci-swiotlb.c
 F:	include/linux/swiotlb.h
 
+SWITCHDEV
+M:	Jiri Pirko <[email protected]>
+L:	[email protected]
+S:	Supported
+F:	net/switchdev/
+F:	include/net/switchdev.h
+
 SYNOPSYS ARC ARCHITECTURE
 M:	Vineet Gupta <vgupta-HKixBCOQz3hWk0Htik3J/[email protected]>
 S:	Supported
include/linux/netdevice.h +12 -0
index 13d765f..b290dcf 100644
@@ -752,6 +752,8 @@ struct netdev_phys_item_id {
 typedef u16 (*select_queue_fallback_t)(struct net_device *dev,
 				       struct sk_buff *skb);
 
+#include <net/switchdev.h>
+
 /*
  * This structure defines the management hooks for network devices.
  * The following hooks can be defined; unless noted otherwise, they are
@@ -997,6 +999,12 @@ typedef u16 (*select_queue_fallback_t)(struct net_device *dev,
  *	Callback to use for xmit over the accelerated station. This
  *	is used in place of ndo_start_xmit on accelerated net
  *	devices.
+ *
+ * int (*ndo_swdev_id_get)(struct net_device *dev,
+ *			   struct netdev_phys_item_id *psid);
+ *	Called to get an ID of the switch chip this port is part of.
+ *	If driver implements this, it indicates that it represents a port
+ *	of a switch chip.
  */
 struct net_device_ops {
 	int			(*ndo_init)(struct net_device *dev);
@@ -1146,6 +1154,10 @@ struct net_device_ops {
 							struct net_device *dev,
 							void *priv);
 	int			(*ndo_get_lock_subclass)(struct net_device *dev);
+#ifdef CONFIG_NET_SWITCHDEV
+	int			(*ndo_swdev_id_get)(struct net_device *dev,
+						    struct netdev_phys_item_id *psid);
+#endif
 };
 
 /**
include/net/switchdev.h new file +29 -0
new file mode 100644
index 0000000..af30f75
@@ -0,0 +1,29 @@
+/*
+ * include/net/switchdev.h - Switch device API
+ * Copyright (c) 2014 Jiri Pirko <[email protected]>
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+#ifndef _LINUX_SWITCHDEV_H_
+#define _LINUX_SWITCHDEV_H_
+
+#include <linux/netdevice.h>
+
+#ifdef CONFIG_NET_SWITCHDEV
+
+int swdev_id_get(struct net_device *dev, struct netdev_phys_item_id *psid);
+
+#else
+
+static inline int swdev_id_get(struct net_device *dev,
+			       struct netdev_phys_item_id *psid)
+{
+	return -EOPNOTSUPP;
+}
+
+#endif
+
+#endif /* _LINUX_SWITCHDEV_H_ */
net/Kconfig +1 -0
index 4051fdf..89a7fec 100644
@@ -226,6 +226,7 @@ source "net/vmw_vsock/Kconfig"
 source "net/netlink/Kconfig"
 source "net/mpls/Kconfig"
 source "net/hsr/Kconfig"
+source "net/switchdev/Kconfig"
 
 config RPS
 	boolean
net/Makefile +3 -0
index 7ed1970..95fc694 100644
@@ -73,3 +73,6 @@ obj-$(CONFIG_OPENVSWITCH)	+= openvswitch/
 obj-$(CONFIG_VSOCKETS)	+= vmw_vsock/
 obj-$(CONFIG_NET_MPLS_GSO)	+= mpls/
 obj-$(CONFIG_HSR)		+= hsr/
+ifneq ($(CONFIG_NET_SWITCHDEV),)
+obj-y				+= switchdev/
+endif
net/switchdev/Kconfig new file +9 -0
new file mode 100644
index 0000000..20e8ed2
@@ -0,0 +1,9 @@
+#
+# Configuration for Switch device support
+#
+
+config NET_SWITCHDEV
+	boolean "Switch device support (EXPERIMENTAL)"
+	depends on INET
+	---help---
+	  This module provides support for hardware switch chips.
net/switchdev/Makefile new file +5 -0
new file mode 100644
index 0000000..5ed63ed
@@ -0,0 +1,5 @@
+#
+# Makefile for the Switch device API
+#
+
+obj-$(CONFIG_NET_SWITCHDEV) += switchdev.o
net/switchdev/switchdev.c new file +32 -0
new file mode 100644
index 0000000..14a5fc9
@@ -0,0 +1,32 @@
+/*
+ * net/switchdev/switchdev.c - Switch device API
+ * Copyright (c) 2014 Jiri Pirko <[email protected]>
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/init.h>
+#include <linux/netdevice.h>
+#include <net/switchdev.h>
+
+/**
+ *	swdev_id_get - Get ID of a switch
+ *	@dev: port device
+ *	@psid: switch ID
+ *
+ *	Get ID of a switch this port is part of.
+ */
+int swdev_id_get(struct net_device *dev, struct netdev_phys_item_id *psid)
+{
+	const struct net_device_ops *ops = dev->netdev_ops;
+
+	if (!ops->ndo_swdev_id_get)
+		return -EOPNOTSUPP;
+	return ops->ndo_swdev_id_get(dev, psid);
+}
+EXPORT_SYMBOL(swdev_id_get);
Signature · 1 line
1.9.3
#3 lore raw
In reply to a message not in the archive

From: Jiri Pirko

Quoted 4 lines

This patchset can be divided into 3 main sections:
- introduce switchdev api for implementing switch drivers
- introduce switchdev generic netlink api for userspace manipulation
- introduce rocker switch driver which implements switchdev api

Perhaps you should be including the name of what you are switching in the name of the API?

Is this for interfacing to ethernet switches, TDM switches or mechanical ones?
It isn't really clear from any of these commit messages.

David

A message that is not in the archive (sent off-list or not yet received): 063D6719AE5E284EB5DD2968C1650D6D17495CC6-VkEWCZq2GCInGFn1LkZF6NBPR1lH4CV8@public.gmane.org

author
#5 lore raw
Quoted 6 lines · Fri, Sep 19, 2014 at 04:15:32PM CEST, David.Laight-ZS65k/vG3HxXrIkS9f7CXA@publi…

From: Jiri Pirko

Quoted 4 lines

This patchset can be divided into 3 main sections:
- introduce switchdev api for implementing switch drivers
- introduce switchdev generic netlink api for userspace manipulation
- introduce rocker switch driver which implements switchdev api

Quoted 6 lines

Perhaps you should be including the name of what you are switching in the name of the API?

Is this for interfacing to ethernet switches, TDM switches or mechanical ones?
It isn't really clear from any of these commit messages.

I thought that is isn't necessary, that it is clear this is about ethernet switches.

#6 lore raw
Quoted 10 lines · Jiri Pirko
Quoted 9 lines · Fri, Sep 19, 2014 at 04:15:32PM CEST, [email protected] wrote:

From: Jiri Pirko

Quoted 4 lines

This patchset can be divided into 3 main sections:
- introduce switchdev api for implementing switch drivers
- introduce switchdev generic netlink api for userspace manipulation
- introduce rocker switch driver which implements switchdev api

Perhaps you should be including the name of what you are switching in the name of the API?

Quoted 7 lines
Quoted 3 lines

Is this for interfacing to ethernet switches, TDM switches or mechanical ones?
It isn't really clear from any of these commit messages.

I thought that is isn't necessary, that it is clear this is about ethernet switches.

How about putting some of this code in net/ethernet/* to make very very obvious this is what this thing is about? --
Florian

maintainer
#7 lore raw

PATCH v2 1/9 net: rename netdev_phys_port_id to more generic name

In reply to Jiri Pirko

So this can be reused for identification of other "items" as well.

---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c |  2 +-
 drivers/net/ethernet/intel/i40e/i40e_main.c      |  2 +-
 drivers/net/ethernet/mellanox/mlx4/en_netdev.c   |  2 +-
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c |  2 +-
 include/linux/netdevice.h                        | 16 ++++++++--------
 net/core/dev.c                                   |  2 +-
 net/core/net-sysfs.c                             |  2 +-
 net/core/rtnetlink.c                             |  6 +++---
 8 files changed, 17 insertions(+), 17 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +1 -1
index 32e2444..770e3d0 100644
@@ -12425,7 +12425,7 @@ static int bnx2x_validate_addr(struct net_device *dev)
 }
 
 static int bnx2x_get_phys_port_id(struct net_device *netdev,
-				  struct netdev_phys_port_id *ppid)
+				  struct netdev_phys_item_id *ppid)
 {
 	struct bnx2x *bp = netdev_priv(netdev);
 
drivers/net/ethernet/intel/i40e/i40e_main.c +1 -1
index ed5f1c1..ab2f3e1 100644
@@ -7341,7 +7341,7 @@ static void i40e_del_vxlan_port(struct net_device *netdev,
 
 #endif
 static int i40e_get_phys_port_id(struct net_device *netdev,
-				 struct netdev_phys_port_id *ppid)
+				 struct netdev_phys_item_id *ppid)
 {
 	struct i40e_netdev_priv *np = netdev_priv(netdev);
 	struct i40e_pf *pf = np->vsi->back;
drivers/net/ethernet/mellanox/mlx4/en_netdev.c +1 -1
index abddcf8..f45e161 100644
@@ -2249,7 +2249,7 @@ static int mlx4_en_set_vf_link_state(struct net_device *dev, int vf, int link_st
 
 #define PORT_ID_BYTE_LEN 8
 static int mlx4_en_get_phys_port_id(struct net_device *dev,
-				    struct netdev_phys_port_id *ppid)
+				    struct netdev_phys_item_id *ppid)
 {
 	struct mlx4_en_priv *priv = netdev_priv(dev);
 	struct mlx4_dev *mdev = priv->mdev->dev;
drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +1 -1
index f5e29f7..6e514d2 100644
@@ -460,7 +460,7 @@ static void qlcnic_82xx_cancel_idc_work(struct qlcnic_adapter *adapter)
 }
 
 static int qlcnic_get_phys_port_id(struct net_device *netdev,
-				   struct netdev_phys_port_id *ppid)
+				   struct netdev_phys_item_id *ppid)
 {
 	struct qlcnic_adapter *adapter = netdev_priv(netdev);
 	struct qlcnic_hardware_context *ahw = adapter->ahw;
include/linux/netdevice.h +8 -8
index 28d4378..13d765f 100644
@@ -739,13 +739,13 @@ struct netdev_fcoe_hbainfo {
 };
 #endif
 
-#define MAX_PHYS_PORT_ID_LEN 32
+#define MAX_PHYS_ITEM_ID_LEN 32
 
-/* This structure holds a unique identifier to identify the
- * physical port used by a netdevice.
+/* This structure holds a unique identifier to identify some
+ * physical item (port for example) used by a netdevice.
  */
-struct netdev_phys_port_id {
-	unsigned char id[MAX_PHYS_PORT_ID_LEN];
+struct netdev_phys_item_id {
+	unsigned char id[MAX_PHYS_ITEM_ID_LEN];
 	unsigned char id_len;
 };
 
@@ -961,7 +961,7 @@ typedef u16 (*select_queue_fallback_t)(struct net_device *dev,
  *	USB_CDC_NOTIFY_NETWORK_CONNECTION) should NOT implement this function.
  *
  * int (*ndo_get_phys_port_id)(struct net_device *dev,
- *			       struct netdev_phys_port_id *ppid);
+ *			       struct netdev_phys_item_id *ppid);
  *	Called to get ID of physical port of this device. If driver does
  *	not implement this, it is assumed that the hw is not able to have
  *	multiple net devices on single physical port.
@@ -1129,7 +1129,7 @@ struct net_device_ops {
 	int			(*ndo_change_carrier)(struct net_device *dev,
 						      bool new_carrier);
 	int			(*ndo_get_phys_port_id)(struct net_device *dev,
-							struct netdev_phys_port_id *ppid);
+							struct netdev_phys_item_id *ppid);
 	void			(*ndo_add_vxlan_port)(struct  net_device *dev,
 						      sa_family_t sa_family,
 						      __be16 port);
@@ -2820,7 +2820,7 @@ void dev_set_group(struct net_device *, int);
 int dev_set_mac_address(struct net_device *, struct sockaddr *);
 int dev_change_carrier(struct net_device *, bool new_carrier);
 int dev_get_phys_port_id(struct net_device *dev,
-			 struct netdev_phys_port_id *ppid);
+			 struct netdev_phys_item_id *ppid);
 struct sk_buff *validate_xmit_skb(struct sk_buff *skb, struct net_device *dev);
 struct sk_buff *dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev,
 				    struct netdev_queue *txq, int *ret);
net/core/dev.c +1 -1
index e916ba8..38ce5b3 100644
@@ -5768,7 +5768,7 @@ EXPORT_SYMBOL(dev_change_carrier);
  *	Get device physical port ID
  */
 int dev_get_phys_port_id(struct net_device *dev,
-			 struct netdev_phys_port_id *ppid)
+			 struct netdev_phys_item_id *ppid)
 {
 	const struct net_device_ops *ops = dev->netdev_ops;
 
net/core/net-sysfs.c +1 -1
index 9dd0669..55dc4da 100644
@@ -387,7 +387,7 @@ static ssize_t phys_port_id_show(struct device *dev,
 		return restart_syscall();
 
 	if (dev_isalive(netdev)) {
-		struct netdev_phys_port_id ppid;
+		struct netdev_phys_item_id ppid;
 
 		ret = dev_get_phys_port_id(netdev, &ppid);
 		if (!ret)
net/core/rtnetlink.c +3 -3
index a688268..1087c6d 100644
@@ -868,7 +868,7 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev,
 	       + rtnl_port_size(dev, ext_filter_mask) /* IFLA_VF_PORTS + IFLA_PORT_SELF */
 	       + rtnl_link_get_size(dev) /* IFLA_LINKINFO */
 	       + rtnl_link_get_af_size(dev) /* IFLA_AF_SPEC */
-	       + nla_total_size(MAX_PHYS_PORT_ID_LEN); /* IFLA_PHYS_PORT_ID */
+	       + nla_total_size(MAX_PHYS_ITEM_ID_LEN); /* IFLA_PHYS_PORT_ID */
 }
 
 static int rtnl_vf_ports_fill(struct sk_buff *skb, struct net_device *dev)
@@ -952,7 +952,7 @@ static int rtnl_port_fill(struct sk_buff *skb, struct net_device *dev,
 static int rtnl_phys_port_id_fill(struct sk_buff *skb, struct net_device *dev)
 {
 	int err;
-	struct netdev_phys_port_id ppid;
+	struct netdev_phys_item_id ppid;
 
 	err = dev_get_phys_port_id(dev, &ppid);
 	if (err) {
@@ -1196,7 +1196,7 @@ static const struct nla_policy ifla_policy[IFLA_MAX+1] = {
 	[IFLA_PROMISCUITY]	= { .type = NLA_U32 },
 	[IFLA_NUM_TX_QUEUES]	= { .type = NLA_U32 },
 	[IFLA_NUM_RX_QUEUES]	= { .type = NLA_U32 },
-	[IFLA_PHYS_PORT_ID]	= { .type = NLA_BINARY, .len = MAX_PHYS_PORT_ID_LEN },
+	[IFLA_PHYS_PORT_ID]	= { .type = NLA_BINARY, .len = MAX_PHYS_ITEM_ID_LEN },
 	[IFLA_CARRIER_CHANGES]	= { .type = NLA_U32 },  /* ignored */
 };
 
Signature · 1 line
1.9.3

A message that is not in the archive (sent off-list or not yet received): 1411134590-4586-2-git-send-email-jiri-rHqAuBHg3fBzbRFIqnYvSA@public.gmane.org

Acked-by
#9 lore raw

Re: [patch net-next v2 1/9] net: rename netdev_phys_port_id to more generic name

Quoted 14 lines · Jiri Pirko

So this can be reused for identification of other "items" as well.

---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c |  2 +-
 drivers/net/ethernet/intel/i40e/i40e_main.c      |  2 +-
 drivers/net/ethernet/mellanox/mlx4/en_netdev.c   |  2 +-
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c |  2 +-
 include/linux/netdevice.h                        | 16
++++++++--------
 net/core/dev.c                                   |  2 +-
 net/core/net-sysfs.c                             |  2 +-
 net/core/rtnetlink.c                             |  6 +++---
 8 files changed, 17 insertions(+), 17 deletions(-)

With regards to the i40e changes.

maintainer
#10 lore raw

PATCH v2 3/9 rtnl: expose physical switch id for particular device

In reply to Jiri Pirko

The netdevice represents a port in a switch, it will expose IFLA_PHYS_SWITCH_ID value via rtnl. Two netdevices with the same value belong to one physical switch.

---
 include/uapi/linux/if_link.h |  1 +
 net/core/rtnetlink.c         | 26 +++++++++++++++++++++++++-
 2 files changed, 26 insertions(+), 1 deletion(-)
include/uapi/linux/if_link.h +1 -0
index c80f95f..c5ca3b9 100644
@@ -145,6 +145,7 @@ enum {
 	IFLA_CARRIER,
 	IFLA_PHYS_PORT_ID,
 	IFLA_CARRIER_CHANGES,
+	IFLA_PHYS_SWITCH_ID,
 	__IFLA_MAX
 };
 
net/core/rtnetlink.c +25 -1
index 1087c6d..8947297 100644
@@ -43,6 +43,7 @@
 
 #include <linux/inet.h>
 #include <linux/netdevice.h>
+#include <net/switchdev.h>
 #include <net/ip.h>
 #include <net/protocol.h>
 #include <net/arp.h>
@@ -868,7 +869,8 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev,
 	       + rtnl_port_size(dev, ext_filter_mask) /* IFLA_VF_PORTS + IFLA_PORT_SELF */
 	       + rtnl_link_get_size(dev) /* IFLA_LINKINFO */
 	       + rtnl_link_get_af_size(dev) /* IFLA_AF_SPEC */
-	       + nla_total_size(MAX_PHYS_ITEM_ID_LEN); /* IFLA_PHYS_PORT_ID */
+	       + nla_total_size(MAX_PHYS_ITEM_ID_LEN) /* IFLA_PHYS_PORT_ID */
+	       + nla_total_size(MAX_PHYS_ITEM_ID_LEN); /* IFLA_PHYS_SWITCH_ID */
 }
 
 static int rtnl_vf_ports_fill(struct sk_buff *skb, struct net_device *dev)
@@ -967,6 +969,24 @@ static int rtnl_phys_port_id_fill(struct sk_buff *skb, struct net_device *dev)
 	return 0;
 }
 
+static int rtnl_phys_switch_id_fill(struct sk_buff *skb, struct net_device *dev)
+{
+	int err;
+	struct netdev_phys_item_id psid;
+
+	err = swdev_id_get(dev, &psid);
+	if (err) {
+		if (err == -EOPNOTSUPP)
+			return 0;
+		return err;
+	}
+
+	if (nla_put(skb, IFLA_PHYS_SWITCH_ID, psid.id_len, psid.id))
+		return -EMSGSIZE;
+
+	return 0;
+}
+
 static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
 			    int type, u32 pid, u32 seq, u32 change,
 			    unsigned int flags, u32 ext_filter_mask)
@@ -1039,6 +1059,9 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
 	if (rtnl_phys_port_id_fill(skb, dev))
 		goto nla_put_failure;
 
+	if (rtnl_phys_switch_id_fill(skb, dev))
+		goto nla_put_failure;
+
 	attr = nla_reserve(skb, IFLA_STATS,
 			sizeof(struct rtnl_link_stats));
 	if (attr == NULL)
@@ -1198,6 +1221,7 @@ static const struct nla_policy ifla_policy[IFLA_MAX+1] = {
 	[IFLA_NUM_RX_QUEUES]	= { .type = NLA_U32 },
 	[IFLA_PHYS_PORT_ID]	= { .type = NLA_BINARY, .len = MAX_PHYS_ITEM_ID_LEN },
 	[IFLA_CARRIER_CHANGES]	= { .type = NLA_U32 },  /* ignored */
+	[IFLA_PHYS_SWITCH_ID]	= { .type = NLA_BINARY, .len = MAX_PHYS_ITEM_ID_LEN },
 };
 
 static const struct nla_policy ifla_info_policy[IFLA_INFO_MAX+1] = {
Signature · 1 line
1.9.3
maintainer
#11 lore raw

PATCH v2 4/9 net-sysfs: expose physical switch id for particular device

In reply to Jiri Pirko
---
 net/core/net-sysfs.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
net/core/net-sysfs.c +24 -0
index 55dc4da..87b97bc 100644
@@ -12,6 +12,7 @@
 #include <linux/capability.h>
 #include <linux/kernel.h>
 #include <linux/netdevice.h>
+#include <net/switchdev.h>
 #include <linux/if_arp.h>
 #include <linux/slab.h>
 #include <linux/nsproxy.h>
@@ -399,6 +400,28 @@ static ssize_t phys_port_id_show(struct device *dev,
 }
 static DEVICE_ATTR_RO(phys_port_id);
 
+static ssize_t phys_switch_id_show(struct device *dev,
+				   struct device_attribute *attr, char *buf)
+{
+	struct net_device *netdev = to_net_dev(dev);
+	ssize_t ret = -EINVAL;
+
+	if (!rtnl_trylock())
+		return restart_syscall();
+
+	if (dev_isalive(netdev)) {
+		struct netdev_phys_item_id ppid;
+
+		ret = swdev_id_get(netdev, &ppid);
+		if (!ret)
+			ret = sprintf(buf, "%*phN\n", ppid.id_len, ppid.id);
+	}
+	rtnl_unlock();
+
+	return ret;
+}
+static DEVICE_ATTR_RO(phys_switch_id);
+
 static struct attribute *net_class_attrs[] = {
 	&dev_attr_netdev_group.attr,
 	&dev_attr_type.attr,
@@ -423,6 +446,7 @@ static struct attribute *net_class_attrs[] = {
 	&dev_attr_flags.attr,
 	&dev_attr_tx_queue_len.attr,
 	&dev_attr_phys_port_id.attr,
+	&dev_attr_phys_switch_id.attr,
 	NULL,
 };
 ATTRIBUTE_GROUPS(net_class);
Signature · 1 line
1.9.3
maintainer
#12 lore raw

PATCH v2 5/9 net: introduce dummy switch

In reply to Jiri Pirko

Dummy switch implementation using switchdev interface

---
 drivers/net/Kconfig          |   7 +++
 drivers/net/Makefile         |   1 +
 drivers/net/dummyswitch.c    | 130 +++++++++++++++++++++++++++++++++++++++++++
 include/uapi/linux/if_link.h |   9 +++
 4 files changed, 147 insertions(+)
 create mode 100644 drivers/net/dummyswitch.c
drivers/net/Kconfig +7 -0
index c6f6f69..7822c74 100644
@@ -71,6 +71,13 @@ config DUMMY
 	  To compile this driver as a module, choose M here: the module
 	  will be called dummy.
 
+config NET_DUMMY_SWITCH
+	tristate "Dummy switch net driver support"
+	depends on NET_SWITCHDEV
+	---help---
+	  To compile this driver as a module, choose M here: the module
+	  will be called dummyswitch.
+
 config EQUALIZER
 	tristate "EQL (serial line load balancing) support"
 	---help---
drivers/net/Makefile +1 -0
index 61aefdd..3c835ba 100644
@@ -7,6 +7,7 @@
 #
 obj-$(CONFIG_BONDING) += bonding/
 obj-$(CONFIG_DUMMY) += dummy.o
+obj-$(CONFIG_NET_DUMMY_SWITCH) += dummyswitch.o
 obj-$(CONFIG_EQUALIZER) += eql.o
 obj-$(CONFIG_IFB) += ifb.o
 obj-$(CONFIG_MACVLAN) += macvlan.o
drivers/net/dummyswitch.c new file +130 -0

130 lines not on this page · raw message

include/uapi/linux/if_link.h +9 -0
index c5ca3b9..bd24d69 100644
@@ -574,4 +574,13 @@ enum {
 
 #define IFLA_HSR_MAX (__IFLA_HSR_MAX - 1)
 
+/* DUMMYSWPORT section */
+enum {
+	IFLA_DUMMYSWPORT_UNSPEC,
+	IFLA_DUMMYSWPORT_PHYS_SWITCH_ID,
+	__IFLA_DUMMYSWPORT_MAX,
+};
+
+#define IFLA_DUMMYSWPORT_MAX (__IFLA_DUMMYSWPORT_MAX - 1)
+
 #endif /* _UAPI_LINUX_IF_LINK_H */
Signature · 1 line
1.9.3

A message that is not in the archive (sent off-list or not yet received): 1411134590-4586-6-git-send-email-jiri-rHqAuBHg3fBzbRFIqnYvSA@public.gmane.org

#14 lore raw

Re: [patch net-next v2 5/9] net: introduce dummy switch

Quoted 1 line · Jiri Pirko

Dummy switch implementation using switchdev interface

This really looks like a DSA driver that has 0 ports, and is not attached to an useful network interface, and which is registering its own set of rtnl operations for a purpose that is unclear to me.

I think registering these rtnl ops is misleading as it leads to a false idea that this is allowed, and that people are actually encouraged to do that for custom switch drivers, and this completely defeats the purpose of coming up with a generic API.

If we are to go that route anyway, I really prefer the way Felix did it in swconfig, and the fake switch driver did do something useful being attached to the loopback interface:

http://lists.openwall.net/netdev/2013/10/22/103
http://patchwork.ozlabs.org/patch/285478/

Quoted 195 lines
---
  drivers/net/Kconfig          |   7 +++
  drivers/net/Makefile         |   1 +
  drivers/net/dummyswitch.c    | 130 +++++++++++++++++++++++++++++++++++++++++++
  include/uapi/linux/if_link.h |   9 +++
  4 files changed, 147 insertions(+)

create mode 100644 drivers/net/dummyswitch.c

drivers/net/Kconfig +7 -0
index c6f6f69..7822c74 100644
@@ -71,6 +71,13 @@ config DUMMY
  	  To compile this driver as a module, choose M here: the module
  	  will be called dummy.
 
+config NET_DUMMY_SWITCH
+	tristate "Dummy switch net driver support"
+	depends on NET_SWITCHDEV
+	---help---
+	  To compile this driver as a module, choose M here: the module
+	  will be called dummyswitch.
+
  config EQUALIZER
  	tristate "EQL (serial line load balancing) support"
  	---help---
drivers/net/Makefile +1 -0
index 61aefdd..3c835ba 100644
@@ -7,6 +7,7 @@
  #
  obj-$(CONFIG_BONDING) += bonding/
  obj-$(CONFIG_DUMMY) += dummy.o
+obj-$(CONFIG_NET_DUMMY_SWITCH) += dummyswitch.o
  obj-$(CONFIG_EQUALIZER) += eql.o
  obj-$(CONFIG_IFB) += ifb.o
  obj-$(CONFIG_MACVLAN) += macvlan.o
drivers/net/dummyswitch.c new file +130 -0
new file mode 100644
index 0000000..e7a48f4
@@ -0,0 +1,130 @@
+/*
+ * drivers/net/dummyswitch.c - Dummy switch device
+ * Copyright (c) 2014 Jiri Pirko <[email protected]>
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
+#include <net/rtnetlink.h>
+
+struct dummyswport_priv {
+	struct netdev_phys_item_id psid;
+};
+
+static netdev_tx_t dummyswport_start_xmit(struct sk_buff *skb,
+					  struct net_device *dev)
+{
+	dev_kfree_skb(skb);
+	return NETDEV_TX_OK;
+}
+
+static int dummyswport_swdev_id_get(struct net_device *dev,
+				    struct netdev_phys_item_id *psid)
+{
+	struct dummyswport_priv *dsp = netdev_priv(dev);
+
+	memcpy(psid, &dsp->psid, sizeof(*psid));
+	return 0;
+}
+
+static int dummyswport_change_carrier(struct net_device *dev, bool new_carrier)
+{
+	if (new_carrier)
+		netif_carrier_on(dev);
+	else
+		netif_carrier_off(dev);
+	return 0;
+}
+
+static const struct net_device_ops dummyswport_netdev_ops = {
+	.ndo_start_xmit		= dummyswport_start_xmit,
+	.ndo_swdev_id_get	= dummyswport_swdev_id_get,
+	.ndo_change_carrier	= dummyswport_change_carrier,
+};
+
+static void dummyswport_setup(struct net_device *dev)
+{
+	ether_setup(dev);
+
+	/* Initialize the device structure. */
+	dev->netdev_ops = &dummyswport_netdev_ops;
+	dev->destructor = free_netdev;
+
+	/* Fill in device structure with ethernet-generic values. */
+	dev->tx_queue_len = 0;
+	dev->flags |= IFF_NOARP;
+	dev->flags &= ~IFF_MULTICAST;
+	dev->priv_flags |= IFF_LIVE_ADDR_CHANGE;
+	dev->features	|= NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_TSO;
+	dev->features	|= NETIF_F_HW_CSUM | NETIF_F_HIGHDMA | NETIF_F_LLTX;
+	eth_hw_addr_random(dev);
+}
+
+static int dummyswport_validate(struct nlattr *tb[], struct nlattr *data[])
+{
+	if (tb[IFLA_ADDRESS])
+		return -EINVAL;
+	if (!data || !data[IFLA_DUMMYSWPORT_PHYS_SWITCH_ID])
+		return -EINVAL;
+	return 0;
+}
+
+static int dummyswport_newlink(struct net *src_net, struct net_device *dev,
+			       struct nlattr *tb[], struct nlattr *data[])
+{
+	struct dummyswport_priv *dsp = netdev_priv(dev);
+	int err;
+
+	dsp->psid.id_len = nla_len(data[IFLA_DUMMYSWPORT_PHYS_SWITCH_ID]);
+	memcpy(dsp->psid.id, nla_data(data[IFLA_DUMMYSWPORT_PHYS_SWITCH_ID]),
+	       dsp->psid.id_len);
+
+	err = register_netdevice(dev);
+	if (err)
+		return err;
+
+	netif_carrier_on(dev);
+
+	return 0;
+}
+
+static const struct nla_policy dummyswport_policy[IFLA_DUMMYSWPORT_MAX + 1] = {
+	[IFLA_DUMMYSWPORT_PHYS_SWITCH_ID] = { .type = NLA_BINARY,
+					      .len = MAX_PHYS_ITEM_ID_LEN },
+};
+
+static struct rtnl_link_ops dummyswport_link_ops __read_mostly = {
+	.kind		= "dummyswport",
+	.priv_size	= sizeof(struct dummyswport_priv),
+	.setup		= dummyswport_setup,
+	.validate	= dummyswport_validate,
+	.newlink	= dummyswport_newlink,
+	.policy		= dummyswport_policy,
+	.maxtype	= IFLA_DUMMYSWPORT_MAX,
+};
+
+static int __init dummysw_module_init(void)
+{
+	return rtnl_link_register(&dummyswport_link_ops);
+}
+
+static void __exit dummysw_module_exit(void)
+{
+	rtnl_link_unregister(&dummyswport_link_ops);
+}
+
+module_init(dummysw_module_init);
+module_exit(dummysw_module_exit);
+
+MODULE_LICENSE("GPL v2");
+MODULE_AUTHOR("Jiri Pirko <[email protected]>");
+MODULE_DESCRIPTION("Dummy switch device");
+MODULE_ALIAS_RTNL_LINK("dummyswport");
include/uapi/linux/if_link.h +9 -0
index c5ca3b9..bd24d69 100644
@@ -574,4 +574,13 @@ enum {
 
  #define IFLA_HSR_MAX (__IFLA_HSR_MAX - 1)
 
+/* DUMMYSWPORT section */
+enum {
+	IFLA_DUMMYSWPORT_UNSPEC,
+	IFLA_DUMMYSWPORT_PHYS_SWITCH_ID,
+	__IFLA_DUMMYSWPORT_MAX,
+};
+
+#define IFLA_DUMMYSWPORT_MAX (__IFLA_DUMMYSWPORT_MAX - 1)
+
  #endif /* _UAPI_LINUX_IF_LINK_H */
maintainer
#15 lore raw

Re: [patch net-next v2 5/9] net: introduce dummy switch

Quoted 12 lines · Sat, Sep 20, 2014 at 07:21:00AM CEST, [email protected] wrote:
Quoted 1 line · Jiri Pirko

Dummy switch implementation using switchdev interface

This really looks like a DSA driver that has 0 ports, and is not attached to an useful network interface, and which is registering its own set of rtnl operations for a purpose that is unclear to me.

I think registering these rtnl ops is misleading as it leads to a false idea that this is allowed, and that people are actually encouraged to do that for custom switch drivers, and this completely defeats the purpose of coming up with a generic API.

Quoted 6 lines

If we are to go that route anyway, I really prefer the way Felix did it in swconfig, and the fake switch driver did do something useful being attached to the loopback interface:

http://lists.openwall.net/netdev/2013/10/22/103
http://patchwork.ozlabs.org/patch/285478/

I will drop dummyswitch because it serves primary as an example. But since rocker is here, this is no longer needed.

Quoted 197 lines
Quoted 196 lines
---
 drivers/net/Kconfig          |   7 +++
 drivers/net/Makefile         |   1 +
 drivers/net/dummyswitch.c    | 130 +++++++++++++++++++++++++++++++++++++++++++
 include/uapi/linux/if_link.h |   9 +++
 4 files changed, 147 insertions(+)
 create mode 100644 drivers/net/dummyswitch.c
drivers/net/Kconfig +7 -0
index c6f6f69..7822c74 100644
@@ -71,6 +71,13 @@ config DUMMY
 	  To compile this driver as a module, choose M here: the module
 	  will be called dummy.
 
+config NET_DUMMY_SWITCH
+	tristate "Dummy switch net driver support"
+	depends on NET_SWITCHDEV
+	---help---
+	  To compile this driver as a module, choose M here: the module
+	  will be called dummyswitch.
+
 config EQUALIZER
 	tristate "EQL (serial line load balancing) support"
 	---help---
drivers/net/Makefile +1 -0
index 61aefdd..3c835ba 100644
@@ -7,6 +7,7 @@
 #
 obj-$(CONFIG_BONDING) += bonding/
 obj-$(CONFIG_DUMMY) += dummy.o
+obj-$(CONFIG_NET_DUMMY_SWITCH) += dummyswitch.o
 obj-$(CONFIG_EQUALIZER) += eql.o
 obj-$(CONFIG_IFB) += ifb.o
 obj-$(CONFIG_MACVLAN) += macvlan.o
drivers/net/dummyswitch.c new file +130 -0
new file mode 100644
index 0000000..e7a48f4
@@ -0,0 +1,130 @@
+/*
+ * drivers/net/dummyswitch.c - Dummy switch device
+ * Copyright (c) 2014 Jiri Pirko <[email protected]>
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
+#include <net/rtnetlink.h>
+
+struct dummyswport_priv {
+	struct netdev_phys_item_id psid;
+};
+
+static netdev_tx_t dummyswport_start_xmit(struct sk_buff *skb,
+					  struct net_device *dev)
+{
+	dev_kfree_skb(skb);
+	return NETDEV_TX_OK;
+}
+
+static int dummyswport_swdev_id_get(struct net_device *dev,
+				    struct netdev_phys_item_id *psid)
+{
+	struct dummyswport_priv *dsp = netdev_priv(dev);
+
+	memcpy(psid, &dsp->psid, sizeof(*psid));
+	return 0;
+}
+
+static int dummyswport_change_carrier(struct net_device *dev, bool new_carrier)
+{
+	if (new_carrier)
+		netif_carrier_on(dev);
+	else
+		netif_carrier_off(dev);
+	return 0;
+}
+
+static const struct net_device_ops dummyswport_netdev_ops = {
+	.ndo_start_xmit		= dummyswport_start_xmit,
+	.ndo_swdev_id_get	= dummyswport_swdev_id_get,
+	.ndo_change_carrier	= dummyswport_change_carrier,
+};
+
+static void dummyswport_setup(struct net_device *dev)
+{
+	ether_setup(dev);
+
+	/* Initialize the device structure. */
+	dev->netdev_ops = &dummyswport_netdev_ops;
+	dev->destructor = free_netdev;
+
+	/* Fill in device structure with ethernet-generic values. */
+	dev->tx_queue_len = 0;
+	dev->flags |= IFF_NOARP;
+	dev->flags &= ~IFF_MULTICAST;
+	dev->priv_flags |= IFF_LIVE_ADDR_CHANGE;
+	dev->features	|= NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_TSO;
+	dev->features	|= NETIF_F_HW_CSUM | NETIF_F_HIGHDMA | NETIF_F_LLTX;
+	eth_hw_addr_random(dev);
+}
+
+static int dummyswport_validate(struct nlattr *tb[], struct nlattr *data[])
+{
+	if (tb[IFLA_ADDRESS])
+		return -EINVAL;
+	if (!data || !data[IFLA_DUMMYSWPORT_PHYS_SWITCH_ID])
+		return -EINVAL;
+	return 0;
+}
+
+static int dummyswport_newlink(struct net *src_net, struct net_device *dev,
+			       struct nlattr *tb[], struct nlattr *data[])
+{
+	struct dummyswport_priv *dsp = netdev_priv(dev);
+	int err;
+
+	dsp->psid.id_len = nla_len(data[IFLA_DUMMYSWPORT_PHYS_SWITCH_ID]);
+	memcpy(dsp->psid.id, nla_data(data[IFLA_DUMMYSWPORT_PHYS_SWITCH_ID]),
+	       dsp->psid.id_len);
+
+	err = register_netdevice(dev);
+	if (err)
+		return err;
+
+	netif_carrier_on(dev);
+
+	return 0;
+}
+
+static const struct nla_policy dummyswport_policy[IFLA_DUMMYSWPORT_MAX + 1] = {
+	[IFLA_DUMMYSWPORT_PHYS_SWITCH_ID] = { .type = NLA_BINARY,
+					      .len = MAX_PHYS_ITEM_ID_LEN },
+};
+
+static struct rtnl_link_ops dummyswport_link_ops __read_mostly = {
+	.kind		= "dummyswport",
+	.priv_size	= sizeof(struct dummyswport_priv),
+	.setup		= dummyswport_setup,
+	.validate	= dummyswport_validate,
+	.newlink	= dummyswport_newlink,
+	.policy		= dummyswport_policy,
+	.maxtype	= IFLA_DUMMYSWPORT_MAX,
+};
+
+static int __init dummysw_module_init(void)
+{
+	return rtnl_link_register(&dummyswport_link_ops);
+}
+
+static void __exit dummysw_module_exit(void)
+{
+	rtnl_link_unregister(&dummyswport_link_ops);
+}
+
+module_init(dummysw_module_init);
+module_exit(dummysw_module_exit);
+
+MODULE_LICENSE("GPL v2");
+MODULE_AUTHOR("Jiri Pirko <[email protected]>");
+MODULE_DESCRIPTION("Dummy switch device");
+MODULE_ALIAS_RTNL_LINK("dummyswport");
include/uapi/linux/if_link.h +9 -0
index c5ca3b9..bd24d69 100644
@@ -574,4 +574,13 @@ enum {
 
 #define IFLA_HSR_MAX (__IFLA_HSR_MAX - 1)
 
+/* DUMMYSWPORT section */
+enum {
+	IFLA_DUMMYSWPORT_UNSPEC,
+	IFLA_DUMMYSWPORT_PHYS_SWITCH_ID,
+	__IFLA_DUMMYSWPORT_MAX,
+};
+
+#define IFLA_DUMMYSWPORT_MAX (__IFLA_DUMMYSWPORT_MAX - 1)
+
 #endif /* _UAPI_LINUX_IF_LINK_H */
maintainer
#16 lore raw

PATCH v2 6/9 switchdev: add basic support for flow matching and actions

In reply to Jiri Pirko

This patch adds basic support for flows. The infrastructure is prepared to easily add another flow matching types. So far, only the key one is implemented.

---
 include/linux/netdevice.h |  16 ++++++
 include/net/switchdev.h   | 113 ++++++++++++++++++++++++++++++++++++++++++
 net/switchdev/switchdev.c | 123 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 252 insertions(+)
include/linux/netdevice.h +16 -0
index b290dcf..034baca 100644
@@ -1005,6 +1005,18 @@ typedef u16 (*select_queue_fallback_t)(struct net_device *dev,
  *	Called to get an ID of the switch chip this port is part of.
  *	If driver implements this, it indicates that it represents a port
  *	of a switch chip.
+ *
+ * int (*ndo_swdev_flow_insert)(struct net_device *dev,
+ *				const struct swdev_flow *flow);
+ *	Called to insert a flow into switch device. If driver does
+ *	not implement this, it is assumed that the hw does not have
+ *	a capability to work with flows.
+ *
+ * int (*ndo_swdev_flow_remove)(struct net_device *dev,
+ *				const struct swdev_flow *flow);
+ *	Called to remove a flow from switch device. If driver does
+ *	not implement this, it is assumed that the hw does not have
+ *	a capability to work with flows.
  */
 struct net_device_ops {
 	int			(*ndo_init)(struct net_device *dev);
@@ -1157,6 +1169,10 @@ struct net_device_ops {
 #ifdef CONFIG_NET_SWITCHDEV
 	int			(*ndo_swdev_id_get)(struct net_device *dev,
 						    struct netdev_phys_item_id *psid);
+	int			(*ndo_swdev_flow_insert)(struct net_device *dev,
+							 const struct swdev_flow *flow);
+	int			(*ndo_swdev_flow_remove)(struct net_device *dev,
+							 const struct swdev_flow *flow);
 #endif
 };
 
include/net/switchdev.h +113 -0

128 lines not on this page · raw message

net/switchdev/switchdev.c +123 -0

126 lines not on this page · raw message

Signature · 1 line
1.9.3
#17 lore raw

Re: [patch net-next v2 6/9] switchdev: add basic support for flow matching and actions

Quoted 6 lines · Jiri Pirko

This patch adds basic support for flows. The infrastructure is prepared to easily add another flow matching types. So far, only the key one is implemented.

---

[snip]

include/net/switchdev.h line 23

Quoted 10 lines
include/net/switchdev.h +9 -0
+struct swdev_flow_match_key {
+	struct {
+		u32	priority;	/* Packet QoS priority. */
+		u32	in_port_ifindex; /* Input switch port ifindex (or 0). */
+	} phy;
+	struct {
+		u8     src[ETH_ALEN];	/* Ethernet source address. */
+		u8     dst[ETH_ALEN];	/* Ethernet destination address. */
+		__be16 tci;		/* 0 if no VLAN, VLAN_TAG_PRESENT set otherwise. */

Humm, how about QinQ here? I would provision two more 16 bits fields so we can do all sorts of VLAN matching.

You might want to allow for a 4 to 8 bytes hardware switch tag as well.

include/net/switchdev.h line 30

Quoted 7 lines
include/net/switchdev.h +7 -0
+		__be16 type;		/* Ethernet frame type. */
+	} eth;
+	struct {
+		u8     proto;		/* IP protocol or lower 8 bits of ARP opcode. */
+		u8     tos;		/* IP ToS. */
+		u8     ttl;		/* IP TTL/hop limit. */
+		u8     frag;		/* One of OVS_FRAG_TYPE_*. */

Options might be missing?

[snip]

net/switchdev/switchdev.c int swdev_id_get(struct net_device *dev, struct netdev_phys_item_id *psid) · line 117

Quoted 8 lines
net/switchdev/switchdev.c +8 -0
+
+static void print_flow(const struct swdev_flow *flow, struct net_device *dev,
+		       const char *comment)
+{
+	pr_debug("%s flow %s:\n", dev->name, comment);
+	print_flow_match(&flow->match);
+	print_flow_actions(flow->action, flow->action_count);
+}

I am really not sure how much of this valuable besides early (as in, right now) debugging, don't we rather want a generic way to dump a given flow under a its native netlink format, does that code has to be here in the first place? --
Florian

maintainer
#18 lore raw

Re: [patch net-next v2 6/9] switchdev: add basic support for flow matching and actions

Quoted 24 lines · Sat, Sep 20, 2014 at 07:32:08AM CEST, [email protected] wrote:
Quoted 6 lines · Jiri Pirko

This patch adds basic support for flows. The infrastructure is prepared to easily add another flow matching types. So far, only the key one is implemented.

---

[snip]

include/net/switchdev.h line 23

Quoted 10 lines
include/net/switchdev.h +9 -0
+struct swdev_flow_match_key {
+	struct {
+		u32	priority;	/* Packet QoS priority. */
+		u32	in_port_ifindex; /* Input switch port ifindex (or 0). */
+	} phy;
+	struct {
+		u8     src[ETH_ALEN];	/* Ethernet source address. */
+		u8     dst[ETH_ALEN];	/* Ethernet destination address. */
+		__be16 tci;		/* 0 if no VLAN, VLAN_TAG_PRESENT set otherwise. */

Humm, how about QinQ here? I would provision two more 16 bits fields so we can do all sorts of VLAN matching.

Quoted 1 line

You might want to allow for a 4 to 8 bytes hardware switch tag as well.

Note this structure is not carved in stone and can be easily adjusted without any problems any time. So when the time comes and the changes you are describing will be needed, we can do it.

Quoted 13 lines

include/net/switchdev.h line 30

Quoted 8 lines
include/net/switchdev.h +7 -0
+		__be16 type;		/* Ethernet frame type. */
+	} eth;
+	struct {
+		u8     proto;		/* IP protocol or lower 8 bits of ARP opcode. */
+		u8     tos;		/* IP ToS. */
+		u8     ttl;		/* IP TTL/hop limit. */
+		u8     frag;		/* One of OVS_FRAG_TYPE_*. */

Options might be missing?

[snip]

Quoted 13 lines

net/switchdev/switchdev.c int swdev_id_get(struct net_device *dev, struct netdev_phys_item_id *psid) · line 117

Quoted 8 lines
net/switchdev/switchdev.c +8 -0
+
+static void print_flow(const struct swdev_flow *flow, struct net_device *dev,
+		       const char *comment)
+{
+	pr_debug("%s flow %s:\n", dev->name, comment);
+	print_flow_match(&flow->match);
+	print_flow_actions(flow->action, flow->action_count);
+}

I am really not sure how much of this valuable besides early (as in, right now) debugging, don't we rather want a generic way to dump a given flow under a its native netlink format, does that code has to be here in the first place?

Hmm, I think you have a point here, let me think about that.

Quoted 2 lines

--
Florian

maintainer
#19 lore raw

PATCH v2 7/9 switchdev: add swdev features

In reply to Jiri Pirko

Driver should define ndo_swdev_festures_get and indicate which switch features it supports.

---
 include/linux/netdevice.h |  5 +++++
 include/net/switchdev.h   | 18 ++++++++++++++++++
 net/switchdev/switchdev.c | 33 +++++++++++++++++++++++++++++++++
 3 files changed, 56 insertions(+)
include/linux/netdevice.h +5 -0
index 034baca..b87d0cc 100644
@@ -1006,6 +1006,10 @@ typedef u16 (*select_queue_fallback_t)(struct net_device *dev,
  *	If driver implements this, it indicates that it represents a port
  *	of a switch chip.
  *
+ * swdev_features_t (*ndo_swdev_features_get)(struct net_device *dev);
+ *	Called to get a list of features the switch chip this port is part of
+ *	supports.
+ *
  * int (*ndo_swdev_flow_insert)(struct net_device *dev,
  *				const struct swdev_flow *flow);
  *	Called to insert a flow into switch device. If driver does
@@ -1169,6 +1173,7 @@ struct net_device_ops {
 #ifdef CONFIG_NET_SWITCHDEV
 	int			(*ndo_swdev_id_get)(struct net_device *dev,
 						    struct netdev_phys_item_id *psid);
+	swdev_features_t	(*ndo_swdev_features_get)(struct net_device *dev);
 	int			(*ndo_swdev_flow_insert)(struct net_device *dev,
 							 const struct swdev_flow *flow);
 	int			(*ndo_swdev_flow_remove)(struct net_device *dev,
include/net/switchdev.h +18 -0
index 060d3fc..91cdb47 100644
@@ -12,6 +12,18 @@
 
 #include <linux/netdevice.h>
 
+typedef u64 swdev_features_t;
+
+enum {
+	SWDEV_F_FLOW_MATCH_KEY_BIT,	/* Supports fixed key match */
+	/**/SWDEV_FEATURE_COUNT
+};
+
+#define __SWDEV_F_BIT(bit)	((swdev_features_t)1 << (bit))
+#define __SWDEV_F(name)		__SWDEV_F_BIT(SWDEV_F_##name##_BIT)
+
+#define SWDEV_F_FLOW_MATCH_KEY	__SWDEV_F(FLOW_MATCH_KEY)
+
 struct swdev_flow_match_key {
 	struct {
 		u32	priority;	/* Packet QoS priority. */
@@ -114,6 +126,7 @@ static inline struct swdev_flow *swdev_flow_alloc(unsigned action_count,
 #ifdef CONFIG_NET_SWITCHDEV
 
 int swdev_id_get(struct net_device *dev, struct netdev_phys_item_id *psid);
+swdev_features_t swdev_features_get(struct net_device *dev);
 int swdev_flow_insert(struct net_device *dev, const struct swdev_flow *flow);
 int swdev_flow_remove(struct net_device *dev, const struct swdev_flow *flow);
 
@@ -125,6 +138,11 @@ static inline int swdev_id_get(struct net_device *dev,
 	return -EOPNOTSUPP;
 }
 
+static inline swdev_features_t swdev_features_get(struct net_device *dev)
+{
+	return 0;
+}
+
 static inline int swdev_flow_insert(struct net_device *dev,
 				    const struct swdev_flow *flow)
 {
net/switchdev/switchdev.c +33 -0
index 90bc5e4..5348125 100644
@@ -31,6 +31,22 @@ int swdev_id_get(struct net_device *dev, struct netdev_phys_item_id *psid)
 }
 EXPORT_SYMBOL(swdev_id_get);
 
+/**
+ *	swdev_features_get - Get list of features switch supports
+ *	@dev: port device
+ *
+ *	Get list of features switch this port is part of supports.
+ */
+swdev_features_t swdev_features_get(struct net_device *dev)
+{
+	const struct net_device_ops *ops = dev->netdev_ops;
+
+	if (!ops->ndo_swdev_features_get)
+		return 0;
+	return ops->ndo_swdev_features_get(dev);
+}
+EXPORT_SYMBOL(swdev_features_get);
+
 static void print_flow_key_phy(const char *prefix,
 			       const struct swdev_flow_match_key *key)
 {
@@ -116,6 +132,15 @@ static void print_flow(const struct swdev_flow *flow, struct net_device *dev,
 	print_flow_actions(flow->action, flow->action_count);
 }
 
+static int check_match_type_features(struct net_device *dev,
+				     const struct swdev_flow *flow)
+{
+	if (flow->match.type == SW_FLOW_MATCH_TYPE_KEY &&
+	    !(swdev_features_get(dev) & SWDEV_F_FLOW_MATCH_KEY))
+		return -EOPNOTSUPP;
+	return 0;
+}
+
 /**
  *	swdev_flow_insert - Insert a flow into switch
  *	@dev: port device
@@ -126,10 +151,14 @@ static void print_flow(const struct swdev_flow *flow, struct net_device *dev,
 int swdev_flow_insert(struct net_device *dev, const struct swdev_flow *flow)
 {
 	const struct net_device_ops *ops = dev->netdev_ops;
+	int err;
 
 	print_flow(flow, dev, "insert");
 	if (!ops->ndo_swdev_flow_insert)
 		return -EOPNOTSUPP;
+	err = check_match_type_features(dev, flow);
+	if (err)
+		return err;
 	WARN_ON(!ops->ndo_swdev_id_get);
 	return ops->ndo_swdev_flow_insert(dev, flow);
 }
@@ -145,10 +174,14 @@ EXPORT_SYMBOL(swdev_flow_insert);
 int swdev_flow_remove(struct net_device *dev, const struct swdev_flow *flow)
 {
 	const struct net_device_ops *ops = dev->netdev_ops;
+	int err;
 
 	print_flow(flow, dev, "remove");
 	if (!ops->ndo_swdev_flow_remove)
 		return -EOPNOTSUPP;
+	err = check_match_type_features(dev, flow);
+	if (err)
+		return err;
 	WARN_ON(!ops->ndo_swdev_id_get);
 	return ops->ndo_swdev_flow_remove(dev, flow);
 }
Signature · 1 line
1.9.3
maintainer
#20 lore raw

PATCH v2 8/9 switchdev: introduce Netlink API

In reply to Jiri Pirko

This patch exposes switchdev API using generic Netlink. Example userspace utility is here:
https://github.com/jpirko/switchdev

---
 MAINTAINERS                       |   1 +
 include/uapi/linux/switchdev.h    | 113 ++++++++++
 net/switchdev/Kconfig             |  11 +
 net/switchdev/Makefile            |   1 +
 net/switchdev/switchdev_netlink.c | 441 ++++++++++++++++++++++++++++++++++++++
 5 files changed, 567 insertions(+)
 create mode 100644 include/uapi/linux/switchdev.h
 create mode 100644 net/switchdev/switchdev_netlink.c
MAINTAINERS +1 -0
index f1f26db..0fe2822 100644
@@ -8832,6 +8832,7 @@ L:	[email protected]
 S:	Supported
 F:	net/switchdev/
 F:	include/net/switchdev.h
+F:	include/uapi/linux/switchdev.h
 
 SYNOPSYS ARC ARCHITECTURE
 M:	Vineet Gupta <[email protected]>
include/uapi/linux/switchdev.h new file +113 -0

113 lines not on this page · raw message

net/switchdev/Kconfig +11 -0
index 20e8ed2..4470d6e 100644
@@ -7,3 +7,14 @@ config NET_SWITCHDEV
 	depends on INET
 	---help---
 	  This module provides support for hardware switch chips.
+
+config NET_SWITCHDEV_NETLINK
+	tristate "Netlink interface to Switch device"
+	depends on NET_SWITCHDEV
+	default m
+	---help---
+	  This module provides Generic Netlink intercace to hardware switch
+	  chips.
+
+	  To compile this code as a module, choose M here: the
+	  module will be called switchdev_netlink.
net/switchdev/Makefile +1 -0
index 5ed63ed..0695b53 100644
@@ -3,3 +3,4 @@
 #
 
 obj-$(CONFIG_NET_SWITCHDEV) += switchdev.o
+obj-$(CONFIG_NET_SWITCHDEV_NETLINK) += switchdev_netlink.o
net/switchdev/switchdev_netlink.c new file +441 -0

441 lines not on this page · raw message

Signature · 1 line
1.9.3
#21 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

Quoted 4 lines · Jiri Pirko

This patch exposes switchdev API using generic Netlink. Example userspace utility is here:
https://github.com/jpirko/switchdev

Is this just a temporary test tool? Otherwise i dont see reason for its existence (or the API that it feeds on).

cheers,
jamal

maintainer
#22 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

Quoted 8 lines · Fri, Sep 19, 2014 at 05:25:48PM CEST, [email protected] wrote:
Quoted 4 lines · Jiri Pirko

This patch exposes switchdev API using generic Netlink. Example userspace utility is here:
https://github.com/jpirko/switchdev

Is this just a temporary test tool? Otherwise i dont see reason for its existence (or the API that it feeds on).

Please read the conversation I had with Pravin and Jesse in v1 thread. Long story short they like to have the api separated from ovs datapath so ovs daemon can use it to directly communicate with driver. Also John Fastabend requested a way to work with driver flows without using ovs -> that was the original reason I created switchdev genl api.

Regarding the "sw" tool, yes it is for testing purposes now. ovs daemon will use directly switchdev genl api.

I hope I cleared this out.

#23 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

Quoted 11 lines · Jiri Pirko
Quoted 2 lines · Fri, Sep 19, 2014 at 05:25:48PM CEST, [email protected] wrote:

Is this just a temporary test tool? Otherwise i dont see reason for its existence (or the API that it feeds on).

Please read the conversation I had with Pravin and Jesse in v1 thread. Long story short they like to have the api separated from ovs datapath so ovs daemon can use it to directly communicate with driver. Also John Fastabend requested a way to work with driver flows without using ovs -> that was the original reason I created switchdev genl api.

Quoted 5 lines

Regarding the "sw" tool, yes it is for testing purposes now. ovs daemon will use directly switchdev genl api.

I hope I cleared this out.

It is - thanks Jiri.

cheers,
jamal

#24 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

Quoted 15 lines · Jamal Hadi Salim
Quoted 14 lines · Jiri Pirko
Quoted 2 lines · Fri, Sep 19, 2014 at 05:25:48PM CEST, [email protected] wrote:

Is this just a temporary test tool? Otherwise i dont see reason for its existence (or the API that it feeds on).

Please read the conversation I had with Pravin and Jesse in v1 thread. Long story short they like to have the api separated from ovs datapath so ovs daemon can use it to directly communicate with driver. Also John Fastabend requested a way to work with driver flows without using ovs -> that was the original reason I created switchdev genl api.

Regarding the "sw" tool, yes it is for testing purposes now. ovs daemon will use directly switchdev genl api.

Quoted 7 lines
Quoted 2 lines

I hope I cleared this out.

It is - thanks Jiri.

cheers,
jamal

Hi Jiri,

I was considering a slightly different approach where the device would report via netlink the fields/actions it supported rather than creating pre-defined enums for every possible key.

I already need to have an API to report fields/matches that are being supported why not have the device report the headers as header fields (len, offset) and the associated parse graph the hardware uses? Vendors should have this already to describe/design their real hardware.

As always its better to have code and when I get some time I'll try to write it up. Maybe its just a separate classifier although I don't actually want two hardware flow APIs.

I see you dropped the RFC tag are you proposing we include this now?

.John

#25 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

Quoted 37 lines · John Fastabend
Quoted 15 lines · Jamal Hadi Salim
Quoted 14 lines · Jiri Pirko
Quoted 2 lines · Fri, Sep 19, 2014 at 05:25:48PM CEST, [email protected] wrote:

Is this just a temporary test tool? Otherwise i dont see reason for its existence (or the API that it feeds on).

Please read the conversation I had with Pravin and Jesse in v1 thread. Long story short they like to have the api separated from ovs datapath so ovs daemon can use it to directly communicate with driver. Also John Fastabend requested a way to work with driver flows without using ovs -> that was the original reason I created switchdev genl api.

Regarding the "sw" tool, yes it is for testing purposes now. ovs daemon will use directly switchdev genl api.

Quoted 7 lines
Quoted 2 lines

I hope I cleared this out.

It is - thanks Jiri.

cheers,
jamal

Hi Jiri,

I was considering a slightly different approach where the device would report via netlink the fields/actions it supported rather than creating pre-defined enums for every possible key.

I already need to have an API to report fields/matches that are being supported why not have the device report the headers as header fields (len, offset) and the associated parse graph the hardware uses? Vendors should have this already to describe/design their real hardware.

Quoted 8 lines

As always its better to have code and when I get some time I'll try to write it up. Maybe its just a separate classifier although I don't actually want two hardware flow APIs.

I see you dropped the RFC tag are you proposing we include this now?

Actually I just realized i missed something very basic that Jiri said. I think i understand the tool being there for testing but i am assumed the same about the genlink api.
Jiri, are you saying that genlink api is there to stay?

cheers,
jamal

#26 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

Quoted 49 lines · Jamal Hadi Salim
Quoted 38 lines · John Fastabend
Quoted 16 lines · Jamal Hadi Salim
Quoted 15 lines · Jiri Pirko
Quoted 2 lines · Fri, Sep 19, 2014 at 05:25:48PM CEST, [email protected] wrote:

Is this just a temporary test tool? Otherwise i dont see reason for its existence (or the API that it feeds on).

Please read the conversation I had with Pravin and Jesse in v1 thread. Long story short they like to have the api separated from ovs datapath so ovs daemon can use it to directly communicate with driver. Also John Fastabend requested a way to work with driver flows without using ovs ->
that was the original reason I created switchdev genl api.

Regarding the "sw" tool, yes it is for testing purposes now. ovs daemon will use directly switchdev genl api.

Quoted 7 lines
Quoted 2 lines

I hope I cleared this out.

It is - thanks Jiri.

cheers,
jamal

Hi Jiri,

I was considering a slightly different approach where the device would report via netlink the fields/actions it supported rather than creating pre-defined enums for every possible key.

I already need to have an API to report fields/matches that are being supported why not have the device report the headers as header fields (len, offset) and the associated parse graph the hardware uses? Vendors should have this already to describe/design their real hardware.

Quoted 8 lines

As always its better to have code and when I get some time I'll try to write it up. Maybe its just a separate classifier although I don't actually want two hardware flow APIs.

I see you dropped the RFC tag are you proposing we include this now?

Quoted 5 lines

Actually I just realized i missed something very basic that Jiri said. I think i understand the tool being there for testing but i am assumed the same about the genlink api.
Jiri, are you saying that genlink api is there to stay?

So, I really have mixed feelings about this netlink API, in particular because it is not clear to me where is the line between what should be a network device ndo operation, what should be an ethtool command, what should be a netlink message, and the rest.

I can certainly acknowledge the fact that manipulating flows is not ideal with the current set of tools, but really once we are there with netlink, how far are we from not having any network devices at all, and how does that differ from OpenWrt's swconfig in the end [1]?

[1]: https://lwn.net/Articles/571390/
--
Florian

maintainer
#27 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

Quoted 56 lines · Sat, Sep 20, 2014 at 07:39:51AM CEST, [email protected] wrote:
Quoted 49 lines · Jamal Hadi Salim
Quoted 38 lines · John Fastabend
Quoted 16 lines · Jamal Hadi Salim
Quoted 15 lines · Jiri Pirko
Quoted 2 lines · Fri, Sep 19, 2014 at 05:25:48PM CEST, [email protected] wrote:

Is this just a temporary test tool? Otherwise i dont see reason for its existence (or the API that it feeds on).

Please read the conversation I had with Pravin and Jesse in v1 thread. Long story short they like to have the api separated from ovs datapath so ovs daemon can use it to directly communicate with driver. Also John Fastabend requested a way to work with driver flows without using ovs ->
that was the original reason I created switchdev genl api.

Regarding the "sw" tool, yes it is for testing purposes now. ovs daemon will use directly switchdev genl api.

Quoted 7 lines
Quoted 2 lines

I hope I cleared this out.

It is - thanks Jiri.

cheers,
jamal

Hi Jiri,

I was considering a slightly different approach where the device would report via netlink the fields/actions it supported rather than creating pre-defined enums for every possible key.

I already need to have an API to report fields/matches that are being supported why not have the device report the headers as header fields (len, offset) and the associated parse graph the hardware uses? Vendors should have this already to describe/design their real hardware.

Quoted 8 lines

As always its better to have code and when I get some time I'll try to write it up. Maybe its just a separate classifier although I don't actually want two hardware flow APIs.

I see you dropped the RFC tag are you proposing we include this now?

Quoted 5 lines

Actually I just realized i missed something very basic that Jiri said. I think i understand the tool being there for testing but i am assumed the same about the genlink api.
Jiri, are you saying that genlink api is there to stay?

Quoted 4 lines

So, I really have mixed feelings about this netlink API, in particular because it is not clear to me where is the line between what should be a network device ndo operation, what should be an ethtool command, what should be a netlink message, and the rest.

Well as I said, this api should serve for flow manipulation only, therefore swdev flow related ndos are used.

Quoted 5 lines

I can certainly acknowledge the fact that manipulating flows is not ideal with the current set of tools, but really once we are there with netlink, how far are we from not having any network devices at all, and how does that differ from OpenWrt's swconfig in the end [1]?

I'm all ears on proposals how to make flow manipulation better.

Quoted 4 lines

[1]: https://lwn.net/Articles/571390/
--
Florian

maintainer
#28 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

In reply to Jamal Hadi Salim
Quoted 48 lines · Sat, Sep 20, 2014 at 12:18:02AM CEST, [email protected] wrote:
Quoted 37 lines · John Fastabend
Quoted 15 lines · Jamal Hadi Salim
Quoted 14 lines · Jiri Pirko
Quoted 2 lines · Fri, Sep 19, 2014 at 05:25:48PM CEST, [email protected] wrote:

Is this just a temporary test tool? Otherwise i dont see reason for its existence (or the API that it feeds on).

Please read the conversation I had with Pravin and Jesse in v1 thread. Long story short they like to have the api separated from ovs datapath so ovs daemon can use it to directly communicate with driver. Also John Fastabend requested a way to work with driver flows without using ovs -> that was the original reason I created switchdev genl api.

Regarding the "sw" tool, yes it is for testing purposes now. ovs daemon will use directly switchdev genl api.

Quoted 7 lines
Quoted 2 lines

I hope I cleared this out.

It is - thanks Jiri.

cheers,
jamal

Hi Jiri,

I was considering a slightly different approach where the device would report via netlink the fields/actions it supported rather than creating pre-defined enums for every possible key.

I already need to have an API to report fields/matches that are being supported why not have the device report the headers as header fields (len, offset) and the associated parse graph the hardware uses? Vendors should have this already to describe/design their real hardware.

Quoted 8 lines

As always its better to have code and when I get some time I'll try to write it up. Maybe its just a separate classifier although I don't actually want two hardware flow APIs.

I see you dropped the RFC tag are you proposing we include this now?

Quoted 5 lines

Actually I just realized i missed something very basic that Jiri said. I think i understand the tool being there for testing but i am assumed the same about the genlink api.
Jiri, are you saying that genlink api is there to stay?

Yes, that I say. It is needed for flow manipulation, because such api does not exist. As I stated earlier, I do not want to use switchdev genl for anything other than flow manipulation.

Quoted 3 lines

cheers,
jamal

#29 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

Quoted 2 lines · Jiri Pirko

Yes, that I say. It is needed for flow manipulation, because such api does not exist.

Come on Jiri!
The ovs guys are against this and now no *api exists*?
Write a 15 tuple classifier tc classifier and use it. I will be more than happy to help you. I will get to it when we have basics L2 working on real devices.

Quoted 2 lines

As I stated earlier, I do not want to use switchdev genl for anything other than flow manipulation.

Totally unacceptable in my books. If the OVS guys want some way out to be able to ride on some vendor sdks then that is their problem. We shouldnt allow for such loopholes. This is why/how TOE never made it in the kernel.

cheers,
jamal

#30 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

Quoted 4 lines · Jamal Hadi Salim

The ovs guys are against this and now no *api exists*?
Write a 15 tuple classifier tc classifier and use it. I will be more than happy to help you. I will get to it when we have basics L2 working on real devices.

Nothing speaks against having such a tc classifier. In fact, having the interface consist of only an embedded Netlink attribute structure would allow for such a classifier in a very straight forward way.

That doesn't mean everybody should be forced to use the stateful tc interface.

Quoted 4 lines

Totally unacceptable in my books. If the OVS guys want some way out to be able to ride on some vendor sdks then that is their problem. We shouldnt allow for such loopholes. This is why/how TOE never made it in the kernel.

No need for false accusations here. Nobody ever mentioned vendor SDKs.

The statement was that the requirement of deriving hardware flows from software flows *in the kernel* is not flexible enough for the future for reasons such as:

1) The OVS software data path might be based on eBPF in the future and it is unclear how we could derive hardware flows from that transparently.

2) Depending on hardware capabilities. Hardware flows might need to be assisted by software flow counterparts and it is believed that it is the wrong approach to push all the necessary context for the decision down into the kernel. This can be argued about and I don't feel strongly either way.

#31 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

Quoted 7 lines · Thomas Graf

Nothing speaks against having such a tc classifier. In fact, having the interface consist of only an embedded Netlink attribute structure would allow for such a classifier in a very straight forward way.

That doesn't mean everybody should be forced to use the stateful tc interface.

Agreed. The response was to Jiri's strange statement that now that he cant use OVS, there is no such api. I point to tc as very capable of such usage.

Quoted 2 lines

No need for false accusations here. Nobody ever mentioned vendor SDKs.

I am sorry to have tied the two together. Maybe not OVS but the approach described is heaven for vendor SDKs.

Quoted 8 lines

The statement was that the requirement of deriving hardware flows from software flows *in the kernel* is not flexible enough for the future for reasons such as:

1) The OVS software data path might be based on eBPF in the future and it is unclear how we could derive hardware flows from that transparently.

Who says you cant put BPF in hardware?
And why is OVS defining how BPF should evolve or how it should be used?

Quoted 6 lines

2) Depending on hardware capabilities. Hardware flows might need to be assisted by software flow counterparts and it is believed that it is the wrong approach to push all the necessary context for the decision down into the kernel. This can be argued about and I don't feel strongly either way.

Pointing to the current FDB offload: You can select to bypass and not use s/ware.

cheers,
jamal

#32 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

Quoted 2 lines · Jamal Hadi Salim

I am sorry to have tied the two together. Maybe not OVS but the approach described is heaven for vendor SDKs.

I fail to see the connection. You can use switch vendor SDK no matter how we define the kernel APIs. They already exist and have been designed in a way to be completely indepenedent from the kernel.

Are you referring to vendor specific decisions in user space in general? I believe that the whole point of swdev is to provide *that* level of abstraction so decisions can be made in a vendor neutral way.

Quoted 10 lines
Quoted 8 lines

The statement was that the requirement of deriving hardware flows from software flows *in the kernel* is not flexible enough for the future for reasons such as:

1) The OVS software data path might be based on eBPF in the future and it is unclear how we could derive hardware flows from that transparently.

Who says you cant put BPF in hardware?

I don't think anybody is saying that. P4 is likely a reality soon. But we definitely want hardware offload in a BPF world even if the hardware can't do BPF yet.

Quoted 1 line

And why is OVS defining how BPF should evolve or how it should be used?

Not sure I understand. OVS would be a user of eBPF just like tracing, xt_BPF, socket filter, ...

Quoted 9 lines
Quoted 6 lines

2) Depending on hardware capabilities. Hardware flows might need to be assisted by software flow counterparts and it is believed that it is the wrong approach to push all the necessary context for the decision down into the kernel. This can be argued about and I don't feel strongly either way.

Pointing to the current FDB offload: You can select to bypass and not use s/ware.

As I said, this can be argued about. It would require to push a lot of context into the kernel though. The FDB offload is relatively trivial in comparison to the complexity OVS user space can handle. I can't think of any reasons why to complicate the kernel further with OVS specific knowledge as long as we can guarantee the vendor abstraction.

A message that is not in the archive (sent off-list or not yet received): 20140920115140.GA3777-FZi0V3Vbi30CUdFEqe4BF2D2FQJk+8+b@public.gmane.org

#34 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

Quoted 8 lines · Thomas Graf

I fail to see the connection. You can use switch vendor SDK no matter how we define the kernel APIs. They already exist and have been designed in a way to be completely indepenedent from the kernel.

Are you referring to vendor specific decisions in user space in general? I believe that the whole point of swdev is to provide *that* level of abstraction so decisions can be made in a vendor neutral way.

I am not against the swdev idea. I think we have disagreements for the general classification/action interface how that should look like - but that is resolvable with correct interfaces. The vendor neutral way *already exists* via current netlink abstractions that existing tools use. When we need to add new interfaces then we should.

Quoted 4 lines

I don't think anybody is saying that. P4 is likely a reality soon. But we definitely want hardware offload in a BPF world even if the hardware can't do BPF yet.

I dont think we have contradictions. We are speaking past each other. You implied that in the future OVS s/w path might be based on BPF. I implied BPF itself could be offloaded and stands on its own merit and should work if we have the correct interface. As an example, I dont care about P4 or OVS - but i have no problem if they use the common interfaces provided by Linux. i.e
If i want to build a little cpu running the BPF instruction set and use that as my offload then that interface should work and if it doesnt i should provide extensions.

Quoted 3 lines

Not sure I understand. OVS would be a user of eBPF just like tracing, xt_BPF, socket filter, ...

Ok, we are on the same page then.

Quoted 6 lines

As I said, this can be argued about. It would require to push a lot of context into the kernel though. The FDB offload is relatively trivial in comparison to the complexity OVS user space can handle. I can't think of any reasons why to complicate the kernel further with OVS specific knowledge as long as we can guarantee the vendor abstraction.

I disagree. OVS maybe complex in that sense (I am sorry i am making an assumption based on what you are saying) but i dont think there is any other kernel subsystem that has this challenge.
Note: i am pointing to fdb only because it carries the concept of "put this in hardware and/or software". I agree the fdb maybe reasonably simpler.

cheers,
jamal

maintainer
#35 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

In reply to Jamal Hadi Salim
Quoted 6 lines · Sat, Sep 20, 2014 at 01:32:30PM CEST, [email protected] wrote:
Quoted 4 lines · Thomas Graf

Nothing speaks against having such a tc classifier. In fact, having the interface consist of only an embedded Netlink attribute structure would allow for such a classifier in a very straight forward way.

Quoted 8 lines
Quoted 3 lines

That doesn't mean everybody should be forced to use the stateful tc interface.

Agreed. The response was to Jiri's strange statement that now that he cant use OVS, there is no such api. I point to tc as very capable of such usage.

Jamal, would you please give us some examples on how to use tc to work with flows? I have a feeling that you see something other people does not. Lets get on the same page now.
Thanks.

Quoted 31 lines
Quoted 3 lines

No need for false accusations here. Nobody ever mentioned vendor SDKs.

I am sorry to have tied the two together. Maybe not OVS but the approach described is heaven for vendor SDKs.

Quoted 8 lines

The statement was that the requirement of deriving hardware flows from software flows *in the kernel* is not flexible enough for the future for reasons such as:

1) The OVS software data path might be based on eBPF in the future and it is unclear how we could derive hardware flows from that transparently.

Who says you cant put BPF in hardware?
And why is OVS defining how BPF should evolve or how it should be used?

Quoted 6 lines

2) Depending on hardware capabilities. Hardware flows might need to be assisted by software flow counterparts and it is believed that it is the wrong approach to push all the necessary context for the decision down into the kernel. This can be argued about and I don't feel strongly either way.

Pointing to the current FDB offload: You can select to bypass and not use s/ware.

cheers,
jamal

A message that is not in the archive (sent off-list or not yet received): [email protected]

#37 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

Quoted 2 lines · Jiri Pirko

Jamal, would you please give us some examples on how to use tc to work with flows? I have a feeling that you see something other people does not.

I will be a little verbose so as to avoid knowledge assumption.

Lets talk about tc classifier/action subsystem because that is what would take advantage of flows. We could also talk about qdiscs i.e schedulers and queue objects because the two are often related (the default classification action is "classid" which typically maps to a queue class).

tc classification/action subsystem allows you to specify arbitrary classifiers and actions.
You can then specify (using a precise BNF grammar) how filters and actions are to be related.
Look at iproute2/f_*.c to see the currently defined ones.

Each classifier has a name/id and attributes/options specific to itself. Classifiers dont necessarily have to filter on packet headers; they could filter on metadata for example. Each classifier running in software may be offloaded. I think that simple model would allow usable tools.
The classifier you have defined currently in your patches could be realized via the u32 classifier but i think that would require knowledge of u32. So for usability reasons I would suggest to write a brand new classifier. For lack of a better name, lets call it "multi-tuple classifier".
I would expect this classifier to be usable in software tc as well without necessarily being offloaded.

There are two important details to note:
1) many different types of classifiers exist. This would very likely depend on hardware implementation. It is academic bullshit (i.e not pragmatic) to claim all hardware offload can use the same classification language. As i was telling Thomas
I dont see why one wouldnt offload the defined bpf classifier. From an API level, this means your ->flow_add/del/get would have to support ability to define different classifiers.

2) Each classifier will have different semantics.
From a device API level this means you have to allow the different classifiers to pass attributes specific to them. This means each classifier may override the ops(). I am indifferent how it is achieved. So while you could pass one big structure such as your flow struct, one should be able to do u32 kind of semantics.

We also need to discover which device supports which classifiers and what constraints exist in the hardware implementation exist (we can talk about that because it is important). Example if one supports u32, how many u32 rules can be offloaded etc.

As to how it is to be implemented:
I like the semantics of the current bridge code. I have always wondered why we didnt use that scheme for offloading qdiscs. Each device supporting FDB offload has an ->fdb_add/del/get (dont quote me on the naming). User space describes what it wants. If something is to be offloaded we already know the netdev the user is pointing to. We invoke the appropriate ->flow() calls with appropriately cooked structures.
I am not sure i like that we pass the netlink structure as Scott often seems to point to; i think that passing the internal structure we would install in s/ware may be the better approach since:
a) we would need to parse the data anyways for validation etc
b) each hardware offload will likely need to translate further in internal format
c)we have well defined mapping between user and offload, the generic structure will be very close to hardware.
note: that is what the fdb offload does.

Note: I described this using tc, but i dont see why nftable couldnt follow the same approach. My angle is that we dont impede other users by over-focussing on ovs and whatever other things that surround it.
cheers,
jamal

#38 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

In reply to John Fastabend
Quoted 31 lines · John Fastabend
Quoted 15 lines · Jamal Hadi Salim
Quoted 14 lines · Jiri Pirko
Quoted 2 lines · Fri, Sep 19, 2014 at 05:25:48PM CEST, [email protected] wrote:

Is this just a temporary test tool? Otherwise i dont see reason for its existence (or the API that it feeds on).

Please read the conversation I had with Pravin and Jesse in v1 thread. Long story short they like to have the api separated from ovs datapath so ovs daemon can use it to directly communicate with driver. Also John Fastabend requested a way to work with driver flows without using ovs -> that was the original reason I created switchdev genl api.

Regarding the "sw" tool, yes it is for testing purposes now. ovs daemon will use directly switchdev genl api.

Quoted 7 lines
Quoted 2 lines

I hope I cleared this out.

It is - thanks Jiri.

cheers,
jamal

Hi Jiri,

I was considering a slightly different approach where the device would report via netlink the fields/actions it supported rather than creating pre-defined enums for every possible key.

Quoted 5 lines

I already need to have an API to report fields/matches that are being supported why not have the device report the headers as header fields (len, offset) and the associated parse graph the hardware uses? Vendors should have this already to describe/design their real hardware.

Humm would not that slightly go against coming with a netlink API that is generic? Surely we could pay close attention when reviewing what is being added and spot when a common API needs to be introduced...

This might become very similar to the private ioctl(), private wireless extensions, nl80211 testmode and well it's not extremely pretty.

Quoted 11 lines

As always its better to have code and when I get some time I'll try to write it up. Maybe its just a separate classifier although I don't actually want two hardware flow APIs.

I see you dropped the RFC tag are you proposing we include this now?

.John

maintainer
#39 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

In reply to John Fastabend
Quoted 31 lines · Sat, Sep 20, 2014 at 12:12:12AM CEST, [email protected] wrote:
Quoted 15 lines · Jamal Hadi Salim
Quoted 14 lines · Jiri Pirko
Quoted 2 lines · Fri, Sep 19, 2014 at 05:25:48PM CEST, [email protected] wrote:

Is this just a temporary test tool? Otherwise i dont see reason for its existence (or the API that it feeds on).

Please read the conversation I had with Pravin and Jesse in v1 thread. Long story short they like to have the api separated from ovs datapath so ovs daemon can use it to directly communicate with driver. Also John Fastabend requested a way to work with driver flows without using ovs -> that was the original reason I created switchdev genl api.

Regarding the "sw" tool, yes it is for testing purposes now. ovs daemon will use directly switchdev genl api.

Quoted 7 lines
Quoted 2 lines

I hope I cleared this out.

It is - thanks Jiri.

cheers,
jamal

Hi Jiri,

I was considering a slightly different approach where the device would report via netlink the fields/actions it supported rather than creating pre-defined enums for every possible key.

Quoted 5 lines

I already need to have an API to report fields/matches that are being supported why not have the device report the headers as header fields (len, offset) and the associated parse graph the hardware uses? Vendors should have this already to describe/design their real hardware.

Hmm, let me think about this a bit more. I will try to figure out how to handle that. Sound logic though. Will try to incorporate the idea in the patchset.

Quoted 5 lines

As always its better to have code and when I get some time I'll try to write it up. Maybe its just a separate classifier although I don't actually want two hardware flow APIs.

Understood.

Quoted 3 lines

I see you dropped the RFC tag are you proposing we include this now?

v11 is my bet :)

Quoted 2 lines

.John

#40 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

Quoted 12 lines · Jiri Pirko
Quoted 10 lines · Sat, Sep 20, 2014 at 12:12:12AM CEST, [email protected] wrote:

I was considering a slightly different approach where the device would report via netlink the fields/actions it supported rather than creating pre-defined enums for every possible key.

I already need to have an API to report fields/matches that are being supported why not have the device report the headers as header fields (len, offset) and the associated parse graph the hardware uses? Vendors should have this already to describe/design their real hardware.

Quoted 3 lines

Hmm, let me think about this a bit more. I will try to figure out how to handle that. Sound logic though. Will try to incorporate the idea in the patchset.

I think this is the right track.

I agree with Jamal that there is no need for a new permanent and separate Netlink interface for this. I think this would best be described as a structure of nested Netlink attributes in the form John proposes which is then embedded into existing Netlink interfaces such as rtnetlink and OVS genl.

OVS can register new genl ops to check capabilities and insert hardware flows which allows implementation of the offload decision in user space and allows for arbitary combination of hardware and software flows. It also allows to run a eBPF software data path in combination with a hardware flow setup.

rtnetlink can embed the nested attribute structure into existing APIs to allow feature capability detection from user space, statistic reporting and optional direct hardware offload if a transaprent offload is not feasible. Would that work for you John?

I think we should focus on getting the layering right and make it generic enough so we allow evolving naturally.

#41 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

Quoted 13 lines · Thomas Graf
Quoted 12 lines · Jiri Pirko
Quoted 10 lines · Sat, Sep 20, 2014 at 12:12:12AM CEST, [email protected] wrote:

I was considering a slightly different approach where the device would report via netlink the fields/actions it supported rather than creating pre-defined enums for every possible key.

I already need to have an API to report fields/matches that are being supported why not have the device report the headers as header fields (len, offset) and the associated parse graph the hardware uses? Vendors should have this already to describe/design their real hardware.

Quoted 5 lines
Quoted 3 lines

Hmm, let me think about this a bit more. I will try to figure out how to handle that. Sound logic though. Will try to incorporate the idea in the patchset.

I think this is the right track.

I agree with John and Thomas here.
I think HW should not be limited by SW abstractions whether these abstractions are called flows, n-tuples, bridge or else. Really looking forward to see "device reporting the headers as header fields (len, offset) and the associated parse graph" as the first step.

Another topic that this discussion didn't cover yet is how this all connects to tunnels and what is 'tunnel offloading'. imo flow offloading by itself serves only academic interest.

#42 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

Quoted 9 lines · Alexei Starovoitov

I think HW should not be limited by SW abstractions whether these abstractions are called flows, n-tuples, bridge or else. Really looking forward to see "device reporting the headers as header fields (len, offset) and the associated parse graph" as the first step.

Another topic that this discussion didn't cover yet is how this all connects to tunnels and what is 'tunnel offloading'. imo flow offloading by itself serves only academic interest.

We haven't touched encryption yet either ;-)

Certainly true for the host case. The Linux on TOR case is less dependant on this and L2/L3 offload w/o encap already has value.

I'm with you though, all of this has little value on the host in the DC if stateful encap offload is not incorporated. I expect the HW to provide filters on the outer header plus metadata in the encap. Actually, this was a follow-up question I had for John as this is not easily describable with offset/len filters. How would we represent such capabilities?

The TX side of this was one of the reasons why I initially thought it would be beneficial to implement a cache like offload as we could serve an initial encap in SW, do the FIB lookup and offload it transparently to avoid replicating the FIB in user space.

What seems most feasisble to me right now is to separate the offload of the encap action from the IP -> dev mapping decision. The eSwitch would send the first encap for an unknown dest IP to the CPU due to a miss in the IP mapping table, the CPU would do the FIB lookup, update the table and send it back.

What do you have in mind?

#43 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

Quoted 7 lines · Thomas Graf
Quoted 6 lines · Alexei Starovoitov

I think HW should not be limited by SW abstractions whether these abstractions are called flows, n-tuples, bridge or else. Really looking forward to see "device reporting the headers as header fields (len, offset) and the associated parse graph" as the first step.

Quoted 9 lines
Quoted 3 lines

Another topic that this discussion didn't cover yet is how this all connects to tunnels and what is 'tunnel offloading'. imo flow offloading by itself serves only academic interest.

We haven't touched encryption yet either ;-)

Certainly true for the host case. The Linux on TOR case is less dependant on this and L2/L3 offload w/o encap already has value.

Thomas, can you (or someone else) quantify what the host case is. I suppose there may be merit in using a switch on NIC for kernel bypass scenarios, but I'm still having a hard time understanding how this could be integrated into the host stack with benefits that outweigh complexity. The history of stateful offloads in NICs is not great, and encapsulation (stuffing a few bytes of header into a packet) is in itself not nearly an expensive enough operation to warrant offloading to the NIC. Personally, I wish if NIC vendors are going to focus on stateful offload I rather see it be for encryption which I believe currently does warrant offload at 40G and higher speeds.

Tom

Quoted 23 lines

I'm with you though, all of this has little value on the host in the DC if stateful encap offload is not incorporated. I expect the HW to provide filters on the outer header plus metadata in the encap. Actually, this was a follow-up question I had for John as this is not easily describable with offset/len filters. How would we represent such capabilities?

The TX side of this was one of the reasons why I initially thought it would be beneficial to implement a cache like offload as we could serve an initial encap in SW, do the FIB lookup and offload it transparently to avoid replicating the FIB in user space.

What seems most feasisble to me right now is to separate the offload of the encap action from the IP -> dev mapping decision. The eSwitch would send the first encap for an unknown dest IP to the CPU due to a miss in the IP mapping table, the CPU would do the FIB lookup, update the table and send it back.

What do you have in mind?
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#44 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

Quoted 4 lines · Tom Herbert

Thomas, can you (or someone else) quantify what the host case is. I suppose there may be merit in using a switch on NIC for kernel bypass scenarios, but I'm still having a hard time understanding how this could be integrated into the host stack with benefits that outweigh

Personally my primary interest is on lxc and vm based workloads w/ end to end encryption, encap, distributed L3 and NAT, and policy enforcement including service graphs which imply both east-west and north-south traffic patterns on a host. The usual I guess ;-)

Quoted 3 lines

complexity. The history of stateful offloads in NICs is not great, and encapsulation (stuffing a few bytes of header into a packet) is in itself not nearly an expensive enough operation to warrant offloading

No argument here. The direct benchmark comparisons I've measured showed only around 2% improvement.

What makes stateful offload interesting to me is that the final desintation of a packet is known at RX and can be redirected to a queue or VF. This allows to build packet batches on shared pages while preserving the securiy model.

Will the gains outweigh complexity? I hope so but I don't know for sure. If you have insights, let me know. What I know for sure is that I don't want to rely on a kernel bypass for the above.

Quoted 3 lines

to the NIC. Personally, I wish if NIC vendors are going to focus on stateful offload I rather see it be for encryption which I believe currently does warrant offload at 40G and higher speeds.

Agreed. I would like to be see a focus on both.

A message that is not in the archive (sent off-list or not yet received): 20140922221727.GA4708-FZi0V3Vbi30CUdFEqe4BF2D2FQJk+8+b@public.gmane.org

#46 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

Quoted 15 lines · Thomas Graf
Quoted 4 lines · Tom Herbert

Thomas, can you (or someone else) quantify what the host case is. I suppose there may be merit in using a switch on NIC for kernel bypass scenarios, but I'm still having a hard time understanding how this could be integrated into the host stack with benefits that outweigh

Personally my primary interest is on lxc and vm based workloads w/ end to end encryption, encap, distributed L3 and NAT, and policy enforcement including service graphs which imply both east-west and north-south traffic patterns on a host. The usual I guess ;-)

Quoted 3 lines

complexity. The history of stateful offloads in NICs is not great, and encapsulation (stuffing a few bytes of header into a packet) is in itself not nearly an expensive enough operation to warrant offloading

Quoted 8 lines

No argument here. The direct benchmark comparisons I've measured showed only around 2% improvement.

What makes stateful offload interesting to me is that the final desintation of a packet is known at RX and can be redirected to a queue or VF. This allows to build packet batches on shared pages while preserving the securiy model.

How is this different from what rx-filtering already does?

Quoted 9 lines

Will the gains outweigh complexity? I hope so but I don't know for sure. If you have insights, let me know. What I know for sure is that I don't want to rely on a kernel bypass for the above.

Quoted 3 lines

to the NIC. Personally, I wish if NIC vendors are going to focus on stateful offload I rather see it be for encryption which I believe currently does warrant offload at 40G and higher speeds.

Agreed. I would like to be see a focus on both.

#47 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

Quoted 7 lines · Tom Herbert
Quoted 5 lines · Thomas Graf

What makes stateful offload interesting to me is that the final desintation of a packet is known at RX and can be redirected to a queue or VF. This allows to build packet batches on shared pages while preserving the securiy model.

How is this different from what rx-filtering already does?

Without stateful offload I can't know where the packet is destined to until after I've allocated an skb and parsed the packet in software. I might be missing what you refer to here specifically.

#48 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

Quoted 7 lines · Thomas Graf
Quoted 6 lines · Tom Herbert
Quoted 5 lines · Thomas Graf

What makes stateful offload interesting to me is that the final desintation of a packet is known at RX and can be redirected to a queue or VF. This allows to build packet batches on shared pages while preserving the securiy model.

Quoted 5 lines
Quoted 1 line

How is this different from what rx-filtering already does?

Without stateful offload I can't know where the packet is destined to until after I've allocated an skb and parsed the packet in software. I might be missing what you refer to here specifically.

n-tuple filtering in as exposed by ethtool.

#49 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

Quoted 8 lines · Tom Herbert
Quoted 7 lines · Thomas Graf
Quoted 6 lines · Tom Herbert
Quoted 5 lines · Thomas Graf

What makes stateful offload interesting to me is that the final desintation of a packet is known at RX and can be redirected to a queue or VF. This allows to build packet batches on shared pages while preserving the securiy model.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

How is this different from what rx-filtering already does?

Without stateful offload I can't know where the packet is destined to until after I've allocated an skb and parsed the packet in software. I might be missing what you refer to here specifically.

n-tuple filtering in as exposed by ethtool.

n-tuple has some deficiencies,

- its not possible to get the capabilities to learn what fields are supported by the device, what actions, etc.

- its ioctl based so we have to poll the device

- only supports a single table, where we have devices with multiple tables

- sort of the same as above but it doesn't allow creating new tables or destroying old tables.

I probably missed a few others but those are the main ones that I would like to address. Granted other than the ioctl line the rest could be solved by extending the existing interface. However I would just assume port it to ndo_ops and netlink then extend the existing ioctl seeing it needs a reasonable overall to support the above anyways.

We could port the ethtool ops over to the new interface to simplify drivers.

.John

Signature · 1 line
John Fastabend         Intel Corporation
#50 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

Quoted 5 lines · John Fastabend

n-tuple has some deficiencies,

- its not possible to get the capabilities to learn what fields are supported by the device, what actions, etc.

Quoted 7 lines

- its ioctl based so we have to poll the device

- only supports a single table, where we have devices with multiple tables

- sort of the same as above but it doesn't allow creating new tables or destroying old tables.

OK, I understand where Tom was going. Given we add feature detection capabilities this could be used to identify the guest for fixed length encap. I still assume HW won't be able to match on the inner header for any variable lengh encap with metadata packet unless it can actually parse the encap. I hope I didn't bring encap format to this thread at this very moment ;-)

#51 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

In reply to John Fastabend
Quoted 7 lines · John Fastabend

n-tuple has some deficiencies,

- its not possible to get the capabilities to learn what fields are supported by the device, what actions, etc.

- its ioctl based so we have to poll the device

Quoted 7 lines

- only supports a single table, where we have devices with multiple tables

- sort of the same as above but it doesn't allow creating new tables or destroying old tables.

I probably missed a few others

A few more I can think of which are generic:
The whole event subsystem allowing multi-user sync or monitoring offered by netlink is missing because ethtool ioctl go directly to the driver.
The synchronous interface vs async offered by netlink offers a more effective user programmability.
The ioctl binary interface whose extensibility is a pain (dont let Stephen H hear you mention ioctls for just this one reason).

Quoted 8 lines

but those are the main ones that I
would like to address. Granted other than the ioctl line the rest could be solved by extending the existing interface. However I would just assume port it to ndo_ops and netlink then extend the existing ioctl seeing it needs a reasonable overall to support the above anyways.

We could port the ethtool ops over to the new interface to simplify drivers.

Indeed.

cheers,
jamal

Quoted 2 lines

.John

A message that is not in the archive (sent off-list or not yet received): CA+mtBx9ZVQ5r5Hzy9-uEnk+iu+HKkOP4+VANC06Xf8VvTxktwQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#53 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

Quoted 5 lines · Tom Herbert
Quoted 4 lines · Thomas Graf

What makes stateful offload interesting to me is that the final desintation of a packet is known at RX and can be redirected to a queue or VF. This allows to build packet batches on shared pages while preserving the securiy model.

To put this in other words: It is equivalent to applying the snabbswitch
+ vhost-user principle to the kernel but with encap support. The SR-IOV case would be a further optimization of that.

#54 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

In reply to Tom Herbert
Quoted 8 lines · Tom Herbert
Quoted 7 lines · Thomas Graf
Quoted 6 lines · Alexei Starovoitov

I think HW should not be limited by SW abstractions whether these abstractions are called flows, n-tuples, bridge or else. Really looking forward to see "device reporting the headers as header fields (len, offset) and the associated parse graph" as the first step.

Quoted 6 lines
Quoted 2 lines
Quoted 2 lines

Another topic that this discussion didn't cover yet is how this all connects to tunnels and what is 'tunnel offloading'.

encapsulation (stuffing a few bytes of header into a packet) is in itself not nearly an expensive enough operation to warrant offloading to the NIC. Personally, I wish if NIC vendors are going to focus on

On contrary, generic tunneling is most important one to get right when we're talking offloads.
Adding encap header is easy to do in hw, but it breaks all other offloads if hw is not generic. Consider gso packet coming from vm. Generic tunnel allows sw to add inner headers, outer headers and setup offload offsets, so that HW does segmentation, checksuming of inner packet, adjusts inner headers and adds final outer encap. And this is just tx offload. On rx smart tunnel offload in HW parses encap and goes all the way to inner headers to verify checksums, it also steers based on inner headers.
Try mellanox nics with and without vxlan offload to see the difference.
It looks like fm10k will be just as good, but existing encaps are not going to last forever, so RX should be improved they way John is saying. There gotta to be a 'parse graph' for HW to see past variable length encap and into inner headers. checksum_complete style of offloading checksum verification is not efficient. The cost of adjusting it over and over while parsing encaps is too high. Plus cpu steering based on outer headers is just too slow when speeds are in 40G range.

Quoted 2 lines

stateful offload I rather see it be for encryption which I believe currently does warrant offload at 40G and higher speeds.

encryption offload is badly needed as well. Unfortunately it's not seen as nic feature yet.

#55 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

Quoted 16 lines · Alexei Starovoitov
Quoted 8 lines · Tom Herbert
Quoted 7 lines · Thomas Graf
Quoted 6 lines · Alexei Starovoitov

I think HW should not be limited by SW abstractions whether these abstractions are called flows, n-tuples, bridge or else. Really looking forward to see "device reporting the headers as header fields (len, offset) and the associated parse graph" as the first step.

Quoted 6 lines
Quoted 2 lines
Quoted 2 lines

Another topic that this discussion didn't cover yet is how this all connects to tunnels and what is 'tunnel offloading'.

encapsulation (stuffing a few bytes of header into a packet) is in itself not nearly an expensive enough operation to warrant offloading to the NIC. Personally, I wish if NIC vendors are going to focus on

Quoted 7 lines

On contrary, generic tunneling is most important one to get right when we're talking offloads.
Adding encap header is easy to do in hw, but it breaks all other offloads if hw is not generic. Consider gso packet coming from vm. Generic tunnel allows sw to add inner headers, outer headers and setup offload offsets, so that HW does segmentation, checksuming of inner packet, adjusts inner headers and adds final outer encap.

As I pointed out on a previous thread, we already have a sufficiently generic interface to allow HW to do encapsulated TSO (SKB_GSO_UDP_TUNNEL and SKB_GSO_UDP_TUNNEL_CSUM with the inner headers). If properly implemented, HW can implement a whole bunch of UDP encap protocols without knowing how to parse them. I don't see how a switch on the NIC helps this...

Quoted 5 lines

And this is just tx offload. On rx smart tunnel offload in HW parses encap and goes all the way to inner headers to verify checksums, it also steers based on inner headers.
Try mellanox nics with and without vxlan offload to see the difference.

Turn on UDP RSS on the device and I bet you'll see those differences go away! Once we moved to UDP encapsulation, there's really little value in looking at inner headers for RSS or ECMP, this should be sufficient. Sure someone might want to parse the inner headers for some sort of advanced RX steering, but again this implies rx-filtering and not switch functionality.

Alexei, I believe you said previously said that SW should not dictate HW models. I agree with this, but also believe the converse is true-- HW shouldn't dictate SW model. This is really why I'm raising the question of what it means to integrate a switch into the host stack. If this is something that doesn't require any model change to the stack and is just a clever backend for rx-filters or tc, then I'm fine with that!

Thanks,
Tom

Quoted 14 lines

It looks like fm10k will be just as good, but existing encaps are not going to last forever, so RX should be improved they way John is saying. There gotta to be a 'parse graph' for HW to see past variable length encap and into inner headers. checksum_complete style of offloading checksum verification is not efficient. The cost of adjusting it over and over while parsing encaps is too high. Plus cpu steering based on outer headers is just too slow when speeds are in 40G range.

Quoted 2 lines

stateful offload I rather see it be for encryption which I believe currently does warrant offload at 40G and higher speeds.

encryption offload is badly needed as well. Unfortunately it's not seen as nic feature yet.

#56 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

On Mon, Sep 22, 2014 at 07:16:47PM -0700, Tom Herbert wrote:
[...]

Quoted 5 lines

Alexei, I believe you said previously said that SW should not dictate HW models. I agree with this, but also believe the converse is true-- HW shouldn't dictate SW model. This is really why I'm raising the question of what it means to integrate a switch into the host stack.

Tom, when I read this I cannot help but remind myself that the intentions/hopes/dreams of those on this thread and how different their views can be on what it means to add additional 'offload support' to the kernel.

There are clearly some that are most interested in how an eSwitch on an SR-IOV capable NIC be controlled can provide traditional forwarding help as well as offload the various technologies they hope to terminate at/inside their endpoint (host/guest/container) -- Thomas's _simple_ use-case demonstrates this. ;) This is a logical extention/increase in functionality that is offered in many eSwitches that was previously hidden from the user with the first generation SR-IOV capable network devices on hosts/servers.

Others (like Florian who has been working to extend DSA or those pushing hardware vendors to make SDKs more open) where the existing bridging/ routing/offload code can take advantage of the hardware offload/encap available in merchant silicon. The general idea seems to add the knowledge of offload hardware to the kernel -- either via new ndo_ops or netlink. This gives users who have this hardware the ability to have a solution for their router/switch that makes it feel like Linux is actually helping make forwarding decisions -- rather than just being the kernel chosen to provide an environment where some other non-community code runs that makes all of the decisions.

And now we also have the patchset that spawned what I think has been more excellent discussion. Jiri and Scott's patches bring up another, more generic model that while not currently backed by hardware provided an example/vision for what could be done if such hardware existed and how to consider interacting with that driver/hardware (that clearly has been met with some resistance, but the discussion has been great). There ultimate goals appear to be similar to those that want full offload/fordwarding support for a device, but via a different method than what some would consider standard.

I am personally hopeful that most who are passionate about this will be able to get together next month at LPC (or send someone to represent them!) so that those interested can sit in the same room and try to better understand each others desires and start to form some concrete direction towards a solution that seems to meet the needs of most while not being an architectural disaster.

Of course that may be way too optimistic for this crowd! :-D

#57 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

Quoted 8 lines · Andy Gospodarek

There are clearly some that are most interested in how an eSwitch on an SR-IOV capable NIC be controlled can provide traditional forwarding help as well as offload the various technologies they hope to terminate at/inside their endpoint (host/guest/container) -- Thomas's _simple_ use-case demonstrates this. ;) This is a logical extention/increase in functionality that is offered in many eSwitches that was previously hidden from the user with the first generation SR-IOV capable network devices on hosts/servers.

I think we can define this more broadly and state that providing RX steering capabilities to identify a guest in the NIC allows to directly map packets into a memory region shared between host and guest. Not a new concept at all but the existing dMAC and VLAN rx filtering is just too limiting. We require a programmable API with support for encap and encryption. SR-IOV is a hardware assisted form of that which can expedite the guest to guest path on a host.

#58 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

In reply to Andy Gospodarek
Quoted 11 lines · Andy Gospodarek

On Mon, Sep 22, 2014 at 07:16:47PM -0700, Tom Herbert wrote:
[...]

Quoted 4 lines

Alexei, I believe you said previously said that SW should not dictate HW models. I agree with this, but also believe the converse is true-- HW shouldn't dictate SW model. This is really why I'm raising the question of what it means to integrate a switch into the host stack.

Tom, when I read this I cannot help but remind myself that the intentions/hopes/dreams of those on this thread and how different their views can be on what it means to add additional 'offload support' to the kernel.

Quoted 8 lines

There are clearly some that are most interested in how an eSwitch on an SR-IOV capable NIC be controlled can provide traditional forwarding help as well as offload the various technologies they hope to terminate at/inside their endpoint (host/guest/container) -- Thomas's _simple_ use-case demonstrates this. ;) This is a logical extention/increase in functionality that is offered in many eSwitches that was previously hidden from the user with the first generation SR-IOV capable network devices on hosts/servers.

Indeed.

The idea is to leverage OVS to manage eSwitch (embedded NIC switch) as well (NOT to offload OVS).

We envision a seamless integration of user environment which is based on OVS with SRIOV eSwitch and the grounds for that were very well supported in Jiri’s V1.

The eSwitch hardware does not need to have multiple tables and ‘enjoys’ the flat rule of OVS. The kernel datapath does not need to be aware of the existence of HW nor its capabilities, it just pushes the flow also to the switchdev which represents the eSwitch.

If the flow can be supported in HW it will be forwarded in HW and if not it will be forwarded by the kernel

Quoted 12 lines

[....]

And now we also have the patchset that spawned what I think has been more excellent discussion. Jiri and Scott's patches bring up another, more generic model that while not currently backed by hardware provided an example/vision for what could be done if such hardware existed and how to consider interacting with that driver/hardware (that clearly has been met with some resistance, but the discussion has been great). There ultimate goals appear to be similar to those that want full offload/fordwarding support for a device, but via a different method than what some would consider standard.

Quoted 7 lines

I am personally hopeful that most who are passionate about this will be able to get together next month at LPC (or send someone to represent them!) so that those interested can sit in the same room and try to better understand each others desires and start to form some concrete direction towards a solution that seems to meet the needs of most while not being an architectural disaster.

Yep. LPC is the time and place to go over the multiple use-cases (phyiscal switch, eSwitch, eBPF, etc) that could (should) be supported by the basic framework.

Or.

#59 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

Quoted 8 lines · Or Gerlitz

Indeed.

The idea is to leverage OVS to manage eSwitch (embedded NIC switch) as well (NOT to offload OVS).

We envision a seamless integration of user environment which is based on OVS with SRIOV eSwitch and the grounds for that were very well supported in Jiri’s V1.

Please consider comparing your model with what is described here [0]. I'm trying to write down an architecture document that we can finalize in Düsseldorf.

[0] http://goo.gl/qkzW5y

Quoted 4 lines

The eSwitch hardware does not need to have multiple tables and ‘enjoys’ the flat rule of OVS. The kernel datapath does not need to be aware of the existence of HW nor its capabilities, it just pushes the flow also to the switchdev which represents the eSwitch.

I think you are saying that the kernel should not be required to make the offload decision which is fair. We definitely don't want to force the decision to be outside though, there are several legit reasons to support transparent offloads within the kernel as well outside of OVS.

Quoted 3 lines

Yep. LPC is the time and place to go over the multiple use-cases (phyiscal switch, eSwitch, eBPF, etc) that could (should) be supported by the basic framework.

For reference:
http://www.linuxplumbersconf.org/2014/ocw/proposals/2463

#60 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

Quoted 6 lines · Thomas Graf
Quoted 5 lines · Or Gerlitz

Indeed.

The idea is to leverage OVS to manage eSwitch (embedded NIC switch) as well (NOT to offload OVS).

Quoted 8 lines
Quoted 3 lines

We envision a seamless integration of user environment which is based on OVS with SRIOV eSwitch and the grounds for that were very well supported in Jiri’s V1.

Please consider comparing your model with what is described here [0]. I'm trying to write down an architecture document that we can finalize in Düsseldorf.
[0] http://goo.gl/qkzW5y

Yep, this can serve us for the architecture discussion @ LPC. Re the SRIOV case, you referred to the case where guest VF traffic goes through HW (say) VXLAN encap/decap -- just to make sure, we need also to support the simpler case, where guest traffic just goes through vlan tag/strip.

Quoted 10 lines
Quoted 4 lines

The eSwitch hardware does not need to have multiple tables and ‘enjoys’ the flat rule of OVS. The kernel datapath does not need to be aware of the existence of HW nor its capabilities, it just pushes the flow also to the switchdev which represents the eSwitch.

I think you are saying that the kernel should not be required to make the offload decision which is fair. We definitely don't want to force the decision to be outside though, there are several legit reasons to support transparent offloads within the kernel as well outside of OVS.

Quoted 6 lines
Quoted 3 lines

Yep. LPC is the time and place to go over the multiple use-cases (phyiscal switch, eSwitch, eBPF, etc) that could (should) be supported by the basic framework.

For reference:
http://www.linuxplumbersconf.org/2014/ocw/proposals/2463

The SRIOV case is only mentioned here in the "Compatibility with existing FDB ioctls for SR-IOV" bullet, so I'm a bit nervous... we need to have it clear in the agenda. Also, this BoF needs to be double-len, two hours, can you act to get that done?

thanks,

Or.

#61 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

Quoted 5 lines · Or Gerlitz

Yep, this can serve us for the architecture discussion @ LPC. Re the SRIOV case, you referred to the case where guest VF traffic goes through HW (say) VXLAN encap/decap -- just to make sure, we need also to support the simpler case, where guest traffic just goes through vlan tag/strip.

Agreed.

Quoted 3 lines

The SRIOV case is only mentioned here in the "Compatibility with existing FDB ioctls for SR-IOV" bullet, so I'm a bit nervous... we need to have it clear in the agenda.

I think the offload API discussion should consider the SR-iOV case but we might need to discuss additional details outside of that BoF to ensure that the BoF can keep focus on the offload API itself. That said, I suggest we define the specific agenda once we know that the BoF has been accepted and 2 hours have been allocated ;-)

Quoted 2 lines

Also, this BoF needs to be double-len, two hours, can you act to get that done?

This has already been requested.

#62 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

In reply to Tom Herbert
Quoted 6 lines · Tom Herbert

Turn on UDP RSS on the device and I bet you'll see those differences go away! Once we moved to UDP encapsulation, there's really little value in looking at inner headers for RSS or ECMP, this should be sufficient. Sure someone might want to parse the inner headers for some sort of advanced RX steering, but again this implies rx-filtering and not switch functionality.

Agreed. The reason we discuss this in the context of this thread is because the required rx-filtering capabilities seem to be introduced in the form of (adapted) switch chip integrations onto NICs. In that sense, OVS is essentially doing advanced RX steering in software.

I agree that switch functionality (whatever that specifically implies) is not strictly required for the host if you consider queue redirection as part of RX steering. The exception here would be use of SR-IOV which could be highly interesting for corner cases if combined with smart elephant guest detection. A classic example would be NFV deployed in a virtualized environment, i.e. a virtual firewall or DPI application serving a bunch of guests.

Quoted 3 lines

If this is something that doesn't require any model change to the stack and is just a clever backend for rx-filters or tc, then I'm fine with that!

I haven't seen any model change proposed. I'm most certainly not advocating that. Anyone who can live a model change might as well just stick to SnabbSwitch or DPDK.

#63 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

In reply to Jiri Pirko
Quoted 14 lines · Jiri Pirko
Quoted 7 lines · Fri, Sep 19, 2014 at 05:25:48PM CEST, [email protected] wrote:
Quoted 4 lines · Jiri Pirko

This patch exposes switchdev API using generic Netlink. Example userspace utility is here:
https://github.com/jpirko/switchdev

Is this just a temporary test tool? Otherwise i dont see reason for its existence (or the API that it feeds on).

Please read the conversation I had with Pravin and Jesse in v1 thread. Long story short they like to have the api separated from ovs datapath so ovs daemon can use it to directly communicate with driver. Also John Fastabend requested a way to work with driver flows without using ovs -> that was the original reason I created switchdev genl api.

Quoted 4 lines

Regarding the "sw" tool, yes it is for testing purposes now. ovs daemon will use directly switchdev genl api.

I hope I cleared this out.

We already have all the needed rtnetlink kernel api and userspace tools around it to support all switching asic features. ie, the rtnetlink api is the switchdev api. We can do l2, l3, acl's with it. Its unclear to me why we need another new netlink api. Which will mean none of the existing tools to create bridges etc will work on a switchdev.
Which seems like going in the direction exactly opposite to what we had discussed earlier.

If a non-ovs flow interface is needed from userspace, we can extend the existing interface to include flows. I don't understand why we should replace the existing rtnetlink switchdev api to accommodate flows.

Thanks,
Roopa

maintainer
#64 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

Quoted 18 lines · Sat, Sep 20, 2014 at 05:41:16AM CEST, [email protected] wrote:
Quoted 17 lines · Jiri Pirko
Quoted 7 lines · Fri, Sep 19, 2014 at 05:25:48PM CEST, [email protected] wrote:
Quoted 4 lines · Jiri Pirko

This patch exposes switchdev API using generic Netlink. Example userspace utility is here:
https://github.com/jpirko/switchdev

Is this just a temporary test tool? Otherwise i dont see reason for its existence (or the API that it feeds on).

Please read the conversation I had with Pravin and Jesse in v1 thread. Long story short they like to have the api separated from ovs datapath so ovs daemon can use it to directly communicate with driver. Also John Fastabend requested a way to work with driver flows without using ovs -> that was the original reason I created switchdev genl api.

Regarding the "sw" tool, yes it is for testing purposes now. ovs daemon will use directly switchdev genl api.

Quoted 8 lines
Quoted 1 line

I hope I cleared this out.

We already have all the needed rtnetlink kernel api and userspace tools around it to support all
switching asic features. ie, the rtnetlink api is the switchdev api. We can do l2, l3, acl's with it.
Its unclear to me why we need another new netlink api. Which will mean none of the existing tools to
create bridges etc will work on a switchdev.

No one is proposing such API. Note that what I'm trying to solve in my patchset is FLOW world. There is only one API there, ovs genl. But the usage of that for hw offload purposes was nacked by ovs maintainer. Plus couple of people wanted to run the offloading independently on ovs instance. Therefore I introduced the switchdev genl, which takes care of that. No plan to extend it for other things you mentioned, just flows.

Quoted 2 lines

Which seems like going in the direction exactly opposite to what we had discussed earlier.

Nope. The previous discussion ignored flows.

Quoted 3 lines

If a non-ovs flow interface is needed from userspace, we can extend the existing interface to include flows.

How? You mean to extend rtnetlink? What advantage it would bring comparing to separate genl iface?

Quoted 2 lines

I don't understand why we should replace the existing rtnetlink switchdev api to accommodate flows.

Sorry, I do not undertand what "existing rtnetlink switchdev api" you have on mind. Would you care to explain?

Quoted 4 lines

Thanks,
Roopa

#65 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

Quoted 27 lines · Jiri Pirko
Quoted 18 lines · Sat, Sep 20, 2014 at 05:41:16AM CEST, [email protected] wrote:
Quoted 17 lines · Jiri Pirko
Quoted 7 lines · Fri, Sep 19, 2014 at 05:25:48PM CEST, [email protected] wrote:
Quoted 4 lines · Jiri Pirko

This patch exposes switchdev API using generic Netlink. Example userspace utility is here:
https://github.com/jpirko/switchdev

Is this just a temporary test tool? Otherwise i dont see reason for its existence (or the API that it feeds on).

Please read the conversation I had with Pravin and Jesse in v1 thread. Long story short they like to have the api separated from ovs datapath so ovs daemon can use it to directly communicate with driver. Also John Fastabend requested a way to work with driver flows without using ovs -> that was the original reason I created switchdev genl api.

Regarding the "sw" tool, yes it is for testing purposes now. ovs daemon will use directly switchdev genl api.

Quoted 8 lines
Quoted 1 line

I hope I cleared this out.

We already have all the needed rtnetlink kernel api and userspace tools around it to support all
switching asic features. ie, the rtnetlink api is the switchdev api. We can do l2, l3, acl's with it.
Its unclear to me why we need another new netlink api. Which will mean none of the existing tools to
create bridges etc will work on a switchdev.

Quoted 6 lines

No one is proposing such API. Note that what I'm trying to solve in my patchset is FLOW world. There is only one API there, ovs genl. But the usage of that for hw offload purposes was nacked by ovs maintainer. Plus couple of people wanted to run the offloading independently on ovs instance. Therefore I introduced the switchdev genl, which takes care of that. No plan to extend it for other things you mentioned, just flows.

ok, That was not clear to me. Introducing a new genl api and calling it the switchd dev api can result it non-flow creep into it in the future.

Quoted 9 lines
Quoted 4 lines

Which seems like going in the direction exactly opposite to what we had discussed earlier.

Nope. The previous discussion ignored flows.

Quoted 2 lines

If a non-ovs flow interface is needed from userspace, we can extend the existing interface to include flows.

How? You mean to extend rtnetlink? What advantage it would bring comparing to separate genl iface?

yes. Advantage would be that we dont have yet another parallel switchdev netlink api.

Quoted 4 lines
Quoted 2 lines

I don't understand why we should replace the existing rtnetlink switchdev api to accommodate flows.

Sorry, I do not undertand what "existing rtnetlink switchdev api" you have on mind. Would you care to explain?

I am taking about existing rtnetlink api that bridge, ip link uses to talk l2 and l3 to the kernel. RTM_NEWROUTE etc.

#66 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

In reply to Roopa Prabhu
Quoted 18 lines · Roopa Prabhu
Quoted 17 lines · Jiri Pirko
Quoted 7 lines · Fri, Sep 19, 2014 at 05:25:48PM CEST, [email protected] wrote:
Quoted 4 lines · Jiri Pirko

This patch exposes switchdev API using generic Netlink. Example userspace utility is here:
https://github.com/jpirko/switchdev

Is this just a temporary test tool? Otherwise i dont see reason for its existence (or the API that it feeds on).

Please read the conversation I had with Pravin and Jesse in v1 thread. Long story short they like to have the api separated from ovs datapath so ovs daemon can use it to directly communicate with driver. Also John Fastabend requested a way to work with driver flows without using ovs -> that was the original reason I created switchdev genl api.

Regarding the "sw" tool, yes it is for testing purposes now. ovs daemon will use directly switchdev genl api.

Quoted 6 lines
Quoted 1 line

I hope I cleared this out.

We already have all the needed rtnetlink kernel api and userspace tools around it to support all switching asic features. ie, the rtnetlink api is the switchdev api. We can do l2, l3, acl's with it. Its unclear to me why we need another new netlink api. Which will mean none of the existing tools to create bridges etc will work on a switchdev.
Which seems like going in the direction exactly opposite to what we had discussed earlier.

Existing rtnetlink isn’t available to swdev without some kind of snooping the echoes from the various kernel components (bridge, fib, etc). With swdev_flow, as Jiri has defined it, there is an additional conversion needed to bridge the gap (bad expression, I know) between rtnetlink and swdev_flow. This conversion happens in the kernel components. For example, the bridge module, still driven from userspace by existing rtnetlink, will formulate the necessary swdev_flow insert/remove calls to the swdev driver such that HW will offload the fwd path.

You have:

    user -> rtnetlink -> kernel -> netlink echo -> [some process] -> [some driver] -> HW

Jiri has:

    user -> rtnetlink -> kernel -> swdev_* -> swdev driver -> HW
Quoted 6 lines

If a non-ovs flow interface is needed from userspace, we can extend the existing interface to include flows. I don't understand why we should replace the existing rtnetlink switchdev api to accommodate flows.

Thanks,
Roopa

-scott

#67 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

Quoted 7 lines · Scott Feldman

On Sep 19, 2014, at 8:41 PM, Roopa Prabhu <[email protected]> wrote:

Existing rtnetlink isn’t available to swdev without some kind of snooping the echoes from the various kernel components (bridge, fib, etc).

You have made this claim before Scott and I am still not following.
Why do we need to echo things to get FDB or FIB to work? device ops for FDB offload for example already exist. I think they need to be revamped, but that consensus can be reasonably reached. Why do we
need this flow api for such activities?

cheers,
jamal

A message that is not in the archive (sent off-list or not yet received): DDC24110-C3F5-470F-B9BE-1D1792415D1E-qUQiAmfTcIp+XZJcv9eMoEEOCMrvLtNR@public.gmane.org

#69 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

Quoted 26 lines · Scott Feldman
Quoted 18 lines · Roopa Prabhu
Quoted 17 lines · Jiri Pirko
Quoted 7 lines · Fri, Sep 19, 2014 at 05:25:48PM CEST, jhs-jkUAjuhPggJWk0Htik3J/[email protected]…
Quoted 4 lines · Jiri Pirko

This patch exposes switchdev API using generic Netlink. Example userspace utility is here:
https://github.com/jpirko/switchdev

Is this just a temporary test tool? Otherwise i dont see reason for its existence (or the API that it feeds on).

Please read the conversation I had with Pravin and Jesse in v1 thread. Long story short they like to have the api separated from ovs datapath so ovs daemon can use it to directly communicate with driver. Also John Fastabend requested a way to work with driver flows without using ovs -> that was the original reason I created switchdev genl api.

Regarding the "sw" tool, yes it is for testing purposes now. ovs daemon will use directly switchdev genl api.

Quoted 6 lines
Quoted 1 line

I hope I cleared this out.

We already have all the needed rtnetlink kernel api and userspace tools around it to support all switching asic features. ie, the rtnetlink api is the switchdev api. We can do l2, l3, acl's with it. Its unclear to me why we need another new netlink api. Which will mean none of the existing tools to create bridges etc will work on a switchdev.
Which seems like going in the direction exactly opposite to what we had discussed earlier.

Quoted 8 lines

Existing rtnetlink isn’t available to swdev without some kind of snooping the echoes from the various kernel components (bridge, fib, etc). With swdev_flow, as Jiri has defined it, there is an additional conversion needed to bridge the gap (bad expression, I know) between rtnetlink and swdev_flow. This conversion happens in the kernel components. For example, the bridge module, still driven from userspace by existing rtnetlink, will formulate the necessary swdev_flow insert/remove calls to the swdev driver such that HW will offload the fwd path.

You have:

     user -> rtnetlink -> kernel -> netlink echo -> [some process] -> [some driver] -> HW

Jiri has:

     user -> rtnetlink -> kernel -> swdev_* -> swdev driver -> HW

Keeping the goal to not change or not add a new userspace API in mind,

I have :

    user -> rtnetlink -> kernel -> ndo_op -> swdev driver  -> HW

Jiri has:

    user -> genl (newapi) -> kernel -> swdev_* -> swdev driver -> HW
#70 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

Quoted 45 lines · Roopa Prabhu
Quoted 44 lines · Scott Feldman
Quoted 26 lines · Roopa Prabhu
Quoted 24 lines · Jiri Pirko

Fri, Sep 19, 2014 at 05:25:48PM CEST, [email protected]

Quoted 5 lines · wrote:
Quoted 3 lines · Jiri Pirko

This patch exposes switchdev API using generic Netlink. Example userspace utility is here:

Quoted 7 lines
Quoted 4 lines

https://github.com/jpirko/switchdev

Is this just a temporary test tool? Otherwise i dont see reason for its existence (or the API that it feeds on).

Please read the conversation I had with Pravin and Jesse in v1 thread. Long story short they like to have the api separated from ovs datapath so ovs daemon can use it to directly communicate with driver. Also John Fastabend requested a way to work with driver flows without using ovs -> that was the original reason I created switchdev genl api.

Regarding the "sw" tool, yes it is for testing purposes now. ovs daemon will use directly switchdev genl api.

Quoted 8 lines
Quoted 2 lines

I hope I cleared this out.

We already have all the needed rtnetlink kernel api and userspace tools around it to support all switching asic features. ie, the rtnetlink api is the switchdev api. We can do l2, l3, acl's with it. Its unclear to me why we need another new netlink api. Which will mean none of the existing tools to create bridges etc will work on a switchdev.
Which seems like going in the direction exactly opposite to what we had discussed earlier.

Existing rtnetlink isn’t available to swdev without some kind of snooping the echoes from the various kernel components (bridge, fib, etc). With swdev_flow, as Jiri has defined it, there is an additional conversion needed to bridge the gap (bad expression, I know) between rtnetlink and swdev_flow. This conversion happens in the kernel components. For example, the bridge module, still driven from userspace by existing rtnetlink, will formulate the necessary swdev_flow insert/remove calls to the swdev driver such that HW will offload the fwd path.

You have:

    user -> rtnetlink -> kernel -> netlink echo -> [some process] -> [some driver] -> HW
Quoted 8 lines
Quoted 4 lines

Jiri has:

    user -> rtnetlink -> kernel -> swdev_* -> swdev driver -> HW

Keeping the goal to not change or not add a new userspace API in mind, I have :

    user -> rtnetlink -> kernel -> ndo_op -> swdev driver  -> HW

Then you have the same as Jiri, for the traditional L2/L3 case.

Quoted 2 lines

Jiri has:

    user -> genl (newapi) -> kernel -> swdev_* -> swdev driver -> HW

Jiri’s genl is for userspace apps that are talking rtnetlink, like OVS. It’s not a substitute for rtnetlink, it’s an alternative. The complete picture is:

user -> swdev genl -----

                        \
                         \
                          -------> kernel -> ndo_swdev_* -> swdev driver -> HW
                         /
                        /

user -> rtnetlink ------

-scott

maintainer
#71 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

Quoted 57 lines · Sat, Sep 20, 2014 at 07:21:10PM CEST, [email protected] wrote:
Quoted 45 lines · Roopa Prabhu
Quoted 44 lines · Scott Feldman
Quoted 26 lines · Roopa Prabhu
Quoted 24 lines · Jiri Pirko

Fri, Sep 19, 2014 at 05:25:48PM CEST, [email protected]

Quoted 5 lines · wrote:
Quoted 3 lines · Jiri Pirko

This patch exposes switchdev API using generic Netlink. Example userspace utility is here:

Quoted 7 lines
Quoted 4 lines

https://github.com/jpirko/switchdev

Is this just a temporary test tool? Otherwise i dont see reason for its existence (or the API that it feeds on).

Please read the conversation I had with Pravin and Jesse in v1 thread. Long story short they like to have the api separated from ovs datapath so ovs daemon can use it to directly communicate with driver. Also John Fastabend requested a way to work with driver flows without using ovs -> that was the original reason I created switchdev genl api.

Regarding the "sw" tool, yes it is for testing purposes now. ovs daemon will use directly switchdev genl api.

Quoted 8 lines
Quoted 2 lines

I hope I cleared this out.

We already have all the needed rtnetlink kernel api and userspace tools around it to support all switching asic features. ie, the rtnetlink api is the switchdev api. We can do l2, l3, acl's with it. Its unclear to me why we need another new netlink api. Which will mean none of the existing tools to create bridges etc will work on a switchdev.
Which seems like going in the direction exactly opposite to what we had discussed earlier.

Existing rtnetlink isn’t available to swdev without some kind of snooping the echoes from the various kernel components (bridge, fib, etc). With swdev_flow, as Jiri has defined it, there is an additional conversion needed to bridge the gap (bad expression, I know) between rtnetlink and swdev_flow. This conversion happens in the kernel components. For example, the bridge module, still driven from userspace by existing rtnetlink, will formulate the necessary swdev_flow insert/remove calls to the swdev driver such that HW will offload the fwd path.

You have:

    user -> rtnetlink -> kernel -> netlink echo -> [some process] -> [some driver] -> HW
Quoted 8 lines
Quoted 4 lines

Jiri has:

    user -> rtnetlink -> kernel -> swdev_* -> swdev driver -> HW

Keeping the goal to not change or not add a new userspace API in mind, I have :

    user -> rtnetlink -> kernel -> ndo_op -> swdev driver  -> HW
Quoted 6 lines

Then you have the same as Jiri, for the traditional L2/L3 case.

Quoted 2 lines

Jiri has:

    user -> genl (newapi) -> kernel -> swdev_* -> swdev driver -> HW

Jiri’s genl is for userspace apps that are talking rtnetlink, like OVS. It’s not a substitute for rtnetlink, it’s an alternative. The complete picture is:

Not an alternative, an addition.

Quoted 8 lines

user -> swdev genl -----

                       \
                        \
                         -------> kernel -> ndo_swdev_* -> swdev driver -> HW
                        /
                       /

user -> rtnetlink ------

True is that, as Thomas pointed out, we can probably nest this into rtnl_link messages. That might work.

#72 lore raw

Re: [patch net-next v2 8/9] switchdev: introduce Netlink API

Quoted 70 lines · Jiri Pirko
Quoted 55 lines · Sat, Sep 20, 2014 at 07:21:10PM CEST, [email protected] wrote:
Quoted 45 lines · Roopa Prabhu
Quoted 44 lines · Scott Feldman
Quoted 26 lines · Roopa Prabhu
Quoted 24 lines · Jiri Pirko

Fri, Sep 19, 2014 at 05:25:48PM CEST, [email protected]

Quoted 5 lines · wrote:
Quoted 3 lines · Jiri Pirko

This patch exposes switchdev API using generic Netlink. Example userspace utility is here:

Quoted 7 lines
Quoted 4 lines

https://github.com/jpirko/switchdev

Is this just a temporary test tool? Otherwise i dont see reason for its existence (or the API that it feeds on).

Please read the conversation I had with Pravin and Jesse in v1 thread. Long story short they like to have the api separated from ovs datapath so ovs daemon can use it to directly communicate with driver. Also John Fastabend requested a way to work with driver flows without using ovs -> that was the original reason I created switchdev genl api.

Regarding the "sw" tool, yes it is for testing purposes now. ovs daemon will use directly switchdev genl api.

Quoted 8 lines
Quoted 2 lines

I hope I cleared this out.

We already have all the needed rtnetlink kernel api and userspace tools around it to support all switching asic features. ie, the rtnetlink api is the switchdev api. We can do l2, l3, acl's with it. Its unclear to me why we need another new netlink api. Which will mean none of the existing tools to create bridges etc will work on a switchdev.
Which seems like going in the direction exactly opposite to what we had discussed earlier.

Existing rtnetlink isn’t available to swdev without some kind of snooping the echoes from the various kernel components (bridge, fib, etc). With swdev_flow, as Jiri has defined it, there is an additional conversion needed to bridge the gap (bad expression, I know) between rtnetlink and swdev_flow. This conversion happens in the kernel components. For example, the bridge module, still driven from userspace by existing rtnetlink, will formulate the necessary swdev_flow insert/remove calls to the swdev driver such that HW will offload the fwd path.

You have:

     user -> rtnetlink -> kernel -> netlink echo -> [some process] -> [some driver] -> HW
Quoted 8 lines
Quoted 4 lines

Jiri has:

     user -> rtnetlink -> kernel -> swdev_* -> swdev driver -> HW

Keeping the goal to not change or not add a new userspace API in mind, I have :

     user -> rtnetlink -> kernel -> ndo_op -> swdev driver  -> HW
Quoted 5 lines

Then you have the same as Jiri, for the traditional L2/L3 case.

Quoted 2 lines

Jiri has:

     user -> genl (newapi) -> kernel -> swdev_* -> swdev driver -> HW

Jiri’s genl is for userspace apps that are talking rtnetlink, like OVS. It’s not a substitute for rtnetlink, it’s an alternative. The complete picture is:

Not an alternative, an addition.

Quoted 7 lines

user -> swdev genl -----

                        \
                         \
                          -------> kernel -> ndo_swdev_* -> swdev driver -> HW
                         /
                        /

user -> rtnetlink ------

Quoted 2 lines

True is that, as Thomas pointed out, we can probably nest this into rtnl_link messages. That might work.

That's the thing i was hinting as well. You can extend the existing infrastructure/api instead of adding a new one.

maintainer
#73 lore raw

PATCH v2 9/9 rocker: introduce rocker switch driver

In reply to Jiri Pirko

This patch introduces the first driver to benefit from the switchdev infrastructure and to implement newly introduced switch ndos. This is a driver for emulated switch chip implemented in qemu:
https://github.com/sfeldma/qemu-rocker/

This patch is a result of joint work with Scott Feldman.

---
 MAINTAINERS                          |    6 +
 drivers/net/ethernet/Kconfig         |    1 +
 drivers/net/ethernet/Makefile        |    1 +
 drivers/net/ethernet/rocker/Kconfig  |   29 +
 drivers/net/ethernet/rocker/Makefile |    5 +
 drivers/net/ethernet/rocker/rocker.c | 3561 ++++++++++++++++++++++++++++++++++
 drivers/net/ethernet/rocker/rocker.h |  465 +++++
 7 files changed, 4068 insertions(+)
 create mode 100644 drivers/net/ethernet/rocker/Kconfig
 create mode 100644 drivers/net/ethernet/rocker/Makefile
 create mode 100644 drivers/net/ethernet/rocker/rocker.c
 create mode 100644 drivers/net/ethernet/rocker/rocker.h
MAINTAINERS +6 -0
index 0fe2822..703f482 100644
@@ -7656,6 +7656,12 @@ F:	drivers/hid/hid-roccat*
 F:	include/linux/hid-roccat*
 F:	Documentation/ABI/*/sysfs-driver-hid-roccat*
 
+ROCKER DRIVER
+M:	Jiri Pirko <[email protected]>
+L:	[email protected]
+S:	Supported
+F:	drivers/net/ethernet/rocker/
+
 ROCKETPORT DRIVER
 P:	Comtrol Corp.
 W:	http://www.comtrol.com
drivers/net/ethernet/Kconfig +1 -0
index dc7406c..61c9cc4 100644
@@ -153,6 +153,7 @@ source "drivers/net/ethernet/qlogic/Kconfig"
 source "drivers/net/ethernet/realtek/Kconfig"
 source "drivers/net/ethernet/renesas/Kconfig"
 source "drivers/net/ethernet/rdc/Kconfig"
+source "drivers/net/ethernet/rocker/Kconfig"
 
 config S6GMAC
 	tristate "S6105 GMAC ethernet support"
drivers/net/ethernet/Makefile +1 -0
index 224a018..51ff723 100644
@@ -63,6 +63,7 @@ obj-$(CONFIG_NET_VENDOR_QLOGIC) += qlogic/
 obj-$(CONFIG_NET_VENDOR_REALTEK) += realtek/
 obj-$(CONFIG_SH_ETH) += renesas/
 obj-$(CONFIG_NET_VENDOR_RDC) += rdc/
+obj-$(CONFIG_NET_VENDOR_ROCKER) += rocker/
 obj-$(CONFIG_S6GMAC) += s6gmac.o
 obj-$(CONFIG_NET_VENDOR_SAMSUNG) += samsung/
 obj-$(CONFIG_NET_VENDOR_SEEQ) += seeq/
drivers/net/ethernet/rocker/Kconfig new file +29 -0
new file mode 100644
index 0000000..0441932
@@ -0,0 +1,29 @@
+#
+# Rocker device configuration
+#
+
+config NET_VENDOR_ROCKER
+	bool "Rocker devices"
+	default y
+	---help---
+	  If you have a network (Ethernet) card belonging to this class, say Y
+	  and read the Ethernet-HOWTO, available from
+	  <http://www.tldp.org/docs.html#howto>.
+
+	  Note that the answer to this question doesn't directly affect the
+	  kernel: saying N will just cause the configurator to skip all
+	  the questions about Rocker devices. If you say Y, you will be asked for
+	  your specific card in the following questions.
+
+if NET_VENDOR_ROCKER
+
+config ROCKER
+	tristate "Rocker switch driver (EXPERIMENTAL)"
+	depends on PCI && NET_SWITCHDEV
+	---help---
+	  This driver supports Rocker switch device.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called rocker.
+
+endif # NET_VENDOR_ROCKER
drivers/net/ethernet/rocker/Makefile new file +5 -0
new file mode 100644
index 0000000..f85fb12
@@ -0,0 +1,5 @@
+#
+# Makefile for the Rocker network device drivers.
+#
+
+obj-$(CONFIG_ROCKER) += rocker.o
drivers/net/ethernet/rocker/rocker.c new file +3561 -0

2,940 lines not on this page · raw message

drivers/net/ethernet/rocker/rocker.h new file +465 -0

465 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.9.3

Part of the diff is not shown here. View the raw message.