test/sched: add subport config flexibility
[dpdk.git] / app / test-pmd / util.c
index 009d226..1570270 100644 (file)
@@ -245,3 +245,61 @@ eth_dev_info_get_print_err(uint16_t port_id,
 
        return ret;
 }
+
+void
+eth_set_promisc_mode(uint16_t port, int enable)
+{
+       int ret;
+
+       if (enable)
+               ret = rte_eth_promiscuous_enable(port);
+       else
+               ret = rte_eth_promiscuous_disable(port);
+
+       if (ret != 0)
+               printf("Error during %s promiscuous mode for port %u: %s\n",
+                       enable ? "enabling" : "disabling",
+                       port, rte_strerror(-ret));
+}
+
+void
+eth_set_allmulticast_mode(uint16_t port, int enable)
+{
+       int ret;
+
+       if (enable)
+               ret = rte_eth_allmulticast_enable(port);
+       else
+               ret = rte_eth_allmulticast_disable(port);
+
+       if (ret != 0)
+               printf("Error during %s all-multicast mode for port %u: %s\n",
+                       enable ? "enabling" : "disabling",
+                       port, rte_strerror(-ret));
+}
+
+int
+eth_link_get_nowait_print_err(uint16_t port_id, struct rte_eth_link *link)
+{
+       int ret;
+
+       ret = rte_eth_link_get_nowait(port_id, link);
+       if (ret < 0)
+               printf("Device (port %u) link get (without wait) failed: %s\n",
+                       port_id, rte_strerror(-ret));
+
+       return ret;
+}
+
+int
+eth_macaddr_get_print_err(uint16_t port_id, struct rte_ether_addr *mac_addr)
+{
+       int ret;
+
+       ret = rte_eth_macaddr_get(port_id, mac_addr);
+       if (ret != 0)
+               printf("Error getting device (port %u) mac address: %s\n",
+                               port_id, rte_strerror(-ret));
+
+       return ret;
+}