The intension in NOT to make a complete patch, this is to just for input
to discussion.

Signed-off-by: Ferruh Yigit <ferruh.yi...@intel.com>
---
 drivers/net/pcap/rte_eth_pcap.c | 61 ++++++++++++++++++++++++++++-----
 1 file changed, 52 insertions(+), 9 deletions(-)

diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c
index 7bbe72e25..3bc174841 100644
--- a/drivers/net/pcap/rte_eth_pcap.c
+++ b/drivers/net/pcap/rte_eth_pcap.c
@@ -81,6 +81,7 @@ struct pmd_internals {
        int if_index;
        int single_iface;
        int phy_mac;
+       char devargs[ETH_PCAP_ARG_MAXLEN];
 };
 
 struct pmd_devargs {
@@ -934,6 +935,8 @@ pmd_init_internals(struct rte_vdev_device *vdev,
         */
        (*eth_dev)->dev_ops = &ops;
 
+       strlcpy((*internals)->devargs, rte_vdev_device_args(vdev), 
ETH_PCAP_ARG_MAXLEN);
+
        return 0;
 }
 
@@ -1123,21 +1126,24 @@ pmd_pcap_probe(struct rte_vdev_device *dev)
        hz = rte_get_timer_hz();
 
        if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
+               struct pmd_internals *internals;
+
                eth_dev = rte_eth_dev_attach_secondary(name);
                if (!eth_dev) {
                        PMD_LOG(ERR, "Failed to probe %s", name);
                        return -1;
                }
-               /* TODO: request info from primary to set up Rx and Tx */
-               eth_dev->dev_ops = &ops;
-               eth_dev->device = &dev->device;
-               rte_eth_dev_probing_finish(eth_dev);
-               return 0;
-       }
 
-       kvlist = rte_kvargs_parse(rte_vdev_device_args(dev), valid_arguments);
-       if (kvlist == NULL)
-               return -1;
+               internals = eth_dev->data->dev_private;
+
+               kvlist = rte_kvargs_parse(internals->devargs, valid_arguments);
+               if (kvlist == NULL)
+                       return -1;
+       } else {
+               kvlist = rte_kvargs_parse(rte_vdev_device_args(dev), 
valid_arguments);
+               if (kvlist == NULL)
+                       return -1;
+       }
 
        /*
         * If iface argument is passed we open the NICs and use them for
@@ -1202,6 +1208,43 @@ pmd_pcap_probe(struct rte_vdev_device *dev)
                goto free_kvlist;
 
 create_eth:
+       if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
+               struct pmd_internals *internals = eth_dev->data->dev_private;
+               unsigned int i;
+
+               /* TODO: request info from primary to set up Rx and Tx */
+               eth_dev->dev_ops = &ops;
+               eth_dev->device = &dev->device;
+
+               for (i = 0; i < pcaps.num_of_queue; i++) {
+                       struct pcap_rx_queue *rx = &internals->rx_queue[i];
+                       struct devargs_queue *queue = &pcaps.queue[i];
+
+                       rx->pcap = queue->pcap;
+                       snprintf(rx->name, sizeof(rx->name), "%s", queue->name);
+                       snprintf(rx->type, sizeof(rx->type), "%s", queue->type);
+               }
+
+               for (i = 0; i < dumpers.num_of_queue; i++) {
+                       struct pcap_tx_queue *tx = &internals->tx_queue[i];
+                       struct devargs_queue *queue = &dumpers.queue[i];
+
+                       tx->dumper = queue->dumper;
+                       tx->pcap = queue->pcap;
+                       snprintf(tx->name, sizeof(tx->name), "%s", queue->name);
+                       snprintf(tx->type, sizeof(tx->type), "%s", queue->type);
+               }
+
+               eth_dev->rx_pkt_burst = eth_pcap_rx;
+               if (is_tx_pcap)
+                       eth_dev->tx_pkt_burst = eth_pcap_tx_dumper;
+               else
+                       eth_dev->tx_pkt_burst = eth_pcap_tx;
+
+               rte_eth_dev_probing_finish(eth_dev);
+               return 0;
+       }
+
        ret = eth_from_pcaps(dev, &pcaps, pcaps.num_of_queue, &dumpers,
                dumpers.num_of_queue, single_iface, is_tx_pcap);
 
-- 
2.17.2

Reply via email to