src/dpdk/lib/librte_ethdev/rte_ethdev.c
struct rte_eth_dev *
rte_eth_dev_attach_secondary(const char *name)
{
	uint16_t i;
	struct rte_eth_dev *eth_dev = NULL;

	eth_dev_shared_data_prepare();

	/* Synchronize port attachment to primary port creation and release. */
	rte_spinlock_lock(&eth_dev_shared_data->ownership_lock);

	for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
		if (strcmp(eth_dev_shared_data->data[i].name, name) == 0)
			break;
	}
	if (i == RTE_MAX_ETHPORTS) {
		RTE_ETHDEV_LOG(ERR,
			"Device %s is not driven by the primary process\n",
			name);
	} else {
		eth_dev = eth_dev_get(i);
		RTE_ASSERT(eth_dev->data->port_id == i);
	}

	rte_spinlock_unlock(&eth_dev_shared_data->ownership_lock);
	return eth_dev;
}
/*
 * Attach to a port already registered by the primary process, which
 * makes sure that the same device would have the same port id both
 * in the primary and secondary process.
 */
Attach to a port already registered by the primary process, which
makes sure that the same device would have the same port id both
in the primary and secondary process.
Attach to a port already registered by the primary process which makes sure that the same device would have the same port id both in the primary and secondary process .
struct rte_eth_dev *
rte_eth_dev_attach_secondary(const char *name)
{
	uint16_t i;
	struct rte_eth_dev *eth_dev = NULL;
	eth_dev_shared_data_prepare();
	rte_spinlock_lock(&eth_dev_shared_data->ownership_lock);
	for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
		if (strcmp(eth_dev_shared_data->data[i].name, name) == 0)
			break;
	}
	if (i == RTE_MAX_ETHPORTS) {
		RTE_ETHDEV_LOG(ERR,
			"Device %s is not driven by the primary process\n",
			name);
	} else {
		eth_dev = eth_dev_get(i);
		RTE_ASSERT(eth_dev->data->port_id == i);
	}
	rte_spinlock_unlock(&eth_dev_shared_data->ownership_lock);
	return eth_dev;
}
struct rte_eth_dev * rte_eth_dev_attach_secondary ( const char * name ) { uint16_t i ; struct rte_eth_dev * eth_dev = NULL ; eth_dev_shared_data_prepare ( ) ; rte_spinlock_lock ( & eth_dev_shared_data -> ownership_lock ) ; for ( i = 0 ; i < RTE_MAX_ETHPORTS ; i ++ ) { if ( strcmp ( eth_dev_shared_data -> data [ i ] . name , name ) == 0 ) break ; } if ( i == RTE_MAX_ETHPORTS ) { RTE_ETHDEV_LOG ( ERR , " \n " , name ) ; } else { eth_dev = eth_dev_get ( i ) ; RTE_ASSERT ( eth_dev -> data -> port_id == i ) ; } rte_spinlock_unlock ( & eth_dev_shared_data -> ownership_lock ) ; return eth_dev ; }
Attach to a port already registered by the primary process, which
 makes sure that the same device would have the same port id both
 in the primary and secondary process.
Attach to a port already registered by the primary process which makes sure that the same device would have the same port id both in the primary and secondary process .
/* Synchronize port attachment to primary port creation and release. */