Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp1559120iol; Fri, 10 Jun 2022 09:52:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+NJE82cxdABI6huA3ub306p7yIVzVAfI5ssaYxFFVyePWKCI4CCj9s0G11Ge/CEEvCZ3j X-Received: by 2002:a62:1687:0:b0:50d:3364:46d4 with SMTP id 129-20020a621687000000b0050d336446d4mr46790375pfw.74.1654879945897; Fri, 10 Jun 2022 09:52:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654879945; cv=none; d=google.com; s=arc-20160816; b=nzb33h09wOB6C3Phax16Gy8saMq1mKXEY7iFtr4BPaAgpkMIyBgusL4c2qlqptkEM1 28/VKBZVZy5qNcsAAzVH4wycYElakmylrW/9TvCcC66OGHvNsXrQMrkgAXMYIaNb6Oje MbuJujrfTJxi3CP8QQUL2Vemx+8EgAe6W9IYmyfPqcHhflcRuNvTjldoYN8BJ7W7/NDg erlEVKjheKy5CB5zOMldb61ZljQNw06kP3OAJ4reofaJKXynixxTLF4CgIZaKNtaA+Yr 1OTUh/mQvwD3zu8nGYSIvt1TZuk2TRqe+3kwjwLLetVx8BxDrlX0PPkjsxC+ycpsP/q9 odLg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=FWbwZtxelHgJJWEV2aHLmDtMOwsLmWT+YaJ0hUui0m8=; b=mIQ8EiPl6xnenapvNpNHhp6NZhDq0/PM5Tp6ElNHaOTtLyqn5J74le9Dupems4TjgQ ySdqZhXbkA/0rGlKc3hhHofklxuw0IBUmgitYn6FmFBv+nDoe+ZjeiSFvBNj3vpKhGv0 ewxrwxYjZmbZn8Xje0KMku9J5i5kRhDn2SMafWgkUZxJeo6+40ehF0UkPvXn3I8D2Xfk F8rUNShVaro3hkXU/hskEnudZzVrbz9M6upehywzfMmPEl5ShPTAhn1zgHaUcnh5/2Mo SkaMpFwFvYhUudMb44+nqpw+cCcf7TXD8gaMAF03op9Frt0JUvYmqtR8Gt+mcjTF27KJ VxEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=LhhTH24i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u77-20020a627950000000b0051873a6f9ffsi33525980pfc.265.2022.06.10.09.52.13; Fri, 10 Jun 2022 09:52:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=LhhTH24i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349849AbiFJQsW (ORCPT + 99 others); Fri, 10 Jun 2022 12:48:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349815AbiFJQsG (ORCPT ); Fri, 10 Jun 2022 12:48:06 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE462B2EB6; Fri, 10 Jun 2022 09:47:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654879674; x=1686415674; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dTbJGn1wT4KOCMCBcHh3vCtqTv4ul5foDXW+RuzFICU=; b=LhhTH24iqh+l/4hFBcayLgBPEEqtNq/KcYS23TFGO6OjTY5ApSX9MEFe y4pxEkynT6ZRNcbj1OmVQtGfBW51UOKh2uYJik5tizVhhnO3fLYqLdY4D e83sPvlPZkTEkAZQwx2cW3AGtHsWYOgfPKs/lGD3zaxQfeksmbQpWpojY gfC3+w534za4VrvAt2v5d3aVzD4qgp3xK7ovuu9IGaok9uan3ekVni+La +kegdEeAMUDv478cb91aH+WlfzWuA5mZPhj+ATnv0I6QVXMu/jRgoHdjk Aqg5TbrKr1Qh4hRvL9ZwnlnlyRN2mDa++4V1XKyd0jgwOmDDPam1b1wKT A==; X-IronPort-AV: E=McAfee;i="6400,9594,10374"; a="275209640" X-IronPort-AV: E=Sophos;i="5.91,290,1647327600"; d="scan'208";a="275209640" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2022 09:47:54 -0700 X-IronPort-AV: E=Sophos;i="5.91,290,1647327600"; d="scan'208";a="638211067" Received: from unknown (HELO jiaqingz-server.sh.intel.com) ([10.239.48.171]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2022 09:47:53 -0700 From: Jiaqing Zhao To: Samuel Mendoza-Jonas , "David S . Miller" , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jiaqing Zhao Subject: [PATCH 6/6] net/ncsi: Support VLAN mode configuration Date: Sat, 11 Jun 2022 00:45:55 +0800 Message-Id: <20220610164555.2322930-7-jiaqing.zhao@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220610164555.2322930-1-jiaqing.zhao@linux.intel.com> References: <20220610164555.2322930-1-jiaqing.zhao@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org NCSI specification defines 4 VLAN modes, currently kernel NCSI driver only supports the "VLAN + non-VLAN" mode (Mode #2), and there is no way to detect which modes are supported by the device. This patch adds support for configuring VLAN mode via the "ncsi,vlan-mode" devicetree node. Signed-off-by: Jiaqing Zhao --- net/ncsi/internal.h | 1 + net/ncsi/ncsi-manage.c | 41 ++++++++++++++++++++++++++++++++++------- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/net/ncsi/internal.h b/net/ncsi/internal.h index 7f384f841019..b868e07f7ffd 100644 --- a/net/ncsi/internal.h +++ b/net/ncsi/internal.h @@ -334,6 +334,7 @@ struct ncsi_dev_priv { struct work_struct work; /* For channel management */ struct packet_type ptype; /* NCSI packet Rx handler */ struct list_head node; /* Form NCSI device list */ + u32 vlan_mode; /* VLAN mode */ #define NCSI_MAX_VLAN_VIDS 15 struct list_head vlan_vids; /* List of active VLAN IDs */ diff --git a/net/ncsi/ncsi-manage.c b/net/ncsi/ncsi-manage.c index 3fb95f29e3e2..a398b0eb72b2 100644 --- a/net/ncsi/ncsi-manage.c +++ b/net/ncsi/ncsi-manage.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -1042,7 +1043,11 @@ static void ncsi_configure_channel(struct ncsi_dev_priv *ndp) nd->state = ncsi_dev_state_config_oem_gma; break; case ncsi_dev_state_config_oem_gma: - nd->state = ncsi_dev_state_config_clear_vids; + /* Only set up hardware VLAN filters in filtered mode */ + if (ndp->vlan_mode == NCSI_VLAN_MODE_FILTERED) + nd->state = ncsi_dev_state_config_clear_vids; + else + nd->state = ncsi_dev_state_config_ev; ret = -1; #if IS_ENABLED(CONFIG_NCSI_OEM_CMD_GET_MAC) @@ -1094,11 +1099,15 @@ static void ncsi_configure_channel(struct ncsi_dev_priv *ndp) nd->state = ncsi_dev_state_config_svf; /* Enable/Disable the VLAN filter */ } else if (nd->state == ncsi_dev_state_config_ev) { - if (list_empty(&ndp->vlan_vids)) { - nca.type = NCSI_PKT_CMD_DV; - } else { + if (ndp->vlan_mode == NCSI_VLAN_MODE_FILTERED && + !list_empty(&ndp->vlan_vids)) { nca.type = NCSI_PKT_CMD_EV; nca.bytes[3] = NCSI_CAP_VLAN_FILTERED; + } else if (ndp->vlan_mode == NCSI_VLAN_MODE_ANY) { + nca.type = NCSI_PKT_CMD_EV; + nca.bytes[3] = NCSI_CAP_VLAN_ANY; + } else { + nca.type = NCSI_PKT_CMD_DV; } nd->state = ncsi_dev_state_config_sma; } else if (nd->state == ncsi_dev_state_config_sma) { @@ -1800,15 +1809,33 @@ struct ncsi_dev *ncsi_register_dev(struct net_device *dev, ndp->ptype.dev = dev; dev_add_pack(&ndp->ptype); + /* Set default VLAN mode (filtered) */ + ndp->vlan_mode = NCSI_VLAN_MODE_FILTERED; + pdev = to_platform_device(dev->dev.parent); if (pdev) { np = pdev->dev.of_node; - if (np && of_get_property(np, "mlx,multi-host", NULL)) - ndp->mlx_multi_host = true; + if (np) { + u32 vlan_mode; + + if (!of_property_read_u32(np, "ncsi,vlan-mode", &vlan_mode)) { + if (vlan_mode > NCSI_VLAN_MODE_ANY || + vlan_mode == NCSI_VLAN_MODE_ONLY) + dev_warn(&pdev->dev, "NCSI: Unsupported VLAN mode %u", + vlan_mode); + else + ndp->vlan_mode = vlan_mode; + dev_info(&pdev->dev, "NCSI: Configured VLAN mode %u", + ndp->vlan_mode); + } + if (of_get_property(np, "mlx,multi-host", NULL)) + ndp->mlx_multi_host = true; + } } /* Enable hardware VLAN filtering */ - if (dev->netdev_ops->ndo_vlan_rx_add_vid == ncsi_vlan_rx_add_vid && + if (ndp->vlan_mode == NCSI_VLAN_MODE_FILTERED && + dev->netdev_ops->ndo_vlan_rx_add_vid == ncsi_vlan_rx_add_vid && dev->netdev_ops->ndo_vlan_rx_kill_vid == ncsi_vlan_rx_kill_vid) dev->hw_features |= NETIF_F_HW_VLAN_CTAG_FILTER; -- 2.34.1