Re: [PATCH v1 01/25] drivers/net: introduce a new PMD driver
On Wed, 22 Dec 2021 08:55:22 -0800 Stephen Hemminger wrote: > On Wed, 22 Dec 2021 08:54:00 +0800 > Yanling Song wrote: > > > > If all you want is jiffie accuracy, you could use > > > CLOCK_MONOTONIC_COARSE. > > > > > I did not get your point: CLOCK_MONOTONIC is more accurate than > > CLOCK_MONOTONIC_COARSE, right? > > CLOCK_MONOTONIC ends up using the TSC counter and values in the > shared page (VDSO) to compute time accurately. > > CLOCK_MONOTONIC_COARSE is faster and good enough if you only > want ms accuracy. It just reads a value from shared page > and avoids the TSC instruction. OK. Got it. Thanks. Will be included in the next version.
[PATCH v1] net/mlx5: fix assertion on the flags set in pkt mbuf
Fixed the assertion on the flags set in pkt->ol_flags for vectorized MPRQ. With vectorized MPRQ the CQs are processed before copying the MPRQ bufs so the valid assertion is that the expected flag is set and not that the pkt->ol_flags equlas this flag alone. Fixes: 0f20acbf5eda ("net/mlx5: implement vectorized MPRQ burst") Cc: akozy...@nvidia.com Cc: sta...@dpdk.org Signed-off-by: Lior Margalit Acked-by: Slava Ovsiienko --- drivers/net/mlx5/mlx5_rx.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/mlx5/mlx5_rx.h b/drivers/net/mlx5/mlx5_rx.h index adb759c235..c178f9a24b 100644 --- a/drivers/net/mlx5/mlx5_rx.h +++ b/drivers/net/mlx5/mlx5_rx.h @@ -543,7 +543,7 @@ mprq_buf_to_pkt(struct mlx5_rxq_data *rxq, struct rte_mbuf *pkt, uint32_t len, buf_len, shinfo); /* Set mbuf head-room. */ SET_DATA_OFF(pkt, RTE_PKTMBUF_HEADROOM); - MLX5_ASSERT(pkt->ol_flags == RTE_MBUF_F_EXTERNAL); + MLX5_ASSERT(pkt->ol_flags & RTE_MBUF_F_EXTERNAL); MLX5_ASSERT(rte_pktmbuf_tailroom(pkt) >= len - (hdrm_overlap > 0 ? hdrm_overlap : 0)); DATA_LEN(pkt) = len; -- 2.25.1
[PATCH v2 01/25] drivers/net: introduce a new PMD driver
Introduce a new PMD driver which names spnic. Now, this driver only implements module entry without doing anything else. Signed-off-by: Yanling Song --- drivers/net/meson.build | 1 + drivers/net/spnic/base/meson.build| 26 drivers/net/spnic/base/spnic_compat.h | 184 ++ drivers/net/spnic/meson.build | 17 +++ drivers/net/spnic/spnic_ethdev.c | 107 +++ drivers/net/spnic/spnic_ethdev.h | 28 drivers/net/spnic/version.map | 3 + 7 files changed, 366 insertions(+) create mode 100644 drivers/net/spnic/base/meson.build create mode 100644 drivers/net/spnic/base/spnic_compat.h create mode 100644 drivers/net/spnic/meson.build create mode 100644 drivers/net/spnic/spnic_ethdev.c create mode 100644 drivers/net/spnic/spnic_ethdev.h create mode 100644 drivers/net/spnic/version.map diff --git a/drivers/net/meson.build b/drivers/net/meson.build index 2355d1cde8..a5c715f59c 100644 --- a/drivers/net/meson.build +++ b/drivers/net/meson.build @@ -53,6 +53,7 @@ drivers = [ 'ring', 'sfc', 'softnic', + 'spnic', 'tap', 'thunderx', 'txgbe', diff --git a/drivers/net/spnic/base/meson.build b/drivers/net/spnic/base/meson.build new file mode 100644 index 00..e83a473881 --- /dev/null +++ b/drivers/net/spnic/base/meson.build @@ -0,0 +1,26 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2021 Ramaxel Memory Technology, Ltd + +sources = [ +] + +extra_flags = [] +# The driver runs only on arch64 machine, remove 32bit warnings +if not dpdk_conf.get('RTE_ARCH_64') +extra_flags += ['-Wno-int-to-pointer-cast', '-Wno-pointer-to-int-cast'] +endif + +foreach flag: extra_flags +if cc.has_argument(flag) +cflags += flag +endif +endforeach + +deps += ['hash'] +cflags += ['-DHW_CONVERT_ENDIAN'] +c_args = cflags + +base_lib = static_library('spnic_base', sources, + dependencies: [static_rte_eal, static_rte_ethdev, static_rte_bus_pci, static_rte_hash], + c_args: c_args) +base_objs = base_lib.extract_all_objects() diff --git a/drivers/net/spnic/base/spnic_compat.h b/drivers/net/spnic/base/spnic_compat.h new file mode 100644 index 00..cc94a8c225 --- /dev/null +++ b/drivers/net/spnic/base/spnic_compat.h @@ -0,0 +1,184 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2021 Ramaxel Memory Technology, Ltd + */ + +#ifndef _SPNIC_COMPAT_H_ +#define _SPNIC_COMPAT_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef uint8_t u8; +typedef int8_ts8; +typedef uint16_t u16; +typedef uint32_t u32; +typedef int32_t s32; +typedef uint64_t u64; + +#ifndef BIT +#define BIT(n) (1 << (n)) +#endif + +#define upper_32_bits(n) ((u32)(((n) >> 16) >> 16)) +#define lower_32_bits(n) ((u32)(n)) + +#define SPNIC_MEM_ALLOC_ALIGN_MIN 1 + +#define SPNIC_DRIVER_NAME "spnic" + +extern int spnic_logtype; + +#define PMD_DRV_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, spnic_logtype, \ + SPNIC_DRIVER_NAME ": " fmt "\n", ##args) + +/* Bit order interface */ +#define cpu_to_be16(o) rte_cpu_to_be_16(o) +#define cpu_to_be32(o) rte_cpu_to_be_32(o) +#define cpu_to_be64(o) rte_cpu_to_be_64(o) +#define cpu_to_le32(o) rte_cpu_to_le_32(o) +#define be16_to_cpu(o) rte_be_to_cpu_16(o) +#define be32_to_cpu(o) rte_be_to_cpu_32(o) +#define be64_to_cpu(o) rte_be_to_cpu_64(o) +#define le32_to_cpu(o) rte_le_to_cpu_32(o) + +#define ARRAY_LEN(arr) ((sizeof(arr) / sizeof((arr)[0]))) + +#define SPNIC_MUTEX_TIMEOUT10 +#define SPNIC_S_TO_MS_UNIT 1000 +#define SPNIC_S_TO_NS_UNIT 100 + +static inline unsigned long clock_gettime_ms(void) +{ + struct timespec tv; + + (void)clock_gettime(CLOCK_MONOTONIC_COARSE, &tv); + + return (unsigned long)tv.tv_sec * SPNIC_S_TO_MS_UNIT + + (unsigned long)tv.tv_nsec / SPNIC_S_TO_NS_UNIT; +} + +#define jiffiesclock_gettime_ms() +#define msecs_to_jiffies(ms) (ms) + +#define time_after(a, b) ((long)((b) - (a)) < 0) +#define time_before(a, b) time_after(b, a) + +/** + * Convert data to big endian 32 bit format + * + * @param data + * The data to convert + * @param len + * Length of data to convert, must be Multiple of 4B + */ +static inline void spnic_cpu_to_be32(void *data, int len) +{ + int i, chunk_sz = sizeof(u32); + u32 *mem = data; + + if (!data) + return; + + len = len / chunk_sz; + + for (i = 0; i < len; i++) { + *mem = cpu_to_be32(*mem); + mem++; + } +} + +/** + * Convert data from big endian 32 bit format + * + * @param data + * The data to convert + * @param len + * Length of data to convert, must be Multiple of 4B + */ +static inline void spnic_be32_to_cpu(void *data, int len) +{ +
[PATCH v2 02/25] net/spnic: initialize the HW interface
Add HW interface registers and initialize the HW interface. Signed-off-by: Yanling Song --- drivers/net/spnic/base/meson.build | 2 + drivers/net/spnic/base/spnic_csr.h | 104 drivers/net/spnic/base/spnic_hwdev.c | 41 ++ drivers/net/spnic/base/spnic_hwdev.h | 29 + drivers/net/spnic/base/spnic_hwif.c | 774 +++ drivers/net/spnic/base/spnic_hwif.h | 155 ++ drivers/net/spnic/spnic_ethdev.c | 66 +++ drivers/net/spnic/spnic_ethdev.h | 48 +- 8 files changed, 1212 insertions(+), 7 deletions(-) create mode 100644 drivers/net/spnic/base/spnic_csr.h create mode 100644 drivers/net/spnic/base/spnic_hwdev.c create mode 100644 drivers/net/spnic/base/spnic_hwdev.h create mode 100644 drivers/net/spnic/base/spnic_hwif.c create mode 100644 drivers/net/spnic/base/spnic_hwif.h diff --git a/drivers/net/spnic/base/meson.build b/drivers/net/spnic/base/meson.build index e83a473881..edd6e94772 100644 --- a/drivers/net/spnic/base/meson.build +++ b/drivers/net/spnic/base/meson.build @@ -2,6 +2,8 @@ # Copyright(c) 2021 Ramaxel Memory Technology, Ltd sources = [ + 'spnic_hwdev.c', + 'spnic_hwif.c' ] extra_flags = [] diff --git a/drivers/net/spnic/base/spnic_csr.h b/drivers/net/spnic/base/spnic_csr.h new file mode 100644 index 00..b4cf7c2593 --- /dev/null +++ b/drivers/net/spnic/base/spnic_csr.h @@ -0,0 +1,104 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2021 Ramaxel Memory Technology, Ltd + */ + +#ifndef _SPNIC_CSR_H_ +#define _SPNIC_CSR_H_ + +#define PCI_VENDOR_ID_RAMAXEL 0x1E81 + +/* Device ids */ +#define SPNIC_DEV_ID_PF0x9020 +#define SPNIC_DEV_ID_VF0x9001 + +/* + * Bit30/bit31 for bar index flag + * 00: bar0 + * 01: bar1 + * 10: bar2 + * 11: bar3 + */ +#define SPNIC_CFG_REGS_FLAG0x4000 + +#define SPNIC_MGMT_REGS_FLAG 0xC000 + +#define SPNIC_REGS_FLAG_MASK 0x3FFF + +#define SPNIC_VF_CFG_REG_OFFSET 0x2000 + +#define SPNIC_HOST_CSR_BASE_ADDR (SPNIC_MGMT_REGS_FLAG + 0x6000) +#define SPNIC_CSR_GLOBAL_BASE_ADDR (SPNIC_MGMT_REGS_FLAG + 0x6400) + +/* HW interface registers */ +#define SPNIC_CSR_FUNC_ATTR0_ADDR (SPNIC_CFG_REGS_FLAG + 0x0) +#define SPNIC_CSR_FUNC_ATTR1_ADDR (SPNIC_CFG_REGS_FLAG + 0x4) +#define SPNIC_CSR_FUNC_ATTR2_ADDR (SPNIC_CFG_REGS_FLAG + 0x8) +#define SPNIC_CSR_FUNC_ATTR3_ADDR (SPNIC_CFG_REGS_FLAG + 0xC) +#define SPNIC_CSR_FUNC_ATTR4_ADDR (SPNIC_CFG_REGS_FLAG + 0x10) +#define SPNIC_CSR_FUNC_ATTR5_ADDR (SPNIC_CFG_REGS_FLAG + 0x14) +#define SPNIC_CSR_FUNC_ATTR6_ADDR (SPNIC_CFG_REGS_FLAG + 0x18) + +#define SPNIC_FUNC_CSR_MAILBOX_DATA_OFF0x80 +#define SPNIC_FUNC_CSR_MAILBOX_CONTROL_OFF (SPNIC_CFG_REGS_FLAG + 0x0100) +#define SPNIC_FUNC_CSR_MAILBOX_INT_OFFSET_OFF (SPNIC_CFG_REGS_FLAG + 0x0104) +#define SPNIC_FUNC_CSR_MAILBOX_RESULT_H_OFF(SPNIC_CFG_REGS_FLAG + 0x0108) +#define SPNIC_FUNC_CSR_MAILBOX_RESULT_L_OFF(SPNIC_CFG_REGS_FLAG + 0x010C) + +#define SPNIC_PPF_ELECTION_OFFSET 0x0 +#define SPNIC_MPF_ELECTION_OFFSET 0x20 + +#define SPNIC_CSR_PPF_ELECTION_ADDR\ + (SPNIC_HOST_CSR_BASE_ADDR + SPNIC_PPF_ELECTION_OFFSET) + +#define SPNIC_CSR_GLOBAL_MPF_ELECTION_ADDR \ + (SPNIC_HOST_CSR_BASE_ADDR + SPNIC_MPF_ELECTION_OFFSET) + +#define SPNIC_CSR_DMA_ATTR_TBL_ADDR(SPNIC_CFG_REGS_FLAG + 0x380) +#define SPNIC_CSR_DMA_ATTR_INDIR_IDX_ADDR (SPNIC_CFG_REGS_FLAG + 0x390) + +/* MSI-X registers */ +#define SPNIC_CSR_MSIX_INDIR_IDX_ADDR (SPNIC_CFG_REGS_FLAG + 0x310) +#define SPNIC_CSR_MSIX_CTRL_ADDR (SPNIC_CFG_REGS_FLAG + 0x300) +#define SPNIC_CSR_MSIX_CNT_ADDR(SPNIC_CFG_REGS_FLAG + 0x304) +#define SPNIC_CSR_FUNC_MSI_CLR_WR_ADDR (SPNIC_CFG_REGS_FLAG + 0x58) + +#define SPNIC_MSI_CLR_INDIR_RESEND_TIMER_CLR_SHIFT 0 +#define SPNIC_MSI_CLR_INDIR_INT_MSK_SET_SHIFT 1 +#define SPNIC_MSI_CLR_INDIR_INT_MSK_CLR_SHIFT 2 +#define SPNIC_MSI_CLR_INDIR_AUTO_MSK_SET_SHIFT 3 +#define SPNIC_MSI_CLR_INDIR_AUTO_MSK_CLR_SHIFT 4 +#define SPNIC_MSI_CLR_INDIR_SIMPLE_INDIR_IDX_SHIFT 22 + +#define SPNIC_MSI_CLR_INDIR_RESEND_TIMER_CLR_MASK 0x1U +#define SPNIC_MSI_CLR_INDIR_INT_MSK_SET_MASK 0x1U +#define SPNIC_MSI_CLR_INDIR_INT_MSK_CLR_MASK 0x1U +#define SPNIC_MSI_CLR_INDIR_AUTO_MSK_SET_MASK 0x1U +#define SPNIC_MSI_CLR_INDIR_AUTO_MSK_CLR_MASK 0x1U +#define SPNIC_MSI_CLR_INDIR_SIMPLE_INDIR_IDX_MASK 0x3FFU + +#define SPNIC_MSI_CLR_INDIR_SET(val, member) \ + (((val) & SPNIC_MSI_CLR_INDIR_##member##_MASK) << \ + SPNIC_MSI_CLR_INDIR_##member##_SHIFT) + +/* EQ registers */ +#de
[PATCH v2 00/25] Net/SPNIC: support SPNIC into DPDK 22.03
The patchsets introduce SPNIC driver for Ramaxel's SPNxx serial NIC cards into DPDK 22.03. Ramaxel Memory Technology is a company which supply a lot of electric products: storage, communication, PCB... SPNxxx is a serial PCIE interface NIC cards: SPN110: 2 PORTs *25G SPN120: 4 PORTs *25G SPN130: 2 PORTs *100G The following is main features of our SPNIC: - TSO - LRO - Flow control - SR-IOV(Partially supported) - VLAN offload - VLAN filter - CRC offload - Promiscuous mode - RSS v1->v2: 1. Fix coding style issues and compiling failures; 2. Only support linux in meson.build; 3. Use CLOCK_MONOTONIC_COARSE instead of CLOCK_MONOTONIC/CLOCK_MONOTONIC_RAW; 4. Fix time_before(); 5. Remove redundant checks in spnic_dev_configure(); Yanling Song (25): drivers/net: introduce a new PMD driver net/spnic: initialize the HW interface net/spnic: add mbox message channel net/spnic: introduce event queue net/spnic: add mgmt module net/spnic: add cmdq and work queue net/spnic: add interface handling cmdq message net/spnic: add hardware info initialization net/spnic: support MAC and link event handling net/spnic: add function info initialization net/spnic: add queue pairs context initialization net/spnic: support mbuf handling of Tx/Rx net/spnic: support Rx congfiguration net/spnic: add port/vport enable net/spnic: support IO packets handling net/spnic: add device configure/version/info net/spnic: support RSS configuration update and get net/spnic: support VLAN filtering and offloading net/spnic: support promiscuous and allmulticast Rx modes net/spnic: support flow control net/spnic: support getting Tx/Rx queues info net/spnic: net/spnic: support xstats statistics net/spnic: support VFIO interrupt net/spnic: support Tx/Rx queue start/stop net/spnic: add doc infrastructure MAINTAINERS |6 + doc/guides/nics/features/spnic.ini | 40 + doc/guides/nics/spnic.rst| 61 + drivers/net/meson.build |1 + drivers/net/spnic/base/meson.build | 37 + drivers/net/spnic/base/spnic_cmd.h | 222 ++ drivers/net/spnic/base/spnic_cmdq.c | 875 ++ drivers/net/spnic/base/spnic_cmdq.h | 248 ++ drivers/net/spnic/base/spnic_compat.h| 190 ++ drivers/net/spnic/base/spnic_csr.h | 104 + drivers/net/spnic/base/spnic_eqs.c | 661 + drivers/net/spnic/base/spnic_eqs.h | 102 + drivers/net/spnic/base/spnic_hw_cfg.c| 212 ++ drivers/net/spnic/base/spnic_hw_cfg.h| 125 + drivers/net/spnic/base/spnic_hw_comm.c | 485 drivers/net/spnic/base/spnic_hw_comm.h | 204 ++ drivers/net/spnic/base/spnic_hwdev.c | 514 drivers/net/spnic/base/spnic_hwdev.h | 143 + drivers/net/spnic/base/spnic_hwif.c | 774 ++ drivers/net/spnic/base/spnic_hwif.h | 155 ++ drivers/net/spnic/base/spnic_mbox.c | 1194 drivers/net/spnic/base/spnic_mbox.h | 202 ++ drivers/net/spnic/base/spnic_mgmt.c | 367 +++ drivers/net/spnic/base/spnic_mgmt.h | 110 + drivers/net/spnic/base/spnic_nic_cfg.c | 1348 + drivers/net/spnic/base/spnic_nic_cfg.h | 1110 drivers/net/spnic/base/spnic_nic_event.c | 185 ++ drivers/net/spnic/base/spnic_nic_event.h | 24 + drivers/net/spnic/base/spnic_wq.c| 139 + drivers/net/spnic/base/spnic_wq.h| 123 + drivers/net/spnic/meson.build| 14 + drivers/net/spnic/spnic_ethdev.c | 3212 ++ drivers/net/spnic/spnic_ethdev.h | 95 + drivers/net/spnic/spnic_io.c | 738 + drivers/net/spnic/spnic_io.h | 154 ++ drivers/net/spnic/spnic_rx.c | 956 +++ drivers/net/spnic/spnic_rx.h | 326 +++ drivers/net/spnic/spnic_tx.c | 858 ++ drivers/net/spnic/spnic_tx.h | 297 ++ drivers/net/spnic/version.map|3 + 40 files changed, 16614 insertions(+) create mode 100644 doc/guides/nics/features/spnic.ini create mode 100644 doc/guides/nics/spnic.rst create mode 100644 drivers/net/spnic/base/meson.build create mode 100644 drivers/net/spnic/base/spnic_cmd.h create mode 100644 drivers/net/spnic/base/spnic_cmdq.c create mode 100644 drivers/net/spnic/base/spnic_cmdq.h create mode 100644 drivers/net/spnic/base/spnic_compat.h create mode 100644 drivers/net/spnic/base/spnic_csr.h create mode 100644 drivers/net/spnic/base/spnic_eqs.c create mode 100644 drivers/net/spnic/base/spnic_eqs.h create mode 100644 drivers/net/spnic/base/spnic_hw_cfg.c create mode 100644 drivers/net/spnic/base/spnic_hw_cfg.h create mode 100644 drivers/net/spnic/base/spnic_hw_comm.c create mode 100644 drivers/net/spnic/base/spnic_hw_comm.h create mode 100644 drivers/net/spnic/base/spnic_hwdev.c create mode 100644 drivers/net/spnic/base/spnic_hwdev.h create mode 100644 drivers/net/spnic/base/spnic_hwif.c create mode 100644 drivers/net/spnic/bas
[PATCH v2 04/25] net/spnic: introduce event queue
This patch introduce event queue to receive response message from hardware or destiation function when a source function send mbox to it. This commit implements the related data structure, initialization and interfaces handling the message. Signed-off-by: Yanling Song --- drivers/net/spnic/base/meson.build | 1 + drivers/net/spnic/base/spnic_eqs.c | 606 +++ drivers/net/spnic/base/spnic_eqs.h | 102 + drivers/net/spnic/base/spnic_hwdev.c | 44 +- drivers/net/spnic/base/spnic_hwdev.h | 22 + drivers/net/spnic/base/spnic_mbox.c | 20 +- 6 files changed, 790 insertions(+), 5 deletions(-) create mode 100644 drivers/net/spnic/base/spnic_eqs.c create mode 100644 drivers/net/spnic/base/spnic_eqs.h diff --git a/drivers/net/spnic/base/meson.build b/drivers/net/spnic/base/meson.build index de80eef7c4..ce7457f400 100644 --- a/drivers/net/spnic/base/meson.build +++ b/drivers/net/spnic/base/meson.build @@ -2,6 +2,7 @@ # Copyright(c) 2021 Ramaxel Memory Technology, Ltd sources = [ + 'spnic_eqs.c', 'spnic_hwdev.c', 'spnic_hwif.c', 'spnic_mbox.c' diff --git a/drivers/net/spnic/base/spnic_eqs.c b/drivers/net/spnic/base/spnic_eqs.c new file mode 100644 index 00..7953976441 --- /dev/null +++ b/drivers/net/spnic/base/spnic_eqs.c @@ -0,0 +1,606 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2021 Ramaxel Memory Technology, Ltd + */ + +#include +#include +#include +#include "spnic_compat.h" +#include "spnic_hwdev.h" +#include "spnic_hwif.h" +#include "spnic_csr.h" +#include "spnic_eqs.h" +#include "spnic_mgmt.h" +#include "spnic_mbox.h" + +#define AEQ_CTRL_0_INTR_IDX_SHIFT 0 +#define AEQ_CTRL_0_DMA_ATTR_SHIFT 12 +#define AEQ_CTRL_0_PCI_INTF_IDX_SHIFT 20 +#define AEQ_CTRL_0_INTR_MODE_SHIFT 31 + +#define AEQ_CTRL_0_INTR_IDX_MASK 0x3FFU +#define AEQ_CTRL_0_DMA_ATTR_MASK 0x3FU +#define AEQ_CTRL_0_PCI_INTF_IDX_MASK 0x7U +#define AEQ_CTRL_0_INTR_MODE_MASK 0x1U + +#define AEQ_CTRL_0_SET(val, member)\ + (((val) & AEQ_CTRL_0_##member##_MASK) << \ + AEQ_CTRL_0_##member##_SHIFT) + +#define AEQ_CTRL_0_CLEAR(val, member) \ + ((val) & (~(AEQ_CTRL_0_##member##_MASK \ + << AEQ_CTRL_0_##member##_SHIFT))) + +#define AEQ_CTRL_1_LEN_SHIFT 0 +#define AEQ_CTRL_1_ELEM_SIZE_SHIFT 24 +#define AEQ_CTRL_1_PAGE_SIZE_SHIFT 28 + +#define AEQ_CTRL_1_LEN_MASK0x1FU +#define AEQ_CTRL_1_ELEM_SIZE_MASK 0x3U +#define AEQ_CTRL_1_PAGE_SIZE_MASK 0xFU + +#define AEQ_CTRL_1_SET(val, member)\ + (((val) & AEQ_CTRL_1_##member##_MASK) << \ + AEQ_CTRL_1_##member##_SHIFT) + +#define AEQ_CTRL_1_CLEAR(val, member) \ + ((val) & (~(AEQ_CTRL_1_##member##_MASK \ + << AEQ_CTRL_1_##member##_SHIFT))) + +#define SPNIC_EQ_PROD_IDX_MASK 0xF +#define SPNIC_TASK_PROCESS_EQE_LIMIT 1024 +#define SPNIC_EQ_UPDATE_CI_STEP 64 + +#define EQ_ELEM_DESC_TYPE_SHIFT0 +#define EQ_ELEM_DESC_SRC_SHIFT 7 +#define EQ_ELEM_DESC_SIZE_SHIFT8 +#define EQ_ELEM_DESC_WRAPPED_SHIFT 31 + +#define EQ_ELEM_DESC_TYPE_MASK 0x7FU +#define EQ_ELEM_DESC_SRC_MASK 0x1U +#define EQ_ELEM_DESC_SIZE_MASK 0xFFU +#define EQ_ELEM_DESC_WRAPPED_MASK 0x1U + +#define EQ_ELEM_DESC_GET(val, member) \ + (((val) >> EQ_ELEM_DESC_##member##_SHIFT) & \ + EQ_ELEM_DESC_##member##_MASK) + +#define EQ_CI_SIMPLE_INDIR_CI_SHIFT0 +#define EQ_CI_SIMPLE_INDIR_ARMED_SHIFT 21 +#define EQ_CI_SIMPLE_INDIR_AEQ_IDX_SHIFT 30 + +#define EQ_CI_SIMPLE_INDIR_CI_MASK 0x1FU +#define EQ_CI_SIMPLE_INDIR_ARMED_MASK 0x1U +#define EQ_CI_SIMPLE_INDIR_AEQ_IDX_MASK0x3U + +#define EQ_CI_SIMPLE_INDIR_SET(val, member)\ + (((val) & EQ_CI_SIMPLE_INDIR_##member##_MASK) << \ + EQ_CI_SIMPLE_INDIR_##member##_SHIFT) + +#define EQ_CI_SIMPLE_INDIR_CLEAR(val, member) \ + ((val) & (~(EQ_CI_SIMPLE_INDIR_##member##_MASK \ + << EQ_CI_SIMPLE_INDIR_##member##_SHIFT))) + +#define EQ_WRAPPED(eq) ((u32)(eq)->wrapped << EQ_VALID_SHIFT) + +#define EQ_CONS_IDX(eq)((eq)->cons_idx | \ + ((u32)(eq)->wrapped << EQ_WRAPPED_SHIFT)) +#define GET_EQ_NUM_PAGES(eq, size) \ + ((u16)(RTE_ALIGN((u32)((eq)->eq_len * (
[PATCH v2 08/25] net/spnic: add hardware info initialization
This commits add hardware info initialization, including that device capability initialization, common feature negotiation, and two interfaces spnic_get_board_info(), spnic_get_mgmt_version() to get hardware info and firmware version. Signed-off-by: Yanling Song --- drivers/net/spnic/base/meson.build | 3 +- drivers/net/spnic/base/spnic_hw_cfg.c | 157 + drivers/net/spnic/base/spnic_hw_cfg.h | 117 ++ drivers/net/spnic/base/spnic_hw_comm.c | 121 +++ drivers/net/spnic/base/spnic_hw_comm.h | 22 drivers/net/spnic/base/spnic_hwdev.c | 70 +++ drivers/net/spnic/base/spnic_hwdev.h | 5 + drivers/net/spnic/base/spnic_mbox.c| 8 ++ 8 files changed, 502 insertions(+), 1 deletion(-) create mode 100644 drivers/net/spnic/base/spnic_hw_cfg.c create mode 100644 drivers/net/spnic/base/spnic_hw_cfg.h diff --git a/drivers/net/spnic/base/meson.build b/drivers/net/spnic/base/meson.build index da6d6ee4a2..77a56ca41e 100644 --- a/drivers/net/spnic/base/meson.build +++ b/drivers/net/spnic/base/meson.build @@ -10,7 +10,8 @@ sources = [ 'spnic_nic_event.c', 'spnic_cmdq.c', 'spnic_hw_comm.c', - 'spnic_wq.c' + 'spnic_wq.c', + 'spnic_hw_cfg.c' ] extra_flags = [] diff --git a/drivers/net/spnic/base/spnic_hw_cfg.c b/drivers/net/spnic/base/spnic_hw_cfg.c new file mode 100644 index 00..e8856ce9fe --- /dev/null +++ b/drivers/net/spnic/base/spnic_hw_cfg.c @@ -0,0 +1,157 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2021 Ramaxel Memory Technology, Ltd + */ + +#include "spnic_compat.h" +#include "spnic_mgmt.h" +#include "spnic_mbox.h" +#include "spnic_hwdev.h" +#include "spnic_hwif.h" +#include "spnic_hw_cfg.h" + +static void parse_pub_res_cap(struct service_cap *cap, + struct spnic_cfg_cmd_dev_cap *dev_cap, + enum func_type type) +{ + cap->host_id = dev_cap->host_id; + cap->ep_id = dev_cap->ep_id; + cap->er_id = dev_cap->er_id; + cap->port_id = dev_cap->port_id; + + cap->svc_type = dev_cap->svc_cap_en; + cap->chip_svc_type = cap->svc_type; + + cap->cos_valid_bitmap = dev_cap->valid_cos_bitmap; + cap->flexq_en = dev_cap->flexq_en; + + cap->host_total_function = dev_cap->host_total_func; + cap->max_vf = 0; + if (type == TYPE_PF || type == TYPE_PPF) { + cap->max_vf = dev_cap->max_vf; + cap->pf_num = dev_cap->host_pf_num; + cap->pf_id_start = dev_cap->pf_id_start; + cap->vf_num = dev_cap->host_vf_num; + cap->vf_id_start = dev_cap->vf_id_start; + } + + PMD_DRV_LOG(INFO, "Get public resource capability: "); + PMD_DRV_LOG(INFO, "host_id: 0x%x, ep_id: 0x%x, er_id: 0x%x, " + "port_id: 0x%x", + cap->host_id, cap->ep_id, cap->er_id, cap->port_id); + PMD_DRV_LOG(INFO, "host_total_function: 0x%x, max_vf: 0x%x", + cap->host_total_function, cap->max_vf); + PMD_DRV_LOG(INFO, "host_pf_num: 0x%x, pf_id_start: 0x%x, host_vf_num: 0x%x, vf_id_start: 0x%x", + cap->pf_num, cap->pf_id_start, + cap->vf_num, cap->vf_id_start); +} + +static void parse_l2nic_res_cap(struct service_cap *cap, + struct spnic_cfg_cmd_dev_cap *dev_cap) +{ + struct nic_service_cap *nic_cap = &cap->nic_cap; + + nic_cap->max_sqs = dev_cap->nic_max_sq_id + 1; + nic_cap->max_rqs = dev_cap->nic_max_rq_id + 1; + + PMD_DRV_LOG(INFO, "L2nic resource capbility, max_sqs: 0x%x, " + "max_rqs: 0x%x", + nic_cap->max_sqs, nic_cap->max_rqs); +} + +static void parse_dev_cap(struct spnic_hwdev *dev, + struct spnic_cfg_cmd_dev_cap *dev_cap, + enum func_type type) +{ + struct service_cap *cap = &dev->cfg_mgmt->svc_cap; + + parse_pub_res_cap(cap, dev_cap, type); + + if (IS_NIC_TYPE(dev)) + parse_l2nic_res_cap(cap, dev_cap); +} + +static int get_cap_from_fw(struct spnic_hwdev *hwdev, enum func_type type) +{ + struct spnic_cfg_cmd_dev_cap dev_cap; + u16 out_len = sizeof(dev_cap); + int err; + + memset(&dev_cap, 0, sizeof(dev_cap)); + dev_cap.func_id = spnic_global_func_id(hwdev); + err = spnic_msg_to_mgmt_sync(hwdev, SPNIC_MOD_CFGM, +SPNIC_CFG_CMD_GET_DEV_CAP, +&dev_cap, sizeof(dev_cap), +&dev_cap, &out_len, 0); + if (err || dev_cap.status || !out_len) { + PMD_DRV_LOG(ERR, "Get capability from FW failed, err: %d, " + "status: 0x%x, out size: 0x%x", + err, dev_cap.status, out_len); + return -EFAULT; + } + + parse_dev_cap(hwdev, &dev_c
[PATCH v2 05/25] net/spnic: add mgmt module
Mgmt module manage the message gerenated from the hardware. This patch implements mgmt module initialization, related event processing and message command definition. Signed-off-by: Yanling Song --- drivers/net/spnic/base/meson.build | 4 +- drivers/net/spnic/base/spnic_cmd.h | 222 ++ drivers/net/spnic/base/spnic_eqs.c | 46 ++- drivers/net/spnic/base/spnic_hwdev.c | 91 +- drivers/net/spnic/base/spnic_hwdev.h | 66 +++- drivers/net/spnic/base/spnic_mbox.c | 16 + drivers/net/spnic/base/spnic_mgmt.c | 367 +++ drivers/net/spnic/base/spnic_mgmt.h | 74 + drivers/net/spnic/base/spnic_nic_event.c | 162 ++ drivers/net/spnic/base/spnic_nic_event.h | 29 ++ 10 files changed, 1066 insertions(+), 11 deletions(-) create mode 100644 drivers/net/spnic/base/spnic_cmd.h create mode 100644 drivers/net/spnic/base/spnic_mgmt.c create mode 100644 drivers/net/spnic/base/spnic_nic_event.c create mode 100644 drivers/net/spnic/base/spnic_nic_event.h diff --git a/drivers/net/spnic/base/meson.build b/drivers/net/spnic/base/meson.build index ce7457f400..3f6a060b37 100644 --- a/drivers/net/spnic/base/meson.build +++ b/drivers/net/spnic/base/meson.build @@ -5,7 +5,9 @@ sources = [ 'spnic_eqs.c', 'spnic_hwdev.c', 'spnic_hwif.c', - 'spnic_mbox.c' + 'spnic_mbox.c', + 'spnic_mgmt.c', + 'spnic_nic_event.c' ] extra_flags = [] diff --git a/drivers/net/spnic/base/spnic_cmd.h b/drivers/net/spnic/base/spnic_cmd.h new file mode 100644 index 00..4f0c46f900 --- /dev/null +++ b/drivers/net/spnic/base/spnic_cmd.h @@ -0,0 +1,222 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2021 Ramaxel Memory Technology, Ltd + */ + +#ifndef _SPNIC_CMD_H_ +#define _SPNIC_CMD_H_ + +#define NIC_RSS_TEMP_ID_TO_CTX_LT_IDX(tmp_id) tmp_id +/* Begin of one temp tbl */ +#define NIC_RSS_TEMP_ID_TO_INDIR_LT_IDX(tmp_id)((tmp_id) << 4) +/* 4 ctx in one entry */ +#define NIC_RSS_CTX_TBL_ENTRY_SIZE 0x10 +/* Entry size = 16B, 16 entry/template */ +#define NIC_RSS_INDIR_TBL_ENTRY_SIZE 0x10 +/* Entry size = 16B, so entry_num = 256B/16B */ +#define NIC_RSS_INDIR_TBL_ENTRY_NUM0x10 + +#define NIC_UP_RSS_INVALID_TEMP_ID 0xFF +#define NIC_UP_RSS_INVALID_FUNC_ID 0x +#define NIC_UP_RSS_INVALID 0x00 +#define NIC_UP_RSS_EN 0x01 +#define NIC_UP_RSS_INVALID_GROUP_ID0x7F + +#define NIC_RSS_CMD_TEMP_ALLOC 0x01 +#define NIC_RSS_CMD_TEMP_FREE 0x02 + +#define SPNIC_RSS_TYPE_VALID_SHIFT 23 +#define SPNIC_RSS_TYPE_TCP_IPV6_EXT_SHIFT 24 +#define SPNIC_RSS_TYPE_IPV6_EXT_SHIFT 25 +#define SPNIC_RSS_TYPE_TCP_IPV6_SHIFT 26 +#define SPNIC_RSS_TYPE_IPV6_SHIFT 27 +#define SPNIC_RSS_TYPE_TCP_IPV4_SHIFT 28 +#define SPNIC_RSS_TYPE_IPV4_SHIFT 29 +#define SPNIC_RSS_TYPE_UDP_IPV6_SHIFT 30 +#define SPNIC_RSS_TYPE_UDP_IPV4_SHIFT 31 +#define SPNIC_RSS_TYPE_SET(val, member)\ + (((u32)(val) & 0x1) << SPNIC_RSS_TYPE_##member##_SHIFT) + +#define SPNIC_RSS_TYPE_GET(val, member)\ + (((u32)(val) >> SPNIC_RSS_TYPE_##member##_SHIFT) & 0x1) + +/* NIC CMDQ MODE */ +typedef enum spnic_ucode_cmd { + SPNIC_UCODE_CMD_MODIFY_QUEUE_CTX = 0, + SPNIC_UCODE_CMD_CLEAN_QUEUE_CONTEXT, + SPNIC_UCODE_CMD_ARM_SQ, + SPNIC_UCODE_CMD_ARM_RQ, + SPNIC_UCODE_CMD_SET_RSS_INDIR_TABLE, + SPNIC_UCODE_CMD_SET_RSS_CONTEXT_TABLE, + SPNIC_UCODE_CMD_GET_RSS_INDIR_TABLE, + SPNIC_UCODE_CMD_GET_RSS_CONTEXT_TABLE, + SPNIC_UCODE_CMD_SET_IQ_ENABLE, + SPNIC_UCODE_CMD_SET_RQ_FLUSH = 10, + SPNIC_UCODE_CMD_MODIFY_VLAN_CTX, + SPNIC_UCODE_CMD_DPI_FLOW +} cmdq_nic_subtype_e; + +/* + * Commands between NIC and MPU + */ +enum spnic_cmd { + SPNIC_CMD_VF_REGISTER = 0, /* only for PFD and VFD */ + + /* FUNC CFG */ + SPNIC_CMD_SET_FUNC_TBL = 5, + SPNIC_CMD_SET_VPORT_ENABLE, + SPNIC_CMD_SET_RX_MODE, + SPNIC_CMD_SQ_CI_ATTR_SET, + SPNIC_CMD_GET_VPORT_STAT, + SPNIC_CMD_CLEAN_VPORT_STAT, + SPNIC_CMD_CLEAR_QP_RESOURCE, + SPNIC_CMD_CFG_FLEX_QUEUE, + /* LRO CFG */ + SPNIC_CMD_CFG_RX_LRO, + SPNIC_CMD_CFG_LRO_TIMER, + SPNIC_CMD_FEATURE_NEGO, + + /* MAC & VLAN CFG */ + SPNIC_CMD_GET_MAC = 20, + SPNIC_CMD_SET_MAC, + SPNIC_CMD_DEL_MAC, + SPNIC_CMD_UPDATE_MAC, + SPNIC_CMD_GET_ALL_DEFAULT_MAC, + + SPNIC_CMD_CFG_FUNC_VLAN, + SPNIC_CMD_SET_VLAN_FILTER_EN, + SPNIC_CMD_SET_RX_VLAN_OFFLOAD, + + /* SR-IOV */ + SPNIC_CMD_CFG_VF_VLAN = 40, + SPNIC_CMD_SET_SPOOPCHK_STATE, + /* RATE LIMIT */ + SPNIC_CMD_SET_MAX_MIN_RATE, + + /* RSS CFG */ + SPNIC_CMD_RSS_CFG = 60, + SPNIC_CMD_RSS_TEMP_MGR, +
[PATCH v2 07/25] net/spnic: add interface handling cmdq message
This commit adds cmdq_sync_cmd_direct_resp() and cmdq_sync_cmd_detail_resp() interfaces by which driver can send cmdq message using wqe a data structure describe the buffer. Signed-off-by: Yanling Song --- drivers/net/spnic/base/meson.build | 1 + drivers/net/spnic/base/spnic_cmdq.c| 673 + drivers/net/spnic/base/spnic_cmdq.h| 20 + drivers/net/spnic/base/spnic_hw_comm.c | 41 ++ drivers/net/spnic/base/spnic_hwdev.c | 8 +- drivers/net/spnic/base/spnic_hwdev.h | 13 + drivers/net/spnic/base/spnic_wq.c | 139 + drivers/net/spnic/base/spnic_wq.h | 70 ++- 8 files changed, 960 insertions(+), 5 deletions(-) create mode 100644 drivers/net/spnic/base/spnic_wq.c diff --git a/drivers/net/spnic/base/meson.build b/drivers/net/spnic/base/meson.build index 5e4efac7be..da6d6ee4a2 100644 --- a/drivers/net/spnic/base/meson.build +++ b/drivers/net/spnic/base/meson.build @@ -10,6 +10,7 @@ sources = [ 'spnic_nic_event.c', 'spnic_cmdq.c', 'spnic_hw_comm.c', + 'spnic_wq.c' ] extra_flags = [] diff --git a/drivers/net/spnic/base/spnic_cmdq.c b/drivers/net/spnic/base/spnic_cmdq.c index ccfcf739a0..b8950f91c2 100644 --- a/drivers/net/spnic/base/spnic_cmdq.c +++ b/drivers/net/spnic/base/spnic_cmdq.c @@ -12,6 +12,71 @@ #include "spnic_mgmt.h" #include "spnic_cmdq.h" +#define CMDQ_CMD_TIMEOUT 30 /* Millisecond */ + +#define UPPER_8_BITS(data) (((data) >> 8) & 0xFF) +#define LOWER_8_BITS(data) ((data) & 0xFF) + +#define CMDQ_DB_INFO_HI_PROD_IDX_SHIFT 0 +#define CMDQ_DB_INFO_HI_PROD_IDX_MASK 0xFFU + +#define CMDQ_DB_INFO_SET(val, member) \ + u32)(val)) & CMDQ_DB_INFO_##member##_MASK) \ + << CMDQ_DB_INFO_##member##_SHIFT) +#define CMDQ_DB_INFO_UPPER_32(val) ((u64)(val) << 32) + +#define CMDQ_DB_HEAD_QUEUE_TYPE_SHIFT 23 +#define CMDQ_DB_HEAD_CMDQ_TYPE_SHIFT 24 +#define CMDQ_DB_HEAD_SRC_TYPE_SHIFT27 +#define CMDQ_DB_HEAD_QUEUE_TYPE_MASK 0x1U +#define CMDQ_DB_HEAD_CMDQ_TYPE_MASK0x7U +#define CMDQ_DB_HEAD_SRC_TYPE_MASK 0x1FU +#define CMDQ_DB_HEAD_SET(val, member) \ + u32)(val)) & CMDQ_DB_HEAD_##member##_MASK) << \ + CMDQ_DB_HEAD_##member##_SHIFT) + +#define CMDQ_CTRL_PI_SHIFT 0 +#define CMDQ_CTRL_CMD_SHIFT16 +#define CMDQ_CTRL_MOD_SHIFT24 +#define CMDQ_CTRL_ACK_TYPE_SHIFT 29 +#define CMDQ_CTRL_HW_BUSY_BIT_SHIFT31 + +#define CMDQ_CTRL_PI_MASK 0xU +#define CMDQ_CTRL_CMD_MASK 0xFFU +#define CMDQ_CTRL_MOD_MASK 0x1FU +#define CMDQ_CTRL_ACK_TYPE_MASK0x3U +#define CMDQ_CTRL_HW_BUSY_BIT_MASK 0x1U + +#define CMDQ_CTRL_SET(val, member) \ + (((u32)(val) & CMDQ_CTRL_##member##_MASK) << CMDQ_CTRL_##member##_SHIFT) + +#define CMDQ_CTRL_GET(val, member) \ + (((val) >> CMDQ_CTRL_##member##_SHIFT) & CMDQ_CTRL_##member##_MASK) + +#define CMDQ_WQE_HEADER_BUFDESC_LEN_SHIFT 0 +#define CMDQ_WQE_HEADER_COMPLETE_FMT_SHIFT 15 +#define CMDQ_WQE_HEADER_DATA_FMT_SHIFT 22 +#define CMDQ_WQE_HEADER_COMPLETE_REQ_SHIFT 23 +#define CMDQ_WQE_HEADER_COMPLETE_SECT_LEN_SHIFT27 +#define CMDQ_WQE_HEADER_CTRL_LEN_SHIFT 29 +#define CMDQ_WQE_HEADER_HW_BUSY_BIT_SHIFT 31 + +#define CMDQ_WQE_HEADER_BUFDESC_LEN_MASK 0xFFU +#define CMDQ_WQE_HEADER_COMPLETE_FMT_MASK 0x1U +#define CMDQ_WQE_HEADER_DATA_FMT_MASK 0x1U +#define CMDQ_WQE_HEADER_COMPLETE_REQ_MASK 0x1U +#define CMDQ_WQE_HEADER_COMPLETE_SECT_LEN_MASK 0x3U +#define CMDQ_WQE_HEADER_CTRL_LEN_MASK 0x3U +#define CMDQ_WQE_HEADER_HW_BUSY_BIT_MASK 0x1U + +#define CMDQ_WQE_HEADER_SET(val, member) \ + (((u32)(val) & CMDQ_WQE_HEADER_##member##_MASK) << \ + CMDQ_WQE_HEADER_##member##_SHIFT) + +#define CMDQ_WQE_HEADER_GET(val, member) \ + (((val) >> CMDQ_WQE_HEADER_##member##_SHIFT) & \ + CMDQ_WQE_HEADER_##member##_MASK) + #define CMDQ_CTXT_CURR_WQE_PAGE_PFN_SHIFT 0 #define CMDQ_CTXT_EQ_ID_SHIFT 53 #define CMDQ_CTXT_CEQ_ARM_SHIFT61 @@ -36,8 +101,523 @@ #define CMDQ_CTXT_BLOCK_INFO_SET(val, member) \ (((u64)(val) & CMDQ_CTXT_##member##_MASK) << CMDQ_CTXT_##member##_SHIFT) +#define SAVED_DATA_ARM_SHIFT 31 + +#define SAVED_DATA_ARM_MASK
[PATCH v2 06/25] net/spnic: add cmdq and work queue
This commit introduce cmdq and work queue which can be used to send bulk message data(up to 2KB) to hardware. cmdq provides a mechanism to encapsulate the message to be sent and handle the response data or status. work queue is used to manager the wqe in which includes message data buffer description, ctrl info, header info and response message data buffer. This patch implements the initialization and data structure. Signed-off-by: Yanling Song --- drivers/net/spnic/base/meson.build | 4 +- drivers/net/spnic/base/spnic_cmdq.c| 202 ++ drivers/net/spnic/base/spnic_cmdq.h| 228 + drivers/net/spnic/base/spnic_hw_comm.c | 222 drivers/net/spnic/base/spnic_hw_comm.h | 176 +++ drivers/net/spnic/base/spnic_hwdev.c | 215 +++ drivers/net/spnic/base/spnic_hwdev.h | 8 +- drivers/net/spnic/base/spnic_wq.h | 57 +++ 8 files changed, 1109 insertions(+), 3 deletions(-) create mode 100644 drivers/net/spnic/base/spnic_cmdq.c create mode 100644 drivers/net/spnic/base/spnic_cmdq.h create mode 100644 drivers/net/spnic/base/spnic_hw_comm.c create mode 100644 drivers/net/spnic/base/spnic_hw_comm.h create mode 100644 drivers/net/spnic/base/spnic_wq.h diff --git a/drivers/net/spnic/base/meson.build b/drivers/net/spnic/base/meson.build index 3f6a060b37..5e4efac7be 100644 --- a/drivers/net/spnic/base/meson.build +++ b/drivers/net/spnic/base/meson.build @@ -7,7 +7,9 @@ sources = [ 'spnic_hwif.c', 'spnic_mbox.c', 'spnic_mgmt.c', - 'spnic_nic_event.c' + 'spnic_nic_event.c', + 'spnic_cmdq.c', + 'spnic_hw_comm.c', ] extra_flags = [] diff --git a/drivers/net/spnic/base/spnic_cmdq.c b/drivers/net/spnic/base/spnic_cmdq.c new file mode 100644 index 00..ccfcf739a0 --- /dev/null +++ b/drivers/net/spnic/base/spnic_cmdq.c @@ -0,0 +1,202 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2021 Ramaxel Memory Technology, Ltd + */ + +#include + +#include "spnic_compat.h" +#include "spnic_hwdev.h" +#include "spnic_hwif.h" +#include "spnic_wq.h" +#include "spnic_cmd.h" +#include "spnic_mgmt.h" +#include "spnic_cmdq.h" + +#define CMDQ_CTXT_CURR_WQE_PAGE_PFN_SHIFT 0 +#define CMDQ_CTXT_EQ_ID_SHIFT 53 +#define CMDQ_CTXT_CEQ_ARM_SHIFT61 +#define CMDQ_CTXT_CEQ_EN_SHIFT 62 +#define CMDQ_CTXT_HW_BUSY_BIT_SHIFT63 + +#define CMDQ_CTXT_CURR_WQE_PAGE_PFN_MASK 0xF +#define CMDQ_CTXT_EQ_ID_MASK 0xFF +#define CMDQ_CTXT_CEQ_ARM_MASK 0x1 +#define CMDQ_CTXT_CEQ_EN_MASK 0x1 +#define CMDQ_CTXT_HW_BUSY_BIT_MASK 0x1 + +#define CMDQ_CTXT_PAGE_INFO_SET(val, member) \ + (((u64)(val) & CMDQ_CTXT_##member##_MASK) << CMDQ_CTXT_##member##_SHIFT) + +#define CMDQ_CTXT_WQ_BLOCK_PFN_SHIFT 0 +#define CMDQ_CTXT_CI_SHIFT 52 + +#define CMDQ_CTXT_WQ_BLOCK_PFN_MASK0xF +#define CMDQ_CTXT_CI_MASK 0xFFF + +#define CMDQ_CTXT_BLOCK_INFO_SET(val, member) \ + (((u64)(val) & CMDQ_CTXT_##member##_MASK) << CMDQ_CTXT_##member##_SHIFT) + +#define WAIT_CMDQ_ENABLE_TIMEOUT 300 + +static int init_cmdq(struct spnic_cmdq *cmdq, struct spnic_hwdev *hwdev, +struct spnic_wq *wq, enum spnic_cmdq_type q_type) +{ + void *db_base = NULL; + int err = 0; + size_t errcode_size; + size_t cmd_infos_size; + + cmdq->wq = wq; + cmdq->cmdq_type = q_type; + cmdq->wrapped = 1; + + rte_spinlock_init(&cmdq->cmdq_lock); + + errcode_size = wq->q_depth * sizeof(*cmdq->errcode); + cmdq->errcode = rte_zmalloc(NULL, errcode_size, 0); + if (!cmdq->errcode) { + PMD_DRV_LOG(ERR, "Allocate errcode for cmdq failed"); + return -ENOMEM; + } + + cmd_infos_size = wq->q_depth * sizeof(*cmdq->cmd_infos); + cmdq->cmd_infos = rte_zmalloc(NULL, cmd_infos_size, 0); + if (!cmdq->cmd_infos) { + PMD_DRV_LOG(ERR, "Allocate cmd info for cmdq failed"); + err = -ENOMEM; + goto cmd_infos_err; + } + + err = spnic_alloc_db_addr(hwdev, &db_base, NULL); + if (err) + goto alloc_db_err; + + cmdq->db_base = (u8 *)db_base; + + return 0; + +alloc_db_err: + rte_free(cmdq->cmd_infos); + +cmd_infos_err: + rte_free(cmdq->errcode); + + return err; +} + +static void free_cmdq(struct spnic_hwdev *hwdev, struct spnic_cmdq *cmdq) +{ + spnic_free_db_addr(hwdev, cmdq->db_base, NULL); + rte_free(cmdq->cmd_infos); + rte_free(cmdq->errcode); +} + +static int spnic_set_cmdq_ctxts(struct spnic_hwdev *hwdev) +{ + struct spnic_cmd
[PATCH v2 03/25] net/spnic: add mbox message channel
This patch adds a message channel named mbox which can send message form PF/VF driver to hardware or sned message from VF to PF. Signed-off-by: Yanling Song --- drivers/net/spnic/base/meson.build |3 +- drivers/net/spnic/base/spnic_hwdev.c | 69 ++ drivers/net/spnic/base/spnic_hwdev.h |6 + drivers/net/spnic/base/spnic_mbox.c | 1158 ++ drivers/net/spnic/base/spnic_mbox.h | 202 + drivers/net/spnic/base/spnic_mgmt.h | 36 + 6 files changed, 1473 insertions(+), 1 deletion(-) create mode 100644 drivers/net/spnic/base/spnic_mbox.c create mode 100644 drivers/net/spnic/base/spnic_mbox.h create mode 100644 drivers/net/spnic/base/spnic_mgmt.h diff --git a/drivers/net/spnic/base/meson.build b/drivers/net/spnic/base/meson.build index edd6e94772..de80eef7c4 100644 --- a/drivers/net/spnic/base/meson.build +++ b/drivers/net/spnic/base/meson.build @@ -3,7 +3,8 @@ sources = [ 'spnic_hwdev.c', - 'spnic_hwif.c' + 'spnic_hwif.c', + 'spnic_mbox.c' ] extra_flags = [] diff --git a/drivers/net/spnic/base/spnic_hwdev.c b/drivers/net/spnic/base/spnic_hwdev.c index de73f244fd..bcecbaa895 100644 --- a/drivers/net/spnic/base/spnic_hwdev.c +++ b/drivers/net/spnic/base/spnic_hwdev.c @@ -5,8 +5,66 @@ #include "spnic_compat.h" #include "spnic_csr.h" #include "spnic_hwif.h" +#include "spnic_mgmt.h" +#include "spnic_mbox.h" #include "spnic_hwdev.h" +int vf_handle_pf_comm_mbox(void *handle, __rte_unused void *pri_handle, + __rte_unused u16 cmd, __rte_unused void *buf_in, + __rte_unused u16 in_size, __rte_unused void *buf_out, + __rte_unused u16 *out_size) +{ + struct spnic_hwdev *hwdev = handle; + + if (!hwdev) + return -EINVAL; + + PMD_DRV_LOG(WARNING, "Unsupported pf mbox event %d to process", cmd); + + return 0; +} + +static int init_mgmt_channel(struct spnic_hwdev *hwdev) +{ + int err; + + err = spnic_func_to_func_init(hwdev); + if (err) { + PMD_DRV_LOG(ERR, "Init mailbox channel failed"); + goto func_to_func_init_err; + } + + return 0; + +func_to_func_init_err: + + return err; +} + +static void free_mgmt_channel(struct spnic_hwdev *hwdev) +{ + spnic_func_to_func_free(hwdev); +} + + +static int spnic_init_comm_ch(struct spnic_hwdev *hwdev) +{ + int err; + + err = init_mgmt_channel(hwdev); + if (err) { + PMD_DRV_LOG(ERR, "Init mgmt channel failed"); + return err; + } + + return 0; +} + +static void spnic_uninit_comm_ch(struct spnic_hwdev *hwdev) +{ + free_mgmt_channel(hwdev); +} + int spnic_init_hwdev(struct spnic_hwdev *hwdev) { int err; @@ -25,8 +83,17 @@ int spnic_init_hwdev(struct spnic_hwdev *hwdev) goto init_hwif_err; } + err = spnic_init_comm_ch(hwdev); + if (err) { + PMD_DRV_LOG(ERR, "Init communication channel failed"); + goto init_comm_ch_err; + } + return 0; +init_comm_ch_err: + spnic_free_hwif(hwdev); + init_hwif_err: rte_free(hwdev->chip_fault_stats); @@ -35,6 +102,8 @@ int spnic_init_hwdev(struct spnic_hwdev *hwdev) void spnic_free_hwdev(struct spnic_hwdev *hwdev) { + spnic_uninit_comm_ch(hwdev); + spnic_free_hwif(hwdev); rte_free(hwdev->chip_fault_stats); diff --git a/drivers/net/spnic/base/spnic_hwdev.h b/drivers/net/spnic/base/spnic_hwdev.h index c89a4fa840..4a20e34754 100644 --- a/drivers/net/spnic/base/spnic_hwdev.h +++ b/drivers/net/spnic/base/spnic_hwdev.h @@ -17,12 +17,18 @@ struct spnic_hwdev { uint16_t port_id; struct spnic_hwif *hwif; + struct spnic_mbox *func_to_func; u8 *chip_fault_stats; u16 max_vfs; u16 link_status; }; +int vf_handle_pf_comm_mbox(void *handle, __rte_unused void *pri_handle, + __rte_unused u16 cmd, __rte_unused void *buf_in, + __rte_unused u16 in_size, __rte_unused void *buf_out, + __rte_unused u16 *out_size); + int spnic_init_hwdev(struct spnic_hwdev *hwdev); void spnic_free_hwdev(struct spnic_hwdev *hwdev); diff --git a/drivers/net/spnic/base/spnic_mbox.c b/drivers/net/spnic/base/spnic_mbox.c new file mode 100644 index 00..0a15017874 --- /dev/null +++ b/drivers/net/spnic/base/spnic_mbox.c @@ -0,0 +1,1158 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2021 Ramaxel Memory Technology, Ltd + */ + +#include +#include +#include "spnic_compat.h" +#include "spnic_hwdev.h" +#include "spnic_csr.h" +#include "spnic_hwif.h" +#include "spnic_mgmt.h" +#include "spnic_mbox.h" + +#define SPNIC_MBOX_INT_DST_FUNC_SHIFT 0 +#define SPNIC_MBOX_INT_DST_AEQN_SHIFT 10 +#define SPNIC_MBOX_INT_SRC_RESP_AEQN_SHIFT 12 +#def
[PATCH v2 12/25] net/spnic: support mbuf handling of Tx/Rx
This patch defines a wqe data structure for hardware to learn the sge info and offload info of packet. Furthermore, this commit implements the interfaces to fill wqe with DPDK mbuf. Signed-off-by: Yanling Song --- drivers/net/spnic/base/spnic_nic_cfg.c | 23 ++ drivers/net/spnic/base/spnic_nic_cfg.h | 23 ++ drivers/net/spnic/meson.build | 2 + drivers/net/spnic/spnic_ethdev.c | 502 - drivers/net/spnic/spnic_rx.c | 302 +++ drivers/net/spnic/spnic_rx.h | 41 ++ drivers/net/spnic/spnic_tx.c | 334 drivers/net/spnic/spnic_tx.h | 228 +++ 8 files changed, 1454 insertions(+), 1 deletion(-) create mode 100644 drivers/net/spnic/spnic_rx.c create mode 100644 drivers/net/spnic/spnic_tx.c diff --git a/drivers/net/spnic/base/spnic_nic_cfg.c b/drivers/net/spnic/base/spnic_nic_cfg.c index 25d98d67dd..f6914f6f6d 100644 --- a/drivers/net/spnic/base/spnic_nic_cfg.c +++ b/drivers/net/spnic/base/spnic_nic_cfg.c @@ -378,6 +378,29 @@ int spnic_set_port_enable(void *hwdev, bool enable) return 0; } +int spnic_flush_qps_res(void *hwdev) +{ + struct spnic_cmd_clear_qp_resource sq_res; + u16 out_size = sizeof(sq_res); + int err; + + if (!hwdev) + return -EINVAL; + + memset(&sq_res, 0, sizeof(sq_res)); + sq_res.func_id = spnic_global_func_id(hwdev); + + err = l2nic_msg_to_mgmt_sync(hwdev, SPNIC_CMD_CLEAR_QP_RESOURCE, &sq_res, +sizeof(sq_res), &sq_res, &out_size); + if (err || !out_size || sq_res.msg_head.status) { + PMD_DRV_LOG(ERR, "Clear sq resources failed, err: %d, status: 0x%x, out size: 0x%x", + err, sq_res.msg_head.status, out_size); + return -EIO; + } + + return 0; +} + static int spnic_set_function_table(void *hwdev, u32 cfg_bitmap, struct spnic_func_tbl_cfg *cfg) { diff --git a/drivers/net/spnic/base/spnic_nic_cfg.h b/drivers/net/spnic/base/spnic_nic_cfg.h index a7ff44a891..31d2607234 100644 --- a/drivers/net/spnic/base/spnic_nic_cfg.h +++ b/drivers/net/spnic/base/spnic_nic_cfg.h @@ -255,6 +255,17 @@ struct spnic_cmd_register_vf { u8 rsvd[39]; }; + +struct spnic_cmd_set_rq_flush { + union { + struct { + u16 global_rq_id; + u16 local_rq_id; + }; + u32 value; + }; +}; + int l2nic_msg_to_mgmt_sync(void *hwdev, u16 cmd, void *buf_in, u16 in_size, void *buf_out, u16 *out_size); @@ -381,6 +392,18 @@ int spnic_set_port_enable(void *hwdev, bool enable); */ int spnic_get_link_state(void *hwdev, u8 *link_state); +/** + * Flush queue pairs resource in hardware + * + * @param[in] hwdev + * Device pointer to hwdev + * + * @retval zero : Success + * @retval non-zero : Failure + */ +int spnic_flush_qps_res(void *hwdev); + + /** * Init nic hwdev * diff --git a/drivers/net/spnic/meson.build b/drivers/net/spnic/meson.build index 20d5151a8d..cd8f316366 100644 --- a/drivers/net/spnic/meson.build +++ b/drivers/net/spnic/meson.build @@ -7,6 +7,8 @@ objs = [base_objs] sources = files( 'spnic_ethdev.c', 'spnic_io.c', + 'spnic_rx.c', + 'spnic_tx.c' ) includes += include_directories('base') diff --git a/drivers/net/spnic/spnic_ethdev.c b/drivers/net/spnic/spnic_ethdev.c index 4205ab43a4..27942e5d68 100644 --- a/drivers/net/spnic/spnic_ethdev.c +++ b/drivers/net/spnic/spnic_ethdev.c @@ -139,6 +139,468 @@ static int spnic_link_update(struct rte_eth_dev *dev, int wait_to_complete) return rte_eth_linkstatus_set(dev, &link); } +static void spnic_reset_rx_queue(struct rte_eth_dev *dev) +{ + struct spnic_rxq *rxq = NULL; + struct spnic_nic_dev *nic_dev; + int q_id = 0; + + nic_dev = SPNIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev); + + for (q_id = 0; q_id < nic_dev->num_rqs; q_id++) { + rxq = nic_dev->rxqs[q_id]; + + rxq->cons_idx = 0; + rxq->prod_idx = 0; + rxq->delta = rxq->q_depth; + rxq->next_to_update = 0; + } +} + +static void spnic_reset_tx_queue(struct rte_eth_dev *dev) +{ + struct spnic_nic_dev *nic_dev; + struct spnic_txq *txq = NULL; + int q_id = 0; + + nic_dev = SPNIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev); + + for (q_id = 0; q_id < nic_dev->num_sqs; q_id++) { + txq = nic_dev->txqs[q_id]; + + txq->cons_idx = 0; + txq->prod_idx = 0; + txq->owner = 1; + + /* Clear hardware ci */ + *(u16 *)txq->ci_vaddr_base = 0; + } +} + +/** + * Create the receive queue. + * + * @param[in] dev + * Pointer to ethernet device structure. + * @param[in] qid + * Receive queue index. + * @param[in] nb_desc + * Number of des
[PATCH v2 14/25] net/spnic: add port/vport enable
This patch adds interface to enable port/vport so that the hardware would receive packets to host. Signed-off-by: Yanling Song --- drivers/net/spnic/spnic_ethdev.c | 46 1 file changed, 46 insertions(+) diff --git a/drivers/net/spnic/spnic_ethdev.c b/drivers/net/spnic/spnic_ethdev.c index 74d09bafac..0459959ca5 100644 --- a/drivers/net/spnic/spnic_ethdev.c +++ b/drivers/net/spnic/spnic_ethdev.c @@ -855,8 +855,10 @@ static void spnic_deinit_sw_rxtxqs(struct spnic_nic_dev *nic_dev) static int spnic_dev_start(struct rte_eth_dev *eth_dev) { struct spnic_nic_dev *nic_dev; + struct spnic_rxq *rxq = NULL; u64 nic_features; int err; + u16 i; nic_dev = SPNIC_ETH_DEV_TO_PRIVATE_NIC_DEV(eth_dev); @@ -916,6 +918,22 @@ static int spnic_dev_start(struct rte_eth_dev *eth_dev) spnic_start_all_sqs(eth_dev); + /* Open virtual port and ready to start packet receiving */ + err = spnic_set_vport_enable(nic_dev->hwdev, true); + if (err) { + PMD_DRV_LOG(ERR, "Enable vport failed, dev_name: %s", + eth_dev->data->name); + goto en_vport_fail; + } + + /* Open physical port and start packet receiving */ + err = spnic_set_port_enable(nic_dev->hwdev, true); + if (err) { + PMD_DRV_LOG(ERR, "Enable physical port failed, dev_name: %s", + eth_dev->data->name); + goto en_port_fail; + } + /* Update eth_dev link status */ if (eth_dev->data->dev_conf.intr_conf.lsc != 0) (void)spnic_link_update(eth_dev, 0); @@ -924,6 +942,20 @@ static int spnic_dev_start(struct rte_eth_dev *eth_dev) return 0; +en_port_fail: + (void)spnic_set_vport_enable(nic_dev->hwdev, false); + +en_vport_fail: + /* Flush tx && rx chip resources in case of setting vport fake fail */ + (void)spnic_flush_qps_res(nic_dev->hwdev); + rte_delay_ms(100); + for (i = 0; i < nic_dev->num_rqs; i++) { + rxq = nic_dev->rxqs[i]; + spnic_remove_rq_from_rx_queue_list(nic_dev, rxq->q_id); + spnic_free_rxq_mbufs(rxq); + eth_dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED; + eth_dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED; + } start_rqs_fail: spnic_remove_rxtx_configure(eth_dev); @@ -951,6 +983,7 @@ static int spnic_dev_stop(struct rte_eth_dev *dev) { struct spnic_nic_dev *nic_dev; struct rte_eth_link link; + int err; nic_dev = SPNIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev); if (!rte_bit_relaxed_test_and_clear32(SPNIC_DEV_START, &nic_dev->dev_status)) { @@ -959,6 +992,19 @@ static int spnic_dev_stop(struct rte_eth_dev *dev) return 0; } + /* Stop phy port and vport */ + err = spnic_set_port_enable(nic_dev->hwdev, false); + if (err) + PMD_DRV_LOG(WARNING, "Disable phy port failed, error: %d, " + "dev_name: %s, port_id: %d", err, dev->data->name, + dev->data->port_id); + + err = spnic_set_vport_enable(nic_dev->hwdev, false); + if (err) + PMD_DRV_LOG(WARNING, "Disable vport failed, error: %d, " + "dev_name: %s, port_id: %d", err, dev->data->name, + dev->data->port_id); + /* Clear recorded link status */ memset(&link, 0, sizeof(link)); (void)rte_eth_linkstatus_set(dev, &link); -- 2.32.0
[PATCH v2 11/25] net/spnic: add queue pairs context initialization
This patch adds the initialization of Tx/Rx queues context and negotiation of NIC features. Signed-off-by: Yanling Song --- drivers/net/spnic/base/spnic_hw_comm.c | 101 drivers/net/spnic/base/spnic_hw_comm.h | 6 + drivers/net/spnic/base/spnic_nic_cfg.c | 76 +++ drivers/net/spnic/base/spnic_nic_cfg.h | 65 ++- drivers/net/spnic/meson.build | 3 +- drivers/net/spnic/spnic_ethdev.c | 57 +- drivers/net/spnic/spnic_io.c | 738 + drivers/net/spnic/spnic_io.h | 154 ++ drivers/net/spnic/spnic_rx.h | 113 drivers/net/spnic/spnic_tx.h | 62 +++ 10 files changed, 1370 insertions(+), 5 deletions(-) create mode 100644 drivers/net/spnic/spnic_io.c create mode 100644 drivers/net/spnic/spnic_io.h create mode 100644 drivers/net/spnic/spnic_rx.h create mode 100644 drivers/net/spnic/spnic_tx.h diff --git a/drivers/net/spnic/base/spnic_hw_comm.c b/drivers/net/spnic/base/spnic_hw_comm.c index 5cb607cf03..1c751f2403 100644 --- a/drivers/net/spnic/base/spnic_hw_comm.c +++ b/drivers/net/spnic/base/spnic_hw_comm.c @@ -217,6 +217,107 @@ int spnic_func_reset(void *hwdev, u64 reset_flag) return 0; } +int spnic_convert_rx_buf_size(u32 rx_buf_sz, u32 *match_sz) +{ + u32 i, num_hw_types, best_match_sz; + + if (unlikely(!match_sz || rx_buf_sz < SPNIC_RX_BUF_SIZE_32B)) + return -EINVAL; + + if (rx_buf_sz >= SPNIC_RX_BUF_SIZE_16K) { + best_match_sz = SPNIC_RX_BUF_SIZE_16K; + goto size_matched; + } + + num_hw_types = sizeof(spnic_hw_rx_buf_size) / + sizeof(spnic_hw_rx_buf_size[0]); + best_match_sz = spnic_hw_rx_buf_size[0]; + for (i = 0; i < num_hw_types; i++) { + if (rx_buf_sz == spnic_hw_rx_buf_size[i]) { + best_match_sz = spnic_hw_rx_buf_size[i]; + break; + } else if (rx_buf_sz < spnic_hw_rx_buf_size[i]) { + break; + } + best_match_sz = spnic_hw_rx_buf_size[i]; + } + +size_matched: + *match_sz = best_match_sz; + + return 0; +} + +static u16 get_hw_rx_buf_size(u32 rx_buf_sz) +{ + u16 num_hw_types = sizeof(spnic_hw_rx_buf_size) / + sizeof(spnic_hw_rx_buf_size[0]); + u16 i; + + for (i = 0; i < num_hw_types; i++) { + if (spnic_hw_rx_buf_size[i] == rx_buf_sz) + return i; + } + + PMD_DRV_LOG(WARNING, "Chip can't support rx buf size of %d", rx_buf_sz); + + return DEFAULT_RX_BUF_SIZE; /* Default 2K */ +} + +int spnic_set_root_ctxt(void *hwdev, u32 rq_depth, u32 sq_depth, u16 rx_buf_sz) +{ + struct spnic_cmd_root_ctxt root_ctxt; + u16 out_size = sizeof(root_ctxt); + int err; + + if (!hwdev) + return -EINVAL; + + memset(&root_ctxt, 0, sizeof(root_ctxt)); + root_ctxt.func_idx = spnic_global_func_id(hwdev); + root_ctxt.set_cmdq_depth = 0; + root_ctxt.cmdq_depth = 0; + root_ctxt.lro_en = 1; + root_ctxt.rq_depth = (u16)ilog2(rq_depth); + root_ctxt.rx_buf_sz = get_hw_rx_buf_size(rx_buf_sz); + root_ctxt.sq_depth = (u16)ilog2(sq_depth); + + err = spnic_msg_to_mgmt_sync(hwdev, SPNIC_MOD_COMM, MGMT_CMD_SET_VAT, +&root_ctxt, sizeof(root_ctxt), +&root_ctxt, &out_size, 0); + if (err || !out_size || root_ctxt.status) { + PMD_DRV_LOG(ERR, "Set root context failed, err: %d, status: 0x%x, out_size: 0x%x", + err, root_ctxt.status, out_size); + return -EFAULT; + } + + return 0; +} + +int spnic_clean_root_ctxt(void *hwdev) +{ + struct spnic_cmd_root_ctxt root_ctxt; + u16 out_size = sizeof(root_ctxt); + int err; + + if (!hwdev) + return -EINVAL; + + memset(&root_ctxt, 0, sizeof(root_ctxt)); + root_ctxt.func_idx = spnic_global_func_id(hwdev); + + err = spnic_msg_to_mgmt_sync(hwdev, SPNIC_MOD_COMM, MGMT_CMD_SET_VAT, +&root_ctxt, sizeof(root_ctxt), +&root_ctxt, &out_size, 0); + if (err || !out_size || root_ctxt.status) { + PMD_DRV_LOG(ERR, "Clean root context failed, err: %d, status: 0x%x, out_size: 0x%x", + err, root_ctxt.status, out_size); + return -EFAULT; + } + + return 0; +} + int spnic_set_cmdq_depth(void *hwdev, u16 cmdq_depth) { struct spnic_cmd_root_ctxt root_ctxt; diff --git a/drivers/net/spnic/base/spnic_hw_comm.h b/drivers/net/spnic/base/spnic_hw_comm.h index cf4328a04b..4573595a89 100644 --- a/drivers/net/spnic/base/spnic_hw_comm.h +++ b/drivers/net/spnic/base/spnic_hw_comm.h @@ -180,6 +180,10 @@ int spnic_get_mgmt_version(void *hwdev, char *mgmt_ver, int max_m
[PATCH v2 13/25] net/spnic: support Rx congfiguration
This patch Rx/Tx configuration including Rx csum offload, LRO, RSS, VLAN filter and VLAN offload. Signed-off-by: Yanling Song --- drivers/net/spnic/base/spnic_nic_cfg.c | 525 + drivers/net/spnic/base/spnic_nic_cfg.h | 387 ++ drivers/net/spnic/spnic_ethdev.c | 187 - drivers/net/spnic/spnic_ethdev.h | 2 + drivers/net/spnic/spnic_rx.c | 221 +++ drivers/net/spnic/spnic_rx.h | 31 ++ 6 files changed, 1349 insertions(+), 4 deletions(-) diff --git a/drivers/net/spnic/base/spnic_nic_cfg.c b/drivers/net/spnic/base/spnic_nic_cfg.c index f6914f6f6d..ddaecba95d 100644 --- a/drivers/net/spnic/base/spnic_nic_cfg.c +++ b/drivers/net/spnic/base/spnic_nic_cfg.c @@ -271,6 +271,37 @@ int spnic_get_default_mac(void *hwdev, u8 *mac_addr, int ether_len) return 0; } +static int spnic_config_vlan(void *hwdev, u8 opcode, u16 vlan_id, u16 func_id) +{ + struct spnic_cmd_vlan_config vlan_info; + u16 out_size = sizeof(vlan_info); + int err; + + memset(&vlan_info, 0, sizeof(vlan_info)); + vlan_info.opcode = opcode; + vlan_info.func_id = func_id; + vlan_info.vlan_id = vlan_id; + + err = l2nic_msg_to_mgmt_sync(hwdev, SPNIC_CMD_CFG_FUNC_VLAN, &vlan_info, +sizeof(vlan_info), &vlan_info, &out_size); + if (err || !out_size || vlan_info.msg_head.status) { + PMD_DRV_LOG(ERR, "%s vlan failed, err: %d, status: 0x%x, out size: 0x%x", + opcode == SPNIC_CMD_OP_ADD ? "Add" : "Delete", + err, vlan_info.msg_head.status, out_size); + return -EINVAL; + } + + return 0; +} + +int spnic_del_vlan(void *hwdev, u16 vlan_id, u16 func_id) +{ + if (!hwdev) + return -EINVAL; + + return spnic_config_vlan(hwdev, SPNIC_CMD_OP_DEL, vlan_id, func_id); +} + int spnic_get_port_info(void *hwdev, struct nic_port_info *port_info) { struct spnic_cmd_port_info port_msg; @@ -564,6 +595,500 @@ void spnic_free_nic_hwdev(void *hwdev) spnic_vf_func_free(hwdev); } +int spnic_set_rx_mode(void *hwdev, u32 enable) +{ + struct spnic_rx_mode_config rx_mode_cfg; + u16 out_size = sizeof(rx_mode_cfg); + int err; + + if (!hwdev) + return -EINVAL; + + memset(&rx_mode_cfg, 0, sizeof(rx_mode_cfg)); + rx_mode_cfg.func_id = spnic_global_func_id(hwdev); + rx_mode_cfg.rx_mode = enable; + + err = l2nic_msg_to_mgmt_sync(hwdev, SPNIC_CMD_SET_RX_MODE, +&rx_mode_cfg, sizeof(rx_mode_cfg), +&rx_mode_cfg, &out_size); + if (err || !out_size || rx_mode_cfg.msg_head.status) { + PMD_DRV_LOG(ERR, "Set rx mode failed, err: %d, status: 0x%x, out size: 0x%x", + err, rx_mode_cfg.msg_head.status, out_size); + return -EIO; + } + + return 0; +} + +int spnic_set_rx_vlan_offload(void *hwdev, u8 en) +{ + struct spnic_cmd_vlan_offload vlan_cfg; + u16 out_size = sizeof(vlan_cfg); + int err; + + if (!hwdev) + return -EINVAL; + + memset(&vlan_cfg, 0, sizeof(vlan_cfg)); + vlan_cfg.func_id = spnic_global_func_id(hwdev); + vlan_cfg.vlan_offload = en; + + err = l2nic_msg_to_mgmt_sync(hwdev, SPNIC_CMD_SET_RX_VLAN_OFFLOAD, +&vlan_cfg, sizeof(vlan_cfg), +&vlan_cfg, &out_size); + if (err || !out_size || vlan_cfg.msg_head.status) { + PMD_DRV_LOG(ERR, "Set rx vlan offload failed, err: %d, status: 0x%x, out size: 0x%x", + err, vlan_cfg.msg_head.status, out_size); + return -EIO; + } + + return 0; +} + +int spnic_set_vlan_fliter(void *hwdev, u32 vlan_filter_ctrl) +{ + struct spnic_cmd_set_vlan_filter vlan_filter; + u16 out_size = sizeof(vlan_filter); + int err; + + if (!hwdev) + return -EINVAL; + + memset(&vlan_filter, 0, sizeof(vlan_filter)); + vlan_filter.func_id = spnic_global_func_id(hwdev); + vlan_filter.vlan_filter_ctrl = vlan_filter_ctrl; + + err = l2nic_msg_to_mgmt_sync(hwdev, SPNIC_CMD_SET_VLAN_FILTER_EN, +&vlan_filter, sizeof(vlan_filter), +&vlan_filter, &out_size); + if (err || !out_size || vlan_filter.msg_head.status) { + PMD_DRV_LOG(ERR, "Failed to set vlan filter, err: %d, status: 0x%x, out size: 0x%x", + err, vlan_filter.msg_head.status, out_size); + return -EIO; + } + + return 0; +} + +static int spnic_set_rx_lro(void *hwdev, u8 ipv4_en, u8 ipv6_en, + u8 lro_max_pkt_len) +{ + struct spnic_cmd_lro_config lro_cfg; + u16 out_size = sizeof(l
[PATCH v2 09/25] net/spnic: support MAC and link event handling
This commit adds interfaces to add/remove MAC addresses and registers related ops to struct eth_dev_ops. Furthermore, this commit adds callback to handle link events. Signed-off-by: Yanling Song --- drivers/net/spnic/base/meson.build | 3 +- drivers/net/spnic/base/spnic_hw_cfg.c| 12 + drivers/net/spnic/base/spnic_hw_cfg.h| 2 + drivers/net/spnic/base/spnic_nic_cfg.c | 291 +++ drivers/net/spnic/base/spnic_nic_cfg.h | 180 drivers/net/spnic/base/spnic_nic_event.c | 27 +- drivers/net/spnic/base/spnic_nic_event.h | 9 +- drivers/net/spnic/spnic_ethdev.c | 348 ++- 8 files changed, 861 insertions(+), 11 deletions(-) create mode 100644 drivers/net/spnic/base/spnic_nic_cfg.c create mode 100644 drivers/net/spnic/base/spnic_nic_cfg.h diff --git a/drivers/net/spnic/base/meson.build b/drivers/net/spnic/base/meson.build index 77a56ca41e..f4bb4469ae 100644 --- a/drivers/net/spnic/base/meson.build +++ b/drivers/net/spnic/base/meson.build @@ -11,7 +11,8 @@ sources = [ 'spnic_cmdq.c', 'spnic_hw_comm.c', 'spnic_wq.c', - 'spnic_hw_cfg.c' + 'spnic_hw_cfg.c', + 'spnic_nic_cfg.c' ] extra_flags = [] diff --git a/drivers/net/spnic/base/spnic_hw_cfg.c b/drivers/net/spnic/base/spnic_hw_cfg.c index e8856ce9fe..6505f48273 100644 --- a/drivers/net/spnic/base/spnic_hw_cfg.c +++ b/drivers/net/spnic/base/spnic_hw_cfg.c @@ -155,3 +155,15 @@ void spnic_free_capability(void *dev) { rte_free(((struct spnic_hwdev *)dev)->cfg_mgmt); } + +u8 spnic_physical_port_id(void *hwdev) +{ + struct spnic_hwdev *dev = hwdev; + + if (!dev) { + PMD_DRV_LOG(INFO, "Hwdev is NULL for getting physical port id"); + return 0; + } + + return dev->cfg_mgmt->svc_cap.port_id; +} diff --git a/drivers/net/spnic/base/spnic_hw_cfg.h b/drivers/net/spnic/base/spnic_hw_cfg.h index 1b1b598726..9ab51f2875 100644 --- a/drivers/net/spnic/base/spnic_hw_cfg.h +++ b/drivers/net/spnic/base/spnic_hw_cfg.h @@ -112,6 +112,8 @@ struct spnic_cfg_cmd_dev_cap { int spnic_init_capability(void *dev); void spnic_free_capability(void *dev); +u8 spnic_physical_port_id(void *hwdev); + int cfg_mbx_vf_proc_msg(void *hwdev, void *pri_handle, u16 cmd, void *buf_in, u16 in_size, void *buf_out, u16 *out_size); #endif /* _SPNIC_HW_CFG_H_ */ diff --git a/drivers/net/spnic/base/spnic_nic_cfg.c b/drivers/net/spnic/base/spnic_nic_cfg.c new file mode 100644 index 00..c47bc330a3 --- /dev/null +++ b/drivers/net/spnic/base/spnic_nic_cfg.c @@ -0,0 +1,291 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2021 Ramaxel Memory Technology, Ltd + */ + +#include +#include "spnic_compat.h" +#include "spnic_cmd.h" +#include "spnic_mgmt.h" +#include "spnic_hwif.h" +#include "spnic_mbox.h" +#include "spnic_hwdev.h" +#include "spnic_wq.h" +#include "spnic_cmdq.h" +#include "spnic_nic_cfg.h" +#include "spnic_hw_cfg.h" + +struct vf_msg_handler { + u16 cmd; +}; + +const struct vf_msg_handler vf_cmd_handler[] = { + { + .cmd = SPNIC_CMD_VF_REGISTER, + }, + + { + .cmd = SPNIC_CMD_GET_MAC, + }, + + { + .cmd = SPNIC_CMD_SET_MAC, + }, + + { + .cmd = SPNIC_CMD_DEL_MAC, + }, + + { + .cmd = SPNIC_CMD_UPDATE_MAC, + }, + + { + .cmd = SPNIC_CMD_VF_COS, + }, +}; + +static const struct vf_msg_handler vf_mag_cmd_handler[] = { + { + .cmd = MAG_CMD_GET_LINK_STATUS, + }, +}; + +static int mag_msg_to_mgmt_sync(void *hwdev, u16 cmd, void *buf_in, u16 in_size, + void *buf_out, u16 *out_size); + +int l2nic_msg_to_mgmt_sync(void *hwdev, u16 cmd, void *buf_in, u16 in_size, + void *buf_out, u16 *out_size) +{ + u32 i, cmd_cnt = ARRAY_LEN(vf_cmd_handler); + bool cmd_to_pf = false; + + if (spnic_func_type(hwdev) == TYPE_VF) { + for (i = 0; i < cmd_cnt; i++) { + if (cmd == vf_cmd_handler[i].cmd) + cmd_to_pf = true; + } + } + + if (cmd_to_pf) { + return spnic_mbox_to_pf(hwdev, SPNIC_MOD_L2NIC, cmd, buf_in, + in_size, buf_out, out_size, 0); + } + + return spnic_msg_to_mgmt_sync(hwdev, SPNIC_MOD_L2NIC, cmd, buf_in, + in_size, buf_out, out_size, 0); +} + +static int spnic_check_mac_info(u8 status, u16 vlan_id) +{ + if ((status && status != SPNIC_MGMT_STATUS_EXIST && +status != SPNIC_PF_SET_VF_ALREADY) || + (vlan_id & CHECK_IPSU_15BIT && +status == SPNIC_MGMT_STATUS_EXIST)) + return -EINVAL; + + return 0; +} + +#define VLAN_N_VID 4096 + +int spnic_set_mac(void *hwdev, const u8 *mac_addr, u16
[PATCH v2 10/25] net/spnic: add function info initialization
This patch mainly implements function info initialization including mtu, link state, port state, port info and cos as well as the definition of the corresponding data structure. Signed-off-by: Yanling Song --- drivers/net/spnic/base/spnic_hw_cfg.c | 43 +++ drivers/net/spnic/base/spnic_hw_cfg.h | 6 + drivers/net/spnic/base/spnic_nic_cfg.c | 221 ++ drivers/net/spnic/base/spnic_nic_cfg.h | 213 ++ drivers/net/spnic/spnic_ethdev.c | 382 - drivers/net/spnic/spnic_ethdev.h | 22 +- 6 files changed, 876 insertions(+), 11 deletions(-) diff --git a/drivers/net/spnic/base/spnic_hw_cfg.c b/drivers/net/spnic/base/spnic_hw_cfg.c index 6505f48273..49e16ee89c 100644 --- a/drivers/net/spnic/base/spnic_hw_cfg.c +++ b/drivers/net/spnic/base/spnic_hw_cfg.c @@ -156,6 +156,49 @@ void spnic_free_capability(void *dev) rte_free(((struct spnic_hwdev *)dev)->cfg_mgmt); } +/* * + * @brief spnic_support_nic - function support nic + * @param hwdev: device pointer to hwdev + * @retval true: function support nic + * @retval false: function not support nic + */ +bool spnic_support_nic(void *hwdev) +{ + struct spnic_hwdev *dev = (struct spnic_hwdev *)hwdev; + + if (!hwdev) + return false; + + if (!IS_NIC_TYPE(dev)) + return false; + + return true; +} + +u16 spnic_func_max_sqs(void *hwdev) +{ + struct spnic_hwdev *dev = hwdev; + + if (!dev) { + PMD_DRV_LOG(INFO, "Hwdev is NULL for getting max_sqs"); + return 0; + } + + return dev->cfg_mgmt->svc_cap.nic_cap.max_sqs; +} + +u16 spnic_func_max_rqs(void *hwdev) +{ + struct spnic_hwdev *dev = hwdev; + + if (!dev) { + PMD_DRV_LOG(INFO, "Hwdev is NULL for getting max_rqs"); + return 0; + } + + return dev->cfg_mgmt->svc_cap.nic_cap.max_rqs; +} + u8 spnic_physical_port_id(void *hwdev) { struct spnic_hwdev *dev = hwdev; diff --git a/drivers/net/spnic/base/spnic_hw_cfg.h b/drivers/net/spnic/base/spnic_hw_cfg.h index 9ab51f2875..5019f38ec2 100644 --- a/drivers/net/spnic/base/spnic_hw_cfg.h +++ b/drivers/net/spnic/base/spnic_hw_cfg.h @@ -112,8 +112,14 @@ struct spnic_cfg_cmd_dev_cap { int spnic_init_capability(void *dev); void spnic_free_capability(void *dev); +u16 spnic_func_max_sqs(void *hwdev); +u16 spnic_func_max_rqs(void *hwdev); + u8 spnic_physical_port_id(void *hwdev); int cfg_mbx_vf_proc_msg(void *hwdev, void *pri_handle, u16 cmd, void *buf_in, u16 in_size, void *buf_out, u16 *out_size); + +bool spnic_support_nic(void *hwdev); + #endif /* _SPNIC_HW_CFG_H_ */ diff --git a/drivers/net/spnic/base/spnic_nic_cfg.c b/drivers/net/spnic/base/spnic_nic_cfg.c index c47bc330a3..886aaea384 100644 --- a/drivers/net/spnic/base/spnic_nic_cfg.c +++ b/drivers/net/spnic/base/spnic_nic_cfg.c @@ -265,6 +265,227 @@ int spnic_get_port_info(void *hwdev, struct nic_port_info *port_info) return 0; } + +int spnic_get_link_state(void *hwdev, u8 *link_state) +{ + struct spnic_cmd_link_state get_link; + u16 out_size = sizeof(get_link); + int err; + + if (!hwdev || !link_state) + return -EINVAL; + + memset(&get_link, 0, sizeof(get_link)); + get_link.port_id = spnic_physical_port_id(hwdev); + err = mag_msg_to_mgmt_sync(hwdev, MAG_CMD_GET_LINK_STATUS, &get_link, + sizeof(get_link), &get_link, &out_size); + if (err || !out_size || get_link.msg_head.status) { + PMD_DRV_LOG(ERR, "Get link state failed, err: %d, status: 0x%x, out size: 0x%x", + err, get_link.msg_head.status, out_size); + return -EIO; + } + + *link_state = get_link.state; + + return 0; +} + +int spnic_set_vport_enable(void *hwdev, bool enable) +{ + struct spnic_vport_state en_state; + u16 out_size = sizeof(en_state); + int err; + + if (!hwdev) + return -EINVAL; + + memset(&en_state, 0, sizeof(en_state)); + en_state.func_id = spnic_global_func_id(hwdev); + en_state.state = enable ? 1 : 0; + + err = l2nic_msg_to_mgmt_sync(hwdev, SPNIC_CMD_SET_VPORT_ENABLE, &en_state, +sizeof(en_state), &en_state, &out_size); + if (err || !out_size || en_state.msg_head.status) { + PMD_DRV_LOG(ERR, "Set vport state failed, err: %d, status: 0x%x, out size: 0x%x", + err, en_state.msg_head.status, out_size); + return -EIO; + } + + return 0; +} + +int spnic_set_port_enable(void *hwdev, bool enable) +{ + struct mag_cmd_set_port_enable en_state; + u16 out_size = sizeof(en_state); + int err; + + if (!hwdev) + return -EINVAL; + + if (spnic_func_type(hwdev) == TYPE_VF) + return 0; + + memset(&en_state, 0,
[PATCH v2 18/25] net/spnic: support VLAN filtering and offloading
This commit implements vlan_filter_set() and vlan_offload_set() to support VLAN filtering and offloading. Signed-off-by: Yanling Song --- drivers/net/spnic/base/spnic_nic_cfg.c | 8 ++ drivers/net/spnic/spnic_ethdev.c | 121 + 2 files changed, 129 insertions(+) diff --git a/drivers/net/spnic/base/spnic_nic_cfg.c b/drivers/net/spnic/base/spnic_nic_cfg.c index ddaecba95d..d54b017434 100644 --- a/drivers/net/spnic/base/spnic_nic_cfg.c +++ b/drivers/net/spnic/base/spnic_nic_cfg.c @@ -294,6 +294,14 @@ static int spnic_config_vlan(void *hwdev, u8 opcode, u16 vlan_id, u16 func_id) return 0; } +int spnic_add_vlan(void *hwdev, u16 vlan_id, u16 func_id) +{ + if (!hwdev) + return -EINVAL; + + return spnic_config_vlan(hwdev, SPNIC_CMD_OP_ADD, vlan_id, func_id); +} + int spnic_del_vlan(void *hwdev, u16 vlan_id, u16 func_id) { if (!hwdev) diff --git a/drivers/net/spnic/spnic_ethdev.c b/drivers/net/spnic/spnic_ethdev.c index cca03b5115..5b1c67c90f 100644 --- a/drivers/net/spnic/spnic_ethdev.c +++ b/drivers/net/spnic/spnic_ethdev.c @@ -1258,6 +1258,123 @@ static int spnic_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu) return err; } +/** + * Add or delete vlan id. + * + * @param[in] dev + * Pointer to ethernet device structure. + * @param[in] vlan_id + * Vlan id is used to filter vlan packets + * @param[in] enable + * Disable or enable vlan filter function + * + * @retval zero: Success + * @retval non-zero: Failure + */ +static int spnic_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, +int enable) +{ + struct spnic_nic_dev *nic_dev = SPNIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev); + int err = 0; + u16 func_id; + + if (vlan_id >= RTE_ETHER_MAX_VLAN_ID) + return -EINVAL; + + if (vlan_id == 0) + return 0; + + func_id = spnic_global_func_id(nic_dev->hwdev); + + if (enable) { + /* If vlanid is already set, just return */ + if (spnic_find_vlan_filter(nic_dev, vlan_id)) { + PMD_DRV_LOG(INFO, "Vlan %u has been added, device: %s", + vlan_id, nic_dev->dev_name); + return 0; + } + + err = spnic_add_vlan(nic_dev->hwdev, vlan_id, func_id); + } else { + /* If vlanid can't be found, just return */ + if (!spnic_find_vlan_filter(nic_dev, vlan_id)) { + PMD_DRV_LOG(INFO, "Vlan %u is not in the vlan filter list, device: %s", + vlan_id, nic_dev->dev_name); + return 0; + } + + err = spnic_del_vlan(nic_dev->hwdev, vlan_id, func_id); + } + + if (err) { + PMD_DRV_LOG(ERR, "%s vlan failed, func_id: %d, vlan_id: %d, err: %d", + enable ? "Add" : "Remove", func_id, vlan_id, err); + return err; + } + + spnic_store_vlan_filter(nic_dev, vlan_id, enable); + + PMD_DRV_LOG(INFO, "%s vlan %u succeed, device: %s", + enable ? "Add" : "Remove", vlan_id, nic_dev->dev_name); + + return 0; +} + +/** + * Enable or disable vlan offload. + * + * @param[in] dev + * Pointer to ethernet device structure. + * @param[in] mask + * Definitions used for VLAN setting, vlan filter of vlan strip + * + * @retval zero: Success + * @retval non-zero: Failure + */ +static int spnic_vlan_offload_set(struct rte_eth_dev *dev, int mask) +{ + struct spnic_nic_dev *nic_dev = SPNIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev); + struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode; + bool on; + int err; + + /* Enable or disable VLAN filter */ + if (mask & ETH_VLAN_FILTER_MASK) { + on = (rxmode->offloads & DEV_RX_OFFLOAD_VLAN_FILTER) ? +true : false; + err = spnic_set_vlan_fliter(nic_dev->hwdev, on); + if (err) { + PMD_DRV_LOG(ERR, "%s vlan filter failed, device: %s, port_id: %d, err: %d", + on ? "Enable" : "Disable", + nic_dev->dev_name, dev->data->port_id, err); + return err; + } + + PMD_DRV_LOG(INFO, "%s vlan filter succeed, device: %s, port_id: %d", + on ? "Enable" : "Disable", + nic_dev->dev_name, dev->data->port_id); + } + + /* Enable or disable VLAN stripping */ + if (mask & ETH_VLAN_STRIP_MASK) { + on = (rxmode->offloads & DEV_RX_OFFLOAD_VLAN_STRIP) ? +true : false; + err = spnic_set_rx_vlan_offload(nic_dev->hwdev, on); + if (err) { + PMD_DRV_LOG(ERR, "%s vlan strip failed, device: %s, port_id: %d, err: %d", +
[PATCH v2 21/25] net/spnic: support getting Tx/Rx queues info
This patch implements rxq_info_get() and txq_info_get() to support getting queue depth and mbuf pool info of specified Tx/Rx queue. Signed-off-by: Yanling Song --- drivers/net/spnic/spnic_ethdev.c | 21 + 1 file changed, 21 insertions(+) diff --git a/drivers/net/spnic/spnic_ethdev.c b/drivers/net/spnic/spnic_ethdev.c index 8df019db28..0dc7c367e7 100644 --- a/drivers/net/spnic/spnic_ethdev.c +++ b/drivers/net/spnic/spnic_ethdev.c @@ -1827,6 +1827,23 @@ static int spnic_rss_reta_update(struct rte_eth_dev *dev, return err; } +static void spnic_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id, + struct rte_eth_rxq_info *rxq_info) +{ + struct spnic_rxq *rxq = dev->data->rx_queues[queue_id]; + + rxq_info->mp = rxq->mb_pool; + rxq_info->nb_desc = rxq->q_depth; +} + +static void spnic_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id, + struct rte_eth_txq_info *txq_qinfo) +{ + struct spnic_txq *txq = dev->data->tx_queues[queue_id]; + + txq_qinfo->nb_desc = txq->q_depth; +} + /** * Update MAC address * @@ -2042,6 +2059,8 @@ static const struct eth_dev_ops spnic_pmd_ops = { .rss_hash_conf_get = spnic_rss_conf_get, .reta_update = spnic_rss_reta_update, .reta_query= spnic_rss_reta_query, + .rxq_info_get = spnic_rxq_info_get, + .txq_info_get = spnic_txq_info_get, .mac_addr_set = spnic_set_mac_addr, .mac_addr_remove = spnic_mac_addr_remove, .mac_addr_add = spnic_mac_addr_add, @@ -2073,6 +2092,8 @@ static const struct eth_dev_ops spnic_pmd_vf_ops = { .rss_hash_conf_get = spnic_rss_conf_get, .reta_update = spnic_rss_reta_update, .reta_query= spnic_rss_reta_query, + .rxq_info_get = spnic_rxq_info_get, + .txq_info_get = spnic_txq_info_get, .mac_addr_set = spnic_set_mac_addr, .mac_addr_remove = spnic_mac_addr_remove, .mac_addr_add = spnic_mac_addr_add, -- 2.32.0
[PATCH v2 15/25] net/spnic: support IO packets handling
This patch implements rx_pkt_burst() and tx_pkt_burst() to hanld IO packets. For Tx packets, this commit implements parsing ol_flags of mbuf and filling those offload info on wqe so that hardware can process the packets correctly. Furthermore, this commit allocates a mempool to cover scenes with too many mbufs for one packet. For Rx packets, this commit implements filling ol_flags of mbuf and rearming new mbuf and rq wqe. Signed-off-by: Yanling Song --- drivers/net/spnic/spnic_ethdev.c | 48 +++ drivers/net/spnic/spnic_ethdev.h | 7 + drivers/net/spnic/spnic_rx.c | 209 drivers/net/spnic/spnic_rx.h | 137 drivers/net/spnic/spnic_tx.c | 524 +++ drivers/net/spnic/spnic_tx.h | 7 + 6 files changed, 932 insertions(+) diff --git a/drivers/net/spnic/spnic_ethdev.c b/drivers/net/spnic/spnic_ethdev.c index 0459959ca5..7bd9aa0b9e 100644 --- a/drivers/net/spnic/spnic_ethdev.c +++ b/drivers/net/spnic/spnic_ethdev.c @@ -970,6 +970,32 @@ static int spnic_dev_start(struct rte_eth_dev *eth_dev) return err; } +static int spnic_copy_mempool_init(struct spnic_nic_dev *nic_dev) +{ + nic_dev->cpy_mpool = rte_mempool_lookup(nic_dev->dev_name); + if (nic_dev->cpy_mpool == NULL) { + nic_dev->cpy_mpool = + rte_pktmbuf_pool_create(nic_dev->dev_name, + SPNIC_COPY_MEMPOOL_DEPTH, 0, 0, + SPNIC_COPY_MBUF_SIZE, rte_socket_id()); + if (nic_dev->cpy_mpool == NULL) { + PMD_DRV_LOG(ERR, "Create copy mempool failed, errno: %d, dev_name: %s", + rte_errno, nic_dev->dev_name); + return -ENOMEM; + } + } + + return 0; +} + +static void spnic_copy_mempool_uninit(struct spnic_nic_dev *nic_dev) +{ + if (nic_dev->cpy_mpool != NULL) { + rte_mempool_free(nic_dev->cpy_mpool); + nic_dev->cpy_mpool = NULL; + } +} + /** * Stop the device. * @@ -986,6 +1012,9 @@ static int spnic_dev_stop(struct rte_eth_dev *dev) int err; nic_dev = SPNIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev); + if (!nic_dev || !spnic_support_nic(nic_dev->hwdev)) + return 0; + if (!rte_bit_relaxed_test_and_clear32(SPNIC_DEV_START, &nic_dev->dev_status)) { PMD_DRV_LOG(INFO, "Device %s already stopped", nic_dev->dev_name); @@ -1014,6 +1043,11 @@ static int spnic_dev_stop(struct rte_eth_dev *dev) spnic_flush_qps_res(nic_dev->hwdev); + /* +* After set vport disable 100ms, no packets will be send to host +*/ + rte_delay_ms(100); + /* Clean RSS table and rx_mode */ spnic_remove_rxtx_configure(dev); @@ -1054,6 +1088,7 @@ static int spnic_dev_close(struct rte_eth_dev *eth_dev) for (qid = 0; qid < nic_dev->num_rqs; qid++) spnic_rx_queue_release(eth_dev, qid); + spnic_copy_mempool_uninit(nic_dev); spnic_deinit_sw_rxtxqs(nic_dev); spnic_deinit_mac_addr(eth_dev); rte_free(nic_dev->mc_list); @@ -1067,6 +1102,8 @@ static int spnic_dev_close(struct rte_eth_dev *eth_dev) spnic_free_nic_hwdev(nic_dev->hwdev); spnic_free_hwdev(nic_dev->hwdev); + eth_dev->rx_pkt_burst = NULL; + eth_dev->tx_pkt_burst = NULL; eth_dev->dev_ops = NULL; rte_free(nic_dev->hwdev); @@ -1548,6 +1585,13 @@ static int spnic_func_init(struct rte_eth_dev *eth_dev) goto set_default_feature_fail; } + err = spnic_copy_mempool_init(nic_dev); + if (err) { + PMD_DRV_LOG(ERR, "Create copy mempool failed, dev_name: %s", +eth_dev->data->name); + goto init_mpool_fail; + } + spnic_mutex_init(&nic_dev->rx_mode_mutex, NULL); rte_bit_relaxed_set32(SPNIC_DEV_INTR_EN, &nic_dev->dev_status); @@ -1558,6 +1602,7 @@ static int spnic_func_init(struct rte_eth_dev *eth_dev) return 0; +init_mpool_fail: set_default_feature_fail: spnic_deinit_mac_addr(eth_dev); @@ -1602,6 +1647,9 @@ static int spnic_dev_init(struct rte_eth_dev *eth_dev) (rte_eal_process_type() == RTE_PROC_PRIMARY) ? "primary" : "secondary"); + eth_dev->rx_pkt_burst = spnic_recv_pkts; + eth_dev->tx_pkt_burst = spnic_xmit_pkts; + return spnic_func_init(eth_dev); } diff --git a/drivers/net/spnic/spnic_ethdev.h b/drivers/net/spnic/spnic_ethdev.h index 996b4e4b8f..2b59886942 100644 --- a/drivers/net/spnic/spnic_ethdev.h +++ b/drivers/net/spnic/spnic_ethdev.h @@ -4,6 +4,9 @@ #ifndef _SPNIC_ETHDEV_H_ #define _SPNIC_ETHDEV_H_ + +#define SPNIC_COPY_MEMPOOL_DEPTH 128 +#define SPNIC_COPY_MBUF_SIZE 4096 #define SPNIC_DEV_NAME_LEN 32 #define SPNIC_UINT32_BIT_SIZE (
[PATCH v2 19/25] net/spnic: support promiscuous and allmulticast Rx modes
This commit implements promiscuous_enable/disable() and allmulticast_enable/disable() to configure promiscuous or allmulticast Rx modes. Note: promiscuous rx mode is only supported by PF. Signed-off-by: Yanling Song --- drivers/net/spnic/spnic_ethdev.c | 156 +++ 1 file changed, 156 insertions(+) diff --git a/drivers/net/spnic/spnic_ethdev.c b/drivers/net/spnic/spnic_ethdev.c index 5b1c67c90f..4ca14f0c68 100644 --- a/drivers/net/spnic/spnic_ethdev.c +++ b/drivers/net/spnic/spnic_ethdev.c @@ -1375,6 +1375,156 @@ static int spnic_vlan_offload_set(struct rte_eth_dev *dev, int mask) return 0; } +/** + * Enable allmulticast mode. + * + * @param[in] dev + * Pointer to ethernet device structure. + * + * @retval zero: Success + * @retval non-zero: Failure + */ +static int spnic_dev_allmulticast_enable(struct rte_eth_dev *dev) +{ + struct spnic_nic_dev *nic_dev = SPNIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev); + u32 rx_mode; + int err; + + err = spnic_mutex_lock(&nic_dev->rx_mode_mutex); + if (err) + return err; + + rx_mode = nic_dev->rx_mode | SPNIC_RX_MODE_MC_ALL; + + err = spnic_set_rx_mode(nic_dev->hwdev, rx_mode); + if (err) { + (void)spnic_mutex_unlock(&nic_dev->rx_mode_mutex); + PMD_DRV_LOG(ERR, "Enable allmulticast failed, error: %d", err); + return err; + } + + nic_dev->rx_mode = rx_mode; + + (void)spnic_mutex_unlock(&nic_dev->rx_mode_mutex); + + PMD_DRV_LOG(INFO, "Enable allmulticast succeed, nic_dev: %s, port_id: %d", + nic_dev->dev_name, dev->data->port_id); + return 0; +} + +/** + * Disable allmulticast mode. + * + * @param[in] dev + * Pointer to ethernet device structure. + * + * @retval zero: Success + * @retval non-zero: Failure + */ +static int spnic_dev_allmulticast_disable(struct rte_eth_dev *dev) +{ + struct spnic_nic_dev *nic_dev = SPNIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev); + u32 rx_mode; + int err; + + err = spnic_mutex_lock(&nic_dev->rx_mode_mutex); + if (err) + return err; + + rx_mode = nic_dev->rx_mode & (~SPNIC_RX_MODE_MC_ALL); + + err = spnic_set_rx_mode(nic_dev->hwdev, rx_mode); + if (err) { + (void)spnic_mutex_unlock(&nic_dev->rx_mode_mutex); + PMD_DRV_LOG(ERR, "Disable allmulticast failed, error: %d", err); + return err; + } + + nic_dev->rx_mode = rx_mode; + + (void)spnic_mutex_unlock(&nic_dev->rx_mode_mutex); + + PMD_DRV_LOG(INFO, "Disable allmulticast succeed, nic_dev: %s, port_id: %d", + nic_dev->dev_name, dev->data->port_id); + return 0; +} + +/** + * Enable promiscuous mode. + * + * @param[in] dev + * Pointer to ethernet device structure. + * + * @retval zero: Success + * @retval non-zero: Failure + */ +static int spnic_dev_promiscuous_enable(struct rte_eth_dev *dev) +{ + struct spnic_nic_dev *nic_dev = SPNIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev); + u32 rx_mode; + int err; + + err = spnic_mutex_lock(&nic_dev->rx_mode_mutex); + if (err) + return err; + + rx_mode = nic_dev->rx_mode | SPNIC_RX_MODE_PROMISC; + + err = spnic_set_rx_mode(nic_dev->hwdev, rx_mode); + if (err) { + (void)spnic_mutex_unlock(&nic_dev->rx_mode_mutex); + PMD_DRV_LOG(ERR, "Enable promiscuous failed"); + return err; + } + + nic_dev->rx_mode = rx_mode; + + (void)spnic_mutex_unlock(&nic_dev->rx_mode_mutex); + + PMD_DRV_LOG(INFO, "Enable promiscuous, nic_dev: %s, port_id: %d, promisc: %d", + nic_dev->dev_name, dev->data->port_id, + dev->data->promiscuous); + return 0; +} + +/** + * Disable promiscuous mode. + * + * @param[in] dev + * Pointer to ethernet device structure. + * + * @retval zero: Success + * @retval non-zero: Failure + */ +static int spnic_dev_promiscuous_disable(struct rte_eth_dev *dev) +{ + struct spnic_nic_dev *nic_dev = SPNIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev); + u32 rx_mode; + int err; + + err = spnic_mutex_lock(&nic_dev->rx_mode_mutex); + if (err) + return err; + + rx_mode = nic_dev->rx_mode & (~SPNIC_RX_MODE_PROMISC); + + err = spnic_set_rx_mode(nic_dev->hwdev, rx_mode); + if (err) { + (void)spnic_mutex_unlock(&nic_dev->rx_mode_mutex); + PMD_DRV_LOG(ERR, "Disable promiscuous failed"); + return err; + } + + nic_dev->rx_mode = rx_mode; + + (void)spnic_mutex_unlock(&nic_dev->rx_mode_mutex); + + PMD_DRV_LOG(INFO, "Disable promiscuous, nic_dev: %s, port_id: %d, promisc: %d", + nic_dev->dev_name, dev->data->port_id, + dev->data->promiscuous); + return 0; +} + /** * Update the RSS hash key and RSS hash type. @@ -1811,6 +1961,10 @@ st
[PATCH v2 20/25] net/spnic: support flow control
This commit implements flow control operations to support related syscalls. Signed-off-by: Yanling Song --- drivers/net/spnic/base/spnic_nic_cfg.c | 53 ++ drivers/net/spnic/base/spnic_nic_cfg.h | 25 + drivers/net/spnic/spnic_ethdev.c | 77 ++ drivers/net/spnic/spnic_ethdev.h | 1 + 4 files changed, 156 insertions(+) diff --git a/drivers/net/spnic/base/spnic_nic_cfg.c b/drivers/net/spnic/base/spnic_nic_cfg.c index d54b017434..258c6cf8c7 100644 --- a/drivers/net/spnic/base/spnic_nic_cfg.c +++ b/drivers/net/spnic/base/spnic_nic_cfg.c @@ -440,6 +440,59 @@ int spnic_flush_qps_res(void *hwdev) return 0; } +static int spnic_cfg_hw_pause(void *hwdev, u8 opcode, + struct nic_pause_config *nic_pause) +{ + struct spnic_cmd_pause_config pause_info; + u16 out_size = sizeof(pause_info); + int err; + + memset(&pause_info, 0, sizeof(pause_info)); + + pause_info.port_id = spnic_physical_port_id(hwdev); + pause_info.opcode = opcode; + if (opcode == SPNIC_CMD_OP_SET) { + pause_info.auto_neg = nic_pause->auto_neg; + pause_info.rx_pause = nic_pause->rx_pause; + pause_info.tx_pause = nic_pause->tx_pause; + } + + err = l2nic_msg_to_mgmt_sync(hwdev, SPNIC_CMD_CFG_PAUSE_INFO, +&pause_info, sizeof(pause_info), +&pause_info, &out_size); + if (err || !out_size || pause_info.msg_head.status) { + PMD_DRV_LOG(ERR, "%s pause info failed, err: %d, status: 0x%x, out size: 0x%x\n", + opcode == SPNIC_CMD_OP_SET ? "Set" : "Get", + err, pause_info.msg_head.status, out_size); + return -EIO; + } + + if (opcode == SPNIC_CMD_OP_GET) { + nic_pause->auto_neg = pause_info.auto_neg; + nic_pause->rx_pause = pause_info.rx_pause; + nic_pause->tx_pause = pause_info.tx_pause; + } + + return 0; +} + +int spnic_set_pause_info(void *hwdev, struct nic_pause_config nic_pause) +{ + if (!hwdev) + return -EINVAL; + + return spnic_cfg_hw_pause(hwdev, SPNIC_CMD_OP_SET, &nic_pause); +} + +int spnic_get_pause_info(void *hwdev, struct nic_pause_config *nic_pause) +{ + if (!hwdev || !nic_pause) + return -EINVAL; + + + return spnic_cfg_hw_pause(hwdev, SPNIC_CMD_OP_GET, nic_pause); +} + static int spnic_set_function_table(void *hwdev, u32 cfg_bitmap, struct spnic_func_tbl_cfg *cfg) { diff --git a/drivers/net/spnic/base/spnic_nic_cfg.h b/drivers/net/spnic/base/spnic_nic_cfg.h index 1044af3dcc..bc4707c05b 100644 --- a/drivers/net/spnic/base/spnic_nic_cfg.h +++ b/drivers/net/spnic/base/spnic_nic_cfg.h @@ -560,6 +560,31 @@ int spnic_get_link_state(void *hwdev, u8 *link_state); */ int spnic_flush_qps_res(void *hwdev); +/** + * Set pause info + * + * @param[in] hwdev + * Device pointer to hwdev + * @param[in] nic_pause + * Pause info + * + * @retval zero : Success + * @retval non-zero : Failure + */ +int spnic_set_pause_info(void *hwdev, struct nic_pause_config nic_pause); + +/** + * Get pause info + * + * @param[in] hwdev + * Device pointer to hwdev + * @param[out] nic_pause + * Pause info + * + * @retval zero : Success + * @retval non-zero : Failure + */ +int spnic_get_pause_info(void *hwdev, struct nic_pause_config *nic_pause); /** * Init nic hwdev diff --git a/drivers/net/spnic/spnic_ethdev.c b/drivers/net/spnic/spnic_ethdev.c index 4ca14f0c68..8df019db28 100644 --- a/drivers/net/spnic/spnic_ethdev.c +++ b/drivers/net/spnic/spnic_ethdev.c @@ -1525,6 +1525,81 @@ static int spnic_dev_promiscuous_disable(struct rte_eth_dev *dev) return 0; } +static int spnic_dev_flow_ctrl_get(struct rte_eth_dev *dev, + struct rte_eth_fc_conf *fc_conf) +{ + struct spnic_nic_dev *nic_dev = SPNIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev); + struct nic_pause_config nic_pause; + int err; + + err = spnic_mutex_lock(&nic_dev->pause_mutuex); + if (err) + return err; + + memset(&nic_pause, 0, sizeof(nic_pause)); + err = spnic_get_pause_info(nic_dev->hwdev, &nic_pause); + if (err) { + (void)spnic_mutex_unlock(&nic_dev->pause_mutuex); + return err; + } + + if (nic_dev->pause_set || !nic_pause.auto_neg) { + nic_pause.rx_pause = nic_dev->nic_pause.rx_pause; + nic_pause.tx_pause = nic_dev->nic_pause.tx_pause; + } + + fc_conf->autoneg = nic_pause.auto_neg; + + if (nic_pause.tx_pause && nic_pause.rx_pause) + fc_conf->mode = RTE_FC_FULL; + else if (nic_pause.tx_pause) + fc_conf->mode = RTE_FC_TX_PAUSE; + else if (nic_pause.rx_pause) + fc_conf->mode
[PATCH v2 23/25] net/spnic: support VFIO interrupt
This commit supports VFIO interrupt for Rx queue and asynchronous event, and implements rx_queue_intr_disable() and rx_queue_intr_enable() to disable/enable the interrupt of specified Rx queue. Signed-off-by: Yanling Song --- drivers/net/spnic/base/spnic_eqs.c | 11 ++ drivers/net/spnic/spnic_ethdev.c | 218 - drivers/net/spnic/spnic_ethdev.h | 3 + drivers/net/spnic/spnic_rx.c | 2 + 4 files changed, 233 insertions(+), 1 deletion(-) diff --git a/drivers/net/spnic/base/spnic_eqs.c b/drivers/net/spnic/base/spnic_eqs.c index ee52252ecc..513d0329ed 100644 --- a/drivers/net/spnic/base/spnic_eqs.c +++ b/drivers/net/spnic/base/spnic_eqs.c @@ -12,6 +12,7 @@ #include "spnic_eqs.h" #include "spnic_mgmt.h" #include "spnic_mbox.h" +#include "spnic_hw_comm.h" #include "spnic_nic_event.h" #define AEQ_CTRL_0_INTR_IDX_SHIFT 0 @@ -648,3 +649,13 @@ int spnic_aeq_poll_msg(struct spnic_eq *eq, u32 timeout, void *param) return err; } + +void spnic_dev_handle_aeq_event(struct spnic_hwdev *hwdev, void *param) +{ + struct spnic_eq *aeq = &hwdev->aeqs->aeq[0]; + + /* Clear resend timer cnt register */ + spnic_misx_intr_clear_resend_bit(hwdev, aeq->eq_irq.msix_entry_idx, +EQ_MSIX_RESEND_TIMER_CLEAR); + (void)spnic_aeq_poll_msg(aeq, 0, param); +} diff --git a/drivers/net/spnic/spnic_ethdev.c b/drivers/net/spnic/spnic_ethdev.c index b53eb96903..569d29b429 100644 --- a/drivers/net/spnic/spnic_ethdev.c +++ b/drivers/net/spnic/spnic_ethdev.c @@ -248,6 +248,28 @@ static const struct rte_eth_desc_lim spnic_tx_desc_lim = { .nb_align = SPNIC_TXD_ALIGN, }; +/** + * Interrupt handler triggered by NIC for handling specific event + * + * @param[in] param + * The address of parameter (struct rte_eth_dev *) registered before + */ +static void spnic_dev_interrupt_handler(void *param) +{ + struct rte_eth_dev *dev = param; + struct spnic_nic_dev *nic_dev = SPNIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev); + + if (!rte_bit_relaxed_get32(SPNIC_DEV_INTR_EN, &nic_dev->dev_status)) { + PMD_DRV_LOG(WARNING, + "Intr is disabled, ignore intr event, dev_name: %s, port_id: %d", + nic_dev->dev_name, dev->data->port_id); + return; + } + + /* Aeq0 msg handler */ + spnic_dev_handle_aeq_event(nic_dev->hwdev, param); +} + /** * Ethernet device configuration. * @@ -952,6 +974,46 @@ static void spnic_deinit_mac_addr(struct rte_eth_dev *eth_dev) spnic_delete_mc_addr_list(nic_dev); } +int spnic_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, + uint16_t queue_id) +{ + struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); + struct rte_intr_handle *intr_handle = pci_dev->intr_handle; + struct spnic_nic_dev *nic_dev = SPNIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev); + u16 msix_intr; + + if (!rte_intr_dp_is_en(intr_handle)) + return 0; + + if (queue_id >= dev->data->nb_rx_queues) + return -EINVAL; + + msix_intr = (u16)(queue_id + RTE_INTR_VEC_RXTX_OFFSET); + spnic_set_msix_state(nic_dev->hwdev, msix_intr, SPNIC_MSIX_ENABLE); + + return 0; +} + +int spnic_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id) +{ + struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); + struct rte_intr_handle *intr_handle = pci_dev->intr_handle; + struct spnic_nic_dev *nic_dev = SPNIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev); + u16 msix_intr; + + if (!rte_intr_dp_is_en(intr_handle)) + return 0; + + if (queue_id >= dev->data->nb_rx_queues) + return -EINVAL; + + msix_intr = (u16)(queue_id + RTE_INTR_VEC_RXTX_OFFSET); + spnic_set_msix_state(nic_dev->hwdev, msix_intr, SPNIC_MSIX_DISABLE); + spnic_misx_intr_clear_resend_bit(nic_dev->hwdev, msix_intr, 1); + + return 0; +} + static int spnic_set_rxtx_configure(struct rte_eth_dev *dev) { struct spnic_nic_dev *nic_dev = SPNIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev); @@ -1085,6 +1147,108 @@ static void spnic_remove_all_vlanid(struct rte_eth_dev *dev) } } +static void spnic_disable_interrupt(struct rte_eth_dev *dev) +{ + struct spnic_nic_dev *nic_dev = SPNIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev); + struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); + + if (!rte_bit_relaxed_get32(SPNIC_DEV_INIT, &nic_dev->dev_status)) + return; + + /* disable rte interrupt */ + rte_intr_disable(pci_dev->intr_handle); + rte_intr_callback_unregister(pci_dev->intr_handle, +spnic_dev_interrupt_handler, (void *)dev); +} + +static void spnic_enable_interrupt(struct rte_eth_dev *dev) +{ + struct spnic_nic_dev *nic_dev = SPNIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev); + struct rte_pci_device *pc
[PATCH v2 22/25] net/spnic: net/spnic: support xstats statistics
This commit implements DFX statistics of physical port, function, Rx queues and Tx queues, which includes MAC statistic, unicast/multicast/broadcast packets statistic, rx_mbuf, tx_busy and etc. Signed-off-by: Yanling Song --- drivers/net/spnic/base/spnic_nic_cfg.c | 118 ++ drivers/net/spnic/base/spnic_nic_cfg.h | 206 +++ drivers/net/spnic/spnic_ethdev.c | 474 + 3 files changed, 798 insertions(+) diff --git a/drivers/net/spnic/base/spnic_nic_cfg.c b/drivers/net/spnic/base/spnic_nic_cfg.c index 258c6cf8c7..e740138b8e 100644 --- a/drivers/net/spnic/base/spnic_nic_cfg.c +++ b/drivers/net/spnic/base/spnic_nic_cfg.c @@ -493,6 +493,124 @@ int spnic_get_pause_info(void *hwdev, struct nic_pause_config *nic_pause) return spnic_cfg_hw_pause(hwdev, SPNIC_CMD_OP_GET, nic_pause); } +int spnic_get_vport_stats(void *hwdev, struct spnic_vport_stats *stats) +{ + struct spnic_port_stats_info stats_info; + struct spnic_cmd_vport_stats vport_stats; + u16 out_size = sizeof(vport_stats); + int err; + + if (!hwdev || !stats) + return -EINVAL; + + memset(&stats_info, 0, sizeof(stats_info)); + memset(&vport_stats, 0, sizeof(vport_stats)); + + stats_info.func_id = spnic_global_func_id(hwdev); + + err = l2nic_msg_to_mgmt_sync(hwdev, SPNIC_CMD_GET_VPORT_STAT, +&stats_info, sizeof(stats_info), +&vport_stats, &out_size); + if (err || !out_size || vport_stats.msg_head.status) { + PMD_DRV_LOG(ERR, "Get function stats failed, err: %d, status: 0x%x, out size: 0x%x", + err, vport_stats.msg_head.status, out_size); + return -EIO; + } + + memcpy(stats, &vport_stats.stats, sizeof(*stats)); + + return 0; +} + +int spnic_get_phy_port_stats(void *hwdev, struct mag_phy_port_stats *stats) +{ + struct mag_cmd_get_port_stat *port_stats = NULL; + struct mag_cmd_port_stats_info stats_info; + u16 out_size = sizeof(*port_stats); + int err; + + port_stats = rte_zmalloc("port_stats", sizeof(*port_stats), 0); + if (!port_stats) + return -ENOMEM; + + memset(&stats_info, 0, sizeof(stats_info)); + stats_info.port_id = spnic_physical_port_id(hwdev); + + err = mag_msg_to_mgmt_sync(hwdev, MAG_CMD_GET_PORT_STAT, + &stats_info, sizeof(stats_info), + port_stats, &out_size); + if (err || !out_size || port_stats->head.status) { + PMD_DRV_LOG(ERR, + "Failed to get port statistics, err: %d, status: 0x%x, out size: 0x%x\n", + err, port_stats->head.status, out_size); + err = -EIO; + goto out; + } + + memcpy(stats, &port_stats->counter, sizeof(*stats)); + +out: + rte_free(port_stats); + + return err; +} + +int spnic_clear_vport_stats(void *hwdev) +{ + struct spnic_cmd_clear_vport_stats clear_vport_stats; + u16 out_size = sizeof(clear_vport_stats); + int err; + + if (!hwdev) { + PMD_DRV_LOG(ERR, "Hwdev is NULL"); + return -EINVAL; + } + + memset(&clear_vport_stats, 0, sizeof(clear_vport_stats)); + clear_vport_stats.func_id = spnic_global_func_id(hwdev); + + err = l2nic_msg_to_mgmt_sync(hwdev, SPNIC_CMD_CLEAN_VPORT_STAT, +&clear_vport_stats, +sizeof(clear_vport_stats), +&clear_vport_stats, &out_size); + if (err || !out_size || clear_vport_stats.msg_head.status) { + PMD_DRV_LOG(ERR, "Clear vport stats failed, err: %d, status: 0x%x, out size: 0x%x", + err, clear_vport_stats.msg_head.status, out_size); + return -EIO; + } + + return 0; +} + +int spnic_clear_phy_port_stats(void *hwdev) +{ + struct mag_cmd_clr_port_stat *port_stats = NULL; + u16 out_size = sizeof(*port_stats); + int err; + + port_stats = rte_zmalloc("port_stats", sizeof(*port_stats), 0); + if (!port_stats) + return -ENOMEM; + + port_stats->port_id = spnic_physical_port_id(hwdev); + + err = mag_msg_to_mgmt_sync(hwdev, MAG_CMD_GET_PORT_STAT, + &port_stats, sizeof(port_stats), + port_stats, &out_size); + if (err || !out_size || port_stats->head.status) { + PMD_DRV_LOG(ERR, + "Failed to get port statistics, err: %d, status: 0x%x, out size: 0x%x\n", + err, port_stats->head.status, out_size); + err = -EIO; + goto out; + } + +out: + rte_free(port_stats); + + return err; +} + static int spnic_set_function_table(void *hwd
[PATCH v2 24/25] net/spnic: support Tx/Rx queue start/stop
This commit support starting or stopping a specified Rx/Tx queue For Rx queue: when starting rx queue, mbuf will be allocated and fill rq wqe with mbuf info, then add the qid to indirect table of RSS. if the first rx queue is started, the valid bit in function table will be set so that the packets can be received to host. when stopping rx queue, the PMD driver will poll the rx queue until it is empty and release the mbuf, then the PMD driver will remove the qid for RSS indirect table. if the last rx queue is stopped, the valid bit in function table will be cleared. For Rx queue: when stopping tx queue, the PMD driver will wait until all tx packets are sent and then releases all mbuf. Signed-off-by: Yanling Song --- drivers/net/spnic/base/spnic_nic_cfg.c | 33 drivers/net/spnic/base/spnic_nic_cfg.h | 13 ++ drivers/net/spnic/spnic_ethdev.c | 82 + drivers/net/spnic/spnic_rx.c | 222 + drivers/net/spnic/spnic_rx.h | 4 + 5 files changed, 354 insertions(+) diff --git a/drivers/net/spnic/base/spnic_nic_cfg.c b/drivers/net/spnic/base/spnic_nic_cfg.c index e740138b8e..862400de71 100644 --- a/drivers/net/spnic/base/spnic_nic_cfg.c +++ b/drivers/net/spnic/base/spnic_nic_cfg.c @@ -1289,6 +1289,39 @@ int spnic_vf_get_default_cos(void *hwdev, u8 *cos_id) return 0; } +int spnic_set_rq_flush(void *hwdev, u16 q_id) +{ + struct spnic_cmd_set_rq_flush *rq_flush_msg = NULL; + struct spnic_cmd_buf *cmd_buf = NULL; + u64 out_param = EIO; + int err; + + cmd_buf = spnic_alloc_cmd_buf(hwdev); + if (!cmd_buf) { + PMD_DRV_LOG(ERR, "Failed to allocate cmd buf\n"); + return -ENOMEM; + } + + cmd_buf->size = sizeof(*rq_flush_msg); + + rq_flush_msg = cmd_buf->buf; + rq_flush_msg->local_rq_id = q_id; + rq_flush_msg->value = cpu_to_be32(rq_flush_msg->value); + + err = spnic_cmdq_direct_resp(hwdev, SPNIC_MOD_L2NIC, +SPNIC_UCODE_CMD_SET_RQ_FLUSH, cmd_buf, +&out_param, 0); + if (err || out_param != 0) { + PMD_DRV_LOG(ERR, "Failed to set rq flush, err:%d, out_param: %" PRIu64 "", + err, out_param); + err = -EFAULT; + } + + spnic_free_cmd_buf(cmd_buf); + + return err; +} + static int _mag_msg_to_mgmt_sync(void *hwdev, u16 cmd, void *buf_in, u16 in_size, void *buf_out, u16 *out_size) { diff --git a/drivers/net/spnic/base/spnic_nic_cfg.h b/drivers/net/spnic/base/spnic_nic_cfg.h index 560c9e4e7d..7c39a32d7c 100644 --- a/drivers/net/spnic/base/spnic_nic_cfg.h +++ b/drivers/net/spnic/base/spnic_nic_cfg.h @@ -1069,6 +1069,19 @@ int spnic_set_vlan_fliter(void *hwdev, u32 vlan_filter_ctrl); */ int spnic_vf_get_default_cos(void *hwdev, u8 *cos_id); +/** + * Flush rx queue resource + * + * @param[in] hwdev + * Device pointer to hwdev + * @param[in] q_id + * rx queue id + * + * @retval zero : Success + * @retval non-zero : Failure + */ +int spnic_set_rq_flush(void *hwdev, u16 q_id); + /** * Get service feature HW supported * diff --git a/drivers/net/spnic/spnic_ethdev.c b/drivers/net/spnic/spnic_ethdev.c index 569d29b429..aae40f9c02 100644 --- a/drivers/net/spnic/spnic_ethdev.c +++ b/drivers/net/spnic/spnic_ethdev.c @@ -974,6 +974,80 @@ static void spnic_deinit_mac_addr(struct rte_eth_dev *eth_dev) spnic_delete_mc_addr_list(nic_dev); } +static int spnic_dev_rx_queue_start(__rte_unused struct rte_eth_dev *dev, +__rte_unused uint16_t rq_id) +{ + struct spnic_rxq *rxq = NULL; + int rc; + + if (rq_id < dev->data->nb_rx_queues) { + rxq = dev->data->rx_queues[rq_id]; + + rc = spnic_start_rq(dev, rxq); + if (rc) { + PMD_DRV_LOG(ERR, "Start rx queue failed, eth_dev:%s, queue_idx:%d", + dev->data->name, rq_id); + return rc; + } + + dev->data->rx_queue_state[rq_id] = RTE_ETH_QUEUE_STATE_STARTED; + } + + return 0; +} + +static int spnic_dev_rx_queue_stop(__rte_unused struct rte_eth_dev *dev, + __rte_unused uint16_t rq_id) +{ + struct spnic_rxq *rxq = NULL; + int rc; + + if (rq_id < dev->data->nb_rx_queues) { + rxq = dev->data->rx_queues[rq_id]; + + rc = spnic_stop_rq(dev, rxq); + if (rc) { + PMD_DRV_LOG(ERR, "Stop rx queue failed, eth_dev:%s, queue_idx:%d", + dev->data->name, rq_id); + return rc; + } + + dev->data->rx_queue_state[rq_id] = RTE_ETH_QUEUE_STATE_STOPPED; + } + + return 0; +} + +static int spnic_dev_tx_queue_start(__rte_
[PATCH v2 25/25] net/spnic: add doc infrastructure
This patch adds doc infrastructure for spnic PMD driver. Signed-off-by: Yanling Song --- MAINTAINERS| 6 +++ doc/guides/nics/features/spnic.ini | 39 +++ doc/guides/nics/index.rst | 1 + doc/guides/nics/spnic.rst | 61 ++ 4 files changed, 107 insertions(+) create mode 100644 doc/guides/nics/features/spnic.ini create mode 100644 doc/guides/nics/spnic.rst diff --git a/MAINTAINERS b/MAINTAINERS index 18d9edaf88..12f6171aef 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -919,6 +919,12 @@ F: drivers/net/qede/ F: doc/guides/nics/qede.rst F: doc/guides/nics/features/qede*.ini +Ramaxel SPNIC +M: Yanling Song +F: drivers/net/spnic/ +F: doc/guides/nics/spnic.rst +F: doc/guides/nics/features/spnic.ini + Solarflare sfc_efx M: Andrew Rybchenko F: drivers/common/sfc_efx/ diff --git a/doc/guides/nics/features/spnic.ini b/doc/guides/nics/features/spnic.ini new file mode 100644 index 00..1cec6a59fa --- /dev/null +++ b/doc/guides/nics/features/spnic.ini @@ -0,0 +1,39 @@ +; +; Supported features of 'spnic' network poll mode driver. +; +; Refer to default.ini for the full list of available PMD features. +; +[Features] +Speed capabilities = Y +Link status = Y +Link status event= Y +Queue start/stop = Y +MTU update = Y +Scattered Rx = Y +LRO = Y +TSO = Y +Promiscuous mode = Y +Allmulticast mode= Y +Unicast MAC filter = Y +Multicast MAC filter = Y +RSS hash = Y +RSS key update = Y +RSS reta update = Y +Inner RSS= Y +SR-IOV = Y +Flow control = Y +CRC offload = Y +VLAN filter = Y +VLAN offload = Y +L3 checksum offload = Y +L4 checksum offload = Y +Inner L3 checksum= Y +Inner L4 checksum= Y +Basic stats = Y +Extended stats = Y +Stats per queue = Y +FW version = Y +Multiprocess aware = Y +Linux= Y +x86-64 = Y +ARMv8= Y diff --git a/doc/guides/nics/index.rst b/doc/guides/nics/index.rst index 1c94caccea..6d47fa64a1 100644 --- a/doc/guides/nics/index.rst +++ b/doc/guides/nics/index.rst @@ -57,6 +57,7 @@ Network Interface Controller Drivers pfe qede sfc_efx +spnic softnic tap thunderx diff --git a/doc/guides/nics/spnic.rst b/doc/guides/nics/spnic.rst new file mode 100644 index 00..9305ecbb84 --- /dev/null +++ b/doc/guides/nics/spnic.rst @@ -0,0 +1,61 @@ +.. SPDX-License-Identifier: BSD-3-Clause +Copyright(c) 2021 Ramaxel Memory Technology, Ltd + + +SPNIC Poll Mode Driver +== + +The spnic PMD (**librte_net_spnic**) provides poll mode driver support +for 25Gbps/100Gbps SPNxxx Network Adapters. + + +Features + + +- Multiple queues for TX and RX +- Receiver Side Scaling(RSS) +- RSS supports IPv4, IPv6, TCPv4, TCPv6, UDPv4 and UDPv6, use inner type for VXLAN as default +- MAC/VLAN filtering +- Checksum offload +- TSO offload +- LRO offload +- Promiscuous mode +- Port hardware statistics +- Link state information +- Link flow control(pause frame) +- Scattered and gather for TX and RX +- SR-IOV - Partially supported VFIO only +- VLAN filter and VLAN offload +- Allmulticast mode +- MTU update +- Unicast MAC filter +- Multicast MAC filter +- Set Link down or up +- FW version +- Multi arch support: x86_64, ARMv8. + +Prerequisites +- + +- Learning about SPNIC using + ``_. + +- Getting the latest product documents and software supports using + ``_. + +- Follow the DPDK :ref:`Getting Started Guide for Linux ` to setup the basic DPDK environment. + + +Driver compilation and testing +-- + +Refer to the document :ref:`compiling and testing a PMD for a NIC ` +for details. + +It is highly recommended to upgrade the spnic driver and firmware to avoid the compatibility issues, +and check the work mode with the latest product documents. + +Limitations or Known issues +--- +Build with ICC is not supported yet. +X86-32, Power8, ARMv7 and BSD are not supported yet. -- 2.32.0
[PATCH v2 16/25] net/spnic: add device configure/version/info
This commit adds the callbacks to configure queue number and mtu as well as query configuration information and firmware version. Signed-off-by: Yanling Song --- drivers/net/spnic/spnic_ethdev.c | 129 ++- 1 file changed, 127 insertions(+), 2 deletions(-) diff --git a/drivers/net/spnic/spnic_ethdev.c b/drivers/net/spnic/spnic_ethdev.c index 7bd9aa0b9e..50cca24258 100644 --- a/drivers/net/spnic/spnic_ethdev.c +++ b/drivers/net/spnic/spnic_ethdev.c @@ -71,12 +71,131 @@ enum spnic_rx_mod { #define SPNIC_TXD_ALIGN1 #define SPNIC_RXD_ALIGN1 +static const struct rte_eth_desc_lim spnic_rx_desc_lim = { + .nb_max = SPNIC_MAX_QUEUE_DEPTH, + .nb_min = SPNIC_MIN_QUEUE_DEPTH, + .nb_align = SPNIC_RXD_ALIGN, +}; + +static const struct rte_eth_desc_lim spnic_tx_desc_lim = { + .nb_max = SPNIC_MAX_QUEUE_DEPTH, + .nb_min = SPNIC_MIN_QUEUE_DEPTH, + .nb_align = SPNIC_TXD_ALIGN, +}; + /** - * Deinit mac_vlan table in hardware. + * Ethernet device configuration. * - * @param[in] eth_dev + * Prepare the driver for a given number of TX and RX queues, mtu size + * and configure RSS. + * + * @param[in] dev + * Pointer to ethernet device structure. + * + * @retval zero : Success + * @retval non-zero : Failure. + */ +static int spnic_dev_configure(struct rte_eth_dev *dev) +{ + struct spnic_nic_dev *nic_dev = SPNIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev); + + nic_dev->num_sqs = dev->data->nb_tx_queues; + nic_dev->num_rqs = dev->data->nb_rx_queues; + + nic_dev->mtu_size = + SPNIC_PKTLEN_TO_MTU(dev->data->dev_conf.rxmode.mtu); + + if (dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_RSS_FLAG) + dev->data->dev_conf.rxmode.offloads |= DEV_RX_OFFLOAD_RSS_HASH; + + return 0; +} + +/** + * Get information about the device. + * + * @param[in] dev * Pointer to ethernet device structure. + * @param[out] info + * Info structure for ethernet device. + * + * @retval zero : Success + * @retval non-zero : Failure. */ +static int spnic_dev_infos_get(struct rte_eth_dev *dev, + struct rte_eth_dev_info *info) +{ + struct spnic_nic_dev *nic_dev = SPNIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev); + + info->max_rx_queues = nic_dev->max_rqs; + info->max_tx_queues = nic_dev->max_sqs; + info->min_rx_bufsize = SPNIC_MIN_RX_BUF_SIZE; + info->max_rx_pktlen = SPNIC_MAX_JUMBO_FRAME_SIZE; + info->max_mac_addrs = SPNIC_MAX_UC_MAC_ADDRS; + info->min_mtu = SPNIC_MIN_MTU_SIZE; + info->max_mtu = SPNIC_MAX_MTU_SIZE; + info->max_lro_pkt_size = SPNIC_MAX_LRO_SIZE; + + info->rx_queue_offload_capa = 0; + info->rx_offload_capa = DEV_RX_OFFLOAD_VLAN_STRIP | + DEV_RX_OFFLOAD_IPV4_CKSUM | + DEV_RX_OFFLOAD_UDP_CKSUM | + DEV_RX_OFFLOAD_TCP_CKSUM | + DEV_RX_OFFLOAD_SCTP_CKSUM | + DEV_RX_OFFLOAD_VLAN_FILTER | + DEV_RX_OFFLOAD_SCATTER | + DEV_RX_OFFLOAD_TCP_LRO | + DEV_RX_OFFLOAD_RSS_HASH; + + info->tx_queue_offload_capa = 0; + info->tx_offload_capa = DEV_TX_OFFLOAD_VLAN_INSERT | + DEV_TX_OFFLOAD_IPV4_CKSUM | + DEV_TX_OFFLOAD_UDP_CKSUM | + DEV_TX_OFFLOAD_TCP_CKSUM | + DEV_TX_OFFLOAD_SCTP_CKSUM | + DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM | + DEV_TX_OFFLOAD_TCP_TSO | + DEV_TX_OFFLOAD_MULTI_SEGS; + + info->hash_key_size = SPNIC_RSS_KEY_SIZE; + info->reta_size = SPNIC_RSS_INDIR_SIZE; + info->flow_type_rss_offloads = SPNIC_RSS_OFFLOAD_ALL; + + info->rx_desc_lim = spnic_rx_desc_lim; + info->tx_desc_lim = spnic_tx_desc_lim; + + /* Driver-preferred rx/tx parameters */ + info->default_rxportconf.burst_size = SPNIC_DEFAULT_BURST_SIZE; + info->default_txportconf.burst_size = SPNIC_DEFAULT_BURST_SIZE; + info->default_rxportconf.nb_queues = SPNIC_DEFAULT_NB_QUEUES; + info->default_txportconf.nb_queues = SPNIC_DEFAULT_NB_QUEUES; + info->default_rxportconf.ring_size = SPNIC_DEFAULT_RING_SIZE; + info->default_txportconf.ring_size = SPNIC_DEFAULT_RING_SIZE; + + return 0; +} + +static int spnic_fw_version_get(struct rte_eth_dev *dev, char *fw_version, + size_t fw_size) +{ + struct spnic_nic_dev *nic_dev = SPNIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev); + char mgmt_ver[MGMT_VERSION_MAX_LEN] = { 0 }; + int err; + + err = spnic_get_mgmt_version(nic_dev->hwdev, mgmt_ver, +SPNIC_MGMT_VERSION_MAX_LEN); + if (err) { +
[PATCH v2 17/25] net/spnic: support RSS configuration update and get
This commit implements rss_hash_update and rss_hash_conf_get. Signed-off-by: Yanling Song --- drivers/net/spnic/spnic_ethdev.c | 235 +++ 1 file changed, 235 insertions(+) diff --git a/drivers/net/spnic/spnic_ethdev.c b/drivers/net/spnic/spnic_ethdev.c index 50cca24258..cca03b5115 100644 --- a/drivers/net/spnic/spnic_ethdev.c +++ b/drivers/net/spnic/spnic_ethdev.c @@ -1258,6 +1258,233 @@ static int spnic_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu) return err; } + +/** + * Update the RSS hash key and RSS hash type. + * + * @param[in] dev + * Pointer to ethernet device structure. + * @param[in] rss_conf + * RSS configuration data. + * + * @retval zero: Success + * @retval non-zero: Failure + */ +static int spnic_rss_hash_update(struct rte_eth_dev *dev, +struct rte_eth_rss_conf *rss_conf) +{ + struct spnic_nic_dev *nic_dev = SPNIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev); + struct spnic_rss_type rss_type = {0}; + u64 rss_hf = rss_conf->rss_hf; + int err = 0; + + if (nic_dev->rss_state == SPNIC_RSS_DISABLE) { + if (rss_hf != 0) + return -EINVAL; + + PMD_DRV_LOG(INFO, "RSS is not enabled"); + return 0; + } + + if (rss_conf->rss_key_len > SPNIC_RSS_KEY_SIZE) { + PMD_DRV_LOG(ERR, "Invalid RSS key, rss_key_len: %d", + rss_conf->rss_key_len); + return -EINVAL; + } + + if (rss_conf->rss_key) { + err = spnic_rss_set_hash_key(nic_dev->hwdev, nic_dev->rss_key); + if (err) { + PMD_DRV_LOG(ERR, "Set RSS hash key failed"); + return err; + } + memcpy(nic_dev->rss_key, rss_conf->rss_key, + rss_conf->rss_key_len); + } + + rss_type.ipv4 = (rss_hf & (ETH_RSS_IPV4 | ETH_RSS_FRAG_IPV4 | + ETH_RSS_NONFRAG_IPV4_OTHER)) ? 1 : 0; + rss_type.tcp_ipv4 = (rss_hf & ETH_RSS_NONFRAG_IPV4_TCP) ? 1 : 0; + rss_type.ipv6 = (rss_hf & (ETH_RSS_IPV6 | ETH_RSS_FRAG_IPV6 | + ETH_RSS_NONFRAG_IPV6_OTHER)) ? 1 : 0; + rss_type.ipv6_ext = (rss_hf & ETH_RSS_IPV6_EX) ? 1 : 0; + rss_type.tcp_ipv6 = (rss_hf & ETH_RSS_NONFRAG_IPV6_TCP) ? 1 : 0; + rss_type.tcp_ipv6_ext = (rss_hf & ETH_RSS_IPV6_TCP_EX) ? 1 : 0; + rss_type.udp_ipv4 = (rss_hf & ETH_RSS_NONFRAG_IPV4_UDP) ? 1 : 0; + rss_type.udp_ipv6 = (rss_hf & ETH_RSS_NONFRAG_IPV6_UDP) ? 1 : 0; + + err = spnic_set_rss_type(nic_dev->hwdev, rss_type); + if (err) + PMD_DRV_LOG(ERR, "Set RSS type failed"); + + return err; +} + +/** + * Get the RSS hash configuration. + * + * @param[in] dev + * Pointer to ethernet device structure. + * @param[out] rss_conf + * RSS configuration data. + * + * @retval zero: Success + * @retval non-zero: Failure + */ +static int spnic_rss_conf_get(struct rte_eth_dev *dev, + struct rte_eth_rss_conf *rss_conf) +{ + struct spnic_nic_dev *nic_dev = SPNIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev); + struct spnic_rss_type rss_type = {0}; + int err; + + if (!rss_conf) + return -EINVAL; + + if (nic_dev->rss_state == SPNIC_RSS_DISABLE) { + rss_conf->rss_hf = 0; + PMD_DRV_LOG(INFO, "RSS is not enabled"); + return 0; + } + + if (rss_conf->rss_key && + rss_conf->rss_key_len >= SPNIC_RSS_KEY_SIZE) { + /* +* Get RSS key from driver to reduce the frequency of the MPU +* accessing the RSS memory. +*/ + rss_conf->rss_key_len = sizeof(nic_dev->rss_key); + memcpy(rss_conf->rss_key, nic_dev->rss_key, + rss_conf->rss_key_len); + } + + err = spnic_get_rss_type(nic_dev->hwdev, &rss_type); + if (err) + return err; + + rss_conf->rss_hf = 0; + rss_conf->rss_hf |= rss_type.ipv4 ? (ETH_RSS_IPV4 | + ETH_RSS_FRAG_IPV4 | ETH_RSS_NONFRAG_IPV4_OTHER) : 0; + rss_conf->rss_hf |= rss_type.tcp_ipv4 ? ETH_RSS_NONFRAG_IPV4_TCP : 0; + rss_conf->rss_hf |= rss_type.ipv6 ? (ETH_RSS_IPV6 | + ETH_RSS_FRAG_IPV6 | ETH_RSS_NONFRAG_IPV6_OTHER) : 0; + rss_conf->rss_hf |= rss_type.ipv6_ext ? ETH_RSS_IPV6_EX : 0; + rss_conf->rss_hf |= rss_type.tcp_ipv6 ? ETH_RSS_NONFRAG_IPV6_TCP : 0; + rss_conf->rss_hf |= rss_type.tcp_ipv6_ext ? ETH_RSS_IPV6_TCP_EX : 0; + rss_conf->rss_hf |= rss_type.udp_ipv4 ? ETH_RSS_NONFRAG_IPV4_UDP : 0; + rss_conf->rss_hf |= rss_type.udp_ipv6 ? ETH_RSS_NONFRAG_IPV6_UDP : 0; + + return 0; +} + +/** + * Get the RETA indirection table. + * + * @param[in] dev + * Pointer to ethernet device structure. + * @param[out] reta_conf + * Pointer to RETA configuration structure array. +
[PATCH 0/7] vhost: improve logging
This series aims at easing Vhost logs analysis, by prepending the Vhost-user socket path to all logs and to remove multi-line comments. Doing so, filtering Vhost-user ports logs is much easier. Maxime Coquelin (7): vhost: improve IOTLB logs vhost: improve vDPA registration failure log vhost: improve socket layer logs vhost: improve Vhost layer logs vhost: improve Vhost-user layer logs vhost: improve Virtio-net layer logs vhost: remove multi-line logs lib/vhost/iotlb.c | 26 +- lib/vhost/iotlb.h | 10 +- lib/vhost/socket.c | 131 - lib/vhost/vdpa.c | 4 +- lib/vhost/vhost.c | 106 --- lib/vhost/vhost_user.c | 653 - lib/vhost/virtio_net.c | 165 +-- 7 files changed, 518 insertions(+), 577 deletions(-) -- 2.31.1
[PATCH 2/7] vhost: improve vDPA registration failure log
This patchs adds name of the device failing vDPA registration. Signed-off-by: Maxime Coquelin --- lib/vhost/vdpa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/vhost/vdpa.c b/lib/vhost/vdpa.c index 09ad5d866e..6df2230a67 100644 --- a/lib/vhost/vdpa.c +++ b/lib/vhost/vdpa.c @@ -82,8 +82,8 @@ rte_vdpa_register_device(struct rte_device *rte_dev, !ops->get_protocol_features || !ops->dev_conf || !ops->dev_close || !ops->set_vring_state || !ops->set_features) { - VHOST_LOG_CONFIG(ERR, - "Some mandatory vDPA ops aren't implemented\n"); + VHOST_LOG_CONFIG(ERR, "(%s) Some mandatory vDPA ops aren't implemented\n", + rte_dev->name); return NULL; } -- 2.31.1
[PATCH 1/7] vhost: improve IOTLB logs
This patch adds IOTLB mempool name when logging debug or error messages, and also prepends the socket path. to all the logs. Signed-off-by: Maxime Coquelin --- lib/vhost/iotlb.c | 26 +++--- lib/vhost/iotlb.h | 10 +- lib/vhost/vhost.c | 2 +- lib/vhost/vhost_user.c | 2 +- 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/lib/vhost/iotlb.c b/lib/vhost/iotlb.c index 82bdb84526..e9e1ede7a4 100644 --- a/lib/vhost/iotlb.c +++ b/lib/vhost/iotlb.c @@ -62,7 +62,7 @@ vhost_user_iotlb_pending_miss(struct vhost_virtqueue *vq, uint64_t iova, } void -vhost_user_iotlb_pending_insert(struct vhost_virtqueue *vq, +vhost_user_iotlb_pending_insert(struct virtio_net *dev, struct vhost_virtqueue *vq, uint64_t iova, uint8_t perm) { struct vhost_iotlb_entry *node; @@ -70,14 +70,16 @@ vhost_user_iotlb_pending_insert(struct vhost_virtqueue *vq, ret = rte_mempool_get(vq->iotlb_pool, (void **)&node); if (ret) { - VHOST_LOG_CONFIG(DEBUG, "IOTLB pool empty, clear entries\n"); + VHOST_LOG_CONFIG(DEBUG, "(%s) IOTLB pool %s empty, clear entries\n", + dev->ifname, vq->iotlb_pool->name); if (!TAILQ_EMPTY(&vq->iotlb_pending_list)) vhost_user_iotlb_pending_remove_all(vq); else vhost_user_iotlb_cache_random_evict(vq); ret = rte_mempool_get(vq->iotlb_pool, (void **)&node); if (ret) { - VHOST_LOG_CONFIG(ERR, "IOTLB pool still empty, failure\n"); + VHOST_LOG_CONFIG(ERR, "(%s) IOTLB pool %s still empty, failure\n", + dev->ifname, vq->iotlb_pool->name); return; } } @@ -156,22 +158,25 @@ vhost_user_iotlb_cache_random_evict(struct vhost_virtqueue *vq) } void -vhost_user_iotlb_cache_insert(struct vhost_virtqueue *vq, uint64_t iova, - uint64_t uaddr, uint64_t size, uint8_t perm) +vhost_user_iotlb_cache_insert(struct virtio_net *dev, struct vhost_virtqueue *vq, + uint64_t iova, uint64_t uaddr, + uint64_t size, uint8_t perm) { struct vhost_iotlb_entry *node, *new_node; int ret; ret = rte_mempool_get(vq->iotlb_pool, (void **)&new_node); if (ret) { - VHOST_LOG_CONFIG(DEBUG, "IOTLB pool empty, clear entries\n"); + VHOST_LOG_CONFIG(DEBUG, "(%s) IOTLB pool %s empty, clear entries\n", + dev->ifname, vq->iotlb_pool->name); if (!TAILQ_EMPTY(&vq->iotlb_list)) vhost_user_iotlb_cache_random_evict(vq); else vhost_user_iotlb_pending_remove_all(vq); ret = rte_mempool_get(vq->iotlb_pool, (void **)&new_node); if (ret) { - VHOST_LOG_CONFIG(ERR, "IOTLB pool still empty, failure\n"); + VHOST_LOG_CONFIG(ERR, "(%s) IOTLB pool %s still empty, failure\n", + dev->ifname, vq->iotlb_pool->name); return; } } @@ -311,7 +316,7 @@ vhost_user_iotlb_init(struct virtio_net *dev, int vq_index) snprintf(pool_name, sizeof(pool_name), "iotlb_%u_%d_%d", getpid(), dev->vid, vq_index); - VHOST_LOG_CONFIG(DEBUG, "IOTLB cache name: %s\n", pool_name); + VHOST_LOG_CONFIG(DEBUG, "(%s) IOTLB cache name: %s\n", dev->ifname, pool_name); /* If already created, free it and recreate */ vq->iotlb_pool = rte_mempool_lookup(pool_name); @@ -324,9 +329,8 @@ vhost_user_iotlb_init(struct virtio_net *dev, int vq_index) RTE_MEMPOOL_F_NO_CACHE_ALIGN | RTE_MEMPOOL_F_SP_PUT); if (!vq->iotlb_pool) { - VHOST_LOG_CONFIG(ERR, - "Failed to create IOTLB cache pool (%s)\n", - pool_name); + VHOST_LOG_CONFIG(ERR, "(%s) Failed to create IOTLB cache pool (%s)\n", + dev->ifname, pool_name); return -1; } diff --git a/lib/vhost/iotlb.h b/lib/vhost/iotlb.h index b6e0757ad6..8d0ff7473b 100644 --- a/lib/vhost/iotlb.h +++ b/lib/vhost/iotlb.h @@ -33,17 +33,17 @@ vhost_user_iotlb_wr_unlock(struct vhost_virtqueue *vq) rte_rwlock_write_unlock(&vq->iotlb_lock); } -void vhost_user_iotlb_cache_insert(struct vhost_virtqueue *vq, uint64_t iova, - uint64_t uaddr, uint64_t size, - uint8_t perm); +void vhost_user_iotlb_cache_insert(struct virtio_net *dev, struct vhost_virtqueue *vq, + uint64_t iova, uint64_t u
[PATCH 3/7] vhost: improve socket layer logs
This patch adds the Vhost socket path whenever possible in order to make debugging possible when multiple Vhost devices are in use. Signed-off-by: Maxime Coquelin --- lib/vhost/socket.c | 129 ++--- 1 file changed, 51 insertions(+), 78 deletions(-) diff --git a/lib/vhost/socket.c b/lib/vhost/socket.c index 82963c1e6d..fd6b3a3ee4 100644 --- a/lib/vhost/socket.c +++ b/lib/vhost/socket.c @@ -124,12 +124,12 @@ read_fd_message(int sockfd, char *buf, int buflen, int *fds, int max_fds, ret = recvmsg(sockfd, &msgh, 0); if (ret <= 0) { if (ret) - VHOST_LOG_CONFIG(ERR, "recvmsg failed\n"); + VHOST_LOG_CONFIG(ERR, "recvmsg failed (fd %d)\n", sockfd); return ret; } if (msgh.msg_flags & (MSG_TRUNC | MSG_CTRUNC)) { - VHOST_LOG_CONFIG(ERR, "truncated msg\n"); + VHOST_LOG_CONFIG(ERR, "truncated msg (fd %d)\n", sockfd); return -1; } @@ -192,7 +192,7 @@ send_fd_message(int sockfd, char *buf, int buflen, int *fds, int fd_num) } while (ret < 0 && errno == EINTR); if (ret < 0) { - VHOST_LOG_CONFIG(ERR, "sendmsg error\n"); + VHOST_LOG_CONFIG(ERR, "sendmsg error (fd %d)\n", sockfd); return ret; } @@ -243,14 +243,14 @@ vhost_user_add_connection(int fd, struct vhost_user_socket *vsocket) dev->async_copy = 1; } - VHOST_LOG_CONFIG(INFO, "new device, handle is %d, path is %s\n", vid, vsocket->path); + VHOST_LOG_CONFIG(INFO, "(%s) new device, handle is %d\n", vsocket->path, vid); if (vsocket->notify_ops->new_connection) { ret = vsocket->notify_ops->new_connection(vid); if (ret < 0) { VHOST_LOG_CONFIG(ERR, - "failed to add vhost user connection with fd %d\n", - fd); + "(%s) failed to add vhost user connection with fd %d\n", + vsocket->path, fd); goto err_cleanup; } } @@ -261,9 +261,8 @@ vhost_user_add_connection(int fd, struct vhost_user_socket *vsocket) ret = fdset_add(&vhost_user.fdset, fd, vhost_user_read_cb, NULL, conn); if (ret < 0) { - VHOST_LOG_CONFIG(ERR, - "failed to add fd %d into vhost server fdset\n", - fd); + VHOST_LOG_CONFIG(ERR, "(%s) failed to add fd %d into vhost server fdset\n", + vsocket->path, fd); if (vsocket->notify_ops->destroy_connection) vsocket->notify_ops->destroy_connection(conn->vid); @@ -295,7 +294,8 @@ vhost_user_server_new_connection(int fd, void *dat, int *remove __rte_unused) if (fd < 0) return; - VHOST_LOG_CONFIG(INFO, "new vhost user connection is %d\n", fd); + VHOST_LOG_CONFIG(INFO, "(%s) new vhost user connection is %d\n", + vsocket->path, fd); vhost_user_add_connection(fd, vsocket); } @@ -343,13 +343,13 @@ create_unix_socket(struct vhost_user_socket *vsocket) fd = socket(AF_UNIX, SOCK_STREAM, 0); if (fd < 0) return -1; - VHOST_LOG_CONFIG(INFO, "vhost-user %s: socket created, fd: %d\n", - vsocket->is_server ? "server" : "client", fd); + VHOST_LOG_CONFIG(INFO, "(%s) vhost-user %s: socket created, fd: %d\n", + vsocket->path, vsocket->is_server ? "server" : "client", fd); if (!vsocket->is_server && fcntl(fd, F_SETFL, O_NONBLOCK)) { VHOST_LOG_CONFIG(ERR, - "vhost-user: can't set nonblocking mode for socket, fd: " - "%d (%s)\n", fd, strerror(errno)); + "(%s) vhost-user: can't set nonblocking mode for socket, fd: %d (%s)\n", + vsocket->path, fd, strerror(errno)); close(fd); return -1; } @@ -382,12 +382,11 @@ vhost_user_start_server(struct vhost_user_socket *vsocket) */ ret = bind(fd, (struct sockaddr *)&vsocket->un, sizeof(vsocket->un)); if (ret < 0) { - VHOST_LOG_CONFIG(ERR, - "failed to bind to %s: %s; remove it and try again\n", + VHOST_LOG_CONFIG(ERR, "(%s) failed to bind: %s; remove it and try again\n", path, strerror(errno)); goto err; } - VHOST_LOG_CONFIG(INFO, "bind to %s\n", path); + VHOST_LOG_CONFIG(INFO, "(%s) binding succeeded\n", path); ret = listen(fd, MAX_VIRTIO_BACKLOG); if (ret < 0) @@ -397,8 +396,8 @@ vhost_user_start_server(struct vhost_user_socket *vsocket) NULL, vsocket); if (ret
[PATCH 4/7] vhost: improve Vhost layer logs
This patch prepends Vhost logs with the Vhost-user socket patch when available to ease filtering logs for a given port. Signed-off-by: Maxime Coquelin --- lib/vhost/vhost.c | 104 +++--- 1 file changed, 51 insertions(+), 53 deletions(-) diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c index e52d7f7bb6..dac0915ac0 100644 --- a/lib/vhost/vhost.c +++ b/lib/vhost/vhost.c @@ -58,9 +58,8 @@ __vhost_iova_to_vva(struct virtio_net *dev, struct vhost_virtqueue *vq, vhost_user_iotlb_pending_insert(dev, vq, iova, perm); if (vhost_user_iotlb_miss(dev, iova, perm)) { - VHOST_LOG_CONFIG(ERR, - "IOTLB miss req failed for IOVA 0x%" PRIx64 "\n", - iova); + VHOST_LOG_DATA(ERR, "(%s) IOTLB miss req failed for IOVA 0x%" PRIx64 "\n", + dev->ifname, iova); vhost_user_iotlb_pending_remove(vq, iova, 1, perm); } @@ -126,8 +125,8 @@ __vhost_log_write_iova(struct virtio_net *dev, struct vhost_virtqueue *vq, hva = __vhost_iova_to_vva(dev, vq, iova, &map_len, VHOST_ACCESS_RW); if (map_len != len) { VHOST_LOG_DATA(ERR, - "Failed to write log for IOVA 0x%" PRIx64 ". No IOTLB entry found\n", - iova); + "(%s) failed to write log for IOVA 0x%" PRIx64 ". No IOTLB entry found\n", + dev->ifname, iova); return; } @@ -243,8 +242,8 @@ __vhost_log_cache_write_iova(struct virtio_net *dev, struct vhost_virtqueue *vq, hva = __vhost_iova_to_vva(dev, vq, iova, &map_len, VHOST_ACCESS_RW); if (map_len != len) { VHOST_LOG_DATA(ERR, - "Failed to write log for IOVA 0x%" PRIx64 ". No IOTLB entry found\n", - iova); + "(%s) failed to write log for IOVA 0x%" PRIx64 ". No IOTLB entry found\n", + dev->ifname, iova); return; } @@ -422,9 +421,9 @@ translate_log_addr(struct virtio_net *dev, struct vhost_virtqueue *vq, gpa = hva_to_gpa(dev, hva, exp_size); if (!gpa) { VHOST_LOG_CONFIG(ERR, - "VQ: Failed to find GPA for log_addr: 0x%" + "(%s) failed to find GPA for log_addr: 0x%" PRIx64 " hva: 0x%" PRIx64 "\n", - log_addr, hva); + dev->ifname, log_addr, hva); return 0; } return gpa; @@ -551,16 +550,15 @@ init_vring_queue(struct virtio_net *dev, uint32_t vring_idx) int numa_node = SOCKET_ID_ANY; if (vring_idx >= VHOST_MAX_VRING) { - VHOST_LOG_CONFIG(ERR, - "Failed not init vring, out of bound (%d)\n", - vring_idx); + VHOST_LOG_CONFIG(ERR, "(%s) failed not init vring, out of bound (%d)\n", + dev->ifname, vring_idx); return; } vq = dev->virtqueue[vring_idx]; if (!vq) { - VHOST_LOG_CONFIG(ERR, "Virtqueue not allocated (%d)\n", - vring_idx); + VHOST_LOG_CONFIG(ERR, "(%s) virtqueue not allocated (%d)\n", + dev->ifname, vring_idx); return; } @@ -572,8 +570,8 @@ init_vring_queue(struct virtio_net *dev, uint32_t vring_idx) #ifdef RTE_LIBRTE_VHOST_NUMA if (get_mempolicy(&numa_node, NULL, 0, vq, MPOL_F_NODE | MPOL_F_ADDR)) { - VHOST_LOG_CONFIG(ERR, "(%d) failed to query numa node: %s\n", - dev->vid, rte_strerror(errno)); + VHOST_LOG_CONFIG(ERR, "(%s) failed to query numa node: %s\n", + dev->ifname, rte_strerror(errno)); numa_node = SOCKET_ID_ANY; } #endif @@ -590,15 +588,15 @@ reset_vring_queue(struct virtio_net *dev, uint32_t vring_idx) if (vring_idx >= VHOST_MAX_VRING) { VHOST_LOG_CONFIG(ERR, - "Failed not init vring, out of bound (%d)\n", - vring_idx); + "(%s) failed to reset vring, out of bound (%d)\n", + dev->ifname, vring_idx); return; } vq = dev->virtqueue[vring_idx]; if (!vq) { - VHOST_LOG_CONFIG(ERR, "Virtqueue not allocated (%d)\n", - vring_idx); + VHOST_LOG_CONFIG(ERR, "(%s) failed to reset vring, virtqueue not allocated (%d)\n", + dev->ifname, vring_idx); return; } @@
[PATCH 7/7] vhost: remove multi-line logs
This patch replaces multi-lines logs in multiple single- line logs in order to ease logs filtering based on their socket path. Signed-off-by: Maxime Coquelin --- lib/vhost/socket.c | 10 ++-- lib/vhost/vhost.c | 8 ++-- lib/vhost/vhost_user.c | 106 +++-- 3 files changed, 60 insertions(+), 64 deletions(-) diff --git a/lib/vhost/socket.c b/lib/vhost/socket.c index fd6b3a3ee4..9c31498a87 100644 --- a/lib/vhost/socket.c +++ b/lib/vhost/socket.c @@ -865,8 +865,8 @@ rte_vhost_driver_register(const char *path, uint64_t flags) if (vsocket->async_copy && (flags & (RTE_VHOST_USER_IOMMU_SUPPORT | RTE_VHOST_USER_POSTCOPY_SUPPORT))) { - VHOST_LOG_CONFIG(ERR, "(%s) enabling async copy and IOMMU " - "or post-copy feature simultaneously is not supported\n", path); + VHOST_LOG_CONFIG(ERR, "(%s) async copy with IOMMU or post-copy not supported\n", + path); goto out_mutex; } @@ -905,8 +905,10 @@ rte_vhost_driver_register(const char *path, uint64_t flags) (1ULL << VIRTIO_NET_F_HOST_TSO6) | (1ULL << VIRTIO_NET_F_HOST_UFO); - VHOST_LOG_CONFIG(INFO, "(%s) Linear buffers requested without external buffers, " - "disabling host segmentation offloading support\n", path); + VHOST_LOG_CONFIG(INFO, "(%s) Linear buffers requested without external buffers,\n", + path); + VHOST_LOG_CONFIG(INFO, "(%s) disabling host segmentation offloading support\n", + path); vsocket->supported_features &= ~seg_offload_features; vsocket->features &= ~seg_offload_features; } diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c index dac0915ac0..857cdc5ac1 100644 --- a/lib/vhost/vhost.c +++ b/lib/vhost/vhost.c @@ -1786,8 +1786,8 @@ rte_vhost_async_channel_unregister(int vid, uint16_t queue_id) } if (vq->async->pkts_inflight_n) { - VHOST_LOG_CONFIG(ERR, "(%s) failed to unregister async channel. " - "async inflight packets must be completed before unregistration.\n", + VHOST_LOG_CONFIG(ERR, "(%s) failed to unregister async channel.\n", dev->ifname); + VHOST_LOG_CONFIG(ERR, "(%s) inflight packets must be completed before unregistration.\n", dev->ifname); ret = -1; goto out; @@ -1821,8 +1821,8 @@ rte_vhost_async_channel_unregister_thread_unsafe(int vid, uint16_t queue_id) return 0; if (vq->async->pkts_inflight_n) { - VHOST_LOG_CONFIG(ERR, "(%s) failed to unregister async channel. " - "async inflight packets must be completed before unregistration.\n", + VHOST_LOG_CONFIG(ERR, "(%s) failed to unregister async channel.\n", dev->ifname); + VHOST_LOG_CONFIG(ERR, "(%s) inflight packets must be completed before unregistration.\n", dev->ifname); return -1; } diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c index 923d619213..c34819f371 100644 --- a/lib/vhost/vhost_user.c +++ b/lib/vhost/vhost_user.c @@ -872,13 +872,13 @@ translate_ring_addresses(struct virtio_net *dev, int vq_index) } if (vq->last_used_idx != vq->used->idx) { - VHOST_LOG_CONFIG(WARNING, - "(%s) last_used_idx (%u) and vq->used->idx (%u) mismatches; " - "some packets maybe resent for Tx and dropped for Rx\n", + VHOST_LOG_CONFIG(WARNING, "(%s) last_used_idx (%u) and vq->used->idx (%u) mismatches;\n", dev->ifname, vq->last_used_idx, vq->used->idx); vq->last_used_idx = vq->used->idx; vq->last_avail_idx = vq->used->idx; + VHOST_LOG_CONFIG(WARNING, "(%s) some packets maybe resent for Tx and dropped for Rx\n", + dev->ifname); } vq->access_ok = true; @@ -1066,15 +1066,14 @@ dump_guest_pages(struct virtio_net *dev) for (i = 0; i < dev->nr_guest_pages; i++) { page = &dev->guest_pages[i]; - VHOST_LOG_CONFIG(INFO, - "(%s) guest physical page region %u\n" - "\t guest_phys_addr: %" PRIx64 "\n" - "\t host_phys_addr : %" PRIx64 "\n" - "\t size : %" PRIx64 "\n", - dev->ifname, i, - page->guest_phys_addr, - page->host_phys_addr, - page->size); + VHOST_LOG_CONFIG(INFO, "(%s) guest physical page region %u\n", + dev->i
[PATCH 5/7] vhost: improve Vhost-user layer logs
This patch adds the Vhost-user socket path to Vhost-user layer logs in order to ease logs filtering. Signed-off-by: Maxime Coquelin --- lib/vhost/vhost_user.c | 573 - 1 file changed, 275 insertions(+), 298 deletions(-) diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c index 67934be12c..923d619213 100644 --- a/lib/vhost/vhost_user.c +++ b/lib/vhost/vhost_user.c @@ -94,7 +94,7 @@ static const char *vhost_message_str[VHOST_USER_MAX] = { }; static int send_vhost_reply(int sockfd, struct VhostUserMsg *msg); -static int read_vhost_message(int sockfd, struct VhostUserMsg *msg); +static int read_vhost_message(struct virtio_net *dev, int sockfd, struct VhostUserMsg *msg); static void close_msg_fds(struct VhostUserMsg *msg) @@ -117,14 +117,13 @@ close_msg_fds(struct VhostUserMsg *msg) * close all FDs and return an error if this is not the case. */ static int -validate_msg_fds(struct VhostUserMsg *msg, int expected_fds) +validate_msg_fds(struct virtio_net *dev, struct VhostUserMsg *msg, int expected_fds) { if (msg->fd_num == expected_fds) return 0; - VHOST_LOG_CONFIG(ERR, - " Expect %d FDs for request %s, received %d\n", - expected_fds, + VHOST_LOG_CONFIG(ERR, "(%s) expect %d FDs for request %s, received %d\n", + dev->ifname, expected_fds, vhost_message_str[msg->request.master], msg->fd_num); @@ -144,7 +143,7 @@ get_blk_size(int fd) } static int -async_dma_map(struct rte_vhost_mem_region *region, bool do_map) +async_dma_map(struct virtio_net *dev, struct rte_vhost_mem_region *region, bool do_map) { uint64_t host_iova; int ret = 0; @@ -172,7 +171,7 @@ async_dma_map(struct rte_vhost_mem_region *region, bool do_map) if (rte_errno == ENODEV || rte_errno == ENOTSUP) return 0; - VHOST_LOG_CONFIG(ERR, "DMA engine map failed\n"); + VHOST_LOG_CONFIG(ERR, "(%s) DMA engine map failed\n", dev->ifname); /* DMA mapping errors won't stop VHST_USER_SET_MEM_TABLE. */ return 0; } @@ -188,7 +187,7 @@ async_dma_map(struct rte_vhost_mem_region *region, bool do_map) if (rte_errno == EINVAL) return 0; - VHOST_LOG_CONFIG(ERR, "DMA engine unmap failed\n"); + VHOST_LOG_CONFIG(ERR, "(%s) DMA engine unmap failed\n", dev->ifname); return ret; } } @@ -209,7 +208,7 @@ free_mem_region(struct virtio_net *dev) reg = &dev->mem->regions[i]; if (reg->host_user_addr) { if (dev->async_copy && rte_vfio_is_enabled("vfio")) - async_dma_map(reg, false); + async_dma_map(dev, reg, false); munmap(reg->mmap_addr, reg->mmap_size); close(reg->fd); @@ -287,11 +286,13 @@ vhost_user_notify_queue_state(struct virtio_net *dev, uint16_t index, * the device hasn't been initialised. */ static int -vhost_user_set_owner(struct virtio_net **pdev __rte_unused, +vhost_user_set_owner(struct virtio_net **pdev, struct VhostUserMsg *msg, int main_fd __rte_unused) { - if (validate_msg_fds(msg, 0) != 0) + struct virtio_net *dev = *pdev; + + if (validate_msg_fds(dev, msg, 0) != 0) return RTE_VHOST_MSG_RESULT_ERR; return RTE_VHOST_MSG_RESULT_OK; @@ -304,7 +305,7 @@ vhost_user_reset_owner(struct virtio_net **pdev, { struct virtio_net *dev = *pdev; - if (validate_msg_fds(msg, 0) != 0) + if (validate_msg_fds(dev, msg, 0) != 0) return RTE_VHOST_MSG_RESULT_ERR; vhost_destroy_device_notify(dev); @@ -324,7 +325,7 @@ vhost_user_get_features(struct virtio_net **pdev, struct VhostUserMsg *msg, struct virtio_net *dev = *pdev; uint64_t features = 0; - if (validate_msg_fds(msg, 0) != 0) + if (validate_msg_fds(dev, msg, 0) != 0) return RTE_VHOST_MSG_RESULT_ERR; rte_vhost_driver_get_features(dev->ifname, &features); @@ -346,7 +347,7 @@ vhost_user_get_queue_num(struct virtio_net **pdev, struct VhostUserMsg *msg, struct virtio_net *dev = *pdev; uint32_t queue_num = 0; - if (validate_msg_fds(msg, 0) != 0) + if (validate_msg_fds(dev, msg, 0) != 0) return RTE_VHOST_MSG_RESULT_ERR; rte_vhost_driver_get_queue_num(dev->ifname, &queue_num); @@ -370,14 +371,13 @@ vhost_user_set_features(struct virtio_net **pdev, struct VhostUserMsg *msg, uint64_t vhost_features = 0; struct rte_vdpa_device *vdpa_dev; - if (validate_msg_fds(msg, 0) != 0) + if
[PATCH 6/7] vhost: improve Virtio-net layer logs
This patch standardizes logging done in Virtio-net, so that the Vhost-user socket path is always prepended to the logs. It will ease log analysis when multiple Vhost-user ports are in use. Signed-off-by: Maxime Coquelin --- lib/vhost/virtio_net.c | 165 - 1 file changed, 79 insertions(+), 86 deletions(-) diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c index b3d954aab4..f19713137c 100644 --- a/lib/vhost/virtio_net.c +++ b/lib/vhost/virtio_net.c @@ -792,12 +792,12 @@ copy_vnet_hdr_to_desc(struct virtio_net *dev, struct vhost_virtqueue *vq, } static __rte_always_inline int -async_iter_initialize(struct vhost_async *async) +async_iter_initialize(struct virtio_net *dev, struct vhost_async *async) { struct rte_vhost_iov_iter *iter; if (unlikely(async->iovec_idx >= VHOST_MAX_ASYNC_VEC)) { - VHOST_LOG_DATA(ERR, "no more async iovec available\n"); + VHOST_LOG_DATA(ERR, "(%s) no more async iovec available\n", dev->ifname); return -1; } @@ -809,7 +809,8 @@ async_iter_initialize(struct vhost_async *async) } static __rte_always_inline int -async_iter_add_iovec(struct vhost_async *async, void *src, void *dst, size_t len) +async_iter_add_iovec(struct virtio_net *dev, struct vhost_async *async, + void *src, void *dst, size_t len) { struct rte_vhost_iov_iter *iter; struct rte_vhost_iovec *iovec; @@ -818,7 +819,7 @@ async_iter_add_iovec(struct vhost_async *async, void *src, void *dst, size_t len static bool vhost_max_async_vec_log; if (!vhost_max_async_vec_log) { - VHOST_LOG_DATA(ERR, "no more async iovec available\n"); + VHOST_LOG_DATA(ERR, "(%s) no more async iovec available\n", dev->ifname); vhost_max_async_vec_log = true; } @@ -876,11 +877,11 @@ async_mbuf_to_desc_seg(struct virtio_net *dev, struct vhost_virtqueue *vq, hpa = (void *)(uintptr_t)gpa_to_first_hpa(dev, buf_iova + buf_offset, cpy_len, &mapped_len); if (unlikely(!hpa)) { - VHOST_LOG_DATA(ERR, "(%d) %s: failed to get hpa.\n", dev->vid, __func__); + VHOST_LOG_DATA(ERR, "(%s) %s: failed to get hpa.\n", dev->ifname, __func__); return -1; } - if (unlikely(async_iter_add_iovec(async, + if (unlikely(async_iter_add_iovec(dev, async, (void *)(uintptr_t)rte_pktmbuf_iova_offset(m, mbuf_offset), hpa, (size_t)mapped_len))) @@ -951,8 +952,8 @@ mbuf_to_desc(struct virtio_net *dev, struct vhost_virtqueue *vq, } else hdr = (struct virtio_net_hdr_mrg_rxbuf *)(uintptr_t)hdr_addr; - VHOST_LOG_DATA(DEBUG, "(%d) RX: num merge buffers %d\n", - dev->vid, num_buffers); + VHOST_LOG_DATA(DEBUG, "(%s) RX: num merge buffers %d\n", + dev->ifname, num_buffers); if (unlikely(buf_len < dev->vhost_hlen)) { buf_offset = dev->vhost_hlen - buf_len; @@ -970,7 +971,7 @@ mbuf_to_desc(struct virtio_net *dev, struct vhost_virtqueue *vq, mbuf_offset = 0; if (is_async) { - if (async_iter_initialize(async)) + if (async_iter_initialize(dev, async)) return -1; } @@ -1133,14 +1134,14 @@ virtio_dev_rx_split(struct virtio_net *dev, struct vhost_virtqueue *vq, pkt_len, buf_vec, &num_buffers, avail_head, &nr_vec) < 0)) { VHOST_LOG_DATA(DEBUG, - "(%d) failed to get enough desc from vring\n", - dev->vid); + "(%s) failed to get enough desc from vring\n", + dev->ifname); vq->shadow_used_idx -= num_buffers; break; } - VHOST_LOG_DATA(DEBUG, "(%d) current index %d | end index %d\n", - dev->vid, vq->last_avail_idx, + VHOST_LOG_DATA(DEBUG, "(%s) current index %d | end index %d\n", + dev->ifname, vq->last_avail_idx, vq->last_avail_idx + num_buffers); if (mbuf_to_desc(dev, vq, pkts[pkt_idx], buf_vec, nr_vec, @@ -1287,14 +1288,13 @@ virtio_dev_rx_single_packed(struct virtio_net *dev, if (unlikely(vhost_enqueue_single_packed(dev, vq, pkt, buf_vec, &nr_descs) < 0)) { - VHOST_LOG_DATA(DEBUG, - "(%d) failed to get enough desc
Minutes of Technical Board Meeting, 2021-12-15
Members Attending: 12/12 - Aaron Conole - Bruce Richardson - Ferruh Yigit - Hemant Agrawal - Honnappa Nagarahalli - Jerin Jacob - Kevin Traynor - Konstantin Ananyev - Maxime Coquelin - Olivier Matz - Stephen Hemminger - Thomas Monjalon (Chair) NOTE: The Technical Board meetings take place every second Wednesday on https://meet.jit.si/DPDK at 3 pm UTC. Meetings are public, and DPDK community members are welcome to attend. Agenda and minutes can be found at http://core.dpdk.org/techboard/minutes NOTE: Next meeting will be on Wednesday 2022-01-12 @3pm UTC, and will be chaired by Aaron. 1/ marketing decisions The marketing meetings are cancelled because of a lack of attendees. It is agreed that the Governing Board becomes responsible to plan and execute marketing activity. The Technical Board may be requested to bring ideas and opinions on some topics, like event dates, through emails or dedicated meetings. 2/ technical writer The Governing Board has allocated a budget for a technical writer, and is looking for the Technical Board to help with the requirements. The requirements written by Bruce last year are shared again. Jim is checking how to make progress. 3/ community lab Aaron will present the status for the year 2021 in the next meeting. Then the Technical Board will discuss the plan for the year 2022. 4/ Kubernetes blog post In order to write a blog post about the DPDK solutions for containers and Kubernetes integration, we need participation of experts for the various technologies and use cases. 5/ security process It may be interesting to encourage active research of vulnerabilities. The two alternatives discussed are a bug bounty or a hackathon taking place before the userspace event. Jim will investigate the legal framework with the Linux Foundation. Then we could ask the Governing Board to evaluate a budget. 6/ DTS There was a community meeting on Tuesday 14 December. Owen explained the status of the work done in the DTS work group. Questions and discussions helped to better understand the challenge. Volunteers are welcome to rework DTS for a clean integration in DPDK.
[PATCH] net/mlx5: fix RSS expansion with explicit next protocol
The PMD RSS expansion scheme by default compiles flow rules for all flow item types that may branch out from a stub supplied by application. For example, ETH can lead to VLAN, IPv4 or IPv6. IPv4 can lead to UDP, TCP, IPv4 or IPv6. If application explicitly specified next protocol type, expansion must use that option only and not create flows with other protocol types. The PMD ignored explicit next protocol values in GRE and VXLAN-GPE. The patch updates RSS expansion for GRE and VXLAN-GPE with explicit next protocol settings. Fixes: c7870bfe09dc ("ethdev: move RSS expansion code to mlx5 driver") Cc: sta...@dpdk.org Signed-off-by: Gregory Etelson Acked-by: Matan Azrad --- drivers/net/mlx5/mlx5_flow.c | 209 ++- 1 file changed, 108 insertions(+), 101 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index f34e4b88aa..4e2ff16e30 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -164,128 +164,135 @@ mlx5_flow_is_rss_expandable_item(const struct rte_flow_item *item) return false; } +/** + * Network Service Header (NSH) and its next protocol values + * are described in RFC-8393. + */ +static enum rte_flow_item_type +mlx5_nsh_proto_to_item_type(uint8_t proto_spec, uint8_t proto_mask) +{ + enum rte_flow_item_type type; + + switch (proto_mask & proto_spec) { + case RTE_VXLAN_GPE_TYPE_IPV4: + type = RTE_FLOW_ITEM_TYPE_IPV4; + break; + case RTE_VXLAN_GPE_TYPE_IPV6: + type = RTE_VXLAN_GPE_TYPE_IPV6; + break; + case RTE_VXLAN_GPE_TYPE_ETH: + type = RTE_FLOW_ITEM_TYPE_ETH; + break; + default: + type = RTE_FLOW_ITEM_TYPE_END; + } + return type; +} + +static enum rte_flow_item_type +mlx5_inet_proto_to_item_type(uint8_t proto_spec, uint8_t proto_mask) +{ + enum rte_flow_item_type type; + + switch (proto_mask & proto_spec) { + case IPPROTO_UDP: + type = RTE_FLOW_ITEM_TYPE_UDP; + break; + case IPPROTO_TCP: + type = RTE_FLOW_ITEM_TYPE_TCP; + break; + case IPPROTO_IP: + type = RTE_FLOW_ITEM_TYPE_IPV4; + break; + case IPPROTO_IPV6: + type = RTE_FLOW_ITEM_TYPE_IPV6; + break; + default: + type = RTE_FLOW_ITEM_TYPE_END; + } + return type; +} + +static enum rte_flow_item_type +mlx5_ethertype_to_item_type(rte_be16_t type_spec, + rte_be16_t type_mask, bool is_tunnel) +{ + enum rte_flow_item_type type; + + switch (rte_be_to_cpu_16(type_spec & type_mask)) { + case RTE_ETHER_TYPE_TEB: + type = is_tunnel ? + RTE_FLOW_ITEM_TYPE_ETH : RTE_FLOW_ITEM_TYPE_END; + break; + case RTE_ETHER_TYPE_VLAN: + type = !is_tunnel ? + RTE_FLOW_ITEM_TYPE_VLAN : RTE_FLOW_ITEM_TYPE_END; + break; + case RTE_ETHER_TYPE_IPV4: + type = RTE_FLOW_ITEM_TYPE_IPV4; + break; + case RTE_ETHER_TYPE_IPV6: + type = RTE_FLOW_ITEM_TYPE_IPV6; + break; + default: + type = RTE_FLOW_ITEM_TYPE_END; + } + return type; +} + static enum rte_flow_item_type mlx5_flow_expand_rss_item_complete(const struct rte_flow_item *item) { - enum rte_flow_item_type ret = RTE_FLOW_ITEM_TYPE_VOID; - uint16_t ether_type = 0; - uint16_t ether_type_m; - uint8_t ip_next_proto = 0; - uint8_t ip_next_proto_m; +#define MLX5_XSET_ITEM_MASK_SPEC(type, fld) \ + do { \ + const void *m = item->mask; \ + const void *s = item->spec; \ + mask = m ? \ + ((const struct rte_flow_item_##type *)m)->fld : \ + rte_flow_item_##type##_mask.fld; \ + spec = ((const struct rte_flow_item_##type *)s)->fld;\ + } while (0) + + enum rte_flow_item_type ret; + uint16_t spec, mask; if (item == NULL || item->spec == NULL) - return ret; + return RTE_FLOW_ITEM_TYPE_VOID; switch (item->type) { case RTE_FLOW_ITEM_TYPE_ETH: - if (item->mask) - ether_type_m = ((const struct rte_flow_item_eth *) - (item->mask))->type; - else - ether_type_m = rte_flow_item_eth_mask.type; - if (ether_type_m != RTE_BE16(0x)) - break; - ether_type = ((const struct rte_flow_item_eth *) -
[PATCH] net/mlx5: fix GRE protocol type translation for VERB API
When application creates several flows to match on GRE tunnel without explicitly specifying GRE protocol type value in flow rules, PMD will translate that to zero mask. RDMA-CORE cannot distinguish between different inner flow types and produces identical matchers for each zero mask. The patch extracts inner header type from flow rule and forces it in GRE protocol type, if application did not specify any. Cc: sta...@dpdk.org Fixes: 84c406e74524 ("net/mlx5: add flow translate function") Signed-off-by: Gregory Etelson Acked-by: Matan Azrad --- drivers/net/mlx5/mlx5_flow.h | 14 +++ drivers/net/mlx5/mlx5_flow_dv.c| 14 --- drivers/net/mlx5/mlx5_flow_verbs.c | 37 -- 3 files changed, 39 insertions(+), 26 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 1f54649c69..f80d9454d5 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -1450,6 +1450,20 @@ flow_aso_ct_get_by_idx(struct rte_eth_dev *dev, uint32_t own_idx) return ct; } +static inline uint16_t +mlx5_translate_tunnel_etypes(uint64_t pattern_flags) +{ + if (pattern_flags & MLX5_FLOW_LAYER_INNER_L2) + return RTE_ETHER_TYPE_TEB; + else if (pattern_flags & MLX5_FLOW_LAYER_INNER_L3_IPV4) + return RTE_ETHER_TYPE_IPV4; + else if (pattern_flags & MLX5_FLOW_LAYER_INNER_L3_IPV6) + return RTE_ETHER_TYPE_IPV6; + else if (pattern_flags & MLX5_FLOW_LAYER_MPLS) + return RTE_ETHER_TYPE_MPLS; + return 0; +} + int mlx5_flow_group_to_table(struct rte_eth_dev *dev, const struct mlx5_flow_tunnel *tunnel, uint32_t group, uint32_t *table, diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 1c6cae8779..5bb60dd73c 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -93,20 +93,6 @@ static int flow_dv_jump_tbl_resource_release(struct rte_eth_dev *dev, uint32_t rix_jump); -static inline uint16_t -mlx5_translate_tunnel_etypes(uint64_t pattern_flags) -{ - if (pattern_flags & MLX5_FLOW_LAYER_INNER_L2) - return RTE_ETHER_TYPE_TEB; - else if (pattern_flags & MLX5_FLOW_LAYER_INNER_L3_IPV4) - return RTE_ETHER_TYPE_IPV4; - else if (pattern_flags & MLX5_FLOW_LAYER_INNER_L3_IPV6) - return RTE_ETHER_TYPE_IPV6; - else if (pattern_flags & MLX5_FLOW_LAYER_MPLS) - return RTE_ETHER_TYPE_MPLS; - return 0; -} - static int16_t flow_dv_get_esw_manager_vport_id(struct rte_eth_dev *dev) { diff --git a/drivers/net/mlx5/mlx5_flow_verbs.c b/drivers/net/mlx5/mlx5_flow_verbs.c index 29cd694752..192a00d4fd 100644 --- a/drivers/net/mlx5/mlx5_flow_verbs.c +++ b/drivers/net/mlx5/mlx5_flow_verbs.c @@ -907,6 +907,7 @@ flow_verbs_translate_item_gre(struct mlx5_flow *dev_flow, .size = size, }; #else + static const struct rte_flow_item_gre empty_gre = {0,}; const struct rte_flow_item_gre *spec = item->spec; const struct rte_flow_item_gre *mask = item->mask; unsigned int size = sizeof(struct ibv_flow_spec_gre); @@ -915,17 +916,29 @@ flow_verbs_translate_item_gre(struct mlx5_flow *dev_flow, .size = size, }; - if (!mask) - mask = &rte_flow_item_gre_mask; - if (spec) { - tunnel.val.c_ks_res0_ver = spec->c_rsvd0_ver; - tunnel.val.protocol = spec->protocol; - tunnel.mask.c_ks_res0_ver = mask->c_rsvd0_ver; - tunnel.mask.protocol = mask->protocol; - /* Remove unwanted bits from values. */ - tunnel.val.c_ks_res0_ver &= tunnel.mask.c_ks_res0_ver; + if (!spec) { + spec = &empty_gre; + mask = &empty_gre; + } else { + if (!mask) + mask = &rte_flow_item_gre_mask; + } + tunnel.val.c_ks_res0_ver = spec->c_rsvd0_ver; + tunnel.val.protocol = spec->protocol; + tunnel.mask.c_ks_res0_ver = mask->c_rsvd0_ver; + tunnel.mask.protocol = mask->protocol; + /* Remove unwanted bits from values. */ + tunnel.val.c_ks_res0_ver &= tunnel.mask.c_ks_res0_ver; + tunnel.val.key &= tunnel.mask.key; + if (tunnel.mask.protocol) { tunnel.val.protocol &= tunnel.mask.protocol; - tunnel.val.key &= tunnel.mask.key; + } else { + tunnel.val.protocol = mlx5_translate_tunnel_etypes(item_flags); + if (tunnel.val.protocol) { + tunnel.mask.protocol = 0x; + tunnel.val.protocol = + rte_cpu_to_be_16(tunnel.val.protocol); + } } #endif if (item_flags & MLX5_FLOW_LAYER_OUTER_L3_IPV4) @@ -1803,8 +1816,6 @@ flow_verbs_tra
RE: 20.11.4 patches review and test
Hi, > -Original Message- > From: Xueming(Steven) Li > Sent: Monday, December 6, 2021 6:15 PM > To: sta...@dpdk.org > Cc: Xueming(Steven) Li ; dev@dpdk.org; Abhishek > Marathe ; Ali Alnubani > ; benjamin.wal...@intel.com; David Christensen > ; hariprasad.govindhara...@intel.com; Hemant > Agrawal ; Ian Stokes ; > Jerin Jacob ; John McNamara > ; Ju-Hyoung Lee ; > Kevin Traynor ; Luca Boccassi ; > Pei Zhang ; qian.q...@intel.com; Raslan Darawsheh > ; NBU-Contact-Thomas Monjalon (EXTERNAL) > ; yuan.p...@intel.com; zhaoyan.c...@intel.com > Subject: 20.11.4 patches review and test > > Hi all, > > Here is a list of patches targeted for stable release 20.11.4. > > The planned date for the final release is 31th December. > > Please help with testing and validation of your use cases and report > any issues/results with reply-all to this mail. For the final release > the fixes and reported validations will be added to the release notes. > > A release candidate tarball can be found at: > > https://dpdk.org/browse/dpdk-stable/tag/?id=v20.11.4-rc1 > > These patches are located at branch 20.11 of dpdk-stable repo: > https://dpdk.org/browse/dpdk-stable/ > > Thanks. > > Xueming Li > > --- The following covers the functional tests that we ran on Mellanox hardware for this release: - Basic functionality: Send and receive multiple types of traffic. - testpmd xstats counter test. - testpmd timestamp test. - Changing/checking link status through testpmd. - RTE flow tests: Items: - eth - geneve - gre - gre_key - gtp - icmp - icmp6 - ipv4 - ipv6 - ipv6_frag_ext - mark - meta - mpls - nvgre - tag - tcp - udp - vlan - vxlan - vxlan_gpe Actions: - age (shared and non-shared) - count - dec_tcp_ack - dec_tcp_seq - dec_ttl - drop - flag - inc_tcp_ack - inc_tcp_seq - jump - mark - queue - raw_decap - raw_encap - rss (shared and non-shared) - set_ipv4_dscp - set_ipv4_dst - set_ipv4_src - set_ipv6_dscp - set_ipv6_dst - set_ipv6_src - set_mac_dst - set_mac_src - set_meta - set_tag - set_tp_dst - set_tp_src - set_ttl - vxlan_decap - vxlan_encap - Some RSS tests. - VLAN filtering, stripping and insertion tests. - Checksum and TSO tests. - ptype tests. - link_status_interrupt example application tests. - l3fwd-power example application tests. - Multi-process example applications tests. - Hardware LRO tests. Functional tests ran on: - NIC: ConnectX-4 Lx / OS: Ubuntu 20.04 LTS / Driver: MLNX_OFED_LINUX-5.5-1.0.3.2 / Firmware: 14.32.1010 - NIC: ConnectX-4 Lx / OS: Ubuntu 20.04 LTS / Kernel: 5.16.0-rc5 / Driver: rdma-core v38.0 / Firmware: 14.32.1010 - NIC: ConnectX-5 / OS: Ubuntu 20.04 LTS / Driver: MLNX_OFED_LINUX-5.5-1.0.3.2 / Firmware: 16.32.1010 - NIC: ConnectX-5 / OS: Ubuntu 20.04 LTS / Kernel: 5.16.0-rc5 / Driver: v38.0 / Firmware: 16.32.1010 - NIC: ConnectX-6 Dx / OS: Ubuntu 20.04 LTS / Driver: MLNX_OFED_LINUX-5.5-1.0.3.2 / Firmware: 22.32.1010 Compilation tests with multiple configurations in the following OS/driver combinations are also passing: - Ubuntu 20.04.3 with MLNX_OFED_LINUX-5.5-1.0.3.2. - Ubuntu 20.04.3 with rdma-core master (c52b43e). - Ubuntu 20.04.3 with rdma-core v28.0. - Ubuntu 18.04.6 with rdma-core v17.1. - Ubuntu 18.04.6 with rdma-core master (c52b43e) (i386). - Ubuntu 16.04.7 with rdma-core v22.7. - Fedora 35 with rdma-core v38.0. - Fedora 36 (Rawhide) with rdma-core v38.0 - CentOS 7 7.9.2009 with rdma-core master (940f53f). - CentOS 7 7.9.2009 with MLNX_OFED_LINUX-5.5-1.0.3.2. - CentOS 8 8.4.2105 with rdma-core master (940f53f). - OpenSUSE Leap 15.3 with rdma-core v31.0. - Windows Server 2019 with Clang 11.0.0. The only issue we found that was introduced by 20.11.4-rc1 is the following: - Bug 916 - [20.11.4-rc1][mlx5] 2% single core packet forwarding performance degradation (https://bugs.dpdk.org/show_bug.cgi?id=916) We are still discussing whether we want to backport a fix to this release or not. Thanks, Ali
Re: 20.11.4 patches review and test
On Thu, 2021-12-16 at 06:40 +, Jiang, YuX wrote: > > -Original Message- > > From: Xueming(Steven) Li > > Sent: Wednesday, December 15, 2021 10:45 PM > > To: Lin, Xueqin ; Jiang, YuX > > ; > > sta...@dpdk.org > > Cc: Stokes, Ian ; dev@dpdk.org; > > ktray...@redhat.com; abhishek.mara...@microsoft.com; > > d...@linux.vnet.ibm.com; NBU-Contact-Thomas Monjalon (EXTERNAL) > > ; Peng, Yuan ; > > jer...@marvell.com; Walker, Benjamin ; > > bl...@debian.org; Raslan Darawsheh ; Mcnamara, > > John ; Chen, Zhaoyan > > ; Govindharajan, Hariprasad > > ; Ali Alnubani > > ; > > hemant.agra...@nxp.com; pezh...@redhat.com; juh...@microsoft.com; > > Xu, Qian Q > > Subject: Re: 20.11.4 patches review and test > > > > On Fri, 2021-12-10 at 11:35 +, Jiang, YuX wrote: > > > > -Original Message- > > > > From: Jiang, YuX > > > > Sent: Thursday, December 9, 2021 6:01 PM > > > > To: Xueming Li ; sta...@dpdk.org; Lin, > > > > Xueqin > > > > > > > > Cc: dev@dpdk.org; Abhishek Marathe > > > > ; > > > > Ali Alnubani ; Walker, Benjamin > > > > ; David Christensen > > > > ; Govindharajan, Hariprasad > > > > ; Hemant Agrawal > > > > ; Stokes, Ian ; > > > > Jerin > > > > Jacob ; Mcnamara, John > > > > ; Ju-Hyoung Lee > > > > ; > > > > Kevin Traynor ; Luca Boccassi > > > > ; Pei Zhang ; Xu, Qian Q > > > > ; Raslan Darawsheh ; > > Thomas > > > > Monjalon ; Peng, Yuan > > ; > > > > Chen, Zhaoyan > > > > Subject: RE: 20.11.4 patches review and test > > > > > > > > > -Original Message- > > > > > From: Xueming Li > > > > > Sent: Tuesday, December 7, 2021 12:15 AM > > > > > To: sta...@dpdk.org > > > > > Cc: xuemi...@nvidia.com; dev@dpdk.org; Abhishek Marathe > > > > > ; Ali Alnubani > > > > > ; Walker, Benjamin > > > > > ; David Christensen > > > > > ; Govindharajan, Hariprasad > > > > > ; Hemant Agrawal > > > > > ; Stokes, Ian ; > > > > > Jerin Jacob ; Mcnamara, John > > > > ; > > > > > Ju-Hyoung Lee ; Kevin Traynor > > > > > ; Luca Boccassi ; Pei > > > > > Zhang > > > > > ; Xu, Qian Q ; > > > > > Raslan > > > > > Darawsheh ; Thomas Monjalon > > > > ; > > > > > Peng, Yuan ; Chen, Zhaoyan > > > > > > > > > > Subject: 20.11.4 patches review and test > > > > > > > > > > Hi all, > > > > > > > > > > Here is a list of patches targeted for stable release > > > > > 20.11.4. > > > > > > > > > > The planned date for the final release is 31th December. > > > > > > > > > > Please help with testing and validation of your use cases and > > > > > report any issues/results with reply-all to this mail. For > > > > > the > > > > > final release the fixes and reported validations will be > > > > > added to > > > > > the release notes. > > > > > > > > > > A release candidate tarball can be found at: > > > > > > > > > > https://nam11.safelinks.protection.outlook.com/?url=https > > > > > %3A%25 > > > > > 2F%2Fdpdk.org%2Fbrowse%2Fdpdk- > > stable%2Ftag%2F%3Fid%3Dv20.11.4- > > > > > > > rc1&data=04%7C01%7Cxuemingl%40nvidia.com%7Cc9cdc823fce64be11 > > 8 > > > > > > > 0908d9bbd13e8a%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637 > > 74 > > > > > > > 7329661244261%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLC > > JQIjo > > > > > > > iV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=DtlL0BYV > > > > > > > vWm7JE9JV%2BliWzq6R%2FHmKRSNKbc10nmF81Q%3D&reserved=0 > > > > > > > > > > These patches are located at branch 20.11 of dpdk-stable > > > > > repo: > > > > > https://nam11.safelinks.protection.outlook.com/?url=https > > > > > %3A%25 > > > > > 2F%2Fdpdk.org%2Fbrowse%2Fdpdk- > > > > > > > stable%2F&data=04%7C01%7Cxuemingl%40nvidia.com%7Cc9cdc823fce > > 6 > > > > > > > 4be1180908d9bbd13e8a%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0 > > %7 > > > > > > > C637747329661244261%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAw > > MDAiL > > > > > > > CJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=KO > > > > > > > 3YKk3gXS%2B73gMdQf9MFohT9q55YiDW8df%2F12ZepMs%3D&reserve > > d=0 > > > > > > > > > > Thanks. > > > > > > > > > > Xueming Li > > > > > > > > > Update the test status for Intel part. Till now dpdk20.11.4-rc1 > > > > test > > > > execution rate is 80%. Currently, find three bugs, two bugs > > > > have fix > > > > now. > > > > # Basic Intel(R) NIC testing > > > > * Build or compile: > > > > *Build: cover the build test combination with latest > > > > GCC/Clang/ICC > > > > version and the popular OS revision such as Ubuntu20.04, > > > > Fedora34, > > > > RHEL8.4, etc. > > > > - All test done. > > > > - Two bugs are found in 20.11.4-rc1. > > > > - dpdk- > > > > 20.11.4]kernel/linux/kni/rte_kni.ko > > > > build > > > > failed on OpenSuse15.3 with gcc7.5.0&clang11.0.1 > > > > - fix link: > > > > http://inbox.dpdk.org/stable/20211208103410.835542-1- > > > > ferruh.yi...@intel.com/T/#u , verify passed by Intel > > > > - > > > > https://bugs.dpdk.org/show_bug.cgi?id=894 > > > > [dpdk-20.11.
Re: 20.11.4 patches review and test
Hi Ali, Thanks very much for your support! On Thu, 2021-12-23 at 14:52 +, Ali Alnubani wrote: > Hi, > > > -Original Message- > > From: Xueming(Steven) Li > > Sent: Monday, December 6, 2021 6:15 PM > > To: sta...@dpdk.org > > Cc: Xueming(Steven) Li ; dev@dpdk.org; Abhishek > > Marathe ; Ali Alnubani > > ; benjamin.wal...@intel.com; David Christensen > > ; hariprasad.govindhara...@intel.com; Hemant > > Agrawal ; Ian Stokes ; > > Jerin Jacob ; John McNamara > > ; Ju-Hyoung Lee ; > > Kevin Traynor ; Luca Boccassi ; > > Pei Zhang ; qian.q...@intel.com; Raslan Darawsheh > > ; NBU-Contact-Thomas Monjalon (EXTERNAL) > > ; yuan.p...@intel.com; zhaoyan.c...@intel.com > > Subject: 20.11.4 patches review and test > > > > Hi all, > > > > Here is a list of patches targeted for stable release 20.11.4. > > > > The planned date for the final release is 31th December. > > > > Please help with testing and validation of your use cases and report > > any issues/results with reply-all to this mail. For the final release > > the fixes and reported validations will be added to the release notes. > > > > A release candidate tarball can be found at: > > > > > > https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdpdk.org%2Fbrowse%2Fdpdk-stable%2Ftag%2F%3Fid%3Dv20.11.4-rc1&data=04%7C01%7Cxuemingl%40nvidia.com%7C4df7aa57e1ed4e9e263308d9c623e4d0%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637758679724411133%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=jX1ppD4x%2FH3x%2FWZLI6bMP7LiUZxKPZCmks6AH7wm88c%3D&reserved=0 > > > > These patches are located at branch 20.11 of dpdk-stable repo: > > > > https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdpdk.org%2Fbrowse%2Fdpdk-stable%2F&data=04%7C01%7Cxuemingl%40nvidia.com%7C4df7aa57e1ed4e9e263308d9c623e4d0%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637758679724411133%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=59XOMTcOVxkUmeWeg0SM8GHgGapaOLdm2oONMq7fvqQ%3D&reserved=0 > > > > Thanks. > > > > Xueming Li > > > > --- > > The following covers the functional tests that we ran on Mellanox hardware > for this release: > - Basic functionality: > Send and receive multiple types of traffic. > - testpmd xstats counter test. > - testpmd timestamp test. > - Changing/checking link status through testpmd. > - RTE flow tests: > Items: > - eth > - geneve > - gre > - gre_key > - gtp > - icmp > - icmp6 > - ipv4 > - ipv6 > - ipv6_frag_ext > - mark > - meta > - mpls > - nvgre > - tag > - tcp > - udp > - vlan > - vxlan > - vxlan_gpe > Actions: > - age (shared and non-shared) > - count > - dec_tcp_ack > - dec_tcp_seq > - dec_ttl > - drop > - flag > - inc_tcp_ack > - inc_tcp_seq > - jump > - mark > - queue > - raw_decap > - raw_encap > - rss (shared and non-shared) > - set_ipv4_dscp > - set_ipv4_dst > - set_ipv4_src > - set_ipv6_dscp > - set_ipv6_dst > - set_ipv6_src > - set_mac_dst > - set_mac_src > - set_meta > - set_tag > - set_tp_dst > - set_tp_src > - set_ttl > - vxlan_decap > - vxlan_encap > > - Some RSS tests. > - VLAN filtering, stripping and insertion tests. > - Checksum and TSO tests. > - ptype tests. > - link_status_interrupt example application tests. > - l3fwd-power example application tests. > - Multi-process example applications tests. > - Hardware LRO tests. > > Functional tests ran on: > - NIC: ConnectX-4 Lx / OS: Ubuntu 20.04 LTS / Driver: > MLNX_OFED_LINUX-5.5-1.0.3.2 / Firmware: 14.32.1010 > - NIC: ConnectX-4 Lx / OS: Ubuntu 20.04 LTS / Kernel: 5.16.0-rc5 / Driver: > rdma-core v38.0 / Firmware: 14.32.1010 > - NIC: ConnectX-5 / OS: Ubuntu 20.04 LTS / Driver: > MLNX_OFED_LINUX-5.5-1.0.3.2 / Firmware: 16.32.1010 > - NIC: ConnectX-5 / OS: Ubuntu 20.04 LTS / Kernel: 5.16.0-rc5 / Driver: v38.0 > / Firmware: 16.32.1010 > - NIC: ConnectX-6 Dx / OS: Ubuntu 20.04 LTS / Driver: > MLNX_OFED_LINUX-5.5-1.0.3.2 / Firmware: 22.32.1010 > > Compilation tests with multiple configurations in the following OS/driver > combinations are also passing: > - Ubuntu 20.04.3 with MLNX_OFED_LINUX-5.5-1.0.3.2. > - Ubuntu 20.04.3 with rdma-core master (c52b43e). > - Ubuntu 20.04.3 with rdma-core v28.0. > - Ubuntu 18.04.6 with rdma-core v17.1. > - Ubuntu 18.04.6 with rdma-core master (c52b43e) (i386). > - Ubuntu 16.04.7 with rdma-core v22.7. > - Fedora 35 with rdma-core v38.0. > - Fedora 36 (Rawhide) with rdma-core v38.0 > - CentOS 7 7.9.2009 with rdma-core master (940f53f). > - CentOS 7 7.9.2009 with MLNX_OFED_LINUX-5.5-1.0.3.2. > - CentOS 8 8.4.2105 with rdma-core master (940f53f). > - OpenSUSE Leap 15.3 with rdma-core v31.0. > - Windows Server 2019 with Clang 11.0.0. > > The only issue we found that was introduced by 20.11.4-rc1 is the following: > - Bug 916 - [20.11.4-rc1][mlx5] 2% single core packet forwarding performance > deg
[PATCH] app/test-fib: fix possible division by zero
This patch fixes the division by 0, which occurs if the number of routes is less than 10. Can be triggered by passing -n argument with value < 10: ./dpdk-test-fib -- -n 9 ... Floating point exception (core dumped) Fixes: 103809d032cd ("app/test-fib: add test application for FIB") Cc: vladimir.medved...@intel.com Signed-off-by: Vladimir Medvedkin --- app/test-fib/main.c | 40 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/app/test-fib/main.c b/app/test-fib/main.c index ecd420116a..9bc8b8a7ca 100644 --- a/app/test-fib/main.c +++ b/app/test-fib/main.c @@ -902,8 +902,9 @@ run_v4(void) return -ret; } } - printf("AVG FIB add %"PRIu64"\n", - (rte_rdtsc_precise() - start) / j); + if (j != 0) + printf("AVG FIB add %"PRIu64"\n", + (rte_rdtsc_precise() - start) / j); i += j; } @@ -930,8 +931,9 @@ run_v4(void) return -ret; } } - printf("AVG LPM add %"PRIu64"\n", - (rte_rdtsc_precise() - start) / j); + if (j != 0) + printf("AVG LPM add %"PRIu64"\n", + (rte_rdtsc_precise() - start) / j); i += j; } } @@ -984,8 +986,9 @@ run_v4(void) for (j = 0; j < (config.nb_routes - i) / k; j++) rte_fib_delete(fib, rt[i + j].addr, rt[i + j].depth); - printf("AVG FIB delete %"PRIu64"\n", - (rte_rdtsc_precise() - start) / j); + if (j != 0) + printf("AVG FIB delete %"PRIu64"\n", + (rte_rdtsc_precise() - start) / j); i += j; } @@ -996,8 +999,9 @@ run_v4(void) rte_lpm_delete(lpm, rt[i + j].addr, rt[i + j].depth); - printf("AVG LPM delete %"PRIu64"\n", - (rte_rdtsc_precise() - start) / j); + if (j != 0) + printf("AVG LPM delete %"PRIu64"\n", + (rte_rdtsc_precise() - start) / j); i += j; } } @@ -1097,8 +1101,9 @@ run_v6(void) return -ret; } } - printf("AVG FIB add %"PRIu64"\n", - (rte_rdtsc_precise() - start) / j); + if (j != 0) + printf("AVG FIB add %"PRIu64"\n", + (rte_rdtsc_precise() - start) / j); i += j; } @@ -1125,8 +1130,9 @@ run_v6(void) return -ret; } } - printf("AVG LPM add %"PRIu64"\n", - (rte_rdtsc_precise() - start) / j); + if (j != 0) + printf("AVG LPM add %"PRIu64"\n", + (rte_rdtsc_precise() - start) / j); i += j; } } @@ -1183,8 +1189,9 @@ run_v6(void) for (j = 0; j < (config.nb_routes - i) / k; j++) rte_fib6_delete(fib, rt[i + j].addr, rt[i + j].depth); - printf("AVG FIB delete %"PRIu64"\n", - (rte_rdtsc_precise() - start) / j); + if (j != 0) + printf("AVG FIB delete %"PRIu64"\n", + (rte_rdtsc_precise() - start) / j); i += j; } @@ -1195,8 +1202,9 @@ run_v6(void) rte_lpm6_delete(lpm, rt[i + j].addr, rt[i + j].depth); - printf("AVG LPM delete %"PRIu64"\n", - (rte_rdtsc_precise() - start) / j); + if (j != 0) + printf("AVG LPM delete %"PRIu64"\n", + (rte_rdtsc_precise() - start) / j); i += j; } } -- 2.25.1
[PATCH v2] app/test-fib: fix possible division by zero
This patch fixes the division by 0, which occurs if the number of routes is less than 10. Can be triggered by passing -n argument with value < 10: ./dpdk-test-fib -- -n 9 ... Floating point exception (core dumped) Fixes: 103809d032cd ("app/test-fib: add test application for FIB") Cc: sta...@dpdk.org Signed-off-by: Vladimir Medvedkin --- app/test-fib/main.c | 40 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/app/test-fib/main.c b/app/test-fib/main.c index ecd420116a..9bc8b8a7ca 100644 --- a/app/test-fib/main.c +++ b/app/test-fib/main.c @@ -902,8 +902,9 @@ run_v4(void) return -ret; } } - printf("AVG FIB add %"PRIu64"\n", - (rte_rdtsc_precise() - start) / j); + if (j != 0) + printf("AVG FIB add %"PRIu64"\n", + (rte_rdtsc_precise() - start) / j); i += j; } @@ -930,8 +931,9 @@ run_v4(void) return -ret; } } - printf("AVG LPM add %"PRIu64"\n", - (rte_rdtsc_precise() - start) / j); + if (j != 0) + printf("AVG LPM add %"PRIu64"\n", + (rte_rdtsc_precise() - start) / j); i += j; } } @@ -984,8 +986,9 @@ run_v4(void) for (j = 0; j < (config.nb_routes - i) / k; j++) rte_fib_delete(fib, rt[i + j].addr, rt[i + j].depth); - printf("AVG FIB delete %"PRIu64"\n", - (rte_rdtsc_precise() - start) / j); + if (j != 0) + printf("AVG FIB delete %"PRIu64"\n", + (rte_rdtsc_precise() - start) / j); i += j; } @@ -996,8 +999,9 @@ run_v4(void) rte_lpm_delete(lpm, rt[i + j].addr, rt[i + j].depth); - printf("AVG LPM delete %"PRIu64"\n", - (rte_rdtsc_precise() - start) / j); + if (j != 0) + printf("AVG LPM delete %"PRIu64"\n", + (rte_rdtsc_precise() - start) / j); i += j; } } @@ -1097,8 +1101,9 @@ run_v6(void) return -ret; } } - printf("AVG FIB add %"PRIu64"\n", - (rte_rdtsc_precise() - start) / j); + if (j != 0) + printf("AVG FIB add %"PRIu64"\n", + (rte_rdtsc_precise() - start) / j); i += j; } @@ -1125,8 +1130,9 @@ run_v6(void) return -ret; } } - printf("AVG LPM add %"PRIu64"\n", - (rte_rdtsc_precise() - start) / j); + if (j != 0) + printf("AVG LPM add %"PRIu64"\n", + (rte_rdtsc_precise() - start) / j); i += j; } } @@ -1183,8 +1189,9 @@ run_v6(void) for (j = 0; j < (config.nb_routes - i) / k; j++) rte_fib6_delete(fib, rt[i + j].addr, rt[i + j].depth); - printf("AVG FIB delete %"PRIu64"\n", - (rte_rdtsc_precise() - start) / j); + if (j != 0) + printf("AVG FIB delete %"PRIu64"\n", + (rte_rdtsc_precise() - start) / j); i += j; } @@ -1195,8 +1202,9 @@ run_v6(void) rte_lpm6_delete(lpm, rt[i + j].addr, rt[i + j].depth); - printf("AVG LPM delete %"PRIu64"\n", - (rte_rdtsc_precise() - start) / j); + if (j != 0) + printf("AVG LPM delete %"PRIu64"\n", + (rte_rdtsc_precise() - start) / j); i += j; } } -- 2.25.1
Re: [PATCH 0/7] vhost: improve logging
On Thu, 23 Dec 2021 09:36:52 +0100 Maxime Coquelin wrote: > This series aims at easing Vhost logs analysis, by > prepending the Vhost-user socket path to all logs and to > remove multi-line comments. Doing so, filtering Vhost-user > ports logs is much easier. > > Maxime Coquelin (7): > vhost: improve IOTLB logs > vhost: improve vDPA registration failure log > vhost: improve socket layer logs > vhost: improve Vhost layer logs > vhost: improve Vhost-user layer logs > vhost: improve Virtio-net layer logs > vhost: remove multi-line logs > > lib/vhost/iotlb.c | 26 +- > lib/vhost/iotlb.h | 10 +- > lib/vhost/socket.c | 131 - > lib/vhost/vdpa.c | 4 +- > lib/vhost/vhost.c | 106 --- > lib/vhost/vhost_user.c | 653 - > lib/vhost/virtio_net.c | 165 +-- > 7 files changed, 518 insertions(+), 577 deletions(-) > Good work Acked-by: Stephen Hemminger
[PATCH] event/cnxk: add timer adapter periodic mode support
Add support for event timer adapter periodic mode capability. Signed-off-by: Shijith Thotton --- Depends-on: series-20928 (event/cnxk: update min interval calculation) drivers/event/cnxk/cnxk_tim_evdev.c | 21 + drivers/event/cnxk/cnxk_tim_evdev.h | 1 + 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/event/cnxk/cnxk_tim_evdev.c b/drivers/event/cnxk/cnxk_tim_evdev.c index 5d52a39752..4d22ac6ac3 100644 --- a/drivers/event/cnxk/cnxk_tim_evdev.c +++ b/drivers/event/cnxk/cnxk_tim_evdev.c @@ -58,7 +58,7 @@ cnxk_tim_chnk_pool_create(struct cnxk_tim_ring *tim_ring, } tim_ring->aura = roc_npa_aura_handle_to_aura( tim_ring->chunk_pool->pool_id); - tim_ring->ena_dfb = 0; + tim_ring->ena_dfb = tim_ring->ena_periodic ? 1 : 0; } else { tim_ring->chunk_pool = rte_mempool_create( pool_name, tim_ring->nb_chunks, tim_ring->chunk_sz, @@ -112,7 +112,9 @@ cnxk_tim_ring_info_get(const struct rte_event_timer_adapter *adptr, struct cnxk_tim_ring *tim_ring = adptr->data->adapter_priv; adptr_info->max_tmo_ns = tim_ring->max_tout; - adptr_info->min_resolution_ns = tim_ring->tck_nsec; + adptr_info->min_resolution_ns = tim_ring->ena_periodic ? + tim_ring->max_tout : + tim_ring->tck_nsec; rte_memcpy(&adptr_info->conf, &adptr->data->conf, sizeof(struct rte_event_timer_adapter_conf)); } @@ -237,6 +239,12 @@ cnxk_tim_ring_create(struct rte_event_timer_adapter *adptr) goto tim_hw_free; } + if (rcfg->flags & RTE_EVENT_TIMER_ADAPTER_F_PERIODIC) { + /* Use 2 buckets to avoid contention */ + rcfg->timer_tick_ns /= 2; + tim_ring->ena_periodic = 1; + } + if (rcfg->timer_tick_ns < min_intvl_ns) { if (rcfg->flags & RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES) { rcfg->timer_tick_ns = min_intvl_ns; @@ -246,6 +254,9 @@ cnxk_tim_ring_create(struct rte_event_timer_adapter *adptr) } } + if (tim_ring->ena_periodic) + rcfg->max_tmo_ns = rcfg->timer_tick_ns * 2; + if (rcfg->timer_tick_ns > rcfg->max_tmo_ns) { plt_err("Max timeout to too high"); rc = -ERANGE; @@ -322,7 +333,8 @@ cnxk_tim_ring_create(struct rte_event_timer_adapter *adptr) if (rc < 0) goto tim_bkt_free; - rc = roc_tim_lf_config(&dev->tim, tim_ring->ring_id, clk_src, 0, 0, + rc = roc_tim_lf_config(&dev->tim, tim_ring->ring_id, clk_src, + tim_ring->ena_periodic, tim_ring->ena_dfb, tim_ring->nb_bkts, tim_ring->chunk_sz, tim_ring->tck_int, tim_ring->tck_nsec, clk_freq); if (rc < 0) { @@ -493,7 +505,8 @@ cnxk_tim_caps_get(const struct rte_eventdev *evdev, uint64_t flags, /* Store evdev pointer for later use. */ dev->event_dev = (struct rte_eventdev *)(uintptr_t)evdev; - *caps = RTE_EVENT_TIMER_ADAPTER_CAP_INTERNAL_PORT; + *caps = RTE_EVENT_TIMER_ADAPTER_CAP_INTERNAL_PORT | + RTE_EVENT_TIMER_ADAPTER_CAP_PERIODIC; *ops = &cnxk_tim_ops; return 0; diff --git a/drivers/event/cnxk/cnxk_tim_evdev.h b/drivers/event/cnxk/cnxk_tim_evdev.h index 6b5342cc34..91a90ee2ce 100644 --- a/drivers/event/cnxk/cnxk_tim_evdev.h +++ b/drivers/event/cnxk/cnxk_tim_evdev.h @@ -135,6 +135,7 @@ struct cnxk_tim_ring { uint8_t enable_stats; uint8_t disable_npa; uint8_t ena_dfb; + uint8_t ena_periodic; uint16_t ring_id; uint32_t aura; uint64_t nb_timers; -- 2.25.1
[PATCH] eal: log hugepage create errors with filename
While debugging running DPDK service in a container, it is useful to see which file creation failed. Don't hide this failure with DEBUG. Signed-off-by: Stephen Hemminger --- lib/eal/linux/eal_memalloc.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/eal/linux/eal_memalloc.c b/lib/eal/linux/eal_memalloc.c index 337f2bc739cf..16b58d861b31 100644 --- a/lib/eal/linux/eal_memalloc.c +++ b/lib/eal/linux/eal_memalloc.c @@ -308,8 +308,8 @@ get_seg_fd(char *path, int buflen, struct hugepage_info *hi, if (fd < 0) { fd = open(path, O_CREAT | O_RDWR, 0600); if (fd < 0) { - RTE_LOG(ERR, EAL, "%s(): open failed: %s\n", - __func__, strerror(errno)); + RTE_LOG(ERR, EAL, "%s(): open '%s' failed: %s\n", + __func__, path, strerror(errno)); return -1; } /* take out a read lock and keep it indefinitely */ @@ -346,8 +346,8 @@ get_seg_fd(char *path, int buflen, struct hugepage_info *hi, fd = open(path, O_CREAT | O_RDWR, 0600); if (fd < 0) { - RTE_LOG(DEBUG, EAL, "%s(): open failed: %s\n", - __func__, strerror(errno)); + RTE_LOG(ERR, EAL, "%s(): open '%s' failed: %s\n", + __func__, path, strerror(errno)); return -1; } /* take out a read lock */ -- 2.30.2
[RFC] eal: support systemd service convention for runtime directory
Systemd.exec supports configuring the runtime directory of a service via RuntimeDirectory=. This creates the directory with the necessary permissions which actual service may not have if running in container. The change to DPDK is to look for the environment RUNTIME_DIRECTORY first and use that in preference to the fallback alternatives. Signed-off-by: Stephen Hemminger --- lib/eal/linux/eal.c | 23 --- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c index 60b49248388e..e729c713b393 100644 --- a/lib/eal/linux/eal.c +++ b/lib/eal/linux/eal.c @@ -86,25 +86,26 @@ struct lcore_config lcore_config[RTE_MAX_LCORE]; /* used by rte_rdtsc() */ int rte_cycles_vmware_tsc_map; -static const char *default_runtime_dir = "/var/run"; - int eal_create_runtime_dir(void) { - const char *directory = default_runtime_dir; - const char *xdg_runtime_dir = getenv("XDG_RUNTIME_DIR"); - const char *fallback = "/tmp"; + const char *directory; char run_dir[PATH_MAX]; char tmp[PATH_MAX]; int ret; - if (getuid() != 0) { - /* try XDG path first, fall back to /tmp */ - if (xdg_runtime_dir != NULL) - directory = xdg_runtime_dir; - else - directory = fallback; + /* from RuntimeDirectory= see systemd.exec */ + directory = getenv("RUNTIME_DIRECTORY"); + if (directory == NULL) { + if (getuid() == 0) + directory = "/var/run"; + else { + directory = getenv("XDG_RUNTIME_DIR"); + if (directory == NULL) + directory = "/tmp"; + } } + /* create DPDK subdirectory under runtime dir */ ret = snprintf(tmp, sizeof(tmp), "%s/dpdk", directory); if (ret < 0 || ret == sizeof(tmp)) { -- 2.30.2
[PATCH] net/mlx5: support the imissed counter on Windows
Add support for the imissed counter using the DevX API on Windows. imissed is queried by creating a queue counter for the port, attaching it to all created RQs and querying the "out_of_buffer" field. If the counter cannot be created, imissed will always report 0. Signed-off-by: Tal Shnaiderman Acked-by: Matan Azrad --- drivers/common/mlx5/version.map | 4 ++-- drivers/net/mlx5/windows/mlx5_ethdev_os.c | 11 ++- drivers/net/mlx5/windows/mlx5_os.c| 29 - 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/drivers/common/mlx5/version.map b/drivers/common/mlx5/version.map index 34e86004a0..462b7cea5e 100644 --- a/drivers/common/mlx5/version.map +++ b/drivers/common/mlx5/version.map @@ -55,8 +55,8 @@ INTERNAL { mlx5_devx_cmd_query_parse_samples; mlx5_devx_cmd_query_virtio_q_counters; # WINDOWS_NO_EXPORT mlx5_devx_cmd_query_virtq; - mlx5_devx_cmd_queue_counter_alloc; # WINDOWS_NO_EXPORT - mlx5_devx_cmd_queue_counter_query; # WINDOWS_NO_EXPORT + mlx5_devx_cmd_queue_counter_alloc; + mlx5_devx_cmd_queue_counter_query; mlx5_devx_cmd_register_read; mlx5_devx_cmd_register_write; mlx5_devx_cmd_wq_query; # WINDOWS_NO_EXPORT diff --git a/drivers/net/mlx5/windows/mlx5_ethdev_os.c b/drivers/net/mlx5/windows/mlx5_ethdev_os.c index 359f73df7c..c6315ce368 100644 --- a/drivers/net/mlx5/windows/mlx5_ethdev_os.c +++ b/drivers/net/mlx5/windows/mlx5_ethdev_os.c @@ -203,7 +203,16 @@ mlx5_os_get_stats_n(struct rte_eth_dev *dev) void mlx5_os_stats_init(struct rte_eth_dev *dev) { - RTE_SET_USED(dev); + struct mlx5_priv *priv = dev->data->dev_private; + struct mlx5_stats_ctrl *stats_ctrl = &priv->stats_ctrl; + int ret; + + /* Copy to base at first time. */ + ret = mlx5_os_read_dev_stat(priv, "out_of_buffer", &stats_ctrl->imissed_base); + if (ret) + DRV_LOG(ERR, "port %u cannot read device counters: %s", + dev->data->port_id, strerror(rte_errno)); + stats_ctrl->imissed = 0; } /** diff --git a/drivers/net/mlx5/windows/mlx5_os.c b/drivers/net/mlx5/windows/mlx5_os.c index dec4b923d0..0e31aba892 100644 --- a/drivers/net/mlx5/windows/mlx5_os.c +++ b/drivers/net/mlx5/windows/mlx5_os.c @@ -72,6 +72,22 @@ static struct mlx5_indexed_pool_config icfg[] = { }, }; +static void +mlx5_queue_counter_id_prepare(struct rte_eth_dev *dev) +{ + struct mlx5_priv *priv = dev->data->dev_private; + void *ctx = priv->sh->cdev->ctx; + + priv->q_counters = mlx5_devx_cmd_queue_counter_alloc(ctx); + if (!priv->q_counters) { + DRV_LOG(ERR, "Port %d queue counter object cannot be created " + "by DevX - imissed counter will be unavailable", + dev->data->port_id); + return; + } + priv->counter_set_id = priv->q_counters->id; +} + /** * Initialize shared data between primary and secondary process. * @@ -655,6 +671,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, goto error; } mlx5_flow_counter_mode_config(eth_dev); + mlx5_queue_counter_id_prepare(eth_dev); return eth_dev; error: if (priv) { @@ -718,7 +735,8 @@ mlx5_os_dev_shared_handler_uninstall(struct mlx5_dev_ctx_shared *sh) * @param[out] stat * Pointer to read statistic value. * @return - * 0 on success and stat is valud, 1 if failed to read the value + * 0 on success and stat is valid, non-zero if failed to read the value + * or counter is not supported. * rte_errno is set. * */ @@ -726,10 +744,11 @@ int mlx5_os_read_dev_stat(struct mlx5_priv *priv, const char *ctr_name, uint64_t *stat) { - RTE_SET_USED(priv); - RTE_SET_USED(ctr_name); - RTE_SET_USED(stat); - DRV_LOG(WARNING, "%s: is not supported", __func__); + if (priv->q_counters != NULL && strcmp(ctr_name, "out_of_buffer") == 0) + return mlx5_devx_cmd_queue_counter_query + (priv->q_counters, 0, (uint32_t *)stat); + DRV_LOG(WARNING, "%s: is not supported for the %s counter", + __func__, ctr_name); return -ENOTSUP; } -- 2.16.1.windows.4