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 B1B28A0350; Tue, 23 Jun 2020 17:04:18 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 374BE1D695; Tue, 23 Jun 2020 17:04:18 +0200 (CEST) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2078.outbound.protection.outlook.com [40.107.21.78]) by dpdk.org (Postfix) with ESMTP id E02485323 for ; Tue, 23 Jun 2020 17:04:16 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UXbMko+k9rfUbzCc3TLJlEEIx2R5Kj+FC/tH066KlE+1r6mk4hPfyPUiNPCeq51khWrqsf3xxHkKBRtjnML+fdu5qM4POb4UbV44waB5MuT7D7nBu9r3QeOaWm7juR4UJh3RDJAUGQelkVjF40gmhdSZk5kcVNy8oQa5RG0v9edUcbCYoCTvvGSoj3fE9FQOgHn+Sf8DzKqtd7TT2eV45wBOMY4uGc2EhF4lBHP1GVUrA5KDh92CDOFYSAfam2HU24lpoUl+83MFRsiNwysURBHRkbsSrlf0qooB9CG00oaPvXOuS/Q7aYalKK38NAG9cM9zGiLmCxMOxPeU8dcQgw== 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=Nt8iMBZg+M7AoJRlQlOD+4rs1GVjPTFvFY5LRyKOw3Y=; b=CkvRUvGV1FV7TKeTVEf+kCaje/W6i7hBix9jLsIC+n23Ewx03WHm/q1GzqaChgv2KGQ3vqfh4GggB+YGVAHguCI4VG8k2HgEtBiUEzEksTmKaW45JLdvkxjYwO2Fo5Yxv7OKBxZbK/DgMp08auHi0Wv7EoOlF7E+w4bkvnH/fjbWp19bqmZE5rEbEqgrra+F8AlIfrzPxN90nsUDm2mUkdrvdb5Ysd/pEXlptwKwQJ2RkfcoZuSzNdq0SRmOeXCFbnsu2hnsO+AFOG8n4TsiJTgICc2Lf7fQUCUuh+z4QENV30C9NqHkGYIFbLlPtcO2lm4A1FJoAZtASiol9rNVAg== 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=Nt8iMBZg+M7AoJRlQlOD+4rs1GVjPTFvFY5LRyKOw3Y=; b=piPN20YGBgqVf2dPgJidrEiDF/9ORrGk/pBBsxiYrDJBIxKdduPcdKg431oVVZn9KEdTdb2b0mDaeI5V2hx9y3eKKYM5+xcMnt/1x3liMdXcnQJRkM97qYJiHBFavs/QXcdkDB6r2MfhjJ+YfZoL1mB3egLTDwaPR0jsk/jGukQ= Received: from AM4PR05MB3265.eurprd05.prod.outlook.com (2603:10a6:205:8::26) by AM4PR05MB3172.eurprd05.prod.outlook.com (2603:10a6:205:3::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.24; Tue, 23 Jun 2020 15:04:16 +0000 Received: from AM4PR05MB3265.eurprd05.prod.outlook.com ([fe80::194e:dc46:7543:50ed]) by AM4PR05MB3265.eurprd05.prod.outlook.com ([fe80::194e:dc46:7543:50ed%2]) with mapi id 15.20.3109.027; Tue, 23 Jun 2020 15:04:15 +0000 From: Slava Ovsiienko To: Patrick Keroulas , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [RFC][PATCH v2 2/3] ethdev: add API to convert raw timestamps to nsec Thread-Index: AQHWQANWMUizrx5OfEK3fWpXTVLN+ajmXffQ Date: Tue, 23 Jun 2020 15:04:15 +0000 Message-ID: References: <20200611151610.32409-1-patrick.keroulas@radio-canada.ca> <20200611151610.32409-3-patrick.keroulas@radio-canada.ca> In-Reply-To: <20200611151610.32409-3-patrick.keroulas@radio-canada.ca> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: radio-canada.ca; dkim=none (message not signed) header.d=none;radio-canada.ca; dmarc=none action=none header.from=mellanox.com; x-originating-ip: [95.164.10.10] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 00820cbb-8b64-414e-3eef-08d81786b266 x-ms-traffictypediagnostic: AM4PR05MB3172: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:5236; x-forefront-prvs: 04433051BF x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: btsO3pvHT6hzrCv6a85fCiT8CdtNyXvqpnJsFoV4Wco0OMit2d8lPUKOtEMLFXOSGkrlgT5Kh7eTTwm9wWMNwVzoZpJztmg8VfV3B1NvWI0d+SNmupwul/DTOlrMUEU0eEuTq/v/irkuZSC7VNf7zHbPYHOh/g4mqyvbGokZCYAUBzdCgBP/MiL3F+Oqa/kr4NuKEzSIqpQoxyHhFKOyUJs9xO7f80s5BKaSOehdIDgeajFCJu1brP8echZ0APmQnRu9WyJoT6g4BKy3b9oh2POnXPPtdPEAsIzZOQmTxdET3qu3Xp4cwKPW9eAZvogZGxn6aGkfaQB76JTjkRAS0w== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM4PR05MB3265.eurprd05.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(366004)(86362001)(64756008)(66946007)(66446008)(66476007)(76116006)(66556008)(8936002)(55016002)(498600001)(53546011)(7696005)(33656002)(71200400001)(26005)(6506007)(2906002)(9686003)(186003)(110136005)(52536014)(83380400001)(5660300002); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: kmutHrriDj140zrLHWkvvl1mWAhIMqfe21VQOGcxsaEFwG8+MVISf2uTPvhFx+kWTmh5jja5p7E1Z6RL7RSeCwHXmIqdSzSBPmLGIurJGRK6oxJzroLbsuut1QLKR16do0L4yT+PSCHev4CA4Ix1O+q6SI1HL0b+it5fGKfKfCw2ElKpYSkmfXC7HM8woaN2sghhcZo7xGXtrBo9XCoQWryzwU+oFutki97OMaYrf2Lj1ZaWrH/99CZSkqdLHfiZFMTqdaO+TXeZayTzxhgd2b/hhHu1N1m0VmsC13kd9IlLfpBzWyhI3YGGyKUh4a0gUDa/CXKI74e55mnz1ebo8QBMCBI1Wj29uG1JjrDODrF2f3wzT9+jnhqfA4nBwOkkwZAx8lP2bmElzIa/VDMrkxbIGH6QEaCC6jHiuR1YSax3RyWvcNI/668EHMoWmCx7Lw0QFzpwiqAekUHcQDhW9LAzWsyMaja5+Fmd+E+p/o8= 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: 00820cbb-8b64-414e-3eef-08d81786b266 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Jun 2020 15:04:15.7867 (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: iIgKohi7buXY6cNuhWKv1PK4dRLIfqFtfnBqkXQJqzVfQVXEeLOVtLvBKQlLVd2kEIVS8YRa3CKqprhl/umMIjtWXCn/mqbz/Eg7vk5Ev7w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR05MB3172 Subject: Re: [dpdk-dev] [RFC][PATCH v2 2/3] ethdev: add API to convert raw timestamps to nsec 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" Hi, Patrick > /**< @internal Function used to get the current value of the device cloc= k. */ > @@ -730,6 +734,7 @@ struct eth_dev_ops { > eth_timesync_read_time timesync_read_time; /** Get the device > clock time. */ > eth_timesync_write_time timesync_write_time; /** Set the device > clock time. */ >=20 > + eth_convert_ts_to_ns convert_ts_to_ns; > eth_read_clock read_clock; I have a concern about this - it adds the new field into struct eth_dev_ops= and breaks ABI, should we postpone patch to 20.11? With best regards, Slava > -----Original Message----- > From: dev On Behalf Of Patrick Keroulas > Sent: Thursday, June 11, 2020 18:16 > To: dev@dpdk.org > Cc: Patrick Keroulas > Subject: [dpdk-dev] [RFC][PATCH v2 2/3] ethdev: add API to convert raw > timestamps to nsec >=20 > Existing ethdev functions can read/write time from/to device but they're = all > related to timesync and none of them can translate a raw counter in real > time unit which is usefull in a pdump application. >=20 > A new API is required because the conversion is derived from dev clock in= fo. >=20 > Signed-off-by: Patrick Keroulas > --- > lib/librte_ethdev/rte_ethdev.c | 12 ++++++++++++ > lib/librte_ethdev/rte_ethdev.h | 17 +++++++++++++++++ > lib/librte_ethdev/rte_ethdev_core.h | 5 +++++ > lib/librte_ethdev/rte_ethdev_version.map | 2 ++ > lib/librte_mbuf/rte_mbuf_core.h | 3 ++- > lib/librte_pdump/rte_pdump.c | 14 +++++++++++++- > 6 files changed, 51 insertions(+), 2 deletions(-) >=20 > diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethde= v.c > index 8e10a6fc3..822fa6d5a 100644 > --- a/lib/librte_ethdev/rte_ethdev.c > +++ b/lib/librte_ethdev/rte_ethdev.c > @@ -4810,6 +4810,18 @@ rte_eth_timesync_write_time(uint16_t port_id, > const struct timespec *timestamp) > timestamp)); > } >=20 > +int > +rte_eth_convert_ts_to_ns(uint16_t port_id, uint64_t *timestamp) { > + struct rte_eth_dev *dev; > + > + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); > + dev =3D &rte_eth_devices[port_id]; > + > + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->convert_ts_to_ns, - > ENOTSUP); > + return eth_err(port_id, (*dev->dev_ops->convert_ts_to_ns)(dev, > +timestamp)); } > + > int > rte_eth_read_clock(uint16_t port_id, uint64_t *clock) { diff --git > a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h index > a49242bcd..2d4d0bc7d 100644 > --- a/lib/librte_ethdev/rte_ethdev.h > +++ b/lib/librte_ethdev/rte_ethdev.h > @@ -4103,6 +4103,23 @@ int rte_eth_timesync_read_time(uint16_t > port_id, struct timespec *time); > */ > int rte_eth_timesync_write_time(uint16_t port_id, const struct timespec > *time); >=20 > +/** > + * Convert a raw clock counter to nanoseconds from device clock > + * > + * @param port_id > + * The port identifier of the Ethernet device. > + * @param[in&out] timestamp > + * Pointer to the timestamp to be converted. > + * > + * @return > + * - 0: Success. > + * - -ENODEV: The port ID is invalid. > + * - -ENOTSUP: The function is not supported by the Ethernet driver. > + */ > +__rte_experimental > +int > +rte_eth_convert_ts_to_ns(uint16_t port_id, uint64_t *timestamp); > + > /** > * @warning > * @b EXPERIMENTAL: this API may change without prior notice. > diff --git a/lib/librte_ethdev/rte_ethdev_core.h > b/lib/librte_ethdev/rte_ethdev_core.h > index 32407dd41..255b41b67 100644 > --- a/lib/librte_ethdev/rte_ethdev_core.h > +++ b/lib/librte_ethdev/rte_ethdev_core.h > @@ -464,6 +464,10 @@ typedef int (*eth_timesync_write_time)(struct > rte_eth_dev *dev, > const struct timespec *timestamp); /**< > @internal Function used to get time from the device clock */ >=20 > +typedef int (*eth_convert_ts_to_ns)(struct rte_eth_dev *dev, > + uint64_t *timestamp); > +/**< @internal Function used to convert timestamp from device clock */ > + > typedef int (*eth_read_clock)(struct rte_eth_dev *dev, > uint64_t *timestamp); > /**< @internal Function used to get the current value of the device cloc= k. */ > @@ -730,6 +734,7 @@ struct eth_dev_ops { > eth_timesync_read_time timesync_read_time; /** Get the device > clock time. */ > eth_timesync_write_time timesync_write_time; /** Set the device > clock time. */ >=20 > + eth_convert_ts_to_ns convert_ts_to_ns; > eth_read_clock read_clock; >=20 > eth_xstats_get_by_id_t xstats_get_by_id; > diff --git a/lib/librte_ethdev/rte_ethdev_version.map > b/lib/librte_ethdev/rte_ethdev_version.map > index 715505604..754c05630 100644 > --- a/lib/librte_ethdev/rte_ethdev_version.map > +++ b/lib/librte_ethdev/rte_ethdev_version.map > @@ -241,4 +241,6 @@ EXPERIMENTAL { > __rte_ethdev_trace_rx_burst; > __rte_ethdev_trace_tx_burst; > rte_flow_get_aged_flows; > + > + rte_eth_convert_ts_to_ns; > }; > diff --git a/lib/librte_mbuf/rte_mbuf_core.h > b/lib/librte_mbuf/rte_mbuf_core.h index b9a59c879..7f51f9157 100644 > --- a/lib/librte_mbuf/rte_mbuf_core.h > +++ b/lib/librte_mbuf/rte_mbuf_core.h > @@ -592,7 +592,8 @@ struct rte_mbuf { > /** Valid if PKT_RX_TIMESTAMP is set. The unit and time reference > * are not normalized but are always the same for a given port. > * Some devices allow to query rte_eth_read_clock that will return > the > - * current device timestamp. > + * current device timestamp or rte_eth_ts_to_ns that will convert > raw > + * counter to nanoseconds. > */ > uint64_t timestamp; >=20 > diff --git a/lib/librte_pdump/rte_pdump.c b/lib/librte_pdump/rte_pdump.c > index f96709f95..03d9ba484 100644 > --- a/lib/librte_pdump/rte_pdump.c > +++ b/lib/librte_pdump/rte_pdump.c > @@ -100,12 +100,24 @@ pdump_copy(struct rte_mbuf **pkts, uint16_t > nb_pkts, void *user_params) > } > } >=20 > +static inline void > +pdump_ts_to_ns(uint16_t port_id, struct rte_mbuf **pkts, uint16_t > +nb_pkts) { > + unsigned int i; > + > + for (i =3D 0; i < nb_pkts; i++) { > + if (pkts[i]->ol_flags & PKT_RX_TIMESTAMP) > + rte_eth_convert_ts_to_ns(port_id, &pkts[i]- > >timestamp); > + } > +} > + > static uint16_t > -pdump_rx(uint16_t port __rte_unused, uint16_t qidx __rte_unused, > +pdump_rx(uint16_t port_id, uint16_t qidx __rte_unused, > struct rte_mbuf **pkts, uint16_t nb_pkts, > uint16_t max_pkts __rte_unused, > void *user_params) > { > + pdump_ts_to_ns(port_id, pkts, nb_pkts); > pdump_copy(pkts, nb_pkts, user_params); > return nb_pkts; > } > -- > 2.17.1