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 37B8BA0544; Tue, 7 Jun 2022 04:36:34 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 17FBC4021D; Tue, 7 Jun 2022 04:36:34 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mails.dpdk.org (Postfix) with ESMTP id D05E740156; Tue, 7 Jun 2022 04:36:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654569392; x=1686105392; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=UH2Ozt3h/6nhTzA3U0u+PKF5MP7wyZMOmP60KW8OT1M=; b=kcdwstml/Ev/tT1o28pTyHa5Nbg+TRp0mVF/fxLOFloIWZ6EIWKFsWv8 UalulsSAanBR7HUVk/gq0KL43UC6fHGFKmXsqlzuArqYW0prWPPgKRIon ezX/Lq/z7VhzCaBXdXVU1D6BPLdbfQraPEYEmGagjcUTf+EOa1cqt94y4 KcMhXOIi4MPWaeInsOjD8lO/Lu5uVYaW6EzH9POpE1s0YgTxha/+B2Upa iHByHi24qGWDfolg1qVG8WOL1ewoJFmNZoEvxKMikRGM/g8xcY67UuzfO 4cKFGo/+SlAWOkXy+1D0oSMuomnt34toM4BwgTCJ8TY0uK1gsetzEQKso Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10370"; a="363047170" X-IronPort-AV: E=Sophos;i="5.91,282,1647327600"; d="scan'208";a="363047170" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2022 19:36:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,282,1647327600"; d="scan'208";a="532420968" Received: from orsmsx606.amr.corp.intel.com ([10.22.229.19]) by orsmga003.jf.intel.com with ESMTP; 06 Jun 2022 19:36:29 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX606.amr.corp.intel.com (10.22.229.19) 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:36:29 -0700 Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX610.amr.corp.intel.com (10.22.229.23) 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:36:28 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx612.amr.corp.intel.com (10.22.229.25) 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:36:28 -0700 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.41) by edgegateway.intel.com (134.134.137.100) 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:36:28 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G8LXvA/V2sqez3dggXfDne8gi7w8OWFmoIzS16HXjwz8XkskZdS92ZFs9krcNPYSP+ezXPLsPxGJDsbvjHJX8zvVVUwubmSaKLcUEZk1md0tM4fS7bpQUF9R09e2zacIkWc94IgHFFWeerjnQqww7+AivRZ03G3Jk73QCPVXMicOX8sVTIR5/YxHCG8sZvAtpqH/W86w886IpjgXLuwtkBgFTZrWrmZf3BYDFj0TdhRGVcG+he1CpNoPKecz8gzHS/RU+1ZnIKuugdkP0fp3iGjWL91ucEKG7M6vkdEdJY7G/JkCvcmAon2eQDs31aRcSPy8NOL8dTHfT7GkTacAgA== 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=wQpyNxJN2RUer7Iov2zeOLmYhzFIZwnvMsxchmqY8gM=; b=dY8Oym5OqEqZodVIsG3gxRyDQFMNC3FZqr1Byl5B1RthLy+u5eyPs2CzAKDi5m6hoR016BFUPUKbBxxqQW9xJUM85ZuHDL0VeQWCO9BRMPwhdeim4omh2mm6+9WgMNSFtMstHXiNHheEJEe7xnsKI3fkm4D2efw0mRfcSP2TyBixxk6qm1917HdYx0DXewwWmfuh+29DT+JjDW1soXlWt/MrFwLLkXENg3AOyKvnLwgECGV83OvbquX0RtvVkBXgNfpVrbV6bqS6b8S0LMLCdS6e52YKPhVVQpqxaf3tdJO7A6+hDPIQTnFOQf0wIgRo+grYJsYZONRNdvkzIH+u0Q== 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:36:21 +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:36:21 +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: AQHYcYrSsBplv7poB0mR3pczzalPw61BrTIAgAACDwCAAZxGQA== Date: Tue, 7 Jun 2022 02:36:21 +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: 4d7f57df-b8a9-4d10-fed2-08da482e8219 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: 0/L5dtk+FEFU/0Uy/7ZRkbG729DsWUQtIshlQexlKlmM0+qz/xh9Z3aRxmk08NNfN9NXDwbHpbZuS496252nzZweJDpZllVWntPMeomKmPMRK605DXhhmMC4ASidjk+y5ifWgIkowaACLtqGPkmBpbKweN0taU1ErypPIjiUqOW1GUk/Uc62yQKqL6IZ/vjh2BXkp9eQI7m4BMD9qnrf43GsxDjndtliHNlg6pfP6BFsAIoWcMbc6JBK7tygc3lD9yK02J8IsNT2EGnZy6Gb4Ar87JI+TQuvdFRFbPvDzR6Zb2KX4xawgeToAp9wyTCsiHs05LX6+5iPzhB5wx/gXXVyw+KopaRj58YDEbj7ZRtLv1PKlV/a9YklAuPqGipBfBGBES5VFlbIGbXJ59c7009q5tXdGtD/TJo7VUqeo2PWUF8/ogEAdW73HLgKA6GqGF9r7r1yUDdnkulYXO8ID9toOws9yWydj7pJq3JrjcxcU/hWhzAKuFzj1JcJcQDvAcp5tUI3S2H3w/hi9DzlGpHKxxNTe1TnkSjQFGi5OpNwYFagzZ2ght1Avo4mPKBPk27LUwhkwIK6tGJoIu3yYkObcHsbjpxPiuXmdES7aEplr7GJb/1WThi6NVjDyYui0xJCses1dy18s9s0kMo8g/1TLaX+LT3kg/pzfpLqvdAsvP3HqWXbrYqSPAv3rm05SoQXLYXgGrGD24u6H/S4Sw== 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?VsxgAPIxInVOLte04PtkKDvnoXt5W7uyqhdcAlDi+SSc0MZGlQvrIWh3/N5y?= =?us-ascii?Q?LDun6U2wjt++3v7QPMVva1mxF3/6FzyaEj9Vjc6+qImdFpd1DtM/I/HDl8h1?= =?us-ascii?Q?6wDZ6mPEtc1Ck93NafmxemLOs5qG8UTUI+P7zFKsNjoINlUCJAAfdX3hW+Hp?= =?us-ascii?Q?QREs+yK4K1gqXA6dtOqNvRfF0QQbKL8+7iH/gVybvvVNxJ9UFyb+NC+DhIoW?= =?us-ascii?Q?H5jDXzTdbQuU2CUXQTRK2E+UPM4mx9A5qINKOL2nRfdUUN41DU5Ug5lVDKjq?= =?us-ascii?Q?vIRL+jcG2DnOYT2S8SjYRzK768GonvZcWb4pUI27JGO+MGjIynTPof012YoA?= =?us-ascii?Q?251Q8K07nsX3J0+u28ydkRqRj4ckTcKSPMQsg+HxRrBTqB2tWjL5tdC28acC?= =?us-ascii?Q?Ql8zWkzx5lpB0sO21F1sq/AM6J5kRHkzYPtiPnQSUnSuDzGNoG2w5uhE03kT?= =?us-ascii?Q?wam7/691iCe5LCFgAr6ZvvDDDhZA2rSE3NDfCWv6r5V8o6P2p3zTyP/h3t4f?= =?us-ascii?Q?l/aCGCeKwQZ1orG5bV4dy5qoW4Ti1U/wWwR72PKnEbEyJwnB3JnMsTqwisfd?= =?us-ascii?Q?NtoBVtHuy7fVLyjkrjgSHX2wvDMGEHrRocRNZdiiw7s7l8ozjsxVRPU+mUfN?= =?us-ascii?Q?tYJ6KmsrGxUwlrgVHMxvU3fz586IQKMc4n9BLXXH5U4F0xzx0M22w9IZQPTt?= =?us-ascii?Q?xNc/SHvDOer83L2En5yteCL+NWoKnKhUZTaIPVqztb43h8JTAAy36G3ITt98?= =?us-ascii?Q?R2XxJfpV40WvQz8ZjF2K8QtI0sHWH8mwt7O+2FWyjlHq+GNzIo+xegU/U6ax?= =?us-ascii?Q?oOC9KyyB/YMcs6fdDSdAsBbBNY4Me6aNMZiBWe+MFJ+Lno1Ji5g+vbUEuNJ3?= =?us-ascii?Q?vaMf9lkEEXVRQhcuS8O7C9vG+AOIyh41xebjx+GGLAg/pN3q1h5KNB5o0eJj?= =?us-ascii?Q?nJT+dyBga7/DSGxWX9eV7i2b52EfEQvhV6B819Eoq3UMJRxrW6c8DfycJp9h?= =?us-ascii?Q?8VS2nc3Y3Fv2a7WmSAa2ZgKb+otnRANU3DkRoeDc4zFAvZOJSQkwCiNt68nz?= =?us-ascii?Q?0KNjkD6/n7PWhLAW5MLvPRCoiHaA3qLzYv5L+yXfrD5r7S+quBcivPzITe56?= =?us-ascii?Q?JN7GYjhjG9+YvzeCZE1XFZSkw0Q6MT6hTNzjM/DyXpzwQjqdR6YXJptc7EE4?= =?us-ascii?Q?AsTdnVQ/eeQvIaocIdgPro9/n7c2e4WGN8UBSmPjspmB6N4/Ixf/xT7wYziy?= =?us-ascii?Q?yL6eQ3ZmDMhw1yreWtonsAvvfcazq2NJgIXo1WPXbTn5dqN46/QsK/hp8NFX?= =?us-ascii?Q?ejUPskxCD3+n5NVCJSOlhIlkuVGARgXowGiLDlD/Ws/RleWbI5ArFB0LUeDi?= =?us-ascii?Q?0AWa4sBGd21S4xI+32hMS7cvKQnpKh6YBvec/r/imfTQ0DlYqW3WpV2Ku9td?= =?us-ascii?Q?M9lVvsFEvp/+ggLZzCD5H84c/SDA4eVVvTSGTbGFwZTChAI8F3jukIGg95k3?= =?us-ascii?Q?rv3pSuEo3VxuVl/dBPKYrBVMQ3e5Hq2V2eTRFxfaeusxVKHciuGEXwaXcMlb?= =?us-ascii?Q?f/yXb5AsM2kawY8Xsq1VRY+tJd/lmEtS0bxpyEefuMuV2WebPX41qS13XHjL?= =?us-ascii?Q?T6ewK77OlN5MJ7YPFFi02mi705l3xqxp5De9JWXJo5i+V68sgNfk05559hqi?= =?us-ascii?Q?W2Y1V/ZGAu2MyfnR15Zqbpoav60Ls5/5qLVo8yUQCwZtz2JwrOKX/W1CNQ/c?= =?us-ascii?Q?iQFWdmkzGw=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: 4d7f57df-b8a9-4d10-fed2-08da482e8219 X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Jun 2022 02:36:21.4471 (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: +HBt1FuY6rqkWTxn3lbqB6Hd4uC9SUSJUQNou6+Pcovd3QnEbBvZS4EtV1A1+8jTX9kZ0sqvqWzHQY966d9QQQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR11MB4211 X-OriginatorOrg: intel.com 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 > -----Original Message----- > From: Zhang, Tianfei > Sent: Monday, June 6, 2022 10:00 > To: Zhang, Tianfei ; 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: Zhang, Tianfei > > Sent: Monday, June 6, 2022 9:53 AM > > 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 > > > > > > > > > -----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 > > > > I am thinking that just put those afu* c/h files into > > drivers/raw/ifpga/ folder is better? Because this AFU PMD driver is wor= k on > ifpga. > > And the file name of "afu_mf_rawdev.c" change to "afu_pmd_driver.c"? >=20 > Ohm, the file name of "afu_mf_rawdev.c" change to "afu_pmd_core.c"? > Because this file is the common code of AFU PMD driver, and specific > function are in separate c file, like afu_pmd_n3000.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