From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0055.outbound.protection.outlook.com [104.47.38.55]) by dpdk.org (Postfix) with ESMTP id 3D1305F16 for ; Fri, 9 Mar 2018 09:35:50 +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=msbilWHNwM9IhaA674wdXASmCmlEZC5C+0hnesj+EanU93ZuouU7MTbePX9tRqZYkrhlk6QfY36NXlOiir9eqj844vJ9ZuljPKP6i3IDhUkZAt4mWWUOro8rV8qWrVKQh6DA/VFrt3PwzMH17lnK7P0ah+DxzeCG3qNLsQPnXmI= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Ravi1.Kumar@amd.com; Received: from wallaby-smavila.amd.com (202.56.249.162) by MWHPR12MB1518.namprd12.prod.outlook.com (2603:10b6:301:b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.548.14; Fri, 9 Mar 2018 08:35:47 +0000 From: Ravi Kumar To: dev@dpdk.org Cc: pablo.de.lara.guarch@intel.com Date: Fri, 9 Mar 2018 03:35:05 -0500 Message-Id: <1520584520-130522-5-git-send-email-Ravi1.kumar@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520584520-130522-1-git-send-email-Ravi1.kumar@amd.com> References: <1515577379-18453-1-git-send-email-Ravi1.kumar@amd.com> <1520584520-130522-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: MA1PR0101CA0050.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:20::12) To MWHPR12MB1518.namprd12.prod.outlook.com (2603:10b6:301:b::22) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: ebc6a8d1-a952-4bb4-244c-08d58598c28d X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:MWHPR12MB1518; X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1518; 3:8Ah28TrjEvbtm3nS/YPUJuJCM1BlSHPXtEHUO5Qs0YyAAH/mw//9ZIv8nLb3eFigOYQZpNgh1YYDLDjJKToJNgqYXRY8ifXgnig6rZ1DDElDsgTsGW7/2a0cCE5oGPqaH+yw4lxDXWJ8Eb/ckdvG2HxuZFIoDkKn0fi0psEyRxix3Jh06XNsr2YsPL1GqnUUtD6XH+/kQ6CoUEOgnGwzUIzyezojSGoNgb5bJq28rcZ8IC9/7Pnl7oMmVwcRbuDx; 25:ygZCeI+1aqD6URKtXEn46/Gv6H6NKsUHdDOOpN6UgJIjpGDS4/H61G2b00n6tvubW8UD5t/q0MTLyhu2TjvvTimBxzANjqcxeADS/Gv5xrWKC/91e0oljPs+3kRee8Netrfkvlx4bZK5YpROF6O66u40bMgGHujri3lKthUiFVwZzmIw4+HhkJBnQasyF+x29a/f3+5qfUT6Dek2vPcAVWMUQOzjyJRdUOqgBY0+rhI3Iud4B6dRRAlRLG4BIzYrDO1cBihEmKXi18Xzuwfc2N3GZI4Y6SkpTEvfEQsrelDHc9Trc7LaEaoPtIp10/Yx0a2BJDaYGTUnZuiuVbcx0Q==; 31:kDsx+ZS5Wj0GopJDFGbPUo0LbsM6+25rXv8HZUVfhLzsI/meeW59dmX2YS1xErlT/jvRobm8nN+jSOXBLwwWT2q9CI91XKAfTj3kyUvoEB2PU50TZxaJaPH7Gowgd+K76ifbWbB0MSBBCCznlr/JqCnUVipyH7StrpT0pbIqFXmHS2J6LvEKJXziqH+WovzFRnmtBjk8DZyF8lFDtGWk7V9ZbbeoBl2bnDRhUH2D/lc= X-MS-TrafficTypeDiagnostic: MWHPR12MB1518: X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1518; 20:P2UhRpQkwb9VGZUvGOXu0J6ekBO96YPrW/upgauDDCHjfouft5732l9TAXFWcstgQvvsIR4WX3mJ2ol+f4p3i1nSvJLN+5WRuqMKw6d2y/KzQDjTPRcwgDacrggo25dcGc6MHFe+uUCCfnRmvX1wA2x1m/35APXLmOaNIAVL7NMkNdYxZoIIqW9aquIIQw60PxlDR3YN+TjMvF/9qL/bfiAbnI+TdnSxpDWA28+1U4JuM8E/wVn7RymTyfs6BifEQDuaeZS1kp+vw69v4bcugH/ke5v57ZSZP0+9EZKaOC8CZPlKOSiGkyTsAn9GJxnVaPpLdivVT59fAZKnwFwLhgUFpFzMAAWysp0epsYZDwfHcGHpmQnMS1Fs3BfFTX1fqwS87cNxhE75XtdcjTl+VoZju4Z9ccrRYc5U6SjpkpkcfMBXp52V1GiMkCotMwbTgsNXHzi0ZHZquWMjjZDugUaXroUdJ5jLHB14XrIRc4nevTy3ZvEw1OwxWUwch1nY; 4:klDcof2tsvwtTMU1i3fXrnge5movGX29+tv/8x7BSxULHhEOS4vNYCMatZGkG9NNH93daemI4QEje9YMJuX2fn7UUzebRbMvCe/escGCCCJI7+fTT/tdtcaDVz2JnjjCCLWqybaGyFarPMNv8x83jHauZqOJib7PhXVF1+6Z408Dv8Ay5JgpqN9mw707jJ/jE9b+hngI2FB5mDvCgS8JtCruoEEmX8dq7JkEnkGVydFTy7+jFOAxMj8XKtwgA23wgkCX3M6/MySeaqeyXD7hhzT65DM/Yq1nSNQpA8yTWZ2kY23I8EsCk364nWWbbUxq 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)(3002001)(3231220)(944501244)(52105095)(10201501046)(93006095)(93001095)(6055026)(6041310)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:MWHPR12MB1518; BCL:0; PCL:0; RULEID:; SRVR:MWHPR12MB1518; X-Forefront-PRVS: 0606BBEB39 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39860400002)(39380400002)(396003)(366004)(376002)(346002)(199004)(189003)(16586007)(26005)(81156014)(16526019)(8676002)(186003)(81166006)(25786009)(7736002)(3846002)(386003)(305945005)(4326008)(6116002)(6666003)(316002)(86362001)(76176011)(52116002)(8936002)(51416003)(575784001)(50226002)(5660300001)(2906002)(2950100002)(6916009)(7696005)(36756003)(106356001)(105586002)(6486002)(68736007)(48376002)(97736004)(53416004)(2361001)(2351001)(53936002)(50466002)(478600001)(47776003)(66066001)(72206003); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR12MB1518; 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; MWHPR12MB1518; 23:E3Y3lFzQuO4BAZ1KQcdEukGLw47pdWXAXZkHZo9fv?= =?us-ascii?Q?Afq9E9u3zqAStrmihtIlTsCFmEj+5gRdFAg9+QqZxuviHMCIHNhQk8D8aMXQ?= =?us-ascii?Q?cLnNxvFlgDlp9SuMQRazoSaLVJHzrMprkZD3vq74+BFU0AqPYGSI2HOxJfqS?= =?us-ascii?Q?VgSI3w60G8hyREShBqnjXX/330KK4ZwvIgFMucNrn03c8HgawKW/aTsZrMVI?= =?us-ascii?Q?wRhR6RGdf42WO6GYfY+54Vv/d8Wr3IhW1B5Qfr0QdVCsgjGMtDWdyozEGMTT?= =?us-ascii?Q?t2/0t/0jplSjCW13kFCRlP5eDpBTJdXjnmg42tHY7yFDpVyGQcJi7W1g4u3w?= =?us-ascii?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tDGL7onG1KKGmMa1mDEiy96Kw2+/4SplsEKhYERwFPlSFOl4JieVqkjhHiDmwh4sm SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1518; 20:rQcI960EHwJ1FG9rWvlb1aFhOBfDHgcGl1enrFI+b+I6F2Ojy1jZBfh7Evmnp3tl23BPLrPYIBU7pPYzvctCiYKze2Emeqg9aP+SgMy4q9L35tzOxrOYOkbdSDUGxLWfpFMSkOhqql747K/XNcuSsMlgiYFyNhSlFsPhkWA7c/biCBTMDOY0IPg6RaiD9HMLafD08eog0mfeSkOZiVq7V/gKSk8ebZkt6ssRcTuN7ez6/ZHbXJ8vrRuVfArC7Kq2 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2018 08:35:47.9908 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ebc6a8d1-a952-4bb4-244c-08d58598c28d X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1518 Subject: [dpdk-dev] [PATCH v4 05/20] 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: Fri, 09 Mar 2018 08:35:50 -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