2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 14:25:26 +00:00

dp-packet.h: move funcs to be within cond block

There is already an ifdef DPDK_NETDEV block, so instead of checking
on each and every function, move them to the right block.

No functional change.

Signed-off-by: Flavio Leitner <fbl@sysclose.org>
Acked-by: Tiago Lam <tiago.lam@intel.com>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
This commit is contained in:
Flavio Leitner
2018-09-25 18:08:04 -03:00
committed by Ian Stokes
parent 4617d1f6bd
commit e52ad72157

View File

@@ -465,7 +465,96 @@ dp_packet_set_allocated(struct dp_packet *b, uint16_t s)
{
b->mbuf.buf_len = s;
}
#else
/* Returns the RSS hash of the packet 'p'. Note that the returned value is
* correct only if 'dp_packet_rss_valid(p)' returns true */
static inline uint32_t
dp_packet_get_rss_hash(struct dp_packet *p)
{
return p->mbuf.hash.rss;
}
static inline void
dp_packet_set_rss_hash(struct dp_packet *p, uint32_t hash)
{
p->mbuf.hash.rss = hash;
p->mbuf.ol_flags |= PKT_RX_RSS_HASH;
}
static inline bool
dp_packet_rss_valid(struct dp_packet *p)
{
return p->mbuf.ol_flags & PKT_RX_RSS_HASH;
}
static inline void
dp_packet_rss_invalidate(struct dp_packet *p OVS_UNUSED)
{
}
static inline void
dp_packet_mbuf_rss_flag_reset(struct dp_packet *p)
{
p->mbuf.ol_flags &= ~PKT_RX_RSS_HASH;
}
/* This initialization is needed for packets that do not come
* from DPDK interfaces, when vswitchd is built with --with-dpdk.
* The DPDK rte library will still otherwise manage the mbuf.
* We only need to initialize the mbuf ol_flags. */
static inline void
dp_packet_mbuf_init(struct dp_packet *p)
{
p->mbuf.ol_flags = 0;
}
static inline bool
dp_packet_ip_checksum_valid(struct dp_packet *p)
{
return (p->mbuf.ol_flags & PKT_RX_IP_CKSUM_MASK) ==
PKT_RX_IP_CKSUM_GOOD;
}
static inline bool
dp_packet_ip_checksum_bad(struct dp_packet *p)
{
return (p->mbuf.ol_flags & PKT_RX_IP_CKSUM_MASK) ==
PKT_RX_IP_CKSUM_BAD;
}
static inline bool
dp_packet_l4_checksum_valid(struct dp_packet *p)
{
return (p->mbuf.ol_flags & PKT_RX_L4_CKSUM_MASK) ==
PKT_RX_L4_CKSUM_GOOD;
}
static inline bool
dp_packet_l4_checksum_bad(struct dp_packet *p)
{
return (p->mbuf.ol_flags & PKT_RX_L4_CKSUM_MASK) ==
PKT_RX_L4_CKSUM_BAD;
}
static inline void
reset_dp_packet_checksum_ol_flags(struct dp_packet *p)
{
p->mbuf.ol_flags &= ~(PKT_RX_L4_CKSUM_GOOD | PKT_RX_L4_CKSUM_BAD |
PKT_RX_IP_CKSUM_GOOD | PKT_RX_IP_CKSUM_BAD);
}
static inline bool
dp_packet_has_flow_mark(struct dp_packet *p, uint32_t *mark)
{
if (p->mbuf.ol_flags & PKT_RX_FDIR_ID) {
*mark = p->mbuf.hash.fdir.hi;
return true;
}
return false;
}
#else /* DPDK_NETDEV */
static inline void *
dp_packet_base(const struct dp_packet *b)
{
@@ -513,7 +602,80 @@ dp_packet_set_allocated(struct dp_packet *b, uint16_t s)
{
b->allocated_ = s;
}
#endif
/* Returns the RSS hash of the packet 'p'. Note that the returned value is
* correct only if 'dp_packet_rss_valid(p)' returns true */
static inline uint32_t
dp_packet_get_rss_hash(struct dp_packet *p)
{
return p->rss_hash;
}
static inline void
dp_packet_set_rss_hash(struct dp_packet *p, uint32_t hash)
{
p->rss_hash = hash;
p->rss_hash_valid = true;
}
static inline bool
dp_packet_rss_valid(struct dp_packet *p)
{
return p->rss_hash_valid;
}
static inline void
dp_packet_rss_invalidate(struct dp_packet *p)
{
p->rss_hash_valid = false;
}
static inline void
dp_packet_mbuf_rss_flag_reset(struct dp_packet *p OVS_UNUSED)
{
}
static inline void
dp_packet_mbuf_init(struct dp_packet *p OVS_UNUSED)
{
}
static inline bool
dp_packet_ip_checksum_valid(struct dp_packet *p OVS_UNUSED)
{
return false;
}
static inline bool
dp_packet_ip_checksum_bad(struct dp_packet *p OVS_UNUSED)
{
return false;
}
static inline bool
dp_packet_l4_checksum_valid(struct dp_packet *p OVS_UNUSED)
{
return false;
}
static inline bool
dp_packet_l4_checksum_bad(struct dp_packet *p OVS_UNUSED)
{
return false;
}
static inline void
reset_dp_packet_checksum_ol_flags(struct dp_packet *p OVS_UNUSED)
{
}
static inline bool
dp_packet_has_flow_mark(struct dp_packet *p OVS_UNUSED,
uint32_t *mark OVS_UNUSED)
{
return false;
}
#endif /* DPDK_NETDEV */
static inline void
dp_packet_reset_cutlen(struct dp_packet *b)
@@ -574,136 +736,6 @@ dp_packet_reset_packet(struct dp_packet *b, int off)
dp_packet_reset_offsets(b);
}
/* Returns the RSS hash of the packet 'p'. Note that the returned value is
* correct only if 'dp_packet_rss_valid(p)' returns true */
static inline uint32_t
dp_packet_get_rss_hash(struct dp_packet *p)
{
#ifdef DPDK_NETDEV
return p->mbuf.hash.rss;
#else
return p->rss_hash;
#endif
}
static inline void
dp_packet_set_rss_hash(struct dp_packet *p, uint32_t hash)
{
#ifdef DPDK_NETDEV
p->mbuf.hash.rss = hash;
p->mbuf.ol_flags |= PKT_RX_RSS_HASH;
#else
p->rss_hash = hash;
p->rss_hash_valid = true;
#endif
}
static inline bool
dp_packet_rss_valid(struct dp_packet *p)
{
#ifdef DPDK_NETDEV
return p->mbuf.ol_flags & PKT_RX_RSS_HASH;
#else
return p->rss_hash_valid;
#endif
}
static inline void
dp_packet_rss_invalidate(struct dp_packet *p OVS_UNUSED)
{
#ifndef DPDK_NETDEV
p->rss_hash_valid = false;
#endif
}
static inline void
dp_packet_mbuf_rss_flag_reset(struct dp_packet *p OVS_UNUSED)
{
#ifdef DPDK_NETDEV
p->mbuf.ol_flags &= ~PKT_RX_RSS_HASH;
#endif
}
/* This initialization is needed for packets that do not come
* from DPDK interfaces, when vswitchd is built with --with-dpdk.
* The DPDK rte library will still otherwise manage the mbuf.
* We only need to initialize the mbuf ol_flags. */
static inline void
dp_packet_mbuf_init(struct dp_packet *p OVS_UNUSED)
{
#ifdef DPDK_NETDEV
p->mbuf.ol_flags = 0;
#endif
}
static inline bool
dp_packet_ip_checksum_valid(struct dp_packet *p OVS_UNUSED)
{
#ifdef DPDK_NETDEV
return (p->mbuf.ol_flags & PKT_RX_IP_CKSUM_MASK) ==
PKT_RX_IP_CKSUM_GOOD;
#else
return false;
#endif
}
static inline bool
dp_packet_ip_checksum_bad(struct dp_packet *p OVS_UNUSED)
{
#ifdef DPDK_NETDEV
return (p->mbuf.ol_flags & PKT_RX_IP_CKSUM_MASK) ==
PKT_RX_IP_CKSUM_BAD;
#else
return false;
#endif
}
static inline bool
dp_packet_l4_checksum_valid(struct dp_packet *p OVS_UNUSED)
{
#ifdef DPDK_NETDEV
return (p->mbuf.ol_flags & PKT_RX_L4_CKSUM_MASK) ==
PKT_RX_L4_CKSUM_GOOD;
#else
return false;
#endif
}
static inline bool
dp_packet_l4_checksum_bad(struct dp_packet *p OVS_UNUSED)
{
#ifdef DPDK_NETDEV
return (p->mbuf.ol_flags & PKT_RX_L4_CKSUM_MASK) ==
PKT_RX_L4_CKSUM_BAD;
#else
return false;
#endif
}
#ifdef DPDK_NETDEV
static inline void
reset_dp_packet_checksum_ol_flags(struct dp_packet *p)
{
p->mbuf.ol_flags &= ~(PKT_RX_L4_CKSUM_GOOD | PKT_RX_L4_CKSUM_BAD |
PKT_RX_IP_CKSUM_GOOD | PKT_RX_IP_CKSUM_BAD);
}
#else
#define reset_dp_packet_checksum_ol_flags(arg)
#endif
static inline bool
dp_packet_has_flow_mark(struct dp_packet *p OVS_UNUSED,
uint32_t *mark OVS_UNUSED)
{
#ifdef DPDK_NETDEV
if (p->mbuf.ol_flags & PKT_RX_FDIR_ID) {
*mark = p->mbuf.hash.fdir.hi;
return true;
}
#endif
return false;
}
enum { NETDEV_MAX_BURST = 32 }; /* Maximum number packets in a batch. */
struct dp_packet_batch {