From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f50.google.com (mail-pa0-f50.google.com [209.85.220.50]) by dpdk.org (Postfix) with ESMTP id DA2B991BF for ; Fri, 4 Dec 2015 18:14:18 +0100 (CET) Received: by pacej9 with SMTP id ej9so89770711pac.2 for ; Fri, 04 Dec 2015 09:14:18 -0800 (PST) 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=5LNasNJSIzTfmTgJuHrOwAUkEpUNtjt2cCuzhqnByxE=; b=lOYeMkNgtC5cdQXsDlItudhu9lJYhW7L8tSlD5iLXfFzsRrJ6QjJh1EfE+qZhE4yXt YunihAQasBJ2HciTkJWV1iyLaaW/jNnGah3zbhdyzfh/fYJ8oQ9cnT2AVz1Jpfmlk6ut x97PI+DVwLwdTRcN08koJ/50v7QEcN8yNuuFYKrO25gAzU7LGb3HsrjdyADMnHQ0NdO+ LxtvYk4jIXO0muB8LD3kGcjaGYma83Og/JqYBeyMWSIsPqms47TmisTVFbMFqsz2wYN7 Q+CggNoiYs7VVWP6luzZvFbMSG+NdQkFG+auduxF0LcQJ23o2mXhKev6GG0kbzdWe7Ht xXzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5LNasNJSIzTfmTgJuHrOwAUkEpUNtjt2cCuzhqnByxE=; b=ZJL+TVRb29f2VpX/SP89YTehN/VnV0l2L+0v2zOuuvWMd98umIIIJnHoegAgLURFI6 tQUureWr8Fp6Fybr8J9pJzWT6m8WH9NXxvIslb6Xl4O9uTT0eG7zp9AE2Zlam0S+NFkM 9esrSRpD8GeGBtkWJoJr8ivO2wm8caO4bEob7AWbnfzxoeBJn6A3/bvXO4IXwY6cV1O1 BLh/80JrGU/SFt4PR7YQt5DSt5Fo3+ZgBA0USpAA1dwwuJokdmijCndWxDClEgGirBYS 3Q/9rDeU2STps72XSMn9A0m2XQq2btfvKoLGgw1eBwESfbLVcxHsFO3u87so5xyYeu0/ O2AQ== X-Gm-Message-State: ALoCoQkB9UVqTVndZ/0882w6Hz4c8X28QefDhAZ+K4gRKDZGJogKL992Ia37CSmtONfUC9lwBrD8 X-Received: by 10.66.180.48 with SMTP id dl16mr22811713pac.39.1449249258303; Fri, 04 Dec 2015 09:14:18 -0800 (PST) Received: from xeon-e3.home.lan (static-50-53-82-155.bvtn.or.frontiernet.net. [50.53.82.155]) by smtp.gmail.com with ESMTPSA id 134sm18291003pfa.30.2015.12.04.09.14.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 04 Dec 2015 09:14:17 -0800 (PST) From: Stephen Hemminger To: declan.doherty@intel.com Date: Fri, 4 Dec 2015 09:14:19 -0800 Message-Id: <1449249260-15165-8-git-send-email-stephen@networkplumber.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1449249260-15165-1-git-send-email-stephen@networkplumber.org> References: <1449249260-15165-1-git-send-email-stephen@networkplumber.org> Cc: dev@dpdk.org, Eric Kinzie Subject: [dpdk-dev] [PATCH 7/8] bond: per-slave intermediate rx ring X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Dec 2015 17:14:19 -0000 From: Eric Kinzie Need to handle the case when bonding two (or more) ixgbe devices together. The existing code would break because the ixgbe devices assumed that if setup in vector mode that the burst size would always be large. To solve this, during bond 802.3ad receive, a burst of packets is fetched from each slave into a local array and appended to per-slave ring buffer. Packets are taken from the head of the ring buffer and returned to the caller. The number of mbufs provided to each slave is sufficient to meet the requirements of the ixgbe vector receive. Signed-off-by: Eric Kinzie Signed-off-by: Stephen Hemminger --- drivers/net/bonding/rte_eth_bond_api.c | 29 ++++++++++++ drivers/net/bonding/rte_eth_bond_pmd.c | 71 ++++++++++++++++++++++-------- drivers/net/bonding/rte_eth_bond_private.h | 4 ++ 3 files changed, 86 insertions(+), 18 deletions(-) diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c index 64058ff..91b3819 100644 --- a/drivers/net/bonding/rte_eth_bond_api.c +++ b/drivers/net/bonding/rte_eth_bond_api.c @@ -37,6 +37,8 @@ #include #include #include +#include +#include #include "rte_eth_bond.h" #include "rte_eth_bond_private.h" @@ -170,6 +172,7 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id) { struct bond_dev_private *internals = NULL; struct rte_eth_dev *eth_dev = NULL; + char mem_name[RTE_ETH_NAME_MAX_LEN]; /* now do all data allocation - for eth_dev structure, dummy pci driver * and internal (private) data @@ -254,6 +257,18 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id) memset(internals->active_slaves, 0, sizeof(internals->active_slaves)); memset(internals->slaves, 0, sizeof(internals->slaves)); + snprintf(mem_name, RTE_DIM(mem_name), "%s_rx", name); + internals->rx_ring = rte_ring_lookup(mem_name); + if (internals->rx_ring == NULL) { + internals->rx_ring = rte_ring_create(mem_name, + rte_align32pow2(PMD_BOND_RECV_RING_PKTS * + rte_lcore_count()), + socket_id, 0); + if (internals->rx_ring == NULL) + rte_panic("%s: Failed to create rx ring '%s': %s\n", name, + mem_name, rte_strerror(rte_errno)); + } + /* Set mode 4 default configuration */ bond_mode_8023ad_setup(eth_dev, NULL); if (bond_ethdev_mode_set(eth_dev, mode)) { @@ -532,12 +547,26 @@ __eth_bond_slave_remove_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id) memset(rte_eth_devices[bonded_port_id].data->mac_addrs, 0, sizeof(*(rte_eth_devices[bonded_port_id].data->mac_addrs))); } + if (internals->slave_count == 0) { + /* Remove any remaining packets in the receive ring */ + struct rte_mbuf *bufs[PMD_BOND_RECV_PKTS_PER_SLAVE]; + unsigned j, count; + internals->rx_offload_capa = 0; internals->tx_offload_capa = 0; internals->flow_type_rss_offloads = ETH_RSS_PROTO_MASK; internals->reta_size = 0; + + do { + count = rte_ring_dequeue_burst(internals->rx_ring, + (void **)bufs, + PMD_BOND_RECV_PKTS_PER_SLAVE); + for (j = 0; j < count; j++) + rte_pktmbuf_free(bufs[j]); + } while (count > 0); } + return 0; } diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c index 868e66b..043160e 100644 --- a/drivers/net/bonding/rte_eth_bond_pmd.c +++ b/drivers/net/bonding/rte_eth_bond_pmd.c @@ -180,10 +180,15 @@ bond_ethdev_rx_burst_8023ad(void *queue, struct rte_mbuf **bufs, struct bond_dev_private *internals = bd_rx_q->dev_private; struct ether_addr bond_mac; + unsigned rx_ring_avail = rte_ring_free_count(internals->rx_ring); + struct rte_mbuf *mbuf_bounce[PMD_BOND_RECV_PKTS_PER_SLAVE]; + struct ether_hdr *hdr; const uint16_t ether_type_slow_be = rte_be_to_cpu_16(ETHER_TYPE_SLOW); uint16_t num_rx_total = 0; /* Total number of received packets */ + uint16_t num_rx_slave; + uint16_t num_enq_slave; uint8_t slaves[RTE_MAX_ETHPORTS]; uint8_t slave_count; @@ -191,6 +196,9 @@ bond_ethdev_rx_burst_8023ad(void *queue, struct rte_mbuf **bufs, const uint8_t promisc = internals->promiscuous_en; uint8_t i, j, k; + if (rx_ring_avail < PMD_BOND_RECV_PKTS_PER_SLAVE) + goto dequeue; + rte_eth_macaddr_get(internals->port_id, &bond_mac); /* Copy slave list to protect against slave up/down changes during tx * bursting */ @@ -198,23 +206,27 @@ bond_ethdev_rx_burst_8023ad(void *queue, struct rte_mbuf **bufs, slave_count = bond_active_slaves_by_rxqid(internals, bd_rx_q->queue_id, slaves); - for (i = 0; i < slave_count && num_rx_total < nb_pkts; i++) { - j = num_rx_total; + for (i = 0; i < slave_count && num_rx_total < rx_ring_avail; i++) { + j = 0; collecting = ACTOR_STATE(&mode_8023ad_ports[slaves[i]], COLLECTING); /* Read packets from this slave */ - num_rx_total += rte_eth_rx_burst(slaves[i], bd_rx_q->queue_id, - &bufs[num_rx_total], nb_pkts - num_rx_total); - - for (k = j; k < 2 && k < num_rx_total; k++) - rte_prefetch0(rte_pktmbuf_mtod(bufs[k], void *)); + if (unlikely(rx_ring_avail - num_rx_total < PMD_BOND_RECV_PKTS_PER_SLAVE)) + continue; + num_rx_slave = rte_eth_rx_burst(slaves[i], bd_rx_q->queue_id, + mbuf_bounce, + PMD_BOND_RECV_PKTS_PER_SLAVE); + for (k = j; k < 2 && k < num_rx_slave; k++) + rte_prefetch0(rte_pktmbuf_mtod(mbuf_bounce[k], void *)); /* Handle slow protocol packets. */ - while (j < num_rx_total) { - if (j + 3 < num_rx_total) - rte_prefetch0(rte_pktmbuf_mtod(bufs[j + 3], void *)); + while (j < num_rx_slave) { + if (j + 3 < num_rx_slave) + rte_prefetch0(rte_pktmbuf_mtod( + mbuf_bounce[j + 3], + void *)); - hdr = rte_pktmbuf_mtod(bufs[j], struct ether_hdr *); + hdr = rte_pktmbuf_mtod(mbuf_bounce[j], struct ether_hdr *); /* Remove packet from array if it is slow packet or slave is not * in collecting state or bondign interface is not in promiscus * mode and packet address does not match. */ @@ -225,22 +237,45 @@ bond_ethdev_rx_burst_8023ad(void *queue, struct rte_mbuf **bufs, if (hdr->ether_type == ether_type_slow_be) { bond_mode_8023ad_handle_slow_pkt(internals, slaves[i], - bufs[j]); + mbuf_bounce[j]); } else - rte_pktmbuf_free(bufs[j]); + rte_pktmbuf_free(mbuf_bounce[j]); /* Packet is managed by mode 4 or dropped, shift the array */ - num_rx_total--; - if (j < num_rx_total) { - memmove(&bufs[j], &bufs[j + 1], sizeof(bufs[0]) * - (num_rx_total - j)); + num_rx_slave--; + if (j < num_rx_slave) { + memmove(&mbuf_bounce[j], + &mbuf_bounce[j + 1], + sizeof(mbuf_bounce[0]) * + (num_rx_slave - j)); } } else j++; } + + if (num_rx_slave > 0) { + if (mbuf_bounce[0] == NULL) + RTE_LOG(ERR, PMD, "%s: Enqueue a NULL??\n", + __func__); + + num_enq_slave = rte_ring_enqueue_burst(internals->rx_ring, + (void **)mbuf_bounce, + num_rx_slave); + + if (num_enq_slave < num_rx_slave) { + RTE_LOG(ERR, PMD, + "%s: failed to enqueue %u packets", + __func__, + (num_rx_slave - num_enq_slave)); + for (j = num_enq_slave; j < num_rx_slave; j++) + rte_pktmbuf_free(mbuf_bounce[j]); + } + num_rx_total += num_enq_slave; + } } - return num_rx_total; +dequeue: + return rte_ring_dequeue_burst(internals->rx_ring, (void **)bufs, nb_pkts); } #if defined(RTE_LIBRTE_BOND_DEBUG_ALB) || defined(RTE_LIBRTE_BOND_DEBUG_ALB_L1) diff --git a/drivers/net/bonding/rte_eth_bond_private.h b/drivers/net/bonding/rte_eth_bond_private.h index 02f6de1..2c43bc3 100644 --- a/drivers/net/bonding/rte_eth_bond_private.h +++ b/drivers/net/bonding/rte_eth_bond_private.h @@ -50,6 +50,8 @@ #define PMD_BOND_LSC_POLL_PERIOD_KVARG ("lsc_poll_period_ms") #define PMD_BOND_LINK_UP_PROP_DELAY_KVARG ("up_delay") #define PMD_BOND_LINK_DOWN_PROP_DELAY_KVARG ("down_delay") +#define PMD_BOND_RECV_RING_PKTS 512 +#define PMD_BOND_RECV_PKTS_PER_SLAVE 32 #define PMD_BOND_XMIT_POLICY_LAYER2_KVARG ("l2") #define PMD_BOND_XMIT_POLICY_LAYER23_KVARG ("l23") @@ -171,6 +173,8 @@ struct bond_dev_private { struct rte_kvargs *kvlist; uint8_t slave_update_idx; + + struct rte_ring *rx_ring; }; extern struct eth_dev_ops default_dev_ops; -- 2.1.4