linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kamlakant Patel <kamlakant.patel@cavium.com>
To: Corey Minyard <minyard@acm.org>, Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Kamlakant Patel <kamlakant.patel@cavium.com>,
	openipmi-developer@lists.sourceforge.net,
	linux-kernel@vger.kernel.org,
	George Cherian <george.cherian@cavium.com>,
	jayachandran.nair@cavium.com
Subject: [PATCH v3] ipmi: update ssif max_xmit_msg_size limit for multi-part messages
Date: Mon, 30 Jul 2018 16:21:08 +0530	[thread overview]
Message-ID: <1532947868-21907-1-git-send-email-kamlakant.patel@cavium.com> (raw)

Currently, by setting the xmit_msg_size to 63, the ssif driver never
does a SSIF_MULTI_n_PART, it falls back to only SSIF_MULTI_2_PART.
Due to this all IPMI commands with request size more than 63 bytes
will not work.

As per IPMI spec 2.0 (section 12.15, Table 10), SSIF supports message
length up to 255 bytes. In a multi-part message, the first part must
carry 32 bytes with command 06h. All intermediate ("middle") parts must
carry 32 bytes with command 07h and the number of message data bytes in
the End transaction can range from 1 to 32 bytes with command 08h.

Update ssif max_xmit_msg_size to handle multi-part messages up
to 255 bytes.
Enable command(08h) for End part transaction.

Signed-off-by: Kamlakant Patel <kamlakant.patel@cavium.com>
Suggested-by: Robert Richter <robert.richter@cavium.com>
Reported-by: Karthikeyan M <karthikeyanm@amiindia.co.in>
---
 drivers/char/ipmi/ipmi_ssif.c | 38 +++++++++++++++++++++++++++-----------
 1 file changed, 27 insertions(+), 11 deletions(-)

diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c
index 18e4650..ada59b7 100644
--- a/drivers/char/ipmi/ipmi_ssif.c
+++ b/drivers/char/ipmi/ipmi_ssif.c
@@ -60,6 +60,7 @@
 #define	SSIF_IPMI_REQUEST			2
 #define	SSIF_IPMI_MULTI_PART_REQUEST_START	6
 #define	SSIF_IPMI_MULTI_PART_REQUEST_MIDDLE	7
+#define	SSIF_IPMI_MULTI_PART_REQUEST_END	8
 #define	SSIF_IPMI_RESPONSE			3
 #define	SSIF_IPMI_MULTI_PART_RESPONSE_MIDDLE	9
 
@@ -88,6 +89,8 @@
 #define SSIF_MSG_JIFFIES	((SSIF_MSG_USEC * 1000) / TICK_NSEC)
 #define SSIF_MSG_PART_JIFFIES	((SSIF_MSG_PART_USEC * 1000) / TICK_NSEC)
 
+#define SSIF_MAX_MSG_LENGTH	255
+
 enum ssif_intf_state {
 	SSIF_NORMAL,
 	SSIF_GETTING_FLAGS,
@@ -887,28 +890,39 @@ static void msg_written_handler(struct ssif_info *ssif_info, int result,
 		 */
 		int left;
 		unsigned char *data_to_send;
+		int command;
 
 		ssif_inc_stat(ssif_info, sent_messages_parts);
 
 		left = ssif_info->multi_len - ssif_info->multi_pos;
-		if (left > 32)
-			left = 32;
+
 		/* Length byte. */
-		ssif_info->multi_data[ssif_info->multi_pos] = left;
+		ssif_info->multi_data[ssif_info->multi_pos] =
+						left > 32 ? 32 : left;
 		data_to_send = ssif_info->multi_data + ssif_info->multi_pos;
-		ssif_info->multi_pos += left;
-		if (left < 32)
+		ssif_info->multi_pos += left > 32 ? 32 : left;
+		command = SSIF_IPMI_MULTI_PART_REQUEST_MIDDLE;
+		if (left <= 32) {
 			/*
 			 * Write is finished.  Note that we must end
-			 * with a write of less than 32 bytes to
-			 * complete the transaction, even if it is
-			 * zero bytes.
+			 * with a write up to 32 bytes to complete the
+			 * transaction, even if it is zero bytes.
+			 * The number of message data bytes in the End
+			 * transaction can range from 1 to 32 bytes.
+			 * As per IPMI spec 2.0(section 12.15,Table 12-10),
+			 * the BMC Multi-part Write commands are:
+			 * Start-first part	- 06h
+			 * Middle-part(s)	- 07h
+			 * End-part		- 08h
+			 * Update command for END part transaction.
 			 */
 			ssif_info->multi_data = NULL;
+			command = SSIF_IPMI_MULTI_PART_REQUEST_END;
+		}
 
 		rv = ssif_i2c_send(ssif_info, msg_written_handler,
 				  I2C_SMBUS_WRITE,
-				  SSIF_IPMI_MULTI_PART_REQUEST_MIDDLE,
+				  command,
 				  data_to_send,
 				  I2C_SMBUS_BLOCK_DATA);
 		if (rv < 0) {
@@ -1499,9 +1513,11 @@ static int ssif_probe(struct i2c_client *client, const struct i2c_device_id *id)
 			 * start and the next message is always going
 			 * to be 1-31 bytes in length.  Not ideal, but
 			 * it should work.
+			 * As per IPMI spec 2.0, SSIF interface supports
+			 * message size up to 255 bytes.
 			 */
-			if (ssif_info->max_xmit_msg_size > 63)
-				ssif_info->max_xmit_msg_size = 63;
+			if (ssif_info->max_xmit_msg_size > SSIF_MAX_MSG_LENGTH)
+				ssif_info->max_xmit_msg_size = SSIF_MAX_MSG_LENGTH;
 			break;
 
 		default:
-- 
2.7.4


             reply	other threads:[~2018-07-30 10:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-30 10:51 Kamlakant Patel [this message]
2018-07-30 12:56 ` [PATCH v3] ipmi: update ssif max_xmit_msg_size limit for multi-part messages Corey Minyard
2018-07-31  7:37   ` Kamlakant Patel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1532947868-21907-1-git-send-email-kamlakant.patel@cavium.com \
    --to=kamlakant.patel@cavium.com \
    --cc=arnd@arndb.de \
    --cc=george.cherian@cavium.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jayachandran.nair@cavium.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=minyard@acm.org \
    --cc=openipmi-developer@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).