Skip to contentSkip to conversation

common/cnxk: set inplace bit of lookaside IPsec

PATCH New Tejasree Kondoj 1 participant 7 messages Oct 19, 2022 1 message not in the archive Crypto API

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/13 crypto/cnxk: fix length of AES-CMAC algo

AES-CMAC uses PDCP opcode. Length should be passed in bits.

Fixes 759b5e653580 ("crypto/cnxk: support AES-CMAC")
---
 drivers/crypto/cnxk/cnxk_se.h | 3 +++
 1 file changed, 3 insertions(+)
drivers/crypto/cnxk/cnxk_se.h +3 -0
index 54a78d0a5a..c92e2cca2f 100644
@@ -1323,6 +1323,9 @@ cpt_pdcp_alg_prep(uint32_t req_flags, uint64_t d_offs, uint64_t d_lens,
 			auth_offset += iv_len;
 
 			inputlen = auth_offset + auth_data_len;
+
+			/* length should be in bits */
+			auth_data_len *= 8;
 		}
 
 		outputlen = mac_len;
Signature · 1 line
2.25.1
#2 lore raw

PATCH 2/13 common/cnxk: set inplace bit of lookaside IPsec

In reply to a message not in the archive

Set inplace bit of lookaside IPsec and remove
rptr population in datapath.

---
 drivers/common/cnxk/roc_ie_on.h          | 1 +
 drivers/common/cnxk/roc_ie_ot.h          | 2 ++
 drivers/crypto/cnxk/cn10k_ipsec.c        | 4 ++--
 drivers/crypto/cnxk/cn10k_ipsec_la_ops.h | 2 --
 drivers/crypto/cnxk/cn9k_ipsec.c         | 4 ++--
 drivers/crypto/cnxk/cn9k_ipsec_la_ops.h  | 3 +--
 6 files changed, 8 insertions(+), 8 deletions(-)
drivers/common/cnxk/roc_ie_on.h +1 -0
index 961d5fc95e..5d02684e34 100644
@@ -30,6 +30,7 @@ enum roc_ie_on_ucc_ipsec {
 #define ROC_IE_ON_INB_RPTR_HDR 16
 #define ROC_IE_ON_MAX_IV_LEN   16
 #define ROC_IE_ON_PER_PKT_IV   BIT(43)
+#define ROC_IE_ON_INPLACE_BIT  BIT(6)
 
 enum {
 	ROC_IE_ON_SA_ENC_NULL = 0,
drivers/common/cnxk/roc_ie_ot.h +2 -0
index 56a1e9f1d6..722fbc1ddc 100644
@@ -18,6 +18,8 @@
 #define ROC_IE_OT_CPT_TS_PKIND	  54
 #define ROC_IE_OT_SA_CTX_HDR_SIZE 1
 
+#define ROC_IE_OT_INPLACE_BIT BIT(6)
+
 enum roc_ie_ot_ucc_ipsec {
 	ROC_IE_OT_UCC_SUCCESS = 0x00,
 	ROC_IE_OT_UCC_ERR_SA_INVAL = 0xb0,
drivers/crypto/cnxk/cn10k_ipsec.c +2 -2
index ef013c8bae..1740a73c36 100644
@@ -99,7 +99,7 @@ cn10k_ipsec_outb_sa_create(struct roc_cpt *roc_cpt, struct roc_cpt_lf *lf,
 
 	/* pre-populate CPT INST word 4 */
 	inst_w4.u64 = 0;
-	inst_w4.s.opcode_major = ROC_IE_OT_MAJOR_OP_PROCESS_OUTBOUND_IPSEC;
+	inst_w4.s.opcode_major = ROC_IE_OT_MAJOR_OP_PROCESS_OUTBOUND_IPSEC | ROC_IE_OT_INPLACE_BIT;
 
 	param1.u16 = 0;
 
@@ -193,7 +193,7 @@ cn10k_ipsec_inb_sa_create(struct roc_cpt *roc_cpt, struct roc_cpt_lf *lf,
 
 	/* pre-populate CPT INST word 4 */
 	inst_w4.u64 = 0;
-	inst_w4.s.opcode_major = ROC_IE_OT_MAJOR_OP_PROCESS_INBOUND_IPSEC;
+	inst_w4.s.opcode_major = ROC_IE_OT_MAJOR_OP_PROCESS_INBOUND_IPSEC | ROC_IE_OT_INPLACE_BIT;
 
 	param1.u16 = 0;
 
drivers/crypto/cnxk/cn10k_ipsec_la_ops.h +0 -2
index a75e88cb28..084198b5bb 100644
@@ -83,7 +83,6 @@ process_outb_sa(struct roc_cpt_lf *lf, struct rte_crypto_op *cop, struct cn10k_s
 	inst->w4.u64 = inst_w4_u64 | rte_pktmbuf_pkt_len(m_src);
 	dptr = rte_pktmbuf_mtod(m_src, uint64_t);
 	inst->dptr = dptr;
-	inst->rptr = dptr;
 
 	return 0;
 }
@@ -99,7 +98,6 @@ process_inb_sa(struct rte_crypto_op *cop, struct cn10k_sec_session *sess, struct
 	inst->w4.u64 = sess->inst.w4 | rte_pktmbuf_pkt_len(m_src);
 	dptr = rte_pktmbuf_mtod(m_src, uint64_t);
 	inst->dptr = dptr;
-	inst->rptr = dptr;
 
 	return 0;
 }
drivers/crypto/cnxk/cn9k_ipsec.c +2 -2
index 5f3a74107b..55a13570ad 100644
@@ -87,7 +87,7 @@ cn9k_ipsec_outb_sa_create(struct cnxk_cpt_qp *qp,
 		return ret;
 
 	w4.u64 = 0;
-	w4.s.opcode_major = ROC_IE_ON_MAJOR_OP_PROCESS_OUTBOUND_IPSEC;
+	w4.s.opcode_major = ROC_IE_ON_MAJOR_OP_PROCESS_OUTBOUND_IPSEC | ROC_IE_ON_INPLACE_BIT;
 	w4.s.opcode_minor = ctx_len >> 3;
 
 	param1.u16 = 0;
@@ -174,7 +174,7 @@ cn9k_ipsec_inb_sa_create(struct cnxk_cpt_qp *qp,
 		return ret;
 
 	w4.u64 = 0;
-	w4.s.opcode_major = ROC_IE_ON_MAJOR_OP_PROCESS_INBOUND_IPSEC;
+	w4.s.opcode_major = ROC_IE_ON_MAJOR_OP_PROCESS_INBOUND_IPSEC | ROC_IE_ON_INPLACE_BIT;
 	w4.s.opcode_minor = ctx_len >> 3;
 
 	param2.u16 = 0;
drivers/crypto/cnxk/cn9k_ipsec_la_ops.h +1 -2
index 8b4e636c70..52618e8840 100644
@@ -82,7 +82,6 @@ process_outb_sa(struct rte_crypto_op *cop, struct cn9k_sec_session *sess, struct
 	/* Prepare CPT instruction */
 	inst->w4.u64 = sess->inst.w4 | dlen;
 	inst->dptr = PLT_U64_CAST(hdr);
-	inst->rptr = PLT_U64_CAST(hdr);
 	inst->w7.u64 = sess->inst.w7;
 
 	return 0;
@@ -96,7 +95,7 @@ process_inb_sa(struct rte_crypto_op *cop, struct cn9k_sec_session *sess, struct
 
 	/* Prepare CPT instruction */
 	inst->w4.u64 = sess->inst.w4 | rte_pktmbuf_pkt_len(m_src);
-	inst->dptr = inst->rptr = rte_pktmbuf_mtod(m_src, uint64_t);
+	inst->dptr = rte_pktmbuf_mtod(m_src, uint64_t);
 	inst->w7.u64 = sess->inst.w7;
 }
 #endif /* __CN9K_IPSEC_LA_OPS_H__ */
Signature · 1 line
2.25.1
#3 lore raw

PATCH 3/13 crypto/cnxk: change capabilities as per firmware

In reply to a message not in the archive

Changing CPT engine capabilities structure as per
microcode.

---
 drivers/common/cnxk/roc_mbox.h           | 5 ++++-
 drivers/crypto/cnxk/cnxk_cryptodev_ops.c | 4 +---
 2 files changed, 5 insertions(+), 4 deletions(-)
drivers/common/cnxk/roc_mbox.h +4 -1
index 66a1be387d..9b57b934b1 100644
@@ -1517,7 +1517,10 @@ union cpt_eng_caps {
 		uint64_t __io kasumi : 1;
 		uint64_t __io des : 1;
 		uint64_t __io crc : 1;
-		uint64_t __io reserved_14_63 : 50;
+		uint64_t __io mmul : 1;
+		uint64_t __io reserved_15_33 : 19;
+		uint64_t __io pdcp_chain : 1;
+		uint64_t __io reserved_35_63 : 29;
 	};
 };
 
drivers/crypto/cnxk/cnxk_cryptodev_ops.c +1 -3
index a5233a942a..e0ceaa32d5 100644
@@ -449,9 +449,7 @@ cnxk_sess_fill(struct roc_cpt *roc_cpt, struct rte_crypto_sym_xform *xform,
 	bool pdcp_chain_supported = false;
 	bool ciph_then_auth = false;
 
-	if (roc_cpt->cpt_revision == ROC_CPT_REVISION_ID_96XX_B0 ||
-	    roc_cpt->cpt_revision == ROC_CPT_REVISION_ID_96XX_C0 ||
-	    roc_cpt->cpt_revision == ROC_CPT_REVISION_ID_98XX)
+	if (roc_cpt->hw_caps[CPT_ENG_TYPE_SE].pdcp_chain)
 		pdcp_chain_supported = true;
 
 	if (xform == NULL)
Signature · 1 line
2.25.1
#4 lore raw

PATCH 4/13 common/cnxk: support 103XX CPT

In reply to a message not in the archive

Adding support for 103XX CPT.

---
 drivers/common/cnxk/hw/cpt.h              |   26 +-
 drivers/common/cnxk/roc_se.h              |   11 +
 drivers/crypto/cnxk/cn10k_cryptodev.c     |    2 +-
 drivers/crypto/cnxk/cn10k_cryptodev_ops.c |   67 +-
 drivers/crypto/cnxk/cn10k_cryptodev_ops.h |    9 +-
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c  |    4 +-
 drivers/crypto/cnxk/cnxk_se.h             | 1602 +++++++++++----------
 drivers/crypto/cnxk/version.map           |    3 +-
 drivers/event/cnxk/cn10k_eventdev.c       |   13 +-
 9 files changed, 926 insertions(+), 811 deletions(-)
drivers/common/cnxk/hw/cpt.h +24 -2
index 3c87a0d1e4..ff5aa46f64 100644
@@ -157,6 +157,22 @@ union cpt_inst_w4 {
 	} s;
 };
 
+union cpt_inst_w5 {
+	uint64_t u64;
+	struct {
+		uint64_t dptr : 60;
+		uint64_t gather_sz : 4;
+	} s;
+};
+
+union cpt_inst_w6 {
+	uint64_t u64;
+	struct {
+		uint64_t rptr : 60;
+		uint64_t scatter_sz : 4;
+	} s;
+};
+
 union cpt_inst_w7 {
 	uint64_t u64;
 	struct {
@@ -200,9 +216,15 @@ struct cpt_inst_s {
 
 	union cpt_inst_w4 w4;
 
-	uint64_t dptr;
+	union {
+		union cpt_inst_w5 w5;
+		uint64_t dptr;
+	};
 
-	uint64_t rptr;
+	union {
+		union cpt_inst_w6 w6;
+		uint64_t rptr;
+	};
 
 	union cpt_inst_w7 w7;
 };
drivers/common/cnxk/roc_se.h +11 -0
index e70a197d4f..c357c19c0b 100644
@@ -183,6 +183,17 @@ struct roc_se_sglist_comp {
 	uint64_t ptr[4];
 };
 
+struct roc_se_sg2list_comp {
+	union {
+		uint64_t len;
+		struct {
+			uint16_t len[3];
+			uint16_t valid_segs;
+		} s;
+	} u;
+	uint64_t ptr[3];
+};
+
 struct roc_se_enc_context {
 	uint64_t iv_source : 1;
 	uint64_t aes_key : 2;
drivers/crypto/cnxk/cn10k_cryptodev.c +1 -1
index db11ac7444..52de9b9657 100644
@@ -99,7 +99,7 @@ cn10k_cpt_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	dev->driver_id = cn10k_cryptodev_driver_id;
 	dev->feature_flags = cnxk_cpt_default_ff_get();
 
-	cn10k_cpt_set_enqdeq_fns(dev);
+	cn10k_cpt_set_enqdeq_fns(dev, vf);
 	cn10k_sec_ops_override();
 
 	rte_cryptodev_pmd_probing_finish(dev);
drivers/crypto/cnxk/cn10k_cryptodev_ops.c +47 -20

154 lines not on this page · raw message

drivers/crypto/cnxk/cn10k_cryptodev_ops.h +7 -2
index 8104310c30..3d7c6d195a 100644
@@ -9,12 +9,17 @@
 #include <rte_cryptodev.h>
 #include <rte_eventdev.h>
 
+#include "cnxk_cryptodev.h"
+
 extern struct rte_cryptodev_ops cn10k_cpt_ops;
 
-void cn10k_cpt_set_enqdeq_fns(struct rte_cryptodev *dev);
+void cn10k_cpt_set_enqdeq_fns(struct rte_cryptodev *dev, struct cnxk_cpt_vf *vf);
 
 __rte_internal
-uint16_t __rte_hot cn10k_cpt_crypto_adapter_enqueue(void *ws, struct rte_event ev[],
+uint16_t __rte_hot cn10k_cpt_sg_ver1_crypto_adapter_enqueue(void *ws, struct rte_event ev[],
+		uint16_t nb_events);
+__rte_internal
+uint16_t __rte_hot cn10k_cpt_sg_ver2_crypto_adapter_enqueue(void *ws, struct rte_event ev[],
 		uint16_t nb_events);
 __rte_internal
 uintptr_t cn10k_cpt_crypto_adapter_dequeue(uintptr_t get_work1);
drivers/crypto/cnxk/cn9k_cryptodev_ops.c +2 -2
index 289601330e..2a5c00eadd 100644
@@ -91,7 +91,7 @@ cn9k_cpt_inst_prep(struct cnxk_cpt_qp *qp, struct rte_crypto_op *op,
 		if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
 			sym_op = op->sym;
 			sess = CRYPTODEV_GET_SYM_SESS_PRIV(sym_op->session);
-			ret = cpt_sym_inst_fill(qp, op, sess, infl_req, inst);
+			ret = cpt_sym_inst_fill(qp, op, sess, infl_req, inst, false);
 			inst->w7.u64 = sess->cpt_inst_w7;
 		} else if (op->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION)
 			ret = cn9k_cpt_sec_inst_fill(op, infl_req, inst);
@@ -102,7 +102,7 @@ cn9k_cpt_inst_prep(struct cnxk_cpt_qp *qp, struct rte_crypto_op *op,
 				return -1;
 			}
 
-			ret = cpt_sym_inst_fill(qp, op, sess, infl_req, inst);
+			ret = cpt_sym_inst_fill(qp, op, sess, infl_req, inst, false);
 			if (unlikely(ret)) {
 				sym_session_clear(op->sym->session);
 				rte_mempool_put(qp->sess_mp, op->sym->session);
drivers/crypto/cnxk/cnxk_se.h +824 -778

1,905 lines not on this page · raw message

drivers/crypto/cnxk/version.map +2 -1
index 4735e70550..d13209feec 100644
@@ -3,7 +3,8 @@ INTERNAL {
 
 	cn9k_cpt_crypto_adapter_enqueue;
 	cn9k_cpt_crypto_adapter_dequeue;
-	cn10k_cpt_crypto_adapter_enqueue;
+	cn10k_cpt_sg_ver1_crypto_adapter_enqueue;
+	cn10k_cpt_sg_ver2_crypto_adapter_enqueue;
 	cn10k_cpt_crypto_adapter_dequeue;
 	cn10k_cpt_crypto_adapter_vector_dequeue;
 
drivers/event/cnxk/cn10k_eventdev.c +8 -5
index 742e43a5c6..30c922b5fc 100644
@@ -292,6 +292,7 @@ static void
 cn10k_sso_fp_fns_set(struct rte_eventdev *event_dev)
 {
 	struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
+	struct roc_cpt *cpt = roc_idev_cpt_get();
 	const event_dequeue_t sso_hws_deq[NIX_RX_OFFLOAD_MAX] = {
 #define R(name, flags)[flags] = cn10k_sso_hws_deq_##name,
 		NIX_RX_FASTPATH_MODES
@@ -594,14 +595,16 @@ cn10k_sso_fp_fns_set(struct rte_eventdev *event_dev)
 			}
 		}
 	}
-	event_dev->ca_enqueue = cn10k_cpt_crypto_adapter_enqueue;
+
+	if ((cpt != NULL) && (cpt->cpt_revision > ROC_CPT_REVISION_ID_106XX))
+		event_dev->ca_enqueue = cn10k_cpt_sg_ver2_crypto_adapter_enqueue;
+	else
+		event_dev->ca_enqueue = cn10k_cpt_sg_ver1_crypto_adapter_enqueue;
 
 	if (dev->tx_offloads & NIX_TX_MULTI_SEG_F)
-		CN10K_SET_EVDEV_ENQ_OP(dev, event_dev->txa_enqueue,
-				       sso_hws_tx_adptr_enq_seg);
+		CN10K_SET_EVDEV_ENQ_OP(dev, event_dev->txa_enqueue, sso_hws_tx_adptr_enq_seg);
 	else
-		CN10K_SET_EVDEV_ENQ_OP(dev, event_dev->txa_enqueue,
-				       sso_hws_tx_adptr_enq);
+		CN10K_SET_EVDEV_ENQ_OP(dev, event_dev->txa_enqueue, sso_hws_tx_adptr_enq);
 
 	event_dev->txa_enqueue_same_dest = event_dev->txa_enqueue;
 }
Signature · 1 line
2.25.1
#5 lore raw

PATCH 5/13 common/cnxk: support custom UDP port values

In reply to a message not in the archive

From: Vidya Sagar Velumuri <[email protected]>

Add support for custom port values for UDP encapsulation

---
 drivers/common/cnxk/cnxk_security.c | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)
drivers/common/cnxk/cnxk_security.c +18 -8
index f8bdeabeac..f220d2577f 100644
@@ -1219,6 +1219,7 @@ cnxk_on_ipsec_outb_sa_create(struct rte_security_ipsec_xform *ipsec,
 	struct rte_ipv6_hdr *ip6;
 	struct rte_ipv4_hdr *ip4;
 	const uint8_t *auth_key;
+	uint16_t sport, dport;
 	int auth_key_len = 0;
 	size_t ctx_len;
 	int ret;
@@ -1266,10 +1267,20 @@ cnxk_on_ipsec_outb_sa_create(struct rte_security_ipsec_xform *ipsec,
 	}
 
 	ip4 = (struct rte_ipv4_hdr *)&template->ip4.ipv4_hdr;
+	/* If custom port values are provided, Overwrite default port values. */
 	if (ipsec->options.udp_encap) {
+		sport = 4500;
+		dport = 4500;
+
+		if (ipsec->udp.sport)
+			sport = ipsec->udp.sport;
+
+		if (ipsec->udp.dport)
+			dport = ipsec->udp.dport;
+
 		ip4->next_proto_id = IPPROTO_UDP;
-		template->ip4.udp_src = rte_be_to_cpu_16(4500);
-		template->ip4.udp_dst = rte_be_to_cpu_16(4500);
+		template->ip4.udp_src = rte_be_to_cpu_16(sport);
+		template->ip4.udp_dst = rte_be_to_cpu_16(dport);
 	} else {
 		if (ipsec->proto == RTE_SECURITY_IPSEC_SA_PROTO_AH)
 			ip4->next_proto_id = IPPROTO_AH;
@@ -1303,13 +1314,12 @@ cnxk_on_ipsec_outb_sa_create(struct rte_security_ipsec_xform *ipsec,
 			ip6 = (struct rte_ipv6_hdr *)&template->ip6.ipv6_hdr;
 			if (ipsec->options.udp_encap) {
 				ip6->proto = IPPROTO_UDP;
-				template->ip6.udp_src = rte_be_to_cpu_16(4500);
-				template->ip6.udp_dst = rte_be_to_cpu_16(4500);
+				template->ip6.udp_src = rte_be_to_cpu_16(sport);
+				template->ip6.udp_dst = rte_be_to_cpu_16(dport);
 			} else {
-				ip6->proto = (ipsec->proto ==
-					      RTE_SECURITY_IPSEC_SA_PROTO_ESP) ?
-						     IPPROTO_ESP :
-						     IPPROTO_AH;
+				ip6->proto = (ipsec->proto == RTE_SECURITY_IPSEC_SA_PROTO_ESP) ?
+							      IPPROTO_ESP :
+							      IPPROTO_AH;
 			}
 			ip6->vtc_flow =
 				rte_cpu_to_be_32(0x60000000 |
Signature · 1 line
2.25.1
#6 lore raw

PATCH 6/13 crypto/cnxk: update rlen calculation for lookaside mode

In reply to a message not in the archive

From: Vidya Sagar Velumuri <[email protected]>

For transport mode, IP header will not be part of encryption. Update the response len calculation accordingly for transport mode

---
 drivers/crypto/cnxk/cn9k_ipsec.c        | 42 -------------------------
 drivers/crypto/cnxk/cn9k_ipsec_la_ops.h | 10 ++++--
 2 files changed, 7 insertions(+), 45 deletions(-)
drivers/crypto/cnxk/cn9k_ipsec.c +0 -42
index 55a13570ad..9ae7c73b37 100644
@@ -211,50 +211,8 @@ cn9k_ipsec_xform_verify(struct rte_security_ipsec_xform *ipsec,
 				plt_err("Transport mode AES-256-GCM is not supported");
 				return -ENOTSUP;
 			}
-		} else {
-			struct rte_crypto_cipher_xform *cipher;
-			struct rte_crypto_auth_xform *auth;
-
-			if (crypto->type == RTE_CRYPTO_SYM_XFORM_CIPHER) {
-				cipher = &crypto->cipher;
-				auth = &crypto->next->auth;
-			} else {
-				cipher = &crypto->next->cipher;
-				auth = &crypto->auth;
-			}
-
-			if ((cipher->algo == RTE_CRYPTO_CIPHER_AES_CBC) &&
-			    (auth->algo == RTE_CRYPTO_AUTH_SHA256_HMAC)) {
-				plt_err("Transport mode AES-CBC SHA2 HMAC 256 is not supported");
-				return -ENOTSUP;
-			}
-
-			if ((cipher->algo == RTE_CRYPTO_CIPHER_AES_CBC) &&
-			    (auth->algo == RTE_CRYPTO_AUTH_SHA384_HMAC)) {
-				plt_err("Transport mode AES-CBC SHA2 HMAC 384 is not supported");
-				return -ENOTSUP;
-			}
-
-			if ((cipher->algo == RTE_CRYPTO_CIPHER_AES_CBC) &&
-			    (auth->algo == RTE_CRYPTO_AUTH_SHA512_HMAC)) {
-				plt_err("Transport mode AES-CBC SHA2 HMAC 512 is not supported");
-				return -ENOTSUP;
-			}
-
-			if ((cipher->algo == RTE_CRYPTO_CIPHER_AES_CBC) &&
-			    (auth->algo == RTE_CRYPTO_AUTH_AES_XCBC_MAC)) {
-				plt_err("Transport mode AES-CBC AES-XCBC is not supported");
-				return -ENOTSUP;
-			}
-
-			if ((cipher->algo == RTE_CRYPTO_CIPHER_3DES_CBC) &&
-			    (auth->algo == RTE_CRYPTO_AUTH_AES_XCBC_MAC)) {
-				plt_err("Transport mode 3DES-CBC AES-XCBC is not supported");
-				return -ENOTSUP;
-			}
 		}
 	}
-
 	return 0;
 }
 
drivers/crypto/cnxk/cn9k_ipsec_la_ops.h +7 -3
index 52618e8840..724fc525ad 100644
@@ -16,11 +16,15 @@ static __rte_always_inline int32_t
 ipsec_po_out_rlen_get(struct cn9k_sec_session *sess, uint32_t plen)
 {
 	uint32_t enc_payload_len;
+	int adj_len = 0;
 
-	enc_payload_len = RTE_ALIGN_CEIL(plen + sess->rlens.roundup_len,
-					 sess->rlens.roundup_byte);
+	if (sess->sa.out_sa.common_sa.ctl.ipsec_mode == ROC_IE_SA_MODE_TRANSPORT)
+		adj_len = ROC_CPT_TUNNEL_IPV4_HDR_LEN;
 
-	return sess->custom_hdr_len + sess->rlens.partial_len + enc_payload_len;
+	enc_payload_len =
+		RTE_ALIGN_CEIL(plen + sess->rlens.roundup_len - adj_len, sess->rlens.roundup_byte);
+
+	return sess->custom_hdr_len + sess->rlens.partial_len + enc_payload_len + adj_len;
 }
 
 static __rte_always_inline int
Signature · 1 line
2.25.1
#7 lore raw

PATCH 7/13 crypto/cnxk: add support for DES and MD5

In reply to a message not in the archive

From: Vidya Sagar Velumuri <[email protected]>

Add supoort for cipher DES and auth MD5 for IPsec offload

---
 drivers/crypto/cnxk/cnxk_cryptodev.h          |  2 +-
 .../crypto/cnxk/cnxk_cryptodev_capabilities.c | 42 ++++++++++++++++++-
 drivers/crypto/cnxk/cnxk_ipsec.h              |  9 ++++
 3 files changed, 51 insertions(+), 2 deletions(-)
drivers/crypto/cnxk/cnxk_cryptodev.h +1 -1
index 588760cfb0..48bd6e144c 100644
@@ -11,7 +11,7 @@
 #include "roc_cpt.h"
 
 #define CNXK_CPT_MAX_CAPS	 37
-#define CNXK_SEC_CRYPTO_MAX_CAPS 14
+#define CNXK_SEC_CRYPTO_MAX_CAPS 16
 #define CNXK_SEC_MAX_CAPS	 9
 #define CNXK_AE_EC_ID_MAX	 8
 /**
drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c +41 -1

60 lines not on this page · raw message

drivers/crypto/cnxk/cnxk_ipsec.h +9 -0
index 00873ca6ac..0c471b2cfe 100644
@@ -23,6 +23,10 @@ ipsec_xform_cipher_verify(struct rte_crypto_sym_xform *crypto_xform)
 	if (crypto_xform->cipher.algo == RTE_CRYPTO_CIPHER_NULL)
 		return 0;
 
+	if (crypto_xform->cipher.algo == RTE_CRYPTO_CIPHER_DES_CBC &&
+	    crypto_xform->cipher.key.length == 8)
+		return 0;
+
 	if (crypto_xform->cipher.algo == RTE_CRYPTO_CIPHER_AES_CBC ||
 	    crypto_xform->cipher.algo == RTE_CRYPTO_CIPHER_AES_CTR) {
 		switch (crypto_xform->cipher.key.length) {
@@ -51,6 +55,11 @@ ipsec_xform_auth_verify(struct rte_crypto_sym_xform *crypto_xform)
 	if (crypto_xform->auth.algo == RTE_CRYPTO_AUTH_NULL)
 		return 0;
 
+	if (crypto_xform->auth.algo == RTE_CRYPTO_AUTH_MD5_HMAC) {
+		if (keylen == 16)
+			return 0;
+	}
+
 	if (crypto_xform->auth.algo == RTE_CRYPTO_AUTH_SHA1_HMAC) {
 		if (keylen >= 20 && keylen <= 64)
 			return 0;
Signature · 1 line
2.25.1