[dpdk-dev,v2] net/tap: fix the vdev data sharing for tun

Message ID 1526986914-31856-1-git-send-email-vipin.varghese@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Varghese, Vipin May 22, 2018, 11:01 a.m. UTC
  Fixes: ee27edbe0c10 ("drivers/net: share vdev data to secondary process")

Enables TUN PMD sharing by attaching the port from the shared data.

Cc: zhihong.wang@intel.com
Cc: ferruh.yigit@intel.com

Signed-off-by: Vipin Varghese <vipin.varghese@intel.com>
---

Changes in V2:
- removal of To Do comment - Keith Wiles, Ferruh Yigit
---
 drivers/net/tap/rte_eth_tap.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
  

Comments

Wiles, Keith May 22, 2018, 1:40 p.m. UTC | #1
> On May 22, 2018, at 6:01 AM, Varghese, Vipin <vipin.varghese@intel.com> wrote:
> 
> Fixes: ee27edbe0c10 ("drivers/net: share vdev data to secondary process")
> 
> Enables TUN PMD sharing by attaching the port from the shared data.
> 
> Cc: zhihong.wang@intel.com
> Cc: ferruh.yigit@intel.com
> 
> Signed-off-by: Vipin Varghese <vipin.varghese@intel.com>
> ---
> 
> Changes in V2:
> - removal of To Do comment - Keith Wiles, Ferruh Yigit

Acked-by: Keith Wiles<keith.wiles@intel.com>

Regards,
Keith
  
Ferruh Yigit May 22, 2018, 10:26 p.m. UTC | #2
On 5/22/2018 2:40 PM, Wiles, Keith wrote:
> 
> 
>> On May 22, 2018, at 6:01 AM, Varghese, Vipin <vipin.varghese@intel.com> wrote:
>>
>> Fixes: ee27edbe0c10 ("drivers/net: share vdev data to secondary process")
>>
>> Enables TUN PMD sharing by attaching the port from the shared data.
>>
>> Cc: zhihong.wang@intel.com
>> Cc: ferruh.yigit@intel.com
>>
>> Signed-off-by: Vipin Varghese <vipin.varghese@intel.com>
>> ---
>>
>> Changes in V2:
>> - removal of To Do comment - Keith Wiles, Ferruh Yigit
> 
> Acked-by: Keith Wiles<keith.wiles@intel.com>

Applied to dpdk-next-net/master, thanks.
  

Patch

diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 8d8f67b..41300a6 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -1650,6 +1650,7 @@  rte_pmd_tun_probe(struct rte_vdev_device *dev)
 	struct rte_kvargs *kvlist = NULL;
 	char tun_name[RTE_ETH_NAME_MAX_LEN];
 	char remote_iface[RTE_ETH_NAME_MAX_LEN];
+	struct rte_eth_dev *eth_dev;
 
 	strcpy(tuntap_name, "TUN");
 
@@ -1657,6 +1658,17 @@  rte_pmd_tun_probe(struct rte_vdev_device *dev)
 	params = rte_vdev_device_args(dev);
 	memset(remote_iface, 0, RTE_ETH_NAME_MAX_LEN);
 
+	if (rte_eal_process_type() == RTE_PROC_SECONDARY &&
+	    strlen(params) == 0) {
+		eth_dev = rte_eth_dev_attach_secondary(name);
+		if (!eth_dev) {
+			TAP_LOG(ERR, "Failed to probe %s", name);
+			return -1;
+		}
+		eth_dev->dev_ops = &ops;
+		return 0;
+	}
+
 	snprintf(tun_name, sizeof(tun_name), "%s%u",
 		 DEFAULT_TUN_NAME, tun_unit++);