remove mbuf timestamp
cover remove mbuf timestamp
The mbuf field timestamp was announced to be removed for three reasons:
- a dynamic field already exist, used for Tx only
- this field always used 8 bytes even if unneeded
- this field is in the first half (cacheline) of mbuf
After this series the dynamic field timestamp is used for both Rx and Tx with separate dynamic flags to distinguish when the value is meaningful without resetting the field during forwarding.
As a consequence, 8 bytes can be re-allocated to dynamic fields, and bonus...
the mempool pointer can be promoted to the first half of mbuf!
This mbuf layout change is important to allow adding more features (consuming more dynamic fields) during the next year and can bring some performance improvement.
Thomas Monjalon (15):
eventdev: remove software Rx timestamp
mbuf: add Rx timestamp dynamic flag
ethdev: register mbuf field and flags for timestamp
latency: switch timestamp to dynamic mbuf field net/ark: switch timestamp to dynamic mbuf field net/dpaa2: switch timestamp to dynamic mbuf field net/mlx5: fix dynamic mbuf offset lookup check net/mlx5: switch timestamp to dynamic mbuf field net/nfb: switch timestamp to dynamic mbuf field net/octeontx2: switch timestamp to dynamic mbuf field net/pcap: switch timestamp to dynamic mbuf field app/testpmd: switch timestamp to dynamic mbuf field examples/rxtx_callbacks: switch timestamp to dynamic field
mbuf: remove deprecated timestamp field
mbuf: move pool pointer in hotter first half
app/test-pmd/config.c | 38 ---------- app/test-pmd/util.c | 39 ++++++++++- app/test/test_mbuf.c | 1 - doc/guides/nics/mlx5.rst | 5 +- .../prog_guide/event_ethernet_rx_adapter.rst | 6 +- doc/guides/rel_notes/deprecation.rst | 6 -- doc/guides/rel_notes/release_20_11.rst | 4 ++ drivers/net/ark/ark_ethdev.c | 23 ++++++ drivers/net/ark/ark_ethdev_rx.c | 10 ++- drivers/net/dpaa2/dpaa2_ethdev.c | 20 ++++++ drivers/net/dpaa2/dpaa2_ethdev.h | 2 + drivers/net/dpaa2/dpaa2_rxtx.c | 25 +++++-- drivers/net/mlx5/mlx5_rxq.c | 36 ++++++++++ drivers/net/mlx5/mlx5_rxtx.c | 8 +-- drivers/net/mlx5/mlx5_rxtx.h | 19 +++++ drivers/net/mlx5/mlx5_rxtx_vec_altivec.h | 41 +++++------ drivers/net/mlx5/mlx5_rxtx_vec_neon.h | 43 ++++++------ drivers/net/mlx5/mlx5_rxtx_vec_sse.h | 35 +++++----- drivers/net/mlx5/mlx5_trigger.c | 2 +- drivers/net/mlx5/mlx5_txq.c | 2 +- drivers/net/nfb/nfb_rx.c | 23 +++++- drivers/net/nfb/nfb_rx.h | 18 +++-- drivers/net/octeontx2/otx2_ethdev.c | 33 +++++++++ drivers/net/octeontx2/otx2_rx.h | 19 ++++- drivers/net/octeontx2/version.map | 7 ++ drivers/net/pcap/rte_eth_pcap.c | 29 +++++++- examples/rxtx_callbacks/main.c | 12 +++- lib/librte_ethdev/rte_ethdev.c | 70 +++++++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 13 +++- .../rte_event_eth_rx_adapter.c | 11 --- .../rte_event_eth_rx_adapter.h | 6 +- lib/librte_kni/rte_kni_common.h | 3 +- lib/librte_latencystats/rte_latencystats.c | 48 +++++++++++-- lib/librte_mbuf/rte_mbuf.c | 2 - lib/librte_mbuf/rte_mbuf.h | 1 - lib/librte_mbuf/rte_mbuf_core.h | 15 +--- lib/librte_mbuf/rte_mbuf_dyn.h | 11 +-- 37 files changed, 502 insertions(+), 184 deletions(-)
Signature · 1 line
2.28.0
PATCH 1/15 eventdev: remove software Rx timestamp
This a revert of the commit 569758758dcd ("eventdev: add Rx timestamp"). If the Rx timestamp is not configured on the ethdev port, there is no reason to set one.
Also the accuracy of the timestamp was bad because set at a late stage. Anyway there is no trace of the usage of this timestamp.
--- doc/guides/prog_guide/event_ethernet_rx_adapter.rst | 6 +----- lib/librte_eventdev/rte_event_eth_rx_adapter.c | 11 ----------- lib/librte_eventdev/rte_event_eth_rx_adapter.h | 6 +----- 3 files changed, 2 insertions(+), 21 deletions(-)
doc/guides/prog_guide/event_ethernet_rx_adapter.rst +1 -5
@@ -12,11 +12,7 @@ be supported in hardware or require a software thread to receive packets from the ethdev port using ethdev poll mode APIs and enqueue these as events to the event device using the eventdev API. Both transfer mechanisms may be present on the same platform depending on the particular combination of the ethdev and -the event device. For SW based packet transfer, if the mbuf does not have a -timestamp set, the adapter adds a timestamp to the mbuf using -rte_get_tsc_cycles(), this provides a more accurate timestamp as compared to -if the application were to set the timestamp since it avoids event device -schedule latency. +the event device. The Event Ethernet Rx Adapter library is intended for the application code to configure both transfer mechanisms using a common API. A capability API allows
lib/librte_eventdev/rte_event_eth_rx_adapter.c +0 -11
@@ -763,7 +763,6 @@ rxa_buffer_mbufs(struct rte_event_eth_rx_adapter *rx_adapter,uint32_t rss_mask;uint32_t rss;int do_rss; -uint64_t ts;uint16_t nb_cb;uint16_t dropped;
@@ -771,16 +770,6 @@ rxa_buffer_mbufs(struct rte_event_eth_rx_adapter *rx_adapter, rss_mask = ~(((m->ol_flags &PKT_RX_RSS_HASH ) !=0 ) -1 ); do_rss = !rss_mask && !eth_rx_queue_info->flow_id_mask; -if ((m->ol_flags &PKT_RX_TIMESTAMP ) ==0 ) { - ts =rte_get_tsc_cycles (); -for (i =0 ; i < num; i++) { - m = mbufs[i]; - - m->timestamp = ts; - m->ol_flags |=PKT_RX_TIMESTAMP ; - } - } -for (i =0 ; i < num; i++) { m = mbufs[i];
lib/librte_eventdev/rte_event_eth_rx_adapter.h +1 -5
@@ -21,11 +21,7 @@* * The adapter uses a EAL service core function for SW based packet transfer * and uses the eventdev PMD functions to configure HW based packet transfer -* between the ethernet device and the event device. For SW based packet -* transfer, if the mbuf does not have a timestamp set, the adapter adds a -* timestamp to the mbuf using rte_get_tsc_cycles(), this provides a more -* accurate timestamp as compared to if the application were to set the time -* stamp since it avoids event device schedule latency. +* between the ethernet device and the event device. * * The ethernet Rx event adapter's functions are: * - rte_event_eth_rx_adapter_create_ext()
Signature · 1 line
2.28.0
PATCH 2/15 mbuf: add Rx timestamp dynamic flag
In reply to Thomas MonjalonThere is already a dynamic field for timestamp,
used only for Tx scheduling, thanks to the dedicated flag. The same field can be used for Rx timestamp filled by drivers. The only missing part to get rid of the static timestamp field was to declare a new dynamic flag for Rx usage.
After migrating all Rx timestamp usages, it will be possible to remove the deprecated timestamp field.
--- lib/librte_mbuf/rte_mbuf_dyn.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
lib/librte_mbuf/rte_mbuf_dyn.h +5 -5
@@ -258,14 +258,14 @@ void rte_mbuf_dyn_dump(FILE *out);* timestamp. The dynamic Tx timestamp flag tells whether the field contains * actual timestamp value for the packets being sent, this value can be * used by PMD to schedule packet sending. -* -* After PKT_RX_TIMESTAMP flag and fixed timestamp field deprecation -* and obsoleting, the dedicated Rx timestamp flag is supposed to be -* introduced and the shared dynamic timestamp field will be used -* to handle the timestamps on receiving datapath as well. */ #define RTE_MBUF_DYNFIELD_TIMESTAMP_NAME "rte_dynfield_timestamp" +/** +* Indicate that the timestamp field in the mbuf was filled by the driver. +*/ +#define RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME "rte_dynflag_rx_timestamp" +/** * When PMD sees the RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME flag set on the * packet being sent it tries to synchronize the time of packet appearing
Signature · 1 line
2.28.0
Re: [dpdk-dev] [PATCH 02/15] mbuf: add Rx timestamp dynamic flag
Quoted 10 lines · Thomas Monjalon
There is already a dynamic field for timestamp,
used only for Tx scheduling, thanks to the dedicated flag. The same field can be used for Rx timestamp filled by drivers. The only missing part to get rid of the static timestamp field was to declare a new dynamic flag for Rx usage.After migrating all Rx timestamp usages, it will be possible to remove the deprecated timestamp field.
Signed-off-by Thomas Monjalon <[email protected]>
Ajit Khaparde
Acked-byRe: [dpdk-dev] [PATCH 02/15] mbuf: add Rx timestamp dynamic flag
Quoted 8 lines · Andrew Rybchenko
Quoted 6 lines · Thomas Monjalon
There is already a dynamic field for timestamp,
used only for Tx scheduling, thanks to the dedicated flag. The same field can be used for Rx timestamp filled by drivers. The only missing part to get rid of the static timestamp field was to declare a new dynamic flag for Rx usage.
Quoted 6 lines
Quoted 4 lines
After migrating all Rx timestamp usages, it will be possible to remove the deprecated timestamp field.
Signed-off-by Thomas Monjalon <[email protected]>Acked-by Andrew Rybchenko <[email protected]>
Quoted 1 line
PATCH 3/15 ethdev: register mbuf field and flags for timestamp
In reply to Thomas MonjalonDuring port configure or queue setup, the offload flags DEV_RX_OFFLOAD_TIMESTAMP and DEV_TX_OFFLOAD_SEND_ON_TIMESTAMP trigger the registration of the related mbuf field and flags.
Previously, the Tx timestamp field and flag were registered in testpmd, as described in mlx5 guide.
For the general usage of Rx and Tx timestamps,
managing registrations inside ethdev is simpler and properly documented.
--- app/test-pmd/config.c | 38 ------------------ doc/guides/nics/mlx5.rst | 5 +-- lib/librte_ethdev/rte_ethdev.c | 70 ++++++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 9 ++++- lib/librte_mbuf/rte_mbuf_dyn.h | 1 + 5 files changed, 81 insertions(+), 42 deletions(-)
app/test-pmd/config.c +0 -38
@@ -3955,44 +3955,6 @@ show_tx_pkt_times(void)void set_tx_pkt_times (unsigned int *tx_times) { -uint16_t port_id; -int offload_found =0 ; -int offset; -int flag; - -static const struct rte_mbuf_dynfield desc_offs = { - .name =RTE_MBUF_DYNFIELD_TIMESTAMP_NAME , - .size =sizeof (uint64_t ), - .align = __alignof__(uint64_t ), - }; -static const struct rte_mbuf_dynflag desc_flag = { - .name =RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME , - }; - -RTE_ETH_FOREACH_DEV (port_id) { -struct rte_eth_dev_info dev_info = {0 }; -int ret; - - ret =rte_eth_dev_info_get (port_id, &dev_info); -if (ret ==0 && dev_info.tx_offload_capa & -DEV_TX_OFFLOAD_SEND_ON_TIMESTAMP ) { - offload_found =1 ; -break ; - } - } -if (!offload_found) { -printf ("No device supporting Tx timestamp scheduling found, " -"dynamic flag and field not registered\n" ); -return ; - } - offset =rte_mbuf_dynfield_register (&desc_offs); -if (offset <0 && rte_errno !=EEXIST ) -printf ("Dynamic timestamp field registration error: %d" , - rte_errno); - flag =rte_mbuf_dynflag_register (&desc_flag); -if (flag <0 && rte_errno !=EEXIST ) -printf ("Dynamic timestamp flag registration error: %d" , - rte_errno); tx_pkt_times_inter = tx_times[0 ]; tx_pkt_times_intra = tx_times[1 ]; }
doc/guides/nics/mlx5.rst +2 -3
@@ -237,9 +237,8 @@ Limitations ``txq_inline_max`` and ``txq_inline_mpw`` devargs keys. - To provide the packet send scheduling on mbuf timestamps the ``tx_pp`` - parameter should be specified, RTE_MBUF_DYNFIELD_TIMESTAMP_NAME and - RTE_MBUF_DYNFLAG_TIMESTAMP_NAME should be registered by application. - When PMD sees the RTE_MBUF_DYNFLAG_TIMESTAMP_NAME set on the packet + parameter should be specified. + When PMD sees the RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME set on the packet being sent it tries to synchronize the time of packet appearing on the wire with the specified packet timestamp. It the specified one is in the past it should be ignored, if one is in the distant future
lib/librte_ethdev/rte_ethdev.c +70 -0
100 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev.h +8 -1
@@ -1344,6 +1344,9 @@ struct rte_eth_conf {#define DEV_RX_OFFLOAD_VLAN_EXTEND 0x00000400#define DEV_RX_OFFLOAD_JUMBO_FRAME 0x00000800#define DEV_RX_OFFLOAD_SCATTER 0x00002000 +/** +* The mbuf field and flag are registered when the offload is configured. +*/ #define DEV_RX_OFFLOAD_TIMESTAMP 0x00004000#define DEV_RX_OFFLOAD_SECURITY 0x00008000#define DEV_RX_OFFLOAD_KEEP_CRC 0x00010000
@@ -1408,7 +1411,11 @@ struct rte_eth_conf {#define DEV_TX_OFFLOAD_IP_TNL_TSO 0x00080000/** Device supports outer UDP checksum */ #define DEV_TX_OFFLOAD_OUTER_UDP_CKSUM 0x00100000 -/** Device supports send on timestamp */ +/** +* Device sends on time read from RTE_MBUF_DYNFIELD_TIMESTAMP_NAME +* if RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME is set in ol_flags. +* The mbuf field and flag are registered when the offload is configured. +*/ #define DEV_TX_OFFLOAD_SEND_ON_TIMESTAMP 0x00200000/* * If new Tx offload capabilities are defined, they also must be
lib/librte_mbuf/rte_mbuf_dyn.h +1 -0
@@ -260,6 +260,7 @@ void rte_mbuf_dyn_dump(FILE *out);* used by PMD to schedule packet sending. */ #define RTE_MBUF_DYNFIELD_TIMESTAMP_NAME "rte_dynfield_timestamp" +typedef uint64_t rte_mbuf_timestamp_t ;/** * Indicate that the timestamp field in the mbuf was filled by the driver.
Signature · 1 line
2.28.0
Re: [dpdk-dev] [PATCH 03/15] ethdev: register mbuf field and flags for timestamp
Quoted 10 lines · Thomas Monjalon
During port configure or queue setup, the offload flags
DEV_RX_OFFLOAD_TIMESTAMPandDEV_TX_OFFLOAD_SEND_ON_TIMESTAMPtrigger the registration of the related mbuf field and flags.Previously, the Tx timestamp field and flag were registered in testpmd, as described in mlx5 guide.
For the general usage of Rx and Tx timestamps,
managing registrations inside ethdev is simpler and properly documented.Signed-off-by Thomas Monjalon <[email protected]>
A small note below, other than that
Quoted 4 lines
lib/librte_ethdev/rte_ethdev.c +0
-0
[snip]
Quoted 9 lines
lib/librte_ethdev/rte_ethdev.c +5
-0@@ -1232,6 +1233,59 @@ eth_dev_check_lro_pkt_size(uint16_t port_id, uint32_t config_size,return ret; } +static inline int +eth_dev_timestamp_mbuf_register (uint64_t rx_offloads,uint64_t tx_offloads) +{ +static const struct rte_mbuf_dynfield field_desc = { + .name =RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,
lib/librte_ethdev/rte_ethdev.c eth_dev_check_lro_pkt_size(uint16_t port_id, uint32_t config_size, · line 1250
Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10
-0+ .size = sizeof(rte_mbuf_timestamp_t), + .align = __alignof__(rte_mbuf_timestamp_t), + }; +static const struct rte_mbuf_dynflag rx_flag_desc = { + .name =RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME , + }; +static const struct rte_mbuf_dynflag tx_flag_desc = { + .name =RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME , + }; +static bool done_rx, done_tx;
I think we don't need these static flags. We can just repeat registeration request and it will simply lookup and return the same offset/flagbit as before.
[snip]
Re: [dpdk-dev] [PATCH 03/15] ethdev: register mbuf field and flags for timestamp
29/10/2020 11:08, Andrew Rybchenko:
Quoted 27 lines · Thomas Monjalon
Quoted 10 lines
During port configure or queue setup, the offload flags
DEV_RX_OFFLOAD_TIMESTAMPandDEV_TX_OFFLOAD_SEND_ON_TIMESTAMPtrigger the registration of the related mbuf field and flags.Previously, the Tx timestamp field and flag were registered in testpmd, as described in mlx5 guide.
For the general usage of Rx and Tx timestamps,
managing registrations inside ethdev is simpler and properly documented.Signed-off-by Thomas Monjalon <[email protected]>A small note below, other than that
Reviewed-by Andrew Rybchenko <[email protected]>Quoted 11 lines
lib/librte_ethdev/rte_ethdev.c +11
-0+static inline int +eth_dev_timestamp_mbuf_register (uint64_t rx_offloads,uint64_t tx_offloads) +{ +static const struct rte_mbuf_dynfield field_desc = { + .name =RTE_MBUF_DYNFIELD_TIMESTAMP_NAME , + .size =sizeof (rte_mbuf_timestamp_t), + .align = __alignof__(rte_mbuf_timestamp_t ), + }; +static const struct rte_mbuf_dynflag rx_flag_desc = { + .name =RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME , + };
Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c eth_dev_check_lro_pkt_size(uint16_t port_id, uint32_t config_size, · line 1250
Quoted 4 lines
lib/librte_ethdev/rte_ethdev.c +4
-0+static const struct rte_mbuf_dynflag tx_flag_desc = { + .name =RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME , + }; +static bool done_rx, done_tx;I think we don't need these static flags. We can just repeat registeration request and it will simply lookup and return the same offset/flagbit as before.
Absolutely.
I did it as a small optimization in control path.
I hesitated. Given it is only 2 booleans,
do you prefer with or without or no opinion?
Re: [dpdk-dev] [PATCH 03/15] ethdev: register mbuf field and flags for timestamp
Quoted 37 lines · Thomas Monjalon
29/10/2020 11:08, Andrew Rybchenko:
Quoted 27 lines · Thomas Monjalon
Quoted 10 lines
During port configure or queue setup, the offload flags
DEV_RX_OFFLOAD_TIMESTAMPandDEV_TX_OFFLOAD_SEND_ON_TIMESTAMPtrigger the registration of the related mbuf field and flags.Previously, the Tx timestamp field and flag were registered in testpmd, as described in mlx5 guide.
For the general usage of Rx and Tx timestamps,
managing registrations inside ethdev is simpler and properly documented.Signed-off-by Thomas Monjalon <[email protected]>A small note below, other than that
Reviewed-by Andrew Rybchenko <[email protected]>Quoted 11 lines
lib/librte_ethdev/rte_ethdev.c +11
-0+static inline int +eth_dev_timestamp_mbuf_register (uint64_t rx_offloads,uint64_t tx_offloads) +{ +static const struct rte_mbuf_dynfield field_desc = { + .name =RTE_MBUF_DYNFIELD_TIMESTAMP_NAME , + .size =sizeof (rte_mbuf_timestamp_t), + .align = __alignof__(rte_mbuf_timestamp_t ), + }; +static const struct rte_mbuf_dynflag rx_flag_desc = { + .name =RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME , + };Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c eth_dev_check_lro_pkt_size(uint16_t port_id, uint32_t config_size, · line 1250
Quoted 4 lines
lib/librte_ethdev/rte_ethdev.c +4
-0+static const struct rte_mbuf_dynflag tx_flag_desc = { + .name =RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME , + }; +static bool done_rx, done_tx;I think we don't need these static flags. We can just repeat registeration request and it will simply lookup and return the same offset/flagbit as before.
Quoted 6 lines
Absolutely.
I did it as a small optimization in control path.I hesitated. Given it is only 2 booleans,
do you prefer with or without or no opinion?
I'd prefer without it. It is always better without static variables if possible.
Re: [dpdk-dev] [PATCH 03/15] ethdev: register mbuf field and flags for timestamp
29/10/2020 11:33, Andrew Rybchenko:
Quoted 38 lines · Thomas Monjalon
Quoted 37 lines
29/10/2020 11:08, Andrew Rybchenko:
Quoted 35 lines · Thomas Monjalon
Quoted 10 lines
During port configure or queue setup, the offload flags
DEV_RX_OFFLOAD_TIMESTAMPandDEV_TX_OFFLOAD_SEND_ON_TIMESTAMPtrigger the registration of the related mbuf field and flags.Previously, the Tx timestamp field and flag were registered in testpmd, as described in mlx5 guide.
For the general usage of Rx and Tx timestamps,
managing registrations inside ethdev is simpler and properly documented.Signed-off-by Thomas Monjalon <[email protected]>A small note below, other than that
Reviewed-by Andrew Rybchenko <[email protected]>Quoted 5 lines
lib/librte_ethdev/rte_ethdev.c +5
-0+static inline int +eth_dev_timestamp_mbuf_register (uint64_t rx_offloads,uint64_t tx_offloads) +{ +static const struct rte_mbuf_dynfield field_desc = { + .name =RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,lib/librte_ethdev/rte_ethdev.c eth_dev_check_lro_pkt_size(uint16_t port_id, uint32_t config_size, · line 1250
Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10
-0+ .size = sizeof(rte_mbuf_timestamp_t), + .align = __alignof__(rte_mbuf_timestamp_t), + }; +static const struct rte_mbuf_dynflag rx_flag_desc = { + .name =RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME , + }; +static const struct rte_mbuf_dynflag tx_flag_desc = { + .name =RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME , + }; +static bool done_rx, done_tx;I think we don't need these static flags. We can just repeat registeration request and it will simply lookup and return the same offset/flagbit as before.
Quoted 8 lines
Quoted 6 lines
Absolutely.
I did it as a small optimization in control path.I hesitated. Given it is only 2 booleans,
do you prefer with or without or no opinion?I'd prefer without it. It is always better without static variables if possible.
I liked the naming of variables "todo" and "done"
but I will do what is preferred.
If nobody objects, I will remove this small (useless) optimization.
PATCH 4/15 latency: switch timestamp to dynamic mbuf field
In reply to Thomas MonjalonThe mbuf timestamp is moved to a dynamic field
in order to allow removal of the deprecated static field. The related mbuf flag is also replaced with the dynamic one.
--- lib/librte_latencystats/rte_latencystats.c | 48 +++++++++++++++++++--- 1 file changed, 43 insertions(+), 5 deletions(-)
lib/librte_latencystats/rte_latencystats.c +43 -5
@@ -8,7 +8,9 @@#include <math.h> #include <rte_string_fns.h> +#include <rte_bitops.h> #include <rte_mbuf.h> +#include <rte_mbuf_dyn.h> #include <rte_log.h> #include <rte_cycles.h> #include <rte_ethdev.h>
@@ -31,6 +33,16 @@ latencystat_cycles_per_ns(void)/* Macros for printing using RTE_LOG */ #define RTE_LOGTYPE_LATENCY_STATS RTE_LOGTYPE_USER1 +static uint64_t timestamp_dynflag; +static int timestamp_dynfield_offset =-1 ; + +static inline rte_mbuf_timestamp_t * +timestamp_dynfield (struct rte_mbuf *mbuf) +{ +return RTE_MBUF_DYNFIELD (mbuf, + timestamp_dynfield_offset, rte_mbuf_timestamp_t *); +} +static const char *MZ_RTE_LATENCY_STATS ="rte_latencystats" ;static int latency_stats_index;static uint64_t samp_intvl;
@@ -128,10 +140,10 @@ add_time_stamps(uint16_t pid __rte_unused, diff_tsc = now - prev_tsc; timer_tsc += diff_tsc; -if ((pkts[i]->ol_flags &PKT_RX_TIMESTAMP ) ==0 +if ((pkts[i]->ol_flags & timestamp_dynflag) ==0 && (timer_tsc >= samp_intvl)) { - pkts[i]->timestamp = now; - pkts[i]->ol_flags |=PKT_RX_TIMESTAMP ; + *timestamp_dynfield (pkts[i]) = now; + pkts[i]->ol_flags |= timestamp_dynflag; timer_tsc =0 ; } prev_tsc = now;
@@ -161,8 +173,8 @@ calc_latency(uint16_t pid __rte_unused, now =rte_rdtsc ();for (i =0 ; i < nb_pkts; i++) { -if (pkts[i]->ol_flags &PKT_RX_TIMESTAMP ) - latency[cnt++] = now - pkts[i]->timestamp; +if (pkts[i]->ol_flags & timestamp_dynflag) + latency[cnt++] = now - *timestamp_dynfield (pkts[i]); }rte_spinlock_lock (&glob_stats->lock);
@@ -204,6 +216,14 @@ int rte_latencystats_init(uint64_t app_samp_intvl, rte_latency_stats_flow_type_fn user_cb) { +static const struct rte_mbuf_dynfield timestamp_dynfield_desc = { + .name =RTE_MBUF_DYNFIELD_TIMESTAMP_NAME , + .size =sizeof (rte_mbuf_timestamp_t), + .align = __alignof__(rte_mbuf_timestamp_t ), + }; +static const struct rte_mbuf_dynflag timestamp_dynflag_desc = { + .name =RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME , + };unsigned int i;uint16_t pid;uint16_t qid;
@@ -211,6 +231,7 @@ rte_latencystats_init(uint64_t app_samp_intvl,const char *ptr_strings[NUM_LATENCY_STATS ] = {0 };const struct rte_memzone *mz =NULL ;const unsigned int flags =0 ; +int timestamp_dynflag_offset;int ret;if (rte_memzone_lookup (MZ_RTE_LATENCY_STATS ))
@@ -241,6 +262,23 @@ rte_latencystats_init(uint64_t app_samp_intvl,return -1 ; } +/* Register mbuf field and flag for Rx timestamp */ + timestamp_dynfield_offset = +rte_mbuf_dynfield_register (×tamp_dynfield_desc); +if (timestamp_dynfield_offset <0 ) { +RTE_LOG (ERR ,LATENCY_STATS , +"Cannot register mbuf field for timestamp\n" ); +return -rte_errno; + } + timestamp_dynflag_offset = +rte_mbuf_dynflag_register (×tamp_dynflag_desc); +if (timestamp_dynflag_offset <0 ) { +RTE_LOG (ERR ,LATENCY_STATS , +"Cannot register mbuf field for timestamp\n" ); +return -rte_errno; + } + timestamp_dynflag =RTE_BIT64 (timestamp_dynflag_offset); +/** Register Rx/Tx callbacks */ RTE_ETH_FOREACH_DEV (pid) {struct rte_eth_dev_info dev_info;
Signature · 1 line
2.28.0
Re: [dpdk-dev] [PATCH 04/15] latency: switch timestamp to dynamic mbuf field
Quoted 5 lines · Thomas Monjalon
The mbuf timestamp is moved to a dynamic field
in order to allow removal of the deprecated static field. The related mbuf flag is also replaced with the dynamic one.Signed-off-by Thomas Monjalon <[email protected]>
[snip]
Quoted 4 lines
lib/librte_latencystats/rte_latencystats.c +0
-0
[snip]
lib/librte_latencystats/rte_latencystats.c int · line 226
Quoted 12 lines
lib/librte_latencystats/rte_latencystats.c +8
-0@@ -204,6 +216,14 @@ int rte_latencystats_init(uint64_t app_samp_intvl, rte_latency_stats_flow_type_fn user_cb) { +static const struct rte_mbuf_dynfield timestamp_dynfield_desc = { + .name =RTE_MBUF_DYNFIELD_TIMESTAMP_NAME , + .size =sizeof (rte_mbuf_timestamp_t), + .align = __alignof__(rte_mbuf_timestamp_t ), + }; +static const struct rte_mbuf_dynflag timestamp_dynflag_desc = { + .name =RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME , + };
I dislike the duplication. If we can't just lookup by name which is done after ethdev configure (I guess so), may be ethdev should provide an API to register?
Re: [dpdk-dev] [PATCH 04/15] latency: switch timestamp to dynamic mbuf field
29/10/2020 11:13, Andrew Rybchenko:
Quoted 16 lines · Thomas Monjalon
Quoted 5 lines
The mbuf timestamp is moved to a dynamic field
in order to allow removal of the deprecated static field. The related mbuf flag is also replaced with the dynamic one.Signed-off-by Thomas Monjalon <[email protected]>[snip]
Quoted 4 lines
lib/librte_latencystats/rte_latencystats.c +0
-0[snip]
Quoted 16 lines
lib/librte_latencystats/rte_latencystats.c int · line 226
Quoted 12 lines
lib/librte_latencystats/rte_latencystats.c +8
-0@@ -204,6 +216,14 @@ int rte_latencystats_init(uint64_t app_samp_intvl, rte_latency_stats_flow_type_fn user_cb) { +static const struct rte_mbuf_dynfield timestamp_dynfield_desc = { + .name =RTE_MBUF_DYNFIELD_TIMESTAMP_NAME , + .size =sizeof (rte_mbuf_timestamp_t), + .align = __alignof__(rte_mbuf_timestamp_t ), + }; +static const struct rte_mbuf_dynflag timestamp_dynflag_desc = { + .name =RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME , + };I dislike the duplication. If we can't just lookup by name which is done after ethdev configure (I guess so), may be ethdev should provide an API to register?
That's because it is a separate library.
We don't know whether the feature timestamp is already enabled. We have the port_id, so we could do something.
But the current behaviour is to use timestamp even if it is disabled at ethdev level. And I don't want to change the behaviour.
Maybe the right solution is to register a separate field for this lib. Anyway the time base is not the same.
Re: [dpdk-dev] [PATCH 04/15] latency: switch timestamp to dynamic mbuf field
In reply to Thomas MonjalonQuoted 4 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
<snip>
lib/librte_latencystats/rte_latencystats.c rte_latencystats_init(uint64_t app_samp_intvl, · line 277
Quoted 4 lines
rte_mbuf_dynflag_register(×tamp_dynflag_desc);lib/librte_latencystats/rte_latencystats.c +3
-0+if (timestamp_dynflag_offset <0 ) { +RTE_LOG (ERR ,LATENCY_STATS , +"Cannot register mbuf field for timestamp\n" );
Field->flag, i.e. field should be changed to flag?
<snip>
Re: [dpdk-dev] [PATCH 04/15] latency: switch timestamp to dynamic mbuf field
29/10/2020 15:20, Pattan, Reshma:
Quoted 5 lines
Quoted 3 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Quoted 8 lines
<snip>
lib/librte_latencystats/rte_latencystats.c rte_latencystats_init(uint64_t app_samp_intvl, · line 277
Quoted 4 lines
rte_mbuf_dynflag_register(×tamp_dynflag_desc);lib/librte_latencystats/rte_latencystats.c +3
-0+if (timestamp_dynflag_offset <0 ) { +RTE_LOG (ERR ,LATENCY_STATS , +"Cannot register mbuf field for timestamp\n" );
Field->flag, i.e. field should be changed to flag?
Yes good catch, thanks!
PATCH 5/15 net/ark: switch timestamp to dynamic mbuf field
In reply to Thomas MonjalonThe mbuf timestamp is moved to a dynamic field
in order to allow removal of the deprecated static field. The related dynamic mbuf flag is set, although was missing previously.
The timestamp is set if configured for at least one device.
--- drivers/net/ark/ark_ethdev.c | 23 +++++++++++++++++++++++ drivers/net/ark/ark_ethdev_rx.c | 10 +++++++++- 2 files changed, 32 insertions(+), 1 deletion(-)
drivers/net/ark/ark_ethdev.c +23 -0
@@ -9,6 +9,7 @@#include <rte_bus_pci.h> #include <rte_ethdev_pci.h> #include <rte_kvargs.h> +#include <rte_bitops.h> #include "rte_pmd_ark.h" #include "ark_global.h"
@@ -79,6 +80,8 @@ static int eth_ark_set_mtu(struct rte_eth_dev *dev, uint16_t size);#define ARK_TX_MAX_QUEUE (4096 * 4)#define ARK_TX_MIN_QUEUE (256) +uint64_t ark_timestamp_rx_dynflag; +int ark_timestamp_dynfield_offset =-1 ;int rte_pmd_ark_rx_userdata_dynfield_offset =-1 ;int rte_pmd_ark_tx_userdata_dynfield_offset =-1 ;
@@ -552,6 +555,24 @@ static int eth_ark_dev_configure(struct rte_eth_dev *dev) {struct ark_adapter *ark = dev->data->dev_private; +int ark_timestamp_rx_dynflag_offset; + +if (dev->data->dev_conf.rxmode.offloads &DEV_RX_OFFLOAD_TIMESTAMP ) { + ark_timestamp_dynfield_offset =rte_mbuf_dynfield_lookup ( +RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ); +if (ark_timestamp_dynfield_offset <0 ) { +ARK_PMD_LOG (ERR ,"Failed to lookup timestamp field\n" ); +return -rte_errno; + } + ark_timestamp_rx_dynflag_offset =rte_mbuf_dynflag_lookup ( +RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME ,NULL ); +if (ark_timestamp_rx_dynflag_offset <0 ) { +ARK_PMD_LOG (ERR ,"Failed to lookup Rx timestamp flag\n" ); +return -rte_errno; + } + ark_timestamp_rx_dynflag = +RTE_BIT64 (ark_timestamp_rx_dynflag_offset); + }eth_ark_dev_set_link_up (dev);if (ark->user_ext.dev_configure)
@@ -782,6 +803,8 @@ eth_ark_dev_info_get(struct rte_eth_dev *dev,ETH_LINK_SPEED_50G | ETH_LINK_SPEED_100G); + dev_info->rx_offload_capa =DEV_RX_OFFLOAD_TIMESTAMP ; +return 0 ; }
drivers/net/ark/ark_ethdev_rx.c +9 -1
@@ -15,6 +15,9 @@#define ARK_RX_META_OFFSET (RTE_PKTMBUF_HEADROOM - ARK_RX_META_SIZE)#define ARK_RX_MAX_NOCHAIN (RTE_MBUF_DEFAULT_DATAROOM) +extern uint64_t ark_timestamp_rx_dynflag; +extern int ark_timestamp_dynfield_offset; +/* Forward declarations */ struct ark_rx_queue ;struct ark_rx_meta ;
@@ -272,7 +275,12 @@ eth_ark_recv_pkts(void *rx_queue, mbuf->port = meta->port; mbuf->pkt_len = meta->pkt_len; mbuf->data_len = meta->pkt_len; - mbuf->timestamp = meta->timestamp; +/* set timestamp if enabled at least on one device */ +if (ark_timestamp_rx_dynflag >0 ) { + *RTE_MBUF_DYNFIELD (mbuf, ark_timestamp_dynfield_offset, + rte_mbuf_timestamp_t *) = meta->timestamp; + mbuf->ol_flags |= ark_timestamp_rx_dynflag; + }rte_pmd_ark_mbuf_rx_userdata_set (mbuf, meta->user_data);if (ARK_DEBUG_CORE ) {/* debug sanity checks */
Signature · 1 line
2.28.0
PATCH 6/15 net/dpaa2: switch timestamp to dynamic mbuf field
In reply to Thomas MonjalonThe mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced.
--- drivers/net/dpaa2/dpaa2_ethdev.c | 20 ++++++++++++++++++++ drivers/net/dpaa2/dpaa2_ethdev.h | 2 ++ drivers/net/dpaa2/dpaa2_rxtx.c | 25 ++++++++++++++++++------- 3 files changed, 40 insertions(+), 7 deletions(-)
drivers/net/dpaa2/dpaa2_ethdev.c +20 -0
@@ -8,6 +8,7 @@#include <time.h> #include <net/if.h> +#include <rte_bitops.h> #include <rte_mbuf.h> #include <rte_ethdev_driver.h> #include <rte_malloc.h>
@@ -65,6 +66,8 @@ static uint64_t dev_tx_offloads_nodis =/* enable timestamp in mbuf */ bool dpaa2_enable_ts[RTE_MAX_ETHPORTS ]; +uint64_t dpaa2_timestamp_rx_dynflag; +int dpaa2_timestamp_dynfield_offset =-1 ;struct rte_dpaa2_xstats_name_off {char name[RTE_ETH_XSTATS_NAME_SIZE ];
@@ -505,6 +508,7 @@ dpaa2_eth_dev_configure(struct rte_eth_dev *dev)struct rte_eth_conf *eth_conf = &dev->data->dev_conf;uint64_t rx_offloads = eth_conf->rxmode.offloads;uint64_t tx_offloads = eth_conf->txmode.offloads; +int timestamp_rx_dynflag_offset;int rx_l3_csum_offload = false;int rx_l4_csum_offload = false;int tx_l3_csum_offload = false;
@@ -587,7 +591,23 @@ dpaa2_eth_dev_configure(struct rte_eth_dev *dev)#if !defined(RTE_LIBRTE_IEEE1588 ) if (rx_offloads & DEV_RX_OFFLOAD_TIMESTAMP)#endif + { + dpaa2_timestamp_dynfield_offset =rte_mbuf_dynfield_lookup ( +RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ); +if (dpaa2_timestamp_dynfield_offset <0 ) { +DPAA2_PMD_ERR ("Error to lookup timestamp field" ); +return -rte_errno; + } + timestamp_rx_dynflag_offset =rte_mbuf_dynflag_lookup ( +RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME ,NULL ); +if (timestamp_rx_dynflag_offset <0 ) { +DPAA2_PMD_ERR ("Error to lookup Rx timestamp flag" ); +return -rte_errno; + } + dpaa2_timestamp_rx_dynflag = +RTE_BIT64 (timestamp_rx_dynflag_offset); dpaa2_enable_ts[dev->data->port_id] = true; + }if (tx_offloads &DEV_TX_OFFLOAD_IPV4_CKSUM ) tx_l3_csum_offload = true;
drivers/net/dpaa2/dpaa2_ethdev.h +2 -0
@@ -92,6 +92,8 @@/* enable timestamp in mbuf*/ extern bool dpaa2_enable_ts[]; +extern uint64_t dpaa2_timestamp_rx_dynflag; +extern int dpaa2_timestamp_dynfield_offset;#define DPAA2_QOS_TABLE_RECONFIGURE 1#define DPAA2_FS_TABLE_RECONFIGURE 2
drivers/net/dpaa2/dpaa2_rxtx.c +18 -7
@@ -31,6 +31,13 @@ dpaa2_dev_rx_parse_slow(struct rte_mbuf *mbuf, static void enable_tx_tstamp(struct qbman_fd *fd) __rte_unused; +static inline rte_mbuf_timestamp_t * +dpaa2_timestamp_dynfield (struct rte_mbuf *mbuf) +{ +return RTE_MBUF_DYNFIELD (mbuf, + dpaa2_timestamp_dynfield_offset, rte_mbuf_timestamp_t *); +} +#define DPAA2_MBUF_TO_CONTIG_FD (_mbuf, _fd, _bpid) do { \ DPAA2_SET_FD_ADDR(_fd, DPAA2_MBUF_VADDR_TO_IOVA(_mbuf)); \ DPAA2_SET_FD_LEN(_fd, _mbuf->data_len); \
@@ -109,9 +116,10 @@ dpaa2_dev_rx_parse_new(struct rte_mbuf *m, const struct qbman_fd *fd, m->ol_flags |=PKT_RX_RSS_HASH ;if (dpaa2_enable_ts[m->port]) { - m->timestamp = annotation->word2; - m->ol_flags |=PKT_RX_TIMESTAMP ; -DPAA2_PMD_DP_DEBUG ("pkt timestamp:0x%" PRIx64"" , m->timestamp); + *dpaa2_timestamp_dynfield (m) = annotation->word2; + m->ol_flags |= dpaa2_timestamp_rx_dynflag; +DPAA2_PMD_DP_DEBUG ("pkt timestamp:0x%" PRIx64"" , + *dpaa2_timestamp_dynfield (m)); } DPAA2_PMD_DP_DEBUG("HW frc = 0x%x\t packet type =0x%x "
@@ -223,9 +231,12 @@ dpaa2_dev_rx_parse(struct rte_mbuf *mbuf, void *hw_annot_addr)else if (BIT_ISSET_AT_POS (annotation->word8,DPAA2_ETH_FAS_L4CE )) mbuf->ol_flags |=PKT_RX_L4_CKSUM_BAD ; - mbuf->ol_flags |=PKT_RX_TIMESTAMP ; - mbuf->timestamp = annotation->word2; -DPAA2_PMD_DP_DEBUG ("pkt timestamp: 0x%" PRIx64"" , mbuf->timestamp); +if (dpaa2_enable_ts[mbuf->port]) { + *dpaa2_timestamp_dynfield (mbuf) = annotation->word2; + mbuf->ol_flags |= dpaa2_timestamp_rx_dynflag; +DPAA2_PMD_DP_DEBUG ("pkt timestamp: 0x%" PRIx64"" , + *dpaa2_timestamp_dynfield (mbuf)); + }/* Check detailed parsing requirement */ if (annotation->word3 &0x7FFFFC3FFFF )
@@ -629,7 +640,7 @@ dpaa2_dev_prefetch_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)else bufs[num_rx] =eth_fd_to_mbuf (fd, eth_data->port_id);#if defined(RTE_LIBRTE_IEEE1588 ) - priv->rx_timestamp = bufs[num_rx]->timestamp; + priv->rx_timestamp = *dpaa2_timestamp_dynfield (bufs[num_rx]);#endif if (eth_data->dev_conf.rxmode.offloads &
Signature · 1 line
2.28.0
PATCH 7/15 net/mlx5: fix dynamic mbuf offset lookup check
In reply to Thomas MonjalonThe functions rte_mbuf_dynfield_lookup() and rte_mbuf_dynflag_lookup() can return an offset starting with 0 or a negative error code.
In reality the first offsets are probably reserved forever, but for the sake of strict API compliance,
the checks which considered 0 as an error are fixed.
--- drivers/net/mlx5/mlx5_rxtx.c | 4 ++-- drivers/net/mlx5/mlx5_trigger.c | 2 +- drivers/net/mlx5/mlx5_txq.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/mlx5/mlx5_rxtx.c +2 -2
@@ -5661,9 +5661,9 @@ mlx5_select_tx_function(struct rte_eth_dev *dev) }if (tx_offloads &DEV_TX_OFFLOAD_SEND_ON_TIMESTAMP &&rte_mbuf_dynflag_lookup - (RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME ,NULL ) >0 && + (RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME ,NULL ) >=0 &&rte_mbuf_dynfield_lookup - (RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ) >0 ) { + (RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ) >=0 ) {/* Offload configured, dynamic entities registered. */ olx |=MLX5_TXOFF_CONFIG_TXPP ; }
drivers/net/mlx5/mlx5_trigger.c +1 -1
@@ -302,7 +302,7 @@ mlx5_dev_start(struct rte_eth_dev *dev)DRV_LOG (DEBUG ,"port %u starting device" , dev->data->port_id); fine_inline =rte_mbuf_dynflag_lookup (RTE_PMD_MLX5_FINE_GRANULARITY_INLINE ,NULL ); -if (fine_inline >0 ) +if (fine_inline >=0 ) rte_net_mlx5_dynf_inline_mask =1UL << fine_inline;else rte_net_mlx5_dynf_inline_mask =0 ;
drivers/net/mlx5/mlx5_txq.c +1 -1
@@ -1305,7 +1305,7 @@ mlx5_txq_dynf_timestamp_set(struct rte_eth_dev *dev) (RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME ,NULL ); off =rte_mbuf_dynfield_lookup (RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ); -if (nbit >0 && off >=0 && sh->txpp.refcnt) +if (nbit >=0 && off >=0 && sh->txpp.refcnt) mask =1ULL << nbit;for (i =0 ; i != priv->txqs_n; ++i) { data = (*priv->txqs)[i];
Signature · 1 line
2.28.0
PATCH 8/15 net/mlx5: switch timestamp to dynamic mbuf field
In reply to Thomas MonjalonThe mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced.
--- drivers/net/mlx5/mlx5_rxq.c | 36 ++++++++++++++++++++ drivers/net/mlx5/mlx5_rxtx.c | 4 +-- drivers/net/mlx5/mlx5_rxtx.h | 19 +++++++++++ drivers/net/mlx5/mlx5_rxtx_vec_altivec.h | 41 +++++++++++----------- drivers/net/mlx5/mlx5_rxtx_vec_neon.h | 43 ++++++++++++------------ drivers/net/mlx5/mlx5_rxtx_vec_sse.h | 35 +++++++++---------- 6 files changed, 118 insertions(+), 60 deletions(-)
drivers/net/mlx5/mlx5_rxq.c +36 -0
@@ -1310,6 +1310,39 @@ mlx5_max_lro_msg_size_adjust(struct rte_eth_dev *dev, uint16_t idx, priv->max_lro_msg_size * MLX5_LRO_SEG_CHUNK_SIZE); } +/** +* Lookup mbuf field and flag for Rx timestamp if offload requested. +* +* @param rxq_data +* Datapath struct where field offset and flag mask are stored. +* +* @return +* 0 on success or offload disabled, negative errno otherwise. +*/ +static int +mlx5_rx_timestamp_setup (struct mlx5_rxq_data *rxq_data) +{ +int timestamp_rx_dynflag_offset; + + rxq_data->timestamp_rx_flag =0 ; +if (rxq_data->hw_timestamp ==0 ) +return 0 ; + rxq_data->timestamp_offset =rte_mbuf_dynfield_lookup ( +RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ); +if (rxq_data->timestamp_offset <0 ) { +DRV_LOG (ERR ,"Cannot lookup timestamp field\n" ); +return -rte_errno; + } + timestamp_rx_dynflag_offset =rte_mbuf_dynflag_lookup ( +RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME ,NULL ); +if (timestamp_rx_dynflag_offset <0 ) { +DRV_LOG (ERR ,"Cannot lookup Rx timestamp flag\n" ); +return -rte_errno; + } + rxq_data->timestamp_rx_flag =RTE_BIT64 (timestamp_rx_dynflag_offset); +return 0 ; +} +/** * Create a DPDK Rx queue. *
@@ -1492,7 +1525,10 @@ mlx5_rxq_new(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,mlx5_max_lro_msg_size_adjust (dev, idx, max_lro_size);/* Toggle RX checksum offload if hardware supports it. */ tmpl->rxq.csum = !!(offloads &DEV_RX_OFFLOAD_CHECKSUM ); +/* Configure Rx timestamp. */ tmpl->rxq.hw_timestamp = !!(offloads &DEV_RX_OFFLOAD_TIMESTAMP ); +if (mlx5_rx_timestamp_setup (&tmpl->rxq) !=0 ) + goto error;/* Configure VLAN stripping. */ tmpl->rxq.vlan_strip = !!(offloads &DEV_RX_OFFLOAD_VLAN_STRIP );/* By default, FCS (CRC) is stripped by hardware. */
drivers/net/mlx5/mlx5_rxtx.c +2 -2
@@ -1287,8 +1287,8 @@ rxq_cq_to_mbuf(struct mlx5_rxq_data *rxq, struct rte_mbuf *pkt,if (rxq->rt_timestamp) ts =mlx5_txpp_convert_rx_ts (rxq->sh, ts); - pkt->timestamp = ts; - pkt->ol_flags |=PKT_RX_TIMESTAMP ; +mlx5_timestamp_set (pkt, rxq->timestamp_offset, ts); + pkt->ol_flags |= rxq->timestamp_rx_flag; } }
drivers/net/mlx5/mlx5_rxtx.h +19 -0
@@ -151,6 +151,8 @@ struct mlx5_rxq_data {/* CQ (UAR) access lock required for 32bit implementations */ #endif uint32_t tunnel;/* Tunnel information. */ +int timestamp_offset;/* Dynamic mbuf field for timestamp. */ +uint64_t timestamp_rx_flag;/* Dynamic mbuf flag for timestamp. */ uint64_t flow_meta_mask;int32_t flow_meta_offset; } __rte_cache_aligned;
@@ -681,4 +683,21 @@ mlx5_txpp_convert_tx_ts(struct mlx5_dev_ctx_shared *sh, uint64_t mts) return ci; } +/** +* Set timestamp in mbuf dynamic field. +* +* @param mbuf +* Structure to write into. +* @param offset +* Dynamic field offset in mbuf structure. +* @param timestamp +* Value to write. +*/ +static __rte_always_inline void +mlx5_timestamp_set (struct rte_mbuf *mbuf,int offset, +rte_mbuf_timestamp_t timestamp) +{ + *RTE_MBUF_DYNFIELD(mbuf, offset, rte_mbuf_timestamp_t *) = timestamp; +} +#endif /* RTE_PMD_MLX5_RXTX_H_ */
drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +21 -20
65 lines not on this page · raw message
drivers/net/mlx5/mlx5_rxtx_vec_neon.h +22 -21
71 lines not on this page · raw message
drivers/net/mlx5/mlx5_rxtx_vec_sse.h +18 -17
@@ -251,7 +251,7 @@ rxq_cq_to_ptype_oflags_v(struct mlx5_rxq_data *rxq, __m128i cqes[4],__m128i pinfo0, pinfo1;__m128i pinfo, ptype;__m128i ol_flags =_mm_set1_epi32 (rxq->rss_hash *PKT_RX_RSS_HASH | - rxq->hw_timestamp *PKT_RX_TIMESTAMP ); + rxq->hw_timestamp * rxq->timestamp_rx_flag);__m128i cv_flags;const __m128i zero =_mm_setzero_si128 (); const __m128i ptype_mask =
@@ -656,31 +656,32 @@ rxq_burst_v(struct mlx5_rxq_data *rxq, struct rte_mbuf **pkts, uint16_t pkts_n,/* D.5 fill in mbuf - rearm_data and packet_type. */ rxq_cq_to_ptype_oflags_v (rxq, cqes, opcode, &pkts[pos]);if (rxq->hw_timestamp) { +int offset = rxq->timestamp_offset;if (rxq->rt_timestamp) {struct mlx5_dev_ctx_shared *sh = rxq->sh;uint64_t ts; ts =rte_be_to_cpu_64 (cq[pos].timestamp); - pkts[pos]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (pkts[pos], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); ts =rte_be_to_cpu_64 (cq[pos + p1].timestamp); - pkts[pos +1 ]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (pkts[pos +1 ], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); ts =rte_be_to_cpu_64 (cq[pos + p2].timestamp); - pkts[pos +2 ]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (pkts[pos +2 ], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); ts =rte_be_to_cpu_64 (cq[pos + p3].timestamp); - pkts[pos +3 ]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (pkts[pos +3 ], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); }else { - pkts[pos]->timestamp =rte_be_to_cpu_64 - (cq[pos].timestamp); - pkts[pos +1 ]->timestamp =rte_be_to_cpu_64 - (cq[pos + p1].timestamp); - pkts[pos +2 ]->timestamp =rte_be_to_cpu_64 - (cq[pos + p2].timestamp); - pkts[pos +3 ]->timestamp =rte_be_to_cpu_64 - (cq[pos + p3].timestamp); +mlx5_timestamp_set (pkts[pos], offset, +rte_be_to_cpu_64 (cq[pos].timestamp)); +mlx5_timestamp_set (pkts[pos +1 ], offset, +rte_be_to_cpu_64 (cq[pos + p1].timestamp)); +mlx5_timestamp_set (pkts[pos +2 ], offset, +rte_be_to_cpu_64 (cq[pos + p2].timestamp)); +mlx5_timestamp_set (pkts[pos +3 ], offset, +rte_be_to_cpu_64 (cq[pos + p3].timestamp)); } }if (rxq->dynf_meta) {
Signature · 1 line
2.28.0
PATCH 9/15 net/nfb: switch timestamp to dynamic mbuf field
In reply to Thomas MonjalonThe mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced.
--- drivers/net/nfb/nfb_rx.c | 23 ++++++++++++++++++++++- drivers/net/nfb/nfb_rx.h | 18 ++++++++++++++---- 2 files changed, 36 insertions(+), 5 deletions(-)
drivers/net/nfb/nfb_rx.c +22 -1
@@ -5,10 +5,14 @@*/ #include <rte_kvargs.h> +#include <rte_bitops.h> #include "nfb_rx.h" #include "nfb.h" +uint64_t nfb_timestamp_rx_dynflag; +int nfb_timestamp_dynfield_offset =-1 ; +static int timestamp_check_handler(__rte_unused const char *key, const char *value, __rte_unused void *opaque)
@@ -23,6 +27,7 @@ timestamp_check_handler(__rte_unused const char *key,static int nfb_check_timestamp (struct rte_devargs *devargs) { +int timestamp_rx_dynflag_offset;struct rte_kvargs *kvlist;if (devargs ==NULL )
@@ -38,6 +43,7 @@ nfb_check_timestamp(struct rte_devargs *devargs) }/* Timestamps are enabled when there is * key-value pair: enable_timestamp=1 +* TODO: timestamp should be enabled with DEV_RX_OFFLOAD_TIMESTAMP */ if (rte_kvargs_process (kvlist,TIMESTAMP_ARG , timestamp_check_handler,NULL ) <0 ) {
@@ -46,6 +52,21 @@ nfb_check_timestamp(struct rte_devargs *devargs) }rte_kvargs_free (kvlist); + nfb_timestamp_dynfield_offset =rte_mbuf_dynfield_lookup ( +RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ); +if (nfb_timestamp_dynfield_offset <0 ) { +RTE_LOG (ERR ,PMD ,"Cannot lookup timestamp field\n" ); +return -rte_errno; + } + timestamp_rx_dynflag_offset =rte_mbuf_dynflag_lookup ( +RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME ,NULL ); +if (timestamp_rx_dynflag_offset <0 ) { +RTE_LOG (ERR ,PMD ,"Cannot lookup Rx timestamp flag\n" ); +return -rte_errno; + } + nfb_timestamp_rx_dynflag = +RTE_BIT64 (timestamp_rx_dynflag_offset); +return 1 ; }
@@ -125,7 +146,7 @@ nfb_eth_rx_queue_setup(struct rte_eth_dev *dev,else rte_free (rxq); -if (nfb_check_timestamp (dev->device->devargs)) +if (nfb_check_timestamp (dev->device->devargs) >0 ) rxq->flags |=NFB_TIMESTAMP_FLAG ;return ret;
drivers/net/nfb/nfb_rx.h +14 -4
@@ -15,6 +15,16 @@#define NFB_TIMESTAMP_FLAG (1 << 0) +extern uint64_t nfb_timestamp_rx_dynflag; +extern int nfb_timestamp_dynfield_offset; + +static inline rte_mbuf_timestamp_t * +nfb_timestamp_dynfield (struct rte_mbuf *mbuf) +{ +return RTE_MBUF_DYNFIELD (mbuf, + nfb_timestamp_dynfield_offset, rte_mbuf_timestamp_t *); +} +struct ndp_rx_queue {struct nfb_device *nfb;/* nfb dev structure */ struct ndp_queue *queue;/* rx queue */
@@ -191,15 +201,15 @@ nfb_eth_ndp_rx(void *queue,if (timestamping_enabled) {/* nanoseconds */ - mbuf->timestamp = + *nfb_timestamp_dynfield (mbuf) =rte_le_to_cpu_32 (*((uint32_t *) (packets[i].header +4 ))); - mbuf->timestamp <<=32 ; + *nfb_timestamp_dynfield (mbuf) <<=32 ;/* seconds */ - mbuf->timestamp |= + *nfb_timestamp_dynfield (mbuf) |=rte_le_to_cpu_32 (*((uint32_t *) (packets[i].header +8 ))); - mbuf->ol_flags |=PKT_RX_TIMESTAMP ; + mbuf->ol_flags |= nfb_timestamp_rx_dynflag; } bufs[num_rx++] = mbuf;
Signature · 1 line
2.28.0
PATCH 10/15 net/octeontx2: switch timestamp to dynamic mbuf field
In reply to Thomas MonjalonThe mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced.
--- drivers/net/octeontx2/otx2_ethdev.c | 33 +++++++++++++++++++++++++++++ drivers/net/octeontx2/otx2_rx.h | 19 ++++++++++++++--- drivers/net/octeontx2/version.map | 7 ++++++ 3 files changed, 56 insertions(+), 3 deletions(-)
drivers/net/octeontx2/otx2_ethdev.c +33 -0
@@ -4,6 +4,7 @@#include <inttypes.h> +#include <rte_bitops.h> #include <rte_ethdev_pci.h> #include <rte_io.h> #include <rte_malloc.h>
@@ -14,6 +15,35 @@#include "otx2_ethdev.h" #include "otx2_ethdev_sec.h" +uint64_t rte_pmd_octeontx2_timestamp_rx_dynflag; +int rte_pmd_octeontx2_timestamp_dynfield_offset =-1 ; + +static int +otx2_rx_timestamp_setup (uint16_t flags) +{ +int timestamp_rx_dynflag_offset; + +if ((flags &NIX_RX_OFFLOAD_TSTAMP_F ) ==0 ) +return 0 ; + + rte_pmd_octeontx2_timestamp_dynfield_offset =rte_mbuf_dynfield_lookup ( +RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ); +if (rte_pmd_octeontx2_timestamp_dynfield_offset <0 ) { +otx2_err ("Failed to lookup timestamp field" ); +return -rte_errno; + } + timestamp_rx_dynflag_offset =rte_mbuf_dynflag_lookup ( +RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME ,NULL ); +if (timestamp_rx_dynflag_offset <0 ) { +otx2_err ("Failed to lookup Rx timestamp flag" ); +return -rte_errno; + } + rte_pmd_octeontx2_timestamp_rx_dynflag = +RTE_BIT64 (timestamp_rx_dynflag_offset); + +return 0 ; +} +static inline uint64_t nix_get_rx_offload_capa (struct otx2_eth_dev *dev) {
@@ -1874,6 +1904,9 @@ otx2_nix_configure(struct rte_eth_dev *eth_dev) dev->tx_offload_flags |=nix_tx_offload_flags (eth_dev); dev->rss_info.rss_grps =NIX_RSS_GRPS ; +if (otx2_rx_timestamp_setup (dev->rx_offload_flags) !=0 ) + goto fail_offloads; + nb_rxq =RTE_MAX (data->nb_rx_queues,1 ); nb_txq =RTE_MAX (data->nb_tx_queues,1 );
drivers/net/octeontx2/otx2_rx.h +16 -3
@@ -63,6 +63,18 @@ union mbuf_initializer {uint64_t value; }; +/* variables are exported because this file is included in other drivers */ +extern uint64_t rte_pmd_octeontx2_timestamp_rx_dynflag; +extern int rte_pmd_octeontx2_timestamp_dynfield_offset; + +static inline rte_mbuf_timestamp_t * +otx2_timestamp_dynfield (struct rte_mbuf *mbuf) +{ +return RTE_MBUF_DYNFIELD (mbuf, + rte_pmd_octeontx2_timestamp_dynfield_offset, + rte_mbuf_timestamp_t *); +} + static __rte_always_inline void otx2_nix_mbuf_to_tstamp(struct rte_mbuf *mbuf, struct otx2_timesync_info *tstamp, const uint16_t flag,
@@ -77,15 +89,16 @@ otx2_nix_mbuf_to_tstamp(struct rte_mbuf *mbuf,/* Reading the rx timestamp inserted by CGX, viz at * starting of the packet data. */ - mbuf->timestamp =rte_be_to_cpu_64 (*tstamp_ptr); + *otx2_timestamp_dynfield (mbuf) =rte_be_to_cpu_64 (*tstamp_ptr);/* PKT_RX_IEEE1588_TMST flag needs to be set only in case * PTP packets are received. */ if (mbuf->packet_type ==RTE_PTYPE_L2_ETHER_TIMESYNC ) { - tstamp->rx_tstamp = mbuf->timestamp; + tstamp->rx_tstamp = *otx2_timestamp_dynfield (mbuf); tstamp->rx_ready =1 ; mbuf->ol_flags |=PKT_RX_IEEE1588_PTP | -PKT_RX_IEEE1588_TMST |PKT_RX_TIMESTAMP ; +PKT_RX_IEEE1588_TMST | + rte_pmd_octeontx2_timestamp_rx_dynflag; } } }
drivers/net/octeontx2/version.map +7 -0
@@ -1,3 +1,10 @@ DPDK_21 { local: *; }; + +INTERNAL { + global: + + rte_pmd_octeontx2_timestamp_dynfield_offset; + rte_pmd_octeontx2_timestamp_rx_dynflag; +};
Signature · 1 line
2.28.0
Re: [dpdk-dev] [PATCH 10/15] net/octeontx2: switch timestamp to dynamic mbuf field
Quoted 79 lines · Thomas Monjalon
The mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced.
Signed-off-by Thomas Monjalon <[email protected]>--- drivers/net/octeontx2/otx2_ethdev.c | 33 +++++++++++++++++++++++++++++ drivers/net/octeontx2/otx2_rx.h | 19 ++++++++++++++--- drivers/net/octeontx2/version.map | 7 ++++++ 3 files changed, 56 insertions(+), 3 deletions(-)drivers/net/octeontx2/otx2_ethdev.c +33
-0@@ -4,6 +4,7 @@#include <inttypes.h> +#include <rte_bitops.h> #include <rte_ethdev_pci.h> #include <rte_io.h> #include <rte_malloc.h> @@ -14,6 +15,35 @@#include "otx2_ethdev.h" #include "otx2_ethdev_sec.h" +uint64_t rte_pmd_octeontx2_timestamp_rx_dynflag; +int rte_pmd_octeontx2_timestamp_dynfield_offset =-1 ; + +static int +otx2_rx_timestamp_setup (uint16_t flags) +{ +int timestamp_rx_dynflag_offset; + +if ((flags &NIX_RX_OFFLOAD_TSTAMP_F ) ==0 ) +return 0 ; + + rte_pmd_octeontx2_timestamp_dynfield_offset =rte_mbuf_dynfield_lookup ( +RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ); +if (rte_pmd_octeontx2_timestamp_dynfield_offset <0 ) { +otx2_err ("Failed to lookup timestamp field" ); +return -rte_errno; + } + timestamp_rx_dynflag_offset =rte_mbuf_dynflag_lookup ( +RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME ,NULL ); +if (timestamp_rx_dynflag_offset <0 ) { +otx2_err ("Failed to lookup Rx timestamp flag" ); +return -rte_errno; + } + rte_pmd_octeontx2_timestamp_rx_dynflag = +RTE_BIT64 (timestamp_rx_dynflag_offset); + +return 0 ; +} +static inline uint64_t nix_get_rx_offload_capa (struct otx2_eth_dev *dev) {@@ -1874,6 +1904,9 @@ otx2_nix_configure(struct rte_eth_dev *eth_dev) dev->tx_offload_flags |=nix_tx_offload_flags (eth_dev); dev->rss_info.rss_grps =NIX_RSS_GRPS ; +if (otx2_rx_timestamp_setup (dev->rx_offload_flags) !=0 ) + goto fail_offloads; + nb_rxq =RTE_MAX (data->nb_rx_queues,1 ); nb_txq =RTE_MAX (data->nb_tx_queues,1 );drivers/net/octeontx2/otx2_rx.h +2
-0@@ -63,6 +63,18 @@ union mbuf_initializer {uint64_t value; }; +/* variables are exported because this file is included in other drivers */ +extern uint64_t rte_pmd_octeontx2_timestamp_rx_dynflag;
drivers/net/octeontx2/otx2_rx.h union mbuf_initializer { · line 77
Quoted 10 lines
drivers/net/octeontx2/otx2_rx.h +10
-0+extern int rte_pmd_octeontx2_timestamp_dynfield_offset; + +static inline rte_mbuf_timestamp_t * +otx2_timestamp_dynfield (struct rte_mbuf *mbuf) +{ +return RTE_MBUF_DYNFIELD (mbuf, + rte_pmd_octeontx2_timestamp_dynfield_offset, + rte_mbuf_timestamp_t *); +} +
May be ethdev should provide the inline function?
Re: [dpdk-dev] [PATCH 10/15] net/octeontx2: switch timestamp to dynamic mbuf field
29/10/2020 12:02, Andrew Rybchenko:
Quoted 7 lines · Thomas Monjalon
Quoted 6 lines
drivers/net/octeontx2/otx2_rx.h +6
-0+/* variables are exported because this file is included in other drivers */ +extern uint64_t rte_pmd_octeontx2_timestamp_rx_dynflag; +extern int rte_pmd_octeontx2_timestamp_dynfield_offset; + +static inline rte_mbuf_timestamp_t * +otx2_timestamp_dynfield (struct rte_mbuf *mbuf)
Quoted 8 lines
drivers/net/octeontx2/otx2_rx.h union mbuf_initializer { · line 77
Quoted 6 lines
drivers/net/octeontx2/otx2_rx.h +6
-0+{ +return RTE_MBUF_DYNFIELD (mbuf, + rte_pmd_octeontx2_timestamp_dynfield_offset, + rte_mbuf_timestamp_t *); +} +May be ethdev should provide the inline function?
It would mean exporting the offsets.
And actually I think this field should not be restricted to ethdev.
Re: [dpdk-dev] [PATCH 10/15] net/octeontx2: switch timestamp to dynamic mbuf field
Quoted 17 lines · Thomas Monjalon
29/10/2020 12:02, Andrew Rybchenko:
Quoted 7 lines · Thomas Monjalon
Quoted 6 lines
drivers/net/octeontx2/otx2_rx.h +6
-0+/* variables are exported because this file is included in other drivers */ +extern uint64_t rte_pmd_octeontx2_timestamp_rx_dynflag; +extern int rte_pmd_octeontx2_timestamp_dynfield_offset; + +static inline rte_mbuf_timestamp_t * +otx2_timestamp_dynfield (struct rte_mbuf *mbuf)Quoted 8 lines
drivers/net/octeontx2/otx2_rx.h union mbuf_initializer { · line 77
Quoted 6 lines
drivers/net/octeontx2/otx2_rx.h +6
-0+{ +return RTE_MBUF_DYNFIELD (mbuf, + rte_pmd_octeontx2_timestamp_dynfield_offset, + rte_mbuf_timestamp_t *); +} +May be ethdev should provide the inline function?
Quoted 4 lines
It would mean exporting the offsets.
And actually I think this field should not be restricted to ethdev.
I see OK.
Re: [dpdk-dev] [PATCH 10/15] net/octeontx2: switch timestamp to dynamic mbuf field
In reply to Andrew RybchenkoJust five cents - exporting the offset (making it global) might have side effect impacting the performance. Offset might be located in some memory sharing the cacheline with some other variables.
If these variables are writable and are being updated frequently - we might get the cache contention. I'd prefer to keep all dynamic offsets In the PMD and entirely control memory allocation attributes for these ones. Hence, exporting is OK, but practical usage in datapath is questionable.
With best regards, Slava
Quoted 91 lines
-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Thursday, October 29, 2020 13:02
To: NBU-Contact-Thomas Monjalon <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Slava Ovsiienko <[email protected]>; Nithin Dabilpuram <[email protected]>; Kiran Kumar K <[email protected]>; Ray Kinsella <[email protected]>; Neil Horman <[email protected]>
Subject: Re: [PATCH 10/15] net/octeontx2: switch timestamp to dynamic mbuf fieldQuoted 7 lines · Thomas Monjalon
The mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field.
The related mbuf flag is also replaced.Signed-off-by Thomas Monjalon <[email protected]>--- drivers/net/octeontx2/otx2_ethdev.c | 33+++++++++++++++++++++++++++++
Quoted 22 lines
drivers/net/octeontx2/otx2_rx.h | 19 ++++++++++++++--- drivers/net/octeontx2/version.map | 7 ++++++ 3 files changed, 56 insertions(+), 3 deletions(-)drivers/net/octeontx2/otx2_ethdev.c +2
-0@@ -4,6 +4,7 @@#include <inttypes.h> +#include <rte_bitops.h> #include <rte_ethdev_pci.h> #include <rte_io.h> #include <rte_malloc.h> @@ -14,6 +15,35 @@#include "otx2_ethdev.h" #include "otx2_ethdev_sec.h" +uint64_t rte_pmd_octeontx2_timestamp_rx_dynflag;drivers/net/octeontx2/otx2_ethdev.c line 28
Quoted 10 lines
drivers/net/octeontx2/otx2_ethdev.c +10
-0+int rte_pmd_octeontx2_timestamp_dynfield_offset =-1 ; + +static int +otx2_rx_timestamp_setup (uint16_t flags) { +int timestamp_rx_dynflag_offset; + +if ((flags &NIX_RX_OFFLOAD_TSTAMP_F ) ==0 ) +return 0 ; + + rte_pmd_octeontx2_timestamp_dynfield_offset =rte_mbuf_dynfield_lookup(
Quoted 37 lines
drivers/net/octeontx2/otx2_ethdev.c +18
-0+ RTE_MBUF_DYNFIELD_TIMESTAMP_NAME, NULL); +if (rte_pmd_octeontx2_timestamp_dynfield_offset <0 ) { +otx2_err ("Failed to lookup timestamp field" ); +return -rte_errno; + } + timestamp_rx_dynflag_offset =rte_mbuf_dynflag_lookup ( +RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME ,NULL ); +if (timestamp_rx_dynflag_offset <0 ) { +otx2_err ("Failed to lookup Rx timestamp flag" ); +return -rte_errno; + } + rte_pmd_octeontx2_timestamp_rx_dynflag = +RTE_BIT64 (timestamp_rx_dynflag_offset); + +return 0 ; +} +static inline uint64_t nix_get_rx_offload_capa(struct otx2_eth_dev *dev) { @@ -1874,6 +1904,9 @@ otx2_nix_configure(struct rte_eth_dev *eth_dev) dev->tx_offload_flags |=nix_tx_offload_flags (eth_dev);drivers/net/octeontx2/otx2_ethdev.c +3
-0dev->rss_info.rss_grps =NIX_RSS_GRPS ; +if (otx2_rx_timestamp_setup (dev->rx_offload_flags) !=0 ) + goto fail_offloads; + nb_rxq =RTE_MAX (data->nb_rx_queues,1 ); nb_txq =RTE_MAX (data->nb_tx_queues,1 );(quoted diff) +0
-0
b/drivers/net/octeontx2/otx2_rx.hindex61a5c436dd..6981edce82100644drivers/net/octeontx2/otx2_rx.h +0
-0@@ -63,6 +63,18 @@ union mbuf_initializer {uint64_t value; };
Quoted 13 lines
drivers/net/octeontx2/otx2_rx.h union mbuf_initializer { · line 77
Quoted 11 lines
drivers/net/octeontx2/otx2_rx.h +11
-0+/* variables are exported because this file is included in other +drivers */ extern uint64_t rte_pmd_octeontx2_timestamp_rx_dynflag; +extern int rte_pmd_octeontx2_timestamp_dynfield_offset; + +static inline rte_mbuf_timestamp_t * +otx2_timestamp_dynfield (struct rte_mbuf *mbuf) { +return RTE_MBUF_DYNFIELD (mbuf, + rte_pmd_octeontx2_timestamp_dynfield_offset, + rte_mbuf_timestamp_t *); +} +May be ethdev should provide the inline function?
Just five cents - exporting the offset (making it global) might have side effect impacting the performance. Offset might be located in some memory sharing the cacheline with some other variables.
If these variables are writable and are being updated frequently - we might get the cache contention. I'd prefer to keep all dynamic offsets In the PMD and entirely control memory allocation attributes for these ones. Hence, exporting/inline function is possible,
but practical usage, say, in datapath, is questionable.
With best regards, Slava
Re: [dpdk-dev] [PATCH 10/15] net/octeontx2: switch timestamp to dynamic mbuf field
Quoted 2 lines · Slava Ovsiienko
Just five cents - exporting the offset (making it global) might have side effect impacting the performance.
I agree with Slava. The offset value should be stored in the PMD structure. IMO, We can have an ethdev API to get the offset and store it in PMD's fastpath structures in the slow path
to use in fastpath.
Quoted 120 lines
Offset might be located in some memory sharing the cacheline with some other variables. If these variables are writable and are being updated frequently - we might get the cache contention. I'd prefer to keep all dynamic offsets In the PMD and entirely control memory allocation attributes for these ones. Hence, exporting is OK, but practical usage in datapath is questionable.
With best regards, Slava
Quoted 91 lines
-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Thursday, October 29, 2020 13:02
To: NBU-Contact-Thomas Monjalon <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Slava Ovsiienko <[email protected]>; Nithin Dabilpuram <[email protected]>; Kiran Kumar K <[email protected]>; Ray Kinsella <[email protected]>; Neil Horman <[email protected]>
Subject: Re: [PATCH 10/15] net/octeontx2: switch timestamp to dynamic mbuf fieldQuoted 7 lines · Thomas Monjalon
The mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field.
The related mbuf flag is also replaced.Signed-off-by Thomas Monjalon <[email protected]>--- drivers/net/octeontx2/otx2_ethdev.c | 33+++++++++++++++++++++++++++++
Quoted 22 lines
drivers/net/octeontx2/otx2_rx.h | 19 ++++++++++++++--- drivers/net/octeontx2/version.map | 7 ++++++ 3 files changed, 56 insertions(+), 3 deletions(-)drivers/net/octeontx2/otx2_ethdev.c +2
-0@@ -4,6 +4,7 @@#include <inttypes.h> +#include <rte_bitops.h> #include <rte_ethdev_pci.h> #include <rte_io.h> #include <rte_malloc.h> @@ -14,6 +15,35 @@#include "otx2_ethdev.h" #include "otx2_ethdev_sec.h" +uint64_t rte_pmd_octeontx2_timestamp_rx_dynflag;drivers/net/octeontx2/otx2_ethdev.c line 28
Quoted 10 lines
drivers/net/octeontx2/otx2_ethdev.c +10
-0+int rte_pmd_octeontx2_timestamp_dynfield_offset =-1 ; + +static int +otx2_rx_timestamp_setup (uint16_t flags) { +int timestamp_rx_dynflag_offset; + +if ((flags &NIX_RX_OFFLOAD_TSTAMP_F ) ==0 ) +return 0 ; + + rte_pmd_octeontx2_timestamp_dynfield_offset =rte_mbuf_dynfield_lookup(
Quoted 37 lines
drivers/net/octeontx2/otx2_ethdev.c +18
-0+ RTE_MBUF_DYNFIELD_TIMESTAMP_NAME, NULL); +if (rte_pmd_octeontx2_timestamp_dynfield_offset <0 ) { +otx2_err ("Failed to lookup timestamp field" ); +return -rte_errno; + } + timestamp_rx_dynflag_offset =rte_mbuf_dynflag_lookup ( +RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME ,NULL ); +if (timestamp_rx_dynflag_offset <0 ) { +otx2_err ("Failed to lookup Rx timestamp flag" ); +return -rte_errno; + } + rte_pmd_octeontx2_timestamp_rx_dynflag = +RTE_BIT64 (timestamp_rx_dynflag_offset); + +return 0 ; +} +static inline uint64_t nix_get_rx_offload_capa(struct otx2_eth_dev *dev) { @@ -1874,6 +1904,9 @@ otx2_nix_configure(struct rte_eth_dev *eth_dev) dev->tx_offload_flags |=nix_tx_offload_flags (eth_dev);dev->rss_info.rss_grps = NIX_RSS_GRPS;drivers/net/octeontx2/otx2_ethdev.c +3
-0+if (otx2_rx_timestamp_setup (dev->rx_offload_flags) !=0 ) + goto fail_offloads; + nb_rxq =RTE_MAX (data->nb_rx_queues,1 ); nb_txq =RTE_MAX (data->nb_tx_queues,1 );(quoted diff) +0
-0
b/drivers/net/octeontx2/otx2_rx.hindex61a5c436dd..6981edce82100644drivers/net/octeontx2/otx2_rx.h +0
-0@@ -63,6 +63,18 @@ union mbuf_initializer {uint64_t value; };Quoted 13 lines
drivers/net/octeontx2/otx2_rx.h union mbuf_initializer { · line 77
Quoted 11 lines
drivers/net/octeontx2/otx2_rx.h +11
-0+/* variables are exported because this file is included in other +drivers */ extern uint64_t rte_pmd_octeontx2_timestamp_rx_dynflag; +extern int rte_pmd_octeontx2_timestamp_dynfield_offset; + +static inline rte_mbuf_timestamp_t * +otx2_timestamp_dynfield (struct rte_mbuf *mbuf) { +return RTE_MBUF_DYNFIELD (mbuf, + rte_pmd_octeontx2_timestamp_dynfield_offset, + rte_mbuf_timestamp_t *); +} +May be ethdev should provide the inline function?
Just five cents - exporting the offset (making it global) might have side effect impacting the performance. Offset might be located in some memory sharing the cacheline with some other variables.
If these variables are writable and are being updated frequently - we might get the cache contention. I'd prefer to keep all dynamic offsets In the PMD and entirely control memory allocation attributes for these ones. Hence, exporting/inline function is possible,
but practical usage, say, in datapath, is questionable.With best regards, Slava
Re: [dpdk-dev] [PATCH 10/15] net/octeontx2: switch timestamp to dynamic mbuf field
30/10/2020 13:41, Jerin Jacob:
Quoted 14 lines · Slava Ovsiienko
Quoted 3 lines
From: Andrew Rybchenko <[email protected]>
Just five cents - exporting the offset (making it global) might have side effect impacting the performance.
I agree with Slava. The offset value should be stored in the PMD structure. IMO, We can have an ethdev API to get the offset and store it in PMD's fastpath structures in the slow path
to use in fastpath.Quoted 4 lines
Offset might be located in some memory sharing the cacheline with some other variables. If these variables are writable and are being updated frequently - we might get the cache contention. I'd prefer to keep all dynamic offsets In the PMD and entirely control memory allocation attributes for these ones. Hence, exporting is OK, but practical usage in datapath is questionable.
Yes this is a major design point:
the field offsets are preferably stored in a hot cache line which depends on the driver, library or application context.
Re: [dpdk-dev] [PATCH 10/15] net/octeontx2: switch timestamp to dynamic mbuf field
In reply to Jerin JacobQuoted 6 lines · Jerin Jacob
Quoted 1 line · Slava Ovsiienko
Just five cents - exporting the offset (making it global) might have side effect impacting the performance.
I agree with Slava. The offset value should be stored in the PMD structure. IMO, We can have an ethdev API to get the offset and store it in PMD's fastpath structures in the slow path
to use in fastpath.
I don't mind. My main goal is to raise the topic and, may be, add a bit more comments in the code to help the future maintainers to understand it. It is not trivial topic and any help to code readers in the comments would be very useful.
Quoted 119 lines
Quoted 119 lines
Offset might be located in some memory sharing the cacheline with some other variables. If these variables are writable and are being updated frequently - we might get the cache contention. I'd prefer to keep all dynamic offsets In the PMD and entirely control memory allocation attributes for these ones. Hence, exporting is OK, but practical usage in datapath is questionable.
With best regards, Slava
Quoted 91 lines
-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Thursday, October 29, 2020 13:02
To: NBU-Contact-Thomas Monjalon <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Slava Ovsiienko <[email protected]>; Nithin Dabilpuram <[email protected]>; Kiran Kumar K <[email protected]>; Ray Kinsella <[email protected]>; Neil Horman <[email protected]>
Subject: Re: [PATCH 10/15] net/octeontx2: switch timestamp to dynamic mbuf fieldQuoted 7 lines · Thomas Monjalon
The mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field.
The related mbuf flag is also replaced.Signed-off-by Thomas Monjalon <[email protected]>--- drivers/net/octeontx2/otx2_ethdev.c | 33+++++++++++++++++++++++++++++
Quoted 22 lines
drivers/net/octeontx2/otx2_rx.h | 19 ++++++++++++++--- drivers/net/octeontx2/version.map | 7 ++++++ 3 files changed, 56 insertions(+), 3 deletions(-)drivers/net/octeontx2/otx2_ethdev.c +2
-0@@ -4,6 +4,7 @@#include <inttypes.h> +#include <rte_bitops.h> #include <rte_ethdev_pci.h> #include <rte_io.h> #include <rte_malloc.h> @@ -14,6 +15,35 @@#include "otx2_ethdev.h" #include "otx2_ethdev_sec.h" +uint64_t rte_pmd_octeontx2_timestamp_rx_dynflag;drivers/net/octeontx2/otx2_ethdev.c line 28
Quoted 10 lines
drivers/net/octeontx2/otx2_ethdev.c +10
-0+int rte_pmd_octeontx2_timestamp_dynfield_offset =-1 ; + +static int +otx2_rx_timestamp_setup (uint16_t flags) { +int timestamp_rx_dynflag_offset; + +if ((flags &NIX_RX_OFFLOAD_TSTAMP_F ) ==0 ) +return 0 ; + + rte_pmd_octeontx2_timestamp_dynfield_offset =rte_mbuf_dynfield_lookup(
Quoted 37 lines
drivers/net/octeontx2/otx2_ethdev.c +18
-0+ RTE_MBUF_DYNFIELD_TIMESTAMP_NAME, NULL); +if (rte_pmd_octeontx2_timestamp_dynfield_offset <0 ) { +otx2_err ("Failed to lookup timestamp field" ); +return -rte_errno; + } + timestamp_rx_dynflag_offset =rte_mbuf_dynflag_lookup ( +RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME ,NULL ); +if (timestamp_rx_dynflag_offset <0 ) { +otx2_err ("Failed to lookup Rx timestamp flag" ); +return -rte_errno; + } + rte_pmd_octeontx2_timestamp_rx_dynflag = +RTE_BIT64 (timestamp_rx_dynflag_offset); + +return 0 ; +} +static inline uint64_t nix_get_rx_offload_capa(struct otx2_eth_dev *dev) { @@ -1874,6 +1904,9 @@ otx2_nix_configure(struct rte_eth_dev *eth_dev) dev->tx_offload_flags |=nix_tx_offload_flags (eth_dev);dev->rss_info.rss_grps = NIX_RSS_GRPS;drivers/net/octeontx2/otx2_ethdev.c +3
-0+if (otx2_rx_timestamp_setup (dev->rx_offload_flags) !=0 ) + goto fail_offloads; + nb_rxq =RTE_MAX (data->nb_rx_queues,1 ); nb_txq =RTE_MAX (data->nb_tx_queues,1 );(quoted diff) +0
-0
b/drivers/net/octeontx2/otx2_rx.hindex61a5c436dd..6981edce82100644drivers/net/octeontx2/otx2_rx.h +0
-0@@ -63,6 +63,18 @@ union mbuf_initializer {uint64_t value; };Quoted 12 lines
drivers/net/octeontx2/otx2_rx.h union mbuf_initializer { · line 77
Quoted 11 lines
drivers/net/octeontx2/otx2_rx.h +11
-0+/* variables are exported because this file is included in other +drivers */ extern uint64_t rte_pmd_octeontx2_timestamp_rx_dynflag; +extern int rte_pmd_octeontx2_timestamp_dynfield_offset; + +static inline rte_mbuf_timestamp_t * +otx2_timestamp_dynfield (struct rte_mbuf *mbuf) { +return RTE_MBUF_DYNFIELD (mbuf, + rte_pmd_octeontx2_timestamp_dynfield_offset, + rte_mbuf_timestamp_t *); +} +May be ethdev should provide the inline function?
Just five cents - exporting the offset (making it global) might have side effect impacting the performance. Offset might be located in some memory sharing the cacheline with some other variables.
If these variables are writable and are being updated frequently - we might get the cache contention. I'd prefer to keep all dynamic offsets In the PMD and entirely control memory allocation attributes for these ones. Hence, exporting/inline function is possible,
but practical usage, say, in datapath, is questionable.With best regards, Slava
PATCH 11/15 net/pcap: switch timestamp to dynamic mbuf field
In reply to Thomas MonjalonThe mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced.
--- drivers/net/pcap/rte_eth_pcap.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-)
drivers/net/pcap/rte_eth_pcap.c +26 -3
@@ -18,6 +18,7 @@#include <pcap.h> +#include <rte_bitops.h> #include <rte_cycles.h> #include <rte_ethdev_driver.h> #include <rte_ethdev_vdev.h>
@@ -51,6 +52,9 @@ static uint64_t start_cycles;static uint64_t hz;static uint8_t iface_idx; +static uint64_t timestamp_rx_dynflag; +static int timestamp_dynfield_offset =-1 ; +struct queue_stat {volatile unsigned long pkts;volatile unsigned long bytes;
@@ -265,9 +269,11 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) } mbuf->pkt_len = (uint16_t )header.caplen; - mbuf->timestamp = (uint64_t )header.ts.tv_sec *1000000 - + header.ts.tv_usec; - mbuf->ol_flags |=PKT_RX_TIMESTAMP ; + *RTE_MBUF_DYNFIELD (mbuf, timestamp_dynfield_offset, + rte_mbuf_timestamp_t *) = + (uint64_t )header.ts.tv_sec *1000000 + + header.ts.tv_usec; + mbuf->ol_flags |= timestamp_rx_dynflag; mbuf->port = pcap_q->port_id; bufs[num_rx] = mbuf; num_rx++;
@@ -656,6 +662,23 @@ eth_dev_stop(struct rte_eth_dev *dev)static int eth_dev_configure(struct rte_eth_dev *dev __rte_unused) { +int timestamp_rx_dynflag_offset; + + timestamp_dynfield_offset =rte_mbuf_dynfield_lookup ( +RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ); +if (timestamp_dynfield_offset <0 ) { +PMD_LOG (ERR ,"Failed to lookup timestamp field" ); +return -rte_errno; + } + timestamp_rx_dynflag_offset =rte_mbuf_dynflag_lookup ( +RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME ,NULL ); +if (timestamp_rx_dynflag_offset <0 ) { +PMD_LOG (ERR ,"Failed lookup Rx timestamp flag" ); +return -rte_errno; + } + timestamp_rx_dynflag = +RTE_BIT64 (timestamp_rx_dynflag_offset); +return 0 ; }
Signature · 1 line
2.28.0
PATCH 12/15 app/testpmd: switch timestamp to dynamic mbuf field
In reply to Thomas MonjalonThe mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced.
--- app/test-pmd/util.c | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-)
app/test-pmd/util.c +37 -2
@@ -5,6 +5,7 @@#include <stdio.h> +#include <rte_bitops.h> #include <rte_net.h> #include <rte_mbuf.h> #include <rte_ether.h>
@@ -22,6 +23,40 @@ print_ether_addr(const char *what, const struct rte_ether_addr *eth_addr)printf ("%s%s" , what, buf); } +static inline bool +is_timestamp_enabled (const struct rte_mbuf *mbuf) +{ +static uint64_t timestamp_rx_dynflag; + +int timestamp_rx_dynflag_offset; + +if (timestamp_rx_dynflag ==0 ) { + timestamp_rx_dynflag_offset =rte_mbuf_dynflag_lookup ( +RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME ,NULL ); +if (timestamp_rx_dynflag_offset <0 ) +return false; + timestamp_rx_dynflag =RTE_BIT64 (timestamp_rx_dynflag_offset); + } + +return (mbuf->ol_flags & timestamp_rx_dynflag) !=0 ; +} + +static inline rte_mbuf_timestamp_t +get_timestamp (const struct rte_mbuf *mbuf) +{ +static int timestamp_dynfield_offset =-1 ; + +if (timestamp_dynfield_offset <0 ) { + timestamp_dynfield_offset =rte_mbuf_dynfield_lookup ( +RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ); +if (timestamp_dynfield_offset <0 ) +return 0 ; + } + +return *RTE_MBUF_DYNFIELD (mbuf, + timestamp_dynfield_offset, rte_mbuf_timestamp_t *); +} +static inline void dump_pkt_burst (uint16_t port_id,uint16_t queue,struct rte_mbuf *pkts[],uint16_t nb_pkts,int is_rx)
@@ -107,8 +142,8 @@ dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],printf ("hash=0x%x ID=0x%x " , mb->hash.fdir.hash, mb->hash.fdir.id); } -if (ol_flags &PKT_RX_TIMESTAMP ) -printf (" - timestamp %" PRIu64" " , mb->timestamp); +if (is_timestamp_enabled (mb)) +printf (" - timestamp %" PRIu64" " ,get_timestamp (mb));if (ol_flags &PKT_RX_QINQ )printf (" - QinQ VLAN tci=0x%x, VLAN tci outer=0x%x" , mb->vlan_tci, mb->vlan_tci_outer);
Signature · 1 line
2.28.0
Re: [dpdk-dev] [PATCH 12/15] app/testpmd: switch timestamp to dynamic mbuf field
Quoted 25 lines · Thomas Monjalon
The mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced.
Signed-off-by Thomas Monjalon <[email protected]>--- app/test-pmd/util.c | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-)app/test-pmd/util.c +1
-0@@ -5,6 +5,7 @@#include <stdio.h> +#include <rte_bitops.h> #include <rte_net.h> #include <rte_mbuf.h> #include <rte_ether.h> @@ -22,6 +23,40 @@ print_ether_addr(const char *what, const struct rte_ether_addr *eth_addr)printf ("%s%s" , what, buf); }
app/test-pmd/util.c print_ether_addr(const char *what, const struct rte_ether_addr *eth_addr) · line 35
Quoted 10 lines
app/test-pmd/util.c +10
-0+static inline bool +is_timestamp_enabled (const struct rte_mbuf *mbuf) +{ +static uint64_t timestamp_rx_dynflag; + +int timestamp_rx_dynflag_offset; + +if (timestamp_rx_dynflag ==0 ) { + timestamp_rx_dynflag_offset =rte_mbuf_dynflag_lookup ( +RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME ,NULL );
If the flag is not registered, it will try to lookup on every call. I'm not sure that it is good.
Quoted 6 lines
app/test-pmd/util.c +6
-0+if (timestamp_rx_dynflag_offset <0 ) +return false; + timestamp_rx_dynflag =RTE_BIT64 (timestamp_rx_dynflag_offset); + } + +return (mbuf->ol_flags & timestamp_rx_dynflag) !=0 ;
app/test-pmd/util.c print_ether_addr(const char *what, const struct rte_ether_addr *eth_addr) · line 51
Quoted 10 lines
app/test-pmd/util.c +10
-0+} + +static inline rte_mbuf_timestamp_t +get_timestamp (const struct rte_mbuf *mbuf) +{ +static int timestamp_dynfield_offset =-1 ; + +if (timestamp_dynfield_offset <0 ) { + timestamp_dynfield_offset =rte_mbuf_dynfield_lookup ( +RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL );
same here
Quoted 23 lines
app/test-pmd/util.c +10
-2+if (timestamp_dynfield_offset <0 ) +return 0 ; + } + +return *RTE_MBUF_DYNFIELD (mbuf, + timestamp_dynfield_offset, rte_mbuf_timestamp_t *); +} +static inline void dump_pkt_burst (uint16_t port_id,uint16_t queue,struct rte_mbuf *pkts[],uint16_t nb_pkts,int is_rx)@@ -107,8 +142,8 @@ dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],printf ("hash=0x%x ID=0x%x " , mb->hash.fdir.hash, mb->hash.fdir.id); } -if (ol_flags &PKT_RX_TIMESTAMP ) -printf (" - timestamp %" PRIu64" " , mb->timestamp); +if (is_timestamp_enabled (mb)) +printf (" - timestamp %" PRIu64" " ,get_timestamp (mb));if (ol_flags &PKT_RX_QINQ )printf (" - QinQ VLAN tci=0x%x, VLAN tci outer=0x%x" , mb->vlan_tci, mb->vlan_tci_outer);
Re: [dpdk-dev] [PATCH 12/15] app/testpmd: switch timestamp to dynamic mbuf field
29/10/2020 11:20, Andrew Rybchenko:
Quoted 14 lines · Thomas Monjalon
Quoted 13 lines
The mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced.
Signed-off-by Thomas Monjalon <[email protected]>---
app/test-pmd/util.c +5
-0+static inline bool +is_timestamp_enabled (const struct rte_mbuf *mbuf) +{ +static uint64_t timestamp_rx_dynflag; +
Quoted 8 lines
app/test-pmd/util.c print_ether_addr(const char *what, const struct rte_ether_addr *eth_addr) · line 35
Quoted 5 lines
app/test-pmd/util.c +5
-0+int timestamp_rx_dynflag_offset; + +if (timestamp_rx_dynflag ==0 ) { + timestamp_rx_dynflag_offset =rte_mbuf_dynflag_lookup ( +RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME ,NULL );If the flag is not registered, it will try to lookup on every call. I'm not sure that it is good.
I don't see the problem.
It is a dump in a test application.
The idea is to have a fresh dump whatever was updated recently.
Re: [dpdk-dev] [PATCH 12/15] app/testpmd: switch timestamp to dynamic mbuf field
Quoted 24 lines · Thomas Monjalon
29/10/2020 11:20, Andrew Rybchenko:
Quoted 14 lines · Thomas Monjalon
Quoted 13 lines
The mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced.
Signed-off-by Thomas Monjalon <[email protected]>---
app/test-pmd/util.c +5
-0+static inline bool +is_timestamp_enabled (const struct rte_mbuf *mbuf) +{ +static uint64_t timestamp_rx_dynflag; +Quoted 8 lines
app/test-pmd/util.c print_ether_addr(const char *what, const struct rte_ether_addr *eth_addr) · line 35
Quoted 5 lines
app/test-pmd/util.c +5
-0+int timestamp_rx_dynflag_offset; + +if (timestamp_rx_dynflag ==0 ) { + timestamp_rx_dynflag_offset =rte_mbuf_dynflag_lookup ( +RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME ,NULL );If the flag is not registered, it will try to lookup on every call. I'm not sure that it is good.
Quoted 3 lines
I don't see the problem.
It is a dump in a test application.
The idea is to have a fresh dump whatever was updated recently.
OK, makes sense.
PATCH 13/15 examples/rxtx_callbacks: switch timestamp to dynamic field
In reply to Thomas MonjalonThe mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field.
--- examples/rxtx_callbacks/main.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
examples/rxtx_callbacks/main.c +11 -1
@@ -19,6 +19,10 @@#define MBUF_CACHE_SIZE 250#define BURST_SIZE 32 +static int hwts_dynfield_offset =-1 ; +#define HWTS_FIELD (mbuf) (*RTE_MBUF_DYNFIELD(mbuf, \ + hwts_dynfield_offset, rte_mbuf_timestamp_t *)) +typedef uint64_t tsc_t ;static int tsc_dynfield_offset =-1 ;#define TSC_FIELD (mbuf) (*RTE_MBUF_DYNFIELD(mbuf, \
@@ -73,7 +77,7 @@ calc_latency(uint16_t port, uint16_t qidx __rte_unused,for (i =0 ; i < nb_pkts; i++) { cycles += now -TSC_FIELD (pkts[i]);if (hw_timestamping) - queue_ticks += ticks - pkts[i]->timestamp; + queue_ticks += ticks -HWTS_FIELD (pkts[i]); } latency_numbers.total_cycles += cycles;
@@ -137,6 +141,12 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)return -1 ; } port_conf.rxmode.offloads |=DEV_RX_OFFLOAD_TIMESTAMP ; + hwts_dynfield_offset =rte_mbuf_dynfield_lookup ( +RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ); +if (hwts_dynfield_offset <0 ) { +printf ("ERROR: Failed to lookup timestamp field\n" ); +return -rte_errno; + } } retval =rte_eth_dev_configure (port, rx_rings, tx_rings, &port_conf);
Signature · 1 line
2.28.0
Re: [dpdk-dev] [PATCH 13/15] examples/rxtx_callbacks: switch timestamp to dynamic field
Quoted 13 lines · Thomas Monjalon
The mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field.
Signed-off-by Thomas Monjalon <[email protected]>--- examples/rxtx_callbacks/main.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)examples/rxtx_callbacks/main.c +0
-0
examples/rxtx_callbacks/main.c line 25
Quoted 7 lines
examples/rxtx_callbacks/main.c +4
-0@@ -19,6 +19,10 @@#define MBUF_CACHE_SIZE 250#define BURST_SIZE 32 +static int hwts_dynfield_offset =-1 ; +#define HWTS_FIELD (mbuf) (*RTE_MBUF_DYNFIELD(mbuf, \ + hwts_dynfield_offset, rte_mbuf_timestamp_t *)) +
Why is approach here differs? Macro vs inline function.
Re: [dpdk-dev] [PATCH 13/15] examples/rxtx_callbacks: switch timestamp to dynamic field
29/10/2020 11:21, Andrew Rybchenko:
Quoted 17 lines · Thomas Monjalon
Quoted 16 lines
The mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field.
Signed-off-by Thomas Monjalon <[email protected]>--- examples/rxtx_callbacks/main.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)examples/rxtx_callbacks/main.c +0
-0@@ -19,6 +19,10 @@#define MBUF_CACHE_SIZE 250#define BURST_SIZE 32
Quoted 6 lines
examples/rxtx_callbacks/main.c line 25
Quoted 4 lines
examples/rxtx_callbacks/main.c +4
-0+static int hwts_dynfield_offset =-1 ; +#define HWTS_FIELD (mbuf) (*RTE_MBUF_DYNFIELD(mbuf, \ + hwts_dynfield_offset, rte_mbuf_timestamp_t *)) +Why is approach here differs? Macro vs inline function.
Because it is a self-contained file,
and there is already a macro for another field.
If you really want a function, I could it for both fields.
PATCH 14/15 mbuf: remove deprecated timestamp field
In reply to Thomas MonjalonAs announced in the deprecation note, the field timestamp is removed to allow giving more space to the dynamic fields. The related offload flag PKT_RX_TIMESTAMP is also removed.
--- app/test/test_mbuf.c | 1 - doc/guides/rel_notes/deprecation.rst | 1 - doc/guides/rel_notes/release_20_11.rst | 4 ++++ lib/librte_ethdev/rte_ethdev.h | 4 +++- lib/librte_mbuf/rte_mbuf.c | 2 -- lib/librte_mbuf/rte_mbuf.h | 1 - lib/librte_mbuf/rte_mbuf_core.h | 12 +----------- 7 files changed, 8 insertions(+), 17 deletions(-)
app/test/test_mbuf.c +0 -1
@@ -1621,7 +1621,6 @@ test_get_rx_ol_flag_name(void)VAL_NAME (PKT_RX_FDIR_FLX ),VAL_NAME (PKT_RX_QINQ_STRIPPED ),VAL_NAME (PKT_RX_LRO ), -VAL_NAME (PKT_RX_TIMESTAMP ),VAL_NAME (PKT_RX_SEC_OFFLOAD ),VAL_NAME (PKT_RX_SEC_OFFLOAD_FAILED ), VAL_NAME(PKT_RX_OUTER_L4_CKSUM_BAD),
doc/guides/rel_notes/deprecation.rst +0 -1
@@ -86,7 +86,6 @@ Deprecation Notices `this presentation <https://www.youtube.com/watch?v=Ttl6MlhmzWY>`_. The following static fields will be moved as dynamic: - - ``timestamp`` - ``seqn`` As a consequence, the layout of the ``struct rte_mbuf`` will be re-arranged,
doc/guides/rel_notes/release_20_11.rst +4 -0
@@ -429,6 +429,10 @@ API Changes * mbuf: Removed the unioned fields ``userdata`` and ``udata64`` from the structure ``rte_mbuf``. It is replaced with dynamic fields. +* mbuf: Removed the field ``timestamp`` from the structure ``rte_mbuf``. + It is replaced with the dynamic field RTE_MBUF_DYNFIELD_TIMESTAMP_NAME + which was previously used only for Tx. + * pci: Removed the ``rte_kernel_driver`` enum defined in rte_dev.h and replaced with a private enum in the PCI subsystem.
lib/librte_ethdev/rte_ethdev.h +3 -1
@@ -1345,6 +1345,8 @@ struct rte_eth_conf {#define DEV_RX_OFFLOAD_JUMBO_FRAME 0x00000800#define DEV_RX_OFFLOAD_SCATTER 0x00002000/** +* Timestamp is set by the driver in RTE_MBUF_DYNFIELD_TIMESTAMP_NAME +* and RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME is set in ol_flags. * The mbuf field and flag are registered when the offload is configured. */ #define DEV_RX_OFFLOAD_TIMESTAMP 0x00004000
@@ -4654,7 +4656,7 @@ int rte_eth_timesync_write_time(uint16_t port_id, const struct timespec *time);* rte_eth_read_clock(port, base_clock); * * Then, convert the raw mbuf timestamp with: -* base_time_sec + (double)(mbuf->timestamp - base_clock) / freq; +* base_time_sec + (double)(*timestamp_dynfield(mbuf) - 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.
lib/librte_mbuf/rte_mbuf.c +0 -2
@@ -764,7 +764,6 @@ const char *rte_get_rx_ol_flag_name(uint64_t mask)case PKT_RX_QINQ_STRIPPED :return "PKT_RX_QINQ_STRIPPED" ;case PKT_RX_QINQ :return "PKT_RX_QINQ" ;case PKT_RX_LRO :return "PKT_RX_LRO" ; -case PKT_RX_TIMESTAMP :return "PKT_RX_TIMESTAMP" ;case PKT_RX_SEC_OFFLOAD :return "PKT_RX_SEC_OFFLOAD" ;case PKT_RX_SEC_OFFLOAD_FAILED :return "PKT_RX_SEC_OFFLOAD_FAILED" ;case PKT_RX_OUTER_L4_CKSUM_BAD :return "PKT_RX_OUTER_L4_CKSUM_BAD" ;
@@ -808,7 +807,6 @@ rte_get_rx_ol_flag_list(uint64_t mask, char *buf, size_t buflen) { PKT_RX_FDIR_FLX, PKT_RX_FDIR_FLX, NULL }, { PKT_RX_QINQ_STRIPPED, PKT_RX_QINQ_STRIPPED, NULL }, { PKT_RX_LRO, PKT_RX_LRO, NULL }, - { PKT_RX_TIMESTAMP, PKT_RX_TIMESTAMP, NULL }, { PKT_RX_SEC_OFFLOAD, PKT_RX_SEC_OFFLOAD, NULL }, { PKT_RX_SEC_OFFLOAD_FAILED, PKT_RX_SEC_OFFLOAD_FAILED, NULL }, { PKT_RX_QINQ, PKT_RX_QINQ, NULL },
lib/librte_mbuf/rte_mbuf.h +0 -1
@@ -1108,7 +1108,6 @@ __rte_pktmbuf_copy_hdr(struct rte_mbuf *mdst, const struct rte_mbuf *msrc) mdst->tx_offload = msrc->tx_offload; mdst->hash = msrc->hash; mdst->packet_type = msrc->packet_type; - mdst->timestamp = msrc->timestamp;rte_mbuf_dynfield_copy (mdst, msrc); }
lib/librte_mbuf/rte_mbuf_core.h +1 -11
@@ -149,11 +149,6 @@ extern "C" {*/ #define PKT_RX_LRO (1ULL << 16) -/** -* Indicate that the timestamp field in the mbuf is valid. -*/ -#define PKT_RX_TIMESTAMP (1ULL << 17) -/** * Indicate that security offload processing was applied on the RX packet. */
@@ -589,12 +584,7 @@ struct rte_mbuf {uint16_t buf_len;/**< Length of segment buffer. */ -/** 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; +uint64_t unused;/* second cache line - fields only used in slow path or on TX */ RTE_MARKER cacheline1 __rte_cache_min_aligned;
Signature · 1 line
2.28.0
Re: [dpdk-dev] [PATCH 14/15] mbuf: remove deprecated timestamp field
Quoted 5 lines · Thomas Monjalon
As announced in the deprecation note, the field timestamp is removed to allow giving more space to the dynamic fields. The related offload flag
PKT_RX_TIMESTAMPis also removed.Signed-off-by Thomas Monjalon <[email protected]>
Ajit Khaparde
Acked-byRe: [dpdk-dev] [PATCH 14/15] mbuf: remove deprecated timestamp field
Quoted 9 lines · Andrew Rybchenko
Quoted 5 lines · Thomas Monjalon
As announced in the deprecation note, the field timestamp is removed to allow giving more space to the dynamic fields. The related offload flag
PKT_RX_TIMESTAMPis also removed.Signed-off-by Thomas Monjalon <[email protected]>Reviewed-by Andrew Rybchenko <[email protected]>
Re: [dpdk-dev] [PATCH 14/15] mbuf: remove deprecated timestamp field
In reply to Thomas MonjalonQuoted 128 lines · Thomas Monjalon
As announced in the deprecation note, the field timestamp is removed to allow giving more space to the dynamic fields. The related offload flag
PKT_RX_TIMESTAMPis also removed.Signed-off-by Thomas Monjalon <[email protected]>--- app/test/test_mbuf.c | 1 - doc/guides/rel_notes/deprecation.rst | 1 - doc/guides/rel_notes/release_20_11.rst | 4 ++++ lib/librte_ethdev/rte_ethdev.h | 4 +++- lib/librte_mbuf/rte_mbuf.c | 2 -- lib/librte_mbuf/rte_mbuf.h | 1 - lib/librte_mbuf/rte_mbuf_core.h | 12 +----------- 7 files changed, 8 insertions(+), 17 deletions(-)app/test/test_mbuf.c +0
-1@@ -1621,7 +1621,6 @@ test_get_rx_ol_flag_name(void)VAL_NAME (PKT_RX_FDIR_FLX ),VAL_NAME (PKT_RX_QINQ_STRIPPED ),VAL_NAME (PKT_RX_LRO ), -VAL_NAME (PKT_RX_TIMESTAMP ),VAL_NAME (PKT_RX_SEC_OFFLOAD ),VAL_NAME (PKT_RX_SEC_OFFLOAD_FAILED ), VAL_NAME(PKT_RX_OUTER_L4_CKSUM_BAD),doc/guides/rel_notes/deprecation.rst +0
-1@@ -86,7 +86,6 @@ Deprecation Notices `this presentation <https://www.youtube.com/watch?v=Ttl6MlhmzWY>`_. The following static fields will be moved as dynamic: - - ``timestamp`` - ``seqn`` As a consequence, the layout of the ``struct rte_mbuf`` will be re-arranged,doc/guides/rel_notes/release_20_11.rst +4
-0@@ -429,6 +429,10 @@ API Changes * mbuf: Removed the unioned fields ``userdata`` and ``udata64`` from the structure ``rte_mbuf``. It is replaced with dynamic fields. +* mbuf: Removed the field ``timestamp`` from the structure ``rte_mbuf``. + It is replaced with the dynamic field RTE_MBUF_DYNFIELD_TIMESTAMP_NAME + which was previously used only for Tx. + * pci: Removed the ``rte_kernel_driver`` enum defined in rte_dev.h and replaced with a private enum in the PCI subsystem.lib/librte_ethdev/rte_ethdev.h +3
-1@@ -1345,6 +1345,8 @@ struct rte_eth_conf {#define DEV_RX_OFFLOAD_JUMBO_FRAME 0x00000800#define DEV_RX_OFFLOAD_SCATTER 0x00002000/** +* Timestamp is set by the driver in RTE_MBUF_DYNFIELD_TIMESTAMP_NAME +* and RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME is set in ol_flags. * The mbuf field and flag are registered when the offload is configured. */ #define DEV_RX_OFFLOAD_TIMESTAMP 0x00004000@@ -4654,7 +4656,7 @@ int rte_eth_timesync_write_time(uint16_t port_id, const struct timespec *time);* rte_eth_read_clock(port, base_clock); * * Then, convert the raw mbuf timestamp with: -* base_time_sec + (double)(mbuf->timestamp - base_clock) / freq; +* base_time_sec + (double)(*timestamp_dynfield(mbuf) - 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. lib/librte_mbuf/rte_mbuf.c +0
-2@@ -764,7 +764,6 @@ const char *rte_get_rx_ol_flag_name(uint64_t mask)case PKT_RX_QINQ_STRIPPED :return "PKT_RX_QINQ_STRIPPED" ;case PKT_RX_QINQ :return "PKT_RX_QINQ" ;case PKT_RX_LRO :return "PKT_RX_LRO" ; -case PKT_RX_TIMESTAMP :return "PKT_RX_TIMESTAMP" ;case PKT_RX_SEC_OFFLOAD :return "PKT_RX_SEC_OFFLOAD" ;case PKT_RX_SEC_OFFLOAD_FAILED :return "PKT_RX_SEC_OFFLOAD_FAILED" ;case PKT_RX_OUTER_L4_CKSUM_BAD :return "PKT_RX_OUTER_L4_CKSUM_BAD" ;@@ -808,7 +807,6 @@ rte_get_rx_ol_flag_list(uint64_t mask, char *buf, size_t buflen) { PKT_RX_FDIR_FLX, PKT_RX_FDIR_FLX, NULL }, { PKT_RX_QINQ_STRIPPED, PKT_RX_QINQ_STRIPPED, NULL }, { PKT_RX_LRO, PKT_RX_LRO, NULL }, - { PKT_RX_TIMESTAMP, PKT_RX_TIMESTAMP, NULL }, { PKT_RX_SEC_OFFLOAD, PKT_RX_SEC_OFFLOAD, NULL }, { PKT_RX_SEC_OFFLOAD_FAILED, PKT_RX_SEC_OFFLOAD_FAILED, NULL }, { PKT_RX_QINQ, PKT_RX_QINQ, NULL },lib/librte_mbuf/rte_mbuf.h +0
-1@@ -1108,7 +1108,6 @@ __rte_pktmbuf_copy_hdr(struct rte_mbuf *mdst, const struct rte_mbuf *msrc) mdst->tx_offload = msrc->tx_offload; mdst->hash = msrc->hash; mdst->packet_type = msrc->packet_type; - mdst->timestamp = msrc->timestamp;rte_mbuf_dynfield_copy (mdst, msrc); }lib/librte_mbuf/rte_mbuf_core.h +0
-5@@ -149,11 +149,6 @@ extern "C" {*/ #define PKT_RX_LRO (1ULL << 16) -/** -* Indicate that the timestamp field in the mbuf is valid. -*/ -#define PKT_RX_TIMESTAMP (1ULL << 17) -/** * Indicate that security offload processing was applied on the RX packet. */ @@ -589,12 +584,7 @@ struct rte_mbuf {uint16_t buf_len;/**< Length of segment buffer. */
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 590
Quoted 10 lines
lib/librte_mbuf/rte_mbuf_core.h +1
-6-/** 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; +uint64_t unused;/* second cache line - fields only used in slow path or on TX */ RTE_MARKER cacheline1 __rte_cache_min_aligned;
PATCH 15/15 mbuf: move pool pointer in hotter first half
In reply to Thomas MonjalonThe mempool pointer in the mbuf struct is moved
from the second to the first half.
It should increase performance on most systems having 64-byte cache line, i.e. mbuf is split in two cache lines.
On such system, the first half (also called first cache line) is hotter than the second one where the pool pointer was.
Moving this field gives more space to dynfield1.
This is how the mbuf layout looks like (pahole-style):
word type name byte size
0 void * buf_addr; /* 0 + 8 */
1 rte_iova_t buf_iova /* 8 + 8 */
/* --- RTE_MARKER64 rearm_data; */
2 uint16_t data_off; /* 16 + 2 */
uint16_t refcnt; /* 18 + 2 */
uint16_t nb_segs; /* 20 + 2 */
uint16_t port; /* 22 + 2 */
3 uint64_t ol_flags; /* 24 + 8 */
/* --- RTE_MARKER rx_descriptor_fields1; */
4 uint32_t union packet_type; /* 32 + 4 */
uint32_t pkt_len; /* 36 + 4 */
5 uint16_t data_len; /* 40 + 2 */
uint16_t vlan_tci; /* 42 + 2 */
5.5 uint64_t union hash; /* 44 + 8 */
6.5 uint16_t vlan_tci_outer; /* 52 + 2 */
uint16_t buf_len; /* 54 + 2 */
7 struct rte_mempool * pool; /* 56 + 8 */
/* --- RTE_MARKER cacheline1; */
8 struct rte_mbuf * next; /* 64 + 8 */
9 uint64_t union tx_offload; /* 72 + 8 */
10 uint16_t priv_size; /* 80 + 2 */
uint16_t timesync; /* 82 + 2 */
uint32_t seqn; /* 84 + 4 */
11 struct rte_mbuf_ext_shared_info * shinfo; /* 88 + 8 */
12 uint64_t dynfield1[4]; /* 96 + 32 */
16 /* --- END 128 */--- doc/guides/rel_notes/deprecation.rst | 5 ----- lib/librte_kni/rte_kni_common.h | 3 ++- lib/librte_mbuf/rte_mbuf_core.h | 5 ++--- 3 files changed, 4 insertions(+), 9 deletions(-)
doc/guides/rel_notes/deprecation.rst +0 -5
@@ -88,11 +88,6 @@ Deprecation Notices - ``seqn`` - As a consequence, the layout of the ``struct rte_mbuf`` will be re-arranged, - avoiding impact on vectorized implementation of the driver datapaths, - while evaluating performance gains of a better use of the first cache line. - - * ethdev: the legacy filter API, including ``rte_eth_dev_filter_supported()``, ``rte_eth_dev_filter_ctrl()`` as well as filter types MACVLAN, ETHERTYPE, FLEXIBLE, SYN, NTUPLE, TUNNEL, FDIR,
lib/librte_kni/rte_kni_common.h +2 -1
@@ -84,10 +84,11 @@ struct rte_kni_mbuf {char pad2[4 ];uint32_t pkt_len;/**< Total pkt len: sum of all segment data_len. */ uint16_t data_len;/**< Amount of data in segment buffer. */ +char pad3[14 ]; +void *pool;/* fields on second cache line */ __attribute__((__aligned__ (RTE_CACHE_LINE_MIN_SIZE ))) -void *pool;void *next;/**< Physical address of next mbuf in kernel. */ };
lib/librte_mbuf/rte_mbuf_core.h +2 -3
@@ -584,12 +584,11 @@ struct rte_mbuf {uint16_t buf_len;/**< Length of segment buffer. */ -uint64_t unused; +struct rte_mempool *pool;/**< Pool from which mbuf was allocated. */ /* second cache line - fields only used in slow path or on TX */ RTE_MARKER cacheline1 __rte_cache_min_aligned; -struct rte_mempool *pool;/**< Pool from which mbuf was allocated. */ struct rte_mbuf *next;/**< Next segment of scattered packet. */ /* fields to support TX offloads */
@@ -646,7 +645,7 @@ struct rte_mbuf {*/ struct rte_mbuf_ext_shared_info *shinfo; -uint64_t dynfield1[3 ];/**< Reserved for dynamic fields. */ +uint64_t dynfield1[4 ];/**< Reserved for dynamic fields. */ } __rte_cache_aligned;/**
Signature · 1 line
2.28.0
Re: [dpdk-dev] [PATCH 15/15] mbuf: move pool pointer in hotter first half
Quoted 39 lines · Thomas Monjalon
The mempool pointer in the mbuf struct is moved
from the second to the first half.
It should increase performance on most systems having 64-byte cache line, i.e. mbuf is split in two cache lines.
On such system, the first half (also called first cache line) is hotter than the second one where the pool pointer was.Moving this field gives more space to dynfield1.
This is how the mbuf layout looks like (pahole-style):
word type name byte size 0 void * buf_addr; /* 0 + 8 */ 1 rte_iova_t buf_iova /* 8 + 8 */ /* --- RTE_MARKER64 rearm_data; */ 2 uint16_t data_off; /* 16 + 2 */ uint16_t refcnt; /* 18 + 2 */ uint16_t nb_segs; /* 20 + 2 */ uint16_t port; /* 22 + 2 */ 3 uint64_t ol_flags; /* 24 + 8 */ /* --- RTE_MARKER rx_descriptor_fields1; */ 4 uint32_t union packet_type; /* 32 + 4 */ uint32_t pkt_len; /* 36 + 4 */ 5 uint16_t data_len; /* 40 + 2 */ uint16_t vlan_tci; /* 42 + 2 */ 5.5 uint64_t union hash; /* 44 + 8 */ 6.5 uint16_t vlan_tci_outer; /* 52 + 2 */ uint16_t buf_len; /* 54 + 2 */ 7 struct rte_mempool * pool; /* 56 + 8 */ /* --- RTE_MARKER cacheline1; */ 8 struct rte_mbuf * next; /* 64 + 8 */ 9 uint64_t union tx_offload; /* 72 + 8 */ 10 uint16_t priv_size; /* 80 + 2 */ uint16_t timesync; /* 82 + 2 */ uint32_t seqn; /* 84 + 4 */ 11 struct rte_mbuf_ext_shared_info * shinfo; /* 88 + 8 */ 12 uint64_t dynfield1[4]; /* 96 + 32 */ 16 /* --- END 128 */
Quoted 1 line
Signed-off-by Thomas Monjalon <[email protected]>
I'd like to understand why pool is chosen instead of, for example, next pointer.
Pool is used on housekeeping when driver refills Rx ring or free completed Tx mbufs. Free thresholds try to avoid it on every Rx/Tx burst (if possible).
Next is used for multi-segment Tx and scattered (and buffer split) Rx. IMHO the key question here is we consider these use cases as common and priority to optimize. If yes, I'd vote to have next on the first cacheline.
I'm not sure. Just trying to hear a bit more about it.
Re: [dpdk-dev] [PATCH 15/15] mbuf: move pool pointer in hotter first half
29/10/2020 11:50, Andrew Rybchenko:
Quoted 49 lines · Thomas Monjalon
Quoted 39 lines
The mempool pointer in the mbuf struct is moved
from the second to the first half.
It should increase performance on most systems having 64-byte cache line, i.e. mbuf is split in two cache lines.
On such system, the first half (also called first cache line) is hotter than the second one where the pool pointer was.Moving this field gives more space to dynfield1.
This is how the mbuf layout looks like (pahole-style):
word type name byte size 0 void * buf_addr; /* 0 + 8 */ 1 rte_iova_t buf_iova /* 8 + 8 */ /* --- RTE_MARKER64 rearm_data; */ 2 uint16_t data_off; /* 16 + 2 */ uint16_t refcnt; /* 18 + 2 */ uint16_t nb_segs; /* 20 + 2 */ uint16_t port; /* 22 + 2 */ 3 uint64_t ol_flags; /* 24 + 8 */ /* --- RTE_MARKER rx_descriptor_fields1; */ 4 uint32_t union packet_type; /* 32 + 4 */ uint32_t pkt_len; /* 36 + 4 */ 5 uint16_t data_len; /* 40 + 2 */ uint16_t vlan_tci; /* 42 + 2 */ 5.5 uint64_t union hash; /* 44 + 8 */ 6.5 uint16_t vlan_tci_outer; /* 52 + 2 */ uint16_t buf_len; /* 54 + 2 */ 7 struct rte_mempool * pool; /* 56 + 8 */ /* --- RTE_MARKER cacheline1; */ 8 struct rte_mbuf * next; /* 64 + 8 */ 9 uint64_t union tx_offload; /* 72 + 8 */ 10 uint16_t priv_size; /* 80 + 2 */ uint16_t timesync; /* 82 + 2 */ uint32_t seqn; /* 84 + 4 */ 11 struct rte_mbuf_ext_shared_info * shinfo; /* 88 + 8 */ 12 uint64_t dynfield1[4]; /* 96 + 32 */ 16 /* --- END 128 */Quoted 1 line
Signed-off-by Thomas Monjalon <[email protected]>I'd like to understand why pool is chosen instead of, for example, next pointer.
Pool is used on housekeeping when driver refills Rx ring or free completed Tx mbufs. Free thresholds try to avoid it on every Rx/Tx burst (if possible).
Quoted 6 lines
Next is used for multi-segment Tx and scattered (and buffer split) Rx. IMHO the key question here is we consider these use cases as common and priority to optimize. If yes, I'd vote to have next on the first cacheline.
I'm not sure. Just trying to hear a bit more about it.
That's a good question.
Clearly pool and next are good options.
The best would be to have some benchmarks.
If one use case shows no benefit, the decision is easier.
If you prefer, we can leave this last patch for -rc3.
Re: [dpdk-dev] [PATCH 15/15] mbuf: move pool pointer in hotter first half
Quoted 57 lines
29/10/2020 11:50, Andrew Rybchenko:
Quoted 53 lines · Thomas Monjalon
Quoted 39 lines
The mempool pointer in the mbuf struct is moved
from the second to the first half.
It should increase performance on most systems having 64-byte cache line, i.e. mbuf is split in two cache lines.
On such system, the first half (also called first cache line) is hotter than the second one where the pool pointer was.Moving this field gives more space to dynfield1.
This is how the mbuf layout looks like (pahole-style):
word type name byte size 0 void * buf_addr; /* 0 + 8 */ 1 rte_iova_t buf_iova /* 8 + 8 */ /* --- RTE_MARKER64 rearm_data; */ 2 uint16_t data_off; /* 16 + 2 */ uint16_t refcnt; /* 18 + 2 */ uint16_t nb_segs; /* 20 + 2 */ uint16_t port; /* 22 + 2 */ 3 uint64_t ol_flags; /* 24 + 8 */ /* --- RTE_MARKER rx_descriptor_fields1; */ 4 uint32_t union packet_type; /* 32 + 4 */ uint32_t pkt_len; /* 36 + 4 */ 5 uint16_t data_len; /* 40 + 2 */ uint16_t vlan_tci; /* 42 + 2 */ 5.5 uint64_t union hash; /* 44 + 8 */ 6.5 uint16_t vlan_tci_outer; /* 52 + 2 */ uint16_t buf_len; /* 54 + 2 */ 7 struct rte_mempool * pool; /* 56 + 8 */ /* --- RTE_MARKER cacheline1; */ 8 struct rte_mbuf * next; /* 64 + 8 */ 9 uint64_t union tx_offload; /* 72 + 8 */ 10 uint16_t priv_size; /* 80 + 2 */ uint16_t timesync; /* 82 + 2 */ uint32_t seqn; /* 84 + 4 */ 11 struct rte_mbuf_ext_shared_info * shinfo; /* 88 + 8 */ 12 uint64_t dynfield1[4]; /* 96 + 32 */ 16 /* --- END 128 */Quoted 1 line
Signed-off-by Thomas Monjalon <[email protected]>I'd like to understand why pool is chosen instead of, for example, next pointer.
Pool is used on housekeeping when driver refills Rx ring or free completed Tx mbufs. Free thresholds try to avoid it on every Rx/Tx burst (if possible).
Next is used for multi-segment Tx and scattered (and buffer split) Rx. IMHO the key question here is we consider these use cases as common and priority to optimize. If yes, I'd vote to have next on the first cacheline.
Between these two I also would probably lean towards *next* (after all _free_ also has to access/update next). As another alternative to consider: tx_offload.
It is also used quite widely.
Quoted 10 lines
Quoted 2 lines
I'm not sure. Just trying to hear a bit more about it.
.
That's a good question.
Clearly pool and next are good options.
The best would be to have some benchmarks.
If one use case shows no benefit, the decision is easier.If you prefer, we can leave this last patch for -rc3.
Re: [dpdk-dev] [PATCH 15/15] mbuf: move pool pointer in hotter first half
Quoted 54 lines · Konstantin
Quoted 54 lines
29/10/2020 11:50, Andrew Rybchenko:
Quoted 49 lines · Thomas Monjalon
Quoted 39 lines
The mempool pointer in the mbuf struct is moved
from the second to the first half.
It should increase performance on most systems having 64-byte cache line, i.e. mbuf is split in two cache lines.
On such system, the first half (also called first cache line) is hotter than the second one where the pool pointer was.Moving this field gives more space to dynfield1.
This is how the mbuf layout looks like (pahole-style):
word type name byte size 0 void * buf_addr; /* 0 + 8 */ 1 rte_iova_t buf_iova /* 8 + 8 */ /* --- RTE_MARKER64 rearm_data; */ 2 uint16_t data_off; /* 16 + 2 */ uint16_t refcnt; /* 18 + 2 */ uint16_t nb_segs; /* 20 + 2 */ uint16_t port; /* 22 + 2 */ 3 uint64_t ol_flags; /* 24 + 8 */ /* --- RTE_MARKER rx_descriptor_fields1; */ 4 uint32_t union packet_type; /* 32 + 4 */ uint32_t pkt_len; /* 36 + 4 */ 5 uint16_t data_len; /* 40 + 2 */ uint16_t vlan_tci; /* 42 + 2 */ 5.5 uint64_t union hash; /* 44 + 8 */ 6.5 uint16_t vlan_tci_outer; /* 52 + 2 */ uint16_t buf_len; /* 54 + 2 */ 7 struct rte_mempool * pool; /* 56 + 8 */ /* --- RTE_MARKER cacheline1; */ 8 struct rte_mbuf * next; /* 64 + 8 */ 9 uint64_t union tx_offload; /* 72 + 8 */ 10 uint16_t priv_size; /* 80 + 2 */ uint16_t timesync; /* 82 + 2 */ uint32_t seqn; /* 84 + 4 */ 11 struct rte_mbuf_ext_shared_info * shinfo; /* 88 + 8 */ 12 uint64_t dynfield1[4]; /* 96 + 32 */ 16 /* --- END 128 */Quoted 1 line
Signed-off-by Thomas Monjalon <[email protected]>I'd like to understand why pool is chosen instead of, for example, next pointer.
Pool is used on housekeeping when driver refills Rx ring or free completed Tx mbufs. Free thresholds try to avoid it on every Rx/Tx burst (if possible).
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Next is used for multi-segment Tx and scattered (and buffer split) Rx. IMHO the key question here is we consider these use cases as common and priority to optimize. If yes, I'd vote to have next on the first cacheline.
Between these two I also would probably lean towards *next* (after all _free_ also has to access/update next).
+1
Quoted 14 lines
As another alternative to consider:
tx_offload.
It is also used quite widely.Quoted 10 lines
Quoted 2 lines
I'm not sure. Just trying to hear a bit more about it.
.
That's a good question.
Clearly pool and next are good options.
The best would be to have some benchmarks.
If one use case shows no benefit, the decision is easier.If you prefer, we can leave this last patch for -rc3.
Re: [dpdk-dev] [PATCH 15/15] mbuf: move pool pointer in hotterfirst half
Thomas,
Adding my thoughts to the already detailed feedback on this important patch...
The first cache line is not inherently "hotter" than the second. The hotness depends on their usage.
The mbuf cacheline1 marker has the following comment:
/* second cache line - fields only used in slow path or on TX */
In other words, the second cache line is intended not to be touched in fast path RX.
I do not think this is true anymore. Not even with simple non-scattered RX. And regression testing probably didn't catch this, because the tests perform TX after RX, so the cache miss moved from TX to RX and became a cache hit in TX instead. (I may be wrong about this claim, but it's not important for the discussion.)
I think the right question for this patch is: Can we achieve this - not using the second cache line for fast path RX - again by putting the right fields in the first cache line?
Probably not in all cases, but perhaps for some...
Consider the application scenarios.
When a packet is received, one of three things happens to it:
1. It is immediately transmitted on one or more ports.
2. It is immediately discarded, e.g. by a firewall rule.
3. It is put in some sort of queue, e.g. a ring for the next pipeline stage, or in a QoS queue.
1. If the packet is immediately transmitted, the m->tx_offload field in the second cache line will be touched by the application and TX function anyway, so we don't need to optimize the mbuf layout for this scenario.
2. The second scenario touches m->pool no matter how it is implemented. The application can avoid touching m->next by using rte_mbuf_raw_free(), knowing that the mbuf came directly from RX and thus no other fields have been touched. In this scenario, we want m->pool in the first cache line.
3. Now, let's consider the third scenario, where RX is followed by enqueue into a ring. If the application does nothing but put the packet into a ring, we don't need to move anything into the first cache line. But applications usually does more... So it is application specific what would be good to move to the first cache line:
A. If the application does not use segmented mbufs, and performs analysis and preparation for transmission in the initial pipeline stages, and only the last pipeline stage performs TX, we could move m->tx_offload to the first cache line, which would keep the second cache line cold until the actual TX happens in the last pipeline stage - maybe even after the packet has waited in a QoS queue for a long time, and its cache lines have gone cold.
B. If the application uses segmented mbufs on RX, it might make sense moving m->next to the first cache line. (We don't use segmented mbufs, so I'm not sure about this.)
However, reality perhaps beats theory:
Looking at the E1000 PMD, it seems like even its non-scattered RX function, eth_igb_recv_pkts(), sets m->next. If it only kept its own free pool pre-initialized instead... I haven't investigated other PMDs, except briefly looking at the mlx5 PMD, and it seems like it doesn't touch m->next in RX.
I haven't looked deeper into how m->pool is being used by RX in PMDs, but I suppose that it isn't touched in RX.
<rant on>
If only we had a performance test where RX was not immediately followed by TX, but the packets were passed through a large queue in-between, so RX cache misses were not free of charge because they transform TX cache misses into cache hits instead... <rant off>
Whatever you choose, I am sure that most applications will find it more useful than the timestamp. :-)
Med venlig hilsen / kind regards
- Morten Brørup
Re: [dpdk-dev] [PATCH 15/15] mbuf: move pool pointer in hotterfirst half
Thanks for the thoughts Morten.
I believe we need benchmarks of different scenarios with different drivers.
31/10/2020 19:20, Morten Brørup:
Quoted 46 lines
Thomas,
Adding my thoughts to the already detailed feedback on this important patch...
The first cache line is not inherently "hotter" than the second. The hotness depends on their usage.
The mbuf cacheline1 marker has the following comment:
/* second cache line - fields only used in slow path or on TX */In other words, the second cache line is intended not to be touched in fast path RX.
I do not think this is true anymore. Not even with simple non-scattered RX. And regression testing probably didn't catch this, because the tests perform TX after RX, so the cache miss moved from TX to RX and became a cache hit in TX instead. (I may be wrong about this claim, but it's not important for the discussion.)
I think the right question for this patch is: Can we achieve this - not using the second cache line for fast path RX - again by putting the right fields in the first cache line?
Probably not in all cases, but perhaps for some...
Consider the application scenarios.
When a packet is received, one of three things happens to it:
1. It is immediately transmitted on one or more ports.
2. It is immediately discarded, e.g. by a firewall rule.
3. It is put in some sort of queue, e.g. a ring for the next pipeline stage, or in a QoS queue.1. If the packet is immediately transmitted, the
m->tx_offloadfield in the second cache line will be touched by the application and TX function anyway, so we don't need to optimize the mbuf layout for this scenario.2. The second scenario touches
m->poolno matter how it is implemented. The application can avoid touchingm->nextby usingrte_mbuf_raw_free(), knowing that the mbuf came directly from RX and thus no other fields have been touched. In this scenario, we wantm->poolin the first cache line.3. Now, let's consider the third scenario, where RX is followed by enqueue into a ring. If the application does nothing but put the packet into a ring, we don't need to move anything into the first cache line. But applications usually does more... So it is application specific what would be good to move to the first cache line:
A. If the application does not use segmented mbufs, and performs analysis and preparation for transmission in the initial pipeline stages, and only the last pipeline stage performs TX, we could move
m->tx_offloadto the first cache line, which would keep the second cache line cold until the actual TX happens in the last pipeline stage - maybe even after the packet has waited in a QoS queue for a long time, and its cache lines have gone cold.B. If the application uses segmented mbufs on RX, it might make sense moving
m->nextto the first cache line. (We don't use segmented mbufs, so I'm not sure about this.)However, reality perhaps beats theory:
Looking at the E1000 PMD, it seems like even its non-scattered RX function,
eth_igb_recv_pkts(), setsm->next. If it only kept its own free pool pre-initialized instead... I haven't investigated other PMDs, except briefly looking at the mlx5 PMD, and it seems like it doesn't touchm->nextin RX.I haven't looked deeper into how
m->poolis being used by RX in PMDs, but I suppose that it isn't touched in RX.<rant on>
If only we had a performance test where RX was not immediately followed by TX, but the packets were passed through a large queue in-between, so RX cache misses were not free of charge because they transform TX cache misses into cache hits instead... <rant off>Whatever you choose, I am sure that most applications will find it more useful than the timestamp. :-)
Re: [dpdk-dev] [PATCH 15/15] mbuf: move pool pointer in hotterfirst half
Quoted 82 lines
From: Thomas Monjalon [mailto:[email protected]]
Sent: Saturday, October 31, 2020 9:41 PM31/10/2020 19:20, Morten Brørup:
Quoted 3 lines
Thomas,
Adding my thoughts to the already detailed feedback on this important
patch...
Quoted 2 lines
The first cache line is not inherently "hotter" than the second. The
hotness depends on their usage.
Quoted 5 lines
The mbuf cacheline1 marker has the following comment:
/* second cache line - fields only used in slow path or on TX */In other words, the second cache line is intended not to be touched in
fast path RX.
Quoted 2 lines
I do not think this is true anymore. Not even with simple non-scattered
RX. And regression testing probably didn't catch this, because the tests perform TX after RX, so the cache miss moved from TX to RX and became a cache hit in TX instead. (I may be wrong about this claim, but it's not important for the discussion.)
Quoted 2 lines
I think the right question for this patch is: Can we achieve this - not
using the second cache line for fast path RX - again by putting the right fields in the first cache line?
Quoted 9 lines
Probably not in all cases, but perhaps for some...
Consider the application scenarios.
When a packet is received, one of three things happens to it:
1. It is immediately transmitted on one or more ports.
2. It is immediately discarded, e.g. by a firewall rule.
3. It is put in some sort of queue, e.g. a ring for the next pipelinestage, or in a QoS queue.
Quoted 2 lines
1. If the packet is immediately transmitted, the
m->tx_offloadfield inthe second cache line will be touched by the application and TX function anyway, so we don't need to optimize the mbuf layout for this scenario.
Quoted 2 lines
2. The second scenario touches
m->poolno matter how it is implemented.The application can avoid touching
m->nextby usingrte_mbuf_raw_free(), knowing that the mbuf came directly from RX and thus no other fields have been touched. In this scenario, we wantm->poolin the first cache line.Quoted 2 lines
3. Now, let's consider the third scenario, where RX is followed by
enqueue into a ring. If the application does nothing but put the packet into a ring, we don't need to move anything into the first cache line. But applications usually does more... So it is application specific what would be good to move to the first cache line:
Quoted 2 lines
A. If the application does not use segmented mbufs, and performs analysis
and preparation for transmission in the initial pipeline stages, and only the last pipeline stage performs TX, we could move
m->tx_offloadto the first cache line, which would keep the second cache line cold until the actual TX happens in the last pipeline stage - maybe even after the packet has waited in a QoS queue for a long time, and its cache lines have gone cold.Quoted 2 lines
B. If the application uses segmented mbufs on RX, it might make sense
moving
m->nextto the first cache line. (We don't use segmented mbufs, so I'm not sure about this.)Quoted 5 lines
However, reality perhaps beats theory:
Looking at the E1000 PMD, it seems like even its non-scattered RX
function,
eth_igb_recv_pkts(), setsm->next. If it only kept its own free pool pre-initialized instead... I haven't investigated other PMDs, except briefly looking at the mlx5 PMD, and it seems like it doesn't touchm->nextin RX.Quoted 2 lines
I haven't looked deeper into how
m->poolis being used by RX in PMDs, butI suppose that it isn't touched in RX.
Quoted 3 lines
<rant on>
If only we had a performance test where RX was not immediately followedby TX, but the packets were passed through a large queue in-between, so RX cache misses were not free of charge because they transform TX cache misses into cache hits instead...
Quoted 8 lines
Quoted 3 lines
<rant off>
Whatever you choose, I am sure that most applications will find it more
useful than the timestamp. :-)
Thanks for the thoughts Morten.
I believe we need benchmarks of different scenarios with different drivers.
If we are only allowed to modify the mbuf structure this one more time, we should look forward, not backwards!
If we move m->tx_offload to the first cache line, applications using simple, non-scattered packet mbufs would never even need to touch the second cache line, except for freeing the mbuf (which needs to read m->pool).
And this leads to my next suggestion...
One thing has always puzzled me: Why do we use 64 bits to indicate which memory pool an mbuf belongs to? The portid only uses 16 bits and an indirection index. Why don't we use the same kind of indirection index for mbuf pools?
I can easily imagine using one mbuf pool (or perhaps a few pools) per CPU socket (or per physical memory bus closest to an attached NIC), but not more than 256 mbuf memory pools in total. So, let's introduce an mbufpoolid like the portid, and cut this mbuf field down from 64 to 8 bits.
If we also cut down m->pkt_len from 32 to 24 bits, we can get the 8 bit mbuf pool index into the first cache line at no additional cost.
In other words: This would free up another 64 bit field in the mbuf structure!
And even though the m->next pointer for scattered packets resides in the second cache line, the libraries and application knows that m->next is NULL when m->nb_segs is 1. This proves that my suggestion would make touching the second cache line unnecessary (in simple cases), even for re-initializing the mbuf.
And now I will proceed out on a tangent with two more independent thoughts, so feel free to ignore.
Consider a multi CPU socket system with one mbuf pool per CPU socket, the NICs attached to each CPU socket use an RX mbuf pool with RAM on the same CPU socket. I would imagine that (re-)initializing these mbufs could be faster if performed only on a CPU on the same socket. If this is the case, mbufs should be re-initialized as part of the RX preparation at ingress, not as part of the mbuf free at egress.
Perhaps some microarchitectures are faster to compare nb_segs==0 than nb_segs==1. If so, nb_segs could be redefined to mean number of additional segments, rather than number of segments.
PS: I have added two more mlx5 maintainers to the discussion; they might have qualified opinions about how PMDs could benefit from this.
Med venlig hilsen / kind regards
- Morten Brørup
Re: [dpdk-dev] [PATCH 15/15] mbuf: move pool pointer in hotterfirst half
That's very interesting food for thoughts.
I hope we will have a good community discussion on this list during this week to make some decisions.
01/11/2020 10:12, Morten Brørup:
Quoted 114 lines
Quoted 82 lines
From: Thomas Monjalon [mailto:[email protected]]
Sent: Saturday, October 31, 2020 9:41 PM31/10/2020 19:20, Morten Brørup:
Quoted 3 lines
Thomas,
Adding my thoughts to the already detailed feedback on this important
patch...
Quoted 2 lines
The first cache line is not inherently "hotter" than the second. The
hotness depends on their usage.
Quoted 5 lines
The mbuf cacheline1 marker has the following comment:
/* second cache line - fields only used in slow path or on TX */In other words, the second cache line is intended not to be touched in
fast path RX.
Quoted 2 lines
I do not think this is true anymore. Not even with simple non-scattered
RX. And regression testing probably didn't catch this, because the tests perform TX after RX, so the cache miss moved from TX to RX and became a cache hit in TX instead. (I may be wrong about this claim, but it's not important for the discussion.)
Quoted 2 lines
I think the right question for this patch is: Can we achieve this - not
using the second cache line for fast path RX - again by putting the right fields in the first cache line?
Quoted 9 lines
Probably not in all cases, but perhaps for some...
Consider the application scenarios.
When a packet is received, one of three things happens to it:
1. It is immediately transmitted on one or more ports.
2. It is immediately discarded, e.g. by a firewall rule.
3. It is put in some sort of queue, e.g. a ring for the next pipelinestage, or in a QoS queue.
Quoted 2 lines
1. If the packet is immediately transmitted, the
m->tx_offloadfield inthe second cache line will be touched by the application and TX function anyway, so we don't need to optimize the mbuf layout for this scenario.
Quoted 2 lines
2. The second scenario touches
m->poolno matter how it is implemented.The application can avoid touching
m->nextby usingrte_mbuf_raw_free(), knowing that the mbuf came directly from RX and thus no other fields have been touched. In this scenario, we wantm->poolin the first cache line.Quoted 2 lines
3. Now, let's consider the third scenario, where RX is followed by
enqueue into a ring. If the application does nothing but put the packet into a ring, we don't need to move anything into the first cache line. But applications usually does more... So it is application specific what would be good to move to the first cache line:
Quoted 2 lines
A. If the application does not use segmented mbufs, and performs analysis
and preparation for transmission in the initial pipeline stages, and only the last pipeline stage performs TX, we could move
m->tx_offloadto the first cache line, which would keep the second cache line cold until the actual TX happens in the last pipeline stage - maybe even after the packet has waited in a QoS queue for a long time, and its cache lines have gone cold.Quoted 2 lines
B. If the application uses segmented mbufs on RX, it might make sense
moving
m->nextto the first cache line. (We don't use segmented mbufs, so I'm not sure about this.)Quoted 5 lines
However, reality perhaps beats theory:
Looking at the E1000 PMD, it seems like even its non-scattered RX
function,
eth_igb_recv_pkts(), setsm->next. If it only kept its own free pool pre-initialized instead... I haven't investigated other PMDs, except briefly looking at the mlx5 PMD, and it seems like it doesn't touchm->nextin RX.Quoted 2 lines
I haven't looked deeper into how
m->poolis being used by RX in PMDs, butI suppose that it isn't touched in RX.
Quoted 3 lines
<rant on>
If only we had a performance test where RX was not immediately followedby TX, but the packets were passed through a large queue in-between, so RX cache misses were not free of charge because they transform TX cache misses into cache hits instead...
Quoted 8 lines
Quoted 3 lines
<rant off>
Whatever you choose, I am sure that most applications will find it more
useful than the timestamp. :-)
Thanks for the thoughts Morten.
I believe we need benchmarks of different scenarios with different drivers.If we are only allowed to modify the mbuf structure this one more time, we should look forward, not backwards!
If we move
m->tx_offloadto the first cache line, applications using simple, non-scattered packet mbufs would never even need to touch the second cache line, except for freeing the mbuf (which needs to readm->pool).And this leads to my next suggestion...
One thing has always puzzled me: Why do we use 64 bits to indicate which memory pool an mbuf belongs to? The portid only uses 16 bits and an indirection index. Why don't we use the same kind of indirection index for mbuf pools?
I can easily imagine using one mbuf pool (or perhaps a few pools) per CPU socket (or per physical memory bus closest to an attached NIC), but not more than 256 mbuf memory pools in total. So, let's introduce an mbufpoolid like the portid, and cut this mbuf field down from 64 to 8 bits.
If we also cut down
m->pkt_lenfrom 32 to 24 bits, we can get the 8 bit mbuf pool index into the first cache line at no additional cost.In other words: This would free up another 64 bit field in the mbuf structure!
And even though the
m->nextpointer for scattered packets resides in the second cache line, the libraries and application knows thatm->nextis NULL whenm->nb_segsis 1. This proves that my suggestion would make touching the second cache line unnecessary (in simple cases), even for re-initializing the mbuf.And now I will proceed out on a tangent with two more independent thoughts, so feel free to ignore.
Consider a multi CPU socket system with one mbuf pool per CPU socket, the NICs attached to each CPU socket use an RX mbuf pool with RAM on the same CPU socket. I would imagine that (re-)initializing these mbufs could be faster if performed only on a CPU on the same socket. If this is the case, mbufs should be re-initialized as part of the RX preparation at ingress, not as part of the mbuf free at egress.
Perhaps some microarchitectures are faster to compare nb_segs==0 than nb_segs==1. If so,
nb_segscould be redefined to mean number of additional segments, rather than number of segments.
Re: [dpdk-dev] [PATCH 15/15] mbuf: move pool pointer in hotterfirst half
In reply to Morten Brørup01/11/2020 10:12, Morten Brørup:
Quoted 5 lines
One thing has always puzzled me:
Why do we use 64 bits to indicate which memory pool
an mbuf belongs to?
The portid only uses 16 bits and an indirection index. Why don't we use the same kind of indirection index for mbuf pools?
I wonder what would be the cost of indirection. Probably neglectible. I think it is a good proposal...
... for next year, after a deprecation notice.
Quoted 7 lines
I can easily imagine using one mbuf pool (or perhaps a few pools) per CPU socket (or per physical memory bus closest to an attached NIC), but not more than 256 mbuf memory pools in total.
So, let's introduce an mbufpoolid like the portid,
and cut this mbuf field down from 64 to 8 bits.If we also cut down
m->pkt_lenfrom 32 to 24 bits,
Who is using packets larger than 64k? Are 16 bits enough?
Quoted 2 lines
we can get the 8 bit mbuf pool index into the first cache line at no additional cost.
I like the idea.
It means we don't need to move the pool pointer now, i.e. it does not have to replace the timestamp field.
Quoted 1 line
In other words: This would free up another 64 bit field in the mbuf structure!
That would be great!
Quoted 6 lines
And even though the
m->nextpointer for scattered packets resides in the second cache line, the libraries and application knows thatm->nextis NULL whenm->nb_segsis 1.
This proves that my suggestion would make touching
the second cache line unnecessary (in simple cases), even for re-initializing the mbuf.
So you think the "next" pointer should stay in the second half of mbuf?
I feel you would like to move the Tx offloads in the first half to improve performance of very simple apps.
I am thinking the opposite: we could have some dynamic fields space in the first half to improve performance of complex Rx.
Note: we can add a flag hint for field registration in this first half.
Quoted 16 lines
And now I will proceed out on a tangent with two more independent thoughts, so feel free to ignore.
Consider a multi CPU socket system with one mbuf pool per CPU socket, the NICs attached to each CPU socket use an RX mbuf pool with RAM on the same CPU socket.
I would imagine that (re-)initializing these mbufs could be faster if performed only on a CPU on the same socket.
If this is the case, mbufs should be re-initialized
as part of the RX preparation at ingress,
not as part of the mbuf free at egress.Perhaps some microarchitectures are faster to compare nb_segs==0 than nb_segs==1.
If so,nb_segscould be redefined to mean number of additional segments, rather than number of segments.
Re: [dpdk-dev] [PATCH 15/15] mbuf: move pool pointer in hotterfirst half
Quoted 11 lines
From: Thomas Monjalon [mailto:[email protected]]
Sent: Sunday, November 1, 2020 5:38 PM01/11/2020 10:12, Morten Brørup:
Quoted 5 lines
One thing has always puzzled me:
Why do we use 64 bits to indicate which memory pool
an mbuf belongs to?
The portid only uses 16 bits and an indirection index. Why don't we use the same kind of indirection index for mbuf pools?I wonder what would be the cost of indirection. Probably neglectible.
Probably. The portid does it, and that indirection is heavily used everywhere.
The size of mbuf memory pool indirection array should be compile time configurable, like the size of the portid indirection array.
And for reference, the indirection array will fit into one cache line if we default to 8 mbuf pools, thus supporting an 8 CPU socket system with one mbuf pool per CPU socket, or a 4 CPU socket system with two mbuf pools per CPU socket.
(And as a side note: Our application is optimized for single-socket systems, and we only use one mbuf pool. I guess many applications were developed without carefully optimizing for multi-socket systems, and also just use one mbuf pool. In these cases, the mbuf structure doesn't really need a pool field. But it is still there, and the DPDK libraries use it, so we didn't bother removing it.)
Quoted 9 lines
I think it is a good proposal...
... for next year, after a deprecation notice.Quoted 6 lines
I can easily imagine using one mbuf pool (or perhaps a few pools) per CPU socket (or per physical memory bus closest to an attached NIC), but not more than 256 mbuf memory pools in total.
So, let's introduce an mbufpoolid like the portid,
and cut this mbuf field down from 64 to 8 bits.
Quoted 3 lines
Quoted 1 line
If we also cut down
m->pkt_lenfrom 32 to 24 bits,Who is using packets larger than 64k? Are 16 bits enough?
I personally consider 64k a reasonable packet size limit. Exotic applications with even larger packets would have to live with this constraint. But let's see if there are any objections. For reference, 64k corresponds to ca. 44 Ethernet (1500 byte) packets.
(The limit could be 65535 bytes, to avoid translation of the value 0 into 65536 bytes.)
This modification would go nicely hand in hand with the mbuf pool indirection modification.
... after yet another round of ABI stability discussions, depreciation notices, and so on. :-)
Quoted 7 lines
Quoted 3 lines
we can get the 8 bit mbuf pool index into the first cache line at no additional cost.
I like the idea.
It means we don't need to move the pool pointer now, i.e. it does not have to replace the timestamp field.
Agreed! Don't move m->pool to the first cache line; it is not used for RX.
Quoted 14 lines
Quoted 2 lines
In other words: This would free up another 64 bit field in the mbuf
structure!
That would be great!
Quoted 6 lines
And even though the
m->nextpointer for scattered packets resides in the second cache line, the libraries and application knows thatm->nextis NULL whenm->nb_segsis 1.
This proves that my suggestion would make touching
the second cache line unnecessary (in simple cases), even for re-initializing the mbuf.
Quoted 4 lines
So you think the "next" pointer should stay in the second half of mbuf?
I feel you would like to move the Tx offloads in the first half to improve performance of very simple apps.
"Very simple apps" sounds like a minority of apps. I would rather say "very simple packet handling scenarios", e.g. forwarding of normal size non-segmented packets. I would guess that the vast majority of packets handled by DPDK applications actually match this scenario. So I'm proposing to optimize for what I think is the most common scenario.
If segmented packets are common, then m->next could be moved to the first cache line. But it will only improve the pure RX steps of the pipeline. When preparing the packet for TX, m->tx_offloads will need to be set, and the second cache line comes into play. So I'm wondering how big the benefit of having m->next in the first cache line really is - assuming that m->nb_segs will be checked before accessing m->next.
Quoted 4 lines
I am thinking the opposite: we could have some dynamic fields space in the first half to improve performance of complex Rx.
Note: we can add a flag hint for field registration in this first half.
I have had the same thoughts. However, I would prefer being able to forward ordinary packets without using the second mbuf cache line at all (although only in specific scenarios like my example above).
Furthermore, the application can abuse the 64 bit m->tx_offload field for private purposes until it is time to prepare the packet for TX and pass it on to the driver. This hack somewhat resembles a dynamic field in the first cache line, and will not be possible if the m->pool or m->next field is moved there.
Re: [dpdk-dev] [PATCH 15/15] mbuf: move pool pointer in hotterfirst half
+Cc techboard
We need benchmark numbers in order to take a decision. Please all, prepare some arguments and numbers so we can discuss the mbuf layout in the next techboard meeting.
01/11/2020 21:59, Morten Brørup:
Quoted 12 lines
Quoted 11 lines
From: Thomas Monjalon [mailto:[email protected]]
Sent: Sunday, November 1, 2020 5:38 PM01/11/2020 10:12, Morten Brørup:
Quoted 5 lines
One thing has always puzzled me:
Why do we use 64 bits to indicate which memory pool
an mbuf belongs to?
The portid only uses 16 bits and an indirection index. Why don't we use the same kind of indirection index for mbuf pools?I wonder what would be the cost of indirection. Probably neglectible.
Quoted 16 lines
Probably. The portid does it, and that indirection is heavily used everywhere.
The size of mbuf memory pool indirection array should be compile time configurable, like the size of the portid indirection array.
And for reference, the indirection array will fit into one cache line if we default to 8 mbuf pools, thus supporting an 8 CPU socket system with one mbuf pool per CPU socket, or a 4 CPU socket system with two mbuf pools per CPU socket.
(And as a side note: Our application is optimized for single-socket systems, and we only use one mbuf pool. I guess many applications were developed without carefully optimizing for multi-socket systems, and also just use one mbuf pool. In these cases, the mbuf structure doesn't really need a pool field. But it is still there, and the DPDK libraries use it, so we didn't bother removing it.)
Quoted 8 lines
I think it is a good proposal...
... for next year, after a deprecation notice.Quoted 5 lines
I can easily imagine using one mbuf pool (or perhaps a few pools) per CPU socket (or per physical memory bus closest to an attached NIC), but not more than 256 mbuf memory pools in total.
So, let's introduce an mbufpoolid like the portid,
and cut this mbuf field down from 64 to 8 bits.
We will need to measure the perf of the solution. There is a chance for the cost to be too much high.
Quoted 11 lines
Quoted 3 lines
Quoted 1 line
If we also cut down
m->pkt_lenfrom 32 to 24 bits,Who is using packets larger than 64k? Are 16 bits enough?
I personally consider 64k a reasonable packet size limit. Exotic applications with even larger packets would have to live with this constraint. But let's see if there are any objections. For reference, 64k corresponds to ca. 44 Ethernet (1500 byte) packets.
(The limit could be 65535 bytes, to avoid translation of the value 0 into 65536 bytes.)
This modification would go nicely hand in hand with the mbuf pool indirection modification.
... after yet another round of ABI stability discussions, depreciation notices, and so on. :-)
After more thoughts, I'm afraid 64k is too small in some cases. And 24-bit manipulation would probably break performance. I'm afraid we are stuck with 32-bit length.
Quoted 40 lines
Quoted 6 lines
Quoted 2 lines
we can get the 8 bit mbuf pool index into the first cache line at no additional cost.
I like the idea.
It means we don't need to move the pool pointer now, i.e. it does not have to replace the timestamp field.Agreed! Don't move
m->poolto the first cache line; it is not used for RX.Quoted 14 lines
Quoted 2 lines
In other words: This would free up another 64 bit field in the mbuf
structure!
That would be great!
Quoted 6 lines
And even though the
m->nextpointer for scattered packets resides in the second cache line, the libraries and application knows thatm->nextis NULL whenm->nb_segsis 1.
This proves that my suggestion would make touching
the second cache line unnecessary (in simple cases), even for re-initializing the mbuf.Quoted 4 lines
So you think the "next" pointer should stay in the second half of mbuf?
I feel you would like to move the Tx offloads in the first half to improve performance of very simple apps.
"Very simple apps" sounds like a minority of apps. I would rather say "very simple packet handling scenarios", e.g. forwarding of normal size non-segmented packets. I would guess that the vast majority of packets handled by DPDK applications actually match this scenario. So I'm proposing to optimize for what I think is the most common scenario.
If segmented packets are common, then
m->nextcould be moved to the first cache line. But it will only improve the pure RX steps of the pipeline. When preparing the packet for TX,m->tx_offloadswill need to be set, and the second cache line comes into play. So I'm wondering how big the benefit of havingm->nextin the first cache line really is - assuming thatm->nb_segswill be checked before accessingm->next.Quoted 4 lines
I am thinking the opposite: we could have some dynamic fields space in the first half to improve performance of complex Rx.
Note: we can add a flag hint for field registration in this first half.I have had the same thoughts. However, I would prefer being able to forward ordinary packets without using the second mbuf cache line at all (although only in specific scenarios like my example above).
Furthermore, the application can abuse the 64 bit
m->tx_offloadfield for private purposes until it is time to prepare the packet for TX and pass it on to the driver. This hack somewhat resembles a dynamic field in the first cache line, and will not be possible if them->poolorm->nextfield is moved there.
Re: [dpdk-dev] [PATCH 15/15] mbuf: move pool pointer in hotterfirst half
Quoted 8 lines
From: Thomas Monjalon [mailto:[email protected]]
Sent: Monday, November 2, 2020 4:58 PM+Cc techboard
We need benchmark numbers in order to take a decision. Please all, prepare some arguments and numbers so we can discuss the mbuf layout in the next techboard meeting.
I propose that the techboard considers this from two angels:
1. Long term goals and their relative priority. I.e. what can be achieved with wide-ranging modifications, requiring yet another ABI break and due notices.
2. Short term goals, i.e. what can be achieved for this release.
My suggestions follow...
1. Regarding long term goals:
I have argued that simple forwarding of non-segmented packets using only the first mbuf cache line can be achieved by making three modifications:
a) Move m->tx_offload to the first cache line.
b) Use an 8 bit pktmbuf mempool index in the first cache line, instead of the 64 bit m->pool pointer in the second cache line.
c) Do not access m->next when we know that it is NULL. We can use m->nb_segs == 1 or some other invariant as the gate. It can be implemented by adding an m->next accessor function:
struct rte_mbuf * rte_mbuf_next(struct rte_mbuf * m)
{
return m->nb_segs == 1 ? NULL : m->next;}
Regarding the priority of this goal, I guess that simple forwarding of non-segmented packets is probably the path taken by the majority of packets handled by DPDK.
An alternative goal could be:
Do not touch the second cache line during RX.
A comment in the mbuf structure says so, but it is not true anymore.
(I guess that regression testing didn't catch this because the tests perform TX immediately after RX, so the cache miss just moves from the TX to the RX part of the test application.)
2. Regarding short term goals:
The current DPDK source code looks to me like m->next is the most frequently accessed field in the second cache line, so it makes sense moving this to the first cache line, rather than m->pool. Benchmarking may help here.
If we - without breaking the ABI - can introduce a gate to avoid accessing m->next when we know that it is NULL, we should keep it in the second cache line.
In this case, I would prefer to move m->tx_offload to the first cache line, thereby providing a field available for application use, until the application prepares the packet for transmission.
Quoted 62 lines
01/11/2020 21:59, Morten Brørup:
Quoted 9 lines
Quoted 9 lines
From: Thomas Monjalon [mailto:[email protected]]
Sent: Sunday, November 1, 2020 5:38 PM01/11/2020 10:12, Morten Brørup:
Quoted 5 lines
One thing has always puzzled me:
Why do we use 64 bits to indicate which memory pool an mbuf belongs to?
The portid only uses 16 bits and an indirection index. Why don't we use the same kind of indirection index for mbufpools?
Quoted 2 lines
Quoted 2 lines
I wonder what would be the cost of indirection. Probably
neglectible.
Quoted 2 lines
Probably. The portid does it, and that indirection is heavily used
everywhere.
Quoted 2 lines
The size of mbuf memory pool indirection array should be compile time
configurable, like the size of the portid indirection array.
Quoted 2 lines
And for reference, the indirection array will fit into one cache line
if we default to 8 mbuf pools, thus supporting an 8 CPU socket system with one mbuf pool per CPU socket, or a 4 CPU socket system with two mbuf pools per CPU socket.
Quoted 2 lines
(And as a side note: Our application is optimized for single-socket
systems, and we only use one mbuf pool. I guess many applications were developed without carefully optimizing for multi-socket systems, and also just use one mbuf pool. In these cases, the mbuf structure doesn't really need a pool field. But it is still there, and the DPDK libraries use it, so we didn't bother removing it.)
Quoted 6 lines
Quoted 6 lines
I think it is a good proposal...
... for next year, after a deprecation notice.Quoted 2 lines
I can easily imagine using one mbuf pool (or perhaps a few pools) per CPU socket (or per physical memory bus closest to an attached
NIC),
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
but not more than 256 mbuf memory pools in total. So, let's introduce an mbufpoolid like the portid, and cut this mbuf field down from 64 to 8 bits.
We will need to measure the perf of the solution. There is a chance for the cost to be too much high.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
If we also cut down
m->pkt_lenfrom 32 to 24 bits,Who is using packets larger than 64k? Are 16 bits enough?
I personally consider 64k a reasonable packet size limit. Exotic
applications with even larger packets would have to live with this constraint. But let's see if there are any objections. For reference, 64k corresponds to ca. 44 Ethernet (1500 byte) packets.
Quoted 2 lines
(The limit could be 65535 bytes, to avoid translation of the value 0
into 65536 bytes.)
Quoted 2 lines
This modification would go nicely hand in hand with the mbuf pool
Quoted 8 lines
indirection modification.
Quoted 2 lines
... after yet another round of ABI stability discussions,
depreciation notices, and so on. :-)
After more thoughts, I'm afraid 64k is too small in some cases. And 24-bit manipulation would probably break performance. I'm afraid we are stuck with 32-bit length.
Yes, 24 bit manipulation would probably break performance.
Perhaps a solution exists with 16 bits (least significant bits) for the common cases, and 8 bits more (most significant bits) for the less common cases. Just thinking out loud here...
Quoted 63 lines
Quoted 9 lines
Quoted 7 lines
Quoted 3 lines
we can get the 8 bit mbuf pool index into the first cache line at no additional cost.
I like the idea.
It means we don't need to move the pool pointer now, i.e. it does not have to replace the timestamp field.Agreed! Don't move
m->poolto the first cache line; it is not usedfor RX.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
In other words: This would free up another 64 bit field in the
mbuf
Quoted 5 lines
Quoted 5 lines
structure!
That would be great!
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
And even though the
m->nextpointer for scattered packets resides in the second cache line, the libraries and application knows thatm->nextis NULL whenm->nb_segsis 1.
This proves that my suggestion would make touching
the second cache line unnecessary (in simple cases), even for re-initializing the mbuf.So you think the "next" pointer should stay in the second half of
mbuf?
Quoted 5 lines
Quoted 3 lines
I feel you would like to move the Tx offloads in the first half to improve performance of very simple apps.
"Very simple apps" sounds like a minority of apps. I would rather say
"very simple packet handling scenarios", e.g. forwarding of normal size non-segmented packets. I would guess that the vast majority of packets handled by DPDK applications actually match this scenario. So I'm proposing to optimize for what I think is the most common scenario.
Quoted 2 lines
If segmented packets are common, then
m->nextcould be moved to thefirst cache line. But it will only improve the pure RX steps of the pipeline. When preparing the packet for TX,
m->tx_offloadswill need to be set, and the second cache line comes into play. So I'm wondering how big the benefit of havingm->nextin the first cache line really is - assuming thatm->nb_segswill be checked before accessingm->next.Quoted 4 lines
Quoted 4 lines
I am thinking the opposite: we could have some dynamic fields space in the first half to improve performance of complex Rx.
Note: we can add a flag hint for field registration in this firsthalf.
Quoted 3 lines
Quoted 1 line
I have had the same thoughts. However, I would prefer being able to
forward ordinary packets without using the second mbuf cache line at all (although only in specific scenarios like my example above).
Quoted 2 lines
Furthermore, the application can abuse the 64 bit
m->tx_offloadfieldfor private purposes until it is time to prepare the packet for TX and pass it on to the driver. This hack somewhat resembles a dynamic field in the first cache line, and will not be possible if the
m->poolor m-Quoted 1 line
next field is moved there.
Re: [dpdk-dev] [PATCH 15/15] mbuf: move pool pointer in hotterfirst half
Quoted 37 lines · Morten Brørup
Quoted 8 lines
From: Thomas Monjalon [mailto:[email protected]]
Sent: Monday, November 2, 2020 4:58 PM+Cc techboard
We need benchmark numbers in order to take a decision. Please all, prepare some arguments and numbers so we can discuss the mbuf layout in the next techboard meeting.
I propose that the techboard considers this from two angels:
1. Long term goals and their relative priority. I.e. what can be achieved with wide-ranging modifications, requiring yet another ABI break and due notices.
2. Short term goals, i.e. what can be achieved for this release.
My suggestions follow...
1. Regarding long term goals:
I have argued that simple forwarding of non-segmented packets using only the first mbuf cache line can be achieved by making three modifications:
a) Move
m->tx_offloadto the first cache line.
b) Use an 8 bit pktmbuf mempool index in the first cache line, instead of the 64 bitm->poolpointer in the second cache line.
c) Do not accessm->nextwhen we know that it is NULL. We can usem->nb_segs== 1 or some other invariant as the gate. It can be implemented by adding anm->nextaccessor function:struct rte_mbuf * rte_mbuf_next(struct rte_mbuf * m) { return m->nb_segs == 1 ? NULL : m->next; }
Quoted 9 lines
Regarding the priority of this goal, I guess that simple forwarding of non-segmented packets is probably the path taken by the majority of packets handled by DPDK.
An alternative goal could be:
Do not touch the second cache line during RX.
A comment in the mbuf structure says so, but it is not true anymore.
The comment should be true for non-scattered RX, I believe. I'm not aware of any use of second cacheline for the fast-path RXs for many drivers. Am I missing something that has changed recently here?
/Bruce
Re: [dpdk-dev] [PATCH 15/15] mbuf: move pool pointer in hotterfirst half
Quoted 46 lines
From: Bruce Richardson [mailto:[email protected]]
Sent: Tuesday, November 3, 2020 1:26 PMQuoted 42 lines · Morten Brørup
Quoted 8 lines
From: Thomas Monjalon [mailto:[email protected]]
Sent: Monday, November 2, 2020 4:58 PM+Cc techboard
We need benchmark numbers in order to take a decision. Please all, prepare some arguments and numbers so we can discuss the mbuf layout in the next techboard meeting.
I propose that the techboard considers this from two angels:
1. Long term goals and their relative priority. I.e. what can be achieved with wide-ranging modifications, requiring yet another ABI break and due notices.
2. Short term goals, i.e. what can be achieved for this release.
My suggestions follow...
1. Regarding long term goals:
I have argued that simple forwarding of non-segmented packets using only the first mbuf cache line can be achieved by making three modifications:
a) Move
m->tx_offloadto the first cache line.
b) Use an 8 bit pktmbuf mempool index in the first cache line, instead of the 64 bitm->poolpointer in the second cache line.
c) Do not accessm->nextwhen we know that it is NULL. We can usem->nb_segs== 1 or some other invariant as the gate. It can be implemented by adding anm->nextaccessor function:struct rte_mbuf * rte_mbuf_next(struct rte_mbuf * m) { return m->nb_segs == 1 ? NULL : m->next; }Regarding the priority of this goal, I guess that simple forwarding of non-segmented packets is probably the path taken by the majority of packets handled by DPDK.
Quoted 6 lines
Quoted 4 lines
An alternative goal could be:
Do not touch the second cache line during RX.
A comment in the mbuf structure says so, but it is not true anymore.The comment should be true for non-scattered RX, I believe.
You are correct.
My suggestion was unclear: Extend this remark to include segmented packets.
This could be a priority if the techboard considers RX segmented packets more important than my suggestion for single cache line forwarding of non-segmented packets.
Quoted 2 lines
I'm not aware of any use of second cacheline for the fast-path RXs for many drivers. Am I missing something that has changed recently here?
Check out eth_igb_recv_pkts() in the E1000 driver: rxm->next = NULL; Or pmd_rx_burst() in the TAP driver: new_tail->next = seg->next;
Perhaps the documentation should describe best practices for implementing RX and TX functions in drivers, including allocating/freeing mbufs. Or an example dummy Ethernet driver could do it.
Re: [dpdk-dev] [PATCH 15/15] mbuf: move pool pointer in hotterfirst half
Quoted 60 lines · Morten Brørup
Quoted 46 lines
From: Bruce Richardson [mailto:[email protected]]
Sent: Tuesday, November 3, 2020 1:26 PMQuoted 42 lines · Morten Brørup
Quoted 8 lines
From: Thomas Monjalon [mailto:[email protected]]
Sent: Monday, November 2, 2020 4:58 PM+Cc techboard
We need benchmark numbers in order to take a decision. Please all, prepare some arguments and numbers so we can discuss the mbuf layout in the next techboard meeting.
I propose that the techboard considers this from two angels:
1. Long term goals and their relative priority. I.e. what can be achieved with wide-ranging modifications, requiring yet another ABI break and due notices.
2. Short term goals, i.e. what can be achieved for this release.
My suggestions follow...
1. Regarding long term goals:
I have argued that simple forwarding of non-segmented packets using only the first mbuf cache line can be achieved by making three modifications:
a) Move
m->tx_offloadto the first cache line.
b) Use an 8 bit pktmbuf mempool index in the first cache line, instead of the 64 bitm->poolpointer in the second cache line.
c) Do not accessm->nextwhen we know that it is NULL. We can usem->nb_segs== 1 or some other invariant as the gate. It can be implemented by adding anm->nextaccessor function:struct rte_mbuf * rte_mbuf_next(struct rte_mbuf * m) { return m->nb_segs == 1 ? NULL : m->next; }Regarding the priority of this goal, I guess that simple forwarding of non-segmented packets is probably the path taken by the majority of packets handled by DPDK.
Quoted 6 lines
Quoted 4 lines
An alternative goal could be:
Do not touch the second cache line during RX.
A comment in the mbuf structure says so, but it is not true anymore.The comment should be true for non-scattered RX, I believe.
You are correct.
My suggestion was unclear: Extend this remark to include segmented packets.
This could be a priority if the techboard considers RX segmented packets more important than my suggestion for single cache line forwarding of non-segmented packets.
Quoted 8 lines
Quoted 2 lines
I'm not aware of any use of second cacheline for the fast-path RXs for many drivers. Am I missing something that has changed recently here?
Check out
eth_igb_recv_pkts()in the E1000 driver:rxm->next= NULL; Orpmd_rx_burst()in the TAP driver:new_tail->next=seg->next;Perhaps the documentation should describe best practices for implementing RX and TX functions in drivers, including allocating/freeing mbufs. Or an example dummy Ethernet driver could do it.
Yes, perhaps I should be clearer about the "fast-path", because I was thinking of the optimized RX/TX paths for those nics at 10G and above. Probably the documentation should indeed have an update clarifying things a bit, since using the first cacheline only possible but not mandatory for simple RX.
/Bruce
Re: [dpdk-dev] [PATCH 15/15] mbuf: move pool pointer in hotterfirst half
Quoted 88 lines
From: Bruce Richardson [mailto:[email protected]]
Sent: Tuesday, November 3, 2020 2:50 PMQuoted 11 lines · Morten Brørup
Quoted 11 lines
From: Bruce Richardson [mailto:[email protected]]
Sent: Tuesday, November 3, 2020 1:26 PMQuoted 7 lines · Morten Brørup
Quoted 7 lines
From: Thomas Monjalon [mailto:[email protected]]
Sent: Monday, November 2, 2020 4:58 PM+Cc techboard
We need benchmark numbers in order to take a decision. Please all, prepare some arguments and numbers so we can
discuss
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
the mbuf layout in the next techboard meeting.
I propose that the techboard considers this from two angels:
1. Long term goals and their relative priority. I.e. what can be achieved with wide-ranging modifications, requiring yet another
ABI
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
break and due notices.
2. Short term goals, i.e. what can be achieved for this release.
My suggestions follow...
1. Regarding long term goals:
I have argued that simple forwarding of non-segmented packets
using
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
only the first mbuf cache line can be achieved by making three modifications:
a) Move
m->tx_offloadto the first cache line.
b) Use an 8 bit pktmbuf mempool index in the first cache line, instead of the 64 bitm->poolpointer in the second cacheline.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
c) Do not access
m->nextwhen we know that it is NULL. We can usem->nb_segs== 1 or some other invariant as thegate.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
It can be implemented by adding an m->next accessor function: struct rte_mbuf * rte_mbuf_next(struct rte_mbuf * m) { return m->nb_segs == 1 ? NULL : m->next; }Regarding the priority of this goal, I guess that simple
forwarding
Quoted 1 line
Quoted 1 line
Quoted 1 line
of non-segmented packets is probably the path taken by the
majority
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
of packets handled by DPDK.
An alternative goal could be:
Do not touch the second cache line during RX.
A comment in the mbuf structure says so, but it is not trueanymore.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
The comment should be true for non-scattered RX, I believe.
You are correct.
My suggestion was unclear: Extend this remark to include segmented
packets.
Quoted 2 lines
This could be a priority if the techboard considers RX segmented
packets more important than my suggestion for single cache line forwarding of non-segmented packets.
Quoted 3 lines
Quoted 3 lines
I'm not aware of any use of second cacheline for the fast-path RXs
for many drivers.
Quoted 6 lines
Quoted 1 line
Am I missing something that has changed recently here?
Check out
eth_igb_recv_pkts()in the E1000 driver:rxm->next= NULL; Orpmd_rx_burst()in the TAP driver:new_tail->next=seg->next;Perhaps the documentation should describe best practices for
implementing RX and TX functions in drivers, including allocating/freeing mbufs. Or an example dummy Ethernet driver could do it.
Quoted 1 line
Quoted 7 lines
Yes, perhaps I should be clearer about the "fast-path", because I was thinking of the optimized RX/TX paths for those nics at 10G and above. Probably the documentation should indeed have an update clarifying things a
bit, since using the first cacheline only possible but not mandatory for
simple RX.
I sometimes look at the source code of the simple drivers for reference, as they are easier to understand than the advanced vector drivers. I suppose new PMD developers also would. :-)
Anyway, it is probably a good idea to add a clarifying note to the documentation, thus reflecting reality.
Just make sure that it says that the second cache line is supposed to be untouched by RX of high performance drivers, so application developers still consider it cold.
Re: [dpdk-dev] [PATCH 15/15] mbuf: move pool pointer in hotterfirst half
In reply to Morten BrørupHi, Morten
Quoted 36 lines
-----Original Message-----
From: Morten Brørup <[email protected]>
Sent: Tuesday, November 3, 2020 14:10
To: NBU-Contact-Thomas Monjalon <[email protected]>; [email protected]; [email protected]
Cc: Ajit Khaparde <[email protected]>; Ananyev, Konstantin <[email protected]>; Andrew Rybchenko <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>; [email protected]; Richardson, Bruce <[email protected]>; [email protected]; [email protected]; Slava Ovsiienko <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>; Shahaf Shuler <[email protected]>
Subject: RE: [dpdk-dev] [PATCH 15/15] mbuf: move pool pointer in hotterfirst halfQuoted 8 lines
From: Thomas Monjalon [mailto:[email protected]]
Sent: Monday, November 2, 2020 4:58 PM+Cc techboard
We need benchmark numbers in order to take a decision. Please all, prepare some arguments and numbers so we can discuss the mbuf layout in the next techboard meeting.
I propose that the techboard considers this from two angels:
1. Long term goals and their relative priority. I.e. what can be achieved with wide-ranging modifications, requiring yet another ABI break and due notices.
2. Short term goals, i.e. what can be achieved for this release.
My suggestions follow...
Quoted 7 lines
1. Regarding long term goals:
I have argued that simple forwarding of non-segmented packets using only the first mbuf cache line can be achieved by making three modifications:
a) Move
m->tx_offloadto the first cache line.
Not all PMDs use this field on Tx. HW might support the checksum offloads directly, not requiring these fields at all.
Quoted 2 lines
b) Use an 8 bit pktmbuf mempool index in the first cache line, instead of the 64 bit
m->poolpointer in the second cache line.
256 mpool looks enough, as for me. Regarding the indirect access to the pool (via some table) - it might introduce some performance impact. For example, mlx5 PMD strongly relies on pool field for allocating mbufs in Rx datapath. We're going to update (o-o, we found point to optimize), but for now it does.
Quoted 7 lines
c) Do not access
m->nextwhen we know that it is NULL. We can usem->nb_segs== 1 or some other invariant as the gate. It can be implemented by adding anm->nextaccessor function:struct rte_mbuf * rte_mbuf_next(struct rte_mbuf * m) { return m->nb_segs == 1 ? NULL : m->next; }
Sorry, not sure about this. IIRC, nb_segs is valid in the first segment/mbuf only. If we have the 4 segments in the pkt we see nb_seg=4 in the first one, and the nb_seg=1 in the others. The next field is NULL in the last mbuf only. Am I wrong and miss something ?
Quoted 13 lines
Regarding the priority of this goal, I guess that simple forwarding of non- segmented packets is probably the path taken by the majority of packets handled by DPDK.
An alternative goal could be:
Do not touch the second cache line during RX.
A comment in the mbuf structure says so, but it is not true anymore.(I guess that regression testing didn't catch this because the tests perform TX immediately after RX, so the cache miss just moves from the TX to the RX part of the test application.)
Quoted 6 lines
2. Regarding short term goals:
The current DPDK source code looks to me like
m->nextis the most frequently accessed field in the second cache line, so it makes sense moving this to the first cache line, rather thanm->pool.
Benchmarking may help here.
Moreover, for the segmented packets the packet size is supposed to be large, and it imposes the relatively low packet rate, so probably optimization of moving next to the 1st cache line might be negligible at all. Just compare 148Mpps of 64B pkts and 4Mpps of 3000B pkts over 100Gbps link. Currently we are on benchmarking and did not succeed yet on difference finding. The benefit can't be expressed in mpps delta, we should measure CPU clocks, but Rx queue is almost always empty - we have an empty loops. So, if we have the boost - it is extremely hard to catch one.
With best regards, Slava
Quoted 156 lines
If we - without breaking the ABI - can introduce a gate to avoid accessing m-
Quoted 1 line
next when we know that it is NULL, we should keep it in the second cache
line.
In this case, I would prefer to move
m->tx_offloadto the first cache line, thereby providing a field available for application use, until the application prepares the packet for transmission.Quoted 65 lines
01/11/2020 21:59, Morten Brørup:
Quoted 9 lines
Quoted 9 lines
From: Thomas Monjalon [mailto:[email protected]]
Sent: Sunday, November 1, 2020 5:38 PM01/11/2020 10:12, Morten Brørup:
Quoted 5 lines
One thing has always puzzled me:
Why do we use 64 bits to indicate which memory pool an mbuf belongs to?
The portid only uses 16 bits and an indirection index. Why don't we use the same kind of indirection index for mbufpools?
Quoted 2 lines
Quoted 2 lines
I wonder what would be the cost of indirection. Probably
neglectible.
Quoted 2 lines
Probably. The portid does it, and that indirection is heavily used
everywhere.
Quoted 3 lines
The size of mbuf memory pool indirection array should be compile time
configurable, like the size of the portid indirection array.
Quoted 3 lines
And for reference, the indirection array will fit into one cache line
if we default to 8 mbuf pools, thus supporting an 8 CPU socket system with one mbuf pool per CPU socket, or a 4 CPU socket system with two mbuf pools per CPU socket.
Quoted 2 lines
(And as a side note: Our application is optimized for single-socket
systems, and we only use one mbuf pool. I guess many applications were developed without carefully optimizing for multi-socket systems, and also just use one mbuf pool. In these cases, the mbuf structure doesn't really need a pool field. But it is still there, and the DPDK libraries use it, so we didn't bother removing it.)
Quoted 7 lines
Quoted 7 lines
I think it is a good proposal...
... for next year, after a deprecation notice.Quoted 3 lines
I can easily imagine using one mbuf pool (or perhaps a few pools) per CPU socket (or per physical memory bus closest to an attached
NIC),
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
but not more than 256 mbuf memory pools in total.
So, let's introduce an mbufpoolid like the portid, and cut this mbuf field down from 64 to 8 bits.We will need to measure the perf of the solution. There is a chance for the cost to be too much high.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
If we also cut down
m->pkt_lenfrom 32 to 24 bits,Who is using packets larger than 64k? Are 16 bits enough?
I personally consider 64k a reasonable packet size limit. Exotic
applications with even larger packets would have to live with this constraint. But let's see if there are any objections. For reference, 64k corresponds to ca. 44 Ethernet (1500 byte) packets.
Quoted 2 lines
(The limit could be 65535 bytes, to avoid translation of the value 0
into 65536 bytes.)
Quoted 2 lines
This modification would go nicely hand in hand with the mbuf pool
Quoted 8 lines
indirection modification.
Quoted 2 lines
... after yet another round of ABI stability discussions,
depreciation notices, and so on. :-)
After more thoughts, I'm afraid 64k is too small in some cases. And 24-bit manipulation would probably break performance. I'm afraid we are stuck with 32-bit length.
Yes, 24 bit manipulation would probably break performance.
Perhaps a solution exists with 16 bits (least significant bits) for the common cases, and 8 bits more (most significant bits) for the less common cases. Just thinking out loud here...
Quoted 65 lines
Quoted 9 lines
Quoted 7 lines
Quoted 3 lines
we can get the 8 bit mbuf pool index into the first cache line at no additional cost.
I like the idea.
It means we don't need to move the pool pointer now, i.e. it does not have to replace the timestamp field.Agreed! Don't move
m->poolto the first cache line; it is not usedfor RX.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
In other words: This would free up another 64 bit field in the
mbuf
Quoted 5 lines
Quoted 5 lines
structure!
That would be great!
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
And even though the
m->nextpointer for scattered packets resides in the second cache line, the libraries and application knows thatm->nextis NULL whenm->nb_segsis 1.
This proves that my suggestion would make touching the second cache line unnecessary (in simple cases), even for re-initializing the mbuf.So you think the "next" pointer should stay in the second half of
mbuf?
Quoted 6 lines
Quoted 3 lines
I feel you would like to move the Tx offloads in the first half to improve performance of very simple apps.
"Very simple apps" sounds like a minority of apps. I would rather say
"very simple packet handling scenarios", e.g. forwarding of normal size non-segmented packets. I would guess that the vast majority of packets handled by DPDK applications actually match this scenario. So I'm proposing to optimize for what I think is the most common scenario.
Quoted 2 lines
If segmented packets are common, then
m->nextcould be moved to thefirst cache line. But it will only improve the pure RX steps of the pipeline. When preparing the packet for TX,
m->tx_offloadswill need to be set, and the second cache line comes into play. So I'm wondering how big the benefit of havingm->nextin the first cache line really is - assuming thatm->nb_segswill be checked before accessingm->next.Quoted 4 lines
Quoted 4 lines
I am thinking the opposite: we could have some dynamic fields space in the first half to improve performance of complex Rx.
Note: we can add a flag hint for field registration in this firsthalf.
Quoted 3 lines
Quoted 1 line
I have had the same thoughts. However, I would prefer being able to
forward ordinary packets without using the second mbuf cache line at all (although only in specific scenarios like my example above).
Quoted 3 lines
Furthermore, the application can abuse the 64 bit
m->tx_offloadfieldfor private purposes until it is time to prepare the packet for TX and pass it on to the driver. This hack somewhat resembles a dynamic field in the first cache line, and will not be possible if the
m->poolor m-Quoted 1 line
next field is moved there.
Re: [dpdk-dev] [PATCH 15/15] mbuf: move pool pointer in hotterfirst half
Quoted 43 lines
From: dev [mailto:[email protected]] On Behalf Of Slava Ovsiienko
Sent: Tuesday, November 3, 2020 3:03 PMHi, Morten
Quoted 10 lines
From: Morten Brørup <[email protected]>
Sent: Tuesday, November 3, 2020 14:10Quoted 7 lines
From: Thomas Monjalon [mailto:[email protected]]
Sent: Monday, November 2, 2020 4:58 PM+Cc techboard
We need benchmark numbers in order to take a decision. Please all, prepare some arguments and numbers so we can discuss
the
Quoted 5 lines
Quoted 1 line
mbuf layout in the next techboard meeting.
I propose that the techboard considers this from two angels:
1. Long term goals and their relative priority. I.e. what can be
achieved with
Quoted 1 line
wide-ranging modifications, requiring yet another ABI break and due
notices.
Quoted 9 lines
2. Short term goals, i.e. what can be achieved for this release.
My suggestions follow...
1. Regarding long term goals:
I have argued that simple forwarding of non-segmented packets using
only the
Quoted 4 lines
first mbuf cache line can be achieved by making three modifications:
a) Move
m->tx_offloadto the first cache line.Not all PMDs use this field on Tx. HW might support the checksum offloads
directly, not requiring these fields at all.
Quoted 5 lines
Quoted 2 lines
b) Use an 8 bit pktmbuf mempool index in the first cache line, instead of the 64 bit
m->poolpointer in the second cache line.256 mpool looks enough, as for me. Regarding the indirect access to the pool
(via some table) - it might introduce some performance impact.
It might, but I hope that it is negligible, so the benefits outweigh the disadvantages.
It would have to be measured, though.
And m->pool is only used for free()'ing (and detach()'ing) mbufs.
Quoted 5 lines
For example,
mlx5 PMD strongly relies on pool field for allocating mbufs in Rx datapath.
We're going to update (o-o, we found point to optimize), but for now it does.
Without looking at the source code, I don't think the PMD is using m->pool in the RX datapath, I think it is using a pool dedicated to a receive queue used for RX descriptors in the PMD (i.e. driver->queue->pool).
Quoted 9 lines
Quoted 8 lines
c) Do not access
m->nextwhen we know that it is NULL. We can usem->nb_segs== 1 or some other invariant as the gate. It can be implemented by adding anm->nextaccessor function:struct rte_mbuf * rte_mbuf_next(struct rte_mbuf * m) { return m->nb_segs == 1 ? NULL : m->next; }
Quoted 6 lines
Sorry, not sure about this. IIRC,
nb_segsis valid in the first segment/mbuf only.
If we have the 4 segments in the pkt we see nb_seg=4 in the first one, and the nb_seg=1
in the others. The next field is NULL in the last mbuf only. Am I wrong and miss something ?
You are correct.
This would have to be updated too. Either by increasing m->nb_seg in the following segments, or by splitting up relevant functions into functions for working on first segments (incl. non-segmented packets), and functions for working on following segments of segmented packets.
Quoted 27 lines
Quoted 2 lines
Regarding the priority of this goal, I guess that simple forwarding
of non-
Quoted 1 line
segmented packets is probably the path taken by the majority of
packets
Quoted 7 lines
handled by DPDK.
An alternative goal could be:
Do not touch the second cache line during RX.
A comment in the mbuf structure says so, but it is not true anymore.(I guess that regression testing didn't catch this because the tests
perform TX
Quoted 1 line
immediately after RX, so the cache miss just moves from the TX to the
RX part
Quoted 6 lines
of the test application.)
2. Regarding short term goals:
The current DPDK source code looks to me like
m->nextis the mostfrequently
Quoted 1 line
accessed field in the second cache line, so it makes sense moving
this to the
Quoted 2 lines
first cache line, rather than
m->pool. Benchmarking may help here.
Quoted 13 lines
Moreover, for the segmented packets the packet size is supposed to be large,
and it imposes the relatively low packet rate, so probably optimization of
moving next to the 1st cache line might be negligible at all. Just compare 148Mpps of
64B pkts and 4Mpps of 3000B pkts over 100Gbps link. Currently we are on benchmarking
and did not succeed yet on difference finding. The benefit can't be expressed in mpps delta,
we should measure CPU clocks, but Rx queue is almost always empty - we have an empty
loops. So, if we have the boost - it is extremely hard to catch one.
Very good point regarding the value of such an optimization, Slava!
And when free()'ing packets, both m->next and m->pool are touched.
So perhaps the free()/detach() functions in the mbuf library can be modified to handle first segments (and non-segmented packets) and following segments differently, so accessing m->next can be avoided for non-segmented packets. Then m->pool should be moved to the first cache line.
Re: [dpdk-dev] [PATCH 15/15] mbuf: move pool pointer in hotterfirst half
Hi,
Quoted 11 lines · Morten Brørup
Quoted 11 lines
From: dev [mailto:[email protected]] On Behalf Of Slava Ovsiienko
Sent: Tuesday, November 3, 2020 3:03 PMHi, Morten
Quoted 6 lines
From: Morten Brørup <[email protected]>
Sent: Tuesday, November 3, 2020 14:10Quoted 3 lines
From: Thomas Monjalon [mailto:[email protected]]
Sent: Monday, November 2, 2020 4:58 PM
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
+Cc techboard
We need benchmark numbers in order to take a decision. Please all, prepare some arguments and numbers so we can discuss
the
Quoted 1 line
Quoted 1 line
mbuf layout in the next techboard meeting.
I did some quick tests, and it appears to me that just moving the pool pointer to the first cache line has not a significant impact.
However, I agree with Morten that there is some room for optimization around m->pool: I did a hack in the ixgbe driver to assume there is only one mbuf pool. This simplifies a lot the freeing of mbufs in Tx, because we don't have to group them in bulks that shares the same pool (see ixgbe_tx_free_bufs()). The impact of this hack is quite good: +~5% on a real-life forwarding use case.
It is maybe possible to store the pool in the sw ring to avoid a later access to m->pool. Having a pool index as suggested by Morten would also help to reduce used room in sw ring in this case. But this is a bit off-topic :)
Quoted 15 lines
Quoted 15 lines
Quoted 3 lines
I propose that the techboard considers this from two angels:
1. Long term goals and their relative priority. I.e. what can be
achieved with
Quoted 1 line
wide-ranging modifications, requiring yet another ABI break and due
notices.
Quoted 9 lines
2. Short term goals, i.e. what can be achieved for this release.
My suggestions follow...
1. Regarding long term goals:
I have argued that simple forwarding of non-segmented packets using
Quoted 8 lines
Quoted 8 lines
only the
Quoted 4 lines
first mbuf cache line can be achieved by making three modifications:
a) Move
m->tx_offloadto the first cache line.Not all PMDs use this field on Tx. HW might support the checksum offloads
directly, not requiring these fields at all.
To me, a driver should use m->tx_offload, because the application specifies the offset where the checksum has to be done, in case the hw is not able to recognize the protocol.
Quoted 36 lines
Quoted 5 lines
Quoted 2 lines
b) Use an 8 bit pktmbuf mempool index in the first cache line, instead of the 64 bit
m->poolpointer in the second cache line.256 mpool looks enough, as for me. Regarding the indirect access to the pool
(via some table) - it might introduce some performance impact.It might, but I hope that it is negligible, so the benefits outweigh the disadvantages.
It would have to be measured, though.
And
m->poolis only used for free()'ing (and detach()'ing) mbufs.Quoted 5 lines
For example,
mlx5 PMD strongly relies on pool field for allocating mbufs in Rx datapath.
We're going to update (o-o, we found point to optimize), but for now it does.Without looking at the source code, I don't think the PMD is using
m->poolin the RX datapath, I think it is using a pool dedicated to a receive queue used for RX descriptors in the PMD (i.e.driver->queue->pool).Quoted 9 lines
Quoted 8 lines
c) Do not access
m->nextwhen we know that it is NULL. We can usem->nb_segs== 1 or some other invariant as the gate. It can be implemented by adding anm->nextaccessor function:struct rte_mbuf * rte_mbuf_next(struct rte_mbuf * m) { return m->nb_segs == 1 ? NULL : m->next; }Quoted 6 lines
Sorry, not sure about this. IIRC,
nb_segsis valid in the first segment/mbuf only.
If we have the 4 segments in the pkt we see nb_seg=4 in the first one, and the nb_seg=1
in the others. The next field is NULL in the last mbuf only. Am I wrong and miss something ?
Quoted 3 lines
You are correct.
This would have to be updated too. Either by increasing
m->nb_segin the following segments, or by splitting up relevant functions into functions for working on first segments (incl. non-segmented packets), and functions for working on following segments of segmented packets.
Instead of maintaining a valid nb_segs, a HAS_NEXT flag would be easier to implement. However it means that an accessor needs to be used instead of any m->next access.
Quoted 40 lines
Quoted 26 lines
Quoted 1 line
Regarding the priority of this goal, I guess that simple forwarding
of non-
Quoted 1 line
segmented packets is probably the path taken by the majority of
packets
Quoted 7 lines
handled by DPDK.
An alternative goal could be:
Do not touch the second cache line during RX.
A comment in the mbuf structure says so, but it is not true anymore.(I guess that regression testing didn't catch this because the tests
perform TX
Quoted 1 line
immediately after RX, so the cache miss just moves from the TX to the
RX part
Quoted 6 lines
of the test application.)
2. Regarding short term goals:
The current DPDK source code looks to me like
m->nextis the mostfrequently
Quoted 1 line
accessed field in the second cache line, so it makes sense moving
this to the
Quoted 2 lines
first cache line, rather than
m->pool. Benchmarking may help here.Quoted 13 lines
Moreover, for the segmented packets the packet size is supposed to be large,
and it imposes the relatively low packet rate, so probably optimization of
moving next to the 1st cache line might be negligible at all. Just compare 148Mpps of
64B pkts and 4Mpps of 3000B pkts over 100Gbps link. Currently we are on benchmarking
and did not succeed yet on difference finding. The benefit can't be expressed in mpps delta,
we should measure CPU clocks, but Rx queue is almost always empty - we have an empty
loops. So, if we have the boost - it is extremely hard to catch one.
Quoted 6 lines
Very good point regarding the value of such an optimization, Slava!
And when free()'ing packets, both
m->nextandm->poolare touched.So perhaps the free()/detach() functions in the mbuf library can be modified to handle first segments (and non-segmented packets) and following segments differently, so accessing
m->nextcan be avoided for non-segmented packets. Thenm->poolshould be moved to the first cache line.
I also think that Moving m->pool without doing something else about m->next is probably useless. And it's too late for 20.11 to do additionnal changes, so I suggest to postpone the field move to 21.11, once we have a clearer view of possible optimizations.
Olivier
Re: [dpdk-dev] [PATCH 15/15] mbuf: move pool pointer in hotterfirst half
Quoted 19 lines
Hi,
Quoted 13 lines · Morten Brørup
Quoted 13 lines
From: dev [mailto:[email protected]] On Behalf Of Slava Ovsiienko
Sent: Tuesday, November 3, 2020 3:03 PMHi, Morten
Quoted 8 lines
From: Morten Brørup <[email protected]>
Sent: Tuesday, November 3, 2020 14:10Quoted 5 lines
From: Thomas Monjalon [mailto:[email protected]]
Sent: Monday, November 2, 2020 4:58 PM+Cc techboard
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
We need benchmark numbers in order to take a decision. Please all, prepare some arguments and numbers so we can discuss
the
Quoted 1 line
Quoted 1 line
mbuf layout in the next techboard meeting.
I did some quick tests, and it appears to me that just moving the pool pointer to the first cache line has not a significant impact.
Hmm, as I remember Thomas mentioned about 5%+ improvement with that change. Though I suppose a lot depends from actual test-case. Would be good to know when it does help and when it doesn't.
Quoted 7 lines
However, I agree with Morten that there is some room for optimization around
m->pool: I did a hack in the ixgbe driver to assume there is only one mbuf pool. This simplifies a lot the freeing of mbufs in Tx, because we don't have to group them in bulks that shares the same pool (seeixgbe_tx_free_bufs()). The impact of this hack is quite good: +~5% on a real-life forwarding use case.
I think we already have such optimization ability within DPDK:
#define DEV_TX_OFFLOAD_MBUF_FAST_FREE 0x00010000
/**< Device supports optimization for fast release of mbufs.
* When set application must guarantee that per-queue all mbufs comes from
* the same mempool and has refcnt = 1.
*/
Seems over-optimistic to me, but many PMDs do support it.
Quoted 138 lines
It is maybe possible to store the pool in the sw ring to avoid a later access to
m->pool. Having a pool index as suggested by Morten would also help to reduce used room in sw ring in this case. But this is a bit off-topic :)Quoted 15 lines
Quoted 15 lines
Quoted 3 lines
I propose that the techboard considers this from two angels:
1. Long term goals and their relative priority. I.e. what can be
achieved with
Quoted 1 line
wide-ranging modifications, requiring yet another ABI break and due
notices.
Quoted 9 lines
2. Short term goals, i.e. what can be achieved for this release.
My suggestions follow...
1. Regarding long term goals:
I have argued that simple forwarding of non-segmented packets using
Quoted 8 lines
Quoted 8 lines
only the
Quoted 4 lines
first mbuf cache line can be achieved by making three modifications:
a) Move
m->tx_offloadto the first cache line.Not all PMDs use this field on Tx. HW might support the checksum offloads
directly, not requiring these fields at all.To me, a driver should use
m->tx_offload, because the application specifies the offset where the checksum has to be done, in case the hw is not able to recognize the protocol.Quoted 12 lines
Quoted 5 lines
Quoted 2 lines
b) Use an 8 bit pktmbuf mempool index in the first cache line, instead of the 64 bit
m->poolpointer in the second cache line.256 mpool looks enough, as for me. Regarding the indirect access to the pool
(via some table) - it might introduce some performance impact.It might, but I hope that it is negligible, so the benefits outweigh the disadvantages.
It would have to be measured, though.
And
m->poolis only used for free()'ing (and detach()'ing) mbufs.Quoted 7 lines
Quoted 5 lines
For example,
mlx5 PMD strongly relies on pool field for allocating mbufs in Rx datapath.
We're going to update (o-o, we found point to optimize), but for now it does.Without looking at the source code, I don't think the PMD is using
m->poolin the RX datapath, I think it is using a pool dedicated to areceive queue used for RX descriptors in the PMD (i.e.
driver->queue->pool).Quoted 17 lines
Quoted 10 lines
Quoted 9 lines
c) Do not access
m->nextwhen we know that it is NULL. We can usem->nb_segs== 1 or some other invariant as the gate. It can be implemented by adding anm->nextaccessor function:struct rte_mbuf * rte_mbuf_next(struct rte_mbuf * m) { return m->nb_segs == 1 ? NULL : m->next; }Quoted 6 lines
Sorry, not sure about this. IIRC,
nb_segsis valid in the first segment/mbuf only.
If we have the 4 segments in the pkt we see nb_seg=4 in the first one, and the nb_seg=1
in the others. The next field is NULL in the last mbuf only. Am I wrong and miss something ?Quoted 3 lines
You are correct.
This would have to be updated too. Either by increasing
m->nb_segin the following segments, or by splitting up relevant functions intofunctions for working on first segments (incl. non-segmented packets), and functions for working on following segments of segmented packets.
Instead of maintaining a valid
nb_segs, aHAS_NEXTflag would be easier to implement. However it means that an accessor needs to be used instead of anym->nextaccess.Quoted 40 lines
Quoted 26 lines
Quoted 1 line
Regarding the priority of this goal, I guess that simple forwarding
of non-
Quoted 1 line
segmented packets is probably the path taken by the majority of
packets
Quoted 7 lines
handled by DPDK.
An alternative goal could be:
Do not touch the second cache line during RX.
A comment in the mbuf structure says so, but it is not true anymore.(I guess that regression testing didn't catch this because the tests
perform TX
Quoted 1 line
immediately after RX, so the cache miss just moves from the TX to the
RX part
Quoted 6 lines
of the test application.)
2. Regarding short term goals:
The current DPDK source code looks to me like
m->nextis the mostfrequently
Quoted 1 line
accessed field in the second cache line, so it makes sense moving
this to the
Quoted 2 lines
first cache line, rather than
m->pool. Benchmarking may help here.Quoted 13 lines
Moreover, for the segmented packets the packet size is supposed to be large,
and it imposes the relatively low packet rate, so probably optimization of
moving next to the 1st cache line might be negligible at all. Just compare 148Mpps of
64B pkts and 4Mpps of 3000B pkts over 100Gbps link. Currently we are on benchmarking
and did not succeed yet on difference finding. The benefit can't be expressed in mpps delta,
we should measure CPU clocks, but Rx queue is almost always empty - we have an empty
loops. So, if we have the boost - it is extremely hard to catch one.Quoted 5 lines
Very good point regarding the value of such an optimization, Slava!
And when free()'ing packets, both
m->nextandm->poolare touched.So perhaps the free()/detach() functions in the mbuf library can be modified to handle first segments (and non-segmented packets) and
following segments differently, so accessing
m->nextcan be avoided for non-segmented packets. Thenm->poolshould be moved to the first cache line.Quoted 1 line
I also think that Moving
m->poolwithout doing something else aboutm->nextis probably useless. And it's too late for 20.11 to do additionnal changes, so I suggest to postpone the field move to 21.11, once we have a clearer view of possible optimizations.Olivier
Re: [dpdk-dev] [PATCH 15/15] mbuf: move pool pointer in hotterfirst half
Quoted 55 lines
From: dev [mailto:[email protected]] On Behalf Of Ananyev, Konstantin
Sent: Thursday, November 5, 2020 1:26 AMQuoted 5 lines
Hi,
Quoted 1 line · Morten Brørup
Quoted 1 line
From: dev [mailto:[email protected]] On Behalf Of Slava
Ovsiienko
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Sent: Tuesday, November 3, 2020 3:03 PM
Hi, Morten
Quoted 3 lines
From: Morten Brørup <[email protected]>
Sent: Tuesday, November 3, 2020 14:10Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
From: Thomas Monjalon [mailto:[email protected]]
Sent: Monday, November 2, 2020 4:58 PM+Cc techboard
We need benchmark numbers in order to take a decision. Please all, prepare some arguments and numbers so we can
discuss
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
the
Quoted 1 line
Quoted 1 line
mbuf layout in the next techboard meeting.
I did some quick tests, and it appears to me that just moving the
pool
Quoted 1 line
pointer to the first cache line has not a significant impact.
Hmm, as I remember Thomas mentioned about 5%+ improvement with that change. Though I suppose a lot depends from actual test-case. Would be good to know when it does help and when it doesn't.
Quoted 3 lines
However, I agree with Morten that there is some room for optimization around
m->pool: I did a hack in the ixgbe driver to assume there isonly
Quoted 1 line
one mbuf pool. This simplifies a lot the freeing of mbufs in Tx,
because
Quoted 2 lines
we don't have to group them in bulks that shares the same pool (see
ixgbe_tx_free_bufs()). The impact of this hack is quite good: +~5% ona
Quoted 1 line
real-life forwarding use case.
I think we already have such optimization ability within DPDK:
#defineDEV_TX_OFFLOAD_MBUF_FAST_FREE0x00010000
/**< Device supports optimization for fast release of mbufs.
* When set application must guarantee that per-queue all mbufs comes
from
* the same mempool and has refcnt = 1.
*/
Quoted 1 line
Seems over-optimistic to me, but many PMDs do support it.
Looking at a few drivers using this flag, Intel drivers use rte_mempool_put(m->pool), and thus still reads the second cache line. Only ThunderX seems to use the optimization benefit and use rte_mempool_put_bulk(q->pool).
I would rather see a generic optimization of free()'ing non-segmented packets in the mbuf library, where free() and free_seg() take advantage of knowing whether they are working on the first segment or not - like the is_header indicator in many of the mbuf check functions - and, when working on the first segment, gate access to n->next by m->nb_segs > 1.
Concept:
static inline voidrte_pktmbuf_free(struct rte_mbuf *m)
{
struct rte_mbuf *m_next;
/* NOTE: Sanity check of header has moved to __rte_pktmbuf_prefree_seg(). */
if (m != NULL) {
if (m->nb_segs == 1) {
__rte_pktmbuf_free_seg(m, 1);
} else {
m_next = m->next;
__rte_pktmbuf_free_seg(m, 1);
m = m_next;
while (m != NULL) {
m_next = m->next;
__rte_pktmbuf_free_seg(m, 0);
m = m_next;
}
}
}
}static __rte_always_inline void __rte_pktmbuf_free_seg(struct rte_mbuf *m, int is_header)
{
m = __rte_pktmbuf_prefree_seg(m, is_header);
if (likely(m != NULL))
rte_mbuf_raw_free(m);
}static __rte_always_inline struct rte_mbuf * __rte_pktmbuf_prefree_seg(struct rte_mbuf *m, int is_header)
{
__rte_mbuf_sanity_check(m, is_header);
if (likely(rte_mbuf_refcnt_read(m) == 1)) {
if (!RTE_MBUF_DIRECT(m)) {
rte_pktmbuf_detach(m);
if (RTE_MBUF_HAS_EXTBUF(m) &&
RTE_MBUF_HAS_PINNED_EXTBUF(m) &&
__rte_pktmbuf_pinned_extbuf_decref(m))
return NULL;
}
if (is_header && m->nb_segs == 1)
return m; /* NOTE: Avoid touching (writing to) the second cache line. */
if (m->next != NULL) {
m->next = NULL;
m->nb_segs = 1;
}
return m;
} else if (__rte_mbuf_refcnt_update(m, -1) == 0) {
if (!RTE_MBUF_DIRECT(m)) {
rte_pktmbuf_detach(m);
if (RTE_MBUF_HAS_EXTBUF(m) &&
RTE_MBUF_HAS_PINNED_EXTBUF(m) &&
__rte_pktmbuf_pinned_extbuf_decref(m))
return NULL;
}
if (is_header && m->nb_segs == 1) {
/* NOTE: Avoid touching (writing to) the second cache line. */
rte_mbuf_refcnt_set(m, 1);
return m;
}
if (m->next != NULL) {
m->next = NULL;
m->nb_segs = 1;
}
rte_mbuf_refcnt_set(m, 1);
return m;
}
return NULL;
}Furthermore, this concept might provide an additional performance improvement by moving m->pool to the first cache line, so rte_mempool_put() in rte_mbuf_raw_free() wouldn't have to touch the second cache line either.
Re: [dpdk-dev] [PATCH 15/15] mbuf: move pool pointer in hotterfirst half
In reply to Ananyev, KonstantinThere is a simple alternative for applications with a single mbuf pool to avoid accessing m->pool.
We could add a global variable pointing to the single mbuf pool.
It would be NULL by default.
It would be set by rte_pktmbuf_pool_create() on first invocation, and reset back to NULL on following invocations. (There would need to be a counter too, to prevent setting it again on the third invocation.)
All functions accessing m->pool would use the global mbuf pool pointer if set, and otherwise use the m->pool pointer, like this:
- rte_mempool_put(m->pool, m);
+ rte_mempool_put(global_mbuf_pool ? global_mbuf_pool : m->pool, m);
This optimization can be implemented without ABI breakage:
Since m->pool is initialized as always, functions that are not modified to use the global_mbuf_pool will simply continue using m->pool, not knowing that a global mbuf pool exists.
Med venlig hilsen / kind regards
- Morten Brørup
Re: [dpdk-dev] [PATCH 15/15] mbuf: move pool pointer in hotterfirst half
Quoted 8 lines · Morten Brørup
There is a simple alternative for applications with a single mbuf pool to avoid accessing
m->pool.We could add a global variable pointing to the single mbuf pool.
It would be NULL by default.
It would be set by
rte_pktmbuf_pool_create()on first invocation, and reset back to NULL on following invocations. (There would need to be a counter too, to prevent setting it again on the third invocation.)
Quoted 9 lines
All functions accessing
m->poolwould use the global mbuf pool pointer if set, and otherwise use them->poolpointer, like this:-
rte_mempool_put(m->pool, m);
+rte_mempool_put(global_mbuf_pool ? global_mbuf_pool : m->pool, m);This optimization can be implemented without ABI breakage:
Since
m->poolis initialized as always, functions that are not modified to use theglobal_mbuf_poolwill simply continue usingm->pool, not knowing that a global mbuf pool exists.
Very interesting idea. Definitely worth considering. A TX function would only have to check the global variable once at the start of cleanup too, and if set, it can use bulk frees without any additional work.
/Bruce
Re: [dpdk-dev] [PATCH 15/15] mbuf: move pool pointer in hotter first half
In reply to Thomas MonjalonQuoted 99 lines · Thomas Monjalon
The mempool pointer in the mbuf struct is moved
from the second to the first half.
It should increase performance on most systems having 64-byte cache line, i.e. mbuf is split in two cache lines.
On such system, the first half (also called first cache line) is hotter than the second one where the pool pointer was.Moving this field gives more space to dynfield1.
This is how the mbuf layout looks like (pahole-style):
word type name byte size 0 void * buf_addr; /* 0 + 8 */ 1 rte_iova_t buf_iova /* 8 + 8 */ /* --- RTE_MARKER64 rearm_data; */ 2 uint16_t data_off; /* 16 + 2 */ uint16_t refcnt; /* 18 + 2 */ uint16_t nb_segs; /* 20 + 2 */ uint16_t port; /* 22 + 2 */ 3 uint64_t ol_flags; /* 24 + 8 */ /* --- RTE_MARKER rx_descriptor_fields1; */ 4 uint32_t union packet_type; /* 32 + 4 */ uint32_t pkt_len; /* 36 + 4 */ 5 uint16_t data_len; /* 40 + 2 */ uint16_t vlan_tci; /* 42 + 2 */ 5.5 uint64_t union hash; /* 44 + 8 */ 6.5 uint16_t vlan_tci_outer; /* 52 + 2 */ uint16_t buf_len; /* 54 + 2 */ 7 struct rte_mempool * pool; /* 56 + 8 */ /* --- RTE_MARKER cacheline1; */ 8 struct rte_mbuf * next; /* 64 + 8 */ 9 uint64_t union tx_offload; /* 72 + 8 */ 10 uint16_t priv_size; /* 80 + 2 */ uint16_t timesync; /* 82 + 2 */ uint32_t seqn; /* 84 + 4 */ 11 struct rte_mbuf_ext_shared_info * shinfo; /* 88 + 8 */ 12 uint64_t dynfield1[4]; /* 96 + 32 */ 16 /* --- END 128 */Signed-off-by Thomas Monjalon <[email protected]>--- doc/guides/rel_notes/deprecation.rst | 5 ----- lib/librte_kni/rte_kni_common.h | 3 ++- lib/librte_mbuf/rte_mbuf_core.h | 5 ++--- 3 files changed, 4 insertions(+), 9 deletions(-)doc/guides/rel_notes/deprecation.rst +0
-5@@ -88,11 +88,6 @@ Deprecation Notices - ``seqn`` - As a consequence, the layout of the ``struct rte_mbuf`` will be re-arranged, - avoiding impact on vectorized implementation of the driver datapaths, - while evaluating performance gains of a better use of the first cache line. - - * ethdev: the legacy filter API, including ``rte_eth_dev_filter_supported()``, ``rte_eth_dev_filter_ctrl()`` as well as filter types MACVLAN, ETHERTYPE, FLEXIBLE, SYN, NTUPLE, TUNNEL, FDIR,lib/librte_kni/rte_kni_common.h +2
-1@@ -84,10 +84,11 @@ struct rte_kni_mbuf {char pad2[4 ];uint32_t pkt_len;/**< Total pkt len: sum of all segment data_len. */ uint16_t data_len;/**< Amount of data in segment buffer. */ +char pad3[14 ]; +void *pool;/* fields on second cache line */ __attribute__((__aligned__ (RTE_CACHE_LINE_MIN_SIZE ))) -void *pool;void *next;/**< Physical address of next mbuf in kernel. */ };lib/librte_mbuf/rte_mbuf_core.h +1
-2@@ -584,12 +584,11 @@ struct rte_mbuf {uint16_t buf_len;/**< Length of segment buffer. */ -uint64_t unused; +struct rte_mempool *pool;/**< Pool from which mbuf was allocated. */ /* second cache line - fields only used in slow path or on TX */ RTE_MARKER cacheline1 __rte_cache_min_aligned; -struct rte_mempool *pool;/**< Pool from which mbuf was allocated. */ struct rte_mbuf *next;/**< Next segment of scattered packet. */ /* fields to support TX offloads */
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 651
Quoted 8 lines
lib/librte_mbuf/rte_mbuf_core.h +1
-1@@ -646,7 +645,7 @@ struct rte_mbuf {*/ struct rte_mbuf_ext_shared_info *shinfo; -uint64_t dynfield1[3 ];/**< Reserved for dynamic fields. */ +uint64_t dynfield1[4 ];/**< Reserved for dynamic fields. */ } __rte_cache_aligned;/**
I will let other chime in on the merits of positioning cache alignment of the mempool pointer.
From the ABI PoV, depreciate notice has been observed and since mbuf effects everything doing it outside of a ABI Breakage window is impossible, so it now or never.
Ray K
v2 cover remove mbuf timestamp
In reply to Thomas MonjalonThe mbuf field timestamp was announced to be removed for three reasons:
- a dynamic field already exist, used for Tx only
- this field always used 8 bytes even if unneeded
- this field is in the first half (cacheline) of mbuf
After this series, the dynamic field timestamp is used for both Rx and Tx with separate dynamic flags to distinguish when the value is meaningful without resetting the field during forwarding.
As a consequence, 8 bytes can be re-allocated to dynamic fields in the first half of mbuf structure.
It is still open to change more the mbuf layout.
This mbuf layout change is important to allow adding more features (consuming more dynamic fields) during the next year,
and can allow performance improvements with new usages in the first half.
Thomas Monjalon (14):
eventdev: remove software Rx timestamp
mbuf: add Rx timestamp dynamic flag
ethdev: register mbuf field and flags for timestamp
latency: switch timestamp to dynamic mbuf field net/ark: switch timestamp to dynamic mbuf field net/dpaa2: switch timestamp to dynamic mbuf field net/mlx5: fix dynamic mbuf offset lookup check net/mlx5: switch timestamp to dynamic mbuf field net/nfb: switch timestamp to dynamic mbuf field net/octeontx2: switch timestamp to dynamic mbuf field net/pcap: switch timestamp to dynamic mbuf field app/testpmd: switch timestamp to dynamic mbuf field examples/rxtx_callbacks: switch timestamp to dynamic field
mbuf: remove deprecated timestamp field
app/test-pmd/config.c | 38 ----------- app/test-pmd/util.c | 39 ++++++++++- app/test/test_mbuf.c | 1 - doc/guides/nics/mlx5.rst | 5 +- .../prog_guide/event_ethernet_rx_adapter.rst | 6 +- doc/guides/rel_notes/deprecation.rst | 4 -- doc/guides/rel_notes/release_20_11.rst | 4 ++ drivers/net/ark/ark_ethdev.c | 23 +++++++ drivers/net/ark/ark_ethdev_rx.c | 10 ++- drivers/net/dpaa2/dpaa2_ethdev.c | 20 ++++++ drivers/net/dpaa2/dpaa2_ethdev.h | 2 + drivers/net/dpaa2/dpaa2_rxtx.c | 25 +++++-- drivers/net/mlx5/mlx5_rxq.c | 36 ++++++++++ drivers/net/mlx5/mlx5_rxtx.c | 8 +-- drivers/net/mlx5/mlx5_rxtx.h | 19 ++++++ drivers/net/mlx5/mlx5_rxtx_vec_altivec.h | 41 ++++++------ drivers/net/mlx5/mlx5_rxtx_vec_neon.h | 43 ++++++------ drivers/net/mlx5/mlx5_rxtx_vec_sse.h | 35 +++++----- drivers/net/mlx5/mlx5_trigger.c | 2 +- drivers/net/mlx5/mlx5_txq.c | 2 +- drivers/net/nfb/nfb_rx.c | 23 ++++++- drivers/net/nfb/nfb_rx.h | 18 +++-- drivers/net/octeontx2/otx2_ethdev.c | 33 ++++++++++ drivers/net/octeontx2/otx2_rx.h | 19 +++++- drivers/net/octeontx2/version.map | 7 ++ drivers/net/pcap/rte_eth_pcap.c | 29 ++++++++- examples/rxtx_callbacks/main.c | 17 ++++- lib/librte_ethdev/rte_ethdev.c | 65 +++++++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 13 +++- .../rte_event_eth_rx_adapter.c | 11 ---- .../rte_event_eth_rx_adapter.h | 6 +- lib/librte_latencystats/rte_latencystats.c | 48 ++++++++++++-- lib/librte_mbuf/rte_mbuf.c | 2 - lib/librte_mbuf/rte_mbuf.h | 2 +- lib/librte_mbuf/rte_mbuf_core.h | 12 +--- lib/librte_mbuf/rte_mbuf_dyn.c | 1 + lib/librte_mbuf/rte_mbuf_dyn.h | 11 ++-- 37 files changed, 501 insertions(+), 179 deletions(-)
Signature · 1 line
2.28.0
PATCH v2 1/14 eventdev: remove software Rx timestamp
This a revert of the commit 569758758dcd ("eventdev: add Rx timestamp"). If the Rx timestamp is not configured on the ethdev port, there is no reason to set one.
Also the accuracy of the timestamp was bad because set at a late stage. Anyway there is no trace of the usage of this timestamp.
--- doc/guides/prog_guide/event_ethernet_rx_adapter.rst | 6 +----- lib/librte_eventdev/rte_event_eth_rx_adapter.c | 11 ----------- lib/librte_eventdev/rte_event_eth_rx_adapter.h | 6 +----- 3 files changed, 2 insertions(+), 21 deletions(-)
doc/guides/prog_guide/event_ethernet_rx_adapter.rst +1 -5
@@ -12,11 +12,7 @@ be supported in hardware or require a software thread to receive packets from the ethdev port using ethdev poll mode APIs and enqueue these as events to the event device using the eventdev API. Both transfer mechanisms may be present on the same platform depending on the particular combination of the ethdev and -the event device. For SW based packet transfer, if the mbuf does not have a -timestamp set, the adapter adds a timestamp to the mbuf using -rte_get_tsc_cycles(), this provides a more accurate timestamp as compared to -if the application were to set the timestamp since it avoids event device -schedule latency. +the event device. The Event Ethernet Rx Adapter library is intended for the application code to configure both transfer mechanisms using a common API. A capability API allows
lib/librte_eventdev/rte_event_eth_rx_adapter.c +0 -11
@@ -763,7 +763,6 @@ rxa_buffer_mbufs(struct rte_event_eth_rx_adapter *rx_adapter,uint32_t rss_mask;uint32_t rss;int do_rss; -uint64_t ts;uint16_t nb_cb;uint16_t dropped;
@@ -771,16 +770,6 @@ rxa_buffer_mbufs(struct rte_event_eth_rx_adapter *rx_adapter, rss_mask = ~(((m->ol_flags &PKT_RX_RSS_HASH ) !=0 ) -1 ); do_rss = !rss_mask && !eth_rx_queue_info->flow_id_mask; -if ((m->ol_flags &PKT_RX_TIMESTAMP ) ==0 ) { - ts =rte_get_tsc_cycles (); -for (i =0 ; i < num; i++) { - m = mbufs[i]; - - m->timestamp = ts; - m->ol_flags |=PKT_RX_TIMESTAMP ; - } - } -for (i =0 ; i < num; i++) { m = mbufs[i];
lib/librte_eventdev/rte_event_eth_rx_adapter.h +1 -5
@@ -21,11 +21,7 @@* * The adapter uses a EAL service core function for SW based packet transfer * and uses the eventdev PMD functions to configure HW based packet transfer -* between the ethernet device and the event device. For SW based packet -* transfer, if the mbuf does not have a timestamp set, the adapter adds a -* timestamp to the mbuf using rte_get_tsc_cycles(), this provides a more -* accurate timestamp as compared to if the application were to set the time -* stamp since it avoids event device schedule latency. +* between the ethernet device and the event device. * * The ethernet Rx event adapter's functions are: * - rte_event_eth_rx_adapter_create_ext()
Signature · 1 line
2.28.0
PATCH v2 2/14 mbuf: add Rx timestamp dynamic flag
In reply to Thomas MonjalonThere is already a dynamic field for timestamp,
used only for Tx scheduling, thanks to the dedicated flag. The same field can be used for Rx timestamp filled by drivers. The only missing part to get rid of the static timestamp field was to declare a new dynamic flag for Rx usage.
After migrating all Rx timestamp usages, it will be possible to remove the deprecated timestamp field.
--- lib/librte_mbuf/rte_mbuf_dyn.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
lib/librte_mbuf/rte_mbuf_dyn.h +5 -5
@@ -258,14 +258,14 @@ void rte_mbuf_dyn_dump(FILE *out);* timestamp. The dynamic Tx timestamp flag tells whether the field contains * actual timestamp value for the packets being sent, this value can be * used by PMD to schedule packet sending. -* -* After PKT_RX_TIMESTAMP flag and fixed timestamp field deprecation -* and obsoleting, the dedicated Rx timestamp flag is supposed to be -* introduced and the shared dynamic timestamp field will be used -* to handle the timestamps on receiving datapath as well. */ #define RTE_MBUF_DYNFIELD_TIMESTAMP_NAME "rte_dynfield_timestamp" +/** +* Indicate that the timestamp field in the mbuf was filled by the driver. +*/ +#define RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME "rte_dynflag_rx_timestamp" +/** * When PMD sees the RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME flag set on the * packet being sent it tries to synchronize the time of packet appearing
Signature · 1 line
2.28.0
PATCH v2 3/14 ethdev: register mbuf field and flags for timestamp
In reply to Thomas MonjalonDuring port configure or queue setup, the offload flags DEV_RX_OFFLOAD_TIMESTAMP and DEV_TX_OFFLOAD_SEND_ON_TIMESTAMP trigger the registration of the related mbuf field and flags.
Previously, the Tx timestamp field and flag were registered in testpmd, as described in mlx5 guide.
For the general usage of Rx and Tx timestamps,
managing registrations inside ethdev is simpler and properly documented.
--- app/test-pmd/config.c | 38 -------------------- doc/guides/nics/mlx5.rst | 5 ++- lib/librte_ethdev/rte_ethdev.c | 65 ++++++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 9 ++++- lib/librte_mbuf/rte_mbuf_dyn.h | 1 + 5 files changed, 76 insertions(+), 42 deletions(-)
app/test-pmd/config.c +0 -38
@@ -3955,44 +3955,6 @@ show_tx_pkt_times(void)void set_tx_pkt_times (unsigned int *tx_times) { -uint16_t port_id; -int offload_found =0 ; -int offset; -int flag; - -static const struct rte_mbuf_dynfield desc_offs = { - .name =RTE_MBUF_DYNFIELD_TIMESTAMP_NAME , - .size =sizeof (uint64_t ), - .align = __alignof__(uint64_t ), - }; -static const struct rte_mbuf_dynflag desc_flag = { - .name =RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME , - }; - -RTE_ETH_FOREACH_DEV (port_id) { -struct rte_eth_dev_info dev_info = {0 }; -int ret; - - ret =rte_eth_dev_info_get (port_id, &dev_info); -if (ret ==0 && dev_info.tx_offload_capa & -DEV_TX_OFFLOAD_SEND_ON_TIMESTAMP ) { - offload_found =1 ; -break ; - } - } -if (!offload_found) { -printf ("No device supporting Tx timestamp scheduling found, " -"dynamic flag and field not registered\n" ); -return ; - } - offset =rte_mbuf_dynfield_register (&desc_offs); -if (offset <0 && rte_errno !=EEXIST ) -printf ("Dynamic timestamp field registration error: %d" , - rte_errno); - flag =rte_mbuf_dynflag_register (&desc_flag); -if (flag <0 && rte_errno !=EEXIST ) -printf ("Dynamic timestamp flag registration error: %d" , - rte_errno); tx_pkt_times_inter = tx_times[0 ]; tx_pkt_times_intra = tx_times[1 ]; }
doc/guides/nics/mlx5.rst +2 -3
@@ -237,9 +237,8 @@ Limitations ``txq_inline_max`` and ``txq_inline_mpw`` devargs keys. - To provide the packet send scheduling on mbuf timestamps the ``tx_pp`` - parameter should be specified, RTE_MBUF_DYNFIELD_TIMESTAMP_NAME and - RTE_MBUF_DYNFLAG_TIMESTAMP_NAME should be registered by application. - When PMD sees the RTE_MBUF_DYNFLAG_TIMESTAMP_NAME set on the packet + parameter should be specified. + When PMD sees the RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME set on the packet being sent it tries to synchronize the time of packet appearing on the wire with the specified packet timestamp. It the specified one is in the past it should be ignored, if one is in the distant future
lib/librte_ethdev/rte_ethdev.c +65 -0
95 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev.h +8 -1
@@ -1344,6 +1344,9 @@ struct rte_eth_conf {#define DEV_RX_OFFLOAD_VLAN_EXTEND 0x00000400#define DEV_RX_OFFLOAD_JUMBO_FRAME 0x00000800#define DEV_RX_OFFLOAD_SCATTER 0x00002000 +/** +* The mbuf field and flag are registered when the offload is configured. +*/ #define DEV_RX_OFFLOAD_TIMESTAMP 0x00004000#define DEV_RX_OFFLOAD_SECURITY 0x00008000#define DEV_RX_OFFLOAD_KEEP_CRC 0x00010000
@@ -1408,7 +1411,11 @@ struct rte_eth_conf {#define DEV_TX_OFFLOAD_IP_TNL_TSO 0x00080000/** Device supports outer UDP checksum */ #define DEV_TX_OFFLOAD_OUTER_UDP_CKSUM 0x00100000 -/** Device supports send on timestamp */ +/** +* Device sends on time read from RTE_MBUF_DYNFIELD_TIMESTAMP_NAME +* if RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME is set in ol_flags. +* The mbuf field and flag are registered when the offload is configured. +*/ #define DEV_TX_OFFLOAD_SEND_ON_TIMESTAMP 0x00200000/* * If new Tx offload capabilities are defined, they also must be
lib/librte_mbuf/rte_mbuf_dyn.h +1 -0
@@ -260,6 +260,7 @@ void rte_mbuf_dyn_dump(FILE *out);* used by PMD to schedule packet sending. */ #define RTE_MBUF_DYNFIELD_TIMESTAMP_NAME "rte_dynfield_timestamp" +typedef uint64_t rte_mbuf_timestamp_t ;/** * Indicate that the timestamp field in the mbuf was filled by the driver.
Signature · 1 line
2.28.0
Re: [dpdk-dev] [PATCH v2 03/14] ethdev: register mbuf field and flags for timestamp
Quoted 11 lines · Thomas Monjalon
During port configure or queue setup, the offload flags
DEV_RX_OFFLOAD_TIMESTAMPandDEV_TX_OFFLOAD_SEND_ON_TIMESTAMPtrigger the registration of the related mbuf field and flags.Previously, the Tx timestamp field and flag were registered in testpmd, as described in mlx5 guide.
For the general usage of Rx and Tx timestamps,
managing registrations inside ethdev is simpler and properly documented.Signed-off-by Thomas Monjalon <[email protected]>Reviewed-by Andrew Rybchenko <[email protected]>
<...>
Quoted 51 lines
lib/librte_ethdev/rte_ethdev.c +38
-0@@ -31,6 +31,7 @@#include <rte_mempool.h> #include <rte_malloc.h> #include <rte_mbuf.h> +#include <rte_mbuf_dyn.h> #include <rte_errno.h> #include <rte_spinlock.h> #include <rte_string_fns.h> @@ -1232,6 +1233,54 @@ eth_dev_check_lro_pkt_size(uint16_t port_id, uint32_t config_size,return ret; } +static inline int +eth_dev_timestamp_mbuf_register (uint64_t rx_offloads,uint64_t tx_offloads) +{ +static const struct rte_mbuf_dynfield field_desc = { + .name =RTE_MBUF_DYNFIELD_TIMESTAMP_NAME , + .size =sizeof (rte_mbuf_timestamp_t), + .align = __alignof__(rte_mbuf_timestamp_t ), + }; +static const struct rte_mbuf_dynflag rx_flag_desc = { + .name =RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME , + }; +static const struct rte_mbuf_dynflag tx_flag_desc = { + .name =RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME , + }; +bool todo_rx, todo_tx; +int offset; + + todo_rx = (rx_offloads &DEV_RX_OFFLOAD_TIMESTAMP ) !=0 ; + todo_tx = (tx_offloads &DEV_TX_OFFLOAD_SEND_ON_TIMESTAMP ) !=0 ; + +if (todo_rx || todo_tx) { + offset =rte_mbuf_dynfield_register (&field_desc); +if (offset <0 ) { +RTE_ETHDEV_LOG (ERR , +"Failed to register mbuf field for timestamp\n" ); +return -rte_errno; + } + } +if (todo_rx) { + offset =rte_mbuf_dynflag_register (&rx_flag_desc); +if (offset <0 ) { +RTE_ETHDEV_LOG (ERR , +"Failed to register mbuf flag for Rx timestamp\n" ); +return -rte_errno; + } + } +if (todo_tx) {
lib/librte_ethdev/rte_ethdev.c eth_dev_check_lro_pkt_size(uint16_t port_id, uint32_t config_size, · line 1282
Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10
-0+ offset =rte_mbuf_dynflag_register (&tx_flag_desc); +if (offset <0 ) { +RTE_ETHDEV_LOG (ERR , +"Failed to register mbuf flag for Tx timestamp\n" ); +return -rte_errno; + } + } + +return 0 ; +}
The code that registers the dynamic fields and flags for timestamp is more or less duplicated several times in the patchset. As discussed privately, it would make sense to have helpers to register them in one operation, without the need to redeclare the structures:
int rte_mbuf_dyn_rx_timestamp_register(int *offset, uint64_t *rx_bitnum) int rte_mbuf_dyn_tx_timestamp_register(int *offset, uint64_t *tx_bitnum)
Re: [dpdk-dev] [PATCH v2 03/14] ethdev: register mbuf field and flags for timestamp
02/11/2020 16:39, Olivier Matz:
Quoted 70 lines · Thomas Monjalon
Quoted 11 lines
During port configure or queue setup, the offload flags
DEV_RX_OFFLOAD_TIMESTAMPandDEV_TX_OFFLOAD_SEND_ON_TIMESTAMPtrigger the registration of the related mbuf field and flags.Previously, the Tx timestamp field and flag were registered in testpmd, as described in mlx5 guide.
For the general usage of Rx and Tx timestamps,
managing registrations inside ethdev is simpler and properly documented.Signed-off-by Thomas Monjalon <[email protected]>Reviewed-by Andrew Rybchenko <[email protected]><...>
Quoted 39 lines
lib/librte_ethdev/rte_ethdev.c +37
-0+static inline int +eth_dev_timestamp_mbuf_register (uint64_t rx_offloads,uint64_t tx_offloads) +{ +static const struct rte_mbuf_dynfield field_desc = { + .name =RTE_MBUF_DYNFIELD_TIMESTAMP_NAME , + .size =sizeof (rte_mbuf_timestamp_t), + .align = __alignof__(rte_mbuf_timestamp_t ), + }; +static const struct rte_mbuf_dynflag rx_flag_desc = { + .name =RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME , + }; +static const struct rte_mbuf_dynflag tx_flag_desc = { + .name =RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME , + }; +bool todo_rx, todo_tx; +int offset; + + todo_rx = (rx_offloads &DEV_RX_OFFLOAD_TIMESTAMP ) !=0 ; + todo_tx = (tx_offloads &DEV_TX_OFFLOAD_SEND_ON_TIMESTAMP ) !=0 ; + +if (todo_rx || todo_tx) { + offset =rte_mbuf_dynfield_register (&field_desc); +if (offset <0 ) { +RTE_ETHDEV_LOG (ERR , +"Failed to register mbuf field for timestamp\n" ); +return -rte_errno; + } + } +if (todo_rx) { + offset =rte_mbuf_dynflag_register (&rx_flag_desc); +if (offset <0 ) { +RTE_ETHDEV_LOG (ERR , +"Failed to register mbuf flag for Rx timestamp\n" ); +return -rte_errno; + } + } +if (todo_tx) {lib/librte_ethdev/rte_ethdev.c eth_dev_check_lro_pkt_size(uint16_t port_id, uint32_t config_size, · line 1282
Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10
-0+ offset =rte_mbuf_dynflag_register (&tx_flag_desc); +if (offset <0 ) { +RTE_ETHDEV_LOG (ERR , +"Failed to register mbuf flag for Tx timestamp\n" ); +return -rte_errno; + } + } + +return 0 ; +}The code that registers the dynamic fields and flags for timestamp is more or less duplicated several times in the patchset. As discussed privately, it would make sense to have helpers to register them in one operation, without the need to redeclare the structures:
Quoted 2 lines
int
rte_mbuf_dyn_rx_timestamp_register(int *offset, uint64_t *rx_bitnum)intrte_mbuf_dyn_tx_timestamp_register(int *offset, uint64_t *tx_bitnum)
Yes we can have a function in rte_mbuf_dyn.h/c which is called to register field and flags from drivers or apps. Then no need to register at ethdev level.
PATCH v2 4/14 latency: switch timestamp to dynamic mbuf field
In reply to Thomas MonjalonThe mbuf timestamp is moved to a dynamic field
in order to allow removal of the deprecated static field. The related mbuf flag is also replaced with the dynamic one.
--- lib/librte_latencystats/rte_latencystats.c | 48 +++++++++++++++++++--- 1 file changed, 43 insertions(+), 5 deletions(-)
lib/librte_latencystats/rte_latencystats.c +43 -5
@@ -8,7 +8,9 @@#include <math.h> #include <rte_string_fns.h> +#include <rte_bitops.h> #include <rte_mbuf.h> +#include <rte_mbuf_dyn.h> #include <rte_log.h> #include <rte_cycles.h> #include <rte_ethdev.h>
@@ -31,6 +33,16 @@ latencystat_cycles_per_ns(void)/* Macros for printing using RTE_LOG */ #define RTE_LOGTYPE_LATENCY_STATS RTE_LOGTYPE_USER1 +static uint64_t timestamp_dynflag; +static int timestamp_dynfield_offset =-1 ; + +static inline rte_mbuf_timestamp_t * +timestamp_dynfield (struct rte_mbuf *mbuf) +{ +return RTE_MBUF_DYNFIELD (mbuf, + timestamp_dynfield_offset, rte_mbuf_timestamp_t *); +} +static const char *MZ_RTE_LATENCY_STATS ="rte_latencystats" ;static int latency_stats_index;static uint64_t samp_intvl;
@@ -128,10 +140,10 @@ add_time_stamps(uint16_t pid __rte_unused, diff_tsc = now - prev_tsc; timer_tsc += diff_tsc; -if ((pkts[i]->ol_flags &PKT_RX_TIMESTAMP ) ==0 +if ((pkts[i]->ol_flags & timestamp_dynflag) ==0 && (timer_tsc >= samp_intvl)) { - pkts[i]->timestamp = now; - pkts[i]->ol_flags |=PKT_RX_TIMESTAMP ; + *timestamp_dynfield (pkts[i]) = now; + pkts[i]->ol_flags |= timestamp_dynflag; timer_tsc =0 ; } prev_tsc = now;
@@ -161,8 +173,8 @@ calc_latency(uint16_t pid __rte_unused, now =rte_rdtsc ();for (i =0 ; i < nb_pkts; i++) { -if (pkts[i]->ol_flags &PKT_RX_TIMESTAMP ) - latency[cnt++] = now - pkts[i]->timestamp; +if (pkts[i]->ol_flags & timestamp_dynflag) + latency[cnt++] = now - *timestamp_dynfield (pkts[i]); }rte_spinlock_lock (&glob_stats->lock);
@@ -204,6 +216,14 @@ int rte_latencystats_init(uint64_t app_samp_intvl, rte_latency_stats_flow_type_fn user_cb) { +static const struct rte_mbuf_dynfield timestamp_dynfield_desc = { + .name =RTE_MBUF_DYNFIELD_TIMESTAMP_NAME , + .size =sizeof (rte_mbuf_timestamp_t), + .align = __alignof__(rte_mbuf_timestamp_t ), + }; +static const struct rte_mbuf_dynflag timestamp_dynflag_desc = { + .name =RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME , + };unsigned int i;uint16_t pid;uint16_t qid;
@@ -211,6 +231,7 @@ rte_latencystats_init(uint64_t app_samp_intvl,const char *ptr_strings[NUM_LATENCY_STATS ] = {0 };const struct rte_memzone *mz =NULL ;const unsigned int flags =0 ; +int timestamp_dynflag_offset;int ret;if (rte_memzone_lookup (MZ_RTE_LATENCY_STATS ))
@@ -241,6 +262,23 @@ rte_latencystats_init(uint64_t app_samp_intvl,return -1 ; } +/* Register mbuf field and flag for Rx timestamp */ + timestamp_dynfield_offset = +rte_mbuf_dynfield_register (×tamp_dynfield_desc); +if (timestamp_dynfield_offset <0 ) { +RTE_LOG (ERR ,LATENCY_STATS , +"Cannot register mbuf field for timestamp\n" ); +return -rte_errno; + } + timestamp_dynflag_offset = +rte_mbuf_dynflag_register (×tamp_dynflag_desc); +if (timestamp_dynflag_offset <0 ) { +RTE_LOG (ERR ,LATENCY_STATS , +"Cannot register mbuf flag for timestamp\n" ); +return -rte_errno; + } + timestamp_dynflag =RTE_BIT64 (timestamp_dynflag_offset); +/** Register Rx/Tx callbacks */ RTE_ETH_FOREACH_DEV (pid) {struct rte_eth_dev_info dev_info;
Signature · 1 line
2.28.0
PATCH v2 5/14 net/ark: switch timestamp to dynamic mbuf field
In reply to Thomas MonjalonThe mbuf timestamp is moved to a dynamic field
in order to allow removal of the deprecated static field. The related dynamic mbuf flag is set, although was missing previously.
The timestamp is set if configured for at least one device.
--- drivers/net/ark/ark_ethdev.c | 23 +++++++++++++++++++++++ drivers/net/ark/ark_ethdev_rx.c | 10 +++++++++- 2 files changed, 32 insertions(+), 1 deletion(-)
drivers/net/ark/ark_ethdev.c +23 -0
@@ -9,6 +9,7 @@#include <rte_bus_pci.h> #include <rte_ethdev_pci.h> #include <rte_kvargs.h> +#include <rte_bitops.h> #include "rte_pmd_ark.h" #include "ark_global.h"
@@ -79,6 +80,8 @@ static int eth_ark_set_mtu(struct rte_eth_dev *dev, uint16_t size);#define ARK_TX_MAX_QUEUE (4096 * 4)#define ARK_TX_MIN_QUEUE (256) +uint64_t ark_timestamp_rx_dynflag; +int ark_timestamp_dynfield_offset =-1 ;int rte_pmd_ark_rx_userdata_dynfield_offset =-1 ;int rte_pmd_ark_tx_userdata_dynfield_offset =-1 ;
@@ -552,6 +555,24 @@ static int eth_ark_dev_configure(struct rte_eth_dev *dev) {struct ark_adapter *ark = dev->data->dev_private; +int ark_timestamp_rx_dynflag_offset; + +if (dev->data->dev_conf.rxmode.offloads &DEV_RX_OFFLOAD_TIMESTAMP ) { + ark_timestamp_dynfield_offset =rte_mbuf_dynfield_lookup ( +RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ); +if (ark_timestamp_dynfield_offset <0 ) { +ARK_PMD_LOG (ERR ,"Failed to lookup timestamp field\n" ); +return -rte_errno; + } + ark_timestamp_rx_dynflag_offset =rte_mbuf_dynflag_lookup ( +RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME ,NULL ); +if (ark_timestamp_rx_dynflag_offset <0 ) { +ARK_PMD_LOG (ERR ,"Failed to lookup Rx timestamp flag\n" ); +return -rte_errno; + } + ark_timestamp_rx_dynflag = +RTE_BIT64 (ark_timestamp_rx_dynflag_offset); + }eth_ark_dev_set_link_up (dev);if (ark->user_ext.dev_configure)
@@ -782,6 +803,8 @@ eth_ark_dev_info_get(struct rte_eth_dev *dev,ETH_LINK_SPEED_50G | ETH_LINK_SPEED_100G); + dev_info->rx_offload_capa =DEV_RX_OFFLOAD_TIMESTAMP ; +return 0 ; }
drivers/net/ark/ark_ethdev_rx.c +9 -1
@@ -15,6 +15,9 @@#define ARK_RX_META_OFFSET (RTE_PKTMBUF_HEADROOM - ARK_RX_META_SIZE)#define ARK_RX_MAX_NOCHAIN (RTE_MBUF_DEFAULT_DATAROOM) +extern uint64_t ark_timestamp_rx_dynflag; +extern int ark_timestamp_dynfield_offset; +/* Forward declarations */ struct ark_rx_queue ;struct ark_rx_meta ;
@@ -272,7 +275,12 @@ eth_ark_recv_pkts(void *rx_queue, mbuf->port = meta->port; mbuf->pkt_len = meta->pkt_len; mbuf->data_len = meta->pkt_len; - mbuf->timestamp = meta->timestamp; +/* set timestamp if enabled at least on one device */ +if (ark_timestamp_rx_dynflag >0 ) { + *RTE_MBUF_DYNFIELD (mbuf, ark_timestamp_dynfield_offset, + rte_mbuf_timestamp_t *) = meta->timestamp; + mbuf->ol_flags |= ark_timestamp_rx_dynflag; + }rte_pmd_ark_mbuf_rx_userdata_set (mbuf, meta->user_data);if (ARK_DEBUG_CORE ) {/* debug sanity checks */
Signature · 1 line
2.28.0
Re: [dpdk-dev] [PATCH v2 05/14] net/ark: switch timestamp to dynamic mbuf field
Quoted 11 lines · Thomas Monjalon
The mbuf timestamp is moved to a dynamic field
in order to allow removal of the deprecated static field. The related dynamic mbuf flag is set, although was missing previously.The timestamp is set if configured for at least one device.
Signed-off-by Thomas Monjalon <[email protected]>--- drivers/net/ark/ark_ethdev.c | 23 +++++++++++++++++++++++ drivers/net/ark/ark_ethdev_rx.c | 10 +++++++++- 2 files changed, 32 insertions(+), 1 deletion(-)
<...>
drivers/net/ark/ark_ethdev_rx.c line 20
Quoted 9 lines
drivers/net/ark/ark_ethdev_rx.c +3
-0@@ -15,6 +15,9 @@#define ARK_RX_META_OFFSET (RTE_PKTMBUF_HEADROOM - ARK_RX_META_SIZE)#define ARK_RX_MAX_NOCHAIN (RTE_MBUF_DEFAULT_DATAROOM) +extern uint64_t ark_timestamp_rx_dynflag; +extern int ark_timestamp_dynfield_offset; +
Wouldn't it be better in a .h ?
Maybe ark_ethdev_rx.h
Quoted 20 lines
drivers/net/ark/ark_ethdev_rx.c +6
-1/* Forward declarations */ struct ark_rx_queue ;struct ark_rx_meta ;@@ -272,7 +275,12 @@ eth_ark_recv_pkts(void *rx_queue, mbuf->port = meta->port; mbuf->pkt_len = meta->pkt_len; mbuf->data_len = meta->pkt_len; - mbuf->timestamp = meta->timestamp; +/* set timestamp if enabled at least on one device */ +if (ark_timestamp_rx_dynflag >0 ) { + *RTE_MBUF_DYNFIELD (mbuf, ark_timestamp_dynfield_offset, + rte_mbuf_timestamp_t *) = meta->timestamp; + mbuf->ol_flags |= ark_timestamp_rx_dynflag; + }rte_pmd_ark_mbuf_rx_userdata_set (mbuf, meta->user_data);if (ARK_DEBUG_CORE ) {/* debug sanity checks */ Signature · 1 line
2.28.0
Re: [dpdk-dev] [PATCH v2 05/14] net/ark: switch timestamp to dynamic mbuf field
02/11/2020 16:32, Olivier Matz:
Quoted 7 lines · Thomas Monjalon
Quoted 6 lines
drivers/net/ark/ark_ethdev_rx.c +0
-0@@ -15,6 +15,9 @@#define ARK_RX_META_OFFSET (RTE_PKTMBUF_HEADROOM - ARK_RX_META_SIZE)#define ARK_RX_MAX_NOCHAIN (RTE_MBUF_DEFAULT_DATAROOM)
Quoted 6 lines
drivers/net/ark/ark_ethdev_rx.c line 20
Quoted 3 lines
drivers/net/ark/ark_ethdev_rx.c +3
-0+extern uint64_t ark_timestamp_rx_dynflag; +extern int ark_timestamp_dynfield_offset; +Wouldn't it be better in a .h ?
Maybeark_ethdev_rx.h
Yes it would allow type checking on compilation.
PATCH v2 6/14 net/dpaa2: switch timestamp to dynamic mbuf field
In reply to Thomas MonjalonThe mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced.
--- drivers/net/dpaa2/dpaa2_ethdev.c | 20 ++++++++++++++++++++ drivers/net/dpaa2/dpaa2_ethdev.h | 2 ++ drivers/net/dpaa2/dpaa2_rxtx.c | 25 ++++++++++++++++++------- 3 files changed, 40 insertions(+), 7 deletions(-)
drivers/net/dpaa2/dpaa2_ethdev.c +20 -0
@@ -8,6 +8,7 @@#include <time.h> #include <net/if.h> +#include <rte_bitops.h> #include <rte_mbuf.h> #include <rte_ethdev_driver.h> #include <rte_malloc.h>
@@ -65,6 +66,8 @@ static uint64_t dev_tx_offloads_nodis =/* enable timestamp in mbuf */ bool dpaa2_enable_ts[RTE_MAX_ETHPORTS ]; +uint64_t dpaa2_timestamp_rx_dynflag; +int dpaa2_timestamp_dynfield_offset =-1 ;struct rte_dpaa2_xstats_name_off {char name[RTE_ETH_XSTATS_NAME_SIZE ];
@@ -505,6 +508,7 @@ dpaa2_eth_dev_configure(struct rte_eth_dev *dev)struct rte_eth_conf *eth_conf = &dev->data->dev_conf;uint64_t rx_offloads = eth_conf->rxmode.offloads;uint64_t tx_offloads = eth_conf->txmode.offloads; +int timestamp_rx_dynflag_offset;int rx_l3_csum_offload = false;int rx_l4_csum_offload = false;int tx_l3_csum_offload = false;
@@ -587,7 +591,23 @@ dpaa2_eth_dev_configure(struct rte_eth_dev *dev)#if !defined(RTE_LIBRTE_IEEE1588 ) if (rx_offloads & DEV_RX_OFFLOAD_TIMESTAMP)#endif + { + dpaa2_timestamp_dynfield_offset =rte_mbuf_dynfield_lookup ( +RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ); +if (dpaa2_timestamp_dynfield_offset <0 ) { +DPAA2_PMD_ERR ("Error to lookup timestamp field" ); +return -rte_errno; + } + timestamp_rx_dynflag_offset =rte_mbuf_dynflag_lookup ( +RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME ,NULL ); +if (timestamp_rx_dynflag_offset <0 ) { +DPAA2_PMD_ERR ("Error to lookup Rx timestamp flag" ); +return -rte_errno; + } + dpaa2_timestamp_rx_dynflag = +RTE_BIT64 (timestamp_rx_dynflag_offset); dpaa2_enable_ts[dev->data->port_id] = true; + }if (tx_offloads &DEV_TX_OFFLOAD_IPV4_CKSUM ) tx_l3_csum_offload = true;
drivers/net/dpaa2/dpaa2_ethdev.h +2 -0
@@ -92,6 +92,8 @@/* enable timestamp in mbuf*/ extern bool dpaa2_enable_ts[]; +extern uint64_t dpaa2_timestamp_rx_dynflag; +extern int dpaa2_timestamp_dynfield_offset;#define DPAA2_QOS_TABLE_RECONFIGURE 1#define DPAA2_FS_TABLE_RECONFIGURE 2
drivers/net/dpaa2/dpaa2_rxtx.c +18 -7
@@ -31,6 +31,13 @@ dpaa2_dev_rx_parse_slow(struct rte_mbuf *mbuf, static void enable_tx_tstamp(struct qbman_fd *fd) __rte_unused; +static inline rte_mbuf_timestamp_t * +dpaa2_timestamp_dynfield (struct rte_mbuf *mbuf) +{ +return RTE_MBUF_DYNFIELD (mbuf, + dpaa2_timestamp_dynfield_offset, rte_mbuf_timestamp_t *); +} +#define DPAA2_MBUF_TO_CONTIG_FD (_mbuf, _fd, _bpid) do { \ DPAA2_SET_FD_ADDR(_fd, DPAA2_MBUF_VADDR_TO_IOVA(_mbuf)); \ DPAA2_SET_FD_LEN(_fd, _mbuf->data_len); \
@@ -109,9 +116,10 @@ dpaa2_dev_rx_parse_new(struct rte_mbuf *m, const struct qbman_fd *fd, m->ol_flags |=PKT_RX_RSS_HASH ;if (dpaa2_enable_ts[m->port]) { - m->timestamp = annotation->word2; - m->ol_flags |=PKT_RX_TIMESTAMP ; -DPAA2_PMD_DP_DEBUG ("pkt timestamp:0x%" PRIx64"" , m->timestamp); + *dpaa2_timestamp_dynfield (m) = annotation->word2; + m->ol_flags |= dpaa2_timestamp_rx_dynflag; +DPAA2_PMD_DP_DEBUG ("pkt timestamp:0x%" PRIx64"" , + *dpaa2_timestamp_dynfield (m)); } DPAA2_PMD_DP_DEBUG("HW frc = 0x%x\t packet type =0x%x "
@@ -223,9 +231,12 @@ dpaa2_dev_rx_parse(struct rte_mbuf *mbuf, void *hw_annot_addr)else if (BIT_ISSET_AT_POS (annotation->word8,DPAA2_ETH_FAS_L4CE )) mbuf->ol_flags |=PKT_RX_L4_CKSUM_BAD ; - mbuf->ol_flags |=PKT_RX_TIMESTAMP ; - mbuf->timestamp = annotation->word2; -DPAA2_PMD_DP_DEBUG ("pkt timestamp: 0x%" PRIx64"" , mbuf->timestamp); +if (dpaa2_enable_ts[mbuf->port]) { + *dpaa2_timestamp_dynfield (mbuf) = annotation->word2; + mbuf->ol_flags |= dpaa2_timestamp_rx_dynflag; +DPAA2_PMD_DP_DEBUG ("pkt timestamp: 0x%" PRIx64"" , + *dpaa2_timestamp_dynfield (mbuf)); + }/* Check detailed parsing requirement */ if (annotation->word3 &0x7FFFFC3FFFF )
@@ -629,7 +640,7 @@ dpaa2_dev_prefetch_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)else bufs[num_rx] =eth_fd_to_mbuf (fd, eth_data->port_id);#if defined(RTE_LIBRTE_IEEE1588 ) - priv->rx_timestamp = bufs[num_rx]->timestamp; + priv->rx_timestamp = *dpaa2_timestamp_dynfield (bufs[num_rx]);#endif if (eth_data->dev_conf.rxmode.offloads &
Signature · 1 line
2.28.0
PATCH v2 7/14 net/mlx5: fix dynamic mbuf offset lookup check
In reply to Thomas MonjalonThe functions rte_mbuf_dynfield_lookup() and rte_mbuf_dynflag_lookup() can return an offset starting with 0 or a negative error code.
In reality the first offsets are probably reserved forever, but for the sake of strict API compliance,
the checks which considered 0 as an error are fixed.
--- drivers/net/mlx5/mlx5_rxtx.c | 4 ++-- drivers/net/mlx5/mlx5_trigger.c | 2 +- drivers/net/mlx5/mlx5_txq.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/mlx5/mlx5_rxtx.c +2 -2
@@ -5661,9 +5661,9 @@ mlx5_select_tx_function(struct rte_eth_dev *dev) }if (tx_offloads &DEV_TX_OFFLOAD_SEND_ON_TIMESTAMP &&rte_mbuf_dynflag_lookup - (RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME ,NULL ) >0 && + (RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME ,NULL ) >=0 &&rte_mbuf_dynfield_lookup - (RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ) >0 ) { + (RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ) >=0 ) {/* Offload configured, dynamic entities registered. */ olx |=MLX5_TXOFF_CONFIG_TXPP ; }
drivers/net/mlx5/mlx5_trigger.c +1 -1
@@ -302,7 +302,7 @@ mlx5_dev_start(struct rte_eth_dev *dev)DRV_LOG (DEBUG ,"port %u starting device" , dev->data->port_id); fine_inline =rte_mbuf_dynflag_lookup (RTE_PMD_MLX5_FINE_GRANULARITY_INLINE ,NULL ); -if (fine_inline >0 ) +if (fine_inline >=0 ) rte_net_mlx5_dynf_inline_mask =1UL << fine_inline;else rte_net_mlx5_dynf_inline_mask =0 ;
drivers/net/mlx5/mlx5_txq.c +1 -1
@@ -1305,7 +1305,7 @@ mlx5_txq_dynf_timestamp_set(struct rte_eth_dev *dev) (RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME ,NULL ); off =rte_mbuf_dynfield_lookup (RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ); -if (nbit >0 && off >=0 && sh->txpp.refcnt) +if (nbit >=0 && off >=0 && sh->txpp.refcnt) mask =1ULL << nbit;for (i =0 ; i != priv->txqs_n; ++i) { data = (*priv->txqs)[i];
Signature · 1 line
2.28.0
PATCH v2 8/14 net/mlx5: switch timestamp to dynamic mbuf field
In reply to Thomas MonjalonThe mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced.
--- drivers/net/mlx5/mlx5_rxq.c | 36 ++++++++++++++++++++ drivers/net/mlx5/mlx5_rxtx.c | 4 +-- drivers/net/mlx5/mlx5_rxtx.h | 19 +++++++++++ drivers/net/mlx5/mlx5_rxtx_vec_altivec.h | 41 +++++++++++----------- drivers/net/mlx5/mlx5_rxtx_vec_neon.h | 43 ++++++++++++------------ drivers/net/mlx5/mlx5_rxtx_vec_sse.h | 35 +++++++++---------- 6 files changed, 118 insertions(+), 60 deletions(-)
drivers/net/mlx5/mlx5_rxq.c +36 -0
@@ -1310,6 +1310,39 @@ mlx5_max_lro_msg_size_adjust(struct rte_eth_dev *dev, uint16_t idx, priv->max_lro_msg_size * MLX5_LRO_SEG_CHUNK_SIZE); } +/** +* Lookup mbuf field and flag for Rx timestamp if offload requested. +* +* @param rxq_data +* Datapath struct where field offset and flag mask are stored. +* +* @return +* 0 on success or offload disabled, negative errno otherwise. +*/ +static int +mlx5_rx_timestamp_setup (struct mlx5_rxq_data *rxq_data) +{ +int timestamp_rx_dynflag_offset; + + rxq_data->timestamp_rx_flag =0 ; +if (rxq_data->hw_timestamp ==0 ) +return 0 ; + rxq_data->timestamp_offset =rte_mbuf_dynfield_lookup ( +RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ); +if (rxq_data->timestamp_offset <0 ) { +DRV_LOG (ERR ,"Cannot lookup timestamp field\n" ); +return -rte_errno; + } + timestamp_rx_dynflag_offset =rte_mbuf_dynflag_lookup ( +RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME ,NULL ); +if (timestamp_rx_dynflag_offset <0 ) { +DRV_LOG (ERR ,"Cannot lookup Rx timestamp flag\n" ); +return -rte_errno; + } + rxq_data->timestamp_rx_flag =RTE_BIT64 (timestamp_rx_dynflag_offset); +return 0 ; +} +/** * Create a DPDK Rx queue. *
@@ -1492,7 +1525,10 @@ mlx5_rxq_new(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,mlx5_max_lro_msg_size_adjust (dev, idx, max_lro_size);/* Toggle RX checksum offload if hardware supports it. */ tmpl->rxq.csum = !!(offloads &DEV_RX_OFFLOAD_CHECKSUM ); +/* Configure Rx timestamp. */ tmpl->rxq.hw_timestamp = !!(offloads &DEV_RX_OFFLOAD_TIMESTAMP ); +if (mlx5_rx_timestamp_setup (&tmpl->rxq) !=0 ) + goto error;/* Configure VLAN stripping. */ tmpl->rxq.vlan_strip = !!(offloads &DEV_RX_OFFLOAD_VLAN_STRIP );/* By default, FCS (CRC) is stripped by hardware. */
drivers/net/mlx5/mlx5_rxtx.c +2 -2
@@ -1287,8 +1287,8 @@ rxq_cq_to_mbuf(struct mlx5_rxq_data *rxq, struct rte_mbuf *pkt,if (rxq->rt_timestamp) ts =mlx5_txpp_convert_rx_ts (rxq->sh, ts); - pkt->timestamp = ts; - pkt->ol_flags |=PKT_RX_TIMESTAMP ; +mlx5_timestamp_set (pkt, rxq->timestamp_offset, ts); + pkt->ol_flags |= rxq->timestamp_rx_flag; } }
drivers/net/mlx5/mlx5_rxtx.h +19 -0
@@ -151,6 +151,8 @@ struct mlx5_rxq_data {/* CQ (UAR) access lock required for 32bit implementations */ #endif uint32_t tunnel;/* Tunnel information. */ +int timestamp_offset;/* Dynamic mbuf field for timestamp. */ +uint64_t timestamp_rx_flag;/* Dynamic mbuf flag for timestamp. */ uint64_t flow_meta_mask;int32_t flow_meta_offset; } __rte_cache_aligned;
@@ -681,4 +683,21 @@ mlx5_txpp_convert_tx_ts(struct mlx5_dev_ctx_shared *sh, uint64_t mts) return ci; } +/** +* Set timestamp in mbuf dynamic field. +* +* @param mbuf +* Structure to write into. +* @param offset +* Dynamic field offset in mbuf structure. +* @param timestamp +* Value to write. +*/ +static __rte_always_inline void +mlx5_timestamp_set (struct rte_mbuf *mbuf,int offset, +rte_mbuf_timestamp_t timestamp) +{ + *RTE_MBUF_DYNFIELD(mbuf, offset, rte_mbuf_timestamp_t *) = timestamp; +} +#endif /* RTE_PMD_MLX5_RXTX_H_ */
drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +21 -20
65 lines not on this page · raw message
drivers/net/mlx5/mlx5_rxtx_vec_neon.h +22 -21
71 lines not on this page · raw message
drivers/net/mlx5/mlx5_rxtx_vec_sse.h +18 -17
@@ -251,7 +251,7 @@ rxq_cq_to_ptype_oflags_v(struct mlx5_rxq_data *rxq, __m128i cqes[4],__m128i pinfo0, pinfo1;__m128i pinfo, ptype;__m128i ol_flags =_mm_set1_epi32 (rxq->rss_hash *PKT_RX_RSS_HASH | - rxq->hw_timestamp *PKT_RX_TIMESTAMP ); + rxq->hw_timestamp * rxq->timestamp_rx_flag);__m128i cv_flags;const __m128i zero =_mm_setzero_si128 (); const __m128i ptype_mask =
@@ -656,31 +656,32 @@ rxq_burst_v(struct mlx5_rxq_data *rxq, struct rte_mbuf **pkts, uint16_t pkts_n,/* D.5 fill in mbuf - rearm_data and packet_type. */ rxq_cq_to_ptype_oflags_v (rxq, cqes, opcode, &pkts[pos]);if (rxq->hw_timestamp) { +int offset = rxq->timestamp_offset;if (rxq->rt_timestamp) {struct mlx5_dev_ctx_shared *sh = rxq->sh;uint64_t ts; ts =rte_be_to_cpu_64 (cq[pos].timestamp); - pkts[pos]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (pkts[pos], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); ts =rte_be_to_cpu_64 (cq[pos + p1].timestamp); - pkts[pos +1 ]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (pkts[pos +1 ], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); ts =rte_be_to_cpu_64 (cq[pos + p2].timestamp); - pkts[pos +2 ]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (pkts[pos +2 ], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); ts =rte_be_to_cpu_64 (cq[pos + p3].timestamp); - pkts[pos +3 ]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (pkts[pos +3 ], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); }else { - pkts[pos]->timestamp =rte_be_to_cpu_64 - (cq[pos].timestamp); - pkts[pos +1 ]->timestamp =rte_be_to_cpu_64 - (cq[pos + p1].timestamp); - pkts[pos +2 ]->timestamp =rte_be_to_cpu_64 - (cq[pos + p2].timestamp); - pkts[pos +3 ]->timestamp =rte_be_to_cpu_64 - (cq[pos + p3].timestamp); +mlx5_timestamp_set (pkts[pos], offset, +rte_be_to_cpu_64 (cq[pos].timestamp)); +mlx5_timestamp_set (pkts[pos +1 ], offset, +rte_be_to_cpu_64 (cq[pos + p1].timestamp)); +mlx5_timestamp_set (pkts[pos +2 ], offset, +rte_be_to_cpu_64 (cq[pos + p2].timestamp)); +mlx5_timestamp_set (pkts[pos +3 ], offset, +rte_be_to_cpu_64 (cq[pos + p3].timestamp)); } }if (rxq->dynf_meta) {
Signature · 1 line
2.28.0
Re: [dpdk-dev] [PATCH v2 08/14] net/mlx5: switch timestamp to dynamic mbuf field
Quoted 396 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Monday, November 2, 2020 2:06 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Matan Azrad <[email protected]>; Shahaf Shuler <[email protected]>; David Christensen <[email protected]>; Ruifeng Wang <[email protected]>; Konstantin Ananyev <[email protected]>
Subject: [PATCH v2 08/14] net/mlx5: switch timestamp to dynamic mbuf fieldThe mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field.
The related mbuf flag is also replaced.Signed-off-by Thomas Monjalon <[email protected]>--- drivers/net/mlx5/mlx5_rxq.c | 36 ++++++++++++++++++++ drivers/net/mlx5/mlx5_rxtx.c | 4 +-- drivers/net/mlx5/mlx5_rxtx.h | 19 +++++++++++ drivers/net/mlx5/mlx5_rxtx_vec_altivec.h | 41 +++++++++++----------- drivers/net/mlx5/mlx5_rxtx_vec_neon.h | 43 ++++++++++++------------ drivers/net/mlx5/mlx5_rxtx_vec_sse.h | 35 +++++++++---------- 6 files changed, 118 insertions(+), 60 deletions(-)drivers/net/mlx5/mlx5_rxq.c +35
-0@@ -1310,6 +1310,39 @@ mlx5_max_lro_msg_size_adjust(struct rte_eth_dev *dev, uint16_t idx, priv->max_lro_msg_size * MLX5_LRO_SEG_CHUNK_SIZE); } +/** +* Lookup mbuf field and flag for Rx timestamp if offload requested. +* +* @param rxq_data +* Datapath struct where field offset and flag mask are stored. +* +* @return +* 0 on success or offload disabled, negative errno otherwise. +*/ +static int +mlx5_rx_timestamp_setup (struct mlx5_rxq_data *rxq_data) { +int timestamp_rx_dynflag_offset; + + rxq_data->timestamp_rx_flag =0 ; +if (rxq_data->hw_timestamp ==0 ) +return 0 ; + rxq_data->timestamp_offset =rte_mbuf_dynfield_lookup ( +RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ); +if (rxq_data->timestamp_offset <0 ) { +DRV_LOG (ERR ,"Cannot lookup timestamp field\n" ); +return -rte_errno; + } + timestamp_rx_dynflag_offset =rte_mbuf_dynflag_lookup ( +RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME ,NULL ); +if (timestamp_rx_dynflag_offset <0 ) { +DRV_LOG (ERR ,"Cannot lookup Rx timestamp flag\n" ); +return -rte_errno; + } + rxq_data->timestamp_rx_flag =RTE_BIT64 (timestamp_rx_dynflag_offset); +return 0 ; +} +/** * Create a DPDK Rx queue. * @@ -1492,7 +1525,10 @@ mlx5_rxq_new(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,mlx5_max_lro_msg_size_adjust (dev, idx, max_lro_size);/* Toggle RX checksum offload if hardware supports it. */ tmpl->rxq.csum = !!(offloads &DEV_RX_OFFLOAD_CHECKSUM ); +/* Configure Rx timestamp. */ tmpl->rxq.hw_timestamp = !!(offloads &DEV_RX_OFFLOAD_TIMESTAMP ); +if (mlx5_rx_timestamp_setup (&tmpl->rxq) !=0 ) + goto error;/* Configure VLAN stripping. */
tmpl->rxq.vlan_strip= !!(offloads &DEV_RX_OFFLOAD_VLAN_STRIP);
/* By default, FCS (CRC) is stripped by hardware. */ diff --gita/drivers/net/mlx5/mlx5_rxtx.cb/drivers/net/mlx5/mlx5_rxtx.cindexe86468b67a..b577aab00b100644drivers/net/mlx5/mlx5_rxtx.c +2
-2@@ -1287,8 +1287,8 @@ rxq_cq_to_mbuf(struct mlx5_rxq_data *rxq, struct rte_mbuf *pkt, if (rxq->rt_timestamp) ts = mlx5_txpp_convert_rx_ts(rxq->sh, ts); - pkt->timestamp = ts; - pkt->ol_flags |=PKT_RX_TIMESTAMP ; +mlx5_timestamp_set (pkt, rxq->timestamp_offset, ts); + pkt->ol_flags |= rxq->timestamp_rx_flag; } }drivers/net/mlx5/mlx5_rxtx.h +17
-0@@ -151,6 +151,8 @@ struct mlx5_rxq_data {/* CQ (UAR) access lock required for 32bit implementations */ #endif uint32_t tunnel;/* Tunnel information. */ +int timestamp_offset;/* Dynamic mbuf field for timestamp. */ +uint64_t timestamp_rx_flag;/* Dynamic mbuf flag for timestamp. */ uint64_t flow_meta_mask;int32_t flow_meta_offset; } __rte_cache_aligned;@@ -681,4 +683,21 @@ mlx5_txpp_convert_tx_ts(struct mlx5_dev_ctx_shared *sh, uint64_t mts) return ci; } +/** +* Set timestamp in mbuf dynamic field. +* +* @param mbuf +* Structure to write into. +* @param offset +* Dynamic field offset in mbuf structure. +* @param timestamp +* Value to write. +*/ +static __rte_always_inline void +mlx5_timestamp_set (struct rte_mbuf *mbuf,int offset, +rte_mbuf_timestamp_t timestamp) +{ + *RTE_MBUF_DYNFIELD(mbuf, offset, rte_mbuf_timestamp_t *) =timestamp;
drivers/net/mlx5/mlx5_rxtx.h +2
-0+} +#endif /* RTE_PMD_MLX5_RXTX_H_ */ drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +4
-4@@ -330,13 +330,13 @@ rxq_cq_to_ptype_oflags_v(struct mlx5_rxq_data *rxq, vector unsigned char ol_flags = (vector unsigned char) (vector unsigned int){ rxq->rss_hash *PKT_RX_RSS_HASH | - rxq->hw_timestamp *PKT_RX_TIMESTAMP , + rxq->hw_timestamp * rxq- >timestamp_rx_flag, rxq->rss_hash *PKT_RX_RSS_HASH | - rxq->hw_timestamp *PKT_RX_TIMESTAMP , + rxq->hw_timestamp * rxq- >timestamp_rx_flag, rxq->rss_hash *PKT_RX_RSS_HASH | - rxq->hw_timestamp *PKT_RX_TIMESTAMP , + rxq->hw_timestamp * rxq- >timestamp_rx_flag, rxq->rss_hash *PKT_RX_RSS_HASH | - rxq->hw_timestamp *PKT_RX_TIMESTAMP }; + rxq->hw_timestamp * rxq-Quoted 1 line
timestamp_rx_flag};drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +0
-0vector unsigned char cv_flags; const vector unsigned char zero = (vector unsigned char){0}; const vector unsigned char ptype_mask = @@ -1025,31 +1025,32 @@rxq_burst_v(struct
mlx5_rxq_data*rxq, structrte_mbuf**pkts,uint16_tpkts_n,drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +3
-2/* D.5 fill in mbuf - rearm_data and packet_type. */ rxq_cq_to_ptype_oflags_v (rxq, cqes, opcode, &pkts[pos]);if (rxq->hw_timestamp) { +int offset = rxq->timestamp_offset;if (rxq->rt_timestamp) {struct mlx5_dev_ctx_shared *sh = rxq->sh;uint64_t ts; ts =rte_be_to_cpu_64 (cq[pos].timestamp); - pkts[pos]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (pkts[pos], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); ts = rte_be_to_cpu_64(cq[pos +p1].timestamp);
drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +2
-2- pkts[pos +1 ]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (pkts[pos +1 ], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); ts = rte_be_to_cpu_64(cq[pos +p2].timestamp);
drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +2
-2- pkts[pos +2 ]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (pkts[pos +2 ], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); ts = rte_be_to_cpu_64(cq[pos +p3].timestamp);
drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +2
-5- pkts[pos +3 ]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (pkts[pos +3 ], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); }else { - pkts[pos]->timestamp =rte_be_to_cpu_64 - (cq[pos].timestamp); - pkts[pos + 1]->timestamp =
rte_be_to_cpu_64drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +0
-2- (cq[pos + p1].timestamp); - pkts[pos + 2]->timestamp =
rte_be_to_cpu_64drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +0
-2- (cq[pos + p2].timestamp); - pkts[pos + 3]->timestamp =
rte_be_to_cpu_64drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +2
-1- (cq[pos + p3].timestamp); + mlx5_timestamp_set(pkts[pos], offset, +rte_be_to_cpu_64(cq[pos].timestamp));drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +2
-0+ mlx5_timestamp_set(pkts[pos + 1], offset, + rte_be_to_cpu_64(cq[pos +p1].timestamp));
drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +2
-0+ mlx5_timestamp_set(pkts[pos + 2], offset, + rte_be_to_cpu_64(cq[pos +p2].timestamp));
drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +2
-0+ mlx5_timestamp_set(pkts[pos + 3], offset, + rte_be_to_cpu_64(cq[pos +p3].timestamp));
drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +0
-0} }if (rxq->dynf_meta) {drivers/net/mlx5/mlx5_rxtx_vec_neon.h +1
-1@@ -271,7 +271,7 @@ rxq_cq_to_ptype_oflags_v(struct mlx5_rxq_data *rxq, uint32x4_t pinfo, cv_flags;uint32x4_t ol_flags =vdupq_n_u32 (rxq->rss_hash *PKT_RX_RSS_HASH | - rxq->hw_timestamp *PKT_RX_TIMESTAMP ); + rxq->hw_timestamp * rxq->timestamp_rx_flag);const uint32x4_t ptype_ol_mask = {0x106 ,0x106 ,0x106 ,0x106 };const uint8x16_t cv_flag_sel = {drivers/net/mlx5/mlx5_rxtx_vec_neon.h +1
-00,@@ -697,6 +697,7 @@ rxq_burst_v(struct mlx5_rxq_data *rxq, struct rte_mbuf **pkts, uint16_t pkts_n,rxq_cq_to_ptype_oflags_v (rxq ,ptype_info ,flow_tag , opcode, &elts[pos]);if (rxq->hw_timestamp) { +int offset = rxq->timestamp_offset;if (rxq->rt_timestamp) {struct mlx5_dev_ctx_shared *sh = rxq->sh;drivers/net/mlx5/mlx5_rxtx_vec_neon.h +8
-12uint64_t ts;@@ -704,36 +705,36 @@ rxq_burst_v(struct mlx5_rxq_data *rxq, struct rte_mbuf **pkts, uint16_t pkts_n, ts =rte_be_to_cpu_64 (container_of(p0, struct mlx5_cqe, pkt_info)->timestamp); - elts[pos]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (elts[pos], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); ts =rte_be_to_cpu_64 (container_of(p1, struct mlx5_cqe, pkt_info)->timestamp); - elts[pos +1 ]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (elts[pos +1 ], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); ts =rte_be_to_cpu_64 (container_of(p2, struct mlx5_cqe, pkt_info)->timestamp); - elts[pos +2 ]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (elts[pos +2 ], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); ts =rte_be_to_cpu_64 (container_of(p3, struct mlx5_cqe, pkt_info)->timestamp); - elts[pos +3 ]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (elts[pos +3 ], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); }else { - elts[pos]->timestamp =rte_be_to_cpu_64 - (container_of(p0, struct mlx5_cqe, - pkt_info)->timestamp); - elts[pos + 1]->timestamp =
rte_be_to_cpu_64drivers/net/mlx5/mlx5_rxtx_vec_neon.h +0
-3- (container_of(p1, struct mlx5_cqe, - pkt_info)->timestamp); - elts[pos + 2]->timestamp =
rte_be_to_cpu_64drivers/net/mlx5/mlx5_rxtx_vec_neon.h +0
-3- (container_of(p2, struct mlx5_cqe, - pkt_info)->timestamp); - elts[pos + 3]->timestamp =
rte_be_to_cpu_64drivers/net/mlx5/mlx5_rxtx_vec_neon.h +3
-2- (container_of(p3, struct mlx5_cqe, - pkt_info)->timestamp); + mlx5_timestamp_set(elts[pos], offset, + rte_be_to_cpu_64(container_of(p0, + struct mlx5_cqe, pkt_info)-Quoted 1 line
timestamp));
drivers/net/mlx5/mlx5_rxtx_vec_neon.h +3
-0+ mlx5_timestamp_set(elts[pos + 1], offset, + rte_be_to_cpu_64(container_of(p1, + struct mlx5_cqe, pkt_info)-Quoted 1 line
timestamp));
drivers/net/mlx5/mlx5_rxtx_vec_neon.h +3
-0+ mlx5_timestamp_set(elts[pos + 2], offset, + rte_be_to_cpu_64(container_of(p2, + struct mlx5_cqe, pkt_info)-Quoted 1 line
timestamp));
drivers/net/mlx5/mlx5_rxtx_vec_neon.h +3
-0+ mlx5_timestamp_set(elts[pos + 3], offset, + rte_be_to_cpu_64(container_of(p3, + struct mlx5_cqe, pkt_info)-Quoted 1 line
timestamp));
drivers/net/mlx5/mlx5_rxtx_vec_neon.h +0
-0} }if (rxq->dynf_meta) {drivers/net/mlx5/mlx5_rxtx_vec_sse.h +0
-0@@ -251,7 +251,7 @@ rxq_cq_to_ptype_oflags_v(struct mlx5_rxq_data *rxq, __m128i cqes[4], __m128i pinfo0, pinfo1;__m128i pinfo, ptype; __m128i ol_flags = _mm_set1_epi32(rxq->rss_hash *
PKT_RX_RSS_HASH|drivers/net/mlx5/mlx5_rxtx_vec_sse.h +0
-1- rxq->hw_timestamp *
PKT_RX_TIMESTAMP);drivers/net/mlx5/mlx5_rxtx_vec_sse.h +1
-0+ rxq->hw_timestamp * rxq-Quoted 1 line
timestamp_rx_flag);drivers/net/mlx5/mlx5_rxtx_vec_sse.h +9
-11__m128i cv_flags;const __m128i zero =_mm_setzero_si128 (); const __m128i ptype_mask =@@ -656,31 +656,32 @@ rxq_burst_v(struct mlx5_rxq_data *rxq, struct rte_mbuf **pkts, uint16_t pkts_n,/* D.5 fill in mbuf - rearm_data and packet_type. */ rxq_cq_to_ptype_oflags_v(rxq, cqes, opcode, &pkts[pos]);if (rxq->hw_timestamp) { +int offset = rxq->timestamp_offset;if (rxq->rt_timestamp) {struct mlx5_dev_ctx_shared *sh = rxq->sh;uint64_t ts; ts =rte_be_to_cpu_64 (cq[pos].timestamp); - pkts[pos]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (pkts[pos], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); ts =rte_be_to_cpu_64 (cq[pos + p1].timestamp); - pkts[pos +1 ]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (pkts[pos +1 ], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); ts =rte_be_to_cpu_64 (cq[pos + p2].timestamp); - pkts[pos +2 ]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (pkts[pos +2 ], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); ts =rte_be_to_cpu_64 (cq[pos + p3].timestamp); - pkts[pos +3 ]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (pkts[pos +3 ], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); }else { - pkts[pos]->timestamp =rte_be_to_cpu_64 - (cq[pos].timestamp); - pkts[pos + 1]->timestamp =
rte_be_to_cpu_64drivers/net/mlx5/mlx5_rxtx_vec_sse.h +0
-2- (cq[pos + p1].timestamp); - pkts[pos + 2]->timestamp =
rte_be_to_cpu_64drivers/net/mlx5/mlx5_rxtx_vec_sse.h +0
-2- (cq[pos + p2].timestamp); - pkts[pos + 3]->timestamp =
rte_be_to_cpu_64drivers/net/mlx5/mlx5_rxtx_vec_sse.h +2
-1- (cq[pos + p3].timestamp); + mlx5_timestamp_set(pkts[pos], offset, +rte_be_to_cpu_64(cq[pos].timestamp));drivers/net/mlx5/mlx5_rxtx_vec_sse.h +2
-0+ mlx5_timestamp_set(pkts[pos + 1], offset, + rte_be_to_cpu_64(cq[pos +p1].timestamp));
drivers/net/mlx5/mlx5_rxtx_vec_sse.h +2
-0+ mlx5_timestamp_set(pkts[pos + 2], offset, + rte_be_to_cpu_64(cq[pos +p2].timestamp));
drivers/net/mlx5/mlx5_rxtx_vec_sse.h +2
-0+ mlx5_timestamp_set(pkts[pos + 3], offset, + rte_be_to_cpu_64(cq[pos +p3].timestamp));
drivers/net/mlx5/mlx5_rxtx_vec_sse.h +0
-1} }if (rxq->dynf_meta) { --
Quoted 1 line
2.28.0
Re: [dpdk-dev] [PATCH v2 08/14] net/mlx5: switch timestamp to dynamic mbuf field
In reply to Thomas MonjalonQuoted 180 lines · Thomas Monjalon
The mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced.
Signed-off-by Thomas Monjalon <[email protected]>--- drivers/net/mlx5/mlx5_rxq.c | 36 ++++++++++++++++++++ drivers/net/mlx5/mlx5_rxtx.c | 4 +-- drivers/net/mlx5/mlx5_rxtx.h | 19 +++++++++++ drivers/net/mlx5/mlx5_rxtx_vec_altivec.h | 41 +++++++++++----------- drivers/net/mlx5/mlx5_rxtx_vec_neon.h | 43 ++++++++++++------------ drivers/net/mlx5/mlx5_rxtx_vec_sse.h | 35 +++++++++---------- 6 files changed, 118 insertions(+), 60 deletions(-)drivers/net/mlx5/mlx5_rxq.c +36
-0@@ -1310,6 +1310,39 @@ mlx5_max_lro_msg_size_adjust(struct rte_eth_dev *dev, uint16_t idx, priv->max_lro_msg_size * MLX5_LRO_SEG_CHUNK_SIZE); } +/** +* Lookup mbuf field and flag for Rx timestamp if offload requested. +* +* @param rxq_data +* Datapath struct where field offset and flag mask are stored. +* +* @return +* 0 on success or offload disabled, negative errno otherwise. +*/ +static int +mlx5_rx_timestamp_setup (struct mlx5_rxq_data *rxq_data) +{ +int timestamp_rx_dynflag_offset; + + rxq_data->timestamp_rx_flag =0 ; +if (rxq_data->hw_timestamp ==0 ) +return 0 ; + rxq_data->timestamp_offset =rte_mbuf_dynfield_lookup ( +RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ); +if (rxq_data->timestamp_offset <0 ) { +DRV_LOG (ERR ,"Cannot lookup timestamp field\n" ); +return -rte_errno; + } + timestamp_rx_dynflag_offset =rte_mbuf_dynflag_lookup ( +RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME ,NULL ); +if (timestamp_rx_dynflag_offset <0 ) { +DRV_LOG (ERR ,"Cannot lookup Rx timestamp flag\n" ); +return -rte_errno; + } + rxq_data->timestamp_rx_flag =RTE_BIT64 (timestamp_rx_dynflag_offset); +return 0 ; +} +/** * Create a DPDK Rx queue. * @@ -1492,7 +1525,10 @@ mlx5_rxq_new(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,mlx5_max_lro_msg_size_adjust (dev, idx, max_lro_size);/* Toggle RX checksum offload if hardware supports it. */ tmpl->rxq.csum = !!(offloads &DEV_RX_OFFLOAD_CHECKSUM ); +/* Configure Rx timestamp. */ tmpl->rxq.hw_timestamp = !!(offloads &DEV_RX_OFFLOAD_TIMESTAMP ); +if (mlx5_rx_timestamp_setup (&tmpl->rxq) !=0 ) + goto error;/* Configure VLAN stripping. */ tmpl->rxq.vlan_strip = !!(offloads &DEV_RX_OFFLOAD_VLAN_STRIP );/* By default, FCS (CRC) is stripped by hardware. */ drivers/net/mlx5/mlx5_rxtx.c +2
-2@@ -1287,8 +1287,8 @@ rxq_cq_to_mbuf(struct mlx5_rxq_data *rxq, struct rte_mbuf *pkt,if (rxq->rt_timestamp) ts =mlx5_txpp_convert_rx_ts (rxq->sh, ts); - pkt->timestamp = ts; - pkt->ol_flags |=PKT_RX_TIMESTAMP ; +mlx5_timestamp_set (pkt, rxq->timestamp_offset, ts); + pkt->ol_flags |= rxq->timestamp_rx_flag; } }drivers/net/mlx5/mlx5_rxtx.h +19
-0@@ -151,6 +151,8 @@ struct mlx5_rxq_data {/* CQ (UAR) access lock required for 32bit implementations */ #endif uint32_t tunnel;/* Tunnel information. */ +int timestamp_offset;/* Dynamic mbuf field for timestamp. */ +uint64_t timestamp_rx_flag;/* Dynamic mbuf flag for timestamp. */ uint64_t flow_meta_mask;int32_t flow_meta_offset; } __rte_cache_aligned;@@ -681,4 +683,21 @@ mlx5_txpp_convert_tx_ts(struct mlx5_dev_ctx_shared *sh, uint64_t mts) return ci; } +/** +* Set timestamp in mbuf dynamic field. +* +* @param mbuf +* Structure to write into. +* @param offset +* Dynamic field offset in mbuf structure. +* @param timestamp +* Value to write. +*/ +static __rte_always_inline void +mlx5_timestamp_set (struct rte_mbuf *mbuf,int offset, +rte_mbuf_timestamp_t timestamp) +{ + *RTE_MBUF_DYNFIELD(mbuf, offset, rte_mbuf_timestamp_t *) = timestamp; +} +#endif /* RTE_PMD_MLX5_RXTX_H_ */ drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +14
-20@@ -330,13 +330,13 @@ rxq_cq_to_ptype_oflags_v(struct mlx5_rxq_data *rxq, vector unsigned char ol_flags = (vector unsigned char) (vector unsigned int){ rxq->rss_hash *PKT_RX_RSS_HASH | - rxq->hw_timestamp *PKT_RX_TIMESTAMP , + rxq->hw_timestamp * rxq->timestamp_rx_flag, rxq->rss_hash *PKT_RX_RSS_HASH | - rxq->hw_timestamp *PKT_RX_TIMESTAMP , + rxq->hw_timestamp * rxq->timestamp_rx_flag, rxq->rss_hash *PKT_RX_RSS_HASH | - rxq->hw_timestamp *PKT_RX_TIMESTAMP , + rxq->hw_timestamp * rxq->timestamp_rx_flag, rxq->rss_hash *PKT_RX_RSS_HASH | - rxq->hw_timestamp *PKT_RX_TIMESTAMP }; + rxq->hw_timestamp * rxq->timestamp_rx_flag}; vector unsigned char cv_flags; const vector unsigned char zero = (vector unsigned char){0}; const vector unsigned char ptype_mask =@@ -1025,31 +1025,32 @@ rxq_burst_v(struct mlx5_rxq_data *rxq, struct rte_mbuf **pkts, uint16_t pkts_n,/* D.5 fill in mbuf - rearm_data and packet_type. */ rxq_cq_to_ptype_oflags_v (rxq, cqes, opcode, &pkts[pos]);if (rxq->hw_timestamp) { +int offset = rxq->timestamp_offset;if (rxq->rt_timestamp) {struct mlx5_dev_ctx_shared *sh = rxq->sh;uint64_t ts; ts =rte_be_to_cpu_64 (cq[pos].timestamp); - pkts[pos]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (pkts[pos], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); ts =rte_be_to_cpu_64 (cq[pos + p1].timestamp); - pkts[pos +1 ]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (pkts[pos +1 ], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); ts =rte_be_to_cpu_64 (cq[pos + p2].timestamp); - pkts[pos +2 ]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (pkts[pos +2 ], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); ts =rte_be_to_cpu_64 (cq[pos + p3].timestamp); - pkts[pos +3 ]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (pkts[pos +3 ], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); }else { - pkts[pos]->timestamp =rte_be_to_cpu_64 - (cq[pos].timestamp); - pkts[pos +1 ]->timestamp =rte_be_to_cpu_64 - (cq[pos + p1].timestamp); - pkts[pos +2 ]->timestamp =rte_be_to_cpu_64 - (cq[pos + p2].timestamp); - pkts[pos +3 ]->timestamp =rte_be_to_cpu_64 - (cq[pos + p3].timestamp); + mlx5_timestamp_set(pkts[pos], offset,
drivers/net/mlx5/mlx5_rxtx_vec_altivec.h rxq_burst_v(struct mlx5_rxq_data *rxq, struct rte_mbuf **pkts, uint16_t pkts_n, · line 1056
Quoted 10 lines
drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +7
-0+ rte_be_to_cpu_64(cq[pos].timestamp)); +mlx5_timestamp_set (pkts[pos +1 ], offset, +rte_be_to_cpu_64 (cq[pos + p1].timestamp)); +mlx5_timestamp_set (pkts[pos +2 ], offset, +rte_be_to_cpu_64 (cq[pos + p2].timestamp)); +mlx5_timestamp_set (pkts[pos +3 ], offset, +rte_be_to_cpu_64 (cq[pos + p3].timestamp)); } }if (rxq->dynf_meta) {
PATCH v2 9/14 net/nfb: switch timestamp to dynamic mbuf field
In reply to Thomas MonjalonThe mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced.
--- drivers/net/nfb/nfb_rx.c | 23 ++++++++++++++++++++++- drivers/net/nfb/nfb_rx.h | 18 ++++++++++++++---- 2 files changed, 36 insertions(+), 5 deletions(-)
drivers/net/nfb/nfb_rx.c +22 -1
@@ -5,10 +5,14 @@*/ #include <rte_kvargs.h> +#include <rte_bitops.h> #include "nfb_rx.h" #include "nfb.h" +uint64_t nfb_timestamp_rx_dynflag; +int nfb_timestamp_dynfield_offset =-1 ; +static int timestamp_check_handler(__rte_unused const char *key, const char *value, __rte_unused void *opaque)
@@ -23,6 +27,7 @@ timestamp_check_handler(__rte_unused const char *key,static int nfb_check_timestamp (struct rte_devargs *devargs) { +int timestamp_rx_dynflag_offset;struct rte_kvargs *kvlist;if (devargs ==NULL )
@@ -38,6 +43,7 @@ nfb_check_timestamp(struct rte_devargs *devargs) }/* Timestamps are enabled when there is * key-value pair: enable_timestamp=1 +* TODO: timestamp should be enabled with DEV_RX_OFFLOAD_TIMESTAMP */ if (rte_kvargs_process (kvlist,TIMESTAMP_ARG , timestamp_check_handler,NULL ) <0 ) {
@@ -46,6 +52,21 @@ nfb_check_timestamp(struct rte_devargs *devargs) }rte_kvargs_free (kvlist); + nfb_timestamp_dynfield_offset =rte_mbuf_dynfield_lookup ( +RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ); +if (nfb_timestamp_dynfield_offset <0 ) { +RTE_LOG (ERR ,PMD ,"Cannot lookup timestamp field\n" ); +return -rte_errno; + } + timestamp_rx_dynflag_offset =rte_mbuf_dynflag_lookup ( +RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME ,NULL ); +if (timestamp_rx_dynflag_offset <0 ) { +RTE_LOG (ERR ,PMD ,"Cannot lookup Rx timestamp flag\n" ); +return -rte_errno; + } + nfb_timestamp_rx_dynflag = +RTE_BIT64 (timestamp_rx_dynflag_offset); +return 1 ; }
@@ -125,7 +146,7 @@ nfb_eth_rx_queue_setup(struct rte_eth_dev *dev,else rte_free (rxq); -if (nfb_check_timestamp (dev->device->devargs)) +if (nfb_check_timestamp (dev->device->devargs) >0 ) rxq->flags |=NFB_TIMESTAMP_FLAG ;return ret;
drivers/net/nfb/nfb_rx.h +14 -4
@@ -15,6 +15,16 @@#define NFB_TIMESTAMP_FLAG (1 << 0) +extern uint64_t nfb_timestamp_rx_dynflag; +extern int nfb_timestamp_dynfield_offset; + +static inline rte_mbuf_timestamp_t * +nfb_timestamp_dynfield (struct rte_mbuf *mbuf) +{ +return RTE_MBUF_DYNFIELD (mbuf, + nfb_timestamp_dynfield_offset, rte_mbuf_timestamp_t *); +} +struct ndp_rx_queue {struct nfb_device *nfb;/* nfb dev structure */ struct ndp_queue *queue;/* rx queue */
@@ -191,15 +201,15 @@ nfb_eth_ndp_rx(void *queue,if (timestamping_enabled) {/* nanoseconds */ - mbuf->timestamp = + *nfb_timestamp_dynfield (mbuf) =rte_le_to_cpu_32 (*((uint32_t *) (packets[i].header +4 ))); - mbuf->timestamp <<=32 ; + *nfb_timestamp_dynfield (mbuf) <<=32 ;/* seconds */ - mbuf->timestamp |= + *nfb_timestamp_dynfield (mbuf) |=rte_le_to_cpu_32 (*((uint32_t *) (packets[i].header +8 ))); - mbuf->ol_flags |=PKT_RX_TIMESTAMP ; + mbuf->ol_flags |= nfb_timestamp_rx_dynflag; } bufs[num_rx++] = mbuf;
Signature · 1 line
2.28.0
PATCH v2 10/14 net/octeontx2: switch timestamp to dynamic mbuf field
In reply to Thomas MonjalonThe mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced.
--- drivers/net/octeontx2/otx2_ethdev.c | 33 +++++++++++++++++++++++++++++ drivers/net/octeontx2/otx2_rx.h | 19 ++++++++++++++--- drivers/net/octeontx2/version.map | 7 ++++++ 3 files changed, 56 insertions(+), 3 deletions(-)
drivers/net/octeontx2/otx2_ethdev.c +33 -0
@@ -4,6 +4,7 @@#include <inttypes.h> +#include <rte_bitops.h> #include <rte_ethdev_pci.h> #include <rte_io.h> #include <rte_malloc.h>
@@ -14,6 +15,35 @@#include "otx2_ethdev.h" #include "otx2_ethdev_sec.h" +uint64_t rte_pmd_octeontx2_timestamp_rx_dynflag; +int rte_pmd_octeontx2_timestamp_dynfield_offset =-1 ; + +static int +otx2_rx_timestamp_setup (uint16_t flags) +{ +int timestamp_rx_dynflag_offset; + +if ((flags &NIX_RX_OFFLOAD_TSTAMP_F ) ==0 ) +return 0 ; + + rte_pmd_octeontx2_timestamp_dynfield_offset =rte_mbuf_dynfield_lookup ( +RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ); +if (rte_pmd_octeontx2_timestamp_dynfield_offset <0 ) { +otx2_err ("Failed to lookup timestamp field" ); +return -rte_errno; + } + timestamp_rx_dynflag_offset =rte_mbuf_dynflag_lookup ( +RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME ,NULL ); +if (timestamp_rx_dynflag_offset <0 ) { +otx2_err ("Failed to lookup Rx timestamp flag" ); +return -rte_errno; + } + rte_pmd_octeontx2_timestamp_rx_dynflag = +RTE_BIT64 (timestamp_rx_dynflag_offset); + +return 0 ; +} +static inline uint64_t nix_get_rx_offload_capa (struct otx2_eth_dev *dev) {
@@ -1874,6 +1904,9 @@ otx2_nix_configure(struct rte_eth_dev *eth_dev) dev->tx_offload_flags |=nix_tx_offload_flags (eth_dev); dev->rss_info.rss_grps =NIX_RSS_GRPS ; +if (otx2_rx_timestamp_setup (dev->rx_offload_flags) !=0 ) + goto fail_offloads; + nb_rxq =RTE_MAX (data->nb_rx_queues,1 ); nb_txq =RTE_MAX (data->nb_tx_queues,1 );
drivers/net/octeontx2/otx2_rx.h +16 -3
@@ -63,6 +63,18 @@ union mbuf_initializer {uint64_t value; }; +/* variables are exported because this file is included in other drivers */ +extern uint64_t rte_pmd_octeontx2_timestamp_rx_dynflag; +extern int rte_pmd_octeontx2_timestamp_dynfield_offset; + +static inline rte_mbuf_timestamp_t * +otx2_timestamp_dynfield (struct rte_mbuf *mbuf) +{ +return RTE_MBUF_DYNFIELD (mbuf, + rte_pmd_octeontx2_timestamp_dynfield_offset, + rte_mbuf_timestamp_t *); +} + static __rte_always_inline void otx2_nix_mbuf_to_tstamp(struct rte_mbuf *mbuf, struct otx2_timesync_info *tstamp, const uint16_t flag,
@@ -77,15 +89,16 @@ otx2_nix_mbuf_to_tstamp(struct rte_mbuf *mbuf,/* Reading the rx timestamp inserted by CGX, viz at * starting of the packet data. */ - mbuf->timestamp =rte_be_to_cpu_64 (*tstamp_ptr); + *otx2_timestamp_dynfield (mbuf) =rte_be_to_cpu_64 (*tstamp_ptr);/* PKT_RX_IEEE1588_TMST flag needs to be set only in case * PTP packets are received. */ if (mbuf->packet_type ==RTE_PTYPE_L2_ETHER_TIMESYNC ) { - tstamp->rx_tstamp = mbuf->timestamp; + tstamp->rx_tstamp = *otx2_timestamp_dynfield (mbuf); tstamp->rx_ready =1 ; mbuf->ol_flags |=PKT_RX_IEEE1588_PTP | -PKT_RX_IEEE1588_TMST |PKT_RX_TIMESTAMP ; +PKT_RX_IEEE1588_TMST | + rte_pmd_octeontx2_timestamp_rx_dynflag; } } }
drivers/net/octeontx2/version.map +7 -0
@@ -1,3 +1,10 @@ DPDK_21 { local: *; }; + +INTERNAL { + global: + + rte_pmd_octeontx2_timestamp_dynfield_offset; + rte_pmd_octeontx2_timestamp_rx_dynflag; +};
Signature · 1 line
2.28.0
Re: [dpdk-dev] [PATCH v2 10/14] net/octeontx2: switch timestamp to dynamic mbuf field
Quoted 25 lines · Thomas Monjalon
The mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced.
Signed-off-by Thomas Monjalon <[email protected]>--- drivers/net/octeontx2/otx2_ethdev.c | 33 +++++++++++++++++++++++++++++ drivers/net/octeontx2/otx2_rx.h | 19 ++++++++++++++--- drivers/net/octeontx2/version.map | 7 ++++++ 3 files changed, 56 insertions(+), 3 deletions(-)drivers/net/octeontx2/otx2_ethdev.c +1
-0@@ -4,6 +4,7 @@#include <inttypes.h> +#include <rte_bitops.h> #include <rte_ethdev_pci.h> #include <rte_io.h> #include <rte_malloc.h>
drivers/net/octeontx2/otx2_ethdev.c line 19
Quoted 5 lines
drivers/net/octeontx2/otx2_ethdev.c +2
-0@@ -14,6 +15,35 @@#include "otx2_ethdev.h" #include "otx2_ethdev_sec.h" +uint64_t rte_pmd_octeontx2_timestamp_rx_dynflag; +int rte_pmd_octeontx2_timestamp_dynfield_offset =-1 ;
Instead of the global variable, please move the offset to struct otx2_timesync_info(which is used in fastpath) and accessible in slow path.
Quoted 45 lines
drivers/net/octeontx2/otx2_ethdev.c +30
-0+ +static int +otx2_rx_timestamp_setup (uint16_t flags) +{ +int timestamp_rx_dynflag_offset; + +if ((flags &NIX_RX_OFFLOAD_TSTAMP_F ) ==0 ) +return 0 ; + + rte_pmd_octeontx2_timestamp_dynfield_offset =rte_mbuf_dynfield_lookup ( +RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ); +if (rte_pmd_octeontx2_timestamp_dynfield_offset <0 ) { +otx2_err ("Failed to lookup timestamp field" ); +return -rte_errno; + } + timestamp_rx_dynflag_offset =rte_mbuf_dynflag_lookup ( +RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME ,NULL ); +if (timestamp_rx_dynflag_offset <0 ) { +otx2_err ("Failed to lookup Rx timestamp flag" ); +return -rte_errno; + } + rte_pmd_octeontx2_timestamp_rx_dynflag = +RTE_BIT64 (timestamp_rx_dynflag_offset); + +return 0 ; +} +static inline uint64_t nix_get_rx_offload_capa (struct otx2_eth_dev *dev) {@@ -1874,6 +1904,9 @@ otx2_nix_configure(struct rte_eth_dev *eth_dev) dev->tx_offload_flags |=nix_tx_offload_flags (eth_dev); dev->rss_info.rss_grps =NIX_RSS_GRPS ; +if (otx2_rx_timestamp_setup (dev->rx_offload_flags) !=0 ) + goto fail_offloads; + nb_rxq =RTE_MAX (data->nb_rx_queues,1 ); nb_txq =RTE_MAX (data->nb_tx_queues,1 );drivers/net/octeontx2/otx2_rx.h +0
-0
drivers/net/octeontx2/otx2_rx.h union mbuf_initializer { · line 71
Quoted 9 lines
drivers/net/octeontx2/otx2_rx.h +6
-0@@ -63,6 +63,18 @@ union mbuf_initializer {uint64_t value; }; +/* variables are exported because this file is included in other drivers */ +extern uint64_t rte_pmd_octeontx2_timestamp_rx_dynflag; +extern int rte_pmd_octeontx2_timestamp_dynfield_offset; + +static inline rte_mbuf_timestamp_t * +otx2_timestamp_dynfield (struct rte_mbuf *mbuf)
Please take the offset from struct otx2_timesync_info *tstamp. it already available in otx2_nix_mbuf_to_tstamp(). See below.
Quoted 34 lines
drivers/net/octeontx2/otx2_rx.h +10
-3+{ +return RTE_MBUF_DYNFIELD (mbuf, + rte_pmd_octeontx2_timestamp_dynfield_offset, + rte_mbuf_timestamp_t *); +} + static __rte_always_inline void otx2_nix_mbuf_to_tstamp(struct rte_mbuf *mbuf, struct otx2_timesync_info *tstamp, const uint16_t flag,@@ -77,15 +89,16 @@ otx2_nix_mbuf_to_tstamp(struct rte_mbuf *mbuf,/* Reading the rx timestamp inserted by CGX, viz at * starting of the packet data. */ - mbuf->timestamp =rte_be_to_cpu_64 (*tstamp_ptr); + *otx2_timestamp_dynfield (mbuf) =rte_be_to_cpu_64 (*tstamp_ptr);/* PKT_RX_IEEE1588_TMST flag needs to be set only in case * PTP packets are received. */ if (mbuf->packet_type ==RTE_PTYPE_L2_ETHER_TIMESYNC ) { - tstamp->rx_tstamp = mbuf->timestamp; + tstamp->rx_tstamp = *otx2_timestamp_dynfield (mbuf); tstamp->rx_ready =1 ; mbuf->ol_flags |=PKT_RX_IEEE1588_PTP | -PKT_RX_IEEE1588_TMST |PKT_RX_TIMESTAMP ; +PKT_RX_IEEE1588_TMST | + rte_pmd_octeontx2_timestamp_rx_dynflag; } } }drivers/net/octeontx2/version.map +0
-0
drivers/net/octeontx2/version.map line 9
Quoted 9 lines
drivers/net/octeontx2/version.map +6
-0@@ -1,3 +1,10 @@ DPDK_21 { local: *; }; + +INTERNAL { + global: + + rte_pmd_octeontx2_timestamp_dynfield_offset; + rte_pmd_octeontx2_timestamp_rx_dynflag;
No need to export this function if offset is part of struct otx2_timesync_info
Quoted 4 lines
drivers/net/octeontx2/version.map +1
-1+}; --2.28.0
Re: [dpdk-dev] [PATCH v2 10/14] net/octeontx2: switch timestamp to dynamic mbuf field
01/11/2020 19:28, Jerin Jacob:
Quoted 8 lines · Thomas Monjalon
Quoted 7 lines
The mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced.
Signed-off-by Thomas Monjalon <[email protected]>---
[...]
Quoted 6 lines
drivers/net/octeontx2/otx2_ethdev.c line 19
Quoted 2 lines
drivers/net/octeontx2/otx2_ethdev.c +2
-0+uint64_t rte_pmd_octeontx2_timestamp_rx_dynflag; +int rte_pmd_octeontx2_timestamp_dynfield_offset =-1 ;Instead of the global variable, please move the offset to struct
otx2_timesync_info(which is used in fastpath)and accessible in slow path.
This structure is initialized in otx2_nix_dev_start(). otx2_rx_timestamp_setup() is called earlier in otx2_nix_configure(). One of the two has to change. Which one?
Quoted 34 lines
Quoted 34 lines
drivers/net/octeontx2/otx2_ethdev.c +28
-0+static int +otx2_rx_timestamp_setup (uint16_t flags) +{ +int timestamp_rx_dynflag_offset; + +if ((flags &NIX_RX_OFFLOAD_TSTAMP_F ) ==0 ) +return 0 ; + + rte_pmd_octeontx2_timestamp_dynfield_offset =rte_mbuf_dynfield_lookup ( +RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ); +if (rte_pmd_octeontx2_timestamp_dynfield_offset <0 ) { +otx2_err ("Failed to lookup timestamp field" ); +return -rte_errno; + } + timestamp_rx_dynflag_offset =rte_mbuf_dynflag_lookup ( +RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME ,NULL ); +if (timestamp_rx_dynflag_offset <0 ) { +otx2_err ("Failed to lookup Rx timestamp flag" ); +return -rte_errno; + } + rte_pmd_octeontx2_timestamp_rx_dynflag = +RTE_BIT64 (timestamp_rx_dynflag_offset); + +return 0 ; +}@@ -1874,6 +1904,9 @@ otx2_nix_configure(struct rte_eth_dev *eth_dev) dev->tx_offload_flags |=nix_tx_offload_flags (eth_dev); dev->rss_info.rss_grps =NIX_RSS_GRPS ; +if (otx2_rx_timestamp_setup (dev->rx_offload_flags) !=0 ) + goto fail_offloads; + nb_rxq =RTE_MAX (data->nb_rx_queues,1 ); nb_txq =RTE_MAX (data->nb_tx_queues,1 );
Re: [dpdk-dev] [PATCH v2 10/14] net/octeontx2: switch timestamp to dynamic mbuf field
02/11/2020 10:38, Thomas Monjalon:
Quoted 17 lines
01/11/2020 19:28, Jerin Jacob:
Quoted 8 lines · Thomas Monjalon
Quoted 7 lines
The mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced.
Signed-off-by Thomas Monjalon <[email protected]>---
[...]
Quoted 6 lines
drivers/net/octeontx2/otx2_ethdev.c line 19
Quoted 2 lines
drivers/net/octeontx2/otx2_ethdev.c +2
-0+uint64_t rte_pmd_octeontx2_timestamp_rx_dynflag; +int rte_pmd_octeontx2_timestamp_dynfield_offset =-1 ;Instead of the global variable, please move the offset to struct
otx2_timesync_info(which is used in fastpath)and accessible in slow path.
Quoted 3 lines
This structure is initialized in
otx2_nix_dev_start().otx2_rx_timestamp_setup()is called earlier inotx2_nix_configure(). One of the two has to change. Which one?
I see that the timestamp config can be changed in otx2_nix_dev_start() so it looks I have no other choice than moving timestamp setup at "start" stage anyway.
Will be done in v3, that I will send later today.
PATCH v2 11/14 net/pcap: switch timestamp to dynamic mbuf field
In reply to Thomas MonjalonThe mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced.
--- drivers/net/pcap/rte_eth_pcap.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-)
drivers/net/pcap/rte_eth_pcap.c +26 -3
@@ -18,6 +18,7 @@#include <pcap.h> +#include <rte_bitops.h> #include <rte_cycles.h> #include <rte_ethdev_driver.h> #include <rte_ethdev_vdev.h>
@@ -51,6 +52,9 @@ static uint64_t start_cycles;static uint64_t hz;static uint8_t iface_idx; +static uint64_t timestamp_rx_dynflag; +static int timestamp_dynfield_offset =-1 ; +struct queue_stat {volatile unsigned long pkts;volatile unsigned long bytes;
@@ -265,9 +269,11 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) } mbuf->pkt_len = (uint16_t )header.caplen; - mbuf->timestamp = (uint64_t )header.ts.tv_sec *1000000 - + header.ts.tv_usec; - mbuf->ol_flags |=PKT_RX_TIMESTAMP ; + *RTE_MBUF_DYNFIELD (mbuf, timestamp_dynfield_offset, + rte_mbuf_timestamp_t *) = + (uint64_t )header.ts.tv_sec *1000000 + + header.ts.tv_usec; + mbuf->ol_flags |= timestamp_rx_dynflag; mbuf->port = pcap_q->port_id; bufs[num_rx] = mbuf; num_rx++;
@@ -656,6 +662,23 @@ eth_dev_stop(struct rte_eth_dev *dev)static int eth_dev_configure(struct rte_eth_dev *dev __rte_unused) { +int timestamp_rx_dynflag_offset; + + timestamp_dynfield_offset =rte_mbuf_dynfield_lookup ( +RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ); +if (timestamp_dynfield_offset <0 ) { +PMD_LOG (ERR ,"Failed to lookup timestamp field" ); +return -rte_errno; + } + timestamp_rx_dynflag_offset =rte_mbuf_dynflag_lookup ( +RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME ,NULL ); +if (timestamp_rx_dynflag_offset <0 ) { +PMD_LOG (ERR ,"Failed lookup Rx timestamp flag" ); +return -rte_errno; + } + timestamp_rx_dynflag = +RTE_BIT64 (timestamp_rx_dynflag_offset); +return 0 ; }
Signature · 1 line
2.28.0
PATCH v2 12/14 app/testpmd: switch timestamp to dynamic mbuf field
In reply to Thomas MonjalonThe mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced.
--- app/test-pmd/util.c | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-)
app/test-pmd/util.c +37 -2
@@ -5,6 +5,7 @@#include <stdio.h> +#include <rte_bitops.h> #include <rte_net.h> #include <rte_mbuf.h> #include <rte_ether.h>
@@ -22,6 +23,40 @@ print_ether_addr(const char *what, const struct rte_ether_addr *eth_addr)printf ("%s%s" , what, buf); } +static inline bool +is_timestamp_enabled (const struct rte_mbuf *mbuf) +{ +static uint64_t timestamp_rx_dynflag; + +int timestamp_rx_dynflag_offset; + +if (timestamp_rx_dynflag ==0 ) { + timestamp_rx_dynflag_offset =rte_mbuf_dynflag_lookup ( +RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME ,NULL ); +if (timestamp_rx_dynflag_offset <0 ) +return false; + timestamp_rx_dynflag =RTE_BIT64 (timestamp_rx_dynflag_offset); + } + +return (mbuf->ol_flags & timestamp_rx_dynflag) !=0 ; +} + +static inline rte_mbuf_timestamp_t +get_timestamp (const struct rte_mbuf *mbuf) +{ +static int timestamp_dynfield_offset =-1 ; + +if (timestamp_dynfield_offset <0 ) { + timestamp_dynfield_offset =rte_mbuf_dynfield_lookup ( +RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ); +if (timestamp_dynfield_offset <0 ) +return 0 ; + } + +return *RTE_MBUF_DYNFIELD (mbuf, + timestamp_dynfield_offset, rte_mbuf_timestamp_t *); +} +static inline void dump_pkt_burst (uint16_t port_id,uint16_t queue,struct rte_mbuf *pkts[],uint16_t nb_pkts,int is_rx)
@@ -107,8 +142,8 @@ dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],printf ("hash=0x%x ID=0x%x " , mb->hash.fdir.hash, mb->hash.fdir.id); } -if (ol_flags &PKT_RX_TIMESTAMP ) -printf (" - timestamp %" PRIu64" " , mb->timestamp); +if (is_timestamp_enabled (mb)) +printf (" - timestamp %" PRIu64" " ,get_timestamp (mb));if (ol_flags &PKT_RX_QINQ )printf (" - QinQ VLAN tci=0x%x, VLAN tci outer=0x%x" , mb->vlan_tci, mb->vlan_tci_outer);
Signature · 1 line
2.28.0
PATCH v2 13/14 examples/rxtx_callbacks: switch timestamp to dynamic field
In reply to Thomas MonjalonThe mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field.
--- examples/rxtx_callbacks/main.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
examples/rxtx_callbacks/main.c +16 -1
@@ -19,6 +19,15 @@#define MBUF_CACHE_SIZE 250#define BURST_SIZE 32 +static int hwts_dynfield_offset =-1 ; + +static inline rte_mbuf_timestamp_t * +hwts_field (struct rte_mbuf *mbuf) +{ +return RTE_MBUF_DYNFIELD (mbuf, + hwts_dynfield_offset, rte_mbuf_timestamp_t *); +} +typedef uint64_t tsc_t ;static int tsc_dynfield_offset =-1 ;
@@ -77,7 +86,7 @@ calc_latency(uint16_t port, uint16_t qidx __rte_unused,for (i =0 ; i < nb_pkts; i++) { cycles += now - *tsc_field (pkts[i]);if (hw_timestamping) - queue_ticks += ticks - pkts[i]->timestamp; + queue_ticks += ticks - *hwts_field (pkts[i]); } latency_numbers.total_cycles += cycles;
@@ -141,6 +150,12 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)return -1 ; } port_conf.rxmode.offloads |=DEV_RX_OFFLOAD_TIMESTAMP ; + hwts_dynfield_offset =rte_mbuf_dynfield_lookup ( +RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ); +if (hwts_dynfield_offset <0 ) { +printf ("ERROR: Failed to lookup timestamp field\n" ); +return -rte_errno; + } } retval =rte_eth_dev_configure (port, rx_rings, tx_rings, &port_conf);
Signature · 1 line
2.28.0
PATCH v2 14/14 mbuf: remove deprecated timestamp field
In reply to Thomas MonjalonAs announced in the deprecation note, the field timestamp is removed to give more space to the dynamic fields. The related offload flag PKT_RX_TIMESTAMP is also removed.
This is how the mbuf layout looks like (pahole-style):
word type name byte size
0 void * buf_addr; /* 0 + 8 */
1 rte_iova_t buf_iova /* 8 + 8 */
/* --- RTE_MARKER64 rearm_data; */
2 uint16_t data_off; /* 16 + 2 */
uint16_t refcnt; /* 18 + 2 */
uint16_t nb_segs; /* 20 + 2 */
uint16_t port; /* 22 + 2 */
3 uint64_t ol_flags; /* 24 + 8 */
/* --- RTE_MARKER rx_descriptor_fields1; */
4 uint32_t union packet_type; /* 32 + 4 */
uint32_t pkt_len; /* 36 + 4 */
5 uint16_t data_len; /* 40 + 2 */
uint16_t vlan_tci; /* 42 + 2 */
5.5 uint64_t union hash; /* 44 + 8 */
6.5 uint16_t vlan_tci_outer; /* 52 + 2 */
uint16_t buf_len; /* 54 + 2 */
7 uint64_t dynfield0[1]; /* 56 + 8 */
/* --- RTE_MARKER cacheline1; */
8 struct rte_mempool * pool; /* 64 + 8 */
9 struct rte_mbuf * next; /* 72 + 8 */
10 uint64_t union tx_offload; /* 80 + 8 */
11 struct rte_mbuf_ext_shared_info * shinfo; /* 88 + 8 */
12 uint16_t priv_size; /* 96 + 2 */
uint16_t timesync; /* 98 + 2 */
12.5 uint32_t dynfield1[7]; /* 100 + 28 */16 /* --- END 128 */
--- app/test/test_mbuf.c | 1 - doc/guides/rel_notes/deprecation.rst | 4 ---- doc/guides/rel_notes/release_20_11.rst | 4 ++++ lib/librte_ethdev/rte_ethdev.h | 4 +++- lib/librte_mbuf/rte_mbuf.c | 2 -- lib/librte_mbuf/rte_mbuf.h | 2 +- lib/librte_mbuf/rte_mbuf_core.h | 12 +----------- lib/librte_mbuf/rte_mbuf_dyn.c | 1 + 8 files changed, 10 insertions(+), 20 deletions(-)
app/test/test_mbuf.c +0 -1
@@ -1621,7 +1621,6 @@ test_get_rx_ol_flag_name(void)VAL_NAME (PKT_RX_FDIR_FLX ),VAL_NAME (PKT_RX_QINQ_STRIPPED ),VAL_NAME (PKT_RX_LRO ), -VAL_NAME (PKT_RX_TIMESTAMP ),VAL_NAME (PKT_RX_SEC_OFFLOAD ),VAL_NAME (PKT_RX_SEC_OFFLOAD_FAILED ), VAL_NAME(PKT_RX_OUTER_L4_CKSUM_BAD),
doc/guides/rel_notes/deprecation.rst +0 -4
@@ -84,10 +84,6 @@ Deprecation Notices * mbuf: Some fields will be converted to dynamic API in DPDK 20.11 in order to reserve more space for the dynamic fields, as explained in `this presentation <https://www.youtube.com/watch?v=Ttl6MlhmzWY>`_. - The following static fields will be moved as dynamic: - - - ``timestamp`` - As a consequence, the layout of the ``struct rte_mbuf`` will be re-arranged, avoiding impact on vectorized implementation of the driver datapaths, while evaluating performance gains of a better use of the first cache line.
doc/guides/rel_notes/release_20_11.rst +4 -0
@@ -448,6 +448,10 @@ API Changes * mbuf: Removed the field ``seqn`` from the structure ``rte_mbuf``. It is replaced with dynamic fields. +* mbuf: Removed the field ``timestamp`` from the structure ``rte_mbuf``. + It is replaced with the dynamic field RTE_MBUF_DYNFIELD_TIMESTAMP_NAME + which was previously used only for Tx. + * pci: Removed the ``rte_kernel_driver`` enum defined in rte_dev.h and replaced with a private enum in the PCI subsystem.
lib/librte_ethdev/rte_ethdev.h +3 -1
@@ -1345,6 +1345,8 @@ struct rte_eth_conf {#define DEV_RX_OFFLOAD_JUMBO_FRAME 0x00000800#define DEV_RX_OFFLOAD_SCATTER 0x00002000/** +* Timestamp is set by the driver in RTE_MBUF_DYNFIELD_TIMESTAMP_NAME +* and RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME is set in ol_flags. * The mbuf field and flag are registered when the offload is configured. */ #define DEV_RX_OFFLOAD_TIMESTAMP 0x00004000
@@ -4654,7 +4656,7 @@ int rte_eth_timesync_write_time(uint16_t port_id, const struct timespec *time);* rte_eth_read_clock(port, base_clock); * * Then, convert the raw mbuf timestamp with: -* base_time_sec + (double)(mbuf->timestamp - base_clock) / freq; +* base_time_sec + (double)(*timestamp_dynfield(mbuf) - 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.
lib/librte_mbuf/rte_mbuf.c +0 -2
@@ -764,7 +764,6 @@ const char *rte_get_rx_ol_flag_name(uint64_t mask)case PKT_RX_QINQ_STRIPPED :return "PKT_RX_QINQ_STRIPPED" ;case PKT_RX_QINQ :return "PKT_RX_QINQ" ;case PKT_RX_LRO :return "PKT_RX_LRO" ; -case PKT_RX_TIMESTAMP :return "PKT_RX_TIMESTAMP" ;case PKT_RX_SEC_OFFLOAD :return "PKT_RX_SEC_OFFLOAD" ;case PKT_RX_SEC_OFFLOAD_FAILED :return "PKT_RX_SEC_OFFLOAD_FAILED" ;case PKT_RX_OUTER_L4_CKSUM_BAD :return "PKT_RX_OUTER_L4_CKSUM_BAD" ;
@@ -808,7 +807,6 @@ rte_get_rx_ol_flag_list(uint64_t mask, char *buf, size_t buflen) { PKT_RX_FDIR_FLX, PKT_RX_FDIR_FLX, NULL }, { PKT_RX_QINQ_STRIPPED, PKT_RX_QINQ_STRIPPED, NULL }, { PKT_RX_LRO, PKT_RX_LRO, NULL }, - { PKT_RX_TIMESTAMP, PKT_RX_TIMESTAMP, NULL }, { PKT_RX_SEC_OFFLOAD, PKT_RX_SEC_OFFLOAD, NULL }, { PKT_RX_SEC_OFFLOAD_FAILED, PKT_RX_SEC_OFFLOAD_FAILED, NULL }, { PKT_RX_QINQ, PKT_RX_QINQ, NULL },
lib/librte_mbuf/rte_mbuf.h +1 -1
@@ -1095,6 +1095,7 @@ rte_pktmbuf_attach_extbuf(struct rte_mbuf *m, void *buf_addr,static inline void rte_mbuf_dynfield_copy (struct rte_mbuf *mdst,const struct rte_mbuf *msrc) { +memcpy (&mdst->dynfield0, msrc->dynfield0,sizeof (mdst->dynfield0));memcpy (&mdst->dynfield1, msrc->dynfield1,sizeof (mdst->dynfield1)); }
@@ -1108,7 +1109,6 @@ __rte_pktmbuf_copy_hdr(struct rte_mbuf *mdst, const struct rte_mbuf *msrc) mdst->tx_offload = msrc->tx_offload; mdst->hash = msrc->hash; mdst->packet_type = msrc->packet_type; - mdst->timestamp = msrc->timestamp;rte_mbuf_dynfield_copy (mdst, msrc); }
lib/librte_mbuf/rte_mbuf_core.h +1 -11
@@ -149,11 +149,6 @@ extern "C" {*/ #define PKT_RX_LRO (1ULL << 16) -/** -* Indicate that the timestamp field in the mbuf is valid. -*/ -#define PKT_RX_TIMESTAMP (1ULL << 17) -/** * Indicate that security offload processing was applied on the RX packet. */
@@ -589,12 +584,7 @@ struct rte_mbuf {uint16_t buf_len;/**< Length of segment buffer. */ -/** 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; +uint64_t dynfield0[1 ];/**< Reserved for dynamic fields. */ /* second cache line - fields only used in slow path or on TX */ RTE_MARKER cacheline1 __rte_cache_min_aligned;
lib/librte_mbuf/rte_mbuf_dyn.c +1 -0
@@ -124,6 +124,7 @@ init_shared_mem(void)* rte_mbuf_dynfield_copy(). */ memset (shm,0 ,sizeof (*shm)); +mark_free (dynfield0);mark_free (dynfield1);/* init free_flags */
Signature · 1 line
2.28.0
Re: [dpdk-dev] [PATCH v2 14/14] mbuf: remove deprecated timestamp field
Quoted 38 lines · Thomas Monjalon
As announced in the deprecation note, the field timestamp is removed to give more space to the dynamic fields. The related offload flag
PKT_RX_TIMESTAMPis also removed.This is how the mbuf layout looks like (pahole-style):
word type name byte size 0 void * buf_addr; /* 0 + 8 */ 1 rte_iova_t buf_iova /* 8 + 8 */ /* --- RTE_MARKER64 rearm_data; */ 2 uint16_t data_off; /* 16 + 2 */ uint16_t refcnt; /* 18 + 2 */ uint16_t nb_segs; /* 20 + 2 */ uint16_t port; /* 22 + 2 */ 3 uint64_t ol_flags; /* 24 + 8 */ /* --- RTE_MARKER rx_descriptor_fields1; */ 4 uint32_t union packet_type; /* 32 + 4 */ uint32_t pkt_len; /* 36 + 4 */ 5 uint16_t data_len; /* 40 + 2 */ uint16_t vlan_tci; /* 42 + 2 */ 5.5 uint64_t union hash; /* 44 + 8 */ 6.5 uint16_t vlan_tci_outer; /* 52 + 2 */ uint16_t buf_len; /* 54 + 2 */ 7 uint64_t dynfield0[1]; /* 56 + 8 */ /* --- RTE_MARKER cacheline1; */ 8 struct rte_mempool * pool; /* 64 + 8 */ 9 struct rte_mbuf * next; /* 72 + 8 */ 10 uint64_t union tx_offload; /* 80 + 8 */ 11 struct rte_mbuf_ext_shared_info * shinfo; /* 88 + 8 */ 12 uint16_t priv_size; /* 96 + 2 */ uint16_t timesync; /* 98 + 2 */ 12.5 uint32_t dynfield1[7]; /* 100 + 28 */16 /* --- END 128 */
Signed-off-by Thomas Monjalon <[email protected]>Reviewed-by Andrew Rybchenko <[email protected]>Acked-by Ajit Khaparde <[email protected]>Acked-by Ray Kinsella <[email protected]>
<...>
Quoted 4 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-0@@ -149,11 +149,6 @@ extern "C" {*/
lib/librte_mbuf/rte_mbuf_core.h extern "C" { · line 154
Quoted 10 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-5#define PKT_RX_LRO (1ULL << 16) -/** -* Indicate that the timestamp field in the mbuf is valid. -*/ -#define PKT_RX_TIMESTAMP (1ULL << 17) -/** * Indicate that security offload processing was applied on the RX packet. */
nit: can we keep a comment here to highlight the flag 17 is unused?
Re: [dpdk-dev] [PATCH v2 14/14] mbuf: remove deprecated timestamp field
Quoted 6 lines · Olivier Matz
Quoted 6 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-0@@ -149,11 +149,6 @@ extern "C" {*/ #define PKT_RX_LRO (1ULL << 16)
Quoted 10 lines
lib/librte_mbuf/rte_mbuf_core.h extern "C" { · line 154
Quoted 8 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-5-/** -* Indicate that the timestamp field in the mbuf is valid. -*/ -#define PKT_RX_TIMESTAMP (1ULL << 17) -/** * Indicate that security offload processing was applied on the RX packet. */ nit: can we keep a comment here to highlight the flag 17 is unused?
What about marking it free in free_flags?
Signature · 1 line
David Marchand
Re: [dpdk-dev] [PATCH v2 14/14] mbuf: remove deprecated timestamp field
02/11/2020 16:47, David Marchand:
Quoted 18 lines · Olivier Matz
Quoted 6 lines
Quoted 6 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-0@@ -149,11 +149,6 @@ extern "C" {*/ #define PKT_RX_LRO (1ULL << 16)Quoted 10 lines
lib/librte_mbuf/rte_mbuf_core.h extern "C" { · line 154
Quoted 8 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-5-/** -* Indicate that the timestamp field in the mbuf is valid. -*/ -#define PKT_RX_TIMESTAMP (1ULL << 17) -/** * Indicate that security offload processing was applied on the RX packet. */ nit: can we keep a comment here to highlight the flag 17 is unused?
Quoted 1 line
What about marking it free in
free_flags?
Overkill for a single bit. We will probably use it in future. I will add a comment as suggested by Olivier.
01/11/2020 19:06, Thomas Monjalon:
Quoted 9 lines
The mbuf field timestamp was announced to be removed for three reasons:
- a dynamic field already exist, used for Tx only
- this field always used 8 bytes even if unneeded
- this field is in the first half (cacheline) of mbufAfter this series, the dynamic field timestamp is used for both Rx and Tx with separate dynamic flags to distinguish when the value is meaningful without resetting the field during forwarding.
Quoted 7 lines
As a consequence, 8 bytes can be re-allocated to dynamic fields in the first half of mbuf structure.
It is still open to change more the mbuf layout.This mbuf layout change is important to allow adding more features (consuming more dynamic fields) during the next year,
and can allow performance improvements with new usages in the first half.
The changelog was missing:
v2:
- remove optimization to register only once in ethdev
- fix error message in latencystats
- convert rxtx_callbacks macro to inline function
- increase dynamic fields space
- do not move pool field
v3 cover remove mbuf timestamp
In reply to Thomas MonjalonThe mbuf field timestamp was announced to be removed for three reasons:
- a dynamic field already exist, used for Tx only
- this field always used 8 bytes even if unneeded
- this field is in the first half (cacheline) of mbuf
After this series, the dynamic field timestamp is used for both Rx and Tx with separate dynamic flags to distinguish when the value is meaningful without resetting the field during forwarding.
As a consequence, 8 bytes can be re-allocated to dynamic fields in the first half of mbuf structure.
It is still open to change more the mbuf layout.
This mbuf layout change is important to allow adding more features (consuming more dynamic fields) during the next year,
and can allow performance improvements with new usages in the first half.
v3:
- move ark variables declaration in a .h file
- improve cache locality for octeontx2
- add comments about cache locality in commit logs
- add comment for unused flag offset 17
- add timestamp register functions
- replace lookup with register in drivers and apps
- remove register in ethdev
v2:
- remove optimization to register only once in ethdev
- fix error message in latencystats
- convert rxtx_callbacks macro to inline function
- increase dynamic fields space
- do not move pool field
Thomas Monjalon (16):
eventdev: remove software Rx timestamp
mbuf: add Rx timestamp flag and helpers
latency: switch Rx timestamp to dynamic mbuf field net/ark: switch Rx timestamp to dynamic mbuf field net/dpaa2: switch Rx timestamp to dynamic mbuf field net/mlx5: fix dynamic mbuf offset lookup check net/mlx5: switch Rx timestamp to dynamic mbuf field net/nfb: switch Rx timestamp to dynamic mbuf field net/octeontx2: switch Rx timestamp to dynamic mbuf field net/pcap: switch Rx timestamp to dynamic mbuf field app/testpmd: switch Rx timestamp to dynamic mbuf field examples/rxtx_callbacks: switch timestamp to dynamic field
ethdev: add doxygen comment for Rx timestamp API
mbuf: remove deprecated timestamp field
mbuf: add Tx timestamp registration helper
ethdev: include mbuf registration in Tx timestamp API
app/test-pmd/config.c | 38 ------------- app/test-pmd/util.c | 39 ++++++++++++- app/test/test_mbuf.c | 1 - doc/guides/nics/mlx5.rst | 5 +- .../prog_guide/event_ethernet_rx_adapter.rst | 6 +- doc/guides/rel_notes/deprecation.rst | 4 -- doc/guides/rel_notes/release_20_11.rst | 4 ++ drivers/net/ark/ark_ethdev.c | 16 ++++++ drivers/net/ark/ark_ethdev_rx.c | 7 ++- drivers/net/ark/ark_ethdev_rx.h | 2 + drivers/net/dpaa2/dpaa2_ethdev.c | 11 ++++ drivers/net/dpaa2/dpaa2_ethdev.h | 2 + drivers/net/dpaa2/dpaa2_rxtx.c | 25 ++++++--- drivers/net/mlx5/mlx5_ethdev.c | 8 ++- drivers/net/mlx5/mlx5_rxq.c | 8 +++ drivers/net/mlx5/mlx5_rxtx.c | 8 +-- drivers/net/mlx5/mlx5_rxtx.h | 19 +++++++ drivers/net/mlx5/mlx5_rxtx_vec_altivec.h | 41 +++++++------- drivers/net/mlx5/mlx5_rxtx_vec_neon.h | 43 ++++++++------- drivers/net/mlx5/mlx5_rxtx_vec_sse.h | 35 ++++++------ drivers/net/mlx5/mlx5_trigger.c | 2 +- drivers/net/mlx5/mlx5_txq.c | 2 +- drivers/net/nfb/nfb_rx.c | 15 ++++- drivers/net/nfb/nfb_rx.h | 18 ++++-- drivers/net/octeontx2/otx2_ethdev.c | 10 ++++ drivers/net/octeontx2/otx2_rx.h | 19 ++++++- drivers/net/pcap/rte_eth_pcap.c | 20 ++++++- examples/rxtx_callbacks/main.c | 16 +++++- lib/librte_ethdev/rte_ethdev.h | 13 ++++- .../rte_event_eth_rx_adapter.c | 11 ---- .../rte_event_eth_rx_adapter.h | 6 +- lib/librte_latencystats/rte_latencystats.c | 30 ++++++++-- lib/librte_mbuf/rte_mbuf.c | 2 - lib/librte_mbuf/rte_mbuf.h | 2 +- lib/librte_mbuf/rte_mbuf_core.h | 12 +--- lib/librte_mbuf/rte_mbuf_dyn.c | 51 +++++++++++++++++ lib/librte_mbuf/rte_mbuf_dyn.h | 55 +++++++++++++++++-- lib/librte_mbuf/version.map | 2 + 38 files changed, 429 insertions(+), 179 deletions(-)
Signature · 1 line
2.28.0
PATCH v3 1/16 eventdev: remove software Rx timestamp
This a revert of the commit 569758758dcd ("eventdev: add Rx timestamp"). If the Rx timestamp is not configured on the ethdev port, there is no reason to set one.
Also the accuracy of the timestamp was bad because set at a late stage. Anyway there is no trace of the usage of this timestamp.
--- doc/guides/prog_guide/event_ethernet_rx_adapter.rst | 6 +----- lib/librte_eventdev/rte_event_eth_rx_adapter.c | 11 ----------- lib/librte_eventdev/rte_event_eth_rx_adapter.h | 6 +----- 3 files changed, 2 insertions(+), 21 deletions(-)
doc/guides/prog_guide/event_ethernet_rx_adapter.rst +1 -5
@@ -12,11 +12,7 @@ be supported in hardware or require a software thread to receive packets from the ethdev port using ethdev poll mode APIs and enqueue these as events to the event device using the eventdev API. Both transfer mechanisms may be present on the same platform depending on the particular combination of the ethdev and -the event device. For SW based packet transfer, if the mbuf does not have a -timestamp set, the adapter adds a timestamp to the mbuf using -rte_get_tsc_cycles(), this provides a more accurate timestamp as compared to -if the application were to set the timestamp since it avoids event device -schedule latency. +the event device. The Event Ethernet Rx Adapter library is intended for the application code to configure both transfer mechanisms using a common API. A capability API allows
lib/librte_eventdev/rte_event_eth_rx_adapter.c +0 -11
@@ -763,7 +763,6 @@ rxa_buffer_mbufs(struct rte_event_eth_rx_adapter *rx_adapter,uint32_t rss_mask;uint32_t rss;int do_rss; -uint64_t ts;uint16_t nb_cb;uint16_t dropped;
@@ -771,16 +770,6 @@ rxa_buffer_mbufs(struct rte_event_eth_rx_adapter *rx_adapter, rss_mask = ~(((m->ol_flags &PKT_RX_RSS_HASH ) !=0 ) -1 ); do_rss = !rss_mask && !eth_rx_queue_info->flow_id_mask; -if ((m->ol_flags &PKT_RX_TIMESTAMP ) ==0 ) { - ts =rte_get_tsc_cycles (); -for (i =0 ; i < num; i++) { - m = mbufs[i]; - - m->timestamp = ts; - m->ol_flags |=PKT_RX_TIMESTAMP ; - } - } -for (i =0 ; i < num; i++) { m = mbufs[i];
lib/librte_eventdev/rte_event_eth_rx_adapter.h +1 -5
@@ -21,11 +21,7 @@* * The adapter uses a EAL service core function for SW based packet transfer * and uses the eventdev PMD functions to configure HW based packet transfer -* between the ethernet device and the event device. For SW based packet -* transfer, if the mbuf does not have a timestamp set, the adapter adds a -* timestamp to the mbuf using rte_get_tsc_cycles(), this provides a more -* accurate timestamp as compared to if the application were to set the time -* stamp since it avoids event device schedule latency. +* between the ethernet device and the event device. * * The ethernet Rx event adapter's functions are: * - rte_event_eth_rx_adapter_create_ext()
Signature · 1 line
2.28.0
PATCH v3 2/16 mbuf: add Rx timestamp flag and helpers
In reply to Thomas MonjalonThere is already a dynamic field for timestamp,
used only for Tx scheduling with the dedicated Tx offload flag. The same field can be used for Rx timestamp filled by drivers.
A new dynamic flag is defined for Rx usage.
A new function wraps the registration of both field and Rx flag. The type rte_mbuf_timestamp_t is defined for the API users.
After migrating all Rx timestamp usages, it will be possible to remove the deprecated timestamp field.
--- lib/librte_mbuf/rte_mbuf_dyn.c | 43 ++++++++++++++++++++++++++++++++++ lib/librte_mbuf/rte_mbuf_dyn.h | 33 ++++++++++++++++++++++---- lib/librte_mbuf/version.map | 1 + 3 files changed, 72 insertions(+), 5 deletions(-)
lib/librte_mbuf/rte_mbuf_dyn.c +43 -0
@@ -13,6 +13,7 @@#include <rte_errno.h> #include <rte_malloc.h> #include <rte_string_fns.h> +#include <rte_bitops.h> #include <rte_mbuf.h> #include <rte_mbuf_dyn.h>
@@ -569,3 +570,45 @@ void rte_mbuf_dyn_dump(FILE *out)rte_mcfg_tailq_write_unlock (); } + +static int +rte_mbuf_dyn_timestamp_register (int *field_offset,uint64_t *flag, +const char *direction,const char *flag_name) +{ +static const struct rte_mbuf_dynfield field_desc = { + .name =RTE_MBUF_DYNFIELD_TIMESTAMP_NAME , + .size =sizeof (rte_mbuf_timestamp_t), + .align = __alignof__(rte_mbuf_timestamp_t ), + }; +struct rte_mbuf_dynflag flag_desc; +int offset; + + offset =rte_mbuf_dynfield_register (&field_desc); +if (offset <0 ) { +RTE_LOG (ERR ,MBUF , +"Failed to register mbuf field for timestamp\n" ); +return -1 ; + } +if (field_offset !=NULL ) + *field_offset = offset; + +strlcpy (flag_desc.name, flag_name,sizeof flag_desc.name); + offset =rte_mbuf_dynflag_register (&flag_desc); +if (offset <0 ) { +RTE_LOG (ERR ,MBUF , +"Failed to register mbuf flag for %s timestamp\n" , + direction); +return -1 ; + } +if (flag !=NULL ) + *flag =RTE_BIT64 (offset); + +return 0 ; +} + +int +rte_mbuf_dyn_rx_timestamp_register (int *field_offset,uint64_t *rx_flag) +{ +return rte_mbuf_dyn_timestamp_register (field_offset, rx_flag, +"Rx" ,RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME ); +}
lib/librte_mbuf/rte_mbuf_dyn.h +28 -5
@@ -258,13 +258,36 @@ void rte_mbuf_dyn_dump(FILE *out);* timestamp. The dynamic Tx timestamp flag tells whether the field contains * actual timestamp value for the packets being sent, this value can be * used by PMD to schedule packet sending. -* -* After PKT_RX_TIMESTAMP flag and fixed timestamp field deprecation -* and obsoleting, the dedicated Rx timestamp flag is supposed to be -* introduced and the shared dynamic timestamp field will be used -* to handle the timestamps on receiving datapath as well. */ #define RTE_MBUF_DYNFIELD_TIMESTAMP_NAME "rte_dynfield_timestamp" +typedef uint64_t rte_mbuf_timestamp_t ; + +/** +* Indicate that the timestamp field in the mbuf was filled by the driver. +*/ +#define RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME "rte_dynflag_rx_timestamp" + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Register dynamic mbuf field and flag for Rx timestamp. +* +* @param field_offset +* Pointer to the offset of the registered mbuf field, can be NULL. +* The same field is shared for Rx and Tx timestamp. +* @param rx_flag +* Pointer to the mask of the registered offload flag, can be NULL. +* @return +* 0 on success, -1 otherwise. +* Possible values for rte_errno: +* - EEXIST: already registered with different parameters. +* - EPERM: called from a secondary process. +* - ENOENT: no more field or flag available. +* - ENOMEM: allocation failure. +*/ +__rte_experimental +int rte_mbuf_dyn_rx_timestamp_register(int *field_offset, uint64_t *rx_flag);/** * When PMD sees the RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME flag set on the
lib/librte_mbuf/version.map +1 -0
@@ -42,6 +42,7 @@ EXPERIMENTAL { rte_mbuf_dynflag_register; rte_mbuf_dynflag_register_bitnum; rte_mbuf_dyn_dump; + rte_mbuf_dyn_rx_timestamp_register; rte_pktmbuf_copy; rte_pktmbuf_free_bulk; rte_pktmbuf_pool_create_extbuf;
Signature · 1 line
2.28.0
Re: [dpdk-dev] [PATCH v3 02/16] mbuf: add Rx timestamp flag and helpers
Hi Thomas,
Quoted 47 lines · Thomas Monjalon
There is already a dynamic field for timestamp,
used only for Tx scheduling with the dedicated Tx offload flag. The same field can be used for Rx timestamp filled by drivers.A new dynamic flag is defined for Rx usage.
A new function wraps the registration of both field and Rx flag. The typerte_mbuf_timestamp_tis defined for the API users.After migrating all Rx timestamp usages, it will be possible to remove the deprecated timestamp field.
Signed-off-by Thomas Monjalon <[email protected]>--- lib/librte_mbuf/rte_mbuf_dyn.c | 43 ++++++++++++++++++++++++++++++++++ lib/librte_mbuf/rte_mbuf_dyn.h | 33 ++++++++++++++++++++++---- lib/librte_mbuf/version.map | 1 + 3 files changed, 72 insertions(+), 5 deletions(-)lib/librte_mbuf/rte_mbuf_dyn.c +14
-0@@ -13,6 +13,7 @@#include <rte_errno.h> #include <rte_malloc.h> #include <rte_string_fns.h> +#include <rte_bitops.h> #include <rte_mbuf.h> #include <rte_mbuf_dyn.h> @@ -569,3 +570,45 @@ void rte_mbuf_dyn_dump(FILE *out)rte_mcfg_tailq_write_unlock (); } + +static int +rte_mbuf_dyn_timestamp_register (int *field_offset,uint64_t *flag, +const char *direction,const char *flag_name) +{ +static const struct rte_mbuf_dynfield field_desc = { + .name =RTE_MBUF_DYNFIELD_TIMESTAMP_NAME , + .size =sizeof (rte_mbuf_timestamp_t), + .align = __alignof__(rte_mbuf_timestamp_t ), + }; +struct rte_mbuf_dynflag flag_desc; +int offset; +
lib/librte_mbuf/rte_mbuf_dyn.c void rte_mbuf_dyn_dump(FILE *out) · line 595
Quoted 10 lines
lib/librte_mbuf/rte_mbuf_dyn.c +10
-0+ offset =rte_mbuf_dynfield_register (&field_desc); +if (offset <0 ) { +RTE_LOG (ERR ,MBUF , +"Failed to register mbuf field for timestamp\n" ); +return -1 ; + } +if (field_offset !=NULL ) + *field_offset = offset; + +strlcpy (flag_desc.name, flag_name,sizeof flag_desc.name);
The rest of the flag_desc structure is not initialized to 0 (the "flags" field).
I suggest to do it at declaration:
struct rte_mbuf_dynflag flag_desc = { 0 };Quoted 80 lines
lib/librte_mbuf/rte_mbuf_dyn.c +19
-0+ offset =rte_mbuf_dynflag_register (&flag_desc); +if (offset <0 ) { +RTE_LOG (ERR ,MBUF , +"Failed to register mbuf flag for %s timestamp\n" , + direction); +return -1 ; + } +if (flag !=NULL ) + *flag =RTE_BIT64 (offset); + +return 0 ; +} + +int +rte_mbuf_dyn_rx_timestamp_register (int *field_offset,uint64_t *rx_flag) +{ +return rte_mbuf_dyn_timestamp_register (field_offset, rx_flag, +"Rx" ,RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME ); +}lib/librte_mbuf/rte_mbuf_dyn.h +28
-5@@ -258,13 +258,36 @@ void rte_mbuf_dyn_dump(FILE *out);* timestamp. The dynamic Tx timestamp flag tells whether the field contains * actual timestamp value for the packets being sent, this value can be * used by PMD to schedule packet sending. -* -* After PKT_RX_TIMESTAMP flag and fixed timestamp field deprecation -* and obsoleting, the dedicated Rx timestamp flag is supposed to be -* introduced and the shared dynamic timestamp field will be used -* to handle the timestamps on receiving datapath as well. */ #define RTE_MBUF_DYNFIELD_TIMESTAMP_NAME "rte_dynfield_timestamp" +typedef uint64_t rte_mbuf_timestamp_t ; + +/** +* Indicate that the timestamp field in the mbuf was filled by the driver. +*/ +#define RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME "rte_dynflag_rx_timestamp" + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Register dynamic mbuf field and flag for Rx timestamp. +* +* @param field_offset +* Pointer to the offset of the registered mbuf field, can be NULL. +* The same field is shared for Rx and Tx timestamp. +* @param rx_flag +* Pointer to the mask of the registered offload flag, can be NULL. +* @return +* 0 on success, -1 otherwise. +* Possible values for rte_errno: +* - EEXIST: already registered with different parameters. +* - EPERM: called from a secondary process. +* - ENOENT: no more field or flag available. +* - ENOMEM: allocation failure. +*/ +__rte_experimental +int rte_mbuf_dyn_rx_timestamp_register(int *field_offset, uint64_t *rx_flag);/** * When PMD sees the RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME flag set on the lib/librte_mbuf/version.map +1
-0@@ -42,6 +42,7 @@ EXPERIMENTAL { rte_mbuf_dynflag_register; rte_mbuf_dynflag_register_bitnum; rte_mbuf_dyn_dump; + rte_mbuf_dyn_rx_timestamp_register; rte_pktmbuf_copy; rte_pktmbuf_free_bulk; rte_pktmbuf_pool_create_extbuf;Signature · 1 line
2.28.0
Re: [dpdk-dev] [PATCH v3 02/16] mbuf: add Rx timestamp flag and helpers
03/11/2020 10:33, Olivier Matz:
Quoted 27 lines · Thomas Monjalon
Quoted 12 lines
lib/librte_mbuf/rte_mbuf_dyn.c +12
-0+static int +rte_mbuf_dyn_timestamp_register (int *field_offset,uint64_t *flag, +const char *direction,const char *flag_name) +{ +static const struct rte_mbuf_dynfield field_desc = { + .name =RTE_MBUF_DYNFIELD_TIMESTAMP_NAME , + .size =sizeof (rte_mbuf_timestamp_t), + .align = __alignof__(rte_mbuf_timestamp_t ), + }; +struct rte_mbuf_dynflag flag_desc; +int offset; +lib/librte_mbuf/rte_mbuf_dyn.c void rte_mbuf_dyn_dump(FILE *out) · line 595
Quoted 10 lines
lib/librte_mbuf/rte_mbuf_dyn.c +10
-0+ offset =rte_mbuf_dynfield_register (&field_desc); +if (offset <0 ) { +RTE_LOG (ERR ,MBUF , +"Failed to register mbuf field for timestamp\n" ); +return -1 ; + } +if (field_offset !=NULL ) + *field_offset = offset; + +strlcpy (flag_desc.name, flag_name,sizeof flag_desc.name);The rest of the
flag_descstructure is not initialized to 0 (the "flags" field).
Quoted 3 lines
I suggest to do it at declaration:
struct rte_mbuf_dynflag flag_desc = { 0 };
Yes I forgot, thanks for catching.
PATCH v3 3/16 latency: switch Rx timestamp to dynamic mbuf field
In reply to Thomas MonjalonThe mbuf timestamp is moved to a dynamic field
in order to allow removal of the deprecated static field. The related mbuf flag is also replaced with the dynamic one.
--- lib/librte_latencystats/rte_latencystats.c | 30 ++++++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-)
lib/librte_latencystats/rte_latencystats.c +25 -5
@@ -9,6 +9,7 @@#include <rte_string_fns.h> #include <rte_mbuf.h> +#include <rte_mbuf_dyn.h> #include <rte_log.h> #include <rte_cycles.h> #include <rte_ethdev.h>
@@ -31,6 +32,16 @@ latencystat_cycles_per_ns(void)/* Macros for printing using RTE_LOG */ #define RTE_LOGTYPE_LATENCY_STATS RTE_LOGTYPE_USER1 +static uint64_t timestamp_dynflag; +static int timestamp_dynfield_offset =-1 ; + +static inline rte_mbuf_timestamp_t * +timestamp_dynfield (struct rte_mbuf *mbuf) +{ +return RTE_MBUF_DYNFIELD (mbuf, + timestamp_dynfield_offset, rte_mbuf_timestamp_t *); +} +static const char *MZ_RTE_LATENCY_STATS ="rte_latencystats" ;static int latency_stats_index;static uint64_t samp_intvl;
@@ -128,10 +139,10 @@ add_time_stamps(uint16_t pid __rte_unused, diff_tsc = now - prev_tsc; timer_tsc += diff_tsc; -if ((pkts[i]->ol_flags &PKT_RX_TIMESTAMP ) ==0 +if ((pkts[i]->ol_flags & timestamp_dynflag) ==0 && (timer_tsc >= samp_intvl)) { - pkts[i]->timestamp = now; - pkts[i]->ol_flags |=PKT_RX_TIMESTAMP ; + *timestamp_dynfield (pkts[i]) = now; + pkts[i]->ol_flags |= timestamp_dynflag; timer_tsc =0 ; } prev_tsc = now;
@@ -161,8 +172,8 @@ calc_latency(uint16_t pid __rte_unused, now =rte_rdtsc ();for (i =0 ; i < nb_pkts; i++) { -if (pkts[i]->ol_flags &PKT_RX_TIMESTAMP ) - latency[cnt++] = now - pkts[i]->timestamp; +if (pkts[i]->ol_flags & timestamp_dynflag) + latency[cnt++] = now - *timestamp_dynfield (pkts[i]); }rte_spinlock_lock (&glob_stats->lock);
@@ -241,6 +252,15 @@ rte_latencystats_init(uint64_t app_samp_intvl,return -1 ; } +/* Register mbuf field and flag for Rx timestamp */ + ret =rte_mbuf_dyn_rx_timestamp_register (×tamp_dynfield_offset, + ×tamp_dynflag); +if (ret !=0 ) { +RTE_LOG (ERR ,LATENCY_STATS , +"Cannot register mbuf field/flag for timestamp\n" ); +return -rte_errno; + } +/** Register Rx/Tx callbacks */ RTE_ETH_FOREACH_DEV (pid) {struct rte_eth_dev_info dev_info;
Signature · 1 line
2.28.0
PATCH v3 4/16 net/ark: switch Rx timestamp to dynamic mbuf field
In reply to Thomas MonjalonThe mbuf timestamp is moved to a dynamic field
in order to allow removal of the deprecated static field. The related dynamic mbuf flag is set, although was missing previously.
The timestamp is set if configured for at least one device.
--- drivers/net/ark/ark_ethdev.c | 16 ++++++++++++++++ drivers/net/ark/ark_ethdev_rx.c | 7 ++++++- drivers/net/ark/ark_ethdev_rx.h | 2 ++ 3 files changed, 24 insertions(+), 1 deletion(-)
drivers/net/ark/ark_ethdev.c +16 -0
@@ -79,6 +79,8 @@ static int eth_ark_set_mtu(struct rte_eth_dev *dev, uint16_t size);#define ARK_TX_MAX_QUEUE (4096 * 4)#define ARK_TX_MIN_QUEUE (256) +uint64_t ark_timestamp_rx_dynflag; +int ark_timestamp_dynfield_offset =-1 ;int rte_pmd_ark_rx_userdata_dynfield_offset =-1 ;int rte_pmd_ark_tx_userdata_dynfield_offset =-1 ;
@@ -552,6 +554,18 @@ static int eth_ark_dev_configure(struct rte_eth_dev *dev) {struct ark_adapter *ark = dev->data->dev_private; +int ret; + +if (dev->data->dev_conf.rxmode.offloads &DEV_RX_OFFLOAD_TIMESTAMP ) { + ret =rte_mbuf_dyn_rx_timestamp_register ( + &ark_timestamp_dynfield_offset, + &ark_timestamp_rx_dynflag); +if (ret !=0 ) { +ARK_PMD_LOG (ERR , +"Failed to register Rx timestamp field/flag\n" ); +return -rte_errno; + } + }eth_ark_dev_set_link_up (dev);if (ark->user_ext.dev_configure)
@@ -782,6 +796,8 @@ eth_ark_dev_info_get(struct rte_eth_dev *dev,ETH_LINK_SPEED_50G | ETH_LINK_SPEED_100G); + dev_info->rx_offload_capa =DEV_RX_OFFLOAD_TIMESTAMP ; +return 0 ; }
drivers/net/ark/ark_ethdev_rx.c +6 -1
@@ -272,7 +272,12 @@ eth_ark_recv_pkts(void *rx_queue, mbuf->port = meta->port; mbuf->pkt_len = meta->pkt_len; mbuf->data_len = meta->pkt_len; - mbuf->timestamp = meta->timestamp; +/* set timestamp if enabled at least on one device */ +if (ark_timestamp_rx_dynflag >0 ) { + *RTE_MBUF_DYNFIELD (mbuf, ark_timestamp_dynfield_offset, + rte_mbuf_timestamp_t *) = meta->timestamp; + mbuf->ol_flags |= ark_timestamp_rx_dynflag; + }rte_pmd_ark_mbuf_rx_userdata_set (mbuf, meta->user_data);if (ARK_DEBUG_CORE ) {/* debug sanity checks */
drivers/net/ark/ark_ethdev_rx.h +2 -0
@@ -11,6 +11,8 @@#include <rte_mempool.h> #include <rte_ethdev_driver.h> +extern uint64_t ark_timestamp_rx_dynflag; +extern int ark_timestamp_dynfield_offset; int eth_ark_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
Signature · 1 line
2.28.0
PATCH v3 5/16 net/dpaa2: switch Rx timestamp to dynamic mbuf field
In reply to Thomas MonjalonThe mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced.
--- drivers/net/dpaa2/dpaa2_ethdev.c | 11 +++++++++++ drivers/net/dpaa2/dpaa2_ethdev.h | 2 ++ drivers/net/dpaa2/dpaa2_rxtx.c | 25 ++++++++++++++++++------- 3 files changed, 31 insertions(+), 7 deletions(-)
drivers/net/dpaa2/dpaa2_ethdev.c +11 -0
@@ -65,6 +65,8 @@ static uint64_t dev_tx_offloads_nodis =/* enable timestamp in mbuf */ bool dpaa2_enable_ts[RTE_MAX_ETHPORTS ]; +uint64_t dpaa2_timestamp_rx_dynflag; +int dpaa2_timestamp_dynfield_offset =-1 ;struct rte_dpaa2_xstats_name_off {char name[RTE_ETH_XSTATS_NAME_SIZE ];
@@ -587,7 +589,16 @@ dpaa2_eth_dev_configure(struct rte_eth_dev *dev)#if !defined(RTE_LIBRTE_IEEE1588 ) if (rx_offloads & DEV_RX_OFFLOAD_TIMESTAMP)#endif + { + ret =rte_mbuf_dyn_rx_timestamp_register ( + &dpaa2_timestamp_dynfield_offset, + &dpaa2_timestamp_rx_dynflag); +if (ret !=0 ) { +DPAA2_PMD_ERR ("Error to register timestamp field/flag" ); +return -rte_errno; + } dpaa2_enable_ts[dev->data->port_id] = true; + }if (tx_offloads &DEV_TX_OFFLOAD_IPV4_CKSUM ) tx_l3_csum_offload = true;
drivers/net/dpaa2/dpaa2_ethdev.h +2 -0
@@ -92,6 +92,8 @@/* enable timestamp in mbuf*/ extern bool dpaa2_enable_ts[]; +extern uint64_t dpaa2_timestamp_rx_dynflag; +extern int dpaa2_timestamp_dynfield_offset;#define DPAA2_QOS_TABLE_RECONFIGURE 1#define DPAA2_FS_TABLE_RECONFIGURE 2
drivers/net/dpaa2/dpaa2_rxtx.c +18 -7
@@ -31,6 +31,13 @@ dpaa2_dev_rx_parse_slow(struct rte_mbuf *mbuf, static void enable_tx_tstamp(struct qbman_fd *fd) __rte_unused; +static inline rte_mbuf_timestamp_t * +dpaa2_timestamp_dynfield (struct rte_mbuf *mbuf) +{ +return RTE_MBUF_DYNFIELD (mbuf, + dpaa2_timestamp_dynfield_offset, rte_mbuf_timestamp_t *); +} +#define DPAA2_MBUF_TO_CONTIG_FD (_mbuf, _fd, _bpid) do { \ DPAA2_SET_FD_ADDR(_fd, DPAA2_MBUF_VADDR_TO_IOVA(_mbuf)); \ DPAA2_SET_FD_LEN(_fd, _mbuf->data_len); \
@@ -109,9 +116,10 @@ dpaa2_dev_rx_parse_new(struct rte_mbuf *m, const struct qbman_fd *fd, m->ol_flags |=PKT_RX_RSS_HASH ;if (dpaa2_enable_ts[m->port]) { - m->timestamp = annotation->word2; - m->ol_flags |=PKT_RX_TIMESTAMP ; -DPAA2_PMD_DP_DEBUG ("pkt timestamp:0x%" PRIx64"" , m->timestamp); + *dpaa2_timestamp_dynfield (m) = annotation->word2; + m->ol_flags |= dpaa2_timestamp_rx_dynflag; +DPAA2_PMD_DP_DEBUG ("pkt timestamp:0x%" PRIx64"" , + *dpaa2_timestamp_dynfield (m)); } DPAA2_PMD_DP_DEBUG("HW frc = 0x%x\t packet type =0x%x "
@@ -223,9 +231,12 @@ dpaa2_dev_rx_parse(struct rte_mbuf *mbuf, void *hw_annot_addr)else if (BIT_ISSET_AT_POS (annotation->word8,DPAA2_ETH_FAS_L4CE )) mbuf->ol_flags |=PKT_RX_L4_CKSUM_BAD ; - mbuf->ol_flags |=PKT_RX_TIMESTAMP ; - mbuf->timestamp = annotation->word2; -DPAA2_PMD_DP_DEBUG ("pkt timestamp: 0x%" PRIx64"" , mbuf->timestamp); +if (dpaa2_enable_ts[mbuf->port]) { + *dpaa2_timestamp_dynfield (mbuf) = annotation->word2; + mbuf->ol_flags |= dpaa2_timestamp_rx_dynflag; +DPAA2_PMD_DP_DEBUG ("pkt timestamp: 0x%" PRIx64"" , + *dpaa2_timestamp_dynfield (mbuf)); + }/* Check detailed parsing requirement */ if (annotation->word3 &0x7FFFFC3FFFF )
@@ -629,7 +640,7 @@ dpaa2_dev_prefetch_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)else bufs[num_rx] =eth_fd_to_mbuf (fd, eth_data->port_id);#if defined(RTE_LIBRTE_IEEE1588 ) - priv->rx_timestamp = bufs[num_rx]->timestamp; + priv->rx_timestamp = *dpaa2_timestamp_dynfield (bufs[num_rx]);#endif if (eth_data->dev_conf.rxmode.offloads &
Signature · 1 line
2.28.0
Re: [dpdk-dev] [PATCH v3 05/16] net/dpaa2: switch Rx timestamp to dynamic mbuf field
PATCH v3 6/16 net/mlx5: fix dynamic mbuf offset lookup check
In reply to Thomas MonjalonThe functions rte_mbuf_dynfield_lookup() and rte_mbuf_dynflag_lookup() can return an offset starting with 0 or a negative error code.
In reality the first offsets are probably reserved forever, but for the sake of strict API compliance,
the checks which considered 0 as an error are fixed.
--- drivers/net/mlx5/mlx5_rxtx.c | 4 ++-- drivers/net/mlx5/mlx5_trigger.c | 2 +- drivers/net/mlx5/mlx5_txq.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/mlx5/mlx5_rxtx.c +2 -2
@@ -5661,9 +5661,9 @@ mlx5_select_tx_function(struct rte_eth_dev *dev) }if (tx_offloads &DEV_TX_OFFLOAD_SEND_ON_TIMESTAMP &&rte_mbuf_dynflag_lookup - (RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME ,NULL ) >0 && + (RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME ,NULL ) >=0 &&rte_mbuf_dynfield_lookup - (RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ) >0 ) { + (RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ) >=0 ) {/* Offload configured, dynamic entities registered. */ olx |=MLX5_TXOFF_CONFIG_TXPP ; }
drivers/net/mlx5/mlx5_trigger.c +1 -1
@@ -302,7 +302,7 @@ mlx5_dev_start(struct rte_eth_dev *dev)DRV_LOG (DEBUG ,"port %u starting device" , dev->data->port_id); fine_inline =rte_mbuf_dynflag_lookup (RTE_PMD_MLX5_FINE_GRANULARITY_INLINE ,NULL ); -if (fine_inline >0 ) +if (fine_inline >=0 ) rte_net_mlx5_dynf_inline_mask =1UL << fine_inline;else rte_net_mlx5_dynf_inline_mask =0 ;
drivers/net/mlx5/mlx5_txq.c +1 -1
@@ -1305,7 +1305,7 @@ mlx5_txq_dynf_timestamp_set(struct rte_eth_dev *dev) (RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME ,NULL ); off =rte_mbuf_dynfield_lookup (RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ); -if (nbit >0 && off >=0 && sh->txpp.refcnt) +if (nbit >=0 && off >=0 && sh->txpp.refcnt) mask =1ULL << nbit;for (i =0 ; i != priv->txqs_n; ++i) { data = (*priv->txqs)[i];
Signature · 1 line
2.28.0
Re: [dpdk-dev] [PATCH v3 06/16] net/mlx5: fix dynamic mbuf offset lookup check
Quoted 18 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Tuesday, November 3, 2020 2:14
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Slava Ovsiienko <[email protected]>; [email protected]; Matan Azrad <[email protected]>; Shahaf Shuler <[email protected]>; Ori Kam <[email protected]>
Subject: [PATCH v3 06/16] net/mlx5: fix dynamic mbuf offset lookup checkThe functions
rte_mbuf_dynfield_lookup()andrte_mbuf_dynflag_lookup()can return an offset starting with 0 or a negative error code.In reality the first offsets are probably reserved forever, but for the sake of strict API compliance, the checks which considered 0 as an error are fixed.
Quoted 7 lines
Fixes efa79e68c8cd ("net/mlx5: support fine grain dynamic flag")Fixes 3172c471b86f ("net/mlx5: prepare Tx queue structures to supporttimestamp")
Fixes 0febfcce3693 ("net/mlx5: prepare Tx to support scheduling")Signed-off-by Thomas Monjalon <[email protected]>
Quoted 57 lines
--- drivers/net/mlx5/mlx5_rxtx.c | 4 ++-- drivers/net/mlx5/mlx5_trigger.c | 2 +- drivers/net/mlx5/mlx5_txq.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)drivers/net/mlx5/mlx5_rxtx.c index renamed from drivers/net/mlx5/mlx5_rxtx.c +0
-0
b530ff421f..e86468b67a100644drivers/net/mlx5/mlx5_rxtx.c +0
-1@@ -5661,9 +5661,9 @@ mlx5_select_tx_function(struct rte_eth_dev *dev) }if (tx_offloads &DEV_TX_OFFLOAD_SEND_ON_TIMESTAMP && rte_mbuf_dynflag_lookup - (RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME, NULL)Quoted 1 line
0 &&
drivers/net/mlx5/mlx5_rxtx.c +1
-0+ (RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME ,NULL )Quoted 1 line
= 0 &&
drivers/net/mlx5/mlx5_rxtx.c +0
-1rte_mbuf_dynfield_lookup - (RTE_MBUF_DYNFIELD_TIMESTAMP_NAME, NULL) >0) {
drivers/net/mlx5/mlx5_rxtx.c +1
-0+ (RTE_MBUF_DYNFIELD_TIMESTAMP_NAME, NULL) >=0) {
drivers/net/mlx5/mlx5_rxtx.c +0
-0/* Offload configured, dynamic entities registered. */ olx |=MLX5_TXOFF_CONFIG_TXPP ; }drivers/net/mlx5/mlx5_trigger.c +1
-1@@ -302,7 +302,7 @@ mlx5_dev_start(struct rte_eth_dev *dev)DRV_LOG (DEBUG ,"port %u starting device" , dev->data->port_id); fine_inline =rte_mbuf_dynflag_lookup (RTE_PMD_MLX5_FINE_GRANULARITY_INLINE ,NULL ); -if (fine_inline >0 ) +if (fine_inline >=0 ) rte_net_mlx5_dynf_inline_mask =1UL << fine_inline;else rte_net_mlx5_dynf_inline_mask =0 ;drivers/net/mlx5/mlx5_txq.c index renamed from drivers/net/mlx5/mlx5_txq.c +0
-0
af84f5f72b..8ed2bcff7b100644drivers/net/mlx5/mlx5_txq.c +1
-1@@ -1305,7 +1305,7 @@ mlx5_txq_dynf_timestamp_set(struct rte_eth_dev *dev) (RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME ,NULL ); off =rte_mbuf_dynfield_lookup (RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ); -if (nbit >0 && off >=0 && sh->txpp.refcnt) +if (nbit >=0 && off >=0 && sh->txpp.refcnt)drivers/net/mlx5/mlx5_txq.c +0
-1mask =1ULL << nbit;for (i =0 ; i != priv->txqs_n; ++i) { data = (*priv->txqs)[i]; --2.28.0
PATCH v3 7/16 net/mlx5: switch Rx timestamp to dynamic mbuf field
In reply to Thomas MonjalonThe mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced.
The dynamic offset and flag are stored in struct mlx5_rxq_data to favor cache locality.
--- drivers/net/mlx5/mlx5_rxq.c | 8 +++++ drivers/net/mlx5/mlx5_rxtx.c | 4 +-- drivers/net/mlx5/mlx5_rxtx.h | 19 +++++++++++ drivers/net/mlx5/mlx5_rxtx_vec_altivec.h | 41 +++++++++++----------- drivers/net/mlx5/mlx5_rxtx_vec_neon.h | 43 ++++++++++++------------ drivers/net/mlx5/mlx5_rxtx_vec_sse.h | 35 +++++++++---------- 6 files changed, 90 insertions(+), 60 deletions(-)
drivers/net/mlx5/mlx5_rxq.c +8 -0
@@ -1492,7 +1492,15 @@ mlx5_rxq_new(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,mlx5_max_lro_msg_size_adjust (dev, idx, max_lro_size);/* Toggle RX checksum offload if hardware supports it. */ tmpl->rxq.csum = !!(offloads &DEV_RX_OFFLOAD_CHECKSUM ); +/* Configure Rx timestamp. */ tmpl->rxq.hw_timestamp = !!(offloads &DEV_RX_OFFLOAD_TIMESTAMP ); + tmpl->rxq.timestamp_rx_flag =0 ; +if (tmpl->rxq.hw_timestamp &&rte_mbuf_dyn_rx_timestamp_register ( + &tmpl->rxq.timestamp_offset, + &tmpl->rxq.timestamp_rx_flag) !=0 ) { +DRV_LOG (ERR ,"Cannot register Rx timestamp field/flag" ); + goto error; + }/* Configure VLAN stripping. */ tmpl->rxq.vlan_strip = !!(offloads &DEV_RX_OFFLOAD_VLAN_STRIP );/* By default, FCS (CRC) is stripped by hardware. */
drivers/net/mlx5/mlx5_rxtx.c +2 -2
@@ -1287,8 +1287,8 @@ rxq_cq_to_mbuf(struct mlx5_rxq_data *rxq, struct rte_mbuf *pkt,if (rxq->rt_timestamp) ts =mlx5_txpp_convert_rx_ts (rxq->sh, ts); - pkt->timestamp = ts; - pkt->ol_flags |=PKT_RX_TIMESTAMP ; +mlx5_timestamp_set (pkt, rxq->timestamp_offset, ts); + pkt->ol_flags |= rxq->timestamp_rx_flag; } }
drivers/net/mlx5/mlx5_rxtx.h +19 -0
@@ -151,6 +151,8 @@ struct mlx5_rxq_data {/* CQ (UAR) access lock required for 32bit implementations */ #endif uint32_t tunnel;/* Tunnel information. */ +int timestamp_offset;/* Dynamic mbuf field for timestamp. */ +uint64_t timestamp_rx_flag;/* Dynamic mbuf flag for timestamp. */ uint64_t flow_meta_mask;int32_t flow_meta_offset; } __rte_cache_aligned;
@@ -681,4 +683,21 @@ mlx5_txpp_convert_tx_ts(struct mlx5_dev_ctx_shared *sh, uint64_t mts) return ci; } +/** +* Set timestamp in mbuf dynamic field. +* +* @param mbuf +* Structure to write into. +* @param offset +* Dynamic field offset in mbuf structure. +* @param timestamp +* Value to write. +*/ +static __rte_always_inline void +mlx5_timestamp_set (struct rte_mbuf *mbuf,int offset, +rte_mbuf_timestamp_t timestamp) +{ + *RTE_MBUF_DYNFIELD(mbuf, offset, rte_mbuf_timestamp_t *) = timestamp; +} +#endif /* RTE_PMD_MLX5_RXTX_H_ */
drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +21 -20
65 lines not on this page · raw message
drivers/net/mlx5/mlx5_rxtx_vec_neon.h +22 -21
71 lines not on this page · raw message
drivers/net/mlx5/mlx5_rxtx_vec_sse.h +18 -17
@@ -251,7 +251,7 @@ rxq_cq_to_ptype_oflags_v(struct mlx5_rxq_data *rxq, __m128i cqes[4],__m128i pinfo0, pinfo1;__m128i pinfo, ptype;__m128i ol_flags =_mm_set1_epi32 (rxq->rss_hash *PKT_RX_RSS_HASH | - rxq->hw_timestamp *PKT_RX_TIMESTAMP ); + rxq->hw_timestamp * rxq->timestamp_rx_flag);__m128i cv_flags;const __m128i zero =_mm_setzero_si128 (); const __m128i ptype_mask =
@@ -656,31 +656,32 @@ rxq_burst_v(struct mlx5_rxq_data *rxq, struct rte_mbuf **pkts, uint16_t pkts_n,/* D.5 fill in mbuf - rearm_data and packet_type. */ rxq_cq_to_ptype_oflags_v (rxq, cqes, opcode, &pkts[pos]);if (rxq->hw_timestamp) { +int offset = rxq->timestamp_offset;if (rxq->rt_timestamp) {struct mlx5_dev_ctx_shared *sh = rxq->sh;uint64_t ts; ts =rte_be_to_cpu_64 (cq[pos].timestamp); - pkts[pos]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (pkts[pos], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); ts =rte_be_to_cpu_64 (cq[pos + p1].timestamp); - pkts[pos +1 ]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (pkts[pos +1 ], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); ts =rte_be_to_cpu_64 (cq[pos + p2].timestamp); - pkts[pos +2 ]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (pkts[pos +2 ], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); ts =rte_be_to_cpu_64 (cq[pos + p3].timestamp); - pkts[pos +3 ]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (pkts[pos +3 ], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); }else { - pkts[pos]->timestamp =rte_be_to_cpu_64 - (cq[pos].timestamp); - pkts[pos +1 ]->timestamp =rte_be_to_cpu_64 - (cq[pos + p1].timestamp); - pkts[pos +2 ]->timestamp =rte_be_to_cpu_64 - (cq[pos + p2].timestamp); - pkts[pos +3 ]->timestamp =rte_be_to_cpu_64 - (cq[pos + p3].timestamp); +mlx5_timestamp_set (pkts[pos], offset, +rte_be_to_cpu_64 (cq[pos].timestamp)); +mlx5_timestamp_set (pkts[pos +1 ], offset, +rte_be_to_cpu_64 (cq[pos + p1].timestamp)); +mlx5_timestamp_set (pkts[pos +2 ], offset, +rte_be_to_cpu_64 (cq[pos + p2].timestamp)); +mlx5_timestamp_set (pkts[pos +3 ], offset, +rte_be_to_cpu_64 (cq[pos + p3].timestamp)); } }if (rxq->dynf_meta) {
Signature · 1 line
2.28.0
Re: [dpdk-dev] [PATCH v3 07/16] net/mlx5: switch Rx timestamp to dynamic mbuf field
Quoted 18 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Tuesday, November 3, 2020 2:14
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Slava Ovsiienko <[email protected]>; Ruifeng Wang <[email protected]>; David Christensen <[email protected]>; Matan Azrad <[email protected]>; Shahaf Shuler <[email protected]>; Konstantin Ananyev <[email protected]>
Subject: [PATCH v3 07/16] net/mlx5: switch Rx timestamp to dynamic mbuf fieldThe mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field.
The related mbuf flag is also replaced.
Quoted 6 lines
The dynamic offset and flag are stored in struct
mlx5_rxq_datato favor cache locality.Signed-off-by Thomas Monjalon <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>Reviewed-by David Christensen <[email protected]>
Quoted 331 lines
--- drivers/net/mlx5/mlx5_rxq.c | 8 +++++ drivers/net/mlx5/mlx5_rxtx.c | 4 +-- drivers/net/mlx5/mlx5_rxtx.h | 19 +++++++++++ drivers/net/mlx5/mlx5_rxtx_vec_altivec.h | 41 +++++++++++----------- drivers/net/mlx5/mlx5_rxtx_vec_neon.h | 43 ++++++++++++------------ drivers/net/mlx5/mlx5_rxtx_vec_sse.h | 35 +++++++++---------- 6 files changed, 90 insertions(+), 60 deletions(-)drivers/net/mlx5/mlx5_rxq.c index renamed from drivers/net/mlx5/mlx5_rxq.c +0
-0
f1d8373079..52519910ee100644drivers/net/mlx5/mlx5_rxq.c +3
-0@@ -1492,7 +1492,15 @@ mlx5_rxq_new(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,mlx5_max_lro_msg_size_adjust (dev, idx, max_lro_size);/* Toggle RX checksum offload if hardware supports it. */ tmpl->rxq.csum = !!(offloads &DEV_RX_OFFLOAD_CHECKSUM ); +/* Configure Rx timestamp. */ tmpl->rxq.hw_timestamp = !!(offloads &DEV_RX_OFFLOAD_TIMESTAMP ); + tmpl->rxq.timestamp_rx_flag =0 ; + if (tmpl->rxq.hw_timestamp &&rte_mbuf_dyn_rx_timestamp_register(
drivers/net/mlx5/mlx5_rxq.c +5
-0+ &tmpl->rxq.timestamp_offset, + &tmpl->rxq.timestamp_rx_flag) != 0) { +DRV_LOG (ERR ,"Cannot register Rx timestamp field/flag" ); + goto error; + }/* Configure VLAN stripping. */ tmpl->rxq.vlan_strip = !!(offloads &DEV_RX_OFFLOAD_VLAN_STRIP ); /* By default, FCS (CRC) is stripped by hardware. */ diff --git
a/drivers/net/mlx5/mlx5_rxtx.cb/drivers/net/mlx5/mlx5_rxtx.cindexe86468b67a..b577aab00b100644drivers/net/mlx5/mlx5_rxtx.c +2
-2@@ -1287,8 +1287,8 @@ rxq_cq_to_mbuf(struct mlx5_rxq_data *rxq, struct rte_mbuf *pkt, if (rxq->rt_timestamp) ts = mlx5_txpp_convert_rx_ts(rxq->sh, ts); - pkt->timestamp = ts; - pkt->ol_flags |=PKT_RX_TIMESTAMP ; +mlx5_timestamp_set (pkt, rxq->timestamp_offset, ts); + pkt->ol_flags |= rxq->timestamp_rx_flag; } }drivers/net/mlx5/mlx5_rxtx.h index renamed from drivers/net/mlx5/mlx5_rxtx.h +0
-0
674296ee98..e9eca36b40100644drivers/net/mlx5/mlx5_rxtx.h +17
-0@@ -151,6 +151,8 @@ struct mlx5_rxq_data {/* CQ (UAR) access lock required for 32bit implementations */ #endif uint32_t tunnel;/* Tunnel information. */ +int timestamp_offset;/* Dynamic mbuf field for timestamp. */ +uint64_t timestamp_rx_flag;/* Dynamic mbuf flag for timestamp. */ uint64_t flow_meta_mask;int32_t flow_meta_offset; } __rte_cache_aligned;@@ -681,4 +683,21 @@ mlx5_txpp_convert_tx_ts(struct mlx5_dev_ctx_shared *sh, uint64_t mts) return ci; } +/** +* Set timestamp in mbuf dynamic field. +* +* @param mbuf +* Structure to write into. +* @param offset +* Dynamic field offset in mbuf structure. +* @param timestamp +* Value to write. +*/ +static __rte_always_inline void +mlx5_timestamp_set (struct rte_mbuf *mbuf,int offset, +rte_mbuf_timestamp_t timestamp) +{ + *RTE_MBUF_DYNFIELD(mbuf, offset, rte_mbuf_timestamp_t *) =timestamp;
drivers/net/mlx5/mlx5_rxtx.h +2
-0+} +#endif /* RTE_PMD_MLX5_RXTX_H_ */ drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +4
-4@@ -330,13 +330,13 @@ rxq_cq_to_ptype_oflags_v(struct mlx5_rxq_data *rxq, vector unsigned char ol_flags = (vector unsigned char) (vector unsigned int){ rxq->rss_hash *PKT_RX_RSS_HASH | - rxq->hw_timestamp *PKT_RX_TIMESTAMP , + rxq->hw_timestamp * rxq- >timestamp_rx_flag, rxq->rss_hash *PKT_RX_RSS_HASH | - rxq->hw_timestamp *PKT_RX_TIMESTAMP , + rxq->hw_timestamp * rxq- >timestamp_rx_flag, rxq->rss_hash *PKT_RX_RSS_HASH | - rxq->hw_timestamp *PKT_RX_TIMESTAMP , + rxq->hw_timestamp * rxq- >timestamp_rx_flag, rxq->rss_hash *PKT_RX_RSS_HASH | - rxq->hw_timestamp *PKT_RX_TIMESTAMP }; + rxq->hw_timestamp * rxq-Quoted 1 line
timestamp_rx_flag};drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +0
-0vector unsigned char cv_flags; const vector unsigned char zero = (vector unsigned char){0}; const vector unsigned char ptype_mask = @@ -1025,31 +1025,32 @@rxq_burst_v(struct
mlx5_rxq_data*rxq, structrte_mbuf**pkts,uint16_tpkts_n,drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +3
-2/* D.5 fill in mbuf - rearm_data and packet_type. */ rxq_cq_to_ptype_oflags_v (rxq, cqes, opcode, &pkts[pos]);if (rxq->hw_timestamp) { +int offset = rxq->timestamp_offset;if (rxq->rt_timestamp) {struct mlx5_dev_ctx_shared *sh = rxq->sh;uint64_t ts; ts =rte_be_to_cpu_64 (cq[pos].timestamp); - pkts[pos]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (pkts[pos], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); ts = rte_be_to_cpu_64(cq[pos +p1].timestamp);
drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +2
-2- pkts[pos +1 ]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (pkts[pos +1 ], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); ts = rte_be_to_cpu_64(cq[pos +p2].timestamp);
drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +2
-2- pkts[pos +2 ]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (pkts[pos +2 ], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); ts = rte_be_to_cpu_64(cq[pos +p3].timestamp);
drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +4
-10- pkts[pos +3 ]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (pkts[pos +3 ], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); }else { - pkts[pos]->timestamp =rte_be_to_cpu_64 - (cq[pos].timestamp); - pkts[pos +1 ]->timestamp =rte_be_to_cpu_64 - (cq[pos + p1].timestamp); - pkts[pos +2 ]->timestamp =rte_be_to_cpu_64 - (cq[pos + p2].timestamp); - pkts[pos +3 ]->timestamp =rte_be_to_cpu_64 - (cq[pos + p3].timestamp); + mlx5_timestamp_set(pkts[pos], offset, +rte_be_to_cpu_64(cq[pos].timestamp));drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +2
-0+ mlx5_timestamp_set(pkts[pos + 1], offset, + rte_be_to_cpu_64(cq[pos +p1].timestamp));
drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +2
-0+ mlx5_timestamp_set(pkts[pos + 2], offset, + rte_be_to_cpu_64(cq[pos +p2].timestamp));
drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +2
-0+ mlx5_timestamp_set(pkts[pos + 3], offset, + rte_be_to_cpu_64(cq[pos +p3].timestamp));
drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +0
-0} }if (rxq->dynf_meta) {drivers/net/mlx5/mlx5_rxtx_vec_neon.h +2
-1@@ -271,7 +271,7 @@ rxq_cq_to_ptype_oflags_v(struct mlx5_rxq_data *rxq,uint32x4_t pinfo, cv_flags;uint32x4_t ol_flags =vdupq_n_u32 (rxq->rss_hash *PKT_RX_RSS_HASH | - rxq->hw_timestamp *PKT_RX_TIMESTAMP ); + rxq->hw_timestamp * rxq->timestamp_rx_flag);const uint32x4_t ptype_ol_mask = {0x106 ,0x106 ,0x106 ,0x106 };const uint8x16_t cv_flag_sel = {0 ,@@ -697,6 +697,7 @@ rxq_burst_v(struct mlx5_rxq_data *rxq, struct rte_mbuf **pkts, uint16_t pkts_n,rxq_cq_to_ptype_oflags_v (rxq ,ptype_info ,flow_tag , opcode, &elts[pos]);if (rxq->hw_timestamp) { +int offset = rxq->timestamp_offset;if (rxq->rt_timestamp) {struct mlx5_dev_ctx_shared *sh = rxq->sh;drivers/net/mlx5/mlx5_rxtx_vec_neon.h +17
-20uint64_t ts;@@ -704,36 +705,36 @@ rxq_burst_v(struct mlx5_rxq_data *rxq, struct rte_mbuf **pkts, uint16_t pkts_n, ts =rte_be_to_cpu_64 (container_of(p0, struct mlx5_cqe, pkt_info)->timestamp); - elts[pos]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (elts[pos], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); ts =rte_be_to_cpu_64 (container_of(p1, struct mlx5_cqe, pkt_info)->timestamp); - elts[pos +1 ]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (elts[pos +1 ], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); ts =rte_be_to_cpu_64 (container_of(p2, struct mlx5_cqe, pkt_info)->timestamp); - elts[pos +2 ]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (elts[pos +2 ], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); ts =rte_be_to_cpu_64 (container_of(p3, struct mlx5_cqe, pkt_info)->timestamp); - elts[pos +3 ]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (elts[pos +3 ], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); }else { - elts[pos]->timestamp =rte_be_to_cpu_64 - (container_of(p0, struct mlx5_cqe, - pkt_info)->timestamp); - elts[pos +1 ]->timestamp =rte_be_to_cpu_64 - (container_of(p1, struct mlx5_cqe, - pkt_info)->timestamp); - elts[pos +2 ]->timestamp =rte_be_to_cpu_64 - (container_of(p2, struct mlx5_cqe, - pkt_info)->timestamp); - elts[pos +3 ]->timestamp =rte_be_to_cpu_64 - (container_of(p3, struct mlx5_cqe, - pkt_info)->timestamp); +mlx5_timestamp_set (elts[pos], offset, +rte_be_to_cpu_64 (container_of (p0, + struct mlx5_cqe, pkt_info)- >timestamp)); +mlx5_timestamp_set (elts[pos +1 ], offset, +rte_be_to_cpu_64 (container_of (p1, + struct mlx5_cqe, pkt_info)- >timestamp)); + mlx5_timestamp_set(elts[pos + 2], offset, + rte_be_to_cpu_64(container_of(p2, + struct mlx5_cqe, pkt_info)-Quoted 1 line
timestamp));
drivers/net/mlx5/mlx5_rxtx_vec_neon.h +3
-0+ mlx5_timestamp_set(elts[pos + 3], offset, + rte_be_to_cpu_64(container_of(p3, + struct mlx5_cqe, pkt_info)-Quoted 1 line
timestamp));
drivers/net/mlx5/mlx5_rxtx_vec_neon.h +0
-0} }if (rxq->dynf_meta) {drivers/net/mlx5/mlx5_rxtx_vec_sse.h +0
-0@@ -251,7 +251,7 @@ rxq_cq_to_ptype_oflags_v(struct mlx5_rxq_data *rxq,__m128i cqes[4 ], __m128i pinfo0, pinfo1;__m128i pinfo, ptype; __m128i ol_flags = _mm_set1_epi32(rxq->rss_hash *
PKT_RX_RSS_HASH|drivers/net/mlx5/mlx5_rxtx_vec_sse.h +0
-1- rxq->hw_timestamp *
PKT_RX_TIMESTAMP);drivers/net/mlx5/mlx5_rxtx_vec_sse.h +1
-0+ rxq->hw_timestamp * rxq-Quoted 1 line
timestamp_rx_flag);drivers/net/mlx5/mlx5_rxtx_vec_sse.h +11
-16__m128i cv_flags;const __m128i zero =_mm_setzero_si128 (); const __m128i ptype_mask =@@ -656,31 +656,32 @@ rxq_burst_v(struct mlx5_rxq_data *rxq, struct rte_mbuf **pkts, uint16_t pkts_n,/* D.5 fill in mbuf - rearm_data and packet_type. */ rxq_cq_to_ptype_oflags_v(rxq, cqes, opcode, &pkts[pos]);if (rxq->hw_timestamp) { +int offset = rxq->timestamp_offset;if (rxq->rt_timestamp) {struct mlx5_dev_ctx_shared *sh = rxq->sh;uint64_t ts; ts =rte_be_to_cpu_64 (cq[pos].timestamp); - pkts[pos]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (pkts[pos], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); ts =rte_be_to_cpu_64 (cq[pos + p1].timestamp); - pkts[pos +1 ]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (pkts[pos +1 ], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); ts =rte_be_to_cpu_64 (cq[pos + p2].timestamp); - pkts[pos +2 ]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (pkts[pos +2 ], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); ts =rte_be_to_cpu_64 (cq[pos + p3].timestamp); - pkts[pos +3 ]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (pkts[pos +3 ], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); }else { - pkts[pos]->timestamp =rte_be_to_cpu_64 - (cq[pos].timestamp); - pkts[pos +1 ]->timestamp =rte_be_to_cpu_64 - (cq[pos + p1].timestamp); - pkts[pos +2 ]->timestamp =rte_be_to_cpu_64 - (cq[pos + p2].timestamp); - pkts[pos +3 ]->timestamp =rte_be_to_cpu_64 - (cq[pos + p3].timestamp); + mlx5_timestamp_set(pkts[pos], offset, +rte_be_to_cpu_64(cq[pos].timestamp));drivers/net/mlx5/mlx5_rxtx_vec_sse.h +2
-0+ mlx5_timestamp_set(pkts[pos + 1], offset, + rte_be_to_cpu_64(cq[pos +p1].timestamp));
drivers/net/mlx5/mlx5_rxtx_vec_sse.h +2
-0+ mlx5_timestamp_set(pkts[pos + 2], offset, + rte_be_to_cpu_64(cq[pos +p2].timestamp));
drivers/net/mlx5/mlx5_rxtx_vec_sse.h +2
-0+ mlx5_timestamp_set(pkts[pos + 3], offset, + rte_be_to_cpu_64(cq[pos +p3].timestamp));
drivers/net/mlx5/mlx5_rxtx_vec_sse.h +0
-1} }if (rxq->dynf_meta) { --2.28.0
PATCH v3 8/16 net/nfb: switch Rx timestamp to dynamic mbuf field
In reply to Thomas MonjalonThe mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced.
--- drivers/net/nfb/nfb_rx.c | 15 ++++++++++++++- drivers/net/nfb/nfb_rx.h | 18 ++++++++++++++---- 2 files changed, 28 insertions(+), 5 deletions(-)
drivers/net/nfb/nfb_rx.c +14 -1
@@ -9,6 +9,9 @@#include "nfb_rx.h" #include "nfb.h" +uint64_t nfb_timestamp_rx_dynflag; +int nfb_timestamp_dynfield_offset =-1 ; +static int timestamp_check_handler(__rte_unused const char *key, const char *value, __rte_unused void *opaque)
@@ -24,6 +27,7 @@ static int nfb_check_timestamp(struct rte_devargs *devargs) {struct rte_kvargs *kvlist; +int ret;if (devargs ==NULL )return 0 ;
@@ -38,6 +42,7 @@ nfb_check_timestamp(struct rte_devargs *devargs) }/* Timestamps are enabled when there is * key-value pair: enable_timestamp=1 +* TODO: timestamp should be enabled with DEV_RX_OFFLOAD_TIMESTAMP */ if (rte_kvargs_process (kvlist,TIMESTAMP_ARG , timestamp_check_handler,NULL ) <0 ) {
@@ -46,6 +51,14 @@ nfb_check_timestamp(struct rte_devargs *devargs) }rte_kvargs_free (kvlist); + ret =rte_mbuf_dyn_rx_timestamp_register ( + &nfb_timestamp_dynfield_offset, + &nfb_timestamp_rx_dynflag); +if (ret !=0 ) { +RTE_LOG (ERR ,PMD ,"Cannot register Rx timestamp field/flag\n" ); +return -rte_errno; + } +return 1 ; }
@@ -125,7 +138,7 @@ nfb_eth_rx_queue_setup(struct rte_eth_dev *dev,else rte_free (rxq); -if (nfb_check_timestamp (dev->device->devargs)) +if (nfb_check_timestamp (dev->device->devargs) >0 ) rxq->flags |=NFB_TIMESTAMP_FLAG ;return ret;
drivers/net/nfb/nfb_rx.h +14 -4
@@ -15,6 +15,16 @@#define NFB_TIMESTAMP_FLAG (1 << 0) +extern uint64_t nfb_timestamp_rx_dynflag; +extern int nfb_timestamp_dynfield_offset; + +static inline rte_mbuf_timestamp_t * +nfb_timestamp_dynfield (struct rte_mbuf *mbuf) +{ +return RTE_MBUF_DYNFIELD (mbuf, + nfb_timestamp_dynfield_offset, rte_mbuf_timestamp_t *); +} +struct ndp_rx_queue {struct nfb_device *nfb;/* nfb dev structure */ struct ndp_queue *queue;/* rx queue */
@@ -191,15 +201,15 @@ nfb_eth_ndp_rx(void *queue,if (timestamping_enabled) {/* nanoseconds */ - mbuf->timestamp = + *nfb_timestamp_dynfield (mbuf) =rte_le_to_cpu_32 (*((uint32_t *) (packets[i].header +4 ))); - mbuf->timestamp <<=32 ; + *nfb_timestamp_dynfield (mbuf) <<=32 ;/* seconds */ - mbuf->timestamp |= + *nfb_timestamp_dynfield (mbuf) |=rte_le_to_cpu_32 (*((uint32_t *) (packets[i].header +8 ))); - mbuf->ol_flags |=PKT_RX_TIMESTAMP ; + mbuf->ol_flags |= nfb_timestamp_rx_dynflag; } bufs[num_rx++] = mbuf;
Signature · 1 line
2.28.0
Re: [dpdk-dev] [PATCH v3 08/16] net/nfb: switch Rx timestamp to dynamic mbuf field
Quoted 9 lines · Thomas Monjalon
The mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced.
Signed-off-by Thomas Monjalon <[email protected]>--- drivers/net/nfb/nfb_rx.c | 15 ++++++++++++++- drivers/net/nfb/nfb_rx.h | 18 ++++++++++++++---- 2 files changed, 28 insertions(+), 5 deletions(-)
<...>
Quoted 30 lines
index
cf3899b2fb..e548226e0f100644drivers/net/nfb/nfb_rx.h +12
-2@@ -15,6 +15,16 @@#define NFB_TIMESTAMP_FLAG (1 << 0) +extern uint64_t nfb_timestamp_rx_dynflag; +extern int nfb_timestamp_dynfield_offset; + +static inline rte_mbuf_timestamp_t * +nfb_timestamp_dynfield (struct rte_mbuf *mbuf) +{ +return RTE_MBUF_DYNFIELD (mbuf, + nfb_timestamp_dynfield_offset, rte_mbuf_timestamp_t *); +} +struct ndp_rx_queue {struct nfb_device *nfb;/* nfb dev structure */ struct ndp_queue *queue;/* rx queue */ @@ -191,15 +201,15 @@ nfb_eth_ndp_rx(void *queue,if (timestamping_enabled) {/* nanoseconds */ - mbuf->timestamp = + *nfb_timestamp_dynfield (mbuf) =rte_le_to_cpu_32 (*((uint32_t *) (packets[i].header +4 ))); - mbuf->timestamp <<=32 ; + *nfb_timestamp_dynfield (mbuf) <<=32 ;
drivers/net/nfb/nfb_rx.h nfb_eth_ndp_rx(void *queue, · line 215
Quoted 10 lines
drivers/net/nfb/nfb_rx.h +2
-2/* seconds */ - mbuf->timestamp |= + *nfb_timestamp_dynfield (mbuf) |=rte_le_to_cpu_32 (*((uint32_t *) (packets[i].header +8 ))); - mbuf->ol_flags |=PKT_RX_TIMESTAMP ; + mbuf->ol_flags |= nfb_timestamp_rx_dynflag; } bufs[num_rx++] = mbuf;
I think it would be better with a local variable.
PATCH v3 9/16 net/octeontx2: switch Rx timestamp to dynamic mbuf field
In reply to Thomas MonjalonThe mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced.
The dynamic offset and flag are stored in struct otx2_timesync_info to favor cache locality.
--- drivers/net/octeontx2/otx2_ethdev.c | 10 ++++++++++ drivers/net/octeontx2/otx2_rx.h | 19 ++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-)
drivers/net/octeontx2/otx2_ethdev.c +10 -0
@@ -2219,6 +2219,16 @@ otx2_nix_dev_start(struct rte_eth_dev *eth_dev)else otx2_nix_timesync_disable (eth_dev); +if (dev->rx_offload_flags &NIX_RX_OFFLOAD_TSTAMP_F ) { + rc =rte_mbuf_dyn_rx_timestamp_register ( + &dev->tstamp.tstamp_dynfield_offset, + &dev->tstamp.rx_tstamp_dynflag); +if (rc !=0 ) { +otx2_err ("Failed to register Rx timestamp field/flag" ); +return -rte_errno; + } + } +/* Update VF about data off shifted by 8 bytes if PTP already * enabled in PF owning this VF */
drivers/net/octeontx2/otx2_rx.h +16 -3
@@ -49,6 +49,8 @@ struct otx2_timesync_info {uint64_t rx_tstamp;rte_iova_t tx_tstamp_iova;uint64_t *tx_tstamp; +uint64_t rx_tstamp_dynflag; +int tstamp_dynfield_offset;uint8_t tx_ready;uint8_t rx_ready; } __rte_cache_aligned;
@@ -63,6 +65,14 @@ union mbuf_initializer {uint64_t value; }; +static inline rte_mbuf_timestamp_t * +otx2_timestamp_dynfield (struct rte_mbuf *mbuf, +struct otx2_timesync_info *info) +{ +return RTE_MBUF_DYNFIELD (mbuf, + info->tstamp_dynfield_offset, rte_mbuf_timestamp_t *); +} + static __rte_always_inline void otx2_nix_mbuf_to_tstamp(struct rte_mbuf *mbuf, struct otx2_timesync_info *tstamp, const uint16_t flag,
@@ -77,15 +87,18 @@ otx2_nix_mbuf_to_tstamp(struct rte_mbuf *mbuf,/* Reading the rx timestamp inserted by CGX, viz at * starting of the packet data. */ - mbuf->timestamp =rte_be_to_cpu_64 (*tstamp_ptr); + *otx2_timestamp_dynfield (mbuf, tstamp) = +rte_be_to_cpu_64 (*tstamp_ptr);/* PKT_RX_IEEE1588_TMST flag needs to be set only in case * PTP packets are received. */ if (mbuf->packet_type ==RTE_PTYPE_L2_ETHER_TIMESYNC ) { - tstamp->rx_tstamp = mbuf->timestamp; + tstamp->rx_tstamp = + *otx2_timestamp_dynfield (mbuf, tstamp); tstamp->rx_ready =1 ; mbuf->ol_flags |=PKT_RX_IEEE1588_PTP | -PKT_RX_IEEE1588_TMST |PKT_RX_TIMESTAMP ; +PKT_RX_IEEE1588_TMST | + tstamp->rx_tstamp_dynflag; } } }
Signature · 1 line
2.28.0
Re: [dpdk-dev] [PATCH v3 09/16] net/octeontx2: switch Rx timestamp to dynamic mbuf field
Quoted 8 lines · Thomas Monjalon
The mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced.
The dynamic offset and flag are stored in struct
otx2_timesync_infoto favor cache locality.Signed-off-by Thomas Monjalon <[email protected]>
Hi Thomas,
With the following changes, ptpclient and testpmd(ieee1588 mode) is crashing for us. I am debugging the issue and will update soon.
------------------
Steps to reproduce:
1. Testpmd:
./dpdk-testpmd -c 0xffff01 -n 4 -w 0002:05:00.0 -- -i
--port-topology=loop
testpmd> set fwd ieee1588
testpmd> set port 0 ptype_mask 0xf
testpmd> start
I am sending ptp packets using scapy from the peer:
>>> p = Ether(src='98:03:9b:67:b0:d0', dst='FA:62:0C:27:AD:BC',
>>> type=35063)/Raw(load='\x00\x02')
>>> sendp (p, iface="p5p2")
I am observing seg fault even for 1 packet.
2. ./ptpclient -l 1 -n 4 -w 0002:05:00.0 -- -p 0xf -- on board
ptp4l -E -2 -H -i p5p2 -m -q -p /dev/ptp4 ... on peerThanks
Harman
Quoted 79 lines
--- drivers/net/octeontx2/otx2_ethdev.c | 10 ++++++++++ drivers/net/octeontx2/otx2_rx.h | 19 ++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-)drivers/net/octeontx2/otx2_ethdev.c +10
-0@@ -2219,6 +2219,16 @@ otx2_nix_dev_start(struct rte_eth_dev *eth_dev)else otx2_nix_timesync_disable (eth_dev); +if (dev->rx_offload_flags &NIX_RX_OFFLOAD_TSTAMP_F ) { + rc =rte_mbuf_dyn_rx_timestamp_register ( + &dev->tstamp.tstamp_dynfield_offset, + &dev->tstamp.rx_tstamp_dynflag); +if (rc !=0 ) { +otx2_err ("Failed to register Rx timestamp field/flag" ); +return -rte_errno; + } + } +/* Update VF about data off shifted by 8 bytes if PTP already * enabled in PF owning this VF */ drivers/net/octeontx2/otx2_rx.h +16
-3@@ -49,6 +49,8 @@ struct otx2_timesync_info {uint64_t rx_tstamp;rte_iova_t tx_tstamp_iova;uint64_t *tx_tstamp; +uint64_t rx_tstamp_dynflag; +int tstamp_dynfield_offset;uint8_t tx_ready;uint8_t rx_ready; } __rte_cache_aligned;@@ -63,6 +65,14 @@ union mbuf_initializer {uint64_t value; }; +static inline rte_mbuf_timestamp_t * +otx2_timestamp_dynfield (struct rte_mbuf *mbuf, +struct otx2_timesync_info *info) +{ +return RTE_MBUF_DYNFIELD (mbuf, + info->tstamp_dynfield_offset, rte_mbuf_timestamp_t *); +} + static __rte_always_inline void otx2_nix_mbuf_to_tstamp(struct rte_mbuf *mbuf, struct otx2_timesync_info *tstamp, const uint16_t flag,@@ -77,15 +87,18 @@ otx2_nix_mbuf_to_tstamp(struct rte_mbuf *mbuf,/* Reading the rx timestamp inserted by CGX, viz at * starting of the packet data. */ - mbuf->timestamp =rte_be_to_cpu_64 (*tstamp_ptr); + *otx2_timestamp_dynfield (mbuf, tstamp) = +rte_be_to_cpu_64 (*tstamp_ptr);/* PKT_RX_IEEE1588_TMST flag needs to be set only in case * PTP packets are received. */ if (mbuf->packet_type ==RTE_PTYPE_L2_ETHER_TIMESYNC ) { - tstamp->rx_tstamp = mbuf->timestamp; + tstamp->rx_tstamp = + *otx2_timestamp_dynfield (mbuf, tstamp); tstamp->rx_ready =1 ; mbuf->ol_flags |=PKT_RX_IEEE1588_PTP | -PKT_RX_IEEE1588_TMST |PKT_RX_TIMESTAMP ; +PKT_RX_IEEE1588_TMST | + tstamp->rx_tstamp_dynflag; } } }Signature · 1 line
2.28.0
Re: [dpdk-dev] [PATCH v3 09/16] net/octeontx2: switch Rx timestamp to dynamic mbuf field
03/11/2020 11:52, Harman Kalra:
Quoted 4 lines
With the following changes, ptpclient and testpmd(ieee1588 mode) is crashing for us. I am debugging the issue and will update soon.
------------------
Steps to reproduce:
Quoted 13 lines
1. Testpmd:
./dpdk-testpmd -c 0xffff01 -n 4 -w 0002:05:00.0 -- -i
--port-topology=loop
testpmd> set fwd ieee1588
testpmd> set port 0 ptype_mask 0xf
testpmd> start
I am sending ptp packets using scapy from the peer:
>>> p = Ether(src='98:03:9b:67:b0:d0', dst='FA:62:0C:27:AD:BC',
>>> type=35063)/Raw(load='\x00\x02')
>>> sendp (p, iface="p5p2")
I am observing seg fault even for 1 packet.Where is the crash? Could you provide a backtrace? Is the field well registered?
Re: [dpdk-dev] [PATCH v3 09/16] net/octeontx2: switch Rx timestamp to dynamic mbuf field
03/11/2020 12:22, Thomas Monjalon:
Quoted 17 lines
03/11/2020 11:52, Harman Kalra:
Quoted 16 lines
With the following changes, ptpclient and testpmd(ieee1588 mode) is crashing for us. I am debugging the issue and will update soon.
------------------
Steps to reproduce:1. Testpmd: ./dpdk-testpmd -c 0xffff01 -n 4 -w 0002:05:00.0 -- -i --port-topology=loop testpmd> set fwd ieee1588 testpmd> set port 0 ptype_mask 0xf testpmd> start I am sending ptp packets using scapy from the peer: >>> p = Ether(src='98:03:9b:67:b0:d0', dst='FA:62:0C:27:AD:BC', >>> type=35063)/Raw(load='\x00\x02') >>> sendp (p, iface="p5p2")
Quoted 4 lines
Quoted 1 line
I am observing seg fault even for 1 packet.
Where is the crash? Could you provide a backtrace? Is the field well registered?
Sorry Harman, without any more explanation, we must move forward. I am going to send a v4 without any change for octeontx2. It should be merged today for -rc2.
Re: [dpdk-dev] [EXT] Re: [PATCH v3 09/16] net/octeontx2: switch Rx timestamp to dynamic mbuf field
Quoted 21 lines · Thomas Monjalon
External Email
----------------------------------------------------------------------
03/11/2020 12:22, Thomas Monjalon:Quoted 17 lines
03/11/2020 11:52, Harman Kalra:
Quoted 16 lines
With the following changes, ptpclient and testpmd(ieee1588 mode) is crashing for us. I am debugging the issue and will update soon.
------------------
Steps to reproduce:1. Testpmd: ./dpdk-testpmd -c 0xffff01 -n 4 -w 0002:05:00.0 -- -i --port-topology=loop testpmd> set fwd ieee1588 testpmd> set port 0 ptype_mask 0xf testpmd> start I am sending ptp packets using scapy from the peer: >>> p = Ether(src='98:03:9b:67:b0:d0', dst='FA:62:0C:27:AD:BC', >>> type=35063)/Raw(load='\x00\x02') >>> sendp (p, iface="p5p2")
Quoted 9 lines
Quoted 4 lines
Quoted 1 line
I am observing seg fault even for 1 packet.
Where is the crash? Could you provide a backtrace? Is the field well registered?
Sorry Harman, without any more explanation, we must move forward. I am going to send a v4 without any change for octeontx2. It should be merged today for -rc2.
Hi Thomas,
I have fixed the issue and sent a patch on top of your changes, kindly apply it:
https://patches.dpdk.org/patch/83611/
Once you will squash both the patches, I will abondon my patch.
Thanks
Harman
Quoted 1 line
PATCH v3 10/16 net/pcap: switch Rx timestamp to dynamic mbuf field
In reply to Thomas MonjalonThe mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced.
--- drivers/net/pcap/rte_eth_pcap.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
drivers/net/pcap/rte_eth_pcap.c +17 -3
@@ -51,6 +51,9 @@ static uint64_t start_cycles;static uint64_t hz;static uint8_t iface_idx; +static uint64_t timestamp_rx_dynflag; +static int timestamp_dynfield_offset =-1 ; +struct queue_stat {volatile unsigned long pkts;volatile unsigned long bytes;
@@ -265,9 +268,11 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) } mbuf->pkt_len = (uint16_t )header.caplen; - mbuf->timestamp = (uint64_t )header.ts.tv_sec *1000000 - + header.ts.tv_usec; - mbuf->ol_flags |=PKT_RX_TIMESTAMP ; + *RTE_MBUF_DYNFIELD (mbuf, timestamp_dynfield_offset, + rte_mbuf_timestamp_t *) = + (uint64_t )header.ts.tv_sec *1000000 + + header.ts.tv_usec; + mbuf->ol_flags |= timestamp_rx_dynflag; mbuf->port = pcap_q->port_id; bufs[num_rx] = mbuf; num_rx++;
@@ -656,6 +661,15 @@ eth_dev_stop(struct rte_eth_dev *dev)static int eth_dev_configure(struct rte_eth_dev *dev __rte_unused) { +int ret; + + ret =rte_mbuf_dyn_rx_timestamp_register (×tamp_dynfield_offset, + ×tamp_rx_dynflag); +if (ret !=0 ) { +PMD_LOG (ERR ,"Failed to register Rx timestamp field/flag" ); +return -rte_errno; + } +return 0 ; }
Signature · 1 line
2.28.0
PATCH v3 11/16 app/testpmd: switch Rx timestamp to dynamic mbuf field
In reply to Thomas MonjalonThe mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced.
--- app/test-pmd/util.c | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-)
app/test-pmd/util.c +37 -2
@@ -5,6 +5,7 @@#include <stdio.h> +#include <rte_bitops.h> #include <rte_net.h> #include <rte_mbuf.h> #include <rte_ether.h>
@@ -22,6 +23,40 @@ print_ether_addr(const char *what, const struct rte_ether_addr *eth_addr)printf ("%s%s" , what, buf); } +static inline bool +is_timestamp_enabled (const struct rte_mbuf *mbuf) +{ +static uint64_t timestamp_rx_dynflag; + +int timestamp_rx_dynflag_offset; + +if (timestamp_rx_dynflag ==0 ) { + timestamp_rx_dynflag_offset =rte_mbuf_dynflag_lookup ( +RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME ,NULL ); +if (timestamp_rx_dynflag_offset <0 ) +return false; + timestamp_rx_dynflag =RTE_BIT64 (timestamp_rx_dynflag_offset); + } + +return (mbuf->ol_flags & timestamp_rx_dynflag) !=0 ; +} + +static inline rte_mbuf_timestamp_t +get_timestamp (const struct rte_mbuf *mbuf) +{ +static int timestamp_dynfield_offset =-1 ; + +if (timestamp_dynfield_offset <0 ) { + timestamp_dynfield_offset =rte_mbuf_dynfield_lookup ( +RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ); +if (timestamp_dynfield_offset <0 ) +return 0 ; + } + +return *RTE_MBUF_DYNFIELD (mbuf, + timestamp_dynfield_offset, rte_mbuf_timestamp_t *); +} +static inline void dump_pkt_burst (uint16_t port_id,uint16_t queue,struct rte_mbuf *pkts[],uint16_t nb_pkts,int is_rx)
@@ -107,8 +142,8 @@ dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],printf ("hash=0x%x ID=0x%x " , mb->hash.fdir.hash, mb->hash.fdir.id); } -if (ol_flags &PKT_RX_TIMESTAMP ) -printf (" - timestamp %" PRIu64" " , mb->timestamp); +if (is_timestamp_enabled (mb)) +printf (" - timestamp %" PRIu64" " ,get_timestamp (mb));if (ol_flags &PKT_RX_QINQ )printf (" - QinQ VLAN tci=0x%x, VLAN tci outer=0x%x" , mb->vlan_tci, mb->vlan_tci_outer);
Signature · 1 line
2.28.0
Re: [dpdk-dev] [PATCH v3 11/16] app/testpmd: switch Rx timestamp to dynamic mbuf field
Quoted 22 lines · Thomas Monjalon
The mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced.
Signed-off-by Thomas Monjalon <[email protected]>--- app/test-pmd/util.c | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-)app/test-pmd/util.c +1
-0@@ -5,6 +5,7 @@#include <stdio.h> +#include <rte_bitops.h> #include <rte_net.h> #include <rte_mbuf.h> #include <rte_ether.h>
app/test-pmd/util.c print_ether_addr(const char *what, const struct rte_ether_addr *eth_addr) · line 31
Quoted 9 lines
app/test-pmd/util.c +6
-0@@ -22,6 +23,40 @@ print_ether_addr(const char *what, const struct rte_ether_addr *eth_addr)printf ("%s%s" , what, buf); } +static inline bool +is_timestamp_enabled (const struct rte_mbuf *mbuf) +{ +static uint64_t timestamp_rx_dynflag; + +int timestamp_rx_dynflag_offset;
unneeded blank line
Quoted 45 lines
app/test-pmd/util.c +30
-2+ +if (timestamp_rx_dynflag ==0 ) { + timestamp_rx_dynflag_offset =rte_mbuf_dynflag_lookup ( +RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME ,NULL ); +if (timestamp_rx_dynflag_offset <0 ) +return false; + timestamp_rx_dynflag =RTE_BIT64 (timestamp_rx_dynflag_offset); + } + +return (mbuf->ol_flags & timestamp_rx_dynflag) !=0 ; +} + +static inline rte_mbuf_timestamp_t +get_timestamp (const struct rte_mbuf *mbuf) +{ +static int timestamp_dynfield_offset =-1 ; + +if (timestamp_dynfield_offset <0 ) { + timestamp_dynfield_offset =rte_mbuf_dynfield_lookup ( +RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ); +if (timestamp_dynfield_offset <0 ) +return 0 ; + } + +return *RTE_MBUF_DYNFIELD (mbuf, + timestamp_dynfield_offset, rte_mbuf_timestamp_t *); +} +static inline void dump_pkt_burst (uint16_t port_id,uint16_t queue,struct rte_mbuf *pkts[],uint16_t nb_pkts,int is_rx)@@ -107,8 +142,8 @@ dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],printf ("hash=0x%x ID=0x%x " , mb->hash.fdir.hash, mb->hash.fdir.id); } -if (ol_flags &PKT_RX_TIMESTAMP ) -printf (" - timestamp %" PRIu64" " , mb->timestamp); +if (is_timestamp_enabled (mb)) +printf (" - timestamp %" PRIu64" " ,get_timestamp (mb));if (ol_flags &PKT_RX_QINQ )printf (" - QinQ VLAN tci=0x%x, VLAN tci outer=0x%x" , mb->vlan_tci, mb->vlan_tci_outer);Signature · 1 line
2.28.0
PATCH v3 12/16 examples/rxtx_callbacks: switch timestamp to dynamic field
In reply to Thomas MonjalonThe mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field.
--- examples/rxtx_callbacks/main.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
examples/rxtx_callbacks/main.c +15 -1
@@ -19,6 +19,15 @@#define MBUF_CACHE_SIZE 250#define BURST_SIZE 32 +static int hwts_dynfield_offset =-1 ; + +static inline rte_mbuf_timestamp_t * +hwts_field (struct rte_mbuf *mbuf) +{ +return RTE_MBUF_DYNFIELD (mbuf, + hwts_dynfield_offset, rte_mbuf_timestamp_t *); +} +typedef uint64_t tsc_t ;static int tsc_dynfield_offset =-1 ;
@@ -77,7 +86,7 @@ calc_latency(uint16_t port, uint16_t qidx __rte_unused,for (i =0 ; i < nb_pkts; i++) { cycles += now - *tsc_field (pkts[i]);if (hw_timestamping) - queue_ticks += ticks - pkts[i]->timestamp; + queue_ticks += ticks - *hwts_field (pkts[i]); } latency_numbers.total_cycles += cycles;
@@ -141,6 +150,11 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)return -1 ; } port_conf.rxmode.offloads |=DEV_RX_OFFLOAD_TIMESTAMP ; +rte_mbuf_dyn_rx_timestamp_register (&hwts_dynfield_offset,NULL ); +if (hwts_dynfield_offset <0 ) { +printf ("ERROR: Failed to register timestamp field\n" ); +return -rte_errno; + } } retval =rte_eth_dev_configure (port, rx_rings, tx_rings, &port_conf);
Signature · 1 line
2.28.0
PATCH v3 13/16 ethdev: add doxygen comment for Rx timestamp API
In reply to Thomas MonjalonThe offload flag DEV_RX_OFFLOAD_TIMESTAMP had no documentation. After switching to dynamic mbuf flag and field,
it becomes even more important to explicit the feature behaviour.
A doxyegn comment for the timesync API was mentioning the deprecated timestamp field, so it is also updated.
--- lib/librte_ethdev/rte_ethdev.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
lib/librte_ethdev/rte_ethdev.h +6 -1
@@ -1344,6 +1344,11 @@ struct rte_eth_conf {#define DEV_RX_OFFLOAD_VLAN_EXTEND 0x00000400#define DEV_RX_OFFLOAD_JUMBO_FRAME 0x00000800#define DEV_RX_OFFLOAD_SCATTER 0x00002000 +/** +* Timestamp is set by the driver in RTE_MBUF_DYNFIELD_TIMESTAMP_NAME +* and RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME is set in ol_flags. +* The mbuf field and flag are registered when the offload is configured. +*/ #define DEV_RX_OFFLOAD_TIMESTAMP 0x00004000#define DEV_RX_OFFLOAD_SECURITY 0x00008000#define DEV_RX_OFFLOAD_KEEP_CRC 0x00010000
@@ -4647,7 +4652,7 @@ int rte_eth_timesync_write_time(uint16_t port_id, const struct timespec *time);* rte_eth_read_clock(port, base_clock); * * Then, convert the raw mbuf timestamp with: -* base_time_sec + (double)(mbuf->timestamp - base_clock) / freq; +* base_time_sec + (double)(*timestamp_dynfield(mbuf) - 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.
Signature · 1 line
2.28.0
PATCH v3 14/16 mbuf: remove deprecated timestamp field
In reply to Thomas MonjalonAs announced in the deprecation note, the field timestamp is removed to give more space to the dynamic fields. The related offload flag PKT_RX_TIMESTAMP is also removed.
This is how the mbuf layout looks like (pahole-style):
word type name byte size
0 void * buf_addr; /* 0 + 8 */
1 rte_iova_t buf_iova /* 8 + 8 */
/* --- RTE_MARKER64 rearm_data; */
2 uint16_t data_off; /* 16 + 2 */
uint16_t refcnt; /* 18 + 2 */
uint16_t nb_segs; /* 20 + 2 */
uint16_t port; /* 22 + 2 */
3 uint64_t ol_flags; /* 24 + 8 */
/* --- RTE_MARKER rx_descriptor_fields1; */
4 uint32_t union packet_type; /* 32 + 4 */
uint32_t pkt_len; /* 36 + 4 */
5 uint16_t data_len; /* 40 + 2 */
uint16_t vlan_tci; /* 42 + 2 */
5.5 uint64_t union hash; /* 44 + 8 */
6.5 uint16_t vlan_tci_outer; /* 52 + 2 */
uint16_t buf_len; /* 54 + 2 */
7 uint64_t dynfield0[1]; /* 56 + 8 */
/* --- RTE_MARKER cacheline1; */
8 struct rte_mempool * pool; /* 64 + 8 */
9 struct rte_mbuf * next; /* 72 + 8 */
10 uint64_t union tx_offload; /* 80 + 8 */
11 struct rte_mbuf_ext_shared_info * shinfo; /* 88 + 8 */
12 uint16_t priv_size; /* 96 + 2 */
uint16_t timesync; /* 98 + 2 */
12.5 uint32_t dynfield1[7]; /* 100 + 28 */16 /* --- END 128 */
--- app/test/test_mbuf.c | 1 - doc/guides/rel_notes/deprecation.rst | 4 ---- doc/guides/rel_notes/release_20_11.rst | 4 ++++ lib/librte_mbuf/rte_mbuf.c | 2 -- lib/librte_mbuf/rte_mbuf.h | 2 +- lib/librte_mbuf/rte_mbuf_core.h | 12 ++---------- lib/librte_mbuf/rte_mbuf_dyn.c | 1 + 7 files changed, 8 insertions(+), 18 deletions(-)
app/test/test_mbuf.c +0 -1
@@ -1621,7 +1621,6 @@ test_get_rx_ol_flag_name(void)VAL_NAME (PKT_RX_FDIR_FLX ),VAL_NAME (PKT_RX_QINQ_STRIPPED ),VAL_NAME (PKT_RX_LRO ), -VAL_NAME (PKT_RX_TIMESTAMP ),VAL_NAME (PKT_RX_SEC_OFFLOAD ),VAL_NAME (PKT_RX_SEC_OFFLOAD_FAILED ), VAL_NAME(PKT_RX_OUTER_L4_CKSUM_BAD),
doc/guides/rel_notes/deprecation.rst +0 -4
@@ -84,10 +84,6 @@ Deprecation Notices * mbuf: Some fields will be converted to dynamic API in DPDK 20.11 in order to reserve more space for the dynamic fields, as explained in `this presentation <https://www.youtube.com/watch?v=Ttl6MlhmzWY>`_. - The following static fields will be moved as dynamic: - - - ``timestamp`` - As a consequence, the layout of the ``struct rte_mbuf`` will be re-arranged, avoiding impact on vectorized implementation of the driver datapaths, while evaluating performance gains of a better use of the first cache line.
doc/guides/rel_notes/release_20_11.rst +4 -0
@@ -448,6 +448,10 @@ API Changes * mbuf: Removed the field ``seqn`` from the structure ``rte_mbuf``. It is replaced with dynamic fields. +* mbuf: Removed the field ``timestamp`` from the structure ``rte_mbuf``. + It is replaced with the dynamic field RTE_MBUF_DYNFIELD_TIMESTAMP_NAME + which was previously used only for Tx. + * pci: Removed the ``rte_kernel_driver`` enum defined in rte_dev.h and replaced with a private enum in the PCI subsystem.
lib/librte_mbuf/rte_mbuf.c +0 -2
@@ -764,7 +764,6 @@ const char *rte_get_rx_ol_flag_name(uint64_t mask)case PKT_RX_QINQ_STRIPPED :return "PKT_RX_QINQ_STRIPPED" ;case PKT_RX_QINQ :return "PKT_RX_QINQ" ;case PKT_RX_LRO :return "PKT_RX_LRO" ; -case PKT_RX_TIMESTAMP :return "PKT_RX_TIMESTAMP" ;case PKT_RX_SEC_OFFLOAD :return "PKT_RX_SEC_OFFLOAD" ;case PKT_RX_SEC_OFFLOAD_FAILED :return "PKT_RX_SEC_OFFLOAD_FAILED" ;case PKT_RX_OUTER_L4_CKSUM_BAD :return "PKT_RX_OUTER_L4_CKSUM_BAD" ;
@@ -808,7 +807,6 @@ rte_get_rx_ol_flag_list(uint64_t mask, char *buf, size_t buflen) { PKT_RX_FDIR_FLX, PKT_RX_FDIR_FLX, NULL }, { PKT_RX_QINQ_STRIPPED, PKT_RX_QINQ_STRIPPED, NULL }, { PKT_RX_LRO, PKT_RX_LRO, NULL }, - { PKT_RX_TIMESTAMP, PKT_RX_TIMESTAMP, NULL }, { PKT_RX_SEC_OFFLOAD, PKT_RX_SEC_OFFLOAD, NULL }, { PKT_RX_SEC_OFFLOAD_FAILED, PKT_RX_SEC_OFFLOAD_FAILED, NULL }, { PKT_RX_QINQ, PKT_RX_QINQ, NULL },
lib/librte_mbuf/rte_mbuf.h +1 -1
@@ -1095,6 +1095,7 @@ rte_pktmbuf_attach_extbuf(struct rte_mbuf *m, void *buf_addr,static inline void rte_mbuf_dynfield_copy (struct rte_mbuf *mdst,const struct rte_mbuf *msrc) { +memcpy (&mdst->dynfield0, msrc->dynfield0,sizeof (mdst->dynfield0));memcpy (&mdst->dynfield1, msrc->dynfield1,sizeof (mdst->dynfield1)); }
@@ -1108,7 +1109,6 @@ __rte_pktmbuf_copy_hdr(struct rte_mbuf *mdst, const struct rte_mbuf *msrc) mdst->tx_offload = msrc->tx_offload; mdst->hash = msrc->hash; mdst->packet_type = msrc->packet_type; - mdst->timestamp = msrc->timestamp;rte_mbuf_dynfield_copy (mdst, msrc); }
lib/librte_mbuf/rte_mbuf_core.h +2 -10
@@ -149,10 +149,7 @@ extern "C" {*/ #define PKT_RX_LRO (1ULL << 16) -/** -* Indicate that the timestamp field in the mbuf is valid. -*/ -#define PKT_RX_TIMESTAMP (1ULL << 17) +/* There is no flag defined at offset 17. It is free for any future use. */ /** * Indicate that security offload processing was applied on the RX packet.
@@ -589,12 +586,7 @@ struct rte_mbuf {uint16_t buf_len;/**< Length of segment buffer. */ -/** 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; +uint64_t dynfield0[1 ];/**< Reserved for dynamic fields. */ /* second cache line - fields only used in slow path or on TX */ RTE_MARKER cacheline1 __rte_cache_min_aligned;
lib/librte_mbuf/rte_mbuf_dyn.c +1 -0
@@ -125,6 +125,7 @@ init_shared_mem(void)* rte_mbuf_dynfield_copy(). */ memset (shm,0 ,sizeof (*shm)); +mark_free (dynfield0);mark_free (dynfield1);/* init free_flags */
Signature · 1 line
2.28.0
PATCH v3 15/16 mbuf: add Tx timestamp registration helper
In reply to Thomas MonjalonThe function rte_mbuf_dyn_tx_timestamp_register() can be used to register the required field and flag.
--- lib/librte_mbuf/rte_mbuf_dyn.c | 7 +++++++ lib/librte_mbuf/rte_mbuf_dyn.h | 22 ++++++++++++++++++++++ lib/librte_mbuf/version.map | 1 + 3 files changed, 30 insertions(+)
lib/librte_mbuf/rte_mbuf_dyn.c +7 -0
@@ -613,3 +613,10 @@ rte_mbuf_dyn_rx_timestamp_register(int *field_offset, uint64_t *rx_flag)return rte_mbuf_dyn_timestamp_register (field_offset, rx_flag,"Rx" ,RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME ); } + +int +rte_mbuf_dyn_tx_timestamp_register (int *field_offset,uint64_t *tx_flag) +{ +return rte_mbuf_dyn_timestamp_register (field_offset, tx_flag, +"Tx" ,RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME ); +}
lib/librte_mbuf/rte_mbuf_dyn.h +22 -0
@@ -304,4 +304,26 @@ int rte_mbuf_dyn_rx_timestamp_register(int *field_offset, uint64_t *rx_flag);*/ #define RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME "rte_dynflag_tx_timestamp" +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Register dynamic mbuf field and flag for Tx timestamp. +* +* @param field_offset +* Pointer to the offset of the registered mbuf field, can be NULL. +* The same field is shared for Rx and Tx timestamp. +* @param tx_flag +* Pointer to the mask of the registered offload flag, can be NULL. +* @return +* 0 on success, -1 otherwise. +* Possible values for rte_errno: +* - EEXIST: already registered with different parameters. +* - EPERM: called from a secondary process. +* - ENOENT: no more field or flag available. +* - ENOMEM: allocation failure. +*/ +__rte_experimental +int rte_mbuf_dyn_tx_timestamp_register(int *field_offset, uint64_t *tx_flag); +#endif
lib/librte_mbuf/version.map +1 -0
@@ -43,6 +43,7 @@ EXPERIMENTAL { rte_mbuf_dynflag_register_bitnum; rte_mbuf_dyn_dump; rte_mbuf_dyn_rx_timestamp_register; + rte_mbuf_dyn_tx_timestamp_register; rte_pktmbuf_copy; rte_pktmbuf_free_bulk; rte_pktmbuf_pool_create_extbuf;
Signature · 1 line
2.28.0
PATCH v3 16/16 ethdev: include mbuf registration in Tx timestamp API
In reply to Thomas MonjalonPreviously, the Tx timestamp field and flag were registered in testpmd, as described in mlx5 guide.
For consistency between Rx and Tx timestamps,
managing mbuf registrations inside the driver, as properly documented, is a simpler expectation.
The only driver to support this feature (mlx5) is updated as well as the testpmd application.
--- app/test-pmd/config.c | 38 ---------------------------------- doc/guides/nics/mlx5.rst | 5 ++--- drivers/net/mlx5/mlx5_ethdev.c | 8 ++++++- lib/librte_ethdev/rte_ethdev.h | 6 +++++- 4 files changed, 14 insertions(+), 43 deletions(-)
app/test-pmd/config.c +0 -38
@@ -3955,44 +3955,6 @@ show_tx_pkt_times(void)void set_tx_pkt_times (unsigned int *tx_times) { -uint16_t port_id; -int offload_found =0 ; -int offset; -int flag; - -static const struct rte_mbuf_dynfield desc_offs = { - .name =RTE_MBUF_DYNFIELD_TIMESTAMP_NAME , - .size =sizeof (uint64_t ), - .align = __alignof__(uint64_t ), - }; -static const struct rte_mbuf_dynflag desc_flag = { - .name =RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME , - }; - -RTE_ETH_FOREACH_DEV (port_id) { -struct rte_eth_dev_info dev_info = {0 }; -int ret; - - ret =rte_eth_dev_info_get (port_id, &dev_info); -if (ret ==0 && dev_info.tx_offload_capa & -DEV_TX_OFFLOAD_SEND_ON_TIMESTAMP ) { - offload_found =1 ; -break ; - } - } -if (!offload_found) { -printf ("No device supporting Tx timestamp scheduling found, " -"dynamic flag and field not registered\n" ); -return ; - } - offset =rte_mbuf_dynfield_register (&desc_offs); -if (offset <0 && rte_errno !=EEXIST ) -printf ("Dynamic timestamp field registration error: %d" , - rte_errno); - flag =rte_mbuf_dynflag_register (&desc_flag); -if (flag <0 && rte_errno !=EEXIST ) -printf ("Dynamic timestamp flag registration error: %d" , - rte_errno); tx_pkt_times_inter = tx_times[0 ]; tx_pkt_times_intra = tx_times[1 ]; }
doc/guides/nics/mlx5.rst +2 -3
@@ -237,9 +237,8 @@ Limitations ``txq_inline_max`` and ``txq_inline_mpw`` devargs keys. - To provide the packet send scheduling on mbuf timestamps the ``tx_pp`` - parameter should be specified, RTE_MBUF_DYNFIELD_TIMESTAMP_NAME and - RTE_MBUF_DYNFLAG_TIMESTAMP_NAME should be registered by application. - When PMD sees the RTE_MBUF_DYNFLAG_TIMESTAMP_NAME set on the packet + parameter should be specified. + When PMD sees the RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME set on the packet being sent it tries to synchronize the time of packet appearing on the wire with the specified packet timestamp. It the specified one is in the past it should be ignored, if one is in the distant future
drivers/net/mlx5/mlx5_ethdev.c +7 -1
@@ -88,7 +88,13 @@ mlx5_dev_configure(struct rte_eth_dev *dev)if (dev->data->dev_conf.rxmode.mq_mode Ð_MQ_RX_RSS_FLAG ) dev->data->dev_conf.rxmode.offloads |=DEV_RX_OFFLOAD_RSS_HASH ; - +if ((dev->data->dev_conf.txmode.offloads & +DEV_TX_OFFLOAD_SEND_ON_TIMESTAMP ) && +rte_mbuf_dyn_tx_timestamp_register (NULL ,NULL ) !=0 ) { +DRV_LOG (ERR ,"port %u cannot register Tx timestamp field/flag" , + dev->data->port_id); +return -rte_errno; + } memcpy(priv->rss_conf.rss_key, use_app_rss_key ? dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key :
lib/librte_ethdev/rte_ethdev.h +5 -1
@@ -1413,7 +1413,11 @@ struct rte_eth_conf {#define DEV_TX_OFFLOAD_IP_TNL_TSO 0x00080000/** Device supports outer UDP checksum */ #define DEV_TX_OFFLOAD_OUTER_UDP_CKSUM 0x00100000 -/** Device supports send on timestamp */ +/** +* Device sends on time read from RTE_MBUF_DYNFIELD_TIMESTAMP_NAME +* if RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME is set in ol_flags. +* The mbuf field and flag are registered when the offload is configured. +*/ #define DEV_TX_OFFLOAD_SEND_ON_TIMESTAMP 0x00200000/* * If new Tx offload capabilities are defined, they also must be
Signature · 1 line
2.28.0
Re: [dpdk-dev] [PATCH v3 16/16] ethdev: include mbuf registration in Tx timestamp API
Quoted 18 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Tuesday, November 3, 2020 2:14
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Slava Ovsiienko <[email protected]>; Wenzhuo Lu <[email protected]>; Beilei Xing <[email protected]>; Bernard Iremonger <[email protected]>; Matan Azrad <[email protected]>; Shahaf Shuler <[email protected]>
Subject: [PATCH v3 16/16] ethdev: include mbuf registration in Tx timestamp APIPreviously, the Tx timestamp field and flag were registered in testpmd, as described in mlx5 guide.
For consistency between Rx and Tx timestamps, managing mbuf registrations inside the driver, as properly documented, is a simpler expectation.
Quoted 4 lines
The only driver to support this feature (mlx5) is updated as well as the testpmd application.
Signed-off-by Thomas Monjalon <[email protected]>
Quoted 10 lines · Thomas Monjalon
The mbuf field timestamp was announced to be removed for three reasons:
- a dynamic field already exist, used for Tx only
- this field always used 8 bytes even if unneeded
- this field is in the first half (cacheline) of mbufAfter this series, the dynamic field timestamp is used for both Rx and Tx with separate dynamic flags to distinguish when the value is meaningful without resetting the field during forwarding.
Quoted 7 lines
As a consequence, 8 bytes can be re-allocated to dynamic fields in the first half of mbuf structure.
It is still open to change more the mbuf layout.This mbuf layout change is important to allow adding more features (consuming more dynamic fields) during the next year,
and can allow performance improvements with new usages in the first half.
For the series:
Signature · 1 line
David Marchand
v4 cover remove mbuf timestamp
In reply to Thomas MonjalonThe mbuf field timestamp was announced to be removed for three reasons:
- a dynamic field already exist, used for Tx only
- this field always used 8 bytes even if unneeded
- this field is in the first half (cacheline) of mbuf
After this series, the dynamic field timestamp is used for both Rx and Tx with separate dynamic flags to distinguish when the value is meaningful without resetting the field during forwarding.
As a consequence, 8 bytes can be re-allocated to dynamic fields in the first half of mbuf structure.
It is still open to change more the mbuf layout.
This mbuf layout change is important to allow adding more features (consuming more dynamic fields) during the next year,
and can allow performance improvements with new usages in the first half.
v4:
- use local variable in nfb
- fix flag initialization
- remove useless blank line
v3:
- move ark variables declaration in a .h file
- improve cache locality for octeontx2
- add comments about cache locality in commit logs
- add comment for unused flag offset 17
- add timestamp register functions
- replace lookup with register in drivers and apps
- remove register in ethdev
v2:
- remove optimization to register only once in ethdev
- fix error message in latencystats
- convert rxtx_callbacks macro to inline function
- increase dynamic fields space
- do not move pool field
Thomas Monjalon (16):
eventdev: remove software Rx timestamp
mbuf: add Rx timestamp flag and helpers
latency: switch Rx timestamp to dynamic mbuf field net/ark: switch Rx timestamp to dynamic mbuf field net/dpaa2: switch Rx timestamp to dynamic mbuf field net/mlx5: fix dynamic mbuf offset lookup check net/mlx5: switch Rx timestamp to dynamic mbuf field net/nfb: switch Rx timestamp to dynamic mbuf field net/octeontx2: switch Rx timestamp to dynamic mbuf field net/pcap: switch Rx timestamp to dynamic mbuf field app/testpmd: switch Rx timestamp to dynamic mbuf field examples/rxtx_callbacks: switch timestamp to dynamic field
ethdev: add doxygen comment for Rx timestamp API
mbuf: remove deprecated timestamp field
mbuf: add Tx timestamp registration helper
ethdev: include mbuf registration in Tx timestamp API
app/test-pmd/config.c | 38 ------------- app/test-pmd/util.c | 38 ++++++++++++- app/test/test_mbuf.c | 1 - doc/guides/nics/mlx5.rst | 5 +- .../prog_guide/event_ethernet_rx_adapter.rst | 6 +- doc/guides/rel_notes/deprecation.rst | 4 -- doc/guides/rel_notes/release_20_11.rst | 4 ++ drivers/net/ark/ark_ethdev.c | 16 ++++++ drivers/net/ark/ark_ethdev_rx.c | 7 ++- drivers/net/ark/ark_ethdev_rx.h | 2 + drivers/net/dpaa2/dpaa2_ethdev.c | 11 ++++ drivers/net/dpaa2/dpaa2_ethdev.h | 2 + drivers/net/dpaa2/dpaa2_rxtx.c | 25 ++++++--- drivers/net/mlx5/mlx5_ethdev.c | 8 ++- drivers/net/mlx5/mlx5_rxq.c | 8 +++ drivers/net/mlx5/mlx5_rxtx.c | 8 +-- drivers/net/mlx5/mlx5_rxtx.h | 19 +++++++ drivers/net/mlx5/mlx5_rxtx_vec_altivec.h | 41 +++++++------- drivers/net/mlx5/mlx5_rxtx_vec_neon.h | 43 ++++++++------- drivers/net/mlx5/mlx5_rxtx_vec_sse.h | 35 ++++++------ drivers/net/mlx5/mlx5_trigger.c | 2 +- drivers/net/mlx5/mlx5_txq.c | 2 +- drivers/net/nfb/nfb_rx.c | 15 ++++- drivers/net/nfb/nfb_rx.h | 21 +++++-- drivers/net/octeontx2/otx2_ethdev.c | 10 ++++ drivers/net/octeontx2/otx2_rx.h | 19 ++++++- drivers/net/pcap/rte_eth_pcap.c | 20 ++++++- examples/rxtx_callbacks/main.c | 16 +++++- lib/librte_ethdev/rte_ethdev.h | 13 ++++- .../rte_event_eth_rx_adapter.c | 11 ---- .../rte_event_eth_rx_adapter.h | 6 +- lib/librte_latencystats/rte_latencystats.c | 30 ++++++++-- lib/librte_mbuf/rte_mbuf.c | 2 - lib/librte_mbuf/rte_mbuf.h | 2 +- lib/librte_mbuf/rte_mbuf_core.h | 12 +--- lib/librte_mbuf/rte_mbuf_dyn.c | 51 +++++++++++++++++ lib/librte_mbuf/rte_mbuf_dyn.h | 55 +++++++++++++++++-- lib/librte_mbuf/version.map | 2 + 38 files changed, 431 insertions(+), 179 deletions(-)
Signature · 1 line
2.28.0
PATCH v4 1/16 eventdev: remove software Rx timestamp
This a revert of the commit 569758758dcd ("eventdev: add Rx timestamp"). If the Rx timestamp is not configured on the ethdev port, there is no reason to set one.
Also the accuracy of the timestamp was bad because set at a late stage. Anyway there is no trace of the usage of this timestamp.
--- doc/guides/prog_guide/event_ethernet_rx_adapter.rst | 6 +----- lib/librte_eventdev/rte_event_eth_rx_adapter.c | 11 ----------- lib/librte_eventdev/rte_event_eth_rx_adapter.h | 6 +----- 3 files changed, 2 insertions(+), 21 deletions(-)
doc/guides/prog_guide/event_ethernet_rx_adapter.rst +1 -5
@@ -12,11 +12,7 @@ be supported in hardware or require a software thread to receive packets from the ethdev port using ethdev poll mode APIs and enqueue these as events to the event device using the eventdev API. Both transfer mechanisms may be present on the same platform depending on the particular combination of the ethdev and -the event device. For SW based packet transfer, if the mbuf does not have a -timestamp set, the adapter adds a timestamp to the mbuf using -rte_get_tsc_cycles(), this provides a more accurate timestamp as compared to -if the application were to set the timestamp since it avoids event device -schedule latency. +the event device. The Event Ethernet Rx Adapter library is intended for the application code to configure both transfer mechanisms using a common API. A capability API allows
lib/librte_eventdev/rte_event_eth_rx_adapter.c +0 -11
@@ -763,7 +763,6 @@ rxa_buffer_mbufs(struct rte_event_eth_rx_adapter *rx_adapter,uint32_t rss_mask;uint32_t rss;int do_rss; -uint64_t ts;uint16_t nb_cb;uint16_t dropped;
@@ -771,16 +770,6 @@ rxa_buffer_mbufs(struct rte_event_eth_rx_adapter *rx_adapter, rss_mask = ~(((m->ol_flags &PKT_RX_RSS_HASH ) !=0 ) -1 ); do_rss = !rss_mask && !eth_rx_queue_info->flow_id_mask; -if ((m->ol_flags &PKT_RX_TIMESTAMP ) ==0 ) { - ts =rte_get_tsc_cycles (); -for (i =0 ; i < num; i++) { - m = mbufs[i]; - - m->timestamp = ts; - m->ol_flags |=PKT_RX_TIMESTAMP ; - } - } -for (i =0 ; i < num; i++) { m = mbufs[i];
lib/librte_eventdev/rte_event_eth_rx_adapter.h +1 -5
@@ -21,11 +21,7 @@* * The adapter uses a EAL service core function for SW based packet transfer * and uses the eventdev PMD functions to configure HW based packet transfer -* between the ethernet device and the event device. For SW based packet -* transfer, if the mbuf does not have a timestamp set, the adapter adds a -* timestamp to the mbuf using rte_get_tsc_cycles(), this provides a more -* accurate timestamp as compared to if the application were to set the time -* stamp since it avoids event device schedule latency. +* between the ethernet device and the event device. * * The ethernet Rx event adapter's functions are: * - rte_event_eth_rx_adapter_create_ext()
Signature · 1 line
2.28.0
PATCH v4 2/16 mbuf: add Rx timestamp flag and helpers
In reply to Thomas MonjalonThere is already a dynamic field for timestamp,
used only for Tx scheduling with the dedicated Tx offload flag. The same field can be used for Rx timestamp filled by drivers.
A new dynamic flag is defined for Rx usage.
A new function wraps the registration of both field and Rx flag. The type rte_mbuf_timestamp_t is defined for the API users.
After migrating all Rx timestamp usages, it will be possible to remove the deprecated timestamp field.
--- lib/librte_mbuf/rte_mbuf_dyn.c | 43 ++++++++++++++++++++++++++++++++++ lib/librte_mbuf/rte_mbuf_dyn.h | 33 ++++++++++++++++++++++---- lib/librte_mbuf/version.map | 1 + 3 files changed, 72 insertions(+), 5 deletions(-)
lib/librte_mbuf/rte_mbuf_dyn.c +43 -0
@@ -13,6 +13,7 @@#include <rte_errno.h> #include <rte_malloc.h> #include <rte_string_fns.h> +#include <rte_bitops.h> #include <rte_mbuf.h> #include <rte_mbuf_dyn.h>
@@ -569,3 +570,45 @@ void rte_mbuf_dyn_dump(FILE *out)rte_mcfg_tailq_write_unlock (); } + +static int +rte_mbuf_dyn_timestamp_register (int *field_offset,uint64_t *flag, +const char *direction,const char *flag_name) +{ +static const struct rte_mbuf_dynfield field_desc = { + .name =RTE_MBUF_DYNFIELD_TIMESTAMP_NAME , + .size =sizeof (rte_mbuf_timestamp_t), + .align = __alignof__(rte_mbuf_timestamp_t ), + }; +struct rte_mbuf_dynflag flag_desc = {0 }; +int offset; + + offset =rte_mbuf_dynfield_register (&field_desc); +if (offset <0 ) { +RTE_LOG (ERR ,MBUF , +"Failed to register mbuf field for timestamp\n" ); +return -1 ; + } +if (field_offset !=NULL ) + *field_offset = offset; + +strlcpy (flag_desc.name, flag_name,sizeof (flag_desc.name)); + offset =rte_mbuf_dynflag_register (&flag_desc); +if (offset <0 ) { +RTE_LOG (ERR ,MBUF , +"Failed to register mbuf flag for %s timestamp\n" , + direction); +return -1 ; + } +if (flag !=NULL ) + *flag =RTE_BIT64 (offset); + +return 0 ; +} + +int +rte_mbuf_dyn_rx_timestamp_register (int *field_offset,uint64_t *rx_flag) +{ +return rte_mbuf_dyn_timestamp_register (field_offset, rx_flag, +"Rx" ,RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME ); +}
lib/librte_mbuf/rte_mbuf_dyn.h +28 -5
@@ -258,13 +258,36 @@ void rte_mbuf_dyn_dump(FILE *out);* timestamp. The dynamic Tx timestamp flag tells whether the field contains * actual timestamp value for the packets being sent, this value can be * used by PMD to schedule packet sending. -* -* After PKT_RX_TIMESTAMP flag and fixed timestamp field deprecation -* and obsoleting, the dedicated Rx timestamp flag is supposed to be -* introduced and the shared dynamic timestamp field will be used -* to handle the timestamps on receiving datapath as well. */ #define RTE_MBUF_DYNFIELD_TIMESTAMP_NAME "rte_dynfield_timestamp" +typedef uint64_t rte_mbuf_timestamp_t ; + +/** +* Indicate that the timestamp field in the mbuf was filled by the driver. +*/ +#define RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME "rte_dynflag_rx_timestamp" + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Register dynamic mbuf field and flag for Rx timestamp. +* +* @param field_offset +* Pointer to the offset of the registered mbuf field, can be NULL. +* The same field is shared for Rx and Tx timestamp. +* @param rx_flag +* Pointer to the mask of the registered offload flag, can be NULL. +* @return +* 0 on success, -1 otherwise. +* Possible values for rte_errno: +* - EEXIST: already registered with different parameters. +* - EPERM: called from a secondary process. +* - ENOENT: no more field or flag available. +* - ENOMEM: allocation failure. +*/ +__rte_experimental +int rte_mbuf_dyn_rx_timestamp_register(int *field_offset, uint64_t *rx_flag);/** * When PMD sees the RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME flag set on the
lib/librte_mbuf/version.map +1 -0
@@ -42,6 +42,7 @@ EXPERIMENTAL { rte_mbuf_dynflag_register; rte_mbuf_dynflag_register_bitnum; rte_mbuf_dyn_dump; + rte_mbuf_dyn_rx_timestamp_register; rte_pktmbuf_copy; rte_pktmbuf_free_bulk; rte_pktmbuf_pool_create_extbuf;
Signature · 1 line
2.28.0
Re: [dpdk-dev] [PATCH v4 02/16] mbuf: add Rx timestamp flag and helpers
Quoted 8 lines · Thomas Monjalon
There is already a dynamic field for timestamp,
used only for Tx scheduling with the dedicated Tx offload flag. The same field can be used for Rx timestamp filled by drivers.A new dynamic flag is defined for Rx usage.
A new function wraps the registration of both field and Rx flag. The typerte_mbuf_timestamp_tis defined for the API users.
Quoted 5 lines
After migrating all Rx timestamp usages, it will be possible to remove the deprecated timestamp field.
Signed-off-by Thomas Monjalon <[email protected]>Acked-by David Marchand <[email protected]>
PATCH v4 3/16 latency: switch Rx timestamp to dynamic mbuf field
In reply to Thomas MonjalonThe mbuf timestamp is moved to a dynamic field
in order to allow removal of the deprecated static field. The related mbuf flag is also replaced with the dynamic one.
--- lib/librte_latencystats/rte_latencystats.c | 30 ++++++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-)
lib/librte_latencystats/rte_latencystats.c +25 -5
@@ -9,6 +9,7 @@#include <rte_string_fns.h> #include <rte_mbuf.h> +#include <rte_mbuf_dyn.h> #include <rte_log.h> #include <rte_cycles.h> #include <rte_ethdev.h>
@@ -31,6 +32,16 @@ latencystat_cycles_per_ns(void)/* Macros for printing using RTE_LOG */ #define RTE_LOGTYPE_LATENCY_STATS RTE_LOGTYPE_USER1 +static uint64_t timestamp_dynflag; +static int timestamp_dynfield_offset =-1 ; + +static inline rte_mbuf_timestamp_t * +timestamp_dynfield (struct rte_mbuf *mbuf) +{ +return RTE_MBUF_DYNFIELD (mbuf, + timestamp_dynfield_offset, rte_mbuf_timestamp_t *); +} +static const char *MZ_RTE_LATENCY_STATS ="rte_latencystats" ;static int latency_stats_index;static uint64_t samp_intvl;
@@ -128,10 +139,10 @@ add_time_stamps(uint16_t pid __rte_unused, diff_tsc = now - prev_tsc; timer_tsc += diff_tsc; -if ((pkts[i]->ol_flags &PKT_RX_TIMESTAMP ) ==0 +if ((pkts[i]->ol_flags & timestamp_dynflag) ==0 && (timer_tsc >= samp_intvl)) { - pkts[i]->timestamp = now; - pkts[i]->ol_flags |=PKT_RX_TIMESTAMP ; + *timestamp_dynfield (pkts[i]) = now; + pkts[i]->ol_flags |= timestamp_dynflag; timer_tsc =0 ; } prev_tsc = now;
@@ -161,8 +172,8 @@ calc_latency(uint16_t pid __rte_unused, now =rte_rdtsc ();for (i =0 ; i < nb_pkts; i++) { -if (pkts[i]->ol_flags &PKT_RX_TIMESTAMP ) - latency[cnt++] = now - pkts[i]->timestamp; +if (pkts[i]->ol_flags & timestamp_dynflag) + latency[cnt++] = now - *timestamp_dynfield (pkts[i]); }rte_spinlock_lock (&glob_stats->lock);
@@ -241,6 +252,15 @@ rte_latencystats_init(uint64_t app_samp_intvl,return -1 ; } +/* Register mbuf field and flag for Rx timestamp */ + ret =rte_mbuf_dyn_rx_timestamp_register (×tamp_dynfield_offset, + ×tamp_dynflag); +if (ret !=0 ) { +RTE_LOG (ERR ,LATENCY_STATS , +"Cannot register mbuf field/flag for timestamp\n" ); +return -rte_errno; + } +/** Register Rx/Tx callbacks */ RTE_ETH_FOREACH_DEV (pid) {struct rte_eth_dev_info dev_info;
Signature · 1 line
2.28.0
PATCH v4 4/16 net/ark: switch Rx timestamp to dynamic mbuf field
In reply to Thomas MonjalonThe mbuf timestamp is moved to a dynamic field
in order to allow removal of the deprecated static field. The related dynamic mbuf flag is set, although was missing previously.
The timestamp is set if configured for at least one device.
--- drivers/net/ark/ark_ethdev.c | 16 ++++++++++++++++ drivers/net/ark/ark_ethdev_rx.c | 7 ++++++- drivers/net/ark/ark_ethdev_rx.h | 2 ++ 3 files changed, 24 insertions(+), 1 deletion(-)
drivers/net/ark/ark_ethdev.c +16 -0
@@ -79,6 +79,8 @@ static int eth_ark_set_mtu(struct rte_eth_dev *dev, uint16_t size);#define ARK_TX_MAX_QUEUE (4096 * 4)#define ARK_TX_MIN_QUEUE (256) +uint64_t ark_timestamp_rx_dynflag; +int ark_timestamp_dynfield_offset =-1 ;int rte_pmd_ark_rx_userdata_dynfield_offset =-1 ;int rte_pmd_ark_tx_userdata_dynfield_offset =-1 ;
@@ -552,6 +554,18 @@ static int eth_ark_dev_configure(struct rte_eth_dev *dev) {struct ark_adapter *ark = dev->data->dev_private; +int ret; + +if (dev->data->dev_conf.rxmode.offloads &DEV_RX_OFFLOAD_TIMESTAMP ) { + ret =rte_mbuf_dyn_rx_timestamp_register ( + &ark_timestamp_dynfield_offset, + &ark_timestamp_rx_dynflag); +if (ret !=0 ) { +ARK_PMD_LOG (ERR , +"Failed to register Rx timestamp field/flag\n" ); +return -rte_errno; + } + }eth_ark_dev_set_link_up (dev);if (ark->user_ext.dev_configure)
@@ -782,6 +796,8 @@ eth_ark_dev_info_get(struct rte_eth_dev *dev,ETH_LINK_SPEED_50G | ETH_LINK_SPEED_100G); + dev_info->rx_offload_capa =DEV_RX_OFFLOAD_TIMESTAMP ; +return 0 ; }
drivers/net/ark/ark_ethdev_rx.c +6 -1
@@ -272,7 +272,12 @@ eth_ark_recv_pkts(void *rx_queue, mbuf->port = meta->port; mbuf->pkt_len = meta->pkt_len; mbuf->data_len = meta->pkt_len; - mbuf->timestamp = meta->timestamp; +/* set timestamp if enabled at least on one device */ +if (ark_timestamp_rx_dynflag >0 ) { + *RTE_MBUF_DYNFIELD (mbuf, ark_timestamp_dynfield_offset, + rte_mbuf_timestamp_t *) = meta->timestamp; + mbuf->ol_flags |= ark_timestamp_rx_dynflag; + }rte_pmd_ark_mbuf_rx_userdata_set (mbuf, meta->user_data);if (ARK_DEBUG_CORE ) {/* debug sanity checks */
drivers/net/ark/ark_ethdev_rx.h +2 -0
@@ -11,6 +11,8 @@#include <rte_mempool.h> #include <rte_ethdev_driver.h> +extern uint64_t ark_timestamp_rx_dynflag; +extern int ark_timestamp_dynfield_offset; int eth_ark_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
Signature · 1 line
2.28.0
Re: [dpdk-dev] [PATCH v4 04/16] net/ark: switch Rx timestamp to dynamic mbuf field
Quoted 8 lines · Thomas Monjalon
The mbuf timestamp is moved to a dynamic field
in order to allow removal of the deprecated static field. The related dynamic mbuf flag is set, although was missing previously.The timestamp is set if configured for at least one device.
Signed-off-by Thomas Monjalon <[email protected]>Acked-by David Marchand <[email protected]>
Just one minor comment below
Quoted 11 lines
--- drivers/net/ark/ark_ethdev.c | 16 ++++++++++++++++ drivers/net/ark/ark_ethdev_rx.c | 7 ++++++- drivers/net/ark/ark_ethdev_rx.h | 2 ++ 3 files changed, 24 insertions(+), 1 deletion(-)drivers/net/ark/ark_ethdev.c +0
-0
drivers/net/ark/ark_ethdev.c static int eth_ark_set_mtu(struct rte_eth_dev *dev, uint16_t size); · line 85
Quoted 7 lines
drivers/net/ark/ark_ethdev.c +2
-0@@ -79,6 +79,8 @@ static int eth_ark_set_mtu(struct rte_eth_dev *dev, uint16_t size);#define ARK_TX_MAX_QUEUE (4096 * 4)#define ARK_TX_MIN_QUEUE (256) +uint64_t ark_timestamp_rx_dynflag; +int ark_timestamp_dynfield_offset =-1 ;int rte_pmd_ark_rx_userdata_dynfield_offset =-1 ;int rte_pmd_ark_tx_userdata_dynfield_offset =-1 ;
It is a bit confusing that naming above differs so much and put in the same block without empty lines in between. I guess the reason is export/no-export. May be it would be useful to highlight it in a comment.
Re: [dpdk-dev] [PATCH v4 04/16] net/ark: switch Rx timestamp to dynamic mbuf field
03/11/2020 13:37, Andrew Rybchenko:
Quoted 12 lines · Thomas Monjalon
drivers/net/ark/ark_ethdev.c static int eth_ark_set_mtu(struct rte_eth_dev *dev, uint16_t size); · line 85
Quoted 6 lines
drivers/net/ark/ark_ethdev.c +2
-0+uint64_t ark_timestamp_rx_dynflag; +int ark_timestamp_dynfield_offset =-1 ;int rte_pmd_ark_rx_userdata_dynfield_offset =-1 ;int rte_pmd_ark_tx_userdata_dynfield_offset =-1 ;It is a bit confusing that naming above differs so much and put in the same block without empty lines in between. I guess the reason is export/no-export. May be it would be useful to highlight it in a comment.
I can add a blank line.
Not sure it is worth an out of scope comment to explain that "rte_pmd_" prefixed variables are for the PMD-specific API.
PATCH v4 5/16 net/dpaa2: switch Rx timestamp to dynamic mbuf field
In reply to Thomas MonjalonThe mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced.
--- drivers/net/dpaa2/dpaa2_ethdev.c | 11 +++++++++++ drivers/net/dpaa2/dpaa2_ethdev.h | 2 ++ drivers/net/dpaa2/dpaa2_rxtx.c | 25 ++++++++++++++++++------- 3 files changed, 31 insertions(+), 7 deletions(-)
drivers/net/dpaa2/dpaa2_ethdev.c +11 -0
@@ -65,6 +65,8 @@ static uint64_t dev_tx_offloads_nodis =/* enable timestamp in mbuf */ bool dpaa2_enable_ts[RTE_MAX_ETHPORTS ]; +uint64_t dpaa2_timestamp_rx_dynflag; +int dpaa2_timestamp_dynfield_offset =-1 ;struct rte_dpaa2_xstats_name_off {char name[RTE_ETH_XSTATS_NAME_SIZE ];
@@ -587,7 +589,16 @@ dpaa2_eth_dev_configure(struct rte_eth_dev *dev)#if !defined(RTE_LIBRTE_IEEE1588 ) if (rx_offloads & DEV_RX_OFFLOAD_TIMESTAMP)#endif + { + ret =rte_mbuf_dyn_rx_timestamp_register ( + &dpaa2_timestamp_dynfield_offset, + &dpaa2_timestamp_rx_dynflag); +if (ret !=0 ) { +DPAA2_PMD_ERR ("Error to register timestamp field/flag" ); +return -rte_errno; + } dpaa2_enable_ts[dev->data->port_id] = true; + }if (tx_offloads &DEV_TX_OFFLOAD_IPV4_CKSUM ) tx_l3_csum_offload = true;
drivers/net/dpaa2/dpaa2_ethdev.h +2 -0
@@ -92,6 +92,8 @@/* enable timestamp in mbuf*/ extern bool dpaa2_enable_ts[]; +extern uint64_t dpaa2_timestamp_rx_dynflag; +extern int dpaa2_timestamp_dynfield_offset;#define DPAA2_QOS_TABLE_RECONFIGURE 1#define DPAA2_FS_TABLE_RECONFIGURE 2
drivers/net/dpaa2/dpaa2_rxtx.c +18 -7
@@ -31,6 +31,13 @@ dpaa2_dev_rx_parse_slow(struct rte_mbuf *mbuf, static void enable_tx_tstamp(struct qbman_fd *fd) __rte_unused; +static inline rte_mbuf_timestamp_t * +dpaa2_timestamp_dynfield (struct rte_mbuf *mbuf) +{ +return RTE_MBUF_DYNFIELD (mbuf, + dpaa2_timestamp_dynfield_offset, rte_mbuf_timestamp_t *); +} +#define DPAA2_MBUF_TO_CONTIG_FD (_mbuf, _fd, _bpid) do { \ DPAA2_SET_FD_ADDR(_fd, DPAA2_MBUF_VADDR_TO_IOVA(_mbuf)); \ DPAA2_SET_FD_LEN(_fd, _mbuf->data_len); \
@@ -109,9 +116,10 @@ dpaa2_dev_rx_parse_new(struct rte_mbuf *m, const struct qbman_fd *fd, m->ol_flags |=PKT_RX_RSS_HASH ;if (dpaa2_enable_ts[m->port]) { - m->timestamp = annotation->word2; - m->ol_flags |=PKT_RX_TIMESTAMP ; -DPAA2_PMD_DP_DEBUG ("pkt timestamp:0x%" PRIx64"" , m->timestamp); + *dpaa2_timestamp_dynfield (m) = annotation->word2; + m->ol_flags |= dpaa2_timestamp_rx_dynflag; +DPAA2_PMD_DP_DEBUG ("pkt timestamp:0x%" PRIx64"" , + *dpaa2_timestamp_dynfield (m)); } DPAA2_PMD_DP_DEBUG("HW frc = 0x%x\t packet type =0x%x "
@@ -223,9 +231,12 @@ dpaa2_dev_rx_parse(struct rte_mbuf *mbuf, void *hw_annot_addr)else if (BIT_ISSET_AT_POS (annotation->word8,DPAA2_ETH_FAS_L4CE )) mbuf->ol_flags |=PKT_RX_L4_CKSUM_BAD ; - mbuf->ol_flags |=PKT_RX_TIMESTAMP ; - mbuf->timestamp = annotation->word2; -DPAA2_PMD_DP_DEBUG ("pkt timestamp: 0x%" PRIx64"" , mbuf->timestamp); +if (dpaa2_enable_ts[mbuf->port]) { + *dpaa2_timestamp_dynfield (mbuf) = annotation->word2; + mbuf->ol_flags |= dpaa2_timestamp_rx_dynflag; +DPAA2_PMD_DP_DEBUG ("pkt timestamp: 0x%" PRIx64"" , + *dpaa2_timestamp_dynfield (mbuf)); + }/* Check detailed parsing requirement */ if (annotation->word3 &0x7FFFFC3FFFF )
@@ -629,7 +640,7 @@ dpaa2_dev_prefetch_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)else bufs[num_rx] =eth_fd_to_mbuf (fd, eth_data->port_id);#if defined(RTE_LIBRTE_IEEE1588 ) - priv->rx_timestamp = bufs[num_rx]->timestamp; + priv->rx_timestamp = *dpaa2_timestamp_dynfield (bufs[num_rx]);#endif if (eth_data->dev_conf.rxmode.offloads &
Signature · 1 line
2.28.0
PATCH v4 6/16 net/mlx5: fix dynamic mbuf offset lookup check
In reply to Thomas MonjalonThe functions rte_mbuf_dynfield_lookup() and rte_mbuf_dynflag_lookup() can return an offset starting with 0 or a negative error code.
In reality the first offsets are probably reserved forever, but for the sake of strict API compliance,
the checks which considered 0 as an error are fixed.
--- drivers/net/mlx5/mlx5_rxtx.c | 4 ++-- drivers/net/mlx5/mlx5_trigger.c | 2 +- drivers/net/mlx5/mlx5_txq.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/mlx5/mlx5_rxtx.c +2 -2
@@ -5661,9 +5661,9 @@ mlx5_select_tx_function(struct rte_eth_dev *dev) }if (tx_offloads &DEV_TX_OFFLOAD_SEND_ON_TIMESTAMP &&rte_mbuf_dynflag_lookup - (RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME ,NULL ) >0 && + (RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME ,NULL ) >=0 &&rte_mbuf_dynfield_lookup - (RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ) >0 ) { + (RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ) >=0 ) {/* Offload configured, dynamic entities registered. */ olx |=MLX5_TXOFF_CONFIG_TXPP ; }
drivers/net/mlx5/mlx5_trigger.c +1 -1
@@ -302,7 +302,7 @@ mlx5_dev_start(struct rte_eth_dev *dev)DRV_LOG (DEBUG ,"port %u starting device" , dev->data->port_id); fine_inline =rte_mbuf_dynflag_lookup (RTE_PMD_MLX5_FINE_GRANULARITY_INLINE ,NULL ); -if (fine_inline >0 ) +if (fine_inline >=0 ) rte_net_mlx5_dynf_inline_mask =1UL << fine_inline;else rte_net_mlx5_dynf_inline_mask =0 ;
drivers/net/mlx5/mlx5_txq.c +1 -1
@@ -1305,7 +1305,7 @@ mlx5_txq_dynf_timestamp_set(struct rte_eth_dev *dev) (RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME ,NULL ); off =rte_mbuf_dynfield_lookup (RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ); -if (nbit >0 && off >=0 && sh->txpp.refcnt) +if (nbit >=0 && off >=0 && sh->txpp.refcnt) mask =1ULL << nbit;for (i =0 ; i != priv->txqs_n; ++i) { data = (*priv->txqs)[i];
Signature · 1 line
2.28.0
PATCH v4 7/16 net/mlx5: switch Rx timestamp to dynamic mbuf field
In reply to Thomas MonjalonThe mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced.
The dynamic offset and flag are stored in struct mlx5_rxq_data to favor cache locality.
--- drivers/net/mlx5/mlx5_rxq.c | 8 +++++ drivers/net/mlx5/mlx5_rxtx.c | 4 +-- drivers/net/mlx5/mlx5_rxtx.h | 19 +++++++++++ drivers/net/mlx5/mlx5_rxtx_vec_altivec.h | 41 +++++++++++----------- drivers/net/mlx5/mlx5_rxtx_vec_neon.h | 43 ++++++++++++------------ drivers/net/mlx5/mlx5_rxtx_vec_sse.h | 35 +++++++++---------- 6 files changed, 90 insertions(+), 60 deletions(-)
drivers/net/mlx5/mlx5_rxq.c +8 -0
@@ -1492,7 +1492,15 @@ mlx5_rxq_new(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,mlx5_max_lro_msg_size_adjust (dev, idx, max_lro_size);/* Toggle RX checksum offload if hardware supports it. */ tmpl->rxq.csum = !!(offloads &DEV_RX_OFFLOAD_CHECKSUM ); +/* Configure Rx timestamp. */ tmpl->rxq.hw_timestamp = !!(offloads &DEV_RX_OFFLOAD_TIMESTAMP ); + tmpl->rxq.timestamp_rx_flag =0 ; +if (tmpl->rxq.hw_timestamp &&rte_mbuf_dyn_rx_timestamp_register ( + &tmpl->rxq.timestamp_offset, + &tmpl->rxq.timestamp_rx_flag) !=0 ) { +DRV_LOG (ERR ,"Cannot register Rx timestamp field/flag" ); + goto error; + }/* Configure VLAN stripping. */ tmpl->rxq.vlan_strip = !!(offloads &DEV_RX_OFFLOAD_VLAN_STRIP );/* By default, FCS (CRC) is stripped by hardware. */
drivers/net/mlx5/mlx5_rxtx.c +2 -2
@@ -1287,8 +1287,8 @@ rxq_cq_to_mbuf(struct mlx5_rxq_data *rxq, struct rte_mbuf *pkt,if (rxq->rt_timestamp) ts =mlx5_txpp_convert_rx_ts (rxq->sh, ts); - pkt->timestamp = ts; - pkt->ol_flags |=PKT_RX_TIMESTAMP ; +mlx5_timestamp_set (pkt, rxq->timestamp_offset, ts); + pkt->ol_flags |= rxq->timestamp_rx_flag; } }
drivers/net/mlx5/mlx5_rxtx.h +19 -0
@@ -151,6 +151,8 @@ struct mlx5_rxq_data {/* CQ (UAR) access lock required for 32bit implementations */ #endif uint32_t tunnel;/* Tunnel information. */ +int timestamp_offset;/* Dynamic mbuf field for timestamp. */ +uint64_t timestamp_rx_flag;/* Dynamic mbuf flag for timestamp. */ uint64_t flow_meta_mask;int32_t flow_meta_offset; } __rte_cache_aligned;
@@ -681,4 +683,21 @@ mlx5_txpp_convert_tx_ts(struct mlx5_dev_ctx_shared *sh, uint64_t mts) return ci; } +/** +* Set timestamp in mbuf dynamic field. +* +* @param mbuf +* Structure to write into. +* @param offset +* Dynamic field offset in mbuf structure. +* @param timestamp +* Value to write. +*/ +static __rte_always_inline void +mlx5_timestamp_set (struct rte_mbuf *mbuf,int offset, +rte_mbuf_timestamp_t timestamp) +{ + *RTE_MBUF_DYNFIELD(mbuf, offset, rte_mbuf_timestamp_t *) = timestamp; +} +#endif /* RTE_PMD_MLX5_RXTX_H_ */
drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +21 -20
65 lines not on this page · raw message
drivers/net/mlx5/mlx5_rxtx_vec_neon.h +22 -21
71 lines not on this page · raw message
drivers/net/mlx5/mlx5_rxtx_vec_sse.h +18 -17
@@ -251,7 +251,7 @@ rxq_cq_to_ptype_oflags_v(struct mlx5_rxq_data *rxq, __m128i cqes[4],__m128i pinfo0, pinfo1;__m128i pinfo, ptype;__m128i ol_flags =_mm_set1_epi32 (rxq->rss_hash *PKT_RX_RSS_HASH | - rxq->hw_timestamp *PKT_RX_TIMESTAMP ); + rxq->hw_timestamp * rxq->timestamp_rx_flag);__m128i cv_flags;const __m128i zero =_mm_setzero_si128 (); const __m128i ptype_mask =
@@ -656,31 +656,32 @@ rxq_burst_v(struct mlx5_rxq_data *rxq, struct rte_mbuf **pkts, uint16_t pkts_n,/* D.5 fill in mbuf - rearm_data and packet_type. */ rxq_cq_to_ptype_oflags_v (rxq, cqes, opcode, &pkts[pos]);if (rxq->hw_timestamp) { +int offset = rxq->timestamp_offset;if (rxq->rt_timestamp) {struct mlx5_dev_ctx_shared *sh = rxq->sh;uint64_t ts; ts =rte_be_to_cpu_64 (cq[pos].timestamp); - pkts[pos]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (pkts[pos], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); ts =rte_be_to_cpu_64 (cq[pos + p1].timestamp); - pkts[pos +1 ]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (pkts[pos +1 ], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); ts =rte_be_to_cpu_64 (cq[pos + p2].timestamp); - pkts[pos +2 ]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (pkts[pos +2 ], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); ts =rte_be_to_cpu_64 (cq[pos + p3].timestamp); - pkts[pos +3 ]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (pkts[pos +3 ], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); }else { - pkts[pos]->timestamp =rte_be_to_cpu_64 - (cq[pos].timestamp); - pkts[pos +1 ]->timestamp =rte_be_to_cpu_64 - (cq[pos + p1].timestamp); - pkts[pos +2 ]->timestamp =rte_be_to_cpu_64 - (cq[pos + p2].timestamp); - pkts[pos +3 ]->timestamp =rte_be_to_cpu_64 - (cq[pos + p3].timestamp); +mlx5_timestamp_set (pkts[pos], offset, +rte_be_to_cpu_64 (cq[pos].timestamp)); +mlx5_timestamp_set (pkts[pos +1 ], offset, +rte_be_to_cpu_64 (cq[pos + p1].timestamp)); +mlx5_timestamp_set (pkts[pos +2 ], offset, +rte_be_to_cpu_64 (cq[pos + p2].timestamp)); +mlx5_timestamp_set (pkts[pos +3 ], offset, +rte_be_to_cpu_64 (cq[pos + p3].timestamp)); } }if (rxq->dynf_meta) {
Signature · 1 line
2.28.0
PATCH v4 8/16 net/nfb: switch Rx timestamp to dynamic mbuf field
In reply to Thomas MonjalonThe mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced.
--- drivers/net/nfb/nfb_rx.c | 15 ++++++++++++++- drivers/net/nfb/nfb_rx.h | 21 +++++++++++++++++---- 2 files changed, 31 insertions(+), 5 deletions(-)
drivers/net/nfb/nfb_rx.c +14 -1
@@ -9,6 +9,9 @@#include "nfb_rx.h" #include "nfb.h" +uint64_t nfb_timestamp_rx_dynflag; +int nfb_timestamp_dynfield_offset =-1 ; +static int timestamp_check_handler(__rte_unused const char *key, const char *value, __rte_unused void *opaque)
@@ -24,6 +27,7 @@ static int nfb_check_timestamp(struct rte_devargs *devargs) {struct rte_kvargs *kvlist; +int ret;if (devargs ==NULL )return 0 ;
@@ -38,6 +42,7 @@ nfb_check_timestamp(struct rte_devargs *devargs) }/* Timestamps are enabled when there is * key-value pair: enable_timestamp=1 +* TODO: timestamp should be enabled with DEV_RX_OFFLOAD_TIMESTAMP */ if (rte_kvargs_process (kvlist,TIMESTAMP_ARG , timestamp_check_handler,NULL ) <0 ) {
@@ -46,6 +51,14 @@ nfb_check_timestamp(struct rte_devargs *devargs) }rte_kvargs_free (kvlist); + ret =rte_mbuf_dyn_rx_timestamp_register ( + &nfb_timestamp_dynfield_offset, + &nfb_timestamp_rx_dynflag); +if (ret !=0 ) { +RTE_LOG (ERR ,PMD ,"Cannot register Rx timestamp field/flag\n" ); +return -rte_errno; + } +return 1 ; }
@@ -125,7 +138,7 @@ nfb_eth_rx_queue_setup(struct rte_eth_dev *dev,else rte_free (rxq); -if (nfb_check_timestamp (dev->device->devargs)) +if (nfb_check_timestamp (dev->device->devargs) >0 ) rxq->flags |=NFB_TIMESTAMP_FLAG ;return ret;
drivers/net/nfb/nfb_rx.h +17 -4
@@ -15,6 +15,16 @@#define NFB_TIMESTAMP_FLAG (1 << 0) +extern uint64_t nfb_timestamp_rx_dynflag; +extern int nfb_timestamp_dynfield_offset; + +static inline rte_mbuf_timestamp_t * +nfb_timestamp_dynfield (struct rte_mbuf *mbuf) +{ +return RTE_MBUF_DYNFIELD (mbuf, + nfb_timestamp_dynfield_offset, rte_mbuf_timestamp_t *); +} +struct ndp_rx_queue {struct nfb_device *nfb;/* nfb dev structure */ struct ndp_queue *queue;/* rx queue */
@@ -190,16 +200,19 @@ nfb_eth_ndp_rx(void *queue, mbuf->ol_flags =0 ;if (timestamping_enabled) { +rte_mbuf_timestamp_t timestamp; +/* nanoseconds */ - mbuf->timestamp = + timestamp =rte_le_to_cpu_32 (*((uint32_t *) (packets[i].header +4 ))); - mbuf->timestamp <<=32 ; + timestamp <<=32 ;/* seconds */ - mbuf->timestamp |= + timestamp |=rte_le_to_cpu_32 (*((uint32_t *) (packets[i].header +8 ))); - mbuf->ol_flags |=PKT_RX_TIMESTAMP ; + *nfb_timestamp_dynfield (mbuf) = timestamp; + mbuf->ol_flags |= nfb_timestamp_rx_dynflag; } bufs[num_rx++] = mbuf;
Signature · 1 line
2.28.0
PATCH v4 9/16 net/octeontx2: switch Rx timestamp to dynamic mbuf field
In reply to Thomas MonjalonThe mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced.
The dynamic offset and flag are stored in struct otx2_timesync_info to favor cache locality.
--- drivers/net/octeontx2/otx2_ethdev.c | 10 ++++++++++ drivers/net/octeontx2/otx2_rx.h | 19 ++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-)
drivers/net/octeontx2/otx2_ethdev.c +10 -0
@@ -2219,6 +2219,16 @@ otx2_nix_dev_start(struct rte_eth_dev *eth_dev)else otx2_nix_timesync_disable (eth_dev); +if (dev->rx_offload_flags &NIX_RX_OFFLOAD_TSTAMP_F ) { + rc =rte_mbuf_dyn_rx_timestamp_register ( + &dev->tstamp.tstamp_dynfield_offset, + &dev->tstamp.rx_tstamp_dynflag); +if (rc !=0 ) { +otx2_err ("Failed to register Rx timestamp field/flag" ); +return -rte_errno; + } + } +/* Update VF about data off shifted by 8 bytes if PTP already * enabled in PF owning this VF */
drivers/net/octeontx2/otx2_rx.h +16 -3
@@ -49,6 +49,8 @@ struct otx2_timesync_info {uint64_t rx_tstamp;rte_iova_t tx_tstamp_iova;uint64_t *tx_tstamp; +uint64_t rx_tstamp_dynflag; +int tstamp_dynfield_offset;uint8_t tx_ready;uint8_t rx_ready; } __rte_cache_aligned;
@@ -63,6 +65,14 @@ union mbuf_initializer {uint64_t value; }; +static inline rte_mbuf_timestamp_t * +otx2_timestamp_dynfield (struct rte_mbuf *mbuf, +struct otx2_timesync_info *info) +{ +return RTE_MBUF_DYNFIELD (mbuf, + info->tstamp_dynfield_offset, rte_mbuf_timestamp_t *); +} + static __rte_always_inline void otx2_nix_mbuf_to_tstamp(struct rte_mbuf *mbuf, struct otx2_timesync_info *tstamp, const uint16_t flag,
@@ -77,15 +87,18 @@ otx2_nix_mbuf_to_tstamp(struct rte_mbuf *mbuf,/* Reading the rx timestamp inserted by CGX, viz at * starting of the packet data. */ - mbuf->timestamp =rte_be_to_cpu_64 (*tstamp_ptr); + *otx2_timestamp_dynfield (mbuf, tstamp) = +rte_be_to_cpu_64 (*tstamp_ptr);/* PKT_RX_IEEE1588_TMST flag needs to be set only in case * PTP packets are received. */ if (mbuf->packet_type ==RTE_PTYPE_L2_ETHER_TIMESYNC ) { - tstamp->rx_tstamp = mbuf->timestamp; + tstamp->rx_tstamp = + *otx2_timestamp_dynfield (mbuf, tstamp); tstamp->rx_ready =1 ; mbuf->ol_flags |=PKT_RX_IEEE1588_PTP | -PKT_RX_IEEE1588_TMST |PKT_RX_TIMESTAMP ; +PKT_RX_IEEE1588_TMST | + tstamp->rx_tstamp_dynflag; } } }
Signature · 1 line
2.28.0
PATCH v4 10/16 net/pcap: switch Rx timestamp to dynamic mbuf field
In reply to Thomas MonjalonThe mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced.
--- drivers/net/pcap/rte_eth_pcap.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
drivers/net/pcap/rte_eth_pcap.c +17 -3
@@ -51,6 +51,9 @@ static uint64_t start_cycles;static uint64_t hz;static uint8_t iface_idx; +static uint64_t timestamp_rx_dynflag; +static int timestamp_dynfield_offset =-1 ; +struct queue_stat {volatile unsigned long pkts;volatile unsigned long bytes;
@@ -265,9 +268,11 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) } mbuf->pkt_len = (uint16_t )header.caplen; - mbuf->timestamp = (uint64_t )header.ts.tv_sec *1000000 - + header.ts.tv_usec; - mbuf->ol_flags |=PKT_RX_TIMESTAMP ; + *RTE_MBUF_DYNFIELD (mbuf, timestamp_dynfield_offset, + rte_mbuf_timestamp_t *) = + (uint64_t )header.ts.tv_sec *1000000 + + header.ts.tv_usec; + mbuf->ol_flags |= timestamp_rx_dynflag; mbuf->port = pcap_q->port_id; bufs[num_rx] = mbuf; num_rx++;
@@ -656,6 +661,15 @@ eth_dev_stop(struct rte_eth_dev *dev)static int eth_dev_configure(struct rte_eth_dev *dev __rte_unused) { +int ret; + + ret =rte_mbuf_dyn_rx_timestamp_register (×tamp_dynfield_offset, + ×tamp_rx_dynflag); +if (ret !=0 ) { +PMD_LOG (ERR ,"Failed to register Rx timestamp field/flag" ); +return -rte_errno; + } +return 0 ; }
Signature · 1 line
2.28.0
PATCH v4 11/16 app/testpmd: switch Rx timestamp to dynamic mbuf field
In reply to Thomas MonjalonThe mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced.
--- app/test-pmd/util.c | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-)
app/test-pmd/util.c +36 -2
@@ -5,6 +5,7 @@#include <stdio.h> +#include <rte_bitops.h> #include <rte_net.h> #include <rte_mbuf.h> #include <rte_ether.h>
@@ -22,6 +23,39 @@ print_ether_addr(const char *what, const struct rte_ether_addr *eth_addr)printf ("%s%s" , what, buf); } +static inline bool +is_timestamp_enabled (const struct rte_mbuf *mbuf) +{ +static uint64_t timestamp_rx_dynflag; +int timestamp_rx_dynflag_offset; + +if (timestamp_rx_dynflag ==0 ) { + timestamp_rx_dynflag_offset =rte_mbuf_dynflag_lookup ( +RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME ,NULL ); +if (timestamp_rx_dynflag_offset <0 ) +return false; + timestamp_rx_dynflag =RTE_BIT64 (timestamp_rx_dynflag_offset); + } + +return (mbuf->ol_flags & timestamp_rx_dynflag) !=0 ; +} + +static inline rte_mbuf_timestamp_t +get_timestamp (const struct rte_mbuf *mbuf) +{ +static int timestamp_dynfield_offset =-1 ; + +if (timestamp_dynfield_offset <0 ) { + timestamp_dynfield_offset =rte_mbuf_dynfield_lookup ( +RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ); +if (timestamp_dynfield_offset <0 ) +return 0 ; + } + +return *RTE_MBUF_DYNFIELD (mbuf, + timestamp_dynfield_offset, rte_mbuf_timestamp_t *); +} +static inline void dump_pkt_burst (uint16_t port_id,uint16_t queue,struct rte_mbuf *pkts[],uint16_t nb_pkts,int is_rx)
@@ -107,8 +141,8 @@ dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],printf ("hash=0x%x ID=0x%x " , mb->hash.fdir.hash, mb->hash.fdir.id); } -if (ol_flags &PKT_RX_TIMESTAMP ) -printf (" - timestamp %" PRIu64" " , mb->timestamp); +if (is_timestamp_enabled (mb)) +printf (" - timestamp %" PRIu64" " ,get_timestamp (mb));if (ol_flags &PKT_RX_QINQ )printf (" - QinQ VLAN tci=0x%x, VLAN tci outer=0x%x" , mb->vlan_tci, mb->vlan_tci_outer);
Signature · 1 line
2.28.0
PATCH v4 12/16 examples/rxtx_callbacks: switch timestamp to dynamic field
In reply to Thomas MonjalonThe mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field.
--- examples/rxtx_callbacks/main.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
examples/rxtx_callbacks/main.c +15 -1
@@ -19,6 +19,15 @@#define MBUF_CACHE_SIZE 250#define BURST_SIZE 32 +static int hwts_dynfield_offset =-1 ; + +static inline rte_mbuf_timestamp_t * +hwts_field (struct rte_mbuf *mbuf) +{ +return RTE_MBUF_DYNFIELD (mbuf, + hwts_dynfield_offset, rte_mbuf_timestamp_t *); +} +typedef uint64_t tsc_t ;static int tsc_dynfield_offset =-1 ;
@@ -77,7 +86,7 @@ calc_latency(uint16_t port, uint16_t qidx __rte_unused,for (i =0 ; i < nb_pkts; i++) { cycles += now - *tsc_field (pkts[i]);if (hw_timestamping) - queue_ticks += ticks - pkts[i]->timestamp; + queue_ticks += ticks - *hwts_field (pkts[i]); } latency_numbers.total_cycles += cycles;
@@ -141,6 +150,11 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)return -1 ; } port_conf.rxmode.offloads |=DEV_RX_OFFLOAD_TIMESTAMP ; +rte_mbuf_dyn_rx_timestamp_register (&hwts_dynfield_offset,NULL ); +if (hwts_dynfield_offset <0 ) { +printf ("ERROR: Failed to register timestamp field\n" ); +return -rte_errno; + } } retval =rte_eth_dev_configure (port, rx_rings, tx_rings, &port_conf);
Signature · 1 line
2.28.0
PATCH v4 13/16 ethdev: add doxygen comment for Rx timestamp API
In reply to Thomas MonjalonThe offload flag DEV_RX_OFFLOAD_TIMESTAMP had no documentation. After switching to dynamic mbuf flag and field,
it becomes even more important to explicit the feature behaviour.
A doxygen comment for the timesync API was mentioning the deprecated timestamp field, so it is also updated.
--- lib/librte_ethdev/rte_ethdev.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
lib/librte_ethdev/rte_ethdev.h +6 -1
@@ -1344,6 +1344,11 @@ struct rte_eth_conf {#define DEV_RX_OFFLOAD_VLAN_EXTEND 0x00000400#define DEV_RX_OFFLOAD_JUMBO_FRAME 0x00000800#define DEV_RX_OFFLOAD_SCATTER 0x00002000 +/** +* Timestamp is set by the driver in RTE_MBUF_DYNFIELD_TIMESTAMP_NAME +* and RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME is set in ol_flags. +* The mbuf field and flag are registered when the offload is configured. +*/ #define DEV_RX_OFFLOAD_TIMESTAMP 0x00004000#define DEV_RX_OFFLOAD_SECURITY 0x00008000#define DEV_RX_OFFLOAD_KEEP_CRC 0x00010000
@@ -4647,7 +4652,7 @@ int rte_eth_timesync_write_time(uint16_t port_id, const struct timespec *time);* rte_eth_read_clock(port, base_clock); * * Then, convert the raw mbuf timestamp with: -* base_time_sec + (double)(mbuf->timestamp - base_clock) / freq; +* base_time_sec + (double)(*timestamp_dynfield(mbuf) - 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.
Signature · 1 line
2.28.0
Re: [dpdk-dev] [PATCH v4 13/16] ethdev: add doxygen comment for Rx timestamp API
Quoted 9 lines · Thomas Monjalon
The offload flag
DEV_RX_OFFLOAD_TIMESTAMPhad no documentation. After switching to dynamic mbuf flag and field,
it becomes even more important to explicit the feature behaviour.A doxygen comment for the timesync API was mentioning the deprecated timestamp field, so it is also updated.
Signed-off-by Thomas Monjalon <[email protected]>Acked-by David Marchand <[email protected]>
PATCH v4 14/16 mbuf: remove deprecated timestamp field
In reply to Thomas MonjalonAs announced in the deprecation note, the field timestamp is removed to give more space to the dynamic fields. The related offload flag PKT_RX_TIMESTAMP is also removed.
This is how the mbuf layout looks like (pahole-style):
word type name byte size
0 void * buf_addr; /* 0 + 8 */
1 rte_iova_t buf_iova /* 8 + 8 */
/* --- RTE_MARKER64 rearm_data; */
2 uint16_t data_off; /* 16 + 2 */
uint16_t refcnt; /* 18 + 2 */
uint16_t nb_segs; /* 20 + 2 */
uint16_t port; /* 22 + 2 */
3 uint64_t ol_flags; /* 24 + 8 */
/* --- RTE_MARKER rx_descriptor_fields1; */
4 uint32_t union packet_type; /* 32 + 4 */
uint32_t pkt_len; /* 36 + 4 */
5 uint16_t data_len; /* 40 + 2 */
uint16_t vlan_tci; /* 42 + 2 */
5.5 uint64_t union hash; /* 44 + 8 */
6.5 uint16_t vlan_tci_outer; /* 52 + 2 */
uint16_t buf_len; /* 54 + 2 */
7 uint64_t dynfield0[1]; /* 56 + 8 */
/* --- RTE_MARKER cacheline1; */
8 struct rte_mempool * pool; /* 64 + 8 */
9 struct rte_mbuf * next; /* 72 + 8 */
10 uint64_t union tx_offload; /* 80 + 8 */
11 struct rte_mbuf_ext_shared_info * shinfo; /* 88 + 8 */
12 uint16_t priv_size; /* 96 + 2 */
uint16_t timesync; /* 98 + 2 */
12.5 uint32_t dynfield1[7]; /* 100 + 28 */16 /* --- END 128 */
--- app/test/test_mbuf.c | 1 - doc/guides/rel_notes/deprecation.rst | 4 ---- doc/guides/rel_notes/release_20_11.rst | 4 ++++ lib/librte_mbuf/rte_mbuf.c | 2 -- lib/librte_mbuf/rte_mbuf.h | 2 +- lib/librte_mbuf/rte_mbuf_core.h | 12 ++---------- lib/librte_mbuf/rte_mbuf_dyn.c | 1 + 7 files changed, 8 insertions(+), 18 deletions(-)
app/test/test_mbuf.c +0 -1
@@ -1621,7 +1621,6 @@ test_get_rx_ol_flag_name(void)VAL_NAME (PKT_RX_FDIR_FLX ),VAL_NAME (PKT_RX_QINQ_STRIPPED ),VAL_NAME (PKT_RX_LRO ), -VAL_NAME (PKT_RX_TIMESTAMP ),VAL_NAME (PKT_RX_SEC_OFFLOAD ),VAL_NAME (PKT_RX_SEC_OFFLOAD_FAILED ), VAL_NAME(PKT_RX_OUTER_L4_CKSUM_BAD),
doc/guides/rel_notes/deprecation.rst +0 -4
@@ -84,10 +84,6 @@ Deprecation Notices * mbuf: Some fields will be converted to dynamic API in DPDK 20.11 in order to reserve more space for the dynamic fields, as explained in `this presentation <https://www.youtube.com/watch?v=Ttl6MlhmzWY>`_. - The following static fields will be moved as dynamic: - - - ``timestamp`` - As a consequence, the layout of the ``struct rte_mbuf`` will be re-arranged, avoiding impact on vectorized implementation of the driver datapaths, while evaluating performance gains of a better use of the first cache line.
doc/guides/rel_notes/release_20_11.rst +4 -0
@@ -458,6 +458,10 @@ API Changes * mbuf: Removed the field ``seqn`` from the structure ``rte_mbuf``. It is replaced with dynamic fields. +* mbuf: Removed the field ``timestamp`` from the structure ``rte_mbuf``. + It is replaced with the dynamic field RTE_MBUF_DYNFIELD_TIMESTAMP_NAME + which was previously used only for Tx. + * pci: Removed the ``rte_kernel_driver`` enum defined in rte_dev.h and replaced with a private enum in the PCI subsystem.
lib/librte_mbuf/rte_mbuf.c +0 -2
@@ -764,7 +764,6 @@ const char *rte_get_rx_ol_flag_name(uint64_t mask)case PKT_RX_QINQ_STRIPPED :return "PKT_RX_QINQ_STRIPPED" ;case PKT_RX_QINQ :return "PKT_RX_QINQ" ;case PKT_RX_LRO :return "PKT_RX_LRO" ; -case PKT_RX_TIMESTAMP :return "PKT_RX_TIMESTAMP" ;case PKT_RX_SEC_OFFLOAD :return "PKT_RX_SEC_OFFLOAD" ;case PKT_RX_SEC_OFFLOAD_FAILED :return "PKT_RX_SEC_OFFLOAD_FAILED" ;case PKT_RX_OUTER_L4_CKSUM_BAD :return "PKT_RX_OUTER_L4_CKSUM_BAD" ;
@@ -808,7 +807,6 @@ rte_get_rx_ol_flag_list(uint64_t mask, char *buf, size_t buflen) { PKT_RX_FDIR_FLX, PKT_RX_FDIR_FLX, NULL }, { PKT_RX_QINQ_STRIPPED, PKT_RX_QINQ_STRIPPED, NULL }, { PKT_RX_LRO, PKT_RX_LRO, NULL }, - { PKT_RX_TIMESTAMP, PKT_RX_TIMESTAMP, NULL }, { PKT_RX_SEC_OFFLOAD, PKT_RX_SEC_OFFLOAD, NULL }, { PKT_RX_SEC_OFFLOAD_FAILED, PKT_RX_SEC_OFFLOAD_FAILED, NULL }, { PKT_RX_QINQ, PKT_RX_QINQ, NULL },
lib/librte_mbuf/rte_mbuf.h +1 -1
@@ -1095,6 +1095,7 @@ rte_pktmbuf_attach_extbuf(struct rte_mbuf *m, void *buf_addr,static inline void rte_mbuf_dynfield_copy (struct rte_mbuf *mdst,const struct rte_mbuf *msrc) { +memcpy (&mdst->dynfield0, msrc->dynfield0,sizeof (mdst->dynfield0));memcpy (&mdst->dynfield1, msrc->dynfield1,sizeof (mdst->dynfield1)); }
@@ -1108,7 +1109,6 @@ __rte_pktmbuf_copy_hdr(struct rte_mbuf *mdst, const struct rte_mbuf *msrc) mdst->tx_offload = msrc->tx_offload; mdst->hash = msrc->hash; mdst->packet_type = msrc->packet_type; - mdst->timestamp = msrc->timestamp;rte_mbuf_dynfield_copy (mdst, msrc); }
lib/librte_mbuf/rte_mbuf_core.h +2 -10
@@ -149,10 +149,7 @@ extern "C" {*/ #define PKT_RX_LRO (1ULL << 16) -/** -* Indicate that the timestamp field in the mbuf is valid. -*/ -#define PKT_RX_TIMESTAMP (1ULL << 17) +/* There is no flag defined at offset 17. It is free for any future use. */ /** * Indicate that security offload processing was applied on the RX packet.
@@ -589,12 +586,7 @@ struct rte_mbuf {uint16_t buf_len;/**< Length of segment buffer. */ -/** 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; +uint64_t dynfield0[1 ];/**< Reserved for dynamic fields. */ /* second cache line - fields only used in slow path or on TX */ RTE_MARKER cacheline1 __rte_cache_min_aligned;
lib/librte_mbuf/rte_mbuf_dyn.c +1 -0
@@ -125,6 +125,7 @@ init_shared_mem(void)* rte_mbuf_dynfield_copy(). */ memset (shm,0 ,sizeof (*shm)); +mark_free (dynfield0);mark_free (dynfield1);/* init free_flags */
Signature · 1 line
2.28.0