Add timestamp to dpdk.log

2022-01-05 Thread Soumya Muralidhar
Hi,

I am looking to add timestamp while logging using 
rte_openlog_stream
 function where you pass the file pointer as a parameter to this function.
Below is the snippet :


const char 
*dpdk_log_path
 = 
"/var/log/dpdk.log"


log_fp
 = 
fopen(dpdk_log_path,
 "a+");

if 
(log_fp
 == NULL) {

 
EHAL_LOG(LOG_ERR,
 "dpdk log file(%s) open failed, error (%d:%s) ",

  
dpdk_log_path,
 errno, 
strerror(errno));

 return 
(errno);



rte_openlog_stream(log_fp);


Thanks,
Soumya
This message may contain confidential and privileged information. If it has 
been sent to you in error, please reply to advise the sender of the error and 
then immediately delete it. If you are not the intended recipient, do not read, 
copy, disclose or otherwise use this message. The sender disclaims any 
liability for such unauthorized use. NOTE that all incoming emails sent to 
Gigamon email accounts will be archived and may be scanned by us and/or by 
external service providers to detect and prevent threats to our systems, 
investigate illegal or inappropriate behavior, and/or eliminate unsolicited 
promotional emails (“spam”).


[PATCH v4 00/11] Add cnxk_gpio

2022-01-05 Thread Tomasz Duszynski
This series introduces a new rawdevice PMD which allows
to manage userspace GPIOs and install custom GPIO interrupt
handlers which bypass kernel. This is especially useful for
applications that, besides providing standard dataplane functionality,
want to have fast and low latency access to GPIO pin state.

It'd be great to have that merged during 22.02 merge window.

v4:
- free kvargs after parsing arguments
- add support for allowing only subset of available GPIOs

v3:
- fix meson formatting
- fix cnxk_gpio_process_buf() return value

v2:
- do not trigger irq by writing to /dev/mem, use ioctl() instead

Tomasz Duszynski (11):
  raw/cnxk_gpio: add GPIO driver skeleton
  raw/cnxk_gpio: support reading default queue conf
  raw/cnxk_gpio: support reading queue count
  raw/cnxk_gpio: support queue setup
  raw/cnxk_gpio: support queue release
  raw/cnxk_gpio: support enqueuing buffers
  raw/cnxk_gpio: support dequeuing buffers
  raw/cnxk_gpio: support standard GPIO operations
  raw/cnxk_gpio: support custom irq handlers
  raw/cnxk_gpio: support selftest
  raw/cnxk_gpio: add option to allow using subset of GPIOs

 doc/guides/rawdevs/cnxk_gpio.rst   | 200 ++
 doc/guides/rawdevs/index.rst   |   1 +
 drivers/raw/cnxk_gpio/cnxk_gpio.c  | 754 +
 drivers/raw/cnxk_gpio/cnxk_gpio.h  |  35 +
 drivers/raw/cnxk_gpio/cnxk_gpio_irq.c  | 216 ++
 drivers/raw/cnxk_gpio/cnxk_gpio_selftest.c | 386 +++
 drivers/raw/cnxk_gpio/meson.build  |  11 +
 drivers/raw/cnxk_gpio/rte_pmd_cnxk_gpio.h  | 437 
 drivers/raw/cnxk_gpio/version.map  |   3 +
 drivers/raw/meson.build|   1 +
 10 files changed, 2044 insertions(+)
 create mode 100644 doc/guides/rawdevs/cnxk_gpio.rst
 create mode 100644 drivers/raw/cnxk_gpio/cnxk_gpio.c
 create mode 100644 drivers/raw/cnxk_gpio/cnxk_gpio.h
 create mode 100644 drivers/raw/cnxk_gpio/cnxk_gpio_irq.c
 create mode 100644 drivers/raw/cnxk_gpio/cnxk_gpio_selftest.c
 create mode 100644 drivers/raw/cnxk_gpio/meson.build
 create mode 100644 drivers/raw/cnxk_gpio/rte_pmd_cnxk_gpio.h
 create mode 100644 drivers/raw/cnxk_gpio/version.map

--
2.25.1



[PATCH v4 02/11] raw/cnxk_gpio: support reading default queue conf

2022-01-05 Thread Tomasz Duszynski
Add support for reading default queue configuration.

Signed-off-by: Tomasz Duszynski 
---
 drivers/raw/cnxk_gpio/cnxk_gpio.c | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/drivers/raw/cnxk_gpio/cnxk_gpio.c 
b/drivers/raw/cnxk_gpio/cnxk_gpio.c
index 881615d62e..f80788f7fb 100644
--- a/drivers/raw/cnxk_gpio/cnxk_gpio.c
+++ b/drivers/raw/cnxk_gpio/cnxk_gpio.c
@@ -138,7 +138,26 @@ cnxk_gpio_read_attr_int(char *attr, int *val)
return 0;
 }
 
+static int
+cnxk_gpio_queue_def_conf(struct rte_rawdev *dev, uint16_t queue_id,
+rte_rawdev_obj_t queue_conf, size_t queue_conf_size)
+{
+   unsigned int *conf;
+
+   RTE_SET_USED(dev);
+   RTE_SET_USED(queue_id);
+
+   if (queue_conf_size != sizeof(*conf))
+   return -EINVAL;
+
+   conf = (unsigned int *)queue_conf;
+   *conf = 1;
+
+   return 0;
+}
+
 static const struct rte_rawdev_ops cnxk_gpio_rawdev_ops = {
+   .queue_def_conf = cnxk_gpio_queue_def_conf,
 };
 
 static int
-- 
2.25.1



[PATCH v4 01/11] raw/cnxk_gpio: add GPIO driver skeleton

2022-01-05 Thread Tomasz Duszynski
Add initial support for PMD that allows to control particular pins form
userspace. Moreover PMD allows to attach custom interrupt handlers to
controllable GPIOs.

Main users of this PMD are dataplain applications requiring fast and low
latency access to pin state.

Signed-off-by: Tomasz Duszynski 
---
 doc/guides/rawdevs/cnxk_gpio.rst  |  65 
 doc/guides/rawdevs/index.rst  |   1 +
 drivers/raw/cnxk_gpio/cnxk_gpio.c | 239 ++
 drivers/raw/cnxk_gpio/cnxk_gpio.h |  22 +++
 drivers/raw/cnxk_gpio/meson.build |   8 +
 drivers/raw/cnxk_gpio/version.map |   3 +
 drivers/raw/meson.build   |   1 +
 7 files changed, 339 insertions(+)
 create mode 100644 doc/guides/rawdevs/cnxk_gpio.rst
 create mode 100644 drivers/raw/cnxk_gpio/cnxk_gpio.c
 create mode 100644 drivers/raw/cnxk_gpio/cnxk_gpio.h
 create mode 100644 drivers/raw/cnxk_gpio/meson.build
 create mode 100644 drivers/raw/cnxk_gpio/version.map

diff --git a/doc/guides/rawdevs/cnxk_gpio.rst b/doc/guides/rawdevs/cnxk_gpio.rst
new file mode 100644
index 00..868302d07f
--- /dev/null
+++ b/doc/guides/rawdevs/cnxk_gpio.rst
@@ -0,0 +1,65 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+Copyright(c) 2021 Marvell.
+
+Marvell CNXK GPIO Driver
+
+
+CNXK GPIO PMD configures and manages GPIOs available on the system using
+standard enqueue/dequeue mechanism offered by raw device abstraction. PMD 
relies
+both on standard sysfs GPIO interface provided by the Linux kernel and GPIO
+kernel driver custom interface allowing one to install userspace interrupt
+handlers.
+
+Features
+
+
+Following features are available:
+
+- export/unexport a GPIO
+- read/write specific value from/to exported GPIO
+- set GPIO direction
+- set GPIO edge that triggers interrupt
+- set GPIO active low
+- register interrupt handler for specific GPIO
+
+Requirements
+
+
+PMD relies on modified kernel GPIO driver which exposes ``ioctl()`` interface
+for installing interrupt handlers for low latency signal processing.
+
+Driver is shipped with Marvell SDK.
+
+Device Setup
+
+
+CNXK GPIO PMD binds to virtual device which gets created by passing
+`--vdev=cnxk_gpio,gpiochip=` command line to EAL. `gpiochip` parameter
+tells PMD which GPIO controller should be used. Available controllers are
+available under `/sys/class/gpio`. For further details on how Linux represents
+GPIOs in userspace please refer to
+`sysfs.txt `_.
+
+If `gpiochip=` was omitted then first gpiochip from the alphabetically
+sort list of available gpiochips is used.
+
+.. code-block:: console
+
+   $ ls /sys/class/gpio
+   export gpiochip448 unexport
+
+In above scenario only one GPIO controller is present hence
+`--vdev=cnxk_gpio,gpiochip=448` should be passed to EAL.
+
+Before performing actual data transfer one needs to call
+``rte_rawdev_queue_count()`` followed by ``rte_rawdev_queue_conf_get()``. The
+former returns number GPIOs available in the system irrespective of GPIOs
+being controllable or not. Thus it is user responsibility to pick the proper
+ones. The latter call simply returns queue capacity.
+
+Respective queue needs to be configured with ``rte_rawdev_queue_setup()``. This
+call barely exports GPIO to userspace.
+
+To perform actual data transfer use standard ``rte_rawdev_enqueue_buffers()``
+and ``rte_rawdev_dequeue_buffers()`` APIs. Not all messages produce sensible
+responses hence dequeueing is not always necessary.
diff --git a/doc/guides/rawdevs/index.rst b/doc/guides/rawdevs/index.rst
index b6cf917443..0c02da6e90 100644
--- a/doc/guides/rawdevs/index.rst
+++ b/doc/guides/rawdevs/index.rst
@@ -12,6 +12,7 @@ application through rawdev API.
 :numbered:
 
 cnxk_bphy
+cnxk_gpio
 dpaa2_cmdif
 dpaa2_qdma
 ifpga
diff --git a/drivers/raw/cnxk_gpio/cnxk_gpio.c 
b/drivers/raw/cnxk_gpio/cnxk_gpio.c
new file mode 100644
index 00..881615d62e
--- /dev/null
+++ b/drivers/raw/cnxk_gpio/cnxk_gpio.c
@@ -0,0 +1,239 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "cnxk_gpio.h"
+
+#define CNXK_GPIO_BUFSZ 128
+#define CNXK_GPIO_CLASS_PATH "/sys/class/gpio"
+
+static const char *const cnxk_gpio_args[] = {
+#define CNXK_GPIO_ARG_GPIOCHIP "gpiochip"
+   CNXK_GPIO_ARG_GPIOCHIP,
+   NULL
+};
+
+static void
+cnxk_gpio_format_name(char *name, size_t len)
+{
+   snprintf(name, len, "cnxk_gpio");
+}
+
+static int
+cnxk_gpio_filter_gpiochip(const struct dirent *dirent)
+{
+   const char *pattern = "gpiochip";
+
+   return !strncmp(dirent->d_name, pattern, strlen(pattern));
+}
+
+static void
+cnxk_gpio_set_defaults(struct cnxk_gpiochip *gpiochip)
+{
+   struct dirent **namelist;
+   int n;
+
+   n = scandir(CNXK_GPIO_CLASS_PATH, &namelist, cnxk_gpio_filter_gpiochip,
+

[PATCH v4 03/11] raw/cnxk_gpio: support reading queue count

2022-01-05 Thread Tomasz Duszynski
Add support for reading number of available queues. Single queue
corresponds to GPIO.

Signed-off-by: Tomasz Duszynski 
---
 drivers/raw/cnxk_gpio/cnxk_gpio.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/raw/cnxk_gpio/cnxk_gpio.c 
b/drivers/raw/cnxk_gpio/cnxk_gpio.c
index f80788f7fb..3455d6258c 100644
--- a/drivers/raw/cnxk_gpio/cnxk_gpio.c
+++ b/drivers/raw/cnxk_gpio/cnxk_gpio.c
@@ -156,8 +156,17 @@ cnxk_gpio_queue_def_conf(struct rte_rawdev *dev, uint16_t 
queue_id,
return 0;
 }
 
+static uint16_t
+cnxk_gpio_queue_count(struct rte_rawdev *dev)
+{
+   struct cnxk_gpiochip *gpiochip = dev->dev_private;
+
+   return gpiochip->num_gpios;
+}
+
 static const struct rte_rawdev_ops cnxk_gpio_rawdev_ops = {
.queue_def_conf = cnxk_gpio_queue_def_conf,
+   .queue_count = cnxk_gpio_queue_count,
 };
 
 static int
-- 
2.25.1



[PATCH v4 04/11] raw/cnxk_gpio: support queue setup

2022-01-05 Thread Tomasz Duszynski
Add support for queue setup.

Signed-off-by: Tomasz Duszynski 
---
 drivers/raw/cnxk_gpio/cnxk_gpio.c | 80 +++
 1 file changed, 80 insertions(+)

diff --git a/drivers/raw/cnxk_gpio/cnxk_gpio.c 
b/drivers/raw/cnxk_gpio/cnxk_gpio.c
index 3455d6258c..c1e74fad43 100644
--- a/drivers/raw/cnxk_gpio/cnxk_gpio.c
+++ b/drivers/raw/cnxk_gpio/cnxk_gpio.c
@@ -138,6 +138,85 @@ cnxk_gpio_read_attr_int(char *attr, int *val)
return 0;
 }
 
+static int
+cnxk_gpio_write_attr(const char *attr, const char *val)
+{
+   FILE *fp;
+   int ret;
+
+   if (!val)
+   return -EINVAL;
+
+   fp = fopen(attr, "w");
+   if (!fp)
+   return -errno;
+
+   ret = fprintf(fp, "%s", val);
+   if (ret < 0) {
+   fclose(fp);
+   return ret;
+   }
+
+   ret = fclose(fp);
+   if (ret)
+   return -errno;
+
+   return 0;
+}
+
+static int
+cnxk_gpio_write_attr_int(const char *attr, int val)
+{
+   char buf[CNXK_GPIO_BUFSZ];
+
+   snprintf(buf, sizeof(buf), "%d", val);
+
+   return cnxk_gpio_write_attr(attr, buf);
+}
+
+static struct cnxk_gpio *
+cnxk_gpio_lookup(struct cnxk_gpiochip *gpiochip, uint16_t queue)
+{
+   if (queue >= gpiochip->num_gpios)
+   return NULL;
+
+   return gpiochip->gpios[queue];
+}
+
+static int
+cnxk_gpio_queue_setup(struct rte_rawdev *dev, uint16_t queue_id,
+ rte_rawdev_obj_t queue_conf, size_t queue_conf_size)
+{
+   struct cnxk_gpiochip *gpiochip = dev->dev_private;
+   char buf[CNXK_GPIO_BUFSZ];
+   struct cnxk_gpio *gpio;
+   int ret;
+
+   RTE_SET_USED(queue_conf);
+   RTE_SET_USED(queue_conf_size);
+
+   gpio = cnxk_gpio_lookup(gpiochip, queue_id);
+   if (gpio)
+   return -EEXIST;
+
+   gpio = rte_zmalloc(NULL, sizeof(*gpio), 0);
+   if (!gpio)
+   return -ENOMEM;
+   gpio->num = queue_id + gpiochip->base;
+   gpio->gpiochip = gpiochip;
+
+   snprintf(buf, sizeof(buf), "%s/export", CNXK_GPIO_CLASS_PATH);
+   ret = cnxk_gpio_write_attr_int(buf, gpio->num);
+   if (ret) {
+   rte_free(gpio);
+   return ret;
+   }
+
+   gpiochip->gpios[queue_id] = gpio;
+
+   return 0;
+}
+
 static int
 cnxk_gpio_queue_def_conf(struct rte_rawdev *dev, uint16_t queue_id,
 rte_rawdev_obj_t queue_conf, size_t queue_conf_size)
@@ -167,6 +246,7 @@ cnxk_gpio_queue_count(struct rte_rawdev *dev)
 static const struct rte_rawdev_ops cnxk_gpio_rawdev_ops = {
.queue_def_conf = cnxk_gpio_queue_def_conf,
.queue_count = cnxk_gpio_queue_count,
+   .queue_setup = cnxk_gpio_queue_setup,
 };
 
 static int
-- 
2.25.1



[PATCH v4 05/11] raw/cnxk_gpio: support queue release

2022-01-05 Thread Tomasz Duszynski
Add support for queue release.

Signed-off-by: Tomasz Duszynski 
---
 drivers/raw/cnxk_gpio/cnxk_gpio.c | 34 +++
 1 file changed, 34 insertions(+)

diff --git a/drivers/raw/cnxk_gpio/cnxk_gpio.c 
b/drivers/raw/cnxk_gpio/cnxk_gpio.c
index c1e74fad43..71f568f7a4 100644
--- a/drivers/raw/cnxk_gpio/cnxk_gpio.c
+++ b/drivers/raw/cnxk_gpio/cnxk_gpio.c
@@ -217,6 +217,29 @@ cnxk_gpio_queue_setup(struct rte_rawdev *dev, uint16_t 
queue_id,
return 0;
 }
 
+static int
+cnxk_gpio_queue_release(struct rte_rawdev *dev, uint16_t queue_id)
+{
+   struct cnxk_gpiochip *gpiochip = dev->dev_private;
+   char buf[CNXK_GPIO_BUFSZ];
+   struct cnxk_gpio *gpio;
+   int ret;
+
+   gpio = cnxk_gpio_lookup(gpiochip, queue_id);
+   if (!gpio)
+   return -ENODEV;
+
+   snprintf(buf, sizeof(buf), "%s/unexport", CNXK_GPIO_CLASS_PATH);
+   ret = cnxk_gpio_write_attr_int(buf, gpiochip->base + queue_id);
+   if (ret)
+   return ret;
+
+   gpiochip->gpios[queue_id] = NULL;
+   rte_free(gpio);
+
+   return 0;
+}
+
 static int
 cnxk_gpio_queue_def_conf(struct rte_rawdev *dev, uint16_t queue_id,
 rte_rawdev_obj_t queue_conf, size_t queue_conf_size)
@@ -247,6 +270,7 @@ static const struct rte_rawdev_ops cnxk_gpio_rawdev_ops = {
.queue_def_conf = cnxk_gpio_queue_def_conf,
.queue_count = cnxk_gpio_queue_count,
.queue_setup = cnxk_gpio_queue_setup,
+   .queue_release = cnxk_gpio_queue_release,
 };
 
 static int
@@ -320,6 +344,8 @@ cnxk_gpio_remove(struct rte_vdev_device *dev)
char name[RTE_RAWDEV_NAME_MAX_LEN];
struct cnxk_gpiochip *gpiochip;
struct rte_rawdev *rawdev;
+   struct cnxk_gpio *gpio;
+   int i;
 
RTE_SET_USED(dev);
 
@@ -332,6 +358,14 @@ cnxk_gpio_remove(struct rte_vdev_device *dev)
return -ENODEV;
 
gpiochip = rawdev->dev_private;
+   for (i = 0; i < gpiochip->num_gpios; i++) {
+   gpio = gpiochip->gpios[i];
+   if (!gpio)
+   continue;
+
+   cnxk_gpio_queue_release(rawdev, gpio->num);
+   }
+
rte_free(gpiochip->gpios);
rte_rawdev_pmd_release(rawdev);
 
-- 
2.25.1



[PATCH v4 06/11] raw/cnxk_gpio: support enqueuing buffers

2022-01-05 Thread Tomasz Duszynski
Add dummy support for enqueuing buffers.

Signed-off-by: Tomasz Duszynski 
---
 drivers/raw/cnxk_gpio/cnxk_gpio.c | 47 +++
 drivers/raw/cnxk_gpio/cnxk_gpio.h |  1 +
 drivers/raw/cnxk_gpio/meson.build |  1 +
 drivers/raw/cnxk_gpio/rte_pmd_cnxk_gpio.h | 38 ++
 4 files changed, 87 insertions(+)
 create mode 100644 drivers/raw/cnxk_gpio/rte_pmd_cnxk_gpio.h

diff --git a/drivers/raw/cnxk_gpio/cnxk_gpio.c 
b/drivers/raw/cnxk_gpio/cnxk_gpio.c
index 71f568f7a4..235f0d6f7a 100644
--- a/drivers/raw/cnxk_gpio/cnxk_gpio.c
+++ b/drivers/raw/cnxk_gpio/cnxk_gpio.c
@@ -14,6 +14,7 @@
 #include 
 
 #include "cnxk_gpio.h"
+#include "rte_pmd_cnxk_gpio.h"
 
 #define CNXK_GPIO_BUFSZ 128
 #define CNXK_GPIO_CLASS_PATH "/sys/class/gpio"
@@ -266,7 +267,53 @@ cnxk_gpio_queue_count(struct rte_rawdev *dev)
return gpiochip->num_gpios;
 }
 
+static int
+cnxk_gpio_process_buf(struct cnxk_gpio *gpio, struct rte_rawdev_buf *rbuf)
+{
+   struct cnxk_gpio_msg *msg = rbuf->buf_addr;
+   void *rsp = NULL;
+   int ret;
+
+   switch (msg->type) {
+   default:
+   return -EINVAL;
+   }
+
+   /* get rid of last response if any */
+   if (gpio->rsp) {
+   RTE_LOG(WARNING, PMD, "previous response got overwritten\n");
+   rte_free(gpio->rsp);
+   }
+   gpio->rsp = rsp;
+
+   return ret;
+}
+
+static int
+cnxk_gpio_enqueue_bufs(struct rte_rawdev *dev, struct rte_rawdev_buf **buffers,
+  unsigned int count, rte_rawdev_obj_t context)
+{
+   struct cnxk_gpiochip *gpiochip = dev->dev_private;
+   unsigned int queue = (size_t)context;
+   struct cnxk_gpio *gpio;
+   int ret;
+
+   if (count == 0)
+   return 0;
+
+   gpio = cnxk_gpio_lookup(gpiochip, queue);
+   if (!gpio)
+   return -ENODEV;
+
+   ret = cnxk_gpio_process_buf(gpio, buffers[0]);
+   if (ret)
+   return ret;
+
+   return 1;
+}
+
 static const struct rte_rawdev_ops cnxk_gpio_rawdev_ops = {
+   .enqueue_bufs = cnxk_gpio_enqueue_bufs,
.queue_def_conf = cnxk_gpio_queue_def_conf,
.queue_count = cnxk_gpio_queue_count,
.queue_setup = cnxk_gpio_queue_setup,
diff --git a/drivers/raw/cnxk_gpio/cnxk_gpio.h 
b/drivers/raw/cnxk_gpio/cnxk_gpio.h
index 4dae8316ba..6b54ebe6e6 100644
--- a/drivers/raw/cnxk_gpio/cnxk_gpio.h
+++ b/drivers/raw/cnxk_gpio/cnxk_gpio.h
@@ -9,6 +9,7 @@ struct cnxk_gpiochip;
 
 struct cnxk_gpio {
struct cnxk_gpiochip *gpiochip;
+   void *rsp;
int num;
 };
 
diff --git a/drivers/raw/cnxk_gpio/meson.build 
b/drivers/raw/cnxk_gpio/meson.build
index 9a7e716c1e..3fbfdd838c 100644
--- a/drivers/raw/cnxk_gpio/meson.build
+++ b/drivers/raw/cnxk_gpio/meson.build
@@ -6,3 +6,4 @@ deps += ['bus_vdev', 'common_cnxk', 'rawdev', 'kvargs']
 sources = files(
 'cnxk_gpio.c',
 )
+headers = files('rte_pmd_cnxk_gpio.h')
diff --git a/drivers/raw/cnxk_gpio/rte_pmd_cnxk_gpio.h 
b/drivers/raw/cnxk_gpio/rte_pmd_cnxk_gpio.h
new file mode 100644
index 00..c71065e10c
--- /dev/null
+++ b/drivers/raw/cnxk_gpio/rte_pmd_cnxk_gpio.h
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#ifndef _RTE_PMD_CNXK_GPIO_H_
+#define _RTE_PMD_CNXK_GPIO_H_
+
+/**
+ * @file rte_pmd_cnxk_gpio.h
+ *
+ * Marvell GPIO PMD specific structures and interface
+ *
+ * This API allows applications to manage GPIOs in user space along with
+ * installing interrupt handlers for low latency signal processing.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** Available message types */
+enum cnxk_gpio_msg_type {
+   /** Invalid message type */
+   CNXK_GPIO_MSG_TYPE_INVALID,
+};
+
+struct cnxk_gpio_msg {
+   /** Message type */
+   enum cnxk_gpio_msg_type type;
+   /** Message data passed to PMD or received from PMD */
+   void *data;
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTE_PMD_CNXK_GPIO_H_ */
-- 
2.25.1



[PATCH v4 07/11] raw/cnxk_gpio: support dequeuing buffers

2022-01-05 Thread Tomasz Duszynski
Add support for dequeuing buffers.

Signed-off-by: Tomasz Duszynski 
---
 drivers/raw/cnxk_gpio/cnxk_gpio.c | 26 ++
 1 file changed, 26 insertions(+)

diff --git a/drivers/raw/cnxk_gpio/cnxk_gpio.c 
b/drivers/raw/cnxk_gpio/cnxk_gpio.c
index 235f0d6f7a..909fa9d390 100644
--- a/drivers/raw/cnxk_gpio/cnxk_gpio.c
+++ b/drivers/raw/cnxk_gpio/cnxk_gpio.c
@@ -312,8 +312,34 @@ cnxk_gpio_enqueue_bufs(struct rte_rawdev *dev, struct 
rte_rawdev_buf **buffers,
return 1;
 }
 
+static int
+cnxk_gpio_dequeue_bufs(struct rte_rawdev *dev, struct rte_rawdev_buf **buffers,
+  unsigned int count, rte_rawdev_obj_t context)
+{
+   struct cnxk_gpiochip *gpiochip = dev->dev_private;
+   unsigned int queue = (size_t)context;
+   struct cnxk_gpio *gpio;
+
+   if (count == 0)
+   return 0;
+
+   gpio = cnxk_gpio_lookup(gpiochip, queue);
+   if (!gpio)
+   return -ENODEV;
+
+   if (gpio->rsp) {
+   buffers[0]->buf_addr = gpio->rsp;
+   gpio->rsp = NULL;
+
+   return 1;
+   }
+
+   return 0;
+}
+
 static const struct rte_rawdev_ops cnxk_gpio_rawdev_ops = {
.enqueue_bufs = cnxk_gpio_enqueue_bufs,
+   .dequeue_bufs = cnxk_gpio_dequeue_bufs,
.queue_def_conf = cnxk_gpio_queue_def_conf,
.queue_count = cnxk_gpio_queue_count,
.queue_setup = cnxk_gpio_queue_setup,
-- 
2.25.1



[PATCH v4 08/11] raw/cnxk_gpio: support standard GPIO operations

2022-01-05 Thread Tomasz Duszynski
Add support for standard GPIO operations i.e ones normally
provided by GPIO sysfs interface.

Signed-off-by: Tomasz Duszynski 
---
 doc/guides/rawdevs/cnxk_gpio.rst  |  98 
 drivers/raw/cnxk_gpio/cnxk_gpio.c | 147 +++-
 drivers/raw/cnxk_gpio/rte_pmd_cnxk_gpio.h | 279 +-
 3 files changed, 521 insertions(+), 3 deletions(-)

diff --git a/doc/guides/rawdevs/cnxk_gpio.rst b/doc/guides/rawdevs/cnxk_gpio.rst
index 868302d07f..f6c3c942c5 100644
--- a/doc/guides/rawdevs/cnxk_gpio.rst
+++ b/doc/guides/rawdevs/cnxk_gpio.rst
@@ -63,3 +63,101 @@ call barely exports GPIO to userspace.
 To perform actual data transfer use standard ``rte_rawdev_enqueue_buffers()``
 and ``rte_rawdev_dequeue_buffers()`` APIs. Not all messages produce sensible
 responses hence dequeueing is not always necessary.
+
+CNXK GPIO PMD
+-
+
+PMD accepts ``struct cnxk_gpio_msg`` messages which differ by type and payload.
+Message types along with description are listed below. As for the usage 
examples
+please refer to ``cnxk_gpio_selftest()``. There's a set of convenient wrappers
+available, one for each existing command.
+
+Set GPIO value
+~~
+
+Message is used to set output to low or high. This does not work for GPIOs
+configured as input.
+
+Message must have type set to ``CNXK_GPIO_MSG_TYPE_SET_PIN_VALUE``.
+
+Payload must be an integer set to 0 (low) or 1 (high).
+
+Consider using ``rte_pmd_gpio_set_pin_value()`` wrapper.
+
+Set GPIO edge
+~
+
+Message is used to set edge that triggers interrupt.
+
+Message must have type set to ``CNXK_GPIO_MSG_TYPE_SET_PIN_EDGE``.
+
+Payload must be `enum cnxk_gpio_pin_edge`.
+
+Consider using ``rte_pmd_gpio_set_pin_edge()`` wrapper.
+
+Set GPIO direction
+~~
+
+Message is used to change GPIO direction to either input or output.
+
+Message must have type set to ``CNXK_GPIO_MSG_TYPE_SET_PIN_DIR``.
+
+Payload must be `enum cnxk_gpio_pin_dir`.
+
+Consider using ``rte_pmd_gpio_set_pin_dir()`` wrapper.
+
+Set GPIO active low
+~~~
+
+Message is used to set whether pin is active low.
+
+Message must have type set to ``CNXK_GPIO_MSG_TYPE_SET_PIN_ACTIVE_LOW``.
+
+Payload must be an integer set to 0 or 1. The latter activates inversion.
+
+Consider using ``rte_pmd_gpio_set_pin_active_low()`` wrapper.
+
+Get GPIO value
+~~
+
+Message is used to read GPIO value. Value can be 0 (low) or 1 (high).
+
+Message must have type set to ``CNXK_GPIO_MSG_TYPE_GET_PIN_VALUE``.
+
+Payload contains integer set to either 0 or 1.
+
+Consider using ``rte_pmd_gpio_get_pin_value()`` wrapper.
+
+Get GPIO edge
+~
+
+Message is used to read GPIO edge.
+
+Message must have type set to ``CNXK_GPIO_MSG_TYPE_GET_PIN_EDGE``.
+
+Payload contains `enum cnxk_gpio_pin_edge`.
+
+Consider using ``rte_pmd_gpio_get_pin_edge()`` wrapper.
+
+Get GPIO direction
+~~
+
+Message is used to read GPIO direction.
+
+Message must have type set to ``CNXK_GPIO_MSG_TYPE_GET_PIN_DIR``.
+
+Payload contains `enum cnxk_gpio_pin_dir`.
+
+Consider using ``rte_pmd_gpio_get_pin_dir()`` wrapper.
+
+Get GPIO active low
+~~~
+
+Message is used check whether inverted logic is active.
+
+Message must have type set to ``CNXK_GPIO_MSG_TYPE_GET_PIN_ACTIVE_LOW``.
+
+Payload contains an integer set to 0 or 1. The latter means inverted logic
+is turned on.
+
+Consider using ``rte_pmd_gpio_get_pin_active_low()`` wrapper.
diff --git a/drivers/raw/cnxk_gpio/cnxk_gpio.c 
b/drivers/raw/cnxk_gpio/cnxk_gpio.c
index 909fa9d390..e24d8c1b6e 100644
--- a/drivers/raw/cnxk_gpio/cnxk_gpio.c
+++ b/drivers/raw/cnxk_gpio/cnxk_gpio.c
@@ -267,14 +267,159 @@ cnxk_gpio_queue_count(struct rte_rawdev *dev)
return gpiochip->num_gpios;
 }
 
+static const struct {
+   enum cnxk_gpio_pin_edge edge;
+   const char *name;
+} cnxk_gpio_edge_name[] = {
+   { CNXK_GPIO_PIN_EDGE_NONE, "none" },
+   { CNXK_GPIO_PIN_EDGE_FALLING, "falling" },
+   { CNXK_GPIO_PIN_EDGE_RISING, "rising" },
+   { CNXK_GPIO_PIN_EDGE_BOTH, "both" },
+};
+
+static const char *
+cnxk_gpio_edge_to_name(enum cnxk_gpio_pin_edge edge)
+{
+   unsigned int i;
+
+   for (i = 0; i < RTE_DIM(cnxk_gpio_edge_name); i++) {
+   if (cnxk_gpio_edge_name[i].edge == edge)
+   return cnxk_gpio_edge_name[i].name;
+   }
+
+   return NULL;
+}
+
+static enum cnxk_gpio_pin_edge
+cnxk_gpio_name_to_edge(const char *name)
+{
+   unsigned int i;
+
+   for (i = 0; i < RTE_DIM(cnxk_gpio_edge_name); i++) {
+   if (!strcmp(cnxk_gpio_edge_name[i].name, name))
+   break;
+   }
+
+   return cnxk_gpio_edge_name[i].edge;
+}
+
+static const struct {
+   enum cnxk_gpio_pin_dir dir;
+   const char *name;
+} cnxk_gpio_dir_name[] = {
+   { CNXK_GPIO_PIN_DIR_IN, "in" },
+   { CNXK_GPIO_PIN_DIR_OUT, "out" },
+   { CNXK_GPIO_PIN_DIR_HIGH, "high" },
+   { CNXK_GPIO_PI

[PATCH v4 09/11] raw/cnxk_gpio: support custom irq handlers

2022-01-05 Thread Tomasz Duszynski
Add support for custom interrupt handlers. Custom interrupt
handlers bypass kernel completely and are meant for fast
and low latency access to GPIO state.

Signed-off-by: Tomasz Duszynski 
---
 doc/guides/rawdevs/cnxk_gpio.rst  |  21 +++
 drivers/raw/cnxk_gpio/cnxk_gpio.c |  37 
 drivers/raw/cnxk_gpio/cnxk_gpio.h |   8 +
 drivers/raw/cnxk_gpio/cnxk_gpio_irq.c | 216 ++
 drivers/raw/cnxk_gpio/meson.build |   1 +
 drivers/raw/cnxk_gpio/rte_pmd_cnxk_gpio.h | 116 
 6 files changed, 399 insertions(+)
 create mode 100644 drivers/raw/cnxk_gpio/cnxk_gpio_irq.c

diff --git a/doc/guides/rawdevs/cnxk_gpio.rst b/doc/guides/rawdevs/cnxk_gpio.rst
index f6c3c942c5..ad93ec0d44 100644
--- a/doc/guides/rawdevs/cnxk_gpio.rst
+++ b/doc/guides/rawdevs/cnxk_gpio.rst
@@ -161,3 +161,24 @@ Payload contains an integer set to 0 or 1. The latter 
means inverted logic
 is turned on.
 
 Consider using ``rte_pmd_gpio_get_pin_active_low()`` wrapper.
+
+Request interrupt
+~
+
+Message is used to install custom interrupt handler.
+
+Message must have type set to ``CNXK_GPIO_MSG_TYPE_REGISTER_IRQ``.
+
+Payload needs to be set to ``struct cnxk_gpio_irq`` which describes interrupt
+being requested.
+
+Consider using ``rte_pmd_gpio_register_gpio()`` wrapper.
+
+Free interrupt
+~~
+
+Message is used to remove installed interrupt handler.
+
+Message must have type set to ``CNXK_GPIO_MSG_TYPE_UNREGISTER_IRQ``.
+
+Consider using ``rte_pmd_gpio_unregister_gpio()`` wrapper.
diff --git a/drivers/raw/cnxk_gpio/cnxk_gpio.c 
b/drivers/raw/cnxk_gpio/cnxk_gpio.c
index e24d8c1b6e..b30427c01c 100644
--- a/drivers/raw/cnxk_gpio/cnxk_gpio.c
+++ b/drivers/raw/cnxk_gpio/cnxk_gpio.c
@@ -339,6 +339,28 @@ cnxk_gpio_name_to_dir(const char *name)
return cnxk_gpio_dir_name[i].dir;
 }
 
+static int
+cnxk_gpio_register_irq(struct cnxk_gpio *gpio, struct cnxk_gpio_irq *irq)
+{
+   int ret;
+
+   ret = cnxk_gpio_irq_request(gpio->num - gpio->gpiochip->base, irq->cpu);
+   if (ret)
+   return ret;
+
+   gpio->handler = irq->handler;
+   gpio->data = irq->data;
+   gpio->cpu = irq->cpu;
+
+   return 0;
+}
+
+static int
+cnxk_gpio_unregister_irq(struct cnxk_gpio *gpio)
+{
+   return cnxk_gpio_irq_free(gpio->num - gpio->gpiochip->base);
+}
+
 static int
 cnxk_gpio_process_buf(struct cnxk_gpio *gpio, struct rte_rawdev_buf *rbuf)
 {
@@ -420,6 +442,13 @@ cnxk_gpio_process_buf(struct cnxk_gpio *gpio, struct 
rte_rawdev_buf *rbuf)
 
*(int *)rsp = val;
break;
+   case CNXK_GPIO_MSG_TYPE_REGISTER_IRQ:
+   ret = cnxk_gpio_register_irq(gpio,
+(struct cnxk_gpio_irq *)msg->data);
+   break;
+   case CNXK_GPIO_MSG_TYPE_UNREGISTER_IRQ:
+   ret = cnxk_gpio_unregister_irq(gpio);
+   break;
default:
return -EINVAL;
}
@@ -523,6 +552,10 @@ cnxk_gpio_probe(struct rte_vdev_device *dev)
if (ret)
goto out;
 
+   ret = cnxk_gpio_irq_init(gpiochip);
+   if (ret)
+   goto out;
+
/* read gpio base */
snprintf(buf, sizeof(buf), "%s/gpiochip%d/base", CNXK_GPIO_CLASS_PATH,
 gpiochip->num);
@@ -581,10 +614,14 @@ cnxk_gpio_remove(struct rte_vdev_device *dev)
if (!gpio)
continue;
 
+   if (gpio->handler)
+   cnxk_gpio_unregister_irq(gpio);
+
cnxk_gpio_queue_release(rawdev, gpio->num);
}
 
rte_free(gpiochip->gpios);
+   cnxk_gpio_irq_fini();
rte_rawdev_pmd_release(rawdev);
 
return 0;
diff --git a/drivers/raw/cnxk_gpio/cnxk_gpio.h 
b/drivers/raw/cnxk_gpio/cnxk_gpio.h
index 6b54ebe6e6..c052ca5735 100644
--- a/drivers/raw/cnxk_gpio/cnxk_gpio.h
+++ b/drivers/raw/cnxk_gpio/cnxk_gpio.h
@@ -11,6 +11,9 @@ struct cnxk_gpio {
struct cnxk_gpiochip *gpiochip;
void *rsp;
int num;
+   void (*handler)(int gpio, void *data);
+   void *data;
+   int cpu;
 };
 
 struct cnxk_gpiochip {
@@ -20,4 +23,9 @@ struct cnxk_gpiochip {
struct cnxk_gpio **gpios;
 };
 
+int cnxk_gpio_irq_init(struct cnxk_gpiochip *gpiochip);
+void cnxk_gpio_irq_fini(void);
+int cnxk_gpio_irq_request(int gpio, int cpu);
+int cnxk_gpio_irq_free(int gpio);
+
 #endif /* _CNXK_GPIO_H_ */
diff --git a/drivers/raw/cnxk_gpio/cnxk_gpio_irq.c 
b/drivers/raw/cnxk_gpio/cnxk_gpio_irq.c
new file mode 100644
index 00..2fa8e69899
--- /dev/null
+++ b/drivers/raw/cnxk_gpio/cnxk_gpio_irq.c
@@ -0,0 +1,216 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+
+#include "cnxk_gpio.h"
+
+#define OTX_IOC_MAGIC 0xF2
+#define OTX_IOC_SET_GPIO_HANDLER   
\
+  

[PATCH v4 10/11] raw/cnxk_gpio: support selftest

2022-01-05 Thread Tomasz Duszynski
Add support for performing selftest.

Signed-off-by: Tomasz Duszynski 
---
 doc/guides/rawdevs/cnxk_gpio.rst   |  11 +
 drivers/raw/cnxk_gpio/cnxk_gpio.c  |   1 +
 drivers/raw/cnxk_gpio/cnxk_gpio.h  |   2 +
 drivers/raw/cnxk_gpio/cnxk_gpio_selftest.c | 386 +
 drivers/raw/cnxk_gpio/meson.build  |   1 +
 5 files changed, 401 insertions(+)
 create mode 100644 drivers/raw/cnxk_gpio/cnxk_gpio_selftest.c

diff --git a/doc/guides/rawdevs/cnxk_gpio.rst b/doc/guides/rawdevs/cnxk_gpio.rst
index ad93ec0d44..c03a5b937c 100644
--- a/doc/guides/rawdevs/cnxk_gpio.rst
+++ b/doc/guides/rawdevs/cnxk_gpio.rst
@@ -182,3 +182,14 @@ Message is used to remove installed interrupt handler.
 Message must have type set to ``CNXK_GPIO_MSG_TYPE_UNREGISTER_IRQ``.
 
 Consider using ``rte_pmd_gpio_unregister_gpio()`` wrapper.
+
+Self test
+-
+
+On EAL initialization CNXK GPIO device will be probed and populated into
+the list of raw devices on condition ``--vdev=cnxk_gpio,gpiochip=`` was
+passed. ``rte_rawdev_get_dev_id("CNXK_GPIO")`` returns unique device id. Use
+this identifier for further rawdev function calls.
+
+Selftest rawdev API can be used to verify the PMD functionality. Note it 
blindly
+assumes that all GPIOs are controllable so some errors during test are 
expected.
diff --git a/drivers/raw/cnxk_gpio/cnxk_gpio.c 
b/drivers/raw/cnxk_gpio/cnxk_gpio.c
index b30427c01c..16a886b693 100644
--- a/drivers/raw/cnxk_gpio/cnxk_gpio.c
+++ b/drivers/raw/cnxk_gpio/cnxk_gpio.c
@@ -518,6 +518,7 @@ static const struct rte_rawdev_ops cnxk_gpio_rawdev_ops = {
.queue_count = cnxk_gpio_queue_count,
.queue_setup = cnxk_gpio_queue_setup,
.queue_release = cnxk_gpio_queue_release,
+   .dev_selftest = cnxk_gpio_selftest,
 };
 
 static int
diff --git a/drivers/raw/cnxk_gpio/cnxk_gpio.h 
b/drivers/raw/cnxk_gpio/cnxk_gpio.h
index c052ca5735..1b31b5a486 100644
--- a/drivers/raw/cnxk_gpio/cnxk_gpio.h
+++ b/drivers/raw/cnxk_gpio/cnxk_gpio.h
@@ -23,6 +23,8 @@ struct cnxk_gpiochip {
struct cnxk_gpio **gpios;
 };
 
+int cnxk_gpio_selftest(uint16_t dev_id);
+
 int cnxk_gpio_irq_init(struct cnxk_gpiochip *gpiochip);
 void cnxk_gpio_irq_fini(void);
 int cnxk_gpio_irq_request(int gpio, int cpu);
diff --git a/drivers/raw/cnxk_gpio/cnxk_gpio_selftest.c 
b/drivers/raw/cnxk_gpio/cnxk_gpio_selftest.c
new file mode 100644
index 00..6502902f86
--- /dev/null
+++ b/drivers/raw/cnxk_gpio/cnxk_gpio_selftest.c
@@ -0,0 +1,386 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include "cnxk_gpio.h"
+#include "rte_pmd_cnxk_gpio.h"
+
+#define CNXK_GPIO_BUFSZ 128
+
+#define OTX_IOC_MAGIC 0xF2
+#define OTX_IOC_TRIGGER_GPIO_HANDLER   
\
+   _IO(OTX_IOC_MAGIC, 3)
+
+static int fd;
+
+static int
+cnxk_gpio_attr_exists(const char *attr)
+{
+   struct stat st;
+
+   return !stat(attr, &st);
+}
+
+static int
+cnxk_gpio_read_attr(char *attr, char *val)
+{
+   FILE *fp;
+   int ret;
+
+   fp = fopen(attr, "r");
+   if (!fp)
+   return -errno;
+
+   ret = fscanf(fp, "%s", val);
+   if (ret < 0)
+   return -errno;
+   if (ret != 1)
+   return -EIO;
+
+   ret = fclose(fp);
+   if (ret)
+   return -errno;
+
+   return 0;
+}
+
+#define CNXK_GPIO_ERR_STR(err, str, ...) do {  
\
+   if (err) { \
+   RTE_LOG(ERR, PMD, "%s:%d: " str " (%d)\n", __func__, __LINE__, \
+   ##__VA_ARGS__, err);   \
+   goto out;  \
+   }  \
+} while (0)
+
+static int
+cnxk_gpio_validate_attr(char *attr, const char *expected)
+{
+   char buf[CNXK_GPIO_BUFSZ];
+   int ret;
+
+   ret = cnxk_gpio_read_attr(attr, buf);
+   if (ret)
+   return ret;
+
+   if (strncmp(buf, expected, sizeof(buf)))
+   return -EIO;
+
+   return 0;
+}
+
+#define CNXK_GPIO_PATH_FMT "/sys/class/gpio/gpio%d"
+
+static int
+cnxk_gpio_test_input(uint16_t dev_id, int base, int gpio)
+{
+   char buf[CNXK_GPIO_BUFSZ];
+   int ret, n;
+
+   n = snprintf(buf, sizeof(buf), CNXK_GPIO_PATH_FMT, base + gpio);
+   snprintf(buf + n, sizeof(buf) - n, "/direction");
+
+   ret = rte_pmd_gpio_set_pin_dir(dev_id, gpio, CNXK_GPIO_PIN_DIR_IN);
+   CNXK_GPIO_ERR_STR(ret, "failed to set dir to input");
+   ret = cnxk_gpio_validate_attr(buf, "in");
+   CNXK_GPIO_ERR_STR(ret, "failed to validate %s", buf);
+
+   ret = rte_pmd_gpio_set_pin_value(dev_id, gpio, 1) |
+ rte_pmd_gpio_set_pin_value(dev_id, gpio, 0);
+   if (!re

[PATCH v4 11/11] raw/cnxk_gpio: add option to allow using subset of GPIOs

2022-01-05 Thread Tomasz Duszynski
Add PMD parameter that allows one to select only subset of available
GPIOs.

This might be useful in cases where some GPIOs are already reserved yet
still available for userspace access but particular app should not touch
them.

Signed-off-by: Tomasz Duszynski 
Reviewed-by: Jerin Jacob Kollanukkaran 
---
 doc/guides/rawdevs/cnxk_gpio.rst   |   5 +
 drivers/raw/cnxk_gpio/cnxk_gpio.c  | 173 +
 drivers/raw/cnxk_gpio/cnxk_gpio.h  |   2 +
 drivers/raw/cnxk_gpio/cnxk_gpio_selftest.c |  20 +--
 drivers/raw/cnxk_gpio/rte_pmd_cnxk_gpio.h  |   8 +
 5 files changed, 170 insertions(+), 38 deletions(-)

diff --git a/doc/guides/rawdevs/cnxk_gpio.rst b/doc/guides/rawdevs/cnxk_gpio.rst
index c03a5b937c..adff535a77 100644
--- a/doc/guides/rawdevs/cnxk_gpio.rst
+++ b/doc/guides/rawdevs/cnxk_gpio.rst
@@ -57,6 +57,11 @@ former returns number GPIOs available in the system 
irrespective of GPIOs
 being controllable or not. Thus it is user responsibility to pick the proper
 ones. The latter call simply returns queue capacity.
 
+In order to allow using only subset of available GPIOs `allowlist` PMD param 
may
+be used. For example passing 
`--vdev=cnxk_gpio,gpiochip=448,allowlist=[0,1,2,3]`
+to EAL will deny using all GPIOs except those specified explicitly in the
+`allowlist`.
+
 Respective queue needs to be configured with ``rte_rawdev_queue_setup()``. This
 call barely exports GPIO to userspace.
 
diff --git a/drivers/raw/cnxk_gpio/cnxk_gpio.c 
b/drivers/raw/cnxk_gpio/cnxk_gpio.c
index 16a886b693..0951899a45 100644
--- a/drivers/raw/cnxk_gpio/cnxk_gpio.c
+++ b/drivers/raw/cnxk_gpio/cnxk_gpio.c
@@ -22,9 +22,13 @@
 static const char *const cnxk_gpio_args[] = {
 #define CNXK_GPIO_ARG_GPIOCHIP "gpiochip"
CNXK_GPIO_ARG_GPIOCHIP,
+#define CNXK_GPIO_ARG_ALLOWLIST "allowlist"
+   CNXK_GPIO_ARG_ALLOWLIST,
NULL
 };
 
+static char *allowlist;
+
 static void
 cnxk_gpio_format_name(char *name, size_t len)
 {
@@ -73,13 +77,23 @@ cnxk_gpio_parse_arg_gpiochip(const char *key __rte_unused, 
const char *value,
 }
 
 static int
-cnxk_gpio_parse_args(struct cnxk_gpiochip *gpiochip,
-struct rte_devargs *devargs)
+cnxk_gpio_parse_arg_allowlist(const char *key __rte_unused, const char *value,
+ void *extra_args __rte_unused)
+{
+   allowlist = strdup(value);
+   if (!allowlist)
+   return -ENOMEM;
+
+   return 0;
+}
+
+static int
+cnxk_gpio_parse_args(struct cnxk_gpiochip *gpiochip, const char *args)
 {
struct rte_kvargs *kvlist;
int ret;
 
-   kvlist = rte_kvargs_parse(devargs->args, cnxk_gpio_args);
+   kvlist = rte_kvargs_parse(args, cnxk_gpio_args);
if (!kvlist)
return 0;
 
@@ -92,6 +106,14 @@ cnxk_gpio_parse_args(struct cnxk_gpiochip *gpiochip,
goto out;
}
 
+   ret = rte_kvargs_count(kvlist, CNXK_GPIO_ARG_ALLOWLIST);
+   if (ret == 1) {
+   ret = rte_kvargs_process(kvlist, CNXK_GPIO_ARG_ALLOWLIST,
+cnxk_gpio_parse_arg_allowlist, NULL);
+   if (ret)
+   goto out;
+   }
+
ret = 0;
 out:
rte_kvargs_free(kvlist);
@@ -99,6 +121,60 @@ cnxk_gpio_parse_args(struct cnxk_gpiochip *gpiochip,
return ret;
 }
 
+static int
+cnxk_gpio_parse_allowlist(struct cnxk_gpiochip *gpiochip)
+{
+   int i, ret, val, queue = 0;
+   char *token;
+   int *list;
+
+   list = rte_calloc(NULL, gpiochip->num_gpios, sizeof(*list), 0);
+   if (!list)
+   return -ENOMEM;
+
+   /* replace brackets with something meaningless for strtol() */
+   allowlist[0] = ' ';
+   allowlist[strlen(allowlist) - 1] = ' ';
+
+   /* quiesce -Wcast-qual */
+   token = strtok((char *)(uintptr_t)allowlist, ",");
+   do {
+   errno = 0;
+   val = strtol(token, NULL, 10);
+   if (errno) {
+   RTE_LOG(ERR, PMD, "failed to parse %s\n", token);
+   ret = -errno;
+   goto out;
+   }
+
+   if (val < 0 || val >= gpiochip->num_gpios) {
+   RTE_LOG(ERR, PMD, "gpio%d out of 0-%d range\n", val,
+   gpiochip->num_gpios - 1);
+   ret = -EINVAL;
+   goto out;
+   }
+
+   for (i = 0; i < queue; i++) {
+   if (list[i] != val)
+   continue;
+
+   RTE_LOG(WARNING, PMD, "gpio%d already allowed\n", val);
+   break;
+   }
+   if (i == queue)
+   list[queue++] = val;
+   } while ((token = strtok(NULL, ",")));
+
+   gpiochip->allowlist = list;
+   gpiochip->num_queues = queue;
+
+   return 0;
+out:
+   rte_free(list);
+
+   return ret;
+}
+
 static int
 cnxk

Re: Add timestamp to dpdk.log

2022-01-05 Thread Stephen Hemminger
Your message is garbaled with lots of bogus URL's. Please avoid HTML mail
or weird links.

I use this. There was a more general version submitted as a patch to
DPDK but no one seemed interested.  The reason for redirecting stdout
is that are libraries we use that print to stdout and want to get timestamps
from them if debugging startup issues.


/*
 * Sample of redirecting DPDK log stream.
 *
 * If program is run for debugging then stdout will be a console and
 * put messages onto console stream with timestamps.  Otherwise, just
 * put message onto stderr which systemd journal handles.  No need for
 * syslog because that causes duplicate messages.
 */

static struct timespec log_t0; /* Start program in monotonic time */

/*
 * Write message to standard output with timestamp.
 * Use writev() so that timestamp and message do not get interleaved.
 */
static ssize_t
dpdk_log_tty_write(__rte_unused void *ctx, const char *buf, size_t size)
{
struct timespec ts;
struct iovec iov[2];
char tbuf[64];

/* format up monotonic timestamp */
clock_gettime(CLOCK_MONOTONIC, &ts);

ts.tv_sec -= log_t0.tv_sec;
ts.tv_nsec -= log_t0.tv_nsec;
if (ts.tv_nsec < 0) {
--ts.tv_sec;
ts.tv_nsec += NS_PER_S;
}

iov[0].iov_base = tbuf;
iov[0].iov_len  = snprintf(tbuf, sizeof(tbuf), "[%8lu.%06lu] ",
   ts.tv_sec, ts.tv_nsec / 1000u);

/* extra cast is workaround to remove const qualifier */
iov[1].iov_base = (void *)(uintptr_t)buf;
iov[1].iov_len = size;

return writev(STDOUT_FILENO, iov, 2);
}

static cookie_io_functions_t dpdk_log_tty_func = {
.write = dpdk_log_tty_write,
};

/*
 * Print message to stderr with priority format so that 
 * Systemd journal can handle it. Alternative would be
 * to use syslog or use sd_journal; but less is more.
 */
static ssize_t
dpdk_log_write(__rte_unused void *ctx, const char *buf, size_t size)
{
/* Syslog error levels are from 0 to 7, DPDK uses 1 to 8 */
int priority = rte_log_cur_msg_loglevel() - 1;

fprintf(stderr, "<%i>%.*s\n", priority, (int)size, buf);
return size;
}

static cookie_io_functions_t dpdk_log_func = {
.write = dpdk_log_write,
};

/*
 * Override default DPDK logging which duplicates messages
 * to both stderr and syslog.
 */
static void log_init(void)
{
backplane_logtype = rte_log_register("backplane");
if (backplane_logtype >= 0)
rte_log_set_level(backplane_logtype, RTE_LOG_INFO);

if (isatty(STDOUT_FILENO)) {
clock_gettime(CLOCK_MONOTONIC, &log_t0);

stdout = fopencookie(NULL, "w+", dpdk_log_tty_func);
setlinebuf(stdout);
rte_openlog_stream(stdout);
} else {
FILE *jf;

jf = fopencookie(NULL, "w+", dpdk_log_func);
rte_openlog_stream(jf);
}
}

/* Put DPDK log back onto stderr */
static void log_uninit(void)
{
FILE *logf;

logf = rte_log_get_stream();
if (logf != stderr) {
rte_openlog_stream(stderr);
fclose(logf);
}
}


[PATCH] doc: simplify baseband features matrix

2022-01-05 Thread Thomas Monjalon
The "feature" BBDEV API is useless as all baseband drivers
must implement it by definition.

The non-implemented features should not be marked with "N".
Keeping them blank is clearer to read in the resulting matrix.

Signed-off-by: Thomas Monjalon 
---
 doc/guides/bbdevs/features/acc100.ini| 1 -
 doc/guides/bbdevs/features/default.ini   | 1 -
 doc/guides/bbdevs/features/fpga_5gnr_fec.ini | 1 -
 doc/guides/bbdevs/features/fpga_lte_fec.ini  | 1 -
 doc/guides/bbdevs/features/la12xx.ini| 4 
 doc/guides/bbdevs/features/null.ini  | 1 -
 doc/guides/bbdevs/features/turbo_sw.ini  | 1 -
 7 files changed, 10 deletions(-)

diff --git a/doc/guides/bbdevs/features/acc100.ini 
b/doc/guides/bbdevs/features/acc100.ini
index 642cd48818..61a31065e1 100644
--- a/doc/guides/bbdevs/features/acc100.ini
+++ b/doc/guides/bbdevs/features/acc100.ini
@@ -11,4 +11,3 @@ LDPC Encoder (5G)  = Y
 LLR/HARQ Compression   = Y
 External DDR Access= Y
 HW Accelerated = Y
-BBDEV API  = Y
diff --git a/doc/guides/bbdevs/features/default.ini 
b/doc/guides/bbdevs/features/default.ini
index 5fe267a625..494be5e400 100644
--- a/doc/guides/bbdevs/features/default.ini
+++ b/doc/guides/bbdevs/features/default.ini
@@ -13,4 +13,3 @@ LDPC Encoder (5G)  =
 LLR/HARQ Compression   =
 External DDR Access=
 HW Accelerated =
-BBDEV API  =
diff --git a/doc/guides/bbdevs/features/fpga_5gnr_fec.ini 
b/doc/guides/bbdevs/features/fpga_5gnr_fec.ini
index 7a0b8d4e75..66c9139409 100644
--- a/doc/guides/bbdevs/features/fpga_5gnr_fec.ini
+++ b/doc/guides/bbdevs/features/fpga_5gnr_fec.ini
@@ -8,4 +8,3 @@ LDPC Decoder (5G)  = Y
 LDPC Encoder (5G)  = Y
 External DDR Access= Y
 HW Accelerated = Y
-BBDEV API  = Y
diff --git a/doc/guides/bbdevs/features/fpga_lte_fec.ini 
b/doc/guides/bbdevs/features/fpga_lte_fec.ini
index f1cfb924a2..c3c398312b 100644
--- a/doc/guides/bbdevs/features/fpga_lte_fec.ini
+++ b/doc/guides/bbdevs/features/fpga_lte_fec.ini
@@ -7,4 +7,3 @@
 Turbo Decoder (4G) = Y
 Turbo Encoder (4G) = Y
 HW Accelerated = Y
-BBDEV API  = Y
diff --git a/doc/guides/bbdevs/features/la12xx.ini 
b/doc/guides/bbdevs/features/la12xx.ini
index 0aec5eecb6..70c11990b7 100644
--- a/doc/guides/bbdevs/features/la12xx.ini
+++ b/doc/guides/bbdevs/features/la12xx.ini
@@ -4,10 +4,6 @@
 ; Refer to default.ini for the full list of available PMD features.
 ;
 [Features]
-Turbo Decoder (4G) = N
-Turbo Encoder (4G) = N
 LDPC Decoder (5G)  = Y
 LDPC Encoder (5G)  = Y
-LLR/HARQ Compression   = N
 HW Accelerated = Y
-BBDEV API  = Y
diff --git a/doc/guides/bbdevs/features/null.ini 
b/doc/guides/bbdevs/features/null.ini
index d9bbda9cf0..50648cdecb 100644
--- a/doc/guides/bbdevs/features/null.ini
+++ b/doc/guides/bbdevs/features/null.ini
@@ -4,4 +4,3 @@
 ; Refer to default.ini for the full list of available PMD features.
 ;
 [Features]
-BBDEV API  = Y
diff --git a/doc/guides/bbdevs/features/turbo_sw.ini 
b/doc/guides/bbdevs/features/turbo_sw.ini
index 2c7075e212..1d908d3ceb 100644
--- a/doc/guides/bbdevs/features/turbo_sw.ini
+++ b/doc/guides/bbdevs/features/turbo_sw.ini
@@ -8,4 +8,3 @@ Turbo Decoder (4G) = Y
 Turbo Encoder (4G) = Y
 LDPC Decoder (5G)  = Y
 LDPC Encoder (5G)  = Y
-BBDEV API  = Y
-- 
2.34.1



Re: Add timestamp to dpdk.log

2022-01-05 Thread Stephen Hemminger
On Wed, 5 Jan 2022 17:42:49 +
Soumya Muralidhar  wrote:

> Hi Stephen,
> 
> Thanks for getting back. But I am looking at storing logs with timestamps in 
> a file, basically something similar to syslog. Could you help me with that ?
> 
> Regards,
> Soumya
> 
> On 1/5/22, 8:17 AM, "Stephen Hemminger"  wrote:
> 
> WARNING: This email originated from outside of Gigamon. Use caution with 
> any links or attachments.
> 
> 
> Your message is garbaled with lots of bogus URL's. Please avoid HTML mail
> or weird links.
> 
> I use this. There was a more general version submitted as a patch to
> DPDK but no one seemed interested.  The reason for redirecting stdout
> is that are libraries we use that print to stdout and want to get 
> timestamps
> from them if debugging startup issues.
> 
> 
> /*
>  * Sample of redirecting DPDK log stream.
>  *
>  * If program is run for debugging then stdout will be a console and
>  * put messages onto console stream with timestamps.  Otherwise, just
>  * put message onto stderr which systemd journal handles.  No need for
>  * syslog because that causes duplicate messages.
>  */
> 
> static struct timespec log_t0; /* Start program in monotonic time */
> 
> /*
>  * Write message to standard output with timestamp.
>  * Use writev() so that timestamp and message do not get interleaved.
>  */
> static ssize_t
> dpdk_log_tty_write(__rte_unused void *ctx, const char *buf, size_t size)
> {
> struct timespec ts;
> struct iovec iov[2];
> char tbuf[64];
> 
> /* format up monotonic timestamp */
> clock_gettime(CLOCK_MONOTONIC, &ts);
> 
> ts.tv_sec -= log_t0.tv_sec;
> ts.tv_nsec -= log_t0.tv_nsec;
> if (ts.tv_nsec < 0) {
> --ts.tv_sec;
> ts.tv_nsec += NS_PER_S;
> }
> 
> iov[0].iov_base = tbuf;
> iov[0].iov_len  = snprintf(tbuf, sizeof(tbuf), "[%8lu.%06lu] ",
>ts.tv_sec, ts.tv_nsec / 1000u);
> 
> /* extra cast is workaround to remove const qualifier */
> iov[1].iov_base = (void *)(uintptr_t)buf;
> iov[1].iov_len = size;
> 
> return writev(STDOUT_FILENO, iov, 2);
> }
> 
> static cookie_io_functions_t dpdk_log_tty_func = {
> .write = dpdk_log_tty_write,
> };
> 
> /*
>  * Print message to stderr with priority format so that
>  * Systemd journal can handle it. Alternative would be
>  * to use syslog or use sd_journal; but less is more.
>  */
> static ssize_t
> dpdk_log_write(__rte_unused void *ctx, const char *buf, size_t size)
> {
> /* Syslog error levels are from 0 to 7, DPDK uses 1 to 8 */
> int priority = rte_log_cur_msg_loglevel() - 1;
> 
> fprintf(stderr, "<%i>%.*s\n", priority, (int)size, buf);
> return size;
> }
> 
> static cookie_io_functions_t dpdk_log_func = {
> .write = dpdk_log_write,
> };
> 
> /*
>  * Override default DPDK logging which duplicates messages
>  * to both stderr and syslog.
>  */
> static void log_init(void)
> {
> backplane_logtype = rte_log_register("backplane");
> if (backplane_logtype >= 0)
> rte_log_set_level(backplane_logtype, RTE_LOG_INFO);
> 
> if (isatty(STDOUT_FILENO)) {
> clock_gettime(CLOCK_MONOTONIC, &log_t0);
> 
> stdout = fopencookie(NULL, "w+", dpdk_log_tty_func);
> setlinebuf(stdout);
> rte_openlog_stream(stdout);
> } else {
> FILE *jf;
> 
> jf = fopencookie(NULL, "w+", dpdk_log_func);
> rte_openlog_stream(jf);
> }
> }
> 
> /* Put DPDK log back onto stderr */
> static void log_uninit(void)
> {
> FILE *logf;
> 
> logf = rte_log_get_stream();
> if (logf != stderr) {
> rte_openlog_stream(stderr);
> fclose(logf);
> }
> }
> 
> This message may contain confidential and privileged information. If it has 
> been sent to you in error, please reply to advise the sender of the error and 
> then immediately delete it. If you are not the intended recipient, do not 
> read, copy, disclose or otherwise use this message. The sender disclaims any 
> liability for such unauthorized use. NOTE that all incoming emails sent to 
> Gigamon email accounts will be archived and may be scanned by us and/or by 
> external service providers to detect and prevent threats to our systems, 
> investigate illegal or inappropriate behavior, and/or eliminate unsolicited 
> promotional emails (“spam”).

Just use my example and make code like dpdk_tty_log_write that does wr

[RFC] eal: remove size for eal_set_runtime_dir

2022-01-05 Thread Stephen Hemminger
The size argument to eal_set_runtime_dir is useless and was
being used incorrectly in strlcpy. It worked only because
all callers passed PATH_MAX which is same as sizeof the destination
runtime_dir.

Signed-off-by: Stephen Hemminger 
Suggested-by: Morten Brørup 
---
 lib/eal/common/eal_common_config.c | 7 ++-
 lib/eal/common/eal_private.h   | 4 +---
 lib/eal/freebsd/eal.c  | 2 +-
 lib/eal/linux/eal.c| 2 +-
 4 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/lib/eal/common/eal_common_config.c 
b/lib/eal/common/eal_common_config.c
index 1c4c4dd585d0..62a9d7a198db 100644
--- a/lib/eal/common/eal_common_config.c
+++ b/lib/eal/common/eal_common_config.c
@@ -29,12 +29,9 @@ rte_eal_get_runtime_dir(void)
 }
 
 int
-eal_set_runtime_dir(char *run_dir, size_t size)
+eal_set_runtime_dir(const char *run_dir)
 {
-   size_t str_size;
-
-   str_size = strlcpy(runtime_dir, run_dir, size);
-   if (str_size >= size) {
+   if (strlcpy(runtime_dir, run_dir, PATH_MAX) >= PATH_MAX) {
RTE_LOG(ERR, EAL, "Runtime directory string too long\n");
return -1;
}
diff --git a/lib/eal/common/eal_private.h b/lib/eal/common/eal_private.h
index 36bcc0b5a492..734f1f334b69 100644
--- a/lib/eal/common/eal_private.h
+++ b/lib/eal/common/eal_private.h
@@ -681,13 +681,11 @@ eal_mem_set_dump(void *virt, size_t size, bool dump);
  *
  * @param run_dir
  *   The new runtime directory path of DPDK
- * @param size
- *   The size of the new runtime directory path in bytes.
  * @return
  *   0 on success, (-1) on failure.
  */
 int
-eal_set_runtime_dir(char *run_dir, size_t size);
+eal_set_runtime_dir(const char *run_dir);
 
 /**
  * Get the internal configuration structure.
diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c
index a1cd2462db1b..503e276dc27f 100644
--- a/lib/eal/freebsd/eal.c
+++ b/lib/eal/freebsd/eal.c
@@ -123,7 +123,7 @@ eal_create_runtime_dir(void)
return -1;
}
 
-   if (eal_set_runtime_dir(run_dir, sizeof(run_dir)))
+   if (eal_set_runtime_dir(run_dir))
return -1;
 
return 0;
diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
index 80ffe1c7f9d8..a73ff75f65c9 100644
--- a/lib/eal/linux/eal.c
+++ b/lib/eal/linux/eal.c
@@ -135,7 +135,7 @@ eal_create_runtime_dir(void)
return -1;
}
 
-   if (eal_set_runtime_dir(run_dir, sizeof(run_dir)))
+   if (eal_set_runtime_dir(run_dir))
return -1;
 
return 0;
-- 
2.30.2



RE: [RFC] eal: remove size for eal_set_runtime_dir

2022-01-05 Thread Morten Brørup
> From: Stephen Hemminger [mailto:step...@networkplumber.org]
> Sent: Wednesday, 5 January 2022 19.02
> 
> The size argument to eal_set_runtime_dir is useless and was
> being used incorrectly in strlcpy. It worked only because
> all callers passed PATH_MAX which is same as sizeof the destination
> runtime_dir.
> 
> Signed-off-by: Stephen Hemminger 
> Suggested-by: Morten Brørup 
> ---
>  lib/eal/common/eal_common_config.c | 7 ++-
>  lib/eal/common/eal_private.h   | 4 +---
>  lib/eal/freebsd/eal.c  | 2 +-
>  lib/eal/linux/eal.c| 2 +-
>  4 files changed, 5 insertions(+), 10 deletions(-)
> 
> diff --git a/lib/eal/common/eal_common_config.c
> b/lib/eal/common/eal_common_config.c
> index 1c4c4dd585d0..62a9d7a198db 100644
> --- a/lib/eal/common/eal_common_config.c
> +++ b/lib/eal/common/eal_common_config.c
> @@ -29,12 +29,9 @@ rte_eal_get_runtime_dir(void)
>  }
> 
>  int
> -eal_set_runtime_dir(char *run_dir, size_t size)
> +eal_set_runtime_dir(const char *run_dir)
>  {
> - size_t str_size;
> -
> - str_size = strlcpy(runtime_dir, run_dir, size);
> - if (str_size >= size) {
> + if (strlcpy(runtime_dir, run_dir, PATH_MAX) >= PATH_MAX) {
>   RTE_LOG(ERR, EAL, "Runtime directory string too long\n");
>   return -1;
>   }
> diff --git a/lib/eal/common/eal_private.h
> b/lib/eal/common/eal_private.h
> index 36bcc0b5a492..734f1f334b69 100644
> --- a/lib/eal/common/eal_private.h
> +++ b/lib/eal/common/eal_private.h
> @@ -681,13 +681,11 @@ eal_mem_set_dump(void *virt, size_t size, bool
> dump);
>   *
>   * @param run_dir
>   *   The new runtime directory path of DPDK
> - * @param size
> - *   The size of the new runtime directory path in bytes.
>   * @return
>   *   0 on success, (-1) on failure.
>   */
>  int
> -eal_set_runtime_dir(char *run_dir, size_t size);
> +eal_set_runtime_dir(const char *run_dir);
> 
>  /**
>   * Get the internal configuration structure.
> diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c
> index a1cd2462db1b..503e276dc27f 100644
> --- a/lib/eal/freebsd/eal.c
> +++ b/lib/eal/freebsd/eal.c
> @@ -123,7 +123,7 @@ eal_create_runtime_dir(void)
>   return -1;
>   }
> 
> - if (eal_set_runtime_dir(run_dir, sizeof(run_dir)))
> + if (eal_set_runtime_dir(run_dir))
>   return -1;
> 
>   return 0;
> diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
> index 80ffe1c7f9d8..a73ff75f65c9 100644
> --- a/lib/eal/linux/eal.c
> +++ b/lib/eal/linux/eal.c
> @@ -135,7 +135,7 @@ eal_create_runtime_dir(void)
>   return -1;
>   }
> 
> - if (eal_set_runtime_dir(run_dir, sizeof(run_dir)))
> + if (eal_set_runtime_dir(run_dir))
>   return -1;
> 
>   return 0;
> --
> 2.30.2
> 

Reviewed-by: Morten Brørup



RE: [PATCH] doc: simplify baseband features matrix

2022-01-05 Thread Morten Brørup
> From: Thomas Monjalon [mailto:tho...@monjalon.net]
> Sent: Wednesday, 5 January 2022 18.40
> 
> The "feature" BBDEV API is useless as all baseband drivers
> must implement it by definition.
> 
> The non-implemented features should not be marked with "N".
> Keeping them blank is clearer to read in the resulting matrix.
> 
> Signed-off-by: Thomas Monjalon 
> ---
>  doc/guides/bbdevs/features/acc100.ini| 1 -
>  doc/guides/bbdevs/features/default.ini   | 1 -
>  doc/guides/bbdevs/features/fpga_5gnr_fec.ini | 1 -
>  doc/guides/bbdevs/features/fpga_lte_fec.ini  | 1 -
>  doc/guides/bbdevs/features/la12xx.ini| 4 
>  doc/guides/bbdevs/features/null.ini  | 1 -
>  doc/guides/bbdevs/features/turbo_sw.ini  | 1 -
>  7 files changed, 10 deletions(-)
> 
> diff --git a/doc/guides/bbdevs/features/acc100.ini
> b/doc/guides/bbdevs/features/acc100.ini
> index 642cd48818..61a31065e1 100644
> --- a/doc/guides/bbdevs/features/acc100.ini
> +++ b/doc/guides/bbdevs/features/acc100.ini
> @@ -11,4 +11,3 @@ LDPC Encoder (5G)  = Y
>  LLR/HARQ Compression   = Y
>  External DDR Access= Y
>  HW Accelerated = Y
> -BBDEV API  = Y
> diff --git a/doc/guides/bbdevs/features/default.ini
> b/doc/guides/bbdevs/features/default.ini
> index 5fe267a625..494be5e400 100644
> --- a/doc/guides/bbdevs/features/default.ini
> +++ b/doc/guides/bbdevs/features/default.ini
> @@ -13,4 +13,3 @@ LDPC Encoder (5G)  =
>  LLR/HARQ Compression   =
>  External DDR Access=
>  HW Accelerated =
> -BBDEV API  =
> diff --git a/doc/guides/bbdevs/features/fpga_5gnr_fec.ini
> b/doc/guides/bbdevs/features/fpga_5gnr_fec.ini
> index 7a0b8d4e75..66c9139409 100644
> --- a/doc/guides/bbdevs/features/fpga_5gnr_fec.ini
> +++ b/doc/guides/bbdevs/features/fpga_5gnr_fec.ini
> @@ -8,4 +8,3 @@ LDPC Decoder (5G)  = Y
>  LDPC Encoder (5G)  = Y
>  External DDR Access= Y
>  HW Accelerated = Y
> -BBDEV API  = Y
> diff --git a/doc/guides/bbdevs/features/fpga_lte_fec.ini
> b/doc/guides/bbdevs/features/fpga_lte_fec.ini
> index f1cfb924a2..c3c398312b 100644
> --- a/doc/guides/bbdevs/features/fpga_lte_fec.ini
> +++ b/doc/guides/bbdevs/features/fpga_lte_fec.ini
> @@ -7,4 +7,3 @@
>  Turbo Decoder (4G) = Y
>  Turbo Encoder (4G) = Y
>  HW Accelerated = Y
> -BBDEV API  = Y
> diff --git a/doc/guides/bbdevs/features/la12xx.ini
> b/doc/guides/bbdevs/features/la12xx.ini
> index 0aec5eecb6..70c11990b7 100644
> --- a/doc/guides/bbdevs/features/la12xx.ini
> +++ b/doc/guides/bbdevs/features/la12xx.ini
> @@ -4,10 +4,6 @@
>  ; Refer to default.ini for the full list of available PMD features.
>  ;
>  [Features]
> -Turbo Decoder (4G) = N
> -Turbo Encoder (4G) = N
>  LDPC Decoder (5G)  = Y
>  LDPC Encoder (5G)  = Y
> -LLR/HARQ Compression   = N
>  HW Accelerated = Y
> -BBDEV API  = Y
> diff --git a/doc/guides/bbdevs/features/null.ini
> b/doc/guides/bbdevs/features/null.ini
> index d9bbda9cf0..50648cdecb 100644
> --- a/doc/guides/bbdevs/features/null.ini
> +++ b/doc/guides/bbdevs/features/null.ini
> @@ -4,4 +4,3 @@
>  ; Refer to default.ini for the full list of available PMD features.
>  ;
>  [Features]
> -BBDEV API  = Y
> diff --git a/doc/guides/bbdevs/features/turbo_sw.ini
> b/doc/guides/bbdevs/features/turbo_sw.ini
> index 2c7075e212..1d908d3ceb 100644
> --- a/doc/guides/bbdevs/features/turbo_sw.ini
> +++ b/doc/guides/bbdevs/features/turbo_sw.ini
> @@ -8,4 +8,3 @@ Turbo Decoder (4G) = Y
>  Turbo Encoder (4G) = Y
>  LDPC Decoder (5G)  = Y
>  LDPC Encoder (5G)  = Y
> -BBDEV API  = Y
> --
> 2.34.1
> 

Acked-by: Morten Brørup 



RE: [RFC 1/1] vhost: integrate dmadev in asynchronous datapath

2022-01-05 Thread Hu, Jiayu
Hi Maxime,

> -Original Message-
> From: Maxime Coquelin 
> Sent: Monday, January 3, 2022 6:26 PM
> To: Hu, Jiayu ; dev@dpdk.org
> Cc: i.maxim...@ovn.org; Xia, Chenbo ; Richardson,
> Bruce ; Van Haaren, Harry
> ; Mcnamara, John
> ; Pai G, Sunil 
> Subject: Re: [RFC 1/1] vhost: integrate dmadev in asynchronous datapath
> 
> Hi Jiayu,
> 
> On 12/28/21 02:15, Hu, Jiayu wrote:
> > Hi Maxime,
> >
> > Thanks for your comments, and some replies are inline.
> >
> > Thanks,
> > Jiayu
> >
> >> -Original Message-
> >> From: Maxime Coquelin 
> >> Sent: Friday, December 24, 2021 6:40 PM
> >> To: Hu, Jiayu ; dev@dpdk.org
> >> Cc: i.maxim...@ovn.org; Xia, Chenbo ;
> >> Richardson, Bruce ; Van Haaren, Harry
> >> ; Mcnamara, John
> >> ; Pai G, Sunil 
> >> Subject: Re: [RFC 1/1] vhost: integrate dmadev in asynchronous
> >> datapath
> >>
> >> Hi Jiayu,
> >>
> >> This is a first review, I need to spend more time on the series to
> >> understand it well. Do you have a prototype of the OVS part, so that
> >> it helps us to grasp how the full integration would look like?
> >
> > I think OVS patch will be sent soon. And we will send the deq side
> implementation too.
> >
> >>
> >> On 11/22/21 11:54, Jiayu Hu wrote:
> >>> Since dmadev is introduced in 21.11, to avoid the overhead of vhost
> >>> DMA abstraction layer and simplify application logics, this patch
> >>> integrates dmadev in asynchronous data path.
> >>>
> >>> Signed-off-by: Jiayu Hu 
> >>> Signed-off-by: Sunil Pai G 
> >>> ---
> >>>doc/guides/prog_guide/vhost_lib.rst |  63 
> >>>examples/vhost/ioat.c   | 218 
> >>>examples/vhost/ioat.h   |  63 
> >>>examples/vhost/main.c   | 144 +++---
> >>>examples/vhost/main.h   |  12 ++
> >>>examples/vhost/meson.build  |   6 +-
> >>>lib/vhost/meson.build   |   3 +-
> >>>lib/vhost/rte_vhost_async.h |  73 +++---
> >>>lib/vhost/vhost.c   |  37 ++---
> >>>lib/vhost/vhost.h   |  45 +-
> >>>lib/vhost/virtio_net.c  | 198 -
> >>>11 files changed, 410 insertions(+), 452 deletions(-)
> >>>delete mode 100644 examples/vhost/ioat.c
> >>>delete mode 100644 examples/vhost/ioat.h
> >>>
> 
> ...
> 
> >>> diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c index
> >>> 13a9bb9dd1..595cf63b8d 100644
> >>> --- a/lib/vhost/vhost.c
> >>> +++ b/lib/vhost/vhost.c
> >>> @@ -344,6 +344,7 @@ vhost_free_async_mem(struct vhost_virtqueue
> *vq)
> >>>   return;
> >>>
> >>>   rte_free(vq->async->pkts_info);
> >>> + rte_free(vq->async->pkts_cmpl_flag);
> >>>
> >>>   rte_free(vq->async->buffers_packed);
> >>>   vq->async->buffers_packed = NULL; @@ -1626,8 +1627,7 @@
> >>> rte_vhost_extern_callback_register(int vid,
> >>>}
> >>>
> >>> diff --git a/lib/vhost/vhost.h b/lib/vhost/vhost.h index
> >>> 7085e0885c..974e495b56 100644
> >>> --- a/lib/vhost/vhost.h
> >>> +++ b/lib/vhost/vhost.h
> >>> @@ -51,6 +51,11 @@
> >>>#define VHOST_MAX_ASYNC_IT (MAX_PKT_BURST)
> >>>#define VHOST_MAX_ASYNC_VEC 2048
> >>>
> >>> +/* DMA device copy operation tracking ring size. */ #define
> >>> +VHOST_ASYNC_DMA_TRACK_RING_SIZE (uint32_t)4096
> >>
> >> How is this value chosen? Is that specific to your hardware?
> >
> > Yes. But in fact, this value should be equal to or greater than vchan
> > desc number, and it should be dynamic. In addition, the context
> > tracking array " dma_copy_track" should be per-vchan basis, rather
> > than per-device, although existed DMA devices only supports 1 vchan at
> most.
> >
> > I have reworked this part which can be configured by users dynamically.
> 
> Wouldn't it be better to use the max_desc value from from struct
> rte_dma_info?

Yes, you are right. I will use this structure in the next version.

Thanks,
Jiayu