Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp1184441rdb; Fri, 22 Dec 2023 19:01:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IFiSsxUGKFoQyp5oP6P2nB9c9bYHxd5xnQrEVKB1+3TEZuTnUFMnEqtv+mz/bYNsWyQES0v X-Received: by 2002:a05:620a:1138:b0:781:33e3:ec1b with SMTP id p24-20020a05620a113800b0078133e3ec1bmr1485127qkk.18.1703300518348; Fri, 22 Dec 2023 19:01:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703300518; cv=none; d=google.com; s=arc-20160816; b=0aWeIKJqWwJL4/YEgXdm0cVloyijdjfoPAoIOKYaCrs/sAjUb6IVTvvySR7Dl8ZNTj 8KGoCjYmHITBRh+L/rqfRLmPGtw01g+abUgbKvjyjeIKhxavykD6DflmYYaF67nfOylb qksvaxMSR8s7y6agthJ5u9BP+enlPEjGcVRwU9+WOd2zgyiwir+ut3LSHPmYUu4kzjij p59n0TkPo2IMgEqlYz9UtvQdcnqbs289OXSFNYhzhGzM8NpXzFq/rT0EEs1JeMcSlHUk xhYtuHhFUsrlClP7obOAUCmLmoXqN3H/GulJVLcnreGgjSd/JTmOzEUB70UL+9DJ/gmA /Ndw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=0+iVMU6cArgB6fiYKr2wvRDL9vTvfJPoXAVmAOSVIwU=; fh=J3H3jkZRTdH/CD0R7uXO8r43FYFiJ1FqB2ouoqeBxmQ=; b=fbpsDsM+Tn6ZKua3VgnJBeoh1grRK+i97Tj35seGtUG2QkA00joWXWXM/lenX3wx1T 48UL63iPyb3pWDgNOSJWmEI/TkU2ataB64J54UWyzyXPGkH4DQAyPa1O2KnsGxImrQOv 8GXDEJKue62ejkymA2ONsQyiOeYlTw7A910Iv7G/NXlZeL2Ci+ozFJujwFbaZFd2Dxxr jLuR21i9bDumigGPn9lbMRSFAXfKlBxi6IVMjm++I8zwjIDQ00LaOMUceSNfdVBstXz0 PC4Kv5+gslQhbuqt6myfAvEfXiJG073kxTYwHJNDHNTpo2x4xSoydwauDHCHW5na1vM5 H3GQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FzYVt7fY; spf=pass (google.com: domain of linux-kernel+bounces-10226-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10226-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id q11-20020a05620a024b00b007811c90b7fbsi5070769qkn.587.2023.12.22.19.01.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 19:01:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10226-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FzYVt7fY; spf=pass (google.com: domain of linux-kernel+bounces-10226-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10226-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 1DC261C229E2 for ; Sat, 23 Dec 2023 03:01:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7F138134DD; Sat, 23 Dec 2023 02:58:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="FzYVt7fY" X-Original-To: linux-kernel@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C9DC1401A; Sat, 23 Dec 2023 02:58:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1703300323; x=1734836323; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XDKZ7I8YXkzL6jtWwhlWlUnbadwUogykSHePFi5AJXo=; b=FzYVt7fYs4AIhFeOmCHkDLB7PPeHpZbK86k0pIJdeZHUNXRGd0EA/gjs lESqUWvAYe0PNXZhdWfOci7KdN/ewLMRRbq8NXdIhVwg0+5irZhWw4m8D VqKpWMpLPNwq/piX0hekRbgmYoFkluI2zOXcFdwmgrEAGlAFHA/O86vDq nJvWgLF9PeAWClUGJgtym2Cw5QMbyBXbXhSloaOilui6vziw/PXsRvQCW wa11rCCGtClwsh4iVqVyOszTISH4MzcRKf8VBxK0lrjJk491TU1O8J7RI G35MGyWqhMpMMs9ipUEeYn7OGSwiWFaMx7rANpCl67pQzmyhGItJFHLoJ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10932"; a="386610849" X-IronPort-AV: E=Sophos;i="6.04,298,1695711600"; d="scan'208";a="386610849" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Dec 2023 18:58:43 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.04,298,1695711600"; d="scan'208";a="25537480" Received: from newjersey.igk.intel.com ([10.102.20.203]) by orviesa001.jf.intel.com with ESMTP; 22 Dec 2023 18:58:39 -0800 From: Alexander Lobakin To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Alexander Lobakin , Maciej Fijalkowski , Michal Kubiak , Larysa Zaremba , Alexei Starovoitov , Daniel Borkmann , Willem de Bruijn , intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC net-next 10/34] xdp: constify read-only arguments of some static inline helpers Date: Sat, 23 Dec 2023 03:55:30 +0100 Message-ID: <20231223025554.2316836-11-aleksander.lobakin@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231223025554.2316836-1-aleksander.lobakin@intel.com> References: <20231223025554.2316836-1-aleksander.lobakin@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Lots of read-only helpers for &xdp_buff and &xdp_frame, such as getting the frame length, skb_shared_info etc., don't have their arguments marked with `const` for no reason. Add the missing annotations to leave less place for mistakes and more for optimization. Signed-off-by: Alexander Lobakin --- include/net/xdp.h | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/include/net/xdp.h b/include/net/xdp.h index e6770dd40c91..197808df1ee1 100644 --- a/include/net/xdp.h +++ b/include/net/xdp.h @@ -88,7 +88,7 @@ struct xdp_buff { u32 flags; /* supported values defined in xdp_buff_flags */ }; -static __always_inline bool xdp_buff_has_frags(struct xdp_buff *xdp) +static __always_inline bool xdp_buff_has_frags(const struct xdp_buff *xdp) { return !!(xdp->flags & XDP_FLAGS_HAS_FRAGS); } @@ -103,7 +103,8 @@ static __always_inline void xdp_buff_clear_frags_flag(struct xdp_buff *xdp) xdp->flags &= ~XDP_FLAGS_HAS_FRAGS; } -static __always_inline bool xdp_buff_is_frag_pfmemalloc(struct xdp_buff *xdp) +static __always_inline bool +xdp_buff_is_frag_pfmemalloc(const struct xdp_buff *xdp) { return !!(xdp->flags & XDP_FLAGS_FRAGS_PF_MEMALLOC); } @@ -144,15 +145,16 @@ xdp_prepare_buff(struct xdp_buff *xdp, unsigned char *hard_start, SKB_DATA_ALIGN(sizeof(struct skb_shared_info))) static inline struct skb_shared_info * -xdp_get_shared_info_from_buff(struct xdp_buff *xdp) +xdp_get_shared_info_from_buff(const struct xdp_buff *xdp) { return (struct skb_shared_info *)xdp_data_hard_end(xdp); } -static __always_inline unsigned int xdp_get_buff_len(struct xdp_buff *xdp) +static __always_inline unsigned int +xdp_get_buff_len(const struct xdp_buff *xdp) { unsigned int len = xdp->data_end - xdp->data; - struct skb_shared_info *sinfo; + const struct skb_shared_info *sinfo; if (likely(!xdp_buff_has_frags(xdp))) goto out; @@ -177,12 +179,13 @@ struct xdp_frame { u32 flags; /* supported values defined in xdp_buff_flags */ }; -static __always_inline bool xdp_frame_has_frags(struct xdp_frame *frame) +static __always_inline bool xdp_frame_has_frags(const struct xdp_frame *frame) { return !!(frame->flags & XDP_FLAGS_HAS_FRAGS); } -static __always_inline bool xdp_frame_is_frag_pfmemalloc(struct xdp_frame *frame) +static __always_inline bool +xdp_frame_is_frag_pfmemalloc(const struct xdp_frame *frame) { return !!(frame->flags & XDP_FLAGS_FRAGS_PF_MEMALLOC); } @@ -201,7 +204,7 @@ static __always_inline void xdp_frame_bulk_init(struct xdp_frame_bulk *bq) } static inline struct skb_shared_info * -xdp_get_shared_info_from_frame(struct xdp_frame *frame) +xdp_get_shared_info_from_frame(const struct xdp_frame *frame) { void *data_hard_start = frame->data - frame->headroom - sizeof(*frame); @@ -249,7 +252,8 @@ int xdp_alloc_skb_bulk(void **skbs, int n_skb, gfp_t gfp); struct xdp_frame *xdpf_clone(struct xdp_frame *xdpf); static inline -void xdp_convert_frame_to_buff(struct xdp_frame *frame, struct xdp_buff *xdp) +void xdp_convert_frame_to_buff(const struct xdp_frame *frame, + struct xdp_buff *xdp) { xdp->data_hard_start = frame->data - frame->headroom - sizeof(*frame); xdp->data = frame->data; @@ -260,7 +264,7 @@ void xdp_convert_frame_to_buff(struct xdp_frame *frame, struct xdp_buff *xdp) } static inline -int xdp_update_frame_from_buff(struct xdp_buff *xdp, +int xdp_update_frame_from_buff(const struct xdp_buff *xdp, struct xdp_frame *xdp_frame) { int metasize, headroom; @@ -317,9 +321,10 @@ void xdp_flush_frame_bulk(struct xdp_frame_bulk *bq); void xdp_return_frame_bulk(struct xdp_frame *xdpf, struct xdp_frame_bulk *bq); -static __always_inline unsigned int xdp_get_frame_len(struct xdp_frame *xdpf) +static __always_inline unsigned int +xdp_get_frame_len(const struct xdp_frame *xdpf) { - struct skb_shared_info *sinfo; + const struct skb_shared_info *sinfo; unsigned int len = xdpf->len; if (likely(!xdp_frame_has_frags(xdpf))) -- 2.43.0