if (!is_tso && !(b->flags & VNET_BUFFER_F_OFFLOAD))
return 0;
- u32 oflags = vnet_buffer (b)->oflags;
+ vnet_buffer_oflags_t oflags = vnet_buffer (b)->oflags;
u32 is_tcp = is_tso || oflags & VNET_BUFFER_OFFLOAD_F_TCP_CKSUM;
u32 is_udp = !is_tso && oflags & VNET_BUFFER_OFFLOAD_F_UDP_CKSUM;
u32 is_ip4 = b->flags & VNET_BUFFER_F_IS_IP4;
{
int is_ip4 = b->flags & VNET_BUFFER_F_IS_IP4;
u32 tso = b->flags & VNET_BUFFER_F_GSO, max_pkt_len;
- u32 oflags, ip_cksum, tcp_cksum, udp_cksum;
+ u32 ip_cksum, tcp_cksum, udp_cksum;
u64 ol_flags;
+ vnet_buffer_oflags_t oflags = 0;
/* Is there any work for us? */
if (PREDICT_TRUE (((b->flags & VNET_BUFFER_F_OFFLOAD) | tso) == 0))
u16 gso_size)
{
u8 l4_hdr_sz = 0;
- u32 oflags = 0;
+ vnet_buffer_oflags_t oflags = 0;
if (rx_comp->flags & VMXNET3_RXCF_IP4)
{
STATIC_ASSERT (((VNET_BUFFER_FLAGS_ALL_AVAIL & VLIB_BUFFER_FLAGS_ALL) == 0),
"VLIB / VNET buffer flags overlap");
+#define foreach_vnet_buffer_offload_flag \
+ _ (0, IP_CKSUM, "offload-ip-cksum", 1) \
+ _ (1, TCP_CKSUM, "offload-tcp-cksum", 1) \
+ _ (2, UDP_CKSUM, "offload-udp-cksum", 1) \
+ _ (3, OUTER_IP_CKSUM, "offload-outer-ip-cksum", 1) \
+ _ (4, OUTER_TCP_CKSUM, "offload-outer-tcp-cksum", 1) \
+ _ (5, OUTER_UDP_CKSUM, "offload-outer-udp-cksum", 1)
+
+typedef enum
+{
+#define _(bit, name, s, v) VNET_BUFFER_OFFLOAD_F_##name = (1 << bit),
+ foreach_vnet_buffer_offload_flag
+#undef _
+} vnet_buffer_oflags_t;
+
#define foreach_buffer_opaque_union_subtype \
_(ip) \
_(l2) \
i16 l4_hdr_offset;
u8 feature_arc_index;
/* offload flags */
- u8 oflags;
+ vnet_buffer_oflags_t oflags : 8;
union
{
#define vnet_buffer(b) ((vnet_buffer_opaque_t *) (b)->opaque)
-#define foreach_vnet_buffer_offload_flag \
- _ (0, IP_CKSUM, "offload-ip-cksum", 1) \
- _ (1, TCP_CKSUM, "offload-tcp-cksum", 1) \
- _ (2, UDP_CKSUM, "offload-udp-cksum", 1) \
- _ (3, OUTER_IP_CKSUM, "offload-outer-ip-cksum", 1) \
- _ (4, OUTER_TCP_CKSUM, "offload-outer-tcp-cksum", 1) \
- _ (5, OUTER_UDP_CKSUM, "offload-outer-udp-cksum", 1)
-
-enum
-{
-#define _(bit, name, s, v) VNET_BUFFER_OFFLOAD_F_##name = (1 << bit),
- foreach_vnet_buffer_offload_flag
-#undef _
-};
-
/* Full cache line (64 bytes) of additional space */
typedef struct
{
format_function_t format_vnet_buffer_opaque2;
static_always_inline void
-vnet_buffer_offload_flags_set (vlib_buffer_t *b, u32 oflags)
+vnet_buffer_offload_flags_set (vlib_buffer_t *b, vnet_buffer_oflags_t oflags)
{
if (b->flags & VNET_BUFFER_F_OFFLOAD)
{
}
static_always_inline void
-vnet_buffer_offload_flags_clear (vlib_buffer_t *b, u32 oflags)
+vnet_buffer_offload_flags_clear (vlib_buffer_t *b, vnet_buffer_oflags_t oflags)
{
vnet_buffer (b)->oflags &= ~oflags;
if (0 == vnet_buffer (b)->oflags)
mark_tcp_udp_cksum_calc (vlib_buffer_t *b, u8 *l4_hdr_sz)
{
ethernet_header_t *eth = vlib_buffer_get_current (b);
- u32 oflags = 0;
+ vnet_buffer_oflags_t oflags = 0;
if (clib_net_to_host_u16 (eth->type) == ETHERNET_TYPE_IP4)
{
ip4_header_t *ip4 =
set_checksum_offsets (vlib_buffer_t *b, virtio_net_hdr_v1_t *hdr,
const int is_l2)
{
- u32 oflags = vnet_buffer (b)->oflags;
+ vnet_buffer_oflags_t oflags = vnet_buffer (b)->oflags;
if (b->flags & VNET_BUFFER_F_IS_IP4)
{
static void
set_gso_offsets (vlib_buffer_t *b, virtio_net_hdr_v1_t *hdr, const int is_l2)
{
- u32 oflags = vnet_buffer (b)->oflags;
+ vnet_buffer_oflags_t oflags = vnet_buffer (b)->oflags;
if (b->flags & VNET_BUFFER_F_IS_IP4)
{
if (hdr->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM)
{
u16 ethertype = 0, l2hdr_sz = 0;
- u32 oflags = 0;
+ vnet_buffer_oflags_t oflags = 0;
if (type == VIRTIO_IF_TYPE_TUN)
{
ethernet_header_t *eh = (ethernet_header_t *) b0_data;
u16 ethertype = clib_net_to_host_u16 (eh->type);
u16 l2hdr_sz = sizeof (ethernet_header_t);
- u32 oflags = 0;
+ vnet_buffer_oflags_t oflags = 0;
if (ethernet_frame_is_tagged (ethertype))
{
generic_header_offset_t gho = { 0 };
int is_ip4 = b->flags & VNET_BUFFER_F_IS_IP4;
int is_ip6 = b->flags & VNET_BUFFER_F_IS_IP6;
- u32 oflags = vnet_buffer (b)->oflags;
+ vnet_buffer_oflags_t oflags = vnet_buffer (b)->oflags;
ASSERT (!(is_ip4 && is_ip6));
vnet_generic_header_offset_parser (b, &gho, 1 /* l2 */ , is_ip4, is_ip6);
{
u32 *flagp = va_arg (*args, u32 *);
int rv = 0;
- u32 oflags = 0;
+ vnet_buffer_oflags_t oflags = 0;
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
else break;
}
if (rv)
- *flagp = oflags;
+ *flagp = (u32) oflags;
return rv;
}
static_always_inline void
vnet_calc_ip4_checksums (vlib_main_t *vm, vlib_buffer_t *b, ip4_header_t *ip4,
- tcp_header_t *th, udp_header_t *uh, u32 oflags)
+ tcp_header_t *th, udp_header_t *uh,
+ vnet_buffer_oflags_t oflags)
{
if (oflags & VNET_BUFFER_OFFLOAD_F_IP_CKSUM)
ip4->checksum = ip4_header_checksum (ip4);
static_always_inline void
vnet_calc_ip6_checksums (vlib_main_t *vm, vlib_buffer_t *b, ip6_header_t *ip6,
- tcp_header_t *th, udp_header_t *uh, u32 oflags)
+ tcp_header_t *th, udp_header_t *uh,
+ vnet_buffer_oflags_t oflags)
{
int bogus;
if (oflags & VNET_BUFFER_OFFLOAD_F_TCP_CKSUM)
ip6_header_t *ip6;
tcp_header_t *th;
udp_header_t *uh;
- u32 oflags;
+ vnet_buffer_oflags_t oflags;
if (!(b->flags & VNET_BUFFER_F_OFFLOAD))
return;
flags[0] = b[0]->flags;
flags[1] = b[1]->flags;
- u32 oflags[2];
+ vnet_buffer_oflags_t oflags[2];
oflags[0] = vnet_buffer (b[0])->oflags;
oflags[1] = vnet_buffer (b[1])->oflags;
u32 flags = b[0]->flags;
- u32 oflags = vnet_buffer (b[0])->oflags;
+ vnet_buffer_oflags_t oflags = vnet_buffer (b[0])->oflags;
u32 l4_offload = (flags & VNET_BUFFER_F_OFFLOAD) &&
(oflags & (VNET_BUFFER_OFFLOAD_F_TCP_CKSUM |
if (PREDICT_FALSE (b0->flags & VNET_BUFFER_F_OFFLOAD))
{
- u32 oflags = vnet_buffer (b0)->oflags;
+ vnet_buffer_oflags_t oflags = vnet_buffer (b0)->oflags;
/*
* Clearing offload flags before checksum is computed
{
vlib_buffer_t *b0 = vlib_get_buffer (vm, buffers[i]);
u8 l4_proto = 0;
- u32 oflags = 0;
+ vnet_buffer_oflags_t oflags = 0;
ethernet_header_t *eh =
(ethernet_header_t *) vlib_buffer_get_current (b0);