From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-f68.google.com (mail-pg0-f68.google.com [74.125.83.68]) by dpdk.org (Postfix) with ESMTP id 84FCBA48E for ; Wed, 25 Apr 2018 17:57:05 +0200 (CEST) Received: by mail-pg0-f68.google.com with SMTP id 82so3793618pge.11 for ; Wed, 25 Apr 2018 08:57:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WrtdoyZNJ6JKFzwjKEMe5TLOlyuFRr9wG13PWm1roiI=; b=ChMm+dgb6q2cXdW1Y043XA83OIPBAOKW6Y82pRwPQgv2O7+a4P5sKn/IflsSaCYix/ Zu59iuhweiv93tMsn1441SrsRNHzbpMrbFTMCkSNO8nolimQ+6mAI3XjfD0OFeq1DlV9 eupJUESzJuHIxW0OUW0p3qgDCQh1ERs9DvIhzygNeDxVIL3Nxc+2wj3OfFFc3QPjA6Mc 9BoPa/JZ0K7Su8b/ECCWrlwWtcBFJKFkWAEhEvg/59cJQtYzhDWd5d1Knfr2MbhhMUeF TN00GqXHac/JQUfyYQKsi2ChrJKjKi34GQNO7rOKDO3kM9D71/cJhdBW1Kf0WVuBBreD /myw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=WrtdoyZNJ6JKFzwjKEMe5TLOlyuFRr9wG13PWm1roiI=; b=TAapcwfh3INzkBaEaJhM/z6gSnhaDrfMTMz1udN22Ranl7FWBzAm/prcE0QcnLEYni 2zxobV7+id2RbQFMeQiIY4uWRTeuirW+ZC4PU0xW0PhMiV3FSY7eEBWUkaHgrg7vSeSW GNzBnw2oyx5JqeQfZ2j9Zy2nXY3wb3v4+5DMc814RXjSbdeQjdDqtsETT7pWKkHOEmkY ftQ4FWTon/8/+EzLEewU9oSJyfsGJx5XsnQXZ0k6flnFiVkVPUMyPVOyr/hTK9M56hJj 6rcGwHn7c4ITIQFYVoV7NZi/npBDGICQzRsxOFSdkPQXbCZbT5kuKGp9ohmigEZCQStQ wVrw== X-Gm-Message-State: ALQs6tBKl2EqNsMAlplGO2sAF9IWKU8psSj5SqX/O6uZK7Lp7hV06Ypu d2p172M9H4zXerBDPbKa1MbwJlh3EJY= X-Google-Smtp-Source: AIpwx48GnHB0FdZHrJUKt8DGvENbKcLvEyde+TYlPhni0X46RxcUFAZjvccZQiWW+VAlzCaacMBTyg== X-Received: by 2002:a17:902:5801:: with SMTP id m1-v6mr30136361pli.325.1524671824153; Wed, 25 Apr 2018 08:57:04 -0700 (PDT) Received: from xeon-e3.lan (204-195-71-95.wavecable.com. [204.195.71.95]) by smtp.gmail.com with ESMTPSA id y3sm25713924pgc.81.2018.04.25.08.57.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Apr 2018 08:57:03 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Wed, 25 Apr 2018 08:56:46 -0700 Message-Id: <20180425155646.3627-11-stephen@networkplumber.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180425155646.3627-1-stephen@networkplumber.org> References: <20180425155646.3627-1-stephen@networkplumber.org> Subject: [dpdk-dev] [PATCH next 10/10] net/bond: convert to dynamic logging X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Apr 2018 15:57:06 -0000 Signed-off-by: Stephen Hemminger --- 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= " "up_delay= " "down_delay="); + +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