From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10071.outbound.protection.outlook.com [40.107.1.71]) by dpdk.org (Postfix) with ESMTP id 90C1E1B277 for ; Fri, 5 Oct 2018 15:58:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nxJKib4s6GqqK1tI21jGlddPNho0Yzow9naHG2+bxig=; b=L6f0r2LebPwVRJR6h/UG3efzAczBWOhAMM1KuWc+YWDv0XdpFZbDLiudp8gGN7ufTTwMJGSAbC2O8X/bRQ8+N9vajEQNAmJ+GjKonr2eI2FgqQREeNQt0LgvBdyyvYYl9PqHO8n4I2Xjk0VwzqmaFUZaeYqXhK+3XiSQGfHgwbM= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=akhil.goyal@nxp.com; Received: from GDB1.ap.freescale.net (14.143.30.134) by DB7PR04MB4889.eurprd04.prod.outlook.com (2603:10a6:10:18::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1207.26; Fri, 5 Oct 2018 13:58:52 +0000 From: akhil.goyal@nxp.com To: dev@dpdk.org Cc: pablo.de.lara.guarch@intel.com, radu.nicolau@intel.com, jerin.jacob@caviumnetworks.com, narayanaprasad.athreya@caviumnetworks.com, Shally.Verma@caviumnetworks.com, Anoob.Joseph@caviumnetworks.com, Vidya.Velumuri@caviumnetworks.com, hemant.agrawal@nxp.com, Akhil Goyal Date: Fri, 5 Oct 2018 19:23:18 +0530 Message-Id: <20181005135318.6350-4-akhil.goyal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181005135318.6350-1-akhil.goyal@nxp.com> References: <20181005133344.6115-1-akhil.goyal@nxp.com> <20181005135318.6350-1-akhil.goyal@nxp.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [14.143.30.134] X-ClientProxiedBy: TYAPR01CA0109.jpnprd01.prod.outlook.com (2603:1096:404:2a::25) To DB7PR04MB4889.eurprd04.prod.outlook.com (2603:10a6:10:18::20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4c2394df-cd7b-48d7-24cf-08d62acab146 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:DB7PR04MB4889; X-Microsoft-Exchange-Diagnostics: 1; DB7PR04MB4889; 3:pK/pAnIBke+b5NaNbvayXNUAkXkd/x6go7+WKe9fGoK8C4AG30VmUtkwkyx4/1xoH1UTW4a5hh9zr2Bqs2JoYGZ9lVn8tMiPpRa9VwFxsWhuQP2eQsYiHICBqAgNCI07JYrc3mcLADEae3nTYzbgjQWUV7T0F8WsIMx3rnbvJsQULQADAcMJacezDSXjDDaQYqizxYdUYaSQb9eOBgUeJTZKbGb2CEQH7ONpRgzxaO0e75VVqXcI6o7pooxBCejT; 25:hu7Hs2TME0LWSKN4K8x7KwYA2yRAOgYOP/Q9th8N20r46lw27eqmKurGdlHaQsFE3uBOW2OkeSx0TCeAbEgZkncJauu3hu/ckED8oqHD99nZiLiKGCGYyATVuCKRCVrBdi6NJnXK5ue6Irlf1LcX/7RphIlnYSyuymNpPM9hDl6Tb0fLTO/7PrJIj4nOdMAdiGxwBfLV01FQLyQTGQXBlrodPHnzzWo7+GGBmzOGxoItzxNyNrjTO27s8ufiOQrA0SXjBNDdz+Dq6WFoeAFInyOepNyF8Fl5c5uwuJ0051HbCPcug+RucAZitzdcPOIQUkxDB55TM1v65THPWMlhxg==; 31:noToM57QAN+GyxzgNDwcbAOXjt7lFfD16dM/dQVqwmirqqOnHkckVdJStV/jk4SAOCDRGG5ZBWJnpPOGO+VLQ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dSRGdkAc+B6jS5vxfBuLk+HNrGNP09JNrbfUejVgFPMfOR4rDE+ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(269456686620040)(163750095850); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231355)(944501410)(52105095)(10201501046)(3002001)(93006095)(93001095)(6055026)(149066)(150057)(6041310)(20161123564045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(201708071742011)(7699051); SRVR:DB7PR04MB4889; BCL:0; PCL:0; RULEID:; SRVR:DB7PR04MB4889; X-Forefront-PRVS: 0816F1D86E X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(39860400002)(136003)(376002)(366004)(346002)(189003)(199004)(316002)(1076002)(16586007)(50226002)(53936002)(2351001)(6116002)(86362001)(478600001)(25786009)(3846002)(14444005)(5009440100003)(8936002)(26005)(2906002)(16526019)(6666003)(4744004)(6916009)(33896004)(186003)(6512007)(85782001)(9686003)(6486002)(97736004)(68736007)(11346002)(81156014)(956004)(81166006)(66066001)(446003)(8676002)(6506007)(36756003)(386003)(47776003)(48376002)(2361001)(50466002)(7736002)(486006)(76176011)(2616005)(106356001)(51416003)(5660300001)(52116002)(105586002)(305945005)(55236004)(4326008)(476003)(110426005)(85772001); DIR:OUT; SFP:1101; SCL:1; SRVR:DB7PR04MB4889; H:GDB1.ap.freescale.net; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DB7PR04MB4889; 23:yWNj7MqYue06YnJtwW4fH/SciRss5wYj6ZrvQKwIV?= =?us-ascii?Q?o6UDJ3nNEy2jL68WVndaMxiEaAN2Ew0NiPZbr30L2vjY2Tz6jZ2gw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OM8XRWfzIaniWFlkvOCj6k1WMAJNnDbF6h9IynUIUT23kX?= =?us-ascii?Q?IgB7f7rEvUg9Kxpp/LhAoGNNxz8tadIdR9neZhNWP4rQgXEuBp1H+rBO4InC?= =?us-ascii?Q?He3gOTGkoBWsahTb6k3LAlsmEvKRnqoPoDwzoavx2zyQGMFyr26NFuVBKgtz?= =?us-ascii?Q?/l4lFXANflYhtPHiJE9pF3SUkTT9DItLtqC1mrZ3LD8pkliqOZWamQn7uhp+?= =?us-ascii?Q?Vz3LP45Ar6eO8mOj1PpQtg3NhebFhjo2vBi9koCDt9uGOq338E494asgDjZh?= =?us-ascii?Q?lyH1TbN+68oRpIXpJjX+f2jFr7kJSD6XfmTXC6rx3FN2/0HgSPI46atmiKq1?= =?us-ascii?Q?MsTzWT3PIjMcCn4x2FtUHLApTcxqENn4beFevgjquFN8k/mkibsiBRCmklMf?= =?us-ascii?Q?YNeCdYuwqdZ9aS4FMLQETChWOsz1kVFCucAMqVyU4E1ro/KMZT6EyGuZ9+wC?= =?us-ascii?Q?wBM42neJQ=3D=3D?= X-Microsoft-Antispam-Message-Info: jGOQ8XqekibOAQi1sRsRuqWYwD26RGzQASsHv7zQ3FQ+y2qcu3RQexlbTrTJ+EGSwwHA1Na0CHOfLeDap9U82PLEq63qDU2uu7Jf8FDA/D2prZ0AwgS8yeMg1xkIM77rn/AejFLTZu1MMv+3wkQvUp5+VpzKeA4wlu7exPlrbrGgnCWBGx52Hui0sRq//fpwGBOF6YnPJW8ziGt2lDWNl2o7dcj6ywlqqKm7Z2ZKQQw9HB2yCSce6JA2lryUXD77G4Ze0QXv60UnUijDiyCpUGOhlra9U9L5GJ+To5R9IXZqqFvB05K0FSqilWRFuXJIzBREwwL5yyphbIfNjYqNvsvznnUUJjwCPrbTNgLUi4o= X-Microsoft-Exchange-Diagnostics: 1; DB7PR04MB4889; 6:CC44o0Y9rCPvdwmJKGpnM+g925n0q8sqvWVkWP3tpcP4DnnxMNY+Evms1HnvLLG0OPyBVo3ioXsazzu+yCEy2+8mDOQXSZrMCNLQ32wn3T9P8xGLzJrbU6ASfZbV1GKSvDRM4FcFa0cTUSHc7Sqitl4S1G5idFwlkBOfOlD5JnEwI6N3lLPjZzSM9Q2UM5WiUJiTy6JU7oiEAs+fmR8z/J5l447Wjss52fgMl4I1363ZaiDxaH8yQYNgVPLdin/ML5fQf8gBZBEAhNOxiHbKsFV3REHlmjgnfq6nb/K9cKKPJTyloORk2IwlH/us07mpi99HXGze6GR2Fi5+zduHpmaxQmTtJ8lonRRpgvVoEX+iy/SZJl5ExZh8pVwCGXWdyCaAMkiiDBXH1+pv3eQDUHpEaH4ZWZv+2+3l67p6plSIfgMoJZunFCeeJ961NaBmBvp5m0nbpokHZhKxtx3/ew==; 5:frQjRPP3x3umQzhQy7dw997etobH2SXBLTl91TEkTHMaepJxJtDrWhLpAV/q17tWIzv/ut5Km2eBCvMd1JDGkQW29lpUd3HmloUvfDeKBGHT+Tz0SFolLg49HWDa+wwbEHiKbOFfPKuQpx3zbIxLcx6YEImm1ESciPCzCIH7S1M=; 7:EcSnj/0uQypNp/PBTzFhZupWJoxvvylBgD5OZgHLCe44FfOzDCOa1BFaYFZymGgD1o0jbGGVPqGpOKNQ/pAQwGIN2dIo/NPbhMPT8IWG6cAAQXpp95zYM2wxPfn88vVLX2CyDxl6WZofW1EHNunxpSckz8NC2+WUGW9UkAVXcMLFS/QH1sRuWaUMRJ/Rmgpf87Z+bYfICdzx+vOKzjoNmP0uDOMVoJh2O4koZOO+J4vqW0gOYeOL53rzLt+6ASWu SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2018 13:58:52.0336 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4c2394df-cd7b-48d7-24cf-08d62acab146 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB4889 Subject: [dpdk-dev] [PATCH v3 3/3] crypto/dpaa2_sec: support pdcp offload X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Oct 2018 13:58:58 -0000 From: Akhil Goyal PDCP session configuration for lookaside protocol offload and data path is added. Signed-off-by: Hemant Agrawal Signed-off-by: Akhil Goyal --- drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 233 ++++++++++++++++++++ drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h | 172 +++++++++++++++ 2 files changed, 405 insertions(+) diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c index 265a8e41a..d263c9388 100644 --- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c +++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c @@ -35,6 +35,7 @@ typedef uint64_t dma_addr_t; /* RTA header files */ #include +#include #include /* Minimum job descriptor consists of a oneword job descriptor HEADER and @@ -74,6 +75,9 @@ build_proto_compound_fd(dpaa2_sec_session *sess, struct rte_mbuf *dst_mbuf = sym_op->m_dst; int retval; + if (!dst_mbuf) + dst_mbuf = src_mbuf; + /* Save the shared descriptor */ flc = &priv->flc_desc[0].flc; @@ -1188,6 +1192,9 @@ build_sec_fd(struct rte_crypto_op *op, case DPAA2_SEC_IPSEC: ret = build_proto_fd(sess, op, fd, bpid); break; + case DPAA2_SEC_PDCP: + ret = build_proto_compound_fd(sess, op, fd, bpid); + break; case DPAA2_SEC_HASH_CIPHER: default: DPAA2_SEC_ERR("error: Unsupported session"); @@ -2541,6 +2548,228 @@ dpaa2_sec_set_ipsec_session(struct rte_cryptodev *dev, return ret; } +static int +dpaa2_sec_set_pdcp_session(struct rte_cryptodev *dev, + struct rte_security_session_conf *conf, + void *sess) +{ + struct rte_security_pdcp_xform *pdcp_xform = &conf->pdcp; + struct rte_crypto_sym_xform *xform = conf->crypto_xform; + struct rte_crypto_auth_xform *auth_xform = NULL; + struct rte_crypto_cipher_xform *cipher_xform; + dpaa2_sec_session *session = (dpaa2_sec_session *)sess; + struct ctxt_priv *priv; + struct dpaa2_sec_dev_private *dev_priv = dev->data->dev_private; + struct alginfo authdata, cipherdata; + int bufsize = -1; + struct sec_flow_context *flc; + + PMD_INIT_FUNC_TRACE(); + + memset(session, 0, sizeof(dpaa2_sec_session)); + + priv = (struct ctxt_priv *)rte_zmalloc(NULL, + sizeof(struct ctxt_priv) + + sizeof(struct sec_flc_desc), + RTE_CACHE_LINE_SIZE); + + if (priv == NULL) { + DPAA2_SEC_ERR("No memory for priv CTXT"); + return -ENOMEM; + } + + priv->fle_pool = dev_priv->fle_pool; + flc = &priv->flc_desc[0].flc; + + /* find xfrm types */ + if (xform->type == RTE_CRYPTO_SYM_XFORM_CIPHER && xform->next == NULL) { + cipher_xform = &xform->cipher; + } else if (xform->type == RTE_CRYPTO_SYM_XFORM_CIPHER && + xform->next->type == RTE_CRYPTO_SYM_XFORM_AUTH) { + session->ext_params.aead_ctxt.auth_cipher_text = true; + cipher_xform = &xform->cipher; + auth_xform = &xform->next->auth; + } else if (xform->type == RTE_CRYPTO_SYM_XFORM_AUTH && + xform->next->type == RTE_CRYPTO_SYM_XFORM_CIPHER) { + session->ext_params.aead_ctxt.auth_cipher_text = false; + cipher_xform = &xform->next->cipher; + auth_xform = &xform->auth; + } else { + DPAA2_SEC_ERR("Invalid crypto type"); + return -EINVAL; + } + + session->ctxt_type = DPAA2_SEC_PDCP; + if (cipher_xform) { + session->cipher_key.data = rte_zmalloc(NULL, + cipher_xform->key.length, + RTE_CACHE_LINE_SIZE); + if (session->cipher_key.data == NULL && + cipher_xform->key.length > 0) { + DPAA2_SEC_ERR("No Memory for cipher key"); + rte_free(priv); + return -ENOMEM; + } + session->cipher_key.length = cipher_xform->key.length; + memcpy(session->cipher_key.data, cipher_xform->key.data, + cipher_xform->key.length); + session->dir = (cipher_xform->op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) ? + DIR_ENC : DIR_DEC; + session->cipher_alg = cipher_xform->algo; + } else { + session->cipher_key.data = NULL; + session->cipher_key.length = 0; + session->cipher_alg = RTE_CRYPTO_CIPHER_NULL; + session->dir = DIR_ENC; + } + + cipherdata.key = (size_t)session->cipher_key.data; + cipherdata.keylen = session->cipher_key.length; + cipherdata.key_enc_flags = 0; + cipherdata.key_type = RTA_DATA_IMM; + + switch (session->cipher_alg) { + case RTE_CRYPTO_CIPHER_SNOW3G_UEA2: + cipherdata.algtype = PDCP_CIPHER_TYPE_SNOW; + break; + case RTE_CRYPTO_CIPHER_ZUC_EEA3: + cipherdata.algtype = PDCP_CIPHER_TYPE_ZUC; + break; + case RTE_CRYPTO_CIPHER_AES_CTR: + cipherdata.algtype = PDCP_CIPHER_TYPE_AES; + break; + case RTE_CRYPTO_CIPHER_NULL: + cipherdata.algtype = PDCP_CIPHER_TYPE_NULL; + break; + default: + DPAA2_SEC_ERR("Crypto: Undefined Cipher specified %u", + session->cipher_alg); + goto out; + } + + /* Auth is only applicable for control mode operation. */ + if (pdcp_xform->domain == RTE_SECURITY_PDCP_MODE_CONTROL) { + if (pdcp_xform->sn_size != RTE_SECURITY_PDCP_SN_SIZE_5) { + DPAA2_SEC_ERR( + "PDCP Seq Num size should be 5 bits for cmode"); + goto out; + } + if (auth_xform) { + session->auth_key.data = rte_zmalloc(NULL, + auth_xform->key.length, + RTE_CACHE_LINE_SIZE); + if (session->auth_key.data == NULL && + auth_xform->key.length > 0) { + DPAA2_SEC_ERR("No Memory for auth key"); + rte_free(session->cipher_key.data); + rte_free(priv); + return -ENOMEM; + } + session->auth_key.length = auth_xform->key.length; + memcpy(session->auth_key.data, auth_xform->key.data, + auth_xform->key.length); + session->auth_alg = auth_xform->algo; + } else { + session->auth_key.data = NULL; + session->auth_key.length = 0; + session->auth_alg = RTE_CRYPTO_AUTH_NULL; + } + authdata.key = (size_t)session->auth_key.data; + authdata.keylen = session->auth_key.length; + authdata.key_enc_flags = 0; + authdata.key_type = RTA_DATA_IMM; + + switch (session->auth_alg) { + case RTE_CRYPTO_AUTH_SNOW3G_UIA2: + authdata.algtype = PDCP_AUTH_TYPE_SNOW; + break; + case RTE_CRYPTO_AUTH_ZUC_EIA3: + authdata.algtype = PDCP_AUTH_TYPE_ZUC; + break; + case RTE_CRYPTO_AUTH_AES_CMAC: + authdata.algtype = PDCP_AUTH_TYPE_AES; + break; + case RTE_CRYPTO_AUTH_NULL: + authdata.algtype = PDCP_AUTH_TYPE_NULL; + break; + default: + DPAA2_SEC_ERR("Crypto: Unsupported auth alg %u", + session->auth_alg); + goto out; + } + + if (session->dir == DIR_ENC) + bufsize = cnstr_shdsc_pdcp_c_plane_encap( + priv->flc_desc[0].desc, 1, 0, + pdcp_xform->hfn, + pdcp_xform->bearer, + pdcp_xform->pkt_dir, + pdcp_xform->hfn_threshold, + &cipherdata, &authdata, + 0); + else if (session->dir == DIR_DEC) + bufsize = cnstr_shdsc_pdcp_c_plane_decap( + priv->flc_desc[0].desc, 1, 0, + pdcp_xform->hfn, + pdcp_xform->bearer, + pdcp_xform->pkt_dir, + pdcp_xform->hfn_threshold, + &cipherdata, &authdata, + 0); + } else { + if (session->dir == DIR_ENC) + bufsize = cnstr_shdsc_pdcp_u_plane_encap( + priv->flc_desc[0].desc, 1, 0, + pdcp_xform->sn_size, + pdcp_xform->hfn, + pdcp_xform->bearer, + pdcp_xform->pkt_dir, + pdcp_xform->hfn_threshold, + &cipherdata, 0); + else if (session->dir == DIR_DEC) + bufsize = cnstr_shdsc_pdcp_u_plane_decap( + priv->flc_desc[0].desc, 1, 0, + pdcp_xform->sn_size, + pdcp_xform->hfn, + pdcp_xform->bearer, + pdcp_xform->pkt_dir, + pdcp_xform->hfn_threshold, + &cipherdata, 0); + } + + if (bufsize < 0) { + DPAA2_SEC_ERR("Crypto: Invalid buffer length"); + goto out; + } + + /* Enable the stashing control bit */ + DPAA2_SET_FLC_RSC(flc); + flc->word2_rflc_31_0 = lower_32_bits( + (size_t)&(((struct dpaa2_sec_qp *) + dev->data->queue_pairs[0])->rx_vq) | 0x14); + flc->word3_rflc_63_32 = upper_32_bits( + (size_t)&(((struct dpaa2_sec_qp *) + dev->data->queue_pairs[0])->rx_vq)); + + flc->word1_sdl = (uint8_t)bufsize; + + /* Set EWS bit i.e. enable write-safe */ + DPAA2_SET_FLC_EWS(flc); + /* Set BS = 1 i.e reuse input buffers as output buffers */ + DPAA2_SET_FLC_REUSE_BS(flc); + /* Set FF = 10; reuse input buffers if they provide sufficient space */ + DPAA2_SET_FLC_REUSE_FF(flc); + + session->ctxt = priv; + + return 0; +out: + rte_free(session->auth_key.data); + rte_free(session->cipher_key.data); + rte_free(priv); + return -1; +} + static int dpaa2_sec_security_session_create(void *dev, struct rte_security_session_conf *conf, @@ -2563,6 +2792,10 @@ dpaa2_sec_security_session_create(void *dev, break; case RTE_SECURITY_PROTOCOL_MACSEC: return -ENOTSUP; + case RTE_SECURITY_PROTOCOL_PDCP: + ret = dpaa2_sec_set_pdcp_session(cdev, conf, + sess_private_data); + break; default: return -EINVAL; } diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h b/drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h index d015be1e9..907374346 100644 --- a/drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h +++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h @@ -390,6 +390,162 @@ static const struct rte_cryptodev_capabilities dpaa2_sec_capabilities[] = { RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST() }; +static const struct rte_cryptodev_capabilities dpaa2_pdcp_capabilities[] = { + { /* SNOW 3G (UIA2) */ + .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, + {.sym = { + .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH, + {.auth = { + .algo = RTE_CRYPTO_AUTH_SNOW3G_UIA2, + .block_size = 16, + .key_size = { + .min = 16, + .max = 16, + .increment = 0 + }, + .digest_size = { + .min = 4, + .max = 4, + .increment = 0 + }, + .iv_size = { + .min = 16, + .max = 16, + .increment = 0 + } + }, } + }, } + }, + { /* SNOW 3G (UEA2) */ + .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, + {.sym = { + .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER, + {.cipher = { + .algo = RTE_CRYPTO_CIPHER_SNOW3G_UEA2, + .block_size = 16, + .key_size = { + .min = 16, + .max = 16, + .increment = 0 + }, + .iv_size = { + .min = 16, + .max = 16, + .increment = 0 + } + }, } + }, } + }, + { /* AES CTR */ + .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, + {.sym = { + .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER, + {.cipher = { + .algo = RTE_CRYPTO_CIPHER_AES_CTR, + .block_size = 16, + .key_size = { + .min = 16, + .max = 32, + .increment = 8 + }, + .iv_size = { + .min = 16, + .max = 16, + .increment = 0 + } + }, } + }, } + }, + { /* NULL (AUTH) */ + .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, + {.sym = { + .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH, + {.auth = { + .algo = RTE_CRYPTO_AUTH_NULL, + .block_size = 1, + .key_size = { + .min = 0, + .max = 0, + .increment = 0 + }, + .digest_size = { + .min = 0, + .max = 0, + .increment = 0 + }, + .iv_size = { 0 } + }, }, + }, }, + }, + { /* NULL (CIPHER) */ + .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, + {.sym = { + .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER, + {.cipher = { + .algo = RTE_CRYPTO_CIPHER_NULL, + .block_size = 1, + .key_size = { + .min = 0, + .max = 0, + .increment = 0 + }, + .iv_size = { + .min = 0, + .max = 0, + .increment = 0 + } + }, }, + }, } + }, + { /* ZUC (EEA3) */ + .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, + {.sym = { + .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER, + {.cipher = { + .algo = RTE_CRYPTO_CIPHER_ZUC_EEA3, + .block_size = 16, + .key_size = { + .min = 16, + .max = 16, + .increment = 0 + }, + .iv_size = { + .min = 16, + .max = 16, + .increment = 0 + } + }, } + }, } + }, + { /* ZUC (EIA3) */ + .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, + {.sym = { + .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH, + {.auth = { + .algo = RTE_CRYPTO_AUTH_ZUC_EIA3, + .block_size = 16, + .key_size = { + .min = 16, + .max = 16, + .increment = 0 + }, + .digest_size = { + .min = 4, + .max = 4, + .increment = 0 + }, + .iv_size = { + .min = 16, + .max = 16, + .increment = 0 + } + }, } + }, } + }, + + RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST() +}; + static const struct rte_security_capability dpaa2_sec_security_cap[] = { { /* IPsec Lookaside Protocol offload ESP Transport Egress */ .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, @@ -413,6 +569,22 @@ static const struct rte_security_capability dpaa2_sec_security_cap[] = { }, .crypto_capabilities = dpaa2_sec_capabilities }, + { /* PDCP Lookaside Protocol offload Data */ + .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, + .protocol = RTE_SECURITY_PROTOCOL_PDCP, + .pdcp = { + .domain = RTE_SECURITY_PDCP_MODE_DATA, + }, + .crypto_capabilities = dpaa2_pdcp_capabilities + }, + { /* PDCP Lookaside Protocol offload Control */ + .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, + .protocol = RTE_SECURITY_PROTOCOL_PDCP, + .pdcp = { + .domain = RTE_SECURITY_PDCP_MODE_CONTROL, + }, + .crypto_capabilities = dpaa2_pdcp_capabilities + }, { .action = RTE_SECURITY_ACTION_TYPE_NONE } -- 2.17.1