From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60051.outbound.protection.outlook.com [40.107.6.51]) by dpdk.org (Postfix) with ESMTP id 930682BD5 for ; Sun, 9 Dec 2018 07:00:13 +0100 (CET) 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=C32pFzJ2RJzkk+nFqoCx9SBTmhN+jHughWjI435ufQY=; b=YdhVDe9CW7WH2WYTcmoNCncmCHwRqMhUpa8VdjCqupb0aj4cz0oGCqBo0X99dCXbp18c0yQjtx7a8A4LkSdyOLPzemy6WsKUcv/JrYO19Q+idd/RBsKFkfF1VaUwBFFLVxDlY65ZZ/GQxz07v/qhMK28/L3UTuU1+PEwDJhwBu8= Received: from DB7PR05MB4426.eurprd05.prod.outlook.com (52.134.109.15) by DB7PR05MB6265.eurprd05.prod.outlook.com (20.176.234.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1404.17; Sun, 9 Dec 2018 06:00:09 +0000 Received: from DB7PR05MB4426.eurprd05.prod.outlook.com ([fe80::f59c:f6f0:665b:8b16]) by DB7PR05MB4426.eurprd05.prod.outlook.com ([fe80::f59c:f6f0:665b:8b16%4]) with mapi id 15.20.1404.025; Sun, 9 Dec 2018 06:00:09 +0000 From: Shahaf Shuler To: Tom Barbette , "dev@dpdk.org" CC: "bruce.richardson@intel.com" , "john.mcnamara@intel.com" , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko , Yongseok Koh Thread-Topic: [RFC PATCH 1/3] rte_ethdev: Add API function to read dev clock Thread-Index: AQHUhwBXs04hejatLkKg0kHGD68Fe6V1+XPg Date: Sun, 9 Dec 2018 06:00:09 +0000 Message-ID: References: <1543398732-79439-1-git-send-email-barbette@kth.se> <1543398732-79439-2-git-send-email-barbette@kth.se> In-Reply-To: <1543398732-79439-2-git-send-email-barbette@kth.se> 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=shahafs@mellanox.com; x-originating-ip: [31.154.10.105] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB7PR05MB6265; 6:qZgUkogmr5hV2hPql6Fi57Zo4mJmmJY+TyhqMs4GqFrqdyjPtxbCm/KTYqnsp7FbqSJDAcvVCg+IJww259gAoRkGiV9bfyXR+of7e45R2dxcZhww+s6plqVOvH6cgT6an9Q7L8FWNPb9ZSDY7kLkBGDruAj0+qZ929YKCbviW7ZOYg4PUG1PjF7PqbIYCjywcJuV8f43XuLgwr0jshDgBIJHqhPrrB9r3xRrwR59t1P44gdPHifiO6GDrY6snFNtjYRU1y+P4VRtpT0zlxknzLGIE4EuaE2eRiXURRmLTl0GQ9pz2zZrKI77ymR060IN7JEMnyCzyN8LeyvXkP5u+KCEcSzPp1TYyX1UlUcJdXv+iZ3XYrpxpX1+d1n/UWwU3PD5dFkpnnNlyrCPPIjpKFyf2g7+lJY+jgngGBRHuSFuNDsCRJh0uqlhFMeKUEC6ID/mEtui8YknOMIvOQdCYA==; 5:hB+Sp497rr2Nin/o+WYyskvxbfOMYWZpOs3R8cWOwA1U1m/bw8PCfD6CD0cUTjIDNDG4+tTSgJG8L214F3JZmUa0U1Hro0DgD3Qj9lP+8+szP3EF7r0XZxjO9jFlXfCFtyNdDG6NGpnyapDNjBF3zFqkoDhCNzfpBZ1V5kuaBjE=; 7:469ww3B1BTd4EyK6trnBNWuJjwXdk4SlVmsdFsLln3HoVQwe3DfcPbAnuw0gOfnkoblLKonEkw+mrqMBQELbFXfFGTgbsra+c3KuIaiLl9Ggkkkz7DfcozCuZqa9i8rdWQ7zTpw6HEgGYFa5hpLWAg== x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: 4d2cbbf7-e0d3-4d9d-14fe-08d65d9b938a x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:DB7PR05MB6265; x-ms-traffictypediagnostic: DB7PR05MB6265: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3002001)(3231455)(999002)(944501520)(52105112)(93006095)(93001095)(10201501046)(6055026)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123562045)(20161123564045)(201708071742011)(7699051)(76991095); SRVR:DB7PR05MB6265; BCL:0; PCL:0; RULEID:; SRVR:DB7PR05MB6265; x-forefront-prvs: 0881A7A935 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(376002)(366004)(346002)(136003)(39850400004)(396003)(199004)(189003)(2501003)(110136005)(186003)(74316002)(54906003)(102836004)(305945005)(6506007)(8936002)(26005)(97736004)(25786009)(33656002)(316002)(229853002)(5660300001)(66066001)(6436002)(3846002)(6116002)(9686003)(55016002)(99286004)(2906002)(8676002)(76176011)(105586002)(81166006)(106356001)(7736002)(81156014)(107886003)(4326008)(6246003)(14454004)(53936002)(11346002)(7696005)(476003)(68736007)(256004)(14444005)(71190400001)(71200400001)(486006)(446003)(86362001)(478600001)(217873002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB7PR05MB6265; H:DB7PR05MB4426.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: RDw9HTAPC1q03tgfQfeOWQwZRcIEElmWI0pCAYRJtJpJfo8NTP+PVB+QF8QmLwZUoymkk6qK0bFVtFS5fDnxaSzHpTXb0CuGDRR40mulUrp3SbTDUXnQw6JUo8ZxIqdz3LkOOBJJS3n6p6VsKWRVIqmT4jM2vpfTLobvKYM8nKquGo6lfS3REuWHvDSwrbPlYOyR2nVdJWI59jOqLUIymz0ZUF7/AD0eNlqI6DHTM6Hsxjhbp8edYTb2fu9hqR5ZAdQZVRUGBcScDnL6LP6xhruSX6XdfejJGBGFZVTMAYmqKmZwhBAVZqY2nWUSarIDIdjUHRbLyQx8GIr7+WegYH+o9IyWVoTep6UORL48ohY= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM 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: 4d2cbbf7-e0d3-4d9d-14fe-08d65d9b938a X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Dec 2018 06:00:09.4456 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR05MB6265 Subject: Re: [dpdk-dev] [RFC PATCH 1/3] rte_ethdev: Add API function to read dev clock 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: , X-List-Received-Date: Sun, 09 Dec 2018 06:00:13 -0000 Hi Tom, See few nits below.=20 Wednesday, November 28, 2018 11:52 AM, Tom Barbette: > Subject: [RFC PATCH 1/3] rte_ethdev: Add API function to read dev clock >=20 > Add rte_eth_read_clock to read the current clock of a devide. To be explicit, the **raw** clock of the device.=20 >=20 > The main use is to get the current clock as written by the driver in the > timestamp field of the pkt mbuf when timestamp offloading is enabled. I think the main use of it is to get the device clock conversion co-eff to = be able to translate the mbuf raw timestamp to a local synced time value.=20 >=20 > This function was missing to allow users to convert that RX timestamp fie= ld to > real time without the complexity of the rte_timesync* facility. One can > derivate the clock frequency by calling twice read_clock and then keep a > common time base. >=20 > Signed-off-by: Tom Barbette > --- > doc/guides/nics/features.rst | 1 + > lib/librte_ethdev/rte_ethdev.c | 13 +++++++++++++ > lib/librte_ethdev/rte_ethdev.h | 23 +++++++++++++++++++++++ > lib/librte_ethdev/rte_ethdev_core.h | 6 ++++++ > lib/librte_ethdev/rte_ethdev_version.map | 1 + > lib/librte_mbuf/rte_mbuf.h | 2 ++ > 6 files changed, 46 insertions(+) >=20 > diff --git a/doc/guides/nics/features.rst b/doc/guides/nics/features.rst = index > d3f904839..45484a30f 100644 > --- a/doc/guides/nics/features.rst > +++ b/doc/guides/nics/features.rst > @@ -602,6 +602,7 @@ Supports Timestamp. > * **[provides] mbuf**: ``mbuf.ol_flags:PKT_RX_TIMESTAMP``. > * **[provides] mbuf**: ``mbuf.timestamp``. > * **[provides] rte_eth_dev_info**: > ``rx_offload_capa,rx_queue_offload_capa: > DEV_RX_OFFLOAD_TIMESTAMP``. > +* **[implements] eth_dev_ops**: ``read_clock``. >=20 > .. _nic_features_macsec_offload: >=20 > diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethde= v.c > index 5f858174b..48e8218b2 100644 > --- a/lib/librte_ethdev/rte_ethdev.c > +++ b/lib/librte_ethdev/rte_ethdev.c > @@ -4124,6 +4124,19 @@ rte_eth_timesync_write_time(uint16_t port_id, > const struct timespec *timestamp) > timestamp)); > } >=20 > +int > +rte_eth_read_clock(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->read_clock, - > ENOTSUP); > + return eth_err(port_id, (*dev->dev_ops->read_clock)(dev, > + timestamp)); > +} > + > int > rte_eth_dev_get_reg_info(uint16_t port_id, struct rte_dev_reg_info *info= ) > { diff --git a/lib/librte_ethdev/rte_ethdev.h > b/lib/librte_ethdev/rte_ethdev.h index 1960f3a2d..6e3a48308 100644 > --- a/lib/librte_ethdev/rte_ethdev.h > +++ b/lib/librte_ethdev/rte_ethdev.h > @@ -3642,6 +3642,29 @@ 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 > +/** > + * @warning > + * @b EXPERIMENTAL: this API may change without prior notice. > + * > + * Read the current clock counter of an Ethernet device > + * > + * This returns the current raw clock value of an Ethernet device. > + * The value returned here is from the same clock than the one > + * filling timestamp field of RX packets. Therefore it can be used > + * to compute a precise conversion of the device clock to the real time. I would add in the documentation of the function the heuristics to get the = conversion co-eff. > + * > + * @param port_id > + * The port identifier of the Ethernet device. > + * @param time > + * Pointer to the uint64_t that holds the raw clock value. > + * > + * @return > + * - 0: Success. > + * - -ENODEV: The port ID is invalid. > + * - -ENOTSUP: The function is not supported by the Ethernet driver. > + */ > +int __rte_experimental rte_eth_read_clock(uint16_t port_id, uint64_t > +*time); > + > /** > * Config l2 tunnel ether type of an Ethernet device for filtering speci= fic > * tunnel packets by ether type. > diff --git a/lib/librte_ethdev/rte_ethdev_core.h > b/lib/librte_ethdev/rte_ethdev_core.h > index 8f03f83f6..86806b3eb 100644 > --- a/lib/librte_ethdev/rte_ethdev_core.h > +++ b/lib/librte_ethdev/rte_ethdev_core.h > @@ -322,6 +322,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_read_clock)(struct rte_eth_dev *dev, > + uint64_t *timestamp); > +/**< @internal Function used to get the current value of the device > +clock. */ > + > typedef int (*eth_get_reg_t)(struct rte_eth_dev *dev, > struct rte_dev_reg_info *info); > /**< @internal Retrieve registers */ > @@ -496,6 +500,8 @@ 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_read_clock read_clock; > + > eth_xstats_get_by_id_t xstats_get_by_id; > /**< Get extended device statistic values by ID. */ > eth_xstats_get_names_by_id_t xstats_get_names_by_id; diff --git > a/lib/librte_ethdev/rte_ethdev_version.map > b/lib/librte_ethdev/rte_ethdev_version.map > index 92ac3de25..12d6c3c1d 100644 > --- a/lib/librte_ethdev/rte_ethdev_version.map > +++ b/lib/librte_ethdev/rte_ethdev_version.map > @@ -249,6 +249,7 @@ EXPERIMENTAL { > rte_eth_switch_domain_free; > rte_flow_conv; > rte_flow_expand_rss; > + rte_eth_read_clock; > rte_mtr_capabilities_get; > rte_mtr_create; > rte_mtr_destroy; > diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h inde= x > 3dbc6695e..4ceefa913 100644 > --- a/lib/librte_mbuf/rte_mbuf.h > +++ b/lib/librte_mbuf/rte_mbuf.h > @@ -605,6 +605,8 @@ struct rte_mbuf { >=20 > /** 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. > */ > uint64_t timestamp; >=20 Other than that, on the RFC - Acked-by: Shahaf Shluer . Let's see next the full implementation.=20 > -- > 2.17.1