* [dpdk-dev] [PATCH next 01/10] net/tap: convert to dynamic logging
2018-04-25 15:56 [dpdk-dev] [PATCH next 00/10] more dynamic logging Stephen Hemminger
@ 2018-04-25 15:56 ` Stephen Hemminger
2018-04-25 15:56 ` [dpdk-dev] [PATCH next 02/10] net/af_packet: convert to dynamic log level Stephen Hemminger
` (9 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: Stephen Hemminger @ 2018-04-25 15:56 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger
Use new logging macro to convert all calls to RTE_LOG() into
new dynamic log type.
Also fix whitespace.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/tap/rte_eth_tap.c | 168 ++++++++++++++++++----------------
drivers/net/tap/rte_eth_tap.h | 1 +
drivers/net/tap/tap_flow.c | 51 +++++------
drivers/net/tap/tap_intr.c | 2 +-
drivers/net/tap/tap_log.h | 10 ++
drivers/net/tap/tap_netlink.c | 18 ++--
drivers/net/tap/tap_tcmsgs.c | 9 +-
7 files changed, 138 insertions(+), 121 deletions(-)
create mode 100644 drivers/net/tap/tap_log.h
diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index cca5852cc3ac..63f05cec6706 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -118,50 +118,46 @@ tun_alloc(struct pmd_internals *pmd)
ifr.ifr_flags = (tap_type) ? IFF_TAP : IFF_TUN | IFF_POINTOPOINT;
snprintf(ifr.ifr_name, IFNAMSIZ, "%s", pmd->name);
- RTE_LOG(DEBUG, PMD, "ifr_name '%s'\n", ifr.ifr_name);
+ TAP_LOG(DEBUG, "ifr_name '%s'", ifr.ifr_name);
fd = open(TUN_TAP_DEV_PATH, O_RDWR);
if (fd < 0) {
- RTE_LOG(ERR, PMD, "Unable to create %s interface\n",
- tuntap_name);
+ TAP_LOG(ERR, "Unable to create %s interface", tuntap_name);
goto error;
}
#ifdef IFF_MULTI_QUEUE
/* Grab the TUN features to verify we can work multi-queue */
if (ioctl(fd, TUNGETFEATURES, &features) < 0) {
- RTE_LOG(ERR, PMD, "%s unable to get TUN/TAP features\n",
- tuntap_name);
+ TAP_LOG(ERR, "%s unable to get TUN/TAP features",
+ tuntap_name);
goto error;
}
- RTE_LOG(DEBUG, PMD, "%s Features %08x\n", tuntap_name, features);
+ TAP_LOG(DEBUG, "%s Features %08x", tuntap_name, features);
if (features & IFF_MULTI_QUEUE) {
- RTE_LOG(DEBUG, PMD, " Multi-queue support for %d queues\n",
+ TAP_LOG(DEBUG, " Multi-queue support for %d queues",
RTE_PMD_TAP_MAX_QUEUES);
ifr.ifr_flags |= IFF_MULTI_QUEUE;
} else
#endif
{
ifr.ifr_flags |= IFF_ONE_QUEUE;
- RTE_LOG(DEBUG, PMD, " Single queue only support\n");
+ TAP_LOG(DEBUG, " Single queue only support");
}
/* Set the TUN/TAP configuration and set the name if needed */
if (ioctl(fd, TUNSETIFF, (void *)&ifr) < 0) {
- RTE_LOG(WARNING, PMD,
- "Unable to set TUNSETIFF for %s\n",
- ifr.ifr_name);
- perror("TUNSETIFF");
+ TAP_LOG(WARNING, "Unable to set TUNSETIFF for %s: %s",
+ ifr.ifr_name, strerror(errno));
goto error;
}
/* Always set the file descriptor to non-blocking */
if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) {
- RTE_LOG(WARNING, PMD,
- "Unable to set %s to nonblocking\n",
- ifr.ifr_name);
- perror("F_SETFL, NONBLOCK");
+ TAP_LOG(WARNING,
+ "Unable to set %s to nonblocking: %s",
+ ifr.ifr_name, strerror(errno));
goto error;
}
@@ -195,10 +191,11 @@ tun_alloc(struct pmd_internals *pmd)
fcntl(fd, F_SETFL, flags | O_ASYNC);
fcntl(fd, F_SETOWN, getpid());
} while (0);
+
if (errno) {
/* Disable trigger globally in case of error */
tap_trigger = 0;
- RTE_LOG(WARNING, PMD, "Rx trigger disabled: %s\n",
+ TAP_LOG(WARNING, "Rx trigger disabled: %s",
strerror(errno));
}
@@ -630,8 +627,8 @@ tap_ioctl(struct pmd_internals *pmd, unsigned long request,
return 0;
error:
- RTE_LOG(DEBUG, PMD, "%s: %s(%s) failed: %s(%d)\n", ifr->ifr_name,
- __func__, tap_ioctl_req2str(request), strerror(errno), errno);
+ TAP_LOG(DEBUG, "%s(%s) failed: %s(%d)", ifr->ifr_name,
+ tap_ioctl_req2str(request), strerror(errno), errno);
return -errno;
}
@@ -683,34 +680,34 @@ tap_dev_configure(struct rte_eth_dev *dev)
if ((tx_offloads & supp_tx_offloads) != tx_offloads) {
rte_errno = ENOTSUP;
- RTE_LOG(ERR, PMD,
+ TAP_LOG(ERR,
"Some Tx offloads are not supported "
- "requested 0x%" PRIx64 " supported 0x%" PRIx64 "\n",
+ "requested 0x%" PRIx64 " supported 0x%" PRIx64,
tx_offloads, supp_tx_offloads);
return -rte_errno;
}
if (dev->data->nb_rx_queues > RTE_PMD_TAP_MAX_QUEUES) {
- RTE_LOG(ERR, PMD,
- "%s: number of rx queues %d exceeds max num of queues %d\n",
+ TAP_LOG(ERR,
+ "%s: number of rx queues %d exceeds max num of queues %d",
dev->device->name,
dev->data->nb_rx_queues,
RTE_PMD_TAP_MAX_QUEUES);
return -1;
}
if (dev->data->nb_tx_queues > RTE_PMD_TAP_MAX_QUEUES) {
- RTE_LOG(ERR, PMD,
- "%s: number of tx queues %d exceeds max num of queues %d\n",
+ TAP_LOG(ERR,
+ "%s: number of tx queues %d exceeds max num of queues %d",
dev->device->name,
dev->data->nb_tx_queues,
RTE_PMD_TAP_MAX_QUEUES);
return -1;
}
- RTE_LOG(INFO, PMD, "%s: %p: TX configured queues number: %u\n",
- dev->device->name, (void *)dev, dev->data->nb_tx_queues);
+ TAP_LOG(INFO, "%s: %p: TX configured queues number: %u",
+ dev->device->name, (void *)dev, dev->data->nb_tx_queues);
- RTE_LOG(INFO, PMD, "%s: %p: RX configured queues number: %u\n",
- dev->device->name, (void *)dev, dev->data->nb_rx_queues);
+ TAP_LOG(INFO, "%s: %p: RX configured queues number: %u",
+ dev->device->name, (void *)dev, dev->data->nb_rx_queues);
return 0;
}
@@ -965,7 +962,7 @@ tap_mac_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr)
int ret;
if (is_zero_ether_addr(mac_addr)) {
- RTE_LOG(ERR, PMD, "%s: can't set an empty MAC address\n",
+ TAP_LOG(ERR, "%s: can't set an empty MAC address",
dev->device->name);
return -EINVAL;
}
@@ -993,15 +990,15 @@ tap_mac_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr)
/* Replace MAC redirection rule after a MAC change */
ret = tap_flow_implicit_destroy(pmd, TAP_REMOTE_LOCAL_MAC);
if (ret < 0) {
- RTE_LOG(ERR, PMD,
- "%s: Couldn't delete MAC redirection rule\n",
+ TAP_LOG(ERR,
+ "%s: Couldn't delete MAC redirection rule",
dev->device->name);
return ret;
}
ret = tap_flow_implicit_create(pmd, TAP_REMOTE_LOCAL_MAC);
if (ret < 0) {
- RTE_LOG(ERR, PMD,
- "%s: Couldn't add MAC redirection rule\n",
+ TAP_LOG(ERR,
+ "%s: Couldn't add MAC redirection rule",
dev->device->name);
return ret;
}
@@ -1034,29 +1031,27 @@ tap_setup_queue(struct rte_eth_dev *dev,
}
if (*fd != -1) {
/* fd for this queue already exists */
- RTE_LOG(DEBUG, PMD, "%s: fd %d for %s queue qid %d exists\n",
+ TAP_LOG(DEBUG, "%s: fd %d for %s queue qid %d exists",
pmd->name, *fd, dir, qid);
} else if (*other_fd != -1) {
/* Only other_fd exists. dup it */
*fd = dup(*other_fd);
if (*fd < 0) {
*fd = -1;
- RTE_LOG(ERR, PMD, "%s: dup() failed.\n",
- pmd->name);
+ TAP_LOG(ERR, "%s: dup() failed.", pmd->name);
return -1;
}
- RTE_LOG(DEBUG, PMD, "%s: dup fd %d for %s queue qid %d (%d)\n",
+ TAP_LOG(DEBUG, "%s: dup fd %d for %s queue qid %d (%d)",
pmd->name, *other_fd, dir, qid, *fd);
} else {
/* Both RX and TX fds do not exist (equal -1). Create fd */
*fd = tun_alloc(pmd);
if (*fd < 0) {
*fd = -1; /* restore original value */
- RTE_LOG(ERR, PMD, "%s: tun_alloc() failed.\n",
- pmd->name);
+ TAP_LOG(ERR, "%s: tun_alloc() failed.", pmd->name);
return -1;
}
- RTE_LOG(DEBUG, PMD, "%s: add %s queue for qid %d fd %d\n",
+ TAP_LOG(DEBUG, "%s: add %s queue for qid %d fd %d",
pmd->name, dir, qid, *fd);
}
@@ -1086,8 +1081,8 @@ tap_rx_queue_setup(struct rte_eth_dev *dev,
int i;
if (rx_queue_id >= dev->data->nb_rx_queues || !mp) {
- RTE_LOG(WARNING, PMD,
- "nb_rx_queues %d too small or mempool NULL\n",
+ TAP_LOG(WARNING,
+ "nb_rx_queues %d too small or mempool NULL",
dev->data->nb_rx_queues);
return -1;
}
@@ -1095,10 +1090,10 @@ tap_rx_queue_setup(struct rte_eth_dev *dev,
/* Verify application offloads are valid for our port and queue. */
if (!tap_rxq_are_offloads_valid(dev, rx_conf->offloads)) {
rte_errno = ENOTSUP;
- RTE_LOG(ERR, PMD,
+ TAP_LOG(ERR,
"%p: Rx queue offloads 0x%" PRIx64
" don't match port offloads 0x%" PRIx64
- " or supported offloads 0x%" PRIx64 "\n",
+ " or supported offloads 0x%" PRIx64,
(void *)dev, rx_conf->offloads,
dev->data->dev_conf.rxmode.offloads,
(tap_rx_offload_get_port_capa() |
@@ -1112,8 +1107,8 @@ tap_rx_queue_setup(struct rte_eth_dev *dev,
iovecs = rte_zmalloc_socket(dev->device->name, sizeof(*iovecs), 0,
socket_id);
if (!iovecs) {
- RTE_LOG(WARNING, PMD,
- "%s: Couldn't allocate %d RX descriptors\n",
+ TAP_LOG(WARNING,
+ "%s: Couldn't allocate %d RX descriptors",
dev->device->name, nb_desc);
return -ENOMEM;
}
@@ -1132,8 +1127,8 @@ tap_rx_queue_setup(struct rte_eth_dev *dev,
for (i = 1; i <= nb_desc; i++) {
*tmp = rte_pktmbuf_alloc(rxq->mp);
if (!*tmp) {
- RTE_LOG(WARNING, PMD,
- "%s: couldn't allocate memory for queue %d\n",
+ TAP_LOG(WARNING,
+ "%s: couldn't allocate memory for queue %d",
dev->device->name, rx_queue_id);
ret = -ENOMEM;
goto error;
@@ -1145,7 +1140,7 @@ tap_rx_queue_setup(struct rte_eth_dev *dev,
tmp = &(*tmp)->next;
}
- RTE_LOG(DEBUG, PMD, " RX TUNTAP device name %s, qid %d on fd %d\n",
+ TAP_LOG(DEBUG, " RX TUNTAP device name %s, qid %d on fd %d",
internals->name, rx_queue_id, internals->rxq[rx_queue_id].fd);
return 0;
@@ -1186,7 +1181,7 @@ tap_tx_queue_setup(struct rte_eth_dev *dev,
DEV_TX_OFFLOAD_TCP_CKSUM));
} else {
rte_errno = ENOTSUP;
- RTE_LOG(ERR, PMD,
+ TAP_LOG(ERR,
"%p: Tx queue offloads 0x%" PRIx64
" don't match port offloads 0x%" PRIx64
" or supported offloads 0x%" PRIx64,
@@ -1199,8 +1194,8 @@ tap_tx_queue_setup(struct rte_eth_dev *dev,
ret = tap_setup_queue(dev, internals, tx_queue_id, 0);
if (ret == -1)
return -1;
- RTE_LOG(DEBUG, PMD,
- " TX TUNTAP device name %s, qid %d on fd %d csum %s\n",
+ TAP_LOG(DEBUG,
+ " TX TUNTAP device name %s, qid %d on fd %d csum %s",
internals->name, tx_queue_id, internals->txq[tx_queue_id].fd,
txq->csum ? "on" : "off");
@@ -1383,12 +1378,12 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name,
struct ifreq ifr;
int i;
- RTE_LOG(DEBUG, PMD, "%s device on numa %u\n",
+ TAP_LOG(DEBUG, "%s device on numa %u",
tuntap_name, rte_socket_id());
dev = rte_eth_vdev_allocate(vdev, sizeof(*pmd));
if (!dev) {
- RTE_LOG(ERR, PMD, "%s Unable to allocate device struct\n",
+ TAP_LOG(ERR, "%s Unable to allocate device struct",
tuntap_name);
goto error_exit_nodev;
}
@@ -1399,8 +1394,8 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name,
pmd->ioctl_sock = socket(AF_INET, SOCK_DGRAM, 0);
if (pmd->ioctl_sock == -1) {
- RTE_LOG(ERR, PMD,
- "%s Unable to get a socket for management: %s\n",
+ TAP_LOG(ERR,
+ "%s Unable to get a socket for management: %s",
tuntap_name, strerror(errno));
goto error_exit;
}
@@ -1469,22 +1464,22 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name,
*/
pmd->nlsk_fd = tap_nl_init(0);
if (pmd->nlsk_fd == -1) {
- RTE_LOG(WARNING, PMD, "%s: failed to create netlink socket.\n",
+ TAP_LOG(WARNING, "%s: failed to create netlink socket.",
pmd->name);
goto disable_rte_flow;
}
pmd->if_index = if_nametoindex(pmd->name);
if (!pmd->if_index) {
- RTE_LOG(ERR, PMD, "%s: failed to get if_index.\n", pmd->name);
+ TAP_LOG(ERR, "%s: failed to get if_index.", pmd->name);
goto disable_rte_flow;
}
if (qdisc_create_multiq(pmd->nlsk_fd, pmd->if_index) < 0) {
- RTE_LOG(ERR, PMD, "%s: failed to create multiq qdisc.\n",
+ TAP_LOG(ERR, "%s: failed to create multiq qdisc.",
pmd->name);
goto disable_rte_flow;
}
if (qdisc_create_ingress(pmd->nlsk_fd, pmd->if_index) < 0) {
- RTE_LOG(ERR, PMD, "%s: failed to create ingress qdisc.\n",
+ TAP_LOG(ERR, "%s: failed to create ingress qdisc.",
pmd->name);
goto disable_rte_flow;
}
@@ -1493,7 +1488,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name,
if (strlen(remote_iface)) {
pmd->remote_if_index = if_nametoindex(remote_iface);
if (!pmd->remote_if_index) {
- RTE_LOG(ERR, PMD, "%s: failed to get %s if_index.\n",
+ TAP_LOG(ERR, "%s: failed to get %s if_index.",
pmd->name, remote_iface);
goto error_remote;
}
@@ -1505,7 +1500,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name,
/* Replicate remote MAC address */
if (tap_ioctl(pmd, SIOCGIFHWADDR, &ifr, 0, REMOTE_ONLY) < 0) {
- RTE_LOG(ERR, PMD, "%s: failed to get %s MAC address.\n",
+ TAP_LOG(ERR, "%s: failed to get %s MAC address.",
pmd->name, pmd->remote_iface);
goto error_remote;
}
@@ -1513,7 +1508,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name,
ETHER_ADDR_LEN);
/* The desired MAC is already in ifreq after SIOCGIFHWADDR. */
if (tap_ioctl(pmd, SIOCSIFHWADDR, &ifr, 0, LOCAL_ONLY) < 0) {
- RTE_LOG(ERR, PMD, "%s: failed to get %s MAC address.\n",
+ TAP_LOG(ERR, "%s: failed to get %s MAC address.",
pmd->name, remote_iface);
goto error_remote;
}
@@ -1526,7 +1521,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name,
qdisc_flush(pmd->nlsk_fd, pmd->remote_if_index);
if (qdisc_create_ingress(pmd->nlsk_fd,
pmd->remote_if_index) < 0) {
- RTE_LOG(ERR, PMD, "%s: failed to create ingress qdisc.\n",
+ TAP_LOG(ERR, "%s: failed to create ingress qdisc.",
pmd->remote_iface);
goto error_remote;
}
@@ -1535,8 +1530,8 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name,
tap_flow_implicit_create(pmd, TAP_REMOTE_LOCAL_MAC) < 0 ||
tap_flow_implicit_create(pmd, TAP_REMOTE_BROADCAST) < 0 ||
tap_flow_implicit_create(pmd, TAP_REMOTE_BROADCASTV6) < 0) {
- RTE_LOG(ERR, PMD,
- "%s: failed to create implicit rules.\n",
+ TAP_LOG(ERR,
+ "%s: failed to create implicit rules.",
pmd->name);
goto error_remote;
}
@@ -1545,16 +1540,16 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name,
return 0;
disable_rte_flow:
- RTE_LOG(ERR, PMD, " Disabling rte flow support: %s(%d)\n",
+ TAP_LOG(ERR, " Disabling rte flow support: %s(%d)",
strerror(errno), errno);
if (strlen(remote_iface)) {
- RTE_LOG(ERR, PMD, "Remote feature requires flow support.\n");
+ TAP_LOG(ERR, "Remote feature requires flow support.");
goto error_exit;
}
return 0;
error_remote:
- RTE_LOG(ERR, PMD, " Can't set up remote feature: %s(%d)\n",
+ TAP_LOG(ERR, " Can't set up remote feature: %s(%d)",
strerror(errno), errno);
tap_flow_implicit_flush(pmd, NULL);
@@ -1564,7 +1559,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name,
rte_eth_dev_release_port(dev);
error_exit_nodev:
- RTE_LOG(ERR, PMD, "%s Unable to initialize %s\n",
+ TAP_LOG(ERR, "%s Unable to initialize %s",
tuntap_name, rte_vdev_device_name(vdev));
return -EINVAL;
@@ -1644,11 +1639,11 @@ set_mac_type(const char *key __rte_unused,
if (parse_user_mac(user_mac, value) != 6)
goto error;
success:
- RTE_LOG(DEBUG, PMD, "TAP user MAC param (%s)\n", value);
+ TAP_LOG(DEBUG, "TAP user MAC param (%s)", value);
return 0;
error:
- RTE_LOG(ERR, PMD, "TAP user MAC (%s) is not in format (%s|%s)\n",
+ TAP_LOG(ERR, "TAP user MAC (%s) is not in format (%s|%s)",
value, ETH_TAP_MAC_FIXED, ETH_TAP_USR_MAC_FMT);
return -1;
}
@@ -1676,7 +1671,7 @@ rte_pmd_tun_probe(struct rte_vdev_device *dev)
memset(remote_iface, 0, RTE_ETH_NAME_MAX_LEN);
if (params && (params[0] != '\0')) {
- RTE_LOG(DEBUG, PMD, "parameters (%s)\n", params);
+ TAP_LOG(DEBUG, "parameters (%s)", params);
kvlist = rte_kvargs_parse(params, valid_arguments);
if (kvlist) {
@@ -1693,14 +1688,14 @@ rte_pmd_tun_probe(struct rte_vdev_device *dev)
}
pmd_link.link_speed = ETH_SPEED_NUM_10G;
- RTE_LOG(NOTICE, PMD, "Initializing pmd_tun for %s as %s\n",
+ TAP_LOG(NOTICE, "Initializing pmd_tun for %s as %s",
name, tun_name);
ret = eth_dev_tap_create(dev, tun_name, remote_iface, 0);
leave:
if (ret == -1) {
- RTE_LOG(ERR, PMD, "Failed to create pmd for %s as %s\n",
+ TAP_LOG(ERR, "Failed to create pmd for %s as %s",
name, tun_name);
tun_unit--; /* Restore the unit number */
}
@@ -1733,7 +1728,7 @@ rte_pmd_tap_probe(struct rte_vdev_device *dev)
strlen(params) == 0) {
eth_dev = rte_eth_dev_attach_secondary(name);
if (!eth_dev) {
- RTE_LOG(ERR, PMD, "Failed to probe %s\n", name);
+ TAP_LOG(ERR, "Failed to probe %s", name);
return -1;
}
/* TODO: request info from primary to set up Rx and Tx */
@@ -1747,7 +1742,7 @@ rte_pmd_tap_probe(struct rte_vdev_device *dev)
memset(remote_iface, 0, RTE_ETH_NAME_MAX_LEN);
if (params && (params[0] != '\0')) {
- RTE_LOG(DEBUG, PMD, "parameters (%s)\n", params);
+ TAP_LOG(DEBUG, "parameters (%s)", params);
kvlist = rte_kvargs_parse(params, valid_arguments);
if (kvlist) {
@@ -1781,14 +1776,14 @@ rte_pmd_tap_probe(struct rte_vdev_device *dev)
}
pmd_link.link_speed = speed;
- RTE_LOG(NOTICE, PMD, "Initializing pmd_tap for %s as %s\n",
+ TAP_LOG(NOTICE, "Initializing pmd_tap for %s as %s",
name, tap_name);
ret = eth_dev_tap_create(dev, tap_name, remote_iface, &user_mac);
leave:
if (ret == -1) {
- RTE_LOG(ERR, PMD, "Failed to create pmd for %s as %s\n",
+ TAP_LOG(ERR, "Failed to create pmd for %s as %s",
name, tap_name);
tap_unit--; /* Restore the unit number */
}
@@ -1806,7 +1801,7 @@ rte_pmd_tap_remove(struct rte_vdev_device *dev)
struct pmd_internals *internals;
int i;
- RTE_LOG(DEBUG, PMD, "Closing TUN/TAP Ethernet device on numa %u\n",
+ TAP_LOG(DEBUG, "Closing TUN/TAP Ethernet device on numa %u",
rte_socket_id());
/* find the ethdev entry */
@@ -1848,6 +1843,7 @@ static struct rte_vdev_driver pmd_tap_drv = {
.probe = rte_pmd_tap_probe,
.remove = rte_pmd_tap_remove,
};
+
RTE_PMD_REGISTER_VDEV(net_tap, pmd_tap_drv);
RTE_PMD_REGISTER_VDEV(net_tun, pmd_tun_drv);
RTE_PMD_REGISTER_ALIAS(net_tap, eth_tap);
@@ -1857,3 +1853,13 @@ RTE_PMD_REGISTER_PARAM_STRING(net_tap,
ETH_TAP_IFACE_ARG "=<string> "
ETH_TAP_MAC_ARG "=" ETH_TAP_MAC_ARG_FMT " "
ETH_TAP_REMOTE_ARG "=<string>");
+int tap_logtype;
+
+RTE_INIT(tap_init_log);
+static void
+tap_init_log(void)
+{
+ tap_logtype = rte_log_register("pmd.net.tap");
+ if (tap_logtype >= 0)
+ rte_log_set_level(tap_logtype, RTE_LOG_NOTICE);
+}
diff --git a/drivers/net/tap/rte_eth_tap.h b/drivers/net/tap/rte_eth_tap.h
index 25b65bf308c7..67c9d4beebb6 100644
--- a/drivers/net/tap/rte_eth_tap.h
+++ b/drivers/net/tap/rte_eth_tap.h
@@ -15,6 +15,7 @@
#include <rte_ethdev_driver.h>
#include <rte_ether.h>
+#include "tap_log.h"
#ifdef IFF_MULTI_QUEUE
#define RTE_PMD_TAP_MAX_QUEUES TAP_MAX_QUEUES
diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c
index 3b7a960b0946..1b23c09174c8 100644
--- a/drivers/net/tap/tap_flow.c
+++ b/drivers/net/tap/tap_flow.c
@@ -1376,8 +1376,8 @@ tap_flow_create(struct rte_eth_dev *dev,
}
err = tap_nl_recv_ack(pmd->nlsk_fd);
if (err < 0) {
- RTE_LOG(ERR, PMD,
- "Kernel refused TC filter rule creation (%d): %s\n",
+ TAP_LOG(ERR,
+ "Kernel refused TC filter rule creation (%d): %s",
errno, strerror(errno));
rte_flow_error_set(error, EEXIST, RTE_FLOW_ERROR_TYPE_HANDLE,
NULL,
@@ -1421,8 +1421,8 @@ tap_flow_create(struct rte_eth_dev *dev,
}
err = tap_nl_recv_ack(pmd->nlsk_fd);
if (err < 0) {
- RTE_LOG(ERR, PMD,
- "Kernel refused TC filter rule creation (%d): %s\n",
+ TAP_LOG(ERR,
+ "Kernel refused TC filter rule creation (%d): %s",
errno, strerror(errno));
rte_flow_error_set(
error, ENOMEM, RTE_FLOW_ERROR_TYPE_HANDLE,
@@ -1476,8 +1476,8 @@ tap_flow_destroy_pmd(struct pmd_internals *pmd,
if (ret < 0 && errno == ENOENT)
ret = 0;
if (ret < 0) {
- RTE_LOG(ERR, PMD,
- "Kernel refused TC filter rule deletion (%d): %s\n",
+ TAP_LOG(ERR,
+ "Kernel refused TC filter rule deletion (%d): %s",
errno, strerror(errno));
rte_flow_error_set(
error, ENOTSUP, RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
@@ -1500,8 +1500,8 @@ tap_flow_destroy_pmd(struct pmd_internals *pmd,
if (ret < 0 && errno == ENOENT)
ret = 0;
if (ret < 0) {
- RTE_LOG(ERR, PMD,
- "Kernel refused TC filter rule deletion (%d): %s\n",
+ TAP_LOG(ERR,
+ "Kernel refused TC filter rule deletion (%d): %s",
errno, strerror(errno));
rte_flow_error_set(
error, ENOMEM, RTE_FLOW_ERROR_TYPE_HANDLE,
@@ -1665,7 +1665,7 @@ int tap_flow_implicit_create(struct pmd_internals *pmd,
remote_flow = rte_malloc(__func__, sizeof(struct rte_flow), 0);
if (!remote_flow) {
- RTE_LOG(ERR, PMD, "Cannot allocate memory for rte_flow\n");
+ TAP_LOG(ERR, "Cannot allocate memory for rte_flow");
goto fail;
}
msg = &remote_flow->msg;
@@ -1706,12 +1706,12 @@ int tap_flow_implicit_create(struct pmd_internals *pmd,
tap_flow_set_handle(remote_flow);
if (priv_flow_process(pmd, attr, items, actions, NULL,
remote_flow, implicit_rte_flows[idx].mirred)) {
- RTE_LOG(ERR, PMD, "rte flow rule validation failed\n");
+ TAP_LOG(ERR, "rte flow rule validation failed");
goto fail;
}
err = tap_nl_send(pmd->nlsk_fd, &msg->nh);
if (err < 0) {
- RTE_LOG(ERR, PMD, "Failure sending nl request\n");
+ TAP_LOG(ERR, "Failure sending nl request");
goto fail;
}
err = tap_nl_recv_ack(pmd->nlsk_fd);
@@ -1719,8 +1719,8 @@ int tap_flow_implicit_create(struct pmd_internals *pmd,
/* Silently ignore re-entering remote promiscuous rule */
if (errno == EEXIST && idx == TAP_REMOTE_PROMISC)
goto success;
- RTE_LOG(ERR, PMD,
- "Kernel refused TC filter rule creation (%d): %s\n",
+ TAP_LOG(ERR,
+ "Kernel refused TC filter rule creation (%d): %s",
errno, strerror(errno));
goto fail;
}
@@ -1836,8 +1836,8 @@ static int rss_enable(struct pmd_internals *pmd,
sizeof(struct rss_key),
MAX_RSS_KEYS);
if (pmd->map_fd < 0) {
- RTE_LOG(ERR, PMD,
- "Failed to create BPF map (%d): %s\n",
+ TAP_LOG(ERR,
+ "Failed to create BPF map (%d): %s",
errno, strerror(errno));
rte_flow_error_set(
error, ENOTSUP, RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
@@ -1854,7 +1854,7 @@ static int rss_enable(struct pmd_internals *pmd,
for (i = 0; i < pmd->dev->data->nb_rx_queues; i++) {
pmd->bpf_fd[i] = tap_flow_bpf_cls_q(i);
if (pmd->bpf_fd[i] < 0) {
- RTE_LOG(ERR, PMD,
+ TAP_LOG(ERR,
"Failed to load BPF section %s for queue %d",
SEC_NAME_CLS_Q, i);
rte_flow_error_set(
@@ -1868,7 +1868,7 @@ static int rss_enable(struct pmd_internals *pmd,
rss_flow = rte_malloc(__func__, sizeof(struct rte_flow), 0);
if (!rss_flow) {
- RTE_LOG(ERR, PMD,
+ TAP_LOG(ERR,
"Cannot allocate memory for rte_flow");
return -1;
}
@@ -1911,8 +1911,8 @@ static int rss_enable(struct pmd_internals *pmd,
return -1;
err = tap_nl_recv_ack(pmd->nlsk_fd);
if (err < 0) {
- RTE_LOG(ERR, PMD,
- "Kernel refused TC filter rule creation (%d): %s\n",
+ TAP_LOG(ERR,
+ "Kernel refused TC filter rule creation (%d): %s",
errno, strerror(errno));
return err;
}
@@ -2066,8 +2066,8 @@ static int rss_add_actions(struct rte_flow *flow, struct pmd_internals *pmd,
&flow->key_idx, &rss_entry);
if (err) {
- RTE_LOG(ERR, PMD,
- "Failed to update BPF map entry #%u (%d): %s\n",
+ TAP_LOG(ERR,
+ "Failed to update BPF map entry #%u (%d): %s",
flow->key_idx, errno, strerror(errno));
rte_flow_error_set(
error, ENOTSUP, RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
@@ -2085,8 +2085,8 @@ static int rss_add_actions(struct rte_flow *flow, struct pmd_internals *pmd,
flow->bpf_fd[SEC_L3_L4] =
tap_flow_bpf_calc_l3_l4_hash(flow->key_idx, pmd->map_fd);
if (flow->bpf_fd[SEC_L3_L4] < 0) {
- RTE_LOG(ERR, PMD,
- "Failed to load BPF section %s (%d): %s\n",
+ TAP_LOG(ERR,
+ "Failed to load BPF section %s (%d): %s",
sec_name[SEC_L3_L4], errno, strerror(errno));
rte_flow_error_set(
error, ENOTSUP, RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
@@ -2147,9 +2147,8 @@ tap_dev_filter_ctrl(struct rte_eth_dev *dev,
*(const void **)arg = &tap_flow_ops;
return 0;
default:
- RTE_LOG(ERR, PMD, "%p: filter type (%d) not supported\n",
- (void *)dev, filter_type);
+ TAP_LOG(ERR, "%p: filter type (%d) not supported",
+ dev, filter_type);
}
return -EINVAL;
}
-
diff --git a/drivers/net/tap/tap_intr.c b/drivers/net/tap/tap_intr.c
index 8283ecb3db41..fc590181fca7 100644
--- a/drivers/net/tap/tap_intr.c
+++ b/drivers/net/tap/tap_intr.c
@@ -62,7 +62,7 @@ tap_rx_intr_vec_install(struct rte_eth_dev *dev)
intr_handle->intr_vec = malloc(sizeof(intr_handle->intr_vec[rxqs_n]));
if (intr_handle->intr_vec == NULL) {
rte_errno = ENOMEM;
- RTE_LOG(ERR, PMD,
+ TAP_LOG(ERR,
"failed to allocate memory for interrupt vector,"
" Rx interrupts will not be supported");
return -rte_errno;
diff --git a/drivers/net/tap/tap_log.h b/drivers/net/tap/tap_log.h
new file mode 100644
index 000000000000..fa06843a4c41
--- /dev/null
+++ b/drivers/net/tap/tap_log.h
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2017 6WIND S.A.
+ * Copyright 2017 Mellanox Technologies, Ltd
+ */
+
+extern int tap_logtype;
+
+#define TAP_LOG(level, fmt, args...) \
+ rte_log(RTE_LOG_ ## level, tap_logtype, "%s(): " fmt "\n", \
+ __func__, ## args)
diff --git a/drivers/net/tap/tap_netlink.c b/drivers/net/tap/tap_netlink.c
index 8273ac031b4e..6cb510092218 100644
--- a/drivers/net/tap/tap_netlink.c
+++ b/drivers/net/tap/tap_netlink.c
@@ -13,6 +13,7 @@
#include <rte_malloc.h>
#include <tap_netlink.h>
#include <rte_random.h>
+#include "tap_log.h"
/* Must be quite large to support dumping a huge list of QDISC or filters. */
#define BUF_SIZE (32 * 1024) /* Size of the buffer to receive kernel messages */
@@ -45,19 +46,19 @@ tap_nl_init(uint32_t nl_groups)
fd = socket(AF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, NETLINK_ROUTE);
if (fd < 0) {
- RTE_LOG(ERR, PMD, "Unable to create a netlink socket\n");
+ TAP_LOG(ERR, "Unable to create a netlink socket");
return -1;
}
if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &sndbuf_size, sizeof(int))) {
- RTE_LOG(ERR, PMD, "Unable to set socket buffer send size\n");
+ TAP_LOG(ERR, "Unable to set socket buffer send size");
return -1;
}
if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &rcvbuf_size, sizeof(int))) {
- RTE_LOG(ERR, PMD, "Unable to set socket buffer receive size\n");
+ TAP_LOG(ERR, "Unable to set socket buffer receive size");
return -1;
}
if (bind(fd, (struct sockaddr *)&local, sizeof(local)) < 0) {
- RTE_LOG(ERR, PMD, "Unable to bind to the netlink socket\n");
+ TAP_LOG(ERR, "Unable to bind to the netlink socket");
return -1;
}
return fd;
@@ -76,7 +77,7 @@ int
tap_nl_final(int nlsk_fd)
{
if (close(nlsk_fd)) {
- RTE_LOG(ERR, PMD, "Failed to close netlink socket: %s (%d)\n",
+ TAP_LOG(ERR, "Failed to close netlink socket: %s (%d)",
strerror(errno), errno);
return -1;
}
@@ -117,7 +118,7 @@ tap_nl_send(int nlsk_fd, struct nlmsghdr *nh)
nh->nlmsg_seq = (uint32_t)rte_rand();
send_bytes = sendmsg(nlsk_fd, &msg, 0);
if (send_bytes < 0) {
- RTE_LOG(ERR, PMD, "Failed to send netlink message: %s (%d)\n",
+ TAP_LOG(ERR, "Failed to send netlink message: %s (%d)",
strerror(errno), errno);
return -1;
}
@@ -300,9 +301,8 @@ tap_nlattr_nested_start(struct nlmsg *msg, uint16_t type)
tail = rte_zmalloc(NULL, sizeof(struct nested_tail), 0);
if (!tail) {
- RTE_LOG(ERR, PMD,
- "Couldn't allocate memory for nested netlink"
- " attribute\n");
+ TAP_LOG(ERR,
+ "Couldn't allocate memory for nested netlink attribute");
return -1;
}
diff --git a/drivers/net/tap/tap_tcmsgs.c b/drivers/net/tap/tap_tcmsgs.c
index 8da6ccc86df0..3c9d0366725e 100644
--- a/drivers/net/tap/tap_tcmsgs.c
+++ b/drivers/net/tap/tap_tcmsgs.c
@@ -10,6 +10,7 @@
#include <rte_log.h>
#include <tap_tcmsgs.h>
+#include "tap_log.h"
struct qdisc {
uint32_t handle;
@@ -81,8 +82,8 @@ qdisc_del(int nlsk_fd, uint16_t ifindex, struct qdisc *qinfo)
if (!nlsk_fd) {
fd = tap_nl_init(0);
if (fd < 0) {
- RTE_LOG(ERR, PMD,
- "Could not delete QDISC: null netlink socket\n");
+ TAP_LOG(ERR,
+ "Could not delete QDISC: null netlink socket");
return -1;
}
} else {
@@ -261,7 +262,7 @@ qdisc_create_multiq(int nlsk_fd, uint16_t ifindex)
err = qdisc_add_multiq(nlsk_fd, ifindex);
if (err < 0 && errno != -EEXIST) {
- RTE_LOG(ERR, PMD, "Could not add multiq qdisc (%d): %s\n",
+ TAP_LOG(ERR, "Could not add multiq qdisc (%d): %s",
errno, strerror(errno));
return -1;
}
@@ -287,7 +288,7 @@ qdisc_create_ingress(int nlsk_fd, uint16_t ifindex)
err = qdisc_add_ingress(nlsk_fd, ifindex);
if (err < 0 && errno != -EEXIST) {
- RTE_LOG(ERR, PMD, "Could not add ingress qdisc (%d): %s\n",
+ TAP_LOG(ERR, "Could not add ingress qdisc (%d): %s",
errno, strerror(errno));
return -1;
}
--
2.17.0
^ permalink raw reply [flat|nested] 15+ messages in thread
* [dpdk-dev] [PATCH next 02/10] net/af_packet: convert to dynamic log level
2018-04-25 15:56 [dpdk-dev] [PATCH next 00/10] more dynamic logging Stephen Hemminger
2018-04-25 15:56 ` [dpdk-dev] [PATCH next 01/10] net/tap: convert to " Stephen Hemminger
@ 2018-04-25 15:56 ` Stephen Hemminger
2018-04-25 15:56 ` [dpdk-dev] [PATCH next 03/10] net/null: convert to dynamic logging Stephen Hemminger
` (8 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: Stephen Hemminger @ 2018-04-25 15:56 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger
Convert this driver to use dynamic log level support.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/af_packet/rte_eth_af_packet.c | 132 ++++++++++++----------
1 file changed, 73 insertions(+), 59 deletions(-)
diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
index b394d3cb2926..247a2af5a0ff 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -97,6 +97,12 @@ static struct rte_eth_link pmd_link = {
.link_autoneg = ETH_LINK_AUTONEG
};
+static int af_packet_logtype;
+
+#define PMD_LOG(level, fmt, args...) \
+ rte_log(RTE_LOG_ ## level, af_packet_logtype, \
+ "%s(): " fmt "\n", __func__, ##args)
+
static uint16_t
eth_af_packet_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
{
@@ -393,8 +399,8 @@ eth_rx_queue_setup(struct rte_eth_dev *dev,
data_size -= TPACKET2_HDRLEN - sizeof(struct sockaddr_ll);
if (data_size > buf_size) {
- RTE_LOG(ERR, PMD,
- "%s: %d bytes will not fit in mbuf (%d bytes)\n",
+ PMD_LOG(ERR,
+ "%s: %d bytes will not fit in mbuf (%d bytes)",
dev->device->name, data_size, buf_size);
return -ENOMEM;
}
@@ -515,7 +521,7 @@ open_packet_iface(const char *key __rte_unused,
/* Open an AF_PACKET socket... */
*sockfd = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
if (*sockfd == -1) {
- RTE_LOG(ERR, PMD, "Could not open AF_PACKET socket\n");
+ PMD_LOG(ERR, "Could not open AF_PACKET socket");
return -1;
}
@@ -561,14 +567,14 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
break;
}
if (pair == NULL) {
- RTE_LOG(ERR, PMD,
- "%s: no interface specified for AF_PACKET ethdev\n",
+ PMD_LOG(ERR,
+ "%s: no interface specified for AF_PACKET ethdev",
name);
return -1;
}
- RTE_LOG(INFO, PMD,
- "%s: creating AF_PACKET-backed ethdev on numa socket %u\n",
+ PMD_LOG(INFO,
+ "%s: creating AF_PACKET-backed ethdev on numa socket %u",
name, numa_node);
*internals = rte_zmalloc_socket(name, sizeof(**internals),
@@ -593,14 +599,14 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
memcpy(ifr.ifr_name, pair->value, ifnamelen);
ifr.ifr_name[ifnamelen] = '\0';
} else {
- RTE_LOG(ERR, PMD,
- "%s: I/F name too long (%s)\n",
+ PMD_LOG(ERR,
+ "%s: I/F name too long (%s)",
name, pair->value);
return -1;
}
if (ioctl(sockfd, SIOCGIFINDEX, &ifr) == -1) {
- RTE_LOG(ERR, PMD,
- "%s: ioctl failed (SIOCGIFINDEX)\n",
+ PMD_LOG(ERR,
+ "%s: ioctl failed (SIOCGIFINDEX)",
name);
return -1;
}
@@ -610,8 +616,8 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
(*internals)->if_index = ifr.ifr_ifindex;
if (ioctl(sockfd, SIOCGIFHWADDR, &ifr) == -1) {
- RTE_LOG(ERR, PMD,
- "%s: ioctl failed (SIOCGIFHWADDR)\n",
+ PMD_LOG(ERR,
+ "%s: ioctl failed (SIOCGIFHWADDR)",
name);
return -1;
}
@@ -634,8 +640,8 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
/* Open an AF_PACKET socket for this queue... */
qsockfd = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
if (qsockfd == -1) {
- RTE_LOG(ERR, PMD,
- "%s: could not open AF_PACKET socket\n",
+ PMD_LOG(ERR,
+ "%s: could not open AF_PACKET socket",
name);
return -1;
}
@@ -644,9 +650,9 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
rc = setsockopt(qsockfd, SOL_PACKET, PACKET_VERSION,
&tpver, sizeof(tpver));
if (rc == -1) {
- RTE_LOG(ERR, PMD,
- "%s: could not set PACKET_VERSION on AF_PACKET "
- "socket for %s\n", name, pair->value);
+ PMD_LOG(ERR,
+ "%s: could not set PACKET_VERSION on AF_PACKET socket for %s",
+ name, pair->value);
goto error;
}
@@ -654,9 +660,9 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
rc = setsockopt(qsockfd, SOL_PACKET, PACKET_LOSS,
&discard, sizeof(discard));
if (rc == -1) {
- RTE_LOG(ERR, PMD,
- "%s: could not set PACKET_LOSS on "
- "AF_PACKET socket for %s\n", name, pair->value);
+ PMD_LOG(ERR,
+ "%s: could not set PACKET_LOSS on AF_PACKET socket for %s",
+ name, pair->value);
goto error;
}
@@ -664,10 +670,9 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
rc = setsockopt(qsockfd, SOL_PACKET, PACKET_QDISC_BYPASS,
&qdisc_bypass, sizeof(qdisc_bypass));
if (rc == -1) {
- RTE_LOG(ERR, PMD,
- "%s: could not set PACKET_QDISC_BYPASS "
- "on AF_PACKET socket for %s\n", name,
- pair->value);
+ PMD_LOG(ERR,
+ "%s: could not set PACKET_QDISC_BYPASS on AF_PACKET socket for %s",
+ name, pair->value);
goto error;
}
#else
@@ -676,17 +681,17 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
rc = setsockopt(qsockfd, SOL_PACKET, PACKET_RX_RING, req, sizeof(*req));
if (rc == -1) {
- RTE_LOG(ERR, PMD,
- "%s: could not set PACKET_RX_RING on AF_PACKET "
- "socket for %s\n", name, pair->value);
+ PMD_LOG(ERR,
+ "%s: could not set PACKET_RX_RING on AF_PACKET socket for %s",
+ name, pair->value);
goto error;
}
rc = setsockopt(qsockfd, SOL_PACKET, PACKET_TX_RING, req, sizeof(*req));
if (rc == -1) {
- RTE_LOG(ERR, PMD,
+ PMD_LOG(ERR,
"%s: could not set PACKET_TX_RING on AF_PACKET "
- "socket for %s\n", name, pair->value);
+ "socket for %s", name, pair->value);
goto error;
}
@@ -697,8 +702,8 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
PROT_READ | PROT_WRITE, MAP_SHARED | MAP_LOCKED,
qsockfd, 0);
if (rx_queue->map == MAP_FAILED) {
- RTE_LOG(ERR, PMD,
- "%s: call to mmap failed on AF_PACKET socket for %s\n",
+ PMD_LOG(ERR,
+ "%s: call to mmap failed on AF_PACKET socket for %s",
name, pair->value);
goto error;
}
@@ -734,8 +739,8 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
rc = bind(qsockfd, (const struct sockaddr*)&sockaddr, sizeof(sockaddr));
if (rc == -1) {
- RTE_LOG(ERR, PMD,
- "%s: could not bind AF_PACKET socket to %s\n",
+ PMD_LOG(ERR,
+ "%s: could not bind AF_PACKET socket to %s",
name, pair->value);
goto error;
}
@@ -744,9 +749,9 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
rc = setsockopt(qsockfd, SOL_PACKET, PACKET_FANOUT,
&fanout_arg, sizeof(fanout_arg));
if (rc == -1) {
- RTE_LOG(ERR, PMD,
+ PMD_LOG(ERR,
"%s: could not set PACKET_FANOUT on AF_PACKET socket "
- "for %s\n", name, pair->value);
+ "for %s", name, pair->value);
goto error;
}
#endif
@@ -826,8 +831,8 @@ rte_eth_from_packet(struct rte_vdev_device *dev,
qpairs = atoi(pair->value);
if (qpairs < 1 ||
qpairs > RTE_PMD_AF_PACKET_MAX_RINGS) {
- RTE_LOG(ERR, PMD,
- "%s: invalid qpairs value\n",
+ PMD_LOG(ERR,
+ "%s: invalid qpairs value",
name);
return -1;
}
@@ -836,8 +841,8 @@ rte_eth_from_packet(struct rte_vdev_device *dev,
if (strstr(pair->key, ETH_AF_PACKET_BLOCKSIZE_ARG) != NULL) {
blocksize = atoi(pair->value);
if (!blocksize) {
- RTE_LOG(ERR, PMD,
- "%s: invalid blocksize value\n",
+ PMD_LOG(ERR,
+ "%s: invalid blocksize value",
name);
return -1;
}
@@ -846,8 +851,8 @@ rte_eth_from_packet(struct rte_vdev_device *dev,
if (strstr(pair->key, ETH_AF_PACKET_FRAMESIZE_ARG) != NULL) {
framesize = atoi(pair->value);
if (!framesize) {
- RTE_LOG(ERR, PMD,
- "%s: invalid framesize value\n",
+ PMD_LOG(ERR,
+ "%s: invalid framesize value",
name);
return -1;
}
@@ -856,8 +861,8 @@ rte_eth_from_packet(struct rte_vdev_device *dev,
if (strstr(pair->key, ETH_AF_PACKET_FRAMECOUNT_ARG) != NULL) {
framecount = atoi(pair->value);
if (!framecount) {
- RTE_LOG(ERR, PMD,
- "%s: invalid framecount value\n",
+ PMD_LOG(ERR,
+ "%s: invalid framecount value",
name);
return -1;
}
@@ -866,8 +871,8 @@ rte_eth_from_packet(struct rte_vdev_device *dev,
if (strstr(pair->key, ETH_AF_PACKET_QDISC_BYPASS_ARG) != NULL) {
qdisc_bypass = atoi(pair->value);
if (qdisc_bypass > 1) {
- RTE_LOG(ERR, PMD,
- "%s: invalid bypass value\n",
+ PMD_LOG(ERR,
+ "%s: invalid bypass value",
name);
return -1;
}
@@ -876,24 +881,24 @@ rte_eth_from_packet(struct rte_vdev_device *dev,
}
if (framesize > blocksize) {
- RTE_LOG(ERR, PMD,
- "%s: AF_PACKET MMAP frame size exceeds block size!\n",
+ PMD_LOG(ERR,
+ "%s: AF_PACKET MMAP frame size exceeds block size!",
name);
return -1;
}
blockcount = framecount / (blocksize / framesize);
if (!blockcount) {
- RTE_LOG(ERR, PMD,
- "%s: invalid AF_PACKET MMAP parameters\n", name);
+ PMD_LOG(ERR,
+ "%s: invalid AF_PACKET MMAP parameters", name);
return -1;
}
- RTE_LOG(INFO, PMD, "%s: AF_PACKET MMAP parameters:\n", name);
- RTE_LOG(INFO, PMD, "%s:\tblock size %d\n", name, blocksize);
- RTE_LOG(INFO, PMD, "%s:\tblock count %d\n", name, blockcount);
- RTE_LOG(INFO, PMD, "%s:\tframe size %d\n", name, framesize);
- RTE_LOG(INFO, PMD, "%s:\tframe count %d\n", name, framecount);
+ PMD_LOG(INFO, "%s: AF_PACKET MMAP parameters:", name);
+ PMD_LOG(INFO, "%s:\tblock size %d", name, blocksize);
+ PMD_LOG(INFO, "%s:\tblock count %d", name, blockcount);
+ PMD_LOG(INFO, "%s:\tframe size %d", name, framesize);
+ PMD_LOG(INFO, "%s:\tframe count %d", name, framecount);
if (rte_pmd_init_internals(dev, *sockfd, qpairs,
blocksize, blockcount,
@@ -918,13 +923,13 @@ rte_pmd_af_packet_probe(struct rte_vdev_device *dev)
struct rte_eth_dev *eth_dev;
const char *name = rte_vdev_device_name(dev);
- RTE_LOG(INFO, PMD, "Initializing pmd_af_packet for %s\n", name);
+ PMD_LOG(INFO, "Initializing pmd_af_packet for %s", name);
if (rte_eal_process_type() == RTE_PROC_SECONDARY &&
strlen(rte_vdev_device_args(dev)) == 0) {
eth_dev = rte_eth_dev_attach_secondary(name);
if (!eth_dev) {
- RTE_LOG(ERR, PMD, "Failed to probe %s\n", name);
+ PMD_LOG(ERR, "Failed to probe %s", name);
return -1;
}
/* TODO: request info from primary to set up Rx and Tx */
@@ -968,8 +973,8 @@ rte_pmd_af_packet_remove(struct rte_vdev_device *dev)
struct pmd_internals *internals;
unsigned q;
- RTE_LOG(INFO, PMD, "Closing AF_PACKET ethdev on numa socket %u\n",
- rte_socket_id());
+ PMD_LOG(INFO, "Closing AF_PACKET ethdev on numa socket %u",
+ rte_socket_id());
if (dev == NULL)
return -1;
@@ -1007,3 +1012,12 @@ RTE_PMD_REGISTER_PARAM_STRING(net_af_packet,
"framesz=<int> "
"framecnt=<int> "
"qdisc_bypass=<0|1>");
+
+RTE_INIT(af_packet_init_log);
+static void
+af_packet_init_log(void)
+{
+ af_packet_logtype = rte_log_register("pmd.net.packet");
+ if (af_packet_logtype >= 0)
+ rte_log_set_level(af_packet_logtype, RTE_LOG_NOTICE);
+}
--
2.17.0
^ permalink raw reply [flat|nested] 15+ messages in thread
* [dpdk-dev] [PATCH next 03/10] net/null: convert to dynamic logging
2018-04-25 15:56 [dpdk-dev] [PATCH next 00/10] more dynamic logging Stephen Hemminger
2018-04-25 15:56 ` [dpdk-dev] [PATCH next 01/10] net/tap: convert to " Stephen Hemminger
2018-04-25 15:56 ` [dpdk-dev] [PATCH next 02/10] net/af_packet: convert to dynamic log level Stephen Hemminger
@ 2018-04-25 15:56 ` Stephen Hemminger
2018-04-25 15:56 ` [dpdk-dev] [PATCH next 04/10] net/ring: " Stephen Hemminger
` (7 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: Stephen Hemminger @ 2018-04-25 15:56 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger
Convert null device to use dynamic logging.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/null/rte_eth_null.c | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c
index 6413a9064245..571ba7952cd2 100644
--- a/drivers/net/null/rte_eth_null.c
+++ b/drivers/net/null/rte_eth_null.c
@@ -92,6 +92,12 @@ static struct rte_eth_link pmd_link = {
.link_autoneg = ETH_LINK_AUTONEG,
};
+static int eth_null_logtype;
+
+#define PMD_LOG(level, fmt, args...) \
+ rte_log(RTE_LOG_ ## level, eth_null_logtype, \
+ "%s(): " fmt "\n", __func__, ##args)
+
static uint16_t
eth_null_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)
{
@@ -509,7 +515,7 @@ eth_dev_null_create(struct rte_vdev_device *dev,
if (dev->device.numa_node == SOCKET_ID_ANY)
dev->device.numa_node = rte_socket_id();
- RTE_LOG(INFO, PMD, "Creating null ethdev on numa socket %u\n",
+ PMD_LOG(INFO, "Creating null ethdev on numa socket %u",
dev->device.numa_node);
eth_dev = rte_eth_vdev_allocate(dev, sizeof(*internals));
@@ -605,13 +611,13 @@ rte_pmd_null_probe(struct rte_vdev_device *dev)
name = rte_vdev_device_name(dev);
params = rte_vdev_device_args(dev);
- RTE_LOG(INFO, PMD, "Initializing pmd_null for %s\n", name);
+ PMD_LOG(INFO, "Initializing pmd_null for %s", name);
if (rte_eal_process_type() == RTE_PROC_SECONDARY &&
strlen(params) == 0) {
eth_dev = rte_eth_dev_attach_secondary(name);
if (!eth_dev) {
- RTE_LOG(ERR, PMD, "Failed to probe %s\n", name);
+ PMD_LOG(ERR, "Failed to probe %s", name);
return -1;
}
/* TODO: request info from primary to set up Rx and Tx */
@@ -643,8 +649,8 @@ rte_pmd_null_probe(struct rte_vdev_device *dev)
}
}
- RTE_LOG(INFO, PMD, "Configure pmd_null: packet size is %d, "
- "packet copy is %s\n", packet_size,
+ PMD_LOG(INFO, "Configure pmd_null: packet size is %d, "
+ "packet copy is %s", packet_size,
packet_copy ? "enabled" : "disabled");
ret = eth_dev_null_create(dev, packet_size, packet_copy);
@@ -663,7 +669,7 @@ rte_pmd_null_remove(struct rte_vdev_device *dev)
if (!dev)
return -EINVAL;
- RTE_LOG(INFO, PMD, "Closing null ethdev on numa socket %u\n",
+ PMD_LOG(INFO, "Closing null ethdev on numa socket %u",
rte_socket_id());
/* find the ethdev entry */
@@ -688,3 +694,12 @@ RTE_PMD_REGISTER_ALIAS(net_null, eth_null);
RTE_PMD_REGISTER_PARAM_STRING(net_null,
"size=<int> "
"copy=<int>");
+
+RTE_INIT(eth_null_init_log);
+static void
+eth_null_init_log(void)
+{
+ eth_null_logtype = rte_log_register("pmd.net.null");
+ if (eth_null_logtype >= 0)
+ rte_log_set_level(eth_null_logtype, RTE_LOG_NOTICE);
+}
--
2.17.0
^ permalink raw reply [flat|nested] 15+ messages in thread
* [dpdk-dev] [PATCH next 04/10] net/ring: convert to dynamic logging
2018-04-25 15:56 [dpdk-dev] [PATCH next 00/10] more dynamic logging Stephen Hemminger
` (2 preceding siblings ...)
2018-04-25 15:56 ` [dpdk-dev] [PATCH next 03/10] net/null: convert to dynamic logging Stephen Hemminger
@ 2018-04-25 15:56 ` Stephen Hemminger
2018-04-25 15:56 ` [dpdk-dev] [PATCH next 05/10] net/softnic: " Stephen Hemminger
` (6 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: Stephen Hemminger @ 2018-04-25 15:56 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/ring/rte_eth_ring.c | 46 ++++++++++++++++++++++-----------
1 file changed, 31 insertions(+), 15 deletions(-)
diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index e53823adb3e5..0581ab216cd4 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -63,6 +63,12 @@ static struct rte_eth_link pmd_link = {
.link_autoneg = ETH_LINK_AUTONEG
};
+static int eth_ring_logtype;
+
+#define PMD_LOG(level, fmt, args...) \
+ rte_log(RTE_LOG_ ## level, eth_ring_logtype, \
+ "%s(): " fmt "\n", __func__, ##args)
+
static uint16_t
eth_ring_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)
{
@@ -256,7 +262,7 @@ do_eth_dev_ring_create(const char *name,
void **tx_queues_local = NULL;
unsigned i;
- RTE_LOG(INFO, PMD, "Creating rings-backed ethdev on numa socket %u\n",
+ PMD_LOG(INFO, "Creating rings-backed ethdev on numa socket %u",
numa_node);
rx_queues_local = rte_zmalloc_socket(name,
@@ -446,13 +452,13 @@ static int parse_kvlist (const char *key __rte_unused, const char *value, void *
ret = -EINVAL;
if (!name) {
- RTE_LOG(WARNING, PMD, "command line parameter is empty for ring pmd!\n");
+ PMD_LOG(WARNING, "command line parameter is empty for ring pmd!");
goto out;
}
node = strchr(name, ':');
if (!node) {
- RTE_LOG(WARNING, PMD, "could not parse node value from %s\n",
+ PMD_LOG(WARNING, "could not parse node value from %s",
name);
goto out;
}
@@ -462,7 +468,7 @@ static int parse_kvlist (const char *key __rte_unused, const char *value, void *
action = strchr(node, ':');
if (!action) {
- RTE_LOG(WARNING, PMD, "could not parse action value from %s\n",
+ PMD_LOG(WARNING, "could not parse action value from %s",
node);
goto out;
}
@@ -485,7 +491,8 @@ static int parse_kvlist (const char *key __rte_unused, const char *value, void *
info->list[info->count].node = strtol(node, &end, 10);
if ((errno != 0) || (*end != '\0')) {
- RTE_LOG(WARNING, PMD, "node value %s is unparseable as a number\n", node);
+ PMD_LOG(WARNING,
+ "node value %s is unparseable as a number", node);
goto out;
}
@@ -529,14 +536,14 @@ rte_pmd_ring_probe(struct rte_vdev_device *dev)
name = rte_vdev_device_name(dev);
params = rte_vdev_device_args(dev);
- RTE_LOG(INFO, PMD, "Initializing pmd_ring for %s\n", name);
+ PMD_LOG(INFO, "Initializing pmd_ring for %s", name);
if (params == NULL || params[0] == '\0') {
ret = eth_dev_ring_create(name, rte_socket_id(), DEV_CREATE,
ð_dev);
if (ret == -1) {
- RTE_LOG(INFO, PMD,
- "Attach to pmd_ring for %s\n", name);
+ PMD_LOG(INFO,
+ "Attach to pmd_ring for %s", name);
ret = eth_dev_ring_create(name, rte_socket_id(),
DEV_ATTACH, ð_dev);
}
@@ -544,13 +551,13 @@ rte_pmd_ring_probe(struct rte_vdev_device *dev)
kvlist = rte_kvargs_parse(params, valid_arguments);
if (!kvlist) {
- RTE_LOG(INFO, PMD, "Ignoring unsupported parameters when creating"
- " rings-backed ethernet device\n");
+ PMD_LOG(INFO, "Ignoring unsupported parameters when creating"
+ " rings-backed ethernet device");
ret = eth_dev_ring_create(name, rte_socket_id(),
DEV_CREATE, ð_dev);
if (ret == -1) {
- RTE_LOG(INFO, PMD,
- "Attach to pmd_ring for %s\n",
+ PMD_LOG(INFO,
+ "Attach to pmd_ring for %s",
name);
ret = eth_dev_ring_create(name, rte_socket_id(),
DEV_ATTACH, ð_dev);
@@ -604,8 +611,8 @@ rte_pmd_ring_probe(struct rte_vdev_device *dev)
ð_dev);
if ((ret == -1) &&
(info->list[info->count].action == DEV_CREATE)) {
- RTE_LOG(INFO, PMD,
- "Attach to pmd_ring for %s\n",
+ PMD_LOG(INFO,
+ "Attach to pmd_ring for %s",
name);
ret = eth_dev_ring_create(name,
info->list[info->count].node,
@@ -634,7 +641,7 @@ rte_pmd_ring_remove(struct rte_vdev_device *dev)
struct ring_queue *r = NULL;
uint16_t i;
- RTE_LOG(INFO, PMD, "Un-Initializing pmd_ring for %s\n", name);
+ PMD_LOG(INFO, "Un-Initializing pmd_ring for %s", name);
if (name == NULL)
return -EINVAL;
@@ -675,3 +682,12 @@ RTE_PMD_REGISTER_VDEV(net_ring, pmd_ring_drv);
RTE_PMD_REGISTER_ALIAS(net_ring, eth_ring);
RTE_PMD_REGISTER_PARAM_STRING(net_ring,
ETH_RING_NUMA_NODE_ACTION_ARG "=name:node:action(ATTACH|CREATE)");
+
+RTE_INIT(eth_ring_init_log);
+static void
+eth_ring_init_log(void)
+{
+ eth_ring_logtype = rte_log_register("pmd.net.ring");
+ if (eth_ring_logtype >= 0)
+ rte_log_set_level(eth_ring_logtype, RTE_LOG_NOTICE);
+}
--
2.17.0
^ permalink raw reply [flat|nested] 15+ messages in thread
* [dpdk-dev] [PATCH next 05/10] net/softnic: convert to dynamic logging
2018-04-25 15:56 [dpdk-dev] [PATCH next 00/10] more dynamic logging Stephen Hemminger
` (3 preceding siblings ...)
2018-04-25 15:56 ` [dpdk-dev] [PATCH next 04/10] net/ring: " Stephen Hemminger
@ 2018-04-25 15:56 ` Stephen Hemminger
2018-04-25 15:56 ` [dpdk-dev] [PATCH next 06/10] net/failsafe: " Stephen Hemminger
` (5 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: Stephen Hemminger @ 2018-04-25 15:56 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/softnic/rte_eth_softnic.c | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)
diff --git a/drivers/net/softnic/rte_eth_softnic.c b/drivers/net/softnic/rte_eth_softnic.c
index e3243940cba7..9835124ad9f2 100644
--- a/drivers/net/softnic/rte_eth_softnic.c
+++ b/drivers/net/softnic/rte_eth_softnic.c
@@ -67,6 +67,12 @@ static const struct rte_eth_dev_info pmd_dev_info = {
},
};
+static int pmd_softnic_logtype;
+
+#define PMD_LOG(level, fmt, args...) \
+ rte_log(RTE_LOG_ ## level, pmd_softnic_logtype, \
+ "%s(): " fmt "\n", __func__, ##args)
+
static void
pmd_dev_infos_get(struct rte_eth_dev *dev __rte_unused,
struct rte_eth_dev_info *dev_info)
@@ -728,7 +734,7 @@ pmd_probe(struct rte_vdev_device *vdev)
struct rte_eth_dev *eth_dev;
const char *name = rte_vdev_device_name(vdev);
- RTE_LOG(INFO, PMD, "Probing device \"%s\"\n", name);
+ PMD_LOG(INFO, "Probing device \"%s\"", name);
/* Parse input arguments */
params = rte_vdev_device_args(vdev);
@@ -737,7 +743,7 @@ pmd_probe(struct rte_vdev_device *vdev)
strlen(params) == 0) {
eth_dev = rte_eth_dev_attach_secondary(name);
if (!eth_dev) {
- RTE_LOG(ERR, PMD, "Failed to probe %s\n", name);
+ PMD_LOG(ERR, "Failed to probe %s", name);
return -1;
}
/* TODO: request info from primary to set up Rx and Tx */
@@ -776,8 +782,8 @@ pmd_probe(struct rte_vdev_device *vdev)
return -ENOMEM;
/* Register soft ethdev */
- RTE_LOG(INFO, PMD,
- "Creating soft ethdev \"%s\" for hard ethdev \"%s\"\n",
+ PMD_LOG(INFO,
+ "Creating soft ethdev \"%s\" for hard ethdev \"%s\"",
p.soft.name, p.hard.name);
status = pmd_ethdev_register(vdev, &p, dev_private);
@@ -798,7 +804,7 @@ pmd_remove(struct rte_vdev_device *vdev)
if (!vdev)
return -EINVAL;
- RTE_LOG(INFO, PMD, "Removing device \"%s\"\n",
+ PMD_LOG(INFO, "Removing device \"%s\"",
rte_vdev_device_name(vdev));
/* Find the ethdev entry */
@@ -833,3 +839,12 @@ RTE_PMD_REGISTER_PARAM_STRING(net_softnic,
PMD_PARAM_SOFT_TM_DEQ_BSZ "=<int> "
PMD_PARAM_HARD_NAME "=<string> "
PMD_PARAM_HARD_TX_QUEUE_ID "=<int>");
+
+RTE_INIT(pmd_softnic_init_log);
+static void
+pmd_softnic_init_log(void)
+{
+ pmd_softnic_logtype = rte_log_register("pmd.net.softnic");
+ if (pmd_softnic_logtype >= 0)
+ rte_log_set_level(pmd_softnic_logtype, RTE_LOG_NOTICE);
+}
--
2.17.0
^ permalink raw reply [flat|nested] 15+ messages in thread
* [dpdk-dev] [PATCH next 06/10] net/failsafe: convert to dynamic logging
2018-04-25 15:56 [dpdk-dev] [PATCH next 00/10] more dynamic logging Stephen Hemminger
` (4 preceding siblings ...)
2018-04-25 15:56 ` [dpdk-dev] [PATCH next 05/10] net/softnic: " Stephen Hemminger
@ 2018-04-25 15:56 ` Stephen Hemminger
2018-04-25 15:56 ` [dpdk-dev] [PATCH next 07/10] net/kni: support " Stephen Hemminger
` (4 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: Stephen Hemminger @ 2018-04-25 15:56 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/failsafe/failsafe.c | 13 ++++++++++++-
drivers/net/failsafe/failsafe_private.h | 8 ++++++--
2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/drivers/net/failsafe/failsafe.c b/drivers/net/failsafe/failsafe.c
index dc9b0d08881d..5e7a8ba1b0dd 100644
--- a/drivers/net/failsafe/failsafe.c
+++ b/drivers/net/failsafe/failsafe.c
@@ -13,6 +13,8 @@
#include "failsafe_private.h"
+int failsafe_logtype;
+
const char pmd_failsafe_driver_name[] = FAILSAFE_DRIVER_NAME;
static const struct rte_eth_link eth_link = {
.link_speed = ETH_SPEED_NUM_10G,
@@ -304,7 +306,7 @@ rte_pmd_failsafe_probe(struct rte_vdev_device *vdev)
strlen(rte_vdev_device_args(vdev)) == 0) {
eth_dev = rte_eth_dev_attach_secondary(name);
if (!eth_dev) {
- RTE_LOG(ERR, PMD, "Failed to probe %s\n", name);
+ ERROR("Failed to probe %s", name);
return -1;
}
/* TODO: request info from primary to set up Rx and Tx */
@@ -332,3 +334,12 @@ static struct rte_vdev_driver failsafe_drv = {
RTE_PMD_REGISTER_VDEV(net_failsafe, failsafe_drv);
RTE_PMD_REGISTER_PARAM_STRING(net_failsafe, PMD_FAILSAFE_PARAM_STRING);
+
+RTE_INIT(failsafe_init_log);
+static void
+failsafe_init_log(void)
+{
+ failsafe_logtype = rte_log_register("pmd.net.failsafe");
+ if (failsafe_logtype >= 0)
+ rte_log_set_level(failsafe_logtype, RTE_LOG_NOTICE);
+}
diff --git a/drivers/net/failsafe/failsafe_private.h b/drivers/net/failsafe/failsafe_private.h
index 7db9eebe3fcc..b54f8e33671f 100644
--- a/drivers/net/failsafe/failsafe_private.h
+++ b/drivers/net/failsafe/failsafe_private.h
@@ -326,8 +326,12 @@ extern int mac_from_arg;
#define FS_THREADID_FMT "lu"
#endif
-#define LOG__(level, m, ...) \
- RTE_LOG(level, PMD, "net_failsafe: " m "%c", __VA_ARGS__)
+extern int failsafe_logtype;
+
+#define LOG__(l, m, ...) \
+ rte_log(RTE_LOG_ ## l, failsafe_logtype, \
+ "net_failsafe: " m "%c", __VA_ARGS__)
+
#define LOG_(level, ...) LOG__(level, __VA_ARGS__, '\n')
#define DEBUG(...) LOG_(DEBUG, __VA_ARGS__)
#define INFO(...) LOG_(INFO, __VA_ARGS__)
--
2.17.0
^ permalink raw reply [flat|nested] 15+ messages in thread
* [dpdk-dev] [PATCH next 07/10] net/kni: support dynamic logging
2018-04-25 15:56 [dpdk-dev] [PATCH next 00/10] more dynamic logging Stephen Hemminger
` (5 preceding siblings ...)
2018-04-25 15:56 ` [dpdk-dev] [PATCH next 06/10] net/failsafe: " Stephen Hemminger
@ 2018-04-25 15:56 ` Stephen Hemminger
2018-04-25 15:56 ` [dpdk-dev] [PATCH next 08/10] net/pcap: " Stephen Hemminger
` (3 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: Stephen Hemminger @ 2018-04-25 15:56 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/kni/rte_eth_kni.c | 34 ++++++++++++++++++++++++----------
1 file changed, 24 insertions(+), 10 deletions(-)
diff --git a/drivers/net/kni/rte_eth_kni.c b/drivers/net/kni/rte_eth_kni.c
index 35a6d3ef7280..bbb2f00c80d7 100644
--- a/drivers/net/kni/rte_eth_kni.c
+++ b/drivers/net/kni/rte_eth_kni.c
@@ -65,6 +65,11 @@ static const struct rte_eth_link pmd_link = {
};
static int is_kni_initialized;
+static int eth_kni_logtype;
+
+#define PMD_LOG(level, fmt, args...) \
+ rte_log(RTE_LOG_ ## level, eth_kni_logtype, \
+ "%s(): " fmt "\n", __func__, ##args)
static uint16_t
eth_kni_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)
{
@@ -126,8 +131,8 @@ eth_kni_start(struct rte_eth_dev *dev)
internals->kni = rte_kni_alloc(mb_pool, &conf, NULL);
if (internals->kni == NULL) {
- RTE_LOG(ERR, PMD,
- "Fail to create kni interface for port: %d\n",
+ PMD_LOG(ERR,
+ "Fail to create kni interface for port: %d",
port_id);
return -1;
}
@@ -153,8 +158,8 @@ eth_kni_dev_start(struct rte_eth_dev *dev)
"kni_handle_req", NULL,
kni_handle_request, internals);
if (ret) {
- RTE_LOG(ERR, PMD,
- "Fail to create kni request thread\n");
+ PMD_LOG(ERR,
+ "Fail to create kni request thread");
return -1;
}
}
@@ -175,11 +180,11 @@ eth_kni_dev_stop(struct rte_eth_dev *dev)
ret = pthread_cancel(internals->thread);
if (ret)
- RTE_LOG(ERR, PMD, "Can't cancel the thread\n");
+ PMD_LOG(ERR, "Can't cancel the thread");
ret = pthread_join(internals->thread, NULL);
if (ret)
- RTE_LOG(ERR, PMD, "Can't join the thread\n");
+ PMD_LOG(ERR, "Can't join the thread");
internals->stop_thread = 0;
}
@@ -338,7 +343,7 @@ eth_kni_create(struct rte_vdev_device *vdev,
struct rte_eth_dev_data *data;
struct rte_eth_dev *eth_dev;
- RTE_LOG(INFO, PMD, "Creating kni ethdev on numa socket %u\n",
+ PMD_LOG(INFO, "Creating kni ethdev on numa socket %u",
numa_node);
/* reserve an ethdev entry */
@@ -403,13 +408,13 @@ eth_kni_probe(struct rte_vdev_device *vdev)
name = rte_vdev_device_name(vdev);
params = rte_vdev_device_args(vdev);
- RTE_LOG(INFO, PMD, "Initializing eth_kni for %s\n", name);
+ PMD_LOG(INFO, "Initializing eth_kni for %s", name);
if (rte_eal_process_type() == RTE_PROC_SECONDARY &&
strlen(params) == 0) {
eth_dev = rte_eth_dev_attach_secondary(name);
if (!eth_dev) {
- RTE_LOG(ERR, PMD, "Failed to probe %s\n", name);
+ PMD_LOG(ERR, "Failed to probe %s", name);
return -1;
}
/* TODO: request info from primary to set up Rx and Tx */
@@ -449,7 +454,7 @@ eth_kni_remove(struct rte_vdev_device *vdev)
const char *name;
name = rte_vdev_device_name(vdev);
- RTE_LOG(INFO, PMD, "Un-Initializing eth_kni for %s\n", name);
+ PMD_LOG(INFO, "Un-Initializing eth_kni for %s", name);
/* find the ethdev entry */
eth_dev = rte_eth_dev_allocated(name);
@@ -479,3 +484,12 @@ static struct rte_vdev_driver eth_kni_drv = {
RTE_PMD_REGISTER_VDEV(net_kni, eth_kni_drv);
RTE_PMD_REGISTER_PARAM_STRING(net_kni, ETH_KNI_NO_REQUEST_THREAD_ARG "=<int>");
+
+RTE_INIT(eth_kni_init_log);
+static void
+eth_kni_init_log(void)
+{
+ eth_kni_logtype = rte_log_register("pmd.net.kni");
+ if (eth_kni_logtype >= 0)
+ rte_log_set_level(eth_kni_logtype, RTE_LOG_NOTICE);
+}
--
2.17.0
^ permalink raw reply [flat|nested] 15+ messages in thread
* [dpdk-dev] [PATCH next 08/10] net/pcap: support dynamic logging
2018-04-25 15:56 [dpdk-dev] [PATCH next 00/10] more dynamic logging Stephen Hemminger
` (6 preceding siblings ...)
2018-04-25 15:56 ` [dpdk-dev] [PATCH next 07/10] net/kni: support " Stephen Hemminger
@ 2018-04-25 15:56 ` Stephen Hemminger
2018-04-25 15:56 ` [dpdk-dev] [PATCH next 09/10] net/vhost: implement " Stephen Hemminger
` (2 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: Stephen Hemminger @ 2018-04-25 15:56 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/pcap/rte_eth_pcap.c | 41 ++++++++++++++++++++++-----------
1 file changed, 28 insertions(+), 13 deletions(-)
diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c
index 570c9e984d32..4ef28a4995d2 100644
--- a/drivers/net/pcap/rte_eth_pcap.c
+++ b/drivers/net/pcap/rte_eth_pcap.c
@@ -99,6 +99,12 @@ static struct rte_eth_link pmd_link = {
.link_autoneg = ETH_LINK_AUTONEG,
};
+static int eth_pcap_logtype;
+
+#define PMD_LOG(level, fmt, args...) \
+ rte_log(RTE_LOG_ ## level, eth_pcap_logtype, \
+ "%s(): " fmt "\n", __func__, ##args)
+
static int
eth_pcap_rx_jumbo(struct rte_mempool *mb_pool, struct rte_mbuf *mbuf,
const u_char *data, uint16_t data_len)
@@ -256,8 +262,8 @@ eth_pcap_tx_dumper(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
pcap_dump((u_char *)dumper_q->dumper, &header,
tx_pcap_data);
} else {
- RTE_LOG(ERR, PMD,
- "Dropping PCAP packet. Size (%d) > max jumbo size (%d).\n",
+ PMD_LOG(ERR,
+ "Dropping PCAP packet. Size (%d) > max jumbo size (%d).",
mbuf->pkt_len,
ETHER_MAX_JUMBO_FRAME_LEN);
@@ -313,8 +319,8 @@ eth_pcap_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
ret = pcap_sendpacket(tx_queue->pcap,
tx_pcap_data, mbuf->pkt_len);
} else {
- RTE_LOG(ERR, PMD,
- "Dropping PCAP packet. Size (%d) > max jumbo size (%d).\n",
+ PMD_LOG(ERR,
+ "Dropping PCAP packet. Size (%d) > max jumbo size (%d).",
mbuf->pkt_len,
ETHER_MAX_JUMBO_FRAME_LEN);
@@ -346,7 +352,7 @@ open_iface_live(const char *iface, pcap_t **pcap) {
RTE_ETH_PCAP_PROMISC, RTE_ETH_PCAP_TIMEOUT, errbuf);
if (*pcap == NULL) {
- RTE_LOG(ERR, PMD, "Couldn't open %s: %s\n", iface, errbuf);
+ PMD_LOG(ERR, "Couldn't open %s: %s", iface, errbuf);
return -1;
}
@@ -357,7 +363,7 @@ static int
open_single_iface(const char *iface, pcap_t **pcap)
{
if (open_iface_live(iface, pcap) < 0) {
- RTE_LOG(ERR, PMD, "Couldn't open interface %s\n", iface);
+ PMD_LOG(ERR, "Couldn't open interface %s", iface);
return -1;
}
@@ -376,7 +382,7 @@ open_single_tx_pcap(const char *pcap_filename, pcap_dumper_t **dumper)
*/
tx_pcap = pcap_open_dead(DLT_EN10MB, RTE_ETH_PCAP_SNAPSHOT_LEN);
if (tx_pcap == NULL) {
- RTE_LOG(ERR, PMD, "Couldn't create dead pcap\n");
+ PMD_LOG(ERR, "Couldn't create dead pcap");
return -1;
}
@@ -384,7 +390,7 @@ open_single_tx_pcap(const char *pcap_filename, pcap_dumper_t **dumper)
*dumper = pcap_dump_open(tx_pcap, pcap_filename);
if (*dumper == NULL) {
pcap_close(tx_pcap);
- RTE_LOG(ERR, PMD, "Couldn't open %s for writing.\n",
+ PMD_LOG(ERR, "Couldn't open %s for writing.",
pcap_filename);
return -1;
}
@@ -398,7 +404,7 @@ open_single_rx_pcap(const char *pcap_filename, pcap_t **pcap)
{
*pcap = pcap_open_offline(pcap_filename, errbuf);
if (*pcap == NULL) {
- RTE_LOG(ERR, PMD, "Couldn't open %s: %s\n", pcap_filename,
+ PMD_LOG(ERR, "Couldn't open %s: %s", pcap_filename,
errbuf);
return -1;
}
@@ -776,7 +782,7 @@ pmd_init_internals(struct rte_vdev_device *vdev,
struct rte_eth_dev_data *data;
unsigned int numa_node = vdev->device.numa_node;
- RTE_LOG(INFO, PMD, "Creating pcap-backed ethdev on numa socket %d\n",
+ PMD_LOG(INFO, "Creating pcap-backed ethdev on numa socket %d",
numa_node);
/* reserve an ethdev entry */
@@ -903,7 +909,7 @@ pmd_pcap_probe(struct rte_vdev_device *dev)
int ret;
name = rte_vdev_device_name(dev);
- RTE_LOG(INFO, PMD, "Initializing pmd_pcap for %s\n", name);
+ PMD_LOG(INFO, "Initializing pmd_pcap for %s", name);
gettimeofday(&start_time, NULL);
start_cycles = rte_get_timer_cycles();
@@ -913,7 +919,7 @@ pmd_pcap_probe(struct rte_vdev_device *dev)
strlen(rte_vdev_device_args(dev)) == 0) {
eth_dev = rte_eth_dev_attach_secondary(name);
if (!eth_dev) {
- RTE_LOG(ERR, PMD, "Failed to probe %s\n", name);
+ PMD_LOG(ERR, "Failed to probe %s", name);
return -1;
}
/* TODO: request info from primary to set up Rx and Tx */
@@ -1009,7 +1015,7 @@ pmd_pcap_remove(struct rte_vdev_device *dev)
{
struct rte_eth_dev *eth_dev = NULL;
- RTE_LOG(INFO, PMD, "Closing pcap ethdev on numa socket %d\n",
+ PMD_LOG(INFO, "Closing pcap ethdev on numa socket %d",
rte_socket_id());
if (!dev)
@@ -1040,3 +1046,12 @@ RTE_PMD_REGISTER_PARAM_STRING(net_pcap,
ETH_PCAP_RX_IFACE_ARG "=<ifc> "
ETH_PCAP_TX_IFACE_ARG "=<ifc> "
ETH_PCAP_IFACE_ARG "=<ifc>");
+
+RTE_INIT(eth_pcap_init_log);
+static void
+eth_pcap_init_log(void)
+{
+ eth_pcap_logtype = rte_log_register("pmd.net.pcap");
+ if (eth_pcap_logtype >= 0)
+ rte_log_set_level(eth_pcap_logtype, RTE_LOG_NOTICE);
+}
--
2.17.0
^ permalink raw reply [flat|nested] 15+ messages in thread
* [dpdk-dev] [PATCH next 09/10] net/vhost: implement dynamic logging
2018-04-25 15:56 [dpdk-dev] [PATCH next 00/10] more dynamic logging Stephen Hemminger
` (7 preceding siblings ...)
2018-04-25 15:56 ` [dpdk-dev] [PATCH next 08/10] net/pcap: " Stephen Hemminger
@ 2018-04-25 15:56 ` Stephen Hemminger
2018-04-25 15:56 ` [dpdk-dev] [PATCH next 10/10] net/bond: convert to " Stephen Hemminger
2018-04-26 23:42 ` [dpdk-dev] [PATCH next 00/10] more " Ferruh Yigit
10 siblings, 0 replies; 15+ messages in thread
From: Stephen Hemminger @ 2018-04-25 15:56 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger
Use dynamic log type (instead of PMD) in vhost.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/vhost/rte_eth_vhost.c | 82 ++++++++++++++++++-------------
1 file changed, 48 insertions(+), 34 deletions(-)
diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
index 99a7727a39c0..23231719984d 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c
@@ -46,6 +46,11 @@
#include "rte_eth_vhost.h"
+static int vhost_logtype;
+
+#define VHOST_LOG(level, ...) \
+ rte_log(RTE_LOG_ ## level, vhost_logtype, __VA_ARGS__)
+
enum {VIRTIO_RXQ, VIRTIO_TXQ, VIRTIO_QNUM};
#define ETH_VHOST_IFACE_ARG "iface"
@@ -518,7 +523,7 @@ eth_dev_configure(struct rte_eth_dev *dev __rte_unused)
internal->vlan_strip = rxmode->hw_vlan_strip;
if (rxmode->hw_vlan_filter)
- RTE_LOG(WARNING, PMD,
+ VHOST_LOG(WARNING,
"vhost(%s): vlan filtering not available\n",
internal->dev_name);
@@ -562,16 +567,16 @@ eth_rxq_intr_enable(struct rte_eth_dev *dev, uint16_t qid)
vq = dev->data->rx_queues[qid];
if (!vq) {
- RTE_LOG(ERR, PMD, "rxq%d is not setup yet\n", qid);
+ VHOST_LOG(ERR, "rxq%d is not setup yet\n", qid);
return -1;
}
ret = rte_vhost_get_vhost_vring(vq->vid, (qid << 1) + 1, &vring);
if (ret < 0) {
- RTE_LOG(ERR, PMD, "Failed to get rxq%d's vring\n", qid);
+ VHOST_LOG(ERR, "Failed to get rxq%d's vring\n", qid);
return ret;
}
- RTE_LOG(INFO, PMD, "Enable interrupt for rxq%d\n", qid);
+ VHOST_LOG(INFO, "Enable interrupt for rxq%d\n", qid);
rte_vhost_enable_guest_notification(vq->vid, (qid << 1) + 1, 1);
rte_wmb();
@@ -587,16 +592,16 @@ eth_rxq_intr_disable(struct rte_eth_dev *dev, uint16_t qid)
vq = dev->data->rx_queues[qid];
if (!vq) {
- RTE_LOG(ERR, PMD, "rxq%d is not setup yet\n", qid);
+ VHOST_LOG(ERR, "rxq%d is not setup yet\n", qid);
return -1;
}
ret = rte_vhost_get_vhost_vring(vq->vid, (qid << 1) + 1, &vring);
if (ret < 0) {
- RTE_LOG(ERR, PMD, "Failed to get rxq%d's vring", qid);
+ VHOST_LOG(ERR, "Failed to get rxq%d's vring", qid);
return ret;
}
- RTE_LOG(INFO, PMD, "Disable interrupt for rxq%d\n", qid);
+ VHOST_LOG(INFO, "Disable interrupt for rxq%d\n", qid);
rte_vhost_enable_guest_notification(vq->vid, (qid << 1) + 1, 0);
rte_wmb();
@@ -633,7 +638,7 @@ eth_vhost_install_intr(struct rte_eth_dev *dev)
dev->intr_handle = malloc(sizeof(*dev->intr_handle));
if (!dev->intr_handle) {
- RTE_LOG(ERR, PMD, "Fail to allocate intr_handle\n");
+ VHOST_LOG(ERR, "Fail to allocate intr_handle\n");
return -ENOMEM;
}
memset(dev->intr_handle, 0, sizeof(*dev->intr_handle));
@@ -644,36 +649,36 @@ eth_vhost_install_intr(struct rte_eth_dev *dev)
malloc(nb_rxq * sizeof(dev->intr_handle->intr_vec[0]));
if (!dev->intr_handle->intr_vec) {
- RTE_LOG(ERR, PMD,
+ VHOST_LOG(ERR,
"Failed to allocate memory for interrupt vector\n");
free(dev->intr_handle);
return -ENOMEM;
}
- RTE_LOG(INFO, PMD, "Prepare intr vec\n");
+ VHOST_LOG(INFO, "Prepare intr vec\n");
for (i = 0; i < nb_rxq; i++) {
vq = dev->data->rx_queues[i];
if (!vq) {
- RTE_LOG(INFO, PMD, "rxq-%d not setup yet, skip!\n", i);
+ VHOST_LOG(INFO, "rxq-%d not setup yet, skip!\n", i);
continue;
}
ret = rte_vhost_get_vhost_vring(vq->vid, (i << 1) + 1, &vring);
if (ret < 0) {
- RTE_LOG(INFO, PMD,
+ VHOST_LOG(INFO,
"Failed to get rxq-%d's vring, skip!\n", i);
continue;
}
if (vring.kickfd < 0) {
- RTE_LOG(INFO, PMD,
+ VHOST_LOG(INFO,
"rxq-%d's kickfd is invalid, skip!\n", i);
continue;
}
dev->intr_handle->intr_vec[i] = RTE_INTR_VEC_RXTX_OFFSET + i;
dev->intr_handle->efds[i] = vring.kickfd;
count++;
- RTE_LOG(INFO, PMD, "Installed intr vec for rxq-%d\n", i);
+ VHOST_LOG(INFO, "Installed intr vec for rxq-%d\n", i);
}
dev->intr_handle->nb_efd = count;
@@ -758,7 +763,7 @@ new_device(int vid)
rte_vhost_get_ifname(vid, ifname, sizeof(ifname));
list = find_internal_resource(ifname);
if (list == NULL) {
- RTE_LOG(INFO, PMD, "Invalid device name: %s\n", ifname);
+ VHOST_LOG(INFO, "Invalid device name: %s\n", ifname);
return -1;
}
@@ -778,13 +783,13 @@ new_device(int vid)
if (dev_conf->intr_conf.rxq) {
if (eth_vhost_install_intr(eth_dev) < 0) {
- RTE_LOG(INFO, PMD,
+ VHOST_LOG(INFO,
"Failed to install interrupt handler.");
return -1;
}
}
} else {
- RTE_LOG(INFO, PMD, "RX/TX queues not exist yet\n");
+ VHOST_LOG(INFO, "RX/TX queues not exist yet\n");
}
for (i = 0; i < rte_vhost_get_vring_num(vid); i++)
@@ -797,7 +802,7 @@ new_device(int vid)
rte_atomic32_set(&internal->dev_attached, 1);
update_queuing_status(eth_dev);
- RTE_LOG(INFO, PMD, "Vhost device %d created\n", vid);
+ VHOST_LOG(INFO, "Vhost device %d created\n", vid);
_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_INTR_LSC, NULL);
@@ -818,7 +823,7 @@ destroy_device(int vid)
rte_vhost_get_ifname(vid, ifname, sizeof(ifname));
list = find_internal_resource(ifname);
if (list == NULL) {
- RTE_LOG(ERR, PMD, "Invalid interface name: %s\n", ifname);
+ VHOST_LOG(ERR, "Invalid interface name: %s\n", ifname);
return;
}
eth_dev = list->eth_dev;
@@ -853,7 +858,7 @@ destroy_device(int vid)
state->max_vring = 0;
rte_spinlock_unlock(&state->lock);
- RTE_LOG(INFO, PMD, "Vhost device %d destroyed\n", vid);
+ VHOST_LOG(INFO, "Vhost device %d destroyed\n", vid);
eth_vhost_uninstall_intr(eth_dev);
_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_INTR_LSC, NULL);
@@ -870,7 +875,7 @@ vring_state_changed(int vid, uint16_t vring, int enable)
rte_vhost_get_ifname(vid, ifname, sizeof(ifname));
list = find_internal_resource(ifname);
if (list == NULL) {
- RTE_LOG(ERR, PMD, "Invalid interface name: %s\n", ifname);
+ VHOST_LOG(ERR, "Invalid interface name: %s\n", ifname);
return -1;
}
@@ -882,7 +887,7 @@ vring_state_changed(int vid, uint16_t vring, int enable)
state->max_vring = RTE_MAX(vring, state->max_vring);
rte_spinlock_unlock(&state->lock);
- RTE_LOG(INFO, PMD, "vring%u is %s\n",
+ VHOST_LOG(INFO, "vring%u is %s\n",
vring, enable ? "enabled" : "disabled");
_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_QUEUE_STATE, NULL);
@@ -905,13 +910,13 @@ rte_eth_vhost_get_queue_event(uint16_t port_id,
int idx;
if (port_id >= RTE_MAX_ETHPORTS) {
- RTE_LOG(ERR, PMD, "Invalid port id\n");
+ VHOST_LOG(ERR, "Invalid port id\n");
return -1;
}
state = vring_states[port_id];
if (!state) {
- RTE_LOG(ERR, PMD, "Unused port\n");
+ VHOST_LOG(ERR, "Unused port\n");
return -1;
}
@@ -973,7 +978,7 @@ eth_dev_start(struct rte_eth_dev *eth_dev)
if (rte_atomic32_read(&internal->dev_attached) == 1) {
if (dev_conf->intr_conf.rxq) {
if (eth_vhost_install_intr(eth_dev) < 0) {
- RTE_LOG(INFO, PMD,
+ VHOST_LOG(INFO,
"Failed to install interrupt handler.");
return -1;
}
@@ -1047,7 +1052,7 @@ eth_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
vq = rte_zmalloc_socket(NULL, sizeof(struct vhost_queue),
RTE_CACHE_LINE_SIZE, socket_id);
if (vq == NULL) {
- RTE_LOG(ERR, PMD, "Failed to allocate memory for rx queue\n");
+ VHOST_LOG(ERR, "Failed to allocate memory for rx queue\n");
return -ENOMEM;
}
@@ -1069,7 +1074,7 @@ eth_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
vq = rte_zmalloc_socket(NULL, sizeof(struct vhost_queue),
RTE_CACHE_LINE_SIZE, socket_id);
if (vq == NULL) {
- RTE_LOG(ERR, PMD, "Failed to allocate memory for tx queue\n");
+ VHOST_LOG(ERR, "Failed to allocate memory for tx queue\n");
return -ENOMEM;
}
@@ -1087,7 +1092,7 @@ eth_dev_info(struct rte_eth_dev *dev,
internal = dev->data->dev_private;
if (internal == NULL) {
- RTE_LOG(ERR, PMD, "Invalid device specified\n");
+ VHOST_LOG(ERR, "Invalid device specified\n");
return;
}
@@ -1234,7 +1239,7 @@ eth_dev_vhost_create(struct rte_vdev_device *dev, char *iface_name,
struct rte_vhost_vring_state *vring_state = NULL;
struct internal_list *list = NULL;
- RTE_LOG(INFO, PMD, "Creating VHOST-USER backend on numa socket %u\n",
+ VHOST_LOG(INFO, "Creating VHOST-USER backend on numa socket %u\n",
numa_node);
list = rte_zmalloc_socket(name, sizeof(*list), 0, numa_node);
@@ -1296,12 +1301,12 @@ eth_dev_vhost_create(struct rte_vdev_device *dev, char *iface_name,
goto error;
if (rte_vhost_driver_callback_register(iface_name, &vhost_ops) < 0) {
- RTE_LOG(ERR, PMD, "Can't register callbacks\n");
+ VHOST_LOG(ERR, "Can't register callbacks\n");
goto error;
}
if (rte_vhost_driver_start(iface_name) < 0) {
- RTE_LOG(ERR, PMD, "Failed to start driver for %s\n",
+ VHOST_LOG(ERR, "Failed to start driver for %s\n",
iface_name);
goto error;
}
@@ -1365,13 +1370,13 @@ rte_pmd_vhost_probe(struct rte_vdev_device *dev)
struct rte_eth_dev *eth_dev;
const char *name = rte_vdev_device_name(dev);
- RTE_LOG(INFO, PMD, "Initializing pmd_vhost for %s\n", name);
+ VHOST_LOG(INFO, "Initializing pmd_vhost for %s\n", name);
if (rte_eal_process_type() == RTE_PROC_SECONDARY &&
strlen(rte_vdev_device_args(dev)) == 0) {
eth_dev = rte_eth_dev_attach_secondary(name);
if (!eth_dev) {
- RTE_LOG(ERR, PMD, "Failed to probe %s\n", name);
+ VHOST_LOG(ERR, "Failed to probe %s\n", name);
return -1;
}
/* TODO: request info from primary to set up Rx and Tx */
@@ -1450,7 +1455,7 @@ rte_pmd_vhost_remove(struct rte_vdev_device *dev)
struct rte_eth_dev *eth_dev = NULL;
name = rte_vdev_device_name(dev);
- RTE_LOG(INFO, PMD, "Un-Initializing pmd_vhost for %s\n", name);
+ VHOST_LOG(INFO, "Un-Initializing pmd_vhost for %s\n", name);
/* find an ethdev entry */
eth_dev = rte_eth_dev_allocated(name);
@@ -1477,3 +1482,12 @@ RTE_PMD_REGISTER_ALIAS(net_vhost, eth_vhost);
RTE_PMD_REGISTER_PARAM_STRING(net_vhost,
"iface=<ifc> "
"queues=<int>");
+
+RTE_INIT(vhost_init_log);
+static void
+vhost_init_log(void)
+{
+ vhost_logtype = rte_log_register("pmd.net.vhost");
+ if (vhost_logtype >= 0)
+ rte_log_set_level(vhost_logtype, RTE_LOG_NOTICE);
+}
--
2.17.0
^ permalink raw reply [flat|nested] 15+ messages in thread
* [dpdk-dev] [PATCH next 10/10] net/bond: convert to dynamic logging
2018-04-25 15:56 [dpdk-dev] [PATCH next 00/10] more dynamic logging Stephen Hemminger
` (8 preceding siblings ...)
2018-04-25 15:56 ` [dpdk-dev] [PATCH next 09/10] net/vhost: implement " Stephen Hemminger
@ 2018-04-25 15:56 ` Stephen Hemminger
2018-04-26 23:41 ` Ferruh Yigit
2018-04-26 23:42 ` [dpdk-dev] [PATCH next 00/10] more " Ferruh Yigit
10 siblings, 1 reply; 15+ messages in thread
From: Stephen Hemminger @ 2018-04-25 15:56 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/bonding/rte_eth_bond_8023ad.c | 126 +++++----
drivers/net/bonding/rte_eth_bond_alb.c | 4 +-
drivers/net/bonding/rte_eth_bond_args.c | 5 +-
drivers/net/bonding/rte_eth_bond_pmd.c | 303 ++++++++++-----------
drivers/net/bonding/rte_eth_bond_private.h | 5 +-
5 files changed, 227 insertions(+), 216 deletions(-)
diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c b/drivers/net/bonding/rte_eth_bond_8023ad.c
index c452318ff63b..f8cea4b6dbf3 100644
--- a/drivers/net/bonding/rte_eth_bond_8023ad.c
+++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
@@ -16,9 +16,12 @@
static void bond_mode_8023ad_ext_periodic_cb(void *arg);
#ifdef RTE_LIBRTE_BOND_DEBUG_8023AD
-#define MODE4_DEBUG(fmt, ...) RTE_LOG(DEBUG, PMD, "%6u [Port %u: %s] " fmt, \
- bond_dbg_get_time_diff_ms(), slave_id, \
- __func__, ##__VA_ARGS__)
+
+#define MODE4_DEBUG(fmt, ...) \
+ rte_log(RTE_LOG_DEBUG, bond_logtype, \
+ "%6u [Port %u: %s] " fmt, \
+ bond_dbg_get_time_diff_ms(), slave_id, \
+ __func__, ##__VA_ARGS__)
static uint64_t start_time;
@@ -77,44 +80,46 @@ bond_print_lacp(struct lacpdu *l)
if (p_len && p_state[p_len-1] == ' ')
p_state[p_len-1] = '\0';
- RTE_LOG(DEBUG, PMD, "LACP: {\n"\
- " subtype= %02X\n"\
- " ver_num=%02X\n"\
- " actor={ tlv=%02X, len=%02X\n"\
- " pri=%04X, system=%s, key=%04X, p_pri=%04X p_num=%04X\n"\
- " state={ %s }\n"\
- " }\n"\
- " partner={ tlv=%02X, len=%02X\n"\
- " pri=%04X, system=%s, key=%04X, p_pri=%04X p_num=%04X\n"\
- " state={ %s }\n"\
- " }\n"\
- " collector={info=%02X, length=%02X, max_delay=%04X\n, " \
- "type_term=%02X, terminator_length = %02X}\n",\
- l->subtype,\
- l->version_number,\
- l->actor.tlv_type_info,\
- l->actor.info_length,\
- l->actor.port_params.system_priority,\
- a_address,\
- l->actor.port_params.key,\
- l->actor.port_params.port_priority,\
- l->actor.port_params.port_number,\
- a_state,\
- l->partner.tlv_type_info,\
- l->partner.info_length,\
- l->partner.port_params.system_priority,\
- p_address,\
- l->partner.port_params.key,\
- l->partner.port_params.port_priority,\
- l->partner.port_params.port_number,\
- p_state,\
- l->tlv_type_collector_info,\
- l->collector_info_length,\
- l->collector_max_delay,\
- l->tlv_type_terminator,\
- l->terminator_length);
+ RTE_BOND_LOG(DEBUG,
+ "LACP: {\n"
+ " subtype= %02X\n"
+ " ver_num=%02X\n"
+ " actor={ tlv=%02X, len=%02X\n"
+ " pri=%04X, system=%s, key=%04X, p_pri=%04X p_num=%04X\n"
+ " state={ %s }\n"
+ " }\n"
+ " partner={ tlv=%02X, len=%02X\n"
+ " pri=%04X, system=%s, key=%04X, p_pri=%04X p_num=%04X\n"
+ " state={ %s }\n"
+ " }\n"
+ " collector={info=%02X, length=%02X, max_delay=%04X\n, "
+ "type_term=%02X, terminator_length = %02X }",
+ l->subtype,
+ l->version_number,
+ l->actor.tlv_type_info,
+ l->actor.info_length,
+ l->actor.port_params.system_priority,
+ a_address,
+ l->actor.port_params.key,
+ l->actor.port_params.port_priority,
+ l->actor.port_params.port_number,
+ a_state,
+ l->partner.tlv_type_info,
+ l->partner.info_length,
+ l->partner.port_params.system_priority,
+ p_address,
+ l->partner.port_params.key,
+ l->partner.port_params.port_priority,
+ l->partner.port_params.port_number,
+ p_state,
+ l->tlv_type_collector_info,
+ l->collector_info_length,
+ l->collector_max_delay,
+ l->tlv_type_terminator,
+ l->terminator_length);
}
+
#define BOND_PRINT_LACP(lacpdu) bond_print_lacp(lacpdu)
#else
#define BOND_PRINT_LACP(lacpdu) do { } while (0)
@@ -200,31 +205,34 @@ show_warnings(uint16_t slave_id)
rte_get_tsc_hz() / 1000);
if (warnings & WRN_RX_QUEUE_FULL) {
- RTE_LOG(DEBUG, PMD,
- "Slave %u: failed to enqueue LACP packet into RX ring.\n"
- "Receive and transmit functions must be invoked on bonded\n"
- "interface at least 10 times per second or LACP will not\n"
- "work correctly\n", slave_id);
+ RTE_BOND_LOG(DEBUG,
+ "Slave %u: failed to enqueue LACP packet into RX ring.\n"
+ "Receive and transmit functions must be invoked on bonded"
+ "interface at least 10 times per second or LACP will notwork correctly",
+ slave_id);
}
if (warnings & WRN_TX_QUEUE_FULL) {
- RTE_LOG(DEBUG, PMD,
- "Slave %u: failed to enqueue LACP packet into TX ring.\n"
- "Receive and transmit functions must be invoked on bonded\n"
- "interface at least 10 times per second or LACP will not\n"
- "work correctly\n", slave_id);
+ RTE_BOND_LOG(DEBUG,
+ "Slave %u: failed to enqueue LACP packet into TX ring.\n"
+ "Receive and transmit functions must be invoked on bonded"
+ "interface at least 10 times per second or LACP will not work correctly",
+ slave_id);
}
if (warnings & WRN_RX_MARKER_TO_FAST)
- RTE_LOG(INFO, PMD, "Slave %u: marker to early - ignoring.\n", slave_id);
+ RTE_BOND_LOG(INFO, "Slave %u: marker to early - ignoring.",
+ slave_id);
if (warnings & WRN_UNKNOWN_SLOW_TYPE) {
- RTE_LOG(INFO, PMD,
- "Slave %u: ignoring unknown slow protocol frame type", slave_id);
+ RTE_BOND_LOG(INFO,
+ "Slave %u: ignoring unknown slow protocol frame type",
+ slave_id);
}
if (warnings & WRN_UNKNOWN_MARKER_TYPE)
- RTE_LOG(INFO, PMD, "Slave %u: ignoring unknown marker type", slave_id);
+ RTE_BOND_LOG(INFO, "Slave %u: ignoring unknown marker type",
+ slave_id);
if (warnings & WRN_NOT_LACP_CAPABLE)
MODE4_DEBUG("Port %u is not LACP capable!\n", slave_id);
@@ -507,8 +515,8 @@ mux_machine(struct bond_dev_private *internals, uint16_t slave_id)
ACTOR_STATE_SET(port, DISTRIBUTING);
SM_FLAG_SET(port, NTT);
MODE4_DEBUG("COLLECTING -> DISTRIBUTING\n");
- RTE_LOG(INFO, PMD,
- "Bond %u: slave id %u distributing started.\n",
+ RTE_BOND_LOG(INFO,
+ "Bond %u: slave id %u distributing started.",
internals->port_id, slave_id);
}
} else {
@@ -518,8 +526,8 @@ mux_machine(struct bond_dev_private *internals, uint16_t slave_id)
ACTOR_STATE_CLR(port, DISTRIBUTING);
SM_FLAG_SET(port, NTT);
MODE4_DEBUG("DISTRIBUTING -> COLLECTING\n");
- RTE_LOG(INFO, PMD,
- "Bond %u: slave id %u distributing stopped.\n",
+ RTE_BOND_LOG(INFO,
+ "Bond %u: slave id %u distributing stopped.",
internals->port_id, slave_id);
}
}
@@ -557,7 +565,7 @@ tx_machine(struct bond_dev_private *internals, uint16_t slave_id)
lacp_pkt = rte_pktmbuf_alloc(port->mbuf_pool);
if (lacp_pkt == NULL) {
- RTE_LOG(ERR, PMD, "Failed to allocate LACP packet from pool\n");
+ RTE_BOND_LOG(ERR, "Failed to allocate LACP packet from pool");
return;
}
@@ -1337,7 +1345,7 @@ bond_8023ad_setup_validate(uint16_t port_id,
conf->tx_period_ms == 0 ||
conf->rx_marker_period_ms == 0 ||
conf->update_timeout_ms == 0) {
- RTE_LOG(ERR, PMD, "given mode 4 configuration is invalid\n");
+ RTE_BOND_LOG(ERR, "given mode 4 configuration is invalid");
return -EINVAL;
}
}
diff --git a/drivers/net/bonding/rte_eth_bond_alb.c b/drivers/net/bonding/rte_eth_bond_alb.c
index 3f9945b32893..c3891c7e3762 100644
--- a/drivers/net/bonding/rte_eth_bond_alb.c
+++ b/drivers/net/bonding/rte_eth_bond_alb.c
@@ -60,8 +60,8 @@ bond_mode_alb_enable(struct rte_eth_dev *bond_dev)
0, data_size, socket_id);
if (internals->mode6.mempool == NULL) {
- RTE_LOG(ERR, PMD, "%s: Failed to initialize ALB mempool.\n",
- bond_dev->device->name);
+ RTE_BOND_LOG(ERR, "%s: Failed to initialize ALB mempool.\n",
+ bond_dev->device->name);
goto mempool_alloc_error;
}
}
diff --git a/drivers/net/bonding/rte_eth_bond_args.c b/drivers/net/bonding/rte_eth_bond_args.c
index eb205c8bb2e2..b60fde6a86c2 100644
--- a/drivers/net/bonding/rte_eth_bond_args.c
+++ b/drivers/net/bonding/rte_eth_bond_args.c
@@ -92,7 +92,7 @@ parse_port_id(const char *port_str)
if (pci_bus->parse(port_str, &dev_addr) == 0) {
dev = pci_bus->find_device(NULL, bond_pci_addr_cmp, &dev_addr);
if (dev == NULL) {
- RTE_LOG(ERR, PMD, "unable to find PCI device\n");
+ RTE_BOND_LOG(ERR, "unable to find PCI device");
return -1;
}
port_id = find_port_id_by_pci_addr(&dev_addr);
@@ -134,7 +134,8 @@ bond_ethdev_parse_slave_port_kvarg(const char *key,
if (strcmp(key, PMD_BOND_SLAVE_PORT_KVARG) == 0) {
int port_id = parse_port_id(value);
if (port_id < 0) {
- RTE_BOND_LOG(ERR, "Invalid slave port value (%s) specified", value);
+ RTE_BOND_LOG(ERR, "Invalid slave port value (%s) specified",
+ value);
return -1;
} else
slave_ports->slaves[slave_ports->slave_count++] =
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index 09696ea3f88c..cde0d94b1d43 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -571,34 +571,21 @@ update_client_stats(uint32_t addr, uint16_t port, uint32_t *TXorRXindicator)
}
#ifdef RTE_LIBRTE_BOND_DEBUG_ALB
-#define MODE6_DEBUG(info, src_ip, dst_ip, eth_h, arp_op, port, burstnumber) \
- RTE_LOG(DEBUG, PMD, \
- "%s " \
- "port:%d " \
- "SrcMAC:%02X:%02X:%02X:%02X:%02X:%02X " \
- "SrcIP:%s " \
- "DstMAC:%02X:%02X:%02X:%02X:%02X:%02X " \
- "DstIP:%s " \
- "%s " \
- "%d\n", \
- info, \
- port, \
- eth_h->s_addr.addr_bytes[0], \
- eth_h->s_addr.addr_bytes[1], \
- eth_h->s_addr.addr_bytes[2], \
- eth_h->s_addr.addr_bytes[3], \
- eth_h->s_addr.addr_bytes[4], \
- eth_h->s_addr.addr_bytes[5], \
- src_ip, \
- eth_h->d_addr.addr_bytes[0], \
- eth_h->d_addr.addr_bytes[1], \
- eth_h->d_addr.addr_bytes[2], \
- eth_h->d_addr.addr_bytes[3], \
- eth_h->d_addr.addr_bytes[4], \
- eth_h->d_addr.addr_bytes[5], \
- dst_ip, \
- arp_op, \
- ++burstnumber)
+#define MODE6_DEBUG(info, src_ip, dst_ip, eth_h, arp_op, port, burstnumber) \
+ rte_log(RTE_LOG_DEBUG, logtype_bond, \
+ "%s port:%d SrcMAC:%02X:%02X:%02X:%02X:%02X:%02X SrcIP:%s " \
+ "DstMAC:%02X:%02X:%02X:%02X:%02X:%02X DstIP:%s %s %d\n", \
+ info, \
+ port, \
+ eth_h->s_addr.addr_bytes[0], eth_h->s_addr.addr_bytes[1], \
+ eth_h->s_addr.addr_bytes[2], eth_h->s_addr.addr_bytes[3], \
+ eth_h->s_addr.addr_bytes[4], eth_h->s_addr.addr_bytes[5], \
+ src_ip, \
+ eth_h->d_addr.addr_bytes[0], eth_h->d_addr.addr_bytes[1], \
+ eth_h->d_addr.addr_bytes[2], eth_h->d_addr.addr_bytes[3], \
+ eth_h->d_addr.addr_bytes[4], eth_h->d_addr.addr_bytes[5], \
+ dst_ip, \
+ arp_op, ++burstnumber)
#endif
static void
@@ -1139,7 +1126,8 @@ bond_ethdev_tx_burst_alb(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
/* Allocate new packet to send ARP update on current slave */
upd_pkt = rte_pktmbuf_alloc(internals->mode6.mempool);
if (upd_pkt == NULL) {
- RTE_LOG(ERR, PMD, "Failed to allocate ARP packet from pool\n");
+ RTE_BOND_LOG(ERR,
+ "Failed to allocate ARP packet from pool");
continue;
}
pkt_size = sizeof(struct ether_hdr) + sizeof(struct arp_hdr)
@@ -1561,12 +1549,12 @@ mac_address_get(struct rte_eth_dev *eth_dev, struct ether_addr *dst_mac_addr)
struct ether_addr *mac_addr;
if (eth_dev == NULL) {
- RTE_LOG(ERR, PMD, "%s: NULL pointer eth_dev specified\n", __func__);
+ RTE_BOND_LOG(ERR, "NULL pointer eth_dev specified");
return -1;
}
if (dst_mac_addr == NULL) {
- RTE_LOG(ERR, PMD, "%s: NULL pointer MAC specified\n", __func__);
+ RTE_BOND_LOG(ERR, "NULL pointer MAC specified");
return -1;
}
@@ -1687,9 +1675,9 @@ bond_ethdev_mode_set(struct rte_eth_dev *eth_dev, int mode)
if (internals->mode4.dedicated_queues.enabled == 0) {
eth_dev->rx_pkt_burst = bond_ethdev_rx_burst_8023ad;
eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_8023ad;
- RTE_LOG(WARNING, PMD,
+ RTE_BOND_LOG(WARNING,
"Using mode 4, it is necessary to do TX burst "
- "and RX burst at least every 100ms.\n");
+ "and RX burst at least every 100ms.");
} else {
/* Use flow director's optimization */
eth_dev->rx_pkt_burst =
@@ -1850,7 +1838,7 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
nb_rx_queues, nb_tx_queues,
&(slave_eth_dev->data->dev_conf));
if (errval != 0) {
- RTE_BOND_LOG(ERR, "Cannot configure slave device: port %u , err (%d)",
+ RTE_BOND_LOG(ERR, "Cannot configure slave device: port %u, err (%d)",
slave_eth_dev->data->port_id, errval);
return errval;
}
@@ -1932,10 +1920,10 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
&internals->reta_conf[0],
internals->slaves[i].reta_size);
if (errval != 0) {
- RTE_LOG(WARNING, PMD,
- "rte_eth_dev_rss_reta_update on slave port %d fails (err %d)."
- " RSS Configuration for bonding may be inconsistent.\n",
- slave_eth_dev->data->port_id, errval);
+ RTE_BOND_LOG(WARNING,
+ "rte_eth_dev_rss_reta_update on slave port %d fails (err %d)."
+ " RSS Configuration for bonding may be inconsistent.",
+ slave_eth_dev->data->port_id, errval);
}
break;
}
@@ -2192,16 +2180,16 @@ bond_ethdev_close(struct rte_eth_dev *dev)
uint8_t bond_port_id = internals->port_id;
int skipped = 0;
- RTE_LOG(INFO, EAL, "Closing bonded device %s\n", dev->device->name);
+ RTE_BOND_LOG(INFO, "Closing bonded device %s", dev->device->name);
while (internals->slave_count != skipped) {
uint16_t port_id = internals->slaves[skipped].port_id;
rte_eth_dev_stop(port_id);
if (rte_eth_bond_slave_remove(bond_port_id, port_id) != 0) {
- RTE_LOG(ERR, EAL,
- "Failed to remove port %d from bonded device "
- "%s\n", port_id, dev->device->name);
+ RTE_BOND_LOG(ERR,
+ "Failed to remove port %d from bonded device %s",
+ port_id, dev->device->name);
skipped++;
}
}
@@ -2290,9 +2278,9 @@ bond_ethdev_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
res = rte_eth_dev_vlan_filter(port_id, vlan_id, on);
if (res == ENOTSUP)
- RTE_LOG(WARNING, PMD,
- "Setting VLAN filter on slave port %u not supported.\n",
- port_id);
+ RTE_BOND_LOG(WARNING,
+ "Setting VLAN filter on slave port %u not supported.",
+ port_id);
}
rte_spinlock_unlock(&internals->lock);
@@ -2975,7 +2963,7 @@ bond_alloc(struct rte_vdev_device *dev, uint8_t mode)
/* Set mode 4 default configuration */
bond_mode_8023ad_setup(eth_dev, NULL);
if (bond_ethdev_mode_set(eth_dev, mode)) {
- RTE_BOND_LOG(ERR, "Failed to set bonded device %d mode to %d\n",
+ RTE_BOND_LOG(ERR, "Failed to set bonded device %d mode to %d",
eth_dev->data->port_id, mode);
goto err;
}
@@ -2986,7 +2974,7 @@ bond_alloc(struct rte_vdev_device *dev, uint8_t mode)
RTE_CACHE_LINE_SIZE);
if (internals->vlan_filter_bmpmem == NULL) {
RTE_BOND_LOG(ERR,
- "Failed to allocate vlan bitmap for bonded device %u\n",
+ "Failed to allocate vlan bitmap for bonded device %u",
eth_dev->data->port_id);
goto err;
}
@@ -2995,7 +2983,7 @@ bond_alloc(struct rte_vdev_device *dev, uint8_t mode)
internals->vlan_filter_bmpmem, vlan_filter_bmp_size);
if (internals->vlan_filter_bmp == NULL) {
RTE_BOND_LOG(ERR,
- "Failed to init vlan bitmap for bonded device %u\n",
+ "Failed to init vlan bitmap for bonded device %u",
eth_dev->data->port_id);
rte_free(internals->vlan_filter_bmpmem);
goto err;
@@ -3027,13 +3015,13 @@ bond_probe(struct rte_vdev_device *dev)
return -EINVAL;
name = rte_vdev_device_name(dev);
- RTE_LOG(INFO, EAL, "Initializing pmd_bond for %s\n", name);
+ RTE_BOND_LOG(INFO, "Initializing pmd_bond for %s", name);
if (rte_eal_process_type() == RTE_PROC_SECONDARY &&
strlen(rte_vdev_device_args(dev)) == 0) {
eth_dev = rte_eth_dev_attach_secondary(name);
if (!eth_dev) {
- RTE_LOG(ERR, PMD, "Failed to probe %s\n", name);
+ RTE_BOND_LOG(ERR, "Failed to probe %s", name);
return -1;
}
/* TODO: request info from primary to set up Rx and Tx */
@@ -3051,13 +3039,13 @@ bond_probe(struct rte_vdev_device *dev)
if (rte_kvargs_process(kvlist, PMD_BOND_MODE_KVARG,
&bond_ethdev_parse_slave_mode_kvarg,
&bonding_mode) != 0) {
- RTE_LOG(ERR, EAL, "Invalid mode for bonded device %s\n",
+ RTE_BOND_LOG(ERR, "Invalid mode for bonded device %s",
name);
goto parse_error;
}
} else {
- RTE_LOG(ERR, EAL, "Mode must be specified only once for bonded "
- "device %s\n", name);
+ RTE_BOND_LOG(ERR, "Mode must be specified only once for bonded "
+ "device %s", name);
goto parse_error;
}
@@ -3067,13 +3055,13 @@ bond_probe(struct rte_vdev_device *dev)
if (rte_kvargs_process(kvlist, PMD_BOND_SOCKET_ID_KVARG,
&bond_ethdev_parse_socket_id_kvarg, &socket_id)
!= 0) {
- RTE_LOG(ERR, EAL, "Invalid socket Id specified for "
- "bonded device %s\n", name);
+ RTE_BOND_LOG(ERR, "Invalid socket Id specified for "
+ "bonded device %s", name);
goto parse_error;
}
} else if (arg_count > 1) {
- RTE_LOG(ERR, EAL, "Socket Id can be specified only once for "
- "bonded device %s\n", name);
+ RTE_BOND_LOG(ERR, "Socket Id can be specified only once for "
+ "bonded device %s", name);
goto parse_error;
} else {
socket_id = rte_socket_id();
@@ -3084,8 +3072,8 @@ bond_probe(struct rte_vdev_device *dev)
/* Create link bonding eth device */
port_id = bond_alloc(dev, bonding_mode);
if (port_id < 0) {
- RTE_LOG(ERR, EAL, "Failed to create socket %s in mode %u on "
- "socket %u.\n", name, bonding_mode, socket_id);
+ RTE_BOND_LOG(ERR, "Failed to create socket %s in mode %u on "
+ "socket %u.", name, bonding_mode, socket_id);
goto parse_error;
}
internals = rte_eth_devices[port_id].data->dev_private;
@@ -3097,8 +3085,8 @@ bond_probe(struct rte_vdev_device *dev)
PMD_BOND_AGG_MODE_KVARG,
&bond_ethdev_parse_slave_agg_mode_kvarg,
&agg_mode) != 0) {
- RTE_LOG(ERR, EAL,
- "Failed to parse agg selection mode for bonded device %s\n",
+ RTE_BOND_LOG(ERR,
+ "Failed to parse agg selection mode for bonded device %s",
name);
goto parse_error;
}
@@ -3110,8 +3098,8 @@ bond_probe(struct rte_vdev_device *dev)
rte_eth_bond_8023ad_agg_selection_set(port_id, AGG_STABLE);
}
- RTE_LOG(INFO, EAL, "Create bonded device %s on port %d in mode %u on "
- "socket %u.\n", name, port_id, bonding_mode, socket_id);
+ RTE_BOND_LOG(INFO, "Create bonded device %s on port %d in mode %u on "
+ "socket %u.", name, port_id, bonding_mode, socket_id);
return 0;
parse_error:
@@ -3131,7 +3119,7 @@ bond_remove(struct rte_vdev_device *dev)
return -EINVAL;
name = rte_vdev_device_name(dev);
- RTE_LOG(INFO, EAL, "Uninitializing pmd_bond for %s\n", name);
+ RTE_BOND_LOG(INFO, "Uninitializing pmd_bond for %s", name);
/* now free all data allocation - for eth_dev structure,
* dummy pci driver and internal (private) data
@@ -3222,23 +3210,23 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
struct ether_addr bond_mac;
if (rte_kvargs_process(kvlist, PMD_BOND_MAC_ADDR_KVARG,
- &bond_ethdev_parse_bond_mac_addr_kvarg, &bond_mac) < 0) {
- RTE_LOG(INFO, EAL, "Invalid mac address for bonded device %s\n",
- name);
+ &bond_ethdev_parse_bond_mac_addr_kvarg, &bond_mac) < 0) {
+ RTE_BOND_LOG(INFO, "Invalid mac address for bonded device %s",
+ name);
return -1;
}
/* Set MAC address */
if (rte_eth_bond_mac_address_set(port_id, &bond_mac) != 0) {
- RTE_LOG(ERR, EAL,
- "Failed to set mac address on bonded device %s\n",
- name);
+ RTE_BOND_LOG(ERR,
+ "Failed to set mac address on bonded device %s",
+ name);
return -1;
}
} else if (arg_count > 1) {
- RTE_LOG(ERR, EAL,
- "MAC address can be specified only once for bonded device %s\n",
- name);
+ RTE_BOND_LOG(ERR,
+ "MAC address can be specified only once for bonded device %s",
+ name);
return -1;
}
@@ -3248,40 +3236,40 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
uint8_t xmit_policy;
if (rte_kvargs_process(kvlist, PMD_BOND_XMIT_POLICY_KVARG,
- &bond_ethdev_parse_balance_xmit_policy_kvarg, &xmit_policy) !=
- 0) {
- RTE_LOG(INFO, EAL,
- "Invalid xmit policy specified for bonded device %s\n",
- name);
+ &bond_ethdev_parse_balance_xmit_policy_kvarg, &xmit_policy) !=
+ 0) {
+ RTE_BOND_LOG(INFO,
+ "Invalid xmit policy specified for bonded device %s",
+ name);
return -1;
}
/* Set balance mode transmit policy*/
if (rte_eth_bond_xmit_policy_set(port_id, xmit_policy) != 0) {
- RTE_LOG(ERR, EAL,
- "Failed to set balance xmit policy on bonded device %s\n",
- name);
+ RTE_BOND_LOG(ERR,
+ "Failed to set balance xmit policy on bonded device %s",
+ name);
return -1;
}
} else if (arg_count > 1) {
- RTE_LOG(ERR, EAL,
- "Transmit policy can be specified only once for bonded device"
- " %s\n", name);
+ RTE_BOND_LOG(ERR,
+ "Transmit policy can be specified only once for bonded device %s",
+ name);
return -1;
}
if (rte_kvargs_count(kvlist, PMD_BOND_AGG_MODE_KVARG) == 1) {
if (rte_kvargs_process(kvlist,
- PMD_BOND_AGG_MODE_KVARG,
- &bond_ethdev_parse_slave_agg_mode_kvarg,
- &agg_mode) != 0) {
- RTE_LOG(ERR, EAL,
- "Failed to parse agg selection mode for bonded device %s\n",
- name);
+ PMD_BOND_AGG_MODE_KVARG,
+ &bond_ethdev_parse_slave_agg_mode_kvarg,
+ &agg_mode) != 0) {
+ RTE_BOND_LOG(ERR,
+ "Failed to parse agg selection mode for bonded device %s",
+ name);
}
if (internals->mode == BONDING_MODE_8023AD)
- rte_eth_bond_8023ad_agg_selection_set(port_id,
- agg_mode);
+ rte_eth_bond_8023ad_agg_selection_set(port_id,
+ agg_mode);
}
/* Parse/add slave ports to bonded device */
@@ -3292,23 +3280,23 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
memset(&slave_ports, 0, sizeof(slave_ports));
if (rte_kvargs_process(kvlist, PMD_BOND_SLAVE_PORT_KVARG,
- &bond_ethdev_parse_slave_port_kvarg, &slave_ports) != 0) {
- RTE_LOG(ERR, EAL,
- "Failed to parse slave ports for bonded device %s\n",
- name);
+ &bond_ethdev_parse_slave_port_kvarg, &slave_ports) != 0) {
+ RTE_BOND_LOG(ERR,
+ "Failed to parse slave ports for bonded device %s",
+ name);
return -1;
}
for (i = 0; i < slave_ports.slave_count; i++) {
if (rte_eth_bond_slave_add(port_id, slave_ports.slaves[i]) != 0) {
- RTE_LOG(ERR, EAL,
- "Failed to add port %d as slave to bonded device %s\n",
- slave_ports.slaves[i], name);
+ RTE_BOND_LOG(ERR,
+ "Failed to add port %d as slave to bonded device %s",
+ slave_ports.slaves[i], name);
}
}
} else {
- RTE_LOG(INFO, EAL, "No slaves specified for bonded device %s\n", name);
+ RTE_BOND_LOG(INFO, "No slaves specified for bonded device %s", name);
return -1;
}
@@ -3318,27 +3306,27 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
uint16_t primary_slave_port_id;
if (rte_kvargs_process(kvlist,
- PMD_BOND_PRIMARY_SLAVE_KVARG,
- &bond_ethdev_parse_primary_slave_port_id_kvarg,
- &primary_slave_port_id) < 0) {
- RTE_LOG(INFO, EAL,
- "Invalid primary slave port id specified for bonded device"
- " %s\n", name);
+ PMD_BOND_PRIMARY_SLAVE_KVARG,
+ &bond_ethdev_parse_primary_slave_port_id_kvarg,
+ &primary_slave_port_id) < 0) {
+ RTE_BOND_LOG(INFO,
+ "Invalid primary slave port id specified for bonded device %s",
+ name);
return -1;
}
/* Set balance mode transmit policy*/
if (rte_eth_bond_primary_set(port_id, primary_slave_port_id)
- != 0) {
- RTE_LOG(ERR, EAL,
- "Failed to set primary slave port %d on bonded device %s\n",
- primary_slave_port_id, name);
+ != 0) {
+ RTE_BOND_LOG(ERR,
+ "Failed to set primary slave port %d on bonded device %s",
+ primary_slave_port_id, name);
return -1;
}
} else if (arg_count > 1) {
- RTE_LOG(INFO, EAL,
- "Primary slave can be specified only once for bonded device"
- " %s\n", name);
+ RTE_BOND_LOG(INFO,
+ "Primary slave can be specified only once for bonded device %s",
+ name);
return -1;
}
@@ -3348,26 +3336,26 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
uint32_t lsc_poll_interval_ms;
if (rte_kvargs_process(kvlist,
- PMD_BOND_LSC_POLL_PERIOD_KVARG,
- &bond_ethdev_parse_time_ms_kvarg,
- &lsc_poll_interval_ms) < 0) {
- RTE_LOG(INFO, EAL,
- "Invalid lsc polling interval value specified for bonded"
- " device %s\n", name);
+ PMD_BOND_LSC_POLL_PERIOD_KVARG,
+ &bond_ethdev_parse_time_ms_kvarg,
+ &lsc_poll_interval_ms) < 0) {
+ RTE_BOND_LOG(INFO,
+ "Invalid lsc polling interval value specified for bonded"
+ " device %s", name);
return -1;
}
if (rte_eth_bond_link_monitoring_set(port_id, lsc_poll_interval_ms)
- != 0) {
- RTE_LOG(ERR, EAL,
- "Failed to set lsc monitor polling interval (%u ms) on"
- " bonded device %s\n", lsc_poll_interval_ms, name);
+ != 0) {
+ RTE_BOND_LOG(ERR,
+ "Failed to set lsc monitor polling interval (%u ms) on bonded device %s",
+ lsc_poll_interval_ms, name);
return -1;
}
} else if (arg_count > 1) {
- RTE_LOG(INFO, EAL,
- "LSC polling interval can be specified only once for bonded"
- " device %s\n", name);
+ RTE_BOND_LOG(INFO,
+ "LSC polling interval can be specified only once for bonded"
+ " device %s", name);
return -1;
}
@@ -3377,27 +3365,27 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
uint32_t link_up_delay_ms;
if (rte_kvargs_process(kvlist,
- PMD_BOND_LINK_UP_PROP_DELAY_KVARG,
- &bond_ethdev_parse_time_ms_kvarg,
- &link_up_delay_ms) < 0) {
- RTE_LOG(INFO, EAL,
- "Invalid link up propagation delay value specified for"
- " bonded device %s\n", name);
+ PMD_BOND_LINK_UP_PROP_DELAY_KVARG,
+ &bond_ethdev_parse_time_ms_kvarg,
+ &link_up_delay_ms) < 0) {
+ RTE_BOND_LOG(INFO,
+ "Invalid link up propagation delay value specified for"
+ " bonded device %s", name);
return -1;
}
/* Set balance mode transmit policy*/
if (rte_eth_bond_link_up_prop_delay_set(port_id, link_up_delay_ms)
- != 0) {
- RTE_LOG(ERR, EAL,
- "Failed to set link up propagation delay (%u ms) on bonded"
- " device %s\n", link_up_delay_ms, name);
+ != 0) {
+ RTE_BOND_LOG(ERR,
+ "Failed to set link up propagation delay (%u ms) on bonded"
+ " device %s", link_up_delay_ms, name);
return -1;
}
} else if (arg_count > 1) {
- RTE_LOG(INFO, EAL,
- "Link up propagation delay can be specified only once for"
- " bonded device %s\n", name);
+ RTE_BOND_LOG(INFO,
+ "Link up propagation delay can be specified only once for"
+ " bonded device %s", name);
return -1;
}
@@ -3407,27 +3395,27 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
uint32_t link_down_delay_ms;
if (rte_kvargs_process(kvlist,
- PMD_BOND_LINK_DOWN_PROP_DELAY_KVARG,
- &bond_ethdev_parse_time_ms_kvarg,
- &link_down_delay_ms) < 0) {
- RTE_LOG(INFO, EAL,
- "Invalid link down propagation delay value specified for"
- " bonded device %s\n", name);
+ PMD_BOND_LINK_DOWN_PROP_DELAY_KVARG,
+ &bond_ethdev_parse_time_ms_kvarg,
+ &link_down_delay_ms) < 0) {
+ RTE_BOND_LOG(INFO,
+ "Invalid link down propagation delay value specified for"
+ " bonded device %s", name);
return -1;
}
/* Set balance mode transmit policy*/
if (rte_eth_bond_link_down_prop_delay_set(port_id, link_down_delay_ms)
- != 0) {
- RTE_LOG(ERR, EAL,
- "Failed to set link down propagation delay (%u ms) on"
- " bonded device %s\n", link_down_delay_ms, name);
+ != 0) {
+ RTE_BOND_LOG(ERR,
+ "Failed to set link down propagation delay (%u ms) on bonded device %s",
+ link_down_delay_ms, name);
return -1;
}
} else if (arg_count > 1) {
- RTE_LOG(INFO, EAL,
- "Link down propagation delay can be specified only once for"
- " bonded device %s\n", name);
+ RTE_BOND_LOG(INFO,
+ "Link down propagation delay can be specified only once for bonded device %s",
+ name);
return -1;
}
@@ -3453,3 +3441,14 @@ RTE_PMD_REGISTER_PARAM_STRING(net_bonding,
"lsc_poll_period_ms=<int> "
"up_delay=<int> "
"down_delay=<int>");
+
+int bond_logtype;
+
+RTE_INIT(bond_init_log);
+static void
+bond_init_log(void)
+{
+ bond_logtype = rte_log_register("pmd.net.bon");
+ if (bond_logtype >= 0)
+ rte_log_set_level(bond_logtype, RTE_LOG_NOTICE);
+}
diff --git a/drivers/net/bonding/rte_eth_bond_private.h b/drivers/net/bonding/rte_eth_bond_private.h
index 94eca8838e17..833900745abf 100644
--- a/drivers/net/bonding/rte_eth_bond_private.h
+++ b/drivers/net/bonding/rte_eth_bond_private.h
@@ -28,8 +28,11 @@
#define PMD_BOND_XMIT_POLICY_LAYER23_KVARG ("l23")
#define PMD_BOND_XMIT_POLICY_LAYER34_KVARG ("l34")
+extern int bond_logtype;
+
#define RTE_BOND_LOG(lvl, msg, ...) \
- RTE_LOG(lvl, PMD, "%s(%d) - " msg "\n", __func__, __LINE__, ##__VA_ARGS__)
+ rte_log(RTE_LOG_ ## lvl, bond_logtype, \
+ "%s(%d) - " msg "\n", __func__, __LINE__, ##__VA_ARGS__)
#define BONDING_MODE_INVALID 0xFF
--
2.17.0
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [dpdk-dev] [PATCH next 10/10] net/bond: convert to dynamic logging
2018-04-25 15:56 ` [dpdk-dev] [PATCH next 10/10] net/bond: convert to " Stephen Hemminger
@ 2018-04-26 23:41 ` Ferruh Yigit
0 siblings, 0 replies; 15+ messages in thread
From: Ferruh Yigit @ 2018-04-26 23:41 UTC (permalink / raw)
To: Stephen Hemminger, dev
On 4/25/2018 4:56 PM, Stephen Hemminger wrote:
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
<...>
> +#define MODE6_DEBUG(info, src_ip, dst_ip, eth_h, arp_op, port, burstnumber) \
> + rte_log(RTE_LOG_DEBUG, logtype_bond, \
Variable is "bond_logtype", will fix while applying
<...>
> +int bond_logtype;
> +
> +RTE_INIT(bond_init_log);
> +static void
> +bond_init_log(void)
> +{
> + bond_logtype = rte_log_register("pmd.net.bon");
> + if (bond_logtype >= 0)
> + rte_log_set_level(bond_logtype, RTE_LOG_NOTICE);
> +}
<...>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [dpdk-dev] [PATCH next 00/10] more dynamic logging
2018-04-25 15:56 [dpdk-dev] [PATCH next 00/10] more dynamic logging Stephen Hemminger
` (9 preceding siblings ...)
2018-04-25 15:56 ` [dpdk-dev] [PATCH next 10/10] net/bond: convert to " Stephen Hemminger
@ 2018-04-26 23:42 ` Ferruh Yigit
2018-04-26 23:55 ` Ferruh Yigit
2018-04-26 23:55 ` Ferruh Yigit
10 siblings, 2 replies; 15+ messages in thread
From: Ferruh Yigit @ 2018-04-26 23:42 UTC (permalink / raw)
To: Stephen Hemminger, dev
On 4/25/2018 4:56 PM, Stephen Hemminger wrote:
> This set of patches converts more virtual drivers to use the
> dynamic log type, rather than PMD log type.
>
> Marking these for next since there is no urgency to get
> these into 18.05 and they are compile tested only.
>
> Stephen Hemminger (10):
> net/tap: convert to dynamic logging
> net/af_packet: convert to dynamic log level
> net/null: convert to dynamic logging
> net/ring: convert to dynamic logging
> net/softnic: convert to dynamic logging
> net/failsafe: convert to dynamic logging
> net/kni: support dynamic logging
> net/pcap: support dynamic logging
> net/vhost: implement dynamic logging
> net/bond: convert to dynamic logging
For series,
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [dpdk-dev] [PATCH next 00/10] more dynamic logging
2018-04-26 23:42 ` [dpdk-dev] [PATCH next 00/10] more " Ferruh Yigit
@ 2018-04-26 23:55 ` Ferruh Yigit
2018-04-26 23:55 ` Ferruh Yigit
1 sibling, 0 replies; 15+ messages in thread
From: Ferruh Yigit @ 2018-04-26 23:55 UTC (permalink / raw)
To: Stephen Hemminger, dev
On 4/27/2018 12:42 AM, Ferruh Yigit wrote:
> On 4/25/2018 4:56 PM, Stephen Hemminger wrote:
>> This set of patches converts more virtual drivers to use the
>> dynamic log type, rather than PMD log type.
>>
>> Marking these for next since there is no urgency to get
>> these into 18.05 and they are compile tested only.
>>
>> Stephen Hemminger (10):
>> net/tap: convert to dynamic logging
>> net/af_packet: convert to dynamic log level
>> net/null: convert to dynamic logging
>> net/ring: convert to dynamic logging
>> net/softnic: convert to dynamic logging
>> net/failsafe: convert to dynamic logging
>> net/kni: support dynamic logging
>> net/pcap: support dynamic logging
>> net/vhost: implement dynamic logging
>> net/bond: convert to dynamic logging
>
> For series,
> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [dpdk-dev] [PATCH next 00/10] more dynamic logging
2018-04-26 23:42 ` [dpdk-dev] [PATCH next 00/10] more " Ferruh Yigit
2018-04-26 23:55 ` Ferruh Yigit
@ 2018-04-26 23:55 ` Ferruh Yigit
1 sibling, 0 replies; 15+ messages in thread
From: Ferruh Yigit @ 2018-04-26 23:55 UTC (permalink / raw)
To: Stephen Hemminger, dev
On 4/27/2018 12:42 AM, Ferruh Yigit wrote:
> On 4/25/2018 4:56 PM, Stephen Hemminger wrote:
>> This set of patches converts more virtual drivers to use the
>> dynamic log type, rather than PMD log type.
>>
>> Marking these for next since there is no urgency to get
>> these into 18.05 and they are compile tested only.
>>
>> Stephen Hemminger (10):
>> net/tap: convert to dynamic logging
>> net/af_packet: convert to dynamic log level
>> net/null: convert to dynamic logging
>> net/ring: convert to dynamic logging
>> net/softnic: convert to dynamic logging
>> net/failsafe: convert to dynamic logging
>> net/kni: support dynamic logging
>> net/pcap: support dynamic logging
>> net/vhost: implement dynamic logging
>> net/bond: convert to dynamic logging
>
> For series,
> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
Series applied to dpdk-next-net/master, thanks.
^ permalink raw reply [flat|nested] 15+ messages in thread