diff mbox series

[26/35] net/ionic: add Rx descriptor status functions

Message ID 20221007174336.54354-27-andrew.boyer@amd.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers show
Series net/ionic: updates for 22.11 release | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Boyer, Andrew Oct. 7, 2022, 5:43 p.m. UTC
These may be useful for clients.

Signed-off-by: Andrew Boyer <andrew.boyer@amd.com>
Signed-off-by: Allen Hubbe <allen.hubbe@amd.com>
---
 doc/guides/nics/features/ionic.ini     |  1 +
 doc/guides/rel_notes/release_22_11.rst |  1 +
 drivers/net/ionic/ionic_ethdev.c       |  2 ++
 drivers/net/ionic/ionic_rxtx.c         | 39 ++++++++++++++++++++++++++
 drivers/net/ionic/ionic_rxtx.h         |  2 ++
 5 files changed, 45 insertions(+)
diff mbox series

Patch

diff --git a/doc/guides/nics/features/ionic.ini b/doc/guides/nics/features/ionic.ini
index 77947bfd22..e01ba87135 100644
--- a/doc/guides/nics/features/ionic.ini
+++ b/doc/guides/nics/features/ionic.ini
@@ -27,6 +27,7 @@  CRC offload          = Y
 L3 checksum offload  = Y
 L4 checksum offload  = Y
 Packet type parsing  = Y
+Rx descriptor status = Y
 Basic stats          = Y
 Extended stats       = Y
 Stats per queue      = Y
diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst
index 5c3bd15e55..d2e82979e6 100644
--- a/doc/guides/rel_notes/release_22_11.rst
+++ b/doc/guides/rel_notes/release_22_11.rst
@@ -86,6 +86,7 @@  New Features
   * Enhanced data path to provide substantial performance improvements.
   * Added support for mbuf fast free.
   * Added support for advertising packet types.
+  * Added support for descriptor status functions.
 
 Removed Items
 -------------
diff --git a/drivers/net/ionic/ionic_ethdev.c b/drivers/net/ionic/ionic_ethdev.c
index 39bbe60d79..7ac7006d88 100644
--- a/drivers/net/ionic/ionic_ethdev.c
+++ b/drivers/net/ionic/ionic_ethdev.c
@@ -984,6 +984,8 @@  eth_ionic_dev_init(struct rte_eth_dev *eth_dev, void *init_params)
 	eth_dev->tx_pkt_burst = &ionic_xmit_pkts;
 	eth_dev->tx_pkt_prepare = &ionic_prep_pkts;
 
+	eth_dev->rx_descriptor_status = ionic_dev_rx_descriptor_status;
+
 	/* Multi-process not supported, primary does initialization anyway */
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
 		return 0;
diff --git a/drivers/net/ionic/ionic_rxtx.c b/drivers/net/ionic/ionic_rxtx.c
index 24fd8fcf04..64cbbd9815 100644
--- a/drivers/net/ionic/ionic_rxtx.c
+++ b/drivers/net/ionic/ionic_rxtx.c
@@ -1235,3 +1235,42 @@  ionic_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 
 	return rx_svc.nb_rx;
 }
+
+int
+ionic_dev_rx_descriptor_status(void *rx_queue, uint16_t offset)
+{
+	struct ionic_rx_qcq *rxq = rx_queue;
+	struct ionic_qcq *qcq = &rxq->qcq;
+	struct ionic_rxq_comp *cq_desc;
+	uint16_t mask, head, tail, pos;
+	bool done_color;
+
+	mask = qcq->q.size_mask;
+
+	/* offset must be within the size of the ring */
+	if (offset > mask)
+		return -EINVAL;
+
+	head = qcq->q.head_idx;
+	tail = qcq->q.tail_idx;
+
+	/* offset is beyond what is posted */
+	if (offset >= ((head - tail) & mask))
+		return RTE_ETH_RX_DESC_UNAVAIL;
+
+	/* interested in this absolute position in the rxq */
+	pos = (tail + offset) & mask;
+
+	/* rx cq position == rx q position */
+	cq_desc = qcq->cq.base;
+	cq_desc = &cq_desc[pos];
+
+	/* expected done color at this position */
+	done_color = qcq->cq.done_color != (pos < tail);
+
+	/* has the hw indicated the done color at this position? */
+	if (color_match(cq_desc->pkt_type_color, done_color))
+		return RTE_ETH_RX_DESC_DONE;
+
+	return RTE_ETH_RX_DESC_AVAIL;
+}
diff --git a/drivers/net/ionic/ionic_rxtx.h b/drivers/net/ionic/ionic_rxtx.h
index de51f21012..465001a063 100644
--- a/drivers/net/ionic/ionic_rxtx.h
+++ b/drivers/net/ionic/ionic_rxtx.h
@@ -40,6 +40,8 @@  void ionic_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
 void ionic_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
 	struct rte_eth_txq_info *qinfo);
 
+int ionic_dev_rx_descriptor_status(void *rx_queue, uint16_t offset);
+
 const uint32_t *ionic_dev_supported_ptypes_get(struct rte_eth_dev *dev);
 
 #endif /* _IONIC_RXTX_H_ */