From patchwork Tue Mar 5 12:15:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13582315 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 326BA5A7A5; Tue, 5 Mar 2024 12:15:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709640936; cv=none; b=Ax5ubWXLUmHC7Nkz/R+p4IAuNh7bWlV1tgLGCJaYZO6IKtxHVxRhOmkwtKW27mJfdbeozdsrcfo4GFbHJLS25mBtPeFw/PDP60i86AfcMf7B4F34ezbK/kF41en2j90e5z2PxGGSkEyei81zsgYlclzPbmqWVH+dxI2WalOobks= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709640936; c=relaxed/simple; bh=yrysr5iWvnRVbt2xL/EIfqttzTX5rUTHYqNzaLx5qcM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=pXrtShTFtWFEtZlmXpNo6hoolrRtA+o/8w3d52LO2vKdNdlMlzlLreIZQEJRD//XlefSwgLmfsAPCyD6ty6Ij0t5RMrqeR6kZHSMmdfTbHF7ZE+fcE28Ei1dN9F2vYfea/BAUyH2TfqL5JOiAjoXM7yaUAN/tv2YRPlycV6+MWk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.218.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-a2f22bfb4e6so89482166b.0; Tue, 05 Mar 2024 04:15:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709640933; x=1710245733; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=JG3VSpSBId+LffdzAqb7pqYBWbcN1uLse2eKNRmus5E=; b=pkevkpGKzBqWRHEwmigNroyoSZQy0DS4ru68UxJJhuND2vh7NWcg5h9IudToeGth2o j9EaLo8qR8wiskgK3yOw3OsVoOJcL24unwlJT/5DeaiHczfztV1wd4kTfGGFGEYHrQh1 bo/eLXYgBM9VwqKs7LOATIMuV7Ib/0Sk9R2oyhkoIPkSwTdX0ostvk/yE2YEBzbN13Gx R9nXxE7mYpja+b2Hk66zNnm/rb2F1zlf/LMHuEXxmgL51mXHmf66NQ6w5wgfF6sa6E4x 8ojmVLKYABx6QoSGgrKrNn/1V3jnug9vkr80+iAmIib6mxCrxXcBlVAoDaxVBdxYafmn vXhg== X-Forwarded-Encrypted: i=1; AJvYcCWs9pBtAvHlyCC5pkfl5aVdEWzJnR7wxf8oGuD7LFNNiJXh48mcfABC83owp9CC9c/6OcpgGPnZAycBrpaPb85lF+Hzrm5pkQ8KYNEL X-Gm-Message-State: AOJu0YylXMaw6da+wnNuRqmghLAoU2P4zr7UGhsuaL13XQv/7oRXV6Wp SxsFRV8gNhrUj5qg7mY8krtfNiVZlsDFp4u9BgtHZpQNP7kPXsVM X-Google-Smtp-Source: AGHT+IFR3WGZuebyFFvq/51EnY9cTbsjkK/kx7Ilk++87zUVxhXQMBrOMecLr6eR2TSNRBaf4SPz1Q== X-Received: by 2002:a17:906:6954:b0:a45:8f10:50c6 with SMTP id c20-20020a170906695400b00a458f1050c6mr2209901ejs.57.1709640933320; Tue, 05 Mar 2024 04:15:33 -0800 (PST) Received: from localhost (fwdproxy-lla-120.fbsv.net. [2a03:2880:30ff:78::face:b00c]) by smtp.gmail.com with ESMTPSA id am19-20020a170906569300b00a44cb0bf11bsm4027184ejc.79.2024.03.05.04.15.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 04:15:32 -0800 (PST) From: Breno Leitao To: Pablo Neira Ayuso , Harald Welte , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, horms@kernel.org, dsahern@kernel.org, osmocom-net-gprs@lists.osmocom.org (open list:GTP (GPRS Tunneling Protocol)) Subject: [PATCH net-next 1/3] net: gtp: Leverage core stats allocator Date: Tue, 5 Mar 2024 04:15:21 -0800 Message-ID: <20240305121524.2254533-1-leitao@debian.org> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org With commit 34d21de99cea9 ("net: Move {l,t,d}stats allocation to core and convert veth & vrf"), stats allocation could be done on net core instead of in this driver. With this new approach, the driver doesn't have to bother with error handling (allocation failure checking, making sure free happens in the right spot, etc). This is core responsibility now. Remove the allocation in the gtp driver and leverage the network core allocation instead. Signed-off-by: Breno Leitao Acked-by: Pablo Neira Ayuso --- drivers/net/gtp.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c index 2b46b7398ade..facbfba5d77f 100644 --- a/drivers/net/gtp.c +++ b/drivers/net/gtp.c @@ -717,10 +717,6 @@ static int gtp_dev_init(struct net_device *dev) gtp->dev = dev; - dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); - if (!dev->tstats) - return -ENOMEM; - return 0; } @@ -729,7 +725,6 @@ static void gtp_dev_uninit(struct net_device *dev) struct gtp_dev *gtp = netdev_priv(dev); gtp_encap_disable(gtp); - free_percpu(dev->tstats); } static inline void gtp0_push_header(struct sk_buff *skb, struct pdp_ctx *pctx) @@ -970,6 +965,7 @@ static void gtp_link_setup(struct net_device *dev) dev->type = ARPHRD_NONE; dev->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST; + dev->pcpu_stat_type = NETDEV_PCPU_STAT_TSTATS; dev->priv_flags |= IFF_NO_QUEUE; dev->features |= NETIF_F_LLTX; netif_keep_dst(dev); From patchwork Tue Mar 5 12:15:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13582316 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D235B5A792; Tue, 5 Mar 2024 12:15:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709640938; cv=none; b=HRFPws1MFSPBUsMXiYg9sMPuuEsb9w15IgfekjV6OE+qe/eLP7OiZ5B3ss2E6ManfpGJM0gEnjqS4L7zRrFEmdrJnsEuLsfbub2yCZLy/ccbWenl+1kdX3bV+8skAm2+aQBEJqB1FM5qQ8WLPfj1NIxnNYBgYLHG9u7ylmv3mzw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709640938; c=relaxed/simple; bh=woWMYc5OgL+cBIbSw0Bp6OpF6hwqiIc1KvuQj/MhjT0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=G6b/hXtIl+bObCZBkOap+fd9dMnb7MQfsHCvxtu+m/hy36DQ+frr8pfSoox9mGe1cWnF5b3IcZHrBLu2g+EbD4VM8rwFCM8O2LD2YDVkZ6gqpuJod0h4lmA12b4znDwI9njCtIyWLed+X72MF+s01V111sj4EaEqrKFVyIYane8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.208.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-563bb51c36eso7247506a12.2; Tue, 05 Mar 2024 04:15:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709640935; x=1710245735; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=73oxC7fiTEx14ckkL7VJ6pLMLA9f6p7sprpT+joqmVc=; b=u97pXZfNqdZrVQzEVJKffvkxO3Gxyzq/50yTZThXDDI1gi7V9I0fB4klsXT19aqt2N vOaQIoKq5PwaCfoz+WRqkOG7nOwwVkUq8zMcdU+O0v2eboUqaRXmHarOlRI9WJGjHaKc 2ukCDuhNyDhdJvA23Zv7tDHJM+vpRQQ6GzT6CkP/MrGbE/IRHdTBq6hr78uQtDxFSDWU BZySVFPHUPAAMD5NJyyjg54l8KsOmK+EaHlI7RhGYz0Y7BfSMZ5gGF5a4MiBIuTJKltm nSb1gHRtFSSHat0sBQSvcNNdGGweo9DwbtuTsFIcr3UIa+qqRVv+Uqi3SELMQzzw5zUY +eiA== X-Forwarded-Encrypted: i=1; AJvYcCUzQpjz+HLm9sio43N2+MIwx4fpyBEcaBUkBFnDe2tzXQUv4dU8Ya/WvYDBHBrEr301PJ75Me3BgHkF9gxa9n6pPgafhqK4wczRO3og X-Gm-Message-State: AOJu0Yxt9/ROvuEC1Wz0cSq2WQEUv0owieXdsrD14xAPrV/0YEI7bcfB O6dNpzusVdItNifOtKnSiDXlKqNlMvx6YuDG78h0z2iK4HmBWGKw X-Google-Smtp-Source: AGHT+IEgZP/25f03fXOd6Z9uDpCifrB6YeqYPf/fSwLvjFuOevo4KNmPHtiLcHQMRiGqrIZxE03Bmw== X-Received: by 2002:a50:954c:0:b0:565:8339:5753 with SMTP id v12-20020a50954c000000b0056583395753mr6511550eda.40.1709640935115; Tue, 05 Mar 2024 04:15:35 -0800 (PST) Received: from localhost (fwdproxy-lla-005.fbsv.net. [2a03:2880:30ff:5::face:b00c]) by smtp.gmail.com with ESMTPSA id v3-20020aa7d9c3000000b0056629f5de88sm5707578eds.61.2024.03.05.04.15.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 04:15:34 -0800 (PST) From: Breno Leitao To: Pablo Neira Ayuso , Harald Welte , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, horms@kernel.org, dsahern@kernel.org, osmocom-net-gprs@lists.osmocom.org (open list:GTP (GPRS Tunneling Protocol)) Subject: [PATCH net-next 2/3] net: gtp: Remove generic .ndo_get_stats64 Date: Tue, 5 Mar 2024 04:15:22 -0800 Message-ID: <20240305121524.2254533-2-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240305121524.2254533-1-leitao@debian.org> References: <20240305121524.2254533-1-leitao@debian.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Commit 3e2f544dd8a33 ("net: get stats64 if device if driver is configured") moved the callback to dev_get_tstats64() to net core, so, unless the driver is doing some custom stats collection, it does not need to set .ndo_get_stats64. Since this driver is now relying in NETDEV_PCPU_STAT_TSTATS, then, it doesn't need to set the dev_get_tstats64() generic .ndo_get_stats64 function pointer. Signed-off-by: Breno Leitao Acked-by: Pablo Neira Ayuso --- drivers/net/gtp.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c index facbfba5d77f..a279f0cd1b4d 100644 --- a/drivers/net/gtp.c +++ b/drivers/net/gtp.c @@ -940,7 +940,6 @@ static const struct net_device_ops gtp_netdev_ops = { .ndo_init = gtp_dev_init, .ndo_uninit = gtp_dev_uninit, .ndo_start_xmit = gtp_dev_xmit, - .ndo_get_stats64 = dev_get_tstats64, }; static const struct device_type gtp_type = { From patchwork Tue Mar 5 12:15:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13582317 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A76435CDCE; Tue, 5 Mar 2024 12:15:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709640940; cv=none; b=UcUYVP6vWpSMeufg1YwFDZbSE1v/jx0GXx2FxiZ0LeNGBVnerSLM1V60S7085bQN4/EKYyzyBuwnwoFHxwwdnCcYtYSMHVA5yzW5SsnuznZdt/lj7U4Yow3uQyPOMLhRAMzz+golTdxZoRQclMBKETb4FUM7GtQSykYG9HL/1eo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709640940; c=relaxed/simple; bh=BbqzQ7FR84wGJYSQkkFifd7v2CBPk8tXqQd8kQ9d8zs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sMbcaWhURERLVWnIVDeVcrzEIZLd3Sotc2Psgxe+Y/8NioOo/R/hxVuMoxd0N5skk1RY+jjRuWEnmmskoKkE2Ntkd5Au5RzxJgBiA8KOx6yS894lO8TdycIetgRyfizMFmQ9I8e20NykCzZgsXsUWNAPm49adLo/d6+nEqNia9g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.167.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-513382f40e9so3944731e87.2; Tue, 05 Mar 2024 04:15:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709640937; x=1710245737; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PlRgBsvkdB1uk+pnCPMDoR/KGnekNC9DXpehVtGRALc=; b=s8216JggPEnr9p9Y0ToNwMHMXOVt6A1JGD45Mi1o4j6m+N9rYSV03LgFfvyzbwCmVG 2ExXXruENzxEwib+IouXF845EtezlLfazGNDf3GaVux6HYP9+Y+S8Kumez5h3b4ynGM6 0ZhXKQTkoDapV0/YxF5OgVkNXUTUUxS2rtLU5ZGgcvjDbNismQTYAMzCbmiYFjPsg05O kJdL/KD3DKoCVN+qEyJJbHu+HiudBs9f2Vpad2ggLmI6xjul0j2+ZRYDvl8eMIgBzZ3X 8Bq44yah+JTFr5bwbZwPnv3N94oL/sBR+2hYa87XNqBatr5hv7Kh+opiB/eRoEXWlmYe dPVQ== X-Forwarded-Encrypted: i=1; AJvYcCVYgIj+Qo/BzbAeiF3rUna9Q3HQsM3/hSc6oeWG3InFTJMFqTscvT+X28+5/quONm7kjRXbGQL3EYDw47JOs0ArW1gEkI+kBtN4qVMJ X-Gm-Message-State: AOJu0YwxswJCbCMFe2HFVvoSJQLf444S2HZnTTmZzZ8gBSrZWF35LU41 kwZsMQrBakMhrI+GsNa2JqBPiJbBt94K3WUz5jxOo8RfnGJlt3+J X-Google-Smtp-Source: AGHT+IEXK9I278PFM2NIiTH6L6oGJxrYG3KEfyvFvNNFUTa2taVG6i2Re3nVRx86yMtHAooJDKZ7FA== X-Received: by 2002:ac2:4186:0:b0:512:f59d:7612 with SMTP id z6-20020ac24186000000b00512f59d7612mr1122169lfh.57.1709640936735; Tue, 05 Mar 2024 04:15:36 -0800 (PST) Received: from localhost (fwdproxy-lla-009.fbsv.net. [2a03:2880:30ff:9::face:b00c]) by smtp.gmail.com with ESMTPSA id k3-20020a17090646c300b00a3fbca02e17sm5935394ejs.75.2024.03.05.04.15.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 04:15:36 -0800 (PST) From: Breno Leitao To: Pablo Neira Ayuso , Harald Welte , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, horms@kernel.org, dsahern@kernel.org, osmocom-net-gprs@lists.osmocom.org (open list:GTP (GPRS Tunneling Protocol)) Subject: [PATCH net-next 3/3] net: gtp: Move net_device assigned in setup Date: Tue, 5 Mar 2024 04:15:23 -0800 Message-ID: <20240305121524.2254533-3-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240305121524.2254533-1-leitao@debian.org> References: <20240305121524.2254533-1-leitao@debian.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Assign netdev to gtp->dev at setup time, so, we can get rid of gtp_dev_init() completely. Signed-off-by: Breno Leitao Acked-by: Pablo Neira Ayuso --- drivers/net/gtp.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c index a279f0cd1b4d..ba4704c2c640 100644 --- a/drivers/net/gtp.c +++ b/drivers/net/gtp.c @@ -711,15 +711,6 @@ static int gtp_encap_recv(struct sock *sk, struct sk_buff *skb) return ret; } -static int gtp_dev_init(struct net_device *dev) -{ - struct gtp_dev *gtp = netdev_priv(dev); - - gtp->dev = dev; - - return 0; -} - static void gtp_dev_uninit(struct net_device *dev) { struct gtp_dev *gtp = netdev_priv(dev); @@ -937,7 +928,6 @@ static netdev_tx_t gtp_dev_xmit(struct sk_buff *skb, struct net_device *dev) } static const struct net_device_ops gtp_netdev_ops = { - .ndo_init = gtp_dev_init, .ndo_uninit = gtp_dev_uninit, .ndo_start_xmit = gtp_dev_xmit, }; @@ -951,6 +941,7 @@ static void gtp_link_setup(struct net_device *dev) unsigned int max_gtp_header_len = sizeof(struct iphdr) + sizeof(struct udphdr) + sizeof(struct gtp0_header); + struct gtp_dev *gtp = netdev_priv(dev); dev->netdev_ops = >p_netdev_ops; dev->needs_free_netdev = true; @@ -970,6 +961,7 @@ static void gtp_link_setup(struct net_device *dev) netif_keep_dst(dev); dev->needed_headroom = LL_MAX_HEADER + max_gtp_header_len; + gtp->dev = dev; } static int gtp_hashtable_new(struct gtp_dev *gtp, int hsize);