* DPDK callback to retrieve plug-in module EEPROM data. * * @param dev * Pointer to Ethernet device structure. * @param[out] info * Storage for plug-in module EEPROM data. * * @return * 0 on success, a negative errno value otherwise and rte_errno is set. */
| 1240 | * 0 on success, a negative errno value otherwise and rte_errno is set. |
| 1241 | */ |
| 1242 | int mlx5_get_module_eeprom(struct rte_eth_dev *dev, |
| 1243 | struct rte_dev_eeprom_info *info) |
| 1244 | { |
| 1245 | struct ethtool_eeprom *eeprom; |
| 1246 | struct ifreq ifr; |
| 1247 | int ret = 0; |
| 1248 | |
| 1249 | if (!dev) { |
| 1250 | DRV_LOG(WARNING, "missing argument, cannot get module eeprom"); |
| 1251 | rte_errno = EINVAL; |
| 1252 | return -rte_errno; |
| 1253 | } |
| 1254 | eeprom = mlx5_malloc(MLX5_MEM_ZERO, |
| 1255 | (sizeof(struct ethtool_eeprom) + info->length), 0, |
| 1256 | SOCKET_ID_ANY); |
| 1257 | if (!eeprom) { |
| 1258 | DRV_LOG(WARNING, "port %u cannot allocate memory for " |
| 1259 | "eeprom data", dev->data->port_id); |
| 1260 | rte_errno = ENOMEM; |
| 1261 | return -rte_errno; |
| 1262 | } |
| 1263 | eeprom->cmd = ETHTOOL_GMODULEEEPROM; |
| 1264 | eeprom->offset = info->offset; |
| 1265 | eeprom->len = info->length; |
| 1266 | ifr = (struct ifreq) { |
| 1267 | .ifr_data = (void *)eeprom, |
| 1268 | }; |
| 1269 | ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr); |
| 1270 | if (ret) |
| 1271 | DRV_LOG(WARNING, "port %u ioctl(SIOCETHTOOL) failed: %s", |
| 1272 | dev->data->port_id, strerror(rte_errno)); |
| 1273 | else |
| 1274 | rte_memcpy(info->data, eeprom->data, info->length); |
| 1275 | mlx5_free(eeprom); |
| 1276 | return ret; |
| 1277 | } |
| 1278 | |
| 1279 | /** |
| 1280 | * Read device counters table. |
nothing calls this directly
no test coverage detected