Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp56505rwl; Thu, 30 Mar 2023 12:05:18 -0700 (PDT) X-Google-Smtp-Source: AKy350bAJt9I1n/njJxyVyisBVQ+6cl4LVxSGQj3K0Ctpi54WAXYqB8Of/qj04jfryHuIieLnlY7 X-Received: by 2002:a17:906:101c:b0:929:b101:937d with SMTP id 28-20020a170906101c00b00929b101937dmr2843709ejm.1.1680203118454; Thu, 30 Mar 2023 12:05:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680203118; cv=none; d=google.com; s=arc-20160816; b=eKjUf2T51+W8or7U02XO4fHoAcgGONq30L7iFmuW55BkInqrUkTpCbp4lEdKXvHv9a rUOnvetBV/m8c4hbp2/j9YlV6AFj0ft5Alr90ayOr/aK2ExwaY6N0pIuxhCJR8y9kjVk jN4kjk0oZb/aqdDgDBeDZ/G+u8DHrqCZGVV8MgFBF4KhRF2PxOJLq/bE3Zk3VU+OmfEl Li7d91hplVRFFluuTzELbR1PkYK8aj4AOw6XC7l5wJyacvNGudtzfdyFjW3NoM2Fp8Dc +2Sal+coBQIiwoYEqPRKrYb8XJ3zb0vKCThfrTnVzhhfcbVreJMzyAxVJni3lq4OUkh+ f5cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=p2UKzHLw5AMRHbJxUqeu6Kh29H/LxajcGBLc6kBn8NM=; b=IVzB2sToIl5VNaMSpMOAYeer/5B/cfGCbbmKJ8PAk5AnLJLH1kSauuT0LlxDgZRsPv +olrGAwQ2hZ1KnEOLpDGvVPVIiUrNa0095bepMJ9PxSES2UbRmMxPUn5QGa3CVHADbWc aNJcxm6xjP9T6bLfetKoEAY/P5IBlGub1+Fy3ORcjA6564DpGwb5GG9hJLbPC66tAW/v 8rZ0jXjTNjsoo+nr4dBAv/8uBwYEHIbanIwEQXYiy8y+Q/vIEkn3PdZoG67ErY1IxkYD 9mxNpYu9RT8Tu+66lS//d7fKEzDghclwW8QVkDyTFVwyjb4bdmaq9ukG+OAh9dvZ1oZk TwYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=jfxxG+wl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id la7-20020a170907780700b0093defbd6298si192568ejc.1055.2023.03.30.12.04.27; Thu, 30 Mar 2023 12:05:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=jfxxG+wl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231845AbjC3TDD (ORCPT + 99 others); Thu, 30 Mar 2023 15:03:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231838AbjC3TDB (ORCPT ); Thu, 30 Mar 2023 15:03:01 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D01901710 for ; Thu, 30 Mar 2023 12:02:55 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id c4so2162161pjs.4 for ; Thu, 30 Mar 2023 12:02:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680202975; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=p2UKzHLw5AMRHbJxUqeu6Kh29H/LxajcGBLc6kBn8NM=; b=jfxxG+wlfnmoC+ExMU9oSM4vowDpE80ayaaX0O2aBGqC2elIvYflpzHBV9g0BvsEZY xy6wYhpi53/pArSydRtmoRVAkpJ47+6HOoJ/ys8DqhLR0XEPWl1geCfVLPnO86XM/QRs 5M5lmSeM47SYVWpnHWtSjh92WtSPWEMrmBsN0ndbnr4svt5eEX/U9eifrPjCFUjKDWxF 6VgrxjuOvQCwWy7y7Gx4PeORHJ+Umqiq9RGATMWBwQNFyL5cTxzzB86fQGpO0r+Bf6Lx E6Jkc/UAy5cdsW4StBgbk+kOUz91yWbobl/7E3Nh9H7TljwvXrNPn+Bvi2+tZGoOavcs 9qkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680202975; h=content-transfer-encoding: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=p2UKzHLw5AMRHbJxUqeu6Kh29H/LxajcGBLc6kBn8NM=; b=oa+bSp8f+gCH5dAh8C/uMSRRSWmUpgkn/gwer+VVWY+hDaNbWKGk+96R9+3Er4/RW4 2icM+E2XHTZAi3PzdM38YQV4wONmrntAUmUxM1TY5LM0ivapJ7eyiXFt/mkDB/YvOb57 te8lCF1rm+RYrJNJr5i16f9Fq68iY6PoUUKjC4ZrM6QAHiKVGBjQ/CKDjzL3fJpVZ6KX P+oIUJfwNbZKz1LLk85cXnSyE8/ToZMZzSy/1W4DB55ocONVx1i0LnIiTKu5b84FkuJG CDwlvajG6KFr2/lbBoemxiPq6HYQbHrYRZX9qwbEuV6l+XceV3q2dLhC0UR4zm578qPS nZEw== X-Gm-Message-State: AAQBX9fERevZBJy2J4S+8pvERNehqbMH60kOdi+sIwUItwYAoxHAtWTl Cz7QdAY54c1YioaDZpt/bOhZ7RYzkQi9PRLA82Voiw== X-Received: by 2002:a17:902:7b89:b0:19f:2c5a:5786 with SMTP id w9-20020a1709027b8900b0019f2c5a5786mr8632202pll.8.1680202974843; Thu, 30 Mar 2023 12:02:54 -0700 (PDT) MIME-Version: 1.0 References: <168019602958.3557870.9960387532660882277.stgit@firesoul> <168019606574.3557870.15629824904085210321.stgit@firesoul> <04256caf-aa28-7e0a-59b1-ecf2b237c96f@redhat.com> In-Reply-To: <04256caf-aa28-7e0a-59b1-ecf2b237c96f@redhat.com> From: Stanislav Fomichev Date: Thu, 30 Mar 2023 12:02:43 -0700 Message-ID: Subject: Re: [PATCH bpf RFC-V3 1/5] xdp: rss hash types representation To: Jesper Dangaard Brouer Cc: brouer@redhat.com, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, martin.lau@kernel.org, ast@kernel.org, daniel@iogearbox.net, alexandr.lobakin@intel.com, larysa.zaremba@intel.com, xdp-hints@xdp-project.net, anthony.l.nguyen@intel.com, yoong.siang.song@intel.com, boon.leong.ong@intel.com, intel-wired-lan@lists.osuosl.org, pabeni@redhat.com, jesse.brandeburg@intel.com, kuba@kernel.org, edumazet@google.com, john.fastabend@gmail.com, hawk@kernel.org, davem@davemloft.net Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-15.7 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,ENV_AND_HDR_SPF_MATCH, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 30, 2023 at 11:56=E2=80=AFAM Jesper Dangaard Brouer wrote: > > > On 30/03/2023 20.35, Stanislav Fomichev wrote: > > On 03/30, Jesper Dangaard Brouer wrote: > >> The RSS hash type specifies what portion of packet data NIC hardware u= sed > >> when calculating RSS hash value. The RSS types are focused on Internet > >> traffic protocols at OSI layers L3 and L4. L2 (e.g. ARP) often get has= h > >> value zero and no RSS type. For L3 focused on IPv4 vs. IPv6, and L4 > >> primarily TCP vs UDP, but some hardware supports SCTP. > > > >> Hardware RSS types are differently encoded for each hardware NIC. Most > >> hardware represent RSS hash type as a number. Determining L3 vs L4 oft= en > >> requires a mapping table as there often isn't a pattern or sorting > >> according to ISO layer. > > > >> The patch introduce a XDP RSS hash type (enum xdp_rss_hash_type) that > >> contain combinations to be used by drivers, which gets build up with b= its > >> from enum xdp_rss_type_bits. Both enum xdp_rss_type_bits and > >> xdp_rss_hash_type get exposed to BPF via BTF, and it is up to the > >> BPF-programmer to match using these defines. > > > >> This proposal change the kfunc API bpf_xdp_metadata_rx_hash() adding > >> a pointer value argument for provide the RSS hash type. > > > >> Signed-off-by: Jesper Dangaard Brouer > >> --- > >> include/linux/netdevice.h | 3 ++- > >> include/net/xdp.h | 46 +++++++++++++++++++++++++++++++++++= ++++++++++ > >> net/core/xdp.c | 10 +++++++++- > >> 3 files changed, 57 insertions(+), 2 deletions(-) > > > > [...] > >> diff --git a/net/core/xdp.c b/net/core/xdp.c > >> index 528d4b37983d..38d2dee16b47 100644 > >> --- a/net/core/xdp.c > >> +++ b/net/core/xdp.c > >> @@ -734,14 +734,22 @@ __bpf_kfunc int > >> bpf_xdp_metadata_rx_timestamp(const struct xdp_md *ctx, u64 *tim > >> * bpf_xdp_metadata_rx_hash - Read XDP frame RX hash. > >> * @ctx: XDP context pointer. > >> * @hash: Return value pointer. > >> + * @rss_type: Return value pointer for RSS type. > >> + * > >> + * The RSS hash type (@rss_type) specifies what portion of packet hea= ders NIC > >> + * hardware were used when calculating RSS hash value. The type comb= inations > >> + * are defined via &enum xdp_rss_hash_type and individual bits can be= decoded > >> + * via &enum xdp_rss_type_bits. > >> * > >> * Return: > >> * * Returns 0 on success or ``-errno`` on error. > >> * * ``-EOPNOTSUPP`` : means device driver doesn't implement kfunc > >> * * ``-ENODATA`` : means no RX-hash available for this frame > >> */ > >> -__bpf_kfunc int bpf_xdp_metadata_rx_hash(const struct xdp_md *ctx, > >> u32 *hash) > >> +__bpf_kfunc int bpf_xdp_metadata_rx_hash(const struct xdp_md *ctx, > >> u32 *hash, > >> + enum xdp_rss_hash_type *rss_type) > >> { > > > > [..] > > > >> + BTF_TYPE_EMIT(enum xdp_rss_type_bits); > > > > nit: Do we still need this with an extra argument? > > > > Yes, unfortunately (compiler optimizes out enum xdp_rss_type_bits). > Do notice the difference xdp_rss_type_bits vs xdp_rss_hash_type. > We don't need it for "xdp_rss_hash_type" but need it for > "xdp_rss_type_bits". Ah, I missed that. Then why not expose xdp_rss_type_bits? Keep xdp_rss_hash_type for internal drivers' tables, and export the enum with the bits? > --Jesper >