From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B7421A0471 for ; Fri, 19 Jul 2019 14:34:57 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 79E881B9AF; Fri, 19 Jul 2019 14:34:02 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id D7F7A1B953 for ; Fri, 19 Jul 2019 14:33:46 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x6JCF9SK009722 for ; Fri, 19 Jul 2019 05:33:46 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pfpt0818; bh=A2cRHpH6pTK1RTi3Tywk9z+EnjuD1SLqsMrznlB6+n4=; b=TmQ78cYN7Ko4MfyqDBcJEyNa5crvEAfB8VIT9ZZ+0s9TpXOVRqvPsfpS3Xe5GXyIN6aU XkGwWnp8QH/zIPDvbc4bPnjvVkZi0iqH5FuXQudfTqaV+BSURIFKbmyGfCiHAeKI/tgx BPDK1SLIV7e/jxpUqWzdwffPOD/lG8rpBATOA8yef8CyVU9ncctqip1ALoMT4KLuRLY3 Y667k03CeJ+WnajdOq3B3Y/fCzKsouwTydlkqQxw6iWs3DC31FcSiVhzYorM5p6HRRb5 3P7aXXmOrwuH0j/oviPJJEDouGekTXgUck3bdeqVWpaHIMUJvBw3ytJMTe0Enwglfykt RQ== Received: from sc-exch04.marvell.com ([199.233.58.184]) by mx0b-0016f401.pphosted.com with ESMTP id 2ts0a2gfqf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Fri, 19 Jul 2019 05:33:45 -0700 Received: from SC-EXCH02.marvell.com (10.93.176.82) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Fri, 19 Jul 2019 05:33:43 -0700 Received: from NAM03-BY2-obe.outbound.protection.outlook.com (104.47.42.51) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Fri, 19 Jul 2019 05:33:43 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bV6wDOStilhG+s7pok5Ff8TlisQDFQnFwiw9U/N0VfMni+RcOKMYahsqNzXbvFCEDWAnkf0jeFc8TcpGFsaLXNCbGoePM8DuHG12L/q01HRVSEUu8ZcHaitQLqQBuuYSulaGDge9gvvlzzFdE5VlB+PK8XGgSIUT+Q5fzIMJ91gfraXJsvkphk1gP3qYJZ369Uk/MefEwkb+pZPd5i50jlaXxSDXoJAdg1jtHxaMJZvgWVeWEnAIVJLQP2rcmeptm0xUfjh6jCitX0WaL3bxdnXl2njlTFaCLTvWJomAESSBz522Jv+ZBPda2OYPX492g4HOgo6Zt/RcX7//UtN/Fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=A2cRHpH6pTK1RTi3Tywk9z+EnjuD1SLqsMrznlB6+n4=; b=DJGVGIurKkU5ZccsoVlrwMiim1ChbAMlHBFk5q1KDB45e2C2rJ9YoV3T/U4tda2hcC9Wi/87TvbEUWzcos/Tct8F3OeB/OlIZIpV8YqMtptIurjpX6wyRCafCKZfCTH528gp2dyHzF8L50qP+ovUEut9WwNsje/O4Rb0Q4gCg73Rk+5oRUbQNeX3Du4UBbF1oxQjPFX0rC02DVdBiF2zrHGrSrl85Nh7o46/Umwl4xjusupmiYYRYgYT/VLCqt6HFQXJc7Lp7JVDY9WUOLKwLqRAt4CmikBCj3wMz1KdisIFabYa0sPuP2w8FzVo6eNbG8bd3ExDmtYXDX3IXbcCFw== ARC-Authentication-Results: i=1; mx.microsoft.com 1;spf=pass smtp.mailfrom=marvell.com;dmarc=pass action=none header.from=marvell.com;dkim=pass header.d=marvell.com;arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector2-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=A2cRHpH6pTK1RTi3Tywk9z+EnjuD1SLqsMrznlB6+n4=; b=Xp5Kev9Z6jSsrC+6x300yarrjmIRlQfkRLjfSI6cxPraEMQ028ofHlNVPoW6IiC7409UtIA0XN5Gduno+Bs82r2ePhXPpGzDPOtGsGWncbM+Z+r+lUwsFYl9dBPj9CKUkIfxoSyg1ZVFtj1KzwUtMXm0DBl6h22umfiJvPpwsuM= Received: from MN2PR18MB2797.namprd18.prod.outlook.com (20.179.22.16) by MN2PR18MB2527.namprd18.prod.outlook.com (20.179.82.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2073.14; Fri, 19 Jul 2019 12:33:42 +0000 Received: from MN2PR18MB2797.namprd18.prod.outlook.com ([fe80::5d53:ac2e:80ec:cd8f]) by MN2PR18MB2797.namprd18.prod.outlook.com ([fe80::5d53:ac2e:80ec:cd8f%6]) with mapi id 15.20.2094.011; Fri, 19 Jul 2019 12:33:42 +0000 From: Nagadheeraj Rottela To: "dev@dpdk.org" CC: Srikanth Jampala , Nagadheeraj Rottela Thread-Topic: [PATCH v2 07/10] crypto/nitrox: add session management operations Thread-Index: AQHVPi4zCo8TDl8hhUOjblaZ+37IbA== Date: Fri, 19 Jul 2019 12:33:42 +0000 Message-ID: <20190719123309.24417-8-rnagadheeraj@marvell.com> References: <20190717052837.647-1-rnagadheeraj@marvell.com> <20190719123309.24417-1-rnagadheeraj@marvell.com> In-Reply-To: <20190719123309.24417-1-rnagadheeraj@marvell.com> Accept-Language: en-IN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BM1PR0101CA0048.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:1a::34) To MN2PR18MB2797.namprd18.prod.outlook.com (2603:10b6:208:a0::16) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.13.6 x-originating-ip: [115.113.156.2] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 151c66e5-fc82-4ad2-1a1c-08d70c455564 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:MN2PR18MB2527; x-ms-traffictypediagnostic: MN2PR18MB2527: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:785; x-forefront-prvs: 01039C93E4 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(136003)(346002)(39860400002)(396003)(366004)(376002)(199004)(189003)(2616005)(6486002)(107886003)(36756003)(486006)(5660300002)(316002)(99286004)(30864003)(6116002)(14454004)(102836004)(1076003)(476003)(86362001)(6916009)(6512007)(5640700003)(8936002)(76176011)(53936002)(186003)(26005)(54906003)(6436002)(2501003)(8676002)(81166006)(1730700003)(81156014)(478600001)(3846002)(66476007)(66446008)(64756008)(52116002)(25786009)(68736007)(50226002)(4326008)(2906002)(66946007)(71200400001)(446003)(71190400001)(11346002)(14444005)(66066001)(55236004)(2351001)(7736002)(6506007)(305945005)(66556008)(256004)(386003); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR18MB2527; H:MN2PR18MB2797.namprd18.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: marvell.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: nOz2mvE3au/m1yEYaKRpGWOupgTWMuJQcsS0jsHIiyau12Bpm/17Brpmi3sTNn9U85p3ZVqpPGsirHpZddv5h0tcaXJ/974S8sfclUQNNKfQAgC47NJkf/ywWmnUQpJTpBcVKO6yZsMt9SL5NAVDxBQ/Es37kzT19PfBrK7ojCps9G9+tfoMsx83GjwglI9aFguNkw8d9xtDHjV2HqRoX35MZwcq52mQZCU6juEojC2zqU327ADv5LO/0ScfJOl2Di0n38IbfDKzQ7g8teUDaKVNFD5gTsy4NModalGxgxZ/A+N97HFBuFAwDNZb1aD3YBY/+lusRQxwZpHBJkwVwnhHVo8DLlMcC2rhaSpiFiJICymztg+BJiLUNkBJvYH+9EJQkW7pt3MzOh6OBrsmNEOy+vlJziliQtP2RWxJzjc= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 151c66e5-fc82-4ad2-1a1c-08d70c455564 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Jul 2019 12:33:42.4303 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: rnagadheeraj@marvell.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR18MB2527 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:5.22.84,1.0.8 definitions=2019-07-19_08:2019-07-19,2019-07-19 signatures=0 Subject: [dpdk-dev] [PATCH v2 07/10] crypto/nitrox: add session management operations 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add all the session management operations. Signed-off-by: Nagadheeraj Rottela --- drivers/crypto/nitrox/nitrox_sym.c | 323 +++++++++++++++++++++++++++++= +++- drivers/crypto/nitrox/nitrox_sym_ctx.h | 85 +++++++++ 2 files changed, 405 insertions(+), 3 deletions(-) create mode 100644 drivers/crypto/nitrox/nitrox_sym_ctx.h diff --git a/drivers/crypto/nitrox/nitrox_sym.c b/drivers/crypto/nitrox/nit= rox_sym.c index 05f089cae..34c62b02e 100644 --- a/drivers/crypto/nitrox/nitrox_sym.c +++ b/drivers/crypto/nitrox/nitrox_sym.c @@ -12,16 +12,54 @@ #include "nitrox_sym_capabilities.h" #include "nitrox_qp.h" #include "nitrox_sym_reqmgr.h" +#include "nitrox_sym_ctx.h" #include "nitrox_logs.h" =20 #define CRYPTODEV_NAME_NITROX_PMD crypto_nitrox +#define MC_MAC_MISMATCH_ERR_CODE 0x4c #define NPS_PKT_IN_INSTR_SIZE 64 +#define IV_FROM_DPTR 1 +#define FLEXI_CRYPTO_ENCRYPT_HMAC 0x33 +#define AES_KEYSIZE_128 16 +#define AES_KEYSIZE_192 24 +#define AES_KEYSIZE_256 32 +#define MAX_IV_LEN 16 =20 struct nitrox_sym_device { struct rte_cryptodev *cdev; struct nitrox_device *ndev; }; =20 +/* Cipher opcodes */ +enum flexi_cipher { + CIPHER_NULL =3D 0, + CIPHER_3DES_CBC, + CIPHER_3DES_ECB, + CIPHER_AES_CBC, + CIPHER_AES_ECB, + CIPHER_AES_CFB, + CIPHER_AES_CTR, + CIPHER_AES_GCM, + CIPHER_AES_XTS, + CIPHER_AES_CCM, + CIPHER_AES_CBC_CTS, + CIPHER_AES_ECB_CTS, + CIPHER_INVALID +}; + +/* Auth opcodes */ +enum flexi_auth { + AUTH_NULL =3D 0, + AUTH_MD5, + AUTH_SHA1, + AUTH_SHA2_SHA224, + AUTH_SHA2_SHA256, + AUTH_SHA2_SHA384, + AUTH_SHA2_SHA512, + AUTH_GMAC, + AUTH_INVALID +}; + uint8_t nitrox_sym_drv_id; static const char nitrox_sym_drv_name[] =3D RTE_STR(CRYPTODEV_NAME_NITROX_= PMD); static const struct rte_driver nitrox_rte_sym_drv =3D { @@ -204,6 +242,285 @@ nitrox_sym_dev_qp_release(struct rte_cryptodev *cdev,= uint16_t qp_id) return err; } =20 +static unsigned int +nitrox_sym_dev_sess_get_size(__rte_unused struct rte_cryptodev *cdev) +{ + return sizeof(struct nitrox_crypto_ctx); +} + +static enum nitrox_chain +get_crypto_chain_order(const struct rte_crypto_sym_xform *xform) +{ + enum nitrox_chain res =3D NITROX_CHAIN_NOT_SUPPORTED; + + if (unlikely(xform =3D=3D NULL)) + return res; + + switch (xform->type) { + case RTE_CRYPTO_SYM_XFORM_AUTH: + if (xform->next =3D=3D NULL) { + res =3D NITROX_CHAIN_NOT_SUPPORTED; + } else if (xform->next->type =3D=3D RTE_CRYPTO_SYM_XFORM_CIPHER) { + if (xform->auth.op =3D=3D RTE_CRYPTO_AUTH_OP_VERIFY && + xform->next->cipher.op =3D=3D + RTE_CRYPTO_CIPHER_OP_DECRYPT) { + res =3D NITROX_CHAIN_AUTH_CIPHER; + } else { + NITROX_LOG(ERR, "auth op %d, cipher op %d\n", + xform->auth.op, xform->next->cipher.op); + } + } + break; + case RTE_CRYPTO_SYM_XFORM_CIPHER: + if (xform->next =3D=3D NULL) { + res =3D NITROX_CHAIN_CIPHER_ONLY; + } else if (xform->next->type =3D=3D RTE_CRYPTO_SYM_XFORM_AUTH) { + if (xform->cipher.op =3D=3D RTE_CRYPTO_CIPHER_OP_ENCRYPT && + xform->next->auth.op =3D=3D + RTE_CRYPTO_AUTH_OP_GENERATE) { + res =3D NITROX_CHAIN_CIPHER_AUTH; + } else { + NITROX_LOG(ERR, "cipher op %d, auth op %d\n", + xform->cipher.op, xform->next->auth.op); + } + } + break; + default: + break; + } + + return res; +} + +static enum flexi_cipher +get_flexi_cipher_type(enum rte_crypto_cipher_algorithm algo, bool *is_aes) +{ + enum flexi_cipher type; + + switch (algo) { + case RTE_CRYPTO_CIPHER_AES_CBC: + type =3D CIPHER_AES_CBC; + *is_aes =3D true; + break; + default: + type =3D CIPHER_INVALID; + NITROX_LOG(ERR, "Algorithm not supported %d\n", algo); + break; + } + + return type; +} + +static int +flexi_aes_keylen(size_t keylen, bool is_aes) +{ + int aes_keylen; + + if (!is_aes) + return 0; + + switch (keylen) { + case AES_KEYSIZE_128: + aes_keylen =3D 1; + break; + case AES_KEYSIZE_192: + aes_keylen =3D 2; + break; + case AES_KEYSIZE_256: + aes_keylen =3D 3; + break; + default: + NITROX_LOG(ERR, "Invalid keylen %zu\n", keylen); + aes_keylen =3D -EINVAL; + break; + } + + return aes_keylen; +} + +static bool +crypto_key_is_valid(struct rte_crypto_cipher_xform *xform, + struct flexi_crypto_context *fctx) +{ + if (unlikely(xform->key.length > sizeof(fctx->crypto.key))) { + NITROX_LOG(ERR, "Invalid crypto key length %d\n", + xform->key.length); + return false; + } + + return true; +} + +static int +configure_cipher_ctx(struct rte_crypto_cipher_xform *xform, + struct nitrox_crypto_ctx *ctx) +{ + enum flexi_cipher type; + bool cipher_is_aes =3D false; + int aes_keylen; + struct flexi_crypto_context *fctx =3D &ctx->fctx; + + type =3D get_flexi_cipher_type(xform->algo, &cipher_is_aes); + if (unlikely(type =3D=3D CIPHER_INVALID)) + return -ENOTSUP; + + aes_keylen =3D flexi_aes_keylen(xform->key.length, cipher_is_aes); + if (unlikely(aes_keylen < 0)) + return -EINVAL; + + if (unlikely(!cipher_is_aes && !crypto_key_is_valid(xform, fctx))) + return -EINVAL; + + if (unlikely(xform->iv.length > MAX_IV_LEN)) + return -EINVAL; + + fctx->flags =3D rte_be_to_cpu_64(fctx->flags); + fctx->w0.cipher_type =3D type; + fctx->w0.aes_keylen =3D aes_keylen; + fctx->w0.iv_source =3D IV_FROM_DPTR; + fctx->flags =3D rte_cpu_to_be_64(fctx->flags); + memset(fctx->crypto.key, 0, sizeof(fctx->crypto.key)); + memcpy(fctx->crypto.key, xform->key.data, xform->key.length); + + ctx->opcode =3D FLEXI_CRYPTO_ENCRYPT_HMAC; + ctx->req_op =3D (xform->op =3D=3D RTE_CRYPTO_CIPHER_OP_ENCRYPT) ? + NITROX_OP_ENCRYPT : NITROX_OP_DECRYPT; + ctx->iv.offset =3D xform->iv.offset; + ctx->iv.length =3D xform->iv.length; + return 0; +} + +static enum flexi_auth +get_flexi_auth_type(enum rte_crypto_auth_algorithm algo) +{ + enum flexi_auth type; + + switch (algo) { + case RTE_CRYPTO_AUTH_SHA1_HMAC: + type =3D AUTH_SHA1; + break; + default: + NITROX_LOG(ERR, "Algorithm not supported %d\n", algo); + type =3D AUTH_INVALID; + break; + } + + return type; +} + +static bool +auth_key_digest_is_valid(struct rte_crypto_auth_xform *xform, + struct flexi_crypto_context *fctx) +{ + if (unlikely(!xform->key.data && xform->key.length)) { + NITROX_LOG(ERR, "Invalid auth key\n"); + return false; + } + + if (unlikely(xform->key.length > sizeof(fctx->auth.opad))) { + NITROX_LOG(ERR, "Invalid auth key length %d\n", + xform->key.length); + return false; + } + + return true; +} + +static int +configure_auth_ctx(struct rte_crypto_auth_xform *xform, + struct nitrox_crypto_ctx *ctx) +{ + enum flexi_auth type; + struct flexi_crypto_context *fctx =3D &ctx->fctx; + + type =3D get_flexi_auth_type(xform->algo); + if (unlikely(type =3D=3D AUTH_INVALID)) + return -ENOTSUP; + + if (unlikely(!auth_key_digest_is_valid(xform, fctx))) + return -EINVAL; + + ctx->auth_op =3D xform->op; + ctx->auth_algo =3D xform->algo; + ctx->digest_length =3D xform->digest_length; + + fctx->flags =3D rte_be_to_cpu_64(fctx->flags); + fctx->w0.hash_type =3D type; + fctx->w0.auth_input_type =3D 1; + fctx->w0.mac_len =3D xform->digest_length; + fctx->flags =3D rte_cpu_to_be_64(fctx->flags); + memset(&fctx->auth, 0, sizeof(fctx->auth)); + memcpy(fctx->auth.opad, xform->key.data, xform->key.length); + return 0; +} + +static int +nitrox_sym_dev_sess_configure(struct rte_cryptodev *cdev, + struct rte_crypto_sym_xform *xform, + struct rte_cryptodev_sym_session *sess, + struct rte_mempool *mempool) +{ + void *mp_obj; + struct nitrox_crypto_ctx *ctx; + struct rte_crypto_cipher_xform *cipher_xform =3D NULL; + struct rte_crypto_auth_xform *auth_xform =3D NULL; + + if (rte_mempool_get(mempool, &mp_obj)) { + NITROX_LOG(ERR, "Couldn't allocate context\n"); + return -ENOMEM; + } + + ctx =3D mp_obj; + ctx->nitrox_chain =3D get_crypto_chain_order(xform); + switch (ctx->nitrox_chain) { + case NITROX_CHAIN_CIPHER_AUTH: + cipher_xform =3D &xform->cipher; + auth_xform =3D &xform->next->auth; + break; + case NITROX_CHAIN_AUTH_CIPHER: + auth_xform =3D &xform->auth; + cipher_xform =3D &xform->next->cipher; + break; + default: + NITROX_LOG(ERR, "Crypto chain not supported\n"); + goto err; + } + + if (cipher_xform && unlikely(configure_cipher_ctx(cipher_xform, ctx))) { + NITROX_LOG(ERR, "Failed to configure cipher ctx\n"); + goto err; + } + + if (auth_xform && unlikely(configure_auth_ctx(auth_xform, ctx))) { + NITROX_LOG(ERR, "Failed to configure auth ctx\n"); + goto err; + } + + ctx->iova =3D rte_mempool_virt2iova(ctx); + set_sym_session_private_data(sess, cdev->driver_id, ctx); + return 0; +err: + rte_mempool_put(mempool, mp_obj); + return -EINVAL; +} + +static void +nitrox_sym_dev_sess_clear(struct rte_cryptodev *cdev, + struct rte_cryptodev_sym_session *sess) +{ + struct nitrox_crypto_ctx *ctx =3D get_sym_session_private_data(sess, + cdev->driver_id); + struct rte_mempool *sess_mp; + + if (!ctx) + return; + + memset(ctx, 0, sizeof(*ctx)); + sess_mp =3D rte_mempool_from_obj(ctx); + set_sym_session_private_data(sess, cdev->driver_id, NULL); + rte_mempool_put(sess_mp, ctx); +} + static struct rte_cryptodev_ops nitrox_cryptodev_ops =3D { .dev_configure =3D nitrox_sym_dev_config, .dev_start =3D nitrox_sym_dev_start, @@ -217,9 +534,9 @@ static struct rte_cryptodev_ops nitrox_cryptodev_ops = =3D { .queue_pair_setup =3D nitrox_sym_dev_qp_setup, .queue_pair_release =3D nitrox_sym_dev_qp_release, =20 - .sym_session_get_size =3D NULL, - .sym_session_configure =3D NULL, - .sym_session_clear =3D NULL + .sym_session_get_size =3D nitrox_sym_dev_sess_get_size, + .sym_session_configure =3D nitrox_sym_dev_sess_configure, + .sym_session_clear =3D nitrox_sym_dev_sess_clear }; =20 int diff --git a/drivers/crypto/nitrox/nitrox_sym_ctx.h b/drivers/crypto/nitrox= /nitrox_sym_ctx.h new file mode 100644 index 000000000..d63c71455 --- /dev/null +++ b/drivers/crypto/nitrox/nitrox_sym_ctx.h @@ -0,0 +1,85 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2019 Marvell International Ltd. + */ + +#ifndef _NITROX_SYM_CTX_H_ +#define _NITROX_SYM_CTX_H_ + +#include + +#include + +#define AES_MAX_KEY_SIZE 32 +#define AES_BLOCK_SIZE 16 + +enum nitrox_chain { + NITROX_CHAIN_CIPHER_ONLY, + NITROX_CHAIN_CIPHER_AUTH, + NITROX_CHAIN_AUTH_CIPHER, + NITROX_CHAIN_COMBINED, + NITROX_CHAIN_NOT_SUPPORTED +}; + +enum nitrox_op { + NITROX_OP_ENCRYPT, + NITROX_OP_DECRYPT, +}; + +struct crypto_keys { + uint8_t key[AES_MAX_KEY_SIZE]; + uint8_t iv[AES_BLOCK_SIZE]; +}; + +struct auth_keys { + uint8_t ipad[64]; + uint8_t opad[64]; +}; + +struct flexi_crypto_context { + union { + uint64_t flags; + struct { +#if RTE_BYTE_ORDER =3D=3D RTE_BIG_ENDIAN + uint64_t cipher_type : 4; + uint64_t reserved_59 : 1; + uint64_t aes_keylen : 2; + uint64_t iv_source : 1; + uint64_t hash_type : 4; + uint64_t reserved_49_51 : 3; + uint64_t auth_input_type : 1; + uint64_t mac_len : 8; + uint64_t reserved_0_39 : 40; +#else + uint64_t reserved_0_39 : 40; + uint64_t mac_len : 8; + uint64_t auth_input_type : 1; + uint64_t reserved_49_51 : 3; + uint64_t hash_type : 4; + uint64_t iv_source : 1; + uint64_t aes_keylen : 2; + uint64_t reserved_59 : 1; + uint64_t cipher_type : 4; +#endif + } w0; + }; + + struct crypto_keys crypto; + struct auth_keys auth; +}; + +struct nitrox_crypto_ctx { + struct flexi_crypto_context fctx; + enum nitrox_chain nitrox_chain; + enum rte_crypto_auth_operation auth_op; + enum rte_crypto_auth_algorithm auth_algo; + struct { + uint16_t offset; + uint16_t length; + } iv; + rte_iova_t iova; + uint16_t digest_length; + uint8_t opcode; + uint8_t req_op; +}; + +#endif /* _NITROX_SYM_CTX_H_ */ --=20 2.13.6