From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id BAADF7F2D for ; Fri, 7 Nov 2014 13:13:35 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP; 07 Nov 2014 04:20:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,332,1413270000"; d="scan'208";a="604086257" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga001.jf.intel.com with ESMTP; 07 Nov 2014 04:23:05 -0800 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id sA7CN4ON002831; Fri, 7 Nov 2014 12:23:04 GMT Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id sA7CN4aF007557; Fri, 7 Nov 2014 12:23:04 GMT Received: (from dwdohert@localhost) by sivswdev02.ir.intel.com with id sA7CN49w007553; Fri, 7 Nov 2014 12:23:04 GMT From: Declan Doherty To: dev@dpdk.org Date: Fri, 7 Nov 2014 12:22:52 +0000 Message-Id: <1415362978-6306-3-git-send-email-declan.doherty@intel.com> X-Mailer: git-send-email 1.7.12.2 In-Reply-To: <1415362978-6306-1-git-send-email-declan.doherty@intel.com> References: <1413291597-27326-1-git-send-email-declan.doherty@intel.com> <1415362978-6306-1-git-send-email-declan.doherty@intel.com> Subject: [dpdk-dev] [PATCH v6 2/8] bond: removing switch statement from rx burst method 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, 07 Nov 2014 12:13:36 -0000 Signed-off-by: Declan Doherty --- lib/librte_pmd_bond/rte_eth_bond_pmd.c | 65 +++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c index de0cd56..f2fe930 100644 --- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c +++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c @@ -59,35 +59,38 @@ bond_ethdev_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) internals = bd_rx_q->dev_private; - switch (internals->mode) { - case BONDING_MODE_ROUND_ROBIN: -#ifdef RTE_MBUF_REFCNT - case BONDING_MODE_BROADCAST: -#endif - case BONDING_MODE_BALANCE: - for (i = 0; i < internals->active_slave_count && nb_pkts; i++) { - /* Offset of pointer to *bufs increases as packets are received - * from other slaves */ - num_rx_slave = rte_eth_rx_burst(internals->active_slaves[i], - bd_rx_q->queue_id, bufs + num_rx_total, nb_pkts); - if (num_rx_slave) { - num_rx_total += num_rx_slave; - nb_pkts -= num_rx_slave; - } + + for (i = 0; i < internals->active_slave_count && nb_pkts; i++) { + /* Offset of pointer to *bufs increases as packets are received + * from other slaves */ + num_rx_slave = rte_eth_rx_burst(internals->active_slaves[i], + bd_rx_q->queue_id, bufs + num_rx_total, nb_pkts); + if (num_rx_slave) { + num_rx_total += num_rx_slave; + nb_pkts -= num_rx_slave; } - break; - case BONDING_MODE_ACTIVE_BACKUP: - num_rx_slave = rte_eth_rx_burst(internals->current_primary_port, - bd_rx_q->queue_id, bufs, nb_pkts); - if (num_rx_slave) - num_rx_total = num_rx_slave; - break; } + return num_rx_total; } static uint16_t -bond_ethdev_tx_round_robin(void *queue, struct rte_mbuf **bufs, +bond_ethdev_rx_burst_active_backup(void *queue, struct rte_mbuf **bufs, + uint16_t nb_pkts) +{ + struct bond_dev_private *internals; + + /* Cast to structure, containing bonded device's port id and queue id */ + struct bond_rx_queue *bd_rx_q = (struct bond_rx_queue *)queue; + + internals = bd_rx_q->dev_private; + + return rte_eth_rx_burst(internals->current_primary_port, + bd_rx_q->queue_id, bufs, nb_pkts); +} + +static uint16_t +bond_ethdev_tx_burst_round_robin(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) { struct bond_dev_private *dev_private; @@ -136,7 +139,7 @@ bond_ethdev_tx_round_robin(void *queue, struct rte_mbuf **bufs, } static uint16_t -bond_ethdev_tx_active_backup(void *queue, +bond_ethdev_tx_burst_active_backup(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) { struct bond_dev_private *internals; @@ -272,7 +275,8 @@ xmit_slave_hash(const struct rte_mbuf *buf, uint8_t slave_count, uint8_t policy) } static uint16_t -bond_ethdev_tx_balance(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) +bond_ethdev_tx_burst_balance(void *queue, struct rte_mbuf **bufs, + uint16_t nb_pkts) { struct bond_dev_private *internals; struct bond_tx_queue *bd_tx_q; @@ -486,24 +490,27 @@ bond_ethdev_mode_set(struct rte_eth_dev *eth_dev, int mode) switch (mode) { case BONDING_MODE_ROUND_ROBIN: - eth_dev->tx_pkt_burst = bond_ethdev_tx_round_robin; + eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_round_robin; + eth_dev->rx_pkt_burst = bond_ethdev_rx_burst; break; case BONDING_MODE_ACTIVE_BACKUP: - eth_dev->tx_pkt_burst = bond_ethdev_tx_active_backup; + eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_active_backup; + eth_dev->rx_pkt_burst = bond_ethdev_rx_burst_active_backup; break; case BONDING_MODE_BALANCE: - eth_dev->tx_pkt_burst = bond_ethdev_tx_balance; + eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_balance; + eth_dev->rx_pkt_burst = bond_ethdev_rx_burst; break; #ifdef RTE_MBUF_REFCNT case BONDING_MODE_BROADCAST: eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_broadcast; + eth_dev->rx_pkt_burst = bond_ethdev_rx_burst; break; #endif default: return -1; } - eth_dev->rx_pkt_burst = bond_ethdev_rx_burst; internals->mode = mode; return 0; -- 1.7.12.2