From patchwork Tue Dec 20 22:20:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stanislav Fomichev X-Patchwork-Id: 13078224 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 844D1C3DA6E for ; Tue, 20 Dec 2022 22:23:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234328AbiLTWXG (ORCPT ); Tue, 20 Dec 2022 17:23:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234321AbiLTWWY (ORCPT ); Tue, 20 Dec 2022 17:22:24 -0500 Received: from mail-pl1-x64a.google.com (mail-pl1-x64a.google.com [IPv6:2607:f8b0:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2A531FCD0 for ; Tue, 20 Dec 2022 14:21:13 -0800 (PST) Received: by mail-pl1-x64a.google.com with SMTP id o18-20020a170902d4d200b00189d4c25568so10023441plg.13 for ; Tue, 20 Dec 2022 14:21:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=rfJO+GQYze9TOg5vw18ss4rmZmF2LBjdqaB1j+Nx9Ls=; b=QU5rXZY51IYDtIPXczKfRymujAQRVfDedJDPJkcGvEijVm6FuEUYqMxlAuZ12pL6CW 77vlD+T9su0alS4MyN1dVME5HLHAKa5YJOd/pYprasBYX6DHO+Ypo/gncdzjdgPsRSS2 BsQl81SFjSFHy+dLj/WYPCgJSpgU3nBddGV2TBVw2/QCgq15ogVrhqoRDmbNjsM2X/kN x1p2gCGxhUxkXBVsXtld3REegAQGAskmKEnMCkD7MDxKGZHb2e8CZAYowodzh02P4+Uj SW/dYye/TcT4ZZkLRN+7oNXeX8wyes3GukvtcSyD70D34+Tttsvs2gkOCK1+Vbo9r01s 4SnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=rfJO+GQYze9TOg5vw18ss4rmZmF2LBjdqaB1j+Nx9Ls=; b=tE2t2BP0774rtu/h6BxXEKrMkAParHu32Zsxdt0MY3EemqkW4VQBpwo11iSPc2FqpK wmrNza9GxEWsQXx6nEugtn4WmWeaPWFMc0GE3cBUzVqq3J4A/9oVLpfypODVg27LuGtU adJqqPjbK0S7gtjCMVeLfK/vA/Des1OULFGZ59XQkQ62zsBySlyZ1u1PIhlXsRf0mKNR ZtyYHH7lV8bG0PyBES9K9lm/iFaJ6jLVxRtgELk7wrPsRnr8Lgy7O80T1CkcjTwgpIgI 5yFYdzq32znjPoNUhVTSISohKaotYp5a3/fE201RxEg4me4nmHuB3Ea90y/xslTgJLYr yyxw== X-Gm-Message-State: ANoB5pmwWW3tfjtle9cRKAEfbNisTlv2MQzRh3CL0HTVgIzyqH7QiucB PtbmY/gG3gh2sD4Kz/e2ax34/pw= X-Google-Smtp-Source: AA0mqf71FV3cUaHj89bBiQjY0b5r796mRu/GfHEUXAkRixdUA4v/absSYPLS6h9WtMd/hBG2Kwqiuzk= X-Received: from sdf.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5935]) (user=sdf job=sendgmr) by 2002:a63:4420:0:b0:479:3eee:a727 with SMTP id r32-20020a634420000000b004793eeea727mr1699661pga.56.1671574870508; Tue, 20 Dec 2022 14:21:10 -0800 (PST) Date: Tue, 20 Dec 2022 14:20:40 -0800 In-Reply-To: <20221220222043.3348718-1-sdf@google.com> Mime-Version: 1.0 References: <20221220222043.3348718-1-sdf@google.com> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog Message-ID: <20221220222043.3348718-15-sdf@google.com> Subject: [PATCH bpf-next v5 14/17] xsk: Add cb area to struct xdp_buff_xsk From: Stanislav Fomichev To: bpf@vger.kernel.org Cc: 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, " =?utf-8?q?Toke_H=C3=B8iland-J=C3=B8rgensen?= " , David Ahern , Jakub Kicinski , Willem de Bruijn , Jesper Dangaard Brouer , Anatoly Burakov , Alexander Lobakin , Magnus Karlsson , Maryam Tahhan , xdp-hints@xdp-project.net, netdev@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net From: Toke Høiland-Jørgensen Add an area after the xdp_buff in struct xdp_buff_xsk that drivers can use to stash extra information to use in metadata kfuncs. The maximum size of 24 bytes means the full xdp_buff_xsk structure will take up exactly two cache lines (with the cb field spanning both). Also add a macro drivers can use to check their own wrapping structs against the available size. Cc: John Fastabend Cc: David Ahern Cc: Martin KaFai Lau Cc: Jakub Kicinski Cc: Willem de Bruijn Cc: Jesper Dangaard Brouer Cc: Anatoly Burakov Cc: Alexander Lobakin Cc: Magnus Karlsson Cc: Maryam Tahhan Cc: xdp-hints@xdp-project.net Cc: netdev@vger.kernel.org Suggested-by: Jakub Kicinski Signed-off-by: Toke Høiland-Jørgensen Signed-off-by: Stanislav Fomichev --- include/net/xsk_buff_pool.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/net/xsk_buff_pool.h b/include/net/xsk_buff_pool.h index f787c3f524b0..3e952e569418 100644 --- a/include/net/xsk_buff_pool.h +++ b/include/net/xsk_buff_pool.h @@ -19,8 +19,11 @@ struct xdp_sock; struct device; struct page; +#define XSK_PRIV_MAX 24 + struct xdp_buff_xsk { struct xdp_buff xdp; + u8 cb[XSK_PRIV_MAX]; dma_addr_t dma; dma_addr_t frame_dma; struct xsk_buff_pool *pool; @@ -28,6 +31,8 @@ struct xdp_buff_xsk { struct list_head free_list_node; }; +#define XSK_CHECK_PRIV_TYPE(t) BUILD_BUG_ON(sizeof(t) > offsetofend(struct xdp_buff_xsk, cb)) + struct xsk_dma_map { dma_addr_t *dma_pages; struct device *dev;