[dpdk-dev] [PATCH 1/2] net/sfc: fix an Rx queue double release possibility
From: Igor Romanov There are two function that call sfc_rx_qfini(): sfc_rx_fini_queues() and sfc_rx_queue_release(). But only sfc_rx_queue_release() sets rx_queues pointer of the device data to NULL. It may lead to the scenario in which a queue is destroyed by sfc_rx_fini_queues() and after the queue is attempted to be destroyed again by sfc_rx_queue_release(). Move NULL assignment to sfc_rx_qfini(). Fixes: ce35b05c635e ("net/sfc: implement Rx queue setup release operations") Cc: sta...@dpdk.org Signed-off-by: Igor Romanov Signed-off-by: Andrew Rybchenko --- drivers/net/sfc/sfc_ethdev.c | 2 -- drivers/net/sfc/sfc_rx.c | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index 435bde67f..23778c9f3 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -444,8 +444,6 @@ sfc_rx_queue_release(void *queue) sfc_log_init(sa, "RxQ=%u", sw_index); - sa->eth_dev->data->rx_queues[sw_index] = NULL; - sfc_rx_qfini(sa, sw_index); sfc_adapter_unlock(sa); diff --git a/drivers/net/sfc/sfc_rx.c b/drivers/net/sfc/sfc_rx.c index c6321d174..5bd6bb9be 100644 --- a/drivers/net/sfc/sfc_rx.c +++ b/drivers/net/sfc/sfc_rx.c @@ -1104,6 +1104,7 @@ sfc_rx_qfini(struct sfc_adapter *sa, unsigned int sw_index) struct sfc_rxq *rxq; SFC_ASSERT(sw_index < sa->rxq_count); + sa->eth_dev->data->rx_queues[sw_index] = NULL; rxq_info = &sa->rxq_info[sw_index]; -- 2.17.1
[dpdk-dev] [PATCH 2/2] net/sfc: fix a Tx queue double release possibility
From: Igor Romanov There are two function that call sfc_tx_qfini(): sfc_tx_fini_queues() and sfc_tx_queue_release(). But only sfc_tx_queue_release() sets tx_queues pointer of the device data to NULL. It may lead to the scenario in which a queue is destroyed by sfc_tx_fini_queues() and after the queue is attempted to be destroyed again by sfc_tx_queue_release(). Move NULL assignment to sfc_tx_qfini(). Fixes: b1b7ad933b39 ("net/sfc: set up and release Tx queues") Cc: sta...@dpdk.org Signed-off-by: Igor Romanov Signed-off-by: Andrew Rybchenko --- drivers/net/sfc/sfc_ethdev.c | 3 --- drivers/net/sfc/sfc_tx.c | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index 23778c9f3..93bfecc4e 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -498,9 +498,6 @@ sfc_tx_queue_release(void *queue) sfc_adapter_lock(sa); - SFC_ASSERT(sw_index < sa->eth_dev->data->nb_tx_queues); - sa->eth_dev->data->tx_queues[sw_index] = NULL; - sfc_tx_qfini(sa, sw_index); sfc_adapter_unlock(sa); diff --git a/drivers/net/sfc/sfc_tx.c b/drivers/net/sfc/sfc_tx.c index 8af08b37c..12665d813 100644 --- a/drivers/net/sfc/sfc_tx.c +++ b/drivers/net/sfc/sfc_tx.c @@ -233,6 +233,8 @@ sfc_tx_qfini(struct sfc_adapter *sa, unsigned int sw_index) sfc_log_init(sa, "TxQ = %u", sw_index); SFC_ASSERT(sw_index < sa->txq_count); + sa->eth_dev->data->tx_queues[sw_index] = NULL; + txq_info = &sa->txq_info[sw_index]; txq = txq_info->txq; -- 2.17.1
Re: [dpdk-dev] [PATCH 14/15] net/vmxnet3: rename version map after library file name
13/09/2018 23:44, Yong Wang: > From: Luca Boccassi > The library is called librte_pmd_vmxnet3_uio, so rename the map > file and set the name in the meson file so that the built library names > with meson and legacy makefiles are the same > > Signed-off-by: Luca Boccassi > --- > > Not directly related to this change but I have some question on the uio > naming. The original motivation is from the following commit: > > commit 1daf0aae7fd6b3bc38952e9817a1653c1258be66 > Author: Thomas Monjalon > Date: Fri Mar 21 13:52:17 2014 +0100 > > vmxnet3: rename library > > In order to distinguish clearly this implementation from the extension > vmxnet3-usermap, it is renamed to reflect its usage of uio framework. > > Signed-off-by: Thomas Monjalon > Acked-by: Thomas Graf > > However, this version of vmxnet3 can also be bound to vfio-pci driver. I > think having the uio naming in that case will be misleading. Yes, i agree. vmxnet3-usermap is not maintained anymore, so we can remove the uio suffix.
Re: [dpdk-dev] [PATCH v3 6/9] memalloc: add EAL-internal API to get and set segment fd's
On 09/04/2018 05:15 PM, Anatoly Burakov wrote: Enable setting and retrieving segment fd's internally. For now, retrieving fd's will not be used anywhere until we get an external API, but it will be useful for things like virtio, where we wish to share segment fd's. Setting segment fd's will not be available as a public API at this time, but internally it is needed for legacy mode, because we're not allocating our hugepages in memalloc in legacy mode case, and we still need to store the fd. Another user of get segment fd API is memseg info dump, to show which pages use which fd's. Not supported on FreeBSD. Signed-off-by: Anatoly Burakov --- lib/librte_eal/bsdapp/eal/eal_memalloc.c | 12 + lib/librte_eal/common/eal_common_memory.c | 8 +-- lib/librte_eal/common/eal_memalloc.h | 6 +++ lib/librte_eal/linuxapp/eal/eal_memalloc.c | 60 +- lib/librte_eal/linuxapp/eal/eal_memory.c | 44 +--- 5 files changed, 109 insertions(+), 21 deletions(-) diff --git a/lib/librte_eal/bsdapp/eal/eal_memalloc.c b/lib/librte_eal/bsdapp/eal/eal_memalloc.c index f7f07abd6..a5fb09f71 100644 --- a/lib/librte_eal/bsdapp/eal/eal_memalloc.c +++ b/lib/librte_eal/bsdapp/eal/eal_memalloc.c @@ -47,6 +47,18 @@ eal_memalloc_sync_with_primary(void) return -1; } +int +eal_memalloc_get_seg_fd(int list_idx, int seg_idx) +{ + return -1; Why not returning -ENOTSUPP directly here? (see patch 7). +} + +int +eal_memalloc_set_seg_fd(int list_idx, int seg_idx, int fd) +{ + return -1; Ditto. +} + Other than that, the patch looks good to me. Maxime
Re: [dpdk-dev] [PATCH v3 8/9] mem: allow querying offset into segment fd
On 09/04/2018 05:15 PM, Anatoly Burakov wrote: In a few cases, user may need to query offset into fd for a particular memory segment (for example, to selectively map pages). This commit adds a new API to do that. Signed-off-by: Anatoly Burakov --- Notes: v3: - Fix single file segments mode not working lib/librte_eal/bsdapp/eal/eal_memalloc.c | 6 +++ lib/librte_eal/common/eal_common_memory.c | 50 ++ lib/librte_eal/common/eal_memalloc.h | 3 ++ lib/librte_eal/common/include/rte_memory.h | 49 + lib/librte_eal/linuxapp/eal/eal_memalloc.c | 24 +++ lib/librte_eal/rte_eal_version.map | 2 + 6 files changed, 134 insertions(+) Reviewed-by: Maxime Coquelin Thanks, Maxime
Re: [dpdk-dev] [PATCH v3 7/9] mem: add external API to retrieve page fd from EAL
On 09/04/2018 05:15 PM, Anatoly Burakov wrote: Now that we can retrieve page fd's internally, we can expose it as an external API. This will add two flavors of API - thread-safe and non-thread-safe. Fix up internal API's to return values we need without modifying rte_errno internally if called from within EAL. We do not want calling code to accidentally close an internal fd, so we make a duplicate of it before we return it to the user. Caller is therefore responsible for closing this fd. Signed-off-by: Anatoly Burakov --- lib/librte_eal/bsdapp/eal/eal_memalloc.c | 5 ++- lib/librte_eal/common/eal_common_memory.c | 49 ++ lib/librte_eal/common/eal_memalloc.h | 2 + lib/librte_eal/common/include/rte_memory.h | 48 + lib/librte_eal/linuxapp/eal/eal_memalloc.c | 21 ++ lib/librte_eal/rte_eal_version.map | 2 + 6 files changed, 118 insertions(+), 9 deletions(-) Reviewed-by: Maxime Coquelin
Re: [dpdk-dev] [PATCH v3 9/9] mem: support using memfd segments for in-memory mode
On 09/04/2018 05:15 PM, Anatoly Burakov wrote: Enable using memfd-created segments if supported by the system. This will allow having real fd's for pages but without hugetlbfs mounts, which will enable in-memory mode to be used with virtio. The implementation is mostly piggy-backing on existing real-fd code, except that we no longer need to unlink any files or track per-page locks in single-file segments mode, because in-memory mode does not support secondary processes anyway. We move some checks from EAL command-line parsing code to memalloc because it is now possible to use single-file segments mode with in-memory mode, but only if memfd is supported. Signed-off-by: Anatoly Burakov --- lib/librte_eal/common/eal_common_options.c | 6 +- lib/librte_eal/linuxapp/eal/eal_memalloc.c | 265 ++--- 2 files changed, 235 insertions(+), 36 deletions(-) Reviewed-by: Maxime Coquelin Thanks, Maxime
Re: [dpdk-dev] [PATCH v2 00/33] Adding Cavium's OcteonTX crypto PMD
Hi Akhil, Pablo, Did you get a chance to look at the patches? Anoob On 04-09-2018 09:28, Anoob Joseph wrote: Ankur Dwivedi (5): config: add Cavium OcteonTX crypto PMD skeleton common/cpt: add common logging support crypto/octeontx: add PCI probe and remove crypto/octeontx: add register addresses test: adds validation test Anoob Joseph (5): common/cpt: add common code for init routine crypto/octeontx: add hardware init routine common/cpt: add hardware register defines crypto/octeontx: add hardware register access for misc poll doc: adds doc file Murthy NSSR (5): crypto/octeontx: adds symmetric capabilities common/cpt: add PMD ops helper functions crypto/octeontx: add global resource init crypto/octeontx: add mailbox routines crypto/octeontx: add basic dev ops Nithin Dabilpuram (5): common/cpt: add common macros for queue pair ops crypto/octeontx: add queue pair functions common/cpt: add common code required for session management crypto/octeontx: add session management ops common/cpt: add common code for fill session data Ragothaman Jayaraman (5): crypto/octeontx: add supported sessions common/cpt: add common defines for microcode common/cpt: add microcode interface for encryption common/cpt: add microcode interface for decryption common/cpt: add crypo op enqueue request manager framework Srisivasubramanian S (5): common/cpt: add support for zuc and snow3g common/cpt: add support for kasumi common/cpt: add support for hash crypto/octeontx: add routines to prepare instructions common/cpt: add common code for enqueuing cpt instruction Tejasree Kondoj (3): crypto/octeontx: add enqueue burst op common/cpt: add common code for cpt dequeue crypto/octeontx: add dequeue burst op MAINTAINERS|7 + config/common_base |5 + doc/guides/cryptodevs/features/octeontx.ini| 60 + doc/guides/cryptodevs/octeontx.rst | 121 + drivers/common/Makefile|4 + drivers/common/cpt/Makefile| 25 + drivers/common/cpt/cpt_common.h| 103 + drivers/common/cpt/cpt_hw_types.h | 521 +++ drivers/common/cpt/cpt_mcode_defines.h | 378 ++ drivers/common/cpt/cpt_pmd_logs.h | 52 + drivers/common/cpt/cpt_pmd_ops_helper.c| 41 + drivers/common/cpt/cpt_pmd_ops_helper.h| 34 + drivers/common/cpt/cpt_request_mgr.h | 189 + drivers/common/cpt/cpt_ucode.h | 3646 drivers/common/cpt/meson.build |8 + drivers/common/cpt/rte_common_cpt_version.map |6 + drivers/common/meson.build |2 +- drivers/crypto/Makefile|1 + drivers/crypto/meson.build |2 +- drivers/crypto/octeontx/Makefile | 45 + drivers/crypto/octeontx/meson.build| 17 + drivers/crypto/octeontx/otx_cryptodev.c| 135 + drivers/crypto/octeontx/otx_cryptodev.h| 20 + .../crypto/octeontx/otx_cryptodev_capabilities.h | 595 drivers/crypto/octeontx/otx_cryptodev_hw_access.c | 609 drivers/crypto/octeontx/otx_cryptodev_hw_access.h | 320 ++ drivers/crypto/octeontx/otx_cryptodev_mbox.c | 180 + drivers/crypto/octeontx/otx_cryptodev_mbox.h | 92 + drivers/crypto/octeontx/otx_cryptodev_ops.c| 532 +++ drivers/crypto/octeontx/otx_cryptodev_ops.h| 18 + .../octeontx/rte_pmd_octeontx_crypto_version.map |4 + mk/rte.app.mk |5 + test/test/meson.build |1 + test/test/test_cryptodev.c | 308 ++ test/test/test_cryptodev.h |1 + test/test/test_cryptodev_aes_test_vectors.h| 96 +- test/test/test_cryptodev_blockcipher.c |9 +- test/test/test_cryptodev_blockcipher.h |1 + test/test/test_cryptodev_des_test_vectors.h| 12 +- test/test/test_cryptodev_hash_test_vectors.h | 72 +- 40 files changed, 8214 insertions(+), 63 deletions(-) create mode 100644 doc/guides/cryptodevs/features/octeontx.ini create mode 100644 doc/guides/cryptodevs/octeontx.rst create mode 100644 drivers/common/cpt/Makefile create mode 100644 drivers/common/cpt/cpt_common.h create mode 100644 drivers/common/cpt/cpt_hw_types.h create mode 100644 drivers/common/cpt/cpt_mcode_defines.h create mode 100644 drivers/common/cpt/cpt_pmd_logs.h create mode 100644 drivers/common/cpt/cpt_pmd_ops_helper.c create mode 100644 drivers/common/cpt/cpt_pmd_ops_helper.h create mode 100644 drivers/common/cpt/cpt_request_mgr.h create mode 100644 drivers/common/cpt/cp
[dpdk-dev] [PATCH 0/3] fix test vector checks
Multiple fixes to the test vector checks. Anoob Joseph (3): app/test-crypto-perf: add checks for AEAD key app/test-crypto-perf: fix check for auth key app/test-crypto-perf: fix check for cipher IV app/test-crypto-perf/main.c | 12 ++-- 1 file changed, 10 insertions(+), 2 deletions(-) -- 2.7.4
[dpdk-dev] [PATCH 1/3] app/test-crypto-perf: add checks for AEAD key
Adding validation checks for AEAD key. Signed-off-by: Akash Saxena Signed-off-by: Anoob Joseph --- app/test-crypto-perf/main.c | 4 1 file changed, 4 insertions(+) diff --git a/app/test-crypto-perf/main.c b/app/test-crypto-perf/main.c index 5c7dadb..c9f99a7 100644 --- a/app/test-crypto-perf/main.c +++ b/app/test-crypto-perf/main.c @@ -421,6 +421,10 @@ cperf_check_test_vector(struct cperf_options *opts, return -1; if (test_vec->ciphertext.length < opts->max_buffer_size) return -1; + if (test_vec->aead_key.data == NULL) + return -1; + if (test_vec->aead_key.length != opts->aead_key_sz) + return -1; if (test_vec->aead_iv.data == NULL) return -1; if (test_vec->aead_iv.length != opts->aead_iv_sz) -- 2.7.4
[dpdk-dev] [PATCH 2/3] app/test-crypto-perf: fix check for auth key
Authentication key is not required for all algorithms. Making sure the null check is done only when 'auth_key_sz' is non-zero. Fixes: f8be1786b1b8 ("app/crypto-perf: introduce performance test application") Signed-off-by: Anoob Joseph Signed-off-by: Ayuj Verma --- app/test-crypto-perf/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/test-crypto-perf/main.c b/app/test-crypto-perf/main.c index c9f99a7..55d97c2 100644 --- a/app/test-crypto-perf/main.c +++ b/app/test-crypto-perf/main.c @@ -357,7 +357,9 @@ cperf_check_test_vector(struct cperf_options *opts, return -1; if (test_vec->plaintext.length < opts->max_buffer_size) return -1; - if (test_vec->auth_key.data == NULL) + /* Auth key is only required for some algorithms */ + if (opts->auth_key_sz && + test_vec->auth_key.data == NULL) return -1; if (test_vec->auth_key.length != opts->auth_key_sz) return -1; -- 2.7.4
[dpdk-dev] [PATCH 3/3] app/test-crypto-perf: fix check for cipher IV
IV is not required for all ciphers. Making sure the null check is done only when 'cipher_iv_sz' is non-zero. Fixes: f8be1786b1b8 ("app/crypto-perf: introduce performance test application") Signed-off-by: Akash Saxena Signed-off-by: Anoob Joseph --- app/test-crypto-perf/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/test-crypto-perf/main.c b/app/test-crypto-perf/main.c index 55d97c2..953e058 100644 --- a/app/test-crypto-perf/main.c +++ b/app/test-crypto-perf/main.c @@ -342,7 +342,9 @@ cperf_check_test_vector(struct cperf_options *opts, return -1; if (test_vec->ciphertext.length < opts->max_buffer_size) return -1; - if (test_vec->cipher_iv.data == NULL) + /* Cipher IV is only required for some algorithms */ + if (opts->cipher_iv_sz && + test_vec->cipher_iv.data == NULL) return -1; if (test_vec->cipher_iv.length != opts->cipher_iv_sz) return -1; -- 2.7.4
Re: [dpdk-dev] [PATCH v2 00/33] Adding Cavium's OcteonTX crypto PMD
Hi Anoob, I would review it early next week. Thanks, Akhil On 9/14/2018 2:46 PM, Joseph, Anoob wrote: Hi Akhil, Pablo, Did you get a chance to look at the patches? Anoob On 04-09-2018 09:28, Anoob Joseph wrote: Ankur Dwivedi (5): config: add Cavium OcteonTX crypto PMD skeleton common/cpt: add common logging support crypto/octeontx: add PCI probe and remove crypto/octeontx: add register addresses test: adds validation test Anoob Joseph (5): common/cpt: add common code for init routine crypto/octeontx: add hardware init routine common/cpt: add hardware register defines crypto/octeontx: add hardware register access for misc poll doc: adds doc file Murthy NSSR (5): crypto/octeontx: adds symmetric capabilities common/cpt: add PMD ops helper functions crypto/octeontx: add global resource init crypto/octeontx: add mailbox routines crypto/octeontx: add basic dev ops Nithin Dabilpuram (5): common/cpt: add common macros for queue pair ops crypto/octeontx: add queue pair functions common/cpt: add common code required for session management crypto/octeontx: add session management ops common/cpt: add common code for fill session data Ragothaman Jayaraman (5): crypto/octeontx: add supported sessions common/cpt: add common defines for microcode common/cpt: add microcode interface for encryption common/cpt: add microcode interface for decryption common/cpt: add crypo op enqueue request manager framework Srisivasubramanian S (5): common/cpt: add support for zuc and snow3g common/cpt: add support for kasumi common/cpt: add support for hash crypto/octeontx: add routines to prepare instructions common/cpt: add common code for enqueuing cpt instruction Tejasree Kondoj (3): crypto/octeontx: add enqueue burst op common/cpt: add common code for cpt dequeue crypto/octeontx: add dequeue burst op MAINTAINERS | 7 + config/common_base | 5 + doc/guides/cryptodevs/features/octeontx.ini | 60 + doc/guides/cryptodevs/octeontx.rst | 121 + drivers/common/Makefile | 4 + drivers/common/cpt/Makefile | 25 + drivers/common/cpt/cpt_common.h | 103 + drivers/common/cpt/cpt_hw_types.h | 521 +++ drivers/common/cpt/cpt_mcode_defines.h | 378 ++ drivers/common/cpt/cpt_pmd_logs.h | 52 + drivers/common/cpt/cpt_pmd_ops_helper.c | 41 + drivers/common/cpt/cpt_pmd_ops_helper.h | 34 + drivers/common/cpt/cpt_request_mgr.h | 189 + drivers/common/cpt/cpt_ucode.h | 3646 drivers/common/cpt/meson.build | 8 + drivers/common/cpt/rte_common_cpt_version.map | 6 + drivers/common/meson.build | 2 +- drivers/crypto/Makefile | 1 + drivers/crypto/meson.build | 2 +- drivers/crypto/octeontx/Makefile | 45 + drivers/crypto/octeontx/meson.build | 17 + drivers/crypto/octeontx/otx_cryptodev.c | 135 + drivers/crypto/octeontx/otx_cryptodev.h | 20 + .../crypto/octeontx/otx_cryptodev_capabilities.h | 595 drivers/crypto/octeontx/otx_cryptodev_hw_access.c | 609 drivers/crypto/octeontx/otx_cryptodev_hw_access.h | 320 ++ drivers/crypto/octeontx/otx_cryptodev_mbox.c | 180 + drivers/crypto/octeontx/otx_cryptodev_mbox.h | 92 + drivers/crypto/octeontx/otx_cryptodev_ops.c | 532 +++ drivers/crypto/octeontx/otx_cryptodev_ops.h | 18 + .../octeontx/rte_pmd_octeontx_crypto_version.map | 4 + mk/rte.app.mk | 5 + test/test/meson.build | 1 + test/test/test_cryptodev.c | 308 ++ test/test/test_cryptodev.h | 1 + test/test/test_cryptodev_aes_test_vectors.h | 96 +- test/test/test_cryptodev_blockcipher.c | 9 +- test/test/test_cryptodev_blockcipher.h | 1 + test/test/test_cryptodev_des_test_vectors.h | 12 +- test/test/test_cryptodev_hash_test_vectors.h | 72 +- 40 files changed, 8214 insertions(+), 63 deletions(-) create mode 100644 doc/guides/cryptodevs/features/octeontx.ini create mode 100644 doc/guides/cryptodevs/octeontx.rst create mode 100644 drivers/common/cpt/Makefile create mode 100644 drivers/common/cpt/cpt_common.h create mode 100644 drivers/common/cpt/cpt_hw_types.h create mode 100644 drivers/common/cpt/cpt_mcode_defines.h create mode 100644 drivers/common/cpt/cpt_pmd_logs.h create mode 100644 drivers/common/cpt/c
Re: [dpdk-dev] [PATCH 00/13] driver/net: NXP DPAA driver enhancements
On 8/29/2018 11:47 AM, Hemant Agrawal wrote: > > Hemant Agrawal (9): > net/dpaa: configure frame queue on MAC ID basis > net/dpaa: fix jumbo buffer config > net/dpaa: implement scatter offload support > net/dpaa: minor debug log enhancements > bus/dpaa: add interrupt based portal fd support > net/dpaa: separate Rx function for LS1046 > net/dpaa: tune prefetch in Rx path > bus/dpaa: add check for re-definition in compat > mempool/dpaa: change the debug log level to DP > > Nipun Gupta (2): > bus/dpaa: avoid tag Set for eqcr in Tx path > bus/dpaa: avoid using be conversions for contextb > > Sachin Saxena (1): > net/dpaa: set correct speed based on MAC type > > Sunil Kumar Kori (1): > net/dpaa: rearranging of atomic queue support code Series applied to dpdk-next-net/master, thanks.
[dpdk-dev] [PATCH v2 0/2] CPU non-blocking delay
For meson build without deprecation warnings following patch should be applied first: http://patches.dpdk.org/patch/44129/ Version 2: * Added comment for EINTR handling for nanosleep. [Stephen Hemminger] Ilya Maximets (2): eal: add nanosleep based delay function drivers/net: use sleep delay by default for intel NICs drivers/net/avf/Makefile | 1 + drivers/net/avf/base/avf_osdep.h | 4 +- drivers/net/e1000/Makefile| 1 + drivers/net/e1000/base/e1000_osdep.h | 2 +- drivers/net/e1000/meson.build | 2 + drivers/net/i40e/base/i40e_osdep.h| 6 +-- drivers/net/ifc/base/ifcvf_osdep.h| 2 +- drivers/net/ixgbe/base/ixgbe_osdep.h | 2 +- drivers/net/ixgbe/meson.build | 3 +- lib/librte_eal/common/eal_common_timer.c | 24 + .../common/include/generic/rte_cycles.h | 11 lib/librte_eal/rte_eal_version.map| 1 + test/test/autotest_data.py| 6 +++ test/test/meson.build | 1 + test/test/test_cycles.c | 51 ++- 15 files changed, 94 insertions(+), 23 deletions(-) -- 2.17.1
[dpdk-dev] [PATCH v2 1/2] eal: add nanosleep based delay function
Add a new rte_delay_us_sleep() function that uses nanosleep(). This function can be used by applications to not implement their own nanosleep() based callback and by internal DPDK code if CPU non-blocking delay needed. Signed-off-by: Ilya Maximets --- lib/librte_eal/common/eal_common_timer.c | 24 + .../common/include/generic/rte_cycles.h | 11 lib/librte_eal/rte_eal_version.map| 1 + test/test/autotest_data.py| 6 +++ test/test/meson.build | 1 + test/test/test_cycles.c | 51 ++- 6 files changed, 80 insertions(+), 14 deletions(-) diff --git a/lib/librte_eal/common/eal_common_timer.c b/lib/librte_eal/common/eal_common_timer.c index 2e2b770fb..c6344ca87 100644 --- a/lib/librte_eal/common/eal_common_timer.c +++ b/lib/librte_eal/common/eal_common_timer.c @@ -7,9 +7,11 @@ #include #include #include +#include #include #include +#include #include #include #include @@ -31,6 +33,28 @@ rte_delay_us_block(unsigned int us) rte_pause(); } +void __rte_experimental +rte_delay_us_sleep(unsigned int us) +{ + struct timespec wait[2]; + int ind = 0; + + wait[0].tv_sec = 0; + if (us >= US_PER_S) { + wait[0].tv_sec = us / US_PER_S; + us -= wait[0].tv_sec * US_PER_S; + } + wait[0].tv_nsec = 1000 * us; + + while (nanosleep(&wait[ind], &wait[1 - ind]) == EINTR) { + /* +* Sleep was interrupted. Flip the index, so the 'remainder' +* will become the 'request' for a next call. +*/ + ind = 1 - ind; + } +} + uint64_t rte_get_tsc_hz(void) { diff --git a/lib/librte_eal/common/include/generic/rte_cycles.h b/lib/librte_eal/common/include/generic/rte_cycles.h index 0ff1af504..ac379e878 100644 --- a/lib/librte_eal/common/include/generic/rte_cycles.h +++ b/lib/librte_eal/common/include/generic/rte_cycles.h @@ -13,6 +13,7 @@ */ #include +#include #include #include @@ -157,6 +158,16 @@ rte_delay_ms(unsigned ms) */ void rte_delay_us_block(unsigned int us); +/** + * Delay function that uses system sleep. + * Does not block the CPU core. + * + * @param us + * Number of microseconds to wait. + */ +void __rte_experimental +rte_delay_us_sleep(unsigned int us); + /** * Replace rte_delay_us with user defined function. * diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map index 344a43d32..d68777ce0 100644 --- a/lib/librte_eal/rte_eal_version.map +++ b/lib/librte_eal/rte_eal_version.map @@ -270,6 +270,7 @@ EXPERIMENTAL { rte_class_register; rte_class_unregister; rte_ctrl_thread_create; + rte_delay_us_sleep; rte_dev_event_callback_register; rte_dev_event_callback_unregister; rte_dev_event_monitor_start; diff --git a/test/test/autotest_data.py b/test/test/autotest_data.py index f68d9b111..874d0cb53 100644 --- a/test/test/autotest_data.py +++ b/test/test/autotest_data.py @@ -278,6 +278,12 @@ "Func":default_autotest, "Report": None, }, +{ +"Name":"Sleep delay", +"Command": "delay_us_sleep_autotest", +"Func":default_autotest, +"Report": None, +}, { "Name":"Rawdev autotest", "Command": "rawdev_autotest", diff --git a/test/test/meson.build b/test/test/meson.build index b1dd6eca2..0078aea30 100644 --- a/test/test/meson.build +++ b/test/test/meson.build @@ -143,6 +143,7 @@ test_names = [ 'cryptodev_dpaa_sec_autotest', 'cycles_autotest', 'debug_autotest', + 'delay_us_sleep_autotest', 'devargs_autotest', 'distributor_autotest', 'distributor_perf_autotest', diff --git a/test/test/test_cycles.c b/test/test/test_cycles.c index 149f60b07..c78e6a5b1 100644 --- a/test/test/test_cycles.c +++ b/test/test/test_cycles.c @@ -23,6 +23,30 @@ * of cycles is correct with regard to the frequency of the timer. */ +static int +check_wait_one_second(void) +{ + uint64_t cycles, prev_cycles; + uint64_t hz = rte_get_timer_hz(); + uint64_t max_inc = (hz / 100); /* 10 ms max between 2 reads */ + + /* check that waiting 1 second is precise */ + prev_cycles = rte_get_timer_cycles(); + rte_delay_us(100); + cycles = rte_get_timer_cycles(); + + if ((uint64_t)(cycles - prev_cycles) > (hz + max_inc)) { + printf("delay_us is not accurate: too long\n"); + return -1; + } + if ((uint64_t)(cycles - prev_cycles) < (hz - max_inc)) { + printf("delay_us is not accurate: too short\n"); + return -1; + } + + return 0; +} + static int test_cycles(void) { @@ -43,24 +67,23 @@ test_cycles(void) prev_cycles = cycles; } - /* check that waiting 1 second is prec
[dpdk-dev] [PATCH v2 2/2] drivers/net: use sleep delay by default for intel NICs
NICs uses different delays up to a second during their configuration. It makes no sense to busy-wait so long wasting CPU cycles and preventing any other threads to execute on the same CPU core. These busy polling are the rudiments that came from the kernel drivers where you can not sleep in interrupt context, but as we're in userspace, we're able and should sleep to allow other threads to run. Delays never called on rx/tx path, so this should not affect performance. Signed-off-by: Ilya Maximets --- drivers/net/avf/Makefile | 1 + drivers/net/avf/base/avf_osdep.h | 4 ++-- drivers/net/e1000/Makefile | 1 + drivers/net/e1000/base/e1000_osdep.h | 2 +- drivers/net/e1000/meson.build| 2 ++ drivers/net/i40e/base/i40e_osdep.h | 6 +++--- drivers/net/ifc/base/ifcvf_osdep.h | 2 +- drivers/net/ixgbe/base/ixgbe_osdep.h | 2 +- drivers/net/ixgbe/meson.build| 3 ++- 9 files changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/net/avf/Makefile b/drivers/net/avf/Makefile index 3f815bbc4..8ee707529 100644 --- a/drivers/net/avf/Makefile +++ b/drivers/net/avf/Makefile @@ -9,6 +9,7 @@ include $(RTE_SDK)/mk/rte.vars.mk LIB = librte_pmd_avf.a CFLAGS += -O3 +CFLAGS += -DALLOW_EXPERIMENTAL_API LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs -lrte_hash LDLIBS += -lrte_bus_pci diff --git a/drivers/net/avf/base/avf_osdep.h b/drivers/net/avf/base/avf_osdep.h index 9ef45968e..442a5acd0 100644 --- a/drivers/net/avf/base/avf_osdep.h +++ b/drivers/net/avf/base/avf_osdep.h @@ -93,8 +93,8 @@ typedef uint64_tu64; #define avf_memset(a, b, c, d) memset((a), (b), (c)) #define avf_memcpy(a, b, c, d) rte_memcpy((a), (b), (c)) -#define avf_usec_delay(x) rte_delay_us(x) -#define avf_msec_delay(x) rte_delay_us(1000*(x)) +#define avf_usec_delay(x) rte_delay_us_sleep(x) +#define avf_msec_delay(x) avf_usec_delay(1000 * (x)) #define AVF_PCI_REG(reg) rte_read32(reg) #define AVF_PCI_REG_ADDR(a, reg) \ diff --git a/drivers/net/e1000/Makefile b/drivers/net/e1000/Makefile index 9c87e883b..0ed627656 100644 --- a/drivers/net/e1000/Makefile +++ b/drivers/net/e1000/Makefile @@ -10,6 +10,7 @@ LIB = librte_pmd_e1000.a CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) +CFLAGS += -DALLOW_EXPERIMENTAL_API LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs LDLIBS += -lrte_bus_pci diff --git a/drivers/net/e1000/base/e1000_osdep.h b/drivers/net/e1000/base/e1000_osdep.h index b8868049f..5958ea157 100644 --- a/drivers/net/e1000/base/e1000_osdep.h +++ b/drivers/net/e1000/base/e1000_osdep.h @@ -48,7 +48,7 @@ #include "../e1000_logs.h" -#define DELAY(x) rte_delay_us(x) +#define DELAY(x) rte_delay_us_sleep(x) #define usec_delay(x) DELAY(x) #define usec_delay_irq(x) DELAY(x) #define msec_delay(x) DELAY(1000*(x)) diff --git a/drivers/net/e1000/meson.build b/drivers/net/e1000/meson.build index cf456995c..d0901d377 100644 --- a/drivers/net/e1000/meson.build +++ b/drivers/net/e1000/meson.build @@ -1,6 +1,8 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel Corporation +allow_experimental_apis = true + subdir('base') objs = [base_objs] diff --git a/drivers/net/i40e/base/i40e_osdep.h b/drivers/net/i40e/base/i40e_osdep.h index 8e5c593c9..a6072e153 100644 --- a/drivers/net/i40e/base/i40e_osdep.h +++ b/drivers/net/i40e/base/i40e_osdep.h @@ -233,9 +233,9 @@ struct i40e_spinlock { #define i40e_memcpy(a, b, c, d) rte_memcpy((a), (b), (c)) #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) -#define DELAY(x) rte_delay_us(x) -#define i40e_usec_delay(x) rte_delay_us(x) -#define i40e_msec_delay(x) rte_delay_us(1000*(x)) +#define DELAY(x) rte_delay_us_sleep(x) +#define i40e_usec_delay(x) DELAY(x) +#define i40e_msec_delay(x) DELAY(1000 * (x)) #define udelay(x) DELAY(x) #define msleep(x) DELAY(1000*(x)) #define usleep_range(min, max) msleep(DIV_ROUND_UP(min, 1000)) diff --git a/drivers/net/ifc/base/ifcvf_osdep.h b/drivers/net/ifc/base/ifcvf_osdep.h index cf151ef52..6aef25ea4 100644 --- a/drivers/net/ifc/base/ifcvf_osdep.h +++ b/drivers/net/ifc/base/ifcvf_osdep.h @@ -17,7 +17,7 @@ #define DEBUGOUT(S, args...)RTE_LOG(DEBUG, PMD, S, ##args) #define STATIC static -#define msec_delay rte_delay_ms +#define msec_delay(x) rte_delay_us_sleep(1000 * (x)) #define IFCVF_READ_REG8(reg) rte_read8(reg) #define IFCVF_WRITE_REG8(val, reg) rte_write8((val), (reg)) diff --git a/drivers/net/ixgbe/base/ixgbe_osdep.h b/drivers/net/ixgbe/base/ixgbe_osdep.h index bb5dfd2af..94ede9bc2 100644 --- a/drivers/net/ixgbe/base/ixgbe_osdep.h +++ b/drivers/net/ixgbe/base/ixgbe_osdep.h @@ -51,7 +51,7 @@ #define ASSERT(x) if(!(x)) rte_panic("IXGBE: x") -#define DELAY(x) rte_delay_us(x) +#define DELAY(x) rte_delay_us_sleep(x) #define usec_delay(x) DELAY(x) #define msec_delay(x) DELAY(1000*(x)) diff --git a/drivers/net/ixgbe/meson.buil
Re: [dpdk-dev] [PATCH v2] ethdev: make default behavior CRC strip on Rx
On 9/4/2018 11:02 AM, Shahaf Shuler wrote: > Tuesday, September 4, 2018 1:13 PM, Ferruh Yigit: >> Subject: [PATCH v2] ethdev: make default behavior CRC strip on Rx >> >> Removed DEV_RX_OFFLOAD_CRC_STRIP offload flag. >> Without any specific Rx offload flag, default behavior by PMDs is to >> strip CRC. >> >> PMDs that support keeping CRC should advertise >> DEV_RX_OFFLOAD_KEEP_CRC >> Rx offload capability. >> >> Applications that require keeping CRC should check PMD capability first >> and if it is supported can enable this feature by setting >> DEV_RX_OFFLOAD_KEEP_CRC in Rx offload flag in rte_eth_dev_configure() >> >> Signed-off-by: Ferruh Yigit >> Acked-by: Tomasz Duszynski >> --- >> v2: >> * fix flag check >> * add KEEP_CRC flag into "show port cap #" >> >> Note "show port cap #" and >> "show port # [r/t]x_offload capabilities/configuration" >> does same thing, in long term I suggest removing "show port cap" one > > > Acked-by: Shahaf Shuler > Applied to dpdk-next-net/master, thanks.
[dpdk-dev] [PATCH 0/3] dpaa2: support for crypto adapter
From: Akhil Goyal This patchset add support for event crypto adapter on dpaa2_sec support for parallel and atomic queues are added. The patches are rebased over http://patches.dpdk.org/user/todo/dpdk/?series=1101 Akhil Goyal (2): crypto/dpaa2_sec: support for event crypto adapter event/dpaa2: support for crypto adapter Ashish Jain (1): crypto/dpaa2_sec: support for atomic queues drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 145 - drivers/crypto/dpaa2_sec/dpaa2_sec_event.h| 18 +++ drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h | 2 + .../dpaa2_sec/rte_pmd_dpaa2_sec_version.map | 8 + drivers/event/dpaa2/Makefile | 3 +- drivers/event/dpaa2/dpaa2_eventdev.c | 150 ++ drivers/event/dpaa2/dpaa2_eventdev.h | 9 ++ drivers/event/dpaa2/meson.build | 3 +- 8 files changed, 330 insertions(+), 8 deletions(-) create mode 100644 drivers/crypto/dpaa2_sec/dpaa2_sec_event.h -- 2.17.1
[dpdk-dev] [PATCH 1/3] crypto/dpaa2_sec: support for event crypto adapter
From: Akhil Goyal Signed-off-by: Akhil Goyal Signed-off-by: Ashish Jain --- drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 90 ++- drivers/crypto/dpaa2_sec/dpaa2_sec_event.h| 18 drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h | 2 + .../dpaa2_sec/rte_pmd_dpaa2_sec_version.map | 8 ++ 4 files changed, 116 insertions(+), 2 deletions(-) create mode 100644 drivers/crypto/dpaa2_sec/dpaa2_sec_event.h diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c index 53e493457..ae38f507b 100644 --- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c +++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved. - * Copyright 2016 NXP + * Copyright 2016-2018 NXP * */ @@ -10,7 +10,6 @@ #include #include -#include #include #include #include @@ -28,6 +27,7 @@ #include #include "dpaa2_sec_priv.h" +#include "dpaa2_sec_event.h" #include "dpaa2_sec_logs.h" /* Required types */ @@ -2853,6 +2853,92 @@ void dpaa2_sec_stats_reset(struct rte_cryptodev *dev) } } +static void __attribute__((hot)) +dpaa2_sec_process_parallel_event(struct qbman_swp *swp, +const struct qbman_fd *fd, +const struct qbman_result *dq, +struct dpaa2_queue *rxq, +struct rte_event *ev) +{ + /* Prefetching mbuf */ + rte_prefetch0((void *)(size_t)(DPAA2_GET_FD_ADDR(fd)- + rte_dpaa2_bpid_info[DPAA2_GET_FD_BPID(fd)].meta_data_size)); + + /* Prefetching ipsec crypto_op stored in priv data of mbuf */ + rte_prefetch0((void *)(size_t)(DPAA2_GET_FD_ADDR(fd)-64)); + + ev->flow_id = rxq->ev.flow_id; + ev->sub_event_type = rxq->ev.sub_event_type; + ev->event_type = RTE_EVENT_TYPE_CRYPTODEV; + ev->op = RTE_EVENT_OP_NEW; + ev->sched_type = rxq->ev.sched_type; + ev->queue_id = rxq->ev.queue_id; + ev->priority = rxq->ev.priority; + ev->event_ptr = sec_fd_to_mbuf(fd, ((struct rte_cryptodev *) + (rxq->dev))->driver_id); + + qbman_swp_dqrr_consume(swp, dq); +} + +int +dpaa2_sec_eventq_attach(const struct rte_cryptodev *dev, + int qp_id, + uint16_t dpcon_id, + const struct rte_event *event) +{ + struct dpaa2_sec_dev_private *priv = dev->data->dev_private; + struct fsl_mc_io *dpseci = (struct fsl_mc_io *)priv->hw; + struct dpaa2_sec_qp *qp = dev->data->queue_pairs[qp_id]; + struct dpseci_rx_queue_cfg cfg; + int ret; + + if (event->sched_type == RTE_SCHED_TYPE_PARALLEL) + qp->rx_vq.cb = dpaa2_sec_process_parallel_event; + else + return -EINVAL; + + memset(&cfg, 0, sizeof(struct dpseci_rx_queue_cfg)); + cfg.options = DPSECI_QUEUE_OPT_DEST; + cfg.dest_cfg.dest_type = DPSECI_DEST_DPCON; + cfg.dest_cfg.dest_id = dpcon_id; + cfg.dest_cfg.priority = event->priority; + + cfg.options |= DPSECI_QUEUE_OPT_USER_CTX; + cfg.user_ctx = (size_t)(qp); + + ret = dpseci_set_rx_queue(dpseci, CMD_PRI_LOW, priv->token, + qp_id, &cfg); + if (ret) { + RTE_LOG(ERR, PMD, "Error in dpseci_set_queue: ret: %d\n", ret); + return ret; + } + + memcpy(&qp->rx_vq.ev, event, sizeof(struct rte_event)); + + return 0; +} + +int +dpaa2_sec_eventq_detach(const struct rte_cryptodev *dev, + int qp_id) +{ + struct dpaa2_sec_dev_private *priv = dev->data->dev_private; + struct fsl_mc_io *dpseci = (struct fsl_mc_io *)priv->hw; + struct dpseci_rx_queue_cfg cfg; + int ret; + + memset(&cfg, 0, sizeof(struct dpseci_rx_queue_cfg)); + cfg.options = DPSECI_QUEUE_OPT_DEST; + cfg.dest_cfg.dest_type = DPSECI_DEST_NONE; + + ret = dpseci_set_rx_queue(dpseci, CMD_PRI_LOW, priv->token, + qp_id, &cfg); + if (ret) + RTE_LOG(ERR, PMD, "Error in dpseci_set_queue: ret: %d\n", ret); + + return ret; +} + static struct rte_cryptodev_ops crypto_ops = { .dev_configure= dpaa2_sec_dev_configure, .dev_start= dpaa2_sec_dev_start, diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_event.h b/drivers/crypto/dpaa2_sec/dpaa2_sec_event.h new file mode 100644 index 0..977099429 --- /dev/null +++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_event.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2018 NXP + * + */ + +#ifndef _DPAA2_SEC_EVENT_H_ +#define _DPAA2_SEC_EVENT_H_ + +int +dpaa2_sec_eventq_attach(const struct rte_cryptodev *dev, + int qp_id, + uint16_t dpcon_id, + const struct rte_event *event); + +in
[dpdk-dev] [PATCH 3/3] event/dpaa2: support for crypto adapter
From: Akhil Goyal Signed-off-by: Akhil Goyal Signed-off-by: Ashish Jain Signed-off-by: Hemant Agrawal --- drivers/event/dpaa2/Makefile | 3 +- drivers/event/dpaa2/dpaa2_eventdev.c | 150 +++ drivers/event/dpaa2/dpaa2_eventdev.h | 9 ++ drivers/event/dpaa2/meson.build | 3 +- 4 files changed, 163 insertions(+), 2 deletions(-) diff --git a/drivers/event/dpaa2/Makefile b/drivers/event/dpaa2/Makefile index 5e1a63200..46f7d061e 100644 --- a/drivers/event/dpaa2/Makefile +++ b/drivers/event/dpaa2/Makefile @@ -20,9 +20,10 @@ CFLAGS += -I$(RTE_SDK)/drivers/event/dpaa2 CFLAGS += -I$(RTE_SDK)/lib/librte_eal/linuxapp/eal LDLIBS += -lrte_eal -lrte_eventdev LDLIBS += -lrte_bus_fslmc -lrte_mempool_dpaa2 -lrte_pmd_dpaa2 -LDLIBS += -lrte_bus_vdev +LDLIBS += -lrte_bus_vdev -lrte_pmd_dpaa2_sec CFLAGS += -I$(RTE_SDK)/drivers/net/dpaa2 CFLAGS += -I$(RTE_SDK)/drivers/net/dpaa2/mc +CFLAGS += -I$(RTE_SDK)/drivers/crypto/dpaa2_sec # versioning export map EXPORT_MAP := rte_pmd_dpaa2_event_version.map diff --git a/drivers/event/dpaa2/dpaa2_eventdev.c b/drivers/event/dpaa2/dpaa2_eventdev.c index cadbdb13b..890ab461c 100644 --- a/drivers/event/dpaa2/dpaa2_eventdev.c +++ b/drivers/event/dpaa2/dpaa2_eventdev.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -34,6 +35,7 @@ #include #include #include +#include #include "dpaa2_eventdev.h" #include "dpaa2_eventdev_logs.h" #include @@ -793,6 +795,149 @@ dpaa2_eventdev_eth_stop(const struct rte_eventdev *dev, return 0; } +static int +dpaa2_eventdev_crypto_caps_get(const struct rte_eventdev *dev, + const struct rte_cryptodev *cdev, + uint32_t *caps) +{ + const char *name = cdev->data->name; + + EVENTDEV_INIT_FUNC_TRACE(); + + RTE_SET_USED(dev); + + if (!strncmp(name, "dpsec-", 6)) + *caps = RTE_EVENT_CRYPTO_ADAPTER_DPAA2_CAP; + else + return -1; + + return 0; +} + +static int +dpaa2_eventdev_crypto_queue_add_all(const struct rte_eventdev *dev, + const struct rte_cryptodev *cryptodev, + const struct rte_event *ev) +{ + struct dpaa2_eventdev *priv = dev->data->dev_private; + uint8_t ev_qid = ev->queue_id; + uint16_t dpcon_id = priv->evq_info[ev_qid].dpcon->dpcon_id; + int i, ret; + + EVENTDEV_INIT_FUNC_TRACE(); + + for (i = 0; i < cryptodev->data->nb_queue_pairs; i++) { + ret = dpaa2_sec_eventq_attach(cryptodev, i, + dpcon_id, ev); + if (ret) { + DPAA2_EVENTDEV_ERR("dpaa2_sec_eventq_attach failed: ret %d\n", + ret); + goto fail; + } + } + return 0; +fail: + for (i = (i - 1); i >= 0 ; i--) + dpaa2_sec_eventq_detach(cryptodev, i); + + return ret; +} + +static int +dpaa2_eventdev_crypto_queue_add(const struct rte_eventdev *dev, + const struct rte_cryptodev *cryptodev, + int32_t rx_queue_id, + const struct rte_event *ev) +{ + struct dpaa2_eventdev *priv = dev->data->dev_private; + uint8_t ev_qid = ev->queue_id; + uint16_t dpcon_id = priv->evq_info[ev_qid].dpcon->dpcon_id; + int ret; + + EVENTDEV_INIT_FUNC_TRACE(); + + if (rx_queue_id == -1) + return dpaa2_eventdev_crypto_queue_add_all(dev, + cryptodev, ev); + + ret = dpaa2_sec_eventq_attach(cryptodev, rx_queue_id, + dpcon_id, ev); + if (ret) { + DPAA2_EVENTDEV_ERR( + "dpaa2_sec_eventq_attach failed: ret: %d\n", ret); + return ret; + } + return 0; +} + +static int +dpaa2_eventdev_crypto_queue_del_all(const struct rte_eventdev *dev, +const struct rte_cryptodev *cdev) +{ + int i, ret; + + EVENTDEV_INIT_FUNC_TRACE(); + + RTE_SET_USED(dev); + + for (i = 0; i < cdev->data->nb_queue_pairs; i++) { + ret = dpaa2_sec_eventq_detach(cdev, i); + if (ret) { + DPAA2_EVENTDEV_ERR( + "dpaa2_sec_eventq_detach failed:ret %d\n", ret); + return ret; + } + } + + return 0; +} + +static int +dpaa2_eventdev_crypto_queue_del(const struct rte_eventdev *dev, +const struct rte_cryptodev *cryptodev, +int32_t rx_queue_id) +{ + int ret; + + EVENTDEV_INIT_FUNC_TRACE(); + + if (rx_queue_id == -1) + return dpaa2_eventdev_crypto_queue_del_all(dev, cryptodev); + + ret = dpaa2_sec_eventq_detach(cryptodev, rx_queue_id); + if (ret) { + DPAA2_EVENTDEV_ERR( + "dpaa2_sec_eventq_detach
[dpdk-dev] [PATCH 2/3] crypto/dpaa2_sec: support for atomic queues
From: Ashish Jain Signed-off-by: Ashish Jain --- drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 57 +++-- 1 file changed, 52 insertions(+), 5 deletions(-) diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c index ae38f507b..781595b38 100644 --- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c +++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c @@ -1209,6 +1209,7 @@ dpaa2_sec_enqueue_burst(void *qp, struct rte_crypto_op **ops, struct dpaa2_sec_qp *dpaa2_qp = (struct dpaa2_sec_qp *)qp; struct qbman_swp *swp; uint16_t num_tx = 0; + uint32_t flags[MAX_TX_RING_SLOTS] = {0}; /*todo - need to support multiple buffer pools */ uint16_t bpid; struct rte_mempool *mb_pool; @@ -1240,6 +1241,15 @@ dpaa2_sec_enqueue_burst(void *qp, struct rte_crypto_op **ops, dpaa2_eqcr_size : nb_ops; for (loop = 0; loop < frames_to_send; loop++) { + if ((*ops)->sym->m_src->seqn) { +uint8_t dqrr_index = (*ops)->sym->m_src->seqn - 1; + +flags[loop] = QBMAN_ENQUEUE_FLAG_DCA | dqrr_index; +DPAA2_PER_LCORE_DQRR_SIZE--; +DPAA2_PER_LCORE_DQRR_HELD &= ~(1 << dqrr_index); +(*ops)->sym->m_src->seqn = DPAA2_INVALID_MBUF_SEQN; + } + /*Clear the unused FD fields before sending*/ memset(&fd_arr[loop], 0, sizeof(struct qbman_fd)); mb_pool = (*ops)->sym->m_src->pool; @@ -1256,7 +1266,7 @@ dpaa2_sec_enqueue_burst(void *qp, struct rte_crypto_op **ops, while (loop < frames_to_send) { loop += qbman_swp_enqueue_multiple(swp, &eqdesc, &fd_arr[loop], - NULL, + &flags[loop], frames_to_send - loop); } @@ -1281,6 +1291,9 @@ sec_simple_fd_to_mbuf(const struct qbman_fd *fd, __rte_unused uint8_t id) DPAA2_IOVA_TO_VADDR(DPAA2_GET_FD_ADDR(fd)), rte_dpaa2_bpid_info[DPAA2_GET_FD_BPID(fd)].meta_data_size); + diff = len - mbuf->pkt_len; + mbuf->pkt_len += diff; + mbuf->data_len += diff; op = (struct rte_crypto_op *)(size_t)mbuf->buf_iova; mbuf->buf_iova = op->sym->aead.digest.phys_addr; op->sym->aead.digest.phys_addr = 0L; @@ -1291,9 +1304,6 @@ sec_simple_fd_to_mbuf(const struct qbman_fd *fd, __rte_unused uint8_t id) mbuf->data_off += SEC_FLC_DHR_OUTBOUND; else mbuf->data_off += SEC_FLC_DHR_INBOUND; - diff = len - mbuf->pkt_len; - mbuf->pkt_len += diff; - mbuf->data_len += diff; return op; } @@ -2879,6 +2889,38 @@ dpaa2_sec_process_parallel_event(struct qbman_swp *swp, qbman_swp_dqrr_consume(swp, dq); } +static void +dpaa2_sec_process_atomic_event(struct qbman_swp *swp __attribute__((unused)), +const struct qbman_fd *fd, +const struct qbman_result *dq, +struct dpaa2_queue *rxq, +struct rte_event *ev) +{ + uint8_t dqrr_index; + struct rte_crypto_op *crypto_op = (struct rte_crypto_op *)ev->event_ptr; + /* Prefetching mbuf */ + rte_prefetch0((void *)(size_t)(DPAA2_GET_FD_ADDR(fd)- + rte_dpaa2_bpid_info[DPAA2_GET_FD_BPID(fd)].meta_data_size)); + + /* Prefetching ipsec crypto_op stored in priv data of mbuf */ + rte_prefetch0((void *)(size_t)(DPAA2_GET_FD_ADDR(fd)-64)); + + ev->flow_id = rxq->ev.flow_id; + ev->sub_event_type = rxq->ev.sub_event_type; + ev->event_type = RTE_EVENT_TYPE_CRYPTODEV; + ev->op = RTE_EVENT_OP_NEW; + ev->sched_type = rxq->ev.sched_type; + ev->queue_id = rxq->ev.queue_id; + ev->priority = rxq->ev.priority; + + ev->event_ptr = sec_fd_to_mbuf(fd, ((struct rte_cryptodev *) + (rxq->dev))->driver_id); + dqrr_index = qbman_get_dqrr_idx(dq); + crypto_op->sym->m_src->seqn = dqrr_index + 1; + DPAA2_PER_LCORE_DQRR_SIZE++; + DPAA2_PER_LCORE_DQRR_HELD |= 1 << dqrr_index; + DPAA2_PER_LCORE_DQRR_MBUF(dqrr_index) = crypto_op->sym->m_src; +} int dpaa2_sec_eventq_attach(const struct rte_cryptodev *dev, @@ -2894,6 +2936,8 @@ dpaa2_sec_eventq_attach(const struct rte_cryptodev *dev, if (event->sched_type == RTE_SCHED_TYPE_PARALLEL) qp->rx_vq.cb = dpaa2_sec_process_parallel_event; + else if (event->sched_type == RTE_SCHED_TYPE_ATOMIC) + qp->rx_vq.cb = dpaa2_sec_process_atomic_event; else return -EIN
Re: [dpdk-dev] [dpdk-stable] [PATCH] vhost: fix vhost interrupt support
On 9/10/2018 8:36 AM, Tiwei Bie wrote: > Hi Maxime, > > On Mon, Sep 10, 2018 at 09:22:00AM +0200, Maxime Coquelin wrote: >> Hi Tiwei, >> >> On 09/05/2018 01:55 AM, Tiwei Bie wrote: >>> When VIRTIO_RING_F_EVENT_IDX is negotiated, we need to >>> update the avail event to enable the notification. >>> >>> Fixes: 3f8ff12821e4 ("vhost: support interrupt mode") >>> Cc: sta...@dpdk.org >>> >>> Signed-off-by: Tiwei Bie >>> --- >>> lib/librte_vhost/Makefile | 1 + >>> lib/librte_vhost/vhost.c | 18 -- >>> lib/librte_vhost/vhost.h | 2 ++ >>> 3 files changed, 15 insertions(+), 6 deletions(-) >>> >>> diff --git a/lib/librte_vhost/Makefile b/lib/librte_vhost/Makefile >>> index de431fbb7..531cf4832 100644 >>> --- a/lib/librte_vhost/Makefile >>> +++ b/lib/librte_vhost/Makefile >>> @@ -13,6 +13,7 @@ LIBABIVER := 4 >>> CFLAGS += -DALLOW_EXPERIMENTAL_API >>> CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) -O3 -D_FILE_OFFSET_BITS=64 >>> CFLAGS += -I vhost_user >>> +CFLAGS += -fno-strict-aliasing >> >> I'm not clear why this is needed looking at the code below, >> could you please explain? > > Without this, we will get below build error: > > lib/librte_vhost/vhost.c: In function ‘vhost_enable_notify_split’: > lib/librte_vhost/vhost.h:656:4: error: dereferencing type-punned pointer will > break strict-aliasing rules [-Werror=strict-aliasing] > (*(volatile uint16_t*)&(vr)->used->ring[(vr)->size]) > ^ > lib/librte_vhost/vhost.c:659:4: note: in expansion of macro > ‘vhost_avail_event’ > vhost_avail_event(vq) = vq->last_avail_idx; > ^ > cc1: all warnings being treated as errors > Getting this error with meson build system, since "-fno-strict-aliasing" is not added to meson build file. BUT instead of disabling compiler warning, first element of the "struct vring_used_elem ring[0]" is "uint32_t id;", so it should be accessed as uint32_t. What about following: #define vhost_avail_event(vr) \ - (*(volatile uint16_t*)&(vr)->used->ring[(vr)->size]) + (*(volatile uint32_t*)&(vr)->used->ring[(vr)->size]) And for "vhost_avail_event(vq) = vq->last_avail_idx;", "last_avail_idx" is uint16_t, so assigning from uint16_t to uint32_t should be ok too. If above works for you please send a patch for update also removing "-fno-strict-aliasing", this can be rebased on existing patch. If not works, please at least send a patch to add flag to meson build file Thanks, ferruh >> >>> LDLIBS += -lpthread >>> ifeq ($(CONFIG_RTE_LIBRTE_VHOST_NUMA),y) >>> diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c >>> index 3c9be10a0..88b1781d5 100644 >>> --- a/lib/librte_vhost/vhost.c >>> +++ b/lib/librte_vhost/vhost.c >>> @@ -646,12 +646,18 @@ rte_vhost_avail_entries(int vid, uint16_t queue_id) >>> } >>> static inline void >>> -vhost_enable_notify_split(struct vhost_virtqueue *vq, int enable) >>> +vhost_enable_notify_split(struct virtio_net *dev, >>> + struct vhost_virtqueue *vq, int enable) >>> { >>> - if (enable) >>> - vq->used->flags &= ~VRING_USED_F_NO_NOTIFY; >>> - else >>> - vq->used->flags |= VRING_USED_F_NO_NOTIFY; >>> + if (!(dev->features & (1ULL << VIRTIO_RING_F_EVENT_IDX))) { >>> + if (enable) >>> + vq->used->flags &= ~VRING_USED_F_NO_NOTIFY; >>> + else >>> + vq->used->flags |= VRING_USED_F_NO_NOTIFY; >>> + } else { >>> + if (enable) >>> + vhost_avail_event(vq) = vq->last_avail_idx; >>> + } >>> } >>> static inline void >>> @@ -689,7 +695,7 @@ rte_vhost_enable_guest_notification(int vid, uint16_t >>> queue_id, int enable) >>> if (vq_is_packed(dev)) >>> vhost_enable_notify_packed(dev, vq, enable); >>> else >>> - vhost_enable_notify_split(vq, enable); >>> + vhost_enable_notify_split(dev, vq, enable); >>> return 0; >>> } >>> diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h >>> index 760a09c0d..25ffd7614 100644 >>> --- a/lib/librte_vhost/vhost.h >>> +++ b/lib/librte_vhost/vhost.h >>> @@ -648,6 +648,8 @@ vhost_iova_to_vva(struct virtio_net *dev, struct >>> vhost_virtqueue *vq, >>> return __vhost_iova_to_vva(dev, vq, iova, len, perm); >>> } >>> +#define vhost_avail_event(vr) \ >>> + (*(volatile uint16_t*)&(vr)->used->ring[(vr)->size]) >>> #define vhost_used_event(vr) \ >>> (*(volatile uint16_t*)&(vr)->avail->ring[(vr)->size]) >>>
Re: [dpdk-dev] [PATCH v2 01/33] config: add Cavium OcteonTX crypto PMD skeleton
Hi Anoob, On 9/4/2018 9:28 AM, Anoob Joseph wrote: From: Ankur Dwivedi This adds Makefile, meson.build and config file options. Also adds the version map files and maintainers file to claim responsibility. Signed-off-by: Ankur Dwivedi Signed-off-by: Anoob Joseph Signed-off-by: Murthy NSSR Signed-off-by: Nithin Dabilpuram Signed-off-by: Ragothaman Jayaraman Signed-off-by: Srisivasubramanian S Signed-off-by: Tejasree Kondoj --- MAINTAINERS| 7 config/common_base | 5 +++ drivers/crypto/Makefile| 1 + drivers/crypto/meson.build | 2 +- drivers/crypto/octeontx/Makefile | 37 ++ drivers/crypto/octeontx/meson.build| 12 +++ .../octeontx/rte_pmd_octeontx_crypto_version.map | 4 +++ mk/rte.app.mk | 1 + 8 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 drivers/crypto/octeontx/Makefile create mode 100644 drivers/crypto/octeontx/meson.build create mode 100644 drivers/crypto/octeontx/rte_pmd_octeontx_crypto_version.map diff --git a/MAINTAINERS b/MAINTAINERS index 9fd258f..09548fa 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -771,6 +771,13 @@ F: drivers/crypto/armv8/ F: doc/guides/cryptodevs/armv8.rst F: doc/guides/cryptodevs/features/armv8.ini +Cavium OcteonTX +M: Anoob Joseph +F: drivers/common/cpt/ +F: drivers/crypto/octeontx/ +F: doc/guides/cryptodevs/octeontx.rst +F: doc/guides/cryptodevs/features/octeontx.ini octeontx.rst and octeontx.ini does not exist. Please update MAINTAINERS in the patch which is adding this file. + Crypto Scheduler M: Fan Zhang F: drivers/crypto/scheduler/ diff --git a/config/common_base b/config/common_base index 4bcbaf9..4c6a951 100644 --- a/config/common_base +++ b/config/common_base @@ -635,6 +635,11 @@ CONFIG_RTE_LIBRTE_PMD_DPAA_EVENTDEV=n CONFIG_RTE_LIBRTE_PMD_DPAA2_EVENTDEV=n # +# Compile PMD for Cavium OcteonTX crypto device +# +CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO=y + +# # Compile raw device support # EXPERIMENTAL: API may change without prior notice # diff --git a/drivers/crypto/Makefile b/drivers/crypto/Makefile index c480cbd..c083e64 100644 --- a/drivers/crypto/Makefile +++ b/drivers/crypto/Makefile @@ -7,6 +7,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_PMD_AESNI_GCM) += aesni_gcm DIRS-$(CONFIG_RTE_LIBRTE_PMD_AESNI_MB) += aesni_mb DIRS-$(CONFIG_RTE_LIBRTE_PMD_ARMV8_CRYPTO) += armv8 DIRS-$(CONFIG_RTE_LIBRTE_PMD_CCP) += ccp +DIRS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO) += octeontx DIRS-$(CONFIG_RTE_LIBRTE_PMD_OPENSSL) += openssl DIRS-$(CONFIG_RTE_LIBRTE_PMD_CRYPTO_SCHEDULER) += scheduler DIRS-$(CONFIG_RTE_LIBRTE_PMD_SNOW3G) += snow3g diff --git a/drivers/crypto/meson.build b/drivers/crypto/meson.build index d64ca41..2187870 100644 --- a/drivers/crypto/meson.build +++ b/drivers/crypto/meson.build @@ -2,7 +2,7 @@ # Copyright(c) 2017 Intel Corporation drivers = ['ccp', 'dpaa_sec', 'dpaa2_sec', 'mvsam', - 'null', 'openssl', 'qat', 'virtio'] + 'null', 'octeontx', 'openssl', 'qat', 'virtio'] std_deps = ['cryptodev'] # cryptodev pulls in all other needed deps config_flag_fmt = 'RTE_LIBRTE_@0@_PMD' diff --git a/drivers/crypto/octeontx/Makefile b/drivers/crypto/octeontx/Makefile new file mode 100644 index 000..65bd02f --- /dev/null +++ b/drivers/crypto/octeontx/Makefile @@ -0,0 +1,37 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2018 Cavium, Inc +# + +include $(RTE_SDK)/mk/rte.vars.mk + +# library name +LIB = librte_pmd_octeontx_crypto.a + +# library version +LIBABIVER := 1 + +# build flags +CFLAGS += $(WERROR_FLAGS) + +LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring +LDLIBS += -lrte_cryptodev +LDLIBS += -lrte_pci -lrte_bus_pci + +VPATH += $(RTE_SDK)/drivers/crypto/octeontx + +CFLAGS += -O3 -DCPT_MODEL=CRYPTO_OCTEONTX + +# export include files +SYMLINK-y-include += + +# versioning export map +EXPORT_MAP := rte_pmd_octeontx_crypto_version.map + +# library dependencies +DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO) += lib/librte_eal +DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO) += lib/librte_cryptodev +DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO) += lib/librte_mempool +DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO) += lib/librte_mbuf +DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO) += lib/librte_malloc + +include $(RTE_SDK)/mk/rte.lib.mk diff --git a/drivers/crypto/octeontx/meson.build b/drivers/crypto/octeontx/meson.build new file mode 100644 index 000..261bb77 --- /dev/null +++ b/drivers/crypto/octeontx/meson.build @@ -0,0 +1,12 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2018 Cavium, Inc +if host_machine.system() != 'linux' + build = false +endif + +deps += ['bus_pci'] +name = 'octeontx_crypto' + +sources = files() + +cflags += '-DCPT_MODEL=CRYPTO_OCTEONTX' diff --git a/drivers/crypto
Re: [dpdk-dev] [PATCH v2 02/33] common/cpt: add common logging support
On 9/4/2018 9:28 AM, Anoob Joseph wrote: From: Ankur Dwivedi Add common logging macros Signed-off-by: Ankur Dwivedi Signed-off-by: Anoob Joseph Signed-off-by: Murthy NSSR Signed-off-by: Nithin Dabilpuram Signed-off-by: Ragothaman Jayaraman Signed-off-by: Srisivasubramanian S Signed-off-by: Tejasree Kondoj --- drivers/common/cpt/cpt_pmd_logs.h | 52 +++ 1 file changed, 52 insertions(+) create mode 100644 drivers/common/cpt/cpt_pmd_logs.h diff --git a/drivers/common/cpt/cpt_pmd_logs.h b/drivers/common/cpt/cpt_pmd_logs.h new file mode 100644 index 000..e1bfbb3 --- /dev/null +++ b/drivers/common/cpt/cpt_pmd_logs.h @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2018 Cavium, Inc + */ + +#ifndef _CPT_PMD_LOGS_H_ +#define _CPT_PMD_LOGS_H_ + +#include + +/* + * This file defines log macros + */ + +#define CPT_PMD_DRV_LOG_RAW(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, cpt_logtype, \ + "cpt: %s(): " fmt "\n", __func__, ##args) + +#define CPT_PMD_INIT_FUNC_TRACE() CPT_PMD_DRV_LOG_RAW(DEBUG, " >>") +#define CPT_PMD_DRV_LOG(level, args...) \ + CPT_PMD_DRV_LOG_RAW(level, ##args) + +#define CPT_LOG_INFO(fmt, args...) \ + CPT_PMD_DRV_LOG_RAW(INFO, fmt, ## args) +#define CPT_LOG_WARN(fmt, args...) \ + CPT_PMD_DRV_LOG_RAW(WARNING, fmt, ## args) +#define CPT_LOG_ERR(fmt, args...) \ + CPT_PMD_DRV_LOG_RAW(ERR, fmt, ## args) + +/* + * DP logs, toggled out at compile time if level lower than current level. + * DP logs would be logged under 'PMD' type. So for dynamic logging, the + * level of 'pmd' has to be used. + */ +#define CPT_LOG_DP(level, fmt, args...) \ + RTE_LOG_DP(level, PMD, fmt "\n", ## args) + +#define CPT_LOG_DP_DEBUG(fmt, args...) \ + CPT_LOG_DP(DEBUG, fmt, ## args) +#define CPT_LOG_DP_INFO(fmt, args...) \ + CPT_LOG_DP(INFO, fmt, ## args) +#define CPT_LOG_DP_WARN(fmt, args...) \ + CPT_LOG_DP(WARNING, fmt, ## args) +#define CPT_LOG_DP_ERR(fmt, args...) \ + CPT_LOG_DP(ERR, fmt, ## args) + +/* + * cpt_logtype will be used for common logging. This field would be intiailized typo intiailized + * by otx_* driver routines during PCI probe. + */ +int cpt_logtype; + +#endif /* _CPT_PMD_LOGS_H_ */
Re: [dpdk-dev] [PATCH v2 03/33] crypto/octeontx: add PCI probe and remove
On 9/4/2018 9:28 AM, Anoob Joseph wrote: From: Ankur Dwivedi Adding basic PCI probe/remove functions for OcteonTX crypto device. Initialization function for logging is also added. Signed-off-by: Ankur Dwivedi Signed-off-by: Anoob Joseph Signed-off-by: Murthy NSSR Signed-off-by: Nithin Dabilpuram Signed-off-by: Ragothaman Jayaraman Signed-off-by: Srisivasubramanian S Signed-off-by: Tejasree Kondoj --- drivers/crypto/octeontx/Makefile| 5 ++ drivers/crypto/octeontx/meson.build | 4 +- drivers/crypto/octeontx/otx_cryptodev.c | 132 drivers/crypto/octeontx/otx_cryptodev.h | 20 + drivers/crypto/octeontx/otx_cryptodev_ops.c | 15 drivers/crypto/octeontx/otx_cryptodev_ops.h | 11 +++ 6 files changed, 186 insertions(+), 1 deletion(-) create mode 100644 drivers/crypto/octeontx/otx_cryptodev.c create mode 100644 drivers/crypto/octeontx/otx_cryptodev.h create mode 100644 drivers/crypto/octeontx/otx_cryptodev_ops.c create mode 100644 drivers/crypto/octeontx/otx_cryptodev_ops.h diff --git a/drivers/crypto/octeontx/Makefile b/drivers/crypto/octeontx/Makefile index 65bd02f..12fec75 100644 --- a/drivers/crypto/octeontx/Makefile +++ b/drivers/crypto/octeontx/Makefile @@ -20,6 +20,11 @@ LDLIBS += -lrte_pci -lrte_bus_pci VPATH += $(RTE_SDK)/drivers/crypto/octeontx CFLAGS += -O3 -DCPT_MODEL=CRYPTO_OCTEONTX +CFLAGS += -I$(RTE_SDK)/drivers/common/cpt + +# PMD code +SRCS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO) += otx_cryptodev.c +SRCS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO) += otx_cryptodev_ops.c # export include files SYMLINK-y-include += diff --git a/drivers/crypto/octeontx/meson.build b/drivers/crypto/octeontx/meson.build index 261bb77..6564090 100644 --- a/drivers/crypto/octeontx/meson.build +++ b/drivers/crypto/octeontx/meson.build @@ -7,6 +7,8 @@ endif deps += ['bus_pci'] name = 'octeontx_crypto' -sources = files() +sources = files('otx_cryptodev.c', + 'otx_cryptodev_ops.c') cflags += '-DCPT_MODEL=CRYPTO_OCTEONTX' +includes += include_directories('../../common/cpt') diff --git a/drivers/crypto/octeontx/otx_cryptodev.c b/drivers/crypto/octeontx/otx_cryptodev.c new file mode 100644 index 000..df88a84 --- /dev/null +++ b/drivers/crypto/octeontx/otx_cryptodev.c @@ -0,0 +1,132 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2018 Cavium, Inc + */ + +#include +#include +#include +#include +#include +#include + +/* CPT common headers */ +#include "cpt_pmd_logs.h" + +#include "otx_cryptodev.h" +#include "otx_cryptodev_ops.h" + +static int otx_cryptodev_logtype; + +static struct rte_pci_id pci_id_cpt_table[] = { + { + RTE_PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, CPT_81XX_PCI_VF_DEVICE_ID), + }, + /* sentinel */ + { + .device_id = 0 indentation + }, +}; + +static void +otx_cpt_init_log(void) +{ + /* Bus level logs */ + otx_cryptodev_logtype = rte_log_register("pmd.crypto.octeontx"); + if (otx_cryptodev_logtype >= 0) + rte_log_set_level(otx_cryptodev_logtype, RTE_LOG_NOTICE); +} + +static void +otx_cpt_logtype_init(void) +{ + cpt_logtype = otx_cryptodev_logtype; +} + +static int +otx_cpt_pci_probe(struct rte_pci_driver *pci_drv, + struct rte_pci_device *pci_dev) +{ + struct rte_cryptodev *cryptodev; + char name[RTE_CRYPTODEV_NAME_MAX_LEN]; + int retval; + + if (pci_drv == NULL) + return -ENODEV; + + rte_pci_device_name(&pci_dev->addr, name, sizeof(name)); + + cryptodev = rte_cryptodev_pmd_allocate(name, rte_socket_id()); + if (cryptodev == NULL) + return -ENOMEM; + + cryptodev->device = &pci_dev->device; + cryptodev->device->driver = &pci_drv->driver; + cryptodev->driver_id = otx_cryptodev_driver_id; + + /* init user callbacks */ + TAILQ_INIT(&(cryptodev->link_intr_cbs)); + + /* init logtype used in common */ + otx_cpt_logtype_init(); + + /* Invoke PMD device initialization function */ + retval = otx_cpt_dev_create(cryptodev); + if (retval == 0) + return 0; + + CPT_LOG_ERR("[DRV %s]: Failed to create device " + "(vendor_id: 0x%x device_id: 0x%x", + pci_drv->driver.name, + (unsigned int) pci_dev->id.vendor_id, + (unsigned int) pci_dev->id.device_id); + + cryptodev->attached = RTE_CRYPTODEV_DETACHED; + + return -ENXIO; +} + +static int +otx_cpt_pci_remove(struct rte_pci_device *pci_dev) +{ + struct rte_cryptodev *cryptodev; + char name[RTE_CRYPTODEV_NAME_MAX_LEN]; + + if (pci_dev == NULL) + return -EINVAL; + + rte_pci_device_name(&pci_dev->addr, name, sizeof(name)); + + cryptodev = rte_cryptodev_pmd_get_named_dev(name); + if (cryptodev == NULL) + retur
Re: [dpdk-dev] [PATCH 1/5] bus/vmbus: add devargs support
On 8/30/2018 11:35 PM, Stephen Hemminger wrote: > From: Stephen Hemminger > > Take device arguments from command line and put > them in the device devargs. > > Signed-off-by: Stephen Hemminger <...> > @@ -204,6 +203,27 @@ vmbus_parse(const char *name, void *addr) > return ret; > } > > +/* > + * scan for matching device args on command line > + * example: > + * -w 'vmbus(635a7ae3-091e-4410-ad59-667c4f8c04c3,latency=20)' This is just in comment but, I guess latest syntax is: -w "vmbus:635a7ae3-091e-4410-ad59-667c4f8c04c3,latency=20" @Gaetan, is latest devarg syntax documented somewhere?
Re: [dpdk-dev] [PATCH 2/5] net/netvsc: allow tuning latency with devargs
On 8/30/2018 11:35 PM, Stephen Hemminger wrote: > From: Stephen Hemminger > > Allow overriding default guest to host latency on per device basis > with devargs. > > Signed-off-by: Stephen Hemminger Reviewed-by: Ferruh Yigit
Re: [dpdk-dev] [PATCH 5/5] net/netvsc: integrated VF support
On 8/30/2018 11:35 PM, Stephen Hemminger wrote: > From: Stephen Hemminger > > Integrate accelerated networking support into netvsc PMD. > This allows netvsc to manage VF without using failsafe or vdev_netvsc. > For the exception vswitch path some tests like transmit > get a 22% increase in packets/sec. > For the VF path, the code is slightly shorter but has no > real change in performance. > > Pro: >* using netvsc is more like other DPDK NIC's >* the exception packet uses less CPU >* much smaller code size >* no locking required on VF transmit/receive path >* no legacy Linux network device to get mangled by userspace >* much simpler (1K vs 9K) LOC >* unified extended statistics > > Con: >* using netvsc has more complex startup model >* no bifurcated driver support >* no flow support (since host does not have flow API). >* no tunnel offload support >* no receive interrupt support > > Signed-off-by: Stephen Hemminger > --- > devtools/checkpatches.sh | 2 +- > doc/guides/nics/netvsc.rst | 12 +- > doc/guides/rel_notes/release_18_11.rst | 14 +- > drivers/net/netvsc/Makefile| 1 + > drivers/net/netvsc/hn_ethdev.c | 109 +- > drivers/net/netvsc/hn_nvs.c| 11 +- > drivers/net/netvsc/hn_nvs.h| 9 + > drivers/net/netvsc/hn_rndis.c | 31 ++ > drivers/net/netvsc/hn_rndis.h | 1 + > drivers/net/netvsc/hn_rxtx.c | 136 --- > drivers/net/netvsc/hn_var.h| 43 ++- > drivers/net/netvsc/hn_vf.c | 512 + > drivers/net/netvsc/meson.build | 2 +- > 13 files changed, 799 insertions(+), 84 deletions(-) > create mode 100644 drivers/net/netvsc/hn_vf.c > > diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh > index ba795ad1dc36..db7afc43d4c0 100755 > --- a/devtools/checkpatches.sh > +++ b/devtools/checkpatches.sh > @@ -1,4 +1,4 @@ > -#! /bin/sh > +#! /bin/bash > # SPDX-License-Identifier: BSD-3-Clause > # Copyright 2015 6WIND S.A. This tool patch shouldn't be part of driver update, would you mind sending a separate patch for it?
Re: [dpdk-dev] [PATCH 1/5] bus/vmbus: add devargs support
Hi, On Fri, Sep 14, 2018 at 01:46:59PM +0100, Ferruh Yigit wrote: > On 8/30/2018 11:35 PM, Stephen Hemminger wrote: > > From: Stephen Hemminger > > > > Take device arguments from command line and put > > them in the device devargs. > > > > Signed-off-by: Stephen Hemminger > > <...> > > > @@ -204,6 +203,27 @@ vmbus_parse(const char *name, void *addr) > > return ret; > > } > > > > +/* > > + * scan for matching device args on command line > > + * example: > > + * -w 'vmbus(635a7ae3-091e-4410-ad59-667c4f8c04c3,latency=20)' > > This is just in comment but, > > I guess latest syntax is: > -w "vmbus:635a7ae3-091e-4410-ad59-667c4f8c04c3,latency=20" > > @Gaetan, is latest devarg syntax documented somewhere? That's the current syntax indeed. Some documentation is found at lib/librte_eal/common/include/rte_devargs.h:100 Where it is specified that the bus name can be either omitted or followed by any character, to separate it from the device identifier. This means that using ':' is fine, as well as '('. As long as the device PMD afterward ignore the dangling ')' during devargs parsing, this should be fine. I don't think this is very clean, but it works. -- Gaëtan Rivet 6WIND
Re: [dpdk-dev] [PATCH 1/5] bus/vmbus: add devargs support
On 9/14/2018 2:06 PM, Gaëtan Rivet wrote: > Hi, > > On Fri, Sep 14, 2018 at 01:46:59PM +0100, Ferruh Yigit wrote: >> On 8/30/2018 11:35 PM, Stephen Hemminger wrote: >>> From: Stephen Hemminger >>> >>> Take device arguments from command line and put >>> them in the device devargs. >>> >>> Signed-off-by: Stephen Hemminger >> >> <...> >> >>> @@ -204,6 +203,27 @@ vmbus_parse(const char *name, void *addr) >>> return ret; >>> } >>> >>> +/* >>> + * scan for matching device args on command line >>> + * example: >>> + * -w 'vmbus(635a7ae3-091e-4410-ad59-667c4f8c04c3,latency=20)' >> >> This is just in comment but, >> >> I guess latest syntax is: >> -w "vmbus:635a7ae3-091e-4410-ad59-667c4f8c04c3,latency=20" >> >> @Gaetan, is latest devarg syntax documented somewhere? > > That's the current syntax indeed. Some documentation is found at > > lib/librte_eal/common/include/rte_devargs.h:100 > > Where it is specified that the bus name can be either omitted or > followed by any character, to separate it from the device identifier. > > This means that using ':' is fine, as well as '('. As long as the device > PMD afterward ignore the dangling ')' during devargs parsing, this should > be fine. > > I don't think this is very clean, but it works. Thanks for the info, I see how "(" works, but ")" is takes as part of argument and causing problem, I think better to not give "()" as supported syntax at all. btw, now both -w and --vdev are valid and can be used interchangeably, right? I mean all following are valid? -w pci::86:06.0,enable_floating_veb=1 -w vdev:net_pcap,iface=lo --vdev pci::86:06.0,enable_floating_veb=1 --vdev vdev:net_pcap,iface=lo
Re: [dpdk-dev] [PATCH 0/5] netvsc changes for 18.11
On 8/30/2018 11:35 PM, Stephen Hemminger wrote: > These patches are against dpdk-net-next/master because > that is where previous patches have already been merged. > > Stephen Hemminger (5): > bus/vmbus: add devargs support > net/netvsc: allow tuning latency with devargs > net/netvsc: exhausting transmit descriptors is not an error > net/netvsc: implement link state change callback > net/netvsc: integrated VF support Series applied to dpdk-next-net/master, thanks. (checkpatches.sh update dropped from patch, devarg syntax in function comment updated.)
[dpdk-dev] [PATCH v3 1/8] examples/power: add checks around hypervisor
Allow vm_power_manager to run without requiring qemu to be present on the machine. This will be required for instances where the JSON interface is used for commands and polices, without any VMs present. A use case for this is a container enviromnent. Signed-off-by: David Hunt --- examples/vm_power_manager/channel_manager.c | 71 + examples/vm_power_manager/channel_monitor.c | 2 +- 2 files changed, 44 insertions(+), 29 deletions(-) diff --git a/examples/vm_power_manager/channel_manager.c b/examples/vm_power_manager/channel_manager.c index 927fc35ab..2e471d0c1 100644 --- a/examples/vm_power_manager/channel_manager.c +++ b/examples/vm_power_manager/channel_manager.c @@ -43,7 +43,8 @@ static unsigned char *global_cpumaps; static virVcpuInfo *global_vircpuinfo; static size_t global_maplen; -static unsigned global_n_host_cpus; +static unsigned int global_n_host_cpus; +static bool global_hypervisor_available; /* * Represents a single Virtual Machine @@ -198,7 +199,11 @@ get_pcpus_mask(struct channel_info *chan_info, unsigned vcpu) { struct virtual_machine_info *vm_info = (struct virtual_machine_info *)chan_info->priv_info; - return rte_atomic64_read(&vm_info->pcpu_mask[vcpu]); + + if (global_hypervisor_available && (vm_info != NULL)) + return rte_atomic64_read(&vm_info->pcpu_mask[vcpu]); + else + return 0; } static inline int @@ -559,6 +564,8 @@ get_all_vm(int *num_vm, int *num_vcpu) VIR_CONNECT_LIST_DOMAINS_PERSISTENT; unsigned int domain_flag = VIR_DOMAIN_VCPU_CONFIG; + if (!global_hypervisor_available) + return; memset(global_cpumaps, 0, CHANNEL_CMDS_MAX_CPUS*global_maplen); if (virNodeGetInfo(global_vir_conn_ptr, &node_info)) { @@ -768,38 +775,42 @@ connect_hypervisor(const char *path) } return 0; } - int -channel_manager_init(const char *path) +channel_manager_init(const char *path __rte_unused) { virNodeInfo info; LIST_INIT(&vm_list_head); if (connect_hypervisor(path) < 0) { - RTE_LOG(ERR, CHANNEL_MANAGER, "Unable to initialize channel manager\n"); - return -1; - } - - global_maplen = VIR_CPU_MAPLEN(CHANNEL_CMDS_MAX_CPUS); + global_n_host_cpus = 64; + global_hypervisor_available = 0; + RTE_LOG(INFO, CHANNEL_MANAGER, "Unable to initialize channel manager\n"); + } else { + global_hypervisor_available = 1; + + global_maplen = VIR_CPU_MAPLEN(CHANNEL_CMDS_MAX_CPUS); + + global_vircpuinfo = rte_zmalloc(NULL, + sizeof(*global_vircpuinfo) * + CHANNEL_CMDS_MAX_CPUS, RTE_CACHE_LINE_SIZE); + if (global_vircpuinfo == NULL) { + RTE_LOG(ERR, CHANNEL_MANAGER, "Error allocating memory for CPU Info\n"); + goto error; + } + global_cpumaps = rte_zmalloc(NULL, + CHANNEL_CMDS_MAX_CPUS * global_maplen, + RTE_CACHE_LINE_SIZE); + if (global_cpumaps == NULL) + goto error; - global_vircpuinfo = rte_zmalloc(NULL, sizeof(*global_vircpuinfo) * - CHANNEL_CMDS_MAX_CPUS, RTE_CACHE_LINE_SIZE); - if (global_vircpuinfo == NULL) { - RTE_LOG(ERR, CHANNEL_MANAGER, "Error allocating memory for CPU Info\n"); - goto error; - } - global_cpumaps = rte_zmalloc(NULL, CHANNEL_CMDS_MAX_CPUS * global_maplen, - RTE_CACHE_LINE_SIZE); - if (global_cpumaps == NULL) { - goto error; + if (virNodeGetInfo(global_vir_conn_ptr, &info)) { + RTE_LOG(ERR, CHANNEL_MANAGER, "Unable to retrieve node Info\n"); + goto error; + } + global_n_host_cpus = (unsigned int)info.cpus; } - if (virNodeGetInfo(global_vir_conn_ptr, &info)) { - RTE_LOG(ERR, CHANNEL_MANAGER, "Unable to retrieve node Info\n"); - goto error; - } - global_n_host_cpus = (unsigned)info.cpus; if (global_n_host_cpus > CHANNEL_CMDS_MAX_CPUS) { RTE_LOG(WARNING, CHANNEL_MANAGER, "The number of host CPUs(%u) exceeds the " @@ -811,7 +822,8 @@ channel_manager_init(const char *path) return 0; error: - disconnect_hypervisor(); + if (global_hypervisor_available) + disconnect_hypervisor(); return -1; } @@ -838,7 +850,10 @@ channel_manager_exit(void) rte_free(vm_info); } - rte_free(global_cpumaps); - rte_free(global_vircpuinfo); - disconnect_hypervisor(); + if (global_hypervisor_available) { + /* Only needed if hyper
[dpdk-dev] [PATCH v3 0/8] add json power policy interface for containers
The current vm_power_manager example app has the capability to accept power policies from virtual machines via virtio-serial channels. These power policies allow a virtual machine to give information to the power manager to allow the power manager take care of the power management of the virtual machine based on the information in the policy. This power policy functionality is limited to virtual machines sending the policies to the power manager (which runs in the Host OS), and a solution was needed for additional methods of sending power policies to the power manager app. The main use-case for this modification is for containers and host applications that wish to send polices to the power manager. This patchset adds the capability to send power polices and power commands to the vm_power_manager app via JSON strings through a fifo on the file system. For example, given the following file, policy.json: {"policy": { "name": "ubuntu2", "command": "create", "policy_type": "TIME", "busy_hours":[ 17, 18, 19, 20, 21, 22, 23 ], "quiet_hours":[ 2, 3, 4, 5, 6 ], "core_list":[ 11, 12, 13 ] }} Then running the command: cat policy.json >/tmp/powermonitor/fifo.0 The policy is sent to the vm_power_manager. The power manager app then parses the JSON data, and inserts the policy into the array of policies. Part of the patch series contains documentation updates to give all the details of the valid name-value pairs, the data types, etc. Patch v2: * Fixed review comments from Stephen Hemminger and Lei A Yao. * Added a check in the Makefile for libjansson-dev. Will Warn user and build without JSON functionality if not present, will build including JSON functionality if it is present. Patch v3: * Added meson/ninja support for vm_power_manager and guest_cli apps * Fixed compilation issue with guest_cli app [1/8] examples/power: add checks around hypervisor [2/8] lib/power: add changes for host commands/policies [3/8] examples/power: add necessary changes to guest app [4/8] examples/power: add host channel to power manager [5/8] examples/power: add json string handling [6/8] examples/power: add meson/ninja build support [7/8] doc/vm_power_manager: add JSON interface API info [8/8] examples/power: add json example files
[dpdk-dev] [PATCH v3 2/8] lib/power: add changes for host commands/policies
Signed-off-by: David Hunt --- lib/librte_power/channel_commands.h | 5 + 1 file changed, 5 insertions(+) diff --git a/lib/librte_power/channel_commands.h b/lib/librte_power/channel_commands.h index ee638eefa..e7b93a797 100644 --- a/lib/librte_power/channel_commands.h +++ b/lib/librte_power/channel_commands.h @@ -19,6 +19,7 @@ extern "C" { #define CPU_POWER 1 #define CPU_POWER_CONNECT 2 #define PKT_POLICY 3 +#define PKT_POLICY_REMOVE 4 /* CPU Power Command Scaling */ #define CPU_POWER_SCALE_UP 1 @@ -58,6 +59,9 @@ struct traffic { uint32_t max_max_packet_thresh; }; +#define CORE_TYPE_VIRTUAL 0 +#define CORE_TYPE_PHYSICAL 1 + struct channel_packet { uint64_t resource_id; /**< core_num, device */ uint32_t unit;/**< scale down/up/min/max */ @@ -70,6 +74,7 @@ struct channel_packet { uint8_t vcpu_to_control[MAX_VCPU_PER_VM]; uint8_t num_vcpu; struct timer_profile timer_policy; + bool core_type; enum workload workload; enum policy_to_use policy_to_use; struct t_boost_status t_boost_status; -- 2.17.1
[dpdk-dev] [PATCH v3 4/8] examples/power: add host channel to power manager
This patch adds a fifo channel to the vm_power_manager app through which we can send commands and polices. Intended for sending JSON strings. The fifo is at /tmp/powermonitor/fifo.0 Signed-off-by: David Hunt --- examples/vm_power_manager/channel_manager.c | 108 +++ examples/vm_power_manager/channel_manager.h | 17 ++- examples/vm_power_manager/channel_monitor.c | 146 +++- examples/vm_power_manager/main.c| 2 + 4 files changed, 238 insertions(+), 35 deletions(-) diff --git a/examples/vm_power_manager/channel_manager.c b/examples/vm_power_manager/channel_manager.c index 2e471d0c1..88ae108a6 100644 --- a/examples/vm_power_manager/channel_manager.c +++ b/examples/vm_power_manager/channel_manager.c @@ -13,6 +13,7 @@ #include #include +#include #include #include @@ -284,6 +285,38 @@ open_non_blocking_channel(struct channel_info *info) return 0; } +static int +open_host_channel(struct channel_info *info) +{ + int flags; + + info->fd = open(info->channel_path, O_RDWR | O_RSYNC); + if (info->fd == -1) { + RTE_LOG(ERR, CHANNEL_MANAGER, "Error(%s) opening fifo for '%s'\n", + strerror(errno), + info->channel_path); + return -1; + } + + /* Get current flags */ + flags = fcntl(info->fd, F_GETFL, 0); + if (flags < 0) { + RTE_LOG(WARNING, CHANNEL_MANAGER, "Error(%s) fcntl get flags socket for" + "'%s'\n", strerror(errno), info->channel_path); + return 1; + } + /* Set to Non Blocking */ + flags |= O_NONBLOCK; + if (fcntl(info->fd, F_SETFL, flags) < 0) { + RTE_LOG(WARNING, CHANNEL_MANAGER, + "Error(%s) setting non-blocking " + "socket for '%s'\n", + strerror(errno), info->channel_path); + return -1; + } + return 0; +} + static int setup_channel_info(struct virtual_machine_info **vm_info_dptr, struct channel_info **chan_info_dptr, unsigned channel_num) @@ -294,6 +327,7 @@ setup_channel_info(struct virtual_machine_info **vm_info_dptr, chan_info->channel_num = channel_num; chan_info->priv_info = (void *)vm_info; chan_info->status = CHANNEL_MGR_CHANNEL_DISCONNECTED; + chan_info->type = CHANNEL_TYPE_BINARY; if (open_non_blocking_channel(chan_info) < 0) { RTE_LOG(ERR, CHANNEL_MANAGER, "Could not open channel: " "'%s' for VM '%s'\n", @@ -316,6 +350,35 @@ setup_channel_info(struct virtual_machine_info **vm_info_dptr, return 0; } +static int +setup_host_channel_info(struct channel_info **chan_info_dptr, + unsigned int channel_num) +{ + struct channel_info *chan_info = *chan_info_dptr; + + chan_info->channel_num = channel_num; + chan_info->priv_info = (void *)0; + chan_info->status = CHANNEL_MGR_CHANNEL_DISCONNECTED; + chan_info->type = CHANNEL_TYPE_JSON; + sprintf(chan_info->channel_path, "%sfifo.0", CHANNEL_MGR_SOCKET_PATH); + + if (open_host_channel(chan_info) < 0) { + RTE_LOG(ERR, CHANNEL_MANAGER, "Could not open host channel: " + "'%s'\n", + chan_info->channel_path); + return -1; + } + if (add_channel_to_monitor(&chan_info) < 0) { + RTE_LOG(ERR, CHANNEL_MANAGER, "Could add channel: " + "'%s' to epoll ctl\n", + chan_info->channel_path); + return -1; + + } + chan_info->status = CHANNEL_MGR_CHANNEL_CONNECTED; + return 0; +} + int add_all_channels(const char *vm_name) { @@ -470,6 +533,51 @@ add_channels(const char *vm_name, unsigned *channel_list, return num_channels_enabled; } +int +add_host_channel(void) +{ + struct channel_info *chan_info; + char socket_path[PATH_MAX]; + int num_channels_enabled = 0; + int ret; + + snprintf(socket_path, sizeof(socket_path), "%sfifo.%u", + CHANNEL_MGR_SOCKET_PATH, 0); + + errno = 0; + ret = mkfifo(socket_path, 0666); + if ((errno != EEXIST) && (ret < 0)) { + printf(" %d %d, %d\n", ret, EEXIST, errno); + RTE_LOG(ERR, CHANNEL_MANAGER, "Cannot create fifo '%s' error: " + "%s\n", socket_path, strerror(errno)); + return 0; + } + + errno = 0; + if (access(socket_path, F_OK) < 0) { + RTE_LOG(ERR, CHANNEL_MANAGER, "Channel path '%s' error: " + "%s\n", socket_path, strerror(errno)); + return 0; + } + chan_info = rte_malloc(NULL, sizeof(*chan_info), + RTE_CACHE_LIN
[dpdk-dev] [PATCH v3 3/8] examples/power: add necessary changes to guest app
The changes here are minimal, as the guest app functionality is not changing at all, but there is a new element in the channel_packet struct that needs to have a default set (channel_packet->core_type). Signed-off-by: David Hunt --- examples/vm_power_manager/guest_cli/vm_power_cli_guest.c | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/vm_power_manager/guest_cli/vm_power_cli_guest.c b/examples/vm_power_manager/guest_cli/vm_power_cli_guest.c index 0db1b804f..2d9e7689a 100644 --- a/examples/vm_power_manager/guest_cli/vm_power_cli_guest.c +++ b/examples/vm_power_manager/guest_cli/vm_power_cli_guest.c @@ -92,6 +92,7 @@ set_policy_defaults(struct channel_packet *pkt) pkt->timer_policy.hours_to_use_traffic_profile[0] = 8; pkt->timer_policy.hours_to_use_traffic_profile[1] = 10; + pkt->core_type = CORE_TYPE_VIRTUAL; pkt->workload = LOW; pkt->policy_to_use = TIME; pkt->command = PKT_POLICY; -- 2.17.1
[dpdk-dev] [PATCH v3 5/8] examples/power: add json string handling
Add JSON string handling to vm_power_manager for JSON strings received through the fifo. The format of the JSON strings are detailed in the next patch, the vm_power_manager user guide documentation updates. This patch introduces a new dependency on Jansson, a C library for encoding, decoding and manipulating JSON data. To compile the sample app you now need to have installed libjansson4 and libjansson-dev (these may be named slightly differently depending on your Operating System) Signed-off-by: David Hunt --- examples/vm_power_manager/Makefile | 6 + examples/vm_power_manager/channel_monitor.c | 297 +--- 2 files changed, 258 insertions(+), 45 deletions(-) diff --git a/examples/vm_power_manager/Makefile b/examples/vm_power_manager/Makefile index 13a5205ba..50147c05d 100644 --- a/examples/vm_power_manager/Makefile +++ b/examples/vm_power_manager/Makefile @@ -31,6 +31,12 @@ CFLAGS += $(WERROR_FLAGS) LDLIBS += -lvirt +JANSSON := $(shell pkg-config --exists jansson; echo $$?) +ifeq ($(JANSSON), 0) +LDLIBS += $(shell pkg-config --libs jansson) +CFLAGS += -DUSE_JANSSON +endif + ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y) ifeq ($(CONFIG_RTE_LIBRTE_IXGBE_PMD),y) diff --git a/examples/vm_power_manager/channel_monitor.c b/examples/vm_power_manager/channel_monitor.c index 17383e9d2..655f5e279 100644 --- a/examples/vm_power_manager/channel_monitor.c +++ b/examples/vm_power_manager/channel_monitor.c @@ -9,11 +9,18 @@ #include #include #include +#include #include #include #include #include - +#include +#include +#ifdef USE_JANSSON +#include +#else +#pragma message "Jansson dev libs unavailable, not including JSON parsing" +#endif #include #include #include @@ -35,6 +42,8 @@ uint64_t vsi_pkt_count_prev[384]; uint64_t rdtsc_prev[384]; +#define MAX_JSON_STRING_LEN 1024 +char json_data[MAX_JSON_STRING_LEN]; double time_period_ms = 1; static volatile unsigned run_loop = 1; @@ -43,6 +52,132 @@ static unsigned int policy_is_set; static struct epoll_event *global_events_list; static struct policy policies[MAX_VMS]; +#ifdef USE_JANSSON +static int +parse_json_to_pkt(json_t *element, struct channel_packet *pkt) +{ + const char *key; + json_t *value; + int ret; + + memset(pkt, 0, sizeof(struct channel_packet)); + + pkt->nb_mac_to_monitor = 0; + pkt->t_boost_status.tbEnabled = false; + pkt->workload = LOW; + pkt->policy_to_use = TIME; + pkt->command = PKT_POLICY; + pkt->core_type = CORE_TYPE_PHYSICAL; + + json_object_foreach(element, key, value) { + if (!strcmp(key, "policy")) { + /* Recurse in to get the contents of profile */ + ret = parse_json_to_pkt(value, pkt); + if (ret) + return ret; + } else if (!strcmp(key, "instruction")) { + /* Recurse in to get the contents of instruction */ + ret = parse_json_to_pkt(value, pkt); + if (ret) + return ret; + } else if (!strcmp(key, "name")) { + strcpy(pkt->vm_name, json_string_value(value)); + } else if (!strcmp(key, "command")) { + char command[32]; + snprintf(command, 32, "%s", json_string_value(value)); + if (!strcmp(command, "power")) { + pkt->command = CPU_POWER; + } else if (!strcmp(command, "create")) { + pkt->command = PKT_POLICY; + } else if (!strcmp(command, "destroy")) { + pkt->command = PKT_POLICY_REMOVE; + } else { + RTE_LOG(ERR, CHANNEL_MONITOR, + "Invalid command received in JSON\n"); + return -1; + } + } else if (!strcmp(key, "policy_type")) { + char command[32]; + snprintf(command, 32, "%s", json_string_value(value)); + if (!strcmp(command, "TIME")) { + pkt->policy_to_use = TIME; + } else if (!strcmp(command, "TRAFFIC")) { + pkt->policy_to_use = TRAFFIC; + } else if (!strcmp(command, "WORKLOAD")) { + pkt->policy_to_use = WORKLOAD; + } else if (!strcmp(command, "BRANCH_RATIO")) { + pkt->policy_to_use = BRANCH_RATIO; + } else { + RTE_LOG(ERR, CHANNEL_MONITOR, + "Wrong policy_type received in JSON\n"); + return -1; + } +
[dpdk-dev] [PATCH v3 6/8] examples/power: add meson/ninja build support
Add meson.build in vm_power_manager and the guest_cli subdirectory. Building can be achieved by going to the build directory, and using meson configure -Dexamples=vm_power_manager,vm_power_manager/guest_cli Then, when ninja is invoked, it will build dpdk-vm_power_manger and dpdk-guest_cli Work still needs to be done on the meson build system to handles the case where the target list of example apps is defined as 'all'. That will come in a future patch. Signed-off-by: David Hunt --- .../vm_power_manager/guest_cli/meson.build| 21 +++ examples/vm_power_manager/meson.build | 37 ++- 2 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 examples/vm_power_manager/guest_cli/meson.build diff --git a/examples/vm_power_manager/guest_cli/meson.build b/examples/vm_power_manager/guest_cli/meson.build new file mode 100644 index 0..9e821ceb8 --- /dev/null +++ b/examples/vm_power_manager/guest_cli/meson.build @@ -0,0 +1,21 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2018 Intel Corporation + +# meson file, for building this example as part of a main DPDK build. +# +# To build this example as a standalone application with an already-installed +# DPDK instance, use 'make' + +# Setting the name here because the default name will conflict with the +# vm_power_manager app because of the way the directories are parsed. +name = 'guest_cli' + +deps += ['power'] + +sources = files( + 'main.c', 'parse.c', 'vm_power_cli_guest.c' +) + +opt_dep = cc.find_library('virt', required : false) +build = opt_dep.found() +ext_deps += opt_dep diff --git a/examples/vm_power_manager/meson.build b/examples/vm_power_manager/meson.build index c370d7476..f98445bc6 100644 --- a/examples/vm_power_manager/meson.build +++ b/examples/vm_power_manager/meson.build @@ -6,5 +6,38 @@ # To build this example as a standalone application with an already-installed # DPDK instance, use 'make' -# Example app currently unsupported by meson build -build = false +if dpdk_conf.has('RTE_LIBRTE_BNXT_PMD') + deps += ['pmd_bnxt'] +endif + +if dpdk_conf.has('RTE_LIBRTE_I40E_PMD') + deps += ['pmd_i40e'] +endif + +if dpdk_conf.has('RTE_LIBRTE_IXGBE_PMD') + deps += ['pmd_ixgbe'] +endif + +deps += ['power'] + + +sources = files( + 'channel_manager.c', 'channel_monitor.c', 'main.c', 'parse.c', 'power_manager.c', 'vm_power_cli.c' +) + +# If we're on X86, pull in the x86 code for the branch monitor algo. +if dpdk_conf.has('RTE_ARCH_X86_64') + sources += files('oob_monitor_x86.c') +else + sources += files('oob_monitor_nop.c') +endif + +opt_dep = cc.find_library('virt', required : false) +build = opt_dep.found() +ext_deps += opt_dep + +opt_dep = dependency('jansson', required : false) +if opt_dep.found() + ext_deps += opt_dep + cflags += '-DUSE_JANSSON' +endif -- 2.17.1
[dpdk-dev] [PATCH v3 7/8] doc/vm_power_manager: add JSON interface API info
Also added meson/ninja build info Signed-off-by: David Hunt --- .../sample_app_ug/vm_power_management.rst | 272 +- 1 file changed, 270 insertions(+), 2 deletions(-) diff --git a/doc/guides/sample_app_ug/vm_power_management.rst b/doc/guides/sample_app_ug/vm_power_management.rst index 855570d6b..038cf1f93 100644 --- a/doc/guides/sample_app_ug/vm_power_management.rst +++ b/doc/guides/sample_app_ug/vm_power_management.rst @@ -199,7 +199,7 @@ see :doc:`compiling`. The application is located in the ``vm_power_manager`` sub-directory. -To build just the ``vm_power_manager`` application: +To build just the ``vm_power_manager`` application using ``make``: .. code-block:: console @@ -208,6 +208,22 @@ To build just the ``vm_power_manager`` application: cd ${RTE_SDK}/examples/vm_power_manager/ make +The resulting binary will be ${RTE_SDK}/build/examples/vm_power_manager + +To build just the ``vm_power_manager`` application using ``meson/ninja``: + +.. code-block:: console + + export RTE_SDK=/path/to/rte_sdk + cd ${RTE_SDK} + meson build + cd build + ninja + meson configure -Dexamples=vm_power_manager + ninja + +The resulting binary will be ${RTE_SDK}/build/examples/dpdk-vm_power_manager + Running ~~~ @@ -337,6 +353,242 @@ monitoring of branch ratio on cores doing busy polling via PMDs. and will need to be adjusted for different workloads. + +JSON API + + +In addition to the command line interface for host command and a virtio-serial +interface for VM power policies, there is also a JSON interface through which +power commands and policies can be sent. This functionality adds a dependency +on the Jansson library, and the Jansson development package must be installed +on the system before the JSON parsing functionality is included in the app. +This is achieved by: + + .. code-block:: console + +apt-get install libjansson-dev + +The command and package name may be different depending on your operating +system. It's worth noting that the app will successfully build without this +package present, but a warning is shown during compilation, and the JSON +parsing functionality will not be present in the app. + +Sending a command or policy to the power manager application is achieved by +simply opening a fifo file, writing a JSON string to that fifo, and closing +the file. + +The fifo is at /tmp/powermonitor/fifo.0 + +The jason string can be a policy or instruction, and takes the following +format: + + .. code-block:: console + +{"packet_type": { + "pair_1": value, + "pair_2": value +}} + +The 'packet_type' header can contain one of two values, depending on +whether a policy or power command is being sent. The two possible values are +"policy" and "instruction", and the expected name-value pairs is different +depending on which type is being sent. + +The pairs are the format of standard JSON name-value pairs. The value type +varies between the different name/value pairs, and may be intgers, strings, +arrays, etc. Examples of policies follow later in this document. The allowed +names and value types are as follows: + + +:Pair Name: "name" +:Description: Name of the VM or Host. Allows the parser to associate the + policy with the relevant VM or Host OS. +:Type: string +:Values: any valid string +:Required: yes +:Example: + + .. code-block:: console + +""name", "ubuntu2" + + +:Pair Name: "command" +:Description: The type of packet we're sending to the power manager. We can be + creating or destroying a policy, or sending a direct command to adjust + the frequency of a core, similar to the command line interface. +:Type: string +:Values: + + :"CREATE": used when creating a new policy, + :"DESTROY": used when removing a policy, + :"POWER": used when sending an immediate command, max, min, etc. +:Required: yes +:Example: + +.. code-block:: console + + "command", "CREATE" + + +:Pair Name: "policy_type" +:Description: Type of policy to apply. Please see vm_power_manager documentation + for more information on the types of policies that may be used. +:Type: string +:Values: + + :"TIME": Time-of-day policy. Frequencies of the relevant cores are +scaled up/down depending on busy and quiet hours. + :"TRAFFIC": This policy takes statistics from the NIC and scales up +and down accordingly. + :"WORKLOAD": This policy looks at how heavily loaded the cores are, +and scales up and down accordingly. + :"BRANCH_RATIO": This out-of-band policy can look at the ratio between +branch hits and misses on a core, and is useful for detecting +how much packet processing a core is doing. +:Required: only for CREATE/DESTROY command +:Example: + + .. code-block:: console + +"policy_type", "TIME" + +:Pair Name: "busy_hours" +:Description: The hours of the day in which we scale up the cores for busy + times. +:Type: array of integers +:Values: array with list of hour numbers, (0-23) +:Required: only for TIME pol
[dpdk-dev] [PATCH v3 8/8] examples/power: add json example files
This patch provides some example files in the json_examples sub-directory for sending to the fifo. Signed-off-by: David Hunt --- examples/vm_power_manager/json_examples/README| 6 ++ examples/vm_power_manager/json_examples/create.json | 8 examples/vm_power_manager/json_examples/destroy.json | 4 examples/vm_power_manager/json_examples/set_core_max.json | 6 ++ examples/vm_power_manager/json_examples/set_core_min.json | 6 ++ 5 files changed, 30 insertions(+) create mode 100644 examples/vm_power_manager/json_examples/README create mode 100644 examples/vm_power_manager/json_examples/create.json create mode 100644 examples/vm_power_manager/json_examples/destroy.json create mode 100644 examples/vm_power_manager/json_examples/set_core_max.json create mode 100644 examples/vm_power_manager/json_examples/set_core_min.json diff --git a/examples/vm_power_manager/json_examples/README b/examples/vm_power_manager/json_examples/README new file mode 100644 index 0..a94c6b14b --- /dev/null +++ b/examples/vm_power_manager/json_examples/README @@ -0,0 +1,6 @@ +Sample files for sending to the vm_power_manager through the fifo. + +Simply cat the file to /tmp/powermonitor/fifo.0 when the vm_power_manager +application is running. + +E.g. cat create.json >/tmp/powermonitor/fifo.0 diff --git a/examples/vm_power_manager/json_examples/create.json b/examples/vm_power_manager/json_examples/create.json new file mode 100644 index 0..a7133d9a1 --- /dev/null +++ b/examples/vm_power_manager/json_examples/create.json @@ -0,0 +1,8 @@ +{"policy": { + "name": "policy-1", + "command": "create", + "policy_type": "TIME", + "busy_hours":[ 17, 18, 19, 20, 21, 22, 23 ], + "quiet_hours":[ 2, 3, 4, 5, 6 ], + "core_list":[ 11, 12 ] +}} diff --git a/examples/vm_power_manager/json_examples/destroy.json b/examples/vm_power_manager/json_examples/destroy.json new file mode 100644 index 0..587c9e7e9 --- /dev/null +++ b/examples/vm_power_manager/json_examples/destroy.json @@ -0,0 +1,4 @@ +{"policy": { + "name": "policy-1", + "command": "destroy" +}} diff --git a/examples/vm_power_manager/json_examples/set_core_max.json b/examples/vm_power_manager/json_examples/set_core_max.json new file mode 100644 index 0..497030a44 --- /dev/null +++ b/examples/vm_power_manager/json_examples/set_core_max.json @@ -0,0 +1,6 @@ +{"instruction": { + "name": "set_power", + "command": "power", + "unit": "SCALE_MAX", + "resource_id": 10 +}} diff --git a/examples/vm_power_manager/json_examples/set_core_min.json b/examples/vm_power_manager/json_examples/set_core_min.json new file mode 100644 index 0..76d934fd8 --- /dev/null +++ b/examples/vm_power_manager/json_examples/set_core_min.json @@ -0,0 +1,6 @@ +{"instruction": { + "name": "set_power", + "command": "power", + "unit": "SCALE_MIN", + "resource_id": 10 +}} -- 2.17.1
[dpdk-dev] [PATCH] test: fix kni test to check kni module dependency
Check the prerequisites to run the test 1.checked whether the rte_kni module is loaded, if not fail testcase 2.checked whether the rte_kni module is loaded with loop back mode, if not skip packet forwarding testcase and log 3.Disabled the test in freebsd as test is not supported Fixes: 5233e5924a ("app/test: update kni") Signed-off-by: Naga Suresh Somarowthu --- test/test/test_kni.c | 49 ++--- 1 file changed, 38 insertions(+), 11 deletions(-) diff --git a/test/test/test_kni.c b/test/test/test_kni.c index 1b876719a..6c1420a16 100644 --- a/test/test/test_kni.c +++ b/test/test/test_kni.c @@ -7,10 +7,11 @@ #include #include #include +#include #include "test.h" -#ifndef RTE_LIBRTE_KNI +#if !defined(RTE_EXEC_ENV_LINUXAPP) || !defined(RTE_LIBRTE_KNI) static int test_kni(void) @@ -40,6 +41,8 @@ test_kni(void) #define IFCONFIG "/sbin/ifconfig " #define TEST_KNI_PORT "test_kni_port" +#define KNI_MODULE_PATH "/sys/module/rte_kni" +#define KNI_MODULE_PARAM_LO KNI_MODULE_PATH"/parameters/lo_mode" #define KNI_TEST_MAX_PORTS 4 /* The threshold number of mbufs to be transmitted or received. */ #define KNI_NUM_MBUF_THRESHOLD 100 @@ -462,7 +465,7 @@ static int test_kni(void) { int ret = -1; - uint16_t nb_ports, port_id; + uint16_t port_id; struct rte_kni *kni; struct rte_mempool *mp; struct rte_kni_conf conf; @@ -470,6 +473,20 @@ test_kni(void) struct rte_kni_ops ops; const struct rte_pci_device *pci_dev; const struct rte_bus *bus; + FILE *fd; + DIR *dir; + char buf[16]; + + dir = opendir(KNI_MODULE_PATH); + if (!dir) { + if (errno == ENOENT) { + printf("Cannot run UT due to missing rte_kni module\n"); + return -1; + } + printf("opendir: %s", strerror(errno)); + return -1; + } + closedir(dir); /* Initialize KNI subsytem */ rte_kni_init(KNI_TEST_MAX_PORTS); @@ -485,12 +502,6 @@ test_kni(void) return -1; } - nb_ports = rte_eth_dev_count_avail(); - if (nb_ports == 0) { - printf("no supported nic port found\n"); - return -1; - } - /* configuring port 0 for the test is enough */ port_id = 0; ret = rte_eth_dev_configure(port_id, 1, 1, &port_conf); @@ -519,9 +530,25 @@ test_kni(void) rte_eth_promiscuous_enable(port_id); /* basic test of kni processing */ - ret = test_kni_processing(port_id, mp); - if (ret < 0) - goto fail; + fd = fopen(KNI_MODULE_PARAM_LO, "r"); + if (fd == NULL) { + printf("fopen: %s", strerror(errno)); + return -1; + } + memset(&buf, 0, sizeof(buf)); + if (fgets(buf, sizeof(buf), fd)) { + if (!strncmp(buf, "lo_mode_fifo", strlen("lo_mode_fifo")) || + !strncmp(buf, "lo_mode_fifo_skb", + strlen("lo_mode_fifo_skb"))) { + ret = test_kni_processing(port_id, mp); + if (ret < 0) { + fclose(fd); + goto fail; + } + } else + printf("test_kni_processing skipped because of missing rte_kni module lo_mode argument\n"); + } + fclose(fd); /* test of allocating KNI with NULL mempool pointer */ memset(&info, 0, sizeof(info)); -- 2.13.6
Re: [dpdk-dev] [PATCH 1/5] bus/vmbus: add devargs support
On Fri, Sep 14, 2018 at 02:19:19PM +0100, Ferruh Yigit wrote: > On 9/14/2018 2:06 PM, Gaëtan Rivet wrote: > > Hi, > > > > On Fri, Sep 14, 2018 at 01:46:59PM +0100, Ferruh Yigit wrote: > >> On 8/30/2018 11:35 PM, Stephen Hemminger wrote: > >>> From: Stephen Hemminger > >>> > >>> Take device arguments from command line and put > >>> them in the device devargs. > >>> > >>> Signed-off-by: Stephen Hemminger > >> > >> <...> > >> > >>> @@ -204,6 +203,27 @@ vmbus_parse(const char *name, void *addr) > >>> return ret; > >>> } > >>> > >>> +/* > >>> + * scan for matching device args on command line > >>> + * example: > >>> + * -w 'vmbus(635a7ae3-091e-4410-ad59-667c4f8c04c3,latency=20)' > >> > >> This is just in comment but, > >> > >> I guess latest syntax is: > >> -w "vmbus:635a7ae3-091e-4410-ad59-667c4f8c04c3,latency=20" > >> > >> @Gaetan, is latest devarg syntax documented somewhere? > > > > That's the current syntax indeed. Some documentation is found at > > > > lib/librte_eal/common/include/rte_devargs.h:100 > > > > Where it is specified that the bus name can be either omitted or > > followed by any character, to separate it from the device identifier. > > > > This means that using ':' is fine, as well as '('. As long as the device > > PMD afterward ignore the dangling ')' during devargs parsing, this should > > be fine. > > > > I don't think this is very clean, but it works. > > Thanks for the info, I see how "(" works, but ")" is takes as part of argument > and causing problem, I think better to not give "()" as supported syntax at > all. > > btw, now both -w and --vdev are valid and can be used interchangeably, right? > I > mean all following are valid? > -w pci::86:06.0,enable_floating_veb=1 > -w vdev:net_pcap,iface=lo > --vdev pci::86:06.0,enable_floating_veb=1 > --vdev vdev:net_pcap,iface=lo > > They are both valid but cannot be used interchangeably. This was the case at one point, between two rcs, because I had removed the devtype and the bus black/white-listing was configured another way. A user complained about the API change because it was not announced in time IIRC, and this was scrapped. Since then, the effort has been to on the new syntax instead of cleaning the old system. They cannot be used interchangeably because an rte_devtype is defined by the parameter choosen. BLACKLISTED_PCI for -b, WHITELISTED_PCI for -w, and VIRTUAL for --vdev. -b will actually change the bus configuration to "blacklist mode", -w to "whitelist mode", and --vdev will do nothing. So a PCI device declared using --vdev, will actually be skipped during PCI probe because by default it operates in blacklist mode, and the device policy is not WHITELISTED. This could surprise the one attempting this trick. This semantic is subtle and bug-prone. I'm adding it to the pile of reasons I'd like to remove the blacklist mode altogether. -- Gaëtan Rivet 6WIND
Re: [dpdk-dev] [PATCH v3 6/8] examples/power: add meson/ninja build support
On Fri, Sep 14, 2018 at 02:54:04PM +0100, David Hunt wrote: > Add meson.build in vm_power_manager and the guest_cli subdirectory. > Building can be achieved by going to the build directory, and using > > meson configure -Dexamples=vm_power_manager,vm_power_manager/guest_cli > > Then, when ninja is invoked, it will build dpdk-vm_power_manger and > dpdk-guest_cli > > Work still needs to be done on the meson build system to handles the case > where the target list of example apps is defined as 'all'. That will come > in a future patch. > > Signed-off-by: David Hunt > --- The examples=all limitation only applies to the guest_cli app, because it's in a subdirectory. That should be possible to manage in a later changeset, but this is good for now, as it still has the main app buildable with the test-meson-builds script. Acked-by: Bruce Richardson
Re: [dpdk-dev] [PATCH] app/testpmd: show errno along with flow API errors
On 8/31/2018 10:10 AM, Adrien Mazarguil wrote: > Signed-off-by: Adrien Mazarguil Reviewed-by: Ferruh Yigit
Re: [dpdk-dev] [PATCH] app/testpmd: show errno along with flow API errors
On 9/14/2018 3:27 PM, Ferruh Yigit wrote: > On 8/31/2018 10:10 AM, Adrien Mazarguil wrote: >> Signed-off-by: Adrien Mazarguil > > Reviewed-by: Ferruh Yigit Applied to dpdk-next-net/master, thanks.
Re: [dpdk-dev] [PATCH] test: fix kni test to check kni module dependency
On 9/14/2018 2:57 PM, Naga Suresh Somarowthu wrote: > Check the prerequisites to run the test > 1.checked whether the rte_kni module is loaded, if not fail testcase > 2.checked whether the rte_kni module is loaded with loop back mode, > if not skip packet forwarding testcase and log > 3.Disabled the test in freebsd as test is not supported > > Fixes: 5233e5924a ("app/test: update kni") > > Signed-off-by: Naga Suresh Somarowthu Cc: sta...@dpdk.org Acked-by: Ferruh Yigit
Re: [dpdk-dev] [dpdk-stable] [PATCH] devtools: don't use bash extension in checkpatches
16/08/2018 07:25, Arnon Warshavsky: > Hi Ilya > > Let's use single quotes instead of variable. > > > Using the script directly with single quotes loses the ability to reuse it > with an additional set of folders , expressions and RET_ON_FAIL. I don't know awk. Please could you explain what we are loosing and why? > If we wish to keep the awk code in this file and not in a separate file, > maybe receiving the awk script parameters from the function > check_forbidden_additions( ) can also preserve the ability to reuse in > future cases. Yes I feel we could add some parameters to this function. And yes, we could move the awk script in a separate file. Actually, it would be better to keep checkpatches.sh as a wrapper script calling various tools. Thanks
Re: [dpdk-dev] [dpdk-stable] [PATCH] vhost: fix vhost interrupt support
On Fri, Sep 14, 2018 at 01:10:07PM +0100, Ferruh Yigit wrote: > On 9/10/2018 8:36 AM, Tiwei Bie wrote: > > Hi Maxime, > > > > On Mon, Sep 10, 2018 at 09:22:00AM +0200, Maxime Coquelin wrote: > >> Hi Tiwei, > >> > >> On 09/05/2018 01:55 AM, Tiwei Bie wrote: > >>> When VIRTIO_RING_F_EVENT_IDX is negotiated, we need to > >>> update the avail event to enable the notification. > >>> > >>> Fixes: 3f8ff12821e4 ("vhost: support interrupt mode") > >>> Cc: sta...@dpdk.org > >>> > >>> Signed-off-by: Tiwei Bie > >>> --- > >>> lib/librte_vhost/Makefile | 1 + > >>> lib/librte_vhost/vhost.c | 18 -- > >>> lib/librte_vhost/vhost.h | 2 ++ > >>> 3 files changed, 15 insertions(+), 6 deletions(-) > >>> > >>> diff --git a/lib/librte_vhost/Makefile b/lib/librte_vhost/Makefile > >>> index de431fbb7..531cf4832 100644 > >>> --- a/lib/librte_vhost/Makefile > >>> +++ b/lib/librte_vhost/Makefile > >>> @@ -13,6 +13,7 @@ LIBABIVER := 4 > >>> CFLAGS += -DALLOW_EXPERIMENTAL_API > >>> CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) -O3 -D_FILE_OFFSET_BITS=64 > >>> CFLAGS += -I vhost_user > >>> +CFLAGS += -fno-strict-aliasing > >> > >> I'm not clear why this is needed looking at the code below, > >> could you please explain? > > > > Without this, we will get below build error: > > > > lib/librte_vhost/vhost.c: In function ‘vhost_enable_notify_split’: > > lib/librte_vhost/vhost.h:656:4: error: dereferencing type-punned pointer > > will break strict-aliasing rules [-Werror=strict-aliasing] > > (*(volatile uint16_t*)&(vr)->used->ring[(vr)->size]) > > ^ > > lib/librte_vhost/vhost.c:659:4: note: in expansion of macro > > ‘vhost_avail_event’ > > vhost_avail_event(vq) = vq->last_avail_idx; > > ^ > > cc1: all warnings being treated as errors > > > > Getting this error with meson build system, since "-fno-strict-aliasing" is > not > added to meson build file. Thanks! I didn't notice this. I just tried the meson build manually. The warning isn't treated as errors on my side. So it was not caught by the build script.. > BUT instead of disabling compiler warning, > > first element of the "struct vring_used_elem ring[0]" is "uint32_t id;", so it > should be accessed as uint32_t. What about following: > > #define vhost_avail_event(vr) \ > - (*(volatile uint16_t*)&(vr)->used->ring[(vr)->size]) > + (*(volatile uint32_t*)&(vr)->used->ring[(vr)->size]) > > And for "vhost_avail_event(vq) = vq->last_avail_idx;", "last_avail_idx" is > uint16_t, so assigning from uint16_t to uint32_t should be ok too. At the end of used ring, there is a 16bits event_idx. It can't be interpreted as a vring_used_elem and it's also not part of a vring_used_elem. This is the traditional way how we access it: https://github.com/torvalds/linux/blob/a06b0c82a049/drivers/vhost/vhost.c#L50 https://github.com/freebsd/freebsd/blob/209b94df8701/sys/dev/virtio/virtio_ring.h#L133 > > If above works for you please send a patch for update also removing > "-fno-strict-aliasing", this can be rebased on existing patch. > > If not works, please at least send a patch to add flag to meson build file I'll send a patch to add flag to meson build file. Thanks! > > Thanks, > ferruh > > >> > >>> LDLIBS += -lpthread > >>> ifeq ($(CONFIG_RTE_LIBRTE_VHOST_NUMA),y) > >>> diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c > >>> index 3c9be10a0..88b1781d5 100644 > >>> --- a/lib/librte_vhost/vhost.c > >>> +++ b/lib/librte_vhost/vhost.c > >>> @@ -646,12 +646,18 @@ rte_vhost_avail_entries(int vid, uint16_t queue_id) > >>> } > >>> static inline void > >>> -vhost_enable_notify_split(struct vhost_virtqueue *vq, int enable) > >>> +vhost_enable_notify_split(struct virtio_net *dev, > >>> + struct vhost_virtqueue *vq, int enable) > >>> { > >>> - if (enable) > >>> - vq->used->flags &= ~VRING_USED_F_NO_NOTIFY; > >>> - else > >>> - vq->used->flags |= VRING_USED_F_NO_NOTIFY; > >>> + if (!(dev->features & (1ULL << VIRTIO_RING_F_EVENT_IDX))) { > >>> + if (enable) > >>> + vq->used->flags &= ~VRING_USED_F_NO_NOTIFY; > >>> + else > >>> + vq->used->flags |= VRING_USED_F_NO_NOTIFY; > >>> + } else { > >>> + if (enable) > >>> + vhost_avail_event(vq) = vq->last_avail_idx; > >>> + } > >>> } > >>> static inline void > >>> @@ -689,7 +695,7 @@ rte_vhost_enable_guest_notification(int vid, uint16_t > >>> queue_id, int enable) > >>> if (vq_is_packed(dev)) > >>> vhost_enable_notify_packed(dev, vq, enable); > >>> else > >>> - vhost_enable_notify_split(vq, enable); > >>> + vhost_enable_notify_split(dev, vq, enable); > >>> return 0; > >>> } > >>> diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h > >>> index 760a09c0d..25ffd7614 100644 > >>> --- a/lib/librte_vhost/vhost.h > >>> +++ b/lib/librte_vhost/vhos
[dpdk-dev] [PATCH] vhost: add missing cflags in meson build
Fixes: 6ee380ffb5e7 ("vhost: fix vhost interrupt support") Signed-off-by: Tiwei Bie --- Hi Ferruh, The hash in above fixes line isn't really right, because that patch hasn't been committed to the main repo yet. Please squash this patch to that one if possible. Thanks! lib/librte_vhost/meson.build | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/librte_vhost/meson.build b/lib/librte_vhost/meson.build index bd62e0e39..9d25b4d88 100644 --- a/lib/librte_vhost/meson.build +++ b/lib/librte_vhost/meson.build @@ -9,6 +9,7 @@ if has_libnuma == 1 endif version = 4 allow_experimental_apis = true +cflags += '-fno-strict-aliasing' sources = files('fd_man.c', 'iotlb.c', 'socket.c', 'vdpa.c', 'vhost.c', 'vhost_user.c', 'virtio_net.c', 'vhost_crypto.c') -- 2.18.0
Re: [dpdk-dev] [PATCH] doc: add cross compile part for sample applications
14/08/2018 18:18, Gavin Hu: > +For cross compiling the sample application(s), please append > 'CC=$(CROSS_COMPILER)' to the 'make' command. As you can see in doc/build-sdk-quick.txt, you should use CROSS= for cross compilation. > +For example: > +export CROSS_COMPILER=aarch64-linux-gnu-gcc > +make -C examples CC=$(CROSS_COMPILER) It should be make -C examples CROSS=aarch64-linux-gnu- Please would you like to make a patch v2 ?
Re: [dpdk-dev] [dpdk-stable] [PATCH] devtools: don't use bash extension in checkpatches
Hi Thomas. Beside your questions, There is another patch that targeted to fix this issue: http://patches.dpdk.org/patch/44020/ And one similar to mine that I missed while sending: http://patches.dpdk.org/patch/43692/ So, I'm not sure which one should be accepted and if I need to update my version. What do you think? Stephen? Andrzej? Best regards, Ilya Maximets. On 14.09.2018 17:50, Thomas Monjalon wrote: > 16/08/2018 07:25, Arnon Warshavsky: >> Hi Ilya >> >> Let's use single quotes instead of variable. >> >> >> Using the script directly with single quotes loses the ability to reuse it >> with an additional set of folders , expressions and RET_ON_FAIL. > > I don't know awk. Please could you explain what we are loosing and why? > >> If we wish to keep the awk code in this file and not in a separate file, >> maybe receiving the awk script parameters from the function >> check_forbidden_additions( ) can also preserve the ability to reuse in >> future cases. > > Yes I feel we could add some parameters to this function. > And yes, we could move the awk script in a separate file. > Actually, it would be better to keep checkpatches.sh as a wrapper script > calling various tools. > > Thanks > > > >
Re: [dpdk-dev] [PATCH 1/5] bus/vmbus: add devargs support
On Fri, 14 Sep 2018 15:58:04 +0200 Gaëtan Rivet wrote: > On Fri, Sep 14, 2018 at 02:19:19PM +0100, Ferruh Yigit wrote: > > On 9/14/2018 2:06 PM, Gaëtan Rivet wrote: > > > Hi, > > > > > > On Fri, Sep 14, 2018 at 01:46:59PM +0100, Ferruh Yigit wrote: > > >> On 8/30/2018 11:35 PM, Stephen Hemminger wrote: > > >>> From: Stephen Hemminger > > >>> > > >>> Take device arguments from command line and put > > >>> them in the device devargs. > > >>> > > >>> Signed-off-by: Stephen Hemminger > > >> > > >> <...> > > >> > > >>> @@ -204,6 +203,27 @@ vmbus_parse(const char *name, void *addr) > > >>> return ret; > > >>> } > > >>> > > >>> +/* > > >>> + * scan for matching device args on command line > > >>> + * example: > > >>> + * -w 'vmbus(635a7ae3-091e-4410-ad59-667c4f8c04c3,latency=20)' > > >> > > >> This is just in comment but, > > >> > > >> I guess latest syntax is: > > >> -w "vmbus:635a7ae3-091e-4410-ad59-667c4f8c04c3,latency=20" > > >> > > >> @Gaetan, is latest devarg syntax documented somewhere? > > > > > > That's the current syntax indeed. Some documentation is found at > > > > > > lib/librte_eal/common/include/rte_devargs.h:100 > > > > > > Where it is specified that the bus name can be either omitted or > > > followed by any character, to separate it from the device identifier. > > > > > > This means that using ':' is fine, as well as '('. As long as the device > > > PMD afterward ignore the dangling ')' during devargs parsing, this should > > > be fine. > > > > > > I don't think this is very clean, but it works. > > > > Thanks for the info, I see how "(" works, but ")" is takes as part of > > argument > > and causing problem, I think better to not give "()" as supported syntax at > > all. > > > > btw, now both -w and --vdev are valid and can be used interchangeably, > > right? I > > mean all following are valid? > > -w pci::86:06.0,enable_floating_veb=1 > > -w vdev:net_pcap,iface=lo > > --vdev pci::86:06.0,enable_floating_veb=1 > > --vdev vdev:net_pcap,iface=lo > > > > > > They are both valid but cannot be used interchangeably. > > This was the case at one point, between two rcs, because I had removed > the devtype and the bus black/white-listing was configured another way. > > A user complained about the API change because it was not announced in > time IIRC, and this was scrapped. Since then, the effort has been to on > the new syntax instead of cleaning the old system. > > They cannot be used interchangeably because an rte_devtype is defined by > the parameter choosen. BLACKLISTED_PCI for -b, WHITELISTED_PCI for -w, > and VIRTUAL for --vdev. > > -b will actually change the bus configuration to "blacklist mode", -w to > "whitelist mode", and --vdev will do nothing. > > So a PCI device declared using --vdev, will actually be skipped during > PCI probe because by default it operates in blacklist mode, and the > device policy is not WHITELISTED. This could surprise the one attempting > this trick. > > This semantic is subtle and bug-prone. I'm adding it to the pile of > reasons I'd like to remove the blacklist mode altogether. > It would have been nice if there was a --devargs instead of overloading -w and -b. Especially when just changing parameter on a device.
Re: [dpdk-dev] [PATCH 5/5] net/netvsc: integrated VF support
On Fri, 14 Sep 2018 13:57:58 +0100 Ferruh Yigit wrote: > On 8/30/2018 11:35 PM, Stephen Hemminger wrote: > > From: Stephen Hemminger > > > > Integrate accelerated networking support into netvsc PMD. > > This allows netvsc to manage VF without using failsafe or vdev_netvsc. > > For the exception vswitch path some tests like transmit > > get a 22% increase in packets/sec. > > For the VF path, the code is slightly shorter but has no > > real change in performance. > > > > Pro: > >* using netvsc is more like other DPDK NIC's > >* the exception packet uses less CPU > >* much smaller code size > >* no locking required on VF transmit/receive path > >* no legacy Linux network device to get mangled by userspace > >* much simpler (1K vs 9K) LOC > >* unified extended statistics > > > > Con: > >* using netvsc has more complex startup model > >* no bifurcated driver support > >* no flow support (since host does not have flow API). > >* no tunnel offload support > >* no receive interrupt support > > > > Signed-off-by: Stephen Hemminger > > --- > > devtools/checkpatches.sh | 2 +- > > doc/guides/nics/netvsc.rst | 12 +- > > doc/guides/rel_notes/release_18_11.rst | 14 +- > > drivers/net/netvsc/Makefile| 1 + > > drivers/net/netvsc/hn_ethdev.c | 109 +- > > drivers/net/netvsc/hn_nvs.c| 11 +- > > drivers/net/netvsc/hn_nvs.h| 9 + > > drivers/net/netvsc/hn_rndis.c | 31 ++ > > drivers/net/netvsc/hn_rndis.h | 1 + > > drivers/net/netvsc/hn_rxtx.c | 136 --- > > drivers/net/netvsc/hn_var.h| 43 ++- > > drivers/net/netvsc/hn_vf.c | 512 + > > drivers/net/netvsc/meson.build | 2 +- > > 13 files changed, 799 insertions(+), 84 deletions(-) > > create mode 100644 drivers/net/netvsc/hn_vf.c > > > > diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh > > index ba795ad1dc36..db7afc43d4c0 100755 > > --- a/devtools/checkpatches.sh > > +++ b/devtools/checkpatches.sh > > @@ -1,4 +1,4 @@ > > -#! /bin/sh > > +#! /bin/bash > > # SPDX-License-Identifier: BSD-3-Clause > > # Copyright 2015 6WIND S.A. > > This tool patch shouldn't be part of driver update, would you mind sending a > separate patch for it? Sorry, that slipped in. Will drop it.
[dpdk-dev] [PATCH] igb_uio: fix refcount if open returns error
This fixes the problem of reference count leak if igbuio_pci_enable_interrupts fails. Also, replace mutex and integer with a kernel atomic counter. This is standard pattern for kernel devices. Fixes: 19685d5aa79c ("igb_uio: allow multi-process access") Signed-off-by: Stephen Hemminger --- kernel/linux/igb_uio/igb_uio.c | 33 +++-- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/kernel/linux/igb_uio/igb_uio.c b/kernel/linux/igb_uio/igb_uio.c index 3398eacd3fcc..fede66cf2735 100644 --- a/kernel/linux/igb_uio/igb_uio.c +++ b/kernel/linux/igb_uio/igb_uio.c @@ -26,8 +26,7 @@ struct rte_uio_pci_dev { struct uio_info info; struct pci_dev *pdev; enum rte_intr_mode mode; - struct mutex lock; - int refcnt; + atomic_t refcnt; }; static int wc_activate; @@ -320,23 +319,19 @@ igbuio_pci_open(struct uio_info *info, struct inode *inode) struct pci_dev *dev = udev->pdev; int err; - mutex_lock(&udev->lock); - if (++udev->refcnt > 1) { - mutex_unlock(&udev->lock); + if (atomic_inc_return(&udev->refcnt) != 1) return 0; - } /* set bus master, which was cleared by the reset function */ pci_set_master(dev); /* enable interrupts */ err = igbuio_pci_enable_interrupts(udev); - mutex_unlock(&udev->lock); if (err) { + atomic_dec(&udev->refcnt); dev_err(&dev->dev, "Enable interrupt fails\n"); - return err; } - return 0; + return err; } static int @@ -345,19 +340,14 @@ igbuio_pci_release(struct uio_info *info, struct inode *inode) struct rte_uio_pci_dev *udev = info->priv; struct pci_dev *dev = udev->pdev; - mutex_lock(&udev->lock); - if (--udev->refcnt > 0) { - mutex_unlock(&udev->lock); - return 0; - } - - /* disable interrupts */ - igbuio_pci_disable_interrupts(udev); + if (atomic_dec_and_test(&udev->refcnt)) { + /* disable interrupts */ + igbuio_pci_disable_interrupts(udev); - /* stop the device from further DMA */ - pci_clear_master(dev); + /* stop the device from further DMA */ + pci_clear_master(dev); + } - mutex_unlock(&udev->lock); return 0; } @@ -489,7 +479,6 @@ igbuio_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) if (!udev) return -ENOMEM; - mutex_init(&udev->lock); /* * enable device: ask low-level code to enable I/O and * memory @@ -529,6 +518,7 @@ igbuio_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) udev->info.release = igbuio_pci_release; udev->info.priv = udev; udev->pdev = dev; + atomic_set(&udev->refcnt, 0); err = sysfs_create_group(&dev->dev.kobj, &dev_attr_grp); if (err != 0) @@ -580,7 +570,6 @@ igbuio_pci_remove(struct pci_dev *dev) { struct rte_uio_pci_dev *udev = pci_get_drvdata(dev); - mutex_destroy(&udev->lock); sysfs_remove_group(&dev->dev.kobj, &dev_attr_grp); uio_unregister_device(&udev->info); igbuio_pci_release_iomem(&udev->info); -- 2.18.0
[dpdk-dev] [PATCH] devtools/test-meson-build: use shared libraries to save space
For usability, the default build type in meson is static, so that binaries can be run from the build directly easily. However, static builds take more space, so for build-testing purposes default to using shared builds where possible. Signed-off-by: Bruce Richardson --- With this patch applied on Debian 9 (Stretch) the space used by a DPDK checkout and test builds drops from ~2.5G to <1G. [Including space used by cross compiles] --- devtools/test-meson-builds.sh | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/devtools/test-meson-builds.sh b/devtools/test-meson-builds.sh index 66723fe2b..1542dab01 100755 --- a/devtools/test-meson-builds.sh +++ b/devtools/test-meson-builds.sh @@ -9,6 +9,7 @@ srcdir=$(dirname $(readlink -m $0))/.. MESON=${MESON:-meson} +use_shared="--default-library=shared" if command -v ninja >/dev/null 2>&1 ; then ninja_cmd=ninja @@ -42,23 +43,23 @@ for c in gcc clang ; do done # test compilation with minimal x86 instruction set -build build-x86-default -Dmachine=nehalem +build build-x86-default -Dmachine=nehalem $use_shared # test 32-bit x86 compilation # NOTE: meson >0.47 recommended for best results -build build-i686 --cross-file config/x86/i686_sse4_linuxapp_gcc +build build-i686 --cross-file config/x86/i686_sse4_linuxapp_gcc $use_shared # enable cross compilation if gcc cross-compiler is found c=aarch64-linux-gnu-gcc if command -v $c >/dev/null 2>&1 ; then # compile the general v8a also for clang to increase coverage export CC="ccache clang" - build build-arm64-host-clang --cross-file \ + build build-arm64-host-clang $use_shared --cross-file \ config/arm/arm64_armv8_linuxapp_gcc for f in config/arm/arm*gcc ; do export CC="ccache gcc" build build-$(basename $f | tr '_' '-' | cut -d'-' -f-2) \ - --cross-file $f + --cross-file $f $use_shared done fi -- 2.11.0
[dpdk-dev] [PATCH v2] devtools/test-meson-build: use shared libraries to save space
For usability, the default build type in meson is static, so that binaries can be run from the build directory easily. However, static builds take more space, so for build-testing purposes default to using shared builds where possible. Signed-off-by: Bruce Richardson --- With this patch applied on Debian 9 (Stretch) the space used by a DPDK checkout and test builds drops from ~2.5G to <1G. [Including space used by cross compiles] V2: fix typo in commit message --- devtools/test-meson-builds.sh | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/devtools/test-meson-builds.sh b/devtools/test-meson-builds.sh index 66723fe2b..1542dab01 100755 --- a/devtools/test-meson-builds.sh +++ b/devtools/test-meson-builds.sh @@ -9,6 +9,7 @@ srcdir=$(dirname $(readlink -m $0))/.. MESON=${MESON:-meson} +use_shared="--default-library=shared" if command -v ninja >/dev/null 2>&1 ; then ninja_cmd=ninja @@ -42,23 +43,23 @@ for c in gcc clang ; do done # test compilation with minimal x86 instruction set -build build-x86-default -Dmachine=nehalem +build build-x86-default -Dmachine=nehalem $use_shared # test 32-bit x86 compilation # NOTE: meson >0.47 recommended for best results -build build-i686 --cross-file config/x86/i686_sse4_linuxapp_gcc +build build-i686 --cross-file config/x86/i686_sse4_linuxapp_gcc $use_shared # enable cross compilation if gcc cross-compiler is found c=aarch64-linux-gnu-gcc if command -v $c >/dev/null 2>&1 ; then # compile the general v8a also for clang to increase coverage export CC="ccache clang" - build build-arm64-host-clang --cross-file \ + build build-arm64-host-clang $use_shared --cross-file \ config/arm/arm64_armv8_linuxapp_gcc for f in config/arm/arm*gcc ; do export CC="ccache gcc" build build-$(basename $f | tr '_' '-' | cut -d'-' -f-2) \ - --cross-file $f + --cross-file $f $use_shared done fi -- 2.11.0
Re: [dpdk-dev] [PATCH v3 0/8] Add Marvell NETA PMD
On 8/31/2018 1:59 PM, Andrzej Ostruszka wrote: > This patch series introduces new PMD for Marvell NETA adapters (MVNETA). > See the documentation for more info. > > It is split for easier reviewing. > > v3: > No changes against v2, just resubmitting again to have clean patch > set after my faulty format-patch. My apologies for the noise. > > v2: > * fixed couple of checkpatch warnings > * removed '\n' from MVNETA_LOG invocations (appended by the macro) > * removed unused MVNETA_MUSDK_DMA_MEMSIZE define > * changed one printf into MVNETA_LOG > * removed __func__ from one MVNETA_LOG invocation (inserted > automatically by the macro) > * minor grammar/spelling correction in comments > * removed license text from file with SPDX tag (mvneta.rst) > * removed misleading part of comment for mvneta_shadow_txq > * changed authorship of the patches to the original author > > Natalie Samsonov (1): > net/mvneta: add reset statistics callback > > Zyta Szpak (7): > net/mvneta: add neta PMD skeleton > net/mvneta: add Rx/Tx support > net/mvneta: support for setting of MTU > net/mvneta: add link update > net/mvneta: support for promiscuous > net/mvneta: add MAC filtering > net/mvneta: add support for basic stats Hi Andrzej, Patchset is mostly looks good to me, there is no major issue but I have commented on some minor issues. Can you also set a web page patch to add new hardware to supported hw list: http://core.dpdk.org/supported/ https://git.dpdk.org/tools/dpdk-web/
Re: [dpdk-dev] [PATCH v2] devtools/test-meson-build: use shared libraries to save space
On Fri, 2018-09-14 at 17:17 +0100, Bruce Richardson wrote: > For usability, the default build type in meson is static, so that > binaries can be run from the build directory easily. However, static > builds take more space, so for build-testing purposes default to > using > shared builds where possible. > > Signed-off-by: Bruce Richardson > --- > With this patch applied on Debian 9 (Stretch) the space used by a > DPDK > checkout and test builds drops from ~2.5G to <1G. [Including space > used > by cross compiles] > > V2: fix typo in commit message > --- > devtools/test-meson-builds.sh | 9 + > 1 file changed, 5 insertions(+), 4 deletions(-) Acked-by: Luca Boccassi -- Kind regards, Luca Boccassi
Re: [dpdk-dev] [PATCH v3 1/8] net/mvneta: add neta PMD skeleton
On 8/31/2018 1:59 PM, Andrzej Ostruszka wrote: > From: Zyta Szpak > > Add neta pmd driver skeleton providing base for the further > development. > > Signed-off-by: Natalie Samsonov > Signed-off-by: Yelena Krivosheev > Signed-off-by: Dmitri Epshtein > Signed-off-by: Zyta Szpak > Signed-off-by: Andrzej Ostruszka <...> > --- /dev/null > +++ b/doc/guides/nics/features/mvneta.ini > @@ -0,0 +1,18 @@ > +; > +; Supported features of the 'mvneta' network poll mode driver. > +; > +; Refer to default.ini for the full list of available PMD features. > +; > +[Features] > +Speed capabilities = Y > +Link status = Y For link status feature "link_update" eth_dev_ops needs to be implemented, please either implement it or remove feature. (I saw this done later, please add this on relevant patch) > +MTU update = Y For mtu update feature "mtu_set" eth_dev_ops needs to be implemented, please either implement it or remove feature. (I saw this done later, please add this on relevant patch) > +Jumbo frame = Y > +Promiscuous mode = Y Promiscuous mode support is not enabled. (I saw this done later, please add this on relevant patch) > +CRC offload = Y > +L3 checksum offload = Y > +L4 checksum offload = Y Claiming L3 & L4 cksum offload also requires data path implementation to take care mbuf.ol_flags flags. (I saw this is done in next patch, please add this line in next patch) Also I can see these are presented as capabilities but shouldn't this information passed to musdk somehow? Are they always enabled? > +Packet type parsing = Y Similar to above, dev_supported_ptypes_get() is implemented but this also requires data path implementation that fills mbuf->packet_type. (I saw this is done in next patch, please add this line in next patch) > +Basic stats = Y Basic stats collection is not implemented in this patch. (I saw this done later, please add this on relevant patch) <...> > +Usage example > +^ > + > +.. code-block:: console > + > + ./testpmd --vdev=eth_mvneta,iface=eth0,iface=eth1 \ There is a limit to number of "iface" in code, does it make sense to document it? <...> > +#define MVNETA_RX_OFFLOADS (DEV_RX_OFFLOAD_JUMBO_FRAME | \ > + DEV_RX_OFFLOAD_CRC_STRIP | \ CRC_STRIP flag removed in next-net <...> > + > + if (!(dev->data->dev_conf.rxmode.offloads & DEV_RX_OFFLOAD_CRC_STRIP)) { > + MVNETA_LOG(INFO, > + "L2 CRC stripping is always enabled in hw"); > + dev->data->dev_conf.rxmode.offloads |= DEV_RX_OFFLOAD_CRC_STRIP; > + } DEV_RX_OFFLOAD_CRC_STRIP is removed from next-net, you can remove it from capabilities and remove above block. <...> > + > + eth_dev->data->kdrv = RTE_KDRV_NONE; > + eth_dev->data->dev_private = priv; > + eth_dev->device = &vdev->device; > +;eth_dev->dev_ops = &mvneta_ops; extra ";" at the beginning of the line <...> > +RTE_PMD_REGISTER_VDEV(net_mvneta, pmd_mvneta_drv); > +RTE_PMD_REGISTER_ALIAS(net_mvneta, eth_mvneta); No need to provide alias for new PMDs
Re: [dpdk-dev] [PATCH v3 2/8] net/mvneta: add Rx/Tx support
On 8/31/2018 1:59 PM, Andrzej Ostruszka wrote: > From: Zyta Szpak > > Add part of PMD for actual reception/transmission. > > Signed-off-by: Yelena Krivosheev > Signed-off-by: Dmitri Epshtein > Signed-off-by: Zyta Szpak > --- > drivers/net/mvneta/mvneta_ethdev.c | 791 > + > drivers/net/mvneta/mvneta_ethdev.h | 11 + > 2 files changed, 802 insertions(+) It is common in DPDK to move Rx/Tx related functions to its own file, like mvneta_rxtx.c, that is a good logical separation which I suggest to do, but it is up to you to have all in same file or not.
Re: [dpdk-dev] [PATCH v3 6/8] net/mvneta: add MAC filtering
On 8/31/2018 1:59 PM, Andrzej Ostruszka wrote: > From: Zyta Szpak > > Add callbacks for adding/removing MAC addresses. > > Signed-off-by: Yelena Krivosheev > Signed-off-by: Natalie Samsonov > Signed-off-by: Zyta Szpak <...> > @@ -1614,6 +1681,8 @@ static const struct eth_dev_ops mvneta_ops = { > .link_update = mvneta_link_update, > .promiscuous_enable = mvneta_promiscuous_enable, > .promiscuous_disable = mvneta_promiscuous_disable, > + .mac_addr_remove = mvneta_mac_addr_remove, > + .mac_addr_add = mvneta_mac_addr_add, Please announce "Unicast MAC filter" support in .ini file
Re: [dpdk-dev] [PATCH v2] net/mlx5: fix wrong representor port link status
> On Sep 13, 2018, at 11:27 PM, Xueming Li wrote: > > Current code uses PF links status for representor port, not the representor > interface itself. This caused wrong representor port link status when > toggling linterface up or down. > > Fixes: 5a4b8e2612c5 ("net/mlx5: probe all port representors") Wrong commit SHA. Please always check it by running ./devtools/check-git-log.sh -$n ./devtools/checkpatches.sh -n$n > Cc: adrien.mazarg...@6wind.com > > Signed-off-by: Xueming Li > --- > drivers/net/mlx5/mlx5_ethdev.c | 16 ++-- > 1 file changed, 10 insertions(+), 6 deletions(-) > > diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c > index 34c5b95..7391ab8 100644 > --- a/drivers/net/mlx5/mlx5_ethdev.c > +++ b/drivers/net/mlx5/mlx5_ethdev.c > @@ -627,7 +627,7 @@ struct ethtool_link_settings { > int link_speed = 0; > int ret; > > - ret = mlx5_ifreq(dev, SIOCGIFFLAGS, &ifr, 1); > + ret = mlx5_ifreq(dev, SIOCGIFFLAGS, &ifr, 0); > if (ret) { > DRV_LOG(WARNING, "port %u ioctl(SIOCGIFFLAGS) failed: %s", > dev->data->port_id, strerror(rte_errno)); > @@ -636,6 +636,7 @@ struct ethtool_link_settings { > memset(&dev_link, 0, sizeof(dev_link)); > dev_link.link_status = ((ifr.ifr_flags & IFF_UP) && > (ifr.ifr_flags & IFF_RUNNING)); > + memset(&ifr, 0, sizeof(ifr)); > ifr.ifr_data = (void *)&edata; It would be enough to be done like: ifr = { .ifr_data = (void *)&edata, }; And please do the same for dev_link even though it isn't relevant in the patch. > ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr, 1); > if (ret) { > @@ -666,8 +667,9 @@ struct ethtool_link_settings { > ETH_LINK_HALF_DUPLEX : ETH_LINK_FULL_DUPLEX); > dev_link.link_autoneg = !(dev->data->dev_conf.link_speeds & > ETH_LINK_SPEED_FIXED); > - if ((dev_link.link_speed && !dev_link.link_status) || > - (!dev_link.link_speed && dev_link.link_status)) { > + if (!priv->representor && > + ((dev_link.link_speed && !dev_link.link_status) || > + (!dev_link.link_speed && dev_link.link_status))) { What does this change mean? Is it allowed for representors? > rte_errno = EAGAIN; > return -rte_errno; > } > @@ -698,7 +700,7 @@ struct ethtool_link_settings { > uint64_t sc; > int ret; > > - ret = mlx5_ifreq(dev, SIOCGIFFLAGS, &ifr, 1); > + ret = mlx5_ifreq(dev, SIOCGIFFLAGS, &ifr, 0); > if (ret) { > DRV_LOG(WARNING, "port %u ioctl(SIOCGIFFLAGS) failed: %s", > dev->data->port_id, strerror(rte_errno)); > @@ -707,6 +709,7 @@ struct ethtool_link_settings { > memset(&dev_link, 0, sizeof(dev_link)); > dev_link.link_status = ((ifr.ifr_flags & IFF_UP) && > (ifr.ifr_flags & IFF_RUNNING)); > + memset(&ifr, 0, sizeof(ifr)); Same here for dev_link and ifr. Thanks, Yongseok > ifr.ifr_data = (void *)&gcmd; > ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr, 1); > if (ret) { > @@ -775,8 +778,9 @@ struct ethtool_link_settings { > ETH_LINK_HALF_DUPLEX : ETH_LINK_FULL_DUPLEX); > dev_link.link_autoneg = !(dev->data->dev_conf.link_speeds & > ETH_LINK_SPEED_FIXED); > - if ((dev_link.link_speed && !dev_link.link_status) || > - (!dev_link.link_speed && dev_link.link_status)) { > + if (!priv->representor && > + ((dev_link.link_speed && !dev_link.link_status) || > + (!dev_link.link_speed && dev_link.link_status))) { > rte_errno = EAGAIN; > return -rte_errno; > } > -- > 1.8.3.1 >
Re: [dpdk-dev] [PATCH v2] net/mlx5: fix representor port xstats
> On Sep 13, 2018, at 11:33 PM, Xueming Li wrote: > > This patch fixes the issue that representor port shows xstats of PF. > > Fixes: 5a4b8e2612c5 ("net/mlx5: probe all port representors") Wrong commit SHA. > Signed-off-by: Xueming Li > --- > drivers/net/mlx5/mlx5_stats.c | 13 + > 1 file changed, 9 insertions(+), 4 deletions(-) > > diff --git a/drivers/net/mlx5/mlx5_stats.c b/drivers/net/mlx5/mlx5_stats.c > index 91f3d47..ed5b51b 100644 > --- a/drivers/net/mlx5/mlx5_stats.c > +++ b/drivers/net/mlx5/mlx5_stats.c > @@ -146,7 +146,7 @@ struct mlx5_counter_ctrl { > et_stats->cmd = ETHTOOL_GSTATS; > et_stats->n_stats = xstats_ctrl->stats_n; > ifr.ifr_data = (caddr_t)et_stats; > - ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr, 1); > + ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr, 0); > if (ret) { > DRV_LOG(WARNING, > "port %u unable to read statistic values from device", > @@ -194,7 +194,7 @@ struct mlx5_counter_ctrl { > > drvinfo.cmd = ETHTOOL_GDRVINFO; > ifr.ifr_data = (caddr_t)&drvinfo; > - ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr, 1); > + ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr, 0); > if (ret) { > DRV_LOG(WARNING, "port %u unable to query number of statistics", > dev->data->port_id); > @@ -229,7 +229,6 @@ struct mlx5_counter_ctrl { > return; > } > dev_stats_n = ret; > - xstats_ctrl->stats_n = dev_stats_n; > /* Allocate memory to grab stat names and values. */ > str_sz = dev_stats_n * ETH_GSTRING_LEN; > strings = (struct ethtool_gstrings *) > @@ -244,7 +243,7 @@ struct mlx5_counter_ctrl { > strings->string_set = ETH_SS_STATS; > strings->len = dev_stats_n; > ifr.ifr_data = (caddr_t)strings; > - ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr, 1); > + ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr, 0); > if (ret) { > DRV_LOG(WARNING, "port %u unable to get statistic names", > dev->data->port_id); > @@ -275,6 +274,7 @@ struct mlx5_counter_ctrl { > goto free; > } > } > + xstats_ctrl->stats_n = dev_stats_n; Any reason to move it? If it is done to group the code, I'm fine with that. Thanks, Yongseok > /* Copy to base at first time. */ > assert(xstats_n <= MLX5_MAX_XSTATS); > ret = mlx5_read_dev_counters(dev, xstats_ctrl->base); > @@ -307,6 +307,8 @@ struct mlx5_counter_ctrl { > unsigned int i; > uint64_t counters[n]; > > + if (!priv->xstats_ctrl.stats_n) > + return 0; > if (n >= xstats_n && stats) { > struct mlx5_xstats_ctrl *xstats_ctrl = &priv->xstats_ctrl; > int stats_n; > @@ -480,8 +482,11 @@ struct mlx5_counter_ctrl { > mlx5_xstats_get_names(struct rte_eth_dev *dev __rte_unused, > struct rte_eth_xstat_name *xstats_names, unsigned int n) > { > + struct priv *priv = dev->data->dev_private; > unsigned int i; > > + if (!priv->xstats_ctrl.stats_n) > + return 0; > if (n >= xstats_n && xstats_names) { > for (i = 0; i != xstats_n; ++i) { > strncpy(xstats_names[i].name, > -- > 1.8.3.1 >
Re: [dpdk-dev] [PATCH] vhost: add missing cflags in meson build
On 9/14/2018 3:51 PM, Tiwei Bie wrote: > Fixes: 6ee380ffb5e7 ("vhost: fix vhost interrupt support") > > Signed-off-by: Tiwei Bie Squashed into relevant commit in next-net, thanks.
[dpdk-dev] [PATCH v3 00/10] net/softnic: implement metering and policing API
This series is prepared on top of following patchset; https://mails.dpdk.org/archives/dev/2018-September/111379.html v3 changes: - update pipeline table with meter profiles - update pipeline table with dscp table entry update v2 changes: - fix copyright year for rte_eth_softnic_meter.c - Place all checks in a separate functions while creating meter object - Use softnic_pipeline_table_mtr_profile_add() api to add meter profile instead of implementing new function - Use stats type indicator to determine the stats_mask for meter stats read 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 flow rule with meter action 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 | 155 - drivers/net/softnic/rte_eth_softnic_internals.h | 66 +++ drivers/net/softnic/rte_eth_softnic_meter.c | 728 drivers/net/softnic/rte_eth_softnic_pipeline.c | 26 + drivers/net/softnic/rte_eth_softnic_thread.c| 33 ++ 8 files changed, 1022 insertions(+), 1 deletion(-) create mode 100644 drivers/net/softnic/rte_eth_softnic_meter.c -- 2.9.3
[dpdk-dev] [PATCH v3 02/10] net/softnic: add meter profile
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 | 31 ++ drivers/net/softnic/rte_eth_softnic_meter.c | 122 +++- 3 files changed, 155 insertions(+), 1 deletion(-) diff --git a/drivers/net/softnic/rte_eth_softnic.c b/drivers/net/softnic/rte_eth_softnic.c index 659a1b4..b7b2383 100644 --- a/drivers/net/softnic/rte_eth_softnic.c +++ b/drivers/net/softnic/rte_eth_softnic.c @@ -191,6 +191,7 @@ pmd_dev_stop(struct rte_eth_dev *dev) softnic_mempool_free(p); tm_hierarchy_free(p); + softnic_mtr_free(p); } static void @@ -291,6 +292,7 @@ pmd_init(struct pmd_params *params) /* Resources */ tm_hierarchy_init(p); + softnic_mtr_init(p); softnic_mempool_init(p); softnic_swq_init(p); @@ -345,6 +347,7 @@ pmd_free(struct pmd_internals *p) softnic_mempool_free(p); tm_hierarchy_free(p); + softnic_mtr_free(p); rte_free(p); } diff --git a/drivers/net/softnic/rte_eth_softnic_internals.h b/drivers/net/softnic/rte_eth_softnic_internals.h index 92be4e8..1db9310 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,24 @@ 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); + +struct mtr_internals { + struct softnic_mtr_meter_profile_list meter_profiles; +}; + +/** * MEMPOOL */ struct softnic_mempool_params { @@ -525,6 +544,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 +595,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 0a5409b..1222866 100644 --- a/drivers/net/softnic/rte_eth_softnic_meter.c +++ b/drivers/net/softnic/rte_eth_softnic_meter.c @@ -11,10 +11,130 @@ #include "rte_eth_softnic_internals.h" +int +softnic_mtr_init(struct pmd_internals *p) +{ + /* Initialize meter profiles list */ + TAILQ_INIT(&p->mtr.meter_profiles); + + 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); + } +} + +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, + struct rte_mtr_error *error) +{ + struct pmd_internals *p = dev->data->dev_private; + struct softnic_mtr_meter_profile *mp; + + /* Meter profile ID must be valid. */ + if (meter_profile_id == UINT32_MAX) + return -rte_mtr_error_set(error, + EINVAL, + RTE_MTR_ERROR_TYPE_METER_PROFILE_ID, + NULL, + "Meter profile id not valid"); + + /* Meter profile must not exist. */ + mp = softnic_mtr_meter_profile_find(p, meter_profile_id); + if (mp) + return -rte_mtr_error_set(error, + EEXIST, + RTE_MTR_ERROR_TYPE_METER_PROFILE_ID, + NULL, + "Meter prfile already exists"); + + /* Profile must not be NULL. */ + if (profile == NULL) + return -rte_mtr_error_set(error, + EINVAL, +
[dpdk-dev] [PATCH v3 04/10] net/softnic: create meter object
implement meter object create function. Signed-off-by: Jasvinder Singh --- drivers/net/softnic/rte_eth_softnic_internals.h | 15 +++ drivers/net/softnic/rte_eth_softnic_meter.c | 123 +++- 2 files changed, 137 insertions(+), 1 deletion(-) diff --git a/drivers/net/softnic/rte_eth_softnic_internals.h b/drivers/net/softnic/rte_eth_softnic_internals.h index 1db9310..50b7295 100644 --- a/drivers/net/softnic/rte_eth_softnic_internals.h +++ b/drivers/net/softnic/rte_eth_softnic_internals.h @@ -82,8 +82,19 @@ struct softnic_mtr_meter_profile { TAILQ_HEAD(softnic_mtr_meter_profile_list, softnic_mtr_meter_profile); +/* MTR meter 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; }; /** @@ -601,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 f3205bd..12dd79c 100644 --- a/drivers/net/softnic/rte_eth_softnic_meter.c +++ b/drivers/net/softnic/rte_eth_softnic_meter.c @@ -17,12 +17,27 @@ 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 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); + } + /* Remove meter profiles */ for ( ; ; ) { struct softnic_mtr_meter_profile *mp; @@ -164,13 +179,119 @@ 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; +} + + +static int +mtr_check(struct pmd_internals *p, + uint32_t mtr_id, + struct rte_mtr_params *params, + int shared, + struct rte_mtr_error *error) +{ + /* MTR id valid */ + if (softnic_mtr_find(p, mtr_id)) + return -rte_mtr_error_set(error, + EEXIST, + RTE_MTR_ERROR_TYPE_MTR_ID, + NULL, + "MTR object already exists"); + + /* MTR params must not be NULL */ + if (params == NULL) + return -rte_mtr_error_set(error, + EINVAL, + RTE_MTR_ERROR_TYPE_MTR_PARAMS, + NULL, + "MTR object params null"); + + /* 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, + "Previous meter color not supported"); + + /* Shared MTR object not supported */ + if (shared) + return -rte_mtr_error_set(error, + EINVAL, + RTE_MTR_ERROR_TYPE_SHARED, + NULL, + "Shared MTR object not supported"); + + return 0; +} + +/* 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; + int status; + + /* Check parameters */ + status = mtr_check(p, mtr_id, params, shared, error); + if (status) + return status; + + /* 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, + "Meter profile id
[dpdk-dev] [PATCH v3 03/10] net/softnic: delete meter profile
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 1222866..f3205bd 100644 --- a/drivers/net/softnic/rte_eth_softnic_meter.c +++ b/drivers/net/softnic/rte_eth_softnic_meter.c @@ -131,11 +131,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, + "Meter profile id invalid"); + + /* Check unused */ + if (mp->n_users) + return -rte_mtr_error_set(error, + EBUSY, + RTE_MTR_ERROR_TYPE_METER_PROFILE_ID, + NULL, + "Meter profile in use"); + + /* 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 v3 01/10] net/softnic: add metering and policing support
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..0a5409b --- /dev/null +++ b/drivers/net/softnic/rte_eth_softnic_meter.c @@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2018 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 v3 06/10] net/softnic: update meter profile
Implement meter profile update function Signed-off-by: Jasvinder Singh --- drivers/net/softnic/rte_eth_softnic_internals.h | 14 drivers/net/softnic/rte_eth_softnic_meter.c | 103 +++- drivers/net/softnic/rte_eth_softnic_pipeline.c | 25 ++ drivers/net/softnic/rte_eth_softnic_thread.c| 23 ++ 4 files changed, 164 insertions(+), 1 deletion(-) diff --git a/drivers/net/softnic/rte_eth_softnic_internals.h b/drivers/net/softnic/rte_eth_softnic_internals.h index 50b7295..4b0f54c 100644 --- a/drivers/net/softnic/rte_eth_softnic_internals.h +++ b/drivers/net/softnic/rte_eth_softnic_internals.h @@ -320,6 +320,15 @@ struct softnic_table_action_profile { TAILQ_HEAD(softnic_table_action_profile_list, softnic_table_action_profile); +struct softnic_table_meter_profile { + TAILQ_ENTRY(softnic_table_meter_profile) node; + uint32_t meter_profile_id; + struct rte_table_action_meter_profile profile; +}; + +TAILQ_HEAD(softnic_table_meter_profile_list, + softnic_table_meter_profile); + /** * Pipeline */ @@ -455,6 +464,7 @@ struct softnic_table { struct softnic_table_action_profile *ap; struct rte_table_action *a; struct flow_list flows; + struct softnic_table_meter_profile_list meter_profiles; }; struct pipeline { @@ -813,6 +823,10 @@ softnic_pipeline_table_create(struct pmd_internals *p, const char *pipeline_name, struct softnic_table_params *params); +struct softnic_table_meter_profile * +softnic_pipeline_table_meter_profile_find(struct softnic_table *table, + uint32_t meter_profile_id); + struct softnic_table_rule_match_acl { int ip_version; diff --git a/drivers/net/softnic/rte_eth_softnic_meter.c b/drivers/net/softnic/rte_eth_softnic_meter.c index 5103bda..5ce5037 100644 --- a/drivers/net/softnic/rte_eth_softnic_meter.c +++ b/drivers/net/softnic/rte_eth_softnic_meter.c @@ -332,6 +332,107 @@ pmd_mtr_destroy(struct rte_eth_dev *dev, 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 *mp0, *mp1; + 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, + "MTR object id not valid"); + + /* Meter profile id must be valid */ + mp0 = softnic_mtr_meter_profile_find(p, meter_profile_id); + if (mp0 == NULL) + return -rte_mtr_error_set(error, + EINVAL, + RTE_MTR_ERROR_TYPE_METER_PROFILE_ID, + NULL, + "Meter profile not valid"); + + /* MTR object already set to meter profile id */ + if (m->params.meter_profile_id == meter_profile_id) + return 0; + + /* MTR object owner table update */ + if (m->flow) { + uint32_t table_id = m->flow->table_id; + struct softnic_table *table = &m->flow->pipeline->table[table_id]; + struct softnic_table_rule_action action; + + if (!softnic_pipeline_table_meter_profile_find(table, + meter_profile_id)) { + struct rte_table_action_meter_profile profile; + + memset(&profile, 0, sizeof(profile)); + + profile.alg = RTE_TABLE_ACTION_METER_TRTCM; + profile.trtcm.cir = mp0->params.trtcm_rfc2698.cir; + profile.trtcm.pir = mp0->params.trtcm_rfc2698.pir; + profile.trtcm.cbs = mp0->params.trtcm_rfc2698.cbs; + profile.trtcm.pbs = mp0->params.trtcm_rfc2698.pbs; + + /* Add meter profile to pipeline table */ + status = softnic_pipeline_table_mtr_profile_add(p, + m->flow->pipeline->name, + table_id, + meter_profile_id, + &profile); + if (status) + return -rte_mtr_error_set(error, + EINVAL, + RTE_MTR_ERROR_TYPE_UNSPECIFIED, + NULL, + "Table meter profile add failed"); + } + + /* Set meter action */ + memcpy(&action, &m->flow->action, sizeof(action)); + + action.mtr.mtr[0].meter_profile_id =
[dpdk-dev] [PATCH v3 09/10] net/softnic: meter stats read
Implement meter object stats read function. Signed-off-by: Jasvinder Singh --- drivers/net/softnic/rte_eth_softnic_meter.c | 136 +++- 1 file changed, 135 insertions(+), 1 deletion(-) diff --git a/drivers/net/softnic/rte_eth_softnic_meter.c b/drivers/net/softnic/rte_eth_softnic_meter.c index 6774eb6..d73f489 100644 --- a/drivers/net/softnic/rte_eth_softnic_meter.c +++ b/drivers/net/softnic/rte_eth_softnic_meter.c @@ -574,6 +574,140 @@ pmd_mtr_policer_actions_update(struct rte_eth_dev *dev, return 0; } +#define MTR_STATS_PKTS_DEFAULT (RTE_MTR_STATS_N_PKTS_GREEN | \ + RTE_MTR_STATS_N_PKTS_YELLOW | \ + RTE_MTR_STATS_N_PKTS_RED | \ + RTE_MTR_STATS_N_PKTS_DROPPED) + +#define MTR_STATS_BYTES_DEFAULT (RTE_MTR_STATS_N_BYTES_GREEN | \ + RTE_MTR_STATS_N_BYTES_YELLOW | \ + RTE_MTR_STATS_N_BYTES_RED | \ + RTE_MTR_STATS_N_BYTES_DROPPED) + +/* MTR object stats read */ +static void +mtr_stats_convert(struct softnic_mtr *m, + struct rte_table_action_mtr_counters_tc *in, + struct rte_mtr_stats *out, + uint64_t *out_mask) +{ + memset(&out, 0, sizeof(out)); + *out_mask = 0; + + if (in->n_packets_valid) { + uint32_t i; + + for (i = 0; i < RTE_MTR_COLORS; i++) { + if (m->params.action[i] == MTR_POLICER_ACTION_COLOR_GREEN) + out->n_pkts[RTE_MTR_GREEN] += in->n_packets[i]; + + if (m->params.action[i] == MTR_POLICER_ACTION_COLOR_YELLOW) + out->n_pkts[RTE_MTR_YELLOW] += in->n_packets[i]; + + if (m->params.action[i] == MTR_POLICER_ACTION_COLOR_RED) + out->n_pkts[RTE_MTR_RED] += in->n_packets[i]; + + if (m->params.action[i] == MTR_POLICER_ACTION_DROP) + out->n_pkts_dropped += in->n_packets[i]; + } + + *out_mask |= MTR_STATS_PKTS_DEFAULT; + } + + if (in->n_bytes_valid) { + uint32_t i; + + for (i = 0; i < RTE_MTR_COLORS; i++) { + if (m->params.action[i] == MTR_POLICER_ACTION_COLOR_GREEN) + out->n_bytes[RTE_MTR_GREEN] += in->n_bytes[i]; + + if (m->params.action[i] == MTR_POLICER_ACTION_COLOR_YELLOW) + out->n_bytes[RTE_MTR_YELLOW] += in->n_bytes[i]; + + if (m->params.action[i] == MTR_POLICER_ACTION_COLOR_RED) + out->n_bytes[RTE_MTR_RED] += in->n_bytes[i]; + + if (m->params.action[i] == MTR_POLICER_ACTION_DROP) + out->n_bytes_dropped += in->n_bytes[i]; + } + + *out_mask |= MTR_STATS_BYTES_DEFAULT; + } +} + +/* 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 rte_table_action_mtr_counters counters; + struct pipeline *pipeline; + struct softnic_table *table; + 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, + "MTR object id not valid"); + + /* MTR meter object owner valid? */ + if (m->flow == NULL) { + if (stats != NULL) + memset(stats, 0, sizeof(*stats)); + + if (stats_mask) + *stats_mask = MTR_STATS_PKTS_DEFAULT | + MTR_STATS_BYTES_DEFAULT; + + return 0; + } + + pipeline = m->flow->pipeline; + table = &pipeline->table[m->flow->table_id]; + + /* Meter stats read. */ + status = rte_table_action_meter_read(table->a, + m->flow->data, + 1, + &counters, + clear); + if (status) + return -rte_mtr_error_set(error, + EINVAL, + RTE_MTR_ERROR_TYPE_UNSPECIFIED, + NULL, + "Meter stats read failed"); + + /* Stats format conversion. */ + if (stats || stats_mask) { + struct rte_mtr_stats s; + uint64_t s_mask = 0; + + mtr_stats_convert(m, + &counters.stats[0], + &s, + &s_mask); +
[dpdk-dev] [PATCH v3 07/10] net/softnic: update dscp table
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 | 54 - drivers/net/softnic/rte_eth_softnic_pipeline.c | 1 + drivers/net/softnic/rte_eth_softnic_thread.c| 10 + 4 files changed, 65 insertions(+), 1 deletion(-) diff --git a/drivers/net/softnic/rte_eth_softnic_internals.h b/drivers/net/softnic/rte_eth_softnic_internals.h index 4b0f54c..78864e7 100644 --- a/drivers/net/softnic/rte_eth_softnic_internals.h +++ b/drivers/net/softnic/rte_eth_softnic_internals.h @@ -464,6 +464,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_table_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 5ce5037..68373ee 100644 --- a/drivers/net/softnic/rte_eth_softnic_meter.c +++ b/drivers/net/softnic/rte_eth_softnic_meter.c @@ -433,6 +433,58 @@ 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 rte_table_action_dscp_table dt; + struct pipeline *pipeline; + struct softnic_table *table; + struct softnic_mtr *m; + uint32_t table_id, 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, + "MTR object id not valid"); + + /* MTR object owner valid? */ + if (m->flow == NULL) + return 0; + + pipeline = m->flow->pipeline; + table_id = m->flow->table_id; + table = &pipeline->table[table_id]; + + 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]; + + /* Update table */ + status = softnic_pipeline_table_dscp_table_update(p, + pipeline->name, + table_id, + UINT64_MAX, + &dt); + if (status) + return -rte_mtr_error_set(error, + EINVAL, + RTE_MTR_ERROR_TYPE_UNSPECIFIED, + NULL, + "Table action dscp table update failed"); + + return 0; +} + const struct rte_mtr_ops pmd_mtr_ops = { .capabilities_get = NULL, @@ -445,7 +497,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 9c544f4..7c81152 100644 --- a/drivers/net/softnic/rte_eth_softnic_pipeline.c +++ b/drivers/net/softnic/rte_eth_softnic_pipeline.c @@ -1000,6 +1000,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; diff --git a/drivers/net/softnic/rte_eth_softnic_thread.c b/drivers/net/softnic/rte_eth_softnic_thread.c index df61832..af659b9 100644 --- a/drivers/net/softnic/rte_eth_softnic_thread.c +++ b/drivers/net/softnic/rte_eth_softnic_thread.c @@ -1897,6 +1897,11 @@ softnic_pipeline_table_dscp_table_update(struct pmd_internals *softnic, dscp_mask, dscp_table); + /* Update table dscp table */ + if (!status) + memcpy(&p->table[table_id].dscp_table, dscp_table, + sizeof(p->table[table_id].dscp_table)); + return status; } @@ -1920,6 +1925,11 @@ softnic_pipeline_table_dscp_table_update(struct pmd_internals *softnic, /* Read response */ status = rsp->status; + /* Update table dscp table */ + if (!status) + memcpy(&p->table[table_id].dscp_table, dscp_table, + sizeof(p->table[table_id].dscp_table)); + /* Free response */ pipeline_m
[dpdk-dev] [PATCH v3 05/10] net/softnic: destroy meter object
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 12dd79c..5103bda 100644 --- a/drivers/net/softnic/rte_eth_softnic_meter.c +++ b/drivers/net/softnic/rte_eth_softnic_meter.c @@ -285,6 +285,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, + "MTR object id not valid"); + + /* MTR object must not have any owner */ + if (m->flow != NULL) + return -rte_mtr_error_set(error, + EINVAL, + RTE_MTR_ERROR_TYPE_UNSPECIFIED, + NULL, + "MTR object is being used"); + + /* 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, + "MTR object meter profile invalid"); + + /* 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, @@ -292,7 +339,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 v3 08/10] net/softnic: update policer actions
Implement meter object policer actions function. Signed-off-by: Jasvinder Singh --- drivers/net/softnic/rte_eth_softnic_meter.c | 91 - 1 file changed, 90 insertions(+), 1 deletion(-) diff --git a/drivers/net/softnic/rte_eth_softnic_meter.c b/drivers/net/softnic/rte_eth_softnic_meter.c index 68373ee..6774eb6 100644 --- a/drivers/net/softnic/rte_eth_softnic_meter.c +++ b/drivers/net/softnic/rte_eth_softnic_meter.c @@ -485,6 +485,95 @@ pmd_mtr_meter_dscp_table_update(struct rte_eth_dev *dev, 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, + "MTR object id not valid"); + + /* Valid policer actions */ + if (actions == NULL) + return -rte_mtr_error_set(error, + EINVAL, + RTE_MTR_ERROR_TYPE_UNSPECIFIED, + NULL, + "Invalid actions"); + + for (i = 0; i < RTE_MTR_COLORS; i++) { + if (action_mask & (1 << i)) { + 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, + " Invalid action value"); + } + } + } + + /* MTR object owner valid? */ + if (m->flow) { + struct pipeline *pipeline = m->flow->pipeline; + struct softnic_table *table = &pipeline->table[m->flow->table_id]; + struct softnic_table_rule_action action; + + memcpy(&action, &m->flow->action, sizeof(action)); + + /* Set action */ + for (i = 0; i < RTE_MTR_COLORS; i++) + if (action_mask & (1 << i)) + action.mtr.mtr[0].policer[i] = + (enum rte_table_action_policer)actions[i]; + + /* Re-add the rule */ + status = softnic_pipeline_table_rule_add(p, + pipeline->name, + m->flow->table_id, + &m->flow->match, + &action, + &m->flow->data); + if (status) + return -rte_mtr_error_set(error, + EINVAL, + RTE_MTR_ERROR_TYPE_UNSPECIFIED, + NULL, + "Pipeline table rule re-add failed"); + + /* Flow: Update meter action */ + memcpy(&m->flow->action, &action, sizeof(m->flow->action)); + + /* Reset the meter stats */ + rte_table_action_meter_read(table->a, m->flow->data, + 1, NULL, 1); + } + + /* Meter: Update policer actions */ + for (i = 0; i < RTE_MTR_COLORS; i++) + if (action_mask & (1 << i)) + m->params.action[i] = actions[i]; + + return 0; +} + const struct rte_mtr_ops pmd_mtr_ops = { .capabilities_get = NULL, @@ -498,7 +587,7 @@ const struct rte_mtr_ops pmd_mtr_ops = { .meter_profile_update = pmd_mtr_meter_profile_update, .meter_dscp_table_update = pmd_mtr_meter_dscp_table_update, - .policer_actions_update = NULL, + .policer_actions_update = pmd_mtr_policer_actions_update, .stats_update = NULL, .stats_read = NULL, -- 2.9.3
[dpdk-dev] [PATCH v3 10/10] net/softnic: enable flow rule with meter action
Implement flow rules with meter action. Signed-off-by: Jasvinder Singh --- drivers/net/softnic/rte_eth_softnic_flow.c | 155 - 1 file changed, 154 insertions(+), 1 deletion(-) diff --git a/drivers/net/softnic/rte_eth_softnic_flow.c b/drivers/net/softnic/rte_eth_softnic_flow.c index 6562004..b7d2626 100644 --- a/drivers/net/softnic/rte_eth_softnic_flow.c +++ b/drivers/net/softnic/rte_eth_softnic_flow.c @@ -1146,7 +1146,7 @@ flow_rule_action_get(struct pmd_internals *softnic, const struct rte_flow_attr *attr, const struct rte_flow_action *action, struct softnic_table_rule_action *rule_action, - struct rte_flow_error *error __rte_unused) + struct rte_flow_error *error) { struct softnic_table_action_profile *profile; struct softnic_table_action_profile_params *params; @@ -1459,6 +1459,95 @@ flow_rule_action_get(struct pmd_internals *softnic, break; } /* RTE_FLOW_ACTION_TYPE_COUNT */ + case RTE_FLOW_ACTION_TYPE_METER: + { + const struct rte_flow_action_meter *conf = action->conf; + struct softnic_mtr_meter_profile *mp; + struct softnic_mtr *m; + uint32_t table_id = table - pipeline->table; + uint32_t meter_profile_id; + int status; + + if ((params->action_mask & (1LLU << RTE_TABLE_ACTION_MTR)) == 0) + return rte_flow_error_set(error, + EINVAL, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, + "METER: Table action not supported"); + + if (params->mtr.n_tc != 1) + return rte_flow_error_set(error, + EINVAL, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, + "METER: Multiple TCs not supported"); + + if (conf == NULL) + return rte_flow_error_set(error, + EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + action, + "METER: Null configuration"); + + 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, + "METER: Invalid meter ID"); + + if (m->flow) + return rte_flow_error_set(error, + EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION_CONF, + NULL, + "METER: Meter already attached to a flow"); + + meter_profile_id = m->params.meter_profile_id; + mp = softnic_mtr_meter_profile_find(softnic, meter_profile_id); + + /* Add meter profile to pipeline table */ + if (!softnic_pipeline_table_meter_profile_find(table, + meter_profile_id)) { + struct rte_table_action_meter_profile profile; + + memset(&profile, 0, sizeof(profile)); + profile.alg = RTE_TABLE_ACTION_METER_TRTCM; + profile.trtcm.cir = mp->params.trtcm_rfc2698.cir; + profile.trtcm.pir = mp->params.trtcm_rfc2698.pir; + profile.trtcm.cbs = mp->params.trtcm_rfc2698.cbs; + profile.trtcm.pbs = mp->params.trtcm_rfc2698.pbs; + + status = softnic_pipeline_table_mtr_profile_add(softnic, + pipeline->name, + table_id, + meter_profile_id, + &profile); + if (status) { + rte_flow_error_set(error, + EINVAL, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, + "METER: Table meter profile add failed"); +
Re: [dpdk-dev] [PATCH 0/4] Address reader-writer concurrency in rte_hash
I have added the memory ordering ladder diagrams to the DPDK summit slides to help understand the changes. The slides are available at: https://dpdkuserspace2018.sched.com/event/G44w/lock-free-read-write-concurrency-in-rtehash. Please look at the backup slides. Thank you, Honnappa -Original Message- From: Honnappa Nagarahalli Sent: Thursday, September 6, 2018 12:12 PM To: bruce.richard...@intel.com; pablo.de.lara.gua...@intel.com Cc: dev@dpdk.org; honnappa.nagarahalli; Gavin Hu (Arm Technology China) ; Steve Capper ; Ola Liljedahl ; nd ; Honnappa Nagarahalli Subject: [PATCH 0/4] Address reader-writer concurrency in rte_hash Currently, reader-writer concurrency problems in rte_hash are addressed using reader-writer locks. Use of reader-writer locks results in following issues: 1) In many of the use cases for the hash table, writer threads are running on control plane. If the writer is preempted while holding the lock, it will block the readers for an extended period resulting in packet drops. This problem seems to apply for platforms with transactional memory support as well because of the algorithm used for rte_rwlock_write_lock_tm: static inline void rte_rwlock_write_lock_tm(rte_rwlock_t *rwl) { if (likely(rte_try_tm(&rwl->cnt))) return; rte_rwlock_write_lock(rwl); } i.e. there is a posibility of using rte_rwlock_write_lock in failure cases. 2) Reader-writer lock based solution does not address the following issue. rte_hash_lookup_xxx APIs return the index of the element in the key store. Application(reader) can use that index to reference other data structures in its scope. Because of this, the index should not be freed till the application completes using the index. 3) Since writer blocks all the readers, the hash lookup rate comes down significantly when there is activity on the writer. This happens even for unrelated entries. Performance numbers given below clearly indicate this. Lock-free solution is required to solve these problems. This patch series adds the lock-free capabilities in the following steps: 1) Correct the alignment for the key store entry to prep for memory ordering. 2) Add memory ordering to prevent race conditions when a new key is added to the table. 3) Reader-writer concurrency issue, caused by moving the keys to their alternate locations during key insert, is solved by introducing an atomic global counter indicating a change in table. 4) This solution also has to solve the issue of readers using key store element even after the key is deleted from control plane. To solve this issue, the hash_del_key_xxx APIs do not free the key store element. The key store element has to be freed using the newly introduced rte_hash_free_key_with_position API. It needs to be called once all the readers have stopped using the key store element. How this is determined is outside the scope of this patch (RCU is one such mechanism that the application can use). 4) Finally, a lock free reader-writer concurrency flag is added to enable this feature at run time. Performance numbers: Scenario: Equal number of writer/reader threads for concurrent writers and readers. For readers only test, the entries are added upfront. Current code: Cores Lookup Lookup with add 2 474246 4 935579 6 1387 1048 8 1766 1480 10 2119 1951 12 2546 2441 With this patch: Cores Lookup Lookup with add 2 291211 4 297196 6 304198 8 309202 10 315205 12 319209 Honnappa Nagarahalli (4): hash: correct key store element alignment hash: add memory ordering to avoid race conditions hash: fix rw concurrency while moving keys hash: enable lock-free reader-writer concurrency lib/librte_hash/rte_cuckoo_hash.c| 445 +-- lib/librte_hash/rte_cuckoo_hash.h| 6 +- lib/librte_hash/rte_hash.h | 63 - lib/librte_hash/rte_hash_version.map | 7 + 4 files changed, 393 insertions(+), 128 deletions(-) -- 2.7.4
[dpdk-dev] [PATCH] [PATCH] bonding: add QinQ packet xmit hash support
For QinQ packet with ether type 0x88a8, dpdk bond's xmit hash policy is not worked to get the ip or port field. Change-Id: Icb6843aff0a0d176b90ebe19a5c7125412fea5ce Signed-off-by: Lilijun --- drivers/net/bonding/rte_eth_bond_pmd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c index 58f7377..4417422 100644 --- a/drivers/net/bonding/rte_eth_bond_pmd.c +++ b/drivers/net/bonding/rte_eth_bond_pmd.c @@ -37,7 +37,8 @@ { size_t vlan_offset = 0; - if (rte_cpu_to_be_16(ETHER_TYPE_VLAN) == *proto) { + if (rte_cpu_to_be_16(ETHER_TYPE_VLAN) == *proto || + rte_cpu_to_be_16(ETHER_TYPE_QINQ) == *proto) { struct vlan_hdr *vlan_hdr = (struct vlan_hdr *)(eth_hdr + 1); vlan_offset = sizeof(struct vlan_hdr); -- 1.8.4.msysgit.0
[dpdk-dev] [PATCH] [PATCH] bonding: add QinQ packet xmit hash support
For QinQ packet with ether type 0x88a8, dpdk bond's xmit hash policy is not worked to get the ip or port field. Change-Id: Icb6843aff0a0d176b90ebe19a5c7125412fea5ce Signed-off-by: Lilijun --- drivers/net/bonding/rte_eth_bond_pmd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c index 58f7377..4417422 100644 --- a/drivers/net/bonding/rte_eth_bond_pmd.c +++ b/drivers/net/bonding/rte_eth_bond_pmd.c @@ -37,7 +37,8 @@ { size_t vlan_offset = 0; - if (rte_cpu_to_be_16(ETHER_TYPE_VLAN) == *proto) { + if (rte_cpu_to_be_16(ETHER_TYPE_VLAN) == *proto || + rte_cpu_to_be_16(ETHER_TYPE_QINQ) == *proto) { struct vlan_hdr *vlan_hdr = (struct vlan_hdr *)(eth_hdr + 1); vlan_offset = sizeof(struct vlan_hdr); -- 1.8.4.msysgit.0
[dpdk-dev] [PATCH] bonding: add QinQ packet xmit hash support
For QinQ packet with ether type 0x88a8, dpdk bond's xmit hash policy is not worked to get the ip or port field. Signed-off-by: Lilijun --- drivers/net/bonding/rte_eth_bond_pmd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c index 58f7377..4417422 100644 --- a/drivers/net/bonding/rte_eth_bond_pmd.c +++ b/drivers/net/bonding/rte_eth_bond_pmd.c @@ -37,7 +37,8 @@ { size_t vlan_offset = 0; - if (rte_cpu_to_be_16(ETHER_TYPE_VLAN) == *proto) { + if (rte_cpu_to_be_16(ETHER_TYPE_VLAN) == *proto || + rte_cpu_to_be_16(ETHER_TYPE_QINQ) == *proto) { struct vlan_hdr *vlan_hdr = (struct vlan_hdr *)(eth_hdr + 1); vlan_offset = sizeof(struct vlan_hdr); -- 1.8.4.msysgit.0
[dpdk-dev] [PATCH v3 2/5] vhost: make message handling functions prepare the reply
As VhostUserMsg structure is reused to generate the reply, move the relevant fields update into the respective message handling functions. Signed-off-by: Nikolay Nikolaev --- lib/librte_vhost/vhost_user.c | 24 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index b05b57670..3a00d53cf 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -146,11 +146,15 @@ vhost_user_reset_owner(struct virtio_net *dev) * The features that we support are requested. */ static uint64_t -vhost_user_get_features(struct virtio_net *dev) +vhost_user_get_features(struct virtio_net *dev, VhostUserMsg *msg) { uint64_t features = 0; rte_vhost_driver_get_features(dev->ifname, &features); + + msg->payload.u64 = features; + msg->size = sizeof(msg->payload.u64); + return features; } @@ -158,11 +162,15 @@ vhost_user_get_features(struct virtio_net *dev) * The queue number that we support are requested. */ static uint32_t -vhost_user_get_queue_num(struct virtio_net *dev) +vhost_user_get_queue_num(struct virtio_net *dev, VhostUserMsg *msg) { uint32_t queue_num = 0; rte_vhost_driver_get_queue_num(dev->ifname, &queue_num); + + msg->payload.u64 = (uint64_t)queue_num; + msg->size = sizeof(msg->payload.u64); + return queue_num; } @@ -1117,6 +1125,8 @@ vhost_user_get_vring_base(struct virtio_net *dev, rte_free(vq->batch_copy_elems); vq->batch_copy_elems = NULL; + msg->size = sizeof(msg->payload.state); + return 0; } @@ -1244,6 +1254,8 @@ vhost_user_set_log_base(struct virtio_net *dev, VhostUserMsg *msg) dev->log_base = dev->log_addr + off; dev->log_size = size; + msg->size = sizeof(msg->payload.u64); + return 0; } @@ -1657,8 +1669,7 @@ vhost_user_msg_handler(int vid, int fd) switch (msg.request.master) { case VHOST_USER_GET_FEATURES: - msg.payload.u64 = vhost_user_get_features(dev); - msg.size = sizeof(msg.payload.u64); + vhost_user_get_features(dev, &msg); send_vhost_reply(fd, &msg); break; case VHOST_USER_SET_FEATURES: @@ -1689,7 +1700,6 @@ vhost_user_msg_handler(int vid, int fd) if (ret) goto skip_to_reply; /* it needs a reply */ - msg.size = sizeof(msg.payload.u64); send_vhost_reply(fd, &msg); break; case VHOST_USER_SET_LOG_FD: @@ -1711,7 +1721,6 @@ vhost_user_msg_handler(int vid, int fd) ret = vhost_user_get_vring_base(dev, &msg); if (ret) goto skip_to_reply; - msg.size = sizeof(msg.payload.state); send_vhost_reply(fd, &msg); break; @@ -1729,8 +1738,7 @@ vhost_user_msg_handler(int vid, int fd) break; case VHOST_USER_GET_QUEUE_NUM: - msg.payload.u64 = (uint64_t)vhost_user_get_queue_num(dev); - msg.size = sizeof(msg.payload.u64); + vhost_user_get_queue_num(dev, &msg); send_vhost_reply(fd, &msg); break;
[dpdk-dev] [PATCH v3 0/5] vhost: vhost_user.c code cleanup
vhost: vhost_user.c code cleanup This patchesries introduces a set of code redesigns in vhost_user.c. The goal is to unify and simplify vhost-user message handling. The patches do not intend to make any functional changes. v3 changes: - rebased on top of git://dpdk.org/next/dpdk-next-virtio dead0602 - introduce VH_RESULT_FATAL (Maxime Coquelin) - vhost_user_set_features return VH_RESULT_FATAL on failure. This allows keeping the propagate error logic (Ilya Maximets) - fixed vhost_user_set_vring_kick and vhost_user_set_protocol_features return VH_RESULT_ERR upon failure - fixed missing break in case VH_RESULT_ERR (Ilya Maximets) - fixed a type on the description of 2/5 patch (Maxime Coquelin) v2 changes: - Fix the comments by Tiwei Bie - Keep the old behavior - Fall through when the callback returns VH_RESULT_ERR - Fall through if the request is out of range --- Nikolay Nikolaev (5): vhost: unify VhostUserMsg usage vhost: make message handling functions prepare the reply vhost: handle unsupported message types in functions vhost: unify message handling function signature vhost: message handling implemented as a callback array lib/librte_vhost/vhost_user.c | 402 ++--- 1 file changed, 216 insertions(+), 186 deletions(-) -- Signature
[dpdk-dev] [PATCH v3 1/5] vhost: unify VhostUserMsg usage
Use the typedef version of struct VhostUserMsg. Also unify the related parameter name. Signed-off-by: Nikolay Nikolaev --- lib/librte_vhost/vhost_user.c | 50 + 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index 63d145b2d..b05b57670 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -780,10 +780,10 @@ vhost_memory_changed(struct VhostUserMemory *new, } static int -vhost_user_set_mem_table(struct virtio_net **pdev, struct VhostUserMsg *pmsg) +vhost_user_set_mem_table(struct virtio_net **pdev, VhostUserMsg *msg) { struct virtio_net *dev = *pdev; - struct VhostUserMemory memory = pmsg->payload.memory; + struct VhostUserMemory memory = msg->payload.memory; struct rte_vhost_mem_region *reg; void *mmap_addr; uint64_t mmap_size; @@ -804,7 +804,7 @@ vhost_user_set_mem_table(struct virtio_net **pdev, struct VhostUserMsg *pmsg) "(%d) memory regions not changed\n", dev->vid); for (i = 0; i < memory.nregions; i++) - close(pmsg->fds[i]); + close(msg->fds[i]); return 0; } @@ -845,7 +845,7 @@ vhost_user_set_mem_table(struct virtio_net **pdev, struct VhostUserMsg *pmsg) dev->mem->nregions = memory.nregions; for (i = 0; i < memory.nregions; i++) { - fd = pmsg->fds[i]; + fd = msg->fds[i]; reg = &dev->mem->regions[i]; reg->guest_phys_addr = memory.regions[i].guest_phys_addr; @@ -994,16 +994,16 @@ virtio_is_ready(struct virtio_net *dev) } static void -vhost_user_set_vring_call(struct virtio_net *dev, struct VhostUserMsg *pmsg) +vhost_user_set_vring_call(struct virtio_net *dev, VhostUserMsg *msg) { struct vhost_vring_file file; struct vhost_virtqueue *vq; - file.index = pmsg->payload.u64 & VHOST_USER_VRING_IDX_MASK; - if (pmsg->payload.u64 & VHOST_USER_VRING_NOFD_MASK) + file.index = msg->payload.u64 & VHOST_USER_VRING_IDX_MASK; + if (msg->payload.u64 & VHOST_USER_VRING_NOFD_MASK) file.fd = VIRTIO_INVALID_EVENTFD; else - file.fd = pmsg->fds[0]; + file.fd = msg->fds[0]; RTE_LOG(INFO, VHOST_CONFIG, "vring call idx:%d file:%d\n", file.index, file.fd); @@ -1015,17 +1015,17 @@ vhost_user_set_vring_call(struct virtio_net *dev, struct VhostUserMsg *pmsg) } static int -vhost_user_set_vring_kick(struct virtio_net **pdev, struct VhostUserMsg *pmsg) +vhost_user_set_vring_kick(struct virtio_net **pdev, VhostUserMsg *msg) { struct vhost_vring_file file; struct vhost_virtqueue *vq; struct virtio_net *dev = *pdev; - file.index = pmsg->payload.u64 & VHOST_USER_VRING_IDX_MASK; - if (pmsg->payload.u64 & VHOST_USER_VRING_NOFD_MASK) + file.index = msg->payload.u64 & VHOST_USER_VRING_IDX_MASK; + if (msg->payload.u64 & VHOST_USER_VRING_NOFD_MASK) file.fd = VIRTIO_INVALID_EVENTFD; else - file.fd = pmsg->fds[0]; + file.fd = msg->fds[0]; RTE_LOG(INFO, VHOST_CONFIG, "vring kick idx:%d file:%d\n", file.index, file.fd); @@ -1153,7 +1153,7 @@ vhost_user_set_vring_enable(struct virtio_net *dev, static void vhost_user_get_protocol_features(struct virtio_net *dev, -struct VhostUserMsg *msg) +VhostUserMsg *msg) { uint64_t features, protocol_features; @@ -1189,7 +1189,7 @@ vhost_user_set_protocol_features(struct virtio_net *dev, } static int -vhost_user_set_log_base(struct virtio_net *dev, struct VhostUserMsg *msg) +vhost_user_set_log_base(struct virtio_net *dev, VhostUserMsg *msg) { int fd = msg->fds[0]; uint64_t size, off; @@ -1256,7 +1256,7 @@ vhost_user_set_log_base(struct virtio_net *dev, struct VhostUserMsg *msg) * a flag 'broadcast_rarp' to let rte_vhost_dequeue_burst() inject it. */ static int -vhost_user_send_rarp(struct virtio_net *dev, struct VhostUserMsg *msg) +vhost_user_send_rarp(struct virtio_net *dev, VhostUserMsg *msg) { uint8_t *mac = (uint8_t *)&msg->payload.u64; struct rte_vdpa_device *vdpa_dev; @@ -1285,7 +1285,7 @@ vhost_user_send_rarp(struct virtio_net *dev, struct VhostUserMsg *msg) } static int -vhost_user_net_set_mtu(struct virtio_net *dev, struct VhostUserMsg *msg) +vhost_user_net_set_mtu(struct virtio_net *dev, VhostUserMsg *msg) { if (msg->payload.u64 < VIRTIO_MIN_MTU || msg->payload.u64 > VIRTIO_MAX_MTU) { @@ -1301,7 +1301,7 @@ vhost_user_net_set_mtu(struct virtio_net *dev, struct VhostUserMsg *msg) } static int -vhost_user_set_req_fd(struct virtio_net *dev, struct VhostUserMsg *msg) +vhost_user_set_req_fd(struct virtio
Re: [dpdk-dev] [PATCH v2] net/mlx5: fix representor port xstats
> -Original Message- > From: Yongseok Koh > Sent: Saturday, September 15, 2018 12:51 AM > To: Xueming(Steven) Li > Cc: Shahaf Shuler ; dev@dpdk.org > Subject: Re: [PATCH v2] net/mlx5: fix representor port xstats > > > > On Sep 13, 2018, at 11:33 PM, Xueming Li wrote: > > > > This patch fixes the issue that representor port shows xstats of PF. > > > > Fixes: 5a4b8e2612c5 ("net/mlx5: probe all port representors") > > Wrong commit SHA. > > > Signed-off-by: Xueming Li > > --- > > drivers/net/mlx5/mlx5_stats.c | 13 + > > 1 file changed, 9 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/net/mlx5/mlx5_stats.c > > b/drivers/net/mlx5/mlx5_stats.c index 91f3d47..ed5b51b 100644 > > --- a/drivers/net/mlx5/mlx5_stats.c > > +++ b/drivers/net/mlx5/mlx5_stats.c > > @@ -146,7 +146,7 @@ struct mlx5_counter_ctrl { > > et_stats->cmd = ETHTOOL_GSTATS; > > et_stats->n_stats = xstats_ctrl->stats_n; > > ifr.ifr_data = (caddr_t)et_stats; > > - ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr, 1); > > + ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr, 0); > > if (ret) { > > DRV_LOG(WARNING, > > "port %u unable to read statistic values from device", > > @@ -194,7 > > +194,7 @@ struct mlx5_counter_ctrl { > > > > drvinfo.cmd = ETHTOOL_GDRVINFO; > > ifr.ifr_data = (caddr_t)&drvinfo; > > - ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr, 1); > > + ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr, 0); > > if (ret) { > > DRV_LOG(WARNING, "port %u unable to query number of statistics", > > dev->data->port_id); > > @@ -229,7 +229,6 @@ struct mlx5_counter_ctrl { > > return; > > } > > dev_stats_n = ret; > > - xstats_ctrl->stats_n = dev_stats_n; > > /* Allocate memory to grab stat names and values. */ > > str_sz = dev_stats_n * ETH_GSTRING_LEN; > > strings = (struct ethtool_gstrings *) @@ -244,7 +243,7 @@ struct > > mlx5_counter_ctrl { > > strings->string_set = ETH_SS_STATS; > > strings->len = dev_stats_n; > > ifr.ifr_data = (caddr_t)strings; > > - ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr, 1); > > + ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr, 0); > > if (ret) { > > DRV_LOG(WARNING, "port %u unable to get statistic names", > > dev->data->port_id); > > @@ -275,6 +274,7 @@ struct mlx5_counter_ctrl { > > goto free; > > } > > } > > + xstats_ctrl->stats_n = dev_stats_n; > > Any reason to move it? > If it is done to group the code, I'm fine with that. Don't set value until all code success. > > Thanks, > Yongseok > > > /* Copy to base at first time. */ > > assert(xstats_n <= MLX5_MAX_XSTATS); > > ret = mlx5_read_dev_counters(dev, xstats_ctrl->base); @@ -307,6 > > +307,8 @@ struct mlx5_counter_ctrl { > > unsigned int i; > > uint64_t counters[n]; > > > > + if (!priv->xstats_ctrl.stats_n) > > + return 0; > > if (n >= xstats_n && stats) { > > struct mlx5_xstats_ctrl *xstats_ctrl = &priv->xstats_ctrl; > > int stats_n; > > @@ -480,8 +482,11 @@ struct mlx5_counter_ctrl { > > mlx5_xstats_get_names(struct rte_eth_dev *dev __rte_unused, > > struct rte_eth_xstat_name *xstats_names, unsigned int n) { > > + struct priv *priv = dev->data->dev_private; > > unsigned int i; > > > > + if (!priv->xstats_ctrl.stats_n) > > + return 0; > > if (n >= xstats_n && xstats_names) { > > for (i = 0; i != xstats_n; ++i) { > > strncpy(xstats_names[i].name, > > -- > > 1.8.3.1 > >
[dpdk-dev] [PATCH v3 4/5] vhost: unify message handling function signature
Each vhost-user message handling function will return an int result which is described in the new enum vh_result: error, OK and reply. All functions will now have two arguments, virtio_net double pointer and VhostUserMsg pointer. Signed-off-by: Nikolay Nikolaev --- lib/librte_vhost/vhost_user.c | 213 - 1 file changed, 126 insertions(+), 87 deletions(-) diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index c38b0fd70..81c0396de 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -71,6 +71,16 @@ static const char *vhost_message_str[VHOST_USER_MAX] = { [VHOST_USER_CRYPTO_CLOSE_SESS] = "VHOST_USER_CRYPTO_CLOSE_SESS", }; +/* The possible results of a message handling function */ +enum vh_result { + /* Message handling failed */ + VH_RESULT_ERR = -1, + /* Message handling successful */ + VH_RESULT_OK= 0, + /* Message handling successful and reply prepared */ + VH_RESULT_REPLY = 1, +}; + static uint64_t get_blk_size(int fd) { @@ -127,27 +137,31 @@ vhost_backend_cleanup(struct virtio_net *dev) * the device hasn't been initialised. */ static int -vhost_user_set_owner(void) +vhost_user_set_owner(struct virtio_net **pdev __rte_unused, + VhostUserMsg * msg __rte_unused) { - return 0; + return VH_RESULT_OK; } static int -vhost_user_reset_owner(struct virtio_net *dev) +vhost_user_reset_owner(struct virtio_net **pdev, + VhostUserMsg * msg __rte_unused) { + struct virtio_net *dev = *pdev; vhost_destroy_device_notify(dev); cleanup_device(dev, 0); reset_device(dev); - return 0; + return VH_RESULT_OK; } /* * The features that we support are requested. */ -static uint64_t -vhost_user_get_features(struct virtio_net *dev, VhostUserMsg *msg) +static int +vhost_user_get_features(struct virtio_net **pdev, VhostUserMsg *msg) { + struct virtio_net *dev = *pdev; uint64_t features = 0; rte_vhost_driver_get_features(dev->ifname, &features); @@ -155,15 +169,16 @@ vhost_user_get_features(struct virtio_net *dev, VhostUserMsg *msg) msg->payload.u64 = features; msg->size = sizeof(msg->payload.u64); - return features; + return VH_RESULT_REPLY; } /* * The queue number that we support are requested. */ -static uint32_t -vhost_user_get_queue_num(struct virtio_net *dev, VhostUserMsg *msg) +static int +vhost_user_get_queue_num(struct virtio_net **pdev, VhostUserMsg *msg) { + struct virtio_net *dev = *pdev; uint32_t queue_num = 0; rte_vhost_driver_get_queue_num(dev->ifname, &queue_num); @@ -171,15 +186,17 @@ vhost_user_get_queue_num(struct virtio_net *dev, VhostUserMsg *msg) msg->payload.u64 = (uint64_t)queue_num; msg->size = sizeof(msg->payload.u64); - return queue_num; + return VH_RESULT_REPLY; } /* * We receive the negotiated features supported by us and the virtio device. */ static int -vhost_user_set_features(struct virtio_net *dev, uint64_t features) +vhost_user_set_features(struct virtio_net **pdev, VhostUserMsg *msg) { + struct virtio_net *dev = *pdev; + uint64_t features = msg->payload.u64; uint64_t vhost_features = 0; struct rte_vdpa_device *vdpa_dev; int did = -1; @@ -189,12 +206,12 @@ vhost_user_set_features(struct virtio_net *dev, uint64_t features) RTE_LOG(ERR, VHOST_CONFIG, "(%d) received invalid negotiated features.\n", dev->vid); - return -1; + return VH_RESULT_ERR; } if (dev->flags & VIRTIO_DEV_RUNNING) { if (dev->features == features) - return 0; + return VH_RESULT_OK; /* * Error out if master tries to change features while device is @@ -205,7 +222,7 @@ vhost_user_set_features(struct virtio_net *dev, uint64_t features) RTE_LOG(ERR, VHOST_CONFIG, "(%d) features changed while device is running.\n", dev->vid); - return -1; + return VH_RESULT_ERR; } if (dev->notify_ops->features_changed) @@ -250,16 +267,17 @@ vhost_user_set_features(struct virtio_net *dev, uint64_t features) if (vdpa_dev && vdpa_dev->ops->set_features) vdpa_dev->ops->set_features(dev->vid); - return 0; + return VH_RESULT_OK; } /* * The virtio device sends us the size of the descriptor ring. */ static int -vhost_user_set_vring_num(struct virtio_net *dev, +vhost_user_set_vring_num(struct virtio_net **pdev, VhostUserMsg *msg) { + struct virtio_net *dev = *pdev; struct vhost_virtqueue *vq = dev->
[dpdk-dev] [PATCH v3 3/5] vhost: handle unsupported message types in functions
Add new functions to handle the unsupported vhost message types: - vhost_user_set_vring_err - vhost_user_set_log_fd Signed-off-by: Nikolay Nikolaev --- lib/librte_vhost/vhost_user.c | 22 +- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index 3a00d53cf..c38b0fd70 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -1022,6 +1022,14 @@ vhost_user_set_vring_call(struct virtio_net *dev, VhostUserMsg *msg) vq->callfd = file.fd; } +static void vhost_user_set_vring_err(struct virtio_net *dev __rte_unused, + VhostUserMsg *msg) +{ + if (!(msg->payload.u64 & VHOST_USER_VRING_NOFD_MASK)) + close(msg->fds[0]); + RTE_LOG(INFO, VHOST_CONFIG, "not implemented\n"); +} + static int vhost_user_set_vring_kick(struct virtio_net **pdev, VhostUserMsg *msg) { @@ -1259,6 +1267,13 @@ vhost_user_set_log_base(struct virtio_net *dev, VhostUserMsg *msg) return 0; } +static void +vhost_user_set_log_fd(struct virtio_net *dev __rte_unused, VhostUserMsg *msg) +{ + close(msg->fds[0]); + RTE_LOG(INFO, VHOST_CONFIG, "not implemented.\n"); +} + /* * An rarp packet is constructed and broadcasted to notify switches about * the new location of the migrated VM, so that packets from outside will @@ -1703,8 +1718,7 @@ vhost_user_msg_handler(int vid, int fd) send_vhost_reply(fd, &msg); break; case VHOST_USER_SET_LOG_FD: - close(msg.fds[0]); - RTE_LOG(INFO, VHOST_CONFIG, "not implemented.\n"); + vhost_user_set_log_fd(dev, &msg); break; case VHOST_USER_SET_VRING_NUM: @@ -1732,9 +1746,7 @@ vhost_user_msg_handler(int vid, int fd) break; case VHOST_USER_SET_VRING_ERR: - if (!(msg.payload.u64 & VHOST_USER_VRING_NOFD_MASK)) - close(msg.fds[0]); - RTE_LOG(INFO, VHOST_CONFIG, "not implemented\n"); + vhost_user_set_vring_err(dev, &msg); break; case VHOST_USER_GET_QUEUE_NUM:
[dpdk-dev] [PATCH v3 5/5] vhost: message handling implemented as a callback array
Introduce vhost_message_handlers, which maps the message request type to the message handler. Then replace the switch construct with a map and call. Failing vhost_user_set_features is fatal and all processing should stop immediately and propagate the error to the upper layers. Change the code accordingly to reflect that. Signed-off-by: Nikolay Nikolaev --- lib/librte_vhost/vhost_user.c | 161 + 1 file changed, 66 insertions(+), 95 deletions(-) diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index 81c0396de..9004e1ac8 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -73,6 +73,8 @@ static const char *vhost_message_str[VHOST_USER_MAX] = { /* The possible results of a message handling function */ enum vh_result { + /* Message handling failed with an unrecoverable error */ + VH_RESULT_FATAL = -2, /* Message handling failed */ VH_RESULT_ERR = -1, /* Message handling successful */ @@ -206,7 +208,7 @@ vhost_user_set_features(struct virtio_net **pdev, VhostUserMsg *msg) RTE_LOG(ERR, VHOST_CONFIG, "(%d) received invalid negotiated features.\n", dev->vid); - return VH_RESULT_ERR; + return VH_RESULT_FATAL; } if (dev->flags & VIRTIO_DEV_RUNNING) { @@ -222,7 +224,7 @@ vhost_user_set_features(struct virtio_net **pdev, VhostUserMsg *msg) RTE_LOG(ERR, VHOST_CONFIG, "(%d) features changed while device is running.\n", dev->vid); - return VH_RESULT_ERR; + return VH_RESULT_FATAL; } if (dev->notify_ops->features_changed) @@ -1477,6 +1479,34 @@ vhost_user_iotlb_msg(struct virtio_net **pdev, VhostUserMsg *msg) return VH_RESULT_OK; } +typedef int (*vhost_message_handler_t)(struct virtio_net **pdev, VhostUserMsg * msg); +static vhost_message_handler_t vhost_message_handlers[VHOST_USER_MAX] = { + [VHOST_USER_NONE] = NULL, + [VHOST_USER_GET_FEATURES] = vhost_user_get_features, + [VHOST_USER_SET_FEATURES] = vhost_user_set_features, + [VHOST_USER_SET_OWNER] = vhost_user_set_owner, + [VHOST_USER_RESET_OWNER] = vhost_user_reset_owner, + [VHOST_USER_SET_MEM_TABLE] = vhost_user_set_mem_table, + [VHOST_USER_SET_LOG_BASE] = vhost_user_set_log_base, + [VHOST_USER_SET_LOG_FD] = vhost_user_set_log_fd, + [VHOST_USER_SET_VRING_NUM] = vhost_user_set_vring_num, + [VHOST_USER_SET_VRING_ADDR] = vhost_user_set_vring_addr, + [VHOST_USER_SET_VRING_BASE] = vhost_user_set_vring_base, + [VHOST_USER_GET_VRING_BASE] = vhost_user_get_vring_base, + [VHOST_USER_SET_VRING_KICK] = vhost_user_set_vring_kick, + [VHOST_USER_SET_VRING_CALL] = vhost_user_set_vring_call, + [VHOST_USER_SET_VRING_ERR] = vhost_user_set_vring_err, + [VHOST_USER_GET_PROTOCOL_FEATURES] = vhost_user_get_protocol_features, + [VHOST_USER_SET_PROTOCOL_FEATURES] = vhost_user_set_protocol_features, + [VHOST_USER_GET_QUEUE_NUM] = vhost_user_get_queue_num, + [VHOST_USER_SET_VRING_ENABLE] = vhost_user_set_vring_enable, + [VHOST_USER_SEND_RARP] = vhost_user_send_rarp, + [VHOST_USER_NET_SET_MTU] = vhost_user_net_set_mtu, + [VHOST_USER_SET_SLAVE_REQ_FD] = vhost_user_set_req_fd, + [VHOST_USER_IOTLB_MSG] = vhost_user_iotlb_msg, +}; + + /* return bytes# of read on success or negative val on failure. */ static int read_vhost_message(int sockfd, VhostUserMsg *msg) @@ -1629,6 +1659,7 @@ vhost_user_msg_handler(int vid, int fd) int ret; int unlock_required = 0; uint32_t skip_master = 0; + int request; dev = get_device(vid); if (dev == NULL) @@ -1721,100 +1752,40 @@ vhost_user_msg_handler(int vid, int fd) goto skip_to_post_handle; } - switch (msg.request.master) { - case VHOST_USER_GET_FEATURES: - ret = vhost_user_get_features(&dev, &msg); - send_vhost_reply(fd, &msg); - break; - case VHOST_USER_SET_FEATURES: - ret = vhost_user_set_features(&dev, &msg); - break; - - case VHOST_USER_GET_PROTOCOL_FEATURES: - ret = vhost_user_get_protocol_features(&dev, &msg); - send_vhost_reply(fd, &msg); - break; - case VHOST_USER_SET_PROTOCOL_FEATURES: - ret = vhost_user_set_protocol_features(&dev, &msg); - break; - - case VHOST_USER_SET_OWNER: - ret = vhost_user_set_owner(&dev, &msg); - break; - case VHOST_USER_RESET_OWNER: - ret = vhost_user_reset_owner(&dev, &msg); - break; - - case VHOST_USER_SET_MEM_TABLE: - ret = vhost_
Re: [dpdk-dev] [PATCH v2] net/mlx5: fix wrong representor port link status
> -Original Message- > From: Yongseok Koh > Sent: Saturday, September 15, 2018 12:43 AM > To: Xueming(Steven) Li > Cc: Shahaf Shuler ; dev@dpdk.org; Adrien Mazarguil > > Subject: Re: [PATCH v2] net/mlx5: fix wrong representor port link status > > > > On Sep 13, 2018, at 11:27 PM, Xueming Li wrote: > > > > Current code uses PF links status for representor port, not the > > representor interface itself. This caused wrong representor port link > > status when toggling linterface up or down. > > > > Fixes: 5a4b8e2612c5 ("net/mlx5: probe all port representors") > > Wrong commit SHA. > Please always check it by running > ./devtools/check-git-log.sh -$n > ./devtools/checkpatches.sh -n$n > > > Cc: adrien.mazarg...@6wind.com > > > > Signed-off-by: Xueming Li > > --- > > drivers/net/mlx5/mlx5_ethdev.c | 16 ++-- > > 1 file changed, 10 insertions(+), 6 deletions(-) > > > > diff --git a/drivers/net/mlx5/mlx5_ethdev.c > > b/drivers/net/mlx5/mlx5_ethdev.c index 34c5b95..7391ab8 100644 > > --- a/drivers/net/mlx5/mlx5_ethdev.c > > +++ b/drivers/net/mlx5/mlx5_ethdev.c > > @@ -627,7 +627,7 @@ struct ethtool_link_settings { > > int link_speed = 0; > > int ret; > > > > - ret = mlx5_ifreq(dev, SIOCGIFFLAGS, &ifr, 1); > > + ret = mlx5_ifreq(dev, SIOCGIFFLAGS, &ifr, 0); > > if (ret) { > > DRV_LOG(WARNING, "port %u ioctl(SIOCGIFFLAGS) failed: %s", > > dev->data->port_id, strerror(rte_errno)); @@ -636,6 > > +636,7 @@ > > struct ethtool_link_settings { > > memset(&dev_link, 0, sizeof(dev_link)); > > dev_link.link_status = ((ifr.ifr_flags & IFF_UP) && > > (ifr.ifr_flags & IFF_RUNNING)); > > + memset(&ifr, 0, sizeof(ifr)); > > ifr.ifr_data = (void *)&edata; > > It would be enough to be done like: > > ifr = { > .ifr_data = (void *)&edata, > }; > > And please do the same for dev_link even though it isn't relevant in the > patch. > > > ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr, 1); > > if (ret) { > > @@ -666,8 +667,9 @@ struct ethtool_link_settings { > > ETH_LINK_HALF_DUPLEX : ETH_LINK_FULL_DUPLEX); > > dev_link.link_autoneg = !(dev->data->dev_conf.link_speeds & > > ETH_LINK_SPEED_FIXED); > > - if ((dev_link.link_speed && !dev_link.link_status) || > > - (!dev_link.link_speed && dev_link.link_status)) { > > + if (!priv->representor && > > + ((dev_link.link_speed && !dev_link.link_status) || > > +(!dev_link.link_speed && dev_link.link_status))) { > > What does this change mean? > Is it allowed for representors? Performance the check only if not representor port. For representor port, the status not consistent here due to speed info retrieved from PF. > > > rte_errno = EAGAIN; > > return -rte_errno; > > } > > @@ -698,7 +700,7 @@ struct ethtool_link_settings { > > uint64_t sc; > > int ret; > > > > - ret = mlx5_ifreq(dev, SIOCGIFFLAGS, &ifr, 1); > > + ret = mlx5_ifreq(dev, SIOCGIFFLAGS, &ifr, 0); > > if (ret) { > > DRV_LOG(WARNING, "port %u ioctl(SIOCGIFFLAGS) failed: %s", > > dev->data->port_id, strerror(rte_errno)); @@ -707,6 > > +709,7 @@ > > struct ethtool_link_settings { > > memset(&dev_link, 0, sizeof(dev_link)); > > dev_link.link_status = ((ifr.ifr_flags & IFF_UP) && > > (ifr.ifr_flags & IFF_RUNNING)); > > + memset(&ifr, 0, sizeof(ifr)); > > Same here for dev_link and ifr. > > Thanks, > Yongseok > > > ifr.ifr_data = (void *)&gcmd; > > ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr, 1); > > if (ret) { > > @@ -775,8 +778,9 @@ struct ethtool_link_settings { > > ETH_LINK_HALF_DUPLEX : ETH_LINK_FULL_DUPLEX); > > dev_link.link_autoneg = !(dev->data->dev_conf.link_speeds & > > ETH_LINK_SPEED_FIXED); > > - if ((dev_link.link_speed && !dev_link.link_status) || > > - (!dev_link.link_speed && dev_link.link_status)) { > > + if (!priv->representor && > > + ((dev_link.link_speed && !dev_link.link_status) || > > +(!dev_link.link_speed && dev_link.link_status))) { > > rte_errno = EAGAIN; > > return -rte_errno; > > } > > -- > > 1.8.3.1 > >