From nobody Sun Nov 16 02:30:08 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1744848257; cv=none; d=zohomail.com; s=zohoarc; b=Imlm+uAD+/XByQrR7OxhxTodibOPCFTNBGfKWh3/e1ec/yzuxCfXgVUhsyCA5DkU0BysmYMJ8xFtnA3kjCykf4BhXYTktDZAVGY6yGSzePOHsG/LKrkzIiRFdtYCTMoBe6JpXbcQ1kvBiO17pl+8ZvcE1jf3qiHVkywVS9fjUfc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1744848257; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=/AW4tnkOIpzn+hkaLSPNo53y2Z1zRYt/SZox39VKYwQ=; b=TpZG+DCksS3a1cO9n7hLJTO1euc6DKtlu69yhQwuzJXE5m8hHkku1aazHa9TjGYrFJXEEWsa84ywuFY16JKj2uxK+xC3EQ+deKa5XG5414gk9FLmKtSu92uO6fagHyo/H2L/L38KmKNsN+rd42I+x54rFZaN1u921MKT0bUeJs0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1744848256991871.9134639872897; Wed, 16 Apr 2025 17:04:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u5CiM-00043c-KG; Wed, 16 Apr 2025 20:02:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u5CiK-00042v-Bo for qemu-devel@nongnu.org; Wed, 16 Apr 2025 20:02:44 -0400 Received: from mail-oo1-xc2c.google.com ([2607:f8b0:4864:20::c2c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1u5CiI-0006QC-Gk for qemu-devel@nongnu.org; Wed, 16 Apr 2025 20:02:44 -0400 Received: by mail-oo1-xc2c.google.com with SMTP id 006d021491bc7-603fd257386so36718eaf.1 for ; Wed, 16 Apr 2025 17:02:42 -0700 (PDT) Received: from localhost ([2001:470:b8f6:1b:8795:e9fb:beca:ef25]) by smtp.gmail.com with UTF8SMTPSA id 006d021491bc7-604a5b94c27sm567505eaf.13.2025.04.16.17.02.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 16 Apr 2025 17:02:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=minyard-net.20230601.gappssmtp.com; s=20230601; t=1744848159; x=1745452959; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/AW4tnkOIpzn+hkaLSPNo53y2Z1zRYt/SZox39VKYwQ=; b=dFYhTQShKnK6/K52R5SA/rna2kf7nTu4uFvWFgcf1Cya2ruN9beCfrEGzeeI/8DciV DWypoptbhzO1oazB/mQZLMu+gvXRuogxdOUzp3mAk3LCqtH6F+8yeiD/cLp9R0CuToTl gIh61wsI8r2Ga6G0lVnfrP4OSxCzsYthGvvmj20EFA4AC/r3iGGwj3V29AD8yAjK/2R8 Fs74586aNCAgbMv3/EhZrO7gjNY3oIc93a/6saC5LIWXL2K1X12IlDZ9IIh4qMG2ZgZq c5zb/eQ0qHHMLBAF/MMzeMx0XTXNA26TYSZdqQld7sSzo7JOMeSs6EhdLR6pptOyLdje gSew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744848159; x=1745452959; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/AW4tnkOIpzn+hkaLSPNo53y2Z1zRYt/SZox39VKYwQ=; b=xENZF7xDnG0EU4IWBw816c0PWW4Bou/7oWCbTxGo0AAz+JY6ykngg8cZuffOacmQu1 NOZu12LzDpeYVscAb251RKIc64KY+xUv9AzuVeAK4tM7TYAXP4dTyMp8at6bGrHM1Er8 0EHMUBkXPLni7I609XIm8SgSJjnaLKrwfqmbUcWKzTPsKzs6RjKU+zYFN9kJ4/NAQT+y jKm3x9d4AJhD2Xy4Q9k6ALZ6uLnf75k5ymTxyQTqRnSBKNkfg372xH8vvM6Zl3paiGVC Ik+1W9YFM+zzg7gs4IBkDsRsnUqu+JNVKAvYPWgYjeviqc/5hXbIs8JV7OWF9LeGuMOh GAQg== X-Gm-Message-State: AOJu0Ywy8JwBAEEfpmoUY9Wi6rap7iPoRhnG1n3TVFQbQeAatwXmkHeV xWUkjOV48sGZtYdnSu+wmu3xJIR3kAayYnKqpGVo4NGz/uzbLE1jSVR+XQFRN/cTXZhSOlQZVrv m X-Gm-Gg: ASbGncuJ44bfizIZos9KT7rThLVyY7wkqygCA+DXd41jd4Mn9lkGKEddntfBM8WY/x+ R/imYe0zHZp+7Shiwx8vUkl53iRl+Gy7NZ1geiLdnJJOqd1HGkLKK8hKYtvhe0LdSGNps229z5a dfKHME/OPmTAhVcul9fLitUx1aqwig8Zkte9axABTcjl7EaVR8HS/M0CUCM8LeVxNOQj18GdD5I WB7RlO8GuF5jESgn7C1pPeqMDAuE8Qw+GGOF8q5yYJ/KoHy1LeUbIhDS/KHGvRexrJ6HlkiyUff bvsmbRVxfcHmYfKRKpfwpqZPjKPthASPSfs= X-Google-Smtp-Source: AGHT+IGf3fmN6Dftp8lWka7GnVEDjDvMNgDglg2hGJsI7Z241e3OMiamt8xvqgEcHw3195BZlNuLZA== X-Received: by 2002:a05:6820:509:b0:604:710b:b921 with SMTP id 006d021491bc7-604a8fcacbdmr1941982eaf.0.1744848158441; Wed, 16 Apr 2025 17:02:38 -0700 (PDT) From: Corey Minyard To: qemu-devel@nongnu.org Cc: Nicholas Piggin , Corey Minyard Subject: [PULL 4/6] ipmi/bmc-sim: Add 'Get Channel Info' command Date: Wed, 16 Apr 2025 18:59:08 -0500 Message-ID: <20250417000224.3830705-5-corey@minyard.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250417000224.3830705-1-corey@minyard.net> References: <20250417000224.3830705-1-corey@minyard.net> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::c2c; envelope-from=corey@minyard.net; helo=mail-oo1-xc2c.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @minyard-net.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1744848257844019000 Content-Type: text/plain; charset="utf-8" From: Nicholas Piggin Linux issues this command when booting a powernv machine. Signed-off-by: Nicholas Piggin Message-ID: <20250401140153.685523-4-npiggin@gmail.com> Signed-off-by: Corey Minyard --- hw/ipmi/ipmi_bmc_sim.c | 68 ++++++++++++++++++++++++++++++++++++++++-- hw/ipmi/ipmi_bt.c | 2 ++ hw/ipmi/ipmi_kcs.c | 1 + include/hw/ipmi/ipmi.h | 10 +++++++ 4 files changed, 79 insertions(+), 2 deletions(-) diff --git a/hw/ipmi/ipmi_bmc_sim.c b/hw/ipmi/ipmi_bmc_sim.c index bc0ddc52a9..03e58d283e 100644 --- a/hw/ipmi/ipmi_bmc_sim.c +++ b/hw/ipmi/ipmi_bmc_sim.c @@ -70,6 +70,7 @@ #define IPMI_CMD_GET_MSG 0x33 #define IPMI_CMD_SEND_MSG 0x34 #define IPMI_CMD_READ_EVT_MSG_BUF 0x35 +#define IPMI_CMD_GET_CHANNEL_INFO 0x42 =20 #define IPMI_NETFN_STORAGE 0x0a =20 @@ -1020,8 +1021,8 @@ static void send_msg(IPMIBmcSim *ibs, uint8_t *buf; uint8_t netfn, rqLun, rsLun, rqSeq; =20 - if (cmd[2] !=3D 0) { - /* We only handle channel 0 with no options */ + if (cmd[2] !=3D IPMI_CHANNEL_IPMB) { + /* We only handle channel 0h (IPMB) with no options */ rsp_buffer_set_error(rsp, IPMI_CC_INVALID_DATA_FIELD); return; } @@ -1219,6 +1220,68 @@ static void get_watchdog_timer(IPMIBmcSim *ibs, } } =20 +static void get_channel_info(IPMIBmcSim *ibs, + uint8_t *cmd, unsigned int cmd_len, + RspBuffer *rsp) +{ + IPMIInterface *s =3D ibs->parent.intf; + IPMIInterfaceClass *k =3D IPMI_INTERFACE_GET_CLASS(s); + IPMIFwInfo info =3D {}; + uint8_t ch =3D cmd[2] & 0x0f; + + /* Only define channel 0h (IPMB) and Fh (system interface) */ + + if (ch =3D=3D 0x0e) { /* "This channel" */ + ch =3D IPMI_CHANNEL_SYSTEM; + } + rsp_buffer_push(rsp, ch); + + if (ch !=3D IPMI_CHANNEL_IPMB && ch !=3D IPMI_CHANNEL_SYSTEM) { + /* Not a supported channel */ + rsp_buffer_set_error(rsp, IPMI_CC_INVALID_DATA_FIELD); + return; + } + + if (k->get_fwinfo) { + k->get_fwinfo(s, &info); + } + + if (ch =3D=3D IPMI_CHANNEL_IPMB) { + rsp_buffer_push(rsp, IPMI_CHANNEL_MEDIUM_IPMB); + rsp_buffer_push(rsp, IPMI_CHANNEL_PROTOCOL_IPMB); + } else { /* IPMI_CHANNEL_SYSTEM */ + rsp_buffer_push(rsp, IPMI_CHANNEL_MEDIUM_SYSTEM); + rsp_buffer_push(rsp, info.ipmi_channel_protocol); + } + + rsp_buffer_push(rsp, 0x00); /* Session-less */ + + /* IPMI Enterprise Number for Vendor ID */ + rsp_buffer_push(rsp, 0xf2); + rsp_buffer_push(rsp, 0x1b); + rsp_buffer_push(rsp, 0x00); + + if (ch =3D=3D IPMI_CHANNEL_SYSTEM) { + uint8_t irq; + + if (info.irq_source =3D=3D IPMI_ISA_IRQ) { + irq =3D info.interrupt_number; + } else if (info.irq_source =3D=3D IPMI_PCI_IRQ) { + irq =3D 0x10 + info.interrupt_number; + } else { + irq =3D 0xff; /* no interrupt / unspecified */ + } + + /* Both interrupts use the same irq number */ + rsp_buffer_push(rsp, irq); + rsp_buffer_push(rsp, irq); + } else { + /* Reserved */ + rsp_buffer_push(rsp, 0x00); + rsp_buffer_push(rsp, 0x00); + } +} + static void get_sdr_rep_info(IPMIBmcSim *ibs, uint8_t *cmd, unsigned int cmd_len, RspBuffer *rsp) @@ -2015,6 +2078,7 @@ static const IPMICmdHandler app_cmds[] =3D { [IPMI_CMD_RESET_WATCHDOG_TIMER] =3D { reset_watchdog_timer }, [IPMI_CMD_SET_WATCHDOG_TIMER] =3D { set_watchdog_timer, 8 }, [IPMI_CMD_GET_WATCHDOG_TIMER] =3D { get_watchdog_timer }, + [IPMI_CMD_GET_CHANNEL_INFO] =3D { get_channel_info, 3 }, }; static const IPMINetfn app_netfn =3D { .cmd_nums =3D ARRAY_SIZE(app_cmds), diff --git a/hw/ipmi/ipmi_bt.c b/hw/ipmi/ipmi_bt.c index 583fc64730..28cf6ab218 100644 --- a/hw/ipmi/ipmi_bt.c +++ b/hw/ipmi/ipmi_bt.c @@ -419,6 +419,8 @@ void ipmi_bt_get_fwinfo(struct IPMIBT *ib, IPMIFwInfo *= info) info->interface_type =3D IPMI_SMBIOS_BT; info->ipmi_spec_major_revision =3D 2; info->ipmi_spec_minor_revision =3D 0; + /* BT System Interface Format, IPMI v1.5 */ + info->ipmi_channel_protocol =3D IPMI_CHANNEL_PROTOCOL_BT_15; info->base_address =3D ib->io_base; info->register_length =3D ib->io_length; info->register_spacing =3D 1; diff --git a/hw/ipmi/ipmi_kcs.c b/hw/ipmi/ipmi_kcs.c index c15977cab4..578dd7cef3 100644 --- a/hw/ipmi/ipmi_kcs.c +++ b/hw/ipmi/ipmi_kcs.c @@ -405,6 +405,7 @@ void ipmi_kcs_get_fwinfo(IPMIKCS *ik, IPMIFwInfo *info) info->interface_type =3D IPMI_SMBIOS_KCS; info->ipmi_spec_major_revision =3D 2; info->ipmi_spec_minor_revision =3D 0; + info->ipmi_channel_protocol =3D IPMI_CHANNEL_PROTOCOL_KCS; info->base_address =3D ik->io_base; info->i2c_slave_address =3D ik->bmc->slave_addr; info->register_length =3D ik->io_length; diff --git a/include/hw/ipmi/ipmi.h b/include/hw/ipmi/ipmi.h index c8ef04856e..802a2febb0 100644 --- a/include/hw/ipmi/ipmi.h +++ b/include/hw/ipmi/ipmi.h @@ -41,6 +41,15 @@ enum ipmi_op { IPMI_SEND_NMI }; =20 +/* Channel properties */ +#define IPMI_CHANNEL_IPMB 0x00 +#define IPMI_CHANNEL_SYSTEM 0x0f +#define IPMI_CHANNEL_MEDIUM_IPMB 0x01 +#define IPMI_CHANNEL_MEDIUM_SYSTEM 0x0c +#define IPMI_CHANNEL_PROTOCOL_IPMB 0x01 +#define IPMI_CHANNEL_PROTOCOL_KCS 0x05 +#define IPMI_CHANNEL_PROTOCOL_BT_15 0x08 + #define IPMI_CC_INVALID_CMD 0xc1 #define IPMI_CC_COMMAND_INVALID_FOR_LUN 0xc2 #define IPMI_CC_TIMEOUT 0xc3 @@ -76,6 +85,7 @@ typedef struct IPMIFwInfo { int interface_type; uint8_t ipmi_spec_major_revision; uint8_t ipmi_spec_minor_revision; + uint8_t ipmi_channel_protocol; uint8_t i2c_slave_address; uint32_t uuid; =20 --=20 2.43.0