[dpdk-dev] [PATCH] vhost: fix corner case for split ring enqueue operation

2018-09-07 Thread Jiayu Hu
When perform enqueue operations on the split ring, if the
reserved buffer length from the descriptor table execeeds 65535,
the returned length by fill_vec_buf_split() is overflowed.
This patch is to avoid this corner case.

Fixes: f689586bc060 ("vhost: shadow used ring update")

Signed-off-by: Jiayu Hu 
---
 lib/librte_vhost/virtio_net.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
index 99c7afc..9f3c88f 100644
--- a/lib/librte_vhost/virtio_net.c
+++ b/lib/librte_vhost/virtio_net.c
@@ -122,7 +122,7 @@ flush_shadow_used_ring_split(struct virtio_net *dev, struct 
vhost_virtqueue *vq)
 
 static __rte_always_inline void
 update_shadow_used_ring_split(struct vhost_virtqueue *vq,
-uint16_t desc_idx, uint16_t len)
+uint16_t desc_idx, uint32_t len)
 {
uint16_t i = vq->shadow_used_idx++;
 
@@ -329,7 +329,7 @@ static __rte_always_inline int
 fill_vec_buf_split(struct virtio_net *dev, struct vhost_virtqueue *vq,
 uint32_t avail_idx, uint16_t *vec_idx,
 struct buf_vector *buf_vec, uint16_t *desc_chain_head,
-uint16_t *desc_chain_len, uint8_t perm)
+uint32_t *desc_chain_len, uint8_t perm)
 {
uint16_t idx = vq->avail->ring[avail_idx & (vq->size - 1)];
uint16_t vec_id = *vec_idx;
@@ -409,7 +409,7 @@ reserve_avail_buf_split(struct virtio_net *dev, struct 
vhost_virtqueue *vq,
uint16_t max_tries, tries = 0;
 
uint16_t head_idx = 0;
-   uint16_t len = 0;
+   uint32_t len = 0;
 
*num_buffers = 0;
cur_idx  = vq->last_avail_idx;
@@ -1378,7 +1378,8 @@ virtio_dev_tx_split(struct virtio_net *dev, struct 
vhost_virtqueue *vq,
 
for (i = 0; i < count; i++) {
struct buf_vector buf_vec[BUF_VECTOR_MAX];
-   uint16_t head_idx, dummy_len;
+   uint16_t head_idx;
+   uint32_t dummy_len;
uint16_t nr_vec = 0;
int err;
 
-- 
2.7.4



[dpdk-dev] [PATCH v2 1/4] doc: create a platorm specific page for NXP DPAA platform

2018-09-07 Thread Hemant Agrawal
Signed-off-by: Hemant Agrawal 
---
 doc/guides/platform/dpaa.rst  | 100 ++
 doc/guides/platform/index.rst |   1 +
 2 files changed, 101 insertions(+)
 create mode 100644 doc/guides/platform/dpaa.rst

diff --git a/doc/guides/platform/dpaa.rst b/doc/guides/platform/dpaa.rst
new file mode 100644
index 000..c065df0
--- /dev/null
+++ b/doc/guides/platform/dpaa.rst
@@ -0,0 +1,100 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+Copyright 2018 NXP
+
+NXP QorIQ DPAA Board Support Package
+
+
+This doc has information about steps to setup QorIq dpaa
+based layerscape platform and information about common offload
+hw block drivers of **NXP QorIQ DPAA** SoC family.
+
+Supported DPAA SoCs
+
+
+* LS1046A/LS1026A
+* LS1043A/LS1023A
+
+More information about SoC can be found at `NXP Official Website
+`_.
+
+
+Common Offload HW Block Drivers
+---
+
+1. **Nics Driver**
+   See :doc:`../nics/dpaa` for NXP dpaa nic driver information.
+
+2. **Cryptodev Driver**
+   See :doc:`../cryptodevs/dpaa_sec` for NXP dpaa cryptodev driver information.
+
+3. **Eventdev Driver**
+   See :doc:`../eventdevs/dpaa` for NXP dpaa eventdev driver information.
+
+
+Steps To Setup Platform
+---
+
+There are four main pre-requisities for executing DPAA PMD on a DPAA
+compatible board:
+
+1. **ARM 64 Tool Chain**
+
+   For example, the `*aarch64* Linaro Toolchain 
`_.
+
+2. **Linux Kernel**
+
+   It can be obtained from `NXP's Github hosting 
`_.
+
+3. **Rootfile system**
+
+   Any *aarch64* supporting filesystem can be used. For example,
+   Ubuntu 16.04 LTS (Xenial) or 18.04 (Bionic) userland which can be obtained
+   from `here
+   
`_.
+
+4. **FMC Tool**
+
+   Before any DPDK application can be executed, the Frame Manager Configuration
+   Tool (FMC) need to be executed to set the configurations of the queues. This
+   includes the queue state, RSS and other policies.
+   This tool can be obtained from `NXP (Freescale) Public Git Repository 
`_.
+
+   This tool needs configuration files which are available in the
+   :ref:`DPDK Extra Scripts `, described below for DPDK usages.
+
+As an alternative method, DPAA PMD can also be executed using images provided
+as part of SDK from NXP. The SDK includes all the above prerequisites necessary
+to bring up a DPAA board.
+
+The following dependencies are not part of DPDK and must be installed
+separately:
+
+- **NXP Linux SDK**
+
+  NXP Linux software development kit (SDK) includes support for family
+  of QorIQ® ARM-Architecture-based system on chip (SoC) processors
+  and corresponding boards.
+
+  It includes the Linux board support packages (BSPs) for NXP SoCs,
+  a fully operational tool chain, kernel and board specific modules.
+
+  SDK and related information can be obtained from:  `NXP QorIQ SDK  
`_.
+
+
+.. _extra_scripts:
+
+- **DPDK Extra Scripts**
+
+  DPAA based resources can be configured easily with the help of ready scripts
+  as provided in the DPDK Extra repository.
+
+  `DPDK Extras Scripts 
`_.
+
+Currently supported by DPDK:
+
+- NXP SDK **2.0+** (preferred: LSDK 18.09).
+- Supported architectures:  **arm64 LE**.
+
+- Follow the DPDK :ref:`Getting Started Guide for Linux `
+  to setup the basic DPDK environment.
diff --git a/doc/guides/platform/index.rst b/doc/guides/platform/index.rst
index ca6113d..fc7c6d4 100644
--- a/doc/guides/platform/index.rst
+++ b/doc/guides/platform/index.rst
@@ -10,4 +10,5 @@ The following are platform specific guides and setup 
information.
 :maxdepth: 2
 :numbered:
 
+dpaa
 octeontx
-- 
2.7.4



[dpdk-dev] [PATCH v2 2/4] doc: remove redundant prerequisite info for dpaa devices

2018-09-07 Thread Hemant Agrawal
Signed-off-by: Hemant Agrawal 
---
 doc/guides/cryptodevs/dpaa_sec.rst | 25 ++--
 doc/guides/eventdevs/dpaa.rst  | 48 +++
 doc/guides/nics/dpaa.rst   | 59 +-
 3 files changed, 7 insertions(+), 125 deletions(-)

diff --git a/doc/guides/cryptodevs/dpaa_sec.rst 
b/doc/guides/cryptodevs/dpaa_sec.rst
index dd68389..897a4fe 100644
--- a/doc/guides/cryptodevs/dpaa_sec.rst
+++ b/doc/guides/cryptodevs/dpaa_sec.rst
@@ -101,32 +101,11 @@ Prerequisites
 -
 
 DPAA_SEC driver has similar pre-requisites as described in 
:ref:`dpaa_overview`.
-The following dependencies are not part of DPDK and must be installed 
separately:
 
-* **NXP Linux SDK**
+See :doc:`../platform/dpaa` for setup information
 
-  NXP Linux software development kit (SDK) includes support for the family
-  of QorIQ® ARM-Architecture-based system on chip (SoC) processors
-  and corresponding boards.
 
-  It includes the Linux board support packages (BSPs) for NXP SoCs,
-  a fully operational tool chain, kernel and board specific modules.
-
-  SDK and related information can be obtained from:  `NXP QorIQ SDK  
`_.
-
-* **DPDK Extras Scripts**
-
-  DPAA based resources can be configured easily with the help of ready scripts
-  as provided in the DPDK Extras repository.
-
-  `DPDK Extras Scripts `_.
-
-Currently supported by DPDK:
-
-* NXP SDK **2.0+**.
-* Supported architectures:  **arm64 LE**.
-
-* Follow the DPDK :ref:`Getting Started Guide for Linux ` to setup 
the basic DPDK environment.
+- Follow the DPDK :ref:`Getting Started Guide for Linux ` to setup 
the basic DPDK environment.
 
 Pre-Installation Configuration
 --
diff --git a/doc/guides/eventdevs/dpaa.rst b/doc/guides/eventdevs/dpaa.rst
index 7383295..3af2343 100644
--- a/doc/guides/eventdevs/dpaa.rst
+++ b/doc/guides/eventdevs/dpaa.rst
@@ -25,57 +25,17 @@ The DPAA EVENTDEV implements many features in the eventdev 
API;
 Supported DPAA SoCs
 
 
-- LS1046A
-- LS1043A
+- LS1046A/LS1026A
+- LS1043A/LS1023A
 
 Prerequisites
 -
 
-There are following pre-requisites for executing EVENTDEV on a DPAA compatible
-platform:
-
-1. **ARM 64 Tool Chain**
-
-  For example, the `*aarch64* Linaro Toolchain 
`_.
-
-2. **Linux Kernel**
-
-   It can be obtained from `NXP's Github hosting 
`_.
-
-3. **Rootfile System**
-
-   Any *aarch64* supporting filesystem can be used. For example,
-   Ubuntu 15.10 (Wily) or 16.04 LTS (Xenial) userland which can be obtained
-   from `here 
`_.
-
-As an alternative method, DPAA EVENTDEV can also be executed using images 
provided
-as part of SDK from NXP. The SDK includes all the above prerequisites necessary
-to bring up a DPAA board.
-
-The following dependencies are not part of DPDK and must be installed
-separately:
-
-- **NXP Linux SDK**
-
-  NXP Linux software development kit (SDK) includes support for family
-  of QorIQ® ARM-Architecture-based system on chip (SoC) processors
-  and corresponding boards.
-
-  It includes the Linux board support packages (BSPs) for NXP SoCs,
-  a fully operational tool chain, kernel and board specific modules.
-
-  SDK and related information can be obtained from:  `NXP QorIQ SDK  
`_.
-
-- **DPDK Extra Scripts**
-
-  DPAA based resources can be configured easily with the help of ready to use
-  xml files as provided in the DPDK Extra repository.
-
-  `DPDK Extras Scripts `_.
+See :doc:`../platform/dpaa` for setup information
 
 Currently supported by DPDK:
 
-- NXP SDK **2.0+** or LSDK **17.09+**
+- NXP SDK **2.0+** or LSDK **18.09+**
 - Supported architectures:  **arm64 LE**.
 
 - Follow the DPDK :ref:`Getting Started Guide for Linux ` to setup 
the basic DPDK environment.
diff --git a/doc/guides/nics/dpaa.rst b/doc/guides/nics/dpaa.rst
index 620c045..2173673 100644
--- a/doc/guides/nics/dpaa.rst
+++ b/doc/guides/nics/dpaa.rst
@@ -181,65 +181,8 @@ Supported DPAA SoCs
 Prerequisites
 -
 
-There are three main pre-requisities for executing DPAA PMD on a DPAA
-compatible board:
+See :doc:`../platform/dpaa` for setup information
 
-1. **ARM 64 Tool Chain**
-
-   For example, the `*aarch64* Linaro Toolchain 
`_.
-
-2. **Linux Kernel**
-
-   It can be obtained from `NXP's Github hosting 


[dpdk-dev] [PATCH v2 3/4] doc: create a platorm specific page for NXP DPAA2 platform

2018-09-07 Thread Hemant Agrawal
Signed-off-by: Hemant Agrawal 
---
 doc/guides/platform/dpaa2.rst | 98 +++
 doc/guides/platform/index.rst |  1 +
 2 files changed, 99 insertions(+)
 create mode 100644 doc/guides/platform/dpaa2.rst

diff --git a/doc/guides/platform/dpaa2.rst b/doc/guides/platform/dpaa2.rst
new file mode 100644
index 000..e9f4399
--- /dev/null
+++ b/doc/guides/platform/dpaa2.rst
@@ -0,0 +1,98 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+Copyright 2018 NXP
+
+NXP QorIQ DPAA2 Board Support Package
+=
+
+This doc has information about steps to setup NXP QoriQ DPAA2 platform
+and information about common offload hw block drivers of
+**NXP QorIQ DPAA2** SoC family.
+
+Supported DPAA2 SoCs
+
+
+- LX2160A
+- LS2084A/LS2044A
+- LS2088A/LS2048A
+- LS1088A/LS1048A
+
+More information about SoC can be found at `NXP Official Website
+`_.
+
+
+Common Offload HW Block Drivers
+---
+
+1. **Nics Driver**
+   See :doc:`../nics/dpaa2` for NXP dpaa2 nic driver information.
+
+2. **Cryptodev Driver**
+   See :doc:`../cryptodevs/dpaa2_sec` for NXP dpaa2 cryptodev driver 
information.
+
+3. **Eventdev Driver**
+   See :doc:`../eventdevs/dpaa2` for NXP dpaa2 eventdev driver information.
+
+
+Steps To Setup Platform
+---
+
+There are four main pre-requisities for executing DPAA2 PMD on a DPAA2
+compatible board:
+
+1. **ARM 64 Tool Chain**
+
+   For example, the `*aarch64* Linaro Toolchain 
`_.
+
+2. **Linux Kernel**
+
+   It can be obtained from `NXP's Github hosting 
`_.
+
+3. **Rootfile system**
+
+   Any *aarch64* supporting filesystem can be used. For example,
+   Ubuntu 16.04 LTS (Xenial) or 18.04 (Bionic) userland which can be obtained
+   from `here
+   
`_.
+
+4. **Resource Scripts**
+
+   DPAA2 based resources can be configured easily with the help of ready 
scripts
+   as provided in the DPDK Extra repository.
+
+As an alternative method, DPAA2 PMD can also be executed using images provided
+as part of SDK from NXP. The SDK includes all the above prerequisites necessary
+to bring up a DPAA2 board.
+
+The following dependencies are not part of DPDK and must be installed
+separately:
+
+- **NXP Linux SDK**
+
+  NXP Linux software development kit (SDK) includes support for family
+  of QorIQ® ARM-Architecture-based system on chip (SoC) processors
+  and corresponding boards.
+
+  It includes the Linux board support packages (BSPs) for NXP SoCs,
+  a fully operational tool chain, kernel and board specific modules.
+
+  SDK and related information can be obtained from:  `NXP QorIQ SDK  
`_.
+
+
+.. _extra_scripts:
+
+- **DPDK Extra Scripts**
+
+  DPAA2 based resources can be configured easily with the help of ready scripts
+  as provided in the DPDK Extra repository.
+
+  `DPDK Extras Scripts 
`_.
+
+Currently supported by DPDK:
+
+- NXP SDK **2.0+** (preferred: LSDK 18.09).
+- MC Firmware version **10.10.0** and higher.
+- Supported architectures:  **arm64 LE**.
+
+- Follow the DPDK :ref:`Getting Started Guide for Linux `
+  to setup the basic DPDK environment.
diff --git a/doc/guides/platform/index.rst b/doc/guides/platform/index.rst
index fc7c6d4..98c6638 100644
--- a/doc/guides/platform/index.rst
+++ b/doc/guides/platform/index.rst
@@ -11,4 +11,5 @@ The following are platform specific guides and setup 
information.
 :numbered:
 
 dpaa
+dpaa2
 octeontx
-- 
2.7.4



[dpdk-dev] [PATCH v2 4/4] doc: remove redundant prerequisite info for dpaa2 devices

2018-09-07 Thread Hemant Agrawal
Signed-off-by: Hemant Agrawal 
---
 doc/guides/cryptodevs/dpaa2_sec.rst | 28 +
 doc/guides/eventdevs/dpaa2.rst  | 50 -
 doc/guides/nics/dpaa2.rst   | 49 +++-
 3 files changed, 15 insertions(+), 112 deletions(-)

diff --git a/doc/guides/cryptodevs/dpaa2_sec.rst 
b/doc/guides/cryptodevs/dpaa2_sec.rst
index 9191704..aee79ab 100644
--- a/doc/guides/cryptodevs/dpaa2_sec.rst
+++ b/doc/guides/cryptodevs/dpaa2_sec.rst
@@ -129,7 +129,7 @@ AEAD algorithms:
 Supported DPAA2 SoCs
 
 
-* LS2080A/LS2040A
+* LS2160A
 * LS2084A/LS2044A
 * LS2088A/LS2048A
 * LS1088A/LS1048A
@@ -157,31 +157,15 @@ Prerequisites
 DPAA2_SEC driver has similar pre-requisites as described in 
:ref:`dpaa2_overview`.
 The following dependencies are not part of DPDK and must be installed 
separately:
 
-* **NXP Linux SDK**
-
-  NXP Linux software development kit (SDK) includes support for the family
-  of QorIQ® ARM-Architecture-based system on chip (SoC) processors
-  and corresponding boards.
-
-  It includes the Linux board support packages (BSPs) for NXP SoCs,
-  a fully operational tool chain, kernel and board specific modules.
-
-  SDK and related information can be obtained from:  `NXP QorIQ SDK  
`_.
-
-* **DPDK Extra Scripts**
-
-  DPAA2 based resources can be configured easily with the help of ready scripts
-  as provided in the DPDK helper repository.
-
-  `DPDK Extra Scripts `_.
+See :doc:`../platform/dpaa2` for setup information
 
 Currently supported by DPDK:
 
-* NXP SDK **17.08+**.
-* MC Firmware version **10.3.1** and higher.
-* Supported architectures:  **arm64 LE**.
+- NXP SDK **18.09+**.
+- MC Firmware version **10.10.0** and higher.
+- Supported architectures:  **arm64 LE**.
 
-* Follow the DPDK :ref:`Getting Started Guide for Linux ` to setup 
the basic DPDK environment.
+- Follow the DPDK :ref:`Getting Started Guide for Linux ` to setup 
the basic DPDK environment.
 
 Pre-Installation Configuration
 --
diff --git a/doc/guides/eventdevs/dpaa2.rst b/doc/guides/eventdevs/dpaa2.rst
index ad94f24..2b1700a 100644
--- a/doc/guides/eventdevs/dpaa2.rst
+++ b/doc/guides/eventdevs/dpaa2.rst
@@ -26,7 +26,7 @@ The DPAA2 EVENTDEV implements many features in the eventdev 
API;
 Supported DPAA2 SoCs
 
 
-- LS2080A/LS2040A
+- LX2160A
 - LS2084A/LS2044A
 - LS2088A/LS2048A
 - LS1088A/LS1048A
@@ -34,52 +34,12 @@ Supported DPAA2 SoCs
 Prerequisites
 -
 
-There are three main pre-requisities for executing DPAA2 EVENTDEV on a DPAA2
-compatible board:
-
-1. **ARM 64 Tool Chain**
-
-   For example, the `*aarch64* Linaro Toolchain 
`_.
-
-2. **Linux Kernel**
-
-   It can be obtained from `NXP's Github hosting 
`_.
-
-3. **Rootfile system**
-
-   Any *aarch64* supporting filesystem can be used. For example,
-   Ubuntu 15.10 (Wily) or 16.04 LTS (Xenial) userland which can be obtained
-   from `here 
`_.
-
-As an alternative method, DPAA2 EVENTDEV can also be executed using images 
provided
-as part of SDK from NXP. The SDK includes all the above prerequisites necessary
-to bring up a DPAA2 board.
-
-The following dependencies are not part of DPDK and must be installed
-separately:
-
-- **NXP Linux SDK**
-
-  NXP Linux software development kit (SDK) includes support for family
-  of QorIQ® ARM-Architecture-based system on chip (SoC) processors
-  and corresponding boards.
-
-  It includes the Linux board support packages (BSPs) for NXP SoCs,
-  a fully operational tool chain, kernel and board specific modules.
-
-  SDK and related information can be obtained from:  `NXP QorIQ SDK  
`_.
-
-- **DPDK Extra Scripts**
-
-  DPAA2 based resources can be configured easily with the help of ready scripts
-  as provided in the DPDK Extra repository.
-
-  `DPDK Extras Scripts `_.
+See :doc:`../platform/dpaa2` for setup information
 
 Currently supported by DPDK:
 
-- NXP SDK **2.0+**.
-- MC Firmware version **10.0.0** and higher.
+- NXP SDK **18.09+**.
+- MC Firmware version **10.10.0** and higher.
 - Supported architectures:  **arm64 LE**.
 
 - Follow the DPDK :ref:`Getting Started Guide for Linux ` to setup 
the basic DPDK environment.
@@ -155,4 +115,4 @@ DPAA2 drivers for DPDK can only work on NXP SoCs as listed 
in the
 Port-core binding
 ~
 
-DPAA2 EVENTDEV driver requires event port 'x' to be used on core 'x'.
+DP

[dpdk-dev] [PATCH 1/3] lib/librte_table: add hash_func header files

2018-09-07 Thread Kevin Laatz
This commit adds rte_table_hash_func.h and rte_table_hash_func_arm64.h to
librte_table. This will replace hash_func.h and hash_func_arm64.h in the IP
Pipeline application and in SoftNIC. This also adds a scalar implementation
of the x86_64 intrinsic for crc32 as a generic fallback.

Signed-off-by: Cristian Dumitrescu 
Signed-off-by: Kevin Laatz 

---
v2:
   - Fixed typo in commit message
   - Fixed typo in arm header that caused some compilations to fail for the
 entire patchset
---
 lib/librte_table/Makefile|   2 +
 lib/librte_table/meson.build |   2 +
 lib/librte_table/rte_table_hash_func.h   | 244 +++
 lib/librte_table/rte_table_hash_func_arm64.h |  21 +++
 lib/librte_table/rte_table_version.map   |  14 ++
 5 files changed, 283 insertions(+)
 create mode 100644 lib/librte_table/rte_table_hash_func.h
 create mode 100644 lib/librte_table/rte_table_hash_func_arm64.h

diff --git a/lib/librte_table/Makefile b/lib/librte_table/Makefile
index 276d476..f935678 100644
--- a/lib/librte_table/Makefile
+++ b/lib/librte_table/Makefile
@@ -46,6 +46,8 @@ SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include += rte_table_acl.h
 endif
 SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include += rte_table_hash.h
 SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include += rte_table_hash_cuckoo.h
+SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include += rte_table_hash_func.h
+SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include += rte_table_hash_func_arm64.h
 SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include += rte_lru.h
 ifeq ($(CONFIG_RTE_ARCH_X86),y)
 SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include += rte_lru_x86.h
diff --git a/lib/librte_table/meson.build b/lib/librte_table/meson.build
index 8b2f841..6ae3cd6 100644
--- a/lib/librte_table/meson.build
+++ b/lib/librte_table/meson.build
@@ -19,6 +19,8 @@ headers = files('rte_table.h',
'rte_table_lpm_ipv6.h',
'rte_table_hash.h',
'rte_table_hash_cuckoo.h',
+   'rte_table_hash_func.h',
+   'rte_table_hash_func_arm64.h',
'rte_lru.h',
'rte_table_array.h',
'rte_table_stub.h')
diff --git a/lib/librte_table/rte_table_hash_func.h 
b/lib/librte_table/rte_table_hash_func.h
new file mode 100644
index 000..4eadbfb
--- /dev/null
+++ b/lib/librte_table/rte_table_hash_func.h
@@ -0,0 +1,244 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2018 Intel Corporation
+ */
+
+#ifndef __INCLUDE_RTE_TABLE_HASH_FUNC_H__
+#define __INCLUDE_RTE_TABLE_HASH_FUNC_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include 
+
+#include 
+
+static inline uint64_t
+rte_crc32_u64_generic(uint64_t crc, uint64_t value)
+{
+   int i;
+
+   crc = (crc & 0xLLU) ^ value;
+   for (i = 63; i >= 0; i--) {
+   uint64_t mask;
+
+   mask = -(crc & 1LLU);
+   crc = (crc >> 1LLU) ^ (0x82F63B78LLU & mask);
+   }
+
+   return crc;
+}
+
+#if defined(RTE_ARCH_X86_64)
+
+#include 
+
+static inline uint64_t
+rte_crc32_u64(uint64_t crc, uint64_t v)
+{
+   return _mm_crc32_u64(crc, v);
+}
+
+#elif defined(RTE_ARCH_ARM64)
+#include "rte_table_hash_func_arm64.h"
+#else
+
+static inline uin64_t
+rte_crc32_u64(uint64_t crc, uint64_t v)
+{
+   return rte_crc32_u64_generic(crc, v);
+}
+
+#endif
+
+static inline uint64_t
+rte_table_hash_crc_key8(void *key, void *mask, __rte_unused uint32_t key_size,
+   uint64_t seed)
+{
+   uint64_t *k = key;
+   uint64_t *m = mask;
+   uint64_t crc0;
+
+   crc0 = rte_crc32_u64(seed, k[0] & m[0]);
+
+   return crc0;
+}
+
+static inline uint64_t
+rte_table_hash_crc_key16(void *key, void *mask, __rte_unused uint32_t key_size,
+   uint64_t seed)
+{
+   uint64_t *k = key;
+   uint64_t *m = mask;
+   uint64_t k0, crc0, crc1;
+
+   k0 = k[0] & m[0];
+
+   crc0 = rte_crc32_u64(k0, seed);
+   crc1 = rte_crc32_u64(k0 >> 32, k[1] & m[1]);
+
+   crc0 ^= crc1;
+
+   return crc0;
+}
+
+static inline uint64_t
+rte_table_hash_crc_key24(void *key, void *mask, __rte_unused uint32_t key_size,
+   uint64_t seed)
+{
+   uint64_t *k = key;
+   uint64_t *m = mask;
+   uint64_t k0, k2, crc0, crc1;
+
+   k0 = k[0] & m[0];
+   k2 = k[2] & m[2];
+
+   crc0 = rte_crc32_u64(k0, seed);
+   crc1 = rte_crc32_u64(k0 >> 32, k[1] & m[1]);
+
+   crc0 = rte_crc32_u64(crc0, k2);
+
+   crc0 ^= crc1;
+
+   return crc0;
+}
+
+static inline uint64_t
+rte_table_hash_crc_key32(void *key, void *mask, __rte_unused uint32_t key_size,
+   uint64_t seed)
+{
+   uint64_t *k = key;
+   uint64_t *m = mask;
+   uint64_t k0, k2, crc0, crc1, crc2, crc3;
+
+   k0 = k[0] & m[0];
+   k2 = k[2] & m[2];
+
+   crc0 = rte_crc32_u64(k0, seed);
+   crc1 = rte_crc32_u64(k0 >> 32, k[1] & m[1]);
+
+   crc2 = rte_crc32_u64(k2, k[3] & m[3]);
+   crc3 = k2 >> 32;
+
+   crc0 = rte_crc32_u64(crc0, crc1);
+   cr

[dpdk-dev] [PATCH 3/3] net/softnic: modify softnic to use librte_table headers

2018-09-07 Thread Kevin Laatz
This commit modifies SoftNIC to make use of the new header files in
librte_table.

As we are now using the new header files in librte_table in SoftNIC, we no
longer need the old header files so they can be removed.

Signed-off-by: Cristian Dumitrescu 
Signed-off-by: Kevin Laatz 
---
 drivers/net/softnic/hash_func.h| 359 -
 drivers/net/softnic/hash_func_arm64.h  | 261 --
 drivers/net/softnic/rte_eth_softnic_action.c   |  34 +--
 drivers/net/softnic/rte_eth_softnic_pipeline.c |  19 +-
 4 files changed, 26 insertions(+), 647 deletions(-)
 delete mode 100644 drivers/net/softnic/hash_func.h
 delete mode 100644 drivers/net/softnic/hash_func_arm64.h

diff --git a/drivers/net/softnic/hash_func.h b/drivers/net/softnic/hash_func.h
deleted file mode 100644
index 198d2b2..000
--- a/drivers/net/softnic/hash_func.h
+++ /dev/null
@@ -1,359 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2018 Intel Corporation
- */
-
-#ifndef __INCLUDE_HASH_FUNC_H__
-#define __INCLUDE_HASH_FUNC_H__
-
-#include 
-
-static inline uint64_t
-hash_xor_key8(void *key, void *mask, __rte_unused uint32_t key_size,
-   uint64_t seed)
-{
-   uint64_t *k = key;
-   uint64_t *m = mask;
-   uint64_t xor0;
-
-   xor0 = seed ^ (k[0] & m[0]);
-
-   return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key16(void *key, void *mask, __rte_unused uint32_t key_size,
-   uint64_t seed)
-{
-   uint64_t *k = key;
-   uint64_t *m = mask;
-   uint64_t xor0;
-
-   xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-
-   return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key24(void *key, void *mask, __rte_unused uint32_t key_size,
-   uint64_t seed)
-{
-   uint64_t *k = key;
-   uint64_t *m = mask;
-   uint64_t xor0;
-
-   xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-
-   xor0 ^= k[2] & m[2];
-
-   return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key32(void *key, void *mask, __rte_unused uint32_t key_size,
-   uint64_t seed)
-{
-   uint64_t *k = key;
-   uint64_t *m = mask;
-   uint64_t xor0, xor1;
-
-   xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-   xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
-
-   xor0 ^= xor1;
-
-   return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key40(void *key, void *mask, __rte_unused uint32_t key_size,
-   uint64_t seed)
-{
-   uint64_t *k = key;
-   uint64_t *m = mask;
-   uint64_t xor0, xor1;
-
-   xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-   xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
-
-   xor0 ^= xor1;
-
-   xor0 ^= k[4] & m[4];
-
-   return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key48(void *key, void *mask, __rte_unused uint32_t key_size,
-   uint64_t seed)
-{
-   uint64_t *k = key;
-   uint64_t *m = mask;
-   uint64_t xor0, xor1, xor2;
-
-   xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-   xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
-   xor2 = (k[4] & m[4]) ^ (k[5] & m[5]);
-
-   xor0 ^= xor1;
-
-   xor0 ^= xor2;
-
-   return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key56(void *key, void *mask, __rte_unused uint32_t key_size,
-   uint64_t seed)
-{
-   uint64_t *k = key;
-   uint64_t *m = mask;
-   uint64_t xor0, xor1, xor2;
-
-   xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-   xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
-   xor2 = (k[4] & m[4]) ^ (k[5] & m[5]);
-
-   xor0 ^= xor1;
-   xor2 ^= k[6] & m[6];
-
-   xor0 ^= xor2;
-
-   return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key64(void *key, void *mask, __rte_unused uint32_t key_size,
-   uint64_t seed)
-{
-   uint64_t *k = key;
-   uint64_t *m = mask;
-   uint64_t xor0, xor1, xor2, xor3;
-
-   xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-   xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
-   xor2 = (k[4] & m[4]) ^ (k[5] & m[5]);
-   xor3 = (k[6] & m[6]) ^ (k[7] & m[7]);
-
-   xor0 ^= xor1;
-   xor2 ^= xor3;
-
-   xor0 ^= xor2;
-
-   return (xor0 >> 32) ^ xor0;
-}
-
-#if defined(RTE_ARCH_X86_64)
-
-#include 
-
-static inline uint64_t
-hash_crc_key8(void *key, void *mask, __rte_unused uint32_t key_size,
-   uint64_t seed)
-{
-   uint64_t *k = key;
-   uint64_t *m = mask;
-   uint64_t crc0;
-
-   crc0 = _mm_crc32_u64(seed, k[0] & m[0]);
-
-   return crc0;
-}
-
-static inline uint64_t
-hash_crc_key16(void *key, void *mask, __rte_unused uint32_t key_size,
-   uint64_t seed)
-{
-   uint64_t *k = key;
-   uint64_t *m = mask;
-   uint64_t k0, crc0, crc1;
-
-   k0 = k[0] & m[0];
-
-   crc0 = _mm_crc32_u64(k0, seed);
-   crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]);
-
-   crc0 ^= crc1;
-
-   return crc0;
-}
-
-static inline uint64_t
-hash_crc_key24(void *key, void *ma

[dpdk-dev] [PATCH 2/3] examples/ip_pipeline: modify application to use librte_table headers

2018-09-07 Thread Kevin Laatz
This commit modifies the IP Pipeline application to use the new header
files in librte_table.

As we are now using the new header files, we can remove the old ones from
the application directory.

Signed-off-by: Cristian Dumitrescu 
Signed-off-by: Kevin Laatz 
---
 examples/ip_pipeline/action.c  |  34 ++--
 examples/ip_pipeline/hash_func.h   | 357 -
 examples/ip_pipeline/hash_func_arm64.h | 232 -
 examples/ip_pipeline/pipeline.c|  19 +-
 4 files changed, 26 insertions(+), 616 deletions(-)
 delete mode 100644 examples/ip_pipeline/hash_func.h
 delete mode 100644 examples/ip_pipeline/hash_func_arm64.h

diff --git a/examples/ip_pipeline/action.c b/examples/ip_pipeline/action.c
index a29c2b3..20497c3 100644
--- a/examples/ip_pipeline/action.c
+++ b/examples/ip_pipeline/action.c
@@ -7,9 +7,9 @@
 #include 
 
 #include 
+#include 
 
 #include "action.h"
-#include "hash_func.h"
 
 /**
  * Input port
@@ -57,35 +57,35 @@ port_in_action_profile_create(const char *name,
(params->lb.f_hash == NULL)) {
switch (params->lb.key_size) {
case  8:
-   params->lb.f_hash = hash_default_key8;
+   params->lb.f_hash = rte_table_hash_crc_key8;
break;
 
case 16:
-   params->lb.f_hash = hash_default_key16;
+   params->lb.f_hash = rte_table_hash_crc_key16;
break;
 
case 24:
-   params->lb.f_hash = hash_default_key24;
+   params->lb.f_hash = rte_table_hash_crc_key24;
break;
 
case 32:
-   params->lb.f_hash = hash_default_key32;
+   params->lb.f_hash = rte_table_hash_crc_key32;
break;
 
case 40:
-   params->lb.f_hash = hash_default_key40;
+   params->lb.f_hash = rte_table_hash_crc_key40;
break;
 
case 48:
-   params->lb.f_hash = hash_default_key48;
+   params->lb.f_hash = rte_table_hash_crc_key48;
break;
 
case 56:
-   params->lb.f_hash = hash_default_key56;
+   params->lb.f_hash = rte_table_hash_crc_key56;
break;
 
case 64:
-   params->lb.f_hash = hash_default_key64;
+   params->lb.f_hash = rte_table_hash_crc_key64;
break;
 
default:
@@ -192,35 +192,35 @@ table_action_profile_create(const char *name,
(params->lb.f_hash == NULL)) {
switch (params->lb.key_size) {
case 8:
-   params->lb.f_hash = hash_default_key8;
+   params->lb.f_hash = rte_table_hash_crc_key8;
break;
 
case 16:
-   params->lb.f_hash = hash_default_key16;
+   params->lb.f_hash = rte_table_hash_crc_key16;
break;
 
case 24:
-   params->lb.f_hash = hash_default_key24;
+   params->lb.f_hash = rte_table_hash_crc_key24;
break;
 
case 32:
-   params->lb.f_hash = hash_default_key32;
+   params->lb.f_hash = rte_table_hash_crc_key32;
break;
 
case 40:
-   params->lb.f_hash = hash_default_key40;
+   params->lb.f_hash = rte_table_hash_crc_key40;
break;
 
case 48:
-   params->lb.f_hash = hash_default_key48;
+   params->lb.f_hash = rte_table_hash_crc_key48;
break;
 
case 56:
-   params->lb.f_hash = hash_default_key56;
+   params->lb.f_hash = rte_table_hash_crc_key56;
break;
 
case 64:
-   params->lb.f_hash = hash_default_key64;
+   params->lb.f_hash = rte_table_hash_crc_key64;
break;
 
default:
diff --git a/examples/ip_pipeline/hash_func.h b/examples/ip_pipeline/hash_func.h
deleted file mode 100644
index f1b9d94..000
--- a/examples/ip_pipeline/hash_func.h
+++ /dev/null
@@ -1,357 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2018 Intel Corporation
- */
-
-#ifndef __INCLUDE_HASH_FUNC_H__
-#define __INCLUDE_HASH_FUNC_H__
-
-static inline uint64_t
-hash_xor_key8(void *key, void *mask, __rte_unused uint32_t key_size,
-   uint64_t seed)
-{
-   uint64_t *k = key;
-   uint64_t *m = mask;
-   uint64_t xor0;
-
-   xor0 = seed 

[dpdk-dev] [PATCH v2 1/3] lib/librte_table: add hash_func header files

2018-09-07 Thread Kevin Laatz
This commit adds rte_table_hash_func.h and rte_table_hash_func_arm64.h to
librte_table. This will replace hash_func.h and hash_func_arm64.h in the IP
Pipeline application and in SoftNIC. This also adds a scalar implementation
of the x86_64 intrinsic for crc32 as a generic fallback.

Signed-off-by: Cristian Dumitrescu 
Signed-off-by: Kevin Laatz 

---
v2:
   - Fixed typo in commit message
   - Fixed typo in arm header that caused some compilations to fail for the
 entire patchset
---
 lib/librte_table/Makefile|   2 +
 lib/librte_table/meson.build |   2 +
 lib/librte_table/rte_table_hash_func.h   | 244 +++
 lib/librte_table/rte_table_hash_func_arm64.h |  21 +++
 lib/librte_table/rte_table_version.map   |  14 ++
 5 files changed, 283 insertions(+)
 create mode 100644 lib/librte_table/rte_table_hash_func.h
 create mode 100644 lib/librte_table/rte_table_hash_func_arm64.h

diff --git a/lib/librte_table/Makefile b/lib/librte_table/Makefile
index 276d476..f935678 100644
--- a/lib/librte_table/Makefile
+++ b/lib/librte_table/Makefile
@@ -46,6 +46,8 @@ SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include += rte_table_acl.h
 endif
 SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include += rte_table_hash.h
 SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include += rte_table_hash_cuckoo.h
+SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include += rte_table_hash_func.h
+SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include += rte_table_hash_func_arm64.h
 SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include += rte_lru.h
 ifeq ($(CONFIG_RTE_ARCH_X86),y)
 SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include += rte_lru_x86.h
diff --git a/lib/librte_table/meson.build b/lib/librte_table/meson.build
index 8b2f841..6ae3cd6 100644
--- a/lib/librte_table/meson.build
+++ b/lib/librte_table/meson.build
@@ -19,6 +19,8 @@ headers = files('rte_table.h',
'rte_table_lpm_ipv6.h',
'rte_table_hash.h',
'rte_table_hash_cuckoo.h',
+   'rte_table_hash_func.h',
+   'rte_table_hash_func_arm64.h',
'rte_lru.h',
'rte_table_array.h',
'rte_table_stub.h')
diff --git a/lib/librte_table/rte_table_hash_func.h 
b/lib/librte_table/rte_table_hash_func.h
new file mode 100644
index 000..4eadbfb
--- /dev/null
+++ b/lib/librte_table/rte_table_hash_func.h
@@ -0,0 +1,244 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2018 Intel Corporation
+ */
+
+#ifndef __INCLUDE_RTE_TABLE_HASH_FUNC_H__
+#define __INCLUDE_RTE_TABLE_HASH_FUNC_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include 
+
+#include 
+
+static inline uint64_t
+rte_crc32_u64_generic(uint64_t crc, uint64_t value)
+{
+   int i;
+
+   crc = (crc & 0xLLU) ^ value;
+   for (i = 63; i >= 0; i--) {
+   uint64_t mask;
+
+   mask = -(crc & 1LLU);
+   crc = (crc >> 1LLU) ^ (0x82F63B78LLU & mask);
+   }
+
+   return crc;
+}
+
+#if defined(RTE_ARCH_X86_64)
+
+#include 
+
+static inline uint64_t
+rte_crc32_u64(uint64_t crc, uint64_t v)
+{
+   return _mm_crc32_u64(crc, v);
+}
+
+#elif defined(RTE_ARCH_ARM64)
+#include "rte_table_hash_func_arm64.h"
+#else
+
+static inline uin64_t
+rte_crc32_u64(uint64_t crc, uint64_t v)
+{
+   return rte_crc32_u64_generic(crc, v);
+}
+
+#endif
+
+static inline uint64_t
+rte_table_hash_crc_key8(void *key, void *mask, __rte_unused uint32_t key_size,
+   uint64_t seed)
+{
+   uint64_t *k = key;
+   uint64_t *m = mask;
+   uint64_t crc0;
+
+   crc0 = rte_crc32_u64(seed, k[0] & m[0]);
+
+   return crc0;
+}
+
+static inline uint64_t
+rte_table_hash_crc_key16(void *key, void *mask, __rte_unused uint32_t key_size,
+   uint64_t seed)
+{
+   uint64_t *k = key;
+   uint64_t *m = mask;
+   uint64_t k0, crc0, crc1;
+
+   k0 = k[0] & m[0];
+
+   crc0 = rte_crc32_u64(k0, seed);
+   crc1 = rte_crc32_u64(k0 >> 32, k[1] & m[1]);
+
+   crc0 ^= crc1;
+
+   return crc0;
+}
+
+static inline uint64_t
+rte_table_hash_crc_key24(void *key, void *mask, __rte_unused uint32_t key_size,
+   uint64_t seed)
+{
+   uint64_t *k = key;
+   uint64_t *m = mask;
+   uint64_t k0, k2, crc0, crc1;
+
+   k0 = k[0] & m[0];
+   k2 = k[2] & m[2];
+
+   crc0 = rte_crc32_u64(k0, seed);
+   crc1 = rte_crc32_u64(k0 >> 32, k[1] & m[1]);
+
+   crc0 = rte_crc32_u64(crc0, k2);
+
+   crc0 ^= crc1;
+
+   return crc0;
+}
+
+static inline uint64_t
+rte_table_hash_crc_key32(void *key, void *mask, __rte_unused uint32_t key_size,
+   uint64_t seed)
+{
+   uint64_t *k = key;
+   uint64_t *m = mask;
+   uint64_t k0, k2, crc0, crc1, crc2, crc3;
+
+   k0 = k[0] & m[0];
+   k2 = k[2] & m[2];
+
+   crc0 = rte_crc32_u64(k0, seed);
+   crc1 = rte_crc32_u64(k0 >> 32, k[1] & m[1]);
+
+   crc2 = rte_crc32_u64(k2, k[3] & m[3]);
+   crc3 = k2 >> 32;
+
+   crc0 = rte_crc32_u64(crc0, crc1);
+   cr

[dpdk-dev] [PATCH v2 2/3] examples/ip_pipeline: modify application to use librte_table headers

2018-09-07 Thread Kevin Laatz
This commit modifies the IP Pipeline application to use the new header
files in librte_table.

As we are now using the new header files, we can remove the old ones from
the application directory.

Signed-off-by: Cristian Dumitrescu 
Signed-off-by: Kevin Laatz 
---
 examples/ip_pipeline/action.c  |  34 ++--
 examples/ip_pipeline/hash_func.h   | 357 -
 examples/ip_pipeline/hash_func_arm64.h | 232 -
 examples/ip_pipeline/pipeline.c|  19 +-
 4 files changed, 26 insertions(+), 616 deletions(-)
 delete mode 100644 examples/ip_pipeline/hash_func.h
 delete mode 100644 examples/ip_pipeline/hash_func_arm64.h

diff --git a/examples/ip_pipeline/action.c b/examples/ip_pipeline/action.c
index a29c2b3..20497c3 100644
--- a/examples/ip_pipeline/action.c
+++ b/examples/ip_pipeline/action.c
@@ -7,9 +7,9 @@
 #include 
 
 #include 
+#include 
 
 #include "action.h"
-#include "hash_func.h"
 
 /**
  * Input port
@@ -57,35 +57,35 @@ port_in_action_profile_create(const char *name,
(params->lb.f_hash == NULL)) {
switch (params->lb.key_size) {
case  8:
-   params->lb.f_hash = hash_default_key8;
+   params->lb.f_hash = rte_table_hash_crc_key8;
break;
 
case 16:
-   params->lb.f_hash = hash_default_key16;
+   params->lb.f_hash = rte_table_hash_crc_key16;
break;
 
case 24:
-   params->lb.f_hash = hash_default_key24;
+   params->lb.f_hash = rte_table_hash_crc_key24;
break;
 
case 32:
-   params->lb.f_hash = hash_default_key32;
+   params->lb.f_hash = rte_table_hash_crc_key32;
break;
 
case 40:
-   params->lb.f_hash = hash_default_key40;
+   params->lb.f_hash = rte_table_hash_crc_key40;
break;
 
case 48:
-   params->lb.f_hash = hash_default_key48;
+   params->lb.f_hash = rte_table_hash_crc_key48;
break;
 
case 56:
-   params->lb.f_hash = hash_default_key56;
+   params->lb.f_hash = rte_table_hash_crc_key56;
break;
 
case 64:
-   params->lb.f_hash = hash_default_key64;
+   params->lb.f_hash = rte_table_hash_crc_key64;
break;
 
default:
@@ -192,35 +192,35 @@ table_action_profile_create(const char *name,
(params->lb.f_hash == NULL)) {
switch (params->lb.key_size) {
case 8:
-   params->lb.f_hash = hash_default_key8;
+   params->lb.f_hash = rte_table_hash_crc_key8;
break;
 
case 16:
-   params->lb.f_hash = hash_default_key16;
+   params->lb.f_hash = rte_table_hash_crc_key16;
break;
 
case 24:
-   params->lb.f_hash = hash_default_key24;
+   params->lb.f_hash = rte_table_hash_crc_key24;
break;
 
case 32:
-   params->lb.f_hash = hash_default_key32;
+   params->lb.f_hash = rte_table_hash_crc_key32;
break;
 
case 40:
-   params->lb.f_hash = hash_default_key40;
+   params->lb.f_hash = rte_table_hash_crc_key40;
break;
 
case 48:
-   params->lb.f_hash = hash_default_key48;
+   params->lb.f_hash = rte_table_hash_crc_key48;
break;
 
case 56:
-   params->lb.f_hash = hash_default_key56;
+   params->lb.f_hash = rte_table_hash_crc_key56;
break;
 
case 64:
-   params->lb.f_hash = hash_default_key64;
+   params->lb.f_hash = rte_table_hash_crc_key64;
break;
 
default:
diff --git a/examples/ip_pipeline/hash_func.h b/examples/ip_pipeline/hash_func.h
deleted file mode 100644
index f1b9d94..000
--- a/examples/ip_pipeline/hash_func.h
+++ /dev/null
@@ -1,357 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2018 Intel Corporation
- */
-
-#ifndef __INCLUDE_HASH_FUNC_H__
-#define __INCLUDE_HASH_FUNC_H__
-
-static inline uint64_t
-hash_xor_key8(void *key, void *mask, __rte_unused uint32_t key_size,
-   uint64_t seed)
-{
-   uint64_t *k = key;
-   uint64_t *m = mask;
-   uint64_t xor0;
-
-   xor0 = seed 

[dpdk-dev] [PATCH v2 3/3] net/softnic: modify softnic to use librte_table headers

2018-09-07 Thread Kevin Laatz
This commit modifies SoftNIC to make use of the new header files in
librte_table.

As we are now using the new header files in librte_table in SoftNIC, we no
longer need the old header files so they can be removed.

Signed-off-by: Cristian Dumitrescu 
Signed-off-by: Kevin Laatz 
---
 drivers/net/softnic/hash_func.h| 359 -
 drivers/net/softnic/hash_func_arm64.h  | 261 --
 drivers/net/softnic/rte_eth_softnic_action.c   |  34 +--
 drivers/net/softnic/rte_eth_softnic_pipeline.c |  19 +-
 4 files changed, 26 insertions(+), 647 deletions(-)
 delete mode 100644 drivers/net/softnic/hash_func.h
 delete mode 100644 drivers/net/softnic/hash_func_arm64.h

diff --git a/drivers/net/softnic/hash_func.h b/drivers/net/softnic/hash_func.h
deleted file mode 100644
index 198d2b2..000
--- a/drivers/net/softnic/hash_func.h
+++ /dev/null
@@ -1,359 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2018 Intel Corporation
- */
-
-#ifndef __INCLUDE_HASH_FUNC_H__
-#define __INCLUDE_HASH_FUNC_H__
-
-#include 
-
-static inline uint64_t
-hash_xor_key8(void *key, void *mask, __rte_unused uint32_t key_size,
-   uint64_t seed)
-{
-   uint64_t *k = key;
-   uint64_t *m = mask;
-   uint64_t xor0;
-
-   xor0 = seed ^ (k[0] & m[0]);
-
-   return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key16(void *key, void *mask, __rte_unused uint32_t key_size,
-   uint64_t seed)
-{
-   uint64_t *k = key;
-   uint64_t *m = mask;
-   uint64_t xor0;
-
-   xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-
-   return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key24(void *key, void *mask, __rte_unused uint32_t key_size,
-   uint64_t seed)
-{
-   uint64_t *k = key;
-   uint64_t *m = mask;
-   uint64_t xor0;
-
-   xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-
-   xor0 ^= k[2] & m[2];
-
-   return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key32(void *key, void *mask, __rte_unused uint32_t key_size,
-   uint64_t seed)
-{
-   uint64_t *k = key;
-   uint64_t *m = mask;
-   uint64_t xor0, xor1;
-
-   xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-   xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
-
-   xor0 ^= xor1;
-
-   return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key40(void *key, void *mask, __rte_unused uint32_t key_size,
-   uint64_t seed)
-{
-   uint64_t *k = key;
-   uint64_t *m = mask;
-   uint64_t xor0, xor1;
-
-   xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-   xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
-
-   xor0 ^= xor1;
-
-   xor0 ^= k[4] & m[4];
-
-   return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key48(void *key, void *mask, __rte_unused uint32_t key_size,
-   uint64_t seed)
-{
-   uint64_t *k = key;
-   uint64_t *m = mask;
-   uint64_t xor0, xor1, xor2;
-
-   xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-   xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
-   xor2 = (k[4] & m[4]) ^ (k[5] & m[5]);
-
-   xor0 ^= xor1;
-
-   xor0 ^= xor2;
-
-   return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key56(void *key, void *mask, __rte_unused uint32_t key_size,
-   uint64_t seed)
-{
-   uint64_t *k = key;
-   uint64_t *m = mask;
-   uint64_t xor0, xor1, xor2;
-
-   xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-   xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
-   xor2 = (k[4] & m[4]) ^ (k[5] & m[5]);
-
-   xor0 ^= xor1;
-   xor2 ^= k[6] & m[6];
-
-   xor0 ^= xor2;
-
-   return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key64(void *key, void *mask, __rte_unused uint32_t key_size,
-   uint64_t seed)
-{
-   uint64_t *k = key;
-   uint64_t *m = mask;
-   uint64_t xor0, xor1, xor2, xor3;
-
-   xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-   xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
-   xor2 = (k[4] & m[4]) ^ (k[5] & m[5]);
-   xor3 = (k[6] & m[6]) ^ (k[7] & m[7]);
-
-   xor0 ^= xor1;
-   xor2 ^= xor3;
-
-   xor0 ^= xor2;
-
-   return (xor0 >> 32) ^ xor0;
-}
-
-#if defined(RTE_ARCH_X86_64)
-
-#include 
-
-static inline uint64_t
-hash_crc_key8(void *key, void *mask, __rte_unused uint32_t key_size,
-   uint64_t seed)
-{
-   uint64_t *k = key;
-   uint64_t *m = mask;
-   uint64_t crc0;
-
-   crc0 = _mm_crc32_u64(seed, k[0] & m[0]);
-
-   return crc0;
-}
-
-static inline uint64_t
-hash_crc_key16(void *key, void *mask, __rte_unused uint32_t key_size,
-   uint64_t seed)
-{
-   uint64_t *k = key;
-   uint64_t *m = mask;
-   uint64_t k0, crc0, crc1;
-
-   k0 = k[0] & m[0];
-
-   crc0 = _mm_crc32_u64(k0, seed);
-   crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]);
-
-   crc0 ^= crc1;
-
-   return crc0;
-}
-
-static inline uint64_t
-hash_crc_key24(void *key, void *ma

Re: [dpdk-dev] [PATCH v2 1/3] lib/librte_table: add hash_func header files

2018-09-07 Thread Gavin Hu (Arm Technology China)
The code looks good, some comments to the commit message.

> -Original Message-
> From: Kevin Laatz 
> Sent: Friday, September 7, 2018 4:05 PM
> To: dev@dpdk.org
> Cc: cristian.dumitre...@intel.com; Jianbo Liu ; Gavin
> Hu (Arm Technology China) ;
> jerin.ja...@caviumnetworks.com; Kevin Laatz 
> Subject: [PATCH v2 1/3] lib/librte_table: add hash_func header files
>
> This commit adds rte_table_hash_func.h and rte_table_hash_func_arm64.h
> to librte_table. This will replace hash_func.h and hash_func_arm64.h in the
> IP Pipeline application and in SoftNIC. This also adds a scalar implementation
> of the x86_64 intrinsic for crc32 as a generic fallback.
It is better to mention this patch reduces code duplication by removing 
duplicate headers files
Within two folders and consolidating them into a single one.
>
> Signed-off-by: Cristian Dumitrescu 
> Signed-off-by: Kevin Laatz 
Acked-by: Gavin Hu 
> ---
> v2:
>- Fixed typo in commit message
>- Fixed typo in arm header that caused some compilations to fail for the
>  entire patchset
> ---
>  lib/librte_table/Makefile|   2 +
>  lib/librte_table/meson.build |   2 +
>  lib/librte_table/rte_table_hash_func.h   | 244
> +++
>  lib/librte_table/rte_table_hash_func_arm64.h |  21 +++
>  lib/librte_table/rte_table_version.map   |  14 ++
>  5 files changed, 283 insertions(+)
>  create mode 100644 lib/librte_table/rte_table_hash_func.h
>  create mode 100644 lib/librte_table/rte_table_hash_func_arm64.h
>
> diff --git a/lib/librte_table/Makefile b/lib/librte_table/Makefile index
> 276d476..f935678 100644
> --- a/lib/librte_table/Makefile
> +++ b/lib/librte_table/Makefile
> @@ -46,6 +46,8 @@ SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include +=
> rte_table_acl.h  endif  SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include +=
> rte_table_hash.h  SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include +=
> rte_table_hash_cuckoo.h
> +SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include += rte_table_hash_func.h
> +SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include +=
> +rte_table_hash_func_arm64.h
>  SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include += rte_lru.h  ifeq
> ($(CONFIG_RTE_ARCH_X86),y)  SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-
> include += rte_lru_x86.h diff --git a/lib/librte_table/meson.build
> b/lib/librte_table/meson.build index 8b2f841..6ae3cd6 100644
> --- a/lib/librte_table/meson.build
> +++ b/lib/librte_table/meson.build
> @@ -19,6 +19,8 @@ headers = files('rte_table.h',
>  'rte_table_lpm_ipv6.h',
>  'rte_table_hash.h',
>  'rte_table_hash_cuckoo.h',
> +'rte_table_hash_func.h',
> +'rte_table_hash_func_arm64.h',
>  'rte_lru.h',
>  'rte_table_array.h',
>  'rte_table_stub.h')
> diff --git a/lib/librte_table/rte_table_hash_func.h
> b/lib/librte_table/rte_table_hash_func.h
> new file mode 100644
> index 000..4eadbfb
> --- /dev/null
> +++ b/lib/librte_table/rte_table_hash_func.h
> @@ -0,0 +1,244 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(c) 2010-2018 Intel Corporation  */
> +
> +#ifndef __INCLUDE_RTE_TABLE_HASH_FUNC_H__ #define
> +__INCLUDE_RTE_TABLE_HASH_FUNC_H__
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +#include 
> +
> +#include 
> +
> +static inline uint64_t
> +rte_crc32_u64_generic(uint64_t crc, uint64_t value) {
> +int i;
> +
> +crc = (crc & 0xLLU) ^ value;
> +for (i = 63; i >= 0; i--) {
> +uint64_t mask;
> +
> +mask = -(crc & 1LLU);
> +crc = (crc >> 1LLU) ^ (0x82F63B78LLU & mask);
> +}
> +
> +return crc;
> +}
> +
> +#if defined(RTE_ARCH_X86_64)
> +
> +#include 
> +
> +static inline uint64_t
> +rte_crc32_u64(uint64_t crc, uint64_t v) {
> +return _mm_crc32_u64(crc, v);
> +}
> +
> +#elif defined(RTE_ARCH_ARM64)
> +#include "rte_table_hash_func_arm64.h"
> +#else
> +
> +static inline uin64_t
> +rte_crc32_u64(uint64_t crc, uint64_t v) {
> +return rte_crc32_u64_generic(crc, v);
> +}
> +
> +#endif
> +
> +static inline uint64_t
> +rte_table_hash_crc_key8(void *key, void *mask, __rte_unused uint32_t
> key_size,
> +uint64_t seed)
> +{
> +uint64_t *k = key;
> +uint64_t *m = mask;
> +uint64_t crc0;
> +
> +crc0 = rte_crc32_u64(seed, k[0] & m[0]);
> +
> +return crc0;
> +}
> +
> +static inline uint64_t
> +rte_table_hash_crc_key16(void *key, void *mask, __rte_unused uint32_t
> key_size,
> +uint64_t seed)
> +{
> +uint64_t *k = key;
> +uint64_t *m = mask;
> +uint64_t k0, crc0, crc1;
> +
> +k0 = k[0] & m[0];
> +
> +crc0 = rte_crc32_u64(k0, seed);
> +crc1 = rte_crc32_u64(k0 >> 32, k[1] & m[1]);
> +
> +crc0 ^= crc1;
> +
> +return crc0;
> +}
> +
> +static inline uint64_t
> +rte_table_hash_crc_key24(void *key, void *mask, __rte_unused uint32_t
> key_size,
> +uint64_t seed)
> +{
> +uint64_t *k = key;
> +uint64_t *m = mask;
> +uint64_t k0, k2, crc0, crc1;
> +
> +k0 = k[0] & m[0];
> +k2 = k[2] & m[2];
> +
> +crc0 = rte_crc32_u64(k0, seed);
> +crc1 = rte_crc32_u64(k0 >> 32, k[1] & m[1]);
> +
> +crc0 = rte_crc32_u64(crc0, k2);
> +
> +crc0 ^= crc1;
> +
> +return crc0;
> +}
> +
> +static inline uint64_t
> +rte_table_h

Re: [dpdk-dev] [PATCH v3] net/i40e: add interface to choose latest vector path

2018-09-07 Thread Li, Xiaoyun
OK. Will send v4 later. Thanks.

> -Original Message-
> From: Zhang, Qi Z
> Sent: Wednesday, September 5, 2018 20:22
> To: Li, Xiaoyun ; Xing, Beilei 
> Cc: dev@dpdk.org; Yang, Zhiyong ; Richardson,
> Bruce ; Hunt, David 
> Subject: RE: [PATCH v3] net/i40e: add interface to choose latest vector path
> 
> Hi Xiaoyun:
> 
> > -Original Message-
> > From: Li, Xiaoyun
> > Sent: Tuesday, September 4, 2018 7:40 PM
> > To: Xing, Beilei ; Zhang, Qi Z
> > 
> > Cc: dev@dpdk.org; Yang, Zhiyong ; Richardson,
> > Bruce ; Hunt, David
> > ; Li, Xiaoyun 
> > Subject: [PATCH v3] net/i40e: add interface to choose latest vector
> > path
> >
> > Right now, vector path is limited to only use on later platform.
> > This patch adds a devarg enable-latest-vec to allow the users to use
> > the latest vector path that the platform supported. Namely, using AVX2
> > vector path on broadwell is possible.
> >
> > Signed-off-by: Xiaoyun Li 
> > ---
> > v3:
> >  * Polish the doc and commit log.
> > v2:
> >  * Correct the calling of the wrong function last time.
> >  * Fix seg fault bug.
> >
> >  doc/guides/nics/i40e.rst   |  8 ++
> >  doc/guides/rel_notes/release_18_11.rst |  4 +++
> >  drivers/net/i40e/i40e_ethdev.c | 38
> > ++
> >  drivers/net/i40e/i40e_ethdev.h |  1 +
> >  drivers/net/i40e/i40e_rxtx.c   | 27 ++
> >  5 files changed, 78 insertions(+)
> >
> > diff --git a/doc/guides/nics/i40e.rst b/doc/guides/nics/i40e.rst index
> > 65d87f869..6158e7c34 100644
> > --- a/doc/guides/nics/i40e.rst
> > +++ b/doc/guides/nics/i40e.rst
> > @@ -163,6 +163,14 @@ Runtime Config Options
> >Currently hot-plugging of representor ports is not supported so all
> required
> >representors must be specified on the creation of the PF.
> >
> > +- ``Enable latest vector`` (default ``disable``)
> > +
> > +  Vector path was limited to use only on later platform. But users
> > + may want the  latest vector path. For example, VPP users may want to
> > + use
> > + AVX2 vector path on HSW/BDW  because it can get better perf. So
> > + ``devargs`` parameter ``enable-latest-vec``  is introduced, for example::
> > +-w 84:00.0,enable-latest-vec=1
> 
> 
> How about "use_latest_vec" or "use-lastest-vpmd"?
> 
> > +
> >  Driver compilation and testing
> >  --
> >
> > diff --git a/doc/guides/rel_notes/release_18_11.rst
> > b/doc/guides/rel_notes/release_18_11.rst
> > index 3ae6b3f58..f8b0f3189 100644
> > --- a/doc/guides/rel_notes/release_18_11.rst
> > +++ b/doc/guides/rel_notes/release_18_11.rst
> > @@ -54,6 +54,10 @@ New Features
> >   Also, make sure to start the actual text at the margin.
> >   =
> >
> > +* **Added a devarg to eable the latest vector path.**
> > +  A new devarg ``enable-latest-vec`` was introduced to allow users to
> > +choose
> > +  the latest vector path that the platform supported. For example,
> > +VPP users
> > +  can use AVX2 vector path on BDW/HSW to get better performance.
> >
> >  API Changes
> >  ---
> > diff --git a/drivers/net/i40e/i40e_ethdev.c
> > b/drivers/net/i40e/i40e_ethdev.c index 85a6a867f..16b5345fb 100644
> > --- a/drivers/net/i40e/i40e_ethdev.c
> > +++ b/drivers/net/i40e/i40e_ethdev.c
> > @@ -12513,6 +12513,44 @@ i40e_config_rss_filter(struct i40e_pf *pf,
> > return 0;
> >  }
> >
> > +#define ETH_I40E_ENABLE_LATEST_VEC "enable-latest-vec"
> 
> This should be defined along with other exist devargs, please check
> ETH_I40E_SUPPORT_MULTI_DRIVER for reference Also it should be
> registered with RTE_PMD_REGISTER_PARAM_STRING.
> 
> > +
> > +bool
> > +i40e_parse_latest_vec(struct rte_eth_dev *dev) {
> > +   static const char *const valid_keys[] = {
> > +   ETH_I40E_ENABLE_LATEST_VEC, NULL};
> > +   int enable_latest_vec;
> > +   struct rte_kvargs *kvlist;
> > +
> > +   if (!dev->device->devargs)
> > +   return 0;
> > +
> > +   kvlist = rte_kvargs_parse(dev->device->devargs->args, valid_keys);
> > +   if (!kvlist)
> > +   return -EINVAL;
> > +
> > +   if (!rte_kvargs_count(kvlist, ETH_I40E_ENABLE_LATEST_VEC))
> > +   return 0;
> > +
> > +   if (rte_kvargs_count(kvlist, ETH_I40E_ENABLE_LATEST_VEC) > 1)
> > +   PMD_DRV_LOG(WARNING, "More than one argument \"%s\"
> and
> > only "
> > +   "the first one is used !",
> > +   ETH_I40E_ENABLE_LATEST_VEC);
> > +
> > +   enable_latest_vec = atoi((&kvlist->pairs[0])->value);
> > +
> > +   rte_kvargs_free(kvlist);
> > +
> > +   if (enable_latest_vec != 0 && enable_latest_vec != 1)
> > +   PMD_DRV_LOG(WARNING, "Value should be 0 or 1, set it as
> 1!");
> > +
> > +   if (enable_latest_vec)
> > +   return true;
> > +   else
> > +   return false;
> > +}
> 
> We call rte_kvargs_parse in different place for different parameter which is
> not necessary.
> it's better to merge them into one parse_d

Re: [dpdk-dev] [PATCH] eal: force IOVA mode to physical

2018-09-07 Thread Burakov, Anatoly

On 06-Sep-18 8:34 AM, Jerin Jacob wrote:

-Original Message-

Date: Tue, 4 Sep 2018 23:40:36 -0400
From: Eric Zhang 
To: santosh , hemant.agra...@nxp.com,
  Gaëtan Rivet , "Burakov, Anatoly"
  
CC: bruce.richard...@intel.com, dev@dpdk.org, allain.leg...@windriver.com,
  matt.pet...@windriver.com
Subject: Re: [dpdk-dev] [PATCH] eal: force IOVA mode to physical
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
  Thunderbird/52.9.1

On 08/30/2018 08:59 AM, santosh wrote:

On Thursday 30 August 2018 05:43 PM, Hemant wrote:

External Email

Hi,

On 8/30/2018 3:13 PM, Gaëtan Rivet wrote:

Hi,

On Thu, Aug 30, 2018 at 10:09:04AM +0100, Burakov, Anatoly wrote:

On 29-Aug-18 4:58 PM, eric zhang wrote:

This patch adds a configuration option to force the IOVA mode to
physical address (PA). There exists virtual devices that are not
directly attached to the PCI bus, and therefore the auto detection
of the IOVA mode based on probing the PCI bus and IOMMU configuration
may not report the required addressing mode. Having the configuration
option permits the mode to be explicitly configured in this scenario.

Signed-off-by: eric zhang 
---

Defining this at compile-time seems like an overkill. Wouldn't it be better
to just add an EAL command-line option to force IOVA mode to a particular
value?

That is a good suggestion.

--
Thanks,
Anatoly

What is the bus of these devices and why not implement get_iommu_class
in it?

There are cases, where you are using dpdk libraries with external
libraries and you need to change the default behavior DPDK lib to use
physical address instead of virtual address.
Providing an option to user will help.



More appropriate solution could be:
* Either fix it at bus layer .. i.e.. get_iommu_class()..
* Or introduce something like [1] --iova-mode= param.

Former is better solution than latter if autodetection is a key criteria.
Thanks.

[1] http://patchwork.dpdk.org/patch/25192/


It's not generic which couldn't be fixed at bus layer.
So what's the preference of EAL option or compile time solution?
Adding --iova-mode as patch [1] will overrivde auto-detection
rte_bus_get_iommu_class()
make it no use; compile time solution will align with upstream and keep
new atuodetection
solution in #ifndef.


If it is for vdev devices, why not introduce something like
RTE_PCI_DRV_IOVA_AS_VA and let vdev device describe its personality.
And based on the devices(flags) on vdev bus, rte_bus_get_iommu_class()
of vdev can decide the mode just like PCI bus.



That seems like a better option to me, +1. As far as i know, at the 
moment if there are no devices attached at all, or if there are only 
vdev devices attached, DPDK will default to IOVA as PA mode for no good 
reason; such a change would certainly fix this.






Thanks
Eric






--
Thanks,
Anatoly


Re: [dpdk-dev] [PATCH 1/3] net/virtio-user: fix deadlock in memory events callback

2018-09-07 Thread Burakov, Anatoly

On 05-Sep-18 5:28 AM, Tiwei Bie wrote:

Deadlock can occur when allocating memory if a vhost-kernel
based virtio-user device is in use. To fix the deadlock,
we will take memory hotplug lock explicitly in virtio-user
when necessary, and always call the _thread_unsafe memory
functions.

Bugzilla ID: 81
Fixes: 12ecb2f63b12 ("net/virtio-user: support memory hotplug")
Cc: sta...@dpdk.org

Reported-by: Seán Harte 
Signed-off-by: Tiwei Bie 
---
  drivers/net/virtio/virtio_user/vhost_kernel.c |  6 +-
  .../net/virtio/virtio_user/virtio_user_dev.c  | 19 +++
  2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/drivers/net/virtio/virtio_user/vhost_kernel.c 
b/drivers/net/virtio/virtio_user/vhost_kernel.c
index b2444096c..897fee0af 100644
--- a/drivers/net/virtio/virtio_user/vhost_kernel.c
+++ b/drivers/net/virtio/virtio_user/vhost_kernel.c
@@ -115,7 +115,11 @@ prepare_vhost_memory_kernel(void)
wa.region_nr = 0;
wa.vm = vm;
  
-	if (rte_memseg_contig_walk(add_memory_region, &wa) < 0) {

+   /*
+* The memory lock has already been taken by memory subsystem
+* or virtio_user_start_device().
+*/
+   if (rte_memseg_contig_walk_thread_unsafe(add_memory_region, &wa) < 0) {
free(vm);
return NULL;
}
diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c 
b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index 7df600b02..869e96f87 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -13,6 +13,8 @@
  #include 
  #include 
  
+#include 

+
  #include "vhost.h"
  #include "virtio_user_dev.h"
  #include "../virtio_ethdev.h"
@@ -109,9 +111,24 @@ is_vhost_user_by_type(const char *path)
  int
  virtio_user_start_device(struct virtio_user_dev *dev)
  {
+   struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
uint64_t features;
int ret;
  
+	/*

+* XXX workaround!
+*
+* We need to make sure that the locks will be
+* taken in the correct order to avoid deadlocks.
+*
+* Before releasing this lock, this thread should
+* not trigger any memory hotplug events.
+*
+* This is a temporary workaround, and should be
+* replaced when we get proper supports from the
+* memory subsystem in the future.
+*/
+   rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
pthread_mutex_lock(&dev->mutex);
  
  	if (is_vhost_user_by_type(dev->path) && dev->vhostfd < 0)

@@ -152,10 +169,12 @@ virtio_user_start_device(struct virtio_user_dev *dev)
  
  	dev->started = true;

pthread_mutex_unlock(&dev->mutex);
+   rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
  
  	return 0;

  error:
pthread_mutex_unlock(&dev->mutex);
+   rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
/* TODO: free resource here or caller to check */
return -1;
  }



For the memory parts,

Reviewed-by: Anatoly Burakov 

--
Thanks,
Anatoly


Re: [dpdk-dev] [PATCH 2/3] net/virtio-user: avoid parsing process mappings

2018-09-07 Thread Burakov, Anatoly

On 05-Sep-18 5:28 AM, Tiwei Bie wrote:

Recently some memory APIs were introduced to allow users to
get the file descriptor and offset for each memory segment.
We can leverage those APIs to get rid of the /proc magic on
memory table preparation in vhost-user backend.

Signed-off-by: Tiwei Bie 
---





-   for (i = 0; i < num; ++i) {
-   mr = &msg->payload.memory.regions[i];
-   mr->guest_phys_addr = huges[i].addr; /* use vaddr! */
-   mr->userspace_addr = huges[i].addr;
-   mr->memory_size = huges[i].size;
-   mr->mmap_offset = 0;
-   fds[i] = open(huges[i].path, O_RDWR);
+   if (rte_memseg_get_fd_offset_thread_unsafe(ms, &offset) < 0) {
+   PMD_DRV_LOG(ERR, "Failed to get offset, ms=%p rte_errno=%d",
+   ms, rte_errno);
+   return -1;
+   }
+
+   start_addr = (uint64_t)(uintptr_t)ms->addr;
+   end_addr = start_addr + ms->len;
+
+   for (i = 0; i < wa->region_nr; i++) {


There has to be a better way than to run this loop on every segment. 
Maybe store last-used region, and only do a region look up if there's a 
mismatch? Generally, in single-file segments mode, you'll get lots of 
segments from one memseg list one after the other, so you will need to 
do a lookup once memseg list changes, instead of on each segment.



+   if (wa->fds[i] != fd)
+   continue;
+
+   mr = &wa->vm->regions[i];
+
+   if (mr->userspace_addr + mr->memory_size < end_addr)
+   mr->memory_size = end_addr - mr->userspace_addr;
+





int fds[VHOST_MEMORY_MAX_NREGIONS];
int fd_num = 0;
-   int i, len;
+   int len;
int vhostfd = dev->vhostfd;
  
  	RTE_SET_USED(m);

@@ -364,10 +337,6 @@ vhost_user_sock(struct virtio_user_dev *dev,
return -1;
}
  
-	if (req == VHOST_USER_SET_MEM_TABLE)

-   for (i = 0; i < fd_num; ++i)
-   close(fds[i]);
-


You're sharing fd's - presumably the other side of this is in a 
different process, so it's safe to close these fd's there?



if (need_reply) {
if (vhost_user_read(vhostfd, &msg) < 0) {
PMD_DRV_LOG(ERR, "Received msg failed: %s",




--
Thanks,
Anatoly


Re: [dpdk-dev] [PATCH 3/3] net/virtio-user: fix memory hotplug support in vhost-kernel

2018-09-07 Thread Burakov, Anatoly

On 05-Sep-18 5:28 AM, Tiwei Bie wrote:

It's possible to have much more hugepage backed memory regions
than what vhost-kernel supports due to the memory hotplug, which
may cause problems. A better solution is to have the virtio-user
pass all the memory ranges reserved by DPDK to vhost-kernel.

Fixes: 12ecb2f63b12 ("net/virtio-user: support memory hotplug")
Cc: sta...@dpdk.org

Signed-off-by: Tiwei Bie 
---
  drivers/net/virtio/virtio_user/vhost_kernel.c | 38 +--
  1 file changed, 18 insertions(+), 20 deletions(-)

diff --git a/drivers/net/virtio/virtio_user/vhost_kernel.c 
b/drivers/net/virtio/virtio_user/vhost_kernel.c
index 897fee0af..9338166d9 100644
--- a/drivers/net/virtio/virtio_user/vhost_kernel.c
+++ b/drivers/net/virtio/virtio_user/vhost_kernel.c
@@ -70,41 +70,41 @@ static uint64_t vhost_req_user_to_kernel[] = {
[VHOST_USER_SET_MEM_TABLE] = VHOST_SET_MEM_TABLE,
  };
  
-struct walk_arg {

-   struct vhost_memory_kernel *vm;
-   uint32_t region_nr;
-};
  static int
-add_memory_region(const struct rte_memseg_list *msl __rte_unused,
-   const struct rte_memseg *ms, size_t len, void *arg)
+add_memseg_list(const struct rte_memseg_list *msl, void *arg)
  {
-   struct walk_arg *wa = arg;
+   struct vhost_memory_kernel *vm = arg;
struct vhost_memory_region *mr;
void *start_addr;
+   uint64_t len;
  
-	if (wa->region_nr >= max_regions)

+   if (vm->nregions >= max_regions)
return -1;
  
-	mr = &wa->vm->regions[wa->region_nr++];

-   start_addr = ms->addr;
+   start_addr = msl->base_va;
+   len = msl->page_sz * msl->memseg_arr.len;
+
+   mr = &vm->regions[vm->nregions++];
  
  	mr->guest_phys_addr = (uint64_t)(uintptr_t)start_addr;

mr->userspace_addr = (uint64_t)(uintptr_t)start_addr;
mr->memory_size = len;
-   mr->mmap_offset = 0;
+   mr->mmap_offset = 0; /* flags_padding */
+
+   PMD_DRV_LOG(DEBUG, "index=%u addr=%p len=%" PRIu64,
+   vm->nregions - 1, start_addr, len);
  
  	return 0;

  }
  
-/* By default, vhost kernel module allows 64 regions, but DPDK allows

- * 256 segments. As a relief, below function merges those virtually
- * adjacent memsegs into one region.
+/* By default, vhost kernel module allows 64 regions, but DPDK may
+ * have much more memory regions. Below function will treat each
+ * contiguous memory space reserved by DPDK as one region.
   */
  static struct vhost_memory_kernel *
  prepare_vhost_memory_kernel(void)
  {
struct vhost_memory_kernel *vm;
-   struct walk_arg wa;
  
  	vm = malloc(sizeof(struct vhost_memory_kernel) +

max_regions *
@@ -112,20 +112,18 @@ prepare_vhost_memory_kernel(void)
if (!vm)
return NULL;
  
-	wa.region_nr = 0;

-   wa.vm = vm;
+   vm->nregions = 0;
+   vm->padding = 0;
  
  	/*

 * The memory lock has already been taken by memory subsystem
 * or virtio_user_start_device().
 */
-   if (rte_memseg_contig_walk_thread_unsafe(add_memory_region, &wa) < 0) {
+   if (rte_memseg_list_walk_thread_unsafe(add_memseg_list, vm) < 0) {
free(vm);
return NULL;
}
  
-	vm->nregions = wa.region_nr;

-   vm->padding = 0;
return vm;
  }
  



Doesn't that assume single file segments mode?

--
Thanks,
Anatoly


Re: [dpdk-dev] [PATCH 02/11] telemetry: add initial connection socket

2018-09-07 Thread Burakov, Anatoly

On 23-Aug-18 1:08 PM, Ciara Power wrote:

This patch adds the telemetry UNIX socket. It is used to
allow connections from external clients.

On the initial connection from a client, ethdev stats are
registered in the metrics library, to allow for their retrieval
at a later stage.

Signed-off-by: Ciara Power 
Signed-off-by: Brian Archbold 
---


Quick question: is there really a need for a separate thread? Can't you 
just register the socket as an interrupt, and just get a callback when 
something arrives? IPC works like that right now, i see no reason to not 
do it this way for telemetry?


--
Thanks,
Anatoly


Re: [dpdk-dev] [PATCH] vhost: fix corner case for split ring enqueue operation

2018-09-07 Thread Gavin Hu (Arm Technology China)
This is a good catch for split vring, I advise to change also for packed vring. 
It also has this issue.

> -Original Message-
> From: dev  On Behalf Of Jiayu Hu
> Sent: Friday, September 7, 2018 3:25 PM
> To: dev@dpdk.org
> Cc: zhihong.w...@intel.com; tiwei@intel.com;
> maxime.coque...@redhat.com; Jiayu Hu 
> Subject: [dpdk-dev] [PATCH] vhost: fix corner case for split ring enqueue
> operation
>
> When perform enqueue operations on the split ring, if the reserved buffer
> length from the descriptor table execeeds 65535, the returned length by
> fill_vec_buf_split() is overflowed.
> This patch is to avoid this corner case.
>
> Fixes: f689586bc060 ("vhost: shadow used ring update")
>
> Signed-off-by: Jiayu Hu 
> ---
>  lib/librte_vhost/virtio_net.c | 9 +
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c 
> index
> 99c7afc..9f3c88f 100644
> --- a/lib/librte_vhost/virtio_net.c
> +++ b/lib/librte_vhost/virtio_net.c
> @@ -122,7 +122,7 @@ flush_shadow_used_ring_split(struct virtio_net *dev,
> struct vhost_virtqueue *vq)
>
>  static __rte_always_inline void
>  update_shadow_used_ring_split(struct vhost_virtqueue *vq,
> - uint16_t desc_idx, uint16_t len)
> + uint16_t desc_idx, uint32_t len)
>  {
>  uint16_t i = vq->shadow_used_idx++;
>
> @@ -329,7 +329,7 @@ static __rte_always_inline int  fill_vec_buf_split(struct
> virtio_net *dev, struct vhost_virtqueue *vq,
>   uint32_t avail_idx, uint16_t *vec_idx,
>   struct buf_vector *buf_vec, uint16_t
> *desc_chain_head,
> - uint16_t *desc_chain_len, uint8_t perm)
> + uint32_t *desc_chain_len, uint8_t perm)
>  {
>  uint16_t idx = vq->avail->ring[avail_idx & (vq->size - 1)];
>  uint16_t vec_id = *vec_idx;
> @@ -409,7 +409,7 @@ reserve_avail_buf_split(struct virtio_net *dev, struct
> vhost_virtqueue *vq,
>  uint16_t max_tries, tries = 0;
>
>  uint16_t head_idx = 0;
> -uint16_t len = 0;
> +uint32_t len = 0;
>
>  *num_buffers = 0;
>  cur_idx  = vq->last_avail_idx;
> @@ -1378,7 +1378,8 @@ virtio_dev_tx_split(struct virtio_net *dev, struct
> vhost_virtqueue *vq,
>
>  for (i = 0; i < count; i++) {
>  struct buf_vector buf_vec[BUF_VECTOR_MAX];
> -uint16_t head_idx, dummy_len;
> +uint16_t head_idx;
> +uint32_t dummy_len;
>  uint16_t nr_vec = 0;
>  int err;
>
> --
> 2.7.4

IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium. Thank you.


[dpdk-dev] [PATCH v3 1/3] lib/librte_table: add hash_func header files

2018-09-07 Thread Kevin Laatz
This commit adds rte_table_hash_func.h and rte_table_hash_func_arm64.h to
librte_table. This reduces code duplication by removing duplicate header files
within two folders and consolidating them into a single one. This also adds a
scalar implementation of the x86_64 intrinsic for crc32 as a generic fallback.

Signed-off-by: Cristian Dumitrescu 
Signed-off-by: Kevin Laatz 
Acked-by: Gavin Hu 
---
v2:
   - Fixed typo in commit message
   - Fixed typo in arm header that caused some compilations to fail for the
 entire patchset
v3:
   - Improved commit message
---
 lib/librte_table/Makefile|   2 +
 lib/librte_table/meson.build |   2 +
 lib/librte_table/rte_table_hash_func.h   | 244 +++
 lib/librte_table/rte_table_hash_func_arm64.h |  21 +++
 lib/librte_table/rte_table_version.map   |  14 ++
 5 files changed, 283 insertions(+)
 create mode 100644 lib/librte_table/rte_table_hash_func.h
 create mode 100644 lib/librte_table/rte_table_hash_func_arm64.h

diff --git a/lib/librte_table/Makefile b/lib/librte_table/Makefile
index 276d476..f935678 100644
--- a/lib/librte_table/Makefile
+++ b/lib/librte_table/Makefile
@@ -46,6 +46,8 @@ SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include += rte_table_acl.h
 endif
 SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include += rte_table_hash.h
 SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include += rte_table_hash_cuckoo.h
+SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include += rte_table_hash_func.h
+SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include += rte_table_hash_func_arm64.h
 SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include += rte_lru.h
 ifeq ($(CONFIG_RTE_ARCH_X86),y)
 SYMLINK-$(CONFIG_RTE_LIBRTE_TABLE)-include += rte_lru_x86.h
diff --git a/lib/librte_table/meson.build b/lib/librte_table/meson.build
index 8b2f841..6ae3cd6 100644
--- a/lib/librte_table/meson.build
+++ b/lib/librte_table/meson.build
@@ -19,6 +19,8 @@ headers = files('rte_table.h',
'rte_table_lpm_ipv6.h',
'rte_table_hash.h',
'rte_table_hash_cuckoo.h',
+   'rte_table_hash_func.h',
+   'rte_table_hash_func_arm64.h',
'rte_lru.h',
'rte_table_array.h',
'rte_table_stub.h')
diff --git a/lib/librte_table/rte_table_hash_func.h 
b/lib/librte_table/rte_table_hash_func.h
new file mode 100644
index 000..761ef3d
--- /dev/null
+++ b/lib/librte_table/rte_table_hash_func.h
@@ -0,0 +1,244 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2018 Intel Corporation
+ */
+
+#ifndef __INCLUDE_RTE_TABLE_HASH_FUNC_H__
+#define __INCLUDE_RTE_TABLE_HASH_FUNC_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include 
+
+#include 
+
+static inline uint64_t
+rte_crc32_u64_generic(uint64_t crc, uint64_t value)
+{
+   int i;
+
+   crc = (crc & 0xLLU) ^ value;
+   for (i = 63; i >= 0; i--) {
+   uint64_t mask;
+
+   mask = -(crc & 1LLU);
+   crc = (crc >> 1LLU) ^ (0x82F63B78LLU & mask);
+   }
+
+   return crc;
+}
+
+#if defined(RTE_ARCH_X86_64)
+
+#include 
+
+static inline uint64_t
+rte_crc32_u64(uint64_t crc, uint64_t v)
+{
+   return _mm_crc32_u64(crc, v);
+}
+
+#elif defined(RTE_ARCH_ARM64)
+#include "rte_table_hash_func_arm64.h"
+#else
+
+static inline uint64_t
+rte_crc32_u64(uint64_t crc, uint64_t v)
+{
+   return rte_crc32_u64_generic(crc, v);
+}
+
+#endif
+
+static inline uint64_t
+rte_table_hash_crc_key8(void *key, void *mask, __rte_unused uint32_t key_size,
+   uint64_t seed)
+{
+   uint64_t *k = key;
+   uint64_t *m = mask;
+   uint64_t crc0;
+
+   crc0 = rte_crc32_u64(seed, k[0] & m[0]);
+
+   return crc0;
+}
+
+static inline uint64_t
+rte_table_hash_crc_key16(void *key, void *mask, __rte_unused uint32_t key_size,
+   uint64_t seed)
+{
+   uint64_t *k = key;
+   uint64_t *m = mask;
+   uint64_t k0, crc0, crc1;
+
+   k0 = k[0] & m[0];
+
+   crc0 = rte_crc32_u64(k0, seed);
+   crc1 = rte_crc32_u64(k0 >> 32, k[1] & m[1]);
+
+   crc0 ^= crc1;
+
+   return crc0;
+}
+
+static inline uint64_t
+rte_table_hash_crc_key24(void *key, void *mask, __rte_unused uint32_t key_size,
+   uint64_t seed)
+{
+   uint64_t *k = key;
+   uint64_t *m = mask;
+   uint64_t k0, k2, crc0, crc1;
+
+   k0 = k[0] & m[0];
+   k2 = k[2] & m[2];
+
+   crc0 = rte_crc32_u64(k0, seed);
+   crc1 = rte_crc32_u64(k0 >> 32, k[1] & m[1]);
+
+   crc0 = rte_crc32_u64(crc0, k2);
+
+   crc0 ^= crc1;
+
+   return crc0;
+}
+
+static inline uint64_t
+rte_table_hash_crc_key32(void *key, void *mask, __rte_unused uint32_t key_size,
+   uint64_t seed)
+{
+   uint64_t *k = key;
+   uint64_t *m = mask;
+   uint64_t k0, k2, crc0, crc1, crc2, crc3;
+
+   k0 = k[0] & m[0];
+   k2 = k[2] & m[2];
+
+   crc0 = rte_crc32_u64(k0, seed);
+   crc1 = rte_crc32_u64(k0 >> 32, k[1] & m[1]);
+
+   crc2 = rte_crc32_u64(k2, k[3] & m[3]);

[dpdk-dev] [PATCH v3 3/3] net/softnic: modify softnic to use librte_table headers

2018-09-07 Thread Kevin Laatz
This commit modifies SoftNIC to make use of the new header files in
librte_table.

As we are now using the new header files in librte_table in SoftNIC, we no
longer need the old header files so they can be removed.

Signed-off-by: Cristian Dumitrescu 
Signed-off-by: Kevin Laatz 
---
 drivers/net/softnic/hash_func.h| 359 -
 drivers/net/softnic/hash_func_arm64.h  | 261 --
 drivers/net/softnic/rte_eth_softnic_action.c   |  34 +--
 drivers/net/softnic/rte_eth_softnic_pipeline.c |  19 +-
 4 files changed, 26 insertions(+), 647 deletions(-)
 delete mode 100644 drivers/net/softnic/hash_func.h
 delete mode 100644 drivers/net/softnic/hash_func_arm64.h

diff --git a/drivers/net/softnic/hash_func.h b/drivers/net/softnic/hash_func.h
deleted file mode 100644
index 198d2b2..000
--- a/drivers/net/softnic/hash_func.h
+++ /dev/null
@@ -1,359 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2018 Intel Corporation
- */
-
-#ifndef __INCLUDE_HASH_FUNC_H__
-#define __INCLUDE_HASH_FUNC_H__
-
-#include 
-
-static inline uint64_t
-hash_xor_key8(void *key, void *mask, __rte_unused uint32_t key_size,
-   uint64_t seed)
-{
-   uint64_t *k = key;
-   uint64_t *m = mask;
-   uint64_t xor0;
-
-   xor0 = seed ^ (k[0] & m[0]);
-
-   return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key16(void *key, void *mask, __rte_unused uint32_t key_size,
-   uint64_t seed)
-{
-   uint64_t *k = key;
-   uint64_t *m = mask;
-   uint64_t xor0;
-
-   xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-
-   return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key24(void *key, void *mask, __rte_unused uint32_t key_size,
-   uint64_t seed)
-{
-   uint64_t *k = key;
-   uint64_t *m = mask;
-   uint64_t xor0;
-
-   xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-
-   xor0 ^= k[2] & m[2];
-
-   return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key32(void *key, void *mask, __rte_unused uint32_t key_size,
-   uint64_t seed)
-{
-   uint64_t *k = key;
-   uint64_t *m = mask;
-   uint64_t xor0, xor1;
-
-   xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-   xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
-
-   xor0 ^= xor1;
-
-   return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key40(void *key, void *mask, __rte_unused uint32_t key_size,
-   uint64_t seed)
-{
-   uint64_t *k = key;
-   uint64_t *m = mask;
-   uint64_t xor0, xor1;
-
-   xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-   xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
-
-   xor0 ^= xor1;
-
-   xor0 ^= k[4] & m[4];
-
-   return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key48(void *key, void *mask, __rte_unused uint32_t key_size,
-   uint64_t seed)
-{
-   uint64_t *k = key;
-   uint64_t *m = mask;
-   uint64_t xor0, xor1, xor2;
-
-   xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-   xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
-   xor2 = (k[4] & m[4]) ^ (k[5] & m[5]);
-
-   xor0 ^= xor1;
-
-   xor0 ^= xor2;
-
-   return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key56(void *key, void *mask, __rte_unused uint32_t key_size,
-   uint64_t seed)
-{
-   uint64_t *k = key;
-   uint64_t *m = mask;
-   uint64_t xor0, xor1, xor2;
-
-   xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-   xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
-   xor2 = (k[4] & m[4]) ^ (k[5] & m[5]);
-
-   xor0 ^= xor1;
-   xor2 ^= k[6] & m[6];
-
-   xor0 ^= xor2;
-
-   return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key64(void *key, void *mask, __rte_unused uint32_t key_size,
-   uint64_t seed)
-{
-   uint64_t *k = key;
-   uint64_t *m = mask;
-   uint64_t xor0, xor1, xor2, xor3;
-
-   xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-   xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
-   xor2 = (k[4] & m[4]) ^ (k[5] & m[5]);
-   xor3 = (k[6] & m[6]) ^ (k[7] & m[7]);
-
-   xor0 ^= xor1;
-   xor2 ^= xor3;
-
-   xor0 ^= xor2;
-
-   return (xor0 >> 32) ^ xor0;
-}
-
-#if defined(RTE_ARCH_X86_64)
-
-#include 
-
-static inline uint64_t
-hash_crc_key8(void *key, void *mask, __rte_unused uint32_t key_size,
-   uint64_t seed)
-{
-   uint64_t *k = key;
-   uint64_t *m = mask;
-   uint64_t crc0;
-
-   crc0 = _mm_crc32_u64(seed, k[0] & m[0]);
-
-   return crc0;
-}
-
-static inline uint64_t
-hash_crc_key16(void *key, void *mask, __rte_unused uint32_t key_size,
-   uint64_t seed)
-{
-   uint64_t *k = key;
-   uint64_t *m = mask;
-   uint64_t k0, crc0, crc1;
-
-   k0 = k[0] & m[0];
-
-   crc0 = _mm_crc32_u64(k0, seed);
-   crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]);
-
-   crc0 ^= crc1;
-
-   return crc0;
-}
-
-static inline uint64_t
-hash_crc_key24(void *key, void *ma

[dpdk-dev] [PATCH v3 2/3] examples/ip_pipeline: modify application to use librte_table headers

2018-09-07 Thread Kevin Laatz
This commit modifies the IP Pipeline application to use the new header
files in librte_table.

As we are now using the new header files, we can remove the old ones from
the application directory.

Signed-off-by: Cristian Dumitrescu 
Signed-off-by: Kevin Laatz 
---
 examples/ip_pipeline/action.c  |  34 ++--
 examples/ip_pipeline/hash_func.h   | 357 -
 examples/ip_pipeline/hash_func_arm64.h | 232 -
 examples/ip_pipeline/pipeline.c|  19 +-
 4 files changed, 26 insertions(+), 616 deletions(-)
 delete mode 100644 examples/ip_pipeline/hash_func.h
 delete mode 100644 examples/ip_pipeline/hash_func_arm64.h

diff --git a/examples/ip_pipeline/action.c b/examples/ip_pipeline/action.c
index a29c2b3..20497c3 100644
--- a/examples/ip_pipeline/action.c
+++ b/examples/ip_pipeline/action.c
@@ -7,9 +7,9 @@
 #include 
 
 #include 
+#include 
 
 #include "action.h"
-#include "hash_func.h"
 
 /**
  * Input port
@@ -57,35 +57,35 @@ port_in_action_profile_create(const char *name,
(params->lb.f_hash == NULL)) {
switch (params->lb.key_size) {
case  8:
-   params->lb.f_hash = hash_default_key8;
+   params->lb.f_hash = rte_table_hash_crc_key8;
break;
 
case 16:
-   params->lb.f_hash = hash_default_key16;
+   params->lb.f_hash = rte_table_hash_crc_key16;
break;
 
case 24:
-   params->lb.f_hash = hash_default_key24;
+   params->lb.f_hash = rte_table_hash_crc_key24;
break;
 
case 32:
-   params->lb.f_hash = hash_default_key32;
+   params->lb.f_hash = rte_table_hash_crc_key32;
break;
 
case 40:
-   params->lb.f_hash = hash_default_key40;
+   params->lb.f_hash = rte_table_hash_crc_key40;
break;
 
case 48:
-   params->lb.f_hash = hash_default_key48;
+   params->lb.f_hash = rte_table_hash_crc_key48;
break;
 
case 56:
-   params->lb.f_hash = hash_default_key56;
+   params->lb.f_hash = rte_table_hash_crc_key56;
break;
 
case 64:
-   params->lb.f_hash = hash_default_key64;
+   params->lb.f_hash = rte_table_hash_crc_key64;
break;
 
default:
@@ -192,35 +192,35 @@ table_action_profile_create(const char *name,
(params->lb.f_hash == NULL)) {
switch (params->lb.key_size) {
case 8:
-   params->lb.f_hash = hash_default_key8;
+   params->lb.f_hash = rte_table_hash_crc_key8;
break;
 
case 16:
-   params->lb.f_hash = hash_default_key16;
+   params->lb.f_hash = rte_table_hash_crc_key16;
break;
 
case 24:
-   params->lb.f_hash = hash_default_key24;
+   params->lb.f_hash = rte_table_hash_crc_key24;
break;
 
case 32:
-   params->lb.f_hash = hash_default_key32;
+   params->lb.f_hash = rte_table_hash_crc_key32;
break;
 
case 40:
-   params->lb.f_hash = hash_default_key40;
+   params->lb.f_hash = rte_table_hash_crc_key40;
break;
 
case 48:
-   params->lb.f_hash = hash_default_key48;
+   params->lb.f_hash = rte_table_hash_crc_key48;
break;
 
case 56:
-   params->lb.f_hash = hash_default_key56;
+   params->lb.f_hash = rte_table_hash_crc_key56;
break;
 
case 64:
-   params->lb.f_hash = hash_default_key64;
+   params->lb.f_hash = rte_table_hash_crc_key64;
break;
 
default:
diff --git a/examples/ip_pipeline/hash_func.h b/examples/ip_pipeline/hash_func.h
deleted file mode 100644
index f1b9d94..000
--- a/examples/ip_pipeline/hash_func.h
+++ /dev/null
@@ -1,357 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2018 Intel Corporation
- */
-
-#ifndef __INCLUDE_HASH_FUNC_H__
-#define __INCLUDE_HASH_FUNC_H__
-
-static inline uint64_t
-hash_xor_key8(void *key, void *mask, __rte_unused uint32_t key_size,
-   uint64_t seed)
-{
-   uint64_t *k = key;
-   uint64_t *m = mask;
-   uint64_t xor0;
-
-   xor0 = seed 

Re: [dpdk-dev] [PATCH v3 3/3] net/softnic: modify softnic to use librte_table headers

2018-09-07 Thread Gavin Hu (Arm Technology China)



> -Original Message-
> From: Kevin Laatz 
> Sent: Friday, September 7, 2018 6:06 PM
> To: dev@dpdk.org
> Cc: cristian.dumitre...@intel.com; Jianbo Liu ; Gavin
> Hu (Arm Technology China) ;
> jerin.ja...@caviumnetworks.com; Kevin Laatz 
> Subject: [PATCH v3 3/3] net/softnic: modify softnic to use librte_table
> headers
>
> This commit modifies SoftNIC to make use of the new header files in
> librte_table.
>
> As we are now using the new header files in librte_table in SoftNIC, we no
> longer need the old header files so they can be removed.
>
> Signed-off-by: Cristian Dumitrescu 
> Signed-off-by: Kevin Laatz 
Acked-by: Gavin Hu 
> ---
>  drivers/net/softnic/hash_func.h| 359 
> -
>  drivers/net/softnic/hash_func_arm64.h  | 261 --
>  drivers/net/softnic/rte_eth_softnic_action.c   |  34 +--
>  drivers/net/softnic/rte_eth_softnic_pipeline.c |  19 +-
>  4 files changed, 26 insertions(+), 647 deletions(-)  delete mode 100644
> drivers/net/softnic/hash_func.h  delete mode 100644
> drivers/net/softnic/hash_func_arm64.h
>
> diff --git a/drivers/net/softnic/hash_func.h
> b/drivers/net/softnic/hash_func.h deleted file mode 100644 index
> 198d2b2..000
> --- a/drivers/net/softnic/hash_func.h
> +++ /dev/null
> @@ -1,359 +0,0 @@
> -/* SPDX-License-Identifier: BSD-3-Clause
> - * Copyright(c) 2010-2018 Intel Corporation
> - */
> -
> -#ifndef __INCLUDE_HASH_FUNC_H__
> -#define __INCLUDE_HASH_FUNC_H__
> -
> -#include 
> -
> -static inline uint64_t
> -hash_xor_key8(void *key, void *mask, __rte_unused uint32_t key_size,
> -uint64_t seed)
> -{
> -uint64_t *k = key;
> -uint64_t *m = mask;
> -uint64_t xor0;
> -
> -xor0 = seed ^ (k[0] & m[0]);
> -
> -return (xor0 >> 32) ^ xor0;
> -}
> -
> -static inline uint64_t
> -hash_xor_key16(void *key, void *mask, __rte_unused uint32_t key_size,
> -uint64_t seed)
> -{
> -uint64_t *k = key;
> -uint64_t *m = mask;
> -uint64_t xor0;
> -
> -xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
> -
> -return (xor0 >> 32) ^ xor0;
> -}
> -
> -static inline uint64_t
> -hash_xor_key24(void *key, void *mask, __rte_unused uint32_t key_size,
> -uint64_t seed)
> -{
> -uint64_t *k = key;
> -uint64_t *m = mask;
> -uint64_t xor0;
> -
> -xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
> -
> -xor0 ^= k[2] & m[2];
> -
> -return (xor0 >> 32) ^ xor0;
> -}
> -
> -static inline uint64_t
> -hash_xor_key32(void *key, void *mask, __rte_unused uint32_t key_size,
> -uint64_t seed)
> -{
> -uint64_t *k = key;
> -uint64_t *m = mask;
> -uint64_t xor0, xor1;
> -
> -xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
> -xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
> -
> -xor0 ^= xor1;
> -
> -return (xor0 >> 32) ^ xor0;
> -}
> -
> -static inline uint64_t
> -hash_xor_key40(void *key, void *mask, __rte_unused uint32_t key_size,
> -uint64_t seed)
> -{
> -uint64_t *k = key;
> -uint64_t *m = mask;
> -uint64_t xor0, xor1;
> -
> -xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
> -xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
> -
> -xor0 ^= xor1;
> -
> -xor0 ^= k[4] & m[4];
> -
> -return (xor0 >> 32) ^ xor0;
> -}
> -
> -static inline uint64_t
> -hash_xor_key48(void *key, void *mask, __rte_unused uint32_t key_size,
> -uint64_t seed)
> -{
> -uint64_t *k = key;
> -uint64_t *m = mask;
> -uint64_t xor0, xor1, xor2;
> -
> -xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
> -xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
> -xor2 = (k[4] & m[4]) ^ (k[5] & m[5]);
> -
> -xor0 ^= xor1;
> -
> -xor0 ^= xor2;
> -
> -return (xor0 >> 32) ^ xor0;
> -}
> -
> -static inline uint64_t
> -hash_xor_key56(void *key, void *mask, __rte_unused uint32_t key_size,
> -uint64_t seed)
> -{
> -uint64_t *k = key;
> -uint64_t *m = mask;
> -uint64_t xor0, xor1, xor2;
> -
> -xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
> -xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
> -xor2 = (k[4] & m[4]) ^ (k[5] & m[5]);
> -
> -xor0 ^= xor1;
> -xor2 ^= k[6] & m[6];
> -
> -xor0 ^= xor2;
> -
> -return (xor0 >> 32) ^ xor0;
> -}
> -
> -static inline uint64_t
> -hash_xor_key64(void *key, void *mask, __rte_unused uint32_t key_size,
> -uint64_t seed)
> -{
> -uint64_t *k = key;
> -uint64_t *m = mask;
> -uint64_t xor0, xor1, xor2, xor3;
> -
> -xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
> -xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
> -xor2 = (k[4] & m[4]) ^ (k[5] & m[5]);
> -xor3 = (k[6] & m[6]) ^ (k[7] & m[7]);
> -
> -xor0 ^= xor1;
> -xor2 ^= xor3;
> -
> -xor0 ^= xor2;
> -
> -return (xor0 >> 32) ^ xor0;
> -}
> -
> -#if defined(RTE_ARCH_X86_64)
> -
> -#include 
> -
> -static inline uint64_t
> -hash_crc_key8(void *key, void *mask, __rte_unused uint32_t key_size,
> -uint64_t seed)
> -{
> -uint64_t *k = key;
> -uint64_t *m = mask;
> -uint64_t crc0;
> -
> -crc0 = _mm_crc32_u64(seed, k[0] & m[0]);
> -
> -return crc0;
> -}
> -
> -static inline uint64_t
> -hash_crc_key16(void *key, void *mask, __rte_unused uint32_t key_size,
> -uint64_t seed)
> -{
> -uint64_t *k = key;
> -uint64_t *m = mask;
> -uint64_t k0, crc0, crc1;
> -
> -k0 = k[0] & m[0];
> -
> -crc0 = _mm_crc32_u64

Re: [dpdk-dev] [PATCH v3 2/3] examples/ip_pipeline: modify application to use librte_table headers

2018-09-07 Thread Gavin Hu (Arm Technology China)



> -Original Message-
> From: Kevin Laatz 
> Sent: Friday, September 7, 2018 6:06 PM
> To: dev@dpdk.org
> Cc: cristian.dumitre...@intel.com; Jianbo Liu ; Gavin
> Hu (Arm Technology China) ;
> jerin.ja...@caviumnetworks.com; Kevin Laatz 
> Subject: [PATCH v3 2/3] examples/ip_pipeline: modify application to use
> librte_table headers
>
> This commit modifies the IP Pipeline application to use the new header files
> in librte_table.
>
> As we are now using the new header files, we can remove the old ones from
> the application directory.
>
> Signed-off-by: Cristian Dumitrescu 
> Signed-off-by: Kevin Laatz 
Acked-by: Gavin Hu 
> ---
>  examples/ip_pipeline/action.c  |  34 ++--
>  examples/ip_pipeline/hash_func.h   | 357 
> -
>  examples/ip_pipeline/hash_func_arm64.h | 232 -
>  examples/ip_pipeline/pipeline.c|  19 +-
>  4 files changed, 26 insertions(+), 616 deletions(-)  delete mode 100644
> examples/ip_pipeline/hash_func.h  delete mode 100644
> examples/ip_pipeline/hash_func_arm64.h
>
> diff --git a/examples/ip_pipeline/action.c b/examples/ip_pipeline/action.c
> index a29c2b3..20497c3 100644
> --- a/examples/ip_pipeline/action.c
> +++ b/examples/ip_pipeline/action.c
> @@ -7,9 +7,9 @@
>  #include 
>
>  #include 
> +#include 
>
>  #include "action.h"
> -#include "hash_func.h"
>
>  /**
>   * Input port
> @@ -57,35 +57,35 @@ port_in_action_profile_create(const char *name,
>  (params->lb.f_hash == NULL)) {
>  switch (params->lb.key_size) {
>  case  8:
> -params->lb.f_hash = hash_default_key8;
> +params->lb.f_hash = rte_table_hash_crc_key8;
>  break;
>
>  case 16:
> -params->lb.f_hash = hash_default_key16;
> +params->lb.f_hash = rte_table_hash_crc_key16;
>  break;
>
>  case 24:
> -params->lb.f_hash = hash_default_key24;
> +params->lb.f_hash = rte_table_hash_crc_key24;
>  break;
>
>  case 32:
> -params->lb.f_hash = hash_default_key32;
> +params->lb.f_hash = rte_table_hash_crc_key32;
>  break;
>
>  case 40:
> -params->lb.f_hash = hash_default_key40;
> +params->lb.f_hash = rte_table_hash_crc_key40;
>  break;
>
>  case 48:
> -params->lb.f_hash = hash_default_key48;
> +params->lb.f_hash = rte_table_hash_crc_key48;
>  break;
>
>  case 56:
> -params->lb.f_hash = hash_default_key56;
> +params->lb.f_hash = rte_table_hash_crc_key56;
>  break;
>
>  case 64:
> -params->lb.f_hash = hash_default_key64;
> +params->lb.f_hash = rte_table_hash_crc_key64;
>  break;
>
>  default:
> @@ -192,35 +192,35 @@ table_action_profile_create(const char *name,
>  (params->lb.f_hash == NULL)) {
>  switch (params->lb.key_size) {
>  case 8:
> -params->lb.f_hash = hash_default_key8;
> +params->lb.f_hash = rte_table_hash_crc_key8;
>  break;
>
>  case 16:
> -params->lb.f_hash = hash_default_key16;
> +params->lb.f_hash = rte_table_hash_crc_key16;
>  break;
>
>  case 24:
> -params->lb.f_hash = hash_default_key24;
> +params->lb.f_hash = rte_table_hash_crc_key24;
>  break;
>
>  case 32:
> -params->lb.f_hash = hash_default_key32;
> +params->lb.f_hash = rte_table_hash_crc_key32;
>  break;
>
>  case 40:
> -params->lb.f_hash = hash_default_key40;
> +params->lb.f_hash = rte_table_hash_crc_key40;
>  break;
>
>  case 48:
> -params->lb.f_hash = hash_default_key48;
> +params->lb.f_hash = rte_table_hash_crc_key48;
>  break;
>
>  case 56:
> -params->lb.f_hash = hash_default_key56;
> +params->lb.f_hash = rte_table_hash_crc_key56;
>  break;
>
>  case 64:
> -params->lb.f_hash = hash_default_key64;
> +params->lb.f_hash = rte_table_hash_crc_key64;
>  break;
>
>  default:
> diff --git a/examples/ip_pipeline/hash_func.h
> b/examples/ip_pipeline/hash_func.h
> deleted file mode 100644
> index f1b9d94..000
> --- a/examples/ip_pipeline/hash_func.h
> +++ /dev/null
> @@ -1,357 +0,0 @@
> -/* SPDX-License-Identifier: BSD-3-Clause
> - * Copyright(c) 2010-2018 Intel Corporation
> - */
> -
> -#ifndef __INCLUDE_HASH_FUNC_H__
> -#define __INCLUDE_HASH_FUNC_H__
> -
> -static inline uint64_t
> -hash_xor_key8(void *key, void *mask, __rte_unused uint32_t key_size,
> -uint64_t seed)
> -{
> -uint64_t *k = key;
> -uint64_t *m = mask;
> -uint64_t xor0;
> -
> -xor0 = seed ^ (k[0] & m[0]);
> -
> -return (xor0 >> 32) ^ xor0;
> -}
> -
> -static inline uint64_t
> -hash_xor_key16(void *key, void *mask, __rte_unused uint32_t key_size,
> -uint64_t seed)
> -{
> -uint64_t *k = key;
> -uint64_t *m = mask;
> -uint64_t xor0;
> -
> -xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
> -
> -return (xor0 >> 32) ^ xor0;
> -}
> -
> -static inline uint64_t
> -hash_xor_key24(void *key, void *mask, __rte_unused uint32_t key_size,
> -uint64_t seed)
> -{
> -uint64_t *k = key;
> -uint64_t *m = mask;
> -uint64_t xor0;
> -
> -xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
> -
> -xor0 ^= k[2] & m[2];
> -
> -return (xor0 >> 32) ^ xor0;
> -}
> -
> -static inline uint64_t
> -hash_xor_key32(void *key, void *mask, __rte_unused uint32_t key_size,
> -uint64_t seed)
> -{
> -uint64_t *k = key;
> -uint64_t *m = mask;
> -uint64_t xor0, xor1;
> -
> -xo

Re: [dpdk-dev] [PATCH v5] net/mlx: add meson build support

2018-09-07 Thread Bruce Richardson
On Wed, Sep 05, 2018 at 02:47:46PM +0300, Shahaf Shuler wrote:
> From: Nelio Laranjeiro 
> 
> Compile Mellanox drivers when their external dependencies are met.  A
> glue version of the driver can still be requested by using the
> -Denable_driver_mlx_glue=true
> 
> To avoid modifying the whole sources and keep the compatibility with
> current build systems (e.g. make), the mlx{4,5}_autoconf.h is still
> generated.
> 
> Meson will try to find the required external libraries.  When they are
> not installed system wide, they can be provided though CFLAGS, LDFLAGS
> and LD_LIBRARY_PATH environment variables, example (considering
> RDMA-Core is installed in /tmp/rdma-core):
> 
>  # CLFAGS=-I/tmp/rdma-core/build/include \
>LDFLAGS=-L/tmp/rdma-core/build/lib \
>LD_LIBRARY_PATH=/tmp/rdma-core/build/lib \
>meson output
>  # LD_LIBRARY_PATH=/tmp/rdma-core/build/lib \
>ninja -C output install
> 
> Note: LD_LIBRARY_PATH before ninja is necessary when the meson
> configuration has changed (e.g. meson configure has been called), in
> such situation the LD_LIBRARY_PATH is necessary to invoke the
> autoconfiguration script.
> 
> Signed-off-by: Nelio Laranjeiro 
> Signed-off-by: Shahaf Shuler 
> Acked-by: Bruce Richardson 
> ---
> Changes in v5:
> 
> - use meson tool to generate Mellanox config file instead of DPDK custom 
> scripts.
> 



> +# To maintain the compatibility with the make build system
> +# mlx5_autoconf.h file is still generated.
> +# input array for meson symbol search:
> +# [ "MACRO to define if found", "header for the search",
> +#   "type/enum/define", "symbol to search",
> +#   "struct member to search (type only)]
> +#
> +args = [
> +[ 'HAVE_IBV_DEVICE_STRIDING_RQ_SUPPORT', 
> 'infiniband/mlx5dv.h',
> +  'enum', 'MLX5DV_CQE_RES_FORMAT_CSUM_STRIDX' ],
> +[ 'HAVE_IBV_DEVICE_TUNNEL_SUPPORT', 'infiniband/mlx5dv.h',
> +  'enum', 'MLX5DV_CONTEXT_MASK_TUNNEL_OFFLOADS' ],
> +[ 'HAVE_IBV_MLX5_MOD_MPW', 'infiniband/mlx5dv.h',
> +  'enum', 'MLX5DV_CONTEXT_FLAGS_MPW_ALLOWED' ],
> +[ 'HAVE_IBV_MLX5_MOD_SWP', 'infiniband/mlx5dv.h',
> +  'type', 'struct mlx5dv_sw_parsing_caps',
> +  'sw_parsing_offloads' ],
> +[ 'HAVE_IBV_MLX5_MOD_CQE_128B_COMP', 'infiniband/mlx5dv.h',
> +  'enum', 'MLX5DV_CONTEXT_FLAGS_CQE_128B_COMP' ],
> +[ 'HAVE_IBV_DEVICE_MPLS_SUPPORT', 'infiniband/verbs.h',
> +  'enum', 'IBV_FLOW_SPEC_MPLS' ],
> +[ 'HAVE_IBV_WQ_FLAG_RX_END_PADDING', 'infiniband/verbs.h',
> +  'enum', 'IBV_WQ_FLAG_RX_END_PADDING' ],
> +[ 'HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT', 
> 'infiniband/verbs.h',
> +  'type', 'struct ibv_counter_set_init_attr',
> +  'counter_set_id' ],
> +[ 'HAVE_SUPPORTED_4baseKR4_Full', 'linux/ethtool.h',
> +  'define', 'SUPPORTED_4baseKR4_Full' ],
> +[ 'HAVE_SUPPORTED_4baseCR4_Full', 'linux/ethtool.h',
> +  'define', 'SUPPORTED_4baseCR4_Full' ],
> +[ 'HAVE_SUPPORTED_4baseSR4_Full', 'linux/ethtool.h',
> +  'define', 'SUPPORTED_4baseSR4_Full' ],
> +[ 'HAVE_SUPPORTED_4baseLR4_Full', 'linux/ethtool.h',
> +  'define', 'SUPPORTED_4baseLR4_Full' ],
> +[ 'HAVE_SUPPORTED_56000baseKR4_Full', 'linux/ethtool.h',
> +  'define', 'SUPPORTED_56000baseKR4_Full' ],
> +[ 'HAVE_SUPPORTED_56000baseCR4_Full', 'linux/ethtool.h',
> +  'define', 'SUPPORTED_56000baseCR4_Full' ],
> +[ 'HAVE_SUPPORTED_56000baseSR4_Full', 'linux/ethtool.h',
> +  'define', 'SUPPORTED_56000baseSR4_Full' ],
> +[ 'HAVE_SUPPORTED_56000baseLR4_Full', 'linux/ethtool.h',
> +  'define', 'SUPPORTED_56000baseLR4_Full' ],
> +[ 'HAVE_ETHTOOL_LINK_MODE_25G', 'linux/ethtool.h',
> +  'enum', 'ETHTOOL_LINK_MODE_25000baseCR_Full_BIT' ],
> +[ 'HAVE_ETHTOOL_LINK_MODE_50G', 'linux/ethtool.h',
> +  'enum', 'ETHTOOL_LINK_MODE_5baseCR2_Full_BIT' ],
> +[ 'HAVE_ETHTOOL_LINK_MODE_100G', 'linux/ethtool.h',
> +  'enum', 'ETHTOOL_LINK_MODE_10baseKR4_Full_BIT' ],
> +[ 'HAVE_IFLA_PHYS_SWITCH_ID', 'linux/if_link.h',
> +  'enum', 'IFLA_PHYS_SWITCH_ID' ],
> +[ 'HAVE_IFLA_PHYS_PORT_NAME', 'linux/if_link.h',
> +  'enum', 'IFLA_PHYS_PORT_NAME' ],
> +[ 'HAVE_TCA_FLOWER_ACT', 'linux/pkt_cls.h',
> +  'enum', 'TCA_FLOWER_ACT' ],
> +[ 'HAVE_TCA_FLOWER_FLAGS', 'linux/pkt_cls.h',
> +  'enum', 'TCA_FLOWER_FLAGS' ],
> + 

[dpdk-dev] [PATCH 1/3] crypto/aesni_mb: add aes-gcm algorithm support

2018-09-07 Thread Fan Zhang
This patch adds AES-GCM algorithm support to AESNI-MB PMD.

Signed-off-by: Fan Zhang 
---
 drivers/crypto/aesni_mb/aesni_mb_ops.h |  28 +++-
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c | 159 +++--
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c |  30 
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd_private.h |   3 +
 4 files changed, 172 insertions(+), 48 deletions(-)

diff --git a/drivers/crypto/aesni_mb/aesni_mb_ops.h 
b/drivers/crypto/aesni_mb/aesni_mb_ops.h
index 5a1cba6cb..7257e40aa 100644
--- a/drivers/crypto/aesni_mb/aesni_mb_ops.h
+++ b/drivers/crypto/aesni_mb/aesni_mb_ops.h
@@ -39,6 +39,8 @@ typedef void (*aes_cmac_sub_key_gen_t)
(const void *exp_key, void *k2, void *k3);
 typedef void (*aes_cmac_keyexp_t)
(const void *key, void *keyexp);
+typedef void (*aes_gcm_keyexp_t)
+   (const void *key, struct gcm_key_data *keyexp);
 
 /** Multi-buffer library function pointer table */
 struct aesni_mb_op_fns {
@@ -86,6 +88,12 @@ struct aesni_mb_op_fns {
/**< AES CMAC subkey expansions */
aes_cmac_keyexp_t aes_cmac_expkey;
/**< AES CMAC key expansions */
+   aes_gcm_keyexp_t aes_gcm_128;
+   /**< AES GCM 128 key expansions */
+   aes_gcm_keyexp_t aes_gcm_192;
+   /**< AES GCM 192 key expansions */
+   aes_gcm_keyexp_t aes_gcm_256;
+   /**< AES GCM 256 key expansions */
} keyexp;
/**< Key expansion functions */
} aux;
@@ -130,7 +138,10 @@ static const struct aesni_mb_op_fns job_ops[] = {
aes_keyexp_256_sse,
aes_xcbc_expand_key_sse,
aes_cmac_subkey_gen_sse,
-   aes_keyexp_128_enc_sse
+   aes_keyexp_128_enc_sse,
+   aes_gcm_pre_128_sse,
+   aes_gcm_pre_192_sse,
+   aes_gcm_pre_256_sse
}
}
},
@@ -157,7 +168,10 @@ static const struct aesni_mb_op_fns job_ops[] = {
aes_keyexp_256_avx,
aes_xcbc_expand_key_avx,
aes_cmac_subkey_gen_avx,
-   aes_keyexp_128_enc_avx
+   aes_keyexp_128_enc_avx,
+   aes_gcm_pre_128_avx_gen2,
+   aes_gcm_pre_192_avx_gen2,
+   aes_gcm_pre_256_avx_gen2
}
}
},
@@ -184,7 +198,10 @@ static const struct aesni_mb_op_fns job_ops[] = {
aes_keyexp_256_avx2,
aes_xcbc_expand_key_avx2,
aes_cmac_subkey_gen_avx2,
-   aes_keyexp_128_enc_avx2
+   aes_keyexp_128_enc_avx2,
+   aes_gcm_pre_128_avx_gen4,
+   aes_gcm_pre_192_avx_gen4,
+   aes_gcm_pre_256_avx_gen4
}
}
},
@@ -211,7 +228,10 @@ static const struct aesni_mb_op_fns job_ops[] = {
aes_keyexp_256_avx512,
aes_xcbc_expand_key_avx512,
aes_cmac_subkey_gen_avx512,
-   aes_keyexp_128_enc_avx512
+   aes_keyexp_128_enc_avx512,
+   aes_gcm_pre_128_avx_gen4,
+   aes_gcm_pre_192_avx_gen4,
+   aes_gcm_pre_256_avx_gen4
}
}
}
diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c 
b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
index 93dc7a443..fe04ae48c 100644
--- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
+++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
@@ -83,7 +83,8 @@ aesni_mb_get_chain_order(const struct rte_crypto_sym_xform 
*xform)
}
 
if (xform->type == RTE_CRYPTO_SYM_XFORM_AEAD) {
-   if (xform->aead.algo == RTE_CRYPTO_AEAD_AES_CCM) {
+   if (xform->aead.algo == RTE_CRYPTO_AEAD_AES_CCM ||
+   xform->aead.algo == RTE_CRYPTO_AEAD_AES_GCM) {
if (xform->aead.op == RTE_CRYPTO_AEAD_OP_ENCRYPT)

[dpdk-dev] [PATCH 0/3] crypto/aesni_mb: add aes-gcm support

2018-09-07 Thread Fan Zhang
This patchset adds the AES-GCM algorithm support to AESNI-MB Cryptodev
PMD and updates the unit test and documentations along.

Fan Zhang (3):
  crypto/aesni_mb: add aes-gcm algorithm support
  test/test_cryptodev: add AES-GCM tests to AESNI-MB
  doc: update cryptodev and release note

 doc/guides/cryptodevs/aesni_mb.rst |   1 +
 doc/guides/rel_notes/release_18_11.rst |   5 +
 drivers/crypto/aesni_mb/aesni_mb_ops.h |  28 +++-
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c | 159 +++--
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c |  30 
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd_private.h |   3 +
 test/test/test_cryptodev.c | 126 +++-
 7 files changed, 298 insertions(+), 54 deletions(-)

-- 
2.13.6



[dpdk-dev] [PATCH 3/3] doc: update cryptodev and release note

2018-09-07 Thread Fan Zhang
Signed-off-by: Fan Zhang 
---
 doc/guides/cryptodevs/aesni_mb.rst | 1 +
 doc/guides/rel_notes/release_18_11.rst | 5 +
 2 files changed, 6 insertions(+)

diff --git a/doc/guides/cryptodevs/aesni_mb.rst 
b/doc/guides/cryptodevs/aesni_mb.rst
index c29295002..63e060d75 100644
--- a/doc/guides/cryptodevs/aesni_mb.rst
+++ b/doc/guides/cryptodevs/aesni_mb.rst
@@ -44,6 +44,7 @@ Hash algorithms:
 AEAD algorithms:
 
 * RTE_CRYPTO_AEAD_AES_CCM
+* RTE_CRYPTO_AEAD_AES_GCM
 
 Limitations
 ---
diff --git a/doc/guides/rel_notes/release_18_11.rst 
b/doc/guides/rel_notes/release_18_11.rst
index 3ae6b3f58..bb7ea6a4b 100644
--- a/doc/guides/rel_notes/release_18_11.rst
+++ b/doc/guides/rel_notes/release_18_11.rst
@@ -54,6 +54,11 @@ New Features
  Also, make sure to start the actual text at the margin.
  =
 
+* **Updated the AESNI MB PMD.**
+
+  The AESNI MB PMD has been updated with additional support for:
+
+  * AES-GCM algorithm support.
 
 API Changes
 ---
-- 
2.13.6



[dpdk-dev] [PATCH 2/3] test/test_cryptodev: add AES-GCM tests to AESNI-MB

2018-09-07 Thread Fan Zhang
Signed-off-by: Fan Zhang 
---
 test/test/test_cryptodev.c | 126 ++---
 1 file changed, 120 insertions(+), 6 deletions(-)

diff --git a/test/test/test_cryptodev.c b/test/test/test_cryptodev.c
index a6044b261..5e9ed357a 100644
--- a/test/test/test_cryptodev.c
+++ b/test/test/test_cryptodev.c
@@ -1550,7 +1550,7 @@ test_AES_CBC_HMAC_SHA512_decrypt_perform(struct 
rte_cryptodev_sym_session *sess,
return TEST_SUCCESS;
 }
 
-static int
+static __rte_unused int
 test_AES_cipheronly_mb_all(void)
 {
struct crypto_testsuite_params *ts_params = &testsuite_params;
@@ -1569,7 +1569,7 @@ test_AES_cipheronly_mb_all(void)
return TEST_SUCCESS;
 }
 
-static int
+static __rte_unused int
 test_AES_docsis_mb_all(void)
 {
struct crypto_testsuite_params *ts_params = &testsuite_params;
@@ -1626,7 +1626,7 @@ test_DES_docsis_qat_all(void)
return TEST_SUCCESS;
 }
 
-static int
+static __rte_unused int
 test_authonly_mb_all(void)
 {
struct crypto_testsuite_params *ts_params = &testsuite_params;
@@ -1663,7 +1663,7 @@ test_authonly_qat_all(void)
 
return TEST_SUCCESS;
 }
-static int
+static __rte_unused int
 test_AES_chain_mb_all(void)
 {
struct crypto_testsuite_params *ts_params = &testsuite_params;
@@ -5002,7 +5002,7 @@ test_DES_docsis_openssl_all(void)
return TEST_SUCCESS;
 }
 
-static int
+static __rte_unused int
 test_DES_cipheronly_mb_all(void)
 {
struct crypto_testsuite_params *ts_params = &testsuite_params;
@@ -5039,7 +5039,7 @@ test_3DES_cipheronly_mb_all(void)
return TEST_SUCCESS;
 }
 
-static int
+static __rte_unused int
 test_DES_docsis_mb_all(void)
 {
struct crypto_testsuite_params *ts_params = &testsuite_params;
@@ -9042,6 +9042,120 @@ static struct unit_test_suite 
cryptodev_aesni_mb_testsuite  = {
.setup = testsuite_setup,
.teardown = testsuite_teardown,
.unit_test_cases = {
+   TEST_CASE_ST(ut_setup, ut_teardown,
+   test_AES_GCM_authenticated_encryption_test_case_1),
+   TEST_CASE_ST(ut_setup, ut_teardown,
+   test_AES_GCM_authenticated_encryption_test_case_2),
+   TEST_CASE_ST(ut_setup, ut_teardown,
+   test_AES_GCM_authenticated_encryption_test_case_3),
+   TEST_CASE_ST(ut_setup, ut_teardown,
+   test_AES_GCM_authenticated_encryption_test_case_4),
+   TEST_CASE_ST(ut_setup, ut_teardown,
+   test_AES_GCM_authenticated_encryption_test_case_5),
+   TEST_CASE_ST(ut_setup, ut_teardown,
+   test_AES_GCM_authenticated_encryption_test_case_6),
+   TEST_CASE_ST(ut_setup, ut_teardown,
+   test_AES_GCM_authenticated_encryption_test_case_7),
+
+   /** AES GCM Authenticated Decryption */
+   TEST_CASE_ST(ut_setup, ut_teardown,
+   test_AES_GCM_authenticated_decryption_test_case_1),
+   TEST_CASE_ST(ut_setup, ut_teardown,
+   test_AES_GCM_authenticated_decryption_test_case_2),
+   TEST_CASE_ST(ut_setup, ut_teardown,
+   test_AES_GCM_authenticated_decryption_test_case_3),
+   TEST_CASE_ST(ut_setup, ut_teardown,
+   test_AES_GCM_authenticated_decryption_test_case_4),
+   TEST_CASE_ST(ut_setup, ut_teardown,
+   test_AES_GCM_authenticated_decryption_test_case_5),
+   TEST_CASE_ST(ut_setup, ut_teardown,
+   test_AES_GCM_authenticated_decryption_test_case_6),
+   TEST_CASE_ST(ut_setup, ut_teardown,
+   test_AES_GCM_authenticated_decryption_test_case_7),
+
+   /** AES GCM Authenticated Encryption 192 bits key */
+   TEST_CASE_ST(ut_setup, ut_teardown,
+   test_AES_GCM_auth_encryption_test_case_192_1),
+   TEST_CASE_ST(ut_setup, ut_teardown,
+   test_AES_GCM_auth_encryption_test_case_192_2),
+   TEST_CASE_ST(ut_setup, ut_teardown,
+   test_AES_GCM_auth_encryption_test_case_192_3),
+   TEST_CASE_ST(ut_setup, ut_teardown,
+   test_AES_GCM_auth_encryption_test_case_192_4),
+   TEST_CASE_ST(ut_setup, ut_teardown,
+   test_AES_GCM_auth_encryption_test_case_192_5),
+   TEST_CASE_ST(ut_setup, ut_teardown,
+   test_AES_GCM_auth_encryption_test_case_192_6),
+   TEST_CASE_ST(ut_setup, ut_teardown,
+   test_AES_GCM_auth_encryption_test_case_192_7),
+
+   /** AES GCM Authenticated Decryption 192 bits key */
+   TEST_CASE_ST(ut_setup, ut_teardown,
+   test_AES_GCM_auth_decryption_test_case_192_1),
+   TEST_CASE_ST(ut_setup, ut_teardown,
+   

Re: [dpdk-dev] [PATCH] app/testpmd: add check for rx offload security flag

2018-09-07 Thread Ferruh Yigit
On 9/4/2018 1:32 PM, Kevin Laatz wrote:
> Add a check for the DEV_RX_OFFLOAD_SECURITY flag to the
> port_offload_cap_display().
> 
> Signed-off-by: Kevin Laatz 

Reviewed-by: Ferruh Yigit 


Re: [dpdk-dev] [PATCH v3] hash table: add an iterator over conflicting entries

2018-09-07 Thread Michel Machado

On 09/05/2018 06:13 PM, Honnappa Nagarahalli wrote:

+   uint32_t  next;
+   uint32_t  total_entries;
+};
This structure can be moved to rte_cuckoo_hash.h file.


 What's the purpose of moving this struct to a header file since it's only 
used in the C file rte_cuckoo_hash.c?

This is to maintain consistency. For ex: 'struct queue_node', which is an 
internal structure, is kept in rte_cuckoo_hash.h


   Okay. We'll move it there.


+int32_t
+rte_hash_iterator_init(const struct rte_hash *h,
+   struct rte_hash_iterator_state *state) {
+   struct rte_hash_iterator_istate *__state;
'__state' can be replaced by 's'.

+
+   RETURN_IF_TRUE(((h == NULL) || (state == NULL)), -EINVAL);
+
+   __state = (struct rte_hash_iterator_istate *)state;
+   __state->h = h;
+   __state->next = 0;
+   __state->total_entries = h->num_buckets * RTE_HASH_BUCKET_ENTRIES;
+
+   return 0;
+}
IMO, creating this API can be avoided if the initialization is handled in 
'rte_hash_iterate' function. The cost of doing this is very trivial (one extra 
'if' statement) in 'rte_hash_iterate' function. It will help keep the number of 
APIs to minimal.


 Applications would have to initialize struct rte_hash_iterator_state 
*state before calling rte_hash_iterate() anyway. Why not initializing the 
fields of a state only once?

My concern is about creating another API for every iterator API. You have a 
valid point on saving cycles as this API applies for data plane. Have you done 
any performance benchmarking with and without this API? May be we can guide our 
decision based on that.


   It's not just about creating one init function for each iterator 
because an iterator may have a couple of init functions. For example, 
someone may eventually find useful to add another init function for the 
conflicting-entry iterator that we are advocating in this patch. A 
possibility would be for this new init function to use the key of the 
new entry instead of its signature to initialize the state. Similar to 
what is already done in rte_hash_lookup*() functions. In spite of 
possibly having multiple init functions, there will be a single iterator 
function.


   About the performance benchmarking, the current API only requites 
applications to initialize a single 32-bit integer. But with the 
adoption of a struct for the state, the initialization will grow to 64 
bytes.



   int32_t
-rte_hash_iterate(const struct rte_hash *h, const void **key, void
**data, uint32_t *next)
+rte_hash_iterate(
+   struct rte_hash_iterator_state *state, const void **key, void
+**data)

IMO, as suggested above, do not store 'struct rte_hash *h' in 'struct 
rte_hash_iterator_state'. Instead, change the API definition as follows:
rte_hash_iterate(const struct rte_hash *h, const void **key, void
**data, struct rte_hash_iterator_state *state)

This will help keep the API signature consistent with existing APIs.

This is an ABI change. Please take a look at 
https://doc.dpdk.org/guides/contributing/versioning.html.


 The ABI will change in a way or another, so why not going for a single 
state instead of requiring parameters that are already needed for the 
initialization of the state?

Are there any cost savings we can achieve by keeping the 'h' in the iterator 
state?


   There's a tiny cost saving: avoiding to push that parameter in the 
execution stack every time the iterator will get another entry. However, 
the reason I find more important is to make impossible to introduce a 
bug in the code. Consider a function that is dealing with two hash 
tables and two iterators. Without asking for the hash table to make 
progress in an iterator, it's impossible to mix up hash tables and 
iterator states.


   There's even the possibility that an iterator doesn't need the hash 
table after its initialization. This would be an *unlikely* case, but 
consider an iterator that only returns a couple of entries. It could 
cache those entries during initialization.



/* Calculate bucket and index of current iterator */
-   bucket_idx = *next / RTE_HASH_BUCKET_ENTRIES;
-   idx = *next % RTE_HASH_BUCKET_ENTRIES;
+   bucket_idx = __state->next / RTE_HASH_BUCKET_ENTRIES;
+   idx = __state->next % RTE_HASH_BUCKET_ENTRIES;
   
   	/* If current position is empty, go to the next one */

-   while (h->buckets[bucket_idx].key_idx[idx] == EMPTY_SLOT) {
-   (*next)++;
+   while (__state->h->buckets[bucket_idx].key_idx[idx] == EMPTY_SLOT) {
+   __state->next++;
/* End of table */
-   if (*next == total_entries)
+   if (__state->next == __state->total_entries)
return -ENOENT;
-   bucket_idx = *next / RTE_HASH_BUCKET_ENTRIES;
-   idx = *next % RTE_HASH_BUCKET_ENTRIES;
+   bucket_idx = __state->next / RTE_HASH_BUCKET_ENTRIES;
+   idx = __state->next % RTE_HAS

Re: [dpdk-dev] [PATCH v3] hash table: add an iterator over conflicting entries

2018-09-07 Thread Michel Machado

On 09/05/2018 04:27 PM, Wang, Yipeng1 wrote:

Hmm I see, it falls back to my original thought to have malloc inside the init 
function..
Thanks for the explanation. :)

So I guess with your implementation, in future if we change the internal state 
to be larger,
the ABI will be broken.


   If that happens, yes, the ABI would need to change again. But this 
concern is overblown for two reasons. First, this event is unlikely to 
happen because struct rte_hash_iterator_state is already allocating 64 
bytes while struct rte_hash_iterator_istate and struct 
rte_hash_iterator_conflict_entries_istate consume 16 and 20 bytes, 
respectively. Thus, the complexity of the underlying hash algorithm 
would need to grow substantially to force the necessary state of these 
iterators to grow more than 4x and 3x, respectively. This is unlikely to 
happen, and, if it does, it would likely break the ABI somewhere else 
and have a high impact on applications anyway.


   Second, even if the unlikely event happens, all one would need to do 
is to increase the size of struct rte_hash_iterator_state, mark the new 
API as a new version, and applications would be ready for the new ABI 
just recompiling.



BTW, this patch set also changes API so proper notice is needed.
People more familiar with API/ABI change policies may be able to help here.


   We'd be happy to get feedback on this aspect.


Just to confirm, is there anyway like I said for your application to have some 
long-live states
and reuse them throughout the application so that you don’t have to have 
short-lived ones in stack?


   Two things would need to happen for this to be possible. The init 
functions would need to accept previously allocated iterator states, 
that is, the init function would act as a reset of the state when acting 
on a previous allocated state. And, applications would now need to carry 
these pre-allocated state to avoid a malloc. In order words, we'll 
increase the complexity of the API.


   To emphasize that the cost of a malloc is not negligible, 
rte_malloc() needs to get a spinlock (see heap_alloc_on_socket()), do 
its thing to allocate memory, and, if the first attempt fails, try to 
allocate the memory on other sockets (see end of malloc_heap_alloc()). 
For an iterator that goes through the whole hash table, this cost may be 
okay, but for an iterator that goes through a couple entries, this cost 
is a lot to add.


   This memory allocation concern is not new. Function 
rte_pktmbuf_read(), for example, let applications pass buffers, which 
are often allocated in the execution stack, to avoid the malloc cost.


[ ]'s
Michel Machado


[dpdk-dev] [dpdk-announce] DPDK 18.05.1 released

2018-09-07 Thread Christian Ehrhardt
Hi all,

Here is a new stable release:
https://fast.dpdk.org/rel/dpdk-18.05.1.tar.xz

The git tree is at:
https://dpdk.org/browse/dpdk-stable/?h=18.05

Christian Ehrhardt 

---
 MAINTAINERS   |  12 +-
 app/test-crypto-perf/cperf_ops.c  |   3 +
 app/test-eventdev/test_order_atq.c|  12 +-
 app/test-eventdev/test_order_queue.c  |  12 +-
 app/test-pmd/cmdline.c|   8 +-
 app/test-pmd/cmdline_flow.c   |  29 ++-
 app/test-pmd/cmdline_tm.c |  37 ++-
 app/test-pmd/testpmd.c|  46 +++-
 buildtools/pmdinfogen/Makefile|   2 +-
 config/meson.build|   3 +-
 devtools/test-build.sh|   1 -
 devtools/test-meson-builds.sh |  13 +-
 doc/guides/cryptodevs/dpaa2_sec.rst   |   1 -
 doc/guides/cryptodevs/dpaa_sec.rst|   1 -
 doc/guides/eventdevs/octeontx.rst |   2 +-
 doc/guides/nics/qede.rst  |  13 +-
 doc/guides/nics/vdev_netvsc.rst   |   2 +-
 doc/guides/rel_notes/release_18_05.rst| 234 +++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst   |   6 +-
 drivers/bus/dpaa/base/fman/fman_hw.c  |  20 +-
 drivers/bus/dpaa/base/fman/of.c   |   5 +
 drivers/bus/dpaa/dpaa_bus.c   |  14 +-
 drivers/bus/dpaa/include/compat.h |   6 +
 drivers/bus/pci/linux/pci_vfio.c  |   2 +-
 drivers/compress/isal/isal_compress_pmd.c |  68 --
 drivers/compress/isal/isal_compress_pmd_ops.c |   7 +-
 drivers/crypto/virtio/virtio_cryptodev.c  |   6 +
 drivers/crypto/virtio/virtio_cryptodev.h  |   3 +
 drivers/crypto/virtio/virtio_rxtx.c   |  14 +-
 drivers/event/octeontx/ssovf_evdev.c  |  14 +-
 drivers/event/octeontx/ssovf_worker.c |  17 +-
 drivers/event/octeontx/timvf_evdev.c  |   2 +-
 drivers/mempool/octeontx/octeontx_fpavf.c |  45 ++--
 drivers/mempool/octeontx/octeontx_fpavf.h |   9 +
 drivers/meson.build   |   3 +
 drivers/net/af_packet/rte_eth_af_packet.c |   1 +
 drivers/net/avf/avf_ethdev.c  |  17 +-
 drivers/net/bnx2x/bnx2x.c |  22 +-
 drivers/net/bnx2x/bnx2x.h |   1 +
 drivers/net/bnx2x/bnx2x_ethdev.c  | 105 ++---
 drivers/net/bnx2x/bnx2x_ethdev.h  |   3 +-
 drivers/net/bnxt/bnxt.h   |   4 +
 drivers/net/bnxt/bnxt_ethdev.c|  56 +++--
 drivers/net/bnxt/bnxt_filter.c|  27 ++-
 drivers/net/bnxt/bnxt_hwrm.c  |  57 +++--
 drivers/net/bnxt/bnxt_stats.c |   3 +
 drivers/net/bnxt/bnxt_txr.c   |  59 -
 drivers/net/bnxt/bnxt_txr.h   |  10 +
 drivers/net/bnxt/bnxt_vnic.c  |   5 +-
 drivers/net/bnxt/bnxt_vnic.h  |   6 +-
 drivers/net/bonding/rte_eth_bond_api.c|  14 +-
 drivers/net/bonding/rte_eth_bond_pmd.c|  27 +--
 drivers/net/cxgbe/base/t4_hw.c|  97 ++--
 drivers/net/cxgbe/base/t4_regs.h  |   3 +
 drivers/net/cxgbe/base/t4fw_interface.h   |   8 +
 drivers/net/cxgbe/base/t4vf_hw.c  |   6 +
 drivers/net/cxgbe/cxgbe_compat.h  |   9 -
 drivers/net/cxgbe/cxgbe_ethdev.c  |   3 +-
 drivers/net/cxgbe/cxgbevf_ethdev.c|   1 +
 drivers/net/cxgbe/sge.c   |  10 +-
 drivers/net/dpaa/dpaa_ethdev.c|  36 ++-
 drivers/net/dpaa2/dpaa2_rxtx.c|  16 +-
 drivers/net/dpaa2/mc/dpni.c   |   2 +-
 drivers/net/ena/base/ena_plat_dpdk.h  |  35 +--
 drivers/net/ena/ena_ethdev.c  |   4 +-
 drivers/net/enic/base/vnic_dev.c  |  16 ++
 drivers/net/enic/base/vnic_dev.h  |   4 +
 drivers/net/enic/base/vnic_devcmd.h   |  23 +-
 drivers/net/enic/base/vnic_enet.h |   5 +-
 drivers/net/enic/base/vnic_nic.h  |   4 +-
 drivers/net/enic/enic.h   |   2 +
 drivers/net/enic/enic_ethdev.c|   5 +-
 drivers/net/enic/enic_main.c  |  42 ++--
 drivers/net/enic/enic_res.c   |  11 +-
 drivers/net/enic/enic_rxtx.c  |  42 +++-
 drivers/net/failsafe/failsafe.c   |   1 +
 drivers/net/fm10k/fm10k.h |   3 -
 drivers/net/i40e/i40e_ethdev.c| 197 
 drivers/net/i40e/i40e_ethdev_vf.c |   1 -
 drivers/net/i40e/i4

Re: [dpdk-dev] [PATCH 2/3] net/virtio-user: avoid parsing process mappings

2018-09-07 Thread Tiwei Bie
On Fri, Sep 07, 2018 at 10:39:16AM +0100, Burakov, Anatoly wrote:
> On 05-Sep-18 5:28 AM, Tiwei Bie wrote:
> > Recently some memory APIs were introduced to allow users to
> > get the file descriptor and offset for each memory segment.
> > We can leverage those APIs to get rid of the /proc magic on
> > memory table preparation in vhost-user backend.
> > 
> > Signed-off-by: Tiwei Bie 
> > ---
> 
> 
> 
> > -   for (i = 0; i < num; ++i) {
> > -   mr = &msg->payload.memory.regions[i];
> > -   mr->guest_phys_addr = huges[i].addr; /* use vaddr! */
> > -   mr->userspace_addr = huges[i].addr;
> > -   mr->memory_size = huges[i].size;
> > -   mr->mmap_offset = 0;
> > -   fds[i] = open(huges[i].path, O_RDWR);
> > +   if (rte_memseg_get_fd_offset_thread_unsafe(ms, &offset) < 0) {
> > +   PMD_DRV_LOG(ERR, "Failed to get offset, ms=%p rte_errno=%d",
> > +   ms, rte_errno);
> > +   return -1;
> > +   }
> > +
> > +   start_addr = (uint64_t)(uintptr_t)ms->addr;
> > +   end_addr = start_addr + ms->len;
> > +
> > +   for (i = 0; i < wa->region_nr; i++) {
> 
> There has to be a better way than to run this loop on every segment. Maybe
> store last-used region, and only do a region look up if there's a mismatch?
> Generally, in single-file segments mode, you'll get lots of segments from
> one memseg list one after the other, so you will need to do a lookup once
> memseg list changes, instead of on each segment.

We may have holes in one memseg list due to dynamic free.
Do you mean we just need to do rte_memseg_contig_walk()
and we can assume that fds of the contiguous memegs will
be the same?

> 
> > +   if (wa->fds[i] != fd)
> > +   continue;
> > +
> > +   mr = &wa->vm->regions[i];
> > +
> > +   if (mr->userspace_addr + mr->memory_size < end_addr)
> > +   mr->memory_size = end_addr - mr->userspace_addr;
> > +
> 
> 
> 
> > int fds[VHOST_MEMORY_MAX_NREGIONS];
> > int fd_num = 0;
> > -   int i, len;
> > +   int len;
> > int vhostfd = dev->vhostfd;
> > RTE_SET_USED(m);
> > @@ -364,10 +337,6 @@ vhost_user_sock(struct virtio_user_dev *dev,
> > return -1;
> > }
> > -   if (req == VHOST_USER_SET_MEM_TABLE)
> > -   for (i = 0; i < fd_num; ++i)
> > -   close(fds[i]);
> > -
> 
> You're sharing fd's - presumably the other side of this is in a different
> process, so it's safe to close these fd's there?

Above code belongs to virtio-user, and it will close the
fds got from rte_memseg_get_fd_thread_unsafe().

Below is the code which will close these fds on the other
side (i.e. the vhost-user process):

https://github.com/DPDK/dpdk/blob/3605968c2fa7/lib/librte_vhost/vhost_user.c#L805
https://github.com/DPDK/dpdk/blob/3605968c2fa7/lib/librte_vhost/vhost_user.c#L97


> 
> > if (need_reply) {
> > if (vhost_user_read(vhostfd, &msg) < 0) {
> > PMD_DRV_LOG(ERR, "Received msg failed: %s",
> > 
> 
> 
> -- 
> Thanks,
> Anatoly


Re: [dpdk-dev] [PATCH 3/3] net/virtio-user: fix memory hotplug support in vhost-kernel

2018-09-07 Thread Tiwei Bie
On Fri, Sep 07, 2018 at 10:44:22AM +0100, Burakov, Anatoly wrote:
> On 05-Sep-18 5:28 AM, Tiwei Bie wrote:
> > It's possible to have much more hugepage backed memory regions
> > than what vhost-kernel supports due to the memory hotplug, which
> > may cause problems. A better solution is to have the virtio-user
> > pass all the memory ranges reserved by DPDK to vhost-kernel.
> > 
> > Fixes: 12ecb2f63b12 ("net/virtio-user: support memory hotplug")
> > Cc: sta...@dpdk.org
> > 
> > Signed-off-by: Tiwei Bie 
> > ---
> >   drivers/net/virtio/virtio_user/vhost_kernel.c | 38 +--
> >   1 file changed, 18 insertions(+), 20 deletions(-)
> > 
> > diff --git a/drivers/net/virtio/virtio_user/vhost_kernel.c 
> > b/drivers/net/virtio/virtio_user/vhost_kernel.c
> > index 897fee0af..9338166d9 100644
> > --- a/drivers/net/virtio/virtio_user/vhost_kernel.c
> > +++ b/drivers/net/virtio/virtio_user/vhost_kernel.c
> > @@ -70,41 +70,41 @@ static uint64_t vhost_req_user_to_kernel[] = {
> > [VHOST_USER_SET_MEM_TABLE] = VHOST_SET_MEM_TABLE,
> >   };
> > -struct walk_arg {
> > -   struct vhost_memory_kernel *vm;
> > -   uint32_t region_nr;
> > -};
> >   static int
> > -add_memory_region(const struct rte_memseg_list *msl __rte_unused,
> > -   const struct rte_memseg *ms, size_t len, void *arg)
> > +add_memseg_list(const struct rte_memseg_list *msl, void *arg)
> >   {
> > -   struct walk_arg *wa = arg;
> > +   struct vhost_memory_kernel *vm = arg;
> > struct vhost_memory_region *mr;
> > void *start_addr;
> > +   uint64_t len;
> > -   if (wa->region_nr >= max_regions)
> > +   if (vm->nregions >= max_regions)
> > return -1;
> > -   mr = &wa->vm->regions[wa->region_nr++];
> > -   start_addr = ms->addr;
> > +   start_addr = msl->base_va;
> > +   len = msl->page_sz * msl->memseg_arr.len;
> > +
> > +   mr = &vm->regions[vm->nregions++];
> > mr->guest_phys_addr = (uint64_t)(uintptr_t)start_addr;
> > mr->userspace_addr = (uint64_t)(uintptr_t)start_addr;
> > mr->memory_size = len;
> > -   mr->mmap_offset = 0;
> > +   mr->mmap_offset = 0; /* flags_padding */
> > +
> > +   PMD_DRV_LOG(DEBUG, "index=%u addr=%p len=%" PRIu64,
> > +   vm->nregions - 1, start_addr, len);
> > return 0;
> >   }
> > -/* By default, vhost kernel module allows 64 regions, but DPDK allows
> > - * 256 segments. As a relief, below function merges those virtually
> > - * adjacent memsegs into one region.
> > +/* By default, vhost kernel module allows 64 regions, but DPDK may
> > + * have much more memory regions. Below function will treat each
> > + * contiguous memory space reserved by DPDK as one region.
> >*/
> >   static struct vhost_memory_kernel *
> >   prepare_vhost_memory_kernel(void)
> >   {
> > struct vhost_memory_kernel *vm;
> > -   struct walk_arg wa;
> > vm = malloc(sizeof(struct vhost_memory_kernel) +
> > max_regions *
> > @@ -112,20 +112,18 @@ prepare_vhost_memory_kernel(void)
> > if (!vm)
> > return NULL;
> > -   wa.region_nr = 0;
> > -   wa.vm = vm;
> > +   vm->nregions = 0;
> > +   vm->padding = 0;
> > /*
> >  * The memory lock has already been taken by memory subsystem
> >  * or virtio_user_start_device().
> >  */
> > -   if (rte_memseg_contig_walk_thread_unsafe(add_memory_region, &wa) < 0) {
> > +   if (rte_memseg_list_walk_thread_unsafe(add_memseg_list, vm) < 0) {
> > free(vm);
> > return NULL;
> > }
> > -   vm->nregions = wa.region_nr;
> > -   vm->padding = 0;
> > return vm;
> >   }
> > 
> 
> Doesn't that assume single file segments mode?

This is to find out the VA ranges reserved by memory subsystem.
Why does it need to assume single file segments mode?


> 
> -- 
> Thanks,
> Anatoly


Re: [dpdk-dev] [PATCH 2/3] net/virtio-user: avoid parsing process mappings

2018-09-07 Thread Burakov, Anatoly

On 07-Sep-18 12:35 PM, Tiwei Bie wrote:

On Fri, Sep 07, 2018 at 10:39:16AM +0100, Burakov, Anatoly wrote:

On 05-Sep-18 5:28 AM, Tiwei Bie wrote:

Recently some memory APIs were introduced to allow users to
get the file descriptor and offset for each memory segment.
We can leverage those APIs to get rid of the /proc magic on
memory table preparation in vhost-user backend.

Signed-off-by: Tiwei Bie 
---





-   for (i = 0; i < num; ++i) {
-   mr = &msg->payload.memory.regions[i];
-   mr->guest_phys_addr = huges[i].addr; /* use vaddr! */
-   mr->userspace_addr = huges[i].addr;
-   mr->memory_size = huges[i].size;
-   mr->mmap_offset = 0;
-   fds[i] = open(huges[i].path, O_RDWR);
+   if (rte_memseg_get_fd_offset_thread_unsafe(ms, &offset) < 0) {
+   PMD_DRV_LOG(ERR, "Failed to get offset, ms=%p rte_errno=%d",
+   ms, rte_errno);
+   return -1;
+   }
+
+   start_addr = (uint64_t)(uintptr_t)ms->addr;
+   end_addr = start_addr + ms->len;
+
+   for (i = 0; i < wa->region_nr; i++) {


There has to be a better way than to run this loop on every segment. Maybe
store last-used region, and only do a region look up if there's a mismatch?
Generally, in single-file segments mode, you'll get lots of segments from
one memseg list one after the other, so you will need to do a lookup once
memseg list changes, instead of on each segment.


We may have holes in one memseg list due to dynamic free.
Do you mean we just need to do rte_memseg_contig_walk()
and we can assume that fds of the contiguous memegs will
be the same?


No, i didn't mean that.

Whether or not you are in single-file segments mode, you still need to 
scan each segment. However, you lose your state when you exit this 
function, and thus have to look up the appropriate memory region (that 
matches your fd) again, over and over. It would be good if you could 
store last-used memory region somewhere, so that next time you come back 
into this function, if the memseg has the same fd, you will not have to 
look it up.


Something like this:

struct walk_arg {
*last_used;

}

int walk_func() {

cur_region = wa->last_used; // check if it matches
if (cur->region->fd != fd) {
// fd is different - we've changed the segment

wa->last_used = cur_region
}
}

So, cache last used region to not have to look it up again, because 
chances are, you won't have to. That way, you will still do region 
lookups, but only if you have to - not every time.







+   if (wa->fds[i] != fd)
+   continue;
+
+   mr = &wa->vm->regions[i];
+
+   if (mr->userspace_addr + mr->memory_size < end_addr)
+   mr->memory_size = end_addr - mr->userspace_addr;
+





int fds[VHOST_MEMORY_MAX_NREGIONS];
int fd_num = 0;
-   int i, len;
+   int len;
int vhostfd = dev->vhostfd;
RTE_SET_USED(m);
@@ -364,10 +337,6 @@ vhost_user_sock(struct virtio_user_dev *dev,
return -1;
}
-   if (req == VHOST_USER_SET_MEM_TABLE)
-   for (i = 0; i < fd_num; ++i)
-   close(fds[i]);
-


You're sharing fd's - presumably the other side of this is in a different
process, so it's safe to close these fd's there?


Above code belongs to virtio-user, and it will close the
fds got from rte_memseg_get_fd_thread_unsafe().

Below is the code which will close these fds on the other
side (i.e. the vhost-user process):

https://github.com/DPDK/dpdk/blob/3605968c2fa7/lib/librte_vhost/vhost_user.c#L805
https://github.com/DPDK/dpdk/blob/3605968c2fa7/lib/librte_vhost/vhost_user.c#L97


OK, so not a problem then.







if (need_reply) {
if (vhost_user_read(vhostfd, &msg) < 0) {
PMD_DRV_LOG(ERR, "Received msg failed: %s",




--
Thanks,
Anatoly





--
Thanks,
Anatoly


Re: [dpdk-dev] [PATCH 3/3] net/virtio-user: fix memory hotplug support in vhost-kernel

2018-09-07 Thread Burakov, Anatoly

On 07-Sep-18 12:37 PM, Tiwei Bie wrote:

On Fri, Sep 07, 2018 at 10:44:22AM +0100, Burakov, Anatoly wrote:

On 05-Sep-18 5:28 AM, Tiwei Bie wrote:

It's possible to have much more hugepage backed memory regions
than what vhost-kernel supports due to the memory hotplug, which
may cause problems. A better solution is to have the virtio-user
pass all the memory ranges reserved by DPDK to vhost-kernel.

Fixes: 12ecb2f63b12 ("net/virtio-user: support memory hotplug")
Cc: sta...@dpdk.org

Signed-off-by: Tiwei Bie 
---
   drivers/net/virtio/virtio_user/vhost_kernel.c | 38 +--
   1 file changed, 18 insertions(+), 20 deletions(-)

diff --git a/drivers/net/virtio/virtio_user/vhost_kernel.c 
b/drivers/net/virtio/virtio_user/vhost_kernel.c
index 897fee0af..9338166d9 100644
--- a/drivers/net/virtio/virtio_user/vhost_kernel.c
+++ b/drivers/net/virtio/virtio_user/vhost_kernel.c
@@ -70,41 +70,41 @@ static uint64_t vhost_req_user_to_kernel[] = {
[VHOST_USER_SET_MEM_TABLE] = VHOST_SET_MEM_TABLE,
   };
-struct walk_arg {
-   struct vhost_memory_kernel *vm;
-   uint32_t region_nr;
-};
   static int
-add_memory_region(const struct rte_memseg_list *msl __rte_unused,
-   const struct rte_memseg *ms, size_t len, void *arg)
+add_memseg_list(const struct rte_memseg_list *msl, void *arg)
   {
-   struct walk_arg *wa = arg;
+   struct vhost_memory_kernel *vm = arg;
struct vhost_memory_region *mr;
void *start_addr;
+   uint64_t len;
-   if (wa->region_nr >= max_regions)
+   if (vm->nregions >= max_regions)
return -1;
-   mr = &wa->vm->regions[wa->region_nr++];
-   start_addr = ms->addr;
+   start_addr = msl->base_va;
+   len = msl->page_sz * msl->memseg_arr.len;
+
+   mr = &vm->regions[vm->nregions++];
mr->guest_phys_addr = (uint64_t)(uintptr_t)start_addr;
mr->userspace_addr = (uint64_t)(uintptr_t)start_addr;
mr->memory_size = len;
-   mr->mmap_offset = 0;
+   mr->mmap_offset = 0; /* flags_padding */
+
+   PMD_DRV_LOG(DEBUG, "index=%u addr=%p len=%" PRIu64,
+   vm->nregions - 1, start_addr, len);
return 0;
   }
-/* By default, vhost kernel module allows 64 regions, but DPDK allows
- * 256 segments. As a relief, below function merges those virtually
- * adjacent memsegs into one region.
+/* By default, vhost kernel module allows 64 regions, but DPDK may
+ * have much more memory regions. Below function will treat each
+ * contiguous memory space reserved by DPDK as one region.
*/
   static struct vhost_memory_kernel *
   prepare_vhost_memory_kernel(void)
   {
struct vhost_memory_kernel *vm;
-   struct walk_arg wa;
vm = malloc(sizeof(struct vhost_memory_kernel) +
max_regions *
@@ -112,20 +112,18 @@ prepare_vhost_memory_kernel(void)
if (!vm)
return NULL;
-   wa.region_nr = 0;
-   wa.vm = vm;
+   vm->nregions = 0;
+   vm->padding = 0;
/*
 * The memory lock has already been taken by memory subsystem
 * or virtio_user_start_device().
 */
-   if (rte_memseg_contig_walk_thread_unsafe(add_memory_region, &wa) < 0) {
+   if (rte_memseg_list_walk_thread_unsafe(add_memseg_list, vm) < 0) {
free(vm);
return NULL;
}
-   vm->nregions = wa.region_nr;
-   vm->padding = 0;
return vm;
   }



Doesn't that assume single file segments mode?


This is to find out the VA ranges reserved by memory subsystem.
Why does it need to assume single file segments mode?


If you are not in single-file segments mode, each individual page in a 
VA-contiguous area will be behind a different fd - so it will be part of 
a different region, would it not?







--
Thanks,
Anatoly





--
Thanks,
Anatoly


Re: [dpdk-dev] Change in binary name w/ meson build

2018-09-07 Thread Bruce Richardson
On Wed, Sep 05, 2018 at 11:52:10AM +, Shahaf Shuler wrote:
>Hi Bruce,
> 
> 
>Playing w/ meson build I got to know that the binary name for testpmd
>got changed to dpdk-testpmd.
> 
> 
>Not sure if it was discussed or not before, but such change will affect
>all the automation used to run testpmd w/ the old build system.
> 
> 
>What is the reason for the change in the name?

The primary driver was that the autotest binary could not be called "test"
any more, since that is a reserved name. When appending a dpdk prefix to
the test binary, I felt for consistency that other binaries should have a
dpdk prefix too, to indicate that they come from DPDK. If this is a
problem, we can remove the prefix from the binaries easily enough.

/Bruce


[dpdk-dev] DPDK Shared lib: No Ethernet ports

2018-09-07 Thread Shubhachint, Chaitanya
Hello,

I recently started working with DPDK and gone through the initial steps of 
getting source code installed and trying out few examples. To integrate DPDK 
with our product, I need to build the share-lib version of DPDK.
I run into an issue when I build DPDK as shared, I don't see this issue when 
DPDK is built as static. DPDK built with default configuration, I can run the 
examples and get expected results. When built as shared, EAL detects no 
Ethernet ports.

I am building shared-lib version using steps below:
. switch the CONFIG_RTE_BUILD_SHARED_LIB to y in the config/common_base
. make config T=x86_64-native-linuxapp-gcc
. make install T=x86_64-native-linuxapp-gcc
. export RTE_SDK=$HOME/dpdk-18.08
. export RTE_TARGET=x86_64-native-linuxapp-gcc
. build examples.
. Set LD_LIBRARY_PATH to point to $HOME/dpdk-18.08/ 
x86_64-native-linuxapp-gcc/lib

I am using Intel I350 Quad port NIC, and have switched to uio_pci_generic 
driver =>
Network devices using DPDK-compatible driver

:06:00.0 'I350 Gigabit Network Connection 1521' drv=uio_pci_generic 
unused=igb
:06:00.1 'I350 Gigabit Network Connection 1521' drv=uio_pci_generic 
unused=igb
:06:00.2 'I350 Gigabit Network Connection 1521' drv=uio_pci_generic 
unused=igb
:06:00.3 'I350 Gigabit Network Connection 1521' drv=uio_pci_generic 
unused=igb

When I run any examples, I get error 'No Ethernet ports'.

root:l2fwd$./build/l2fwd
EAL: Detected 6 lcore(s)
EAL: Detected 1 NUMA nodes
EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
EAL: No free hugepages reported in hugepages-1048576kB
EAL: Probing VFIO support...
MAC updating enabled
EAL: Error - exiting with code: 1
  Cause: No Ethernet ports - bye

Interestingly, same code base built with 'CONFIG_RTE_BUILD_SHARED_LIB=n' works 
just fine. The ports get detected correctly and I can run all the examples and 
applications.

Your help is appreciated.
Regards,
Chai.



Re: [dpdk-dev] DPDK Shared lib: No Ethernet ports

2018-09-07 Thread Richardson, Bruce



> -Original Message-
> From: dev [mailto:dev-boun...@dpdk.org] On Behalf Of Shubhachint,
> Chaitanya
> Sent: Friday, September 7, 2018 3:18 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] DPDK Shared lib: No Ethernet ports
> 
> Hello,
> 
> I recently started working with DPDK and gone through the initial steps of
> getting source code installed and trying out few examples. To integrate
> DPDK with our product, I need to build the share-lib version of DPDK.
> I run into an issue when I build DPDK as shared, I don't see this issue
> when DPDK is built as static. DPDK built with default configuration, I can
> run the examples and get expected results. When built as shared, EAL
> detects no Ethernet ports.
> 
> I am building shared-lib version using steps below:
> . switch the CONFIG_RTE_BUILD_SHARED_LIB to y in the config/common_base .
> make config T=x86_64-native-linuxapp-gcc . make install T=x86_64-native-
> linuxapp-gcc . export RTE_SDK=$HOME/dpdk-18.08 . export RTE_TARGET=x86_64-
> native-linuxapp-gcc
> . build examples.
> . Set LD_LIBRARY_PATH to point to $HOME/dpdk-18.08/ x86_64-native-
> linuxapp-gcc/lib
> 
> I am using Intel I350 Quad port NIC, and have switched to uio_pci_generic
> driver => Network devices using DPDK-compatible driver
> 
> :06:00.0 'I350 Gigabit Network Connection 1521' drv=uio_pci_generic
> unused=igb
> :06:00.1 'I350 Gigabit Network Connection 1521' drv=uio_pci_generic
> unused=igb
> :06:00.2 'I350 Gigabit Network Connection 1521' drv=uio_pci_generic
> unused=igb
> :06:00.3 'I350 Gigabit Network Connection 1521' drv=uio_pci_generic
> unused=igb
> 
> When I run any examples, I get error 'No Ethernet ports'.
> 
> root:l2fwd$./build/l2fwd
> EAL: Detected 6 lcore(s)
> EAL: Detected 1 NUMA nodes
> EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
> EAL: No free hugepages reported in hugepages-1048576kB
> EAL: Probing VFIO support...
> MAC updating enabled
> EAL: Error - exiting with code: 1
>   Cause: No Ethernet ports - bye
> 
> Interestingly, same code base built with 'CONFIG_RTE_BUILD_SHARED_LIB=n'
> works just fine. The ports get detected correctly and I can run all the
> examples and applications.
> 
> Your help is appreciated.

With shared library builds, the drivers are not linked in automatically. You
need to explicitly load them via "-d" EAL flag - either individually or by
passing in the path to a directory of drivers which can be loaded. See also
in the build config the setting "CONFIG_RTE_EAL_PMD_PATH" which can be used
to set a default search path for loading drivers.

Regards,
/Bruce


[dpdk-dev] [PATCH] pci/linux: use RTE_IOVA_VA whenever possible

2018-09-07 Thread Darek Stojaczyk
This allows DPDK to use RTE_IOVA_VA with VFIO/UIO-bound PCI
devices present on the system, but not attached to any
rte_pci_driver at the time of init.

So far we used RTE_IOVA_VA whenever there was at least one
device attached to a driver with an RTE_PCI_DRV_IOVA_AS_VA flag,
meaning that other drivers which didn't explicitly report such
flag could have been forced to work in RTE_IOVA_VA as well.

This patch makes the RTE_PCI_DRV_IOVA_AS_VA explicitly a hint.
If it's set, but RTE_IOVA_VA cannot be used, then EAL will print
a proper warning.

Signed-off-by: Darek Stojaczyk 
---
 drivers/bus/pci/linux/pci.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c
index 04648ac93..961e24024 100644
--- a/drivers/bus/pci/linux/pci.c
+++ b/drivers/bus/pci/linux/pci.c
@@ -534,7 +534,7 @@ pci_one_device_bound_uio(void)
  * Any one of the device has iova as va
  */
 static inline int
-pci_one_device_has_iova_va(void)
+pci_one_device_want_iova_va(void)
 {
struct rte_pci_device *dev = NULL;
struct rte_pci_driver *drv = NULL;
@@ -635,7 +635,7 @@ rte_pci_get_iommu_class(void)
 {
bool is_bound;
bool is_vfio_noiommu_enabled = true;
-   bool has_iova_va;
+   bool want_iova_va;
bool is_bound_uio;
bool iommu_no_va;
 
@@ -643,7 +643,7 @@ rte_pci_get_iommu_class(void)
if (!is_bound)
return RTE_IOVA_DC;
 
-   has_iova_va = pci_one_device_has_iova_va();
+   want_iova_va = pci_one_device_want_iova_va();
is_bound_uio = pci_one_device_bound_uio();
iommu_no_va = !pci_devices_iommu_support_va();
 #ifdef VFIO_PRESENT
@@ -651,11 +651,10 @@ rte_pci_get_iommu_class(void)
true : false;
 #endif
 
-   if (has_iova_va && !is_bound_uio && !is_vfio_noiommu_enabled &&
-   !iommu_no_va)
+   if (!is_bound_uio && !is_vfio_noiommu_enabled && !iommu_no_va)
return RTE_IOVA_VA;
 
-   if (has_iova_va) {
+   if (want_iova_va) {
RTE_LOG(WARNING, EAL, "Some devices want iova as va but pa will 
be used because.. ");
if (is_vfio_noiommu_enabled)
RTE_LOG(WARNING, EAL, "vfio-noiommu mode configured\n");
-- 
2.17.1



[dpdk-dev] [PATCH] net/i40e: firmware status check

2018-09-07 Thread Xiaoyun Li
Check the firmware status at init time. If the firmware is in
recovery mode, alert the user to check it.

Signed-off-by: Xiaoyun Li 
---
 drivers/net/i40e/i40e_ethdev.c | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 85a6a86..30cec47 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -1210,7 +1210,7 @@ eth_i40e_dev_init(struct rte_eth_dev *dev, void 
*init_params __rte_unused)
struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
struct i40e_vsi *vsi;
int ret;
-   uint32_t len;
+   uint32_t len, val;
uint8_t aq_fail = 0;
 
PMD_INIT_FUNC_TRACE();
@@ -1261,6 +1261,15 @@ eth_i40e_dev_init(struct rte_eth_dev *dev, void 
*init_params __rte_unused)
 */
hw->switch_tag = 0x;
 
+   val = I40E_READ_REG(hw, I40E_GL_FWSTS);
+   if (val & I40E_GL_FWSTS_FWS1B_MASK) {
+   PMD_INIT_LOG(ERR, "\nERROR: "
+   "Firmware recovery mode detected. Limiting 
functionality.\n"
+   "Refer to the Intel(R) Ethernet Adapters and Devices "
+   "User Guide for details on firmware recovery mode.");
+   return -EIO;
+   }
+
/* Check if need to support multi-driver */
i40e_support_multi_driver(dev);
 
-- 
2.7.4



[dpdk-dev] [PATCH] net/ixgbe: firmware status check

2018-09-07 Thread Xiaoyun Li
Check the firmware status at init time. If the firmware is in
recovery mode, alert the user to check it.

Signed-off-by: Xiaoyun Li 
---
v1:
 * This patch needs base code updating which will be done later.
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 26b1927..263c72b 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -1107,6 +1107,14 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev, void 
*init_params __rte_unused)
hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
hw->allow_unsupported_sfp = 1;
 
+   if (hw->mac.ops.fw_recovery_mode && hw->mac.ops.fw_recovery_mode(hw)) {
+   PMD_INIT_LOG(ERR, "\nERROR:"
+   "Firmware recovery mode detected. Limiting 
functionality.\n"
+   "Refer to the Intel(R) Ethernet Adapters and Devices "
+   "User Guide for details on firmware recovery mode.");
+   return -EIO;
+   }
+
/* Initialize the shared code (base driver) */
 #ifdef RTE_LIBRTE_IXGBE_BYPASS
diag = ixgbe_bypass_init_shared_code(hw);
-- 
2.7.4



[dpdk-dev] [PATCH 01/21] net/atlantic: atlantic PMD driver skeleton

2018-09-07 Thread Igor Russkikh
From: Pavel Belous 

Makefile/meson build infrastructure, atl_ethdev minimal skeleton,
header with aquantia aQtion NIC device and vendor IDs.

Signed-off-by: Igor Russkikh 
---
 config/common_base|   9 +
 drivers/net/Makefile  |   2 +
 drivers/net/atlantic/Makefile |  59 +
 drivers/net/atlantic/atl_common.h |  97 
 drivers/net/atlantic/atl_ethdev.c | 284 ++
 drivers/net/atlantic/atl_ethdev.h |  28 +++
 drivers/net/atlantic/meson.build  |  19 ++
 drivers/net/atlantic/rte_pmd_atlantic_version.map |   4 +
 drivers/net/meson.build   |   1 +
 mk/rte.app.mk |   1 +
 10 files changed, 504 insertions(+)
 create mode 100644 drivers/net/atlantic/Makefile
 create mode 100644 drivers/net/atlantic/atl_common.h
 create mode 100644 drivers/net/atlantic/atl_ethdev.c
 create mode 100644 drivers/net/atlantic/atl_ethdev.h
 create mode 100644 drivers/net/atlantic/meson.build
 create mode 100644 drivers/net/atlantic/rte_pmd_atlantic_version.map

diff --git a/config/common_base b/config/common_base
index 4bcbaf923..3b5fc8e71 100644
--- a/config/common_base
+++ b/config/common_base
@@ -635,6 +635,15 @@ CONFIG_RTE_LIBRTE_PMD_DPAA_EVENTDEV=n
 CONFIG_RTE_LIBRTE_PMD_DPAA2_EVENTDEV=n
 
 #
+# Compile Aquantia Atlantic PMD driver
+#
+CONFIG_RTE_LIBRTE_ATLANTIC_PMD=y
+CONFIG_RTE_LIBRTE_ATLANTIC_DEBUG=n
+CONFIG_RTE_LIBRTE_ATLANTIC_DEBUG_RX=n
+CONFIG_RTE_LIBRTE_ATLANTIC_DEBUG_TX=n
+CONFIG_RTE_LIBRTE_ATLANTIC_DEBUG_TX_FREE=n
+
+#
 # Compile raw device support
 # EXPERIMENTAL: API may change without prior notice
 #
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 664398de9..3d4a1ae59 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -70,4 +70,6 @@ $(error "RTE_LIBRTE_CFGFILE must be enabled in 
configuration!")
 endif
 endif
 
+DIRS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += atlantic
+
 include $(RTE_SDK)/mk/rte.subdir.mk
diff --git a/drivers/net/atlantic/Makefile b/drivers/net/atlantic/Makefile
new file mode 100644
index 0..d70ee4380
--- /dev/null
+++ b/drivers/net/atlantic/Makefile
@@ -0,0 +1,59 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2018 Aquantia Corporation
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# library name
+#
+LIB = librte_pmd_atlantic.a
+
+CFLAGS += -O3
+CFLAGS += $(WERROR_FLAGS)
+
+EXPORT_MAP := rte_pmd_atlantic_version.map
+
+LIBABIVER := 1
+
+ifeq ($(CONFIG_RTE_TOOLCHAIN_ICC),y)
+#
+# CFLAGS for icc
+#
+CFLAGS_BASE_DRIVER = -wd174 -wd593 -wd869 -wd981 -wd2259
+
+else ifeq ($(CONFIG_RTE_TOOLCHAIN_CLANG),y)
+#
+# CFLAGS for clang
+#
+#CFLAGS_BASE_DRIVER = -Wno-unused-parameter -Wno-unused-value
+CFLAGS_BASE_DRIVER += -Wno-strict-aliasing -Wno-format-extra-args
+
+else
+#
+# CFLAGS for gcc
+#
+
+#CFLAGS_BASE_DRIVER = -Wno-unused-parameter -Wno-unused-value
+CFLAGS_BASE_DRIVER += -Wno-strict-aliasing -Wno-format-extra-args
+
+
+endif
+LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
+LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs -lrte_hash
+LDLIBS += -lrte_bus_pci
+
+#
+# Add extra flags for base driver files (also known as shared code)
+# to disable warnings in them
+#
+BASE_DRIVER_OBJS=$(sort $(patsubst %.c,%.o,$(notdir $(wildcard 
$(SRCDIR)/base/*.c
+$(foreach obj, $(BASE_DRIVER_OBJS), $(eval 
CFLAGS_$(obj)+=$(CFLAGS_BASE_DRIVER)))
+
+VPATH += $(SRCDIR)/hw_atl
+
+#
+# all source are stored in SRCS-y
+#
+SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += atl_ethdev.c
+
+include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/drivers/net/atlantic/atl_common.h 
b/drivers/net/atlantic/atl_common.h
new file mode 100644
index 0..fd3e705e7
--- /dev/null
+++ b/drivers/net/atlantic/atl_common.h
@@ -0,0 +1,97 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 Aquantia Corporation
+ */
+
+#ifndef AQ_COMMON_H
+#define AQ_COMMON_H
+
+#define ATL_PMD_DRIVER_VERSION "0.4.1"
+
+#define PCI_VENDOR_ID_AQUANTIA  0x1D6A
+
+#define AQ_DEVICE_ID_0001  0x0001
+#define AQ_DEVICE_ID_D100  0xD100
+#define AQ_DEVICE_ID_D107  0xD107
+#define AQ_DEVICE_ID_D108  0xD108
+#define AQ_DEVICE_ID_D109  0xD109
+
+#define AQ_DEVICE_ID_AQC1000x00B1
+#define AQ_DEVICE_ID_AQC1070x07B1
+#define AQ_DEVICE_ID_AQC1080x08B1
+#define AQ_DEVICE_ID_AQC1090x09B1
+#define AQ_DEVICE_ID_AQC1110x11B1
+#define AQ_DEVICE_ID_AQC1120x12B1
+
+#define AQ_DEVICE_ID_AQC100S   0x80B1
+#define AQ_DEVICE_ID_AQC107S   0x87B1
+#define AQ_DEVICE_ID_AQC108S   0x88B1
+#define AQ_DEVICE_ID_AQC109S   0x89B1
+#define AQ_DEVICE_ID_AQC111S   0x91B1
+#define AQ_DEVICE_ID_AQC112S   0x92B1
+
+#define AQ_DEVICE_ID_AQC111E   0x51B1
+#define AQ_DEVICE_ID_AQC112E   0x52B1
+
+#define HW_ATL_NIC_NAME "aQuantia AQtion 10Gbit Network Adapter"
+
+#define AQ_HWREV_ANY   0
+#define AQ_HWREV_1 1
+#define AQ_HWREV_2 2
+
+#define AQ_NIC_RATE_10GBIT(0)

[dpdk-dev] [PATCH 05/21] net/atlantic: b0 hardware layer main logic

2018-09-07 Thread Igor Russkikh
This is hw_atl logic layer derived from linux atlantic
driver. It contains RX/TX hardware initialization
sequences, various hw configuration.

Signed-off-by: Igor Russkikh 
---
 drivers/net/atlantic/hw_atl/hw_atl_b0.c  | 504 +++
 drivers/net/atlantic/hw_atl/hw_atl_b0.h  |  45 ++
 drivers/net/atlantic/hw_atl/hw_atl_b0_internal.h | 151 +++
 3 files changed, 700 insertions(+)
 create mode 100644 drivers/net/atlantic/hw_atl/hw_atl_b0.c
 create mode 100644 drivers/net/atlantic/hw_atl/hw_atl_b0.h
 create mode 100644 drivers/net/atlantic/hw_atl/hw_atl_b0_internal.h

diff --git a/drivers/net/atlantic/hw_atl/hw_atl_b0.c 
b/drivers/net/atlantic/hw_atl/hw_atl_b0.c
new file mode 100644
index 0..71f5b0633
--- /dev/null
+++ b/drivers/net/atlantic/hw_atl/hw_atl_b0.c
@@ -0,0 +1,504 @@
+/*
+ * aQuantia Corporation Network Driver
+ * Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ */
+
+/* File hw_atl_b0.c: Definition of Atlantic hardware specific functions. */
+
+#include "../atl_types.h"
+#include "hw_atl_b0.h"
+
+#include "../atl_hw_regs.h"
+#include "hw_atl_utils.h"
+#include "hw_atl_llh.h"
+#include "hw_atl_b0_internal.h"
+#include "hw_atl_llh_internal.h"
+#include "../atl_logs.h"
+
+int hw_atl_b0_hw_rss_hash_type_set(struct aq_hw_s *self);
+
+int hw_atl_b0_hw_reset(struct aq_hw_s *self)
+{
+   int err = 0;
+
+   err = hw_atl_utils_soft_reset(self);
+   if (err)
+   return err;
+
+   self->aq_fw_ops->set_state(self, MPI_RESET);
+
+   return err;
+}
+
+static int hw_atl_b0_hw_qos_set(struct aq_hw_s *self)
+{
+   u32 tc = 0U;
+   u32 buff_size = 0U;
+   unsigned int i_priority = 0U;
+   bool is_rx_flow_control = false;
+
+   /* TPS Descriptor rate init */
+   hw_atl_tps_tx_pkt_shed_desc_rate_curr_time_res_set(self, 0x0U);
+   hw_atl_tps_tx_pkt_shed_desc_rate_lim_set(self, 0xA);
+
+   /* TPS VM init */
+   hw_atl_tps_tx_pkt_shed_desc_vm_arb_mode_set(self, 0U);
+
+   /* TPS TC credits init */
+   hw_atl_tps_tx_pkt_shed_desc_tc_arb_mode_set(self, 0U);
+   hw_atl_tps_tx_pkt_shed_data_arb_mode_set(self, 0U);
+
+   hw_atl_tps_tx_pkt_shed_tc_data_max_credit_set(self, 0xFFF, 0U);
+   hw_atl_tps_tx_pkt_shed_tc_data_weight_set(self, 0x64, 0U);
+   hw_atl_tps_tx_pkt_shed_desc_tc_max_credit_set(self, 0x50, 0U);
+   hw_atl_tps_tx_pkt_shed_desc_tc_weight_set(self, 0x1E, 0U);
+
+   /* Tx buf size */
+   buff_size = HW_ATL_B0_TXBUF_MAX;
+
+   hw_atl_tpb_tx_pkt_buff_size_per_tc_set(self, buff_size, tc);
+   hw_atl_tpb_tx_buff_hi_threshold_per_tc_set(self,
+  (buff_size *
+  (1024 / 32U) * 66U) /
+  100U, tc);
+   hw_atl_tpb_tx_buff_lo_threshold_per_tc_set(self,
+  (buff_size *
+  (1024 / 32U) * 50U) /
+  100U, tc);
+
+   /* QoS Rx buf size per TC */
+   tc = 0;
+   is_rx_flow_control = 0;//TODO (AQ_NIC_FC_RX & 
self->aq_nic_cfg->flow_control);
+   buff_size = HW_ATL_B0_RXBUF_MAX;
+
+   hw_atl_rpb_rx_pkt_buff_size_per_tc_set(self, buff_size, tc);
+   hw_atl_rpb_rx_buff_hi_threshold_per_tc_set(self,
+  (buff_size *
+  (1024U / 32U) * 66U) /
+  100U, tc);
+   hw_atl_rpb_rx_buff_lo_threshold_per_tc_set(self,
+  (buff_size *
+  (1024U / 32U) * 50U) /
+  100U, tc);
+   hw_atl_rpb_rx_xoff_en_per_tc_set(self, is_rx_flow_control ? 1U : 0U, 
tc);
+
+   /* QoS 802.1p priority -> TC mapping */
+   for (i_priority = 8U; i_priority--;)
+   hw_atl_rpf_rpb_user_priority_tc_map_set(self, i_priority, 0U);
+
+   return aq_hw_err_from_flags(self);
+}
+
+int hw_atl_b0_hw_rss_hash_set(struct aq_hw_s *self,
+struct aq_rss_parameters *rss_params)
+{
+   struct aq_hw_cfg_s *cfg = self->aq_nic_cfg;
+   int err = 0;
+   unsigned int i = 0U;
+   unsigned int addr = 0U;
+
+   for (i = 10, addr = 0U; i--; ++addr) {
+   u32 key_data = cfg->is_rss ?
+   htonl(rss_params->hash_secret_key[i]) : 0U;
+   hw_atl_rpf_rss_key_wr_data_set(self, key_data);
+   hw_atl_rpf_rss_key_addr_set(self, addr);
+   hw_atl_rpf_rss_key_wr_en_set(self, 1U);
+

[dpdk-dev] [PATCH 03/21] net/atlantic: logging macroes and some typedefs

2018-09-07 Thread Igor Russkikh
Signed-off-by: Igor Russkikh 
---
 drivers/net/atlantic/atl_ethdev.c |  9 +++
 drivers/net/atlantic/atl_logs.h   | 55 +++
 drivers/net/atlantic/atl_types.h  | 34 
 3 files changed, 98 insertions(+)
 create mode 100644 drivers/net/atlantic/atl_logs.h
 create mode 100644 drivers/net/atlantic/atl_types.h

diff --git a/drivers/net/atlantic/atl_ethdev.c 
b/drivers/net/atlantic/atl_ethdev.c
index 16080ef9e..31ff50f18 100644
--- a/drivers/net/atlantic/atl_ethdev.c
+++ b/drivers/net/atlantic/atl_ethdev.c
@@ -145,6 +145,8 @@ eth_atl_dev_init(struct rte_eth_dev *eth_dev)
struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
int err = 0;
 
+   PMD_INIT_FUNC_TRACE();
+
eth_dev->dev_ops = &atl_eth_dev_ops;
eth_dev->rx_pkt_burst = &atl_recv_pkts;
eth_dev->tx_pkt_burst = &atl_xmit_pkts;
@@ -165,6 +167,8 @@ eth_atl_dev_uninit(struct rte_eth_dev *eth_dev)
struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
struct aq_hw_s *hw;
 
+   PMD_INIT_FUNC_TRACE();
+
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
return -EPERM;
 
@@ -220,9 +224,12 @@ atl_dev_start(struct rte_eth_dev *dev)
dev->data->dev_conf.intr_conf.rxq != 0) {
intr_vector = dev->data->nb_rx_queues;
if (intr_vector > ATL_MAX_INTR_QUEUE_NUM) {
+   PMD_INIT_LOG(ERR, "At most %d intr queues supported",
+   ATL_MAX_INTR_QUEUE_NUM);
return -ENOTSUP;
}
if (rte_intr_efd_enable(intr_handle, intr_vector)) {
+   PMD_INIT_LOG(ERR, "rte_intr_efd_enable failed");
return -1;
}
}
@@ -231,6 +238,8 @@ atl_dev_start(struct rte_eth_dev *dev)
intr_handle->intr_vec = rte_zmalloc("intr_vec",
dev->data->nb_rx_queues * sizeof(int), 0);
if (intr_handle->intr_vec == NULL) {
+   PMD_INIT_LOG(ERR, "Failed to allocate %d rx_queues"
+" intr_vec", dev->data->nb_rx_queues);
return -ENOMEM;
}
}
diff --git a/drivers/net/atlantic/atl_logs.h b/drivers/net/atlantic/atl_logs.h
new file mode 100644
index 0..c5020c3e4
--- /dev/null
+++ b/drivers/net/atlantic/atl_logs.h
@@ -0,0 +1,55 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 Aquantia Corporation
+ */
+#ifndef ATL_LOGS_H
+#define ATL_LOGS_H
+
+#include 
+
+extern int atl_logtype_init;
+
+#ifndef RTE_LIBRTE_ATLANTIC_DEBUG
+#define RTE_LIBRTE_ATLANTIC_DEBUG 0
+#endif
+
+
+#if RTE_LIBRTE_ATLANTIC_DEBUG
+#define PMD_INIT_LOG(level, fmt, args...) \
+   rte_log(RTE_LOG_ ## level, atl_logtype_init, \
+   "%s(): " fmt "\n", __func__, ##args)
+#else
+#define PMD_INIT_LOG(level, fmt, args...) do { } while(0)
+#endif
+
+#define PMD_INIT_FUNC_TRACE() PMD_INIT_LOG(DEBUG, " >>")
+
+#if RTE_LIBRTE_ATLANTIC_DEBUG_RX
+#define PMD_RX_LOG(level, fmt, args...) \
+   RTE_LOG(level, PMD, "%s(): " fmt "\n", __func__, ## args)
+#else
+#define PMD_RX_LOG(level, fmt, args...) do { } while(0)
+#endif
+
+#if RTE_LIBRTE_ATLANTIC_DEBUG_TX
+#define PMD_TX_LOG(level, fmt, args...) \
+   RTE_LOG(level, PMD, "%s(): " fmt "\n", __func__, ## args)
+#else
+#define PMD_TX_LOG(level, fmt, args...) do { } while(0)
+#endif
+
+#if RTE_LIBRTE_ATLANTIC_DEBUG_TX_FREE
+#define PMD_TX_FREE_LOG(level, fmt, args...) \
+   RTE_LOG(level, PMD, "%s(): " fmt "\n", __func__, ## args)
+#else
+#define PMD_TX_FREE_LOG(level, fmt, args...) do { } while(0)
+#endif
+
+extern int atl_logtype_driver;
+#define PMD_DRV_LOG_RAW(level, fmt, args...) \
+   rte_log(RTE_LOG_ ## level, atl_logtype_driver, "%s(): " fmt, \
+   __func__, ## args)
+
+#define PMD_DRV_LOG(level, fmt, args...) \
+   PMD_DRV_LOG_RAW(level, fmt "\n", ## args)
+
+#endif
diff --git a/drivers/net/atlantic/atl_types.h b/drivers/net/atlantic/atl_types.h
new file mode 100644
index 0..f1558b0a5
--- /dev/null
+++ b/drivers/net/atlantic/atl_types.h
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 Aquantia Corporation
+ */
+#ifndef ATL_TYPES_H
+#define ATL_TYPES_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+typedef uint8_tu8;
+typedef int8_t s8;
+typedef uint16_t   u16;
+typedef int16_ts16;
+typedef uint32_t   u32;
+typedef int32_ts32;
+typedef uint64_t   u64;
+#ifndef __cplusplus
+typedef intbool;
+#endif
+
+#define FALSE   0
+#define TRUE1
+
+#define false   0
+#define true1
+#define min(a,b)   RTE_MIN(a,b)
+#define max(a,b)   RTE_MAX(a,b)
+
+#define wmb()  rte_wmb()
+
+#endif
-- 
2.13.3.windows.1



[dpdk-dev] [PATCH 02/21] net/atlantic: documentation and rel notes

2018-09-07 Thread Igor Russkikh
Signed-off-by: Igor Russkikh 
---
 doc/guides/nics/atlantic.rst   | 59 ++
 doc/guides/nics/features/atlantic.ini  | 37 +
 doc/guides/nics/index.rst  |  1 +
 doc/guides/rel_notes/release_18_11.rst |  5 +++
 4 files changed, 102 insertions(+)
 create mode 100644 doc/guides/nics/atlantic.rst
 create mode 100644 doc/guides/nics/features/atlantic.ini

diff --git a/doc/guides/nics/atlantic.rst b/doc/guides/nics/atlantic.rst
new file mode 100644
index 0..b65916fea
--- /dev/null
+++ b/doc/guides/nics/atlantic.rst
@@ -0,0 +1,59 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+Copyright(c) 2018 Aquantia Corporation.
+
+Aquantia Atlantic DPDK Driver
+=
+
+Atlantic DPDK driver provides DPDK support for Aquantia's AQtion family of 
chipsets: AQC107/AQC108/AQC109
+
+Supported features
+^^
+
+
+- Base L2 features
+- Promiscuous mode
+- Port statistics
+- Multicast mode
+- RSS (Receive Side Scaling)
+- Checksum offload
+- Jumbo Frame upto 16K
+
+Configuration Information
+^
+
+- ``CONFIG_RTE_LIBRTE_ATLANTIC_PMD`` (default ``y``)
+
+- Various debug (default ``n``):
+- ``CONFIG_RTE_LIBRTE_ATLANTIC_DEBUG``
+- ``CONFIG_RTE_LIBRTE_ATLANTIC_DEBUG_RX``
+- ``CONFIG_RTE_LIBRTE_ATLANTIC_DEBUG_TX``
+- ``CONFIG_RTE_LIBRTE_ATLANTIC_DEBUG_TX_FREE``
+
+Not yet supported features
+^^
+
+NOP
+
+Application Programming Interface
+-
+
+Atlantic NIC supports custom LED pin configuration interface.
+For details, refer rte_pmd_atlantic.h header file
+
+Limitations or Known issues
+---
+
+Statistics
+~~
+
+MTU setting
+~~~
+
+Atlantic NIC supports up to 16K jumbo frame size
+
+Supported Chipsets and NICs
+---
+
+- Aquantia AQtion AQC107 10 Gigabit Ethernet Controller
+- Aquantia AQtion AQC108 5 Gigabit Ethernet Controller
+- Aquantia AQtion AQC109 2.5 Gigabit Ethernet Controller
diff --git a/doc/guides/nics/features/atlantic.ini 
b/doc/guides/nics/features/atlantic.ini
new file mode 100644
index 0..2d943ce13
--- /dev/null
+++ b/doc/guides/nics/features/atlantic.ini
@@ -0,0 +1,37 @@
+;
+; Supported features of the 'atlantic' network poll mode driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+[Features]
+Speed capabilities   = Y
+Link status  = Y
+Link status event= Y
+MTU update   = Y
+Jumbo frame  = Y
+Promiscuous mode = Y
+Allmulticast mode= Y
+Unicast MAC filter   = Y
+VLAN filter  = Y
+Flow control = Y
+CRC offload  = Y
+VLAN offload = Y
+L3 checksum offload  = Y
+L4 checksum offload  = Y
+Rx descriptor status = Y
+Tx descriptor status = Y
+Basic stats  = Y
+Extended stats   = Y
+Stats per queue  = Y
+Linux UIO= Y
+x86-32   = Y
+x86-64   = Y
+Queue start/stop = Y
+RSS hash = Y
+RSS key update   = Y
+RSS reta update  = Y
+Packet type parsing  = Y
+FW version   = Y
+EEPROM dump  = Y
+Registers dump   = Y
+LED  = Y
diff --git a/doc/guides/nics/index.rst b/doc/guides/nics/index.rst
index 59f6063dc..7925c2bd8 100644
--- a/doc/guides/nics/index.rst
+++ b/doc/guides/nics/index.rst
@@ -12,6 +12,7 @@ Network Interface Controller Drivers
 features
 build_and_test
 ark
+atlantic
 avp
 axgbe
 bnx2x
diff --git a/doc/guides/rel_notes/release_18_11.rst 
b/doc/guides/rel_notes/release_18_11.rst
index 3ae6b3f58..5a68ff8c3 100644
--- a/doc/guides/rel_notes/release_18_11.rst
+++ b/doc/guides/rel_notes/release_18_11.rst
@@ -54,6 +54,11 @@ New Features
  Also, make sure to start the actual text at the margin.
  =
 
+* **Added Ethernet poll mode driver for Aquantia aQtion family of 10G 
devices.**
+
+  Added the new ``atlantic`` ethernet poll mode driver for Aquantia XGBE 
devices.
+  See the :doc:`../nics/atlantic` nic driver guide for more details on this
+  driver.
 
 API Changes
 ---
-- 
2.13.3.windows.1



[dpdk-dev] [PATCH 06/21] net/atlantic: firmware operations layer

2018-09-07 Thread Igor Russkikh
AQC NICs comes in fields with two major
FW generations: 1x and 3x.

This is part of linux atlantic driver shared code,
responsible for internal NIC firmware interactions,
including link management ops, FW initialization,
various lifecycle features.

Signed-off-by: Igor Russkikh 
---
 drivers/net/atlantic/hw_atl/hw_atl_utils.c  | 942 
 drivers/net/atlantic/hw_atl/hw_atl_utils.h  | 516 +
 drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c | 623 
 3 files changed, 2081 insertions(+)
 create mode 100644 drivers/net/atlantic/hw_atl/hw_atl_utils.c
 create mode 100644 drivers/net/atlantic/hw_atl/hw_atl_utils.h
 create mode 100644 drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c

diff --git a/drivers/net/atlantic/hw_atl/hw_atl_utils.c 
b/drivers/net/atlantic/hw_atl/hw_atl_utils.c
new file mode 100644
index 0..c3b55baad
--- /dev/null
+++ b/drivers/net/atlantic/hw_atl/hw_atl_utils.c
@@ -0,0 +1,942 @@
+/*
+ * aQuantia Corporation Network Driver
+ * Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ */
+
+/* File hw_atl_utils.c: Definition of common functions for Atlantic hardware
+ * abstraction layer.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "../atl_hw_regs.h"
+
+#include "hw_atl_llh.h"
+#include "hw_atl_llh_internal.h"
+#include "../atl_logs.h"
+
+#define HW_ATL_UCP_0X370_REG0x0370U
+
+#define HW_ATL_MIF_CMD  0x0200U
+#define HW_ATL_MIF_ADDR 0x0208U
+#define HW_ATL_MIF_VAL  0x020CU
+
+#define HW_ATL_FW_SM_RAM0x2U
+#define HW_ATL_MPI_FW_VERSION  0x18
+#define HW_ATL_MPI_CONTROL_ADR  0x0368U
+#define HW_ATL_MPI_STATE_ADR0x036CU
+
+#define HW_ATL_MPI_STATE_MSK  0x00FFU
+#define HW_ATL_MPI_STATE_SHIFT0U
+#define HW_ATL_MPI_SPEED_MSK  0x00FFU
+#define HW_ATL_MPI_SPEED_SHIFT16U
+#define HW_ATL_MPI_DIRTY_WAKE_MSK 0x0200U
+
+#define HW_ATL_MPI_DAISY_CHAIN_STATUS  0x704
+#define HW_ATL_MPI_BOOT_EXIT_CODE  0x388
+
+#define HW_ATL_MAC_PHY_CONTROL 0x4000
+#define HW_ATL_MAC_PHY_MPI_RESET_BIT 0x1D
+
+#define HW_ATL_FW_VER_1X 0x01050006U
+#define HW_ATL_FW_VER_2X 0x0200U
+#define HW_ATL_FW_VER_3X 0x0300U
+
+#define FORCE_FLASHLESS 0
+
+static int hw_atl_utils_ver_match(u32 ver_expected, u32 ver_actual);
+int hw_atl_utils_mpi_set_state(struct aq_hw_s *self,
+   enum hal_atl_utils_fw_state_e state);
+
+
+int hw_atl_utils_initfw(struct aq_hw_s *self, const struct aq_fw_ops **fw_ops)
+{
+   int err = 0;
+
+   err = hw_atl_utils_soft_reset(self);
+   if (err)
+   return err;
+
+   hw_atl_utils_hw_chip_features_init(self,
+  &self->chip_features);
+
+   hw_atl_utils_get_fw_version(self, &self->fw_ver_actual);
+
+   if (hw_atl_utils_ver_match(HW_ATL_FW_VER_1X,
+  self->fw_ver_actual) == 0) {
+   *fw_ops = &aq_fw_1x_ops;
+   } else if (hw_atl_utils_ver_match(HW_ATL_FW_VER_2X,
+   self->fw_ver_actual) == 0) {
+   *fw_ops = &aq_fw_2x_ops;
+   } else if (hw_atl_utils_ver_match(HW_ATL_FW_VER_3X,
+   self->fw_ver_actual) == 0) {
+   *fw_ops = &aq_fw_2x_ops;
+   } else {
+   PMD_DRV_LOG(ERR, "Bad FW version detected: %x\n",
+ self->fw_ver_actual);
+   return -EOPNOTSUPP;
+   }
+   self->aq_fw_ops = *fw_ops;
+   err = self->aq_fw_ops->init(self);
+   return err;
+}
+
+static int hw_atl_utils_soft_reset_flb(struct aq_hw_s *self)
+{
+   u32 gsr, val;
+   int k = 0;
+
+   aq_hw_write_reg(self, 0x404, 0x40e1);
+   AQ_HW_SLEEP(50);
+
+   /* Cleanup SPI */
+   val = aq_hw_read_reg(self, 0x53C);
+   aq_hw_write_reg(self, 0x53C, val | 0x10);
+
+   gsr = aq_hw_read_reg(self, HW_ATL_GLB_SOFT_RES_ADR);
+   aq_hw_write_reg(self, HW_ATL_GLB_SOFT_RES_ADR, (gsr & 0xBFFF) | 0x8000);
+
+   /* Kickstart MAC */
+   aq_hw_write_reg(self, 0x404, 0x80e0);
+   aq_hw_write_reg(self, 0x32a8, 0x0);
+   aq_hw_write_reg(self, 0x520, 0x1);
+
+   /* Reset SPI again because of possible interrupted SPI burst */
+   val = aq_hw_read_reg(self, 0x53C);
+   aq_hw_write_reg(self, 0x53C, val | 0x10);
+   AQ_HW_SLEEP(10);
+   /* Clear SPI reset state */
+   aq_hw_write_reg(self, 0x53C, val & ~0x10);
+
+   aq_hw_write_reg(self, 0x404, 0x180e0);
+
+   for (k = 0; k < 1000; k++) {
+   u32 flb_status = aq_hw_read_reg(self,
+   HW_ATL_MPI_DAISY_CHAIN_STATUS);
+
+   flb_status = flb_status & 0x10;
+  

[dpdk-dev] [PATCH 00/21] net/atlantic: Aquantia aQtion 10G NIC Family DPDK PMD driver

2018-09-07 Thread Igor Russkikh
Hello DPDK community!

Aquantia would like to contribute PMD for aQtion AQC10X NIC family:
https://www.aquantia.com/products/aqtion/chips/
These are 10G ethernet NICs with various features.

We do base this work on parts of the existing native linux kernel
driver source (atlantic). Shared code is hw_atl hardware and registers access 
module.

We'd like to target this driver for 18.11 DPDK release timeline,
it'd be good to hear comments from the community on how feasible is this.

This patchset implements basic driver infrastructure,
vlan offloads, checksumm offloads, rss control,
multiring, jumbo frames and other features.

Later on, we plan to share HW MACSEC offloads, rxflows and other features.

Igor Russkikh (11):
  net/atlantic: documentation and rel notes
  net/atlantic: logging macroes and some typedefs
  net/atlantic: hw_atl register declarations
  net/atlantic: b0 hardware layer main logic
  net/atlantic: firmware operations layer
  net/atlantic: hardware register access routines
  net/atlantic: rte device start, stop, initial configuration
  net/atlantic: RSS and RETA manipulation API
  net/atlantic: LED control DPDK and private APIs
  net/atlantic: device statistics, xstats
  net/atlantic: RX side structures and implementation

Pavel Belous (10):
  net/atlantic: atlantic PMD driver skeleton
  net/atlantic: link status and interrupt management
  net/atlantic: add hw adapter structures and defines
  net/atlantic: flow control configuration
  net/atlantic: MAC address manipulations
  net/atlantic: eeprom and register manipulation routines
  net/atlantic: promisc and allmulti configuration
  net/atlantic: VLAN filters and offloads
  net/atlantic: device MTU and statuses
  net/atlantic: TX side structures and implementation

 config/common_base|9 +
 doc/guides/nics/atlantic.rst  |   59 +
 doc/guides/nics/features/atlantic.ini |   37 +
 doc/guides/nics/index.rst |1 +
 doc/guides/rel_notes/release_18_11.rst|5 +
 drivers/net/Makefile  |2 +
 drivers/net/atlantic/Makefile |   69 +
 drivers/net/atlantic/atl_common.h |   97 +
 drivers/net/atlantic/atl_ethdev.c | 1717 +++
 drivers/net/atlantic/atl_ethdev.h |  131 ++
 drivers/net/atlantic/atl_hw_regs.c|   58 +
 drivers/net/atlantic/atl_hw_regs.h|   59 +
 drivers/net/atlantic/atl_logs.h   |   55 +
 drivers/net/atlantic/atl_rxtx.c   | 1324 +++
 drivers/net/atlantic/atl_types.h  |  234 ++
 drivers/net/atlantic/hw_atl/hw_atl_b0.c   |  504 +
 drivers/net/atlantic/hw_atl/hw_atl_b0.h   |   45 +
 drivers/net/atlantic/hw_atl/hw_atl_b0_internal.h  |  151 ++
 drivers/net/atlantic/hw_atl/hw_atl_llh.c  | 1490 +
 drivers/net/atlantic/hw_atl/hw_atl_llh.h  |  714 ++
 drivers/net/atlantic/hw_atl/hw_atl_llh_internal.h | 2413 +
 drivers/net/atlantic/hw_atl/hw_atl_utils.c|  942 
 drivers/net/atlantic/hw_atl/hw_atl_utils.h|  516 +
 drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c   |  623 ++
 drivers/net/atlantic/meson.build  |   28 +
 drivers/net/atlantic/rte_pmd_atlantic.c   |   19 +
 drivers/net/atlantic/rte_pmd_atlantic.h   |   44 +
 drivers/net/atlantic/rte_pmd_atlantic_version.map |4 +
 drivers/net/meson.build   |1 +
 mk/rte.app.mk |1 +
 30 files changed, 11352 insertions(+)
 create mode 100644 doc/guides/nics/atlantic.rst
 create mode 100644 doc/guides/nics/features/atlantic.ini
 create mode 100644 drivers/net/atlantic/Makefile
 create mode 100644 drivers/net/atlantic/atl_common.h
 create mode 100644 drivers/net/atlantic/atl_ethdev.c
 create mode 100644 drivers/net/atlantic/atl_ethdev.h
 create mode 100644 drivers/net/atlantic/atl_hw_regs.c
 create mode 100644 drivers/net/atlantic/atl_hw_regs.h
 create mode 100644 drivers/net/atlantic/atl_logs.h
 create mode 100644 drivers/net/atlantic/atl_rxtx.c
 create mode 100644 drivers/net/atlantic/atl_types.h
 create mode 100644 drivers/net/atlantic/hw_atl/hw_atl_b0.c
 create mode 100644 drivers/net/atlantic/hw_atl/hw_atl_b0.h
 create mode 100644 drivers/net/atlantic/hw_atl/hw_atl_b0_internal.h
 create mode 100644 drivers/net/atlantic/hw_atl/hw_atl_llh.c
 create mode 100644 drivers/net/atlantic/hw_atl/hw_atl_llh.h
 create mode 100644 drivers/net/atlantic/hw_atl/hw_atl_llh_internal.h
 create mode 100644 drivers/net/atlantic/hw_atl/hw_atl_utils.c
 create mode 100644 drivers/net/atlantic/hw_atl/hw_atl_utils.h
 create mode 100644 drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c
 create mode 100644 drivers/net/atlantic/meson.build
 create mode 100644 drivers/net/atlantic/rte_pmd_atlantic.c
 create mode 100644 drivers/net/atlantic/

[dpdk-dev] [PATCH 08/21] net/atlantic: rte device start, stop, initial configuration

2018-09-07 Thread Igor Russkikh
Start, stop and reset are all done via hw_atl layer.
Link interrupt configuration is also done here.

Signed-off-by: Igor Russkikh 
---
 drivers/net/atlantic/atl_ethdev.c | 253 ++
 drivers/net/atlantic/atl_ethdev.h |   2 +
 2 files changed, 255 insertions(+)

diff --git a/drivers/net/atlantic/atl_ethdev.c 
b/drivers/net/atlantic/atl_ethdev.c
index 31ff50f18..78438174e 100644
--- a/drivers/net/atlantic/atl_ethdev.c
+++ b/drivers/net/atlantic/atl_ethdev.c
@@ -39,6 +39,9 @@
 #include "atl_common.h"
 #include "atl_hw_regs.h"
 #include "atl_logs.h"
+#include "hw_atl/hw_atl_llh.h"
+#include "hw_atl/hw_atl_b0.h"
+#include "hw_atl/hw_atl_b0_internal.h"
 
 static int eth_atl_dev_init(struct rte_eth_dev *eth_dev);
 static int eth_atl_dev_uninit(struct rte_eth_dev *eth_dev);
@@ -126,6 +129,26 @@ static const struct eth_dev_ops atl_eth_dev_ops = {
.dev_reset= atl_dev_reset,
 };
 
+static inline int32_t
+atl_reset_hw(struct aq_hw_s *hw)
+{
+   return hw_atl_b0_hw_reset(hw);
+}
+
+static inline void
+atl_enable_intr(struct rte_eth_dev *dev)
+{
+   struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+   hw_atl_itr_irq_msk_setlsw_set(hw, 0x);
+}
+
+static void
+atl_disable_intr(struct aq_hw_s *hw)
+{
+   PMD_INIT_FUNC_TRACE();
+   hw_atl_itr_irq_msk_clearlsw_set(hw, 0x);
+}
 
 static int
 atl_get_bus_info(struct aq_hw_s *hw)
@@ -136,6 +159,16 @@ atl_get_bus_info(struct aq_hw_s *hw)
return 0;
 }
 
+static void
+atl_print_adapter_info(struct aq_hw_s *hw __rte_unused)
+{
+   PMD_INIT_LOG(DEBUG, "FW version: %u.%u.%u",
+   hw->fw_ver_actual >> 24,
+   (hw->fw_ver_actual >> 16) & 0xFF,
+   hw->fw_ver_actual & 0x);
+   PMD_INIT_LOG(DEBUG, "Driver version: %s", ATL_PMD_DRIVER_VERSION);
+}
+
 static int
 eth_atl_dev_init(struct rte_eth_dev *eth_dev)
 {
@@ -157,6 +190,60 @@ eth_atl_dev_init(struct rte_eth_dev *eth_dev)
return 0;
}
 
+   rte_eth_copy_pci_info(eth_dev, pci_dev);
+
+   /* Vendor and Device ID need to be set before init of shared code */
+   hw->device_id = pci_dev->id.device_id;
+   hw->vendor_id = pci_dev->id.vendor_id;
+   hw->mmio = (void *)pci_dev->mem_resource[0].addr;
+   hw->allow_unsupported_sfp = 1;
+
+   /* Hardware configuration - hardcode */
+   adapter->hw_cfg.is_lro = false;
+   adapter->hw_cfg.is_rss = false;
+   adapter->hw_cfg.num_rss_queues = HW_ATL_B0_RSS_MAX;
+   adapter->hw_cfg.wol = false;
+   adapter->hw_cfg.link_speed_msk = AQ_NIC_RATE_10G|
+ AQ_NIC_RATE_5G|
+ AQ_NIC_RATE_2G5|
+ AQ_NIC_RATE_1G|
+ AQ_NIC_RATE_100M;
+
+   adapter->hw_cfg.flow_control = (AQ_NIC_FC_RX | AQ_NIC_FC_TX);
+   adapter->hw_cfg.aq_rss.indirection_table_size = 
HW_ATL_B0_RSS_REDIRECTION_MAX;
+
+hw->aq_nic_cfg = &adapter->hw_cfg;
+
+   /* pick up the PCI bus settings for reporting later */
+   atl_get_bus_info(hw);
+
+   /* disable interrupt */
+   atl_disable_intr(hw);
+
+   /* Allocate memory for storing MAC addresses */
+   eth_dev->data->mac_addrs = rte_zmalloc("atlantic", ETHER_ADDR_LEN, 0);
+   if (eth_dev->data->mac_addrs == NULL) {
+   PMD_INIT_LOG(ERR, "MAC Malloc failed");
+   return -ENOMEM;
+   }
+
+   err = hw_atl_utils_initfw(hw, &hw->aq_fw_ops); 
+   if (err)
+   return err;
+
+   /* Copy the permanent MAC address */
+   if (hw->aq_fw_ops->get_mac_permanent(hw, 
(u8*)ð_dev->data->mac_addrs[0]) != 0)
+   return -EINVAL;
+
+   rte_intr_callback_register(intr_handle,
+  atl_dev_interrupt_handler, eth_dev);
+
+   /* enable uio/vfio intr/eventfd mapping */
+   rte_intr_enable(intr_handle);
+
+   /* enable support intr */
+   atl_enable_intr(eth_dev);
+
return err;
 }
 
@@ -172,10 +259,30 @@ eth_atl_dev_uninit(struct rte_eth_dev *eth_dev)
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
return -EPERM;
 
+   hw = ATL_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+
+   if (hw->adapter_stopped == 0)
+   atl_dev_close(eth_dev);
+
eth_dev->dev_ops = NULL;
eth_dev->rx_pkt_burst = NULL;
eth_dev->tx_pkt_burst = NULL;
 
+   /* disable uio intr before callback unregister */
+   rte_intr_disable(intr_handle);
+   rte_intr_callback_unregister(intr_handle,
+atl_dev_interrupt_handler, eth_dev);
+
+   rte_free(eth_dev->data->mac_addrs);
+   eth_dev->data->mac_addrs = NULL;
+
+   rte_free(eth_dev->data->hash_mac_addrs);
+   eth_dev->data->hash_mac_addrs = NULL;
+
+#ifdef RTE_LIBRTE_SECURITY
+   rte_free(eth_dev->security_ctx);
+#endif
+
return 0;
 }
 
@@ -198,6 +305,11

[dpdk-dev] [PATCH 07/21] net/atlantic: hardware register access routines

2018-09-07 Thread Igor Russkikh
Signed-off-by: Igor Russkikh 
---
 drivers/net/atlantic/atl_hw_regs.c | 58 +
 drivers/net/atlantic/atl_hw_regs.h | 59 ++
 2 files changed, 117 insertions(+)
 create mode 100644 drivers/net/atlantic/atl_hw_regs.c
 create mode 100644 drivers/net/atlantic/atl_hw_regs.h

diff --git a/drivers/net/atlantic/atl_hw_regs.c 
b/drivers/net/atlantic/atl_hw_regs.c
new file mode 100644
index 0..7301d08e7
--- /dev/null
+++ b/drivers/net/atlantic/atl_hw_regs.c
@@ -0,0 +1,58 @@
+/*
+ * aQuantia Corporation Network Driver
+ * Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ */
+
+/* File aq_hw_utils.c: Definitions of helper functions used across
+ * hardware layer.
+ */
+
+#include "atl_hw_regs.h"
+
+#include 
+#include 
+
+void aq_hw_write_reg_bit(struct aq_hw_s *aq_hw, u32 addr, u32 msk,
+u32 shift, u32 val)
+{
+   if (msk ^ ~0) {
+   u32 reg_old, reg_new;
+
+   reg_old = aq_hw_read_reg(aq_hw, addr);
+   reg_new = (reg_old & (~msk)) | (val << shift);
+
+   if (reg_old != reg_new)
+   aq_hw_write_reg(aq_hw, addr, reg_new);
+   } else {
+   aq_hw_write_reg(aq_hw, addr, val);
+   }
+}
+
+u32 aq_hw_read_reg_bit(struct aq_hw_s *aq_hw, u32 addr, u32 msk, u32 shift)
+{
+   return ((aq_hw_read_reg(aq_hw, addr) & msk) >> shift);
+}
+
+u32 aq_hw_read_reg(struct aq_hw_s *hw, u32 reg)
+{
+   return rte_le_to_cpu_32(rte_read32((u8*)hw->mmio + reg));
+}
+
+void aq_hw_write_reg(struct aq_hw_s *hw, u32 reg, u32 value)
+{
+   rte_write32((rte_cpu_to_le_32(value)), (u8*)hw->mmio + reg);
+}
+
+int aq_hw_err_from_flags(struct aq_hw_s *hw)
+{
+   int err = 0;
+
+   if (aq_hw_read_reg(hw, 0x10U) == ~0U)
+   return -ENXIO;
+
+   return err;
+}
diff --git a/drivers/net/atlantic/atl_hw_regs.h 
b/drivers/net/atlantic/atl_hw_regs.h
new file mode 100644
index 0..ca5a80ed2
--- /dev/null
+++ b/drivers/net/atlantic/atl_hw_regs.h
@@ -0,0 +1,59 @@
+/*
+ * aQuantia Corporation Network Driver
+ * Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ */
+
+/* File aq_hw_utils.h: Declaration of helper functions used across hardware
+ * layer.
+ */
+
+#ifndef AQ_HW_UTILS_H
+#define AQ_HW_UTILS_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "atl_common.h"
+#include "atl_types.h"
+
+
+#ifndef HIDWORD
+#define LODWORD(_qw)((u32)(_qw))
+#define HIDWORD(_qw)((u32)(((_qw) >> 32) & 0x))
+#endif
+
+#define AQ_HW_SLEEP(_US_) rte_delay_ms(_US_)
+
+#define mdelay rte_delay_ms
+#define udelay rte_delay_us
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
+#define BIT(x) (1UL << x)
+
+#define AQ_HW_WAIT_FOR(_B_, _US_, _N_) \
+do { \
+   unsigned int AQ_HW_WAIT_FOR_i; \
+   for (AQ_HW_WAIT_FOR_i = _N_; (!(_B_)) && (AQ_HW_WAIT_FOR_i);\
+   --AQ_HW_WAIT_FOR_i) {\
+   udelay(_US_); \
+   } \
+   if (!AQ_HW_WAIT_FOR_i) {\
+   err = -ETIME; \
+   } \
+} while (0)
+
+#define ATL_WRITE_FLUSH(aq_hw) { (void)aq_hw_read_reg(aq_hw, 0x10); }
+
+void aq_hw_write_reg_bit(struct aq_hw_s *aq_hw, u32 addr, u32 msk,
+u32 shift, u32 val);
+u32 aq_hw_read_reg_bit(struct aq_hw_s *aq_hw, u32 addr, u32 msk, u32 shift);
+u32 aq_hw_read_reg(struct aq_hw_s *hw, u32 reg);
+void aq_hw_write_reg(struct aq_hw_s *hw, u32 reg, u32 value);
+int aq_hw_err_from_flags(struct aq_hw_s *hw);
+
+#endif /* AQ_HW_UTILS_H */
-- 
2.13.3.windows.1



[dpdk-dev] [PATCH 09/21] net/atlantic: link status and interrupt management

2018-09-07 Thread Igor Russkikh
From: Pavel Belous 

Implement link interrupt, link info, link polling

Signed-off-by: Igor Russkikh 
---
 drivers/net/atlantic/atl_ethdev.c | 255 ++
 drivers/net/atlantic/atl_ethdev.h |  10 ++
 2 files changed, 265 insertions(+)

diff --git a/drivers/net/atlantic/atl_ethdev.c 
b/drivers/net/atlantic/atl_ethdev.c
index 78438174e..6dda8280a 100644
--- a/drivers/net/atlantic/atl_ethdev.c
+++ b/drivers/net/atlantic/atl_ethdev.c
@@ -49,8 +49,11 @@ static int eth_atl_dev_uninit(struct rte_eth_dev *eth_dev);
 static int  atl_dev_configure(struct rte_eth_dev *dev);
 static int  atl_dev_start(struct rte_eth_dev *dev);
 static void atl_dev_stop(struct rte_eth_dev *dev);
+static int  atl_dev_set_link_up(struct rte_eth_dev *dev);
+static int  atl_dev_set_link_down(struct rte_eth_dev *dev);
 static void atl_dev_close(struct rte_eth_dev *dev);
 static int  atl_dev_reset(struct rte_eth_dev *dev);
+static int  atl_dev_link_update(struct rte_eth_dev *dev, int wait);
 
 static int atl_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
 uint16_t queue_id,
@@ -63,6 +66,15 @@ static void atl_dev_info_get(struct rte_eth_dev *dev,
 
 static const uint32_t *atl_dev_supported_ptypes_get(struct rte_eth_dev *dev);
 
+/* Interrupts */
+static int atl_dev_rxq_interrupt_setup(struct rte_eth_dev *dev);
+static int atl_dev_lsc_interrupt_setup(struct rte_eth_dev *dev, uint8_t on);
+static int atl_dev_interrupt_get_status(struct rte_eth_dev *dev);
+static int atl_dev_interrupt_action(struct rte_eth_dev *dev,
+   struct rte_intr_handle *handle);
+static void atl_dev_interrupt_handler(void *param);
+
+
 static int eth_atl_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
struct rte_pci_device *pci_dev);
 static int eth_atl_pci_remove(struct rte_pci_device *pci_dev);
@@ -125,10 +137,66 @@ static const struct eth_dev_ops atl_eth_dev_ops = {
.dev_configure= atl_dev_configure,
.dev_start= atl_dev_start,
.dev_stop = atl_dev_stop,
+   .dev_set_link_up  = atl_dev_set_link_up,
+   .dev_set_link_down= atl_dev_set_link_down,
.dev_close= atl_dev_close,
.dev_reset= atl_dev_reset,
+   /* Link */
+   .link_update  = atl_dev_link_update,
 };
 
+/**
+ * Atomically reads the link status information from global
+ * structure rte_eth_dev.
+ *
+ * @param dev
+ *   - Pointer to the structure rte_eth_dev to read from.
+ *   - Pointer to the buffer to be saved with the link status.
+ *
+ * @return
+ *   - On success, zero.
+ *   - On failure, negative value.
+ */
+static inline int
+rte_atl_dev_atomic_read_link_status(struct rte_eth_dev *dev,
+   struct rte_eth_link *link)
+{
+   struct rte_eth_link *dst = link;
+   struct rte_eth_link *src = &(dev->data->dev_link);
+
+   if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
+   *(uint64_t *)src) == 0)
+   return -1;
+
+   return 0;
+}
+
+/**
+ * Atomically writes the link status information into global
+ * structure rte_eth_dev.
+ *
+ * @param dev
+ *   - Pointer to the structure rte_eth_dev to read from.
+ *   - Pointer to the buffer to be saved with the link status.
+ *
+ * @return
+ *   - On success, zero.
+ *   - On failure, negative value.
+ */
+static inline int
+rte_atl_dev_atomic_write_link_status(struct rte_eth_dev *dev,
+   struct rte_eth_link *link)
+{
+   struct rte_eth_link *dst = &(dev->data->dev_link);
+   struct rte_eth_link *src = link;
+
+   if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
+   *(uint64_t *)src) == 0)
+   return -1;
+
+   return 0;
+}
+
 static inline int32_t
 atl_reset_hw(struct aq_hw_s *hw)
 {
@@ -383,6 +451,38 @@ atl_dev_start(struct rte_eth_dev *dev)
}
}
 
+
+   err = hw->aq_fw_ops->update_link_status(hw);
+
+   if (err) {
+   goto error;
+   }
+
+   dev->data->dev_link.link_status = hw->aq_link_status.mbps != 0;
+
+   link_speeds = &dev->data->dev_conf.link_speeds;
+
+   speed = 0x0;
+
+   if (*link_speeds == ETH_LINK_SPEED_AUTONEG) {
+   speed = hw->aq_nic_cfg->link_speed_msk;
+   } else {
+   if (*link_speeds & ETH_LINK_SPEED_10G)
+   speed |= AQ_NIC_RATE_10G;
+   if (*link_speeds & ETH_LINK_SPEED_5G)
+   speed |= AQ_NIC_RATE_5G;
+   if (*link_speeds & ETH_LINK_SPEED_1G)
+   speed |= AQ_NIC_RATE_1G;
+   if (*link_speeds & ETH_LINK_SPEED_2_5G)
+   speed |=  AQ_NIC_RATE_2G5;
+   if (*link_speeds & ETH_LINK_SPEED_100M)
+   speed |= AQ_NIC_RATE_100M;
+   }
+
+   err = hw->aq_fw_ops->

[dpdk-dev] [PATCH 10/21] net/atlantic: add hw adapter structures and defines

2018-09-07 Thread Igor Russkikh
From: Pavel Belous 

These declare statistic structures, hw internal structures and variables.

Signed-off-by: Igor Russkikh 
---
 drivers/net/atlantic/atl_ethdev.h |   9 ++
 drivers/net/atlantic/atl_types.h  | 202 +-
 2 files changed, 210 insertions(+), 1 deletion(-)

diff --git a/drivers/net/atlantic/atl_ethdev.h 
b/drivers/net/atlantic/atl_ethdev.h
index 5b9fc63c6..ce4bc9544 100644
--- a/drivers/net/atlantic/atl_ethdev.h
+++ b/drivers/net/atlantic/atl_ethdev.h
@@ -16,12 +16,18 @@
 #define ATL_FLAG_NEED_LINK_UPDATE (uint32_t)(1 << 0)
 #define ATL_FLAG_NEED_LINK_CONFIG (uint32_t)(4 << 0)
 
+struct atl_interrupt {
+   uint32_t flags;
+   uint32_t mask;
+};
+
 /*
  * Structure to store private data for each driver instance (for each port).
  */
 struct atl_adapter {
struct aq_hw_s hw;
struct aq_hw_cfg_s hw_cfg;
+   struct atl_sw_statssw_stats;
struct atl_interrupt   intr;
 };
 
@@ -31,6 +37,9 @@ struct atl_adapter {
 #define ATL_DEV_PRIVATE_TO_HW(adapter) \
(&((struct atl_adapter *)adapter)->hw)
 
+#define ATL_DEV_PRIVATE_TO_STATS(adapter) \
+   (&((struct atl_adapter *)adapter)->sw_stats)
+
 #define ATL_DEV_PRIVATE_TO_INTR(adapter) \
(&((struct atl_adapter *)adapter)->intr)
 
diff --git a/drivers/net/atlantic/atl_types.h b/drivers/net/atlantic/atl_types.h
index f1558b0a5..60cbb6cda 100644
--- a/drivers/net/atlantic/atl_types.h
+++ b/drivers/net/atlantic/atl_types.h
@@ -29,6 +29,206 @@ typedef int bool;
 #define min(a,b)   RTE_MIN(a,b)
 #define max(a,b)   RTE_MAX(a,b)
 
-#define wmb()  rte_wmb()
+#define wmb() rte_wmb()
+
+#include "hw_atl/hw_atl_b0_internal.h"
+#include "hw_atl/hw_atl_utils.h"
+
+struct aq_hw_link_status_s {
+   unsigned int mbps;
+};
+
+struct aq_stats_s {
+   u64 uprc;
+   u64 mprc;
+   u64 bprc;
+   u64 erpt;
+   u64 uptc;
+   u64 mptc;
+   u64 bptc;
+   u64 erpr;
+   u64 mbtc;
+   u64 bbtc;
+   u64 mbrc;
+   u64 bbrc;
+   u64 ubrc;
+   u64 ubtc;
+   u64 dpc;
+   u64 dma_pkt_rc;
+   u64 dma_pkt_tc;
+   u64 dma_oct_rc;
+   u64 dma_oct_tc;
+};
+
+enum atl_bus_speed {
+atl_bus_speed_unknown = 0,
+atl_bus_speed_2500,
+atl_bus_speed_5000,
+atl_bus_speed_reserved
+};
+
+enum atl_bus_width {
+atl_bus_width_unknown = 0,
+atl_bus_width_pcie_x1,
+atl_bus_width_pcie_x2,
+atl_bus_width_pcie_x4 = 4,
+atl_bus_width_pcie_x8 = 8,
+atl_bus_width_reserved
+};
+
+struct atl_bus_info {
+enum atl_bus_speed speed;
+enum atl_bus_width width;
+
+u16 func;
+u16 pci_cmd_word;
+};
+
+struct aq_rss_parameters {
+   u16 base_cpu_number;
+   u16 indirection_table_size;
+   u16 hash_secret_key_size;
+   u32 hash_secret_key[HW_ATL_B0_RSS_HASHKEY_BITS/8];
+   u8 indirection_table[HW_ATL_B0_RSS_REDIRECTION_MAX];
+};
+
+struct aq_hw_cfg_s {
+   bool is_lro;
+   bool is_rss;
+   unsigned int num_rss_queues;
+   int wol;
+
+   int link_speed_msk;
+   int irq_type;
+   int irq_mask;
+   unsigned int vecs;
+
+   bool vlan_strip;
+   uint32_t vlan_filter[HW_ATL_B0_MAX_VLAN_IDS];
+   uint32_t flow_control;
+
+   struct aq_rss_parameters aq_rss;
+};
+
+struct aq_hw_s {
+   void *back;
+
+   struct atl_bus_info bus;
+
+   const u32 *mvals;
+   u16 device_id;
+   u16 vendor_id;
+   u16 subsystem_device_id;
+   u16 subsystem_vendor_id;
+   u8 revision_id;
+   bool adapter_stopped;
+   int api_version;
+   bool force_full_reset;
+   bool allow_unsupported_sfp;
+   bool wol_enabled;
+   bool need_crosstalk_fix;
+
+   u8 rbl_enabled:1;
+   struct aq_hw_cfg_s *aq_nic_cfg;
+   const struct aq_fw_ops *aq_fw_ops;
+   void *mmio;
+
+   struct aq_hw_link_status_s aq_link_status;
+   bool is_autoneg;
+
+   struct hw_aq_atl_utils_mbox mbox;
+   struct hw_atl_stats_s last_stats;
+   struct aq_stats_s curr_stats;
+
+   u64 speed;
+   u32 itr_tx;
+   u32 itr_rx;
+   unsigned int chip_features;
+   u32 fw_ver_actual;
+   u32 mbox_addr;
+   u32 rpc_addr;
+   u32 rpc_tid;
+   struct hw_aq_atl_utils_fw_rpc rpc;
+};
+
+struct aq_fw_ops {
+   int (*init)(struct aq_hw_s *self);
+
+   int (*deinit)(struct aq_hw_s *self);
+
+   int (*reset)(struct aq_hw_s *self);
+
+   int (*get_mac_permanent)(struct aq_hw_s *self, u8 *mac);
+
+   int (*set_link_speed)(struct aq_hw_s *self, u32 speed);
+
+   int (*set_state)(struct aq_hw_s *self,
+   enum hal_atl_utils_fw_state_e state);
+
+   int (*update_link_status)(struct aq_hw_s *self);
+
+   int (*update_stats)(struct aq_hw_s *self);
+
+   int (*set_power)(struct aq_hw_s *self, unsigned int power_state,
+   u8 *ma

[dpdk-dev] [PATCH 11/21] net/atlantic: RSS and RETA manipulation API

2018-09-07 Thread Igor Russkikh
Signed-off-by: Igor Russkikh 
---
 drivers/net/atlantic/atl_ethdev.c | 93 +++
 1 file changed, 93 insertions(+)

diff --git a/drivers/net/atlantic/atl_ethdev.c 
b/drivers/net/atlantic/atl_ethdev.c
index 6dda8280a..ec1c22886 100644
--- a/drivers/net/atlantic/atl_ethdev.c
+++ b/drivers/net/atlantic/atl_ethdev.c
@@ -75,6 +75,19 @@ static int atl_dev_interrupt_action(struct rte_eth_dev *dev,
 static void atl_dev_interrupt_handler(void *param);
 
 
+/* RSS */
+static int atl_reta_update(struct rte_eth_dev *dev,
+struct rte_eth_rss_reta_entry64 *reta_conf,
+uint16_t reta_size);
+static int atl_reta_query(struct rte_eth_dev *dev,
+   struct rte_eth_rss_reta_entry64 *reta_conf,
+   uint16_t reta_size);
+static int atl_rss_hash_update(struct rte_eth_dev *dev,
+struct rte_eth_rss_conf *rss_conf);
+static int atl_rss_hash_conf_get(struct rte_eth_dev *dev,
+  struct rte_eth_rss_conf *rss_conf);
+
+
 static int eth_atl_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
struct rte_pci_device *pci_dev);
 static int eth_atl_pci_remove(struct rte_pci_device *pci_dev);
@@ -143,6 +156,12 @@ static const struct eth_dev_ops atl_eth_dev_ops = {
.dev_reset= atl_dev_reset,
/* Link */
.link_update  = atl_dev_link_update,
+
+   .reta_update  = atl_reta_update,
+   .reta_query   = atl_reta_query,
+   .rss_hash_update  = atl_rss_hash_update,
+   .rss_hash_conf_get= atl_rss_hash_conf_get,
+
 };
 
 /**
@@ -796,6 +815,80 @@ atl_dev_interrupt_handler(void *param)
atl_dev_interrupt_action(dev, dev->intr_handle);
 }
 
+
+static int
+atl_reta_update(struct rte_eth_dev *dev,
+  struct rte_eth_rss_reta_entry64 *reta_conf,
+  uint16_t reta_size)
+{
+   int i;
+   struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   struct aq_hw_cfg_s *cfg = 
ATL_DEV_PRIVATE_TO_CFG(dev->data->dev_private);
+
+   for (i = 0; i < reta_size && i < cfg->aq_rss.indirection_table_size; 
i++)
+   cfg->aq_rss.indirection_table[i] = min(reta_conf->reta[i], 
dev->data->nb_rx_queues - 1);
+
+   hw_atl_b0_hw_rss_set(hw, &cfg->aq_rss);
+   return 0;
+}
+
+static int
+atl_reta_query(struct rte_eth_dev *dev,
+   struct rte_eth_rss_reta_entry64 *reta_conf,
+   uint16_t reta_size)
+{
+   int i;
+   struct aq_hw_cfg_s *cfg = 
ATL_DEV_PRIVATE_TO_CFG(dev->data->dev_private);
+
+   for (i = 0; i < reta_size && i < cfg->aq_rss.indirection_table_size; 
i++)
+   reta_conf->reta[i] = cfg->aq_rss.indirection_table[i];
+   reta_conf->mask = ~0U;
+   return 0;
+}
+
+static int
+atl_rss_hash_update(struct rte_eth_dev *dev,
+struct rte_eth_rss_conf *rss_conf)
+{
+   struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   struct aq_hw_cfg_s *cfg = 
ATL_DEV_PRIVATE_TO_CFG(dev->data->dev_private);
+   static u8 def_rss_key[40] = {
+   0x1e, 0xad, 0x71, 0x87, 0x65, 0xfc, 0x26, 0x7d,
+   0x0d, 0x45, 0x67, 0x74, 0xcd, 0x06, 0x1a, 0x18,
+   0xb6, 0xc1, 0xf0, 0xc7, 0xbb, 0x18, 0xbe, 0xf8,
+   0x19, 0x13, 0x4b, 0xa9, 0xd0, 0x3e, 0xfe, 0x70,
+   0x25, 0x03, 0xab, 0x50, 0x6a, 0x8b, 0x82, 0x0c
+   };
+
+   cfg->is_rss = !!rss_conf->rss_hf;
+   if (rss_conf->rss_key) {
+   memcpy(cfg->aq_rss.hash_secret_key, rss_conf->rss_key, 
rss_conf->rss_key_len);
+   cfg->aq_rss.hash_secret_key_size = rss_conf->rss_key_len;
+   }else{
+   memcpy(cfg->aq_rss.hash_secret_key, def_rss_key, 
sizeof(def_rss_key));
+   cfg->aq_rss.hash_secret_key_size = sizeof(def_rss_key);
+   }
+
+   hw_atl_b0_hw_rss_set(hw, &cfg->aq_rss);
+   hw_atl_b0_hw_rss_hash_set(hw, &cfg->aq_rss);
+   return 0;
+}
+
+static int
+atl_rss_hash_conf_get(struct rte_eth_dev *dev,
+struct rte_eth_rss_conf *rss_conf)
+{
+   struct aq_hw_cfg_s *cfg = 
ATL_DEV_PRIVATE_TO_CFG(dev->data->dev_private);
+
+   rss_conf->rss_hf = cfg->is_rss ? ATL_RSS_OFFLOAD_ALL : 0;
+   if (rss_conf->rss_key) {
+   rss_conf->rss_key_len = cfg->aq_rss.hash_secret_key_size;
+   memcpy(rss_conf->rss_key, cfg->aq_rss.hash_secret_key, 
rss_conf->rss_key_len);
+   }
+
+   return 0;
+}
+
 RTE_PMD_REGISTER_PCI(net_atlantic, rte_atl_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_atlantic, pci_id_atl_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_atlantic, "* igb_uio | uio_pci_generic");
-- 
2.13.3.windows.1



[dpdk-dev] [PATCH 12/21] net/atlantic: flow control configuration

2018-09-07 Thread Igor Russkikh
From: Pavel Belous 

Signed-off-by: Igor Russkikh 
---
 drivers/net/atlantic/atl_ethdev.c | 50 +++
 1 file changed, 50 insertions(+)

diff --git a/drivers/net/atlantic/atl_ethdev.c 
b/drivers/net/atlantic/atl_ethdev.c
index ec1c22886..a95dc87fd 100644
--- a/drivers/net/atlantic/atl_ethdev.c
+++ b/drivers/net/atlantic/atl_ethdev.c
@@ -66,6 +66,11 @@ static void atl_dev_info_get(struct rte_eth_dev *dev,
 
 static const uint32_t *atl_dev_supported_ptypes_get(struct rte_eth_dev *dev);
 
+/* Flow control */
+static int atl_flow_ctrl_get(struct rte_eth_dev *dev,
+  struct rte_eth_fc_conf *fc_conf);
+static int atl_flow_ctrl_set(struct rte_eth_dev *dev,
+  struct rte_eth_fc_conf *fc_conf);
 /* Interrupts */
 static int atl_dev_rxq_interrupt_setup(struct rte_eth_dev *dev);
 static int atl_dev_lsc_interrupt_setup(struct rte_eth_dev *dev, uint8_t on);
@@ -157,6 +162,10 @@ static const struct eth_dev_ops atl_eth_dev_ops = {
/* Link */
.link_update  = atl_dev_link_update,
 
+
+   /* Flow Control */
+   .flow_ctrl_get= atl_flow_ctrl_get,
+   .flow_ctrl_set= atl_flow_ctrl_set,
.reta_update  = atl_reta_update,
.reta_query   = atl_reta_query,
.rss_hash_update  = atl_rss_hash_update,
@@ -815,6 +824,47 @@ atl_dev_interrupt_handler(void *param)
atl_dev_interrupt_action(dev, dev->intr_handle);
 }
 
+static int
+atl_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
+{
+   struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+   if (hw->aq_nic_cfg->flow_control == AQ_NIC_FC_OFF)
+   fc_conf->mode = RTE_FC_NONE;
+   else if (hw->aq_nic_cfg->flow_control & (AQ_NIC_FC_RX | AQ_NIC_FC_TX))
+   fc_conf->mode = RTE_FC_FULL;
+   else if (hw->aq_nic_cfg->flow_control & AQ_NIC_FC_RX)
+   fc_conf->mode = RTE_FC_RX_PAUSE;
+   else if (hw->aq_nic_cfg->flow_control & AQ_NIC_FC_RX)
+   fc_conf->mode = RTE_FC_TX_PAUSE;
+
+   return 0;
+}
+
+static int
+atl_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
+{
+   struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   uint32_t old_flow_control = hw->aq_nic_cfg->flow_control;
+
+
+   if (hw->aq_fw_ops->set_flow_control == NULL)
+   return -ENOTSUP;
+
+   if (fc_conf->mode == RTE_FC_NONE)
+   hw->aq_nic_cfg->flow_control = AQ_NIC_FC_OFF;
+   else if (fc_conf->mode == RTE_FC_RX_PAUSE)
+   hw->aq_nic_cfg->flow_control = AQ_NIC_FC_RX;
+   else if (fc_conf->mode == RTE_FC_TX_PAUSE)
+   hw->aq_nic_cfg->flow_control = AQ_NIC_FC_TX;
+   else if (fc_conf->mode == RTE_FC_FULL)
+   hw->aq_nic_cfg->flow_control = (AQ_NIC_FC_RX | AQ_NIC_FC_TX);
+
+   if (old_flow_control != hw->aq_nic_cfg->flow_control)
+   return hw->aq_fw_ops->set_flow_control(hw);
+
+   return 0;
+}
 
 static int
 atl_reta_update(struct rte_eth_dev *dev,
-- 
2.13.3.windows.1



[dpdk-dev] [PATCH 13/21] net/atlantic: MAC address manipulations

2018-09-07 Thread Igor Russkikh
From: Pavel Belous 

Signed-off-by: Igor Russkikh 
---
 drivers/net/atlantic/atl_ethdev.c | 101 ++
 1 file changed, 101 insertions(+)

diff --git a/drivers/net/atlantic/atl_ethdev.c 
b/drivers/net/atlantic/atl_ethdev.c
index a95dc87fd..24c3a0cf3 100644
--- a/drivers/net/atlantic/atl_ethdev.c
+++ b/drivers/net/atlantic/atl_ethdev.c
@@ -80,6 +80,18 @@ static int atl_dev_interrupt_action(struct rte_eth_dev *dev,
 static void atl_dev_interrupt_handler(void *param);
 
 
+static int atl_add_mac_addr(struct rte_eth_dev *dev, struct ether_addr 
*mac_addr,
+uint32_t index, uint32_t pool);
+static void atl_remove_mac_addr(struct rte_eth_dev *dev, uint32_t index);
+static int atl_set_default_mac_addr(struct rte_eth_dev *dev,
+  struct ether_addr *mac_addr);
+static bool is_device_supported(struct rte_eth_dev *dev,
+   struct rte_pci_driver *drv);
+
+static int atl_dev_set_mc_addr_list(struct rte_eth_dev *dev,
+   struct ether_addr *mc_addr_set,
+   uint32_t nb_mc_addr);
+
 /* RSS */
 static int atl_reta_update(struct rte_eth_dev *dev,
 struct rte_eth_rss_reta_entry64 *reta_conf,
@@ -166,6 +178,12 @@ static const struct eth_dev_ops atl_eth_dev_ops = {
/* Flow Control */
.flow_ctrl_get= atl_flow_ctrl_get,
.flow_ctrl_set= atl_flow_ctrl_set,
+
+   /* MAC */
+   .mac_addr_add = atl_add_mac_addr,
+   .mac_addr_remove  = atl_remove_mac_addr,
+   .mac_addr_set = atl_set_default_mac_addr,
+   .set_mc_addr_list = atl_dev_set_mc_addr_list,
.reta_update  = atl_reta_update,
.reta_query   = atl_reta_query,
.rss_hash_update  = atl_rss_hash_update,
@@ -867,6 +885,89 @@ atl_flow_ctrl_set(struct rte_eth_dev *dev, struct 
rte_eth_fc_conf *fc_conf)
 }
 
 static int
+atl_update_mac_addr(struct rte_eth_dev *dev, uint32_t index, u8 *mac_addr, 
bool enable)
+{
+   struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   unsigned int h = 0U;
+   unsigned int l = 0U;
+   int err;
+
+   if (mac_addr) {
+   h = (mac_addr[0] << 8) | (mac_addr[1]);
+   l = (mac_addr[2] << 24) | (mac_addr[3] << 16) | (mac_addr[4] << 
8) | mac_addr[5];
+   }
+
+   hw_atl_rpfl2_uc_flr_en_set(hw, 0U, index);
+   hw_atl_rpfl2unicast_dest_addresslsw_set(hw, l, index);
+   hw_atl_rpfl2unicast_dest_addressmsw_set(hw, h, index);
+
+   if (enable)
+   hw_atl_rpfl2_uc_flr_en_set(hw, 1U, index);
+
+   err = aq_hw_err_from_flags(hw);
+
+   return err;
+}
+
+static int
+atl_add_mac_addr(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
+   uint32_t index __rte_unused, uint32_t pool __rte_unused)
+{
+   if (is_zero_ether_addr(mac_addr)) {
+   PMD_DRV_LOG(ERR, "Invalid Ethernet Address");
+   return -EINVAL;
+   }
+
+   return atl_update_mac_addr(dev, index, (u8*)mac_addr, TRUE);
+}
+
+static void
+atl_remove_mac_addr(struct rte_eth_dev *dev, uint32_t index)
+{
+   atl_update_mac_addr(dev, index, NULL, FALSE);
+}
+
+static int
+atl_set_default_mac_addr(struct rte_eth_dev *dev, struct ether_addr *addr)
+{
+   atl_remove_mac_addr(dev, 0);
+   atl_add_mac_addr(dev, addr, 0, 0);
+   return 0;
+}
+
+
+static int
+atl_dev_set_mc_addr_list(struct rte_eth_dev *dev,
+ struct ether_addr *mc_addr_set,
+ uint32_t nb_mc_addr)
+{
+   struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   u32 i;
+
+   if (nb_mc_addr > AQ_HW_MULTICAST_ADDRESS_MAX - HW_ATL_B0_MAC_MIN)
+   return -EINVAL;
+
+   /* Update whole uc filters table */
+   for (i =0; i < AQ_HW_MULTICAST_ADDRESS_MAX - HW_ATL_B0_MAC_MIN; i++) {
+   u8 *mac_addr = NULL;
+   u32 l = 0, h = 0;
+
+   if (i < nb_mc_addr) {
+   mac_addr = mc_addr_set[i].addr_bytes;
+   l = (mac_addr[2] << 24) | (mac_addr[3] << 16) | 
(mac_addr[4] << 8) | mac_addr[5];
+   h = (mac_addr[0] << 8) | mac_addr[1];
+   }
+
+   hw_atl_rpfl2_uc_flr_en_set(hw, 0U, HW_ATL_B0_MAC_MIN + i);
+   hw_atl_rpfl2unicast_dest_addresslsw_set(hw, l, 
HW_ATL_B0_MAC_MIN + i);
+   hw_atl_rpfl2unicast_dest_addressmsw_set(hw, h, 
HW_ATL_B0_MAC_MIN + i);
+   hw_atl_rpfl2_uc_flr_en_set(hw, !!mac_addr, HW_ATL_B0_MAC_MIN + 
i);
+   }
+
+   return 0;
+}
+
+static int
 atl_reta_update(struct rte_eth_dev *dev,
   struct rte_eth_rss_reta_entry64 *reta_conf,
   uint16_t reta_size)
-- 
2.13.3.windows.1



[dpdk-dev] [PATCH 14/21] net/atlantic: eeprom and register manipulation routines

2018-09-07 Thread Igor Russkikh
From: Pavel Belous 

Signed-off-by: Igor Russkikh 
---
 drivers/net/atlantic/atl_ethdev.c | 77 +++
 1 file changed, 77 insertions(+)

diff --git a/drivers/net/atlantic/atl_ethdev.c 
b/drivers/net/atlantic/atl_ethdev.c
index 24c3a0cf3..fe1560923 100644
--- a/drivers/net/atlantic/atl_ethdev.c
+++ b/drivers/net/atlantic/atl_ethdev.c
@@ -66,6 +66,14 @@ static void atl_dev_info_get(struct rte_eth_dev *dev,
 
 static const uint32_t *atl_dev_supported_ptypes_get(struct rte_eth_dev *dev);
 
+/* EEPROM */
+static int atl_dev_get_eeprom_length(struct rte_eth_dev *dev);
+static int atl_dev_get_eeprom(struct rte_eth_dev *dev, struct 
rte_dev_eeprom_info *eeprom);
+static int atl_dev_set_eeprom(struct rte_eth_dev *dev, struct 
rte_dev_eeprom_info *eeprom);
+
+/* Regs */
+static int atl_dev_get_regs(struct rte_eth_dev *dev, struct rte_dev_reg_info 
*regs);
+
 /* Flow control */
 static int atl_flow_ctrl_get(struct rte_eth_dev *dev,
   struct rte_eth_fc_conf *fc_conf);
@@ -174,6 +182,12 @@ static const struct eth_dev_ops atl_eth_dev_ops = {
/* Link */
.link_update  = atl_dev_link_update,
 
+   .get_reg  = atl_dev_get_regs,
+
+   /* EEPROM */
+   .get_eeprom_length= atl_dev_get_eeprom_length,
+   .get_eeprom   = atl_dev_get_eeprom,
+   .set_eeprom   = atl_dev_set_eeprom,
 
/* Flow Control */
.flow_ctrl_get= atl_flow_ctrl_get,
@@ -842,6 +856,69 @@ atl_dev_interrupt_handler(void *param)
atl_dev_interrupt_action(dev, dev->intr_handle);
 }
 
+#define SFP_EEPROM_SIZE 0xff
+
+static int
+atl_dev_get_eeprom_length(struct rte_eth_dev *dev __rte_unused)
+{
+   return SFP_EEPROM_SIZE;
+}
+
+static int
+atl_dev_get_eeprom(struct rte_eth_dev *dev, struct rte_dev_eeprom_info *eeprom)
+{
+   struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+   if (hw->aq_fw_ops->get_eeprom == NULL)
+   return -ENOTSUP;
+
+   if (eeprom->length != SFP_EEPROM_SIZE || eeprom->data == NULL)
+   return -EINVAL;
+
+   return hw->aq_fw_ops->get_eeprom(hw, eeprom->data, eeprom->length);
+
+}
+
+static int
+atl_dev_set_eeprom(struct rte_eth_dev *dev, struct rte_dev_eeprom_info *eeprom)
+{
+   struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+   if (hw->aq_fw_ops->set_eeprom == NULL)
+   return -ENOTSUP;
+
+if (eeprom->length != SFP_EEPROM_SIZE || eeprom->data == NULL)
+return -EINVAL;
+
+   return hw->aq_fw_ops->set_eeprom(hw, eeprom->data, eeprom->length);
+}
+
+static int
+atl_dev_get_regs(struct rte_eth_dev *dev, struct rte_dev_reg_info *regs)
+{
+   struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   u32 mif_id;
+   int err;
+
+   if (regs->data == NULL) {
+   regs->length = hw_atl_utils_hw_get_reg_length();
+   regs->width = sizeof(u32);
+   return 0;
+   }
+
+   /* Only full register dump is supported */
+   if (regs->length && regs->length != hw_atl_utils_hw_get_reg_length())
+   return -ENOTSUP;
+
+   err = hw_atl_utils_hw_get_regs(hw, regs->data);
+
+   /* Device version */
+   mif_id = hw_atl_reg_glb_mif_id_get(hw);
+   regs->version = mif_id & 0xFFU;
+
+   return err;
+}
+
 static int
 atl_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
 {
-- 
2.13.3.windows.1



[dpdk-dev] [PATCH 17/21] net/atlantic: device statistics, xstats

2018-09-07 Thread Igor Russkikh
Signed-off-by: Igor Russkikh 
---
 drivers/net/atlantic/atl_ethdev.c | 131 ++
 1 file changed, 131 insertions(+)

diff --git a/drivers/net/atlantic/atl_ethdev.c 
b/drivers/net/atlantic/atl_ethdev.c
index b3ec7c492..c99d321c9 100644
--- a/drivers/net/atlantic/atl_ethdev.c
+++ b/drivers/net/atlantic/atl_ethdev.c
@@ -59,6 +59,19 @@ static void atl_dev_allmulticast_enable(struct rte_eth_dev 
*dev);
 static void atl_dev_allmulticast_disable(struct rte_eth_dev *dev);
 static int  atl_dev_link_update(struct rte_eth_dev *dev, int wait);
 
+static int atl_dev_xstats_get_names(struct rte_eth_dev *dev __rte_unused,
+   struct rte_eth_xstat_name *xstats_names,
+   unsigned int size);
+
+static int atl_dev_stats_get(struct rte_eth_dev *dev,
+   struct rte_eth_stats *stats);
+
+static int atl_dev_xstats_get(struct rte_eth_dev *dev,
+struct rte_eth_xstat *stats, unsigned int n);
+
+static void atl_dev_stats_reset(struct rte_eth_dev *dev);
+static void atl_dev_xstats_reset(struct rte_eth_dev *dev);
+
 static int atl_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
 uint16_t queue_id,
 uint8_t stat_idx,
@@ -180,6 +193,34 @@ static const struct rte_eth_desc_lim tx_desc_lim = {
.nb_mtu_seg_max = ATL_TX_MAX_SEG,
 };
 
+#define ATL_XSTATS_FIELD(name) { \
+   #name, \
+   offsetof(struct aq_stats_s, name) \
+}
+
+struct atl_xstats_tbl_s {
+   const char *name;
+   unsigned int offset;
+};
+
+static struct atl_xstats_tbl_s atl_xstats_tbl[] = {
+   ATL_XSTATS_FIELD(uprc),
+   ATL_XSTATS_FIELD(mprc),
+   ATL_XSTATS_FIELD(bprc),
+   ATL_XSTATS_FIELD(erpt),
+   ATL_XSTATS_FIELD(uptc),
+   ATL_XSTATS_FIELD(mptc),
+   ATL_XSTATS_FIELD(bptc),
+   ATL_XSTATS_FIELD(erpr),
+   ATL_XSTATS_FIELD(ubrc),
+   ATL_XSTATS_FIELD(ubtc),
+   ATL_XSTATS_FIELD(mbrc),
+   ATL_XSTATS_FIELD(mbtc),
+   ATL_XSTATS_FIELD(bbrc),
+   ATL_XSTATS_FIELD(bbtc),
+};
+
+
 static const struct eth_dev_ops atl_eth_dev_ops = {
.dev_configure= atl_dev_configure,
.dev_start= atl_dev_start,
@@ -200,6 +241,12 @@ static const struct eth_dev_ops atl_eth_dev_ops = {
 
.get_reg  = atl_dev_get_regs,
 
+   /* Stats */
+   .stats_get= atl_dev_stats_get,
+   .xstats_get   = atl_dev_xstats_get,
+   .xstats_get_names = atl_dev_xstats_get_names,
+   .stats_reset  = atl_dev_stats_reset,
+   .xstats_reset = atl_dev_xstats_reset,
 
/* LEDs */
.dev_led_on   = atl_dev_led_on,
@@ -384,6 +431,9 @@ eth_atl_dev_init(struct rte_eth_dev *eth_dev)
if (hw->aq_fw_ops->get_mac_permanent(hw, 
(u8*)ð_dev->data->mac_addrs[0]) != 0)
return -EINVAL;
 
+   /* Reset the hw statistics */
+   atl_dev_stats_reset(eth_dev);
+
rte_intr_callback_register(intr_handle,
   atl_dev_interrupt_handler, eth_dev);
 
@@ -693,6 +743,87 @@ atl_dev_reset(struct rte_eth_dev *dev)
 }
 
 
+static int
+atl_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
+{
+   struct atl_adapter *adapter = (struct atl_adapter 
*)dev->data->dev_private;
+   struct aq_hw_s *hw = &adapter->hw;
+   struct atl_sw_stats *swstats = &adapter->sw_stats;
+   unsigned i;
+
+   hw->aq_fw_ops->update_stats(hw);
+
+   /* Fill out the rte_eth_stats statistics structure */
+   stats->ipackets = hw->curr_stats.dma_pkt_rc;
+   stats->ibytes = hw->curr_stats.dma_oct_rc;
+   stats->imissed = hw->curr_stats.dpc;
+   stats->ierrors = hw->curr_stats.erpt;
+
+   stats->opackets = hw->curr_stats.dma_pkt_tc;
+   stats->obytes = hw->curr_stats.dma_oct_tc;
+   stats->oerrors = 0;
+
+   stats->rx_nombuf = swstats->rx_nombuf;
+
+   for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS; i++) {
+   stats->q_ipackets[i] = swstats->q_ipackets[i];
+   stats->q_opackets[i] = swstats->q_opackets[i];
+   stats->q_ibytes[i] = swstats->q_ibytes[i];
+   stats->q_obytes[i] = swstats->q_obytes[i];
+   stats->q_errors[i] = swstats->q_errors[i];
+   }
+   return 0;
+}
+
+static void
+atl_dev_stats_reset(struct rte_eth_dev *dev)
+{
+   struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+   hw->aq_fw_ops->update_stats(hw);
+
+   /* Reset software totals */
+   memset(&hw->curr_stats, 0, sizeof(hw->curr_stats));
+}
+
+static int
+atl_dev_xstats_get_names(struct rte_eth_dev *dev __rte_unused, struct 
rte_eth_xstat_name *xstats_names, unsigned int size)
+{
+   unsigned int i;
+
+   if (!xstats_names)
+   return RTE_DIM(atl_xstats_tbl);
+
+   for (i = 0; i <

[dpdk-dev] [PATCH 18/21] net/atlantic: VLAN filters and offloads

2018-09-07 Thread Igor Russkikh
From: Pavel Belous 

Signed-off-by: Igor Russkikh 
---
 drivers/net/atlantic/atl_ethdev.c | 156 +-
 1 file changed, 154 insertions(+), 2 deletions(-)

diff --git a/drivers/net/atlantic/atl_ethdev.c 
b/drivers/net/atlantic/atl_ethdev.c
index c99d321c9..80b7ac88e 100644
--- a/drivers/net/atlantic/atl_ethdev.c
+++ b/drivers/net/atlantic/atl_ethdev.c
@@ -84,6 +84,16 @@ static void atl_dev_info_get(struct rte_eth_dev *dev,
 static const uint32_t *atl_dev_supported_ptypes_get(struct rte_eth_dev *dev);
 
 
+/* VLAN stuff */
+static int atl_vlan_filter_set(struct rte_eth_dev *dev,
+   uint16_t vlan_id, int on);
+
+static int atl_vlan_offload_set(struct rte_eth_dev *dev, int mask);
+
+static void atl_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t 
queue_id, int on);
+
+static int atl_vlan_tpid_set(struct rte_eth_dev *dev, enum rte_vlan_type 
vlan_type, uint16_t tpid);
+
 /* LEDs */
 static int atl_dev_led_on(struct rte_eth_dev *dev);
 static int atl_dev_led_off(struct rte_eth_dev *dev);
@@ -247,6 +257,11 @@ static const struct eth_dev_ops atl_eth_dev_ops = {
.xstats_get_names = atl_dev_xstats_get_names,
.stats_reset  = atl_dev_stats_reset,
.xstats_reset = atl_dev_xstats_reset,
+   /* VLAN */
+   .vlan_filter_set  = atl_vlan_filter_set,
+   .vlan_offload_set = atl_vlan_offload_set,
+   .vlan_tpid_set= atl_vlan_tpid_set,
+   .vlan_strip_queue_set = atl_vlan_strip_queue_set,
 
/* LEDs */
.dev_led_on   = atl_dev_led_on,
@@ -525,7 +540,6 @@ atl_dev_start(struct rte_eth_dev *dev)
uint32_t intr_vector = 0;
uint32_t *link_speeds;
uint32_t speed = 0;
-   int vlan_mask = 0;
int status;
int err;
 
@@ -582,7 +596,6 @@ atl_dev_start(struct rte_eth_dev *dev)
}
}
 
-
err = hw->aq_fw_ops->update_link_status(hw);
 
if (err) {
@@ -1241,6 +1254,145 @@ atl_set_default_mac_addr(struct rte_eth_dev *dev, 
struct ether_addr *addr)
return 0;
 }
 
+static int
+atl_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
+{
+   struct aq_hw_cfg_s *cfg = 
ATL_DEV_PRIVATE_TO_CFG(dev->data->dev_private);
+   struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   int err = 0;
+   int i = 0;
+
+   PMD_INIT_FUNC_TRACE();
+
+   for (i = 0; i < HW_ATL_B0_MAX_VLAN_IDS; i++) {
+   if (cfg->vlan_filter[i] == vlan_id) {
+   if (!on) {
+   /* Disable VLAN filter. */
+   //hw_atl_rpf_vlan_flr_act_set(hw, 1U, i);
+   //hw_atl_rpf_vlan_id_flr_set(hw, 
vlan_filter[i], i);
+   hw_atl_rpf_vlan_flr_en_set(hw, 0U, i);
+
+   /* Clear VLAN filter entry */
+   cfg->vlan_filter[i] = 0;
+   }
+   break;
+   }
+   }
+
+   if (i == HW_ATL_B0_MAX_VLAN_IDS && !on)
+   goto exit; /* VLAN_ID was not found. So, nothing to delete. */
+
+   if (i != HW_ATL_B0_MAX_VLAN_IDS)
+   goto exit; /* VLAN_ID already exist, or already removed above. 
Nothing to do. */
+
+   /* Try to found free VLAN filter to add new VLAN_ID */
+   for (i = 0; i < HW_ATL_B0_MAX_VLAN_IDS; i++) {
+   if (cfg->vlan_filter[i] == 0)
+   break;
+   }
+
+   if (i == HW_ATL_B0_MAX_VLAN_IDS) {
+   /* We have no free VLAN filter to add new VLAN_ID*/
+   err = -ENOMEM;
+   goto exit;
+   }
+
+   cfg->vlan_filter[i] = vlan_id;
+   hw_atl_rpf_vlan_flr_act_set(hw, 1U, i);
+   hw_atl_rpf_vlan_id_flr_set(hw, vlan_id, i);
+   hw_atl_rpf_vlan_flr_en_set(hw, 1U, i);
+
+exit:
+   /* Enable VLAN promisc mode if vlan_filter empty  */
+for (i = 0; i < HW_ATL_B0_MAX_VLAN_IDS; i++) {
+if (cfg->vlan_filter[i] != 0)
+break;
+}
+
+   hw_atl_rpf_vlan_prom_mode_en_set(hw, i == HW_ATL_B0_MAX_VLAN_IDS);
+
+   return err;
+}
+
+static int
+atl_enable_vlan_filter(struct rte_eth_dev *dev, int en)
+{
+   struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   struct aq_hw_cfg_s *cfg = 
ATL_DEV_PRIVATE_TO_CFG(dev->data->dev_private);
+   int i;
+
+   PMD_INIT_FUNC_TRACE();
+
+   for (i = 0; i < HW_ATL_B0_MAX_VLAN_IDS; i++) {
+   if (cfg->vlan_filter[i]) {
+   hw_atl_rpf_vlan_flr_en_set(hw, en, i);
+   }
+   }
+   return 0;
+}
+
+static int 
+atl_vlan_offload_set(struct rte_eth_dev *dev, int mask)
+{
+   struct aq_hw_cfg_s *cfg = 
ATL_DEV_PRIVATE_TO_CFG(dev->data->dev_private);
+   struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   int ret = 0;
+   int i;
+
+   PMD_

[dpdk-dev] [PATCH 16/21] net/atlantic: promisc and allmulti configuration

2018-09-07 Thread Igor Russkikh
From: Pavel Belous 

Signed-off-by: Igor Russkikh 
---
 drivers/net/atlantic/atl_ethdev.c | 46 +++
 1 file changed, 46 insertions(+)

diff --git a/drivers/net/atlantic/atl_ethdev.c 
b/drivers/net/atlantic/atl_ethdev.c
index 00e686639..b3ec7c492 100644
--- a/drivers/net/atlantic/atl_ethdev.c
+++ b/drivers/net/atlantic/atl_ethdev.c
@@ -53,6 +53,10 @@ static int  atl_dev_set_link_up(struct rte_eth_dev *dev);
 static int  atl_dev_set_link_down(struct rte_eth_dev *dev);
 static void atl_dev_close(struct rte_eth_dev *dev);
 static int  atl_dev_reset(struct rte_eth_dev *dev);
+static void atl_dev_promiscuous_enable(struct rte_eth_dev *dev);
+static void atl_dev_promiscuous_disable(struct rte_eth_dev *dev);
+static void atl_dev_allmulticast_enable(struct rte_eth_dev *dev);
+static void atl_dev_allmulticast_disable(struct rte_eth_dev *dev);
 static int  atl_dev_link_update(struct rte_eth_dev *dev, int wait);
 
 static int atl_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
@@ -184,6 +188,13 @@ static const struct eth_dev_ops atl_eth_dev_ops = {
.dev_set_link_down= atl_dev_set_link_down,
.dev_close= atl_dev_close,
.dev_reset= atl_dev_reset,
+
+   /* PROMISC */
+   .promiscuous_enable   = atl_dev_promiscuous_enable,
+   .promiscuous_disable  = atl_dev_promiscuous_disable,
+   .allmulticast_enable  = atl_dev_allmulticast_enable,
+   .allmulticast_disable = atl_dev_allmulticast_disable,
+
/* Link */
.link_update  = atl_dev_link_update,
 
@@ -728,6 +739,41 @@ atl_dev_link_update(struct rte_eth_dev *dev, int wait 
__rte_unused)
return 0;
 }
 
+static void
+atl_dev_promiscuous_enable(struct rte_eth_dev *dev)
+{
+   struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+   hw_atl_rpfl2promiscuous_mode_en_set(hw, true);
+}
+
+static void
+atl_dev_promiscuous_disable(struct rte_eth_dev *dev)
+{
+   struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+   hw_atl_rpfl2promiscuous_mode_en_set(hw, false);
+}
+
+static void
+atl_dev_allmulticast_enable(struct rte_eth_dev *dev)
+{
+   struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+   hw_atl_rpfl2_accept_all_mc_packets_set(hw, true);
+}
+
+static void
+atl_dev_allmulticast_disable(struct rte_eth_dev *dev)
+{
+   struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+   if (dev->data->promiscuous == 1)
+   return; /* must remain in all_multicast mode */
+
+   hw_atl_rpfl2_accept_all_mc_packets_set(hw, false);
+}
+
 /**
  * It clears the interrupt causes and enables the interrupt.
  * It will be called once only during nic initialized.
-- 
2.13.3.windows.1



[dpdk-dev] [PATCH 15/21] net/atlantic: LED control DPDK and private APIs

2018-09-07 Thread Igor Russkikh
Signed-off-by: Igor Russkikh 
---
 drivers/net/atlantic/Makefile   |  4 +++
 drivers/net/atlantic/atl_ethdev.c   | 52 +
 drivers/net/atlantic/atl_ethdev.h   |  2 ++
 drivers/net/atlantic/meson.build|  3 ++
 drivers/net/atlantic/rte_pmd_atlantic.c | 19 
 drivers/net/atlantic/rte_pmd_atlantic.h | 44 
 6 files changed, 124 insertions(+)
 create mode 100644 drivers/net/atlantic/rte_pmd_atlantic.c
 create mode 100644 drivers/net/atlantic/rte_pmd_atlantic.h

diff --git a/drivers/net/atlantic/Makefile b/drivers/net/atlantic/Makefile
index d70ee4380..4b0e6f06c 100644
--- a/drivers/net/atlantic/Makefile
+++ b/drivers/net/atlantic/Makefile
@@ -55,5 +55,9 @@ VPATH += $(SRCDIR)/hw_atl
 # all source are stored in SRCS-y
 #
 SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += atl_ethdev.c
+SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += rte_pmd_atlantic.c
+
+# install this header file
+SYMLINK-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD)-include := rte_pmd_atlantic.h
 
 include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/drivers/net/atlantic/atl_ethdev.c 
b/drivers/net/atlantic/atl_ethdev.c
index fe1560923..00e686639 100644
--- a/drivers/net/atlantic/atl_ethdev.c
+++ b/drivers/net/atlantic/atl_ethdev.c
@@ -66,6 +66,11 @@ static void atl_dev_info_get(struct rte_eth_dev *dev,
 
 static const uint32_t *atl_dev_supported_ptypes_get(struct rte_eth_dev *dev);
 
+
+/* LEDs */
+static int atl_dev_led_on(struct rte_eth_dev *dev);
+static int atl_dev_led_off(struct rte_eth_dev *dev);
+
 /* EEPROM */
 static int atl_dev_get_eeprom_length(struct rte_eth_dev *dev);
 static int atl_dev_get_eeprom(struct rte_eth_dev *dev, struct 
rte_dev_eeprom_info *eeprom);
@@ -184,6 +189,11 @@ static const struct eth_dev_ops atl_eth_dev_ops = {
 
.get_reg  = atl_dev_get_regs,
 
+
+   /* LEDs */
+   .dev_led_on   = atl_dev_led_on,
+   .dev_led_off  = atl_dev_led_off,
+
/* EEPROM */
.get_eeprom_length= atl_dev_get_eeprom_length,
.get_eeprom   = atl_dev_get_eeprom,
@@ -856,6 +866,48 @@ atl_dev_interrupt_handler(void *param)
atl_dev_interrupt_action(dev, dev->intr_handle);
 }
 
+/**
+ * LED ON Enables software controllable LED blinking.
+ * LED status then is independent of link status or traffic
+ */
+static int
+atl_dev_led_on(struct rte_eth_dev *dev)
+{
+struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+   if (hw->aq_fw_ops->led_control == NULL)
+   return -ENOTSUP;
+
+   return hw->aq_fw_ops->led_control(hw, AQ_HW_LED_BLINK | 
(AQ_HW_LED_BLINK << 2) | (AQ_HW_LED_BLINK << 4));
+}
+
+/**
+ * LED OFF disables software controllable LED blinking
+ * LED is controlled by default logic and depends on link status and
+ * traffic activity
+ */
+static int
+atl_dev_led_off(struct rte_eth_dev *dev)
+{
+   struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+   if (hw->aq_fw_ops->led_control == NULL)
+   return -ENOTSUP;
+
+   return hw->aq_fw_ops->led_control(hw, AQ_HW_LED_DEFAULT);
+}
+
+int
+atl_dev_led_control(struct rte_eth_dev *dev, int control)
+{
+struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+   if (hw->aq_fw_ops->led_control == NULL)
+   return -ENOTSUP;
+
+   return hw->aq_fw_ops->led_control(hw, control);
+}
+
 #define SFP_EEPROM_SIZE 0xff
 
 static int
diff --git a/drivers/net/atlantic/atl_ethdev.h 
b/drivers/net/atlantic/atl_ethdev.h
index ce4bc9544..3ebef1f43 100644
--- a/drivers/net/atlantic/atl_ethdev.h
+++ b/drivers/net/atlantic/atl_ethdev.h
@@ -46,4 +46,6 @@ struct atl_adapter {
 #define ATL_DEV_PRIVATE_TO_CFG(adapter) \
(&((struct atl_adapter *)adapter)->hw_cfg)
 
+int
+atl_dev_led_control(struct rte_eth_dev *dev, int control);
 #endif /* _ATLANTIC_ETHDEV_H_ */
diff --git a/drivers/net/atlantic/meson.build b/drivers/net/atlantic/meson.build
index 187ca9808..19fa41cd3 100644
--- a/drivers/net/atlantic/meson.build
+++ b/drivers/net/atlantic/meson.build
@@ -5,6 +5,7 @@
 
 sources = files(
'atl_ethdev.c',
+   'rte_pmd_atlantic.c',
 )
 
 deps += ['hash', 'eal']
@@ -17,3 +18,5 @@ if get_option('buildtype') == 'debug'
 endif
 
 allow_experimental_apis = true
+
+install_headers('rte_pmd_atlantic.h')
diff --git a/drivers/net/atlantic/rte_pmd_atlantic.c 
b/drivers/net/atlantic/rte_pmd_atlantic.c
new file mode 100644
index 0..34f063ea4
--- /dev/null
+++ b/drivers/net/atlantic/rte_pmd_atlantic.c
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 Aquantia Corporation
+ */
+
+#include 
+
+#include "rte_pmd_atlantic.h"
+#include "atl_ethdev.h"
+
+int rte_pmd_atl_dev_led_control(int port, int control)
+{
+   struct rte_eth_dev *dev;
+   
+   RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+   dev = &rte_eth_devices[port];
+
+   return atl_dev_led_control(dev, control);
+}
diff --git a/

[dpdk-dev] [PATCH 19/21] net/atlantic: device MTU and statuses

2018-09-07 Thread Igor Russkikh
From: Pavel Belous 

Signed-off-by: Igor Russkikh 
---
 drivers/net/atlantic/atl_ethdev.c | 160 ++
 1 file changed, 160 insertions(+)

diff --git a/drivers/net/atlantic/atl_ethdev.c 
b/drivers/net/atlantic/atl_ethdev.c
index 80b7ac88e..44cea12ab 100644
--- a/drivers/net/atlantic/atl_ethdev.c
+++ b/drivers/net/atlantic/atl_ethdev.c
@@ -78,11 +78,14 @@ static int atl_dev_queue_stats_mapping_set(struct 
rte_eth_dev *eth_dev,
 uint8_t is_rx);
 
 
+static int atl_fw_version_get(struct rte_eth_dev *dev, char *fw_version, 
size_t fw_size);
 static void atl_dev_info_get(struct rte_eth_dev *dev,
   struct rte_eth_dev_info *dev_info);
 
 static const uint32_t *atl_dev_supported_ptypes_get(struct rte_eth_dev *dev);
 
+static int atl_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
+
 
 /* VLAN stuff */
 static int atl_vlan_filter_set(struct rte_eth_dev *dev,
@@ -111,6 +114,9 @@ static int atl_flow_ctrl_get(struct rte_eth_dev *dev,
   struct rte_eth_fc_conf *fc_conf);
 static int atl_flow_ctrl_set(struct rte_eth_dev *dev,
   struct rte_eth_fc_conf *fc_conf);
+
+static void atl_dev_link_status_print(struct rte_eth_dev *dev);
+
 /* Interrupts */
 static int atl_dev_rxq_interrupt_setup(struct rte_eth_dev *dev);
 static int atl_dev_lsc_interrupt_setup(struct rte_eth_dev *dev, uint8_t on);
@@ -189,6 +195,20 @@ static struct rte_pci_driver rte_atl_pmd = {
.remove = eth_atl_pci_remove,
 };
 
+#define ATL_RX_OFFLOADS ( DEV_RX_OFFLOAD_VLAN_STRIP \
+   | DEV_RX_OFFLOAD_IPV4_CKSUM \
+   | DEV_RX_OFFLOAD_UDP_CKSUM \
+   | DEV_RX_OFFLOAD_TCP_CKSUM \
+   | DEV_RX_OFFLOAD_JUMBO_FRAME \
+   | DEV_RX_OFFLOAD_CRC_STRIP)
+
+#define ATL_TX_OFFLOADS ( DEV_TX_OFFLOAD_VLAN_INSERT \
+   | DEV_TX_OFFLOAD_IPV4_CKSUM \
+   | DEV_TX_OFFLOAD_UDP_CKSUM \
+   | DEV_TX_OFFLOAD_TCP_CKSUM \
+   | DEV_TX_OFFLOAD_TCP_TSO \
+   | DEV_TX_OFFLOAD_MULTI_SEGS)
+
 static const struct rte_eth_desc_lim rx_desc_lim = {
.nb_max = ATL_MAX_RING_DESC,
.nb_min = ATL_MIN_RING_DESC,
@@ -257,6 +277,12 @@ static const struct eth_dev_ops atl_eth_dev_ops = {
.xstats_get_names = atl_dev_xstats_get_names,
.stats_reset  = atl_dev_stats_reset,
.xstats_reset = atl_dev_xstats_reset,
+   .fw_version_get   = atl_fw_version_get,
+   .dev_infos_get= atl_dev_info_get,
+   .dev_supported_ptypes_get = atl_dev_supported_ptypes_get,
+
+   .mtu_set  = atl_dev_mtu_set,
+
/* VLAN */
.vlan_filter_set  = atl_vlan_filter_set,
.vlan_offload_set = atl_vlan_offload_set,
@@ -657,6 +683,7 @@ atl_dev_start(struct rte_eth_dev *dev)
return 0;
 
 error:
+   PMD_INIT_LOG(ERR, "failure in atl_dev_start(): %d", err);
atl_stop_queues(dev);
return -EIO;
 }
@@ -837,6 +864,94 @@ atl_dev_xstats_reset(struct rte_eth_dev *dev __rte_unused)
 {
return;
 }
+
+
+static int
+atl_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size)
+{
+   struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   uint32_t fw_ver = 0;
+   unsigned int ret = 0;
+
+   ret = hw_atl_utils_get_fw_version(hw, &fw_ver);
+   if (ret)
+   return 0;
+
+   ret = snprintf(fw_version, fw_size, "%u.%u.%u", fw_ver >> 24, (fw_ver 
>> 16) & 0xFFU, fw_ver & 0xU);
+
+   ret += 1; /* add string null-terminator */
+
+   if (fw_size < ret)
+   return ret;
+
+   return 0;
+}
+
+static void
+atl_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
+{
+   struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
+
+   dev_info->max_rx_queues = AQ_HW_MAX_RX_QUEUES;
+   dev_info->max_tx_queues = AQ_HW_MAX_TX_QUEUES;
+
+   dev_info->min_rx_bufsize = 1024;
+   dev_info->max_rx_pktlen = HW_ATL_B0_MTU_JUMBO;
+   dev_info->max_mac_addrs = HW_ATL_B0_MAC_MAX;
+   dev_info->max_vfs = pci_dev->max_vfs;
+
+   dev_info->max_hash_mac_addrs = 0;
+   dev_info->max_vmdq_pools = 0;
+   dev_info->vmdq_queue_num = 0;
+
+   dev_info->rx_offload_capa = ATL_RX_OFFLOADS;
+
+   dev_info->tx_offload_capa = ATL_TX_OFFLOADS;
+
+
+   dev_info->default_rxconf = (struct rte_eth_rxconf) {
+   .rx_free_thresh = ATL_DEFAULT_RX_FREE_THRESH,
+   };
+
+   dev_info->default_txconf = (struct rte_eth_txconf) {
+   .tx_free_thresh = ATL_DEFAULT_TX_FREE_THRESH,
+   };
+
+   dev_info->rx_desc_lim = rx_desc_lim;
+   dev_info->tx_desc_lim = tx_desc_lim;
+
+   dev_info->hash_key_size = HW_ATL_B0_RSS_HASHKEY_BITS/8;
+   dev_info->reta_size = HW_ATL_B0_RSS_

[dpdk-dev] [PATCH 20/21] net/atlantic: RX side structures and implementation

2018-09-07 Thread Igor Russkikh
Signed-off-by: Igor Russkikh 
---
 drivers/net/atlantic/Makefile |   6 +
 drivers/net/atlantic/atl_ethdev.c |  44 +++
 drivers/net/atlantic/atl_ethdev.h |  80 
 drivers/net/atlantic/atl_rxtx.c   | 758 ++
 drivers/net/atlantic/meson.build  |   6 +
 5 files changed, 894 insertions(+)
 create mode 100644 drivers/net/atlantic/atl_rxtx.c

diff --git a/drivers/net/atlantic/Makefile b/drivers/net/atlantic/Makefile
index 4b0e6f06c..7b11246d1 100644
--- a/drivers/net/atlantic/Makefile
+++ b/drivers/net/atlantic/Makefile
@@ -54,7 +54,13 @@ VPATH += $(SRCDIR)/hw_atl
 #
 # all source are stored in SRCS-y
 #
+SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += atl_rxtx.c
 SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += atl_ethdev.c
+SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += atl_hw_regs.c
+SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += hw_atl_utils.c
+SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += hw_atl_llh.c
+SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += hw_atl_utils_fw2x.c
+SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += hw_atl_b0.c
 SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += rte_pmd_atlantic.c
 
 # install this header file
diff --git a/drivers/net/atlantic/atl_ethdev.c 
b/drivers/net/atlantic/atl_ethdev.c
index 44cea12ab..bb4d96bb1 100644
--- a/drivers/net/atlantic/atl_ethdev.c
+++ b/drivers/net/atlantic/atl_ethdev.c
@@ -277,6 +277,8 @@ static const struct eth_dev_ops atl_eth_dev_ops = {
.xstats_get_names = atl_dev_xstats_get_names,
.stats_reset  = atl_dev_stats_reset,
.xstats_reset = atl_dev_xstats_reset,
+   .queue_stats_mapping_set = atl_dev_queue_stats_mapping_set,
+
.fw_version_get   = atl_fw_version_get,
.dev_infos_get= atl_dev_info_get,
.dev_supported_ptypes_get = atl_dev_supported_ptypes_get,
@@ -289,6 +291,20 @@ static const struct eth_dev_ops atl_eth_dev_ops = {
.vlan_tpid_set= atl_vlan_tpid_set,
.vlan_strip_queue_set = atl_vlan_strip_queue_set,
 
+   /* Queue Control */
+   .rx_queue_start   = atl_rx_queue_start,
+   .rx_queue_stop= atl_rx_queue_stop,
+   .rx_queue_setup   = atl_rx_queue_setup,
+   .rx_queue_release = atl_rx_queue_release,
+
+   .rx_queue_intr_enable = atl_dev_rx_queue_intr_enable,
+   .rx_queue_intr_disable = atl_dev_rx_queue_intr_disable,
+
+   .rx_queue_count   = atl_rx_queue_count,
+   .rx_descriptor_done   = atl_dev_rx_descriptor_done,
+   .rx_descriptor_status = atl_dev_rx_descriptor_status,
+   .tx_descriptor_status = atl_dev_tx_descriptor_status,
+
/* LEDs */
.dev_led_on   = atl_dev_led_on,
.dev_led_off  = atl_dev_led_off,
@@ -307,6 +323,7 @@ static const struct eth_dev_ops atl_eth_dev_ops = {
.mac_addr_remove  = atl_remove_mac_addr,
.mac_addr_set = atl_set_default_mac_addr,
.set_mc_addr_list = atl_dev_set_mc_addr_list,
+   .rxq_info_get = atl_rxq_info_get,
.reta_update  = atl_reta_update,
.reta_query   = atl_reta_query,
.rss_hash_update  = atl_rss_hash_update,
@@ -622,6 +639,19 @@ atl_dev_start(struct rte_eth_dev *dev)
}
}
 
+   /* This can fail when allocating mbufs for descriptor rings */
+   err = atl_rx_init(dev);
+   if (err) {
+   PMD_INIT_LOG(ERR, "Unable to initialize RX hardware");
+   goto error;
+   }
+
+   err = atl_start_queues(dev);
+   if (err < 0) {
+   PMD_INIT_LOG(ERR, "Unable to start rxtx queues");
+   goto error;
+   }
+
err = hw->aq_fw_ops->update_link_status(hw);
 
if (err) {
@@ -708,6 +738,9 @@ atl_dev_stop(struct rte_eth_dev *dev)
/* reset the NIC */
atl_reset_hw(hw);
hw->adapter_stopped = 0;
+
+   atl_stop_queues(dev);
+
/* Clear stored conf */
dev->data->scattered_rx = 0;
dev->data->lro = 0;
@@ -766,6 +799,8 @@ atl_dev_close(struct rte_eth_dev *dev)
 
atl_dev_stop(dev);
hw->adapter_stopped = 1;
+
+   atl_free_queues(dev);
 }
 
 static int
@@ -865,6 +900,15 @@ atl_dev_xstats_reset(struct rte_eth_dev *dev __rte_unused)
return;
 }
 
+static int
+atl_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev __rte_unused,
+uint16_t queue_id __rte_unused,
+uint8_t stat_idx __rte_unused,
+uint8_t is_rx __rte_unused)
+{
+   /* The mapping is hardcoded: queue 0 -> stat 0, etc */
+   return 0;
+}
 
 static int
 atl_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size)
diff --git a/drivers/net/atlantic/atl_ethdev.h 
b/drivers/net/atlantic/atl_ethdev.h
index 3ebef1f43..e532c43fa 100644
--- a/drivers/net/atlantic/atl_ethdev.h
+++ b/drivers/net/atlantic/atl_ethdev.h
@@ -13,6 +13,17 @@
 #include "atl_types.h

[dpdk-dev] [PATCH 21/21] net/atlantic: TX side structures and implementation

2018-09-07 Thread Igor Russkikh
From: Pavel Belous 

Signed-off-by: Igor Russkikh 
---
 drivers/net/atlantic/atl_ethdev.c |  10 +
 drivers/net/atlantic/atl_rxtx.c   | 566 ++
 2 files changed, 576 insertions(+)

diff --git a/drivers/net/atlantic/atl_ethdev.c 
b/drivers/net/atlantic/atl_ethdev.c
index bb4d96bb1..7abae2236 100644
--- a/drivers/net/atlantic/atl_ethdev.c
+++ b/drivers/net/atlantic/atl_ethdev.c
@@ -297,6 +297,11 @@ static const struct eth_dev_ops atl_eth_dev_ops = {
.rx_queue_setup   = atl_rx_queue_setup,
.rx_queue_release = atl_rx_queue_release,
 
+   .tx_queue_start   = atl_tx_queue_start,
+   .tx_queue_stop= atl_tx_queue_stop,
+   .tx_queue_setup   = atl_tx_queue_setup,
+   .tx_queue_release = atl_tx_queue_release,
+
.rx_queue_intr_enable = atl_dev_rx_queue_intr_enable,
.rx_queue_intr_disable = atl_dev_rx_queue_intr_disable,
 
@@ -324,6 +329,8 @@ static const struct eth_dev_ops atl_eth_dev_ops = {
.mac_addr_set = atl_set_default_mac_addr,
.set_mc_addr_list = atl_dev_set_mc_addr_list,
.rxq_info_get = atl_rxq_info_get,
+   .txq_info_get = atl_txq_info_get,
+
.reta_update  = atl_reta_update,
.reta_query   = atl_reta_query,
.rss_hash_update  = atl_rss_hash_update,
@@ -639,6 +646,9 @@ atl_dev_start(struct rte_eth_dev *dev)
}
}
 
+   /* initialize transmission unit */
+   atl_tx_init(dev);
+
/* This can fail when allocating mbufs for descriptor rings */
err = atl_rx_init(dev);
if (err) {
diff --git a/drivers/net/atlantic/atl_rxtx.c b/drivers/net/atlantic/atl_rxtx.c
index 6198f5dfe..bed2265b9 100644
--- a/drivers/net/atlantic/atl_rxtx.c
+++ b/drivers/net/atlantic/atl_rxtx.c
@@ -46,6 +46,20 @@
 #include "hw_atl/hw_atl_b0.h"
 #include "hw_atl/hw_atl_b0_internal.h"
 
+#define ATL_TX_CKSUM_OFFLOAD_MASK ( \
+   PKT_TX_IP_CKSUM |\
+   PKT_TX_L4_MASK | \
+   PKT_TX_TCP_SEG)
+
+#define ATL_TX_OFFLOAD_MASK (  \
+   PKT_TX_VLAN_PKT |\
+   PKT_TX_IP_CKSUM |\
+   PKT_TX_L4_MASK | \
+   PKT_TX_TCP_SEG)
+
+#define ATL_TX_OFFLOAD_NOTSUP_MASK \
+   (PKT_TX_OFFLOAD_MASK ^ ATL_TX_OFFLOAD_MASK)
+
 /**
  * Structure associated with each descriptor of the RX ring of a RX queue.
  */
@@ -54,6 +68,15 @@ struct atl_rx_entry {
 };
 
 /**
+ * Structure associated with each descriptor of the TX ring of a TX queue.
+ */
+struct atl_tx_entry {
+   struct rte_mbuf *mbuf;
+   uint16_t next_id;
+   uint16_t last_id;
+};
+
+/**
  * Structure associated with each RX queue.
  */
 struct atl_rx_queue {
@@ -72,6 +95,22 @@ struct atl_rx_queue {
booll4_csum_enabled;
 };
 
+/**
+ * Structure associated with each TX queue.
+ */
+struct atl_tx_queue {
+   struct hw_atl_txd_s *hw_ring;
+   uint64_thw_ring_phys_addr;
+   struct atl_tx_entry *sw_ring;
+   uint16_tnb_tx_desc;
+   uint16_ttx_tail;
+   uint16_ttx_head;
+   uint16_tqueue_id;
+   uint16_tport_id;
+   uint16_ttx_free_thresh;
+   uint16_ttx_free;
+};
+
 inline static void
 atl_reset_rx_queue(struct atl_rx_queue *rxq)
 {
@@ -169,6 +208,134 @@ atl_rx_queue_setup(struct rte_eth_dev *dev, uint16_t 
rx_queue_id,
return 0;
 }
 
+static inline void
+atl_reset_tx_queue(struct atl_tx_queue *txq)
+{
+   struct atl_tx_entry *tx_entry;
+   union hw_atl_txc_s *txc;
+   uint16_t i;
+
+   PMD_INIT_FUNC_TRACE();
+
+   if (!txq) {
+   PMD_DRV_LOG(ERR, "Pointer to txq is NULL");
+   return;
+   }
+
+   tx_entry = txq->sw_ring;
+
+   for (i = 0; i < txq->nb_tx_desc; i++) {
+   txc = (union hw_atl_txc_s *)&txq->hw_ring[i];
+   txc->flags1 = 0;
+   txc->flags2 = 2;
+   }
+
+   for (i = 0; i < txq->nb_tx_desc; i++) {
+   txq->hw_ring[i].dd = 1;
+   tx_entry[i].mbuf = NULL;
+   }
+
+   txq->tx_tail = 0;
+   txq->tx_head = 0;
+   txq->tx_free = txq->nb_tx_desc - 1;
+}
+
+int
+atl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
+  uint16_t nb_tx_desc, unsigned int socket_id,
+  const struct rte_eth_txconf *tx_conf)
+{
+   struct atl_tx_queue *txq;
+   const struct rte_memzone *mz;
+
+   PMD_INIT_FUNC_TRACE();
+
+   /* make sure a valid number of descriptors have been requested */
+   if (nb_tx_desc < AQ_HW_MIN_TX_RING_SIZE || nb_tx_desc > 
AQ_HW_MAX_TX_RING_SIZE) {
+   PMD_INIT_LOG(ERR, "Number of Tx descriptors must be "
+

Re: [dpdk-dev] Change in binary name w/ meson build

2018-09-07 Thread Bruce Richardson
On Fri, Sep 07, 2018 at 03:13:43PM +0100, Bruce Richardson wrote:
> On Wed, Sep 05, 2018 at 11:52:10AM +, Shahaf Shuler wrote:
> >Hi Bruce,
> > 
> > 
> >Playing w/ meson build I got to know that the binary name for testpmd
> >got changed to dpdk-testpmd.
> > 
> > 
> >Not sure if it was discussed or not before, but such change will affect
> >all the automation used to run testpmd w/ the old build system.
> > 
> > 
> >What is the reason for the change in the name?
> 
> The primary driver was that the autotest binary could not be called "test"
> any more, since that is a reserved name. When appending a dpdk prefix to
> the test binary, I felt for consistency that other binaries should have a
> dpdk prefix too, to indicate that they come from DPDK. If this is a
> problem, we can remove the prefix from the binaries easily enough.
> 
Also to point out that when building with meson the scripting is going to
have to change anyway, right. The actual build commands are different, the
configuration commands are different, and the directories the resulting
binaries are placed in are different too. Therefore, I'd like to keep the
name prefixes if possible, since for automated tooling on DPDK there are
going to have to be lots of other changes anyway.

For packagers, the rename I understand could be problematic, but that could
probably be solved by symlinks in the install phase.

/Bruce


[dpdk-dev] [PATCH] eal/bus: use RTE_IOVA_PA only if phys addresses are available

2018-09-07 Thread Darek Stojaczyk
When neither RTE_IOVA_VA nor RTE_IOVA_PA was explicitly
requested, DPDK would currently fallback to the default
RTE_IOVA_PA mode and possibly encounter a failure later
on if running as a non-priviledged user. Attempting to
use RTE_IOVA_VA if no phys addresses are available may
help in this case.

Signed-off-by: Darek Stojaczyk 
---
 lib/librte_eal/common/eal_common_bus.c | 18 ++
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_bus.c 
b/lib/librte_eal/common/eal_common_bus.c
index 0943851cc..8b56979d7 100644
--- a/lib/librte_eal/common/eal_common_bus.c
+++ b/lib/librte_eal/common/eal_common_bus.c
@@ -236,9 +236,19 @@ rte_bus_get_iommu_class(void)
mode |= bus->get_iommu_class();
}
 
-   if (mode != RTE_IOVA_VA) {
-   /* Use default IOVA mode */
-   mode = RTE_IOVA_PA;
+   if (mode == RTE_IOVA_VA)
+   return RTE_IOVA_VA;
+
+   if (mode & RTE_IOVA_PA) {
+   /* Not all buses support RTE_IOVA_VA, fallback to RTE_IOVA_PA */
+   return RTE_IOVA_PA;
+   }
+
+   if (rte_eal_using_phys_addrs()) {
+   /* Default to RTE_IOVA_PA only if it's supported */
+   return RTE_IOVA_PA;
}
-   return mode;
+
+   /* Since RTE_IOVA_PA is unsupported, fallback to RTE_IOVA_VA */
+   return RTE_IOVA_VA;
 }
-- 
2.17.1



[dpdk-dev] [PATCH 1/2] pipeline: add vxlan encap

2018-09-07 Thread Cristian Dumitrescu
Add support for VXLAN as part of the encap table action.

Signed-off-by: Cristian Dumitrescu 
---
 lib/librte_pipeline/rte_table_action.c | 356 +
 lib/librte_pipeline/rte_table_action.h |  75 +++
 2 files changed, 431 insertions(+)

diff --git a/lib/librte_pipeline/rte_table_action.c 
b/lib/librte_pipeline/rte_table_action.c
index 83ffa5d..338dcfe 100644
--- a/lib/librte_pipeline/rte_table_action.c
+++ b/lib/librte_pipeline/rte_table_action.c
@@ -430,6 +430,7 @@ encap_valid(enum rte_table_action_encap_type encap)
case RTE_TABLE_ACTION_ENCAP_QINQ:
case RTE_TABLE_ACTION_ENCAP_MPLS:
case RTE_TABLE_ACTION_ENCAP_PPPOE:
+   case RTE_TABLE_ACTION_ENCAP_VXLAN:
return 1;
default:
return 0;
@@ -498,6 +499,38 @@ struct encap_pppoe_data {
struct pppoe_ppp_hdr pppoe_ppp;
 } __attribute__((__packed__));
 
+#define IP_PROTO_UDP   17
+
+struct encap_vxlan_ipv4_data {
+   struct ether_hdr ether;
+   struct ipv4_hdr ipv4;
+   struct udp_hdr udp;
+   struct vxlan_hdr vxlan;
+} __attribute__((__packed__));
+
+struct encap_vxlan_ipv4_vlan_data {
+   struct ether_hdr ether;
+   struct vlan_hdr vlan;
+   struct ipv4_hdr ipv4;
+   struct udp_hdr udp;
+   struct vxlan_hdr vxlan;
+} __attribute__((__packed__));
+
+struct encap_vxlan_ipv6_data {
+   struct ether_hdr ether;
+   struct ipv6_hdr ipv6;
+   struct udp_hdr udp;
+   struct vxlan_hdr vxlan;
+} __attribute__((__packed__));
+
+struct encap_vxlan_ipv6_vlan_data {
+   struct ether_hdr ether;
+   struct vlan_hdr vlan;
+   struct ipv6_hdr ipv6;
+   struct udp_hdr udp;
+   struct vxlan_hdr vxlan;
+} __attribute__((__packed__));
+
 static size_t
 encap_data_size(struct rte_table_action_encap_config *encap)
 {
@@ -517,6 +550,18 @@ encap_data_size(struct rte_table_action_encap_config 
*encap)
case 1LLU << RTE_TABLE_ACTION_ENCAP_PPPOE:
return sizeof(struct encap_pppoe_data);
 
+   case 1LLU << RTE_TABLE_ACTION_ENCAP_VXLAN:
+   if (encap->vxlan.ip_version)
+   if (encap->vxlan.vlan)
+   return sizeof(struct 
encap_vxlan_ipv4_vlan_data);
+   else
+   return sizeof(struct encap_vxlan_ipv4_data);
+   else
+   if (encap->vxlan.vlan)
+   return sizeof(struct 
encap_vxlan_ipv6_vlan_data);
+   else
+   return sizeof(struct encap_vxlan_ipv6_data);
+
default:
return 0;
}
@@ -550,6 +595,9 @@ encap_apply_check(struct rte_table_action_encap_params *p,
case RTE_TABLE_ACTION_ENCAP_PPPOE:
return 0;
 
+   case RTE_TABLE_ACTION_ENCAP_VXLAN:
+   return 0;
+
default:
return -EINVAL;
}
@@ -679,6 +727,168 @@ encap_pppoe_apply(void *data,
 }
 
 static int
+encap_vxlan_apply(void *data,
+   struct rte_table_action_encap_params *p,
+   struct rte_table_action_encap_config *cfg)
+{
+   if ((p->vxlan.vxlan.vni > 0xFF) ||
+   (cfg->vxlan.ip_version && (p->vxlan.ipv4.dscp > 0x3F)) ||
+   (!cfg->vxlan.ip_version && (p->vxlan.ipv6.flow_label > 
0xF)) ||
+   (!cfg->vxlan.ip_version && (p->vxlan.ipv6.dscp > 0x3F)) ||
+   (cfg->vxlan.vlan && (p->vxlan.vlan.vid > 0xFFF)))
+   return -1;
+
+   if (cfg->vxlan.ip_version)
+   if (cfg->vxlan.vlan) {
+   struct encap_vxlan_ipv4_vlan_data *d = data;
+
+   /* Ethernet */
+   ether_addr_copy(&p->vxlan.ether.da, &d->ether.d_addr);
+   ether_addr_copy(&p->vxlan.ether.sa, &d->ether.s_addr);
+   d->ether.ether_type = rte_htons(ETHER_TYPE_VLAN);
+
+   /* VLAN */
+   d->vlan.vlan_tci = rte_htons(VLAN(p->vxlan.vlan.pcp,
+   p->vxlan.vlan.dei,
+   p->vxlan.vlan.vid));
+   d->vlan.eth_proto = rte_htons(ETHER_TYPE_IPv4);
+
+   /* IPv4*/
+   d->ipv4.version_ihl = 0x45;
+   d->ipv4.type_of_service = p->vxlan.ipv4.dscp << 2;
+   d->ipv4.total_length = 0; /* not pre-computed */
+   d->ipv4.packet_id = 0;
+   d->ipv4.fragment_offset = 0;
+   d->ipv4.time_to_live = p->vxlan.ipv4.ttl;
+   d->ipv4.next_proto_id = IP_PROTO_UDP;
+   d->ipv4.hdr_checksum = 0;
+   d->ipv4.src_addr = rte_htonl(p->vxlan.ipv4.sa);
+   d->ipv4.dst_addr = rte_htonl(p->vxlan.ipv4.da);
+
+   d->ipv4.hdr_checksum = rte_ipv4_

[dpdk-dev] [PATCH 2/2] examples/ip_pipeline: add vxlan encap

2018-09-07 Thread Cristian Dumitrescu
Add CLI support for VXLAN encap.

Signed-off-by: Cristian Dumitrescu 
---
 examples/ip_pipeline/cli.c | 181 -
 1 file changed, 177 insertions(+), 4 deletions(-)

diff --git a/examples/ip_pipeline/cli.c b/examples/ip_pipeline/cli.c
index 102a1d6..01c3769 100644
--- a/examples/ip_pipeline/cli.c
+++ b/examples/ip_pipeline/cli.c
@@ -961,7 +961,8 @@ static const char cmd_table_action_profile_help[] =
 "   tc \n"
 "   stats none | pkts | bytes | both]\n"
 "   [tm spp  pps ]\n"
-"   [encap ether | vlan | qinq | mpls | pppoe]\n"
+"   [encap ether | vlan | qinq | mpls | pppoe |\n"
+"   vxlan offset  ipv4 | ipv6 vlan on | off]\n"
 "   [nat src | dst\n"
 "   proto udp | tcp]\n"
 "   [ttl drop | fwd\n"
@@ -1157,6 +1158,8 @@ cmd_table_action_profile(char **tokens,
} /* tm */
 
if ((t0 < n_tokens) && (strcmp(tokens[t0], "encap") == 0)) {
+   uint32_t n_extra_tokens = 0;
+
if (n_tokens < t0 + 2) {
snprintf(out, out_size, MSG_ARG_MISMATCH,
"action profile encap");
@@ -1173,13 +1176,61 @@ cmd_table_action_profile(char **tokens,
p.encap.encap_mask = 1LLU << 
RTE_TABLE_ACTION_ENCAP_MPLS;
else if (strcmp(tokens[t0 + 1], "pppoe") == 0)
p.encap.encap_mask = 1LLU << 
RTE_TABLE_ACTION_ENCAP_PPPOE;
-   else {
+   else if (strcmp(tokens[t0 + 1], "vxlan") == 0) {
+   if (n_tokens < t0 + 2 + 5) {
+   snprintf(out, out_size, MSG_ARG_MISMATCH,
+   "action profile encap vxlan");
+   return;
+   }
+
+   if (strcmp(tokens[t0 + 2], "offset") != 0) {
+   snprintf(out, out_size, MSG_ARG_NOT_FOUND,
+   "vxlan: offset");
+   return;
+   }
+
+   if (parser_read_uint32(&p.encap.vxlan.data_offset,
+   tokens[t0 + 2 + 1]) != 0) {
+   snprintf(out, out_size, MSG_ARG_INVALID,
+   "vxlan: ether_offset");
+   return;
+   }
+
+   if (strcmp(tokens[t0 + 2 + 2], "ipv4") == 0)
+   p.encap.vxlan.ip_version = 1;
+   else if (strcmp(tokens[t0 + 2 + 2], "ipv6") == 0)
+   p.encap.vxlan.ip_version = 0;
+   else {
+   snprintf(out, out_size, MSG_ARG_INVALID,
+   "vxlan: ipv4 or ipv6");
+   return;
+   }
+
+   if (strcmp(tokens[t0 + 2 + 3], "vlan") != 0) {
+   snprintf(out, out_size, MSG_ARG_NOT_FOUND,
+   "vxlan: vlan");
+   return;
+   }
+
+   if (strcmp(tokens[t0 + 2 + 4], "on") == 0)
+   p.encap.vxlan.vlan = 1;
+   else if (strcmp(tokens[t0 + 2 + 4], "off") == 0)
+   p.encap.vxlan.vlan = 0;
+   else {
+   snprintf(out, out_size, MSG_ARG_INVALID,
+   "vxlan: on or off");
+   return;
+   }
+
+   p.encap.encap_mask = 1LLU << 
RTE_TABLE_ACTION_ENCAP_VXLAN;
+   n_extra_tokens = 5;
+   } else {
snprintf(out, out_size, MSG_ARG_MISMATCH, "encap");
return;
}
 
p.action_mask |= 1LLU << RTE_TABLE_ACTION_ENCAP;
-   t0 += 2;
+   t0 += 2 + n_extra_tokens;
} /* encap */
 
if ((t0 < n_tokens) && (strcmp(tokens[t0], "nat") == 0)) {
@@ -2861,7 +2912,13 @@ parse_match(char **tokens,
  *  [label1   
  *  [label2   
  *  [label3   ]]]
- *   | pppoe   ]
+ *   | pppoe   
+ *   | vxlan ether  
+ *  [vlan   ]
+ *  ipv4
+ *  | ipv6 
+ *  udp  
+ *  vxlan ]
  *[nat ipv4 | ipv6  ]
  *[ttl dec | keep]
  *[stats]
@@ -3254,6 +3311,122 @@ parse_table_action_encap(char **tokens,
return 1 + 4;
}
 
+   /* vxlan */
+   if (n_tokens && (strcmp(tokens[0], "vxlan") == 0)) {
+   uint32_t n = 0;
+
+   n_tokens--;
+   tokens++;
+   n++;
+
+   /* ether   */
+   if ((n_tokens < 3) ||
+   strcmp(tokens[0], "ether") ||
+   parse_mac_addr(tokens[1], &a->encap.vxlan.

[dpdk-dev] [PATCH v2] eal/bus: use RTE_IOVA_PA only if phys addresses are available

2018-09-07 Thread Darek Stojaczyk
When neither RTE_IOVA_VA nor RTE_IOVA_PA was explicitly
requested, DPDK would currently fallback to the default
RTE_IOVA_PA mode and possibly encounter a failure later
on if running as a non-priviledged user. Attempting to
use RTE_IOVA_VA if no phys addresses are available may
help in this case.

Signed-off-by: Darek Stojaczyk 
---
Changes since v1:
 * added a missing rte_memory.h include

 lib/librte_eal/common/eal_common_bus.c | 19 +++
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_bus.c 
b/lib/librte_eal/common/eal_common_bus.c
index 0943851cc..68c581b8a 100644
--- a/lib/librte_eal/common/eal_common_bus.c
+++ b/lib/librte_eal/common/eal_common_bus.c
@@ -37,6 +37,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "eal_private.h"
 
@@ -236,9 +237,19 @@ rte_bus_get_iommu_class(void)
mode |= bus->get_iommu_class();
}
 
-   if (mode != RTE_IOVA_VA) {
-   /* Use default IOVA mode */
-   mode = RTE_IOVA_PA;
+   if (mode == RTE_IOVA_VA)
+   return RTE_IOVA_VA;
+
+   if (mode & RTE_IOVA_PA) {
+   /* Not all buses support RTE_IOVA_VA, fallback to RTE_IOVA_PA */
+   return RTE_IOVA_PA;
+   }
+
+   if (rte_eal_using_phys_addrs()) {
+   /* Default to RTE_IOVA_PA only if it's supported */
+   return RTE_IOVA_PA;
}
-   return mode;
+
+   /* Since RTE_IOVA_PA is unsupported, fallback to RTE_IOVA_VA */
+   return RTE_IOVA_VA;
 }
-- 
2.17.1



Re: [dpdk-dev] [PATCH v2] test/event: add adapter tests to meson build

2018-09-07 Thread Bruce Richardson
On Wed, Sep 05, 2018 at 07:36:13PM +0530, Nikhil Rao wrote:
> Add tests for event eth Rx, crypto and timer adapters to
> meson build
> 
> Cc: Abhinandan Gujjar 
> Cc: Erik G. Carrillo 
> Signed-off-by: Nikhil Rao 
> ---
> 
> v2:
> * fix Erik's email address
> 
>  test/test/meson.build | 7 +++
>  1 file changed, 7 insertions(+)
> 
When running this with test-meson-build.sh, errors are thrown up with the
x86-default build. Please investigate.

Regards,
/Bruce


[dpdk-dev] A couple question before starting to work on a Silicom NIC-Bypass driver implementation

2018-09-07 Thread Jean-Christophe BEGUE

Hello everyone,

Here at FraudBuster we really need a NIC-Bypass feature to be 
integrated in our products.


We've been able to use the Silicom boards we can find here: 
https://bit.ly/2NrIK7z .
Unfortunately the only driver Silicom seems to support is written for 
kernel-space bound interfaces: you need your interface to have an 
`interface index`  assigned in the kernel, which I beleive is not a 
common thing in the DPDK bound way of accessing hardware.


We were able to get a functional driver from Silicom's module with a 
quick and dirty hack. But we would be very interested in writing a 
DPDK-integrated driver has the one implemented in 
`drivers/net/ixgbe/ixgbe_bypass.c`. It seems to share similarities in 
hardware implementation, in particular the I2C bit-banging control via 
ESDP.


We would like to start with the PE210G2BPI9, a Dual Port Fiber 10G, 
82599ES Based.


But first, as I am totally new to the DPDK world, I have a couple of 
question:


How would the community welcome this feature ? Would it be useful for 
some DPDK users ?


Would some people agree to mentor my work, review and give me advice. 
Helping me to integrate well into the project architecture and reach 
the required code quality required to be merged ?


Thank you!


Re: [dpdk-dev] [PATCH 1/4] mk: use script to generate examples.dox

2018-09-07 Thread Bruce Richardson
On Mon, Sep 03, 2018 at 10:07:07AM +0100, Luca Boccassi wrote:
> On Mon, 2018-09-03 at 02:54 +0200, Thomas Monjalon wrote:
> > 31/08/2018 20:20, Luca Boccassi:
> > > +# SC2129 - avoid multiple individual redirects
> > 
> > What is SC2129 ?
> 
> shellcheck - will clarify in v2
> 
> > > +{ \
> > > +printf '/**\n'; \
> > > +printf '@page examples DPDK Example Programs\n\n'; \
> > > +find "${EXAMPLES_DIR}" -type f -name '*.c' -printf '@example
> > > examples/%P\n' | LC_ALL=C sort; \
> > > +printf '*/\n'; \
> > > +} > "${API_EXAMPLES}"
> > 
> > Why using backslashes (continuation lines)?
> 
> Good point, will remove in v2
>
Agree, rather than using continuation lines, I suggest one of the
following:
* use exec > ${API_EXAMPLES} at the top of the script
* let the script just print to stdout and have make/meson put that in the
  output file for you.

/Bruce


Re: [dpdk-dev] [PATCH 4/4] build: generate API documentation with Meson

2018-09-07 Thread Bruce Richardson
On Fri, Aug 31, 2018 at 07:20:55PM +0100, Luca Boccassi wrote:
> Both a configuration-time "enable_docs" boolean option and an optional
> 'ninja doc' target are available. Note that due to a Meson bug for now
> the latter will only build, but not install the files.
> 
> Signed-off-by: Luca Boccassi 
> ---
>  doc/api/generate_doxygen.sh | 10 
>  doc/api/meson.build | 51 +
>  doc/build-sdk-meson.txt |  2 ++
>  doc/meson.build |  4 +++
>  meson.build |  3 +++
>  meson_options.txt   |  2 ++
>  6 files changed, 72 insertions(+)
>  create mode 100755 doc/api/generate_doxygen.sh
>  create mode 100644 doc/api/meson.build
>  create mode 100644 doc/meson.build
> 
> diff --git a/doc/api/generate_doxygen.sh b/doc/api/generate_doxygen.sh
> new file mode 100755
> index 00..ab57660958
> --- /dev/null
> +++ b/doc/api/generate_doxygen.sh
> @@ -0,0 +1,10 @@
> +#! /bin/sh -e
> +# SPDX-License-Identifier: BSD-3-Clause
> +# Copyright 2018 Luca Boccassi 
> +
> +DOXYCONF=$1
> +OUTDIR=$2
> +SCRIPTCSS=$3
> +
> +doxygen "${DOXYCONF}"
> +"${SCRIPTCSS}" "${OUTDIR}"/doxygen.css
> diff --git a/doc/api/meson.build b/doc/api/meson.build
> new file mode 100644
> index 00..e44963e4a9
> --- /dev/null
> +++ b/doc/api/meson.build
> @@ -0,0 +1,51 @@
> +# SPDX-License-Identifier: BSD-3-Clause
> +# Copyright(c) 2018 Luca Boccassi 
> +
> +# due to the CSS customisation script, which needs to run on a file that
> +# is in a subdirectory that is created at build time and thus it cannot
> +# be an individual custom_target, we need to wrap the doxygen call in a
> +# script to run the CSS modification afterwards
> +generate_doxygen = find_program('generate_doxygen.sh')
> +generate_examples = find_program('generate_examples.sh')
> +generate_css = find_program('doxy-html-custom.sh')
> +doxygen = find_program('doxygen')

This needs to be inside a conditional if we are not building docs.
Otherwise overall build will error out if doxygen is missing - even if
unused.

/Bruce


[dpdk-dev] [PATCH v2 4/4] build: generate API documentation with Meson

2018-09-07 Thread Luca Boccassi
Signed-off-by: Luca Boccassi 
---
v2: made doxygen dependency optional, skip doxygen build when not found

 doc/api/generate_doxygen.sh | 10 +++
 doc/api/meson.build | 54 +
 doc/build-sdk-meson.txt |  2 ++
 doc/meson.build |  4 +++
 meson.build |  3 +++
 meson_options.txt   |  2 ++
 6 files changed, 75 insertions(+)
 create mode 100755 doc/api/generate_doxygen.sh
 create mode 100644 doc/api/meson.build
 create mode 100644 doc/meson.build

diff --git a/doc/api/generate_doxygen.sh b/doc/api/generate_doxygen.sh
new file mode 100755
index 00..ab57660958
--- /dev/null
+++ b/doc/api/generate_doxygen.sh
@@ -0,0 +1,10 @@
+#! /bin/sh -e
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright 2018 Luca Boccassi 
+
+DOXYCONF=$1
+OUTDIR=$2
+SCRIPTCSS=$3
+
+doxygen "${DOXYCONF}"
+"${SCRIPTCSS}" "${OUTDIR}"/doxygen.css
diff --git a/doc/api/meson.build b/doc/api/meson.build
new file mode 100644
index 00..5dfa0fe044
--- /dev/null
+++ b/doc/api/meson.build
@@ -0,0 +1,54 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2018 Luca Boccassi 
+
+doxygen = find_program('doxygen', required: false)
+
+if doxygen.found()
+   # due to the CSS customisation script, which needs to run on a file that
+   # is in a subdirectory that is created at build time and thus it cannot
+   # be an individual custom_target, we need to wrap the doxygen call in a
+   # script to run the CSS modification afterwards
+   generate_doxygen = find_program('generate_doxygen.sh')
+   generate_examples = find_program('generate_examples.sh')
+   generate_css = find_program('doxy-html-custom.sh')
+
+   inputdir = join_paths(meson.source_root(), 'examples')
+   htmldir = join_paths('doc', 'html')
+
+   # due to the following bug: 
https://github.com/mesonbuild/meson/issues/4107
+   # if install is set to true it will override build_by_default and it 
will
+   # cause the target to always be built. If install were to be always set 
to
+   # false it would be impossible to install the docs.
+   # So use a configure option for now.
+   example = custom_target('examples.dox',
+   input: inputdir,
+   output: 'examples.dox',
+   command: [generate_examples, '@INPUT@', '@OUTPUT@'],
+   install: get_option('enable_docs'),
+   install_dir: htmldir,
+   build_by_default: false)
+
+   cdata = configuration_data()
+   cdata.set('VERSION', meson.project_version())
+   cdata.set('API_EXAMPLES', join_paths(meson.build_root(), 'doc', 'api', 
'examples.dox'))
+   cdata.set('OUTPUT', join_paths(meson.build_root(), 'doc', 'api'))
+   cdata.set('HTML_OUTPUT', 'api')
+   cdata.set('TOPDIR', meson.source_root())
+   cdata.set('STRIP_FROM_PATH', meson.source_root())
+
+   doxy_conf = configure_file(input: 'doxy-api.conf.in',
+   output: 'doxy-api.conf',
+   configuration: cdata,
+   install: false)
+
+   doxy_build = custom_target('doxygen',
+   depends: example,
+   input: doxy_conf,
+   output: 'api',
+   command: [generate_doxygen, '@INPUT@', '@OUTPUT@', 
generate_css],
+   install: get_option('enable_docs'),
+   install_dir: htmldir,
+   build_by_default: false)
+
+   run_target('doc', command: 'true', depends: doxy_build)
+endif
diff --git a/doc/build-sdk-meson.txt b/doc/build-sdk-meson.txt
index 9618e759ea..508e2cb642 100644
--- a/doc/build-sdk-meson.txt
+++ b/doc/build-sdk-meson.txt
@@ -85,6 +85,8 @@ Project-specific options are passed used -Doption=value::
 
meson -Dmax_lcores=8 smallbuild  # scale build for smaller systems
 
+   meson -Denable_docs=true fullbuild  # build and install docs
+
 Examples of setting the same options using meson configure::
 
meson configure -Dwerror=true
diff --git a/doc/meson.build b/doc/meson.build
new file mode 100644
index 00..afca2e7133
--- /dev/null
+++ b/doc/meson.build
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2018 Luca Boccassi 
+
+subdir('api')
diff --git a/meson.build b/meson.build
index e8640a..09506ec48c 100644
--- a/meson.build
+++ b/meson.build
@@ -34,6 +34,9 @@ subdir('usertools')
 subdir('app')
 subdir('test')
 
+# build docs
+subdir('doc')
+
 # build any examples explicitly requested - useful for developers
 if get_option('examples') != ''
subdir('examples')
diff --git a/meson_options.txt b/meson_options.txt
index f20887212a..d38ba56e29 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -2,6 +2,8 @@ option('allow_invalid_socket_id', type: 'boolean', value: false,
description: 'allow out-of-range NUMA socket id\'s for platforms that 
don\'t report the value correctly')
 option('enable_kmods', type: 'boolean', value: true,
description: 'bui

Re: [dpdk-dev] [PATCH 4/4] build: generate API documentation with Meson

2018-09-07 Thread Luca Boccassi
On Fri, 2018-09-07 at 17:31 +0100, Bruce Richardson wrote:
> On Fri, Aug 31, 2018 at 07:20:55PM +0100, Luca Boccassi wrote:
> > Both a configuration-time "enable_docs" boolean option and an
> > optional
> > 'ninja doc' target are available. Note that due to a Meson bug for
> > now
> > the latter will only build, but not install the files.
> > 
> > Signed-off-by: Luca Boccassi 
> > ---
> >  doc/api/generate_doxygen.sh | 10 
> >  doc/api/meson.build | 51
> > +
> >  doc/build-sdk-meson.txt |  2 ++
> >  doc/meson.build |  4 +++
> >  meson.build |  3 +++
> >  meson_options.txt   |  2 ++
> >  6 files changed, 72 insertions(+)
> >  create mode 100755 doc/api/generate_doxygen.sh
> >  create mode 100644 doc/api/meson.build
> >  create mode 100644 doc/meson.build
> > 
> > diff --git a/doc/api/generate_doxygen.sh
> > b/doc/api/generate_doxygen.sh
> > new file mode 100755
> > index 00..ab57660958
> > --- /dev/null
> > +++ b/doc/api/generate_doxygen.sh
> > @@ -0,0 +1,10 @@
> > +#! /bin/sh -e
> > +# SPDX-License-Identifier: BSD-3-Clause
> > +# Copyright 2018 Luca Boccassi 
> > +
> > +DOXYCONF=$1
> > +OUTDIR=$2
> > +SCRIPTCSS=$3
> > +
> > +doxygen "${DOXYCONF}"
> > +"${SCRIPTCSS}" "${OUTDIR}"/doxygen.css
> > diff --git a/doc/api/meson.build b/doc/api/meson.build
> > new file mode 100644
> > index 00..e44963e4a9
> > --- /dev/null
> > +++ b/doc/api/meson.build
> > @@ -0,0 +1,51 @@
> > +# SPDX-License-Identifier: BSD-3-Clause
> > +# Copyright(c) 2018 Luca Boccassi 
> > +
> > +# due to the CSS customisation script, which needs to run on a
> > file that
> > +# is in a subdirectory that is created at build time and thus it
> > cannot
> > +# be an individual custom_target, we need to wrap the doxygen call
> > in a
> > +# script to run the CSS modification afterwards
> > +generate_doxygen = find_program('generate_doxygen.sh')
> > +generate_examples = find_program('generate_examples.sh')
> > +generate_css = find_program('doxy-html-custom.sh')
> > +doxygen = find_program('doxygen')
> 
> This needs to be inside a conditional if we are not building docs.
> Otherwise overall build will error out if doxygen is missing - even
> if
> unused.
> 
> /Bruce

Good point, forgot about that, done in v2

-- 
Kind regards,
Luca Boccassi


[dpdk-dev] [PATCH v2 2/4] mk: use templated doxygen config, modified on the fly

2018-09-07 Thread Luca Boccassi
This will allow the same config file to be used from Meson.
The result has been verified to be identical via diffoscope.

Signed-off-by: Luca Boccassi 
---
v2: reordered generated fields as requested

 doc/api/doxy-api.conf| 87 
 doc/api/doxy-api.conf.in | 96 
 mk/rte.sdkdoc.mk | 16 +++
 3 files changed, 103 insertions(+), 96 deletions(-)
 delete mode 100644 doc/api/doxy-api.conf
 create mode 100644 doc/api/doxy-api.conf.in

diff --git a/doc/api/doxy-api.conf b/doc/api/doxy-api.conf
deleted file mode 100644
index 66693c3835..00
--- a/doc/api/doxy-api.conf
+++ /dev/null
@@ -1,87 +0,0 @@
-# SPDX-License-Identifier: BSD-3-Clause
-# Copyright 2013-2017 6WIND S.A.
-
-PROJECT_NAME= DPDK
-INPUT   = doc/api/doxy-api-index.md \
-  drivers/crypto/scheduler \
-  drivers/mempool/dpaa2 \
-  drivers/net/bnxt \
-  drivers/net/bonding \
-  drivers/net/dpaa \
-  drivers/net/i40e \
-  drivers/net/ixgbe \
-  drivers/net/softnic \
-  drivers/raw/dpaa2_cmdif \
-  drivers/raw/dpaa2_qdma \
-  lib/librte_eal/common/include \
-  lib/librte_eal/common/include/generic \
-  lib/librte_acl \
-  lib/librte_bbdev \
-  lib/librte_bitratestats \
-  lib/librte_bpf \
-  lib/librte_cfgfile \
-  lib/librte_cmdline \
-  lib/librte_compat \
-  lib/librte_compressdev \
-  lib/librte_cryptodev \
-  lib/librte_distributor \
-  lib/librte_efd \
-  lib/librte_ethdev \
-  lib/librte_eventdev \
-  lib/librte_flow_classify \
-  lib/librte_gro \
-  lib/librte_gso \
-  lib/librte_hash \
-  lib/librte_ip_frag \
-  lib/librte_jobstats \
-  lib/librte_kni \
-  lib/librte_kvargs \
-  lib/librte_latencystats \
-  lib/librte_lpm \
-  lib/librte_mbuf \
-  lib/librte_member \
-  lib/librte_mempool \
-  lib/librte_meter \
-  lib/librte_metrics \
-  lib/librte_net \
-  lib/librte_pci \
-  lib/librte_pdump \
-  lib/librte_pipeline \
-  lib/librte_port \
-  lib/librte_power \
-  lib/librte_rawdev \
-  lib/librte_reorder \
-  lib/librte_ring \
-  lib/librte_sched \
-  lib/librte_security \
-  lib/librte_table \
-  lib/librte_timer \
-  lib/librte_vhost
-FILE_PATTERNS   = rte_*.h \
-  cmdline.h
-PREDEFINED  = __DOXYGEN__ \
-  VFIO_PRESENT \
-  __attribute__(x)=
-
-OPTIMIZE_OUTPUT_FOR_C   = YES
-ENABLE_PREPROCESSING= YES
-MACRO_EXPANSION = YES
-EXPAND_ONLY_PREDEF  = YES
-EXTRACT_STATIC  = YES
-DISTRIBUTE_GROUP_DOC= YES
-HIDE_UNDOC_MEMBERS  = YES
-HIDE_UNDOC_CLASSES  = YES
-HIDE_SCOPE_NAMES= YES
-GENERATE_DEPRECATEDLIST = NO
-VERBATIM_HEADERS= NO
-ALPHABETICAL_INDEX  = NO
-
-HTML_TIMESTAMP  = NO
-HTML_DYNAMIC_SECTIONS   = YES
-SEARCHENGINE= NO
-SORT_MEMBER_DOCS= NO
-SOURCE_BROWSER  = YES
-
-EXAMPLE_PATH= examples
-EXAMPLE_PATTERNS= *.c
-EXAMPLE_RECURSIVE   = YES
diff --git a/doc/api/doxy-api.conf.in b/doc/api/doxy-api.conf.in
new file mode 100644
index 00..c3d8fdef18
--- /dev/null
+++ b/doc/api/doxy-api.conf.in
@@ -0,0 +1,96 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright 2013-2017 6WIND S.A.
+
+PROJECT_NAME= DPDK
+PROJECT_NUMBER  = @VERSION@
+INPUT   = @TOPDIR@/doc/api/doxy-api-index.md \
+  @TOPDIR@/drivers/crypto/scheduler \
+  @TOPDIR@/drivers/mempool/dpaa2 \
+  @TOPDIR@/drivers/net/bnxt \
+  @TOPDIR@/drivers/net/bonding \
+  @TOPDIR@/drivers/net/dpaa \
+  @TOPDIR@/drivers

[dpdk-dev] [PATCH v2 3/4] build: use same version as make showversion in Meson

2018-09-07 Thread Luca Boccassi
make showversion will print 18.11.0-rc0 but Meson sets 18.11-rc0,
causing among other things a difference in the generated documentation.

Fixes: 76b9d9de5c7d ("version: 18.11-rc0")

Signed-off-by: Luca Boccassi 
---
 meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meson.build b/meson.build
index 84af32ecef..e8640a 100644
--- a/meson.build
+++ b/meson.build
@@ -2,7 +2,7 @@
 # Copyright(c) 2017 Intel Corporation
 
 project('DPDK', 'C',
-   version: '18.11-rc0',
+   version: '18.11.0-rc0',
license: 'BSD',
default_options: ['buildtype=release', 'default_library=static'],
meson_version: '>= 0.41'
-- 
2.18.0



[dpdk-dev] [PATCH v2 1/4] mk: use script to generate examples.dox

2018-09-07 Thread Luca Boccassi
This will make it possible to generate the file in the same way from
Meson as well.

Signed-off-by: Luca Boccassi 
---
v2: simplified script by using exec > file

 doc/api/generate_examples.sh | 12 
 mk/rte.sdkdoc.mk |  5 +
 2 files changed, 13 insertions(+), 4 deletions(-)
 create mode 100755 doc/api/generate_examples.sh

diff --git a/doc/api/generate_examples.sh b/doc/api/generate_examples.sh
new file mode 100755
index 00..6fcfe513b6
--- /dev/null
+++ b/doc/api/generate_examples.sh
@@ -0,0 +1,12 @@
+#! /bin/sh -e
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright 2018 Luca Boccassi 
+
+EXAMPLES_DIR=$1
+API_EXAMPLES=$2
+
+exec > "${API_EXAMPLES}"
+printf '/**\n'
+printf '@page examples DPDK Example Programs\n\n'
+find "${EXAMPLES_DIR}" -type f -name '*.c' -printf '@example examples/%P\n' | 
LC_ALL=C sort
+printf '*/\n'
diff --git a/mk/rte.sdkdoc.mk b/mk/rte.sdkdoc.mk
index bd2e5763df..d023b720fe 100644
--- a/mk/rte.sdkdoc.mk
+++ b/mk/rte.sdkdoc.mk
@@ -63,10 +63,7 @@ api-html-clean:
 
 $(API_EXAMPLES): api-html-clean
$(Q)mkdir -p $(@D)
-   @printf '/**\n' > $(API_EXAMPLES)
-   @printf '@page examples DPDK Example Programs\n\n' >> $(API_EXAMPLES)
-   @find examples -type f -name '*.c' -printf '@example %p\n' | LC_ALL=C 
sort >> $(API_EXAMPLES)
-   @printf '*/\n' >> $(API_EXAMPLES)
+   $(Q)doc/api/generate_examples.sh examples $(API_EXAMPLES)
 
 guides-pdf-clean: guides-pdf-img-clean
 guides-pdf-img-clean:
-- 
2.18.0



Re: [dpdk-dev] [PATCH 1/4] mk: use script to generate examples.dox

2018-09-07 Thread Luca Boccassi
On Fri, 2018-09-07 at 17:13 +0100, Bruce Richardson wrote:
> On Mon, Sep 03, 2018 at 10:07:07AM +0100, Luca Boccassi wrote:
> > On Mon, 2018-09-03 at 02:54 +0200, Thomas Monjalon wrote:
> > > 31/08/2018 20:20, Luca Boccassi:
> > > > +# SC2129 - avoid multiple individual redirects
> > > 
> > > What is SC2129 ?
> > 
> > shellcheck - will clarify in v2
> > 
> > > > +{ \
> > > > +printf '/**\n'; \
> > > > +printf '@page examples DPDK Example Programs\n\n'; \
> > > > +find "${EXAMPLES_DIR}" -type f -name '*.c' -printf '@examp
> > > > le
> > > > examples/%P\n' | LC_ALL=C sort; \
> > > > +printf '*/\n'; \
> > > > +} > "${API_EXAMPLES}"
> > > 
> > > Why using backslashes (continuation lines)?
> > 
> > Good point, will remove in v2
> > 
> 
> Agree, rather than using continuation lines, I suggest one of the
> following:
> * use exec > ${API_EXAMPLES} at the top of the script
> * let the script just print to stdout and have make/meson put that in
> the
>   output file for you.
> 
> /Bruce

exec > works and checkbashism is also happy with it, so used that in v2

-- 
Kind regards,
Luca Boccassi


Re: [dpdk-dev] DPDK Shared lib: No Ethernet ports

2018-09-07 Thread Shubhachint, Chaitanya
Thank you for your reply Bruce. 
Still having issues with shared-lib DPDK. I tried both options and get two 
distinct issues. 
I tried running the l2fwd example with e1000 driver and get little farther. 
This time it does find the devices but there is an error with MBUF

root:build$./l2fwd -d 
/home/sp2/dpdk-18.08/x86_64-native-linuxapp-gcc/lib/librte_pmd_e1000.so
EAL: Detected 6 lcore(s)
EAL: Detected 1 NUMA nodes
EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
EAL: No free hugepages reported in hugepages-1048576kB
EAL: Probing VFIO support...
EAL: PCI device :00:19.0 on NUMA socket -1
EAL:   Invalid NUMA socket, default to 0
EAL:   probe driver: 8086:1502 net_e1000_em
EAL: PCI device :06:00.0 on NUMA socket -1
EAL:   Invalid NUMA socket, default to 0
EAL:   probe driver: 8086:1521 net_e1000_igb
EAL: PCI device :06:00.1 on NUMA socket -1
EAL:   Invalid NUMA socket, default to 0
EAL:   probe driver: 8086:1521 net_e1000_igb
EAL: PCI device :06:00.2 on NUMA socket -1
EAL:   Invalid NUMA socket, default to 0
EAL:   probe driver: 8086:1521 net_e1000_igb
EAL: PCI device :06:00.3 on NUMA socket -1
EAL:   Invalid NUMA socket, default to 0
EAL:   probe driver: 8086:1521 net_e1000_igb
EAL: PCI device :08:00.0 on NUMA socket -1
EAL:   Invalid NUMA socket, default to 0
EAL:   probe driver: 8086:10d3 net_e1000_em
MAC updating enabled
MBUF: error setting mempool handler
EAL: Error - exiting with code: 1
  Cause: Cannot init mbuf pool

2nd Option of setting CONFIG_RTE_EAL_PMD_PATH option is ideal, but I run into 
issue with as well. I am configuring and installing the DPDK with 
CONFIG_RTE_EAL_PMD_PATH set as 
CONFIG_RTE_EAL_PMD_PATH=$(HOME)/dpdk-18.08/x86_64-native-linuxapp-gcc/lib

I this case I get following error when I run l2fwd

root:build$./l2fwd 
EAL: Detected 6 lcore(s)
EAL: Detected 1 NUMA nodes
EAL: /home/sp2/dpdk-18.08/x86_64-native-linuxapp-gcc/lib/libdpdk.so: invalid 
ELF header
EAL: FATAL: Cannot init plugins

EAL: Cannot init plugins

EAL: Error - exiting with code: 1
  Cause: Invalid EAL arguments

Regards,
Chai

-Original Message-
From: Richardson, Bruce  
Sent: Friday, September 07, 2018 09:22 AM
To: Shubhachint, Chaitanya ; dev@dpdk.org
Subject: RE: DPDK Shared lib: No Ethernet ports

[EXTERNAL EMAIL]



> -Original Message-
> From: dev [mailto:dev-boun...@dpdk.org] On Behalf Of Shubhachint, 
> Chaitanya
> Sent: Friday, September 7, 2018 3:18 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] DPDK Shared lib: No Ethernet ports
> 
> Hello,
> 
> I recently started working with DPDK and gone through the initial 
> steps of getting source code installed and trying out few examples. To 
> integrate DPDK with our product, I need to build the share-lib version of 
> DPDK.
> I run into an issue when I build DPDK as shared, I don't see this 
> issue when DPDK is built as static. DPDK built with default 
> configuration, I can run the examples and get expected results. When 
> built as shared, EAL detects no Ethernet ports.
> 
> I am building shared-lib version using steps below:
> . switch the CONFIG_RTE_BUILD_SHARED_LIB to y in the config/common_base .
> make config T=x86_64-native-linuxapp-gcc . make install 
> T=x86_64-native- linuxapp-gcc . export RTE_SDK=$HOME/dpdk-18.08 . 
> export RTE_TARGET=x86_64- native-linuxapp-gcc . build examples.
> . Set LD_LIBRARY_PATH to point to $HOME/dpdk-18.08/ x86_64-native- 
> linuxapp-gcc/lib
> 
> I am using Intel I350 Quad port NIC, and have switched to 
> uio_pci_generic driver => Network devices using DPDK-compatible driver 
> 
> :06:00.0 'I350 Gigabit Network Connection 1521' 
> drv=uio_pci_generic unused=igb
> :06:00.1 'I350 Gigabit Network Connection 1521' 
> drv=uio_pci_generic unused=igb
> :06:00.2 'I350 Gigabit Network Connection 1521' 
> drv=uio_pci_generic unused=igb
> :06:00.3 'I350 Gigabit Network Connection 1521' 
> drv=uio_pci_generic unused=igb
> 
> When I run any examples, I get error 'No Ethernet ports'.
> 
> root:l2fwd$./build/l2fwd
> EAL: Detected 6 lcore(s)
> EAL: Detected 1 NUMA nodes
> EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
> EAL: No free hugepages reported in hugepages-1048576kB
> EAL: Probing VFIO support...
> MAC updating enabled
> EAL: Error - exiting with code: 1
>   Cause: No Ethernet ports - bye
> 
> Interestingly, same code base built with 'CONFIG_RTE_BUILD_SHARED_LIB=n'
> works just fine. The ports get detected correctly and I can run all 
> the examples and applications.
> 
> Your help is appreciated.

With shared library builds, the drivers are not linked in automatically. You 
need to explicitly load them via "-d" EAL flag - either individually or by 
passing in the path to a directory of drivers which can be loaded. See also in 
the build config the setting "CONFIG_RTE_EAL_PMD_PATH" which can be used to set 
a default search path for loading drivers.

Regards,
/Bruce


[dpdk-dev] [PATCH v1 0/2] FIPS validation capability

2018-09-07 Thread Marko Kovacevic
Adding capability into DPDK to allow certification for FIPS
validation, I have just added one test for one algo will be adding other
algos into other versions of the patch and i will be refactoring the code and
cleaning the parser once i start adding the different algos.

Marko Kovacevic (2):
  test/test: cryptodev application for FIPS certification
  test/test: cryptodev application parser for FIPS certification

 test/test/Makefile   |   4 +
 test/test/test_cryptodev_fips.c  | 771 +++
 test/test/test_cryptodev_fips_parse.h| 156 ++
 test/test/test_cryptodev_fips_parse_aes.c| 399 ++
 test/test/test_cryptodev_fips_parse_common.c | 330 
 5 files changed, 1660 insertions(+)
 create mode 100644 test/test/test_cryptodev_fips.c
 create mode 100644 test/test/test_cryptodev_fips_parse.h
 create mode 100644 test/test/test_cryptodev_fips_parse_aes.c
 create mode 100644 test/test/test_cryptodev_fips_parse_common.c

-- 
2.9.5



[dpdk-dev] [PATCH v1 2/2] test/test: cryptodev application parser for FIPS certification

2018-09-07 Thread Marko Kovacevic
Added parser to parser required request file which has
different algos required by the fips certification
and to generate the response file needed.

Signed-off-by: Marko Kovacevic 
---
 test/test/Makefile   |   3 +
 test/test/test_cryptodev_fips_parse.h| 156 +++
 test/test/test_cryptodev_fips_parse_aes.c| 399 +++
 test/test/test_cryptodev_fips_parse_common.c | 330 ++
 4 files changed, 888 insertions(+)
 create mode 100644 test/test/test_cryptodev_fips_parse.h
 create mode 100644 test/test/test_cryptodev_fips_parse_aes.c
 create mode 100644 test/test/test_cryptodev_fips_parse_common.c

diff --git a/test/test/Makefile b/test/test/Makefile
index ee74450..9d6abb5 100644
--- a/test/test/Makefile
+++ b/test/test/Makefile
@@ -183,6 +183,9 @@ SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += 
test_cryptodev_blockcipher.c
 SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev.c
 SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev_asym.c
 SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev_fips.c
+SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev_fips_parse_common.c
+SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev_fips_parse_aes.c
+
 
 ifeq ($(CONFIG_RTE_COMPRESSDEV_TEST),y)
 SRCS-$(CONFIG_RTE_LIBRTE_COMPRESSDEV) += test_compressdev.c
diff --git a/test/test/test_cryptodev_fips_parse.h 
b/test/test/test_cryptodev_fips_parse.h
new file mode 100644
index 000..edb1d41
--- /dev/null
+++ b/test/test/test_cryptodev_fips_parse.h
@@ -0,0 +1,156 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 Intel Corporation
+ */
+#ifndef _TEST_CRYPTODEV_FIPS_PARSE_
+#define _TEST_CRYPTODEV_FIPS_PARSE_
+
+#include 
+
+#define FIPS_PARSE_ERR(line, fmt, args...) \
+   RTE_LOG(ERR, USER1, "[%s] %s() line %u: Error in file line %u " \
+   fmt "\n", "FIPS", __func__, __LINE__, line, ## args)
+
+#define ERR_MSG_SIZE   128
+#define MAX_CASE_LINE  15
+#define MAX_NB_CHAR1024 /*< maximum number of characters per line */
+#define MAX_NB_TESTS   10240
+#define MAX_BUF_SIZE   2048 /*< maximum plain/cipher text size */
+#define MAX_KEY_LEN64
+#define MAX_IV_LEN 256
+
+#define POSITIVE_TEST  0
+#define NEGATIVE_TEST  -1
+
+#define REQ_FILE_PERFIX"req"
+#define RSP_FILE_PERFIX"rsp"
+#define FAX_FILE_PERFIX"fax"
+
+#define HEADER_IND "#"
+#define GEN_TIME_STR   "# Generated on "
+
+enum file_types {
+   FIPS_FILE_TYPE_REQ = 1,
+   FIPS_FILE_TYPE_FAX,
+   FIPS_FILE_TYPE_RSP
+};
+
+struct fips_aes_test_case {
+   char case_desc[MAX_CASE_LINE][MAX_NB_CHAR];
+#define AESAVS_OP_ENC  1
+#define AESAVS_OP_DEC  2
+   enum rte_crypto_cipher_operation test_op;
+   uint8_t key[MAX_KEY_LEN];
+   uint8_t iv[MAX_IV_LEN];
+   uint32_t iv_len;
+   uint8_t plaintext[MAX_BUF_SIZE];
+   uint32_t plaintext_len;
+   uint8_t ciphertext[MAX_BUF_SIZE];
+   uint32_t ciphertext_len;
+   uint32_t count;
+   uint32_t skip_flag;
+};
+
+/* AES TEST DATA */
+struct fips_aes_test_data {
+   enum file_types f_type;
+   char file_header[MAX_CASE_LINE][MAX_NB_CHAR];
+
+/* follow the sequence as test_type_strings declared above */
+#define AESAVS_TYPE_GFXBOX 0
+#define AESAVS_TYPE_KEYSBOX1
+#define AESAVS_TYPE_VARKEY 2
+#define AESAVS_TYPE_VARTXT 3
+#define AESAVS_TYPE_MMT4
+#define AESAVS_TYPE_MCT5
+   uint32_t test_type;
+
+   /* *_algo == 0 means no algo */
+   enum rte_crypto_cipher_algorithm cipher_algo;
+   enum rte_crypto_auth_algorithm auth_algo;
+
+   uint32_t key_len;
+
+   uint32_t nb_test_cases;
+
+   struct fips_aes_test_case test_cases[MAX_NB_TESTS];
+};
+
+/**
+ * INTERNAL APIS, used for other parsers
+ */
+int
+fips_get_file_line(FILE **fp, char *line,  uint32_t max_line_char);
+
+int
+parser_read_uint64(uint64_t *value, const char *p);
+
+int
+parser_read_uint64_hex(uint64_t *value, const char *p);
+
+int
+parser_read_uint32(uint32_t *value, const char *p);
+
+int
+parser_read_uint32_hex(uint32_t *value, const char *p);
+
+int
+parser_read_uint16(uint16_t *value, const char *p);
+
+int
+parser_read_uint16_hex(uint16_t *value, const char *p);
+
+int
+parser_read_uint8(uint8_t *value, const char *p);
+
+int
+parser_read_uint8_hex(uint8_t *value, const char *p);
+
+int
+parse_uint8_hex_str(uint8_t *dst, char *src, uint32_t max_len);
+
+enum file_types
+parse_file_type(const char *path);
+
+int
+fetch_block(FILE **fp, char *line[MAX_CASE_LINE], uint32_t from_line,
+   const char *trigger, uint32_t max_nb_line_char);
+
+void
+copy_block(char dst[][MAX_NB_CHAR], char *src[MAX_CASE_LINE],
+   uint32_t nb_lines, uint32_t max_nb_line_char);
+
+void
+write_block_to_file(FILE *fp, char from[][MAX_NB_CHAR]);
+
+void
+write_uint8_str_to_file(FILE *fp, const uint8_t *from, uint32_t size);
+
+int
+alloc_line_block_mem(

[dpdk-dev] [PATCH v1 1/2] test/test: cryptodev application for FIPS certification

2018-09-07 Thread Marko Kovacevic
Adding initial set up for the FIPS ceritifcation into DPDK,
more algos will be added in other versions of the code.
Also documentation will be added with steps on how to run.

Signed-off-by: Marko Kovacevic 
---
 test/test/Makefile  |   1 +
 test/test/test_cryptodev_fips.c | 771 
 2 files changed, 772 insertions(+)
 create mode 100644 test/test/test_cryptodev_fips.c

diff --git a/test/test/Makefile b/test/test/Makefile
index e6967ba..ee74450 100644
--- a/test/test/Makefile
+++ b/test/test/Makefile
@@ -182,6 +182,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_PMD_RING) += test_pmd_ring_perf.c
 SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev_blockcipher.c
 SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev.c
 SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev_asym.c
+SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev_fips.c
 
 ifeq ($(CONFIG_RTE_COMPRESSDEV_TEST),y)
 SRCS-$(CONFIG_RTE_LIBRTE_COMPRESSDEV) += test_compressdev.c
diff --git a/test/test/test_cryptodev_fips.c b/test/test/test_cryptodev_fips.c
new file mode 100644
index 000..4bfc24e
--- /dev/null
+++ b/test/test/test_cryptodev_fips.c
@@ -0,0 +1,771 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 Intel Corporation
+ */
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include "test.h"
+#include "test_cryptodev.h"
+#include "test_cryptodev_fips_parse.h"
+
+#define AES_IV_LENGTH16
+#define AES_BLOCK_LENGTH 16
+#define AES_MCT_NUM_INTERNAL_ITER 1000
+#define AES_MCT_NUM_EXTERNAL_ITER 100
+
+
+
+struct crypto_testsuite_params {
+   struct rte_mempool *mbuf_pool;
+   struct rte_mempool *op_mpool;
+   struct rte_mempool *session_mpool;
+   struct rte_cryptodev_config conf;
+   struct rte_cryptodev_qp_conf qp_conf;
+   uint8_t enabled_devs[RTE_CRYPTO_MAX_DEVS];
+   uint8_t nb_enabled_devs;
+};
+
+static struct crypto_testsuite_params testsuite_params = { NULL };
+
+static int
+fips_testsuite_setup(void)
+{
+   struct crypto_testsuite_params *ts_params = &testsuite_params;
+   uint8_t nb_devs;
+   uint8_t dev_id, i;
+   uint32_t max_session_size = 0;
+
+   memset(ts_params, 0, sizeof(*ts_params));
+
+   ts_params->mbuf_pool = rte_mempool_lookup("mbuf pool");
+   if (ts_params->mbuf_pool == NULL) {
+   /* Not already created so create */
+   ts_params->mbuf_pool = rte_pktmbuf_pool_create(
+   "Mbuf pool",
+   1, 0, 0, UINT16_MAX,
+   rte_socket_id());
+   if (ts_params->mbuf_pool == NULL) {
+   RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
+   return TEST_FAILED;
+   }
+   }
+
+   ts_params->op_mpool = rte_crypto_op_pool_create(
+   "Op pool",
+   RTE_CRYPTO_OP_TYPE_SYMMETRIC,
+   1, 0,
+   MAXIMUM_IV_LENGTH,
+   rte_socket_id());
+   if (ts_params->op_mpool == NULL) {
+   RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
+   return TEST_FAILED;
+   }
+
+   nb_devs = rte_cryptodev_count();
+   if (nb_devs < 1) {
+   RTE_LOG(ERR, USER1, "No crypto devices found?\n");
+   return TEST_FAILED;
+   }
+
+   ts_params->conf.nb_queue_pairs = 1;
+   ts_params->conf.socket_id = SOCKET_ID_ANY;
+
+   struct rte_cryptodev_sym_capability_idx cap_idx;
+
+   /* Configure device capable of encrypting with AES-CBC */
+   for (dev_id = 0; dev_id < nb_devs; dev_id++) {
+   cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
+   cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
+   if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) != NULL) 
{
+   ts_params->enabled_devs[ts_params->nb_enabled_devs] = 
dev_id;
+   (ts_params->nb_enabled_devs)++;
+   break;
+   }
+   }
+
+   if (dev_id == nb_devs)
+   RTE_LOG(WARNING, USER1, "There is no device that supports 
AES-CBC\n");
+
+   /* Configure device capable of encrypting with AES-GCM */
+   for (dev_id = 0; dev_id < nb_devs; dev_id++) {
+   cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
+   cap_idx.algo.aead = RTE_CRYPTO_AEAD_AES_GCM;
+   if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) != NULL) 
{
+   for (i = 0; i < ts_params->nb_enabled_devs; i++)
+   if (ts_params->enabled_devs[i] == dev_id)
+   break;
+   if (i == ts_params->nb_enabled_devs) {
+   
ts_params->enabled_devs[ts_params->nb_enabled_devs] = dev_id;
+

[dpdk-dev] [PATCH 02/10] net/softnic: add meter profile

2018-09-07 Thread Jasvinder Singh
Implement meter profile add function.

Signed-off-by: Jasvinder Singh 
---
 drivers/net/softnic/rte_eth_softnic.c   |   3 +
 drivers/net/softnic/rte_eth_softnic_internals.h |  42 
 drivers/net/softnic/rte_eth_softnic_meter.c | 137 +++-
 3 files changed, 181 insertions(+), 1 deletion(-)

diff --git a/drivers/net/softnic/rte_eth_softnic.c 
b/drivers/net/softnic/rte_eth_softnic.c
index 659a1b4..d265d1a 100644
--- a/drivers/net/softnic/rte_eth_softnic.c
+++ b/drivers/net/softnic/rte_eth_softnic.c
@@ -186,6 +186,7 @@ pmd_dev_stop(struct rte_eth_dev *dev)
softnic_port_in_action_profile_free(p);
softnic_tap_free(p);
softnic_tmgr_free(p);
+   softnic_mtr_free(p);
softnic_link_free(p);
softnic_softnic_swq_free_keep_rxq_txq(p);
softnic_mempool_free(p);
@@ -296,6 +297,7 @@ pmd_init(struct pmd_params *params)
softnic_swq_init(p);
softnic_link_init(p);
softnic_tmgr_init(p);
+   softnic_mtr_init(p);
softnic_tap_init(p);
softnic_port_in_action_profile_init(p);
softnic_table_action_profile_init(p);
@@ -340,6 +342,7 @@ pmd_free(struct pmd_internals *p)
softnic_port_in_action_profile_free(p);
softnic_tap_free(p);
softnic_tmgr_free(p);
+   softnic_mtr_free(p);
softnic_link_free(p);
softnic_swq_free(p);
softnic_mempool_free(p);
diff --git a/drivers/net/softnic/rte_eth_softnic_internals.h 
b/drivers/net/softnic/rte_eth_softnic_internals.h
index 92be4e8..14ea57d 100644
--- a/drivers/net/softnic/rte_eth_softnic_internals.h
+++ b/drivers/net/softnic/rte_eth_softnic_internals.h
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "rte_eth_softnic.h"
 #include "conn.h"
@@ -68,6 +69,35 @@ struct flow_internals {
 };
 
 /**
+ * Meter
+ */
+
+/* MTR meter profile */
+struct softnic_mtr_meter_profile {
+   TAILQ_ENTRY(softnic_mtr_meter_profile) node;
+   uint32_t meter_profile_id;
+   struct rte_mtr_meter_profile params;
+   uint32_t n_users;
+};
+
+TAILQ_HEAD(softnic_mtr_meter_profile_list, softnic_mtr_meter_profile);
+
+/* MTR object */
+struct softnic_mtr {
+   TAILQ_ENTRY(softnic_mtr) node;
+   uint32_t mtr_id;
+   struct rte_mtr_params params;
+   struct rte_flow *flow;
+};
+
+TAILQ_HEAD(softnic_mtr_list, softnic_mtr);
+
+struct mtr_internals {
+   struct softnic_mtr_meter_profile_list meter_profiles;
+   struct softnic_mtr_list mtrs;
+};
+
+/**
  * MEMPOOL
  */
 struct softnic_mempool_params {
@@ -525,6 +555,8 @@ struct pmd_internals {
} soft;
 
struct flow_internals flow;
+   struct mtr_internals mtr;
+
struct softnic_conn *conn;
struct softnic_mempool_list mempool_list;
struct softnic_swq_list swq_list;
@@ -574,6 +606,16 @@ extern const struct rte_flow_ops pmd_flow_ops;
 /**
  * Meter
  */
+int
+softnic_mtr_init(struct pmd_internals *p);
+
+void
+softnic_mtr_free(struct pmd_internals *p);
+
+struct softnic_mtr_meter_profile *
+softnic_mtr_meter_profile_find(struct pmd_internals *p,
+   uint32_t meter_profile_id);
+
 extern const struct rte_mtr_ops pmd_mtr_ops;
 
 /**
diff --git a/drivers/net/softnic/rte_eth_softnic_meter.c 
b/drivers/net/softnic/rte_eth_softnic_meter.c
index 572288d..a80ebf7 100644
--- a/drivers/net/softnic/rte_eth_softnic_meter.c
+++ b/drivers/net/softnic/rte_eth_softnic_meter.c
@@ -11,10 +11,145 @@
 
 #include "rte_eth_softnic_internals.h"
 
+int
+softnic_mtr_init(struct pmd_internals *p)
+{
+   /* Initialize meter profiles list */
+   TAILQ_INIT(&p->mtr.meter_profiles);
+
+   /* Initialize MTR objects list */
+   TAILQ_INIT(&p->mtr.mtrs);
+
+   return 0;
+}
+
+void
+softnic_mtr_free(struct pmd_internals *p)
+{
+   /* Remove meter profiles */
+   for ( ; ; ) {
+   struct softnic_mtr_meter_profile *mp;
+
+   mp = TAILQ_FIRST(&p->mtr.meter_profiles);
+   if (mp == NULL)
+   break;
+
+   TAILQ_REMOVE(&p->mtr.meter_profiles, mp, node);
+   free(mp);
+   }
+
+   /* Remove MTR objects */
+   for ( ; ; ) {
+   struct softnic_mtr *m;
+
+   m = TAILQ_FIRST(&p->mtr.mtrs);
+   if (m == NULL)
+   break;
+
+   TAILQ_REMOVE(&p->mtr.mtrs, m, node);
+   free(m);
+   }
+}
+
+struct softnic_mtr_meter_profile *
+softnic_mtr_meter_profile_find(struct pmd_internals *p,
+   uint32_t meter_profile_id)
+{
+   struct softnic_mtr_meter_profile_list *mpl = &p->mtr.meter_profiles;
+   struct softnic_mtr_meter_profile *mp;
+
+   TAILQ_FOREACH(mp, mpl, node)
+   if (meter_profile_id == mp->meter_profile_id)
+   return mp;
+
+   return NULL;
+}
+
+static int
+meter_profile_check(struct rte_eth_dev *dev,
+   uint32_t meter_profile_id,
+   struct rte_mtr_meter_profile *profile,
+

[dpdk-dev] [PATCH 00/10] net/softnic: implement metering and policing API

2018-09-07 Thread Jasvinder Singh
This patchset adds the metering and policing API support for the
softnic. The metering and policing action can be enabled through the
flow rules.

This series is prepared on top of following patchset;
https://mails.dpdk.org/archives/dev/2018-September/110998.html

Jasvinder Singh (10):
  net/softnic: add metering and policing support
  net/softnic: add meter profile
  net/softnic: delete meter profile
  net/softnic: create meter object
  net/softnic: destroy meter object
  net/softnic: update meter profile
  net/softnic: update dscp table
  net/softnic: update policer actions
  net/softnic: meter stats read
  net/softnic: enable meter action using flow rule

 drivers/net/softnic/Makefile|   1 +
 drivers/net/softnic/meson.build |   1 +
 drivers/net/softnic/rte_eth_softnic.c   |  13 +
 drivers/net/softnic/rte_eth_softnic_flow.c  | 170 ++
 drivers/net/softnic/rte_eth_softnic_internals.h |  57 ++
 drivers/net/softnic/rte_eth_softnic_meter.c | 746 
 drivers/net/softnic/rte_eth_softnic_pipeline.c  |  13 +
 7 files changed, 1001 insertions(+)
 create mode 100644 drivers/net/softnic/rte_eth_softnic_meter.c

-- 
2.9.3



[dpdk-dev] [PATCH 08/10] net/softnic: update policer actions

2018-09-07 Thread Jasvinder Singh
Implement meter object policer actions function.

Signed-off-by: Jasvinder Singh 
---
 drivers/net/softnic/rte_eth_softnic_meter.c | 127 +++-
 1 file changed, 126 insertions(+), 1 deletion(-)

diff --git a/drivers/net/softnic/rte_eth_softnic_meter.c 
b/drivers/net/softnic/rte_eth_softnic_meter.c
index 9344f37..41af9c7 100644
--- a/drivers/net/softnic/rte_eth_softnic_meter.c
+++ b/drivers/net/softnic/rte_eth_softnic_meter.c
@@ -504,6 +504,131 @@ pmd_mtr_meter_dscp_table_update(struct rte_eth_dev *dev,
return 0;
 }
 
+static int
+softnic_table_policer_actions_update(struct pmd_internals *p,
+   struct softnic_mtr *m,
+   uint32_t action_mask,
+   enum rte_mtr_policer_action *actions,
+   struct rte_mtr_error *error)
+{
+   struct rte_flow *mflow = m->flow;
+   uint32_t i;
+   int status;
+
+   /* Update meter policer actions */
+   for (i = 0; i < RTE_MTR_COLORS; i++) {
+   if ((action_mask >> i) & 1)
+   mflow->action.mtr.mtr[0].policer[i] =
+   (enum rte_table_action_policer)actions[i];
+   }
+
+   /* Re-add new rule */
+   status = softnic_pipeline_table_rule_add(p,
+   mflow->pipeline->name,
+   mflow->table_id,
+   &mflow->match,
+   &mflow->action,
+   &mflow->data);
+   if (status) {
+   rte_mtr_error_set(error,
+   EINVAL,
+   RTE_MTR_ERROR_TYPE_UNSPECIFIED,
+   NULL,
+   "Pipeline table rule re-add failed");
+   return -1;
+   }
+
+   /* Reset the meter stats */
+   struct pipeline *pipeline = mflow->pipeline;
+   struct softnic_table *table = &pipeline->table[mflow->table_id];
+   uint32_t tc_mask = 1 << 0;
+
+   status = rte_table_action_meter_read(table->a,
+   mflow->data,
+   tc_mask,
+   NULL,
+   1);
+   if (status) {
+   rte_mtr_error_set(error,
+   EINVAL,
+   RTE_MTR_ERROR_TYPE_UNSPECIFIED,
+   NULL,
+   "Meter stats reset failed");
+   return -1;
+   }
+
+   return 0;
+}
+
+/* MTR object policer action update */
+static int
+pmd_mtr_policer_actions_update(struct rte_eth_dev *dev,
+   uint32_t mtr_id,
+   uint32_t action_mask,
+   enum rte_mtr_policer_action *actions,
+   struct rte_mtr_error *error)
+{
+   struct pmd_internals *p = dev->data->dev_private;
+   struct softnic_mtr *m;
+   uint32_t i;
+   int status;
+
+   /* MTR object id must be valid */
+   m = softnic_mtr_find(p, mtr_id);
+   if (m == NULL)
+   return -rte_mtr_error_set(error,
+   EEXIST,
+   RTE_MTR_ERROR_TYPE_MTR_ID,
+   NULL,
+   rte_strerror(EEXIST));
+
+   /* Policer actions */
+   if (actions == NULL)
+   return -rte_mtr_error_set(error,
+   EINVAL,
+   RTE_MTR_ERROR_TYPE_UNSPECIFIED,
+   NULL,
+   rte_strerror(EINVAL));
+
+   /* Valid Policer actions */
+   for (i = 0; i < RTE_MTR_COLORS; i++) {
+   if ((action_mask >> i) & 1) {
+   if (actions[i] != MTR_POLICER_ACTION_COLOR_GREEN  &&
+   actions[i] != MTR_POLICER_ACTION_COLOR_YELLOW &&
+   actions[i] != MTR_POLICER_ACTION_COLOR_RED &&
+   actions[i] != MTR_POLICER_ACTION_DROP)
+   return -rte_mtr_error_set(error,
+   EINVAL,
+   RTE_MTR_ERROR_TYPE_UNSPECIFIED,
+   NULL,
+   rte_strerror(EINVAL));
+   }
+   }
+
+   /* MTR object owner valid? */
+   if (m->flow) {
+   status = softnic_table_policer_actions_update(p,
+   m,
+   action_mask,
+   actions,
+   error);
+   if (status)
+   return -rte_mtr_error_set(error,
+   EINVAL,
+   RTE_MTR_ERROR_TYPE_UNSPECIFIED,
+   NULL,
+   rte_strerror(EINVAL));
+   }
+
+   /* Update MTR object policer actions */
+   for (i = 0; i < RTE_MTR_COLORS; i++) {
+   if ((action_mask >> i) & 1)
+   m->params.action[i] = actions[i];
+   }
+
+   return 0;
+}
+
 const struct rte_mtr_ops pmd_mtr_ops = {
.capabilities_get = NULL,
 
@@ -517,7 +642,7 @@ const

[dpdk-dev] [PATCH 07/10] net/softnic: update dscp table

2018-09-07 Thread Jasvinder Singh
Implement meter object dscp table update.

Signed-off-by: Jasvinder Singh 
---
 drivers/net/softnic/rte_eth_softnic_internals.h |  1 +
 drivers/net/softnic/rte_eth_softnic_meter.c | 53 -
 drivers/net/softnic/rte_eth_softnic_pipeline.c  |  1 +
 3 files changed, 54 insertions(+), 1 deletion(-)

diff --git a/drivers/net/softnic/rte_eth_softnic_internals.h 
b/drivers/net/softnic/rte_eth_softnic_internals.h
index 5995e61..037088b 100644
--- a/drivers/net/softnic/rte_eth_softnic_internals.h
+++ b/drivers/net/softnic/rte_eth_softnic_internals.h
@@ -455,6 +455,7 @@ struct softnic_table {
struct softnic_table_action_profile *ap;
struct rte_table_action *a;
struct flow_list flows;
+   struct rte_table_action_dscp_table dscp_table;
struct softnic_mtr_meter_profile_list meter_profiles;
 };
 
diff --git a/drivers/net/softnic/rte_eth_softnic_meter.c 
b/drivers/net/softnic/rte_eth_softnic_meter.c
index 3b05ad6..9344f37 100644
--- a/drivers/net/softnic/rte_eth_softnic_meter.c
+++ b/drivers/net/softnic/rte_eth_softnic_meter.c
@@ -453,6 +453,57 @@ pmd_mtr_meter_profile_update(struct rte_eth_dev *dev,
return 0;
 }
 
+/* MTR object meter DSCP table update */
+static int
+pmd_mtr_meter_dscp_table_update(struct rte_eth_dev *dev,
+   uint32_t mtr_id,
+   enum rte_mtr_color *dscp_table,
+   struct rte_mtr_error *error)
+{
+   struct pmd_internals *p = dev->data->dev_private;
+   struct softnic_mtr *m;
+
+   /* MTR object id must be valid */
+   m = softnic_mtr_find(p, mtr_id);
+   if (m == NULL)
+   return -rte_mtr_error_set(error,
+   EEXIST,
+   RTE_MTR_ERROR_TYPE_MTR_ID,
+   NULL,
+   rte_strerror(EEXIST));
+
+   /* MTR object owner valid? */
+   if (m->flow == NULL)
+   return 0;
+
+   /* Update the data plane table */
+   struct pipeline *pipeline = m->flow->pipeline;
+   struct softnic_table *table = &pipeline->table[m->flow->table_id];
+   struct rte_table_action_dscp_table dt;
+   uint32_t i;
+   int status;
+
+   memcpy(&dt, &table->dscp_table, sizeof(dt));
+
+   for (i = 0; i < RTE_DIM(dt.entry); i++)
+   dt.entry[i].color = (enum rte_meter_color)dscp_table[i];
+
+   status = rte_table_action_dscp_table_update(table->a,
+   UINT64_MAX,
+   &dt);
+   if (status)
+   return -rte_mtr_error_set(error,
+   EINVAL,
+   RTE_MTR_ERROR_TYPE_UNSPECIFIED,
+   NULL,
+   rte_strerror(EINVAL));
+
+   /* Update the current table */
+   memcpy(&table->dscp_table, &dt, sizeof(table->dscp_table));
+
+   return 0;
+}
+
 const struct rte_mtr_ops pmd_mtr_ops = {
.capabilities_get = NULL,
 
@@ -465,7 +516,7 @@ const struct rte_mtr_ops pmd_mtr_ops = {
.meter_disable = NULL,
 
.meter_profile_update = pmd_mtr_meter_profile_update,
-   .meter_dscp_table_update = NULL,
+   .meter_dscp_table_update = pmd_mtr_meter_dscp_table_update,
.policer_actions_update = NULL,
.stats_update = NULL,
 
diff --git a/drivers/net/softnic/rte_eth_softnic_pipeline.c 
b/drivers/net/softnic/rte_eth_softnic_pipeline.c
index 77911bb..7c54ca8 100644
--- a/drivers/net/softnic/rte_eth_softnic_pipeline.c
+++ b/drivers/net/softnic/rte_eth_softnic_pipeline.c
@@ -1001,6 +1001,7 @@ softnic_pipeline_table_create(struct pmd_internals 
*softnic,
table->a = action;
TAILQ_INIT(&table->flows);
TAILQ_INIT(&table->meter_profiles);
+   memset(&table->dscp_table, 0, sizeof(table->dscp_table));
pipeline->n_tables++;
 
return 0;
-- 
2.9.3



[dpdk-dev] [PATCH 06/10] net/softnic: update meter profile

2018-09-07 Thread Jasvinder Singh
Implement meter profile update function

Signed-off-by: Jasvinder Singh 
---
 drivers/net/softnic/rte_eth_softnic_internals.h |   5 +
 drivers/net/softnic/rte_eth_softnic_meter.c | 139 +++-
 drivers/net/softnic/rte_eth_softnic_pipeline.c  |  12 ++
 3 files changed, 155 insertions(+), 1 deletion(-)

diff --git a/drivers/net/softnic/rte_eth_softnic_internals.h 
b/drivers/net/softnic/rte_eth_softnic_internals.h
index 4e2ad56..5995e61 100644
--- a/drivers/net/softnic/rte_eth_softnic_internals.h
+++ b/drivers/net/softnic/rte_eth_softnic_internals.h
@@ -455,6 +455,7 @@ struct softnic_table {
struct softnic_table_action_profile *ap;
struct rte_table_action *a;
struct flow_list flows;
+   struct softnic_mtr_meter_profile_list meter_profiles;
 };
 
 struct pipeline {
@@ -620,6 +621,10 @@ struct softnic_mtr_meter_profile *
 softnic_mtr_meter_profile_find(struct pmd_internals *p,
uint32_t meter_profile_id);
 
+struct softnic_mtr_meter_profile *
+softnic_table_meter_profile_find(struct softnic_table *table,
+   uint32_t meter_profile_id);
+
 extern const struct rte_mtr_ops pmd_mtr_ops;
 
 /**
diff --git a/drivers/net/softnic/rte_eth_softnic_meter.c 
b/drivers/net/softnic/rte_eth_softnic_meter.c
index 48ec446..3b05ad6 100644
--- a/drivers/net/softnic/rte_eth_softnic_meter.c
+++ b/drivers/net/softnic/rte_eth_softnic_meter.c
@@ -316,6 +316,143 @@ pmd_mtr_destroy(struct rte_eth_dev *dev,
return 0;
 }
 
+struct softnic_mtr_meter_profile *
+softnic_table_meter_profile_find(struct softnic_table *table,
+   uint32_t meter_profile_id)
+{
+   struct softnic_mtr_meter_profile *mp;
+
+   TAILQ_FOREACH(mp, &table->meter_profiles, node)
+   if (mp->meter_profile_id == meter_profile_id)
+   return mp;
+
+   return NULL;
+}
+
+static int
+softnic_table_meter_profile_update(struct pmd_internals *p,
+   struct softnic_mtr *mtr,
+   uint32_t meter_profile_id,
+   struct rte_mtr_meter_profile *params,
+   struct rte_mtr_error *error)
+{
+   struct rte_flow *mflow = mtr->flow;
+   struct softnic_table *table = &mflow->pipeline->table[mflow->table_id];
+   struct softnic_mtr_meter_profile *mp;
+   int status, mp_mem_alloc = 0;
+
+   /* Find/allocate meter profile for table */
+   if (!softnic_table_meter_profile_find(table, meter_profile_id)) {
+   mp = calloc(1, sizeof(struct softnic_mtr_meter_profile));
+   if (mp == NULL) {
+   rte_mtr_error_set(error,
+   ENOMEM,
+   RTE_MTR_ERROR_TYPE_UNSPECIFIED,
+   NULL,
+   "Not enough table memory for meter profile");
+   return -1;
+   }
+   mp_mem_alloc = 1;
+
+   /* Fill in */
+   mp->meter_profile_id = meter_profile_id;
+   memcpy(&mp->params, params, sizeof(mp->params));
+
+   /* Add to list */
+   TAILQ_INSERT_TAIL(&table->meter_profiles, mp, node);
+   }
+
+   /* Update meter action */
+   mflow->action.mtr.mtr[0].meter_profile_id = meter_profile_id;
+
+   /* Re-add new rule */
+   status = softnic_pipeline_table_rule_add(p,
+   mflow->pipeline->name,
+   mflow->table_id,
+   &mflow->match,
+   &mflow->action,
+   &mflow->data);
+   if (status) {
+   if (mp_mem_alloc)
+   free(mp);
+
+   rte_mtr_error_set(error,
+   EINVAL,
+   RTE_MTR_ERROR_TYPE_UNSPECIFIED,
+   NULL,
+   "Pipeline table rule add failed");
+   return -1;
+   }
+
+   return 0;
+}
+
+/* MTR object meter profile update */
+static int
+pmd_mtr_meter_profile_update(struct rte_eth_dev *dev,
+   uint32_t mtr_id,
+   uint32_t meter_profile_id,
+   struct rte_mtr_error *error)
+{
+   struct pmd_internals *p = dev->data->dev_private;
+   struct softnic_mtr_meter_profile *mp, *mp_old;
+   struct softnic_mtr *m;
+   int status;
+
+   /* MTR object id must be valid */
+   m = softnic_mtr_find(p, mtr_id);
+   if (m == NULL)
+   return -rte_mtr_error_set(error,
+   EEXIST,
+   RTE_MTR_ERROR_TYPE_MTR_ID,
+   NULL,
+   rte_strerror(EEXIST));
+
+   /* Meter profile id must be valid */
+   mp = softnic_mtr_meter_profile_find(p, meter_profile_id);
+   if (mp == NULL)
+   return -rte_mtr_error_set(error,
+   EINVAL,
+   RTE_MTR_ERROR_TYPE_METER_PROFILE_ID,
+   NULL,
+   rte_strerror(EINVAL));
+
+   /* MTR object already set to meter profile id */
+   if (m->params.met

[dpdk-dev] [PATCH 03/10] net/softnic: delete meter profile

2018-09-07 Thread Jasvinder Singh
Implement meter profile delete function.

Signed-off-by: Jasvinder Singh 
---
 drivers/net/softnic/rte_eth_softnic_meter.c | 35 -
 1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/drivers/net/softnic/rte_eth_softnic_meter.c 
b/drivers/net/softnic/rte_eth_softnic_meter.c
index a80ebf7..1d6af0c 100644
--- a/drivers/net/softnic/rte_eth_softnic_meter.c
+++ b/drivers/net/softnic/rte_eth_softnic_meter.c
@@ -146,11 +146,44 @@ pmd_mtr_meter_profile_add(struct rte_eth_dev *dev,
return 0;
 }
 
+/* MTR meter profile delete */
+static int
+pmd_mtr_meter_profile_delete(struct rte_eth_dev *dev,
+   uint32_t meter_profile_id,
+   struct rte_mtr_error *error)
+{
+   struct pmd_internals *p = dev->data->dev_private;
+   struct softnic_mtr_meter_profile *mp;
+
+   /* Meter profile must exist */
+   mp = softnic_mtr_meter_profile_find(p, meter_profile_id);
+   if (mp == NULL)
+   return -rte_mtr_error_set(error,
+   EINVAL,
+   RTE_MTR_ERROR_TYPE_METER_PROFILE_ID,
+   NULL,
+   rte_strerror(EINVAL));
+
+   /* Check unused */
+   if (mp->n_users)
+   return -rte_mtr_error_set(error,
+   EBUSY,
+   RTE_MTR_ERROR_TYPE_METER_PROFILE_ID,
+   NULL,
+   rte_strerror(EBUSY));
+
+   /* Remove from list */
+   TAILQ_REMOVE(&p->mtr.meter_profiles, mp, node);
+   free(mp);
+
+   return 0;
+}
+
 const struct rte_mtr_ops pmd_mtr_ops = {
.capabilities_get = NULL,
 
.meter_profile_add = pmd_mtr_meter_profile_add,
-   .meter_profile_delete = NULL,
+   .meter_profile_delete = pmd_mtr_meter_profile_delete,
 
.create = NULL,
.destroy = NULL,
-- 
2.9.3



[dpdk-dev] [PATCH 05/10] net/softnic: destroy meter object

2018-09-07 Thread Jasvinder Singh
Implement meter object destroy function.

Signed-off-by: Jasvinder Singh 
---
 drivers/net/softnic/rte_eth_softnic_meter.c | 49 -
 1 file changed, 48 insertions(+), 1 deletion(-)

diff --git a/drivers/net/softnic/rte_eth_softnic_meter.c 
b/drivers/net/softnic/rte_eth_softnic_meter.c
index 261a6a3..48ec446 100644
--- a/drivers/net/softnic/rte_eth_softnic_meter.c
+++ b/drivers/net/softnic/rte_eth_softnic_meter.c
@@ -269,6 +269,53 @@ pmd_mtr_create(struct rte_eth_dev *dev,
return 0;
 }
 
+/* MTR object destroy */
+static int
+pmd_mtr_destroy(struct rte_eth_dev *dev,
+   uint32_t mtr_id,
+   struct rte_mtr_error *error)
+{
+   struct pmd_internals *p = dev->data->dev_private;
+   struct softnic_mtr_list *ml = &p->mtr.mtrs;
+   struct softnic_mtr_meter_profile *mp;
+   struct softnic_mtr *m;
+
+   /* MTR object must exist */
+   m = softnic_mtr_find(p, mtr_id);
+   if (m == NULL)
+   return -rte_mtr_error_set(error,
+   EEXIST,
+   RTE_MTR_ERROR_TYPE_MTR_ID,
+   NULL,
+   rte_strerror(EEXIST));
+
+   /* MTR object must not have any owner */
+   if (m->flow != NULL)
+   return -rte_mtr_error_set(error,
+   EINVAL,
+   RTE_MTR_ERROR_TYPE_UNSPECIFIED,
+   NULL,
+   rte_strerror(EINVAL));
+
+   /* Get meter profile */
+   mp = softnic_mtr_meter_profile_find(p, m->params.meter_profile_id);
+   if (mp == NULL)
+   return -rte_mtr_error_set(error,
+   EINVAL,
+   RTE_MTR_ERROR_TYPE_METER_PROFILE_ID,
+   NULL,
+   rte_strerror(EINVAL));
+
+   /* Update dependencies */
+   mp->n_users--;
+
+   /* Remove from list */
+   TAILQ_REMOVE(ml, m, node);
+   free(m);
+
+   return 0;
+}
+
 const struct rte_mtr_ops pmd_mtr_ops = {
.capabilities_get = NULL,
 
@@ -276,7 +323,7 @@ const struct rte_mtr_ops pmd_mtr_ops = {
.meter_profile_delete = pmd_mtr_meter_profile_delete,
 
.create = pmd_mtr_create,
-   .destroy = NULL,
+   .destroy = pmd_mtr_destroy,
.meter_enable = NULL,
.meter_disable = NULL,
 
-- 
2.9.3



[dpdk-dev] [PATCH 01/10] net/softnic: add metering and policing support

2018-09-07 Thread Jasvinder Singh
Enable metering and policing support for softnic.

Signed-off-by: Jasvinder Singh 
---
 drivers/net/softnic/Makefile|  1 +
 drivers/net/softnic/meson.build |  1 +
 drivers/net/softnic/rte_eth_softnic.c   | 10 
 drivers/net/softnic/rte_eth_softnic_internals.h |  5 
 drivers/net/softnic/rte_eth_softnic_meter.c | 31 +
 5 files changed, 48 insertions(+)
 create mode 100644 drivers/net/softnic/rte_eth_softnic_meter.c

diff --git a/drivers/net/softnic/Makefile b/drivers/net/softnic/Makefile
index 12515b1..720f067b 100644
--- a/drivers/net/softnic/Makefile
+++ b/drivers/net/softnic/Makefile
@@ -34,6 +34,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC) += 
rte_eth_softnic_pipeline.c
 SRCS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC) += rte_eth_softnic_thread.c
 SRCS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC) += rte_eth_softnic_cli.c
 SRCS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC) += rte_eth_softnic_flow.c
+SRCS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC) += rte_eth_softnic_meter.c
 SRCS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC) += parser.c
 SRCS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC) += conn.c
 
diff --git a/drivers/net/softnic/meson.build b/drivers/net/softnic/meson.build
index 56e5e2b..6b7a6cc 100644
--- a/drivers/net/softnic/meson.build
+++ b/drivers/net/softnic/meson.build
@@ -14,6 +14,7 @@ sources = files('rte_eth_softnic_tm.c',
'rte_eth_softnic_thread.c',
'rte_eth_softnic_cli.c',
'rte_eth_softnic_flow.c',
+   'rte_eth_softnic_meter.c',
'parser.c',
'conn.c')
 deps += ['pipeline', 'port', 'table', 'sched']
diff --git a/drivers/net/softnic/rte_eth_softnic.c 
b/drivers/net/softnic/rte_eth_softnic.c
index ae2a438..659a1b4 100644
--- a/drivers/net/softnic/rte_eth_softnic.c
+++ b/drivers/net/softnic/rte_eth_softnic.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "rte_eth_softnic.h"
 #include "rte_eth_softnic_internals.h"
@@ -228,6 +229,14 @@ pmd_tm_ops_get(struct rte_eth_dev *dev __rte_unused, void 
*arg)
return 0;
 }
 
+static int
+pmd_mtr_ops_get(struct rte_eth_dev *dev __rte_unused, void *arg)
+{
+   *(const struct rte_mtr_ops **)arg = &pmd_mtr_ops;
+
+   return 0;
+}
+
 static const struct eth_dev_ops pmd_ops = {
.dev_configure = pmd_dev_configure,
.dev_start = pmd_dev_start,
@@ -239,6 +248,7 @@ static const struct eth_dev_ops pmd_ops = {
.tx_queue_setup = pmd_tx_queue_setup,
.filter_ctrl = pmd_filter_ctrl,
.tm_ops_get = pmd_tm_ops_get,
+   .mtr_ops_get = pmd_mtr_ops_get,
 };
 
 static uint16_t
diff --git a/drivers/net/softnic/rte_eth_softnic_internals.h 
b/drivers/net/softnic/rte_eth_softnic_internals.h
index a1a2e15..92be4e8 100644
--- a/drivers/net/softnic/rte_eth_softnic_internals.h
+++ b/drivers/net/softnic/rte_eth_softnic_internals.h
@@ -572,6 +572,11 @@ flow_attr_map_get(struct pmd_internals *softnic,
 extern const struct rte_flow_ops pmd_flow_ops;
 
 /**
+ * Meter
+ */
+extern const struct rte_mtr_ops pmd_mtr_ops;
+
+/**
  * MEMPOOL
  */
 int
diff --git a/drivers/net/softnic/rte_eth_softnic_meter.c 
b/drivers/net/softnic/rte_eth_softnic_meter.c
new file mode 100644
index 000..572288d
--- /dev/null
+++ b/drivers/net/softnic/rte_eth_softnic_meter.c
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2017 Intel Corporation
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include "rte_eth_softnic_internals.h"
+
+const struct rte_mtr_ops pmd_mtr_ops = {
+   .capabilities_get = NULL,
+
+   .meter_profile_add = NULL,
+   .meter_profile_delete = NULL,
+
+   .create = NULL,
+   .destroy = NULL,
+   .meter_enable = NULL,
+   .meter_disable = NULL,
+
+   .meter_profile_update = NULL,
+   .meter_dscp_table_update = NULL,
+   .policer_actions_update = NULL,
+   .stats_update = NULL,
+
+   .stats_read = NULL,
+};
-- 
2.9.3



[dpdk-dev] [PATCH 04/10] net/softnic: create meter object

2018-09-07 Thread Jasvinder Singh
implement meter object create function.

Signed-off-by: Jasvinder Singh 
---
 drivers/net/softnic/rte_eth_softnic_internals.h |  4 ++
 drivers/net/softnic/rte_eth_softnic_meter.c | 92 -
 2 files changed, 95 insertions(+), 1 deletion(-)

diff --git a/drivers/net/softnic/rte_eth_softnic_internals.h 
b/drivers/net/softnic/rte_eth_softnic_internals.h
index 14ea57d..4e2ad56 100644
--- a/drivers/net/softnic/rte_eth_softnic_internals.h
+++ b/drivers/net/softnic/rte_eth_softnic_internals.h
@@ -612,6 +612,10 @@ softnic_mtr_init(struct pmd_internals *p);
 void
 softnic_mtr_free(struct pmd_internals *p);
 
+struct softnic_mtr *
+softnic_mtr_find(struct pmd_internals *p,
+   uint32_t mtr_id);
+
 struct softnic_mtr_meter_profile *
 softnic_mtr_meter_profile_find(struct pmd_internals *p,
uint32_t meter_profile_id);
diff --git a/drivers/net/softnic/rte_eth_softnic_meter.c 
b/drivers/net/softnic/rte_eth_softnic_meter.c
index 1d6af0c..261a6a3 100644
--- a/drivers/net/softnic/rte_eth_softnic_meter.c
+++ b/drivers/net/softnic/rte_eth_softnic_meter.c
@@ -179,13 +179,103 @@ pmd_mtr_meter_profile_delete(struct rte_eth_dev *dev,
return 0;
 }
 
+struct softnic_mtr *
+softnic_mtr_find(struct pmd_internals *p, uint32_t mtr_id)
+{
+   struct softnic_mtr_list *ml = &p->mtr.mtrs;
+   struct softnic_mtr *m;
+
+   TAILQ_FOREACH(m, ml, node)
+   if (m->mtr_id == mtr_id)
+   return m;
+
+   return NULL;
+}
+
+
+/* MTR object create */
+static int
+pmd_mtr_create(struct rte_eth_dev *dev,
+   uint32_t mtr_id,
+   struct rte_mtr_params *params,
+   int shared,
+   struct rte_mtr_error *error)
+{
+   struct pmd_internals *p = dev->data->dev_private;
+   struct softnic_mtr_list *ml = &p->mtr.mtrs;
+   struct softnic_mtr_meter_profile *mp;
+   struct softnic_mtr *m;
+
+   /* MTR id valid  */
+   if (softnic_mtr_find(p, mtr_id))
+   return -rte_mtr_error_set(error,
+   EEXIST,
+   RTE_MTR_ERROR_TYPE_MTR_ID,
+   NULL,
+   rte_strerror(EEXIST));
+
+   /* MTR params must not be NULL */
+   if (params == NULL)
+   return -rte_mtr_error_set(error,
+   EINVAL,
+   RTE_MTR_ERROR_TYPE_MTR_PARAMS,
+   NULL,
+   rte_strerror(EINVAL));
+
+   /* Meter profile must exist */
+   mp = softnic_mtr_meter_profile_find(p, params->meter_profile_id);
+   if (mp == NULL)
+   return -rte_mtr_error_set(error,
+   EINVAL,
+   RTE_MTR_ERROR_TYPE_METER_PROFILE_ID,
+   NULL,
+   rte_strerror(EINVAL));
+
+   /* Previous meter color not supported */
+   if (params->use_prev_mtr_color)
+   return -rte_mtr_error_set(error,
+   EINVAL,
+   RTE_MTR_ERROR_TYPE_MTR_PARAMS,
+   NULL,
+   rte_strerror(EINVAL));
+
+   /* Shared MTR object not supported */
+   if (shared)
+   return -rte_mtr_error_set(error,
+   EINVAL,
+   RTE_MTR_ERROR_TYPE_SHARED,
+   NULL,
+   rte_strerror(EINVAL));
+
+   /* Memory allocation */
+   m = calloc(1, sizeof(struct softnic_mtr));
+   if (m == NULL)
+   return -rte_mtr_error_set(error,
+   ENOMEM,
+   RTE_MTR_ERROR_TYPE_UNSPECIFIED,
+   NULL,
+   rte_strerror(ENOMEM));
+
+   /* Fill in */
+   m->mtr_id = mtr_id;
+   memcpy(&m->params, params, sizeof(m->params));
+
+   /* Add to list */
+   TAILQ_INSERT_TAIL(ml, m, node);
+
+   /* Update dependencies */
+   mp->n_users++;
+
+   return 0;
+}
+
 const struct rte_mtr_ops pmd_mtr_ops = {
.capabilities_get = NULL,
 
.meter_profile_add = pmd_mtr_meter_profile_add,
.meter_profile_delete = pmd_mtr_meter_profile_delete,
 
-   .create = NULL,
+   .create = pmd_mtr_create,
.destroy = NULL,
.meter_enable = NULL,
.meter_disable = NULL,
-- 
2.9.3



[dpdk-dev] [PATCH 09/10] net/softnic: meter stats read

2018-09-07 Thread Jasvinder Singh
Implement meter object stats read function.

Signed-off-by: Jasvinder Singh 
---
 drivers/net/softnic/rte_eth_softnic_meter.c | 99 -
 1 file changed, 98 insertions(+), 1 deletion(-)

diff --git a/drivers/net/softnic/rte_eth_softnic_meter.c 
b/drivers/net/softnic/rte_eth_softnic_meter.c
index 41af9c7..2cea19f 100644
--- a/drivers/net/softnic/rte_eth_softnic_meter.c
+++ b/drivers/net/softnic/rte_eth_softnic_meter.c
@@ -629,6 +629,103 @@ pmd_mtr_policer_actions_update(struct rte_eth_dev *dev,
return 0;
 }
 
+/* MTR object stats read */
+static int
+pmd_mtr_stats_read(struct rte_eth_dev *dev,
+   uint32_t mtr_id,
+   struct rte_mtr_stats *stats,
+   uint64_t *stats_mask,
+   int clear,
+   struct rte_mtr_error *error)
+{
+   struct pmd_internals *p = dev->data->dev_private;
+   struct softnic_mtr *m;
+   uint32_t i;
+   int status;
+
+   /* MTR object id must be valid */
+   m = softnic_mtr_find(p, mtr_id);
+   if (m == NULL)
+   return -rte_mtr_error_set(error,
+   EEXIST,
+   RTE_MTR_ERROR_TYPE_MTR_ID,
+   NULL,
+   rte_strerror(EEXIST));
+
+   /* MTR meter object owner valid? */
+   if (m->flow == NULL)
+   return 0;
+
+   /* Meter stats */
+   struct pipeline *pipeline = m->flow->pipeline;
+   struct softnic_table *table = &pipeline->table[m->flow->table_id];
+   struct rte_table_action_mtr_counters counters;
+   uint32_t tc_mask = 1 << 0;
+
+   status = rte_table_action_meter_read(table->a,
+   m->flow->data,
+   tc_mask,
+   &counters,
+   clear);
+   if (status) {
+   rte_mtr_error_set(error,
+   EINVAL,
+   RTE_MTR_ERROR_TYPE_UNSPECIFIED,
+   NULL,
+   "Meter stats read failed");
+   return -1;
+   }
+
+   if (stats) {
+   struct rte_table_action_mtr_counters_tc tc_stats;
+
+   memcpy(&tc_stats, &counters.stats[tc_mask], sizeof(tc_stats));
+
+   for (i = 0; i < RTE_MTR_COLORS; i++) {
+   if (m->params.action[i] == 
MTR_POLICER_ACTION_COLOR_GREEN) {
+   stats->n_pkts[RTE_MTR_GREEN] += 
tc_stats.n_packets[i];
+   stats->n_bytes[RTE_MTR_GREEN] += 
tc_stats.n_bytes[i];
+   }
+
+   if (m->params.action[i] == 
MTR_POLICER_ACTION_COLOR_YELLOW) {
+   stats->n_pkts[RTE_MTR_YELLOW] += 
tc_stats.n_packets[i];
+   stats->n_bytes[RTE_MTR_YELLOW] += 
tc_stats.n_bytes[i];
+   }
+
+   if (m->params.action[i] == 
MTR_POLICER_ACTION_COLOR_RED) {
+   stats->n_pkts[RTE_MTR_RED] += 
tc_stats.n_packets[i];
+   stats->n_bytes[RTE_MTR_RED] += 
tc_stats.n_bytes[i];
+   }
+
+   if (m->params.action[i] == MTR_POLICER_ACTION_DROP) {
+   stats->n_pkts_dropped += tc_stats.n_packets[i];
+   stats->n_bytes_dropped += tc_stats.n_bytes[i];
+   }
+   }
+   }
+
+   if (stats_mask) {
+   if (stats->n_pkts[RTE_MTR_GREEN])
+   *stats_mask |= RTE_MTR_STATS_N_PKTS_GREEN;
+   if (stats->n_pkts[RTE_MTR_YELLOW])
+   *stats_mask |= RTE_MTR_STATS_N_PKTS_YELLOW;
+   if (stats->n_pkts[RTE_MTR_RED])
+   *stats_mask |= RTE_MTR_STATS_N_PKTS_RED;
+   if (stats->n_bytes[RTE_MTR_GREEN])
+   *stats_mask |= RTE_MTR_STATS_N_BYTES_GREEN;
+   if (stats->n_bytes[RTE_MTR_YELLOW])
+   *stats_mask |= RTE_MTR_STATS_N_BYTES_YELLOW;
+   if (stats->n_bytes[RTE_MTR_RED])
+   *stats_mask |= RTE_MTR_STATS_N_BYTES_RED;
+   if (stats->n_pkts_dropped)
+   *stats_mask |= RTE_MTR_STATS_N_PKTS_DROPPED;
+   if (stats->n_bytes_dropped)
+   *stats_mask |= RTE_MTR_STATS_N_BYTES_DROPPED;
+   }
+
+   return 0;
+}
+
 const struct rte_mtr_ops pmd_mtr_ops = {
.capabilities_get = NULL,
 
@@ -645,5 +742,5 @@ const struct rte_mtr_ops pmd_mtr_ops = {
.policer_actions_update = pmd_mtr_policer_actions_update,
.stats_update = NULL,
 
-   .stats_read = NULL,
+   .stats_read = pmd_mtr_stats_read,
 };
-- 
2.9.3



[dpdk-dev] [PATCH 10/10] net/softnic: enable meter action using flow rule

2018-09-07 Thread Jasvinder Singh
Implement meter enablement through flow rules.

Signed-off-by: Jasvinder Singh 
---
 drivers/net/softnic/rte_eth_softnic_flow.c | 170 +
 1 file changed, 170 insertions(+)

diff --git a/drivers/net/softnic/rte_eth_softnic_flow.c 
b/drivers/net/softnic/rte_eth_softnic_flow.c
index 6562004..0f33381 100644
--- a/drivers/net/softnic/rte_eth_softnic_flow.c
+++ b/drivers/net/softnic/rte_eth_softnic_flow.c
@@ -1459,6 +1459,117 @@ flow_rule_action_get(struct pmd_internals *softnic,
break;
} /* RTE_FLOW_ACTION_TYPE_COUNT */
 
+   case RTE_FLOW_ACTION_TYPE_METER:
+   {
+   struct rte_table_action_mtr_tc_params mtr_tc_params;
+   const struct rte_flow_action_meter *conf = action->conf;
+   struct softnic_mtr *m;
+   struct softnic_mtr_meter_profile *mp;
+   uint32_t meter_profile_id;
+
+   if (conf == NULL)
+   return rte_flow_error_set(error,
+   EINVAL,
+   RTE_FLOW_ERROR_TYPE_ACTION,
+   action,
+   "COUNT: Null configuration");
+
+   if ((params->action_mask & (1LLU << 
RTE_TABLE_ACTION_MTR)) == 0)
+   return rte_flow_error_set(error,
+   EINVAL,
+   RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+   NULL,
+   "METER action not supported by this 
table");
+
+   m = softnic_mtr_find(softnic, conf->mtr_id);
+   if (m == NULL)
+   return -rte_flow_error_set(error,
+   EINVAL,
+   RTE_FLOW_ERROR_TYPE_ACTION_CONF,
+   NULL,
+   rte_strerror(EINVAL));
+
+   if (params->mtr.n_tc != 1)
+   return -rte_flow_error_set(error,
+   EINVAL,
+   RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+   NULL,
+   rte_strerror(EINVAL));
+
+   meter_profile_id = m->params.meter_profile_id;
+
+   mp = softnic_table_meter_profile_find(table, 
meter_profile_id);
+   if (mp == NULL) {
+   struct softnic_mtr_meter_profile 
*mtr_meter_profile;
+   struct rte_table_action_meter_profile profile;
+   int status;
+
+   mp = calloc(1, sizeof(struct 
softnic_mtr_meter_profile));
+   if (mp == NULL) {
+   rte_flow_error_set(error,
+   ENOMEM,
+   RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+   NULL,
+   "Not enough table memory for 
meter profile");
+   return -1;
+   }
+
+   mtr_meter_profile = 
softnic_mtr_meter_profile_find(softnic,
+   meter_profile_id);
+   if (mtr_meter_profile == NULL) {
+   free(mp);
+
+   rte_flow_error_set(error,
+   EINVAL,
+   RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+   NULL,
+   rte_strerror(EINVAL));
+   return -1;
+   }
+
+   mp->meter_profile_id = meter_profile_id;
+   mp->n_users = mtr_meter_profile->n_users;
+   memcpy(&mp->params, &mtr_meter_profile->params,
+   sizeof(mp->params));
+
+   profile.alg = RTE_TABLE_ACTION_METER_TRTCM;
+   memcpy(&profile.trtcm, 
&mp->params.trtcm_rfc2698,
+   sizeof(profile.trtcm));
+
+   status = 
rte_table_action_meter_profile_add(table->a,
+   meter_profile_id,
+   &profile);
+   if (status) {
+   free(mp);
+
+ 

[dpdk-dev] [PATCH] build: add PPC64 Meson build

2018-09-07 Thread Luca Boccassi
This has been only build-tested for now, on a native ppc64el POWER8E
machine running Debian sid.

Signed-off-by: Luca Boccassi 
---
The build box cannot be used to run DPDK as it doesn't have supported
NICs and root access. Would be great if someone could run-test it, but
at this point I think build support is enough to get started.

 config/meson.build   |  8 
 config/ppc_64/meson.build| 15 +++
 lib/librte_eal/common/arch/ppc_64/meson.build|  5 +
 .../common/include/arch/ppc_64/meson.build   | 16 
 4 files changed, 44 insertions(+)
 create mode 100644 config/ppc_64/meson.build
 create mode 100644 lib/librte_eal/common/arch/ppc_64/meson.build
 create mode 100644 lib/librte_eal/common/include/arch/ppc_64/meson.build

diff --git a/config/meson.build b/config/meson.build
index 4d755323f4..8e87b344c2 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -9,7 +9,13 @@ else
 endif
 dpdk_conf.set('RTE_MACHINE', machine)
 machine_args = []
+# ppc64 does not support -march=native
+if host_machine.cpu_family().startswith('ppc') and machine == 'native'
+machine_args += '-mcpu=' + machine
+machine_args += '-mtune=' + machine
+else
 machine_args += '-march=' + machine
+endif
 
 toolchain = cc.get_id()
 dpdk_conf.set_quoted('RTE_TOOLCHAIN', toolchain)
@@ -84,6 +90,8 @@ if host_machine.cpu_family().startswith('x86')
arch_subdir = 'x86'
 elif host_machine.cpu_family().startswith('arm') or 
host_machine.cpu_family().startswith('aarch')
arch_subdir = 'arm'
+elif host_machine.cpu_family().startswith('ppc')
+   arch_subdir = 'ppc_64'
 endif
 subdir(arch_subdir)
 dpdk_conf.set('RTE_COMPILE_TIME_CPUFLAGS', ','.join(compile_time_cpuflags))
diff --git a/config/ppc_64/meson.build b/config/ppc_64/meson.build
new file mode 100644
index 00..d6faa7d64f
--- /dev/null
+++ b/config/ppc_64/meson.build
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2018 Luca Boccassi 
+
+# for checking defines we need to use the correct compiler flags
+march_opt = '-march=@0@'.format(machine)
+
+dpdk_conf.set('RTE_ARCH', 'ppc_64')
+dpdk_conf.set('RTE_ARCH_PPC_64', 1)
+dpdk_conf.set('RTE_ARCH_64', 1)
+
+# overrides specific to ppc64
+dpdk_conf.set('RTE_MAX_LCORE', 256)
+dpdk_conf.set('RTE_MAX_NUMA_NODES', 32)
+dpdk_conf.set('RTE_CACHE_LINE_SIZE', 128)
+dpdk_conf.set('RTE_MAX_LCORE', 256)
diff --git a/lib/librte_eal/common/arch/ppc_64/meson.build 
b/lib/librte_eal/common/arch/ppc_64/meson.build
new file mode 100644
index 00..40b3dc533a
--- /dev/null
+++ b/lib/librte_eal/common/arch/ppc_64/meson.build
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2018 Luca Boccassi 
+
+eal_common_arch_sources = files('rte_cpuflags.c',
+   'rte_cycles.c', 'rte_hypervisor.c')
diff --git a/lib/librte_eal/common/include/arch/ppc_64/meson.build 
b/lib/librte_eal/common/include/arch/ppc_64/meson.build
new file mode 100644
index 00..00f9611768
--- /dev/null
+++ b/lib/librte_eal/common/include/arch/ppc_64/meson.build
@@ -0,0 +1,16 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2018 Luca Boccassi 
+
+install_headers(
+   'rte_atomic.h',
+   'rte_byteorder.h',
+   'rte_cpuflags.h',
+   'rte_cycles.h',
+   'rte_io.h',
+   'rte_memcpy.h',
+   'rte_pause.h',
+   'rte_prefetch.h',
+   'rte_rwlock.h',
+   'rte_spinlock.h',
+   'rte_vect.h',
+   subdir: get_option('include_subdir_arch'))
-- 
2.18.0



[dpdk-dev] [RFC] net/mlx5: support multiple groups and jump action

2018-09-07 Thread Yongseok Koh
Hi,

rte_flow has 'group' attribute and 'jump' action in order to support multiple
groups. This feature is known as multi-table support ('chain' in linux TC
flower) in general because a group means a table of flows. This will be added
to mlx5 PMD for 18.11. Example commands are:

flow create 0 transfer priority 1 ingress
 pattern eth / vlan vid is 100 / end
 actions of_pop_vlan / jump group 100 / end

flow create 0 transfer priority 1 ingress
 pattern eth / vlan vid is 200 / end
 actions of_pop_vlan / jump group 200 / end

flow create 0 transfer group 100 priority 2 ingress
 pattern eth / ipv4 dst spec 192.168.40.0 dst prefix 24 / end
 actions drop / end

flow create 0 transfer group 100 priority 2 ingress
 pattern end
 actions port_id id 1 / end

flow create 0 transfer group 200 priority 2 ingress
 pattern eth / ipv4 dst spec 192.168.40.0 dst prefix 24 / end
 actions of_push_vlan ethertype 0x0800 / of_set_vlan_vid vlan_vid 
300 /
 port_id 1 / end

flow create 0 transfer group 200 priority 2 ingress
 pattern end
 actions of_push_vlan ethertype 0x0800 / of_set_vlan_vid vlan_vid 
400 /
 port_id 1 / end

With theses flows, if a packet having vlan 200 and src_ip as 192.168.40.1, this
packet will hit the 2nd flow and the vlan tag will be stripped off. Then it will
hit the 5th flow because of the 'jump' action. As a result, the packet will have
a new vlan tag with vid=300 and will be forwarded to a different interface.  If
the packet had vlan 100, it would be dropped according to 3rd flow.


Thanks,
Yongseok



Re: [dpdk-dev] [PATCH] eal: force IOVA mode to physical

2018-09-07 Thread Eric Zhang




On 09/07/2018 05:26 AM, Burakov, Anatoly wrote:

On 06-Sep-18 8:34 AM, Jerin Jacob wrote:

-Original Message-

Date: Tue, 4 Sep 2018 23:40:36 -0400
From: Eric Zhang 
To: santosh , 
hemant.agra...@nxp.com,

  Gaëtan Rivet , "Burakov, Anatoly"
  
CC: bruce.richard...@intel.com, dev@dpdk.org, 
allain.leg...@windriver.com,

  matt.pet...@windriver.com
Subject: Re: [dpdk-dev] [PATCH] eal: force IOVA mode to physical
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
  Thunderbird/52.9.1

On 08/30/2018 08:59 AM, santosh wrote:

On Thursday 30 August 2018 05:43 PM, Hemant wrote:

External Email

Hi,

On 8/30/2018 3:13 PM, Gaëtan Rivet wrote:

Hi,

On Thu, Aug 30, 2018 at 10:09:04AM +0100, Burakov, Anatoly wrote:

On 29-Aug-18 4:58 PM, eric zhang wrote:

This patch adds a configuration option to force the IOVA mode to
physical address (PA). There exists virtual devices that are not
directly attached to the PCI bus, and therefore the auto detection
of the IOVA mode based on probing the PCI bus and IOMMU 
configuration
may not report the required addressing mode. Having the 
configuration
option permits the mode to be explicitly configured in this 
scenario.


Signed-off-by: eric zhang 
---
Defining this at compile-time seems like an overkill. Wouldn't 
it be better
to just add an EAL command-line option to force IOVA mode to a 
particular

value?

That is a good suggestion.

--
Thanks,
Anatoly
What is the bus of these devices and why not implement 
get_iommu_class

in it?

There are cases, where you are using dpdk libraries with external
libraries and you need to change the default behavior DPDK lib to use
physical address instead of virtual address.
Providing an option to user will help.



More appropriate solution could be:
* Either fix it at bus layer .. i.e.. get_iommu_class()..
* Or introduce something like [1] --iova-mode= param.

Former is better solution than latter if autodetection is a key 
criteria.

Thanks.

[1] http://patchwork.dpdk.org/patch/25192/


It's not generic which couldn't be fixed at bus layer.
So what's the preference of EAL option or compile time solution?
Adding --iova-mode as patch [1] will overrivde auto-detection
rte_bus_get_iommu_class()
make it no use; compile time solution will align with upstream and keep
new atuodetection
solution in #ifndef.


If it is for vdev devices, why not introduce something like
RTE_PCI_DRV_IOVA_AS_VA and let vdev device describe its personality.
And based on the devices(flags) on vdev bus, rte_bus_get_iommu_class()
of vdev can decide the mode just like PCI bus.



That seems like a better option to me, +1. As far as i know, at the 
moment if there are no devices attached at all, or if there are only 
vdev devices attached, DPDK will default to IOVA as PA mode for no 
good reason; such a change would certainly fix this.
Thanks for the suggestions however our virtual device doesn't run dpdk 
vdev code so we can't use the flag.
Notice that in eal.c there is one workaround that force iova to be PA 
per virtual device is not directly attached to pci. That case is 
checking kni module. Ours is a similar case that virtual device not 
attach pci directly.
So we have to turn to force iova to PA either 1. compilation option 2. 
eal option.  Which one should be the preference by taking into 
consideration that align with upstream?


Thanks







Thanks
Eric










[dpdk-dev] [RFC] eal: simplify parameters of hotplug functions

2018-09-07 Thread Thomas Monjalon
All informations about a device to probe can be grouped
in a common string, which is what we usually call devargs.
That's why the bus name and device name can be removed from
rte_eal_hotplug_add().

When removing a device, we already know its rte_device handle
which can be directly passed as parameter of rte_eal_hotplug_remove().
If the rte_device is not known, it can be retrieved from the devargs,
thanks to RTE_DEV_FOREACH().

Signed-off-by: Thomas Monjalon 
---
This patch contains only the change in the API as RFC.

This idea was presented at Dublin during the "hotplug talk".
---
 lib/librte_eal/common/include/rte_dev.h | 19 +--
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/lib/librte_eal/common/include/rte_dev.h 
b/lib/librte_eal/common/include/rte_dev.h
index b80a80598..2f4212d01 100644
--- a/lib/librte_eal/common/include/rte_dev.h
+++ b/lib/librte_eal/common/include/rte_dev.h
@@ -194,18 +194,12 @@ int rte_eal_dev_detach(struct rte_device *dev);
  *
  * Hotplug add a given device to a specific bus.
  *
- * @param busname
- *   The bus name the device is added to.
- * @param devname
- *   The device name. Based on this device name, eal will identify a driver
- *   capable of handling it and pass it to the driver probing function.
  * @param devargs
- *   Device arguments to be passed to the driver.
+ *   Device arguments including bus, class and driver properties
  * @return
  *   0 on success, negative on error.
  */
-int __rte_experimental rte_eal_hotplug_add(const char *busname, const char 
*devname,
-   const char *devargs);
+int __rte_experimental rte_eal_hotplug_add(const char *devargs);
 
 /**
  * @warning
@@ -213,15 +207,12 @@ int __rte_experimental rte_eal_hotplug_add(const char 
*busname, const char *devn
  *
  * Hotplug remove a given device from a specific bus.
  *
- * @param busname
- *   The bus name the device is removed from.
- * @param devname
- *   The device name being removed.
+ * @param dev
+ *   Data structure of the device to remove
  * @return
  *   0 on success, negative on error.
  */
-int __rte_experimental rte_eal_hotplug_remove(const char *busname,
- const char *devname);
+int __rte_experimental rte_eal_hotplug_remove(struct rte_device *dev);
 
 /**
  * Device comparison function.
-- 
2.18.0



[dpdk-dev] [RFC] eal: allow hotplug to skip an already probed device

2018-09-07 Thread Thomas Monjalon
In the devargs syntax for device representors, it is possible to add
several devices at once: -w dbdf,representor=[0-3]
It will become a more frequent case when introducing wildcards
and ranges in the new devargs syntax.

If a devargs string is provided for probing, and updated with a bigger
range for a new probing, then we do not want it to fail because
part of this range was already probed previously.

On the opposite, we could require rte_eal_hotplug_add() to try
to add all matching devices, and fail if one is already probed.

That's why a new parameter is added to specify if the function
must fail or not when trying to add an already probed device.

Signed-off-by: Thomas Monjalon 
---
This patch contains only the change in the function itself as RFC.

This idea was presented at Dublin during the "hotplug talk".
---
 lib/librte_eal/common/eal_common_dev.c  | 4 +++-
 lib/librte_eal/common/include/rte_dev.h | 5 -
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_dev.c 
b/lib/librte_eal/common/eal_common_dev.c
index 678dbcac7..17d7e9089 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c
@@ -128,7 +128,7 @@ int rte_eal_dev_detach(struct rte_device *dev)
 }
 
 int __rte_experimental rte_eal_hotplug_add(const char *busname, const char 
*devname,
-   const char *devargs)
+   const char *devargs, bool fail_existing)
 {
struct rte_bus *bus;
struct rte_device *dev;
@@ -173,6 +173,8 @@ int __rte_experimental rte_eal_hotplug_add(const char 
*busname, const char *devn
}
 
if (dev->driver != NULL) {
+   if (!fail_existing)
+   return 0;
RTE_LOG(ERR, EAL, "Device is already plugged\n");
return -EEXIST;
}
diff --git a/lib/librte_eal/common/include/rte_dev.h 
b/lib/librte_eal/common/include/rte_dev.h
index b80a80598..10a1cd2b4 100644
--- a/lib/librte_eal/common/include/rte_dev.h
+++ b/lib/librte_eal/common/include/rte_dev.h
@@ -201,11 +201,14 @@ int rte_eal_dev_detach(struct rte_device *dev);
  *   capable of handling it and pass it to the driver probing function.
  * @param devargs
  *   Device arguments to be passed to the driver.
+ * @param fail_existing
+ *   If true and a matching device is already probed, then return -EEXIST.
+ *   If false, then skip the already probed device without returning an error.
  * @return
  *   0 on success, negative on error.
  */
 int __rte_experimental rte_eal_hotplug_add(const char *busname, const char 
*devname,
-   const char *devargs);
+   const char *devargs, bool fail_existing);
 
 /**
  * @warning
-- 
2.18.0



[dpdk-dev] [RFC] ethdev: complete closing to free all resources

2018-09-07 Thread Thomas Monjalon
After closing a port, it cannot be restarted.
So there is no reason to not free all associated resources.

The last step was done with rte_eth_dev_detach() which is deprecated.
Instead of removing the associated rte_device, the driver should check
if no more port (ethdev, cryptodev, etc) is still open for the device.
Then the device resources can be freed by the driver inside the
dev_close() driver callback operation.

The last ethdev freeing (dev_private and final release), which were done
by rte_eth_dev_detach(), are now done at the end of rte_eth_dev_close().

Signed-off-by: Thomas Monjalon 
---
This patch contains only the change in the close function as RFC.

This idea was presented at Dublin during the "hotplug talk".
---
 lib/librte_ethdev/rte_ethdev.c | 5 +
 lib/librte_ethdev/rte_ethdev.h | 5 +++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index 4c3202505..071fcbd23 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -1358,6 +1358,7 @@ void
 rte_eth_dev_close(uint16_t port_id)
 {
struct rte_eth_dev *dev;
+   struct rte_bus *bus;
 
RTE_ETH_VALID_PORTID_OR_RET(port_id);
dev = &rte_eth_devices[port_id];
@@ -1372,6 +1373,10 @@ rte_eth_dev_close(uint16_t port_id)
dev->data->nb_tx_queues = 0;
rte_free(dev->data->tx_queues);
dev->data->tx_queues = NULL;
+
+   rte_free(dev->data->dev_private);
+
+   rte_eth_dev_release_port(dev);
 }
 
 int
diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h
index 7070e9ab4..37a757a7a 100644
--- a/lib/librte_ethdev/rte_ethdev.h
+++ b/lib/librte_ethdev/rte_ethdev.h
@@ -1797,8 +1797,9 @@ int rte_eth_dev_set_link_down(uint16_t port_id);
 
 /**
  * Close a stopped Ethernet device. The device cannot be restarted!
- * The function frees all resources except for needed by the
- * closed state. To free these resources, call rte_eth_dev_detach().
+ * The function frees all port resources.
+ * If there is no more port associated with the underlying device,
+ * the driver should free the device resources.
  *
  * @param port_id
  *   The port identifier of the Ethernet device.
-- 
2.18.0



  1   2   >