From patchwork Fri Jan 12 16:15:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 860030 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=resnulli-us.20150623.gappssmtp.com header.i=@resnulli-us.20150623.gappssmtp.com header.b="iUluGKT9"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zJ7CT65cnz9t3p for ; Sat, 13 Jan 2018 03:16:05 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934063AbeALQQC (ORCPT ); Fri, 12 Jan 2018 11:16:02 -0500 Received: from mail-wr0-f194.google.com ([209.85.128.194]:46521 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934004AbeALQQB (ORCPT ); Fri, 12 Jan 2018 11:16:01 -0500 Received: by mail-wr0-f194.google.com with SMTP id g21so5718275wrb.13 for ; Fri, 12 Jan 2018 08:16:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=gXaL1Dsl98ft6aJo4anAEUSUCX9duJT1+5uHnhTgtk4=; b=iUluGKT9jWmH19VM85igop4Yv684YPMKEuf3BY1MfLaWI9AaQlX4ZI466HO+uIt097 7C/giYllj9OAyblJHZfwOQyAINNrqI9nEbwy7ecaLGQqrRynPwMjQfsyd4UMvwSFChdR BL6S5E6b1B6680M8+3+Ae88Lk+OMYp5olUE8rNMCpMmJfKC/viV4RXAdEYwuTDhMHKIM AykD4BW+lf210UKm9vhTYgb8+knBxlPq2kLFLsXUkGoYT+y5yype0Bi1PTDTqkchH7Gt EY+mg9cbE3mt7tAvtQGYPkBjrSw3ja7SpLP16jOIFjlGatSBgg3TeaJ1r61cu7yQUwbz HYEA== 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; bh=gXaL1Dsl98ft6aJo4anAEUSUCX9duJT1+5uHnhTgtk4=; b=OszzSgojFdeeMypXI2RNehnoskLvD8W2e6EnAxzot5Kn02olra8RPBrSF7q4uZJ55V 2kM1PxXC/2epks4M3JEvSYhHFLMJqoO6QNybbyh9Z+jP09If5wnKp5ckDJ/MkXlxFvnN BEfxxYw4vVMvyrAb+Y+u0KpdknBjfDzlrdO+BK6ExC6HNd3eJ/G37Tm1sJs6MDw5aAn8 ByYzcaDZoDuUeOy4tCMY2fcNNRz0vB79A69JlTEG3aiARFa4HBytT7fFdZ+q9rxyGaLL yf2sBBBXUNAmLfGtC7F1106VGgWtW3xObh6W+7Tv+XrOxgX1Ku00Mn8dWTl+HTuq1hjf U9oA== X-Gm-Message-State: AKGB3mId2tlpgjJXLVzRTy1chjKQyh0NyLxbhpMLQHtP/AQCaNZfv5he ue8Ain122KiR3HtJWRwUzhSsJMFE X-Google-Smtp-Source: ACJfBotbM/NzeBPzh8Yn/YKAZW6d/RFoMh4St8A8Y/rtFhJ8y+Z9sLlbnuuh2b7fG+mU1ZTJmeOwYw== X-Received: by 10.223.133.207 with SMTP id 15mr24852845wru.231.1515773760494; Fri, 12 Jan 2018 08:16:00 -0800 (PST) Received: from localhost (jirka.pirko.cz. [84.16.102.26]) by smtp.gmail.com with ESMTPSA id v75sm3018058wrc.45.2018.01.12.08.16.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Jan 2018 08:16:00 -0800 (PST) From: Jiri Pirko To: netdev@vger.kernel.org Cc: davem@davemloft.net, idosch@mellanox.com, mlxsw@mellanox.com Subject: [patch net-next] mlxsw: spectrum_router: Add support for IPv6 non-equal-cost multipath Date: Fri, 12 Jan 2018 17:15:59 +0100 Message-Id: <20180112161559.27691-1-jiri@resnulli.us> X-Mailer: git-send-email 2.14.3 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Ido Schimmel Since commit eb789980d0aa ("mlxsw: spectrum_router: Populate adjacency entries according to weights") the driver includes support for non-equal-cost multipath, but IPv4 nexthops were the only user. Now that the kernel supports weighted IPv6 nexthops, we can extend the driver to support it as well. This is done by assigning each nexthop its configured weight, so that it will be populated accordingly in the device's adjacency table. The `weight` parameter is also taken into account when comparing nexthop groups in order not to consolidate non-identical groups. Signed-off-by: Ido Schimmel Signed-off-by: Jiri Pirko --- drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c index 434b3922b34f..7a136256b8f7 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c @@ -2628,7 +2628,8 @@ struct mlxsw_sp_nexthop_group_cmp_arg { static bool mlxsw_sp_nexthop6_group_has_nexthop(const struct mlxsw_sp_nexthop_group *nh_grp, - const struct in6_addr *gw, int ifindex) + const struct in6_addr *gw, int ifindex, + int weight) { int i; @@ -2636,7 +2637,7 @@ mlxsw_sp_nexthop6_group_has_nexthop(const struct mlxsw_sp_nexthop_group *nh_grp, const struct mlxsw_sp_nexthop *nh; nh = &nh_grp->nexthops[i]; - if (nh->ifindex == ifindex && + if (nh->ifindex == ifindex && nh->nh_weight == weight && ipv6_addr_equal(gw, (struct in6_addr *) nh->gw_addr)) return true; } @@ -2655,11 +2656,13 @@ mlxsw_sp_nexthop6_group_cmp(const struct mlxsw_sp_nexthop_group *nh_grp, list_for_each_entry(mlxsw_sp_rt6, &fib6_entry->rt6_list, list) { struct in6_addr *gw; - int ifindex; + int ifindex, weight; ifindex = mlxsw_sp_rt6->rt->dst.dev->ifindex; + weight = mlxsw_sp_rt6->rt->rt6i_nh_weight; gw = &mlxsw_sp_rt6->rt->rt6i_gateway; - if (!mlxsw_sp_nexthop6_group_has_nexthop(nh_grp, gw, ifindex)) + if (!mlxsw_sp_nexthop6_group_has_nexthop(nh_grp, gw, ifindex, + weight)) return false; } @@ -4762,7 +4765,7 @@ static int mlxsw_sp_nexthop6_init(struct mlxsw_sp *mlxsw_sp, struct net_device *dev = rt->dst.dev; nh->nh_grp = nh_grp; - nh->nh_weight = 1; + nh->nh_weight = rt->rt6i_nh_weight; memcpy(&nh->gw_addr, &rt->rt6i_gateway, sizeof(nh->gw_addr)); mlxsw_sp_nexthop_counter_alloc(mlxsw_sp, nh);