DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 19.11 00/12] Miscellaneous fixes
@ 2019-08-07 14:37 Thierry Herbelot
  2019-08-07 14:37 ` [dpdk-dev] [PATCH 19.11 01/12] net/ixgbevf: fix stats update after a PF reset Thierry Herbelot
                   ` (24 more replies)
  0 siblings, 25 replies; 46+ messages in thread
From: Thierry Herbelot @ 2019-08-07 14:37 UTC (permalink / raw)
  To: dev; +Cc: stable, Thomas Monjalon

This series of patches includes fixes for issues seen with
6WIND fast path, built on DPDK.
The patches are in 6WIND version of DPDK, and should have been
upstreamed a long time ago.

Guo Fengtian (1):
  net/ixgbevf: fix stats update after a PF reset

Laurent Hardy (1):
  net/i40e: set speed to undefined for default case in link update

Olivier Matz (5):
  ethdev: fix description of tx descriptor status
  net/e1000: fix Tx descriptor status api (igb)
  net/e1000: fix Tx descriptor status api (em)
  net/ixgbe: fix Tx descriptor status api
  net/i40e: fix Tx descriptor status api

Thibaut Collet (2):
  virtio: fix rx stats with vectorized functions
  virtio: get all pending rx packets with vectorized functions

Thierry Herbelot (3):
  drivers/crypto/openssl: use a local copy for the session contexts
  drivers/crypto/dpaa_sec: update DPAA iova table in dpaa_mem_vtop
  drivers/crypto/octeontx: enable unbinding for the OcteonTx crypto
    engines

 drivers/crypto/dpaa_sec/dpaa_sec.c           |  5 +++-
 drivers/crypto/octeontx/otx_cryptodev.c      |  1 +
 drivers/crypto/openssl/rte_openssl_pmd.c     | 34 +++++++++++++++------
 drivers/net/e1000/em_rxtx.c                  | 33 +++++++++++++-------
 drivers/net/e1000/igb_rxtx.c                 |  9 +++---
 drivers/net/i40e/i40e_ethdev.c               |  4 +--
 drivers/net/i40e/i40e_ethdev_vf.c            |  8 +++--
 drivers/net/i40e/i40e_rxtx.c                 | 37 ++++++++++++++++-------
 drivers/net/ixgbe/ixgbe_ethdev.c             |  6 ++--
 drivers/net/ixgbe/ixgbe_rxtx.c               | 45 ++++++++++++++++++++--------
 drivers/net/ixgbe/ixgbe_rxtx.h               |  1 +
 drivers/net/virtio/virtio_rxtx.c             |  2 +-
 drivers/net/virtio/virtio_rxtx.h             |  2 ++
 drivers/net/virtio/virtio_rxtx_simple_neon.c | 11 +++++--
 drivers/net/virtio/virtio_rxtx_simple_sse.c  | 11 +++++--
 lib/librte_ethdev/rte_ethdev.h               |  4 +--
 16 files changed, 153 insertions(+), 60 deletions(-)

-- 
2.11.0


^ permalink raw reply	[flat|nested] 46+ messages in thread

* [dpdk-dev] [PATCH 19.11 01/12] net/ixgbevf: fix stats update after a PF reset
  2019-08-07 14:37 [dpdk-dev] [PATCH 19.11 00/12] Miscellaneous fixes Thierry Herbelot
@ 2019-08-07 14:37 ` Thierry Herbelot
  2019-08-07 14:37 ` [dpdk-dev] [PATCH 19.11 02/12] ethdev: fix description of tx descriptor status Thierry Herbelot
                   ` (23 subsequent siblings)
  24 siblings, 0 replies; 46+ messages in thread
From: Thierry Herbelot @ 2019-08-07 14:37 UTC (permalink / raw)
  To: dev; +Cc: Guo Fengtian, stable, Thomas Monjalon

From: Guo Fengtian <fengtian.guo@6wind.com>

When PF is set down, in VF, the value of stats register is zero.
So only increase stats when it's non zero.

Fixes: af75078fece3 ('first public release')
Cc: stable at dpdk.org

Signed-off-by: Guo Fengtian <fengtian.guo@6wind.com>
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 03fc1f71799c..57f5bfa219c1 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -385,7 +385,8 @@ static void ixgbe_l2_tunnel_conf(struct rte_eth_dev *dev);
 #define UPDATE_VF_STAT(reg, last, cur)                          \
 {                                                               \
 	uint32_t latest = IXGBE_READ_REG(hw, reg);              \
-	cur += (latest - last) & UINT_MAX;                      \
+	if (latest)                                             \
+		cur += (latest - last) & UINT_MAX;              \
 	last = latest;                                          \
 }
 
@@ -394,7 +395,8 @@ static void ixgbe_l2_tunnel_conf(struct rte_eth_dev *dev);
 	u64 new_lsb = IXGBE_READ_REG(hw, lsb);                   \
 	u64 new_msb = IXGBE_READ_REG(hw, msb);                   \
 	u64 latest = ((new_msb << 32) | new_lsb);                \
-	cur += (0x1000000000LL + latest - last) & 0xFFFFFFFFFLL; \
+	if (latest)                                              \
+		cur += (0x1000000000LL + latest - last) & 0xFFFFFFFFFLL;\
 	last = latest;                                           \
 }
 
-- 
2.11.0


^ permalink raw reply	[flat|nested] 46+ messages in thread

* [dpdk-dev] [PATCH 19.11 02/12] ethdev: fix description of tx descriptor status
  2019-08-07 14:37 [dpdk-dev] [PATCH 19.11 00/12] Miscellaneous fixes Thierry Herbelot
  2019-08-07 14:37 ` [dpdk-dev] [PATCH 19.11 01/12] net/ixgbevf: fix stats update after a PF reset Thierry Herbelot
@ 2019-08-07 14:37 ` Thierry Herbelot
  2019-08-07 14:37 ` [dpdk-dev] [PATCH 19.11 03/12] net/e1000: fix Tx descriptor status api (igb) Thierry Herbelot
                   ` (22 subsequent siblings)
  24 siblings, 0 replies; 46+ messages in thread
From: Thierry Herbelot @ 2019-08-07 14:37 UTC (permalink / raw)
  To: dev; +Cc: Olivier Matz, stable, Thomas Monjalon

From: Olivier Matz <olivier.matz@6wind.com>

The API comment of rte_eth_tx_descriptor_status() was incorrect. The reference
descriptor (when offset = 0) is not where the next packet will be sent, but
where the latest packet has been enqueued.

Fixes: 52f5cdd2e897 ("ethdev: add descriptor status API")
Cc: stable at dpdk.org

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
 lib/librte_ethdev/rte_ethdev.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h
index dc6596bc93b4..b423e71050e9 100644
--- a/lib/librte_ethdev/rte_ethdev.h
+++ b/lib/librte_ethdev/rte_ethdev.h
@@ -4245,8 +4245,8 @@ rte_eth_rx_descriptor_status(uint16_t port_id, uint16_t queue_id,
  * @param queue_id
  *  A valid Tx queue identifier on this port.
  * @param offset
- *  The offset of the descriptor starting from tail (0 is the place where
- *  the next packet will be send).
+ *  The offset of the descriptor starting from tail (0 is the last written
+ *  descriptor).
  *
  * @return
  *  - (RTE_ETH_TX_DESC_FULL) Descriptor is being processed by the hw, i.e.
-- 
2.11.0


^ permalink raw reply	[flat|nested] 46+ messages in thread

* [dpdk-dev] [PATCH 19.11 03/12] net/e1000: fix Tx descriptor status api (igb)
  2019-08-07 14:37 [dpdk-dev] [PATCH 19.11 00/12] Miscellaneous fixes Thierry Herbelot
  2019-08-07 14:37 ` [dpdk-dev] [PATCH 19.11 01/12] net/ixgbevf: fix stats update after a PF reset Thierry Herbelot
  2019-08-07 14:37 ` [dpdk-dev] [PATCH 19.11 02/12] ethdev: fix description of tx descriptor status Thierry Herbelot
@ 2019-08-07 14:37 ` Thierry Herbelot
  2019-08-07 14:37 ` [dpdk-dev] [PATCH 19.11 04/12] net/e1000: fix Tx descriptor status api (em) Thierry Herbelot
                   ` (21 subsequent siblings)
  24 siblings, 0 replies; 46+ messages in thread
From: Thierry Herbelot @ 2019-08-07 14:37 UTC (permalink / raw)
  To: dev; +Cc: Olivier Matz, stable, Thomas Monjalon

From: Olivier Matz <olivier.matz@6wind.com>

The Tx descriptor status api was not behaving as expected. This API is
used to inspect the content of the descriptors in the Tx ring to
determine the length of the Tx queue.

Since the software advances the tail pointer and the hardware advances
the head pointer, the Tx queue is located before txq->tx_tail in the
ring. Therefore, a call to rte_eth_tx_descriptor_status(..., offset=20)
should inspect the 20th descriptor before the tail, not after.

Fixes: 978f8eea1719 ("net/e1000: implement descriptor status API (igb)")
Cc: stable at dpdk.org

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
 drivers/net/e1000/igb_rxtx.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c
index c5606de5d7a0..c22118e59a21 100644
--- a/drivers/net/e1000/igb_rxtx.c
+++ b/drivers/net/e1000/igb_rxtx.c
@@ -1835,14 +1835,15 @@ eth_igb_tx_descriptor_status(void *tx_queue, uint16_t offset)
 {
 	struct igb_tx_queue *txq = tx_queue;
 	volatile uint32_t *status;
-	uint32_t desc;
+	int32_t desc;
 
 	if (unlikely(offset >= txq->nb_tx_desc))
 		return -EINVAL;
 
-	desc = txq->tx_tail + offset;
-	if (desc >= txq->nb_tx_desc)
-		desc -= txq->nb_tx_desc;
+	desc = txq->tx_tail - offset - 1;
+	if (desc < 0)
+		desc += txq->nb_tx_desc;
+	desc = txq->sw_ring[desc].last_id;
 
 	status = &txq->tx_ring[desc].wb.status;
 	if (*status & rte_cpu_to_le_32(E1000_TXD_STAT_DD))
-- 
2.11.0


^ permalink raw reply	[flat|nested] 46+ messages in thread

* [dpdk-dev] [PATCH 19.11 04/12] net/e1000: fix Tx descriptor status api (em)
  2019-08-07 14:37 [dpdk-dev] [PATCH 19.11 00/12] Miscellaneous fixes Thierry Herbelot
                   ` (2 preceding siblings ...)
  2019-08-07 14:37 ` [dpdk-dev] [PATCH 19.11 03/12] net/e1000: fix Tx descriptor status api (igb) Thierry Herbelot
@ 2019-08-07 14:37 ` Thierry Herbelot
  2019-08-07 14:37 ` [dpdk-dev] [PATCH 19.11 05/12] net/ixgbe: fix Tx descriptor status api Thierry Herbelot
                   ` (20 subsequent siblings)
  24 siblings, 0 replies; 46+ messages in thread
From: Thierry Herbelot @ 2019-08-07 14:37 UTC (permalink / raw)
  To: dev; +Cc: Olivier Matz, stable, Thomas Monjalon

From: Olivier Matz <olivier.matz@6wind.com>

The Tx descriptor status api was not behaving as expected. This API is
used to inspect the content of the descriptors in the Tx ring to
determine the length of the Tx queue.

Since the software advances the tail pointer and the hardware advances
the head pointer, the Tx queue is located before txq->tx_tail in the
ring. Therefore, a call to rte_eth_tx_descriptor_status(..., offset=20)
should inspect the 20th descriptor before the tail, not after.

As before, we still need to take care about only checking descriptors
that have the RS bit.

Additionally, we can avoid an access to the ring if offset is greater or
equal to nb_tx_desc - nb_tx_free.

Fixes: b9082317cab3 ("net/e1000: implement descriptor status API (em)")
Cc: stable at dpdk.org

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
 drivers/net/e1000/em_rxtx.c | 33 +++++++++++++++++++++++----------
 1 file changed, 23 insertions(+), 10 deletions(-)

diff --git a/drivers/net/e1000/em_rxtx.c b/drivers/net/e1000/em_rxtx.c
index 5925e490641b..3061998c7768 100644
--- a/drivers/net/e1000/em_rxtx.c
+++ b/drivers/net/e1000/em_rxtx.c
@@ -152,6 +152,7 @@ struct em_tx_queue {
 	uint64_t               tx_ring_phys_addr; /**< TX ring DMA address. */
 	struct em_tx_entry    *sw_ring; /**< virtual address of SW ring. */
 	volatile uint32_t      *tdt_reg_addr; /**< Address of TDT register. */
+	volatile uint32_t      *tdh_reg_addr; /**< Address of TDH register. */
 	uint16_t               nb_tx_desc;    /**< number of TX descriptors. */
 	uint16_t               tx_tail;  /**< Current value of TDT register. */
 	/**< Start freeing TX buffers if there are less free descriptors than
@@ -1304,6 +1305,7 @@ eth_em_tx_queue_setup(struct rte_eth_dev *dev,
 	txq->port_id = dev->data->port_id;
 
 	txq->tdt_reg_addr = E1000_PCI_REG_ADDR(hw, E1000_TDT(queue_idx));
+	txq->tdh_reg_addr = E1000_PCI_REG_ADDR(hw, E1000_TDH(queue_idx));
 	txq->tx_ring_phys_addr = tz->iova;
 	txq->tx_ring = (struct e1000_data_desc *) tz->addr;
 
@@ -1557,22 +1559,33 @@ eth_em_tx_descriptor_status(void *tx_queue, uint16_t offset)
 {
 	struct em_tx_queue *txq = tx_queue;
 	volatile uint8_t *status;
-	uint32_t desc;
+	int32_t desc, dd;
 
 	if (unlikely(offset >= txq->nb_tx_desc))
 		return -EINVAL;
+	if (offset >= txq->nb_tx_desc - txq->nb_tx_free)
+		return RTE_ETH_TX_DESC_DONE;
 
-	desc = txq->tx_tail + offset;
-	/* go to next desc that has the RS bit */
-	desc = ((desc + txq->tx_rs_thresh - 1) / txq->tx_rs_thresh) *
-		txq->tx_rs_thresh;
-	if (desc >= txq->nb_tx_desc) {
-		desc -= txq->nb_tx_desc;
-		if (desc >= txq->nb_tx_desc)
-			desc -= txq->nb_tx_desc;
+	desc = txq->tx_tail - offset - 1;
+	if (desc < 0)
+		desc += txq->nb_tx_desc;
+
+	/* offset is too small, no other way than reading PCI reg */
+	if (unlikely(offset < txq->tx_rs_thresh)) {
+		int16_t tx_head, queue_size;
+		tx_head = e1000_read_addr(txq->tdh_reg_addr);
+		queue_size = txq->tx_tail - tx_head;
+		if (queue_size < 0)
+			queue_size += txq->nb_tx_desc;
+		return queue_size > offset ? RTE_ETH_TX_DESC_FULL :
+			RTE_ETH_TX_DESC_DONE;
 	}
 
-	status = &txq->tx_ring[desc].upper.fields.status;
+	/* index of the dd bit to look at */
+	dd = (desc / txq->tx_rs_thresh + 1) * txq->tx_rs_thresh - 1;
+	dd = txq->sw_ring[dd].last_id;
+
+	status = &txq->tx_ring[dd].upper.fields.status;
 	if (*status & E1000_TXD_STAT_DD)
 		return RTE_ETH_TX_DESC_DONE;
 
-- 
2.11.0


^ permalink raw reply	[flat|nested] 46+ messages in thread

* [dpdk-dev] [PATCH 19.11 05/12] net/ixgbe: fix Tx descriptor status api
  2019-08-07 14:37 [dpdk-dev] [PATCH 19.11 00/12] Miscellaneous fixes Thierry Herbelot
                   ` (3 preceding siblings ...)
  2019-08-07 14:37 ` [dpdk-dev] [PATCH 19.11 04/12] net/e1000: fix Tx descriptor status api (em) Thierry Herbelot
@ 2019-08-07 14:37 ` Thierry Herbelot
  2019-08-07 14:37 ` [dpdk-dev] [PATCH 19.11 06/12] net/i40e: " Thierry Herbelot
                   ` (19 subsequent siblings)
  24 siblings, 0 replies; 46+ messages in thread
From: Thierry Herbelot @ 2019-08-07 14:37 UTC (permalink / raw)
  To: dev; +Cc: Olivier Matz, stable, Thomas Monjalon

From: Olivier Matz <olivier.matz@6wind.com>

The Tx descriptor status api was not behaving as expected. This API is
used to inspect the content of the descriptors in the Tx ring to
determine the length of the Tx queue.

Since the software advances the tail pointer and the hardware advances
the head pointer, the Tx queue is located before txq->tx_tail in the
ring. Therefore, a call to rte_eth_tx_descriptor_status(..., offset=20)
should inspect the 20th descriptor before the tail, not after.

As before, we still need to take care about only checking descriptors
that have the RS bit.

Additionally, we can avoid an access to the ring if offset is greater or
equal to nb_tx_desc - nb_tx_free.

Fixes: 5da8b8814178 ("net/ixgbe: implement descriptor status API")
Cc: stable at dpdk.org

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
 drivers/net/ixgbe/ixgbe_rxtx.c | 45 +++++++++++++++++++++++++++++++-----------
 drivers/net/ixgbe/ixgbe_rxtx.h |  1 +
 2 files changed, 34 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c
index edcfa60cec98..68e3aea5ed46 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx.c
+++ b/drivers/net/ixgbe/ixgbe_rxtx.c
@@ -2627,10 +2627,15 @@ ixgbe_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	    hw->mac.type == ixgbe_mac_X540_vf ||
 	    hw->mac.type == ixgbe_mac_X550_vf ||
 	    hw->mac.type == ixgbe_mac_X550EM_x_vf ||
-	    hw->mac.type == ixgbe_mac_X550EM_a_vf)
+	    hw->mac.type == ixgbe_mac_X550EM_a_vf) {
 		txq->tdt_reg_addr = IXGBE_PCI_REG_ADDR(hw, IXGBE_VFTDT(queue_idx));
-	else
+		txq->tdh_reg_addr = IXGBE_PCI_REG_ADDR(hw,
+				IXGBE_VFTDH(queue_idx));
+	} else {
 		txq->tdt_reg_addr = IXGBE_PCI_REG_ADDR(hw, IXGBE_TDT(txq->reg_idx));
+		txq->tdh_reg_addr = IXGBE_PCI_REG_ADDR(hw,
+				IXGBE_TDH(txq->reg_idx));
+	}
 
 	txq->tx_ring_phys_addr = tz->iova;
 	txq->tx_ring = (union ixgbe_adv_tx_desc *) tz->addr;
@@ -3163,22 +3168,38 @@ ixgbe_dev_tx_descriptor_status(void *tx_queue, uint16_t offset)
 {
 	struct ixgbe_tx_queue *txq = tx_queue;
 	volatile uint32_t *status;
-	uint32_t desc;
+	int32_t desc, dd;
 
 	if (unlikely(offset >= txq->nb_tx_desc))
 		return -EINVAL;
+	if (offset >= txq->nb_tx_desc - txq->nb_tx_free)
+		return RTE_ETH_TX_DESC_DONE;
+
+	desc = txq->tx_tail - offset - 1;
+	if (desc < 0)
+		desc += txq->nb_tx_desc;
 
-	desc = txq->tx_tail + offset;
-	/* go to next desc that has the RS bit */
-	desc = ((desc + txq->tx_rs_thresh - 1) / txq->tx_rs_thresh) *
-		txq->tx_rs_thresh;
-	if (desc >= txq->nb_tx_desc) {
-		desc -= txq->nb_tx_desc;
-		if (desc >= txq->nb_tx_desc)
-			desc -= txq->nb_tx_desc;
+	/* offset is too small, no other way than reading PCI reg */
+	if (unlikely(offset < txq->tx_rs_thresh)) {
+		int16_t tx_head, queue_size;
+		tx_head = ixgbe_read_addr(txq->tdh_reg_addr);
+		queue_size = txq->tx_tail - tx_head;
+		if (queue_size < 0)
+			queue_size += txq->nb_tx_desc;
+		return queue_size > offset ? RTE_ETH_TX_DESC_FULL :
+			RTE_ETH_TX_DESC_DONE;
 	}
 
-	status = &txq->tx_ring[desc].wb.status;
+	/* index of the dd bit to look at */
+	dd = (desc / txq->tx_rs_thresh + 1) * txq->tx_rs_thresh - 1;
+
+	/* In full featured mode, RS bit is only set in the last descriptor */
+	/* of a multisegments packet */
+	if (!((txq->offloads == 0) &&
+	      (txq->tx_rs_thresh >= RTE_PMD_IXGBE_TX_MAX_BURST)))
+		dd = txq->sw_ring[dd].last_id;
+
+	status = &txq->tx_ring[dd].wb.status;
 	if (*status & rte_cpu_to_le_32(IXGBE_ADVTXD_STAT_DD))
 		return RTE_ETH_TX_DESC_DONE;
 
diff --git a/drivers/net/ixgbe/ixgbe_rxtx.h b/drivers/net/ixgbe/ixgbe_rxtx.h
index 505d344b9cee..05fd4167576c 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx.h
+++ b/drivers/net/ixgbe/ixgbe_rxtx.h
@@ -201,6 +201,7 @@ struct ixgbe_tx_queue {
 		struct ixgbe_tx_entry_v *sw_ring_v; /**< address of SW ring for vector PMD */
 	};
 	volatile uint32_t   *tdt_reg_addr; /**< Address of TDT register. */
+	volatile uint32_t   *tdh_reg_addr; /**< Address of TDH register. */
 	uint16_t            nb_tx_desc;    /**< number of TX descriptors. */
 	uint16_t            tx_tail;       /**< current value of TDT reg. */
 	/**< Start freeing TX buffers if there are less free descriptors than
-- 
2.11.0


^ permalink raw reply	[flat|nested] 46+ messages in thread

* [dpdk-dev] [PATCH 19.11 06/12] net/i40e: fix Tx descriptor status api
  2019-08-07 14:37 [dpdk-dev] [PATCH 19.11 00/12] Miscellaneous fixes Thierry Herbelot
                   ` (4 preceding siblings ...)
  2019-08-07 14:37 ` [dpdk-dev] [PATCH 19.11 05/12] net/ixgbe: fix Tx descriptor status api Thierry Herbelot
@ 2019-08-07 14:37 ` Thierry Herbelot
  2019-08-07 14:37 ` [dpdk-dev] [PATCH 19.11 07/12] net/i40e: set speed to undefined for default case in link update Thierry Herbelot
                   ` (18 subsequent siblings)
  24 siblings, 0 replies; 46+ messages in thread
From: Thierry Herbelot @ 2019-08-07 14:37 UTC (permalink / raw)
  To: dev; +Cc: Olivier Matz, stable, Thomas Monjalon

From: Olivier Matz <olivier.matz@6wind.com>

The Tx descriptor status api was not behaving as expected. This API is
used to inspect the content of the descriptors in the Tx ring to
determine the length of the Tx queue.

Since the software advances the tail pointer and the hardware advances
the head pointer, the Tx queue is located before txq->tx_tail in the
ring. Therefore, a call to rte_eth_tx_descriptor_status(..., offset=20)
should inspect the 20th descriptor before the tail, not after.

As before, we still need to take care about only checking descriptors
that have the RS bit.

Additionally, we can avoid an access to the ring if offset is greater or
equal to nb_tx_desc - nb_tx_free.

Fixes: a9dd9af6f38e ("net/i40e: implement descriptor status API")
Cc: stable at dpdk.org

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
 drivers/net/i40e/i40e_rxtx.c | 37 +++++++++++++++++++++++++++----------
 1 file changed, 27 insertions(+), 10 deletions(-)

diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index 692c3bab4b5f..4fbbc097ed4f 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -2031,22 +2031,39 @@ i40e_dev_tx_descriptor_status(void *tx_queue, uint16_t offset)
 	struct i40e_tx_queue *txq = tx_queue;
 	volatile uint64_t *status;
 	uint64_t mask, expect;
-	uint32_t desc;
+	int32_t desc, dd;
 
 	if (unlikely(offset >= txq->nb_tx_desc))
 		return -EINVAL;
+	if (offset >= txq->nb_tx_desc - txq->nb_tx_free)
+		return RTE_ETH_TX_DESC_DONE;
+
+	desc = txq->tx_tail - offset - 1;
+	if (desc < 0)
+		desc += txq->nb_tx_desc;
 
-	desc = txq->tx_tail + offset;
-	/* go to next desc that has the RS bit */
-	desc = ((desc + txq->tx_rs_thresh - 1) / txq->tx_rs_thresh) *
-		txq->tx_rs_thresh;
-	if (desc >= txq->nb_tx_desc) {
-		desc -= txq->nb_tx_desc;
-		if (desc >= txq->nb_tx_desc)
-			desc -= txq->nb_tx_desc;
+	/* offset is too small, no other way than reading PCI reg */
+	if (unlikely(offset < txq->tx_rs_thresh)) {
+		int16_t tx_head, queue_size;
+		tx_head = I40E_READ_REG(I40E_VSI_TO_HW(txq->vsi),
+					I40E_QTX_HEAD(txq->reg_idx));
+		queue_size = txq->tx_tail - tx_head;
+		if (queue_size < 0)
+			queue_size += txq->nb_tx_desc;
+		return queue_size > offset ? RTE_ETH_TX_DESC_FULL :
+			RTE_ETH_TX_DESC_DONE;
 	}
 
-	status = &txq->tx_ring[desc].cmd_type_offset_bsz;
+	/* index of the dd bit to look at */
+	dd = (desc / txq->tx_rs_thresh + 1) * txq->tx_rs_thresh - 1;
+
+	/* In full featured mode, RS bit is only set in the last descriptor */
+	/* of a multisegments packet */
+	if (!((txq->offloads == 0) &&
+	      (txq->tx_rs_thresh >= RTE_PMD_I40E_TX_MAX_BURST)))
+		dd = txq->sw_ring[dd].last_id;
+
+	status = &txq->tx_ring[dd].cmd_type_offset_bsz;
 	mask = rte_le_to_cpu_64(I40E_TXD_QW1_DTYPE_MASK);
 	expect = rte_cpu_to_le_64(
 		I40E_TX_DESC_DTYPE_DESC_DONE << I40E_TXD_QW1_DTYPE_SHIFT);
-- 
2.11.0


^ permalink raw reply	[flat|nested] 46+ messages in thread

* [dpdk-dev] [PATCH 19.11 07/12] net/i40e: set speed to undefined for default case in link update
  2019-08-07 14:37 [dpdk-dev] [PATCH 19.11 00/12] Miscellaneous fixes Thierry Herbelot
                   ` (5 preceding siblings ...)
  2019-08-07 14:37 ` [dpdk-dev] [PATCH 19.11 06/12] net/i40e: " Thierry Herbelot
@ 2019-08-07 14:37 ` Thierry Herbelot
  2019-08-07 14:37 ` [dpdk-dev] [PATCH 19.11 08/12] virtio: fix rx stats with vectorized functions Thierry Herbelot
                   ` (17 subsequent siblings)
  24 siblings, 0 replies; 46+ messages in thread
From: Thierry Herbelot @ 2019-08-07 14:37 UTC (permalink / raw)
  To: dev; +Cc: Laurent Hardy, stable, Thomas Monjalon

From: Laurent Hardy <laurent.hardy@6wind.com>

During PF/VF link update, a default speed value of 100M will be set
if get_link_info has failed or speed is unknown.

Consequently if PF is put in no-carrier state, VFs will switch to
"in carrier" state due to a link up + a link speed set to 100M
(default value if no speed detected).

To be consistent with linux drivers on which PF and VFs are in
same carrier state, sets default speed to undefined (instead of 100M)
and updates a link status of VF only if link is up and speed is
different from undefined.

Fixes: 4861cde46116 ('i40e: new poll mode driver')
Cc: stable at dpdk.org

Signed-off-by: Laurent Hardy <laurent.hardy@6wind.com>
---
 drivers/net/i40e/i40e_ethdev.c    | 4 ++--
 drivers/net/i40e/i40e_ethdev_vf.c | 8 +++++---
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 4e40b7ab5250..76abe8209a10 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -2743,7 +2743,7 @@ update_link_aq(struct i40e_hw *hw, struct rte_eth_link *link,
 		status = i40e_aq_get_link_info(hw, enable_lse,
 						&link_status, NULL);
 		if (unlikely(status != I40E_SUCCESS)) {
-			link->link_speed = ETH_SPEED_NUM_100M;
+			link->link_speed = ETH_SPEED_NUM_NONE;
 			link->link_duplex = ETH_LINK_FULL_DUPLEX;
 			PMD_DRV_LOG(ERR, "Failed to get link info");
 			return;
@@ -2777,7 +2777,7 @@ update_link_aq(struct i40e_hw *hw, struct rte_eth_link *link,
 		link->link_speed = ETH_SPEED_NUM_40G;
 		break;
 	default:
-		link->link_speed = ETH_SPEED_NUM_100M;
+		link->link_speed = ETH_SPEED_NUM_NONE;
 		break;
 	}
 }
diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index 308fb9835ab1..9ba351710b7a 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -2143,13 +2143,15 @@ i40evf_dev_link_update(struct rte_eth_dev *dev,
 		new_link.link_speed = ETH_SPEED_NUM_40G;
 		break;
 	default:
-		new_link.link_speed = ETH_SPEED_NUM_100M;
+		new_link.link_speed = ETH_SPEED_NUM_NONE;
 		break;
 	}
 	/* full duplex only */
 	new_link.link_duplex = ETH_LINK_FULL_DUPLEX;
-	new_link.link_status = vf->link_up ? ETH_LINK_UP :
-					     ETH_LINK_DOWN;
+	new_link.link_status = vf->link_up
+				&& new_link.link_speed != ETH_SPEED_NUM_NONE
+				? ETH_LINK_UP
+				: ETH_LINK_DOWN;
 	new_link.link_autoneg =
 		!(dev->data->dev_conf.link_speeds & ETH_LINK_SPEED_FIXED);
 
-- 
2.11.0


^ permalink raw reply	[flat|nested] 46+ messages in thread

* [dpdk-dev] [PATCH 19.11 08/12] virtio: fix rx stats with vectorized functions
  2019-08-07 14:37 [dpdk-dev] [PATCH 19.11 00/12] Miscellaneous fixes Thierry Herbelot
                   ` (6 preceding siblings ...)
  2019-08-07 14:37 ` [dpdk-dev] [PATCH 19.11 07/12] net/i40e: set speed to undefined for default case in link update Thierry Herbelot
@ 2019-08-07 14:37 ` Thierry Herbelot
  2019-08-07 14:37 ` [dpdk-dev] [PATCH 19.11 09/12] virtio: get all pending rx packets " Thierry Herbelot
                   ` (16 subsequent siblings)
  24 siblings, 0 replies; 46+ messages in thread
From: Thierry Herbelot @ 2019-08-07 14:37 UTC (permalink / raw)
  To: dev; +Cc: Thibaut Collet, stable, Thomas Monjalon

From: Thibaut Collet <thibaut.collet@6wind.com>

With vectorized functions, only the rx stats for number of packets is
incremented.
Update also the other statistics.
Performance impact is about 2%

Fixes: fc3d66212fed ("virtio: add vector Rx")
Cc: stable at dpdk.org

Signed-off-by: Thibaut Collet <thibaut.collet@6wind.com>
---
 drivers/net/virtio/virtio_rxtx.c             | 2 +-
 drivers/net/virtio/virtio_rxtx.h             | 2 ++
 drivers/net/virtio/virtio_rxtx_simple_neon.c | 6 ++++++
 drivers/net/virtio/virtio_rxtx_simple_sse.c  | 6 ++++++
 4 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c
index 27ead19fbe81..6dd62bf51863 100644
--- a/drivers/net/virtio/virtio_rxtx.c
+++ b/drivers/net/virtio/virtio_rxtx.c
@@ -1083,7 +1083,7 @@ virtio_discard_rxbuf_inorder(struct virtqueue *vq, struct rte_mbuf *m)
 	}
 }
 
-static inline void
+void
 virtio_update_packet_stats(struct virtnet_stats *stats, struct rte_mbuf *mbuf)
 {
 	uint32_t s = mbuf->pkt_len;
diff --git a/drivers/net/virtio/virtio_rxtx.h b/drivers/net/virtio/virtio_rxtx.h
index 685cc4f8104c..1eb8dae227ee 100644
--- a/drivers/net/virtio/virtio_rxtx.h
+++ b/drivers/net/virtio/virtio_rxtx.h
@@ -59,5 +59,7 @@ struct virtnet_ctl {
 };
 
 int virtio_rxq_vec_setup(struct virtnet_rx *rxvq);
+void virtio_update_packet_stats(struct virtnet_stats *stats,
+				struct rte_mbuf *mbuf);
 
 #endif /* _VIRTIO_RXTX_H_ */
diff --git a/drivers/net/virtio/virtio_rxtx_simple_neon.c b/drivers/net/virtio/virtio_rxtx_simple_neon.c
index cdc2a4d28ed5..e4b18cba0ce5 100644
--- a/drivers/net/virtio/virtio_rxtx_simple_neon.c
+++ b/drivers/net/virtio/virtio_rxtx_simple_neon.c
@@ -47,6 +47,7 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 	struct vring_used_elem *rused;
 	struct rte_mbuf **sw_ring;
 	struct rte_mbuf **sw_ring_end;
+	struct rte_mbuf **ref_rx_pkts;
 	uint16_t nb_pkts_received = 0;
 
 	uint8x16_t shuf_msk1 = {
@@ -105,6 +106,7 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 			virtqueue_notify(vq);
 	}
 
+	ref_rx_pkts = rx_pkts;
 	for (nb_pkts_received = 0;
 		nb_pkts_received < nb_used;) {
 		uint64x2_t desc[RTE_VIRTIO_DESC_PER_LOOP / 2];
@@ -204,5 +206,9 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 	vq->vq_used_cons_idx += nb_pkts_received;
 	vq->vq_free_cnt += nb_pkts_received;
 	rxvq->stats.packets += nb_pkts_received;
+	for (nb_used = 0; nb_used < nb_pkts_received; nb_used++) {
+		rxvq->stats.bytes += ref_rx_pkts[nb_used]->pkt_len;
+		virtio_update_packet_stats(&rxvq->stats, ref_rx_pkts[nb_used]);
+	}
 	return nb_pkts_received;
 }
diff --git a/drivers/net/virtio/virtio_rxtx_simple_sse.c b/drivers/net/virtio/virtio_rxtx_simple_sse.c
index af76708d66ae..c757e8c9d601 100644
--- a/drivers/net/virtio/virtio_rxtx_simple_sse.c
+++ b/drivers/net/virtio/virtio_rxtx_simple_sse.c
@@ -48,6 +48,7 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 	struct vring_used_elem *rused;
 	struct rte_mbuf **sw_ring;
 	struct rte_mbuf **sw_ring_end;
+	struct rte_mbuf **ref_rx_pkts;
 	uint16_t nb_pkts_received = 0;
 	__m128i shuf_msk1, shuf_msk2, len_adjust;
 
@@ -107,6 +108,7 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 			virtqueue_notify(vq);
 	}
 
+	ref_rx_pkts = rx_pkts;
 	for (nb_pkts_received = 0;
 		nb_pkts_received < nb_used;) {
 		__m128i desc[RTE_VIRTIO_DESC_PER_LOOP / 2];
@@ -190,5 +192,9 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 	vq->vq_used_cons_idx += nb_pkts_received;
 	vq->vq_free_cnt += nb_pkts_received;
 	rxvq->stats.packets += nb_pkts_received;
+	for (nb_used = 0; nb_used < nb_pkts_received; nb_used++) {
+		rxvq->stats.bytes += ref_rx_pkts[nb_used]->pkt_len;
+		virtio_update_packet_stats(&rxvq->stats, ref_rx_pkts[nb_used]);
+	}
 	return nb_pkts_received;
 }
-- 
2.11.0


^ permalink raw reply	[flat|nested] 46+ messages in thread

* [dpdk-dev] [PATCH 19.11 09/12] virtio: get all pending rx packets with vectorized functions
  2019-08-07 14:37 [dpdk-dev] [PATCH 19.11 00/12] Miscellaneous fixes Thierry Herbelot
                   ` (7 preceding siblings ...)
  2019-08-07 14:37 ` [dpdk-dev] [PATCH 19.11 08/12] virtio: fix rx stats with vectorized functions Thierry Herbelot
@ 2019-08-07 14:37 ` Thierry Herbelot
  2019-08-07 14:37 ` [dpdk-dev] [PATCH 19.11 10/12] drivers/crypto/openssl: use a local copy for the session contexts Thierry Herbelot
                   ` (15 subsequent siblings)
  24 siblings, 0 replies; 46+ messages in thread
From: Thierry Herbelot @ 2019-08-07 14:37 UTC (permalink / raw)
  To: dev; +Cc: Thibaut Collet, stable, Thomas Monjalon

From: Thibaut Collet <thibaut.collet@6wind.com>

The loop to read packets does not take all packets as the number of
available packets (nb_used) is decremented in the loop.
Take all available packets provides a performance improvement of 3%.

Fixes: fc3d66212fed ("virtio: add vector Rx")
Cc: stable at dpdk.org

Signed-off-by: Thibaut Collet <thibaut.collet@6wind.com>
---
 drivers/net/virtio/virtio_rxtx_simple_neon.c | 5 +++--
 drivers/net/virtio/virtio_rxtx_simple_sse.c  | 5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/virtio/virtio_rxtx_simple_neon.c b/drivers/net/virtio/virtio_rxtx_simple_neon.c
index e4b18cba0ce5..66bdaa00e01f 100644
--- a/drivers/net/virtio/virtio_rxtx_simple_neon.c
+++ b/drivers/net/virtio/virtio_rxtx_simple_neon.c
@@ -42,7 +42,7 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 	struct virtnet_rx *rxvq = rx_queue;
 	struct virtqueue *vq = rxvq->vq;
 	struct virtio_hw *hw = vq->hw;
-	uint16_t nb_used;
+	uint16_t nb_used, nb_total;
 	uint16_t desc_idx;
 	struct vring_used_elem *rused;
 	struct rte_mbuf **sw_ring;
@@ -106,9 +106,10 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 			virtqueue_notify(vq);
 	}
 
+	nb_total = nb_used;
 	ref_rx_pkts = rx_pkts;
 	for (nb_pkts_received = 0;
-		nb_pkts_received < nb_used;) {
+		nb_pkts_received < nb_total;) {
 		uint64x2_t desc[RTE_VIRTIO_DESC_PER_LOOP / 2];
 		uint64x2_t mbp[RTE_VIRTIO_DESC_PER_LOOP / 2];
 		uint64x2_t pkt_mb[RTE_VIRTIO_DESC_PER_LOOP];
diff --git a/drivers/net/virtio/virtio_rxtx_simple_sse.c b/drivers/net/virtio/virtio_rxtx_simple_sse.c
index c757e8c9d601..811b416755e7 100644
--- a/drivers/net/virtio/virtio_rxtx_simple_sse.c
+++ b/drivers/net/virtio/virtio_rxtx_simple_sse.c
@@ -43,7 +43,7 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 	struct virtnet_rx *rxvq = rx_queue;
 	struct virtqueue *vq = rxvq->vq;
 	struct virtio_hw *hw = vq->hw;
-	uint16_t nb_used;
+	uint16_t nb_used, nb_total;
 	uint16_t desc_idx;
 	struct vring_used_elem *rused;
 	struct rte_mbuf **sw_ring;
@@ -108,9 +108,10 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 			virtqueue_notify(vq);
 	}
 
+	nb_total = nb_used;
 	ref_rx_pkts = rx_pkts;
 	for (nb_pkts_received = 0;
-		nb_pkts_received < nb_used;) {
+		nb_pkts_received < nb_total;) {
 		__m128i desc[RTE_VIRTIO_DESC_PER_LOOP / 2];
 		__m128i mbp[RTE_VIRTIO_DESC_PER_LOOP / 2];
 		__m128i pkt_mb[RTE_VIRTIO_DESC_PER_LOOP];
-- 
2.11.0


^ permalink raw reply	[flat|nested] 46+ messages in thread

* [dpdk-dev] [PATCH 19.11 10/12] drivers/crypto/openssl: use a local copy for the session contexts
  2019-08-07 14:37 [dpdk-dev] [PATCH 19.11 00/12] Miscellaneous fixes Thierry Herbelot
                   ` (8 preceding siblings ...)
  2019-08-07 14:37 ` [dpdk-dev] [PATCH 19.11 09/12] virtio: get all pending rx packets " Thierry Herbelot
@ 2019-08-07 14:37 ` Thierry Herbelot
  2019-08-07 14:37 ` [dpdk-dev] [PATCH 19.11 11/12] drivers/crypto/dpaa_sec: update DPAA iova table in dpaa_mem_vtop Thierry Herbelot
                   ` (14 subsequent siblings)
  24 siblings, 0 replies; 46+ messages in thread
From: Thierry Herbelot @ 2019-08-07 14:37 UTC (permalink / raw)
  To: dev; +Cc: stable, Thomas Monjalon

Session contexts are used for temporary storage when processing a
packet.
If packets for the same session are to be processed simultaneously on
multiple cores, separate contexts must be used.

Note: with openssl 1.1.1 EVP_CIPHER_CTX can no longer be defined as a
variable on the stack: it must be allocated. This in turn reduces the
performance.

Fixes: d61f70b4c918 ('crypto/libcrypto: add driver for OpenSSL library')
Cc: stable at dpdk.org

Signed-off-by: Thierry Herbelot <thierry.herbelot@6wind.com>
---
 drivers/crypto/openssl/rte_openssl_pmd.c | 34 +++++++++++++++++++++++---------
 1 file changed, 25 insertions(+), 9 deletions(-)

diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c b/drivers/crypto/openssl/rte_openssl_pmd.c
index 2f5552840741..ce2d12347737 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd.c
@@ -1290,6 +1290,7 @@ process_openssl_combined_op
 	int srclen, aadlen, status = -1;
 	uint32_t offset;
 	uint8_t taglen;
+	EVP_CIPHER_CTX *ctx_copy;
 
 	/*
 	 * Segmented destination buffer is not supported for
@@ -1326,6 +1327,8 @@ process_openssl_combined_op
 	}
 
 	taglen = sess->auth.digest_length;
+	ctx_copy = EVP_CIPHER_CTX_new();
+	EVP_CIPHER_CTX_copy(ctx_copy, sess->cipher.ctx);
 
 	if (sess->cipher.direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
 		if (sess->auth.algo == RTE_CRYPTO_AUTH_AES_GMAC ||
@@ -1333,12 +1336,12 @@ process_openssl_combined_op
 			status = process_openssl_auth_encryption_gcm(
 					mbuf_src, offset, srclen,
 					aad, aadlen, iv,
-					dst, tag, sess->cipher.ctx);
+					dst, tag, ctx_copy);
 		else
 			status = process_openssl_auth_encryption_ccm(
 					mbuf_src, offset, srclen,
 					aad, aadlen, iv,
-					dst, tag, taglen, sess->cipher.ctx);
+					dst, tag, taglen, ctx_copy);
 
 	} else {
 		if (sess->auth.algo == RTE_CRYPTO_AUTH_AES_GMAC ||
@@ -1346,14 +1349,15 @@ process_openssl_combined_op
 			status = process_openssl_auth_decryption_gcm(
 					mbuf_src, offset, srclen,
 					aad, aadlen, iv,
-					dst, tag, sess->cipher.ctx);
+					dst, tag, ctx_copy);
 		else
 			status = process_openssl_auth_decryption_ccm(
 					mbuf_src, offset, srclen,
 					aad, aadlen, iv,
-					dst, tag, taglen, sess->cipher.ctx);
+					dst, tag, taglen, ctx_copy);
 	}
 
+	EVP_CIPHER_CTX_free(ctx_copy);
 	if (status != 0) {
 		if (status == (-EFAULT) &&
 				sess->auth.operation ==
@@ -1372,6 +1376,7 @@ process_openssl_cipher_op
 {
 	uint8_t *dst, *iv;
 	int srclen, status;
+	EVP_CIPHER_CTX *ctx_copy;
 
 	/*
 	 * Segmented destination buffer is not supported for
@@ -1388,22 +1393,25 @@ process_openssl_cipher_op
 
 	iv = rte_crypto_op_ctod_offset(op, uint8_t *,
 			sess->iv.offset);
+	ctx_copy = EVP_CIPHER_CTX_new();
+	EVP_CIPHER_CTX_copy(ctx_copy, sess->cipher.ctx);
 
 	if (sess->cipher.mode == OPENSSL_CIPHER_LIB)
 		if (sess->cipher.direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT)
 			status = process_openssl_cipher_encrypt(mbuf_src, dst,
 					op->sym->cipher.data.offset, iv,
-					srclen, sess->cipher.ctx);
+					srclen, ctx_copy);
 		else
 			status = process_openssl_cipher_decrypt(mbuf_src, dst,
 					op->sym->cipher.data.offset, iv,
-					srclen, sess->cipher.ctx);
+					srclen, ctx_copy);
 	else
 		status = process_openssl_cipher_des3ctr(mbuf_src, dst,
 				op->sym->cipher.data.offset, iv,
 				sess->cipher.key.data, srclen,
-				sess->cipher.ctx);
+				ctx_copy);
 
+	EVP_CIPHER_CTX_free(ctx_copy);
 	if (status != 0)
 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
 }
@@ -1507,6 +1515,8 @@ process_openssl_auth_op(struct openssl_qp *qp, struct rte_crypto_op *op,
 {
 	uint8_t *dst;
 	int srclen, status;
+	EVP_MD_CTX *ctx_a;
+	HMAC_CTX *ctx_h;
 
 	srclen = op->sym->auth.data.length;
 
@@ -1514,14 +1524,20 @@ process_openssl_auth_op(struct openssl_qp *qp, struct rte_crypto_op *op,
 
 	switch (sess->auth.mode) {
 	case OPENSSL_AUTH_AS_AUTH:
+		ctx_a = EVP_MD_CTX_create();
+		EVP_MD_CTX_copy_ex(ctx_a, sess->auth.auth.ctx);
 		status = process_openssl_auth(mbuf_src, dst,
 				op->sym->auth.data.offset, NULL, NULL, srclen,
-				sess->auth.auth.ctx, sess->auth.auth.evp_algo);
+				ctx_a, sess->auth.auth.evp_algo);
+		EVP_MD_CTX_destroy(ctx_a);
 		break;
 	case OPENSSL_AUTH_AS_HMAC:
+		ctx_h = HMAC_CTX_new();
+		HMAC_CTX_copy(ctx_h, sess->auth.hmac.ctx);
 		status = process_openssl_auth_hmac(mbuf_src, dst,
 				op->sym->auth.data.offset, srclen,
-				sess->auth.hmac.ctx);
+				ctx_h);
+		HMAC_CTX_free(ctx_h);
 		break;
 	default:
 		status = -1;
-- 
2.11.0


^ permalink raw reply	[flat|nested] 46+ messages in thread

* [dpdk-dev] [PATCH 19.11 11/12] drivers/crypto/dpaa_sec: update DPAA iova table in dpaa_mem_vtop
  2019-08-07 14:37 [dpdk-dev] [PATCH 19.11 00/12] Miscellaneous fixes Thierry Herbelot
                   ` (9 preceding siblings ...)
  2019-08-07 14:37 ` [dpdk-dev] [PATCH 19.11 10/12] drivers/crypto/openssl: use a local copy for the session contexts Thierry Herbelot
@ 2019-08-07 14:37 ` Thierry Herbelot
  2019-08-07 14:37 ` [dpdk-dev] [PATCH 19.11 12/12] drivers/crypto/octeontx: enable unbinding for the OcteonTx crypto engines Thierry Herbelot
                   ` (13 subsequent siblings)
  24 siblings, 0 replies; 46+ messages in thread
From: Thierry Herbelot @ 2019-08-07 14:37 UTC (permalink / raw)
  To: dev; +Cc: stable, Thomas Monjalon

dpaa_sec needs translations between physical and virtual addresses. V to P
translation is relatively fast, as memory is managed in contiguous segments.

The result of each V to P translation is used to update the DPAA iova table,
which should be updated by a Mem event callback, but is not.
Then the DPAA iova table has entries for all needed memory ranges.

With this patch, dpaa_mem_ptov will always use dpaax_iova_table_get_va, which
ensures optimal performance.

Fixes: 5a7dbb934d75 ('dpaa: enable dpaax library')
Cc: stable at dpdk.org

Signed-off-by: Thierry Herbelot <thierry.herbelot@6wind.com>
---
 drivers/crypto/dpaa_sec/dpaa_sec.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c
index 122c80a072ff..22b8b1d63ce0 100644
--- a/drivers/crypto/dpaa_sec/dpaa_sec.c
+++ b/drivers/crypto/dpaa_sec/dpaa_sec.c
@@ -38,6 +38,7 @@
 #include <rte_dpaa_bus.h>
 #include <dpaa_sec.h>
 #include <dpaa_sec_log.h>
+#include <dpaax_iova_table.h>
 
 enum rta_sec_era rta_sec_era;
 
@@ -100,8 +101,10 @@ dpaa_mem_vtop(void *vaddr)
 	const struct rte_memseg *ms;
 
 	ms = rte_mem_virt2memseg(vaddr, NULL);
-	if (ms)
+	if (ms) {
+		dpaax_iova_table_update(ms->iova, (void *)ms->addr_64, ms->len);
 		return ms->iova + RTE_PTR_DIFF(vaddr, ms->addr);
+	}
 	return (size_t)NULL;
 }
 
-- 
2.11.0


^ permalink raw reply	[flat|nested] 46+ messages in thread

* [dpdk-dev] [PATCH 19.11 12/12] drivers/crypto/octeontx: enable unbinding for the OcteonTx crypto engines
  2019-08-07 14:37 [dpdk-dev] [PATCH 19.11 00/12] Miscellaneous fixes Thierry Herbelot
                   ` (10 preceding siblings ...)
  2019-08-07 14:37 ` [dpdk-dev] [PATCH 19.11 11/12] drivers/crypto/dpaa_sec: update DPAA iova table in dpaa_mem_vtop Thierry Herbelot
@ 2019-08-07 14:37 ` Thierry Herbelot
  2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 00/12] Miscellaneous fixes Thierry Herbelot
                   ` (12 subsequent siblings)
  24 siblings, 0 replies; 46+ messages in thread
From: Thierry Herbelot @ 2019-08-07 14:37 UTC (permalink / raw)
  To: dev; +Cc: stable, Thomas Monjalon

Like for Ethernet ports, the OcteonTx crypto engines must first be unbound
from their kernel module, then rebound to vfio-pci, before being usable
in DPDK.

As this capability is detected at runtime by dpdk-pmdinfo, add the info
in the PMD registering directives.

Then an external script can be used for bind and unbind.

Fixes: bfe2ae495ee268 ('crypto/octeontx: add PMD skeleton')
Cc: stable at dpdk.org

Signed-off-by: Thierry Herbelot <thierry.herbelot@6wind.com>
---
 drivers/crypto/octeontx/otx_cryptodev.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/crypto/octeontx/otx_cryptodev.c b/drivers/crypto/octeontx/otx_cryptodev.c
index fc64a5f3041f..16f1909966d0 100644
--- a/drivers/crypto/octeontx/otx_cryptodev.c
+++ b/drivers/crypto/octeontx/otx_cryptodev.c
@@ -118,6 +118,7 @@ static struct cryptodev_driver otx_cryptodev_drv;
 
 RTE_PMD_REGISTER_PCI(CRYPTODEV_NAME_OCTEONTX_PMD, otx_cryptodev_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(CRYPTODEV_NAME_OCTEONTX_PMD, pci_id_cpt_table);
+RTE_PMD_REGISTER_KMOD_DEP(CRYPTODEV_NAME_OCTEONTX_PMD, "* igb_uio | uio_pci_generic | vfio-pci");
 RTE_PMD_REGISTER_CRYPTO_DRIVER(otx_cryptodev_drv, otx_cryptodev_pmd.driver,
 		otx_cryptodev_driver_id);
 
-- 
2.11.0


^ permalink raw reply	[flat|nested] 46+ messages in thread

* [dpdk-dev] [PATCH 19.11 V2 00/12] Miscellaneous fixes
  2019-08-07 14:37 [dpdk-dev] [PATCH 19.11 00/12] Miscellaneous fixes Thierry Herbelot
                   ` (11 preceding siblings ...)
  2019-08-07 14:37 ` [dpdk-dev] [PATCH 19.11 12/12] drivers/crypto/octeontx: enable unbinding for the OcteonTx crypto engines Thierry Herbelot
@ 2019-08-07 15:09 ` Thierry Herbelot
  2019-08-08  8:22   ` [dpdk-dev] [PATCH 19.11 V3 " Thierry Herbelot
                     ` (12 more replies)
  2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 01/12] net/ixgbevf: fix stats update after a PF reset Thierry Herbelot
                   ` (11 subsequent siblings)
  24 siblings, 13 replies; 46+ messages in thread
From: Thierry Herbelot @ 2019-08-07 15:09 UTC (permalink / raw)
  To: dev; +Cc: stable, Thomas Monjalon

This series of patches includes fixes for issues seen with
6WIND fast path, built on DPDK.
The patches are in 6WIND version of DPDK, and should have been
upstreamed a long time ago.

V2 changes:
fix checkpatch issues

Guo Fengtian (1):
  net/ixgbevf: fix stats update after a PF reset

Laurent Hardy (1):
  net/i40e: set speed to undefined for default case in link update

Olivier Matz (5):
  ethdev: fix description of tx descriptor status
  net/e1000: fix Tx descriptor status api (igb)
  net/e1000: fix Tx descriptor status api (em)
  net/ixgbe: fix Tx descriptor status api
  net/i40e: fix Tx descriptor status api

Thibaut Collet (2):
  virtio: fix rx stats with vectorized functions
  virtio: get all pending rx packets with vectorized functions

Thierry Herbelot (3):
  drivers/crypto/openssl: use a local copy for the session contexts
  drivers/crypto/dpaa_sec: update DPAA iova table in dpaa_mem_vtop
  drivers/crypto/octeontx: enable unbinding for the OcteonTx crypto
    engines

 drivers/crypto/dpaa_sec/dpaa_sec.c           |  5 +++-
 drivers/crypto/octeontx/otx_cryptodev.c      |  1 +
 drivers/crypto/openssl/rte_openssl_pmd.c     | 34 +++++++++++++++------
 drivers/net/e1000/em_rxtx.c                  | 33 +++++++++++++-------
 drivers/net/e1000/igb_rxtx.c                 |  9 +++---
 drivers/net/i40e/i40e_ethdev.c               |  4 +--
 drivers/net/i40e/i40e_ethdev_vf.c            |  8 +++--
 drivers/net/i40e/i40e_rxtx.c                 | 37 ++++++++++++++++-------
 drivers/net/ixgbe/ixgbe_ethdev.c             |  6 ++--
 drivers/net/ixgbe/ixgbe_rxtx.c               | 45 ++++++++++++++++++++--------
 drivers/net/ixgbe/ixgbe_rxtx.h               |  1 +
 drivers/net/virtio/virtio_rxtx.c             |  2 +-
 drivers/net/virtio/virtio_rxtx.h             |  2 ++
 drivers/net/virtio/virtio_rxtx_simple_neon.c | 11 +++++--
 drivers/net/virtio/virtio_rxtx_simple_sse.c  | 11 +++++--
 lib/librte_ethdev/rte_ethdev.h               |  4 +--
 16 files changed, 153 insertions(+), 60 deletions(-)

-- 
2.11.0


^ permalink raw reply	[flat|nested] 46+ messages in thread

* [dpdk-dev] [PATCH 19.11 V2 01/12] net/ixgbevf: fix stats update after a PF reset
  2019-08-07 14:37 [dpdk-dev] [PATCH 19.11 00/12] Miscellaneous fixes Thierry Herbelot
                   ` (12 preceding siblings ...)
  2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 00/12] Miscellaneous fixes Thierry Herbelot
@ 2019-08-07 15:09 ` Thierry Herbelot
  2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 02/12] ethdev: fix description of tx descriptor status Thierry Herbelot
                   ` (10 subsequent siblings)
  24 siblings, 0 replies; 46+ messages in thread
From: Thierry Herbelot @ 2019-08-07 15:09 UTC (permalink / raw)
  To: dev; +Cc: Guo Fengtian, stable, Thomas Monjalon

From: Guo Fengtian <fengtian.guo@6wind.com>

When PF is set down, in VF, the value of stats register is zero.
So only increase stats when it's non zero.

Fixes: af75078fece3 ('first public release')
Cc: stable@dpdk.org

Signed-off-by: Guo Fengtian <fengtian.guo@6wind.com>
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 03fc1f71799c..57f5bfa219c1 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -385,7 +385,8 @@ static void ixgbe_l2_tunnel_conf(struct rte_eth_dev *dev);
 #define UPDATE_VF_STAT(reg, last, cur)                          \
 {                                                               \
 	uint32_t latest = IXGBE_READ_REG(hw, reg);              \
-	cur += (latest - last) & UINT_MAX;                      \
+	if (latest)                                             \
+		cur += (latest - last) & UINT_MAX;              \
 	last = latest;                                          \
 }
 
@@ -394,7 +395,8 @@ static void ixgbe_l2_tunnel_conf(struct rte_eth_dev *dev);
 	u64 new_lsb = IXGBE_READ_REG(hw, lsb);                   \
 	u64 new_msb = IXGBE_READ_REG(hw, msb);                   \
 	u64 latest = ((new_msb << 32) | new_lsb);                \
-	cur += (0x1000000000LL + latest - last) & 0xFFFFFFFFFLL; \
+	if (latest)                                              \
+		cur += (0x1000000000LL + latest - last) & 0xFFFFFFFFFLL;\
 	last = latest;                                           \
 }
 
-- 
2.11.0


^ permalink raw reply	[flat|nested] 46+ messages in thread

* [dpdk-dev] [PATCH 19.11 V2 02/12] ethdev: fix description of tx descriptor status
  2019-08-07 14:37 [dpdk-dev] [PATCH 19.11 00/12] Miscellaneous fixes Thierry Herbelot
                   ` (13 preceding siblings ...)
  2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 01/12] net/ixgbevf: fix stats update after a PF reset Thierry Herbelot
@ 2019-08-07 15:09 ` Thierry Herbelot
  2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 03/12] net/e1000: fix Tx descriptor status api (igb) Thierry Herbelot
                   ` (9 subsequent siblings)
  24 siblings, 0 replies; 46+ messages in thread
From: Thierry Herbelot @ 2019-08-07 15:09 UTC (permalink / raw)
  To: dev; +Cc: Olivier Matz, stable, Thomas Monjalon

From: Olivier Matz <olivier.matz@6wind.com>

The API comment of rte_eth_tx_descriptor_status() was incorrect. The
reference descriptor (when offset = 0) is not where the next packet
will be sent, but where the latest packet has been enqueued.

Fixes: 52f5cdd2e897 ("ethdev: add descriptor status API")
Cc: stable@dpdk.org

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
 lib/librte_ethdev/rte_ethdev.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h
index dc6596bc93b4..b423e71050e9 100644
--- a/lib/librte_ethdev/rte_ethdev.h
+++ b/lib/librte_ethdev/rte_ethdev.h
@@ -4245,8 +4245,8 @@ rte_eth_rx_descriptor_status(uint16_t port_id, uint16_t queue_id,
  * @param queue_id
  *  A valid Tx queue identifier on this port.
  * @param offset
- *  The offset of the descriptor starting from tail (0 is the place where
- *  the next packet will be send).
+ *  The offset of the descriptor starting from tail (0 is the last written
+ *  descriptor).
  *
  * @return
  *  - (RTE_ETH_TX_DESC_FULL) Descriptor is being processed by the hw, i.e.
-- 
2.11.0


^ permalink raw reply	[flat|nested] 46+ messages in thread

* [dpdk-dev] [PATCH 19.11 V2 03/12] net/e1000: fix Tx descriptor status api (igb)
  2019-08-07 14:37 [dpdk-dev] [PATCH 19.11 00/12] Miscellaneous fixes Thierry Herbelot
                   ` (14 preceding siblings ...)
  2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 02/12] ethdev: fix description of tx descriptor status Thierry Herbelot
@ 2019-08-07 15:09 ` Thierry Herbelot
  2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 04/12] net/e1000: fix Tx descriptor status api (em) Thierry Herbelot
                   ` (8 subsequent siblings)
  24 siblings, 0 replies; 46+ messages in thread
From: Thierry Herbelot @ 2019-08-07 15:09 UTC (permalink / raw)
  To: dev; +Cc: Olivier Matz, stable, Thomas Monjalon

From: Olivier Matz <olivier.matz@6wind.com>

The Tx descriptor status api was not behaving as expected. This API is
used to inspect the content of the descriptors in the Tx ring to
determine the length of the Tx queue.

Since the software advances the tail pointer and the hardware advances
the head pointer, the Tx queue is located before txq->tx_tail in the
ring. Therefore, a call to rte_eth_tx_descriptor_status(..., offset=20)
should inspect the 20th descriptor before the tail, not after.

Fixes: 978f8eea1719 ("net/e1000: implement descriptor status API (igb)")
Cc: stable@dpdk.org

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
 drivers/net/e1000/igb_rxtx.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c
index c5606de5d7a0..c22118e59a21 100644
--- a/drivers/net/e1000/igb_rxtx.c
+++ b/drivers/net/e1000/igb_rxtx.c
@@ -1835,14 +1835,15 @@ eth_igb_tx_descriptor_status(void *tx_queue, uint16_t offset)
 {
 	struct igb_tx_queue *txq = tx_queue;
 	volatile uint32_t *status;
-	uint32_t desc;
+	int32_t desc;
 
 	if (unlikely(offset >= txq->nb_tx_desc))
 		return -EINVAL;
 
-	desc = txq->tx_tail + offset;
-	if (desc >= txq->nb_tx_desc)
-		desc -= txq->nb_tx_desc;
+	desc = txq->tx_tail - offset - 1;
+	if (desc < 0)
+		desc += txq->nb_tx_desc;
+	desc = txq->sw_ring[desc].last_id;
 
 	status = &txq->tx_ring[desc].wb.status;
 	if (*status & rte_cpu_to_le_32(E1000_TXD_STAT_DD))
-- 
2.11.0


^ permalink raw reply	[flat|nested] 46+ messages in thread

* [dpdk-dev] [PATCH 19.11 V2 04/12] net/e1000: fix Tx descriptor status api (em)
  2019-08-07 14:37 [dpdk-dev] [PATCH 19.11 00/12] Miscellaneous fixes Thierry Herbelot
                   ` (15 preceding siblings ...)
  2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 03/12] net/e1000: fix Tx descriptor status api (igb) Thierry Herbelot
@ 2019-08-07 15:09 ` Thierry Herbelot
  2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 05/12] net/ixgbe: fix Tx descriptor status api Thierry Herbelot
                   ` (7 subsequent siblings)
  24 siblings, 0 replies; 46+ messages in thread
From: Thierry Herbelot @ 2019-08-07 15:09 UTC (permalink / raw)
  To: dev; +Cc: Olivier Matz, stable, Thomas Monjalon

From: Olivier Matz <olivier.matz@6wind.com>

The Tx descriptor status api was not behaving as expected. This API is
used to inspect the content of the descriptors in the Tx ring to
determine the length of the Tx queue.

Since the software advances the tail pointer and the hardware advances
the head pointer, the Tx queue is located before txq->tx_tail in the
ring. Therefore, a call to rte_eth_tx_descriptor_status(..., offset=20)
should inspect the 20th descriptor before the tail, not after.

As before, we still need to take care about only checking descriptors
that have the RS bit.

Additionally, we can avoid an access to the ring if offset is greater or
equal to nb_tx_desc - nb_tx_free.

Fixes: b9082317cab3 ("net/e1000: implement descriptor status API (em)")
Cc: stable@dpdk.org

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
 drivers/net/e1000/em_rxtx.c | 33 +++++++++++++++++++++++----------
 1 file changed, 23 insertions(+), 10 deletions(-)

diff --git a/drivers/net/e1000/em_rxtx.c b/drivers/net/e1000/em_rxtx.c
index 5925e490641b..3061998c7768 100644
--- a/drivers/net/e1000/em_rxtx.c
+++ b/drivers/net/e1000/em_rxtx.c
@@ -152,6 +152,7 @@ struct em_tx_queue {
 	uint64_t               tx_ring_phys_addr; /**< TX ring DMA address. */
 	struct em_tx_entry    *sw_ring; /**< virtual address of SW ring. */
 	volatile uint32_t      *tdt_reg_addr; /**< Address of TDT register. */
+	volatile uint32_t      *tdh_reg_addr; /**< Address of TDH register. */
 	uint16_t               nb_tx_desc;    /**< number of TX descriptors. */
 	uint16_t               tx_tail;  /**< Current value of TDT register. */
 	/**< Start freeing TX buffers if there are less free descriptors than
@@ -1304,6 +1305,7 @@ eth_em_tx_queue_setup(struct rte_eth_dev *dev,
 	txq->port_id = dev->data->port_id;
 
 	txq->tdt_reg_addr = E1000_PCI_REG_ADDR(hw, E1000_TDT(queue_idx));
+	txq->tdh_reg_addr = E1000_PCI_REG_ADDR(hw, E1000_TDH(queue_idx));
 	txq->tx_ring_phys_addr = tz->iova;
 	txq->tx_ring = (struct e1000_data_desc *) tz->addr;
 
@@ -1557,22 +1559,33 @@ eth_em_tx_descriptor_status(void *tx_queue, uint16_t offset)
 {
 	struct em_tx_queue *txq = tx_queue;
 	volatile uint8_t *status;
-	uint32_t desc;
+	int32_t desc, dd;
 
 	if (unlikely(offset >= txq->nb_tx_desc))
 		return -EINVAL;
+	if (offset >= txq->nb_tx_desc - txq->nb_tx_free)
+		return RTE_ETH_TX_DESC_DONE;
 
-	desc = txq->tx_tail + offset;
-	/* go to next desc that has the RS bit */
-	desc = ((desc + txq->tx_rs_thresh - 1) / txq->tx_rs_thresh) *
-		txq->tx_rs_thresh;
-	if (desc >= txq->nb_tx_desc) {
-		desc -= txq->nb_tx_desc;
-		if (desc >= txq->nb_tx_desc)
-			desc -= txq->nb_tx_desc;
+	desc = txq->tx_tail - offset - 1;
+	if (desc < 0)
+		desc += txq->nb_tx_desc;
+
+	/* offset is too small, no other way than reading PCI reg */
+	if (unlikely(offset < txq->tx_rs_thresh)) {
+		int16_t tx_head, queue_size;
+		tx_head = e1000_read_addr(txq->tdh_reg_addr);
+		queue_size = txq->tx_tail - tx_head;
+		if (queue_size < 0)
+			queue_size += txq->nb_tx_desc;
+		return queue_size > offset ? RTE_ETH_TX_DESC_FULL :
+			RTE_ETH_TX_DESC_DONE;
 	}
 
-	status = &txq->tx_ring[desc].upper.fields.status;
+	/* index of the dd bit to look at */
+	dd = (desc / txq->tx_rs_thresh + 1) * txq->tx_rs_thresh - 1;
+	dd = txq->sw_ring[dd].last_id;
+
+	status = &txq->tx_ring[dd].upper.fields.status;
 	if (*status & E1000_TXD_STAT_DD)
 		return RTE_ETH_TX_DESC_DONE;
 
-- 
2.11.0


^ permalink raw reply	[flat|nested] 46+ messages in thread

* [dpdk-dev] [PATCH 19.11 V2 05/12] net/ixgbe: fix Tx descriptor status api
  2019-08-07 14:37 [dpdk-dev] [PATCH 19.11 00/12] Miscellaneous fixes Thierry Herbelot
                   ` (16 preceding siblings ...)
  2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 04/12] net/e1000: fix Tx descriptor status api (em) Thierry Herbelot
@ 2019-08-07 15:09 ` Thierry Herbelot
  2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 06/12] net/i40e: " Thierry Herbelot
                   ` (6 subsequent siblings)
  24 siblings, 0 replies; 46+ messages in thread
From: Thierry Herbelot @ 2019-08-07 15:09 UTC (permalink / raw)
  To: dev; +Cc: Olivier Matz, stable, Thomas Monjalon

From: Olivier Matz <olivier.matz@6wind.com>

The Tx descriptor status api was not behaving as expected. This API is
used to inspect the content of the descriptors in the Tx ring to
determine the length of the Tx queue.

Since the software advances the tail pointer and the hardware advances
the head pointer, the Tx queue is located before txq->tx_tail in the
ring. Therefore, a call to rte_eth_tx_descriptor_status(..., offset=20)
should inspect the 20th descriptor before the tail, not after.

As before, we still need to take care about only checking descriptors
that have the RS bit.

Additionally, we can avoid an access to the ring if offset is greater or
equal to nb_tx_desc - nb_tx_free.

Fixes: 5da8b8814178 ("net/ixgbe: implement descriptor status API")
Cc: stable@dpdk.org

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
 drivers/net/ixgbe/ixgbe_rxtx.c | 45 +++++++++++++++++++++++++++++++-----------
 drivers/net/ixgbe/ixgbe_rxtx.h |  1 +
 2 files changed, 34 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c
index edcfa60cec98..4abc2fe37488 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx.c
+++ b/drivers/net/ixgbe/ixgbe_rxtx.c
@@ -2627,10 +2627,15 @@ ixgbe_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	    hw->mac.type == ixgbe_mac_X540_vf ||
 	    hw->mac.type == ixgbe_mac_X550_vf ||
 	    hw->mac.type == ixgbe_mac_X550EM_x_vf ||
-	    hw->mac.type == ixgbe_mac_X550EM_a_vf)
+	    hw->mac.type == ixgbe_mac_X550EM_a_vf) {
 		txq->tdt_reg_addr = IXGBE_PCI_REG_ADDR(hw, IXGBE_VFTDT(queue_idx));
-	else
+		txq->tdh_reg_addr = IXGBE_PCI_REG_ADDR(hw,
+						       IXGBE_VFTDH(queue_idx));
+	} else {
 		txq->tdt_reg_addr = IXGBE_PCI_REG_ADDR(hw, IXGBE_TDT(txq->reg_idx));
+		txq->tdh_reg_addr = IXGBE_PCI_REG_ADDR(hw,
+						       IXGBE_TDH(txq->reg_idx));
+	}
 
 	txq->tx_ring_phys_addr = tz->iova;
 	txq->tx_ring = (union ixgbe_adv_tx_desc *) tz->addr;
@@ -3163,22 +3168,38 @@ ixgbe_dev_tx_descriptor_status(void *tx_queue, uint16_t offset)
 {
 	struct ixgbe_tx_queue *txq = tx_queue;
 	volatile uint32_t *status;
-	uint32_t desc;
+	int32_t desc, dd;
 
 	if (unlikely(offset >= txq->nb_tx_desc))
 		return -EINVAL;
+	if (offset >= txq->nb_tx_desc - txq->nb_tx_free)
+		return RTE_ETH_TX_DESC_DONE;
+
+	desc = txq->tx_tail - offset - 1;
+	if (desc < 0)
+		desc += txq->nb_tx_desc;
 
-	desc = txq->tx_tail + offset;
-	/* go to next desc that has the RS bit */
-	desc = ((desc + txq->tx_rs_thresh - 1) / txq->tx_rs_thresh) *
-		txq->tx_rs_thresh;
-	if (desc >= txq->nb_tx_desc) {
-		desc -= txq->nb_tx_desc;
-		if (desc >= txq->nb_tx_desc)
-			desc -= txq->nb_tx_desc;
+	/* offset is too small, no other way than reading PCI reg */
+	if (unlikely(offset < txq->tx_rs_thresh)) {
+		int16_t tx_head, queue_size;
+		tx_head = ixgbe_read_addr(txq->tdh_reg_addr);
+		queue_size = txq->tx_tail - tx_head;
+		if (queue_size < 0)
+			queue_size += txq->nb_tx_desc;
+		return queue_size > offset ? RTE_ETH_TX_DESC_FULL :
+			RTE_ETH_TX_DESC_DONE;
 	}
 
-	status = &txq->tx_ring[desc].wb.status;
+	/* index of the dd bit to look at */
+	dd = (desc / txq->tx_rs_thresh + 1) * txq->tx_rs_thresh - 1;
+
+	/* In full featured mode, RS bit is only set in the last descriptor */
+	/* of a multisegments packet */
+	if (!(txq->offloads == 0 &&
+	      txq->tx_rs_thresh >= RTE_PMD_IXGBE_TX_MAX_BURST))
+		dd = txq->sw_ring[dd].last_id;
+
+	status = &txq->tx_ring[dd].wb.status;
 	if (*status & rte_cpu_to_le_32(IXGBE_ADVTXD_STAT_DD))
 		return RTE_ETH_TX_DESC_DONE;
 
diff --git a/drivers/net/ixgbe/ixgbe_rxtx.h b/drivers/net/ixgbe/ixgbe_rxtx.h
index 505d344b9cee..05fd4167576c 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx.h
+++ b/drivers/net/ixgbe/ixgbe_rxtx.h
@@ -201,6 +201,7 @@ struct ixgbe_tx_queue {
 		struct ixgbe_tx_entry_v *sw_ring_v; /**< address of SW ring for vector PMD */
 	};
 	volatile uint32_t   *tdt_reg_addr; /**< Address of TDT register. */
+	volatile uint32_t   *tdh_reg_addr; /**< Address of TDH register. */
 	uint16_t            nb_tx_desc;    /**< number of TX descriptors. */
 	uint16_t            tx_tail;       /**< current value of TDT reg. */
 	/**< Start freeing TX buffers if there are less free descriptors than
-- 
2.11.0


^ permalink raw reply	[flat|nested] 46+ messages in thread

* [dpdk-dev] [PATCH 19.11 V2 06/12] net/i40e: fix Tx descriptor status api
  2019-08-07 14:37 [dpdk-dev] [PATCH 19.11 00/12] Miscellaneous fixes Thierry Herbelot
                   ` (17 preceding siblings ...)
  2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 05/12] net/ixgbe: fix Tx descriptor status api Thierry Herbelot
@ 2019-08-07 15:09 ` Thierry Herbelot
  2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 07/12] net/i40e: set speed to undefined for default case in link update Thierry Herbelot
                   ` (5 subsequent siblings)
  24 siblings, 0 replies; 46+ messages in thread
From: Thierry Herbelot @ 2019-08-07 15:09 UTC (permalink / raw)
  To: dev; +Cc: Olivier Matz, stable, Thomas Monjalon

From: Olivier Matz <olivier.matz@6wind.com>

The Tx descriptor status api was not behaving as expected. This API is
used to inspect the content of the descriptors in the Tx ring to
determine the length of the Tx queue.

Since the software advances the tail pointer and the hardware advances
the head pointer, the Tx queue is located before txq->tx_tail in the
ring. Therefore, a call to rte_eth_tx_descriptor_status(..., offset=20)
should inspect the 20th descriptor before the tail, not after.

As before, we still need to take care about only checking descriptors
that have the RS bit.

Additionally, we can avoid an access to the ring if offset is greater or
equal to nb_tx_desc - nb_tx_free.

Fixes: a9dd9af6f38e ("net/i40e: implement descriptor status API")
Cc: stable@dpdk.org

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
 drivers/net/i40e/i40e_rxtx.c | 37 +++++++++++++++++++++++++++----------
 1 file changed, 27 insertions(+), 10 deletions(-)

diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index 692c3bab4b5f..d84a97732f1e 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -2031,22 +2031,39 @@ i40e_dev_tx_descriptor_status(void *tx_queue, uint16_t offset)
 	struct i40e_tx_queue *txq = tx_queue;
 	volatile uint64_t *status;
 	uint64_t mask, expect;
-	uint32_t desc;
+	int32_t desc, dd;
 
 	if (unlikely(offset >= txq->nb_tx_desc))
 		return -EINVAL;
+	if (offset >= txq->nb_tx_desc - txq->nb_tx_free)
+		return RTE_ETH_TX_DESC_DONE;
+
+	desc = txq->tx_tail - offset - 1;
+	if (desc < 0)
+		desc += txq->nb_tx_desc;
 
-	desc = txq->tx_tail + offset;
-	/* go to next desc that has the RS bit */
-	desc = ((desc + txq->tx_rs_thresh - 1) / txq->tx_rs_thresh) *
-		txq->tx_rs_thresh;
-	if (desc >= txq->nb_tx_desc) {
-		desc -= txq->nb_tx_desc;
-		if (desc >= txq->nb_tx_desc)
-			desc -= txq->nb_tx_desc;
+	/* offset is too small, no other way than reading PCI reg */
+	if (unlikely(offset < txq->tx_rs_thresh)) {
+		int16_t tx_head, queue_size;
+		tx_head = I40E_READ_REG(I40E_VSI_TO_HW(txq->vsi),
+					I40E_QTX_HEAD(txq->reg_idx));
+		queue_size = txq->tx_tail - tx_head;
+		if (queue_size < 0)
+			queue_size += txq->nb_tx_desc;
+		return queue_size > offset ? RTE_ETH_TX_DESC_FULL :
+			RTE_ETH_TX_DESC_DONE;
 	}
 
-	status = &txq->tx_ring[desc].cmd_type_offset_bsz;
+	/* index of the dd bit to look at */
+	dd = (desc / txq->tx_rs_thresh + 1) * txq->tx_rs_thresh - 1;
+
+	/* In full featured mode, RS bit is only set in the last descriptor */
+	/* of a multisegments packet */
+	if (!(txq->offloads == 0 &&
+	      txq->tx_rs_thresh >= RTE_PMD_I40E_TX_MAX_BURST))
+		dd = txq->sw_ring[dd].last_id;
+
+	status = &txq->tx_ring[dd].cmd_type_offset_bsz;
 	mask = rte_le_to_cpu_64(I40E_TXD_QW1_DTYPE_MASK);
 	expect = rte_cpu_to_le_64(
 		I40E_TX_DESC_DTYPE_DESC_DONE << I40E_TXD_QW1_DTYPE_SHIFT);
-- 
2.11.0


^ permalink raw reply	[flat|nested] 46+ messages in thread

* [dpdk-dev] [PATCH 19.11 V2 07/12] net/i40e: set speed to undefined for default case in link update
  2019-08-07 14:37 [dpdk-dev] [PATCH 19.11 00/12] Miscellaneous fixes Thierry Herbelot
                   ` (18 preceding siblings ...)
  2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 06/12] net/i40e: " Thierry Herbelot
@ 2019-08-07 15:09 ` Thierry Herbelot
  2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 08/12] virtio: fix rx stats with vectorized functions Thierry Herbelot
                   ` (4 subsequent siblings)
  24 siblings, 0 replies; 46+ messages in thread
From: Thierry Herbelot @ 2019-08-07 15:09 UTC (permalink / raw)
  To: dev; +Cc: Laurent Hardy, stable, Thomas Monjalon

From: Laurent Hardy <laurent.hardy@6wind.com>

During PF/VF link update, a default speed value of 100M will be set
if get_link_info has failed or speed is unknown.

Consequently if PF is put in no-carrier state, VFs will switch to
"in carrier" state due to a link up + a link speed set to 100M
(default value if no speed detected).

To be consistent with linux drivers on which PF and VFs are in
same carrier state, sets default speed to undefined (instead of 100M)
and updates a link status of VF only if link is up and speed is
different from undefined.

Fixes: 4861cde46116 ('i40e: new poll mode driver')
Cc: stable@dpdk.org

Signed-off-by: Laurent Hardy <laurent.hardy@6wind.com>
---
 drivers/net/i40e/i40e_ethdev.c    | 4 ++--
 drivers/net/i40e/i40e_ethdev_vf.c | 8 +++++---
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 4e40b7ab5250..76abe8209a10 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -2743,7 +2743,7 @@ update_link_aq(struct i40e_hw *hw, struct rte_eth_link *link,
 		status = i40e_aq_get_link_info(hw, enable_lse,
 						&link_status, NULL);
 		if (unlikely(status != I40E_SUCCESS)) {
-			link->link_speed = ETH_SPEED_NUM_100M;
+			link->link_speed = ETH_SPEED_NUM_NONE;
 			link->link_duplex = ETH_LINK_FULL_DUPLEX;
 			PMD_DRV_LOG(ERR, "Failed to get link info");
 			return;
@@ -2777,7 +2777,7 @@ update_link_aq(struct i40e_hw *hw, struct rte_eth_link *link,
 		link->link_speed = ETH_SPEED_NUM_40G;
 		break;
 	default:
-		link->link_speed = ETH_SPEED_NUM_100M;
+		link->link_speed = ETH_SPEED_NUM_NONE;
 		break;
 	}
 }
diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index 308fb9835ab1..bf707e57b29b 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -2143,13 +2143,15 @@ i40evf_dev_link_update(struct rte_eth_dev *dev,
 		new_link.link_speed = ETH_SPEED_NUM_40G;
 		break;
 	default:
-		new_link.link_speed = ETH_SPEED_NUM_100M;
+		new_link.link_speed = ETH_SPEED_NUM_NONE;
 		break;
 	}
 	/* full duplex only */
 	new_link.link_duplex = ETH_LINK_FULL_DUPLEX;
-	new_link.link_status = vf->link_up ? ETH_LINK_UP :
-					     ETH_LINK_DOWN;
+	new_link.link_status = vf->link_up &&
+				new_link.link_speed != ETH_SPEED_NUM_NONE
+				? ETH_LINK_UP
+				: ETH_LINK_DOWN;
 	new_link.link_autoneg =
 		!(dev->data->dev_conf.link_speeds & ETH_LINK_SPEED_FIXED);
 
-- 
2.11.0


^ permalink raw reply	[flat|nested] 46+ messages in thread

* [dpdk-dev] [PATCH 19.11 V2 08/12] virtio: fix rx stats with vectorized functions
  2019-08-07 14:37 [dpdk-dev] [PATCH 19.11 00/12] Miscellaneous fixes Thierry Herbelot
                   ` (19 preceding siblings ...)
  2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 07/12] net/i40e: set speed to undefined for default case in link update Thierry Herbelot
@ 2019-08-07 15:09 ` Thierry Herbelot
  2019-08-08  5:15   ` [dpdk-dev] [dpdk-stable] " Tiwei Bie
  2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 09/12] virtio: get all pending rx packets " Thierry Herbelot
                   ` (3 subsequent siblings)
  24 siblings, 1 reply; 46+ messages in thread
From: Thierry Herbelot @ 2019-08-07 15:09 UTC (permalink / raw)
  To: dev; +Cc: Thibaut Collet, stable, Thomas Monjalon

From: Thibaut Collet <thibaut.collet@6wind.com>

With vectorized functions, only the rx stats for number of packets is
incremented.
Update also the other statistics.
Performance impact is about 2%

Fixes: fc3d66212fed ("virtio: add vector Rx")
Cc: stable@dpdk.org

Signed-off-by: Thibaut Collet <thibaut.collet@6wind.com>
---
 drivers/net/virtio/virtio_rxtx.c             | 2 +-
 drivers/net/virtio/virtio_rxtx.h             | 2 ++
 drivers/net/virtio/virtio_rxtx_simple_neon.c | 6 ++++++
 drivers/net/virtio/virtio_rxtx_simple_sse.c  | 6 ++++++
 4 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c
index 27ead19fbe81..6dd62bf51863 100644
--- a/drivers/net/virtio/virtio_rxtx.c
+++ b/drivers/net/virtio/virtio_rxtx.c
@@ -1083,7 +1083,7 @@ virtio_discard_rxbuf_inorder(struct virtqueue *vq, struct rte_mbuf *m)
 	}
 }
 
-static inline void
+void
 virtio_update_packet_stats(struct virtnet_stats *stats, struct rte_mbuf *mbuf)
 {
 	uint32_t s = mbuf->pkt_len;
diff --git a/drivers/net/virtio/virtio_rxtx.h b/drivers/net/virtio/virtio_rxtx.h
index 685cc4f8104c..1eb8dae227ee 100644
--- a/drivers/net/virtio/virtio_rxtx.h
+++ b/drivers/net/virtio/virtio_rxtx.h
@@ -59,5 +59,7 @@ struct virtnet_ctl {
 };
 
 int virtio_rxq_vec_setup(struct virtnet_rx *rxvq);
+void virtio_update_packet_stats(struct virtnet_stats *stats,
+				struct rte_mbuf *mbuf);
 
 #endif /* _VIRTIO_RXTX_H_ */
diff --git a/drivers/net/virtio/virtio_rxtx_simple_neon.c b/drivers/net/virtio/virtio_rxtx_simple_neon.c
index cdc2a4d28ed5..e4b18cba0ce5 100644
--- a/drivers/net/virtio/virtio_rxtx_simple_neon.c
+++ b/drivers/net/virtio/virtio_rxtx_simple_neon.c
@@ -47,6 +47,7 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 	struct vring_used_elem *rused;
 	struct rte_mbuf **sw_ring;
 	struct rte_mbuf **sw_ring_end;
+	struct rte_mbuf **ref_rx_pkts;
 	uint16_t nb_pkts_received = 0;
 
 	uint8x16_t shuf_msk1 = {
@@ -105,6 +106,7 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 			virtqueue_notify(vq);
 	}
 
+	ref_rx_pkts = rx_pkts;
 	for (nb_pkts_received = 0;
 		nb_pkts_received < nb_used;) {
 		uint64x2_t desc[RTE_VIRTIO_DESC_PER_LOOP / 2];
@@ -204,5 +206,9 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 	vq->vq_used_cons_idx += nb_pkts_received;
 	vq->vq_free_cnt += nb_pkts_received;
 	rxvq->stats.packets += nb_pkts_received;
+	for (nb_used = 0; nb_used < nb_pkts_received; nb_used++) {
+		rxvq->stats.bytes += ref_rx_pkts[nb_used]->pkt_len;
+		virtio_update_packet_stats(&rxvq->stats, ref_rx_pkts[nb_used]);
+	}
 	return nb_pkts_received;
 }
diff --git a/drivers/net/virtio/virtio_rxtx_simple_sse.c b/drivers/net/virtio/virtio_rxtx_simple_sse.c
index af76708d66ae..c757e8c9d601 100644
--- a/drivers/net/virtio/virtio_rxtx_simple_sse.c
+++ b/drivers/net/virtio/virtio_rxtx_simple_sse.c
@@ -48,6 +48,7 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 	struct vring_used_elem *rused;
 	struct rte_mbuf **sw_ring;
 	struct rte_mbuf **sw_ring_end;
+	struct rte_mbuf **ref_rx_pkts;
 	uint16_t nb_pkts_received = 0;
 	__m128i shuf_msk1, shuf_msk2, len_adjust;
 
@@ -107,6 +108,7 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 			virtqueue_notify(vq);
 	}
 
+	ref_rx_pkts = rx_pkts;
 	for (nb_pkts_received = 0;
 		nb_pkts_received < nb_used;) {
 		__m128i desc[RTE_VIRTIO_DESC_PER_LOOP / 2];
@@ -190,5 +192,9 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 	vq->vq_used_cons_idx += nb_pkts_received;
 	vq->vq_free_cnt += nb_pkts_received;
 	rxvq->stats.packets += nb_pkts_received;
+	for (nb_used = 0; nb_used < nb_pkts_received; nb_used++) {
+		rxvq->stats.bytes += ref_rx_pkts[nb_used]->pkt_len;
+		virtio_update_packet_stats(&rxvq->stats, ref_rx_pkts[nb_used]);
+	}
 	return nb_pkts_received;
 }
-- 
2.11.0


^ permalink raw reply	[flat|nested] 46+ messages in thread

* [dpdk-dev] [PATCH 19.11 V2 09/12] virtio: get all pending rx packets with vectorized functions
  2019-08-07 14:37 [dpdk-dev] [PATCH 19.11 00/12] Miscellaneous fixes Thierry Herbelot
                   ` (20 preceding siblings ...)
  2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 08/12] virtio: fix rx stats with vectorized functions Thierry Herbelot
@ 2019-08-07 15:09 ` Thierry Herbelot
  2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 10/12] drivers/crypto/openssl: use a local copy for the session contexts Thierry Herbelot
                   ` (2 subsequent siblings)
  24 siblings, 0 replies; 46+ messages in thread
From: Thierry Herbelot @ 2019-08-07 15:09 UTC (permalink / raw)
  To: dev; +Cc: Thibaut Collet, stable, Thomas Monjalon

From: Thibaut Collet <thibaut.collet@6wind.com>

The loop to read packets does not take all packets as the number of
available packets (nb_used) is decremented in the loop.
Take all available packets provides a performance improvement of 3%.

Fixes: fc3d66212fed ("virtio: add vector Rx")
Cc: stable@dpdk.org

Signed-off-by: Thibaut Collet <thibaut.collet@6wind.com>
---
 drivers/net/virtio/virtio_rxtx_simple_neon.c | 5 +++--
 drivers/net/virtio/virtio_rxtx_simple_sse.c  | 5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/virtio/virtio_rxtx_simple_neon.c b/drivers/net/virtio/virtio_rxtx_simple_neon.c
index e4b18cba0ce5..66bdaa00e01f 100644
--- a/drivers/net/virtio/virtio_rxtx_simple_neon.c
+++ b/drivers/net/virtio/virtio_rxtx_simple_neon.c
@@ -42,7 +42,7 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 	struct virtnet_rx *rxvq = rx_queue;
 	struct virtqueue *vq = rxvq->vq;
 	struct virtio_hw *hw = vq->hw;
-	uint16_t nb_used;
+	uint16_t nb_used, nb_total;
 	uint16_t desc_idx;
 	struct vring_used_elem *rused;
 	struct rte_mbuf **sw_ring;
@@ -106,9 +106,10 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 			virtqueue_notify(vq);
 	}
 
+	nb_total = nb_used;
 	ref_rx_pkts = rx_pkts;
 	for (nb_pkts_received = 0;
-		nb_pkts_received < nb_used;) {
+		nb_pkts_received < nb_total;) {
 		uint64x2_t desc[RTE_VIRTIO_DESC_PER_LOOP / 2];
 		uint64x2_t mbp[RTE_VIRTIO_DESC_PER_LOOP / 2];
 		uint64x2_t pkt_mb[RTE_VIRTIO_DESC_PER_LOOP];
diff --git a/drivers/net/virtio/virtio_rxtx_simple_sse.c b/drivers/net/virtio/virtio_rxtx_simple_sse.c
index c757e8c9d601..811b416755e7 100644
--- a/drivers/net/virtio/virtio_rxtx_simple_sse.c
+++ b/drivers/net/virtio/virtio_rxtx_simple_sse.c
@@ -43,7 +43,7 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 	struct virtnet_rx *rxvq = rx_queue;
 	struct virtqueue *vq = rxvq->vq;
 	struct virtio_hw *hw = vq->hw;
-	uint16_t nb_used;
+	uint16_t nb_used, nb_total;
 	uint16_t desc_idx;
 	struct vring_used_elem *rused;
 	struct rte_mbuf **sw_ring;
@@ -108,9 +108,10 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 			virtqueue_notify(vq);
 	}
 
+	nb_total = nb_used;
 	ref_rx_pkts = rx_pkts;
 	for (nb_pkts_received = 0;
-		nb_pkts_received < nb_used;) {
+		nb_pkts_received < nb_total;) {
 		__m128i desc[RTE_VIRTIO_DESC_PER_LOOP / 2];
 		__m128i mbp[RTE_VIRTIO_DESC_PER_LOOP / 2];
 		__m128i pkt_mb[RTE_VIRTIO_DESC_PER_LOOP];
-- 
2.11.0


^ permalink raw reply	[flat|nested] 46+ messages in thread

* [dpdk-dev] [PATCH 19.11 V2 10/12] drivers/crypto/openssl: use a local copy for the session contexts
  2019-08-07 14:37 [dpdk-dev] [PATCH 19.11 00/12] Miscellaneous fixes Thierry Herbelot
                   ` (21 preceding siblings ...)
  2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 09/12] virtio: get all pending rx packets " Thierry Herbelot
@ 2019-08-07 15:09 ` Thierry Herbelot
  2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 11/12] drivers/crypto/dpaa_sec: update DPAA iova table in dpaa_mem_vtop Thierry Herbelot
  2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 12/12] drivers/crypto/octeontx: enable unbinding for the OcteonTx crypto engines Thierry Herbelot
  24 siblings, 0 replies; 46+ messages in thread
From: Thierry Herbelot @ 2019-08-07 15:09 UTC (permalink / raw)
  To: dev; +Cc: stable, Thomas Monjalon

Session contexts are used for temporary storage when processing a
packet.
If packets for the same session are to be processed simultaneously on
multiple cores, separate contexts must be used.

Note: with openssl 1.1.1 EVP_CIPHER_CTX can no longer be defined as a
variable on the stack: it must be allocated. This in turn reduces the
performance.

Fixes: d61f70b4c918 ('crypto/libcrypto: add driver for OpenSSL library')
Cc: stable@dpdk.org

Signed-off-by: Thierry Herbelot <thierry.herbelot@6wind.com>
---
 drivers/crypto/openssl/rte_openssl_pmd.c | 34 +++++++++++++++++++++++---------
 1 file changed, 25 insertions(+), 9 deletions(-)

diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c b/drivers/crypto/openssl/rte_openssl_pmd.c
index 2f5552840741..ce2d12347737 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd.c
@@ -1290,6 +1290,7 @@ process_openssl_combined_op
 	int srclen, aadlen, status = -1;
 	uint32_t offset;
 	uint8_t taglen;
+	EVP_CIPHER_CTX *ctx_copy;
 
 	/*
 	 * Segmented destination buffer is not supported for
@@ -1326,6 +1327,8 @@ process_openssl_combined_op
 	}
 
 	taglen = sess->auth.digest_length;
+	ctx_copy = EVP_CIPHER_CTX_new();
+	EVP_CIPHER_CTX_copy(ctx_copy, sess->cipher.ctx);
 
 	if (sess->cipher.direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
 		if (sess->auth.algo == RTE_CRYPTO_AUTH_AES_GMAC ||
@@ -1333,12 +1336,12 @@ process_openssl_combined_op
 			status = process_openssl_auth_encryption_gcm(
 					mbuf_src, offset, srclen,
 					aad, aadlen, iv,
-					dst, tag, sess->cipher.ctx);
+					dst, tag, ctx_copy);
 		else
 			status = process_openssl_auth_encryption_ccm(
 					mbuf_src, offset, srclen,
 					aad, aadlen, iv,
-					dst, tag, taglen, sess->cipher.ctx);
+					dst, tag, taglen, ctx_copy);
 
 	} else {
 		if (sess->auth.algo == RTE_CRYPTO_AUTH_AES_GMAC ||
@@ -1346,14 +1349,15 @@ process_openssl_combined_op
 			status = process_openssl_auth_decryption_gcm(
 					mbuf_src, offset, srclen,
 					aad, aadlen, iv,
-					dst, tag, sess->cipher.ctx);
+					dst, tag, ctx_copy);
 		else
 			status = process_openssl_auth_decryption_ccm(
 					mbuf_src, offset, srclen,
 					aad, aadlen, iv,
-					dst, tag, taglen, sess->cipher.ctx);
+					dst, tag, taglen, ctx_copy);
 	}
 
+	EVP_CIPHER_CTX_free(ctx_copy);
 	if (status != 0) {
 		if (status == (-EFAULT) &&
 				sess->auth.operation ==
@@ -1372,6 +1376,7 @@ process_openssl_cipher_op
 {
 	uint8_t *dst, *iv;
 	int srclen, status;
+	EVP_CIPHER_CTX *ctx_copy;
 
 	/*
 	 * Segmented destination buffer is not supported for
@@ -1388,22 +1393,25 @@ process_openssl_cipher_op
 
 	iv = rte_crypto_op_ctod_offset(op, uint8_t *,
 			sess->iv.offset);
+	ctx_copy = EVP_CIPHER_CTX_new();
+	EVP_CIPHER_CTX_copy(ctx_copy, sess->cipher.ctx);
 
 	if (sess->cipher.mode == OPENSSL_CIPHER_LIB)
 		if (sess->cipher.direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT)
 			status = process_openssl_cipher_encrypt(mbuf_src, dst,
 					op->sym->cipher.data.offset, iv,
-					srclen, sess->cipher.ctx);
+					srclen, ctx_copy);
 		else
 			status = process_openssl_cipher_decrypt(mbuf_src, dst,
 					op->sym->cipher.data.offset, iv,
-					srclen, sess->cipher.ctx);
+					srclen, ctx_copy);
 	else
 		status = process_openssl_cipher_des3ctr(mbuf_src, dst,
 				op->sym->cipher.data.offset, iv,
 				sess->cipher.key.data, srclen,
-				sess->cipher.ctx);
+				ctx_copy);
 
+	EVP_CIPHER_CTX_free(ctx_copy);
 	if (status != 0)
 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
 }
@@ -1507,6 +1515,8 @@ process_openssl_auth_op(struct openssl_qp *qp, struct rte_crypto_op *op,
 {
 	uint8_t *dst;
 	int srclen, status;
+	EVP_MD_CTX *ctx_a;
+	HMAC_CTX *ctx_h;
 
 	srclen = op->sym->auth.data.length;
 
@@ -1514,14 +1524,20 @@ process_openssl_auth_op(struct openssl_qp *qp, struct rte_crypto_op *op,
 
 	switch (sess->auth.mode) {
 	case OPENSSL_AUTH_AS_AUTH:
+		ctx_a = EVP_MD_CTX_create();
+		EVP_MD_CTX_copy_ex(ctx_a, sess->auth.auth.ctx);
 		status = process_openssl_auth(mbuf_src, dst,
 				op->sym->auth.data.offset, NULL, NULL, srclen,
-				sess->auth.auth.ctx, sess->auth.auth.evp_algo);
+				ctx_a, sess->auth.auth.evp_algo);
+		EVP_MD_CTX_destroy(ctx_a);
 		break;
 	case OPENSSL_AUTH_AS_HMAC:
+		ctx_h = HMAC_CTX_new();
+		HMAC_CTX_copy(ctx_h, sess->auth.hmac.ctx);
 		status = process_openssl_auth_hmac(mbuf_src, dst,
 				op->sym->auth.data.offset, srclen,
-				sess->auth.hmac.ctx);
+				ctx_h);
+		HMAC_CTX_free(ctx_h);
 		break;
 	default:
 		status = -1;
-- 
2.11.0


^ permalink raw reply	[flat|nested] 46+ messages in thread

* [dpdk-dev] [PATCH 19.11 V2 11/12] drivers/crypto/dpaa_sec: update DPAA iova table in dpaa_mem_vtop
  2019-08-07 14:37 [dpdk-dev] [PATCH 19.11 00/12] Miscellaneous fixes Thierry Herbelot
                   ` (22 preceding siblings ...)
  2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 10/12] drivers/crypto/openssl: use a local copy for the session contexts Thierry Herbelot
@ 2019-08-07 15:09 ` Thierry Herbelot
  2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 12/12] drivers/crypto/octeontx: enable unbinding for the OcteonTx crypto engines Thierry Herbelot
  24 siblings, 0 replies; 46+ messages in thread
From: Thierry Herbelot @ 2019-08-07 15:09 UTC (permalink / raw)
  To: dev; +Cc: stable, Thomas Monjalon

dpaa_sec needs translations between physical and virtual addresses.
V to P translation is relatively fast, as memory is managed in
contiguous segments.

The result of each V to P translation is used to update the DPAA iova
table, which should be updated by a Mem event callback, but is not.
Then the DPAA iova table has entries for all needed memory ranges.

With this patch, dpaa_mem_ptov will always use dpaax_iova_table_get_va,
which ensures optimal performance.

Fixes: 5a7dbb934d75 ('dpaa: enable dpaax library')
Cc: stable@dpdk.org

Signed-off-by: Thierry Herbelot <thierry.herbelot@6wind.com>
---
 drivers/crypto/dpaa_sec/dpaa_sec.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c
index 122c80a072ff..22b8b1d63ce0 100644
--- a/drivers/crypto/dpaa_sec/dpaa_sec.c
+++ b/drivers/crypto/dpaa_sec/dpaa_sec.c
@@ -38,6 +38,7 @@
 #include <rte_dpaa_bus.h>
 #include <dpaa_sec.h>
 #include <dpaa_sec_log.h>
+#include <dpaax_iova_table.h>
 
 enum rta_sec_era rta_sec_era;
 
@@ -100,8 +101,10 @@ dpaa_mem_vtop(void *vaddr)
 	const struct rte_memseg *ms;
 
 	ms = rte_mem_virt2memseg(vaddr, NULL);
-	if (ms)
+	if (ms) {
+		dpaax_iova_table_update(ms->iova, (void *)ms->addr_64, ms->len);
 		return ms->iova + RTE_PTR_DIFF(vaddr, ms->addr);
+	}
 	return (size_t)NULL;
 }
 
-- 
2.11.0


^ permalink raw reply	[flat|nested] 46+ messages in thread

* [dpdk-dev] [PATCH 19.11 V2 12/12] drivers/crypto/octeontx: enable unbinding for the OcteonTx crypto engines
  2019-08-07 14:37 [dpdk-dev] [PATCH 19.11 00/12] Miscellaneous fixes Thierry Herbelot
                   ` (23 preceding siblings ...)
  2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 11/12] drivers/crypto/dpaa_sec: update DPAA iova table in dpaa_mem_vtop Thierry Herbelot
@ 2019-08-07 15:09 ` Thierry Herbelot
  24 siblings, 0 replies; 46+ messages in thread
From: Thierry Herbelot @ 2019-08-07 15:09 UTC (permalink / raw)
  To: dev; +Cc: stable, Thomas Monjalon

Like for Ethernet ports, the OcteonTx crypto engines must first be unbound
from their kernel module, then rebound to vfio-pci, before being usable
in DPDK.

As this capability is detected at runtime by dpdk-pmdinfo, add the info
in the PMD registering directives.

Then an external script can be used for bind and unbind.

Fixes: bfe2ae495ee268 ('crypto/octeontx: add PMD skeleton')
Cc: stable@dpdk.org

Signed-off-by: Thierry Herbelot <thierry.herbelot@6wind.com>
---
 drivers/crypto/octeontx/otx_cryptodev.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/crypto/octeontx/otx_cryptodev.c b/drivers/crypto/octeontx/otx_cryptodev.c
index fc64a5f3041f..16f1909966d0 100644
--- a/drivers/crypto/octeontx/otx_cryptodev.c
+++ b/drivers/crypto/octeontx/otx_cryptodev.c
@@ -118,6 +118,7 @@ static struct cryptodev_driver otx_cryptodev_drv;
 
 RTE_PMD_REGISTER_PCI(CRYPTODEV_NAME_OCTEONTX_PMD, otx_cryptodev_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(CRYPTODEV_NAME_OCTEONTX_PMD, pci_id_cpt_table);
+RTE_PMD_REGISTER_KMOD_DEP(CRYPTODEV_NAME_OCTEONTX_PMD, "* igb_uio | uio_pci_generic | vfio-pci");
 RTE_PMD_REGISTER_CRYPTO_DRIVER(otx_cryptodev_drv, otx_cryptodev_pmd.driver,
 		otx_cryptodev_driver_id);
 
-- 
2.11.0


^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: [dpdk-dev] [dpdk-stable] [PATCH 19.11 V2 08/12] virtio: fix rx stats with vectorized functions
  2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 08/12] virtio: fix rx stats with vectorized functions Thierry Herbelot
@ 2019-08-08  5:15   ` Tiwei Bie
  2019-08-08  7:35     ` Thibaut Collet
  0 siblings, 1 reply; 46+ messages in thread
From: Tiwei Bie @ 2019-08-08  5:15 UTC (permalink / raw)
  To: Thierry Herbelot; +Cc: dev, Thibaut Collet, stable, Thomas Monjalon

On Wed, Aug 07, 2019 at 05:09:17PM +0200, Thierry Herbelot wrote:
> From: Thibaut Collet <thibaut.collet@6wind.com>
> 
> With vectorized functions, only the rx stats for number of packets is
> incremented.
> Update also the other statistics.
> Performance impact is about 2%

Could you share some details about your performance test?


> diff --git a/drivers/net/virtio/virtio_rxtx_simple_sse.c b/drivers/net/virtio/virtio_rxtx_simple_sse.c
> index af76708d66ae..c757e8c9d601 100644
> --- a/drivers/net/virtio/virtio_rxtx_simple_sse.c
> +++ b/drivers/net/virtio/virtio_rxtx_simple_sse.c
> @@ -48,6 +48,7 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
>  	struct vring_used_elem *rused;
>  	struct rte_mbuf **sw_ring;
>  	struct rte_mbuf **sw_ring_end;
> +	struct rte_mbuf **ref_rx_pkts;
>  	uint16_t nb_pkts_received = 0;
>  	__m128i shuf_msk1, shuf_msk2, len_adjust;
>  
> @@ -107,6 +108,7 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
>  			virtqueue_notify(vq);
>  	}
>  
> +	ref_rx_pkts = rx_pkts;
>  	for (nb_pkts_received = 0;
>  		nb_pkts_received < nb_used;) {
>  		__m128i desc[RTE_VIRTIO_DESC_PER_LOOP / 2];
> @@ -190,5 +192,9 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
>  	vq->vq_used_cons_idx += nb_pkts_received;
>  	vq->vq_free_cnt += nb_pkts_received;
>  	rxvq->stats.packets += nb_pkts_received;
> +	for (nb_used = 0; nb_used < nb_pkts_received; nb_used++) {
> +		rxvq->stats.bytes += ref_rx_pkts[nb_used]->pkt_len;
> +		virtio_update_packet_stats(&rxvq->stats, ref_rx_pkts[nb_used]);

The stats.bytes was updated twice by above code.

> +	}
>  	return nb_pkts_received;
>  }
> -- 
> 2.11.0
> 

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: [dpdk-dev] [dpdk-stable] [PATCH 19.11 V2 08/12] virtio: fix rx stats with vectorized functions
  2019-08-08  5:15   ` [dpdk-dev] [dpdk-stable] " Tiwei Bie
@ 2019-08-08  7:35     ` Thibaut Collet
  0 siblings, 0 replies; 46+ messages in thread
From: Thibaut Collet @ 2019-08-08  7:35 UTC (permalink / raw)
  To: Tiwei Bie; +Cc: Thierry Herbelot, dev, stable, Thomas Monjalon

On Thu, Aug 8, 2019 at 7:17 AM Tiwei Bie <tiwei.bie@intel.com> wrote:
>
> On Wed, Aug 07, 2019 at 05:09:17PM +0200, Thierry Herbelot wrote:
> > From: Thibaut Collet <thibaut.collet@6wind.com>
> >
> > With vectorized functions, only the rx stats for number of packets is
> > incremented.
> > Update also the other statistics.
> > Performance impact is about 2%
>
> Could you share some details about your performance test?

The test has been done with a 6wind application based on dpdk and I
have not keep details. With test pmd impact is maybe a little bit
higher.

>
>
> > diff --git a/drivers/net/virtio/virtio_rxtx_simple_sse.c b/drivers/net/virtio/virtio_rxtx_simple_sse.c
> > index af76708d66ae..c757e8c9d601 100644
> > --- a/drivers/net/virtio/virtio_rxtx_simple_sse.c
> > +++ b/drivers/net/virtio/virtio_rxtx_simple_sse.c
> > @@ -48,6 +48,7 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
> >       struct vring_used_elem *rused;
> >       struct rte_mbuf **sw_ring;
> >       struct rte_mbuf **sw_ring_end;
> > +     struct rte_mbuf **ref_rx_pkts;
> >       uint16_t nb_pkts_received = 0;
> >       __m128i shuf_msk1, shuf_msk2, len_adjust;
> >
> > @@ -107,6 +108,7 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
> >                       virtqueue_notify(vq);
> >       }
> >
> > +     ref_rx_pkts = rx_pkts;
> >       for (nb_pkts_received = 0;
> >               nb_pkts_received < nb_used;) {
> >               __m128i desc[RTE_VIRTIO_DESC_PER_LOOP / 2];
> > @@ -190,5 +192,9 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
> >       vq->vq_used_cons_idx += nb_pkts_received;
> >       vq->vq_free_cnt += nb_pkts_received;
> >       rxvq->stats.packets += nb_pkts_received;
> > +     for (nb_used = 0; nb_used < nb_pkts_received; nb_used++) {
> > +             rxvq->stats.bytes += ref_rx_pkts[nb_used]->pkt_len;
> > +             virtio_update_packet_stats(&rxvq->stats, ref_rx_pkts[nb_used]);
>
> The stats.bytes was updated twice by above code.

Agree. My correction is an old one, done on the old 18.11 dpdk, and so
done before patch
https://git.dpdk.org/dpdk/commit/drivers/net/virtio/virtio_rxtx.c?id=81e5cdf19e583c742040d3be83b8cc79b451e243.
So the line
 +             rxvq->stats.bytes += ref_rx_pkts[nb_used]->pkt_len;
must be removed to be compliant with Ilya Maximets patch.

>
> > +     }
> >       return nb_pkts_received;
> >  }
> > --
> > 2.11.0
> >

^ permalink raw reply	[flat|nested] 46+ messages in thread

* [dpdk-dev] [PATCH 19.11 V3 00/12] Miscellaneous fixes
  2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 00/12] Miscellaneous fixes Thierry Herbelot
@ 2019-08-08  8:22   ` Thierry Herbelot
  2019-08-08 13:19     ` Thierry Herbelot
  2019-08-08  8:22   ` [dpdk-dev] [PATCH 19.11 V3 01/12] net/ixgbevf: fix stats update after a PF reset Thierry Herbelot
                     ` (11 subsequent siblings)
  12 siblings, 1 reply; 46+ messages in thread
From: Thierry Herbelot @ 2019-08-08  8:22 UTC (permalink / raw)
  To: dev; +Cc: stable, Thomas Monjalon

This series of patches includes fixes for issues seen with
6WIND fast path, built on DPDK.
The patches are in 6WIND version of DPDK, and should have been
upstreamed a long time ago.

V3 changes:
fix double increment of stats in virtio vectorized functions

V2 changes:
fix checkpatch issues


Guo Fengtian (1):
  net/ixgbevf: fix stats update after a PF reset

Laurent Hardy (1):
  net/i40e: set speed to undefined for default case in link update

Olivier Matz (5):
  ethdev: fix description of tx descriptor status
  net/e1000: fix Tx descriptor status api (igb)
  net/e1000: fix Tx descriptor status api (em)
  net/ixgbe: fix Tx descriptor status api
  net/i40e: fix Tx descriptor status api

Thibaut Collet (2):
  virtio: fix rx stats with vectorized functions
  virtio: get all pending rx packets with vectorized functions

Thierry Herbelot (3):
  drivers/crypto/openssl: use a local copy for the session contexts
  drivers/crypto/dpaa_sec: update DPAA iova table in dpaa_mem_vtop
  drivers/crypto/octeontx: enable unbinding for the OcteonTx crypto
    engines

 drivers/crypto/dpaa_sec/dpaa_sec.c           |  5 +++-
 drivers/crypto/octeontx/otx_cryptodev.c      |  1 +
 drivers/crypto/openssl/rte_openssl_pmd.c     | 34 +++++++++++++++------
 drivers/net/e1000/em_rxtx.c                  | 33 +++++++++++++-------
 drivers/net/e1000/igb_rxtx.c                 |  9 +++---
 drivers/net/i40e/i40e_ethdev.c               |  4 +--
 drivers/net/i40e/i40e_ethdev_vf.c            |  8 +++--
 drivers/net/i40e/i40e_rxtx.c                 | 37 ++++++++++++++++-------
 drivers/net/ixgbe/ixgbe_ethdev.c             |  6 ++--
 drivers/net/ixgbe/ixgbe_rxtx.c               | 45 ++++++++++++++++++++--------
 drivers/net/ixgbe/ixgbe_rxtx.h               |  1 +
 drivers/net/virtio/virtio_rxtx.c             |  2 +-
 drivers/net/virtio/virtio_rxtx.h             |  2 ++
 drivers/net/virtio/virtio_rxtx_simple_neon.c | 10 +++++--
 drivers/net/virtio/virtio_rxtx_simple_sse.c  | 10 +++++--
 lib/librte_ethdev/rte_ethdev.h               |  4 +--
 16 files changed, 151 insertions(+), 60 deletions(-)

-- 
2.11.0


^ permalink raw reply	[flat|nested] 46+ messages in thread

* [dpdk-dev] [PATCH 19.11 V3 01/12] net/ixgbevf: fix stats update after a PF reset
  2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 00/12] Miscellaneous fixes Thierry Herbelot
  2019-08-08  8:22   ` [dpdk-dev] [PATCH 19.11 V3 " Thierry Herbelot
@ 2019-08-08  8:22   ` Thierry Herbelot
  2019-08-08  8:22   ` [dpdk-dev] [PATCH 19.11 V3 02/12] ethdev: fix description of tx descriptor status Thierry Herbelot
                     ` (10 subsequent siblings)
  12 siblings, 0 replies; 46+ messages in thread
From: Thierry Herbelot @ 2019-08-08  8:22 UTC (permalink / raw)
  To: dev; +Cc: Guo Fengtian, stable, Thomas Monjalon

From: Guo Fengtian <fengtian.guo@6wind.com>

When PF is set down, in VF, the value of stats register is zero.
So only increase stats when it's non zero.

Fixes: af75078fece3 ('first public release')
Cc: stable@dpdk.org

Signed-off-by: Guo Fengtian <fengtian.guo@6wind.com>
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 03fc1f71799c..57f5bfa219c1 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -385,7 +385,8 @@ static void ixgbe_l2_tunnel_conf(struct rte_eth_dev *dev);
 #define UPDATE_VF_STAT(reg, last, cur)                          \
 {                                                               \
 	uint32_t latest = IXGBE_READ_REG(hw, reg);              \
-	cur += (latest - last) & UINT_MAX;                      \
+	if (latest)                                             \
+		cur += (latest - last) & UINT_MAX;              \
 	last = latest;                                          \
 }
 
@@ -394,7 +395,8 @@ static void ixgbe_l2_tunnel_conf(struct rte_eth_dev *dev);
 	u64 new_lsb = IXGBE_READ_REG(hw, lsb);                   \
 	u64 new_msb = IXGBE_READ_REG(hw, msb);                   \
 	u64 latest = ((new_msb << 32) | new_lsb);                \
-	cur += (0x1000000000LL + latest - last) & 0xFFFFFFFFFLL; \
+	if (latest)                                              \
+		cur += (0x1000000000LL + latest - last) & 0xFFFFFFFFFLL;\
 	last = latest;                                           \
 }
 
-- 
2.11.0


^ permalink raw reply	[flat|nested] 46+ messages in thread

* [dpdk-dev] [PATCH 19.11 V3 02/12] ethdev: fix description of tx descriptor status
  2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 00/12] Miscellaneous fixes Thierry Herbelot
  2019-08-08  8:22   ` [dpdk-dev] [PATCH 19.11 V3 " Thierry Herbelot
  2019-08-08  8:22   ` [dpdk-dev] [PATCH 19.11 V3 01/12] net/ixgbevf: fix stats update after a PF reset Thierry Herbelot
@ 2019-08-08  8:22   ` Thierry Herbelot
  2019-08-08 10:37     ` Andrew Rybchenko
  2019-08-08  8:22   ` [dpdk-dev] [PATCH 19.11 V3 03/12] net/e1000: fix Tx descriptor status api (igb) Thierry Herbelot
                     ` (9 subsequent siblings)
  12 siblings, 1 reply; 46+ messages in thread
From: Thierry Herbelot @ 2019-08-08  8:22 UTC (permalink / raw)
  To: dev; +Cc: Olivier Matz, stable, Thomas Monjalon

From: Olivier Matz <olivier.matz@6wind.com>

The API comment of rte_eth_tx_descriptor_status() was incorrect. The
reference descriptor (when offset = 0) is not where the next packet
will be sent, but where the latest packet has been enqueued.

Fixes: 52f5cdd2e897 ("ethdev: add descriptor status API")
Cc: stable@dpdk.org

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
 lib/librte_ethdev/rte_ethdev.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h
index dc6596bc93b4..b423e71050e9 100644
--- a/lib/librte_ethdev/rte_ethdev.h
+++ b/lib/librte_ethdev/rte_ethdev.h
@@ -4245,8 +4245,8 @@ rte_eth_rx_descriptor_status(uint16_t port_id, uint16_t queue_id,
  * @param queue_id
  *  A valid Tx queue identifier on this port.
  * @param offset
- *  The offset of the descriptor starting from tail (0 is the place where
- *  the next packet will be send).
+ *  The offset of the descriptor starting from tail (0 is the last written
+ *  descriptor).
  *
  * @return
  *  - (RTE_ETH_TX_DESC_FULL) Descriptor is being processed by the hw, i.e.
-- 
2.11.0


^ permalink raw reply	[flat|nested] 46+ messages in thread

* [dpdk-dev] [PATCH 19.11 V3 03/12] net/e1000: fix Tx descriptor status api (igb)
  2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 00/12] Miscellaneous fixes Thierry Herbelot
                     ` (2 preceding siblings ...)
  2019-08-08  8:22   ` [dpdk-dev] [PATCH 19.11 V3 02/12] ethdev: fix description of tx descriptor status Thierry Herbelot
@ 2019-08-08  8:22   ` Thierry Herbelot
  2019-08-08  8:22   ` [dpdk-dev] [PATCH 19.11 V3 04/12] net/e1000: fix Tx descriptor status api (em) Thierry Herbelot
                     ` (8 subsequent siblings)
  12 siblings, 0 replies; 46+ messages in thread
From: Thierry Herbelot @ 2019-08-08  8:22 UTC (permalink / raw)
  To: dev; +Cc: Olivier Matz, stable, Thomas Monjalon

From: Olivier Matz <olivier.matz@6wind.com>

The Tx descriptor status api was not behaving as expected. This API is
used to inspect the content of the descriptors in the Tx ring to
determine the length of the Tx queue.

Since the software advances the tail pointer and the hardware advances
the head pointer, the Tx queue is located before txq->tx_tail in the
ring. Therefore, a call to rte_eth_tx_descriptor_status(..., offset=20)
should inspect the 20th descriptor before the tail, not after.

Fixes: 978f8eea1719 ("net/e1000: implement descriptor status API (igb)")
Cc: stable@dpdk.org

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
 drivers/net/e1000/igb_rxtx.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c
index c5606de5d7a0..c22118e59a21 100644
--- a/drivers/net/e1000/igb_rxtx.c
+++ b/drivers/net/e1000/igb_rxtx.c
@@ -1835,14 +1835,15 @@ eth_igb_tx_descriptor_status(void *tx_queue, uint16_t offset)
 {
 	struct igb_tx_queue *txq = tx_queue;
 	volatile uint32_t *status;
-	uint32_t desc;
+	int32_t desc;
 
 	if (unlikely(offset >= txq->nb_tx_desc))
 		return -EINVAL;
 
-	desc = txq->tx_tail + offset;
-	if (desc >= txq->nb_tx_desc)
-		desc -= txq->nb_tx_desc;
+	desc = txq->tx_tail - offset - 1;
+	if (desc < 0)
+		desc += txq->nb_tx_desc;
+	desc = txq->sw_ring[desc].last_id;
 
 	status = &txq->tx_ring[desc].wb.status;
 	if (*status & rte_cpu_to_le_32(E1000_TXD_STAT_DD))
-- 
2.11.0


^ permalink raw reply	[flat|nested] 46+ messages in thread

* [dpdk-dev] [PATCH 19.11 V3 04/12] net/e1000: fix Tx descriptor status api (em)
  2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 00/12] Miscellaneous fixes Thierry Herbelot
                     ` (3 preceding siblings ...)
  2019-08-08  8:22   ` [dpdk-dev] [PATCH 19.11 V3 03/12] net/e1000: fix Tx descriptor status api (igb) Thierry Herbelot
@ 2019-08-08  8:22   ` Thierry Herbelot
  2019-08-08  8:22   ` [dpdk-dev] [PATCH 19.11 V3 05/12] net/ixgbe: fix Tx descriptor status api Thierry Herbelot
                     ` (7 subsequent siblings)
  12 siblings, 0 replies; 46+ messages in thread
From: Thierry Herbelot @ 2019-08-08  8:22 UTC (permalink / raw)
  To: dev; +Cc: Olivier Matz, stable, Thomas Monjalon

From: Olivier Matz <olivier.matz@6wind.com>

The Tx descriptor status api was not behaving as expected. This API is
used to inspect the content of the descriptors in the Tx ring to
determine the length of the Tx queue.

Since the software advances the tail pointer and the hardware advances
the head pointer, the Tx queue is located before txq->tx_tail in the
ring. Therefore, a call to rte_eth_tx_descriptor_status(..., offset=20)
should inspect the 20th descriptor before the tail, not after.

As before, we still need to take care about only checking descriptors
that have the RS bit.

Additionally, we can avoid an access to the ring if offset is greater or
equal to nb_tx_desc - nb_tx_free.

Fixes: b9082317cab3 ("net/e1000: implement descriptor status API (em)")
Cc: stable@dpdk.org

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
 drivers/net/e1000/em_rxtx.c | 33 +++++++++++++++++++++++----------
 1 file changed, 23 insertions(+), 10 deletions(-)

diff --git a/drivers/net/e1000/em_rxtx.c b/drivers/net/e1000/em_rxtx.c
index 5925e490641b..3061998c7768 100644
--- a/drivers/net/e1000/em_rxtx.c
+++ b/drivers/net/e1000/em_rxtx.c
@@ -152,6 +152,7 @@ struct em_tx_queue {
 	uint64_t               tx_ring_phys_addr; /**< TX ring DMA address. */
 	struct em_tx_entry    *sw_ring; /**< virtual address of SW ring. */
 	volatile uint32_t      *tdt_reg_addr; /**< Address of TDT register. */
+	volatile uint32_t      *tdh_reg_addr; /**< Address of TDH register. */
 	uint16_t               nb_tx_desc;    /**< number of TX descriptors. */
 	uint16_t               tx_tail;  /**< Current value of TDT register. */
 	/**< Start freeing TX buffers if there are less free descriptors than
@@ -1304,6 +1305,7 @@ eth_em_tx_queue_setup(struct rte_eth_dev *dev,
 	txq->port_id = dev->data->port_id;
 
 	txq->tdt_reg_addr = E1000_PCI_REG_ADDR(hw, E1000_TDT(queue_idx));
+	txq->tdh_reg_addr = E1000_PCI_REG_ADDR(hw, E1000_TDH(queue_idx));
 	txq->tx_ring_phys_addr = tz->iova;
 	txq->tx_ring = (struct e1000_data_desc *) tz->addr;
 
@@ -1557,22 +1559,33 @@ eth_em_tx_descriptor_status(void *tx_queue, uint16_t offset)
 {
 	struct em_tx_queue *txq = tx_queue;
 	volatile uint8_t *status;
-	uint32_t desc;
+	int32_t desc, dd;
 
 	if (unlikely(offset >= txq->nb_tx_desc))
 		return -EINVAL;
+	if (offset >= txq->nb_tx_desc - txq->nb_tx_free)
+		return RTE_ETH_TX_DESC_DONE;
 
-	desc = txq->tx_tail + offset;
-	/* go to next desc that has the RS bit */
-	desc = ((desc + txq->tx_rs_thresh - 1) / txq->tx_rs_thresh) *
-		txq->tx_rs_thresh;
-	if (desc >= txq->nb_tx_desc) {
-		desc -= txq->nb_tx_desc;
-		if (desc >= txq->nb_tx_desc)
-			desc -= txq->nb_tx_desc;
+	desc = txq->tx_tail - offset - 1;
+	if (desc < 0)
+		desc += txq->nb_tx_desc;
+
+	/* offset is too small, no other way than reading PCI reg */
+	if (unlikely(offset < txq->tx_rs_thresh)) {
+		int16_t tx_head, queue_size;
+		tx_head = e1000_read_addr(txq->tdh_reg_addr);
+		queue_size = txq->tx_tail - tx_head;
+		if (queue_size < 0)
+			queue_size += txq->nb_tx_desc;
+		return queue_size > offset ? RTE_ETH_TX_DESC_FULL :
+			RTE_ETH_TX_DESC_DONE;
 	}
 
-	status = &txq->tx_ring[desc].upper.fields.status;
+	/* index of the dd bit to look at */
+	dd = (desc / txq->tx_rs_thresh + 1) * txq->tx_rs_thresh - 1;
+	dd = txq->sw_ring[dd].last_id;
+
+	status = &txq->tx_ring[dd].upper.fields.status;
 	if (*status & E1000_TXD_STAT_DD)
 		return RTE_ETH_TX_DESC_DONE;
 
-- 
2.11.0


^ permalink raw reply	[flat|nested] 46+ messages in thread

* [dpdk-dev] [PATCH 19.11 V3 05/12] net/ixgbe: fix Tx descriptor status api
  2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 00/12] Miscellaneous fixes Thierry Herbelot
                     ` (4 preceding siblings ...)
  2019-08-08  8:22   ` [dpdk-dev] [PATCH 19.11 V3 04/12] net/e1000: fix Tx descriptor status api (em) Thierry Herbelot
@ 2019-08-08  8:22   ` Thierry Herbelot
  2019-08-08  8:22   ` [dpdk-dev] [PATCH 19.11 V3 06/12] net/i40e: " Thierry Herbelot
                     ` (6 subsequent siblings)
  12 siblings, 0 replies; 46+ messages in thread
From: Thierry Herbelot @ 2019-08-08  8:22 UTC (permalink / raw)
  To: dev; +Cc: Olivier Matz, stable, Thomas Monjalon

From: Olivier Matz <olivier.matz@6wind.com>

The Tx descriptor status api was not behaving as expected. This API is
used to inspect the content of the descriptors in the Tx ring to
determine the length of the Tx queue.

Since the software advances the tail pointer and the hardware advances
the head pointer, the Tx queue is located before txq->tx_tail in the
ring. Therefore, a call to rte_eth_tx_descriptor_status(..., offset=20)
should inspect the 20th descriptor before the tail, not after.

As before, we still need to take care about only checking descriptors
that have the RS bit.

Additionally, we can avoid an access to the ring if offset is greater or
equal to nb_tx_desc - nb_tx_free.

Fixes: 5da8b8814178 ("net/ixgbe: implement descriptor status API")
Cc: stable@dpdk.org

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
 drivers/net/ixgbe/ixgbe_rxtx.c | 45 +++++++++++++++++++++++++++++++-----------
 drivers/net/ixgbe/ixgbe_rxtx.h |  1 +
 2 files changed, 34 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c
index edcfa60cec98..4abc2fe37488 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx.c
+++ b/drivers/net/ixgbe/ixgbe_rxtx.c
@@ -2627,10 +2627,15 @@ ixgbe_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	    hw->mac.type == ixgbe_mac_X540_vf ||
 	    hw->mac.type == ixgbe_mac_X550_vf ||
 	    hw->mac.type == ixgbe_mac_X550EM_x_vf ||
-	    hw->mac.type == ixgbe_mac_X550EM_a_vf)
+	    hw->mac.type == ixgbe_mac_X550EM_a_vf) {
 		txq->tdt_reg_addr = IXGBE_PCI_REG_ADDR(hw, IXGBE_VFTDT(queue_idx));
-	else
+		txq->tdh_reg_addr = IXGBE_PCI_REG_ADDR(hw,
+						       IXGBE_VFTDH(queue_idx));
+	} else {
 		txq->tdt_reg_addr = IXGBE_PCI_REG_ADDR(hw, IXGBE_TDT(txq->reg_idx));
+		txq->tdh_reg_addr = IXGBE_PCI_REG_ADDR(hw,
+						       IXGBE_TDH(txq->reg_idx));
+	}
 
 	txq->tx_ring_phys_addr = tz->iova;
 	txq->tx_ring = (union ixgbe_adv_tx_desc *) tz->addr;
@@ -3163,22 +3168,38 @@ ixgbe_dev_tx_descriptor_status(void *tx_queue, uint16_t offset)
 {
 	struct ixgbe_tx_queue *txq = tx_queue;
 	volatile uint32_t *status;
-	uint32_t desc;
+	int32_t desc, dd;
 
 	if (unlikely(offset >= txq->nb_tx_desc))
 		return -EINVAL;
+	if (offset >= txq->nb_tx_desc - txq->nb_tx_free)
+		return RTE_ETH_TX_DESC_DONE;
+
+	desc = txq->tx_tail - offset - 1;
+	if (desc < 0)
+		desc += txq->nb_tx_desc;
 
-	desc = txq->tx_tail + offset;
-	/* go to next desc that has the RS bit */
-	desc = ((desc + txq->tx_rs_thresh - 1) / txq->tx_rs_thresh) *
-		txq->tx_rs_thresh;
-	if (desc >= txq->nb_tx_desc) {
-		desc -= txq->nb_tx_desc;
-		if (desc >= txq->nb_tx_desc)
-			desc -= txq->nb_tx_desc;
+	/* offset is too small, no other way than reading PCI reg */
+	if (unlikely(offset < txq->tx_rs_thresh)) {
+		int16_t tx_head, queue_size;
+		tx_head = ixgbe_read_addr(txq->tdh_reg_addr);
+		queue_size = txq->tx_tail - tx_head;
+		if (queue_size < 0)
+			queue_size += txq->nb_tx_desc;
+		return queue_size > offset ? RTE_ETH_TX_DESC_FULL :
+			RTE_ETH_TX_DESC_DONE;
 	}
 
-	status = &txq->tx_ring[desc].wb.status;
+	/* index of the dd bit to look at */
+	dd = (desc / txq->tx_rs_thresh + 1) * txq->tx_rs_thresh - 1;
+
+	/* In full featured mode, RS bit is only set in the last descriptor */
+	/* of a multisegments packet */
+	if (!(txq->offloads == 0 &&
+	      txq->tx_rs_thresh >= RTE_PMD_IXGBE_TX_MAX_BURST))
+		dd = txq->sw_ring[dd].last_id;
+
+	status = &txq->tx_ring[dd].wb.status;
 	if (*status & rte_cpu_to_le_32(IXGBE_ADVTXD_STAT_DD))
 		return RTE_ETH_TX_DESC_DONE;
 
diff --git a/drivers/net/ixgbe/ixgbe_rxtx.h b/drivers/net/ixgbe/ixgbe_rxtx.h
index 505d344b9cee..05fd4167576c 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx.h
+++ b/drivers/net/ixgbe/ixgbe_rxtx.h
@@ -201,6 +201,7 @@ struct ixgbe_tx_queue {
 		struct ixgbe_tx_entry_v *sw_ring_v; /**< address of SW ring for vector PMD */
 	};
 	volatile uint32_t   *tdt_reg_addr; /**< Address of TDT register. */
+	volatile uint32_t   *tdh_reg_addr; /**< Address of TDH register. */
 	uint16_t            nb_tx_desc;    /**< number of TX descriptors. */
 	uint16_t            tx_tail;       /**< current value of TDT reg. */
 	/**< Start freeing TX buffers if there are less free descriptors than
-- 
2.11.0


^ permalink raw reply	[flat|nested] 46+ messages in thread

* [dpdk-dev] [PATCH 19.11 V3 06/12] net/i40e: fix Tx descriptor status api
  2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 00/12] Miscellaneous fixes Thierry Herbelot
                     ` (5 preceding siblings ...)
  2019-08-08  8:22   ` [dpdk-dev] [PATCH 19.11 V3 05/12] net/ixgbe: fix Tx descriptor status api Thierry Herbelot
@ 2019-08-08  8:22   ` Thierry Herbelot
  2019-08-08  8:22   ` [dpdk-dev] [PATCH 19.11 V3 07/12] net/i40e: set speed to undefined for default case in link update Thierry Herbelot
                     ` (5 subsequent siblings)
  12 siblings, 0 replies; 46+ messages in thread
From: Thierry Herbelot @ 2019-08-08  8:22 UTC (permalink / raw)
  To: dev; +Cc: Olivier Matz, stable, Thomas Monjalon

From: Olivier Matz <olivier.matz@6wind.com>

The Tx descriptor status api was not behaving as expected. This API is
used to inspect the content of the descriptors in the Tx ring to
determine the length of the Tx queue.

Since the software advances the tail pointer and the hardware advances
the head pointer, the Tx queue is located before txq->tx_tail in the
ring. Therefore, a call to rte_eth_tx_descriptor_status(..., offset=20)
should inspect the 20th descriptor before the tail, not after.

As before, we still need to take care about only checking descriptors
that have the RS bit.

Additionally, we can avoid an access to the ring if offset is greater or
equal to nb_tx_desc - nb_tx_free.

Fixes: a9dd9af6f38e ("net/i40e: implement descriptor status API")
Cc: stable@dpdk.org

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
 drivers/net/i40e/i40e_rxtx.c | 37 +++++++++++++++++++++++++++----------
 1 file changed, 27 insertions(+), 10 deletions(-)

diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index 692c3bab4b5f..d84a97732f1e 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -2031,22 +2031,39 @@ i40e_dev_tx_descriptor_status(void *tx_queue, uint16_t offset)
 	struct i40e_tx_queue *txq = tx_queue;
 	volatile uint64_t *status;
 	uint64_t mask, expect;
-	uint32_t desc;
+	int32_t desc, dd;
 
 	if (unlikely(offset >= txq->nb_tx_desc))
 		return -EINVAL;
+	if (offset >= txq->nb_tx_desc - txq->nb_tx_free)
+		return RTE_ETH_TX_DESC_DONE;
+
+	desc = txq->tx_tail - offset - 1;
+	if (desc < 0)
+		desc += txq->nb_tx_desc;
 
-	desc = txq->tx_tail + offset;
-	/* go to next desc that has the RS bit */
-	desc = ((desc + txq->tx_rs_thresh - 1) / txq->tx_rs_thresh) *
-		txq->tx_rs_thresh;
-	if (desc >= txq->nb_tx_desc) {
-		desc -= txq->nb_tx_desc;
-		if (desc >= txq->nb_tx_desc)
-			desc -= txq->nb_tx_desc;
+	/* offset is too small, no other way than reading PCI reg */
+	if (unlikely(offset < txq->tx_rs_thresh)) {
+		int16_t tx_head, queue_size;
+		tx_head = I40E_READ_REG(I40E_VSI_TO_HW(txq->vsi),
+					I40E_QTX_HEAD(txq->reg_idx));
+		queue_size = txq->tx_tail - tx_head;
+		if (queue_size < 0)
+			queue_size += txq->nb_tx_desc;
+		return queue_size > offset ? RTE_ETH_TX_DESC_FULL :
+			RTE_ETH_TX_DESC_DONE;
 	}
 
-	status = &txq->tx_ring[desc].cmd_type_offset_bsz;
+	/* index of the dd bit to look at */
+	dd = (desc / txq->tx_rs_thresh + 1) * txq->tx_rs_thresh - 1;
+
+	/* In full featured mode, RS bit is only set in the last descriptor */
+	/* of a multisegments packet */
+	if (!(txq->offloads == 0 &&
+	      txq->tx_rs_thresh >= RTE_PMD_I40E_TX_MAX_BURST))
+		dd = txq->sw_ring[dd].last_id;
+
+	status = &txq->tx_ring[dd].cmd_type_offset_bsz;
 	mask = rte_le_to_cpu_64(I40E_TXD_QW1_DTYPE_MASK);
 	expect = rte_cpu_to_le_64(
 		I40E_TX_DESC_DTYPE_DESC_DONE << I40E_TXD_QW1_DTYPE_SHIFT);
-- 
2.11.0


^ permalink raw reply	[flat|nested] 46+ messages in thread

* [dpdk-dev] [PATCH 19.11 V3 07/12] net/i40e: set speed to undefined for default case in link update
  2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 00/12] Miscellaneous fixes Thierry Herbelot
                     ` (6 preceding siblings ...)
  2019-08-08  8:22   ` [dpdk-dev] [PATCH 19.11 V3 06/12] net/i40e: " Thierry Herbelot
@ 2019-08-08  8:22   ` Thierry Herbelot
  2019-08-08  8:22   ` [dpdk-dev] [PATCH 19.11 V3 08/12] virtio: fix rx stats with vectorized functions Thierry Herbelot
                     ` (4 subsequent siblings)
  12 siblings, 0 replies; 46+ messages in thread
From: Thierry Herbelot @ 2019-08-08  8:22 UTC (permalink / raw)
  To: dev; +Cc: Laurent Hardy, stable, Thomas Monjalon

From: Laurent Hardy <laurent.hardy@6wind.com>

During PF/VF link update, a default speed value of 100M will be set
if get_link_info has failed or speed is unknown.

Consequently if PF is put in no-carrier state, VFs will switch to
"in carrier" state due to a link up + a link speed set to 100M
(default value if no speed detected).

To be consistent with linux drivers on which PF and VFs are in
same carrier state, sets default speed to undefined (instead of 100M)
and updates a link status of VF only if link is up and speed is
different from undefined.

Fixes: 4861cde46116 ('i40e: new poll mode driver')
Cc: stable@dpdk.org

Signed-off-by: Laurent Hardy <laurent.hardy@6wind.com>
---
 drivers/net/i40e/i40e_ethdev.c    | 4 ++--
 drivers/net/i40e/i40e_ethdev_vf.c | 8 +++++---
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 4e40b7ab5250..76abe8209a10 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -2743,7 +2743,7 @@ update_link_aq(struct i40e_hw *hw, struct rte_eth_link *link,
 		status = i40e_aq_get_link_info(hw, enable_lse,
 						&link_status, NULL);
 		if (unlikely(status != I40E_SUCCESS)) {
-			link->link_speed = ETH_SPEED_NUM_100M;
+			link->link_speed = ETH_SPEED_NUM_NONE;
 			link->link_duplex = ETH_LINK_FULL_DUPLEX;
 			PMD_DRV_LOG(ERR, "Failed to get link info");
 			return;
@@ -2777,7 +2777,7 @@ update_link_aq(struct i40e_hw *hw, struct rte_eth_link *link,
 		link->link_speed = ETH_SPEED_NUM_40G;
 		break;
 	default:
-		link->link_speed = ETH_SPEED_NUM_100M;
+		link->link_speed = ETH_SPEED_NUM_NONE;
 		break;
 	}
 }
diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index 308fb9835ab1..bf707e57b29b 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -2143,13 +2143,15 @@ i40evf_dev_link_update(struct rte_eth_dev *dev,
 		new_link.link_speed = ETH_SPEED_NUM_40G;
 		break;
 	default:
-		new_link.link_speed = ETH_SPEED_NUM_100M;
+		new_link.link_speed = ETH_SPEED_NUM_NONE;
 		break;
 	}
 	/* full duplex only */
 	new_link.link_duplex = ETH_LINK_FULL_DUPLEX;
-	new_link.link_status = vf->link_up ? ETH_LINK_UP :
-					     ETH_LINK_DOWN;
+	new_link.link_status = vf->link_up &&
+				new_link.link_speed != ETH_SPEED_NUM_NONE
+				? ETH_LINK_UP
+				: ETH_LINK_DOWN;
 	new_link.link_autoneg =
 		!(dev->data->dev_conf.link_speeds & ETH_LINK_SPEED_FIXED);
 
-- 
2.11.0


^ permalink raw reply	[flat|nested] 46+ messages in thread

* [dpdk-dev] [PATCH 19.11 V3 08/12] virtio: fix rx stats with vectorized functions
  2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 00/12] Miscellaneous fixes Thierry Herbelot
                     ` (7 preceding siblings ...)
  2019-08-08  8:22   ` [dpdk-dev] [PATCH 19.11 V3 07/12] net/i40e: set speed to undefined for default case in link update Thierry Herbelot
@ 2019-08-08  8:22   ` Thierry Herbelot
  2019-08-08  8:22   ` [dpdk-dev] [PATCH 19.11 V3 09/12] virtio: get all pending rx packets " Thierry Herbelot
                     ` (3 subsequent siblings)
  12 siblings, 0 replies; 46+ messages in thread
From: Thierry Herbelot @ 2019-08-08  8:22 UTC (permalink / raw)
  To: dev; +Cc: Thibaut Collet, stable, Thomas Monjalon

From: Thibaut Collet <thibaut.collet@6wind.com>

With vectorized functions, only the rx stats for number of packets is
incremented.
Update also the other statistics.
Performance impact is about 2%

Fixes: fc3d66212fed ("virtio: add vector Rx")
Cc: stable@dpdk.org

Signed-off-by: Thibaut Collet <thibaut.collet@6wind.com>
---
 drivers/net/virtio/virtio_rxtx.c             | 2 +-
 drivers/net/virtio/virtio_rxtx.h             | 2 ++
 drivers/net/virtio/virtio_rxtx_simple_neon.c | 5 +++++
 drivers/net/virtio/virtio_rxtx_simple_sse.c  | 5 +++++
 4 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c
index 27ead19fbe81..6dd62bf51863 100644
--- a/drivers/net/virtio/virtio_rxtx.c
+++ b/drivers/net/virtio/virtio_rxtx.c
@@ -1083,7 +1083,7 @@ virtio_discard_rxbuf_inorder(struct virtqueue *vq, struct rte_mbuf *m)
 	}
 }
 
-static inline void
+void
 virtio_update_packet_stats(struct virtnet_stats *stats, struct rte_mbuf *mbuf)
 {
 	uint32_t s = mbuf->pkt_len;
diff --git a/drivers/net/virtio/virtio_rxtx.h b/drivers/net/virtio/virtio_rxtx.h
index 685cc4f8104c..1eb8dae227ee 100644
--- a/drivers/net/virtio/virtio_rxtx.h
+++ b/drivers/net/virtio/virtio_rxtx.h
@@ -59,5 +59,7 @@ struct virtnet_ctl {
 };
 
 int virtio_rxq_vec_setup(struct virtnet_rx *rxvq);
+void virtio_update_packet_stats(struct virtnet_stats *stats,
+				struct rte_mbuf *mbuf);
 
 #endif /* _VIRTIO_RXTX_H_ */
diff --git a/drivers/net/virtio/virtio_rxtx_simple_neon.c b/drivers/net/virtio/virtio_rxtx_simple_neon.c
index cdc2a4d28ed5..70e89fc428e0 100644
--- a/drivers/net/virtio/virtio_rxtx_simple_neon.c
+++ b/drivers/net/virtio/virtio_rxtx_simple_neon.c
@@ -47,6 +47,7 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 	struct vring_used_elem *rused;
 	struct rte_mbuf **sw_ring;
 	struct rte_mbuf **sw_ring_end;
+	struct rte_mbuf **ref_rx_pkts;
 	uint16_t nb_pkts_received = 0;
 
 	uint8x16_t shuf_msk1 = {
@@ -105,6 +106,7 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 			virtqueue_notify(vq);
 	}
 
+	ref_rx_pkts = rx_pkts;
 	for (nb_pkts_received = 0;
 		nb_pkts_received < nb_used;) {
 		uint64x2_t desc[RTE_VIRTIO_DESC_PER_LOOP / 2];
@@ -204,5 +206,8 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 	vq->vq_used_cons_idx += nb_pkts_received;
 	vq->vq_free_cnt += nb_pkts_received;
 	rxvq->stats.packets += nb_pkts_received;
+	for (nb_used = 0; nb_used < nb_pkts_received; nb_used++)
+		virtio_update_packet_stats(&rxvq->stats, ref_rx_pkts[nb_used]);
+
 	return nb_pkts_received;
 }
diff --git a/drivers/net/virtio/virtio_rxtx_simple_sse.c b/drivers/net/virtio/virtio_rxtx_simple_sse.c
index af76708d66ae..cb1610e71563 100644
--- a/drivers/net/virtio/virtio_rxtx_simple_sse.c
+++ b/drivers/net/virtio/virtio_rxtx_simple_sse.c
@@ -48,6 +48,7 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 	struct vring_used_elem *rused;
 	struct rte_mbuf **sw_ring;
 	struct rte_mbuf **sw_ring_end;
+	struct rte_mbuf **ref_rx_pkts;
 	uint16_t nb_pkts_received = 0;
 	__m128i shuf_msk1, shuf_msk2, len_adjust;
 
@@ -107,6 +108,7 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 			virtqueue_notify(vq);
 	}
 
+	ref_rx_pkts = rx_pkts;
 	for (nb_pkts_received = 0;
 		nb_pkts_received < nb_used;) {
 		__m128i desc[RTE_VIRTIO_DESC_PER_LOOP / 2];
@@ -190,5 +192,8 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 	vq->vq_used_cons_idx += nb_pkts_received;
 	vq->vq_free_cnt += nb_pkts_received;
 	rxvq->stats.packets += nb_pkts_received;
+	for (nb_used = 0; nb_used < nb_pkts_received; nb_used++)
+		virtio_update_packet_stats(&rxvq->stats, ref_rx_pkts[nb_used]);
+
 	return nb_pkts_received;
 }
-- 
2.11.0


^ permalink raw reply	[flat|nested] 46+ messages in thread

* [dpdk-dev] [PATCH 19.11 V3 09/12] virtio: get all pending rx packets with vectorized functions
  2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 00/12] Miscellaneous fixes Thierry Herbelot
                     ` (8 preceding siblings ...)
  2019-08-08  8:22   ` [dpdk-dev] [PATCH 19.11 V3 08/12] virtio: fix rx stats with vectorized functions Thierry Herbelot
@ 2019-08-08  8:22   ` Thierry Herbelot
  2019-08-08  8:22   ` [dpdk-dev] [PATCH 19.11 V3 10/12] drivers/crypto/openssl: use a local copy for the session contexts Thierry Herbelot
                     ` (2 subsequent siblings)
  12 siblings, 0 replies; 46+ messages in thread
From: Thierry Herbelot @ 2019-08-08  8:22 UTC (permalink / raw)
  To: dev; +Cc: Thibaut Collet, stable, Thomas Monjalon

From: Thibaut Collet <thibaut.collet@6wind.com>

The loop to read packets does not take all packets as the number of
available packets (nb_used) is decremented in the loop.
Take all available packets provides a performance improvement of 3%.

Fixes: fc3d66212fed ("virtio: add vector Rx")
Cc: stable@dpdk.org

Signed-off-by: Thibaut Collet <thibaut.collet@6wind.com>
---
 drivers/net/virtio/virtio_rxtx_simple_neon.c | 5 +++--
 drivers/net/virtio/virtio_rxtx_simple_sse.c  | 5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/virtio/virtio_rxtx_simple_neon.c b/drivers/net/virtio/virtio_rxtx_simple_neon.c
index 70e89fc428e0..992e71f010eb 100644
--- a/drivers/net/virtio/virtio_rxtx_simple_neon.c
+++ b/drivers/net/virtio/virtio_rxtx_simple_neon.c
@@ -42,7 +42,7 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 	struct virtnet_rx *rxvq = rx_queue;
 	struct virtqueue *vq = rxvq->vq;
 	struct virtio_hw *hw = vq->hw;
-	uint16_t nb_used;
+	uint16_t nb_used, nb_total;
 	uint16_t desc_idx;
 	struct vring_used_elem *rused;
 	struct rte_mbuf **sw_ring;
@@ -106,9 +106,10 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 			virtqueue_notify(vq);
 	}
 
+	nb_total = nb_used;
 	ref_rx_pkts = rx_pkts;
 	for (nb_pkts_received = 0;
-		nb_pkts_received < nb_used;) {
+		nb_pkts_received < nb_total;) {
 		uint64x2_t desc[RTE_VIRTIO_DESC_PER_LOOP / 2];
 		uint64x2_t mbp[RTE_VIRTIO_DESC_PER_LOOP / 2];
 		uint64x2_t pkt_mb[RTE_VIRTIO_DESC_PER_LOOP];
diff --git a/drivers/net/virtio/virtio_rxtx_simple_sse.c b/drivers/net/virtio/virtio_rxtx_simple_sse.c
index cb1610e71563..f9ec4ae69986 100644
--- a/drivers/net/virtio/virtio_rxtx_simple_sse.c
+++ b/drivers/net/virtio/virtio_rxtx_simple_sse.c
@@ -43,7 +43,7 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 	struct virtnet_rx *rxvq = rx_queue;
 	struct virtqueue *vq = rxvq->vq;
 	struct virtio_hw *hw = vq->hw;
-	uint16_t nb_used;
+	uint16_t nb_used, nb_total;
 	uint16_t desc_idx;
 	struct vring_used_elem *rused;
 	struct rte_mbuf **sw_ring;
@@ -108,9 +108,10 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 			virtqueue_notify(vq);
 	}
 
+	nb_total = nb_used;
 	ref_rx_pkts = rx_pkts;
 	for (nb_pkts_received = 0;
-		nb_pkts_received < nb_used;) {
+		nb_pkts_received < nb_total;) {
 		__m128i desc[RTE_VIRTIO_DESC_PER_LOOP / 2];
 		__m128i mbp[RTE_VIRTIO_DESC_PER_LOOP / 2];
 		__m128i pkt_mb[RTE_VIRTIO_DESC_PER_LOOP];
-- 
2.11.0


^ permalink raw reply	[flat|nested] 46+ messages in thread

* [dpdk-dev] [PATCH 19.11 V3 10/12] drivers/crypto/openssl: use a local copy for the session contexts
  2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 00/12] Miscellaneous fixes Thierry Herbelot
                     ` (9 preceding siblings ...)
  2019-08-08  8:22   ` [dpdk-dev] [PATCH 19.11 V3 09/12] virtio: get all pending rx packets " Thierry Herbelot
@ 2019-08-08  8:22   ` Thierry Herbelot
  2019-08-08  8:22   ` [dpdk-dev] [PATCH 19.11 V3 11/12] drivers/crypto/dpaa_sec: update DPAA iova table in dpaa_mem_vtop Thierry Herbelot
  2019-08-08  8:22   ` [dpdk-dev] [PATCH 19.11 V3 12/12] drivers/crypto/octeontx: enable unbinding for the OcteonTx crypto engines Thierry Herbelot
  12 siblings, 0 replies; 46+ messages in thread
From: Thierry Herbelot @ 2019-08-08  8:22 UTC (permalink / raw)
  To: dev; +Cc: stable, Thomas Monjalon

Session contexts are used for temporary storage when processing a
packet.
If packets for the same session are to be processed simultaneously on
multiple cores, separate contexts must be used.

Note: with openssl 1.1.1 EVP_CIPHER_CTX can no longer be defined as a
variable on the stack: it must be allocated. This in turn reduces the
performance.

Fixes: d61f70b4c918 ('crypto/libcrypto: add driver for OpenSSL library')
Cc: stable@dpdk.org

Signed-off-by: Thierry Herbelot <thierry.herbelot@6wind.com>
---
 drivers/crypto/openssl/rte_openssl_pmd.c | 34 +++++++++++++++++++++++---------
 1 file changed, 25 insertions(+), 9 deletions(-)

diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c b/drivers/crypto/openssl/rte_openssl_pmd.c
index 2f5552840741..ce2d12347737 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd.c
@@ -1290,6 +1290,7 @@ process_openssl_combined_op
 	int srclen, aadlen, status = -1;
 	uint32_t offset;
 	uint8_t taglen;
+	EVP_CIPHER_CTX *ctx_copy;
 
 	/*
 	 * Segmented destination buffer is not supported for
@@ -1326,6 +1327,8 @@ process_openssl_combined_op
 	}
 
 	taglen = sess->auth.digest_length;
+	ctx_copy = EVP_CIPHER_CTX_new();
+	EVP_CIPHER_CTX_copy(ctx_copy, sess->cipher.ctx);
 
 	if (sess->cipher.direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
 		if (sess->auth.algo == RTE_CRYPTO_AUTH_AES_GMAC ||
@@ -1333,12 +1336,12 @@ process_openssl_combined_op
 			status = process_openssl_auth_encryption_gcm(
 					mbuf_src, offset, srclen,
 					aad, aadlen, iv,
-					dst, tag, sess->cipher.ctx);
+					dst, tag, ctx_copy);
 		else
 			status = process_openssl_auth_encryption_ccm(
 					mbuf_src, offset, srclen,
 					aad, aadlen, iv,
-					dst, tag, taglen, sess->cipher.ctx);
+					dst, tag, taglen, ctx_copy);
 
 	} else {
 		if (sess->auth.algo == RTE_CRYPTO_AUTH_AES_GMAC ||
@@ -1346,14 +1349,15 @@ process_openssl_combined_op
 			status = process_openssl_auth_decryption_gcm(
 					mbuf_src, offset, srclen,
 					aad, aadlen, iv,
-					dst, tag, sess->cipher.ctx);
+					dst, tag, ctx_copy);
 		else
 			status = process_openssl_auth_decryption_ccm(
 					mbuf_src, offset, srclen,
 					aad, aadlen, iv,
-					dst, tag, taglen, sess->cipher.ctx);
+					dst, tag, taglen, ctx_copy);
 	}
 
+	EVP_CIPHER_CTX_free(ctx_copy);
 	if (status != 0) {
 		if (status == (-EFAULT) &&
 				sess->auth.operation ==
@@ -1372,6 +1376,7 @@ process_openssl_cipher_op
 {
 	uint8_t *dst, *iv;
 	int srclen, status;
+	EVP_CIPHER_CTX *ctx_copy;
 
 	/*
 	 * Segmented destination buffer is not supported for
@@ -1388,22 +1393,25 @@ process_openssl_cipher_op
 
 	iv = rte_crypto_op_ctod_offset(op, uint8_t *,
 			sess->iv.offset);
+	ctx_copy = EVP_CIPHER_CTX_new();
+	EVP_CIPHER_CTX_copy(ctx_copy, sess->cipher.ctx);
 
 	if (sess->cipher.mode == OPENSSL_CIPHER_LIB)
 		if (sess->cipher.direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT)
 			status = process_openssl_cipher_encrypt(mbuf_src, dst,
 					op->sym->cipher.data.offset, iv,
-					srclen, sess->cipher.ctx);
+					srclen, ctx_copy);
 		else
 			status = process_openssl_cipher_decrypt(mbuf_src, dst,
 					op->sym->cipher.data.offset, iv,
-					srclen, sess->cipher.ctx);
+					srclen, ctx_copy);
 	else
 		status = process_openssl_cipher_des3ctr(mbuf_src, dst,
 				op->sym->cipher.data.offset, iv,
 				sess->cipher.key.data, srclen,
-				sess->cipher.ctx);
+				ctx_copy);
 
+	EVP_CIPHER_CTX_free(ctx_copy);
 	if (status != 0)
 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
 }
@@ -1507,6 +1515,8 @@ process_openssl_auth_op(struct openssl_qp *qp, struct rte_crypto_op *op,
 {
 	uint8_t *dst;
 	int srclen, status;
+	EVP_MD_CTX *ctx_a;
+	HMAC_CTX *ctx_h;
 
 	srclen = op->sym->auth.data.length;
 
@@ -1514,14 +1524,20 @@ process_openssl_auth_op(struct openssl_qp *qp, struct rte_crypto_op *op,
 
 	switch (sess->auth.mode) {
 	case OPENSSL_AUTH_AS_AUTH:
+		ctx_a = EVP_MD_CTX_create();
+		EVP_MD_CTX_copy_ex(ctx_a, sess->auth.auth.ctx);
 		status = process_openssl_auth(mbuf_src, dst,
 				op->sym->auth.data.offset, NULL, NULL, srclen,
-				sess->auth.auth.ctx, sess->auth.auth.evp_algo);
+				ctx_a, sess->auth.auth.evp_algo);
+		EVP_MD_CTX_destroy(ctx_a);
 		break;
 	case OPENSSL_AUTH_AS_HMAC:
+		ctx_h = HMAC_CTX_new();
+		HMAC_CTX_copy(ctx_h, sess->auth.hmac.ctx);
 		status = process_openssl_auth_hmac(mbuf_src, dst,
 				op->sym->auth.data.offset, srclen,
-				sess->auth.hmac.ctx);
+				ctx_h);
+		HMAC_CTX_free(ctx_h);
 		break;
 	default:
 		status = -1;
-- 
2.11.0


^ permalink raw reply	[flat|nested] 46+ messages in thread

* [dpdk-dev] [PATCH 19.11 V3 11/12] drivers/crypto/dpaa_sec: update DPAA iova table in dpaa_mem_vtop
  2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 00/12] Miscellaneous fixes Thierry Herbelot
                     ` (10 preceding siblings ...)
  2019-08-08  8:22   ` [dpdk-dev] [PATCH 19.11 V3 10/12] drivers/crypto/openssl: use a local copy for the session contexts Thierry Herbelot
@ 2019-08-08  8:22   ` Thierry Herbelot
  2019-08-08  8:22   ` [dpdk-dev] [PATCH 19.11 V3 12/12] drivers/crypto/octeontx: enable unbinding for the OcteonTx crypto engines Thierry Herbelot
  12 siblings, 0 replies; 46+ messages in thread
From: Thierry Herbelot @ 2019-08-08  8:22 UTC (permalink / raw)
  To: dev; +Cc: stable, Thomas Monjalon

dpaa_sec needs translations between physical and virtual addresses.
V to P translation is relatively fast, as memory is managed in
contiguous segments.

The result of each V to P translation is used to update the DPAA iova
table, which should be updated by a Mem event callback, but is not.
Then the DPAA iova table has entries for all needed memory ranges.

With this patch, dpaa_mem_ptov will always use dpaax_iova_table_get_va,
which ensures optimal performance.

Fixes: 5a7dbb934d75 ('dpaa: enable dpaax library')
Cc: stable@dpdk.org

Signed-off-by: Thierry Herbelot <thierry.herbelot@6wind.com>
---
 drivers/crypto/dpaa_sec/dpaa_sec.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c
index 122c80a072ff..22b8b1d63ce0 100644
--- a/drivers/crypto/dpaa_sec/dpaa_sec.c
+++ b/drivers/crypto/dpaa_sec/dpaa_sec.c
@@ -38,6 +38,7 @@
 #include <rte_dpaa_bus.h>
 #include <dpaa_sec.h>
 #include <dpaa_sec_log.h>
+#include <dpaax_iova_table.h>
 
 enum rta_sec_era rta_sec_era;
 
@@ -100,8 +101,10 @@ dpaa_mem_vtop(void *vaddr)
 	const struct rte_memseg *ms;
 
 	ms = rte_mem_virt2memseg(vaddr, NULL);
-	if (ms)
+	if (ms) {
+		dpaax_iova_table_update(ms->iova, (void *)ms->addr_64, ms->len);
 		return ms->iova + RTE_PTR_DIFF(vaddr, ms->addr);
+	}
 	return (size_t)NULL;
 }
 
-- 
2.11.0


^ permalink raw reply	[flat|nested] 46+ messages in thread

* [dpdk-dev] [PATCH 19.11 V3 12/12] drivers/crypto/octeontx: enable unbinding for the OcteonTx crypto engines
  2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 00/12] Miscellaneous fixes Thierry Herbelot
                     ` (11 preceding siblings ...)
  2019-08-08  8:22   ` [dpdk-dev] [PATCH 19.11 V3 11/12] drivers/crypto/dpaa_sec: update DPAA iova table in dpaa_mem_vtop Thierry Herbelot
@ 2019-08-08  8:22   ` Thierry Herbelot
  12 siblings, 0 replies; 46+ messages in thread
From: Thierry Herbelot @ 2019-08-08  8:22 UTC (permalink / raw)
  To: dev; +Cc: stable, Thomas Monjalon

Like for Ethernet ports, the OcteonTx crypto engines must first be unbound
from their kernel module, then rebound to vfio-pci, before being usable
in DPDK.

As this capability is detected at runtime by dpdk-pmdinfo, add the info
in the PMD registering directives.

Then an external script can be used for bind and unbind.

Fixes: bfe2ae495ee268 ('crypto/octeontx: add PMD skeleton')
Cc: stable@dpdk.org

Signed-off-by: Thierry Herbelot <thierry.herbelot@6wind.com>
---
 drivers/crypto/octeontx/otx_cryptodev.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/crypto/octeontx/otx_cryptodev.c b/drivers/crypto/octeontx/otx_cryptodev.c
index fc64a5f3041f..16f1909966d0 100644
--- a/drivers/crypto/octeontx/otx_cryptodev.c
+++ b/drivers/crypto/octeontx/otx_cryptodev.c
@@ -118,6 +118,7 @@ static struct cryptodev_driver otx_cryptodev_drv;
 
 RTE_PMD_REGISTER_PCI(CRYPTODEV_NAME_OCTEONTX_PMD, otx_cryptodev_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(CRYPTODEV_NAME_OCTEONTX_PMD, pci_id_cpt_table);
+RTE_PMD_REGISTER_KMOD_DEP(CRYPTODEV_NAME_OCTEONTX_PMD, "* igb_uio | uio_pci_generic | vfio-pci");
 RTE_PMD_REGISTER_CRYPTO_DRIVER(otx_cryptodev_drv, otx_cryptodev_pmd.driver,
 		otx_cryptodev_driver_id);
 
-- 
2.11.0


^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: [dpdk-dev] [PATCH 19.11 V3 02/12] ethdev: fix description of tx descriptor status
  2019-08-08  8:22   ` [dpdk-dev] [PATCH 19.11 V3 02/12] ethdev: fix description of tx descriptor status Thierry Herbelot
@ 2019-08-08 10:37     ` Andrew Rybchenko
  0 siblings, 0 replies; 46+ messages in thread
From: Andrew Rybchenko @ 2019-08-08 10:37 UTC (permalink / raw)
  To: Thierry Herbelot, dev; +Cc: Olivier Matz, stable, Thomas Monjalon

On 8/8/19 11:22 AM, Thierry Herbelot wrote:
> From: Olivier Matz <olivier.matz@6wind.com>
>
> The API comment of rte_eth_tx_descriptor_status() was incorrect. The
> reference descriptor (when offset = 0) is not where the next packet
> will be sent, but where the latest packet has been enqueued.
>
> Fixes: 52f5cdd2e897 ("ethdev: add descriptor status API")
> Cc: stable@dpdk.org
>
> Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
> ---
>   lib/librte_ethdev/rte_ethdev.h | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h
> index dc6596bc93b4..b423e71050e9 100644
> --- a/lib/librte_ethdev/rte_ethdev.h
> +++ b/lib/librte_ethdev/rte_ethdev.h
> @@ -4245,8 +4245,8 @@ rte_eth_rx_descriptor_status(uint16_t port_id, uint16_t queue_id,
>    * @param queue_id
>    *  A valid Tx queue identifier on this port.
>    * @param offset
> - *  The offset of the descriptor starting from tail (0 is the place where
> - *  the next packet will be send).
> + *  The offset of the descriptor starting from tail (0 is the last written
> + *  descriptor).
>    *
>    * @return
>    *  - (RTE_ETH_TX_DESC_FULL) Descriptor is being processed by the hw, i.e.

The patch lacks explanation why it was wrong before and why it is
correct after the patch.

I think there is a space here for description improvements since it is
still confusing. I'd suggest to remove 'tail' term from the description or
write down full description to explain what/where is head and tail.

Rx case:

          V-->offset
=========***********----------------00000000000==
  UNAVAIL     DONE        AVAIL        UNUSED

i.e. V points to the next packet to be received by the driver, i.e. the 
first *
(the descriptor is done by HW and packet is ready to be processed).
DONE(*) are descriptors filled in by HW, but not processed by the driver 
yet.
AVAIL(-) are available for HW to fill in with received packets.
UNUSED(0) (right now it is UNAVAIL as well) are descriptors which can be
done AVAIL on Rx queue refill
UNAVAIL(=) are reserved Rx ring space which cannot be used

The key question for Rx is the length of DONE. Is CPU fast enough to
handle incoming traffic?

Tx case (where is tail V and why):

=========************--------------00000000000==
  UNAVAIL     DONE          FULL       UNUSED

DONE(*) are descriptors processed by HW and should be processed by the 
driver to
free associated mbuf (rte_eth_tx_done_cleanup())
FULL(-) are available for HW to send these packets out, but not 
processed yet.
UNUSED(0) is available space in Tx ring to make it FULL
UNAVAIL(=) is reserved Tx ring space which cannot be used

I'd say that it should be similar to Rx here, but it looks different in 
accordance with
current description. Above patch fixes it from the first '-' (or the 
first '0'?) to be
the last '-'.

What is the main question for Tx status descriptor user?



^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: [dpdk-dev] [PATCH 19.11 V3 00/12] Miscellaneous fixes
  2019-08-08  8:22   ` [dpdk-dev] [PATCH 19.11 V3 " Thierry Herbelot
@ 2019-08-08 13:19     ` Thierry Herbelot
  2019-08-08 14:34       ` Thomas Monjalon
  0 siblings, 1 reply; 46+ messages in thread
From: Thierry Herbelot @ 2019-08-08 13:19 UTC (permalink / raw)
  To: dev; +Cc: stable, Thomas Monjalon

On 8/8/19 10:22 AM, Thierry Herbelot wrote:
> This series of patches includes fixes for issues seen with
> 6WIND fast path, built on DPDK.
> The patches are in 6WIND version of DPDK, and should have been
> upstreamed a long time ago.

In fact, I will re-submit another series of patches, as some are not yet 
ready.

Please disregard the current series.

	Thierry

> 
> V3 changes:
> fix double increment of stats in virtio vectorized functions
> 
> V2 changes:
> fix checkpatch issues
> 
> 
> Guo Fengtian (1):
>    net/ixgbevf: fix stats update after a PF reset
> 
> Laurent Hardy (1):
>    net/i40e: set speed to undefined for default case in link update
> 
> Olivier Matz (5):
>    ethdev: fix description of tx descriptor status
>    net/e1000: fix Tx descriptor status api (igb)
>    net/e1000: fix Tx descriptor status api (em)
>    net/ixgbe: fix Tx descriptor status api
>    net/i40e: fix Tx descriptor status api
> 
> Thibaut Collet (2):
>    virtio: fix rx stats with vectorized functions
>    virtio: get all pending rx packets with vectorized functions
> 
> Thierry Herbelot (3):
>    drivers/crypto/openssl: use a local copy for the session contexts
>    drivers/crypto/dpaa_sec: update DPAA iova table in dpaa_mem_vtop
>    drivers/crypto/octeontx: enable unbinding for the OcteonTx crypto
>      engines
> 
>   drivers/crypto/dpaa_sec/dpaa_sec.c           |  5 +++-
>   drivers/crypto/octeontx/otx_cryptodev.c      |  1 +
>   drivers/crypto/openssl/rte_openssl_pmd.c     | 34 +++++++++++++++------
>   drivers/net/e1000/em_rxtx.c                  | 33 +++++++++++++-------
>   drivers/net/e1000/igb_rxtx.c                 |  9 +++---
>   drivers/net/i40e/i40e_ethdev.c               |  4 +--
>   drivers/net/i40e/i40e_ethdev_vf.c            |  8 +++--
>   drivers/net/i40e/i40e_rxtx.c                 | 37 ++++++++++++++++-------
>   drivers/net/ixgbe/ixgbe_ethdev.c             |  6 ++--
>   drivers/net/ixgbe/ixgbe_rxtx.c               | 45 ++++++++++++++++++++--------
>   drivers/net/ixgbe/ixgbe_rxtx.h               |  1 +
>   drivers/net/virtio/virtio_rxtx.c             |  2 +-
>   drivers/net/virtio/virtio_rxtx.h             |  2 ++
>   drivers/net/virtio/virtio_rxtx_simple_neon.c | 10 +++++--
>   drivers/net/virtio/virtio_rxtx_simple_sse.c  | 10 +++++--
>   lib/librte_ethdev/rte_ethdev.h               |  4 +--
>   16 files changed, 151 insertions(+), 60 deletions(-)
> 


-- 
Thierry Herbelot
6WIND

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: [dpdk-dev] [PATCH 19.11 V3 00/12] Miscellaneous fixes
  2019-08-08 13:19     ` Thierry Herbelot
@ 2019-08-08 14:34       ` Thomas Monjalon
  2019-10-10 13:01         ` David Marchand
  0 siblings, 1 reply; 46+ messages in thread
From: Thomas Monjalon @ 2019-08-08 14:34 UTC (permalink / raw)
  To: Thierry Herbelot; +Cc: dev, stable

08/08/2019 15:19, Thierry Herbelot:
> On 8/8/19 10:22 AM, Thierry Herbelot wrote:
> > This series of patches includes fixes for issues seen with
> > 6WIND fast path, built on DPDK.
> > The patches are in 6WIND version of DPDK, and should have been
> > upstreamed a long time ago.
> 
> In fact, I will re-submit another series of patches, as some are not yet 
> ready.

No hurry to send 3 versions of this series while we are still closing 19.08.

> Please disregard the current series.




^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: [dpdk-dev] [PATCH 19.11 V3 00/12] Miscellaneous fixes
  2019-08-08 14:34       ` Thomas Monjalon
@ 2019-10-10 13:01         ` David Marchand
  2019-10-10 13:12           ` Thierry Herbelot
  0 siblings, 1 reply; 46+ messages in thread
From: David Marchand @ 2019-10-10 13:01 UTC (permalink / raw)
  To: Thierry Herbelot; +Cc: dev, dpdk stable, Thomas Monjalon

On Thu, Aug 8, 2019 at 4:34 PM Thomas Monjalon <thomas@monjalon.net> wrote:
>
> 08/08/2019 15:19, Thierry Herbelot:
> > On 8/8/19 10:22 AM, Thierry Herbelot wrote:
> > > This series of patches includes fixes for issues seen with
> > > 6WIND fast path, built on DPDK.
> > > The patches are in 6WIND version of DPDK, and should have been
> > > upstreamed a long time ago.
> >
> > In fact, I will re-submit another series of patches, as some are not yet
> > ready.
>
> No hurry to send 3 versions of this series while we are still closing 19.08.

I can see some patches went through the virtio subtree, is this series
still valid for 19.11?
Please update these patches status in patchwork.

Thanks.

--
David Marchand


^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: [dpdk-dev] [PATCH 19.11 V3 00/12] Miscellaneous fixes
  2019-10-10 13:01         ` David Marchand
@ 2019-10-10 13:12           ` Thierry Herbelot
  0 siblings, 0 replies; 46+ messages in thread
From: Thierry Herbelot @ 2019-10-10 13:12 UTC (permalink / raw)
  To: David Marchand; +Cc: dev, dpdk stable, Thomas Monjalon

On 10/10/19 3:01 PM, David Marchand wrote:
> On Thu, Aug 8, 2019 at 4:34 PM Thomas Monjalon <thomas@monjalon.net> wrote:
>>
>> 08/08/2019 15:19, Thierry Herbelot:
>>> On 8/8/19 10:22 AM, Thierry Herbelot wrote:
>>>> This series of patches includes fixes for issues seen with
>>>> 6WIND fast path, built on DPDK.
>>>> The patches are in 6WIND version of DPDK, and should have been
>>>> upstreamed a long time ago.
>>>
>>> In fact, I will re-submit another series of patches, as some are not yet
>>> ready.
>>
>> No hurry to send 3 versions of this series while we are still closing 19.08.
> 
> I can see some patches went through the virtio subtree, is this series
> still valid for 19.11?
> Please update these patches status in patchwork.

done: all have been set as superseded.

	Th

> 
> Thanks.
> 
> --
> David Marchand
> 


-- 
Thierry Herbelot
6WIND
Senior Software Engineer

^ permalink raw reply	[flat|nested] 46+ messages in thread

end of thread, other threads:[~2019-10-10 13:12 UTC | newest]

Thread overview: 46+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-07 14:37 [dpdk-dev] [PATCH 19.11 00/12] Miscellaneous fixes Thierry Herbelot
2019-08-07 14:37 ` [dpdk-dev] [PATCH 19.11 01/12] net/ixgbevf: fix stats update after a PF reset Thierry Herbelot
2019-08-07 14:37 ` [dpdk-dev] [PATCH 19.11 02/12] ethdev: fix description of tx descriptor status Thierry Herbelot
2019-08-07 14:37 ` [dpdk-dev] [PATCH 19.11 03/12] net/e1000: fix Tx descriptor status api (igb) Thierry Herbelot
2019-08-07 14:37 ` [dpdk-dev] [PATCH 19.11 04/12] net/e1000: fix Tx descriptor status api (em) Thierry Herbelot
2019-08-07 14:37 ` [dpdk-dev] [PATCH 19.11 05/12] net/ixgbe: fix Tx descriptor status api Thierry Herbelot
2019-08-07 14:37 ` [dpdk-dev] [PATCH 19.11 06/12] net/i40e: " Thierry Herbelot
2019-08-07 14:37 ` [dpdk-dev] [PATCH 19.11 07/12] net/i40e: set speed to undefined for default case in link update Thierry Herbelot
2019-08-07 14:37 ` [dpdk-dev] [PATCH 19.11 08/12] virtio: fix rx stats with vectorized functions Thierry Herbelot
2019-08-07 14:37 ` [dpdk-dev] [PATCH 19.11 09/12] virtio: get all pending rx packets " Thierry Herbelot
2019-08-07 14:37 ` [dpdk-dev] [PATCH 19.11 10/12] drivers/crypto/openssl: use a local copy for the session contexts Thierry Herbelot
2019-08-07 14:37 ` [dpdk-dev] [PATCH 19.11 11/12] drivers/crypto/dpaa_sec: update DPAA iova table in dpaa_mem_vtop Thierry Herbelot
2019-08-07 14:37 ` [dpdk-dev] [PATCH 19.11 12/12] drivers/crypto/octeontx: enable unbinding for the OcteonTx crypto engines Thierry Herbelot
2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 00/12] Miscellaneous fixes Thierry Herbelot
2019-08-08  8:22   ` [dpdk-dev] [PATCH 19.11 V3 " Thierry Herbelot
2019-08-08 13:19     ` Thierry Herbelot
2019-08-08 14:34       ` Thomas Monjalon
2019-10-10 13:01         ` David Marchand
2019-10-10 13:12           ` Thierry Herbelot
2019-08-08  8:22   ` [dpdk-dev] [PATCH 19.11 V3 01/12] net/ixgbevf: fix stats update after a PF reset Thierry Herbelot
2019-08-08  8:22   ` [dpdk-dev] [PATCH 19.11 V3 02/12] ethdev: fix description of tx descriptor status Thierry Herbelot
2019-08-08 10:37     ` Andrew Rybchenko
2019-08-08  8:22   ` [dpdk-dev] [PATCH 19.11 V3 03/12] net/e1000: fix Tx descriptor status api (igb) Thierry Herbelot
2019-08-08  8:22   ` [dpdk-dev] [PATCH 19.11 V3 04/12] net/e1000: fix Tx descriptor status api (em) Thierry Herbelot
2019-08-08  8:22   ` [dpdk-dev] [PATCH 19.11 V3 05/12] net/ixgbe: fix Tx descriptor status api Thierry Herbelot
2019-08-08  8:22   ` [dpdk-dev] [PATCH 19.11 V3 06/12] net/i40e: " Thierry Herbelot
2019-08-08  8:22   ` [dpdk-dev] [PATCH 19.11 V3 07/12] net/i40e: set speed to undefined for default case in link update Thierry Herbelot
2019-08-08  8:22   ` [dpdk-dev] [PATCH 19.11 V3 08/12] virtio: fix rx stats with vectorized functions Thierry Herbelot
2019-08-08  8:22   ` [dpdk-dev] [PATCH 19.11 V3 09/12] virtio: get all pending rx packets " Thierry Herbelot
2019-08-08  8:22   ` [dpdk-dev] [PATCH 19.11 V3 10/12] drivers/crypto/openssl: use a local copy for the session contexts Thierry Herbelot
2019-08-08  8:22   ` [dpdk-dev] [PATCH 19.11 V3 11/12] drivers/crypto/dpaa_sec: update DPAA iova table in dpaa_mem_vtop Thierry Herbelot
2019-08-08  8:22   ` [dpdk-dev] [PATCH 19.11 V3 12/12] drivers/crypto/octeontx: enable unbinding for the OcteonTx crypto engines Thierry Herbelot
2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 01/12] net/ixgbevf: fix stats update after a PF reset Thierry Herbelot
2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 02/12] ethdev: fix description of tx descriptor status Thierry Herbelot
2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 03/12] net/e1000: fix Tx descriptor status api (igb) Thierry Herbelot
2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 04/12] net/e1000: fix Tx descriptor status api (em) Thierry Herbelot
2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 05/12] net/ixgbe: fix Tx descriptor status api Thierry Herbelot
2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 06/12] net/i40e: " Thierry Herbelot
2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 07/12] net/i40e: set speed to undefined for default case in link update Thierry Herbelot
2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 08/12] virtio: fix rx stats with vectorized functions Thierry Herbelot
2019-08-08  5:15   ` [dpdk-dev] [dpdk-stable] " Tiwei Bie
2019-08-08  7:35     ` Thibaut Collet
2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 09/12] virtio: get all pending rx packets " Thierry Herbelot
2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 10/12] drivers/crypto/openssl: use a local copy for the session contexts Thierry Herbelot
2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 11/12] drivers/crypto/dpaa_sec: update DPAA iova table in dpaa_mem_vtop Thierry Herbelot
2019-08-07 15:09 ` [dpdk-dev] [PATCH 19.11 V2 12/12] drivers/crypto/octeontx: enable unbinding for the OcteonTx crypto engines Thierry Herbelot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).