<div dir="ltr"><div>Just wanted to bring it to your attention,</div><div><br></div><div>In Mellanox driver there is a requirement to exchange fds between primary and secondary and similar usage is seen, the primary sends the port_id and the secondary refers to the rte_eth_devices in the driver, <br></div><div>The functions are <br></div><div> - mlx5_mp_secondary_handle in secondary <br></div><div> - mlx5_mp_req_start_rxtx in primary which is invoked from mlx5_dev_start. <br></div><div><br></div><div>In my implementation I have used the name and invoked get_port_by_name, I can also pass the port_id from the primary to make it uniform. So with similar usage in Mellanox is there a problem there as well on referring to the rte_eth_devices from the PMD ? <br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jan 18, 2022 at 3:17 PM Ferruh Yigit <<a href="mailto:ferruh.yigit@intel.com">ferruh.yigit@intel.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 1/17/2022 6:33 PM, Thomas Monjalon wrote:<br>
> 17/01/2022 19:28, Ferruh Yigit:<br>
>>> + ret = rte_eth_dev_get_port_by_name(request_param->port_name, &port_id);<br>
>>> + if (ret) {<br>
>>> + TAP_LOG(ERR, "Failed to get port id for %s",<br>
>>> + request_param->port_name);<br>
>>> + return -1;<br>
>>> + }<br>
>>> + dev = &rte_eth_devices[port_id];<br>
>><br>
>> Since this is not really related with your patch, I want to have a separate thread for it.<br>
>><br>
>> It is not good to access the 'rte_eth_devices' global variable directly from a driver, that<br>
>> is error prone.<br>
>><br>
>> Btw, what 'peer' supposed to contain?<br>
>><br>
>> It can be solved by adding an internal API, only for drivers to get eth_dev from the name,<br>
>> like: 'rte_eth_dev_get_by_name()'.<br>
>> This way a few other usage can be converted to this API.<br>
>><br>
>> @Thomas and @Andrew what do you think about the new API proposal?<br>
> <br>
> It looks similar to rte_eth_dev_get_port_by_name() which returns a port_id.<br>
<br>
Exactly, but get eth_dev directly for drivers. For drivers no need to work with port_id<br>
handler, they can use eth_dev directly.<br>
<br>
Another solution can be an getter function for drivers, which gets port_id and returns<br>
the eth_dev.<br>
<br>
> It is a bit strange for an ethdev driver to not have access to its own ethdev struct.<br>
> Isn't there something broken in the logic?<br>
> <br>
<br>
This is callback function between primary and secondary applications sync. So port name<br>
will be same for both, but eth_dev will be different and port_id may be different.<br>
Driver finds its own eth_dev from the shared port name.<br>
<br>
</blockquote></div>