From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, oss-drivers@netronome.com,
simon.horman@netronome.com, ajit.khaparde@broadcom.com,
sriharsha.basavapatna@broadcom.com, somnath.kotur@broadcom.com,
thomas.lendacky@amd.com, aelior@marvell.com,
skalluru@marvell.com, vishal@chelsio.com, benve@cisco.com,
_govind@gmx.com, dchickles@marvell.com, sburla@marvell.com,
fmanlunas@marvell.com, jeffrey.t.kirsher@intel.com,
anthony.l.nguyen@intel.com, GR-everest-linux-l2@marvell.com,
shshaikh@marvell.com, manishc@marvell.com,
GR-Linux-NIC-Dev@marvell.com, Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH net-next v3 07/12] enic: convert to new udp_tunnel_nic infra
Date: Tue, 14 Jul 2020 12:18:25 -0700 [thread overview]
Message-ID: <20200714191830.694674-8-kuba@kernel.org> (raw)
In-Reply-To: <20200714191830.694674-1-kuba@kernel.org>
Convert to new infra, now the refcounting will be correct,
and driver gets port replay of other ports when offloaded
port gets removed.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
drivers/net/ethernet/cisco/enic/enic_main.c | 105 ++++++++------------
1 file changed, 39 insertions(+), 66 deletions(-)
diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
index cd5fe4f6b54c..6bc7e7ba38c3 100644
--- a/drivers/net/ethernet/cisco/enic/enic_main.c
+++ b/drivers/net/ethernet/cisco/enic/enic_main.c
@@ -176,50 +176,18 @@ static void enic_unset_affinity_hint(struct enic *enic)
irq_set_affinity_hint(enic->msix_entry[i].vector, NULL);
}
-static void enic_udp_tunnel_add(struct net_device *netdev,
- struct udp_tunnel_info *ti)
+static int enic_udp_tunnel_set_port(struct net_device *netdev,
+ unsigned int table, unsigned int entry,
+ struct udp_tunnel_info *ti)
{
struct enic *enic = netdev_priv(netdev);
- __be16 port = ti->port;
int err;
spin_lock_bh(&enic->devcmd_lock);
- if (ti->type != UDP_TUNNEL_TYPE_VXLAN) {
- netdev_info(netdev, "udp_tnl: only vxlan tunnel offload supported");
- goto error;
- }
-
- switch (ti->sa_family) {
- case AF_INET6:
- if (!(enic->vxlan.flags & ENIC_VXLAN_OUTER_IPV6)) {
- netdev_info(netdev, "vxlan: only IPv4 offload supported");
- goto error;
- }
- /* Fall through */
- case AF_INET:
- break;
- default:
- goto error;
- }
-
- if (enic->vxlan.vxlan_udp_port_number) {
- if (ntohs(port) == enic->vxlan.vxlan_udp_port_number)
- netdev_warn(netdev, "vxlan: udp port already offloaded");
- else
- netdev_info(netdev, "vxlan: offload supported for only one UDP port");
-
- goto error;
- }
- if ((vnic_dev_get_res_count(enic->vdev, RES_TYPE_WQ) != 1) &&
- !(enic->vxlan.flags & ENIC_VXLAN_MULTI_WQ)) {
- netdev_info(netdev, "vxlan: vxlan offload with multi wq not supported on this adapter");
- goto error;
- }
-
err = vnic_dev_overlay_offload_cfg(enic->vdev,
OVERLAY_CFG_VXLAN_PORT_UPDATE,
- ntohs(port));
+ ntohs(ti->port));
if (err)
goto error;
@@ -228,52 +196,50 @@ static void enic_udp_tunnel_add(struct net_device *netdev,
if (err)
goto error;
- enic->vxlan.vxlan_udp_port_number = ntohs(port);
-
- netdev_info(netdev, "vxlan fw-vers-%d: offload enabled for udp port: %d, sa_family: %d ",
- (int)enic->vxlan.patch_level, ntohs(port), ti->sa_family);
-
- goto unlock;
-
+ enic->vxlan.vxlan_udp_port_number = ntohs(ti->port);
error:
- netdev_info(netdev, "failed to offload udp port: %d, sa_family: %d, type: %d",
- ntohs(port), ti->sa_family, ti->type);
-unlock:
spin_unlock_bh(&enic->devcmd_lock);
+
+ return err;
}
-static void enic_udp_tunnel_del(struct net_device *netdev,
- struct udp_tunnel_info *ti)
+static int enic_udp_tunnel_unset_port(struct net_device *netdev,
+ unsigned int table, unsigned int entry,
+ struct udp_tunnel_info *ti)
{
struct enic *enic = netdev_priv(netdev);
int err;
spin_lock_bh(&enic->devcmd_lock);
- if ((ntohs(ti->port) != enic->vxlan.vxlan_udp_port_number) ||
- ti->type != UDP_TUNNEL_TYPE_VXLAN) {
- netdev_info(netdev, "udp_tnl: port:%d, sa_family: %d, type: %d not offloaded",
- ntohs(ti->port), ti->sa_family, ti->type);
- goto unlock;
- }
-
err = vnic_dev_overlay_offload_ctrl(enic->vdev, OVERLAY_FEATURE_VXLAN,
OVERLAY_OFFLOAD_DISABLE);
- if (err) {
- netdev_err(netdev, "vxlan: del offload udp port: %d failed",
- ntohs(ti->port));
+ if (err)
goto unlock;
- }
enic->vxlan.vxlan_udp_port_number = 0;
- netdev_info(netdev, "vxlan: del offload udp port %d, family %d\n",
- ntohs(ti->port), ti->sa_family);
-
unlock:
spin_unlock_bh(&enic->devcmd_lock);
+
+ return err;
}
+static const struct udp_tunnel_nic_info enic_udp_tunnels = {
+ .set_port = enic_udp_tunnel_set_port,
+ .unset_port = enic_udp_tunnel_unset_port,
+ .tables = {
+ { .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_VXLAN, },
+ },
+}, enic_udp_tunnels_v4 = {
+ .set_port = enic_udp_tunnel_set_port,
+ .unset_port = enic_udp_tunnel_unset_port,
+ .flags = UDP_TUNNEL_NIC_INFO_IPV4_ONLY,
+ .tables = {
+ { .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_VXLAN, },
+ },
+};
+
static netdev_features_t enic_features_check(struct sk_buff *skb,
struct net_device *dev,
netdev_features_t features)
@@ -2526,8 +2492,8 @@ static const struct net_device_ops enic_netdev_dynamic_ops = {
#ifdef CONFIG_RFS_ACCEL
.ndo_rx_flow_steer = enic_rx_flow_steer,
#endif
- .ndo_udp_tunnel_add = enic_udp_tunnel_add,
- .ndo_udp_tunnel_del = enic_udp_tunnel_del,
+ .ndo_udp_tunnel_add = udp_tunnel_nic_add_port,
+ .ndo_udp_tunnel_del = udp_tunnel_nic_del_port,
.ndo_features_check = enic_features_check,
};
@@ -2552,8 +2518,8 @@ static const struct net_device_ops enic_netdev_ops = {
#ifdef CONFIG_RFS_ACCEL
.ndo_rx_flow_steer = enic_rx_flow_steer,
#endif
- .ndo_udp_tunnel_add = enic_udp_tunnel_add,
- .ndo_udp_tunnel_del = enic_udp_tunnel_del,
+ .ndo_udp_tunnel_add = udp_tunnel_nic_add_port,
+ .ndo_udp_tunnel_del = udp_tunnel_nic_del_port,
.ndo_features_check = enic_features_check,
};
@@ -2963,6 +2929,13 @@ static int enic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
patch_level = fls(patch_level);
patch_level = patch_level ? patch_level - 1 : 0;
enic->vxlan.patch_level = patch_level;
+
+ if (vnic_dev_get_res_count(enic->vdev, RES_TYPE_WQ) == 1 ||
+ enic->vxlan.flags & ENIC_VXLAN_MULTI_WQ) {
+ netdev->udp_tunnel_nic_info = &enic_udp_tunnels_v4;
+ if (enic->vxlan.flags & ENIC_VXLAN_OUTER_IPV6)
+ netdev->udp_tunnel_nic_info = &enic_udp_tunnels;
+ }
}
netdev->features |= netdev->hw_features;
--
2.26.2
next prev parent reply other threads:[~2020-07-14 19:18 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-14 19:18 [PATCH net-next v3 00/12] udp_tunnel: NIC RX port offload infrastructure Jakub Kicinski
2020-07-14 19:18 ` [PATCH net-next v3 01/12] nfp: convert to new udp_tunnel_nic infra Jakub Kicinski
2020-07-14 19:24 ` Alexei Starovoitov
2020-07-14 19:45 ` Jakub Kicinski
2020-07-14 19:49 ` Alexei Starovoitov
2020-07-14 19:18 ` [PATCH net-next v3 02/12] be2net: " Jakub Kicinski
2020-07-14 19:18 ` [PATCH net-next v3 03/12] xgbe: switch to more generic VxLAN detection Jakub Kicinski
2020-07-14 19:18 ` [PATCH net-next v3 04/12] xgbe: convert to new udp_tunnel_nic infra Jakub Kicinski
2020-07-14 19:18 ` [PATCH net-next v3 05/12] bnx2x: " Jakub Kicinski
2020-07-14 19:18 ` [PATCH net-next v3 06/12] cxgb4: " Jakub Kicinski
2020-07-14 19:18 ` Jakub Kicinski [this message]
2020-07-14 19:18 ` [PATCH net-next v3 08/12] liquidio: " Jakub Kicinski
2020-07-14 19:18 ` [PATCH net-next v3 09/12] liquidio_vf: " Jakub Kicinski
2020-07-14 19:18 ` [PATCH net-next v3 10/12] fm10k: " Jakub Kicinski
2020-07-23 0:30 ` Jacob Keller
2020-07-14 19:18 ` [PATCH net-next v3 11/12] qede: " Jakub Kicinski
2020-07-14 19:18 ` [PATCH net-next v3 12/12] qlcnic: " Jakub Kicinski
2020-07-15 0:06 ` [PATCH net-next v3 00/12] udp_tunnel: NIC RX port offload infrastructure David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200714191830.694674-8-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=GR-Linux-NIC-Dev@marvell.com \
--cc=GR-everest-linux-l2@marvell.com \
--cc=_govind@gmx.com \
--cc=aelior@marvell.com \
--cc=ajit.khaparde@broadcom.com \
--cc=anthony.l.nguyen@intel.com \
--cc=benve@cisco.com \
--cc=davem@davemloft.net \
--cc=dchickles@marvell.com \
--cc=fmanlunas@marvell.com \
--cc=jeffrey.t.kirsher@intel.com \
--cc=manishc@marvell.com \
--cc=netdev@vger.kernel.org \
--cc=oss-drivers@netronome.com \
--cc=sburla@marvell.com \
--cc=shshaikh@marvell.com \
--cc=simon.horman@netronome.com \
--cc=skalluru@marvell.com \
--cc=somnath.kotur@broadcom.com \
--cc=sriharsha.basavapatna@broadcom.com \
--cc=thomas.lendacky@amd.com \
--cc=vishal@chelsio.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).