eth_mask = (void *)&fm_mask->l2.eth;
eth_val = (void *)&fm_data->l2.eth;
- /* Outer TPID cannot be matched */
- if (eth_mask->ether_type)
+ /*
+ * Outer TPID cannot be matched. If inner_type is 0, use what is
+ * in the eth header.
+ */
+ if (eth_mask->ether_type && mask->inner_type)
return -ENOTSUP;
/*
* L2, regardless of vlan stripping settings. So, the inner type
* from vlan becomes the ether type of the eth header.
*/
- eth_mask->ether_type = mask->inner_type;
- eth_val->ether_type = spec->inner_type;
+ if (mask->inner_type) {
+ eth_mask->ether_type = mask->inner_type;
+ eth_val->ether_type = spec->inner_type;
+ }
fm_data->fk_header_select |= FKH_ETHER | FKH_QTAG;
fm_mask->fk_header_select |= FKH_ETHER | FKH_QTAG;
fm_data->fk_vlan = rte_be_to_cpu_16(spec->tci);
return enic_fm_append_action_op(fm, &fm_op, error);
}
+/* Generate a reasonable source port number */
+static uint16_t
+gen_src_port(void)
+{
+ /* Min/max below are the default values in OVS-DPDK and Linux */
+ uint16_t p = rte_rand();
+ p = RTE_MAX(p, 32768);
+ p = RTE_MIN(p, 61000);
+ return rte_cpu_to_be_16(p);
+}
+
/* VXLAN encap is done via flowman compound action */
static int
enic_fm_copy_vxlan_encap(struct enic_flowman *fm,
{
struct fm_action_op fm_op;
struct rte_ether_hdr *eth;
+ struct rte_udp_hdr *udp;
uint16_t *ethertype;
void *template;
uint8_t off;
off + offsetof(struct rte_udp_hdr, dgram_len);
fm_op.encap.len2_delta =
sizeof(struct rte_udp_hdr) + sizeof(struct rte_vxlan_hdr);
+ udp = (struct rte_udp_hdr *)template;
append_template(&template, &off, item->spec,
sizeof(struct rte_udp_hdr));
+ /*
+ * Firmware does not hash/fill source port yet. Generate a
+ * random port, as there is *usually* one rte_flow for the
+ * given inner packet stream (i.e. a single stream has one
+ * random port).
+ */
+ if (udp->src_port == 0)
+ udp->src_port = gen_src_port();
item++;
flow_item_skip_void(&item);