From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2F47545B02; Fri, 11 Oct 2024 12:32:28 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BC7C24028B; Fri, 11 Oct 2024 12:32:27 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 4881840150 for ; Fri, 11 Oct 2024 12:32:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728642745; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SLEX/Y8HNYaG6Tm/NnsrMt+rgVb0d+1wCisETN/y87o=; b=aIasBYPoUwcaGrFxOdque4Acgh5VIAlKFiCXYbkgRQ8FuR/QLd28cZ/lP/Xx56jPwpfQnT 8ABS6im+RefxlxvDiJUbqLZn/Ii0d2F6Kxt8AK+SMPhFsG9vZP63YABBH5U79FuY084UTn ppZfXQOYe0eJwYR7mYldutkR7tCH6wo= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-16-PQ66EMQYNvWaNn2J_vOLWQ-1; Fri, 11 Oct 2024 06:32:24 -0400 X-MC-Unique: PQ66EMQYNvWaNn2J_vOLWQ-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-37d4d51b4efso636647f8f.3 for ; Fri, 11 Oct 2024 03:32:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728642743; x=1729247543; h=in-reply-to:references:user-agent:to:from:cc:subject:message-id :date:content-transfer-encoding:mime-version:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=I1LWBh251lvGcc+6eaM7wkPZz96oPN62biecNveDm5g=; b=R9jWhjIxb0C4D91deBnk6lflMRhICGAenoSkx3xdsHAK1L0v0k1I2kLk1Ri3t6UqC1 T7Lz+HA0KKrjUBvZHTiktgY9PLqoehzYQAHRj3fAIvAtIuQEFWLx6eL+nG1SrN58/giy f8Vz/xCN/jGRgbqtTsa1f64dCVcLAj5aXvNNfrJxHUM3vz8Vvj5HhvXazjU182KVEGip krRtcIY4xKHf2rD9TBsJx8m2Y3v9hdACzyaZC4ZJeC3oZ9YBxWS+jNQGXyfyvwUcfG1I NMFUlfUIzFJlMeZiWdZ+GqQSSrWoaUX0InW26TtEZljsnMTTGJEVS0IWGTMsFw6ndu7p a9vQ== X-Forwarded-Encrypted: i=1; AJvYcCXcgNVh44sP3JaN0GnPAYMlUDC7irrDh5kzkI7/EUofFD6r1bcnKf7vNb/2q+fVNpacD/g=@dpdk.org X-Gm-Message-State: AOJu0YxnT2XXikP3vyeWqYA2fcMDILfbr/uhOeL+zjOKbmipz2+v/KqG Fh3iGx4x/G2ZWI0GN+ODM/jmBDEqUih5MXzbErOq1JqftvGyBigonpcu+d9y3D/EPYEsp5Ospmv t91jTurhoDt4CnhdjFn3MNk5S19Q1fYlvDiG0Boq3npYaR6uX X-Received: by 2002:a5d:4fc8:0:b0:37d:5299:c406 with SMTP id ffacd0b85a97d-37d5529ac81mr1439110f8f.38.1728642743301; Fri, 11 Oct 2024 03:32:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE/+CCqEpnLFBq1rcTZISDtQUbqAKUVge/i732ttUvvJq/YNOXEuNHfMl2iybuaJd30oP1W7Q== X-Received: by 2002:a5d:4fc8:0:b0:37d:5299:c406 with SMTP id ffacd0b85a97d-37d5529ac81mr1439092f8f.38.1728642742841; Fri, 11 Oct 2024 03:32:22 -0700 (PDT) Received: from localhost (2a01cb00025433006239e1f47a0b2371.ipv6.abo.wanadoo.fr. [2a01:cb00:254:3300:6239:e1f4:7a0b:2371]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d4b6cffa5sm3618674f8f.53.2024.10.11.03.32.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 11 Oct 2024 03:32:22 -0700 (PDT) Mime-Version: 1.0 Date: Fri, 11 Oct 2024 12:32:22 +0200 Message-Id: Subject: Re: [PATCH v3] fib: network byte order IPv4 lookup Cc: , , From: "Robin Jarry" To: "Vladimir Medvedkin" , User-Agent: aerc/0.18.2-74-g7e4ac1a5f54c References: <20241008173319.441494-1-vladimir.medvedkin@intel.com> <20241010112621.681773-1-vladimir.medvedkin@intel.com> In-Reply-To: <20241010112621.681773-1-vladimir.medvedkin@intel.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8; format=Flowed X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Hi Vladimir, Vladimir Medvedkin, Oct 10, 2024 at 13:26: > Previously when running rte_fib_lookup IPv4 addresses must have been in > host byte order. > > This patch adds a new flag RTE_FIB_FLAG_LOOKUP_BE that can be passed on > fib create, which will allow to have IPv4 in network byte order on > lookup. > > Signed-off-by: Vladimir Medvedkin [snip] > diff --git a/lib/fib/dir24_8.h b/lib/fib/dir24_8.h > index 7125049f15..2c776e118f 100644 > --- a/lib/fib/dir24_8.h > +++ b/lib/fib/dir24_8.h > @@ -7,7 +7,9 @@ > #define _DIR24_8_H_ > =20 > #include > +#include > =20 > +#include > #include > #include > =20 > @@ -237,6 +239,46 @@ dir24_8_lookup_bulk_uni(void *p, const uint32_t *ips= , > =09} > } > =20 > +#define BSWAP_MAX_LENGTH=0964 > + > +typedef void (*dir24_8_lookup_bulk_be_cb)(void *p, const uint32_t *ips, > +=09uint64_t *next_hops, const unsigned int n); > + > +static inline void > +dir24_8_lookup_bulk_be(void *p, const uint32_t *ips, > +=09uint64_t *next_hops, const unsigned int n, > +=09dir24_8_lookup_bulk_be_cb cb) > +{ > +=09uint32_t le_ips[BSWAP_MAX_LENGTH]; > +=09unsigned int i; > + > +=09for (i =3D 0; i < n; i +=3D BSWAP_MAX_LENGTH) { > +=09=09int j; > +=09=09for (j =3D 0; j < BSWAP_MAX_LENGTH && i + j < n; j++) > +=09=09=09le_ips[j] =3D rte_be_to_cpu_32(ips[i + j]); > + > +=09=09cb(p, le_ips, next_hops + i, j); > +=09} This should be a noop for big endian platforms. I'm not sure the=20 complier will be smart enough to collapse the nested loops. > +} > + > +#define DECLARE_BE_LOOKUP_FN(name)=09=09=09=09=09\ > +static inline void=09=09=09=09=09=09=09\ > +name##_be(void *p, const uint32_t *ips,=09=09=09=09=09\ > +=09uint64_t *next_hops, const unsigned int n)=09=09=09\ > +{=09=09=09=09=09=09=09=09=09\ > +=09dir24_8_lookup_bulk_be(p, ips, next_hops, n, name);=09=09\ > +} > + > +DECLARE_BE_LOOKUP_FN(dir24_8_lookup_bulk_1b) > +DECLARE_BE_LOOKUP_FN(dir24_8_lookup_bulk_2b) > +DECLARE_BE_LOOKUP_FN(dir24_8_lookup_bulk_4b) > +DECLARE_BE_LOOKUP_FN(dir24_8_lookup_bulk_8b) > +DECLARE_BE_LOOKUP_FN(dir24_8_lookup_bulk_0) > +DECLARE_BE_LOOKUP_FN(dir24_8_lookup_bulk_1) > +DECLARE_BE_LOOKUP_FN(dir24_8_lookup_bulk_2) > +DECLARE_BE_LOOKUP_FN(dir24_8_lookup_bulk_3) > +DECLARE_BE_LOOKUP_FN(dir24_8_lookup_bulk_uni) > + > void * > dir24_8_create(const char *name, int socket_id, struct rte_fib_conf *con= f); > =20 > @@ -244,7 +286,7 @@ void > dir24_8_free(void *p); > =20 > rte_fib_lookup_fn_t > -dir24_8_get_lookup_fn(void *p, enum rte_fib_lookup_type type); > +dir24_8_get_lookup_fn(void *p, enum rte_fib_lookup_type type, bool be_ad= dr); > =20 > int > dir24_8_modify(struct rte_fib *fib, uint32_t ip, uint8_t depth, [snip] > diff --git a/lib/fib/rte_fib.h b/lib/fib/rte_fib.h > index d7a5aafe53..1617235e85 100644 > --- a/lib/fib/rte_fib.h > +++ b/lib/fib/rte_fib.h > @@ -28,6 +28,9 @@ struct rte_rib; > /** Maximum depth value possible for IPv4 FIB. */ > #define RTE_FIB_MAXDEPTH=0932 > =20 > +/** If set fib lookup is expecting ipv4 in network byte order */ > +#define RTE_FIB_FLAG_LOOKUP_BE=091 I think RTE_FIB_F_NETWORK_ORDER would be more appropriate. > + > /** Type of FIB struct */ > enum rte_fib_type { > =09RTE_FIB_DUMMY,=09=09/**< RIB tree based FIB */ > @@ -76,6 +79,7 @@ enum rte_fib_lookup_type { > /** FIB configuration structure */ > struct rte_fib_conf { > =09enum rte_fib_type type; /**< Type of FIB struct */ > +=09unsigned int flags; Maybe use an explicit int size for flags like uint32_t? I doubt we'll=20 ever need more than 32 flags. Also, maybe it would be better to add this field at the end to avoid=20 breaking the API? You forgot to add a doc string for that field: uint32_t flags; /**< Optional feature flags from RTE_FIB_F_* **/ Thanks!