From patchwork Thu Nov 2 16:14:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 833415 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="tUKZ9nvG"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3ySVXQ6Sp1z9t2r for ; Fri, 3 Nov 2017 03:14:30 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934135AbdKBQO3 (ORCPT ); Thu, 2 Nov 2017 12:14:29 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:46061 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933418AbdKBQOU (ORCPT ); Thu, 2 Nov 2017 12:14:20 -0400 Received: by mail-wr0-f194.google.com with SMTP id y9so55787wrb.2 for ; Thu, 02 Nov 2017 09:14:20 -0700 (PDT) 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:in-reply-to:references; bh=tQ+yxe3bGz/QaJKnFNfhhtDC+I8ueTIsgxTTURP2Y9k=; b=tUKZ9nvGGhNbFbj1KU7RE3Pi+z/L03+THm5RO1WzVtggQzEshLQDFGneqQC5MW2PRX v320cc/H5NfQs7Su9/KJXxH4tY9vyulvj6Jo4olwT83qZPq0EE5RLmAf2+AE6AogyQmx yPVuIBOgUw7gW2mY9kkPnTGyqcD2q4HvfioK+oB/LFMB39tjjiBNhWKkRX/p2sZ4o4T4 JcnotQAtrk6tdgje6+GTjv10m9YdshL/g92pIaaM2cUsYra30wMcpOT9JkROJLcykUT1 yOxnZJJiR+I9cxaBIDBHCet6dGpNhj0+rmGYAIqNeFyNLq/8Y6sbOQksQsOWK9I+NS2S wSrQ== 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=tQ+yxe3bGz/QaJKnFNfhhtDC+I8ueTIsgxTTURP2Y9k=; b=fot8FAGkuBtcUdmNKVYIkrrmEfVDC5m3BKpa/dBIaW8GrMXDDW7LBOpvEP/AZiKCX1 T5MusnUb1JuKNZbszXN6mIjp0U8WKdNAB97yQ8OtgYLgKwverDyJ6yOyqYliORWgyU9B vVL24hP3CVAvCijITf9lfmpJR1XtR9nDixL/FEPNfcCf+nlThUC6/0gDfyNbCG151OF6 b6QAKeJbrAsEhFTZqO7l/a+JRUpMXla68I7IQv4wSUCAtVDULqKgZFEeUDClZEuG/EZM EUte5ud8Uguo8yUHT1fl3taEbN/uurv4lEMmvPctAygQ6DgVcCPCTfXSLEgKxoM5Q6M8 BQ5w== X-Gm-Message-State: AMCzsaVwdUNOTULcL3nnXsk+AAawvMBD2F977ZBzs6zVJwkpRaCUxHzH 5B22OifOlCsRjy7K1vHFUQebGOQr X-Google-Smtp-Source: ABhQp+QkschJQ9Oyjv6z70gHL81gWB7jxYVQmov1N0o1T9Kmo1UGcy+4FuSTbOXGafr18iTHf9ofiw== X-Received: by 10.223.198.134 with SMTP id j6mr3191397wrg.213.1509639259569; Thu, 02 Nov 2017 09:14:19 -0700 (PDT) Received: from localhost (ip-94-113-127-32.net.upcbroadband.cz. [94.113.127.32]) by smtp.gmail.com with ESMTPSA id z192sm3281wmc.32.2017.11.02.09.14.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Nov 2017 09:14:19 -0700 (PDT) From: Jiri Pirko To: netdev@vger.kernel.org Cc: davem@davemloft.net, idosch@mellanox.com, mlxsw@mellanox.com, dsahern@gmail.com Subject: [patch net-next 6/6] mlxsw: spectrum_router: Update multipath hash parameters upon netevents Date: Thu, 2 Nov 2017 17:14:10 +0100 Message-Id: <20171102161410.12171-7-jiri@resnulli.us> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171102161410.12171-1-jiri@resnulli.us> References: <20171102161410.12171-1-jiri@resnulli.us> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Ido Schimmel Make sure the device and the kernel are performing the multipath hash according to the same parameters by updating the device whenever the relevant netevent is generated. Signed-off-by: Ido Schimmel Reviewed-by: Petr Machata Signed-off-by: Jiri Pirko --- .../net/ethernet/mellanox/mlxsw/spectrum_router.c | 31 +++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c index fe99d24..d657f01 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c @@ -2078,15 +2078,29 @@ static void mlxsw_sp_router_neigh_event_work(struct work_struct *work) kfree(net_work); } -static int mlxsw_sp_router_netevent_event(struct notifier_block *unused, +static int mlxsw_sp_mp_hash_init(struct mlxsw_sp *mlxsw_sp); + +static void mlxsw_sp_router_mp_hash_event_work(struct work_struct *work) +{ + struct mlxsw_sp_netevent_work *net_work = + container_of(work, struct mlxsw_sp_netevent_work, work); + struct mlxsw_sp *mlxsw_sp = net_work->mlxsw_sp; + + mlxsw_sp_mp_hash_init(mlxsw_sp); + kfree(net_work); +} + +static int mlxsw_sp_router_netevent_event(struct notifier_block *nb, unsigned long event, void *ptr) { struct mlxsw_sp_netevent_work *net_work; struct mlxsw_sp_port *mlxsw_sp_port; + struct mlxsw_sp_router *router; struct mlxsw_sp *mlxsw_sp; unsigned long interval; struct neigh_parms *p; struct neighbour *n; + struct net *net; switch (event) { case NETEVENT_DELAY_PROBE_TIME_UPDATE: @@ -2138,6 +2152,21 @@ static int mlxsw_sp_router_netevent_event(struct notifier_block *unused, mlxsw_core_schedule_work(&net_work->work); mlxsw_sp_port_dev_put(mlxsw_sp_port); break; + case NETEVENT_MULTIPATH_HASH_UPDATE: + net = ptr; + + if (!net_eq(net, &init_net)) + return NOTIFY_DONE; + + net_work = kzalloc(sizeof(*net_work), GFP_ATOMIC); + if (!net_work) + return NOTIFY_BAD; + + router = container_of(nb, struct mlxsw_sp_router, netevent_nb); + INIT_WORK(&net_work->work, mlxsw_sp_router_mp_hash_event_work); + net_work->mlxsw_sp = router->mlxsw_sp; + mlxsw_core_schedule_work(&net_work->work); + break; } return NOTIFY_DONE;