From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 40107A0C46; Tue, 31 Aug 2021 15:09:01 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3436440E01; Tue, 31 Aug 2021 15:08:57 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id B740440687 for ; Tue, 31 Aug 2021 15:08:55 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 17VCLwru027724 for ; Tue, 31 Aug 2021 06:08:55 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=+xFZ6UE9jbHlQCEP8KUeRBjuJE/tGZMCYUGetnQxsKY=; b=Jm5+2q7D1BzYQjXcSZdZlZjkWCF0p/ZrBDMP9zam/DY2EvcnRYfZEIoht4QL+sl5Q7S3 cHaUocrnXCaNsv0YEXIgw10wAkPniqtXHkwC7D2NNJBbNz+kpi1SbVkpj+iR9CNo9u3m EygfPOdrFRZwjmw3c90qbeGxLESyTZWFb7LkCRoH2cLD3KpFkX0xoCp/KfzYme7NkNsc 8fW5BCftHU64pJg+rcCK69JtcYCyo1SXJloX1ZaaqZoekBBbGYrz7rJ5TRaf3CEBzfl2 R40TwfiFcHDmkZgxXfpP3rhJdk99kagxyd/MJxh9ghIP5U8QObMjB846oQcDiyr9PK/k gQ== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com with ESMTP id 3asf15hhsm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Tue, 31 Aug 2021 06:08:55 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 31 Aug 2021 06:08:52 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Tue, 31 Aug 2021 06:08:53 -0700 Received: from hyd1554T5810.caveonetworks.com.com (unknown [10.29.57.11]) by maili.marvell.com (Postfix) with ESMTP id D0FA95B6925; Tue, 31 Aug 2021 06:08:49 -0700 (PDT) From: Tejasree Kondoj To: Akhil Goyal CC: Archana Muniganti , Anoob Joseph , Ankur Dwivedi , Srujana Challa , Nithin Dabilpuram , "Jerin Jacob" , Tejasree Kondoj , Date: Tue, 31 Aug 2021 19:31:27 +0530 Message-ID: <20210831140127.31775-9-ktejasree@marvell.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210831140127.31775-1-ktejasree@marvell.com> References: <20210831140127.31775-1-ktejasree@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: gPJH_AxODt8jj9S67Jx4XJB-9F_j0Nhn X-Proofpoint-GUID: gPJH_AxODt8jj9S67Jx4XJB-9F_j0Nhn X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-08-31_05,2021-08-31_01,2020-04-07_01 Subject: [dpdk-dev] [PATCH 8/8] common/cnxk: make IPsec defines common X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Archana Muniganti Make IPsec defines common and remove redundant macros. Signed-off-by: Archana Muniganti --- drivers/common/cnxk/cnxk_security.c | 24 +++++++++-------- drivers/common/cnxk/roc_api.h | 1 + drivers/common/cnxk/roc_ie.h | 33 ++++++++++++++++------- drivers/common/cnxk/roc_ie_on.h | 26 ------------------ drivers/common/cnxk/roc_ie_ot.h | 26 ------------------ drivers/crypto/cnxk/cn10k_cryptodev_ops.c | 4 ++- 6 files changed, 41 insertions(+), 73 deletions(-) diff --git a/drivers/common/cnxk/cnxk_security.c b/drivers/common/cnxk/cnxk_security.c index fe64e70c81..4f7fd1b3a0 100644 --- a/drivers/common/cnxk/cnxk_security.c +++ b/drivers/common/cnxk/cnxk_security.c @@ -6,6 +6,8 @@ #include "cnxk_security.h" +#include "roc_api.h" + static void ipsec_hmac_opad_ipad_gen(struct rte_crypto_sym_xform *auth_xform, uint8_t *hmac_opad_ipad) @@ -51,12 +53,12 @@ ot_ipsec_sa_common_param_fill(union roc_ot_ipsec_sa_word2 *w2, /* Set direction */ switch (ipsec_xfrm->direction) { case RTE_SECURITY_IPSEC_SA_DIR_INGRESS: - w2->s.dir = ROC_IE_OT_SA_DIR_INBOUND; + w2->s.dir = ROC_IE_SA_DIR_INBOUND; auth_xfrm = crypto_xfrm; cipher_xfrm = crypto_xfrm->next; break; case RTE_SECURITY_IPSEC_SA_DIR_EGRESS: - w2->s.dir = ROC_IE_OT_SA_DIR_OUTBOUND; + w2->s.dir = ROC_IE_SA_DIR_OUTBOUND; cipher_xfrm = crypto_xfrm; auth_xfrm = crypto_xfrm->next; break; @@ -67,10 +69,10 @@ ot_ipsec_sa_common_param_fill(union roc_ot_ipsec_sa_word2 *w2, /* Set protocol - ESP vs AH */ switch (ipsec_xfrm->proto) { case RTE_SECURITY_IPSEC_SA_PROTO_ESP: - w2->s.protocol = ROC_IE_OT_SA_PROTOCOL_ESP; + w2->s.protocol = ROC_IE_SA_PROTOCOL_ESP; break; case RTE_SECURITY_IPSEC_SA_PROTO_AH: - w2->s.protocol = ROC_IE_OT_SA_PROTOCOL_AH; + w2->s.protocol = ROC_IE_SA_PROTOCOL_AH; break; default: return -EINVAL; @@ -79,10 +81,10 @@ ot_ipsec_sa_common_param_fill(union roc_ot_ipsec_sa_word2 *w2, /* Set mode - transport vs tunnel */ switch (ipsec_xfrm->mode) { case RTE_SECURITY_IPSEC_SA_MODE_TRANSPORT: - w2->s.mode = ROC_IE_OT_SA_MODE_TRANSPORT; + w2->s.mode = ROC_IE_SA_MODE_TRANSPORT; break; case RTE_SECURITY_IPSEC_SA_MODE_TUNNEL: - w2->s.mode = ROC_IE_OT_SA_MODE_TUNNEL; + w2->s.mode = ROC_IE_SA_MODE_TUNNEL; break; default: return -EINVAL; @@ -147,13 +149,13 @@ ot_ipsec_sa_common_param_fill(union roc_ot_ipsec_sa_word2 *w2, switch (length) { case ROC_CPT_AES128_KEY_LEN: - w2->s.aes_key_len = ROC_IE_OT_SA_AES_KEY_LEN_128; + w2->s.aes_key_len = ROC_IE_SA_AES_KEY_LEN_128; break; case ROC_CPT_AES192_KEY_LEN: - w2->s.aes_key_len = ROC_IE_OT_SA_AES_KEY_LEN_192; + w2->s.aes_key_len = ROC_IE_SA_AES_KEY_LEN_192; break; case ROC_CPT_AES256_KEY_LEN: - w2->s.aes_key_len = ROC_IE_OT_SA_AES_KEY_LEN_256; + w2->s.aes_key_len = ROC_IE_SA_AES_KEY_LEN_256; break; default: return -EINVAL; @@ -271,7 +273,7 @@ cnxk_ot_ipsec_outb_sa_fill(struct roc_ot_ipsec_outb_sa *sa, /* Tunnel header info */ switch (tunnel->type) { case RTE_SECURITY_IPSEC_TUNNEL_IPV4: - sa->w2.s.outer_ip_ver = ROC_IE_OT_SA_IP_VERSION_4; + sa->w2.s.outer_ip_ver = ROC_IE_SA_IP_VERSION_4; memcpy(&sa->outer_hdr.ipv4.src_addr, &tunnel->ipv4.src_ip, sizeof(struct in_addr)); memcpy(&sa->outer_hdr.ipv4.dst_addr, &tunnel->ipv4.dst_ip, @@ -302,7 +304,7 @@ cnxk_ot_ipsec_outb_sa_fill(struct roc_ot_ipsec_outb_sa *sa, } break; case RTE_SECURITY_IPSEC_TUNNEL_IPV6: - sa->w2.s.outer_ip_ver = ROC_IE_OT_SA_IP_VERSION_6; + sa->w2.s.outer_ip_ver = ROC_IE_SA_IP_VERSION_6; memcpy(&sa->outer_hdr.ipv6.src_addr, &tunnel->ipv6.src_addr, sizeof(struct in6_addr)); memcpy(&sa->outer_hdr.ipv6.dst_addr, &tunnel->ipv6.dst_addr, diff --git a/drivers/common/cnxk/roc_api.h b/drivers/common/cnxk/roc_api.h index 9c06cfee9a..7dec8453b4 100644 --- a/drivers/common/cnxk/roc_api.h +++ b/drivers/common/cnxk/roc_api.h @@ -121,6 +121,7 @@ /* CPT microcode */ #include "roc_ae.h" #include "roc_ae_fpm_tables.h" +#include "roc_ie.h" #include "roc_ie_on.h" #include "roc_ie_ot.h" #include "roc_se.h" diff --git a/drivers/common/cnxk/roc_ie.h b/drivers/common/cnxk/roc_ie.h index a330ea1b50..31b83948e1 100644 --- a/drivers/common/cnxk/roc_ie.h +++ b/drivers/common/cnxk/roc_ie.h @@ -5,15 +5,30 @@ #ifndef __ROC_IE_H__ #define __ROC_IE_H__ -/* CNXK IPSEC helper macros */ -#define ROC_IE_AH_HDR_LEN 12 -#define ROC_IE_AES_GCM_IV_LEN 8 -#define ROC_IE_AES_GCM_MAC_LEN 16 -#define ROC_IE_AES_CBC_IV_LEN 16 -#define ROC_IE_SHA1_HMAC_LEN 12 -#define ROC_IE_AUTH_KEY_LEN_MAX 64 +enum { + ROC_IE_SA_DIR_INBOUND = 0, + ROC_IE_SA_DIR_OUTBOUND = 1, +}; -#define ROC_IE_AES_GCM_ROUNDUP_BYTE_LEN 4 -#define ROC_IE_AES_CBC_ROUNDUP_BYTE_LEN 16 +enum { + ROC_IE_SA_IP_VERSION_4 = 0, + ROC_IE_SA_IP_VERSION_6 = 1, +}; + +enum { + ROC_IE_SA_MODE_TRANSPORT = 0, + ROC_IE_SA_MODE_TUNNEL = 1, +}; + +enum { + ROC_IE_SA_PROTOCOL_AH = 0, + ROC_IE_SA_PROTOCOL_ESP = 1, +}; + +enum { + ROC_IE_SA_AES_KEY_LEN_128 = 1, + ROC_IE_SA_AES_KEY_LEN_192 = 2, + ROC_IE_SA_AES_KEY_LEN_256 = 3, +}; #endif /* __ROC_IE_H__ */ diff --git a/drivers/common/cnxk/roc_ie_on.h b/drivers/common/cnxk/roc_ie_on.h index 508654a9d8..222c298a53 100644 --- a/drivers/common/cnxk/roc_ie_on.h +++ b/drivers/common/cnxk/roc_ie_on.h @@ -18,32 +18,6 @@ /* Ucode completion codes */ #define ROC_IE_ONF_UCC_SUCCESS 0 -enum { - ROC_IE_ON_SA_DIR_INBOUND = 0, - ROC_IE_ON_SA_DIR_OUTBOUND = 1, -}; - -enum { - ROC_IE_ON_SA_IP_VERSION_4 = 0, - ROC_IE_ON_SA_IP_VERSION_6 = 1, -}; - -enum { - ROC_IE_ON_SA_MODE_TRANSPORT = 0, - ROC_IE_ON_SA_MODE_TUNNEL = 1, -}; - -enum { - ROC_IE_ON_SA_PROTOCOL_AH = 0, - ROC_IE_ON_SA_PROTOCOL_ESP = 1, -}; - -enum { - ROC_IE_ON_SA_AES_KEY_LEN_128 = 1, - ROC_IE_ON_SA_AES_KEY_LEN_192 = 2, - ROC_IE_ON_SA_AES_KEY_LEN_256 = 3, -}; - enum { ROC_IE_ON_SA_ENC_NULL = 0, ROC_IE_ON_SA_ENC_DES_CBC = 1, diff --git a/drivers/common/cnxk/roc_ie_ot.h b/drivers/common/cnxk/roc_ie_ot.h index aeb4be2971..3987a082a2 100644 --- a/drivers/common/cnxk/roc_ie_ot.h +++ b/drivers/common/cnxk/roc_ie_ot.h @@ -97,32 +97,6 @@ enum { ROC_IE_OT_SA_INNER_PKT_L4_CSUM_DISABLE = 1, }; -enum { - ROC_IE_OT_SA_DIR_INBOUND = 0, - ROC_IE_OT_SA_DIR_OUTBOUND = 1, -}; - -enum { - ROC_IE_OT_SA_IP_VERSION_4 = 0, - ROC_IE_OT_SA_IP_VERSION_6 = 1, -}; - -enum { - ROC_IE_OT_SA_MODE_TRANSPORT = 0, - ROC_IE_OT_SA_MODE_TUNNEL = 1, -}; - -enum { - ROC_IE_OT_SA_PROTOCOL_AH = 0, - ROC_IE_OT_SA_PROTOCOL_ESP = 1, -}; - -enum { - ROC_IE_OT_SA_AES_KEY_LEN_128 = 1, - ROC_IE_OT_SA_AES_KEY_LEN_192 = 2, - ROC_IE_OT_SA_AES_KEY_LEN_256 = 3, -}; - enum { ROC_IE_OT_SA_ENC_NULL = 0, ROC_IE_OT_SA_ENC_3DES_CBC = 2, diff --git a/drivers/crypto/cnxk/cn10k_cryptodev_ops.c b/drivers/crypto/cnxk/cn10k_cryptodev_ops.c index 780a321cf7..28055aceed 100644 --- a/drivers/crypto/cnxk/cn10k_cryptodev_ops.c +++ b/drivers/crypto/cnxk/cn10k_cryptodev_ops.c @@ -16,6 +16,8 @@ #include "cnxk_cryptodev_ops.h" #include "cnxk_se.h" +#include "roc_api.h" + static inline struct cnxk_se_sess * cn10k_cpt_sym_temp_sess_create(struct cnxk_cpt_qp *qp, struct rte_crypto_op *op) { @@ -68,7 +70,7 @@ cpt_sec_inst_fill(struct rte_crypto_op *op, struct cn10k_sec_session *sess, sa = &sess->sa; w2 = (union roc_ot_ipsec_sa_word2 *)&sa->in_sa.w2; - if (w2->s.dir == ROC_IE_OT_SA_DIR_OUTBOUND) + if (w2->s.dir == ROC_IE_SA_DIR_OUTBOUND) ret = process_outb_sa(op, sa, inst); else ret = process_inb_sa(op, sa, inst); -- 2.27.0