* [dpdk-dev] [PATCH v2] Move rte_mbuf macros to common header file
@ 2015-09-30 19:18 Ravi Kerur
2015-09-30 19:41 ` Aaron Conole
0 siblings, 1 reply; 3+ messages in thread
From: Ravi Kerur @ 2015-09-30 19:18 UTC (permalink / raw)
To: dev
Macros RTE_MBUF_DATA_DMA_ADDR and RTE_MBUF_DATA_DMA_ADDR_DEFAULT
are defined in each PMD driver file. Move those macros into common
lib/librte_mbuf/rte_mbuf.h file. PMD drivers include rte_mbuf.h
file directly/indirectly hence no additionl header file inclusion
is necessary.
v2:
> Changed both macros to inline functions in all PMD
> Changed macro to rte_pktmbuf_mtod in xenvirt module
v1:
> Move macros into common rte_mbuf header file.
Compiled for:
> x86_64-native-linuxapp-clang
> x86_64-native-linuxapp-gcc
> i686-native-linuxapp-gcc
> x86_64-native-bsdapp-gcc
> x86_64-native-bsdapp-clang
Tested on:
> x86_64 Ubuntu 14.04, testpmd and 'make test'
> FreeBSD 10.1, testpmd
Signed-off-by: Ravi Kerur <rkerur@gmail.com>
---
drivers/net/bnx2x/bnx2x.h | 3 ---
drivers/net/cxgbe/sge.c | 3 ---
drivers/net/e1000/em_rxtx.c | 6 ------
drivers/net/e1000/igb_rxtx.c | 6 ------
drivers/net/i40e/i40e_rxtx.c | 6 ------
drivers/net/ixgbe/ixgbe_rxtx.h | 6 ------
drivers/net/virtio/virtqueue.h | 3 ---
drivers/net/vmxnet3/vmxnet3_rxtx.c | 6 ------
drivers/net/xenvirt/virtqueue.h | 5 +----
lib/librte_mbuf/rte_mbuf.h | 10 ++++++++++
10 files changed, 11 insertions(+), 43 deletions(-)
diff --git a/drivers/net/bnx2x/bnx2x.h b/drivers/net/bnx2x/bnx2x.h
index 867b92a..28bd83f 100644
--- a/drivers/net/bnx2x/bnx2x.h
+++ b/drivers/net/bnx2x/bnx2x.h
@@ -141,9 +141,6 @@ struct bnx2x_device_type {
char *bnx2x_name;
};
-#define RTE_MBUF_DATA_DMA_ADDR(mb) \
- ((uint64_t)((mb)->buf_physaddr + (mb)->data_off))
-
#define BNX2X_PAGE_SHIFT 12
#define BNX2X_PAGE_SIZE (1 << BNX2X_PAGE_SHIFT)
#define BNX2X_PAGE_MASK (~(BNX2X_PAGE_SIZE - 1))
diff --git a/drivers/net/cxgbe/sge.c b/drivers/net/cxgbe/sge.c
index 6eb1244..8f4c025 100644
--- a/drivers/net/cxgbe/sge.c
+++ b/drivers/net/cxgbe/sge.c
@@ -1267,9 +1267,6 @@ static struct rte_mbuf *t4_pktgl_to_mbuf(const struct pkt_gl *gl)
return t4_pktgl_to_mbuf_usembufs(gl);
}
-#define RTE_MBUF_DATA_DMA_ADDR_DEFAULT(mb) \
- ((dma_addr_t) ((mb)->buf_physaddr + (mb)->data_off))
-
/**
* t4_ethrx_handler - process an ingress ethernet packet
* @q: the response queue that received the packet
diff --git a/drivers/net/e1000/em_rxtx.c b/drivers/net/e1000/em_rxtx.c
index 3b8776d..c7d97c1 100644
--- a/drivers/net/e1000/em_rxtx.c
+++ b/drivers/net/e1000/em_rxtx.c
@@ -88,12 +88,6 @@ rte_rxmbuf_alloc(struct rte_mempool *mp)
return (m);
}
-#define RTE_MBUF_DATA_DMA_ADDR(mb) \
- (uint64_t) ((mb)->buf_physaddr + (mb)->data_off)
-
-#define RTE_MBUF_DATA_DMA_ADDR_DEFAULT(mb) \
- (uint64_t) ((mb)->buf_physaddr + RTE_PKTMBUF_HEADROOM)
-
/**
* Structure associated with each descriptor of the RX ring of a RX queue.
*/
diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c
index 19905fd..a217cea 100644
--- a/drivers/net/e1000/igb_rxtx.c
+++ b/drivers/net/e1000/igb_rxtx.c
@@ -88,12 +88,6 @@ rte_rxmbuf_alloc(struct rte_mempool *mp)
return (m);
}
-#define RTE_MBUF_DATA_DMA_ADDR(mb) \
- (uint64_t) ((mb)->buf_physaddr + (mb)->data_off)
-
-#define RTE_MBUF_DATA_DMA_ADDR_DEFAULT(mb) \
- (uint64_t) ((mb)->buf_physaddr + RTE_PKTMBUF_HEADROOM)
-
/**
* Structure associated with each descriptor of the RX ring of a RX queue.
*/
diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index fd656d5..5ba6d27 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -78,12 +78,6 @@
PKT_TX_L4_MASK | \
PKT_TX_OUTER_IP_CKSUM)
-#define RTE_MBUF_DATA_DMA_ADDR_DEFAULT(mb) \
- (uint64_t) ((mb)->buf_physaddr + RTE_PKTMBUF_HEADROOM)
-
-#define RTE_MBUF_DATA_DMA_ADDR(mb) \
- ((uint64_t)((mb)->buf_physaddr + (mb)->data_off))
-
static const struct rte_memzone *
i40e_ring_dma_zone_reserve(struct rte_eth_dev *dev,
const char *ring_name,
diff --git a/drivers/net/ixgbe/ixgbe_rxtx.h b/drivers/net/ixgbe/ixgbe_rxtx.h
index b9eca67..dbb9f00 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx.h
+++ b/drivers/net/ixgbe/ixgbe_rxtx.h
@@ -40,12 +40,6 @@
#define RTE_IXGBE_DESCS_PER_LOOP 4
-#define RTE_MBUF_DATA_DMA_ADDR(mb) \
- (uint64_t) ((mb)->buf_physaddr + (mb)->data_off)
-
-#define RTE_MBUF_DATA_DMA_ADDR_DEFAULT(mb) \
- (uint64_t) ((mb)->buf_physaddr + RTE_PKTMBUF_HEADROOM)
-
#ifdef RTE_IXGBE_INC_VECTOR
#define RTE_IXGBE_RXQ_REARM_THRESH 32
#define RTE_IXGBE_MAX_RX_BURST RTE_IXGBE_RXQ_REARM_THRESH
diff --git a/drivers/net/virtio/virtqueue.h b/drivers/net/virtio/virtqueue.h
index 7789411..9ea9b96 100644
--- a/drivers/net/virtio/virtqueue.h
+++ b/drivers/net/virtio/virtqueue.h
@@ -68,9 +68,6 @@ struct rte_mbuf;
#define VIRTQUEUE_MAX_NAME_SZ 32
-#define RTE_MBUF_DATA_DMA_ADDR(mb) \
- (uint64_t) ((mb)->buf_physaddr + (mb)->data_off)
-
#define VTNET_SQ_RQ_QUEUE_IDX 0
#define VTNET_SQ_TQ_QUEUE_IDX 1
#define VTNET_SQ_CQ_QUEUE_IDX 2
diff --git a/drivers/net/vmxnet3/vmxnet3_rxtx.c b/drivers/net/vmxnet3/vmxnet3_rxtx.c
index 4de5d89..bb2648b 100644
--- a/drivers/net/vmxnet3/vmxnet3_rxtx.c
+++ b/drivers/net/vmxnet3/vmxnet3_rxtx.c
@@ -77,12 +77,6 @@
#include "vmxnet3_logs.h"
#include "vmxnet3_ethdev.h"
-#define RTE_MBUF_DATA_DMA_ADDR(mb) \
- (uint64_t) ((mb)->buf_physaddr + (mb)->data_off)
-
-#define RTE_MBUF_DATA_DMA_ADDR_DEFAULT(mb) \
- (uint64_t) ((mb)->buf_physaddr + RTE_PKTMBUF_HEADROOM)
-
static const uint32_t rxprod_reg[2] = {VMXNET3_REG_RXPROD, VMXNET3_REG_RXPROD2};
static int vmxnet3_post_rx_bufs(vmxnet3_rx_queue_t*, uint8_t);
diff --git a/drivers/net/xenvirt/virtqueue.h b/drivers/net/xenvirt/virtqueue.h
index eff6208..c38288e 100644
--- a/drivers/net/xenvirt/virtqueue.h
+++ b/drivers/net/xenvirt/virtqueue.h
@@ -54,9 +54,6 @@ struct rte_mbuf;
* Address translatio is between gva<->hva,
* rather than gpa<->hva in virito spec.
*/
-#define RTE_MBUF_DATA_DMA_ADDR(mb) \
- rte_pktmbuf_mtod(mb, uint64_t)
-
enum { VTNET_RQ = 0, VTNET_TQ = 1, VTNET_CQ = 2 };
/**
@@ -238,7 +235,7 @@ virtqueue_enqueue_xmit(struct virtqueue *txvq, struct rte_mbuf *cookie)
start_dp[idx].flags = VRING_DESC_F_NEXT;
start_dp[idx].addr = (uintptr_t)NULL;
idx = start_dp[idx].next;
- start_dp[idx].addr = RTE_MBUF_DATA_DMA_ADDR(cookie);
+ start_dp[idx].addr = rte_pktmbuf_mtod(cookie, uint64_t);
start_dp[idx].len = cookie->data_len;
start_dp[idx].flags = 0;
idx = start_dp[idx].next;
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index d7c9030..52c8127 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -843,6 +843,16 @@ struct rte_mbuf {
uint16_t timesync;
} __rte_cache_aligned;
+static inline uint64_t RTE_MBUF_DATA_DMA_ADDR(struct rte_mbuf* mb)
+{
+ return ((uint64_t)((mb)->buf_physaddr + (mb)->data_off));
+}
+
+static inline uint64_t RTE_MBUF_DATA_DMA_ADDR_DEFAULT(struct rte_mbuf *mb)
+{
+ return ((uint64_t)((mb)->buf_physaddr + RTE_PKTMBUF_HEADROOM));
+}
+
static inline uint16_t rte_pktmbuf_priv_size(struct rte_mempool *mp);
/**
--
1.9.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [dpdk-dev] [PATCH v2] Move rte_mbuf macros to common header file
2015-09-30 19:18 [dpdk-dev] [PATCH v2] Move rte_mbuf macros to common header file Ravi Kerur
@ 2015-09-30 19:41 ` Aaron Conole
2015-09-30 21:55 ` Ravi Kerur
0 siblings, 1 reply; 3+ messages in thread
From: Aaron Conole @ 2015-09-30 19:41 UTC (permalink / raw)
To: Ravi Kerur; +Cc: dev
Ravi Kerur <rkerur@gmail.com> writes:
> Macros RTE_MBUF_DATA_DMA_ADDR and RTE_MBUF_DATA_DMA_ADDR_DEFAULT
> are defined in each PMD driver file. Move those macros into common
> lib/librte_mbuf/rte_mbuf.h file. PMD drivers include rte_mbuf.h
> file directly/indirectly hence no additionl header file inclusion
> is necessary.
I think this should also mention that they are no longer macros, as
well.
<<snip>>
> --- a/lib/librte_mbuf/rte_mbuf.h
> +++ b/lib/librte_mbuf/rte_mbuf.h
> @@ -843,6 +843,16 @@ struct rte_mbuf {
> uint16_t timesync;
> } __rte_cache_aligned;
>
> +static inline uint64_t RTE_MBUF_DATA_DMA_ADDR(struct rte_mbuf* mb)
> +{
> + return ((uint64_t)((mb)->buf_physaddr + (mb)->data_off));
> +}
> +
> +static inline uint64_t RTE_MBUF_DATA_DMA_ADDR_DEFAULT(struct rte_mbuf *mb)
> +{
> + return ((uint64_t)((mb)->buf_physaddr + RTE_PKTMBUF_HEADROOM));
> +}
> +
I think these names should be made lower case as well.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [dpdk-dev] [PATCH v2] Move rte_mbuf macros to common header file
2015-09-30 19:41 ` Aaron Conole
@ 2015-09-30 21:55 ` Ravi Kerur
0 siblings, 0 replies; 3+ messages in thread
From: Ravi Kerur @ 2015-09-30 21:55 UTC (permalink / raw)
To: Aaron Conole; +Cc: dev
On Wed, Sep 30, 2015 at 12:41 PM, Aaron Conole <aconole@redhat.com> wrote:
> Ravi Kerur <rkerur@gmail.com> writes:
>
> > Macros RTE_MBUF_DATA_DMA_ADDR and RTE_MBUF_DATA_DMA_ADDR_DEFAULT
> > are defined in each PMD driver file. Move those macros into common
> > lib/librte_mbuf/rte_mbuf.h file. PMD drivers include rte_mbuf.h
> > file directly/indirectly hence no additionl header file inclusion
> > is necessary.
> I think this should also mention that they are no longer macros, as
> well.
>
> <<snip>>
> > --- a/lib/librte_mbuf/rte_mbuf.h
> > +++ b/lib/librte_mbuf/rte_mbuf.h
> > @@ -843,6 +843,16 @@ struct rte_mbuf {
> > uint16_t timesync;
> > } __rte_cache_aligned;
> >
> > +static inline uint64_t RTE_MBUF_DATA_DMA_ADDR(struct rte_mbuf* mb)
> > +{
> > + return ((uint64_t)((mb)->buf_physaddr + (mb)->data_off));
> > +}
> > +
> > +static inline uint64_t RTE_MBUF_DATA_DMA_ADDR_DEFAULT(struct rte_mbuf
> *mb)
> > +{
> > + return ((uint64_t)((mb)->buf_physaddr + RTE_PKTMBUF_HEADROOM));
> > +}
> > +
> I think these names should be made lower case as well.
>
Thanks, I was waiting for one explicit input on this. I have sent v3 patch.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-09-30 21:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-30 19:18 [dpdk-dev] [PATCH v2] Move rte_mbuf macros to common header file Ravi Kerur
2015-09-30 19:41 ` Aaron Conole
2015-09-30 21:55 ` Ravi Kerur
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).