2
0
mirror of https://github.com/openvswitch/ovs synced 2025-09-02 23:35:27 +00:00

dp-packet: Refactor offloading API.

1. No reason to have mbuf related APIs in a generic code.
2. Not only RSS/checksums should be invalidated in case of tunnel
   decapsulation or sending to 'ring' ports.

In order to fix two above issues, new function
'dp_packet_reset_offload' introduced. In order to clean up/unify
the code and simplify addition of new offloading features to non-DPDK
version of dp_packet, introduced 'ol_flags' bitmask. Additionally
reduced code complexity in 'dp_packet_clone_with_headroom' by using
already existent generic APIs.

Unfortunately, we still need to have a special case for mbuf
initialization inside 'dp_packet_init__()'.
'dp_packet_init_specific()' introduced for this purpose as a generic
API for initialization of the implementation-specific fields.

Acked-by: Flavio Leitner <fbl@sysclose.org>
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
This commit is contained in:
Ilya Maximets
2019-02-26 13:38:37 +03:00
committed by Ian Stokes
parent cae643534e
commit a47e2db209
4 changed files with 41 additions and 59 deletions

View File

@@ -46,6 +46,13 @@ enum OVS_PACKED_ENUM dp_packet_source {
#define DP_PACKET_CONTEXT_SIZE 64
#ifndef DPDK_NETDEV
/* Bit masks for the 'ol_flags' member of the 'dp_packet' structure. */
enum dp_packet_offload_mask {
DP_PACKET_OL_RSS_HASH_MASK = 0x1, /* Is the 'rss_hash' valid? */
};
#endif
/* Buffer for holding packet data. A dp_packet is automatically reallocated
* as necessary if it grows too large for the available memory.
* By default the packet type is set to Ethernet (PT_ETH).
@@ -58,8 +65,8 @@ struct dp_packet {
uint16_t allocated_; /* Number of bytes allocated. */
uint16_t data_ofs; /* First byte actually in use. */
uint32_t size_; /* Number of bytes in use. */
uint32_t ol_flags; /* Offloading flags. */
uint32_t rss_hash; /* Packet hash. */
bool rss_hash_valid; /* Is the 'rss_hash' valid? */
#endif
enum dp_packet_source source; /* Source of memory allocated as 'base'. */
@@ -421,6 +428,16 @@ 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_init_specific(struct dp_packet *p)
{
/* This initialization is needed for packets that do not come from DPDK
* interfaces, when vswitchd is built with --with-dpdk. */
p->mbuf.tx_offload = p->mbuf.packet_type = 0;
p->mbuf.nb_segs = 1;
p->mbuf.next = NULL;
}
static inline void *
dp_packet_base(const struct dp_packet *b)
{
@@ -501,24 +518,9 @@ dp_packet_rss_valid(const struct dp_packet *p)
}
static inline void
dp_packet_rss_invalidate(struct dp_packet *p OVS_UNUSED)
dp_packet_reset_offload(struct dp_packet *p)
{
}
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. */
static inline void
dp_packet_mbuf_init(struct dp_packet *p)
{
p->mbuf.ol_flags = p->mbuf.tx_offload = p->mbuf.packet_type = 0;
p->mbuf.nb_segs = 1;
p->mbuf.next = NULL;
p->mbuf.ol_flags = 0;
}
static inline bool
@@ -549,13 +551,6 @@ dp_packet_l4_checksum_bad(const struct dp_packet *p)
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(const struct dp_packet *p, uint32_t *mark)
{
@@ -568,6 +563,13 @@ dp_packet_has_flow_mark(const struct dp_packet *p, uint32_t *mark)
}
#else /* DPDK_NETDEV */
static inline void
dp_packet_init_specific(struct dp_packet *p OVS_UNUSED)
{
/* There are no implementation-specific fields for initialization. */
}
static inline void *
dp_packet_base(const struct dp_packet *b)
{
@@ -628,29 +630,19 @@ static inline void
dp_packet_set_rss_hash(struct dp_packet *p, uint32_t hash)
{
p->rss_hash = hash;
p->rss_hash_valid = true;
p->ol_flags |= DP_PACKET_OL_RSS_HASH_MASK;
}
static inline bool
dp_packet_rss_valid(const struct dp_packet *p)
{
return p->rss_hash_valid;
return p->ol_flags & DP_PACKET_OL_RSS_HASH_MASK;
}
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)
dp_packet_reset_offload(struct dp_packet *p)
{
p->ol_flags = 0;
}
static inline bool
@@ -677,11 +669,6 @@ dp_packet_l4_checksum_bad(const 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(const struct dp_packet *p OVS_UNUSED,
uint32_t *mark OVS_UNUSED)