From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-x736.google.com (mail-qk1-x736.google.com [IPv6:2607:f8b0:4864:20::736]) by mail.toke.dk (Postfix) with ESMTPS id 5A7BFA4670F for ; Tue, 12 Dec 2023 14:53:01 +0100 (CET) Authentication-Results: mail.toke.dk; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=E3T5xL8V Received: by mail-qk1-x736.google.com with SMTP id af79cd13be357-77f68824694so9154785a.0 for ; Tue, 12 Dec 2023 05:53:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702389120; x=1702993920; darn=xdp-project.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=2DSj9HArsmUWrWsZkgJ2wfKDN+jx83el0yD5kZAUyJ0=; b=E3T5xL8Vn2GCl1tKuLVZLvNEKucDlQNwtZxV+ns3lostkqIbQG/bZLd25GhoRewsL9 4sQteQbrCl+P8PV2SoB1+piuJXGExGozkko9JQfYG8K/83EK6Kws0ht5RgknFURRhbWK RQMUZDoBv7f/H+Cd2Ok7Vs8pg8VNNUIg5xNv/rhr+TRdD6bRdpr3K+HoLPPNM8RsvI4C 4su4HZ4DZYOHwRITtslbmmcGq+NslEtaK0pyEull/357Dd0RxtZv5D9FP2wNv8ZpNTbh ZWOscO1F/jw5PW5BQ7cSiIqrhdxL9qtAPAn3VBzPhydt/rruV099aCDa7dWC0JhGeB1+ R15Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702389120; x=1702993920; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=2DSj9HArsmUWrWsZkgJ2wfKDN+jx83el0yD5kZAUyJ0=; b=XxqQSXFWH4wP4NhC8dzBOOaDgmtplVaNNlPs5N1QuXGfCNFjwrlVLhdnSpYfUyR/qS QxQrJ3zm5Mo3dEJCM78FrJ0iGrX8RIUohPqP2N1g1dw5A43Q+T8MSEvgOSYaQkRW4kEQ L4eAzZRIQH0s/cKnxJzAT6Z7hGsaJivtfgP4zj4m8WXsD7J4ShwrThyEwLnLva+NyGZB 9FI0nPTYIMFYTgSz5wPiBdhHlP9eRdqebJUT3eY88owsFnO3yoD4bVLswh8S9GCNsLdq 0STq0hDd0LIUQdS92Al372+c/tuMwjkiowHEEE+qO/W0NqnUBLz9bd7ePDRn7RcxPK4p ykWA== X-Gm-Message-State: AOJu0YzvMmniMmzHuW+LKzyKCktTGYOijdk6/tRg9MzOxFbzGIceHn5l IHhp8RaKLYKe93kjAh23eCRNlAFvWsSBn4idbYk= X-Google-Smtp-Source: AGHT+IH+J0MYsp+6RBByiQFZbj6C5PIVoIcOqafzQfoUnut0QGDo3i1II59DP55FlY3tXJSLxC4pCpZkVSo6mKMfejA= X-Received: by 2002:ad4:4bd0:0:b0:67a:8957:64b0 with SMTP id l16-20020ad44bd0000000b0067a895764b0mr11006405qvw.3.1702389119910; Tue, 12 Dec 2023 05:51:59 -0800 (PST) MIME-Version: 1.0 References: <20231205210847.28460-1-larysa.zaremba@intel.com> <20231205210847.28460-8-larysa.zaremba@intel.com> In-Reply-To: <20231205210847.28460-8-larysa.zaremba@intel.com> From: Magnus Karlsson Date: Tue, 12 Dec 2023 14:51:48 +0100 Message-ID: To: Larysa Zaremba Content-Type: text/plain; charset="UTF-8" Message-ID-Hash: ASDEAN7CUI37A4GK5CDKKVSOGYI4SKGO X-Message-ID-Hash: ASDEAN7CUI37A4GK5CDKKVSOGYI4SKGO X-MailFrom: magnus.karlsson@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: bpf@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, song@kernel.org, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, David Ahern , Jakub Kicinski , Willem de Bruijn , Jesper Dangaard Brouer , Anatoly Burakov , Alexander Lobakin , Maryam Tahhan , xdp-hints@xdp-project.net, netdev@vger.kernel.org, Willem de Bruijn , Alexei Starovoitov , Tariq Toukan , Saeed Mahameed , Maciej Fijalkowski X-Mailman-Version: 3.3.9 Precedence: list Subject: [xdp-hints] Re: [PATCH bpf-next v8 07/18] xsk: add functions to fill control buffer List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Tue, 5 Dec 2023 at 22:11, Larysa Zaremba wrote: > > From: Maciej Fijalkowski > > Commit 94ecc5ca4dbf ("xsk: Add cb area to struct xdp_buff_xsk") has added > a buffer for custom data to xdp_buff_xsk. Particularly, this memory is used > for data, consumed by XDP hints kfuncs. It does not always change on > a per-packet basis and some parts can be set for example, at the same time > as RX queue info. > > Add functions to fill all cbs in xsk_buff_pool with the same metadata. Thanks Larysa and Maciej. Acked-by: Magnus Karlsson > Signed-off-by: Maciej Fijalkowski > Signed-off-by: Larysa Zaremba > --- > include/net/xdp_sock_drv.h | 17 +++++++++++++++++ > include/net/xsk_buff_pool.h | 2 ++ > net/xdp/xsk_buff_pool.c | 12 ++++++++++++ > 3 files changed, 31 insertions(+) > > diff --git a/include/net/xdp_sock_drv.h b/include/net/xdp_sock_drv.h > index 81e02de3f453..b62bb8525a5f 100644 > --- a/include/net/xdp_sock_drv.h > +++ b/include/net/xdp_sock_drv.h > @@ -14,6 +14,12 @@ > > #ifdef CONFIG_XDP_SOCKETS > > +struct xsk_cb_desc { > + void *src; > + u8 off; > + u8 bytes; > +}; > + > void xsk_tx_completed(struct xsk_buff_pool *pool, u32 nb_entries); > bool xsk_tx_peek_desc(struct xsk_buff_pool *pool, struct xdp_desc *desc); > u32 xsk_tx_peek_release_desc_batch(struct xsk_buff_pool *pool, u32 max); > @@ -47,6 +53,12 @@ static inline void xsk_pool_set_rxq_info(struct xsk_buff_pool *pool, > xp_set_rxq_info(pool, rxq); > } > > +static inline void xsk_pool_fill_cb(struct xsk_buff_pool *pool, > + struct xsk_cb_desc *desc) > +{ > + xp_fill_cb(pool, desc); > +} > + > static inline unsigned int xsk_pool_get_napi_id(struct xsk_buff_pool *pool) > { > #ifdef CONFIG_NET_RX_BUSY_POLL > @@ -274,6 +286,11 @@ static inline void xsk_pool_set_rxq_info(struct xsk_buff_pool *pool, > { > } > > +static inline void xsk_pool_fill_cb(struct xsk_buff_pool *pool, > + struct xsk_cb_desc *desc) > +{ > +} > + > static inline unsigned int xsk_pool_get_napi_id(struct xsk_buff_pool *pool) > { > return 0; > diff --git a/include/net/xsk_buff_pool.h b/include/net/xsk_buff_pool.h > index 8d48d37ab7c0..99dd7376df6a 100644 > --- a/include/net/xsk_buff_pool.h > +++ b/include/net/xsk_buff_pool.h > @@ -12,6 +12,7 @@ > > struct xsk_buff_pool; > struct xdp_rxq_info; > +struct xsk_cb_desc; > struct xsk_queue; > struct xdp_desc; > struct xdp_umem; > @@ -135,6 +136,7 @@ static inline void xp_init_xskb_dma(struct xdp_buff_xsk *xskb, struct xsk_buff_p > > /* AF_XDP ZC drivers, via xdp_sock_buff.h */ > void xp_set_rxq_info(struct xsk_buff_pool *pool, struct xdp_rxq_info *rxq); > +void xp_fill_cb(struct xsk_buff_pool *pool, struct xsk_cb_desc *desc); > int xp_dma_map(struct xsk_buff_pool *pool, struct device *dev, > unsigned long attrs, struct page **pages, u32 nr_pages); > void xp_dma_unmap(struct xsk_buff_pool *pool, unsigned long attrs); > diff --git a/net/xdp/xsk_buff_pool.c b/net/xdp/xsk_buff_pool.c > index 4f6f538a5462..28711cc44ced 100644 > --- a/net/xdp/xsk_buff_pool.c > +++ b/net/xdp/xsk_buff_pool.c > @@ -125,6 +125,18 @@ void xp_set_rxq_info(struct xsk_buff_pool *pool, struct xdp_rxq_info *rxq) > } > EXPORT_SYMBOL(xp_set_rxq_info); > > +void xp_fill_cb(struct xsk_buff_pool *pool, struct xsk_cb_desc *desc) > +{ > + u32 i; > + > + for (i = 0; i < pool->heads_cnt; i++) { > + struct xdp_buff_xsk *xskb = &pool->heads[i]; > + > + memcpy(xskb->cb + desc->off, desc->src, desc->bytes); > + } > +} > +EXPORT_SYMBOL(xp_fill_cb); > + > static void xp_disable_drv_zc(struct xsk_buff_pool *pool) > { > struct netdev_bpf bpf; > -- > 2.41.0 >