From patchwork Mon Mar 13 13:37:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roi Dayan X-Patchwork-Id: 738141 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vhfDj1vWdz9s0Z for ; Tue, 14 Mar 2017 00:42:13 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 0D7BDC15; Mon, 13 Mar 2017 13:37:37 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 08601BD8 for ; Mon, 13 Mar 2017 13:37:29 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by smtp1.linuxfoundation.org (Postfix) with ESMTP id B7B30256 for ; Mon, 13 Mar 2017 13:37:27 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from roid@mellanox.com) with ESMTPS (AES256-SHA encrypted); 13 Mar 2017 15:37:23 +0200 Received: from r-vnc05.mtr.labs.mlnx (r-vnc05.mtr.labs.mlnx [10.208.0.115]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id v2DDbJZO028197; Mon, 13 Mar 2017 15:37:23 +0200 From: Roi Dayan To: dev@openvswitch.org Date: Mon, 13 Mar 2017 15:37:09 +0200 Message-Id: <1489412234-30916-20-git-send-email-roid@mellanox.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1489412234-30916-1-git-send-email-roid@mellanox.com> References: <1489412234-30916-1-git-send-email-roid@mellanox.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Shahar Klein , Hadar Hen Zion , Rony Efraim , Jiri Pirko , Marcelo Ricardo Leitner , Simon Horman , Or Gerlitz , Andy Gospodarek Subject: [ovs-dev] [PATCH ovs V4 19/24] netdev-vport: Use common offloads interface X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org From: Paul Blakey 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 Reviewed-by: Roi Dayan --- lib/netdev-linux.c | 7 ++--- lib/netdev-linux.h | 2 + lib/netdev-vport.c | 55 ++++++++++++++++++++++++++++++++++------------------ 3 files changed, 41 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..4cc086e 100644 --- a/lib/netdev-vport.c +++ b/lib/netdev-vport.c @@ -45,6 +45,8 @@ #include "unaligned.h" #include "unixctl.h" #include "openvswitch/vlog.h" +#include "netdev-tc-offloads.h" +#include "netdev-linux.h" VLOG_DEFINE_THIS_MODULE(netdev_vport); @@ -779,11 +781,28 @@ 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); +} + +#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 +827,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 +868,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 +890,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 +928,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); }