[ovs-dev] [PATCH ovs V5 19/24] netdev-vport: Use common offloads interface
Roi Dayan
roid at mellanox.com
Wed Mar 22 11:10:52 UTC 2017
From: Paul Blakey <paulb at mellanox.com>
netdev vports are backed by actualy netdev at the kernel
level, so they can use the common netdev-tc offloads interface
for flow offloading (if enabled).
Signed-off-by: Paul Blakey <paulb at mellanox.com>
Signed-off-by: Simon Horman <simon.horman at netronome.com>
Reviewed-by: Roi Dayan <roid at mellanox.com>
---
lib/netdev-linux.c | 7 +++---
lib/netdev-linux.h | 2 ++
lib/netdev-vport.c | 66 ++++++++++++++++++++++++++++++++++++++----------------
3 files changed, 52 insertions(+), 23 deletions(-)
diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
index 124d2c3..a48c6d9 100644
--- a/lib/netdev-linux.c
+++ b/lib/netdev-linux.c
@@ -531,7 +531,6 @@ static int set_flags(const char *, unsigned int flags);
static int update_flags(struct netdev_linux *netdev, enum netdev_flags off,
enum netdev_flags on, enum netdev_flags *old_flagsp)
OVS_REQUIRES(netdev->mutex);
-static int do_get_ifindex(const char *netdev_name);
static int get_ifindex(const struct netdev *, int *ifindexp);
static int do_set_addr(struct netdev *netdev,
int ioctl_nr, const char *ioctl_name,
@@ -5374,8 +5373,8 @@ set_flags(const char *name, unsigned int flags)
return af_inet_ifreq_ioctl(name, &ifr, SIOCSIFFLAGS, "SIOCSIFFLAGS");
}
-static int
-do_get_ifindex(const char *netdev_name)
+int
+linux_get_ifindex(const char *netdev_name)
{
struct ifreq ifr;
int error;
@@ -5398,7 +5397,7 @@ get_ifindex(const struct netdev *netdev_, int *ifindexp)
struct netdev_linux *netdev = netdev_linux_cast(netdev_);
if (!(netdev->cache_valid & VALID_IFINDEX)) {
- int ifindex = do_get_ifindex(netdev_get_name(netdev_));
+ int ifindex = linux_get_ifindex(netdev_get_name(netdev_));
if (ifindex < 0) {
netdev->get_ifindex_error = -ifindex;
diff --git a/lib/netdev-linux.h b/lib/netdev-linux.h
index d944691..880f864 100644
--- a/lib/netdev-linux.h
+++ b/lib/netdev-linux.h
@@ -27,6 +27,7 @@ struct netdev;
int netdev_linux_ethtool_set_flag(struct netdev *netdev, uint32_t flag,
const char *flag_name, bool enable);
+int linux_get_ifindex(const char *netdev_name);
#define LINUX_FLOW_OFFLOAD_API \
netdev_tc_flow_flush, \
@@ -37,4 +38,5 @@ int netdev_linux_ethtool_set_flag(struct netdev *netdev, uint32_t flag,
netdev_tc_flow_get, \
netdev_tc_flow_del, \
netdev_tc_init_flow_api
+
#endif /* netdev-linux.h */
diff --git a/lib/netdev-vport.c b/lib/netdev-vport.c
index 8cb03e6..874baf4 100644
--- a/lib/netdev-vport.c
+++ b/lib/netdev-vport.c
@@ -45,6 +45,10 @@
#include "unaligned.h"
#include "unixctl.h"
#include "openvswitch/vlog.h"
+#include "netdev-tc-offloads.h"
+#ifdef __linux__
+#include "netdev-linux.h"
+#endif
VLOG_DEFINE_THIS_MODULE(netdev_vport);
@@ -779,11 +783,37 @@ get_stats(const struct netdev *netdev, struct netdev_stats *stats)
return 0;
}
-
+#ifdef __linux__
+static int
+netdev_vport_get_ifindex__(const struct netdev *netdev_)
+{
+ char buf[NETDEV_VPORT_NAME_BUFSIZE];
+ const char *name = netdev_vport_get_dpif_port(netdev_, buf, sizeof(buf));
+
+ return linux_get_ifindex(name);
+}
+
+static int
+netdev_vport_get_ifindex(const struct netdev *netdev_)
+{
+ if (netdev_flow_api_enabled)
+ return netdev_vport_get_ifindex__(netdev_);
+ else
+ return -EOPNOTSUPP;
+}
+
+#define NETDEV_VPORT_GET_IFINDEX netdev_vport_get_ifindex
+#define NETDEV_FLOW_OFFLOAD_API LINUX_FLOW_OFFLOAD_API
+#else /* !__linux__ */
+#define NETDEV_VPORT_GET_IFINDEX NULL
+#define NETDEV_FLOW_OFFLOAD_API NO_OFFLOAD_API
+#endif /* __linux__ */
+
#define VPORT_FUNCTIONS(GET_CONFIG, SET_CONFIG, \
GET_TUNNEL_CONFIG, GET_STATUS, \
BUILD_HEADER, \
- PUSH_HEADER, POP_HEADER) \
+ PUSH_HEADER, POP_HEADER, \
+ GET_IFINDEX) \
NULL, \
netdev_vport_run, \
netdev_vport_wait, \
@@ -808,7 +838,7 @@ get_stats(const struct netdev *netdev, struct netdev_stats *stats)
netdev_vport_get_etheraddr, \
NULL, /* get_mtu */ \
NULL, /* set_mtu */ \
- NULL, /* get_ifindex */ \
+ GET_IFINDEX, \
NULL, /* get_carrier */ \
NULL, /* get_carrier_resets */ \
NULL, /* get_miimon */ \
@@ -849,24 +879,19 @@ get_stats(const struct netdev *netdev, struct netdev_stats *stats)
NULL, /* rx_wait */ \
NULL, /* rx_drain */ \
\
- NULL, /* flow_flush */ \
- NULL, /* flow_dump_create */ \
- NULL, /* flow_dump_destroy */ \
- NULL, /* flow_dump_next */ \
- NULL, /* flow_put */ \
- NULL, /* flow_get */ \
- NULL, /* flow_del */ \
- NULL, /* init_flow_api */
+ NETDEV_FLOW_OFFLOAD_API
-#define TUNNEL_CLASS(NAME, DPIF_PORT, BUILD_HEADER, PUSH_HEADER, POP_HEADER) \
+#define TUNNEL_CLASS(NAME, DPIF_PORT, BUILD_HEADER, PUSH_HEADER, POP_HEADER, \
+ GET_IFINDEX) \
{ DPIF_PORT, \
{ NAME, false, \
VPORT_FUNCTIONS(get_tunnel_config, \
set_tunnel_config, \
get_netdev_tunnel_config, \
tunnel_get_status, \
- BUILD_HEADER, PUSH_HEADER, POP_HEADER) }}
+ BUILD_HEADER, PUSH_HEADER, POP_HEADER, \
+ GET_IFINDEX) }}
void
netdev_vport_tunnel_register(void)
@@ -876,15 +901,18 @@ netdev_vport_tunnel_register(void)
static const struct vport_class vport_classes[] = {
TUNNEL_CLASS("geneve", "genev_sys", netdev_geneve_build_header,
netdev_tnl_push_udp_header,
- netdev_geneve_pop_header),
+ netdev_geneve_pop_header,
+ NULL),
TUNNEL_CLASS("gre", "gre_sys", netdev_gre_build_header,
netdev_gre_push_header,
- netdev_gre_pop_header),
+ netdev_gre_pop_header,
+ NULL),
TUNNEL_CLASS("vxlan", "vxlan_sys", netdev_vxlan_build_header,
netdev_tnl_push_udp_header,
- netdev_vxlan_pop_header),
- TUNNEL_CLASS("lisp", "lisp_sys", NULL, NULL, NULL),
- TUNNEL_CLASS("stt", "stt_sys", NULL, NULL, NULL),
+ netdev_vxlan_pop_header,
+ NETDEV_VPORT_GET_IFINDEX),
+ TUNNEL_CLASS("lisp", "lisp_sys", NULL, NULL, NULL, NULL),
+ TUNNEL_CLASS("stt", "stt_sys", NULL, NULL, NULL, NULL),
};
static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER;
@@ -911,6 +939,6 @@ netdev_vport_patch_register(void)
VPORT_FUNCTIONS(get_patch_config,
set_patch_config,
NULL,
- NULL, NULL, NULL, NULL) }};
+ NULL, NULL, NULL, NULL, NULL) }};
netdev_register_provider(&patch_class.netdev_class);
}
--
2.7.4
More information about the dev
mailing list