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 359D8A00C2 for ; Mon, 6 Jun 2022 03:53:04 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2409F42685; Mon, 6 Jun 2022 03:53:04 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id D989040A7F; Mon, 6 Jun 2022 03:53:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654480381; x=1686016381; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=7T3oc5ssfNvZpwwNbpr+aC+Ia8UVwwXKl+WqOl25XL4=; b=fuDJRIn1nC8c4FOctqmOLdDQwDTgRiDDMpdP2XdpeMmdUWD2SYvmYHon 14+Vm34jGELmMnySTCBlIrf++BUTqonOiMr75+TFUVn25uA7D3yn2Casg aZg8AWWIS7cLHGfM07w8lbJbuHyG3MXFX/1YVSrFJAJe7CGq1dQhkExJ4 IIJbtOBfys7mld4J4w8tjM06qe2/8JfMZ0ETN/I0z2swGZ3XQh0xq1fVp fGKxS1mXcUDRb72Jq/ubVQr/01sxoBDru1+hVXrv7fYHv2uMWQHZTvgP0 XpGU2YiQEfO3qGLWpxafWi3vqwwVbE1ntAgqwaJw1oxqFfCCXdteUS3eo Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10369"; a="276442916" X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="276442916" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2022 18:52:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="647266731" Received: from fmsmsx604.amr.corp.intel.com ([10.18.126.84]) by fmsmga004.fm.intel.com with ESMTP; 05 Jun 2022 18:52:58 -0700 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx604.amr.corp.intel.com (10.18.126.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Sun, 5 Jun 2022 18:52:58 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx612.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27 via Frontend Transport; Sun, 5 Jun 2022 18:52:58 -0700 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (104.47.56.169) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.27; Sun, 5 Jun 2022 18:52:58 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f98xQhZ0T81dLTw23XMmynjI9Y9iNgK16DC1deOgfxUwZigGox8Zgg3tqJSPvybE+vMVkC/phBnHBdAAelUhQ4bQorHmaCFYgGguA5VPE4cgvtyrguBj8ItY7Zfwex+OxruptgfScwQh2Uh9IRfJfNfAbawarAA9VZq5f1eCxUVAy44/S+4qYDWsXXtMNTP8z89rVSBHtL+gszjeSOrneXP6A2kfmCv/J9G173vi/1jfNJ5i9QYgKAOtGCikCERnEG+sjoO0aEVtHNkTeAlpdQGkhHIfiSc5cVGjY6W3VjJKkZlyyWNqS1/qMxUPVUs7JuQONKNYGY9UayCrgdQPUw== 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=Eaj6Ps/Dgcw0gVW9JM6+lbsEcRK+NfOmIWDKpodmpeA=; b=ND/JjPfYcbnoWO9jSkwG6IeSkXH6xt4IVrYOa15ytwENFSV8Le53xB6/B2gfDKREd/BY1DaW9l20PjAe3XxL3tM1zrxlEz9geY2y8MQFsBaJiYriK/fHfRQT9mWYs4ClTwLqrg46xq3V++1xPYHCHKMqVzw5brccb/nu3rbg75GnRXsLoLvAfiPSyn71IOy0Tcmnau9nuvI1bY7MQzJoqgYw8E59DdQmjii5sUIkTMmB0xoZR0tYH5S9HCn1YdbPTt7GtLiCvxvh+bziNA6wvpIPuC8Y5q+vQlaWrd3UkKUMAPSkFgGNTtigZ89CUZgGX+GU5L3FJOKMrTYNlv4Jmw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from BN9PR11MB5483.namprd11.prod.outlook.com (2603:10b6:408:104::10) by SJ0PR11MB5584.namprd11.prod.outlook.com (2603:10b6:a03:3ba::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.13; Mon, 6 Jun 2022 01:52:56 +0000 Received: from BN9PR11MB5483.namprd11.prod.outlook.com ([fe80::4d94:5d8b:51d7:d8b4]) by BN9PR11MB5483.namprd11.prod.outlook.com ([fe80::4d94:5d8b:51d7:d8b4%9]) with mapi id 15.20.5314.019; Mon, 6 Jun 2022 01:52:56 +0000 From: "Zhang, Tianfei" To: "Huang, Wei" , "dev@dpdk.org" , "thomas@monjalon.net" , "nipun.gupta@nxp.com" , "hemant.agrawal@nxp.com" CC: "stable@dpdk.org" , "Xu, Rosen" , "Zhang, Qi Z" Subject: RE: [PATCH v5 1/5] drivers/raw: introduce AFU raw device driver Thread-Topic: [PATCH v5 1/5] drivers/raw: introduce AFU raw device driver Thread-Index: AQHYcYrSOnXAYeB/Y0GM+Z3CM5oUzK1BrD8Q Date: Mon, 6 Jun 2022 01:52:56 +0000 Message-ID: References: <1652939560-15786-1-git-send-email-wei.huang@intel.com> <1653629824-4535-1-git-send-email-wei.huang@intel.com> <1653629824-4535-2-git-send-email-wei.huang@intel.com> In-Reply-To: <1653629824-4535-2-git-send-email-wei.huang@intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.6.500.17 dlp-reaction: no-action authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 5784a7cc-340a-4e96-6270-08da475f46f1 x-ms-traffictypediagnostic: SJ0PR11MB5584:EE_ x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: edXDqCWCTW4dnXdJcxnmRQIxEmQBf6Lqp+JvqjqCwNymjpLYML9lv3NBKWk+igqpxdKZP8ppcSVS/QRt0zu+1cgr1DcbkPLoMoffhrTN3meh4EkHyc5oVcgiAHIhA9W5Rsw/fQpORpxn41KKKfF7WWo6BlYKYJR8G0lC27jC3CAxqWeO8e/yFHDOhcyg9EeMrekvqt5uruL4cAy0yIu1nttK1N7WKUME5z4r7PbQbkEqH1iMsxWNZppmzNezFapcmzZxera2Mq0EbQKscqjaILN9rVJ96dLd4qIlxP8Wl+KTTOfW61ZAc6Vh8HJlPMfePMult0/h1pr+Xc5tc0inXt7baJ4snFFSf/zmOPnL2d1AlgG/Lual5p+/O91732pZ4WwPUkuWWdHDTdaa9dMNAQjYHnRB8IiEQQABQ0Yqbdz8i83RNiBiKBj6oZBwJydkXALmHmE3Ei4ELSskSn90Hm9UfFWprLfEhVAlDufY4f/xUPMy7gVzYpg68kMDTom10ANYXygERmAoPQblFjhcreTTJOErvrwgPbEQCVBzOmed1C2Zr0dVLGnpvX/qQDcw9AxjBeq5/WdstIQfGmGwzb16BXczo4ZJHIdFj0KPmgdMYA+/ChhU8Mt0PeALKbKn5A0uqbWhVD/yBgkxLz7O2aBI+bCR9oVBl7/OXi9Lq0NliX6PIz2UlAjeFyPuCSymEdB4/ep9jP3qFCvz9ohG9Q== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN9PR11MB5483.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(2906002)(8936002)(33656002)(5660300002)(7696005)(6506007)(86362001)(71200400001)(316002)(52536014)(53546011)(30864003)(82960400001)(76116006)(8676002)(66446008)(508600001)(64756008)(4326008)(66556008)(66946007)(66476007)(110136005)(9686003)(54906003)(107886003)(26005)(38100700002)(83380400001)(38070700005)(55016003)(122000001)(186003); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?/WcDeN0EZY3EF1Tkh8AybYUfXgUl1424ev5qpyOCsIsRzoKasEyRZvB/32DM?= =?us-ascii?Q?UNGREibeKlgsgUeRk4oAs5j6brCbTY94seaw+Bvcjg2JQfwovqmI2K0xRgzZ?= =?us-ascii?Q?qO39PqS5It4ohW3NHAW+t/MholysU9grOXXmcywi7xnIMEZ5htG26QdrZkc3?= =?us-ascii?Q?TztlstesZ155ObUQK7LoOgmUA5NRUOpLfTL7P1gRKAx/QyesZpM6gjtlQ6iI?= =?us-ascii?Q?ugKmaxb8YdRFPej8R1oHA3QhKFPrhW7R+jO3AOI5OmP4Dh/Ao+sn6LdOe5qi?= =?us-ascii?Q?4bsCmXX17viOhC5wYD1lSHqSN3X4djXPm4Q4q/e5MxIJx5J9CSqCWM4+wFXZ?= =?us-ascii?Q?N7V+kBrrBUJUaUhbCBZ74Sbxsbs0lxthFCN0ArcXQ0+S7blTpo3FvmvUfkU+?= =?us-ascii?Q?BSHShe8WI+qe/gl3pcI16EB3fkV0lBjM/VCELqUmAQ6F7k8ZVEbNnVaIej/8?= =?us-ascii?Q?kE0cq3GpT8/R588hVeRb8jxIAEdYu+p1cfrGU3GqWmYmGfPioLikzwwWG9DL?= =?us-ascii?Q?39Iiij69DTompuQSYVEK3xZFmwKL+m2wJzLqm9n7iNHIOdBKVAuQb9ZPYkqt?= =?us-ascii?Q?gTMmWm9cwLWLNGWH/NmdU3OEXCj9MkZETU7nN154bjFO7C3JT1FpM40Dt2ky?= =?us-ascii?Q?VtINYvyMdbPbpk6k5//QFjFx6LaP9wWCYbHI+k/907C9Y/fS3o8eu9X9lp9s?= =?us-ascii?Q?9OoEom8IWYtxufQtggNxoNybm6m8k85zTApDDdULxgxkpaOMkFKRnz9E9PKt?= =?us-ascii?Q?dOPLHJst6/C3yQPU9iDXKtrO49SyFa/YTjDMB8Zz3XcGK9KSr7FauToQO9C6?= =?us-ascii?Q?ZL3Izy3TTJos9QuwNuYO+AUpy36e3SmVgzJgydkN6Eti3ihCHTKdy4fIob6J?= =?us-ascii?Q?5PVosp/uYEhAsKtNUyRgZDEILo6G7ZwK/LRa3JtqgkOS9zMY6iLOBJoN2JrI?= =?us-ascii?Q?k7SI/ocSKk0aaihkPp0BBnYpYrcHYmHjiwCbkfmNDpO9cV7qg+dwFWHkzRjy?= =?us-ascii?Q?RbymEM7OHSTKBciiT6wnSrczKHNS6RmFl2lUQpsGFBUBiOlm0rqUDihzaZXk?= =?us-ascii?Q?CB+G+vczAl2QVvyZv9iQmzrepnsL98tgrN1P8jxHa0Tj9xuALA6+kL1IDWIw?= =?us-ascii?Q?FbdFD5sjg5NDFpJ9LzBO0BGCVW2TcmNH3iLIXTssIFE1C8qFNEsvU+wRN8dH?= =?us-ascii?Q?0JhHOw9EgX5Ph1tfgX5c6dMXmdNuWfJmCmIUibtklXy7GDFkCrsO9R9LScnH?= =?us-ascii?Q?aUUL8cbR79hx5jXDwUOcsYqjS6/Cf7BzVDmHhm/IulT8EoKcFfdKwjTLWPkh?= =?us-ascii?Q?Gxh9VBlfRuUDT9H+FXn3pU7vwDIvhNg9ob5VhteT4j3aPrhVl11m/7/abUX0?= =?us-ascii?Q?EQe6qKlWRP8Xpfmai5CIBNjjKOowTbKlnxhKoOvoy5WsMK+KOmleGbIIo+5b?= =?us-ascii?Q?2eNPzi4A/eVUKD61AuX70lnt9jA4Ljmyuw2BlIhWEgzzo/Mb0QHHFypqwS/b?= =?us-ascii?Q?XHkRbSkNzF+/9R01l87jpRAfC8mYmhI/4ZnyrrpE8y/8qCS/ydbekslsdEkF?= =?us-ascii?Q?W5bgs7JCNK5kmJC++sq0Vqea90//jrjPvnSnD+ke/jw1h6eSAQt9tf5EISOa?= =?us-ascii?Q?AHFyLFosDtTxIEkk4pxSwI1LrkZiMfMCbQe17IDMnwVY47IvorGuF3eZybUC?= =?us-ascii?Q?JfiRg8ZDOigHowuun2hr+JZQ26uR7o2MJWUX6yiAO69ZMECqDZtPvoU3omFt?= =?us-ascii?Q?vDjtZPGoIA=3D=3D?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BN9PR11MB5483.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5784a7cc-340a-4e96-6270-08da475f46f1 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Jun 2022 01:52:56.3410 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: ORcG0ty/AGlTSVjDLCSbIw8GBsFXzBsN7e/TkvzaOlmGGhdpYcQ+KtKg3rSM3opx2UKzPldJyZ9P6aZbSaTDaQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB5584 X-OriginatorOrg: intel.com X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org > -----Original Message----- > From: Huang, Wei > Sent: Friday, May 27, 2022 1:37 PM > To: dev@dpdk.org; thomas@monjalon.net; nipun.gupta@nxp.com; > hemant.agrawal@nxp.com > Cc: stable@dpdk.org; Xu, Rosen ; Zhang, Tianfei > ; Zhang, Qi Z ; Huang, Wei > > Subject: [PATCH v5 1/5] drivers/raw: introduce AFU raw device driver >=20 > Add multi-function AFU raw device driver to manage various AFU (Accelerat= ion > Function Unit) in FPGA. > This driver implements common AFU raw device interfaces and exposes them = to > application as standard raw device APIs. > Normal application can operate specified AFU as below, 1. call > rte_rawdev_pmd_get_named_dev() to find AFU raw device. > 2. call rte_rawdev_configure() to initialize AFU raw device. > 3. call rte_rawdev_selftest() to test function of AFU. >=20 > Signed-off-by: Wei Huang > --- > v2: fix typo > --- > v3: fix build error in FreeBSD13-64, UB2004-32 and UB2204-32 > --- > v4: fix coding style issue and build error in FreeBSD13-64 > --- > v5: split patch into several patches > --- > drivers/raw/afu_mf/afu_mf_rawdev.c | 425 > +++++++++++++++++++++++++++++++++++++ > drivers/raw/afu_mf/afu_mf_rawdev.h | 71 +++++++ > drivers/raw/afu_mf/meson.build | 5 + > drivers/raw/afu_mf/version.map | 3 + > drivers/raw/meson.build | 1 + > 5 files changed, 505 insertions(+) > create mode 100644 drivers/raw/afu_mf/afu_mf_rawdev.c > create mode 100644 drivers/raw/afu_mf/afu_mf_rawdev.h > create mode 100644 drivers/raw/afu_mf/meson.build create mode 100644 > drivers/raw/afu_mf/version.map I am thinking that just put those afu* c/h files into drivers/raw/ifpga/ fo= lder is better? Because this AFU PMD driver is work on ifpga. And the file name of "afu_mf_rawdev.c" change to "afu_pmd_driver.c"? >=20 > diff --git a/drivers/raw/afu_mf/afu_mf_rawdev.c > b/drivers/raw/afu_mf/afu_mf_rawdev.c > new file mode 100644 > index 0000000..5be372a > --- /dev/null > +++ b/drivers/raw/afu_mf/afu_mf_rawdev.c > @@ -0,0 +1,425 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright 2022 Intel Corporation > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > +#include > +#include > +#include > + > +#include "afu_mf_rawdev.h" > + > +#define AFU_MF_PMD_RAWDEV_NAME rawdev_afu_mf > + > +static const struct rte_afu_uuid afu_uuid_map[] =3D { > + { 0, 0 /* sentinel */ } > +}; > + > +static struct afu_mf_drv *afu_table[] =3D { > + NULL > +}; > + > +static inline int afu_mf_trylock(struct afu_mf_rawdev *dev) { > + int32_t x =3D 0; > + > + if (!dev || !dev->shared) > + return -ENODEV; > + > + x =3D __atomic_load_n(&dev->shared->lock, __ATOMIC_RELAXED); > + > + if ((x !=3D 0) || (__atomic_compare_exchange_n(&dev->shared->lock, &x, > 1, > + 1, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED) > =3D=3D 0)) > + return -EBUSY; > + > + return 0; > +} > + > +static inline void afu_mf_unlock(struct afu_mf_rawdev *dev) { > + if (!dev || !dev->shared) > + return; > + > + __atomic_store_n(&dev->shared->lock, 0, __ATOMIC_RELEASE); } > + > +static int afu_mf_rawdev_configure(const struct rte_rawdev *rawdev, > + rte_rawdev_obj_t config, size_t config_size) { > + struct afu_mf_rawdev *dev =3D NULL; > + int ret =3D 0; > + > + AFU_MF_PMD_FUNC_TRACE(); > + > + dev =3D afu_mf_rawdev_get_priv(rawdev); > + if (!dev) > + return -ENODEV; > + > + if (dev->ops && dev->ops->config) > + ret =3D (*dev->ops->config)(dev, config, config_size); > + > + return ret; > +} > + > +static int afu_mf_rawdev_start(struct rte_rawdev *rawdev) { > + struct afu_mf_rawdev *dev =3D NULL; > + int ret =3D 0; > + > + AFU_MF_PMD_FUNC_TRACE(); > + > + dev =3D afu_mf_rawdev_get_priv(rawdev); > + if (!dev) > + return -ENODEV; > + > + ret =3D afu_mf_trylock(dev); > + if (ret) { > + AFU_MF_PMD_WARN("AFU is busy, please start it later"); > + return ret; > + } > + > + if (dev->ops && dev->ops->start) > + ret =3D (*dev->ops->start)(dev); > + > + afu_mf_unlock(dev); > + > + return ret; > +} > + > +static void afu_mf_rawdev_stop(struct rte_rawdev *rawdev) { > + struct afu_mf_rawdev *dev =3D NULL; > + int ret =3D 0; > + > + AFU_MF_PMD_FUNC_TRACE(); > + > + dev =3D afu_mf_rawdev_get_priv(rawdev); > + if (!dev) > + return; > + > + ret =3D afu_mf_trylock(dev); > + if (ret) { > + AFU_MF_PMD_WARN("AFU is busy, please stop it later"); > + return; > + } > + > + if (dev->ops && dev->ops->stop) > + ret =3D (*dev->ops->stop)(dev); > + > + afu_mf_unlock(dev); > +} > + > +static int afu_mf_rawdev_close(struct rte_rawdev *rawdev) { > + struct afu_mf_rawdev *dev =3D NULL; > + int ret =3D 0; > + > + AFU_MF_PMD_FUNC_TRACE(); > + > + dev =3D afu_mf_rawdev_get_priv(rawdev); > + if (!dev) > + return -ENODEV; > + > + if (dev->ops && dev->ops->close) > + ret =3D (*dev->ops->close)(dev); > + > + return ret; > +} > + > +static int afu_mf_rawdev_reset(struct rte_rawdev *rawdev) { > + struct afu_mf_rawdev *dev =3D NULL; > + int ret =3D 0; > + > + AFU_MF_PMD_FUNC_TRACE(); > + > + dev =3D afu_mf_rawdev_get_priv(rawdev); > + if (!dev) > + return -ENODEV; > + > + ret =3D afu_mf_trylock(dev); > + if (ret) { > + AFU_MF_PMD_WARN("AFU is busy, please reset it later"); > + return ret; > + } > + > + if (dev->ops && dev->ops->reset) > + ret =3D (*dev->ops->reset)(dev); > + > + afu_mf_unlock(dev); > + > + return ret; > +} > + > +static int afu_mf_rawdev_selftest(uint16_t dev_id) { > + struct afu_mf_rawdev *dev =3D NULL; > + int ret =3D 0; > + > + AFU_MF_PMD_FUNC_TRACE(); > + > + if (!rte_rawdev_pmd_is_valid_dev(dev_id)) > + return -ENODEV; > + > + dev =3D afu_mf_rawdev_get_priv(&rte_rawdevs[dev_id]); > + if (!dev) > + return -ENOENT; > + > + ret =3D afu_mf_trylock(dev); > + if (ret) { > + AFU_MF_PMD_WARN("AFU is busy, please test it later"); > + return ret; > + } > + > + if (dev->ops && dev->ops->test) > + ret =3D (*dev->ops->test)(dev); > + > + afu_mf_unlock(dev); > + > + return ret; > +} > + > +static int afu_mf_rawdev_dump(struct rte_rawdev *rawdev, FILE *f) { > + struct afu_mf_rawdev *dev =3D NULL; > + int ret =3D 0; > + > + AFU_MF_PMD_FUNC_TRACE(); > + > + dev =3D afu_mf_rawdev_get_priv(rawdev); > + if (!dev) > + return -ENODEV; > + > + if (dev->ops && dev->ops->dump) > + ret =3D (*dev->ops->dump)(dev, f); > + > + return ret; > +} > + > +static const struct rte_rawdev_ops afu_mf_rawdev_ops =3D { > + .dev_info_get =3D NULL, > + .dev_configure =3D afu_mf_rawdev_configure, > + .dev_start =3D afu_mf_rawdev_start, > + .dev_stop =3D afu_mf_rawdev_stop, > + .dev_close =3D afu_mf_rawdev_close, > + .dev_reset =3D afu_mf_rawdev_reset, > + > + .queue_def_conf =3D NULL, > + .queue_setup =3D NULL, > + .queue_release =3D NULL, > + .queue_count =3D NULL, > + > + .attr_get =3D NULL, > + .attr_set =3D NULL, > + > + .enqueue_bufs =3D NULL, > + .dequeue_bufs =3D NULL, > + > + .dump =3D afu_mf_rawdev_dump, > + > + .xstats_get =3D NULL, > + .xstats_get_names =3D NULL, > + .xstats_get_by_name =3D NULL, > + .xstats_reset =3D NULL, > + > + .firmware_status_get =3D NULL, > + .firmware_version_get =3D NULL, > + .firmware_load =3D NULL, > + .firmware_unload =3D NULL, > + > + .dev_selftest =3D afu_mf_rawdev_selftest, }; > + > +static int > +afu_mf_shared_alloc(const char *name, struct afu_mf_shared **data, > + int socket_id) > +{ > + const struct rte_memzone *mz; > + char mz_name[RTE_MEMZONE_NAMESIZE]; > + struct afu_mf_shared *ptr =3D NULL; > + int init_mz =3D 0; > + > + if (!name || !data) > + return -EINVAL; > + > + /* name format is afu_?|??:??.? which is unique */ > + snprintf(mz_name, sizeof(mz_name), "%s", name); > + > + mz =3D rte_memzone_lookup(mz_name); > + if (!mz) { > + mz =3D rte_memzone_reserve(mz_name, > + sizeof(struct afu_mf_shared), > + socket_id, 0); > + init_mz =3D 1; > + } > + > + if (!mz) { > + AFU_MF_PMD_ERR("Allocate memory zone %s failed!", > + mz_name); > + return -ENOMEM; > + } > + > + ptr =3D (struct afu_mf_shared *)mz->addr; > + > + if (init_mz) /* initialize memory zone on the first time */ > + ptr->lock =3D 0; > + > + *data =3D ptr; > + > + return 0; > +} > + > +static int afu_mf_rawdev_name_get(struct rte_afu_device *afu_dev, char > *name, > + size_t size) > +{ > + int n =3D 0; > + > + if (!afu_dev || !name || !size) > + return -EINVAL; > + > + n =3D snprintf(name, size, "afu_%s", afu_dev->device.name); > + if (n >=3D (int)size) { > + AFU_MF_PMD_ERR("Name of AFU device is too long!"); > + return -ENAMETOOLONG; > + } > + > + return 0; > +} > + > +static struct afu_mf_ops *afu_mf_ops_get(struct rte_afu_uuid *afu_id) { > + struct afu_mf_drv *entry =3D NULL; > + int i =3D 0; > + > + if (!afu_id) > + return NULL; > + > + while ((entry =3D afu_table[i++])) { > + if ((entry->uuid.uuid_low =3D=3D afu_id->uuid_low) && > + (entry->uuid.uuid_high =3D=3D afu_id->uuid_high)) > + break; > + } > + > + return entry ? entry->ops : NULL; > +} > + > +static int afu_mf_rawdev_create(struct rte_afu_device *afu_dev, int > +socket_id) { > + struct rte_rawdev *rawdev =3D NULL; > + struct afu_mf_rawdev *dev =3D NULL; > + char name[RTE_RAWDEV_NAME_MAX_LEN] =3D {0}; > + int ret =3D 0; > + > + if (!afu_dev) > + return -EINVAL; > + > + ret =3D afu_mf_rawdev_name_get(afu_dev, name, sizeof(name)); > + if (ret) > + return ret; > + > + AFU_MF_PMD_INFO("Create raw device %s on NUMA node %d", > + name, socket_id); > + > + /* Allocate device structure */ > + rawdev =3D rte_rawdev_pmd_allocate(name, sizeof(struct > afu_mf_rawdev), > + socket_id); > + if (!rawdev) { > + AFU_MF_PMD_ERR("Unable to allocate raw device"); > + return -ENOMEM; > + } > + > + rawdev->dev_ops =3D &afu_mf_rawdev_ops; > + rawdev->device =3D &afu_dev->device; > + rawdev->driver_name =3D afu_dev->driver->driver.name; > + > + dev =3D afu_mf_rawdev_get_priv(rawdev); > + if (!dev) > + goto cleanup; > + > + dev->rawdev =3D rawdev; > + dev->port =3D afu_dev->id.port; > + dev->addr =3D afu_dev->mem_resource[0].addr; > + dev->ops =3D afu_mf_ops_get(&afu_dev->id.uuid); > + if (dev->ops =3D=3D NULL) { > + AFU_MF_PMD_ERR("Unsupported AFU device"); > + goto cleanup; > + } > + > + if (dev->ops->init) { > + ret =3D (*dev->ops->init)(dev); > + if (ret) { > + AFU_MF_PMD_ERR("Failed to init %s", name); > + goto cleanup; > + } > + } > + > + ret =3D afu_mf_shared_alloc(name, &dev->shared, socket_id); > + if (ret) > + goto cleanup; > + > + return ret; > + > +cleanup: > + rte_rawdev_pmd_release(rawdev); > + return ret; > +} > + > +static int afu_mf_rawdev_destroy(struct rte_afu_device *afu_dev) { > + struct rte_rawdev *rawdev =3D NULL; > + char name[RTE_RAWDEV_NAME_MAX_LEN] =3D {0}; > + int ret =3D 0; > + > + if (!afu_dev) > + return -EINVAL; > + > + ret =3D afu_mf_rawdev_name_get(afu_dev, name, sizeof(name)); > + if (ret) > + return ret; > + > + AFU_MF_PMD_INFO("Destroy raw device %s", name); > + > + rawdev =3D rte_rawdev_pmd_get_named_dev(name); > + if (!rawdev) { > + AFU_MF_PMD_ERR("Raw device %s not found", name); > + return -EINVAL; > + } > + > + /* rte_rawdev_close is called by pmd_release */ > + ret =3D rte_rawdev_pmd_release(rawdev); > + if (ret) > + AFU_MF_PMD_DEBUG("Device cleanup failed"); > + > + return 0; > +} > + > +static int afu_mf_rawdev_probe(struct rte_afu_device *afu_dev) { > + AFU_MF_PMD_FUNC_TRACE(); > + return afu_mf_rawdev_create(afu_dev, rte_socket_id()); } > + > +static int afu_mf_rawdev_remove(struct rte_afu_device *afu_dev) { > + AFU_MF_PMD_FUNC_TRACE(); > + return afu_mf_rawdev_destroy(afu_dev); } > + > +static struct rte_afu_driver afu_mf_pmd_drv =3D { > + .id_table =3D afu_uuid_map, > + .probe =3D afu_mf_rawdev_probe, > + .remove =3D afu_mf_rawdev_remove > +}; > + > +RTE_PMD_REGISTER_AFU(AFU_MF_PMD_RAWDEV_NAME, afu_mf_pmd_drv); > +RTE_LOG_REGISTER_DEFAULT(afu_mf_pmd_logtype, NOTICE); > diff --git a/drivers/raw/afu_mf/afu_mf_rawdev.h > b/drivers/raw/afu_mf/afu_mf_rawdev.h > new file mode 100644 > index 0000000..df6715c > --- /dev/null > +++ b/drivers/raw/afu_mf/afu_mf_rawdev.h > @@ -0,0 +1,71 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright 2022 Intel Corporation > + */ > + > +#ifndef __AFU_MF_RAWDEV_H__ > +#define __AFU_MF_RAWDEV_H__ > + > +#include > +#include > +#include > + > +#include > +#include > +#include > + > +extern int afu_mf_pmd_logtype; > + > +#define AFU_MF_PMD_LOG(level, fmt, args...) \ > + rte_log(RTE_LOG_ ## level, afu_mf_pmd_logtype, "%s(): " fmt "\n", \ > + __func__, ##args) > + > +#define AFU_MF_PMD_FUNC_TRACE() AFU_MF_PMD_LOG(DEBUG, ">>") > + > +#define AFU_MF_PMD_DEBUG(fmt, args...) \ > + AFU_MF_PMD_LOG(DEBUG, fmt, ## args) > +#define AFU_MF_PMD_INFO(fmt, args...) \ > + AFU_MF_PMD_LOG(INFO, fmt, ## args) > +#define AFU_MF_PMD_ERR(fmt, args...) \ > + AFU_MF_PMD_LOG(ERR, fmt, ## args) > +#define AFU_MF_PMD_WARN(fmt, args...) \ > + AFU_MF_PMD_LOG(WARNING, fmt, ## args) > + > +struct afu_mf_rawdev; > + > +struct afu_mf_ops { > + int (*init)(struct afu_mf_rawdev *dev); > + int (*config)(struct afu_mf_rawdev *dev, void *config, > + size_t config_size); > + int (*start)(struct afu_mf_rawdev *dev); > + int (*stop)(struct afu_mf_rawdev *dev); > + int (*test)(struct afu_mf_rawdev *dev); > + int (*close)(struct afu_mf_rawdev *dev); > + int (*reset)(struct afu_mf_rawdev *dev); > + int (*dump)(struct afu_mf_rawdev *dev, FILE *f); }; > + > +struct afu_mf_drv { > + struct rte_afu_uuid uuid; > + struct afu_mf_ops *ops; > +}; > + > +struct afu_mf_shared { > + int32_t lock; > +}; > + > +struct afu_mf_rawdev { > + struct rte_rawdev *rawdev; /* point to parent raw device */ > + struct afu_mf_shared *shared; /* shared data for multi-process */ > + struct afu_mf_ops *ops; /* device operation functions */ > + int port; /* index of port the AFU attached */ > + void *addr; /* base address of AFU registers */ > + void *priv; /* private driver data */ }; > + > +static inline struct afu_mf_rawdev * > +afu_mf_rawdev_get_priv(const struct rte_rawdev *rawdev) { > + return rawdev ? (struct afu_mf_rawdev *)rawdev->dev_private : NULL; } > + > +#endif /* __AFU_MF_RAWDEV_H__ */ > diff --git a/drivers/raw/afu_mf/meson.build b/drivers/raw/afu_mf/meson.bu= ild > new file mode 100644 index 0000000..80526a2 > --- /dev/null > +++ b/drivers/raw/afu_mf/meson.build > @@ -0,0 +1,5 @@ > +# SPDX-License-Identifier: BSD-3-Clause # Copyright 2022 Intel > +Corporation > + > +deps +=3D ['rawdev', 'bus_pci', 'bus_ifpga'] sources =3D > +files('afu_mf_rawdev.c') > diff --git a/drivers/raw/afu_mf/version.map b/drivers/raw/afu_mf/version.= map > new file mode 100644 index 0000000..c2e0723 > --- /dev/null > +++ b/drivers/raw/afu_mf/version.map > @@ -0,0 +1,3 @@ > +DPDK_22 { > + local: *; > +}; > diff --git a/drivers/raw/meson.build b/drivers/raw/meson.build index > 05e7de1..c3627f7 100644 > --- a/drivers/raw/meson.build > +++ b/drivers/raw/meson.build > @@ -6,6 +6,7 @@ if is_windows > endif >=20 > drivers =3D [ > + 'afu_mf', > 'cnxk_bphy', > 'cnxk_gpio', > 'dpaa2_cmdif', > -- > 1.8.3.1