[2/3] net/cnxk: add support to extract HW error for inline IPsec

Message ID 20231016070437.2295803-2-ndabilpuram@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: Jerin Jacob
Headers
Series [1/3] net/cnxk: fix data offset extract logic in vector function |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Nithin Dabilpuram Oct. 16, 2023, 7:04 a.m. UTC
  Add PMD API support to extract HW error code from mbuf's processed
by inline IPsec inbound.

Signed-off-by: Nithin Dabilpuram <ndabilpuram@marvell.com>
---
 drivers/net/cnxk/cn10k_ethdev_sec.c | 18 ++++++++++++++++++
 drivers/net/cnxk/rte_pmd_cnxk.h     | 17 +++++++++++++++++
 drivers/net/cnxk/version.map        |  6 +++++-
 3 files changed, 40 insertions(+), 1 deletion(-)
  

Patch

diff --git a/drivers/net/cnxk/cn10k_ethdev_sec.c b/drivers/net/cnxk/cn10k_ethdev_sec.c
index 9a831634da..b54795565d 100644
--- a/drivers/net/cnxk/cn10k_ethdev_sec.c
+++ b/drivers/net/cnxk/cn10k_ethdev_sec.c
@@ -1184,6 +1184,24 @@  rte_pmd_cnxk_hw_sa_write(void *device, struct rte_security_session *sess,
 	return 0;
 }
 
+void *
+rte_pmd_cnxk_inl_ipsec_res(struct rte_mbuf *mbuf)
+{
+	const union nix_rx_parse_u *rx;
+	uint16_t desc_size;
+	uintptr_t wqe;
+
+	if (!mbuf || !(mbuf->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD))
+		return NULL;
+
+	wqe = (uintptr_t)(mbuf + 1);
+	rx = (const union nix_rx_parse_u *)(wqe + 8);
+	desc_size = (rx->desc_sizem1 + 1) * 16;
+
+	/* cpt_res_s sits after SG list at 16B aligned address */
+	return (void *)(wqe + 64 + desc_size);
+}
+
 static int
 cn10k_eth_sec_session_stats_get(void *device, struct rte_security_session *sess,
 			    struct rte_security_stats *stats)
diff --git a/drivers/net/cnxk/rte_pmd_cnxk.h b/drivers/net/cnxk/rte_pmd_cnxk.h
index d7eadd582d..7827c33ac9 100644
--- a/drivers/net/cnxk/rte_pmd_cnxk.h
+++ b/drivers/net/cnxk/rte_pmd_cnxk.h
@@ -96,4 +96,21 @@  int rte_pmd_cnxk_hw_sa_read(void *device, struct rte_security_session *sess,
 __rte_experimental
 int rte_pmd_cnxk_hw_sa_write(void *device, struct rte_security_session *sess,
 			     void *data, uint32_t len);
+
+/**
+ * Get pointer to CPT result info for inline inbound processed pkt.
+ *
+ * It is recommended to use this API only when mbuf indicates packet
+ * was processed with inline IPsec and there was a failure with the same i.e
+ * mbuf->ol_flags indicates (RTE_MBUF_F_RX_SEC_OFFLOAD | RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED).
+ *
+ * @param mbuf
+ *   Pointer to packet that was just received and was processed with Inline IPsec.
+ *
+ * @return
+ *   - Pointer to mbuf location where CPT result info is stored on success.
+ *   - NULL on failure.
+ */
+__rte_experimental
+void *rte_pmd_cnxk_inl_ipsec_res(struct rte_mbuf *mbuf);
 #endif /* _PMD_CNXK_H_ */
diff --git a/drivers/net/cnxk/version.map b/drivers/net/cnxk/version.map
index 7ae6d80bf0..77f574bb16 100644
--- a/drivers/net/cnxk/version.map
+++ b/drivers/net/cnxk/version.map
@@ -3,10 +3,14 @@  DPDK_24 {
 };
 
 EXPERIMENTAL {
+	global:
+
 	# added in 22.07
-	global:
 	rte_pmd_cnxk_hw_sa_read;
 	rte_pmd_cnxk_hw_sa_write;
+
+	# added in 23.11
+	rte_pmd_cnxk_inl_ipsec_res;
 };
 
 INTERNAL {