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 EC4D2A00C2 for ; Mon, 6 Jun 2022 03:41:31 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DEF6A41611; Mon, 6 Jun 2022 03:41:31 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mails.dpdk.org (Postfix) with ESMTP id 2AD1940A7F; Mon, 6 Jun 2022 03:41:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654479689; x=1686015689; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=MkEOgF7BoMeCWZf7FymXe0JdaxYscVflUfUvCQ/zpV0=; b=cULRGX4JlTHQ0MFJlno7itC/wrfcz4HH2ajLYzo/qyKSN/rDOuBQ83T+ xhu9qdg8a+eNsDUErRnQ1ueeF7iQwfDehwLrs1i+hcNgaudrjoGGxc443 6qw7/gieOAkwwLwYruVxUjKbxD0DlucyrndNEZo7oMcRnAv63eih5PRYW QRpT8AjbBG7mfEVJBnJXNQSs2fUZDUxSMYx+uEcxNiKSmv5O7fQDJm2UX exSHIXjxX2TT8R5zyd32FcrpDLiVZNtowuE5bkhKKhNHHzBFI6GQx+k6d mEWpQc35OFt4rmKEPUWpfMClzq/5hSdTVcXXCQGBfE03vjaUebadRtsAe Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10369"; a="276650207" X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="276650207" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2022 18:41:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="708864816" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by orsmga004.jf.intel.com with ESMTP; 05 Jun 2022 18:41:06 -0700 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX602.amr.corp.intel.com (10.22.229.15) 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:41:06 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx601.amr.corp.intel.com (10.22.229.14) 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:41:06 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.170) by edgegateway.intel.com (134.134.137.103) 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:41:06 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ogvuYEj9LzRXMVKIvj6IUhx5Ebj8SpD+qrN78BLfZJl7yavjgGGiKsuVitxms35V/Ci7FFLBBxwElgb5P8kKgzMiSoneoKxcWjmOrnCWjPxeIPTOAtZhjdHIGhjWa8dnEx+VA55gkEnO0RPfnq8zxHpvKzI4/czHMZSz+id/km+SxwFCKvOttgi7BZ2asXOhPBk7uocpXiGpnSyuZJK8Mf5ZyIF53WaojCdElIBxYT1UoF2R5KISCo58jNozI2ZHeErcNwoBYHMpf8mFNIOfcgM0aOIDqAMJ+IKGAARB7APogNW25sg/1aiZiXwSqMU+ohLAVxJsozxl1GT+/GzagQ== 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=3+BwoULJCm/dTqrEQBy+4exGuoOW2qXmmoUAhalj8GY=; b=dAPbTCpx+NkIk42rS4DO581CLftRWW3si2cKsXAQ+1Vbfh3t49HkhaRtjMQYlPray0gTFtrw4AMlp5xRpKnYx9a4a8I0agLUpRR8bSaybIIoIegFXOJCcW3HIvEceqXDDeUhuVuXfL/XBwpeV5lZeiFNmmhvhBA0OxwFnm02vvbm2OPH7x+t4lk5VGYldxvw+y73Rq5piHB9h0xmjIBWIkwsrMWw8xDqndWnlDrmFGu+rNA+H6ui25jlchN4UFiknHiPTJDK5rrYsnNS57bNxQNgDe+1D6g3ki+FOPkRP6kupHskeh3b39FZ5/HDB71zO+f6azEzp5DqeRJ8v7WWVw== 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 MN2PR11MB4647.namprd11.prod.outlook.com (2603:10b6:208:262::10) 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:41:04 +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:41:04 +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 3/5] raw/afu_mf: add HE-LBK AFU driver Thread-Topic: [PATCH v5 3/5] raw/afu_mf: add HE-LBK AFU driver Thread-Index: AQHYcYrdgZUVjtSqfU2Z7OlFIeJmq61BqYew Date: Mon, 6 Jun 2022 01:41:04 +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-4-git-send-email-wei.huang@intel.com> In-Reply-To: <1653629824-4535-4-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: ff2cd4b8-4744-4cb2-ec3f-08da475d9e7a x-ms-traffictypediagnostic: MN2PR11MB4647: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: d99p1F/RESuL+COBAskO/aa/8+fRRIF1VHatAiY3a2dD93CE/n+cdfiTYb5ITNatLzYd6dn8cJXWr/LeA90lIuoi57gJhMLc8lkHEjWOtiGpl8q0M65wLoXpoxS9XuWnT6SIGZj5dSdjaJshx8jjngyUP9JSymlEHxoBMzGcXKnPUGRsFBeeWS/N1Iiy2nxrKv2SoTL5v9vP43qT10NVALhfVs1iGvcLeCJJRzUgus09LkL8ZroAbgbChZeM2jm6qLcpojbaIlvhnzt3c7pw7vIQnvDnfQ1N+kLsZIDJQWWT0bWimhbxKNQetAamtgswctaSZNBVaymwss7GM8GQfTO/yqyHDfsVe+fYxr02IZ10B0YmN+pEdTbKy/acXdaQ46wmxYjGVA6KZ7sm6WFZs+8D9/ZWu//DRQzackj8zDGqDoFon9bNKK4L+ywO6G1m3meE+TUZaQfUbiT7muKKSFFgbBOaHilbinS63P/8JLMlVUqBBDtIZvxPbCTp12JlP/IV/X5BpH/2HldAtbc6ZAAXwJMScaaYx+x7amem57bstN/sXmp6zMUQkpVcBl6JdSazNQiDeGWpeBDozhv2rdS8uJcZ7/2Jngg0PM/gIWGIkURPPDMthjX7Wa048O86VQciKSNQ/7gkK5ng++cPSzXjxXjYfVf2TtNy1xP11aktvshHZ9I+Vu349vMHnK1ga2+1ybRR5H6hsNCmXHKS8g== 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)(71200400001)(316002)(54906003)(38070700005)(186003)(5660300002)(33656002)(52536014)(82960400001)(2906002)(30864003)(76116006)(66556008)(66446008)(66476007)(66946007)(64756008)(38100700002)(110136005)(8676002)(4326008)(8936002)(508600001)(122000001)(26005)(9686003)(83380400001)(107886003)(55016003)(7696005)(6506007)(53546011)(86362001)(579004); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?o+scX+svxIzq0JGWvUpWq6B969XqgfvLyetolEhbwDGCEgZEiWiokqcRNP4Y?= =?us-ascii?Q?44R6L0hhIUMrZopZzQf6foFfakPddEWDpIHJERwt8fvIv9YBIoKpxQTfvFSH?= =?us-ascii?Q?djFi0OjEP5+Y/3qstxdNsvbsJSLtasBDGRRXDeCNomioNhY3je59HqZly5cZ?= =?us-ascii?Q?kFl42U5QydwaG8j+mU3aySywPQtaXb+aRAO0A6LsSE7JzU3HU1AFBB7nMB+0?= =?us-ascii?Q?N1Uk+DMId6CeNDhFhUBuOlI1ctaq/QONZ2CRRi+Uwa6F1O++HUII9Vc855Kv?= =?us-ascii?Q?33UQeSENqX8JuF+a/fW9Kr6d+p73YhjLNa+1Mm7QA4TGfx727rYTI4k/VHQm?= =?us-ascii?Q?zEE5YEbXmhnh0w5pal5IbNI8T0PQd+odNmFQ1UHdywsbTGkczPHxQk9sazKO?= =?us-ascii?Q?17LIUlivmWMeN7THVs091nhuAt64Rnjc03fR/Yb1psTM/GTtA2m+DVVqY4LU?= =?us-ascii?Q?wWKgMdx/tpoP/D5ybCCkV7vRk40o++Q/4wLnh77jopq/xLwHc9ZP3PEQDnmh?= =?us-ascii?Q?31Av1Fn8CYqX1BFipu2FfLoDT84hikUwSN6DIfR5wAMCID1c1mK8mJUhVhQH?= =?us-ascii?Q?XwrHmbwF3qwtSf3hb4cL+ClKdj6X9JW9bGGYtUm10jCzB6l6coPd3/c5Erld?= =?us-ascii?Q?ZSznGfeUonA1P851M3g1gZEzoT09oECe0GYtxuWNdC0UC2pkUB681tuFMmSe?= =?us-ascii?Q?lZgzTDhULhBFuoMz3qiq/w8a82EDmVHaaJZawlA8ATtaLr5FewLPw2egOi9/?= =?us-ascii?Q?crX0vDXHhNG0TfdqZ0fGkGkCp+z058EkHQO6LotJTP9oVbaovhkKuCMrr0hK?= =?us-ascii?Q?lvs24eHMNBXwg18r2zHzYnPXm+mnb3i+SVJ4jj62EBhXG8vQfJ9r16wUubvi?= =?us-ascii?Q?GqEPitDHdafwaFYXfe2ZOT3G2HWhIwVtoudk87jze6LonmkNEFB5NPK7/CiA?= =?us-ascii?Q?A0Q9XLk4fZkYyMkNTdOpyTRMO6LDd+9KOY1iARACMMHzFfD1UHSKfqZkAWel?= =?us-ascii?Q?HGcavjsrkswjXi+BSD6Umv51wSUf/OAmGP/KOoM4U4mVq/RlJDHtdKZnmB6U?= =?us-ascii?Q?L1eHDBtDkmFRnewQ7c1KRKEzo70nzK1nC/+V3VMB0NxnAr9gwJk8MsoAec32?= =?us-ascii?Q?LN6+gJreb8U7E5pdX3Hi2pVUpG92xywyorxJcF0EQWAb6xld1owq5nYUFkVm?= =?us-ascii?Q?62o2vry/teL6ztaMnwoUIpA67vS9nyXl2ZKbpq1AiqzB1PU+1fV9dQ5Ocj3Z?= =?us-ascii?Q?afM11XirOzd6oOd0jqy1LD6l64nXR0ki+2DAHH1GNQIYeExNmvTQuvb4njA5?= =?us-ascii?Q?jRymHcG4VyIY2rVwjFfFossNis6PSZjywl2SFeILxgXbEfSj2g5rvDNs/unF?= =?us-ascii?Q?svIDbzYixWkFGpD4W4uppZxuC5t8kYWg3W89AunkVKO2hPqNTcG7kBTHjXpq?= =?us-ascii?Q?s901S3rInkBf2VFMetZ1AR6SW+hFkJbz29rn5YsYBljWZOJkGQsMNyk3XA0e?= =?us-ascii?Q?53E4fHwBjKo1vSrYfXnqNlowBIPBSDBCnT0KMVMq+CqKrTJavp6csvjtH1Qr?= =?us-ascii?Q?RsNoDvWNql57Mhrdo+CcWBShX9yewQqPKA5RVcB+FvPesnGFSbTWdEzZHVis?= =?us-ascii?Q?cjHM3SdcVOthfiGwhKZHa1pbJTWrsNkg0WTzMnFSr2y74NhAW7QoGw723vaZ?= =?us-ascii?Q?HP8RUjkqJ/qS9UZsNErAt1eterALcOir41ISi0l4qN5xILtWNfDPSeoEWrWG?= =?us-ascii?Q?whxOwJstUA=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: ff2cd4b8-4744-4cb2-ec3f-08da475d9e7a X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Jun 2022 01:41:04.2264 (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: aPoCBHdQLx45cKdHgbg2Pggryq0FojxNpl++0hQ9pY50LsLwQHTOik1iuP1zaHCt9AFLcOmAgrF4+7t0vyw5dw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4647 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 3/5] raw/afu_mf: add HE-LBK AFU driver >=20 > HE-LBK and HE-MEM-LBK are host exerciser modules in OFS FPGA, HE-LBK is > used to test PCI bus and HE-MEM-LBK is used to test local memory. > This driver initialize the modules and report test result. >=20 > Signed-off-by: Wei Huang > --- > drivers/raw/afu_mf/afu_mf_rawdev.c | 5 + > drivers/raw/afu_mf/he_lbk.c | 427 > +++++++++++++++++++++++++++++++++++++ > drivers/raw/afu_mf/he_lbk.h | 121 +++++++++++ > drivers/raw/afu_mf/meson.build | 2 +- > drivers/raw/afu_mf/rte_pmd_afu.h | 14 ++ > 5 files changed, 568 insertions(+), 1 deletion(-) create mode 100644 > drivers/raw/afu_mf/he_lbk.c create mode 100644 drivers/raw/afu_mf/he_lbk= .h >=20 > diff --git a/drivers/raw/afu_mf/afu_mf_rawdev.c > b/drivers/raw/afu_mf/afu_mf_rawdev.c > index 7c18f3b..e91eb21 100644 > --- a/drivers/raw/afu_mf/afu_mf_rawdev.c > +++ b/drivers/raw/afu_mf/afu_mf_rawdev.c > @@ -20,16 +20,21 @@ > #include "rte_pmd_afu.h" > #include "afu_mf_rawdev.h" > #include "n3000_afu.h" > +#include "he_lbk.h" >=20 > #define AFU_MF_PMD_RAWDEV_NAME rawdev_afu_mf >=20 > static const struct rte_afu_uuid afu_uuid_map[] =3D { > { N3000_AFU_UUID_L, N3000_AFU_UUID_H }, > + { HE_LBK_UUID_L, HE_LBK_UUID_H }, > + { HE_MEM_LBK_UUID_L, HE_MEM_LBK_UUID_H }, > { 0, 0 /* sentinel */ } > }; >=20 > static struct afu_mf_drv *afu_table[] =3D { > &n3000_afu_drv, > + &he_lbk_drv, > + &he_mem_lbk_drv, > NULL > }; >=20 > diff --git a/drivers/raw/afu_mf/he_lbk.c b/drivers/raw/afu_mf/he_lbk.c ne= w file > mode 100644 index 0000000..8735647 > --- /dev/null > +++ b/drivers/raw/afu_mf/he_lbk.c > @@ -0,0 +1,427 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2022 Intel Corporation > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include "afu_mf_rawdev.h" > +#include "he_lbk.h" > + > +static int he_lbk_afu_config(struct afu_mf_rawdev *dev) { > + struct he_lbk_priv *priv =3D NULL; > + struct rte_pmd_afu_he_lbk_cfg *cfg =3D NULL; > + struct he_lbk_csr_cfg v; > + > + if (!dev) > + return -EINVAL; > + > + priv =3D (struct he_lbk_priv *)dev->priv; > + if (!priv) > + return -ENOENT; > + > + cfg =3D &priv->he_lbk_cfg; > + > + v.csr =3D 0; > + > + if (cfg->cont) > + v.cont =3D 1; > + > + v.mode =3D cfg->mode; > + v.trput_interleave =3D cfg->trput_interleave; > + if (cfg->multi_cl =3D=3D 4) > + v.multicl_len =3D 2; > + else > + v.multicl_len =3D cfg->multi_cl - 1; > + > + AFU_MF_PMD_DEBUG("cfg: 0x%08x", v.csr); > + rte_write32(v.csr, priv->he_lbk_ctx.addr + CSR_CFG); > + > + return 0; > +} > + > +static void he_lbk_report(struct afu_mf_rawdev *dev, uint32_t cl) { > + struct he_lbk_priv *priv =3D NULL; > + struct rte_pmd_afu_he_lbk_cfg *cfg =3D NULL; > + struct he_lbk_ctx *ctx =3D NULL; > + struct he_lbk_dsm_status *stat =3D NULL; > + struct he_lbk_status0 stat0; > + struct he_lbk_status1 stat1; > + uint64_t swtest_msg =3D 0; > + uint64_t ticks =3D 0; > + uint64_t info =3D 0; > + double num, rd_bw, wr_bw; > + > + if (!dev || !dev->priv) > + return; > + > + priv =3D (struct he_lbk_priv *)dev->priv; > + cfg =3D &priv->he_lbk_cfg; > + ctx =3D &priv->he_lbk_ctx; > + > + stat =3D ctx->status_ptr; > + > + swtest_msg =3D rte_read64(ctx->addr + CSR_SWTEST_MSG); > + stat0.csr =3D rte_read64(ctx->addr + CSR_STATUS0); > + stat1.csr =3D rte_read64(ctx->addr + CSR_STATUS1); > + > + if (cfg->cont) > + ticks =3D stat->num_clocks - stat->start_overhead; > + else > + ticks =3D stat->num_clocks - > + (stat->start_overhead + stat->end_overhead); > + > + if (cfg->freq_mhz =3D=3D 0) { > + info =3D rte_read64(ctx->addr + CSR_HE_INFO0); > + AFU_MF_PMD_INFO("API version: %"PRIx64, info >> 16); > + cfg->freq_mhz =3D info & 0xffff; > + if (cfg->freq_mhz =3D=3D 0) { > + AFU_MF_PMD_INFO("Frequency of AFU clock is > unknown." > + " Assuming 350 MHz."); > + cfg->freq_mhz =3D 350; > + } > + } > + > + num =3D (double)stat0.num_reads; > + rd_bw =3D (num * CLS_TO_SIZE(1) * MHZ(cfg->freq_mhz)) / ticks; > + num =3D (double)stat0.num_writes; > + wr_bw =3D (num * CLS_TO_SIZE(1) * MHZ(cfg->freq_mhz)) / ticks; > + > + printf("Cachelines Read_Count Write_Count Pend_Read Pend_Write " > + "Clocks@%uMHz Rd_Bandwidth Wr_Bandwidth\n", > + cfg->freq_mhz); > + printf("%10u %10u %10u %10u %10u %12"PRIu64 > + " %7.3f GB/s %7.3f GB/s\n", > + cl, stat0.num_reads, stat0.num_writes, > + stat1.num_pend_reads, stat1.num_pend_writes, > + ticks, rd_bw / 1e9, wr_bw / 1e9); > + printf("Test Message: 0x%"PRIx64"\n", swtest_msg); } > + > +static int he_lbk_test(struct afu_mf_rawdev *dev) { > + struct he_lbk_priv *priv =3D NULL; > + struct rte_pmd_afu_he_lbk_cfg *cfg =3D NULL; > + struct he_lbk_ctx *ctx =3D NULL; > + struct he_lbk_csr_ctl ctl; > + uint32_t *ptr =3D NULL; > + uint32_t i, j, cl, val =3D 0; > + uint64_t sval =3D 0; > + int ret =3D 0; > + > + if (!dev) > + return -EINVAL; > + > + priv =3D (struct he_lbk_priv *)dev->priv; > + if (!priv) > + return -ENOENT; > + > + cfg =3D &priv->he_lbk_cfg; > + ctx =3D &priv->he_lbk_ctx; > + > + ctl.csr =3D 0; > + rte_write32(ctl.csr, ctx->addr + CSR_CTL); > + rte_delay_us(1000); > + ctl.reset =3D 1; > + rte_write32(ctl.csr, ctx->addr + CSR_CTL); > + > + /* initialize DMA addresses */ > + AFU_MF_PMD_DEBUG("src_addr: 0x%"PRIx64, ctx->src_iova); > + rte_write64(SIZE_TO_CLS(ctx->src_iova), ctx->addr + CSR_SRC_ADDR); > + > + AFU_MF_PMD_DEBUG("dst_addr: 0x%"PRIx64, ctx->dest_iova); > + rte_write64(SIZE_TO_CLS(ctx->dest_iova), ctx->addr + CSR_DST_ADDR); > + > + AFU_MF_PMD_DEBUG("dsm_addr: 0x%"PRIx64, ctx->dsm_iova); > + rte_write32(SIZE_TO_CLS(ctx->dsm_iova), ctx->addr + > CSR_AFU_DSM_BASEL); > + rte_write32(SIZE_TO_CLS(ctx->dsm_iova) >> 32, > + ctx->addr + CSR_AFU_DSM_BASEH); > + > + ret =3D he_lbk_afu_config(dev); > + if (ret) > + return ret; > + > + /* initialize src data */ > + ptr =3D (uint32_t *)ctx->src_ptr; > + j =3D CLS_TO_SIZE(cfg->end) >> 2; > + for (i =3D 0; i < j; i++) > + *ptr++ =3D i; > + > + /* start test */ > + for (cl =3D cfg->begin; cl <=3D cfg->end; cl +=3D cfg->multi_cl) { > + memset(ctx->dest_ptr, 0, CLS_TO_SIZE(cl)); > + memset(ctx->dsm_ptr, 0, DSM_SIZE); > + > + ctl.csr =3D 0; > + rte_write32(ctl.csr, ctx->addr + CSR_CTL); > + rte_delay_us(1000); > + ctl.reset =3D 1; > + rte_write32(ctl.csr, ctx->addr + CSR_CTL); > + > + rte_write32(cl - 1, ctx->addr + CSR_NUM_LINES); > + > + ctl.start =3D 1; > + rte_write32(ctl.csr, ctx->addr + CSR_CTL); > + > + if (cfg->cont) { > + rte_delay_ms(cfg->timeout * 1000); > + ctl.force_completion =3D 1; > + rte_write32(ctl.csr, ctx->addr + CSR_CTL); > + ret =3D dsm_poll_timeout(&ctx->status_ptr- > >test_complete, > + val, (val & 0x1) =3D=3D 1, DSM_POLL_INTERVAL, > + DSM_TIMEOUT); > + if (ret) { > + printf("DSM poll timeout\n"); > + goto end; > + } > + } else { > + ret =3D dsm_poll_timeout(&ctx->status_ptr- > >test_complete, > + val, (val & 0x1) =3D=3D 1, DSM_POLL_INTERVAL, > + DSM_TIMEOUT); > + if (ret) { > + printf("DSM poll timeout\n"); > + goto end; > + } > + ctl.force_completion =3D 1; > + rte_write32(ctl.csr, ctx->addr + CSR_CTL); > + } > + > + he_lbk_report(dev, cl); > + > + i =3D 0; > + while (i++ < 100) { > + sval =3D rte_read64(ctx->addr + CSR_STATUS1); > + if (sval =3D=3D 0) > + break; > + rte_delay_us(1000); > + } > + > + if (cfg->mode =3D=3D NLB_MODE_LPBK) { > + ptr =3D (uint32_t *)ctx->dest_ptr; > + j =3D CLS_TO_SIZE(cl) >> 2; > + for (i =3D 0; i < j; i++) { > + if (*ptr++ !=3D i) { > + AFU_MF_PMD_ERR("Data mismatch @ > %u", i); > + break; > + } > + } > + } > + } > + > +end: > + return 0; > +} > + > +static int he_lbk_ctx_release(struct afu_mf_rawdev *dev) { > + struct he_lbk_priv *priv =3D NULL; > + struct he_lbk_ctx *ctx =3D NULL; > + > + if (!dev) > + return -EINVAL; > + > + priv =3D (struct he_lbk_priv *)dev->priv; > + if (!priv) > + return -ENOENT; > + > + ctx =3D &priv->he_lbk_ctx; > + > + rte_free(ctx->dsm_ptr); > + ctx->dsm_ptr =3D NULL; > + ctx->status_ptr =3D NULL; > + > + rte_free(ctx->src_ptr); > + ctx->src_ptr =3D NULL; > + > + rte_free(ctx->dest_ptr); > + ctx->dest_ptr =3D NULL; > + > + return 0; > +} > + > +static int he_lbk_ctx_init(struct afu_mf_rawdev *dev) { > + struct he_lbk_priv *priv =3D NULL; > + struct he_lbk_ctx *ctx =3D NULL; > + int ret =3D 0; > + > + if (!dev) > + return -EINVAL; > + > + priv =3D (struct he_lbk_priv *)dev->priv; > + if (!priv) > + return -ENOENT; > + > + ctx =3D &priv->he_lbk_ctx; > + ctx->addr =3D (uint8_t *)dev->addr; > + > + ctx->dsm_ptr =3D (uint8_t *)rte_zmalloc(NULL, DSM_SIZE, > TEST_MEM_ALIGN); > + if (!ctx->dsm_ptr) { > + ret =3D -ENOMEM; > + goto release; > + } > + ctx->dsm_iova =3D rte_malloc_virt2iova(ctx->dsm_ptr); > + if (ctx->dsm_iova =3D=3D RTE_BAD_IOVA) { > + ret =3D -ENOMEM; > + goto release; > + } > + > + ctx->src_ptr =3D (uint8_t *)rte_zmalloc(NULL, NLB_BUF_SIZE, > + TEST_MEM_ALIGN); > + if (!ctx->src_ptr) { > + ret =3D -ENOMEM; > + goto release; If ctx->src_ptr alloc fail, he_lbk_ctx_release() can work? > + } > + ctx->src_iova =3D rte_malloc_virt2iova(ctx->src_ptr); > + if (ctx->src_iova =3D=3D RTE_BAD_IOVA) { > + ret =3D -ENOMEM; > + goto release; > + } > + > + ctx->dest_ptr =3D (uint8_t *)rte_zmalloc(NULL, NLB_BUF_SIZE, > + TEST_MEM_ALIGN); > + if (!ctx->dest_ptr) { > + ret =3D -ENOMEM; > + goto release; > + } > + ctx->dest_iova =3D rte_malloc_virt2iova(ctx->dest_ptr); > + if (ctx->dest_iova =3D=3D RTE_BAD_IOVA) { > + ret =3D -ENOMEM; > + goto release; > + } > + > + ctx->status_ptr =3D (struct he_lbk_dsm_status *)ctx->dsm_ptr; > + return 0; > + > +release: > + he_lbk_ctx_release(dev); > + return ret; > +} > + > +static int he_lbk_init(struct afu_mf_rawdev *dev) { > + if (!dev) > + return -EINVAL; > + > + if (!dev->priv) { > + dev->priv =3D rte_zmalloc(NULL, sizeof(struct he_lbk_priv), 0); > + if (!dev->priv) > + return -ENOMEM; > + } > + > + return he_lbk_ctx_init(dev); > +} > + > +static int he_lbk_config(struct afu_mf_rawdev *dev, void *config, > + size_t config_size) > +{ > + struct he_lbk_priv *priv =3D NULL; > + struct rte_pmd_afu_he_lbk_cfg *cfg =3D NULL; > + > + if (!dev || !config || !config_size) > + return -EINVAL; > + > + priv =3D (struct he_lbk_priv *)dev->priv; > + if (!priv) > + return -ENOENT; > + > + if (config_size !=3D sizeof(struct rte_pmd_afu_he_lbk_cfg)) > + return -EINVAL; > + > + cfg =3D (struct rte_pmd_afu_he_lbk_cfg *)config; > + if (cfg->mode > NLB_MODE_TRPUT) > + return -EINVAL; > + if ((cfg->multi_cl !=3D 1) && (cfg->multi_cl !=3D 2) && > + (cfg->multi_cl !=3D 4)) > + return -EINVAL; > + if ((cfg->begin < MIN_CACHE_LINES) || (cfg->begin > > MAX_CACHE_LINES)) > + return -EINVAL; > + if ((cfg->end < cfg->begin) || (cfg->end > MAX_CACHE_LINES)) > + return -EINVAL; > + > + rte_memcpy(&priv->he_lbk_cfg, cfg, sizeof(priv->he_lbk_cfg)); > + > + return 0; > +} > + > +static int he_lbk_close(struct afu_mf_rawdev *dev) { > + if (!dev) > + return -EINVAL; > + > + he_lbk_ctx_release(dev); > + > + rte_free(dev->priv); > + dev->priv =3D NULL; > + > + return 0; > +} > + > +static int he_lbk_dump(struct afu_mf_rawdev *dev, FILE *f) { > + struct he_lbk_priv *priv =3D NULL; > + struct he_lbk_ctx *ctx =3D NULL; > + > + if (!dev) > + return -EINVAL; > + > + priv =3D (struct he_lbk_priv *)dev->priv; > + if (!priv) > + return -ENOENT; > + > + if (!f) > + f =3D stdout; > + > + ctx =3D &priv->he_lbk_ctx; > + > + fprintf(f, "addr:\t\t%p\n", (void *)ctx->addr); > + fprintf(f, "dsm_ptr:\t%p\n", (void *)ctx->dsm_ptr); > + fprintf(f, "dsm_iova:\t0x%"PRIx64"\n", ctx->dsm_iova); > + fprintf(f, "src_ptr:\t%p\n", (void *)ctx->src_ptr); > + fprintf(f, "src_iova:\t0x%"PRIx64"\n", ctx->src_iova); > + fprintf(f, "dest_ptr:\t%p\n", (void *)ctx->dest_ptr); > + fprintf(f, "dest_iova:\t0x%"PRIx64"\n", ctx->dest_iova); > + fprintf(f, "status_ptr:\t%p\n", (void *)ctx->status_ptr); > + > + return 0; > +} > + > +static struct afu_mf_ops he_lbk_ops =3D { > + .init =3D he_lbk_init, > + .config =3D he_lbk_config, > + .start =3D NULL, > + .stop =3D NULL, > + .test =3D he_lbk_test, > + .close =3D he_lbk_close, > + .dump =3D he_lbk_dump, > + .reset =3D NULL > +}; > + > +struct afu_mf_drv he_lbk_drv =3D { > + .uuid =3D { HE_LBK_UUID_L, HE_LBK_UUID_H }, > + .ops =3D &he_lbk_ops > +}; > + > +struct afu_mf_drv he_mem_lbk_drv =3D { > + .uuid =3D { HE_MEM_LBK_UUID_L, HE_MEM_LBK_UUID_H }, > + .ops =3D &he_lbk_ops > +}; > diff --git a/drivers/raw/afu_mf/he_lbk.h b/drivers/raw/afu_mf/he_lbk.h ne= w file > mode 100644 index 0000000..c2e8a29 > --- /dev/null > +++ b/drivers/raw/afu_mf/he_lbk.h > @@ -0,0 +1,121 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2022 Intel Corporation > + */ > + > +#ifndef _HE_LBK_H_ > +#define _HE_LBK_H_ > + > +#include "afu_mf_rawdev.h" > +#include "rte_pmd_afu.h" > + > +#define HE_LBK_UUID_L 0xb94b12284c31e02b > +#define HE_LBK_UUID_H 0x56e203e9864f49a7 > +#define HE_MEM_LBK_UUID_L 0xbb652a578330a8eb #define > HE_MEM_LBK_UUID_H > +0x8568ab4e6ba54616 > + > +extern struct afu_mf_drv he_lbk_drv; > +extern struct afu_mf_drv he_mem_lbk_drv; > + > +/* HE-LBK & HE-MEM-LBK registers definition */ > +#define CSR_SCRATCHPAD0 0x100 > +#define CSR_SCRATCHPAD1 0x108 > +#define CSR_AFU_DSM_BASEL 0x110 > +#define CSR_AFU_DSM_BASEH 0x114 > +#define CSR_SRC_ADDR 0x120 > +#define CSR_DST_ADDR 0x128 > +#define CSR_NUM_LINES 0x130 > +#define CSR_CTL 0x138 > +#define CSR_CFG 0x140 > +#define CSR_INACT_THRESH 0x148 > +#define CSR_INTERRUPT0 0x150 > +#define CSR_SWTEST_MSG 0x158 > +#define CSR_STATUS0 0x160 > +#define CSR_STATUS1 0x168 > +#define CSR_ERROR 0x170 > +#define CSR_STRIDE 0x178 > +#define CSR_HE_INFO0 0x180 > + > +#define DSM_SIZE 0x200000 > +#define DSM_POLL_INTERVAL 5 /* ms */ > +#define DSM_TIMEOUT 1000 /* ms */ > + > +#define NLB_BUF_SIZE 0x400000 > +#define TEST_MEM_ALIGN 1024 > + > +struct he_lbk_csr_ctl { > + union { > + uint32_t csr; > + struct { > + uint32_t reset:1; > + uint32_t start:1; > + uint32_t force_completion:1; > + uint32_t reserved:29; > + }; > + }; > +}; > + > +struct he_lbk_csr_cfg { > + union { > + uint32_t csr; > + struct { > + uint32_t rsvd1:1; > + uint32_t cont:1; > + uint32_t mode:3; > + uint32_t multicl_len:2; > + uint32_t rsvd2:13; > + uint32_t trput_interleave:3; > + uint32_t test_cfg:5; > + uint32_t interrupt_on_error:1; > + uint32_t interrupt_testmode:1; > + uint32_t rsvd3:2; > + }; > + }; > +}; > + > +struct he_lbk_status0 { > + union { > + uint64_t csr; > + struct { > + uint32_t num_writes; > + uint32_t num_reads; > + }; > + }; > +}; > + > +struct he_lbk_status1 { > + union { > + uint64_t csr; > + struct { > + uint32_t num_pend_writes; > + uint32_t num_pend_reads; > + }; > + }; > +}; > + > +struct he_lbk_dsm_status { > + uint32_t test_complete; > + uint32_t test_error; > + uint64_t num_clocks; > + uint32_t num_reads; > + uint32_t num_writes; > + uint32_t start_overhead; > + uint32_t end_overhead; > +}; > + > +struct he_lbk_ctx { > + uint8_t *addr; > + uint8_t *dsm_ptr; > + uint64_t dsm_iova; > + uint8_t *src_ptr; > + uint64_t src_iova; > + uint8_t *dest_ptr; > + uint64_t dest_iova; > + struct he_lbk_dsm_status *status_ptr; > +}; > + > +struct he_lbk_priv { > + struct rte_pmd_afu_he_lbk_cfg he_lbk_cfg; > + struct he_lbk_ctx he_lbk_ctx; > +}; > + > +#endif /* _HE_LBK_H_ */ > diff --git a/drivers/raw/afu_mf/meson.build b/drivers/raw/afu_mf/meson.bu= ild > index 8a989e3..a983f53 100644 > --- a/drivers/raw/afu_mf/meson.build > +++ b/drivers/raw/afu_mf/meson.build > @@ -2,6 +2,6 @@ > # Copyright 2022 Intel Corporation >=20 > deps +=3D ['rawdev', 'bus_pci', 'bus_ifpga'] -sources =3D files('afu_mf_= rawdev.c', > 'n3000_afu.c') > +sources =3D files('afu_mf_rawdev.c', 'n3000_afu.c', 'he_lbk.c') >=20 > headers =3D files('rte_pmd_afu.h') > diff --git a/drivers/raw/afu_mf/rte_pmd_afu.h > b/drivers/raw/afu_mf/rte_pmd_afu.h > index f14a053..658df55 100644 > --- a/drivers/raw/afu_mf/rte_pmd_afu.h > +++ b/drivers/raw/afu_mf/rte_pmd_afu.h > @@ -90,6 +90,20 @@ struct rte_pmd_afu_n3000_cfg { > }; > }; >=20 > +/** > + * HE-LBK & HE-MEM-LBK AFU configuration data structure. > + */ > +struct rte_pmd_afu_he_lbk_cfg { > + uint32_t mode; > + uint32_t begin; > + uint32_t end; > + uint32_t multi_cl; > + uint32_t cont; > + uint32_t timeout; > + uint32_t trput_interleave; > + uint32_t freq_mhz; > +}; > + > #ifdef __cplusplus > } > #endif > -- > 1.8.3.1