From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-x44a.google.com (mail-pf1-x44a.google.com [IPv6:2607:f8b0:4864:20::44a]) by mail.toke.dk (Postfix) with ESMTPS id 8DB8EA17E29 for ; Fri, 7 Jul 2023 21:30:27 +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=CR6BKcR7 Received: by mail-pf1-x44a.google.com with SMTP id d2e1a72fcca58-66eba523cd9so3085826b3a.2 for ; Fri, 07 Jul 2023 12:30:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1688758226; x=1691350226; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=D6eJsNbF+26Hlj3gojwwEfVn/Oe9YdnjjlvU7i1W0CU=; b=CR6BKcR7Wy2o07eut2Ft3PUgYRKMjrlupEts1sdVZegDw7Y2vBuhiB/6/TtRg4Y10v dF+ZmYEeeVDXsks9cWWilO2HwF4t3pMKZ+RYdonIqXVZqCvrVpLBcqQMW8tZyvHCgXBO OPP+VvR7fXPDnne/jIO+lYo1LaV14NdXxTDX3uoR1jnIL01L6AfQFG7qZPWypBh2kKWr Br6GyjpfbyMiWWIqmLxSepiidS77ECCeN8TzohrG1l5tEmdR+8p03mPrNspYO4UqResx tMAfj6lhP5tT1gzjlYg/VNwREhCgdp/DmWpcqTgG2vsalAWJ45pFwlUl9dhB+NPRZSJw r1Zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688758226; x=1691350226; 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=D6eJsNbF+26Hlj3gojwwEfVn/Oe9YdnjjlvU7i1W0CU=; b=HLWrCL4HeXF5DTzaHYBPOHthiZL+6ECj4h70xnhnvKnbLe74JT6WuTGxihZciEShoX Mk3Vnw0MpgCSGS3mNpienc0fqtF1MCl3SDl0pAMNCfoycUwzfuD7fSnXZ4+B2HOelOp4 kuZWhcTft3QdgM3fpCmvNOhQ3Nmk6Ysq+qrY5lIuOc29cHBTf0Wjm/C0A1daHOd52FbR fhsym2xvSm4WZ9NyPM5R+XhGqERbV/1+y78mx3hfSzeIh8QUvtygHV8/n4yycio80sLu nU3zXYcbJWu83TzAWlORm6TNPdotOe+X2ZwcYt7ECY77WRjHRE+kKELkcyf5AR1UkaUm +e+Q== X-Gm-Message-State: ABy/qLZZ0z7hirsxtH2v1MD7Ei5e09xhXWjhYVNTWlTnWIH1kkERIybw 7TOstd+d1IEVKG7cL2oz/Gs/9xo= X-Google-Smtp-Source: APBJJlGlPCsXSYtdOtBh5/L6+wNsA2GXrVg66+kTKWgIhr5kP0PSMj3CUf7R60wWUoAtPJsFFnWe6Wc= X-Received: from sdf.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5935]) (user=sdf job=sendgmr) by 2002:a05:6a00:3990:b0:666:e42c:d5ec with SMTP id fi16-20020a056a00399000b00666e42cd5ecmr7969481pfb.3.1688758225753; Fri, 07 Jul 2023 12:30:25 -0700 (PDT) Date: Fri, 7 Jul 2023 12:30:02 -0700 In-Reply-To: <20230707193006.1309662-1-sdf@google.com> Mime-Version: 1.0 References: <20230707193006.1309662-1-sdf@google.com> X-Mailer: git-send-email 2.41.0.255.g8b1d071c50-goog Message-ID: <20230707193006.1309662-11-sdf@google.com> From: Stanislav Fomichev To: bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Message-ID-Hash: YRVHO52Q5YVDM5UM2GT5T5DYF6SYLIMM X-Message-ID-Hash: YRVHO52Q5YVDM5UM2GT5T5DYF6SYLIMM X-MailFrom: 30WeoZAMKCW4ePRSaaSXQ.OaYjPb-TUZfejPb-bdaVQOf.ZQf@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] [RFC bpf-next v3 10/14] 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 687d83e707f8..c659713e2d43 100644 --- a/tools/testing/selftests/bpf/xsk.c +++ b/tools/testing/selftests/bpf/xsk.c @@ -47,6 +47,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 @@ -124,12 +128,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; } @@ -479,6 +485,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 8da8d557768b..57e0af403aa8 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.255.g8b1d071c50-goog