From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id 14C9C2F42 for ; Tue, 13 Nov 2018 18:11:05 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Nov 2018 09:11:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,228,1539673200"; d="scan'208";a="86188860" Received: from silpixa00399752.ir.intel.com (HELO silpixa00399752.ger.corp.intel.com) ([10.237.222.212]) by fmsmga008.fm.intel.com with ESMTP; 13 Nov 2018 09:11:03 -0800 From: Ferruh Yigit To: qi.z.zhang@intel.com Cc: dev@dpdk.org, Ferruh Yigit , xueqin.lin@intel.com Date: Tue, 13 Nov 2018 17:11:01 +0000 Message-Id: <20181113171101.40212-1-ferruh.yigit@intel.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <861c43b2-a082-fdf8-61b9-2df1f4ed919c@intel.com> References: <861c43b2-a082-fdf8-61b9-2df1f4ed919c@intel.com> Subject: [dpdk-dev] [PATCH] net/pcap: fix pcap handlers for secondary X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Nov 2018 17:11:06 -0000 The intension in NOT to make a complete patch, this is to just for input to discussion. Signed-off-by: Ferruh Yigit --- 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