5454#include <rte_udp.h>
5555#include <rte_eth_bond.h>
5656#include <rte_eth_bond_8023ad.h>
57+ #include <rte_mbuf_dyn.h>
5758
5859#include "ff_dpdk_if.h"
5960#include "ff_dpdk_pcap.h"
@@ -80,6 +81,8 @@ static int numa_on;
8081
8182static unsigned idle_sleep ;
8283static unsigned pkt_tx_delay ;
84+ static int timestamp_dynfield_offset = -1 ;
85+ static uint64_t timestamp_dynflag_mask ;
8386static uint64_t usr_cb_tsc ;
8487static int stop_loop ;
8588
@@ -741,6 +744,11 @@ init_port_start(void)
741744 pconf -> hw_features .rx_csum = 1 ;
742745 }
743746
747+ if (dev_info .rx_offload_capa & RTE_ETH_RX_OFFLOAD_TIMESTAMP ) {
748+ ff_log (FF_LOG_INFO , FF_LOGTYPE_FSTACK_LIB , "RX timestamp offload supported\n" );
749+ port_conf .rxmode .offloads |= RTE_ETH_RX_OFFLOAD_TIMESTAMP ;
750+ }
751+
744752 if (ff_global_cfg .dpdk .tx_csum_offoad_skip == 0 ) {
745753 if ((dev_info .tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM )) {
746754 ff_log (FF_LOG_INFO , FF_LOGTYPE_FSTACK_LIB , "TX ip checksum offload supported\n" );
@@ -852,6 +860,20 @@ init_port_start(void)
852860 return ret ;
853861 }
854862
863+ if ((port_conf .rxmode .offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP ) &&
864+ timestamp_dynfield_offset < 0 ) {
865+ ret = rte_mbuf_dyn_rx_timestamp_register (
866+ & timestamp_dynfield_offset , & timestamp_dynflag_mask );
867+ if (ret == 0 ) {
868+ ff_log (FF_LOG_INFO , FF_LOGTYPE_FSTACK_LIB ,
869+ "RX timestamp dynfield registered, offset=%d\n" ,
870+ timestamp_dynfield_offset );
871+ } else {
872+ ff_log (FF_LOG_ERR , FF_LOGTYPE_FSTACK_LIB ,
873+ "RX timestamp dynfield registration failed\n" );
874+ }
875+ }
876+
855877//RSS reta update will failed when enable flow isolate
856878#if !defined(FF_FLOW_ISOLATE ) && !defined(FF_FLOW_IPIP )
857879 if (nb_queues > 1 ) {
@@ -1460,6 +1482,13 @@ ff_veth_input(const struct ff_dpdk_if_context *ctx, struct rte_mbuf *pkt)
14601482 ff_mbuf_set_vlan_info (hdr , pkt -> vlan_tci );
14611483 }
14621484
1485+ if ((pkt -> ol_flags & timestamp_dynflag_mask ) &&
1486+ timestamp_dynfield_offset >= 0 ) {
1487+ rte_mbuf_timestamp_t ts = * RTE_MBUF_DYNFIELD (
1488+ pkt , timestamp_dynfield_offset , rte_mbuf_timestamp_t * );
1489+ ff_mbuf_set_timestamp (hdr , (uint64_t )ts );
1490+ }
1491+
14631492 struct rte_mbuf * pn = pkt -> next ;
14641493 void * prev = hdr ;
14651494 while (pn != NULL ) {
0 commit comments