From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by mail.toke.dk (Postfix) with ESMTPS id 72C72A1FEFA for ; Wed, 9 Aug 2023 18:54:31 +0200 (CEST) Authentication-Results: mail.toke.dk; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20221208 header.b=sxOfDLfa Received: by mail-pg1-x54a.google.com with SMTP id 41be03b00d2f7-564fa3b49e1so13177a12.0 for ; Wed, 09 Aug 2023 09:54:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1691600070; x=1692204870; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=4XXAjWuOtm6YNmo2ZHsGe+OokqWo6K0W0zM94x/Po2M=; b=sxOfDLfapWQWB/hhXXyI8M5A9fLFZUOnb5mkg0ycH0YhS8gctaSQgIAkLLp56dA1iu gmDE4h8ggIXcpBihQme8xXhnqOCCPISUMIz+DZ4U908LSIwGLePs53+Hrv99YIOt8D8D Y1dYxX+LbAkq15P6aC7B9dhvyMFfDsiGdwp/O25y6o4zy/2KfN7vZCjjAp2dXyI2i4Sh LFijGTdhU0BFWtXg04KitMEGXq97Yn4h/FSQ/8KV5XmHy+wP3vEjmnRs4yi45/sxRfNS tbnRIlIXqCekM+J3N2JLV54saE47Q98yHomlZrDTVFogzR2w3laPKnJ8s0N2DvQEVJ7o e19A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691600070; x=1692204870; h=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=4XXAjWuOtm6YNmo2ZHsGe+OokqWo6K0W0zM94x/Po2M=; b=JeNQnkwNIZiBTZ1vftKaFbgItLgIPikkQTo7pHZaF3DBIuf7I6kIww9zdjUrGxVy1t f8uIUELTFaR2WZlyf7DC8CC1EwurLq/j9lk5LFWGTkrmQKNpTi4bxrzr4+SsUZcOiOQ3 JBNkP+1LTNmye5N0P30dej4B5Gb2KrYAO1tZcLq/1AFzvytc/we8qrRvtAjyjUKYX6C5 qSk9Z70WIxQVhADg5rRFcACsesHn91oUA5Vm1q6hzAu9IWCf5m76duu/zlOFrJnPYF+y /x7+espa7CUPdWdMpDM+pnMwMaZIAcVQnp/lE+iI8xZ9Wc9d+iaCVz5hlSwG8NpfWx4P f8eA== X-Gm-Message-State: AOJu0Yyz+ECQ6T+QOVQXYRn8cFXSgurLL1Q5QHTz2BLERUkQYjnjgIAO stqg4ack/VYALq3oAcVE1AOwjmw= X-Google-Smtp-Source: AGHT+IElNYWkuBNI6oxaQerIGrxmFs6Ms06U/Hm6h/zSlHg/lviZnI5o0kc4Aa59CV5yCmLs2JKNDgI= X-Received: from sdf.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5935]) (user=sdf job=sendgmr) by 2002:a63:714d:0:b0:564:480c:f405 with SMTP id b13-20020a63714d000000b00564480cf405mr293189pgn.1.1691600069926; Wed, 09 Aug 2023 09:54:29 -0700 (PDT) Date: Wed, 9 Aug 2023 09:54:14 -0700 In-Reply-To: <20230809165418.2831456-1-sdf@google.com> Mime-Version: 1.0 References: <20230809165418.2831456-1-sdf@google.com> X-Mailer: git-send-email 2.41.0.640.ga95def55d0-goog Message-ID: <20230809165418.2831456-6-sdf@google.com> From: Stanislav Fomichev To: bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Message-ID-Hash: 7KABYD7VFQ23MA4YVTA4Q2LCXRQ4GHNI X-Message-ID-Hash: 7KABYD7VFQ23MA4YVTA4Q2LCXRQ4GHNI X-MailFrom: 3xcTTZAMKCco8tvw44w1u.s42Dt5-xy398Dt5-574zus9.3u9@flex--sdf.bounces.google.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: 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, kuba@kernel.org, toke@kernel.org, willemb@google.com, dsahern@kernel.org, magnus.karlsson@intel.com, bjorn@kernel.org, maciej.fijalkowski@intel.com, hawk@kernel.org, netdev@vger.kernel.org, xdp-hints@xdp-project.net X-Mailman-Version: 3.3.8 Precedence: list Subject: [xdp-hints] [PATCH bpf-next 5/9] selftests/xsk: Support XDP_TX_METADATA_LEN List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Add new config field and call setsockopt. Signed-off-by: Stanislav Fomichev --- tools/testing/selftests/bpf/xsk.c | 17 +++++++++++++++++ tools/testing/selftests/bpf/xsk.h | 1 + 2 files changed, 18 insertions(+) diff --git a/tools/testing/selftests/bpf/xsk.c b/tools/testing/selftests/bpf/xsk.c index d9fb2b730a2c..cb7e48f24289 100644 --- a/tools/testing/selftests/bpf/xsk.c +++ b/tools/testing/selftests/bpf/xsk.c @@ -49,6 +49,10 @@ #define PF_XDP AF_XDP #endif +#ifndef XDP_TX_METADATA_LEN +#define XDP_TX_METADATA_LEN 9 +#endif + #define pr_warn(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__) #define XSKMAP_SIZE 1 @@ -132,12 +136,14 @@ static int xsk_set_xdp_socket_config(struct xsk_socket_config *cfg, cfg->rx_size = XSK_RING_CONS__DEFAULT_NUM_DESCS; cfg->tx_size = XSK_RING_PROD__DEFAULT_NUM_DESCS; cfg->bind_flags = 0; + cfg->tx_metadata_len = 0; return 0; } cfg->rx_size = usr_cfg->rx_size; cfg->tx_size = usr_cfg->tx_size; cfg->bind_flags = usr_cfg->bind_flags; + cfg->tx_metadata_len = usr_cfg->tx_metadata_len; return 0; } @@ -613,6 +619,17 @@ int xsk_socket__create_shared(struct xsk_socket **xsk_ptr, umem->tx_ring_setup_done = true; } + if (xsk->config.tx_metadata_len) { + int optval = xsk->config.tx_metadata_len; + + err = setsockopt(xsk->fd, SOL_XDP, XDP_TX_METADATA_LEN, + &optval, sizeof(optval)); + if (err) { + err = -errno; + goto out_put_ctx; + } + } + err = xsk_get_mmap_offsets(xsk->fd, &off); if (err) { err = -errno; diff --git a/tools/testing/selftests/bpf/xsk.h b/tools/testing/selftests/bpf/xsk.h index d93200fdaa8d..325fe0c83e5d 100644 --- a/tools/testing/selftests/bpf/xsk.h +++ b/tools/testing/selftests/bpf/xsk.h @@ -212,6 +212,7 @@ struct xsk_socket_config { __u32 rx_size; __u32 tx_size; __u16 bind_flags; + __u8 tx_metadata_len; }; /* Set config to NULL to get the default configuration. */ -- 2.41.0.640.ga95def55d0-goog