32 static const struct rte_flow_attr
ingress = {.ingress = 1 };
33 static const struct rte_flow_item_eth
any_eth[2] = { };
34 static const struct rte_flow_item_vlan
any_vlan[2] = { };
39 struct rte_flow_item_ipv4 ip4[2] = { };
40 struct rte_flow_item_ipv6 ip6[2] = { };
41 struct rte_flow_item_udp udp[2] = { };
42 struct rte_flow_item_tcp tcp[2] = { };
43 struct rte_flow_action_mark mark = { 0 };
44 struct rte_flow_action_queue queue = { 0 };
45 struct rte_flow_item *item, *items = 0;
46 struct rte_flow_action *action, *actions = 0;
51 raw_sz =
sizeof (
struct rte_flow_item_raw)
56 struct rte_flow_item_raw item;
57 u8 val[raw_sz + vxlan_hdr_sz];
65 return VNET_FLOW_ERROR_NOT_SUPPORTED;
70 item->type = RTE_FLOW_ITEM_TYPE_ETH;
75 if (f->
type != VNET_FLOW_TYPE_IP4_VXLAN)
78 item->type = RTE_FLOW_ITEM_TYPE_VLAN;
85 if (f->
type == VNET_FLOW_TYPE_IP6_N_TUPLE)
87 vnet_flow_ip6_n_tuple_t *t6 = &f->ip6_n_tuple;
92 item->type = RTE_FLOW_ITEM_TYPE_IPV6;
96 src_port = t6->src_port.port;
97 dst_port = t6->dst_port.port;
98 src_port_mask = t6->src_port.mask;
99 dst_port_mask = t6->dst_port.mask;
100 protocol = t6->protocol;
102 else if (f->
type == VNET_FLOW_TYPE_IP4_N_TUPLE)
104 vnet_flow_ip4_n_tuple_t *t4 = &f->ip4_n_tuple;
105 ip4[0].hdr.src_addr = t4->src_addr.addr.as_u32;
106 ip4[1].hdr.src_addr = t4->src_addr.mask.as_u32;
107 ip4[0].hdr.dst_addr = t4->dst_addr.addr.as_u32;
108 ip4[1].hdr.dst_addr = t4->dst_addr.mask.as_u32;
109 item->
type = RTE_FLOW_ITEM_TYPE_IPV4;
111 item->mask = ip4 + 1;
113 src_port = t4->src_port.port;
114 dst_port = t4->dst_port.port;
115 src_port_mask = t4->src_port.mask;
116 dst_port_mask = t4->dst_port.mask;
117 protocol = t4->protocol;
119 else if (f->
type == VNET_FLOW_TYPE_IP4_VXLAN)
121 vnet_flow_ip4_vxlan_t *v4 = &f->ip4_vxlan;
122 ip4[0].hdr.src_addr = v4->src_addr.as_u32;
123 ip4[1].hdr.src_addr = -1;
124 ip4[0].hdr.dst_addr = v4->dst_addr.as_u32;
125 ip4[1].hdr.dst_addr = -1;
126 item->
type = RTE_FLOW_ITEM_TYPE_IPV4;
128 item->mask = ip4 + 1;
130 dst_port = v4->dst_port;
134 protocol = IP_PROTOCOL_UDP;
138 rv = VNET_FLOW_ERROR_NOT_SUPPORTED;
144 if (protocol == IP_PROTOCOL_UDP)
146 udp[0].hdr.src_port = clib_host_to_net_u16 (src_port);
147 udp[1].hdr.src_port = clib_host_to_net_u16 (src_port_mask);
148 udp[0].hdr.dst_port = clib_host_to_net_u16 (dst_port);
149 udp[1].hdr.dst_port = clib_host_to_net_u16 (dst_port_mask);
150 item->type = RTE_FLOW_ITEM_TYPE_UDP;
152 item->mask = udp + 1;
154 else if (protocol == IP_PROTOCOL_TCP)
156 tcp[0].hdr.src_port = clib_host_to_net_u16 (src_port);
157 tcp[1].hdr.src_port = clib_host_to_net_u16 (src_port_mask);
158 tcp[0].hdr.dst_port = clib_host_to_net_u16 (dst_port);
159 tcp[1].hdr.dst_port = clib_host_to_net_u16 (dst_port_mask);
160 item->type = RTE_FLOW_ITEM_TYPE_TCP;
162 item->mask = tcp + 1;
166 rv = VNET_FLOW_ERROR_NOT_SUPPORTED;
171 if (f->
type == VNET_FLOW_TYPE_IP4_VXLAN)
173 u32 vni = f->ip4_vxlan.vni;
176 .vni_reserved = clib_host_to_net_u32 (vni << 8)
180 .vni_reserved = clib_host_to_net_u32 (((
u32) - 1) << 8)
184 raw[0].item.relative = 1;
185 raw[0].item.length = vxlan_hdr_sz;
188 raw[0].item.pattern = raw[0].val + raw_sz;
190 raw[1].item.pattern = raw[1].val + raw_sz;
193 item->type = RTE_FLOW_ITEM_TYPE_RAW;
195 item->mask = raw + 1;
199 item->type = RTE_FLOW_ITEM_TYPE_END;
203 action->type = RTE_FLOW_ACTION_TYPE_PASSTHRU;
205 if (f->
actions & VNET_FLOW_ACTION_REDIRECT_TO_QUEUE)
209 action->type = RTE_FLOW_ACTION_TYPE_QUEUE;
210 action->conf = &queue;
213 if (f->
actions & VNET_FLOW_ACTION_MARK)
217 action->type = RTE_FLOW_ACTION_TYPE_MARK;
218 action->conf = &mark;
222 action->type = RTE_FLOW_ACTION_TYPE_END;
230 rv = VNET_FLOW_ERROR_NOT_SUPPORTED;
231 else if (rv == -EEXIST)
232 rv = VNET_FLOW_ERROR_ALREADY_EXISTS;
234 rv = VNET_FLOW_ERROR_INTERNAL;
242 rv = VNET_FLOW_ERROR_NOT_SUPPORTED;
252 u32 flow_index,
uword * private_data)
279 return VNET_FLOW_ERROR_INTERNAL;
293 goto disable_rx_offload;
297 return VNET_FLOW_ERROR_NOT_SUPPORTED;
304 rv = VNET_FLOW_ERROR_NOT_SUPPORTED;
309 if (flow->
actions & (VNET_FLOW_ACTION_MARK |
310 VNET_FLOW_ACTION_REDIRECT_TO_NODE |
311 VNET_FLOW_ACTION_BUFFER_ADVANCE))
322 if (flow->
actions & VNET_FLOW_ACTION_MARK)
324 if (flow->
actions & VNET_FLOW_ACTION_REDIRECT_TO_NODE)
326 if (flow->
actions & VNET_FLOW_ACTION_BUFFER_ADVANCE)
332 if ((xd->
flags & DPDK_DEVICE_FLAG_RX_FLOW_OFFLOAD) == 0)
334 xd->
flags |= DPDK_DEVICE_FLAG_RX_FLOW_OFFLOAD;
340 case VNET_FLOW_TYPE_IP4_N_TUPLE:
341 case VNET_FLOW_TYPE_IP6_N_TUPLE:
342 case VNET_FLOW_TYPE_IP4_VXLAN:
347 rv = VNET_FLOW_ERROR_NOT_SUPPORTED;
365 if ((xd->
flags & DPDK_DEVICE_FLAG_RX_FLOW_OFFLOAD) != 0
368 xd->
flags &= ~DPDK_DEVICE_FLAG_RX_FLOW_OFFLOAD;
378 u32 dev_instance = va_arg (*args,
u32);
379 u32 flow_index = va_arg (*args,
u32);
385 if (flow_index == ~0)
387 s =
format (s,
"%-25s: %U\n",
"supported flow actions",
389 s =
format (s,
"%-25s: %d\n",
"last DPDK error type",
391 s =
format (s,
"%-25s: %s\n",
"last DPDK error message",
398 return format (s,
"unknown flow");
volatile u32 main_loop_count
#define clib_memcpy_fast(a, b, c)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
u32 supported_flow_actions
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
static const struct rte_flow_item_eth any_eth[2]
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
void dpdk_device_setup(dpdk_device_t *xd)
static const struct rte_flow_attr ingress
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
vl_api_ip_proto_t protocol
static int dpdk_flow_add(dpdk_device_t *xd, vnet_flow_t *f, dpdk_flow_entry_t *fe)
#define pool_put(P, E)
Free an object E in pool P.
vnet_flow_t * vnet_get_flow(u32 flow_index)
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P with alignment A.
format_function_t format_flow_actions
dpdk_flow_lookup_entry_t * flow_lookup_entries
u32 * parked_lookup_indexes
u8 * format_dpdk_flow(u8 *s, va_list *args)
#define vec_free(V)
Free vector's memory (no header).
int dpdk_flow_ops_fn(vnet_main_t *vnm, vnet_flow_dev_op_t op, u32 dev_instance, u32 flow_index, uword *private_data)
static const struct rte_flow_item_vlan any_vlan[2]
#define pool_put_index(p, i)
Free pool element with given index.
dpdk_portid_t device_index
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
u32 redirect_device_input_next_index
#define vec_foreach(var, vec)
Vector iterator.
dpdk_flow_entry_t * flow_entries
#define CLIB_CACHE_LINE_BYTES
struct rte_flow_error last_flow_error
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".
static uword pool_elts(void *v)
Number of active elements in a pool.