For the dmadev which only support one vchan, it's OK to ignore vchan parameters.
I don't think that logic needs to be added.

On 2021/9/8 17:54, Walsh, Conor wrote:
> <snip>
> 
> Hi Chengwen,
> 
> While testing the IOAT driver I realised that we hadn't implemented the new 
> RTE_DMADEV_ALL_VCHAN
> flag for stats. Rather than every driver that only supports 1 vchan enabling 
> support for this flag it would
> probably be better to catch it in the library as shown below.
> 
> Thanks,
> Conor.
> 
>> +int
>> +rte_dmadev_stats_get(uint16_t dev_id, uint16_t vchan,
>> +                 struct rte_dmadev_stats *stats)
>> +{
>> +    const struct rte_dmadev *dev = &rte_dmadevices[dev_id];
>> +
>> +    RTE_DMADEV_VALID_DEV_ID_OR_ERR_RET(dev_id, -EINVAL);
>> +    if (stats == NULL)
>> +            return -EINVAL;
>> +    if (vchan >= dev->data->dev_conf.nb_vchans &&
>> +        vchan != RTE_DMADEV_ALL_VCHAN) {
>> +            RTE_DMADEV_LOG(ERR,
>> +                    "Device %u vchan %u out of range", dev_id, vchan);
>> +            return -EINVAL;
>> +    }
>       if (vchan == RTE_DMADEV_ALL_VCHAN && dev->data->dev_conf.nb_vchans == 1)
>               vchan = 0;
>> +
>> +    RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->stats_get, -
>> ENOTSUP);
>> +    memset(stats, 0, sizeof(struct rte_dmadev_stats));
>> +    return (*dev->dev_ops->stats_get)(dev, vchan, stats,
>> +                                      sizeof(struct rte_dmadev_stats));
>> +}
>> +
>> +int
>> +rte_dmadev_stats_reset(uint16_t dev_id, uint16_t vchan)
>> +{
>> +    struct rte_dmadev *dev = &rte_dmadevices[dev_id];
>> +
>> +    RTE_DMADEV_VALID_DEV_ID_OR_ERR_RET(dev_id, -EINVAL);
>> +    if (vchan >= dev->data->dev_conf.nb_vchans &&
>> +        vchan != RTE_DMADEV_ALL_VCHAN) {
>> +            RTE_DMADEV_LOG(ERR,
>> +                    "Device %u vchan %u out of range", dev_id, vchan);
>> +            return -EINVAL;
>> +    }
>       if (vchan == RTE_DMADEV_ALL_VCHAN && dev->data->dev_conf.nb_vchans == 1)
>               vchan = 0;
>> +
>> +    RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->stats_reset, -
>> ENOTSUP);
>> +    return (*dev->dev_ops->stats_reset)(dev, vchan);
>> +}
> 
> <snip>
> 

Reply via email to