diff mbox

[dpdk-dev,v3,08/10] vmxnet3: get rid of DEBUG ifdefs

Message ID 1425600635-20628-9-git-send-email-stephen@networkplumber.org (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Stephen Hemminger March 6, 2015, 12:10 a.m. UTC
By defining macro as a stub it is possible to get rid of #ifdef's
in the actual code. Always evaluate the argument (even in the stub)
so that there are no extra unused variable errors.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/librte_pmd_vmxnet3/vmxnet3_ethdev.h |  6 ++++--
 lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c   | 13 ++-----------
 2 files changed, 6 insertions(+), 13 deletions(-)

Comments

Yong Wang March 6, 2015, 9:59 p.m. UTC | #1
On 3/5/15, 4:10 PM, "Stephen Hemminger" <stephen@networkplumber.org> wrote:

>By defining macro as a stub it is possible to get rid of #ifdef's

>in the actual code. Always evaluate the argument (even in the stub)

>so that there are no extra unused variable errors.

>

>Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>


Acked-by: Yong Wang <yongwang@vmware.com>


>---

> lib/librte_pmd_vmxnet3/vmxnet3_ethdev.h |  6 ++++--

> lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c   | 13 ++-----------

> 2 files changed, 6 insertions(+), 13 deletions(-)

>

>diff --git a/lib/librte_pmd_vmxnet3/vmxnet3_ethdev.h

>b/lib/librte_pmd_vmxnet3/vmxnet3_ethdev.h

>index 83182e2..1c0d95f 100644

>--- a/lib/librte_pmd_vmxnet3/vmxnet3_ethdev.h

>+++ b/lib/librte_pmd_vmxnet3/vmxnet3_ethdev.h

>@@ -35,9 +35,11 @@

> #define _VMXNET3_ETHDEV_H_

> 

> #ifdef RTE_LIBRTE_VMXNET3_DEBUG_DRIVER

>-#define VMXNET3_ASSERT(x) do { \

>-	if (!(x)) rte_panic("VMXNET3: x"); \

>+#define VMXNET3_ASSERT(x) do {					\

>+	if (unlikely(!(x))) rte_panic("VMXNET3: %s\n", #x);	\

> } while(0)

>+#else

>+#define VMXNET3_ASSERT(x) do { (void)(x); } while (0)

> #endif

> 

> #define VMXNET3_MAX_MAC_ADDRS 1

>diff --git a/lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c

>b/lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c

>index 5cf187a..3bd13ef 100644

>--- a/lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c

>+++ b/lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c

>@@ -307,9 +307,7 @@ vmxnet3_tq_tx_complete(vmxnet3_tx_queue_t *txq)

> 

> 	while (tcd->gen == comp_ring->gen) {

> 		/* Release cmd_ring descriptor and free mbuf */

>-#ifdef RTE_LIBRTE_VMXNET3_DEBUG_DRIVER

> 		VMXNET3_ASSERT(txq->cmd_ring.base[tcd->txdIdx].txd.eop == 1);

>-#endif

> 

> 		while (txq->cmd_ring.next2comp != tcd->txdIdx) {

> 			mbuf = txq->cmd_ring.buf_info[txq->cmd_ring.next2comp].m;

>@@ -570,6 +568,7 @@ vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf

>**rx_pkts, uint16_t nb_pkts)

> 	uint8_t ring_idx;

> 	vmxnet3_rx_queue_t *rxq;

> 	Vmxnet3_RxCompDesc *rcd;

>+	Vmxnet3_RxDesc *rxd;

> 	vmxnet3_buf_info_t *rbi;

> 	struct rte_mbuf *rxm = NULL;

> 	struct vmxnet3_hw *hw;

>@@ -596,16 +595,12 @@ vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf

>**rx_pkts, uint16_t nb_pkts)

> 		idx = rcd->rxdIdx;

> 		ring_idx = (uint8_t)((rcd->rqID == rxq->qid1) ? 0 : 1);

> 		rbi = rxq->cmd_ring[ring_idx].buf_info + idx;

>-

>+		rxd = (Vmxnet3_RxDesc *)rxq->cmd_ring[ring_idx].base + idx;

> 

> 		PMD_RX_LOG(DEBUG, "rxd idx: %d ring idx: %d.", idx, ring_idx);

> 

>-#ifdef RTE_LIBRTE_VMXNET3_DEBUG_DRIVER

>-		Vmxnet3_RxDesc *rxd

>-			= (Vmxnet3_RxDesc *)rxq->cmd_ring[ring_idx].base + idx;

> 		VMXNET3_ASSERT(rcd->len <= rxd->len);

> 		VMXNET3_ASSERT(rbi->m);

>-#endif

> 

> 		/* Get the packet buffer pointer from buf_info */

> 		rxm = rbi->m;

>@@ -652,10 +647,8 @@ vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf

>**rx_pkts, uint16_t nb_pkts)

> 		 * the last mbuf of the current packet.

> 		 */

> 		if (rcd->sop) {

>-#ifdef RTE_LIBRTE_VMXNET3_DEBUG_DRIVER

> 			VMXNET3_ASSERT(!rxq->start_seg);

> 			VMXNET3_ASSERT(rxd->btype == VMXNET3_RXD_BTYPE_HEAD);

>-#endif

> 

> 			if (unlikely(rcd->len == 0)) {

> 				PMD_RX_LOG(DEBUG,

>@@ -670,10 +663,8 @@ vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf

>**rx_pkts, uint16_t nb_pkts)

> 		} else {

> 			struct rte_mbuf *start = rxq->start_seg;

> 

>-#ifdef RTE_LIBRTE_VMXNET3_DEBUG_DRIVER

> 			VMXNET3_ASSERT(rxd->btype == VMXNET3_RXD_BTYPE_BODY);

> 			VMXNET3_ASSERT(start != NULL);

>-#endif

> 

> 			start->pkt_len += rxm->data_len;

> 			start->nb_segs++;

>-- 

>2.1.4

>
diff mbox

Patch

diff --git a/lib/librte_pmd_vmxnet3/vmxnet3_ethdev.h b/lib/librte_pmd_vmxnet3/vmxnet3_ethdev.h
index 83182e2..1c0d95f 100644
--- a/lib/librte_pmd_vmxnet3/vmxnet3_ethdev.h
+++ b/lib/librte_pmd_vmxnet3/vmxnet3_ethdev.h
@@ -35,9 +35,11 @@ 
 #define _VMXNET3_ETHDEV_H_
 
 #ifdef RTE_LIBRTE_VMXNET3_DEBUG_DRIVER
-#define VMXNET3_ASSERT(x) do { \
-	if (!(x)) rte_panic("VMXNET3: x"); \
+#define VMXNET3_ASSERT(x) do {					\
+	if (unlikely(!(x))) rte_panic("VMXNET3: %s\n", #x);	\
 } while(0)
+#else
+#define VMXNET3_ASSERT(x) do { (void)(x); } while (0)
 #endif
 
 #define VMXNET3_MAX_MAC_ADDRS 1
diff --git a/lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c b/lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c
index 5cf187a..3bd13ef 100644
--- a/lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c
+++ b/lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c
@@ -307,9 +307,7 @@  vmxnet3_tq_tx_complete(vmxnet3_tx_queue_t *txq)
 
 	while (tcd->gen == comp_ring->gen) {
 		/* Release cmd_ring descriptor and free mbuf */
-#ifdef RTE_LIBRTE_VMXNET3_DEBUG_DRIVER
 		VMXNET3_ASSERT(txq->cmd_ring.base[tcd->txdIdx].txd.eop == 1);
-#endif
 
 		while (txq->cmd_ring.next2comp != tcd->txdIdx) {
 			mbuf = txq->cmd_ring.buf_info[txq->cmd_ring.next2comp].m;
@@ -570,6 +568,7 @@  vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 	uint8_t ring_idx;
 	vmxnet3_rx_queue_t *rxq;
 	Vmxnet3_RxCompDesc *rcd;
+	Vmxnet3_RxDesc *rxd;
 	vmxnet3_buf_info_t *rbi;
 	struct rte_mbuf *rxm = NULL;
 	struct vmxnet3_hw *hw;
@@ -596,16 +595,12 @@  vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 		idx = rcd->rxdIdx;
 		ring_idx = (uint8_t)((rcd->rqID == rxq->qid1) ? 0 : 1);
 		rbi = rxq->cmd_ring[ring_idx].buf_info + idx;
-
+		rxd = (Vmxnet3_RxDesc *)rxq->cmd_ring[ring_idx].base + idx;
 
 		PMD_RX_LOG(DEBUG, "rxd idx: %d ring idx: %d.", idx, ring_idx);
 
-#ifdef RTE_LIBRTE_VMXNET3_DEBUG_DRIVER
-		Vmxnet3_RxDesc *rxd
-			= (Vmxnet3_RxDesc *)rxq->cmd_ring[ring_idx].base + idx;
 		VMXNET3_ASSERT(rcd->len <= rxd->len);
 		VMXNET3_ASSERT(rbi->m);
-#endif
 
 		/* Get the packet buffer pointer from buf_info */
 		rxm = rbi->m;
@@ -652,10 +647,8 @@  vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 		 * the last mbuf of the current packet.
 		 */
 		if (rcd->sop) {
-#ifdef RTE_LIBRTE_VMXNET3_DEBUG_DRIVER
 			VMXNET3_ASSERT(!rxq->start_seg);
 			VMXNET3_ASSERT(rxd->btype == VMXNET3_RXD_BTYPE_HEAD);
-#endif
 
 			if (unlikely(rcd->len == 0)) {
 				PMD_RX_LOG(DEBUG,
@@ -670,10 +663,8 @@  vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 		} else {
 			struct rte_mbuf *start = rxq->start_seg;
 
-#ifdef RTE_LIBRTE_VMXNET3_DEBUG_DRIVER
 			VMXNET3_ASSERT(rxd->btype == VMXNET3_RXD_BTYPE_BODY);
 			VMXNET3_ASSERT(start != NULL);
-#endif
 
 			start->pkt_len += rxm->data_len;
 			start->nb_segs++;