MCPcopy Create free account
hub / github.com/F-Stack/f-stack / mlx5_get_module_eeprom

Function mlx5_get_module_eeprom

dpdk/drivers/net/mlx5/linux/mlx5_ethdev_os.c:1242–1277  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

1240 * 0 on success, a negative errno value otherwise and rte_errno is set.
1241 */
1242int 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.

Callers

nothing calls this directly

Calls 4

mlx5_mallocFunction · 0.85
mlx5_ifreqFunction · 0.85
mlx5_freeFunction · 0.85
rte_memcpyFunction · 0.50

Tested by

no test coverage detected