1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2022 Intel Corporation
7 #include "rte_ethdev.h"
8 #include <rte_common.h>
9 #include "sff_telemetry.h"
10 #include <telemetry_data.h>
13 sff_port_module_eeprom_parse(uint16_t port_id, struct rte_tel_data *d)
15 struct rte_eth_dev_module_info minfo;
16 struct rte_dev_eeprom_info einfo;
20 RTE_ETHDEV_LOG(ERR, "Dict invalid\n");
24 ret = rte_eth_dev_get_module_info(port_id, &minfo);
28 RTE_ETHDEV_LOG(ERR, "Port index %d invalid\n", port_id);
31 RTE_ETHDEV_LOG(ERR, "Operation not supported by device\n");
34 RTE_ETHDEV_LOG(ERR, "Device is removed\n");
37 RTE_ETHDEV_LOG(ERR, "Unable to get port module info, %d\n", ret);
44 einfo.length = minfo.eeprom_len;
45 einfo.data = calloc(1, minfo.eeprom_len);
46 if (einfo.data == NULL) {
47 RTE_ETHDEV_LOG(ERR, "Allocation of port %u EEPROM data failed\n", port_id);
51 ret = rte_eth_dev_get_module_eeprom(port_id, &einfo);
55 RTE_ETHDEV_LOG(ERR, "Port index %d invalid\n", port_id);
58 RTE_ETHDEV_LOG(ERR, "Operation not supported by device\n");
61 RTE_ETHDEV_LOG(ERR, "Device is removed\n");
64 RTE_ETHDEV_LOG(ERR, "Unable to get port module EEPROM, %d\n", ret);
72 /* parsing module EEPROM data base on different module type */
74 RTE_ETHDEV_LOG(NOTICE, "Unsupported module type: %u\n", minfo.type);
82 eth_dev_handle_port_module_eeprom(const char *cmd __rte_unused, const char *params,
83 struct rte_tel_data *d)
88 if (params == NULL || strlen(params) == 0 || !isdigit(*params))
92 port_id = strtoul(params, &end_param, 0);
95 RTE_ETHDEV_LOG(ERR, "Invalid argument, %d\n", errno);
99 if (*end_param != '\0')
100 RTE_ETHDEV_LOG(NOTICE,
101 "Extra parameters [%s] passed to ethdev telemetry command, ignoring\n",
104 rte_tel_data_start_dict(d);
106 sff_port_module_eeprom_parse(port_id, d);