Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3869962pxb; Tue, 17 Nov 2020 05:51:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJzqQrLK5IdWZ4lr/Lkc2ASnAD5nL2j8Oe23R26qCnzfOidPfXgU0LmPdb94xy8mQfLaldWY X-Received: by 2002:a05:6402:b44:: with SMTP id bx4mr10131466edb.373.1605621067903; Tue, 17 Nov 2020 05:51:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605621067; cv=none; d=google.com; s=arc-20160816; b=KEPw6S3grbfsoMpRHrC1Wl69KNFElQ6LAnclGRyzKtnebwC/xkCVQVuzyoxUf7DLfV cM97wGwUlJdIQ6cCt0py2nJrW/Oh1EDgpbQiCRZcyBpyN1BJT4JXj4EXm11pXd9kIg3u okXpycFvEIk5cGu4vLfSROxJ6WKK9IJk9ukmM1Ma+PAlssJZm6cly6y+PhonAiVxi2/E ppXf9g1XmxzwmpvZiFa1dGt3Dh4Q5ERX6n7uSf0oSWUneS/UFco3kdMAQSnDhxPkuk81 UwWDbfIe5rqQW6dxFOtks0ZfJZL4h7pkgDjVhF9gwirmIp0MoI7jFmNG7q0528wVwWl4 oP+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VcF70xEvRBVv6r+c2/Gs5dFdXdrzV6wqk0j+VUqIoEI=; b=gJQeFXt4PQOvBXQfhcPBHOnDbu9bciS5TlroH7Adcb5s0bVA5bM0yj1yVPl/usPRmk RgEAbx6CKzWhmM51wKLTqCA9O15SiW1CUqgX1q8y8bbYfUSbR3gxO8ZV9MYcwW5sJFQ1 nUrHsU/jEuy5MgQvVcWv+8H6gQL2hbgbXNJtDDzHfv4sowwwDJla65j8wo+XT8KmPBB4 t+9HxMZPTsYaZlaTY3pKp1ZV3Puwsx2BcZXBGlcYcsAp72TqsTnwuuAHrOCaVLci6xY6 FV1Xqn13nTubK54cP9jWn99XCsWhy1izu++55+8oYDzYZRwfudSt8KlOcw7b3a2SER5n r0eQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=i9hAmskI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i6si1520115ejx.303.2020.11.17.05.50.44; Tue, 17 Nov 2020 05:51:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=i9hAmskI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732929AbgKQNhS (ORCPT + 99 others); Tue, 17 Nov 2020 08:37:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:47812 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732695AbgKQNgr (ORCPT ); Tue, 17 Nov 2020 08:36:47 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 199BD221FD; Tue, 17 Nov 2020 13:36:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605620206; bh=otJfjv/qwuqgeajwtg/hKL+gCgOGPN47nO+J57SRZbw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i9hAmskIkTQ9hOLMnYdb2Q3MWJPX65eFa1b1MJfz8blm3t3xxsIho32f0GUI00kvH vHP6F0VQz988mByrB443rrQamuAlnmiuXeRn8UJXajfm1EwL64njhaIch+sr0lTSSv J+Fcme6rNWF1VC9COhNv0ggvcp0OJKCz+yISbP+8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Aya Levin , Moshe Shemesh , Saeed Mahameed , Sasha Levin Subject: [PATCH 5.9 141/255] net/mlx5e: Fix VXLAN synchronization after function reload Date: Tue, 17 Nov 2020 14:04:41 +0100 Message-Id: <20201117122145.810379611@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201117122138.925150709@linuxfoundation.org> References: <20201117122138.925150709@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Aya Levin [ Upstream commit c5eb51adf06b2644fa28d4af886bfdcc53e288da ] During driver reload, perform firmware tear-down which results in firmware losing the configured VXLAN ports. These ports are still available in the driver's database. Fix this by cleaning up driver's VXLAN database in the nic unload flow, before firmware tear-down. With that, minimize mlx5_vxlan_destroy() to remove only what was added in mlx5_vxlan_create() and warn on leftover UDP ports. Fixes: 18a2b7f969c9 ("net/mlx5: convert to new udp_tunnel infrastructure") Signed-off-by: Aya Levin Reviewed-by: Moshe Shemesh Signed-off-by: Saeed Mahameed Signed-off-by: Sasha Levin --- .../net/ethernet/mellanox/mlx5/core/en_main.c | 1 + .../ethernet/mellanox/mlx5/core/lib/vxlan.c | 23 ++++++++++++++----- .../ethernet/mellanox/mlx5/core/lib/vxlan.h | 2 ++ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index 42ec28e298348..f399973a44eb0 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -5226,6 +5226,7 @@ static void mlx5e_nic_disable(struct mlx5e_priv *priv) mlx5e_disable_async_events(priv); mlx5_lag_remove(mdev); + mlx5_vxlan_reset_to_default(mdev->vxlan); } int mlx5e_update_nic_rx(struct mlx5e_priv *priv) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.c index 3315afe2f8dce..38084400ee8fa 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.c @@ -167,6 +167,17 @@ struct mlx5_vxlan *mlx5_vxlan_create(struct mlx5_core_dev *mdev) } void mlx5_vxlan_destroy(struct mlx5_vxlan *vxlan) +{ + if (!mlx5_vxlan_allowed(vxlan)) + return; + + mlx5_vxlan_del_port(vxlan, IANA_VXLAN_UDP_PORT); + WARN_ON(!hash_empty(vxlan->htable)); + + kfree(vxlan); +} + +void mlx5_vxlan_reset_to_default(struct mlx5_vxlan *vxlan) { struct mlx5_vxlan_port *vxlanp; struct hlist_node *tmp; @@ -175,12 +186,12 @@ void mlx5_vxlan_destroy(struct mlx5_vxlan *vxlan) if (!mlx5_vxlan_allowed(vxlan)) return; - /* Lockless since we are the only hash table consumers*/ hash_for_each_safe(vxlan->htable, bkt, tmp, vxlanp, hlist) { - hash_del(&vxlanp->hlist); - mlx5_vxlan_core_del_port_cmd(vxlan->mdev, vxlanp->udp_port); - kfree(vxlanp); + /* Don't delete default UDP port added by the HW. + * Remove only user configured ports + */ + if (vxlanp->udp_port == IANA_VXLAN_UDP_PORT) + continue; + mlx5_vxlan_del_port(vxlan, vxlanp->udp_port); } - - kfree(vxlan); } diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.h b/drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.h index ec766529f49b6..34ef662da35ed 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.h @@ -56,6 +56,7 @@ void mlx5_vxlan_destroy(struct mlx5_vxlan *vxlan); int mlx5_vxlan_add_port(struct mlx5_vxlan *vxlan, u16 port); int mlx5_vxlan_del_port(struct mlx5_vxlan *vxlan, u16 port); bool mlx5_vxlan_lookup_port(struct mlx5_vxlan *vxlan, u16 port); +void mlx5_vxlan_reset_to_default(struct mlx5_vxlan *vxlan); #else static inline struct mlx5_vxlan* mlx5_vxlan_create(struct mlx5_core_dev *mdev) { return ERR_PTR(-EOPNOTSUPP); } @@ -63,6 +64,7 @@ static inline void mlx5_vxlan_destroy(struct mlx5_vxlan *vxlan) { return; } static inline int mlx5_vxlan_add_port(struct mlx5_vxlan *vxlan, u16 port) { return -EOPNOTSUPP; } static inline int mlx5_vxlan_del_port(struct mlx5_vxlan *vxlan, u16 port) { return -EOPNOTSUPP; } static inline bool mlx5_vxlan_lookup_port(struct mlx5_vxlan *vxlan, u16 port) { return false; } +static inline void mlx5_vxlan_reset_to_default(struct mlx5_vxlan *vxlan) { return; } #endif #endif /* __MLX5_VXLAN_H__ */ -- 2.27.0