Skip to content

Commit

Permalink
netdev-offload-dpdk: Support offload of set TCP/UDP ports actions.
Browse files Browse the repository at this point in the history
Signed-off-by: Eli Britstein <[email protected]>
Reviewed-by: Oz Shlomo <[email protected]>
Signed-off-by: Ilya Maximets <[email protected]>
  • Loading branch information
Eli Britstein authored and igsilya committed Jan 16, 2020
1 parent d9a831c commit b9254f7
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
1 change: 1 addition & 0 deletions Documentation/howto/dpdk.rst
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ Supported actions for hardware offload are:
- Drop.
- Modification of Ethernet (mod_dl_src/mod_dl_dst).
- Modification of IPv4 (mod_nw_src/mod_nw_dst/mod_nw_ttl).
- Modification of TCP/UDP (mod_tp_src/mod_tp_dst).

Further Reading
---------------
Expand Down
4 changes: 2 additions & 2 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ Post-v2.12.0
interval is increased to 60 seconds for the connection to the
replication server. This value is configurable with the unixctl
command - ovsdb-server/set-active-ovsdb-server-probe-interval.
* Add hardware offload support for output, drop and set actions of
MAC and IPv4 (experimental).
* Add hardware offload support for output, drop, set of MAC, IPv4 and
TCP/UDP ports actions (experimental).
- 'ovs-appctl dpctl/dump-flows' can now show offloaded=partial for
partially offloaded flows, dp:dpdk for fully offloaded by dpdk, and
type filter supports new filters: "dpdk" and "partially-offloaded".
Expand Down
43 changes: 43 additions & 0 deletions lib/netdev-offload-dpdk.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,19 @@ dump_flow_action(struct ds *s, const struct rte_flow_action *actions)
} else {
ds_put_cstr(s, " Set-ttl = null\n");
}
} else if (actions->type == RTE_FLOW_ACTION_TYPE_SET_TP_SRC ||
actions->type == RTE_FLOW_ACTION_TYPE_SET_TP_DST) {
const struct rte_flow_action_set_tp *set_tp = actions->conf;
char *dirstr = actions->type == RTE_FLOW_ACTION_TYPE_SET_TP_DST
? "dst" : "src";

ds_put_format(s, "rte flow set-tcp/udp-port-%s action:\n", dirstr);
if (set_tp) {
ds_put_format(s, " Set-%s-tcp/udp-port: %"PRIu16"\n", dirstr,
ntohs(set_tp->port));
} else {
ds_put_format(s, " Set-%s-tcp/udp-port = null\n", dirstr);
}
} else {
ds_put_format(s, "unknown rte flow action (%d)\n", actions->type);
}
Expand Down Expand Up @@ -876,6 +889,14 @@ BUILD_ASSERT_DECL(sizeof(struct rte_flow_action_set_ipv4) ==
MEMBER_SIZEOF(struct ovs_key_ipv4, ipv4_dst));
BUILD_ASSERT_DECL(sizeof(struct rte_flow_action_set_ttl) ==
MEMBER_SIZEOF(struct ovs_key_ipv4, ipv4_ttl));
BUILD_ASSERT_DECL(sizeof(struct rte_flow_action_set_tp) ==
MEMBER_SIZEOF(struct ovs_key_tcp, tcp_src));
BUILD_ASSERT_DECL(sizeof(struct rte_flow_action_set_tp) ==
MEMBER_SIZEOF(struct ovs_key_tcp, tcp_dst));
BUILD_ASSERT_DECL(sizeof(struct rte_flow_action_set_tp) ==
MEMBER_SIZEOF(struct ovs_key_udp, udp_src));
BUILD_ASSERT_DECL(sizeof(struct rte_flow_action_set_tp) ==
MEMBER_SIZEOF(struct ovs_key_udp, udp_dst));

static int
parse_set_actions(struct flow_actions *actions,
Expand Down Expand Up @@ -917,6 +938,28 @@ parse_set_actions(struct flow_actions *actions,
VLOG_DBG_RL(&rl, "Unsupported IPv4 set action");
return -1;
}
} else if (nl_attr_type(sa) == OVS_KEY_ATTR_TCP) {
const struct ovs_key_tcp *key = nl_attr_get(sa);
const struct ovs_key_tcp *mask = masked ? key + 1 : NULL;

add_set_flow_action(tcp_src, RTE_FLOW_ACTION_TYPE_SET_TP_SRC);
add_set_flow_action(tcp_dst, RTE_FLOW_ACTION_TYPE_SET_TP_DST);

if (mask && !is_all_zeros(mask, sizeof *mask)) {
VLOG_DBG_RL(&rl, "Unsupported TCP set action");
return -1;
}
} else if (nl_attr_type(sa) == OVS_KEY_ATTR_UDP) {
const struct ovs_key_udp *key = nl_attr_get(sa);
const struct ovs_key_udp *mask = masked ? key + 1 : NULL;

add_set_flow_action(udp_src, RTE_FLOW_ACTION_TYPE_SET_TP_SRC);
add_set_flow_action(udp_dst, RTE_FLOW_ACTION_TYPE_SET_TP_DST);

if (mask && !is_all_zeros(mask, sizeof *mask)) {
VLOG_DBG_RL(&rl, "Unsupported UDP set action");
return -1;
}
} else {
VLOG_DBG_RL(&rl,
"Unsupported set action type %d", nl_attr_type(sa));
Expand Down

0 comments on commit b9254f7

Please sign in to comment.