* [PATCH v2 1/4] lib/ethdev: Add link_speed lanes support into rte lib
2024-06-02 2:45 ` [PATCH v2 0/4] " Damodharam Ammepalli
@ 2024-06-02 2:45 ` Damodharam Ammepalli
2024-06-02 2:45 ` [PATCH v2 2/4] testpmd: Add speed lanes to testpmd config and show command Damodharam Ammepalli
` (2 subsequent siblings)
3 siblings, 0 replies; 10+ messages in thread
From: Damodharam Ammepalli @ 2024-06-02 2:45 UTC (permalink / raw)
To: dev; +Cc: Kalesh AP, Ajit Khaparde
Update the eth_dev_ops structure with new function vectors
to get and set number of speed lanes. This will help user to
configure the same fixed speed with different number of lanes
based on the physical carrier type.
Signed-off-by: Damodharam Ammepalli <damodharam.ammepalli@broadcom.com>
Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
lib/ethdev/ethdev_driver.h | 49 +++++++++++++++++++++++++++++++++++
lib/ethdev/rte_ethdev.c | 26 +++++++++++++++++++
lib/ethdev/rte_ethdev.h | 52 ++++++++++++++++++++++++++++++++++++++
lib/ethdev/version.map | 2 ++
4 files changed, 129 insertions(+)
diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h
index 0dbf2dd6a2..b1f473e4de 100644
--- a/lib/ethdev/ethdev_driver.h
+++ b/lib/ethdev/ethdev_driver.h
@@ -1179,6 +1179,51 @@ typedef int (*eth_rx_descriptor_dump_t)(const struct rte_eth_dev *dev,
uint16_t queue_id, uint16_t offset,
uint16_t num, FILE *file);
+/**
+ * @internal
+ * Get number of current active lanes and max supported lanes
+ *
+ * @param dev
+ * ethdev handle of port.
+ * @param speed_lanes_capa
+ * Number of active lanes that the link is trained up.
+ * Max number of lanes supported by HW
+ * @return
+ * Negative errno value on error, 0 on success.
+ *
+ * @retval 0
+ * Success, get speed_lanes data success.
+ * @retval -ENOTSUP
+ * Operation is not supported.
+ * @retval -EIO
+ * Device is removed.
+ */
+typedef int (*eth_speed_lanes_get_t)(struct rte_eth_dev *dev,
+ struct rte_eth_speed_lanes_capa *speed_lanes_capa);
+
+/**
+ * @internal
+ * Set speed lanes
+ *
+ * @param dev
+ * ethdev handle of port.
+ * @param speed_lanes_capa
+ * Non-negative number of lanes
+ *
+ * @return
+ * Negative errno value on error, 0 on success.
+ *
+ * @retval 0
+ * Success, set lanes success.
+ * @retval -ENOTSUP
+ * Operation is not supported.
+ * @retval -EINVAL
+ * Unsupported mode requested.
+ * @retval -EIO
+ * Device is removed.
+ */
+typedef int (*eth_speed_lanes_set_t)(struct rte_eth_dev *dev, uint32_t speed_lanes_capa);
+
/**
* @internal
* Dump Tx descriptor info to a file.
@@ -1474,6 +1519,10 @@ struct eth_dev_ops {
eth_count_aggr_ports_t count_aggr_ports;
/** Map a Tx queue with an aggregated port of the DPDK port */
eth_map_aggr_tx_affinity_t map_aggr_tx_affinity;
+ /** Get number of speed lanes supported and active lanes */
+ eth_speed_lanes_get_t speed_lanes_get;
+ /** Set number of speed lanes */
+ eth_speed_lanes_set_t speed_lanes_set;
};
/**
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index f1c658f49e..45e2f7645b 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -7008,4 +7008,30 @@ int rte_eth_dev_map_aggr_tx_affinity(uint16_t port_id, uint16_t tx_queue_id,
return ret;
}
+int
+rte_eth_speed_lanes_get(uint16_t port_id, struct rte_eth_speed_lanes_capa *capa)
+{
+ 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;
+ return eth_err(port_id, (*dev->dev_ops->speed_lanes_get)(dev, capa));
+}
+
+int
+rte_eth_speed_lanes_set(uint16_t port_id, uint32_t speed_lanes_capa)
+{
+ 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_set == NULL)
+ return -ENOTSUP;
+ return eth_err(port_id, (*dev->dev_ops->speed_lanes_set)(dev, speed_lanes_capa));
+}
+
RTE_LOG_REGISTER_DEFAULT(rte_eth_dev_logtype, INFO);
diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h
index 147257d6a2..caae1f27c6 100644
--- a/lib/ethdev/rte_ethdev.h
+++ b/lib/ethdev/rte_ethdev.h
@@ -1997,6 +1997,12 @@ struct rte_eth_fec_capa {
uint32_t capa; /**< FEC capabilities bitmask */
};
+/* A structure used to get and set lanes capabilities per link speed */
+struct rte_eth_speed_lanes_capa {
+ uint32_t active_lanes;
+ uint32_t max_lanes_cap;
+};
+
#define RTE_ETH_ALL RTE_MAX_ETHPORTS
/* Macros to check for valid port */
@@ -6917,6 +6923,52 @@ rte_eth_tx_queue_count(uint16_t port_id, uint16_t queue_id)
return rc;
}
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Get maximum speed lanes supported by the NIC.
+ *
+ * @param port_id
+ * The port identifier of the Ethernet device.
+ * @param speed_lanes_capa
+ * speed_lanes_capa is out only with max speed lanes capabilities.
+ * If set to NULL, then its assumed zero or not supported.
+ *
+ * @return
+ * - A non-negative value of active lanes that currently link is up with.
+ * - A non-negative value that this HW scales up to for all speeds.
+ * - (-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_capa* invalid
+ */
+__rte_experimental
+int rte_eth_speed_lanes_get(uint16_t port_id, struct rte_eth_speed_lanes_capa *capa);
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Set speed lanes supported by the NIC.
+ *
+ * @param port_id
+ * The port identifier of the Ethernet device.
+ * @param speed_lanes
+ * speed_lanes a non-zero value of number lanes for this speeds.
+ *
+ * @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
+ */
+__rte_experimental
+int rte_eth_speed_lanes_set(uint16_t port_id, uint32_t speed_lanes_capa);
+
#ifdef __cplusplus
}
#endif
diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map
index 79f6f5293b..9c27980f3a 100644
--- a/lib/ethdev/version.map
+++ b/lib/ethdev/version.map
@@ -325,6 +325,8 @@ EXPERIMENTAL {
rte_flow_template_table_resizable;
rte_flow_template_table_resize;
rte_flow_template_table_resize_complete;
+ rte_eth_speed_lanes_get;
+ rte_eth_speed_lanes_set;
};
INTERNAL {
--
2.39.3
--
This electronic communication and the information and any files transmitted
with it, or attached to it, are confidential and are intended solely for
the use of the individual or entity to whom it is addressed and may contain
information that is confidential, legally privileged, protected by privacy
laws, or otherwise restricted from disclosure to anyone else. If you are
not the intended recipient or the person responsible for delivering the
e-mail to the intended recipient, you are hereby notified that any use,
copying, distributing, dissemination, forwarding, printing, or copying of
this e-mail is strictly prohibited. If you received this e-mail in error,
please return the e-mail to the sender, delete it from your computer, and
destroy any printed copy of it.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 2/4] testpmd: Add speed lanes to testpmd config and show command
2024-06-02 2:45 ` [PATCH v2 0/4] " Damodharam Ammepalli
2024-06-02 2:45 ` [PATCH v2 1/4] lib/ethdev: Add link_speed lanes support into rte lib Damodharam Ammepalli
@ 2024-06-02 2:45 ` Damodharam Ammepalli
2024-06-02 2:45 ` [PATCH v2 3/4] lib/ethdev: add support for displaying lanes capability Damodharam Ammepalli
2024-06-02 2:45 ` [PATCH v2 4/4] testpmd: " Damodharam Ammepalli
3 siblings, 0 replies; 10+ messages in thread
From: Damodharam Ammepalli @ 2024-06-02 2:45 UTC (permalink / raw)
To: dev; +Cc: Kalesh AP, Ajit Khaparde
Add speed lanes configuration and display commands support
to testpmd. Also provide display the lanes info show device info.
testpmd>
testpmd> port stop 0
testpmd> port config 0 speed_lanes 4
testpmd> port config 0 speed 200000 duplex full
testpmd> port start 0
testpmd> show port summary 0
Number of available ports: 2
Port MAC Address Name Driver Status Link Lanes
0 14:23:F2:C3:BA:D2 0000:b1:00.0 net_bnxt up 200 Gbps 4
testpmd>
testpmd> show port info 0
********************* Infos for port 0 *********************
MAC address: 14:23:F2:C3:BA:D2
Device name: 0000:b1:00.0
Driver name: net_bnxt
Firmware-version: 228.9.115.0
Connect to socket: 2
memory allocation on the socket: 2
Link status: up
Link speed: 200 Gbps
Lanes: 4
Link duplex: full-duplex
Autoneg status: Off
Signed-off-by: Damodharam Ammepalli <damodharam.ammepalli@broadcom.com>
Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
app/test-pmd/cmdline.c | 142 +++++++++++++++++++++++++++++++++++++++++
app/test-pmd/config.c | 13 ++--
2 files changed, 151 insertions(+), 4 deletions(-)
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index b7759e38a8..785e5dd4de 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -1361,6 +1361,27 @@ struct cmd_config_speed_all {
cmdline_fixed_string_t value2;
};
+static int
+cmd_validate_lanes(portid_t pid, uint32_t *lanes)
+{
+ struct rte_eth_speed_lanes_capa spd_lanes = {0};
+ int ret;
+
+ ret = rte_eth_speed_lanes_get(pid, &spd_lanes);
+ /* if not supported default lanes to 0 */
+ if (ret == -ENOTSUP) {
+ *lanes = 0;
+ return 0;
+ }
+
+ if (*lanes > spd_lanes.max_lanes_cap) {
+ fprintf(stderr, "Invalid lanes %d configuration\n", *lanes);
+ return -1;
+ }
+
+ return 0;
+}
+
static int
parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
{
@@ -1676,6 +1697,125 @@ static cmdline_parse_inst_t cmd_config_loopback_specific = {
},
};
+/* *** configure speed_lanes for all ports *** */
+struct cmd_config_speed_lanes_all {
+ cmdline_fixed_string_t port;
+ cmdline_fixed_string_t keyword;
+ cmdline_fixed_string_t all;
+ cmdline_fixed_string_t item;
+ uint32_t lanes;
+};
+
+static void
+cmd_config_speed_lanes_all_parsed(void *parsed_result,
+ __rte_unused struct cmdline *cl,
+ __rte_unused void *data)
+{
+ struct cmd_config_speed_lanes_all *res = parsed_result;
+ portid_t pid;
+
+ if (!all_ports_stopped()) {
+ fprintf(stderr, "Please stop all ports first\n");
+ return;
+ }
+
+ RTE_ETH_FOREACH_DEV(pid) {
+ if (cmd_validate_lanes(pid, &res->lanes))
+ return;
+ rte_eth_speed_lanes_set(pid, res->lanes);
+ }
+
+ cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
+}
+
+static cmdline_parse_token_string_t cmd_config_speed_lanes_all_port =
+ TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, port, "port");
+static cmdline_parse_token_string_t cmd_config_speed_lanes_all_keyword =
+ TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, keyword,
+ "config");
+static cmdline_parse_token_string_t cmd_config_speed_lanes_all_all =
+ TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, all, "all");
+static cmdline_parse_token_string_t cmd_config_speed_lanes_all_item =
+ TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, item,
+ "speed_lanes");
+static cmdline_parse_token_num_t cmd_config_speed_lanes_all_lanes =
+ TOKEN_NUM_INITIALIZER(struct cmd_config_speed_lanes_all, lanes, RTE_UINT32);
+
+static cmdline_parse_inst_t cmd_config_speed_lanes_all = {
+ .f = cmd_config_speed_lanes_all_parsed,
+ .data = NULL,
+ .help_str = "port config all speed_lanes <value>",
+ .tokens = {
+ (void *)&cmd_config_speed_lanes_all_port,
+ (void *)&cmd_config_speed_lanes_all_keyword,
+ (void *)&cmd_config_speed_lanes_all_all,
+ (void *)&cmd_config_speed_lanes_all_item,
+ (void *)&cmd_config_speed_lanes_all_lanes,
+ NULL,
+ },
+};
+
+/* *** configure speed_lanes for specific port *** */
+struct cmd_config_speed_lanes_specific {
+ cmdline_fixed_string_t port;
+ cmdline_fixed_string_t keyword;
+ uint16_t port_id;
+ cmdline_fixed_string_t item;
+ uint32_t lanes;
+};
+
+static void
+cmd_config_speed_lanes_specific_parsed(void *parsed_result,
+ __rte_unused struct cmdline *cl,
+ __rte_unused void *data)
+{
+ struct cmd_config_speed_lanes_specific *res = parsed_result;
+
+ if (port_id_is_invalid(res->port_id, ENABLED_WARN))
+ return;
+
+ if (!port_is_stopped(res->port_id)) {
+ fprintf(stderr, "Please stop port %u first\n", res->port_id);
+ return;
+ }
+
+ if (cmd_validate_lanes(res->port_id, &res->lanes))
+ return;
+ rte_eth_speed_lanes_set(res->port_id, res->lanes);
+
+ cmd_reconfig_device_queue(res->port_id, 1, 1);
+}
+
+static cmdline_parse_token_string_t cmd_config_speed_lanes_specific_port =
+ TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_specific, port,
+ "port");
+static cmdline_parse_token_string_t cmd_config_speed_lanes_specific_keyword =
+ TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_specific, keyword,
+ "config");
+static cmdline_parse_token_num_t cmd_config_speed_lanes_specific_id =
+ TOKEN_NUM_INITIALIZER(struct cmd_config_speed_lanes_specific, port_id,
+ RTE_UINT16);
+static cmdline_parse_token_string_t cmd_config_speed_lanes_specific_item =
+ TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_specific, item,
+ "speed_lanes");
+static cmdline_parse_token_num_t cmd_config_speed_lanes_specific_lanes =
+ TOKEN_NUM_INITIALIZER(struct cmd_config_speed_lanes_specific, lanes,
+ RTE_UINT32);
+
+static cmdline_parse_inst_t cmd_config_speed_lanes_specific = {
+ .f = cmd_config_speed_lanes_specific_parsed,
+ .data = NULL,
+ .help_str = "port config <port_id> speed_lanes <value>",
+ .tokens = {
+ (void *)&cmd_config_speed_lanes_specific_port,
+ (void *)&cmd_config_speed_lanes_specific_keyword,
+ (void *)&cmd_config_speed_lanes_specific_id,
+ (void *)&cmd_config_speed_lanes_specific_item,
+ (void *)&cmd_config_speed_lanes_specific_lanes,
+ NULL,
+ },
+};
+
/* *** configure txq/rxq, txd/rxd *** */
struct cmd_config_rx_tx {
cmdline_fixed_string_t port;
@@ -13381,6 +13521,8 @@ static cmdline_parse_ctx_t builtin_ctx[] = {
(cmdline_parse_inst_t *)&cmd_show_port_cman_config,
(cmdline_parse_inst_t *)&cmd_set_port_cman_config,
(cmdline_parse_inst_t *)&cmd_config_tx_affinity_map,
+ (cmdline_parse_inst_t *)&cmd_config_speed_lanes_all,
+ (cmdline_parse_inst_t *)&cmd_config_speed_lanes_specific,
NULL,
};
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index ba1007ace6..9f846c5e84 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -779,6 +779,7 @@ port_infos_display(portid_t port_id)
struct rte_ether_addr mac_addr;
struct rte_eth_link link;
struct rte_eth_dev_info dev_info;
+ struct rte_eth_speed_lanes_capa spd_lanes = {0};
int vlan_offload;
struct rte_mempool * mp;
static const char *info_border = "*********************";
@@ -828,6 +829,8 @@ port_infos_display(portid_t port_id)
printf("\nLink status: %s\n", (link.link_status) ? ("up") : ("down"));
printf("Link speed: %s\n", rte_eth_link_speed_to_str(link.link_speed));
+ rte_eth_speed_lanes_get(port_id, &spd_lanes);
+ printf("Lanes: %d\n", spd_lanes.active_lanes);
printf("Link duplex: %s\n", (link.link_duplex == RTE_ETH_LINK_FULL_DUPLEX) ?
("full-duplex") : ("half-duplex"));
printf("Autoneg status: %s\n", (link.link_autoneg == RTE_ETH_LINK_AUTONEG) ?
@@ -962,8 +965,8 @@ port_summary_header_display(void)
port_number = rte_eth_dev_count_avail();
printf("Number of available ports: %i\n", port_number);
- printf("%-4s %-17s %-12s %-14s %-8s %s\n", "Port", "MAC Address", "Name",
- "Driver", "Status", "Link");
+ printf("%-4s %-17s %-12s %-14s %-8s %-8s %s\n", "Port", "MAC Address", "Name",
+ "Driver", "Status", "Link", "Lanes");
}
void
@@ -972,6 +975,7 @@ port_summary_display(portid_t port_id)
struct rte_ether_addr mac_addr;
struct rte_eth_link link;
struct rte_eth_dev_info dev_info;
+ struct rte_eth_speed_lanes_capa spd_lanes = {0};
char name[RTE_ETH_NAME_MAX_LEN];
int ret;
@@ -993,10 +997,11 @@ port_summary_display(portid_t port_id)
if (ret != 0)
return;
- printf("%-4d " RTE_ETHER_ADDR_PRT_FMT " %-12s %-14s %-8s %s\n",
+ rte_eth_speed_lanes_get(port_id, &spd_lanes);
+ printf("%-4d " RTE_ETHER_ADDR_PRT_FMT " %-12s %-14s %-8s %-8s %d\n",
port_id, RTE_ETHER_ADDR_BYTES(&mac_addr), name,
dev_info.driver_name, (link.link_status) ? ("up") : ("down"),
- rte_eth_link_speed_to_str(link.link_speed));
+ rte_eth_link_speed_to_str(link.link_speed), spd_lanes.active_lanes);
}
void
--
2.39.3
--
This electronic communication and the information and any files transmitted
with it, or attached to it, are confidential and are intended solely for
the use of the individual or entity to whom it is addressed and may contain
information that is confidential, legally privileged, protected by privacy
laws, or otherwise restricted from disclosure to anyone else. If you are
not the intended recipient or the person responsible for delivering the
e-mail to the intended recipient, you are hereby notified that any use,
copying, distributing, dissemination, forwarding, printing, or copying of
this e-mail is strictly prohibited. If you received this e-mail in error,
please return the e-mail to the sender, delete it from your computer, and
destroy any printed copy of it.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 3/4] lib/ethdev: add support for displaying lanes capability
2024-06-02 2:45 ` [PATCH v2 0/4] " Damodharam Ammepalli
2024-06-02 2:45 ` [PATCH v2 1/4] lib/ethdev: Add link_speed lanes support into rte lib Damodharam Ammepalli
2024-06-02 2:45 ` [PATCH v2 2/4] testpmd: Add speed lanes to testpmd config and show command Damodharam Ammepalli
@ 2024-06-02 2:45 ` Damodharam Ammepalli
2024-06-02 2:45 ` [PATCH v2 4/4] testpmd: " Damodharam Ammepalli
3 siblings, 0 replies; 10+ messages in thread
From: Damodharam Ammepalli @ 2024-06-02 2:45 UTC (permalink / raw)
To: dev
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>
Signed-off-by: Damodharam Ammepalli <damodharam.ammepalli@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);
+
/**
* @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;
+ 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)
+/**@}*/
+
/**@{@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.
+ *
+ * @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
+ */
+__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 {
--
2.39.3
--
This electronic communication and the information and any files transmitted
with it, or attached to it, are confidential and are intended solely for
the use of the individual or entity to whom it is addressed and may contain
information that is confidential, legally privileged, protected by privacy
laws, or otherwise restricted from disclosure to anyone else. If you are
not the intended recipient or the person responsible for delivering the
e-mail to the intended recipient, you are hereby notified that any use,
copying, distributing, dissemination, forwarding, printing, or copying of
this e-mail is strictly prohibited. If you received this e-mail in error,
please return the e-mail to the sender, delete it from your computer, and
destroy any printed copy of it.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 4/4] testpmd: add support for displaying lanes capability
2024-06-02 2:45 ` [PATCH v2 0/4] " Damodharam Ammepalli
` (2 preceding siblings ...)
2024-06-02 2:45 ` [PATCH v2 3/4] lib/ethdev: add support for displaying lanes capability Damodharam Ammepalli
@ 2024-06-02 2:45 ` Damodharam Ammepalli
3 siblings, 0 replies; 10+ messages in thread
From: Damodharam Ammepalli @ 2024-06-02 2:45 UTC (permalink / raw)
To: dev
Add a new api support that displays the speeds and bitmap of
supported lanes configuration by the ethernet controller.
This patch adds support in the testpmd cli chain.
Signed-off-by: Damodharam Ammepalli <damodharam.ammepalli@broadcom.com>
---
app/test-pmd/cmdline.c | 128 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 128 insertions(+)
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 785e5dd4de..8b0a85f632 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -1637,6 +1637,133 @@ static cmdline_parse_inst_t cmd_config_loopback_all = {
},
};
+/* *** display speed lanes per port capabilities *** */
+struct cmd_show_speed_lanes_result {
+ cmdline_fixed_string_t cmd_show;
+ cmdline_fixed_string_t cmd_port;
+ cmdline_fixed_string_t cmd_keyword;
+ portid_t cmd_pid;
+};
+
+static const char*
+get_device_infos_display_speeds(uint32_t speed_capa)
+{
+ if (speed_capa & RTE_ETH_LINK_SPEED_10M_HD)
+ return(" 10 Mbps half-duplex ");
+ if (speed_capa & RTE_ETH_LINK_SPEED_10M)
+ return(" 10 Mbps full-duplex ");
+ if (speed_capa & RTE_ETH_LINK_SPEED_100M_HD)
+ return(" 100 Mbps half-duplex ");
+ if (speed_capa & RTE_ETH_LINK_SPEED_100M)
+ return(" 100 Mbps full-duplex ");
+ if (speed_capa & RTE_ETH_LINK_SPEED_1G)
+ return(" 1 Gbps ");
+ if (speed_capa & RTE_ETH_LINK_SPEED_2_5G)
+ return(" 2.5 Gbps ");
+ if (speed_capa & RTE_ETH_LINK_SPEED_5G)
+ return(" 5 Gbps ");
+ if (speed_capa & RTE_ETH_LINK_SPEED_10G)
+ return(" 10 Gbps ");
+ if (speed_capa & RTE_ETH_LINK_SPEED_20G)
+ return(" 20 Gbps ");
+ if (speed_capa & RTE_ETH_LINK_SPEED_25G)
+ return(" 25 Gbps ");
+ if (speed_capa & RTE_ETH_LINK_SPEED_40G)
+ return(" 40 Gbps ");
+ if (speed_capa & RTE_ETH_LINK_SPEED_50G)
+ return(" 50 Gbps ");
+ if (speed_capa & RTE_ETH_LINK_SPEED_56G)
+ return(" 56 Gbps ");
+ if (speed_capa & RTE_ETH_LINK_SPEED_100G)
+ return(" 100 Gbps ");
+ if (speed_capa & RTE_ETH_LINK_SPEED_200G)
+ return(" 200 Gbps ");
+ if (speed_capa & RTE_ETH_LINK_SPEED_400G)
+ return(" 400 Gbps ");
+
+ return("Unkown");
+}
+
+static void
+cmd_show_speed_lanes_parsed(void *parsed_result,
+ __rte_unused struct cmdline *cl,
+ __rte_unused void *data)
+{
+ struct cmd_show_speed_lanes_result *res = parsed_result;
+ uint32_t speed_lanes_bmap[RTE_ETH_LINK_SPEED_MAX_BIT] = {0};
+ struct rte_eth_speed_lanes_capa spd_lanes = {0};
+ struct rte_eth_dev_info dev_info;
+ //char lanes_speed_str[128] = {0};
+ bool skip_spd_chk = false;
+ int ret, i;
+ uint32_t j;
+
+ if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
+ fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
+ return;
+ }
+
+ /* get max lanes this nic supports */
+ ret = rte_eth_speed_lanes_get(res->cmd_pid, &spd_lanes);
+ if (ret == -ENOTSUP)
+ return;
+
+ /* Pull out capability if nic supports */
+ ret = rte_eth_speed_lanes_get_capa(res->cmd_pid, speed_lanes_bmap);
+ if (ret == -ENOTSUP)
+ return;
+
+ ret = eth_dev_info_get_print_err(res->cmd_pid, &dev_info);
+ /* when link is down, PHY does not report any speeds */
+ if (ret == 0)
+ skip_spd_chk = true;
+
+ printf("\n%-25s %-10s", " Supported speeds", "Valid lanes");
+ printf("\n-----------------------------------");
+ for (i = 1; i <= RTE_ETH_LINK_SPEED_MAX_BIT; i++) {
+ if ((dev_info.speed_capa & RTE_BIT32(i) || skip_spd_chk) &&
+ (speed_lanes_bmap[i])) {
+ printf("\n%-25s ",
+ get_device_infos_display_speeds(RTE_BIT32(i))) ;
+ for (j = 0; j <= spd_lanes.max_lanes_cap; j++) {
+ if (RTE_BIT32(j) & speed_lanes_bmap[i])
+ printf("%-2d", j);
+ }
+ }
+ }
+ printf("\n");
+}
+
+static cmdline_parse_token_string_t cmd_show_speed_lanes_show =
+ TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
+ cmd_show, "show");
+static cmdline_parse_token_string_t cmd_show_speed_lanes_port =
+ TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
+ cmd_port, "port");
+static cmdline_parse_token_num_t cmd_show_speed_lanes_pid =
+ TOKEN_NUM_INITIALIZER(struct cmd_show_speed_lanes_result,
+ cmd_pid, RTE_UINT16);
+static cmdline_parse_token_string_t cmd_show_speed_lanes_keyword =
+ TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
+ cmd_keyword, "speed_lanes");
+static cmdline_parse_token_string_t cmd_show_speed_lanes_cap_keyword =
+ TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
+ cmd_keyword, "capabilities");
+
+static cmdline_parse_inst_t cmd_show_speed_lanes = {
+ .f = cmd_show_speed_lanes_parsed,
+ .data = NULL,
+ .help_str = "show port <port_id> speed_lanes capabilities",
+ .tokens = {
+ (void *)&cmd_show_speed_lanes_show,
+ (void *)&cmd_show_speed_lanes_port,
+ (void *)&cmd_show_speed_lanes_pid,
+ (void *)&cmd_show_speed_lanes_keyword,
+ (void *)&cmd_show_speed_lanes_cap_keyword,
+ NULL,
+ },
+};
+
/* *** configure loopback for specific port *** */
struct cmd_config_loopback_specific {
cmdline_fixed_string_t port;
@@ -13523,6 +13650,7 @@ static cmdline_parse_ctx_t builtin_ctx[] = {
(cmdline_parse_inst_t *)&cmd_config_tx_affinity_map,
(cmdline_parse_inst_t *)&cmd_config_speed_lanes_all,
(cmdline_parse_inst_t *)&cmd_config_speed_lanes_specific,
+ (cmdline_parse_inst_t *)&cmd_show_speed_lanes,
NULL,
};
--
2.39.3
--
This electronic communication and the information and any files transmitted
with it, or attached to it, are confidential and are intended solely for
the use of the individual or entity to whom it is addressed and may contain
information that is confidential, legally privileged, protected by privacy
laws, or otherwise restricted from disclosure to anyone else. If you are
not the intended recipient or the person responsible for delivering the
e-mail to the intended recipient, you are hereby notified that any use,
copying, distributing, dissemination, forwarding, printing, or copying of
this e-mail is strictly prohibited. If you received this e-mail in error,
please return the e-mail to the sender, delete it from your computer, and
destroy any printed copy of it.
^ permalink raw reply [flat|nested] 10+ messages in thread