net/pcap: fix Rx timestamp in secondary process
PATCH 1/2 net/pcap: fix Rx timestamp in secondary process
The offset and flag of the Rx timestamp dynamic field are the same in all processes, but the driver keeps them in static variables which are only set in dev_configure. A secondary process does not configure the port, so its copy of the offset is still -1 while the shared device data says the offload is enabled. The Rx burst then stores the timestamp over buf_addr of the mbuf.
Move the offset and flag into the device private data, which is shared with secondary processes.
Bugzilla ID: 2128
--- drivers/net/pcap/pcap_ethdev.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/net/pcap/pcap_ethdev.c +10 -10
@@ -60,9 +60,6 @@ static struct timespec start_time;static uint64_t start_cycles;static uint64_t hz; -static uint64_t timestamp_rx_dynflag; -static int timestamp_dynfield_offset =-1 ; -struct queue_stat {volatile unsigned long pkts;volatile unsigned long bytes;
@@ -122,6 +119,8 @@ struct pmd_internals {bool rx_scatter;bool timestamp_offloading;bool lsc_active; +int timestamp_dynfield_offset; +uint64_t timestamp_rx_dynflag; };struct pmd_process_private {
@@ -268,6 +267,7 @@ eth_pcap_rx_infinite(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) {int i;struct pcap_rx_queue *pcap_q = queue; +struct pmd_internals *internals = rte_eth_devices[pcap_q->port_id].data->dev_private;uint32_t rx_bytes =0 ;if (unlikely (nb_pkts ==0 ))
@@ -296,9 +296,9 @@ eth_pcap_rx_infinite(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)struct timespec ts;timespec_get (&ts,TIME_UTC ); - *RTE_MBUF_DYNFIELD (bufs[i], timestamp_dynfield_offset, + *RTE_MBUF_DYNFIELD (bufs[i], internals->timestamp_dynfield_offset, rte_mbuf_timestamp_t *) = rte_timespec_to_ns(&ts); - bufs[i]->ol_flags |= timestamp_rx_dynflag; + bufs[i]->ol_flags |= internals->timestamp_rx_dynflag; } rx_bytes += bufs[i]->data_len;
@@ -420,10 +420,10 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)uint64_t ns = (uint64_t )header->ts.tv_sec *NSEC_PER_SEC + header->ts.tv_usec; - *RTE_MBUF_DYNFIELD (mbuf, timestamp_dynfield_offset, + *RTE_MBUF_DYNFIELD (mbuf, internals->timestamp_dynfield_offset, rte_mbuf_timestamp_t *) = ns; - mbuf->ol_flags |= timestamp_rx_dynflag; + mbuf->ol_flags |= internals->timestamp_rx_dynflag; } mbuf->port = pcap_q->port_id;
@@ -1027,9 +1027,9 @@ eth_dev_configure(struct rte_eth_dev *dev) internals->rx_scatter = !!(rxmode->offloads &RTE_ETH_RX_OFFLOAD_SCATTER ); internals->timestamp_offloading = !!(rxmode->offloads &RTE_ETH_RX_OFFLOAD_TIMESTAMP ); -if (internals->timestamp_offloading && timestamp_rx_dynflag ==0 ) { -int ret =rte_mbuf_dyn_rx_timestamp_register (×tamp_dynfield_offset, - ×tamp_rx_dynflag); +if (internals->timestamp_offloading && internals->timestamp_rx_dynflag ==0 ) { +int ret =rte_mbuf_dyn_rx_timestamp_register (&internals->timestamp_dynfield_offset, + &internals->timestamp_rx_dynflag);if (ret !=0 ) {PMD_LOG (ERR ,"Failed to register Rx timestamp field/flag" );return ret;
Signature · 1 line
2.53.0
PATCH 2/2 net/pcap: handle > 64K packets in capture file
If a pcap file given to the pcap PMD had a super jumbo frame there would be a silent truncation and also the driver was not checking for excessive number of mbuf segments.
Bugzilla ID: 2129
--- drivers/net/pcap/pcap_ethdev.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/pcap/pcap_ethdev.c +5 -2
@@ -226,7 +226,7 @@ queue_missed_stat_get(struct rte_eth_dev *dev, unsigned int qid)static int eth_pcap_rx_jumbo (struct rte_mempool *mb_pool,struct rte_mbuf *mbuf, -const u_char *data,uint16_t data_len) +const u_char *data,uint32_t data_len) {/* Copy the first segment. */ uint16_t len =rte_pktmbuf_tailroom (mbuf);
@@ -237,9 +237,12 @@ eth_pcap_rx_jumbo(struct rte_mempool *mb_pool, struct rte_mbuf *mbuf, data += len;while (data_len >0 ) { +/* Avoid excessively long chain */ +if (mbuf->nb_segs +1 >RTE_MBUF_MAX_NB_SEGS ) +return -1 ; +/* Allocate next mbuf and point to that. */ m->next =rte_pktmbuf_alloc (mb_pool); -if (unlikely (!m->next))return -1 ;
Signature · 1 line
2.53.0