Skip to contentSkip to conversation

Add DLB2 PMD

PATCH Superseded Timothy McDaniel 10 participants 366 messages Sep 11, 2020 – Nov 2, 2020 Arm/Amlogic Meson SoC support Page 5 of 8

lore
Share & tools
lore
#223 lore raw

Re: [dpdk-dev] [PATCH v2 06/22] event/dlb2: add probe

In reply to Jerin Jacob
Quoted 8,541 lines

-----Original Message-----
From: Jerin Jacob <[email protected]>
Sent: Sunday, October 18, 2020 3:40 AM
To: McDaniel, Timothy <[email protected]>
Cc: Burakov, Anatoly <[email protected]>; dpdk-dev <[email protected]>; Carrillo, Erik G <[email protected]>; Eads, Gage <[email protected]>; Van Haaren, Harry <[email protected]>; Jerin Jacob <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2 06/22] event/dlb2: add probe

Quoted 12 lines · Timothy McDaniel

The DLB2 hardware is a PCI device. This commit adds support for probe and other initialization. The dlb2_iface.[ch] files implement a flexible interface that supports both the PF PMD and the bifurcated PMD. The bifurcated PMD will be released in a future patch set. Note that the flexible interface is only used for configuration, and is not used in the data path. The shared code is added in pf/base. This PMD supports command line parameters, and those are parsed at probe-time.

Quoted 1 line

There is a build issue clang10.

[for-main]dell[dpdk-next-eventdev] $ clang -v
clang version 10.0.1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-pc-linux- gnu/10.2.0
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-pc-linux-gnu/8.4.0 Found candidate GCC installation:
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/10.2.0
Found candidate GCC installation:
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0 Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/8.4.0 Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/10.2.0 Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/8.4.0 Selected GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/10.2.0 Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64

meson -Dexamples=l3fwd --buildtype=debugoptimized --werror --default-library=static /export/dpdk-next-eventdev/devtools/.. ./build-clang-static

ccache clang -Idrivers/libtmp_rte_pmd_dlb2_event.a.p -Idrivers

(quoted diff) +0 -3
-I../drivers -Idrivers/event/dlb2 -I../drivers/event/dlb2
-Ilib/librte_eventdev -I../lib/librte_eventdev -I. -I.. -Iconfig
-I../config -Ilib/librte_eal/include -I../lib/librte_e

al/include -Ilib/librte_eal/linux/include

(quoted diff) +0 -4
-I../lib/librte_eal/linux/include -Ilib/librte_eal/x86/include
-I../lib/librte_eal/x86/include -Ilib/librte_eal/common
-I../lib/librte_eal/common -Ilib/librte_eal -I../lib/librte_eal
-Ilib/librte_kv

args -I../lib/librte_kvargs -Ilib/librte_metrics

(quoted diff) +0 -7
-I../lib/librte_metrics -Ilib/librte_telemetry
-I../lib/librte_telemetry -Ilib/librte_ring -I../lib/librte_ring
-Ilib/librte_ethdev -I../lib/librte_ethdev -Ilib/librte_net
-I../lib/librte_net
 -Ilib/librte_mbuf -I../lib/librte_mbuf -Ilib/librte_mempool
-I../lib/librte_mempool -Ilib/librte_meter -I../lib/librte_meter
-Ilib/librte_hash -I../lib/librte_hash -Ilib/librte_timer
-I../lib/librte_timer -Ilib/librte_cryptodev -I../lib/li

brte_cryptodev -Ilib/librte_pci -I../lib/librte_pci -Idrivers/bus/pci

(quoted diff) +0 -7
-I../drivers/bus/pci -I../drivers/bus/pci/linux -Xclang
-fcolor-diagnostics -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch
-Werror -O2 -g -include rte_config.h -Wextra
-Wcast-qual -Wdeprecated -Wformat-nonliteral -Wformat-security
-Wmissing-declarations -Wmissing-prototypes -Wnested-externs
-Wold-style-definition -Wpointer-arith -Wsign-compare
-Wstrict-prototypes -Wundef -Wwrite-strings -Wno-address-of-pa

cked-member -Wno-missing-field-initializers -D_GNU_SOURCE -fPIC -march=native -DALLOW_EXPERIMENTAL_API -DALLOW_INTERNAL_API -MD - MQ drivers/libtmp_rte_pmd_dlb2_event.a.p/event_dlb2_pf_dlb2_pf.c.o -MF drivers/libtmp_rte_pmd_dlb2_event.a.p/ev ent_dlb2_pf_dlb2_pf.c.o.d -o drivers/libtmp_rte_pmd_dlb2_event.a.p/event_dlb2_pf_dlb2_pf.c.o -c ../drivers/event/dlb2/pf/dlb2_pf.c
In file included from ../drivers/event/dlb2/pf/dlb2_pf.c:36:
../drivers/event/dlb2/pf/../dlb2_inline_fns.h:45:2: error: use of unknown builtin '__builtin_ia32_movntdq' [-Wimplicit-function-declaration]

        __builtin_ia32_movntdq((__v2di *)pp_addr + 0, (__v2di)src_data0);
        ^

../drivers/event/dlb2/pf/../dlb2_inline_fns.h:45:2: note: did you mean '__builtin_ia32_movntq'? /usr/lib/clang/10.0.1/include/xmmintrin.h:2122:3: note:
'__builtin_ia32_movntq' declared here
__builtin_ia32_movntq(__p, __a);
^
In file included from ../drivers/event/dlb2/pf/dlb2_pf.c:36:
../drivers/event/dlb2/pf/../dlb2_inline_fns.h:61:2: error: use of unknown builtin '__builtin_ia32_movntdq' [-Wimplicit-function-declaration]

        __builtin_ia32_movntdq((__v2di *)pp_addr, (__v2di)src_data0);
        ^

2 errors generated.
[2124/2479] Compiling C object drivers/libtmp_rte_pmd_dlb2_event.a.p/event_dlb2_dlb2.c.o
FAILED: drivers/libtmp_rte_pmd_dlb2_event.a.p/event_dlb2_dlb2.c.o ccache clang -Idrivers/libtmp_rte_pmd_dlb2_event.a.p -Idrivers

(quoted diff) +0 -3
-I../drivers -Idrivers/event/dlb2 -I../drivers/event/dlb2
-Ilib/librte_eventdev -I../lib/librte_eventdev -I. -I.. -Iconfig
-I../config -Ilib/librte_eal/include -I../lib/librte_e

al/include -Ilib/librte_eal/linux/include

(quoted diff) +0 -4
-I../lib/librte_eal/linux/include -Ilib/librte_eal/x86/include
-I../lib/librte_eal/x86/include -Ilib/librte_eal/common
-I../lib/librte_eal/common -Ilib/librte_eal -I../lib/librte_eal
-Ilib/librte_kv

args -I../lib/librte_kvargs -Ilib/librte_metrics

(quoted diff) +0 -7
-I../lib/librte_metrics -Ilib/librte_telemetry
-I../lib/librte_telemetry -Ilib/librte_ring -I../lib/librte_ring
-Ilib/librte_ethdev -I../lib/librte_ethdev -Ilib/librte_net
-I../lib/librte_net
 -Ilib/librte_mbuf -I../lib/librte_mbuf -Ilib/librte_mempool
-I../lib/librte_mempool -Ilib/librte_meter -I../lib/librte_meter
-Ilib/librte_hash -I../lib/librte_hash -Ilib/librte_timer
-I../lib/librte_timer -Ilib/librte_cryptodev -I../lib/li

brte_cryptodev -Ilib/librte_pci -I../lib/librte_pci -Idrivers/bus/pci

(quoted diff) +0 -7
-I../drivers/bus/pci -I../drivers/bus/pci/linux -Xclang
-fcolor-diagnostics -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch
-Werror -O2 -g -include rte_config.h -Wextra
-Wcast-qual -Wdeprecated -Wformat-nonliteral -Wformat-security
-Wmissing-declarations -Wmissing-prototypes -Wnested-externs
-Wold-style-definition -Wpointer-arith -Wsign-compare
-Wstrict-prototypes -Wundef -Wwrite-strings -Wno-address-of-pa

cked-member -Wno-missing-field-initializers -D_GNU_SOURCE -fPIC -march=native -DALLOW_EXPERIMENTAL_API -DALLOW_INTERNAL_API -MD - MQ drivers/libtmp_rte_pmd_dlb2_event.a.p/event_dlb2_dlb2.c.o -MF drivers/libtmp_rte_pmd_dlb2_event.a.p/event_dl b2_dlb2.c.o.d -o drivers/libtmp_rte_pmd_dlb2_event.a.p/event_dlb2_dlb2.c.o -c ../drivers/event/dlb2/dlb2.c
In file included from ../drivers/event/dlb2/dlb2.c:35:
../drivers/event/dlb2/dlb2_inline_fns.h:45:2: error: use of unknown builtin '__builtin_ia32_movntdq' [-Wimplicit-function-declaration]

        __builtin_ia32_movntdq((__v2di *)pp_addr + 0, (__v2di)src_data0);
        ^

../drivers/event/dlb2/dlb2_inline_fns.h:45:2: note: did you mean '__builtin_ia32_movntq'? /usr/lib/clang/10.0.1/include/xmmintrin.h:2122:3: note:
'__builtin_ia32_movntq' declared here
__builtin_ia32_movntq(__p, __a);
^
In file included from ../drivers/event/dlb2/dlb2.c:35:
../drivers/event/dlb2/dlb2_inline_fns.h:61:2: error: use of unknown builtin '__builtin_ia32_movntdq' [-Wimplicit-function-declaration]

        __builtin_ia32_movntdq((__v2di *)pp_addr, (__v2di)src_data0);
        ^

2 errors generated.
[2125/2479] Generating rte_common_sfc_efx.sym_chk with a meson_exe.py custom command
ninja: build stopped: subcommand failed.

Quoted 4 lines
---
 drivers/event/dlb2/dlb2.c                      |  532 +++++
 drivers/event/dlb2/dlb2_iface.c                |   28 +
 drivers/event/dlb2/dlb2_iface.h                |   29 +
Quoted 8 lines
 drivers/event/dlb2/meson.build                 |    6 +-
 drivers/event/dlb2/pf/base/dlb2_hw_types.h     |  367 ++++
 drivers/event/dlb2/pf/base/dlb2_mbox.h         |  596 ++++++
 drivers/event/dlb2/pf/base/dlb2_osdep.h        |  247 +++
 drivers/event/dlb2/pf/base/dlb2_osdep_bitmap.h |  440 +++++
 drivers/event/dlb2/pf/base/dlb2_osdep_list.h   |  131 ++
 drivers/event/dlb2/pf/base/dlb2_osdep_types.h  |   31 +
 drivers/event/dlb2/pf/base/dlb2_regs.h         | 2527

++++++++++++++++++++++++

Quoted 64 lines
 drivers/event/dlb2/pf/base/dlb2_resource.c     |  274 +++
 drivers/event/dlb2/pf/base/dlb2_resource.h     | 1913 ++++++++++++++++++
 drivers/event/dlb2/pf/dlb2_main.c              |  615 ++++++
 drivers/event/dlb2/pf/dlb2_main.h              |  106 +
 drivers/event/dlb2/pf/dlb2_pf.c                |  244 +++
 16 files changed, 8085 insertions(+), 1 deletion(-)
 create mode 100644 drivers/event/dlb2/dlb2.c
 create mode 100644 drivers/event/dlb2/dlb2_iface.c
 create mode 100644 drivers/event/dlb2/dlb2_iface.h
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_hw_types.h
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_mbox.h
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_osdep.h
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_osdep_bitmap.h
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_osdep_list.h
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_osdep_types.h
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_regs.h
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_resource.c
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_resource.h
 create mode 100644 drivers/event/dlb2/pf/dlb2_main.c
 create mode 100644 drivers/event/dlb2/pf/dlb2_main.h
 create mode 100644 drivers/event/dlb2/pf/dlb2_pf.c
drivers/event/dlb2/dlb2.c new file +36 -0
new file mode 100644
index 0000000..26985b9
@@ -0,0 +1,532 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2016-2020 Intel Corporation
+ */
+
+#include <assert.h>
+#include <errno.h>
+#include <nmmintrin.h>
+#include <pthread.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/fcntl.h>
+
+#include <rte_common.h>
+#include <rte_config.h>
+#include <rte_cycles.h>
+#include <rte_debug.h>
+#include <rte_dev.h>
+#include <rte_errno.h>
+#include <rte_eventdev.h>
+#include <rte_eventdev_pmd.h>
+#include <rte_io.h>
+#include <rte_kvargs.h>
+#include <rte_log.h>
+#include <rte_malloc.h>
+#include <rte_mbuf.h>
+#include <rte_prefetch.h>
+#include <rte_ring.h>
+#include <rte_string_fns.h>
+
+#include "dlb2_priv.h"
+#include "dlb2_iface.h"
+#include "dlb2_inline_fns.h"
+

drivers/event/dlb2/dlb2.c line 46

Quoted 10 lines
drivers/event/dlb2/dlb2.c new file +10 -0
+#if !defined RTE_ARCH_X86_64
+#error "This implementation only supports RTE_ARCH_X86_64 architecture."
+#endif
+
+/*
+ * Resources exposed to eventdev. Some values overridden at runtime using
+ * values returned by the DLB kernel driver.
+ */
+#if (RTE_EVENT_MAX_QUEUES_PER_DEV > UINT8_MAX)
+#error "RTE_EVENT_MAX_QUEUES_PER_DEV cannot fit in member

max_event_queues"

Quoted 9 lines
drivers/event/dlb2/dlb2.c new file +9 -0
+#endif
+static struct rte_event_dev_info evdev_dlb2_default_info = {
+       .driver_name = "", /* probe will set */
+       .min_dequeue_timeout_ns = DLB2_MIN_DEQUEUE_TIMEOUT_NS,
+       .max_dequeue_timeout_ns = DLB2_MAX_DEQUEUE_TIMEOUT_NS,
+#if (RTE_EVENT_MAX_QUEUES_PER_DEV < DLB2_MAX_NUM_LDB_QUEUES)
+       .max_event_queues = RTE_EVENT_MAX_QUEUES_PER_DEV,
+#else
+       .max_event_queues = DLB2_MAX_NUM_LDB_QUEUES,

drivers/event/dlb2/dlb2.c

Quoted 10 lines
drivers/event/dlb2/dlb2.c new file +10 -0
+#endif
+       .max_event_queue_flows = DLB2_MAX_NUM_FLOWS,
+       .max_event_queue_priority_levels = DLB2_QID_PRIORITIES,
+       .max_event_priority_levels = DLB2_QID_PRIORITIES,
+       .max_event_ports = DLB2_MAX_NUM_LDB_PORTS,
+       .max_event_port_dequeue_depth = DLB2_MAX_CQ_DEPTH,
+       .max_event_port_enqueue_depth = DLB2_MAX_ENQUEUE_DEPTH,
+       .max_event_port_links = DLB2_MAX_NUM_QIDS_PER_LDB_CQ,
+       .max_num_events = DLB2_MAX_NUM_LDB_CREDITS,
+       .max_single_link_event_port_queue_pairs =

DLB2_MAX_NUM_DIR_PORTS,

Quoted 100 lines
drivers/event/dlb2/dlb2.c new file +100 -0
+       .event_dev_cap = (RTE_EVENT_DEV_CAP_QUEUE_QOS |
+                         RTE_EVENT_DEV_CAP_EVENT_QOS |
+                         RTE_EVENT_DEV_CAP_BURST_MODE |
+                         RTE_EVENT_DEV_CAP_DISTRIBUTED_SCHED |
+                         RTE_EVENT_DEV_CAP_IMPLICIT_RELEASE_DISABLE |
+                         RTE_EVENT_DEV_CAP_QUEUE_ALL_TYPES),
+};
+
+struct process_local_port_data
+dlb2_port[DLB2_MAX_NUM_PORTS][DLB2_NUM_PORT_TYPES];
+
+/* override defaults with value(s) provided on command line */
+static void
+dlb2_init_queue_depth_thresholds(struct dlb2_eventdev *dlb2,
+                                int *qid_depth_thresholds)
+{
+       int q;
+
+       for (q = 0; q < DLB2_MAX_NUM_QUEUES; q++) {
+               if (qid_depth_thresholds[q] != 0)
+                       dlb2->ev_queues[q].depth_threshold =
+                               qid_depth_thresholds[q];
+       }
+}
+
+static int
+dlb2_hw_query_resources(struct dlb2_eventdev *dlb2)
+{
+       struct dlb2_hw_dev *handle = &dlb2->qm_instance;
+       struct dlb2_hw_resource_info *dlb2_info = &handle->info;
+       int ret;
+
+       /* Query driver resources provisioned for this device */
+
+       ret = dlb2_iface_get_num_resources(handle,
+                                          &dlb2->hw_rsrc_query_results);
+       if (ret) {
+               DLB2_LOG_ERR("ioctl get dlb2 num resources, err=%d\n", ret);
+               return ret;
+       }
+
+       /* Complete filling in device resource info returned to evdev app,
+        * overriding any default values.
+        * The capabilities (CAPs) were set at compile time.
+        */
+
+       evdev_dlb2_default_info.max_event_queues =
+               dlb2->hw_rsrc_query_results.num_ldb_queues;
+
+       evdev_dlb2_default_info.max_event_ports =
+               dlb2->hw_rsrc_query_results.num_ldb_ports;
+
+       evdev_dlb2_default_info.max_num_events =
+               dlb2->hw_rsrc_query_results.num_ldb_credits;
+
+       /* Save off values used when creating the scheduling domain. */
+
+       handle->info.num_sched_domains =
+               dlb2->hw_rsrc_query_results.num_sched_domains;
+
+       handle->info.hw_rsrc_max.nb_events_limit =
+               dlb2->hw_rsrc_query_results.num_ldb_credits;
+
+       handle->info.hw_rsrc_max.num_queues =
+               dlb2->hw_rsrc_query_results.num_ldb_queues +
+               dlb2->hw_rsrc_query_results.num_dir_ports;
+
+       handle->info.hw_rsrc_max.num_ldb_queues =
+               dlb2->hw_rsrc_query_results.num_ldb_queues;
+
+       handle->info.hw_rsrc_max.num_ldb_ports =
+               dlb2->hw_rsrc_query_results.num_ldb_ports;
+
+       handle->info.hw_rsrc_max.num_dir_ports =
+               dlb2->hw_rsrc_query_results.num_dir_ports;
+
+       handle->info.hw_rsrc_max.reorder_window_size =
+               dlb2->hw_rsrc_query_results.num_hist_list_entries;
+
+       rte_memcpy(dlb2_info, &handle->info.hw_rsrc_max, sizeof(*dlb2_info));
+
+       return 0;
+}
+
+#define RTE_BASE_10 10
+
+static int
+dlb2_string_to_int(int *result, const char *str)
+{
+       long ret;
+       char *endptr;
+
+       if (str == NULL || result == NULL)
+               return -EINVAL;
+
+       errno = 0;
+       ret = strtol(str, &endptr, RTE_BASE_10);
+       if (errno)
+               return -errno;
+

drivers/event/dlb2/dlb2.c

Quoted 10 lines
drivers/event/dlb2/dlb2.c new file +10 -0
+       /* long int and int may be different width for some architectures */
+       if (ret < INT_MIN || ret > INT_MAX || endptr == str)
+               return -EINVAL;
+
+       *result = ret;
+       return 0;
+}
+
+static int
+set_numa_node(const char *key __rte_unused, const char *value, void

*opaque)

Quoted 23 lines
drivers/event/dlb2/dlb2.c new file +23 -0
+{
+       int *socket_id = opaque;
+       int ret;
+
+       ret = dlb2_string_to_int(socket_id, value);
+       if (ret < 0)
+               return ret;
+
+       if (*socket_id > RTE_MAX_NUMA_NODES)
+               return -EINVAL;
+       return 0;
+}
+
+static int
+set_max_num_events(const char *key __rte_unused,
+                  const char *value,
+                  void *opaque)
+{
+       int *max_num_events = opaque;
+       int ret;
+
+       if (value == NULL || opaque == NULL) {
+               DLB2_LOG_ERR("NULL pointer\n");

drivers/event/dlb2/dlb2.c

Quoted 10 lines
drivers/event/dlb2/dlb2.c new file +10 -0
+               return -EINVAL;
+       }
+
+       ret = dlb2_string_to_int(max_num_events, value);
+       if (ret < 0)
+               return ret;
+
+       if (*max_num_events < 0 || *max_num_events >
+                       DLB2_MAX_NUM_LDB_CREDITS) {
+               DLB2_LOG_ERR("dlb2: max_num_events must be between 0 and

%d\n",

Quoted 17 lines
drivers/event/dlb2/dlb2.c new file +17 -0
+                            DLB2_MAX_NUM_LDB_CREDITS);
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+static int
+set_num_dir_credits(const char *key __rte_unused,
+                   const char *value,
+                   void *opaque)
+{
+       int *num_dir_credits = opaque;
+       int ret;
+
+       if (value == NULL || opaque == NULL) {
+               DLB2_LOG_ERR("NULL pointer\n");

drivers/event/dlb2/dlb2.c

Quoted 10 lines
drivers/event/dlb2/dlb2.c new file +10 -0
+               return -EINVAL;
+       }
+
+       ret = dlb2_string_to_int(num_dir_credits, value);
+       if (ret < 0)
+               return ret;
+
+       if (*num_dir_credits < 0 ||
+           *num_dir_credits > DLB2_MAX_NUM_DIR_CREDITS) {
+               DLB2_LOG_ERR("dlb2: num_dir_credits must be between 0 and

%d\n",

Quoted 75 lines
drivers/event/dlb2/dlb2.c new file +75 -0
+                            DLB2_MAX_NUM_DIR_CREDITS);
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+static int
+set_dev_id(const char *key __rte_unused,
+          const char *value,
+          void *opaque)
+{
+       int *dev_id = opaque;
+       int ret;
+
+       if (value == NULL || opaque == NULL) {
+               DLB2_LOG_ERR("NULL pointer\n");
+               return -EINVAL;
+       }
+
+       ret = dlb2_string_to_int(dev_id, value);
+       if (ret < 0)
+               return ret;
+
+       return 0;
+}
+
+static int
+set_cos(const char *key __rte_unused,
+       const char *value,
+       void *opaque)
+{
+       enum dlb2_cos *cos_id = opaque;
+       int x = 0;
+       int ret;
+
+       if (value == NULL || opaque == NULL) {
+               DLB2_LOG_ERR("NULL pointer\n");
+               return -EINVAL;
+       }
+
+       ret = dlb2_string_to_int(&x, value);
+       if (ret < 0)
+               return ret;
+
+       if (x != DLB2_COS_DEFAULT && (x < DLB2_COS_0 || x > DLB2_COS_3)) {
+               DLB2_LOG_ERR(
+                       "COS %d out of range, must be DLB2_COS_DEFAULT or 0-3\n",
+                       x);
+               return -EINVAL;
+       }
+
+       *cos_id = x;
+
+       return 0;
+}
+
+
+static int
+set_qid_depth_thresh(const char *key __rte_unused,
+                    const char *value,
+                    void *opaque)
+{
+       struct dlb2_qid_depth_thresholds *qid_thresh = opaque;
+       int first, last, thresh, i;
+
+       if (value == NULL || opaque == NULL) {
+               DLB2_LOG_ERR("NULL pointer\n");
+               return -EINVAL;
+       }
+
+       /* command line override may take one of the following 3 forms:
+        * qid_depth_thresh=all:<threshold_value> ... all queues
+        * qid_depth_thresh=qidA-qidB:<threshold_value> ... a range of queues
+        * qid_depth_thresh=qid:<threshold_value> ... just one queue

drivers/event/dlb2/dlb2.c

Quoted 10 lines
drivers/event/dlb2/dlb2.c new file +10 -0
+        */
+       if (sscanf(value, "all:%d", &thresh) == 1) {
+               first = 0;
+               last = DLB2_MAX_NUM_QUEUES - 1;
+       } else if (sscanf(value, "%d-%d:%d", &first, &last, &thresh) == 3) {
+               /* we have everything we need */
+       } else if (sscanf(value, "%d:%d", &first, &thresh) == 2) {
+               last = first;
+       } else {
+               DLB2_LOG_ERR("Error parsing qid depth devarg. Should be all:val,

qid-qid:val, or qid:val\n");

Quoted 132 lines
drivers/event/dlb2/dlb2.c new file +71 -0
+               return -EINVAL;
+       }
+
+       if (first > last || first < 0 || last >= DLB2_MAX_NUM_QUEUES) {
+               DLB2_LOG_ERR("Error parsing qid depth devarg, invalid qid value\n");
+               return -EINVAL;
+       }
+
+       if (thresh < 0 || thresh > DLB2_MAX_QUEUE_DEPTH_THRESHOLD) {
+               DLB2_LOG_ERR("Error parsing qid depth devarg, threshold > %d\n",
+                            DLB2_MAX_QUEUE_DEPTH_THRESHOLD);
+               return -EINVAL;
+       }
+
+       for (i = first; i <= last; i++)
+               qid_thresh->val[i] = thresh; /* indexed by qid */
+
+       return 0;
+}
+
+static void
+dlb2_entry_points_init(struct rte_eventdev *dev)
+{
+       RTE_SET_USED(dev);
+
+       /* Eventdev PMD entry points */
+}
+
+int
+dlb2_primary_eventdev_probe(struct rte_eventdev *dev,
+                           const char *name,
+                           struct dlb2_devargs *dlb2_args)
+{
+       struct dlb2_eventdev *dlb2;
+       int err;
+
+       dlb2 = dev->data->dev_private;
+
+       dlb2->event_dev = dev; /* backlink */
+
+       evdev_dlb2_default_info.driver_name = name;
+
+       dlb2->max_num_events_override = dlb2_args->max_num_events;
+       dlb2->num_dir_credits_override = dlb2_args->num_dir_credits_override;
+       dlb2->qm_instance.cos_id = dlb2_args->cos_id;
+
+       err = dlb2_iface_open(&dlb2->qm_instance, name);
+       if (err < 0) {
+               DLB2_LOG_ERR("could not open event hardware device, err=%d\n",
+                            err);
+               return err;
+       }
+
+       err = dlb2_iface_get_device_version(&dlb2->qm_instance,
+                                           &dlb2->revision);
+       if (err < 0) {
+               DLB2_LOG_ERR("dlb2: failed to get the device version, err=%d\n",
+                            err);
+               return err;
+       }
+
+       err = dlb2_hw_query_resources(dlb2);
+       if (err) {
+               DLB2_LOG_ERR("get resources err=%d for %s\n",
+                            err, name);
+               return err;
+       }
+
+       dlb2_iface_hardware_init(&dlb2->qm_instance);
+
+       err = dlb2_iface_get_cq_poll_mode(&dlb2->qm_instance, &dlb2-

poll_mode);

drivers/event/dlb2/dlb2.c new file +60 -0
+       if (err < 0) {
+               DLB2_LOG_ERR("dlb2: failed to get the poll mode, err=%d\n",
+                            err);
+               return err;
+       }
+
+       rte_spinlock_init(&dlb2->qm_instance.resource_lock);
+
+       dlb2_iface_low_level_io_init();
+
+       dlb2_entry_points_init(dev);
+
+       dlb2_init_queue_depth_thresholds(dlb2,
+                                        dlb2_args->qid_depth_thresholds.val);
+
+       return 0;
+}
+
+int
+dlb2_secondary_eventdev_probe(struct rte_eventdev *dev,
+                             const char *name)
+{
+       struct dlb2_eventdev *dlb2;
+       int err;
+
+       dlb2 = dev->data->dev_private;
+
+       evdev_dlb2_default_info.driver_name = name;
+
+       err = dlb2_iface_open(&dlb2->qm_instance, name);
+       if (err < 0) {
+               DLB2_LOG_ERR("could not open event hardware device, err=%d\n",
+                            err);
+               return err;
+       }
+
+       err = dlb2_hw_query_resources(dlb2);
+       if (err) {
+               DLB2_LOG_ERR("get resources err=%d for %s\n",
+                            err, name);
+               return err;
+       }
+
+       dlb2_iface_low_level_io_init();
+
+       dlb2_entry_points_init(dev);
+
+       return 0;
+}
+
+int
+dlb2_parse_params(const char *params,
+                 const char *name,
+                 struct dlb2_devargs *dlb2_args)
+{
+       int ret = 0;
+       static const char * const args[] = { NUMA_NODE_ARG,
+                                            DLB2_MAX_NUM_EVENTS,
+                                            DLB2_NUM_DIR_CREDITS,
+                                            DEV_ID_ARG,

drivers/event/dlb2/dlb2.c

Quoted 10 lines
drivers/event/dlb2/dlb2.c new file +10 -0
+                                            DLB2_QID_DEPTH_THRESH_ARG,
+                                            DLB2_COS_ARG,
+                                            NULL };
+
+       if (params != NULL && params[0] != '\0') {
+               struct rte_kvargs *kvlist = rte_kvargs_parse(params, args);
+
+               if (kvlist == NULL) {
+                       RTE_LOG(INFO, PMD,
+                               "Ignoring unsupported parameters when creating device

'%s'\n",

Quoted 7 lines
drivers/event/dlb2/dlb2.c new file +7 -0
+                               name);
+               } else {
+                       int ret = rte_kvargs_process(kvlist, NUMA_NODE_ARG,
+                                                    set_numa_node,
+                                                    &dlb2_args->socket_id);
+                       if (ret != 0) {
+                               DLB2_LOG_ERR("%s: Error parsing numa node parameter",

drivers/event/dlb2/dlb2.c

Quoted 10 lines
drivers/event/dlb2/dlb2.c new file +10 -0
+                                            name);
+                               rte_kvargs_free(kvlist);
+                               return ret;
+                       }
+
+                       ret = rte_kvargs_process(kvlist, DLB2_MAX_NUM_EVENTS,
+                                                set_max_num_events,
+                                                &dlb2_args->max_num_events);
+                       if (ret != 0) {
+                               DLB2_LOG_ERR("%s: Error parsing max_num_events

parameter",

drivers/event/dlb2/dlb2.c

Quoted 11 lines
drivers/event/dlb2/dlb2.c new file +11 -0
+                                            name);
+                               rte_kvargs_free(kvlist);
+                               return ret;
+                       }
+
+                       ret = rte_kvargs_process(kvlist,
+                                       DLB2_NUM_DIR_CREDITS,
+                                       set_num_dir_credits,
+                                       &dlb2_args->num_dir_credits_override);
+                       if (ret != 0) {
+                               DLB2_LOG_ERR("%s: Error parsing num_dir_credits

parameter",

Quoted 12 lines
drivers/event/dlb2/dlb2.c new file +12 -0
+                                            name);
+                               rte_kvargs_free(kvlist);
+                               return ret;
+                       }
+
+                       ret = rte_kvargs_process(kvlist, DEV_ID_ARG,
+                                                set_dev_id,
+                                                &dlb2_args->dev_id);
+                       if (ret != 0) {
+                               DLB2_LOG_ERR("%s: Error parsing dev_id parameter",
+                                            name);
+                               rte_kvargs_free(kvlist);

drivers/event/dlb2/dlb2.c

Quoted 10 lines
drivers/event/dlb2/dlb2.c new file +10 -0
+                               return ret;
+                       }
+
+                       ret = rte_kvargs_process(
+                                       kvlist,
+                                       DLB2_QID_DEPTH_THRESH_ARG,
+                                       set_qid_depth_thresh,
+                                       &dlb2_args->qid_depth_thresholds);
+                       if (ret != 0) {
+                               DLB2_LOG_ERR("%s: Error parsing qid_depth_thresh

parameter",

Quoted 67 lines
drivers/event/dlb2/dlb2.c new file +21 -0
+                                            name);
+                               rte_kvargs_free(kvlist);
+                               return ret;
+                       }
+
+                       ret = rte_kvargs_process(kvlist, DLB2_COS_ARG,
+                                                set_cos,
+                                                &dlb2_args->cos_id);
+                       if (ret != 0) {
+                               DLB2_LOG_ERR("%s: Error parsing cos parameter",
+                                            name);
+                               rte_kvargs_free(kvlist);
+                               return ret;
+                       }
+
+                       rte_kvargs_free(kvlist);
+               }
+       }
+       return ret;
+}
+RTE_LOG_REGISTER(eventdev_dlb2_log_level, pmd.event.dlb2, NOTICE);
drivers/event/dlb2/dlb2_iface.c new file +28 -0
new file mode 100644
index 0000000..0d93faf
@@ -0,0 +1,28 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2016-2020 Intel Corporation
+ */
+
+#include <stdint.h>
+
+#include "dlb2_priv.h"
+
+/* DLB2 PMD Internal interface function pointers.
+ * If VDEV (bifurcated PMD),  these will resolve to functions that issue ioctls
+ * serviced by DLB kernel module.
+ * If PCI (PF PMD),  these will be implemented locally in user mode.
+ */
+
+void (*dlb2_iface_low_level_io_init)(void);
+
+int (*dlb2_iface_open)(struct dlb2_hw_dev *handle, const char *name);
+
+int (*dlb2_iface_get_device_version)(struct dlb2_hw_dev *handle,
+                                    uint8_t *revision);
+
+void (*dlb2_iface_hardware_init)(struct dlb2_hw_dev *handle);
+
+int (*dlb2_iface_get_cq_poll_mode)(struct dlb2_hw_dev *handle,
+                                  enum dlb2_cq_poll_modes *mode);
+
+int (*dlb2_iface_get_num_resources)(struct dlb2_hw_dev *handle,
+                                   struct dlb2_get_num_resources_args *rsrcs);
drivers/event/dlb2/dlb2_iface.h new file +6 -0
new file mode 100644
index 0000000..4fb416e
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2016-2020 Intel Corporation
+ */
+
+#ifndef _DLB2_IFACE_H_
+#define _DLB2_IFACE_H_

drivers/event/dlb2/dlb2_iface.h line 16

Quoted 10 lines
drivers/event/dlb2/dlb2_iface.h new file +10 -0
+
+/* DLB2 PMD Internal interface function pointers.
+ * If VDEV (bifurcated PMD),  these will resolve to functions that issue ioctls
+ * serviced by DLB kernel module.
+ * If PCI (PF PMD),  these will be implemented locally in user mode.
+ */
+
+extern void (*dlb2_iface_low_level_io_init)(void);
+
+extern int (*dlb2_iface_open)(struct dlb2_hw_dev *handle, const char

*name);

Review

Quoted 31 lines
drivers/event/dlb2/dlb2_iface.h new file +13 -0
+
+extern int (*dlb2_iface_get_device_version)(struct dlb2_hw_dev *handle,
+                                           uint8_t *revision);
+
+extern void (*dlb2_iface_hardware_init)(struct dlb2_hw_dev *handle);
+
+extern int (*dlb2_iface_get_cq_poll_mode)(struct dlb2_hw_dev *handle,
+                                         enum dlb2_cq_poll_modes *mode);
+
+extern int (*dlb2_iface_get_num_resources)(struct dlb2_hw_dev *handle,
+                               struct dlb2_get_num_resources_args *rsrcs);
+
+#endif /* _DLB2_IFACE_H_ */
drivers/event/dlb2/meson.build +5 -1
index 54ba2c8..99b71f9 100644
@@ -1,7 +1,11 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2019-2020 Intel Corporation
 
-sources = files(
+sources = files('dlb2.c',
+               'dlb2_iface.c',
+               'pf/dlb2_main.c',
+               'pf/dlb2_pf.c',
+               'pf/base/dlb2_resource.c'
 )
 
 deps += ['mbuf', 'mempool', 'ring', 'pci', 'bus_pci']
(quoted diff) +0 -0

b/drivers/event/dlb2/pf/base/dlb2_hw_types.h

Quoted 10 lines

new file mode 100644
index 0000000..428a5e8

drivers/event/dlb2/pf/base/dlb2_hw_types.h new file +5 -0
@@ -0,0 +1,367 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2016-2020 Intel Corporation
+ */
+
+#ifndef __DLB2_HW_TYPES_H

drivers/event/dlb2/pf/base/dlb2_hw_types.h line 15

Quoted 10 lines
drivers/event/dlb2/pf/base/dlb2_hw_types.h new file +10 -0
+#define __DLB2_HW_TYPES_H
+
+#include "dlb2_user.h"
+
+#include "dlb2_osdep_list.h"
+#include "dlb2_osdep_types.h"
+
+#define DLB2_MAX_NUM_VDEVS                     16
+#define DLB2_MAX_NUM_DOMAINS                   32
+#define DLB2_MAX_NUM_LDB_QUEUES                        32 /* LDB == load-

balanced */

Quoted 6 lines
drivers/event/dlb2/pf/base/dlb2_hw_types.h new file +6 -0
+#define DLB2_MAX_NUM_DIR_QUEUES                        64 /* DIR == directed */
+#define DLB2_MAX_NUM_LDB_PORTS                 64
+#define DLB2_MAX_NUM_DIR_PORTS                 64
+#define DLB2_MAX_NUM_LDB_CREDITS               (8 * 1024)
+#define DLB2_MAX_NUM_DIR_CREDITS               (2 * 1024)
+#define DLB2_MAX_NUM_HIST_LIST_ENTRIES         2048

drivers/event/dlb2/pf/base/dlb2_hw_types.h

Quoted 10 lines
drivers/event/dlb2/pf/base/dlb2_hw_types.h new file +10 -0
+#define DLB2_MAX_NUM_AQED_ENTRIES              2048
+#define DLB2_MAX_NUM_QIDS_PER_LDB_CQ           8
+#define DLB2_MAX_NUM_SEQUENCE_NUMBER_GROUPS    2
+#define DLB2_MAX_NUM_SEQUENCE_NUMBER_MODES     5
+#define DLB2_QID_PRIORITIES                    8
+#define DLB2_NUM_ARB_WEIGHTS                   8
+#define DLB2_MAX_WEIGHT                                255
+#define DLB2_NUM_COS_DOMAINS                   4
+#define DLB2_MAX_CQ_COMP_CHECK_LOOPS           409600
+#define DLB2_MAX_QID_EMPTY_CHECK_LOOPS         (32 * 64 * 1024 * (800 /

30))

Quoted 36 lines
drivers/event/dlb2/pf/base/dlb2_hw_types.h new file +36 -0
+#ifdef FPGA
+#define DLB2_HZ                                        2000000
+#else
+#define DLB2_HZ                                        800000000
+#endif
+
+#define PCI_DEVICE_ID_INTEL_DLB2_PF 0x2710
+#define PCI_DEVICE_ID_INTEL_DLB2_VF 0x2711
+
+/* Interrupt related macros */
+#define DLB2_PF_NUM_NON_CQ_INTERRUPT_VECTORS 1
+#define DLB2_PF_NUM_CQ_INTERRUPT_VECTORS     64
+#define DLB2_PF_TOTAL_NUM_INTERRUPT_VECTORS \
+       (DLB2_PF_NUM_NON_CQ_INTERRUPT_VECTORS + \
+        DLB2_PF_NUM_CQ_INTERRUPT_VECTORS)
+#define DLB2_PF_NUM_COMPRESSED_MODE_VECTORS \
+       (DLB2_PF_NUM_NON_CQ_INTERRUPT_VECTORS + 1)
+#define DLB2_PF_NUM_PACKED_MODE_VECTORS \
+       DLB2_PF_TOTAL_NUM_INTERRUPT_VECTORS
+#define DLB2_PF_COMPRESSED_MODE_CQ_VECTOR_ID \
+       DLB2_PF_NUM_NON_CQ_INTERRUPT_VECTORS
+
+/* DLB non-CQ interrupts (alarm, mailbox, WDT) */
+#define DLB2_INT_NON_CQ 0
+
+#define DLB2_ALARM_HW_SOURCE_SYS 0
+#define DLB2_ALARM_HW_SOURCE_DLB 1
+
+#define DLB2_ALARM_HW_UNIT_CHP 4
+
+#define DLB2_ALARM_SYS_AID_ILLEGAL_QID         3
+#define DLB2_ALARM_SYS_AID_DISABLED_QID                4
+#define DLB2_ALARM_SYS_AID_ILLEGAL_HCW         5
+#define DLB2_ALARM_HW_CHP_AID_ILLEGAL_ENQ      1
+#define DLB2_ALARM_HW_CHP_AID_EXCESS_TOKEN_POPS 2
+

drivers/event/dlb2/pf/base/dlb2_hw_types.h

Quoted 10 lines
drivers/event/dlb2/pf/base/dlb2_hw_types.h new file +10 -0
+#define DLB2_VF_NUM_NON_CQ_INTERRUPT_VECTORS 1
+#define DLB2_VF_NUM_CQ_INTERRUPT_VECTORS     31
+#define DLB2_VF_BASE_CQ_VECTOR_ID           0
+#define DLB2_VF_LAST_CQ_VECTOR_ID           30
+#define DLB2_VF_MBOX_VECTOR_ID              31
+#define DLB2_VF_TOTAL_NUM_INTERRUPT_VECTORS \
+       (DLB2_VF_NUM_NON_CQ_INTERRUPT_VECTORS + \
+        DLB2_VF_NUM_CQ_INTERRUPT_VECTORS)
+
+#define DLB2_VDEV_MAX_NUM_INTERRUPT_VECTORS

(DLB2_MAX_NUM_LDB_PORTS + \

drivers/event/dlb2/pf/base/dlb2_hw_types.h

Quoted 4 lines
drivers/event/dlb2/pf/base/dlb2_hw_types.h new file +4 -0
+                                            DLB2_MAX_NUM_DIR_PORTS + 1)
+
+/*
+ * Hardware-defined base addresses. Those prefixed 'DLB2_DRV' are only

used by

drivers/event/dlb2/pf/base/dlb2_hw_types.h

Quoted 6 lines
drivers/event/dlb2/pf/base/dlb2_hw_types.h new file +6 -0
+ * the PF driver.
+ */
+#define DLB2_DRV_LDB_PP_BASE   0x2300000
+#define DLB2_DRV_LDB_PP_STRIDE 0x1000
+#define DLB2_DRV_LDB_PP_BOUND  (DLB2_DRV_LDB_PP_BASE + \
+                               DLB2_DRV_LDB_PP_STRIDE *

DLB2_MAX_NUM_LDB_PORTS)

drivers/event/dlb2/pf/base/dlb2_hw_types.h

Quoted 4 lines
drivers/event/dlb2/pf/base/dlb2_hw_types.h new file +4 -0
+#define DLB2_DRV_DIR_PP_BASE   0x2200000
+#define DLB2_DRV_DIR_PP_STRIDE 0x1000
+#define DLB2_DRV_DIR_PP_BOUND  (DLB2_DRV_DIR_PP_BASE + \
+                               DLB2_DRV_DIR_PP_STRIDE *

DLB2_MAX_NUM_DIR_PORTS)

Quoted 106 lines
drivers/event/dlb2/pf/base/dlb2_hw_types.h new file +106 -0
+#define DLB2_LDB_PP_BASE       0x2100000
+#define DLB2_LDB_PP_STRIDE     0x1000
+#define DLB2_LDB_PP_BOUND      (DLB2_LDB_PP_BASE + \
+                               DLB2_LDB_PP_STRIDE * DLB2_MAX_NUM_LDB_PORTS)
+#define DLB2_LDB_PP_OFFS(id)   (DLB2_LDB_PP_BASE + (id) * DLB2_PP_SIZE)
+#define DLB2_DIR_PP_BASE       0x2000000
+#define DLB2_DIR_PP_STRIDE     0x1000
+#define DLB2_DIR_PP_BOUND      (DLB2_DIR_PP_BASE + \
+                               DLB2_DIR_PP_STRIDE * DLB2_MAX_NUM_DIR_PORTS)
+#define DLB2_DIR_PP_OFFS(id)   (DLB2_DIR_PP_BASE + (id) * DLB2_PP_SIZE)
+
+struct dlb2_resource_id {
+       u32 phys_id;
+       u32 virt_id;
+       u8 vdev_owned;
+       u8 vdev_id;
+};
+
+struct dlb2_freelist {
+       u32 base;
+       u32 bound;
+       u32 offset;
+};
+
+static inline u32 dlb2_freelist_count(struct dlb2_freelist *list)
+{
+       return list->bound - list->base - list->offset;
+}
+
+struct dlb2_hcw {
+       u64 data;
+       /* Word 3 */
+       u16 opaque;
+       u8 qid;
+       u8 sched_type:2;
+       u8 priority:3;
+       u8 msg_type:3;
+       /* Word 4 */
+       u16 lock_id;
+       u8 ts_flag:1;
+       u8 rsvd1:2;
+       u8 no_dec:1;
+       u8 cmp_id:4;
+       u8 cq_token:1;
+       u8 qe_comp:1;
+       u8 qe_frag:1;
+       u8 qe_valid:1;
+       u8 int_arm:1;
+       u8 error:1;
+       u8 rsvd:2;
+};
+
+struct dlb2_ldb_queue {
+       struct dlb2_list_entry domain_list;
+       struct dlb2_list_entry func_list;
+       struct dlb2_resource_id id;
+       struct dlb2_resource_id domain_id;
+       u32 num_qid_inflights;
+       u32 aqed_limit;
+       u32 sn_group; /* sn == sequence number */
+       u32 sn_slot;
+       u32 num_mappings;
+       u8 sn_cfg_valid;
+       u8 num_pending_additions;
+       u8 owned;
+       u8 configured;
+};
+
+/*
+ * Directed ports and queues are paired by nature, so the driver tracks them
+ * with a single data structure.
+ */
+struct dlb2_dir_pq_pair {
+       struct dlb2_list_entry domain_list;
+       struct dlb2_list_entry func_list;
+       struct dlb2_resource_id id;
+       struct dlb2_resource_id domain_id;
+       u32 ref_cnt;
+       u8 init_tkn_cnt;
+       u8 queue_configured;
+       u8 port_configured;
+       u8 owned;
+       u8 enabled;
+};
+
+enum dlb2_qid_map_state {
+       /* The slot doesn't contain a valid queue mapping */
+       DLB2_QUEUE_UNMAPPED,
+       /* The slot contains a valid queue mapping */
+       DLB2_QUEUE_MAPPED,
+       /* The driver is mapping a queue into this slot */
+       DLB2_QUEUE_MAP_IN_PROG,
+       /* The driver is unmapping a queue from this slot */
+       DLB2_QUEUE_UNMAP_IN_PROG,
+       /*
+        * The driver is unmapping a queue from this slot, and once complete
+        * will replace it with another mapping.
+        */
+       DLB2_QUEUE_UNMAP_IN_PROG_PENDING_MAP,
+};
+
+struct dlb2_ldb_port_qid_map {
+       enum dlb2_qid_map_state state;
+       u16 qid;
+       u16 pending_qid;
+       u8 priority;

drivers/event/dlb2/pf/base/dlb2_hw_types.h

Quoted 10 lines
drivers/event/dlb2/pf/base/dlb2_hw_types.h new file +10 -0
+       u8 pending_priority;
+};
+
+struct dlb2_ldb_port {
+       struct dlb2_list_entry domain_list;
+       struct dlb2_list_entry func_list;
+       struct dlb2_resource_id id;
+       struct dlb2_resource_id domain_id;
+       /* The qid_map represents the hardware QID mapping state. */
+       struct dlb2_ldb_port_qid_map

qid_map[DLB2_MAX_NUM_QIDS_PER_LDB_CQ];

Quoted 98 lines
drivers/event/dlb2/pf/base/dlb2_hw_types.h new file +98 -0
+       u32 hist_list_entry_base;
+       u32 hist_list_entry_limit;
+       u32 ref_cnt;
+       u8 init_tkn_cnt;
+       u8 num_pending_removals;
+       u8 num_mappings;
+       u8 owned;
+       u8 enabled;
+       u8 configured;
+};
+
+struct dlb2_sn_group {
+       u32 mode;
+       u32 sequence_numbers_per_queue;
+       u32 slot_use_bitmap;
+       u32 id;
+};
+
+static inline bool dlb2_sn_group_full(struct dlb2_sn_group *group)
+{
+       u32 mask[] = {
+               0x0000ffff,  /* 64 SNs per queue */
+               0x000000ff,  /* 128 SNs per queue */
+               0x0000000f,  /* 256 SNs per queue */
+               0x00000003,  /* 512 SNs per queue */
+               0x00000001}; /* 1024 SNs per queue */
+
+       return group->slot_use_bitmap == mask[group->mode];
+}
+
+static inline int dlb2_sn_group_alloc_slot(struct dlb2_sn_group *group)
+{
+       u32 bound[6] = {16, 8, 4, 2, 1};
+       u32 i;
+
+       for (i = 0; i < bound[group->mode]; i++) {
+               if (!(group->slot_use_bitmap & (1 << i))) {
+                       group->slot_use_bitmap |= 1 << i;
+                       return i;
+               }
+       }
+
+       return -1;
+}
+
+static inline void
+dlb2_sn_group_free_slot(struct dlb2_sn_group *group, int slot)
+{
+       group->slot_use_bitmap &= ~(1 << slot);
+}
+
+static inline int dlb2_sn_group_used_slots(struct dlb2_sn_group *group)
+{
+       int i, cnt = 0;
+
+       for (i = 0; i < 32; i++)
+               cnt += !!(group->slot_use_bitmap & (1 << i));
+
+       return cnt;
+}
+
+struct dlb2_hw_domain {
+       struct dlb2_function_resources *parent_func;
+       struct dlb2_list_entry func_list;
+       struct dlb2_list_head used_ldb_queues;
+       struct dlb2_list_head used_ldb_ports[DLB2_NUM_COS_DOMAINS];
+       struct dlb2_list_head used_dir_pq_pairs;
+       struct dlb2_list_head avail_ldb_queues;
+       struct dlb2_list_head avail_ldb_ports[DLB2_NUM_COS_DOMAINS];
+       struct dlb2_list_head avail_dir_pq_pairs;
+       u32 total_hist_list_entries;
+       u32 avail_hist_list_entries;
+       u32 hist_list_entry_base;
+       u32 hist_list_entry_offset;
+       u32 num_ldb_credits;
+       u32 num_dir_credits;
+       u32 num_avail_aqed_entries;
+       u32 num_used_aqed_entries;
+       struct dlb2_resource_id id;
+       int num_pending_removals;
+       int num_pending_additions;
+       u8 configured;
+       u8 started;
+};
+
+struct dlb2_bitmap;
+
+struct dlb2_function_resources {
+       struct dlb2_list_head avail_domains;
+       struct dlb2_list_head used_domains;
+       struct dlb2_list_head avail_ldb_queues;
+       struct dlb2_list_head avail_ldb_ports[DLB2_NUM_COS_DOMAINS];
+       struct dlb2_list_head avail_dir_pq_pairs;
+       struct dlb2_bitmap *avail_hist_list_entries;
+       u32 num_avail_domains;
+       u32 num_avail_ldb_queues;
+       u32 num_avail_ldb_ports[DLB2_NUM_COS_DOMAINS];
+       u32 num_avail_dir_pq_pairs;

drivers/event/dlb2/pf/base/dlb2_hw_types.h

Quoted 10 lines
drivers/event/dlb2/pf/base/dlb2_hw_types.h new file +10 -0
+       u32 num_avail_qed_entries;
+       u32 num_avail_dqed_entries;
+       u32 num_avail_aqed_entries;
+       u8 locked; /* (VDEV only) */
+};
+
+/*
+ * After initialization, each resource in dlb2_hw_resources is located in one
+ * of the following lists:
+ * -- The PF's available resources list. These are unconfigured resources

owned

drivers/event/dlb2/pf/base/dlb2_hw_types.h

Quoted 4 lines
drivers/event/dlb2/pf/base/dlb2_hw_types.h new file +4 -0
+ *     by the PF and not allocated to a dlb2 scheduling domain.
+ * -- A VDEV's available resources list. These are VDEV-owned unconfigured
+ *     resources not allocated to a dlb2 scheduling domain.
+ * -- A domain's available resources list. These are domain-owned

unconfigured

drivers/event/dlb2/pf/base/dlb2_hw_types.h

Quoted 5 lines
drivers/event/dlb2/pf/base/dlb2_hw_types.h new file +5 -0
+ *     resources.
+ * -- A domain's used resources list. These are are domain-owned configured
+ *     resources.
+ *
+ * A resource moves to a new list when a VDEV or domain is created or

destroyed,

drivers/event/dlb2/pf/base/dlb2_hw_types.h

Quoted 7 lines
drivers/event/dlb2/pf/base/dlb2_hw_types.h new file +7 -0
+ * or when the resource is configured.
+ */
+struct dlb2_hw_resources {
+       struct dlb2_ldb_queue ldb_queues[DLB2_MAX_NUM_LDB_QUEUES];
+       struct dlb2_ldb_port ldb_ports[DLB2_MAX_NUM_LDB_PORTS];
+       struct dlb2_dir_pq_pair dir_pq_pairs[DLB2_MAX_NUM_DIR_PORTS];
+       struct dlb2_sn_group

sn_groups[DLB2_MAX_NUM_SEQUENCE_NUMBER_GROUPS];

Review

Quoted 37 lines
drivers/event/dlb2/pf/base/dlb2_hw_types.h new file +36 -0
+};
+
+struct dlb2_mbox {
+       u32 *mbox;
+       u32 *isr_in_progress;
+};
+
+struct dlb2_sw_mbox {
+       struct dlb2_mbox vdev_to_pf;
+       struct dlb2_mbox pf_to_vdev;
+       void (*pf_to_vdev_inject)(void *arg);
+       void *pf_to_vdev_inject_arg;
+};
+
+struct dlb2_hw {
+       /* BAR 0 address */
+       void  *csr_kva;
+       unsigned long csr_phys_addr;
+       /* BAR 2 address */
+       void  *func_kva;
+       unsigned long func_phys_addr;
+
+       /* Resource tracking */
+       struct dlb2_hw_resources rsrcs;
+       struct dlb2_function_resources pf;
+       struct dlb2_function_resources vdev[DLB2_MAX_NUM_VDEVS];
+       struct dlb2_hw_domain domains[DLB2_MAX_NUM_DOMAINS];
+       u8 cos_reservation[DLB2_NUM_COS_DOMAINS];
+
+       /* Virtualization */
+       int virt_mode;
+       struct dlb2_sw_mbox mbox[DLB2_MAX_NUM_VDEVS];
+       unsigned int pasid[DLB2_MAX_NUM_VDEVS];
+};
+
+#endif /* __DLB2_HW_TYPES_H */
(quoted diff) +0 -0

b/drivers/event/dlb2/pf/base/dlb2_mbox.h

Quoted 11 lines

new file mode 100644
index 0000000..ce462c0

drivers/event/dlb2/pf/base/dlb2_mbox.h new file +6 -0
@@ -0,0 +1,596 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2016-2020 Intel Corporation
+ */
+
+#ifndef __DLB2_BASE_DLB2_MBOX_H
+#define __DLB2_BASE_DLB2_MBOX_H

drivers/event/dlb2/pf/base/dlb2_mbox.h line 16

Quoted 10 lines
drivers/event/dlb2/pf/base/dlb2_mbox.h new file +10 -0
+
+#include "dlb2_osdep_types.h"
+#include "dlb2_regs.h"
+
+#define DLB2_MBOX_INTERFACE_VERSION 1
+
+/*
+ * The PF uses its PF->VF mailbox to send responses to VF requests, as well as
+ * to send requests of its own (e.g. notifying a VF of an impending FLR).
+ * To avoid communication race conditions, e.g. the PF sends a response and

then

drivers/event/dlb2/pf/base/dlb2_mbox.h

Quoted 6 lines
drivers/event/dlb2/pf/base/dlb2_mbox.h new file +6 -0
+ * sends a request before the VF reads the response, the PF->VF mailbox is
+ * divided into two sections:
+ * - Bytes 0-47: PF responses
+ * - Bytes 48-63: PF requests
+ *
+ * Partitioning the PF->VF mailbox allows responses and requests to occupy

the

drivers/event/dlb2/pf/base/dlb2_mbox.h

Quoted 8 lines
drivers/event/dlb2/pf/base/dlb2_mbox.h new file +8 -0
+ * mailbox simultaneously.
+ */
+#define DLB2_PF2VF_RESP_BYTES    48
+#define DLB2_PF2VF_RESP_BASE     0
+#define DLB2_PF2VF_RESP_BASE_WORD (DLB2_PF2VF_RESP_BASE / 4)
+
+#define DLB2_PF2VF_REQ_BYTES     16
+#define DLB2_PF2VF_REQ_BASE      (DLB2_PF2VF_RESP_BASE +

DLB2_PF2VF_RESP_BYTES)

Quoted 4 lines
drivers/event/dlb2/pf/base/dlb2_mbox.h new file +4 -0
+#define DLB2_PF2VF_REQ_BASE_WORD  (DLB2_PF2VF_REQ_BASE / 4)
+
+/*
+ * Similarly, the VF->PF mailbox is divided into two sections:

drivers/event/dlb2/pf/base/dlb2_mbox.h

Quoted 10 lines
drivers/event/dlb2/pf/base/dlb2_mbox.h new file +10 -0
+ * - Bytes 0-239: VF requests
+ * -- (Bytes 0-3 are unused due to a hardware errata)
+ * - Bytes 240-255: VF responses
+ */
+#define DLB2_VF2PF_REQ_BYTES    236
+#define DLB2_VF2PF_REQ_BASE     4
+#define DLB2_VF2PF_REQ_BASE_WORD (DLB2_VF2PF_REQ_BASE / 4)
+
+#define DLB2_VF2PF_RESP_BYTES    16
+#define DLB2_VF2PF_RESP_BASE     (DLB2_VF2PF_REQ_BASE +

DLB2_VF2PF_REQ_BYTES)

Quoted 425 lines
drivers/event/dlb2/pf/base/dlb2_mbox.h new file +425 -0
+#define DLB2_VF2PF_RESP_BASE_WORD (DLB2_VF2PF_RESP_BASE / 4)
+
+/* VF-initiated commands */
+enum dlb2_mbox_cmd_type {
+       DLB2_MBOX_CMD_REGISTER,
+       DLB2_MBOX_CMD_UNREGISTER,
+       DLB2_MBOX_CMD_GET_NUM_RESOURCES,
+       DLB2_MBOX_CMD_CREATE_SCHED_DOMAIN,
+       DLB2_MBOX_CMD_RESET_SCHED_DOMAIN,
+       DLB2_MBOX_CMD_CREATE_LDB_QUEUE,
+       DLB2_MBOX_CMD_CREATE_DIR_QUEUE,
+       DLB2_MBOX_CMD_CREATE_LDB_PORT,
+       DLB2_MBOX_CMD_CREATE_DIR_PORT,
+       DLB2_MBOX_CMD_ENABLE_LDB_PORT,
+       DLB2_MBOX_CMD_DISABLE_LDB_PORT,
+       DLB2_MBOX_CMD_ENABLE_DIR_PORT,
+       DLB2_MBOX_CMD_DISABLE_DIR_PORT,
+       DLB2_MBOX_CMD_LDB_PORT_OWNED_BY_DOMAIN,
+       DLB2_MBOX_CMD_DIR_PORT_OWNED_BY_DOMAIN,
+       DLB2_MBOX_CMD_MAP_QID,
+       DLB2_MBOX_CMD_UNMAP_QID,
+       DLB2_MBOX_CMD_START_DOMAIN,
+       DLB2_MBOX_CMD_ENABLE_LDB_PORT_INTR,
+       DLB2_MBOX_CMD_ENABLE_DIR_PORT_INTR,
+       DLB2_MBOX_CMD_ARM_CQ_INTR,
+       DLB2_MBOX_CMD_GET_NUM_USED_RESOURCES,
+       DLB2_MBOX_CMD_GET_SN_ALLOCATION,
+       DLB2_MBOX_CMD_GET_LDB_QUEUE_DEPTH,
+       DLB2_MBOX_CMD_GET_DIR_QUEUE_DEPTH,
+       DLB2_MBOX_CMD_PENDING_PORT_UNMAPS,
+       DLB2_MBOX_CMD_GET_COS_BW,
+       DLB2_MBOX_CMD_GET_SN_OCCUPANCY,
+       DLB2_MBOX_CMD_QUERY_CQ_POLL_MODE,
+
+       /* NUM_QE_CMD_TYPES must be last */
+       NUM_DLB2_MBOX_CMD_TYPES,
+};
+
+static const char dlb2_mbox_cmd_type_strings[][128] = {
+       "DLB2_MBOX_CMD_REGISTER",
+       "DLB2_MBOX_CMD_UNREGISTER",
+       "DLB2_MBOX_CMD_GET_NUM_RESOURCES",
+       "DLB2_MBOX_CMD_CREATE_SCHED_DOMAIN",
+       "DLB2_MBOX_CMD_RESET_SCHED_DOMAIN",
+       "DLB2_MBOX_CMD_CREATE_LDB_QUEUE",
+       "DLB2_MBOX_CMD_CREATE_DIR_QUEUE",
+       "DLB2_MBOX_CMD_CREATE_LDB_PORT",
+       "DLB2_MBOX_CMD_CREATE_DIR_PORT",
+       "DLB2_MBOX_CMD_ENABLE_LDB_PORT",
+       "DLB2_MBOX_CMD_DISABLE_LDB_PORT",
+       "DLB2_MBOX_CMD_ENABLE_DIR_PORT",
+       "DLB2_MBOX_CMD_DISABLE_DIR_PORT",
+       "DLB2_MBOX_CMD_LDB_PORT_OWNED_BY_DOMAIN",
+       "DLB2_MBOX_CMD_DIR_PORT_OWNED_BY_DOMAIN",
+       "DLB2_MBOX_CMD_MAP_QID",
+       "DLB2_MBOX_CMD_UNMAP_QID",
+       "DLB2_MBOX_CMD_START_DOMAIN",
+       "DLB2_MBOX_CMD_ENABLE_LDB_PORT_INTR",
+       "DLB2_MBOX_CMD_ENABLE_DIR_PORT_INTR",
+       "DLB2_MBOX_CMD_ARM_CQ_INTR",
+       "DLB2_MBOX_CMD_GET_NUM_USED_RESOURCES",
+       "DLB2_MBOX_CMD_GET_SN_ALLOCATION",
+       "DLB2_MBOX_CMD_GET_LDB_QUEUE_DEPTH",
+       "DLB2_MBOX_CMD_GET_DIR_QUEUE_DEPTH",
+       "DLB2_MBOX_CMD_PENDING_PORT_UNMAPS",
+       "DLB2_MBOX_CMD_GET_COS_BW",
+       "DLB2_MBOX_CMD_GET_SN_OCCUPANCY",
+       "DLB2_MBOX_CMD_QUERY_CQ_POLL_MODE",
+};
+
+/* PF-initiated commands */
+enum dlb2_mbox_vf_cmd_type {
+       DLB2_MBOX_VF_CMD_DOMAIN_ALERT,
+       DLB2_MBOX_VF_CMD_NOTIFICATION,
+       DLB2_MBOX_VF_CMD_IN_USE,
+
+       /* NUM_DLB2_MBOX_VF_CMD_TYPES must be last */
+       NUM_DLB2_MBOX_VF_CMD_TYPES,
+};
+
+static const char dlb2_mbox_vf_cmd_type_strings[][128] = {
+       "DLB2_MBOX_VF_CMD_DOMAIN_ALERT",
+       "DLB2_MBOX_VF_CMD_NOTIFICATION",
+       "DLB2_MBOX_VF_CMD_IN_USE",
+};
+
+#define DLB2_MBOX_CMD_TYPE(hdr) \
+       (((struct dlb2_mbox_req_hdr *)hdr)->type)
+#define DLB2_MBOX_CMD_STRING(hdr) \
+       dlb2_mbox_cmd_type_strings[DLB2_MBOX_CMD_TYPE(hdr)]
+
+enum dlb2_mbox_status_type {
+       DLB2_MBOX_ST_SUCCESS,
+       DLB2_MBOX_ST_INVALID_CMD_TYPE,
+       DLB2_MBOX_ST_VERSION_MISMATCH,
+       DLB2_MBOX_ST_INVALID_OWNER_VF,
+};
+
+static const char dlb2_mbox_status_type_strings[][128] = {
+       "DLB2_MBOX_ST_SUCCESS",
+       "DLB2_MBOX_ST_INVALID_CMD_TYPE",
+       "DLB2_MBOX_ST_VERSION_MISMATCH",
+       "DLB2_MBOX_ST_INVALID_OWNER_VF",
+};
+
+#define DLB2_MBOX_ST_TYPE(hdr) \
+       (((struct dlb2_mbox_resp_hdr *)hdr)->status)
+#define DLB2_MBOX_ST_STRING(hdr) \
+       dlb2_mbox_status_type_strings[DLB2_MBOX_ST_TYPE(hdr)]
+
+/* This structure is always the first field in a request structure */
+struct dlb2_mbox_req_hdr {
+       u32 type;
+};
+
+/* This structure is always the first field in a response structure */
+struct dlb2_mbox_resp_hdr {
+       u32 status;
+};
+
+struct dlb2_mbox_register_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u16 min_interface_version;
+       u16 max_interface_version;
+};
+
+struct dlb2_mbox_register_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 interface_version;
+       u8 pf_id;
+       u8 vf_id;
+       u8 is_auxiliary_vf;
+       u8 primary_vf_id;
+       u32 padding;
+};
+
+struct dlb2_mbox_unregister_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 padding;
+};
+
+struct dlb2_mbox_unregister_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 padding;
+};
+
+struct dlb2_mbox_get_num_resources_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 padding;
+};
+
+struct dlb2_mbox_get_num_resources_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 error_code;
+       u16 num_sched_domains;
+       u16 num_ldb_queues;
+       u16 num_ldb_ports;
+       u16 num_cos_ldb_ports[4];
+       u16 num_dir_ports;
+       u32 num_atomic_inflights;
+       u32 num_hist_list_entries;
+       u32 max_contiguous_hist_list_entries;
+       u16 num_ldb_credits;
+       u16 num_dir_credits;
+};
+
+struct dlb2_mbox_create_sched_domain_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 num_ldb_queues;
+       u32 num_ldb_ports;
+       u32 num_cos_ldb_ports[4];
+       u32 num_dir_ports;
+       u32 num_atomic_inflights;
+       u32 num_hist_list_entries;
+       u32 num_ldb_credits;
+       u32 num_dir_credits;
+       u8 cos_strict;
+       u8 padding0[3];
+       u32 padding1;
+};
+
+struct dlb2_mbox_create_sched_domain_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 error_code;
+       u32 status;
+       u32 id;
+};
+
+struct dlb2_mbox_reset_sched_domain_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 id;
+};
+
+struct dlb2_mbox_reset_sched_domain_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 error_code;
+};
+
+struct dlb2_mbox_create_ldb_queue_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 domain_id;
+       u32 num_sequence_numbers;
+       u32 num_qid_inflights;
+       u32 num_atomic_inflights;
+       u32 lock_id_comp_level;
+       u32 depth_threshold;
+       u32 padding;
+};
+
+struct dlb2_mbox_create_ldb_queue_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 error_code;
+       u32 status;
+       u32 id;
+};
+
+struct dlb2_mbox_create_dir_queue_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 domain_id;
+       u32 port_id;
+       u32 depth_threshold;
+};
+
+struct dlb2_mbox_create_dir_queue_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 error_code;
+       u32 status;
+       u32 id;
+};
+
+struct dlb2_mbox_create_ldb_port_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 domain_id;
+       u16 cq_depth;
+       u16 cq_history_list_size;
+       u8 cos_id;
+       u8 cos_strict;
+       u16 padding1;
+       u64 cq_base_address;
+};
+
+struct dlb2_mbox_create_ldb_port_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 error_code;
+       u32 status;
+       u32 id;
+};
+
+struct dlb2_mbox_create_dir_port_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 domain_id;
+       u64 cq_base_address;
+       u16 cq_depth;
+       u16 padding0;
+       s32 queue_id;
+};
+
+struct dlb2_mbox_create_dir_port_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 error_code;
+       u32 status;
+       u32 id;
+};
+
+struct dlb2_mbox_enable_ldb_port_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 domain_id;
+       u32 port_id;
+       u32 padding;
+};
+
+struct dlb2_mbox_enable_ldb_port_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 error_code;
+       u32 status;
+       u32 padding;
+};
+
+struct dlb2_mbox_disable_ldb_port_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 domain_id;
+       u32 port_id;
+       u32 padding;
+};
+
+struct dlb2_mbox_disable_ldb_port_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 error_code;
+       u32 status;
+       u32 padding;
+};
+
+struct dlb2_mbox_enable_dir_port_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 domain_id;
+       u32 port_id;
+       u32 padding;
+};
+
+struct dlb2_mbox_enable_dir_port_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 error_code;
+       u32 status;
+       u32 padding;
+};
+
+struct dlb2_mbox_disable_dir_port_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 domain_id;
+       u32 port_id;
+       u32 padding;
+};
+
+struct dlb2_mbox_disable_dir_port_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 error_code;
+       u32 status;
+       u32 padding;
+};
+
+struct dlb2_mbox_ldb_port_owned_by_domain_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 domain_id;
+       u32 port_id;
+       u32 padding;
+};
+
+struct dlb2_mbox_ldb_port_owned_by_domain_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       s32 owned;
+};
+
+struct dlb2_mbox_dir_port_owned_by_domain_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 domain_id;
+       u32 port_id;
+       u32 padding;
+};
+
+struct dlb2_mbox_dir_port_owned_by_domain_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       s32 owned;
+};
+
+struct dlb2_mbox_map_qid_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 domain_id;
+       u32 port_id;
+       u32 qid;
+       u32 priority;
+       u32 padding0;
+};
+
+struct dlb2_mbox_map_qid_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 error_code;
+       u32 status;
+       u32 id;
+};
+
+struct dlb2_mbox_unmap_qid_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 domain_id;
+       u32 port_id;
+       u32 qid;
+};
+
+struct dlb2_mbox_unmap_qid_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 error_code;
+       u32 status;
+       u32 padding;
+};
+
+struct dlb2_mbox_start_domain_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 domain_id;
+};
+
+struct dlb2_mbox_start_domain_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 error_code;
+       u32 status;
+       u32 padding;
+};
+
+struct dlb2_mbox_enable_ldb_port_intr_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u16 port_id;
+       u16 thresh;
+       u16 vector;
+       u16 owner_vf;
+       u16 reserved[2];
+};
+
+struct dlb2_mbox_enable_ldb_port_intr_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 error_code;
+       u32 status;
+       u32 padding;
+};
+
+struct dlb2_mbox_enable_dir_port_intr_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u16 port_id;
+       u16 thresh;
+       u16 vector;
+       u16 owner_vf;
+       u16 reserved[2];
+};
+
+struct dlb2_mbox_enable_dir_port_intr_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 error_code;
+       u32 status;
+       u32 padding;
+};
+
+struct dlb2_mbox_arm_cq_intr_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 domain_id;
+       u32 port_id;
+       u32 is_ldb;
+};
+

drivers/event/dlb2/pf/base/dlb2_mbox.h

Quoted 10 lines
drivers/event/dlb2/pf/base/dlb2_mbox.h new file +10 -0
+struct dlb2_mbox_arm_cq_intr_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 error_code;
+       u32 status;
+       u32 padding0;
+};
+
+/*
+ * The alert_id and aux_alert_data follows the format of the alerts defined in
+ * dlb2_types.h. The alert id contains an enum dlb2_domain_alert_id value,

and

Review

Quoted 118 lines
drivers/event/dlb2/pf/base/dlb2_mbox.h new file +117 -0
+ * the aux_alert_data value varies depending on the alert.
+ */
+struct dlb2_mbox_vf_alert_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 domain_id;
+       u32 alert_id;
+       u32 aux_alert_data;
+};
+
+enum dlb2_mbox_vf_notification_type {
+       DLB2_MBOX_VF_NOTIFICATION_PRE_RESET,
+       DLB2_MBOX_VF_NOTIFICATION_POST_RESET,
+
+       /* NUM_DLB2_MBOX_VF_NOTIFICATION_TYPES must be last */
+       NUM_DLB2_MBOX_VF_NOTIFICATION_TYPES,
+};
+
+struct dlb2_mbox_vf_notification_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 notification;
+};
+
+struct dlb2_mbox_vf_in_use_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 padding;
+};
+
+struct dlb2_mbox_vf_in_use_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 in_use;
+};
+
+struct dlb2_mbox_get_sn_allocation_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 group_id;
+};
+
+struct dlb2_mbox_get_sn_allocation_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 num;
+};
+
+struct dlb2_mbox_get_ldb_queue_depth_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 domain_id;
+       u32 queue_id;
+       u32 padding;
+};
+
+struct dlb2_mbox_get_ldb_queue_depth_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 error_code;
+       u32 status;
+       u32 depth;
+};
+
+struct dlb2_mbox_get_dir_queue_depth_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 domain_id;
+       u32 queue_id;
+       u32 padding;
+};
+
+struct dlb2_mbox_get_dir_queue_depth_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 error_code;
+       u32 status;
+       u32 depth;
+};
+
+struct dlb2_mbox_pending_port_unmaps_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 domain_id;
+       u32 port_id;
+       u32 padding;
+};
+
+struct dlb2_mbox_pending_port_unmaps_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 error_code;
+       u32 status;
+       u32 num;
+};
+
+struct dlb2_mbox_get_cos_bw_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 cos_id;
+};
+
+struct dlb2_mbox_get_cos_bw_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 num;
+};
+
+struct dlb2_mbox_get_sn_occupancy_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 group_id;
+};
+
+struct dlb2_mbox_get_sn_occupancy_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 num;
+};
+
+struct dlb2_mbox_query_cq_poll_mode_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 padding;
+};
+
+struct dlb2_mbox_query_cq_poll_mode_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 error_code;
+       u32 status;
+       u32 mode;
+};
+
+#endif /* __DLB2_BASE_DLB2_MBOX_H */
(quoted diff) +0 -0

b/drivers/event/dlb2/pf/base/dlb2_osdep.h

Quoted 23 lines

new file mode 100644
index 0000000..43f2125

drivers/event/dlb2/pf/base/dlb2_osdep.h new file +18 -0
@@ -0,0 +1,247 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2016-2020 Intel Corporation
+ */
+
+#ifndef __DLB2_OSDEP_H
+#define __DLB2_OSDEP_H
+
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+#include <pthread.h>
+
+#include <rte_string_fns.h>
+#include <rte_cycles.h>
+#include <rte_io.h>
+#include <rte_log.h>
+#include <rte_spinlock.h>
+#include "../dlb2_main.h"

drivers/event/dlb2/pf/base/dlb2_osdep.h line 28

Quoted 10 lines
drivers/event/dlb2/pf/base/dlb2_osdep.h new file +10 -0
+#include "dlb2_resource.h"
+#include "../../dlb2_log.h"
+#include "../../dlb2_user.h"
+
+
+#define DLB2_PCI_REG_READ(addr)        rte_read32((void *)addr)
+#define DLB2_PCI_REG_WRITE(reg, value) rte_write32(value, (void *)reg)
+
+/* Read/write register 'reg' in the CSR BAR space */
+#define DLB2_CSR_REG_ADDR(a, reg) ((void *)((uintptr_t)(a)->csr_kva +

(reg)))

drivers/event/dlb2/pf/base/dlb2_osdep.h

Quoted 7 lines
drivers/event/dlb2/pf/base/dlb2_osdep.h new file +7 -0
+#define DLB2_CSR_RD(hw, reg) \
+       DLB2_PCI_REG_READ(DLB2_CSR_REG_ADDR((hw), (reg)))
+#define DLB2_CSR_WR(hw, reg, value) \
+       DLB2_PCI_REG_WRITE(DLB2_CSR_REG_ADDR((hw), (reg)), (value))
+
+/* Read/write register 'reg' in the func BAR space */
+#define DLB2_FUNC_REG_ADDR(a, reg) ((void *)((uintptr_t)(a)->func_kva +

(reg)))

Quoted 28 lines
drivers/event/dlb2/pf/base/dlb2_osdep.h new file +28 -0
+#define DLB2_FUNC_RD(hw, reg) \
+       DLB2_PCI_REG_READ(DLB2_FUNC_REG_ADDR((hw), (reg)))
+#define DLB2_FUNC_WR(hw, reg, value) \
+       DLB2_PCI_REG_WRITE(DLB2_FUNC_REG_ADDR((hw), (reg)), (value))
+
+/* Map to PMDs logging interface */
+#define DLB2_ERR(dev, fmt, args...) \
+       DLB2_LOG_ERR(fmt, ## args)
+
+#define DLB2_INFO(dev, fmt, args...) \
+       DLB2_LOG_INFO(fmt, ## args)
+
+#define DLB2_DEBUG(dev, fmt, args...) \
+       DLB2_LOG_DBG(fmt, ## args)
+
+/**
+ * os_udelay() - busy-wait for a number of microseconds
+ * @usecs: delay duration.
+ */
+static inline void os_udelay(int usecs)
+{
+       rte_delay_us(usecs);
+}
+
+/**
+ * os_msleep() - sleep for a number of milliseconds
+ * @usecs: delay duration.
+ */

drivers/event/dlb2/pf/base/dlb2_osdep.h

Quoted 10 lines
drivers/event/dlb2/pf/base/dlb2_osdep.h new file +10 -0
+static inline void os_msleep(int msecs)
+{
+       rte_delay_ms(msecs);
+}
+
+#define DLB2_PP_BASE(__is_ldb) \
+       ((__is_ldb) ? DLB2_LDB_PP_BASE : DLB2_DIR_PP_BASE)
+
+/**
+ * os_map_producer_port() - map a producer port into the caller's address

space

Quoted 18 lines
drivers/event/dlb2/pf/base/dlb2_osdep.h new file +18 -0
+ * @hw: dlb2_hw handle for a particular device.
+ * @port_id: port ID
+ * @is_ldb: true for load-balanced port, false for a directed port
+ *
+ * This function maps the requested producer port memory into the caller's
+ * address space.
+ *
+ * Return:
+ * Returns the base address at which the PP memory was mapped, else NULL.
+ */
+static inline void *os_map_producer_port(struct dlb2_hw *hw,
+                                        u8 port_id,
+                                        bool is_ldb)
+{
+       uint64_t addr;
+       uint64_t pp_dma_base;
+
+       pp_dma_base = (uintptr_t)hw->func_kva + DLB2_PP_BASE(is_ldb);

drivers/event/dlb2/pf/base/dlb2_osdep.h

Quoted 10 lines
drivers/event/dlb2/pf/base/dlb2_osdep.h new file +10 -0
+       addr = (pp_dma_base + (PAGE_SIZE * port_id));
+
+       return (void *)(uintptr_t)addr;
+}
+
+/**
+ * os_unmap_producer_port() - unmap a producer port
+ * @addr: mapped producer port address
+ *
+ * This function undoes os_map_producer_port() by unmapping the producer

port

Quoted 92 lines
drivers/event/dlb2/pf/base/dlb2_osdep.h new file +92 -0
+ * memory from the caller's address space.
+ *
+ * Return:
+ * Returns the base address at which the PP memory was mapped, else NULL.
+ */
+static inline void os_unmap_producer_port(struct dlb2_hw *hw, void *addr)
+{
+       RTE_SET_USED(hw);
+       RTE_SET_USED(addr);
+}
+
+/**
+ * os_fence_hcw() - fence an HCW to ensure it arrives at the device
+ * @hw: dlb2_hw handle for a particular device.
+ * @pp_addr: producer port address
+ */
+static inline void os_fence_hcw(struct dlb2_hw *hw, u64 *pp_addr)
+{
+       RTE_SET_USED(hw);
+
+       /* To ensure outstanding HCWs reach the device, read the PP address. IA
+        * memory ordering prevents reads from passing older writes, and the
+        * mfence also ensures this.
+        */
+       rte_mb();
+
+       *(volatile u64 *)pp_addr;
+}
+
+/**
+ * os_enqueue_four_hcws() - enqueue four HCWs to DLB
+ * @hw: dlb2_hw handle for a particular device.
+ * @hcw: pointer to the 64B-aligned contiguous HCW memory
+ * @addr: producer port address
+ */
+static inline void os_enqueue_four_hcws(struct dlb2_hw *hw,
+                                       struct dlb2_hcw *hcw,
+                                       void *addr)
+{
+       struct dlb2_dev *dlb2_dev;
+
+       dlb2_dev = container_of(hw, struct dlb2_dev, hw);
+
+       dlb2_dev->enqueue_four(hcw, addr);
+}
+
+/**
+ * DLB2_HW_ERR() - log an error message
+ * @dlb2: dlb2_hw handle for a particular device.
+ * @...: variable string args.
+ */
+#define DLB2_HW_ERR(dlb2, ...) do {    \
+       RTE_SET_USED(dlb2);             \
+       DLB2_ERR(dlb2, __VA_ARGS__);    \
+} while (0)
+
+/**
+ * DLB2_HW_DBG() - log an info message
+ * @dlb2: dlb2_hw handle for a particular device.
+ * @...: variable string args.
+ */
+#define DLB2_HW_DBG(dlb2, ...) do {    \
+       RTE_SET_USED(dlb2);             \
+       DLB2_DEBUG(dlb2, __VA_ARGS__);  \
+} while (0)
+
+/* The callback runs until it completes all outstanding QID->CQ
+ * map and unmap requests. To prevent deadlock, this function gives other
+ * threads a chance to grab the resource mutex and configure hardware.
+ */
+static void *dlb2_complete_queue_map_unmap(void *__args)
+{
+       struct dlb2_dev *dlb2_dev = (struct dlb2_dev *)__args;
+       int ret;
+
+       while (1) {
+               rte_spinlock_lock(&dlb2_dev->resource_mutex);
+
+               ret = dlb2_finish_unmap_qid_procedures(&dlb2_dev->hw);
+               ret += dlb2_finish_map_qid_procedures(&dlb2_dev->hw);
+
+               if (ret != 0) {
+                       rte_spinlock_unlock(&dlb2_dev->resource_mutex);
+                       /* Relinquish the CPU so the application can process
+                        * its CQs, so this function doesn't deadlock.
+                        */
+                       sched_yield();
+               } else {
+                       break;
+               }
+       }
+

drivers/event/dlb2/pf/base/dlb2_osdep.h

Quoted 10 lines
drivers/event/dlb2/pf/base/dlb2_osdep.h new file +10 -0
+       dlb2_dev->worker_launched = false;
+
+       rte_spinlock_unlock(&dlb2_dev->resource_mutex);
+
+       return NULL;
+}
+
+
+/**
+ * os_schedule_work() - launch a thread to process pending map and unmap

work

Quoted 11 lines
drivers/event/dlb2/pf/base/dlb2_osdep.h new file +11 -0
+ * @hw: dlb2_hw handle for a particular device.
+ *
+ * This function launches a kernel thread that will run until all pending
+ * map and unmap procedures are complete.
+ */
+static inline void os_schedule_work(struct dlb2_hw *hw)
+{
+       struct dlb2_dev *dlb2_dev;
+       pthread_t complete_queue_map_unmap_thread;
+       int ret;
+

drivers/event/dlb2/pf/base/dlb2_osdep.h

Quoted 10 lines
drivers/event/dlb2/pf/base/dlb2_osdep.h new file +10 -0
+       dlb2_dev = container_of(hw, struct dlb2_dev, hw);
+
+       ret = rte_ctrl_thread_create(&complete_queue_map_unmap_thread,
+                                    "dlb_queue_unmap_waiter",
+                                    NULL,
+                                    dlb2_complete_queue_map_unmap,
+                                    dlb2_dev);
+       if (ret)
+               DLB2_ERR(dlb2_dev,
+                        "Could not create queue complete map/unmap thread,

err=%d\n",

drivers/event/dlb2/pf/base/dlb2_osdep.h

Quoted 7 lines
drivers/event/dlb2/pf/base/dlb2_osdep.h new file +7 -0
+                        ret);
+       else
+               dlb2_dev->worker_launched = true;
+}
+
+/**
+ * os_worker_active() - query whether the map/unmap worker thread is

active

Review

Quoted 17 lines
drivers/event/dlb2/pf/base/dlb2_osdep.h new file +16 -0
+ * @hw: dlb2_hw handle for a particular device.
+ *
+ * This function returns a boolean indicating whether a thread (launched by
+ * os_schedule_work()) is active. This function is used to determine
+ * whether or not to launch a worker thread.
+ */
+static inline bool os_worker_active(struct dlb2_hw *hw)
+{
+       struct dlb2_dev *dlb2_dev;
+
+       dlb2_dev = container_of(hw, struct dlb2_dev, hw);
+
+       return dlb2_dev->worker_launched;
+}
+
+#endif /*  __DLB2_OSDEP_H */
(quoted diff) +0 -0

b/drivers/event/dlb2/pf/base/dlb2_osdep_bitmap.h

Quoted 57 lines

new file mode 100644
index 0000000..423233b

drivers/event/dlb2/pf/base/dlb2_osdep_bitmap.h new file +52 -0
@@ -0,0 +1,440 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2016-2020 Intel Corporation
+ */
+
+#ifndef __DLB2_OSDEP_BITMAP_H
+#define __DLB2_OSDEP_BITMAP_H
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <rte_bitmap.h>
+#include <rte_string_fns.h>
+#include <rte_malloc.h>
+#include <rte_errno.h>
+#include "../dlb2_main.h"
+
+/*************************/
+/*** Bitmap operations ***/
+/*************************/
+struct dlb2_bitmap {
+       struct rte_bitmap *map;
+       unsigned int len;
+};
+
+/**
+ * dlb2_bitmap_alloc() - alloc a bitmap data structure
+ * @bitmap: pointer to dlb2_bitmap structure pointer.
+ * @len: number of entries in the bitmap.
+ *
+ * This function allocates a bitmap and initializes it with length @len. All
+ * entries are initially zero.
+ *
+ * Return:
+ * Returns 0 upon success, < 0 otherwise.
+ *
+ * Errors:
+ * EINVAL - bitmap is NULL or len is 0.
+ * ENOMEM - could not allocate memory for the bitmap data structure.
+ */
+static inline int dlb2_bitmap_alloc(struct dlb2_bitmap **bitmap,
+                                   unsigned int len)
+{
+       struct dlb2_bitmap *bm;
+       void *mem;
+       uint32_t alloc_size;
+       uint32_t nbits = (uint32_t)len;
+
+       if (bitmap == NULL || nbits == 0)
+               return -EINVAL;
+
+       /* Allocate DLB2 bitmap control struct */

drivers/event/dlb2/pf/base/dlb2_osdep_bitmap.h line 62

Quoted 10 lines
drivers/event/dlb2/pf/base/dlb2_osdep_bitmap.h new file +10 -0
+       bm = rte_malloc("DLB2_PF",
+                       sizeof(struct dlb2_bitmap),
+                       RTE_CACHE_LINE_SIZE);
+
+       if (bm == NULL)
+               return -ENOMEM;
+
+       /* Allocate bitmap memory */
+       alloc_size = rte_bitmap_get_memory_footprint(nbits);
+       mem = rte_malloc("DLB2_PF_BITMAP", alloc_size,

RTE_CACHE_LINE_SIZE);

Review

Quoted 379 lines
drivers/event/dlb2/pf/base/dlb2_osdep_bitmap.h new file +378 -0
+       if (mem == NULL) {
+               rte_free(bm);
+               return -ENOMEM;
+       }
+
+       bm->map = rte_bitmap_init(len, mem, alloc_size);
+       if (bm->map == NULL) {
+               rte_free(mem);
+               rte_free(bm);
+               return -ENOMEM;
+       }
+
+       bm->len = len;
+
+       *bitmap = bm;
+
+       return 0;
+}
+
+/**
+ * dlb2_bitmap_free() - free a previously allocated bitmap data structure
+ * @bitmap: pointer to dlb2_bitmap structure.
+ *
+ * This function frees a bitmap that was allocated with dlb2_bitmap_alloc().
+ */
+static inline void dlb2_bitmap_free(struct dlb2_bitmap *bitmap)
+{
+       if (bitmap == NULL)
+               return;
+
+       rte_free(bitmap->map);
+       rte_free(bitmap);
+}
+
+/**
+ * dlb2_bitmap_fill() - fill a bitmap with all 1s
+ * @bitmap: pointer to dlb2_bitmap structure.
+ *
+ * This function sets all bitmap values to 1.
+ *
+ * Return:
+ * Returns 0 upon success, < 0 otherwise.
+ *
+ * Errors:
+ * EINVAL - bitmap is NULL or is uninitialized.
+ */
+static inline int dlb2_bitmap_fill(struct dlb2_bitmap *bitmap)
+{
+       unsigned int i;
+
+       if (bitmap  == NULL || bitmap->map == NULL)
+               return -EINVAL;
+
+       for (i = 0; i != bitmap->len; i++)
+               rte_bitmap_set(bitmap->map, i);
+
+       return 0;
+}
+
+/**
+ * dlb2_bitmap_fill() - fill a bitmap with all 0s
+ * @bitmap: pointer to dlb2_bitmap structure.
+ *
+ * This function sets all bitmap values to 0.
+ *
+ * Return:
+ * Returns 0 upon success, < 0 otherwise.
+ *
+ * Errors:
+ * EINVAL - bitmap is NULL or is uninitialized.
+ */
+static inline int dlb2_bitmap_zero(struct dlb2_bitmap *bitmap)
+{
+       if (bitmap  == NULL || bitmap->map == NULL)
+               return -EINVAL;
+
+       rte_bitmap_reset(bitmap->map);
+
+       return 0;
+}
+
+/**
+ * dlb2_bitmap_set() - set a bitmap entry
+ * @bitmap: pointer to dlb2_bitmap structure.
+ * @bit: bit index.
+ *
+ * Return:
+ * Returns 0 upon success, < 0 otherwise.
+ *
+ * Errors:
+ * EINVAL - bitmap is NULL or is uninitialized, or bit is larger than the
+ *         bitmap length.
+ */
+static inline int dlb2_bitmap_set(struct dlb2_bitmap *bitmap,
+                                 unsigned int bit)
+{
+       if (bitmap  == NULL || bitmap->map == NULL)
+               return -EINVAL;
+
+       if (bitmap->len <= bit)
+               return -EINVAL;
+
+       rte_bitmap_set(bitmap->map, bit);
+
+       return 0;
+}
+
+/**
+ * dlb2_bitmap_set_range() - set a range of bitmap entries
+ * @bitmap: pointer to dlb2_bitmap structure.
+ * @bit: starting bit index.
+ * @len: length of the range.
+ *
+ * Return:
+ * Returns 0 upon success, < 0 otherwise.
+ *
+ * Errors:
+ * EINVAL - bitmap is NULL or is uninitialized, or the range exceeds the bitmap
+ *         length.
+ */
+static inline int dlb2_bitmap_set_range(struct dlb2_bitmap *bitmap,
+                                       unsigned int bit,
+                                       unsigned int len)
+{
+       unsigned int i;
+
+       if (bitmap  == NULL || bitmap->map == NULL)
+               return -EINVAL;
+
+       if (bitmap->len <= bit)
+               return -EINVAL;
+
+       for (i = 0; i != len; i++)
+               rte_bitmap_set(bitmap->map, bit + i);
+
+       return 0;
+}
+
+/**
+ * dlb2_bitmap_clear() - clear a bitmap entry
+ * @bitmap: pointer to dlb2_bitmap structure.
+ * @bit: bit index.
+ *
+ * Return:
+ * Returns 0 upon success, < 0 otherwise.
+ *
+ * Errors:
+ * EINVAL - bitmap is NULL or is uninitialized, or bit is larger than the
+ *         bitmap length.
+ */
+static inline int dlb2_bitmap_clear(struct dlb2_bitmap *bitmap,
+                                   unsigned int bit)
+{
+       if (bitmap  == NULL || bitmap->map == NULL)
+               return -EINVAL;
+
+       if (bitmap->len <= bit)
+               return -EINVAL;
+
+       rte_bitmap_clear(bitmap->map, bit);
+
+       return 0;
+}
+
+/**
+ * dlb2_bitmap_clear_range() - clear a range of bitmap entries
+ * @bitmap: pointer to dlb2_bitmap structure.
+ * @bit: starting bit index.
+ * @len: length of the range.
+ *
+ * Return:
+ * Returns 0 upon success, < 0 otherwise.
+ *
+ * Errors:
+ * EINVAL - bitmap is NULL or is uninitialized, or the range exceeds the bitmap
+ *         length.
+ */
+static inline int dlb2_bitmap_clear_range(struct dlb2_bitmap *bitmap,
+                                         unsigned int bit,
+                                         unsigned int len)
+{
+       unsigned int i;
+
+       if (bitmap  == NULL || bitmap->map == NULL)
+               return -EINVAL;
+
+       if (bitmap->len <= bit)
+               return -EINVAL;
+
+       for (i = 0; i != len; i++)
+               rte_bitmap_clear(bitmap->map, bit + i);
+
+       return 0;
+}
+
+/**
+ * dlb2_bitmap_find_set_bit_range() - find an range of set bits
+ * @bitmap: pointer to dlb2_bitmap structure.
+ * @len: length of the range.
+ *
+ * This function looks for a range of set bits of length @len.
+ *
+ * Return:
+ * Returns the base bit index upon success, < 0 otherwise.
+ *
+ * Errors:
+ * ENOENT - unable to find a length *len* range of set bits.
+ * EINVAL - bitmap is NULL or is uninitialized, or len is invalid.
+ */
+static inline int dlb2_bitmap_find_set_bit_range(struct dlb2_bitmap *bitmap,
+                                                unsigned int len)
+{
+       unsigned int i, j = 0;
+
+       if (bitmap  == NULL || bitmap->map == NULL || len == 0)
+               return -EINVAL;
+
+       if (bitmap->len < len)
+               return -ENOENT;
+
+       for (i = 0; i != bitmap->len; i++) {
+               if  (rte_bitmap_get(bitmap->map, i)) {
+                       if (++j == len)
+                               return i - j + 1;
+               } else {
+                       j = 0;
+               }
+       }
+
+       /* No set bit range of length len? */
+       return -ENOENT;
+}
+
+/**
+ * dlb2_bitmap_find_set_bit() - find an range of set bits
+ * @bitmap: pointer to dlb2_bitmap structure.
+ *
+ * This function looks for a single set bit.
+ *
+ * Return:
+ * Returns the base bit index upon success, -1 if not found, <-1 otherwise.
+ *
+ * Errors:
+ * EINVAL - bitmap is NULL or is uninitialized, or len is invalid.
+ */
+static inline int dlb2_bitmap_find_set_bit(struct dlb2_bitmap *bitmap)
+{
+       unsigned int i;
+
+       if (bitmap == NULL)
+               return -EINVAL;
+
+       if (bitmap->map == NULL)
+               return -EINVAL;
+
+       for (i = 0; i != bitmap->len; i++) {
+               if  (rte_bitmap_get(bitmap->map, i))
+                       return i;
+       }
+
+       return -ENOENT;
+}
+
+/**
+ * dlb2_bitmap_count() - returns the number of set bits
+ * @bitmap: pointer to dlb2_bitmap structure.
+ *
+ * This function looks for a single set bit.
+ *
+ * Return:
+ * Returns the number of set bits upon success, <0 otherwise.
+ *
+ * Errors:
+ * EINVAL - bitmap is NULL or is uninitialized.
+ */
+static inline int dlb2_bitmap_count(struct dlb2_bitmap *bitmap)
+{
+       int weight = 0;
+       unsigned int i;
+
+       if (bitmap == NULL)
+               return -EINVAL;
+
+       if (bitmap->map == NULL)
+               return -EINVAL;
+
+       for (i = 0; i != bitmap->len; i++) {
+               if  (rte_bitmap_get(bitmap->map, i))
+                       weight++;
+       }
+       return weight;
+}
+
+/**
+ * dlb2_bitmap_longest_set_range() - returns longest contiguous range of set
+ *                                   bits
+ * @bitmap: pointer to dlb2_bitmap structure.
+ *
+ * Return:
+ * Returns the bitmap's longest contiguous range of of set bits upon success,
+ * <0 otherwise.
+ *
+ * Errors:
+ * EINVAL - bitmap is NULL or is uninitialized.
+ */
+static inline int dlb2_bitmap_longest_set_range(struct dlb2_bitmap *bitmap)
+{
+       int max_len = 0, len = 0;
+       unsigned int i;
+
+       if (bitmap == NULL)
+               return -EINVAL;
+
+       if (bitmap->map == NULL)
+               return -EINVAL;
+
+       for (i = 0; i != bitmap->len; i++) {
+               if  (rte_bitmap_get(bitmap->map, i)) {
+                       len++;
+               } else {
+                       if (len > max_len)
+                               max_len = len;
+                       len = 0;
+               }
+       }
+
+       if (len > max_len)
+               max_len = len;
+
+       return max_len;
+}
+
+/**
+ * dlb2_bitmap_or() - store the logical 'or' of two bitmaps into a third
+ * @dest: pointer to dlb2_bitmap structure, which will contain the results of
+ *       the 'or' of src1 and src2.
+ * @src1: pointer to dlb2_bitmap structure, will be 'or'ed with src2.
+ * @src2: pointer to dlb2_bitmap structure, will be 'or'ed with src1.
+ *
+ * This function 'or's two bitmaps together and stores the result in a third
+ * bitmap. The source and destination bitmaps can be the same.
+ *
+ * Return:
+ * Returns the number of set bits upon success, <0 otherwise.
+ *
+ * Errors:
+ * EINVAL - One of the bitmaps is NULL or is uninitialized.
+ */
+static inline int dlb2_bitmap_or(struct dlb2_bitmap *dest,
+                                struct dlb2_bitmap *src1,
+                                struct dlb2_bitmap *src2)
+{
+       unsigned int i, min;
+       int numset = 0;
+
+       if (dest  == NULL || dest->map == NULL ||
+           src1  == NULL || src1->map == NULL ||
+           src2  == NULL || src2->map == NULL)
+               return -EINVAL;
+
+       min = dest->len;
+       min = (min > src1->len) ? src1->len : min;
+       min = (min > src2->len) ? src2->len : min;
+
+       for (i = 0; i != min; i++) {
+               if  (rte_bitmap_get(src1->map, i) ||
+                    rte_bitmap_get(src2->map, i)) {
+                       rte_bitmap_set(dest->map, i);
+                       numset++;
+               } else {
+                       rte_bitmap_clear(dest->map, i);
+               }
+       }
+
+       return numset;
+}
+
+#endif /*  __DLB2_OSDEP_BITMAP_H */
(quoted diff) +0 -0

b/drivers/event/dlb2/pf/base/dlb2_osdep_list.h

Quoted 123 lines

new file mode 100644
index 0000000..5531739

drivers/event/dlb2/pf/base/dlb2_osdep_list.h new file +118 -0
@@ -0,0 +1,131 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2016-2020 Intel Corporation
+ */
+
+#ifndef __DLB2_OSDEP_LIST_H
+#define __DLB2_OSDEP_LIST_H
+
+#include <rte_tailq.h>
+
+struct dlb2_list_entry {
+       TAILQ_ENTRY(dlb2_list_entry) node;
+};
+
+/* Dummy - just a struct definition */
+TAILQ_HEAD(dlb2_list_head, dlb2_list_entry);
+
+/* =================
+ * TAILQ Supplements
+ * =================
+ */
+
+#ifndef TAILQ_FOREACH_ENTRY
+#define TAILQ_FOREACH_ENTRY(ptr, head, name, iter)             \
+       for ((iter) = TAILQ_FIRST(&head);                       \
+           (iter)                                              \
+               && (ptr = container_of(iter, typeof(*(ptr)), name)); \
+           (iter) = TAILQ_NEXT((iter), node))
+#endif
+
+#ifndef TAILQ_FOREACH_ENTRY_SAFE
+#define TAILQ_FOREACH_ENTRY_SAFE(ptr, head, name, iter, tvar)  \
+       for ((iter) = TAILQ_FIRST(&head);                       \
+           (iter) &&                                           \
+               (ptr = container_of(iter, typeof(*(ptr)), name)) &&\
+               ((tvar) = TAILQ_NEXT((iter), node), 1); \
+           (iter) = (tvar))
+#endif
+
+/***********************/
+/*** List operations ***/
+/***********************/
+
+/**
+ * dlb2_list_init_head() - initialize the head of a list
+ * @head: list head
+ */
+static inline void dlb2_list_init_head(struct dlb2_list_head *head)
+{
+       TAILQ_INIT(head);
+}
+
+/**
+ * dlb2_list_add() - add an entry to a list
+ * @head: list head
+ * @entry: new list entry
+ */
+static inline void
+dlb2_list_add(struct dlb2_list_head *head, struct dlb2_list_entry *entry)
+{
+       TAILQ_INSERT_TAIL(head, entry, node);
+}
+
+/**
+ * dlb2_list_del() - delete an entry from a list
+ * @entry: list entry
+ * @head: list head
+ */
+static inline void dlb2_list_del(struct dlb2_list_head *head,
+                                struct dlb2_list_entry *entry)
+{
+       TAILQ_REMOVE(head, entry, node);
+}
+
+/**
+ * dlb2_list_empty() - check if a list is empty
+ * @head: list head
+ *
+ * Return:
+ * Returns 1 if empty, 0 if not.
+ */
+static inline int dlb2_list_empty(struct dlb2_list_head *head)
+{
+       return TAILQ_EMPTY(head);
+}
+
+/**
+ * dlb2_list_splice() - splice a list
+ * @src_head: list to be added
+ * @ head: where src_head will be inserted
+ */
+static inline void dlb2_list_splice(struct dlb2_list_head *src_head,
+                                   struct dlb2_list_head *head)
+{
+       TAILQ_CONCAT(head, src_head, node);
+}
+
+/**
+ * DLB2_LIST_HEAD() - retrieve the head of the list
+ * @head: list head
+ * @type: type of the list variable
+ * @name: name of the list field within the containing struct
+ */
+#define DLB2_LIST_HEAD(head, type, name)                       \
+       (TAILQ_FIRST(&head) ?                                   \
+               container_of(TAILQ_FIRST(&head), type, name) :  \
+               NULL)
+
+/**
+ * DLB2_LIST_FOR_EACH() - iterate over a list
+ * @head: list head
+ * @ptr: pointer to struct containing a struct list
+ * @name: name of the list field within the containing struct
+ * @iter: iterator variable
+ */
+#define DLB2_LIST_FOR_EACH(head, ptr, name, tmp_iter) \
+       TAILQ_FOREACH_ENTRY(ptr, head, name, tmp_iter)
+
+/**

drivers/event/dlb2/pf/base/dlb2_osdep_list.h line 128

Quoted 10 lines
drivers/event/dlb2/pf/base/dlb2_osdep_list.h new file +10 -0
+ * DLB2_LIST_FOR_EACH_SAFE() - iterate over a list. This loop works even if
+ * an element is removed from the list while processing it.
+ * @ptr: pointer to struct containing a struct list
+ * @ptr_tmp: pointer to struct containing a struct list (temporary)
+ * @head: list head
+ * @name: name of the list field within the containing struct
+ * @iter: iterator variable
+ * @iter_tmp: iterator variable (temporary)
+ */
+#define DLB2_LIST_FOR_EACH_SAFE(head, ptr, ptr_tmp, name, tmp_iter,

saf_itr) \

Review

Quoted 4 lines
drivers/event/dlb2/pf/base/dlb2_osdep_list.h new file +3 -0
+       TAILQ_FOREACH_ENTRY_SAFE(ptr, head, name, tmp_iter, saf_itr)
+
+#endif /*  __DLB2_OSDEP_LIST_H */
(quoted diff) +0 -0

b/drivers/event/dlb2/pf/base/dlb2_osdep_types.h

Review

Quoted 37 lines

new file mode 100644
index 0000000..0a48f7e

drivers/event/dlb2/pf/base/dlb2_osdep_types.h new file +31 -0
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2016-2020 Intel Corporation
+ */
+
+#ifndef __DLB2_OSDEP_TYPES_H
+#define __DLB2_OSDEP_TYPES_H
+
+#include <linux/types.h>
+
+#include <inttypes.h>
+#include <ctype.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+
+/* Types for user mode PF PMD */
+typedef uint8_t         u8;
+typedef int8_t          s8;
+typedef uint16_t        u16;
+typedef int16_t         s16;
+typedef uint32_t        u32;
+typedef int32_t         s32;
+typedef uint64_t        u64;
+
+#define __iomem
+
+/* END types for user mode PF PMD */
+
+#endif /* __DLB2_OSDEP_TYPES_H */
(quoted diff) +0 -0

b/drivers/event/dlb2/pf/base/dlb2_regs.h

Quoted 1,042 lines

new file mode 100644
index 0000000..43ecad4

drivers/event/dlb2/pf/base/dlb2_regs.h new file +1037 -0
@@ -0,0 +1,2527 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2016-2020 Intel Corporation
+ */
+
+#ifndef __DLB2_REGS_H
+#define __DLB2_REGS_H
+
+#include "dlb2_osdep_types.h"
+
+#define DLB2_FUNC_PF_VF2PF_MAILBOX_BYTES 256
+#define DLB2_FUNC_PF_VF2PF_MAILBOX(vf_id, x) \
+       (0x1000 + 0x4 * (x) + (vf_id) * 0x10000)
+#define DLB2_FUNC_PF_VF2PF_MAILBOX_RST 0x0
+union dlb2_func_pf_vf2pf_mailbox {
+       struct {
+               u32 msg : 32;
+       } field;
+       u32 val;
+};
+
+#define DLB2_FUNC_PF_VF2PF_MAILBOX_ISR(vf_id) \
+       (0x1f00 + (vf_id) * 0x10000)
+#define DLB2_FUNC_PF_VF2PF_MAILBOX_ISR_RST 0x0
+union dlb2_func_pf_vf2pf_mailbox_isr {
+       struct {
+               u32 vf0_isr : 1;
+               u32 vf1_isr : 1;
+               u32 vf2_isr : 1;
+               u32 vf3_isr : 1;
+               u32 vf4_isr : 1;
+               u32 vf5_isr : 1;
+               u32 vf6_isr : 1;
+               u32 vf7_isr : 1;
+               u32 vf8_isr : 1;
+               u32 vf9_isr : 1;
+               u32 vf10_isr : 1;
+               u32 vf11_isr : 1;
+               u32 vf12_isr : 1;
+               u32 vf13_isr : 1;
+               u32 vf14_isr : 1;
+               u32 vf15_isr : 1;
+               u32 rsvd0 : 16;
+       } field;
+       u32 val;
+};
+
+#define DLB2_FUNC_PF_VF2PF_FLR_ISR(vf_id) \
+       (0x1f04 + (vf_id) * 0x10000)
+#define DLB2_FUNC_PF_VF2PF_FLR_ISR_RST 0x0
+union dlb2_func_pf_vf2pf_flr_isr {
+       struct {
+               u32 vf0_isr : 1;
+               u32 vf1_isr : 1;
+               u32 vf2_isr : 1;
+               u32 vf3_isr : 1;
+               u32 vf4_isr : 1;
+               u32 vf5_isr : 1;
+               u32 vf6_isr : 1;
+               u32 vf7_isr : 1;
+               u32 vf8_isr : 1;
+               u32 vf9_isr : 1;
+               u32 vf10_isr : 1;
+               u32 vf11_isr : 1;
+               u32 vf12_isr : 1;
+               u32 vf13_isr : 1;
+               u32 vf14_isr : 1;
+               u32 vf15_isr : 1;
+               u32 rsvd0 : 16;
+       } field;
+       u32 val;
+};
+
+#define DLB2_FUNC_PF_VF2PF_ISR_PEND(vf_id) \
+       (0x1f10 + (vf_id) * 0x10000)
+#define DLB2_FUNC_PF_VF2PF_ISR_PEND_RST 0x0
+union dlb2_func_pf_vf2pf_isr_pend {
+       struct {
+               u32 isr_pend : 1;
+               u32 rsvd0 : 31;
+       } field;
+       u32 val;
+};
+
+#define DLB2_FUNC_PF_PF2VF_MAILBOX_BYTES 64
+#define DLB2_FUNC_PF_PF2VF_MAILBOX(vf_id, x) \
+       (0x2000 + 0x4 * (x) + (vf_id) * 0x10000)
+#define DLB2_FUNC_PF_PF2VF_MAILBOX_RST 0x0
+union dlb2_func_pf_pf2vf_mailbox {
+       struct {
+               u32 msg : 32;
+       } field;
+       u32 val;
+};
+
+#define DLB2_FUNC_PF_PF2VF_MAILBOX_ISR(vf_id) \
+       (0x2f00 + (vf_id) * 0x10000)
+#define DLB2_FUNC_PF_PF2VF_MAILBOX_ISR_RST 0x0
+union dlb2_func_pf_pf2vf_mailbox_isr {
+       struct {
+               u32 vf0_isr : 1;
+               u32 vf1_isr : 1;
+               u32 vf2_isr : 1;
+               u32 vf3_isr : 1;
+               u32 vf4_isr : 1;
+               u32 vf5_isr : 1;
+               u32 vf6_isr : 1;
+               u32 vf7_isr : 1;
+               u32 vf8_isr : 1;
+               u32 vf9_isr : 1;
+               u32 vf10_isr : 1;
+               u32 vf11_isr : 1;
+               u32 vf12_isr : 1;
+               u32 vf13_isr : 1;
+               u32 vf14_isr : 1;
+               u32 vf15_isr : 1;
+               u32 rsvd0 : 16;
+       } field;
+       u32 val;
+};
+
+#define DLB2_FUNC_PF_VF_RESET_IN_PROGRESS(vf_id) \
+       (0x3000 + (vf_id) * 0x10000)
+#define DLB2_FUNC_PF_VF_RESET_IN_PROGRESS_RST 0xffff
+union dlb2_func_pf_vf_reset_in_progress {
+       struct {
+               u32 vf0_reset_in_progress : 1;
+               u32 vf1_reset_in_progress : 1;
+               u32 vf2_reset_in_progress : 1;
+               u32 vf3_reset_in_progress : 1;
+               u32 vf4_reset_in_progress : 1;
+               u32 vf5_reset_in_progress : 1;
+               u32 vf6_reset_in_progress : 1;
+               u32 vf7_reset_in_progress : 1;
+               u32 vf8_reset_in_progress : 1;
+               u32 vf9_reset_in_progress : 1;
+               u32 vf10_reset_in_progress : 1;
+               u32 vf11_reset_in_progress : 1;
+               u32 vf12_reset_in_progress : 1;
+               u32 vf13_reset_in_progress : 1;
+               u32 vf14_reset_in_progress : 1;
+               u32 vf15_reset_in_progress : 1;
+               u32 rsvd0 : 16;
+       } field;
+       u32 val;
+};
+
+#define DLB2_MSIX_MEM_VECTOR_CTRL(x) \
+       (0x100000c + (x) * 0x10)
+#define DLB2_MSIX_MEM_VECTOR_CTRL_RST 0x1
+union dlb2_msix_mem_vector_ctrl {
+       struct {
+               u32 vec_mask : 1;
+               u32 rsvd0 : 31;
+       } field;
+       u32 val;
+};
+
+#define DLB2_IOSF_FUNC_VF_BAR_DSBL(x) \
+       (0x20 + (x) * 0x4)
+#define DLB2_IOSF_FUNC_VF_BAR_DSBL_RST 0x0
+union dlb2_iosf_func_vf_bar_dsbl {
+       struct {
+               u32 func_vf_bar_dis : 1;
+               u32 rsvd0 : 31;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_TOTAL_VAS 0x1000011c
+#define DLB2_SYS_TOTAL_VAS_RST 0x20
+union dlb2_sys_total_vas {
+       struct {
+               u32 total_vas : 32;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_TOTAL_DIR_PORTS 0x10000118
+#define DLB2_SYS_TOTAL_DIR_PORTS_RST 0x40
+union dlb2_sys_total_dir_ports {
+       struct {
+               u32 total_dir_ports : 32;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_TOTAL_LDB_PORTS 0x10000114
+#define DLB2_SYS_TOTAL_LDB_PORTS_RST 0x40
+union dlb2_sys_total_ldb_ports {
+       struct {
+               u32 total_ldb_ports : 32;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_TOTAL_DIR_QID 0x10000110
+#define DLB2_SYS_TOTAL_DIR_QID_RST 0x40
+union dlb2_sys_total_dir_qid {
+       struct {
+               u32 total_dir_qid : 32;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_TOTAL_LDB_QID 0x1000010c
+#define DLB2_SYS_TOTAL_LDB_QID_RST 0x20
+union dlb2_sys_total_ldb_qid {
+       struct {
+               u32 total_ldb_qid : 32;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_TOTAL_DIR_CRDS 0x10000108
+#define DLB2_SYS_TOTAL_DIR_CRDS_RST 0x1000
+union dlb2_sys_total_dir_crds {
+       struct {
+               u32 total_dir_credits : 32;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_TOTAL_LDB_CRDS 0x10000104
+#define DLB2_SYS_TOTAL_LDB_CRDS_RST 0x2000
+union dlb2_sys_total_ldb_crds {
+       struct {
+               u32 total_ldb_credits : 32;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_ALARM_PF_SYND2 0x10000508
+#define DLB2_SYS_ALARM_PF_SYND2_RST 0x0
+union dlb2_sys_alarm_pf_synd2 {
+       struct {
+               u32 lock_id : 16;
+               u32 meas : 1;
+               u32 debug : 7;
+               u32 cq_pop : 1;
+               u32 qe_uhl : 1;
+               u32 qe_orsp : 1;
+               u32 qe_valid : 1;
+               u32 cq_int_rearm : 1;
+               u32 dsi_error : 1;
+               u32 rsvd0 : 2;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_ALARM_PF_SYND1 0x10000504
+#define DLB2_SYS_ALARM_PF_SYND1_RST 0x0
+union dlb2_sys_alarm_pf_synd1 {
+       struct {
+               u32 dsi : 16;
+               u32 qid : 8;
+               u32 qtype : 2;
+               u32 qpri : 3;
+               u32 msg_type : 3;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_ALARM_PF_SYND0 0x10000500
+#define DLB2_SYS_ALARM_PF_SYND0_RST 0x0
+union dlb2_sys_alarm_pf_synd0 {
+       struct {
+               u32 syndrome : 8;
+               u32 rtype : 2;
+               u32 rsvd0 : 3;
+               u32 is_ldb : 1;
+               u32 cls : 2;
+               u32 aid : 6;
+               u32 unit : 4;
+               u32 source : 4;
+               u32 more : 1;
+               u32 valid : 1;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_VF_LDB_VPP_V(x) \
+       (0x10000f00 + (x) * 0x1000)
+#define DLB2_SYS_VF_LDB_VPP_V_RST 0x0
+union dlb2_sys_vf_ldb_vpp_v {
+       struct {
+               u32 vpp_v : 1;
+               u32 rsvd0 : 31;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_VF_LDB_VPP2PP(x) \
+       (0x10000f04 + (x) * 0x1000)
+#define DLB2_SYS_VF_LDB_VPP2PP_RST 0x0
+union dlb2_sys_vf_ldb_vpp2pp {
+       struct {
+               u32 pp : 6;
+               u32 rsvd0 : 26;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_VF_DIR_VPP_V(x) \
+       (0x10000f08 + (x) * 0x1000)
+#define DLB2_SYS_VF_DIR_VPP_V_RST 0x0
+union dlb2_sys_vf_dir_vpp_v {
+       struct {
+               u32 vpp_v : 1;
+               u32 rsvd0 : 31;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_VF_DIR_VPP2PP(x) \
+       (0x10000f0c + (x) * 0x1000)
+#define DLB2_SYS_VF_DIR_VPP2PP_RST 0x0
+union dlb2_sys_vf_dir_vpp2pp {
+       struct {
+               u32 pp : 6;
+               u32 rsvd0 : 26;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_VF_LDB_VQID_V(x) \
+       (0x10000f10 + (x) * 0x1000)
+#define DLB2_SYS_VF_LDB_VQID_V_RST 0x0
+union dlb2_sys_vf_ldb_vqid_v {
+       struct {
+               u32 vqid_v : 1;
+               u32 rsvd0 : 31;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_VF_LDB_VQID2QID(x) \
+       (0x10000f14 + (x) * 0x1000)
+#define DLB2_SYS_VF_LDB_VQID2QID_RST 0x0
+union dlb2_sys_vf_ldb_vqid2qid {
+       struct {
+               u32 qid : 5;
+               u32 rsvd0 : 27;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_LDB_QID2VQID(x) \
+       (0x10000f18 + (x) * 0x1000)
+#define DLB2_SYS_LDB_QID2VQID_RST 0x0
+union dlb2_sys_ldb_qid2vqid {
+       struct {
+               u32 vqid : 5;
+               u32 rsvd0 : 27;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_VF_DIR_VQID_V(x) \
+       (0x10000f1c + (x) * 0x1000)
+#define DLB2_SYS_VF_DIR_VQID_V_RST 0x0
+union dlb2_sys_vf_dir_vqid_v {
+       struct {
+               u32 vqid_v : 1;
+               u32 rsvd0 : 31;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_VF_DIR_VQID2QID(x) \
+       (0x10000f20 + (x) * 0x1000)
+#define DLB2_SYS_VF_DIR_VQID2QID_RST 0x0
+union dlb2_sys_vf_dir_vqid2qid {
+       struct {
+               u32 qid : 6;
+               u32 rsvd0 : 26;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_LDB_VASQID_V(x) \
+       (0x10000f24 + (x) * 0x1000)
+#define DLB2_SYS_LDB_VASQID_V_RST 0x0
+union dlb2_sys_ldb_vasqid_v {
+       struct {
+               u32 vasqid_v : 1;
+               u32 rsvd0 : 31;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_DIR_VASQID_V(x) \
+       (0x10000f28 + (x) * 0x1000)
+#define DLB2_SYS_DIR_VASQID_V_RST 0x0
+union dlb2_sys_dir_vasqid_v {
+       struct {
+               u32 vasqid_v : 1;
+               u32 rsvd0 : 31;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_ALARM_VF_SYND2(x) \
+       (0x10000f48 + (x) * 0x1000)
+#define DLB2_SYS_ALARM_VF_SYND2_RST 0x0
+union dlb2_sys_alarm_vf_synd2 {
+       struct {
+               u32 lock_id : 16;
+               u32 debug : 8;
+               u32 cq_pop : 1;
+               u32 qe_uhl : 1;
+               u32 qe_orsp : 1;
+               u32 qe_valid : 1;
+               u32 isz : 1;
+               u32 dsi_error : 1;
+               u32 dlbrsvd : 2;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_ALARM_VF_SYND1(x) \
+       (0x10000f44 + (x) * 0x1000)
+#define DLB2_SYS_ALARM_VF_SYND1_RST 0x0
+union dlb2_sys_alarm_vf_synd1 {
+       struct {
+               u32 dsi : 16;
+               u32 qid : 8;
+               u32 qtype : 2;
+               u32 qpri : 3;
+               u32 msg_type : 3;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_ALARM_VF_SYND0(x) \
+       (0x10000f40 + (x) * 0x1000)
+#define DLB2_SYS_ALARM_VF_SYND0_RST 0x0
+union dlb2_sys_alarm_vf_synd0 {
+       struct {
+               u32 syndrome : 8;
+               u32 rtype : 2;
+               u32 vf_synd0_parity : 1;
+               u32 vf_synd1_parity : 1;
+               u32 vf_synd2_parity : 1;
+               u32 is_ldb : 1;
+               u32 cls : 2;
+               u32 aid : 6;
+               u32 unit : 4;
+               u32 source : 4;
+               u32 more : 1;
+               u32 valid : 1;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_LDB_QID_CFG_V(x) \
+       (0x10000f58 + (x) * 0x1000)
+#define DLB2_SYS_LDB_QID_CFG_V_RST 0x0
+union dlb2_sys_ldb_qid_cfg_v {
+       struct {
+               u32 sn_cfg_v : 1;
+               u32 fid_cfg_v : 1;
+               u32 rsvd0 : 30;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_LDB_QID_ITS(x) \
+       (0x10000f54 + (x) * 0x1000)
+#define DLB2_SYS_LDB_QID_ITS_RST 0x0
+union dlb2_sys_ldb_qid_its {
+       struct {
+               u32 qid_its : 1;
+               u32 rsvd0 : 31;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_LDB_QID_V(x) \
+       (0x10000f50 + (x) * 0x1000)
+#define DLB2_SYS_LDB_QID_V_RST 0x0
+union dlb2_sys_ldb_qid_v {
+       struct {
+               u32 qid_v : 1;
+               u32 rsvd0 : 31;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_DIR_QID_ITS(x) \
+       (0x10000f64 + (x) * 0x1000)
+#define DLB2_SYS_DIR_QID_ITS_RST 0x0
+union dlb2_sys_dir_qid_its {
+       struct {
+               u32 qid_its : 1;
+               u32 rsvd0 : 31;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_DIR_QID_V(x) \
+       (0x10000f60 + (x) * 0x1000)
+#define DLB2_SYS_DIR_QID_V_RST 0x0
+union dlb2_sys_dir_qid_v {
+       struct {
+               u32 qid_v : 1;
+               u32 rsvd0 : 31;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_LDB_CQ_AI_DATA(x) \
+       (0x10000fa8 + (x) * 0x1000)
+#define DLB2_SYS_LDB_CQ_AI_DATA_RST 0x0
+union dlb2_sys_ldb_cq_ai_data {
+       struct {
+               u32 cq_ai_data : 32;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_LDB_CQ_AI_ADDR(x) \
+       (0x10000fa4 + (x) * 0x1000)
+#define DLB2_SYS_LDB_CQ_AI_ADDR_RST 0x0
+union dlb2_sys_ldb_cq_ai_addr {
+       struct {
+               u32 rsvd1 : 2;
+               u32 cq_ai_addr : 18;
+               u32 rsvd0 : 12;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_LDB_CQ_PASID(x) \
[… more lines in the raw message]

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

drivers/event/dlb2/pf/base/dlb2_regs.h line 543

Quoted 10 lines
drivers/event/dlb2/pf/base/dlb2_regs.h new file +10 -0
+       (0x10000fa0 + (x) * 0x1000)
+#define DLB2_SYS_LDB_CQ_PASID_RST 0x0
+union dlb2_sys_ldb_cq_pasid {
+       struct {
+               u32 pasid : 20;
+               u32 exe_req : 1;
+               u32 priv_req : 1;
+               u32 fmt2 : 1;
+               u32 rsvd0 : 9;
+       } field;
[… more lines in the raw message]

0xfefcfaf8

drivers/event/dlb2/pf/base/dlb2_regs.h

Quoted 631 lines
drivers/event/dlb2/pf/base/dlb2_regs.h new file +631 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

0xfefcfaf8

drivers/event/dlb2/pf/base/dlb2_regs.h

Quoted 21 lines
drivers/event/dlb2/pf/base/dlb2_regs.h new file +21 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

0xfefcfaf8

drivers/event/dlb2/pf/base/dlb2_regs.h

Quoted 20 lines
drivers/event/dlb2/pf/base/dlb2_regs.h new file +20 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

0x84000010

drivers/event/dlb2/pf/base/dlb2_regs.h

Quoted 1 line
drivers/event/dlb2/pf/base/dlb2_regs.h new file +1 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

0xfefcfaf8

drivers/event/dlb2/pf/base/dlb2_regs.h

Quoted 11 lines
drivers/event/dlb2/pf/base/dlb2_regs.h new file +11 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

0x84000014

Review

Quoted 797 lines
drivers/event/dlb2/pf/base/dlb2_regs.h new file +796 -0

Lines of this file are not shown. View the raw message.

(quoted diff) +0 -0

The rest of this diff is not shown. View the raw message.

b/drivers/event/dlb2/pf/base/dlb2_resource.c

Review

Quoted 280 lines

new file mode 100644
index 0000000..6de8b95

drivers/event/dlb2/pf/base/dlb2_resource.c new file +274 -0

Lines of this file are not shown. View the raw message.

(quoted diff) +0 -0

The rest of this diff is not shown. View the raw message.

b/drivers/event/dlb2/pf/base/dlb2_resource.h

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 23 lines

new file mode 100644
index 0000000..503fdf3

drivers/event/dlb2/pf/base/dlb2_resource.h new file +18 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

should

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 37 lines
drivers/event/dlb2/pf/base/dlb2_resource.h new file +37 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

specified

Quoted 9 lines
drivers/event/dlb2/pf/base/dlb2_resource.h new file +9 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Quoted 7 lines

id
+ * contains the domain ID.
+ *
+ * resp->id contains a virtual ID if vdev_request is true.
+ *
+ * Errors:
+ * EINVAL - A requested resource is unavailable, or the requested domain

name

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 84 lines

+ * is already in use.
+ * EFAULT - Internal error (resp->status not set).
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +23 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

id
+ * contains the queue ID.
+ *
+ * resp->id contains a virtual ID if vdev_request is true.
+ *
+ * Errors:
+ * EINVAL - A requested resource is unavailable, the domain is not configured,
+ * the domain has already been started, or the requested queue name is
+ * already in use.
+ * EFAULT - Internal error (resp->status not set).
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +24 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

id
+ * contains the queue ID.
+ *
+ * resp->id contains a virtual ID if vdev_request is true.
+ *
+ * Errors:
+ * EINVAL - A requested resource is unavailable, the domain is not configured,
+ * or the domain has already been started.
+ * EFAULT - Internal error (resp->status not set).
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +13 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

IOVA.

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 37 lines

+ * @resp: response structure.
+ * @vdev_request: indicates whether this request came from a vdev.
+ * @vdev_id: If vdev_request is true, this contains the vdev's ID.
+ *
+ * This function creates a directed port.
+ *
+ * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
+ * device.
+ *
+ * Return:
+ * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
+ * assigned a detailed error code from enum dlb2_error. If successful, resp- id
+ * contains the port ID.
+ *
+ * resp->id contains a virtual ID if vdev_request is true.
+ *
+ * Errors:
+ * EINVAL - A requested resource is unavailable, a credit setting is invalid, a
+ * pointer address is not properly aligned, the domain is not
+ * configured, or the domain has already been started.
+ * EFAULT - Internal error (resp->status not set).
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +14 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

IOVA.

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 76 lines

+ * @resp: response structure.
+ * @vdev_request: indicates whether this request came from a vdev.
+ * @vdev_id: If vdev_request is true, this contains the vdev's ID.
+ *
+ * This function creates a load-balanced port.
+ *
+ * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
+ * device.
+ *
+ * Return:
+ * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
+ * assigned a detailed error code from enum dlb2_error. If successful, resp- id
+ * contains the port ID.
+ *
+ * resp->id contains a virtual ID if vdev_request is true.
+ *
+ * Errors:
+ * EINVAL - A requested resource is unavailable, a credit setting is invalid, a
+ * pointer address is not properly aligned, the domain is not
+ * configured, or the domain has already been started.
+ * EFAULT - Internal error (resp->status not set).
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +53 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

configured. If

Quoted 9 lines

+ * this function is unable to immediately map the queue to the port, it will
+ * add the requested operation to a per-port list of pending map/unmap
+ * operations, and (if it's not already running) launch a kernel thread that
+ * periodically attempts to process all pending operations. In a sense, this is
+ * an asynchronous function.
+ *
+ * This asynchronicity creates two views of the state of hardware: the actual
+ * hardware state and the requested state (as if every request completed
+ * immediately). If there are any pending map/unmap operations, the

requested

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 26 lines

+ * state will differ from the actual state. All validation is performed with
+ * respect to the pending state; for instance, if there are 8 pending map
+ * operations for port X, a request for a 9th will fail because a load-balanced
+ * port can only map up to 8 queues.
+ *
+ * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
+ * device.
+ *
+ * Return:
+ * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
+ * assigned a detailed error code from enum dlb2_error.
+ *
+ * Errors:
+ * EINVAL - A requested resource is unavailable, invalid port or queue ID, or
+ * the domain is not configured.
+ * EFAULT - Internal error (resp->status not set).
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +9 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

balanced port

Quoted 11 lines

+ * @hw: dlb2_hw handle for a particular device.
+ * @domain_id: domain ID.
+ * @args: unmap QID arguments.
+ * @resp: response structure.
+ * @vdev_request: indicates whether this request came from a vdev.
+ * @vdev_id: If vdev_request is true, this contains the vdev's ID.
+ *
+ * This function configures the DLB to stop scheduling QEs from the specified
+ * queue to the specified port.
+ *
+ * A successful return does not necessarily mean the mapping was removed.

If

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 27 lines

+ * this function is unable to immediately unmap the queue from the port, it
+ * will add the requested operation to a per-port list of pending map/unmap
+ * operations, and (if it's not already running) launch a kernel thread that
+ * periodically attempts to process all pending operations. See
+ * dlb2_hw_map_qid() for more details.
+ *
+ * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
+ * device.
+ *
+ * Return:
+ * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
+ * assigned a detailed error code from enum dlb2_error.
+ *
+ * Errors:
+ * EINVAL - A requested resource is unavailable, invalid port or queue ID, or
+ * the domain is not configured.
+ * EFAULT - Internal error (resp->status not set).
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +9 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

procedures

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 150 lines

+ * @hw: dlb2_hw handle for a particular device.
+ *
+ * This function attempts to finish any outstanding unmap procedures.
+ * This function should be called by the kernel thread responsible for
+ * finishing map/unmap procedures.
+ *
+ * Return:
+ * Returns the number of procedures that weren't completed.
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +141 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

mode,

Quoted 2 lines

+ * else a value up to 64.
+ * @mode: interrupt type (DLB2_CQ_ISR_MODE_MSI or

DLB2_CQ_ISR_MODE_MSIX)

Quoted 4 lines

+ * @vf: If the port is VF-owned, the VF's ID. This is used for translating the
+ * virtual port ID to a physical port ID. Ignored if mode is not MSI.
+ * @owner_vf: the VF to route the interrupt to. Ignore if mode is not MSI.
+ * @threshold: the minimum CQ depth at which the interrupt can fire. Must

be

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 25 lines

+ * greater than 0.
+ *
+ * This function configures the DLB registers for load-balanced CQ's
+ * interrupts. This doesn't enable the CQ's interrupt; that can be done with
+ * dlb2_arm_cq_interrupt() or through an interrupt arm QE.
+ *
+ * Return:
+ * Returns 0 upon success, < 0 otherwise.
+ *
+ * Errors:
+ * EINVAL - The port ID is invalid.
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +13 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

mode,

Quoted 2 lines

+ * else a value up to 64.
+ * @mode: interrupt type (DLB2_CQ_ISR_MODE_MSI or

DLB2_CQ_ISR_MODE_MSIX)

Quoted 4 lines

+ * @vf: If the port is VF-owned, the VF's ID. This is used for translating the
+ * virtual port ID to a physical port ID. Ignored if mode is not MSI.
+ * @owner_vf: the VF to route the interrupt to. Ignore if mode is not MSI.
+ * @threshold: the minimum CQ depth at which the interrupt can fire. Must

be

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 36 lines

+ * greater than 0.
+ *
+ * This function configures the DLB registers for directed CQ's interrupts.
+ * This doesn't enable the CQ's interrupt; that can be done with
+ * dlb2_arm_cq_interrupt() or through an interrupt arm QE.
+ *
+ * Return:
+ * Returns 0 upon success, < 0 otherwise.
+ *
+ * Errors:
+ * EINVAL - The port ID is invalid.
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +24 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

DLB2_MSIX_MODE_COMPRESSED)

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 45 lines

+ *
+ * This function configures the hardware to use either packed or compressed
+ * mode. This function should not be called if using MSI interrupts.
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +41 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

status

Quoted 6 lines

+ * @hw: dlb2_hw handle for a particular device.
+ * @ldb_interrupts: 2-entry array of u32 bitmaps
+ * @dir_interrupts: 4-entry array of u32 bitmaps
+ *
+ * This function can be called from a compressed CQ interrupt handler to
+ * determine which CQ interrupts have fired. The caller should take

appropriate

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 50 lines

+ * (such as waking threads blocked on a CQ's interrupt) then ack the interrupts
+ * with dlb2_ack_compressed_cq_intr().
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +47 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

MME

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 119 lines

+ * is in mode 0, then one bit 0 should ever be set.
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +117 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

queue

Quoted 4 lines

+ * @hw: dlb2_hw handle for a particular device.
+ * @group_id: sequence number group ID.
+ *
+ * This function returns the configured number of sequence numbers per

queue

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 10 lines

+ * for the specified group.
+ *
+ * Return:
+ * Returns -EINVAL if group_id is invalid, else the group's SNs per queue.
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +5 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

slots

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 14 lines

+ * @hw: dlb2_hw handle for a particular device.
+ * @group_id: sequence number group ID.
+ *
+ * This function returns the group's number of in-use slots (i.e. load-balanced
+ * queues using the specified group).
+ *
+ * Return:
+ * Returns -EINVAL if group_id is invalid, else the group's SNs per queue.
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +5 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

queue

Quoted 5 lines

+ * @hw: dlb2_hw handle for a particular device.
+ * @group_id: sequence number group ID.
+ * @val: requested amount of sequence numbers per queue.
+ *
+ * This function configures the group's number of sequence numbers per

queue.

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 20 lines

+ * val can be a power-of-two between 32 and 1024, inclusive. This setting can
+ * be configured until the first ordered load-balanced queue is configured, at
+ * which point the configuration is locked.
+ *
+ * Return:
+ * Returns 0 upon success; -EINVAL if group_id or val is invalid, -EPERM if an
+ * ordered queue is configured.
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +12 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

associated

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 24 lines

+ * resources.
+ *
+ * Pre-condition: the driver must ensure software has stopped sending QEs
+ * through this domain's producer ports before invoking this function, or
+ * undefined behavior will result.
+ *
+ * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
+ * device.
+ *
+ * Return:
+ * Returns 0 upon success, -1 otherwise.
+ *
+ * EINVAL - Invalid domain ID, or the domain is not configured.
+ * EFAULT - Internal error. (Possibly caused if software is the pre-condition
+ * is not met.)
+ * ETIMEDOUT - Hardware component didn't reset in the expected time.
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +7 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

domain

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 25 lines

+ * @hw: dlb2_hw handle for a particular device.
+ * @domain_id: domain ID.
+ * @port_id: indicates whether this request came from a VF.
+ * @vdev_request: indicates whether this request came from a vdev.
+ * @vdev_id: If vdev_request is true, this contains the vdev's ID.
+ *
+ * This function returns whether a load-balanced port is owned by a specified
+ * domain.
+ *
+ * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
+ * device.
+ *
+ * Return:
+ * Returns 0 if false, 1 if true, <0 otherwise.
+ *
+ * EINVAL - Invalid domain or port ID, or the domain is not configured.
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +8 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

domain

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 25 lines

+ * @hw: dlb2_hw handle for a particular device.
+ * @domain_id: domain ID.
+ * @port_id: indicates whether this request came from a VF.
+ * @vdev_request: indicates whether this request came from a vdev.
+ * @vdev_id: If vdev_request is true, this contains the vdev's ID.
+ *
+ * This function returns whether a directed port is owned by a specified
+ * domain.
+ *
+ * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
+ * device.
+ *
+ * Return:
+ * Returns 0 if false, 1 if true, <0 otherwise.
+ *
+ * EINVAL - Invalid domain or port ID, or the domain is not configured.
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +8 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

resources

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 22 lines

+ * @hw: dlb2_hw handle for a particular device.
+ * @arg: pointer to resource counts.
+ * @vdev_request: indicates whether this request came from a vdev.
+ * @vdev_id: If vdev_request is true, this contains the vdev's ID.
+ *
+ * This function returns the number of available resources for the PF or for a
+ * VF.
+ *
+ * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
+ * device.
+ *
+ * Return:
+ * Returns 0 upon success, -EINVAL if vdev_request is true and vdev_id is
+ * invalid.
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +7 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

resources

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 26 lines

+ * @hw: dlb2_hw handle for a particular device.
+ * @arg: pointer to resource counts.
+ * @vdev_request: indicates whether this request came from a vdev.
+ * @vdev_id: If vdev_request is true, this contains the vdev's ID.
+ *
+ * This function returns the number of resources in use by the PF or a VF. It
+ * fills in the fields that args points to, except the following:
+ * - max_contiguous_atomic_inflights
+ * - max_contiguous_hist_list_entries
+ * - max_contiguous_ldb_credits
+ * - max_contiguous_dir_credits
+ *
+ * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
+ * device.
+ *
+ * Return:
+ * Returns 0 upon success, -EINVAL if vdev_request is true and vdev_id is
+ * invalid.
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +7 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

to

Quoted 5 lines

+ * the PF
+ * @hw: dlb2_hw handle for a particular device.
+ *
+ * This function sends a VF->PF mailbox message. It is asynchronous, so it
+ * returns once the message is sent but potentially before the PF has

processed

Quoted 1 line

+ * the message. The caller must call dlb2_vdev_to_pf_complete() to

determine

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 9 lines

+ * when the PF has finished processing the request.
+ *
+ * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
+ * device.
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +4 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

mailbox

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 24 lines

+ * request
+ * @hw: dlb2_hw handle for a particular device.
+ *
+ * This function returns a boolean indicating whether the PF has finished
+ * processing a VF->PF mailbox request. It should only be called after sending
+ * an asynchronous request with dlb2_send_async_vdev_to_pf_msg().
+ *
+ * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
+ * device.
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +14 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

a

Quoted 7 lines

+ * vdev
+ * @hw: dlb2_hw handle for a particular device.
+ * @vdev_id: vdev ID.
+ *
+ * This function sends a PF->vdev mailbox message. It is asynchronous, so it
+ * returns once the message is sent but potentially before the vdev has
+ * processed the message. The caller must call dlb2_pf_to_vdev_complete()

to

Quoted 6 lines

+ * determine when the vdev has finished processing the request.
+ *
+ * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
+ * device.
+ */
+void dlb2_send_async_pf_to_vdev_msg(struct dlb2_hw *hw, unsigned int

vdev_id);

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 3 lines
drivers/event/dlb2/pf/base/dlb2_resource.h new file +3 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

mailbox

Quoted 7 lines

+ * request
+ * @hw: dlb2_hw handle for a particular device.
+ * @vdev_id: vdev ID.
+ *
+ * This function returns a boolean indicating whether the vdev has finished
+ * processing a PF->vdev mailbox request. It should only be called after
+ * sending an asynchronous request with

dlb2_send_async_pf_to_vdev_msg().

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 14 lines

+ *
+ * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
+ * device.
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +10 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

pointed

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 20 lines

+ * to by data.
+ *
+ * Return:
+ * Returns 0 upon success, <0 otherwise.
+ *
+ * EINVAL - len >= DLB2_VF2PF_REQ_BYTES.
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +13 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

pointed

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 175 lines

+ * to by data.
+ *
+ * Return:
+ * Returns 0 upon success, <0 otherwise.
+ *
+ * EINVAL - len >= DLB2_VF2PF_RESP_BYTES.
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +13 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

PF
+ * mailboxes.
+ *
+ * Return:
+ * Returns 0 upon success, <0 otherwise.
+ *
+ * EINVAL - len >= DLB2_PF2VF_RESP_BYTES.
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +13 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

PF
+ * mailboxes.
+ *
+ * Return:
+ * Returns 0 upon success, <0 otherwise.
+ *
+ * EINVAL - len >= DLB2_PF2VF_REQ_BYTES.
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +44 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

VF
+ * mailboxes.
+ *
+ * Return:
+ * Returns 0 upon success, <0 otherwise.
+ *
+ * EINVAL - len >= DLB2_VF2PF_REQ_BYTES.
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +9 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

VF
+ * mailboxes.
+ *
+ * Return:
+ * Returns 0 upon success, <0 otherwise.
+ *
+ * EINVAL - len >= DLB2_VF2PF_RESP_BYTES.
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +57 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

vdev

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 23 lines

+ * @hw: dlb2_hw handle for a particular device.
+ * @id: virtual device ID
+ * @num: number of scheduling domains to assign to this vdev
+ *
+ * This function assigns num scheduling domains to the specified vdev. If the
+ * vdev already has domains assigned, this existing assignment is adjusted
+ * accordingly.
+ *
+ * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
+ * device.
+ *
+ * Return:
+ * Returns 0 upon success, <0 otherwise.
+ *
+ * Errors:
+ * EINVAL - id is invalid, or the requested number of resources are
+ * unavailable.
+ * EPERM - The vdev's resource assignment is locked and cannot be changed.
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +4 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

vdev

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 46 lines

+ * @hw: dlb2_hw handle for a particular device.
+ * @id: virtual device ID
+ * @num: number of LDB queues to assign to this vdev
+ *
+ * This function assigns num LDB queues to the specified vdev. If the vdev
+ * already has LDB queues assigned, this existing assignment is adjusted
+ * accordingly.
+ *
+ * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
+ * device.
+ *
+ * Return:
+ * Returns 0 upon success, <0 otherwise.
+ *
+ * Errors:
+ * EINVAL - id is invalid, or the requested number of resources are
+ * unavailable.
+ * EPERM - The vdev's resource assignment is locked and cannot be changed.
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +27 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

vdev

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 98 lines

+ * @hw: dlb2_hw handle for a particular device.
+ * @id: virtual device ID
+ * @cos: class-of-service ID
+ * @num: number of LDB ports to assign to this vdev
+ *
+ * This function assigns num LDB ports from class-of-service cos to the
+ * specified vdev. If the vdev already has LDB ports from this class-of-service
+ * assigned, this existing assignment is adjusted accordingly.
+ *
+ * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
+ * device.
+ *
+ * Return:
+ * Returns 0 upon success, <0 otherwise.
+ *
+ * Errors:
+ * EINVAL - id is invalid, or the requested number of resources are
+ * unavailable.
+ * EPERM - The vdev's resource assignment is locked and cannot be changed.
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +78 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

entries

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 46 lines

+ * @hw: dlb2_hw handle for a particular device.
+ * @id: virtual device ID
+ * @num: number of history list entries to assign to this vdev
+ *
+ * This function assigns num history list entries to the specified vdev. If the
+ * vdev already has history list entries assigned, this existing assignment is
+ * adjusted accordingly. vdevs are assigned a contiguous chunk of entries, so
+ * this function may fail if a sufficiently large contiguous chunk is not
+ * available.
+ *
+ * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
+ * device.
+ *
+ * Return:
+ * Returns 0 upon success, <0 otherwise.
+ *
+ * Errors:
+ * EINVAL - id is invalid, or the requested number of resources are
+ * unavailable.
+ * EPERM - The vdev's resource assignment is locked and cannot be changed.
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +25 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

num);

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 42 lines
drivers/event/dlb2/pf/base/dlb2_resource.h new file +42 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

vdev

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 22 lines

+ * is in use.
+ *
+ * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
+ * device.
+ *
+ * Return:
+ * Returns 0 for false, 1 for true, and <0 if the mailbox request times out or
+ * an internal error occurs.
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +13 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

queue

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 83 lines

+ * @hw: dlb2_hw handle for a particular device.
+ * @domain_id: domain ID.
+ * @args: queue depth args
+ * @resp: response structure.
+ * @vdev_request: indicates whether this request came from a vdev.
+ * @vdev_id: If vdev_request is true, this contains the vdev's ID.
+ *
+ * This function returns the depth of a load-balanced queue.
+ *
+ * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
+ * device.
+ *
+ * Return:
+ * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
+ * assigned a detailed error code from enum dlb2_error. If successful, resp- id
+ * contains the depth.
+ *
+ * Errors:
+ * EINVAL - Invalid domain ID or queue ID.
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +24 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

id
+ * contains the depth.
+ *
+ * Errors:
+ * EINVAL - Invalid domain ID or queue ID.
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +32 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

mode);

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 40 lines
drivers/event/dlb2/pf/base/dlb2_resource.h new file +40 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

communication.

Quoted 1 line

+ * @pf2vdev_mbox: pointer to a 4KB memory page used for PF->vdev

communication.

Quoted 4 lines

+ * @pf2vdev_inject: callback function for injecting a PF->vdev interrupt.
+ * @inject_arg: user argument for pf2vdev_inject callback.
+ *
+ * When Scalable IOV is enabled, the VDCM must register a software mailbox

for

Quoted 4 lines

+ * every virtual device during vdev creation.
+ *
+ * This function notifies the driver to use a software mailbox using the
+ * provided pointers, instead of the device's hardware mailbox. When the

driver

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 20 lines

+ * calls mailbox functions like dlb2_pf_write_vf_mbox_req(), the request will
+ * go to the software mailbox instead of the hardware one. This is used in
+ * Scalable IOV virtualization.
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +16 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

vdev_id);

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 54 lines
drivers/event/dlb2/pf/base/dlb2_resource.h new file +54 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

operations in

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 26 lines

+ * progress.
+ * @hw: dlb2_hw handle for a particular device.
+ * @domain_id: domain ID.
+ * @args: number of unmaps in progress args
+ * @resp: response structure.
+ * @vf_request: indicates whether this request came from a VF.
+ * @vf_id: If vf_request is true, this contains the VF's ID.
+ *
+ * Return:
+ * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
+ * assigned a detailed error code from enum dlb2_error. If successful, resp- id
+ * contains the number of unmaps in progress.
+ *
+ * Errors:
+ * EINVAL - Invalid port ID.
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +9 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

allocated

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 11 lines

+ * to a port class-of-service.
+ * @hw: dlb2_hw handle for a particular device.
+ * @cos_id: class-of-service ID.
+ *
+ * Return:
+ * Returns -EINVAL if cos_id is invalid, else the class' bandwidth allocation.
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +4 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

a

Quoted 6 lines

+ * port class-of-service.
+ * @hw: dlb2_hw handle for a particular device.
+ * @cos_id: class-of-service ID.
+ * @bandwidth: class-of-service bandwidth.
+ *
+ * Return:

Quoted 8 lines

+ * Returns 0 upon success, < 0 otherwise.
+ *
+ * Errors:
+ * EINVAL - Invalid cos ID, bandwidth is greater than 100, or bandwidth would
+ * cause the total bandwidth across all classes of service to exceed
+ * 100%.
+ */
+int dlb2_hw_set_cos_bandwidth(struct dlb2_hw *hw, u32 cos_id, u8

bandwidth);

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 30 lines
drivers/event/dlb2/pf/base/dlb2_resource.h new file +30 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

tmo);

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 3 lines
drivers/event/dlb2/pf/base/dlb2_resource.h new file +3 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

an

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 19 lines

+ * individual CQ.
+ * @hw: dlb2_hw handle for a particular device.
+ * @id: port ID.
+ * @vdev_req: indicates whether this request came from a vdev.
+ * @vdev_id: If vdev_request is true, this contains the vdev's ID.
+ *
+ * Return:
+ * Returns 0 upon success, < 0 otherwise.
+ *
+ * Errors:
+ * EINVAL - Invalid directed port ID.
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +7 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

an

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 19 lines

+ * individual CQ.
+ * @hw: dlb2_hw handle for a particular device.
+ * @id: port ID.
+ * @vdev_req: indicates whether this request came from a vdev.
+ * @vdev_id: If vdev_request is true, this contains the vdev's ID.
+ *
+ * Return:
+ * Returns 0 upon success, < 0 otherwise.
+ *
+ * Errors:
+ * EINVAL - Invalid load-balanced port ID.
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +7 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

balanced

drivers/event/dlb2/pf/base/dlb2_resource.h

Quoted 9 lines

+ * ports.
+ * @hw: dlb2_hw handle for a particular device.
+ *
+ * This function must be called prior to configuring scheduling domains.
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +4 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

ports.

Review

Quoted 82 lines

+ * @hw: dlb2_hw handle for a particular device.
+ *
+ * This function must be called prior to configuring scheduling domains.
+ */

drivers/event/dlb2/pf/base/dlb2_resource.h new file +77 -0

Lines of this file are not shown. View the raw message.

(quoted diff) +0 -0

The rest of this diff is not shown. View the raw message.

b/drivers/event/dlb2/pf/dlb2_main.c

drivers/event/dlb2/pf/dlb2_main.c

Quoted 315 lines

new file mode 100644
index 0000000..bd8590d

drivers/event/dlb2/pf/dlb2_main.c new file +212 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

mem_resource[0].addr;

drivers/event/dlb2/pf/dlb2_main.c new file +97 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

DLB2_PCI_CAP_ID_EXP);

drivers/event/dlb2/pf/dlb2_main.c

Quoted 105 lines
drivers/event/dlb2/pf/dlb2_main.c new file +105 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

%d\n",

drivers/event/dlb2/pf/dlb2_main.c

Quoted 8 lines
drivers/event/dlb2/pf/dlb2_main.c new file +8 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

%d\n",

drivers/event/dlb2/pf/dlb2_main.c

Quoted 8 lines
drivers/event/dlb2/pf/dlb2_main.c new file +8 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

%d\n",

drivers/event/dlb2/pf/dlb2_main.c

Quoted 8 lines
drivers/event/dlb2/pf/dlb2_main.c new file +8 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

%d\n",

drivers/event/dlb2/pf/dlb2_main.c

Quoted 8 lines
drivers/event/dlb2/pf/dlb2_main.c new file +8 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

%d\n",

drivers/event/dlb2/pf/dlb2_main.c

Quoted 8 lines
drivers/event/dlb2/pf/dlb2_main.c new file +8 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

%d\n",

drivers/event/dlb2/pf/dlb2_main.c

Quoted 8 lines
drivers/event/dlb2/pf/dlb2_main.c new file +8 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

%d\n",

drivers/event/dlb2/pf/dlb2_main.c

Quoted 12 lines
drivers/event/dlb2/pf/dlb2_main.c new file +12 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

%d\n",

drivers/event/dlb2/pf/dlb2_main.c

Quoted 8 lines
drivers/event/dlb2/pf/dlb2_main.c new file +8 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

%d\n",

drivers/event/dlb2/pf/dlb2_main.c

Quoted 18 lines
drivers/event/dlb2/pf/dlb2_main.c new file +18 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

%d\n",

drivers/event/dlb2/pf/dlb2_main.c

Quoted 11 lines
drivers/event/dlb2/pf/dlb2_main.c new file +11 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

%d\n",

drivers/event/dlb2/pf/dlb2_main.c

Quoted 11 lines
drivers/event/dlb2/pf/dlb2_main.c new file +11 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

%d\n",

drivers/event/dlb2/pf/dlb2_main.c

Quoted 10 lines
drivers/event/dlb2/pf/dlb2_main.c new file +10 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

%d\n",

drivers/event/dlb2/pf/dlb2_main.c

Quoted 60 lines
drivers/event/dlb2/pf/dlb2_main.c new file +60 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

%d\n",

drivers/event/dlb2/pf/dlb2_main.c

Quoted 16 lines
drivers/event/dlb2/pf/dlb2_main.c new file +16 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

%d\n",

Review

Quoted 8 lines
drivers/event/dlb2/pf/dlb2_main.c new file +7 -0

Lines of this file are not shown. View the raw message.

(quoted diff) +0 -0

The rest of this diff is not shown. View the raw message.

b/drivers/event/dlb2/pf/dlb2_main.h

drivers/event/dlb2/pf/dlb2_main.h

Quoted 41 lines

new file mode 100644
index 0000000..ec96f11

drivers/event/dlb2/pf/dlb2_main.h new file +36 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

ldb_port_pages[DLB2_MAX_NUM_LDB_PORTS];

drivers/event/dlb2/pf/dlb2_main.h

Quoted 1 line
drivers/event/dlb2/pf/dlb2_main.h new file +1 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

dir_port_pages[DLB2_MAX_NUM_DIR_PORTS];

drivers/event/dlb2/pf/dlb2_main.h

Quoted 1 line
drivers/event/dlb2/pf/dlb2_main.h new file +1 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

worth)

drivers/event/dlb2/pf/dlb2_pf.c

Quoted 116 lines
drivers/event/dlb2/pf/dlb2_main.h new file +68 -0

Lines of this file are not shown. View the raw message.

drivers/event/dlb2/pf/dlb2_pf.c new file +42 -0
new file mode 100644
index 0000000..7d64309

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

RTE_STR(EVDEV_DLB2_NAME_PMD);

drivers/event/dlb2/pf/dlb2_pf.c

Quoted 121 lines
drivers/event/dlb2/pf/dlb2_pf.c new file +121 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

errno=%d\n",

Quoted 76 lines
drivers/event/dlb2/pf/dlb2_pf.c new file +76 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Quoted 8 lines
Quoted 8 lines
drivers/event/dlb2/pf/dlb2_pf.c new file +5 -1

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

2.6.4

Will fix in next drop.

Part of the diff is not shown here. View the raw message.

#224 lore raw

PATCH v2 7/22 event/dlb2: add xstats

In reply to Timothy McDaniel

Add support for DLB2 xstats. Perform initialization and add standard xstats entry points.

---
 drivers/event/dlb2/dlb2.c        |   35 +-
 drivers/event/dlb2/dlb2_xstats.c | 1240 ++++++++++++++++++++++++++++++++++++++
 drivers/event/dlb2/meson.build   |    1 +
 3 files changed, 1273 insertions(+), 3 deletions(-)
 create mode 100644 drivers/event/dlb2/dlb2_xstats.c
drivers/event/dlb2/dlb2.c +32 -3
index 26985b9..a7f8f68 100644
@@ -74,6 +74,21 @@ static struct rte_event_dev_info evdev_dlb2_default_info = {
 struct process_local_port_data
 dlb2_port[DLB2_MAX_NUM_PORTS][DLB2_NUM_PORT_TYPES];
 
+/*
+ * DUMMY - added so that xstats path will compile/link.
+ * Will be replaced by real version in a subsequent
+ * patch.
+ */
+uint32_t
+dlb2_get_queue_depth(struct dlb2_eventdev *dlb2,
+		     struct dlb2_eventdev_queue *queue)
+{
+	RTE_SET_USED(dlb2);
+	RTE_SET_USED(queue);
+
+	return 0;
+}
+
 /* override defaults with value(s) provided on command line */
 static void
 dlb2_init_queue_depth_thresholds(struct dlb2_eventdev *dlb2,
@@ -341,9 +356,16 @@ set_qid_depth_thresh(const char *key __rte_unused,
 static void
 dlb2_entry_points_init(struct rte_eventdev *dev)
 {
-	RTE_SET_USED(dev);
-
-	/* Eventdev PMD entry points */
+	/* Expose PMD's eventdev interface */
+	static struct rte_eventdev_ops dlb2_eventdev_entry_ops = {
+		.dump             = dlb2_eventdev_dump,
+		.xstats_get       = dlb2_eventdev_xstats_get,
+		.xstats_get_names = dlb2_eventdev_xstats_get_names,
+		.xstats_get_by_name = dlb2_eventdev_xstats_get_by_name,
+		.xstats_reset	    = dlb2_eventdev_xstats_reset,
+	};
+
+	dev->dev_ops = &dlb2_eventdev_entry_ops;
 }
 
 int
@@ -395,6 +417,13 @@ dlb2_primary_eventdev_probe(struct rte_eventdev *dev,
 		return err;
 	}
 
+	/* Complete xtstats runtime initialization */
+	err = dlb2_xstats_init(dlb2);
+	if (err) {
+		DLB2_LOG_ERR("dlb2: failed to init xstats, err=%d\n", err);
+		return err;
+	}
+
 	rte_spinlock_init(&dlb2->qm_instance.resource_lock);
 
 	dlb2_iface_low_level_io_init();
drivers/event/dlb2/dlb2_xstats.c new file +1240 -0

1,240 lines not on this page · raw message

drivers/event/dlb2/meson.build +1 -0
index 99b71f9..6bf8adf 100644
@@ -3,6 +3,7 @@
 
 sources = files('dlb2.c',
 		'dlb2_iface.c',
+		'dlb2_xstats.c',
 		'pf/dlb2_main.c',
 		'pf/dlb2_pf.c',
 		'pf/base/dlb2_resource.c'
Signature · 1 line
2.6.4
Reviewed-by on v2 7/22
#225 lore raw

Re: [dpdk-dev] [PATCH v2 07/22] event/dlb2: add xstats

Quoted 10 lines

-----Original Message-----
From: McDaniel, Timothy <[email protected]>
Sent: Saturday, October 17, 2020 1:21 PM
Cc: [email protected]; Carrillo, Erik G <[email protected]>; Eads, Gage <[email protected]>; Van Haaren, Harry <[email protected]>; [email protected]
Subject: [PATCH v2 07/22] event/dlb2: add xstats

Quoted 4 lines

Add support for DLB2 xstats. Perform initialization and add standard xstats entry points.

(Looks like you're missing Mike's Reviewed-by, also)

Quoted 1,355 lines
---
 drivers/event/dlb2/dlb2.c        |   35 +-
 drivers/event/dlb2/dlb2_xstats.c | 1240
++++++++++++++++++++++++++++++++++++++
 drivers/event/dlb2/meson.build   |    1 +
 3 files changed, 1273 insertions(+), 3 deletions(-)
 create mode 100644 drivers/event/dlb2/dlb2_xstats.c
drivers/event/dlb2/dlb2.c +15 -0
index 26985b9..a7f8f68 100644
@@ -74,6 +74,21 @@ static struct rte_event_dev_info evdev_dlb2_default_info
 = {
 struct process_local_port_data
 dlb2_port[DLB2_MAX_NUM_PORTS][DLB2_NUM_PORT_TYPES];
 
+/*
+ * DUMMY - added so that xstats path will compile/link.
+ * Will be replaced by real version in a subsequent
+ * patch.
+ */
+uint32_t
+dlb2_get_queue_depth(struct dlb2_eventdev *dlb2,
+		     struct dlb2_eventdev_queue *queue)
+{
+	RTE_SET_USED(dlb2);
+	RTE_SET_USED(queue);
+
+	return 0;
+}
+
 /* override defaults with value(s) provided on command line */
 static void

dlb2_init_queue_depth_thresholds(struct dlb2_eventdev *dlb2,

drivers/event/dlb2/dlb2.c +17 -3
@@ -341,9 +356,16 @@ set_qid_depth_thresh(const char *key __rte_unused,
 static void
 dlb2_entry_points_init(struct rte_eventdev *dev)
 {
-	RTE_SET_USED(dev);
-
-	/* Eventdev PMD entry points */
+	/* Expose PMD's eventdev interface */
+	static struct rte_eventdev_ops dlb2_eventdev_entry_ops = {
+		.dump             = dlb2_eventdev_dump,
+		.xstats_get       = dlb2_eventdev_xstats_get,
+		.xstats_get_names = dlb2_eventdev_xstats_get_names,
+		.xstats_get_by_name = dlb2_eventdev_xstats_get_by_name,
+		.xstats_reset	    = dlb2_eventdev_xstats_reset,
+	};
+
+	dev->dev_ops = &dlb2_eventdev_entry_ops;
 }
 
 int
@@ -395,6 +417,13 @@ dlb2_primary_eventdev_probe(struct rte_eventdev
 *dev,
 		return err;
 	}
 
+	/* Complete xtstats runtime initialization */
+	err = dlb2_xstats_init(dlb2);
+	if (err) {
+		DLB2_LOG_ERR("dlb2: failed to init xstats, err=%d\n", err);
+		return err;
+	}
+
 	rte_spinlock_init(&dlb2->qm_instance.resource_lock);
 
drivers/event/dlb2/dlb2.c +0 -0
 	dlb2_iface_low_level_io_init();
drivers/event/dlb2/dlb2_xstats.c new file +24 -0
new file mode 100644
index 0000000..21391f7
@@ -0,0 +1,1240 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2016-2020 Intel Corporation
+ */
+
+#include <inttypes.h>
+
+#include <rte_malloc.h>
+#include <rte_eventdev.h>
+
+#include "dlb2_priv.h"
+#include "dlb2_inline_fns.h"
+
+enum dlb2_xstats_type {
+	/* common to device and port */
+	rx_ok,				/**< Receive an event */
+	rx_drop,                        /**< Error bit set in received QE */
+	rx_interrupt_wait,		/**< Wait on an interrupt */
+	rx_umonitor_umwait,		/**< Block using umwait */
+	tx_ok,				/**< Transmit an event */
+	total_polls,			/**< Call dequeue_burst */
+	zero_polls,			/**< Call dequeue burst and return 0 */
+	tx_nospc_ldb_hw_credits,	/**< Insufficient LDB h/w credits */
+	tx_nospc_dir_hw_credits,	/**< Insufficient DIR h/w credits */
+	tx_nospc_inflight_max,		/**< Reach the

new_event_threshold */

drivers/event/dlb2/dlb2_xstats.c new file +10 -0
+	tx_nospc_new_event_limit,	/**< Insufficient s/w credits */
+	tx_nospc_inflight_credits,	/**< Port has too few s/w credits */
+	/* device specific */
+	nb_events_limit,
+	inflight_events,
+	ldb_pool_size,
+	dir_pool_size,
+	/* port specific */
+	tx_new,				/**< Send an OP_NEW event */
+	tx_fwd,				/**< Send an OP_FORWARD

event */

drivers/event/dlb2/dlb2_xstats.c new file +3 -0
+	tx_rel,				/**< Send an OP_RELEASE event */
+	tx_implicit_rel,		/**< Issue an implicit event release */
+	tx_sched_ordered,		/**< Send a SCHED_TYPE_ORDERED

event */

drivers/event/dlb2/dlb2_xstats.c new file +1 -0
+	tx_sched_unordered,		/**< Send a SCHED_TYPE_PARALLEL

event */

drivers/event/dlb2/dlb2_xstats.c new file +1 -0
+	tx_sched_atomic,		/**< Send a SCHED_TYPE_ATOMIC event

*/

drivers/event/dlb2/dlb2_xstats.c new file +17 -0
+	tx_sched_directed,		/**< Send a directed event */
+	tx_invalid,                     /**< Send an event with an invalid op */
+	outstanding_releases,		/**< # of releases a port owes */
+	max_outstanding_releases,	/**< max # of releases a port can owe */
+	rx_sched_ordered,		/**< Dequeue an ordered event */
+	rx_sched_unordered,		/**< Dequeue an unordered event */
+	rx_sched_atomic,		/**< Dequeue an atomic event */
+	rx_sched_directed,		/**< Dequeue an directed event */
+	rx_sched_invalid,               /**< Dequeue event sched type invalid */
+	/* common to port and queue */
+	is_configured,			/**< Port is configured */
+	is_load_balanced,		/**< Port is LDB */
+	hw_id,				/**< Hardware ID */
+	/* queue specific */
+	num_links,			/**< Number of ports linked */
+	sched_type,			/**< Queue sched type */
+	enq_ok,				/**< # events enqueued to the

queue */

drivers/event/dlb2/dlb2_xstats.c new file +6 -0
+	current_depth,			/**< Current queue depth */
+	depth_threshold,		/**< Programmed depth threshold */
+	depth_le50_threshold,
+	/**< Depth LE to 50% of the configured hardware threshold */
+	depth_gt50_le75_threshold,
+	/**< Depth GT 50%, but LE to 75% of the configured hardware threshold

*/

drivers/event/dlb2/dlb2_xstats.c new file +28 -0
+	depth_gt75_le100_threshold,
+	/**< Depth GT 75%. but LE to the configured hardware threshold */
+	depth_gt100_threshold
+	/**< Depth GT 100% of the configured hw threshold */
+};
+
+typedef uint64_t (*dlb2_xstats_fn)(struct dlb2_eventdev *dlb2,
+		uint16_t obj_idx, /* port or queue id */
+		enum dlb2_xstats_type stat, int extra_arg);
+
+enum dlb2_xstats_fn_type {
+	DLB2_XSTATS_FN_DEV,
+	DLB2_XSTATS_FN_PORT,
+	DLB2_XSTATS_FN_QUEUE
+};
+
+struct dlb2_xstats_entry {
+	struct rte_event_dev_xstats_name name;
+	uint64_t reset_value; /* an offset to be taken away to emulate resets */
+	enum dlb2_xstats_fn_type fn_id;
+	enum dlb2_xstats_type stat;
+	enum rte_event_dev_xstats_mode mode;
+	int extra_arg;
+	uint16_t obj_idx;
+	uint8_t reset_allowed; /* when set, this value can be reset */
+};
+
+/* Some device stats are simply a summation of the corresponding port values

*/

drivers/event/dlb2/dlb2_xstats.c new file +133 -0
+static uint64_t
+dlb2_device_traffic_stat_get(struct dlb2_eventdev *dlb2,
+			     int which_stat)
+{
+	int i;
+	uint64_t val = 0;
+
+	for (i = 0; i < DLB2_MAX_NUM_PORTS; i++) {
+		struct dlb2_eventdev_port *port = &dlb2->ev_ports[i];
+
+		if (!port->setup_done)
+			continue;
+
+		switch (which_stat) {
+		case rx_ok:
+			val += port->stats.traffic.rx_ok;
+			break;
+		case rx_drop:
+			val += port->stats.traffic.rx_drop;
+			break;
+		case rx_interrupt_wait:
+			val += port->stats.traffic.rx_interrupt_wait;
+			break;
+		case rx_umonitor_umwait:
+			val += port->stats.traffic.rx_umonitor_umwait;
+			break;
+		case tx_ok:
+			val += port->stats.traffic.tx_ok;
+			break;
+		case total_polls:
+			val += port->stats.traffic.total_polls;
+			break;
+		case zero_polls:
+			val += port->stats.traffic.zero_polls;
+			break;
+		case tx_nospc_ldb_hw_credits:
+			val += port->stats.traffic.tx_nospc_ldb_hw_credits;
+			break;
+		case tx_nospc_dir_hw_credits:
+			val += port->stats.traffic.tx_nospc_dir_hw_credits;
+			break;
+		case tx_nospc_inflight_max:
+			val += port->stats.traffic.tx_nospc_inflight_max;
+			break;
+		case tx_nospc_new_event_limit:
+			val += port->stats.traffic.tx_nospc_new_event_limit;
+			break;
+		case tx_nospc_inflight_credits:
+			val += port->stats.traffic.tx_nospc_inflight_credits;
+			break;
+		default:
+			return -1;
+		}
+	}
+	return val;
+}
+
+static uint64_t
+get_dev_stat(struct dlb2_eventdev *dlb2, uint16_t obj_idx __rte_unused,
+	     enum dlb2_xstats_type type, int extra_arg __rte_unused)
+{
+	switch (type) {
+	case rx_ok:
+	case rx_drop:
+	case rx_interrupt_wait:
+	case rx_umonitor_umwait:
+	case tx_ok:
+	case total_polls:
+	case zero_polls:
+	case tx_nospc_ldb_hw_credits:
+	case tx_nospc_dir_hw_credits:
+	case tx_nospc_inflight_max:
+	case tx_nospc_new_event_limit:
+	case tx_nospc_inflight_credits:
+		return dlb2_device_traffic_stat_get(dlb2, type);
+	case nb_events_limit:
+		return dlb2->new_event_limit;
+	case inflight_events:
+		return __atomic_load_n(&dlb2->inflights, __ATOMIC_SEQ_CST);
+	case ldb_pool_size:
+		return dlb2->num_ldb_credits;
+	case dir_pool_size:
+		return dlb2->num_dir_credits;
+	default: return -1;
+	}
+}
+
+static uint64_t
+get_port_stat(struct dlb2_eventdev *dlb2, uint16_t obj_idx,
+	      enum dlb2_xstats_type type, int extra_arg __rte_unused)
+{
+	struct dlb2_eventdev_port *ev_port = &dlb2->ev_ports[obj_idx];
+
+	switch (type) {
+	case rx_ok: return ev_port->stats.traffic.rx_ok;
+
+	case rx_drop: return ev_port->stats.traffic.rx_drop;
+
+	case rx_interrupt_wait: return ev_port->stats.traffic.rx_interrupt_wait;
+
+	case rx_umonitor_umwait:
+		return ev_port->stats.traffic.rx_umonitor_umwait;
+
+	case tx_ok: return ev_port->stats.traffic.tx_ok;
+
+	case total_polls: return ev_port->stats.traffic.total_polls;
+
+	case zero_polls: return ev_port->stats.traffic.zero_polls;
+
+	case tx_nospc_ldb_hw_credits:
+		return ev_port->stats.traffic.tx_nospc_ldb_hw_credits;
+
+	case tx_nospc_dir_hw_credits:
+		return ev_port->stats.traffic.tx_nospc_dir_hw_credits;
+
+	case tx_nospc_inflight_max:
+		return ev_port->stats.traffic.tx_nospc_inflight_max;
+
+	case tx_nospc_new_event_limit:
+		return ev_port->stats.traffic.tx_nospc_new_event_limit;
+
+	case tx_nospc_inflight_credits:
+		return ev_port->stats.traffic.tx_nospc_inflight_credits;
+
+	case is_configured: return ev_port->setup_done;
+
+	case is_load_balanced: return !ev_port->qm_port.is_directed;
+
+	case hw_id: return ev_port->qm_port.id;
+
+	case tx_new: return ev_port->stats.tx_op_cnt[RTE_EVENT_OP_NEW];
+
+	case tx_fwd: return ev_port-
Quoted 1 line

stats.tx_op_cnt[RTE_EVENT_OP_FORWARD];

drivers/event/dlb2/dlb2_xstats.c new file +335 -0
+
+	case tx_rel: return ev_port->stats.tx_op_cnt[RTE_EVENT_OP_RELEASE];
+
+	case tx_implicit_rel: return ev_port->stats.tx_implicit_rel;
+
+	case tx_sched_ordered:
+		return ev_port->stats.tx_sched_cnt[DLB2_SCHED_ORDERED];
+
+	case tx_sched_unordered:
+		return ev_port->stats.tx_sched_cnt[DLB2_SCHED_UNORDERED];
+
+	case tx_sched_atomic:
+		return ev_port->stats.tx_sched_cnt[DLB2_SCHED_ATOMIC];
+
+	case tx_sched_directed:
+		return ev_port->stats.tx_sched_cnt[DLB2_SCHED_DIRECTED];
+
+	case tx_invalid: return ev_port->stats.tx_invalid;
+
+	case outstanding_releases: return ev_port->outstanding_releases;
+
+	case max_outstanding_releases:
+		return DLB2_NUM_HIST_LIST_ENTRIES_PER_LDB_PORT;
+
+	case rx_sched_ordered:
+		return ev_port->stats.rx_sched_cnt[DLB2_SCHED_ORDERED];
+
+	case rx_sched_unordered:
+		return ev_port->stats.rx_sched_cnt[DLB2_SCHED_UNORDERED];
+
+	case rx_sched_atomic:
+		return ev_port->stats.rx_sched_cnt[DLB2_SCHED_ATOMIC];
+
+	case rx_sched_directed:
+		return ev_port->stats.rx_sched_cnt[DLB2_SCHED_DIRECTED];
+
+	case rx_sched_invalid: return ev_port->stats.rx_sched_invalid;
+
+	default: return -1;
+	}
+}
+
+static uint64_t
+dlb2_get_threshold_stat(struct dlb2_eventdev *dlb2, int qid, int stat)
+{
+	int port = 0;
+	uint64_t tally = 0;
+
+	for (port = 0; port < DLB2_MAX_NUM_PORTS; port++)
+		tally += dlb2->ev_ports[port].stats.queue[qid].qid_depth[stat];
+
+	return tally;
+}
+
+static uint64_t
+dlb2_get_enq_ok_stat(struct dlb2_eventdev *dlb2, int qid)
+{
+	int port = 0;
+	uint64_t enq_ok_tally = 0;
+
+	for (port = 0; port < DLB2_MAX_NUM_PORTS; port++)
+		enq_ok_tally += dlb2->ev_ports[port].stats.queue[qid].enq_ok;
+
+	return enq_ok_tally;
+}
+
+static uint64_t
+get_queue_stat(struct dlb2_eventdev *dlb2, uint16_t obj_idx,
+	       enum dlb2_xstats_type type, int extra_arg __rte_unused)
+{
+	struct dlb2_eventdev_queue *ev_queue =
+		&dlb2->ev_queues[obj_idx];
+
+	switch (type) {
+	case is_configured: return ev_queue->setup_done;
+
+	case is_load_balanced: return !ev_queue->qm_queue.is_directed;
+
+	case hw_id: return ev_queue->qm_queue.id;
+
+	case num_links: return ev_queue->num_links;
+
+	case sched_type: return ev_queue->qm_queue.sched_type;
+
+	case enq_ok: return dlb2_get_enq_ok_stat(dlb2, obj_idx);
+
+	case current_depth: return dlb2_get_queue_depth(dlb2, ev_queue);
+
+	case depth_threshold: return ev_queue->depth_threshold;
+
+	case depth_le50_threshold:
+		return dlb2_get_threshold_stat(dlb2, ev_queue->id,
+					       DLB2_QID_DEPTH_LE50);
+
+	case depth_gt50_le75_threshold:
+		return dlb2_get_threshold_stat(dlb2, ev_queue->id,
+					       DLB2_QID_DEPTH_GT50_LE75);
+
+	case depth_gt75_le100_threshold:
+		return dlb2_get_threshold_stat(dlb2, ev_queue->id,
+					       DLB2_QID_DEPTH_GT75_LE100);
+
+	case depth_gt100_threshold:
+		return dlb2_get_threshold_stat(dlb2, ev_queue->id,
+					       DLB2_QID_DEPTH_GT100);
+
+	default: return -1;
+	}
+}
+
+int
+dlb2_xstats_init(struct dlb2_eventdev *dlb2)
+{
+	/*
+	 * define the stats names and types. Used to build up the device
+	 * xstats array
+	 * There are multiple set of stats:
+	 *   - device-level,
+	 *   - per-port,
+	 *   - per-qid,
+	 *
+	 * For each of these sets, we have three parallel arrays, one for the
+	 * names, the other for the stat type parameter to be passed in the fn
+	 * call to get that stat. The third array allows resetting or not.
+	 * All these arrays must be kept in sync
+	 */
+	static const char * const dev_stats[] = {
+		"rx_ok",
+		"rx_drop",
+		"rx_interrupt_wait",
+		"rx_umonitor_umwait",
+		"tx_ok",
+		"total_polls",
+		"zero_polls",
+		"tx_nospc_ldb_hw_credits",
+		"tx_nospc_dir_hw_credits",
+		"tx_nospc_inflight_max",
+		"tx_nospc_new_event_limit",
+		"tx_nospc_inflight_credits",
+		"nb_events_limit",
+		"inflight_events",
+		"ldb_pool_size",
+		"dir_pool_size",
+	};
+	static const enum dlb2_xstats_type dev_types[] = {
+		rx_ok,
+		rx_drop,
+		rx_interrupt_wait,
+		rx_umonitor_umwait,
+		tx_ok,
+		total_polls,
+		zero_polls,
+		tx_nospc_ldb_hw_credits,
+		tx_nospc_dir_hw_credits,
+		tx_nospc_inflight_max,
+		tx_nospc_new_event_limit,
+		tx_nospc_inflight_credits,
+		nb_events_limit,
+		inflight_events,
+		ldb_pool_size,
+		dir_pool_size,
+	};
+	/* Note: generated device stats are not allowed to be reset. */
+	static const uint8_t dev_reset_allowed[] = {
+		0, /* rx_ok */
+		0, /* rx_drop */
+		0, /* rx_interrupt_wait */
+		0, /* rx_umonitor_umwait */
+		0, /* tx_ok */
+		0, /* total_polls */
+		0, /* zero_polls */
+		0, /* tx_nospc_ldb_hw_credits */
+		0, /* tx_nospc_dir_hw_credits */
+		0, /* tx_nospc_inflight_max */
+		0, /* tx_nospc_new_event_limit */
+		0, /* tx_nospc_inflight_credits */
+		0, /* nb_events_limit */
+		0, /* inflight_events */
+		0, /* ldb_pool_size */
+		0, /* dir_pool_size */
+	};
+	static const char * const port_stats[] = {
+		"is_configured",
+		"is_load_balanced",
+		"hw_id",
+		"rx_ok",
+		"rx_drop",
+		"rx_interrupt_wait",
+		"rx_umonitor_umwait",
+		"tx_ok",
+		"total_polls",
+		"zero_polls",
+		"tx_nospc_ldb_hw_credits",
+		"tx_nospc_dir_hw_credits",
+		"tx_nospc_inflight_max",
+		"tx_nospc_new_event_limit",
+		"tx_nospc_inflight_credits",
+		"tx_new",
+		"tx_fwd",
+		"tx_rel",
+		"tx_implicit_rel",
+		"tx_sched_ordered",
+		"tx_sched_unordered",
+		"tx_sched_atomic",
+		"tx_sched_directed",
+		"tx_invalid",
+		"outstanding_releases",
+		"max_outstanding_releases",
+		"rx_sched_ordered",
+		"rx_sched_unordered",
+		"rx_sched_atomic",
+		"rx_sched_directed",
+		"rx_sched_invalid"
+	};
+	static const enum dlb2_xstats_type port_types[] = {
+		is_configured,
+		is_load_balanced,
+		hw_id,
+		rx_ok,
+		rx_drop,
+		rx_interrupt_wait,
+		rx_umonitor_umwait,
+		tx_ok,
+		total_polls,
+		zero_polls,
+		tx_nospc_ldb_hw_credits,
+		tx_nospc_dir_hw_credits,
+		tx_nospc_inflight_max,
+		tx_nospc_new_event_limit,
+		tx_nospc_inflight_credits,
+		tx_new,
+		tx_fwd,
+		tx_rel,
+		tx_implicit_rel,
+		tx_sched_ordered,
+		tx_sched_unordered,
+		tx_sched_atomic,
+		tx_sched_directed,
+		tx_invalid,
+		outstanding_releases,
+		max_outstanding_releases,
+		rx_sched_ordered,
+		rx_sched_unordered,
+		rx_sched_atomic,
+		rx_sched_directed,
+		rx_sched_invalid
+	};
+	static const uint8_t port_reset_allowed[] = {
+		0, /* is_configured */
+		0, /* is_load_balanced */
+		0, /* hw_id */
+		1, /* rx_ok */
+		1, /* rx_drop */
+		1, /* rx_interrupt_wait */
+		1, /* rx_umonitor_umwait */
+		1, /* tx_ok */
+		1, /* total_polls */
+		1, /* zero_polls */
+		1, /* tx_nospc_ldb_hw_credits */
+		1, /* tx_nospc_dir_hw_credits */
+		1, /* tx_nospc_inflight_max */
+		1, /* tx_nospc_new_event_limit */
+		1, /* tx_nospc_inflight_credits */
+		1, /* tx_new */
+		1, /* tx_fwd */
+		1, /* tx_rel */
+		1, /* tx_implicit_rel */
+		1, /* tx_sched_ordered */
+		1, /* tx_sched_unordered */
+		1, /* tx_sched_atomic */
+		1, /* tx_sched_directed */
+		1, /* tx_invalid */
+		0, /* outstanding_releases */
+		0, /* max_outstanding_releases */
+		1, /* rx_sched_ordered */
+		1, /* rx_sched_unordered */
+		1, /* rx_sched_atomic */
+		1, /* rx_sched_directed */
+		1  /* rx_sched_invalid */
+	};
+
+	/* QID specific stats */
+	static const char * const qid_stats[] = {
+		"is_configured",
+		"is_load_balanced",
+		"hw_id",
+		"num_links",
+		"sched_type",
+		"enq_ok",
+		"current_depth",
+		"depth_threshold",
+		"depth_le50_threshold",
+		"depth_gt50_le75_threshold",
+		"depth_gt75_le100_threshold",
+		"depth_gt100_threshold",
+	};
+	static const enum dlb2_xstats_type qid_types[] = {
+		is_configured,
+		is_load_balanced,
+		hw_id,
+		num_links,
+		sched_type,
+		enq_ok,
+		current_depth,
+		depth_threshold,
+		depth_le50_threshold,
+		depth_gt50_le75_threshold,
+		depth_gt75_le100_threshold,
+		depth_gt100_threshold,
+	};
+	static const uint8_t qid_reset_allowed[] = {
+		0, /* is_configured */
+		0, /* is_load_balanced */
+		0, /* hw_id */
+		0, /* num_links */
+		0, /* sched_type */
+		1, /* enq_ok */
+		0, /* current_depth */
+		0, /* depth_threshold */
+		1, /* depth_le50_threshold */
+		1, /* depth_gt50_le75_threshold */
+		1, /* depth_gt75_le100_threshold */
+		1, /* depth_gt100_threshold */
+	};
+
+	/* ---- end of stat definitions ---- */
+
+	/* check sizes, since a missed comma can lead to strings being
+	 * joined by the compiler.
+	 */
+	RTE_BUILD_BUG_ON(RTE_DIM(dev_stats) != RTE_DIM(dev_types));
+	RTE_BUILD_BUG_ON(RTE_DIM(port_stats) != RTE_DIM(port_types));
+	RTE_BUILD_BUG_ON(RTE_DIM(qid_stats) != RTE_DIM(qid_types));
+
+	RTE_BUILD_BUG_ON(RTE_DIM(dev_stats) !=

RTE_DIM(dev_reset_allowed));

drivers/event/dlb2/dlb2_xstats.c new file +1 -0
+	RTE_BUILD_BUG_ON(RTE_DIM(port_stats) !=

RTE_DIM(port_reset_allowed));

drivers/event/dlb2/dlb2_xstats.c new file +1 -0
+	RTE_BUILD_BUG_ON(RTE_DIM(qid_stats) !=

RTE_DIM(qid_reset_allowed));

drivers/event/dlb2/dlb2_xstats.c new file +46 -0
+
+	/* other vars */
+	const unsigned int count = RTE_DIM(dev_stats) +
+			DLB2_MAX_NUM_PORTS * RTE_DIM(port_stats) +
+			DLB2_MAX_NUM_QUEUES * RTE_DIM(qid_stats);
+	unsigned int i, port, qid, stat_id = 0;
+
+	dlb2->xstats = rte_zmalloc_socket(NULL,
+			sizeof(dlb2->xstats[0]) * count, 0,
+			dlb2->qm_instance.info.socket_id);
+	if (dlb2->xstats == NULL)
+		return -ENOMEM;
+
+#define sname dlb2->xstats[stat_id].name.name
+	for (i = 0; i < RTE_DIM(dev_stats); i++, stat_id++) {
+		dlb2->xstats[stat_id] = (struct dlb2_xstats_entry) {
+			.fn_id = DLB2_XSTATS_FN_DEV,
+			.stat = dev_types[i],
+			.mode = RTE_EVENT_DEV_XSTATS_DEVICE,
+			.reset_allowed = dev_reset_allowed[i],
+		};
+		snprintf(sname, sizeof(sname), "dev_%s", dev_stats[i]);
+	}
+	dlb2->xstats_count_mode_dev = stat_id;
+
+	for (port = 0; port < DLB2_MAX_NUM_PORTS; port++) {
+		dlb2->xstats_offset_for_port[port] = stat_id;
+
+		uint32_t count_offset = stat_id;
+
+		for (i = 0; i < RTE_DIM(port_stats); i++, stat_id++) {
+			dlb2->xstats[stat_id] = (struct dlb2_xstats_entry){
+				.fn_id = DLB2_XSTATS_FN_PORT,
+				.obj_idx = port,
+				.stat = port_types[i],
+				.mode = RTE_EVENT_DEV_XSTATS_PORT,
+				.reset_allowed = port_reset_allowed[i],
+			};
+			snprintf(sname, sizeof(sname), "port_%u_%s",
+				 port, port_stats[i]);
+		}
+
+		dlb2->xstats_count_per_port[port] = stat_id - count_offset;
+	}
+
+	dlb2->xstats_count_mode_port = stat_id - dlb2-
Quoted 1 line

xstats_count_mode_dev;

drivers/event/dlb2/dlb2_xstats.c new file +23 -0
+
+	for (qid = 0; qid < DLB2_MAX_NUM_QUEUES; qid++) {
+		uint32_t count_offset = stat_id;
+
+		dlb2->xstats_offset_for_qid[qid] = stat_id;
+
+		for (i = 0; i < RTE_DIM(qid_stats); i++, stat_id++) {
+			dlb2->xstats[stat_id] = (struct dlb2_xstats_entry){
+				.fn_id = DLB2_XSTATS_FN_QUEUE,
+				.obj_idx = qid,
+				.stat = qid_types[i],
+				.mode = RTE_EVENT_DEV_XSTATS_QUEUE,
+				.reset_allowed = qid_reset_allowed[i],
+			};
+			snprintf(sname, sizeof(sname), "qid_%u_%s",
+				 qid, qid_stats[i]);
+		}
+
+		dlb2->xstats_count_per_qid[qid] = stat_id - count_offset;
+	}
+
+	dlb2->xstats_count_mode_queue = stat_id -
+		(dlb2->xstats_count_mode_dev + dlb2-
Quoted 1 line

xstats_count_mode_port);

drivers/event/dlb2/dlb2_xstats.c new file +17 -0
+#undef sname
+
+	dlb2->xstats_count = stat_id;
+
+	return 0;
+}
+
+void
+dlb2_xstats_uninit(struct dlb2_eventdev *dlb2)
+{
+	rte_free(dlb2->xstats);
+	dlb2->xstats_count = 0;
+}
+
+int
+dlb2_eventdev_xstats_get_names(const struct rte_eventdev *dev,
+		enum rte_event_dev_xstats_mode mode, uint8_t

queue_port_id,

drivers/event/dlb2/dlb2_xstats.c new file +17 -0
+		struct rte_event_dev_xstats_name *xstats_names,
+		unsigned int *ids, unsigned int size)
+{
+	const struct dlb2_eventdev *dlb2 = dlb2_pmd_priv(dev);
+	unsigned int i;
+	unsigned int xidx = 0;
+	uint32_t xstats_mode_count = 0;
+	uint32_t start_offset = 0;
+
+	switch (mode) {
+	case RTE_EVENT_DEV_XSTATS_DEVICE:
+		xstats_mode_count = dlb2->xstats_count_mode_dev;
+		break;
+	case RTE_EVENT_DEV_XSTATS_PORT:
+		if (queue_port_id >= DLB2_MAX_NUM_PORTS)
+			break;
+		xstats_mode_count = dlb2-
Quoted 1 line

xstats_count_per_port[queue_port_id];

drivers/event/dlb2/dlb2_xstats.c new file +8 -0
+		start_offset = dlb2->xstats_offset_for_port[queue_port_id];
+		break;
+	case RTE_EVENT_DEV_XSTATS_QUEUE:
+#if (DLB2_MAX_NUM_QUEUES <= 255) /* max 8 bit value */
+		if (queue_port_id >= DLB2_MAX_NUM_QUEUES)
+			break;
+#endif
+		xstats_mode_count = dlb2-
Quoted 1 line

xstats_count_per_qid[queue_port_id];

drivers/event/dlb2/dlb2_xstats.c new file +43 -0
+		start_offset = dlb2->xstats_offset_for_qid[queue_port_id];
+		break;
+	default:
+		return -EINVAL;
+	};
+
+	if (xstats_mode_count > size || ids == NULL || xstats_names == NULL)
+		return xstats_mode_count;
+
+	for (i = 0; i < dlb2->xstats_count && xidx < size; i++) {
+		if (dlb2->xstats[i].mode != mode)
+			continue;
+
+		if (mode != RTE_EVENT_DEV_XSTATS_DEVICE &&
+		    queue_port_id != dlb2->xstats[i].obj_idx)
+			continue;
+
+		xstats_names[xidx] = dlb2->xstats[i].name;
+		if (ids)
+			ids[xidx] = start_offset + xidx;
+		xidx++;
+	}
+	return xidx;
+}
+
+static int
+dlb2_xstats_update(struct dlb2_eventdev *dlb2,
+		enum rte_event_dev_xstats_mode mode,
+		uint8_t queue_port_id, const unsigned int ids[],
+		uint64_t values[], unsigned int n, const uint32_t reset)
+{
+	unsigned int i;
+	unsigned int xidx = 0;
+	uint32_t xstats_mode_count = 0;
+
+	switch (mode) {
+	case RTE_EVENT_DEV_XSTATS_DEVICE:
+		xstats_mode_count = dlb2->xstats_count_mode_dev;
+		break;
+	case RTE_EVENT_DEV_XSTATS_PORT:
+		if (queue_port_id >= DLB2_MAX_NUM_PORTS)
+			goto invalid_value;
+		xstats_mode_count = dlb2-
Quoted 1 line

xstats_count_per_port[queue_port_id];

drivers/event/dlb2/dlb2_xstats.c new file +7 -0
+		break;
+	case RTE_EVENT_DEV_XSTATS_QUEUE:
+#if (DLB2_MAX_NUM_QUEUES <= 255) /* max 8 bit value */
+		if (queue_port_id >= DLB2_MAX_NUM_QUEUES)
+			goto invalid_value;
+#endif
+		xstats_mode_count = dlb2-
Quoted 1 line

xstats_count_per_qid[queue_port_id];

drivers/event/dlb2/dlb2_xstats.c new file +28 -0
+		break;
+	default:
+		goto invalid_value;
+	};
+
+	for (i = 0; i < n && xidx < xstats_mode_count; i++) {
+		struct dlb2_xstats_entry *xs = &dlb2->xstats[ids[i]];
+		dlb2_xstats_fn fn;
+
+		if (ids[i] > dlb2->xstats_count || xs->mode != mode)
+			continue;
+
+		if (mode != RTE_EVENT_DEV_XSTATS_DEVICE &&
+		    queue_port_id != xs->obj_idx)
+			continue;
+
+		switch (xs->fn_id) {
+		case DLB2_XSTATS_FN_DEV:
+			fn = get_dev_stat;
+			break;
+		case DLB2_XSTATS_FN_PORT:
+			fn = get_port_stat;
+			break;
+		case DLB2_XSTATS_FN_QUEUE:
+			fn = get_queue_stat;
+			break;
+		default:
+			DLB2_LOG_ERR("Unexpected xstat fn_id %d\n", xs-
Quoted 1 line

fn_id);

drivers/event/dlb2/dlb2_xstats.c new file +24 -0
+			goto invalid_value;
+		}
+
+		uint64_t val = fn(dlb2, xs->obj_idx, xs->stat,
+				  xs->extra_arg) - xs->reset_value;
+
+		if (values)
+			values[xidx] = val;
+
+		if (xs->reset_allowed && reset)
+			xs->reset_value += val;
+
+		xidx++;
+	}
+
+	return xidx;
+
+invalid_value:
+	return -EINVAL;
+}
+
+int
+dlb2_eventdev_xstats_get(const struct rte_eventdev *dev,
+		enum rte_event_dev_xstats_mode mode, uint8_t

queue_port_id,

drivers/event/dlb2/dlb2_xstats.c new file +75 -0
+		const unsigned int ids[], uint64_t values[], unsigned int n)
+{
+	struct dlb2_eventdev *dlb2 = dlb2_pmd_priv(dev);
+	const uint32_t reset = 0;
+
+	return dlb2_xstats_update(dlb2, mode, queue_port_id, ids, values, n,
+				  reset);
+}
+
+uint64_t
+dlb2_eventdev_xstats_get_by_name(const struct rte_eventdev *dev,
+				 const char *name, unsigned int *id)
+{
+	struct dlb2_eventdev *dlb2 = dlb2_pmd_priv(dev);
+	unsigned int i;
+	dlb2_xstats_fn fn;
+
+	for (i = 0; i < dlb2->xstats_count; i++) {
+		struct dlb2_xstats_entry *xs = &dlb2->xstats[i];
+
+		if (strncmp(xs->name.name, name,
+			    RTE_EVENT_DEV_XSTATS_NAME_SIZE) == 0){
+			if (id != NULL)
+				*id = i;
+
+			switch (xs->fn_id) {
+			case DLB2_XSTATS_FN_DEV:
+				fn = get_dev_stat;
+				break;
+			case DLB2_XSTATS_FN_PORT:
+				fn = get_port_stat;
+				break;
+			case DLB2_XSTATS_FN_QUEUE:
+				fn = get_queue_stat;
+				break;
+			default:
+				DLB2_LOG_ERR("Unexpected xstat fn_id %d\n",
+					  xs->fn_id);
+				return (uint64_t)-1;
+			}
+
+			return fn(dlb2, xs->obj_idx, xs->stat,
+				  xs->extra_arg) - xs->reset_value;
+		}
+	}
+	if (id != NULL)
+		*id = (uint32_t)-1;
+	return (uint64_t)-1;
+}
+
+static void
+dlb2_xstats_reset_range(struct dlb2_eventdev *dlb2, uint32_t start,
+			uint32_t num)
+{
+	uint32_t i;
+	dlb2_xstats_fn fn;
+
+	for (i = start; i < start + num; i++) {
+		struct dlb2_xstats_entry *xs = &dlb2->xstats[i];
+
+		if (!xs->reset_allowed)
+			continue;
+
+		switch (xs->fn_id) {
+		case DLB2_XSTATS_FN_DEV:
+			fn = get_dev_stat;
+			break;
+		case DLB2_XSTATS_FN_PORT:
+			fn = get_port_stat;
+			break;
+		case DLB2_XSTATS_FN_QUEUE:
+			fn = get_queue_stat;
+			break;
+		default:
+			DLB2_LOG_ERR("Unexpected xstat fn_id %d\n", xs-
Quoted 1 line

fn_id);

drivers/event/dlb2/dlb2_xstats.c new file +204 -0
+			return;
+		}
+
+		uint64_t val = fn(dlb2, xs->obj_idx, xs->stat, xs->extra_arg);
+		xs->reset_value = val;
+	}
+}
+
+static int
+dlb2_xstats_reset_queue(struct dlb2_eventdev *dlb2, uint8_t queue_id,
+			const uint32_t ids[], uint32_t nb_ids)
+{
+	const uint32_t reset = 1;
+
+	if (ids) {
+		uint32_t nb_reset = dlb2_xstats_update(dlb2,
+					RTE_EVENT_DEV_XSTATS_QUEUE,
+					queue_id, ids, NULL, nb_ids,
+					reset);
+		return nb_reset == nb_ids ? 0 : -EINVAL;
+	}
+
+	if (ids == NULL)
+		dlb2_xstats_reset_range(dlb2,
+			dlb2->xstats_offset_for_qid[queue_id],
+			dlb2->xstats_count_per_qid[queue_id]);
+
+	return 0;
+}
+
+static int
+dlb2_xstats_reset_port(struct dlb2_eventdev *dlb2, uint8_t port_id,
+		       const uint32_t ids[], uint32_t nb_ids)
+{
+	const uint32_t reset = 1;
+	int offset = dlb2->xstats_offset_for_port[port_id];
+	int nb_stat = dlb2->xstats_count_per_port[port_id];
+
+	if (ids) {
+		uint32_t nb_reset = dlb2_xstats_update(dlb2,
+					RTE_EVENT_DEV_XSTATS_PORT, port_id,
+					ids, NULL, nb_ids,
+					reset);
+		return nb_reset == nb_ids ? 0 : -EINVAL;
+	}
+
+	dlb2_xstats_reset_range(dlb2, offset, nb_stat);
+	return 0;
+}
+
+static int
+dlb2_xstats_reset_dev(struct dlb2_eventdev *dlb2, const uint32_t ids[],
+		      uint32_t nb_ids)
+{
+	uint32_t i;
+
+	if (ids) {
+		for (i = 0; i < nb_ids; i++) {
+			uint32_t id = ids[i];
+
+			if (id >= dlb2->xstats_count_mode_dev)
+				return -EINVAL;
+			dlb2_xstats_reset_range(dlb2, id, 1);
+		}
+	} else {
+		for (i = 0; i < dlb2->xstats_count_mode_dev; i++)
+			dlb2_xstats_reset_range(dlb2, i, 1);
+	}
+
+	return 0;
+}
+
+int
+dlb2_eventdev_xstats_reset(struct rte_eventdev *dev,
+			   enum rte_event_dev_xstats_mode mode,
+			   int16_t queue_port_id,
+			   const uint32_t ids[],
+			   uint32_t nb_ids)
+{
+	struct dlb2_eventdev *dlb2 = dlb2_pmd_priv(dev);
+	uint32_t i;
+
+	/* handle -1 for queue_port_id here, looping over all ports/queues */
+	switch (mode) {
+	case RTE_EVENT_DEV_XSTATS_DEVICE:
+		if (dlb2_xstats_reset_dev(dlb2, ids, nb_ids))
+			return -EINVAL;
+		break;
+	case RTE_EVENT_DEV_XSTATS_PORT:
+		if (queue_port_id == -1) {
+			for (i = 0; i < DLB2_MAX_NUM_PORTS; i++) {
+				if (dlb2_xstats_reset_port(dlb2, i,
+							   ids, nb_ids))
+					return -EINVAL;
+			}
+		} else if (queue_port_id < DLB2_MAX_NUM_PORTS) {
+			if (dlb2_xstats_reset_port(dlb2, queue_port_id,
+						   ids, nb_ids))
+				return -EINVAL;
+		}
+		break;
+	case RTE_EVENT_DEV_XSTATS_QUEUE:
+		if (queue_port_id == -1) {
+			for (i = 0; i < DLB2_MAX_NUM_QUEUES; i++) {
+				if (dlb2_xstats_reset_queue(dlb2, i,
+							    ids, nb_ids))
+					return -EINVAL;
+			}
+		} else if (queue_port_id < DLB2_MAX_NUM_QUEUES) {
+			if (dlb2_xstats_reset_queue(dlb2, queue_port_id,
+						    ids, nb_ids))
+				return -EINVAL;
+		}
+		break;
+	};
+
+	return 0;
+}
+
+void
+dlb2_eventdev_dump(struct rte_eventdev *dev, FILE *f)
+{
+	struct dlb2_eventdev *dlb2;
+	struct dlb2_hw_dev *handle;
+	int i;
+
+	if (f == NULL) {
+		printf("Invalid file pointer\n");
+		return;
+	}
+
+	if (dev == NULL) {
+		fprintf(f, "Invalid event device\n");
+		return;
+	}
+
+	dlb2 = dlb2_pmd_priv(dev);
+
+	if (dlb2 == NULL) {
+		fprintf(f, "DLB2 Event device cannot be dumped!\n");
+		return;
+	}
+
+	if (!dlb2->configured)
+		fprintf(f, "DLB2 Event device is not configured\n");
+
+	handle = &dlb2->qm_instance;
+
+	fprintf(f, "================\n");
+	fprintf(f, "DLB2 Device Dump\n");
+	fprintf(f, "================\n");
+
+	fprintf(f, "Processor supports umonitor/umwait instructions = %s\n",
+		dlb2->umwait_allowed ? "yes" : "no");
+
+	/* Generic top level device information */
+
+	fprintf(f, "device is configured and run state =");
+	if (dlb2->run_state == DLB2_RUN_STATE_STOPPED)
+		fprintf(f, "STOPPED\n");
+	else if (dlb2->run_state == DLB2_RUN_STATE_STOPPING)
+		fprintf(f, "STOPPING\n");
+	else if (dlb2->run_state == DLB2_RUN_STATE_STARTING)
+		fprintf(f, "STARTING\n");
+	else if (dlb2->run_state == DLB2_RUN_STATE_STARTED)
+		fprintf(f, "STARTED\n");
+	else
+		fprintf(f, "UNEXPECTED\n");
+
+	fprintf(f, "domain ID=%u, socket_id=%u, evdev=%p\n",
+		handle->domain_id, handle->info.socket_id, dlb2->event_dev);
+
+	fprintf(f, "num dir ports=%u, num dir queues=%u\n",
+		dlb2->num_dir_ports, dlb2->num_dir_queues);
+
+	fprintf(f, "num ldb ports=%u, num ldb queues=%u\n",
+		dlb2->num_ldb_ports, dlb2->num_ldb_queues);
+
+	fprintf(f, "num atomic inflights=%u, hist list entries=%u\n",
+		handle->cfg.resources.num_atomic_inflights,
+		handle->cfg.resources.num_hist_list_entries);
+
+	fprintf(f, "results from most recent hw resource query:\n");
+
+	fprintf(f, "\tnum_sched_domains = %u\n",
+		dlb2->hw_rsrc_query_results.num_sched_domains);
+
+	fprintf(f, "\tnum_ldb_queues = %u\n",
+		dlb2->hw_rsrc_query_results.num_ldb_queues);
+
+	fprintf(f, "\tnum_ldb_ports = %u\n",
+		dlb2->hw_rsrc_query_results.num_ldb_ports);
+
+	fprintf(f, "\tnum_dir_ports = %u\n",
+		dlb2->hw_rsrc_query_results.num_dir_ports);
+
+	fprintf(f, "\tnum_atomic_inflights = %u\n",
+		dlb2->hw_rsrc_query_results.num_atomic_inflights);
+
+	fprintf(f, "\tnum_hist_list_entries = %u\n",
+		dlb2->hw_rsrc_query_results.num_hist_list_entries);
+
+	fprintf(f, "\tmax_contiguous_hist_list_entries = %u\n",
+		dlb2-
Quoted 1 line

hw_rsrc_query_results.max_contiguous_hist_list_entries);

drivers/event/dlb2/dlb2_xstats.c new file +173 -0
+
+	fprintf(f, "\tnum_ldb_credits = %u\n",
+		dlb2->hw_rsrc_query_results.num_ldb_credits);
+
+	fprintf(f, "\tnum_dir_credits = %u\n",
+		dlb2->hw_rsrc_query_results.num_dir_credits);
+
+	/* Port level information */
+
+	for (i = 0; i < dlb2->num_ports; i++) {
+		struct dlb2_eventdev_port *p = &dlb2->ev_ports[i];
+		int j;
+
+		if (!p->enq_configured)
+			fprintf(f, "Port_%d is not configured\n", i);
+
+		fprintf(f, "Port_%d\n", i);
+		fprintf(f, "=======\n");
+
+		fprintf(f, "\tevport_%u is configured, setup done=%d\n",
+			p->id, p->setup_done);
+
+		fprintf(f, "\tconfig state=%d, port state=%d\n",
+			p->qm_port.config_state, p->qm_port.state);
+
+		fprintf(f, "\tport is %s\n",
+			p->qm_port.is_directed ? "directed" : "load balanced");
+
+		fprintf(f, "\toutstanding releases=%u\n",
+			p->outstanding_releases);
+
+		fprintf(f, "\tinflight max=%u, inflight credits=%u\n",
+			p->inflight_max, p->inflight_credits);
+
+		fprintf(f, "\tcredit update quanta=%u, implicit release =%u\n",
+			p->credit_update_quanta, p->implicit_release);
+
+		fprintf(f, "\tnum_links=%d, queues -> ", p->num_links);
+
+		for (j = 0; j < DLB2_MAX_NUM_QIDS_PER_LDB_CQ; j++) {
+			if (p->link[j].valid)
+				fprintf(f, "id=%u prio=%u ",
+					p->link[j].queue_id,
+					p->link[j].priority);
+		}
+		fprintf(f, "\n");
+
+		fprintf(f, "\thardware port id=%u\n", p->qm_port.id);
+
+		fprintf(f, "\tcached_ldb_credits=%u\n",
+			p->qm_port.cached_ldb_credits);
+
+		fprintf(f, "\tldb_credits = %u\n",
+			p->qm_port.ldb_credits);
+
+		fprintf(f, "\tcached_dir_credits = %u\n",
+			p->qm_port.cached_dir_credits);
+
+		fprintf(f, "\tdir_credits = %u\n",
+			p->qm_port.dir_credits);
+
+		fprintf(f, "\tgenbit=%d, cq_idx=%d, cq_depth=%d\n",
+			p->qm_port.gen_bit,
+			p->qm_port.cq_idx,
+			p->qm_port.cq_depth);
+
+		fprintf(f, "\tinterrupt armed=%d\n",
+			p->qm_port.int_armed);
+
+		fprintf(f, "\tPort statistics\n");
+
+		fprintf(f, "\t\trx_ok %" PRIu64 "\n",
+			p->stats.traffic.rx_ok);
+
+		fprintf(f, "\t\trx_drop %" PRIu64 "\n",
+			p->stats.traffic.rx_drop);
+
+		fprintf(f, "\t\trx_interrupt_wait %" PRIu64 "\n",
+			p->stats.traffic.rx_interrupt_wait);
+
+		fprintf(f, "\t\trx_umonitor_umwait %" PRIu64 "\n",
+			p->stats.traffic.rx_umonitor_umwait);
+
+		fprintf(f, "\t\ttx_ok %" PRIu64 "\n",
+			p->stats.traffic.tx_ok);
+
+		fprintf(f, "\t\ttotal_polls %" PRIu64 "\n",
+			p->stats.traffic.total_polls);
+
+		fprintf(f, "\t\tzero_polls %" PRIu64 "\n",
+			p->stats.traffic.zero_polls);
+
+		fprintf(f, "\t\ttx_nospc_ldb_hw_credits %" PRIu64 "\n",
+			p->stats.traffic.tx_nospc_ldb_hw_credits);
+
+		fprintf(f, "\t\ttx_nospc_dir_hw_credits %" PRIu64 "\n",
+			p->stats.traffic.tx_nospc_dir_hw_credits);
+
+		fprintf(f, "\t\ttx_nospc_inflight_max %" PRIu64 "\n",
+			p->stats.traffic.tx_nospc_inflight_max);
+
+		fprintf(f, "\t\ttx_nospc_new_event_limit %" PRIu64 "\n",
+			p->stats.traffic.tx_nospc_new_event_limit);
+
+		fprintf(f, "\t\ttx_nospc_inflight_credits %" PRIu64 "\n",
+			p->stats.traffic.tx_nospc_inflight_credits);
+
+		fprintf(f, "\t\ttx_new %" PRIu64 "\n",
+			p->stats.tx_op_cnt[RTE_EVENT_OP_NEW]);
+
+		fprintf(f, "\t\ttx_fwd %" PRIu64 "\n",
+			p->stats.tx_op_cnt[RTE_EVENT_OP_FORWARD]);
+
+		fprintf(f, "\t\ttx_rel %" PRIu64 "\n",
+			p->stats.tx_op_cnt[RTE_EVENT_OP_RELEASE]);
+
+		fprintf(f, "\t\ttx_implicit_rel %" PRIu64 "\n",
+			p->stats.tx_implicit_rel);
+
+		fprintf(f, "\t\ttx_sched_ordered %" PRIu64 "\n",
+			p->stats.tx_sched_cnt[DLB2_SCHED_ORDERED]);
+
+		fprintf(f, "\t\ttx_sched_unordered %" PRIu64 "\n",
+			p->stats.tx_sched_cnt[DLB2_SCHED_UNORDERED]);
+
+		fprintf(f, "\t\ttx_sched_atomic %" PRIu64 "\n",
+			p->stats.tx_sched_cnt[DLB2_SCHED_ATOMIC]);
+
+		fprintf(f, "\t\ttx_sched_directed %" PRIu64 "\n",
+			p->stats.tx_sched_cnt[DLB2_SCHED_DIRECTED]);
+
+		fprintf(f, "\t\ttx_invalid %" PRIu64 "\n",
+			p->stats.tx_invalid);
+
+		fprintf(f, "\t\trx_sched_ordered %" PRIu64 "\n",
+			p->stats.rx_sched_cnt[DLB2_SCHED_ORDERED]);
+
+		fprintf(f, "\t\trx_sched_unordered %" PRIu64 "\n",
+			p->stats.rx_sched_cnt[DLB2_SCHED_UNORDERED]);
+
+		fprintf(f, "\t\trx_sched_atomic %" PRIu64 "\n",
+			p->stats.rx_sched_cnt[DLB2_SCHED_ATOMIC]);
+
+		fprintf(f, "\t\trx_sched_directed %" PRIu64 "\n",
+			p->stats.rx_sched_cnt[DLB2_SCHED_DIRECTED]);
+
+		fprintf(f, "\t\trx_sched_invalid %" PRIu64 "\n",
+			p->stats.rx_sched_invalid);
+	}
+
+	/* Queue level information */
+
+	for (i = 0; i < dlb2->num_queues; i++) {
+		struct dlb2_eventdev_queue *q = &dlb2->ev_queues[i];
+		int j, k;
+
+		if (!q->setup_done)
+			fprintf(f, "Queue_%d is not configured\n", i);
+
+		fprintf(f, "Queue_%d\n", i);
+		fprintf(f, "========\n");
+
+		fprintf(f, "\tevqueue_%u is set up\n", q->id);
+
+		fprintf(f, "\tqueue is %s\n",
+			q->qm_queue.is_directed ? "directed" : "load balanced");
+
+		fprintf(f, "\tnum_links=%d, ports -> ", q->num_links);
+
+		for (j = 0; j < dlb2->num_ports; j++) {
+			struct dlb2_eventdev_port *p = &dlb2->ev_ports[j];
+
+			for (k = 0; k < DLB2_MAX_NUM_QIDS_PER_LDB_CQ; k++)

{

drivers/event/dlb2/dlb2_xstats.c new file +13 -0
+				if (p->link[k].valid &&
+				    p->link[k].queue_id == q->id)
+					fprintf(f, "id=%u prio=%u ",
+						p->id, p->link[k].priority);
+			}
+		}
+		fprintf(f, "\n");
+
+		fprintf(f, "\tcurrent depth: %u events\n",
+			dlb2_get_queue_depth(dlb2, q));
+
+		fprintf(f, "\tnum qid inflights=%u, sched_type=%d\n",
+			q->qm_queue.num_qid_inflights, q-
Quoted 1 line

qm_queue.sched_type);

drivers/event/dlb2/dlb2_xstats.c new file +2 -0
+	}
+}
drivers/event/dlb2/meson.build +1 -1
index 99b71f9..6bf8adf 100644
@@ -3,6 +3,7 @@
 
 sources = files('dlb2.c',
 		'dlb2_iface.c',
+		'dlb2_xstats.c',
 		'pf/dlb2_main.c',
 		'pf/dlb2_pf.c',
 		'pf/base/dlb2_resource.c'
--

2.6.4

#226 lore raw

PATCH v2 8/22 event/dlb2: add infos get and configure

In reply to Timothy McDaniel

Add support for configuring the DLB2 hardware.
In particular, this patch configures the DLB2 hardware's scheduling domain, such that it is provisioned with the requested number of ports and queues, provided sufficient resources are available. Individual queues and ports are configured later in port setup and eventdev start.

---
 drivers/event/dlb2/dlb2.c                  |  310 +++
 drivers/event/dlb2/dlb2_iface.c            |    7 +-
 drivers/event/dlb2/dlb2_iface.h            |    5 +
 drivers/event/dlb2/pf/base/dlb2_resource.c | 3234 ++++++++++++++++++++++++++++
 drivers/event/dlb2/pf/dlb2_main.c          |   15 +
 drivers/event/dlb2/pf/dlb2_pf.c            |   44 +
 6 files changed, 3614 insertions(+), 1 deletion(-)
drivers/event/dlb2/dlb2.c +310 -0
index a7f8f68..79b23da 100644
@@ -89,6 +89,22 @@ dlb2_get_queue_depth(struct dlb2_eventdev *dlb2,
 	return 0;
 }
 
+static void
+dlb2_free_qe_mem(struct dlb2_port *qm_port)
+{
+	if (qm_port == NULL)
+		return;
+
+	rte_free(qm_port->qe4);
+	qm_port->qe4 = NULL;
+
+	rte_free(qm_port->int_arm_qe);
+	qm_port->int_arm_qe = NULL;
+
+	rte_free(qm_port->consume_qe);
+	qm_port->consume_qe = NULL;
+}
+
 /* override defaults with value(s) provided on command line */
 static void
 dlb2_init_queue_depth_thresholds(struct dlb2_eventdev *dlb2,
@@ -354,10 +370,304 @@ set_qid_depth_thresh(const char *key __rte_unused,
 }
 
 static void
+dlb2_eventdev_info_get(struct rte_eventdev *dev,
+		       struct rte_event_dev_info *dev_info)
+{
+	struct dlb2_eventdev *dlb2 = dlb2_pmd_priv(dev);
+	int ret;
+
+	ret = dlb2_hw_query_resources(dlb2);
+	if (ret) {
+		const struct rte_eventdev_data *data = dev->data;
+
+		DLB2_LOG_ERR("get resources err=%d, devid=%d\n",
+			     ret, data->dev_id);
+		/* fn is void, so fall through and return values set up in
+		 * probe
+		 */
+	}
+
+	/* Add num resources currently owned by this domain.
+	 * These would become available if the scheduling domain were reset due
+	 * to the application recalling eventdev_configure to *reconfigure* the
+	 * domain.
+	 */
+	evdev_dlb2_default_info.max_event_ports += dlb2->num_ldb_ports;
+	evdev_dlb2_default_info.max_event_queues += dlb2->num_ldb_queues;
+	evdev_dlb2_default_info.max_num_events += dlb2->max_ldb_credits;
+
+	evdev_dlb2_default_info.max_event_queues =
+		RTE_MIN(evdev_dlb2_default_info.max_event_queues,
+			RTE_EVENT_MAX_QUEUES_PER_DEV);
+
+	evdev_dlb2_default_info.max_num_events =
+		RTE_MIN(evdev_dlb2_default_info.max_num_events,
+			dlb2->max_num_events_override);
+
+	*dev_info = evdev_dlb2_default_info;
+}
+
+static int
+dlb2_hw_create_sched_domain(struct dlb2_hw_dev *handle,
+			    const struct dlb2_hw_rsrcs *resources_asked)
+{
+	int ret = 0;
+	struct dlb2_create_sched_domain_args *cfg;
+
+	if (resources_asked == NULL) {
+		DLB2_LOG_ERR("dlb2: dlb2_create NULL parameter\n");
+		ret = EINVAL;
+		goto error_exit;
+	}
+
+	/* Map generic qm resources to dlb2 resources */
+	cfg = &handle->cfg.resources;
+
+	/* DIR ports and queues */
+
+	cfg->num_dir_ports = resources_asked->num_dir_ports;
+
+	cfg->num_dir_credits = resources_asked->num_dir_credits;
+
+	/* LDB queues */
+
+	cfg->num_ldb_queues = resources_asked->num_ldb_queues;
+
+	/* LDB ports */
+
+	cfg->cos_strict = 0; /* Best effort */
+	cfg->num_cos_ldb_ports[0] = 0;
+	cfg->num_cos_ldb_ports[1] = 0;
+	cfg->num_cos_ldb_ports[2] = 0;
+	cfg->num_cos_ldb_ports[3] = 0;
+
+	switch (handle->cos_id) {
+	case DLB2_COS_0:
+		cfg->num_ldb_ports = 0; /* no don't care ports */
+		cfg->num_cos_ldb_ports[0] =
+			resources_asked->num_ldb_ports;
+		break;
+	case DLB2_COS_1:
+		cfg->num_ldb_ports = 0; /* no don't care ports */
+		cfg->num_cos_ldb_ports[1] = resources_asked->num_ldb_ports;
+		break;
+	case DLB2_COS_2:
+		cfg->num_ldb_ports = 0; /* no don't care ports */
+		cfg->num_cos_ldb_ports[2] = resources_asked->num_ldb_ports;
+		break;
+	case DLB2_COS_3:
+		cfg->num_ldb_ports = 0; /* no don't care ports */
+		cfg->num_cos_ldb_ports[3] =
+			resources_asked->num_ldb_ports;
+		break;
+	case DLB2_COS_DEFAULT:
+		/* all ldb ports are don't care ports from a cos perspective */
+		cfg->num_ldb_ports =
+			resources_asked->num_ldb_ports;
+		break;
+	}
+
+	cfg->num_ldb_credits =
+		resources_asked->num_ldb_credits;
+
+	cfg->num_atomic_inflights =
+		DLB2_NUM_ATOMIC_INFLIGHTS_PER_QUEUE *
+		cfg->num_ldb_queues;
+
+	cfg->num_hist_list_entries = resources_asked->num_ldb_ports *
+		DLB2_NUM_HIST_LIST_ENTRIES_PER_LDB_PORT;
+
+	DLB2_LOG_DBG("sched domain create - ldb_qs=%d, ldb_ports=%d, dir_ports=%d, atomic_inflights=%d, hist_list_entries=%d, ldb_credits=%d, dir_credits=%d\n",
+		     cfg->num_ldb_queues,
+		     resources_asked->num_ldb_ports,
+		     cfg->num_dir_ports,
+		     cfg->num_atomic_inflights,
+		     cfg->num_hist_list_entries,
+		     cfg->num_ldb_credits,
+		     cfg->num_dir_credits);
+
+	/* Configure the QM */
+
+	ret = dlb2_iface_sched_domain_create(handle, cfg);
+	if (ret < 0) {
+		DLB2_LOG_ERR("dlb2: domain create failed, ret = %d, extra status: %s\n",
+			     ret,
+			     dlb2_error_strings[cfg->response.status]);
+
+		goto error_exit;
+	}
+
+	handle->domain_id = cfg->response.id;
+	handle->cfg.configured = true;
+
+error_exit:
+
+	return ret;
+}
+
+static void
+dlb2_hw_reset_sched_domain(const struct rte_eventdev *dev, bool reconfig)
+{
+	struct dlb2_eventdev *dlb2 = dlb2_pmd_priv(dev);
+	enum dlb2_configuration_state config_state;
+	int i, j;
+
+	dlb2_iface_domain_reset(dlb2);
+
+	/* Free all dynamically allocated port memory */
+	for (i = 0; i < dlb2->num_ports; i++)
+		dlb2_free_qe_mem(&dlb2->ev_ports[i].qm_port);
+
+	/* If reconfiguring, mark the device's queues and ports as "previously
+	 * configured." If the user doesn't reconfigure them, the PMD will
+	 * reapply their previous configuration when the device is started.
+	 */
+	config_state = (reconfig) ? DLB2_PREV_CONFIGURED :
+		DLB2_NOT_CONFIGURED;
+
+	for (i = 0; i < dlb2->num_ports; i++) {
+		dlb2->ev_ports[i].qm_port.config_state = config_state;
+		/* Reset setup_done so ports can be reconfigured */
+		dlb2->ev_ports[i].setup_done = false;
+		for (j = 0; j < DLB2_MAX_NUM_QIDS_PER_LDB_CQ; j++)
+			dlb2->ev_ports[i].link[j].mapped = false;
+	}
+
+	for (i = 0; i < dlb2->num_queues; i++)
+		dlb2->ev_queues[i].qm_queue.config_state = config_state;
+
+	for (i = 0; i < DLB2_MAX_NUM_QUEUES; i++)
+		dlb2->ev_queues[i].setup_done = false;
+
+	dlb2->num_ports = 0;
+	dlb2->num_ldb_ports = 0;
+	dlb2->num_dir_ports = 0;
+	dlb2->num_queues = 0;
+	dlb2->num_ldb_queues = 0;
+	dlb2->num_dir_queues = 0;
+	dlb2->configured = false;
+}
+
+/* Note: 1 QM instance per QM device, QM instance/device == event device */
+static int
+dlb2_eventdev_configure(const struct rte_eventdev *dev)
+{
+	struct dlb2_eventdev *dlb2 = dlb2_pmd_priv(dev);
+	struct dlb2_hw_dev *handle = &dlb2->qm_instance;
+	struct dlb2_hw_rsrcs *rsrcs = &handle->info.hw_rsrc_max;
+	const struct rte_eventdev_data *data = dev->data;
+	const struct rte_event_dev_config *config = &data->dev_conf;
+	int ret;
+
+	/* If this eventdev is already configured, we must release the current
+	 * scheduling domain before attempting to configure a new one.
+	 */
+	if (dlb2->configured) {
+		dlb2_hw_reset_sched_domain(dev, true);
+
+		ret = dlb2_hw_query_resources(dlb2);
+		if (ret) {
+			DLB2_LOG_ERR("get resources err=%d, devid=%d\n",
+				     ret, data->dev_id);
+			return ret;
+		}
+	}
+
+	if (config->nb_event_queues > rsrcs->num_queues) {
+		DLB2_LOG_ERR("nb_event_queues parameter (%d) exceeds the QM device's capabilities (%d).\n",
+			     config->nb_event_queues,
+			     rsrcs->num_queues);
+		return -EINVAL;
+	}
+	if (config->nb_event_ports > (rsrcs->num_ldb_ports
+			+ rsrcs->num_dir_ports)) {
+		DLB2_LOG_ERR("nb_event_ports parameter (%d) exceeds the QM device's capabilities (%d).\n",
+			     config->nb_event_ports,
+			     (rsrcs->num_ldb_ports + rsrcs->num_dir_ports));
+		return -EINVAL;
+	}
+	if (config->nb_events_limit > rsrcs->nb_events_limit) {
+		DLB2_LOG_ERR("nb_events_limit parameter (%d) exceeds the QM device's capabilities (%d).\n",
+			     config->nb_events_limit,
+			     rsrcs->nb_events_limit);
+		return -EINVAL;
+	}
+
+	if (config->event_dev_cfg & RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT)
+		dlb2->global_dequeue_wait = false;
+	else {
+		uint32_t timeout32;
+
+		dlb2->global_dequeue_wait = true;
+
+		/* note size mismatch of timeout vals in eventdev lib. */
+		timeout32 = config->dequeue_timeout_ns;
+
+		dlb2->global_dequeue_wait_ticks =
+			timeout32 * (rte_get_timer_hz() / 1E9);
+	}
+
+	/* Does this platform support umonitor/umwait? */
+	if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_WAITPKG)) {
+		if (RTE_LIBRTE_PMD_DLB2_UMWAIT_CTL_STATE != 0 &&
+		    RTE_LIBRTE_PMD_DLB2_UMWAIT_CTL_STATE != 1) {
+			DLB2_LOG_ERR("invalid value (%d) for RTE_LIBRTE_PMD_DLB2_UMWAIT_CTL_STATE, must be 0 or 1.\n",
+				     RTE_LIBRTE_PMD_DLB2_UMWAIT_CTL_STATE);
+			return -EINVAL;
+		}
+		dlb2->umwait_allowed = true;
+	}
+
+	rsrcs->num_dir_ports = config->nb_single_link_event_port_queues;
+	rsrcs->num_ldb_ports  = config->nb_event_ports - rsrcs->num_dir_ports;
+	/* 1 dir queue per dir port */
+	rsrcs->num_ldb_queues = config->nb_event_queues - rsrcs->num_dir_ports;
+
+	/* Scale down nb_events_limit by 4 for directed credits, since there
+	 * are 4x as many load-balanced credits.
+	 */
+	rsrcs->num_ldb_credits = 0;
+	rsrcs->num_dir_credits = 0;
+
+	if (rsrcs->num_ldb_queues)
+		rsrcs->num_ldb_credits = config->nb_events_limit;
+	if (rsrcs->num_dir_ports)
+		rsrcs->num_dir_credits = config->nb_events_limit / 4;
+	if (dlb2->num_dir_credits_override != -1)
+		rsrcs->num_dir_credits = dlb2->num_dir_credits_override;
+
+	if (dlb2_hw_create_sched_domain(handle, rsrcs) < 0) {
+		DLB2_LOG_ERR("dlb2_hw_create_sched_domain failed\n");
+		return -ENODEV;
+	}
+
+	dlb2->new_event_limit = config->nb_events_limit;
+	__atomic_store_n(&dlb2->inflights, 0, __ATOMIC_SEQ_CST);
+
+	/* Save number of ports/queues for this event dev */
+	dlb2->num_ports = config->nb_event_ports;
+	dlb2->num_queues = config->nb_event_queues;
+	dlb2->num_dir_ports = rsrcs->num_dir_ports;
+	dlb2->num_ldb_ports = dlb2->num_ports - dlb2->num_dir_ports;
+	dlb2->num_ldb_queues = dlb2->num_queues - dlb2->num_dir_ports;
+	dlb2->num_dir_queues = dlb2->num_dir_ports;
+	dlb2->ldb_credit_pool = rsrcs->num_ldb_credits;
+	dlb2->max_ldb_credits = rsrcs->num_ldb_credits;
+	dlb2->dir_credit_pool = rsrcs->num_dir_credits;
+	dlb2->max_dir_credits = rsrcs->num_dir_credits;
+
+	dlb2->configured = true;
+
+	return 0;
+}
+
+static void
 dlb2_entry_points_init(struct rte_eventdev *dev)
 {
 	/* Expose PMD's eventdev interface */
 	static struct rte_eventdev_ops dlb2_eventdev_entry_ops = {
+		.dev_infos_get    = dlb2_eventdev_info_get,
+		.dev_configure    = dlb2_eventdev_configure,
 		.dump             = dlb2_eventdev_dump,
 		.xstats_get       = dlb2_eventdev_xstats_get,
 		.xstats_get_names = dlb2_eventdev_xstats_get_names,
drivers/event/dlb2/dlb2_iface.c +6 -1
index 0d93faf..a829b9b 100644
@@ -25,4 +25,9 @@ int (*dlb2_iface_get_cq_poll_mode)(struct dlb2_hw_dev *handle,
 				   enum dlb2_cq_poll_modes *mode);
 
 int (*dlb2_iface_get_num_resources)(struct dlb2_hw_dev *handle,
-				    struct dlb2_get_num_resources_args *rsrcs);
+				struct dlb2_get_num_resources_args *rsrcs);
+
+int (*dlb2_iface_sched_domain_create)(struct dlb2_hw_dev *handle,
+				struct dlb2_create_sched_domain_args *args);
+
+void (*dlb2_iface_domain_reset)(struct dlb2_eventdev *dlb2);
drivers/event/dlb2/dlb2_iface.h +5 -0
index 4fb416e..576c1c3 100644
@@ -26,4 +26,9 @@ extern int (*dlb2_iface_get_cq_poll_mode)(struct dlb2_hw_dev *handle,
 extern int (*dlb2_iface_get_num_resources)(struct dlb2_hw_dev *handle,
 				struct dlb2_get_num_resources_args *rsrcs);
 
+extern int (*dlb2_iface_sched_domain_create)(struct dlb2_hw_dev *handle,
+				 struct dlb2_create_sched_domain_args *args);
+
+extern void (*dlb2_iface_domain_reset)(struct dlb2_eventdev *dlb2);
+
 #endif /* _DLB2_IFACE_H_ */
drivers/event/dlb2/pf/base/dlb2_resource.c +3234 -0

2,655 lines not on this page · raw message

drivers/event/dlb2/pf/dlb2_main.c +15 -0
index bd8590d..061ee72 100644

Lines of this file are not shown. View the raw message.

drivers/event/dlb2/pf/dlb2_pf.c +44 -0

44 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.6.4

Part of the diff is not shown here. View the raw message.

Reviewed-by on v2 8/22
#227 lore raw

Re: [dpdk-dev] [PATCH v2 08/22] event/dlb2: add infos get and configure

Quoted 10 lines

-----Original Message-----
From: McDaniel, Timothy <[email protected]>
Sent: Saturday, October 17, 2020 1:21 PM
Cc: [email protected]; Carrillo, Erik G <[email protected]>; Eads, Gage <[email protected]>; Van Haaren, Harry <[email protected]>; [email protected]
Subject: [PATCH v2 08/22] event/dlb2: add infos get and configure

Quoted 8 lines

Add support for configuring the DLB2 hardware.
In particular, this patch configures the DLB2 hardware's scheduling domain, such that it is provisioned with the requested number of ports and queues, provided sufficient resources are available. Individual queues and ports are configured later in port setup and eventdev start.

Thanks,
Gage

#228 lore raw

PATCH v2 9/22 event/dlb2: add queue and port default conf

In reply to Timothy McDaniel

Add support for getting the queue and port default configuration.

---
 drivers/event/dlb2/dlb2.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
drivers/event/dlb2/dlb2.c +30 -0
index 79b23da..1e28640 100644
@@ -662,12 +662,42 @@ dlb2_eventdev_configure(const struct rte_eventdev *dev)
 }
 
 static void
+dlb2_eventdev_port_default_conf_get(struct rte_eventdev *dev,
+				    uint8_t port_id,
+				    struct rte_event_port_conf *port_conf)
+{
+	RTE_SET_USED(port_id);
+	struct dlb2_eventdev *dlb2 = dlb2_pmd_priv(dev);
+
+	port_conf->new_event_threshold = dlb2->new_event_limit;
+	port_conf->dequeue_depth = 32;
+	port_conf->enqueue_depth = DLB2_MAX_ENQUEUE_DEPTH;
+	port_conf->event_port_cfg = 0;
+}
+
+static void
+dlb2_eventdev_queue_default_conf_get(struct rte_eventdev *dev,
+				     uint8_t queue_id,
+				     struct rte_event_queue_conf *queue_conf)
+{
+	RTE_SET_USED(dev);
+	RTE_SET_USED(queue_id);
+
+	queue_conf->nb_atomic_flows = 1024;
+	queue_conf->nb_atomic_order_sequences = 64;
+	queue_conf->event_queue_cfg = 0;
+	queue_conf->priority = 0;
+}
+
+static void
 dlb2_entry_points_init(struct rte_eventdev *dev)
 {
 	/* Expose PMD's eventdev interface */
 	static struct rte_eventdev_ops dlb2_eventdev_entry_ops = {
 		.dev_infos_get    = dlb2_eventdev_info_get,
 		.dev_configure    = dlb2_eventdev_configure,
+		.queue_def_conf   = dlb2_eventdev_queue_default_conf_get,
+		.port_def_conf    = dlb2_eventdev_port_default_conf_get,
 		.dump             = dlb2_eventdev_dump,
 		.xstats_get       = dlb2_eventdev_xstats_get,
 		.xstats_get_names = dlb2_eventdev_xstats_get_names,
Signature · 1 line
2.6.4
Reviewed-by on v2 9/22
#229 lore raw

Re: [dpdk-dev] [PATCH v2 09/22] event/dlb2: add queue and port default conf

Quoted 10 lines

-----Original Message-----
From: McDaniel, Timothy <[email protected]>
Sent: Saturday, October 17, 2020 1:21 PM
Cc: [email protected]; Carrillo, Erik G <[email protected]>; Eads, Gage <[email protected]>; Van Haaren, Harry <[email protected]>; [email protected]
Subject: [PATCH v2 09/22] event/dlb2: add queue and port default conf

Quoted 3 lines

Add support for getting the queue and port default configuration.

Thanks,
Gage

#230 lore raw

PATCH v2 10/22 event/dlb2: add queue setup

In reply to Timothy McDaniel

Load balanced (ldb) queues are setup here. Directed queues are not set up until link time, at which point we know the directed port ID. Directed queue setup will only fail if this queue is already setup or there are no directed queues left to configure.

---
 drivers/event/dlb2/dlb2.c                  | 314 +++++++++++++++++++
 drivers/event/dlb2/dlb2_iface.c            |  12 +
 drivers/event/dlb2/dlb2_iface.h            |  12 +
 drivers/event/dlb2/pf/base/dlb2_resource.c | 464 +++++++++++++++++++++++++++++
 drivers/event/dlb2/pf/dlb2_main.c          |  10 +
 drivers/event/dlb2/pf/dlb2_pf.c            |  82 +++++
 6 files changed, 894 insertions(+)
drivers/event/dlb2/dlb2.c +314 -0
index 1e28640..bec8fa8 100644
@@ -689,6 +689,319 @@ dlb2_eventdev_queue_default_conf_get(struct rte_eventdev *dev,
 	queue_conf->priority = 0;
 }
 
+static int32_t
+dlb2_get_sn_allocation(struct dlb2_eventdev *dlb2, int group)
+{
+	struct dlb2_hw_dev *handle = &dlb2->qm_instance;
+	struct dlb2_get_sn_allocation_args cfg;
+	int ret;
+
+	cfg.group = group;
+
+	ret = dlb2_iface_get_sn_allocation(handle, &cfg);
+	if (ret < 0) {
+		DLB2_LOG_ERR("dlb2: get_sn_allocation ret=%d (driver status: %s)\n",
+			     ret, dlb2_error_strings[cfg.response.status]);
+		return ret;
+	}
+
+	return cfg.response.id;
+}
+
+static int
+dlb2_set_sn_allocation(struct dlb2_eventdev *dlb2, int group, int num)
+{
+	struct dlb2_hw_dev *handle = &dlb2->qm_instance;
+	struct dlb2_set_sn_allocation_args cfg;
+	int ret;
+
+	cfg.num = num;
+	cfg.group = group;
+
+	ret = dlb2_iface_set_sn_allocation(handle, &cfg);
+	if (ret < 0) {
+		DLB2_LOG_ERR("dlb2: set_sn_allocation ret=%d (driver status: %s)\n",
+			     ret, dlb2_error_strings[cfg.response.status]);
+		return ret;
+	}
+
+	return ret;
+}
+
+static int32_t
+dlb2_get_sn_occupancy(struct dlb2_eventdev *dlb2, int group)
+{
+	struct dlb2_hw_dev *handle = &dlb2->qm_instance;
+	struct dlb2_get_sn_occupancy_args cfg;
+	int ret;
+
+	cfg.group = group;
+
+	ret = dlb2_iface_get_sn_occupancy(handle, &cfg);
+	if (ret < 0) {
+		DLB2_LOG_ERR("dlb2: get_sn_occupancy ret=%d (driver status: %s)\n",
+			     ret, dlb2_error_strings[cfg.response.status]);
+		return ret;
+	}
+
+	return cfg.response.id;
+}
+
+/* Query the current sequence number allocations and, if they conflict with the
+ * requested LDB queue configuration, attempt to re-allocate sequence numbers.
+ * This is best-effort; if it fails, the PMD will attempt to configure the
+ * load-balanced queue and return an error.
+ */
+static void
+dlb2_program_sn_allocation(struct dlb2_eventdev *dlb2,
+			   const struct rte_event_queue_conf *queue_conf)
+{
+	int grp_occupancy[DLB2_NUM_SN_GROUPS];
+	int grp_alloc[DLB2_NUM_SN_GROUPS];
+	int i, sequence_numbers;
+
+	sequence_numbers = (int)queue_conf->nb_atomic_order_sequences;
+
+	for (i = 0; i < DLB2_NUM_SN_GROUPS; i++) {
+		int total_slots;
+
+		grp_alloc[i] = dlb2_get_sn_allocation(dlb2, i);
+		if (grp_alloc[i] < 0)
+			return;
+
+		total_slots = DLB2_MAX_LDB_SN_ALLOC / grp_alloc[i];
+
+		grp_occupancy[i] = dlb2_get_sn_occupancy(dlb2, i);
+		if (grp_occupancy[i] < 0)
+			return;
+
+		/* DLB has at least one available slot for the requested
+		 * sequence numbers, so no further configuration required.
+		 */
+		if (grp_alloc[i] == sequence_numbers &&
+		    grp_occupancy[i] < total_slots)
+			return;
+	}
+
+	/* None of the sequence number groups are configured for the requested
+	 * sequence numbers, so we have to reconfigure one of them. This is
+	 * only possible if a group is not in use.
+	 */
+	for (i = 0; i < DLB2_NUM_SN_GROUPS; i++) {
+		if (grp_occupancy[i] == 0)
+			break;
+	}
+
+	if (i == DLB2_NUM_SN_GROUPS) {
+		printf("[%s()] No groups with %d sequence_numbers are available or have free slots\n",
+		       __func__, sequence_numbers);
+		return;
+	}
+
+	/* Attempt to configure slot i with the requested number of sequence
+	 * numbers. Ignore the return value -- if this fails, the error will be
+	 * caught during subsequent queue configuration.
+	 */
+	dlb2_set_sn_allocation(dlb2, i, sequence_numbers);
+}
+
+static int32_t
+dlb2_hw_create_ldb_queue(struct dlb2_eventdev *dlb2,
+			 struct dlb2_eventdev_queue *ev_queue,
+			 const struct rte_event_queue_conf *evq_conf)
+{
+	struct dlb2_hw_dev *handle = &dlb2->qm_instance;
+	struct dlb2_queue *queue = &ev_queue->qm_queue;
+	struct dlb2_create_ldb_queue_args cfg;
+	int32_t ret;
+	uint32_t qm_qid;
+	int sched_type = -1;
+
+	if (evq_conf == NULL)
+		return -EINVAL;
+
+	if (evq_conf->event_queue_cfg & RTE_EVENT_QUEUE_CFG_ALL_TYPES) {
+		if (evq_conf->nb_atomic_order_sequences != 0)
+			sched_type = RTE_SCHED_TYPE_ORDERED;
+		else
+			sched_type = RTE_SCHED_TYPE_PARALLEL;
+	} else {
+		sched_type = evq_conf->schedule_type;
+	}
+
+	cfg.num_atomic_inflights = DLB2_NUM_ATOMIC_INFLIGHTS_PER_QUEUE;
+	cfg.num_sequence_numbers = evq_conf->nb_atomic_order_sequences;
+	cfg.num_qid_inflights = evq_conf->nb_atomic_order_sequences;
+
+	if (sched_type != RTE_SCHED_TYPE_ORDERED) {
+		cfg.num_sequence_numbers = 0;
+		cfg.num_qid_inflights = 2048;
+	}
+
+	/* App should set this to the number of hardware flows they want, not
+	 * the overall number of flows they're going to use. E.g. if app is
+	 * using 64 flows and sets compression to 64, best-case they'll get
+	 * 64 unique hashed flows in hardware.
+	 */
+	switch (evq_conf->nb_atomic_flows) {
+	/* Valid DLB2 compression levels */
+	case 64:
+	case 128:
+	case 256:
+	case 512:
+	case (1 * 1024): /* 1K */
+	case (2 * 1024): /* 2K */
+	case (4 * 1024): /* 4K */
+	case (64 * 1024): /* 64K */
+		cfg.lock_id_comp_level = evq_conf->nb_atomic_flows;
+		break;
+	default:
+		/* Invalid compression level */
+		cfg.lock_id_comp_level = 0; /* no compression */
+	}
+
+	if (ev_queue->depth_threshold == 0) {
+		cfg.depth_threshold = RTE_PMD_DLB2_DEFAULT_DEPTH_THRESH;
+		ev_queue->depth_threshold = RTE_PMD_DLB2_DEFAULT_DEPTH_THRESH;
+	} else {
+		cfg.depth_threshold = ev_queue->depth_threshold;
+	}
+
+	ret = dlb2_iface_ldb_queue_create(handle, &cfg);
+	if (ret < 0) {
+		DLB2_LOG_ERR("dlb2: create LB event queue error, ret=%d (driver status: %s)\n",
+			     ret, dlb2_error_strings[cfg.response.status]);
+		return -EINVAL;
+	}
+
+	qm_qid = cfg.response.id;
+
+	/* Save off queue config for debug, resource lookups, and reconfig */
+	queue->num_qid_inflights = cfg.num_qid_inflights;
+	queue->num_atm_inflights = cfg.num_atomic_inflights;
+
+	queue->sched_type = sched_type;
+	queue->config_state = DLB2_CONFIGURED;
+
+	DLB2_LOG_DBG("Created LB event queue %d, nb_inflights=%d, nb_seq=%d, qid inflights=%d\n",
+		     qm_qid,
+		     cfg.num_atomic_inflights,
+		     cfg.num_sequence_numbers,
+		     cfg.num_qid_inflights);
+
+	return qm_qid;
+}
+
+static int
+dlb2_eventdev_ldb_queue_setup(struct rte_eventdev *dev,
+			      struct dlb2_eventdev_queue *ev_queue,
+			      const struct rte_event_queue_conf *queue_conf)
+{
+	struct dlb2_eventdev *dlb2 = dlb2_pmd_priv(dev);
+	int32_t qm_qid;
+
+	if (queue_conf->nb_atomic_order_sequences)
+		dlb2_program_sn_allocation(dlb2, queue_conf);
+
+	qm_qid = dlb2_hw_create_ldb_queue(dlb2, ev_queue, queue_conf);
+	if (qm_qid < 0) {
+		DLB2_LOG_ERR("Failed to create the load-balanced queue\n");
+
+		return qm_qid;
+	}
+
+	dlb2->qm_ldb_to_ev_queue_id[qm_qid] = ev_queue->id;
+
+	ev_queue->qm_queue.id = qm_qid;
+
+	return 0;
+}
+
+static int dlb2_num_dir_queues_setup(struct dlb2_eventdev *dlb2)
+{
+	int i, num = 0;
+
+	for (i = 0; i < dlb2->num_queues; i++) {
+		if (dlb2->ev_queues[i].setup_done &&
+		    dlb2->ev_queues[i].qm_queue.is_directed)
+			num++;
+	}
+
+	return num;
+}
+
+static void
+dlb2_queue_link_teardown(struct dlb2_eventdev *dlb2,
+			 struct dlb2_eventdev_queue *ev_queue)
+{
+	struct dlb2_eventdev_port *ev_port;
+	int i, j;
+
+	for (i = 0; i < dlb2->num_ports; i++) {
+		ev_port = &dlb2->ev_ports[i];
+
+		for (j = 0; j < DLB2_MAX_NUM_QIDS_PER_LDB_CQ; j++) {
+			if (!ev_port->link[j].valid ||
+			    ev_port->link[j].queue_id != ev_queue->id)
+				continue;
+
+			ev_port->link[j].valid = false;
+			ev_port->num_links--;
+		}
+	}
+
+	ev_queue->num_links = 0;
+}
+
+static int
+dlb2_eventdev_queue_setup(struct rte_eventdev *dev,
+			  uint8_t ev_qid,
+			  const struct rte_event_queue_conf *queue_conf)
+{
+	struct dlb2_eventdev *dlb2 = dlb2_pmd_priv(dev);
+	struct dlb2_eventdev_queue *ev_queue;
+	int ret;
+
+	if (queue_conf == NULL)
+		return -EINVAL;
+
+	if (ev_qid >= dlb2->num_queues)
+		return -EINVAL;
+
+	ev_queue = &dlb2->ev_queues[ev_qid];
+
+	ev_queue->qm_queue.is_directed = queue_conf->event_queue_cfg &
+		RTE_EVENT_QUEUE_CFG_SINGLE_LINK;
+	ev_queue->id = ev_qid;
+	ev_queue->conf = *queue_conf;
+
+	if (!ev_queue->qm_queue.is_directed) {
+		ret = dlb2_eventdev_ldb_queue_setup(dev, ev_queue, queue_conf);
+	} else {
+		/* The directed queue isn't setup until link time, at which
+		 * point we know its directed port ID. Directed queue setup
+		 * will only fail if this queue is already setup or there are
+		 * no directed queues left to configure.
+		 */
+		ret = 0;
+
+		ev_queue->qm_queue.config_state = DLB2_NOT_CONFIGURED;
+
+		if (ev_queue->setup_done ||
+		    dlb2_num_dir_queues_setup(dlb2) == dlb2->num_dir_queues)
+			ret = -EINVAL;
+	}
+
+	/* Tear down pre-existing port->queue links */
+	if (!ret && dlb2->run_state == DLB2_RUN_STATE_STOPPED)
+		dlb2_queue_link_teardown(dlb2, ev_queue);
+
+	if (!ret)
+		ev_queue->setup_done = true;
+
+	return ret;
+}
+
 static void
 dlb2_entry_points_init(struct rte_eventdev *dev)
 {
@@ -697,6 +1010,7 @@ dlb2_entry_points_init(struct rte_eventdev *dev)
 		.dev_infos_get    = dlb2_eventdev_info_get,
 		.dev_configure    = dlb2_eventdev_configure,
 		.queue_def_conf   = dlb2_eventdev_queue_default_conf_get,
+		.queue_setup      = dlb2_eventdev_queue_setup,
 		.port_def_conf    = dlb2_eventdev_port_default_conf_get,
 		.dump             = dlb2_eventdev_dump,
 		.xstats_get       = dlb2_eventdev_xstats_get,
drivers/event/dlb2/dlb2_iface.c +12 -0
index a829b9b..4c07574 100644
@@ -31,3 +31,15 @@ int (*dlb2_iface_sched_domain_create)(struct dlb2_hw_dev *handle,
 				struct dlb2_create_sched_domain_args *args);
 
 void (*dlb2_iface_domain_reset)(struct dlb2_eventdev *dlb2);
+
+int (*dlb2_iface_ldb_queue_create)(struct dlb2_hw_dev *handle,
+				   struct dlb2_create_ldb_queue_args *cfg);
+
+int (*dlb2_iface_get_sn_allocation)(struct dlb2_hw_dev *handle,
+				    struct dlb2_get_sn_allocation_args *args);
+
+int (*dlb2_iface_set_sn_allocation)(struct dlb2_hw_dev *handle,
+				    struct dlb2_set_sn_allocation_args *args);
+
+int (*dlb2_iface_get_sn_occupancy)(struct dlb2_hw_dev *handle,
+				   struct dlb2_get_sn_occupancy_args *args);
drivers/event/dlb2/dlb2_iface.h +12 -0
index 576c1c3..c1ef7c2 100644
@@ -31,4 +31,16 @@ extern int (*dlb2_iface_sched_domain_create)(struct dlb2_hw_dev *handle,
 
 extern void (*dlb2_iface_domain_reset)(struct dlb2_eventdev *dlb2);
 
+extern int (*dlb2_iface_ldb_queue_create)(struct dlb2_hw_dev *handle,
+				  struct dlb2_create_ldb_queue_args *cfg);
+
+extern int (*dlb2_iface_get_sn_allocation)(struct dlb2_hw_dev *handle,
+				   struct dlb2_get_sn_allocation_args *args);
+
+extern int (*dlb2_iface_set_sn_allocation)(struct dlb2_hw_dev *handle,
+				   struct dlb2_set_sn_allocation_args *args);
+
+extern int (*dlb2_iface_get_sn_occupancy)(struct dlb2_hw_dev *handle,
+				  struct dlb2_get_sn_occupancy_args *args);
+
 #endif /* _DLB2_IFACE_H_ */
drivers/event/dlb2/pf/base/dlb2_resource.c +464 -0

467 lines not on this page · raw message

drivers/event/dlb2/pf/dlb2_main.c +10 -0
index 061ee72..3a938b4 100644
@@ -628,3 +628,13 @@ dlb2_pf_reset_domain(struct dlb2_hw *hw, u32 id)
 {
 	return dlb2_reset_domain(hw, id, NOT_VF_REQ, PF_ID_ZERO);
 }
+
+int
+dlb2_pf_create_ldb_queue(struct dlb2_hw *hw,
+			 u32 id,
+			 struct dlb2_create_ldb_queue_args *args,
+			 struct dlb2_cmd_response *resp)
+{
+	return dlb2_hw_create_ldb_queue(hw, id, args, resp, NOT_VF_REQ,
+					PF_ID_ZERO);
+}
drivers/event/dlb2/pf/dlb2_pf.c +82 -0

94 lines not on this page · raw message

Signature · 1 line
2.6.4
Reviewed-by on v2 10/22
#231 lore raw

Re: [dpdk-dev] [PATCH v2 10/22] event/dlb2: add queue setup

Quoted 10 lines

-----Original Message-----
From: McDaniel, Timothy <[email protected]>
Sent: Saturday, October 17, 2020 1:21 PM
Cc: [email protected]; Carrillo, Erik G <[email protected]>; Eads, Gage <[email protected]>; Van Haaren, Harry <[email protected]>; [email protected]
Subject: [PATCH v2 10/22] event/dlb2: add queue setup

Quoted 7 lines

Load balanced (ldb) queues are setup here. Directed queues are not set up until link time, at which point we know the directed port ID. Directed queue setup will only fail if this queue is already setup or there are no directed queues left to configure.

Thanks,
Gage

#232 lore raw

PATCH v2 11/22 event/dlb2: add port setup

In reply to Timothy McDaniel

Configure the load balanded (ldb) or directed (dir) port. The consumer queue (CQ) and producer port (PP) are also set up here.

---
 drivers/event/dlb2/dlb2.c                  | 501 ++++++++++++++++
 drivers/event/dlb2/dlb2_iface.c            |   9 +
 drivers/event/dlb2/dlb2_iface.h            |   8 +
 drivers/event/dlb2/pf/base/dlb2_resource.c | 922 +++++++++++++++++++++++++++++
 drivers/event/dlb2/pf/dlb2_main.c          |  37 +-
 drivers/event/dlb2/pf/dlb2_main.h          |   2 -
 drivers/event/dlb2/pf/dlb2_pf.c            | 181 ++++++
 7 files changed, 1649 insertions(+), 11 deletions(-)
drivers/event/dlb2/dlb2.c +501 -0
index bec8fa8..e956a7a 100644
@@ -103,6 +103,9 @@ dlb2_free_qe_mem(struct dlb2_port *qm_port)
 
 	rte_free(qm_port->consume_qe);
 	qm_port->consume_qe = NULL;
+
+	rte_free(dlb2_port[qm_port->id][PORT_TYPE(qm_port)].cq_base);
+	rte_free(dlb2_port[qm_port->id][PORT_TYPE(qm_port)].pp_addr);
 }
 
 /* override defaults with value(s) provided on command line */
@@ -1002,6 +1005,503 @@ dlb2_eventdev_queue_setup(struct rte_eventdev *dev,
 	return ret;
 }
 
+static int
+dlb2_init_consume_qe(struct dlb2_port *qm_port, char *mz_name)
+{
+	struct dlb2_cq_pop_qe *qe;
+
+	qe = rte_zmalloc(mz_name,
+			DLB2_NUM_QES_PER_CACHE_LINE *
+				sizeof(struct dlb2_cq_pop_qe),
+			RTE_CACHE_LINE_SIZE);
+
+	if (qe == NULL)	{
+		DLB2_LOG_ERR("dlb2: no memory for consume_qe\n");
+		return -ENOMEM;
+	}
+	qm_port->consume_qe = qe;
+
+	qe->qe_valid = 0;
+	qe->qe_frag = 0;
+	qe->qe_comp = 0;
+	qe->cq_token = 1;
+	/* Tokens value is 0-based; i.e. '0' returns 1 token, '1' returns 2,
+	 * and so on.
+	 */
+	qe->tokens = 0;	/* set at run time */
+	qe->meas_lat = 0;
+	qe->no_dec = 0;
+	/* Completion IDs are disabled */
+	qe->cmp_id = 0;
+
+	return 0;
+}
+
+static int
+dlb2_init_int_arm_qe(struct dlb2_port *qm_port, char *mz_name)
+{
+	struct dlb2_enqueue_qe *qe;
+
+	qe = rte_zmalloc(mz_name,
+			DLB2_NUM_QES_PER_CACHE_LINE *
+				sizeof(struct dlb2_enqueue_qe),
+			RTE_CACHE_LINE_SIZE);
+
+	if (qe == NULL) {
+		DLB2_LOG_ERR("dlb2: no memory for complete_qe\n");
+		return -ENOMEM;
+	}
+	qm_port->int_arm_qe = qe;
+
+	/* V2 - INT ARM is CQ_TOKEN + FRAG */
+	qe->qe_valid = 0;
+	qe->qe_frag = 1;
+	qe->qe_comp = 0;
+	qe->cq_token = 1;
+	qe->meas_lat = 0;
+	qe->no_dec = 0;
+	/* Completion IDs are disabled */
+	qe->cmp_id = 0;
+
+	return 0;
+}
+
+static int
+dlb2_init_qe_mem(struct dlb2_port *qm_port, char *mz_name)
+{
+	int ret, sz;
+
+	sz = DLB2_NUM_QES_PER_CACHE_LINE * sizeof(struct dlb2_enqueue_qe);
+
+	qm_port->qe4 = rte_zmalloc(mz_name, sz, RTE_CACHE_LINE_SIZE);
+
+	if (qm_port->qe4 == NULL) {
+		DLB2_LOG_ERR("dlb2: no qe4 memory\n");
+		ret = -ENOMEM;
+		goto error_exit;
+	}
+
+	ret = dlb2_init_int_arm_qe(qm_port, mz_name);
+	if (ret < 0) {
+		DLB2_LOG_ERR("dlb2: dlb2_init_int_arm_qe ret=%d\n", ret);
+		goto error_exit;
+	}
+
+	ret = dlb2_init_consume_qe(qm_port, mz_name);
+	if (ret < 0) {
+		DLB2_LOG_ERR("dlb2: dlb2_init_consume_qe ret=%d\n", ret);
+		goto error_exit;
+	}
+
+	return 0;
+
+error_exit:
+
+	dlb2_free_qe_mem(qm_port);
+
+	return ret;
+}
+
+static int
+dlb2_hw_create_ldb_port(struct dlb2_eventdev *dlb2,
+			struct dlb2_eventdev_port *ev_port,
+			uint32_t dequeue_depth,
+			uint32_t enqueue_depth)
+{
+	struct dlb2_hw_dev *handle = &dlb2->qm_instance;
+	struct dlb2_create_ldb_port_args cfg = {0};
+	int ret;
+	struct dlb2_port *qm_port = NULL;
+	char mz_name[RTE_MEMZONE_NAMESIZE];
+	uint32_t qm_port_id;
+	uint16_t ldb_credit_high_watermark;
+	uint16_t dir_credit_high_watermark;
+
+	if (handle == NULL)
+		return -EINVAL;
+
+	if (dequeue_depth < DLB2_MIN_CQ_DEPTH) {
+		DLB2_LOG_ERR("dlb2: invalid enqueue_depth, must be at least %d\n",
+			     DLB2_MIN_CQ_DEPTH);
+		return -EINVAL;
+	}
+
+	if (enqueue_depth < DLB2_MIN_ENQUEUE_DEPTH) {
+		DLB2_LOG_ERR("dlb2: invalid enqueue_depth, must be at least %d\n",
+			     DLB2_MIN_ENQUEUE_DEPTH);
+		return -EINVAL;
+	}
+
+	rte_spinlock_lock(&handle->resource_lock);
+
+	/* We round up to the next power of 2 if necessary */
+	cfg.cq_depth = rte_align32pow2(dequeue_depth);
+	cfg.cq_depth_threshold = 1;
+
+	cfg.cq_history_list_size = DLB2_NUM_HIST_LIST_ENTRIES_PER_LDB_PORT;
+
+	if (handle->cos_id == DLB2_COS_DEFAULT)
+		cfg.cos_id = 0;
+	else
+		cfg.cos_id = handle->cos_id;
+
+	cfg.cos_strict = 0;
+
+	/* User controls the LDB high watermark via enqueue depth. The DIR high
+	 * watermark is equal, unless the directed credit pool is too small.
+	 */
+	ldb_credit_high_watermark = enqueue_depth;
+
+	/* If there are no directed ports, the kernel driver will ignore this
+	 * port's directed credit settings. Don't use enqueue_depth if it would
+	 * require more directed credits than are available.
+	 */
+	dir_credit_high_watermark =
+		RTE_MIN(enqueue_depth,
+			handle->cfg.num_dir_credits / dlb2->num_ports);
+
+	/* Per QM values */
+
+	ret = dlb2_iface_ldb_port_create(handle, &cfg,  dlb2->poll_mode);
+	if (ret < 0) {
+		DLB2_LOG_ERR("dlb2: dlb2_ldb_port_create error, ret=%d (driver status: %s)\n",
+			     ret, dlb2_error_strings[cfg.response.status]);
+		goto error_exit;
+	}
+
+	qm_port_id = cfg.response.id;
+
+	DLB2_LOG_DBG("dlb2: ev_port %d uses qm LB port %d <<<<<\n",
+		     ev_port->id, qm_port_id);
+
+	qm_port = &ev_port->qm_port;
+	qm_port->ev_port = ev_port; /* back ptr */
+	qm_port->dlb2 = dlb2; /* back ptr */
+	/*
+	 * Allocate and init local qe struct(s).
+	 * Note: MOVDIR64 requires the enqueue QE (qe4) to be aligned.
+	 */
+
+	snprintf(mz_name, sizeof(mz_name), "dlb2_ldb_port%d",
+		 ev_port->id);
+
+	ret = dlb2_init_qe_mem(qm_port, mz_name);
+	if (ret < 0) {
+		DLB2_LOG_ERR("dlb2: init_qe_mem failed, ret=%d\n", ret);
+		goto error_exit;
+	}
+
+	qm_port->id = qm_port_id;
+
+	qm_port->cached_ldb_credits = 0;
+	qm_port->cached_dir_credits = 0;
+	/* CQs with depth < 8 use an 8-entry queue, but withhold credits so
+	 * the effective depth is smaller.
+	 */
+	qm_port->cq_depth = cfg.cq_depth <= 8 ? 8 : cfg.cq_depth;
+	qm_port->cq_idx = 0;
+	qm_port->cq_idx_unmasked = 0;
+
+	if (dlb2->poll_mode == DLB2_CQ_POLL_MODE_SPARSE)
+		qm_port->cq_depth_mask = (qm_port->cq_depth * 4) - 1;
+	else
+		qm_port->cq_depth_mask = qm_port->cq_depth - 1;
+
+	qm_port->gen_bit_shift = __builtin_popcount(qm_port->cq_depth_mask);
+	/* starting value of gen bit - it toggles at wrap time */
+	qm_port->gen_bit = 1;
+
+	qm_port->int_armed = false;
+
+	/* Save off for later use in info and lookup APIs. */
+	qm_port->qid_mappings = &dlb2->qm_ldb_to_ev_queue_id[0];
+
+	qm_port->dequeue_depth = dequeue_depth;
+
+	qm_port->owed_tokens = 0;
+	qm_port->issued_releases = 0;
+
+	/* Save config message too. */
+	rte_memcpy(&qm_port->cfg.ldb, &cfg, sizeof(qm_port->cfg.ldb));
+
+	/* update state */
+	qm_port->state = PORT_STARTED; /* enabled at create time */
+	qm_port->config_state = DLB2_CONFIGURED;
+
+	qm_port->dir_credits = dir_credit_high_watermark;
+	qm_port->ldb_credits = ldb_credit_high_watermark;
+	qm_port->credit_pool[DLB2_DIR_QUEUE] = &dlb2->dir_credit_pool;
+	qm_port->credit_pool[DLB2_LDB_QUEUE] = &dlb2->ldb_credit_pool;
+
+	DLB2_LOG_DBG("dlb2: created ldb port %d, depth = %d, ldb credits=%d, dir credits=%d\n",
+		     qm_port_id,
+		     dequeue_depth,
+		     qm_port->ldb_credits,
+		     qm_port->dir_credits);
+
+	rte_spinlock_unlock(&handle->resource_lock);
+
+	return 0;
+
+error_exit:
+
+	if (qm_port)
+		dlb2_free_qe_mem(qm_port);
+
+	rte_spinlock_unlock(&handle->resource_lock);
+
+	DLB2_LOG_ERR("dlb2: create ldb port failed!\n");
+
+	return ret;
+}
+
+static void
+dlb2_port_link_teardown(struct dlb2_eventdev *dlb2,
+			struct dlb2_eventdev_port *ev_port)
+{
+	struct dlb2_eventdev_queue *ev_queue;
+	int i;
+
+	for (i = 0; i < DLB2_MAX_NUM_QIDS_PER_LDB_CQ; i++) {
+		if (!ev_port->link[i].valid)
+			continue;
+
+		ev_queue = &dlb2->ev_queues[ev_port->link[i].queue_id];
+
+		ev_port->link[i].valid = false;
+		ev_port->num_links--;
+		ev_queue->num_links--;
+	}
+}
+
+static int
+dlb2_hw_create_dir_port(struct dlb2_eventdev *dlb2,
+			struct dlb2_eventdev_port *ev_port,
+			uint32_t dequeue_depth,
+			uint32_t enqueue_depth)
+{
+	struct dlb2_hw_dev *handle = &dlb2->qm_instance;
+	struct dlb2_create_dir_port_args cfg = {0};
+	int ret;
+	struct dlb2_port *qm_port = NULL;
+	char mz_name[RTE_MEMZONE_NAMESIZE];
+	uint32_t qm_port_id;
+	uint16_t ldb_credit_high_watermark;
+	uint16_t dir_credit_high_watermark;
+
+	if (dlb2 == NULL || handle == NULL)
+		return -EINVAL;
+
+	if (dequeue_depth < DLB2_MIN_CQ_DEPTH) {
+		DLB2_LOG_ERR("dlb2: invalid dequeue_depth, must be %d-%d\n",
+			     DLB2_MIN_CQ_DEPTH, DLB2_MAX_INPUT_QUEUE_DEPTH);
+		return -EINVAL;
+	}
+
+	if (enqueue_depth < DLB2_MIN_ENQUEUE_DEPTH) {
+		DLB2_LOG_ERR("dlb2: invalid enqueue_depth, must be at least %d\n",
+			     DLB2_MIN_ENQUEUE_DEPTH);
+		return -EINVAL;
+	}
+
+	rte_spinlock_lock(&handle->resource_lock);
+
+	/* Directed queues are configured at link time. */
+	cfg.queue_id = -1;
+
+	/* We round up to the next power of 2 if necessary */
+	cfg.cq_depth = rte_align32pow2(dequeue_depth);
+	cfg.cq_depth_threshold = 1;
+
+	/* User controls the LDB high watermark via enqueue depth. The DIR high
+	 * watermark is equal, unless the directed credit pool is too small.
+	 */
+	ldb_credit_high_watermark = enqueue_depth;
+
+	/* Don't use enqueue_depth if it would require more directed credits
+	 * than are available.
+	 */
+	dir_credit_high_watermark =
+		RTE_MIN(enqueue_depth,
+			handle->cfg.num_dir_credits / dlb2->num_ports);
+
+	/* Per QM values */
+
+	ret = dlb2_iface_dir_port_create(handle, &cfg,  dlb2->poll_mode);
+	if (ret < 0) {
+		DLB2_LOG_ERR("dlb2: dlb2_dir_port_create error, ret=%d (driver status: %s)\n",
+			     ret, dlb2_error_strings[cfg.response.status]);
+		goto error_exit;
+	}
+
+	qm_port_id = cfg.response.id;
+
+	DLB2_LOG_DBG("dlb2: ev_port %d uses qm DIR port %d <<<<<\n",
+		     ev_port->id, qm_port_id);
+
+	qm_port = &ev_port->qm_port;
+	qm_port->ev_port = ev_port; /* back ptr */
+	qm_port->dlb2 = dlb2;  /* back ptr */
+
+	/*
+	 * Init local qe struct(s).
+	 * Note: MOVDIR64 requires the enqueue QE to be aligned
+	 */
+
+	snprintf(mz_name, sizeof(mz_name), "dlb2_dir_port%d",
+		 ev_port->id);
+
+	ret = dlb2_init_qe_mem(qm_port, mz_name);
+
+	if (ret < 0) {
+		DLB2_LOG_ERR("dlb2: init_qe_mem failed, ret=%d\n", ret);
+		goto error_exit;
+	}
+
+	qm_port->id = qm_port_id;
+
+	qm_port->cached_ldb_credits = 0;
+	qm_port->cached_dir_credits = 0;
+	/* CQs with depth < 8 use an 8-entry queue, but withhold credits so
+	 * the effective depth is smaller.
+	 */
+	qm_port->cq_depth = cfg.cq_depth <= 8 ? 8 : cfg.cq_depth;
+	qm_port->cq_idx = 0;
+	qm_port->cq_idx_unmasked = 0;
+
+	if (dlb2->poll_mode == DLB2_CQ_POLL_MODE_SPARSE)
+		qm_port->cq_depth_mask = (cfg.cq_depth * 4) - 1;
+	else
+		qm_port->cq_depth_mask = cfg.cq_depth - 1;
+
+	qm_port->gen_bit_shift = __builtin_popcount(qm_port->cq_depth_mask);
+	/* starting value of gen bit - it toggles at wrap time */
+	qm_port->gen_bit = 1;
+
+	qm_port->int_armed = false;
+
+	/* Save off for later use in info and lookup APIs. */
+	qm_port->qid_mappings = &dlb2->qm_dir_to_ev_queue_id[0];
+
+	qm_port->dequeue_depth = dequeue_depth;
+
+	qm_port->owed_tokens = 0;
+	qm_port->issued_releases = 0;
+
+	/* Save config message too. */
+	rte_memcpy(&qm_port->cfg.dir, &cfg, sizeof(qm_port->cfg.dir));
+
+	/* update state */
+	qm_port->state = PORT_STARTED; /* enabled at create time */
+	qm_port->config_state = DLB2_CONFIGURED;
+
+	qm_port->dir_credits = dir_credit_high_watermark;
+	qm_port->ldb_credits = ldb_credit_high_watermark;
+	qm_port->credit_pool[DLB2_DIR_QUEUE] = &dlb2->dir_credit_pool;
+	qm_port->credit_pool[DLB2_LDB_QUEUE] = &dlb2->ldb_credit_pool;
+
+	DLB2_LOG_DBG("dlb2: created dir port %d, depth = %d cr=%d,%d\n",
+		     qm_port_id,
+		     dequeue_depth,
+		     dir_credit_high_watermark,
+		     ldb_credit_high_watermark);
+
+	rte_spinlock_unlock(&handle->resource_lock);
+
+	return 0;
+
+error_exit:
+
+	if (qm_port)
+		dlb2_free_qe_mem(qm_port);
+
+	rte_spinlock_unlock(&handle->resource_lock);
+
+	DLB2_LOG_ERR("dlb2: create dir port failed!\n");
+
+	return ret;
+}
+
+static int
+dlb2_eventdev_port_setup(struct rte_eventdev *dev,
+			 uint8_t ev_port_id,
+			 const struct rte_event_port_conf *port_conf)
+{
+	struct dlb2_eventdev *dlb2;
+	struct dlb2_eventdev_port *ev_port;
+	int ret;
+
+	if (dev == NULL || port_conf == NULL) {
+		DLB2_LOG_ERR("Null parameter\n");
+		return -EINVAL;
+	}
+
+	dlb2 = dlb2_pmd_priv(dev);
+
+	if (ev_port_id >= DLB2_MAX_NUM_PORTS)
+		return -EINVAL;
+
+	if (port_conf->dequeue_depth >
+		evdev_dlb2_default_info.max_event_port_dequeue_depth ||
+	    port_conf->enqueue_depth >
+		evdev_dlb2_default_info.max_event_port_enqueue_depth)
+		return -EINVAL;
+
+	ev_port = &dlb2->ev_ports[ev_port_id];
+	/* configured? */
+	if (ev_port->setup_done) {
+		DLB2_LOG_ERR("evport %d is already configured\n", ev_port_id);
+		return -EINVAL;
+	}
+
+	ev_port->qm_port.is_directed = port_conf->event_port_cfg &
+		RTE_EVENT_PORT_CFG_SINGLE_LINK;
+
+	if (!ev_port->qm_port.is_directed) {
+		ret = dlb2_hw_create_ldb_port(dlb2,
+					      ev_port,
+					      port_conf->dequeue_depth,
+					      port_conf->enqueue_depth);
+		if (ret < 0) {
+			DLB2_LOG_ERR("Failed to create the lB port ve portId=%d\n",
+				     ev_port_id);
+
+			return ret;
+		}
+	} else {
+		ret = dlb2_hw_create_dir_port(dlb2,
+					      ev_port,
+					      port_conf->dequeue_depth,
+					      port_conf->enqueue_depth);
+		if (ret < 0) {
+			DLB2_LOG_ERR("Failed to create the DIR port\n");
+			return ret;
+		}
+	}
+
+	/* Save off port config for reconfig */
+	ev_port->conf = *port_conf;
+
+	ev_port->id = ev_port_id;
+	ev_port->enq_configured = true;
+	ev_port->setup_done = true;
+	ev_port->inflight_max = port_conf->new_event_threshold;
+	ev_port->implicit_release = !(port_conf->event_port_cfg &
+		  RTE_EVENT_PORT_CFG_DISABLE_IMPL_REL);
+	ev_port->outstanding_releases = 0;
+	ev_port->inflight_credits = 0;
+	ev_port->credit_update_quanta = RTE_LIBRTE_PMD_DLB2_SW_CREDIT_QUANTA;
+	ev_port->dlb2 = dlb2; /* reverse link */
+
+	/* Tear down pre-existing port->queue links */
+	if (dlb2->run_state == DLB2_RUN_STATE_STOPPED)
+		dlb2_port_link_teardown(dlb2, &dlb2->ev_ports[ev_port_id]);
+
+	dev->data->ports[ev_port_id] = &dlb2->ev_ports[ev_port_id];
+
+	return 0;
+}
+
 static void
 dlb2_entry_points_init(struct rte_eventdev *dev)
 {
@@ -1012,6 +1512,7 @@ dlb2_entry_points_init(struct rte_eventdev *dev)
 		.queue_def_conf   = dlb2_eventdev_queue_default_conf_get,
 		.queue_setup      = dlb2_eventdev_queue_setup,
 		.port_def_conf    = dlb2_eventdev_port_default_conf_get,
+		.port_setup       = dlb2_eventdev_port_setup,
 		.dump             = dlb2_eventdev_dump,
 		.xstats_get       = dlb2_eventdev_xstats_get,
 		.xstats_get_names = dlb2_eventdev_xstats_get_names,
drivers/event/dlb2/dlb2_iface.c +9 -0
index 4c07574..1690d63 100644
@@ -43,3 +43,12 @@ int (*dlb2_iface_set_sn_allocation)(struct dlb2_hw_dev *handle,
 
 int (*dlb2_iface_get_sn_occupancy)(struct dlb2_hw_dev *handle,
 				   struct dlb2_get_sn_occupancy_args *args);
+
+int (*dlb2_iface_ldb_port_create)(struct dlb2_hw_dev *handle,
+				  struct dlb2_create_ldb_port_args *cfg,
+				  enum dlb2_cq_poll_modes poll_mode);
+
+int (*dlb2_iface_dir_port_create)(struct dlb2_hw_dev *handle,
+				  struct dlb2_create_dir_port_args *cfg,
+				  enum dlb2_cq_poll_modes poll_mode);
+
drivers/event/dlb2/dlb2_iface.h +8 -0
index c1ef7c2..a090a54 100644
@@ -43,4 +43,12 @@ extern int (*dlb2_iface_set_sn_allocation)(struct dlb2_hw_dev *handle,
 extern int (*dlb2_iface_get_sn_occupancy)(struct dlb2_hw_dev *handle,
 				  struct dlb2_get_sn_occupancy_args *args);
 
+extern int (*dlb2_iface_ldb_port_create)(struct dlb2_hw_dev *handle,
+					 struct dlb2_create_ldb_port_args *cfg,
+					 enum dlb2_cq_poll_modes poll_mode);
+
+extern int (*dlb2_iface_dir_port_create)(struct dlb2_hw_dev *handle,
+					 struct dlb2_create_dir_port_args *cfg,
+					 enum dlb2_cq_poll_modes poll_mode);
+
 #endif /* _DLB2_IFACE_H_ */
drivers/event/dlb2/pf/base/dlb2_resource.c +922 -0

925 lines not on this page · raw message

drivers/event/dlb2/pf/dlb2_main.c +28 -9
index 3a938b4..ec6650e 100644
@@ -128,20 +128,11 @@ static int dlb2_pci_find_capability(struct rte_pci_device *pdev, uint32_t id)
 static int
 dlb2_pf_init_driver_state(struct dlb2_dev *dlb2_dev)
 {
-	int i;
-
 	if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_MOVDIR64B))
 		dlb2_dev->enqueue_four = dlb2_movdir64b;
 	else
 		dlb2_dev->enqueue_four = dlb2_movntdq;
 
-	/* Initialize software state */
-	for (i = 0; i < DLB2_MAX_NUM_LDB_PORTS; i++)
-		dlb2_list_init_head(&dlb2_dev->ldb_port_pages[i].list);
-
-	for (i = 0; i < DLB2_MAX_NUM_DIR_PORTS; i++)
-		dlb2_list_init_head(&dlb2_dev->dir_port_pages[i].list);
-
 	rte_spinlock_init(&dlb2_dev->resource_mutex);
 	rte_spinlock_init(&dlb2_dev->measurement_lock);
 
@@ -638,3 +629,31 @@ dlb2_pf_create_ldb_queue(struct dlb2_hw *hw,
 	return dlb2_hw_create_ldb_queue(hw, id, args, resp, NOT_VF_REQ,
 					PF_ID_ZERO);
 }
+
+int
+dlb2_pf_create_ldb_port(struct dlb2_hw *hw,
+			u32 id,
+			struct dlb2_create_ldb_port_args *args,
+			uintptr_t cq_dma_base,
+			struct dlb2_cmd_response *resp)
+{
+	return dlb2_hw_create_ldb_port(hw, id, args,
+				       cq_dma_base,
+				       resp,
+				       NOT_VF_REQ,
+				       PF_ID_ZERO);
+}
+
+int
+dlb2_pf_create_dir_port(struct dlb2_hw *hw,
+			u32 id,
+			struct dlb2_create_dir_port_args *args,
+			uintptr_t cq_dma_base,
+			struct dlb2_cmd_response *resp)
+{
+	return dlb2_hw_create_dir_port(hw, id, args,
+				       cq_dma_base,
+				       resp,
+				       NOT_VF_REQ,
+				       PF_ID_ZERO);
+}
drivers/event/dlb2/pf/dlb2_main.h +0 -2
index ec96f11..674aad0 100644
@@ -33,8 +33,6 @@ struct dlb2_dev {
 	struct dlb2_hw hw;
 	/* struct list_head list; */
 	struct device *dlb2_device;
-	struct dlb2_port_memory ldb_port_pages[DLB2_MAX_NUM_LDB_PORTS];
-	struct dlb2_port_memory dir_port_pages[DLB2_MAX_NUM_DIR_PORTS];
 	/* The enqueue_four function enqueues four HCWs (one cache-line worth)
 	 * to the DLB2, using whichever mechanism is supported by the platform
 	 * on which this driver is running.
drivers/event/dlb2/pf/dlb2_pf.c +181 -0

193 lines not on this page · raw message

Signature · 1 line
2.6.4
#233 lore raw

Re: [dpdk-dev] [PATCH v2 11/22] event/dlb2: add port setup

[...]

Quoted 41 lines
drivers/event/dlb2/pf/dlb2_pf.c +27 -0
+static int
+dlb2_pf_ldb_port_create(struct dlb2_hw_dev *handle,
+			struct dlb2_create_ldb_port_args *cfg,
+			enum dlb2_cq_poll_modes poll_mode)
+{
+	struct dlb2_dev *dlb2_dev = (struct dlb2_dev *)handle->pf_dev;
+	struct dlb2_cmd_response response = {0};
+	struct dlb2_port_memory port_memory;
+	int ret, cq_alloc_depth;
+	uint8_t *port_base;
+	const struct rte_memzone *mz;
+	int alloc_sz, qe_sz;
+	phys_addr_t cq_base;
+	phys_addr_t pp_base;
+	int is_dir = false;
+
+	DLB2_INFO(dev->dlb2_device, "Entering %s()\n", __func__);
+
+	if (poll_mode == DLB2_CQ_POLL_MODE_STD)
+		qe_sz = sizeof(struct dlb2_dequeue_qe);
+	else
+		qe_sz = RTE_CACHE_LINE_SIZE;
+
+	/* Calculate the port memory required, and round up to the nearest
+	 * cache line.
+	 */
+	cq_alloc_depth = RTE_MAX(cfg->cq_depth,

DLB2_MIN_HARDWARE_CQ_DEPTH);

drivers/event/dlb2/pf/dlb2_pf.c +12 -0
+	alloc_sz = cq_alloc_depth * qe_sz;
+	alloc_sz = RTE_CACHE_LINE_ROUNDUP(alloc_sz);
+
+	port_base = dlb2_alloc_coherent_aligned(&mz, &cq_base, alloc_sz,
+						PAGE_SIZE);
+	if (port_base == NULL)
+		return -ENOMEM;
+
+	/* Lock the page in memory */
+	ret = rte_mem_lock_page(port_base);
+	if (ret < 0) {
+		DLB2_LOG_ERR("dlb2 pf pmd could not lock page for device

i/o\n");

drivers/event/dlb2/pf/dlb2_pf.c dlb2_pf_set_sn_allocation(struct dlb2_hw_dev *handle, · line 298

Quoted 4 lines
drivers/event/dlb2/pf/dlb2_pf.c +4 -0
+		goto create_port_err;
+	}
+
+

Nit: extra newline

Quoted 18 lines
drivers/event/dlb2/pf/dlb2_pf.c +18 -0
+	memset(port_base, 0, alloc_sz);
+
+	ret = dlb2_pf_create_ldb_port(&dlb2_dev->hw,
+				      handle->domain_id,
+				      cfg,
+				      cq_base,
+				      &response);
+	if (ret)
+		goto create_port_err;
+
+	pp_base = (uintptr_t)dlb2_dev->hw.func_kva + PP_BASE(is_dir);
+	dlb2_port[response.id][DLB2_LDB_PORT].pp_addr =
+		(void *)(pp_base + (PAGE_SIZE * response.id));
+
+	dlb2_port[response.id][DLB2_LDB_PORT].cq_base = (void *)(port_base);
+	memset(&port_memory, 0, sizeof(port_memory));
+
+	dlb2_port[response.id][DLB2_LDB_PORT].mz = mz;

drivers/event/dlb2/pf/dlb2_pf.c dlb2_pf_set_sn_allocation(struct dlb2_hw_dev *handle, · line 326

Quoted 10 lines
drivers/event/dlb2/pf/dlb2_pf.c +10 -0
+
+	dlb2_list_init_head(&port_memory.list);
+
+	cfg->response = response;
+
+	return 0;
+
+create_port_err:
+
+	rte_free(port_base);

This should be "rte_memzone_free(mz);"

Quoted 67 lines
drivers/event/dlb2/pf/dlb2_pf.c +44 -0
+
+	DLB2_INFO(dev->dlb2_device, "Exiting %s() with ret=%d\n",
+		  __func__, ret);
+	return ret;
+}
+
+static int
+dlb2_pf_dir_port_create(struct dlb2_hw_dev *handle,
+			struct dlb2_create_dir_port_args *cfg,
+			enum dlb2_cq_poll_modes poll_mode)
+{
+	struct dlb2_dev *dlb2_dev = (struct dlb2_dev *)handle->pf_dev;
+	struct dlb2_cmd_response response = {0};
+	struct dlb2_port_memory port_memory;
+	int ret;
+	uint8_t *port_base;
+	const struct rte_memzone *mz;
+	int alloc_sz, qe_sz;
+	phys_addr_t cq_base;
+	phys_addr_t pp_base;
+	int is_dir = true;
+
+	DLB2_INFO(dev->dlb2_device, "Entering %s()\n", __func__);
+
+	if (poll_mode == DLB2_CQ_POLL_MODE_STD)
+		qe_sz = sizeof(struct dlb2_dequeue_qe);
+	else
+		qe_sz = RTE_CACHE_LINE_SIZE;
+
+	/* Calculate the port memory required, and round up to the nearest
+	 * cache line.
+	 */
+	alloc_sz = cfg->cq_depth * qe_sz;
+	alloc_sz = RTE_CACHE_LINE_ROUNDUP(alloc_sz);
+
+	port_base = dlb2_alloc_coherent_aligned(&mz, &cq_base, alloc_sz,
+						PAGE_SIZE);
+	if (port_base == NULL)
+		return -ENOMEM;
+
+	/* Lock the page in memory */
+	ret = rte_mem_lock_page(port_base);
+	if (ret < 0) {
+		DLB2_LOG_ERR("dlb2 pf pmd could not lock page for device

i/o\n");

drivers/event/dlb2/pf/dlb2_pf.c +22 -0
+		goto create_port_err;
+	}
+
+	memset(port_base, 0, alloc_sz);
+
+	ret = dlb2_pf_create_dir_port(&dlb2_dev->hw,
+				      handle->domain_id,
+				      cfg,
+				      cq_base,
+				      &response);
+	if (ret)
+		goto create_port_err;
+
+	pp_base = (uintptr_t)dlb2_dev->hw.func_kva + PP_BASE(is_dir);
+	dlb2_port[response.id][DLB2_DIR_PORT].pp_addr =
+		(void *)(pp_base + (PAGE_SIZE * response.id));
+
+	dlb2_port[response.id][DLB2_DIR_PORT].cq_base =
+		(void *)(port_base);
+	memset(&port_memory, 0, sizeof(port_memory));
+
+	dlb2_port[response.id][DLB2_DIR_PORT].mz = mz;

drivers/event/dlb2/pf/dlb2_pf.c dlb2_pf_set_sn_allocation(struct dlb2_hw_dev *handle, · line 402

Quoted 10 lines
drivers/event/dlb2/pf/dlb2_pf.c +10 -0
+
+	dlb2_list_init_head(&port_memory.list);
+
+	cfg->response = response;
+
+	return 0;
+
+create_port_err:
+
+	rte_free(port_base);

Ditto

Thanks,
Gage

#234 lore raw

PATCH v2 12/22 event/dlb2: add port link

In reply to Timothy McDaniel

Add port link entry point. Directed queues are identified and created at this stage. Their setup deferred until link-time, at which point we know the directed port ID. Directed queue setup will only fail if this queue is already setup or there are no directed queues left to configure.

---
 drivers/event/dlb2/dlb2.c                  | 308 +++++++++++++-
 drivers/event/dlb2/dlb2_iface.c            |   6 +
 drivers/event/dlb2/dlb2_iface.h            |   6 +
 drivers/event/dlb2/pf/base/dlb2_resource.c | 633 +++++++++++++++++++++++++++++
 drivers/event/dlb2/pf/dlb2_main.c          |  10 +
 drivers/event/dlb2/pf/dlb2_pf.c            |  50 +++
 6 files changed, 1009 insertions(+), 4 deletions(-)
drivers/event/dlb2/dlb2.c +304 -4
index e956a7a..b448f59 100644
@@ -828,9 +828,8 @@ dlb2_hw_create_ldb_queue(struct dlb2_eventdev *dlb2,
 			sched_type = RTE_SCHED_TYPE_ORDERED;
 		else
 			sched_type = RTE_SCHED_TYPE_PARALLEL;
-	} else {
+	} else
 		sched_type = evq_conf->schedule_type;
-	}
 
 	cfg.num_atomic_inflights = DLB2_NUM_ATOMIC_INFLIGHTS_PER_QUEUE;
 	cfg.num_sequence_numbers = evq_conf->nb_atomic_order_sequences;
@@ -866,9 +865,8 @@ dlb2_hw_create_ldb_queue(struct dlb2_eventdev *dlb2,
 	if (ev_queue->depth_threshold == 0) {
 		cfg.depth_threshold = RTE_PMD_DLB2_DEFAULT_DEPTH_THRESH;
 		ev_queue->depth_threshold = RTE_PMD_DLB2_DEFAULT_DEPTH_THRESH;
-	} else {
+	} else
 		cfg.depth_threshold = ev_queue->depth_threshold;
-	}
 
 	ret = dlb2_iface_ldb_queue_create(handle, &cfg);
 	if (ret < 0) {
@@ -1502,6 +1500,307 @@ dlb2_eventdev_port_setup(struct rte_eventdev *dev,
 	return 0;
 }
 
+static int16_t
+dlb2_hw_map_ldb_qid_to_port(struct dlb2_hw_dev *handle,
+			    uint32_t qm_port_id,
+			    uint16_t qm_qid,
+			    uint8_t priority)
+{
+	struct dlb2_map_qid_args cfg;
+	int32_t ret;
+
+	if (handle == NULL)
+		return -EINVAL;
+
+	/* Build message */
+	cfg.port_id = qm_port_id;
+	cfg.qid = qm_qid;
+	cfg.priority = EV_TO_DLB2_PRIO(priority);
+
+	ret = dlb2_iface_map_qid(handle, &cfg);
+	if (ret < 0) {
+		DLB2_LOG_ERR("dlb2: map qid error, ret=%d (driver status: %s)\n",
+			     ret, dlb2_error_strings[cfg.response.status]);
+		DLB2_LOG_ERR("dlb2: grp=%d, qm_port=%d, qm_qid=%d prio=%d\n",
+			     handle->domain_id, cfg.port_id,
+			     cfg.qid,
+			     cfg.priority);
+	} else {
+		DLB2_LOG_DBG("dlb2: mapped queue %d to qm_port %d\n",
+			     qm_qid, qm_port_id);
+	}
+
+	return ret;
+}
+
+static int
+dlb2_event_queue_join_ldb(struct dlb2_eventdev *dlb2,
+			  struct dlb2_eventdev_port *ev_port,
+			  struct dlb2_eventdev_queue *ev_queue,
+			  uint8_t priority)
+{
+	int first_avail = -1;
+	int ret, i;
+
+	for (i = 0; i < DLB2_MAX_NUM_QIDS_PER_LDB_CQ; i++) {
+		if (ev_port->link[i].valid) {
+			if (ev_port->link[i].queue_id == ev_queue->id &&
+			    ev_port->link[i].priority == priority) {
+				if (ev_port->link[i].mapped)
+					return 0; /* already mapped */
+				first_avail = i;
+			}
+		} else if (first_avail == -1)
+			first_avail = i;
+	}
+	if (first_avail == -1) {
+		DLB2_LOG_ERR("dlb2: qm_port %d has no available QID slots.\n",
+			     ev_port->qm_port.id);
+		return -EINVAL;
+	}
+
+	ret = dlb2_hw_map_ldb_qid_to_port(&dlb2->qm_instance,
+					  ev_port->qm_port.id,
+					  ev_queue->qm_queue.id,
+					  priority);
+
+	if (!ret)
+		ev_port->link[first_avail].mapped = true;
+
+	return ret;
+}
+
+static int32_t
+dlb2_hw_create_dir_queue(struct dlb2_eventdev *dlb2,
+			 struct dlb2_eventdev_queue *ev_queue,
+			 int32_t qm_port_id)
+{
+	struct dlb2_hw_dev *handle = &dlb2->qm_instance;
+	struct dlb2_create_dir_queue_args cfg;
+	int32_t ret;
+
+	/* The directed port is always configured before its queue */
+	cfg.port_id = qm_port_id;
+
+	if (ev_queue->depth_threshold == 0) {
+		cfg.depth_threshold = RTE_PMD_DLB2_DEFAULT_DEPTH_THRESH;
+		ev_queue->depth_threshold = RTE_PMD_DLB2_DEFAULT_DEPTH_THRESH;
+	} else
+		cfg.depth_threshold = ev_queue->depth_threshold;
+
+	ret = dlb2_iface_dir_queue_create(handle, &cfg);
+	if (ret < 0) {
+		DLB2_LOG_ERR("dlb2: create DIR event queue error, ret=%d (driver status: %s)\n",
+			     ret, dlb2_error_strings[cfg.response.status]);
+		return -EINVAL;
+	}
+
+	return cfg.response.id;
+}
+
+static int
+dlb2_eventdev_dir_queue_setup(struct dlb2_eventdev *dlb2,
+			      struct dlb2_eventdev_queue *ev_queue,
+			      struct dlb2_eventdev_port *ev_port)
+{
+	int32_t qm_qid;
+
+	qm_qid = dlb2_hw_create_dir_queue(dlb2, ev_queue, ev_port->qm_port.id);
+
+	if (qm_qid < 0) {
+		DLB2_LOG_ERR("Failed to create the DIR queue\n");
+		return qm_qid;
+	}
+
+	dlb2->qm_dir_to_ev_queue_id[qm_qid] = ev_queue->id;
+
+	ev_queue->qm_queue.id = qm_qid;
+
+	return 0;
+}
+
+static int
+dlb2_do_port_link(struct rte_eventdev *dev,
+		  struct dlb2_eventdev_queue *ev_queue,
+		  struct dlb2_eventdev_port *ev_port,
+		  uint8_t prio)
+{
+	struct dlb2_eventdev *dlb2 = dlb2_pmd_priv(dev);
+	int err;
+
+	/* Don't link until start time. */
+	if (dlb2->run_state == DLB2_RUN_STATE_STOPPED)
+		return 0;
+
+	if (ev_queue->qm_queue.is_directed)
+		err = dlb2_eventdev_dir_queue_setup(dlb2, ev_queue, ev_port);
+	else
+		err = dlb2_event_queue_join_ldb(dlb2, ev_port, ev_queue, prio);
+
+	if (err) {
+		DLB2_LOG_ERR("port link failure for %s ev_q %d, ev_port %d\n",
+			     ev_queue->qm_queue.is_directed ? "DIR" : "LDB",
+			     ev_queue->id, ev_port->id);
+
+		rte_errno = err;
+		return -1;
+	}
+
+	return 0;
+}
+
+static int
+dlb2_validate_port_link(struct dlb2_eventdev_port *ev_port,
+			uint8_t queue_id,
+			bool link_exists,
+			int index)
+{
+	struct dlb2_eventdev *dlb2 = ev_port->dlb2;
+	struct dlb2_eventdev_queue *ev_queue;
+	bool port_is_dir, queue_is_dir;
+
+	if (queue_id > dlb2->num_queues) {
+		rte_errno = -EINVAL;
+		return -1;
+	}
+
+	ev_queue = &dlb2->ev_queues[queue_id];
+
+	if (!ev_queue->setup_done &&
+	    ev_queue->qm_queue.config_state != DLB2_PREV_CONFIGURED) {
+		rte_errno = -EINVAL;
+		return -1;
+	}
+
+	port_is_dir = ev_port->qm_port.is_directed;
+	queue_is_dir = ev_queue->qm_queue.is_directed;
+
+	if (port_is_dir != queue_is_dir) {
+		DLB2_LOG_ERR("%s queue %u can't link to %s port %u\n",
+			     queue_is_dir ? "DIR" : "LDB", ev_queue->id,
+			     port_is_dir ? "DIR" : "LDB", ev_port->id);
+
+		rte_errno = -EINVAL;
+		return -1;
+	}
+
+	/* Check if there is space for the requested link */
+	if (!link_exists && index == -1) {
+		DLB2_LOG_ERR("no space for new link\n");
+		rte_errno = -ENOSPC;
+		return -1;
+	}
+
+	/* Check if the directed port is already linked */
+	if (ev_port->qm_port.is_directed && ev_port->num_links > 0 &&
+	    !link_exists) {
+		DLB2_LOG_ERR("Can't link DIR port %d to >1 queues\n",
+			     ev_port->id);
+		rte_errno = -EINVAL;
+		return -1;
+	}
+
+	/* Check if the directed queue is already linked */
+	if (ev_queue->qm_queue.is_directed && ev_queue->num_links > 0 &&
+	    !link_exists) {
+		DLB2_LOG_ERR("Can't link DIR queue %d to >1 ports\n",
+			     ev_queue->id);
+		rte_errno = -EINVAL;
+		return -1;
+	}
+
+	return 0;
+}
+
+static int
+dlb2_eventdev_port_link(struct rte_eventdev *dev, void *event_port,
+			const uint8_t queues[], const uint8_t priorities[],
+			uint16_t nb_links)
+
+{
+	struct dlb2_eventdev_port *ev_port = event_port;
+	struct dlb2_eventdev *dlb2;
+	int i, j;
+
+	RTE_SET_USED(dev);
+
+	if (ev_port == NULL) {
+		DLB2_LOG_ERR("dlb2: evport not setup\n");
+		rte_errno = -EINVAL;
+		return 0;
+	}
+
+	if (!ev_port->setup_done &&
+	    ev_port->qm_port.config_state != DLB2_PREV_CONFIGURED) {
+		DLB2_LOG_ERR("dlb2: evport not setup\n");
+		rte_errno = -EINVAL;
+		return 0;
+	}
+
+	/* Note: rte_event_port_link() ensures the PMD won't receive a NULL
+	 * queues pointer.
+	 */
+	if (nb_links == 0) {
+		DLB2_LOG_DBG("dlb2: nb_links is 0\n");
+		return 0; /* Ignore and return success */
+	}
+
+	dlb2 = ev_port->dlb2;
+
+	DLB2_LOG_DBG("Linking %u queues to %s port %d\n",
+		     nb_links,
+		     ev_port->qm_port.is_directed ? "DIR" : "LDB",
+		     ev_port->id);
+
+	for (i = 0; i < nb_links; i++) {
+		struct dlb2_eventdev_queue *ev_queue;
+		uint8_t queue_id, prio;
+		bool found = false;
+		int index = -1;
+
+		queue_id = queues[i];
+		prio = priorities[i];
+
+		/* Check if the link already exists. */
+		for (j = 0; j < DLB2_MAX_NUM_QIDS_PER_LDB_CQ; j++)
+			if (ev_port->link[j].valid) {
+				if (ev_port->link[j].queue_id == queue_id) {
+					found = true;
+					index = j;
+					break;
+				}
+			} else if (index == -1) {
+				index = j;
+			}
+
+		/* could not link */
+		if (index == -1)
+			break;
+
+		/* Check if already linked at the requested priority */
+		if (found && ev_port->link[j].priority == prio)
+			continue;
+
+		if (dlb2_validate_port_link(ev_port, queue_id, found, index))
+			break; /* return index of offending queue */
+
+		ev_queue = &dlb2->ev_queues[queue_id];
+
+		if (dlb2_do_port_link(dev, ev_queue, ev_port, prio))
+			break; /* return index of offending queue */
+
+		ev_queue->num_links++;
+
+		ev_port->link[index].queue_id = queue_id;
+		ev_port->link[index].priority = prio;
+		ev_port->link[index].valid = true;
+		/* Entry already exists?  If so, then must be prio change */
+		if (!found)
+			ev_port->num_links++;
+	}
+	return i;
+}
+
 static void
 dlb2_entry_points_init(struct rte_eventdev *dev)
 {
@@ -1513,6 +1812,7 @@ dlb2_entry_points_init(struct rte_eventdev *dev)
 		.queue_setup      = dlb2_eventdev_queue_setup,
 		.port_def_conf    = dlb2_eventdev_port_default_conf_get,
 		.port_setup       = dlb2_eventdev_port_setup,
+		.port_link        = dlb2_eventdev_port_link,
 		.dump             = dlb2_eventdev_dump,
 		.xstats_get       = dlb2_eventdev_xstats_get,
 		.xstats_get_names = dlb2_eventdev_xstats_get_names,
drivers/event/dlb2/dlb2_iface.c +6 -0
index 1690d63..5f45b97 100644
@@ -52,3 +52,9 @@ int (*dlb2_iface_dir_port_create)(struct dlb2_hw_dev *handle,
 				  struct dlb2_create_dir_port_args *cfg,
 				  enum dlb2_cq_poll_modes poll_mode);
 
+int (*dlb2_iface_dir_queue_create)(struct dlb2_hw_dev *handle,
+				   struct dlb2_create_dir_queue_args *cfg);
+
+int (*dlb2_iface_map_qid)(struct dlb2_hw_dev *handle,
+			  struct dlb2_map_qid_args *cfg);
+
drivers/event/dlb2/dlb2_iface.h +6 -0
index a090a54..90f7b8a 100644
@@ -51,4 +51,10 @@ extern int (*dlb2_iface_dir_port_create)(struct dlb2_hw_dev *handle,
 					 struct dlb2_create_dir_port_args *cfg,
 					 enum dlb2_cq_poll_modes poll_mode);
 
+extern int (*dlb2_iface_dir_queue_create)(struct dlb2_hw_dev *handle,
+					struct dlb2_create_dir_queue_args *cfg);
+
+extern int (*dlb2_iface_map_qid)(struct dlb2_hw_dev *handle,
+				 struct dlb2_map_qid_args *cfg);
+
 #endif /* _DLB2_IFACE_H_ */
drivers/event/dlb2/pf/base/dlb2_resource.c +633 -0

636 lines not on this page · raw message

drivers/event/dlb2/pf/dlb2_main.c +10 -0
index ec6650e..d5f3a82 100644
@@ -657,3 +657,13 @@ dlb2_pf_create_dir_port(struct dlb2_hw *hw,
 				       NOT_VF_REQ,
 				       PF_ID_ZERO);
 }
+
+int
+dlb2_pf_create_dir_queue(struct dlb2_hw *hw,
+			 u32 id,
+			 struct dlb2_create_dir_queue_args *args,
+			 struct dlb2_cmd_response *resp)
+{
+	return dlb2_hw_create_dir_queue(hw, id, args, resp, NOT_VF_REQ,
+					PF_ID_ZERO);
+}
drivers/event/dlb2/pf/dlb2_pf.c +50 -0

63 lines not on this page · raw message

Signature · 1 line
2.6.4
Reviewed-by on v2 12/22
#235 lore raw

Re: [dpdk-dev] [PATCH v2 12/22] event/dlb2: add port link

Quoted 45 lines

-----Original Message-----
From: McDaniel, Timothy <[email protected]>
Sent: Saturday, October 17, 2020 1:21 PM
Cc: [email protected]; Carrillo, Erik G <[email protected]>; Eads, Gage <[email protected]>; Van Haaren, Harry <[email protected]>; [email protected]
Subject: [PATCH v2 12/22] event/dlb2: add port link

Add port link entry point. Directed queues are identified and created at this stage. Their setup deferred until link-time, at which point we know the directed port ID. Directed queue setup will only fail if this queue is already setup or there are no directed queues left to configure.

---
 drivers/event/dlb2/dlb2.c                  | 308 +++++++++++++-
 drivers/event/dlb2/dlb2_iface.c            |   6 +
 drivers/event/dlb2/dlb2_iface.h            |   6 +
 drivers/event/dlb2/pf/base/dlb2_resource.c | 633
+++++++++++++++++++++++++++++
 drivers/event/dlb2/pf/dlb2_main.c          |  10 +
 drivers/event/dlb2/pf/dlb2_pf.c            |  50 +++
 6 files changed, 1009 insertions(+), 4 deletions(-)
drivers/event/dlb2/dlb2.c +1 -2
index e956a7a..b448f59 100644
@@ -828,9 +828,8 @@ dlb2_hw_create_ldb_queue(struct dlb2_eventdev *dlb2,
 			sched_type = RTE_SCHED_TYPE_ORDERED;
 		else
 			sched_type = RTE_SCHED_TYPE_PARALLEL;
-	} else {
+	} else
 		sched_type = evq_conf->schedule_type;
-	}
 
 	cfg.num_atomic_inflights =
 DLB2_NUM_ATOMIC_INFLIGHTS_PER_QUEUE;

cfg.num_sequence_numbers = evq_conf-

Quoted 1 line

nb_atomic_order_sequences;

drivers/event/dlb2/dlb2.c dlb2_hw_create_ldb_queue(struct dlb2_eventdev *dlb2, · line 873

Quoted 9 lines
drivers/event/dlb2/dlb2.c +1 -2
@@ -866,9 +865,8 @@ dlb2_hw_create_ldb_queue(struct dlb2_eventdev *dlb2,
 	if (ev_queue->depth_threshold == 0) {
 		cfg.depth_threshold =
 RTE_PMD_DLB2_DEFAULT_DEPTH_THRESH;
 		ev_queue->depth_threshold =
 RTE_PMD_DLB2_DEFAULT_DEPTH_THRESH;
-	} else {
+	} else
 		cfg.depth_threshold = ev_queue->depth_threshold;
-	}

These two changes should be in patch 10 ("event/dlb2: add queue setup"). Besides that:

Thanks,
Gage

#236 lore raw

PATCH v2 13/22 event/dlb2: add port unlink and port unlinks in progress

In reply to Timothy McDaniel

Add supports for the port unlink(s) eventdev entry points. The unlink operation is an asynchronous operation executed by a control thread, and the unlinks-in-progress function reads a counter shared with the control thread.

---
 drivers/event/dlb2/dlb2.c                  | 163 +++++++++++++++++
 drivers/event/dlb2/dlb2_iface.c            |   5 +
 drivers/event/dlb2/dlb2_iface.h            |   8 +-
 drivers/event/dlb2/pf/base/dlb2_resource.c | 283 +++++++++++++++++++++++++++++
 drivers/event/dlb2/pf/dlb2_pf.c            |  51 ++++++
 5 files changed, 509 insertions(+), 1 deletion(-)
drivers/event/dlb2/dlb2.c +163 -0
index b448f59..11fc88b 100644
@@ -1801,6 +1801,166 @@ dlb2_eventdev_port_link(struct rte_eventdev *dev, void *event_port,
 	return i;
 }
 
+static int16_t
+dlb2_hw_unmap_ldb_qid_from_port(struct dlb2_hw_dev *handle,
+				uint32_t qm_port_id,
+				uint16_t qm_qid)
+{
+	struct dlb2_unmap_qid_args cfg;
+	int32_t ret;
+
+	if (handle == NULL)
+		return -EINVAL;
+
+	cfg.port_id = qm_port_id;
+	cfg.qid = qm_qid;
+
+	ret = dlb2_iface_unmap_qid(handle, &cfg);
+	if (ret < 0)
+		DLB2_LOG_ERR("dlb2: unmap qid error, ret=%d (driver status: %s)\n",
+			     ret, dlb2_error_strings[cfg.response.status]);
+
+	return ret;
+}
+
+static int
+dlb2_event_queue_detach_ldb(struct dlb2_eventdev *dlb2,
+			    struct dlb2_eventdev_port *ev_port,
+			    struct dlb2_eventdev_queue *ev_queue)
+{
+	int ret, i;
+
+	/* Don't unlink until start time. */
+	if (dlb2->run_state == DLB2_RUN_STATE_STOPPED)
+		return 0;
+
+	for (i = 0; i < DLB2_MAX_NUM_QIDS_PER_LDB_CQ; i++) {
+		if (ev_port->link[i].valid &&
+		    ev_port->link[i].queue_id == ev_queue->id)
+			break; /* found */
+	}
+
+	/* This is expected with eventdev API!
+	 * It blindly attemmpts to unmap all queues.
+	 */
+	if (i == DLB2_MAX_NUM_QIDS_PER_LDB_CQ) {
+		DLB2_LOG_DBG("dlb2: ignoring LB QID %d not mapped for qm_port %d.\n",
+			     ev_queue->qm_queue.id,
+			     ev_port->qm_port.id);
+		return 0;
+	}
+
+	ret = dlb2_hw_unmap_ldb_qid_from_port(&dlb2->qm_instance,
+					      ev_port->qm_port.id,
+					      ev_queue->qm_queue.id);
+	if (!ret)
+		ev_port->link[i].mapped = false;
+
+	return ret;
+}
+
+static int
+dlb2_eventdev_port_unlink(struct rte_eventdev *dev, void *event_port,
+			  uint8_t queues[], uint16_t nb_unlinks)
+{
+	struct dlb2_eventdev_port *ev_port = event_port;
+	struct dlb2_eventdev *dlb2;
+	int i;
+
+	RTE_SET_USED(dev);
+
+	if (!ev_port->setup_done) {
+		DLB2_LOG_ERR("dlb2: evport %d is not configured\n",
+			     ev_port->id);
+		rte_errno = -EINVAL;
+		return 0;
+	}
+
+	if (queues == NULL || nb_unlinks == 0) {
+		DLB2_LOG_DBG("dlb2: queues is NULL or nb_unlinks is 0\n");
+		return 0; /* Ignore and return success */
+	}
+
+	/* FIXME: How to handle unlink on a directed port? */
+	if (ev_port->qm_port.is_directed) {
+		DLB2_LOG_DBG("dlb2: ignore unlink from dir port %d\n",
+			     ev_port->id);
+		rte_errno = 0;
+		return nb_unlinks; /* as if success */
+	}
+
+	dlb2 = ev_port->dlb2;
+
+	for (i = 0; i < nb_unlinks; i++) {
+		struct dlb2_eventdev_queue *ev_queue;
+		int ret, j;
+
+		if (queues[i] >= dlb2->num_queues) {
+			DLB2_LOG_ERR("dlb2: invalid queue id %d\n", queues[i]);
+			rte_errno = -EINVAL;
+			return i; /* return index of offending queue */
+		}
+
+		ev_queue = &dlb2->ev_queues[queues[i]];
+
+		/* Does a link exist? */
+		for (j = 0; j < DLB2_MAX_NUM_QIDS_PER_LDB_CQ; j++)
+			if (ev_port->link[j].queue_id == queues[i] &&
+			    ev_port->link[j].valid)
+				break;
+
+		if (j == DLB2_MAX_NUM_QIDS_PER_LDB_CQ)
+			continue;
+
+		ret = dlb2_event_queue_detach_ldb(dlb2, ev_port, ev_queue);
+		if (ret) {
+			DLB2_LOG_ERR("unlink err=%d for port %d queue %d\n",
+				     ret, ev_port->id, queues[i]);
+			rte_errno = -ENOENT;
+			return i; /* return index of offending queue */
+		}
+
+		ev_port->link[j].valid = false;
+		ev_port->num_links--;
+		ev_queue->num_links--;
+	}
+
+	return nb_unlinks;
+}
+
+static int
+dlb2_eventdev_port_unlinks_in_progress(struct rte_eventdev *dev,
+				       void *event_port)
+{
+	struct dlb2_eventdev_port *ev_port = event_port;
+	struct dlb2_eventdev *dlb2;
+	struct dlb2_hw_dev *handle;
+	struct dlb2_pending_port_unmaps_args cfg;
+	int ret;
+
+	RTE_SET_USED(dev);
+
+	if (!ev_port->setup_done) {
+		DLB2_LOG_ERR("dlb2: evport %d is not configured\n",
+			     ev_port->id);
+		rte_errno = -EINVAL;
+		return 0;
+	}
+
+	cfg.port_id = ev_port->qm_port.id;
+	dlb2 = ev_port->dlb2;
+	handle = &dlb2->qm_instance;
+	ret = dlb2_iface_pending_port_unmaps(handle, &cfg);
+
+	if (ret < 0) {
+		DLB2_LOG_ERR("dlb2: num_unlinks_in_progress ret=%d (driver status: %s)\n",
+			     ret, dlb2_error_strings[cfg.response.status]);
+		return ret;
+	}
+
+	return cfg.response.id;
+}
+
 static void
 dlb2_entry_points_init(struct rte_eventdev *dev)
 {
@@ -1813,6 +1973,9 @@ dlb2_entry_points_init(struct rte_eventdev *dev)
 		.port_def_conf    = dlb2_eventdev_port_default_conf_get,
 		.port_setup       = dlb2_eventdev_port_setup,
 		.port_link        = dlb2_eventdev_port_link,
+		.port_unlink      = dlb2_eventdev_port_unlink,
+		.port_unlinks_in_progress =
+				    dlb2_eventdev_port_unlinks_in_progress,
 		.dump             = dlb2_eventdev_dump,
 		.xstats_get       = dlb2_eventdev_xstats_get,
 		.xstats_get_names = dlb2_eventdev_xstats_get_names,
drivers/event/dlb2/dlb2_iface.c +5 -0
index 5f45b97..bd241f3 100644
@@ -58,3 +58,8 @@ int (*dlb2_iface_dir_queue_create)(struct dlb2_hw_dev *handle,
 int (*dlb2_iface_map_qid)(struct dlb2_hw_dev *handle,
 			  struct dlb2_map_qid_args *cfg);
 
+int (*dlb2_iface_unmap_qid)(struct dlb2_hw_dev *handle,
+			    struct dlb2_unmap_qid_args *cfg);
+
+int (*dlb2_iface_pending_port_unmaps)(struct dlb2_hw_dev *handle,
+				struct dlb2_pending_port_unmaps_args *args);
drivers/event/dlb2/dlb2_iface.h +7 -1
index 90f7b8a..182a5bf 100644
@@ -52,9 +52,15 @@ extern int (*dlb2_iface_dir_port_create)(struct dlb2_hw_dev *handle,
 					 enum dlb2_cq_poll_modes poll_mode);
 
 extern int (*dlb2_iface_dir_queue_create)(struct dlb2_hw_dev *handle,
-					struct dlb2_create_dir_queue_args *cfg);
+				  struct dlb2_create_dir_queue_args *cfg);
 
 extern int (*dlb2_iface_map_qid)(struct dlb2_hw_dev *handle,
 				 struct dlb2_map_qid_args *cfg);
 
+extern int (*dlb2_iface_unmap_qid)(struct dlb2_hw_dev *handle,
+				   struct dlb2_unmap_qid_args *cfg);
+
+extern int (*dlb2_iface_pending_port_unmaps)(struct dlb2_hw_dev *handle,
+				struct dlb2_pending_port_unmaps_args *args);
+
 #endif /* _DLB2_IFACE_H_ */
drivers/event/dlb2/pf/base/dlb2_resource.c +283 -0

286 lines not on this page · raw message

drivers/event/dlb2/pf/dlb2_pf.c +51 -0

63 lines not on this page · raw message

Signature · 1 line
2.6.4
#237 lore raw

PATCH v2 14/22 event/dlb2: add eventdev start

In reply to Timothy McDaniel

Add support for the eventdev start entry point.
We delay initializing some resources until
eventdev start, since the number of linked queues can be used to determine if we are dealing with a ldb or dir resource. If this is a device restart, then the previous configuration will be reapplied.

---
 drivers/event/dlb2/dlb2.c                  | 133 +++++++++++++++++++++++++++++
 drivers/event/dlb2/dlb2_iface.c            |   3 +
 drivers/event/dlb2/dlb2_iface.h            |   3 +
 drivers/event/dlb2/pf/base/dlb2_resource.c | 123 ++++++++++++++++++++++++++
 drivers/event/dlb2/pf/dlb2_main.c          |  10 +++
 drivers/event/dlb2/pf/dlb2_pf.c            |  25 ++++++
 6 files changed, 297 insertions(+)
drivers/event/dlb2/dlb2.c +133 -0
index 11fc88b..3337181 100644
@@ -1961,6 +1961,138 @@ dlb2_eventdev_port_unlinks_in_progress(struct rte_eventdev *dev,
 	return cfg.response.id;
 }
 
+static int
+dlb2_eventdev_reapply_configuration(struct rte_eventdev *dev)
+{
+	struct dlb2_eventdev *dlb2 = dlb2_pmd_priv(dev);
+	int ret, i;
+
+	/* If an event queue or port was previously configured, but hasn't been
+	 * reconfigured, reapply its original configuration.
+	 */
+	for (i = 0; i < dlb2->num_queues; i++) {
+		struct dlb2_eventdev_queue *ev_queue;
+
+		ev_queue = &dlb2->ev_queues[i];
+
+		if (ev_queue->qm_queue.config_state != DLB2_PREV_CONFIGURED)
+			continue;
+
+		ret = dlb2_eventdev_queue_setup(dev, i, &ev_queue->conf);
+		if (ret < 0) {
+			DLB2_LOG_ERR("dlb2: failed to reconfigure queue %d", i);
+			return ret;
+		}
+	}
+
+	for (i = 0; i < dlb2->num_ports; i++) {
+		struct dlb2_eventdev_port *ev_port = &dlb2->ev_ports[i];
+
+		if (ev_port->qm_port.config_state != DLB2_PREV_CONFIGURED)
+			continue;
+
+		ret = dlb2_eventdev_port_setup(dev, i, &ev_port->conf);
+		if (ret < 0) {
+			DLB2_LOG_ERR("dlb2: failed to reconfigure ev_port %d",
+				     i);
+			return ret;
+		}
+	}
+
+	return 0;
+}
+
+static int
+dlb2_eventdev_apply_port_links(struct rte_eventdev *dev)
+{
+	struct dlb2_eventdev *dlb2 = dlb2_pmd_priv(dev);
+	int i;
+
+	/* Perform requested port->queue links */
+	for (i = 0; i < dlb2->num_ports; i++) {
+		struct dlb2_eventdev_port *ev_port = &dlb2->ev_ports[i];
+		int j;
+
+		for (j = 0; j < DLB2_MAX_NUM_QIDS_PER_LDB_CQ; j++) {
+			struct dlb2_eventdev_queue *ev_queue;
+			uint8_t prio, queue_id;
+
+			if (!ev_port->link[j].valid)
+				continue;
+
+			prio = ev_port->link[j].priority;
+			queue_id = ev_port->link[j].queue_id;
+
+			if (dlb2_validate_port_link(ev_port, queue_id, true, j))
+				return -EINVAL;
+
+			ev_queue = &dlb2->ev_queues[queue_id];
+
+			if (dlb2_do_port_link(dev, ev_queue, ev_port, prio))
+				return -EINVAL;
+		}
+	}
+
+	return 0;
+}
+
+static int
+dlb2_eventdev_start(struct rte_eventdev *dev)
+{
+	struct dlb2_eventdev *dlb2 = dlb2_pmd_priv(dev);
+	struct dlb2_hw_dev *handle = &dlb2->qm_instance;
+	struct dlb2_start_domain_args cfg;
+	int ret, i;
+
+	rte_spinlock_lock(&dlb2->qm_instance.resource_lock);
+	if (dlb2->run_state != DLB2_RUN_STATE_STOPPED) {
+		DLB2_LOG_ERR("bad state %d for dev_start\n",
+			     (int)dlb2->run_state);
+		rte_spinlock_unlock(&dlb2->qm_instance.resource_lock);
+		return -EINVAL;
+	}
+	dlb2->run_state = DLB2_RUN_STATE_STARTING;
+	rte_spinlock_unlock(&dlb2->qm_instance.resource_lock);
+
+	/* If the device was configured more than once, some event ports and/or
+	 * queues may need to be reconfigured.
+	 */
+	ret = dlb2_eventdev_reapply_configuration(dev);
+	if (ret)
+		return ret;
+
+	/* The DLB PMD delays port links until the device is started. */
+	ret = dlb2_eventdev_apply_port_links(dev);
+	if (ret)
+		return ret;
+
+	for (i = 0; i < dlb2->num_ports; i++) {
+		if (!dlb2->ev_ports[i].setup_done) {
+			DLB2_LOG_ERR("dlb2: port %d not setup", i);
+			return -ESTALE;
+		}
+	}
+
+	for (i = 0; i < dlb2->num_queues; i++) {
+		if (dlb2->ev_queues[i].num_links == 0) {
+			DLB2_LOG_ERR("dlb2: queue %d is not linked", i);
+			return -ENOLINK;
+		}
+	}
+
+	ret = dlb2_iface_sched_domain_start(handle, &cfg);
+	if (ret < 0) {
+		DLB2_LOG_ERR("dlb2: sched_domain_start ret=%d (driver status: %s)\n",
+			     ret, dlb2_error_strings[cfg.response.status]);
+		return ret;
+	}
+
+	dlb2->run_state = DLB2_RUN_STATE_STARTED;
+	DLB2_LOG_DBG("dlb2: sched_domain_start completed OK\n");
+
+	return 0;
+}
+
 static void
 dlb2_entry_points_init(struct rte_eventdev *dev)
 {
@@ -1968,6 +2100,7 @@ dlb2_entry_points_init(struct rte_eventdev *dev)
 	static struct rte_eventdev_ops dlb2_eventdev_entry_ops = {
 		.dev_infos_get    = dlb2_eventdev_info_get,
 		.dev_configure    = dlb2_eventdev_configure,
+		.dev_start        = dlb2_eventdev_start,
 		.queue_def_conf   = dlb2_eventdev_queue_default_conf_get,
 		.queue_setup      = dlb2_eventdev_queue_setup,
 		.port_def_conf    = dlb2_eventdev_port_default_conf_get,
drivers/event/dlb2/dlb2_iface.c +3 -0
index bd241f3..a86191d 100644
@@ -63,3 +63,6 @@ int (*dlb2_iface_unmap_qid)(struct dlb2_hw_dev *handle,
 
 int (*dlb2_iface_pending_port_unmaps)(struct dlb2_hw_dev *handle,
 				struct dlb2_pending_port_unmaps_args *args);
+
+int (*dlb2_iface_sched_domain_start)(struct dlb2_hw_dev *handle,
+				     struct dlb2_start_domain_args *cfg);
drivers/event/dlb2/dlb2_iface.h +3 -0
index 182a5bf..d5bb6be 100644
@@ -63,4 +63,7 @@ extern int (*dlb2_iface_unmap_qid)(struct dlb2_hw_dev *handle,
 extern int (*dlb2_iface_pending_port_unmaps)(struct dlb2_hw_dev *handle,
 				struct dlb2_pending_port_unmaps_args *args);
 
+extern int (*dlb2_iface_sched_domain_start)(struct dlb2_hw_dev *handle,
+				struct dlb2_start_domain_args *cfg);
+
 #endif /* _DLB2_IFACE_H_ */
drivers/event/dlb2/pf/base/dlb2_resource.c +123 -0

126 lines not on this page · raw message

drivers/event/dlb2/pf/dlb2_main.c +10 -0
index d5f3a82..563c944 100644
@@ -667,3 +667,13 @@ dlb2_pf_create_dir_queue(struct dlb2_hw *hw,
 	return dlb2_hw_create_dir_queue(hw, id, args, resp, NOT_VF_REQ,
 					PF_ID_ZERO);
 }
+
+int
+dlb2_pf_start_domain(struct dlb2_hw *hw,
+		     u32 id,
+		     struct dlb2_start_domain_args *args,
+		     struct dlb2_cmd_response *resp)
+{
+	return dlb2_hw_start_domain(hw, id, args, resp, NOT_VF_REQ,
+				    PF_ID_ZERO);
+}
drivers/event/dlb2/pf/dlb2_pf.c +25 -0
index b58b4ba..c9dc200 100644
@@ -504,6 +504,30 @@ dlb2_pf_pending_port_unmaps(struct dlb2_hw_dev *handle,
 
 	return ret;
 }
+
+static int
+dlb2_pf_sched_domain_start(struct dlb2_hw_dev *handle,
+			   struct dlb2_start_domain_args *cfg)
+{
+	struct dlb2_dev *dlb2_dev = (struct dlb2_dev *)handle->pf_dev;
+	struct dlb2_cmd_response response = {0};
+	int ret;
+
+	DLB2_INFO(dev->dlb2_device, "Entering %s()\n", __func__);
+
+	ret = dlb2_pf_start_domain(&dlb2_dev->hw,
+				   handle->domain_id,
+				   cfg,
+				   &response);
+
+	cfg->response = response;
+
+	DLB2_INFO(dev->dlb2_device, "Exiting %s() with ret=%d\n",
+		  __func__, ret);
+
+	return ret;
+}
+
 static void
 dlb2_pf_iface_fn_ptrs_init(void)
 {
@@ -521,6 +545,7 @@ dlb2_pf_iface_fn_ptrs_init(void)
 	dlb2_iface_dir_port_create = dlb2_pf_dir_port_create;
 	dlb2_iface_map_qid = dlb2_pf_map_qid;
 	dlb2_iface_unmap_qid = dlb2_pf_unmap_qid;
+	dlb2_iface_sched_domain_start = dlb2_pf_sched_domain_start;
 	dlb2_iface_pending_port_unmaps = dlb2_pf_pending_port_unmaps;
 	dlb2_iface_get_sn_allocation = dlb2_pf_get_sn_allocation;
 	dlb2_iface_set_sn_allocation = dlb2_pf_set_sn_allocation;
Signature · 1 line
2.6.4
Reviewed-by on v2 14/22
#238 lore raw

Re: [dpdk-dev] [PATCH v2 14/22] event/dlb2: add eventdev start

Quoted 10 lines

-----Original Message-----
From: McDaniel, Timothy <[email protected]>
Sent: Saturday, October 17, 2020 1:21 PM
Cc: [email protected]; Carrillo, Erik G <[email protected]>; Eads, Gage <[email protected]>; Van Haaren, Harry <[email protected]>; [email protected]
Subject: [PATCH v2 14/22] event/dlb2: add eventdev start

Quoted 8 lines

Add support for the eventdev start entry point.
We delay initializing some resources until
eventdev start, since the number of linked queues can be used to determine if we are dealing with a ldb or dir resource. If this is a device restart, then the previous configuration will be reapplied.

Thanks,
Gage

#239 lore raw

PATCH v2 15/22 event/dlb2: add enqueue and its burst variants

In reply to Timothy McDaniel

Add support for enqueue and its variants.

---
 drivers/event/dlb2/dlb2.c | 578 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 578 insertions(+)
drivers/event/dlb2/dlb2.c +578 -0
index 3337181..6cef9cb 100644
@@ -2093,6 +2093,578 @@ dlb2_eventdev_start(struct rte_eventdev *dev)
 	return 0;
 }
 
+static uint8_t cmd_byte_map[DLB2_NUM_PORT_TYPES][DLB2_NUM_HW_SCHED_TYPES] = {
+	{
+		/* Load-balanced cmd bytes */
+		[RTE_EVENT_OP_NEW] = DLB2_NEW_CMD_BYTE,
+		[RTE_EVENT_OP_FORWARD] = DLB2_FWD_CMD_BYTE,
+		[RTE_EVENT_OP_RELEASE] = DLB2_COMP_CMD_BYTE,
+	},
+	{
+		/* Directed cmd bytes */
+		[RTE_EVENT_OP_NEW] = DLB2_NEW_CMD_BYTE,
+		[RTE_EVENT_OP_FORWARD] = DLB2_NEW_CMD_BYTE,
+		[RTE_EVENT_OP_RELEASE] = DLB2_NOOP_CMD_BYTE,
+	},
+};
+
+static inline uint32_t
+dlb2_port_credits_get(struct dlb2_port *qm_port,
+		      enum dlb2_hw_queue_types type)
+{
+	uint32_t credits = *qm_port->credit_pool[type];
+	uint32_t batch_size = DLB2_SW_CREDIT_BATCH_SZ;
+
+	if (unlikely(credits < batch_size))
+		batch_size = credits;
+
+	if (likely(credits &&
+		   __atomic_compare_exchange_n(
+			qm_port->credit_pool[type],
+			&credits, credits - batch_size, false,
+			__ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)))
+		return batch_size;
+	else
+		return 0;
+}
+
+static inline void
+dlb2_replenish_sw_credits(struct dlb2_eventdev *dlb2,
+			  struct dlb2_eventdev_port *ev_port)
+{
+	uint16_t quanta = ev_port->credit_update_quanta;
+
+	if (ev_port->inflight_credits >= quanta * 2) {
+		/* Replenish credits, saving one quanta for enqueues */
+		uint16_t val = ev_port->inflight_credits - quanta;
+
+		__atomic_fetch_sub(&dlb2->inflights, val, __ATOMIC_SEQ_CST);
+		ev_port->inflight_credits -= val;
+	}
+}
+
+static inline int
+dlb2_check_enqueue_sw_credits(struct dlb2_eventdev *dlb2,
+			      struct dlb2_eventdev_port *ev_port)
+{
+	uint32_t sw_inflights = __atomic_load_n(&dlb2->inflights,
+						__ATOMIC_SEQ_CST);
+	const int num = 1;
+
+	if (unlikely(ev_port->inflight_max < sw_inflights)) {
+		DLB2_INC_STAT(ev_port->stats.traffic.tx_nospc_inflight_max, 1);
+		rte_errno = -ENOSPC;
+		return 1;
+	}
+
+	if (ev_port->inflight_credits < num) {
+		/* check if event enqueue brings ev_port over max threshold */
+		uint32_t credit_update_quanta = ev_port->credit_update_quanta;
+
+		if (sw_inflights + credit_update_quanta >
+				dlb2->new_event_limit) {
+			DLB2_INC_STAT(
+			ev_port->stats.traffic.tx_nospc_new_event_limit,
+			1);
+			rte_errno = -ENOSPC;
+			return 1;
+		}
+
+		__atomic_fetch_add(&dlb2->inflights, credit_update_quanta,
+				   __ATOMIC_SEQ_CST);
+		ev_port->inflight_credits += (credit_update_quanta);
+
+		if (ev_port->inflight_credits < num) {
+			DLB2_INC_STAT(
+			ev_port->stats.traffic.tx_nospc_inflight_credits,
+			1);
+			rte_errno = -ENOSPC;
+			return 1;
+		}
+	}
+
+	return 0;
+}
+
+static inline int
+dlb2_check_enqueue_hw_ldb_credits(struct dlb2_port *qm_port)
+{
+	if (unlikely(qm_port->cached_ldb_credits == 0)) {
+		qm_port->cached_ldb_credits =
+			dlb2_port_credits_get(qm_port,
+					      DLB2_LDB_QUEUE);
+		if (unlikely(qm_port->cached_ldb_credits == 0)) {
+			DLB2_INC_STAT(
+			qm_port->ev_port->stats.traffic.tx_nospc_ldb_hw_credits,
+			1);
+			DLB2_LOG_DBG("ldb credits exhausted\n");
+			return 1; /* credits exhausted */
+		}
+	}
+
+	return 0;
+}
+
+static inline int
+dlb2_check_enqueue_hw_dir_credits(struct dlb2_port *qm_port)
+{
+	if (unlikely(qm_port->cached_dir_credits == 0)) {
+		qm_port->cached_dir_credits =
+			dlb2_port_credits_get(qm_port,
+					      DLB2_DIR_QUEUE);
+		if (unlikely(qm_port->cached_dir_credits == 0)) {
+			DLB2_INC_STAT(
+			qm_port->ev_port->stats.traffic.tx_nospc_dir_hw_credits,
+			1);
+			DLB2_LOG_DBG("dir credits exhausted\n");
+			return 1; /* credits exhausted */
+		}
+	}
+
+	return 0;
+}
+
+static __rte_always_inline void
+dlb2_pp_write(struct dlb2_enqueue_qe *qe4,
+	      struct process_local_port_data *port_data)
+{
+	dlb2_movdir64b(qe4, port_data->pp_addr);
+}
+
+static inline int
+dlb2_consume_qe_immediate(struct dlb2_port *qm_port, int num)
+{
+	struct process_local_port_data *port_data;
+	struct dlb2_cq_pop_qe *qe;
+
+	RTE_ASSERT(qm_port->config_state == DLB2_CONFIGURED);
+
+	qe = qm_port->consume_qe;
+
+	qe->tokens = num - 1;
+
+	/* No store fence needed since no pointer is being sent, and CQ token
+	 * pops can be safely reordered with other HCWs.
+	 */
+	port_data = &dlb2_port[qm_port->id][PORT_TYPE(qm_port)];
+
+	dlb2_movntdq_single(qe, port_data->pp_addr);
+
+	DLB2_LOG_DBG("dlb2: consume immediate - %d QEs\n", num);
+
+	qm_port->owed_tokens = 0;
+
+	return 0;
+}
+
+static inline void
+dlb2_hw_do_enqueue(struct dlb2_port *qm_port,
+		   bool do_sfence,
+		   struct process_local_port_data *port_data)
+{
+	/* Since MOVDIR64B is weakly-ordered, use an SFENCE to ensure that
+	 * application writes complete before enqueueing the QE.
+	 */
+	if (do_sfence)
+		rte_wmb();
+
+	dlb2_pp_write(qm_port->qe4, port_data);
+}
+
+static inline void
+dlb2_construct_token_pop_qe(struct dlb2_port *qm_port, int idx)
+{
+	struct dlb2_cq_pop_qe *qe = (void *)qm_port->qe4;
+	int num = qm_port->owed_tokens;
+
+	qe[idx].cmd_byte = DLB2_POP_CMD_BYTE;
+	qe[idx].tokens = num - 1;
+
+	qm_port->owed_tokens = 0;
+}
+
+static inline void
+dlb2_event_build_hcws(struct dlb2_port *qm_port,
+		      const struct rte_event ev[],
+		      int num,
+		      uint8_t *sched_type,
+		      uint8_t *queue_id)
+{
+	struct dlb2_enqueue_qe *qe;
+	uint16_t sched_word[4];
+	__m128i sse_qe[2];
+	int i;
+
+	qe = qm_port->qe4;
+
+	sse_qe[0] = _mm_setzero_si128();
+	sse_qe[1] = _mm_setzero_si128();
+
+	switch (num) {
+	case 4:
+		/* Construct the metadata portion of two HCWs in one 128b SSE
+		 * register. HCW metadata is constructed in the SSE registers
+		 * like so:
+		 * sse_qe[0][63:0]:   qe[0]'s metadata
+		 * sse_qe[0][127:64]: qe[1]'s metadata
+		 * sse_qe[1][63:0]:   qe[2]'s metadata
+		 * sse_qe[1][127:64]: qe[3]'s metadata
+		 */
+
+		/* Convert the event operation into a command byte and store it
+		 * in the metadata:
+		 * sse_qe[0][63:56]   = cmd_byte_map[is_directed][ev[0].op]
+		 * sse_qe[0][127:120] = cmd_byte_map[is_directed][ev[1].op]
+		 * sse_qe[1][63:56]   = cmd_byte_map[is_directed][ev[2].op]
+		 * sse_qe[1][127:120] = cmd_byte_map[is_directed][ev[3].op]
+		 */
+#define DLB2_QE_CMD_BYTE 7
+		sse_qe[0] = _mm_insert_epi8(sse_qe[0],
+				cmd_byte_map[qm_port->is_directed][ev[0].op],
+				DLB2_QE_CMD_BYTE);
+		sse_qe[0] = _mm_insert_epi8(sse_qe[0],
+				cmd_byte_map[qm_port->is_directed][ev[1].op],
+				DLB2_QE_CMD_BYTE + 8);
+		sse_qe[1] = _mm_insert_epi8(sse_qe[1],
+				cmd_byte_map[qm_port->is_directed][ev[2].op],
+				DLB2_QE_CMD_BYTE);
+		sse_qe[1] = _mm_insert_epi8(sse_qe[1],
+				cmd_byte_map[qm_port->is_directed][ev[3].op],
+				DLB2_QE_CMD_BYTE + 8);
+
+		/* Store priority, scheduling type, and queue ID in the sched
+		 * word array because these values are re-used when the
+		 * destination is a directed queue.
+		 */
+		sched_word[0] = EV_TO_DLB2_PRIO(ev[0].priority) << 10 |
+				sched_type[0] << 8 |
+				queue_id[0];
+		sched_word[1] = EV_TO_DLB2_PRIO(ev[1].priority) << 10 |
+				sched_type[1] << 8 |
+				queue_id[1];
+		sched_word[2] = EV_TO_DLB2_PRIO(ev[2].priority) << 10 |
+				sched_type[2] << 8 |
+				queue_id[2];
+		sched_word[3] = EV_TO_DLB2_PRIO(ev[3].priority) << 10 |
+				sched_type[3] << 8 |
+				queue_id[3];
+
+		/* Store the event priority, scheduling type, and queue ID in
+		 * the metadata:
+		 * sse_qe[0][31:16] = sched_word[0]
+		 * sse_qe[0][95:80] = sched_word[1]
+		 * sse_qe[1][31:16] = sched_word[2]
+		 * sse_qe[1][95:80] = sched_word[3]
+		 */
+#define DLB2_QE_QID_SCHED_WORD 1
+		sse_qe[0] = _mm_insert_epi16(sse_qe[0],
+					     sched_word[0],
+					     DLB2_QE_QID_SCHED_WORD);
+		sse_qe[0] = _mm_insert_epi16(sse_qe[0],
+					     sched_word[1],
+					     DLB2_QE_QID_SCHED_WORD + 4);
+		sse_qe[1] = _mm_insert_epi16(sse_qe[1],
+					     sched_word[2],
+					     DLB2_QE_QID_SCHED_WORD);
+		sse_qe[1] = _mm_insert_epi16(sse_qe[1],
+					     sched_word[3],
+					     DLB2_QE_QID_SCHED_WORD + 4);
+
+		/* If the destination is a load-balanced queue, store the lock
+		 * ID. If it is a directed queue, DLB places this field in
+		 * bytes 10-11 of the received QE, so we format it accordingly:
+		 * sse_qe[0][47:32]  = dir queue ? sched_word[0] : flow_id[0]
+		 * sse_qe[0][111:96] = dir queue ? sched_word[1] : flow_id[1]
+		 * sse_qe[1][47:32]  = dir queue ? sched_word[2] : flow_id[2]
+		 * sse_qe[1][111:96] = dir queue ? sched_word[3] : flow_id[3]
+		 */
+#define DLB2_QE_LOCK_ID_WORD 2
+		sse_qe[0] = _mm_insert_epi16(sse_qe[0],
+				(sched_type[0] == DLB2_SCHED_DIRECTED) ?
+					sched_word[0] : ev[0].flow_id,
+				DLB2_QE_LOCK_ID_WORD);
+		sse_qe[0] = _mm_insert_epi16(sse_qe[0],
+				(sched_type[1] == DLB2_SCHED_DIRECTED) ?
+					sched_word[1] : ev[1].flow_id,
+				DLB2_QE_LOCK_ID_WORD + 4);
+		sse_qe[1] = _mm_insert_epi16(sse_qe[1],
+				(sched_type[2] == DLB2_SCHED_DIRECTED) ?
+					sched_word[2] : ev[2].flow_id,
+				DLB2_QE_LOCK_ID_WORD);
+		sse_qe[1] = _mm_insert_epi16(sse_qe[1],
+				(sched_type[3] == DLB2_SCHED_DIRECTED) ?
+					sched_word[3] : ev[3].flow_id,
+				DLB2_QE_LOCK_ID_WORD + 4);
+
+		/* Store the event type and sub event type in the metadata:
+		 * sse_qe[0][15:0]  = flow_id[0]
+		 * sse_qe[0][79:64] = flow_id[1]
+		 * sse_qe[1][15:0]  = flow_id[2]
+		 * sse_qe[1][79:64] = flow_id[3]
+		 */
+#define DLB2_QE_EV_TYPE_WORD 0
+		sse_qe[0] = _mm_insert_epi16(sse_qe[0],
+					     ev[0].sub_event_type << 8 |
+						ev[0].event_type,
+					     DLB2_QE_EV_TYPE_WORD);
+		sse_qe[0] = _mm_insert_epi16(sse_qe[0],
+					     ev[1].sub_event_type << 8 |
+						ev[1].event_type,
+					     DLB2_QE_EV_TYPE_WORD + 4);
+		sse_qe[1] = _mm_insert_epi16(sse_qe[1],
+					     ev[2].sub_event_type << 8 |
+						ev[2].event_type,
+					     DLB2_QE_EV_TYPE_WORD);
+		sse_qe[1] = _mm_insert_epi16(sse_qe[1],
+					     ev[3].sub_event_type << 8 |
+						ev[3].event_type,
+					     DLB2_QE_EV_TYPE_WORD + 4);
+
+		/* Store the metadata to memory (use the double-precision
+		 * _mm_storeh_pd because there is no integer function for
+		 * storing the upper 64b):
+		 * qe[0] metadata = sse_qe[0][63:0]
+		 * qe[1] metadata = sse_qe[0][127:64]
+		 * qe[2] metadata = sse_qe[1][63:0]
+		 * qe[3] metadata = sse_qe[1][127:64]
+		 */
+		_mm_storel_epi64((__m128i *)&qe[0].u.opaque_data, sse_qe[0]);
+		_mm_storeh_pd((double *)&qe[1].u.opaque_data,
+			      (__m128d)sse_qe[0]);
+		_mm_storel_epi64((__m128i *)&qe[2].u.opaque_data, sse_qe[1]);
+		_mm_storeh_pd((double *)&qe[3].u.opaque_data,
+			      (__m128d)sse_qe[1]);
+
+		qe[0].data = ev[0].u64;
+		qe[1].data = ev[1].u64;
+		qe[2].data = ev[2].u64;
+		qe[3].data = ev[3].u64;
+
+		break;
+	case 3:
+	case 2:
+	case 1:
+		/* At least one QE will be valid, so only zero out three */
+		qe[1].cmd_byte = 0;
+		qe[2].cmd_byte = 0;
+		qe[3].cmd_byte = 0;
+
+		for (i = 0; i < num; i++) {
+			qe[i].cmd_byte =
+				cmd_byte_map[qm_port->is_directed][ev[i].op];
+			qe[i].sched_type = sched_type[i];
+			qe[i].data = ev[i].u64;
+			qe[i].qid = queue_id[i];
+			qe[i].priority = EV_TO_DLB2_PRIO(ev[i].priority);
+			qe[i].lock_id = ev[i].flow_id;
+			if (sched_type[i] == DLB2_SCHED_DIRECTED) {
+				struct dlb2_msg_info *info =
+					(struct dlb2_msg_info *)&qe[i].lock_id;
+
+				info->qid = queue_id[i];
+				info->sched_type = DLB2_SCHED_DIRECTED;
+				info->priority = qe[i].priority;
+			}
+			qe[i].u.event_type.major = ev[i].event_type;
+			qe[i].u.event_type.sub = ev[i].sub_event_type;
+		}
+		break;
+	}
+}
+
+static inline int
+dlb2_event_enqueue_prep(struct dlb2_eventdev_port *ev_port,
+			struct dlb2_port *qm_port,
+			const struct rte_event ev[],
+			uint8_t *sched_type,
+			uint8_t *queue_id)
+{
+	struct dlb2_eventdev *dlb2 = ev_port->dlb2;
+	struct dlb2_eventdev_queue *ev_queue;
+	uint16_t *cached_credits = NULL;
+	struct dlb2_queue *qm_queue;
+
+	ev_queue = &dlb2->ev_queues[ev->queue_id];
+	qm_queue = &ev_queue->qm_queue;
+	*queue_id = qm_queue->id;
+
+	/* Ignore sched_type and hardware credits on release events */
+	if (ev->op == RTE_EVENT_OP_RELEASE)
+		goto op_check;
+
+	if (!qm_queue->is_directed) {
+		/* Load balanced destination queue */
+
+		if (dlb2_check_enqueue_hw_ldb_credits(qm_port)) {
+			rte_errno = -ENOSPC;
+			return 1;
+		}
+		cached_credits = &qm_port->cached_ldb_credits;
+
+		switch (ev->sched_type) {
+		case RTE_SCHED_TYPE_ORDERED:
+			DLB2_LOG_DBG("dlb2: put_qe: RTE_SCHED_TYPE_ORDERED\n");
+			if (qm_queue->sched_type != RTE_SCHED_TYPE_ORDERED) {
+				DLB2_LOG_ERR("dlb2: tried to send ordered event to unordered queue %d\n",
+					     *queue_id);
+				rte_errno = -EINVAL;
+				return 1;
+			}
+			*sched_type = DLB2_SCHED_ORDERED;
+			break;
+		case RTE_SCHED_TYPE_ATOMIC:
+			DLB2_LOG_DBG("dlb2: put_qe: RTE_SCHED_TYPE_ATOMIC\n");
+			*sched_type = DLB2_SCHED_ATOMIC;
+			break;
+		case RTE_SCHED_TYPE_PARALLEL:
+			DLB2_LOG_DBG("dlb2: put_qe: RTE_SCHED_TYPE_PARALLEL\n");
+			if (qm_queue->sched_type == RTE_SCHED_TYPE_ORDERED)
+				*sched_type = DLB2_SCHED_ORDERED;
+			else
+				*sched_type = DLB2_SCHED_UNORDERED;
+			break;
+		default:
+			DLB2_LOG_ERR("Unsupported LDB sched type in put_qe\n");
+			DLB2_INC_STAT(ev_port->stats.tx_invalid, 1);
+			rte_errno = -EINVAL;
+			return 1;
+		}
+	} else {
+		/* Directed destination queue */
+
+		if (dlb2_check_enqueue_hw_dir_credits(qm_port)) {
+			rte_errno = -ENOSPC;
+			return 1;
+		}
+		cached_credits = &qm_port->cached_dir_credits;
+
+		DLB2_LOG_DBG("dlb2: put_qe: RTE_SCHED_TYPE_DIRECTED\n");
+
+		*sched_type = DLB2_SCHED_DIRECTED;
+	}
+
+op_check:
+	switch (ev->op) {
+	case RTE_EVENT_OP_NEW:
+		/* Check that a sw credit is available */
+		if (dlb2_check_enqueue_sw_credits(dlb2, ev_port)) {
+			rte_errno = -ENOSPC;
+			return 1;
+		}
+		ev_port->inflight_credits--;
+		(*cached_credits)--;
+		break;
+	case RTE_EVENT_OP_FORWARD:
+		/* Check for outstanding_releases underflow. If this occurs,
+		 * the application is not using the EVENT_OPs correctly; for
+		 * example, forwarding or releasing events that were not
+		 * dequeued.
+		 */
+		RTE_ASSERT(ev_port->outstanding_releases > 0);
+		ev_port->outstanding_releases--;
+		qm_port->issued_releases++;
+		(*cached_credits)--;
+		break;
+	case RTE_EVENT_OP_RELEASE:
+		ev_port->inflight_credits++;
+		/* Check for outstanding_releases underflow. If this occurs,
+		 * the application is not using the EVENT_OPs correctly; for
+		 * example, forwarding or releasing events that were not
+		 * dequeued.
+		 */
+		RTE_ASSERT(ev_port->outstanding_releases > 0);
+		ev_port->outstanding_releases--;
+		qm_port->issued_releases++;
+
+		/* Replenish s/w credits if enough are cached */
+		dlb2_replenish_sw_credits(dlb2, ev_port);
+		break;
+	}
+
+	DLB2_INC_STAT(ev_port->stats.tx_op_cnt[ev->op], 1);
+	DLB2_INC_STAT(ev_port->stats.traffic.tx_ok, 1);
+
+#ifndef RTE_LIBRTE_PMD_DLB2_QUELL_STATS
+	if (ev->op != RTE_EVENT_OP_RELEASE) {
+		DLB2_INC_STAT(ev_port->stats.queue[ev->queue_id].enq_ok, 1);
+		DLB2_INC_STAT(ev_port->stats.tx_sched_cnt[*sched_type], 1);
+	}
+#endif
+
+	return 0;
+}
+
+static inline uint16_t
+dlb2_event_enqueue_burst(void *event_port,
+			 const struct rte_event events[],
+			 uint16_t num)
+{
+	struct dlb2_eventdev_port *ev_port = event_port;
+	struct dlb2_port *qm_port = &ev_port->qm_port;
+	struct process_local_port_data *port_data;
+	int i, cnt;
+
+	RTE_ASSERT(ev_port->enq_configured);
+	RTE_ASSERT(events != NULL);
+
+	cnt = 0;
+
+	port_data = &dlb2_port[qm_port->id][PORT_TYPE(qm_port)];
+
+	for (i = 0; i < num; i += DLB2_NUM_QES_PER_CACHE_LINE) {
+		uint8_t sched_types[DLB2_NUM_QES_PER_CACHE_LINE];
+		uint8_t queue_ids[DLB2_NUM_QES_PER_CACHE_LINE];
+		int j = 0;
+
+		for (; j < DLB2_NUM_QES_PER_CACHE_LINE && (i + j) < num; j++) {
+			const struct rte_event *ev = &events[i + j];
+
+			if (dlb2_event_enqueue_prep(ev_port, qm_port, ev,
+						    &sched_types[j],
+						    &queue_ids[j]))
+				break;
+		}
+
+		if (j == 0)
+			break;
+
+		dlb2_event_build_hcws(qm_port, &events[i], j,
+				      sched_types, queue_ids);
+
+		dlb2_hw_do_enqueue(qm_port, i == 0, port_data);
+
+		cnt += j;
+
+		if (j < DLB2_NUM_QES_PER_CACHE_LINE)
+			break;
+	}
+
+	return cnt;
+}
+
+static inline uint16_t
+dlb2_event_enqueue(void *event_port,
+		   const struct rte_event events[])
+{
+	return dlb2_event_enqueue_burst(event_port, events, 1);
+}
+
+static uint16_t
+dlb2_event_enqueue_new_burst(void *event_port,
+			     const struct rte_event events[],
+			     uint16_t num)
+{
+	return dlb2_event_enqueue_burst(event_port, events, num);
+}
+
+static uint16_t
+dlb2_event_enqueue_forward_burst(void *event_port,
+				 const struct rte_event events[],
+				 uint16_t num)
+{
+	return dlb2_event_enqueue_burst(event_port, events, num);
+}
+
 static void
 dlb2_entry_points_init(struct rte_eventdev *dev)
 {
@@ -2116,7 +2688,13 @@ dlb2_entry_points_init(struct rte_eventdev *dev)
 		.xstats_reset	    = dlb2_eventdev_xstats_reset,
 	};
 
+	/* Expose PMD's eventdev interface */
+
 	dev->dev_ops = &dlb2_eventdev_entry_ops;
+	dev->enqueue = dlb2_event_enqueue;
+	dev->enqueue_burst = dlb2_event_enqueue_burst;
+	dev->enqueue_new_burst = dlb2_event_enqueue_new_burst;
+	dev->enqueue_forward_burst = dlb2_event_enqueue_forward_burst;
 }
 
 int
Signature · 1 line
2.6.4
#240 lore raw

PATCH v2 16/22 event/dlb2: add dequeue and its burst variants

In reply to Timothy McDaniel

Add support for dequeue, dequeue_burst, ...

DLB2 does not currently support interrupts, but instead use umonitor/umwait if supported by the processor. This allows the software to monitor and wait on writes to a cache-line.

DLB2 supports normal and sparse cq mode. In normal mode the hardware will pack 4 QEs into each cache line. In sparse cq mode, the hardware will only populate one QE per cache line. Software must be aware of the cq mode, and take the appropriate actions, based on the mode.

---
 drivers/event/dlb2/dlb2.c | 761 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 761 insertions(+)
drivers/event/dlb2/dlb2.c +761 -0
index 6cef9cb..417c5d0 100644
@@ -2665,9 +2665,761 @@ dlb2_event_enqueue_forward_burst(void *event_port,
 	return dlb2_event_enqueue_burst(event_port, events, num);
 }
 
+static inline void
+dlb2_port_credits_inc(struct dlb2_port *qm_port, int num)
+{
+	uint32_t batch_size = DLB2_SW_CREDIT_BATCH_SZ;
+
+	/* increment port credits, and return to pool if exceeds threshold */
+	if (!qm_port->is_directed) {
+		qm_port->cached_ldb_credits += num;
+		if (qm_port->cached_ldb_credits >= 2 * batch_size) {
+			__atomic_fetch_add(
+				qm_port->credit_pool[DLB2_LDB_QUEUE],
+				batch_size, __ATOMIC_SEQ_CST);
+			qm_port->cached_ldb_credits -= batch_size;
+		}
+	} else {
+		qm_port->cached_dir_credits += num;
+		if (qm_port->cached_dir_credits >= 2 * batch_size) {
+			__atomic_fetch_add(
+				qm_port->credit_pool[DLB2_DIR_QUEUE],
+				batch_size, __ATOMIC_SEQ_CST);
+			qm_port->cached_dir_credits -= batch_size;
+		}
+	}
+}
+
+static inline bool
+dlb2_cq_is_empty(struct dlb2_port *qm_port)
+{
+	volatile struct dlb2_dequeue_qe *qe_ptr;
+	struct dlb2_dequeue_qe qe;
+
+	qe_ptr = dlb2_port[qm_port->id][PORT_TYPE(qm_port)].cq_base;
+	qe = qe_ptr[qm_port->cq_idx];
+
+	return (qe.cq_gen != qm_port->gen_bit);
+}
+
+static inline int
+dlb2_dequeue_wait(struct dlb2_eventdev *dlb2,
+		  struct dlb2_eventdev_port *ev_port,
+		  struct dlb2_port *qm_port,
+		  uint64_t timeout,
+		  uint64_t start_ticks)
+{
+	struct process_local_port_data *port_data;
+	uint64_t elapsed_ticks;
+
+	port_data = &dlb2_port[qm_port->id][PORT_TYPE(qm_port)];
+
+	elapsed_ticks = rte_get_timer_cycles() - start_ticks;
+
+	/* Wait/poll time expired */
+	if (elapsed_ticks >= timeout) {
+		return 1;
+	} else if (dlb2->umwait_allowed) {
+		volatile struct dlb2_dequeue_qe *cq_base;
+
+		cq_base = port_data->cq_base;
+
+		/* Block on cache line write to CQ. Note: it's
+		 * safe to access the per-process cq_base
+		 * address here, since the PMD has already
+		 * attempted at least one CQ dequeue.
+		 */
+		dlb2_umonitor(&cq_base[qm_port->cq_idx]);
+
+		/* Avoid race condition. Check if still empty */
+		if (dlb2_cq_is_empty(qm_port)) {
+			dlb2_umwait(RTE_LIBRTE_PMD_DLB2_UMWAIT_CTL_STATE,
+				    timeout + start_ticks);
+			DLB2_INC_STAT(
+				ev_port->stats.traffic.rx_umonitor_umwait, 1);
+		}
+	} else {
+		uint64_t poll_interval = RTE_LIBRTE_PMD_DLB2_POLL_INTERVAL;
+		uint64_t curr_ticks = rte_get_timer_cycles();
+		uint64_t init_ticks = curr_ticks;
+
+		while ((curr_ticks - start_ticks < timeout) &&
+		       (curr_ticks - init_ticks < poll_interval))
+			curr_ticks = rte_get_timer_cycles();
+	}
+
+	return 0;
+}
+
+static inline int
+dlb2_process_dequeue_qes(struct dlb2_eventdev_port *ev_port,
+			 struct dlb2_port *qm_port,
+			 struct rte_event *events,
+			 struct dlb2_dequeue_qe *qes,
+			 int cnt)
+{
+	uint8_t *qid_mappings = qm_port->qid_mappings;
+	int i, num, evq_id;
+
+	for (i = 0, num = 0; i < cnt; i++) {
+		struct dlb2_dequeue_qe *qe = &qes[i];
+		int sched_type_map[DLB2_NUM_HW_SCHED_TYPES] = {
+			[DLB2_SCHED_ATOMIC] = RTE_SCHED_TYPE_ATOMIC,
+			[DLB2_SCHED_UNORDERED] = RTE_SCHED_TYPE_PARALLEL,
+			[DLB2_SCHED_ORDERED] = RTE_SCHED_TYPE_ORDERED,
+			[DLB2_SCHED_DIRECTED] = RTE_SCHED_TYPE_ATOMIC,
+		};
+
+		/* Fill in event information.
+		 * Note that flow_id must be embedded in the data by
+		 * the app, such as the mbuf RSS hash field if the data
+		 * buffer is a mbuf.
+		 */
+		if (unlikely(qe->error)) {
+			DLB2_LOG_ERR("QE error bit ON\n");
+			DLB2_INC_STAT(ev_port->stats.traffic.rx_drop, 1);
+			dlb2_consume_qe_immediate(qm_port, 1);
+			continue; /* Ignore */
+		}
+
+		events[num].u64 = qe->data;
+		events[num].flow_id = qe->flow_id;
+		events[num].priority = DLB2_TO_EV_PRIO((uint8_t)qe->priority);
+		events[num].event_type = qe->u.event_type.major;
+		events[num].sub_event_type = qe->u.event_type.sub;
+		events[num].sched_type = sched_type_map[qe->sched_type];
+		events[num].impl_opaque = qe->qid_depth;
+
+		/* qid not preserved for directed queues */
+		if (qm_port->is_directed)
+			evq_id = ev_port->link[0].queue_id;
+		else
+			evq_id = qid_mappings[qe->qid];
+
+		events[num].queue_id = evq_id;
+		DLB2_INC_STAT(
+			ev_port->stats.queue[evq_id].qid_depth[qe->qid_depth],
+			1);
+		DLB2_INC_STAT(ev_port->stats.rx_sched_cnt[qe->sched_type], 1);
+		num++;
+	}
+
+	DLB2_INC_STAT(ev_port->stats.traffic.rx_ok, num);
+
+	return num;
+}
+
+static inline int
+dlb2_process_dequeue_four_qes(struct dlb2_eventdev_port *ev_port,
+			      struct dlb2_port *qm_port,
+			      struct rte_event *events,
+			      struct dlb2_dequeue_qe *qes)
+{
+	int sched_type_map[] = {
+		[DLB2_SCHED_ATOMIC] = RTE_SCHED_TYPE_ATOMIC,
+		[DLB2_SCHED_UNORDERED] = RTE_SCHED_TYPE_PARALLEL,
+		[DLB2_SCHED_ORDERED] = RTE_SCHED_TYPE_ORDERED,
+		[DLB2_SCHED_DIRECTED] = RTE_SCHED_TYPE_ATOMIC,
+	};
+	const int num_events = DLB2_NUM_QES_PER_CACHE_LINE;
+	uint8_t *qid_mappings = qm_port->qid_mappings;
+	__m128i sse_evt[2];
+
+	/* In the unlikely case that any of the QE error bits are set, process
+	 * them one at a time.
+	 */
+	if (unlikely(qes[0].error || qes[1].error ||
+		     qes[2].error || qes[3].error))
+		return dlb2_process_dequeue_qes(ev_port, qm_port, events,
+						 qes, num_events);
+
+	events[0].u64 = qes[0].data;
+	events[1].u64 = qes[1].data;
+	events[2].u64 = qes[2].data;
+	events[3].u64 = qes[3].data;
+
+	/* Construct the metadata portion of two struct rte_events
+	 * in one 128b SSE register. Event metadata is constructed in the SSE
+	 * registers like so:
+	 * sse_evt[0][63:0]:   event[0]'s metadata
+	 * sse_evt[0][127:64]: event[1]'s metadata
+	 * sse_evt[1][63:0]:   event[2]'s metadata
+	 * sse_evt[1][127:64]: event[3]'s metadata
+	 */
+	sse_evt[0] = _mm_setzero_si128();
+	sse_evt[1] = _mm_setzero_si128();
+
+	/* Convert the hardware queue ID to an event queue ID and store it in
+	 * the metadata:
+	 * sse_evt[0][47:40]   = qid_mappings[qes[0].qid]
+	 * sse_evt[0][111:104] = qid_mappings[qes[1].qid]
+	 * sse_evt[1][47:40]   = qid_mappings[qes[2].qid]
+	 * sse_evt[1][111:104] = qid_mappings[qes[3].qid]
+	 */
+#define RTE_EVENT_QUEUE_ID_BYTE 5
+	sse_evt[0] = _mm_insert_epi8(sse_evt[0],
+				     qid_mappings[qes[0].qid],
+				     RTE_EVENT_QUEUE_ID_BYTE);
+	sse_evt[0] = _mm_insert_epi8(sse_evt[0],
+				     qid_mappings[qes[1].qid],
+				     RTE_EVENT_QUEUE_ID_BYTE + 8);
+	sse_evt[1] = _mm_insert_epi8(sse_evt[1],
+				     qid_mappings[qes[2].qid],
+				     RTE_EVENT_QUEUE_ID_BYTE);
+	sse_evt[1] = _mm_insert_epi8(sse_evt[1],
+				     qid_mappings[qes[3].qid],
+				     RTE_EVENT_QUEUE_ID_BYTE + 8);
+
+	/* Convert the hardware priority to an event priority and store it in
+	 * the metadata, while also returning the queue depth status
+	 * value captured by the hardware, storing it in impl_opaque, which can
+	 * be read by the application but not modified
+	 * sse_evt[0][55:48]   = DLB2_TO_EV_PRIO(qes[0].priority)
+	 * sse_evt[0][63:56]   = qes[0].qid_depth
+	 * sse_evt[0][119:112] = DLB2_TO_EV_PRIO(qes[1].priority)
+	 * sse_evt[0][127:120] = qes[1].qid_depth
+	 * sse_evt[1][55:48]   = DLB2_TO_EV_PRIO(qes[2].priority)
+	 * sse_evt[1][63:56]   = qes[2].qid_depth
+	 * sse_evt[1][119:112] = DLB2_TO_EV_PRIO(qes[3].priority)
+	 * sse_evt[1][127:120] = qes[3].qid_depth
+	 */
+#define RTE_EVENT_PRIO_IMPL_OPAQUE_WORD 3
+#define RTE_BYTE_SHIFT 8
+	sse_evt[0] =
+		_mm_insert_epi16(sse_evt[0],
+			DLB2_TO_EV_PRIO((uint8_t)qes[0].priority) |
+			(qes[0].qid_depth << RTE_BYTE_SHIFT),
+			RTE_EVENT_PRIO_IMPL_OPAQUE_WORD);
+	sse_evt[0] =
+		_mm_insert_epi16(sse_evt[0],
+			DLB2_TO_EV_PRIO((uint8_t)qes[1].priority) |
+			(qes[1].qid_depth << RTE_BYTE_SHIFT),
+			RTE_EVENT_PRIO_IMPL_OPAQUE_WORD + 4);
+	sse_evt[1] =
+		_mm_insert_epi16(sse_evt[1],
+			DLB2_TO_EV_PRIO((uint8_t)qes[2].priority) |
+			(qes[2].qid_depth << RTE_BYTE_SHIFT),
+			RTE_EVENT_PRIO_IMPL_OPAQUE_WORD);
+	sse_evt[1] =
+		_mm_insert_epi16(sse_evt[1],
+			DLB2_TO_EV_PRIO((uint8_t)qes[3].priority) |
+			(qes[3].qid_depth << RTE_BYTE_SHIFT),
+			RTE_EVENT_PRIO_IMPL_OPAQUE_WORD + 4);
+
+	/* Write the event type, sub event type, and flow_id to the event
+	 * metadata.
+	 * sse_evt[0][31:0]   = qes[0].flow_id |
+	 *			qes[0].u.event_type.major << 28 |
+	 *			qes[0].u.event_type.sub << 20;
+	 * sse_evt[0][95:64]  = qes[1].flow_id |
+	 *			qes[1].u.event_type.major << 28 |
+	 *			qes[1].u.event_type.sub << 20;
+	 * sse_evt[1][31:0]   = qes[2].flow_id |
+	 *			qes[2].u.event_type.major << 28 |
+	 *			qes[2].u.event_type.sub << 20;
+	 * sse_evt[1][95:64]  = qes[3].flow_id |
+	 *			qes[3].u.event_type.major << 28 |
+	 *			qes[3].u.event_type.sub << 20;
+	 */
+#define RTE_EVENT_EV_TYPE_DW 0
+#define RTE_EVENT_EV_TYPE_SHIFT 28
+#define RTE_EVENT_SUB_EV_TYPE_SHIFT 20
+	sse_evt[0] = _mm_insert_epi32(sse_evt[0],
+			qes[0].flow_id |
+			qes[0].u.event_type.major << RTE_EVENT_EV_TYPE_SHIFT |
+			qes[0].u.event_type.sub <<  RTE_EVENT_SUB_EV_TYPE_SHIFT,
+			RTE_EVENT_EV_TYPE_DW);
+	sse_evt[0] = _mm_insert_epi32(sse_evt[0],
+			qes[1].flow_id |
+			qes[1].u.event_type.major << RTE_EVENT_EV_TYPE_SHIFT |
+			qes[1].u.event_type.sub <<  RTE_EVENT_SUB_EV_TYPE_SHIFT,
+			RTE_EVENT_EV_TYPE_DW + 2);
+	sse_evt[1] = _mm_insert_epi32(sse_evt[1],
+			qes[2].flow_id |
+			qes[2].u.event_type.major << RTE_EVENT_EV_TYPE_SHIFT |
+			qes[2].u.event_type.sub <<  RTE_EVENT_SUB_EV_TYPE_SHIFT,
+			RTE_EVENT_EV_TYPE_DW);
+	sse_evt[1] = _mm_insert_epi32(sse_evt[1],
+			qes[3].flow_id |
+			qes[3].u.event_type.major << RTE_EVENT_EV_TYPE_SHIFT  |
+			qes[3].u.event_type.sub << RTE_EVENT_SUB_EV_TYPE_SHIFT,
+			RTE_EVENT_EV_TYPE_DW + 2);
+
+	/* Write the sched type to the event metadata. 'op' and 'rsvd' are not
+	 * set:
+	 * sse_evt[0][39:32]  = sched_type_map[qes[0].sched_type] << 6
+	 * sse_evt[0][103:96] = sched_type_map[qes[1].sched_type] << 6
+	 * sse_evt[1][39:32]  = sched_type_map[qes[2].sched_type] << 6
+	 * sse_evt[1][103:96] = sched_type_map[qes[3].sched_type] << 6
+	 */
+#define RTE_EVENT_SCHED_TYPE_BYTE 4
+#define RTE_EVENT_SCHED_TYPE_SHIFT 6
+	sse_evt[0] = _mm_insert_epi8(sse_evt[0],
+		sched_type_map[qes[0].sched_type] << RTE_EVENT_SCHED_TYPE_SHIFT,
+		RTE_EVENT_SCHED_TYPE_BYTE);
+	sse_evt[0] = _mm_insert_epi8(sse_evt[0],
+		sched_type_map[qes[1].sched_type] << RTE_EVENT_SCHED_TYPE_SHIFT,
+		RTE_EVENT_SCHED_TYPE_BYTE + 8);
+	sse_evt[1] = _mm_insert_epi8(sse_evt[1],
+		sched_type_map[qes[2].sched_type] << RTE_EVENT_SCHED_TYPE_SHIFT,
+		RTE_EVENT_SCHED_TYPE_BYTE);
+	sse_evt[1] = _mm_insert_epi8(sse_evt[1],
+		sched_type_map[qes[3].sched_type] << RTE_EVENT_SCHED_TYPE_SHIFT,
+		RTE_EVENT_SCHED_TYPE_BYTE + 8);
+
+	/* Store the metadata to the event (use the double-precision
+	 * _mm_storeh_pd because there is no integer function for storing the
+	 * upper 64b):
+	 * events[0].event = sse_evt[0][63:0]
+	 * events[1].event = sse_evt[0][127:64]
+	 * events[2].event = sse_evt[1][63:0]
+	 * events[3].event = sse_evt[1][127:64]
+	 */
+	_mm_storel_epi64((__m128i *)&events[0].event, sse_evt[0]);
+	_mm_storeh_pd((double *)&events[1].event, (__m128d) sse_evt[0]);
+	_mm_storel_epi64((__m128i *)&events[2].event, sse_evt[1]);
+	_mm_storeh_pd((double *)&events[3].event, (__m128d) sse_evt[1]);
+
+	DLB2_INC_STAT(ev_port->stats.rx_sched_cnt[qes[0].sched_type], 1);
+	DLB2_INC_STAT(ev_port->stats.rx_sched_cnt[qes[1].sched_type], 1);
+	DLB2_INC_STAT(ev_port->stats.rx_sched_cnt[qes[2].sched_type], 1);
+	DLB2_INC_STAT(ev_port->stats.rx_sched_cnt[qes[3].sched_type], 1);
+
+	DLB2_INC_STAT(
+		ev_port->stats.queue[events[0].queue_id].
+			qid_depth[qes[0].qid_depth],
+		1);
+	DLB2_INC_STAT(
+		ev_port->stats.queue[events[1].queue_id].
+			qid_depth[qes[1].qid_depth],
+		1);
+	DLB2_INC_STAT(
+		ev_port->stats.queue[events[2].queue_id].
+			qid_depth[qes[2].qid_depth],
+		1);
+	DLB2_INC_STAT(
+		ev_port->stats.queue[events[3].queue_id].
+			qid_depth[qes[3].qid_depth],
+		1);
+
+	DLB2_INC_STAT(ev_port->stats.traffic.rx_ok, num_events);
+
+	return num_events;
+}
+
+static __rte_always_inline int
+dlb2_recv_qe_sparse(struct dlb2_port *qm_port, struct dlb2_dequeue_qe *qe)
+{
+	volatile struct dlb2_dequeue_qe *cq_addr;
+	uint8_t xor_mask[2] = {0x0F, 0x00};
+	const uint8_t and_mask = 0x0F;
+	__m128i *qes = (__m128i *)qe;
+	uint8_t gen_bits, gen_bit;
+	uintptr_t addr[4];
+	uint16_t idx;
+
+	cq_addr = dlb2_port[qm_port->id][PORT_TYPE(qm_port)].cq_base;
+
+	idx = qm_port->cq_idx;
+
+	/* Load the next 4 QEs */
+	addr[0] = (uintptr_t)&cq_addr[idx];
+	addr[1] = (uintptr_t)&cq_addr[(idx +  4) & qm_port->cq_depth_mask];
+	addr[2] = (uintptr_t)&cq_addr[(idx +  8) & qm_port->cq_depth_mask];
+	addr[3] = (uintptr_t)&cq_addr[(idx + 12) & qm_port->cq_depth_mask];
+
+	/* Prefetch next batch of QEs (all CQs occupy minimum 8 cache lines) */
+	rte_prefetch0(&cq_addr[(idx + 16) & qm_port->cq_depth_mask]);
+	rte_prefetch0(&cq_addr[(idx + 20) & qm_port->cq_depth_mask]);
+	rte_prefetch0(&cq_addr[(idx + 24) & qm_port->cq_depth_mask]);
+	rte_prefetch0(&cq_addr[(idx + 28) & qm_port->cq_depth_mask]);
+
+	/* Correct the xor_mask for wrap-around QEs */
+	gen_bit = qm_port->gen_bit;
+	xor_mask[gen_bit] ^= !!((idx +  4) > qm_port->cq_depth_mask) << 1;
+	xor_mask[gen_bit] ^= !!((idx +  8) > qm_port->cq_depth_mask) << 2;
+	xor_mask[gen_bit] ^= !!((idx + 12) > qm_port->cq_depth_mask) << 3;
+
+	/* Read the cache lines backwards to ensure that if QE[N] (N > 0) is
+	 * valid, then QEs[0:N-1] are too.
+	 */
+	qes[3] = _mm_load_si128((__m128i *)(void *)addr[3]);
+	rte_compiler_barrier();
+	qes[2] = _mm_load_si128((__m128i *)(void *)addr[2]);
+	rte_compiler_barrier();
+	qes[1] = _mm_load_si128((__m128i *)(void *)addr[1]);
+	rte_compiler_barrier();
+	qes[0] = _mm_load_si128((__m128i *)(void *)addr[0]);
+
+	/* Extract and combine the gen bits */
+	gen_bits = ((_mm_extract_epi8(qes[0], 15) & 0x1) << 0) |
+		   ((_mm_extract_epi8(qes[1], 15) & 0x1) << 1) |
+		   ((_mm_extract_epi8(qes[2], 15) & 0x1) << 2) |
+		   ((_mm_extract_epi8(qes[3], 15) & 0x1) << 3);
+
+	/* XOR the combined bits such that a 1 represents a valid QE */
+	gen_bits ^= xor_mask[gen_bit];
+
+	/* Mask off gen bits we don't care about */
+	gen_bits &= and_mask;
+
+	return __builtin_popcount(gen_bits);
+}
+
+static inline void
+dlb2_inc_cq_idx(struct dlb2_port *qm_port, int cnt)
+{
+	uint16_t idx = qm_port->cq_idx_unmasked + cnt;
+
+	qm_port->cq_idx_unmasked = idx;
+	qm_port->cq_idx = idx & qm_port->cq_depth_mask;
+	qm_port->gen_bit = (~(idx >> qm_port->gen_bit_shift)) & 0x1;
+}
+
+static int
+dlb2_event_release(struct dlb2_eventdev *dlb2,
+		   uint8_t port_id,
+		   int n)
+{
+	struct process_local_port_data *port_data;
+	struct dlb2_eventdev_port *ev_port;
+	struct dlb2_port *qm_port;
+	int i, cnt;
+
+	if (port_id > dlb2->num_ports) {
+		DLB2_LOG_ERR("Invalid port id %d in dlb2-event_release\n",
+			     port_id);
+		rte_errno = -EINVAL;
+		return rte_errno;
+	}
+
+	ev_port = &dlb2->ev_ports[port_id];
+	qm_port = &ev_port->qm_port;
+	port_data = &dlb2_port[qm_port->id][PORT_TYPE(qm_port)];
+
+	cnt = 0;
+
+	if (qm_port->is_directed) {
+		cnt = n;
+		goto sw_credit_update;
+	}
+
+	for (i = 0; i < n; i += DLB2_NUM_QES_PER_CACHE_LINE) {
+		int j;
+
+		/* Zero-out QEs */
+		qm_port->qe4[0].cmd_byte = 0;
+		qm_port->qe4[1].cmd_byte = 0;
+		qm_port->qe4[2].cmd_byte = 0;
+		qm_port->qe4[3].cmd_byte = 0;
+
+		for (j = 0; j < DLB2_NUM_QES_PER_CACHE_LINE && (i + j) < n; j++)
+			qm_port->qe4[j].cmd_byte = DLB2_COMP_CMD_BYTE;
+
+		qm_port->issued_releases += j;
+
+		if (j == 0)
+			break;
+
+		dlb2_hw_do_enqueue(qm_port, i == 0, port_data);
+
+		cnt += j;
+	}
+
+sw_credit_update:
+	/* each release returns one credit */
+	if (!ev_port->outstanding_releases) {
+		DLB2_LOG_ERR("Unrecoverable application error. Outstanding releases underflowed.\n");
+		rte_errno = -ENOTRECOVERABLE;
+		return rte_errno;
+	}
+
+	ev_port->outstanding_releases -= cnt;
+	ev_port->inflight_credits += cnt;
+
+	/* Replenish s/w credits if enough releases are performed */
+	dlb2_replenish_sw_credits(dlb2, ev_port);
+	return 0;
+}
+
+static inline int16_t
+dlb2_hw_dequeue_sparse(struct dlb2_eventdev *dlb2,
+		       struct dlb2_eventdev_port *ev_port,
+		       struct rte_event *events,
+		       uint16_t max_num,
+		       uint64_t dequeue_timeout_ticks)
+{
+	uint64_t timeout;
+	uint64_t start_ticks = 0ULL;
+	struct dlb2_port *qm_port;
+	int num = 0;
+
+	qm_port = &ev_port->qm_port;
+
+	/* We have a special implementation for waiting. Wait can be:
+	 * 1) no waiting at all
+	 * 2) busy poll only
+	 * 3) wait for interrupt. If wakeup and poll time
+	 * has expired, then return to caller
+	 * 4) umonitor/umwait repeatedly up to poll time
+	 */
+
+	/* If configured for per dequeue wait, then use wait value provided
+	 * to this API. Otherwise we must use the global
+	 * value from eventdev config time.
+	 */
+	if (!dlb2->global_dequeue_wait)
+		timeout = dequeue_timeout_ticks;
+	else
+		timeout = dlb2->global_dequeue_wait_ticks;
+
+	start_ticks = rte_get_timer_cycles();
+
+	while (num < max_num) {
+		struct dlb2_dequeue_qe qes[DLB2_NUM_QES_PER_CACHE_LINE];
+		int num_avail;
+
+		/* Copy up to 4 QEs from the current cache line into qes */
+		num_avail = dlb2_recv_qe_sparse(qm_port, qes);
+
+		/* But don't process more than the user requested */
+		num_avail = RTE_MIN(num_avail, max_num - num);
+
+		dlb2_inc_cq_idx(qm_port, num_avail << 2);
+
+		if (num_avail == DLB2_NUM_QES_PER_CACHE_LINE)
+			num += dlb2_process_dequeue_four_qes(ev_port,
+							      qm_port,
+							      &events[num],
+							      &qes[0]);
+		else if (num_avail)
+			num += dlb2_process_dequeue_qes(ev_port,
+							 qm_port,
+							 &events[num],
+							 &qes[0],
+							 num_avail);
+		else if ((timeout == 0) || (num > 0))
+			/* Not waiting in any form, or 1+ events received? */
+			break;
+		else if (dlb2_dequeue_wait(dlb2, ev_port, qm_port,
+					   timeout, start_ticks))
+			break;
+	}
+
+	qm_port->owed_tokens += num;
+
+	if (num) {
+
+		dlb2_consume_qe_immediate(qm_port, num);
+
+		ev_port->outstanding_releases += num;
+
+		dlb2_port_credits_inc(qm_port, num);
+	}
+
+	return num;
+}
+
+static __rte_always_inline int
+dlb2_recv_qe(struct dlb2_port *qm_port, struct dlb2_dequeue_qe *qe,
+	     uint8_t *offset)
+{
+	uint8_t xor_mask[2][4] = { {0x0F, 0x0E, 0x0C, 0x08},
+				   {0x00, 0x01, 0x03, 0x07} };
+	uint8_t and_mask[4] = {0x0F, 0x0E, 0x0C, 0x08};
+	volatile struct dlb2_dequeue_qe *cq_addr;
+	__m128i *qes = (__m128i *)qe;
+	uint64_t *cache_line_base;
+	uint8_t gen_bits;
+
+	cq_addr = dlb2_port[qm_port->id][PORT_TYPE(qm_port)].cq_base;
+	cq_addr = &cq_addr[qm_port->cq_idx];
+
+	cache_line_base = (void *)(((uintptr_t)cq_addr) & ~0x3F);
+	*offset = ((uintptr_t)cq_addr & 0x30) >> 4;
+
+	/* Load the next CQ cache line from memory. Pack these reads as tight
+	 * as possible to reduce the chance that DLB invalidates the line while
+	 * the CPU is reading it. Read the cache line backwards to ensure that
+	 * if QE[N] (N > 0) is valid, then QEs[0:N-1] are too.
+	 *
+	 * (Valid QEs start at &qe[offset])
+	 */
+	qes[3] = _mm_load_si128((__m128i *)&cache_line_base[6]);
+	qes[2] = _mm_load_si128((__m128i *)&cache_line_base[4]);
+	qes[1] = _mm_load_si128((__m128i *)&cache_line_base[2]);
+	qes[0] = _mm_load_si128((__m128i *)&cache_line_base[0]);
+
+	/* Evict the cache line ASAP */
+	dlb2_cldemote(cache_line_base);
+
+	/* Extract and combine the gen bits */
+	gen_bits = ((_mm_extract_epi8(qes[0], 15) & 0x1) << 0) |
+		   ((_mm_extract_epi8(qes[1], 15) & 0x1) << 1) |
+		   ((_mm_extract_epi8(qes[2], 15) & 0x1) << 2) |
+		   ((_mm_extract_epi8(qes[3], 15) & 0x1) << 3);
+
+	/* XOR the combined bits such that a 1 represents a valid QE */
+	gen_bits ^= xor_mask[qm_port->gen_bit][*offset];
+
+	/* Mask off gen bits we don't care about */
+	gen_bits &= and_mask[*offset];
+
+	return __builtin_popcount(gen_bits);
+}
+
+static inline int16_t
+dlb2_hw_dequeue(struct dlb2_eventdev *dlb2,
+		struct dlb2_eventdev_port *ev_port,
+		struct rte_event *events,
+		uint16_t max_num,
+		uint64_t dequeue_timeout_ticks)
+{
+	uint64_t timeout;
+	uint64_t start_ticks = 0ULL;
+	struct dlb2_port *qm_port;
+	int num = 0;
+
+	qm_port = &ev_port->qm_port;
+
+	/* We have a special implementation for waiting. Wait can be:
+	 * 1) no waiting at all
+	 * 2) busy poll only
+	 * 3) wait for interrupt. If wakeup and poll time
+	 * has expired, then return to caller
+	 * 4) umonitor/umwait repeatedly up to poll time
+	 */
+
+	/* If configured for per dequeue wait, then use wait value provided
+	 * to this API. Otherwise we must use the global
+	 * value from eventdev config time.
+	 */
+	if (!dlb2->global_dequeue_wait)
+		timeout = dequeue_timeout_ticks;
+	else
+		timeout = dlb2->global_dequeue_wait_ticks;
+
+	start_ticks = rte_get_timer_cycles();
+
+	while (num < max_num) {
+		struct dlb2_dequeue_qe qes[DLB2_NUM_QES_PER_CACHE_LINE];
+		uint8_t offset;
+		int num_avail;
+
+		/* Copy up to 4 QEs from the current cache line into qes */
+		num_avail = dlb2_recv_qe(qm_port, qes, &offset);
+
+		/* But don't process more than the user requested */
+		num_avail = RTE_MIN(num_avail, max_num - num);
+
+		dlb2_inc_cq_idx(qm_port, num_avail);
+
+		if (num_avail == DLB2_NUM_QES_PER_CACHE_LINE)
+			num += dlb2_process_dequeue_four_qes(ev_port,
+							     qm_port,
+							     &events[num],
+							     &qes[offset]);
+		else if (num_avail)
+			num += dlb2_process_dequeue_qes(ev_port,
+							qm_port,
+							&events[num],
+							&qes[offset],
+							num_avail);
+		else if ((timeout == 0) || (num > 0))
+			/* Not waiting in any form, or 1+ events received? */
+			break;
+		else if (dlb2_dequeue_wait(dlb2, ev_port, qm_port,
+					   timeout, start_ticks))
+			break;
+	}
+
+	qm_port->owed_tokens += num;
+
+	if (num) {
+
+		dlb2_consume_qe_immediate(qm_port, num);
+
+		ev_port->outstanding_releases += num;
+
+		dlb2_port_credits_inc(qm_port, num);
+	}
+
+	return num;
+}
+
+static uint16_t
+dlb2_event_dequeue_burst(void *event_port, struct rte_event *ev, uint16_t num,
+			 uint64_t wait)
+{
+	struct dlb2_eventdev_port *ev_port = event_port;
+	struct dlb2_eventdev *dlb2 = ev_port->dlb2;
+	uint16_t cnt;
+
+	RTE_ASSERT(ev_port->setup_done);
+	RTE_ASSERT(ev != NULL);
+
+	if (ev_port->implicit_release && ev_port->outstanding_releases > 0) {
+		uint16_t out_rels = ev_port->outstanding_releases;
+
+		if (dlb2_event_release(dlb2, ev_port->id, out_rels))
+			return 0; /* rte_errno is set */
+
+		DLB2_INC_STAT(ev_port->stats.tx_implicit_rel, out_rels);
+	}
+
+	cnt = dlb2_hw_dequeue(dlb2, ev_port, ev, num, wait);
+
+	DLB2_INC_STAT(ev_port->stats.traffic.total_polls, 1);
+	DLB2_INC_STAT(ev_port->stats.traffic.zero_polls, ((cnt == 0) ? 1 : 0));
+
+	return cnt;
+}
+
+static uint16_t
+dlb2_event_dequeue(void *event_port, struct rte_event *ev, uint64_t wait)
+{
+	return dlb2_event_dequeue_burst(event_port, ev, 1, wait);
+}
+
+static uint16_t
+dlb2_event_dequeue_burst_sparse(void *event_port, struct rte_event *ev,
+				uint16_t num, uint64_t wait)
+{
+	struct dlb2_eventdev_port *ev_port = event_port;
+	struct dlb2_eventdev *dlb2 = ev_port->dlb2;
+	uint16_t cnt;
+
+	RTE_ASSERT(ev_port->setup_done);
+	RTE_ASSERT(ev != NULL);
+
+	if (ev_port->implicit_release && ev_port->outstanding_releases > 0) {
+		uint16_t out_rels = ev_port->outstanding_releases;
+
+		if (dlb2_event_release(dlb2, ev_port->id, out_rels))
+			return 0; /* rte_errno is set */
+
+		DLB2_INC_STAT(ev_port->stats.tx_implicit_rel, out_rels);
+	}
+
+	cnt = dlb2_hw_dequeue_sparse(dlb2, ev_port, ev, num, wait);
+
+	DLB2_INC_STAT(ev_port->stats.traffic.total_polls, 1);
+	DLB2_INC_STAT(ev_port->stats.traffic.zero_polls, ((cnt == 0) ? 1 : 0));
+	return cnt;
+}
+
+static uint16_t
+dlb2_event_dequeue_sparse(void *event_port, struct rte_event *ev,
+			  uint64_t wait)
+{
+	return dlb2_event_dequeue_burst_sparse(event_port, ev, 1, wait);
+}
+
 static void
 dlb2_entry_points_init(struct rte_eventdev *dev)
 {
+	struct dlb2_eventdev *dlb2;
+
 	/* Expose PMD's eventdev interface */
 	static struct rte_eventdev_ops dlb2_eventdev_entry_ops = {
 		.dev_infos_get    = dlb2_eventdev_info_get,
@@ -2695,6 +3447,15 @@ dlb2_entry_points_init(struct rte_eventdev *dev)
 	dev->enqueue_burst = dlb2_event_enqueue_burst;
 	dev->enqueue_new_burst = dlb2_event_enqueue_new_burst;
 	dev->enqueue_forward_burst = dlb2_event_enqueue_forward_burst;
+
+	dlb2 = dev->data->dev_private;
+	if (dlb2->poll_mode == DLB2_CQ_POLL_MODE_SPARSE) {
+		dev->dequeue = dlb2_event_dequeue_sparse;
+		dev->dequeue_burst = dlb2_event_dequeue_burst_sparse;
+	} else {
+		dev->dequeue = dlb2_event_dequeue;
+		dev->dequeue_burst = dlb2_event_dequeue_burst;
+	}
 }
 
 int
Signature · 1 line
2.6.4
Reviewed-by on v2 16/22
#241 lore raw

Re: [dpdk-dev] [PATCH v2 16/22] event/dlb2: add dequeue and its burst variants

Quoted 16 lines

-----Original Message-----
From: McDaniel, Timothy <[email protected]>
Sent: Saturday, October 17, 2020 1:21 PM
Cc: [email protected]; Carrillo, Erik G <[email protected]>; Eads, Gage <[email protected]>; Van Haaren, Harry <[email protected]>; [email protected]
Subject: [PATCH v2 16/22] event/dlb2: add dequeue and its burst variants

Add support for dequeue, dequeue_burst, ...

DLB2 does not currently support interrupts, but instead use umonitor/umwait if supported by the processor. This allows the software to monitor and wait on writes to a cache-line.

Quoted 7 lines

DLB2 supports normal and sparse cq mode. In normal mode the hardware will pack 4 QEs into each cache line. In sparse cq mode, the hardware will only populate one QE per cache line. Software must be aware of the cq mode, and take the appropriate actions, based on the mode.

Thanks,
Gage

#242 lore raw

PATCH v2 17/22 event/dlb2: add eventdev stop and close

In reply to Timothy McDaniel

Add support for eventdev stop and close entry points.

---
 drivers/event/dlb2/dlb2.c                  | 257 +++++++++++++++++++++++++++--
 drivers/event/dlb2/dlb2_iface.c            |   6 +
 drivers/event/dlb2/dlb2_iface.h            |   6 +
 drivers/event/dlb2/pf/base/dlb2_resource.c |  91 ++++++++++
 drivers/event/dlb2/pf/dlb2_pf.c            |  52 ++++++
 5 files changed, 396 insertions(+), 16 deletions(-)
drivers/event/dlb2/dlb2.c +241 -16
index 417c5d0..483659e 100644
@@ -74,21 +74,6 @@ static struct rte_event_dev_info evdev_dlb2_default_info = {
 struct process_local_port_data
 dlb2_port[DLB2_MAX_NUM_PORTS][DLB2_NUM_PORT_TYPES];
 
-/*
- * DUMMY - added so that xstats path will compile/link.
- * Will be replaced by real version in a subsequent
- * patch.
- */
-uint32_t
-dlb2_get_queue_depth(struct dlb2_eventdev *dlb2,
-		     struct dlb2_eventdev_queue *queue)
-{
-	RTE_SET_USED(dlb2);
-	RTE_SET_USED(queue);
-
-	return 0;
-}
-
 static void
 dlb2_free_qe_mem(struct dlb2_port *qm_port)
 {
@@ -1881,7 +1866,6 @@ dlb2_eventdev_port_unlink(struct rte_eventdev *dev, void *event_port,
 		return 0; /* Ignore and return success */
 	}
 
-	/* FIXME: How to handle unlink on a directed port? */
 	if (ev_port->qm_port.is_directed) {
 		DLB2_LOG_DBG("dlb2: ignore unlink from dir port %d\n",
 			     ev_port->id);
@@ -3416,6 +3400,245 @@ dlb2_event_dequeue_sparse(void *event_port, struct rte_event *ev,
 }
 
 static void
+dlb2_flush_port(struct rte_eventdev *dev, int port_id)
+{
+	struct dlb2_eventdev *dlb2 = dlb2_pmd_priv(dev);
+	eventdev_stop_flush_t flush;
+	struct rte_event ev;
+	uint8_t dev_id;
+	void *arg;
+	int i;
+
+	flush = dev->dev_ops->dev_stop_flush;
+	dev_id = dev->data->dev_id;
+	arg = dev->data->dev_stop_flush_arg;
+
+	while (rte_event_dequeue_burst(dev_id, port_id, &ev, 1, 0)) {
+		if (flush)
+			flush(dev_id, ev, arg);
+
+		if (dlb2->ev_ports[port_id].qm_port.is_directed)
+			continue;
+
+		ev.op = RTE_EVENT_OP_RELEASE;
+
+		rte_event_enqueue_burst(dev_id, port_id, &ev, 1);
+	}
+
+	/* Enqueue any additional outstanding releases */
+	ev.op = RTE_EVENT_OP_RELEASE;
+
+	for (i = dlb2->ev_ports[port_id].outstanding_releases; i > 0; i--)
+		rte_event_enqueue_burst(dev_id, port_id, &ev, 1);
+}
+
+static uint32_t
+dlb2_get_ldb_queue_depth(struct dlb2_eventdev *dlb2,
+			 struct dlb2_eventdev_queue *queue)
+{
+	struct dlb2_hw_dev *handle = &dlb2->qm_instance;
+	struct dlb2_get_ldb_queue_depth_args cfg;
+	int ret;
+
+	cfg.queue_id = queue->qm_queue.id;
+
+	ret = dlb2_iface_get_ldb_queue_depth(handle, &cfg);
+	if (ret < 0) {
+		DLB2_LOG_ERR("dlb2: get_ldb_queue_depth ret=%d (driver status: %s)\n",
+			     ret, dlb2_error_strings[cfg.response.status]);
+		return ret;
+	}
+
+	return cfg.response.id;
+}
+
+static uint32_t
+dlb2_get_dir_queue_depth(struct dlb2_eventdev *dlb2,
+			 struct dlb2_eventdev_queue *queue)
+{
+	struct dlb2_hw_dev *handle = &dlb2->qm_instance;
+	struct dlb2_get_dir_queue_depth_args cfg;
+	int ret;
+
+	cfg.queue_id = queue->qm_queue.id;
+
+	ret = dlb2_iface_get_dir_queue_depth(handle, &cfg);
+	if (ret < 0) {
+		DLB2_LOG_ERR("dlb2: get_dir_queue_depth ret=%d (driver status: %s)\n",
+			     ret, dlb2_error_strings[cfg.response.status]);
+		return ret;
+	}
+
+	return cfg.response.id;
+}
+
+uint32_t
+dlb2_get_queue_depth(struct dlb2_eventdev *dlb2,
+		     struct dlb2_eventdev_queue *queue)
+{
+	if (queue->qm_queue.is_directed)
+		return dlb2_get_dir_queue_depth(dlb2, queue);
+	else
+		return dlb2_get_ldb_queue_depth(dlb2, queue);
+}
+
+static bool
+dlb2_queue_is_empty(struct dlb2_eventdev *dlb2,
+		    struct dlb2_eventdev_queue *queue)
+{
+	return dlb2_get_queue_depth(dlb2, queue) == 0;
+}
+
+static bool
+dlb2_linked_queues_empty(struct dlb2_eventdev *dlb2)
+{
+	int i;
+
+	for (i = 0; i < dlb2->num_queues; i++) {
+		if (dlb2->ev_queues[i].num_links == 0)
+			continue;
+		if (!dlb2_queue_is_empty(dlb2, &dlb2->ev_queues[i]))
+			return false;
+	}
+
+	return true;
+}
+
+static bool
+dlb2_queues_empty(struct dlb2_eventdev *dlb2)
+{
+	int i;
+
+	for (i = 0; i < dlb2->num_queues; i++) {
+		if (!dlb2_queue_is_empty(dlb2, &dlb2->ev_queues[i]))
+			return false;
+	}
+
+	return true;
+}
+
+static void
+dlb2_drain(struct rte_eventdev *dev)
+{
+	struct dlb2_eventdev *dlb2 = dlb2_pmd_priv(dev);
+	struct dlb2_eventdev_port *ev_port = NULL;
+	uint8_t dev_id;
+	int i;
+
+	dev_id = dev->data->dev_id;
+
+	while (!dlb2_linked_queues_empty(dlb2)) {
+		/* Flush all the ev_ports, which will drain all their connected
+		 * queues.
+		 */
+		for (i = 0; i < dlb2->num_ports; i++)
+			dlb2_flush_port(dev, i);
+	}
+
+	/* The queues are empty, but there may be events left in the ports. */
+	for (i = 0; i < dlb2->num_ports; i++)
+		dlb2_flush_port(dev, i);
+
+	/* If the domain's queues are empty, we're done. */
+	if (dlb2_queues_empty(dlb2))
+		return;
+
+	/* Else, there must be at least one unlinked load-balanced queue.
+	 * Select a load-balanced port with which to drain the unlinked
+	 * queue(s).
+	 */
+	for (i = 0; i < dlb2->num_ports; i++) {
+		ev_port = &dlb2->ev_ports[i];
+
+		if (!ev_port->qm_port.is_directed)
+			break;
+	}
+
+	if (i == dlb2->num_ports) {
+		DLB2_LOG_ERR("internal error: no LDB ev_ports\n");
+		return;
+	}
+
+	rte_errno = 0;
+	rte_event_port_unlink(dev_id, ev_port->id, NULL, 0);
+
+	if (rte_errno) {
+		DLB2_LOG_ERR("internal error: failed to unlink ev_port %d\n",
+			     ev_port->id);
+		return;
+	}
+
+	for (i = 0; i < dlb2->num_queues; i++) {
+		uint8_t qid, prio;
+		int ret;
+
+		if (dlb2_queue_is_empty(dlb2, &dlb2->ev_queues[i]))
+			continue;
+
+		qid = i;
+		prio = 0;
+
+		/* Link the ev_port to the queue */
+		ret = rte_event_port_link(dev_id, ev_port->id, &qid, &prio, 1);
+		if (ret != 1) {
+			DLB2_LOG_ERR("internal error: failed to link ev_port %d to queue %d\n",
+				     ev_port->id, qid);
+			return;
+		}
+
+		/* Flush the queue */
+		while (!dlb2_queue_is_empty(dlb2, &dlb2->ev_queues[i]))
+			dlb2_flush_port(dev, ev_port->id);
+
+		/* Drain any extant events in the ev_port. */
+		dlb2_flush_port(dev, ev_port->id);
+
+		/* Unlink the ev_port from the queue */
+		ret = rte_event_port_unlink(dev_id, ev_port->id, &qid, 1);
+		if (ret != 1) {
+			DLB2_LOG_ERR("internal error: failed to unlink ev_port %d to queue %d\n",
+				     ev_port->id, qid);
+			return;
+		}
+	}
+}
+
+static void
+dlb2_eventdev_stop(struct rte_eventdev *dev)
+{
+	struct dlb2_eventdev *dlb2 = dlb2_pmd_priv(dev);
+
+	rte_spinlock_lock(&dlb2->qm_instance.resource_lock);
+
+	if (dlb2->run_state == DLB2_RUN_STATE_STOPPED) {
+		DLB2_LOG_DBG("Internal error: already stopped\n");
+		rte_spinlock_unlock(&dlb2->qm_instance.resource_lock);
+		return;
+	} else if (dlb2->run_state != DLB2_RUN_STATE_STARTED) {
+		DLB2_LOG_ERR("Internal error: bad state %d for dev_stop\n",
+			     (int)dlb2->run_state);
+		rte_spinlock_unlock(&dlb2->qm_instance.resource_lock);
+		return;
+	}
+
+	dlb2->run_state = DLB2_RUN_STATE_STOPPING;
+
+	rte_spinlock_unlock(&dlb2->qm_instance.resource_lock);
+
+	dlb2_drain(dev);
+
+	dlb2->run_state = DLB2_RUN_STATE_STOPPED;
+}
+
+static int
+dlb2_eventdev_close(struct rte_eventdev *dev)
+{
+	dlb2_hw_reset_sched_domain(dev, false);
+
+	return 0;
+}
+
+static void
 dlb2_entry_points_init(struct rte_eventdev *dev)
 {
 	struct dlb2_eventdev *dlb2;
@@ -3425,6 +3648,8 @@ dlb2_entry_points_init(struct rte_eventdev *dev)
 		.dev_infos_get    = dlb2_eventdev_info_get,
 		.dev_configure    = dlb2_eventdev_configure,
 		.dev_start        = dlb2_eventdev_start,
+		.dev_stop         = dlb2_eventdev_stop,
+		.dev_close        = dlb2_eventdev_close,
 		.queue_def_conf   = dlb2_eventdev_queue_default_conf_get,
 		.queue_setup      = dlb2_eventdev_queue_setup,
 		.port_def_conf    = dlb2_eventdev_port_default_conf_get,
drivers/event/dlb2/dlb2_iface.c +6 -0
index a86191d..5471dd8 100644
@@ -66,3 +66,9 @@ int (*dlb2_iface_pending_port_unmaps)(struct dlb2_hw_dev *handle,
 
 int (*dlb2_iface_sched_domain_start)(struct dlb2_hw_dev *handle,
 				     struct dlb2_start_domain_args *cfg);
+
+int (*dlb2_iface_get_ldb_queue_depth)(struct dlb2_hw_dev *handle,
+				struct dlb2_get_ldb_queue_depth_args *args);
+
+int (*dlb2_iface_get_dir_queue_depth)(struct dlb2_hw_dev *handle,
+				struct dlb2_get_dir_queue_depth_args *args);
drivers/event/dlb2/dlb2_iface.h +6 -0
index d5bb6be..bcd9446 100644
@@ -66,4 +66,10 @@ extern int (*dlb2_iface_pending_port_unmaps)(struct dlb2_hw_dev *handle,
 extern int (*dlb2_iface_sched_domain_start)(struct dlb2_hw_dev *handle,
 				struct dlb2_start_domain_args *cfg);
 
+extern int (*dlb2_iface_get_ldb_queue_depth)(struct dlb2_hw_dev *handle,
+				struct dlb2_get_ldb_queue_depth_args *args);
+
+extern int (*dlb2_iface_get_dir_queue_depth)(struct dlb2_hw_dev *handle,
+				struct dlb2_get_dir_queue_depth_args *args);
+
 #endif /* _DLB2_IFACE_H_ */
drivers/event/dlb2/pf/base/dlb2_resource.c +91 -0

94 lines not on this page · raw message

drivers/event/dlb2/pf/dlb2_pf.c +52 -0

64 lines not on this page · raw message

Signature · 1 line
2.6.4
Reviewed-by on v2 17/22
#243 lore raw

Re: [dpdk-dev] [PATCH v2 17/22] event/dlb2: add eventdev stop and close

Quoted 10 lines

-----Original Message-----
From: McDaniel, Timothy <[email protected]>
Sent: Saturday, October 17, 2020 1:21 PM
Cc: [email protected]; Carrillo, Erik G <[email protected]>; Eads, Gage <[email protected]>; Van Haaren, Harry <[email protected]>; [email protected]
Subject: [PATCH v2 17/22] event/dlb2: add eventdev stop and close

Quoted 3 lines

Add support for eventdev stop and close entry points.

Thanks,
Gage

#244 lore raw

PATCH v2 18/22 event/dlb2: add PMD's token pop public interface

In reply to Timothy McDaniel

The PMD uses a public interface to allow applications to control the token pop mode. Supported token pop modes are as follows, and they impact core scheduling affinity for ldb ports.

AUTO_POP: Pop the CQ tokens immediately after dequeueing.
DELAYED_POP: Pop CQ tokens after (dequeue_depth - 1) events
are released. Supported on load-balanced ports only.
DEFERRED_POP: Pop the CQ tokens during next dequeue operation.

---
 doc/api/doxy-api-index.md                         |  1 +
 drivers/event/dlb2/dlb2.c                         | 53 ++++++++++++++++--
 drivers/event/dlb2/dlb2_priv.h                    |  3 +
 drivers/event/dlb2/meson.build                    |  5 +-
 drivers/event/dlb2/rte_pmd_dlb2.c                 | 39 +++++++++++++
 drivers/event/dlb2/rte_pmd_dlb2.h                 | 68 +++++++++++++++++++++++
 drivers/event/dlb2/rte_pmd_dlb2_event_version.map |  6 ++
 7 files changed, 168 insertions(+), 7 deletions(-)
 create mode 100644 drivers/event/dlb2/rte_pmd_dlb2.c
 create mode 100644 drivers/event/dlb2/rte_pmd_dlb2.h
doc/api/doxy-api-index.md +1 -0
index b855a8f..2b2020c 100644
@@ -26,6 +26,7 @@ The public API headers are grouped by topics:
   [event_eth_tx_adapter]   (@ref rte_event_eth_tx_adapter.h),
   [event_timer_adapter]    (@ref rte_event_timer_adapter.h),
   [event_crypto_adapter]   (@ref rte_event_crypto_adapter.h),
+  [dlb2]	       (@ref rte_pmd_dlb2.h)
   [rawdev]             (@ref rte_rawdev.h),
   [metrics]            (@ref rte_metrics.h),
   [bitrate]            (@ref rte_bitrate.h),
drivers/event/dlb2/dlb2.c +47 -6

136 lines not on this page · raw message

drivers/event/dlb2/dlb2_priv.h +3 -0
index 61567a6..b73cf3f 100644
@@ -12,6 +12,7 @@
 #include <rte_config.h>
 #include "dlb2_user.h"
 #include "dlb2_log.h"
+#include "rte_pmd_dlb2.h"
 
 #ifndef RTE_LIBRTE_PMD_DLB2_QUELL_STATS
 #define DLB2_INC_STAT(_stat, _incr_val) ((_stat) += _incr_val)
@@ -290,6 +291,7 @@ struct dlb2_port {
 	bool gen_bit;
 	uint16_t dir_credits;
 	uint32_t dequeue_depth;
+	enum dlb2_token_pop_mode token_pop_mode;
 	union dlb2_port_config cfg;
 	uint32_t *credit_pool[DLB2_NUM_QUEUE_TYPES]; /* use __atomic builtins */
 	uint16_t cached_ldb_credits;
@@ -298,6 +300,7 @@ struct dlb2_port {
 	bool int_armed;
 	uint16_t owed_tokens;
 	int16_t issued_releases;
+	int16_t token_pop_thresh;
 	int cq_depth;
 	uint16_t cq_idx;
 	uint16_t cq_idx_unmasked;
drivers/event/dlb2/meson.build +4 -1
index 6bf8adf..539773c 100644
@@ -1,3 +1,4 @@
+
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2019-2020 Intel Corporation
 
@@ -6,7 +7,9 @@ sources = files('dlb2.c',
 		'dlb2_xstats.c',
 		'pf/dlb2_main.c',
 		'pf/dlb2_pf.c',
-		'pf/base/dlb2_resource.c'
+		'pf/base/dlb2_resource.c',
+		'rte_pmd_dlb2.c'
 )
 
 deps += ['mbuf', 'mempool', 'ring', 'pci', 'bus_pci']
+install_headers('rte_pmd_dlb2.h')
drivers/event/dlb2/rte_pmd_dlb2.c new file +39 -0
new file mode 100644
index 0000000..b09b585
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Intel Corporation
+ */
+
+#include <rte_eventdev.h>
+#include <rte_eventdev_pmd.h>
+
+#include "rte_pmd_dlb2.h"
+#include "dlb2_priv.h"
+#include "dlb2_inline_fns.h"
+
+int
+rte_pmd_dlb2_set_token_pop_mode(uint8_t dev_id,
+				uint8_t port_id,
+				enum dlb2_token_pop_mode mode)
+{
+	struct dlb2_eventdev *dlb2;
+	struct rte_eventdev *dev;
+
+	RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
+	dev = &rte_eventdevs[dev_id];
+
+	dlb2 = dlb2_pmd_priv(dev);
+
+	if (mode >= NUM_TOKEN_POP_MODES)
+		return -EINVAL;
+
+	/* The event device must be configured, but not yet started */
+	if (!dlb2->configured || dlb2->run_state != DLB2_RUN_STATE_STOPPED)
+		return -EINVAL;
+
+	/* The token pop mode must be set before configuring the port */
+	if (port_id >= dlb2->num_ports || dlb2->ev_ports[port_id].setup_done)
+		return -EINVAL;
+
+	dlb2->ev_ports[port_id].qm_port.token_pop_mode = mode;
+
+	return 0;
+}
drivers/event/dlb2/rte_pmd_dlb2.h new file +68 -0

68 lines not on this page · raw message

drivers/event/dlb2/rte_pmd_dlb2_event_version.map +6 -0
index 299ae63..84b81a4 100644
@@ -1,3 +1,9 @@
 DPDK_21.0 {
 	local: *;
 };
+
+EXPERIMENTAL {
+	global:
+
+	rte_pmd_dlb2_set_token_pop_mode;
+};
Signature · 1 line
2.6.4
#245 lore raw

Re: [dpdk-dev] [PATCH v2 18/22] event/dlb2: add PMD's token pop public interface

Quoted 30 lines · Timothy McDaniel

The PMD uses a public interface to allow applications to control the token pop mode. Supported token pop modes are as follows, and they impact core scheduling affinity for ldb ports.

AUTO_POP: Pop the CQ tokens immediately after dequeueing.
DELAYED_POP: Pop CQ tokens after (dequeue_depth - 1) events
are released. Supported on load-balanced ports only.
DEFERRED_POP: Pop the CQ tokens during next dequeue operation.

---
 doc/api/doxy-api-index.md                         |  1 +
 drivers/event/dlb2/dlb2.c                         | 53 ++++++++++++++++--
 drivers/event/dlb2/dlb2_priv.h                    |  3 +
 drivers/event/dlb2/meson.build                    |  5 +-
 drivers/event/dlb2/rte_pmd_dlb2.c                 | 39 +++++++++++++
 drivers/event/dlb2/rte_pmd_dlb2.h                 | 68 +++++++++++++++++++++++
 drivers/event/dlb2/rte_pmd_dlb2_event_version.map |  6 ++
 7 files changed, 168 insertions(+), 7 deletions(-)
 create mode 100644 drivers/event/dlb2/rte_pmd_dlb2.c
 create mode 100644 drivers/event/dlb2/rte_pmd_dlb2.h
doc/api/doxy-api-index.md +0 -0
index b855a8f..2b2020c 100644

doc/api/doxy-api-index.md The public API headers are grouped by topics: · line 29

Quoted 4 lines
doc/api/doxy-api-index.md +1 -0
@@ -26,6 +26,7 @@ The public API headers are grouped by topics:
   [event_eth_tx_adapter]   (@ref rte_event_eth_tx_adapter.h),
   [event_timer_adapter]    (@ref rte_event_timer_adapter.h),
   [event_crypto_adapter]   (@ref rte_event_crypto_adapter.h),
+  [dlb2]              (@ref rte_pmd_dlb2.h)

move this under the already existing "- **device specific**:" section.

#246 lore raw

Re: [dpdk-dev] [PATCH v2 18/22] event/dlb2: add PMD's token pop public interface

Quoted 41 lines

-----Original Message-----
From: Jerin Jacob <[email protected]>
Sent: Sunday, October 18, 2020 4:14 AM
To: McDaniel, Timothy <[email protected]>
Cc: Mcnamara, John <[email protected]>; Kovacevic, Marko <[email protected]>; Ray Kinsella <[email protected]>; Neil Horman <[email protected]>; dpdk-dev <[email protected]>; Carrillo, Erik G <[email protected]>; Eads, Gage <[email protected]>; Van Haaren, Harry <[email protected]>; Jerin Jacob <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2 18/22] event/dlb2: add PMD's token pop public interface

Quoted 25 lines · Timothy McDaniel

The PMD uses a public interface to allow applications to control the token pop mode. Supported token pop modes are as follows, and they impact core scheduling affinity for ldb ports.

AUTO_POP: Pop the CQ tokens immediately after dequeueing.
DELAYED_POP: Pop CQ tokens after (dequeue_depth - 1) events
are released. Supported on load-balanced ports only.
DEFERRED_POP: Pop the CQ tokens during next dequeue operation.

---
 doc/api/doxy-api-index.md                         |  1 +
 drivers/event/dlb2/dlb2.c                         | 53 ++++++++++++++++--
 drivers/event/dlb2/dlb2_priv.h                    |  3 +
 drivers/event/dlb2/meson.build                    |  5 +-
 drivers/event/dlb2/rte_pmd_dlb2.c                 | 39 +++++++++++++
 drivers/event/dlb2/rte_pmd_dlb2.h                 | 68 +++++++++++++++++++++++
 drivers/event/dlb2/rte_pmd_dlb2_event_version.map |  6 ++
 7 files changed, 168 insertions(+), 7 deletions(-)
 create mode 100644 drivers/event/dlb2/rte_pmd_dlb2.c
 create mode 100644 drivers/event/dlb2/rte_pmd_dlb2.h
Quoted 11 lines

doc/api/doxy-api-index.md The public API headers are grouped by topics: · line 29

Quoted 9 lines
doc/api/doxy-api-index.md +1 -0
index b855a8f..2b2020c 100644
@@ -26,6 +26,7 @@ The public API headers are grouped by topics:
   [event_eth_tx_adapter]   (@ref rte_event_eth_tx_adapter.h),
   [event_timer_adapter]    (@ref rte_event_timer_adapter.h),
   [event_crypto_adapter]   (@ref rte_event_crypto_adapter.h),
+  [dlb2]              (@ref rte_pmd_dlb2.h)

move this under the already existing "- **device specific**:" section.

okay, will do.

#247 lore raw

Re: [dpdk-dev] [PATCH v2 18/22] event/dlb2: add PMD's token pop public interface

In reply to Timothy McDaniel
Quoted 316 lines · Timothy McDaniel

The PMD uses a public interface to allow applications to control the token pop mode. Supported token pop modes are as follows, and they impact core scheduling affinity for ldb ports.

AUTO_POP: Pop the CQ tokens immediately after dequeueing.
DELAYED_POP: Pop CQ tokens after (dequeue_depth - 1) events
are released. Supported on load-balanced ports only.
DEFERRED_POP: Pop the CQ tokens during next dequeue operation.

---
 doc/api/doxy-api-index.md                         |  1 +
 drivers/event/dlb2/dlb2.c                         | 53 ++++++++++++++++--
 drivers/event/dlb2/dlb2_priv.h                    |  3 +
 drivers/event/dlb2/meson.build                    |  5 +-
 drivers/event/dlb2/rte_pmd_dlb2.c                 | 39 +++++++++++++
 drivers/event/dlb2/rte_pmd_dlb2.h                 | 68 +++++++++++++++++++++++
 drivers/event/dlb2/rte_pmd_dlb2_event_version.map |  6 ++
 7 files changed, 168 insertions(+), 7 deletions(-)
 create mode 100644 drivers/event/dlb2/rte_pmd_dlb2.c
 create mode 100644 drivers/event/dlb2/rte_pmd_dlb2.h
doc/api/doxy-api-index.md +1 -0
index b855a8f..2b2020c 100644
@@ -26,6 +26,7 @@ The public API headers are grouped by topics:
   [event_eth_tx_adapter]   (@ref rte_event_eth_tx_adapter.h),
   [event_timer_adapter]    (@ref rte_event_timer_adapter.h),
   [event_crypto_adapter]   (@ref rte_event_crypto_adapter.h),
+  [dlb2]	       (@ref rte_pmd_dlb2.h)
   [rawdev]             (@ref rte_rawdev.h),
   [metrics]            (@ref rte_metrics.h),
   [bitrate]            (@ref rte_bitrate.h),
drivers/event/dlb2/dlb2.c +47 -6
index 483659e..9a41418 100644
@@ -1200,7 +1200,7 @@ dlb2_hw_create_ldb_port(struct dlb2_eventdev *dlb2,
 	qm_port->qid_mappings = &dlb2->qm_ldb_to_ev_queue_id[0];
 
 	qm_port->dequeue_depth = dequeue_depth;
-
+	qm_port->token_pop_thresh = dequeue_depth;
 	qm_port->owed_tokens = 0;
 	qm_port->issued_releases = 0;
 
@@ -1368,6 +1368,8 @@ dlb2_hw_create_dir_port(struct dlb2_eventdev *dlb2,
 
 	qm_port->dequeue_depth = dequeue_depth;
 
+	/* Directed ports are auto-pop, by default. */
+	qm_port->token_pop_mode = AUTO_POP;
 	qm_port->owed_tokens = 0;
 	qm_port->issued_releases = 0;
 
@@ -2615,6 +2617,14 @@ dlb2_event_enqueue_burst(void *event_port,
 		dlb2_event_build_hcws(qm_port, &events[i], j,
 				      sched_types, queue_ids);
 
+		if (qm_port->token_pop_mode == DELAYED_POP && j < 4 &&
+		    qm_port->issued_releases >= qm_port->token_pop_thresh - 1) {
+			dlb2_construct_token_pop_qe(qm_port, j);
+
+			/* Reset the releases counter for the next QE batch */
+			qm_port->issued_releases -= qm_port->token_pop_thresh;
+		}
+
 		dlb2_hw_do_enqueue(qm_port, i == 0, port_data);
 
 		cnt += j;
@@ -2623,6 +2633,11 @@ dlb2_event_enqueue_burst(void *event_port,
 			break;
 	}
 
+	if (qm_port->token_pop_mode == DELAYED_POP &&
+	    qm_port->issued_releases >= qm_port->token_pop_thresh - 1) {
+		dlb2_consume_qe_immediate(qm_port, qm_port->owed_tokens);
+		qm_port->issued_releases -= qm_port->token_pop_thresh;
+	}
 	return cnt;
 }
 
@@ -3105,11 +3120,25 @@ dlb2_event_release(struct dlb2_eventdev *dlb2,
 		if (j == 0)
 			break;
 
+		if (qm_port->token_pop_mode == DELAYED_POP && j < 4 &&
+		    qm_port->issued_releases >= qm_port->token_pop_thresh - 1) {
+			dlb2_construct_token_pop_qe(qm_port, j);
+
+			/* Reset the releases counter for the next QE batch */
+			qm_port->issued_releases -= qm_port->token_pop_thresh;
+		}
+
 		dlb2_hw_do_enqueue(qm_port, i == 0, port_data);
 
 		cnt += j;
 	}
 
+	if (qm_port->token_pop_mode == DELAYED_POP &&
+	    qm_port->issued_releases >= qm_port->token_pop_thresh - 1) {
+		dlb2_consume_qe_immediate(qm_port, qm_port->owed_tokens);
+		qm_port->issued_releases -= qm_port->token_pop_thresh;
+	}
+
 sw_credit_update:
 	/* each release returns one credit */
 	if (!ev_port->outstanding_releases) {
@@ -3193,8 +3222,8 @@ dlb2_hw_dequeue_sparse(struct dlb2_eventdev *dlb2,
 	qm_port->owed_tokens += num;
 
 	if (num) {
-
-		dlb2_consume_qe_immediate(qm_port, num);
+		if (qm_port->token_pop_mode == AUTO_POP)
+			dlb2_consume_qe_immediate(qm_port, num);
 
 		ev_port->outstanding_releases += num;
 
@@ -3320,8 +3349,8 @@ dlb2_hw_dequeue(struct dlb2_eventdev *dlb2,
 	qm_port->owed_tokens += num;
 
 	if (num) {
-
-		dlb2_consume_qe_immediate(qm_port, num);
+		if (qm_port->token_pop_mode == AUTO_POP)
+			dlb2_consume_qe_immediate(qm_port, num);
 
 		ev_port->outstanding_releases += num;
 
@@ -3336,6 +3365,7 @@ dlb2_event_dequeue_burst(void *event_port, struct rte_event *ev, uint16_t num,
 			 uint64_t wait)
 {
 	struct dlb2_eventdev_port *ev_port = event_port;
+	struct dlb2_port *qm_port = &ev_port->qm_port;
 	struct dlb2_eventdev *dlb2 = ev_port->dlb2;
 	uint16_t cnt;
 
@@ -3351,6 +3381,9 @@ dlb2_event_dequeue_burst(void *event_port, struct rte_event *ev, uint16_t num,
 		DLB2_INC_STAT(ev_port->stats.tx_implicit_rel, out_rels);
 	}
 
+	if (qm_port->token_pop_mode == DEFERRED_POP && qm_port->owed_tokens)
+		dlb2_consume_qe_immediate(qm_port, qm_port->owed_tokens);
+
 	cnt = dlb2_hw_dequeue(dlb2, ev_port, ev, num, wait);
 
 	DLB2_INC_STAT(ev_port->stats.traffic.total_polls, 1);
@@ -3370,6 +3403,7 @@ dlb2_event_dequeue_burst_sparse(void *event_port, struct rte_event *ev,
 				uint16_t num, uint64_t wait)
 {
 	struct dlb2_eventdev_port *ev_port = event_port;
+	struct dlb2_port *qm_port = &ev_port->qm_port;
 	struct dlb2_eventdev *dlb2 = ev_port->dlb2;
 	uint16_t cnt;
 
@@ -3385,6 +3419,9 @@ dlb2_event_dequeue_burst_sparse(void *event_port, struct rte_event *ev,
 		DLB2_INC_STAT(ev_port->stats.tx_implicit_rel, out_rels);
 	}
 
+	if (qm_port->token_pop_mode == DEFERRED_POP && qm_port->owed_tokens)
+		dlb2_consume_qe_immediate(qm_port, qm_port->owed_tokens);
+
 	cnt = dlb2_hw_dequeue_sparse(dlb2, ev_port, ev, num, wait);
 
 	DLB2_INC_STAT(ev_port->stats.traffic.total_polls, 1);
@@ -3689,7 +3726,7 @@ dlb2_primary_eventdev_probe(struct rte_eventdev *dev,
 			    struct dlb2_devargs *dlb2_args)
 {
 	struct dlb2_eventdev *dlb2;
-	int err;
+	int err, i;
 
 	dlb2 = dev->data->dev_private;
 
@@ -3739,6 +3776,10 @@ dlb2_primary_eventdev_probe(struct rte_eventdev *dev,
 		return err;
 	}
 
+	/* Initialize each port's token pop mode */
+	for (i = 0; i < DLB2_MAX_NUM_PORTS; i++)
+		dlb2->ev_ports[i].qm_port.token_pop_mode = AUTO_POP;
+
 	rte_spinlock_init(&dlb2->qm_instance.resource_lock);
 
 	dlb2_iface_low_level_io_init();
drivers/event/dlb2/dlb2_priv.h +3 -0
index 61567a6..b73cf3f 100644
@@ -12,6 +12,7 @@
 #include <rte_config.h>
 #include "dlb2_user.h"
 #include "dlb2_log.h"
+#include "rte_pmd_dlb2.h"
 
 #ifndef RTE_LIBRTE_PMD_DLB2_QUELL_STATS
 #define DLB2_INC_STAT(_stat, _incr_val) ((_stat) += _incr_val)
@@ -290,6 +291,7 @@ struct dlb2_port {
 	bool gen_bit;
 	uint16_t dir_credits;
 	uint32_t dequeue_depth;
+	enum dlb2_token_pop_mode token_pop_mode;
 	union dlb2_port_config cfg;
 	uint32_t *credit_pool[DLB2_NUM_QUEUE_TYPES]; /* use __atomic builtins */
 	uint16_t cached_ldb_credits;
@@ -298,6 +300,7 @@ struct dlb2_port {
 	bool int_armed;
 	uint16_t owed_tokens;
 	int16_t issued_releases;
+	int16_t token_pop_thresh;
 	int cq_depth;
 	uint16_t cq_idx;
 	uint16_t cq_idx_unmasked;
drivers/event/dlb2/meson.build +4 -1
index 6bf8adf..539773c 100644
@@ -1,3 +1,4 @@
+
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2019-2020 Intel Corporation
 
@@ -6,7 +7,9 @@ sources = files('dlb2.c',
 		'dlb2_xstats.c',
 		'pf/dlb2_main.c',
 		'pf/dlb2_pf.c',
-		'pf/base/dlb2_resource.c'
+		'pf/base/dlb2_resource.c',
+		'rte_pmd_dlb2.c'
 )
 
 deps += ['mbuf', 'mempool', 'ring', 'pci', 'bus_pci']
+install_headers('rte_pmd_dlb2.h')
drivers/event/dlb2/rte_pmd_dlb2.c new file +39 -0
new file mode 100644
index 0000000..b09b585
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Intel Corporation
+ */
+
+#include <rte_eventdev.h>
+#include <rte_eventdev_pmd.h>
+
+#include "rte_pmd_dlb2.h"
+#include "dlb2_priv.h"
+#include "dlb2_inline_fns.h"
+
+int
+rte_pmd_dlb2_set_token_pop_mode(uint8_t dev_id,
+				uint8_t port_id,
+				enum dlb2_token_pop_mode mode)
+{
+	struct dlb2_eventdev *dlb2;
+	struct rte_eventdev *dev;
+
+	RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
+	dev = &rte_eventdevs[dev_id];
+
+	dlb2 = dlb2_pmd_priv(dev);
+
+	if (mode >= NUM_TOKEN_POP_MODES)
+		return -EINVAL;
+
+	/* The event device must be configured, but not yet started */
+	if (!dlb2->configured || dlb2->run_state != DLB2_RUN_STATE_STOPPED)
+		return -EINVAL;
+
+	/* The token pop mode must be set before configuring the port */
+	if (port_id >= dlb2->num_ports || dlb2->ev_ports[port_id].setup_done)
+		return -EINVAL;
+
+	dlb2->ev_ports[port_id].qm_port.token_pop_mode = mode;
+
+	return 0;
+}
drivers/event/dlb2/rte_pmd_dlb2.h new file +28 -0
new file mode 100644
index 0000000..489693f
@@ -0,0 +1,68 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Intel Corporation
+ */
+
+/*!
+ *  @file      rte_pmd_dlb2.h
+ *
+ *  @brief     DLB PMD-specific functions
+ *
+ *  @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ */
+
+#ifndef _RTE_PMD_DLB2_H_
+#define _RTE_PMD_DLB2_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+
+/**
+ * Selects the token pop mode for a DLB2 port.
+ */
+enum dlb2_token_pop_mode {
+	/* Pop the CQ tokens immediately after dequeueing. */
+	AUTO_POP,
+	/* Pop CQ tokens after (dequeue_depth - 1) events are released.

drivers/event/dlb2/rte_pmd_dlb2.h line 38

Quoted 10 lines
drivers/event/dlb2/rte_pmd_dlb2.h new file +10 -0
+	 * Supported on load-balanced ports only.
+	 */
+	DELAYED_POP,
+	/* Pop the CQ tokens during next dequeue operation. */
+	DEFERRED_POP,
+
+	/* NUM_TOKEN_POP_MODES must be last */
+	NUM_TOKEN_POP_MODES
+};
+

Missing the banner.

+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice

Quoted 45 lines
drivers/event/dlb2/rte_pmd_dlb2.h new file +30 -0
+/*!
+ * Configure the token pop mode for a DLB2 port. By default, all ports use
+ * AUTO_POP. This function must be called before calling rte_event_port_setup()
+ * for the port, but after calling rte_event_dev_configure().
+ *
+ * @param dev_id
+ *    The identifier of the event device.
+ * @param port_id
+ *    The identifier of the event port.
+ * @param mode
+ *    The token pop mode.
+ *
+ * @return
+ * - 0: Success
+ * - EINVAL: Invalid dev_id, port_id, or mode
+ * - EINVAL: The DLB2 is not configured, is already running, or the port is
+ *   already setup
+ */
+
+__rte_experimental
+int
+rte_pmd_dlb2_set_token_pop_mode(uint8_t dev_id,
+				uint8_t port_id,
+				enum dlb2_token_pop_mode mode);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTE_PMD_DLB2_H_ */
drivers/event/dlb2/rte_pmd_dlb2_event_version.map +6 -0
index 299ae63..84b81a4 100644
@@ -1,3 +1,9 @@
 DPDK_21.0 {
 	local: *;
 };
+
+EXPERIMENTAL {
+	global:
+
+	rte_pmd_dlb2_set_token_pop_mode;
+};
Reviewed-by on v2 18/22
#248 lore raw

Re: [dpdk-dev] [PATCH v2 18/22] event/dlb2: add PMD's token pop public interface

In reply to Timothy McDaniel
Quoted 18 lines

-----Original Message-----
From: McDaniel, Timothy <[email protected]>
Sent: Saturday, October 17, 2020 1:21 PM
To: Mcnamara, John <[email protected]>; Kovacevic, Marko <[email protected]>; Ray Kinsella <[email protected]>; Neil Horman <[email protected]>
Cc: [email protected]; Carrillo, Erik G <[email protected]>; Eads, Gage <[email protected]>; Van Haaren, Harry <[email protected]>; [email protected]
Subject: [PATCH v2 18/22] event/dlb2: add PMD's token pop public interface

The PMD uses a public interface to allow applications to control the token pop mode. Supported token pop modes are as follows, and they impact core scheduling affinity for ldb ports.

Quoted 7 lines

AUTO_POP: Pop the CQ tokens immediately after dequeueing.
DELAYED_POP: Pop CQ tokens after (dequeue_depth - 1) events
are released. Supported on load-balanced ports only.
DEFERRED_POP: Pop the CQ tokens during next dequeue operation.

With Jerin and Ray's issues addressed:

Thanks,
Gage

#249 lore raw

PATCH v2 19/22 event/dlb2: add PMD self-tests

In reply to Timothy McDaniel

Add a variety of self-tests for both ldb and directed ports/queues, as well as configure, start, stop, link, etc...

---
 app/test/test_eventdev.c           |    7 +
 drivers/event/dlb2/dlb2.c          |    1 +
 drivers/event/dlb2/dlb2_selftest.c | 1570 ++++++++++++++++++++++++++++++++++++
 drivers/event/dlb2/meson.build     |    3 +-
 4 files changed, 1580 insertions(+), 1 deletion(-)
 create mode 100644 drivers/event/dlb2/dlb2_selftest.c
app/test/test_eventdev.c +7 -0
index 62019c1..bcfaa53 100644
@@ -1030,6 +1030,12 @@ test_eventdev_selftest_dpaa2(void)
 	return test_eventdev_selftest_impl("event_dpaa2", "");
 }
 
+static int
+test_eventdev_selftest_dlb2(void)
+{
+	return test_eventdev_selftest_impl("dlb2_event", "");
+}
+
 REGISTER_TEST_COMMAND(eventdev_common_autotest, test_eventdev_common);
 REGISTER_TEST_COMMAND(eventdev_selftest_sw, test_eventdev_selftest_sw);
 REGISTER_TEST_COMMAND(eventdev_selftest_octeontx,
@@ -1037,3 +1043,4 @@ REGISTER_TEST_COMMAND(eventdev_selftest_octeontx,
 REGISTER_TEST_COMMAND(eventdev_selftest_octeontx2,
 		test_eventdev_selftest_octeontx2);
 REGISTER_TEST_COMMAND(eventdev_selftest_dpaa2, test_eventdev_selftest_dpaa2);
+REGISTER_TEST_COMMAND(eventdev_selftest_dlb2, test_eventdev_selftest_dlb2);
drivers/event/dlb2/dlb2.c +1 -0
index 9a41418..06a59a5 100644
@@ -3700,6 +3700,7 @@ dlb2_entry_points_init(struct rte_eventdev *dev)
 		.xstats_get_names = dlb2_eventdev_xstats_get_names,
 		.xstats_get_by_name = dlb2_eventdev_xstats_get_by_name,
 		.xstats_reset	    = dlb2_eventdev_xstats_reset,
+		.dev_selftest     = test_dlb2_eventdev,
 	};
 
 	/* Expose PMD's eventdev interface */
drivers/event/dlb2/dlb2_selftest.c new file +1570 -0

1,570 lines not on this page · raw message

drivers/event/dlb2/meson.build +2 -1
index 539773c..fe0065c 100644
@@ -8,7 +8,8 @@ sources = files('dlb2.c',
 		'pf/dlb2_main.c',
 		'pf/dlb2_pf.c',
 		'pf/base/dlb2_resource.c',
-		'rte_pmd_dlb2.c'
+		'rte_pmd_dlb2.c',
+		'dlb2_selftest.c'
 )
 
 deps += ['mbuf', 'mempool', 'ring', 'pci', 'bus_pci']
Signature · 1 line
2.6.4
#250 lore raw

PATCH v2 20/22 event/dlb2: add queue and port release

In reply to Timothy McDaniel

DLB does not support reconfiguring individual queues or ports on the fly. The entire device must be reconfigured. Previously allocated port QE ond memzone memory
is freed in this patch.

---
 drivers/event/dlb2/dlb2.c | 28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)
drivers/event/dlb2/dlb2.c +26 -2
index 06a59a5..968923e 100644
@@ -89,8 +89,8 @@ dlb2_free_qe_mem(struct dlb2_port *qm_port)
 	rte_free(qm_port->consume_qe);
 	qm_port->consume_qe = NULL;
 
-	rte_free(dlb2_port[qm_port->id][PORT_TYPE(qm_port)].cq_base);
-	rte_free(dlb2_port[qm_port->id][PORT_TYPE(qm_port)].pp_addr);
+	rte_memzone_free(dlb2_port[qm_port->id][PORT_TYPE(qm_port)].mz);
+	dlb2_port[qm_port->id][PORT_TYPE(qm_port)].mz = NULL;
 }
 
 /* override defaults with value(s) provided on command line */
@@ -3676,6 +3676,28 @@ dlb2_eventdev_close(struct rte_eventdev *dev)
 }
 
 static void
+dlb2_eventdev_queue_release(struct rte_eventdev *dev, uint8_t id)
+{
+	RTE_SET_USED(dev);
+	RTE_SET_USED(id);
+
+	/* This function intentionally left blank. */
+}
+
+static void
+dlb2_eventdev_port_release(void *port)
+{
+	struct dlb2_eventdev_port *ev_port = port;
+	struct dlb2_port *qm_port;
+
+	if (ev_port) {
+		qm_port = &ev_port->qm_port;
+		if (qm_port->config_state == DLB2_CONFIGURED)
+			dlb2_free_qe_mem(qm_port);
+	}
+}
+
+static void
 dlb2_entry_points_init(struct rte_eventdev *dev)
 {
 	struct dlb2_eventdev *dlb2;
@@ -3689,8 +3711,10 @@ dlb2_entry_points_init(struct rte_eventdev *dev)
 		.dev_close        = dlb2_eventdev_close,
 		.queue_def_conf   = dlb2_eventdev_queue_default_conf_get,
 		.queue_setup      = dlb2_eventdev_queue_setup,
+		.queue_release    = dlb2_eventdev_queue_release,
 		.port_def_conf    = dlb2_eventdev_port_default_conf_get,
 		.port_setup       = dlb2_eventdev_port_setup,
+		.port_release     = dlb2_eventdev_port_release,
 		.port_link        = dlb2_eventdev_port_link,
 		.port_unlink      = dlb2_eventdev_port_unlink,
 		.port_unlinks_in_progress =
Signature · 1 line
2.6.4
Reviewed-by on v2 20/22
#251 lore raw

Re: [dpdk-dev] [PATCH v2 20/22] event/dlb2: add queue and port release

Quoted 25 lines

-----Original Message-----
From: McDaniel, Timothy <[email protected]>
Sent: Saturday, October 17, 2020 1:21 PM
Cc: [email protected]; Carrillo, Erik G <[email protected]>; Eads, Gage <[email protected]>; Van Haaren, Harry <[email protected]>; [email protected]
Subject: [PATCH v2 20/22] event/dlb2: add queue and port release

DLB does not support reconfiguring individual queues or ports on the fly. The entire device must be reconfigured. Previously allocated port QE ond memzone memory
is freed in this patch.

---
 drivers/event/dlb2/dlb2.c | 28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)
drivers/event/dlb2/dlb2.c +0 -0
index 06a59a5..968923e 100644

drivers/event/dlb2/dlb2.c dlb2_free_qe_mem(struct dlb2_port *qm_port) · line 95

Quoted 9 lines
drivers/event/dlb2/dlb2.c +2 -2
@@ -89,8 +89,8 @@ dlb2_free_qe_mem(struct dlb2_port *qm_port)
 	rte_free(qm_port->consume_qe);
 	qm_port->consume_qe = NULL;
 
-	rte_free(dlb2_port[qm_port->id][PORT_TYPE(qm_port)].cq_base);
-	rte_free(dlb2_port[qm_port->id][PORT_TYPE(qm_port)].pp_addr);
+	rte_memzone_free(dlb2_port[qm_port-
 >id][PORT_TYPE(qm_port)].mz);
+	dlb2_port[qm_port->id][PORT_TYPE(qm_port)].mz = NULL;
 }

This code should be a part of patch 8, when free_qe_mem is introduced. With that change:

Thanks,
Gage

#252 lore raw

PATCH v2 21/22 event/dlb2: add timeout ticks entry point

In reply to Timothy McDaniel

Adds the timeout ticks conversion function.

---
 drivers/event/dlb2/dlb2.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/event/dlb2/dlb2.c +13 -0
index 968923e..48879a1 100644
@@ -3697,6 +3697,18 @@ dlb2_eventdev_port_release(void *port)
 	}
 }
 
+static int
+dlb2_eventdev_timeout_ticks(struct rte_eventdev *dev, uint64_t ns,
+			    uint64_t *timeout_ticks)
+{
+	RTE_SET_USED(dev);
+	uint64_t cycles_per_ns = rte_get_timer_hz() / 1E9;
+
+	*timeout_ticks = ns * cycles_per_ns;
+
+	return 0;
+}
+
 static void
 dlb2_entry_points_init(struct rte_eventdev *dev)
 {
@@ -3719,6 +3731,7 @@ dlb2_entry_points_init(struct rte_eventdev *dev)
 		.port_unlink      = dlb2_eventdev_port_unlink,
 		.port_unlinks_in_progress =
 				    dlb2_eventdev_port_unlinks_in_progress,
+		.timeout_ticks    = dlb2_eventdev_timeout_ticks,
 		.dump             = dlb2_eventdev_dump,
 		.xstats_get       = dlb2_eventdev_xstats_get,
 		.xstats_get_names = dlb2_eventdev_xstats_get_names,
Signature · 1 line
2.6.4
#253 lore raw

PATCH v2 22/22 doc: add new DLB2 eventdev driver to relnotes

In reply to Timothy McDaniel

Added announcement of availabililty for the new driver for Intel Dynamic Load Balancer 2.0 hardware.

---
 MAINTAINERS                            | 5 +++++
 doc/guides/rel_notes/release_20_11.rst | 5 +++++
 2 files changed, 10 insertions(+)
MAINTAINERS +5 -0
index 3b16d7a..f732f28 100644
@@ -1188,6 +1188,11 @@ M: Peter Mccarthy <[email protected]>
 F: drivers/event/opdl/
 F: doc/guides/eventdevs/opdl.rst
 
+Intel DLB2 Eventdev PMD
+M: Timothy McDaniel <[email protected]>
+F: drivers/event/dlb2/
+F: doc/guides/eventdevs/dlb2.rst
+
 
 Rawdev Drivers
 --------------
doc/guides/rel_notes/release_20_11.rst +5 -0
index df227a1..f80df21 100644
@@ -55,6 +55,11 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Added a new driver for the Intel Dynamic Load Balancer v2.0 device.**
+
+  Added the new ``dlb2`` eventdev driver for the Intel DLB V2.0 device. See the
+  :doc:`../eventdevs/dlb2` eventdev guide for more details on this new driver.
+
 
 Removed Items
 -------------
Signature · 1 line
2.6.4
#254 lore raw

Re: [dpdk-dev] [PATCH v2 22/22] doc: add new DLB2 eventdev driver to relnotes

Quoted 15 lines · Timothy McDaniel

Added announcement of availabililty for the new driver for Intel Dynamic Load Balancer 2.0 hardware.

---
 MAINTAINERS                            | 5 +++++
 doc/guides/rel_notes/release_20_11.rst | 5 +++++
 2 files changed, 10 insertions(+)
MAINTAINERS +0 -0
index 3b16d7a..f732f28 100644

MAINTAINERS M: Peter Mccarthy <[email protected]> · line 1194

Quoted 7 lines
MAINTAINERS +4 -0
@@ -1188,6 +1188,11 @@ M: Peter Mccarthy <[email protected]>
 F: drivers/event/opdl/
 F: doc/guides/eventdevs/opdl.rst
 
+Intel DLB2 Eventdev PMD
+M: Timothy McDaniel <[email protected]>
+F: drivers/event/dlb2/
+F: doc/guides/eventdevs/dlb2.rst

Move this section to the first patch.

Quoted 8 lines
MAINTAINERS +0 -0
 Rawdev Drivers
 --------------
doc/guides/rel_notes/release_20_11.rst +0 -0
index df227a1..f80df21 100644

doc/guides/rel_notes/release_20_11.rst New Features · line 61

Quoted 7 lines
doc/guides/rel_notes/release_20_11.rst +4 -0
@@ -55,6 +55,11 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Added a new driver for the Intel Dynamic Load Balancer v2.0 device.**
+
+  Added the new ``dlb2`` eventdev driver for the Intel DLB V2.0 device. See the
+  :doc:`../eventdevs/dlb2` eventdev guide for more details on this new driver.

This specific patch is not required. Move this section to the last patch in this series.

Also, fix the following checkpatch issues in this series.

WARNING:REPEATED_WORD: Possible repeated word: 'from'
#155: FILE: drivers/event/dlb2/dlb2_user.h:132:
+ * - num_ldb_ports: Number of load-balanced ports that can be allocated from
+ * from any class-of-service with available ports.

WARNING:REPEATED_WORD: Possible repeated word: 'are'
#969: FILE: drivers/event/dlb2/pf/base/dlb2_hw_types.h:321:
+ * -- A domain's used resources list. These are are domain-owned configured

### event/dlb2: add queue and port release

WARNING:TYPO_SPELLING: 'ond' may be misspelled - perhaps 'one'? #8:
Previously allocated port QE ond memzone memory

Quoted 7 lines
doc/guides/rel_notes/release_20_11.rst +1 -1
+
 
 Removed Items
 -------------
--

2.6.4

#255 lore raw

Re: [dpdk-dev] [PATCH v2 22/22] doc: add new DLB2 eventdev driver to relnotes

Quoted 34 lines

-----Original Message-----
From: Jerin Jacob <[email protected]>
Sent: Sunday, October 18, 2020 4:23 AM
To: McDaniel, Timothy <[email protected]>
Cc: Thomas Monjalon <[email protected]>; Mcnamara, John <[email protected]>; Kovacevic, Marko <[email protected]>; dpdk-dev <[email protected]>; Carrillo, Erik G <[email protected]>; Eads, Gage <[email protected]>; Van Haaren, Harry <[email protected]>; Jerin Jacob <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2 22/22] doc: add new DLB2 eventdev driver to relnotes

Quoted 18 lines · Timothy McDaniel

Added announcement of availabililty for the new driver for Intel Dynamic Load Balancer 2.0 hardware.

---
 MAINTAINERS                            | 5 +++++
 doc/guides/rel_notes/release_20_11.rst | 5 +++++
 2 files changed, 10 insertions(+)
MAINTAINERS +0 -0
index 3b16d7a..f732f28 100644
@@ -1188,6 +1188,11 @@ M: Peter Mccarthy <[email protected]>
 F: drivers/event/opdl/
 F: doc/guides/eventdevs/opdl.rst
 
Quoted 8 lines

MAINTAINERS M: Peter Mccarthy <[email protected]> · line 1194

Quoted 4 lines
MAINTAINERS +4 -0
+Intel DLB2 Eventdev PMD
+M: Timothy McDaniel <[email protected]>
+F: drivers/event/dlb2/
+F: doc/guides/eventdevs/dlb2.rst

Move this section to the first patch.

Will do

Quoted 22 lines

Review

Quoted 5 lines
MAINTAINERS +0 -0
 Rawdev Drivers
 --------------
(quoted diff) +0 -0

b/doc/guides/rel_notes/release_20_11.rst

doc/guides/rel_notes/release_20_11.rst New Features · line 61

Quoted 11 lines

index df227a1..f80df21 100644

doc/guides/rel_notes/release_20_11.rst +4 -0
@@ -55,6 +55,11 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Added a new driver for the Intel Dynamic Load Balancer v2.0 device.**
+
+  Added the new ``dlb2`` eventdev driver for the Intel DLB V2.0 device. See the
+  :doc:`../eventdevs/dlb2` eventdev guide for more details on this new driver.

This specific patch is not required. Move this section to the last patch in this series.

Quoted 2 lines

Also, fix the following checkpatch issues in this series.

sure, will do

Quoted 24 lines

WARNING:REPEATED_WORD: Possible repeated word: 'from'
#155: FILE: drivers/event/dlb2/dlb2_user.h:132:
+ * - num_ldb_ports: Number of load-balanced ports that can be allocated from
+ * from any class-of-service with available ports.

WARNING:REPEATED_WORD: Possible repeated word: 'are'
#969: FILE: drivers/event/dlb2/pf/base/dlb2_hw_types.h:321:
+ * -- A domain's used resources list. These are are domain-owned configured

### event/dlb2: add queue and port release

WARNING:TYPO_SPELLING: 'ond' may be misspelled - perhaps 'one'? #8:
Previously allocated port QE ond memzone memory

Quoted 7 lines
doc/guides/rel_notes/release_20_11.rst +1 -1
+
 
 Removed Items
 -------------
--

2.6.4

#256 lore raw
In reply to Timothy McDaniel

17/10/2020 20:20, Timothy McDaniel:

Quoted 3 lines

Note that the DLB2 hardware is a successor of the DLB hardware, and as such is structured similarly, both in terms of code layout and implementation.

That's quite funny that you are unable to have a single driver for both similar hardware. I guess that's the Intel way.

#257 lore raw

v3 cover Add DLB2 PMD

In reply to Timothy McDaniel

The following patch series adds support for a new eventdev PMD. The DLB2 PMD adds support for the Intel Dynamic Load Balancer 2.0 (DLB2) hardware.
The DLB2 is a PCIe device that provides load-balanced, prioritized scheduling of core-to-core communication. The device consists of queues and arbiters that connect producer and consumer cores, and implements load-balanced queueing features including:
- Lock-free multi-producer/multi-consumer operation.
- Multiple priority levels for varying traffic types.
- 'Direct' traffic (i.e. multi-producer/single-consumer)
- Simple unordered load-balanced distribution.
- Atomic lock-free load balancing across multiple consumers.
- Queue element reordering feature allowing ordered load-balanced distribution.

The DLB2 hardware supports both load balanced and directed ports and queues. Unlike other eventdev devices already in the repo, not all DLB2 ports and queues are equally capable. In particular, directed ports are limited to a single link, and must be connected to a directed queue. Additionally, even though LDB ports may link multiple queues,
the number of queues that may be linked is limited by hardware.

While reviewing the code, please be aware that this PMD has full control over the DLB2 hardware. Intel will be extending the DLB2 PMD in the future (not as part of this first series) with a mode that we refer to as the bifurcated PMD. The bifurcated PMD communicates with a kernel driver to configure the device, ports, and queues, and memory maps device MMIO so datapath operations occur purely in user-space. Note that the DLB2 hardware is a successor of the DLB hardware, and as such is structured similarly, both in terms of code layout and implementation.

The framework to support both the PF PMD and bifurcated PMD exists in this patchset, and is why the iface.[ch] layer is present.

Changes since V2:
================
- fixed meson conditional build. Moved test into driver’s meson.build file instead of event/meson.build
- documentation is populated as associated code is introduced
- add log_register in add dynamic logging patch
- rename RTE_xxx symbol(s) as DLB2_xxx
- replaced function ptr enqueue_four with direct call to movdir64b
- remove unused port_pages
- broke up probe patch into 3 smaller patches for easier review
- changed param order of movdir64b/movntdq to match intrinsics
- added self to MAINTAINERS files
- squashed announcement of availability into last patch in series
- correct spelling errors and delete repeated words
- DPDK_21.0 -> DPDK 21 in map file
- add experimental banner to public structs and APIs

Changes since V1:
=================
- implement changes requested in code reviews by Gage Eads and Mike Chen
- fix a memzone leak
- convert to use eal rte-cpuflags patch from Liang Ma

Known Issues:
- the documentation contained in dlb2.rst is not complete, and should be updated to include command line parameters (class of service,

	etc ...).

Depends-on: patch-79539 ("eal: add new x86 cpuid support for WAITPKG")

Timothy McDaniel (23):
event/dlb2: add documentation and meson build infrastructure event/dlb2: add dynamic logging
event/dlb2: add private data structures and constants event/dlb2: add definitions shared with LKM or shared code event/dlb2: add inline functions
event/dlb2: add eventdev probe
event/dlb2: add flexible interface
event/dlb2: add probe-time hardware init event/dlb2: add xstats
event/dlb2: add infos get and configure event/dlb2: add queue and port default conf event/dlb2: add queue setup
event/dlb2: add port setup
event/dlb2: add port link
event/dlb2: add port unlink and port unlinks in progress event/dlb2: add eventdev start
event/dlb2: add enqueue and its burst variants event/dlb2: add dequeue and its burst variants event/dlb2: add eventdev stop and close event/dlb2: add PMD's token pop public interface event/dlb2: add PMD self-tests
event/dlb2: add queue and port release
event/dlb2: add timeout ticks entry point

 MAINTAINERS                                       |    5 +
 app/test/test_eventdev.c                          |    7 +
 config/rte_config.h                               |    7 +
 doc/api/doxy-api-index.md                         |    1 +
 doc/guides/eventdevs/dlb2.rst                     |  330 ++
 doc/guides/eventdevs/index.rst                    |    1 +
 doc/guides/rel_notes/release_20_11.rst            |    5 +
 drivers/event/dlb2/dlb2.c                         | 3951 ++++++++++++++
 drivers/event/dlb2/dlb2_iface.c                   |   74 +
 drivers/event/dlb2/dlb2_iface.h                   |   74 +
 drivers/event/dlb2/dlb2_inline_fns.h              |   61 +
 drivers/event/dlb2/dlb2_log.h                     |   25 +
 drivers/event/dlb2/dlb2_priv.h                    |  578 ++
 drivers/event/dlb2/dlb2_selftest.c                | 1570 ++++++
 drivers/event/dlb2/dlb2_user.h                    |  679 +++
 drivers/event/dlb2/dlb2_xstats.c                  | 1240 +++++
 drivers/event/dlb2/meson.build                    |   22 +
 drivers/event/dlb2/pf/base/dlb2_hw_types.h        |  367 ++
 drivers/event/dlb2/pf/base/dlb2_mbox.h            |  596 ++
 drivers/event/dlb2/pf/base/dlb2_osdep.h           |  230 +
 drivers/event/dlb2/pf/base/dlb2_osdep_bitmap.h    |  440 ++
 drivers/event/dlb2/pf/base/dlb2_osdep_list.h      |  131 +
 drivers/event/dlb2/pf/base/dlb2_osdep_types.h     |   31 +
 drivers/event/dlb2/pf/base/dlb2_regs.h            | 2527 +++++++++
 drivers/event/dlb2/pf/base/dlb2_resource.c        | 6027 +++++++++++++++++++++
 drivers/event/dlb2/pf/base/dlb2_resource.h        | 1913 +++++++
 drivers/event/dlb2/pf/dlb2_main.c                 |  673 +++
 drivers/event/dlb2/pf/dlb2_main.h                 |   97 +
 drivers/event/dlb2/pf/dlb2_pf.c                   |  728 +++
 drivers/event/dlb2/rte_pmd_dlb2.c                 |   39 +
 drivers/event/dlb2/rte_pmd_dlb2.h                 |   72 +
 drivers/event/dlb2/rte_pmd_dlb2_event_version.map |    9 +
 drivers/event/meson.build                         |    3 +-
 33 files changed, 22512 insertions(+), 1 deletion(-)
 create mode 100644 doc/guides/eventdevs/dlb2.rst
 create mode 100644 drivers/event/dlb2/dlb2.c
 create mode 100644 drivers/event/dlb2/dlb2_iface.c
 create mode 100644 drivers/event/dlb2/dlb2_iface.h
 create mode 100644 drivers/event/dlb2/dlb2_inline_fns.h
 create mode 100644 drivers/event/dlb2/dlb2_log.h
 create mode 100644 drivers/event/dlb2/dlb2_priv.h
 create mode 100644 drivers/event/dlb2/dlb2_selftest.c
 create mode 100644 drivers/event/dlb2/dlb2_user.h
 create mode 100644 drivers/event/dlb2/dlb2_xstats.c
 create mode 100644 drivers/event/dlb2/meson.build
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_hw_types.h
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_mbox.h
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_osdep.h
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_osdep_bitmap.h
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_osdep_list.h
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_osdep_types.h
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_regs.h
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_resource.c
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_resource.h
 create mode 100644 drivers/event/dlb2/pf/dlb2_main.c
 create mode 100644 drivers/event/dlb2/pf/dlb2_main.h
 create mode 100644 drivers/event/dlb2/pf/dlb2_pf.c
 create mode 100644 drivers/event/dlb2/rte_pmd_dlb2.c
 create mode 100644 drivers/event/dlb2/rte_pmd_dlb2.h
 create mode 100644 drivers/event/dlb2/rte_pmd_dlb2_event_version.map
Signature · 1 line
2.6.4
#258 lore raw

PATCH v3 1/23 event/dlb2: add documentation and meson build infrastructure

Adds the meson build infrastructure, which includes compile-time constants in rte_config.h. DLB2 is only supported on Linux X86 platforms at this time.

---
 MAINTAINERS                                       |  5 +++
 config/rte_config.h                               |  7 ++++
 doc/guides/eventdevs/dlb2.rst                     | 40 +++++++++++++++++++++++
 doc/guides/eventdevs/index.rst                    |  1 +
 drivers/event/dlb2/meson.build                    | 13 ++++++++
 drivers/event/dlb2/rte_pmd_dlb2_event_version.map |  3 ++
 drivers/event/meson.build                         |  3 +-
 7 files changed, 71 insertions(+), 1 deletion(-)
 create mode 100644 doc/guides/eventdevs/dlb2.rst
 create mode 100644 drivers/event/dlb2/meson.build
 create mode 100644 drivers/event/dlb2/rte_pmd_dlb2_event_version.map
MAINTAINERS +5 -0
index 3b16d7a..f732f28 100644
@@ -1188,6 +1188,11 @@ M: Peter Mccarthy <[email protected]>
 F: drivers/event/opdl/
 F: doc/guides/eventdevs/opdl.rst
 
+Intel DLB2 Eventdev PMD
+M: Timothy McDaniel <[email protected]>
+F: drivers/event/dlb2/
+F: doc/guides/eventdevs/dlb2.rst
+
 
 Rawdev Drivers
 --------------
config/rte_config.h +7 -0
index 0bae630..fd1b3c3 100644
@@ -131,4 +131,11 @@
 /* QEDE PMD defines */
 #define RTE_LIBRTE_QEDE_FW ""
 
+/* DLB2 defines */
+#define RTE_LIBRTE_PMD_DLB2_POLL_INTERVAL 1000
+#define RTE_LIBRTE_PMD_DLB2_UMWAIT_CTL_STATE  0
+#undef RTE_LIBRTE_PMD_DLB2_QUELL_STATS
+#define RTE_LIBRTE_PMD_DLB2_SW_CREDIT_QUANTA 32
+#define RTE_PMD_DLB2_DEFAULT_DEPTH_THRESH 256
+
 #endif /* _RTE_CONFIG_H_ */
doc/guides/eventdevs/dlb2.rst new file +40 -0
new file mode 100644
index 0000000..e3091c9
@@ -0,0 +1,40 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+    Copyright(c) 2020 Intel Corporation.
+
+Driver for the Intel® Dynamic Load Balancer (DLB2)
+==================================================
+
+The DPDK dlb poll mode driver supports the Intel® Dynamic Load Balancer.
+
+Prerequisites
+-------------
+
+Follow the DPDK :ref:`Getting Started Guide for Linux <linux_gsg>` to setup
+the basic DPDK environment.
+
+Configuration
+-------------
+
+The DLB2 PF PMD is a user-space PMD that uses VFIO to gain direct
+device access. To use this operation mode, the PCIe PF device must be bound
+to a DPDK-compatible VFIO driver, such as vfio-pci.
+
+Eventdev API Notes
+------------------
+
+The DLB2 provides the functions of a DPDK event device; specifically, it
+supports atomic, ordered, and parallel scheduling events from queues to ports.
+However, the DLB2 hardware is not a perfect match to the eventdev API. Some DLB2
+features are abstracted by the PMD such as directed ports.
+
+In general the dlb PMD is designed for ease-of-use and does not require a
+detailed understanding of the hardware, but these details are important when
+writing high-performance code. This section describes the places where the
+eventdev API and DLB2 misalign.
+
+Flow ID
+~~~~~~~
+
+The flow ID field is preserved in the event when it is scheduled in the
+DLB2.
+
doc/guides/eventdevs/index.rst +1 -0
index bb66a5e..738788d 100644
@@ -11,6 +11,7 @@ application through the eventdev API.
     :maxdepth: 2
     :numbered:
 
+    dlb2
     dpaa
     dpaa2
     dsw
drivers/event/dlb2/meson.build new file +13 -0
new file mode 100644
index 0000000..5324043
@@ -0,0 +1,13 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2019-2020 Intel Corporation
+
+if not is_linux or not dpdk_conf.has('RTE_ARCH_X86_64')
+        build = false
+        reason = 'only supported on ARCH_X86_64 Linux'
+        subdir_done()
+endif
+
+sources = files(
+)
+
+deps += ['mbuf', 'mempool', 'ring', 'pci', 'bus_pci']
drivers/event/dlb2/rte_pmd_dlb2_event_version.map new file +3 -0
new file mode 100644
index 0000000..4a76d1d
@@ -0,0 +1,3 @@
+DPDK_21 {
+	local: *;
+};
drivers/event/meson.build +2 -1
index ebe76a7..1a54de4 100644
@@ -5,7 +5,8 @@ if is_windows
 	subdir_done()
 endif
 
-drivers = ['dpaa', 'dpaa2', 'octeontx2', 'opdl', 'skeleton', 'sw', 'dsw']
+drivers = ['dlb2', 'dpaa', 'dpaa2', 'octeontx2', 'opdl', 'skeleton', 'sw',
+	   'dsw']
 if not (toolchain == 'gcc' and cc.version().version_compare('<4.8.6') and
 	dpdk_conf.has('RTE_ARCH_ARM64'))
 	drivers += 'octeontx'
Signature · 1 line
2.6.4
#259 lore raw

Re: [dpdk-dev] [PATCH v3 01/23] event/dlb2: add documentation and meson build infrastructure

Quoted 7 lines · Timothy McDaniel

Adds the meson build infrastructure, which includes compile-time constants in rte_config.h. DLB2 is only supported on Linux X86 platforms at this time.

There is the following build error[1] with this patch when testing with the latest dpdk-next-eventdev branch.

Timothy, Please check ./devtools/test-meson-builds.sh for each patch before sending the next version of DLB and DLB2 to avoid delay in pulling this series.

[1]
Message: Disabling mlx5 [drivers/vdpa/mlx5]: missing internal dependency "common_mlx5"
drivers/meson.build:179: WARNING: Custom target input '/export/dpdk-next-eventdev/drivers/event/dlb2/version.map' can't be converted to File object(s).
This will become a hard error in the future. drivers/meson.build:184: WARNING: Custom target input '/export/dpdk-next-eventdev/drivers/event/dlb2/version.map' can't be converted to File object(s).
This will become a hard error in the future.

drivers/meson.build:207:3: ERROR: File /export/dpdk-next-eventdev/drivers/event/dlb2/version.map does not exist.

Quoted 148 lines
---
 MAINTAINERS                                       |  5 +++
 config/rte_config.h                               |  7 ++++
 doc/guides/eventdevs/dlb2.rst                     | 40 +++++++++++++++++++++++
 doc/guides/eventdevs/index.rst                    |  1 +
 drivers/event/dlb2/meson.build                    | 13 ++++++++
 drivers/event/dlb2/rte_pmd_dlb2_event_version.map |  3 ++
 drivers/event/meson.build                         |  3 +-
 7 files changed, 71 insertions(+), 1 deletion(-)
 create mode 100644 doc/guides/eventdevs/dlb2.rst
 create mode 100644 drivers/event/dlb2/meson.build
 create mode 100644 drivers/event/dlb2/rte_pmd_dlb2_event_version.map
MAINTAINERS +5 -0
index 3b16d7a..f732f28 100644
@@ -1188,6 +1188,11 @@ M: Peter Mccarthy <[email protected]>
 F: drivers/event/opdl/
 F: doc/guides/eventdevs/opdl.rst
 
+Intel DLB2 Eventdev PMD
+M: Timothy McDaniel <[email protected]>
+F: drivers/event/dlb2/
+F: doc/guides/eventdevs/dlb2.rst
+
 
 Rawdev Drivers
 --------------
config/rte_config.h +7 -0
index 0bae630..fd1b3c3 100644
@@ -131,4 +131,11 @@
 /* QEDE PMD defines */
 #define RTE_LIBRTE_QEDE_FW ""
 
+/* DLB2 defines */
+#define RTE_LIBRTE_PMD_DLB2_POLL_INTERVAL 1000
+#define RTE_LIBRTE_PMD_DLB2_UMWAIT_CTL_STATE  0
+#undef RTE_LIBRTE_PMD_DLB2_QUELL_STATS
+#define RTE_LIBRTE_PMD_DLB2_SW_CREDIT_QUANTA 32
+#define RTE_PMD_DLB2_DEFAULT_DEPTH_THRESH 256
+
 #endif /* _RTE_CONFIG_H_ */
doc/guides/eventdevs/dlb2.rst new file +40 -0
new file mode 100644
index 0000000..e3091c9
@@ -0,0 +1,40 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+    Copyright(c) 2020 Intel Corporation.
+
+Driver for the Intel® Dynamic Load Balancer (DLB2)
+==================================================
+
+The DPDK dlb poll mode driver supports the Intel® Dynamic Load Balancer.
+
+Prerequisites
+-------------
+
+Follow the DPDK :ref:`Getting Started Guide for Linux <linux_gsg>` to setup
+the basic DPDK environment.
+
+Configuration
+-------------
+
+The DLB2 PF PMD is a user-space PMD that uses VFIO to gain direct
+device access. To use this operation mode, the PCIe PF device must be bound
+to a DPDK-compatible VFIO driver, such as vfio-pci.
+
+Eventdev API Notes
+------------------
+
+The DLB2 provides the functions of a DPDK event device; specifically, it
+supports atomic, ordered, and parallel scheduling events from queues to ports.
+However, the DLB2 hardware is not a perfect match to the eventdev API. Some DLB2
+features are abstracted by the PMD such as directed ports.
+
+In general the dlb PMD is designed for ease-of-use and does not require a
+detailed understanding of the hardware, but these details are important when
+writing high-performance code. This section describes the places where the
+eventdev API and DLB2 misalign.
+
+Flow ID
+~~~~~~~
+
+The flow ID field is preserved in the event when it is scheduled in the
+DLB2.
+
doc/guides/eventdevs/index.rst +1 -0
index bb66a5e..738788d 100644
@@ -11,6 +11,7 @@ application through the eventdev API.
     :maxdepth: 2
     :numbered:
 
+    dlb2
     dpaa
     dpaa2
     dsw
drivers/event/dlb2/meson.build new file +13 -0
new file mode 100644
index 0000000..5324043
@@ -0,0 +1,13 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2019-2020 Intel Corporation
+
+if not is_linux or not dpdk_conf.has('RTE_ARCH_X86_64')
+        build = false
+        reason = 'only supported on ARCH_X86_64 Linux'
+        subdir_done()
+endif
+
+sources = files(
+)
+
+deps += ['mbuf', 'mempool', 'ring', 'pci', 'bus_pci']
drivers/event/dlb2/rte_pmd_dlb2_event_version.map new file +3 -0
new file mode 100644
index 0000000..4a76d1d
@@ -0,0 +1,3 @@
+DPDK_21 {
+       local: *;
+};
drivers/event/meson.build +2 -2
index ebe76a7..1a54de4 100644
@@ -5,7 +5,8 @@ if is_windows
        subdir_done()
 endif
 
-drivers = ['dpaa', 'dpaa2', 'octeontx2', 'opdl', 'skeleton', 'sw', 'dsw']
+drivers = ['dlb2', 'dpaa', 'dpaa2', 'octeontx2', 'opdl', 'skeleton', 'sw',
+          'dsw']
 if not (toolchain == 'gcc' and cc.version().version_compare('<4.8.6') and
        dpdk_conf.has('RTE_ARCH_ARM64'))
        drivers += 'octeontx'
--

2.6.4

#260 lore raw

PATCH v3 2/23 event/dlb2: add dynamic logging

In reply to Timothy McDaniel

This commit adds base support for dynamic logging. The default log level is NOTICE. Dynamic logging is used exclusively throughout this patchset.

---
 drivers/event/dlb2/dlb2.c      |  7 +++++++
 drivers/event/dlb2/dlb2_log.h  | 25 +++++++++++++++++++++++++
 drivers/event/dlb2/meson.build |  3 +--
 3 files changed, 33 insertions(+), 2 deletions(-)
 create mode 100644 drivers/event/dlb2/dlb2.c
 create mode 100644 drivers/event/dlb2/dlb2_log.h
drivers/event/dlb2/dlb2.c new file +7 -0
new file mode 100644
index 0000000..2082dd6
@@ -0,0 +1,7 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2016-2020 Intel Corporation
+ */
+
+#include <rte_log.h>
+
+RTE_LOG_REGISTER(eventdev_dlb2_log_level, pmd.event.dlb2, NOTICE);
drivers/event/dlb2/dlb2_log.h new file +25 -0
new file mode 100644
index 0000000..dc1481e
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2016-2020 Intel Corporation
+ */
+
+#ifndef _DLB2_EVDEV_LOG_H_
+#define _DLB2_EVDEV_LOG_H_
+
+extern int eventdev_dlb2_log_level;
+
+/* Dynamic logging */
+#define DLB2_LOG_IMPL(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, eventdev_dlb2_log_level, "%s" fmt "\n", \
+		__func__, ##args)
+
+#define DLB2_LOG_INFO(fmt, args...) \
+	DLB2_LOG_IMPL(INFO, fmt, ## args)
+
+#define DLB2_LOG_ERR(fmt, args...) \
+	DLB2_LOG_IMPL(ERR, fmt, ## args)
+
+/* remove debug logs at compile time unless actually debugging */
+#define DLB2_LOG_DBG(fmt, args...) \
+	RTE_LOG_DP(DEBUG, PMD, fmt, ## args)
+
+#endif /* _DLB2_EVDEV_LOG_H_ */
drivers/event/dlb2/meson.build +1 -2
index 5324043..435c1ee 100644
@@ -7,7 +7,6 @@ if not is_linux or not dpdk_conf.has('RTE_ARCH_X86_64')
         subdir_done()
 endif
 
-sources = files(
-)
+sources = files('dlb2.c')
 
 deps += ['mbuf', 'mempool', 'ring', 'pci', 'bus_pci']
Signature · 1 line
2.6.4
#261 lore raw

PATCH v3 3/23 event/dlb2: add private data structures and constants

In reply to Timothy McDaniel

The header file dlb2_priv.h is used internally by the PMD. It include constants, macros for device resources, structure definitions for hardware interfaces and software state, and various forward-declarations. The header file rte_pmd_dlb2.h will be exported in a subsequent patch, but is included here due to a data structure dependency.

---
 drivers/event/dlb2/dlb2_priv.h | 575 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 575 insertions(+)
 create mode 100644 drivers/event/dlb2/dlb2_priv.h
drivers/event/dlb2/dlb2_priv.h new file +575 -0
new file mode 100644
index 0000000..61567a6
@@ -0,0 +1,575 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2016-2020 Intel Corporation
+ */
+
+#ifndef _DLB2_PRIV_H_
+#define _DLB2_PRIV_H_
+
+#include <emmintrin.h>
+#include <stdbool.h>
+
+#include <rte_eventdev.h>
+#include <rte_config.h>
+#include "dlb2_user.h"
+#include "dlb2_log.h"
+
+#ifndef RTE_LIBRTE_PMD_DLB2_QUELL_STATS
+#define DLB2_INC_STAT(_stat, _incr_val) ((_stat) += _incr_val)
+#else
+#define DLB2_INC_STAT(_stat, _incr_val)
+#endif
+
+#define EVDEV_DLB2_NAME_PMD dlb2_event
+
+/*  command line arg strings */
+#define NUMA_NODE_ARG "numa_node"
+#define DLB2_MAX_NUM_EVENTS "max_num_events"
+#define DLB2_NUM_DIR_CREDITS "num_dir_credits"
+#define DEV_ID_ARG "dev_id"
+#define DLB2_DEFER_SCHED_ARG "defer_sched"
+#define DLB2_QID_DEPTH_THRESH_ARG "qid_depth_thresh"
+#define DLB2_COS_ARG "cos"
+
+/* Begin HW related defines and structs */
+
+#define DLB2_MAX_NUM_DOMAINS 32
+#define DLB2_MAX_NUM_VFS 16
+#define DLB2_MAX_NUM_LDB_QUEUES 32
+#define DLB2_MAX_NUM_LDB_PORTS 64
+#define DLB2_MAX_NUM_DIR_PORTS 64
+#define DLB2_MAX_NUM_DIR_QUEUES 64
+#define DLB2_MAX_NUM_FLOWS (64 * 1024)
+#define DLB2_MAX_NUM_LDB_CREDITS (8 * 1024)
+#define DLB2_MAX_NUM_DIR_CREDITS (2 * 1024)
+#define DLB2_MAX_NUM_LDB_CREDIT_POOLS 64
+#define DLB2_MAX_NUM_DIR_CREDIT_POOLS 64
+#define DLB2_MAX_NUM_HIST_LIST_ENTRIES 2048
+#define DLB2_MAX_NUM_AQOS_ENTRIES 2048
+#define DLB2_MAX_NUM_QIDS_PER_LDB_CQ 8
+#define DLB2_QID_PRIORITIES 8
+#define DLB2_MAX_DEVICE_PATH 32
+#define DLB2_MIN_DEQUEUE_TIMEOUT_NS 1
+/* Note: "- 1" here to support the timeout range check in eventdev_autotest */
+#define DLB2_MAX_DEQUEUE_TIMEOUT_NS (UINT32_MAX - 1)
+#define DLB2_SW_CREDIT_BATCH_SZ 32
+#define DLB2_NUM_SN_GROUPS 2
+#define DLB2_MAX_LDB_SN_ALLOC 1024
+#define DLB2_MAX_QUEUE_DEPTH_THRESHOLD 8191
+
+/* 2048 total hist list entries and 64 total ldb ports, which
+ * makes for 2048/64 == 32 hist list entries per port. However, CQ
+ * depth must be a power of 2 and must also be >= HIST LIST entries.
+ * As a result we just limit the maximum dequeue depth to 32.
+ */
+#define DLB2_MIN_CQ_DEPTH 1
+#define DLB2_MAX_CQ_DEPTH 32
+#define DLB2_MIN_HARDWARE_CQ_DEPTH 8
+#define DLB2_NUM_HIST_LIST_ENTRIES_PER_LDB_PORT \
+	DLB2_MAX_CQ_DEPTH
+
+/*
+ * Static per queue/port provisioning values
+ */
+#define DLB2_NUM_ATOMIC_INFLIGHTS_PER_QUEUE 64
+
+#define CQ_BASE(is_dir) ((is_dir) ? DLB2_DIR_CQ_BASE : DLB2_LDB_CQ_BASE)
+#define CQ_SIZE(is_dir) ((is_dir) ? DLB2_DIR_CQ_MAX_SIZE : \
+				    DLB2_LDB_CQ_MAX_SIZE)
+#define PP_BASE(is_dir) ((is_dir) ? DLB2_DIR_PP_BASE : DLB2_LDB_PP_BASE)
+
+#define PAGE_SIZE (sysconf(_SC_PAGESIZE))
+
+#define DLB2_NUM_QES_PER_CACHE_LINE 4
+
+#define DLB2_MAX_ENQUEUE_DEPTH 64
+#define DLB2_MIN_ENQUEUE_DEPTH 4
+
+#define DLB2_NAME_SIZE 64
+
+#define DLB2_1K 1024
+#define DLB2_2K (2 * DLB2_1K)
+#define DLB2_4K (4 * DLB2_1K)
+#define DLB2_16K (16 * DLB2_1K)
+#define DLB2_32K (32 * DLB2_1K)
+#define DLB2_1MB (DLB2_1K * DLB2_1K)
+#define DLB2_16MB (16 * DLB2_1MB)
+
+/* Use the upper 3 bits of the event priority to select the DLB2 priority */
+#define EV_TO_DLB2_PRIO(x) ((x) >> 5)
+#define DLB2_TO_EV_PRIO(x) ((x) << 5)
+
+enum dlb2_hw_port_types {
+	DLB2_LDB_PORT,
+	DLB2_DIR_PORT,
+	DLB2_NUM_PORT_TYPES /* Must be last */
+};
+
+enum dlb2_hw_queue_types {
+	DLB2_LDB_QUEUE,
+	DLB2_DIR_QUEUE,
+	DLB2_NUM_QUEUE_TYPES /* Must be last */
+};
+
+#define PORT_TYPE(p) ((p)->is_directed ? DLB2_DIR_PORT : DLB2_LDB_PORT)
+
+/* Do not change - must match hardware! */
+enum dlb2_hw_sched_type {
+	DLB2_SCHED_ATOMIC = 0,
+	DLB2_SCHED_UNORDERED,
+	DLB2_SCHED_ORDERED,
+	DLB2_SCHED_DIRECTED,
+	/* DLB2_NUM_HW_SCHED_TYPES must be last */
+	DLB2_NUM_HW_SCHED_TYPES
+};
+
+struct dlb2_hw_rsrcs {
+	int32_t nb_events_limit;
+	uint32_t num_queues;		/* Total queues (lb + dir) */
+	uint32_t num_ldb_queues;	/* Number of available ldb queues */
+	uint32_t num_ldb_ports;         /* Number of load balanced ports */
+	uint32_t num_dir_ports;         /* Number of directed ports */
+	uint32_t num_ldb_credits;       /* Number of load balanced credits */
+	uint32_t num_dir_credits;       /* Number of directed credits */
+	uint32_t reorder_window_size;   /* Size of reorder window */
+};
+
+struct dlb2_hw_resource_info {
+	/**> Max resources that can be provided */
+	struct dlb2_hw_rsrcs hw_rsrc_max;
+	int num_sched_domains;
+	uint32_t socket_id;
+};
+
+enum dlb2_enqueue_type {
+	/**>
+	 * New : Used to inject a new packet into the QM.
+	 */
+	DLB2_ENQ_NEW,
+	/**>
+	 * Forward : Enqueues a packet, and
+	 *  - if atomic: release any lock it holds in the QM
+	 *  - if ordered: release the packet for egress re-ordering
+	 */
+	DLB2_ENQ_FWD,
+	/**>
+	 * Enqueue Drop : Release an inflight packet. Must be called with
+	 * event == NULL. Used to drop a packet.
+	 *
+	 * Note that all packets dequeued from a load-balanced port must be
+	 * released, either with DLB2_ENQ_DROP or DLB2_ENQ_FWD.
+	 */
+	DLB2_ENQ_DROP,
+
+	/* marker for array sizing etc. */
+	_DLB2_NB_ENQ_TYPES
+};
+
+/* hw-specific format - do not change */
+
+struct dlb2_event_type {
+	uint8_t major:4;
+	uint8_t unused:4;
+	uint8_t sub;
+};
+
+union dlb2_opaque_data {
+	uint16_t opaque_data;
+	struct dlb2_event_type event_type;
+};
+
+struct dlb2_msg_info {
+	uint8_t qid;
+	uint8_t sched_type:2;
+	uint8_t priority:3;
+	uint8_t msg_type:3;
+};
+
+#define DLB2_NEW_CMD_BYTE 0x08
+#define DLB2_FWD_CMD_BYTE 0x0A
+#define DLB2_COMP_CMD_BYTE 0x02
+#define DLB2_POP_CMD_BYTE 0x01
+#define DLB2_NOOP_CMD_BYTE 0x00
+
+/* hw-specific format - do not change */
+struct dlb2_enqueue_qe {
+	uint64_t data;
+	/* Word 3 */
+	union dlb2_opaque_data u;
+	uint8_t qid;
+	uint8_t sched_type:2;
+	uint8_t priority:3;
+	uint8_t msg_type:3;
+	/* Word 4 */
+	uint16_t lock_id;
+	uint8_t meas_lat:1;
+	uint8_t rsvd1:2;
+	uint8_t no_dec:1;
+	uint8_t cmp_id:4;
+	union {
+		uint8_t cmd_byte;
+		struct {
+			uint8_t cq_token:1;
+			uint8_t qe_comp:1;
+			uint8_t qe_frag:1;
+			uint8_t qe_valid:1;
+			uint8_t rsvd3:1;
+			uint8_t error:1;
+			uint8_t rsvd:2;
+		};
+	};
+};
+
+/* hw-specific format - do not change */
+struct dlb2_cq_pop_qe {
+	uint64_t data;
+	union dlb2_opaque_data u;
+	uint8_t qid;
+	uint8_t sched_type:2;
+	uint8_t priority:3;
+	uint8_t msg_type:3;
+	uint16_t tokens:10;
+	uint16_t rsvd2:6;
+	uint8_t meas_lat:1;
+	uint8_t rsvd1:2;
+	uint8_t no_dec:1;
+	uint8_t cmp_id:4;
+	union {
+		uint8_t cmd_byte;
+		struct {
+			uint8_t cq_token:1;
+			uint8_t qe_comp:1;
+			uint8_t qe_frag:1;
+			uint8_t qe_valid:1;
+			uint8_t rsvd3:1;
+			uint8_t error:1;
+			uint8_t rsvd:2;
+		};
+	};
+};
+
+/* hw-specific format - do not change */
+struct dlb2_dequeue_qe {
+	uint64_t data;
+	union dlb2_opaque_data u;
+	uint8_t qid;
+	uint8_t sched_type:2;
+	uint8_t priority:3;
+	uint8_t msg_type:3;
+	uint16_t flow_id:16; /* was pp_id in v1 */
+	uint8_t debug;
+	uint8_t cq_gen:1;
+	uint8_t qid_depth:2; /* 2 bits in v2 */
+	uint8_t rsvd1:2;
+	uint8_t error:1;
+	uint8_t rsvd2:2;
+};
+
+union dlb2_port_config {
+	struct dlb2_create_ldb_port_args ldb;
+	struct dlb2_create_dir_port_args dir;
+};
+
+enum dlb2_port_state {
+	PORT_CLOSED,
+	PORT_STARTED,
+	PORT_STOPPED
+};
+
+enum dlb2_configuration_state {
+	/* The resource has not been configured */
+	DLB2_NOT_CONFIGURED,
+	/* The resource was configured, but the device was stopped */
+	DLB2_PREV_CONFIGURED,
+	/* The resource is currently configured */
+	DLB2_CONFIGURED
+};
+
+struct dlb2_port {
+	uint32_t id;
+	bool is_directed;
+	bool gen_bit;
+	uint16_t dir_credits;
+	uint32_t dequeue_depth;
+	union dlb2_port_config cfg;
+	uint32_t *credit_pool[DLB2_NUM_QUEUE_TYPES]; /* use __atomic builtins */
+	uint16_t cached_ldb_credits;
+	uint16_t ldb_credits;
+	uint16_t cached_dir_credits;
+	bool int_armed;
+	uint16_t owed_tokens;
+	int16_t issued_releases;
+	int cq_depth;
+	uint16_t cq_idx;
+	uint16_t cq_idx_unmasked;
+	uint16_t cq_depth_mask;
+	uint16_t gen_bit_shift;
+	enum dlb2_port_state state;
+	enum dlb2_configuration_state config_state;
+	int num_mapped_qids;
+	uint8_t *qid_mappings;
+	struct dlb2_enqueue_qe *qe4; /* Cache line's worth of QEs (4) */
+	struct dlb2_enqueue_qe *int_arm_qe;
+	struct dlb2_cq_pop_qe *consume_qe;
+	struct dlb2_eventdev *dlb2; /* back ptr */
+	struct dlb2_eventdev_port *ev_port; /* back ptr */
+};
+
+/* Per-process per-port mmio and memory pointers */
+struct process_local_port_data {
+	uint64_t *pp_addr;
+	struct dlb2_dequeue_qe *cq_base;
+	const struct rte_memzone *mz;
+	bool mmaped;
+};
+
+struct dlb2_eventdev;
+
+struct dlb2_config {
+	int configured;
+	int reserved;
+	uint32_t num_ldb_credits;
+	uint32_t num_dir_credits;
+	struct dlb2_create_sched_domain_args resources;
+};
+
+enum dlb2_cos {
+	DLB2_COS_DEFAULT = -1,
+	DLB2_COS_0 = 0,
+	DLB2_COS_1,
+	DLB2_COS_2,
+	DLB2_COS_3
+};
+
+struct dlb2_hw_dev {
+	struct dlb2_config cfg;
+	struct dlb2_hw_resource_info info;
+	void *pf_dev; /* opaque pointer to PF PMD dev (struct dlb2_dev) */
+	uint32_t domain_id;
+	enum dlb2_cos cos_id;
+	rte_spinlock_t resource_lock; /* for MP support */
+} __rte_cache_aligned;
+
+/* End HW related defines and structs */
+
+/* Begin DLB2 PMD Eventdev related defines and structs */
+
+#define DLB2_MAX_NUM_QUEUES \
+	(DLB2_MAX_NUM_DIR_QUEUES + DLB2_MAX_NUM_LDB_QUEUES)
+
+#define DLB2_MAX_NUM_PORTS (DLB2_MAX_NUM_DIR_PORTS + DLB2_MAX_NUM_LDB_PORTS)
+#define DLB2_MAX_INPUT_QUEUE_DEPTH 256
+
+/** Structure to hold the queue to port link establishment attributes */
+
+struct dlb2_event_queue_link {
+	uint8_t queue_id;
+	uint8_t priority;
+	bool mapped;
+	bool valid;
+};
+
+struct dlb2_traffic_stats {
+	uint64_t rx_ok;
+	uint64_t rx_drop;
+	uint64_t rx_interrupt_wait;
+	uint64_t rx_umonitor_umwait;
+	uint64_t tx_ok;
+	uint64_t total_polls;
+	uint64_t zero_polls;
+	uint64_t tx_nospc_ldb_hw_credits;
+	uint64_t tx_nospc_dir_hw_credits;
+	uint64_t tx_nospc_inflight_max;
+	uint64_t tx_nospc_new_event_limit;
+	uint64_t tx_nospc_inflight_credits;
+};
+
+/* DLB2 HW sets the 2bit qid_depth in rx QEs based on the programmable depth
+ * threshold. The global default value in config/common_base (or rte_config.h)
+ * can be overridden on a per-qid basis using a vdev command line parameter.
+ * 3: depth > threshold
+ * 2: threshold >= depth > 3/4 threshold
+ * 1: 3/4 threshold >= depth > 1/2 threshold
+ * 0: depth <= 1/2 threshold.
+ */
+#define DLB2_QID_DEPTH_LE50 0
+#define DLB2_QID_DEPTH_GT50_LE75 1
+#define DLB2_QID_DEPTH_GT75_LE100 2
+#define DLB2_QID_DEPTH_GT100 3
+#define DLB2_NUM_QID_DEPTH_STAT_VALS 4 /* 2 bits */
+
+struct dlb2_queue_stats {
+	uint64_t enq_ok;
+	uint64_t qid_depth[DLB2_NUM_QID_DEPTH_STAT_VALS];
+};
+
+struct dlb2_port_stats {
+	struct dlb2_traffic_stats traffic;
+	uint64_t tx_op_cnt[4]; /* indexed by rte_event.op */
+	uint64_t tx_implicit_rel;
+	uint64_t tx_sched_cnt[DLB2_NUM_HW_SCHED_TYPES];
+	uint64_t tx_invalid;
+	uint64_t rx_sched_cnt[DLB2_NUM_HW_SCHED_TYPES];
+	uint64_t rx_sched_invalid;
+	struct dlb2_queue_stats queue[DLB2_MAX_NUM_QUEUES];
+};
+
+struct dlb2_eventdev_port {
+	struct dlb2_port qm_port; /* hw specific data structure */
+	struct rte_event_port_conf conf; /* user-supplied configuration */
+	uint16_t inflight_credits; /* num credits this port has right now */
+	uint16_t credit_update_quanta;
+	struct dlb2_eventdev *dlb2; /* backlink optimization */
+	struct dlb2_port_stats stats __rte_cache_aligned;
+	struct dlb2_event_queue_link link[DLB2_MAX_NUM_QIDS_PER_LDB_CQ];
+	int num_links;
+	uint32_t id; /* port id */
+	/* num releases yet to be completed on this port.
+	 * Only applies to load-balanced ports.
+	 */
+	uint16_t outstanding_releases;
+	uint16_t inflight_max; /* app requested max inflights for this port */
+	/* setup_done is set when the event port is setup */
+	bool setup_done;
+	/* enq_configured is set when the qm port is created */
+	bool enq_configured;
+	uint8_t implicit_release; /* release events before dequeueing */
+}  __rte_cache_aligned;
+
+struct dlb2_queue {
+	uint32_t num_qid_inflights; /* User config */
+	uint32_t num_atm_inflights; /* User config */
+	enum dlb2_configuration_state config_state;
+	int sched_type; /* LB queue only */
+	uint32_t id;
+	bool is_directed;
+};
+
+struct dlb2_eventdev_queue {
+	struct dlb2_queue qm_queue;
+	struct rte_event_queue_conf conf; /* User config */
+	int depth_threshold; /* use default if 0 */
+	uint32_t id;
+	bool setup_done;
+	uint8_t num_links;
+};
+
+enum dlb2_run_state {
+	DLB2_RUN_STATE_STOPPED = 0,
+	DLB2_RUN_STATE_STOPPING,
+	DLB2_RUN_STATE_STARTING,
+	DLB2_RUN_STATE_STARTED
+};
+
+struct dlb2_eventdev {
+	struct dlb2_eventdev_port ev_ports[DLB2_MAX_NUM_PORTS];
+	struct dlb2_eventdev_queue ev_queues[DLB2_MAX_NUM_QUEUES];
+	uint8_t qm_ldb_to_ev_queue_id[DLB2_MAX_NUM_QUEUES];
+	uint8_t qm_dir_to_ev_queue_id[DLB2_MAX_NUM_QUEUES];
+	/* store num stats and offset of the stats for each queue */
+	uint16_t xstats_count_per_qid[DLB2_MAX_NUM_QUEUES];
+	uint16_t xstats_offset_for_qid[DLB2_MAX_NUM_QUEUES];
+	/* store num stats and offset of the stats for each port */
+	uint16_t xstats_count_per_port[DLB2_MAX_NUM_PORTS];
+	uint16_t xstats_offset_for_port[DLB2_MAX_NUM_PORTS];
+	struct dlb2_get_num_resources_args hw_rsrc_query_results;
+	uint32_t xstats_count_mode_queue;
+	struct dlb2_hw_dev qm_instance; /* strictly hw related */
+	uint64_t global_dequeue_wait_ticks;
+	struct dlb2_xstats_entry *xstats;
+	struct rte_eventdev *event_dev; /* backlink to dev */
+	uint32_t xstats_count_mode_dev;
+	uint32_t xstats_count_mode_port;
+	uint32_t xstats_count;
+	uint32_t inflights; /* use __atomic builtins */
+	uint32_t new_event_limit;
+	int max_num_events_override;
+	int num_dir_credits_override;
+	volatile enum dlb2_run_state run_state;
+	uint16_t num_dir_queues; /* total num of evdev dir queues requested */
+	uint16_t num_dir_credits;
+	uint16_t num_ldb_credits;
+	uint16_t num_queues; /* total queues */
+	uint16_t num_ldb_queues; /* total num of evdev ldb queues requested */
+	uint16_t num_ports; /* total num of evdev ports requested */
+	uint16_t num_ldb_ports; /* total num of ldb ports requested */
+	uint16_t num_dir_ports; /* total num of dir ports requested */
+	bool umwait_allowed;
+	bool global_dequeue_wait; /* Not using per dequeue wait if true */
+	bool defer_sched;
+	enum dlb2_cq_poll_modes poll_mode;
+	uint8_t revision;
+	bool configured;
+	uint16_t max_ldb_credits;
+	uint16_t max_dir_credits;
+
+	/* force hw credit pool counters into exclusive cache lines */
+
+	/* use __atomic builtins */ /* shared hw cred */
+	uint32_t ldb_credit_pool __rte_cache_aligned;
+	/* use __atomic builtins */ /* shared hw cred */
+	uint32_t dir_credit_pool __rte_cache_aligned;
+};
+
+/* used for collecting and passing around the dev args */
+struct dlb2_qid_depth_thresholds {
+	int val[DLB2_MAX_NUM_QUEUES];
+};
+
+struct dlb2_devargs {
+	int socket_id;
+	int max_num_events;
+	int num_dir_credits_override;
+	int dev_id;
+	int defer_sched;
+	struct dlb2_qid_depth_thresholds qid_depth_thresholds;
+	enum dlb2_cos cos_id;
+};
+
+/* End Eventdev related defines and structs */
+
+/* Forwards for non-inlined functions */
+
+void dlb2_eventdev_dump(struct rte_eventdev *dev, FILE *f);
+
+int dlb2_xstats_init(struct dlb2_eventdev *dlb2);
+
+void dlb2_xstats_uninit(struct dlb2_eventdev *dlb2);
+
+int dlb2_eventdev_xstats_get(const struct rte_eventdev *dev,
+		enum rte_event_dev_xstats_mode mode, uint8_t queue_port_id,
+		const unsigned int ids[], uint64_t values[], unsigned int n);
+
+int dlb2_eventdev_xstats_get_names(const struct rte_eventdev *dev,
+		enum rte_event_dev_xstats_mode mode, uint8_t queue_port_id,
+		struct rte_event_dev_xstats_name *xstat_names,
+		unsigned int *ids, unsigned int size);
+
+uint64_t dlb2_eventdev_xstats_get_by_name(const struct rte_eventdev *dev,
+					  const char *name, unsigned int *id);
+
+int dlb2_eventdev_xstats_reset(struct rte_eventdev *dev,
+		enum rte_event_dev_xstats_mode mode,
+		int16_t queue_port_id,
+		const uint32_t ids[],
+		uint32_t nb_ids);
+
+int test_dlb2_eventdev(void);
+
+int dlb2_primary_eventdev_probe(struct rte_eventdev *dev,
+				const char *name,
+				struct dlb2_devargs *dlb2_args);
+
+int dlb2_secondary_eventdev_probe(struct rte_eventdev *dev,
+				  const char *name);
+
+uint32_t dlb2_get_queue_depth(struct dlb2_eventdev *dlb2,
+			      struct dlb2_eventdev_queue *queue);
+
+int dlb2_parse_params(const char *params,
+		      const char *name,
+		      struct dlb2_devargs *dlb2_args);
+
+/* Extern globals */
+extern struct process_local_port_data dlb2_port[][DLB2_NUM_PORT_TYPES];
+
+#endif	/* _DLB2_PRIV_H_ */
Signature · 1 line
2.6.4