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 C9DF1A00C2 for ; Mon, 6 Jun 2022 04:00:27 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BDCE5427EA; Mon, 6 Jun 2022 04:00:27 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id C033840A7F; Mon, 6 Jun 2022 04:00:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654480825; x=1686016825; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=6xKHYv60L3LxxQvQGucA3WXKMUwXw6UnP+Qo4eVj4Is=; b=gFHX2T5led4lNYEWKihel6tPltaAS39HPSA4IDscKwTbN/Ygt94lLEAP kz40bwdmmIzxPZ2RmVMGZFrO+j87LKhyOkfQn1NIAXhsWPOQHi6Nn7Mr1 JaySFhC1t0FAaNSHxxJvWmh+WIjdhcG0UdgsoTwfDmBNkz0uQjsxR862w s2EE8J34A1TeLyD6bAARR8uR5pEDFIECMZwEwtUlFfx/52meQ7RWyERAT bLzK5NpzVaHRNA3e7e5yK3Qg7y1reqllOCW14ahMT7Ub5cwMGMFQhoyEB 0IFVvoNXK0btQCXmKnAfLDqe0KVhhEu4Hd+sdDaVieMZRwZdpWyg4+/9Y g==; X-IronPort-AV: E=McAfee;i="6400,9594,10369"; a="339743595" X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="339743595" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2022 19:00:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="647268588" Received: from orsmsx606.amr.corp.intel.com ([10.22.229.19]) by fmsmga004.fm.intel.com with ESMTP; 05 Jun 2022 19:00:21 -0700 Received: from orsmsx608.amr.corp.intel.com (10.22.229.21) 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; Sun, 5 Jun 2022 19:00:21 -0700 Received: from orsmsx609.amr.corp.intel.com (10.22.229.22) by ORSMSX608.amr.corp.intel.com (10.22.229.21) 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 19:00:20 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx609.amr.corp.intel.com (10.22.229.22) 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 19:00:20 -0700 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.108) 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; Sun, 5 Jun 2022 19:00:20 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eggujWD3/hKlHgvIADnkjdzbjE5MalLU6wZG+kgNfdC+9wgSpLECxDMz1wFk4HCzDNffKuOACu8Qj8KGBG5ndjr2PR0Zqfoy2/mPwgU6p6XehhbAPSQBC7iDdMTLOaR5JTcY7UWuUmuwCEuYUHqdTkCPcxtOIEhn1ps4UsZJtb09LBIyXNW9uTqTufacFWv1pqdTsCspp0+1Wz+FOrV6r2UTN1I1vZSJ+NoVZ3peNzNV71kh5Q2yR7GDPNl/dErHrCt8FBsk/uxaQ+u/3Xcfptm0+5nTBEqBxKnKWHFohw31HE9RUEd1uS6qpFjm25WJz/ErBoF3r5emv8qpnS7qeg== 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=i+ouzOecQxmonR9Ete/eWzzIrBNeBA3SbYKHb+Wsk/g=; b=J5sL1TxBx6IUcLmobGkR8Cnw02Z9bcUJiJtzUGYX59DM/GvuneHEEMY01rAwAHAwqH97ej/JYA3JfusKiEi48cWTnizMBtxpa93DL2XyAIoOP4iVruZ/NUF0w1CjI5xJmCEWoamBlVv35MAJWSkJ51JW/yPv72SLqiHfGvjzZ7xEZbsjl7t4Kh4eP9Nd0+pZKM2MRgM6KejmJgGh0iY0KHPWIXEu7NpS4V9h/DOHJc7FDdrNLXbgEFJUlVFXExrD6SKlTpCuh9sHckqDSqBLINY2afXgGOVOVo6egYJuoswZsT+CcNkj4wQGfHaVB6gf6hYR9t6bDNwwRObiY07Fgw== 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 SA2PR11MB4778.namprd11.prod.outlook.com (2603:10b6:806:119::19) 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 02:00:18 +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 02:00:18 +0000 From: "Zhang, Tianfei" 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 Thread-Topic: [PATCH v5 1/5] drivers/raw: introduce AFU raw device driver Thread-Index: AQHYcYrSOnXAYeB/Y0GM+Z3CM5oUzK1BrD8QgAACcqA= Date: Mon, 6 Jun 2022 02:00:18 +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: 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: 814de13a-e801-4322-5eaa-08da47604e77 x-ms-traffictypediagnostic: SA2PR11MB4778: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: RoU0txtADkkP95y6lohlOJNTp32MiQXZkGGogytakqdAzyXnFPCeLUlT555hG5jui/VjCepQBh1FnGxU3I8DqrOhA9YY3O0AAr7b/QeBY9kJszE48E+lG1Nz9l7FBGq8KZQTQFAKtRBYfS033Xrarpo/5Bm3h4xhEB6hpTGPaeGUDnWqrcoVdJ5ssVCVTDGPHMctCjhfV2vLFWwm8asbWOcZk8pS7o3bmiZ1fxrZLoz3XMJT1Cw1V4kjwtOJbtxCpQoeL6BQcXx+p5kLsNmBRPaYiSbSx7yBfRoU3jF4NkUs1qIqj0HfzVfdkwSsFOdOPKZdt4orq/cLG9s4hkzjrp4Wa0g9gaC49pe1+LmDgmmI154SgiB+UGjqOP8XC0OPmiw6xH4J2KncAhfO4o7KzSQjwCM2Zsya+ljI8BBaQheOkuf1LB0lGVrjvbMWGr9HPNFh2UC/9GhGtJnRaiNJzVqAlpWOjy707IhgszOGkSfRu60eOUZl2Ei1B2KTFLEZYQrzr2QeGnsqmtpNLHylbcv9BcS+aZm/7a5EQQepF61AWsDvoGNkZNjNzcHplIP2kuZooPUGWy9fLyUwLalDYrXWeNbBrzutb/3P0NYA5ELym78bHx0RJutNmj4EqiXQLELDEiTLTgqdn8PYKb5TFRhn1KWwfiWAeJ4yzeSA8pguoGPpvepqOD+R/xwPgMkKyeA/lij4Q9a87Mt/WPqS3g== 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)(54906003)(76116006)(2940100002)(82960400001)(30864003)(64756008)(66446008)(66946007)(66476007)(110136005)(71200400001)(107886003)(316002)(66556008)(5660300002)(38070700005)(26005)(122000001)(9686003)(55016003)(8676002)(8936002)(2906002)(4326008)(52536014)(6506007)(83380400001)(7696005)(53546011)(33656002)(508600001)(186003)(86362001)(38100700002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?b9YY8VdY0T0FAaBGqehZvr7JDUICwQof8WnicBm9raSPAEcuFcb1yE5c6Hr0?= =?us-ascii?Q?/coozbcGbXv140vlDC8SWk2bz53CRXc/aBZozUCzzen1UO6v53biHRWT0JvS?= =?us-ascii?Q?3yGd0Frpj/+sE1A4DczBLEVtPyXVuzxP2760JRjje/91wqo14aOwv3btjfG9?= =?us-ascii?Q?FPuyU7DcxvLWLGp/DLySH0MyNWOifE/SZAsnOaUBUPdP1yabhe11Go4SWbYS?= =?us-ascii?Q?Exnu1ONMtuQzCP6Ssxrkz/BHIWG7UQ5zGaE8O2K8Uk30J/3+pdO0hOcoAHrf?= =?us-ascii?Q?Cedr4OqjiBV6ox9l7Xtobz2Ja6/KxwafzCu7Tqq0kBMZuT5iW+PrCwtKyNge?= =?us-ascii?Q?P7c2j2GkqVui9rnMrD1uD2GAEfz0iFMV6mL39cYt/kFohWeJSyP40+ZHphwB?= =?us-ascii?Q?QkeJ4kdS2GZ760x+aaoS7+XSHA9BctCAApVzchjXsrUwvWwsVs4Tur838sJm?= =?us-ascii?Q?LTXZaox9RY0scIwUM+I9FP4z+JmVtgfwg2eMfDuk/d7bIkk/gyRgXkcCZwqR?= =?us-ascii?Q?doAleVV0bUTWnNMl6AQIsFDwoy3Q+bSS+y1o9lCrtMPB8Rd+vvRcShz4Pkvn?= =?us-ascii?Q?tdmrlSaZM/lj1IL3ja0dD5bDmA6P2wvwwV9gx4QegIqLFv8hPNvuEy3E9P3a?= =?us-ascii?Q?L7YR8bXrkeT5lUeYanIOe/X5wrkpATyhy3IHle8ZDidsOnAgRImyifBqfqSP?= =?us-ascii?Q?9DHgw7HleendHoORbPcMKwp9tCKIfCHdZc1AAQJjYxZf15h/xNDWmlcIiQ/2?= =?us-ascii?Q?c5wIxCurZQt+iVTOCFPS7R6rQuXMMr2IPPVcPQKG4X+MQm9kVtYgZvd5Ip0t?= =?us-ascii?Q?A3vpxge4pQzBpG4vvD7SHUsw9fcPog5/YtmvjfFkTaW8B9Gcyj2oCdIv0XzL?= =?us-ascii?Q?tIcW7bGLcdn3LofrE4b91l4tmb01YZc/xjStcvCWz9tGPrrC3i2atrtt8EhC?= =?us-ascii?Q?ivjI8G6+fPMvZ4u4JQj9rRmlUwifn+Ie/8S36sKMGxxWcTq5bywShx0RYYeT?= =?us-ascii?Q?OcBXCrZKzI2YuzB7dQZhobq1HE6letE3E9t+/8jcz6rsebHiVWf5h7GPlFmI?= =?us-ascii?Q?c+Wk6Ln/X7KbPx2/Wkm6nBptpO5u5sObNVgWd7J/Ajebwsz/zIdPU8HTRbHZ?= =?us-ascii?Q?A6pk87klUAKk9HIS1G9dPOOxHQ5pcpLK/jQNjX5ftpyenpy2LXBJKjdlsp0W?= =?us-ascii?Q?MU/ab0xYxr12eNwHruQw/n7bK4Nn0Bf0Aplt/N9Nln+yiwJM/A7mCC4C9Dwf?= =?us-ascii?Q?3U/hao4H1qH6n92ZZvX0wbaxYV7iK2W8jwn1rC9Ph+nhHDcHOC33Iou0TWRM?= =?us-ascii?Q?K3Cdo7ZJR5fSeq4RjYLrdALxe4HdjwfWVxHpz2dn6uD0gNDGOsVjCuqUUoG5?= =?us-ascii?Q?YJSoLdDg7+ljnwnmas9Kh3Ug/p25SWYBiZIqzLbHNGOfLemGB+gsilvv7E8y?= =?us-ascii?Q?RJ4+oWMpRkekIGZ6+JWkh5lPCw0TYjcC1AfWsPk0yAVCvhyK6E9NY4/ghrh9?= =?us-ascii?Q?XDs6zpILq+q15KzmmgAHSF19P16ZEarZH5EQHplYF5zqNLCKl13Aqwo1F4it?= =?us-ascii?Q?Z0KT3xt0N+Kz5c7mKbLoW65/MSXpIczK/ea/OaAujpJHx53RFGGyLftb0g00?= =?us-ascii?Q?tD9tnp+1BBKjlVw5Hno9arEPJTYKDhAQrdORE/IDgw6Z84w34mgccnA8V3VH?= =?us-ascii?Q?uLCiQBKssVngiUKg/wEtSNs/2wpy5Gi94dfY0A6qhrxo8cWA7I6J9N2GKXq0?= =?us-ascii?Q?jbeG0eKyJw=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: 814de13a-e801-4322-5eaa-08da47604e77 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Jun 2022 02:00:18.5068 (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: 01lex5vK0B8yw0tIYVMqhQ2p/+V5a0FdZ3RaXkwFBokUbfyKna1DauPi7QB8aPhjb3Grsu65Ccs67o18+L8xfg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR11MB4778 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 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 >=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"? 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 functi= on are in separate c file, like afu_pmd_n3000.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.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