From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 02C0BA0597; Wed, 8 Apr 2020 07:21:20 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 14C491BF3C; Wed, 8 Apr 2020 07:21:20 +0200 (CEST) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2058.outbound.protection.outlook.com [40.107.20.58]) by dpdk.org (Postfix) with ESMTP id 2D2E31BF30 for ; Wed, 8 Apr 2020 07:21:19 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fOSKUV0UwKY7MkQnepLpsNOpYSWZk2Lx/BbZkiHY38xkV9AdVqtLX5TNa+/0eOeyH8mB2sZm7Ey8/2XpZ1pn0IW1g1lJDV66DlUQXY8uDlQaRLCQKkX3yALbBb540rrs95QUZViopWlW8xpGsAIrV/bVDaCSWIecjhCzx5ldOUNv/b43Tjc2WkdrMhB8/xACRtqtuybbYlbu1vfTL12jRzQCD9YX8Pbc35mKs11SCJ/nz2/cHn27+Qbaw/v2B58o3JIRT744PDRTok6MHs20gVGblw58efOd+I59ozMwcMPcHYspvlS86xJGdgdA1gtCJk8a3n47R+kQu7k85Rr92w== 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-SenderADCheck; bh=sJYMs/lUmS1Sii8IO7qKydS/B4CZok0dWzKiaHnAJ+U=; b=XyyGltpGtSp/4nU+mIAvH2Fqdr+uCGWbFTVI6YQ4UT84S4SZK6W0TBpEV14a6rxd6M6Jwp0h5j5A/59qt2BVV331b5sF59PCGQyvXkkYP6m6TT0wkthKX3GtmLCDEK1nPK+O3uM7/6nSlQ7Fc3ofqN7/SGs9RjNjIJ9eBtmKPuwG4Z7/s37FO8mWnaXHGlwIyZ3B8wc8toBA2huNy+AY0RN1nnz6h2go5wBP33crnrx5BlhgrQbfMRCEZm5o8hyX0z65vh7jt+PfRmCqg9oti3OpbGLSKQdq0pB2AaiQnFR1293xexxSJ2yx2U6NJMNfxbC5rJ9f+Y/junfEKFDPmg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mellanox.com; dmarc=pass action=none header.from=mellanox.com; dkim=pass header.d=mellanox.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sJYMs/lUmS1Sii8IO7qKydS/B4CZok0dWzKiaHnAJ+U=; b=gdhDHBb7atX8diLsYyzR5+9huYxIOqAyqH8YLnv2PW/ddXzW/MPDfBf02jgqv3StMhVkIyoVA2w6dV6rC+N5QvvQ3hsvrbzHwQgP2f64StUFUEjaMI547FtyzGIfv9W/9uHguM+JjgkYxgAUJGQ8CfaZaudFxaL1Khs3iQkJIug= Received: from VI1PR05MB5693.eurprd05.prod.outlook.com (2603:10a6:803:d9::23) by VI1PR05MB6591.eurprd05.prod.outlook.com (2603:10a6:803:102::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2900.15; Wed, 8 Apr 2020 05:21:17 +0000 Received: from VI1PR05MB5693.eurprd05.prod.outlook.com ([fe80::f50f:1ae4:52bb:ce7b]) by VI1PR05MB5693.eurprd05.prod.outlook.com ([fe80::f50f:1ae4:52bb:ce7b%7]) with mapi id 15.20.2878.018; Wed, 8 Apr 2020 05:21:17 +0000 From: Asaf Penso To: Thomas Monjalon , "dev@dpdk.org" CC: Ferruh Yigit , Andrew Rybchenko Thread-Topic: [dpdk-dev] [PATCH 1/2] ethdev: deduplicate functions to get link infos Thread-Index: AQHWDSutT1ykhSWfAkCaJY6uUpuPd6hur34Q Date: Wed, 8 Apr 2020 05:21:17 +0000 Message-ID: References: <98CBD80474FA8B44BF855DF32C47DC35C60F3C@smartserver.smartshare.dk> <20200407222637.55289-1-thomas@monjalon.net> <20200407222637.55289-2-thomas@monjalon.net> In-Reply-To: <20200407222637.55289-2-thomas@monjalon.net> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=asafp@mellanox.com; x-originating-ip: [77.124.83.176] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 4d094e3d-0942-4bec-b770-08d7db7caa4b x-ms-traffictypediagnostic: VI1PR05MB6591: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8273; x-forefront-prvs: 0367A50BB1 x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR05MB5693.eurprd05.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(10009020)(4636009)(376002)(346002)(366004)(396003)(39850400004)(136003)(4326008)(52536014)(5660300002)(66446008)(8936002)(81156014)(316002)(76116006)(66946007)(66556008)(110136005)(54906003)(64756008)(53546011)(6506007)(66476007)(7696005)(71200400001)(2906002)(478600001)(55016002)(33656002)(9686003)(186003)(26005)(86362001)(81166007); DIR:OUT; SFP:1101; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 0s8HXFIGnKCFSlU7yV00EcnYGGAgShqHLiP+FlQM5o52B/tBWcSw0S6tM0shToyhTXlioZxUCzWoMNJHiqmgOC4cBiIlTSr43qP2usBDZv89xKrzVW2V2kbI6xOOu0kt9lsdVKww9nTfhGPCwu+w7hXfvE9m0jZhg1ZB2mhQULCYMbU+WDGfqH0PgbCa1Oy91t1XHZUpUYrVyiKY6XswknYdak8hkWUrt4JdwxifZEozZYQg+PTcrtCm8nbxaKJUl/rYoHjPviqPLp4OZdj0H4uLFqIdXf5xm9yx9czMq2U3y+NoFHmTIZoKo0/c5Z7FpbrKmPUdU5PPxeCUboMe1v7IqPNde+6bSk32Z3ZUvxMX4sWtck26jOHPGpl0KvXDnVyBUZSuFVK8JkO+6HCJQfUWKSAx00es0ztK+U3kPeSI6Xm+bCLfR1W/wy4+m5VJ x-ms-exchange-antispam-messagedata: pOU2CXnZxOnVqemGojuP/fetaVeTCK9c7a5OLaW8R3skW30sJDKdVASnSe6MZ5/Vu9a/V+EosOqClWQIxrIK1rKnDU0aeLDfWgp4tZqgutN2WMORj6XPoZ20okOgMIU6NWoB0e+S77bl2Os6R0BuEg== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4d094e3d-0942-4bec-b770-08d7db7caa4b X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Apr 2020 05:21:17.5361 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: fjsSVZuUVHC+TA8nwSuY6LGN0INTDi/N/53aOECKjauOlwqLjJFQpbEpgpqyxkcNPb0oZyOaDWZdB36p+MlzCQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB6591 Subject: Re: [dpdk-dev] [PATCH 1/2] ethdev: deduplicate functions to get link infos X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" Thank you, Thomas, for taking care of this. PSB. Regards, Asaf Penso > -----Original Message----- > From: dev On Behalf Of Thomas Monjalon > Sent: Wednesday, April 8, 2020 1:27 AM > To: dev@dpdk.org > Cc: Ferruh Yigit ; Andrew Rybchenko > > Subject: [dpdk-dev] [PATCH 1/2] ethdev: deduplicate functions to get link > infos >=20 > There are two function to retrieve link informations. > The only small difference is a boolean timeout parameter. > Adding a new static function, with an additional parameter, > removes the code redundancy. >=20 > Signed-off-by: Thomas Monjalon > --- > lib/librte_ethdev/rte_ethdev.c | 52 ++++++++++++++-------------------- > 1 file changed, 22 insertions(+), 30 deletions(-) >=20 > diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethde= v.c > index 0854ef8832..0df39dff97 100644 > --- a/lib/librte_ethdev/rte_ethdev.c > +++ b/lib/librte_ethdev/rte_ethdev.c > @@ -2332,44 +2332,36 @@ rte_eth_allmulticast_get(uint16_t port_id) > return dev->data->all_multicast; > } >=20 > +static int > +get_link_infos(uint16_t port_id, struct rte_eth_link *eth_link, int wait= ) I would recommend renaming to link_get_infos, to have the same naming conve= ntion as rte_eth_*link_get* and rte_eth_*link_get*_nowait > +{ > + struct rte_eth_dev *dev; > + > + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); > + dev =3D &rte_eth_devices[port_id]; > + > + if (dev->data->dev_conf.intr_conf.lsc && > + dev->data->dev_started) > + rte_eth_linkstatus_get(dev, eth_link); > + else { > + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops- > >link_update, -ENOTSUP); > + (*dev->dev_ops->link_update)(dev, wait); > + *eth_link =3D dev->data->dev_link; > + } > + > + return 0; Since it's a static function, I think it can return void, and the calling f= unctions can decide what to return, but it's a matter of taste. Do we want to check that the return value for eth_link is not NULL and retu= rn -1 in case it is? > +} > + > int > rte_eth_link_get(uint16_t port_id, struct rte_eth_link *eth_link) > { > - struct rte_eth_dev *dev; > - > - RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); > - dev =3D &rte_eth_devices[port_id]; > - > - if (dev->data->dev_conf.intr_conf.lsc && > - dev->data->dev_started) > - rte_eth_linkstatus_get(dev, eth_link); > - else { > - RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops- > >link_update, -ENOTSUP); > - (*dev->dev_ops->link_update)(dev, 1); > - *eth_link =3D dev->data->dev_link; > - } > - > - return 0; > + return get_link_infos(port_id, eth_link, 1); > } >=20 > int > rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link) > { > - struct rte_eth_dev *dev; > - > - RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); > - dev =3D &rte_eth_devices[port_id]; > - > - if (dev->data->dev_conf.intr_conf.lsc && > - dev->data->dev_started) > - rte_eth_linkstatus_get(dev, eth_link); > - else { > - RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops- > >link_update, -ENOTSUP); > - (*dev->dev_ops->link_update)(dev, 0); > - *eth_link =3D dev->data->dev_link; > - } > - > - return 0; > + return get_link_infos(port_id, eth_link, 0); > } >=20 > int > -- > 2.26.0