Skip to contentSkip to conversation

i40e: Remove CONFIG_I40E_VXLAN

PATCH Superseded Anjali Singhai Jain 3 participants 9 messages Sep 8, 2015 – Sep 11, 2015

Subsystems (8)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/5 i40e: Remove CONFIG_I40E_VXLAN

If the kernel flag CONFIG_VXLAN is true or CONFIG_VXLAN_MODULE is true, enable VXLAN offload in the driver.

---
 drivers/net/ethernet/intel/Kconfig          | 11 -----------
 drivers/net/ethernet/intel/i40e/i40e.h      |  4 ----
 drivers/net/ethernet/intel/i40e/i40e_main.c | 14 ++++----------
 3 files changed, 4 insertions(+), 25 deletions(-)
drivers/net/ethernet/intel/Kconfig +0 -11
index 4163b16..061e4e0 100644
@@ -269,17 +269,6 @@ config I40E
 	  To compile this driver as a module, choose M here. The module
 	  will be called i40e.
 
-config I40E_VXLAN
-	bool "Virtual eXtensible Local Area Network Support"
-	default n
-	depends on I40E && VXLAN && !(I40E=y && VXLAN=m)
-	---help---
-	  This allows one to create VXLAN virtual interfaces that provide
-	  Layer 2 Networks over Layer 3 Networks. VXLAN is often used
-	  to tunnel virtual network infrastructure in virtualized environments.
-	  Say Y here if you want to use Virtual eXtensible Local Area Network
-	  (VXLAN) in the driver.
-
 config I40E_DCB
 	bool "Data Center Bridging (DCB) Support"
 	default n
drivers/net/ethernet/intel/i40e/i40e.h +0 -4
index c9fa289..257f7d8 100644
@@ -274,11 +274,9 @@ struct i40e_pf {
 	u32 fd_atr_cnt;
 	u32 fd_tcp_rule;
 
-#ifdef CONFIG_I40E_VXLAN
 	__be16  vxlan_ports[I40E_MAX_PF_UDP_OFFLOAD_PORTS];
 	u16 pending_vxlan_bitmap;
 
-#endif
 	enum i40e_interrupt_policy int_policy;
 	u16 rx_itr_default;
 	u16 tx_itr_default;
@@ -316,9 +314,7 @@ struct i40e_pf {
 #define I40E_FLAG_FD_ATR_ENABLED		BIT_ULL(22)
 #define I40E_FLAG_PTP				BIT_ULL(25)
 #define I40E_FLAG_MFP_ENABLED			BIT_ULL(26)
-#ifdef CONFIG_I40E_VXLAN
 #define I40E_FLAG_VXLAN_FILTER_SYNC		BIT_ULL(27)
-#endif
 #define I40E_FLAG_PORT_ID_VALID			BIT_ULL(28)
 #define I40E_FLAG_DCB_CAPABLE			BIT_ULL(29)
 #define I40E_FLAG_RSS_AQ_CAPABLE		BIT_ULL(31)
drivers/net/ethernet/intel/i40e/i40e_main.c +4 -10
index aef0a4c..d75dbf3 100644
@@ -28,7 +28,7 @@
 #include "i40e.h"
 #include "i40e_helper.h"
 #include "i40e_diag.h"
-#ifdef CONFIG_I40E_VXLAN
+#if IS_ENABLED(CONFIG_VXLAN)
 #include <net/vxlan.h>
 #endif
 
@@ -4934,7 +4934,7 @@ int i40e_open(struct net_device *netdev)
 						       TCP_FLAG_CWR) >> 16);
 	wr32(&pf->hw, I40E_GLLAN_TSOMSK_L, be32_to_cpu(TCP_FLAG_CWR) >> 16);
 
-#ifdef CONFIG_I40E_VXLAN
+#if IS_ENABLED(CONFIG_VXLAN)
 	vxlan_get_rx_port(netdev);
 #endif
 
@@ -6659,13 +6659,13 @@ static void i40e_handle_mdd_event(struct i40e_pf *pf)
 	i40e_flush(hw);
 }
 
-#ifdef CONFIG_I40E_VXLAN
 /**
  * i40e_sync_vxlan_filters_subtask - Sync the VSI filter list with HW
  * @pf: board private structure
  **/
 static void i40e_sync_vxlan_filters_subtask(struct i40e_pf *pf)
 {
+#if IS_ENABLED(CONFIG_VXLAN)
 	struct i40e_hw *hw = &pf->hw;
 	i40e_status ret;
 	__be16 port;
@@ -6699,9 +6699,9 @@ static void i40e_sync_vxlan_filters_subtask(struct i40e_pf *pf)
 			}
 		}
 	}
+#endif
 }
 
-#endif
 /**
  * i40e_service_task - Run the driver's async subtasks
  * @work: pointer to work_struct containing our data
@@ -6725,9 +6725,7 @@ static void i40e_service_task(struct work_struct *work)
 	i40e_watchdog_subtask(pf);
 	i40e_fdir_reinit_subtask(pf);
 	i40e_sync_filters_subtask(pf);
-#ifdef CONFIG_I40E_VXLAN
 	i40e_sync_vxlan_filters_subtask(pf);
-#endif
 	i40e_clean_adminq_subtask(pf);
 
 	i40e_service_event_complete(pf);
@@ -7944,7 +7942,6 @@ static int i40e_set_features(struct net_device *netdev,
 	return 0;
 }
 
-#ifdef CONFIG_I40E_VXLAN
 /**
  * i40e_get_vxlan_port_idx - Lookup a possibly offloaded for Rx UDP port
  * @pf: board private structure
@@ -8039,7 +8036,6 @@ 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_item_id *ppid)
 {
@@ -8262,10 +8258,8 @@ static const struct net_device_ops i40e_netdev_ops = {
 	.ndo_get_vf_config	= i40e_ndo_get_vf_config,
 	.ndo_set_vf_link_state	= i40e_ndo_set_vf_link_state,
 	.ndo_set_vf_spoofchk	= i40e_ndo_set_vf_spoofchk,
-#ifdef CONFIG_I40E_VXLAN
 	.ndo_add_vxlan_port	= i40e_add_vxlan_port,
 	.ndo_del_vxlan_port	= i40e_del_vxlan_port,
-#endif
 	.ndo_get_phys_port_id	= i40e_get_phys_port_id,
 	.ndo_fdb_add		= i40e_ndo_fdb_add,
 	.ndo_features_check	= i40e_features_check,
Signature · 1 line
1.8.1.4
#1 lore raw

PATCH v2 2/5 vxlan: Generalize udp based tunnel offload

Replace add/del ndo ops for vxlan_port with tunnel_port so that all UDP based tunnels can use the same ndo op. Add a parameter to pass tunnel type to the ndo_op.

---
 drivers/net/vxlan.c       | 20 ++++++++++----------
 include/linux/netdevice.h | 33 ++++++++++++++++-----------------
 include/net/udp_tunnel.h  |  6 ++++++
 3 files changed, 32 insertions(+), 27 deletions(-)
drivers/net/vxlan.c +10 -10
index 61b457b..538e846 100644
@@ -629,9 +629,9 @@ static void vxlan_notify_add_rx_port(struct vxlan_sock *vs)
 
 	rcu_read_lock();
 	for_each_netdev_rcu(net, dev) {
-		if (dev->netdev_ops->ndo_add_vxlan_port)
-			dev->netdev_ops->ndo_add_vxlan_port(dev, sa_family,
-							    port);
+		if (dev->netdev_ops->ndo_add_tunnel_port)
+			dev->netdev_ops->ndo_add_tunnel_port(dev, sa_family,
+							port, UDP_TUNNEL_VXLAN);
 	}
 	rcu_read_unlock();
 }
@@ -647,9 +647,9 @@ static void vxlan_notify_del_rx_port(struct vxlan_sock *vs)
 
 	rcu_read_lock();
 	for_each_netdev_rcu(net, dev) {
-		if (dev->netdev_ops->ndo_del_vxlan_port)
-			dev->netdev_ops->ndo_del_vxlan_port(dev, sa_family,
-							    port);
+		if (dev->netdev_ops->ndo_del_tunnel_port)
+			dev->netdev_ops->ndo_del_tunnel_port(dev, sa_family,
+							port, UDP_TUNNEL_VXLAN);
 	}
 	rcu_read_unlock();
 
@@ -2379,9 +2379,9 @@ static struct device_type vxlan_type = {
 	.name = "vxlan",
 };
 
-/* Calls the ndo_add_vxlan_port of the caller in order to
+/* Calls the ndo_add_tunnel_port of the caller in order to
  * supply the listening VXLAN udp ports. Callers are expected
- * to implement the ndo_add_vxlan_port.
+ * to implement the ndo_add_tunnel_port.
  */
 void vxlan_get_rx_port(struct net_device *dev)
 {
@@ -2397,8 +2397,8 @@ void vxlan_get_rx_port(struct net_device *dev)
 		hlist_for_each_entry_rcu(vs, &vn->sock_list[i], hlist) {
 			port = inet_sk(vs->sock->sk)->inet_sport;
 			sa_family = vxlan_get_sk_family(vs);
-			dev->netdev_ops->ndo_add_vxlan_port(dev, sa_family,
-							    port);
+			dev->netdev_ops->ndo_add_tunnel_port(dev, sa_family,
+							port, UDP_TUNNEL_VXLAN);
 		}
 	}
 	spin_unlock(&vn->sock_lock);
include/linux/netdevice.h +16 -17
index c69072b..b6f6beb 100644
@@ -1003,18 +1003,18 @@ typedef u16 (*select_queue_fallback_t)(struct net_device *dev,
  *	not implement this, it is assumed that the hw is not able to have
  *	multiple net devices on single physical port.
  *
- * void (*ndo_add_vxlan_port)(struct  net_device *dev,
- *			      sa_family_t sa_family, __be16 port);
- *	Called by vxlan to notiy a driver about the UDP port and socket
- *	address family that vxlan is listnening to. It is called only when
- *	a new port starts listening. The operation is protected by the
- *	vxlan_net->sock_lock.
- *
- * void (*ndo_del_vxlan_port)(struct  net_device *dev,
- *			      sa_family_t sa_family, __be16 port);
- *	Called by vxlan to notify the driver about a UDP port and socket
- *	address family that vxlan is not listening to anymore. The operation
- *	is protected by the vxlan_net->sock_lock.
+ * void (*ndo_add_tunnel_port)(struct  net_device *dev,
+ *			      sa_family_t sa_family, __be16 port, u32 type);
+ *	Called by UDP based tunnel modules to notify a driver about a UDP
+ *	port and socket address family that the tunnel is listening to. It is
+ *	called only when a new port starts listening. The operation is
+ *	protected by tunnel socket sock_lock.
+ *
+ * void (*ndo_del_tunnel_port)(struct  net_device *dev,
+ *			      sa_family_t sa_family, __be16 port, u32 type);
+ *	Called by UDP based tunnel modules to notify the driver about a UDP port
+ *	and socket address family that tunnel is not listening to anymore.
+ *	The operation is protected by tunnel socket sock_lock.
  *
  * void* (*ndo_dfwd_add_station)(struct net_device *pdev,
  *				 struct net_device *dev)
@@ -1204,13 +1204,12 @@ struct net_device_ops {
 							struct netdev_phys_item_id *ppid);
 	int			(*ndo_get_phys_port_name)(struct net_device *dev,
 							  char *name, size_t len);
-	void			(*ndo_add_vxlan_port)(struct  net_device *dev,
+	void			(*ndo_add_tunnel_port)(struct  net_device *dev,
 						      sa_family_t sa_family,
-						      __be16 port);
-	void			(*ndo_del_vxlan_port)(struct  net_device *dev,
+						      __be16 port, u32 type);
+	void			(*ndo_del_tunnel_port)(struct  net_device *dev,
 						      sa_family_t sa_family,
-						      __be16 port);
-
+						      __be16 port, u32 type);
 	void*			(*ndo_dfwd_add_station)(struct net_device *pdev,
 							struct net_device *dev);
 	void			(*ndo_dfwd_del_station)(struct net_device *pdev,
include/net/udp_tunnel.h +6 -0
index c491c12..328f3ab 100644
@@ -9,6 +9,12 @@
 #include <net/addrconf.h>
 #endif
 
+enum udp_tunnel_type {
+	UDP_TUNNEL_NONE,
+	UDP_TUNNEL_VXLAN,
+	UDP_TUNNEL_GENEVE,
+};
+
 struct udp_port_cfg {
 	u8			family;
 
Signature · 1 line
1.8.1.4
#5 lore raw

PATCH v2 3/5 ethernet: Change drivers to use the generalized udp tunnel offload

In reply to Anjali Singhai Jain

Previous patch in the series replaces vxlan specific ndo_ops with generalized udp_tunnel ndo_ops. This patch propagates the change to all drivers implementing vxlan offload support.

Patch was compile tested with x86_64_defconfig.

---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 14 ++++++---
 drivers/net/ethernet/emulex/benet/be_main.c      | 14 ++++++---
 drivers/net/ethernet/intel/fm10k/fm10k_netdev.c  | 26 ++++++++++++----
 drivers/net/ethernet/intel/i40e/i40e_main.c      | 38 ++++++++++++++++--------
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c    | 16 +++++++---
 drivers/net/ethernet/mellanox/mlx4/en_netdev.c   | 20 +++++++++----
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | 16 +++++++---
 7 files changed, 104 insertions(+), 40 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +10 -4
index 26fbfcc..6c2d5f1 100644
@@ -10117,11 +10117,14 @@ static void __bnx2x_add_vxlan_port(struct bnx2x *bp, u16 port)
 }
 
 static void bnx2x_add_vxlan_port(struct net_device *netdev,
-				 sa_family_t sa_family, __be16 port)
+				 sa_family_t sa_family, __be16 port,
+				 u32 type)
 {
 	struct bnx2x *bp = netdev_priv(netdev);
 	u16 t_port = ntohs(port);
 
+	if (type != UDP_TUNNEL_VXLAN)
+		return;
 	__bnx2x_add_vxlan_port(bp, t_port);
 }
 
@@ -10141,11 +10144,14 @@ static void __bnx2x_del_vxlan_port(struct bnx2x *bp, u16 port)
 }
 
 static void bnx2x_del_vxlan_port(struct net_device *netdev,
-				 sa_family_t sa_family, __be16 port)
+				 sa_family_t sa_family, __be16 port,
+				 u32 type)
 {
 	struct bnx2x *bp = netdev_priv(netdev);
 	u16 t_port = ntohs(port);
 
+	if (type != UDP_TUNNEL_VXLAN)
+		return;
 	__bnx2x_del_vxlan_port(bp, t_port);
 }
 #endif
@@ -13000,8 +13006,8 @@ static const struct net_device_ops bnx2x_netdev_ops = {
 	.ndo_set_vf_link_state	= bnx2x_set_vf_link_state,
 	.ndo_features_check	= bnx2x_features_check,
 #ifdef CONFIG_BNX2X_VXLAN
-	.ndo_add_vxlan_port	= bnx2x_add_vxlan_port,
-	.ndo_del_vxlan_port	= bnx2x_del_vxlan_port,
+	.ndo_add_tunnel_port	= bnx2x_add_vxlan_port,
+	.ndo_del_tunnel_port	= bnx2x_del_vxlan_port,
 #endif
 };
 
drivers/net/ethernet/emulex/benet/be_main.c +10 -4
index 12687bf..c24d352 100644
@@ -5167,12 +5167,15 @@ static int be_ndo_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
  * until after all the tunnels are removed.
  */
 static void be_add_vxlan_port(struct net_device *netdev, sa_family_t sa_family,
-			      __be16 port)
+			      __be16 port, u32 type)
 {
 	struct be_adapter *adapter = netdev_priv(netdev);
 	struct device *dev = &adapter->pdev->dev;
 	int status;
 
+	if (type != UDP_TUNNEL_VXLAN)
+		return;
+
 	if (lancer_chip(adapter) || BEx_chip(adapter) || be_is_mc(adapter))
 		return;
 
@@ -5216,10 +5219,13 @@ err:
 }
 
 static void be_del_vxlan_port(struct net_device *netdev, sa_family_t sa_family,
-			      __be16 port)
+			      __be16 port, u32 type)
 {
 	struct be_adapter *adapter = netdev_priv(netdev);
 
+	if (type != UDP_TUNNEL_VXLAN)
+		return;
+
 	if (lancer_chip(adapter) || BEx_chip(adapter) || be_is_mc(adapter))
 		return;
 
@@ -5324,8 +5330,8 @@ static const struct net_device_ops be_netdev_ops = {
 	.ndo_busy_poll		= be_busy_poll,
 #endif
 #ifdef CONFIG_BE2NET_VXLAN
-	.ndo_add_vxlan_port	= be_add_vxlan_port,
-	.ndo_del_vxlan_port	= be_del_vxlan_port,
+	.ndo_add_tunnel_port    = be_add_vxlan_port,
+	.ndo_del_tunnel_port	= be_del_vxlan_port,
 	.ndo_features_check	= be_features_check,
 #endif
 	.ndo_get_phys_port_id   = be_get_phys_port_id,
drivers/net/ethernet/intel/fm10k/fm10k_netdev.c +20 -6
index 79c0fa2..133408a 100644
@@ -439,18 +439,24 @@ static void fm10k_restore_vxlan_port(struct fm10k_intfc *interface)
  * @netdev: network interface device structure
  * @sa_family: Address family of new port
  * @port: port number used for VXLAN
+ * @type: Tunnel type
  *
- * This funciton is called when a new VXLAN interface has added a new port
+ * This function is called when a new VXLAN interface has added a new port
  * number to the range that is currently in use for VXLAN.  The new port
  * number is always added to the tail so that the port number list should
  * match the order in which the ports were allocated.  The head of the list
  * is always used as the VXLAN port number for offloads.
  **/
 static void fm10k_add_vxlan_port(struct net_device *dev,
-				 sa_family_t sa_family, __be16 port) {
+				 sa_family_t sa_family, __be16 port,
+				 u32 type) {
+#if IS_ENABLED(CONFIG_FM10K_VXLAN)
 	struct fm10k_intfc *interface = netdev_priv(dev);
 	struct fm10k_vxlan_port *vxlan_port;
 
+	if (type != UDP_TUNNEL_VXLAN)
+		return;
+
 	/* only the PF supports configuring tunnels */
 	if (interface->hw.mac.type != fm10k_mac_pf)
 		return;
@@ -476,6 +482,7 @@ insert_tail:
 	list_add_tail(&vxlan_port->list, &interface->vxlan_port);
 
 	fm10k_restore_vxlan_port(interface);
+#endif
 }
 
 /**
@@ -483,17 +490,23 @@ insert_tail:
  * @netdev: network interface device structure
  * @sa_family: Address family of freed port
  * @port: port number used for VXLAN
+ * @type: Tunnel type
  *
- * This funciton is called when a new VXLAN interface has freed a port
+ * This function is called when a new VXLAN interface has freed a port
  * number from the range that is currently in use for VXLAN.  The freed
  * port is removed from the list and the new head is used to determine
  * the port number for offloads.
  **/
 static void fm10k_del_vxlan_port(struct net_device *dev,
-				 sa_family_t sa_family, __be16 port) {
+				 sa_family_t sa_family, __be16 port,
+				 u32 type) {
+#if IS_ENABLED(CONFIG_FM10K_VXLAN)
 	struct fm10k_intfc *interface = netdev_priv(dev);
 	struct fm10k_vxlan_port *vxlan_port;
 
+	if (type != UDP_TUNNEL_VXLAN)
+		return;
+
 	if (interface->hw.mac.type != fm10k_mac_pf)
 		return;
 
@@ -508,6 +521,7 @@ static void fm10k_del_vxlan_port(struct net_device *dev,
 	}
 
 	fm10k_restore_vxlan_port(interface);
+#endif
 }
 
 /**
@@ -1373,8 +1387,8 @@ static const struct net_device_ops fm10k_netdev_ops = {
 	.ndo_set_vf_vlan	= fm10k_ndo_set_vf_vlan,
 	.ndo_set_vf_rate	= fm10k_ndo_set_vf_bw,
 	.ndo_get_vf_config	= fm10k_ndo_get_vf_config,
-	.ndo_add_vxlan_port	= fm10k_add_vxlan_port,
-	.ndo_del_vxlan_port	= fm10k_del_vxlan_port,
+	.ndo_add_tunnel_port	= fm10k_add_vxlan_port,
+	.ndo_del_tunnel_port	= fm10k_del_vxlan_port,
 	.ndo_do_ioctl		= fm10k_ioctl,
 	.ndo_dfwd_add_station	= fm10k_dfwd_add_station,
 	.ndo_dfwd_del_station	= fm10k_dfwd_del_station,
drivers/net/ethernet/intel/i40e/i40e_main.c +26 -12
index d75dbf3..4ec16c0 100644
@@ -7962,20 +7962,26 @@ static u8 i40e_get_vxlan_port_idx(struct i40e_pf *pf, __be16 port)
 }
 
 /**
- * i40e_add_vxlan_port - Get notifications about VXLAN ports that come up
+ * i40e_add_tunnel_port - Get notifications about UDP tunnel ports that come up
  * @netdev: This physical port's netdev
- * @sa_family: Socket Family that VXLAN is notifying us about
- * @port: New UDP port number that VXLAN started listening to
+ * @sa_family: Socket Family that tunnel netdev is  associated with
+ * @port: New UDP port number that tunnel started listening to
+ * @type: Tunnel Type
  **/
-static void i40e_add_vxlan_port(struct net_device *netdev,
-				sa_family_t sa_family, __be16 port)
+static void i40e_add_tunnel_port(struct net_device *netdev,
+				 sa_family_t sa_family, __be16 port,
+				 u32 type)
 {
+#if IS_ENABLED(CONFIG_VXLAN)
 	struct i40e_netdev_priv *np = netdev_priv(netdev);
 	struct i40e_vsi *vsi = np->vsi;
 	struct i40e_pf *pf = vsi->back;
 	u8 next_idx;
 	u8 idx;
 
+	if (type != UDP_TUNNEL_VXLAN)
+		return;
+
 	if (sa_family == AF_INET6)
 		return;
 
@@ -8001,22 +8007,29 @@ static void i40e_add_vxlan_port(struct net_device *netdev,
 	pf->vxlan_ports[next_idx] = port;
 	pf->pending_vxlan_bitmap |= BIT_ULL(next_idx);
 	pf->flags |= I40E_FLAG_VXLAN_FILTER_SYNC;
+#endif
 }
 
 /**
- * i40e_del_vxlan_port - Get notifications about VXLAN ports that go away
+ * i40e_del_tunnel_port - Get notifications about UDP tunnel ports that go away
  * @netdev: This physical port's netdev
- * @sa_family: Socket Family that VXLAN is notifying us about
- * @port: UDP port number that VXLAN stopped listening to
+ * @sa_family: Socket Family that tunnel netdev is associated with
+ * @port: UDP port number that tunnel stopped listening to
+ * @type: Tunnel Type
  **/
-static void i40e_del_vxlan_port(struct net_device *netdev,
-				sa_family_t sa_family, __be16 port)
+static void i40e_del_tunnel_port(struct net_device *netdev,
+				 sa_family_t sa_family, __be16 port,
+				 u32 type)
 {
+#if IS_ENABLED(CONFIG_VXLAN)
 	struct i40e_netdev_priv *np = netdev_priv(netdev);
 	struct i40e_vsi *vsi = np->vsi;
 	struct i40e_pf *pf = vsi->back;
 	u8 idx;
 
+	if (type != UDP_TUNNEL_VXLAN)
+		return;
+
 	if (sa_family == AF_INET6)
 		return;
 
@@ -8034,6 +8047,7 @@ static void i40e_del_vxlan_port(struct net_device *netdev,
 		netdev_warn(netdev, "vxlan port %d was not found, not deleting\n",
 			    ntohs(port));
 	}
+#endif
 }
 
 static int i40e_get_phys_port_id(struct net_device *netdev,
@@ -8258,8 +8272,8 @@ static const struct net_device_ops i40e_netdev_ops = {
 	.ndo_get_vf_config	= i40e_ndo_get_vf_config,
 	.ndo_set_vf_link_state	= i40e_ndo_set_vf_link_state,
 	.ndo_set_vf_spoofchk	= i40e_ndo_set_vf_spoofchk,
-	.ndo_add_vxlan_port	= i40e_add_vxlan_port,
-	.ndo_del_vxlan_port	= i40e_del_vxlan_port,
+	.ndo_add_tunnel_port	= i40e_add_tunnel_port,
+	.ndo_del_tunnel_port	= i40e_del_tunnel_port,
 	.ndo_get_phys_port_id	= i40e_get_phys_port_id,
 	.ndo_fdb_add		= i40e_ndo_fdb_add,
 	.ndo_features_check	= i40e_features_check,
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +12 -4
index 914c1b0..4c132dd 100644
@@ -8080,14 +8080,18 @@ static int ixgbe_set_features(struct net_device *netdev,
  * @dev: The port's netdev
  * @sa_family: Socket Family that VXLAN is notifiying us about
  * @port: New UDP port number that VXLAN started listening to
+ * @type: Tunnel type
  **/
 static void ixgbe_add_vxlan_port(struct net_device *dev, sa_family_t sa_family,
-				 __be16 port)
+				 __be16 port, u32 type)
 {
 	struct ixgbe_adapter *adapter = netdev_priv(dev);
 	struct ixgbe_hw *hw = &adapter->hw;
 	u16 new_port = ntohs(port);
 
+	if (type != UDP_TUNNEL_VXLAN)
+		return;
+
 	if (!(adapter->flags & IXGBE_FLAG_VXLAN_OFFLOAD_CAPABLE))
 		return;
 
@@ -8113,13 +8117,17 @@ static void ixgbe_add_vxlan_port(struct net_device *dev, sa_family_t sa_family,
  * @dev: The port's netdev
  * @sa_family: Socket Family that VXLAN is notifying us about
  * @port: UDP port number that VXLAN stopped listening to
+ * @type: Tunnel type
  **/
 static void ixgbe_del_vxlan_port(struct net_device *dev, sa_family_t sa_family,
-				 __be16 port)
+				 __be16 port, u32 type)
 {
 	struct ixgbe_adapter *adapter = netdev_priv(dev);
 	u16 new_port = ntohs(port);
 
+	if (type != UDP_TUNNEL_VXLAN)
+		return;
+
 	if (!(adapter->flags & IXGBE_FLAG_VXLAN_OFFLOAD_CAPABLE))
 		return;
 
@@ -8428,8 +8436,8 @@ static const struct net_device_ops ixgbe_netdev_ops = {
 	.ndo_dfwd_add_station	= ixgbe_fwd_add,
 	.ndo_dfwd_del_station	= ixgbe_fwd_del,
 #ifdef CONFIG_IXGBE_VXLAN
-	.ndo_add_vxlan_port	= ixgbe_add_vxlan_port,
-	.ndo_del_vxlan_port	= ixgbe_del_vxlan_port,
+	.ndo_add_tunnel_port	= ixgbe_add_vxlan_port,
+	.ndo_del_tunnel_port	= ixgbe_del_vxlan_port,
 #endif /* CONFIG_IXGBE_VXLAN */
 	.ndo_features_check	= ixgbe_features_check,
 };
drivers/net/ethernet/mellanox/mlx4/en_netdev.c +14 -6
index 4726122..8832cae 100644
@@ -2386,11 +2386,15 @@ static void mlx4_en_del_vxlan_offloads(struct work_struct *work)
 }
 
 static void mlx4_en_add_vxlan_port(struct  net_device *dev,
-				   sa_family_t sa_family, __be16 port)
+				   sa_family_t sa_family, __be16 port,
+				   u32 type)
 {
 	struct mlx4_en_priv *priv = netdev_priv(dev);
 	__be16 current_port;
 
+	if (type != UDP_TUNNEL_VXLAN)
+		return;
+
 	if (priv->mdev->dev->caps.tunnel_offload_mode != MLX4_TUNNEL_OFFLOAD_MODE_VXLAN)
 		return;
 
@@ -2409,11 +2413,15 @@ static void mlx4_en_add_vxlan_port(struct  net_device *dev,
 }
 
 static void mlx4_en_del_vxlan_port(struct  net_device *dev,
-				   sa_family_t sa_family, __be16 port)
+				   sa_family_t sa_family, __be16 port,
+				   u32 type)
 {
 	struct mlx4_en_priv *priv = netdev_priv(dev);
 	__be16 current_port;
 
+	if (type != UDP_TUNNEL_VXLAN)
+		return;
+
 	if (priv->mdev->dev->caps.tunnel_offload_mode != MLX4_TUNNEL_OFFLOAD_MODE_VXLAN)
 		return;
 
@@ -2493,8 +2501,8 @@ static const struct net_device_ops mlx4_netdev_ops = {
 #endif
 	.ndo_get_phys_port_id	= mlx4_en_get_phys_port_id,
 #ifdef CONFIG_MLX4_EN_VXLAN
-	.ndo_add_vxlan_port	= mlx4_en_add_vxlan_port,
-	.ndo_del_vxlan_port	= mlx4_en_del_vxlan_port,
+	.ndo_add_tunnel_port	= mlx4_en_add_vxlan_port,
+	.ndo_del_tunnel_port	= mlx4_en_del_vxlan_port,
 	.ndo_features_check	= mlx4_en_features_check,
 #endif
 	.ndo_set_tx_maxrate	= mlx4_en_set_tx_maxrate,
@@ -2531,8 +2539,8 @@ static const struct net_device_ops mlx4_netdev_ops_master = {
 #endif
 	.ndo_get_phys_port_id	= mlx4_en_get_phys_port_id,
 #ifdef CONFIG_MLX4_EN_VXLAN
-	.ndo_add_vxlan_port	= mlx4_en_add_vxlan_port,
-	.ndo_del_vxlan_port	= mlx4_en_del_vxlan_port,
+	.ndo_add_tunnel_port	= mlx4_en_add_vxlan_port,
+	.ndo_del_tunnel_port	= mlx4_en_del_vxlan_port,
 	.ndo_features_check	= mlx4_en_features_check,
 #endif
 	.ndo_set_tx_maxrate	= mlx4_en_set_tx_maxrate,
drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +12 -4
index 8b08b20..048108f 100644
@@ -475,11 +475,15 @@ static int qlcnic_get_phys_port_id(struct net_device *netdev,
 
 #ifdef CONFIG_QLCNIC_VXLAN
 static void qlcnic_add_vxlan_port(struct net_device *netdev,
-				  sa_family_t sa_family, __be16 port)
+				  sa_family_t sa_family, __be16 port,
+				  u32 type)
 {
 	struct qlcnic_adapter *adapter = netdev_priv(netdev);
 	struct qlcnic_hardware_context *ahw = adapter->ahw;
 
+	if (type != UDP_TUNNEL_VXLAN)
+		return;
+
 	/* Adapter supports only one VXLAN port. Use very first port
 	 * for enabling offload
 	 */
@@ -491,11 +495,15 @@ static void qlcnic_add_vxlan_port(struct net_device *netdev,
 }
 
 static void qlcnic_del_vxlan_port(struct net_device *netdev,
-				  sa_family_t sa_family, __be16 port)
+				  sa_family_t sa_family, __be16 port,
+				  u32 type)
 {
 	struct qlcnic_adapter *adapter = netdev_priv(netdev);
 	struct qlcnic_hardware_context *ahw = adapter->ahw;
 
+	if (type != UDP_TUNNEL_VXLAN)
+		return;
+
 	if (!qlcnic_encap_rx_offload(adapter) || !ahw->vxlan_port ||
 	    (ahw->vxlan_port != ntohs(port)))
 		return;
@@ -531,8 +539,8 @@ static const struct net_device_ops qlcnic_netdev_ops = {
 	.ndo_fdb_dump		= qlcnic_fdb_dump,
 	.ndo_get_phys_port_id	= qlcnic_get_phys_port_id,
 #ifdef CONFIG_QLCNIC_VXLAN
-	.ndo_add_vxlan_port	= qlcnic_add_vxlan_port,
-	.ndo_del_vxlan_port	= qlcnic_del_vxlan_port,
+	.ndo_add_tunnel_port	= qlcnic_add_vxlan_port,
+	.ndo_del_tunnel_port	= qlcnic_del_vxlan_port,
 	.ndo_features_check	= qlcnic_features_check,
 #endif
 #ifdef CONFIG_NET_POLL_CONTROLLER
Signature · 1 line
1.8.1.4
#6 lore raw

PATCH v2 4/5 i40e: Generalize the flow for udp based tunnels

In reply to Anjali Singhai Jain

This patch generalizes the driver flow to make room for more than just VXLAN tunnel by defining a common data structure with tunnel type.

---
 drivers/net/ethernet/intel/i40e/i40e.h      | 11 ++++--
 drivers/net/ethernet/intel/i40e/i40e_main.c | 54 ++++++++++++++++-------------
 drivers/net/ethernet/intel/i40e/i40e_txrx.c |  6 ++--
 drivers/net/ethernet/intel/i40e/i40e_txrx.h |  2 +-
 4 files changed, 41 insertions(+), 32 deletions(-)
drivers/net/ethernet/intel/i40e/i40e.h +8 -3
index 257f7d8..71752c6 100644
@@ -237,6 +237,11 @@ struct i40e_tc_configuration {
 	struct i40e_tc_info tc_info[I40E_MAX_TRAFFIC_CLASS];
 };
 
+struct i40e_udp_port_config {
+	__be16 index;
+	u8 type;
+};
+
 /* struct that defines the Ethernet device */
 struct i40e_pf {
 	struct pci_dev *pdev;
@@ -274,8 +279,8 @@ struct i40e_pf {
 	u32 fd_atr_cnt;
 	u32 fd_tcp_rule;
 
-	__be16  vxlan_ports[I40E_MAX_PF_UDP_OFFLOAD_PORTS];
-	u16 pending_vxlan_bitmap;
+	struct i40e_udp_port_config udp_ports[I40E_MAX_PF_UDP_OFFLOAD_PORTS];
+	u16 pending_udp_bitmap;
 
 	enum i40e_interrupt_policy int_policy;
 	u16 rx_itr_default;
@@ -314,7 +319,7 @@ struct i40e_pf {
 #define I40E_FLAG_FD_ATR_ENABLED		BIT_ULL(22)
 #define I40E_FLAG_PTP				BIT_ULL(25)
 #define I40E_FLAG_MFP_ENABLED			BIT_ULL(26)
-#define I40E_FLAG_VXLAN_FILTER_SYNC		BIT_ULL(27)
+#define I40E_FLAG_UDP_FILTER_SYNC              BIT_ULL(27)
 #define I40E_FLAG_PORT_ID_VALID			BIT_ULL(28)
 #define I40E_FLAG_DCB_CAPABLE			BIT_ULL(29)
 #define I40E_FLAG_RSS_AQ_CAPABLE		BIT_ULL(31)
drivers/net/ethernet/intel/i40e/i40e_main.c +29 -25

141 lines not on this page · raw message

drivers/net/ethernet/intel/i40e/i40e_txrx.c +3 -3
index 0fbcd05..424c5cc 100644
@@ -2007,7 +2007,7 @@ static void i40e_atr(struct i40e_ring *tx_ring, struct sk_buff *skb,
 	if (!(tx_flags & (I40E_TX_FLAGS_IPV4 | I40E_TX_FLAGS_IPV6)))
 		return;
 
-	if (!(tx_flags & I40E_TX_FLAGS_VXLAN_TUNNEL)) {
+	if (!(tx_flags & I40E_TX_FLAGS_UDP_TUNNEL)) {
 		/* snag network header to get L4 type and address */
 		hdr.network = skb_network_header(skb);
 
@@ -2092,7 +2092,7 @@ static void i40e_atr(struct i40e_ring *tx_ring, struct sk_buff *skb,
 		     I40E_TXD_FLTR_QW1_FD_STATUS_SHIFT;
 
 	dtype_cmd |= I40E_TXD_FLTR_QW1_CNT_ENA_MASK;
-	if (!(tx_flags & I40E_TX_FLAGS_VXLAN_TUNNEL))
+	if (!(tx_flags & I40E_TX_FLAGS_UDP_TUNNEL))
 		dtype_cmd |=
 			((u32)I40E_FD_ATR_STAT_IDX(pf->hw.pf_id) <<
 			I40E_TXD_FLTR_QW1_CNTINDEX_SHIFT) &
@@ -2323,7 +2323,7 @@ static void i40e_tx_enable_csum(struct sk_buff *skb, u32 *tx_flags,
 			oudph = udp_hdr(skb);
 			oiph = ip_hdr(skb);
 			l4_tunnel = I40E_TXD_CTX_UDP_TUNNELING;
-			*tx_flags |= I40E_TX_FLAGS_VXLAN_TUNNEL;
+			*tx_flags |= I40E_TX_FLAGS_UDP_TUNNEL;
 			break;
 		default:
 			return;
drivers/net/ethernet/intel/i40e/i40e_txrx.h +1 -1
index a992cb8f..db2130f 100644
@@ -151,7 +151,7 @@ enum i40e_dyn_idx_t {
 #define I40E_TX_FLAGS_FSO		BIT(7)
 #define I40E_TX_FLAGS_TSYN		BIT(8)
 #define I40E_TX_FLAGS_FD_SB		BIT(9)
-#define I40E_TX_FLAGS_VXLAN_TUNNEL	BIT(10)
+#define I40E_TX_FLAGS_UDP_TUNNEL	BIT(10)
 #define I40E_TX_FLAGS_VLAN_MASK		0xffff0000
 #define I40E_TX_FLAGS_VLAN_PRIO_MASK	0xe0000000
 #define I40E_TX_FLAGS_VLAN_PRIO_SHIFT	29
Signature · 1 line
1.8.1.4
#7 lore raw

PATCH v2 5/5 i40e: Add geneve tunnel offload support

In reply to Anjali Singhai Jain

This patch adds driver hooks to implement ndo_ops to add/del udp port in the HW to identify GENEVE tunnels.

---
 drivers/net/ethernet/intel/i40e/i40e.h      |  1 +
 drivers/net/ethernet/intel/i40e/i40e_main.c | 22 ++++++++++++++++------
 drivers/net/ethernet/intel/i40e/i40e_txrx.c |  2 +-
 3 files changed, 18 insertions(+), 7 deletions(-)
drivers/net/ethernet/intel/i40e/i40e.h +1 -0
index 71752c6..12c96da 100644
@@ -330,6 +330,7 @@ struct i40e_pf {
 #define I40E_FLAG_VEB_STATS_ENABLED		BIT_ULL(37)
 #define I40E_FLAG_MULTIPLE_TCP_UDP_RSS_PCTYPE	BIT_ULL(38)
 #define I40E_FLAG_VEB_MODE_ENABLED		BIT_ULL(40)
+#define I40E_FLAG_GENEVE_OFFLOAD_CAPABLE	BIT_ULL(41)
 
 	/* tracks features that get auto disabled by errors */
 	u64 auto_disable_flags;
drivers/net/ethernet/intel/i40e/i40e_main.c +16 -6
index b3a6cdf..9bbafc3 100644
@@ -31,6 +31,9 @@
 #if IS_ENABLED(CONFIG_VXLAN)
 #include <net/vxlan.h>
 #endif
+#if IS_ENABLED(CONFIG_GENEVE)
+#include <net/geneve.h>
+#endif
 
 const char i40e_driver_name[] = "i40e";
 static const char i40e_driver_string[] =
@@ -6665,7 +6668,7 @@ static void i40e_handle_mdd_event(struct i40e_pf *pf)
  **/
 static void i40e_sync_udp_filters_subtask(struct i40e_pf *pf)
 {
-#if IS_ENABLED(CONFIG_VXLAN)
+#if IS_ENABLED(CONFIG_VXLAN) || IS_ENABLED(CONFIG_GENEVE)
 	struct i40e_hw *hw = &pf->hw;
 	i40e_status ret;
 	__be16 port;
@@ -7843,7 +7846,8 @@ static int i40e_sw_init(struct i40e_pf *pf)
 			     I40E_FLAG_HW_ATR_EVICT_CAPABLE |
 			     I40E_FLAG_OUTER_UDP_CSUM_CAPABLE |
 			     I40E_FLAG_WB_ON_ITR_CAPABLE |
-			     I40E_FLAG_MULTIPLE_TCP_UDP_RSS_PCTYPE;
+			     I40E_FLAG_MULTIPLE_TCP_UDP_RSS_PCTYPE |
+			     I40E_FLAG_GENEVE_OFFLOAD_CAPABLE;
 	}
 	pf->eeprom_version = 0xDEAD;
 	pf->lan_veb = I40E_NO_VEB;
@@ -7972,14 +7976,18 @@ static void i40e_add_tunnel_port(struct net_device *netdev,
 				 sa_family_t sa_family, __be16 port,
 				 u32 type)
 {
-#if IS_ENABLED(CONFIG_VXLAN)
+#if IS_ENABLED(CONFIG_VXLAN) || IS_ENABLED(CONFIG_GENEVE)
 	struct i40e_netdev_priv *np = netdev_priv(netdev);
 	struct i40e_vsi *vsi = np->vsi;
 	struct i40e_pf *pf = vsi->back;
 	u8 next_idx;
 	u8 idx;
 
-	if (type != UDP_TUNNEL_VXLAN)
+	if (!(type == UDP_TUNNEL_VXLAN || type == UDP_TUNNEL_GENEVE))
+		return;
+
+	if ((type == UDP_TUNNEL_GENEVE) &&
+	    (!(pf->flags & I40E_FLAG_GENEVE_OFFLOAD_CAPABLE)))
 		return;
 
 	if (sa_family == AF_INET6)
@@ -8007,6 +8015,8 @@ static void i40e_add_tunnel_port(struct net_device *netdev,
 	pf->udp_ports[next_idx].index = port;
 	if (type == UDP_TUNNEL_VXLAN)
 		pf->udp_ports[next_idx].type = I40E_AQC_TUNNEL_TYPE_VXLAN;
+	else if (type == UDP_TUNNEL_GENEVE)
+		pf->udp_ports[next_idx].type = I40E_AQC_TUNNEL_TYPE_NGE;
 
 	pf->pending_udp_bitmap |= BIT_ULL(next_idx);
 	pf->flags |= I40E_FLAG_UDP_FILTER_SYNC;
@@ -8024,7 +8034,7 @@ static void i40e_del_tunnel_port(struct net_device *netdev,
 				 sa_family_t sa_family, __be16 port,
 				 u32 type)
 {
-#if IS_ENABLED(CONFIG_VXLAN)
+#if IS_ENABLED(CONFIG_VXLAN) || IS_ENABLED(CONFIG_GENEVE)
 	struct i40e_netdev_priv *np = netdev_priv(netdev);
 	struct i40e_vsi *vsi = np->vsi;
 	struct i40e_pf *pf = vsi->back;
@@ -8228,7 +8238,7 @@ static int i40e_ndo_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
 				       nlflags, 0, 0, filter_mask, NULL);
 }
 
-#define I40E_MAX_TUNNEL_HDR_LEN 80
+#define I40E_MAX_TUNNEL_HDR_LEN 260
 /**
  * i40e_features_check - Validate encapsulated packet conforms to limits
  * @skb: skb buff
drivers/net/ethernet/intel/i40e/i40e_txrx.c +1 -1
index 424c5cc..b93c2dc 100644
@@ -1425,7 +1425,7 @@ static inline void i40e_rx_checksum(struct i40e_vsi *vsi,
 	if (rx_error & BIT(I40E_RX_DESC_ERROR_PPRS_SHIFT))
 		return;
 
-	/* If VXLAN traffic has an outer UDPv4 checksum we need to check
+	/* If VXLAN/GENEVE traffic has an outer UDPv4 checksum we need to check
 	 * it in the driver, hardware does not do it for us.
 	 * Since L3L4P bit was set we assume a valid IHL value (>=5)
 	 * so the total length of IPv4 header is IHL*4 bytes
Signature · 1 line
1.8.1.4
#2 lore raw

PATCH v2 2/5 vxlan: Generalize udp based tunnel offload

In reply to Anjali Singhai Jain
Quoted 6 lines · Anjali Singhai Jain

Replace add/del ndo ops for vxlan_port with tunnel_port so that all UDP based tunnels can use the same ndo op. Add a parameter to pass tunnel type to the ndo_op.

You should squash the patch that comes after this into this one - otherwise the kernel won't compile after this patch.

Did you mean to also add calls from the Geneve code to this? I think you had it in the previous version.

I believe we also need a generalization of vxlan_get_rx_port(). Otherwise, there's no way for drivers to get the non-VXLAN tunnels that were created when they weren't up.

include/linux/netdevice.h typedef u16 (*select_queue_fallback_t)(struct net_device *dev, · line 1011

Quoted 10 lines
include/linux/netdevice.h +6 -0
index c69072b..b6f6beb 100644
+ * void (*ndo_add_tunnel_port)(struct  net_device *dev,
+ *                           sa_family_t sa_family, __be16 port, u32 type);
+ *     Called by UDP based tunnel modules to notify a driver about a UDP
+ *     port and socket address family that the tunnel is listening to. It is
+ *     called only when a new port starts listening. The operation is
+ *     protected by tunnel socket sock_lock.

This locking doesn't look safe to me. Each type of tunnel will have its own socket lock but the data structures that are used in drivers implementing these functions may be shared (such as in your i40e patch). I believe that RTNL is currently held by both VXLAN and Geneve when calling this with the possible exception of vxlan_get_rx_port(). In practice, my guess is that it is likely held then too, so it might only require checking this and documenting/asserting it.

I might just call this ndo_add_udp_tunnel_port since that's what it does anyways.

Quoted 4 lines
include/net/udp_tunnel.h +0 -0
index c491c12..328f3ab 100644

[...]

include/net/udp_tunnel.h line 16

Quoted 5 lines
include/net/udp_tunnel.h +5 -0
+enum udp_tunnel_type {
+       UDP_TUNNEL_NONE,
+       UDP_TUNNEL_VXLAN,
+       UDP_TUNNEL_GENEVE,
+};

What does UDP_TUNNEL_NONE mean?

#8 lore raw

PATCH v2 5/5 i40e: Add geneve tunnel offload support

In reply to Anjali Singhai Jain
Quoted 4 lines · Anjali Singhai Jain
drivers/net/ethernet/intel/i40e/i40e_main.c +0 -0
index b3a6cdf..9bbafc3 100644

[...]

drivers/net/ethernet/intel/i40e/i40e_main.c static int i40e_ndo_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq, · line 8241

Quoted 2 lines
drivers/net/ethernet/intel/i40e/i40e_main.c +1 -1
-#define I40E_MAX_TUNNEL_HDR_LEN 80
+#define I40E_MAX_TUNNEL_HDR_LEN 260

Are you sure that this value is correct for all hardware using this driver? My understanding is that Fortville doesn't support more than 64 bytes of Geneve options (with 8 bytes of UDP header and 8 bytes of Geneve base header making the total tunnel header 80 bytes).

#3 lore raw

PATCH v2 2/5 vxlan: Generalize udp based tunnel offload

In reply to Jesse Gross
Quoted 16 lines

-----Original Message-----
From: Jesse Gross [mailto:jesse at nicira.com]
Sent: Wednesday, September 09, 2015 2:30 PM
To: Singhai, Anjali
Cc: intel-wired-lan
Subject: Re: [Intel-wired-lan] [PATCH v2 2/5] vxlan: Generalize udp based tunnel offload

Quoted 4 lines · Anjali Singhai Jain

Replace add/del ndo ops for vxlan_port with tunnel_port so that all UDP based tunnels can use the same ndo op. Add a parameter to pass tunnel type to the ndo_op.

Quoted 6 lines
Quoted 2 lines

You should squash the patch that comes after this into this one - otherwise the kernel won't compile after this patch.

Ok

Quoted 3 lines

Did you mean to also add calls from the Geneve code to this? I think you had it in the previous version.

Good catch, I will fix it.

Quoted 4 lines

I believe we also need a generalization of vxlan_get_rx_port(). Otherwise, there's no way for drivers to get the non-VXLAN tunnels that were created when they weren't up.

I plan to send this out as a separate patch.

Quoted 11 lines

include/linux/netdevice.h typedef u16 (*select_queue_fallback_t)(struct net_device *dev, · line 1011

Quoted 10 lines
include/linux/netdevice.h +6 -0
index c69072b..b6f6beb 100644
+ * void (*ndo_add_tunnel_port)(struct  net_device *dev,
+ *                           sa_family_t sa_family, __be16 port, u32 type);
+ *     Called by UDP based tunnel modules to notify a driver about a UDP
+ *     port and socket address family that the tunnel is listening to. It is
+ *     called only when a new port starts listening. The operation is
+ *     protected by tunnel socket sock_lock.
Quoted 8 lines

This locking doesn't look safe to me. Each type of tunnel will have its own socket lock but the data structures that are used in drivers implementing these functions may be shared (such as in your i40e patch). I believe that RTNL is currently held by both VXLAN and Geneve when calling this with the possible exception of vxlan_get_rx_port().
In practice, my guess is that it is likely held then too, so it might only require checking this and documenting/asserting it.

ASSERT_RTNL happens in dev.c for both, so do you suggest I just document in the code that we have a common data structure and is being guarded by RTNL acquired by the stack.

Quoted 3 lines

I might just call this ndo_add_udp_tunnel_port since that's what it does anyways.

ok

Quoted 5 lines
Quoted 4 lines
include/net/udp_tunnel.h index renamed from include/net/udp_tunnel.h +0 -0

c491c12..328f3ab 100644

include/net/udp_tunnel.h +0 -0

[...]

Quoted 7 lines

include/net/udp_tunnel.h line 16

Quoted 5 lines
include/net/udp_tunnel.h +5 -0
+enum udp_tunnel_type {
+       UDP_TUNNEL_NONE,
+       UDP_TUNNEL_VXLAN,
+       UDP_TUNNEL_GENEVE,
+};

What does UDP_TUNNEL_NONE mean?

It's a way to avoid 0 based

#4 lore raw

PATCH v2 2/5 vxlan: Generalize udp based tunnel offload

Quoted 8 lines · Anjali
Quoted 8 lines

-----Original Message-----
From: Jesse Gross [mailto:jesse at nicira.com]
Sent: Wednesday, September 09, 2015 2:30 PM
To: Singhai, Anjali
Cc: intel-wired-lan
Subject: Re: [Intel-wired-lan] [PATCH v2 2/5] vxlan: Generalize udp based tunnel offload

Quoted 5 lines
Quoted 4 lines

I believe we also need a generalization of vxlan_get_rx_port(). Otherwise, there's no way for drivers to get the non-VXLAN tunnels that were created when they weren't up.

I plan to send this out as a separate patch.

I would probably suggest doing it as part of this series.

By the way - I do support this series and I'm not trying to add more work to your plate. I'm slightly worried about this being controversial though and so the more complete the patch is, the better off you'll be. Plus, I guess you probably need it in order for the later patches to work correctly in all circumstances.

Quoted 19 lines
Quoted 11 lines

include/linux/netdevice.h typedef u16 (*select_queue_fallback_t)(struct net_device *dev, · line 1011

Quoted 10 lines
include/linux/netdevice.h +6 -0
index c69072b..b6f6beb 100644
+ * void (*ndo_add_tunnel_port)(struct  net_device *dev,
+ *                           sa_family_t sa_family, __be16 port, u32 type);
+ *     Called by UDP based tunnel modules to notify a driver about a UDP
+ *     port and socket address family that the tunnel is listening to. It is
+ *     called only when a new port starts listening. The operation is
+ *     protected by tunnel socket sock_lock.
Quoted 8 lines

This locking doesn't look safe to me. Each type of tunnel will have its own socket lock but the data structures that are used in drivers implementing these functions may be shared (such as in your i40e patch). I believe that RTNL is currently held by both VXLAN and Geneve when calling this with the possible exception of vxlan_get_rx_port().
In practice, my guess is that it is likely held then too, so it might only require checking this and documenting/asserting it.

Quoted 1 line

ASSERT_RTNL happens in dev.c for both, so do you suggest I just document in the code that we have a common data structure and is being guarded by RTNL acquired by the stack.

I think mostly yes. The part that I would be concerned about is that vxlan_get_rx_port() also uses this function and that could be called from different places in drivers. In practice though, I think they are mostly also protected by RTNL. So I would check the callsites and assuming they are OK, also document the requirement for vxlan_get_rx_port() and maybe add an ASSERT_RTNL there.

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
include/net/udp_tunnel.h index renamed from include/net/udp_tunnel.h +0 -0

c491c12..328f3ab 100644

include/net/udp_tunnel.h +0 -0

[...]

Quoted 8 lines
Quoted 7 lines

include/net/udp_tunnel.h line 16

Quoted 5 lines
include/net/udp_tunnel.h +5 -0
+enum udp_tunnel_type {
+       UDP_TUNNEL_NONE,
+       UDP_TUNNEL_VXLAN,
+       UDP_TUNNEL_GENEVE,
+};

What does UDP_TUNNEL_NONE mean?

It's a way to avoid 0 based

Sorry, what's the significance of it being zero? These aren't flags so I'm not sure why zero isn't a valid value.