On 1/8/2020 1:52 PM, Ferruh Yigit wrote:
> On 1/8/2020 1:25 PM, Thomas Monjalon wrote:
>> 08/01/2020 14:20, Ferruh Yigit:
>>> On 1/8/2020 1:06 PM, Thomas Monjalon wrote:
>>>> 08/01/2020 13:59, Ferruh Yigit:
>>>>> But for dev_ops, instead of having another capabilities indicator, which
>>>>> requires PMDs to keep this synchronized, I think it is better if we can 
>>>>> self
>>>>> contain this information within dev_ops, like not implementing dev_ops 
>>>>> would
>>>>> mean it is not supported, this way it is easier to maintain and less 
>>>>> error prone.
>>>>
>>>> It means the dev_ops is resetted at init if a device does not support the 
>>>> feature.
>>>> It is against having const dev_ops.
>>>
>>> I didn't get your comment.
>>> For example getting FW version, I am saying instead of keeping another 
>>> piece of
>>> information to say if it is supported by device/driver, better to grasp this
>>> from if the driver implemented 'fw_version_get' dev_ops or not.
>>
>> I like this approach.
>> Capabilities should be expressed by setting the function pointer or not 
>> (NULL).
>> But a driver may support a feature for a subset of devices.
> 
> In that case dev_ops itself can return the '-ENOTSUP', since application
> interaction will be through the ethdev API, either API send '-ENOTSUP' because
> the dev_ops is NULL or dev_ops itself send the '-ENOTSUP' because of the
> underlying version of the device, for application it will be clear that that
> feature is not supported.

For this specific problem,
What do you think having:
rte_eth_led_on_is_supported()
rte_eth_led_off_is_supported()

like:

rte_eth_led_on_is_supported() {
  RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
  RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_led_on, -ENOTSUP);
  return 0;
}

rte_eth_led_on() {
  ret = rte_eth_led_on_is_supported();
  if (ret)
    return ret;
  return eth_err(port_id, (*dev->dev_ops->dev_led_on)(dev));
}

> 
>> If a device does not support a feature, the function pointer must be set to 
>> NULL.
>> The only issue is having dev_ops as a const struct.
> 
> Not sure about changing the dev_ops on runtime, it can be very hard to debug.
> 

Reply via email to