From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM04-SN1-obe.outbound.protection.outlook.com (mail-eopbgr700079.outbound.protection.outlook.com [40.107.70.79]) by dpdk.org (Postfix) with ESMTP id B4ED55F1B for ; Fri, 8 Jun 2018 18:49:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mf3TpAbm0U5xDQEdjiDGKcpPC2nOsu3+YltjtK4WH0A=; b=cZbg0OosVJKD9dGwflRPb2LQRX0W+gmOLRudBdTey0v3cIFk1lJIQkEcC7s3uCFqoPHkVulERI14t9wlkTKGJLCgXl0IkMt1E+1KyuhXOQ7bSrN+VEVoe+v17RpgQlyvomRoIwjt76YY3DZUEU9qoCpV1Do9aqLlYpw0aDGzFQA= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Anoob.Joseph@cavium.com; Received: from ajoseph83.caveonetworks.com.caveonetworks.com (115.113.156.2) by SN6PR07MB4911.namprd07.prod.outlook.com (2603:10b6:805:3c::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.820.15; Fri, 8 Jun 2018 16:49:18 +0000 From: Anoob Joseph To: Akhil Goyal , Pablo de Lara , Thomas Monjalon Cc: Srisivasubramanian Srinivasan , Ankur Dwivedi , Jerin Jacob , Murthy NSSR , Narayana Prasad , Nithin Dabilpuram , Ragothaman Jayaraman , dev@dpdk.org Date: Fri, 8 Jun 2018 22:15:19 +0530 Message-Id: <1528476325-15585-11-git-send-email-anoob.joseph@caviumnetworks.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1528476325-15585-1-git-send-email-anoob.joseph@caviumnetworks.com> References: <1528476325-15585-1-git-send-email-anoob.joseph@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [115.113.156.2] X-ClientProxiedBy: BM1PR01CA0071.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:1::11) To SN6PR07MB4911.namprd07.prod.outlook.com (2603:10b6:805:3c::29) X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:SN6PR07MB4911; X-Microsoft-Exchange-Diagnostics: 1; SN6PR07MB4911; 3:VtZ7VwcPf5eWcnA/Ulb7BJAo56JmL2zTt/hBvPF7+0YccrPtF1zZ11WAjhbu87qnFpfujmh5TGYF0XRJC9GaWa5sP1fgKliJDW1ksWTGt/+TkMUCDEnpL4OSMf8W0+ZbbW1Nh1ooW3VrWi3M87M9/wUFkgjGZlv9u0pEaXe3a/j/MWrAWAW5NeCXcTuCNOoG7/QBqJiu2dUHUmfMYlYXpiRxdcaVMzUBgD5ASdT5s6zyAXDTTj0DpgWNFM75CPUs; 25:7HQKnhYPmbZsv+j3QeZKJY7ylpLLDZEhrB2KzjznbX+HzxtJgODkFYnq6bfPEyGE8sziV5l8mgUQOek/r25kml/rfUCA50IrsNTsgxsUS4BUEYFJsjKj/8KtjkbptqDEjGKzAqrG7MroOaXBmRJOWxTtxOR/fQZ1rDQuYiuDQ4KutvvNfmK7x7VQXPWtc+iAtOestQRHjlChDYLdc0PKlU7TH5hbggaoIaKTgK2VROYBne58eERO15j72nSINtvUXNzRxSY50l+HOU353Ba80ZsVszrayMTVtw9m3wbZO8RIRxrZyfv/lOvUFuk2L3U7Ji7CPhRf6/uwOxNiwoQfMg==; 31:GLc8SO27QckGJIMhsvv/gd28afg1IFIB7mDkpc5iQVVjw74ffaz5scWSBgjAtH42kmnzlW6sSVfStkrRpmB+Potqh/QQFtD5EtHA4uAdXGiK8aQZZee/Odv/QIQTV+Ibt0Wke0ZxmUWjWRKGK8Uuej09I12b3rKarRGwU6HkR5ZeaRzP5pJgY+8+MTnSJOqwUgWIhoVri43X3zwpcJwOB+5vrCY6yKKjWOef9H2HHSo= X-MS-TrafficTypeDiagnostic: SN6PR07MB4911: X-Microsoft-Exchange-Diagnostics: 1; SN6PR07MB4911; 20:adVGx/XRtAgnKaoqZT8G6pBzFZ5UdyP4eP0vCkY7rc17ns30hJwMILTb5TsN9cgPw/1nVCP3f3MZp28iqZIIWL5j/ZmPVC8ATTYxdrirlS9rkkrelpgFxb00YmMj1oAj0OPZs24BRpKotSLfxvk0sqYKAwQNrnX3emtdFJdSDjlVs/L+tGtxc5lVHd+IjQJmXqtwA486B8/TuesgZdFHmkFKETGCuW5LwqiP2HUFKXLQQxFM53jRdaQGgmjDkRKBBemcG8eiuxuJ1jo64TgeFyGhLM/MG3Y2Vj5PO4QHG5dTM5n/Y4qJavNlGlEIc/fZiaCJ2P4SKAl5B4M+wvXfjcwjzjAzx/o1N9UeSYNCCkXqeFw+YM2425073UgMaCk1fYWhFmn7NkU1IFeu/j1eq56OkS1BT26ezFjOm9vwV+ZzqAIO6ad942/W+J4OZvjr7uMuh6hVWyhXfojuucWXmmeyNSf0pwFAy/O9dFudWTUlob2Odep6WJL3QN9CNt1x913t2VOrBlxRCSdeO2sDr2JEUx9pi/dpPdsLls1Uam0yjsRHq/MlEjHk61IYdyhHSKV4IUnEFHq/g52ON1v2iFKCK5ByiI6Lvor+of1G2Hw=; 4:3cMT1NiI1z+g3HtEKyF7XtsWA0Jb2NPpji0/hMusVDQDXm72gp4m+sMqFpGQC9eit9thi8CzaFtX+rYpGwZePMheCj5Ve3PtekEmoKmX78uJt8s39ywBQb0Yqs/gTlmXANzo/oOzMuJBnuWKn+4XDmg4/o+1TEuFIgDUYLc2l4iee9EkinecbvOm6CntgCN6Al1C+zdv4+OUaqhum8swTIgE/h1fCaL3QTAyWIaQ2ul1F1gNH78MXdZx+J3keRl9NJXMOCOz/26gEHd0zNM2Qw== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(10201501046)(93006095)(3002001)(3231254)(944501410)(52105095)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123558120)(20161123564045)(6072148)(201708071742011)(7699016); SRVR:SN6PR07MB4911; BCL:0; PCL:0; RULEID:; SRVR:SN6PR07MB4911; X-Forefront-PRVS: 06973FFAD3 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(376002)(396003)(346002)(39380400002)(366004)(39860400002)(189003)(199004)(26005)(52116002)(956004)(305945005)(8676002)(81156014)(50226002)(8936002)(81166006)(7736002)(68736007)(105586002)(106356001)(3846002)(6116002)(72206003)(478600001)(6486002)(97736004)(6506007)(16586007)(6512007)(53936002)(47776003)(486006)(25786009)(5660300001)(50466002)(48376002)(4326008)(54906003)(76176011)(36756003)(110136005)(66066001)(8656006)(2906002)(316002)(55236004)(5890100001)(11346002)(16526019)(386003)(186003)(59450400001)(446003)(476003)(42882007)(44832011)(2616005)(51416003); DIR:OUT; SFP:1101; SCL:1; SRVR:SN6PR07MB4911; H:ajoseph83.caveonetworks.com.caveonetworks.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN6PR07MB4911; 23:NlYGN3Agq3RSi3PBAEWM4JqsaLekyGiGjG5xbr6p4?= =?us-ascii?Q?LQj59JorpyAa5m9M91WPLj4zNz+RsdRYm15dMkx2mohp9NkWwOfsHMdFIclL?= =?us-ascii?Q?Ws9o8SkpIxtdvy1cG2/UTKm56/vWoMME5Kg21AO9NCvHCVQXV0gpjmYErB4u?= =?us-ascii?Q?DKYsgvmUi3+8eJ57i226h4tO1FUOXH9xBT75rC8djIh7HGECNx3Ui+eH+XH2?= =?us-ascii?Q?mRN59nXPT34fbSkNio7P16H0L5hhXs4ryhifVG5lo+m9fqWXwG2IadYSGxSV?= =?us-ascii?Q?ClNCLwZMYHdNGPmWyZ26AIsfwN/a/Bi/uEB7XGg1qz65INon6mLGYjQ9eWYr?= =?us-ascii?Q?Jr6ZrCzecmg/Bo48DU0ZIMUhnlYmpP8f4NguSAxgGEIT+0uepiNL96x+pDG6?= =?us-ascii?Q?m+0DnVXa4FS/fYg+9VtGi3Qmd+mRxIRo9BlyhjFxdNALYP5IQ/9RuTuROnff?= =?us-ascii?Q?4/xVSb19o6Nh9HN2PGxDOcAM/troCjRzjTQJTv91y0hUGKkap6NXF1ay+XVF?= =?us-ascii?Q?ADoaBhPNqUTwXt6PxIPlJPGk0buTtwRcdBIhiAkpviZiWYa6B1pi7zpmYaVW?= =?us-ascii?Q?MnKzycIAyQqdL0ptRF29jqicwZRhesumj9Dq3IvixJvtzbUjwOd/Ku8JUNk3?= =?us-ascii?Q?PKIDpNsZINGeL4/egNSrtbyder003zNt+bcJTwd/uHmlDLdY0hh0AzhCvA4O?= =?us-ascii?Q?4Jxa2y06HAfBnm5BH1lg6njxWHYUtDLEZDFIyawmDucczV8KnnYL150Krgs8?= =?us-ascii?Q?C2+Ghyqm1rdQw09zDB04vB8wmxL55jhhteBug3rN1YYu5PSSMcu6O8eudW8d?= =?us-ascii?Q?bFM2lkLtB2ucmZbLGPP7L8hkH9aVZSwMkSleSq8MS9UoUSZqRRt/kAEJ4llG?= =?us-ascii?Q?68/VDdxFS8rW0pxrbAxBA/B3OupCqF6m87dCcvdqx8bUy8K2PlBEcbLKaVb5?= =?us-ascii?Q?JCwZ2BbwcLwioCKlwJ5YTP2C7DD5M8SI50UfcPMQM6RJuVS+3EUR3u+hosqL?= =?us-ascii?Q?9oZeL4il9x5HXJXl/jP/DuI+1z3Om79nQe0r8u4NRNDWdyj9VYBZF2hJh4F/?= =?us-ascii?Q?V+UDX930K/AGB1JVKCUbAin3GhsD+ncA0HRZyxUELRjyVGz3ysxUNDlg864q?= =?us-ascii?Q?gXKJbdMlBQMKtE3fibn9XTvZIeRmdjf4zzEWnATjolmp7KNUgUbDseMxV+Nk?= =?us-ascii?Q?6I2w1nuHKShttQeNIb/zH8VHXut0jJcpJJq0ikuMM/sPpZWq716U10fVARpX?= =?us-ascii?Q?R16HRP1sJfysSWNvCCC71VA9M1zdTlt0kT0q2gETmDaaAzxbQeiZBpoHe2AY?= =?us-ascii?Q?+uBq5zy/9nlrxqOPtVqL8Y=3D?= X-Microsoft-Antispam-Message-Info: leaZ+fieZUczAesPaBFqsGSCATMjNcgEeMdQuFDgd9msQYmnpnuxv/SPcDU3B2oVaDu4fztTAKk5wIft1bzEhiouBdRBC1b3Xa42Wms2mCdLpXEHvN7FKqYYegr+Set0thJwBDyBK92bQiGcpw56r8XVA2zt2jO2tBpK4efT5jebJ6C/IOx8AGwCDSKLzFKe X-Microsoft-Exchange-Diagnostics: 1; SN6PR07MB4911; 6:68kXeC0cxcZQDkGkPY6DnsLozYBZWoOY65He8OX7TmnnJcMdYtrZktaSW/ppCHLvkJuVIOVna68aKh2JlpqfoHmyMmAk4H+3nmt/VJI7+ggg94iLxaufVXTl/uL8S+E1nwYmMuaPOiyahw1ujrnX4Jj51UrwOEUm0hME8NDGH0PFzAYB/ve975hXA56anA7yNtFilV9oKQmt5x/aNQTwErlRcd9SHR26k+o+TrzZ85cIz8jR+7Vf2caIHjPu4PxiTZCVXdMwZCX44UIDJydAqXGA5FBnriXdnYB9z5Nw6TAiwIRxSupdrB426LPC7qmTMI06a9BQOc3/L5AZ0rifNNniTFztjFJmmNlN1ZUV2J/0JbwOtL0lwLURIp4SjFHGzGKOFWkbKLuh9wirnMPpDDwU0DmGb2nbjhkMYLKSFBuG/mcotu5dJ1IjUem8SKL8kPTYEwIYokC86RKmEaqT9w==; 5:XVA+d0Mj5ctSBO1AVvvcCm+to5Q5hlFDU0aHzrkPuR6yKxvdk6hFwOW2jfYOFoGNUC7UPp7n6wrStEC8DKTe02JTemfUsP38AOt8jxfGNr3wpyJZ+eQZShAnHQ9qe2CdjGPrQJST8ftMDJDvpyqT3yik0iPvskQPGTofbkFsLBw=; 24:DVkKPuSnYHvPhhrvD3VJ0/jKGzvVOhL/iiYSLqHmbwbycP3lJWZGAXmq7TDv0D1fXI+NOsULQQomo3ZlrlopyFleK6StflpdvP/lUsNowSk= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN6PR07MB4911; 7:ACayBhcGjQjmOqsgjn4gleWcESasLq2JVlAXY2pPT50dYbfOd0JlaAj7TalDfb/wtRZ4+D2BRo5FmOZmTyjJjq6bkT5/nKhZhYFwTPgNs0hVvSbOeUTKM2xrX8pFMfGifFCHHS6yHO2wYDQ/ebvfZD1u6BdlFmksofjrE5CPqGwGOTklpxEO99gP59R/S+ef0eEM6FjXOWOjPy5w0zF4UcHFlDiFy7vPISB9esPlFRU1zd0VXEnZLHSzPm8dV0PG X-MS-Office365-Filtering-Correlation-Id: 18d27c20-09e3-4d78-3270-08d5cd5fc8e2 X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jun 2018 16:49:18.3370 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 18d27c20-09e3-4d78-3270-08d5cd5fc8e2 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR07MB4911 Subject: [dpdk-dev] [PATCH 10/16] crypto/cpt: add driver initializations 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, 08 Jun 2018 16:49:24 -0000 From: Srisivasubramanian Srinivasan Introduce driver initialization and enable build infrastructure. Signed-off-by: Ankur Dwivedi Signed-off-by: Murthy NSSR Signed-off-by: Nithin Dabilpuram Signed-off-by: Ragothaman Jayaraman Signed-off-by: Srisivasubramanian Srinivasan --- drivers/crypto/cpt/Makefile | 9 +- drivers/crypto/cpt/cpt_pmd_cryptodev.c | 270 +++++++++++++++++++++++++++++++++ drivers/crypto/cpt/cpt_pmd_logs.h | 50 ++++++ 3 files changed, 328 insertions(+), 1 deletion(-) create mode 100644 drivers/crypto/cpt/cpt_pmd_cryptodev.c create mode 100644 drivers/crypto/cpt/cpt_pmd_logs.h diff --git a/drivers/crypto/cpt/Makefile b/drivers/crypto/cpt/Makefile index b2d950d..40ec9e2 100644 --- a/drivers/crypto/cpt/Makefile +++ b/drivers/crypto/cpt/Makefile @@ -23,7 +23,14 @@ CFLAGS += -O3 #CFLAGS += -DAUTH_SOFT_COMPUTE_IPAD_OPAD #CFLAGS += -DCPT_DEBUG -SRCS-$(CONFIG_RTE_LIBRTE_PMD_CPT) += +# PMD code +SRCS-$(CONFIG_RTE_LIBRTE_PMD_CPT) += cpt_pmd_cryptodev.c + +# Base code +SRCS-$(CONFIG_RTE_LIBRTE_PMD_CPT) += cpt_device.c +SRCS-$(CONFIG_RTE_LIBRTE_PMD_CPT) += cpt_ops.c +SRCS-$(CONFIG_RTE_LIBRTE_PMD_CPT) += cpt8xxx_device.c +SRCS-$(CONFIG_RTE_LIBRTE_PMD_CPT) += cpt_vf_mbox.c # export include files SYMLINK-y-include += diff --git a/drivers/crypto/cpt/cpt_pmd_cryptodev.c b/drivers/crypto/cpt/cpt_pmd_cryptodev.c new file mode 100644 index 0000000..addddd8 --- /dev/null +++ b/drivers/crypto/cpt/cpt_pmd_cryptodev.c @@ -0,0 +1,270 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2017 Cavium, Inc + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "base/cpt_device.h" +#include "cpt_pmd_logs.h" + +#define CSP_INTR_POLL_INTERVAL_MS 50 + +static int global_init_done; +uint8_t cryptodev_cpt_driver_id; +struct rte_mempool *cpt_meta_pool; +int cpt_op_mlen; +int cpt_op_sb_mlen; + +static void +cpt_pmd_alarm_cb(void *arg) +{ + struct cpt_vf *cptvf = arg; + cptvf_poll_misc(cptvf); + rte_eal_alarm_set(CSP_INTR_POLL_INTERVAL_MS * 1000, + cpt_pmd_alarm_cb, cptvf); +} + +static int +cpt_pmd_periodic_alarm_start(void *arg) +{ + return rte_eal_alarm_set(CSP_INTR_POLL_INTERVAL_MS * 1000, + cpt_pmd_alarm_cb, arg); +} + +static int +cpt_pmd_periodic_alarm_stop(void *arg) +{ + return rte_eal_alarm_cancel(cpt_pmd_alarm_cb, arg); +} + +static struct rte_cryptodev_ops cptvf_ops = { + /* Device related operations */ + .dev_configure = NULL, + .dev_start = NULL, + .dev_stop = NULL, + .dev_close = NULL, + .dev_infos_get = NULL, + + .stats_get = NULL, + .stats_reset = NULL, + .queue_pair_setup = NULL, + .queue_pair_release = NULL, + .queue_pair_start = NULL, + .queue_pair_stop = NULL, + .queue_pair_count = NULL, + + /* Crypto related operations */ + .session_get_size = NULL, + .session_configure = NULL, + .session_clear = NULL +}; + +static int init_global_resources(void) +{ + /* In future consider rte_security and asym. 4B extra for app use */ + cpt_op_mlen = cpt_fc_get_op_meta_len() + 4 * sizeof(uint64_t); + cpt_meta_pool = rte_mempool_create("cpt_metabuf-pool", 4096 * 16, + cpt_op_mlen, 512, 0, + NULL, NULL, NULL, NULL, + SOCKET_ID_ANY, 0); + if (!cpt_meta_pool) { + PMD_DRV_LOG(ERR, "cpt metabuf pool not created\n"); + return -ENOMEM; + } + cpt_op_sb_mlen = cpt_fc_get_op_sb_meta_len() + 4 * sizeof(uint64_t); + + return 0; +} + +static int +cptvf_dev_init(struct rte_pci_driver *c_drv __rte_unused, + struct rte_cryptodev *c_dev) +{ + struct rte_pci_device *pdev = RTE_DEV_TO_PCI(c_dev->device); + struct cpt_vf *cptvf = c_dev->data->dev_private; + void *reg_base; + char dev_name[32]; + int ret; + + PMD_DRV_LOG(DEBUG, ">>>"); + + if (pdev->mem_resource[0].phys_addr == 0ULL) + return -EIO; + + /* for secondary processes, we don't initialise any further as primary + * has already done this work. + */ + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return 0; + + snprintf(dev_name, 32, "%02x:%02x.%x", + pdev->addr.bus, pdev->addr.devid, pdev->addr.function); + PMD_DRV_LOG(DEBUG, "Found CPT device %s", dev_name); + + reg_base = pdev->mem_resource[0].addr; + if (!reg_base) { + PMD_DRV_LOG(ERR, "Failed to map BAR0 of %s", dev_name); + ret = -ENODEV; + goto fail; + } + + ret = cptvf_init_device(cptvf, pdev, reg_base, dev_name, 0); + if (ret) { + PMD_DRV_LOG(ERR, "Failed to init cptvf %s", dev_name); + return -EIO; + } + + /* Start off timer for mailbox interrupts */ + cpt_pmd_periodic_alarm_start(cptvf); + /* TODO Do we really need this to poll for mbox ?? */ + /* cptvf_enable_mbox_interrupts(cptvf); */ + + if (!global_init_done) { + /* cpt_set_debug_level(debug); */ + ret = init_global_resources(); + if (ret) + goto init_fail; + global_init_done = 1; + } + + c_dev->dev_ops = &cptvf_ops; + + c_dev->enqueue_burst = NULL; + c_dev->dequeue_burst = NULL; + + c_dev->feature_flags = RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO | + RTE_CRYPTODEV_FF_HW_ACCELERATED | + RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING; + + return 0; + +init_fail: + cpt_pmd_periodic_alarm_stop(cptvf); + cptvf_deinit_device(cptvf); + return ret; + +fail: + return ret; +} + +static int +rte_cptdev_pci_probe(struct rte_pci_driver *pci_drv, + struct rte_pci_device *pci_dev) +{ + struct rte_cryptodev *cryptodev; + + char cryptodev_name[RTE_CRYPTODEV_NAME_MAX_LEN]; + + int retval; + + if (pci_drv == NULL) + return -ENODEV; + + rte_pci_device_name(&pci_dev->addr, cryptodev_name, + sizeof(cryptodev_name)); + + cryptodev = rte_cryptodev_pmd_allocate(cryptodev_name, rte_socket_id()); + if (cryptodev == NULL) + return -ENOMEM; + + if (rte_eal_process_type() == RTE_PROC_PRIMARY) { + cryptodev->data->dev_private = + rte_zmalloc_socket( + "cryptodev private structure", + sizeof(struct cpt_vf), + RTE_CACHE_LINE_SIZE, + rte_socket_id()); + + if (cryptodev->data->dev_private == NULL) + rte_panic("Cannot allocate memzone for private " + "device data"); + } + + cryptodev->device = &pci_dev->device; + cryptodev->device->driver = &pci_drv->driver; + cryptodev->driver_id = cryptodev_cpt_driver_id; + + /* init user callbacks */ + TAILQ_INIT(&(cryptodev->link_intr_cbs)); + + /* Invoke PMD device initialization function */ + retval = cptvf_dev_init(pci_drv, cryptodev); + if (retval == 0) + return 0; + + PMD_DRV_LOG(ERR, "driver %s: crypto_dev_init(vendor_id=0x%x device_id=" + "0x%x) failed", pci_drv->driver.name, + (unsigned int) pci_dev->id.vendor_id, + (unsigned int) pci_dev->id.device_id); + + if (rte_eal_process_type() == RTE_PROC_PRIMARY) + rte_free(cryptodev->data->dev_private); + + cryptodev->attached = RTE_CRYPTODEV_DETACHED; + + return -ENXIO; +} + +static int +rte_cptdev_pci_remove(struct rte_pci_device *pci_dev) +{ + struct rte_cryptodev *cryptodev; + char cryptodev_name[RTE_CRYPTODEV_NAME_MAX_LEN]; + + if (pci_dev == NULL) + return -EINVAL; + + rte_pci_device_name(&pci_dev->addr, cryptodev_name, + sizeof(cryptodev_name)); + + cryptodev = rte_cryptodev_pmd_get_named_dev(cryptodev_name); + if (cryptodev == NULL) + return -ENODEV; + + if (pci_dev->driver == NULL) + return -ENODEV; + + /* free crypto device */ + rte_cryptodev_pmd_release_device(cryptodev); + + if (rte_eal_process_type() == RTE_PROC_PRIMARY) + rte_free(cryptodev->data->dev_private); + + cryptodev->device = NULL; + cryptodev->device->driver = NULL; + cryptodev->data = NULL; + + return 0; +} +static struct rte_pci_id pci_id_cpt_table[] = { + { + RTE_PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, CPT_81XX_PCI_VF_DEVICE_ID), + }, + /* sentinel */ + { + .device_id = 0 + }, +}; + +static struct rte_pci_driver cptvf_pmd = { + .id_table = pci_id_cpt_table, + .drv_flags = RTE_PCI_DRV_NEED_MAPPING, + .probe = rte_cptdev_pci_probe, + .remove = rte_cptdev_pci_remove, +}; +static struct cryptodev_driver cpt_crypto_drv; + +#define CRYPTODEV_NAME_CPT_SYM_PMD crypto_cpt +/* Cavium CPT Symmetric Crypto PMD device name */ + +RTE_PMD_REGISTER_PCI(CRYPTODEV_NAME_CPT_SYM_PMD, cptvf_pmd); +RTE_PMD_REGISTER_PCI_TABLE(CRYPTODEV_NAME_CPT_SYM_PMD, pci_id_cpt_table); +RTE_PMD_REGISTER_CRYPTO_DRIVER(cpt_crypto_drv, cptvf_pmd.driver, + cryptodev_cpt_driver_id); diff --git a/drivers/crypto/cpt/cpt_pmd_logs.h b/drivers/crypto/cpt/cpt_pmd_logs.h new file mode 100644 index 0000000..d245d62 --- /dev/null +++ b/drivers/crypto/cpt/cpt_pmd_logs.h @@ -0,0 +1,50 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2017 Cavium, Inc + */ + +#ifndef _CPT_PMD_LOGS_H_ +#define _CPT_PMD_LOGS_H_ + +#include + +#define PMD_DRV_LOG_RAW(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, RTE_LOGTYPE_PMD, \ + "PMD: %s(): " fmt "\n", __func__, ##args) + +#ifdef RTE_LIBRTE_PMD_CPT_DEBUG_INIT + +#define PMD_INIT_FUNC_TRACE() PMD_DRV_LOG_RAW(DEBUG, " >>") +#define PMD_DRV_LOG(level, args...) \ + PMD_DRV_LOG_RAW(level, ##args) +#else + +#define PMD_DRV_LOG(...) do { } while (0) +#define PMD_INIT_FUNC_TRACE() do { } while (0) +#endif + +#ifdef RTE_LIBRTE_PMD_CPT_DEBUG_RX + +#define CPT_DEBUG +#define CPTVF_STRICT_PARAM_CHECK +#define PMD_RX_LOG(level, args...) \ + PMD_DRV_LOG_RAW(level, ##args) +#else + +#define PMD_RX_LOG(...) do { } while (0) +#endif + +#ifdef RTE_LIBRTE_PMD_CPT_DEBUG_TX + +#define CPT_DEBUG +#define CPTVF_STRICT_PARAM_CHECK + +#define PMD_TX_LOG(level, args...) \ + PMD_DRV_LOG_RAW(level, ##args) +#else + +#define PMD_TX_LOG(...) do { } while (0) +#endif + +#define PRINT printf + +#endif -- 1.9.3