fm10k: convert to new udp_tunnel_nic infra (support kernel >= 5.12.0)
Some checks reported errors
continuous-integration/drone/push Build was killed
continuous-integration/drone/pr Build was killed

Straightforward conversion to new infra. Driver restores info
after close/open cycle by calling its internal restore function
so just use that, no need for udp_tunnel_nic_reset_ntf() here.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

Based off linux commit f7529b4ba3c98470b0e367ba447ad0da84dc308c
This commit is contained in:
DataHoarder 2021-08-04 04:16:23 +02:00
parent 279ad02edf
commit d701c1f0c7
5 changed files with 73 additions and 3 deletions

View file

@ -236,11 +236,13 @@ struct fm10k_iov_data {
struct fm10k_vf_info vf_info[0];
};
#ifndef HAVE_UDP_TUNNEL_NIC
struct fm10k_udp_port {
struct list_head list;
sa_family_t sa_family;
__be16 port;
};
#endif
enum fm10k_macvlan_request_type {
FM10K_UC_MAC_REQUEST,
@ -397,9 +399,13 @@ struct fm10k_intfc {
u32 rssrk[FM10K_RSSRK_SIZE];
/* UDP encapsulation port tracking information */
#ifdef HAVE_UDP_TUNNEL_NIC
__be16 vxlan_port;
__be16 geneve_port;
#else
struct list_head vxlan_port;
struct list_head geneve_port;
#endif
/* MAC/VLAN update queue */
struct list_head macvlan_requests;
struct delayed_work macvlan_task;

View file

@ -692,6 +692,9 @@ static int fm10k_clean_rx_irq(struct fm10k_q_vector *q_vector,
static struct ethhdr *fm10k_port_is_vxlan(struct sk_buff *skb)
{
struct fm10k_intfc *interface = netdev_priv(skb->dev);
#ifdef HAVE_UDP_TUNNEL_NIC
if (interface->vxlan_port != udp_hdr(skb)->dest)
#else
struct fm10k_udp_port *vxlan_port;
/* we can only offload a vxlan if we recognize it as such */
@ -701,6 +704,7 @@ static struct ethhdr *fm10k_port_is_vxlan(struct sk_buff *skb)
if (!vxlan_port)
return NULL;
if (vxlan_port->port != udp_hdr(skb)->dest)
#endif
return NULL;
/* return offset of udp_hdr plus 8 bytes for VXLAN header */

View file

@ -376,6 +376,7 @@ static void fm10k_request_glort_range(struct fm10k_intfc *interface)
}
}
#ifndef HAVE_UDP_TUNNEL_NIC
/**
* fm10k_free_udp_port_info
* @interface: board private structure
@ -408,6 +409,7 @@ static void fm10k_free_udp_port_info(struct fm10k_intfc *interface)
list);
}
}
#endif
/**
* fm10k_restore_udp_port_info
@ -418,12 +420,24 @@ static void fm10k_free_udp_port_info(struct fm10k_intfc *interface)
static void fm10k_restore_udp_port_info(struct fm10k_intfc *interface)
{
struct fm10k_hw *hw = &interface->hw;
#ifndef HAVE_UDP_TUNNEL_NIC
struct fm10k_udp_port *port;
#endif
/* only the PF supports configuring tunnels */
if (hw->mac.type != fm10k_mac_pf)
return;
#ifdef HAVE_UDP_TUNNEL_NIC
/* restore tunnel configuration register */
fm10k_write_reg(hw, FM10K_TUNNEL_CFG,
ntohs(interface->vxlan_port) |
(ETH_P_TEB << FM10K_TUNNEL_CFG_NVGRE_SHIFT));
/* restore Geneve tunnel configuration register */
fm10k_write_reg(hw, FM10K_TUNNEL_CFG_GENEVE,
ntohs(interface->geneve_port));
#else
port = list_first_entry_or_null(&interface->vxlan_port,
struct fm10k_udp_port, list);
@ -438,8 +452,42 @@ static void fm10k_restore_udp_port_info(struct fm10k_intfc *interface)
/* restore Geneve tunnel configuration register */
fm10k_write_reg(hw, FM10K_TUNNEL_CFG_GENEVE,
(port ? ntohs(port->port) : 0));
#endif
}
#ifdef HAVE_UDP_TUNNEL_NIC
/**
* fm10k_udp_tunnel_sync - Called when UDP tunnel ports change
* @dev: network interface device structure
* @table: Tunnel table (according to tables of @fm10k_udp_tunnels)
*
* This function is called when a new UDP tunnel port is added or deleted.
* Due to hardware restrictions, only one port per type can be offloaded at
* once. Core will send to the driver a port of its choice.
**/
static int fm10k_udp_tunnel_sync(struct net_device *dev, unsigned int table)
{
struct fm10k_intfc *interface = netdev_priv(dev);
struct udp_tunnel_info ti;
udp_tunnel_nic_get_port(dev, table, 0, &ti);
if (!table)
interface->vxlan_port = ti.port;
else
interface->geneve_port = ti.port;
fm10k_restore_udp_port_info(interface);
return 0;
}
static const struct udp_tunnel_nic_info fm10k_udp_tunnels = {
.sync_table = fm10k_udp_tunnel_sync,
.tables = {
{ .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_VXLAN, },
{ .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_GENEVE, },
},
};
#else
static struct fm10k_udp_port *
fm10k_remove_tunnel_port(struct list_head *ports,
struct udp_tunnel_info *ti)
@ -545,6 +593,7 @@ static void fm10k_udp_tunnel_del(struct net_device *dev,
fm10k_restore_udp_port_info(interface);
}
#endif
#ifdef HAVE_VXLAN_RX_OFFLOAD
/**
@ -679,7 +728,7 @@ int fm10k_open(struct net_device *netdev)
#if defined(HAVE_GENEVE_RX_OFFLOAD) && !defined(HAVE_UDP_ENC_RX_OFFLOAD)
geneve_get_rx_port(netdev);
#endif
#ifdef HAVE_UDP_ENC_RX_OFFLOAD
#if defined(HAVE_UDP_ENC_RX_OFFLOAD) && !defined(HAVE_UDP_TUNNEL_NIC)
udp_tunnel_get_rx_info(netdev);
#endif
@ -716,7 +765,9 @@ int fm10k_close(struct net_device *netdev)
fm10k_qv_free_irq(interface);
#ifndef HAVE_UDP_TUNNEL_NIC
fm10k_free_udp_port_info(interface);
#endif
fm10k_free_all_tx_resources(interface);
fm10k_free_all_rx_resources(interface);
@ -1994,7 +2045,7 @@ static const struct net_device_ops fm10k_netdev_ops = {
#ifdef HAVE_RHEL7_NETDEV_OPS_EXT_NDO_SET_VF_VLAN
.ndo_set_vf_vlan = fm10k_ndo_set_vf_vlan,
#endif /* HAVE_RHEL7_NETDEV_OPS_EXT_NDO_SET_VF_VLAN */
#ifdef HAVE_UDP_ENC_RX_OFFLOAD
#if defined(HAVE_UDP_ENC_RX_OFFLOAD) && defined(HAVE_UDP_TUNNEL_)
.ndo_udp_tunnel_add = fm10k_udp_tunnel_add,
.ndo_udp_tunnel_del = fm10k_udp_tunnel_del,
#endif
@ -2067,6 +2118,9 @@ struct net_device *fm10k_alloc_netdev(void)
#ifdef HAVE_ENCAP_TSO_OFFLOAD
dev->features |= NETIF_F_GSO_UDP_TUNNEL;
#endif
#ifdef HAVE_UDP_TUNNEL_NIC
dev->udp_tunnel_nic_info = &fm10k_udp_tunnels;
#endif
}
#endif

View file

@ -2115,9 +2115,11 @@ static int fm10k_sw_init(struct fm10k_intfc *interface,
interface->tx_itr = FM10K_TX_ITR_DEFAULT;
interface->rx_itr = FM10K_ITR_ADAPTIVE | FM10K_RX_ITR_DEFAULT;
#ifndef HAVE_UDP_TUNNEL_NIC
/* initialize udp port lists */
INIT_LIST_HEAD(&interface->vxlan_port);
INIT_LIST_HEAD(&interface->geneve_port);
#endif
/* Initialize the MAC/VLAN queue */
INIT_LIST_HEAD(&interface->macvlan_requests);

View file

@ -5263,6 +5263,10 @@ pci_release_mem_regions(struct pci_dev *pdev)
#define HAVE_ETHTOOL_NEW_50G_BITS
#endif /* 4.8.0 */
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,12,0))
#define HAVE_UDP_TUNNEL_NIC
#endif
/*****************************************************************************/
#if (LINUX_VERSION_CODE < KERNEL_VERSION(4,9,0))
#ifdef HAVE_TC_SETUP_CLSFLOWER