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 59FF8A0C41; Thu, 16 Sep 2021 08:10:30 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 418D14003F; Thu, 16 Sep 2021 08:10:29 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mails.dpdk.org (Postfix) with ESMTP id D1A1B4003C for ; Thu, 16 Sep 2021 08:10:27 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10108"; a="222151729" X-IronPort-AV: E=Sophos;i="5.85,297,1624345200"; d="scan'208";a="222151729" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2021 23:10:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,297,1624345200"; d="scan'208";a="482600254" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by orsmga008.jf.intel.com with ESMTP; 15 Sep 2021 23:10:25 -0700 Received: from orsmsx607.amr.corp.intel.com (10.22.229.20) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Wed, 15 Sep 2021 23:10:25 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx607.amr.corp.intel.com (10.22.229.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12 via Frontend Transport; Wed, 15 Sep 2021 23:10:25 -0700 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.44) 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.2242.12; Wed, 15 Sep 2021 23:10:24 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LeIJOi/SfNSAsuIX9xFARTFyJutO24pW4xWylNH9Mee4JJ15RCdmF0g2nGI40PG3sdrtQT8m+yi6QQZ8PwnHJoVzSRMuITYZFsPcYQOSUlbg5xqeUPxrYoCUHqhoHRJ4OoqMbPFj13RPyddXSaeAQCCXo4EktFn7hsXjbyRGONn8GCfs4lyFigK4askXYGsXkwr2nfvUviNp4mxaPHLq8Wmh++TYVgBxe30SEDguNM1dLpsa+KukFx/95bDc+goYFU8amrV6Ic+/zt/PDnQpzLyNYaqCgG4fpD6dr6VdZ1xNysoW9ESEHS98l5rLirk/Vd4ziF134pTt157lF7fMrg== 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; bh=a6mYedC5gS8I2TtnEd1ASOksAn+tqtJ5oTczYlxkq94=; b=mwnl4m5T0L22AgSs1arAMnPMOilzkY/4416xRzBg6UsCtNa9t0wmdkOyswx6GDb49n+d+9uUKUlSZLK6r3Er5tGpMPSowXQ7tXKgAMhUfQ7B3Vei77lQYgZWy7kNevhe5I94UMGKtVcImlagQyW6enzLBeZOZtOjJWwmO6nqsVIfl8QKnVyTibQt8Gq6+6CMtisB0gNQPrGCdx4KGQMQWot2dHoOC71OMkzuhC7/wUYCYayByKTjUo/5lxSAL0byxAOQGip+IfNaNNB1vOUTUgqKj4YN/mYBDPHi/znnwghAsPv0sauWdlMnWp6TqwWb1vy0CBu+Jx0oEZWbZUFHOg== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=a6mYedC5gS8I2TtnEd1ASOksAn+tqtJ5oTczYlxkq94=; b=dU5rM0AuWviSrSiGE8yrvLkebMHHACbDHImveE6PMVI56DWhxtiXumWIY/8gebiUlorjoh1b/WpuaLn+4SzzX1tfgbaZlSi9qHPoxi9TrO1qwojOj68u0OCJn54BeH98cBW7WJ00/zLfbCqWs5Sh2LrM4xgWYPF1Pr6VbUdYbEo= Received: from DM4PR11MB5534.namprd11.prod.outlook.com (2603:10b6:5:391::22) by DM5PR11MB1291.namprd11.prod.outlook.com (2603:10b6:3:14::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Thu, 16 Sep 2021 06:10:24 +0000 Received: from DM4PR11MB5534.namprd11.prod.outlook.com ([fe80::3d9b:76d7:e274:bad3]) by DM4PR11MB5534.namprd11.prod.outlook.com ([fe80::3d9b:76d7:e274:bad3%3]) with mapi id 15.20.4523.014; Thu, 16 Sep 2021 06:10:23 +0000 From: "Li, Xiaoyun" To: "Xia, Chenbo" , "dev@dpdk.org" Thread-Topic: [PATCH 2/8] app/testpmd: use PCI memory resource access APIs Thread-Index: AQHXpezkSBn7BX6YgkSdQkOrlOjTu6umNYtw Date: Thu, 16 Sep 2021 06:10:23 +0000 Message-ID: References: <20210910022402.26620-1-chenbo.xia@intel.com> <20210910022402.26620-3-chenbo.xia@intel.com> In-Reply-To: <20210910022402.26620-3-chenbo.xia@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 5e508bd5-5507-4f50-0c8c-08d978d8abc3 x-ms-traffictypediagnostic: DM5PR11MB1291: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1775; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: oSoIykoRipBw5eIuyk9NrC6UdmmdX+1r7LsR9ePegA+xdgu95YQ+rIc/V3jFbKlHXo8EymJ0oeGHJZm9hQh/oWs8WFbUNKYbaDxnahQiNTkuM+fyQ/iynJzCC1LRS7Q+LTzHnT/p4ChH05muVuczxiPGY9AoBxzFfxac/xaR1mXTVzPrr+MtPEBbXkiAjSX13Ha9WGH24mf4TjageJl9AtZqfIXjIhavdDsc/mgTuPUBqbUQgUXOva7CYFjU4tQXm3MzC+UTv3WLSBOkWK1iQsJJmOY2afNw57XToR87r7nIFOvbGaAicVKmSeXZ8m4HcpJxOpaN6WJ+rhU////T9cNVwMN95p2me3V6OdeUa/t3TufBy2JD3p/f66TFsX+flFetuSZBr8ExqWOL6gkaF9aNkz3Ywk1aK6gEAk3giNcVu6vxy7LZpZDmHxqpfsQGShldtLYSG7zhUEhltlglqy+fiSdNDQRQcZfOmQxUNXLxxlW7AsLpqOO9/J49AelxGVIKUkkbngo8CUSXB0LjrIPnOvPtyL/WrUeCQxJamtyp3jLfx6rz4gnlntiMuHqy3C2eqJ7FPbILoyFK8Mq9XWOfRgriRWFVVu3P98VaAFRkRkqL2oGcbffOFuZj9sUfqFtRD6fXySHfNDfBwjupnmkBtwbQg/9rm4STNUW8EhOnGIkQEQFiiAnDJMCy/lRE5qrp8OiI7UtrEpS3jLRIQg== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5534.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(366004)(346002)(396003)(136003)(376002)(53546011)(76116006)(66476007)(66556008)(8676002)(83380400001)(2906002)(6506007)(38070700005)(52536014)(9686003)(8936002)(7696005)(55016002)(478600001)(5660300002)(66946007)(316002)(71200400001)(86362001)(26005)(110136005)(122000001)(66446008)(186003)(64756008)(33656002)(38100700002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?G/ckPPL9HsXO5e+o6G9fGJXSbhANsoFxptCMKM1Abjp9uWerCfkC3dGMxG+/?= =?us-ascii?Q?yACtiAs54snWipGaIeDput/ewzW+/ZeOxFTXk34pUNPZpQSMkfVkpJ5lAAx0?= =?us-ascii?Q?kgcnDMVznnVPW9GH8Y5BU2swDlplFK8LFOdYWFFXuVSGvJRvubBbkoLaXAnV?= =?us-ascii?Q?fhV+2g98HXFWnThrzinQ9N81kAwQE0jUjPCOM+nPPQHQOHsiTXlMeiOvQWsW?= =?us-ascii?Q?j7k2xN1iBOXVu0rgchlQKcTCmJNJPuEhhAsUBgsfFi+2ZNQU7Ng6egi6lzQ7?= =?us-ascii?Q?6f07sajo0XkoOspZXLXZhjkirgsEYyANkXshrKTjAECdt4LI/KX0725GPY0H?= =?us-ascii?Q?4HEQ6daAa6UK+H3t5thW5UzJXTgWUC0PHsjvBd5OWVeE7DHC8u7AU4fliw9S?= =?us-ascii?Q?ocCvk+hge3zgjLAER4OW2DTp1eplgaaCYWODRBgMNhtvB8dph1ucmvqcSEJi?= =?us-ascii?Q?cuCidPS4jWm8GlOG9S2Ljexpw2GLGqJfFb5wqTBb2fRS1X1QWx+jLOeaMHXI?= =?us-ascii?Q?ClMXdYyWescQlT9glntdvNqrnhNu1OTGvMaqLR1qgZ5WI3Ylgk8dNTfviqeM?= =?us-ascii?Q?RlRJmHGIC93wgD9tNKRV0M130dXnBY5t6NLhgrTM18/rz/n41W8Vet4TwepH?= =?us-ascii?Q?juw+bIQad1u2u+Us0xEvpq2wa3jYWtD3CdKR9q7bVogmZQaPj6Z+dMwxaAog?= =?us-ascii?Q?7nZYI1kuZWdUkcxiputnLN28u+XGjczvwQbsywEU4z70ZGA+cF9EY1DTvi8r?= =?us-ascii?Q?MEUPMjyKsYanUBNWiLrVh5MeGKYcLteg8XhfdlaEKI94eV/N5yQeIsk9Lr9x?= =?us-ascii?Q?24dX3/BOm7uN5/3SKjeGwdRufw5KH8BzZvXd7HWKvuk+Gl0LnUBO3o3AX0vB?= =?us-ascii?Q?+AtAzzXWdNXhGzq4m50i4JZWOIUjW4v23frdPS2tXrC3J49bUWH/FqWGmCd4?= =?us-ascii?Q?K+RqjQth1+ADItObydBNLEuOn709BLaEsHjVzzuk0bBvNJgCpNesh1kzQkEV?= =?us-ascii?Q?fCEeq589OS/DW3EUf2A0GTrMDsyy8TgHJIY0SHkiGNn0fy+Fz6sObhvhRf9v?= =?us-ascii?Q?olkX1ci3mw4LdyEExk+NSDQ2DTHbzd5JbInLptdMpzGSQg7rweBaYLbFZtrw?= =?us-ascii?Q?swDq8MxjxAjX3f81E2BA1lxpmmMKrwt0r+hHexQuvQ6ZDEpF6r+ll5iswNWA?= =?us-ascii?Q?/9cAX0KdD95XxZCX1i07j9k+r5rgNAfvERiQOR8Aj+c/8BEHorxj00Kaq3t1?= =?us-ascii?Q?mfU2B6PnL2uLbKFKUwgfd1LfyQKMzPfX5q5tpOf5vtmZLYhl+XMJKBLQvlJp?= =?us-ascii?Q?1r/bCQpu+4qxUb0d9ofsf+Vu?= 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: DM4PR11MB5534.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5e508bd5-5507-4f50-0c8c-08d978d8abc3 X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Sep 2021 06:10:23.9004 (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: t+QqHAZp5o6WQ7zSoTY8Y4sxGWvnjrcQfvAd6rQTjJhdti6i+VUZFfdl20vVMikYhvNKLK5KmM7h9WbkOgpSUg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR11MB1291 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH 2/8] app/testpmd: use PCI memory resource access APIs 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 Sender: "dev" Hi > -----Original Message----- > From: Xia, Chenbo > Sent: Friday, September 10, 2021 10:24 > To: dev@dpdk.org > Cc: Li, Xiaoyun > Subject: [PATCH 2/8] app/testpmd: use PCI memory resource access APIs >=20 > Currently testpmd uses struct rte_pci_device to access PCI memory resourc= e. > Since this structure will be internal later, this patch replaces use of > rte_pci_device with new PCI memory resource access APIs to read/write BAR= 0. >=20 > Signed-off-by: Chenbo Xia > --- > app/test-pmd/config.c | 38 +++++++++++----------------------- > app/test-pmd/testpmd.h | 46 +++++++++++++++++++++--------------------- > 2 files changed, 35 insertions(+), 49 deletions(-) >=20 >=20 > @@ -1081,7 +1063,9 @@ port_reg_bit_set(portid_t port_id, uint32_t reg_off= , > uint8_t bit_pos, > (int) bit_v); > return; > } > - reg_v =3D port_id_pci_reg_read(port_id, reg_off); > + if (port_id_pci_reg_read(port_id, reg_off, ®_v)) > + return; > + > if (bit_v =3D=3D 0) > reg_v &=3D ~(1 << bit_pos); > else > @@ -1123,7 +1107,9 @@ port_reg_bit_field_set(portid_t port_id, uint32_t > reg_off, > (unsigned)max_v, (unsigned)max_v); > return; > } > - reg_v =3D port_id_pci_reg_read(port_id, reg_off); > + if (port_id_pci_reg_read(port_id, reg_off, ®_v)) > + return; > + > reg_v &=3D ~(max_v << l_bit); /* Keep unchanged bits */ > reg_v |=3D (value << l_bit); /* Set changed bits */ > port_id_pci_reg_write(port_id, reg_off, reg_v); diff --git a/app/test- In your implementation, port_id_pci_reg_write() can fail. Then the followin= g display shouldn't be called. So change this function to have return value and check it before use it wil= l be better. > pmd/testpmd.h b/app/test-pmd/testpmd.h index 16a3598e48..7922807a6e > 100644 > --- a/app/test-pmd/testpmd.h > +++ b/app/test-pmd/testpmd.h > static inline void > -port_pci_reg_write(struct rte_port *port, uint32_t reg_off, uint32_t reg= _v) > +port_id_pci_reg_write(portid_t pt_id, uint32_t reg_off, uint32_t reg_v) > { > - const struct rte_pci_device *pci_dev; > + struct rte_port *port =3D &ports[(pt_id)]; > + char name[RTE_ETH_NAME_MAX_LEN]; > const struct rte_bus *bus; > - void *reg_addr; >=20 > if (!port->dev_info.device) { > fprintf(stderr, "Invalid device\n"); > @@ -721,19 +721,19 @@ port_pci_reg_write(struct rte_port *port, uint32_t > reg_off, uint32_t reg_v) >=20 > bus =3D rte_bus_find_by_device(port->dev_info.device); > if (bus && !strcmp(bus->name, "pci")) { > - pci_dev =3D RTE_DEV_TO_PCI(port->dev_info.device); > + rte_eth_dev_get_name_by_port(pt_id, name); > } else { > fprintf(stderr, "Not a PCI device\n"); > return; > } >=20 > - reg_addr =3D ((char *)pci_dev->mem_resource[0].addr + reg_off); > - *((volatile uint32_t *)reg_addr) =3D rte_cpu_to_le_32(reg_v); > + reg_v =3D rte_cpu_to_le_32(reg_v); > + if (rte_pci_mem_wr32(name, 0, ®_v, reg_off)) { > + fprintf(stderr, "Failed to write register\n"); > + return; > + } > } >=20 > -#define port_id_pci_reg_write(pt_id, reg_off, reg_value) \ > - port_pci_reg_write(&ports[(pt_id)], (reg_off), (reg_value)) > - > static inline void > get_start_cycles(uint64_t *start_tsc) > { > -- > 2.17.1