> -----Original Message-----
> From: Viacheslav Galaktionov <viacheslav.galaktio...@oktetlabs.ru>
> Sent: Saturday, July 3, 2021 6:01 PM
> To: Xueming(Steven) Li <xuemi...@nvidia.com>
> Cc: Andrew Rybchenko <andrew.rybche...@oktetlabs.ru>; Matan Azrad
> <ma...@nvidia.com>; Shahaf Shuler
> <shah...@nvidia.com>; Slava Ovsiienko <viachesl...@nvidia.com>;
> NBU-Contact-Thomas Monjalon <tho...@monjalon.net>;
> Ferruh Yigit <ferruh.yi...@intel.com>; dev@dpdk.org; sta...@dpdk.org
> Subject: Re: [PATCH] ethdev: keep count of allocated and used representor
> ranges
>
> Hello!
>
> On 2021-07-03 04:32, Xueming(Steven) Li wrote:
> >> + if (i == n_entries)
> >> + break;
> >> }
> >> out:
> >> + info->nb_ranges = i;
> >
> > Here info maybe NULL.
>
> Good catch, thanks for noticing!
>
> >> faf3bd901d..d2b27c351f 100644
> >> --- a/lib/ethdev/rte_ethdev.h
> >> +++ b/lib/ethdev/rte_ethdev.h
> >> @@ -4856,6 +4856,8 @@ struct rte_eth_representor_range { struct
> >> rte_eth_representor_info {
> >> uint16_t controller; /**< Controller ID of caller device. */
> >> uint16_t pf; /**< Physical function ID of caller device. */
> >> + uint32_t nb_ranges_alloc; /**< Size of the ranges array. */
> >> + uint32_t nb_ranges; /**< Number of initialized ranges. */
> >
> > How about rte_eth_representor_info_get(info) return max ranges size if
> > info is NULL, return real initialized ranges if info not NULL?
>
> I'm not sure how I feel about it. I think it'd be best if the function
> returned just one thing.
>
> Moreover, there are drivers that don't have a fixed structure for representor
> IDs, e.g. net/sfc, where every range will contain a single
> ID. If a new representor range is created between invocations of this
> function, there probably should be a way for the caller to know
> about this.
>
> Perhaps we should move the total number of representors to an out parameter
> and use the return value for the number of initialized
> ranges. What do you think about this?
No big difference, I'm ok with your original design.