From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0070.outbound.protection.outlook.com [104.47.42.70]) by dpdk.org (Postfix) with ESMTP id BBDA81B1FA for ; Wed, 10 Jan 2018 10:43:29 +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=O0iF9dZGeSiHJlN6DifWVKsNP9gMHedy78suEezr5BU=; b=Wyqd5Oztl+ty6iJxxwFoEW1MznBchMzXRPwv7JjvlwRMuO8IIhxPp5j7nFGc1TvB3s7m/q595omTZuwoXInAqNdUmqPV3JkvTFsERDOFuP58PszM9zagmh6oMBbJmxRxSJc25RDbR1N2T9+9UJQjbN9a9SOUU42C+NzQIGHbv/I= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Ravi1.Kumar@amd.com; Received: from wallaby-smavila.amd.com (202.56.249.162) by CY4PR12MB1509.namprd12.prod.outlook.com (10.172.68.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.386.5; Wed, 10 Jan 2018 09:43:27 +0000 From: Ravi Kumar To: dev@dpdk.org Cc: pablo.de.lara.guarch@intel.com Date: Wed, 10 Jan 2018 04:42:45 -0500 Message-Id: <1515577379-18453-5-git-send-email-Ravi1.kumar@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515577379-18453-1-git-send-email-Ravi1.kumar@amd.com> References: <1515145198-97367-1-git-send-email-Ravi1.kumar@amd.com> <1515577379-18453-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: MAXPR0101CA0024.INDPRD01.PROD.OUTLOOK.COM (10.174.62.34) To CY4PR12MB1509.namprd12.prod.outlook.com (10.172.68.22) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 3c51c8c6-582a-43f7-32de-08d5580e9a51 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020049)(4652020)(48565401081)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:CY4PR12MB1509; X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1509; 3:p3m5z0+ahdboCKI77G8q8hixqSzKamJxmPn87G9oLYC+53EeJeB2jau51MY0EakTeFaUfQCAfrfSg9+5NhlMnXRXlVEq+LCieOY8n7JWrzLVLfcjT+IGPvLHrcjoIZwJcI5OiTTAPsnZ9fvpmXytOXV8yxr2DR6gAa2ruGP1ApEQ9FqEbPjAA2Z3g/fuVf/MQt+ke1AGO5h0Iw6S8PGaxJBpA0m6JwKHZ7ToQUfqhPqewf00iR3jUD3VDOFv48Oe; 25:nFrY6AOvLU1qdmsw2Ui6xN6FPr1RsEjUh9W3Izin/rIvImpG10IMIUHINaGrji5NeWUxTz1vQN+XKDKwjn7BgyHYaN3optfSBBr3sHROo1BMV+DXAEaXKsakv5YcI92fEY2EtYSXJk2r0xJQYlxDi45BzzklwZUCe7Ly0t4Tj0qg8T2hgsl4E6OJx4Xp64+WAOa8ZPfjuSVqe4NDq+ZZmx5VOKpgAlwpxW7yL7VdJ6XSEFXJFxO4oSeSSpw3DRg5leGSwhZNnSyGyJG8/cGHMk8BjeM2If6FcFIUcMHCJj582KtGr9q0o3y3A8HMG86F0k27nkXm3Yd9SST7I/LgLQ==; 31:YDzfx1WaQaQZTo7D+yOBn3m97x83htjggGOKsQoiHiFpu4YxwH4qcHNqJesU1a9b7guv6zuNuUw3uKvxZcp6tE/gossm59jpy5s6Ow1lwRAcncXzFqWS83kg+sHo5u5qJcHce+TsLC/xoYg7OTUvYeUP/DFyJ0Zai4waymBmj+60CA66XjGk+CjN+zgIvw+nfjmyqv4IbzVzdHCft/bNtC0O1bk56b67p+8LRDgfCOE= X-MS-TrafficTypeDiagnostic: CY4PR12MB1509: X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1509; 20:tjGopXl3WSCSX5zD6Lcky1mJF8ysBPm8IEOBg//YBNj6mf/qrMlc5pBYf8IczOOD6uvo7eeRMsYZer33zjbwB2A2GfzJRa86bVj43SGrRaQgaJlE+2mpawYdo2Gz/rdRJtGZjUc80EBY8PLSNnkl80X27DFbjwYo1KlNbVxzX7a/+QPFjxpfVbbUrWVIXEVCl7O3LemVgsGwxpE6TmjLopk3jHXOCewObNjMhwXsJc2LdkenKr3clmbdH5rK2na+nflucUU6usCZ2TFp8XkVNP3WkGXFbsqvG/egQjk8k4rtt9el5ed6Gm3aRcNoNZyfq77tDY5f57jLoFdBkM09g18nYjJHeeFmntUHUdgnKU1GXhKDGAzcV/OGGE9SfCOFBVpyT1DBKkV0h68gFOyU0koKVokrYlLnT2HzR/M61g7uCEcGyAWARLOXOQ8VCFUQvggFwJvEPPDg8Rsp1HOTMZap1LF7pu16wDKGIYNnuQ23caVPp0eAkhryI0f8hJZX; 4:/h9UG+dazUJ5lQEsA8YjhMQac60LtXnNunBHhyJ24lTpEMm+9SB1rJp03QwXDmI8rjtY1u+ulzM7FQ6szrf0MIb3tRTxoSYq7vOsei6AaMds5b/DNcAG3NnLkDcrjZTLTZECIHI9AsCL+h/fojQ6WXWVylDmdK+Knkz5V5qnWE8WrBRwygH/nECi+qaP+uJd2DZKoPqNXlbLLkFD+Mrl/wQEjuGGIdyLBBPIRNXOXh+ANinwHDl4L84Cxf1+G85btdSsreyGm9GoCiNm/xObaxv3SWtElvlujG3ciWyCkeCEyliItrBwODjOrdv9iTkK X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(8121501046)(5005006)(93006095)(93001095)(3002001)(10201501046)(3231023)(944501119)(6055026)(6041268)(20161123562045)(20161123558120)(20161123560045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:CY4PR12MB1509; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:CY4PR12MB1509; X-Forefront-PRVS: 0548586081 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(39860400002)(396003)(346002)(376002)(39380400002)(189003)(199004)(25786009)(8676002)(81166006)(47776003)(48376002)(6666003)(2950100002)(81156014)(6916009)(66066001)(50226002)(68736007)(36756003)(8936002)(16586007)(72206003)(50466002)(16526018)(316002)(53936002)(478600001)(5660300001)(86362001)(575784001)(4326008)(386003)(2361001)(2351001)(6486002)(53416004)(97736004)(51416003)(76176011)(106356001)(105586002)(7736002)(6116002)(3846002)(2906002)(305945005)(7696005)(52116002); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR12MB1509; H:wallaby-smavila.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A: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; CY4PR12MB1509; 23:ucy6Y38QMoQtJj3TWwct1RB783yfmfx6DO7EViUhp?= =?us-ascii?Q?ZhzvqSOPV2hIKmTjDWL9o3jsoR1PARDHd3CzuCxiD2tl3UIJSfSsGKglRqeH?= =?us-ascii?Q?iJw7IUCU6wvd2BwPEOH1MmPfcFhzvXXVaXElz5dAljbAd06SmQJqCoQ5z4K5?= =?us-ascii?Q?xSkKdcmwvhVmatrxp/9maa5D1zCMuHBVm80Twttnl0XCEpOnHzCqM9YtmmK3?= =?us-ascii?Q?y9piwD2z3NDuA3Yacy6dRmgpMmmqJpPTpMzTWlT86f3/5LMgGNitoUqU0u7p?= =?us-ascii?Q?NQ7QwQbe4iJr6LdCyRvpVHGSo6nflDHxx111pP+l4Jux9vv8fJ0IQYAFWeor?= =?us-ascii?Q?UzKC0uOgbF3XNanBdmpOW9KsaaMDx/cQCWMLkk1e2BHB3V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56VsnSoukQbOhClx4Ibznuh2UYNKjdf4YxLTgt9dLjPYZGC4svLuF+RkOtlSLUM2Zy82IgnRUM02Ts1dc1A5YK3nhjtF/5qbh8QEvnSXF X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jan 2018 09:43:27.5373 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3c51c8c6-582a-43f7-32de-08d5580e9a51 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1509 Subject: [dpdk-dev] [PATCH v3 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: Wed, 10 Jan 2018 09:43:30 -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 ad0a670..a02aa6f 100644 --- a/drivers/crypto/ccp/ccp_pmd_ops.c +++ b/drivers/crypto/ccp/ccp_pmd_ops.c @@ -82,6 +82,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) { @@ -147,11 +286,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