* [Intel-wired-lan] [PATCH v6 1/6] net: Generalize udp based tunnel offload
2015-11-23 7:03 ` [Intel-wired-lan] [PATCH 0/6] Generalize udp based tunnels and add geneve offload Anjali Singhai Jain
@ 2015-11-23 7:03 ` Anjali Singhai Jain
2015-11-24 21:03 ` Jeff Kirsher
2015-11-23 7:03 ` [Intel-wired-lan] [PATCH v6 2/6] net: Add a generic udp_offload_get_port function Anjali Singhai Jain
` (5 subsequent siblings)
6 siblings, 1 reply; 10+ messages in thread
From: Anjali Singhai Jain @ 2015-11-23 7:03 UTC (permalink / raw)
To: intel-wired-lan
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.
Change all drivers to use the generalized udp tunnel offload
Patch was compile tested with x86_64_defconfig.
Signed-off-by: Kiran Patil <kiran.patil@intel.com>
Signed-off-by: Anjali Singhai Jain <anjali.singhai@intel.com>
---
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 15 ++++++---
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 13 +++++---
drivers/net/ethernet/emulex/benet/be_main.c | 14 +++++---
drivers/net/ethernet/intel/fm10k/fm10k_netdev.c | 27 ++++++++++++----
drivers/net/ethernet/intel/i40e/i40e_main.c | 41 +++++++++++++++++-------
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 17 +++++++---
drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 21 ++++++++----
drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | 17 +++++++---
drivers/net/vxlan.c | 23 +++++++------
include/linux/netdevice.h | 34 ++++++++++----------
include/net/udp_tunnel.h | 6 ++++
11 files changed, 157 insertions(+), 71 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index f1d62d5..3a863dc 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -47,6 +47,7 @@
#include <net/ip.h>
#include <net/ipv6.h>
#include <net/tcp.h>
+#include <net/udp_tunnel.h>
#include <net/vxlan.h>
#include <net/checksum.h>
#include <net/ip6_checksum.h>
@@ -10124,11 +10125,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);
}
@@ -10152,11 +10156,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
@@ -13011,8 +13018,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_udp_tunnel_port = bnx2x_add_vxlan_port,
+ .ndo_del_udp_tunnel_port = bnx2x_del_vxlan_port,
#endif
};
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index db15c5e..94584fa 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -5423,7 +5423,7 @@ static void bnxt_cfg_ntp_filters(struct bnxt *bp)
#endif /* CONFIG_RFS_ACCEL */
static void bnxt_add_vxlan_port(struct net_device *dev, sa_family_t sa_family,
- __be16 port)
+ __be16 port, u32 type)
{
struct bnxt *bp = netdev_priv(dev);
@@ -5433,6 +5433,9 @@ static void bnxt_add_vxlan_port(struct net_device *dev, sa_family_t sa_family,
if (sa_family != AF_INET6 && sa_family != AF_INET)
return;
+ if (type != UDP_TUNNEL_VXLAN)
+ return;
+
if (bp->vxlan_port_cnt && bp->vxlan_port != port)
return;
@@ -5445,7 +5448,7 @@ static void bnxt_add_vxlan_port(struct net_device *dev, sa_family_t sa_family,
}
static void bnxt_del_vxlan_port(struct net_device *dev, sa_family_t sa_family,
- __be16 port)
+ __be16 port, u32 type)
{
struct bnxt *bp = netdev_priv(dev);
@@ -5455,6 +5458,8 @@ static void bnxt_del_vxlan_port(struct net_device *dev, sa_family_t sa_family,
if (sa_family != AF_INET6 && sa_family != AF_INET)
return;
+ if (type != UDP_TUNNEL_VXLAN)
+ return;
if (bp->vxlan_port_cnt && bp->vxlan_port == port) {
bp->vxlan_port_cnt--;
@@ -5493,8 +5498,8 @@ static const struct net_device_ops bnxt_netdev_ops = {
#ifdef CONFIG_RFS_ACCEL
.ndo_rx_flow_steer = bnxt_rx_flow_steer,
#endif
- .ndo_add_vxlan_port = bnxt_add_vxlan_port,
- .ndo_del_vxlan_port = bnxt_del_vxlan_port,
+ .ndo_add_udp_tunnel_port = bnxt_add_vxlan_port,
+ .ndo_del_udp_tunnel_port = bnxt_del_vxlan_port,
#ifdef CONFIG_NET_RX_BUSY_POLL
.ndo_busy_poll = bnxt_busy_poll,
#endif
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index eb48a97..c43f2de 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -23,6 +23,7 @@
#include <linux/aer.h>
#include <linux/if_bridge.h>
#include <net/busy_poll.h>
+#include <net/udp_tunnel.h>
#include <net/vxlan.h>
MODULE_VERSION(DRV_VER);
@@ -5177,12 +5178,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;
@@ -5231,10 +5235,12 @@ 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;
@@ -5344,8 +5350,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_udp_tunnel_port = be_add_vxlan_port,
+ .ndo_del_udp_tunnel_port = be_del_vxlan_port,
.ndo_features_check = be_features_check,
#endif
.ndo_get_phys_port_id = be_get_phys_port_id,
diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c b/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c
index 722ac52..bf7af95 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c
@@ -21,6 +21,7 @@
#include "fm10k.h"
#include <linux/vmalloc.h>
#if IS_ENABLED(CONFIG_FM10K_VXLAN)
+#include <net/udp_tunnel.h>
#include <net/vxlan.h>
#endif /* CONFIG_FM10K_VXLAN */
@@ -439,18 +440,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 +483,7 @@ insert_tail:
list_add_tail(&vxlan_port->list, &interface->vxlan_port);
fm10k_restore_vxlan_port(interface);
+#endif
}
/**
@@ -483,17 +491,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 +522,7 @@ static void fm10k_del_vxlan_port(struct net_device *dev,
}
fm10k_restore_vxlan_port(interface);
+#endif
}
/**
@@ -1389,8 +1404,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_udp_tunnel_port = fm10k_add_vxlan_port,
+ .ndo_del_udp_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,
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index 36645828..314139b 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -30,6 +30,7 @@
#ifdef CONFIG_I40E_VXLAN
#include <net/vxlan.h>
#endif
+#include <net/udp_tunnel.h>
const char i40e_driver_name[] = "i40e";
static const char i40e_driver_string[] =
@@ -8454,13 +8455,18 @@ 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
+ *
+ * This function modifies a common data structure for all udp_tunnels
+ * hence it is expected that it is called under a common lock.
**/
-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)
{
struct i40e_netdev_priv *np = netdev_priv(netdev);
struct i40e_vsi *vsi = np->vsi;
@@ -8468,6 +8474,9 @@ static void i40e_add_vxlan_port(struct net_device *netdev,
u8 next_idx;
u8 idx;
+ if (type != UDP_TUNNEL_VXLAN)
+ return;
+
if (sa_family == AF_INET6)
return;
@@ -8496,19 +8505,27 @@ static void i40e_add_vxlan_port(struct net_device *netdev,
}
/**
- * 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
+ *
+ * This function modifies a common data structure for all udp_tunnels
+ * hence it is expected that it is called under common lock.
**/
-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)
{
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;
@@ -8754,8 +8771,8 @@ static const struct net_device_ops i40e_netdev_ops = {
.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,
+ .ndo_add_udp_tunnel_port = i40e_add_tunnel_port,
+ .ndo_del_udp_tunnel_port = i40e_del_tunnel_port,
#endif
.ndo_get_phys_port_id = i40e_get_phys_port_id,
.ndo_fdb_add = i40e_ndo_fdb_add,
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index f5730dd..d7ad9d9 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -50,6 +50,7 @@
#include <linux/if_bridge.h>
#include <linux/prefetch.h>
#include <scsi/fc/fc_fcoe.h>
+#include <net/udp_tunnel.h>
#include <net/vxlan.h>
#ifdef CONFIG_OF
@@ -8312,14 +8313,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;
@@ -8345,13 +8350,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;
@@ -8663,8 +8672,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_udp_tunnel_port = ixgbe_add_vxlan_port,
+ .ndo_del_udp_tunnel_port = ixgbe_del_vxlan_port,
#endif /* CONFIG_IXGBE_VXLAN */
.ndo_features_check = ixgbe_features_check,
};
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
index 886e1bc..bd8f240 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
@@ -39,6 +39,7 @@
#include <linux/hash.h>
#include <net/ip.h>
#include <net/busy_poll.h>
+#include <net/udp_tunnel.h>
#include <net/vxlan.h>
#include <linux/mlx4/driver.h>
@@ -2402,11 +2403,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;
@@ -2425,11 +2430,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;
@@ -2509,8 +2518,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_udp_tunnel_port = mlx4_en_add_vxlan_port,
+ .ndo_del_udp_tunnel_port = mlx4_en_del_vxlan_port,
.ndo_features_check = mlx4_en_features_check,
#endif
.ndo_set_tx_maxrate = mlx4_en_set_tx_maxrate,
@@ -2547,8 +2556,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_udp_tunnel_port = mlx4_en_add_vxlan_port,
+ .ndo_del_udp_tunnel_port = mlx4_en_del_vxlan_port,
.ndo_features_check = mlx4_en_features_check,
#endif
.ndo_set_tx_maxrate = mlx4_en_set_tx_maxrate,
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
index 1205f6f..aa38dbb 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
@@ -17,6 +17,7 @@
#include <linux/log2.h>
#include <linux/pci.h>
#ifdef CONFIG_QLCNIC_VXLAN
+#include <net/udp_tunnel.h>
#include <net/vxlan.h>
#endif
@@ -476,11 +477,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
*/
@@ -498,11 +503,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_count ||
(ahw->vxlan_port != ntohs(port)))
return;
@@ -540,8 +549,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_udp_tunnel_port = qlcnic_add_vxlan_port,
+ .ndo_del_udp_tunnel_port = qlcnic_del_vxlan_port,
.ndo_features_check = qlcnic_features_check,
#endif
#ifdef CONFIG_NET_POLL_CONTROLLER
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 6369a57..5490629 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -628,9 +628,10 @@ 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_udp_tunnel_port)
+ dev->netdev_ops->ndo_add_udp_tunnel_port(dev, sa_family,
+ port,
+ UDP_TUNNEL_VXLAN);
}
rcu_read_unlock();
}
@@ -646,9 +647,10 @@ 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_udp_tunnel_port)
+ dev->netdev_ops->ndo_del_udp_tunnel_port(dev, sa_family,
+ port,
+ UDP_TUNNEL_VXLAN);
}
rcu_read_unlock();
@@ -2422,9 +2424,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_udp_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)
{
@@ -2440,8 +2442,9 @@ 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_udp_tunnel_port(dev, sa_family,
+ port,
+ UDP_TUNNEL_VXLAN);
}
}
spin_unlock(&vn->sock_lock);
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index d208914..90bd26b 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1004,18 +1004,19 @@ 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_udp_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 udp_offload_lock across all udp based tunnels.
+ *
+ * void (*ndo_del_udp_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 udp_offload_lock across all udp based
+ * tunnels.
*
* void* (*ndo_dfwd_add_station)(struct net_device *pdev,
* struct net_device *dev)
@@ -1209,13 +1210,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_udp_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_udp_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,
diff --git a/include/net/udp_tunnel.h b/include/net/udp_tunnel.h
index cb2f89f..72415aa 100644
--- a/include/net/udp_tunnel.h
+++ b/include/net/udp_tunnel.h
@@ -9,6 +9,12 @@
#include <net/addrconf.h>
#endif
+enum udp_tunnel_type {
+ UDP_TUNNEL_UNSPEC,
+ UDP_TUNNEL_VXLAN,
+ UDP_TUNNEL_GENEVE,
+};
+
struct udp_port_cfg {
u8 family;
--
1.8.1.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Intel-wired-lan] [PATCH v6 1/6] net: Generalize udp based tunnel offload
2015-11-23 7:03 ` [Intel-wired-lan] [PATCH v6 1/6] net: Generalize udp based tunnel offload Anjali Singhai Jain
@ 2015-11-24 21:03 ` Jeff Kirsher
2015-11-24 22:31 ` Singhai, Anjali
0 siblings, 1 reply; 10+ messages in thread
From: Jeff Kirsher @ 2015-11-24 21:03 UTC (permalink / raw)
To: intel-wired-lan
On Sun, 2015-11-22 at 23:03 -0800, Anjali Singhai Jain wrote:
> 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.
>
> Change all drivers to use the generalized udp tunnel offload
>
> Patch was compile tested with x86_64_defconfig.
>
> Signed-off-by: Kiran Patil <kiran.patil@intel.com>
> Signed-off-by: Anjali Singhai Jain <anjali.singhai@intel.com>
> ---
> ?drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 15 ++++++---
> ?drivers/net/ethernet/broadcom/bnxt/bnxt.c??????? | 13 +++++---
> ?drivers/net/ethernet/emulex/benet/be_main.c????? | 14 +++++---
> ?drivers/net/ethernet/intel/fm10k/fm10k_netdev.c? | 27 ++++++++++++
> ----
> ?drivers/net/ethernet/intel/i40e/i40e_main.c????? | 41
> +++++++++++++++++-------
> ?drivers/net/ethernet/intel/ixgbe/ixgbe_main.c??? | 17 +++++++---
> ?drivers/net/ethernet/mellanox/mlx4/en_netdev.c?? | 21 ++++++++----
> ?drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | 17 +++++++---
> ?drivers/net/vxlan.c????????????????????????????? | 23 +++++++------
> ?include/linux/netdevice.h??????????????????????? | 34 ++++++++++--
> --------
> ?include/net/udp_tunnel.h???????????????????????? |? 6 ++++
> ?11 files changed, 157 insertions(+), 71 deletions(-)
This patch breaks the Broadcom drivers, they don't even compile after
this patch.
Dropping this series until the compile issues are resolved.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.osuosl.org/pipermail/intel-wired-lan/attachments/20151124/ec8c99ad/attachment.asc>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Intel-wired-lan] [PATCH v6 1/6] net: Generalize udp based tunnel offload
2015-11-24 21:03 ` Jeff Kirsher
@ 2015-11-24 22:31 ` Singhai, Anjali
0 siblings, 0 replies; 10+ messages in thread
From: Singhai, Anjali @ 2015-11-24 22:31 UTC (permalink / raw)
To: intel-wired-lan
The fix was sent to Netdev but not on intel-wired-lan. It's okay to drop the series though since there are some comments from Alex for which I need to re-spin anyways.
Anjali
> -----Original Message-----
> From: Kirsher, Jeffrey T
> Sent: Tuesday, November 24, 2015 1:04 PM
> To: Singhai, Anjali; intel-wired-lan at lists.osuosl.org
> Subject: Re: [Intel-wired-lan] [PATCH v6 1/6] net: Generalize udp based
> tunnel offload
>
> On Sun, 2015-11-22 at 23:03 -0800, Anjali Singhai Jain wrote:
> > 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.
> >
> > Change all drivers to use the generalized udp tunnel offload
> >
> > Patch was compile tested with x86_64_defconfig.
> >
> > Signed-off-by: Kiran Patil <kiran.patil@intel.com>
> > Signed-off-by: Anjali Singhai Jain <anjali.singhai@intel.com>
> > ---
> > ?drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 15 ++++++---
> > ?drivers/net/ethernet/broadcom/bnxt/bnxt.c??????? | 13 +++++---
> > ?drivers/net/ethernet/emulex/benet/be_main.c????? | 14 +++++---
> > ?drivers/net/ethernet/intel/fm10k/fm10k_netdev.c? | 27 ++++++++++++
> > ----
> > ?drivers/net/ethernet/intel/i40e/i40e_main.c????? | 41
> > +++++++++++++++++-------
> > ?drivers/net/ethernet/intel/ixgbe/ixgbe_main.c??? | 17 +++++++---
> > ?drivers/net/ethernet/mellanox/mlx4/en_netdev.c?? | 21 ++++++++----
> > ?drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | 17 +++++++---
> > ?drivers/net/vxlan.c????????????????????????????? | 23 +++++++------
> > ?include/linux/netdevice.h??????????????????????? | 34 ++++++++++--
> > --------
> > ?include/net/udp_tunnel.h???????????????????????? |? 6 ++++
> > ?11 files changed, 157 insertions(+), 71 deletions(-)
>
> This patch breaks the Broadcom drivers, they don't even compile after this
> patch.
>
> Dropping this series until the compile issues are resolved.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Intel-wired-lan] [PATCH v6 2/6] net: Add a generic udp_offload_get_port function
2015-11-23 7:03 ` [Intel-wired-lan] [PATCH 0/6] Generalize udp based tunnels and add geneve offload Anjali Singhai Jain
2015-11-23 7:03 ` [Intel-wired-lan] [PATCH v6 1/6] net: Generalize udp based tunnel offload Anjali Singhai Jain
@ 2015-11-23 7:03 ` Anjali Singhai Jain
2015-11-23 7:03 ` [Intel-wired-lan] [PATCH v6 3/6] i40e: Generalize the flow for udp based tunnels Anjali Singhai Jain
` (4 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Anjali Singhai Jain @ 2015-11-23 7:03 UTC (permalink / raw)
To: intel-wired-lan
The new function udp_offload_get_port replaces vxlan_get_rx_port().
This is a generic function that will help replay all udp tunnel ports
irrespective of tunnel type.
This way when new udp tunnels get added this function need not change.
Note: Drivers besides i40e are compile tested with this change.
Signed-off-by: Anjali Singhai Jain <anjali.singhai@intel.com>
Signed-off-by: Kiran Patil <kiran.patil@intel.com>
---
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 5 ++--
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 4 +++-
drivers/net/ethernet/emulex/benet/be_main.c | 4 +++-
drivers/net/ethernet/intel/fm10k/fm10k_netdev.c | 3 ++-
drivers/net/ethernet/intel/i40e/i40e_main.c | 5 ++--
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 5 ++--
drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 3 ++-
drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | 3 ++-
drivers/net/vxlan.c | 29 ++----------------------
include/linux/netdevice.h | 2 ++
include/net/protocol.h | 2 ++
include/net/vxlan.h | 8 -------
net/ipv4/udp_offload.c | 27 ++++++++++++++++++++++
13 files changed, 53 insertions(+), 47 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 3a863dc..299dca7 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -60,6 +60,7 @@
#include <linux/semaphore.h>
#include <linux/stringify.h>
#include <linux/vmalloc.h>
+#include <net/protocol.h>
#include "bnx2x.h"
#include "bnx2x_init.h"
@@ -10293,7 +10294,7 @@ sp_rtnl_not_reset:
netdev_info(bp->dev,
"Deleted vxlan dest port %d", port);
bp->vxlan_dst_port = 0;
- vxlan_get_rx_port(bp->dev);
+ udp_offload_get_port(bp->dev);
}
}
#endif
@@ -12499,7 +12500,7 @@ static int bnx2x_open(struct net_device *dev)
#ifdef CONFIG_BNX2X_VXLAN
if (IS_PF(bp))
- vxlan_get_rx_port(dev);
+ udp_offload_get_port(dev);
#endif
return 0;
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 94584fa..3e93c39 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -39,6 +39,7 @@
#include <net/ip6_checksum.h>
#if defined(CONFIG_VXLAN) || defined(CONFIG_VXLAN_MODULE)
#include <net/vxlan.h>
+#include <net/protocol.h>
#endif
#ifdef CONFIG_NET_RX_BUSY_POLL
#include <net/busy_poll.h>
@@ -4591,7 +4592,7 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
if (irq_re_init) {
#if defined(CONFIG_VXLAN) || defined(CONFIG_VXLAN_MODULE)
- vxlan_get_rx_port(bp->dev);
+ udp_offload_get_port(bp->dev);
#endif
if (!bnxt_hwrm_tunnel_dst_port_alloc(
bp, htons(0x17c1),
@@ -5460,6 +5461,7 @@ static void bnxt_del_vxlan_port(struct net_device *dev, sa_family_t sa_family,
if (type != UDP_TUNNEL_VXLAN)
return;
+
if (bp->vxlan_port_cnt && bp->vxlan_port == port) {
bp->vxlan_port_cnt--;
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index c43f2de..5d579eb 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -25,6 +25,7 @@
#include <net/busy_poll.h>
#include <net/udp_tunnel.h>
#include <net/vxlan.h>
+#include <net/protocol.h>
MODULE_VERSION(DRV_VER);
MODULE_DESCRIPTION(DRV_DESC " " DRV_VER);
@@ -3606,7 +3607,7 @@ static int be_open(struct net_device *netdev)
#ifdef CONFIG_BE2NET_VXLAN
if (skyhawk_chip(adapter))
- vxlan_get_rx_port(netdev);
+ udp_offload_get_port(netdev);
#endif
return 0;
@@ -5241,6 +5242,7 @@ static void be_del_vxlan_port(struct net_device *netdev, sa_family_t sa_family,
if (type != UDP_TUNNEL_VXLAN)
return;
+
if (lancer_chip(adapter) || BEx_chip(adapter) || be_is_mc(adapter))
return;
diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c b/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c
index bf7af95..cefa5ab 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c
@@ -23,6 +23,7 @@
#if IS_ENABLED(CONFIG_FM10K_VXLAN)
#include <net/udp_tunnel.h>
#include <net/vxlan.h>
+#include <net/protocol.h>
#endif /* CONFIG_FM10K_VXLAN */
/**
@@ -573,7 +574,7 @@ int fm10k_open(struct net_device *netdev)
#if IS_ENABLED(CONFIG_FM10K_VXLAN)
/* update VXLAN port configuration */
- vxlan_get_rx_port(netdev);
+ udp_offload_get_port(netdev);
#endif
fm10k_up(interface);
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index 314139b..04d8745 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -31,6 +31,7 @@
#include <net/vxlan.h>
#endif
#include <net/udp_tunnel.h>
+#include <net/protocol.h>
const char i40e_driver_name[] = "i40e";
static const char i40e_driver_string[] =
@@ -5295,9 +5296,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
- vxlan_get_rx_port(netdev);
-#endif
+ udp_offload_get_port(netdev);
return 0;
}
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index d7ad9d9..137a637 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -52,6 +52,7 @@
#include <scsi/fc/fc_fcoe.h>
#include <net/udp_tunnel.h>
#include <net/vxlan.h>
+#include <net/protocol.h>
#ifdef CONFIG_OF
#include <linux/of_net.h>
@@ -6039,7 +6040,7 @@ static int ixgbe_open(struct net_device *netdev)
ixgbe_clear_vxlan_port(adapter);
#ifdef CONFIG_IXGBE_VXLAN
- vxlan_get_rx_port(netdev);
+ udp_offload_get_port(netdev);
#endif
return 0;
@@ -7118,7 +7119,7 @@ static void ixgbe_service_task(struct work_struct *work)
#ifdef CONFIG_IXGBE_VXLAN
if (adapter->flags2 & IXGBE_FLAG2_VXLAN_REREG_NEEDED) {
adapter->flags2 &= ~IXGBE_FLAG2_VXLAN_REREG_NEEDED;
- vxlan_get_rx_port(adapter->netdev);
+ udp_offload_get_port(adapter->netdev);
}
#endif /* CONFIG_IXGBE_VXLAN */
ixgbe_reset_subtask(adapter);
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
index bd8f240..ffc43bb 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
@@ -41,6 +41,7 @@
#include <net/busy_poll.h>
#include <net/udp_tunnel.h>
#include <net/vxlan.h>
+#include <net/protocol.h>
#include <linux/mlx4/driver.h>
#include <linux/mlx4/device.h>
@@ -1714,7 +1715,7 @@ int mlx4_en_start_port(struct net_device *dev)
#ifdef CONFIG_MLX4_EN_VXLAN
if (priv->mdev->dev->caps.tunnel_offload_mode == MLX4_TUNNEL_OFFLOAD_MODE_VXLAN)
- vxlan_get_rx_port(dev);
+ udp_offload_get_port(dev);
#endif
priv->port_up = true;
netif_tx_start_all_queues(dev);
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
index aa38dbb..a640872 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
@@ -19,6 +19,7 @@
#ifdef CONFIG_QLCNIC_VXLAN
#include <net/udp_tunnel.h>
#include <net/vxlan.h>
+#include <net/protocol.h>
#endif
#include "qlcnic.h"
@@ -2026,7 +2027,7 @@ qlcnic_attach(struct qlcnic_adapter *adapter)
#ifdef CONFIG_QLCNIC_VXLAN
if (qlcnic_encap_rx_offload(adapter))
- vxlan_get_rx_port(netdev);
+ udp_offload_get_port(netdev);
#endif
adapter->is_up = QLCNIC_ADAPTER_UP_MAGIC;
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 5490629..702f9be 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -2424,33 +2424,6 @@ static struct device_type vxlan_type = {
.name = "vxlan",
};
-/* Calls the ndo_add_udp_tunnel_port of the caller in order to
- * supply the listening VXLAN udp ports. Callers are expected
- * to implement the ndo_add_tunnel_port.
- */
-void vxlan_get_rx_port(struct net_device *dev)
-{
- struct vxlan_sock *vs;
- struct net *net = dev_net(dev);
- struct vxlan_net *vn = net_generic(net, vxlan_net_id);
- sa_family_t sa_family;
- __be16 port;
- unsigned int i;
-
- spin_lock(&vn->sock_lock);
- for (i = 0; i < PORT_HASH_SIZE; ++i) {
- 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_udp_tunnel_port(dev, sa_family,
- port,
- UDP_TUNNEL_VXLAN);
- }
- }
- spin_unlock(&vn->sock_lock);
-}
-EXPORT_SYMBOL_GPL(vxlan_get_rx_port);
-
/* Initialize the device structure. */
static void vxlan_setup(struct net_device *dev)
{
@@ -2639,6 +2612,8 @@ static struct vxlan_sock *vxlan_socket_create(struct net *net, bool ipv6,
/* Initialize the vxlan udp offloads structure */
vs->udp_offloads.port = port;
+ vs->udp_offloads.tunnel_type = UDP_TUNNEL_VXLAN;
+ vs->udp_offloads.family = ipv6 ? AF_INET6 : AF_INET;
vs->udp_offloads.callbacks.gro_receive = vxlan_gro_receive;
vs->udp_offloads.callbacks.gro_complete = vxlan_gro_complete;
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 90bd26b..f78f37b 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2055,6 +2055,8 @@ struct udp_offload_callbacks {
struct udp_offload {
__be16 port;
+ u8 tunnel_type;
+ u8 family;
u8 ipproto;
struct udp_offload_callbacks callbacks;
};
diff --git a/include/net/protocol.h b/include/net/protocol.h
index d6fcc1f..738bfc6 100644
--- a/include/net/protocol.h
+++ b/include/net/protocol.h
@@ -110,6 +110,8 @@ void inet_unregister_protosw(struct inet_protosw *p);
int udp_add_offload(struct udp_offload *prot);
void udp_del_offload(struct udp_offload *prot);
+void udp_offload_get_port(struct net_device *dev);
+
#if IS_ENABLED(CONFIG_IPV6)
int inet6_add_protocol(const struct inet6_protocol *prot, unsigned char num);
int inet6_del_protocol(const struct inet6_protocol *prot, unsigned char num);
diff --git a/include/net/vxlan.h b/include/net/vxlan.h
index c1c899c..926455e 100644
--- a/include/net/vxlan.h
+++ b/include/net/vxlan.h
@@ -242,14 +242,6 @@ static inline netdev_features_t vxlan_features_check(struct sk_buff *skb,
/* IPv6 header + UDP + VXLAN + Ethernet header */
#define VXLAN6_HEADROOM (40 + 8 + 8 + 14)
-#if IS_ENABLED(CONFIG_VXLAN)
-void vxlan_get_rx_port(struct net_device *netdev);
-#else
-static inline void vxlan_get_rx_port(struct net_device *netdev)
-{
-}
-#endif
-
static inline unsigned short vxlan_get_sk_family(struct vxlan_sock *vs)
{
return vs->sock->sk->sk_family;
diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
index f938616..8597020 100644
--- a/net/ipv4/udp_offload.c
+++ b/net/ipv4/udp_offload.c
@@ -290,6 +290,33 @@ unlock:
}
EXPORT_SYMBOL(udp_del_offload);
+void udp_offload_get_port(struct net_device *dev)
+{
+ struct udp_offload_priv __rcu **head;
+ struct udp_offload_priv *uo_priv;
+ struct udp_offload *uo;
+
+ if (udp_offload_base)
+ head = &udp_offload_base;
+ else
+ return;
+
+ spin_lock(&udp_offload_lock);
+ uo_priv = udp_deref_protected(*head);
+ for (; uo_priv != NULL; uo_priv = udp_deref_protected(*head)) {
+ /* call the right add port */
+ uo = uo_priv->offload;
+ if (uo && dev->netdev_ops->ndo_add_udp_tunnel_port)
+ dev->netdev_ops->ndo_add_udp_tunnel_port(dev,
+ uo->family,
+ uo->port,
+ uo->tunnel_type);
+ head = &uo_priv->next;
+ }
+ spin_unlock(&udp_offload_lock);
+}
+EXPORT_SYMBOL(udp_offload_get_port);
+
struct sk_buff **udp_gro_receive(struct sk_buff **head, struct sk_buff *skb,
struct udphdr *uh)
{
--
1.8.1.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Intel-wired-lan] [PATCH v6 3/6] i40e: Generalize the flow for udp based tunnels
2015-11-23 7:03 ` [Intel-wired-lan] [PATCH 0/6] Generalize udp based tunnels and add geneve offload Anjali Singhai Jain
2015-11-23 7:03 ` [Intel-wired-lan] [PATCH v6 1/6] net: Generalize udp based tunnel offload Anjali Singhai Jain
2015-11-23 7:03 ` [Intel-wired-lan] [PATCH v6 2/6] net: Add a generic udp_offload_get_port function Anjali Singhai Jain
@ 2015-11-23 7:03 ` Anjali Singhai Jain
2015-11-23 7:03 ` [Intel-wired-lan] [PATCH v6 4/6] i40e: Remove CONFIG_I40E_VXLAN Anjali Singhai Jain
` (3 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Anjali Singhai Jain @ 2015-11-23 7:03 UTC (permalink / raw)
To: intel-wired-lan
This patch generalizes the driver flow to make room for more than just
VXLAN tunnel by defining a common data structure with tunnel type.
Signed-off-by: Kiran Patil <kiran.patil@intel.com>
Signed-off-by: Anjali Singhai Jain <anjali.singhai@intel.com>
---
drivers/net/ethernet/intel/i40e/i40e.h | 15 ++++----
drivers/net/ethernet/intel/i40e/i40e_main.c | 59 +++++++++++++++--------------
drivers/net/ethernet/intel/i40e/i40e_txrx.c | 6 +--
drivers/net/ethernet/intel/i40e/i40e_txrx.h | 2 +-
4 files changed, 42 insertions(+), 40 deletions(-)
diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h
index 4ca85d5..c24008f 100644
--- a/drivers/net/ethernet/intel/i40e/i40e.h
+++ b/drivers/net/ethernet/intel/i40e/i40e.h
@@ -246,6 +246,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;
@@ -282,11 +287,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;
+ struct i40e_udp_port_config udp_ports[I40E_MAX_PF_UDP_OFFLOAD_PORTS];
+ u16 pending_udp_bitmap;
-#endif
enum i40e_interrupt_policy int_policy;
u16 rx_itr_default;
u16 tx_itr_default;
@@ -323,9 +326,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_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)
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index 04d8745..9ffbe27 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -6990,30 +6990,30 @@ 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
+ * i40e_sync_udp_filters_subtask - Sync the VSI filter list with HW
* @pf: board private structure
**/
-static void i40e_sync_vxlan_filters_subtask(struct i40e_pf *pf)
+static void i40e_sync_udp_filters_subtask(struct i40e_pf *pf)
{
+#ifdef CONFIG_I40E_VXLAN
struct i40e_hw *hw = &pf->hw;
i40e_status ret;
__be16 port;
int i;
- if (!(pf->flags & I40E_FLAG_VXLAN_FILTER_SYNC))
+ if (!(pf->flags & I40E_FLAG_UDP_FILTER_SYNC))
return;
- pf->flags &= ~I40E_FLAG_VXLAN_FILTER_SYNC;
+ pf->flags &= ~I40E_FLAG_UDP_FILTER_SYNC;
for (i = 0; i < I40E_MAX_PF_UDP_OFFLOAD_PORTS; i++) {
- if (pf->pending_vxlan_bitmap & BIT_ULL(i)) {
- pf->pending_vxlan_bitmap &= ~BIT_ULL(i);
- port = pf->vxlan_ports[i];
+ if (pf->pending_udp_bitmap & BIT_ULL(i)) {
+ pf->pending_udp_bitmap &= ~BIT_ULL(i);
+ port = pf->udp_ports[i].index;
if (port)
ret = i40e_aq_add_udp_tunnel(hw, ntohs(port),
- I40E_AQC_TUNNEL_TYPE_VXLAN,
+ pf->udp_ports[i].type,
NULL, NULL);
else
ret = i40e_aq_del_udp_tunnel(hw, i, NULL);
@@ -7026,13 +7026,13 @@ static void i40e_sync_vxlan_filters_subtask(struct i40e_pf *pf)
i40e_stat_str(&pf->hw, ret),
i40e_aq_str(&pf->hw,
pf->hw.aq.asq_last_status));
- pf->vxlan_ports[i] = 0;
+ pf->udp_ports[i].index = 0;
}
}
}
+#endif
}
-#endif
/**
* i40e_service_task - Run the driver's async subtasks
* @work: pointer to work_struct containing our data
@@ -7057,9 +7057,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_sync_udp_filters_subtask(pf);
i40e_clean_adminq_subtask(pf);
i40e_service_event_complete(pf);
@@ -8435,18 +8433,18 @@ static int i40e_set_features(struct net_device *netdev,
#ifdef CONFIG_I40E_VXLAN
/**
- * i40e_get_vxlan_port_idx - Lookup a possibly offloaded for Rx UDP port
+ * i40e_get_udp_port_idx - Lookup a possibly offloaded for Rx UDP port
* @pf: board private structure
* @port: The UDP port to look up
*
* Returns the index number or I40E_MAX_PF_UDP_OFFLOAD_PORTS if port not found
**/
-static u8 i40e_get_vxlan_port_idx(struct i40e_pf *pf, __be16 port)
+static u8 i40e_get_udp_port_idx(struct i40e_pf *pf, __be16 port)
{
u8 i;
for (i = 0; i < I40E_MAX_PF_UDP_OFFLOAD_PORTS; i++) {
- if (pf->vxlan_ports[i] == port)
+ if (pf->udp_ports[i].index == port)
return i;
}
@@ -8479,28 +8477,31 @@ static void i40e_add_tunnel_port(struct net_device *netdev,
if (sa_family == AF_INET6)
return;
- idx = i40e_get_vxlan_port_idx(pf, port);
+ idx = i40e_get_udp_port_idx(pf, port);
/* Check if port already exists */
if (idx < I40E_MAX_PF_UDP_OFFLOAD_PORTS) {
- netdev_info(netdev, "vxlan port %d already offloaded\n",
+ netdev_info(netdev, "UDP port %d already offloaded\n",
ntohs(port));
return;
}
/* Now check if there is space to add the new port */
- next_idx = i40e_get_vxlan_port_idx(pf, 0);
+ next_idx = i40e_get_udp_port_idx(pf, 0);
if (next_idx == I40E_MAX_PF_UDP_OFFLOAD_PORTS) {
- netdev_info(netdev, "maximum number of vxlan UDP ports reached, not adding port %d\n",
+ netdev_info(netdev, "maximum number of UDP ports reached, not adding port %d\n",
ntohs(port));
return;
}
/* New port: add it and mark its index in the bitmap */
- pf->vxlan_ports[next_idx] = port;
- pf->pending_vxlan_bitmap |= BIT_ULL(next_idx);
- pf->flags |= I40E_FLAG_VXLAN_FILTER_SYNC;
+ pf->udp_ports[next_idx].index = port;
+ if (type == UDP_TUNNEL_VXLAN)
+ pf->udp_ports[next_idx].type = I40E_AQC_TUNNEL_TYPE_VXLAN;
+
+ pf->pending_udp_bitmap |= BIT_ULL(next_idx);
+ pf->flags |= I40E_FLAG_UDP_FILTER_SYNC;
}
/**
@@ -8528,18 +8529,18 @@ static void i40e_del_tunnel_port(struct net_device *netdev,
if (sa_family == AF_INET6)
return;
- idx = i40e_get_vxlan_port_idx(pf, port);
+ idx = i40e_get_udp_port_idx(pf, port);
/* Check if port already exists */
if (idx < I40E_MAX_PF_UDP_OFFLOAD_PORTS) {
/* if port exists, set it to 0 (mark for deletion)
* and make it pending
*/
- pf->vxlan_ports[idx] = 0;
- pf->pending_vxlan_bitmap |= BIT_ULL(idx);
- pf->flags |= I40E_FLAG_VXLAN_FILTER_SYNC;
+ pf->udp_ports[idx].index = 0;
+ pf->pending_udp_bitmap |= BIT_ULL(idx);
+ pf->flags |= I40E_FLAG_UDP_FILTER_SYNC;
} else {
- netdev_warn(netdev, "vxlan port %d was not found, not deleting\n",
+ netdev_warn(netdev, "udp tunnel port %d was not found, not deleting\n",
ntohs(port));
}
}
diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
index d67ac85..2729a48 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
@@ -2006,7 +2006,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);
@@ -2091,7 +2091,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) &
@@ -2324,7 +2324,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;
case IPPROTO_GRE:
l4_tunnel = I40E_TXD_CTX_GRE_TUNNELING;
diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.h b/drivers/net/ethernet/intel/i40e/i40e_txrx.h
index dccc1eb..3f081e2 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_txrx.h
+++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.h
@@ -163,7 +163,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
--
1.8.1.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Intel-wired-lan] [PATCH v6 4/6] i40e: Remove CONFIG_I40E_VXLAN
2015-11-23 7:03 ` [Intel-wired-lan] [PATCH 0/6] Generalize udp based tunnels and add geneve offload Anjali Singhai Jain
` (2 preceding siblings ...)
2015-11-23 7:03 ` [Intel-wired-lan] [PATCH v6 3/6] i40e: Generalize the flow for udp based tunnels Anjali Singhai Jain
@ 2015-11-23 7:03 ` Anjali Singhai Jain
2015-11-23 7:03 ` [Intel-wired-lan] [PATCH v6 5/6] net: Refactor udp_offload and add Geneve port offload support Anjali Singhai Jain
` (2 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Anjali Singhai Jain @ 2015-11-23 7:03 UTC (permalink / raw)
To: intel-wired-lan
If the kernel flag CONFIG_VXLAN is true or CONFIG_VXLAN_MODULE is true,
enable VXLAN offload in the driver.
Signed-off-by: Kiran Patil <kiran.patil@intel.com>
Signed-off-by: Anjali Singhai Jain <anjali.singhai@intel.com>
---
drivers/net/ethernet/intel/Kconfig | 11 -----------
drivers/net/ethernet/intel/i40e/i40e_main.c | 14 ++++++++------
2 files changed, 8 insertions(+), 17 deletions(-)
diff --git a/drivers/net/ethernet/intel/Kconfig b/drivers/net/ethernet/intel/Kconfig
index 4163b16..061e4e0 100644
--- a/drivers/net/ethernet/intel/Kconfig
+++ b/drivers/net/ethernet/intel/Kconfig
@@ -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
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index 9ffbe27..21b6285 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -27,7 +27,7 @@
/* Local includes */
#include "i40e.h"
#include "i40e_diag.h"
-#ifdef CONFIG_I40E_VXLAN
+#if IS_ENABLED(CONFIG_VXLAN)
#include <net/vxlan.h>
#endif
#include <net/udp_tunnel.h>
@@ -6996,7 +6996,7 @@ static void i40e_handle_mdd_event(struct i40e_pf *pf)
**/
static void i40e_sync_udp_filters_subtask(struct i40e_pf *pf)
{
-#ifdef CONFIG_I40E_VXLAN
+#if IS_ENABLED(CONFIG_VXLAN)
struct i40e_hw *hw = &pf->hw;
i40e_status ret;
__be16 port;
@@ -8431,7 +8431,7 @@ static int i40e_set_features(struct net_device *netdev,
return 0;
}
-#ifdef CONFIG_I40E_VXLAN
+#if IS_ENABLED(CONFIG_VXLAN)
/**
* i40e_get_udp_port_idx - Lookup a possibly offloaded for Rx UDP port
* @pf: board private structure
@@ -8451,6 +8451,7 @@ static u8 i40e_get_udp_port_idx(struct i40e_pf *pf, __be16 port)
return i;
}
+#endif
/**
* i40e_add_tunnel_port - Get notifications about UDP tunnel ports that come up
* @netdev: This physical port's netdev
@@ -8465,6 +8466,7 @@ 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;
@@ -8502,6 +8504,7 @@ static void i40e_add_tunnel_port(struct net_device *netdev,
pf->pending_udp_bitmap |= BIT_ULL(next_idx);
pf->flags |= I40E_FLAG_UDP_FILTER_SYNC;
+#endif
}
/**
@@ -8518,6 +8521,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)
struct i40e_netdev_priv *np = netdev_priv(netdev);
struct i40e_vsi *vsi = np->vsi;
struct i40e_pf *pf = vsi->back;
@@ -8543,9 +8547,9 @@ static void i40e_del_tunnel_port(struct net_device *netdev,
netdev_warn(netdev, "udp tunnel port %d was not found, not deleting\n",
ntohs(port));
}
+#endif
}
-#endif
static int i40e_get_phys_port_id(struct net_device *netdev,
struct netdev_phys_item_id *ppid)
{
@@ -8770,10 +8774,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_udp_tunnel_port = i40e_add_tunnel_port,
.ndo_del_udp_tunnel_port = i40e_del_tunnel_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,
--
1.8.1.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Intel-wired-lan] [PATCH v6 5/6] net: Refactor udp_offload and add Geneve port offload support
2015-11-23 7:03 ` [Intel-wired-lan] [PATCH 0/6] Generalize udp based tunnels and add geneve offload Anjali Singhai Jain
` (3 preceding siblings ...)
2015-11-23 7:03 ` [Intel-wired-lan] [PATCH v6 4/6] i40e: Remove CONFIG_I40E_VXLAN Anjali Singhai Jain
@ 2015-11-23 7:03 ` Anjali Singhai Jain
2015-11-23 7:03 ` [Intel-wired-lan] [PATCH v6 6/6] i40e:Add geneve tunnel " Anjali Singhai Jain
2015-11-23 18:11 ` [Intel-wired-lan] [PATCH 0/6] Generalize udp based tunnels and add geneve offload Jesse Gross
6 siblings, 0 replies; 10+ messages in thread
From: Anjali Singhai Jain @ 2015-11-23 7:03 UTC (permalink / raw)
To: intel-wired-lan
This patch moves the calls to ndo_add/del ops for vxlan tunnel
into udp_add/del_offload call. This way the ndo_add/del ops get called
for not only vxlan tunnels but for any udp based tunnel.
Signed-off-by: Kiran Patil <kiran.patil@intel.com>
Signed-off-by: Anjali Singhai Jain <anjali.singhai@intel.com>
---
drivers/net/geneve.c | 18 +++++++--------
drivers/net/vxlan.c | 35 ++++------------------------
include/net/protocol.h | 4 ++--
net/ipv4/fou.c | 15 ++++++------
net/ipv4/udp_offload.c | 63 +++++++++++++++++++++++++++++++++-----------------
5 files changed, 64 insertions(+), 71 deletions(-)
diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
index de5c30c..9dc513a 100644
--- a/drivers/net/geneve.c
+++ b/drivers/net/geneve.c
@@ -372,15 +372,12 @@ static struct socket *geneve_create_sock(struct net *net, bool ipv6,
static void geneve_notify_add_rx_port(struct geneve_sock *gs)
{
struct sock *sk = gs->sock->sk;
- sa_family_t sa_family = sk->sk_family;
+ struct net *net = sock_net(sk);
int err;
- if (sa_family == AF_INET) {
- err = udp_add_offload(&gs->udp_offloads);
- if (err)
- pr_warn("geneve: udp_add_offload failed with status %d\n",
- err);
- }
+ err = udp_add_offload(&gs->udp_offloads, net);
+ if (err)
+ pr_warn("geneve: udp_add_offload failed with status %d\n", err);
}
static int geneve_hlen(struct genevehdr *gh)
@@ -505,6 +502,8 @@ static struct geneve_sock *geneve_socket_create(struct net *net, __be16 port,
/* Initialize the geneve udp offloads structure */
gs->udp_offloads.port = port;
+ gs->udp_offloads.tunnel_type = UDP_TUNNEL_GENEVE;
+ gs->udp_offloads.family = ipv6 ? AF_INET6 : AF_INET;
gs->udp_offloads.callbacks.gro_receive = geneve_gro_receive;
gs->udp_offloads.callbacks.gro_complete = geneve_gro_complete;
geneve_notify_add_rx_port(gs);
@@ -522,10 +521,9 @@ static struct geneve_sock *geneve_socket_create(struct net *net, __be16 port,
static void geneve_notify_del_rx_port(struct geneve_sock *gs)
{
struct sock *sk = gs->sock->sk;
- sa_family_t sa_family = sk->sk_family;
+ struct net *net = sock_net(sk);
- if (sa_family == AF_INET)
- udp_del_offload(&gs->udp_offloads);
+ udp_del_offload(&gs->udp_offloads, net);
}
static void __geneve_sock_release(struct geneve_sock *gs)
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 702f9be..231c17e 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -613,49 +613,22 @@ static int vxlan_gro_complete(struct sk_buff *skb, int nhoff,
/* Notify netdevs that UDP port started listening */
static void vxlan_notify_add_rx_port(struct vxlan_sock *vs)
{
- struct net_device *dev;
struct sock *sk = vs->sock->sk;
struct net *net = sock_net(sk);
- sa_family_t sa_family = vxlan_get_sk_family(vs);
- __be16 port = inet_sk(sk)->inet_sport;
int err;
- if (sa_family == AF_INET) {
- err = udp_add_offload(&vs->udp_offloads);
- if (err)
- pr_warn("vxlan: udp_add_offload failed with status %d\n", err);
- }
-
- rcu_read_lock();
- for_each_netdev_rcu(net, dev) {
- if (dev->netdev_ops->ndo_add_udp_tunnel_port)
- dev->netdev_ops->ndo_add_udp_tunnel_port(dev, sa_family,
- port,
- UDP_TUNNEL_VXLAN);
- }
- rcu_read_unlock();
+ err = udp_add_offload(&vs->udp_offloads, net);
+ if (err)
+ pr_warn("vxlan: udp_add_offload failed with status %d\n", err);
}
/* Notify netdevs that UDP port is no more listening */
static void vxlan_notify_del_rx_port(struct vxlan_sock *vs)
{
- struct net_device *dev;
struct sock *sk = vs->sock->sk;
struct net *net = sock_net(sk);
- sa_family_t sa_family = vxlan_get_sk_family(vs);
- __be16 port = inet_sk(sk)->inet_sport;
-
- rcu_read_lock();
- for_each_netdev_rcu(net, dev) {
- if (dev->netdev_ops->ndo_del_udp_tunnel_port)
- dev->netdev_ops->ndo_del_udp_tunnel_port(dev, sa_family,
- port,
- UDP_TUNNEL_VXLAN);
- }
- rcu_read_unlock();
- if (sa_family == AF_INET)
- udp_del_offload(&vs->udp_offloads);
+ udp_del_offload(&vs->udp_offloads, net);
}
/* Add new entry to forwarding table -- assumes lock held */
diff --git a/include/net/protocol.h b/include/net/protocol.h
index 738bfc6..16ee9b5 100644
--- a/include/net/protocol.h
+++ b/include/net/protocol.h
@@ -107,8 +107,8 @@ int inet_del_offload(const struct net_offload *prot, unsigned char num);
void inet_register_protosw(struct inet_protosw *p);
void inet_unregister_protosw(struct inet_protosw *p);
-int udp_add_offload(struct udp_offload *prot);
-void udp_del_offload(struct udp_offload *prot);
+int udp_add_offload(struct udp_offload *prot, struct net *net);
+void udp_del_offload(struct udp_offload *prot, struct net *net);
void udp_offload_get_port(struct net_device *dev);
diff --git a/net/ipv4/fou.c b/net/ipv4/fou.c
index e0fcbbb..4705590 100644
--- a/net/ipv4/fou.c
+++ b/net/ipv4/fou.c
@@ -411,9 +411,9 @@ static void fou_release(struct fou *fou)
{
struct socket *sock = fou->sock;
struct sock *sk = sock->sk;
+ struct net *net = sock_net(sk);
- if (sk->sk_family == AF_INET)
- udp_del_offload(&fou->udp_offloads);
+ udp_del_offload(&fou->udp_offloads, net);
list_del(&fou->list);
udp_tunnel_sock_release(sock);
@@ -484,6 +484,9 @@ static int fou_create(struct net *net, struct fou_cfg *cfg,
goto error;
}
+ fou->udp_offloads.tunnel_type = UDP_TUNNEL_UNSPEC;
+ fou->udp_offloads.family = cfg->udp_config.family;
+
fou->type = cfg->type;
udp_sk(sk)->encap_type = 1;
@@ -496,11 +499,9 @@ static int fou_create(struct net *net, struct fou_cfg *cfg,
sk->sk_allocation = GFP_ATOMIC;
- if (cfg->udp_config.family == AF_INET) {
- err = udp_add_offload(&fou->udp_offloads);
- if (err)
- goto error;
- }
+ err = udp_add_offload(&fou->udp_offloads, net);
+ if (err)
+ goto error;
err = fou_add_to_port_list(net, fou);
if (err)
diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
index 8597020..cf71bd0 100644
--- a/net/ipv4/udp_offload.c
+++ b/net/ipv4/udp_offload.c
@@ -241,18 +241,28 @@ out:
return segs;
}
-int udp_add_offload(struct udp_offload *uo)
+int udp_add_offload(struct udp_offload *uo, struct net *net)
{
- struct udp_offload_priv *new_offload = kzalloc(sizeof(*new_offload), GFP_ATOMIC);
-
- if (!new_offload)
- return -ENOMEM;
-
- new_offload->offload = uo;
+ struct udp_offload_priv *new_offload = NULL;
+ struct net_device *dev;
+
+ if (uo->family == AF_INET) {
+ new_offload = kzalloc(sizeof(*new_offload), GFP_ATOMIC);
+ if (!new_offload)
+ return -ENOMEM;
+ new_offload->offload = uo;
+ }
spin_lock(&udp_offload_lock);
- new_offload->next = udp_offload_base;
- rcu_assign_pointer(udp_offload_base, new_offload);
+ if (new_offload) {
+ new_offload->next = udp_offload_base;
+ rcu_assign_pointer(udp_offload_base, new_offload);
+ }
+ for_each_netdev_rcu(net, dev) {
+ if (dev->netdev_ops->ndo_add_udp_tunnel_port)
+ dev->netdev_ops->ndo_add_udp_tunnel_port(dev,
+ uo->family, uo->port, uo->tunnel_type);
+ }
spin_unlock(&udp_offload_lock);
return 0;
@@ -265,24 +275,35 @@ static void udp_offload_free_routine(struct rcu_head *head)
kfree(ou_priv);
}
-void udp_del_offload(struct udp_offload *uo)
+void udp_del_offload(struct udp_offload *uo, struct net *net)
{
- struct udp_offload_priv __rcu **head = &udp_offload_base;
- struct udp_offload_priv *uo_priv;
+ struct udp_offload_priv __rcu **head;
+ struct udp_offload_priv *uo_priv = NULL;
+ struct net_device *dev;
spin_lock(&udp_offload_lock);
- uo_priv = udp_deref_protected(*head);
- for (; uo_priv != NULL;
- uo_priv = udp_deref_protected(*head)) {
- if (uo_priv->offload == uo) {
- rcu_assign_pointer(*head,
- udp_deref_protected(uo_priv->next));
- goto unlock;
+ for_each_netdev_rcu(net, dev) {
+ if (dev->netdev_ops->ndo_add_udp_tunnel_port)
+ dev->netdev_ops->ndo_del_udp_tunnel_port(dev,
+ uo->family, uo->port, uo->tunnel_type);
+ }
+
+ if (uo->family == AF_INET) {
+ head = &udp_offload_base;
+ uo_priv = udp_deref_protected(*head);
+ for (; uo_priv != NULL;
+ uo_priv = udp_deref_protected(*head)) {
+ if (uo_priv->offload == uo) {
+ rcu_assign_pointer(*head,
+ udp_deref_protected(uo_priv->next));
+ goto unlock;
+ }
+ head = &uo_priv->next;
}
- head = &uo_priv->next;
+ pr_warn("udp_del_offload: didn't find offload for port %d\n",
+ ntohs(uo->port));
}
- pr_warn("udp_del_offload: didn't find offload for port %d\n", ntohs(uo->port));
unlock:
spin_unlock(&udp_offload_lock);
if (uo_priv)
--
1.8.1.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Intel-wired-lan] [PATCH v6 6/6] i40e:Add geneve tunnel offload support
2015-11-23 7:03 ` [Intel-wired-lan] [PATCH 0/6] Generalize udp based tunnels and add geneve offload Anjali Singhai Jain
` (4 preceding siblings ...)
2015-11-23 7:03 ` [Intel-wired-lan] [PATCH v6 5/6] net: Refactor udp_offload and add Geneve port offload support Anjali Singhai Jain
@ 2015-11-23 7:03 ` Anjali Singhai Jain
2015-11-23 18:11 ` [Intel-wired-lan] [PATCH 0/6] Generalize udp based tunnels and add geneve offload Jesse Gross
6 siblings, 0 replies; 10+ messages in thread
From: Anjali Singhai Jain @ 2015-11-23 7:03 UTC (permalink / raw)
To: intel-wired-lan
This patch adds driver hooks to implement ndo_ops to add/del udp
port in the HW to identify GENEVE tunnels.
Also cleans up the features_check path now that we support
multiple udp based tunnels.
Signed-off-by: Anjali Singhai Jain <anjali.singhai@intel.com>
Signed-off-by: Kiran Patil <kiran.patil@intel.com>
---
drivers/net/ethernet/intel/i40e/i40e.h | 1 +
drivers/net/ethernet/intel/i40e/i40e_main.c | 35 +++++++++++++++++++++--------
drivers/net/ethernet/intel/i40e/i40e_txrx.c | 2 +-
3 files changed, 28 insertions(+), 10 deletions(-)
diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h
index c24008f..93f1083 100644
--- a/drivers/net/ethernet/intel/i40e/i40e.h
+++ b/drivers/net/ethernet/intel/i40e/i40e.h
@@ -338,6 +338,7 @@ struct i40e_pf {
#define I40E_FLAG_MULTIPLE_TCP_UDP_RSS_PCTYPE BIT_ULL(38)
#define I40E_FLAG_LINK_POLLING_ENABLED BIT_ULL(39)
#define I40E_FLAG_VEB_MODE_ENABLED BIT_ULL(40)
+#define I40E_FLAG_GENEVE_OFFLOAD_CAPABLE BIT_ULL(41)
#define I40E_FLAG_NO_PCI_LINK_CHECK BIT_ULL(42)
/* tracks features that get auto disabled by errors */
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index 21b6285..f8aff2b 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -30,6 +30,9 @@
#if IS_ENABLED(CONFIG_VXLAN)
#include <net/vxlan.h>
#endif
+#if IS_ENABLED(CONFIG_GENEVE)
+#include <net/geneve.h>
+#endif
#include <net/udp_tunnel.h>
#include <net/protocol.h>
@@ -6996,7 +6999,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;
@@ -8332,7 +8335,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;
@@ -8431,7 +8435,7 @@ static int i40e_set_features(struct net_device *netdev,
return 0;
}
-#if IS_ENABLED(CONFIG_VXLAN)
+#if IS_ENABLED(CONFIG_VXLAN) || IS_ENABLED(CONFIG_GENEVE)
/**
* i40e_get_udp_port_idx - Lookup a possibly offloaded for Rx UDP port
* @pf: board private structure
@@ -8466,14 +8470,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)
@@ -8501,6 +8509,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;
@@ -8521,13 +8531,13 @@ 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;
u8 idx;
- if (type != UDP_TUNNEL_VXLAN)
+ if (!(type == UDP_TUNNEL_VXLAN || type == UDP_TUNNEL_GENEVE))
return;
if (sa_family == AF_INET6)
@@ -8727,7 +8737,10 @@ 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
+/* Hardware supports L4 tunnel length of 128B (=2^7) which includes
+ * inner mac plus all inner ethertypes.
+ */
+#define I40E_MAX_TUNNEL_HDR_LEN 128
/**
* i40e_features_check - Validate encapsulated packet conforms to limits
* @skb: skb buff
@@ -8739,7 +8752,7 @@ static netdev_features_t i40e_features_check(struct sk_buff *skb,
netdev_features_t features)
{
if (skb->encapsulation &&
- (skb_inner_mac_header(skb) - skb_transport_header(skb) >
+ ((skb_inner_network_header(skb) - skb_transport_header(skb)) >
I40E_MAX_TUNNEL_HDR_LEN))
return features & ~(NETIF_F_ALL_CSUM | NETIF_F_GSO_MASK);
@@ -8809,6 +8822,7 @@ static int i40e_config_netdev(struct i40e_vsi *vsi)
np->vsi = vsi;
netdev->hw_enc_features |= NETIF_F_IP_CSUM |
+ NETIF_F_RXCSUM |
NETIF_F_GSO_UDP_TUNNEL |
NETIF_F_GSO_GRE |
NETIF_F_TSO;
@@ -10326,6 +10340,9 @@ static void i40e_print_features(struct i40e_pf *pf)
#if IS_ENABLED(CONFIG_VXLAN)
i += snprintf(&buf[i], REMAIN(i), "VxLAN ");
#endif
+#if IS_ENABLED(CONFIG_GENVE)
+ i += snprintf(&buf[i], REMAIN(i), "Geneve ");
+#endif
if (pf->flags & I40E_FLAG_PTP)
i += snprintf(&buf[i], REMAIN(i), "PTP ");
#ifdef I40E_FCOE
diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
index 2729a48..5dfe15c 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
@@ -1383,7 +1383,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
--
1.8.1.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Intel-wired-lan] [PATCH 0/6] Generalize udp based tunnels and add geneve offload
2015-11-23 7:03 ` [Intel-wired-lan] [PATCH 0/6] Generalize udp based tunnels and add geneve offload Anjali Singhai Jain
` (5 preceding siblings ...)
2015-11-23 7:03 ` [Intel-wired-lan] [PATCH v6 6/6] i40e:Add geneve tunnel " Anjali Singhai Jain
@ 2015-11-23 18:11 ` Jesse Gross
6 siblings, 0 replies; 10+ messages in thread
From: Jesse Gross @ 2015-11-23 18:11 UTC (permalink / raw)
To: intel-wired-lan
On Sun, Nov 22, 2015 at 11:03 PM, Anjali Singhai Jain
<anjali.singhai@intel.com> wrote:
> This patch series generalizes the flow for udp_based tunnels for
> offload hooks. So that much of the frame work can remain common
> for any driver adding support for geneve or any other
> udp_based tunnel in future.
>
> This patch series also makes the driver calls to/from the stack
> independent of the tunnel modules. So it would be easier to remove
> module config parameters from the respective drivers for tunnel
> support. One such example is in i40e driver.
>
> This patch series also adds support for geneve offload in i40e driver.
>
> Much thanks to Jesse Gross for his valuable feedback in getting this
> done the right way.
This series looks nice to me. Thanks a lot for all your work!
^ permalink raw reply [flat|nested] 10+ messages in thread