Skip to contentSkip to conversation

IPMI: per-channel command registration

PATCH In review Corey Minyard 2 participants 3 messages Sep 25, 2006 – Sep 27, 2006

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

PATCH 1/1 IPMI: per-channel command registration

This patch adds the ability to register for a command per-channel in the IPMI driver.

If your BMC supports multiple channels, incoming messages can be differentiated by the channel on which they arrived. In this case it's useful to have the ability to register to receive commands on a specific channel instead the current behaviour of all channels.

drivers/char/ipmi/ipmi_devintf.c +32 -2
Index: linux-2.6.18/drivers/char/ipmi/ipmi_devintf.c
===================================================================
@@ -377,7 +377,8 @@ static int ipmi_ioctl(struct inode  *ino
 			break;
 		}
 
-		rv = ipmi_register_for_cmd(priv->user, val.netfn, val.cmd);
+		rv = ipmi_register_for_cmd(priv->user, val.netfn, val.cmd,
+					   IPMI_CHAN_ALL);
 		break;
 	}
 
@@ -390,7 +391,36 @@ static int ipmi_ioctl(struct inode  *ino
 			break;
 		}
 
-		rv = ipmi_unregister_for_cmd(priv->user, val.netfn, val.cmd);
+		rv = ipmi_unregister_for_cmd(priv->user, val.netfn, val.cmd,
+					     IPMI_CHAN_ALL);
+		break;
+	}
+
+	case IPMICTL_REGISTER_FOR_CMD_CHANS:
+	{
+		struct ipmi_cmdspec_chans val;
+
+		if (copy_from_user(&val, arg, sizeof(val))) {
+			rv = -EFAULT;
+			break;
+		}
+
+		rv = ipmi_register_for_cmd(priv->user, val.netfn, val.cmd,
+					   val.chans);
+		break;
+	}
+
+	case IPMICTL_UNREGISTER_FOR_CMD_CHANS:
+	{
+		struct ipmi_cmdspec_chans val;
+
+		if (copy_from_user(&val, arg, sizeof(val))) {
+			rv = -EFAULT;
+			break;
+		}
+
+		rv = ipmi_unregister_for_cmd(priv->user, val.netfn, val.cmd,
+					     val.chans);
 		break;
 	}
 
drivers/char/ipmi/ipmi_msghandler.c +56 -19

152 lines not on this page · raw message

include/linux/ipmi.h +44 -4

74 lines not on this page · raw message

Documentation/IPMI.txt +6 -3
Index: linux-2.6.18/Documentation/IPMI.txt
===================================================================
@@ -326,9 +326,12 @@ for events, they will all receive all ev
 
 For receiving commands, you have to individually register commands you
 want to receive.  Call ipmi_register_for_cmd() and supply the netfn
-and command name for each command you want to receive.  Only one user
-may be registered for each netfn/cmd, but different users may register
-for different commands.
+and command name for each command you want to receive.  You also
+specify a bitmask of the channels you want to receive the command from
+(or use IPMI_CHAN_ALL for all channels if you don't care).  Only one
+user may be registered for each netfn/cmd/channel, but different users
+may register for different commands, or the same command if the
+channel bitmasks do not overlap.
 
 From userland, equivalent IOCTLs are provided to do these functions.
 
#1 lore raw
Quoted 9 lines · On Mon, 25 Sep 2006 09:09:41 -0500 Corey Minyard <[email protected]> wrote:

This patch adds the ability to register for a command per-channel in the IPMI driver.

If your BMC supports multiple channels, incoming messages can be differentiated by the channel on which they arrived. In this case it's useful to have the ability to register to receive commands on a specific channel instead the current behaviour of all channels.

drivers/char/ipmi/ipmi_devintf.c static int ipmi_ioctl(struct inode *ino · line 403

Quoted 5 lines
drivers/char/ipmi/ipmi_devintf.c +5 -0
+	case IPMICTL_REGISTER_FOR_CMD_CHANS:
+	{
+		struct ipmi_cmdspec_chans val;
+
+		if (copy_from_user(&val, arg, sizeof(val))) {

It becomes part of the ABI.

include/linux/ipmi.h struct ipmi_cmdspec · line 596

Quoted 13 lines
include/linux/ipmi.h +13 -0
+/*
+ * Register to get commands from other entities on specific channels.
+ * This way, you can only listen on specific channels, or have messages
+ * from some channels go to one place and other channels to someplace
+ * else.  The chans field is a bitmask, (1 << channel) for each channel.
+ * It may be IPMI_CHAN_ALL for all channels.
+ */
+struct ipmi_cmdspec_chans
+{
+	unsigned char netfn;
+	unsigned char cmd;
+	unsigned int  chans;
+};

Has it been tested with 32-bit userspace and a 64-bit kernel?

Even if it has, I'd be a bit worried that it depends upon the user's compiler laying this structure out in the same manner as did his kernel-provider's compiler.

Turning this into three u32's sounds safer?

#2 lore raw
Quoted 8 lines · Andrew Morton

Review

Quoted 6 lines
(quoted diff) +6 -0
+struct ipmi_cmdspec_chans
+{
+	unsigned char netfn;
+	unsigned char cmd;
+	unsigned int  chans;
+};

Has it been tested with 32-bit userspace and a 64-bit kernel?

I'll try to do that sometime soon, when I can get access to a 64-bit machine with IPMI.

Quoted 6 lines

Even if it has, I'd be a bit worried that it depends upon the user's compiler laying this structure out in the same manner as did his kernel-provider's compiler.

Turning this into three u32's sounds safer?

Yes, it does. Here's another pass (or you can change the "chars" to "ints" in that structure). Thanks.

-Corey

This patch adds the ability to register for a command per-channel in the IPMI driver.

If your BMC supports multiple channels, incoming messages can be differentiated by the channel on which they arrived. In this case it's useful to have the ability to register to receive commands on a specific channel instead the current behaviour of all channels.

drivers/char/ipmi/ipmi_devintf.c +32 -2
Index: linux-2.6.18/drivers/char/ipmi/ipmi_devintf.c
===================================================================
@@ -377,7 +377,8 @@ static int ipmi_ioctl(struct inode  *ino
 			break;
 		}
 
-		rv = ipmi_register_for_cmd(priv->user, val.netfn, val.cmd);
+		rv = ipmi_register_for_cmd(priv->user, val.netfn, val.cmd,
+					   IPMI_CHAN_ALL);
 		break;
 	}
 
@@ -390,7 +391,36 @@ static int ipmi_ioctl(struct inode  *ino
 			break;
 		}
 
-		rv = ipmi_unregister_for_cmd(priv->user, val.netfn, val.cmd);
+		rv = ipmi_unregister_for_cmd(priv->user, val.netfn, val.cmd,
+					     IPMI_CHAN_ALL);
+		break;
+	}
+
+	case IPMICTL_REGISTER_FOR_CMD_CHANS:
+	{
+		struct ipmi_cmdspec_chans val;
+
+		if (copy_from_user(&val, arg, sizeof(val))) {
+			rv = -EFAULT;
+			break;
+		}
+
+		rv = ipmi_register_for_cmd(priv->user, val.netfn, val.cmd,
+					   val.chans);
+		break;
+	}
+
+	case IPMICTL_UNREGISTER_FOR_CMD_CHANS:
+	{
+		struct ipmi_cmdspec_chans val;
+
+		if (copy_from_user(&val, arg, sizeof(val))) {
+			rv = -EFAULT;
+			break;
+		}
+
+		rv = ipmi_unregister_for_cmd(priv->user, val.netfn, val.cmd,
+					     val.chans);
 		break;
 	}
 
drivers/char/ipmi/ipmi_msghandler.c +56 -19

152 lines not on this page · raw message

include/linux/ipmi.h +44 -4

74 lines not on this page · raw message

Documentation/IPMI.txt +6 -3
Index: linux-2.6.18/Documentation/IPMI.txt
===================================================================
@@ -326,9 +326,12 @@ for events, they will all receive all ev
 
 For receiving commands, you have to individually register commands you
 want to receive.  Call ipmi_register_for_cmd() and supply the netfn
-and command name for each command you want to receive.  Only one user
-may be registered for each netfn/cmd, but different users may register
-for different commands.
+and command name for each command you want to receive.  You also
+specify a bitmask of the channels you want to receive the command from
+(or use IPMI_CHAN_ALL for all channels if you don't care).  Only one
+user may be registered for each netfn/cmd/channel, but different users
+may register for different commands, or the same command if the
+channel bitmasks do not overlap.
 
 From userland, equivalent IOCTLs are provided to do these functions.