PMD driver for AF_XDP
Subsystems (2)
cover PMD driver for AF_XDP
The RFC patches add a new PMD driver for AF_XDP which is a proposed faster version of AF_PACKET interface in Linux, see below link for detail AF_XDP introduction:
https://fosdem.org/2018/schedule/event/af_xdp/
https://lwn.net/Articles/745934/
This patchset is base on v18.02.
It also require a linux kernel that have below AF_XDP RFC patches be applied.
https://patchwork.ozlabs.org/patch/867961/
https://patchwork.ozlabs.org/patch/867960/
https://patchwork.ozlabs.org/patch/867938/
https://patchwork.ozlabs.org/patch/867939/
https://patchwork.ozlabs.org/patch/867940/
https://patchwork.ozlabs.org/patch/867941/
https://patchwork.ozlabs.org/patch/867942/
https://patchwork.ozlabs.org/patch/867943/
https://patchwork.ozlabs.org/patch/867944/
https://patchwork.ozlabs.org/patch/867945/
https://patchwork.ozlabs.org/patch/867946/
https://patchwork.ozlabs.org/patch/867947/
https://patchwork.ozlabs.org/patch/867948/
https://patchwork.ozlabs.org/patch/867949/
https://patchwork.ozlabs.org/patch/867950/
https://patchwork.ozlabs.org/patch/867951/
https://patchwork.ozlabs.org/patch/867952/
https://patchwork.ozlabs.org/patch/867953/
https://patchwork.ozlabs.org/patch/867954/
https://patchwork.ozlabs.org/patch/867955/
https://patchwork.ozlabs.org/patch/867956/
https://patchwork.ozlabs.org/patch/867957/
https://patchwork.ozlabs.org/patch/867958/
https://patchwork.ozlabs.org/patch/867959/
There is no clean upstream target yet since kernel patch is still in RFC stage, The purpose of the patchset is just for anyone that want to eveluate af_xdp with DPDK application and get feedback for further improvement.
To try with the new PMD
1. compile and install the kernel with above patches applied.
2. configure $LINUX_HEADER_DIR (dir of "make headers_install") and $TOOLS_DIR (dir at <kernel_src>/tools) at driver/net/af_xdp/Makefile before compile DPDK.
3. make sure libelf and libbpf is installed.
BTW, performance test shows our PMD can reach 94%~98% of the orignal benchmark when share memory is enabled.
Qi Zhang (7):
net/af_xdp: new PMD driver
lib/mbuf: enable parse flags when create mempool lib/mempool: allow page size aligned mempool net/af_xdp: use mbuf mempool for buffer management net/af_xdp: enable share mempool net/af_xdp: load BPF file
app/testpmd: enable parameter for mempool flags
app/test-pmd/parameters.c | 12 + app/test-pmd/testpmd.c | 15 +- app/test-pmd/testpmd.h | 1 + config/common_base | 5 + config/common_linuxapp | 1 + drivers/net/Makefile | 1 + drivers/net/af_xdp/Makefile | 60 ++ drivers/net/af_xdp/bpf_load.c | 798 +++++++++++++++++++++++ drivers/net/af_xdp/bpf_load.h | 65 ++ drivers/net/af_xdp/libbpf.h | 199 ++++++ drivers/net/af_xdp/meson.build | 7 + drivers/net/af_xdp/rte_eth_af_xdp.c | 878 ++++++++++++++++++++++++++ drivers/net/af_xdp/rte_pmd_af_xdp_version.map | 4 + drivers/net/af_xdp/xdpsock_queue.h | 62 ++ lib/librte_mbuf/rte_mbuf.c | 15 +- lib/librte_mbuf/rte_mbuf.h | 8 +- lib/librte_mempool/rte_mempool.c | 2 + lib/librte_mempool/rte_mempool.h | 1 + mk/rte.app.mk | 1 + 19 files changed, 2125 insertions(+), 10 deletions(-) create mode 100644 drivers/net/af_xdp/Makefile create mode 100644 drivers/net/af_xdp/bpf_load.c create mode 100644 drivers/net/af_xdp/bpf_load.h create mode 100644 drivers/net/af_xdp/libbpf.h create mode 100644 drivers/net/af_xdp/meson.build create mode 100644 drivers/net/af_xdp/rte_eth_af_xdp.c create mode 100644 drivers/net/af_xdp/rte_pmd_af_xdp_version.map create mode 100644 drivers/net/af_xdp/xdpsock_queue.h
Signature · 1 line
2.13.6
RFC 1/7 net/af_xdp: new PMD driver
This is the vanilla version.
Packet data will copy between af_xdp memory buffer and mbuf mempool. indexes of memory buffer is simply managed by a fifo ring.
--- config/common_base | 5 + config/common_linuxapp | 1 + drivers/net/Makefile | 1 + drivers/net/af_xdp/Makefile | 56 ++ drivers/net/af_xdp/meson.build | 7 + drivers/net/af_xdp/rte_eth_af_xdp.c | 763 ++++++++++++++++++++++++++ drivers/net/af_xdp/rte_pmd_af_xdp_version.map | 4 + drivers/net/af_xdp/xdpsock_queue.h | 62 +++ mk/rte.app.mk | 1 + 9 files changed, 900 insertions(+) create mode 100644 drivers/net/af_xdp/Makefile create mode 100644 drivers/net/af_xdp/meson.build create mode 100644 drivers/net/af_xdp/rte_eth_af_xdp.c create mode 100644 drivers/net/af_xdp/rte_pmd_af_xdp_version.map create mode 100644 drivers/net/af_xdp/xdpsock_queue.h
config/common_base +5 -0
@@ -368,6 +368,11 @@ CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_TX_FREE=n CONFIG_RTE_LIBRTE_PMD_AF_PACKET=n # +# Compile software PMD backed by AF_XDP sockets (Linux only) +# +CONFIG_RTE_LIBRTE_PMD_AF_XDP=n + +# # Compile link bonding PMD library # CONFIG_RTE_LIBRTE_PMD_BOND=y
config/common_linuxapp +1 -0
@@ -16,6 +16,7 @@ CONFIG_RTE_LIBRTE_VHOST=y CONFIG_RTE_LIBRTE_VHOST_NUMA=y CONFIG_RTE_LIBRTE_PMD_VHOST=y CONFIG_RTE_LIBRTE_PMD_AF_PACKET=y +CONFIG_RTE_LIBRTE_PMD_AF_XDP=y CONFIG_RTE_LIBRTE_PMD_TAP=y CONFIG_RTE_LIBRTE_AVP_PMD=y CONFIG_RTE_LIBRTE_VDEV_NETVSC_PMD=y
drivers/net/Makefile +1 -0
@@ -9,6 +9,7 @@ ifeq ($(CONFIG_RTE_LIBRTE_THUNDERX_NICVF_PMD),d) endif DIRS-$(CONFIG_RTE_LIBRTE_PMD_AF_PACKET) += af_packet +DIRS-$(CONFIG_RTE_LIBRTE_PMD_AF_XDP) += af_xdp DIRS-$(CONFIG_RTE_LIBRTE_ARK_PMD) += ark DIRS-$(CONFIG_RTE_LIBRTE_AVF_PMD) += avf DIRS-$(CONFIG_RTE_LIBRTE_AVP_PMD) += avp
drivers/net/af_xdp/Makefile new file +56 -0
56 lines not on this page · raw message
drivers/net/af_xdp/meson.build new file +7 -0
@@ -0,0 +1,7 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2017 Intel Corporation + +if host_machine.system() != 'linux' + build = false +endif +sources = files('rte_eth_af_xdp.c')
drivers/net/af_xdp/rte_eth_af_xdp.c new file +763 -0
763 lines not on this page · raw message
drivers/net/af_xdp/rte_pmd_af_xdp_version.map new file +4 -0
@@ -0,0 +1,4 @@ +DPDK_2.0 { + + local: *; +};
drivers/net/af_xdp/xdpsock_queue.h new file +62 -0
62 lines not on this page · raw message
mk/rte.app.mk +1 -0
@@ -120,6 +120,7 @@ ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),n) _LDLIBS-$(CONFIG_RTE_DRIVER_MEMPOOL_STACK) += -lrte_mempool_stack _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_AF_PACKET) += -lrte_pmd_af_packet +_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_AF_XDP) += -lrte_pmd_af_xdp _LDLIBS-$(CONFIG_RTE_LIBRTE_ARK_PMD) += -lrte_pmd_ark _LDLIBS-$(CONFIG_RTE_LIBRTE_AVF_PMD) += -lrte_pmd_avf _LDLIBS-$(CONFIG_RTE_LIBRTE_AVP_PMD) += -lrte_pmd_avp
Signature · 1 line
2.13.6
Re: [RFC 1/7] net/af_xdp: new PMD driver
Quoted 28 lines · On Tue, 27 Feb 2018 17:33:00 +0800 Qi Zhang <[email protected]> wrote:
iff --git a/drivers/net/af_xdp/Makefile b/drivers/net/af_xdp/Makefile new file mode 100644
index 000000000..ac38e20bfdrivers/net/af_xdp/Makefile new file +22
-0@@ -0,0 +1,56 @@ +# BSD LICENSE +# +# Copyright(c) 2014 John W. Linville <[email protected]> +# Copyright(c) 2010-2014 Intel Corporation. All rights reserved. +# Copyright(c) 2014 6WIND S.A. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
drivers/net/af_xdp/Makefile line 32
Quoted 10 lines
drivers/net/af_xdp/Makefile new file +10
-0+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVI
Please use SPDX on new files.
Re: [RFC 1/7] net/af_xdp: new PMD driver
In reply to Qi Zhangdrivers/net/af_xdp/rte_eth_af_xdp.c line 65
Quoted 4 lines · On Tue, 27 Feb 2018 17:33:00 +0800 Qi Zhang <[email protected]> wrote:
struct
pmd_internals{drivers/net/af_xdp/rte_eth_af_xdp.c new file +3
-0+int sfd; +int if_index; +char if_name[0x100 ];
why not IFNAMSIZ?
drivers/net/af_xdp/rte_eth_af_xdp.c line 78
Quoted 13 lines
drivers/net/af_xdp/rte_eth_af_xdp.c new file +13
-0+struct ether_addr eth_addr; +struct xdp_queue rx; +struct xdp_queue tx; +struct xdp_umem *umem; +struct rte_mempool *mb_pool; + +unsigned long rx_pkts; +unsigned long rx_bytes; +unsigned long rx_dropped; + +unsigned long tx_pkts; +unsigned long err_pkts; +unsigned long tx_bytes;
why not per-queue stats? per-port stats are expensive
Quoted 5 lines
drivers/net/af_xdp/rte_eth_af_xdp.c new file +5
-0+uint16_t port_id; +uint16_t queue_idx; +int ring_size; +struct rte_ring *buf_ring; +};
Re: [RFC 1/7] net/af_xdp: new PMD driver
Quoted 20 lines
-----Original Message-----
From: Stephen Hemminger [mailto:[email protected]]
Sent: Thursday, March 1, 2018 7:42 AM
To: Zhang, Qi Z <[email protected]>
Cc: [email protected]; [email protected]; Topel, Bjorn <[email protected]>
Subject: Re: [dpdk-dev] [RFC 1/7]net/af_xdp: new PMD driverdrivers/net/af_xdp/rte_eth_af_xdp.c line 65
Quoted 4 lines · On Tue, 27 Feb 2018 17:33:00 +0800 Qi Zhang <[email protected]> wrote:
struct
pmd_internals{drivers/net/af_xdp/rte_eth_af_xdp.c new file +3
-0+int sfd; +int if_index; +char if_name[0x100 ];why not IFNAMSIZ?
Quoted 15 lines
drivers/net/af_xdp/rte_eth_af_xdp.c line 78
Quoted 13 lines
drivers/net/af_xdp/rte_eth_af_xdp.c new file +13
-0+struct ether_addr eth_addr; +struct xdp_queue rx; +struct xdp_queue tx; +struct xdp_umem *umem; +struct rte_mempool *mb_pool; + +unsigned long rx_pkts; +unsigned long rx_bytes; +unsigned long rx_dropped; + +unsigned long tx_pkts; +unsigned long err_pkts; +unsigned long tx_bytes;why not per-queue stats? per-port stats are expensive
multi-queue is not supported in this implementation, but will be considered.
Regards
Qi
Quoted 6 lines
Quoted 6 lines
drivers/net/af_xdp/rte_eth_af_xdp.c new file +5
-0+uint16_t port_id; +uint16_t queue_idx; +int ring_size; +struct rte_ring *buf_ring; +};
Re: [RFC 1/7] net/af_xdp: new PMD driver
In reply to Qi Zhangdrivers/net/af_xdp/rte_eth_af_xdp.c line 106
Quoted 8 lines · On Tue, 27 Feb 2018 17:33:00 +0800 Qi Zhang <[email protected]> wrote:
drivers/net/af_xdp/rte_eth_af_xdp.c new file +8
-0+ +static void *get_pkt_data (struct pmd_internals *internals, +uint32_t index, +uint32_t offset) +{ +return (uint8_t *)(internals->umem->buffer + + (index << internals->umem->frame_size_log2) + + offset);
You are returning void *, cast here is unnecessary
Re: [RFC 1/7] net/af_xdp: new PMD driver
In reply to Qi ZhangQuoted 4 lines · On Tue, 27 Feb 2018 17:33:00 +0800 Qi Zhang <[email protected]> wrote:
drivers/net/af_xdp/rte_eth_af_xdp.c new file +4
-0+ +static uint16_t +eth_af_xdp_rx (void *queue,struct rte_mbuf **bufs,uint16_t nb_pkts) +{
drivers/net/af_xdp/rte_eth_af_xdp.c line 121
Quoted 10 lines
drivers/net/af_xdp/rte_eth_af_xdp.c new file +10
-0+struct pmd_internals *internals = queue; +struct xdp_queue *rxq = &internals->rx; +struct rte_mbuf *mbuf; +unsigned long dropped =0 ; +unsigned long rx_bytes =0 ; +uint16_t count =0 ; + + nb_pkts = nb_pkts <ETH_AF_XDP_RX_BATCH_SIZE ? + nb_pkts :ETH_AF_XDP_RX_BATCH_SIZE ; +
Put declarations first.
Why not iterate if nb_pkts is huge?
drivers/net/af_xdp/rte_eth_af_xdp.c line 126
Quoted 5 lines
drivers/net/af_xdp/rte_eth_af_xdp.c new file +5
-0+struct xdp_desc descs[ETH_AF_XDP_RX_BATCH_SIZE ]; +void *indexes[ETH_AF_XDP_RX_BATCH_SIZE ]; +int rcvd, i; +/* fill rx ring */ +if (rxq->num_free >=ETH_AF_XDP_RX_BATCH_SIZE ) {
Blank line after declarations before code please.
Re: [RFC 1/7] net/af_xdp: new PMD driver
Quoted 22 lines
-----Original Message-----
From: Stephen Hemminger [mailto:[email protected]]
Sent: Thursday, March 1, 2018 7:45 AM
To: Zhang, Qi Z <[email protected]>
Cc: [email protected]; [email protected]; Topel, Bjorn <[email protected]>
Subject: Re: [dpdk-dev] [RFC 1/7]net/af_xdp: new PMD driverQuoted 9 lines · On Tue, 27 Feb 2018 17:33:00 +0800 Qi Zhang <[email protected]> wrote:
drivers/net/af_xdp/rte_eth_af_xdp.c new file +9
-0+ +static uint16_t +eth_af_xdp_rx (void *queue,struct rte_mbuf **bufs,uint16_t nb_pkts) +{ +struct pmd_internals *internals = queue; +struct xdp_queue *rxq = &internals->rx; +struct rte_mbuf *mbuf; +unsigned long dropped =0 ; +unsigned long rx_bytes =0 ;
Quoted 8 lines
drivers/net/af_xdp/rte_eth_af_xdp.c line 121
Quoted 5 lines
drivers/net/af_xdp/rte_eth_af_xdp.c new file +5
-0+uint16_t count =0 ; + + nb_pkts = nb_pkts <ETH_AF_XDP_RX_BATCH_SIZE ? + nb_pkts :ETH_AF_XDP_RX_BATCH_SIZE ; +Put declarations first.
Why not iterate ifnb_pktsis huge?
Yes, it is not necessary to only read one batch, just for simple implementation, will be fixed.
Quoted 8 lines
drivers/net/af_xdp/rte_eth_af_xdp.c line 126
Quoted 6 lines
drivers/net/af_xdp/rte_eth_af_xdp.c new file +5
-0+struct xdp_desc descs[ETH_AF_XDP_RX_BATCH_SIZE ]; +void *indexes[ETH_AF_XDP_RX_BATCH_SIZE ]; +int rcvd, i; +/* fill rx ring */ +if (rxq->num_free >=ETH_AF_XDP_RX_BATCH_SIZE ) {Blank line after declarations before code please.
RFC 2/7 lib/mbuf: enable parse flags when create mempool
In reply to Qi ZhangThis give the option that applicaiton can configure each memory chunk's size precisely. (by MEMPOOL_F_NO_SPREAD).
--- lib/librte_mbuf/rte_mbuf.c | 15 ++++++++++++--- lib/librte_mbuf/rte_mbuf.h | 8 +++++++- 2 files changed, 19 insertions(+), 4 deletions(-)
lib/librte_mbuf/rte_mbuf.c +12 -3
@@ -125,7 +125,7 @@ rte_pktmbuf_init(struct rte_mempool *mp, struct rte_mempool * __rte_experimentalrte_pktmbuf_pool_create_by_ops (const char *name,unsigned int n,unsigned int cache_size,uint16_t priv_size,uint16_t data_room_size, -int socket_id,const char *ops_name) +unsigned int flags,int socket_id,const char *ops_name) {struct rte_mempool *mp;struct rte_pktmbuf_pool_private mbp_priv;
@@ -145,7 +145,7 @@ rte_pktmbuf_pool_create_by_ops(const char *name, unsigned int n, mbp_priv.mbuf_priv_size = priv_size; mp =rte_mempool_create_empty (name, n, elt_size, cache_size, -sizeof (struct rte_pktmbuf_pool_private ), socket_id,0 ); +sizeof (struct rte_pktmbuf_pool_private ), socket_id, flags);if (mp ==NULL )return NULL ;
@@ -179,9 +179,18 @@ rte_pktmbuf_pool_create(const char *name, unsigned int n, int socket_id) {return rte_pktmbuf_pool_create_by_ops (name, n, cache_size, priv_size, - data_room_size, socket_id,NULL ); + data_room_size,0 , socket_id,NULL ); } +/* helper to create a mbuf pool with NO_SPREAD */ +struct rte_mempool * +rte_pktmbuf_pool_create_with_flags (const char *name,unsigned int n, +unsigned int cache_size,uint16_t priv_size,uint16_t data_room_size, +unsigned int flags,int socket_id) +{ +return rte_pktmbuf_pool_create_by_ops (name, n, cache_size, priv_size, + data_room_size, flags, socket_id,NULL ); +}/* do some sanity checks on a mbuf: panic if it fails */ void rte_mbuf_sanity_check (const struct rte_mbuf *m,int is_header)
lib/librte_mbuf/rte_mbuf.h +7 -1
@@ -1079,6 +1079,12 @@ rte_pktmbuf_pool_create(const char *name, unsigned n, unsigned cache_size, uint16_t priv_size, uint16_t data_room_size, int socket_id); +struct rte_mempool * +rte_pktmbuf_pool_create_with_flags (const char *name,unsigned int n, +unsigned cache_size,uint16_t priv_size,uint16_t data_room_size, +unsigned flags,int socket_id); + +/** * Create a mbuf pool with a given mempool ops name *
@@ -1119,7 +1125,7 @@ rte_pktmbuf_pool_create(const char *name, unsigned n, struct rte_mempool * __rte_experimentalrte_pktmbuf_pool_create_by_ops (const char *name,unsigned int n,unsigned int cache_size,uint16_t priv_size,uint16_t data_room_size, -int socket_id,const char *ops_name); +unsigned int flags,int socket_id,const char *ops_name);/** * Get the data room size of mbufs stored in a pktmbuf_pool
Signature · 1 line
2.13.6
RFC 3/7 lib/mempool: allow page size aligned mempool
In reply to Qi ZhangAllow create a mempool with page size aligned base address.
--- lib/librte_mempool/rte_mempool.c | 2 ++ lib/librte_mempool/rte_mempool.h | 1 + 2 files changed, 3 insertions(+)
lib/librte_mempool/rte_mempool.c +2 -0
@@ -567,6 +567,8 @@ rte_mempool_populate_default(struct rte_mempool *mp) pg_shift =0 ;/* not needed, zone is physically contiguous */ pg_sz =0 ; align =RTE_CACHE_LINE_SIZE ; +if (mp->flags &MEMPOOL_F_PAGE_ALIGN ) + align =getpagesize (); }else { pg_sz =getpagesize (); pg_shift =rte_bsf32 (pg_sz);
lib/librte_mempool/rte_mempool.h +1 -0
@@ -245,6 +245,7 @@ struct rte_mempool {#define MEMPOOL_F_SC_GET 0x0008/**< Default get is "single-consumer".*/ #define MEMPOOL_F_POOL_CREATED 0x0010/**< Internal: pool is created. */ #define MEMPOOL_F_NO_PHYS_CONTIG 0x0020/**< Don't need physically contiguous objs. */ +#define MEMPOOL_F_PAGE_ALIGN 0x0040/**< Base address is page aligned. */ /** * This capability flag is advertised by a mempool handler, if the whole * memory area containing the objects must be physically contiguous.
Signature · 1 line
2.13.6
RFC 4/7 net/af_xdp: use mbuf mempool for buffer management
In reply to Qi ZhangNow, af_xdp registered memory buffer is managed by rte_mempool. mbuf be allocated from rte_mempool can be convert to descriptor index and vice versa.
--- drivers/net/af_xdp/rte_eth_af_xdp.c | 165 +++++++++++++++++++++--------------- 1 file changed, 97 insertions(+), 68 deletions(-)
drivers/net/af_xdp/rte_eth_af_xdp.c +97 -68
@@ -43,7 +43,11 @@#define ETH_AF_XDP_FRAME_SIZE 2048#define ETH_AF_XDP_NUM_BUFFERS 131072 -#define ETH_AF_XDP_DATA_HEADROOM 0 +/* mempool hdrobj size (64 bytes) + sizeof(struct rte_mbuf) (128 bytes) */ +#define ETH_AF_XDP_MBUF_OVERHEAD 192 +/* data start from offset 320 (192 + 128) bytes */ +#define ETH_AF_XDP_DATA_HEADROOM \ + (ETH_AF_XDP_MBUF_OVERHEAD + RTE_PKTMBUF_HEADROOM)#define ETH_AF_XDP_DFLT_RING_SIZE 1024#define ETH_AF_XDP_DFLT_QUEUE_IDX 0
@@ -57,6 +61,7 @@ struct xdp_umem {unsigned int frame_size_log2;unsigned int nframes;int mr_fd; +struct rte_mempool *mb_pool; };struct pmd_internals {
@@ -67,7 +72,7 @@ struct pmd_internals {struct xdp_queue rx;struct xdp_queue tx;struct xdp_umem *umem; -struct rte_mempool *mb_pool; +struct rte_mempool *ext_mb_pool;unsigned long rx_pkts;unsigned long rx_bytes;
@@ -80,7 +85,6 @@ struct pmd_internals {uint16_t port_id;uint16_t queue_idx;int ring_size; -struct rte_ring *buf_ring; };static const char *const valid_arguments[] = {
@@ -106,6 +110,21 @@ static void *get_pkt_data(struct pmd_internals *internals, offset); } +static uint32_t +mbuf_to_idx (struct pmd_internals *internals,struct rte_mbuf *mbuf) +{ +return (uint32_t )(((uint64_t )mbuf->buf_addr - + (uint64_t )internals->umem->buffer) >> + internals->umem->frame_size_log2); +} + +static struct rte_mbuf * +idx_to_mbuf (struct pmd_internals *internals,uint32_t idx) +{ +return (struct rte_mbuf *)(void *)(internals->umem->buffer + (idx + << internals->umem->frame_size_log2) +0x40 ); +} +static uint16_t eth_af_xdp_rx (void *queue,struct rte_mbuf **bufs,uint16_t nb_pkts) {
@@ -120,17 +139,18 @@ eth_af_xdp_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) nb_pkts :ETH_AF_XDP_RX_BATCH_SIZE ;struct xdp_desc descs[ETH_AF_XDP_RX_BATCH_SIZE ]; -void *indexes[ETH_AF_XDP_RX_BATCH_SIZE ]; +struct rte_mbuf *mbufs[ETH_AF_XDP_RX_BATCH_SIZE ];int rcvd, i;/* fill rx ring */ if (rxq->num_free >=ETH_AF_XDP_RX_BATCH_SIZE ) { -int n =rte_ring_dequeue_bulk (internals->buf_ring, - indexes, -ETH_AF_XDP_RX_BATCH_SIZE , -NULL ); -for (i =0 ; i < n; i++) - descs[i].idx = (uint32_t )((long int )indexes[i]); -xq_enq (rxq, descs, n); +int ret =rte_mempool_get_bulk (internals->umem->mb_pool, + (void *)mbufs, +ETH_AF_XDP_RX_BATCH_SIZE ); +if (!ret) { +for (i =0 ; i <ETH_AF_XDP_RX_BATCH_SIZE ; i++) + descs[i].idx =mbuf_to_idx (internals, mbufs[i]); +xq_enq (rxq, descs,ETH_AF_XDP_RX_BATCH_SIZE ); + } }/* read data */
@@ -142,7 +162,7 @@ eth_af_xdp_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)char *pkt;uint32_t idx = descs[i].idx; - mbuf =rte_pktmbuf_alloc (internals->mb_pool); + mbuf =rte_pktmbuf_alloc (internals->ext_mb_pool);rte_pktmbuf_pkt_len (mbuf) =rte_pktmbuf_data_len (mbuf) = descs[i].len;
@@ -155,11 +175,9 @@ eth_af_xdp_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) }else { dropped++; } - indexes[i] = (void *)((long int )idx); +rte_pktmbuf_free (idx_to_mbuf (internals, idx)); } -rte_ring_enqueue_bulk (internals->buf_ring, indexes, rcvd,NULL ); - internals->rx_pkts += (rcvd - dropped); internals->rx_bytes += rx_bytes; internals->rx_dropped += dropped;
@@ -187,9 +205,10 @@ eth_af_xdp_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)struct xdp_queue *txq = &internals->tx;struct rte_mbuf *mbuf;struct xdp_desc descs[ETH_AF_XDP_TX_BATCH_SIZE ]; -void *indexes[ETH_AF_XDP_TX_BATCH_SIZE ]; +struct rte_mbuf *mbufs[ETH_AF_XDP_TX_BATCH_SIZE ];uint16_t i, valid;unsigned long tx_bytes =0 ; +int ret; nb_pkts = nb_pkts <ETH_AF_XDP_TX_BATCH_SIZE ? nb_pkts :ETH_AF_XDP_TX_BATCH_SIZE ;
@@ -198,13 +217,15 @@ eth_af_xdp_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)int n =xq_deq (txq, descs,ETH_AF_XDP_TX_BATCH_SIZE );for (i =0 ; i < n; i++) - indexes[i] = (void *)((long int )descs[i].idx); -rte_ring_enqueue_bulk (internals->buf_ring, indexes, n,NULL ); +rte_pktmbuf_free (idx_to_mbuf (internals, descs[i].idx)); } nb_pkts = nb_pkts > txq->num_free ? txq->num_free : nb_pkts; - nb_pkts =rte_ring_dequeue_bulk (internals->buf_ring, indexes, - nb_pkts,NULL ); + ret =rte_mempool_get_bulk (internals->umem->mb_pool, + (void *)mbufs, + nb_pkts); +if (ret) +return 0 ; valid =0 ;for (i =0 ; i < nb_pkts; i++) {
@@ -213,14 +234,14 @@ eth_af_xdp_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) internals->umem->frame_size -ETH_AF_XDP_DATA_HEADROOM ; mbuf = bufs[i];if (mbuf->pkt_len <= buf_len) { - descs[valid].idx = (uint32_t )((long int )indexes[valid]); + descs[valid].idx =mbuf_to_idx (internals, mbufs[i]); descs[valid].offset =ETH_AF_XDP_DATA_HEADROOM ; descs[valid].flags =0 ; descs[valid].len = mbuf->pkt_len; pkt =get_pkt_data (internals, descs[i].idx, descs[i].offset); memcpy(pkt, rte_pktmbuf_mtod(mbuf, void *), - descs[i].len); + descs[i].len); valid++; tx_bytes += mbuf->pkt_len; }
@@ -230,9 +251,10 @@ eth_af_xdp_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)xq_enq (txq, descs, valid);kick_tx (internals->sfd); -if (valid < nb_pkts) -rte_ring_enqueue_bulk (internals->buf_ring, &indexes[valid], - nb_pkts - valid,NULL ); +if (valid < nb_pkts) { +for (i = valid; i < nb_pkts; i++) +rte_pktmbuf_free (mbufs[i]); + } internals->err_pkts += (nb_pkts - valid); internals->tx_pkts += valid;
@@ -245,14 +267,13 @@ static void fill_rx_desc(struct pmd_internals *internals) {int num_free = internals->rx.num_free; -void *p =NULL ;int i; -for (i =0 ; i < num_free; i++) {struct xdp_desc desc = {}; +struct rte_mbuf *mbuf = +rte_pktmbuf_alloc (internals->umem->mb_pool); -rte_ring_dequeue (internals->buf_ring, &p); - desc.idx = (uint32_t )((long int )p); + desc.idx =mbuf_to_idx (internals, mbuf);xq_enq (&internals->rx, &desc,1 ); } }
@@ -347,33 +368,53 @@ eth_link_update(struct rte_eth_dev *dev __rte_unused,return 0 ; } -static struct xdp_umem *xsk_alloc_and_mem_reg_buffers (int sfd,size_t nbuffers) +static void *get_base_addr (struct rte_mempool *mb_pool) +{ +struct rte_mempool_memhdr *memhdr; + + STAILQ_FOREACH(memhdr, &mb_pool->mem_list, next) { +return memhdr->addr; + } +return NULL ; +} + +static struct xdp_umem *xsk_alloc_and_mem_reg_buffers (int sfd, +size_t nbuffers, +const char *pool_name) {struct xdp_mr_req req = { .frame_size =ETH_AF_XDP_FRAME_SIZE , .data_headroom =ETH_AF_XDP_DATA_HEADROOM }; -struct xdp_umem *umem; -void *bufs; -int ret; +struct xdp_umem *umem =calloc (1 ,sizeof (*umem)); - ret =posix_memalign ((void **)&bufs,getpagesize (), - nbuffers * req.frame_size); -if (ret) +if (!umem) +return NULL ; + + umem->mb_pool = +rte_pktmbuf_pool_create_with_flags ( + pool_name, nbuffers, +250 ,0 , + (ETH_AF_XDP_FRAME_SIZE -ETH_AF_XDP_MBUF_OVERHEAD ), +MEMPOOL_F_NO_SPREAD |MEMPOOL_F_PAGE_ALIGN , +SOCKET_ID_ANY ); + +if (!umem->mb_pool) { +free (umem);return NULL ; + } - umem =calloc (1 ,sizeof (*umem)); -if (!umem) { -free (bufs); +if (umem->mb_pool->nb_mem_chunks >1 ) { +rte_mempool_free (umem->mb_pool); +free (umem);return NULL ; } - req.addr = (unsigned long )bufs; + req.addr = (uint64_t )get_base_addr (umem->mb_pool); req.len = nbuffers * req.frame_size; - ret =setsockopt (sfd,SOL_XDP ,XDP_MEM_REG , &req,sizeof (req)); -RTE_ASSERT (ret ==0 ); +setsockopt (sfd,SOL_XDP ,XDP_MEM_REG , &req,sizeof (req)); umem->frame_size =ETH_AF_XDP_FRAME_SIZE ; umem->frame_size_log2 =11 ; - umem->buffer = bufs; + umem->buffer = (char *)req.addr; umem->size = nbuffers * req.frame_size; umem->nframes = nbuffers; umem->mr_fd = sfd;
@@ -386,38 +427,27 @@ xdp_configure(struct pmd_internals *internals) {struct sockaddr_xdp sxdp;struct xdp_ring_req req; -char ring_name[0x100 ]; +char pool_name[0x100 ]; +int ret =0 ; -long int i; -snprintf (ring_name,0x100 ,"%s_%s_%d" ,"af_xdp_ring" , +snprintf (pool_name,0x100 ,"%s_%s_%d" ,"af_xdp_pool" , internals->if_name, internals->queue_idx); - internals->buf_ring =rte_ring_create (ring_name, -ETH_AF_XDP_NUM_BUFFERS , -SOCKET_ID_ANY , -0x0 ); -if (!internals->buf_ring) -return -1 ; - -for (i =0 ; i <ETH_AF_XDP_NUM_BUFFERS ; i++) -rte_ring_enqueue (internals->buf_ring, (void *)i); - internals->umem =xsk_alloc_and_mem_reg_buffers (internals->sfd, -ETH_AF_XDP_NUM_BUFFERS ); +ETH_AF_XDP_NUM_BUFFERS , + pool_name);if (!internals->umem) - goto error; +return -1 ; req.mr_fd = internals->umem->mr_fd; req.desc_nr = internals->ring_size; ret =setsockopt (internals->sfd,SOL_XDP ,XDP_RX_RING , &req,sizeof (req)); -RTE_ASSERT (ret ==0 ); ret =setsockopt (internals->sfd,SOL_XDP ,XDP_TX_RING , &req,sizeof (req)); -RTE_ASSERT (ret ==0 ); internals->rx.ring = mmap(0, req.desc_nr * sizeof(struct xdp_desc),
@@ -448,10 +478,6 @@ xdp_configure(struct pmd_internals *internals)RTE_ASSERT (ret ==0 );return ret; -error: -rte_ring_free (internals->buf_ring); - internals->buf_ring =NULL ; -return -1 ; } static int
@@ -466,11 +492,11 @@ eth_rx_queue_setup(struct rte_eth_dev *dev,unsigned int buf_size, data_size;RTE_ASSERT (rx_queue_id ==0 ); - internals->mb_pool = mb_pool; + internals->ext_mb_pool = mb_pool;xdp_configure (internals);/* Now get the space available for data in the mbuf */ - buf_size =rte_pktmbuf_data_room_size (internals->mb_pool) - + buf_size =rte_pktmbuf_data_room_size (internals->ext_mb_pool) -RTE_PKTMBUF_HEADROOM ; data_size = internals->umem->frame_size;
@@ -739,8 +765,11 @@ rte_pmd_af_xdp_remove(struct rte_vdev_device *dev)return -1 ; internals = eth_dev->data->dev_private; -rte_ring_free (internals->buf_ring); -rte_free (internals->umem); +if (internals->umem) { +if (internals->umem->mb_pool) +rte_mempool_free (internals->umem->mb_pool); +rte_free (internals->umem); + }rte_free (eth_dev->data->dev_private);rte_free (eth_dev->data);close (internals->sfd);
Signature · 1 line
2.13.6
Re: [RFC 4/7] net/af_xdp: use mbuf mempool for buffer management
Quoted 4 lines · On Tue, 27 Feb 2018 17:33:03 +0800 Qi Zhang <[email protected]> wrote:
drivers/net/af_xdp/rte_eth_af_xdp.c +4
-0+static uint32_t +mbuf_to_idx (struct pmd_internals *internals,struct rte_mbuf *mbuf) +{ + return (uint32_t)(((uint64_t)mbuf->buf_addr -
drivers/net/af_xdp/rte_eth_af_xdp.c static void *get_pkt_data(struct pmd_internals *internals, · line 126
Quoted 10 lines
drivers/net/af_xdp/rte_eth_af_xdp.c +10
-0+ (uint64_t)internals->umem->buffer) >> + internals->umem->frame_size_log2); +} + +static struct rte_mbuf * +idx_to_mbuf (struct pmd_internals *internals,uint32_t idx) +{ +return (struct rte_mbuf *)(void *)(internals->umem->buffer + (idx + << internals->umem->frame_size_log2) +0x40 ); +}
More unnecessary casts's here.
RFC 5/7 net/af_xdp: enable share mempool
In reply to Qi ZhangTry to check if external mempool (from rx_queue_setup) is fit for af_xdp, if it is, it will be registered to af_xdp socket directly and there will be no packet data copy on Rx and Tx.
--- drivers/net/af_xdp/rte_eth_af_xdp.c | 191 +++++++++++++++++++++++------------- 1 file changed, 125 insertions(+), 66 deletions(-)
drivers/net/af_xdp/rte_eth_af_xdp.c +125 -66
@@ -60,7 +60,6 @@ struct xdp_umem {unsigned int frame_size;unsigned int frame_size_log2;unsigned int nframes; -int mr_fd;struct rte_mempool *mb_pool; };
@@ -73,6 +72,7 @@ struct pmd_internals {struct xdp_queue tx;struct xdp_umem *umem;struct rte_mempool *ext_mb_pool; +uint8_t share_mb_pool;unsigned long rx_pkts;unsigned long rx_bytes;
@@ -162,20 +162,30 @@ eth_af_xdp_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)char *pkt;uint32_t idx = descs[i].idx; - mbuf =rte_pktmbuf_alloc (internals->ext_mb_pool); -rte_pktmbuf_pkt_len (mbuf) = -rte_pktmbuf_data_len (mbuf) = - descs[i].len; -if (mbuf) { - pkt =get_pkt_data (internals, idx, descs[i].offset); - memcpy(rte_pktmbuf_mtod(mbuf, void *), - pkt, descs[i].len); - rx_bytes += descs[i].len; - bufs[count++] = mbuf; +if (!internals->share_mb_pool) { + mbuf =rte_pktmbuf_alloc (internals->ext_mb_pool); +rte_pktmbuf_pkt_len (mbuf) = +rte_pktmbuf_data_len (mbuf) = + descs[i].len; +if (mbuf) { + pkt =get_pkt_data (internals, idx, + descs[i].offset); + memcpy(rte_pktmbuf_mtod(mbuf, void *), pkt, + descs[i].len); + rx_bytes += descs[i].len; + bufs[count++] = mbuf; + }else { + dropped++; + } +rte_pktmbuf_free (idx_to_mbuf (internals, idx)); }else { - dropped++; + mbuf =idx_to_mbuf (internals, idx); +rte_pktmbuf_pkt_len (mbuf) = +rte_pktmbuf_data_len (mbuf) = + descs[i].len; + bufs[count++] = mbuf; + rx_bytes += descs[i].len; } -rte_pktmbuf_free (idx_to_mbuf (internals, idx)); } internals->rx_pkts += (rcvd - dropped);
@@ -209,51 +219,71 @@ eth_af_xdp_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)uint16_t i, valid;unsigned long tx_bytes =0 ;int ret; +uint8_t share_mempool =0 ; nb_pkts = nb_pkts <ETH_AF_XDP_TX_BATCH_SIZE ? nb_pkts :ETH_AF_XDP_TX_BATCH_SIZE ;if (txq->num_free <ETH_AF_XDP_TX_BATCH_SIZE *2 ) {int n =xq_deq (txq, descs,ETH_AF_XDP_TX_BATCH_SIZE ); -for (i =0 ; i < n; i++)rte_pktmbuf_free (idx_to_mbuf (internals, descs[i].idx)); } nb_pkts = nb_pkts > txq->num_free ? txq->num_free : nb_pkts; - ret =rte_mempool_get_bulk (internals->umem->mb_pool, - (void *)mbufs, - nb_pkts); -if (ret) +if (nb_pkts ==0 )return 0 ; +if (bufs[0 ]->pool == internals->ext_mb_pool && internals->share_mb_pool) + share_mempool =1 ; + +if (!share_mempool) { + ret =rte_mempool_get_bulk (internals->umem->mb_pool, + (void *)mbufs, + nb_pkts); +if (ret) +return 0 ; + } + valid =0 ;for (i =0 ; i < nb_pkts; i++) {char *pkt; -unsigned int buf_len = - internals->umem->frame_size -ETH_AF_XDP_DATA_HEADROOM ; mbuf = bufs[i]; -if (mbuf->pkt_len <= buf_len) { - descs[valid].idx =mbuf_to_idx (internals, mbufs[i]); - descs[valid].offset =ETH_AF_XDP_DATA_HEADROOM ; - descs[valid].flags =0 ; - descs[valid].len = mbuf->pkt_len; - pkt =get_pkt_data (internals, descs[i].idx, - descs[i].offset); - memcpy(pkt, rte_pktmbuf_mtod(mbuf, void *), - descs[i].len); - valid++; +if (!share_mempool) { +if (mbuf->pkt_len <= + (internals->umem->frame_size - +ETH_AF_XDP_DATA_HEADROOM )) { + descs[valid].idx = +mbuf_to_idx (internals, mbufs[i]); + descs[valid].offset =ETH_AF_XDP_DATA_HEADROOM ; + descs[valid].flags =0 ; + descs[valid].len = mbuf->pkt_len; + pkt =get_pkt_data (internals, descs[i].idx, + descs[i].offset); + memcpy(pkt, rte_pktmbuf_mtod(mbuf, void *), + descs[i].len); + valid++; + tx_bytes += mbuf->pkt_len; + } +rte_pktmbuf_free (mbuf); + }else { + descs[i].idx =mbuf_to_idx (internals, mbuf); + descs[i].offset =ETH_AF_XDP_DATA_HEADROOM ; + descs[i].flags =0 ; + descs[i].len = mbuf->pkt_len; tx_bytes += mbuf->pkt_len; + valid++; } -rte_pktmbuf_free (mbuf); }xq_enq (txq, descs, valid);kick_tx (internals->sfd); -if (valid < nb_pkts) { -for (i = valid; i < nb_pkts; i++) -rte_pktmbuf_free (mbufs[i]); +if (!share_mempool) { +if (valid < nb_pkts) { +for (i = valid; i < nb_pkts; i++) +rte_pktmbuf_free (mbufs[i]); + } } internals->err_pkts += (nb_pkts - valid);
@@ -378,46 +408,81 @@ static void *get_base_addr(struct rte_mempool *mb_pool)return NULL ; } -static struct xdp_umem *xsk_alloc_and_mem_reg_buffers (int sfd, -size_t nbuffers, -const char *pool_name) +static uint8_t +check_mempool (struct rte_mempool *mp) +{ +RTE_ASSERT (mp); + +/* must continues */ +if (mp->nb_mem_chunks >1 ) +return 0 ; + +/* check header size */ +if (mp->header_size !=RTE_CACHE_LINE_SIZE ) +return 0 ; + +/* check base address */ +if ((uint64_t )get_base_addr (mp) %getpagesize () !=0 ) +return 0 ; + +/* check chunk size */ +if ((mp->elt_size + mp->header_size + mp->trailer_size) % +ETH_AF_XDP_FRAME_SIZE !=0 ) +return 0 ; + +return 1 ; +} + +static struct xdp_umem * +xsk_alloc_and_mem_reg_buffers (struct pmd_internals *internals) {struct xdp_mr_req req = { .frame_size =ETH_AF_XDP_FRAME_SIZE , .data_headroom =ETH_AF_XDP_DATA_HEADROOM }; +char pool_name[0x100 ]; +int nbuffers;struct xdp_umem *umem =calloc (1 ,sizeof (*umem));if (!umem)return NULL ; - umem->mb_pool = -rte_pktmbuf_pool_create_with_flags ( - pool_name, nbuffers, -250 ,0 , - (ETH_AF_XDP_FRAME_SIZE -ETH_AF_XDP_MBUF_OVERHEAD ), -MEMPOOL_F_NO_SPREAD |MEMPOOL_F_PAGE_ALIGN , -SOCKET_ID_ANY ); - -if (!umem->mb_pool) { -free (umem); -return NULL ; - } + internals->share_mb_pool =check_mempool (internals->ext_mb_pool); +if (!internals->share_mb_pool) { +snprintf (pool_name,0x100 ,"%s_%s_%d" ,"af_xdp_pool" , + internals->if_name, internals->queue_idx); + umem->mb_pool = +rte_pktmbuf_pool_create_with_flags ( + pool_name, +ETH_AF_XDP_NUM_BUFFERS , +250 ,0 , + (ETH_AF_XDP_FRAME_SIZE - +ETH_AF_XDP_MBUF_OVERHEAD ), +MEMPOOL_F_NO_SPREAD |MEMPOOL_F_PAGE_ALIGN , +SOCKET_ID_ANY ); +if (!umem->mb_pool) { +free (umem); +return NULL ; + } -if (umem->mb_pool->nb_mem_chunks >1 ) { -rte_mempool_free (umem->mb_pool); -free (umem); -return NULL ; +if (umem->mb_pool->nb_mem_chunks >1 ) { +rte_mempool_free (umem->mb_pool); +free (umem); +return NULL ; + } + nbuffers =ETH_AF_XDP_NUM_BUFFERS ; + }else { + umem->mb_pool = internals->ext_mb_pool; + nbuffers = umem->mb_pool->populated_size; } req.addr = (uint64_t )get_base_addr (umem->mb_pool); - req.len = nbuffers * req.frame_size; -setsockopt (sfd,SOL_XDP ,XDP_MEM_REG , &req,sizeof (req)); + req.len =ETH_AF_XDP_NUM_BUFFERS * req.frame_size; +setsockopt (internals->sfd,SOL_XDP ,XDP_MEM_REG , &req,sizeof (req)); umem->frame_size =ETH_AF_XDP_FRAME_SIZE ; umem->frame_size_log2 =11 ; umem->buffer = (char *)req.addr; umem->size = nbuffers * req.frame_size; umem->nframes = nbuffers; - umem->mr_fd = sfd;return umem; }
@@ -427,19 +492,13 @@ xdp_configure(struct pmd_internals *internals) {struct sockaddr_xdp sxdp;struct xdp_ring_req req; -char pool_name[0x100 ]; -int ret =0 ; -snprintf (pool_name,0x100 ,"%s_%s_%d" ,"af_xdp_pool" , - internals->if_name, internals->queue_idx); - internals->umem =xsk_alloc_and_mem_reg_buffers (internals->sfd, -ETH_AF_XDP_NUM_BUFFERS , - pool_name); + internals->umem =xsk_alloc_and_mem_reg_buffers (internals);if (!internals->umem)return -1 ; - req.mr_fd = internals->umem->mr_fd; + req.mr_fd = internals->sfd; req.desc_nr = internals->ring_size; ret = setsockopt(internals->sfd, SOL_XDP, XDP_RX_RING,
@@ -500,7 +559,7 @@ eth_rx_queue_setup(struct rte_eth_dev *dev,RTE_PKTMBUF_HEADROOM ; data_size = internals->umem->frame_size; -if (data_size > buf_size) { +if (data_size -ETH_AF_XDP_DATA_HEADROOM > buf_size) {RTE_LOG (ERR ,PMD ,"%s: %d bytes will not fit in mbuf (%d bytes)\n" , dev->device->name, data_size, buf_size);
@@ -766,7 +825,7 @@ rte_pmd_af_xdp_remove(struct rte_vdev_device *dev) internals = eth_dev->data->dev_private;if (internals->umem) { -if (internals->umem->mb_pool) +if (internals->umem->mb_pool && !internals->share_mb_pool)rte_mempool_free (internals->umem->mb_pool);rte_free (internals->umem); }
Signature · 1 line
2.13.6
RFC 6/7 net/af_xdp: load BPF file
In reply to Qi ZhangAdd libbpf and libelf dependency in Makefile.
Durring initialization, bpf file "xdpsock_kern.o" will be loaded. Then the driver will always try to link XDP fd with DRV mode first, then SKB mode if failed in previoius.
Link will be released during dev_close.
Note: this is workaround solution, af_xdp may remove BPF dependency in future.
--- drivers/net/af_xdp/Makefile | 6 +- drivers/net/af_xdp/bpf_load.c | 798 ++++++++++++++++++++++++++++++++++++ drivers/net/af_xdp/bpf_load.h | 65 +++ drivers/net/af_xdp/libbpf.h | 199 +++++++++ drivers/net/af_xdp/rte_eth_af_xdp.c | 31 +- mk/rte.app.mk | 2 +- 6 files changed, 1097 insertions(+), 4 deletions(-) create mode 100644 drivers/net/af_xdp/bpf_load.c create mode 100644 drivers/net/af_xdp/bpf_load.h create mode 100644 drivers/net/af_xdp/libbpf.h
drivers/net/af_xdp/Makefile +5 -1
@@ -42,7 +42,10 @@ EXPORT_MAP := rte_pmd_af_xdp_version.map LIBABIVER := 1 -CFLAGS += -O3 -I/opt/af_xdp/linux_headers/include +LINUX_HEADER_DIR := /opt/af_xdp/linux_headers/include +TOOLS_DIR := /root/af_xdp/npg_dna-dna-linux/tools + +CFLAGS += -O3 -I$(LINUX_HEADER_DIR) -I$(TOOLS_DIR)/perf -I$(TOOLS_DIR)/include -Wno-error=sign-compare -Wno-error=cast-qual CFLAGS += $(WERROR_FLAGS) LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs
@@ -52,5 +55,6 @@ LDLIBS += -lrte_bus_vdev # all source are stored in SRCS-y # SRCS-$(CONFIG_RTE_LIBRTE_PMD_AF_XDP) += rte_eth_af_xdp.c +SRCS-$(CONFIG_RTE_LIBRTE_PMD_AF_XDP) += bpf_load.c include $(RTE_SDK)/mk/rte.lib.mk
drivers/net/af_xdp/bpf_load.c new file +798 -0
798 lines not on this page · raw message
drivers/net/af_xdp/bpf_load.h new file +65 -0
65 lines not on this page · raw message
drivers/net/af_xdp/libbpf.h new file +199 -0
199 lines not on this page · raw message
drivers/net/af_xdp/rte_eth_af_xdp.c +29 -2
@@ -15,6 +15,7 @@#include <linux/if_ether.h> #include <linux/if_xdp.h> +#include <linux/if_link.h> #include <arpa/inet.h> #include <net/if.h> #include <sys/types.h>
@@ -24,6 +25,7 @@#include <unistd.h> #include <poll.h> #include "xdpsock_queue.h" +#include "bpf_load.h" #ifndef SOL_XDP #define SOL_XDP 283
@@ -85,6 +87,8 @@ struct pmd_internals {uint16_t port_id;uint16_t queue_idx;int ring_size; + +uint32_t xdp_flags; };static const char *const valid_arguments[] = {
@@ -382,8 +386,12 @@ eth_stats_reset(struct rte_eth_dev *dev) }static void -eth_dev_close(struct rte_eth_dev *dev __rte_unused) +eth_dev_close (struct rte_eth_dev *dev) { +struct pmd_internals *internals = dev->data->dev_private; + +if (internals->xdp_flags) +set_link_xdp_fd (internals->if_index,-1 , internals->xdp_flags); } static void
@@ -745,9 +753,25 @@ init_internals(struct rte_vdev_device *dev,if (ret) goto error_3; +/* need fix: hard coded bpf file */ +if (load_bpf_file ("xdpsock_kern.o" )) { +printf ("load bpf file failed\n" ); + goto error_3; + } +RTE_ASSERT (prog_fd[0 ]); + +if (!set_link_xdp_fd (internals->if_index, prog_fd[0 ], +XDP_FLAGS_DRV_MODE )) + internals->xdp_flags =XDP_FLAGS_DRV_MODE ; +else if (!set_link_xdp_fd (internals->if_index, prog_fd[0 ], +XDP_FLAGS_SKB_MODE )) + internals->xdp_flags =XDP_FLAGS_SKB_MODE ; +else + goto error_3; + eth_dev =rte_eth_vdev_allocate (dev,0 );if (!eth_dev) - goto error_3; + goto error_4;rte_memcpy (data, eth_dev->data,sizeof (*data)); internals->port_id = eth_dev->data->port_id;
@@ -765,6 +789,9 @@ init_internals(struct rte_vdev_device *dev,return 0 ; +error_4: +set_link_xdp_fd (internals->if_index,-1 , internals->xdp_flags); + error_3:close (internals->sfd);
mk/rte.app.mk +1 -1
@@ -120,7 +120,7 @@ ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),n) _LDLIBS-$(CONFIG_RTE_DRIVER_MEMPOOL_STACK) += -lrte_mempool_stack _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_AF_PACKET) += -lrte_pmd_af_packet -_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_AF_XDP) += -lrte_pmd_af_xdp +_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_AF_XDP) += -lrte_pmd_af_xdp -lelf -lbpf _LDLIBS-$(CONFIG_RTE_LIBRTE_ARK_PMD) += -lrte_pmd_ark _LDLIBS-$(CONFIG_RTE_LIBRTE_AVF_PMD) += -lrte_pmd_avf _LDLIBS-$(CONFIG_RTE_LIBRTE_AVP_PMD) += -lrte_pmd_avp
Signature · 1 line
2.13.6
Re: [RFC 6/7] net/af_xdp: load BPF file
drivers/net/af_xdp/bpf_load.c line 1
Quoted 8 lines · On Tue, 27 Feb 2018 17:33:05 +0800 Qi Zhang <[email protected]> wrote:
include $(RTE_SDK)/mk/rte.lib.mk
drivers/net/af_xdp/bpf_load.c new file +1
-0@@ -0,0 +1,798 @@ +// SPDX-License-Identifier: GPL-2.0
Sorry all DPDK drivers must be BSD licensed. You can't use GPL-2.0 code. Either get the code dual licensed or write a new loader.
RFC 7/7 app/testpmd: enable parameter for mempool flags
In reply to Qi ZhangNow, it is possible for testpmd to create a af_xdp friendly mempool.
--- app/test-pmd/parameters.c | 12 ++++++++++++ app/test-pmd/testpmd.c | 15 +++++++++------ app/test-pmd/testpmd.h | 1 + 3 files changed, 22 insertions(+), 6 deletions(-)
app/test-pmd/parameters.c +12 -0
@@ -61,6 +61,7 @@ usage(char* progname)"--tx-first | --stats-period=PERIOD | " "--coremask=COREMASK --portmask=PORTMASK --numa " "--mbuf-size= | --total-num-mbufs= | " +"--mp-flags= | " "--nb-cores= | --nb-ports= | " #ifdef RTE_LIBRTE_CMDLINE"--eth-peers-configfile= | "
@@ -105,6 +106,7 @@ usage(char* progname)printf (" --socket-num=N: set socket from which all memory is allocated " "in NUMA mode.\n" );printf (" --mbuf-size=N: set the data size of mbuf to N bytes.\n" ); +printf (" --mp-flags=N: set the flags when create mbuf memory pool.\n" );printf (" --total-num-mbufs=N: set the number of mbufs to be allocated " "in mbuf pools.\n" );printf (" --max-pkt-len=N: set the maximum size of packet to N bytes.\n" );
@@ -568,6 +570,7 @@ launch_args_parse(int argc, char** argv) { "ring-numa-config", 1, 0, 0 }, { "socket-num", 1, 0, 0 }, { "mbuf-size", 1, 0, 0 }, + { "mp-flags", 1, 0, 0 }, { "total-num-mbufs", 1, 0, 0 }, { "max-pkt-len", 1, 0, 0 }, { "pkt-filter-mode", 1, 0, 0 },
@@ -769,6 +772,15 @@ launch_args_parse(int argc, char** argv)rte_exit (EXIT_FAILURE ,"mbuf-size should be > 0 and < 65536\n" ); } +if (!strcmp (lgopts[opt_idx].name,"mp-flags" )) { + n =atoi (optarg); +if (n >0 && n <=0xFFFF ) + mp_flags = (uint16_t )n; +else +rte_exit (EXIT_FAILURE , +"mp-flags should be > 0 and < 65536\n" ); + } +if (!strcmp (lgopts[opt_idx].name,"total-num-mbufs" )) { n =atoi (optarg);if (n >1024 )
app/test-pmd/testpmd.c +9 -6
@@ -171,6 +171,7 @@ uint32_t burst_tx_delay_time = BURST_TX_WAIT_US;uint32_t burst_tx_retry_num =BURST_TX_RETRIES ;uint16_t mbuf_data_size =DEFAULT_MBUF_DATA_SIZE ;/**< Mbuf data space size. */ +uint16_t mp_flags =0 ;/**< flags parsed when create mempool */ uint32_t param_total_num_mbufs =0 ;/**< number of mbufs in all pools - if * specified on command-line. */ uint16_t stats_period;/**< Period to show statistics (disabled by default) */
@@ -486,6 +487,7 @@ set_def_fwd_config(void)*/ static void mbuf_pool_create (uint16_t mbuf_seg_size,unsigned nb_mbuf, +unsigned int flags,unsigned int socket_id) {char pool_name[RTE_MEMPOOL_NAMESIZE ];
@@ -503,7 +505,7 @@ mbuf_pool_create(uint16_t mbuf_seg_size, unsigned nb_mbuf, rte_mp =rte_mempool_create_empty (pool_name, nb_mbuf, mb_size, (unsigned ) mb_mempool_cache,sizeof (struct rte_pktmbuf_pool_private ), - socket_id,0 ); + socket_id, flags);if (rte_mp ==NULL ) goto err;
@@ -518,8 +520,8 @@ mbuf_pool_create(uint16_t mbuf_seg_size, unsigned nb_mbuf,/* wrapper to rte_mempool_create() */ TESTPMD_LOG (INFO ,"preferred mempool ops selected: %s\n" ,rte_mbuf_best_mempool_ops ()); - rte_mp =rte_pktmbuf_pool_create (pool_name, nb_mbuf, - mb_mempool_cache,0 , mbuf_seg_size, socket_id); + rte_mp =rte_pktmbuf_pool_create_with_flags (pool_name, nb_mbuf, + mb_mempool_cache,0 , mbuf_seg_size, flags, socket_id); } err:
@@ -735,13 +737,14 @@ init_config(void)for (i =0 ; i < num_sockets; i++)mbuf_pool_create (mbuf_data_size, nb_mbuf_per_pool, - socket_ids[i]); + mp_flags, socket_ids[i]); }else {if (socket_num ==UMA_NO_CONFIG ) -mbuf_pool_create (mbuf_data_size, nb_mbuf_per_pool,0 ); +mbuf_pool_create (mbuf_data_size, nb_mbuf_per_pool, + mp_flags,0 );else mbuf_pool_create (mbuf_data_size, nb_mbuf_per_pool, - socket_num); + mp_flags, socket_num); }init_port_config ();
app/test-pmd/testpmd.h +1 -0
@@ -386,6 +386,7 @@ extern uint8_t dcb_config;extern uint8_t dcb_test;extern uint16_t mbuf_data_size;/**< Mbuf data space size. */ +extern uint16_t mp_flags;/**< flags for mempool creation. */ extern uint32_t param_total_num_mbufs;extern uint16_t stats_period;
Signature · 1 line
2.13.6
Quoted 46 lines · Qi Zhang
The RFC patches add a new PMD driver for
AF_XDPwhich is a proposed faster version ofAF_PACKETinterface in Linux, see below link for detailAF_XDPintroduction:
https://fosdem.org/2018/schedule/event/af_xdp/
https://lwn.net/Articles/745934/This patchset is base on v18.02.
It also require a linux kernel that have belowAF_XDPRFC patches be applied.
https://patchwork.ozlabs.org/patch/867961/
https://patchwork.ozlabs.org/patch/867960/
https://patchwork.ozlabs.org/patch/867938/
https://patchwork.ozlabs.org/patch/867939/
https://patchwork.ozlabs.org/patch/867940/
https://patchwork.ozlabs.org/patch/867941/
https://patchwork.ozlabs.org/patch/867942/
https://patchwork.ozlabs.org/patch/867943/
https://patchwork.ozlabs.org/patch/867944/
https://patchwork.ozlabs.org/patch/867945/
https://patchwork.ozlabs.org/patch/867946/
https://patchwork.ozlabs.org/patch/867947/
https://patchwork.ozlabs.org/patch/867948/
https://patchwork.ozlabs.org/patch/867949/
https://patchwork.ozlabs.org/patch/867950/
https://patchwork.ozlabs.org/patch/867951/
https://patchwork.ozlabs.org/patch/867952/
https://patchwork.ozlabs.org/patch/867953/
https://patchwork.ozlabs.org/patch/867954/
https://patchwork.ozlabs.org/patch/867955/
https://patchwork.ozlabs.org/patch/867956/
https://patchwork.ozlabs.org/patch/867957/
https://patchwork.ozlabs.org/patch/867958/
https://patchwork.ozlabs.org/patch/867959/There is no clean upstream target yet since kernel patch is still in RFC stage, The purpose of the patchset is just for anyone that want to eveluate
af_xdpwith DPDK application and get feedback for further improvement.To try with the new PMD
1. compile and install the kernel with above patches applied.
2. configure $LINUX_HEADER_DIR (dir of "makeheaders_install") and $TOOLS_DIR (dir at <kernel_src>/tools) at driver/net/af_xdp/Makefile before compile DPDK.
3. make sure libelf and libbpf is installed.
Quoted 2 lines
BTW, performance test shows our PMD can reach 94%~98% of the orignal benchmark when share memory is enabled.
Hi:
Looks like zerocopy is not used in this series. Any plan to support that? If not, what's the advantage compared to vhost-net + tap + XDP_REDIRECT?
Have you measured l2fwd performance in this case? I believe the number you refer here is rxdrop (XDP_DRV) which is 11.6Mpps.
Thanks
Quoted 59 lines
-----Original Message-----
From: Jason Wang [mailto:[email protected]]
Sent: Thursday, March 1, 2018 10:52 AM
To: Zhang, Qi Z <[email protected]>; [email protected]
Cc: [email protected]; Topel, Bjorn <[email protected]>
Subject: Re: [dpdk-dev] [RFC 0/7] PMD driver forAF_XDPQuoted 39 lines · Qi Zhang
The RFC patches add a new PMD driver for
AF_XDPwhich is a proposed faster version ofAF_PACKETinterface in Linux, see below link for detailAF_XDPintroduction:
https://fosdem.org/2018/schedule/event/af_xdp/
https://lwn.net/Articles/745934/This patchset is base on v18.02.
It also require a linux kernel that have belowAF_XDPRFC patches be applied.
https://patchwork.ozlabs.org/patch/867961/
https://patchwork.ozlabs.org/patch/867960/
https://patchwork.ozlabs.org/patch/867938/
https://patchwork.ozlabs.org/patch/867939/
https://patchwork.ozlabs.org/patch/867940/
https://patchwork.ozlabs.org/patch/867941/
https://patchwork.ozlabs.org/patch/867942/
https://patchwork.ozlabs.org/patch/867943/
https://patchwork.ozlabs.org/patch/867944/
https://patchwork.ozlabs.org/patch/867945/
https://patchwork.ozlabs.org/patch/867946/
https://patchwork.ozlabs.org/patch/867947/
https://patchwork.ozlabs.org/patch/867948/
https://patchwork.ozlabs.org/patch/867949/
https://patchwork.ozlabs.org/patch/867950/
https://patchwork.ozlabs.org/patch/867951/
https://patchwork.ozlabs.org/patch/867952/
https://patchwork.ozlabs.org/patch/867953/
https://patchwork.ozlabs.org/patch/867954/
https://patchwork.ozlabs.org/patch/867955/
https://patchwork.ozlabs.org/patch/867956/
https://patchwork.ozlabs.org/patch/867957/
https://patchwork.ozlabs.org/patch/867958/
https://patchwork.ozlabs.org/patch/867959/There is no clean upstream target yet since kernel patch is still in RFC stage, The purpose of the patchset is just for anyone that want to eveluate
af_xdpwith DPDK application and get feedback for further improvement.Quoted 4 lines
To try with the new PMD
1. compile and install the kernel with above patches applied.
2. configure $LINUX_HEADER_DIR (dir of "makeheaders_install") and $TOOLS_DIR (dir at <kernel_src>/tools) atdriver/net/af_xdp/Makefile
Quoted 3 lines
before compile DPDK.
3. make sure libelf and libbpf is installed.
Quoted 6 lines
Quoted 2 lines
BTW, performance test shows our PMD can reach 94%~98% of the orignal benchmark when share memory is enabled.
Hi:
Looks like zero copy is not used in this series. Any plan to support that?
Zero copy is enabled in patch 5, if a mempool passed check_mempool, it will be registered to af_xdp socket. so there will be no memcpy between mbuf and af_xdp.
Quoted 4 lines
If not, what's the advantage compared to vhost-net + tap +
XDP_REDIRECT?Have you measured l2fwd performance in this case? I believe the number you refer here is rxdrop (
XDP_DRV) which is 11.6Mpps.
Actually we measure the performance on rxonly / txonly / l2fwd on i40e with XDP_SKB and XDP_DRV_ZC
Regards
Qi
Quoted 2 lines
Thanks
+Magnus, since a typo in my first batch in email address.
Quoted 90 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Zhang, Qi Z
Sent: Thursday, March 1, 2018 12:19 PM
To: Jason Wang <[email protected]>; [email protected]
Cc: [email protected]; Topel, Bjorn <[email protected]>
Subject: Re: [dpdk-dev] [RFC 0/7] PMD driver forAF_XDPQuoted 57 lines
-----Original Message-----
From: Jason Wang [mailto:[email protected]]
Sent: Thursday, March 1, 2018 10:52 AM
To: Zhang, Qi Z <[email protected]>; [email protected]
Cc: [email protected]; Topel, Bjorn <[email protected]>
Subject: Re: [dpdk-dev] [RFC 0/7] PMD driver forAF_XDPQuoted 39 lines · Qi Zhang
The RFC patches add a new PMD driver for
AF_XDPwhich is a proposed faster version ofAF_PACKETinterface in Linux, see below link for detailAF_XDPintroduction:
https://fosdem.org/2018/schedule/event/af_xdp/
https://lwn.net/Articles/745934/This patchset is base on v18.02.
It also require a linux kernel that have belowAF_XDPRFC patches be applied.
https://patchwork.ozlabs.org/patch/867961/
https://patchwork.ozlabs.org/patch/867960/
https://patchwork.ozlabs.org/patch/867938/
https://patchwork.ozlabs.org/patch/867939/
https://patchwork.ozlabs.org/patch/867940/
https://patchwork.ozlabs.org/patch/867941/
https://patchwork.ozlabs.org/patch/867942/
https://patchwork.ozlabs.org/patch/867943/
https://patchwork.ozlabs.org/patch/867944/
https://patchwork.ozlabs.org/patch/867945/
https://patchwork.ozlabs.org/patch/867946/
https://patchwork.ozlabs.org/patch/867947/
https://patchwork.ozlabs.org/patch/867948/
https://patchwork.ozlabs.org/patch/867949/
https://patchwork.ozlabs.org/patch/867950/
https://patchwork.ozlabs.org/patch/867951/
https://patchwork.ozlabs.org/patch/867952/
https://patchwork.ozlabs.org/patch/867953/
https://patchwork.ozlabs.org/patch/867954/
https://patchwork.ozlabs.org/patch/867955/
https://patchwork.ozlabs.org/patch/867956/
https://patchwork.ozlabs.org/patch/867957/
https://patchwork.ozlabs.org/patch/867958/
https://patchwork.ozlabs.org/patch/867959/There is no clean upstream target yet since kernel patch is still in RFC stage, The purpose of the patchset is just for anyone that want to eveluate
af_xdpwith DPDK application and get feedback for further improvement.Quoted 4 lines
To try with the new PMD
1. compile and install the kernel with above patches applied.
2. configure $LINUX_HEADER_DIR (dir of "makeheaders_install") and $TOOLS_DIR (dir at <kernel_src>/tools) atdriver/net/af_xdp/Makefile
Quoted 3 lines
before compile DPDK.
3. make sure libelf and libbpf is installed.Quoted 6 lines
Quoted 2 lines
BTW, performance test shows our PMD can reach 94%~98% of the orignal benchmark when share memory is enabled.
Hi:
Looks like zero copy is not used in this series. Any plan to support that?
Zero copy is enabled in patch 5, if a mempool passed
check_mempool, it will be registered toaf_xdpsocket.
so there will be no memcpy between mbuf andaf_xdp.Quoted 4 lines
If not, what's the advantage compared to vhost-net + tap +
XDP_REDIRECT?Have you measured l2fwd performance in this case? I believe the number you refer here is rxdrop (
XDP_DRV) which is 11.6Mpps.Actually we measure the performance on rxonly / txonly / l2fwd on i40e with
XDP_SKBandXDP_DRV_ZCRegards
QiQuoted 2 lines
Thanks
Quoted 76 lines · Qi Z
+Magnus, since a typo in my first batch in email address.
Quoted 74 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Zhang, Qi Z
Sent: Thursday, March 1, 2018 12:19 PM
To: Jason Wang<[email protected]>;[email protected] Cc:[email protected]; Topel, Bjorn<[email protected]>
Subject: Re: [dpdk-dev] [RFC 0/7] PMD driver forAF_XDPQuoted 54 lines
-----Original Message-----
From: Jason Wang [mailto:[email protected]]
Sent: Thursday, March 1, 2018 10:52 AM
To: Zhang, Qi Z<[email protected]>;[email protected] Cc:[email protected]; Topel, Bjorn<[email protected]>
Subject: Re: [dpdk-dev] [RFC 0/7] PMD driver forAF_XDPQuoted 39 lines · Qi Zhang
The RFC patches add a new PMD driver for
AF_XDPwhich is a proposed faster version ofAF_PACKETinterface in Linux, see below link for detailAF_XDPintroduction:
https://fosdem.org/2018/schedule/event/af_xdp/
https://lwn.net/Articles/745934/This patchset is base on v18.02.
It also require a linux kernel that have belowAF_XDPRFC patches be applied.
https://patchwork.ozlabs.org/patch/867961/
https://patchwork.ozlabs.org/patch/867960/
https://patchwork.ozlabs.org/patch/867938/
https://patchwork.ozlabs.org/patch/867939/
https://patchwork.ozlabs.org/patch/867940/
https://patchwork.ozlabs.org/patch/867941/
https://patchwork.ozlabs.org/patch/867942/
https://patchwork.ozlabs.org/patch/867943/
https://patchwork.ozlabs.org/patch/867944/
https://patchwork.ozlabs.org/patch/867945/
https://patchwork.ozlabs.org/patch/867946/
https://patchwork.ozlabs.org/patch/867947/
https://patchwork.ozlabs.org/patch/867948/
https://patchwork.ozlabs.org/patch/867949/
https://patchwork.ozlabs.org/patch/867950/
https://patchwork.ozlabs.org/patch/867951/
https://patchwork.ozlabs.org/patch/867952/
https://patchwork.ozlabs.org/patch/867953/
https://patchwork.ozlabs.org/patch/867954/
https://patchwork.ozlabs.org/patch/867955/
https://patchwork.ozlabs.org/patch/867956/
https://patchwork.ozlabs.org/patch/867957/
https://patchwork.ozlabs.org/patch/867958/
https://patchwork.ozlabs.org/patch/867959/There is no clean upstream target yet since kernel patch is still in RFC stage, The purpose of the patchset is just for anyone that want to eveluate
af_xdpwith DPDK application and get feedback for further improvement.Quoted 4 lines
To try with the new PMD
1. compile and install the kernel with above patches applied.
2. configure $LINUX_HEADER_DIR (dir of "makeheaders_install") and $TOOLS_DIR (dir at <kernel_src>/tools) atdriver/net/af_xdp/Makefile
Quoted 8 lines
Quoted 5 lines
before compile DPDK.
3. make sure libelf and libbpf is installed.BTW, performance test shows our PMD can reach 94%~98% of the orignal benchmark when share memory is enabled.
Hi:
Looks like zero copy is not used in this series. Any plan to support that?
Zero copy is enabled in patch 5, if a mempool passed
check_mempool, it will be registered toaf_xdpsocket.
so there will be no memcpy between mbuf andaf_xdp.
Aha, I see. So the zerocopy was limited to some specific use case. And if I understand it correctly, zc mode could not be used for VM.
Thanks
Quoted 11 lines
Quoted 11 lines
Quoted 4 lines
If not, what's the advantage compared to vhost-net + tap +
XDP_REDIRECT?Have you measured l2fwd performance in this case? I believe the number you refer here is rxdrop (
XDP_DRV) which is 11.6Mpps.Actually we measure the performance on rxonly / txonly / l2fwd on i40e with
XDP_SKBandXDP_DRV_ZCRegards
QiQuoted 1 line
Thanks
Quoted 85 lines
-----Original Message-----
From: Jason Wang [mailto:[email protected]]
Sent: Thursday, March 1, 2018 3:46 PM
To: Zhang, Qi Z <[email protected]>; [email protected]
Cc: Karlsson, Magnus <[email protected]>; Topel, Bjorn <[email protected]>
Subject: Re: [dpdk-dev] [RFC 0/7] PMD driver forAF_XDPQuoted 72 lines · Qi Z
+Magnus, since a typo in my first batch in email address.
Quoted 70 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Zhang, Qi Z
Sent: Thursday, March 1, 2018 12:19 PM
To: Jason Wang<[email protected]>;[email protected] Cc:[email protected]; Topel, Bjorn<[email protected]>
Subject: Re: [dpdk-dev] [RFC 0/7] PMD driver forAF_XDPQuoted 61 lines
-----Original Message-----
From: Jason Wang [mailto:[email protected]]
Sent: Thursday, March 1, 2018 10:52 AM
To: Zhang, Qi Z<[email protected]>;[email protected] Cc:[email protected]; Topel, Bjorn<[email protected]>
Subject: Re: [dpdk-dev] [RFC 0/7] PMD driver forAF_XDPQuoted 39 lines · Qi Zhang
The RFC patches add a new PMD driver for
AF_XDPwhich is a proposed faster version ofAF_PACKETinterface in Linux, see below link for detailAF_XDPintroduction:
https://fosdem.org/2018/schedule/event/af_xdp/
https://lwn.net/Articles/745934/This patchset is base on v18.02.
It also require a linux kernel that have belowAF_XDPRFC patches be applied.
https://patchwork.ozlabs.org/patch/867961/
https://patchwork.ozlabs.org/patch/867960/
https://patchwork.ozlabs.org/patch/867938/
https://patchwork.ozlabs.org/patch/867939/
https://patchwork.ozlabs.org/patch/867940/
https://patchwork.ozlabs.org/patch/867941/
https://patchwork.ozlabs.org/patch/867942/
https://patchwork.ozlabs.org/patch/867943/
https://patchwork.ozlabs.org/patch/867944/
https://patchwork.ozlabs.org/patch/867945/
https://patchwork.ozlabs.org/patch/867946/
https://patchwork.ozlabs.org/patch/867947/
https://patchwork.ozlabs.org/patch/867948/
https://patchwork.ozlabs.org/patch/867949/
https://patchwork.ozlabs.org/patch/867950/
https://patchwork.ozlabs.org/patch/867951/
https://patchwork.ozlabs.org/patch/867952/
https://patchwork.ozlabs.org/patch/867953/
https://patchwork.ozlabs.org/patch/867954/
https://patchwork.ozlabs.org/patch/867955/
https://patchwork.ozlabs.org/patch/867956/
https://patchwork.ozlabs.org/patch/867957/
https://patchwork.ozlabs.org/patch/867958/
https://patchwork.ozlabs.org/patch/867959/There is no clean upstream target yet since kernel patch is still in RFC stage, The purpose of the patchset is just for anyone that want to eveluate
af_xdpwith DPDK application and get feedback for further improvement.Quoted 4 lines
To try with the new PMD
1. compile and install the kernel with above patches applied.
2. configure $LINUX_HEADER_DIR (dir of "makeheaders_install") and $TOOLS_DIR (dir at <kernel_src>/tools) atdriver/net/af_xdp/Makefile
Quoted 5 lines
before compile DPDK.
3. make sure libelf and libbpf is installed.BTW, performance test shows our PMD can reach 94%~98% of the orignal benchmark when share memory is enabled.
Hi:
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Looks like zero copy is not used in this series. Any plan to support that?
Zero copy is enabled in patch 5, if a mempool passed
check_mempool, it will be registered toaf_xdpsocket.
so there will be no memcpy between mbuf andaf_xdp.Aha, I see. So the zerocopy was limited to some specific use case. And if I understand it correctly, zc mode could not be used for VM.
I think except the limitation for mempool layout, zerocopy is transparent to DPDK application, only difference is performance. Sorry, I may not get your point, if you could explain more about the VM usage.
Regards
Qi
Quoted 15 lines
Thanks
Quoted 1 line
Quoted 1 line
Quoted 1 line
If not, what's the advantage compared to vhost-net + tap +
XDP_REDIRECT?Quoted 10 lines
Quoted 10 lines
Quoted 3 lines
Have you measured l2fwd performance in this case? I believe the number you refer here is rxdrop (
XDP_DRV) which is 11.6Mpps.Actually we measure the performance on rxonly / txonly / l2fwd on i40e with
XDP_SKBandXDP_DRV_ZCRegards
QiQuoted 1 line
Thanks
Quoted 8 lines · Qi Z
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
BTW, performance test shows our PMD can reach 94%~98% of the orignal benchmark when share memory is enabled.
Hi:
Looks like zero copy is not used in this series. Any plan to support that?
Zero copy is enabled in patch 5, if a mempool passed
check_mempool, it will be registered toaf_xdpsocket.
so there will be no memcpy between mbuf andaf_xdp.
Quoted 7 lines
Quoted 2 lines
Aha, I see. So the zerocopy was limited to some specific use case. And if I understand it correctly, zc mode could not be used for VM.
I think except the limitation for mempool layout, zerocopy is transparent to DPDK application, only difference is performance. Sorry, I may not get your point, if you could explain more about the VM usage.
Regards
Qi
No problem, so the question is:
Can zerocopy be used when using testpmd to foward packets between vhost-user and AF_XDP socket?
Thanks
Quoted 29 lines
-----Original Message-----
From: Jason Wang [mailto:[email protected]]
Sent: Thursday, March 1, 2018 9:18 PM
To: Zhang, Qi Z <[email protected]>
Cc: Karlsson, Magnus <[email protected]>; Topel, Bjorn <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [RFC 0/7] PMD driver forAF_XDPQuoted 5 lines · Qi Z
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
BTW, performance test shows our PMD can reach 94%~98% of the orignal benchmark when share memory is enabled.
Hi:
Looks like zero copy is not used in this series. Any plan to support
that?
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
Zero copy is enabled in patch 5, if a mempool passed
check_mempool, it will be registered toaf_xdpsocket.
so there will be no memcpy between mbuf andaf_xdp.Aha, I see. So the zerocopy was limited to some specific use case. And if I understand it correctly, zc mode could not be used for VM.
I think except the limitation for mempool layout, zerocopy is transparent
to DPDK application, only difference is performance.
Quoted 1 line
Sorry, I may not get your point, if you could explain more about the VM
usage.
Quoted 1 line
Quoted 7 lines
Quoted 2 lines
Regards
QiNo problem, so the question is:
Can zerocopy be used when using testpmd to foward packets between vhost-user and
AF_XDPsocket?
I'm not very familiar with vhost-user, but I guess the answer should be same as the case for forward packet between vhost-user and i40e, (if vhost-user does not have any special requirement for mempool that conflict with af_xdp ZC's requirement)
Regards
Qi
Quoted 2 lines
Thanks