b->source = source;
dp_packet_reset_offsets(b);
pkt_metadata_init(&b->md, 0);
- dp_packet_rss_invalidate(b);
- dp_packet_mbuf_init(b);
dp_packet_reset_cutlen(b);
+ dp_packet_reset_offload(b);
+ /* Initialize implementation-specific fields of dp_packet. */
+ dp_packet_init_specific(b);
/* By default assume the packet type to be Ethernet. */
b->packet_type = htonl(PT_ETH);
}
#ifdef DPDK_NETDEV
new_buffer->mbuf.ol_flags = buffer->mbuf.ol_flags;
-#else
- new_buffer->rss_hash_valid = buffer->rss_hash_valid;
#endif
- if (dp_packet_rss_valid(new_buffer)) {
-#ifdef DPDK_NETDEV
- new_buffer->mbuf.hash.rss = buffer->mbuf.hash.rss;
-#else
- new_buffer->rss_hash = buffer->rss_hash;
-#endif
+ if (dp_packet_rss_valid(buffer)) {
+ dp_packet_set_rss_hash(new_buffer, dp_packet_get_rss_hash(buffer));
}
return new_buffer;
#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).
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'. */
#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)
{
}
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. */
-static inline void
-dp_packet_mbuf_init(struct dp_packet *p)
+dp_packet_reset_offload(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
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)
{
}
#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)
{
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;
-}
-
-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)
-{
+ return p->ol_flags & DP_PACKET_OL_RSS_HASH_MASK;
}
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
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)
struct dp_packet *packet;
/* When using 'dpdkr' and sending to a DPDK ring, we want to ensure that
- * the rss hash field is clear. This is because the same mbuf may be
+ * the offload fields are clear. This is because the same mbuf may be
* modified by the consumer of the ring and return into the datapath
- * without recalculating the RSS hash. */
+ * without recalculating the RSS hash or revalidating the checksums. */
DP_PACKET_BATCH_FOR_EACH (i, packet, batch) {
- dp_packet_mbuf_rss_flag_reset(packet);
+ dp_packet_reset_offload(packet);
}
netdev_dpdk_send__(dev, qid, batch, concurrent_txq);
DP_PACKET_BATCH_REFILL_FOR_EACH (i, size, packet, batch) {
packet = netdev->netdev_class->pop_header(packet);
if (packet) {
- /* Reset the checksum offload flags if present, to avoid wrong
+ /* Reset the offload flags if present, to avoid wrong
* interpretation in the further packet processing when
* recirculated.*/
- reset_dp_packet_checksum_ol_flags(packet);
+ dp_packet_reset_offload(packet);
dp_packet_batch_refill(batch, packet, i);
}
}