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 E906CA0544 for ; Tue, 7 Jun 2022 04:35:55 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DF5A140156; Tue, 7 Jun 2022 04:35:55 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id 4CCBC40156; Tue, 7 Jun 2022 04:35:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654569353; x=1686105353; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=U93CcK7Mpwtzq6uBzOeEiAXXiH2z4lR9Nu5Z6SNeSNc=; b=HNIxiXhtBLc16LS5IGM0MPatESyzgJintPbfceLplDKnsCxvxcPS2P9z t1fe//y+7woeROIhfNPW2tykcqU2GMfxQ/PVMgUL1UKah5sO0zRagru9d 6m05HRcKnZdU+aWl6HO0e5nMLMbRAU5Vm4JybtTcvLL4DCxVpYonsgSE2 wt/ImTD7/FKyj6P6P2SlJY+8lG6gBAsyXhtD3MsLWGJmGLOurSN9HwqfD Ul7RpX3P8wrWveVOMlIcF3rZ9uosDS6bdAeanz/+c2K+2yPIMEKtKE8o4 RoxulAPqFt8QT7bShfNqtoIbEouynSFU33FA1GvXCtsdgCT8p7z6ErPel A==; X-IronPort-AV: E=McAfee;i="6400,9594,10370"; a="302065100" X-IronPort-AV: E=Sophos;i="5.91,282,1647327600"; d="scan'208";a="302065100" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2022 19:35:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,282,1647327600"; d="scan'208";a="826143632" Received: from fmsmsx604.amr.corp.intel.com ([10.18.126.84]) by fmsmga006.fm.intel.com with ESMTP; 06 Jun 2022 19:35:52 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) 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; Mon, 6 Jun 2022 19:35:51 -0700 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Mon, 6 Jun 2022 19:35:51 -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; Mon, 6 Jun 2022 19:35:51 -0700 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.100) 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; Mon, 6 Jun 2022 19:35:51 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FmAMrdu9YVMUQKfLlM+2feltwTrlKMSHox7JhIybFBpZneqt3L6OK6y+qyc+NHfC3agLkF0OeAXMVI3BUcFut6F1abEsHafznDcfAMAudo4tOQMdG3+UBfnctcnhKMAAY4QklMLkqLg11zQQw3yhsRyjvhewqmCKa4Q5M016z16/Chs4Iu8y2FHfMMNe1ghh8zA9L2NMJrNqTTHvLw34lMMMnhbauCtgHzC/BlfXwwb+zrzV+DYXpWxk30Kf3e102S6wNV5LMRpFF6iVMJ37btP9FN86YJFd2eHKqQs/5AZoYEncoQUI5N8FSaV4FvBjRjLO1E1b+g4M6ZESTLSeDg== 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=vgXKtjszdYn9b7Ulmr2TmHOMmTSlbbKg5mm1WOLIx9E=; b=IkQ1IRXdo4DR5IwDGGmgLXZOckp9BZ5g6efQ+4sKv7+tFWQda084BWgWMggAE5j4fljrAF6OpWbDK/SoqlK2KVVsksws6TC0XD1dndJWjOvHrFmX8aW88qcpVPh9uJ8+a0+KBT/b1402Lhu7MRFeg/+TqZXUQgLlMbp68CbeEx4icgTRJTqr93y+wTTNI+IkPVoUv55Bl236F+zqZqlYUVz6Vqf1vVaK3LzKnX5muA7GPqOJU7Hu5OLPI/XT9tR4gVkWmcy26snG2eVxrZRJ+lOVaCFknCAKz8ygkeMjMbcTxnhv1Mlz06QfkFfV90Wo/w0m3Vk/kG7K6enK1cKDew== 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 DM6PR11MB3530.namprd11.prod.outlook.com (2603:10b6:5:72::19) by BY5PR11MB4211.namprd11.prod.outlook.com (2603:10b6:a03:1ba::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.12; Tue, 7 Jun 2022 02:35:49 +0000 Received: from DM6PR11MB3530.namprd11.prod.outlook.com ([fe80::3d0e:6e37:569:cd07]) by DM6PR11MB3530.namprd11.prod.outlook.com ([fe80::3d0e:6e37:569:cd07%6]) with mapi id 15.20.5314.019; Tue, 7 Jun 2022 02:35:49 +0000 From: "Huang, Wei" To: "Zhang, Tianfei" , "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: AQHYcYrSsBplv7poB0mR3pczzalPw61BrTIAgAGeBkA= Date: Tue, 7 Jun 2022 02:35:49 +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: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.6.500.17 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: 47c6b136-d936-4b07-e1fe-08da482e6ecb x-ms-traffictypediagnostic: BY5PR11MB4211: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: UvULzvf8lkwFbYlA1etWRNY+7xpKZ1/9lvFXRXeUn5Cv1/gaZgT7R+/X5bheyLB9dqgdzk9f0wI6yDc6u/mAf4MRPfyn+vZ/8P6VvEcdB2J3hzhkVxMDdsLGhgQO1EFGvXzj8BQhxpMjfuvsEfxWOtS0htagA4vXbuzUc6W9slxYAY1Pt18Bvo8GnRDntfXI0WjSlg4F8u3YoVl+Y86mnY3Z/OFCQ1dL2qfQeUL9kzQWahPxysa9hJ+suMZ0TrCiHnOQaD5uLjGZAvbQ+dLQ2XPn+WDA2mkUCKSI9PqV+71hODRMku1nXquz69p01Mvtw8PISA3HNdsdl9t7NyqgH/FRzr8Sv4afRwzX/fH2sGJRdeyn5H/XV5HPj9ptiEpCIt7bKMXOkMHRHZaTpqcLhFFjsXTQxNrDBbUFHWHonR4ZulTAnoPG5bkgegmb703XwMrw4uoK0MfIXoiGhh99rjGbEYCTy7yS0xpU8rVUAECI68aro76jTDzzxE3J2NL5FNjJLpv0mu1ZsRxToF6Ik/ipnEEzKqxiHlIUCNe/vSs93mnGeHFTLrFR5Doo11b+YpG0Gid8pD5ivnW9uL/tkSraBz9i5IzPOgVocO/YaClv590WjEIlv6LIrguRXMW/B1i82ntZOWxBAMFzfUltIq4UionaSh1SzAjFlUm3nTuxZfU6TTQtM/bEIM/iDjBhs9SnvETmNHP++W5pFQiWAw== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR11MB3530.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(30864003)(6506007)(53546011)(71200400001)(66946007)(66476007)(38100700002)(33656002)(7696005)(4326008)(76116006)(86362001)(8676002)(66556008)(107886003)(186003)(8936002)(66446008)(5660300002)(2906002)(64756008)(55016003)(52536014)(508600001)(83380400001)(110136005)(54906003)(9686003)(82960400001)(26005)(316002)(38070700005)(122000001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?IML3zxDavJqhswFT0+jViWfNhV1rIhI1j748gEcIrUPHuAH0P/My5poCoCtM?= =?us-ascii?Q?J36dgcoYz4iYnNHtwS7kM0YM9cvSy+tz36mVSTrrl2qwlFDB1sfnrVUE9kvl?= =?us-ascii?Q?EVBcU+5EMerlSSHD/YG4nNZxhxD9TG2BNE5FS2egusPgAwRhk/6RvmPoaekg?= =?us-ascii?Q?CTnmPrEx8h6qZRuHBqcHwOmzujVnYF4u88u3FQ3xUP1mNFRirNaKNOsuy6IC?= =?us-ascii?Q?ifVafj29slLZaLc5fi1UeBuwgORNHtnuL4z6tN8retiZmY4sxEjJGfej3aBq?= =?us-ascii?Q?YUdndss1FUrDh6Ef6a6hOyKws1pQ64IDLXLM6CqRAwAxBThd5Dt3cXddEUqq?= =?us-ascii?Q?1OHTKqdTpf/9Y1Xh8HyuoxdMGEb0J8qtzhteCwZ5OcMR1ych5yIIajlQ4eSa?= =?us-ascii?Q?HsOiuky90SiF+4O4J2KlKX0zj+IsuiHe/ch3QsK9nXl2hlOCnrunEQk1K4xf?= =?us-ascii?Q?1m9IjMkmPN2v35ldcPW538blPoWkB2soaXORVQR9LBgUgxhWwqJ1VQT/Y5VZ?= =?us-ascii?Q?382WhH7XETVcqk9joAEB4PCBZseuraEg2DhPWAUMxn3d3JoygPWg4Q2mn7IJ?= =?us-ascii?Q?tDWDcs/uZsEyeV3L/XruofLn7Nazaodxmxmnh9HhSOLsyA8gbxUmEqwSGetY?= =?us-ascii?Q?BLRwLf/OosjAkKMBwN0By6fa2xNnZU4KoAsvRluvQm+GCfHAEMj2libSrsQg?= =?us-ascii?Q?P1J1gxfnvpUUYGVBvumJnhFVQQvyKpVZsZMozHqJefzV0KmGFJgx0mVbjl7K?= =?us-ascii?Q?S1X2jk59SDdlYS/ra5D+G01F9IFxiTLbhJkX+4Bmn8Hhyh5ALuuhXLlooQSN?= =?us-ascii?Q?ifmjBYMybLPMcwlmcYeD/bjRNjt/vdkjZfy7UDtymUoAjrZ+ZyzuNcHQNd8D?= =?us-ascii?Q?/oBE4nvzM2WdcxwMPYsGSSW/rcjuxG4hmrojYbPJYIZ/KA+T07Ty5RgDc/FV?= =?us-ascii?Q?mJ03VG9E74XtMnJH0wAkOsd/Abn91npPdYpm6/3QgZWXc5j5FqCwjsauLi73?= =?us-ascii?Q?h9fAd2/08w2zwk3Bk5RHMBl5keSS1NFAhTctxbcoEZ2fqukqtSO3SZEr4zI8?= =?us-ascii?Q?IAZK/PiJMrgcB/JMXqL2cxKtLtJ+Os9PXyT7p6CCzLCnGlPvN01PGl497wve?= =?us-ascii?Q?BxETOp+t5Mvm+xzs6svWO0y/dKEX9mBB0spVRvYoMBH+jFvPI7JFlIN8KF7V?= =?us-ascii?Q?DnWRDUDxfCW2zlBNEJXmKFnngtWHHAu4YF0FlqF0C45FgHVT4E9agbQewqU9?= =?us-ascii?Q?mJigV+va6zgNH/BHdTLVEcqxsmo1DS6dabGUInPTOoA++qzDBtTi15RYAlGV?= =?us-ascii?Q?nibtYn38qJyatCYujYXt2AHApDCZsqd1sH/7XFEw6TIWUlL2vFNMpy1IkmEH?= =?us-ascii?Q?zP0m48MAp/rHIixH2N1IIWt9lpRQ2C2jaBWyUtWfJZr/aTzroI+0LnrJzsm5?= =?us-ascii?Q?FIoBa+HGiTeFgC+vY+UWCDZ3Ui7JM2xfPTEjdBq15HZyRMawrrGl71T5edk1?= =?us-ascii?Q?Tx5MX5pir2CcXZf3IxZsKQGZkgnoErr3oPuH+HZ5JjHjlFlYUR9vHfr7cPrw?= =?us-ascii?Q?lHAx+gpy9OKncIeEHDwjyVcoXMOunvmn0uONrrPOSn70C9qrJ9wOwyZTHnsa?= =?us-ascii?Q?mffEEB0Q3yrEltgo5jpzVkDcbheXOTqwneozx//sZ32yQbrgYoMhQHqGoYtL?= =?us-ascii?Q?fJzfJojJhX3EiCWRejk9mPW4djGWbKz6KHw978KOpLqrL1bGhZLXf18FNMsf?= =?us-ascii?Q?J5MgkLqL/Q=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: DM6PR11MB3530.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 47c6b136-d936-4b07-e1fe-08da482e6ecb X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Jun 2022 02:35:49.0272 (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: Gy1j/f5hce8oLeH+W5ne7/JBx93yCW3lMhWwT07VEqManCOjCpF314D48UV1q5yPKYaZCj7DYPa62FsAKGFeSA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR11MB4211 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: Zhang, Tianfei > Sent: Monday, June 6, 2022 09:53 > 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 >=20 >=20 >=20 > > -----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 > > > > Add multi-function AFU raw device driver to manage various AFU > > (Acceleration 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. > > > > 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 >=20 > I am thinking that just put those afu* c/h files into drivers/raw/ifpga/ = folder > 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 agree > > > > 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.build 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 > > > > drivers =3D [ > > + 'afu_mf', > > 'cnxk_bphy', > > 'cnxk_gpio', > > 'dpaa2_cmdif', > > -- > > 1.8.3.1