ipmi: bt-i2c: added IPMI Block Transfer over I2C
Subsystems (4)
cover ipmi: bt-i2c: added IPMI Block Transfer over I2C
This patchset introduces IPMI Block Transfer over I2C (BT-I2C), which has the same semantics as IPMI Block Transfer except it done over I2C.
The documentation discusses the reason for this in greater detail, suffice it to say SSIF cannot be correctly implemented on some naive I2C devices. There are some additional reasons why we don't like SSIF, but those are again covered in the documentation for all those who are interested.
In addition, since I am adding both host side and BMC side support, I figured that now is a good time to resolve the problem of where to put BMC side IPMI drivers; right now we have it (there is only one) in drivers/char/ipmi/ with the rest of the host side IPMI drivers, but I think it makes sense to put all of the host side IPMI drivers in one directory and all of the BMC side drivers in another, preferably in a way that does not effect all of the current OpenIPMI users. I have not created a MAINTAINERS entry for the new directory yet, as I figured there might be some discussion to be had about it.
I have tested this patchset on the Aspeed 2500 EVB.
PATCH 1/3 ipmi: bt-i2c: added documentation for bt-i2c drivers
Added device tree binding documentation for ipmi-bt-i2c (host) and ipmi-bmc-bt-i2c (BMC) and documentation for the Block Transfer over I2C (bt-i2c) protocol.
--- Documentation/bt-i2c.txt | 121 +++++++++++++++++++++ .../devicetree/bindings/ipmi/ipmi-bt-i2c.txt | 21 ++++ .../bindings/ipmi_bmc/ipmi-bmc-bt-i2c.txt | 21 ++++ 3 files changed, 163 insertions(+) create mode 100644 Documentation/bt-i2c.txt create mode 100644 Documentation/devicetree/bindings/ipmi/ipmi-bt-i2c.txt create mode 100644 Documentation/devicetree/bindings/ipmi_bmc/ipmi-bmc-bt-i2c.txt
Documentation/bt-i2c.txt new file +121 -0
@@ -0,0 +1,121 @@ +Linux Block Transfer over I2C (bt-i2c) interface description +============================================================ + +by Brendan Higgins <[email protected]> in 2016 + +Introduction +------------ + +IPMI defines an interface for communication between a CPU, a BMC (Baseboard +Management Controller), and sensors and various other peripherals. For a more +complete description of IPMI please see: +http://www.intel.com/content/www/us/en/servers/ipmi/ipmi-second-gen-interface-spec-v2-rev1-1.html + +IPMI defines a *common* message format, as in a set of fields that are common +across all IPMI messages; they could be viewed as part of the framing +information for an IPMI message. They include: + + - netfn + - lun + - cmd + +netfn and cmd together define the type of the message; netfn can be viewed as a +message class and cmd is a subtype of sorts. lun (logical unit number) is used +for routing between messages between different interfaces. After the last field +there is usually a variable length payload. Despite these common fields, the +remainder of the framing varies widely between the IPMI defined hardware +interfaces; some specify a length as part of the framing which is never more +than a byte in length; others use a special signal to denote the end of message. +Some IPMI hardware interfaces, the Block Transfer interface in particular, +support a sequence number that aids in support of multiple in-flight IPMI +messages. + +IPMI defines SSIF (SMBus System Interface) as the IPMI hardware interface for +SMBus/I2C. It supports a maximum total message length of 255 bytes that is +broken up across several SMBus block operations. It does not define a sequence +field in the IPMI framing making it very difficult to support multiple in flight +messages (it is also intentionally left out of the specification). SSIF also +requires the slave device to NACK until it is ready to accept data (technically +it only specifies that it may NACK until it is ready, but must NACK on attempted +reads if it does not support SMBus Alert; however, this is an effective +requirements since a slave device is supposed to start with SMBus Alert +disabled); this again makes SSIF very difficult to support for some slave +devices which may not support NACKing arbitrary messages; indeed, at the time of +writing, the Linux I2C slave driver framework did not have support for sending +NACKs. + +Block Transfer over I2C defines a new IPMI compatible interface that uses Block +Transfer messages and semantics on top of plain old I2C; it does not assume that +the I2C slave is capable of NACKing arbitrary messages; however, it is designed +such that it could take advantage of SMBus Alert so that the master does not +have to poll (the Linux I2C core slave mode does not currently support SMBus +Alert, but a patch adding this support is currently on the way). + +Protocol Definition +------------------- + +Block Transfer over I2C uses the IPMI defined Block Transfer message format; it +supports variable length messages with a maximum length of 255 bytes (limited by +the IPMI Block Transfer length byte). + +A Block Transfer over I2C Request is structured as follows: + +------------------------------------------------------------------------------------------------------ +| I2C start | slave address / RW bit unset | Block Transfer message | ... (another message or stop ) | +------------------------------------------------------------------------------------------------------ + +Multiple requests can be sent before any responses are received. Sequence +numbers are to be handled by the users of the drivers; thus, no semantics are +prescribed to their usage; however, the slave driver is required to buffer at +least 256 requests before dropping requests; this can be used in conjunction +with sequence numbers to prevent messages from being dropped by the slave. + +A Block Transfer over I2C Response is structured as follows: + +---------------------------------------------------------------------------------------------------- +| I2C start | slave address / RW bit set | Block Transfer message | ... (another message or stop ) | +---------------------------------------------------------------------------------------------------- + +Until a response is ready to send, the slave will respond only with zero bytes. +If the slave receives a start or a stop before it was done sending a response, +it will resend the entire response the next time a read is requested; in this +way, an I2C master may poll for responses by reading a single byte until it is +non-zero and then perform the read transaction shown above. + +In the future, it is planned that the slave will support using SMBus Alert to +notify the master of an available response, but will never be required. + +Driver Interface +---------------- + +The slave side of the device file interface is modeled after ipmi-bmc-bt-i2c, a +driver for the Aspeed 24xx/255xx IPMI Block Transfer controller. + +A read (request) should be large enough to fit a Block Transfer message +(including the length byte) of 256 bytes; if the provided buffer is smaller, the +message will be truncated. + +A write (response) must be no greater than the maximum valid length of a Block +Transfer message (including the length byte), 256 bytes; if the provided buffer +is larger, the write will fail with EINVAL. The driver also enforces a valid +length byte which must contain the total length of the message not including the +length byte; thus, the write will fail with EINVAL if the buffer length is less +than the length field plus one. The driver will also only send length field plus +one bytes. + +The slave device file interface also supports the poll system call; it will +report when a request is available to read or it is ready to accept a response. + +The master side conforms to the OpenIPMI kernel framework. + +A read (response) should be large enough to fit a Block Transfer message +(including the length byte) of 256 bytes; if the provided buffer is smaller, the +message will be truncated. + +A write (request) must be no greater than the maximum valid length of a Block +Transfer message (including the length byte), 256 bytes; if the provided buffer +is larger, the write will fail with EFAULT. The driver also enforces a valid +length byte which must contain the total length of the message not including the +length byte; thus, the write will fail with EFAULT if the buffer length is less +than the length field plus one. The driver will also only send length field plus +one bytes.
Documentation/devicetree/bindings/ipmi/ipmi-bt-i2c.txt new file +21 -0
@@ -0,0 +1,21 @@ +Device tree configuration for the ipmi-bt-i2c driver. + +Required Properties: +- compatible : should be "ipmi-bt-i2c" +- reg : the I2C slave address of the ipmi-bmc-bt-i2c + +i2c0: i2c-bus@40 { + #address-cells = <1>; + #size-cells = <0>; + reg = <0x40 0x40>; + compatible = "aspeed,ast2400-i2c-bus"; + clock-frequency = <100000>; + status = "disabled"; + interrupts = <0>; + interrupt-parent = <&i2c>; + + bt-i2c-master@41 { + compatible = "ipmi-bt-i2c"; + reg = <0x41>; + }; +};
Documentation/devicetree/bindings/ipmi_bmc/ipmi-bmc-bt-i2c.txt new file +21 -0
@@ -0,0 +1,21 @@ +Device tree configuration for the ipmi-bmc-bt-i2c driver. + +Required Properties: +- compatible : should be "ipmi-bmc-bt-i2c" +- reg : the I2C slave address of this driver. + +i2c0: i2c-bus@40 { + #address-cells = <1>; + #size-cells = <0>; + reg = <0x40 0x40>; + compatible = "aspeed,ast2400-i2c-bus"; + clock-frequency = <100000>; + status = "disabled"; + interrupts = <0>; + interrupt-parent = <&i2c>; + + bt-i2c-slave@41 { + compatible = "ipmi-bmc-bt-i2c"; + reg = <0x41>; + }; +};
Signature · 1 line
2.14.0.rc1.383.gd1ce394fe2-goog
PATCH 2/3 ipmi: bt-i2c: added IPMI Block Transfer over I2C host side
In reply to Brendan HigginsThe IPMI definition of the Block Transfer protocol defines the hardware registers and behavior in addition to the message format and messaging semantics. This implements a new protocol that uses IPMI Block Transfer messages and semantics on top of a standard I2C interface.
--- drivers/char/ipmi/Kconfig | 4 + drivers/char/ipmi/Makefile | 1 + drivers/char/ipmi/ipmi_bt_i2c.c | 452 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 457 insertions(+) create mode 100644 drivers/char/ipmi/ipmi_bt_i2c.c
drivers/char/ipmi/Kconfig +4 -0
@@ -79,6 +79,10 @@ config IPMI_POWEROFF This enables a function to power off the system with IPMI if the IPMI management controller is capable of this. +config IPMI_BT_I2C + select I2C + tristate 'BT IPMI bmc driver over I2c' + endif # IPMI_HANDLER config ASPEED_BT_IPMI_BMC
drivers/char/ipmi/Makefile +1 -0
@@ -12,4 +12,5 @@ obj-$(CONFIG_IPMI_SSIF) += ipmi_ssif.o obj-$(CONFIG_IPMI_POWERNV) += ipmi_powernv.o obj-$(CONFIG_IPMI_WATCHDOG) += ipmi_watchdog.o obj-$(CONFIG_IPMI_POWEROFF) += ipmi_poweroff.o +obj-$(CONFIG_IPMI_BT_I2C) += ipmi_bt_i2c.o obj-$(CONFIG_ASPEED_BT_IPMI_BMC) += bt-bmc.o
drivers/char/ipmi/ipmi_bt_i2c.c new file +452 -0
452 lines not on this page · raw message
Signature · 6 lines
2.14.0.rc1.383.gd1ce394fe2-goog -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
kbuild test robot
build botRe: [PATCH v1 2/3] ipmi: bt-i2c: added IPMI Block Transfer over I2C host side
url: https://github.com/0day-ci/linux/commits/Brendan-Higgins/ipmi-bt-i2c-added-IPMI-Block-Transfer-over-I2C/20170806-033950 config: ia64-allyesconfig (attached as .config) compiler: ia64-linux-gcc…
Hi Brendan,
[auto build test ERROR on char-misc/char-misc-testing]
[also build test ERROR on v4.13-rc3 next-20170804]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Brendan-Higgins/ipmi-bt-i2c-added-IPMI-Block-Transfer-over-I2C/20170806-033950
config: ia64-allyesconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 6.2.0
reproduce:
wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=ia64
All errors (new ones prefixed by >>):
drivers/char/ipmi/ipmi_bt_i2c.c: In function 'ipmi_bt_i2c_receive_response':
>> drivers/char/ipmi/ipmi_bt_i2c.c:119:7: error: implicit declaration of function 'signal_pending' [-Werror=implicit-function-declaration]
if (signal_pending(current))
^~~~~~~~~~~~~~cc1: some warnings being treated as errors
vim +/signal_pending +119 drivers/char/ipmi/ipmi_bt_i2c.c
97
98 static int ipmi_bt_i2c_receive_response(struct ipmi_bt_i2c_master *master,
99 struct ipmi_bt_i2c_msg *response)
100 {
101 struct i2c_client *client = master->client;
102 unsigned long timeout, read_time;
103 u8 *buf = (u8 *) response;
104 u8 len = 0;
105 int ret;
106
107 /*
108 * Slave may not NACK when not ready, so we peek at the first byte to
109 * see if it is a valid length.
110 */
111 ret = i2c_master_recv(client, &len, 1);
112 while (ret != 1 || len == 0) {
113 if (ret < 0)
114 return ret;
115
116 usleep_range(1000, 1500);
117
118 /* Signal received: quit syscall. */
> 119 if (signal_pending(current)) 120 return -ERESTARTSYS;
121
122 ret = i2c_master_recv(client, &len, 1);
123 }
124
125 timeout = jiffies + msecs_to_jiffies(write_timeout);
126 do {
127 read_time = jiffies;
128 ret = i2c_master_recv(client, buf, len + 1);
129 if (ret >= 0)
130 return 0;
131 usleep_range(1000, 1500);
132 } while (time_before(read_time, timeout));
133 return ret;
134 }
135
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
PATCH 3/3 ipmi: bt-i2c: added IPMI Block Transfer over I2C BMC side
In reply to Brendan HigginsThe IPMI definition of the Block Transfer protocol defines the hardware registers and behavior in addition to the message format and messaging semantics. This implements a new protocol that uses IPMI Block Transfer messages and semantics on top of a standard I2C interface. This protocol has the same BMC side file system interface as "ipmi-bt-host".
--- drivers/char/Kconfig | 1 + drivers/char/Makefile | 1 + drivers/char/ipmi_bmc/Kconfig | 22 ++ drivers/char/ipmi_bmc/Makefile | 5 + drivers/char/ipmi_bmc/ipmi_bmc_bt_i2c.c | 346 ++++++++++++++++++++++++++++++++ include/linux/ipmi_bmc.h | 76 +++++++ 6 files changed, 451 insertions(+) create mode 100644 drivers/char/ipmi_bmc/Kconfig create mode 100644 drivers/char/ipmi_bmc/Makefile create mode 100644 drivers/char/ipmi_bmc/ipmi_bmc_bt_i2c.c create mode 100644 include/linux/ipmi_bmc.h
drivers/char/Kconfig +1 -0
@@ -195,6 +195,7 @@ config POWERNV_OP_PANEL If unsure, say M here to build it as a module called powernv-op-panel. source "drivers/char/ipmi/Kconfig" +source "drivers/char/ipmi_bmc/Kconfig" config DS1620 tristate "NetWinder thermometer support"
drivers/char/Makefile +1 -0
@@ -58,4 +58,5 @@ js-rtc-y = rtc.o obj-$(CONFIG_TILE_SROM) += tile-srom.o obj-$(CONFIG_XILLYBUS) += xillybus/ +obj-$(CONFIG_IPMI_BMC) += ipmi_bmc/ obj-$(CONFIG_POWERNV_OP_PANEL) += powernv-op-panel.o
drivers/char/ipmi_bmc/Kconfig new file +22 -0
@@ -0,0 +1,22 @@ +# +# IPMI BMC configuration +# + +menuconfig IPMI_BMC + tristate 'IPMI BMC core' + help + This enables the BMC-side IPMI drivers. + + If unsure, say N. + +if IPMI_BMC + +config IPMI_BMC_BT_I2C + depends on I2C + select I2C_SLAVE + tristate 'Generic I2C BT IPMI BMC driver' + help + Provides a driver that uses IPMI Block Transfer messages and + semantics on top of plain old I2C. + +endif # IPMI_BMC
drivers/char/ipmi_bmc/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# +# Makefile for the ipmi bmc drivers. +# + +obj-$(CONFIG_IPMI_BMC_BT_I2C) += ipmi_bmc_bt_i2c.o
drivers/char/ipmi_bmc/ipmi_bmc_bt_i2c.c new file +346 -0
346 lines not on this page · raw message
include/linux/ipmi_bmc.h new file +76 -0
76 lines not on this page · raw message
Signature · 6 lines
2.14.0.rc1.383.gd1ce394fe2-goog -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 17 lines · Brendan Higgins
This patchset introduces IPMI Block Transfer over I2C (BT-I2C), which has the same semantics as IPMI Block Transfer except it done over I2C.
The documentation discusses the reason for this in greater detail, suffice it to say SSIF cannot be correctly implemented on some naive I2C devices. There are some additional reasons why we don't like SSIF, but those are again covered in the documentation for all those who are interested.
In addition, since I am adding both host side and BMC side support, I figured that now is a good time to resolve the problem of where to put BMC side IPMI drivers; right now we have it (there is only one) in
drivers/char/ipmi/with the rest of the host side IPMI drivers, but I think it makes sense to put all of the host side IPMI drivers in one directory and all of the BMC side drivers in another, preferably in a way that does not effect all of the current OpenIPMI users. I have not created aMAINTAINERSentry for the new directory yet, as I figured there might be some discussion to be had about it.
Quoted 1 line
I have tested this patchset on the Aspeed 2500 EVB.
I forgot to mention, for the OpenBMC people, this is based on an RFC:
https://lists.ozlabs.org/pipermail/openbmc/2016-September/004505.html
Hello, I would like to mention one of the our related work for IPMI and I2C. We use OpenIPMI stack to connect to the computing nodes through the I2C using IPMB (BT is not supported by nodes): https://github.com/ya-mouse/meta-openbmc-yandex/blob/master/meta-yandex/meta-openrack/meta-shaosi/recipes-kernel/linux/linux-obmc/ipmi_i2c.c It lacks complete slave support (slave part is only for receiving known packets with query results due to OpenIPMI implementation in kernel) and use one local slave to communicate with a number of target systems on the same bus (currently supported only 1-to-1 schema). With this stuff we able to use ipmitool across different /dev/ipmiX devices to communicate with nodes. 05.08.2017, 02:19, "Brendan Higgins" <[email protected]>:This patchset introduces IPMI Block Transfer over I2C (BT-I2C), which has the same semantics as IPMI Block Transfer except it done over I2C.
The documentation discusses the reason for this in greater detail, suffice it to say SSIF cannot be correctly implemented on some naive I2C devices. There are some additional reasons why we don't like SSIF, but those are again covered in the documentation for all those who are interested.
In addition, since I am adding both host side and BMC side support, I figured that now is a good time to resolve the problem of where to put BMC side IPMI drivers; right now we have it (there is only one) in drivers/char/ipmi/ with the rest of the host side IPMI drivers, but I think it makes sense to put all of the host side IPMI drivers in one directory and all of the BMC side drivers in another, preferably in a way that does not effect all of the current OpenIPMI users. I have not created a MAINTAINERS entry for the new directory yet, as I figured there might be some discussion to be had about it.
I have tested this patchset on the Aspeed 2500 EVB. --
Anton D. Kachalov
Quoted 9 lines · Anton D. Kachalov
Hello,
I would like to mention one of the our related work for IPMI and I2C.
We use OpenIPMI stack to connect to the computing nodes through the I2C using IPMB (BT is not supported by nodes):
Quoted 7 lines
It lacks complete slave support (slave part is only for receiving known packets with query results due to OpenIPMI implementation in kernel) and use one local slave to communicate with a number of target systems on the same bus (currently supported only 1-to-1 schema).
With this stuff we able to use ipmitool across different
/dev/ipmiXdevices to communicate with nodes.
Cool, I met someone else who had a similar use case which is part of why I decided to share this (not sure if should say who).
So it sounds like we are probably not going to go with the approach I proposed; if you indeed find this useful, I would suggest that we put this in our OpenBMC repository and switch it out with the suggested method at some point.
Let me know what you think
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html