From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from prod-mail-xrelay06.akamai.com (prod-mail-xrelay06.akamai.com [96.6.114.98]) by dpdk.org (Postfix) with ESMTP id BBF2F5932 for ; Wed, 20 Aug 2014 22:21:43 +0200 (CEST) Received: from prod-mail-xrelay06.akamai.com (localhost.localdomain [127.0.0.1]) by postfix.imss70 (Postfix) with ESMTP id DB98C1656D0; Wed, 20 Aug 2014 20:25:16 +0000 (GMT) Received: from prod-mail-relay09.akamai.com (prod-mail-relay09.akamai.com [172.27.22.68]) by prod-mail-xrelay06.akamai.com (Postfix) with ESMTP id D0CC31656B1; Wed, 20 Aug 2014 20:25:16 +0000 (GMT) Received: from ustx2ex-cashub.dfw01.corp.akamai.com (ustx2ex-cashub7.dfw01.corp.akamai.com [172.27.25.73]) by prod-mail-relay09.akamai.com (Postfix) with ESMTP id CC57A1E047; Wed, 20 Aug 2014 20:25:16 +0000 (GMT) Received: from USMBX2.msg.corp.akamai.com ([169.254.1.85]) by ustx2ex-cashub7.dfw01.corp.akamai.com ([172.27.25.73]) with mapi; Wed, 20 Aug 2014 15:25:16 -0500 From: "Sanford, Robert" To: Declan Doherty , "dev@dpdk.org" Date: Wed, 20 Aug 2014 15:25:15 -0500 Thread-Topic: [dpdk-dev] [PATCH 2/6] bond: removing switch statement from rx burst method Thread-Index: Ac+8tNpgDRv8tmn0Q7mMNwGvW0Ulfg== Message-ID: References: <1408456313-28812-1-git-send-email-declan.doherty@intel.com> <1408456313-28812-3-git-send-email-declan.doherty@intel.com> In-Reply-To: <1408456313-28812-3-git-send-email-declan.doherty@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Microsoft-MacOutlook/14.4.3.140616 acceptlanguage: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH 2/6] 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: Wed, 20 Aug 2014 20:21:44 -0000 Reviewed-by: Robert Sanford >Splitting rx burst function into seperate functions to avoid the need for >a switch statement and also to match the structure of the tx burst >functions. > >Signed-off-by: Declan Doherty >--- > lib/librte_pmd_bond/rte_eth_bond_pmd.c | 62 >++++++++++++++++++-------------- > 1 files changed, 35 insertions(+), 27 deletions(-) > >diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c >b/lib/librte_pmd_bond/rte_eth_bond_pmd.c >index cd3eecf..683b146 100644 >--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c >+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c >@@ -59,33 +59,37 @@ bond_ethdev_rx_burst(void *queue, struct rte_mbuf >**bufs, uint16_t nb_pkts) >=20 > internals =3D bd_rx_q->dev_private; >=20 >- switch (internals->mode) { >- case BONDING_MODE_ROUND_ROBIN: >- case BONDING_MODE_BROADCAST: >- case BONDING_MODE_BALANCE: >- for (i =3D 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 =3D 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 +=3D num_rx_slave; >- nb_pkts -=3D num_rx_slave; >- } >+ for (i =3D 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 =3D 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 +=3D num_rx_slave; >+ nb_pkts -=3D num_rx_slave; > } >- break; >- case BONDING_MODE_ACTIVE_BACKUP: >- num_rx_slave =3D rte_eth_rx_burst(internals->current_primary_port, >- bd_rx_q->queue_id, bufs, nb_pkts); >- if (num_rx_slave) >- num_rx_total =3D num_rx_slave; >- break; > } >+ > return num_rx_total; > } >=20 > 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 =3D (struct bond_rx_queue *)queue; >+ >+ internals =3D 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; >@@ -134,7 +138,7 @@ bond_ethdev_tx_round_robin(void *queue, struct >rte_mbuf **bufs, > } >=20 > 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; >@@ -270,7 +274,8 @@ xmit_slave_hash(const struct rte_mbuf *buf, uint8_t >slave_count, uint8_t policy) > } >=20 > 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; >@@ -480,22 +485,25 @@ bond_ethdev_mode_set(struct rte_eth_dev *eth_dev, >int mode) >=20 > switch (mode) { > case BONDING_MODE_ROUND_ROBIN: >- eth_dev->tx_pkt_burst =3D bond_ethdev_tx_round_robin; >+ eth_dev->tx_pkt_burst =3D bond_ethdev_tx_burst_round_robin; >+ eth_dev->rx_pkt_burst =3D bond_ethdev_rx_burst; > break; > case BONDING_MODE_ACTIVE_BACKUP: >- eth_dev->tx_pkt_burst =3D bond_ethdev_tx_active_backup; >+ eth_dev->tx_pkt_burst =3D bond_ethdev_tx_burst_active_backup; >+ eth_dev->rx_pkt_burst =3D bond_ethdev_rx_burst_active_backup; > break; > case BONDING_MODE_BALANCE: >- eth_dev->tx_pkt_burst =3D bond_ethdev_tx_balance; >+ eth_dev->tx_pkt_burst =3D bond_ethdev_tx_burst_balance; >+ eth_dev->rx_pkt_burst =3D bond_ethdev_rx_burst; > break; > case BONDING_MODE_BROADCAST: > eth_dev->tx_pkt_burst =3D bond_ethdev_tx_burst_broadcast; >+ eth_dev->rx_pkt_burst =3D bond_ethdev_rx_burst; > break; > default: > return -1; > } >=20 >- eth_dev->rx_pkt_burst =3D bond_ethdev_rx_burst; > internals->mode =3D mode; >=20 > return 0; >--=20 >1.7.0.7 >