Skip to contentSkip to conversation

ipmi: bt-i2c: added IPMI Block Transfer over I2C

PATCH In review Brendan Higgins 4 participants 12 messages Aug 5, 2017 – Aug 10, 2017

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v2 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.

For the OpenBMC people, this is based on an RFC:
https://lists.ozlabs.org/pipermail/openbmc/2016-September/004505.html

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.

Changes since previous update:
- Cleaned up some documentation.
- Added patch which moves the Aspeed BT-BMC driver to the new ipmi_bmc directory.

#1 lore raw

PATCH v2 1/4 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.

---
Changes for v2:
- Fixed a typo
- Reworded a sentence to make it clear that I was talking about IBM's BT-BMC
- Deleted an unnecessary discussion of the host side interface (unnecessary since the OpenIPMI stuff already has its own documentation).

---
 Documentation/bt-i2c.txt                           | 109 +++++++++++++++++++++
 .../devicetree/bindings/ipmi/ipmi-bt-i2c.txt       |  21 ++++
 .../bindings/ipmi_bmc/ipmi-bmc-bt-i2c.txt          |  21 ++++
 3 files changed, 151 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 +109 -0
new file mode 100644
index 000000000000..499931b02e6c
@@ -0,0 +1,109 @@
+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 device file interface for the slave side is modeled after bt-bmc, a Block
+Transfer over LPC driver for the Aspeed 24xx/255xx.
+
+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.
Documentation/devicetree/bindings/ipmi/ipmi-bt-i2c.txt new file +21 -0
new file mode 100644
index 000000000000..bd956f2805e4
@@ -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
new file mode 100644
index 000000000000..6e82693ee50e
@@ -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
#3 lore raw

PATCH v2 2/4 ipmi: bt-i2c: added IPMI Block Transfer over I2C host side

In reply to Brendan Higgins

The 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.

---
Changes for v2:
- None

---
 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
index f6fa056a52fc..a8734a369cb0 100644
@@ -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
index eefb0b301e83..323de0b0b8b5 100644
@@ -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 · 1 line
2.14.0.rc1.383.gd1ce394fe2-goog
#4 lore raw

PATCH v2 3/4 ipmi: bt-i2c: added IPMI Block Transfer over I2C BMC side

In reply to Brendan Higgins

The 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".

---
Changes for v2:
- None

---
 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
index ccd239ab879f..2a6ca2325a45 100644
@@ -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
index 53e33720818c..9e143186fa30 100644
@@ -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
new file mode 100644
index 000000000000..26c8e0cb765c
@@ -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
new file mode 100644
index 000000000000..dfe5128f8158
@@ -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 · 1 line
2.14.0.rc1.383.gd1ce394fe2-goog
#5 lore raw

PATCH v2 4/4 ipmi: bt-bmc: move Aspeed IPMI BMC driver to ipmi_bmc

In reply to Brendan Higgins

From: Benjamin Fair <[email protected]>

The ipmi_bmc folder contains drivers for a BMC to communicate using IPMI. The ipmi folder is only for drivers on the host side using the OpenIPMI framework.

---
Added in v2:

---
 drivers/char/ipmi/Kconfig                                     | 9 ---------
 drivers/char/ipmi/Makefile                                    | 1 -
 drivers/char/ipmi_bmc/Kconfig                                 | 9 +++++++++
 drivers/char/ipmi_bmc/Makefile                                | 1 +
 drivers/char/{ipmi/bt-bmc.c => ipmi_bmc/ipmi_bmc_bt_aspeed.c} | 0
 5 files changed, 10 insertions(+), 10 deletions(-)
 rename drivers/char/{ipmi/bt-bmc.c => ipmi_bmc/ipmi_bmc_bt_aspeed.c} (100%)
drivers/char/ipmi/Kconfig +0 -9
index a8734a369cb0..09ce9f64abf8 100644
@@ -84,12 +84,3 @@ config IPMI_BT_I2C
 	tristate 'BT IPMI bmc driver over I2c'
 
 endif # IPMI_HANDLER
-
-config ASPEED_BT_IPMI_BMC
-	depends on ARCH_ASPEED || COMPILE_TEST
-       depends on REGMAP && REGMAP_MMIO && MFD_SYSCON
-	tristate "BT IPMI bmc driver"
-	help
-	  Provides a driver for the BT (Block Transfer) IPMI interface
-	  found on Aspeed SOCs (AST2400 and AST2500). The driver
-	  implements the BMC side of the BT interface.
drivers/char/ipmi/Makefile +0 -1
index 323de0b0b8b5..f0b5672cdca9 100644
@@ -13,4 +13,3 @@ 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_bmc/Kconfig +9 -0
index 26c8e0cb765c..b6af38455702 100644
@@ -19,4 +19,13 @@ config IPMI_BMC_BT_I2C
 	  Provides a driver that uses IPMI Block Transfer messages and
 	  semantics on top of plain old I2C.
 
+config ASPEED_BT_IPMI_BMC
+	depends on ARCH_ASPEED || COMPILE_TEST
+	depends on REGMAP && REGMAP_MMIO && MFD_SYSCON
+	tristate "BT IPMI bmc driver"
+	help
+	  Provides a driver for the BT (Block Transfer) IPMI interface
+	  found on Aspeed SOCs (AST2400 and AST2500). The driver
+	  implements the BMC side of the BT interface.
+
 endif # IPMI_BMC
drivers/char/ipmi_bmc/Makefile +1 -0
index dfe5128f8158..8bff32b55c24 100644
@@ -3,3 +3,4 @@
 #
 
 obj-$(CONFIG_IPMI_BMC_BT_I2C) += ipmi_bmc_bt_i2c.o
+obj-$(CONFIG_ASPEED_BT_IPMI_BMC) += ipmi_bmc_bt_aspeed.o
drivers/char/ipmi_bmc/ipmi_bmc_bt_aspeed.c renamed from drivers/char/ipmi/bt-bmc.c +0 -0
similarity index 100%
rename from drivers/char/ipmi/bt-bmc.c
rename to drivers/char/ipmi_bmc/ipmi_bmc_bt_aspeed.c
Signature · 1 line
2.14.0.rc1.383.gd1ce394fe2-goog
#6 lore raw
In reply to Brendan Higgins
Quoted 10 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.

For the OpenBMC people, this is based on an RFC:
https://lists.ozlabs.org/pipermail/openbmc/2016-September/004505.html

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.

I'm not terribly excited about this. A few notes:

SMBus alerts are fairly broken in Linux right now. I have a patch to fix this at:
https://github.com/cminyard/linux-ipmi/commit/48136176ce1890f99857c73e0ace5bd8dfb61fbf
I haven't been able to get much traction getting anyone to care.

The lack of a NACK could be worked around fairly easily in the current driver. It looks like you are just returning a message too short to be valid. That's easy. I think it's a rather major deficiency in the hardware to not be able to NACK something, but that is what it is.

What you have is not really BT over I2C. You have just added a sequence number to the IPMI messages and dropped the SMBus command. Other interfaces have sequence numbers, too. Calling it BT is a little over the top.

Do you really need the performance required by having multiple outstanding messages? That adds a lot of complexity, if it's unnecessary it's just a waste. The IPMI work on top of interfaces does not really require that much performance, it's just reading sensors, FRU data, and such. Perhaps you have a reason, but I fail to see
why it's really that big a deal. The BT interface has this ability, but the driver does not take advantage of it and nobody has complained.

And I don't understand the part about OpenBMC making use of sequence numbers. Why does that matter for this interface? It's the host side that would care about that, the host would stick the numbers in and the slave would return it. If you are using sequence numbers in OpenBMC, which sounds quite reasonable, I would think it would be a bad idea to to trust that the host would give you good sequence numbers.

Plus, with multiple outstanding messages, you really need to limit it. A particular BMC may not be able to handle it the full 256, and the ability to have that many messages outstanding is probably not a good thing.

If you really need multiple outstanding messages, the host side IPMI message handler needs to change to allow that. It's doable, and I know how, I just haven't seen the need.

I would agree that the multi-part messages in SSIF is a big pain and and a lot of unnecessary complexity. I believe it is there to accommodate host hardware that is limited. But SMBus can have 255 byte messages and there's no arbitrary limit on I2C. It is the way of IPMI to support the least common denominator.

Your interface will only work on Linux. Other OSes (unless they choose to implement this driver) will be unable to use your BMC. Of course there's the NACK issue, but that's a big difference, and it would probably still work with existing drivers on other OSes. Plus people may choose to use OpenBMC on things besides the aspeed devices that could do a NACK. That's kind of the point of OpenBMC, isn't it?

My suggestion would be to implement a BMC that supports standard SSIF single part messages by default. That way any existing driver will work with it. (I don't know about the NACK thing, but that's a much smaller issue than a whole new protocol.) Then use OEM extensions to query things like if it can do messages larger than 32 bytes or supports sequence numbers, and how many outstanding messages it can have, and extend the current SSIF driver. It wouldn't be very hard.

In my experience, sticking with standards is a good thing, and designing your own protocols is fraught with peril. I'm not trying to be difficult here, but I am against the proliferation of things that do not need to proliferate :).

-corey

Quoted 10 lines

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.

Quoted 6 lines

I have tested this patchset on the Aspeed 2500 EVB.

Changes since previous update:
- Cleaned up some documentation.
- Added patch which moves the Aspeed BT-BMC driver to the new ipmi_bmc directory.

--
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

#7 lore raw
Quoted 18 lines · Corey Minyard
Quoted 8 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.

For the OpenBMC people, this is based on an RFC:
https://lists.ozlabs.org/pipermail/openbmc/2016-September/004505.html

Quoted 7 lines

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.

Quoted 1 line

I'm not terribly excited about this. A few notes:

I was afraid so, alas.

Quoted 5 lines

SMBus alerts are fairly broken in Linux right now. I have a patch to fix this at:
https://github.com/cminyard/linux-ipmi/commit/48136176ce1890f99857c73e0ace5bd8dfb61fbf
I haven't been able to get much traction getting anyone to care.

Yeah, I have some work I would like to do there as well.

Quoted 7 lines

The lack of a NACK could be worked around fairly easily in the current driver. It looks like you
are just returning a message too short to be valid. That's easy. I think it's a rather major
deficiency in the hardware to not be able to NACK something, but that is what it is.

Right, we actually have multiple pieces of hardware that do not support NACKing correctly. The most frustrating piece is the Aspeed chip which does not provide and facility for arbitrary NACKs to be generated on the slave side.

Quoted 6 lines

What you have is not really BT over I2C. You have just added a sequence number to the
IPMI messages and dropped the SMBus command. Other interfaces have sequence numbers,
too. Calling it BT is a little over the top.

Fair point, maybe ISIF (I2C System Interface)? I don't have strong feelings about the name.

Quoted 12 lines

Do you really need the performance required by having multiple outstanding messages?
That adds a lot of complexity, if it's unnecessary it's just a waste. The IPMI work on top
of interfaces does not really require that much performance, it's just reading sensors,
FRU data, and such. Perhaps you have a reason, but I fail to see why it's really that big a deal. The BT interface has this ability, but the driver does not
take advantage of it and nobody has complained.

Yes, we do have some platforms which only have IPMI as a standard interface and we are abusing some OEM commands to do some things that we probably should not do with IPMI like doing firmware updates. Also, we have some commands which take a really long time to complete (> 1s). Admittedly, this is abusing IPMI to solve problems which should probably be solved elsewhere; nevertheless, it is a feature we are actually using. And having an option to use sequence numbers if definitely nice from our perspective.

We will probably want to improve the block transfer driver at some point as well.

Quoted 12 lines

And I don't understand the part about OpenBMC making use of sequence numbers.
Why does that matter for this interface? It's the host side that would care about
that, the host would stick the numbers in and the slave would return it. If you are
using sequence numbers in OpenBMC, which sounds quite reasonable, I would think
it would be a bad idea to to trust that the host would give you good sequence
numbers.

I think, I illustrated the use case above, but to reiterate, the desire is to have
multiple messages in flight at the same time because some messages take a long time to service.

Quoted 6 lines

Plus, with multiple outstanding messages, you really need to limit it. A particular BMC
may not be able to handle it the full 256, and the ability to have that many messages
outstanding is probably not a good thing.

It is going to depend on the BMC of course; nevertheless, I would be willing to implement a configurable limit.

Quoted 6 lines

If you really need multiple outstanding messages, the host side IPMI message handler
needs to change to allow that. It's doable, and I know how, I just haven't seen the
need.

Sure, we would also like SMBus alert support, but I figured it was probably best to discuss this with you before we go too far down that path.

Quoted 8 lines

I would agree that the multi-part messages in SSIF is a big pain and and a lot of
unnecessary complexity. I believe it is there to accommodate host hardware that is
limited. But SMBus can have 255 byte messages and there's no arbitrary limit on
I2C. It is the way of IPMI to support the least common denominator.

Quoted 6 lines

Your interface will only work on Linux. Other OSes (unless they choose to implement this
driver) will be unable to use your BMC. Of course there's the NACK issue, but that's a
big difference, and it would probably still work with existing drivers on other OSes.

I hope I did not send the message that we are planning on using this instead of SSIF forever and always. This is intended as an alternative to SSIF for some systems for which I2C is really the only available hardware interface, but SSIF is not well suited for said reasons.

It would be great for OpenBMC if someone added support for SSIF, but as far as I know, no one is asking for it.

Quoted 3 lines

Plus people may choose to use OpenBMC on things besides the aspeed devices that
could do a NACK. That's kind of the point of OpenBMC, isn't it?

Yes, using OpenBMC on other things is part of the point; however, all of the projects
that I am currently aware of and am trying to support use Aspeed parts which also
need an option.

Quoted 7 lines

My suggestion would be to implement a BMC that supports standard SSIF single part
messages by default. That way any existing driver will work with it. (I don't know
about the NACK thing, but that's a much smaller issue than a whole new protocol.)

Coming up with a satisfactory solution to working around systems that cannot NACK is my primary goal; I don't care about alternatives that do not address this.

Quoted 4 lines

Then use OEM extensions to query things like if it can do messages larger than 32
bytes or supports sequence numbers, and how many outstanding messages it can have, and extend the current SSIF driver. It wouldn't be very hard.

It would not be that hard to implement something that is naive, but I think it would
be difficult to implement something that is maintainable and robust. For example,
if I added an OEM extension that allowed me to add a sequence number, I would have to find a place that I could put it that would allow IPMI messages that do not
have the sequence number to still be sent and parsed correctly so that if either the host or BMC reset the other would still be able to send the message to return
it to the desired state. I can think of ways that this could be done, but I cannot
think of anyway that it could be done cleanly and would not make maintaining SSIF more complicated.

Quoted 6 lines

In my experience, sticking with standards is a good thing, and designing your own
protocols is fraught with peril. I'm not trying to be difficult here, but I am against
the proliferation of things that do not need to proliferate :).

I totally agree, which is why I tried to do something which looks like an existing IPMI interface to all of the software outside of this. As I mentioned above, I am afraid that hacking up SSIF to achieve the desired effects would make it much harder to maintain. I figured that the stuff I was trying to do does
not really look like SSIF, so I should not force it into SSIF. If we don't advertise it
as SSIF, then no one will expect it to behave that way.

Moreover, if we put all of the hacky stuff in its own driver then we don't have to
worry about it forever polluting SSIF; whereas, if we modify SSIF to support whatever weird things we suggest, it becomes a lot harder go back and clean it up if one day we find that no one is using it, which I do indeed hope becomes the case.

I guess that I would say that sticking with standards is a good thing, but if you
are going to break them, you must not make anything more difficult for the people who are following them.

All this being said, we do not terribly mind keeping these patches internal, at least for sometime (by then maybe we will have a better solution). The main reason I wanted to upstream these is twofold: I heard that there are some other people who ran into this problem and were interested in a solution of this type and I thought this would be a good motivating example behind a new BMC side IPMI framework that we are working on as it would help to illustrate the desire to separate the hardware layer from the common routing layer as you had done with the host side; however, as long as you are aware that there may be other implementations, just possibly not in the mainline kernel, then I suppose that is not really an issue. I will try to send out an RFC for this framework tonight.

Quoted 19 lines

-corey

Quoted 15 lines

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.

Regardless of what we do with the "BT-I2C" stuff, I am still interested in what you think about this.

Quoted 10 lines
Quoted 7 lines

I have tested this patchset on the Aspeed 2500 EVB.

Changes since previous update:
- Cleaned up some documentation.
- Added patch which moves the Aspeed BT-BMC driver to the new ipmi_bmc directory.

Thanks

#8 lore raw
Quoted 17 lines · Brendan Higgins
Quoted 16 lines · Corey Minyard
Quoted 14 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.

For the OpenBMC people, this is based on an RFC:
https://lists.ozlabs.org/pipermail/openbmc/2016-September/004505.html

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.

Quoted 7 lines
Quoted 5 lines

What you have is not really BT over I2C. You have just added a sequence number to the
IPMI messages and dropped the SMBus command. Other interfaces have sequence numbers,
too. Calling it BT is a little over the top.

Fair point, maybe ISIF (I2C System Interface)? I don't have strong feelings about the name.

I'm not too picky, either, I just didn't want someone to get confused.

Quoted 12 lines
Quoted 12 lines

Do you really need the performance required by having multiple outstanding messages?
That adds a lot of complexity, if it's unnecessary it's just a waste. The IPMI work on top
of interfaces does not really require that much performance, it's just reading sensors,
FRU data, and such. Perhaps you have a reason, but I fail to see why it's really that big a deal. The BT interface has this ability, but the driver does not
take advantage of it and nobody has complained.

Quoted 3 lines

Yes, we do have some platforms which only have IPMI as a standard interface and we are abusing some OEM commands to do some things that we probably should not do with IPMI like doing firmware updates.

Perhaps that is some level of abuse, but it's pretty common. I'm not against it.

There is standard IPMI firmware NetFN (though no commands defined) that if you use the driver automatically goes into "Maintenance mode" and modified the timeouts and handling to some extent to help with this.

Quoted 8 lines

Also, we have some
commands which take a really long time to complete (> 1s). Admittedly, this is abusing IPMI to solve problems which should probably be solved elsewhere; nevertheless, it is a feature we are actually using. And having an option to use sequence numbers if definitely nice from our perspective.

We will probably want to improve the block transfer driver at some point as well.

As long as you have a legitimate need, I don't have a problem with this. The upper layer of the driver can already handle this, there's just a small piece that interfaces to the lower layer that needs to be modified. And the ability to query the maximum number of outstanding messages from the lower layer.

BT will be harder, the SI interface code would need more significant updates.

snip

Quoted 15 lines
Quoted 9 lines

I would agree that the multi-part messages in SSIF is a big pain and and a lot of
unnecessary complexity. I believe it is there to accommodate host hardware that is
limited. But SMBus can have 255 byte messages and there's no arbitrary limit on
I2C. It is the way of IPMI to support the least common denominator.

Quoted 6 lines

Your interface will only work on Linux. Other OSes (unless they choose to implement this
driver) will be unable to use your BMC. Of course there's the NACK issue, but that's a
big difference, and it would probably still work with existing drivers on other OSes.

Quoted 7 lines

I hope I did not send the message that we are planning on using this instead of SSIF forever and always. This is intended as an alternative to SSIF for some systems for which I2C is really the only available hardware interface, but SSIF is not well suited for said reasons.

It would be great for OpenBMC if someone added support for SSIF, but as far as I know, no one is asking for it.

I am not convinced that SSIF is not suitable for this. It is true that the lack of NACK support won't work right now, but for the current SSIF driver that is adding a condition to a single if statement. I would be happy to have that. The current code returns an error in this case, but it might be better to just ignore it, anyway.

Quoted 23 lines
Quoted 3 lines

Plus people may choose to use OpenBMC on things besides the aspeed devices that
could do a NACK. That's kind of the point of OpenBMC, isn't it?

Yes, using OpenBMC on other things is part of the point; however, all of the projects
that I am currently aware of and am trying to support use Aspeed parts which also
need an option.

Quoted 6 lines

My suggestion would be to implement a BMC that supports standard SSIF single part
messages by default. That way any existing driver will work with it. (I don't know
about the NACK thing, but that's a much smaller issue than a whole new protocol.)

Coming up with a satisfactory solution to working around systems that cannot NACK is my primary goal; I don't care about alternatives that do not address this.

Quoted 4 lines

Then use OEM extensions to query things like if it can do messages larger than 32
bytes or supports sequence numbers, and how many outstanding messages it can have, and extend the current SSIF driver. It wouldn't be very hard.

Quoted 14 lines

It would not be that hard to implement something that is naive, but I think it would
be difficult to implement something that is maintainable and robust. For example,
if I added an OEM extension that allowed me to add a sequence number, I would have to find a place that I could put it that would allow IPMI messages that do not
have the sequence number to still be sent and parsed correctly so that if either the host or BMC reset the other would still be able to send the message to return
it to the desired state. I can think of ways that this could be done, but I cannot
think of anyway that it could be done cleanly and would not make maintaining SSIF more complicated.

There are ways to accomplish this that aren't that complex. You can create an OEM command that can query the maximum message size and the ability to do sequence numbers in the messages.

If messages larger than 32-bytes are supported, and the host I2C/SMBus driver supports it, you could use the standard SSIF SMBus commands to do this, they have an 8-bit length field.

If sequence numbers are supported, The SSIF could use different SMBus commands to do the write and read requests. Since this is only if you get an OEM command, and if you put the sequence numbers at the end where they are easy to add on the send side, this is a small change to the driver.

So I think the changes would be small and contained. I'm actually ok with a different driver, but I think it would be more valuable to the OpenBMC project to have a standardized interface that would work (in a not quite as efficient mode) with software that does not use the Linux IPMI driver.

Quoted 55 lines
Quoted 5 lines

In my experience, sticking with standards is a good thing, and designing your own
protocols is fraught with peril. I'm not trying to be difficult here, but I am against
the proliferation of things that do not need to proliferate :).

I totally agree, which is why I tried to do something which looks like an existing IPMI interface to all of the software outside of this. As I mentioned above, I am afraid that hacking up SSIF to achieve the desired effects would make it much harder to maintain. I figured that the stuff I was trying to do does
not really look like SSIF, so I should not force it into SSIF. If we don't advertise it
as SSIF, then no one will expect it to behave that way.

Moreover, if we put all of the hacky stuff in its own driver then we don't have to
worry about it forever polluting SSIF; whereas, if we modify SSIF to support whatever weird things we suggest, it becomes a lot harder go back and clean it up if one day we find that no one is using it, which I do indeed hope becomes the case.

I guess that I would say that sticking with standards is a good thing, but if you
are going to break them, you must not make anything more difficult for the people who are following them.

All this being said, we do not terribly mind keeping these patches internal, at least for sometime (by then maybe we will have a better solution). The main reason I wanted to upstream these is twofold: I heard that there are some other people who ran into this problem and were interested in a solution of this type and I thought this would be a good motivating example behind a new BMC side IPMI framework that we are working on as it would help to illustrate the desire to separate the hardware layer from the common routing layer as you had done with the host side; however, as long as you are aware that there may be other implementations, just possibly not in the mainline kernel, then I suppose that is not really an issue. I will try to send out an RFC for this framework tonight.

Quoted 17 lines

-corey

Quoted 14 lines

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.

Quoted 2 lines

Regardless of what we do with the "BT-I2C" stuff, I am still interested in what you think about this.

I think you are right, it probably belongs some place else. The way that makes the most sense to me would be to have an "ipmi" directory with a "host" and "slave" side, and since ipmi is not really a char driver, to move it to the main driver directory. That might be fairly disruptive, though.

The other option that makes sense to me would be to add a drivers/char/ipmi_slave directory, or something like that, and put the slave code there. That would be less disruptive.

-corey

Quoted 9 lines
Quoted 8 lines
Quoted 6 lines

I have tested this patchset on the Aspeed 2500 EVB.

Changes since previous update:
- Cleaned up some documentation.
- Added patch which moves the Aspeed BT-BMC driver to the new ipmi_bmc directory.

Thanks

--
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

#9 lore raw
Quoted 8 lines

Perhaps that is some level of abuse, but it's pretty common. I'm not against it.

There is standard IPMI firmware NetFN (though no commands defined) that if you use
the driver automatically goes into "Maintenance mode" and modified the timeouts
and handling to some extent to help with this.

That is a really good point, I missed that.
...

Quoted 13 lines

There are ways to accomplish this that aren't that complex. You can create an OEM
command that can query the maximum message size and the ability to do sequence
numbers in the messages.

If messages larger than 32-bytes are supported, and the host I2C/SMBus driver
supports it, you could use the standard SSIF SMBus commands to do this, they have an 8-bit length field.

Quoted 6 lines

If sequence numbers are supported, The SSIF could use different SMBus commands
to do the write and read requests. Since this is only if you get an OEM command,
and if you put the sequence numbers at the end where they are easy to add on the send side, this is a small change to the driver.

What if we just had an OEM command that changed the message structure from that point on? We could abuse the "maintenance mode" NetFN to get back into normal SSIF if necessary.

Quoted 7 lines

So I think the changes would be small and contained. I'm actually ok with a different driver, but I think it would be more valuable to the OpenBMC project
to have a standardized interface that would work (in a not quite as efficient
mode) with software that does not use the Linux IPMI driver.

I guess I see the all of my asks as hacky things which we can hopefully remove at some point. Hopefully, most OpenBMC users won't want or need these things.
...

Quoted 6 lines
Quoted 4 lines

Regardless of what we do with the "BT-I2C" stuff, I am still interested in what
you think about this.

Quoted 7 lines

I think you are right, it probably belongs some place else. The way that makes the most
sense to me would be to have an "ipmi" directory with a "host" and "slave" side, and since
ipmi is not really a char driver, to move it to the main driver directory. That might be
fairly disruptive, though.

That was my thinking exactly.

Quoted 5 lines

The other option that makes sense to me would be to add a drivers/char/ipmi_slave directory,
or something like that, and put the slave code there. That would be less disruptive.

Right that is the approach I took, except I called it drivers/char/ipmi_bmc.

I originally thought doing the less disruptive thing is best; however, I know there are also some OpenBMC people who are interested in implementing IPMB. So maybe now is the time to bite the bullet and create an ipmi directory under drivers/.

Quoted 2 lines

-corey

In summary, I think I can live with making it a mangled form of SSIF, but I would prefer to put it in its own driver.

In any case, I think I would rather focus on the the BMC side IPMI framework now, since it is a bigger change and would also reduce the work of implementing a BMC side SSIF driver.

Here is what I propose: we focus on the BMC side IPMI framework RFC that I sent out the other day:
https://www.mail-archive.com/[email protected]/msg1463473.html
I will add a change to the BMC side IPMI framework patchset to move all the IPMI stuff to the new drivers/ipmi directory as discussed and then drop the patch in that patchset that depends on this patchset.

Let me know what you think

#10 lore raw
Quoted 28 lines · Brendan Higgins
Quoted 8 lines

Perhaps that is some level of abuse, but it's pretty common. I'm not against it.

There is standard IPMI firmware NetFN (though no commands defined) that if you use
the driver automatically goes into "Maintenance mode" and modified the timeouts
and handling to some extent to help with this.

That is a really good point, I missed that.
...

Quoted 12 lines

There are ways to accomplish this that aren't that complex. You can create an OEM
command that can query the maximum message size and the ability to do sequence
numbers in the messages.

If messages larger than 32-bytes are supported, and the host I2C/SMBus driver
supports it, you could use the standard SSIF SMBus commands to do this, they have an 8-bit length field.

Quoted 6 lines

If sequence numbers are supported, The SSIF could use different SMBus commands
to do the write and read requests. Since this is only if you get an OEM command,
and if you put the sequence numbers at the end where they are easy to add on the send side, this is a small change to the driver.

Quoted 3 lines

What if we just had an OEM command that changed the message structure from that point on? We could abuse the "maintenance mode" NetFN to get back into normal SSIF if necessary.

Actually, I wouldn't have a separate "openbmc mode". I would have OpenBMC always work with standard SSIF, and have separate SMBus commands for messages with the sequence number and messages larger than 32 bytes.

I've attached a patch with what I would expect the changes to be to the host driver. It doesn't handle multiple outstanding messages, but it shows what detection and a separate SMBus command would look like.

Quoted 26 lines
Quoted 6 lines

So I think the changes would be small and contained. I'm actually ok with a different driver, but I think it would be more valuable to the OpenBMC project
to have a standardized interface that would work (in a not quite as efficient
mode) with software that does not use the Linux IPMI driver.

I guess I see the all of my asks as hacky things which we can hopefully remove at some point. Hopefully, most OpenBMC users won't want or need these things.
...

Quoted 11 lines
Quoted 3 lines

Regardless of what we do with the "BT-I2C" stuff, I am still interested in what
you think about this.

I think you are right, it probably belongs some place else. The way that makes the most
sense to me would be to have an "ipmi" directory with a "host" and "slave" side, and since
ipmi is not really a char driver, to move it to the main driver directory. That might be
fairly disruptive, though.

That was my thinking exactly.

Quoted 4 lines

The other option that makes sense to me would be to add a drivers/char/ipmi_slave directory,
or something like that, and put the slave code there. That would be less disruptive.

Quoted 6 lines

Right that is the approach I took, except I called it drivers/char/ipmi_bmc.

I originally thought doing the less disruptive thing is best; however, I know there are also some OpenBMC people who are interested in implementing IPMB. So maybe now is the time to bite the bullet and create an ipmi directory under drivers/.

I'm not sure IPMB would make much difference, there's no host side change as it's already supported. I don't think there would be any significant code sharing between the two.

If there end up being a significant amount of common code, then it would definitely be worth the effort to move it.

Quoted 3 lines
Quoted 1 line

-corey

In summary, I think I can live with making it a mangled form of SSIF, but I would prefer to put it in its own driver.

You can look at the patch and consider it, and consider that you would need to implement flag and event handling. On an x86 host there would be SMBIOS and ACPI stuff to deal with somehow for discovery. There's probably few other things to deal with.

Quoted 4 lines

In any case, I think I would rather focus on the the BMC side IPMI framework now, since it is a bigger change and would also reduce the work of implementing a BMC side SSIF driver.

Quoted 8 lines

Here is what I propose: we focus on the BMC side IPMI framework RFC that I sent out the other day:
https://www.mail-archive.com/[email protected]/msg1463473.html
I will add a change to the BMC side IPMI framework patchset to move all the IPMI stuff to the new drivers/ipmi directory as discussed and then drop the patch in that patchset that depends on this patchset.

Let me know what you think

Let's hold off on the new directory, there's probably some convincing of the "powers that be" for that.

I'll look at the patch set tomorrow, unless something critical comes up.

Thanks,

-corey

drivers/char/ipmi/ipmi_ssif.c +52 -7
index 11237e8..d467b1a 100644
@@ -60,6 +60,11 @@
 
 #define IPMI_GET_SYSTEM_INTERFACE_CAPABILITIES_CMD	0x57
 
+static u8 openbmc_iana[3] = { 0x10, 0x20, 0x30 };
+#define IPMI_OPENBMC_CAPABILITY_REQUEST_CMD	0x01
+#define SSIF_OPENBMC_REQUEST	0x80
+#define SSIF_OPENBMC_RESPONSE	0x81
+
 #define	SSIF_IPMI_REQUEST			2
 #define	SSIF_IPMI_MULTI_PART_REQUEST_START	6
 #define	SSIF_IPMI_MULTI_PART_REQUEST_MIDDLE	7
@@ -224,6 +229,12 @@ struct ssif_info {
 	bool		    supports_alert;
 
 	/*
+	 * OpenBMC mode, with large message and sequence number
+	 * support.  An int because we use it as a number, too.
+	 */
+	unsigned int	    is_openbmc;
+
+	/*
 	 * Used to tell what we should do with alerts.  If we are
 	 * waiting on a response, read the data immediately.
 	 */
@@ -537,12 +548,13 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result,
 static void start_get(struct ssif_info *ssif_info)
 {
 	int rv;
+	int command = ssif_info->is_openbmc ? SSIF_OPENBMC_RESPONSE :
+			SSIF_IPMI_RESPONSE;
 
 	ssif_info->rtc_us_timer = 0;
 	ssif_info->multi_pos = 0;
 
-	rv = ssif_i2c_send(ssif_info, msg_done_handler, I2C_SMBUS_READ,
-			  SSIF_IPMI_RESPONSE,
+	rv = ssif_i2c_send(ssif_info, msg_done_handler, I2C_SMBUS_READ, command,
 			  ssif_info->recv, I2C_SMBUS_BLOCK_DATA);
 	if (rv < 0) {
 		/* request failed, just return the error. */
@@ -611,7 +623,8 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result,
 	 * start messing with driver states or the queues.
 	 */
 
-	if (result < 0) {
+	if (result < 0 || len < 3) {
+	ignore_msg:
 		ssif_info->retries_left--;
 		if (ssif_info->retries_left > 0) {
 			ssif_inc_stat(ssif_info, receive_retries);
@@ -633,7 +646,13 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result,
 		goto continue_op;
 	}
 
-	if ((len > 1) && (ssif_info->multi_pos == 0)
+	if (ssif_info->is_openbmc) {
+		if (len < 4)
+			goto ignore_msg;
+		/* Eventually extract sequence number from data[0]. */
+		data++;
+		len--;
+	} else if ((len > 1) && (ssif_info->multi_pos == 0)
 				&& (data[0] == 0x00) && (data[1] == 0x01)) {
 		/* Start of multi-part read.  Start the next transaction. */
 		int i;
@@ -966,7 +985,11 @@ static int start_resend(struct ssif_info *ssif_info)
 
 	ssif_info->got_alert = false;
 
-	if (ssif_info->data_len > 32) {
+	if (ssif_info->is_openbmc) {
+		ssif_info->multi_data = NULL;
+		command = SSIF_OPENBMC_REQUEST;
+		ssif_info->data[0] = ssif_info->data_len;
+	} else if (ssif_info->data_len > 32) {
 		command = SSIF_IPMI_MULTI_PART_REQUEST_START;
 		ssif_info->multi_data = ssif_info->data;
 		ssif_info->multi_len = ssif_info->data_len;
@@ -1000,7 +1023,11 @@ static int start_send(struct ssif_info *ssif_info,
 		return -E2BIG;
 
 	ssif_info->retries_left = SSIF_SEND_RETRIES;
-	memcpy(ssif_info->data + 1, data, len);
+	memcpy(ssif_info->data + 1 + ssif_info->is_openbmc, data, len);
+	if (ssif_info->is_openbmc) {
+		ssif_info->data[1] = 0; /* Sequence number eventually. */
+		len++;
+	}
 	ssif_info->data_len = len;
 	return start_resend(ssif_info);
 }
@@ -1507,7 +1534,7 @@ static struct ipmi_fw_revision_range ssif_broken_alert_bmcs[] = {
 
 static int ssif_probe(struct i2c_client *client, const struct i2c_device_id *id)
 {
-	unsigned char     msg[3];
+	unsigned char     msg[6];
 	unsigned char     *resp;
 	struct ssif_info   *ssif_info;
 	int               rv = 0;
@@ -1643,6 +1670,24 @@ static int ssif_probe(struct i2c_client *client, const struct i2c_device_id *id)
 		ssif_info->supports_pec = 0;
 	}
 
+	msg[0] = IPMI_NETFN_OEM_GROUP_REQUEST << 2;
+	msg[1] = IPMI_OPENBMC_CAPABILITY_REQUEST_CMD;
+	memcpy(msg, openbmc_iana, sizeof(openbmc_iana));
+	rv = do_cmd(client, 5, msg, &len, resp);
+	if (!rv && (len >= 3) && (resp[2] == 0)) {
+		/* It appears we have an OpenBMC device. */
+
+		/* Turn of multi support. */
+		ssif_info->multi_support = SSIF_NO_MULTI;
+		ssif_info->max_xmit_msg_size = 32;
+		ssif_info->max_recv_msg_size = 32;
+		if (len > 3)
+			ssif_info->max_xmit_msg_size = resp[3];
+		if (len > 4)
+			ssif_info->max_recv_msg_size = resp[4];
+		ssif_info->is_openbmc = 1;
+	}
+
 	/* Make sure the NMI timeout is cleared. */
 	msg[0] = IPMI_NETFN_APP_REQUEST << 2;
 	msg[1] = IPMI_CLEAR_MSG_FLAGS_CMD;
include/uapi/linux/ipmi_msgdefs.h +3 -0
index df97e6e..bb0af2e 100644
@@ -71,6 +71,9 @@
 #define IPMI_NETFN_FIRMWARE_REQUEST		0x08
 #define IPMI_NETFN_FIRMWARE_RESPONSE		0x09
 
+#define IPMI_NETFN_OEM_GROUP_REQUEST		0x2e
+#define IPMI_NETFN_OEM_GROUP_RESPONSE		0x2f
+
 /* The default slave address */
 #define IPMI_BMC_SLAVE_ADDR	0x20
 
#11 lore raw
Quoted 48 lines · Corey Minyard
Quoted 36 lines · Brendan Higgins
Quoted 10 lines

Perhaps that is some level of abuse, but it's pretty common. I'm not against it.

There is standard IPMI firmware NetFN (though no commands defined) that if
you use
the driver automatically goes into "Maintenance mode" and modified the timeouts
and handling to some extent to help with this.

That is a really good point, I missed that.
...

Quoted 15 lines

There are ways to accomplish this that aren't that complex. You can create
an OEM
command that can query the maximum message size and the ability to do sequence
numbers in the messages.

If messages larger than 32-bytes are supported, and the host I2C/SMBus driver
supports it, you could use the standard SSIF SMBus commands to do this, they
have an 8-bit length field.

Quoted 7 lines

If sequence numbers are supported, The SSIF could use different SMBus commands
to do the write and read requests. Since this is only if you get an OEM command,
and if you put the sequence numbers at the end where they are easy to add on
the send side, this is a small change to the driver.

Quoted 4 lines

What if we just had an OEM command that changed the message structure from that point on? We could abuse the "maintenance mode" NetFN to get back into
normal SSIF if necessary.

Actually, I wouldn't have a separate "openbmc mode". I would have OpenBMC always
work with standard SSIF, and have separate SMBus commands for messages with the sequence number and messages larger than 32 bytes.

Quoted 5 lines

I've attached a patch with what I would expect the changes to be to the host driver.
It doesn't handle multiple outstanding messages, but it shows what detection and a
separate SMBus command would look like.

I took a look at the patch, it seems reasonable. If I was maintaining SSIF, I probably
would not want that kind of clutter for my admittedly weird use case, but if you're
okay with it, then so am I.

Quoted 49 lines
Quoted 39 lines
Quoted 9 lines

So I think the changes would be small and contained. I'm actually ok with a
different driver, but I think it would be more valuable to the OpenBMC project
to have a standardized interface that would work (in a not quite as efficient
mode) with software that does not use the Linux IPMI driver.

I guess I see the all of my asks as hacky things which we can hopefully remove
at some point. Hopefully, most OpenBMC users won't want or need these things.
...

Quoted 7 lines
Quoted 5 lines

Regardless of what we do with the "BT-I2C" stuff, I am still interested in
what
you think about this.

Quoted 9 lines

I think you are right, it probably belongs some place else. The way that makes the most
sense to me would be to have an "ipmi" directory with a "host" and "slave"
side, and since
ipmi is not really a char driver, to move it to the main driver directory.
That might be
fairly disruptive, though.

That was my thinking exactly.

Quoted 4 lines

The other option that makes sense to me would be to add a drivers/char/ipmi_slave directory,
or something like that, and put the slave code there. That would be less disruptive.

Quoted 8 lines

Right that is the approach I took, except I called it drivers/char/ipmi_bmc.

I originally thought doing the less disruptive thing is best; however, I know
there are also some OpenBMC people who are interested in implementing IPMB. So maybe now is the time to bite the bullet and create an ipmi directory under drivers/.

Quoted 5 lines

I'm not sure IPMB would make much difference, there's no host side change as it's
already supported. I don't think there would be any significant code sharing
between the two.

No, I don't expect much code sharing between them. I just thought it would be a reasonable place to put IPMB, sort of like how we have a bunch of "character" device drivers in drivers/char, but I suppose that might be somewhat of an anti-pattern ;-)

Quoted 31 lines

If there end up being a significant amount of common code, then it would definitely be worth the effort to move it.

Quoted 4 lines
Quoted 1 line

-corey

In summary, I think I can live with making it a mangled form of SSIF, but I would prefer to put it in its own driver.

You can look at the patch and consider it, and consider that you would need to
implement flag and event handling. On an x86 host there would be SMBIOS and ACPI stuff to deal with somehow for discovery. There's probably few other
things to deal with.

Quoted 14 lines

In any case, I think I would rather focus on the the BMC side IPMI framework
now, since it is a bigger change and would also reduce the work of implementing a BMC side SSIF driver.

Here is what I propose: we focus on the BMC side IPMI framework RFC that I sent out the other day:
https://www.mail-archive.com/[email protected]/msg1463473.html
I will add a change to the BMC side IPMI framework patchset to move all the
IPMI stuff to the new drivers/ipmi directory as discussed and then drop the
patch in that patchset that depends on this patchset.

Quoted 8 lines
Quoted 1 line

Let me know what you think

Let's hold off on the new directory, there's probably some convincing of the "powers
that be" for that.

I'll look at the patch set tomorrow, unless something critical comes up.

Sounds good

Quoted 5 lines

Thanks,

-corey

Cheers

maintainer
#2 lore raw

Re: [PATCH v2 1/4] ipmi: bt-i2c: added documentation for bt-i2c drivers

In reply to Brendan Higgins
Quoted 3 lines · Brendan Higgins

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.

Please split the bindings to a separate patch.

Quoted 25 lines

---
Changes for v2:
- Fixed a typo
- Reworded a sentence to make it clear that I was talking about IBM's BT-BMC
- Deleted an unnecessary discussion of the host side interface (unnecessary since the OpenIPMI stuff already has its own documentation).

---
 Documentation/bt-i2c.txt                           | 109 +++++++++++++++++++++
 .../devicetree/bindings/ipmi/ipmi-bt-i2c.txt       |  21 ++++
 .../bindings/ipmi_bmc/ipmi-bmc-bt-i2c.txt          |  21 ++++
 3 files changed, 151 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/devicetree/bindings/ipmi/ipmi-bt-i2c.txt new file +1 -0
new file mode 100644
index 000000000000..bd956f2805e4
@@ -0,0 +1,21 @@
+Device tree configuration for the ipmi-bt-i2c driver.

Documentation/devicetree/bindings/ipmi/ipmi-bt-i2c.txt line 11

Quoted 10 lines
Documentation/devicetree/bindings/ipmi/ipmi-bt-i2c.txt new file +10 -0
+
+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";

This is the host side, right? So this should be something besides an ASpeed I2C controller.

Documentation/devicetree/bindings/ipmi/ipmi-bt-i2c.txt line 13

Quoted 2 lines
Documentation/devicetree/bindings/ipmi/ipmi-bt-i2c.txt new file +2 -0
+	clock-frequency = <100000>;
+	status = "disabled";

Don't should status in examples.

Documentation/devicetree/bindings/ipmi/ipmi-bt-i2c.txt line 17

Quoted 4 lines
Documentation/devicetree/bindings/ipmi/ipmi-bt-i2c.txt new file +4 -0
+	interrupts = <0>;
+	interrupt-parent = <&i2c>;
+
+	bt-i2c-master@41 {

But it's the slave device you are describing here, right? The host is the master. Just "ipmi-bt" is probably enough.

Quoted 19 lines
Documentation/devicetree/bindings/ipmi/ipmi-bt-i2c.txt new file +4 -0
+		compatible = "ipmi-bt-i2c";
+		reg = <0x41>;
+	};
+};
Documentation/devicetree/bindings/ipmi_bmc/ipmi-bmc-bt-i2c.txt new file +9 -0
new file mode 100644
index 000000000000..6e82693ee50e
@@ -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>;

Documentation/devicetree/bindings/ipmi_bmc/ipmi-bmc-bt-i2c.txt line 19

Quoted 10 lines
Documentation/devicetree/bindings/ipmi_bmc/ipmi-bmc-bt-i2c.txt new file +10 -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>;

This doesn't follow the slave binding which sets bit 30 for slave devices.

Quoted 5 lines
Documentation/devicetree/bindings/ipmi_bmc/ipmi-bmc-bt-i2c.txt new file +2 -0
+	};
+};
Signature · 1 line
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