From patchwork Fri Jun 10 16:48:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaqing Zhao X-Patchwork-Id: 580790 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E201ACCA47C for ; Fri, 10 Jun 2022 16:50:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349872AbiFJQuV (ORCPT ); Fri, 10 Jun 2022 12:50:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349729AbiFJQt6 (ORCPT ); Fri, 10 Jun 2022 12:49:58 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70A5422531; Fri, 10 Jun 2022 09:49:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654879797; x=1686415797; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SoQbox9LXcyX3/Opr6a2M/n8V2iom3/0Vp+el7IRj5A=; b=mz0VGk5CtnvflLxwpm4JwaqGC2jTlzHpq4zwfToAtD/uMBul2fz6Smq2 8NIvZcxfa7JmYDsSiUyQjwYZ/xHRIKUFwTLxh6ZhinA+81F2VyEN/4ttF DE9O3yfcnI/61LF1FR2noMsF5VRSJTPaoOYYtYzt3apoS06jtVTElvmaG QuObjRXPNAqub3fUpxIej0vrxky0cMjMsfZKJjbBqLahpAm995nPog5R5 OUkX7jQY2VhFkvkepSNIhkaOs3rs9UeeU95LuryXxTSyU6hWkiG+nnP25 4kKyMoUnq6e8qoMGWMun5Ec9tyOeLOxZtktftOMTUmcs7eU49Gz0OFWGT A==; X-IronPort-AV: E=McAfee;i="6400,9594,10374"; a="339432527" X-IronPort-AV: E=Sophos;i="5.91,290,1647327600"; d="scan'208";a="339432527" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2022 09:49:52 -0700 X-IronPort-AV: E=Sophos;i="5.91,290,1647327600"; d="scan'208";a="760587693" Received: from unknown (HELO jiaqingz-server.sh.intel.com) ([10.239.48.171]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2022 09:49:50 -0700 From: Jiaqing Zhao To: Samuel Mendoza-Jonas , "David S . Miller" , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org Cc: Jiaqing Zhao Subject: [PATCH 1/6] net/ncsi: Fix value of NCSI_CAP_VLAN_ANY Date: Sat, 11 Jun 2022 00:48:03 +0800 Message-Id: <20220610164808.2323340-2-jiaqing.zhao@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220610164808.2323340-1-jiaqing.zhao@linux.intel.com> References: <20220610164808.2323340-1-jiaqing.zhao@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org According to the NCSI specification (DSP0222) [1], the value of allow Any VLAN + non-VLAN mode in Enable VLAN command should be 0x03. [1] https://www.dmtf.org/sites/default/files/standards/documents/DSP0222_1.0.0.pdf Signed-off-by: Jiaqing Zhao --- net/ncsi/internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ncsi/internal.h b/net/ncsi/internal.h index 03757e76bb6b..bc4a00e41695 100644 --- a/net/ncsi/internal.h +++ b/net/ncsi/internal.h @@ -47,7 +47,7 @@ enum { NCSI_CAP_AEN_MASK = 0x07, NCSI_CAP_VLAN_ONLY = 0x01, /* Filter VLAN packet only */ NCSI_CAP_VLAN_NO = 0x02, /* Filter VLAN and non-VLAN */ - NCSI_CAP_VLAN_ANY = 0x04, /* Filter Any-and-non-VLAN */ + NCSI_CAP_VLAN_ANY = 0x03, /* Filter Any-and-non-VLAN */ NCSI_CAP_VLAN_MASK = 0x07 }; From patchwork Fri Jun 10 16:48:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaqing Zhao X-Patchwork-Id: 580791 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA45ECCA47B for ; Fri, 10 Jun 2022 16:50:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349886AbiFJQuW (ORCPT ); Fri, 10 Jun 2022 12:50:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240589AbiFJQt7 (ORCPT ); Fri, 10 Jun 2022 12:49:59 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 545C1E0CC; Fri, 10 Jun 2022 09:49:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654879798; x=1686415798; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=n2DHPKG6LELctv9GPHh5MdlgXeZF+xfpjUKtxgbPNOI=; b=dy66HnlBQDSil+5LMzDog9zDROyyL5NfHOR3fbVJfeP5wlmvuD/dJX+C 8DrPNZlQ8+0NsLgDu5ZhVTM+RU9HgtHboxZnApgAy6+fphbjvoSd8Ew+7 sR4mHh7uZGbbqs2iKJAZh7cbNKiG0KHqjVdlIe+vuW2VaxXjWQOn1f63Z A1u5aBBCWpdavwuZX7X4ZsktetYeqKEsyXJR/cSItV03NZyCidlVWBM4s YYZG4MrKY55FpW/HXmsOf9YlUUdc/b/+dv0JNxpOv1n2nZkrZXkE5BWBd jD+3GThMZ3NHsyxUKWD4kDeDev2ZKETNUPJqsttPhNWIaurAlqpGlVISk g==; X-IronPort-AV: E=McAfee;i="6400,9594,10374"; a="339432537" X-IronPort-AV: E=Sophos;i="5.91,290,1647327600"; d="scan'208";a="339432537" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2022 09:49:54 -0700 X-IronPort-AV: E=Sophos;i="5.91,290,1647327600"; d="scan'208";a="760587696" Received: from unknown (HELO jiaqingz-server.sh.intel.com) ([10.239.48.171]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2022 09:49:52 -0700 From: Jiaqing Zhao To: Samuel Mendoza-Jonas , "David S . Miller" , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org Cc: Jiaqing Zhao Subject: [PATCH 2/6] net/ncsi: Rename NCSI_CAP_VLAN_NO to NCSI_CAP_VLAN_FILTERED Date: Sat, 11 Jun 2022 00:48:04 +0800 Message-Id: <20220610164808.2323340-3-jiaqing.zhao@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220610164808.2323340-1-jiaqing.zhao@linux.intel.com> References: <20220610164808.2323340-1-jiaqing.zhao@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The NCSI_CAP_VLAN_NO actually stands for the "VLAN + non-VLAN" mode defined in NCSI spec, which accepts both VLAN-tagged packets that match the enabled VLAN filter settings and non-VLAN-tagged packets. It would be more clear to rename it to NCSI_CAP_VLAN_FILTERED. Signed-off-by: Jiaqing Zhao --- net/ncsi/internal.h | 2 +- net/ncsi/ncsi-manage.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/net/ncsi/internal.h b/net/ncsi/internal.h index bc4a00e41695..7f384f841019 100644 --- a/net/ncsi/internal.h +++ b/net/ncsi/internal.h @@ -46,7 +46,7 @@ enum { NCSI_CAP_AEN_HDS = 0x04, /* HNC driver status */ NCSI_CAP_AEN_MASK = 0x07, NCSI_CAP_VLAN_ONLY = 0x01, /* Filter VLAN packet only */ - NCSI_CAP_VLAN_NO = 0x02, /* Filter VLAN and non-VLAN */ + NCSI_CAP_VLAN_FILTERED = 0x02, /* Filter VLAN and non-VLAN */ NCSI_CAP_VLAN_ANY = 0x03, /* Filter Any-and-non-VLAN */ NCSI_CAP_VLAN_MASK = 0x07 }; diff --git a/net/ncsi/ncsi-manage.c b/net/ncsi/ncsi-manage.c index 78814417d753..a8f7a2ff52a0 100644 --- a/net/ncsi/ncsi-manage.c +++ b/net/ncsi/ncsi-manage.c @@ -1098,7 +1098,7 @@ static void ncsi_configure_channel(struct ncsi_dev_priv *ndp) nca.type = NCSI_PKT_CMD_DV; } else { nca.type = NCSI_PKT_CMD_EV; - nca.bytes[3] = NCSI_CAP_VLAN_NO; + nca.bytes[3] = NCSI_CAP_VLAN_FILTERED; } nd->state = ncsi_dev_state_config_sma; } else if (nd->state == ncsi_dev_state_config_sma) { From patchwork Fri Jun 10 16:48:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaqing Zhao X-Patchwork-Id: 580789 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D89BCCA47B for ; Fri, 10 Jun 2022 16:50:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349904AbiFJQuZ (ORCPT ); Fri, 10 Jun 2022 12:50:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245061AbiFJQuI (ORCPT ); Fri, 10 Jun 2022 12:50:08 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47DF512ACB; Fri, 10 Jun 2022 09:50:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654879807; x=1686415807; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dTbJGn1wT4KOCMCBcHh3vCtqTv4ul5foDXW+RuzFICU=; b=NdXo4Jyz8BdWeQcfi9AOURVO89nkXL9jKJcsoUmgK8Dw7hVhu2oXSsfP VLRYjq3ctmhiyeWO4p+tquEdp8hx2QV8FUtchG63ASMGA1Y2EPEPazcG4 kXuyHHahd35yH+gupa3wz+Q4FLJbSoQ9PFOfykhWeufCg0dhgg4B6mNGI cA9MRL8DVsmXrjF0uuSJYvaIz5X18ghQmFR6/BoRe3dInvXVUgtx9UHsw p2u1pXSbH+B7yq2EovrSnerieYudsAevGyiLGQ5Y6HhvanMBGcIBVbRpP ANH98as4S6XYBPYdye8ogRkSAMQb5L2sKtK5hmacEUkV9wQ+O6sDbcNeX g==; X-IronPort-AV: E=McAfee;i="6400,9594,10374"; a="339432581" X-IronPort-AV: E=Sophos;i="5.91,290,1647327600"; d="scan'208";a="339432581" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2022 09:50:03 -0700 X-IronPort-AV: E=Sophos;i="5.91,290,1647327600"; d="scan'208";a="760587756" Received: from unknown (HELO jiaqingz-server.sh.intel.com) ([10.239.48.171]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2022 09:50:01 -0700 From: Jiaqing Zhao To: Samuel Mendoza-Jonas , "David S . Miller" , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org Cc: Jiaqing Zhao Subject: [PATCH 6/6] net/ncsi: Support VLAN mode configuration Date: Sat, 11 Jun 2022 00:48:08 +0800 Message-Id: <20220610164808.2323340-7-jiaqing.zhao@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220610164808.2323340-1-jiaqing.zhao@linux.intel.com> References: <20220610164808.2323340-1-jiaqing.zhao@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@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;