diff mbox series

[02/15] crypto: add total raw buffer length

Message ID 20210825071510.7913-3-hemant.agrawal@nxp.com
State Superseded
Headers show
Series crypto: add raw vector support in DPAAx | expand

Commit Message

Hemant Agrawal Aug. 25, 2021, 7:14 a.m. UTC
From: Gagandeep Singh <g.singh@nxp.com>


The current crypto raw data vectors is extended to support
rte_security usecases, where we need total data length to know
how much additional memory space is available in buffer other
than data length so that driver/HW can write expanded size
data after encryption.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>

---
 lib/cryptodev/rte_crypto_sym.h | 6 ++++++
 1 file changed, 6 insertions(+)

-- 
2.17.1

Comments

Akhil Goyal Sept. 6, 2021, 6:36 p.m. UTC | #1
> From: Gagandeep Singh <g.singh@nxp.com>

> 

> The current crypto raw data vectors is extended to support

> rte_security usecases, where we need total data length to know

> how much additional memory space is available in buffer other

> than data length so that driver/HW can write expanded size

> data after encryption.

> 

> Signed-off-by: Gagandeep Singh <g.singh@nxp.com>

> ---

Acked-by: Akhil Goyal <gakhil@marvell.com>
diff mbox series

Patch

diff --git a/lib/cryptodev/rte_crypto_sym.h b/lib/cryptodev/rte_crypto_sym.h
index dcc0bd5933..e5cef1fb72 100644
--- a/lib/cryptodev/rte_crypto_sym.h
+++ b/lib/cryptodev/rte_crypto_sym.h
@@ -37,6 +37,8 @@  struct rte_crypto_vec {
 	rte_iova_t iova;
 	/** length of the data buffer */
 	uint32_t len;
+	/** total buffer length*/
+	uint32_t tot_len;
 };
 
 /**
@@ -980,12 +982,14 @@  rte_crypto_mbuf_to_vec(const struct rte_mbuf *mb, uint32_t ofs, uint32_t len,
 	seglen = mb->data_len - ofs;
 	if (len <= seglen) {
 		vec[0].len = len;
+		vec[0].tot_len = mb->buf_len;
 		return 1;
 	}
 
 	/* data spread across segments */
 	vec[0].len = seglen;
 	left = len - seglen;
+	vec[0].tot_len = mb->buf_len;
 	for (i = 1, nseg = mb->next; nseg != NULL; nseg = nseg->next, i++) {
 
 		vec[i].base = rte_pktmbuf_mtod(nseg, void *);
@@ -995,6 +999,7 @@  rte_crypto_mbuf_to_vec(const struct rte_mbuf *mb, uint32_t ofs, uint32_t len,
 		if (left <= seglen) {
 			/* whole requested data is completed */
 			vec[i].len = left;
+			vec[i].tot_len = mb->buf_len;
 			left = 0;
 			break;
 		}
@@ -1002,6 +1007,7 @@  rte_crypto_mbuf_to_vec(const struct rte_mbuf *mb, uint32_t ofs, uint32_t len,
 		/* use whole segment */
 		vec[i].len = seglen;
 		left -= seglen;
+		vec[i].tot_len = mb->buf_len;
 	}
 
 	RTE_ASSERT(left == 0);