From patchwork Thu Jun 21 13:35:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Hurley X-Patchwork-Id: 932741 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=netronome.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=netronome-com.20150623.gappssmtp.com header.i=@netronome-com.20150623.gappssmtp.com header.b="W30yXO/8"; dkim-atps=neutral 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 41BN6L5HQmz9s19 for ; Thu, 21 Jun 2018 23:37:14 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id EF161CF5; Thu, 21 Jun 2018 13:36:14 +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 6BC99C74 for ; Thu, 21 Jun 2018 13:36:13 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr0-f193.google.com (mail-wr0-f193.google.com [209.85.128.193]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 7D9C0334 for ; Thu, 21 Jun 2018 13:36:12 +0000 (UTC) Received: by mail-wr0-f193.google.com with SMTP id e18-v6so3241856wrs.5 for ; Thu, 21 Jun 2018 06:36:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=BZzBVhqbegdcac1RIBS0vop1xlJ95puSKZaj2xjF3pY=; b=W30yXO/8gznLl9XnGDI3wWfUGeW+9wGMJ1LbCIVB0N43uxHueMyu1V969dIVYxiwYe UNDXZpIKdzX+5auTnyur0Ww2DxxDNT1dL8HbzooXAffVffO3FKKx+xJsY9SdBkJjPlL0 /fHYxkapSs6gkTUNjNIC7RbBZPtheQVCYJ1C1+uZuTuKRcYQUDc+QqMgOqELLNTXE5vK tYP5T4vBJn7bzU/zvyEj1ycIPpVTAQMJSnkaAm5xsY4Vp45L0iIffIZ06DMuYuUfHvWV D0HZoA6rIP2n7jLMWw80q0okKHlKFUb0Uwff0oAB5OxCQXywmHX74UmkNlt4KiIU54E6 NBsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=BZzBVhqbegdcac1RIBS0vop1xlJ95puSKZaj2xjF3pY=; b=Lme3rrsy/U9yPEOTTt8Osqr2YgxtdjOTRgtPt46iGL9epMTAZ01iGVsSnkhNFXO1kV kX/hQLpTdZi/8v1kyqDmoZ8nSrVZi2+qFlrZNzIsigKqPRJlZt7doOV6b7gPg1wYwVpL L+sB7wJppbchqYXRhk8I3vjk7XqINy5qyt1m9gAJptOHbxbX3SBjE+Z/zCRS+jGS+4QZ rLJtmQbnfqAXKXN27eb9MKBICSw+o7kqtLezHvnx+yGQ3nt7V+LK+b/OrrRY9MFxYX7C KXXhzFaYHXCthlsjY7zHKBbC7PDTcPZxkaEO8TAKaf3/Sr7meD73dBiHE6PKeNLX4EnH X0Iw== X-Gm-Message-State: APt69E1dxlqHO4d4QYsLYxzdFlvPS3h8GVpJQypfPB0+JQEIHhspdHOH l4+0ZNiWJ2WmQuR++C1XFCLx5Jsu X-Google-Smtp-Source: ADUXVKIuS/3Hd4aYMDQ6dcg+/xA5Zk5WKZoRpmvHY5dRrM2bHTUr9BdSYhCUex/KcCzyolFRjcjunA== X-Received: by 2002:adf:be09:: with SMTP id n9-v6mr23017283wrh.267.1529588170741; Thu, 21 Jun 2018 06:36:10 -0700 (PDT) Received: from jhurley-Precision-Tower-3420.netronome.com ([80.76.204.157]) by smtp.gmail.com with ESMTPSA id e63-v6sm8406382wma.46.2018.06.21.06.36.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Jun 2018 06:36:10 -0700 (PDT) From: John Hurley To: dev@openvswitch.org, roid@mellanox.com, gavi@mellanox.com, paulb@mellanox.com, fbl@sysclose.org, simon.horman@netronome.com Date: Thu, 21 Jun 2018 14:35:57 +0100 Message-Id: <1529588161-15934-3-git-send-email-john.hurley@netronome.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1529588161-15934-1-git-send-email-john.hurley@netronome.com> References: <1529588161-15934-1-git-send-email-john.hurley@netronome.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 2/6] netdev-provider: add class op to get block_id 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 Add a new class op for netdevs to get the block_id if one exists. The block_id is used in offload ops to group multiple qdiscs together. Stub calls are made to the new class op (implementation to follow in further patches). The default block_id of 0 (no block) will be used in these cases. Signed-off-by: John Hurley Reviewed-by: Dirk van der Merwe Reviewed-by: Simon Horman --- lib/netdev-bsd.c | 3 ++- lib/netdev-dpdk.c | 3 ++- lib/netdev-dummy.c | 3 ++- lib/netdev-linux.c | 3 ++- lib/netdev-provider.h | 4 ++++ lib/netdev-tc-offloads.c | 18 ++++++++++++++++++ lib/netdev-vport.c | 3 ++- lib/netdev.c | 10 ++++++++++ lib/netdev.h | 1 + 9 files changed, 43 insertions(+), 5 deletions(-) diff --git a/lib/netdev-bsd.c b/lib/netdev-bsd.c index b70f327..c6946f9 100644 --- a/lib/netdev-bsd.c +++ b/lib/netdev-bsd.c @@ -1553,7 +1553,8 @@ netdev_bsd_update_flags(struct netdev *netdev_, enum netdev_flags off, netdev_bsd_rxq_wait, \ netdev_bsd_rxq_drain, \ \ - NO_OFFLOAD_API \ + NO_OFFLOAD_API, \ + NULL /* get_block_id */ \ } const struct netdev_class netdev_bsd_class = diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index 1bde9cf..c223e5b 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -3957,7 +3957,8 @@ unlock: RXQ_RECV, \ NULL, /* rx_wait */ \ NULL, /* rxq_drain */ \ - NO_OFFLOAD_API \ + NO_OFFLOAD_API, \ + NULL /* get_block_id */ \ } static const struct netdev_class dpdk_class = diff --git a/lib/netdev-dummy.c b/lib/netdev-dummy.c index fbc98dd..d498467 100644 --- a/lib/netdev-dummy.c +++ b/lib/netdev-dummy.c @@ -1464,7 +1464,8 @@ netdev_dummy_update_flags(struct netdev *netdev_, netdev_dummy_rxq_wait, \ netdev_dummy_rxq_drain, \ \ - NO_OFFLOAD_API \ + NO_OFFLOAD_API, \ + NULL /* get_block_id */ \ } static const struct netdev_class dummy_class = diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index d89a0fb..8feab98 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -3115,7 +3115,8 @@ exit: netdev_linux_rxq_wait, \ netdev_linux_rxq_drain, \ \ - FLOW_OFFLOAD_API \ + FLOW_OFFLOAD_API, \ + NULL /* get_block_id */ \ } const struct netdev_class netdev_linux_class = diff --git a/lib/netdev-provider.h b/lib/netdev-provider.h index 4da579c..1a572f5 100644 --- a/lib/netdev-provider.h +++ b/lib/netdev-provider.h @@ -870,6 +870,10 @@ struct netdev_class { /* Initializies the netdev flow api. * Return 0 if successful, otherwise returns a positive errno value. */ int (*init_flow_api)(struct netdev *); + + /* Get a block_id from the netdev. + * Returns the block_id or 0 if none exists for netdev. */ + uint32_t (*get_block_id)(struct netdev *); }; int netdev_register_provider(const struct netdev_class *); diff --git a/lib/netdev-tc-offloads.c b/lib/netdev-tc-offloads.c index 14558ad..86dbeec 100644 --- a/lib/netdev-tc-offloads.c +++ b/lib/netdev-tc-offloads.c @@ -304,6 +304,16 @@ get_prio_for_tc_flower(struct tc_flower *flower) return new_data->prio; } +static uint32_t +get_block_id_from_netdev(struct netdev *netdev) +{ + if (block_support) { + return netdev_get_block_id(netdev); + } + + return 0; +} + int netdev_tc_flow_flush(struct netdev *netdev) { @@ -316,6 +326,8 @@ netdev_tc_flow_flush(struct netdev *netdev) return -ifindex; } + block_id = get_block_id_from_netdev(netdev); + return tc_flush(ifindex, block_id); } @@ -334,6 +346,7 @@ netdev_tc_flow_dump_create(struct netdev *netdev, return -ifindex; } + block_id = get_block_id_from_netdev(netdev); dump = xzalloc(sizeof *dump); dump->nl_dump = xzalloc(sizeof *dump->nl_dump); dump->netdev = netdev_ref(netdev); @@ -1098,6 +1111,7 @@ netdev_tc_flow_put(struct netdev *netdev, struct match *match, } } + block_id = get_block_id_from_netdev(netdev); handle = get_ufid_tc_mapping(ufid, &prio, NULL); if (handle && prio) { VLOG_DBG_RL(&rl, "updating old handle: %d prio: %d", handle, prio); @@ -1157,6 +1171,7 @@ netdev_tc_flow_get(struct netdev *netdev OVS_UNUSED, VLOG_DBG_RL(&rl, "flow get (dev %s prio %d handle %d)", netdev_get_name(dev), prio, handle); + block_id = get_block_id_from_netdev(netdev); err = tc_get_flower(ifindex, prio, handle, &flower, block_id); netdev_close(dev); if (err) { @@ -1200,6 +1215,8 @@ netdev_tc_flow_del(struct netdev *netdev OVS_UNUSED, return -ifindex; } + block_id = get_block_id_from_netdev(netdev); + if (stats) { memset(stats, 0, sizeof *stats); if (!tc_get_flower(ifindex, prio, handle, &flower, block_id)) { @@ -1289,6 +1306,7 @@ netdev_tc_init_flow_api(struct netdev *netdev) ovsthread_once_done(&block_once); } + block_id = get_block_id_from_netdev(netdev); error = tc_add_del_ingress_qdisc(ifindex, true, block_id); if (error && error != EEXIST) { diff --git a/lib/netdev-vport.c b/lib/netdev-vport.c index 1dae7e0..2290de9 100644 --- a/lib/netdev-vport.c +++ b/lib/netdev-vport.c @@ -1050,7 +1050,8 @@ netdev_vport_get_ifindex(const struct netdev *netdev_) NULL, /* rx_wait */ \ NULL, /* rx_drain */ \ \ - NETDEV_FLOW_OFFLOAD_API + NETDEV_FLOW_OFFLOAD_API, \ + NULL /* get_block_id */ #define TUNNEL_CLASS(NAME, DPIF_PORT, BUILD_HEADER, PUSH_HEADER, POP_HEADER, \ diff --git a/lib/netdev.c b/lib/netdev.c index 83614f5..82ffeb9 100644 --- a/lib/netdev.c +++ b/lib/netdev.c @@ -2225,6 +2225,16 @@ netdev_init_flow_api(struct netdev *netdev) : EOPNOTSUPP); } +uint32_t +netdev_get_block_id(struct netdev *netdev) +{ + const struct netdev_class *class = netdev->netdev_class; + + return (class->get_block_id + ? class->get_block_id(netdev) + : 0); +} + bool netdev_is_flow_api_enabled(void) { diff --git a/lib/netdev.h b/lib/netdev.h index 490b346..c941f1e 100644 --- a/lib/netdev.h +++ b/lib/netdev.h @@ -220,6 +220,7 @@ int netdev_flow_get(struct netdev *, struct match *, struct nlattr **actions, int netdev_flow_del(struct netdev *, const ovs_u128 *, struct dpif_flow_stats *); int netdev_init_flow_api(struct netdev *); +uint32_t netdev_get_block_id(struct netdev *); bool netdev_is_flow_api_enabled(void); void netdev_set_flow_api_enabled(const struct smap *ovs_other_config);