Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp332989pxb; Mon, 16 Aug 2021 06:31:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwE6k2HXUVIl52SfhAa5lMvKLNT9NO9kFG+fD86FxuFPlqRA58ubj6dvdz4wZt0gv6vzak/ X-Received: by 2002:adf:dd91:: with SMTP id x17mr18402908wrl.414.1629120708777; Mon, 16 Aug 2021 06:31:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629120708; cv=none; d=google.com; s=arc-20160816; b=YUKYlXiZQeXhhavRiYS/cqX/o7fmwy075xhB+L6hryRPq+4SJQ8Nf2sa0zlhEJTnJs 59AJINfqEQ4l77hedaWUBJnKvG0nZ5lh2nzVU71uQIcJ3Be731g2t3EKDbfdZ/q/Y/0g 01US9O4UkqS6JKt1abI3ad2R+rZusTMAuHkRladr+pdL/MDrIKT296U7hZ5YhGx0L1QS MNxMvoqZGhRuDDM2rLpuwFkXTiu7VzIg0VxcUWERCR5jNPC9IW9wm2JH7/qu2y+SHHCN 2cE3jq6NaPX743u2UAcl0kM8sk4Oim9l7tL61H0bK+G0KLSfCpgFyui0ntOUSLNUBgNY d4oA== 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=2ovLilmOdI3an6HEo8zf/FjhUqXQMi1BgNgrsI0x9K0=; b=jgJZp+EjMhTEGF+otPiGURLldH3T0tNrTnRfxpM32oFajHwp1bCpZ/4YCCAsaOxf4d ycefk3dN1MDnF4U2E/VV4Fa/Kya8m2FTNptow56pONXMD+cmb2lznGHlXyPX7VShEoca 189raQObY9KOrIsqn8/BcxdUSjdQDRtJhJvppswXh/BiRGgi3nxp4l5N+JL7YrOQvNcP nbpRevbbNDueAzqSi7HUG7gQlojAS20E3WgYc8BTbRv/LRjBvcPfWcIE6Fgp5xRRozdg iNLkGJiZI6MlxNVk1i9TJ6U1tKQScn9NFSB3LWTv3qlJrr4+h0MJilctxHvePRdqfzPK AewQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=J6ziek8p; 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=pass (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 qk13si7479695ejc.661.2021.08.16.06.31.25; Mon, 16 Aug 2021 06:31:48 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=J6ziek8p; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240817AbhHPN0g (ORCPT + 99 others); Mon, 16 Aug 2021 09:26:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:43048 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239888AbhHPNQd (ORCPT ); Mon, 16 Aug 2021 09:16:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CC950632E9; Mon, 16 Aug 2021 13:13:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1629119589; bh=1T/M60qVtl9gUtEk+WyO7Jn76PhYbF9Hn3mSPpZtimc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J6ziek8p+DeQfQ7IQSAacm6Jw7rzT4bX081LWBUICsl8MBaoCXvAPDQQEuoafe7nE IHHFA7htVjS5kHfz0K3hsG8aN9pPeWHWrQY4X6+thdRAh4gT/MdNBgJOYUZYaWqfOS A0eqm+E/nM2gtf8a4MXyDld3NI2gMOv3iRGSVLpI= 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.13 084/151] net/mlx5: Block switchdev mode while devlink traps are active Date: Mon, 16 Aug 2021 15:01:54 +0200 Message-Id: <20210816125446.841830343@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210816125444.082226187@linuxfoundation.org> References: <20210816125444.082226187@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 c85a6b8feb16c0cdbbc8d9f581c7861c4a9ac351 ] Since switchdev mode can't support devlink traps, verify there are no active devlink traps before moving eswitch to switchdev mode. If there are active traps, prevent the switchdev mode configuration. Fixes: eb3862a0525d ("net/mlx5e: Enable traps according to link state") Signed-off-by: Aya Levin Reviewed-by: Moshe Shemesh Signed-off-by: Saeed Mahameed Signed-off-by: Sasha Levin --- .../ethernet/mellanox/mlx5/core/eswitch_offloads.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c index b66e12753f37..d0e4daa55a4a 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c @@ -48,6 +48,7 @@ #include "lib/fs_chains.h" #include "en_tc.h" #include "en/mapping.h" +#include "devlink.h" #define mlx5_esw_for_each_rep(esw, i, rep) \ xa_for_each(&((esw)->offloads.vport_reps), i, rep) @@ -2984,12 +2985,19 @@ int mlx5_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode, if (cur_mlx5_mode == mlx5_mode) goto unlock; - if (mode == DEVLINK_ESWITCH_MODE_SWITCHDEV) + if (mode == DEVLINK_ESWITCH_MODE_SWITCHDEV) { + if (mlx5_devlink_trap_get_num_active(esw->dev)) { + NL_SET_ERR_MSG_MOD(extack, + "Can't change mode while devlink traps are active"); + err = -EOPNOTSUPP; + goto unlock; + } err = esw_offloads_start(esw, extack); - else if (mode == DEVLINK_ESWITCH_MODE_LEGACY) + } else if (mode == DEVLINK_ESWITCH_MODE_LEGACY) { err = esw_offloads_stop(esw, extack); - else + } else { err = -EINVAL; + } unlock: mlx5_esw_unlock(esw); -- 2.30.2