From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50078.outbound.protection.outlook.com [40.107.5.78]) by dpdk.org (Postfix) with ESMTP id B89B91B91F for ; Fri, 12 Oct 2018 16:41:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tjgF7EfVc3a1xrBzXNSC0uNxQgsj33WLMmh8Df67Yy8=; b=GIQNKJyGlfv0idW1Syi4Iy4i5PMfH1XjVZ32G0BPxfZmhc5+hj7BYTOWFlcBOlyYNwstTsIE2lXE7ljnhYGzp/Of09yyGqcGCb4EnxmOupFkXxX2TlVWNRazl4r9r2iuGhJKeUkPmq9yQmS4q86n6LxhmCTzm4nmA6JEcDVj+KI= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=G.Singh@nxp.com; Received: from Tophie.ap.freescale.net (14.142.187.166) by HE1PR04MB1530.eurprd04.prod.outlook.com (2a01:111:e400:59a8::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1207.23; Fri, 12 Oct 2018 14:41:35 +0000 From: Gagandeep Singh To: dev@dpdk.org, akhil.goyal@nxp.com Cc: Gagandeep Singh , Hemant Agrawal Date: Fri, 12 Oct 2018 20:10:42 +0530 Message-Id: <20181012144055.9461-2-g.singh@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181012144055.9461-1-g.singh@nxp.com> References: <20180913060846.29930-1-g.singh@nxp.com> <20181012144055.9461-1-g.singh@nxp.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [14.142.187.166] X-ClientProxiedBy: PN1PR0101CA0039.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00:c::25) To HE1PR04MB1530.eurprd04.prod.outlook.com (2a01:111:e400:59a8::20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 77c7b9ca-fe2f-418d-a04a-08d63050cff2 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:HE1PR04MB1530; X-Microsoft-Exchange-Diagnostics: 1; HE1PR04MB1530; 3:e+PXiaFs6/+rTTZqHipR/i0k11RkoD3e2L8ldLVQ4W0HWC3SWrB+1x4dic4FDgxgbjmewYO/LjY+22++d6G6dGCa7kGTX+q8SDiIlFLbN2+0l/DxBTYtvk2Mg+1fi0cvLzGxKCV8NJzvm4zGrts7e0SW7QdugH/srp2FhpFI2kh5Ivz791bCK19qLVy/CPkHCtTvwsJYYeLDDso4H8RGWyh1xi6Mb/XxNMIuVajY8JUKoxM7X0+QAt65UsjDY3xU; 25:sXtie5JVwGFEMWFfoKqct0Vwlb5m29I0CxOhCKj/p3FeS4qIY069f9YPt17Lyt/K/EA9phri3Gu4ND6/UD5WBDKsGnjnQDLraXAT1FmGArVSEckIA+dFKfuUxAbYdAzq7p2146/IM43HB9+jncnc66VbSilZ8yHzr3LzJlyRszaJtTiZfIs11OiJAvJ/M26+UsJBwpt41uze7DP5ZPkub5uP6ZZdqsJLv0JNCSqTfiVWJ+Ly13LQ9UilpViohcRg1alS1ziXlpa/LEbwODTMevDLUxgawMcu+3z1ex2Pu4Hd4WvFQ48Kr1wTUXOqF6cEKRmQd0tLAm+Jn0u+N8zwMg==; 31:/SoaXAL+K/aHQy7FhKFMR+C7RA+4gvUgAMCdUbTgDnWhrkSXEJlUnKgp5PEeXhELcv6fk3dC7cOkCe0Hp/84WiAAU7Dtp02LhZjNXSdBQ30rpD/a8+8taaCV2/S28DiqQ5xhQZLUThAL6p+FhrxLH4cO9egpuz3Riw/aG53ogB+0X9CB2GgyJXcfotTPX4MI0FzbSNoafOj6lhRN1FkkzFANK7aVDdblB0X1jXSOL0U= X-MS-TrafficTypeDiagnostic: HE1PR04MB1530: X-Microsoft-Exchange-Diagnostics: 1; HE1PR04MB1530; 20:m31Fo18Zu3GqRglHSq/tso1I2ki8DZRtUj62KUZAwAFaa8G3CjaL9rNNg94r2S/JdujGkyjOwrBsRYhHhxEbp/9AuR65rWAOSiwyMqXIxl5RnsmDf1YQy0s0JbmiM4w99I+SSMk3edyt09tK08rhTS0vkNkHzMeE4g2pYqnWt2tdZKMr85L+DFOIAox9PsSogyc3OkUX0dh9jPhUSmbjIDydhZHVaF6R7C6frNCo4l9gjW0nwHSuv99IdIK5WVMnNLwVDdQd2d7r48I1dcn3GFTYKWT6sm0j7Dp6fDsXndCbrmWKLIw5OkfCYD4Iw/U0RTQ4zi+k3o7NkXn+u/mqGAw22whKagGrjp5pxnT8ajfQg5OFqCCvNpq7Mkt2uCz6YD1ckYbR6KjNMlEAxvsor3lQYPgZ3X2bkAsMebTv4WOuWUPJ5W2/OB25tkfod2FmEGefuwuvzQ2FOmTzvtWVZeFOBXPxRGRbt2ARs3ic6gYHBkhALx7oahzwLHVV1zYM; 4:3BC/MdjLTU9+DcC8xJFUzBiI4cY4XP3G1Vi3nCEs2/1DT1ASh3O3Yrn8PCuG89i8kemIZ84mP1Id9oi/2DNOeZkVZhQd0r5Du1eAiu/YqtP75ntUAMhkBGWr6A7B4lmCwADDCyX6Brkt9f7V7640f5VYKsA2h51pv3dJtI5BB/+DJkOOuhsbIX3A10KSOhkFJbqkXAjei2QPeM3OOQEcKCxpErZHVPdTUDrnR2NAAReL5QiSwibSvDzsgzCBG+SJCro1iK3bnl1RI0UKG7k37UPNwg0LOHvPoZjTsf2SGcUI4qefqk03e6XkY+rkwflPZ+bLwXeWg/kqZ18YGgvwQtRH025os2IRRctUqLw6oXY= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(192374486261705); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3002001)(3231355)(944501410)(52105095)(10201501046)(93006095)(93001095)(6055026)(149066)(150057)(6041310)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123562045)(201708071742011)(7699051); SRVR:HE1PR04MB1530; BCL:0; PCL:0; RULEID:; SRVR:HE1PR04MB1530; X-Forefront-PRVS: 0823A5777B X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(376002)(366004)(396003)(136003)(39860400002)(189003)(199004)(316002)(305945005)(8936002)(386003)(55236004)(6636002)(6506007)(106356001)(25786009)(36756003)(4744004)(16586007)(5660300001)(72206003)(52116002)(53936002)(26005)(6512007)(478600001)(54906003)(68736007)(186003)(16526019)(50226002)(7736002)(105586002)(51416003)(97736004)(76176011)(78486009)(3846002)(2906002)(66066001)(1076002)(4326008)(956004)(446003)(2616005)(47776003)(11346002)(6666004)(1006002)(6116002)(486006)(14444005)(476003)(8676002)(50466002)(48376002)(81156014)(575784001)(86362001)(81166006)(6486002)(110426005); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR04MB1530; H:Tophie.ap.freescale.net; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR04MB1530; 23:Hgkw3wvgyjYp84ArV0RAsUyb4dTBPE+mz/D/pa+Yj?= =?us-ascii?Q?MCp58omkuXQ5EWTSTcapIh03RK8noYg2Ounj5faB61RoPpz+7vEzW16wZMW/?= =?us-ascii?Q?ovSFBZImlIzZ/vR412ed8kDg9iO5hFdzs1yVdbb1lk38WqXZlFkw2dNwaxFG?= =?us-ascii?Q?tdl3799Hfi29SvQMYmjEMOGT9/LGbbAI9PwV5CBbjCYEEhf/s4XUZ7A/x4Xf?= =?us-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qUdAnHn64XeL1p/N/BOvaLAZVTABUf75tfMTCVzHDrQdcHaLKzXN9OSjjSuJlcx0WZDxYIN/3F2kdF2NCnxaKQk70AqvjS120hSo5LmZcpexeJZH9FaW9MZgnWVPCczDy4SbBCM8zcHDwfZWMyH6aUErzvFFNE+v39odJ9AO81IyXQ==; 5:jk3imtW9zzPV+hNYvMXR8+D0XcQG94Rt1md9TWbTNuJRP6QjiKhpFcVJKQdxd1JrSwUOBT7hO+EsvqHTFWlj0eYMDmQ/72Zn8gVZPAPbZk9nNHARwfIFyzI0KBq9+6hdu8Xw886MZnLoPWV3dMFfnN9B1QaBChrTkehAgOo2bfc=; 7:LA2SAwCVXe3upcTEU7XWoQ8L8WHncdfe+AQ5LgrB7f/w3Iqos+qT2uz3/Tg6db5TbGPYRZpwQ9/3IGvPW5084KUoEfutbH4YqBXb+faksetBvFH7eOgZazA1khTy15W4jdCRsFwcnsbNKlMiwh0vQ9kCq8zp+VH1b8Ewq/cktXfl82HdHfJzLFQsf4uE/3vXNYiaedl61y95bgwFbdsKMPhBKWjU1Wa4rSrtfSRG5eLk9+PkXHdfMVTQFxnzDwEe SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Oct 2018 14:41:35.2085 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 77c7b9ca-fe2f-418d-a04a-08d63050cff2 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR04MB1530 Subject: [dpdk-dev] [PATCH v2 01/14] crypto/caam_jr: introduce basic driver 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, 12 Oct 2018 14:41:39 -0000 The caam_jr poll mode crypto driver is supported for NXP SEC 4.x+ (CAAM) hardware accelerator. This driver is by default supported on LE platforms, if it is used on BE platforms like LS104X, config option CONFIG_RTE_LIBRTE_PMD_CAAM_JR_BE can be enabled. This patch add skeleton for caam jobring driver with probe and uintialisation functions Signed-off-by: Gagandeep Singh Signed-off-by: Hemant Agrawal --- config/common_base | 6 + config/common_linuxapp | 1 + config/defconfig_arm64-dpaa-linuxapp-gcc | 3 + drivers/crypto/Makefile | 1 + drivers/crypto/caam_jr/Makefile | 37 +++++ drivers/crypto/caam_jr/caam_jr.c | 151 ++++++++++++++++++ drivers/crypto/caam_jr/caam_jr_log.h | 42 +++++ drivers/crypto/caam_jr/meson.build | 11 ++ .../caam_jr/rte_pmd_caam_jr_version.map | 4 + drivers/crypto/meson.build | 5 +- 10 files changed, 259 insertions(+), 2 deletions(-) create mode 100644 drivers/crypto/caam_jr/Makefile create mode 100644 drivers/crypto/caam_jr/caam_jr.c create mode 100644 drivers/crypto/caam_jr/caam_jr_log.h create mode 100644 drivers/crypto/caam_jr/meson.build create mode 100644 drivers/crypto/caam_jr/rte_pmd_caam_jr_version.map diff --git a/config/common_base b/config/common_base index 5519d71e9..9dac7e06c 100644 --- a/config/common_base +++ b/config/common_base @@ -490,6 +490,12 @@ CONFIG_RTE_CRYPTO_MAX_DEVS=64 CONFIG_RTE_LIBRTE_PMD_ARMV8_CRYPTO=n CONFIG_RTE_LIBRTE_PMD_ARMV8_CRYPTO_DEBUG=n +# +# Compile NXP CAAM JR crypto Driver +# +CONFIG_RTE_LIBRTE_PMD_CAAM_JR=n +CONFIG_RTE_LIBRTE_PMD_CAAM_JR_BE=n + # # Compile NXP DPAA2 crypto sec driver for CAAM HW # diff --git a/config/common_linuxapp b/config/common_linuxapp index 485e1467d..d76b7963e 100644 --- a/config/common_linuxapp +++ b/config/common_linuxapp @@ -35,6 +35,7 @@ CONFIG_RTE_LIBRTE_DPAA_MEMPOOL=y CONFIG_RTE_LIBRTE_DPAA_PMD=y CONFIG_RTE_LIBRTE_PMD_DPAA_EVENTDEV=y CONFIG_RTE_LIBRTE_PMD_DPAA_SEC=y +CONFIG_RTE_LIBRTE_PMD_CAAM_JR=y # NXP FSLMC BUS and DPAA2 drivers CONFIG_RTE_LIBRTE_FSLMC_BUS=y diff --git a/config/defconfig_arm64-dpaa-linuxapp-gcc b/config/defconfig_arm64-dpaa-linuxapp-gcc index c47aec0a6..544b6770d 100644 --- a/config/defconfig_arm64-dpaa-linuxapp-gcc +++ b/config/defconfig_arm64-dpaa-linuxapp-gcc @@ -21,3 +21,6 @@ CONFIG_RTE_PKTMBUF_HEADROOM=128 # NXP DPAA Bus CONFIG_RTE_LIBRTE_DPAA_DEBUG_DRIVER=n CONFIG_RTE_LIBRTE_DPAA_HWDEBUG=n + +# NXP CAAM_JR driver +CONFIG_RTE_LIBRTE_PMD_CAAM_JR_BE=y diff --git a/drivers/crypto/Makefile b/drivers/crypto/Makefile index c083e64ff..c25a19fb0 100644 --- a/drivers/crypto/Makefile +++ b/drivers/crypto/Makefile @@ -6,6 +6,7 @@ include $(RTE_SDK)/mk/rte.vars.mk DIRS-$(CONFIG_RTE_LIBRTE_PMD_AESNI_GCM) += aesni_gcm DIRS-$(CONFIG_RTE_LIBRTE_PMD_AESNI_MB) += aesni_mb DIRS-$(CONFIG_RTE_LIBRTE_PMD_ARMV8_CRYPTO) += armv8 +DIRS-$(CONFIG_RTE_LIBRTE_PMD_CAAM_JR) += caam_jr DIRS-$(CONFIG_RTE_LIBRTE_PMD_CCP) += ccp DIRS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO) += octeontx DIRS-$(CONFIG_RTE_LIBRTE_PMD_OPENSSL) += openssl diff --git a/drivers/crypto/caam_jr/Makefile b/drivers/crypto/caam_jr/Makefile new file mode 100644 index 000000000..b1f3ecee7 --- /dev/null +++ b/drivers/crypto/caam_jr/Makefile @@ -0,0 +1,37 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright 2017 NXP + +include $(RTE_SDK)/mk/rte.vars.mk + +# +# library name +# +LIB = librte_pmd_caam_jr.a + +# build flags +CFLAGS += -DALLOW_EXPERIMENTAL_API + +CFLAGS += -D _GNU_SOURCE + +CFLAGS += -O3 +CFLAGS += $(WERROR_FLAGS) + +CFLAGS += -I$(RTE_SDK)/drivers/crypto/caam_jr +CFLAGS += -I$(RTE_SDK)/lib/librte_eal/common/include +CFLAGS += -I$(RTE_SDK)/lib/librte_eal/linuxapp/eal + +# versioning export map +EXPORT_MAP := rte_pmd_caam_jr_version.map + +# library version +LIBABIVER := 1 + +# library source files +SRCS-$(CONFIG_RTE_LIBRTE_PMD_CAAM_JR) += caam_jr.c +# library dependencies + +LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring +LDLIBS += -lrte_cryptodev +LDLIBS += -lrte_bus_vdev + +include $(RTE_SDK)/mk/rte.lib.mk diff --git a/drivers/crypto/caam_jr/caam_jr.c b/drivers/crypto/caam_jr/caam_jr.c new file mode 100644 index 000000000..27331194a --- /dev/null +++ b/drivers/crypto/caam_jr/caam_jr.c @@ -0,0 +1,151 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2017-2018 NXP + */ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define CRYPTODEV_NAME_CAAM_JR_PMD crypto_caam_jr +static uint8_t cryptodev_driver_id; +int caam_jr_logtype; + +/* + * @brief Release the resources used by the SEC user space driver. + * + * Reset and release SEC's job rings indicated by the User Application at + * init_job_ring() and free any memory allocated internally. + * Call once during application tear down. + * + * @note In case there are any descriptors in-flight (descriptors received by + * SEC driver for processing and for which no response was yet provided to UA), + * the descriptors are discarded without any notifications to User Application. + * + * @retval ::0 is returned for a successful execution + * @retval ::-1 is returned if SEC driver release is in progress + */ +static int +caam_jr_dev_uninit(struct rte_cryptodev *dev) +{ + if (dev == NULL) + return -ENODEV; + + CAAM_JR_INFO("Closing crypto device %s", dev->data->name); + + return 0; +} + +static int +caam_jr_dev_init(const char *name, + struct rte_vdev_device *vdev, + struct rte_cryptodev_pmd_init_params *init_params) +{ + struct rte_cryptodev *dev; + + PMD_INIT_FUNC_TRACE(); + + dev = rte_cryptodev_pmd_create(name, &vdev->device, init_params); + if (dev == NULL) { + CAAM_JR_ERR("failed to create cryptodev vdev"); + goto cleanup; + } + + dev->driver_id = cryptodev_driver_id; + dev->dev_ops = NULL; + + /* For secondary processes, we don't initialise any further as primary + * has already done this work. Only check we don't need a different + * RX function + */ + if (rte_eal_process_type() != RTE_PROC_PRIMARY) { + CAAM_JR_WARN("Device already init by primary process"); + return 0; + } + + RTE_LOG(INFO, PMD, "%s cryptodev init\n", dev->data->name); + + return 0; + +cleanup: + CAAM_JR_ERR("driver %s: cryptodev_caam_jr_create failed", + init_params->name); + + return -ENXIO; +} + +/** Initialise CAAM JR crypto device */ +static int +cryptodev_caam_jr_probe(struct rte_vdev_device *vdev) +{ + struct rte_cryptodev_pmd_init_params init_params = { + "", + 128, + rte_socket_id(), + RTE_CRYPTODEV_PMD_DEFAULT_MAX_NB_QUEUE_PAIRS + }; + const char *name; + const char *input_args; + + name = rte_vdev_device_name(vdev); + if (name == NULL) + return -EINVAL; + + input_args = rte_vdev_device_args(vdev); + rte_cryptodev_pmd_parse_input_args(&init_params, input_args); + + return caam_jr_dev_init(name, vdev, &init_params); +} + +/** Uninitialise CAAM JR crypto device */ +static int +cryptodev_caam_jr_remove(struct rte_vdev_device *vdev) +{ + struct rte_cryptodev *cryptodev; + const char *name; + + name = rte_vdev_device_name(vdev); + if (name == NULL) + return -EINVAL; + + cryptodev = rte_cryptodev_pmd_get_named_dev(name); + if (cryptodev == NULL) + return -ENODEV; + + caam_jr_dev_uninit(cryptodev); + + return rte_cryptodev_pmd_destroy(cryptodev); +} + +static struct rte_vdev_driver cryptodev_caam_jr_drv = { + .probe = cryptodev_caam_jr_probe, + .remove = cryptodev_caam_jr_remove +}; + +static struct cryptodev_driver caam_jr_crypto_drv; + +RTE_PMD_REGISTER_VDEV(CRYPTODEV_NAME_CAAM_JR_PMD, cryptodev_caam_jr_drv); +RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_CAAM_JR_PMD, + "max_nb_queue_pairs=" + "socket_id="); +RTE_PMD_REGISTER_CRYPTO_DRIVER(caam_jr_crypto_drv, cryptodev_caam_jr_drv.driver, + cryptodev_driver_id); + +RTE_INIT(caam_jr_init_log) +{ + caam_jr_logtype = rte_log_register("pmd.crypto.caam"); + if (caam_jr_logtype >= 0) + rte_log_set_level(caam_jr_logtype, RTE_LOG_NOTICE); +} diff --git a/drivers/crypto/caam_jr/caam_jr_log.h b/drivers/crypto/caam_jr/caam_jr_log.h new file mode 100644 index 000000000..106ff07a7 --- /dev/null +++ b/drivers/crypto/caam_jr/caam_jr_log.h @@ -0,0 +1,42 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2017-2018 NXP + */ + +#ifndef _CAAM_JR_LOG_H_ +#define _CAAM_JR_LOG_H_ + +#include + +extern int caam_jr_logtype; + +#define CAAM_JR_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, caam_jr_logtype, "caam_jr: " \ + fmt "\n", ##args) + +#define CAAM_JR_DEBUG(fmt, args...) \ + rte_log(RTE_LOG_DEBUG, caam_jr_logtype, "caam_jr: %s(): " \ + fmt "\n", __func__, ##args) + +#define PMD_INIT_FUNC_TRACE() CAAM_JR_DEBUG(" >>") + +#define CAAM_JR_INFO(fmt, args...) \ + CAAM_JR_LOG(INFO, fmt, ## args) +#define CAAM_JR_ERR(fmt, args...) \ + CAAM_JR_LOG(ERR, fmt, ## args) +#define CAAM_JR_WARN(fmt, args...) \ + CAAM_JR_LOG(WARNING, fmt, ## args) + +/* DP Logs, toggled out at compile time if level lower than current level */ +#define CAAM_JR_DP_LOG(level, fmt, args...) \ + RTE_LOG_DP(level, PMD, fmt "\n", ## args) + +#define CAAM_JR_DP_DEBUG(fmt, args...) \ + CAAM_JR_DP_LOG(DEBUG, fmt, ## args) +#define CAAM_JR_DP_INFO(fmt, args...) \ + CAAM_JR_DP_LOG(INFO, fmt, ## args) +#define CAAM_JR_DP_WARN(fmt, args...) \ + CAAM_JR_DP_LOG(WARNING, fmt, ## args) +#define CAAM_JR_DP_ERR(fmt, args...) \ + CAAM_JR_DP_LOG(ERR, fmt, ## args) + +#endif /* _CAAM_JR_LOG_H_ */ diff --git a/drivers/crypto/caam_jr/meson.build b/drivers/crypto/caam_jr/meson.build new file mode 100644 index 000000000..3edd0a212 --- /dev/null +++ b/drivers/crypto/caam_jr/meson.build @@ -0,0 +1,11 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright 2018 NXP + +if host_machine.system() != 'linux' + build = false +endif + +deps += ['bus_vdev', 'bus_dpaa', 'security'] +sources = files('caam_jr.c') + +allow_experimental_apis = true diff --git a/drivers/crypto/caam_jr/rte_pmd_caam_jr_version.map b/drivers/crypto/caam_jr/rte_pmd_caam_jr_version.map new file mode 100644 index 000000000..521e51f41 --- /dev/null +++ b/drivers/crypto/caam_jr/rte_pmd_caam_jr_version.map @@ -0,0 +1,4 @@ +DPDK_18.11 { + + local: *; +}; diff --git a/drivers/crypto/meson.build b/drivers/crypto/meson.build index e9c491af6..bf1bd9286 100644 --- a/drivers/crypto/meson.build +++ b/drivers/crypto/meson.build @@ -1,8 +1,9 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel Corporation -drivers = ['aesni_gcm', 'aesni_mb', 'ccp', 'dpaa_sec', 'dpaa2_sec', 'kasumi', 'mvsam', - 'null', 'octeontx', 'openssl', 'qat', 'scheduler', 'virtio', 'zuc'] +drivers = ['aesni_gcm', 'aesni_mb', 'caam_jr', 'ccp', 'dpaa_sec', 'dpaa2_sec', + 'kasumi', 'mvsam', 'null', 'octeontx', 'openssl', 'qat', 'scheduler', + 'virtio', 'zuc'] std_deps = ['cryptodev'] # cryptodev pulls in all other needed deps config_flag_fmt = 'RTE_LIBRTE_@0@_PMD' -- 2.17.1