From: Paul Blakey <[email protected]>
Implement support for offloading ovs action set using
tc header rewrite action.
Signed-off-by: Paul Blakey <[email protected]>
Reviewed-by: Roi Dayan <[email protected]>
---
lib/netdev-tc-offloads.c | 201 +++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 195 insertions(+), 6 deletions(-)
diff --git a/lib/netdev-tc-offloads.c b/lib/netdev-tc-offloads.c
index 3c145c2..4044a77 100644
--- a/lib/netdev-tc-offloads.c
+++ b/lib/netdev-tc-offloads.c
@@ -27,11 +27,13 @@
#include "openvswitch/ofpbuf.h"
#include "openvswitch/thread.h"
#include "openvswitch/types.h"
+#include "openvswitch/util.h"
#include "openvswitch/vlog.h"
#include "netdev-linux.h"
#include "netlink.h"
#include "netlink-socket.h"
#include "odp-netlink.h"
+#include "odp-util.h"
#include "tc.h"
#include "unaligned.h"
#include "util.h"
@@ -41,6 +43,76 @@ VLOG_DEFINE_THIS_MODULE(netdev_tc_offloads);
static struct vlog_rate_limit error_rl = VLOG_RATE_LIMIT_INIT(60, 5);
static struct hmap ufid_tc = HMAP_INITIALIZER(&ufid_tc);
+
+struct netlink_field {
+ int offset;
+ int flower_offset;
+ int size;
+};
+
+static struct netlink_field set_flower_map[][3] = {
+ [OVS_KEY_ATTR_IPV4] = {
+ { offsetof(struct ovs_key_ipv4, ipv4_src),
+ offsetof(struct tc_flower_key, ipv4.ipv4_src),
+ MEMBER_SIZEOF(struct tc_flower_key, ipv4.ipv4_src)
+ },
+ { offsetof(struct ovs_key_ipv4, ipv4_dst),
+ offsetof(struct tc_flower_key, ipv4.ipv4_dst),
+ MEMBER_SIZEOF(struct tc_flower_key, ipv4.ipv4_dst)
+ },
+ { offsetof(struct ovs_key_ipv4, ipv4_ttl),
+ offsetof(struct tc_flower_key, ipv4.rewrite_ttl),
+ MEMBER_SIZEOF(struct tc_flower_key, ipv4.rewrite_ttl)
+ },
+ },
+ [OVS_KEY_ATTR_IPV6] = {
+ { offsetof(struct ovs_key_ipv6, ipv6_src),
+ offsetof(struct tc_flower_key, ipv6.ipv6_src),
+ MEMBER_SIZEOF(struct tc_flower_key, ipv6.ipv6_src)
+ },
+ { offsetof(struct ovs_key_ipv6, ipv6_dst),
+ offsetof(struct tc_flower_key, ipv6.ipv6_dst),
+ MEMBER_SIZEOF(struct tc_flower_key, ipv6.ipv6_dst)
+ },
+ },
+ [OVS_KEY_ATTR_ETHERNET] = {
+ { offsetof(struct ovs_key_ethernet, eth_src),
+ offsetof(struct tc_flower_key, src_mac),
+ MEMBER_SIZEOF(struct tc_flower_key, src_mac)
+ },
+ { offsetof(struct ovs_key_ethernet, eth_dst),
+ offsetof(struct tc_flower_key, dst_mac),
+ MEMBER_SIZEOF(struct tc_flower_key, dst_mac)
+ },
+ },
+ [OVS_KEY_ATTR_ETHERTYPE] = {
+ { 0,
+ offsetof(struct tc_flower_key, eth_type),
+ MEMBER_SIZEOF(struct tc_flower_key, eth_type)
+ },
+ },
+ [OVS_KEY_ATTR_TCP] = {
+ { offsetof(struct ovs_key_tcp, tcp_src),
+ offsetof(struct tc_flower_key, tcp_src),
+ MEMBER_SIZEOF(struct tc_flower_key, tcp_src)
+ },
+ { offsetof(struct ovs_key_tcp, tcp_dst),
+ offsetof(struct tc_flower_key, tcp_dst),
+ MEMBER_SIZEOF(struct tc_flower_key, tcp_dst)
+ },
+ },
+ [OVS_KEY_ATTR_UDP] = {
+ { offsetof(struct ovs_key_udp, udp_src),
+ offsetof(struct tc_flower_key, udp_src),
+ MEMBER_SIZEOF(struct tc_flower_key, udp_src)
+ },
+ { offsetof(struct ovs_key_udp, udp_dst),
+ offsetof(struct tc_flower_key, udp_dst),
+ MEMBER_SIZEOF(struct tc_flower_key, udp_dst)
+ },
+ },
+};