drivers/net: use internal function to get ethdev struct

Make changes in PMDs to use the new function where
rte_eth_dev_get_port_by_name is used to get port_id
to access rte_eth_devices

Signed-off-by: Kumara Parameshwaran <kparameshwar@vmware.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
This commit is contained in:
Kumara Parameshwaran 2022-02-03 13:54:12 +05:30 committed by Ferruh Yigit
parent e6b9d6411e
commit bcd9f09883
5 changed files with 15 additions and 26 deletions

View File

@ -151,8 +151,8 @@ int
rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
{
struct bond_dev_private *internals;
struct rte_eth_dev *bond_dev;
char devargs[52];
uint16_t port_id;
int ret;
if (name == NULL) {
@ -169,8 +169,8 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
if (ret)
return ret;
ret = rte_eth_dev_get_port_by_name(name, &port_id);
RTE_ASSERT(!ret);
bond_dev = rte_eth_dev_get_by_name(name);
RTE_ASSERT(bond_dev);
/*
* To make bond_ethdev_configure() happy we need to free the
@ -178,11 +178,11 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
*
* Also see comment in bond_ethdev_configure().
*/
internals = rte_eth_devices[port_id].data->dev_private;
internals = bond_dev->data->dev_private;
rte_kvargs_free(internals->kvlist);
internals->kvlist = NULL;
return port_id;
return bond_dev->data->port_id;
}
int

View File

@ -469,7 +469,6 @@ static int ipn3ke_vswitch_probe(struct rte_afu_device *afu_dev)
struct ipn3ke_hw *hw;
struct rte_eth_dev *i40e_eth;
struct ifpga_rawdev *ifpga_dev;
uint16_t port_id;
int i, j, retval;
char *fvl_bdf;
@ -519,14 +518,12 @@ static int ipn3ke_vswitch_probe(struct rte_afu_device *afu_dev)
for (; j < 8; j++) {
fvl_bdf = ifpga_dev->fvl_bdf[j];
retval = rte_eth_dev_get_port_by_name(fvl_bdf,
&port_id);
if (retval) {
i40e_eth = rte_eth_dev_get_by_name(fvl_bdf);
if (!i40e_eth) {
continue;
} else {
i40e_eth = &rte_eth_devices[port_id];
rpst.i40e_pf_eth = i40e_eth;
rpst.i40e_pf_eth_port_id = port_id;
rpst.i40e_pf_eth_port_id = i40e_eth->data->port_id;
j++;
break;

View File

@ -88,17 +88,14 @@ memif_mp_send_region(const struct rte_mp_msg *msg, const void *peer)
const struct mp_region_msg *msg_param = (const struct mp_region_msg *)msg->param;
struct rte_mp_msg reply;
struct mp_region_msg *reply_param = (struct mp_region_msg *)reply.param;
uint16_t port_id;
int ret;
/* Get requested port */
ret = rte_eth_dev_get_port_by_name(msg_param->port_name, &port_id);
if (ret) {
dev = rte_eth_dev_get_by_name(msg_param->port_name);
if (!dev) {
MIF_LOG(ERR, "Failed to get port id for %s",
msg_param->port_name);
return -1;
}
dev = &rte_eth_devices[port_id];
proc_private = dev->process_private;
memset(&reply, 0, sizeof(reply));

View File

@ -129,14 +129,12 @@ thread_sc_service_up(struct pmd_internals *softnic, uint32_t thread_id)
struct softnic_thread *t = &softnic->thread[thread_id];
struct rte_eth_dev *dev;
int status;
uint16_t port_id;
/* service params */
status = rte_eth_dev_get_port_by_name(softnic->params.name, &port_id);
if (status)
return status;
dev = rte_eth_dev_get_by_name(softnic->params.name);
if (!dev)
return -EINVAL;
dev = &rte_eth_devices[port_id];
snprintf(service_params.name, sizeof(service_params.name), "%s_%u",
softnic->params.name,
thread_id);

View File

@ -2428,19 +2428,16 @@ tap_mp_sync_queues(const struct rte_mp_msg *request, const void *peer)
(const struct ipc_queues *)request->param;
struct ipc_queues *reply_param =
(struct ipc_queues *)reply.param;
uint16_t port_id;
int queue;
int ret;
/* Get requested port */
TAP_LOG(DEBUG, "Received IPC request for %s", request_param->port_name);
ret = rte_eth_dev_get_port_by_name(request_param->port_name, &port_id);
if (ret) {
dev = rte_eth_dev_get_by_name(request_param->port_name);
if (!dev) {
TAP_LOG(ERR, "Failed to get port id for %s",
request_param->port_name);
return -1;
}
dev = &rte_eth_devices[port_id];
process_private = dev->process_private;
/* Fill file descriptors for all queues */