From patchwork Thu Jun 21 13:35:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Hurley X-Patchwork-Id: 932740 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="NgwYoOyB"; 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 41BN5h139Zz9s2R for ; Thu, 21 Jun 2018 23:36:40 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 3458FCE0; 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 AECD3CBA for ; Thu, 21 Jun 2018 13:36:12 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 5849E1A0 for ; Thu, 21 Jun 2018 13:36:11 +0000 (UTC) Received: by mail-wm0-f68.google.com with SMTP id z6-v6so3254937wma.0 for ; Thu, 21 Jun 2018 06:36:11 -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=x51nGT4WjSyL4Lk0KU4JPiNqntFDwCfU0/GPNmhxTtQ=; b=NgwYoOyBO8QvWfjjI4tNXigTVnh11aoU9HkAyNRv2/XpbzDJiGHoGyPTI3C7zdEz58 P5XZKwTY51wdjIOhWVUME4VpxED4S2HwdoWq6wGqNbv7eH0qWw6HPi58cqTZAZ66Pb0a 8L42F2Ca65Nv7cDhXrVCbZWmPS5ZRAExKtOz3KmDNPvyLYo4D7zxZGsjhyJP26VslU4D L8K13hjMVE/UF/jAa/fmRaaTKWmuPk3Yzkc/n5dzNWLL+dplz7PTx8/kiQdvNyVPvZbc HnMxJuIvW7N5QQPBCZsorjwcPrykl96xvHzK7AqgCFxOHaMBPzdTECWsXOMTvGBUM0JF y5RQ== 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=x51nGT4WjSyL4Lk0KU4JPiNqntFDwCfU0/GPNmhxTtQ=; b=tkkcas3+CpCCaf3GzDCNX32/9VLdWzJYPDmUhvdAzdzG3KN7w3ebcVCjjjVuJizLwR WNnJ4USXtlUwP5atlHPUyUgcv/N0LMOopNcNUTgTUmFRuChzhH8majhcvkBKJ/02XXfy tk96vvOsFXRDt79wn1IHkzuftE+IUW1vF6QmIsBsViR4XmW2+D/U2+TmS/a3Ddj/x8WE mkmeLudCTG1JW0QAZJ0youwlG0/VW0hI5bK9KPg87nkUfblvCnru59fxJzKDbdAoUizQ qhXu6cNpKeXHnNe+as3rxEEEJq5ssYheRRFBo4oa/ddPriBoIeZbD8q5r2EkOzPHyD2J 7+vA== X-Gm-Message-State: APt69E3umdQ+EwpF/i1Wi4Fm87KA23rLLG331DixIDLeL3R5iFp6lVbB OHTsCUhpP/3jJEwbuzDx71zGswUA X-Google-Smtp-Source: ADUXVKJ0zCvPfWoIFvkLFkDay+a2VGlILHfV/5GIeSthHlJu5rJ8AJ/Qf99Pdsl2hHDiAxGljMRXLw== X-Received: by 2002:a1c:5c82:: with SMTP id q124-v6mr5544234wmb.24.1529588169541; Thu, 21 Jun 2018 06:36:09 -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.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Jun 2018 06:36:08 -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:56 +0100 Message-Id: <1529588161-15934-2-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 1/6] tc: allow offloading of block ids 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 Blocks, in tc classifiers, allow the grouping of multiple qdiscs with an associated block id. Whenever a filter is added to/removed from this block, the filter is added to/removed from all associated qdiscs. Extend TC offload functions to take a block id as a parameter. If the id is zero then the dqisc is not considered part of a block. Signed-off-by: John Hurley Reviewed-by: Simon Horman Reviewed-by: Dirk van der Merwe --- lib/netdev-linux.c | 4 +-- lib/netdev-tc-offloads.c | 64 +++++++++++++++++++++++++++++++++++------------- lib/tc.c | 60 ++++++++++++++++++++++++++++++++------------- lib/tc.h | 12 ++++----- 4 files changed, 98 insertions(+), 42 deletions(-) diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index 054a9b6..d89a0fb 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -2275,7 +2275,7 @@ netdev_linux_set_policing(struct netdev *netdev_, COVERAGE_INC(netdev_set_policing); /* Remove any existing ingress qdisc. */ - error = tc_add_del_ingress_qdisc(ifindex, false); + error = tc_add_del_ingress_qdisc(ifindex, false, 0); if (error) { VLOG_WARN_RL(&rl, "%s: removing policing failed: %s", netdev_name, ovs_strerror(error)); @@ -2283,7 +2283,7 @@ netdev_linux_set_policing(struct netdev *netdev_, } if (kbits_rate) { - error = tc_add_del_ingress_qdisc(ifindex, true); + error = tc_add_del_ingress_qdisc(ifindex, true, 0); if (error) { VLOG_WARN_RL(&rl, "%s: adding policing qdisc failed: %s", netdev_name, ovs_strerror(error)); diff --git a/lib/netdev-tc-offloads.c b/lib/netdev-tc-offloads.c index 0d8cc2c..14558ad 100644 --- a/lib/netdev-tc-offloads.c +++ b/lib/netdev-tc-offloads.c @@ -44,6 +44,7 @@ static struct vlog_rate_limit error_rl = VLOG_RATE_LIMIT_INIT(60, 5); static struct hmap ufid_tc = HMAP_INITIALIZER(&ufid_tc); static bool multi_mask_per_prio = false; +static bool block_support = false; struct netlink_field { int offset; @@ -307,6 +308,7 @@ int netdev_tc_flow_flush(struct netdev *netdev) { int ifindex = netdev_get_ifindex(netdev); + uint32_t block_id = 0; if (ifindex < 0) { VLOG_ERR_RL(&error_rl, "flow_flush: failed to get ifindex for %s: %s", @@ -314,7 +316,7 @@ netdev_tc_flow_flush(struct netdev *netdev) return -ifindex; } - return tc_flush(ifindex); + return tc_flush(ifindex, block_id); } int @@ -322,6 +324,7 @@ netdev_tc_flow_dump_create(struct netdev *netdev, struct netdev_flow_dump **dump_out) { struct netdev_flow_dump *dump; + uint32_t block_id = 0; int ifindex; ifindex = netdev_get_ifindex(netdev); @@ -334,7 +337,7 @@ netdev_tc_flow_dump_create(struct netdev *netdev, dump = xzalloc(sizeof *dump); dump->nl_dump = xzalloc(sizeof *dump->nl_dump); dump->netdev = netdev_ref(netdev); - tc_dump_flower_start(ifindex, dump->nl_dump); + tc_dump_flower_start(ifindex, dump->nl_dump, block_id); *dump_out = dump; @@ -890,6 +893,7 @@ netdev_tc_flow_put(struct netdev *netdev, struct match *match, struct flow *mask = &match->wc.masks; const struct flow_tnl *tnl = &match->flow.tunnel; struct tc_action *action; + uint32_t block_id = 0; struct nlattr *nla; size_t left; int prio = 0; @@ -1097,7 +1101,7 @@ netdev_tc_flow_put(struct netdev *netdev, struct match *match, handle = get_ufid_tc_mapping(ufid, &prio, NULL); if (handle && prio) { VLOG_DBG_RL(&rl, "updating old handle: %d prio: %d", handle, prio); - tc_del_filter(ifindex, prio, handle); + tc_del_filter(ifindex, prio, handle, block_id); } if (!prio) { @@ -1111,7 +1115,7 @@ netdev_tc_flow_put(struct netdev *netdev, struct match *match, flower.act_cookie.data = ufid; flower.act_cookie.len = sizeof *ufid; - err = tc_replace_flower(ifindex, prio, handle, &flower); + err = tc_replace_flower(ifindex, prio, handle, &flower, block_id); if (!err) { add_ufid_tc_mapping(ufid, flower.prio, flower.handle, netdev, ifindex); } @@ -1131,6 +1135,7 @@ netdev_tc_flow_get(struct netdev *netdev OVS_UNUSED, static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 20); struct netdev *dev; struct tc_flower flower; + uint32_t block_id = 0; odp_port_t in_port; int prio = 0; int ifindex; @@ -1152,7 +1157,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); - err = tc_get_flower(ifindex, prio, handle, &flower); + err = tc_get_flower(ifindex, prio, handle, &flower, block_id); netdev_close(dev); if (err) { VLOG_ERR_RL(&error_rl, "flow get failed (dev %s prio %d handle %d): %s", @@ -1175,6 +1180,7 @@ netdev_tc_flow_del(struct netdev *netdev OVS_UNUSED, struct dpif_flow_stats *stats) { struct tc_flower flower; + uint32_t block_id = 0; struct netdev *dev; int prio = 0; int ifindex; @@ -1196,14 +1202,14 @@ netdev_tc_flow_del(struct netdev *netdev OVS_UNUSED, if (stats) { memset(stats, 0, sizeof *stats); - if (!tc_get_flower(ifindex, prio, handle, &flower)) { + if (!tc_get_flower(ifindex, prio, handle, &flower, block_id)) { stats->n_packets = get_32aligned_u64(&flower.stats.n_packets); stats->n_bytes = get_32aligned_u64(&flower.stats.n_bytes); stats->used = flower.lastused; } } - error = tc_del_filter(ifindex, prio, handle); + error = tc_del_filter(ifindex, prio, handle, block_id); del_ufid_tc_mapping(ufid); netdev_close(dev); @@ -1212,7 +1218,7 @@ netdev_tc_flow_del(struct netdev *netdev OVS_UNUSED, } static void -probe_multi_mask_per_prio(int ifindex) +probe_multi_mask_per_prio(int ifindex, uint32_t block_id) { struct tc_flower flower; int error; @@ -1224,7 +1230,7 @@ probe_multi_mask_per_prio(int ifindex) memset(&flower.key.dst_mac, 0x11, sizeof flower.key.dst_mac); memset(&flower.mask.dst_mac, 0xff, sizeof flower.mask.dst_mac); - error = tc_replace_flower(ifindex, 1, 1, &flower); + error = tc_replace_flower(ifindex, 1, 1, &flower, block_id); if (error) { return; } @@ -1232,23 +1238,42 @@ probe_multi_mask_per_prio(int ifindex) memset(&flower.key.src_mac, 0x11, sizeof flower.key.src_mac); memset(&flower.mask.src_mac, 0xff, sizeof flower.mask.src_mac); - error = tc_replace_flower(ifindex, 1, 2, &flower); - tc_del_filter(ifindex, 1, 1); + error = tc_replace_flower(ifindex, 1, 2, &flower, block_id); + tc_del_filter(ifindex, 1, 1, block_id); if (error) { return; } - tc_del_filter(ifindex, 1, 2); + tc_del_filter(ifindex, 1, 2, block_id); multi_mask_per_prio = true; VLOG_INFO("probe tc: multiple masks on single tc prio is supported."); } +static void +probe_tc_block_support(int ifindex) +{ + uint32_t block_id = 1; + int error; + + error = tc_add_del_ingress_qdisc(ifindex, true, block_id); + if (error) { + return; + } + + tc_add_del_ingress_qdisc(ifindex, false, block_id); + + block_support = true; + VLOG_INFO("probe tc: block offload is supported."); +} + int netdev_tc_init_flow_api(struct netdev *netdev) { - static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER; + static struct ovsthread_once multi_mask_once = OVSTHREAD_ONCE_INITIALIZER; + static struct ovsthread_once block_once = OVSTHREAD_ONCE_INITIALIZER; + uint32_t block_id = 0; int ifindex; int error; @@ -1259,7 +1284,12 @@ netdev_tc_init_flow_api(struct netdev *netdev) return -ifindex; } - error = tc_add_del_ingress_qdisc(ifindex, true); + if (ovsthread_once_start(&block_once)) { + probe_tc_block_support(ifindex); + ovsthread_once_done(&block_once); + } + + error = tc_add_del_ingress_qdisc(ifindex, true, block_id); if (error && error != EEXIST) { VLOG_ERR("failed adding ingress qdisc required for offloading: %s", @@ -1269,9 +1299,9 @@ netdev_tc_init_flow_api(struct netdev *netdev) VLOG_INFO("added ingress qdisc to %s", netdev_get_name(netdev)); - if (ovsthread_once_start(&once)) { - probe_multi_mask_per_prio(ifindex); - ovsthread_once_done(&once); + if (ovsthread_once_start(&multi_mask_once)) { + probe_multi_mask_per_prio(ifindex, block_id); + ovsthread_once_done(&multi_mask_once); } return 0; diff --git a/lib/tc.c b/lib/tc.c index 7133486..7a71036 100644 --- a/lib/tc.c +++ b/lib/tc.c @@ -43,6 +43,14 @@ #define MAX_PEDIT_OFFSETS 32 +#ifndef TCM_IFINDEX_MAGIC_BLOCK +#define TCM_IFINDEX_MAGIC_BLOCK (0xFFFFFFFFU) +#endif + +#if TCA_MAX < 14 +#define TCA_INGRESS_BLOCK 13 +#endif + VLOG_DEFINE_THIS_MODULE(tc); static struct vlog_rate_limit error_rl = VLOG_RATE_LIMIT_INIT(60, 5); @@ -173,10 +181,14 @@ tc_transact(struct ofpbuf *request, struct ofpbuf **replyp) * The configuration and stats may be seen with the following command: * /sbin/tc -s qdisc show dev * + * If block_id is greater than 0, then the ingress qdisc is added to a block. + * In this case, it is equivalent to running (when 'add' is true): + * /sbin/tc qdisc add dev ingress_block ingress + * * Returns 0 if successful, otherwise a positive errno value. */ int -tc_add_del_ingress_qdisc(int ifindex, bool add) +tc_add_del_ingress_qdisc(int ifindex, bool add, uint32_t block_id) { struct ofpbuf request; struct tcmsg *tcmsg; @@ -189,6 +201,9 @@ tc_add_del_ingress_qdisc(int ifindex, bool add) tcmsg->tcm_parent = TC_H_INGRESS; nl_msg_put_string(&request, TCA_KIND, "ingress"); nl_msg_put_unspec(&request, TCA_OPTIONS, NULL, 0); + if (block_id) { + nl_msg_put_u32(&request, TCA_INGRESS_BLOCK, block_id); + } error = tc_transact(&request, NULL); if (error) { @@ -1007,13 +1022,15 @@ parse_netlink_to_tc_flower(struct ofpbuf *reply, struct tc_flower *flower) } int -tc_dump_flower_start(int ifindex, struct nl_dump *dump) +tc_dump_flower_start(int ifindex, struct nl_dump *dump, uint32_t block_id) { struct ofpbuf request; struct tcmsg *tcmsg; + int index; - tcmsg = tc_make_request(ifindex, RTM_GETTFILTER, NLM_F_DUMP, &request); - tcmsg->tcm_parent = TC_INGRESS_PARENT; + index = block_id ? TCM_IFINDEX_MAGIC_BLOCK : ifindex; + tcmsg = tc_make_request(index, RTM_GETTFILTER, NLM_F_DUMP, &request); + tcmsg->tcm_parent = block_id ? : TC_INGRESS_PARENT; tcmsg->tcm_info = TC_H_UNSPEC; tcmsg->tcm_handle = 0; @@ -1024,28 +1041,32 @@ tc_dump_flower_start(int ifindex, struct nl_dump *dump) } int -tc_flush(int ifindex) +tc_flush(int ifindex, uint32_t block_id) { struct ofpbuf request; struct tcmsg *tcmsg; + int index; - tcmsg = tc_make_request(ifindex, RTM_DELTFILTER, NLM_F_ACK, &request); - tcmsg->tcm_parent = TC_INGRESS_PARENT; + index = block_id ? TCM_IFINDEX_MAGIC_BLOCK : ifindex; + tcmsg = tc_make_request(index, RTM_DELTFILTER, NLM_F_ACK, &request); + tcmsg->tcm_parent = block_id ? : TC_INGRESS_PARENT; tcmsg->tcm_info = TC_H_UNSPEC; return tc_transact(&request, NULL); } int -tc_del_filter(int ifindex, int prio, int handle) +tc_del_filter(int ifindex, int prio, int handle, uint32_t block_id) { struct ofpbuf request; struct tcmsg *tcmsg; struct ofpbuf *reply; int error; + int index; - tcmsg = tc_make_request(ifindex, RTM_DELTFILTER, NLM_F_ECHO, &request); - tcmsg->tcm_parent = TC_INGRESS_PARENT; + index = block_id ? TCM_IFINDEX_MAGIC_BLOCK : ifindex; + tcmsg = tc_make_request(index, RTM_DELTFILTER, NLM_F_ECHO, &request); + tcmsg->tcm_parent = block_id ? : TC_INGRESS_PARENT; tcmsg->tcm_info = tc_make_handle(prio, 0); tcmsg->tcm_handle = handle; @@ -1057,15 +1078,18 @@ tc_del_filter(int ifindex, int prio, int handle) } int -tc_get_flower(int ifindex, int prio, int handle, struct tc_flower *flower) +tc_get_flower(int ifindex, int prio, int handle, struct tc_flower *flower, + uint32_t block_id) { struct ofpbuf request; struct tcmsg *tcmsg; struct ofpbuf *reply; int error; + int index; - tcmsg = tc_make_request(ifindex, RTM_GETTFILTER, NLM_F_ECHO, &request); - tcmsg->tcm_parent = TC_INGRESS_PARENT; + index = block_id ? TCM_IFINDEX_MAGIC_BLOCK : ifindex; + tcmsg = tc_make_request(index, RTM_GETTFILTER, NLM_F_ECHO, &request); + tcmsg->tcm_parent = block_id ? : TC_INGRESS_PARENT; tcmsg->tcm_info = tc_make_handle(prio, 0); tcmsg->tcm_handle = handle; @@ -1625,7 +1649,7 @@ nl_msg_put_flower_options(struct ofpbuf *request, struct tc_flower *flower) int tc_replace_flower(int ifindex, uint16_t prio, uint32_t handle, - struct tc_flower *flower) + struct tc_flower *flower, uint32_t block_id) { struct ofpbuf request; struct tcmsg *tcmsg; @@ -1633,10 +1657,12 @@ tc_replace_flower(int ifindex, uint16_t prio, uint32_t handle, int error = 0; size_t basic_offset; uint16_t eth_type = (OVS_FORCE uint16_t) flower->key.eth_type; + int index; - tcmsg = tc_make_request(ifindex, RTM_NEWTFILTER, - NLM_F_CREATE | NLM_F_ECHO, &request); - tcmsg->tcm_parent = TC_INGRESS_PARENT; + index = block_id ? TCM_IFINDEX_MAGIC_BLOCK : ifindex; + tcmsg = tc_make_request(index, RTM_NEWTFILTER, NLM_F_CREATE | NLM_F_ECHO, + &request); + tcmsg->tcm_parent = block_id ? : TC_INGRESS_PARENT; tcmsg->tcm_info = tc_make_handle(prio, eth_type); tcmsg->tcm_handle = handle; diff --git a/lib/tc.h b/lib/tc.h index cc19374..80505f0 100644 --- a/lib/tc.h +++ b/lib/tc.h @@ -63,7 +63,7 @@ tc_get_minor(unsigned int handle) struct tcmsg *tc_make_request(int ifindex, int type, unsigned int flags, struct ofpbuf *); int tc_transact(struct ofpbuf *request, struct ofpbuf **replyp); -int tc_add_del_ingress_qdisc(int ifindex, bool add); +int tc_add_del_ingress_qdisc(int ifindex, bool add, uint32_t block_id); struct tc_cookie { const void *data; @@ -198,12 +198,12 @@ BUILD_ASSERT_DECL(offsetof(struct tc_flower, rewrite) + sizeof(uint32_t) - 2 < sizeof(struct tc_flower)); int tc_replace_flower(int ifindex, uint16_t prio, uint32_t handle, - struct tc_flower *flower); -int tc_del_filter(int ifindex, int prio, int handle); + struct tc_flower *flower, uint32_t block_id); +int tc_del_filter(int ifindex, int prio, int handle, uint32_t block_id); int tc_get_flower(int ifindex, int prio, int handle, - struct tc_flower *flower); -int tc_flush(int ifindex); -int tc_dump_flower_start(int ifindex, struct nl_dump *dump); + struct tc_flower *flower, uint32_t block_id); +int tc_flush(int ifindex, uint32_t block_id); +int tc_dump_flower_start(int ifindex, struct nl_dump *dump, uint32_t block_id); int parse_netlink_to_tc_flower(struct ofpbuf *reply, struct tc_flower *flower); void tc_set_policy(const char *policy); 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); From patchwork Thu Jun 21 13:35:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Hurley X-Patchwork-Id: 932742 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="VXKsDEJw"; 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 41BN7637dTz9s19 for ; Thu, 21 Jun 2018 23:37:54 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id E1ABCD14; Thu, 21 Jun 2018 13:36:16 +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 75A87CF1 for ; Thu, 21 Jun 2018 13:36:14 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr0-f172.google.com (mail-wr0-f172.google.com [209.85.128.172]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id D27071A0 for ; Thu, 21 Jun 2018 13:36:13 +0000 (UTC) Received: by mail-wr0-f172.google.com with SMTP id h10-v6so3230829wrq.8 for ; Thu, 21 Jun 2018 06:36:13 -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=LIUG3MR47Ik71fjeWonYWKxYaIlSXUPZRKqMENEcUf8=; b=VXKsDEJw+cyrAfeCspTZk8OmNw8E5/Eu1nW1Rz3uRp/PcgAiPmffF7iHYULh1hA5wJ 1dfIFEbzRxpqz9i/bC5zWx30IvoPV41Ikyi27ZgN8RmjADx9JM9YK6JwQog5GGia9Jv2 JV9QhAV5jUMknVYIW5jK4SJViGCNzw/IPs4W49Zx3VtVlaaV90ESGybyQef6+XnuTakg snKGMVny4hx3iO2PgJzArqQrRyHn0yhIm4oPR30NPtH42rIKj0LeAZ/dZ07WFZnxs2Qz 8Bo/IN/C+1nhLSsO8/chgRL8IT9bzmkoyOZt0j3+JZrASFhNVIxGpiU6thj3Nh39HIqY lXCw== 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=LIUG3MR47Ik71fjeWonYWKxYaIlSXUPZRKqMENEcUf8=; b=t8rjnw8mGigJnfWzFHYu+NKqhi2CZJw3AWdHYwFR01hj7hSOa4jr+X7Vb9FZQswsbM p23Ui3dm+J68T7/47IM/STUq1Do+zEr6vDofhlC8VIDDHavHDQ3r7LheTURbowcUuoAH qk2A1dTan22IcsymyJao7Fc1bfCFnL7X79Jv6bNYATjB0UScrOaUFvkLakbO6tpI29jk m7f8o8QsYIfaz6awCZmkAUafemvw4FqOzXXqSZIDKbLIFyIgpkI0qhFquLnnlAemiCQM 0uQWfe7mnZkFfDNrPoJuTzlhcVz68LYre66xn7+UX7RTljtvPO2LlN61oVsCtI0mlrpP cP2A== X-Gm-Message-State: APt69E0X2r13V0H+Cl4ODhhAVkU+aMcbba0Bjs3J4Ups4kVe6ShgYSo3 r05ywvcwNaIJpJdEyLUncQtT1LRQ X-Google-Smtp-Source: AAOMgpcZ+y429VJFV/lHCMR+gRgWHKc/YK+6RWekXDEt4XU9wpgKPL6jXijBqEXJSuEquu0Fqz8wZQ== X-Received: by 2002:adf:8d8d:: with SMTP id o13-v6mr1940720wrb.274.1529588172196; Thu, 21 Jun 2018 06:36:12 -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.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Jun 2018 06:36:11 -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:58 +0100 Message-Id: <1529588161-15934-4-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 3/6] rtnetlink: extend parser to include kind of master and slave 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 Extend the rtnetlink_parse function to look for linkinfo attributes and, in turn, store pointers to the master and slave kinds (if any) in the rtnetlink_change struct. Signed-off-by: John Hurley Reviewed-by: Simon Horman Reviewed-by: Dirk van der Merwe --- lib/rtnetlink.c | 43 +++++++++++++++++++++++++++++++++++++++++++ lib/rtnetlink.h | 4 ++++ 2 files changed, 47 insertions(+) mode change 100644 => 100755 lib/rtnetlink.h diff --git a/lib/rtnetlink.c b/lib/rtnetlink.c index 4d9003b..f822dff 100644 --- a/lib/rtnetlink.c +++ b/lib/rtnetlink.c @@ -27,6 +27,10 @@ #include "openvswitch/ofpbuf.h" #include "packets.h" +#if IFLA_INFO_MAX < 5 +#define IFLA_INFO_SLAVE_KIND 4 +#endif + static struct nln *nln = NULL; static struct rtnetlink_change rtn_change; @@ -45,6 +49,36 @@ rtnetlink_type_is_rtnlgrp_addr(uint16_t type) return type == RTM_NEWADDR || type == RTM_DELADDR; } +/* Parses nested nlattr for link info. Returns false if unparseable, else + * populates 'change' and returns true. */ +static bool +rtnetlink_parse_link_info(const struct nlattr *nla, + struct rtnetlink_change *change) +{ + bool parsed = false; + + static const struct nl_policy linkinfo_policy[] = { + [IFLA_INFO_KIND] = { .type = NL_A_STRING, .optional = true }, + [IFLA_INFO_SLAVE_KIND] = { .type = NL_A_STRING, .optional = true }, + }; + + struct nlattr *linkinfo[ARRAY_SIZE(linkinfo_policy)]; + + parsed = nl_parse_nested(nla, linkinfo_policy, linkinfo, + ARRAY_SIZE(linkinfo_policy)); + + if (parsed) { + change->master = (linkinfo[IFLA_INFO_KIND] + ? nl_attr_get_string(linkinfo[IFLA_INFO_KIND]) + : NULL); + change->slave = (linkinfo[IFLA_INFO_SLAVE_KIND] + ? nl_attr_get_string(linkinfo[IFLA_INFO_SLAVE_KIND]) + : NULL); + } + + return parsed; +} + /* Parses a rtnetlink message 'buf' into 'change'. If 'buf' is unparseable, * leaves 'change' untouched and returns false. Otherwise, populates 'change' * and returns true. */ @@ -64,6 +98,7 @@ rtnetlink_parse(struct ofpbuf *buf, struct rtnetlink_change *change) [IFLA_MASTER] = { .type = NL_A_U32, .optional = true }, [IFLA_MTU] = { .type = NL_A_U32, .optional = true }, [IFLA_ADDRESS] = { .type = NL_A_UNSPEC, .optional = true }, + [IFLA_LINKINFO] = { .type = NL_A_NESTED, .optional = true }, }; struct nlattr *attrs[ARRAY_SIZE(policy)]; @@ -94,6 +129,14 @@ rtnetlink_parse(struct ofpbuf *buf, struct rtnetlink_change *change) } else { memset(&change->mac, 0, ETH_ADDR_LEN); } + + if (attrs[IFLA_LINKINFO]) { + parsed = rtnetlink_parse_link_info(attrs[IFLA_LINKINFO], + change); + } else { + change->master = NULL; + change->slave = NULL; + } } } else if (rtnetlink_type_is_rtnlgrp_addr(nlmsg->nlmsg_type)) { /* Policy for RTNLGRP_IPV4_IFADDR/RTNLGRP_IPV6_IFADDR messages. diff --git a/lib/rtnetlink.h b/lib/rtnetlink.h old mode 100644 new mode 100755 index 518320f..422d1db --- a/lib/rtnetlink.h +++ b/lib/rtnetlink.h @@ -48,6 +48,10 @@ struct rtnetlink_change { /* Network device address status. */ /* xxx To be added when needed. */ + + /* Link info. */ + const char *master; /* Kind of master (NULL if not master). */ + const char *slave; /* Kind of slave (NULL if not slave). */ }; /* Function called to report that a netdev has changed. 'change' describes the From patchwork Thu Jun 21 13:35:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Hurley X-Patchwork-Id: 932743 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="QeL7hFiY"; 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 41BN7f4mRtz9s19 for ; Thu, 21 Jun 2018 23:38:22 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 92913D0B; Thu, 21 Jun 2018 13:36:17 +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 770A2C74 for ; Thu, 21 Jun 2018 13:36:15 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr0-f182.google.com (mail-wr0-f182.google.com [209.85.128.182]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id E0E481A0 for ; Thu, 21 Jun 2018 13:36:14 +0000 (UTC) Received: by mail-wr0-f182.google.com with SMTP id l8-v6so3252285wrr.2 for ; Thu, 21 Jun 2018 06:36:14 -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=VXDoVSy9hW94Vzr+6ulvXWuVfl1ZsNTR+qeJnMrb1m4=; b=QeL7hFiY1paZSSVILYgDPF/AGUoGkVg2qNtuL4QlmKYDu1oeS0xuwyYEVapYstI87l M2m4/hs0N5EW7Hi621q46A990E5qMnjSEOaw1o0A9LowY9jqZrJZbbFJZqyw+ZnafBJv vlUURa59qY8Dt93Z6hZ3pWNCpzY3qVmWCBl3cXQ1WEzM/yRbwoxWcxNGFwAFYkYsSrv/ +Xtbn0h1B0br9sB8nXE0WnCG3ZdHMmbiYUR68w5PnE8eEKHOwQQHwcgHW2EPe1/8qfB/ jRXOTu7zbgZicvGLRujHiSHY/rx6/AXZXKpbPf56nbgr/f7ot3Uos0kyk/EutGlCMRjV Nygw== 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=VXDoVSy9hW94Vzr+6ulvXWuVfl1ZsNTR+qeJnMrb1m4=; b=mC3fSmt58GsguQn50YCz1qv3FSR3Ul3ObEnLJICho8pzbgHbio5chzrjuqlV7bHZ5+ 1KHUOBRPUHicaf+xi//EvVHn+c3egWJAo3RGTfWNBNKbGGr4PIrlG0anVGdxQtcyQH0B a4AkC/uNM5RDw7JbhiZGAi8A1aStzEX3fHUUbFiWGiLy5B+APZskbxfZFwgCaHkrVpgD 8XJPfZy1uGElH94T0+TM5Pt2118WBuZaxF1VnqzMM9HSJjwUQnNVEcv/zH22R2jyTxnT SvesW+/C1mXxZDCP+Xnv6MdfEJkTaK12xU3yfJ1qfyb4fYgFEjBC/sYO2WBg0M3DQ5d1 3ewA== X-Gm-Message-State: APt69E2Wd4TJmbJiV47Yze/cdkTdqXgMt1Zy6YLLv2Y9B/KFlP7h0byF XvSSBv6Psm460gwsxiazqSHlGDpL X-Google-Smtp-Source: ADUXVKKL9McIZmzC0q4byc7uevsPSyRwQ5GkunGKGoGy+Cc5RcCLpMRlm6yBIreKMfOTAROV0WgO2w== X-Received: by 2002:adf:e447:: with SMTP id t7-v6mr22637434wrm.145.1529588173372; Thu, 21 Jun 2018 06:36:13 -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.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Jun 2018 06:36:12 -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:59 +0100 Message-Id: <1529588161-15934-5-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 4/6] netdev-linux: indicate if netdev is a LAG master 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 If a linux netdev is added to OvS that is a LAG master (for example, a bond or team netdev) then record this in bool form in the dev struct. Use the link info extracted from rtnetlink calls to determine this. Signed-off-by: John Hurley Reviewed-by: Dirk van der Merwe Reviewed-by: Simon Horman --- lib/netdev-linux.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index 8feab98..6ed2f05 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -509,6 +509,9 @@ struct netdev_linux { int tap_fd; bool present; /* If the device is present in the namespace */ uint64_t tx_dropped; /* tap device can drop if the iface is down */ + + /* LAG information. */ + bool is_lag_master; /* True if the netdev is a LAG master. */ }; struct netdev_rxq_linux { @@ -678,6 +681,16 @@ netdev_linux_miimon_enabled(void) return atomic_count_get(&miimon_cnt) > 0; } +static bool +netdev_linux_kind_is_lag(const char *kind) +{ + if (!strcmp(kind, "bond") || !strcmp(kind, "team")) { + return true; + } + + return false; +} + static void netdev_linux_run(const struct netdev_class *netdev_class OVS_UNUSED) { @@ -812,6 +825,10 @@ netdev_linux_update__(struct netdev_linux *dev, rtnetlink_report_link(); } + if (change->master && netdev_linux_kind_is_lag(change->master)) { + dev->is_lag_master = true; + } + dev->ifindex = change->if_index; dev->cache_valid |= VALID_IFINDEX; dev->get_ifindex_error = 0; @@ -5764,6 +5781,9 @@ netdev_linux_update_via_netlink(struct netdev_linux *netdev) netdev->get_ifindex_error = 0; changed = true; } + if (change->master && netdev_linux_kind_is_lag(change->master)) { + netdev->is_lag_master = true; + } if (changed) { netdev_change_seq_changed(&netdev->up); } From patchwork Thu Jun 21 13:36:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Hurley X-Patchwork-Id: 932744 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="c2trnzY7"; 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 41BN8B4P9Yz9s19 for ; Thu, 21 Jun 2018 23:38:50 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 4A007D25; Thu, 21 Jun 2018 13:36:18 +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 8E899D01 for ; Thu, 21 Jun 2018 13:36:16 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr0-f181.google.com (mail-wr0-f181.google.com [209.85.128.181]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 0119D1A0 for ; Thu, 21 Jun 2018 13:36:15 +0000 (UTC) Received: by mail-wr0-f181.google.com with SMTP id e18-v6so3242103wrs.5 for ; Thu, 21 Jun 2018 06:36:15 -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=F+flqhbn6pkMob4D5V2eH9F8Q90vLKU38ufLhP/54QM=; b=c2trnzY7wRM3c8Q8QiNpyWGors0SHX4VHjQvIVVkQv8fFNip9AMzoBkQ8ZFOrAbnbU OspIVuzhGFaYtvIhAYY6Gv7PqEzShW2dPNV61rB1e5qEMrEan8f/buB8lM1WSWCO4R2j /1vH45t4QXnPSU4PesQwiwFubb7C12tty6PEszpkhCgT+8L8uEOEstZrhD8aHYNuvbnS eDlD9ZNA6Rhjx2n9v50kPDf8FQmSDfSAA5t2cQzUlcjraW8dcRJ0fVv+c8eedggLgTbZ 9wEJRH1AX3dkykfOKVvTjgeV6JlzK1NuJIwYs0V75xDHMRls7O9baqeBAvk39G1DdCtH OvCQ== 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=F+flqhbn6pkMob4D5V2eH9F8Q90vLKU38ufLhP/54QM=; b=esxY17R96HEF9bQNs1KMa1i7hRSALarA9agH9JyisvW5/FUYnPBXoeMFBJbL0D7jmr +rJnvZCOf/iWrTxzl48/RfwcDE7PMmODmK56Y29qvm5hSX9YbzSWpaHBAztnfTHMgZVA WxvyV1MjbT0UI2g1XfhtHGU+E6LicGG24w7JvvzTVPcXlS6Q5CXW1fD6bpmo2az/Pfd3 LXN9J3N8iuWtFjI9wRWtVEfZK+olAupgOeuIAGHOQj8q8/HWdaO7vWicFDRa5vtbyGpp 2/SC7F6sl4wSTAGvqxoQMcH095Oh4kFBLdmZisDFJpM4iJZR/8zAsii4p6q0c117YINQ Caww== X-Gm-Message-State: APt69E2U0aH1EZU1HKIie5DCgZJRXcnLgLQcOMTJKuUPafzCKVEpC45E zQwxgInHZ3voMPXjSKqBjmqsB6WV X-Google-Smtp-Source: ADUXVKI+wMbZ3Ap4YUV85T0m/8Qgoa4MECkRQy2hSR/xoU6ehlPEg+VZJWeFedRz8+gH4bj77pFFwg== X-Received: by 2002:adf:e48e:: with SMTP id i14-v6mr23479210wrm.8.1529588174440; Thu, 21 Jun 2018 06:36:14 -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.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Jun 2018 06:36:13 -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:36:00 +0100 Message-Id: <1529588161-15934-6-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 5/6] netdev-linux: assign LAG devs to tc blocks 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 Assign block ids to LAG masters that are added to OvS as linux-netdevs and offloaded via offload API calls. Only LAG masters are assigned to blocks. To ensure uniqueness, the block ids are determined by the netdev ifindex. Implement a get_block_id op for linux netdevs to achieve this. Signed-off-by: John Hurley Reviewed-by: Dirk van der Merwe Reviewed-by: Simon Horman --- lib/netdev-linux.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index 6ed2f05..81de3b1 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -2945,6 +2945,27 @@ netdev_internal_get_status(const struct netdev *netdev OVS_UNUSED, return 0; } +static uint32_t +netdev_linux_get_block_id(struct netdev *netdev_) +{ + struct netdev_linux *netdev = netdev_linux_cast(netdev_); + uint32_t block_id = 0; + + ovs_mutex_lock(&netdev->mutex); + /* Ensure the linux netdev has had its fields populated. */ + if (!(netdev->cache_valid & VALID_IFINDEX)) { + netdev_linux_update_via_netlink(netdev); + } + + /* Only assigning block ids to linux netdevs that are LAG masters. */ + if (netdev->is_lag_master) { + block_id = netdev->ifindex; + } + ovs_mutex_unlock(&netdev->mutex); + + return block_id; +} + /* Looks up the ARP table entry for 'ip' on 'netdev'. If one exists and can be * successfully retrieved, it stores the corresponding MAC address in 'mac' and * returns 0. Otherwise, it returns a positive errno value; in particular, @@ -3060,7 +3081,7 @@ exit: #define NETDEV_LINUX_CLASS(NAME, CONSTRUCT, GET_STATS, \ GET_FEATURES, GET_STATUS, \ - FLOW_OFFLOAD_API) \ + FLOW_OFFLOAD_API, GET_BLOCK_ID) \ { \ NAME, \ false, /* is_pmd */ \ @@ -3133,7 +3154,7 @@ exit: netdev_linux_rxq_drain, \ \ FLOW_OFFLOAD_API, \ - NULL /* get_block_id */ \ + GET_BLOCK_ID \ } const struct netdev_class netdev_linux_class = @@ -3143,7 +3164,8 @@ const struct netdev_class netdev_linux_class = netdev_linux_get_stats, netdev_linux_get_features, netdev_linux_get_status, - LINUX_FLOW_OFFLOAD_API); + LINUX_FLOW_OFFLOAD_API, + netdev_linux_get_block_id); const struct netdev_class netdev_tap_class = NETDEV_LINUX_CLASS( @@ -3152,7 +3174,8 @@ const struct netdev_class netdev_tap_class = netdev_tap_get_stats, netdev_linux_get_features, netdev_linux_get_status, - NO_OFFLOAD_API); + NO_OFFLOAD_API, + NULL); const struct netdev_class netdev_internal_class = NETDEV_LINUX_CLASS( @@ -3161,7 +3184,8 @@ const struct netdev_class netdev_internal_class = netdev_internal_get_stats, NULL, /* get_features */ netdev_internal_get_status, - NO_OFFLOAD_API); + NO_OFFLOAD_API, + NULL); #define CODEL_N_QUEUES 0x0000 From patchwork Thu Jun 21 13:36:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Hurley X-Patchwork-Id: 932746 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="1IZQIAfU"; 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 41BN8x220gz9s2R for ; Thu, 21 Jun 2018 23:39:29 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 3ED42D40; Thu, 21 Jun 2018 13:36:20 +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 6A8E0D36 for ; Thu, 21 Jun 2018 13:36:18 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr0-f194.google.com (mail-wr0-f194.google.com [209.85.128.194]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 3EBE91A0 for ; Thu, 21 Jun 2018 13:36:17 +0000 (UTC) Received: by mail-wr0-f194.google.com with SMTP id k16-v6so3259819wro.0 for ; Thu, 21 Jun 2018 06:36:17 -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=o8fKazfmeeQMc8QrltGB7YNJFWIHK7VSqv2N72eGmII=; b=1IZQIAfULLPHCD6XjSh70urH41fG5ykOoIQctBN21i1eQQDsOTLuePbIQZVomcLJX9 Fkd8ZansAv8p8ipculHr7qc/ovnv7hktXu6MBtC/YM8ZvVjc/MHcvSOeWDDFiCW0JgrF iuvIysCZq+i6mCJ3AePDuuit8Kn1JH4KUB9MEsbb3p5lJVK8wTdjBlPd4f0HcinhUlN7 TnL4ONa7SD99t+EVmBMsKQDea9Fyr/6uWIV6zFzBeY7/xx1nTlAAsZ+jdVBDNgbStaOC ss9cAZtEj7vwKSWriWwrgRMzbw2IfVPFYalanhjWKzGPRLVQSzdNREk91XSufdER/Fi3 XFbg== 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=o8fKazfmeeQMc8QrltGB7YNJFWIHK7VSqv2N72eGmII=; b=pMItWFNb1Bnb0LEeFqiGnWRGATPJdv8MSAxDeL5MBaO3DGxqAD64mZmBQjlsUVrr+/ rt8ej8gEu8TvZvGQu5Whvmqi19daovk3hl4AsA1SSK1LDwwlZTKfJ0/0Hc/TbggEu2N1 XsBPsbdLSAArP/mblR5zZjEkGs7bN6zRkWXTbQedxlhljr9fhytOiEkMSPeqNXsl+Y5U ZCy84xDtkSd5f3yT+tp7cF64mYWgWHYNyuC2V7LON8BRHtLIy6+TiP49Egn6OSNV2/jl cwHueuf9qE5f8MHAsfE6QuoIIFxtciPCI3VnCioHmIjSe6s6/Ygjhw2Sro4SAWfbanNo KkBw== X-Gm-Message-State: APt69E1hBBo1aV5oJMwQSX+RKxIJAPZYsB9pdj8DBS9WCAYBkkVQVjYT yXgiVM3hcNnagTlL+vlO6xN87mC1 X-Google-Smtp-Source: ADUXVKKdUJnh80ky2xHryGqgbKkcKctHTZ+hAOkqu7vYQL7wEg5nkuRy2Def8XffJOg3SV9ZLw+M7Q== X-Received: by 2002:adf:8701:: with SMTP id a1-v6mr23108187wra.178.1529588175614; Thu, 21 Jun 2018 06:36:15 -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.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Jun 2018 06:36:14 -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:36:01 +0100 Message-Id: <1529588161-15934-7-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 6/6] netdev-linux: monitor and offload LAG slaves to TC 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 A LAG slave cannot be added directly to an OvS bridge, nor can a OvS bridge port be added to a LAG dev. However, LAG masters can be added to OvS. Use TC blocks to indirectly offload slaves when their master is attached as a linux-netdev to an OvS bridge. In the kernel TC datapath, blocks link together netdevs in a similar way to LAG devices. For example, if a filter is added to a block then it is added to all block devices, or if stats are incremented on 1 device then the stats on the entire block are incremented. This mimics LAG devices in that if a rule is applied to the LAG master then it should be applied to all slaves etc. Monitor LAG slaves via the netlink socket in netdev-linux and, if their master is attached to the OvS bridge and has a block id, add the slave's qdisc to the same block. Similarly, if a slave is freed from a master, remove the qdisc from the masters block. Signed-off-by: John Hurley Reviewed-by: Simon Horman Reviewed-by: Dirk van der Merwe --- lib/netdev-linux.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index 81de3b1..f2b1dfd 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -233,6 +233,18 @@ enum { VALID_FEATURES = 1 << 7, }; +struct linux_lag_slave { + uint32_t block_id; + struct shash_node *node; +}; + +/* Protects 'lag_shash' and the mutable members of struct linux_lag_slave. */ +static struct ovs_mutex lag_mutex = OVS_MUTEX_INITIALIZER; + +/* All slaves whose LAG masters are network devices in OvS. */ +static struct shash lag_shash OVS_GUARDED_BY(lag_mutex) + = SHASH_INITIALIZER(&lag_shash); + /* Traffic control. */ /* An instance of a traffic control class. Always associated with a particular @@ -692,6 +704,57 @@ netdev_linux_kind_is_lag(const char *kind) } static void +netdev_linux_update_lag(struct rtnetlink_change *change) + OVS_REQUIRES(lag_mutex) +{ + struct linux_lag_slave *lag; + + if (change->slave && netdev_linux_kind_is_lag(change->slave)) { + lag = shash_find_data(&lag_shash, change->ifname); + + if (!lag) { + struct netdev *master_netdev; + char master_name[IFNAMSIZ]; + uint32_t block_id; + int error = 0; + + if_indextoname(change->master_ifindex, master_name); + master_netdev = netdev_from_name(master_name); + + if (is_netdev_linux_class(master_netdev->netdev_class)) { + block_id = netdev_get_block_id(master_netdev); + if (!block_id) { + return; + } + + lag = xmalloc(sizeof *lag); + lag->block_id = block_id; + lag->node = shash_add(&lag_shash, change->ifname, lag); + + /* LAG master is linux netdev so add slave to same block. */ + error = tc_add_del_ingress_qdisc(change->if_index, true, + block_id); + if (error) { + VLOG_WARN("failed to bind LAG slave to master's block"); + shash_delete(&lag_shash, lag->node); + free(lag); + } + } + } + } else if (change->master_ifindex == 0) { + /* Check if this was a lag slave that has been freed. */ + lag = shash_find_data(&lag_shash, change->ifname); + + if (lag) { + tc_add_del_ingress_qdisc(change->if_index, false, + lag->block_id); + shash_delete(&lag_shash, lag->node); + free(lag); + } + } +} + +static void netdev_linux_run(const struct netdev_class *netdev_class OVS_UNUSED) { struct nl_sock *sock; @@ -734,6 +797,12 @@ netdev_linux_run(const struct netdev_class *netdev_class OVS_UNUSED) netdev_linux_update(netdev, nsid, &change); ovs_mutex_unlock(&netdev->mutex); } + else if (!netdev_) { + /* Netdev is not present in OvS but its master could be. */ + ovs_mutex_lock(&lag_mutex); + netdev_linux_update_lag(&change); + ovs_mutex_unlock(&lag_mutex); + } netdev_close(netdev_); } } else if (error == ENOBUFS) {