Currently, if one incorrect mac is set, a first log with little context
is displayed, followed by a more complete one.
Besides, if no port can be identified with the passed mac, then no
explanation is displayed.
Report some details in a single log.
Before:
netdev_dpdk|ERR|invalid mac: 00:00:00:00:00:
netdev_dpdk|WARN|Error attaching device 'class=eth,mac=00:00:00:00:00:'
to DPDK
...
netdev_dpdk|WARN|Error attaching device 'class=eth,mac=00:00:00:00:00:00'
to DPDK
After:
netdev_dpdk|WARN|Error attaching device 'class=eth,mac=00:00:00:00:00:':
invalid mac
...
netdev_dpdk|WARN|Error attaching device 'class=eth,mac=00:00:00:00:00:00':
unknown mac
Acked-by: Eli Britstein <[email protected]>
Acked-by: Eelco Chaudron <[email protected]>
Signed-off-by: David Marchand <[email protected]>
---
Changes since v1:
- avoided allocating memory for error strings,
Changes since RFC v1:
- removed redundant "to DPDK" in netdev-dpdk log messages,
---
lib/netdev-dpdk.c | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 90d4c2c71e..7629d0f974 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -2030,13 +2030,15 @@ netdev_dpdk_lookup_by_port_id(dpdk_port_t port_id)
}
static dpdk_port_t
-netdev_dpdk_get_port_by_mac(const char *mac_str)
+netdev_dpdk_get_port_by_mac(const char *mac_str, char const **extra_err)
{
dpdk_port_t port_id;
struct eth_addr mac, port_mac;
+ *extra_err = NULL;
+
if (!eth_addr_from_string(mac_str, &mac)) {
- VLOG_ERR("invalid mac: %s", mac_str);
+ *extra_err = "invalid mac";
return DPDK_ETH_PORT_ID_INVALID;
}
@@ -2050,6 +2052,7 @@ netdev_dpdk_get_port_by_mac(const char *mac_str)
}
}
+ *extra_err = "unknown mac";
return DPDK_ETH_PORT_ID_INVALID;
}
@@ -2086,31 +2089,38 @@ netdev_dpdk_process_devargs(struct netdev_dpdk *dev,
OVS_REQUIRES(dpdk_mutex)
{
dpdk_port_t new_port_id;
+ char const *extra_err = NULL;
if (strncmp(devargs, "class=eth,mac=", 14) == 0) {
- new_port_id = netdev_dpdk_get_port_by_mac(&devargs[14]);
+ new_port_id = netdev_dpdk_get_port_by_mac(&devargs[14], &extra_err);
} else {
new_port_id = netdev_dpdk_get_port_by_devargs(devargs);
if (!rte_eth_dev_is_valid_port(new_port_id)) {
+ int ret;
+
/* Device not found in DPDK, attempt to attach it */
- if (rte_dev_probe(devargs)) {
+ ret = rte_dev_probe(devargs);
+ if (ret < 0) {
new_port_id = DPDK_ETH_PORT_ID_INVALID;
+ extra_err = ovs_strerror(-ret);
} else {
new_port_id = netdev_dpdk_get_port_by_devargs(devargs);
if (rte_eth_dev_is_valid_port(new_port_id)) {
/* Attach successful */
dev->attached = true;
- VLOG_INFO("Device '%s' attached to DPDK", devargs);
+ VLOG_INFO("Device '%s' attached", devargs);
} else {
/* Attach unsuccessful */
new_port_id = DPDK_ETH_PORT_ID_INVALID;
+ extra_err = "port unknown";
}
}
}
}
if (new_port_id == DPDK_ETH_PORT_ID_INVALID) {
- VLOG_WARN_BUF(errp, "Error attaching device '%s' to DPDK", devargs);
+ VLOG_WARN_BUF(errp, "Error attaching device '%s': %s", devargs,
+ extra_err ? extra_err : "unknown error");
}
return new_port_id;
--
2.53.0
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev