aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/dpdk/device/flow.c
diff options
context:
space:
mode:
authorChenmin Sun <chenmin.sun@intel.com>2020-02-28 22:49:37 +0800
committerDamjan Marion <dmarion@me.com>2020-04-28 21:13:50 +0000
commit24e2c50bf34af37b688df83cd8d39a58345349c5 (patch)
tree6f2741762b16a3e7b9c93e5c526d4c61bebc4276 /src/plugins/dpdk/device/flow.c
parent2857e7850c2a2de02eb9f61c5d760100e382aa09 (diff)
flow: add RSS support
This patch enables the RSS configuration through vnet/flow interface With this RSS feature, users can config the RSS functions for specific flows Currently, it supports: default, toeplitz and symmetric_toeplitz rss function, and ipv4-tcp/ipv4-udp/ipv6-tcp/ipv6-ucp flow types Users can use the following options to combine with above flow types for more specific hash input set selection: l3-src-only, l3-dst-only, l4-src-only, l4-dst-only Command line: test flow add dst-ip any proto udp rss function default rss types ipv4-tcp use l3-dst-only test flow add dst-ip any proto udp rss function toeplitz rss types ipv4-udp use l4-src-only test flow add dst-ip any proto udp rss function symmetric_toeplitz rss types ipv6-udp use l3-src-only and l3-dst-only Type: feature Signed-off-by: Chenmin Sun <chenmin.sun@intel.com> Change-Id: I213efc76dc8af37f2f63605884f353e05b0f5d2a
Diffstat (limited to 'src/plugins/dpdk/device/flow.c')
-rw-r--r--src/plugins/dpdk/device/flow.c56
1 files changed, 49 insertions, 7 deletions
diff --git a/src/plugins/dpdk/device/flow.c b/src/plugins/dpdk/device/flow.c
index 279468f10f8..444a76e307e 100644
--- a/src/plugins/dpdk/device/flow.c
+++ b/src/plugins/dpdk/device/flow.c
@@ -61,6 +61,24 @@ mac_address_is_all_zero (const u8 addr[6])
return true;
}
+static inline void
+dpdk_flow_convert_rss_types (u64 type, u64 * dpdk_rss_type)
+{
+#define BIT_IS_SET(v, b) \
+ ((v) & (u64)1<<(b))
+
+ *dpdk_rss_type = 0;
+
+#undef _
+#define _(n, f, s) \
+ if (n != -1 && BIT_IS_SET(type, n)) \
+ *dpdk_rss_type |= f;
+
+ foreach_dpdk_rss_hf
+#undef _
+ return;
+}
+
static int
dpdk_flow_add (dpdk_device_t * xd, vnet_flow_t * f, dpdk_flow_entry_t * fe)
{
@@ -74,6 +92,7 @@ dpdk_flow_add (dpdk_device_t * xd, vnet_flow_t * f, dpdk_flow_entry_t * fe)
struct rte_flow_item_gtp gtp[2] = { };
struct rte_flow_action_mark mark = { 0 };
struct rte_flow_action_queue queue = { 0 };
+ struct rte_flow_action_rss rss = { 0 };
struct rte_flow_item *item, *items = 0;
struct rte_flow_action *action, *actions = 0;
bool fate = false;
@@ -265,13 +284,15 @@ dpdk_flow_add (dpdk_device_t * xd, vnet_flow_t * f, dpdk_flow_entry_t * fe)
item->spec = NULL;
item->mask = NULL;
}
-
- tcp[0].hdr.src_port = clib_host_to_net_u16 (src_port);
- tcp[1].hdr.src_port = clib_host_to_net_u16 (src_port_mask);
- tcp[0].hdr.dst_port = clib_host_to_net_u16 (dst_port);
- tcp[1].hdr.dst_port = clib_host_to_net_u16 (dst_port_mask);
- item->spec = tcp;
- item->mask = tcp + 1;
+ else
+ {
+ tcp[0].hdr.src_port = clib_host_to_net_u16 (src_port);
+ tcp[1].hdr.src_port = clib_host_to_net_u16 (src_port_mask);
+ tcp[0].hdr.dst_port = clib_host_to_net_u16 (dst_port);
+ tcp[1].hdr.dst_port = clib_host_to_net_u16 (dst_port_mask);
+ item->spec = tcp;
+ item->mask = tcp + 1;
+ }
}
else
{
@@ -512,6 +533,27 @@ pattern_end:
else
fate = true;
}
+ if (f->actions & VNET_FLOW_ACTION_RSS)
+ {
+ u64 rss_type = 0;
+ vec_add2 (actions, action, 1);
+ action->type = RTE_FLOW_ACTION_TYPE_RSS;
+ action->conf = &rss;
+
+ /* convert types to DPDK rss bitmask */
+ dpdk_flow_convert_rss_types (f->rss_types, &rss_type);
+
+ rss.types = rss_type;
+ rss.func = f->rss_fun;
+
+ if (fate == true)
+ {
+ rv = VNET_FLOW_ERROR_INTERNAL;
+ goto done;
+ }
+ else
+ fate = true;
+ }
if (fate == false)
{
vec_add2 (actions, action, 1);