From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4C28344183; Fri, 7 Jun 2024 16:28:28 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B399442D92; Fri, 7 Jun 2024 16:28:23 +0200 (CEST) Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2070.outbound.protection.outlook.com [40.107.101.70]) by mails.dpdk.org (Postfix) with ESMTP id DD16D42D2A for ; Fri, 7 Jun 2024 16:28:20 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ik859fmfJeXHZPM9jOWF4HHx/tpdUlFhm6oKYnDm14h+5qqA2mcjCdmp0kzLexHCAOYl9wy3x8ak2QY1kOhAsRB7kH/HPXXNkUvnvvDci2OZJs9+zlb/SFmKD2A1JaNduiU2aEuIvmZrDF5btA7HAIL8aIlRQCUkJYzGx4FMVdigaY5mFaQrga14jmU5hipNFQqBgnqjdNBTcIMfnh3029fJZTYqv58YTmJQu8bHZ4Rc7F5IvikNS7CLruSunmdqNZsxDoW5bfQMTSNn6ekkpazzYA+ydqZhgi6hnYtda4Mm4dxAWKol1VCRF/UsSPxhQbWzb4ZyOkkLaxsBab1LiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Ikz2vl3Os8aqFrkAwALvPGylYgmlzfYGXfRXCui0tmo=; b=iXlEsjwhm6ZYVWcPmo5VsV6Nor7/pokw6Q0+2DLutlfLTwPX9ULNgaXZ2bmOXshUL3oMv103r366b42fQvPQ6i7vhWlEDFkd6SY6PqSvps0hyJKuDzeuORO7oOqAJL+Xx1m/rj23HCWzabig1gWN7HxuZfEcListXp3FYvOEvhTnJiUYYY8s3OPqeGtNS/7LiX5jf3Ez5YHhAwz6GVCY9DN29C5i2KbC0apOrOANnET4IdmyJphCN7mY7zYg0x3auGely5bUGRPZgKMqDXbpX6+8QVAHwoGhA2qxqczv07JeOeI0/+Z7QtVe9Fmfeu+h5PPz4uR+u+My+bnggneCgw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=dpdk.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ikz2vl3Os8aqFrkAwALvPGylYgmlzfYGXfRXCui0tmo=; b=mbVQhazzs32+3GJS7G/Yz/GbAYYQVULafvnBNBOqcb0o9dGspl5JQP7IOwRKAzMO2+MiaQUN3LIYhMDosoAwkigSkg1034YqgvanF1W5JScYGioeSp8U5u2KXKuiozrCYLHNFr/K0c4uQDCtq7PqvJf4EC17arVOy716m7oWQYg= Received: from DM6PR03CA0028.namprd03.prod.outlook.com (2603:10b6:5:40::41) by PH8PR12MB6892.namprd12.prod.outlook.com (2603:10b6:510:1bc::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.22; Fri, 7 Jun 2024 14:28:16 +0000 Received: from DS2PEPF00003439.namprd02.prod.outlook.com (2603:10b6:5:40:cafe::9a) by DM6PR03CA0028.outlook.office365.com (2603:10b6:5:40::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7656.22 via Frontend Transport; Fri, 7 Jun 2024 14:28:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS2PEPF00003439.mail.protection.outlook.com (10.167.18.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7633.15 via Frontend Transport; Fri, 7 Jun 2024 14:28:15 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Fri, 7 Jun 2024 09:28:03 -0500 From: Andrew Boyer To: CC: Andrew Boyer Subject: [PATCH v3 1/9] crypto/ionic: introduce AMD Pensando driver Date: Fri, 7 Jun 2024 07:27:32 -0700 Message-ID: <20240607142740.60175-2-andrew.boyer@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240607142740.60175-1-andrew.boyer@amd.com> References: <20240430202144.49899-2-andrew.boyer@amd.com> <20240607142740.60175-1-andrew.boyer@amd.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF00003439:EE_|PH8PR12MB6892:EE_ X-MS-Office365-Filtering-Correlation-Id: d4105991-8ed2-4b8b-01ab-08dc86fe11d8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|376005|1800799015|82310400017|36860700004; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?gae0aLWjBjD9xexFeXkkvefGuxvUAu/Ak5fi2LWLv07UhoN+S298O61o7APy?= =?us-ascii?Q?+qhYxKxDAu5VbV6H8EH0l6wIMmTwPzxWt5Q1Accm7s16FE5Yc/krMmDC91Ka?= =?us-ascii?Q?N/Bgs4HFCgvFXgbsY8HNhp73f8h3yP+KuH9vfpe6L9pluA8VMJHFBH4O0hfp?= =?us-ascii?Q?tyVbgA2++Aq7ey0+hVPzhqFI7265goIie7N10pKZJ0uEnSIlXOePCW6I17HX?= =?us-ascii?Q?sGBz7x3Y6HoAhK1M4iL6DbksfOhAYF0XeSrvNV4zgSNqrxsgd6fG3so01JxO?= =?us-ascii?Q?+6ICq6jFVAnPzBJLGYWoTx0cVWfY8vRxpug8qlELXvdvx4n380wsCUa3wQbx?= =?us-ascii?Q?im647W06kYjRRp0MIIPJX7/n2trF+K6SwiAv39+HA3/r26+ChCmYCdOnWWtF?= =?us-ascii?Q?yFC5B5Irp3/D/fLeVLsoUyUb6fLek0zs3h8w1E0a4a1YL104uYcEDoAQfSV7?= =?us-ascii?Q?Xtu45MpOaizoQxJxptZIuJY4qBGOK8BzqnxTOCHsSN6jPq9AJ4UzeCkwtmK6?= =?us-ascii?Q?rZtx6gHsorQlPmOxC/mbnuKqDrpZYV78gbi0Z4mR05OWxSpgKGPFDlMJSVX4?= =?us-ascii?Q?BEgATq/JdtqE8IdgFsYnBu1Vgr0wLxZMNJx8H1RXkolpanBIP+3n8da516iD?= =?us-ascii?Q?DLLrg5xiEpsijUvCDqwkvK0yB9T2ZdD3XkUV9UBoQ5XZsDAZSqe3jdj0kibX?= =?us-ascii?Q?jkYBUPMY1igv1S2XAfS5Fg3Ba07hhvIp4f0RjAADU6CPEWu8mUJkTcWGDr6+?= =?us-ascii?Q?eIym9qWxUDdFd1k/FJoZhJDFitnQcknQ1FZOv0dpJUo3wQJr8LiSLemqDmcJ?= =?us-ascii?Q?MLwdBbofpJAqtjzkNFMqKhKie0ytGaPSfiwb/x9IkPGje3Se9Q5wPKVX/qlS?= =?us-ascii?Q?uWvMRbp1LYQLoT8/jlhe8VdXv46yIOQU/jzn345NSyDcVEmjjvtc7rYinr1O?= =?us-ascii?Q?F8yg46HqT7torRjLAcolOs0pVRsj+k2xN9/UZWRxrMBskU4jtMa6eQyn+4m2?= =?us-ascii?Q?8djewLNIWN7VUHpPWE1bIjogeyyfNwhWvIUEUG+02wpzBY1IK5OVTF3hSMUe?= =?us-ascii?Q?cSm5TBcX+4lAQ+DPOdtJIP2pH6BnDI5aWWtOAxgNeNF3Ylvn8C+xIBu1QZNM?= =?us-ascii?Q?XMIupRpBmvx77pOUCaj/C2dWOyDc/QUepveOjUb4Q+0zDAGzBXXbxIIWlPSG?= =?us-ascii?Q?j77IaDWBHqgbnIKUTo5+USO+dM0EMiqoW8ONh+VwDtm9hOaj8vtdo6I1qv1Q?= =?us-ascii?Q?xr2XTKB1ra5iNSdbA72eEt8lAwerx8u0tR3wxjt4zoWjAItB1VHKIpKfv1Lq?= =?us-ascii?Q?3WwdrUld75B2+AZVSCnOOPFxmCyH9NoewaB2/S/W1Zkr8zHsEp6fSTwpPYA4?= =?us-ascii?Q?fhak/xLNOPS/y2PvFmEGsKVF596r+9qkiAol0FfsDjo19EU29ulS/m8e4hKC?= =?us-ascii?Q?8FGkebOGOUo=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(376005)(1800799015)(82310400017)(36860700004); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jun 2024 14:28:15.8014 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d4105991-8ed2-4b8b-01ab-08dc86fe11d8 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF00003439.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB6892 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Introduce a new crypto PMD for AMD Pensando hardware accelerators. It allows applications running directly on the AMD Pensando DSC to offload cryptographic operations to hardware cryptographic blocks. Add support for the cryptodevs to the common ionic library. Add the driver skeleton. Add a skeleton features list and guide. Hook the new PMD up to the build. Update MAINTAINERS. Update release notes. Signed-off-by: Andrew Boyer --- MAINTAINERS | 7 ++ doc/guides/cryptodevs/features/ionic.ini | 32 +++++ doc/guides/cryptodevs/index.rst | 1 + doc/guides/cryptodevs/ionic.rst | 33 +++++ doc/guides/rel_notes/release_24_07.rst | 4 + drivers/common/ionic/ionic_common.h | 2 + drivers/common/ionic/ionic_common_uio.c | 48 +++++++- drivers/common/ionic/version.map | 1 + drivers/crypto/ionic/ionic_crypto.h | 92 ++++++++++++++ drivers/crypto/ionic/ionic_crypto_main.c | 148 +++++++++++++++++++++++ drivers/crypto/ionic/ionic_crypto_vdev.c | 91 ++++++++++++++ drivers/crypto/ionic/meson.build | 13 ++ drivers/crypto/meson.build | 1 + 13 files changed, 472 insertions(+), 1 deletion(-) create mode 100644 doc/guides/cryptodevs/features/ionic.ini create mode 100644 doc/guides/cryptodevs/ionic.rst create mode 100644 drivers/crypto/ionic/ionic_crypto.h create mode 100644 drivers/crypto/ionic/ionic_crypto_main.c create mode 100644 drivers/crypto/ionic/ionic_crypto_vdev.c create mode 100644 drivers/crypto/ionic/meson.build diff --git a/MAINTAINERS b/MAINTAINERS index c9adff9846..ad4d15954e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1076,6 +1076,13 @@ F: drivers/crypto/ccp/ F: doc/guides/cryptodevs/ccp.rst F: doc/guides/cryptodevs/features/ccp.ini +AMD Pensando ionic crypto +M: Andrew Boyer +F: drivers/crypto/ionic/ +F: drivers/common/ionic/ +F: doc/guides/cryptodevs/ionic.rst +F: doc/guides/cryptodevs/features/ionic.ini + ARMv8 Crypto M: Ruifeng Wang F: drivers/crypto/armv8/ diff --git a/doc/guides/cryptodevs/features/ionic.ini b/doc/guides/cryptodevs/features/ionic.ini new file mode 100644 index 0000000000..62b7e9e8f2 --- /dev/null +++ b/doc/guides/cryptodevs/features/ionic.ini @@ -0,0 +1,32 @@ +; +; Supported features of the 'ionic' crypto driver. +; +; Refer to default.ini for the full list of available PMD features. +; +[Features] + +; +; Supported crypto algorithms of 'ionic' crypto driver. +; +[Cipher] + +; +; Supported authentication algorithms of 'ionic' crypto driver. +; +[Auth] + +; +; Supported AEAD algorithms of 'ionic' crypto driver. +; +[AEAD] + +; +; Supported Asymmetric algorithms of the 'ionic' crypto driver. +; +[Asymmetric] + +; +; Supported Operating systems of the 'ionic' crypto driver. +; +[OS] +Linux = Y diff --git a/doc/guides/cryptodevs/index.rst b/doc/guides/cryptodevs/index.rst index cb4ce227e9..1e57a9fe86 100644 --- a/doc/guides/cryptodevs/index.rst +++ b/doc/guides/cryptodevs/index.rst @@ -20,6 +20,7 @@ Crypto Device Drivers cnxk dpaa2_sec dpaa_sec + ionic kasumi octeontx openssl diff --git a/doc/guides/cryptodevs/ionic.rst b/doc/guides/cryptodevs/ionic.rst new file mode 100644 index 0000000000..b54ddd37a3 --- /dev/null +++ b/doc/guides/cryptodevs/ionic.rst @@ -0,0 +1,33 @@ +.. SPDX-License-Identifier: BSD-3-Clause + Copyright 2021-2024 Advanced Micro Devices, Inc. + +IONIC Crypto Driver +=================== + +The ionic crypto driver provides support for offloading cryptographic operations +to hardware cryptographic blocks on AMD Pensando server adapters. +It currently supports the below models: + +- DSC-25 dual-port 25G Distributed Services Card `(pdf) `__ +- DSC-100 dual-port 100G Distributed Services Card `(pdf) `__ +- DSC-200 dual-port 200G Distributed Services Card `(pdf) `__ + +Please visit the AMD Pensando web site at https://www.amd.com/en/accelerators/pensando for more information. + +Device Support +-------------- + +The ionic crypto driver currently supports running directly on the device's embedded +processors. For help running the driver, please contact AMD Pensando support. + +Limitations +----------- + +- Host-side access via PCI is not yet supported +- Multiprocess applications are not yet supported + +Runtime Configuration +--------------------- + +None + diff --git a/doc/guides/rel_notes/release_24_07.rst b/doc/guides/rel_notes/release_24_07.rst index a69f24cf99..ec737552f4 100644 --- a/doc/guides/rel_notes/release_24_07.rst +++ b/doc/guides/rel_notes/release_24_07.rst @@ -24,6 +24,10 @@ DPDK Release 24.07 New Features ------------ +* **Added AMD Pensando ionic crypto driver.** + + Added a new crypto driver for AMD Pensando hardware accelerators. + .. This section should contain new features added in this release. Sample format: diff --git a/drivers/common/ionic/ionic_common.h b/drivers/common/ionic/ionic_common.h index eb4850e24c..c4a15fdf2b 100644 --- a/drivers/common/ionic/ionic_common.h +++ b/drivers/common/ionic/ionic_common.h @@ -32,6 +32,8 @@ struct ionic_dev_bar { __rte_internal void ionic_uio_scan_mnet_devices(void); +__rte_internal +void ionic_uio_scan_mcrypt_devices(void); __rte_internal void ionic_uio_get_rsrc(const char *name, int idx, struct ionic_dev_bar *bar); diff --git a/drivers/common/ionic/ionic_common_uio.c b/drivers/common/ionic/ionic_common_uio.c index e5c73faf96..c647b22eaf 100644 --- a/drivers/common/ionic/ionic_common_uio.c +++ b/drivers/common/ionic/ionic_common_uio.c @@ -23,10 +23,12 @@ #define IONIC_MDEV_UNK "mdev_unknown" #define IONIC_MNIC "cpu_mnic" +#define IONIC_MCRYPT "cpu_mcrypt" #define IONIC_MAX_NAME_LEN 20 #define IONIC_MAX_MNETS 5 -#define IONIC_MAX_DEVICES (IONIC_MAX_MNETS) +#define IONIC_MAX_MCPTS 1 +#define IONIC_MAX_DEVICES (IONIC_MAX_MNETS + IONIC_MAX_MCPTS) #define IONIC_MAX_U16_IDX 0xFFFF #define IONIC_UIO_MAX_TRIES 32 @@ -49,6 +51,7 @@ struct ionic_map_tbl ionic_mdev_map[IONIC_MAX_DEVICES] = { { "net_ionic2", 2, IONIC_MAX_U16_IDX, IONIC_MDEV_UNK }, { "net_ionic3", 3, IONIC_MAX_U16_IDX, IONIC_MDEV_UNK }, { "net_ionic4", 4, IONIC_MAX_U16_IDX, IONIC_MDEV_UNK }, + { "crypto_ionic0", 5, IONIC_MAX_U16_IDX, IONIC_MDEV_UNK }, }; struct uio_name { @@ -143,6 +146,49 @@ ionic_uio_scan_mnet_devices(void) } } +void +ionic_uio_scan_mcrypt_devices(void) +{ + struct ionic_map_tbl *map; + char devname[IONIC_MAX_NAME_LEN]; + struct uio_name name_cache[IONIC_MAX_DEVICES]; + bool done; + int mdev_idx = 0; + int uio_idx; + int i; + static bool scan_done; + + if (scan_done) + return; + + scan_done = true; + + uio_fill_name_cache(name_cache, IONIC_MCRYPT); + + for (i = IONIC_MAX_MNETS; i < IONIC_MAX_DEVICES; i++) { + done = false; + + while (!done) { + if (mdev_idx > IONIC_MAX_MDEV_SCAN) + break; + + /* Look for a matching mcrypt */ + snprintf(devname, IONIC_MAX_NAME_LEN, + IONIC_MCRYPT "%d", mdev_idx); + uio_idx = uio_get_idx_for_devname(name_cache, devname); + if (uio_idx >= 0) { + map = &ionic_mdev_map[i]; + map->uio_idx = (uint16_t)uio_idx; + strlcpy(map->mdev_name, devname, + IONIC_MAX_NAME_LEN); + done = true; + } + + mdev_idx++; + } + } +} + static int uio_get_multi_dev_uionum(const char *name) { diff --git a/drivers/common/ionic/version.map b/drivers/common/ionic/version.map index 484330c437..db532d4ffc 100644 --- a/drivers/common/ionic/version.map +++ b/drivers/common/ionic/version.map @@ -2,6 +2,7 @@ INTERNAL { global: ionic_uio_scan_mnet_devices; + ionic_uio_scan_mcrypt_devices; ionic_uio_get_rsrc; ionic_uio_rel_rsrc; diff --git a/drivers/crypto/ionic/ionic_crypto.h b/drivers/crypto/ionic/ionic_crypto.h new file mode 100644 index 0000000000..86750f0cbd --- /dev/null +++ b/drivers/crypto/ionic/ionic_crypto.h @@ -0,0 +1,92 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2021-2024 Advanced Micro Devices, Inc. + */ + +#ifndef _IONIC_CRYPTO_H_ +#define _IONIC_CRYPTO_H_ + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "ionic_common.h" +#include "ionic_regs.h" + +/* Devargs */ +/* NONE */ + +extern int iocpt_logtype; +#define RTE_LOGTYPE_IOCPT iocpt_logtype + +#define IOCPT_PRINT(level, ...) \ + RTE_LOG_LINE_PREFIX(level, IOCPT, "%s(): ", __func__, __VA_ARGS__) + +#define IOCPT_PRINT_CALL() IOCPT_PRINT(DEBUG, " >>") + +struct iocpt_dev_bars { + struct ionic_dev_bar bar[IONIC_BARS_MAX]; + uint32_t num_bars; +}; + +#define IOCPT_DEV_F_INITED BIT(0) +#define IOCPT_DEV_F_UP BIT(1) +#define IOCPT_DEV_F_FW_RESET BIT(2) + +/* Combined dev / LIF object */ +struct iocpt_dev { + const char *name; + struct iocpt_dev_bars bars; + + const struct iocpt_dev_intf *intf; + void *bus_dev; + struct rte_cryptodev *crypto_dev; + + uint32_t max_qps; + uint32_t max_sessions; + uint16_t state; + uint8_t driver_id; + uint8_t socket_id; + + uint64_t features; + uint32_t hw_features; +}; + +struct iocpt_dev_intf { + int (*setup_bars)(struct iocpt_dev *dev); + void (*unmap_bars)(struct iocpt_dev *dev); +}; + +static inline int +iocpt_setup_bars(struct iocpt_dev *dev) +{ + if (dev->intf->setup_bars == NULL) + return -EINVAL; + + return (*dev->intf->setup_bars)(dev); +} + +int iocpt_probe(void *bus_dev, struct rte_device *rte_dev, + struct iocpt_dev_bars *bars, const struct iocpt_dev_intf *intf, + uint8_t driver_id, uint8_t socket_id); +int iocpt_remove(struct rte_device *rte_dev); + +void iocpt_configure(struct iocpt_dev *dev); +void iocpt_deinit(struct iocpt_dev *dev); + +static inline bool +iocpt_is_embedded(void) +{ +#if defined(RTE_LIBRTE_IONIC_PMD_EMBEDDED) + return true; +#else + return false; +#endif +} + +#endif /* _IONIC_CRYPTO_H_ */ diff --git a/drivers/crypto/ionic/ionic_crypto_main.c b/drivers/crypto/ionic/ionic_crypto_main.c new file mode 100644 index 0000000000..7c1cf5c20e --- /dev/null +++ b/drivers/crypto/ionic/ionic_crypto_main.c @@ -0,0 +1,148 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2021-2024 Advanced Micro Devices, Inc. + */ + +#include + +#include +#include +#include + +#include "ionic_crypto.h" + +static int +iocpt_init(struct iocpt_dev *dev) +{ + dev->state |= IOCPT_DEV_F_INITED; + + return 0; +} + +void +iocpt_configure(struct iocpt_dev *dev) +{ + RTE_SET_USED(dev); +} + +void +iocpt_deinit(struct iocpt_dev *dev) +{ + IOCPT_PRINT_CALL(); + + if (!(dev->state & IOCPT_DEV_F_INITED)) + return; + + dev->state &= ~IOCPT_DEV_F_INITED; +} + +static int +iocpt_devargs(struct rte_devargs *devargs, struct iocpt_dev *dev) +{ + RTE_SET_USED(devargs); + RTE_SET_USED(dev); + + return 0; +} + +int +iocpt_probe(void *bus_dev, struct rte_device *rte_dev, + struct iocpt_dev_bars *bars, const struct iocpt_dev_intf *intf, + uint8_t driver_id, uint8_t socket_id) +{ + struct rte_cryptodev_pmd_init_params init_params = { + "iocpt", + sizeof(struct iocpt_dev), + socket_id, + RTE_CRYPTODEV_PMD_DEFAULT_MAX_NB_QUEUE_PAIRS + }; + struct rte_cryptodev *cdev; + struct iocpt_dev *dev; + uint32_t i; + int err; + + if (rte_eal_process_type() != RTE_PROC_PRIMARY) { + IOCPT_PRINT(ERR, "Multi-process not supported"); + err = -EPERM; + goto err; + } + + cdev = rte_cryptodev_pmd_create(rte_dev->name, rte_dev, &init_params); + if (cdev == NULL) { + IOCPT_PRINT(ERR, "Out of memory"); + err = -ENOMEM; + goto err; + } + + dev = cdev->data->dev_private; + dev->crypto_dev = cdev; + dev->bus_dev = bus_dev; + dev->intf = intf; + dev->driver_id = driver_id; + dev->socket_id = socket_id; + + for (i = 0; i < bars->num_bars; i++) { + struct ionic_dev_bar *bar = &bars->bar[i]; + + IOCPT_PRINT(DEBUG, + "bar[%u] = { .va = %p, .pa = %#jx, .len = %lu }", + i, bar->vaddr, bar->bus_addr, bar->len); + if (bar->vaddr == NULL) { + IOCPT_PRINT(ERR, "Null bar found, aborting"); + err = -EFAULT; + goto err_destroy_crypto_dev; + } + + dev->bars.bar[i].vaddr = bar->vaddr; + dev->bars.bar[i].bus_addr = bar->bus_addr; + dev->bars.bar[i].len = bar->len; + } + dev->bars.num_bars = bars->num_bars; + + err = iocpt_devargs(rte_dev->devargs, dev); + if (err != 0) { + IOCPT_PRINT(ERR, "Cannot parse device arguments"); + goto err_destroy_crypto_dev; + } + + err = iocpt_setup_bars(dev); + if (err != 0) { + IOCPT_PRINT(ERR, "Cannot setup BARs: %d, aborting", err); + goto err_destroy_crypto_dev; + } + + err = iocpt_init(dev); + if (err != 0) { + IOCPT_PRINT(ERR, "Cannot init device: %d, aborting", err); + goto err_destroy_crypto_dev; + } + + return 0; + +err_destroy_crypto_dev: + rte_cryptodev_pmd_destroy(cdev); +err: + return err; +} + +int +iocpt_remove(struct rte_device *rte_dev) +{ + struct rte_cryptodev *cdev; + struct iocpt_dev *dev; + + cdev = rte_cryptodev_pmd_get_named_dev(rte_dev->name); + if (cdev == NULL) { + IOCPT_PRINT(DEBUG, "Cannot find device %s", rte_dev->name); + return -ENODEV; + } + + dev = cdev->data->dev_private; + + iocpt_deinit(dev); + + rte_cryptodev_pmd_destroy(cdev); + + return 0; +} + +RTE_LOG_REGISTER_DEFAULT(iocpt_logtype, NOTICE); diff --git a/drivers/crypto/ionic/ionic_crypto_vdev.c b/drivers/crypto/ionic/ionic_crypto_vdev.c new file mode 100644 index 0000000000..a915aa06aa --- /dev/null +++ b/drivers/crypto/ionic/ionic_crypto_vdev.c @@ -0,0 +1,91 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2021-2024 Advanced Micro Devices, Inc. + */ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "ionic_crypto.h" + +#define IOCPT_VDEV_DEV_BAR 0 +#define IOCPT_VDEV_INTR_CTL_BAR 1 +#define IOCPT_VDEV_INTR_CFG_BAR 2 +#define IOCPT_VDEV_DB_BAR 3 +#define IOCPT_VDEV_BARS_MAX 4 + +#define IOCPT_VDEV_DEV_INFO_REGS_OFFSET 0x0000 +#define IOCPT_VDEV_DEV_CMD_REGS_OFFSET 0x0800 + +static int +iocpt_vdev_setup_bars(struct iocpt_dev *dev) +{ + IOCPT_PRINT_CALL(); + + dev->name = rte_vdev_device_name(dev->bus_dev); + + return 0; +} + +static void +iocpt_vdev_unmap_bars(struct iocpt_dev *dev) +{ + struct iocpt_dev_bars *bars = &dev->bars; + uint32_t i; + + for (i = 0; i < IOCPT_VDEV_BARS_MAX; i++) + ionic_uio_rel_rsrc(dev->name, i, &bars->bar[i]); +} + +static uint8_t iocpt_vdev_driver_id; +static const struct iocpt_dev_intf iocpt_vdev_intf = { + .setup_bars = iocpt_vdev_setup_bars, + .unmap_bars = iocpt_vdev_unmap_bars, +}; + +static int +iocpt_vdev_probe(struct rte_vdev_device *vdev) +{ + struct iocpt_dev_bars bars = {}; + const char *name = rte_vdev_device_name(vdev); + unsigned int i; + + IOCPT_PRINT(NOTICE, "Initializing device %s%s", name, + rte_eal_process_type() == RTE_PROC_SECONDARY ? + " [SECONDARY]" : ""); + + ionic_uio_scan_mcrypt_devices(); + + for (i = 0; i < IOCPT_VDEV_BARS_MAX; i++) + ionic_uio_get_rsrc(name, i, &bars.bar[i]); + + bars.num_bars = IOCPT_VDEV_BARS_MAX; + + return iocpt_probe((void *)vdev, &vdev->device, + &bars, &iocpt_vdev_intf, + iocpt_vdev_driver_id, rte_socket_id()); +} + +static int +iocpt_vdev_remove(struct rte_vdev_device *vdev) +{ + return iocpt_remove(&vdev->device); +} + +static struct rte_vdev_driver rte_vdev_iocpt_pmd = { + .probe = iocpt_vdev_probe, + .remove = iocpt_vdev_remove, +}; + +static struct cryptodev_driver rte_vdev_iocpt_drv; + +RTE_PMD_REGISTER_VDEV(crypto_ionic, rte_vdev_iocpt_pmd); +RTE_PMD_REGISTER_CRYPTO_DRIVER(rte_vdev_iocpt_drv, rte_vdev_iocpt_pmd.driver, + iocpt_vdev_driver_id); diff --git a/drivers/crypto/ionic/meson.build b/drivers/crypto/ionic/meson.build new file mode 100644 index 0000000000..4114e13e53 --- /dev/null +++ b/drivers/crypto/ionic/meson.build @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright 2021-2024 Advanced Micro Devices, Inc. + +deps += ['bus_vdev'] +deps += ['common_ionic'] + +sources = files( + 'ionic_crypto_main.c', + 'ionic_crypto_vdev.c', +) +name = 'ionic_crypto' + +includes += include_directories('../../common/ionic') diff --git a/drivers/crypto/meson.build b/drivers/crypto/meson.build index ee5377deff..e799861bb6 100644 --- a/drivers/crypto/meson.build +++ b/drivers/crypto/meson.build @@ -10,6 +10,7 @@ drivers = [ 'cnxk', 'dpaa_sec', 'dpaa2_sec', + 'ionic', 'ipsec_mb', 'mlx5', 'mvsam', -- 2.17.1