Add rte_eth_read_clock API
Subsystems (2)
v3 cover Add rte_eth_read_clock API
Some NICs allow to timestamp packets, but do not support the full PTP synchronization process. Hence, the value set in the mbuf timestamp field is only the raw value of an internal clock.
To make sense of this value, one at least needs to be able to query the current hardware clock value. This patch series adds a new API to do so, rte_eth_read_clock. As with the TSC, from there
a frequency can be derieved by querying multiple time the current value of the internal clock with some known delay between the queries (example provided in the API doc).
This patch series adds support of read_clock for MLX5.
An example app is provided in the rxtx_callback application.
It has been updated to display, on top of the software latency
in cycles, the total latency since the packet was received in hardware. The API is used to compute a delta in the TX callback. The raw amount of ticks is converted to cycles using a variation of the technique describe above.
Aside from offloading timestamping, which relieve the software from a few operations, this allows to get much more precision when studying the source of the latency in a system.
Eg. in our 100G, CX5 setup the rxtx callback application shows SW latency is around 74 cycles (TSC is 3.2Ghz), but the latency including NIC processing, PCIe, and queuing is around 196 cycles.
One may think at first this API is overlapping with te_eth_timesync_read_time. rte_eth_timesync_read_time is clearly identified as part of a set of functions to use PTP synchronization.
The device raw clock is not "sync" in any way. More importantly, the returned value is not a timeval, but an amount of ticks. We could have a cast-based solution, but on top of being an ugly solution, some people seeing the timeval type of rte_eth_timesync_read_time could use it blindly.
Change in v2:
- Rebase on current master
Change in v3:
- Address comments from Ferruh Yigit
Tom Barbette (3):
rte_ethdev: Add API function to read dev clock
mlx5: Implement support for read_clock
rxtx_callbacks: Add support for HW timestamp
doc/guides/nics/features.rst | 1 + doc/guides/sample_app_ug/rxtx_callbacks.rst | 9 ++- drivers/net/mlx5/mlx5.c | 1 + drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_ethdev.c | 30 +++++++ drivers/net/mlx5/mlx5_glue.c | 8 ++ drivers/net/mlx5/mlx5_glue.h | 2 + examples/rxtx_callbacks/Makefile | 3 + examples/rxtx_callbacks/main.c | 87 ++++++++++++++++++++- examples/rxtx_callbacks/meson.build | 3 + lib/librte_ethdev/rte_ethdev.c | 13 +++ lib/librte_ethdev/rte_ethdev.h | 45 +++++++++++ lib/librte_ethdev/rte_ethdev_core.h | 6 ++ lib/librte_ethdev/rte_ethdev_version.map | 2 + lib/librte_mbuf/rte_mbuf.h | 2 + 15 files changed, 208 insertions(+), 5 deletions(-)
Signature · 1 line
2.17.1
PATCH v3 1/3 rte_ethdev: Add API function to read dev clock
Add rte_eth_read_clock to read the raw clock of a devide.
The main use is to get the device clock conversion co-efficients to be able to translate the raw clock of the timestamp field of the pkt mbuf to a local synced time value.
This function was missing to allow users to convert the RX timestamp field 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.
--- doc/guides/nics/features.rst | 1 + lib/librte_ethdev/rte_ethdev.c | 13 +++++++ lib/librte_ethdev/rte_ethdev.h | 45 ++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_core.h | 6 ++++ lib/librte_ethdev/rte_ethdev_version.map | 2 ++ lib/librte_mbuf/rte_mbuf.h | 2 ++ 6 files changed, 69 insertions(+)
doc/guides/nics/features.rst +1 -0
@@ -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``. +* **[related] eth_dev_ops**: ``read_clock``. .. _nic_features_macsec_offload:
lib/librte_ethdev/rte_ethdev.c +13 -0
@@ -4170,6 +4170,19 @@ rte_eth_timesync_write_time(uint16_t port_id, const struct timespec *timestamp) timestamp)); } +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 = &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) {
lib/librte_ethdev/rte_ethdev.h +45 -0
51 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev_core.h +6 -0
@@ -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 */ +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. */ +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;
lib/librte_ethdev/rte_ethdev_version.map +2 -0
@@ -253,10 +253,12 @@ EXPERIMENTAL { rte_eth_dev_rx_intr_ctl_q_get_fd; rte_eth_find_next_of; rte_eth_find_next_sibling; + rte_eth_read_clock; rte_eth_switch_domain_alloc; 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;
lib/librte_mbuf/rte_mbuf.h +2 -0
@@ -668,6 +668,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. */ uint64_t timestamp;
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v3 1/3] rte_ethdev: Add API function to read dev clock
Quoted 1 line · Tom Barbette
Add
rte_eth_read_clockto read the raw clock of a devide.
Typo above "devide"
Quoted 5 lines
The main use is to get the device clock conversion co-efficients to be able to translate the raw clock of the timestamp field of the pkt mbuf to a local synced time value.
This function was missing to allow users to convert the RX timestamp field
RX -> Rx
Quoted 5 lines
to real time without the complexity of the rte_timesync* facility. One can derivate the clock frequency by calling twice
read_clockand then keep a common time base.Signed-off-by Tom Barbette <[email protected]>
[snip]
Quoted 9 lines
lib/librte_ethdev/rte_ethdev.c +1
-0@@ -4170,6 +4170,19 @@ rte_eth_timesync_write_time(uint16_t port_id, const struct timespec *timestamp) timestamp)); } +int
lib/librte_ethdev/rte_ethdev.c rte_eth_timesync_write_time(uint16_t port_id, const struct timespec *timestamp) · line 4183
Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10
-0+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 = &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));
Why timestamp on the next line?
Quoted 12 lines
lib/librte_ethdev/rte_ethdev.c +2
-0+} +int rte_eth_dev_get_reg_info (uint16_t port_id,struct rte_dev_reg_info *info) {lib/librte_ethdev/rte_ethdev.h +0
-0@@ -3793,6 +3793,51 @@ 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);
lib/librte_ethdev/rte_ethdev.h int rte_eth_timesync_read_time(uint16_t port_id, struct timespec *time); · line 3804
Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +9
-0+/** +* @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
RX -> Rx
Quoted 39 lines
lib/librte_ethdev/rte_ethdev.h +36
-0+* to compute a precise conversion of the device clock to the real time. +* +* E.g, a simple heuristic to derivate the frequency would be: +* uint64_t start, end; +* rte_eth_read_clock(port, start); +* rte_delay_ms(100); +* rte_eth_read_clock(port, end); +* double freq = (end - start) * 10; +* +* Compute a common reference with: +* uint64_t base_time_sec = current_time(); +* uint64_t base_clock; +* rte_eth_read_clock(port, base_clock); +* +* Then, convert the raw mbuf timestamp with: +* base_time_sec + (double)(mbuf->timestamp - base_clock) / freq; +* +* This simple example will not provide a very good accuracy. One must +* at least measure multiple times the frequency and do a regression. +* To avoid deviation from the system time, the common reference can +* be repeated from time to time. The integer division can also be +* converted by a multiplication and a shift for better performance. +* +* @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 *timestamp); +/** * Config l2 tunnel ether type of an Ethernet device for filtering specific * tunnel packets by ether type.
[snip]
Quoted 6 lines
eth_xstats_get_names_by_id_txstats_get_names_by_id;lib/librte_ethdev/rte_ethdev_version.map +0
-0
lib/librte_ethdev/rte_ethdev_version.map EXPERIMENTAL { · line 261
Quoted 9 lines
lib/librte_ethdev/rte_ethdev_version.map +2
-0@@ -253,10 +253,12 @@ EXPERIMENTAL { rte_eth_dev_rx_intr_ctl_q_get_fd; rte_eth_find_next_of; rte_eth_find_next_sibling; + rte_eth_read_clock; rte_eth_switch_domain_alloc; rte_eth_switch_domain_free; rte_flow_conv; rte_flow_expand_rss; + rte_eth_read_clock;
Dup
[snip]
Re: [dpdk-dev] [PATCH v3 1/3] rte_ethdev: Add API function to read dev clock
In reply to Tom BarbetteQuoted 95 lines · Tom Barbette
Add
rte_eth_read_clockto read the raw clock of a devide.The main use is to get the device clock conversion co-efficients to be able to translate the raw clock of the timestamp field of the pkt mbuf to a local synced time value.
This function was missing to allow users to convert the RX timestamp field to real time without the complexity of the rte_timesync* facility. One can derivate the clock frequency by calling twice
read_clockand then keep a common time base.Signed-off-by Tom Barbette <[email protected]>---
doc/guides/nics/features.rst | 1 + lib/librte_ethdev/rte_ethdev.c | 13 +++++++ lib/librte_ethdev/rte_ethdev.h | 45 ++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_core.h | 6 ++++ lib/librte_ethdev/rte_ethdev_version.map | 2 ++ lib/librte_mbuf/rte_mbuf.h | 2 ++ 6 files changed, 69 insertions(+)doc/guides/nics/features.rst +1
-0@@ -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``. +* **[related] eth_dev_ops**: ``read_clock``...
_nic_features_macsec_offload:lib/librte_ethdev/rte_ethdev.c +13
-0@@ -4170,6 +4170,19 @@ rte_eth_timesync_write_time(uint16_t port_id, const struct timespec *timestamp) timestamp)); } +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 = &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){lib/librte_ethdev/rte_ethdev.h +26
-0@@ -3793,6 +3793,51 @@ 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); +/** +* @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. +* +* E.g, a simple heuristic to derivate the frequency would be: +* uint64_t start, end; +* rte_eth_read_clock(port, start); +* rte_delay_ms(100); +* rte_eth_read_clock(port, end); +* double freq = (end - start) * 10; +* +* Compute a common reference with: +* uint64_t base_time_sec = current_time(); +* uint64_t base_clock; +* rte_eth_read_clock(port, base_clock); +* +* Then, convert the raw mbuf timestamp with: +* base_time_sec + (double)(mbuf->timestamp - base_clock) / freq; +*
lib/librte_ethdev/rte_ethdev.h int rte_eth_timesync_read_time(uint16_t port_id, struct timespec *time); · line 3831
Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +10
-0+* This simple example will not provide a very good accuracy. One must +* at least measure multiple times the frequency and do a regression. +* To avoid deviation from the system time, the common reference can +* be repeated from time to time. The integer division can also be +* converted by a multiplication and a shift for better performance. +* +* @param port_id +* The port identifier of the Ethernet device. +* @param time +* Pointer to the uint64_t that holds the raw clock value.
What is a raw clock value? It took me a bit to find that it is in nano-seconds need to document that point.
lib/librte_ethdev/rte_ethdev.h int rte_eth_timesync_read_time(uint16_t port_id, struct timespec *time); · line 3839
Quoted 8 lines
lib/librte_ethdev/rte_ethdev.h +8
-0+* +* @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 *timestamp);
Using timestamp variable is not very descriptive and some other name needs to be used. Also in the driver it is called *clock.
Another question is why does this routine not perform the looping/delaying and calling read_clock and then return frequency instead. If you want a timestamp reading function then this one is not being described that way and I would think it should be done someplace else or should be.
Quoted 50 lines
lib/librte_ethdev/rte_ethdev.h +1
-0+/** * Config l2 tunnel ether type of an Ethernet device for filtering specific * tunnel packets by ether type. lib/librte_ethdev/rte_ethdev_core.h +6
-0@@ -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 */ +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. */ +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;lib/librte_ethdev/rte_ethdev_version.map +2
-0@@ -253,10 +253,12 @@ EXPERIMENTAL { rte_eth_dev_rx_intr_ctl_q_get_fd; rte_eth_find_next_of; rte_eth_find_next_sibling; + rte_eth_read_clock; rte_eth_switch_domain_alloc; 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;lib/librte_mbuf/rte_mbuf.h +0
-0
lib/librte_mbuf/rte_mbuf.h struct rte_mbuf { · line 672
Quoted 5 lines
lib/librte_mbuf/rte_mbuf.h +2
-0@@ -668,6 +668,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.
The message here is not a good place for this detail, I would put it in the function call doc above.
Quoted 6 lines
lib/librte_mbuf/rte_mbuf.h +0
-0*/ uint64_t timestamp;Signature · 1 line
2.17.1
Regards,
Keith
Re: [dpdk-dev] [PATCH v3 1/3] rte_ethdev: Add API function to read dev clock
@Andrew I applied your comments. Thanks.
Quoted 1 line · Keith
What is a raw clock value? It took me a bit to find that it is in nano-seconds need to document that point.
It is not in nanosecond, it has no units. Finding the relation between the device clock and the real time is the whole point of this API.
Quoted 1 line
Using timestamp variable is not very descriptive and some other name needs to be used. Also in the driver it is called *clock.
The problem is that the "timestamp offload" feature filling the timestamp field of the pktmbuf is already badly named as it is given without time unit. Both of them are not timestamp but raw "clock" values, a number of ticks at an unknown frequency, with an unknow time base (ie is it the number of ticks since boot? Device is up? 1/1/1970?). One solution would be to have an union in the pktmbuf, changing the timestamp field into a "clock" or "timestamp" field. But it's a bit overkill.
I propose to change the read_clock API to reference "clock" instead of timestamp everywhere.
Quoted 1 line
Another question is why does this routine not perform the looping/delaying and calling
read_clockand then return frequency instead. If you want a timestamp reading function then this one is not being described that way and I would think it should be done someplace else or should be.
The frequency is one thing, and would allow to give a relative time in second between packets. In practice though, we change the frequency (as Linux does regarding the TSC ticks) to catch up corrections applied by NTP on the source clock.
The second thing is the time reference, to convert the clock time (of the packets) to the current wall time. One may want to use the monotonic clock, the real clock (we do follow both). Or no system clock at all and directly follow an NTP source. The point is, having a function to give the frequency is not enough. One can derive the frequency and the time reference with this API. I could write a helper in a second step to get the frequency out of read_clock. But the time reference implies timers, choosing a source, and stuff we don't want here, I think...
Quoted 6 lines
lib/librte_mbuf/rte_mbuf.h struct rte_mbuf { · line 672
Quoted 4 lines
/** Valid if PKT_RX_TIMESTAMP is set. The unit and time reference * are not normalized but are always the same for a given port.lib/librte_mbuf/rte_mbuf.h +2
-0+* Some devices allow to query rte_eth_read_clock that will return the +* current device timestamp. The message here is not a good place for this detail, I would put it in the function call doc above.
I can remove these lines, but with read_clock referencing only clock I feel like it's even more needed. Someone reading the doc will see "oh, I can use timestamp offloading to get precise timing of when my packets were received, great ! But it has no unit and no reference... What do I do with that?". It miss the last step "how I see... I can look at rte_eth_read_clock documentation to read more about conversion."
Thanks !
Tom
PATCH v3 2/3 mlx5: Implement support for read_clock
In reply to Tom BarbetteImplements support for read_clock for the mlx5 driver. mlx5 supports hardware timestamp offload, setting packets timestamp field to the device clock. rte_eth_read_clock allows to read the device's current clock value and therefore compare values on similar time base.
See rxtx_callbacks for an example.
--- drivers/net/mlx5/mlx5.c | 1 + drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_ethdev.c | 30 ++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_glue.c | 8 ++++++++ drivers/net/mlx5/mlx5_glue.h | 2 ++ 5 files changed, 42 insertions(+)
drivers/net/mlx5/mlx5.c +1 -0
@@ -748,6 +748,7 @@ const struct eth_dev_ops mlx5_dev_ops = { .xstats_get_names = mlx5_xstats_get_names, .fw_version_get = mlx5_fw_version_get, .dev_infos_get = mlx5_dev_infos_get, + .read_clock = mlx5_read_clock, .dev_supported_ptypes_get = mlx5_dev_supported_ptypes_get, .vlan_filter_set = mlx5_vlan_filter_set, .rx_queue_setup = mlx5_rx_queue_setup,
drivers/net/mlx5/mlx5.h +1 -0
@@ -403,6 +403,7 @@ int mlx5_set_flags(struct rte_eth_dev *dev, unsigned int keep, unsigned int flags);int mlx5_dev_configure (struct rte_eth_dev *dev);void mlx5_dev_infos_get (struct rte_eth_dev *dev,struct rte_eth_dev_info *info); +int mlx5_read_clock (struct rte_eth_dev *dev,uint64_t *time);int mlx5_fw_version_get (struct rte_eth_dev *dev,char *fw_ver,size_t fw_size);const uint32_t *mlx5_dev_supported_ptypes_get (struct rte_eth_dev *dev);int mlx5_link_update (struct rte_eth_dev *dev,int wait_to_complete);
drivers/net/mlx5/mlx5_ethdev.c +30 -0
@@ -564,6 +564,36 @@ mlx5_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info) } } +/** +* Get device current raw clock counter +* +* @param dev +* Pointer to Ethernet device structure. +* @param[out] time +* Current raw clock counter of the device. +* +* @return +* 0 if the clock has correctly been read +* The value of errno in case of error +*/ +int +mlx5_read_clock (struct rte_eth_dev *dev,uint64_t *clock) +{ +struct mlx5_priv *priv = dev->data->dev_private; +struct ibv_context *ctx = priv->sh->ctx; +struct ibv_values_ex values; +int err =0 ; + + values.comp_mask =IBV_VALUES_MASK_RAW_CLOCK ; + err = mlx5_glue->query_rt_values_ex (ctx, &values); +if (err !=0 ) { +DRV_LOG (WARNING ,"Could not query the clock !" ); +return err; + } + *clock = values.raw_clock.tv_nsec; +return 0 ; +} +/** * Get firmware version of a device. *
drivers/net/mlx5/mlx5_glue.c +8 -0
@@ -87,6 +87,13 @@ mlx5_glue_query_device_ex(struct ibv_context *context,return ibv_query_device_ex (context, input, attr); } +static int +mlx5_glue_query_rt_values_ex (struct ibv_context *context, +struct ibv_values_ex *values) +{ +return ibv_query_rt_values_ex (context, values); +} +static int mlx5_glue_query_port (struct ibv_context *context,uint8_t port_num,struct ibv_port_attr *port_attr)
@@ -834,6 +841,7 @@ const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue){ .close_device = mlx5_glue_close_device, .query_device = mlx5_glue_query_device, .query_device_ex = mlx5_glue_query_device_ex, + .query_rt_values_ex = mlx5_glue_query_rt_values_ex, .query_port = mlx5_glue_query_port, .create_comp_channel = mlx5_glue_create_comp_channel, .destroy_comp_channel = mlx5_glue_destroy_comp_channel,
drivers/net/mlx5/mlx5_glue.h +2 -0
@@ -83,6 +83,8 @@ struct mlx5_glue {int (*query_device_ex)(struct ibv_context *context,const struct ibv_query_device_ex_input *input,struct ibv_device_attr_ex *attr); +int (*query_rt_values_ex)(struct ibv_context *context, +struct ibv_values_ex *values);int (*query_port)(struct ibv_context *context,uint8_t port_num,struct ibv_port_attr *port_attr);struct ibv_comp_channel *(*create_comp_channel)
Signature · 1 line
2.17.1
PATCH v3 3/3 rxtx_callbacks: Add support for HW timestamp
In reply to Tom BarbetteUse rxtx callback to demonstrate a way to use rte_eth_read_clock to convert the hardware timestamps to an amount of cycles.
This allows to get the amount of time the packet spent since its entry in the device. While the regular latency only shows the latency from when it entered the software stack.
--- doc/guides/sample_app_ug/rxtx_callbacks.rst | 9 ++- examples/rxtx_callbacks/Makefile | 3 + examples/rxtx_callbacks/main.c | 87 ++++++++++++++++++++- examples/rxtx_callbacks/meson.build | 3 + 4 files changed, 97 insertions(+), 5 deletions(-)
doc/guides/sample_app_ug/rxtx_callbacks.rst +8 -1
@@ -13,6 +13,10 @@ In the sample application a user defined callback is applied to all received packets to add a timestamp. A separate callback is applied to all packets prior to transmission to calculate the elapsed time, in CPU cycles. +If hardware timestamping is supported by the NIC, the sample application will +also display the average latency since the packet was timestamped in hardware, +on top of the latency since the packet was received and processed by the RX +callback. Compiling the Application -------------------------
@@ -36,7 +40,10 @@ To run the example in a ``linux`` environment: .. code-block:: console - ./build/rxtx_callbacks -l 1 -n 4 + ./build/rxtx_callbacks -l 1 -n 4 -- [-t] + +Use -t to enable hardware timestamping. If not supported by the NIC, an error +will be displayed. Refer to *DPDK Getting Started Guide* for general information on running applications and the Environment Abstraction Layer (EAL) options.
examples/rxtx_callbacks/Makefile +3 -0
@@ -50,6 +50,9 @@ include $(RTE_SDK)/mk/rte.vars.mk CFLAGS += $(WERROR_FLAGS) +# rte_eth_read_clock is experimental +CFLAGS += -DALLOW_EXPERIMENTAL_API + # workaround for a gcc bug with noreturn attribute # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603 ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y)
examples/rxtx_callbacks/main.c +83 -4
159 lines not on this page · raw message
examples/rxtx_callbacks/meson.build +3 -0
@@ -6,6 +6,9 @@ # To build this example as a standalone application with an already-installed # DPDK instance, use 'make' +#rte_eth_read_clock is experimental +allow_experimental_apis = true + sources = files( 'main.c' )
Signature · 1 line
2.17.1