ethdev: add telemetry command for module EEPROM
Add a new telemetry command /ethdev/module_eeprom to dump the module EEPROM of each port. The format of module EEPROM information follows the SFF(Small Form Factor) Committee specifications. Signed-off-by: Robin Zhang <robinx.zhang@intel.com> Signed-off-by: Kevin Liu <kevinx.liu@intel.com> Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
This commit is contained in:
parent
cac5e257f6
commit
7546a2cd2b
@ -76,6 +76,7 @@ RSS
|
|||||||
RVU
|
RVU
|
||||||
Rx
|
Rx
|
||||||
SCTP
|
SCTP
|
||||||
|
SFF
|
||||||
SMP
|
SMP
|
||||||
SoC
|
SoC
|
||||||
SQ
|
SQ
|
||||||
|
@ -64,6 +64,10 @@ New Features
|
|||||||
and updated ``struct rte_mtr_params`` and ``struct rte_mtr_capabilities`` to
|
and updated ``struct rte_mtr_params`` and ``struct rte_mtr_capabilities`` to
|
||||||
support protocol based input color selection for meter.
|
support protocol based input color selection for meter.
|
||||||
|
|
||||||
|
* **Added telemetry for module EEPROM.**
|
||||||
|
|
||||||
|
Added telemetry command to dump module EEPROM.
|
||||||
|
|
||||||
* **Added vhost API to get the number of in-flight packets.**
|
* **Added vhost API to get the number of in-flight packets.**
|
||||||
|
|
||||||
Added an API which can get the number of in-flight packets in
|
Added an API which can get the number of in-flight packets in
|
||||||
|
@ -11,6 +11,7 @@ sources = files(
|
|||||||
'rte_flow.c',
|
'rte_flow.c',
|
||||||
'rte_mtr.c',
|
'rte_mtr.c',
|
||||||
'rte_tm.c',
|
'rte_tm.c',
|
||||||
|
'sff_telemetry.c',
|
||||||
)
|
)
|
||||||
|
|
||||||
headers = files(
|
headers = files(
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
#include "ethdev_driver.h"
|
#include "ethdev_driver.h"
|
||||||
#include "ethdev_profile.h"
|
#include "ethdev_profile.h"
|
||||||
#include "ethdev_private.h"
|
#include "ethdev_private.h"
|
||||||
|
#include "sff_telemetry.h"
|
||||||
|
|
||||||
struct rte_eth_dev rte_eth_devices[RTE_MAX_ETHPORTS];
|
struct rte_eth_dev rte_eth_devices[RTE_MAX_ETHPORTS];
|
||||||
|
|
||||||
@ -5890,4 +5891,6 @@ RTE_INIT(ethdev_init_telemetry)
|
|||||||
"Returns the link status for a port. Parameters: int port_id");
|
"Returns the link status for a port. Parameters: int port_id");
|
||||||
rte_telemetry_register_cmd("/ethdev/info", eth_dev_handle_port_info,
|
rte_telemetry_register_cmd("/ethdev/info", eth_dev_handle_port_info,
|
||||||
"Returns the device info for a port. Parameters: int port_id");
|
"Returns the device info for a port. Parameters: int port_id");
|
||||||
|
rte_telemetry_register_cmd("/ethdev/module_eeprom", eth_dev_handle_port_module_eeprom,
|
||||||
|
"Returns module EEPROM info with SFF specs. Parameters: int port_id");
|
||||||
}
|
}
|
||||||
|
109
lib/ethdev/sff_telemetry.c
Normal file
109
lib/ethdev/sff_telemetry.c
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
/* SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
* Copyright(c) 2022 Intel Corporation
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include "rte_ethdev.h"
|
||||||
|
#include <rte_common.h>
|
||||||
|
#include "sff_telemetry.h"
|
||||||
|
#include <telemetry_data.h>
|
||||||
|
|
||||||
|
static void
|
||||||
|
sff_port_module_eeprom_parse(uint16_t port_id, struct rte_tel_data *d)
|
||||||
|
{
|
||||||
|
struct rte_eth_dev_module_info minfo;
|
||||||
|
struct rte_dev_eeprom_info einfo;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (d == NULL) {
|
||||||
|
RTE_ETHDEV_LOG(ERR, "Dict invalid\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = rte_eth_dev_get_module_info(port_id, &minfo);
|
||||||
|
if (ret != 0) {
|
||||||
|
switch (ret) {
|
||||||
|
case -ENODEV:
|
||||||
|
RTE_ETHDEV_LOG(ERR, "Port index %d invalid\n", port_id);
|
||||||
|
break;
|
||||||
|
case -ENOTSUP:
|
||||||
|
RTE_ETHDEV_LOG(ERR, "Operation not supported by device\n");
|
||||||
|
break;
|
||||||
|
case -EIO:
|
||||||
|
RTE_ETHDEV_LOG(ERR, "Device is removed\n");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
RTE_ETHDEV_LOG(ERR, "Unable to get port module info, %d\n", ret);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
einfo.offset = 0;
|
||||||
|
einfo.length = minfo.eeprom_len;
|
||||||
|
einfo.data = calloc(1, minfo.eeprom_len);
|
||||||
|
if (einfo.data == NULL) {
|
||||||
|
RTE_ETHDEV_LOG(ERR, "Allocation of port %u EEPROM data failed\n", port_id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = rte_eth_dev_get_module_eeprom(port_id, &einfo);
|
||||||
|
if (ret != 0) {
|
||||||
|
switch (ret) {
|
||||||
|
case -ENODEV:
|
||||||
|
RTE_ETHDEV_LOG(ERR, "Port index %d invalid\n", port_id);
|
||||||
|
break;
|
||||||
|
case -ENOTSUP:
|
||||||
|
RTE_ETHDEV_LOG(ERR, "Operation not supported by device\n");
|
||||||
|
break;
|
||||||
|
case -EIO:
|
||||||
|
RTE_ETHDEV_LOG(ERR, "Device is removed\n");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
RTE_ETHDEV_LOG(ERR, "Unable to get port module EEPROM, %d\n", ret);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
free(einfo.data);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (minfo.type) {
|
||||||
|
/* parsing module EEPROM data base on different module type */
|
||||||
|
default:
|
||||||
|
RTE_ETHDEV_LOG(NOTICE, "Unsupported module type: %u\n", minfo.type);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
free(einfo.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
eth_dev_handle_port_module_eeprom(const char *cmd __rte_unused, const char *params,
|
||||||
|
struct rte_tel_data *d)
|
||||||
|
{
|
||||||
|
char *end_param;
|
||||||
|
int port_id;
|
||||||
|
|
||||||
|
if (params == NULL || strlen(params) == 0 || !isdigit(*params))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
port_id = strtoul(params, &end_param, 0);
|
||||||
|
|
||||||
|
if (errno != 0) {
|
||||||
|
RTE_ETHDEV_LOG(ERR, "Invalid argument, %d\n", errno);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*end_param != '\0')
|
||||||
|
RTE_ETHDEV_LOG(NOTICE,
|
||||||
|
"Extra parameters [%s] passed to ethdev telemetry command, ignoring\n",
|
||||||
|
end_param);
|
||||||
|
|
||||||
|
rte_tel_data_start_dict(d);
|
||||||
|
|
||||||
|
sff_port_module_eeprom_parse(port_id, d);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
14
lib/ethdev/sff_telemetry.h
Normal file
14
lib/ethdev/sff_telemetry.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
/* SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
* Copyright(c) 2022 Intel Corporation
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _ETHDEV_SFF_TELEMETRY_H_
|
||||||
|
#define _ETHDEV_SFF_TELEMETRY_H_
|
||||||
|
|
||||||
|
#include <rte_telemetry.h>
|
||||||
|
|
||||||
|
int eth_dev_handle_port_module_eeprom(const char *cmd __rte_unused,
|
||||||
|
const char *params,
|
||||||
|
struct rte_tel_data *d);
|
||||||
|
|
||||||
|
#endif /* _ETHDEV_SFF_TELEMETRY_H_ */
|
Loading…
Reference in New Issue
Block a user