From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by mail.toke.dk (Postfix) with ESMTPS id 1293D99E0E7 for ; Thu, 8 Sep 2022 10:06:20 +0200 (CEST) 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=20210112 header.b=pYClB6FS Received: by mail-pf1-x432.google.com with SMTP id c198so7265416pfc.13 for ; Thu, 08 Sep 2022 01:06:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=srKp0qF1Diby5Qs9xfv49IWriKBlWuLXT5Vhw8RgQwA=; b=pYClB6FS9fkQJ5dt0Gt64pDWEkSCLMROuws+FO+tdaksEJnwfYGi+WhEKmcgU1uM/A FflnhAPK3MIEeVOpmabdaFB6iJue3l9izzL+cTkDpS2Y1gQ8A1zpsw13yRXsNTvxggLX 00dHo1IYwxj6jQ919AYsDphu1A6GULpmksejsvpYEjbF9+Voo/vOXqaPelkT7UPAwa6D TYNZdH2FDfDZZgFQlhyh04XZ3VmTty14teo0BNTrEbTnBl6f4ppyzeYhSeG57FVOIAc2 z/hwtGO/QXLfd3UEQ+Xx50uOorZON8lkspfytJCWt9Flad7V8m801cOz9isQ7lrL707p MMSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=srKp0qF1Diby5Qs9xfv49IWriKBlWuLXT5Vhw8RgQwA=; b=2A5f1QR1qj143PYE+XDnGy6Jtz0bFcRdltYQObnsssPFJUzDLXtG08V3OGp0iXUqgS 3vcgHYzip6stIlfXP+k3SY3nKuuGFSf2litEDb0idjpH8meOFlIlZFFtidIwXgh6HM07 ++UtgBRNwggbK2LDN0zrv4daTvnz8gTwefgzUfytiBFRIxBy5DugqITE+Ga6TrhcNVYp fpGZBXKt9wE5aIHX5g48De7yEIHxYgGLHVxl71wsJpNUbErzsBey0azYRfr7J1kCltAO qTLsUYL6IHxaKqQvueNQ4e1zsEhcA88NBakzm9I5boyR2yYJOqO+0okp/7fDsy59dPAE 4kUw== X-Gm-Message-State: ACgBeo0A+2qeIxKdaf5VENpyPGVLYspS9b9Y9X4SgtLzLlLPpktM6tg6 Pl+8Kjjysu2UW4JdgiAZh6WN3N45LgEPpiYdaNw= X-Google-Smtp-Source: AA6agR57bUG3mPEtxyWXG+q4PpxQqoYcnvuFddzBAFn03hap+zWba66gaObxQ5TYtNzzDguiam3ukKXhvg31qkBIdCs= X-Received: by 2002:a63:cc51:0:b0:41f:12f5:675b with SMTP id q17-20020a63cc51000000b0041f12f5675bmr6690826pgi.69.1662624378290; Thu, 08 Sep 2022 01:06:18 -0700 (PDT) MIME-Version: 1.0 References: <166256538687.1434226.15760041133601409770.stgit@firesoul> <166256558657.1434226.7390735974413846384.stgit@firesoul> In-Reply-To: <166256558657.1434226.7390735974413846384.stgit@firesoul> From: Magnus Karlsson Date: Thu, 8 Sep 2022 10:06:06 +0200 Message-ID: To: Jesper Dangaard Brouer Content-Type: text/plain; charset="UTF-8" Message-ID-Hash: Y5P4SDXQSVOIOOVJG3VSZUJCZIMNB6V5 X-Message-ID-Hash: Y5P4SDXQSVOIOOVJG3VSZUJCZIMNB6V5 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, netdev@vger.kernel.org, xdp-hints@xdp-project.net, larysa.zaremba@intel.com, memxor@gmail.com, Lorenzo Bianconi , mtahhan@redhat.com, Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , dave@dtucker.co.uk, Magnus Karlsson , bjorn@kernel.org X-Mailman-Version: 3.3.5 Precedence: list Subject: [xdp-hints] Re: [PATCH RFCv2 bpf-next 17/18] xsk: AF_XDP xdp-hints support in desc options List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Wed, Sep 7, 2022 at 5:48 PM Jesper Dangaard Brouer wrote: > > From: Maryam Tahhan > > Simply set AF_XDP descriptor options to XDP flags. > > Jesper: Will this really be acceptable by AF_XDP maintainers? Maryam, you guessed correctly that dedicating all these options bits for a single feature will not be ok :-). E.g., I want one bit for the AF_XDP multi-buffer support and who knows what other uses there might be for this options field in the future. Let us try to solve this in some other way. Here are some suggestions, all with their pros and cons. * Put this feature flag at a known place in the metadata area, for example just before the BTF ID. No need to fill this in if you are not redirecting to AF_XDP, but at a redirect to AF_XDP, the XDP flags are copied into this u32 in the metadata area so that user-space can consume it. Will cost 4 bytes of the metadata area though. * Instead encode this information into each metadata entry in the metadata area, in some way so that a flags field is not needed (-1 signifies not valid, or whatever happens to make sense). This has the drawback that the user might have to look at a large number of entries just to find out there is nothing valid to read. To alleviate this, it could be combined with the next suggestion. * Dedicate one bit in the options field to indicate that there is at least one valid metadata entry in the metadata area. This could be combined with the two approaches above. However, depending on what metadata you have enabled, this bit might be pointless. If some metadata is always valid, then it serves no purpose. But it might if all enabled metadata is rarely valid, e.g., if you get an Rx timestamp on one packet out of one thousand. > Signed-off-by: Maryam Tahhan > --- > include/uapi/linux/if_xdp.h | 2 +- > net/xdp/xsk.c | 2 +- > net/xdp/xsk_queue.h | 3 ++- > 3 files changed, 4 insertions(+), 3 deletions(-) > > diff --git a/include/uapi/linux/if_xdp.h b/include/uapi/linux/if_xdp.h > index a78a8096f4ce..9335b56474e7 100644 > --- a/include/uapi/linux/if_xdp.h > +++ b/include/uapi/linux/if_xdp.h > @@ -103,7 +103,7 @@ struct xdp_options { > struct xdp_desc { > __u64 addr; > __u32 len; > - __u32 options; > + __u32 options; /* set to the values of xdp_hints_flags*/ > }; > > /* UMEM descriptor is __u64 */ > diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c > index 5b4ce6ba1bc7..32095d78f06b 100644 > --- a/net/xdp/xsk.c > +++ b/net/xdp/xsk.c > @@ -141,7 +141,7 @@ static int __xsk_rcv_zc(struct xdp_sock *xs, struct xdp_buff *xdp, u32 len) > int err; > > addr = xp_get_handle(xskb); > - err = xskq_prod_reserve_desc(xs->rx, addr, len); > + err = xskq_prod_reserve_desc(xs->rx, addr, len, xdp->flags); > if (err) { > xs->rx_queue_full++; > return err; > diff --git a/net/xdp/xsk_queue.h b/net/xdp/xsk_queue.h > index fb20bf7207cf..7a66f082f97e 100644 > --- a/net/xdp/xsk_queue.h > +++ b/net/xdp/xsk_queue.h > @@ -368,7 +368,7 @@ static inline u32 xskq_prod_reserve_addr_batch(struct xsk_queue *q, struct xdp_d > } > > static inline int xskq_prod_reserve_desc(struct xsk_queue *q, > - u64 addr, u32 len) > + u64 addr, u32 len, u32 flags) > { > struct xdp_rxtx_ring *ring = (struct xdp_rxtx_ring *)q->ring; > u32 idx; > @@ -380,6 +380,7 @@ static inline int xskq_prod_reserve_desc(struct xsk_queue *q, > idx = q->cached_prod++ & q->ring_mask; > ring->desc[idx].addr = addr; > ring->desc[idx].len = len; > + ring->desc[idx].options = flags; > > return 0; > } > >