DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] net/af_xdp: make compatible with libbpf v0.8.0
@ 2022-06-24 10:23 Ciara Loftus
  2022-06-24 11:45 ` Andrew Rybchenko
                   ` (4 more replies)
  0 siblings, 5 replies; 35+ messages in thread
From: Ciara Loftus @ 2022-06-24 10:23 UTC (permalink / raw)
  To: dev; +Cc: thomas, ferruh.yigit, Ciara Loftus

libbpf v0.8.0 deprecates the bpf_get_link_xdp_id and bpf_set_link_xdp_fd
functions. Use meson to detect if libbpf >= v0.7.0 is linked and if so, use
the recommended replacement functions bpf_xdp_query_id, bpf_xdp_attach
and bpf_xdp_detach which are available to use since libbpf v0.7.0.

Also prevent linking with libbpf versions > v0.8.0.

Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
---
 doc/guides/nics/af_xdp.rst          |  3 ++-
 drivers/net/af_xdp/compat.h         | 36 ++++++++++++++++++++++++++++-
 drivers/net/af_xdp/meson.build      |  7 ++----
 drivers/net/af_xdp/rte_eth_af_xdp.c | 19 +++------------
 4 files changed, 42 insertions(+), 23 deletions(-)

diff --git a/doc/guides/nics/af_xdp.rst b/doc/guides/nics/af_xdp.rst
index 56681c8365..9edb48df67 100644
--- a/doc/guides/nics/af_xdp.rst
+++ b/doc/guides/nics/af_xdp.rst
@@ -43,7 +43,8 @@ Prerequisites
 This is a Linux-specific PMD, thus the following prerequisites apply:
 
 *  A Linux Kernel (version > v4.18) with XDP sockets configuration enabled;
-*  Both libxdp >=v1.2.2 and libbpf libraries installed, or, libbpf <=v0.6.0
+*  Both libxdp >=v1.2.2 and libbpf <=v0.8.0 libraries installed, or, libbpf
+   <=v0.6.0.
 *  If using libxdp, it requires an environment variable called
    LIBXDP_OBJECT_PATH to be set to the location of where libxdp placed its bpf
    object files. This is usually in /usr/local/lib/bpf or /usr/local/lib64/bpf.
diff --git a/drivers/net/af_xdp/compat.h b/drivers/net/af_xdp/compat.h
index 28ea64aeaa..8f4ac8b5ea 100644
--- a/drivers/net/af_xdp/compat.h
+++ b/drivers/net/af_xdp/compat.h
@@ -60,7 +60,7 @@ tx_syscall_needed(struct xsk_ring_prod *q __rte_unused)
 }
 #endif
 
-#ifdef RTE_NET_AF_XDP_LIBBPF_OBJ_OPEN
+#ifdef RTE_NET_AF_XDP_LIBBPF_V070
 static int load_program(const char *prog_path, struct bpf_object **obj)
 {
 	struct bpf_program *prog;
@@ -85,6 +85,23 @@ static int load_program(const char *prog_path, struct bpf_object **obj)
 	bpf_object__close(*obj);
 	return -1;
 }
+
+static int
+remove_xdp_program(int ifindex)
+{
+	uint32_t curr_prog_id = 0;
+
+	if (bpf_xdp_query_id(ifindex, XDP_FLAGS_UPDATE_IF_NOEXIST,
+				&curr_prog_id))
+		return -1;
+
+	return bpf_xdp_detach(ifindex, XDP_FLAGS_UPDATE_IF_NOEXIST, NULL);
+}
+
+static int link_xdp_prog_with_dev(int ifindex, int fd, __u32 flags)
+{
+	return bpf_xdp_attach(ifindex, fd, flags, NULL);
+}
 #else
 static int load_program(const char *prog_path, struct bpf_object **obj)
 {
@@ -96,4 +113,21 @@ static int load_program(const char *prog_path, struct bpf_object **obj)
 
 	return prog_fd;
 }
+
+static int
+remove_xdp_program(int ifindex)
+{
+	uint32_t curr_prog_id = 0;
+
+	if (bpf_get_link_xdp_id(ifindex, &curr_prog_id,
+				XDP_FLAGS_UPDATE_IF_NOEXIST))
+		return -1;
+
+	return bpf_set_link_xdp_fd(ifindex, -1, XDP_FLAGS_UPDATE_IF_NOEXIST);
+}
+
+static int link_xdp_prog_with_dev(int ifindex, int fd, __u32 flags)
+{
+	return bpf_set_link_xdp_fd(ifindex, fd, flags);
+}
 #endif
diff --git a/drivers/net/af_xdp/meson.build b/drivers/net/af_xdp/meson.build
index 1e0de23705..349f8e7c12 100644
--- a/drivers/net/af_xdp/meson.build
+++ b/drivers/net/af_xdp/meson.build
@@ -10,10 +10,7 @@ endif
 sources = files('rte_eth_af_xdp.c')
 
 xdp_dep = dependency('libxdp', version : '>=1.2.2', required: false, method: 'pkg-config')
-bpf_dep = dependency('libbpf', required: false, method: 'pkg-config')
-if not bpf_dep.found()
-    bpf_dep = cc.find_library('bpf', required: false)
-endif
+bpf_dep = dependency('libbpf', version : '<=0.8.0', required: false, method: 'pkg-config')
 
 if cc.has_header('linux/if_xdp.h')
     if xdp_dep.found() and cc.has_header('xdp/xsk.h')
@@ -25,7 +22,7 @@ if cc.has_header('linux/if_xdp.h')
             bpf_ver_dep = dependency('libbpf', version : '>=0.7.0',
                                  required: false, method: 'pkg-config')
             if bpf_ver_dep.found()
-                cflags += ['-DRTE_NET_AF_XDP_LIBBPF_OBJ_OPEN']
+                cflags += ['-DRTE_NET_AF_XDP_LIBBPF_V070']
             endif
         else
             build = false
diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index 1e37da6e84..943d5c9838 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -863,20 +863,6 @@ eth_stats_reset(struct rte_eth_dev *dev)
 	return 0;
 }
 
-static void
-remove_xdp_program(struct pmd_internals *internals)
-{
-	uint32_t curr_prog_id = 0;
-
-	if (bpf_get_link_xdp_id(internals->if_index, &curr_prog_id,
-				XDP_FLAGS_UPDATE_IF_NOEXIST)) {
-		AF_XDP_LOG(ERR, "bpf_get_link_xdp_id failed\n");
-		return;
-	}
-	bpf_set_link_xdp_fd(internals->if_index, -1,
-			XDP_FLAGS_UPDATE_IF_NOEXIST);
-}
-
 static void
 xdp_umem_destroy(struct xsk_umem_info *umem)
 {
@@ -929,7 +915,8 @@ eth_dev_close(struct rte_eth_dev *dev)
 	 */
 	dev->data->mac_addrs = NULL;
 
-	remove_xdp_program(internals);
+	if (remove_xdp_program(internals->if_index))
+		AF_XDP_LOG(ERR, "Error while removing XDP program.\n");
 
 	if (internals->shared_umem) {
 		struct internal_list *list;
@@ -1195,7 +1182,7 @@ load_custom_xdp_prog(const char *prog_path, int if_index, struct bpf_map **map)
 	}
 
 	/* Link the program with the given network device */
-	ret = bpf_set_link_xdp_fd(if_index, prog_fd,
+	ret = link_xdp_prog_with_dev(if_index, prog_fd,
 					XDP_FLAGS_UPDATE_IF_NOEXIST);
 	if (ret) {
 		AF_XDP_LOG(ERR, "Failed to set prog fd %d on interface\n",
-- 
2.25.1


^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH] net/af_xdp: make compatible with libbpf v0.8.0
  2022-06-24 10:23 [PATCH] net/af_xdp: make compatible with libbpf v0.8.0 Ciara Loftus
@ 2022-06-24 11:45 ` Andrew Rybchenko
  2022-06-27 14:17   ` Loftus, Ciara
  2022-06-28 12:18 ` [PATCH v2] " Ciara Loftus
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 35+ messages in thread
From: Andrew Rybchenko @ 2022-06-24 11:45 UTC (permalink / raw)
  To: Ciara Loftus, dev; +Cc: thomas, ferruh.yigit

On 6/24/22 13:23, Ciara Loftus wrote:
> libbpf v0.8.0 deprecates the bpf_get_link_xdp_id and bpf_set_link_xdp_fd
> functions. Use meson to detect if libbpf >= v0.7.0 is linked and if so, use
> the recommended replacement functions bpf_xdp_query_id, bpf_xdp_attach
> and bpf_xdp_detach which are available to use since libbpf v0.7.0.
> 
> Also prevent linking with libbpf versions > v0.8.0.
> 
> Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
> ---
>   doc/guides/nics/af_xdp.rst          |  3 ++-
>   drivers/net/af_xdp/compat.h         | 36 ++++++++++++++++++++++++++++-
>   drivers/net/af_xdp/meson.build      |  7 ++----
>   drivers/net/af_xdp/rte_eth_af_xdp.c | 19 +++------------
>   4 files changed, 42 insertions(+), 23 deletions(-)

Don't we need to mention these changes in release notes?

> 
> diff --git a/doc/guides/nics/af_xdp.rst b/doc/guides/nics/af_xdp.rst
> index 56681c8365..9edb48df67 100644
> --- a/doc/guides/nics/af_xdp.rst
> +++ b/doc/guides/nics/af_xdp.rst
> @@ -43,7 +43,8 @@ Prerequisites
>   This is a Linux-specific PMD, thus the following prerequisites apply:
>   
>   *  A Linux Kernel (version > v4.18) with XDP sockets configuration enabled;
> -*  Both libxdp >=v1.2.2 and libbpf libraries installed, or, libbpf <=v0.6.0
> +*  Both libxdp >=v1.2.2 and libbpf <=v0.8.0 libraries installed, or, libbpf
> +   <=v0.6.0.
>   *  If using libxdp, it requires an environment variable called
>      LIBXDP_OBJECT_PATH to be set to the location of where libxdp placed its bpf
>      object files. This is usually in /usr/local/lib/bpf or /usr/local/lib64/bpf.
> diff --git a/drivers/net/af_xdp/compat.h b/drivers/net/af_xdp/compat.h
> index 28ea64aeaa..8f4ac8b5ea 100644
> --- a/drivers/net/af_xdp/compat.h
> +++ b/drivers/net/af_xdp/compat.h
> @@ -60,7 +60,7 @@ tx_syscall_needed(struct xsk_ring_prod *q __rte_unused)
>   }
>   #endif
>   
> -#ifdef RTE_NET_AF_XDP_LIBBPF_OBJ_OPEN
> +#ifdef RTE_NET_AF_XDP_LIBBPF_V070

Typically version-based checks are considered as bad. Isn't it
better use feature-based checks/defines?

^ permalink raw reply	[flat|nested] 35+ messages in thread

* RE: [PATCH] net/af_xdp: make compatible with libbpf v0.8.0
  2022-06-24 11:45 ` Andrew Rybchenko
@ 2022-06-27 14:17   ` Loftus, Ciara
  2022-06-27 14:50     ` Andrew Rybchenko
  0 siblings, 1 reply; 35+ messages in thread
From: Loftus, Ciara @ 2022-06-27 14:17 UTC (permalink / raw)
  To: Andrew Rybchenko, dev; +Cc: thomas, ferruh.yigit

> 
> On 6/24/22 13:23, Ciara Loftus wrote:
> > libbpf v0.8.0 deprecates the bpf_get_link_xdp_id and bpf_set_link_xdp_fd
> > functions. Use meson to detect if libbpf >= v0.7.0 is linked and if so, use
> > the recommended replacement functions bpf_xdp_query_id,
> bpf_xdp_attach
> > and bpf_xdp_detach which are available to use since libbpf v0.7.0.
> >
> > Also prevent linking with libbpf versions > v0.8.0.
> >
> > Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
> > ---
> >   doc/guides/nics/af_xdp.rst          |  3 ++-
> >   drivers/net/af_xdp/compat.h         | 36
> ++++++++++++++++++++++++++++-
> >   drivers/net/af_xdp/meson.build      |  7 ++----
> >   drivers/net/af_xdp/rte_eth_af_xdp.c | 19 +++------------
> >   4 files changed, 42 insertions(+), 23 deletions(-)
> 
> Don't we need to mention these changes in release notes?
> 
> >
> > diff --git a/doc/guides/nics/af_xdp.rst b/doc/guides/nics/af_xdp.rst
> > index 56681c8365..9edb48df67 100644
> > --- a/doc/guides/nics/af_xdp.rst
> > +++ b/doc/guides/nics/af_xdp.rst
> > @@ -43,7 +43,8 @@ Prerequisites
> >   This is a Linux-specific PMD, thus the following prerequisites apply:
> >
> >   *  A Linux Kernel (version > v4.18) with XDP sockets configuration enabled;
> > -*  Both libxdp >=v1.2.2 and libbpf libraries installed, or, libbpf <=v0.6.0
> > +*  Both libxdp >=v1.2.2 and libbpf <=v0.8.0 libraries installed, or, libbpf
> > +   <=v0.6.0.
> >   *  If using libxdp, it requires an environment variable called
> >      LIBXDP_OBJECT_PATH to be set to the location of where libxdp placed its
> bpf
> >      object files. This is usually in /usr/local/lib/bpf or /usr/local/lib64/bpf.
> > diff --git a/drivers/net/af_xdp/compat.h b/drivers/net/af_xdp/compat.h
> > index 28ea64aeaa..8f4ac8b5ea 100644
> > --- a/drivers/net/af_xdp/compat.h
> > +++ b/drivers/net/af_xdp/compat.h
> > @@ -60,7 +60,7 @@ tx_syscall_needed(struct xsk_ring_prod *q
> __rte_unused)
> >   }
> >   #endif
> >
> > -#ifdef RTE_NET_AF_XDP_LIBBPF_OBJ_OPEN
> > +#ifdef RTE_NET_AF_XDP_LIBBPF_V070
> 
> Typically version-based checks are considered as bad. Isn't it
> better use feature-based checks/defines?

Hi Andrew,

Thank you for the feedback. Is the feature-based checking something that we can push to the next release?

We are already using the pkg-config version-check method for other libraries/features in the meson.build file:
* libxdp >= v1.2.2 # earliest compatible libxdp release
* libbpf >= v0.7.0 # bpf_object__* functions
* libbpf >= v0.2.0 # shared umem feature

If we change to your suggested method I think we should change them all in one patch. IMO it's probably too close to the release to change them all right now. What do you think?

Thanks,
Ciara

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH] net/af_xdp: make compatible with libbpf v0.8.0
  2022-06-27 14:17   ` Loftus, Ciara
@ 2022-06-27 14:50     ` Andrew Rybchenko
  2022-06-27 15:24       ` Loftus, Ciara
  0 siblings, 1 reply; 35+ messages in thread
From: Andrew Rybchenko @ 2022-06-27 14:50 UTC (permalink / raw)
  To: Loftus, Ciara, dev; +Cc: thomas, ferruh.yigit

On 6/27/22 17:17, Loftus, Ciara wrote:
>>
>> On 6/24/22 13:23, Ciara Loftus wrote:
>>> libbpf v0.8.0 deprecates the bpf_get_link_xdp_id and bpf_set_link_xdp_fd
>>> functions. Use meson to detect if libbpf >= v0.7.0 is linked and if so, use
>>> the recommended replacement functions bpf_xdp_query_id,
>> bpf_xdp_attach
>>> and bpf_xdp_detach which are available to use since libbpf v0.7.0.
>>>
>>> Also prevent linking with libbpf versions > v0.8.0.
>>>
>>> Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
>>> ---
>>>    doc/guides/nics/af_xdp.rst          |  3 ++-
>>>    drivers/net/af_xdp/compat.h         | 36
>> ++++++++++++++++++++++++++++-
>>>    drivers/net/af_xdp/meson.build      |  7 ++----
>>>    drivers/net/af_xdp/rte_eth_af_xdp.c | 19 +++------------
>>>    4 files changed, 42 insertions(+), 23 deletions(-)
>>
>> Don't we need to mention these changes in release notes?
>>
>>>
>>> diff --git a/doc/guides/nics/af_xdp.rst b/doc/guides/nics/af_xdp.rst
>>> index 56681c8365..9edb48df67 100644
>>> --- a/doc/guides/nics/af_xdp.rst
>>> +++ b/doc/guides/nics/af_xdp.rst
>>> @@ -43,7 +43,8 @@ Prerequisites
>>>    This is a Linux-specific PMD, thus the following prerequisites apply:
>>>
>>>    *  A Linux Kernel (version > v4.18) with XDP sockets configuration enabled;
>>> -*  Both libxdp >=v1.2.2 and libbpf libraries installed, or, libbpf <=v0.6.0
>>> +*  Both libxdp >=v1.2.2 and libbpf <=v0.8.0 libraries installed, or, libbpf
>>> +   <=v0.6.0.
>>>    *  If using libxdp, it requires an environment variable called
>>>       LIBXDP_OBJECT_PATH to be set to the location of where libxdp placed its
>> bpf
>>>       object files. This is usually in /usr/local/lib/bpf or /usr/local/lib64/bpf.
>>> diff --git a/drivers/net/af_xdp/compat.h b/drivers/net/af_xdp/compat.h
>>> index 28ea64aeaa..8f4ac8b5ea 100644
>>> --- a/drivers/net/af_xdp/compat.h
>>> +++ b/drivers/net/af_xdp/compat.h
>>> @@ -60,7 +60,7 @@ tx_syscall_needed(struct xsk_ring_prod *q
>> __rte_unused)
>>>    }
>>>    #endif
>>>
>>> -#ifdef RTE_NET_AF_XDP_LIBBPF_OBJ_OPEN
>>> +#ifdef RTE_NET_AF_XDP_LIBBPF_V070
>>
>> Typically version-based checks are considered as bad. Isn't it
>> better use feature-based checks/defines?
> 
> Hi Andrew,
> 
> Thank you for the feedback. Is the feature-based checking something that we can push to the next release?
> 
> We are already using the pkg-config version-check method for other libraries/features in the meson.build file:
> * libxdp >= v1.2.2 # earliest compatible libxdp release
> * libbpf >= v0.7.0 # bpf_object__* functions
> * libbpf >= v0.2.0 # shared umem feature
> 
> If we change to your suggested method I think we should change them all in one patch. IMO it's probably too close to the release to change them all right now. What do you think?
> 
> Thanks,
> Ciara

Hi Ciara,

yes, ideally we should avoid usage of version-based check everywhere,
but I don't think that it is critical to switch at once. We can use it
for new checks right now and rewrite old/existing checks a bit later in
the next release.

Please, note that my notes are related to review notes from Thomas who
asked by file_library() method is removed. Yes, it is confusing and it
is better to avoid it. Usage of feature-based checks would allow to
preserve find_library() as well.

Andrew.


^ permalink raw reply	[flat|nested] 35+ messages in thread

* RE: [PATCH] net/af_xdp: make compatible with libbpf v0.8.0
  2022-06-27 14:50     ` Andrew Rybchenko
@ 2022-06-27 15:24       ` Loftus, Ciara
  2022-06-28  9:15         ` Andrew Rybchenko
  0 siblings, 1 reply; 35+ messages in thread
From: Loftus, Ciara @ 2022-06-27 15:24 UTC (permalink / raw)
  To: Andrew Rybchenko, dev; +Cc: thomas, ferruh.yigit

> 
> On 6/27/22 17:17, Loftus, Ciara wrote:
> >>
> >> On 6/24/22 13:23, Ciara Loftus wrote:
> >>> libbpf v0.8.0 deprecates the bpf_get_link_xdp_id and
> bpf_set_link_xdp_fd
> >>> functions. Use meson to detect if libbpf >= v0.7.0 is linked and if so, use
> >>> the recommended replacement functions bpf_xdp_query_id,
> >> bpf_xdp_attach
> >>> and bpf_xdp_detach which are available to use since libbpf v0.7.0.
> >>>
> >>> Also prevent linking with libbpf versions > v0.8.0.
> >>>
> >>> Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
> >>> ---
> >>>    doc/guides/nics/af_xdp.rst          |  3 ++-
> >>>    drivers/net/af_xdp/compat.h         | 36
> >> ++++++++++++++++++++++++++++-
> >>>    drivers/net/af_xdp/meson.build      |  7 ++----
> >>>    drivers/net/af_xdp/rte_eth_af_xdp.c | 19 +++------------
> >>>    4 files changed, 42 insertions(+), 23 deletions(-)
> >>
> >> Don't we need to mention these changes in release notes?
> >>
> >>>
> >>> diff --git a/doc/guides/nics/af_xdp.rst b/doc/guides/nics/af_xdp.rst
> >>> index 56681c8365..9edb48df67 100644
> >>> --- a/doc/guides/nics/af_xdp.rst
> >>> +++ b/doc/guides/nics/af_xdp.rst
> >>> @@ -43,7 +43,8 @@ Prerequisites
> >>>    This is a Linux-specific PMD, thus the following prerequisites apply:
> >>>
> >>>    *  A Linux Kernel (version > v4.18) with XDP sockets configuration
> enabled;
> >>> -*  Both libxdp >=v1.2.2 and libbpf libraries installed, or, libbpf <=v0.6.0
> >>> +*  Both libxdp >=v1.2.2 and libbpf <=v0.8.0 libraries installed, or, libbpf
> >>> +   <=v0.6.0.
> >>>    *  If using libxdp, it requires an environment variable called
> >>>       LIBXDP_OBJECT_PATH to be set to the location of where libxdp
> placed its
> >> bpf
> >>>       object files. This is usually in /usr/local/lib/bpf or /usr/local/lib64/bpf.
> >>> diff --git a/drivers/net/af_xdp/compat.h
> b/drivers/net/af_xdp/compat.h
> >>> index 28ea64aeaa..8f4ac8b5ea 100644
> >>> --- a/drivers/net/af_xdp/compat.h
> >>> +++ b/drivers/net/af_xdp/compat.h
> >>> @@ -60,7 +60,7 @@ tx_syscall_needed(struct xsk_ring_prod *q
> >> __rte_unused)
> >>>    }
> >>>    #endif
> >>>
> >>> -#ifdef RTE_NET_AF_XDP_LIBBPF_OBJ_OPEN
> >>> +#ifdef RTE_NET_AF_XDP_LIBBPF_V070
> >>
> >> Typically version-based checks are considered as bad. Isn't it
> >> better use feature-based checks/defines?
> >
> > Hi Andrew,
> >
> > Thank you for the feedback. Is the feature-based checking something that
> we can push to the next release?
> >
> > We are already using the pkg-config version-check method for other
> libraries/features in the meson.build file:
> > * libxdp >= v1.2.2 # earliest compatible libxdp release
> > * libbpf >= v0.7.0 # bpf_object__* functions
> > * libbpf >= v0.2.0 # shared umem feature
> >
> > If we change to your suggested method I think we should change them all
> in one patch. IMO it's probably too close to the release to change them all
> right now. What do you think?
> >
> > Thanks,
> > Ciara
> 
> Hi Ciara,
> 
> yes, ideally we should avoid usage of version-based check everywhere,
> but I don't think that it is critical to switch at once. We can use it
> for new checks right now and rewrite old/existing checks a bit later in
> the next release.
> 
> Please, note that my notes are related to review notes from Thomas who
> asked by file_library() method is removed. Yes, it is confusing and it
> is better to avoid it. Usage of feature-based checks would allow to
> preserve find_library() as well.

Thank you for the explanation.
In this case we want to check that the libbpf library is <=v0.8.0. At this moment in time v0.8.0 is the latest version of libbpf so we cannot check for a symbol that tells us the library is > v0.8.0. Can you think of a way to approach this without using the pkg-config version check method?

I've introduced this check to future-proof the PMD and ensure we only ever link with versions of libbpf that we've validated to be compatible with the PMD. When say v0.9.0 is released we can patch the PMD allowing for libbpf <= v0.9.0 and make any necessary API changes as part of that patch. This should hopefully help avoid the scenario Thomas encountered.

Ciara

> 
> Andrew.


^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH] net/af_xdp: make compatible with libbpf v0.8.0
  2022-06-27 15:24       ` Loftus, Ciara
@ 2022-06-28  9:15         ` Andrew Rybchenko
  2022-06-28 10:07           ` Loftus, Ciara
  0 siblings, 1 reply; 35+ messages in thread
From: Andrew Rybchenko @ 2022-06-28  9:15 UTC (permalink / raw)
  To: Loftus, Ciara, dev; +Cc: thomas, ferruh.yigit

On 6/27/22 18:24, Loftus, Ciara wrote:
>>
>> On 6/27/22 17:17, Loftus, Ciara wrote:
>>>>
>>>> On 6/24/22 13:23, Ciara Loftus wrote:
>>>>> libbpf v0.8.0 deprecates the bpf_get_link_xdp_id and
>> bpf_set_link_xdp_fd
>>>>> functions. Use meson to detect if libbpf >= v0.7.0 is linked and if so, use
>>>>> the recommended replacement functions bpf_xdp_query_id,
>>>> bpf_xdp_attach
>>>>> and bpf_xdp_detach which are available to use since libbpf v0.7.0.
>>>>>
>>>>> Also prevent linking with libbpf versions > v0.8.0.
>>>>>
>>>>> Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
>>>>> ---
>>>>>     doc/guides/nics/af_xdp.rst          |  3 ++-
>>>>>     drivers/net/af_xdp/compat.h         | 36
>>>> ++++++++++++++++++++++++++++-
>>>>>     drivers/net/af_xdp/meson.build      |  7 ++----
>>>>>     drivers/net/af_xdp/rte_eth_af_xdp.c | 19 +++------------
>>>>>     4 files changed, 42 insertions(+), 23 deletions(-)
>>>>
>>>> Don't we need to mention these changes in release notes?
>>>>
>>>>>
>>>>> diff --git a/doc/guides/nics/af_xdp.rst b/doc/guides/nics/af_xdp.rst
>>>>> index 56681c8365..9edb48df67 100644
>>>>> --- a/doc/guides/nics/af_xdp.rst
>>>>> +++ b/doc/guides/nics/af_xdp.rst
>>>>> @@ -43,7 +43,8 @@ Prerequisites
>>>>>     This is a Linux-specific PMD, thus the following prerequisites apply:
>>>>>
>>>>>     *  A Linux Kernel (version > v4.18) with XDP sockets configuration
>> enabled;
>>>>> -*  Both libxdp >=v1.2.2 and libbpf libraries installed, or, libbpf <=v0.6.0
>>>>> +*  Both libxdp >=v1.2.2 and libbpf <=v0.8.0 libraries installed, or, libbpf
>>>>> +   <=v0.6.0.
>>>>>     *  If using libxdp, it requires an environment variable called
>>>>>        LIBXDP_OBJECT_PATH to be set to the location of where libxdp
>> placed its
>>>> bpf
>>>>>        object files. This is usually in /usr/local/lib/bpf or /usr/local/lib64/bpf.
>>>>> diff --git a/drivers/net/af_xdp/compat.h
>> b/drivers/net/af_xdp/compat.h
>>>>> index 28ea64aeaa..8f4ac8b5ea 100644
>>>>> --- a/drivers/net/af_xdp/compat.h
>>>>> +++ b/drivers/net/af_xdp/compat.h
>>>>> @@ -60,7 +60,7 @@ tx_syscall_needed(struct xsk_ring_prod *q
>>>> __rte_unused)
>>>>>     }
>>>>>     #endif
>>>>>
>>>>> -#ifdef RTE_NET_AF_XDP_LIBBPF_OBJ_OPEN
>>>>> +#ifdef RTE_NET_AF_XDP_LIBBPF_V070
>>>>
>>>> Typically version-based checks are considered as bad. Isn't it
>>>> better use feature-based checks/defines?
>>>
>>> Hi Andrew,
>>>
>>> Thank you for the feedback. Is the feature-based checking something that
>> we can push to the next release?
>>>
>>> We are already using the pkg-config version-check method for other
>> libraries/features in the meson.build file:
>>> * libxdp >= v1.2.2 # earliest compatible libxdp release
>>> * libbpf >= v0.7.0 # bpf_object__* functions
>>> * libbpf >= v0.2.0 # shared umem feature
>>>
>>> If we change to your suggested method I think we should change them all
>> in one patch. IMO it's probably too close to the release to change them all
>> right now. What do you think?
>>>
>>> Thanks,
>>> Ciara
>>
>> Hi Ciara,
>>
>> yes, ideally we should avoid usage of version-based check everywhere,
>> but I don't think that it is critical to switch at once. We can use it
>> for new checks right now and rewrite old/existing checks a bit later in
>> the next release.
>>
>> Please, note that my notes are related to review notes from Thomas who
>> asked by file_library() method is removed. Yes, it is confusing and it
>> is better to avoid it. Usage of feature-based checks would allow to
>> preserve find_library() as well.
> 
> Thank you for the explanation.
> In this case we want to check that the libbpf library is <=v0.8.0. At this moment in time v0.8.0 is the latest version of libbpf so we cannot check for a symbol that tells us the library is > v0.8.0. Can you think of a way to approach this without using the pkg-config version check method?
> 
> I've introduced this check to future-proof the PMD and ensure we only ever link with versions of libbpf that we've validated to be compatible with the PMD. When say v0.9.0 is released we can patch the PMD allowing for libbpf <= v0.9.0 and make any necessary API changes as part of that patch. This should hopefully help avoid the scenario Thomas encountered.

Personally I'd consider such checks which limit version as a drawback.
I think checks on build should not be used to reject future versions.
Otherwise, introduction of any further even minor version would require
a patch to allow it. Documentation is the place for information about
validated versions. Build should not enforce it.


^ permalink raw reply	[flat|nested] 35+ messages in thread

* RE: [PATCH] net/af_xdp: make compatible with libbpf v0.8.0
  2022-06-28  9:15         ` Andrew Rybchenko
@ 2022-06-28 10:07           ` Loftus, Ciara
  2022-07-21 12:16             ` Loftus, Ciara
  0 siblings, 1 reply; 35+ messages in thread
From: Loftus, Ciara @ 2022-06-28 10:07 UTC (permalink / raw)
  To: Andrew Rybchenko, dev; +Cc: thomas, ferruh.yigit

> >>>>
> >>>> On 6/24/22 13:23, Ciara Loftus wrote:
> >>>>> libbpf v0.8.0 deprecates the bpf_get_link_xdp_id and
> >> bpf_set_link_xdp_fd
> >>>>> functions. Use meson to detect if libbpf >= v0.7.0 is linked and if so,
> use
> >>>>> the recommended replacement functions bpf_xdp_query_id,
> >>>> bpf_xdp_attach
> >>>>> and bpf_xdp_detach which are available to use since libbpf v0.7.0.
> >>>>>
> >>>>> Also prevent linking with libbpf versions > v0.8.0.
> >>>>>
> >>>>> Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
> >>>>> ---
> >>>>>     doc/guides/nics/af_xdp.rst          |  3 ++-
> >>>>>     drivers/net/af_xdp/compat.h         | 36
> >>>> ++++++++++++++++++++++++++++-
> >>>>>     drivers/net/af_xdp/meson.build      |  7 ++----
> >>>>>     drivers/net/af_xdp/rte_eth_af_xdp.c | 19 +++------------
> >>>>>     4 files changed, 42 insertions(+), 23 deletions(-)
> >>>>
> >>>> Don't we need to mention these changes in release notes?
> >>>>
> >>>>>
> >>>>> diff --git a/doc/guides/nics/af_xdp.rst b/doc/guides/nics/af_xdp.rst
> >>>>> index 56681c8365..9edb48df67 100644
> >>>>> --- a/doc/guides/nics/af_xdp.rst
> >>>>> +++ b/doc/guides/nics/af_xdp.rst
> >>>>> @@ -43,7 +43,8 @@ Prerequisites
> >>>>>     This is a Linux-specific PMD, thus the following prerequisites apply:
> >>>>>
> >>>>>     *  A Linux Kernel (version > v4.18) with XDP sockets configuration
> >> enabled;
> >>>>> -*  Both libxdp >=v1.2.2 and libbpf libraries installed, or, libbpf
> <=v0.6.0
> >>>>> +*  Both libxdp >=v1.2.2 and libbpf <=v0.8.0 libraries installed, or,
> libbpf
> >>>>> +   <=v0.6.0.
> >>>>>     *  If using libxdp, it requires an environment variable called
> >>>>>        LIBXDP_OBJECT_PATH to be set to the location of where libxdp
> >> placed its
> >>>> bpf
> >>>>>        object files. This is usually in /usr/local/lib/bpf or
> /usr/local/lib64/bpf.
> >>>>> diff --git a/drivers/net/af_xdp/compat.h
> >> b/drivers/net/af_xdp/compat.h
> >>>>> index 28ea64aeaa..8f4ac8b5ea 100644
> >>>>> --- a/drivers/net/af_xdp/compat.h
> >>>>> +++ b/drivers/net/af_xdp/compat.h
> >>>>> @@ -60,7 +60,7 @@ tx_syscall_needed(struct xsk_ring_prod *q
> >>>> __rte_unused)
> >>>>>     }
> >>>>>     #endif
> >>>>>
> >>>>> -#ifdef RTE_NET_AF_XDP_LIBBPF_OBJ_OPEN
> >>>>> +#ifdef RTE_NET_AF_XDP_LIBBPF_V070
> >>>>
> >>>> Typically version-based checks are considered as bad. Isn't it
> >>>> better use feature-based checks/defines?
> >>>
> >>> Hi Andrew,
> >>>
> >>> Thank you for the feedback. Is the feature-based checking something
> that
> >> we can push to the next release?
> >>>
> >>> We are already using the pkg-config version-check method for other
> >> libraries/features in the meson.build file:
> >>> * libxdp >= v1.2.2 # earliest compatible libxdp release
> >>> * libbpf >= v0.7.0 # bpf_object__* functions
> >>> * libbpf >= v0.2.0 # shared umem feature
> >>>
> >>> If we change to your suggested method I think we should change them
> all
> >> in one patch. IMO it's probably too close to the release to change them all
> >> right now. What do you think?
> >>>
> >>> Thanks,
> >>> Ciara
> >>
> >> Hi Ciara,
> >>
> >> yes, ideally we should avoid usage of version-based check everywhere,
> >> but I don't think that it is critical to switch at once. We can use it
> >> for new checks right now and rewrite old/existing checks a bit later in
> >> the next release.
> >>
> >> Please, note that my notes are related to review notes from Thomas who
> >> asked by file_library() method is removed. Yes, it is confusing and it
> >> is better to avoid it. Usage of feature-based checks would allow to
> >> preserve find_library() as well.
> >
> > Thank you for the explanation.
> > In this case we want to check that the libbpf library is <=v0.8.0. At this
> moment in time v0.8.0 is the latest version of libbpf so we cannot check for a
> symbol that tells us the library is > v0.8.0. Can you think of a way to approach
> this without using the pkg-config version check method?
> >
> > I've introduced this check to future-proof the PMD and ensure we only
> ever link with versions of libbpf that we've validated to be compatible with
> the PMD. When say v0.9.0 is released we can patch the PMD allowing for
> libbpf <= v0.9.0 and make any necessary API changes as part of that patch.
> This should hopefully help avoid the scenario Thomas encountered.
> 
> Personally I'd consider such checks which limit version as a drawback.
> I think checks on build should not be used to reject future versions.
> Otherwise, introduction of any further even minor version would require
> a patch to allow it. Documentation is the place for information about
> validated versions. Build should not enforce it.

Got it. I'll submit a v2 which removes the version-limiting and reinstates the cc.find_library() method. I'll update the documentation to indicate only versions up to v0.8.0 are supported and add a note to the release notes.
Although if it's too late in the release cycle we can postpone this patch until after, and simply patch the docs stating that only libbpf <=v0.7.0 is supported for now?

Next release we can move away from the pkg-config version-checking method which already exists for other features, and replace with the symbol checking method.

Thanks,
Ciara


^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v2] net/af_xdp: make compatible with libbpf v0.8.0
  2022-06-24 10:23 [PATCH] net/af_xdp: make compatible with libbpf v0.8.0 Ciara Loftus
  2022-06-24 11:45 ` Andrew Rybchenko
@ 2022-06-28 12:18 ` Ciara Loftus
  2022-10-05  9:50 ` [PATCH v3 0/6] " Andrew Rybchenko
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 35+ messages in thread
From: Ciara Loftus @ 2022-06-28 12:18 UTC (permalink / raw)
  To: dev; +Cc: andrew.rybchenko, ferruh.yigit, thomas, Ciara Loftus

libbpf v0.8.0 deprecates the bpf_get_link_xdp_id and bpf_set_link_xdp_fd
functions. Use meson to detect if libbpf >= v0.7.0 is linked and if so, use
the recommended replacement functions bpf_xdp_query_id, bpf_xdp_attach
and bpf_xdp_detach which are available to use since libbpf v0.7.0.

Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
---
v2:
* Updated release notes
* Removed version limiting to libbpf v0.8.0
---
 doc/guides/nics/af_xdp.rst             |  3 ++-
 doc/guides/rel_notes/release_22_07.rst |  4 +++
 drivers/net/af_xdp/compat.h            | 36 +++++++++++++++++++++++++-
 drivers/net/af_xdp/meson.build         |  2 +-
 drivers/net/af_xdp/rte_eth_af_xdp.c    | 19 +++-----------
 5 files changed, 45 insertions(+), 19 deletions(-)

diff --git a/doc/guides/nics/af_xdp.rst b/doc/guides/nics/af_xdp.rst
index d42e0f1f79..ca23940e22 100644
--- a/doc/guides/nics/af_xdp.rst
+++ b/doc/guides/nics/af_xdp.rst
@@ -45,7 +45,8 @@ Prerequisites
 This is a Linux-specific PMD, thus the following prerequisites apply:
 
 *  A Linux Kernel (version > v4.18) with XDP sockets configuration enabled;
-*  Both libxdp >=v1.2.2 and libbpf libraries installed, or, libbpf <=v0.6.0
+*  Both libxdp >=v1.2.2 and libbpf <=v0.8.0 libraries installed, or, libbpf
+   <=v0.6.0.
 *  If using libxdp, it requires an environment variable called
    LIBXDP_OBJECT_PATH to be set to the location of where libxdp placed its bpf
    object files. This is usually in /usr/local/lib/bpf or /usr/local/lib64/bpf.
diff --git a/doc/guides/rel_notes/release_22_07.rst b/doc/guides/rel_notes/release_22_07.rst
index 6365800313..562d12abb2 100644
--- a/doc/guides/rel_notes/release_22_07.rst
+++ b/doc/guides/rel_notes/release_22_07.rst
@@ -125,6 +125,10 @@ New Features
   * Added new devargs option ``max_conf_threads``
     defining the number of management threads for parallel configurations.
 
+* **Updated AF_XDP PMD.**
+
+  * Made compatible with libbpf v0.8.0 (when used with libxdp).
+
 * **Updated Amazon ena driver.**
 
   The new driver version (v2.7.0) includes:
diff --git a/drivers/net/af_xdp/compat.h b/drivers/net/af_xdp/compat.h
index 28ea64aeaa..8f4ac8b5ea 100644
--- a/drivers/net/af_xdp/compat.h
+++ b/drivers/net/af_xdp/compat.h
@@ -60,7 +60,7 @@ tx_syscall_needed(struct xsk_ring_prod *q __rte_unused)
 }
 #endif
 
-#ifdef RTE_NET_AF_XDP_LIBBPF_OBJ_OPEN
+#ifdef RTE_NET_AF_XDP_LIBBPF_V070
 static int load_program(const char *prog_path, struct bpf_object **obj)
 {
 	struct bpf_program *prog;
@@ -85,6 +85,23 @@ static int load_program(const char *prog_path, struct bpf_object **obj)
 	bpf_object__close(*obj);
 	return -1;
 }
+
+static int
+remove_xdp_program(int ifindex)
+{
+	uint32_t curr_prog_id = 0;
+
+	if (bpf_xdp_query_id(ifindex, XDP_FLAGS_UPDATE_IF_NOEXIST,
+				&curr_prog_id))
+		return -1;
+
+	return bpf_xdp_detach(ifindex, XDP_FLAGS_UPDATE_IF_NOEXIST, NULL);
+}
+
+static int link_xdp_prog_with_dev(int ifindex, int fd, __u32 flags)
+{
+	return bpf_xdp_attach(ifindex, fd, flags, NULL);
+}
 #else
 static int load_program(const char *prog_path, struct bpf_object **obj)
 {
@@ -96,4 +113,21 @@ static int load_program(const char *prog_path, struct bpf_object **obj)
 
 	return prog_fd;
 }
+
+static int
+remove_xdp_program(int ifindex)
+{
+	uint32_t curr_prog_id = 0;
+
+	if (bpf_get_link_xdp_id(ifindex, &curr_prog_id,
+				XDP_FLAGS_UPDATE_IF_NOEXIST))
+		return -1;
+
+	return bpf_set_link_xdp_fd(ifindex, -1, XDP_FLAGS_UPDATE_IF_NOEXIST);
+}
+
+static int link_xdp_prog_with_dev(int ifindex, int fd, __u32 flags)
+{
+	return bpf_set_link_xdp_fd(ifindex, fd, flags);
+}
 #endif
diff --git a/drivers/net/af_xdp/meson.build b/drivers/net/af_xdp/meson.build
index 1e0de23705..6075a69c00 100644
--- a/drivers/net/af_xdp/meson.build
+++ b/drivers/net/af_xdp/meson.build
@@ -25,7 +25,7 @@ if cc.has_header('linux/if_xdp.h')
             bpf_ver_dep = dependency('libbpf', version : '>=0.7.0',
                                  required: false, method: 'pkg-config')
             if bpf_ver_dep.found()
-                cflags += ['-DRTE_NET_AF_XDP_LIBBPF_OBJ_OPEN']
+                cflags += ['-DRTE_NET_AF_XDP_LIBBPF_V070']
             endif
         else
             build = false
diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index fce649c2a1..355130087a 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -866,20 +866,6 @@ eth_stats_reset(struct rte_eth_dev *dev)
 	return 0;
 }
 
-static void
-remove_xdp_program(struct pmd_internals *internals)
-{
-	uint32_t curr_prog_id = 0;
-
-	if (bpf_get_link_xdp_id(internals->if_index, &curr_prog_id,
-				XDP_FLAGS_UPDATE_IF_NOEXIST)) {
-		AF_XDP_LOG(ERR, "bpf_get_link_xdp_id failed\n");
-		return;
-	}
-	bpf_set_link_xdp_fd(internals->if_index, -1,
-			XDP_FLAGS_UPDATE_IF_NOEXIST);
-}
-
 static void
 xdp_umem_destroy(struct xsk_umem_info *umem)
 {
@@ -932,7 +918,8 @@ eth_dev_close(struct rte_eth_dev *dev)
 	 */
 	dev->data->mac_addrs = NULL;
 
-	remove_xdp_program(internals);
+	if (remove_xdp_program(internals->if_index))
+		AF_XDP_LOG(ERR, "Error while removing XDP program.\n");
 
 	if (internals->shared_umem) {
 		struct internal_list *list;
@@ -1198,7 +1185,7 @@ load_custom_xdp_prog(const char *prog_path, int if_index, struct bpf_map **map)
 	}
 
 	/* Link the program with the given network device */
-	ret = bpf_set_link_xdp_fd(if_index, prog_fd,
+	ret = link_xdp_prog_with_dev(if_index, prog_fd,
 					XDP_FLAGS_UPDATE_IF_NOEXIST);
 	if (ret) {
 		AF_XDP_LOG(ERR, "Failed to set prog fd %d on interface\n",
-- 
2.25.1


^ permalink raw reply	[flat|nested] 35+ messages in thread

* RE: [PATCH] net/af_xdp: make compatible with libbpf v0.8.0
  2022-06-28 10:07           ` Loftus, Ciara
@ 2022-07-21 12:16             ` Loftus, Ciara
  0 siblings, 0 replies; 35+ messages in thread
From: Loftus, Ciara @ 2022-07-21 12:16 UTC (permalink / raw)
  To: Andrew Rybchenko, dev; +Cc: thomas, ferruh.yigit

> 
> > >>>>
> > >>>> On 6/24/22 13:23, Ciara Loftus wrote:
> > >>>>> libbpf v0.8.0 deprecates the bpf_get_link_xdp_id and
> > >> bpf_set_link_xdp_fd
> > >>>>> functions. Use meson to detect if libbpf >= v0.7.0 is linked and if so,
> > use
> > >>>>> the recommended replacement functions bpf_xdp_query_id,
> > >>>> bpf_xdp_attach
> > >>>>> and bpf_xdp_detach which are available to use since libbpf v0.7.0.
> > >>>>>
> > >>>>> Also prevent linking with libbpf versions > v0.8.0.
> > >>>>>
> > >>>>> Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
> > >>>>> ---
> > >>>>>     doc/guides/nics/af_xdp.rst          |  3 ++-
> > >>>>>     drivers/net/af_xdp/compat.h         | 36
> > >>>> ++++++++++++++++++++++++++++-
> > >>>>>     drivers/net/af_xdp/meson.build      |  7 ++----
> > >>>>>     drivers/net/af_xdp/rte_eth_af_xdp.c | 19 +++------------
> > >>>>>     4 files changed, 42 insertions(+), 23 deletions(-)
> > >>>>
> > >>>> Don't we need to mention these changes in release notes?
> > >>>>
> > >>>>>
> > >>>>> diff --git a/doc/guides/nics/af_xdp.rst b/doc/guides/nics/af_xdp.rst
> > >>>>> index 56681c8365..9edb48df67 100644
> > >>>>> --- a/doc/guides/nics/af_xdp.rst
> > >>>>> +++ b/doc/guides/nics/af_xdp.rst
> > >>>>> @@ -43,7 +43,8 @@ Prerequisites
> > >>>>>     This is a Linux-specific PMD, thus the following prerequisites
> apply:
> > >>>>>
> > >>>>>     *  A Linux Kernel (version > v4.18) with XDP sockets configuration
> > >> enabled;
> > >>>>> -*  Both libxdp >=v1.2.2 and libbpf libraries installed, or, libbpf
> > <=v0.6.0
> > >>>>> +*  Both libxdp >=v1.2.2 and libbpf <=v0.8.0 libraries installed, or,
> > libbpf
> > >>>>> +   <=v0.6.0.
> > >>>>>     *  If using libxdp, it requires an environment variable called
> > >>>>>        LIBXDP_OBJECT_PATH to be set to the location of where libxdp
> > >> placed its
> > >>>> bpf
> > >>>>>        object files. This is usually in /usr/local/lib/bpf or
> > /usr/local/lib64/bpf.
> > >>>>> diff --git a/drivers/net/af_xdp/compat.h
> > >> b/drivers/net/af_xdp/compat.h
> > >>>>> index 28ea64aeaa..8f4ac8b5ea 100644
> > >>>>> --- a/drivers/net/af_xdp/compat.h
> > >>>>> +++ b/drivers/net/af_xdp/compat.h
> > >>>>> @@ -60,7 +60,7 @@ tx_syscall_needed(struct xsk_ring_prod *q
> > >>>> __rte_unused)
> > >>>>>     }
> > >>>>>     #endif
> > >>>>>
> > >>>>> -#ifdef RTE_NET_AF_XDP_LIBBPF_OBJ_OPEN
> > >>>>> +#ifdef RTE_NET_AF_XDP_LIBBPF_V070
> > >>>>
> > >>>> Typically version-based checks are considered as bad. Isn't it
> > >>>> better use feature-based checks/defines?
> > >>>
> > >>> Hi Andrew,
> > >>>
> > >>> Thank you for the feedback. Is the feature-based checking something
> > that
> > >> we can push to the next release?
> > >>>
> > >>> We are already using the pkg-config version-check method for other
> > >> libraries/features in the meson.build file:
> > >>> * libxdp >= v1.2.2 # earliest compatible libxdp release
> > >>> * libbpf >= v0.7.0 # bpf_object__* functions
> > >>> * libbpf >= v0.2.0 # shared umem feature
> > >>>
> > >>> If we change to your suggested method I think we should change
> them
> > all
> > >> in one patch. IMO it's probably too close to the release to change them
> all
> > >> right now. What do you think?
> > >>>
> > >>> Thanks,
> > >>> Ciara
> > >>
> > >> Hi Ciara,
> > >>
> > >> yes, ideally we should avoid usage of version-based check everywhere,
> > >> but I don't think that it is critical to switch at once. We can use it
> > >> for new checks right now and rewrite old/existing checks a bit later in
> > >> the next release.
> > >>
> > >> Please, note that my notes are related to review notes from Thomas
> who
> > >> asked by file_library() method is removed. Yes, it is confusing and it
> > >> is better to avoid it. Usage of feature-based checks would allow to
> > >> preserve find_library() as well.
> > >
> > > Thank you for the explanation.
> > > In this case we want to check that the libbpf library is <=v0.8.0. At this
> > moment in time v0.8.0 is the latest version of libbpf so we cannot check for
> a
> > symbol that tells us the library is > v0.8.0. Can you think of a way to
> approach
> > this without using the pkg-config version check method?
> > >
> > > I've introduced this check to future-proof the PMD and ensure we only
> > ever link with versions of libbpf that we've validated to be compatible with
> > the PMD. When say v0.9.0 is released we can patch the PMD allowing for
> > libbpf <= v0.9.0 and make any necessary API changes as part of that patch.
> > This should hopefully help avoid the scenario Thomas encountered.
> >
> > Personally I'd consider such checks which limit version as a drawback.
> > I think checks on build should not be used to reject future versions.
> > Otherwise, introduction of any further even minor version would require
> > a patch to allow it. Documentation is the place for information about
> > validated versions. Build should not enforce it.
> 
> Got it. I'll submit a v2 which removes the version-limiting and reinstates the
> cc.find_library() method. I'll update the documentation to indicate only
> versions up to v0.8.0 are supported and add a note to the release notes.
> Although if it's too late in the release cycle we can postpone this patch until
> after, and simply patch the docs stating that only libbpf <=v0.7.0 is supported
> for now?
> 
> Next release we can move away from the pkg-config version-checking
> method which already exists for other features, and replace with the symbol
> checking method.

I've submitted an RFC for this feature: http://patches.dpdk.org/project/dpdk/list/?series=24043
I'm starting maternity leave next week so am not in a position to rework it in the near future, but if it is functionality that a community member finds useful perhaps they can pick it up in my absence.

Thanks,
Ciara

> 
> Thanks,
> Ciara


^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v3 0/6] net/af_xdp: make compatible with libbpf v0.8.0
  2022-06-24 10:23 [PATCH] net/af_xdp: make compatible with libbpf v0.8.0 Ciara Loftus
  2022-06-24 11:45 ` Andrew Rybchenko
  2022-06-28 12:18 ` [PATCH v2] " Ciara Loftus
@ 2022-10-05  9:50 ` Andrew Rybchenko
  2022-10-05  9:50   ` [PATCH v3] mempool: fix get objects from mempool with cache Andrew Rybchenko
                     ` (6 more replies)
  2022-10-06  6:26 ` [PATCH v4 0/6] " Andrew Rybchenko
  2022-12-20 14:05 ` [PATCH] " Kevin Traynor
  4 siblings, 7 replies; 35+ messages in thread
From: Andrew Rybchenko @ 2022-10-05  9:50 UTC (permalink / raw)
  To: Ciara Loftus, Qi Zhang; +Cc: dev

Update net/af_xdp build to support libbfp v0.8.0.
Avoid library version based checks, check for function presense
instead.

v3:
    - avoid version-based checks

Andrew Rybchenko (5):
  net/af_xdp: move XDP library presence flag to right branch
  net/af_xdp: make it clear which libxdp version is required
  net/af_xdp: avoid version-based check for shared UMEM
  net/af_xdp: avoid version-based check for program load mech
  net/af_xdp: log errors on XDP program removal failures

Ciara Loftus (1):
  net/af_xdp: make compatible with libbpf v0.8.0

 doc/guides/nics/af_xdp.rst             |  3 +-
 doc/guides/rel_notes/release_22_11.rst |  4 ++
 drivers/net/af_xdp/meson.build         | 47 +++++++++++++-------
 drivers/net/af_xdp/rte_eth_af_xdp.c    | 59 ++++++++++++++++++++++----
 4 files changed, 88 insertions(+), 25 deletions(-)

-- 
2.30.2


^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v3] mempool: fix get objects from mempool with cache
  2022-10-05  9:50 ` [PATCH v3 0/6] " Andrew Rybchenko
@ 2022-10-05  9:50   ` Andrew Rybchenko
  2022-10-05  9:56     ` Andrew Rybchenko
  2022-10-05  9:50   ` [PATCH v3 1/6] net/af_xdp: move XDP library presence flag to right branch Andrew Rybchenko
                     ` (5 subsequent siblings)
  6 siblings, 1 reply; 35+ messages in thread
From: Andrew Rybchenko @ 2022-10-05  9:50 UTC (permalink / raw)
  To: Olivier Matz
  Cc: dev, Morten Brørup, Beilei Xing, Bruce Richardson,
	Jerin Jacob Kollanukkaran

From: Morten Brørup <mb@smartsharesystems.com>

A flush threshold for the mempool cache was introduced in DPDK version
1.3, but rte_mempool_do_generic_get() was not completely updated back
then, and some inefficiencies were introduced.

Fix the following in rte_mempool_do_generic_get():

1. The code that initially screens the cache request was not updated
with the change in DPDK version 1.3.
The initial screening compared the request length to the cache size,
which was correct before, but became irrelevant with the introduction of
the flush threshold. E.g. the cache can hold up to flushthresh objects,
which is more than its size, so some requests were not served from the
cache, even though they could be.
The initial screening has now been corrected to match the initial
screening in rte_mempool_do_generic_put(), which verifies that a cache
is present, and that the length of the request does not overflow the
memory allocated for the cache.

This bug caused a major performance degradation in scenarios where the
application burst length is the same as the cache size. In such cases,
the objects were not ever fetched from the mempool cache, regardless if
they could have been.
This scenario occurs e.g. if an application has configured a mempool
with a size matching the application's burst size.

2. The function is a helper for rte_mempool_generic_get(), so it must
behave according to the description of that function.
Specifically, objects must first be returned from the cache,
subsequently from the ring.
After the change in DPDK version 1.3, this was not the behavior when
the request was partially satisfied from the cache; instead, the objects
from the ring were returned ahead of the objects from the cache.
This bug degraded application performance on CPUs with a small L1 cache,
which benefit from having the hot objects first in the returned array.
(This is probably also the reason why the function returns the objects
in reverse order, which it still does.)
Now, all code paths first return objects from the cache, subsequently
from the ring.

The function was not behaving as described (by the function using it)
and expected by applications using it. This in itself is also a bug.

3. If the cache could not be backfilled, the function would attempt
to get all the requested objects from the ring (instead of only the
number of requested objects minus the objects available in the ring),
and the function would fail if that failed.
Now, the first part of the request is always satisfied from the cache,
and if the subsequent backfilling of the cache from the ring fails, only
the remaining requested objects are retrieved from the ring.

The function would fail despite there are enough objects in the cache
plus the common pool.

4. The code flow for satisfying the request from the cache was slightly
inefficient:
The likely code path where the objects are simply served from the cache
was treated as unlikely. Now it is treated as likely.

Signed-off-by: Morten Brørup <mb@smartsharesystems.com>
Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
v3 changes (Andrew Rybchenko)
 - Always get first objects from the cache even if request is bigger
   than cache size. Remove one corresponding condition from the path
   when request is fully served from cache.
 - Simplify code to avoid duplication:
    - Get objects directly from backend in single place only.
    - Share code which gets from the cache first regardless if
      everythihg is obtained from the cache or just the first part.
 - Rollback cache length in unlikely failure branch to avoid cache
   vs NULL check in success branch.

v2 changes
- Do not modify description of return value. This belongs in a separate
doc fix.
- Elaborate even more on which bugs the modifications fix.

 lib/mempool/rte_mempool.h | 74 +++++++++++++++++++++++++--------------
 1 file changed, 48 insertions(+), 26 deletions(-)

diff --git a/lib/mempool/rte_mempool.h b/lib/mempool/rte_mempool.h
index a3c4ee351d..58e41ed401 100644
--- a/lib/mempool/rte_mempool.h
+++ b/lib/mempool/rte_mempool.h
@@ -1443,41 +1443,54 @@ rte_mempool_do_generic_get(struct rte_mempool *mp, void **obj_table,
 			   unsigned int n, struct rte_mempool_cache *cache)
 {
 	int ret;
+	unsigned int remaining = n;
 	uint32_t index, len;
 	void **cache_objs;
 
-	/* No cache provided or cannot be satisfied from cache */
-	if (unlikely(cache == NULL || n >= cache->size))
+	/* No cache provided */
+	if (unlikely(cache == NULL))
 		goto ring_dequeue;
 
-	cache_objs = cache->objs;
+	/* Use the cache as much as we have to return hot objects first */
+	len = RTE_MIN(remaining, cache->len);
+	cache_objs = &cache->objs[cache->len];
+	cache->len -= len;
+	remaining -= len;
+	for (index = 0; index < len; index++)
+		*obj_table++ = *--cache_objs;
 
-	/* Can this be satisfied from the cache? */
-	if (cache->len < n) {
-		/* No. Backfill the cache first, and then fill from it */
-		uint32_t req = n + (cache->size - cache->len);
+	if (remaining == 0) {
+		/* The entire request is satisfied from the cache. */
 
-		/* How many do we require i.e. number to fill the cache + the request */
-		ret = rte_mempool_ops_dequeue_bulk(mp,
-			&cache->objs[cache->len], req);
-		if (unlikely(ret < 0)) {
-			/*
-			 * In the off chance that we are buffer constrained,
-			 * where we are not able to allocate cache + n, go to
-			 * the ring directly. If that fails, we are truly out of
-			 * buffers.
-			 */
-			goto ring_dequeue;
-		}
+		RTE_MEMPOOL_STAT_ADD(mp, get_success_bulk, 1);
+		RTE_MEMPOOL_STAT_ADD(mp, get_success_objs, n);
 
-		cache->len += req;
+		return 0;
 	}
 
-	/* Now fill in the response ... */
-	for (index = 0, len = cache->len - 1; index < n; ++index, len--, obj_table++)
-		*obj_table = cache_objs[len];
+	/* if dequeue below would overflow mem allocated for cache */
+	if (unlikely(remaining > RTE_MEMPOOL_CACHE_MAX_SIZE))
+		goto ring_dequeue;
 
-	cache->len -= n;
+	/* Fill the cache from the ring; fetch size + remaining objects. */
+	ret = rte_mempool_ops_dequeue_bulk(mp, cache->objs,
+			cache->size + remaining);
+	if (unlikely(ret < 0)) {
+		/*
+		 * We are buffer constrained, and not able to allocate
+		 * cache + remaining.
+		 * Do not fill the cache, just satisfy the remaining part of
+		 * the request directly from the ring.
+		 */
+		goto ring_dequeue;
+	}
+
+	/* Satisfy the remaining part of the request from the filled cache. */
+	cache_objs = &cache->objs[cache->size + remaining];
+	for (index = 0; index < remaining; index++)
+		*obj_table++ = *--cache_objs;
+
+	cache->len = cache->size;
 
 	RTE_MEMPOOL_STAT_ADD(mp, get_success_bulk, 1);
 	RTE_MEMPOOL_STAT_ADD(mp, get_success_objs, n);
@@ -1486,10 +1499,19 @@ rte_mempool_do_generic_get(struct rte_mempool *mp, void **obj_table,
 
 ring_dequeue:
 
-	/* get remaining objects from ring */
-	ret = rte_mempool_ops_dequeue_bulk(mp, obj_table, n);
+	/* Get the objects directly from the ring. */
+	ret = rte_mempool_ops_dequeue_bulk(mp, obj_table, remaining);
 
 	if (ret < 0) {
+		if (cache != NULL) {
+			cache->len = n - remaining;
+			/*
+			 * No further action is required to roll the first part
+			 * of the request back into the cache, as objects in
+			 * the cache are intact.
+			 */
+		}
+
 		RTE_MEMPOOL_STAT_ADD(mp, get_fail_bulk, 1);
 		RTE_MEMPOOL_STAT_ADD(mp, get_fail_objs, n);
 	} else {
-- 
2.30.2


^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v3 1/6] net/af_xdp: move XDP library presence flag to right branch
  2022-10-05  9:50 ` [PATCH v3 0/6] " Andrew Rybchenko
  2022-10-05  9:50   ` [PATCH v3] mempool: fix get objects from mempool with cache Andrew Rybchenko
@ 2022-10-05  9:50   ` Andrew Rybchenko
  2022-10-05  9:50   ` [PATCH v3 2/6] net/af_xdp: make it clear which libxdp version is required Andrew Rybchenko
                     ` (4 subsequent siblings)
  6 siblings, 0 replies; 35+ messages in thread
From: Andrew Rybchenko @ 2022-10-05  9:50 UTC (permalink / raw)
  To: Ciara Loftus, Qi Zhang; +Cc: dev

RTE_NET_AF_XDP_LIBXDP is a conditional to include xdp/xsk.h and should
be set as soon as we know that the header is present.
RTE_NET_AF_XDP_SHARED_UMEM is one of conditions to use
xsk_socket__create_shared().
Both do not depend on libbpf and bpf/bpf.h presence.

Since else branch below returns error, there is no functional changes,
just style which will help on further rework.

Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
 drivers/net/af_xdp/meson.build | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/af_xdp/meson.build b/drivers/net/af_xdp/meson.build
index 1e0de23705..882d0b9518 100644
--- a/drivers/net/af_xdp/meson.build
+++ b/drivers/net/af_xdp/meson.build
@@ -17,10 +17,10 @@ endif
 
 if cc.has_header('linux/if_xdp.h')
     if xdp_dep.found() and cc.has_header('xdp/xsk.h')
+        cflags += ['-DRTE_NET_AF_XDP_LIBXDP']
+        cflags += ['-DRTE_NET_AF_XDP_SHARED_UMEM']
+        ext_deps += xdp_dep
         if bpf_dep.found() and cc.has_header('bpf/bpf.h')
-            cflags += ['-DRTE_NET_AF_XDP_LIBXDP']
-            cflags += ['-DRTE_NET_AF_XDP_SHARED_UMEM']
-            ext_deps += xdp_dep
             ext_deps += bpf_dep
             bpf_ver_dep = dependency('libbpf', version : '>=0.7.0',
                                  required: false, method: 'pkg-config')
-- 
2.30.2


^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v3 2/6] net/af_xdp: make it clear which libxdp version is required
  2022-10-05  9:50 ` [PATCH v3 0/6] " Andrew Rybchenko
  2022-10-05  9:50   ` [PATCH v3] mempool: fix get objects from mempool with cache Andrew Rybchenko
  2022-10-05  9:50   ` [PATCH v3 1/6] net/af_xdp: move XDP library presence flag to right branch Andrew Rybchenko
@ 2022-10-05  9:50   ` Andrew Rybchenko
  2022-10-05  9:50   ` [PATCH v3 3/6] net/af_xdp: avoid version-based check for shared UMEM Andrew Rybchenko
                     ` (3 subsequent siblings)
  6 siblings, 0 replies; 35+ messages in thread
From: Andrew Rybchenko @ 2022-10-05  9:50 UTC (permalink / raw)
  To: Ciara Loftus, Qi Zhang; +Cc: dev

Include checked libxdp version in driver build skip reason.

Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
 drivers/net/af_xdp/meson.build | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/af_xdp/meson.build b/drivers/net/af_xdp/meson.build
index 882d0b9518..fa011c357d 100644
--- a/drivers/net/af_xdp/meson.build
+++ b/drivers/net/af_xdp/meson.build
@@ -9,7 +9,8 @@ endif
 
 sources = files('rte_eth_af_xdp.c')
 
-xdp_dep = dependency('libxdp', version : '>=1.2.2', required: false, method: 'pkg-config')
+libxdp_ver = '>=1.2.2'
+xdp_dep = dependency('libxdp', version : libxdp_ver, required: false, method: 'pkg-config')
 bpf_dep = dependency('libbpf', required: false, method: 'pkg-config')
 if not bpf_dep.found()
     bpf_dep = cc.find_library('bpf', required: false)
@@ -45,11 +46,11 @@ if cc.has_header('linux/if_xdp.h')
             endif
         else
             build = false
-            reason = 'missing dependency, "libxdp" or "libbpf <= v0.6.0"'
+            reason = 'missing dependency, "libxdp ' + libxdp_ver + '" or "libbpf <= v0.6.0"'
         endif
     else
         build = false
-        reason = 'missing dependency, "libxdp" and "libbpf"'
+        reason = 'missing dependency, "libxdp ' + libxdp_ver + '" and "libbpf"'
     endif
 else
     build = false
-- 
2.30.2


^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v3 3/6] net/af_xdp: avoid version-based check for shared UMEM
  2022-10-05  9:50 ` [PATCH v3 0/6] " Andrew Rybchenko
                     ` (2 preceding siblings ...)
  2022-10-05  9:50   ` [PATCH v3 2/6] net/af_xdp: make it clear which libxdp version is required Andrew Rybchenko
@ 2022-10-05  9:50   ` Andrew Rybchenko
  2022-10-05  9:50   ` [PATCH v3 4/6] net/af_xdp: avoid version-based check for program load mech Andrew Rybchenko
                     ` (2 subsequent siblings)
  6 siblings, 0 replies; 35+ messages in thread
From: Andrew Rybchenko @ 2022-10-05  9:50 UTC (permalink / raw)
  To: Ciara Loftus, Qi Zhang; +Cc: dev

Check for xsk_socket__create_shared() function instead.

Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
 drivers/net/af_xdp/meson.build | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/net/af_xdp/meson.build b/drivers/net/af_xdp/meson.build
index fa011c357d..a01a67c7e7 100644
--- a/drivers/net/af_xdp/meson.build
+++ b/drivers/net/af_xdp/meson.build
@@ -19,7 +19,6 @@ endif
 if cc.has_header('linux/if_xdp.h')
     if xdp_dep.found() and cc.has_header('xdp/xsk.h')
         cflags += ['-DRTE_NET_AF_XDP_LIBXDP']
-        cflags += ['-DRTE_NET_AF_XDP_SHARED_UMEM']
         ext_deps += xdp_dep
         if bpf_dep.found() and cc.has_header('bpf/bpf.h')
             ext_deps += bpf_dep
@@ -39,11 +38,6 @@ if cc.has_header('linux/if_xdp.h')
                                  required: false, method: 'pkg-config')
         if bpf_ver_dep.found()
             ext_deps += bpf_dep
-            bpf_shumem_ver_dep = dependency('libbpf', version : '>=0.2.0',
-                            required: false, method: 'pkg-config')
-            if bpf_shumem_ver_dep.found()
-                cflags += ['-DRTE_NET_AF_XDP_SHARED_UMEM']
-            endif
         else
             build = false
             reason = 'missing dependency, "libxdp ' + libxdp_ver + '" or "libbpf <= v0.6.0"'
@@ -56,3 +50,18 @@ else
     build = false
     reason = 'missing header, "linux/if_xdp.h"'
 endif
+
+if build
+  xsk_check_prefix = '''
+#ifdef RTE_NET_AF_XDP_LIBXDP
+#include <xdp/xsk.h>
+#else
+#include <bpf/xsk.h>
+#endif
+  '''
+
+  if cc.has_function('xsk_socket__create_shared', prefix : xsk_check_prefix,
+                     dependencies : ext_deps)
+      cflags += ['-DRTE_NET_AF_XDP_SHARED_UMEM']
+  endif
+endif
-- 
2.30.2


^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v3 4/6] net/af_xdp: avoid version-based check for program load mech
  2022-10-05  9:50 ` [PATCH v3 0/6] " Andrew Rybchenko
                     ` (3 preceding siblings ...)
  2022-10-05  9:50   ` [PATCH v3 3/6] net/af_xdp: avoid version-based check for shared UMEM Andrew Rybchenko
@ 2022-10-05  9:50   ` Andrew Rybchenko
  2022-10-05  9:50   ` [PATCH v3 5/6] net/af_xdp: log errors on XDP program removal failures Andrew Rybchenko
  2022-10-05  9:50   ` [PATCH v3 6/6] net/af_xdp: make compatible with libbpf v0.8.0 Andrew Rybchenko
  6 siblings, 0 replies; 35+ messages in thread
From: Andrew Rybchenko @ 2022-10-05  9:50 UTC (permalink / raw)
  To: Ciara Loftus, Qi Zhang; +Cc: dev

Version-based checks are bad. It is better to check for required
functions. Check for bpf_object__next_program() in this case since
it appears last in libbpf among functions used to load program
without bpf_prog_load() which is deprecated in libbpf v0.7.0.

Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
 drivers/net/af_xdp/meson.build | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/af_xdp/meson.build b/drivers/net/af_xdp/meson.build
index a01a67c7e7..9d5ffab96b 100644
--- a/drivers/net/af_xdp/meson.build
+++ b/drivers/net/af_xdp/meson.build
@@ -22,11 +22,6 @@ if cc.has_header('linux/if_xdp.h')
         ext_deps += xdp_dep
         if bpf_dep.found() and cc.has_header('bpf/bpf.h')
             ext_deps += bpf_dep
-            bpf_ver_dep = dependency('libbpf', version : '>=0.7.0',
-                                 required: false, method: 'pkg-config')
-            if bpf_ver_dep.found()
-                cflags += ['-DRTE_NET_AF_XDP_LIBBPF_OBJ_OPEN']
-            endif
         else
             build = false
             reason = 'missing dependency, libbpf'
@@ -64,4 +59,9 @@ if build
                      dependencies : ext_deps)
       cflags += ['-DRTE_NET_AF_XDP_SHARED_UMEM']
   endif
+  if cc.has_function('bpf_object__next_program',
+                     prefix : '#include <bpf/libbpf.h>',
+                     dependencies : bpf_dep)
+      cflags += ['-DRTE_NET_AF_XDP_LIBBPF_OBJ_OPEN']
+  endif
 endif
-- 
2.30.2


^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v3 5/6] net/af_xdp: log errors on XDP program removal failures
  2022-10-05  9:50 ` [PATCH v3 0/6] " Andrew Rybchenko
                     ` (4 preceding siblings ...)
  2022-10-05  9:50   ` [PATCH v3 4/6] net/af_xdp: avoid version-based check for program load mech Andrew Rybchenko
@ 2022-10-05  9:50   ` Andrew Rybchenko
  2022-10-05  9:50   ` [PATCH v3 6/6] net/af_xdp: make compatible with libbpf v0.8.0 Andrew Rybchenko
  6 siblings, 0 replies; 35+ messages in thread
From: Andrew Rybchenko @ 2022-10-05  9:50 UTC (permalink / raw)
  To: Ciara Loftus, Qi Zhang; +Cc: dev

Make it visible in logs if something goes wrong on XDP program
removal failure.

Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
 drivers/net/af_xdp/rte_eth_af_xdp.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index 9957de2314..f7c2321a18 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -866,18 +866,24 @@ eth_stats_reset(struct rte_eth_dev *dev)
 	return 0;
 }
 
-static void
+static int
 remove_xdp_program(struct pmd_internals *internals)
 {
 	uint32_t curr_prog_id = 0;
+	int ret;
 
-	if (bpf_get_link_xdp_id(internals->if_index, &curr_prog_id,
-				XDP_FLAGS_UPDATE_IF_NOEXIST)) {
+	ret = bpf_get_link_xdp_id(internals->if_index, &curr_prog_id,
+				  XDP_FLAGS_UPDATE_IF_NOEXIST);
+	if (ret != 0) {
 		AF_XDP_LOG(ERR, "bpf_get_link_xdp_id failed\n");
-		return;
+		return ret;
 	}
-	bpf_set_link_xdp_fd(internals->if_index, -1,
-			XDP_FLAGS_UPDATE_IF_NOEXIST);
+
+	ret = bpf_set_link_xdp_fd(internals->if_index, -1,
+				  XDP_FLAGS_UPDATE_IF_NOEXIST);
+	if (ret != 0)
+		AF_XDP_LOG(ERR, "bpf_set_link_xdp_fd failed\n");
+	return ret;
 }
 
 static void
@@ -932,7 +938,8 @@ eth_dev_close(struct rte_eth_dev *dev)
 	 */
 	dev->data->mac_addrs = NULL;
 
-	remove_xdp_program(internals);
+	if (remove_xdp_program(internals) != 0)
+		AF_XDP_LOG(ERR, "Error while removing XDP program.\n");
 
 	if (internals->shared_umem) {
 		struct internal_list *list;
-- 
2.30.2


^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v3 6/6] net/af_xdp: make compatible with libbpf v0.8.0
  2022-10-05  9:50 ` [PATCH v3 0/6] " Andrew Rybchenko
                     ` (5 preceding siblings ...)
  2022-10-05  9:50   ` [PATCH v3 5/6] net/af_xdp: log errors on XDP program removal failures Andrew Rybchenko
@ 2022-10-05  9:50   ` Andrew Rybchenko
  6 siblings, 0 replies; 35+ messages in thread
From: Andrew Rybchenko @ 2022-10-05  9:50 UTC (permalink / raw)
  To: Ciara Loftus, Qi Zhang; +Cc: dev

From: Ciara Loftus <ciara.loftus@intel.com>

libbpf v0.8.0 deprecates the bpf_get_link_xdp_id() and
bpf_set_link_xdp_fd() functions. Use meson to detect if
bpf_xdp_attach() is available and if so, use the recommended
replacement functions bpf_xdp_query_id(), bpf_xdp_attach()
and bpf_xdp_detach().

Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
 doc/guides/nics/af_xdp.rst             |  3 +-
 doc/guides/rel_notes/release_22_11.rst |  4 +++
 drivers/net/af_xdp/meson.build         |  5 ++++
 drivers/net/af_xdp/rte_eth_af_xdp.c    | 38 +++++++++++++++++++++++++-
 4 files changed, 48 insertions(+), 2 deletions(-)

diff --git a/doc/guides/nics/af_xdp.rst b/doc/guides/nics/af_xdp.rst
index d42e0f1f79..ca23940e22 100644
--- a/doc/guides/nics/af_xdp.rst
+++ b/doc/guides/nics/af_xdp.rst
@@ -45,7 +45,8 @@ Prerequisites
 This is a Linux-specific PMD, thus the following prerequisites apply:
 
 *  A Linux Kernel (version > v4.18) with XDP sockets configuration enabled;
-*  Both libxdp >=v1.2.2 and libbpf libraries installed, or, libbpf <=v0.6.0
+*  Both libxdp >=v1.2.2 and libbpf <=v0.8.0 libraries installed, or, libbpf
+   <=v0.6.0.
 *  If using libxdp, it requires an environment variable called
    LIBXDP_OBJECT_PATH to be set to the location of where libxdp placed its bpf
    object files. This is usually in /usr/local/lib/bpf or /usr/local/lib64/bpf.
diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst
index 7e03388306..c1f18aecc9 100644
--- a/doc/guides/rel_notes/release_22_11.rst
+++ b/doc/guides/rel_notes/release_22_11.rst
@@ -78,6 +78,10 @@ New Features
   Added new rte_flow action which allows application to re-route packets
   directly to the kernel without software involvement.
 
+* **Updated AF_XDP PMD.**
+
+  * Made compatible with libbpf v0.8.0 (when used with libxdp).
+
 * **Updated Intel iavf driver.**
 
   * Added flow subscription support.
diff --git a/drivers/net/af_xdp/meson.build b/drivers/net/af_xdp/meson.build
index 9d5ffab96b..858047989e 100644
--- a/drivers/net/af_xdp/meson.build
+++ b/drivers/net/af_xdp/meson.build
@@ -64,4 +64,9 @@ if build
                      dependencies : bpf_dep)
       cflags += ['-DRTE_NET_AF_XDP_LIBBPF_OBJ_OPEN']
   endif
+  if cc.has_function('bpf_xdp_attach',
+                     prefix : '#include <bpf/libbpf.h>',
+                     dependencies : bpf_dep)
+      cflags += ['-DRTE_NET_AF_XDP_LIBBPF_XDP_ATTACH']
+  endif
 endif
diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index f7c2321a18..b6ec9bf490 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -866,6 +866,40 @@ eth_stats_reset(struct rte_eth_dev *dev)
 	return 0;
 }
 
+#ifdef RTE_NET_AF_XDP_LIBBPF_XDP_ATTACH
+
+static int link_xdp_prog_with_dev(int ifindex, int fd, __u32 flags)
+{
+	return bpf_xdp_attach(ifindex, fd, flags, NULL);
+}
+
+static int
+remove_xdp_program(struct pmd_internals *internals)
+{
+	uint32_t curr_prog_id = 0;
+	int ret;
+
+	ret = bpf_xdp_query_id(internals->if_index, XDP_FLAGS_UPDATE_IF_NOEXIST,
+			       &curr_prog_id);
+	if (ret != 0) {
+		AF_XDP_LOG(ERR, "bpf_xdp_query_id failed\n");
+		return ret;
+	}
+
+	ret = bpf_xdp_detach(internals->if_index, XDP_FLAGS_UPDATE_IF_NOEXIST,
+			     NULL);
+	if (ret != 0)
+		AF_XDP_LOG(ERR, "bpf_xdp_detach failed\n");
+	return ret;
+}
+
+#else
+
+static int link_xdp_prog_with_dev(int ifindex, int fd, __u32 flags)
+{
+	return bpf_set_link_xdp_fd(ifindex, fd, flags);
+}
+
 static int
 remove_xdp_program(struct pmd_internals *internals)
 {
@@ -886,6 +920,8 @@ remove_xdp_program(struct pmd_internals *internals)
 	return ret;
 }
 
+#endif
+
 static void
 xdp_umem_destroy(struct xsk_umem_info *umem)
 {
@@ -1205,7 +1241,7 @@ load_custom_xdp_prog(const char *prog_path, int if_index, struct bpf_map **map)
 	}
 
 	/* Link the program with the given network device */
-	ret = bpf_set_link_xdp_fd(if_index, prog_fd,
+	ret = link_xdp_prog_with_dev(if_index, prog_fd,
 					XDP_FLAGS_UPDATE_IF_NOEXIST);
 	if (ret) {
 		AF_XDP_LOG(ERR, "Failed to set prog fd %d on interface\n",
-- 
2.30.2


^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH v3] mempool: fix get objects from mempool with cache
  2022-10-05  9:50   ` [PATCH v3] mempool: fix get objects from mempool with cache Andrew Rybchenko
@ 2022-10-05  9:56     ` Andrew Rybchenko
  0 siblings, 0 replies; 35+ messages in thread
From: Andrew Rybchenko @ 2022-10-05  9:56 UTC (permalink / raw)
  To: Olivier Matz
  Cc: dev, Morten Brørup, Beilei Xing, Bruce Richardson,
	Jerin Jacob Kollanukkaran

I'm sorry, below duplicate is sent my mistake.

On 10/5/22 12:50, Andrew Rybchenko wrote:
> From: Morten Brørup <mb@smartsharesystems.com>
> 
> A flush threshold for the mempool cache was introduced in DPDK version
> 1.3, but rte_mempool_do_generic_get() was not completely updated back
> then, and some inefficiencies were introduced.
> 
> Fix the following in rte_mempool_do_generic_get():
> 
> 1. The code that initially screens the cache request was not updated
> with the change in DPDK version 1.3.
> The initial screening compared the request length to the cache size,
> which was correct before, but became irrelevant with the introduction of
> the flush threshold. E.g. the cache can hold up to flushthresh objects,
> which is more than its size, so some requests were not served from the
> cache, even though they could be.
> The initial screening has now been corrected to match the initial
> screening in rte_mempool_do_generic_put(), which verifies that a cache
> is present, and that the length of the request does not overflow the
> memory allocated for the cache.
> 
> This bug caused a major performance degradation in scenarios where the
> application burst length is the same as the cache size. In such cases,
> the objects were not ever fetched from the mempool cache, regardless if
> they could have been.
> This scenario occurs e.g. if an application has configured a mempool
> with a size matching the application's burst size.
> 
> 2. The function is a helper for rte_mempool_generic_get(), so it must
> behave according to the description of that function.
> Specifically, objects must first be returned from the cache,
> subsequently from the ring.
> After the change in DPDK version 1.3, this was not the behavior when
> the request was partially satisfied from the cache; instead, the objects
> from the ring were returned ahead of the objects from the cache.
> This bug degraded application performance on CPUs with a small L1 cache,
> which benefit from having the hot objects first in the returned array.
> (This is probably also the reason why the function returns the objects
> in reverse order, which it still does.)
> Now, all code paths first return objects from the cache, subsequently
> from the ring.
> 
> The function was not behaving as described (by the function using it)
> and expected by applications using it. This in itself is also a bug.
> 
> 3. If the cache could not be backfilled, the function would attempt
> to get all the requested objects from the ring (instead of only the
> number of requested objects minus the objects available in the ring),
> and the function would fail if that failed.
> Now, the first part of the request is always satisfied from the cache,
> and if the subsequent backfilling of the cache from the ring fails, only
> the remaining requested objects are retrieved from the ring.
> 
> The function would fail despite there are enough objects in the cache
> plus the common pool.
> 
> 4. The code flow for satisfying the request from the cache was slightly
> inefficient:
> The likely code path where the objects are simply served from the cache
> was treated as unlikely. Now it is treated as likely.
> 
> Signed-off-by: Morten Brørup <mb@smartsharesystems.com>
> Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> ---
> v3 changes (Andrew Rybchenko)
>   - Always get first objects from the cache even if request is bigger
>     than cache size. Remove one corresponding condition from the path
>     when request is fully served from cache.
>   - Simplify code to avoid duplication:
>      - Get objects directly from backend in single place only.
>      - Share code which gets from the cache first regardless if
>        everythihg is obtained from the cache or just the first part.
>   - Rollback cache length in unlikely failure branch to avoid cache
>     vs NULL check in success branch.
> 
> v2 changes
> - Do not modify description of return value. This belongs in a separate
> doc fix.
> - Elaborate even more on which bugs the modifications fix.
> 
>   lib/mempool/rte_mempool.h | 74 +++++++++++++++++++++++++--------------
>   1 file changed, 48 insertions(+), 26 deletions(-)
> 


^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v4 0/6] net/af_xdp: make compatible with libbpf v0.8.0
  2022-06-24 10:23 [PATCH] net/af_xdp: make compatible with libbpf v0.8.0 Ciara Loftus
                   ` (2 preceding siblings ...)
  2022-10-05  9:50 ` [PATCH v3 0/6] " Andrew Rybchenko
@ 2022-10-06  6:26 ` Andrew Rybchenko
  2022-10-06  6:26   ` [PATCH v4 1/6] net/af_xdp: move XDP library presence flag to right branch Andrew Rybchenko
                     ` (6 more replies)
  2022-12-20 14:05 ` [PATCH] " Kevin Traynor
  4 siblings, 7 replies; 35+ messages in thread
From: Andrew Rybchenko @ 2022-10-06  6:26 UTC (permalink / raw)
  To: Ciara Loftus, Qi Zhang; +Cc: dev, Bruce Richardson

Update net/af_xdp build to support libbfp v0.8.0.
Avoid library version based checks, check for function presense
instead.

v4:
    - just rebase
    - do not mention libbpf v0.8.0 as a strict limitation

v3:
    - avoid version-based checks

Andrew Rybchenko (5):
  net/af_xdp: move XDP library presence flag to right branch
  net/af_xdp: make it clear which libxdp version is required
  net/af_xdp: avoid version-based check for shared UMEM
  net/af_xdp: avoid version-based check for program load mech
  net/af_xdp: log errors on XDP program removal failures

Ciara Loftus (1):
  net/af_xdp: make compatible with libbpf v0.8.0

 doc/guides/rel_notes/release_22_11.rst |  4 ++
 drivers/net/af_xdp/meson.build         | 47 +++++++++++++-------
 drivers/net/af_xdp/rte_eth_af_xdp.c    | 59 ++++++++++++++++++++++----
 3 files changed, 86 insertions(+), 24 deletions(-)

-- 
2.30.2


^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v4 1/6] net/af_xdp: move XDP library presence flag to right branch
  2022-10-06  6:26 ` [PATCH v4 0/6] " Andrew Rybchenko
@ 2022-10-06  6:26   ` Andrew Rybchenko
  2022-10-06  6:26   ` [PATCH v4 2/6] net/af_xdp: make it clear which libxdp version is required Andrew Rybchenko
                     ` (5 subsequent siblings)
  6 siblings, 0 replies; 35+ messages in thread
From: Andrew Rybchenko @ 2022-10-06  6:26 UTC (permalink / raw)
  To: Ciara Loftus, Qi Zhang; +Cc: dev, Bruce Richardson

RTE_NET_AF_XDP_LIBXDP is a conditional to include xdp/xsk.h and should
be set as soon as we know that the header is present.
RTE_NET_AF_XDP_SHARED_UMEM is one of conditions to use
xsk_socket__create_shared().
Both do not depend on libbpf and bpf/bpf.h presence.

Since else branch below returns error, there is no functional changes,
just style which will help on further rework.

Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
 drivers/net/af_xdp/meson.build | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/af_xdp/meson.build b/drivers/net/af_xdp/meson.build
index 1e0de23705..882d0b9518 100644
--- a/drivers/net/af_xdp/meson.build
+++ b/drivers/net/af_xdp/meson.build
@@ -17,10 +17,10 @@ endif
 
 if cc.has_header('linux/if_xdp.h')
     if xdp_dep.found() and cc.has_header('xdp/xsk.h')
+        cflags += ['-DRTE_NET_AF_XDP_LIBXDP']
+        cflags += ['-DRTE_NET_AF_XDP_SHARED_UMEM']
+        ext_deps += xdp_dep
         if bpf_dep.found() and cc.has_header('bpf/bpf.h')
-            cflags += ['-DRTE_NET_AF_XDP_LIBXDP']
-            cflags += ['-DRTE_NET_AF_XDP_SHARED_UMEM']
-            ext_deps += xdp_dep
             ext_deps += bpf_dep
             bpf_ver_dep = dependency('libbpf', version : '>=0.7.0',
                                  required: false, method: 'pkg-config')
-- 
2.30.2


^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v4 2/6] net/af_xdp: make it clear which libxdp version is required
  2022-10-06  6:26 ` [PATCH v4 0/6] " Andrew Rybchenko
  2022-10-06  6:26   ` [PATCH v4 1/6] net/af_xdp: move XDP library presence flag to right branch Andrew Rybchenko
@ 2022-10-06  6:26   ` Andrew Rybchenko
  2022-10-06  6:26   ` [PATCH v4 3/6] net/af_xdp: avoid version-based check for shared UMEM Andrew Rybchenko
                     ` (4 subsequent siblings)
  6 siblings, 0 replies; 35+ messages in thread
From: Andrew Rybchenko @ 2022-10-06  6:26 UTC (permalink / raw)
  To: Ciara Loftus, Qi Zhang; +Cc: dev, Bruce Richardson

Include checked libxdp version in driver build skip reason.

Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
 drivers/net/af_xdp/meson.build | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/af_xdp/meson.build b/drivers/net/af_xdp/meson.build
index 882d0b9518..fa011c357d 100644
--- a/drivers/net/af_xdp/meson.build
+++ b/drivers/net/af_xdp/meson.build
@@ -9,7 +9,8 @@ endif
 
 sources = files('rte_eth_af_xdp.c')
 
-xdp_dep = dependency('libxdp', version : '>=1.2.2', required: false, method: 'pkg-config')
+libxdp_ver = '>=1.2.2'
+xdp_dep = dependency('libxdp', version : libxdp_ver, required: false, method: 'pkg-config')
 bpf_dep = dependency('libbpf', required: false, method: 'pkg-config')
 if not bpf_dep.found()
     bpf_dep = cc.find_library('bpf', required: false)
@@ -45,11 +46,11 @@ if cc.has_header('linux/if_xdp.h')
             endif
         else
             build = false
-            reason = 'missing dependency, "libxdp" or "libbpf <= v0.6.0"'
+            reason = 'missing dependency, "libxdp ' + libxdp_ver + '" or "libbpf <= v0.6.0"'
         endif
     else
         build = false
-        reason = 'missing dependency, "libxdp" and "libbpf"'
+        reason = 'missing dependency, "libxdp ' + libxdp_ver + '" and "libbpf"'
     endif
 else
     build = false
-- 
2.30.2


^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v4 3/6] net/af_xdp: avoid version-based check for shared UMEM
  2022-10-06  6:26 ` [PATCH v4 0/6] " Andrew Rybchenko
  2022-10-06  6:26   ` [PATCH v4 1/6] net/af_xdp: move XDP library presence flag to right branch Andrew Rybchenko
  2022-10-06  6:26   ` [PATCH v4 2/6] net/af_xdp: make it clear which libxdp version is required Andrew Rybchenko
@ 2022-10-06  6:26   ` Andrew Rybchenko
  2022-10-06  6:26   ` [PATCH v4 4/6] net/af_xdp: avoid version-based check for program load mech Andrew Rybchenko
                     ` (3 subsequent siblings)
  6 siblings, 0 replies; 35+ messages in thread
From: Andrew Rybchenko @ 2022-10-06  6:26 UTC (permalink / raw)
  To: Ciara Loftus, Qi Zhang; +Cc: dev, Bruce Richardson

Check for xsk_socket__create_shared() function instead.

Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
 drivers/net/af_xdp/meson.build | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/net/af_xdp/meson.build b/drivers/net/af_xdp/meson.build
index fa011c357d..a01a67c7e7 100644
--- a/drivers/net/af_xdp/meson.build
+++ b/drivers/net/af_xdp/meson.build
@@ -19,7 +19,6 @@ endif
 if cc.has_header('linux/if_xdp.h')
     if xdp_dep.found() and cc.has_header('xdp/xsk.h')
         cflags += ['-DRTE_NET_AF_XDP_LIBXDP']
-        cflags += ['-DRTE_NET_AF_XDP_SHARED_UMEM']
         ext_deps += xdp_dep
         if bpf_dep.found() and cc.has_header('bpf/bpf.h')
             ext_deps += bpf_dep
@@ -39,11 +38,6 @@ if cc.has_header('linux/if_xdp.h')
                                  required: false, method: 'pkg-config')
         if bpf_ver_dep.found()
             ext_deps += bpf_dep
-            bpf_shumem_ver_dep = dependency('libbpf', version : '>=0.2.0',
-                            required: false, method: 'pkg-config')
-            if bpf_shumem_ver_dep.found()
-                cflags += ['-DRTE_NET_AF_XDP_SHARED_UMEM']
-            endif
         else
             build = false
             reason = 'missing dependency, "libxdp ' + libxdp_ver + '" or "libbpf <= v0.6.0"'
@@ -56,3 +50,18 @@ else
     build = false
     reason = 'missing header, "linux/if_xdp.h"'
 endif
+
+if build
+  xsk_check_prefix = '''
+#ifdef RTE_NET_AF_XDP_LIBXDP
+#include <xdp/xsk.h>
+#else
+#include <bpf/xsk.h>
+#endif
+  '''
+
+  if cc.has_function('xsk_socket__create_shared', prefix : xsk_check_prefix,
+                     dependencies : ext_deps)
+      cflags += ['-DRTE_NET_AF_XDP_SHARED_UMEM']
+  endif
+endif
-- 
2.30.2


^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v4 4/6] net/af_xdp: avoid version-based check for program load mech
  2022-10-06  6:26 ` [PATCH v4 0/6] " Andrew Rybchenko
                     ` (2 preceding siblings ...)
  2022-10-06  6:26   ` [PATCH v4 3/6] net/af_xdp: avoid version-based check for shared UMEM Andrew Rybchenko
@ 2022-10-06  6:26   ` Andrew Rybchenko
  2022-10-06  6:26   ` [PATCH v4 5/6] net/af_xdp: log errors on XDP program removal failures Andrew Rybchenko
                     ` (2 subsequent siblings)
  6 siblings, 0 replies; 35+ messages in thread
From: Andrew Rybchenko @ 2022-10-06  6:26 UTC (permalink / raw)
  To: Ciara Loftus, Qi Zhang; +Cc: dev, Bruce Richardson

Version-based checks are bad. It is better to check for required
functions. Check for bpf_object__next_program() in this case since
it appears last in libbpf among functions used to load program
without bpf_prog_load() which is deprecated in libbpf v0.7.0.

Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
 drivers/net/af_xdp/meson.build | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/af_xdp/meson.build b/drivers/net/af_xdp/meson.build
index a01a67c7e7..9d5ffab96b 100644
--- a/drivers/net/af_xdp/meson.build
+++ b/drivers/net/af_xdp/meson.build
@@ -22,11 +22,6 @@ if cc.has_header('linux/if_xdp.h')
         ext_deps += xdp_dep
         if bpf_dep.found() and cc.has_header('bpf/bpf.h')
             ext_deps += bpf_dep
-            bpf_ver_dep = dependency('libbpf', version : '>=0.7.0',
-                                 required: false, method: 'pkg-config')
-            if bpf_ver_dep.found()
-                cflags += ['-DRTE_NET_AF_XDP_LIBBPF_OBJ_OPEN']
-            endif
         else
             build = false
             reason = 'missing dependency, libbpf'
@@ -64,4 +59,9 @@ if build
                      dependencies : ext_deps)
       cflags += ['-DRTE_NET_AF_XDP_SHARED_UMEM']
   endif
+  if cc.has_function('bpf_object__next_program',
+                     prefix : '#include <bpf/libbpf.h>',
+                     dependencies : bpf_dep)
+      cflags += ['-DRTE_NET_AF_XDP_LIBBPF_OBJ_OPEN']
+  endif
 endif
-- 
2.30.2


^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v4 5/6] net/af_xdp: log errors on XDP program removal failures
  2022-10-06  6:26 ` [PATCH v4 0/6] " Andrew Rybchenko
                     ` (3 preceding siblings ...)
  2022-10-06  6:26   ` [PATCH v4 4/6] net/af_xdp: avoid version-based check for program load mech Andrew Rybchenko
@ 2022-10-06  6:26   ` Andrew Rybchenko
  2022-10-06  6:26   ` [PATCH v4 6/6] net/af_xdp: make compatible with libbpf v0.8.0 Andrew Rybchenko
  2022-10-07 17:40   ` [PATCH v4 0/6] " Ferruh Yigit
  6 siblings, 0 replies; 35+ messages in thread
From: Andrew Rybchenko @ 2022-10-06  6:26 UTC (permalink / raw)
  To: Ciara Loftus, Qi Zhang; +Cc: dev, Bruce Richardson

Make it visible in logs if something goes wrong on XDP program
removal failure.

Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
 drivers/net/af_xdp/rte_eth_af_xdp.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index 9957de2314..f7c2321a18 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -866,18 +866,24 @@ eth_stats_reset(struct rte_eth_dev *dev)
 	return 0;
 }
 
-static void
+static int
 remove_xdp_program(struct pmd_internals *internals)
 {
 	uint32_t curr_prog_id = 0;
+	int ret;
 
-	if (bpf_get_link_xdp_id(internals->if_index, &curr_prog_id,
-				XDP_FLAGS_UPDATE_IF_NOEXIST)) {
+	ret = bpf_get_link_xdp_id(internals->if_index, &curr_prog_id,
+				  XDP_FLAGS_UPDATE_IF_NOEXIST);
+	if (ret != 0) {
 		AF_XDP_LOG(ERR, "bpf_get_link_xdp_id failed\n");
-		return;
+		return ret;
 	}
-	bpf_set_link_xdp_fd(internals->if_index, -1,
-			XDP_FLAGS_UPDATE_IF_NOEXIST);
+
+	ret = bpf_set_link_xdp_fd(internals->if_index, -1,
+				  XDP_FLAGS_UPDATE_IF_NOEXIST);
+	if (ret != 0)
+		AF_XDP_LOG(ERR, "bpf_set_link_xdp_fd failed\n");
+	return ret;
 }
 
 static void
@@ -932,7 +938,8 @@ eth_dev_close(struct rte_eth_dev *dev)
 	 */
 	dev->data->mac_addrs = NULL;
 
-	remove_xdp_program(internals);
+	if (remove_xdp_program(internals) != 0)
+		AF_XDP_LOG(ERR, "Error while removing XDP program.\n");
 
 	if (internals->shared_umem) {
 		struct internal_list *list;
-- 
2.30.2


^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v4 6/6] net/af_xdp: make compatible with libbpf v0.8.0
  2022-10-06  6:26 ` [PATCH v4 0/6] " Andrew Rybchenko
                     ` (4 preceding siblings ...)
  2022-10-06  6:26   ` [PATCH v4 5/6] net/af_xdp: log errors on XDP program removal failures Andrew Rybchenko
@ 2022-10-06  6:26   ` Andrew Rybchenko
  2022-10-07 17:19     ` Ferruh Yigit
  2022-10-07 17:40   ` [PATCH v4 0/6] " Ferruh Yigit
  6 siblings, 1 reply; 35+ messages in thread
From: Andrew Rybchenko @ 2022-10-06  6:26 UTC (permalink / raw)
  To: Ciara Loftus, Qi Zhang; +Cc: dev, Bruce Richardson

From: Ciara Loftus <ciara.loftus@intel.com>

libbpf v0.8.0 deprecates the bpf_get_link_xdp_id() and
bpf_set_link_xdp_fd() functions. Use meson to detect if
bpf_xdp_attach() is available and if so, use the recommended
replacement functions bpf_xdp_query_id(), bpf_xdp_attach()
and bpf_xdp_detach().

Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
 doc/guides/rel_notes/release_22_11.rst |  4 +++
 drivers/net/af_xdp/meson.build         |  5 ++++
 drivers/net/af_xdp/rte_eth_af_xdp.c    | 38 +++++++++++++++++++++++++-
 3 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst
index f1cc129933..490186b992 100644
--- a/doc/guides/rel_notes/release_22_11.rst
+++ b/doc/guides/rel_notes/release_22_11.rst
@@ -78,6 +78,10 @@ New Features
   Added new rte_flow action which allows application to re-route packets
   directly to the kernel without software involvement.
 
+* **Updated AF_XDP PMD.**
+
+  * Made compatible with libbpf v0.8.0 (when used with libxdp).
+
 * **Updated Intel iavf driver.**
 
   * Added flow subscription support.
diff --git a/drivers/net/af_xdp/meson.build b/drivers/net/af_xdp/meson.build
index 9d5ffab96b..858047989e 100644
--- a/drivers/net/af_xdp/meson.build
+++ b/drivers/net/af_xdp/meson.build
@@ -64,4 +64,9 @@ if build
                      dependencies : bpf_dep)
       cflags += ['-DRTE_NET_AF_XDP_LIBBPF_OBJ_OPEN']
   endif
+  if cc.has_function('bpf_xdp_attach',
+                     prefix : '#include <bpf/libbpf.h>',
+                     dependencies : bpf_dep)
+      cflags += ['-DRTE_NET_AF_XDP_LIBBPF_XDP_ATTACH']
+  endif
 endif
diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index f7c2321a18..b6ec9bf490 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -866,6 +866,40 @@ eth_stats_reset(struct rte_eth_dev *dev)
 	return 0;
 }
 
+#ifdef RTE_NET_AF_XDP_LIBBPF_XDP_ATTACH
+
+static int link_xdp_prog_with_dev(int ifindex, int fd, __u32 flags)
+{
+	return bpf_xdp_attach(ifindex, fd, flags, NULL);
+}
+
+static int
+remove_xdp_program(struct pmd_internals *internals)
+{
+	uint32_t curr_prog_id = 0;
+	int ret;
+
+	ret = bpf_xdp_query_id(internals->if_index, XDP_FLAGS_UPDATE_IF_NOEXIST,
+			       &curr_prog_id);
+	if (ret != 0) {
+		AF_XDP_LOG(ERR, "bpf_xdp_query_id failed\n");
+		return ret;
+	}
+
+	ret = bpf_xdp_detach(internals->if_index, XDP_FLAGS_UPDATE_IF_NOEXIST,
+			     NULL);
+	if (ret != 0)
+		AF_XDP_LOG(ERR, "bpf_xdp_detach failed\n");
+	return ret;
+}
+
+#else
+
+static int link_xdp_prog_with_dev(int ifindex, int fd, __u32 flags)
+{
+	return bpf_set_link_xdp_fd(ifindex, fd, flags);
+}
+
 static int
 remove_xdp_program(struct pmd_internals *internals)
 {
@@ -886,6 +920,8 @@ remove_xdp_program(struct pmd_internals *internals)
 	return ret;
 }
 
+#endif
+
 static void
 xdp_umem_destroy(struct xsk_umem_info *umem)
 {
@@ -1205,7 +1241,7 @@ load_custom_xdp_prog(const char *prog_path, int if_index, struct bpf_map **map)
 	}
 
 	/* Link the program with the given network device */
-	ret = bpf_set_link_xdp_fd(if_index, prog_fd,
+	ret = link_xdp_prog_with_dev(if_index, prog_fd,
 					XDP_FLAGS_UPDATE_IF_NOEXIST);
 	if (ret) {
 		AF_XDP_LOG(ERR, "Failed to set prog fd %d on interface\n",
-- 
2.30.2


^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH v4 6/6] net/af_xdp: make compatible with libbpf v0.8.0
  2022-10-06  6:26   ` [PATCH v4 6/6] net/af_xdp: make compatible with libbpf v0.8.0 Andrew Rybchenko
@ 2022-10-07 17:19     ` Ferruh Yigit
  2022-10-07 17:28       ` Ferruh Yigit
  0 siblings, 1 reply; 35+ messages in thread
From: Ferruh Yigit @ 2022-10-07 17:19 UTC (permalink / raw)
  To: Andrew Rybchenko, Ciara Loftus, Qi Zhang; +Cc: dev, Bruce Richardson

On 10/6/2022 7:26 AM, Andrew Rybchenko wrote:
> From: Ciara Loftus <ciara.loftus@intel.com>
> 
> libbpf v0.8.0 deprecates the bpf_get_link_xdp_id() and
> bpf_set_link_xdp_fd() functions. Use meson to detect if
> bpf_xdp_attach() is available and if so, use the recommended
> replacement functions bpf_xdp_query_id(), bpf_xdp_attach()
> and bpf_xdp_detach().
> 
> Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
> Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>

<...>

> diff --git a/drivers/net/af_xdp/meson.build b/drivers/net/af_xdp/meson.build
> index 9d5ffab96b..858047989e 100644
> --- a/drivers/net/af_xdp/meson.build
> +++ b/drivers/net/af_xdp/meson.build
> @@ -64,4 +64,9 @@ if build
>                        dependencies : bpf_dep)
>         cflags += ['-DRTE_NET_AF_XDP_LIBBPF_OBJ_OPEN']
>     endif
> +  if cc.has_function('bpf_xdp_attach',
> +                     prefix : '#include <bpf/libbpf.h>',
> +                     dependencies : bpf_dep)
> +      cflags += ['-DRTE_NET_AF_XDP_LIBBPF_XDP_ATTACH']
> +  endif

meson is not detecting functions, I am getting following log, any idea 
what is going wrong:

Run-time dependency libxdp found: YES 1.2.2
Run-time dependency libbpf found: YES 0.8.1
Has header "linux/if_xdp.h" : YES
Has header "xdp/xsk.h" : YES
Has header "bpf/bpf.h" : YES
Checking for function "xsk_socket__create_shared" with dependencies 
libxdp, libbpf: NO
Checking for function "bpf_object__next_program" with dependency libbpf: NO
Checking for function "bpf_xdp_attach" with dependency libbpf: NO


^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH v4 6/6] net/af_xdp: make compatible with libbpf v0.8.0
  2022-10-07 17:19     ` Ferruh Yigit
@ 2022-10-07 17:28       ` Ferruh Yigit
  0 siblings, 0 replies; 35+ messages in thread
From: Ferruh Yigit @ 2022-10-07 17:28 UTC (permalink / raw)
  To: Andrew Rybchenko, Ciara Loftus, Qi Zhang; +Cc: dev, Bruce Richardson

On 10/7/2022 6:19 PM, Ferruh Yigit wrote:
> On 10/6/2022 7:26 AM, Andrew Rybchenko wrote:
>> From: Ciara Loftus <ciara.loftus@intel.com>
>>
>> libbpf v0.8.0 deprecates the bpf_get_link_xdp_id() and
>> bpf_set_link_xdp_fd() functions. Use meson to detect if
>> bpf_xdp_attach() is available and if so, use the recommended
>> replacement functions bpf_xdp_query_id(), bpf_xdp_attach()
>> and bpf_xdp_detach().
>>
>> Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
>> Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> 
> <...>
> 
>> diff --git a/drivers/net/af_xdp/meson.build 
>> b/drivers/net/af_xdp/meson.build
>> index 9d5ffab96b..858047989e 100644
>> --- a/drivers/net/af_xdp/meson.build
>> +++ b/drivers/net/af_xdp/meson.build
>> @@ -64,4 +64,9 @@ if build
>>                        dependencies : bpf_dep)
>>         cflags += ['-DRTE_NET_AF_XDP_LIBBPF_OBJ_OPEN']
>>     endif
>> +  if cc.has_function('bpf_xdp_attach',
>> +                     prefix : '#include <bpf/libbpf.h>',
>> +                     dependencies : bpf_dep)
>> +      cflags += ['-DRTE_NET_AF_XDP_LIBBPF_XDP_ATTACH']
>> +  endif
> 
> meson is not detecting functions, I am getting following log, any idea 
> what is going wrong:
> 
> Run-time dependency libxdp found: YES 1.2.2
> Run-time dependency libbpf found: YES 0.8.1
> Has header "linux/if_xdp.h" : YES
> Has header "xdp/xsk.h" : YES
> Has header "bpf/bpf.h" : YES
> Checking for function "xsk_socket__create_shared" with dependencies 
> libxdp, libbpf: NO
> Checking for function "bpf_object__next_program" with dependency libbpf: NO
> Checking for function "bpf_xdp_attach" with dependency libbpf: NO
> 

It is OK, this was my environment issue, libbpf.so permission was wrong 
although I compile and installed from source, anyway latest log:

Run-time dependency libxdp found: YES 1.2.2
Run-time dependency libbpf found: YES 0.8.1
Has header "linux/if_xdp.h" : YES
Has header "xdp/xsk.h" : YES
Has header "bpf/bpf.h" : YES
Checking for function "xsk_socket__create_shared" with dependencies 
libxdp, libbpf: YES
Checking for function "bpf_object__next_program" with dependency libbpf: 
YES
Checking for function "bpf_xdp_attach" with dependency libbpf: YES

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH v4 0/6] net/af_xdp: make compatible with libbpf v0.8.0
  2022-10-06  6:26 ` [PATCH v4 0/6] " Andrew Rybchenko
                     ` (5 preceding siblings ...)
  2022-10-06  6:26   ` [PATCH v4 6/6] net/af_xdp: make compatible with libbpf v0.8.0 Andrew Rybchenko
@ 2022-10-07 17:40   ` Ferruh Yigit
  6 siblings, 0 replies; 35+ messages in thread
From: Ferruh Yigit @ 2022-10-07 17:40 UTC (permalink / raw)
  To: Andrew Rybchenko, Ciara Loftus, Qi Zhang; +Cc: dev, Bruce Richardson

On 10/6/2022 7:26 AM, Andrew Rybchenko wrote:
> Update net/af_xdp build to support libbfp v0.8.0.
> Avoid library version based checks, check for function presense
> instead.
> 
> v4:
>      - just rebase
>      - do not mention libbpf v0.8.0 as a strict limitation
> 
> v3:
>      - avoid version-based checks
> 
> Andrew Rybchenko (5):
>    net/af_xdp: move XDP library presence flag to right branch
>    net/af_xdp: make it clear which libxdp version is required
>    net/af_xdp: avoid version-based check for shared UMEM
>    net/af_xdp: avoid version-based check for program load mech
>    net/af_xdp: log errors on XDP program removal failures
> 
> Ciara Loftus (1):
>    net/af_xdp: make compatible with libbpf v0.8.0
> 

For series,
Reviewed-by: Ferruh Yigit <ferruh.yigit@amd.com>

Series applied to dpdk-next-net/main, thanks.


^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH] net/af_xdp: make compatible with libbpf v0.8.0
  2022-06-24 10:23 [PATCH] net/af_xdp: make compatible with libbpf v0.8.0 Ciara Loftus
                   ` (3 preceding siblings ...)
  2022-10-06  6:26 ` [PATCH v4 0/6] " Andrew Rybchenko
@ 2022-12-20 14:05 ` Kevin Traynor
  2022-12-21  6:09   ` Andrew Rybchenko
  4 siblings, 1 reply; 35+ messages in thread
From: Kevin Traynor @ 2022-12-20 14:05 UTC (permalink / raw)
  To: Ciara Loftus, dev, Andrew Rybchenko, Zhang, Qi Z; +Cc: thomas, ferruh.yigit

On 24/06/2022 11:23, Ciara Loftus wrote:
> libbpf v0.8.0 deprecates the bpf_get_link_xdp_id and bpf_set_link_xdp_fd
> functions. Use meson to detect if libbpf >= v0.7.0 is linked and if so, use
> the recommended replacement functions bpf_xdp_query_id, bpf_xdp_attach
> and bpf_xdp_detach which are available to use since libbpf v0.7.0.
> 
> Also prevent linking with libbpf versions > v0.8.0.
> 
> Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>

Hi Andrew/Qi (assuming Ciara is still out of office),

I am seeing a similar issue [1] on 21.11 branch with Fedora 37
(libbpf-0.8.0-2.fc37.x86_64 and libxdp-1.2.6-1.fc37.x86_64).

This patch alone won't apply as there are other dependencies. Looking at 
the commits in main branch, it seems like I could take all these [2] to 
resolve the issue. With these cherry-picked the build warnings on Fedora 
37 are removed.

It's a bit late to take these for DPDK 21.11.3 as I intend to release 
later today/tomorrow, so it can be resolved for DPDK 21.11.4.

Do the commits below look ok for backport? Main branch might be able to 
demand user uses new libbpf/libxdp versions etc, but with stable we 
never want to break the users existing setup when they upgrade from 
2X.11.n to 2X.11.n+1.

Let me know what you think?

thanks,
Kevin.

[1] https://paste.centos.org/view/e4eec764
[2]
1eb1846b1a net/af_xdp: make compatible with libbpf 0.8.0
5ff3dbe6ce net/af_xdp: add log on XDP program removal failures
0ed0bc3834 net/af_xdp: avoid version-based check for program load
e024c7e838 net/af_xdp: avoid version-based check for shared UMEM
f76dc44ded net/af_xdp: make clear which libxdp version is required
50b855fc47 net/af_xdp: move XDP library presence flag setting


^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH] net/af_xdp: make compatible with libbpf v0.8.0
  2022-12-20 14:05 ` [PATCH] " Kevin Traynor
@ 2022-12-21  6:09   ` Andrew Rybchenko
  2022-12-21  9:28     ` Kevin Traynor
  0 siblings, 1 reply; 35+ messages in thread
From: Andrew Rybchenko @ 2022-12-21  6:09 UTC (permalink / raw)
  To: Kevin Traynor, Ciara Loftus, dev, Zhang, Qi Z; +Cc: thomas, ferruh.yigit

Hi Kevin,

On 12/20/22 17:05, Kevin Traynor wrote:
> On 24/06/2022 11:23, Ciara Loftus wrote:
>> libbpf v0.8.0 deprecates the bpf_get_link_xdp_id and bpf_set_link_xdp_fd
>> functions. Use meson to detect if libbpf >= v0.7.0 is linked and if 
>> so, use
>> the recommended replacement functions bpf_xdp_query_id, bpf_xdp_attach
>> and bpf_xdp_detach which are available to use since libbpf v0.7.0.
>>
>> Also prevent linking with libbpf versions > v0.8.0.
>>
>> Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
> 
> Hi Andrew/Qi (assuming Ciara is still out of office),
> 
> I am seeing a similar issue [1] on 21.11 branch with Fedora 37
> (libbpf-0.8.0-2.fc37.x86_64 and libxdp-1.2.6-1.fc37.x86_64).
> 
> This patch alone won't apply as there are other dependencies. Looking at 
> the commits in main branch, it seems like I could take all these [2] to 
> resolve the issue. With these cherry-picked the build warnings on Fedora 
> 37 are removed.
> 
> It's a bit late to take these for DPDK 21.11.3 as I intend to release 
> later today/tomorrow, so it can be resolved for DPDK 21.11.4.
> 
> Do the commits below look ok for backport? Main branch might be able to 
> demand user uses new libbpf/libxdp versions etc, but with stable we 
> never want to break the users existing setup when they upgrade from 
> 2X.11.n to 2X.11.n+1.
> 
> Let me know what you think?

IMO these patches are to to be backported to stable branch.
However, af_xdp maintainers opinion is more important here.

> 
> thanks,
> Kevin.
> 
> [1] https://paste.centos.org/view/e4eec764
> [2]
> 1eb1846b1a net/af_xdp: make compatible with libbpf 0.8.0
> 5ff3dbe6ce net/af_xdp: add log on XDP program removal failures
> 0ed0bc3834 net/af_xdp: avoid version-based check for program load
> e024c7e838 net/af_xdp: avoid version-based check for shared UMEM
> f76dc44ded net/af_xdp: make clear which libxdp version is required
> 50b855fc47 net/af_xdp: move XDP library presence flag setting
> 


^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH] net/af_xdp: make compatible with libbpf v0.8.0
  2022-12-21  6:09   ` Andrew Rybchenko
@ 2022-12-21  9:28     ` Kevin Traynor
  2023-03-15 11:47       ` Kevin Traynor
  2023-04-04 15:51       ` Kevin Traynor
  0 siblings, 2 replies; 35+ messages in thread
From: Kevin Traynor @ 2022-12-21  9:28 UTC (permalink / raw)
  To: Andrew Rybchenko, Ciara Loftus, dev, Zhang, Qi Z; +Cc: thomas, ferruh.yigit

On 21/12/2022 06:09, Andrew Rybchenko wrote:
> Hi Kevin,
> 
> On 12/20/22 17:05, Kevin Traynor wrote:
>> On 24/06/2022 11:23, Ciara Loftus wrote:
>>> libbpf v0.8.0 deprecates the bpf_get_link_xdp_id and bpf_set_link_xdp_fd
>>> functions. Use meson to detect if libbpf >= v0.7.0 is linked and if
>>> so, use
>>> the recommended replacement functions bpf_xdp_query_id, bpf_xdp_attach
>>> and bpf_xdp_detach which are available to use since libbpf v0.7.0.
>>>
>>> Also prevent linking with libbpf versions > v0.8.0.
>>>
>>> Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
>>
>> Hi Andrew/Qi (assuming Ciara is still out of office),
>>
>> I am seeing a similar issue [1] on 21.11 branch with Fedora 37
>> (libbpf-0.8.0-2.fc37.x86_64 and libxdp-1.2.6-1.fc37.x86_64).
>>
>> This patch alone won't apply as there are other dependencies. Looking at
>> the commits in main branch, it seems like I could take all these [2] to
>> resolve the issue. With these cherry-picked the build warnings on Fedora
>> 37 are removed.
>>
>> It's a bit late to take these for DPDK 21.11.3 as I intend to release
>> later today/tomorrow, so it can be resolved for DPDK 21.11.4.
>>
>> Do the commits below look ok for backport? Main branch might be able to
>> demand user uses new libbpf/libxdp versions etc, but with stable we
>> never want to break the users existing setup when they upgrade from
>> 2X.11.n to 2X.11.n+1.
>>
>> Let me know what you think?
> 
> IMO these patches are to to be backported to stable branch.

Thanks Andrew.

> However, af_xdp maintainers opinion is more important here.
> 

Qi, what do you think?

>>
>> thanks,
>> Kevin.
>>
>> [1] https://paste.centos.org/view/e4eec764
>> [2]
>> 1eb1846b1a net/af_xdp: make compatible with libbpf 0.8.0
>> 5ff3dbe6ce net/af_xdp: add log on XDP program removal failures
>> 0ed0bc3834 net/af_xdp: avoid version-based check for program load
>> e024c7e838 net/af_xdp: avoid version-based check for shared UMEM
>> f76dc44ded net/af_xdp: make clear which libxdp version is required
>> 50b855fc47 net/af_xdp: move XDP library presence flag setting
>>
> 


^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH] net/af_xdp: make compatible with libbpf v0.8.0
  2022-12-21  9:28     ` Kevin Traynor
@ 2023-03-15 11:47       ` Kevin Traynor
  2023-03-16 13:31         ` Kevin Traynor
  2023-04-04 15:51       ` Kevin Traynor
  1 sibling, 1 reply; 35+ messages in thread
From: Kevin Traynor @ 2023-03-15 11:47 UTC (permalink / raw)
  To: Andrew Rybchenko, Ciara Loftus, dev, Zhang, Qi Z
  Cc: thomas, ferruh.yigit, David Marchand

On 21/12/2022 09:28, Kevin Traynor wrote:
> On 21/12/2022 06:09, Andrew Rybchenko wrote:
>> Hi Kevin,
>>
>> On 12/20/22 17:05, Kevin Traynor wrote:
>>> On 24/06/2022 11:23, Ciara Loftus wrote:
>>>> libbpf v0.8.0 deprecates the bpf_get_link_xdp_id and bpf_set_link_xdp_fd
>>>> functions. Use meson to detect if libbpf >= v0.7.0 is linked and if
>>>> so, use
>>>> the recommended replacement functions bpf_xdp_query_id, bpf_xdp_attach
>>>> and bpf_xdp_detach which are available to use since libbpf v0.7.0.
>>>>
>>>> Also prevent linking with libbpf versions > v0.8.0.
>>>>
>>>> Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
>>>
>>> Hi Andrew/Qi (assuming Ciara is still out of office),
>>>
>>> I am seeing a similar issue [1] on 21.11 branch with Fedora 37
>>> (libbpf-0.8.0-2.fc37.x86_64 and libxdp-1.2.6-1.fc37.x86_64).
>>>
>>> This patch alone won't apply as there are other dependencies. Looking at
>>> the commits in main branch, it seems like I could take all these [2] to
>>> resolve the issue. With these cherry-picked the build warnings on Fedora
>>> 37 are removed.
>>>
>>> It's a bit late to take these for DPDK 21.11.3 as I intend to release
>>> later today/tomorrow, so it can be resolved for DPDK 21.11.4.
>>>
>>> Do the commits below look ok for backport? Main branch might be able to
>>> demand user uses new libbpf/libxdp versions etc, but with stable we
>>> never want to break the users existing setup when they upgrade from
>>> 2X.11.n to 2X.11.n+1.

N.B. ^^^^

>>>
>>> Let me know what you think?
>>
>> IMO these patches are to to be backported to stable branch.
> 
> Thanks Andrew.
> 
>> However, af_xdp maintainers opinion is more important here.
>>
> 
> Qi, what do you think?
> 

Hi Qi/Ciara, this issue is still present approaching 21.11.4.

What is your opinion on backporting these patches? Please especially 
note the paragraph above wrt users not being required to upgrade libbpf.

thanks,
Kevin.

>>>
>>> thanks,
>>> Kevin.
>>>
>>> [1] https://paste.centos.org/view/e4eec764
>>> [2]
>>> 1eb1846b1a net/af_xdp: make compatible with libbpf 0.8.0
>>> 5ff3dbe6ce net/af_xdp: add log on XDP program removal failures
>>> 0ed0bc3834 net/af_xdp: avoid version-based check for program load
>>> e024c7e838 net/af_xdp: avoid version-based check for shared UMEM
>>> f76dc44ded net/af_xdp: make clear which libxdp version is required
>>> 50b855fc47 net/af_xdp: move XDP library presence flag setting
>>>
>>
> 


^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH] net/af_xdp: make compatible with libbpf v0.8.0
  2023-03-15 11:47       ` Kevin Traynor
@ 2023-03-16 13:31         ` Kevin Traynor
  2023-03-23 10:23           ` Kevin Traynor
  0 siblings, 1 reply; 35+ messages in thread
From: Kevin Traynor @ 2023-03-16 13:31 UTC (permalink / raw)
  To: Andrew Rybchenko, Ciara Loftus, dev, Zhang, Qi Z, shibin.koikkara.reeny
  Cc: thomas, ferruh.yigit, David Marchand

On 15/03/2023 11:47, Kevin Traynor wrote:
> On 21/12/2022 09:28, Kevin Traynor wrote:
>> On 21/12/2022 06:09, Andrew Rybchenko wrote:
>>> Hi Kevin,
>>>
>>> On 12/20/22 17:05, Kevin Traynor wrote:
>>>> On 24/06/2022 11:23, Ciara Loftus wrote:
>>>>> libbpf v0.8.0 deprecates the bpf_get_link_xdp_id and bpf_set_link_xdp_fd
>>>>> functions. Use meson to detect if libbpf >= v0.7.0 is linked and if
>>>>> so, use
>>>>> the recommended replacement functions bpf_xdp_query_id, bpf_xdp_attach
>>>>> and bpf_xdp_detach which are available to use since libbpf v0.7.0.
>>>>>
>>>>> Also prevent linking with libbpf versions > v0.8.0.
>>>>>
>>>>> Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
>>>>
>>>> Hi Andrew/Qi (assuming Ciara is still out of office),
>>>>
>>>> I am seeing a similar issue [1] on 21.11 branch with Fedora 37
>>>> (libbpf-0.8.0-2.fc37.x86_64 and libxdp-1.2.6-1.fc37.x86_64).
>>>>
>>>> This patch alone won't apply as there are other dependencies. Looking at
>>>> the commits in main branch, it seems like I could take all these [2] to
>>>> resolve the issue. With these cherry-picked the build warnings on Fedora
>>>> 37 are removed.
>>>>
>>>> It's a bit late to take these for DPDK 21.11.3 as I intend to release
>>>> later today/tomorrow, so it can be resolved for DPDK 21.11.4.
>>>>
>>>> Do the commits below look ok for backport? Main branch might be able to
>>>> demand user uses new libbpf/libxdp versions etc, but with stable we
>>>> never want to break the users existing setup when they upgrade from
>>>> 2X.11.n to 2X.11.n+1.
> 
> N.B. ^^^^
> 
>>>>
>>>> Let me know what you think?
>>>
>>> IMO these patches are to to be backported to stable branch.
>>
>> Thanks Andrew.
>>
>>> However, af_xdp maintainers opinion is more important here.
>>>
>>
>> Qi, what do you think?
>>
> 
> Hi Qi/Ciara, this issue is still present approaching 21.11.4.
> 
> What is your opinion on backporting these patches? Please especially
> note the paragraph above wrt users not being required to upgrade libbpf.
> 

+Shibin, following discussion in DPDK release meeting.

> thanks,
> Kevin.
> 
>>>>
>>>> thanks,
>>>> Kevin.
>>>>
>>>> [1] https://paste.centos.org/view/e4eec764
>>>> [2]
>>>> 1eb1846b1a net/af_xdp: make compatible with libbpf 0.8.0
>>>> 5ff3dbe6ce net/af_xdp: add log on XDP program removal failures
>>>> 0ed0bc3834 net/af_xdp: avoid version-based check for program load
>>>> e024c7e838 net/af_xdp: avoid version-based check for shared UMEM
>>>> f76dc44ded net/af_xdp: make clear which libxdp version is required
>>>> 50b855fc47 net/af_xdp: move XDP library presence flag setting
>>>>
>>>
>>
> 


^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH] net/af_xdp: make compatible with libbpf v0.8.0
  2023-03-16 13:31         ` Kevin Traynor
@ 2023-03-23 10:23           ` Kevin Traynor
  0 siblings, 0 replies; 35+ messages in thread
From: Kevin Traynor @ 2023-03-23 10:23 UTC (permalink / raw)
  To: Andrew Rybchenko, Ciara Loftus, dev, Zhang, Qi Z, shibin.koikkara.reeny
  Cc: thomas, ferruh.yigit, David Marchand, Mcnamara, John

+cc John

For better context, this part of the discussion starts here:
http://inbox.dpdk.org/dev/d718d0fe-09a2-8840-e8a4-dd41b732b391@redhat.com/

On 16/03/2023 13:31, Kevin Traynor wrote:
> On 15/03/2023 11:47, Kevin Traynor wrote:
>> On 21/12/2022 09:28, Kevin Traynor wrote:
>>> On 21/12/2022 06:09, Andrew Rybchenko wrote:
>>>> Hi Kevin,
>>>>
>>>> On 12/20/22 17:05, Kevin Traynor wrote:
>>>>> On 24/06/2022 11:23, Ciara Loftus wrote:
>>>>>> libbpf v0.8.0 deprecates the bpf_get_link_xdp_id and bpf_set_link_xdp_fd
>>>>>> functions. Use meson to detect if libbpf >= v0.7.0 is linked and if
>>>>>> so, use
>>>>>> the recommended replacement functions bpf_xdp_query_id, bpf_xdp_attach
>>>>>> and bpf_xdp_detach which are available to use since libbpf v0.7.0.
>>>>>>
>>>>>> Also prevent linking with libbpf versions > v0.8.0.
>>>>>>
>>>>>> Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
>>>>>
>>>>> Hi Andrew/Qi (assuming Ciara is still out of office),
>>>>>
>>>>> I am seeing a similar issue [1] on 21.11 branch with Fedora 37
>>>>> (libbpf-0.8.0-2.fc37.x86_64 and libxdp-1.2.6-1.fc37.x86_64).
>>>>>
>>>>> This patch alone won't apply as there are other dependencies. Looking at
>>>>> the commits in main branch, it seems like I could take all these [2] to
>>>>> resolve the issue. With these cherry-picked the build warnings on Fedora
>>>>> 37 are removed.
>>>>>
>>>>> It's a bit late to take these for DPDK 21.11.3 as I intend to release
>>>>> later today/tomorrow, so it can be resolved for DPDK 21.11.4.
>>>>>
>>>>> Do the commits below look ok for backport? Main branch might be able to
>>>>> demand user uses new libbpf/libxdp versions etc, but with stable we
>>>>> never want to break the users existing setup when they upgrade from
>>>>> 2X.11.n to 2X.11.n+1.
>>
>> N.B. ^^^^
>>
>>>>>
>>>>> Let me know what you think?
>>>>
>>>> IMO these patches are to to be backported to stable branch.
>>>
>>> Thanks Andrew.
>>>
>>>> However, af_xdp maintainers opinion is more important here.
>>>>
>>>
>>> Qi, what do you think?
>>>
>>
>> Hi Qi/Ciara, this issue is still present approaching 21.11.4.
>>
>> What is your opinion on backporting these patches? Please especially
>> note the paragraph above wrt users not being required to upgrade libbpf.
>>
> 
> +Shibin, following discussion in DPDK release meeting.
> 
>> thanks,
>> Kevin.
>>
>>>>>
>>>>> thanks,
>>>>> Kevin.
>>>>>
>>>>> [1] https://paste.centos.org/view/e4eec764
>>>>> [2]
>>>>> 1eb1846b1a net/af_xdp: make compatible with libbpf 0.8.0
>>>>> 5ff3dbe6ce net/af_xdp: add log on XDP program removal failures
>>>>> 0ed0bc3834 net/af_xdp: avoid version-based check for program load
>>>>> e024c7e838 net/af_xdp: avoid version-based check for shared UMEM
>>>>> f76dc44ded net/af_xdp: make clear which libxdp version is required
>>>>> 50b855fc47 net/af_xdp: move XDP library presence flag setting
>>>>>
>>>>
>>>
>>
> 


^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH] net/af_xdp: make compatible with libbpf v0.8.0
  2022-12-21  9:28     ` Kevin Traynor
  2023-03-15 11:47       ` Kevin Traynor
@ 2023-04-04 15:51       ` Kevin Traynor
  1 sibling, 0 replies; 35+ messages in thread
From: Kevin Traynor @ 2023-04-04 15:51 UTC (permalink / raw)
  To: Ciara Loftus, dev, Zhang, Qi Z
  Cc: thomas, ferruh.yigit, David Marchand, Mcnamara, John, Andrew Rybchenko

On 21/12/2022 09:28, Kevin Traynor wrote:
> On 21/12/2022 06:09, Andrew Rybchenko wrote:
>> Hi Kevin,
>>
>> On 12/20/22 17:05, Kevin Traynor wrote:
>>> On 24/06/2022 11:23, Ciara Loftus wrote:
>>>> libbpf v0.8.0 deprecates the bpf_get_link_xdp_id and bpf_set_link_xdp_fd
>>>> functions. Use meson to detect if libbpf >= v0.7.0 is linked and if
>>>> so, use
>>>> the recommended replacement functions bpf_xdp_query_id, bpf_xdp_attach
>>>> and bpf_xdp_detach which are available to use since libbpf v0.7.0.
>>>>
>>>> Also prevent linking with libbpf versions > v0.8.0.
>>>>
>>>> Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
>>>
>>> Hi Andrew/Qi (assuming Ciara is still out of office),
>>>
>>> I am seeing a similar issue [1] on 21.11 branch with Fedora 37
>>> (libbpf-0.8.0-2.fc37.x86_64 and libxdp-1.2.6-1.fc37.x86_64).
>>>
>>> This patch alone won't apply as there are other dependencies. Looking at
>>> the commits in main branch, it seems like I could take all these [2] to
>>> resolve the issue. With these cherry-picked the build warnings on Fedora
>>> 37 are removed.
>>>
>>> It's a bit late to take these for DPDK 21.11.3 as I intend to release
>>> later today/tomorrow, so it can be resolved for DPDK 21.11.4.
>>>
>>> Do the commits below look ok for backport? Main branch might be able to
>>> demand user uses new libbpf/libxdp versions etc, but with stable we
>>> never want to break the users existing setup when they upgrade from
>>> 2X.11.n to 2X.11.n+1.
>>>
>>> Let me know what you think?
>>
>> IMO these patches are to to be backported to stable branch.
> 
> Thanks Andrew.
> 
>> However, af_xdp maintainers opinion is more important here.
>>
> 
> Qi, what do you think?
> 

As F37 will be the oldest supported Fedora release from mid-May and 
there is no available af_xdp maintainers to comment on backports, I'm 
going to just squash the warnings [0] for 21.11.4.

If a better fix is available for 21.11.5+ please send patches to stable ML.

thanks,
Kevin.

[0] 
http://inbox.dpdk.org/stable/20230404153501.123038-1-ktraynor@redhat.com/

>>>
>>> thanks,
>>> Kevin.
>>>
>>> [1] https://paste.centos.org/view/e4eec764
>>> [2]
>>> 1eb1846b1a net/af_xdp: make compatible with libbpf 0.8.0
>>> 5ff3dbe6ce net/af_xdp: add log on XDP program removal failures
>>> 0ed0bc3834 net/af_xdp: avoid version-based check for program load
>>> e024c7e838 net/af_xdp: avoid version-based check for shared UMEM
>>> f76dc44ded net/af_xdp: make clear which libxdp version is required
>>> 50b855fc47 net/af_xdp: move XDP library presence flag setting
>>>
>>
> 


^ permalink raw reply	[flat|nested] 35+ messages in thread

end of thread, other threads:[~2023-04-04 15:51 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-24 10:23 [PATCH] net/af_xdp: make compatible with libbpf v0.8.0 Ciara Loftus
2022-06-24 11:45 ` Andrew Rybchenko
2022-06-27 14:17   ` Loftus, Ciara
2022-06-27 14:50     ` Andrew Rybchenko
2022-06-27 15:24       ` Loftus, Ciara
2022-06-28  9:15         ` Andrew Rybchenko
2022-06-28 10:07           ` Loftus, Ciara
2022-07-21 12:16             ` Loftus, Ciara
2022-06-28 12:18 ` [PATCH v2] " Ciara Loftus
2022-10-05  9:50 ` [PATCH v3 0/6] " Andrew Rybchenko
2022-10-05  9:50   ` [PATCH v3] mempool: fix get objects from mempool with cache Andrew Rybchenko
2022-10-05  9:56     ` Andrew Rybchenko
2022-10-05  9:50   ` [PATCH v3 1/6] net/af_xdp: move XDP library presence flag to right branch Andrew Rybchenko
2022-10-05  9:50   ` [PATCH v3 2/6] net/af_xdp: make it clear which libxdp version is required Andrew Rybchenko
2022-10-05  9:50   ` [PATCH v3 3/6] net/af_xdp: avoid version-based check for shared UMEM Andrew Rybchenko
2022-10-05  9:50   ` [PATCH v3 4/6] net/af_xdp: avoid version-based check for program load mech Andrew Rybchenko
2022-10-05  9:50   ` [PATCH v3 5/6] net/af_xdp: log errors on XDP program removal failures Andrew Rybchenko
2022-10-05  9:50   ` [PATCH v3 6/6] net/af_xdp: make compatible with libbpf v0.8.0 Andrew Rybchenko
2022-10-06  6:26 ` [PATCH v4 0/6] " Andrew Rybchenko
2022-10-06  6:26   ` [PATCH v4 1/6] net/af_xdp: move XDP library presence flag to right branch Andrew Rybchenko
2022-10-06  6:26   ` [PATCH v4 2/6] net/af_xdp: make it clear which libxdp version is required Andrew Rybchenko
2022-10-06  6:26   ` [PATCH v4 3/6] net/af_xdp: avoid version-based check for shared UMEM Andrew Rybchenko
2022-10-06  6:26   ` [PATCH v4 4/6] net/af_xdp: avoid version-based check for program load mech Andrew Rybchenko
2022-10-06  6:26   ` [PATCH v4 5/6] net/af_xdp: log errors on XDP program removal failures Andrew Rybchenko
2022-10-06  6:26   ` [PATCH v4 6/6] net/af_xdp: make compatible with libbpf v0.8.0 Andrew Rybchenko
2022-10-07 17:19     ` Ferruh Yigit
2022-10-07 17:28       ` Ferruh Yigit
2022-10-07 17:40   ` [PATCH v4 0/6] " Ferruh Yigit
2022-12-20 14:05 ` [PATCH] " Kevin Traynor
2022-12-21  6:09   ` Andrew Rybchenko
2022-12-21  9:28     ` Kevin Traynor
2023-03-15 11:47       ` Kevin Traynor
2023-03-16 13:31         ` Kevin Traynor
2023-03-23 10:23           ` Kevin Traynor
2023-04-04 15:51       ` Kevin Traynor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).