Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp1428398rwn; Thu, 8 Sep 2022 20:26:27 -0700 (PDT) X-Google-Smtp-Source: AA6agR4QZeOSzBpaRKDwFOZRazQXNvV9d6/6u7kctFjL/t5ZiYlqS1dnnY/CmXIbOoYcQJhAo4BU X-Received: by 2002:ac2:4bc1:0:b0:48b:2ac7:bd67 with SMTP id o1-20020ac24bc1000000b0048b2ac7bd67mr3630763lfq.499.1662693987340; Thu, 08 Sep 2022 20:26:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662693987; cv=none; d=google.com; s=arc-20160816; b=YEUrzQseBF7BIP6S0xU+bc8GC45E5oi+Mx+8XKWmG6m8t/A52aWyvhWq8Aku5kTXSm 89fDQu9DsBKvmuIqmtKuMUS90f6tnwKwLRkihIgct6w2zwK10Ys93/DOa7VohxAiKED0 tazsZWh73WgYcpENuENB2zak7kqV0zS1lVCXHW0qYjtBvQYPN6piUPh84rtx6Bu4kIrN FxIU/VlCKgCCGfNjEuG3dJozL6oeiByKtpQRRxC6Kg6Ld5dImf7WTcaOkpcopBti+FmY NAX7ba3af9usnKhoYwMmr3ICkpmOPiZ0cIsx48SNmAkXsgh/RiLGSmJNCGX8VKtufX6y XcMA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=yKSCHDpCRLflmyfb+7MVnPRh8f++VCOTUoHvWn32B0U=; b=kZpJ88DbsP9YrsQvxhVjv7UTLz4nLr3ZejehF387Q203z+1a7cSU/cszV9Eb0oHU+3 XtF8MHrvbsf4e8YUEdwB9msP827H9/7eDjDCnTwizwqoAAEYQO4/5cbCMBsJkQ3sbpBo 1U0uQSuGXV27CbGzUuVEucjTfLX63Z2kmP9XTcHJ24bCJ/8Sa4/wOpoy+GMMqpbMJbZL orLFRa02o//fQ5H4MWeY2JXY0AbdcSgn68450em2sPOzf0YQeDNGNnfKFZbKbZ2p0DvY 9c8W+5YEbJz2WIdymSNL/oEFObwE/X6X+dwUOz/ILaf4/GUtCmRxKC5HjgireUYSPrzG f+7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UWOP7Kt5; 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 bq19-20020a056512151300b00492d8e89782si280968lfb.506.2022.09.08.20.25.58; Thu, 08 Sep 2022 20:26:27 -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=UWOP7Kt5; 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 S230033AbiIIC6C (ORCPT + 99 others); Thu, 8 Sep 2022 22:58:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229920AbiIIC5y (ORCPT ); Thu, 8 Sep 2022 22:57:54 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 055C2E6BA4; Thu, 8 Sep 2022 19:57:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662692273; x=1694228273; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=I9n+WM9Wx9T7J9l3ZjPpBz81L1+PfNaApAGPvBNmItY=; b=UWOP7Kt5Wlxx1r3LELdNb+G468rA3L07eCBv6gcmiSGjIxuWmNeDj5yp aVhEPuN7nVxo5A8jxb6rIVjcbsWdc/4tIB4nqw3EmR9lS6GIiPlzabbSh edFKotFAhg19nDX+wgacqW7LsRByVXzSs4Wa6TFIg25X9gvIUZ0pWuuL4 mRbIme9jp2kqlFRvKjH/AM3ujXmmhfe67iP0EXqyvq109lWPRGjOQ/ET8 Kms8M42l92MOVG9tKlLeBoiPiw9mCUQOjwBSl0vimOJatqqUndRf+J69U viQqr8RUjRs1RAFnYiuVyvN4lvt+RYBd7RGDP8SHgbZv0iKgRQiGE4bGm g==; X-IronPort-AV: E=McAfee;i="6500,9779,10464"; a="323584087" X-IronPort-AV: E=Sophos;i="5.93,300,1654585200"; d="scan'208";a="323584087" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Sep 2022 19:57:52 -0700 X-IronPort-AV: E=Sophos;i="5.93,300,1654585200"; d="scan'208";a="645360094" Received: from unknown (HELO jiaqingz-bmcdev-container.sh.intel.com) ([10.239.138.232]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Sep 2022 19:57:50 -0700 From: Jiaqing Zhao To: Samuel Mendoza-Jonas , "David S. Miller" , Eric Dumazet , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org, Jiaqing Zhao Subject: [PATCH] net/ncsi: Add Intel OS2BMC OEM command Date: Fri, 9 Sep 2022 10:57:17 +0800 Message-Id: <20220909025716.2610386-1-jiaqing.zhao@linux.intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE 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 The Intel OS2BMC OEM NCSI command is used for controlling whether network traffic between host and sideband is allowed or not. By default such traffic is disallowed, meaning that if the device using NCS (usually BMC) does not have extra active connection, it cannot reach the host. This patch enables the host-sideband traffic by sending the Enable OS2BMC flow OEM NCSI command, which is controlled by kernel option CONFIG_NCSI_OEM_CMD_INTEL_OS2BMC. Signed-off-by: Jiaqing Zhao --- net/ncsi/Kconfig | 6 ++++++ net/ncsi/internal.h | 4 ++++ net/ncsi/ncsi-manage.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) diff --git a/net/ncsi/Kconfig b/net/ncsi/Kconfig index ea1dd32b6b1f..faeddbd48fe9 100644 --- a/net/ncsi/Kconfig +++ b/net/ncsi/Kconfig @@ -23,3 +23,9 @@ config NCSI_OEM_CMD_KEEP_PHY help This allows to keep PHY link up and prevents any channel resets during the host load. +config NCSI_OEM_CMD_INTEL_OS2BMC + bool "Allow traffic between host and sideband (Intel-specific)" + depends on NET_NCSI + help + This allows network traffic between host and sideband, specific to + Intel network controllers. diff --git a/net/ncsi/internal.h b/net/ncsi/internal.h index 03757e76bb6b..d730f435d136 100644 --- a/net/ncsi/internal.h +++ b/net/ncsi/internal.h @@ -82,6 +82,8 @@ enum { /* Intel specific OEM command */ #define NCSI_OEM_INTEL_CMD_GMA 0x06 /* CMD ID for Get MAC */ #define NCSI_OEM_INTEL_CMD_KEEP_PHY 0x20 /* CMD ID for Keep PHY up */ +#define NCSI_OEM_INTEL_CMD_OS2BMC 0x40 /* CMD ID for Enable OS2BMC traffic */ +#define NCSI_OEM_INTEL_CMD_OS2BMC_PARAM 0x03 /* Parameter for Enable OS2BMC */ /* Broadcom specific OEM Command */ #define NCSI_OEM_BCM_CMD_GMA 0x01 /* CMD ID for Get MAC */ /* Mellanox specific OEM Command */ @@ -92,6 +94,7 @@ enum { /* OEM Command payload lengths*/ #define NCSI_OEM_INTEL_CMD_GMA_LEN 5 #define NCSI_OEM_INTEL_CMD_KEEP_PHY_LEN 7 +#define NCSI_OEM_INTEL_CMD_OS2BMC_LEN 6 #define NCSI_OEM_BCM_CMD_GMA_LEN 12 #define NCSI_OEM_MLX_CMD_GMA_LEN 8 #define NCSI_OEM_MLX_CMD_SMAF_LEN 60 @@ -285,6 +288,7 @@ enum { ncsi_dev_state_probe_dp, ncsi_dev_state_config_sp = 0x0301, ncsi_dev_state_config_cis, + ncsi_dev_state_config_intel_os2bmc, ncsi_dev_state_config_oem_gma, ncsi_dev_state_config_clear_vids, ncsi_dev_state_config_svf, diff --git a/net/ncsi/ncsi-manage.c b/net/ncsi/ncsi-manage.c index 80713febfac6..d8b9fcedf7ec 100644 --- a/net/ncsi/ncsi-manage.c +++ b/net/ncsi/ncsi-manage.c @@ -718,6 +718,34 @@ static int ncsi_oem_keep_phy_intel(struct ncsi_cmd_arg *nca) #endif +#if IS_ENABLED(CONFIG_NCSI_OEM_CMD_INTEL_OS2BMC) + +static int ncsi_oem_enable_os2bmc_intel(struct ncsi_cmd_arg *nca) +{ + unsigned char data[NCSI_OEM_INTEL_CMD_OS2BMC_LEN]; + int ret = 0; + + nca->payload = NCSI_OEM_INTEL_CMD_OS2BMC_LEN; + + memset(data, 0, NCSI_OEM_INTEL_CMD_OS2BMC_LEN); + *(unsigned int *)data = ntohl((__force __be32)NCSI_OEM_MFR_INTEL_ID); + data[4] = NCSI_OEM_INTEL_CMD_OS2BMC; + + /* Enable both Network-to-BMC and Host-to-BMC traffic */ + data[5] = NCSI_OEM_INTEL_CMD_OS2BMC_PARAM; + + nca->data = data; + + ret = ncsi_xmit_cmd(nca); + if (ret) + netdev_err(nca->ndp->ndev.dev, + "NCSI: Failed to transmit cmd 0x%x during configure\n", + nca->type); + return ret; +} + +#endif + #if IS_ENABLED(CONFIG_NCSI_OEM_CMD_GET_MAC) /* NCSI OEM Command APIs */ @@ -1039,6 +1067,20 @@ static void ncsi_configure_channel(struct ncsi_dev_priv *ndp) goto error; } +#if IS_ENABLED(CONFIG_NCSI_OEM_CMD_INTEL_OS2BMC) + nd->state = ncsi_dev_state_config_intel_os2bmc; + break; + case ncsi_dev_state_config_intel_os2bmc: + nca.type = NCSI_PKT_CMD_OEM; + nca.package = np->id; + nca.channel = nc->id; + ndp->pending_req_num = 1; + ret = ncsi_oem_enable_os2bmc_intel(&nca); + + if (ret) + goto error; +#endif /* CONFIG_NCSI_OEM_CMD_INTEL_OS2BMC */ + nd->state = ncsi_dev_state_config_oem_gma; break; case ncsi_dev_state_config_oem_gma: -- 2.34.1