net: add rte prefix to ether functions
[dpdk.git] / examples / ethtool / lib / rte_ethtool.c
index d519a50..571c4e5 100644 (file)
@@ -4,6 +4,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdint.h>
+#include <rte_string_fns.h>
 #include <rte_version.h>
 #include <rte_ethdev.h>
 #include <rte_ether.h>
@@ -43,10 +44,9 @@ rte_ethtool_get_drvinfo(uint16_t port_id, struct ethtool_drvinfo *drvinfo)
        memset(&dev_info, 0, sizeof(dev_info));
        rte_eth_dev_info_get(port_id, &dev_info);
 
-       snprintf(drvinfo->driver, sizeof(drvinfo->driver), "%s",
-               dev_info.driver_name);
-       snprintf(drvinfo->version, sizeof(drvinfo->version), "%s",
-               rte_version());
+       strlcpy(drvinfo->driver, dev_info.driver_name,
+               sizeof(drvinfo->driver));
+       strlcpy(drvinfo->version, rte_version(), sizeof(drvinfo->version));
        /* TODO: replace bus_info by rte_devargs.name */
        if (dev_info.device)
                bus = rte_bus_find_by_device(dev_info.device);
@@ -177,6 +177,36 @@ rte_ethtool_set_eeprom(uint16_t port_id, struct ethtool_eeprom *eeprom,
        return 0;
 }
 
+int
+rte_ethtool_get_module_info(uint16_t port_id, uint32_t *modinfo)
+{
+       struct rte_eth_dev_module_info *info;
+
+       info = (struct rte_eth_dev_module_info *)modinfo;
+       return rte_eth_dev_get_module_info(port_id, info);
+}
+
+int
+rte_ethtool_get_module_eeprom(uint16_t port_id, struct ethtool_eeprom *eeprom,
+       void *words)
+{
+       struct rte_dev_eeprom_info eeprom_info;
+       int status;
+
+       if (eeprom == NULL || words == NULL)
+               return -EINVAL;
+
+       eeprom_info.offset = eeprom->offset;
+       eeprom_info.length = eeprom->len;
+       eeprom_info.data = words;
+
+       status = rte_eth_dev_get_module_eeprom(port_id, &eeprom_info);
+       if (status)
+               return status;
+
+       return 0;
+}
+
 int
 rte_ethtool_get_pauseparam(uint16_t port_id,
        struct ethtool_pauseparam *pause_param)
@@ -273,7 +303,7 @@ rte_ethtool_net_stop(uint16_t port_id)
 }
 
 int
-rte_ethtool_net_get_mac_addr(uint16_t port_id, struct ether_addr *addr)
+rte_ethtool_net_get_mac_addr(uint16_t port_id, struct rte_ether_addr *addr)
 {
        RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
        if (addr == NULL)
@@ -284,7 +314,7 @@ rte_ethtool_net_get_mac_addr(uint16_t port_id, struct ether_addr *addr)
 }
 
 int
-rte_ethtool_net_set_mac_addr(uint16_t port_id, struct ether_addr *addr)
+rte_ethtool_net_set_mac_addr(uint16_t port_id, struct rte_ether_addr *addr)
 {
        if (addr == NULL)
                return -EINVAL;
@@ -293,11 +323,11 @@ rte_ethtool_net_set_mac_addr(uint16_t port_id, struct ether_addr *addr)
 
 int
 rte_ethtool_net_validate_addr(uint16_t port_id __rte_unused,
-       struct ether_addr *addr)
+       struct rte_ether_addr *addr)
 {
        if (addr == NULL)
                return -EINVAL;
-       return is_valid_assigned_ether_addr(addr);
+       return rte_is_valid_assigned_ether_addr(addr);
 }
 
 int