On 6/2/2024 3:45 AM, Damodharam Ammepalli wrote: > Add new rte_lib callback to display ethernet controller's > supporting speeds and bitmap of supported lanes per speed. > > The new command display looks like this. > > testpmd> show port 0 speed_lanes capabilities > > Supported speeds Valid lanes > ----------------------------------- > 10 Gbps 1 > 25 Gbps 1 > 40 Gbps 4 > 50 Gbps 1 2 > 100 Gbps 1 2 4 > 200 Gbps 2 4 > 400 Gbps 4 8 > testpmd> >
Can you please merge this patch with first one, no need to have capability API its own patch Also testpmd patch to get above output is not added yet, please merge testpmd patch and ethdev patch together. Same for others. > Signed-off-by: Damodharam Ammepalli <damodharam.ammepa...@broadcom.com> > --- > lib/ethdev/ethdev_driver.h | 21 +++++++++++++++++++++ > lib/ethdev/rte_ethdev.c | 13 +++++++++++++ > lib/ethdev/rte_ethdev.h | 32 ++++++++++++++++++++++++++++++++ > lib/ethdev/version.map | 1 + > 4 files changed, 67 insertions(+) > > diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h > index b1f473e4de..5951986cec 100644 > --- a/lib/ethdev/ethdev_driver.h > +++ b/lib/ethdev/ethdev_driver.h > @@ -1224,6 +1224,26 @@ typedef int (*eth_speed_lanes_get_t)(struct > rte_eth_dev *dev, > */ > typedef int (*eth_speed_lanes_set_t)(struct rte_eth_dev *dev, uint32_t > speed_lanes_capa); > > +/** > + * @internal > + * Get speed vs number of lanes supported bitmap that controller supports > + * > + * @param dev > + * ethdev handle of port. > + * @param speed_lanes_capa > + * int array of size max speeds bitmap ie 17 > + * @return > + * Negative errno value on error, 0 on success. > + * > + * @retval 0 > + * Success, driver updates the speed_lanes_capa bitmap. > + * @retval -ENOTSUP > + * Operation is not supported. > + * @retval -EIO > + * Device is removed. > + */ > +typedef int (*eth_speed_lanes_get_capa_t)(struct rte_eth_dev *dev, uint32_t > *speed_lanes_bmap); > + > 'speed_lanes_bmap' is an array of bitmaps, and each element in array for a specific speed, but speed is not explicit, it is found by index defined by 'RTE_ETH_LINK_SPEED_XXX'. Instead, for more explicit information, can you please check "struct rte_eth_fec_capa" and 'rte_eth_fec_get_capability()' API? Also using same logic helps on consistency. > /** > * @internal > * Dump Tx descriptor info to a file. > @@ -1523,6 +1543,7 @@ struct eth_dev_ops { > eth_speed_lanes_get_t speed_lanes_get; > /** Set number of speed lanes */ > eth_speed_lanes_set_t speed_lanes_set; > + eth_speed_lanes_get_capa_t speed_lanes_get_capa; > }; > > /** > diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c > index 45e2f7645b..1ac5174d62 100644 > --- a/lib/ethdev/rte_ethdev.c > +++ b/lib/ethdev/rte_ethdev.c > @@ -7021,6 +7021,19 @@ rte_eth_speed_lanes_get(uint16_t port_id, struct > rte_eth_speed_lanes_capa *capa) > return eth_err(port_id, (*dev->dev_ops->speed_lanes_get)(dev, capa)); > } > > +int > +rte_eth_speed_lanes_get_capa(uint16_t port_id, uint32_t *speed_lanes_bmap) > +{ > + struct rte_eth_dev *dev; > + > + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); > + dev = &rte_eth_devices[port_id]; > + > + if (*dev->dev_ops->speed_lanes_get == NULL) > + return -ENOTSUP; > Should we verify if 'speed_lanes_bmap' parameter is NULL in the API? > + return eth_err(port_id, (*dev->dev_ops->speed_lanes_get_capa)(dev, > speed_lanes_bmap)); > +} > + > int > rte_eth_speed_lanes_set(uint16_t port_id, uint32_t speed_lanes_capa) > { > diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h > index caae1f27c6..b8a29416b6 100644 > --- a/lib/ethdev/rte_ethdev.h > +++ b/lib/ethdev/rte_ethdev.h > @@ -308,6 +308,16 @@ struct rte_eth_stats { > #define RTE_ETH_LINK_SPEED_400G RTE_BIT32(16) /**< 400 Gbps */ > /**@}*/ > > +/**@{@name Link speed lane capabilities > + * Device supported speeds lane bitmap flags > + */ > +#define RTE_ETH_LINK_SPEED_MAX_BIT 17 /**< RTE_ETH_LINK_SPEED_400G bit > position + 1 */ > +#define LANE_1 RTE_BIT32(1) > +#define LANE_2 RTE_BIT32(2) > +#define LANE_4 RTE_BIT32(4) > +#define LANE_8 RTE_BIT32(8) > If capability get updated similarly to FEC one, above defines are not needed. > +/**@}*/ > + > /**@{@name Link speed > * Ethernet numeric link speeds in Mbps > */ > @@ -6969,6 +6979,28 @@ int rte_eth_speed_lanes_get(uint16_t port_id, struct > rte_eth_speed_lanes_capa *c > __rte_experimental > int rte_eth_speed_lanes_set(uint16_t port_id, uint32_t speed_lanes_capa); > > +/** > + * @warning > + * @b EXPERIMENTAL: this API may change, or be removed, without prior notice > + * > + * Set speed lanes supported by the NIC. > Set?? > + * > + * @param port_id > + * The port identifier of the Ethernet device. > + * @param speed_lanes_bmap > + * speed_lanes_bmap int array updated by driver by valid lanes bmap. > + * > + * @return > + * - (>=0) valid input and supported by driver or hardware. > + * - (-ENOTSUP) if underlying hardware OR driver doesn't support. > + * that operation. > + * - (-EIO) if device is removed. > + * - (-ENODEV) if *port_id* invalid. > + * - (-EINVAL) if *speed_lanes* invalid > 'speed_lanes_bmap' > + */ > +__rte_experimental > +int rte_eth_speed_lanes_get_capa(uint16_t port_id, uint32_t > *speed_lanes_bmap); > + > #ifdef __cplusplus > } > #endif > diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map > index 9c27980f3a..c453494b8d 100644 > --- a/lib/ethdev/version.map > +++ b/lib/ethdev/version.map > @@ -327,6 +327,7 @@ EXPERIMENTAL { > rte_flow_template_table_resize_complete; > rte_eth_speed_lanes_get; > rte_eth_speed_lanes_set; > + rte_eth_speed_lanes_get_capa; > }; > > INTERNAL {