summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Britstein <elibr@mellanox.com>2020-01-09 07:46:53 +0000
committerIlya Maximets <i.maximets@ovn.org>2020-01-16 13:34:10 +0100
commitae32e08d637103c1241f3766e9cf6ecb8968e14c (patch)
treeeabd78b37fabed23c962b2376559cc724b2c1893
parentabb288c00a815fedd8d9173090f4f88d1c9b3a11 (diff)
downloadopenvswitch-ae32e08d637103c1241f3766e9cf6ecb8968e14c.tar.gz
netdev-offload-dpdk: Support offload of set MAC actions.
Signed-off-by: Eli Britstein <elibr@mellanox.com> Reviewed-by: Oz Shlomo <ozsh@mellanox.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
-rw-r--r--Documentation/howto/dpdk.rst1
-rw-r--r--NEWS3
-rw-r--r--lib/netdev-offload-dpdk.c99
3 files changed, 102 insertions, 1 deletions
diff --git a/Documentation/howto/dpdk.rst b/Documentation/howto/dpdk.rst
index d9de7bedd..0e9939ddd 100644
--- a/Documentation/howto/dpdk.rst
+++ b/Documentation/howto/dpdk.rst
@@ -392,6 +392,7 @@ Supported actions for hardware offload are:
- Output.
- Drop.
+- Modification of Ethernet (mod_dl_src/mod_dl_dst).
Further Reading
---------------
diff --git a/NEWS b/NEWS
index ffa6a91be..a34990388 100644
--- a/NEWS
+++ b/NEWS
@@ -34,7 +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 and drop actions (experimental).
+ * Add hardware offload support for output, drop and set MAC 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".
diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c
index 8436e1533..c36576d4e 100644
--- a/lib/netdev-offload-dpdk.c
+++ b/lib/netdev-offload-dpdk.c
@@ -369,6 +369,21 @@ dump_flow_action(struct ds *s, const struct rte_flow_action *actions)
}
} else if (actions->type == RTE_FLOW_ACTION_TYPE_DROP) {
ds_put_cstr(s, "rte flow drop action\n");
+ } else if (actions->type == RTE_FLOW_ACTION_TYPE_SET_MAC_SRC ||
+ actions->type == RTE_FLOW_ACTION_TYPE_SET_MAC_DST) {
+ const struct rte_flow_action_set_mac *set_mac = actions->conf;
+
+ char *dirstr = actions->type == RTE_FLOW_ACTION_TYPE_SET_MAC_DST
+ ? "dst" : "src";
+
+ ds_put_format(s, "rte flow set-mac-%s action:\n", dirstr);
+ if (set_mac) {
+ ds_put_format(s,
+ " Set-mac-%s: "ETH_ADDR_FMT"\n", dirstr,
+ ETH_ADDR_BYTES_ARGS(set_mac->mac_addr));
+ } else {
+ ds_put_format(s, " Set-mac-%s = null\n", dirstr);
+ }
} else {
ds_put_format(s, "unknown rte flow action (%d)\n", actions->type);
}
@@ -798,6 +813,80 @@ add_output_action(struct netdev *netdev,
}
static int
+add_set_flow_action__(struct flow_actions *actions,
+ const void *value, void *mask,
+ const size_t size, const int attr)
+{
+ void *spec;
+
+ if (mask) {
+ /* DPDK does not support partially masked set actions. In such
+ * case, fail the offload.
+ */
+ if (is_all_zeros(mask, size)) {
+ return 0;
+ }
+ if (!is_all_ones(mask, size)) {
+ VLOG_DBG_RL(&rl, "Partial mask is not supported");
+ return -1;
+ }
+ }
+
+ spec = xzalloc(size);
+ memcpy(spec, value, size);
+ add_flow_action(actions, attr, spec);
+
+ /* Clear used mask for later checking. */
+ if (mask) {
+ memset(mask, 0, size);
+ }
+ return 0;
+}
+
+BUILD_ASSERT_DECL(sizeof(struct rte_flow_action_set_mac) ==
+ MEMBER_SIZEOF(struct ovs_key_ethernet, eth_src));
+BUILD_ASSERT_DECL(sizeof(struct rte_flow_action_set_mac) ==
+ MEMBER_SIZEOF(struct ovs_key_ethernet, eth_dst));
+
+static int
+parse_set_actions(struct flow_actions *actions,
+ const struct nlattr *set_actions,
+ const size_t set_actions_len,
+ bool masked)
+{
+ const struct nlattr *sa;
+ unsigned int sleft;
+
+#define add_set_flow_action(field, type) \
+ if (add_set_flow_action__(actions, &key->field, \
+ mask ? CONST_CAST(void *, &mask->field) : NULL, \
+ sizeof key->field, type)) { \
+ return -1; \
+ }
+
+ NL_ATTR_FOR_EACH_UNSAFE (sa, sleft, set_actions, set_actions_len) {
+ if (nl_attr_type(sa) == OVS_KEY_ATTR_ETHERNET) {
+ const struct ovs_key_ethernet *key = nl_attr_get(sa);
+ const struct ovs_key_ethernet *mask = masked ? key + 1 : NULL;
+
+ add_set_flow_action(eth_src, RTE_FLOW_ACTION_TYPE_SET_MAC_SRC);
+ add_set_flow_action(eth_dst, RTE_FLOW_ACTION_TYPE_SET_MAC_DST);
+
+ if (mask && !is_all_zeros(mask, sizeof *mask)) {
+ VLOG_DBG_RL(&rl, "Unsupported ETHERNET set action");
+ return -1;
+ }
+ } else {
+ VLOG_DBG_RL(&rl,
+ "Unsupported set action type %d", nl_attr_type(sa));
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+static int
parse_flow_actions(struct netdev *netdev,
struct flow_actions *actions,
struct nlattr *nl_actions,
@@ -815,6 +904,16 @@ parse_flow_actions(struct netdev *netdev,
}
} else if (nl_attr_type(nla) == OVS_ACTION_ATTR_DROP) {
add_flow_action(actions, RTE_FLOW_ACTION_TYPE_DROP, NULL);
+ } else if (nl_attr_type(nla) == OVS_ACTION_ATTR_SET ||
+ nl_attr_type(nla) == OVS_ACTION_ATTR_SET_MASKED) {
+ const struct nlattr *set_actions = nl_attr_get(nla);
+ const size_t set_actions_len = nl_attr_get_size(nla);
+ bool masked = nl_attr_type(nla) == OVS_ACTION_ATTR_SET_MASKED;
+
+ if (parse_set_actions(actions, set_actions, set_actions_len,
+ masked)) {
+ return -1;
+ }
} else {
VLOG_DBG_RL(&rl, "Unsupported action type %d", nl_attr_type(nla));
return -1;