From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0085.outbound.protection.outlook.com [104.47.33.85]) by dpdk.org (Postfix) with ESMTP id 66291AAA4 for ; Mon, 19 Mar 2018 13:24:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=ryKxF0Cm7eZVT6MbRwZD+wWJU7+Oeb1RnCw+K4h1UU0=; b=1kDFaciHL57C6BFccpxI1RCJ8JpEiHXim78c/l3P7SL84AF1A6uUXmhjwwy8qMVmPCX/B29p3jqkBQkR6SKwHazfGs5i5Je0xbSWMU+w2lwwSC/qwrZxhYw/JMXX3Yz2k066jeLxbQ15xfuBaqbwJ83Efi1vvlNcLVvkWddDYLE= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Ravi1.Kumar@amd.com; Received: from wallaby-smavila.amd.com (202.56.249.162) by BN6PR12MB1505.namprd12.prod.outlook.com (10.172.24.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.588.14; Mon, 19 Mar 2018 12:24:24 +0000 From: Ravi Kumar To: dev@dpdk.org Cc: pablo.de.lara.guarch@intel.com, hemant.agrawal@nxp.com Date: Mon, 19 Mar 2018 08:23:39 -0400 Message-Id: <1521462233-13590-5-git-send-email-Ravi1.kumar@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521462233-13590-1-git-send-email-Ravi1.kumar@amd.com> References: <1520584520-130522-1-git-send-email-Ravi1.kumar@amd.com> <1521462233-13590-1-git-send-email-Ravi1.kumar@amd.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [202.56.249.162] X-ClientProxiedBy: MAXPR0101CA0025.INDPRD01.PROD.OUTLOOK.COM (10.174.62.139) To BN6PR12MB1505.namprd12.prod.outlook.com (10.172.24.146) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 4cccf112-a020-4578-c385-08d58d945aa8 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:BN6PR12MB1505; X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1505; 3:JV2Rts2nqY93tes+oxytjPnPLDdFy48Hr7ApNP9T1UUJpi5z9nSo6Vuf+NnEMEx8IIKjKHadTUqhW+8DNT3cGWLgktUkrP/YT/H2C4Hb9BJ2OTqIgph6ybRtUnZ5Ogm13AVAJOq2AcDA3mLInH1BO3OTZnrKR8m43FszPaph7djikseq3XSB3z+5AK1+GJU7W58BkonbgI1tDZiG4XENJH/SgjEVmW+sGoNaHobNhSzt1/5zjKndldYkF+7T7LmB; 25:eF9r0X6lULsAq7XCSeqrV8NjoqgaWXB/74p5fDhXn1sSBVIa0sXY/ZhQXL/TvPhGgNZZgWbxydOQDtJbyxJCFWRZNBr+NJqppahUbEjy/KpKXcbaNY3dHinjqHlMnnyv69Q7R+FYYZfmfpJELzKN1yXcx14OKJrX5JW6JAUOx0CQ/QLsE+SoroGgqSMJK2BFCBOGu/b46VadxIObXREpG2PD1fFlBI0M6A/R2zlrAf+rpVcSvltyJRNi1T8exIoPquBRNE7S3AvwdhDf9cv4zYjQIlmKiICC08uOOKJ2FuPapHmabv5yraf0lV+DygTwNhWhs8KWcNrVrvL+XCIWtw==; 31:cBT5nHbbMpXzTl1HOjxCfOUJws076BEn4G7OegME5j0E4ZM84geBBJBpmCC2x3CvGyBv9OG0+eYiQhsGP+LlLIBSFurhRM0RmFqCyfZyVKznQ6PcLPWGovxjK4J+RxhlwGVJYw5RRCvQdXGTY5q8p8vqKdV3OkGYupMmNlENjL43xdnqiXk77V73asJBZn406Gy96YpoP53g6KtQ6MeXptV7Walk38mV1QFVLgqEQm8= X-MS-TrafficTypeDiagnostic: BN6PR12MB1505: X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1505; 20:FmZwaxbecekoq4UqWlzVeLhzUz+MguQMRM+IbJncpSUUOPPf2moTkNjq8F3RG8/YmPaKwhjdqyhG2kxBT0L/jfC39HsD3+IfaX7k1olimMUuJ9wTBYhDEf9//RGngsctuoUgFKYoSTmXGavDstxqRbpRZsIvk4wxtepF3uuvEByr/XOD98lT9fvYWkhu0Y/D2ALxSlA52Uz+vlm2XfYVTTCj/5cijnSCz7xeL7j8lQbdLI1vXlSO1ZgdjV3PfvqWHo62FhRqcMmPAMqfc/LB5dxBzliB+fCUG+s7i3Yi5FkxgsenKWOIK7iigtuR/eQuVSMbBj+1Ec7APLgfrh76RC0N+eFaKWJUdl+qU2ps5S5vx2LmG/xfzLBGeYYFwZGoE3qroSy9u3HwkOmdgHFyjpqNnq4rXwR60wdhKVQ4MrxIKz2zl1sDZxIL//jKjeItV6LCu9EYl5bEBgZvABes8eJjZmOx4/A8PxQwA8PzbRvQAzqiCUJ/RcDUpjcL//xq; 4:WYc/p+ZswbAok0XuIhslEJWPVwznCb8x/9e+HW/A33LDpiqaytuODcPVrBPjribmVHXHqtiHgMWT3mrWVmhjy+Pxc8Lc+5OJ3VVWXvMv0q5B4BPStnbTVpz7aWDTc8AfIXOIpuqZrwOUCE9FITXwwzlg0nINLmRNTnlb7CY+Xkb1XfQltCOIJXA0abkhe0wzJDKYtFs/52kjPxKtMZ82fsGmdsd5g0uXIoLI0Cc4zjEy03d5F9JN6v6nDXUZRLyb+r8LwAT7aaJ5wy/Pu7pXW6gUDPwVJIjDWrH6ir1aK/3dpQjywgiUnayFUu0MyL0z X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231221)(944501300)(52105095)(3002001)(93006095)(93001095)(10201501046)(6055026)(6041310)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123558120)(6072148)(201708071742011); SRVR:BN6PR12MB1505; BCL:0; PCL:0; RULEID:; SRVR:BN6PR12MB1505; X-Forefront-PRVS: 06167FAD59 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(39380400002)(39860400002)(346002)(376002)(366004)(199004)(189003)(97736004)(105586002)(2361001)(2351001)(72206003)(48376002)(4326008)(50226002)(76176011)(8676002)(26005)(316002)(8936002)(53936002)(106356001)(16586007)(186003)(7696005)(51416003)(16526019)(52116002)(386003)(81166006)(81156014)(8656006)(25786009)(575784001)(66066001)(68736007)(86362001)(47776003)(6486002)(5660300001)(6666003)(7736002)(53416004)(6116002)(305945005)(3846002)(478600001)(2950100002)(36756003)(6916009)(2906002)(50466002); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR12MB1505; H:wallaby-smavila.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN6PR12MB1505; 23:x4J0NcVHa1sue92ivAcK3DCBoAj0e3/Vtj+RMcPHH?= =?us-ascii?Q?hWanOQfs+rKle6vu5+f9xOim4Sa2BDcxffCMJcFedaCwno8D6ND/Vw5fLIo2?= =?us-ascii?Q?cLqZVHMhemgffTfUu8vUdLaAfEFxaCvra8IDyCAnOgkntHK1CeouJ4mqgX1S?= =?us-ascii?Q?NQ0qVfxEB5IRntn5U+trjfakFPDaPH3S3U4I5mzqO50S+f1a0We52OlYGGnD?= =?us-ascii?Q?X8o6xIvKeEpQWtx/o5d4DkxUKGo2z8IMfbqE7t6PUUxxALjimPG2xW7DW12k?= =?us-ascii?Q?DTIylTg5TmLLrDlcwnWSe7eCIbvDmqnSbcCOlV+UFfkRA2oqxt7UnRxIYczW?=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ACWmGF5A/3JTkR1KVkBBxoB0BsrhgyKqSPuwPMATPrrSPGpUb6Oz3KgquPQ1N3nHrOlXT/Ck0hFgBhtwZGMPcEyEqbN0pPE9b2eAGK6zY SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1505; 20:wm/+IgFd8P4CqF1yA3OpnFH0cEcBajvqBIneAt0wYmvatN721w6odHJTYFVAUBimlm/Q9oap/PwGMj2mJ7rizzheSL8vV5RQSItsGQcho1FLvmXno0OHfAN/U8ZxMMM2F58JrTZzaCB6SBqlgJY3e8KPhOAJezwQ9osLnOLJ4TjJKuVLt7d++07FxakRBayl4I6WZ4jessNbcoxIVsumS9SPv/lH2ZXgwV594VzIeR1o04cNzdJxyooIiiJeSBXa X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Mar 2018 12:24:24.5547 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4cccf112-a020-4578-c385-08d58d945aa8 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1505 Subject: [dpdk-dev] [PATCH v5 05/19] crypto/ccp: support queue pair related pmd ops 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: Mon, 19 Mar 2018 12:24:27 -0000 Signed-off-by: Ravi Kumar --- drivers/crypto/ccp/ccp_pmd_ops.c | 149 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 144 insertions(+), 5 deletions(-) diff --git a/drivers/crypto/ccp/ccp_pmd_ops.c b/drivers/crypto/ccp/ccp_pmd_ops.c index 0560f68..bd0aea4 100644 --- a/drivers/crypto/ccp/ccp_pmd_ops.c +++ b/drivers/crypto/ccp/ccp_pmd_ops.c @@ -56,6 +56,145 @@ ccp_pmd_info_get(struct rte_cryptodev *dev, } } +static int +ccp_pmd_qp_release(struct rte_cryptodev *dev, uint16_t qp_id) +{ + struct ccp_qp *qp; + + if (dev->data->queue_pairs[qp_id] != NULL) { + qp = (struct ccp_qp *)dev->data->queue_pairs[qp_id]; + rte_ring_free(qp->processed_pkts); + rte_mempool_free(qp->batch_mp); + rte_free(qp); + dev->data->queue_pairs[qp_id] = NULL; + } + return 0; +} + +static int +ccp_pmd_qp_set_unique_name(struct rte_cryptodev *dev, + struct ccp_qp *qp) +{ + unsigned int n = snprintf(qp->name, sizeof(qp->name), + "ccp_pmd_%u_qp_%u", + dev->data->dev_id, qp->id); + + if (n > sizeof(qp->name)) + return -1; + + return 0; +} + +static struct rte_ring * +ccp_pmd_qp_create_batch_info_ring(struct ccp_qp *qp, + unsigned int ring_size, int socket_id) +{ + struct rte_ring *r; + + r = rte_ring_lookup(qp->name); + if (r) { + if (r->size >= ring_size) { + CCP_LOG_INFO( + "Reusing ring %s for processed packets", + qp->name); + return r; + } + CCP_LOG_INFO( + "Unable to reuse ring %s for processed packets", + qp->name); + return NULL; + } + + return rte_ring_create(qp->name, ring_size, socket_id, + RING_F_SP_ENQ | RING_F_SC_DEQ); +} + +static int +ccp_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id, + const struct rte_cryptodev_qp_conf *qp_conf, + int socket_id, struct rte_mempool *session_pool) +{ + struct ccp_private *internals = dev->data->dev_private; + struct ccp_qp *qp; + int retval = 0; + + if (qp_id >= internals->max_nb_qpairs) { + CCP_LOG_ERR("Invalid qp_id %u, should be less than %u", + qp_id, internals->max_nb_qpairs); + return (-EINVAL); + } + + /* Free memory prior to re-allocation if needed. */ + if (dev->data->queue_pairs[qp_id] != NULL) + ccp_pmd_qp_release(dev, qp_id); + + /* Allocate the queue pair data structure. */ + qp = rte_zmalloc_socket("CCP Crypto PMD Queue Pair", sizeof(*qp), + RTE_CACHE_LINE_SIZE, socket_id); + if (qp == NULL) { + CCP_LOG_ERR("Failed to allocate queue pair memory"); + return (-ENOMEM); + } + + qp->dev = dev; + qp->id = qp_id; + dev->data->queue_pairs[qp_id] = qp; + + retval = ccp_pmd_qp_set_unique_name(dev, qp); + if (retval) { + CCP_LOG_ERR("Failed to create unique name for ccp qp"); + goto qp_setup_cleanup; + } + + qp->processed_pkts = ccp_pmd_qp_create_batch_info_ring(qp, + qp_conf->nb_descriptors, socket_id); + if (qp->processed_pkts == NULL) { + CCP_LOG_ERR("Failed to create batch info ring"); + goto qp_setup_cleanup; + } + + qp->sess_mp = session_pool; + + /* mempool for batch info */ + qp->batch_mp = rte_mempool_create( + qp->name, + qp_conf->nb_descriptors, + sizeof(struct ccp_batch_info), + RTE_CACHE_LINE_SIZE, + 0, NULL, NULL, NULL, NULL, + SOCKET_ID_ANY, 0); + if (qp->batch_mp == NULL) + goto qp_setup_cleanup; + memset(&qp->qp_stats, 0, sizeof(qp->qp_stats)); + return 0; + +qp_setup_cleanup: + dev->data->queue_pairs[qp_id] = NULL; + if (qp) + rte_free(qp); + return -1; +} + +static int +ccp_pmd_qp_start(struct rte_cryptodev *dev __rte_unused, + uint16_t queue_pair_id __rte_unused) +{ + return -ENOTSUP; +} + +static int +ccp_pmd_qp_stop(struct rte_cryptodev *dev __rte_unused, + uint16_t queue_pair_id __rte_unused) +{ + return -ENOTSUP; +} + +static uint32_t +ccp_pmd_qp_count(struct rte_cryptodev *dev) +{ + return dev->data->nb_queue_pairs; +} + static unsigned ccp_pmd_session_get_size(struct rte_cryptodev *dev __rte_unused) { @@ -121,11 +260,11 @@ struct rte_cryptodev_ops ccp_ops = { .dev_infos_get = ccp_pmd_info_get, - .queue_pair_setup = NULL, - .queue_pair_release = NULL, - .queue_pair_start = NULL, - .queue_pair_stop = NULL, - .queue_pair_count = NULL, + .queue_pair_setup = ccp_pmd_qp_setup, + .queue_pair_release = ccp_pmd_qp_release, + .queue_pair_start = ccp_pmd_qp_start, + .queue_pair_stop = ccp_pmd_qp_stop, + .queue_pair_count = ccp_pmd_qp_count, .session_get_size = ccp_pmd_session_get_size, .session_configure = ccp_pmd_session_configure, -- 2.7.4