net/pcap: fix registration of timestamp dynamic field
authorOlivier Matz <olivier.matz@6wind.com>
Fri, 13 Nov 2020 10:39:57 +0000 (11:39 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 13 Nov 2020 18:43:27 +0000 (19:43 +0100)
In pcap pmd, the timestamp mbuf dynamic field is mandatory. When the
pcap pmd is created in a secondary process (this is the case for pdump),
it cannot be registered because this is not allowed from a secondary
process.

To ensure that the field is properly registered, do it from probe()
instead of configure(). Indeed, probe() is first invoked on the primary
process when a device is created in a secondary, this enables
registering dynfield from secondary process.

Bugzilla ID: 571
Fixes: d23d73d088c1 ("net/pcap: switch Rx timestamp to dynamic mbuf field")

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
drivers/net/pcap/rte_eth_pcap.c

index 4e6d493..4930d7d 100644 (file)
@@ -661,15 +661,6 @@ status_down:
 static int
 eth_dev_configure(struct rte_eth_dev *dev __rte_unused)
 {
-       int ret;
-
-       ret = rte_mbuf_dyn_rx_timestamp_register(&timestamp_dynfield_offset,
-                       &timestamp_rx_dynflag);
-       if (ret != 0) {
-               PMD_LOG(ERR, "Failed to register Rx timestamp field/flag");
-               return -rte_errno;
-       }
-
        return 0;
 }
 
@@ -1387,6 +1378,13 @@ pmd_pcap_probe(struct rte_vdev_device *dev)
        start_cycles = rte_get_timer_cycles();
        hz = rte_get_timer_hz();
 
+       ret = rte_mbuf_dyn_rx_timestamp_register(&timestamp_dynfield_offset,
+                       &timestamp_rx_dynflag);
+       if (ret != 0) {
+               PMD_LOG(ERR, "Failed to register Rx timestamp field/flag");
+               return -1;
+       }
+
        if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
                eth_dev = rte_eth_dev_attach_secondary(name);
                if (!eth_dev) {