From patchwork Mon Aug 24 22:04:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Singhai, Anjali" X-Patchwork-Id: 510321 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ozlabs.org (Postfix) with ESMTP id 453E314032C for ; Tue, 25 Aug 2015 07:49:44 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id BE7119581A; Mon, 24 Aug 2015 21:49:43 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vYrwVfdzR9Hs; Mon, 24 Aug 2015 21:49:43 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 048A395803; Mon, 24 Aug 2015 21:49:43 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id ACD801C1FBD for ; Mon, 24 Aug 2015 21:49:42 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 7E69B31AA2 for ; Mon, 24 Aug 2015 21:49:42 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id N+elFIvDbTWz for ; Mon, 24 Aug 2015 21:49:41 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by silver.osuosl.org (Postfix) with ESMTP id 36B6031A62 for ; Mon, 24 Aug 2015 21:49:41 +0000 (UTC) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP; 24 Aug 2015 14:49:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,741,1432623600"; d="scan'208";a="790084493" Received: from asinghai-cp.jf.intel.com ([134.134.3.57]) by fmsmga002.fm.intel.com with ESMTP; 24 Aug 2015 14:49:40 -0700 From: Anjali Singhai Jain To: intel-wired-lan@lists.osuosl.org Date: Mon, 24 Aug 2015 15:04:49 -0700 Message-Id: <1440453891-214878-2-git-send-email-anjali.singhai@intel.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1440453891-214878-1-git-send-email-anjali.singhai@intel.com> References: <1440453891-214878-1-git-send-email-anjali.singhai@intel.com> Subject: [Intel-wired-lan] [RFC v1 2/4] geneve: Add geneve udp port offload for ethernet devices X-BeenThere: intel-wired-lan@lists.osuosl.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-wired-lan-bounces@lists.osuosl.org Sender: "Intel-wired-lan" Add ndo_ops to add/del UDP ports to a device that supports geneve offload. v2:Added comments for new ndo_ops and minor format fix. Signed-off-by: Kiran Patil Signed-off-by: Anjali Singhai Jain --- include/linux/netdevice.h | 20 +++++++++++++++++++- net/ipv4/geneve_core.c | 22 ++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index f3bb290..d6f00c7 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -1016,6 +1016,19 @@ typedef u16 (*select_queue_fallback_t)(struct net_device *dev, * address family that vxlan is not listening to anymore. The operation * is protected by the vxlan_net->sock_lock. * + * void (*ndo_add_geneve_port)(struct net_device *dev, + * sa_family_t sa_family, __be16 port); + * Called by geneve to notiy a driver about the UDP port and socket + * address family that geneve is listnening to. It is called only when + * a new port starts listening. The operation is protected by the + * geneve_net->sock_lock. + * + * void (*ndo_del_geneve_port)(struct net_device *dev, + * sa_family_t sa_family, __be16 port); + * Called by geneve to notify the driver about a UDP port and socket + * address family that geneve is not listening to anymore. The operation + * is protected by the geneve_net->sock_lock. + * * void* (*ndo_dfwd_add_station)(struct net_device *pdev, * struct net_device *dev) * Called by upper layer devices to accelerate switching or other @@ -1210,7 +1223,12 @@ struct net_device_ops { void (*ndo_del_vxlan_port)(struct net_device *dev, sa_family_t sa_family, __be16 port); - + void (*ndo_add_geneve_port)(struct net_device *dev, + sa_family_t sa_family, + __be16 port); + void (*ndo_del_geneve_port)(struct net_device *dev, + sa_family_t sa_family, + __be16 port); 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/net/ipv4/geneve_core.c b/net/ipv4/geneve_core.c index 311a4ba..9ea9082 100644 --- a/net/ipv4/geneve_core.c +++ b/net/ipv4/geneve_core.c @@ -234,8 +234,11 @@ static int geneve_gro_complete(struct sk_buff *skb, int nhoff, static void geneve_notify_add_rx_port(struct geneve_sock *gs) { + struct net_device *dev; struct sock *sk = gs->sock->sk; + struct net *net = sock_net(sk); sa_family_t sa_family = sk->sk_family; + __be16 port = inet_sk(sk)->inet_sport; int err; if (sa_family == AF_INET) { @@ -244,12 +247,31 @@ static void geneve_notify_add_rx_port(struct geneve_sock *gs) pr_warn("geneve: udp_add_offload failed with status %d\n", err); } + + rcu_read_lock(); + for_each_netdev_rcu(net, dev) { + if (dev->netdev_ops->ndo_add_geneve_port) + dev->netdev_ops->ndo_add_geneve_port(dev, sa_family, + port); + } + rcu_read_unlock(); } static void geneve_notify_del_rx_port(struct geneve_sock *gs) { + struct net_device *dev; struct sock *sk = gs->sock->sk; + struct net *net = sock_net(sk); sa_family_t sa_family = sk->sk_family; + __be16 port = inet_sk(sk)->inet_sport; + + rcu_read_lock(); + for_each_netdev_rcu(net, dev) { + if (dev->netdev_ops->ndo_del_geneve_port) + dev->netdev_ops->ndo_del_geneve_port(dev, sa_family, + port); + } + rcu_read_unlock(); if (sa_family == AF_INET) udp_del_offload(&gs->udp_offloads);