2
0
mirror of https://github.com/openvswitch/ovs synced 2025-10-23 14:57:06 +00:00

lib: upgrade to DPDK v1.8.0

DPDK v1.8.0 makes significant changes to struct rte_mbuf, including
removal of the 'pkt' and 'data' fields. The latter, formally a
pointer, is now calculated via an offset from the start of the
segment buffer.  So now dp_packet data is also stored as offset
from base pointer.

Signed-off-by: Mark Kavanagh <mark.b.kavanagh@intel.com>
Signed-off-by: Rory Sexton <rory.sexton@intel.com>
Signed-off-by: Kevin Traynor <kevin.traynor@intel.com>
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
This commit is contained in:
Mark Kavanagh
2015-02-17 13:20:04 -08:00
committed by Pravin B Shelar
parent 09c28fa321
commit b8e57534ec
4 changed files with 72 additions and 56 deletions

View File

@@ -60,9 +60,9 @@ struct dp_packet {
#ifdef DPDK_NETDEV
struct rte_mbuf mbuf; /* DPDK mbuf */
#else
void *base_; /* First byte of allocated space. */
void *data_; /* First byte actually in use. */
uint32_t size_; /* Number of bytes in use. */
void *base_; /* First byte of allocated space. */
uint16_t data_ofs; /* First byte actually in use. */
uint32_t size_; /* Number of bytes in use. */
uint32_t dp_hash; /* Packet hash. */
#endif
uint32_t allocated; /* Number of bytes allocated. */
@@ -382,16 +382,6 @@ static inline const void *dp_packet_get_nd_payload(const struct dp_packet *b)
#ifdef DPDK_NETDEV
BUILD_ASSERT_DECL(offsetof(struct dp_packet, mbuf) == 0);
static inline void * dp_packet_data(const struct dp_packet *b)
{
return b->mbuf.pkt.data;
}
static inline void dp_packet_set_data(struct dp_packet *b, void *d)
{
b->mbuf.pkt.data = d;
}
static inline void * dp_packet_base(const struct dp_packet *b)
{
return b->mbuf.buf_addr;
@@ -404,27 +394,41 @@ static inline void dp_packet_set_base(struct dp_packet *b, void *d)
static inline uint32_t dp_packet_size(const struct dp_packet *b)
{
return b->mbuf.pkt.pkt_len;
return b->mbuf.pkt_len;
}
static inline void dp_packet_set_size(struct dp_packet *b, uint32_t v)
{
b->mbuf.pkt.data_len = v; /* Current seg length. */
b->mbuf.pkt.pkt_len = v; /* Total length of all segments linked to
* this segment. */
/* netdev-dpdk does not currently support segmentation; consequently, for
* all intents and purposes, 'data_len' (16 bit) and 'pkt_len' (32 bit) may
* be used interchangably.
*
* On the datapath, it is expected that the size of packets
* (and thus 'v') will always be <= UINT16_MAX; this means that there is no
* loss of accuracy in assigning 'v' to 'data_len'.
*
* However, control ofpbufs may well be larger than UINT16_MAX (i.e. 'v' >
* UINT16_MAX); even though the value is truncated when assigned to
* 'data_len', loss of accuracy is avoided in this situation by using
* 'pkt_len' to represent the packet size.
*/
b->mbuf.data_len = (uint16_t)v; /* Current seg length. */
b->mbuf.pkt_len = v; /* Total length of all segments linked to
* this segment. */
}
static inline uint16_t __packet_data(const struct dp_packet *b)
{
return b->mbuf.data_off;
}
static inline void __packet_set_data(struct dp_packet *b, uint16_t v)
{
b->mbuf.data_off = v;
}
#else
static inline void * dp_packet_data(const struct dp_packet *b)
{
return b->data_;
}
static inline void dp_packet_set_data(struct dp_packet *b, void *d)
{
b->data_ = d;
}
static inline void * dp_packet_base(const struct dp_packet *b)
{
return b->base_;
@@ -444,8 +448,34 @@ static inline void dp_packet_set_size(struct dp_packet *b, uint32_t v)
{
b->size_ = v;
}
static inline uint16_t __packet_data(const struct dp_packet *b)
{
return b->data_ofs;
}
static inline void __packet_set_data(struct dp_packet *b, uint16_t v)
{
b->data_ofs = v;
}
#endif
static inline void * dp_packet_data(const struct dp_packet *b)
{
return __packet_data(b) != UINT16_MAX ?
(char *)dp_packet_base(b) + __packet_data(b) : NULL;
}
static inline void dp_packet_set_data(struct dp_packet *b, void *data)
{
if (data) {
__packet_set_data(b, (char *)data - (char *)dp_packet_base(b));
} else {
__packet_set_data(b, UINT16_MAX);
}
}
static inline void dp_packet_reset_packet(struct dp_packet *b, int off)
{
dp_packet_set_size(b, dp_packet_size(b) - off);
@@ -457,7 +487,7 @@ static inline void dp_packet_reset_packet(struct dp_packet *b, int off)
static inline uint32_t dp_packet_get_dp_hash(struct dp_packet *p)
{
#ifdef DPDK_NETDEV
return p->mbuf.pkt.hash.rss;
return p->mbuf.hash.rss;
#else
return p->dp_hash;
#endif
@@ -467,7 +497,7 @@ static inline void dp_packet_set_dp_hash(struct dp_packet *p,
uint32_t hash)
{
#ifdef DPDK_NETDEV
p->mbuf.pkt.hash.rss = hash;
p->mbuf.hash.rss = hash;
#else
p->dp_hash = hash;
#endif