udp_tunnel: convert Intel drivers with shared tables
Subsystems (6)
Jakub Kicinski
maintainerv2 cover udp_tunnel: convert Intel drivers with shared tables
This set converts Intel drivers which have the ability to spawn multiple netdevs, but have only one UDP tunnel port table.
Appropriate support is added to the core infra in patch 1, followed by netdevsim support and a selftest.
The table sharing works by core attaching the same table structure to all devices sharing the table. This means the reference count has to accommodate potentially large values.
Once core is ready i40e and ice are converted. These are complex drivers, but we got a tested-by from Aaron, so we should be good :)
Compared to v1 I've made sure the selftest is executable.
Other than that patches 8 and 9 are actually from the Mellanox conversion series were kept out to avoid Mellanox vs Intel conflicts.
Last patch is new, some docs to let users knows ethtool can now display UDP tunnel info.
Jakub Kicinski (10):
udp_tunnel: add the ability to share port tables
netdevsim: add warnings on unexpected UDP tunnel port errors
netdevsim: shared UDP tunnel port table support
selftests: net: add a test for shared UDP tunnel info tables
i40e: convert to new udp_tunnel infrastructure
ice: remove unused args from ice_get_open_tunnel_port()
ice: convert to new udp_tunnel infrastructure
netdevsim: support the static IANA VXLAN port flag
selftests: net: add a test for static UDP tunnel ports
docs: vxlan: add info about device features
Documentation/networking/vxlan.rst | 28 ++ drivers/net/ethernet/intel/i40e/i40e.h | 6 +- drivers/net/ethernet/intel/i40e/i40e_main.c | 264 ++++-------------- .../net/ethernet/intel/ice/ice_ethtool_fdir.c | 6 +- drivers/net/ethernet/intel/ice/ice_fdir.c | 2 +- .../net/ethernet/intel/ice/ice_flex_pipe.c | 231 +++++++-------- .../net/ethernet/intel/ice/ice_flex_pipe.h | 11 +- .../net/ethernet/intel/ice/ice_flex_type.h | 5 +- drivers/net/ethernet/intel/ice/ice_main.c | 97 ++----- drivers/net/ethernet/intel/ice/ice_type.h | 3 + drivers/net/netdevsim/netdevsim.h | 8 +- drivers/net/netdevsim/udp_tunnels.c | 34 ++- include/net/udp_tunnel.h | 24 ++ net/ipv4/udp_tunnel_nic.c | 96 ++++++- .../drivers/net/netdevsim/udp_tunnel_nic.sh | 167 +++++++++++ 15 files changed, 531 insertions(+), 451 deletions(-) mode change 100644 => 100755 tools/testing/selftests/drivers/net/netdevsim/udp_tunnel_nic.sh
Signature · 1 line
2.26.2
Jakub Kicinski
maintainerPATCH v2 2/10 netdevsim: add warnings on unexpected UDP tunnel port errors
We should never see a removal of a port which is not in the table or adding a port to an occupied entry in the table. To make sure such errors don't escape the checks in the test script add a warning/kernel spat.
Error injection will not trigger those, nor should it ever put us in a bad state.
--- drivers/net/netdevsim/udp_tunnels.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/net/netdevsim/udp_tunnels.c +9 -4
@@ -22,11 +22,13 @@ nsim_udp_tunnel_set_port(struct net_device *dev, unsigned int table,msleep (ns->udp_ports.sleep);if (!ret) { -if (ns->udp_ports.ports[table][entry]) +if (ns->udp_ports.ports[table][entry]) { +WARN (1 ,"entry already in use\n" ); ret = -EBUSY ; -else + }else { ns->udp_ports.ports[table][entry] =be16_to_cpu (ti->port) <<16 | ti->type; + } } netdev_info(dev, "set [%d, %d] type %d family %d port %d - %d\n",
@@ -50,10 +52,13 @@ nsim_udp_tunnel_unset_port(struct net_device *dev, unsigned int table,if (!ret) {u32 val =be16_to_cpu (ti->port) <<16 | ti->type; -if (val == ns->udp_ports.ports[table][entry]) +if (val == ns->udp_ports.ports[table][entry]) { ns->udp_ports.ports[table][entry] =0 ; -else + }else { +WARN (1 ,"entry not installed %x vs %x\n" , + val, ns->udp_ports.ports[table][entry]); ret = -ENOENT ; + } } netdev_info(dev, "unset [%d, %d] type %d family %d port %d - %d\n",
Signature · 1 line
2.26.2
Jakub Kicinski
maintainerPATCH v2 1/10 udp_tunnel: add the ability to share port tables
In reply to Jakub KicinskiUnfortunately recent Intel NIC designs share the UDP port table across netdevs. So far the UDP tunnel port state was maintained per netdev, we need to extend that to cater to Intel NICs.
Expect NICs to allocate the info structure dynamically and link to the state from there. All the shared NICs will record port offload information in the one instance of the table so we need to make sure that the use count can accommodate larger numbers.
--- include/net/udp_tunnel.h | 24 ++++++++++ net/ipv4/udp_tunnel_nic.c | 96 +++++++++++++++++++++++++++++++++++---- 2 files changed, 110 insertions(+), 10 deletions(-)
include/net/udp_tunnel.h +24 -0
@@ -200,11 +200,27 @@ enum udp_tunnel_nic_info_flags { UDP_TUNNEL_NIC_INFO_STATIC_IANA_VXLAN = BIT(3), }; +struct udp_tunnel_nic ; + +#define UDP_TUNNEL_NIC_MAX_SHARING_DEVICES (U16_MAX / 2) + +struct udp_tunnel_nic_shared { +struct udp_tunnel_nic *udp_tunnel_nic_info; + +struct list_head devices; +}; + +struct udp_tunnel_nic_shared_node { +struct net_device *dev; +struct list_head list; +}; +/** * struct udp_tunnel_nic_info - driver UDP tunnel offload information * @set_port: callback for adding a new port * @unset_port: callback for removing a port * @sync_table: callback for syncing the entire port table at once +* @shared: reference to device global state (optional) * @flags: device flags from enum udp_tunnel_nic_info_flags * @tables: UDP port tables this device has * @tables.n_entries: number of entries in this table
@@ -213,6 +229,12 @@ enum udp_tunnel_nic_info_flags {* Drivers are expected to provide either @set_port and @unset_port callbacks * or the @sync_table callback. Callbacks are invoked with rtnl lock held. * +* Devices which (misguidedly) share the UDP tunnel port table across multiple +* netdevs should allocate an instance of struct udp_tunnel_nic_shared and +* point @shared at it. +* There must never be more than %UDP_TUNNEL_NIC_MAX_SHARING_DEVICES devices +* sharing a table. +* * Known limitations: * - UDP tunnel port notifications are fundamentally best-effort - * it is likely the driver will both see skbs which use a UDP tunnel port,
@@ -234,6 +256,8 @@ struct udp_tunnel_nic_info {/* all at once */ int (*sync_table)(struct net_device *dev,unsigned int table); +struct udp_tunnel_nic_shared *shared; +unsigned int flags;struct udp_tunnel_nic_table_info {
net/ipv4/udp_tunnel_nic.c +86 -10
159 lines not on this page · raw message
Signature · 1 line
2.26.2
Jakub Kicinski
maintainerPATCH v2 4/10 selftests: net: add a test for shared UDP tunnel info tables
In reply to Jakub KicinskiAdd a test run of checks validating the shared UDP tunnel port tables function as we expect.
--- .../drivers/net/netdevsim/udp_tunnel_nic.sh | 109 ++++++++++++++++++ 1 file changed, 109 insertions(+) mode change 100644 => 100755 tools/testing/selftests/drivers/net/netdevsim/udp_tunnel_nic.sh
tools/testing/selftests/drivers/net/netdevsim/udp_tunnel_nic.sh +109 -0
@@ -775,6 +775,115 @@ for port in 0 1; do exp1=( 0 0 0 0 ) done +cleanup_nsim + +# shared port tables +pfx="table sharing" + +echo $NSIM_ID > /sys/bus/netdevsim/new_device +echo 0 > $NSIM_DEV_SYS/del_port + +echo 0 > $NSIM_DEV_DFS/udp_ports_open_only +echo 1 > $NSIM_DEV_DFS/udp_ports_sleep +echo 1 > $NSIM_DEV_DFS/udp_ports_shared + +old_netdevs=$(ls /sys/class/net) +echo 1 > $NSIM_DEV_SYS/new_port +NSIM_NETDEV=`get_netdev_name old_netdevs` +old_netdevs=$(ls /sys/class/net) +echo 2 > $NSIM_DEV_SYS/new_port +NSIM_NETDEV2=`get_netdev_name old_netdevs` + +msg="VxLAN v4 devices" +exp0=( `mke 4789 1` 0 0 0 ) +exp1=( 0 0 0 0 ) +new_vxlan vxlan0 4789 $NSIM_NETDEV +new_vxlan vxlan1 4789 $NSIM_NETDEV2 + +msg="VxLAN v4 devices go down" +exp0=( 0 0 0 0 ) +ifconfig vxlan1 down +ifconfig vxlan0 down +check_tables + +for ifc in vxlan0 vxlan1; do + ifconfig $ifc up +done + +msg="VxLAN v6 device" +exp0=( `mke 4789 1` `mke 4790 1` 0 0 ) +new_vxlan vxlanC 4790 $NSIM_NETDEV 6 + +msg="Geneve device" +exp1=( `mke 6081 2` 0 0 0 ) +new_geneve gnv0 6081 + +msg="NIC device goes down" +ifconfig $NSIM_NETDEV down +check_tables + +msg="NIC device goes up again" +ifconfig $NSIM_NETDEV up +check_tables + +for i in `seq 2`; do + msg="turn feature off - 1, rep $i" + ethtool -K $NSIM_NETDEV rx-udp_tunnel-port-offload off + check_tables + + msg="turn feature off - 2, rep $i" + exp0=( 0 0 0 0 ) + exp1=( 0 0 0 0 ) + ethtool -K $NSIM_NETDEV2 rx-udp_tunnel-port-offload off + check_tables + + msg="turn feature on - 1, rep $i" + exp0=( `mke 4789 1` `mke 4790 1` 0 0 ) + exp1=( `mke 6081 2` 0 0 0 ) + ethtool -K $NSIM_NETDEV rx-udp_tunnel-port-offload on + check_tables + + msg="turn feature on - 2, rep $i" + ethtool -K $NSIM_NETDEV2 rx-udp_tunnel-port-offload on + check_tables +done + +msg="tunnels destroyed 1" +cleanup_tuns +exp0=( 0 0 0 0 ) +exp1=( 0 0 0 0 ) +check_tables + +overflow_table0 "overflow NIC table" + +msg="re-add a port" + +echo 2 > $NSIM_DEV_SYS/del_port +echo 2 > $NSIM_DEV_SYS/new_port +check_tables + +msg="replace VxLAN in overflow table" +exp0=( `mke 10000 1` `mke 10004 1` `mke 10002 1` `mke 10003 1` ) +del_dev vxlan1 + +msg="vacate VxLAN in overflow table" +exp0=( `mke 10000 1` `mke 10004 1` 0 `mke 10003 1` ) +del_dev vxlan2 + +echo 1 > $NSIM_DEV_DFS/ports/$port/udp_ports_reset +check_tables + +msg="tunnels destroyed 2" +cleanup_tuns +exp0=( 0 0 0 0 ) +exp1=( 0 0 0 0 ) +check_tables + +echo 1 > $NSIM_DEV_SYS/del_port +echo 2 > $NSIM_DEV_SYS/del_port + +cleanup_nsim + modprobe -r netdevsim if [ $num_errors -eq 0 ]; then
Signature · 1 line
2.26.2
Jakub Kicinski
maintainerPATCH v2 9/10 selftests: net: add a test for static UDP tunnel ports
In reply to Jakub KicinskiCheck UDP_TUNNEL_NIC_INFO_STATIC_IANA_VXLAN works as expected.
--- .../drivers/net/netdevsim/udp_tunnel_nic.sh | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+)
tools/testing/selftests/drivers/net/netdevsim/udp_tunnel_nic.sh +58 -0
@@ -7,6 +7,7 @@ NSIM_DEV_SYS=/sys/bus/netdevsim/devices/netdevsim$NSIM_ID NSIM_DEV_DFS=/sys/kernel/debug/netdevsim/netdevsim$NSIM_ID NSIM_NETDEV= HAS_ETHTOOL= +STATIC_ENTRIES= EXIT_STATUS=0 num_cases=0 num_errors=0
@@ -193,6 +194,21 @@ function check_tables { sleep 0.02 ((retries--)) done + + if [ -n "$HAS_ETHTOOL" -a -n "${STATIC_ENTRIES[0]}" ]; then + fail=0 + for i in "${!STATIC_ENTRIES[@]}"; do + pp_expected=`pre_ethtool ${STATIC_ENTRIES[i]}` + cnt=$(ethtool --show-tunnels $NSIM_NETDEV | grep -c "$pp_expected") + if [ $cnt -ne 1 ]; then + err_cnt "ethtool static entry: $pfx - $msg" + echo " check_table: ethtool does not contain '$pp_expected'" + ethtool --show-tunnels $NSIM_NETDEV + fail=1 + fi + done + [ $fail == 0 ] && pass_cnt + fi } function print_table {
@@ -884,6 +900,48 @@ echo 2 > $NSIM_DEV_SYS/del_port cleanup_nsim +# Static IANA port +pfx="static IANA vxlan" + +echo $NSIM_ID > /sys/bus/netdevsim/new_device +echo 0 > $NSIM_DEV_SYS/del_port + +echo 1 > $NSIM_DEV_DFS/udp_ports_static_iana_vxlan +STATIC_ENTRIES=( `mke 4789 1` ) + +port=1 +old_netdevs=$(ls /sys/class/net) +echo $port > $NSIM_DEV_SYS/new_port +NSIM_NETDEV=`get_netdev_name old_netdevs` + +msg="check empty" +exp0=( 0 0 0 0 ) +exp1=( 0 0 0 0 ) +check_tables + +msg="add on static port" +new_vxlan vxlan0 4789 $NSIM_NETDEV +new_vxlan vxlan1 4789 $NSIM_NETDEV + +msg="add on different port" +exp0=( `mke 4790 1` 0 0 0 ) +new_vxlan vxlan2 4790 $NSIM_NETDEV + +cleanup_tuns + +msg="tunnels destroyed" +exp0=( 0 0 0 0 ) +exp1=( 0 0 0 0 ) +check_tables + +msg="different type" +new_geneve gnv0 4789 + +cleanup_tuns +cleanup_nsim + +# END + modprobe -r netdevsim if [ $num_errors -eq 0 ]; then
Signature · 1 line
2.26.2
Jakub Kicinski
maintainerPATCH v2 5/10 i40e: convert to new udp_tunnel infrastructure
In reply to Jakub KicinskiMake use of the "shared port table" to convert i40e to the new infra.
i40e did not have any reference tracking, locking is also dodgy because rtnl gets released while talking to FW, so port may get removed from the table while it's getting added etc.
On the good side i40e does not seem to be using the ports for TX so we can remove the table from the driver state completely.
--- drivers/net/ethernet/intel/i40e/i40e.h | 6 +- drivers/net/ethernet/intel/i40e/i40e_main.c | 264 ++++---------------- 2 files changed, 51 insertions(+), 219 deletions(-)
drivers/net/ethernet/intel/i40e/i40e.h +3 -3
@@ -35,6 +35,7 @@#include <net/pkt_cls.h> #include <net/tc_act/tc_gact.h> #include <net/tc_act/tc_mirred.h> +#include <net/udp_tunnel.h> #include <net/xdp_sock.h> #include "i40e_type.h" #include "i40e_prototype.h"
@@ -133,7 +134,6 @@ enum i40e_state_t { __I40E_PORT_SUSPENDED, __I40E_VF_DISABLE, __I40E_MACVLAN_SYNC_PENDING, - __I40E_UDP_FILTER_SYNC_PENDING, __I40E_TEMP_LINK_POLLING, __I40E_CLIENT_SERVICE_REQUESTED, __I40E_CLIENT_L2_CHANGE,
@@ -478,8 +478,8 @@ struct i40e_pf {struct list_head l3_flex_pit_list;struct list_head l4_flex_pit_list; -struct i40e_udp_port_config udp_ports[I40E_MAX_PF_UDP_OFFLOAD_PORTS ]; -u16 pending_udp_bitmap; +struct udp_tunnel_nic_shared udp_tunnel_shared; +struct udp_tunnel_nic_info udp_tunnel_nic;struct hlist_head cloud_filter_list;u16 num_cloud_filters;
drivers/net/ethernet/intel/i40e/i40e_main.c +48 -216
325 lines not on this page · raw message
Signature · 1 line
2.26.2
Jakub Kicinski
maintainerPATCH v2 7/10 ice: convert to new udp_tunnel infrastructure
In reply to Jakub KicinskiConvert ice to the new infra, use share port tables.
Leave a tiny bit more error checking in place than usual, because this driver really does quite a bit of magic.
We need to calculate the number of VxLAN and GENEVE entries the firmware has reserved.
Thanks to the conversion the driver will no longer sleep in an atomic section.
--- .../net/ethernet/intel/ice/ice_flex_pipe.c | 228 ++++++++---------- .../net/ethernet/intel/ice/ice_flex_pipe.h | 8 +- .../net/ethernet/intel/ice/ice_flex_type.h | 5 +- drivers/net/ethernet/intel/ice/ice_main.c | 97 +++----- drivers/net/ethernet/intel/ice/ice_type.h | 3 + 5 files changed, 135 insertions(+), 206 deletions(-)
drivers/net/ethernet/intel/ice/ice_flex_pipe.c +96 -132
@@ -489,8 +489,6 @@ static void ice_init_pkg_hints(struct ice_hw *hw, struct ice_seg *ice_seg)if ((label_name[len] -'0' ) == hw->pf_id) { hw->tnl.tbl[hw->tnl.count].type = tnls[i].type; hw->tnl.tbl[hw->tnl.count].valid = false; - hw->tnl.tbl[hw->tnl.count].in_use = false; - hw->tnl.tbl[hw->tnl.count].marked = false; hw->tnl.tbl[hw->tnl.count].boost_addr = val; hw->tnl.tbl[hw->tnl.count].port =0 ; hw->tnl.count++;
@@ -505,8 +503,11 @@ static void ice_init_pkg_hints(struct ice_hw *hw, struct ice_seg *ice_seg)for (i =0 ; i < hw->tnl.count; i++) {ice_find_boost_entry (ice_seg, hw->tnl.tbl[i].boost_addr, &hw->tnl.tbl[i].boost_entry); -if (hw->tnl.tbl[i].boost_entry) +if (hw->tnl.tbl[i].boost_entry) { hw->tnl.tbl[i].valid = true; +if (hw->tnl.tbl[i].type < __TNL_TYPE_CNT) + hw->tnl.valid_count[hw->tnl.tbl[i].type]++; + } } }
@@ -1626,101 +1627,59 @@ static struct ice_buf *ice_pkg_buf(struct ice_buf_build *bld) }/** -* ice_tunnel_port_in_use_hlpr - helper function to determine tunnel usage +* ice_get_open_tunnel_port - retrieve an open tunnel port * @hw: pointer to the HW structure -* @port: port to search for -* @index: optionally returns index -* -* Returns whether a port is already in use as a tunnel, and optionally its -* index +* @port: returns open port */ -static bool ice_tunnel_port_in_use_hlpr (struct ice_hw *hw,u16 port,u16 *index) +bool +ice_get_open_tunnel_port (struct ice_hw *hw,u16 *port) { +bool res = false;u16 i; +mutex_lock (&hw->tnl_lock); +for (i =0 ; i < hw->tnl.count && i <ICE_TUNNEL_MAX_ENTRIES ; i++) -if (hw->tnl.tbl[i].in_use && hw->tnl.tbl[i].port == port) { -if (index) - *index = i; -return true; +if (hw->tnl.tbl[i].valid && hw->tnl.tbl[i].port) { + *port = hw->tnl.tbl[i].port; + res = true; +break ; } -return false; -} - -/** -* ice_tunnel_port_in_use -* @hw: pointer to the HW structure -* @port: port to search for -* @index: optionally returns index -* -* Returns whether a port is already in use as a tunnel, and optionally its -* index -*/ -bool ice_tunnel_port_in_use (struct ice_hw *hw,u16 port,u16 *index) -{ -bool res; - -mutex_lock (&hw->tnl_lock); - res =ice_tunnel_port_in_use_hlpr (hw, port, index);mutex_unlock (&hw->tnl_lock);return res; }/** -* ice_find_free_tunnel_entry +* ice_tunnel_idx_to_entry - convert linear index to the sparse one * @hw: pointer to the HW structure -* @type: tunnel type -* @index: optionally returns index +* @type: type of tunnel +* @idx: linear index * -* Returns whether there is a free tunnel entry, and optionally its index -*/ -static bool -ice_find_free_tunnel_entry (struct ice_hw *hw,enum ice_tunnel_type type, -u16 *index) -{ -u16 i; - -for (i =0 ; i < hw->tnl.count && i <ICE_TUNNEL_MAX_ENTRIES ; i++) -if (hw->tnl.tbl[i].valid && !hw->tnl.tbl[i].in_use && - hw->tnl.tbl[i].type == type) { -if (index) - *index = i; -return true; - } - -return false; -} - -/** -* ice_get_open_tunnel_port - retrieve an open tunnel port -* @hw: pointer to the HW structure -* @port: returns open port +* Stack assumes we have 2 linear tables with indexes [0, count_valid), +* but really the port table may be sprase, and types are mixed, so convert +* the stack index into the device index. */ -bool -ice_get_open_tunnel_port (struct ice_hw *hw,u16 *port) +static u16 ice_tunnel_idx_to_entry (struct ice_hw *hw,enum ice_tunnel_type type, +u16 idx) { -bool res = false;u16 i; -mutex_lock (&hw->tnl_lock); -for (i =0 ; i < hw->tnl.count && i <ICE_TUNNEL_MAX_ENTRIES ; i++) -if (hw->tnl.tbl[i].valid && hw->tnl.tbl[i].in_use) { - *port = hw->tnl.tbl[i].port; - res = true; -break ; - } - -mutex_unlock (&hw->tnl_lock); +if (hw->tnl.tbl[i].valid && + hw->tnl.tbl[i].type == type && + idx--) +return i; -return res; +WARN_ON_ONCE (1 ); +return 0 ; }/** * ice_create_tunnel * @hw: pointer to the HW structure +* @index: device table entry * @type: type of tunnel * @port: port of tunnel to create *
@@ -1728,27 +1687,16 @@ ice_get_open_tunnel_port(struct ice_hw *hw, u16 *port)* creating a package buffer with the tunnel info and issuing an update package * command. */ -enum ice_status -ice_create_tunnel (struct ice_hw *hw,enum ice_tunnel_type type,u16 port) +static enum ice_status +ice_create_tunnel (struct ice_hw *hw,u16 index, +enum ice_tunnel_type type,u16 port) {struct ice_boost_tcam_section *sect_rx, *sect_tx;enum ice_status status =ICE_ERR_MAX_LIMIT ;struct ice_buf_build *bld; -u16 index;mutex_lock (&hw->tnl_lock); -if (ice_tunnel_port_in_use_hlpr (hw, port, &index)) { - hw->tnl.tbl[index].ref++; - status =0 ; - goto ice_create_tunnel_end; - } - -if (!ice_find_free_tunnel_entry (hw, type, &index)) { - status =ICE_ERR_OUT_OF_RANGE ; - goto ice_create_tunnel_end; - } - bld =ice_pkg_buf_alloc (hw);if (!bld) { status =ICE_ERR_NO_MEMORY ;
@@ -1787,11 +1735,8 @@ ice_create_tunnel(struct ice_hw *hw, enum ice_tunnel_type type, u16 port)memcpy (sect_tx->tcam, sect_rx->tcam,sizeof (*sect_tx->tcam)); status =ice_update_pkg (hw,ice_pkg_buf (bld),1 ); -if (!status) { +if (!status) hw->tnl.tbl[index].port = port; - hw->tnl.tbl[index].in_use = true; - hw->tnl.tbl[index].ref =1 ; - } ice_create_tunnel_err:ice_pkg_buf_free (hw, bld);
@@ -1805,46 +1750,31 @@ ice_create_tunnel(struct ice_hw *hw, enum ice_tunnel_type type, u16 port)/** * ice_destroy_tunnel * @hw: pointer to the HW structure +* @index: device table entry +* @type: type of tunnel * @port: port of tunnel to destroy (ignored if the all parameter is true) -* @all: flag that states to destroy all tunnels * * Destroys a tunnel or all tunnels by creating an update package buffer * targeting the specific updates requested and then performing an update * package. */ -enum ice_status ice_destroy_tunnel (struct ice_hw *hw,u16 port,bool all) +static enum ice_status +ice_destroy_tunnel (struct ice_hw *hw,u16 index,enum ice_tunnel_type type, +u16 port) {struct ice_boost_tcam_section *sect_rx, *sect_tx;enum ice_status status =ICE_ERR_MAX_LIMIT ;struct ice_buf_build *bld; -u16 count =0 ; -u16 index; -u16 size; -u16 i;mutex_lock (&hw->tnl_lock); -if (!all &&ice_tunnel_port_in_use_hlpr (hw, port, &index)) -if (hw->tnl.tbl[index].ref >1 ) { - hw->tnl.tbl[index].ref--; - status =0 ; - goto ice_destroy_tunnel_end; - } - -/* determine count */ -for (i =0 ; i < hw->tnl.count && i <ICE_TUNNEL_MAX_ENTRIES ; i++) -if (hw->tnl.tbl[i].valid && hw->tnl.tbl[i].in_use && - (all || hw->tnl.tbl[i].port == port)) - count++; - -if (!count) { - status =ICE_ERR_PARAM ; +if (WARN_ON (!hw->tnl.tbl[index].valid || + hw->tnl.tbl[index].type != type || + hw->tnl.tbl[index].port != port)) { + status =ICE_ERR_OUT_OF_RANGE ; goto ice_destroy_tunnel_end; } -/* size of section - there is at least one entry */ - size =struct_size (sect_rx, tcam, count); - bld =ice_pkg_buf_alloc (hw);if (!bld) { status =ICE_ERR_NO_MEMORY ;
@@ -1856,13 +1786,13 @@ enum ice_status ice_destroy_tunnel(struct ice_hw *hw, u16 port, bool all) goto ice_destroy_tunnel_err; sect_rx =ice_pkg_buf_alloc_section (bld,ICE_SID_RXPARSER_BOOST_TCAM , - size); +struct_size (sect_rx, tcam,1 ));if (!sect_rx) goto ice_destroy_tunnel_err; sect_rx->count =cpu_to_le16 (1 ); sect_tx =ice_pkg_buf_alloc_section (bld,ICE_SID_TXPARSER_BOOST_TCAM , - size); +struct_size (sect_tx, tcam,1 ));if (!sect_tx) goto ice_destroy_tunnel_err; sect_tx->count =cpu_to_le16 (1 );
@@ -1870,26 +1800,14 @@ enum ice_status ice_destroy_tunnel(struct ice_hw *hw, u16 port, bool all)/* copy original boost entry to update package buffer, one copy to Rx * section, another copy to the Tx section */ -for (i =0 ; i < hw->tnl.count && i <ICE_TUNNEL_MAX_ENTRIES ; i++) -if (hw->tnl.tbl[i].valid && hw->tnl.tbl[i].in_use && - (all || hw->tnl.tbl[i].port == port)) { -memcpy (sect_rx->tcam + i, hw->tnl.tbl[i].boost_entry, -sizeof (*sect_rx->tcam)); -memcpy (sect_tx->tcam + i, hw->tnl.tbl[i].boost_entry, -sizeof (*sect_tx->tcam)); - hw->tnl.tbl[i].marked = true; - } +memcpy (sect_rx->tcam, hw->tnl.tbl[index].boost_entry, +sizeof (*sect_rx->tcam)); +memcpy (sect_tx->tcam, hw->tnl.tbl[index].boost_entry, +sizeof (*sect_tx->tcam)); status =ice_update_pkg (hw,ice_pkg_buf (bld),1 );if (!status) -for (i =0 ; i < hw->tnl.count && - i <ICE_TUNNEL_MAX_ENTRIES ; i++) -if (hw->tnl.tbl[i].marked) { - hw->tnl.tbl[i].ref =0 ; - hw->tnl.tbl[i].port =0 ; - hw->tnl.tbl[i].in_use = false; - hw->tnl.tbl[i].marked = false; - } + hw->tnl.tbl[index].port =0 ; ice_destroy_tunnel_err:ice_pkg_buf_free (hw, bld);
@@ -1900,6 +1818,52 @@ enum ice_status ice_destroy_tunnel(struct ice_hw *hw, u16 port, bool all)return status; } +int ice_udp_tunnel_set_port (struct net_device *netdev,unsigned int table, +unsigned int idx,struct udp_tunnel_info *ti) +{ +struct ice_netdev_priv *np =netdev_priv (netdev); +struct ice_vsi *vsi = np->vsi; +struct ice_pf *pf = vsi->back; +enum ice_tunnel_type tnl_type; +enum ice_status status; +u16 index; + + tnl_type = ti->type ==UDP_TUNNEL_TYPE_VXLAN ?TNL_VXLAN :TNL_GENEVE ; + index =ice_tunnel_idx_to_entry (&pf->hw, idx, tnl_type); + + status =ice_create_tunnel (&pf->hw, index, tnl_type,ntohs (ti->port)); +if (status) { +netdev_err (netdev,"Error adding UDP tunnel - %s\n" , +ice_stat_str (status)); +return -EIO ; + } + +udp_tunnel_nic_set_port_priv (netdev, table, idx, index); +return 0 ; +} + +int ice_udp_tunnel_unset_port (struct net_device *netdev,unsigned int table, +unsigned int idx,struct udp_tunnel_info *ti) +{ +struct ice_netdev_priv *np =netdev_priv (netdev); +struct ice_vsi *vsi = np->vsi; +struct ice_pf *pf = vsi->back; +enum ice_tunnel_type tnl_type; +enum ice_status status; + + tnl_type = ti->type ==UDP_TUNNEL_TYPE_VXLAN ?TNL_VXLAN :TNL_GENEVE ; + + status =ice_destroy_tunnel (&pf->hw, ti->hw_priv, tnl_type, +ntohs (ti->port)); +if (status) { +netdev_err (netdev,"Error removing UDP tunnel - %s\n" , +ice_stat_str (status)); +return -EIO ; + } + +return 0 ; +} +/* PTG Management */ /**
drivers/net/ethernet/intel/ice/ice_flex_pipe.h +4 -4
@@ -20,10 +20,10 @@bool ice_get_open_tunnel_port (struct ice_hw *hw,u16 *port); -enum ice_status -ice_create_tunnel (struct ice_hw *hw,enum ice_tunnel_type type,u16 port); -enum ice_status ice_destroy_tunnel (struct ice_hw *hw,u16 port,bool all); -bool ice_tunnel_port_in_use (struct ice_hw *hw,u16 port,u16 *index); +int ice_udp_tunnel_set_port (struct net_device *netdev,unsigned int table, +unsigned int idx,struct udp_tunnel_info *ti); +int ice_udp_tunnel_unset_port (struct net_device *netdev,unsigned int table, +unsigned int idx,struct udp_tunnel_info *ti); enum ice_status ice_add_prof(struct ice_hw *hw, enum ice_block blk, u64 id, u8 ptypes[],
drivers/net/ethernet/intel/ice/ice_flex_type.h +2 -3
@@ -298,6 +298,7 @@ struct ice_pkg_enum {enum ice_tunnel_type {TNL_VXLAN =0 ,TNL_GENEVE , + __TNL_TYPE_CNT,TNL_LAST =0xFF ,TNL_ALL =0xFF , };
@@ -311,11 +312,8 @@ struct ice_tunnel_entry {enum ice_tunnel_type type;u16 boost_addr;u16 port; -u16 ref;struct ice_boost_tcam_entry *boost_entry;u8 valid; -u8 in_use; -u8 marked; };#define ICE_TUNNEL_MAX_ENTRIES 16
@@ -323,6 +321,7 @@ struct ice_tunnel_entry {struct ice_tunnel_table {struct ice_tunnel_entry tbl[ICE_TUNNEL_MAX_ENTRIES ];u16 count; +u16 valid_count[__TNL_TYPE_CNT]; };struct ice_pkg_es {
drivers/net/ethernet/intel/ice/ice_main.c +30 -67
130 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_type.h +3 -0
@@ -676,6 +676,9 @@ struct ice_hw {struct mutex tnl_lock;struct ice_tunnel_table tnl; +struct udp_tunnel_nic_shared udp_tunnel_shared; +struct udp_tunnel_nic_info udp_tunnel_nic; +/* HW block tables */ struct ice_blk_info blk[ICE_BLK_COUNT ];struct mutex fl_profs_locks[ICE_BLK_COUNT ];/* lock fltr profiles */
Signature · 1 line
2.26.2
Jakub Kicinski
maintainerPATCH v2 6/10 ice: remove unused args from ice_get_open_tunnel_port()
In reply to Jakub Kicinskiice_get_open_tunnel_port() is always passed TNL_ALL as the second parameter.
--- drivers/net/ethernet/intel/ice/ice_ethtool_fdir.c | 6 ++---- drivers/net/ethernet/intel/ice/ice_fdir.c | 2 +- drivers/net/ethernet/intel/ice/ice_flex_pipe.c | 7 ++----- drivers/net/ethernet/intel/ice/ice_flex_pipe.h | 3 +-- 4 files changed, 6 insertions(+), 12 deletions(-)
drivers/net/ethernet/intel/ice/ice_ethtool_fdir.c +2 -4
@@ -1268,8 +1268,7 @@ ice_fdir_write_all_fltr(struct ice_pf *pf, struct ice_fdir_fltr *input,bool is_tun = tun ==ICE_FD_HW_SEG_TUN ;int err; -if (is_tun && !ice_get_open_tunnel_port (&pf->hw,TNL_ALL , - &port_num)) +if (is_tun && !ice_get_open_tunnel_port (&pf->hw, &port_num))continue ; err =ice_fdir_write_fltr (pf, input, add, is_tun);if (err)
@@ -1647,8 +1646,7 @@ int ice_add_fdir_ethtool(struct ice_vsi *vsi, struct ethtool_rxnfc *cmd) }/* return error if not an update and no available filters */ - fltrs_needed =ice_get_open_tunnel_port (hw,TNL_ALL , &tunnel_port) ? -2 :1 ; + fltrs_needed =ice_get_open_tunnel_port (hw, &tunnel_port) ?2 :1 ;if (!ice_fdir_find_fltr_by_idx (hw, fsp->location) &&ice_fdir_num_avail_fltr (hw, pf->vsi[vsi->idx]) < fltrs_needed) {dev_err (dev,"Failed to add filter. The maximum number of flow director filters has been reached.\n" );
drivers/net/ethernet/intel/ice/ice_fdir.c +1 -1
@@ -556,7 +556,7 @@ ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct ice_fdir_fltr *input,memcpy (pkt, ice_fdir_pkt[idx].pkt, ice_fdir_pkt[idx].pkt_len); loc = pkt; }else { -if (!ice_get_open_tunnel_port (hw,TNL_ALL , &tnl_port)) +if (!ice_get_open_tunnel_port (hw, &tnl_port))return ICE_ERR_DOES_NOT_EXIST ;if (!ice_fdir_pkt[idx].tun_pkt)return ICE_ERR_PARAM ;
drivers/net/ethernet/intel/ice/ice_flex_pipe.c +2 -5
@@ -1696,12 +1696,10 @@ ice_find_free_tunnel_entry(struct ice_hw *hw, enum ice_tunnel_type type,/** * ice_get_open_tunnel_port - retrieve an open tunnel port * @hw: pointer to the HW structure -* @type: tunnel type (TNL_ALL will return any open port) * @port: returns open port */ bool -ice_get_open_tunnel_port (struct ice_hw *hw,enum ice_tunnel_type type, -u16 *port) +ice_get_open_tunnel_port (struct ice_hw *hw,u16 *port) {bool res = false;u16 i;
@@ -1709,8 +1707,7 @@ ice_get_open_tunnel_port(struct ice_hw *hw, enum ice_tunnel_type type,mutex_lock (&hw->tnl_lock);for (i =0 ; i < hw->tnl.count && i <ICE_TUNNEL_MAX_ENTRIES ; i++) -if (hw->tnl.tbl[i].valid && hw->tnl.tbl[i].in_use && - (type ==TNL_ALL || hw->tnl.tbl[i].type == type)) { +if (hw->tnl.tbl[i].valid && hw->tnl.tbl[i].in_use) { *port = hw->tnl.tbl[i].port; res = true;break ;
drivers/net/ethernet/intel/ice/ice_flex_pipe.h +1 -2
@@ -19,8 +19,7 @@#define ICE_PKG_CNT 4bool -ice_get_open_tunnel_port (struct ice_hw *hw,enum ice_tunnel_type type, -u16 *port); +ice_get_open_tunnel_port (struct ice_hw *hw,u16 *port);enum ice_status ice_create_tunnel (struct ice_hw *hw,enum ice_tunnel_type type,u16 port);enum ice_status ice_destroy_tunnel (struct ice_hw *hw,u16 port,bool all);
Signature · 1 line
2.26.2
Jakub Kicinski
maintainerPATCH v2 10/10 docs: vxlan: add info about device features
In reply to Jakub KicinskiAdd some information about VxLAN-related netdev features and how to dump port table via ethtool.
--- Documentation/networking/vxlan.rst | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
Documentation/networking/vxlan.rst +28 -0
@@ -58,3 +58,31 @@ forwarding table using the new bridge command. 3. Show forwarding table:: # bridge fdb show dev vxlan0 + +The following NIC features may indicate support for UDP tunnel-related +offloads (most commonly VXLAN features, but support for a particular +encapsulation protocol is NIC specific): + + - `tx-udp_tnl-segmentation` + - `tx-udp_tnl-csum-segmentation` + ability to perform TCP segmentation offload of UDP encapsulated frames + + - `rx-udp_tunnel-port-offload` + receive side parsing of UDP encapsulated frames which allows NICs to + perform protocol-aware offloads, like checksum validation offload of + inner frames (only needed by NICs without protocol-agnostic offloads) + +For devices supporting `rx-udp_tunnel-port-offload` the list of currently +offloaded ports can be interrogated with `ethtool`:: + + $ ethtool --show-tunnels eth0 + Tunnel information for eth0: + UDP port table 0: + Size: 4 + Types: vxlan + No entries + UDP port table 1: + Size: 4 + Types: geneve, vxlan-gpe + Entries (1): + port 1230, vxlan-gpe
Signature · 1 line
2.26.2
Jakub Kicinski
maintainerPATCH v2 8/10 netdevsim: support the static IANA VXLAN port flag
In reply to Jakub KicinskiAllow setting UDP_TUNNEL_NIC_INFO_STATIC_IANA_VXLAN.
--- drivers/net/netdevsim/netdevsim.h | 1 + drivers/net/netdevsim/udp_tunnels.c | 4 ++++ 2 files changed, 5 insertions(+)
drivers/net/netdevsim/netdevsim.h +1 -0
@@ -216,6 +216,7 @@ struct nsim_dev {bool open_only;bool ipv4_only;bool shared; +bool static_iana_vxlan;u32 sleep; } udp_ports; };
drivers/net/netdevsim/udp_tunnels.c +4 -0
@@ -186,6 +186,8 @@ int nsim_udp_tunnels_info_create(struct nsim_dev *nsim_dev, info->flags |=UDP_TUNNEL_NIC_INFO_IPV4_ONLY ;if (nsim_dev->udp_ports.shared) info->shared = &nsim_dev->udp_ports.utn_shared; +if (nsim_dev->udp_ports.static_iana_vxlan) + info->flags |=UDP_TUNNEL_NIC_INFO_STATIC_IANA_VXLAN ; dev->udp_tunnel_nic_info = info;return 0 ;
@@ -207,6 +209,8 @@ void nsim_udp_tunnels_debugfs_create(struct nsim_dev *nsim_dev) &nsim_dev->udp_ports.ipv4_only);debugfs_create_bool ("udp_ports_shared" ,0600 , nsim_dev->ddir, &nsim_dev->udp_ports.shared); +debugfs_create_bool ("udp_ports_static_iana_vxlan" ,0600 , nsim_dev->ddir, + &nsim_dev->udp_ports.static_iana_vxlan);debugfs_create_u32 ("udp_ports_sleep" ,0600 , nsim_dev->ddir, &nsim_dev->udp_ports.sleep); }
Signature · 1 line
2.26.2
Jakub Kicinski
maintainerPATCH v2 3/10 netdevsim: shared UDP tunnel port table support
In reply to Jakub KicinskiAdd the ability to simulate a device with a shared UDP tunnel port table.
Try to reject the configurations and actions which are not supported by the core, so we don't get syzcaller etc. warning reports.
--- drivers/net/netdevsim/netdevsim.h | 7 ++++++- drivers/net/netdevsim/udp_tunnels.c | 17 ++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-)
drivers/net/netdevsim/netdevsim.h +6 -1
@@ -20,6 +20,7 @@#include <linux/netdevice.h> #include <linux/u64_stats_sync.h> #include <net/devlink.h> +#include <net/udp_tunnel.h> #include <net/xdp.h> #define DRV_NAME "netdevsim"
@@ -84,7 +85,8 @@ struct netdevsim {struct {u32 inject_error;u32 sleep; -u32 ports[2 ][NSIM_UDP_TUNNEL_N_PORTS ]; +u32 __ports[2 ][NSIM_UDP_TUNNEL_N_PORTS ]; +u32 (*ports)[NSIM_UDP_TUNNEL_N_PORTS ];struct debugfs_u32_array dfs_ports[2 ]; } udp_ports;
@@ -208,9 +210,12 @@ struct nsim_dev {bool fail_trap_policer_set;bool fail_trap_policer_counter_get;struct { +struct udp_tunnel_nic_shared utn_shared; +u32 __ports[2 ][NSIM_UDP_TUNNEL_N_PORTS ];bool sync_all;bool open_only;bool ipv4_only; +bool shared;u32 sleep; } udp_ports; };
drivers/net/netdevsim/udp_tunnels.c +16 -1
@@ -112,7 +112,7 @@ nsim_udp_tunnels_info_reset_write(struct file *file, const char __user *data,struct net_device *dev = file->private_data;struct netdevsim *ns =netdev_priv (dev); -memset (&ns->udp_ports.ports,0 ,sizeof (ns->udp_ports.ports)); +memset (ns->udp_ports.ports,0 ,sizeof (ns->udp_ports.__ports));rtnl_lock ();udp_tunnel_nic_reset_ntf (dev);rtnl_unlock ();
@@ -132,6 +132,17 @@ int nsim_udp_tunnels_info_create(struct nsim_dev *nsim_dev,struct netdevsim *ns =netdev_priv (dev);struct udp_tunnel_nic_info *info; +if (nsim_dev->udp_ports.shared && nsim_dev->udp_ports.open_only) { +dev_err (&nsim_dev->nsim_bus_dev->dev, +"shared can't be used in conjunction with open_only\n" ); +return -EINVAL ; + } + +if (!nsim_dev->udp_ports.shared) + ns->udp_ports.ports = ns->udp_ports.__ports; +else + ns->udp_ports.ports = nsim_dev->udp_ports.__ports; +debugfs_create_u32 ("udp_ports_inject_error" ,0600 , ns->nsim_dev_port->ddir, &ns->udp_ports.inject_error);
@@ -173,6 +184,8 @@ int nsim_udp_tunnels_info_create(struct nsim_dev *nsim_dev, info->flags |=UDP_TUNNEL_NIC_INFO_OPEN_ONLY ;if (nsim_dev->udp_ports.ipv4_only) info->flags |=UDP_TUNNEL_NIC_INFO_IPV4_ONLY ; +if (nsim_dev->udp_ports.shared) + info->shared = &nsim_dev->udp_ports.utn_shared; dev->udp_tunnel_nic_info = info;return 0 ;
@@ -192,6 +205,8 @@ void nsim_udp_tunnels_debugfs_create(struct nsim_dev *nsim_dev) &nsim_dev->udp_ports.open_only);debugfs_create_bool ("udp_ports_ipv4_only" ,0600 , nsim_dev->ddir, &nsim_dev->udp_ports.ipv4_only); +debugfs_create_bool ("udp_ports_shared" ,0600 , nsim_dev->ddir, + &nsim_dev->udp_ports.shared);debugfs_create_u32 ("udp_ports_sleep" ,0600 , nsim_dev->ddir, &nsim_dev->udp_ports.sleep); }
Signature · 1 line
2.26.2
Nguyen, Anthony L
maintainerQuoted 6 lines · Jakub Kicinski
This set converts Intel drivers which have the ability to spawn multiple netdevs, but have only one UDP tunnel port table.
Appropriate support is added to the core infra in patch 1, followed by netdevsim support and a selftest.
Quoted 8 lines
The table sharing works by core attaching the same table structure to all devices sharing the table. This means the reference count has to accommodate potentially large values.
Once core is ready i40e and ice are converted. These are complex drivers, but we got a tested-by from Aaron, so we should be good :)
Hi Dave,
Since we've finished our testing and reviews, do you want to pull this series or would you like me to re-send it as a pull request now that the email issue is fixed?
Thanks,
Tony
David Miller
maintainerFrom: "Nguyen, Anthony L" <[email protected]>
Date: Mon, 28 Sep 2020 16:23:54 +0000
Quoted 15 lines · Jakub Kicinski
Quoted 6 lines
This set converts Intel drivers which have the ability to spawn multiple netdevs, but have only one UDP tunnel port table.
Appropriate support is added to the core infra in patch 1, followed by netdevsim support and a selftest.
Quoted 8 lines
The table sharing works by core attaching the same table structure to all devices sharing the table. This means the reference count has to accommodate potentially large values.
Once core is ready i40e and ice are converted. These are complex drivers, but we got a tested-by from Aaron, so we should be good :)
Quoted 5 lines
Hi Dave,
Since we've finished our testing and reviews, do you want to pull this series or would you like me to re-send it as a pull request now that the email issue is fixed?
I'll take it in myself, thanks Tony.
David Miller
maintainerFrom: Jakub Kicinski <[email protected]>
Date: Fri, 25 Sep 2020 17:56:39 -0700
Quoted 14 lines
This set converts Intel drivers which have the ability to spawn multiple netdevs, but have only one UDP tunnel port table.
Appropriate support is added to the core infra in patch 1, followed by netdevsim support and a selftest.
The table sharing works by core attaching the same table structure to all devices sharing the table. This means the reference count has to accommodate potentially large values.
Once core is ready i40e and ice are converted. These are complex drivers, but we got a tested-by from Aaron, so we should be good :)
Quoted 8 lines
Compared to v1 I've made sure the selftest is executable.
Other than that patches 8 and 9 are actually from the Mellanox conversion series were kept out to avoid Mellanox vs Intel conflicts.
Last patch is new, some docs to let users knows ethtool can now display UDP tunnel info.
Series applied, thanks Jakub.