From patchwork Wed Dec 13 13:56:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 121773 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp5508124qgn; Wed, 13 Dec 2017 06:00:59 -0800 (PST) X-Google-Smtp-Source: ACJfBot2Ioes5ChZLgKetCmgSBZT4FQ2sZztIM55DLP5bUTdA0qhQVp7n61QYN7WMJtLTy1ydMVq X-Received: by 10.223.138.212 with SMTP id z20mr2376780wrz.154.1513173659637; Wed, 13 Dec 2017 06:00:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513173659; cv=none; d=google.com; s=arc-20160816; b=0z6ivAquJZz0gT6J1jXKpY5x8cIqLB3BR83m3k9yr6/gxJ7W/s/QGvdjwMCPQ/Zq/A OOozr5Nv38tOT9ZtD3aWQYvON1pqLg2kVlYrV/Q3MesEa8t7dgTqPbYmoF4CGRU+1vLM hFdb5le78AVTbOQlP56eVIVLOCfC1/uAwkKO4C7X+/EOImT3M7GXgg9BjfxUx44x0B+T ihklopu3BXWTRhmbzpLR6JuiIt5Fzm0tkfC3Qm1irqDCyAv/+o/jx5Pag+DeUtPaaykG cDedq8tKz5br42BqIUn47W0uQXCuYzETw9XkaRn5DDGS+5cUsuXPUC02AOLXGM5mScWd kSuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:spamdiagnosticmetadata :spamdiagnosticoutput:mime-version:references:in-reply-to:message-id :date:cc:to:from:arc-authentication-results; bh=G2j+Itgg5Sy2HqmFb7Q4iZAiIgxzEhUaZpZDR5Ib3UU=; b=z95DLnYTZL/oPH8XjF/B0fMRGam9MjfT1bIgkPmwcifaRzBmjmEGb7eg1/xUOL/T7B h47rJ3KhjaYqyRfnfmkYwWwde7Dc7mKjG3GMnMQzP05vI+fQ14/1hJwURxj4J1TpHs2M lqsO9UQ3Oke5JAwEM/dPAtKVo9dm3rcT7+vODZ0eDzuy/XnXW9H14fo2N7a4OmoTe2OE pyFiVVrcGZd9tAWstrq8Vl3stMmbJZIYnBGzUCDz+2W7kZbEu6cz7sq7+91lECGQZ4H7 LQnqenZ8k89M4uCOvnQ7ySkwMhv0dHDI1kJKqG/KWdA3yfqO2n5STNVjn/u7y7NY2P2V DgmA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from dpdk.org (dpdk.org. [92.243.14.124]) by mx.google.com with ESMTP id g80si1517376wmc.162.2017.12.13.06.00.59; Wed, 13 Dec 2017 06:00:59 -0800 (PST) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) client-ip=92.243.14.124; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3117D1B015; Wed, 13 Dec 2017 15:00:47 +0100 (CET) Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on0055.outbound.protection.outlook.com [104.47.32.55]) by dpdk.org (Postfix) with ESMTP id 195351B015 for ; Wed, 13 Dec 2017 15:00:45 +0100 (CET) Received: from CY4PR03CA0007.namprd03.prod.outlook.com (2603:10b6:903:33::17) by BN1PR0301MB0724.namprd03.prod.outlook.com (2a01:111:e400:4c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.302.9; Wed, 13 Dec 2017 14:00:42 +0000 Received: from BN1BFFO11FD027.protection.gbl (2a01:111:f400:7c10::1:128) by CY4PR03CA0007.outlook.office365.com (2603:10b6:903:33::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.302.9 via Frontend Transport; Wed, 13 Dec 2017 14:00:41 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; NXP1.onmicrosoft.com; dkim=none (message not signed) header.d=none;NXP1.onmicrosoft.com; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1BFFO11FD027.mail.protection.outlook.com (10.58.144.90) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.282.5 via Frontend Transport; Wed, 13 Dec 2017 14:00:33 +0000 Received: from netperf2.ap.freescale.net ([10.232.133.164]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id vBDE0WHj023690; Wed, 13 Dec 2017 07:00:38 -0700 From: Akhil Goyal To: CC: , , Date: Wed, 13 Dec 2017 19:26:56 +0530 Message-ID: <20171213135659.32648-3-akhil.goyal@nxp.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20171213135659.32648-1-akhil.goyal@nxp.com> References: <20171213135659.32648-1-akhil.goyal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131576472341283720; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(336005)(7966004)(376002)(39860400002)(346002)(39380400002)(2980300002)(1110001)(1109001)(339900001)(189003)(199004)(81166006)(2950100002)(51416003)(48376002)(8656006)(86362001)(36756003)(6916009)(6666003)(2351001)(77096006)(5660300001)(5890100001)(50466002)(97736004)(106466001)(105606002)(316002)(8676002)(81156014)(4326008)(47776003)(1076002)(76176011)(498600001)(356003)(68736007)(305945005)(296002)(53936002)(104016004)(8936002)(50226002)(54906003)(59450400001)(16586007)(85426001)(2906002); DIR:OUT; SFP:1101; SCL:1; SRVR:BN1PR0301MB0724; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD027; 1:EdsX8TGt5pFGb/Zbrf6siTcNf2alC0Mjk8qyGQtnAQU+F9ICIp36qWyvmJ5As7t0uyp3JwxCdG7w4w+ZeVg/TT4Nj31NxLOKVLLD1CH7M/X1FRBdvSnodur5sCrTApSH MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 86a915f7-e70f-455a-8388-08d54231e12a X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4628075)(201703131517081)(5600026)(4604075)(2017052603307); SRVR:BN1PR0301MB0724; X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0724; 3:rNVsbmav5fgZiIZHQyCbQziWVOzzq2od9HnzpSJQoPM+sFHpw6O12YOdwEdOpB1iPKt3Ai3J9v3RPI7qwrN8wRMxQCfOIrz0g8rj1uSeq7re8oc9zkwEX5bJci3BmPb6j+j60p2MOw+3g5WEkh6zybWxOatcJp5nuxN18+DH6D8Bgsk/teSnQHqvNUsI12rb2Z5rn4uZJHTq0qccURD2Mu1llyszQyBcYdSZWBs7eoQBl0rq0ASB5nc83PPcL8VZC9uTjKoNFKnrUBQeFczGQ1JGPZnfbdEFMt1FOcCWZ9PwpTO7yiWhVz773h0kErcOcTA52gAqrpy0PtK6twOTFuClbkhDOTWeX7ZPRRDigO0=; 25:u9A/s9Z3nTxT5dIIDJidK0ajRni3Wll78yLvz9M6MJ7OtDfExZTq0A4kjt7h2gNSveVQpu7TMdDukmxoZpqRQklxzMm2P65dzuk06qg3vQkaMMrfA1e1rjc8UxUxX18gLveHPgz57REEfkGPGmXcd4Rbn/TIHqP05K1UX6Lt5Pil4t137ljKCVpmRkI9SCdix6kbre118L+ZFTe1OsWJHXkR42OxkITaGQooTqQxp+wAtiLOhyzH+2bfz0/t8uHWAUsKJEf1oIdzFoUSYwb8uQMG5MLnSXkJp83lT/bVa62UV9qsYBqlbjArgI1GZ3/ClR/c3wR8rUy6jYRhWX7EB1x5x6jLa4+KdjkbksMeOU8= X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1PR0301MB0724: X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0724; 31:+EdrJg9INSBIJl3JEqTEWMwzbkop6xOuY3lkOehXqizE2Rfav9pSAqHGYh8UL0g0X8jP5u/4nYl+sRhmTdxCGMXDDzIRTmEnuKbwtnsUOIVrfjDN5gireF5P4O0RnmL/0PFT7jEShGwIlDxf2E4hGccPPgzLStmfS/cEdwycK+GYZifOopBucTxwI/DWb9ZbvR9UPYTOQDYGmus6gxpbea+BiMxcDYc9X/llDG7sqd4=; 4:K13cSx0wyQIj0DmM1BqjDoabi5omdi5rpYq/3UR4RJVEFlH1wZf00KXMONBP0uSLJRYJEROGsioqlS0QjzT/opLuX4SxKSdUJgt6gmKwlEpAeEfWdHpreYwVH6LBKduK23DickTJF3ZYB6kzPsQJSrg6BS/0POgibnAlXyjkNhFUlRgMdvc6URz4/OmGofDIyOqpYLJ/n2YRGHBCa5UjOnuJBcXfO2HqsRLeXtKcrNHQ+epDqi8OdU+N3R3eayJqsrT67tq3vCHb9EGa1388UYlCUcwbCIrEPrIWGIfCjBA/OGl1Riwghtcw8EMboCij X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095135)(2401047)(5005006)(8121501046)(3002001)(10201501046)(3231023)(93006095)(93001095)(6055026)(6096035)(20161123561025)(20161123565025)(20161123559100)(20161123556025)(20161123563025)(201703131430075)(201703131520075)(201703131441075)(201703131448075)(201703131433075)(201703161259150)(201708071742011); SRVR:BN1PR0301MB0724; BCL:0; PCL:0; RULEID:(100000803101)(100110400095)(400006); SRVR:BN1PR0301MB0724; X-Forefront-PRVS: 052017CAF1 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN1PR0301MB0724; 23:JQInDzIn6cOZjmCqdycfL2m/+MxytniPUF5gdjT?= 6VBecy42JOlPpsXmVDYP66kvGQkMKlhHqd4dgL/cPo7hXrP0JvQMnEzb962e7AXPNyluPvVy/bmCk1vsMK2itKTpq7GG+R09RNwHelZtT6z3AXLoysVciS9sw/ffdRHhNzhvJcuyNa+Y+6ytOPFWjqgcTs43RuMhSf4QnSaCi7Cji9pg8cfAj/ZHrhSQjNHTZTbh7iA1QJgsbSjtkI/SZGiXtWaKfDS9TKVo6Uc+kMxQIKbLtamkIOHc+pQ4xuruHfHE4HUxJsanlrdQQu/9LKF8dDbLGebBDpHU60arP9+hCMTuU2cskJm+7NiIYf0jQDsJpci58xPKYxf91Po0Lc5Ks3y43brwCoqbFI1ZHNGI+urgrs/ywsCDch8w4dqLqFE+c49Zaq324V/IGWJ0RfHHKz4l+V9TLVbgbZU/mt9V3HvQpODEgn1VrjIkikUvLIiQMOpWgApE9LgASSDdX06uaUIUr32066yV/qZ3M39Foy9bYZldaJsZ6OchZhXKiQcXJ6T4eFOq1LI0Emt7hV0Za588YYp5zQ8/2+nE81FT4zuqrxXaqDnhU0JiZNihjFaX3MXVh9ccDcQ517mjvG6ywKERnsVO+iBLfgirfR2+32uQCnLORxQ883cfa2TS5w7jMje8UE7YtBQ6cobCQLPiHmnYFMtZ8KWdLmE2Zdrt1zc58U5eER2MIOeAh9NoxJYX6Y783V2YzjYKrqw6G3nAx3K/Jfk+Yi0QM/7G1YvcN0W8qg/2kvm7nKFp+a4My/nM5F2C3Vvkp+cNaUMoDhOg0pbUi5/nE0ch82Pl1PbkCKecYf1vCf9fwliQHhO8iLNoHeW29eOdk2aHgTNgGv/sW7BbvibUNH+rJrOAzi0lWp9OGYZrXB+NrUMuZwibEliC4CifVmEB0SB6XVI8lywymgU0qXv9PmQh25sGtP3StNakhRSxYx/rkhsQ1ADecIvBxrXoGUmpwuOHdtZsNqVPQGxhkP5f+I42nZM4KmyjfE6go7JDgOeXm/47Kv6BQjJFMV0RPTJbkTojxG1gdvnH7JBAVUL8G5sUqxv42EUpqUCfSx43j8l+YI23ivYHn1u06PrC9RXBvqRfnaaCFEIesbUOdR8EcJnS/LMV0AI2EKDUGg+SCUDhmANP5x3fdWUc= X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0724; 6:JkWO8FLDn20OvdGRE+CLIoDFGD8cRhuV1j3+uC1svR2BmN9yOVz6tqW7sOFKt8QRwV3fcGuAzb0VSEsmh5o73VwELaW58qv+ROvs5tThuTty8LJqi6rpDDyTats+tyYnoi9Fuu1sicV7YLjd8juPc+D+C3+oTlCqXSjJj+9X8iNZ7j9rKtJpvPMOLhj8AhsUqBiboRLqixe1rRdArfgUPy7j6kdH7KrKdtVh92B/4vMtGq+3TqrburJtSw5n4kw5shQlruhWCg37mTs6koCJZ+2302cexDjfyk8VJ9KTYoYMGHB7//Ah1jmBSzARYQmxeJD/LYaqECLpqvA+a1le+5ytI1754MeQUGWJlwoT/pE=; 5:hq2vbyzz6UKK00qBYV0cYtHcljgAUr3KjWGrZSBUJEoYGAS62URqGqUunyc07oHdMo6seo4l3GL25Uoum4oYQbhrAQA+rfrZa0BSwt2G9eEvOo630/85dtXMwQej2KuZiIUQ7b7byKpaRMSzcnTBN909A7uNY9L5SOsklOoiyY0=; 24:Cc5d3bNg8a76ZeByRLHgEMNxVgu7m7U94cLis9u4k2pNgS1NTpZm0WBF5NB//HA/EwAmVgCF7mHJ8R6e4B1Q/T7xjMqk5WDZHVONLvenwLs=; 7:nj4dozfie69Ysfnoj6eR45BXWx0YW5ruTe95oA69jvFZ3smRFn7IjQ0eQg3tzk/5HvedbSM4s4TyfXrrHtbp6SvkyBrwMx9F42mcEen+C0RdAtFpA21NQjcFVNyqnBYvqVMfKI9saFTs7A+iLNAvFkVbM5wDBrWgVXknGAE3BlFgTlh+zOl774dL9lTmyoHMOVhPIQ9hi/gG53ue52q6bMS6RMVOJY/lqMCJE/1Z8b5D0BEI5ZiP3/oID4avFFOY SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Dec 2017 14:00:33.9411 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 86a915f7-e70f-455a-8388-08d54231e12a X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN1PR0301MB0724 Subject: [dpdk-dev] [PATCH 2/5] crypto/dpaa_sec: support multiple sessions per qp 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" From: Hemant Agrawal Signed-off-by: Hemant Agrawal Acked-by: Akhil Goyal --- drivers/crypto/dpaa_sec/dpaa_sec.c | 154 +++++++++++++++++++++++++------------ drivers/crypto/dpaa_sec/dpaa_sec.h | 74 +++++++++--------- 2 files changed, 145 insertions(+), 83 deletions(-) -- 2.9.3 diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c index a1271be..b51db83 100644 --- a/drivers/crypto/dpaa_sec/dpaa_sec.c +++ b/drivers/crypto/dpaa_sec/dpaa_sec.c @@ -69,6 +69,9 @@ static uint8_t cryptodev_driver_id; static __thread struct rte_crypto_op **dpaa_sec_ops; static __thread int dpaa_sec_op_nb; +static int +dpaa_sec_attach_sess_q(struct dpaa_sec_qp *qp, dpaa_sec_session *sess); + static inline void dpaa_sec_op_ending(struct dpaa_sec_op_ctx *ctx) { @@ -177,15 +180,6 @@ dpaa_sec_init_rx(struct qman_fq *fq_in, rte_iova_t hwdesc, /* Clear FQ options */ memset(&fq_opts, 0x00, sizeof(struct qm_mcc_initfq)); - flags = QMAN_FQ_FLAG_LOCKED | QMAN_FQ_FLAG_DYNAMIC_FQID | - QMAN_FQ_FLAG_TO_DCPORTAL; - - ret = qman_create_fq(0, flags, fq_in); - if (unlikely(ret != 0)) { - PMD_INIT_LOG(ERR, "qman_create_fq failed"); - return ret; - } - flags = QMAN_INITFQ_FLAG_SCHED; fq_opts.we_mask = QM_INITFQ_WE_DESTWQ | QM_INITFQ_WE_CONTEXTA | QM_INITFQ_WE_CONTEXTB; @@ -197,9 +191,11 @@ dpaa_sec_init_rx(struct qman_fq *fq_in, rte_iova_t hwdesc, fq_in->cb.ern = ern_sec_fq_handler; + PMD_INIT_LOG(DEBUG, "in-%x out-%x", fq_in->fqid, fqid_out); + ret = qman_init_fq(fq_in, flags, &fq_opts); if (unlikely(ret != 0)) - PMD_INIT_LOG(ERR, "qman_init_fq failed"); + PMD_INIT_LOG(ERR, "qman_init_fq failed %d", ret); return ret; } @@ -383,7 +379,7 @@ dpaa_sec_prep_cdb(dpaa_sec_session *ses) { struct alginfo alginfo_c = {0}, alginfo_a = {0}, alginfo = {0}; uint32_t shared_desc_len = 0; - struct sec_cdb *cdb = &ses->qp->cdb; + struct sec_cdb *cdb = &ses->cdb; int err; #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN int swap = false; @@ -903,12 +899,10 @@ dpaa_sec_enqueue_op(struct rte_crypto_op *op, struct dpaa_sec_qp *qp) ses = (dpaa_sec_session *)get_session_private_data(op->sym->session, cryptodev_driver_id); - if (unlikely(!qp->ses || qp->ses != ses)) { - qp->ses = ses; - ses->qp = qp; - ret = dpaa_sec_prep_cdb(ses); - if (ret) - return ret; + if (unlikely(!ses->qp || ses->qp != qp)) { + PMD_INIT_LOG(DEBUG, "sess->qp - %p qp %p", ses->qp, qp); + if (dpaa_sec_attach_sess_q(qp, ses)) + return -1; } /* @@ -944,7 +938,7 @@ dpaa_sec_enqueue_op(struct rte_crypto_op *op, struct dpaa_sec_qp *qp) if (auth_only_len) fd.cmd = 0x80000000 | auth_only_len; do { - ret = qman_enqueue(&qp->inq, &fd, 0); + ret = qman_enqueue(ses->inq, &fd, 0); } while (ret != 0); return 0; @@ -1160,43 +1154,82 @@ dpaa_sec_aead_init(struct rte_cryptodev *dev __rte_unused, return 0; } -static int -dpaa_sec_qp_attach_sess(struct rte_cryptodev *dev, uint16_t qp_id, void *ses) +static struct qman_fq * +dpaa_sec_attach_rxq(struct dpaa_sec_dev_private *qi) { - dpaa_sec_session *sess = ses; - struct dpaa_sec_qp *qp; + unsigned int i; - PMD_INIT_FUNC_TRACE(); + for (i = 0; i < qi->max_nb_sessions; i++) { + if (qi->inq_attach[i] == 0) { + qi->inq_attach[i] = 1; + return &qi->inq[i]; + } + } + PMD_DRV_LOG(ERR, "All ses session in use %x", qi->max_nb_sessions); + + return NULL; +} - qp = dev->data->queue_pairs[qp_id]; - if (qp->ses != NULL) { - PMD_INIT_LOG(ERR, "qp in-use by another session\n"); - return -EBUSY; +static int +dpaa_sec_detach_rxq(struct dpaa_sec_dev_private *qi, struct qman_fq *fq) +{ + unsigned int i; + + for (i = 0; i < qi->max_nb_sessions; i++) { + if (&qi->inq[i] == fq) { + qi->inq_attach[i] = 0; + return 0; + } } + return -1; +} + +static int +dpaa_sec_attach_sess_q(struct dpaa_sec_qp *qp, dpaa_sec_session *sess) +{ + int ret; - qp->ses = sess; sess->qp = qp; + ret = dpaa_sec_prep_cdb(sess); + if (ret) { + PMD_DRV_LOG(ERR, "Unable to prepare sec cdb"); + return -1; + } - return dpaa_sec_prep_cdb(sess); + ret = dpaa_sec_init_rx(sess->inq, dpaa_mem_vtop(&sess->cdb), + qman_fq_fqid(&qp->outq)); + if (ret) + PMD_DRV_LOG(ERR, "Unable to init sec queue"); + + return ret; +} + +static int +dpaa_sec_qp_attach_sess(struct rte_cryptodev *dev __rte_unused, + uint16_t qp_id __rte_unused, + void *ses __rte_unused) +{ + PMD_INIT_FUNC_TRACE(); + return 0; } static int -dpaa_sec_qp_detach_sess(struct rte_cryptodev *dev, uint16_t qp_id, void *ses) +dpaa_sec_qp_detach_sess(struct rte_cryptodev *dev, + uint16_t qp_id __rte_unused, + void *ses) { dpaa_sec_session *sess = ses; - struct dpaa_sec_qp *qp; + struct dpaa_sec_dev_private *qi = dev->data->dev_private; PMD_INIT_FUNC_TRACE(); - qp = dev->data->queue_pairs[qp_id]; - if (qp->ses != NULL) { - qp->ses = NULL; - sess->qp = NULL; - return 0; - } + if (sess->inq) + dpaa_sec_detach_rxq(qi, sess->inq); + sess->inq = NULL; - PMD_DRV_LOG(ERR, "No session attached to qp"); - return -EINVAL; + sess->qp = NULL; + + return 0; } static int @@ -1259,8 +1292,20 @@ dpaa_sec_set_session_parameters(struct rte_cryptodev *dev, return -EINVAL; } session->ctx_pool = internals->ctx_pool; + session->inq = dpaa_sec_attach_rxq(internals); + if (session->inq == NULL) { + PMD_DRV_LOG(ERR, "unable to attach sec queue"); + goto err1; + } return 0; + +err1: + rte_free(session->cipher_key.data); + rte_free(session->auth_key.data); + memset(session, 0, sizeof(dpaa_sec_session)); + + return -EINVAL; } static int @@ -1293,6 +1338,7 @@ dpaa_sec_session_configure(struct rte_cryptodev *dev, set_session_private_data(sess, dev->driver_id, sess_private_data); + return 0; } @@ -1301,16 +1347,22 @@ static void dpaa_sec_session_clear(struct rte_cryptodev *dev, struct rte_cryptodev_sym_session *sess) { - PMD_INIT_FUNC_TRACE(); + struct dpaa_sec_dev_private *qi = dev->data->dev_private; uint8_t index = dev->driver_id; void *sess_priv = get_session_private_data(sess, index); + + PMD_INIT_FUNC_TRACE(); + dpaa_sec_session *s = (dpaa_sec_session *)sess_priv; if (sess_priv) { + struct rte_mempool *sess_mp = rte_mempool_from_obj(sess_priv); + + if (s->inq) + dpaa_sec_detach_rxq(qi, s->inq); rte_free(s->cipher_key.data); rte_free(s->auth_key.data); memset(s, 0, sizeof(dpaa_sec_session)); - struct rte_mempool *sess_mp = rte_mempool_from_obj(sess_priv); set_session_private_data(sess, index, NULL); rte_mempool_put(sess_mp, sess_priv); } @@ -1358,7 +1410,8 @@ dpaa_sec_dev_infos_get(struct rte_cryptodev *dev, info->capabilities = dpaa_sec_capabilities; info->sym.max_nb_sessions = internals->max_nb_sessions; info->sym.max_nb_sessions_per_qp = - RTE_DPAA_SEC_PMD_MAX_NB_SESSIONS / RTE_MAX_NB_SEC_QPS; + RTE_DPAA_SEC_PMD_MAX_NB_SESSIONS / + RTE_DPAA_MAX_NB_SEC_QPS; info->driver_id = cryptodev_driver_id; } } @@ -1403,7 +1456,7 @@ dpaa_sec_dev_init(struct rte_cryptodev *cryptodev) { struct dpaa_sec_dev_private *internals; struct dpaa_sec_qp *qp; - uint32_t i; + uint32_t i, flags; int ret; char str[20]; @@ -1419,7 +1472,7 @@ dpaa_sec_dev_init(struct rte_cryptodev *cryptodev) RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING; internals = cryptodev->data->dev_private; - internals->max_nb_queue_pairs = RTE_MAX_NB_SEC_QPS; + internals->max_nb_queue_pairs = RTE_DPAA_MAX_NB_SEC_QPS; internals->max_nb_sessions = RTE_DPAA_SEC_PMD_MAX_NB_SESSIONS; for (i = 0; i < internals->max_nb_queue_pairs; i++) { @@ -1430,10 +1483,15 @@ dpaa_sec_dev_init(struct rte_cryptodev *cryptodev) PMD_INIT_LOG(ERR, "config tx of queue pair %d", i); goto init_error; } - ret = dpaa_sec_init_rx(&qp->inq, dpaa_mem_vtop(&qp->cdb), - qman_fq_fqid(&qp->outq)); - if (ret) { - PMD_INIT_LOG(ERR, "config rx of queue pair %d", i); + } + + flags = QMAN_FQ_FLAG_LOCKED | QMAN_FQ_FLAG_DYNAMIC_FQID | + QMAN_FQ_FLAG_TO_DCPORTAL; + for (i = 0; i < internals->max_nb_sessions; i++) { + /* create rx qman fq for sessions*/ + ret = qman_create_fq(0, flags, &internals->inq[i]); + if (unlikely(ret != 0)) { + PMD_INIT_LOG(ERR, "sec qman_create_fq failed"); goto init_error; } } diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.h b/drivers/crypto/dpaa_sec/dpaa_sec.h index eba07b6..11407d3 100644 --- a/drivers/crypto/dpaa_sec/dpaa_sec.h +++ b/drivers/crypto/dpaa_sec/dpaa_sec.h @@ -64,36 +64,6 @@ enum dpaa_sec_op_type { DPAA_SEC_MAX }; -typedef struct dpaa_sec_session_entry { - uint8_t dir; /*!< Operation Direction */ - enum rte_crypto_cipher_algorithm cipher_alg; /*!< Cipher Algorithm*/ - enum rte_crypto_auth_algorithm auth_alg; /*!< Authentication Algorithm*/ - enum rte_crypto_aead_algorithm aead_alg; /*!< Authentication Algorithm*/ - union { - struct { - uint8_t *data; /**< pointer to key data */ - size_t length; /**< key length in bytes */ - } aead_key; - struct { - struct { - uint8_t *data; /**< pointer to key data */ - size_t length; /**< key length in bytes */ - } cipher_key; - struct { - uint8_t *data; /**< pointer to key data */ - size_t length; /**< key length in bytes */ - } auth_key; - }; - }; - struct { - uint16_t length; - uint16_t offset; - } iv; /**< Initialisation vector parameters */ - uint16_t auth_only_len; /*!< Length of data for Auth only */ - uint32_t digest_length; - struct dpaa_sec_qp *qp; - struct rte_mempool *ctx_pool; /* session mempool for dpaa_sec_op_ctx */ -} dpaa_sec_session; #define DPAA_SEC_MAX_DESC_SIZE 64 /* code or cmd block to caam */ @@ -143,11 +113,41 @@ struct sec_cdb { uint32_t sh_desc[DPAA_SEC_MAX_DESC_SIZE]; }; +typedef struct dpaa_sec_session_entry { + uint8_t dir; /*!< Operation Direction */ + enum rte_crypto_cipher_algorithm cipher_alg; /*!< Cipher Algorithm*/ + enum rte_crypto_auth_algorithm auth_alg; /*!< Authentication Algorithm*/ + enum rte_crypto_aead_algorithm aead_alg; /*!< Authentication Algorithm*/ + union { + struct { + uint8_t *data; /**< pointer to key data */ + size_t length; /**< key length in bytes */ + } aead_key; + struct { + struct { + uint8_t *data; /**< pointer to key data */ + size_t length; /**< key length in bytes */ + } cipher_key; + struct { + uint8_t *data; /**< pointer to key data */ + size_t length; /**< key length in bytes */ + } auth_key; + }; + }; + struct { + uint16_t length; + uint16_t offset; + } iv; /**< Initialisation vector parameters */ + uint16_t auth_only_len; /*!< Length of data for Auth only */ + uint32_t digest_length; + struct dpaa_sec_qp *qp; + struct qman_fq *inq; + struct sec_cdb cdb; /**< cmd block associated with qp */ + struct rte_mempool *ctx_pool; /* session mempool for dpaa_sec_op_ctx */ +} dpaa_sec_session; + struct dpaa_sec_qp { struct dpaa_sec_dev_private *internals; - struct sec_cdb cdb; /* cmd block associated with qp */ - dpaa_sec_session *ses; /* session associated with qp */ - struct qman_fq inq; struct qman_fq outq; int rx_pkts; int rx_errs; @@ -155,12 +155,16 @@ struct dpaa_sec_qp { int tx_errs; }; -#define RTE_MAX_NB_SEC_QPS RTE_DPAA_SEC_PMD_MAX_NB_SESSIONS +#define RTE_DPAA_MAX_NB_SEC_QPS 1 +#define RTE_DPAA_MAX_RX_QUEUE RTE_DPAA_SEC_PMD_MAX_NB_SESSIONS + /* internal sec queue interface */ struct dpaa_sec_dev_private { void *sec_hw; struct rte_mempool *ctx_pool; /* per dev mempool for dpaa_sec_op_ctx */ - struct dpaa_sec_qp qps[RTE_MAX_NB_SEC_QPS]; /* i/o queue for sec */ + struct dpaa_sec_qp qps[RTE_DPAA_MAX_NB_SEC_QPS]; /* i/o queue for sec */ + struct qman_fq inq[RTE_DPAA_MAX_RX_QUEUE]; + unsigned char inq_attach[RTE_DPAA_MAX_RX_QUEUE]; unsigned int max_nb_queue_pairs; unsigned int max_nb_sessions; };