Skip to contentSkip to conversation

libata: add enclosure management support

PATCH In review Kristen Carlson Accardi 3 participants 14 messages Jan 16, 2008 – Jan 21, 2008

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

PATCH 1/1 libata: add enclosure management support

Add Enclosure Management support to libata and ahci.

This patch adds support for the LED protocol, as defined in the AHCI spec. It adds a generic em_message and em_type sysfs entry per host. It also adds a sw_activity field per existing drive.

The em_message field can be used by the driver to take enclosure management commands from userspace. In the case of the LED protocol, writes and reads from em_message correspond to the LED message format as defined in the AHCI spec.

em_message type is a read only file that displays the current enclosure management protocol that is used by the driver.

sw_activity is used by drivers which support software controlled activity LEDs. It has the following valid values:

0 OFF - the LED is not activated on activity
1 BLINK_ON - the LED blinks on every 10ms when activity is detected.
2 BLINK_OFF - the LED is on when idle, and blinks off every 10ms when
activity is detected.

It's important to note that the user must turn sw_activity OFF it they wish to control the activity LED via the em_message file.

---
I'm concerned about my locking, cause I usually suck at figuring out when I need it. If you could review that really carefully, I'd appreciate it. Thanks!

 drivers/ata/ahci.c        |  321 +++++++++++++++++++++++++++++++++++++++++++++-
 drivers/ata/libata-scsi.c |   77 +++++++++++
 include/linux/libata.h    |   22 +++
 3 files changed, 418 insertions(+), 2 deletions(-)
drivers/ata/ahci.c +319 -2
Index: linux-2.6/drivers/ata/ahci.c
===================================================================
@@ -52,6 +52,12 @@
 static int ahci_enable_alpm(struct ata_port *ap,
 		enum link_pm policy);
 static void ahci_disable_alpm(struct ata_port *ap);
+static ssize_t ahci_led_show(struct ata_port *ap, char *buf);
+static ssize_t ahci_led_store(struct ata_port *ap, const char *buf,
+			      size_t size);
+static ssize_t ahci_transmit_led_message(struct ata_port *ap, u32 state,
+					ssize_t size);
+#define MAX_SLOTS 8
 
 enum {
 	AHCI_PCI_BAR		= 5,
@@ -92,6 +98,8 @@ enum {
 	HOST_IRQ_STAT		= 0x08, /* interrupt status */
 	HOST_PORTS_IMPL		= 0x0c, /* bitmap of implemented ports */
 	HOST_VERSION		= 0x10, /* AHCI spec. version compliancy */
+	HOST_EM_LOC		= 0x1c, /* Enclosure Management location */
+	HOST_EM_CTL		= 0x20, /* Enclosure Management Control */
 
 	/* HOST_CTL bits */
 	HOST_RESET		= (1 << 0),  /* reset controller; self-clear */
@@ -99,6 +107,7 @@ enum {
 	HOST_AHCI_EN		= (1 << 31), /* AHCI enabled */
 
 	/* HOST_CAP bits */
+	HOST_CAP_EMS		= (1 << 6),  /* Enclosure Management support */
 	HOST_CAP_SSC		= (1 << 14), /* Slumber capable */
 	HOST_CAP_PMP		= (1 << 17), /* Port Multiplier support */
 	HOST_CAP_CLO		= (1 << 24), /* Command List Override support */
@@ -195,6 +204,11 @@ enum {
 	AHCI_LFLAG_COMMON		= ATA_LFLAG_SKIP_D2H_BSY,
 
 	ICH_MAP				= 0x90, /* ICH MAP register */
+
+	/* em_ctl bits */
+	EM_CTL_RST			= (1 << 9), /* Reset */
+	EM_CTL_TM			= (1 << 8), /* Transmit Message */
+	EM_CTL_ALHD			= (1 << 26), /* Activity LED */
 };
 
 struct ahci_cmd_hdr {
@@ -212,12 +226,21 @@ struct ahci_sg {
 	u32			flags_size;
 };
 
+struct ahci_em_priv {
+	enum sw_activity blink_policy;
+	struct timer_list timer;
+	unsigned long saved_activity;
+	unsigned long activity;
+	unsigned long led_state;
+};
+
 struct ahci_host_priv {
 	unsigned int		flags;		/* AHCI_HFLAG_* */
 	u32			cap;		/* cap to use */
 	u32			port_map;	/* port map to use */
 	u32			saved_cap;	/* saved initial cap */
 	u32			saved_port_map;	/* saved initial port_map */
+	u32 			em_loc; /* enclosure management location */
 };
 
 struct ahci_port_priv {
@@ -233,6 +256,8 @@ struct ahci_port_priv {
 	unsigned int		ncq_saw_dmas:1;
 	unsigned int		ncq_saw_sdb:1;
 	u32 			intr_mask;	/* interrupts to enable */
+	struct ahci_em_priv	em_priv[MAX_SLOTS];/* enclosure management info
+					 	 * per PM slot */
 };
 
 static int ahci_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val);
@@ -262,9 +287,20 @@ static int ahci_port_suspend(struct ata_
 static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg);
 static int ahci_pci_device_resume(struct pci_dev *pdev);
 #endif
+static ssize_t ahci_activity_show(struct ata_device *dev, char *buf);
+static ssize_t ahci_activity_store(struct ata_device *dev,
+				   enum sw_activity val);
+static void ahci_init_sw_activity(struct ata_link *link);
 
 static struct class_device_attribute *ahci_shost_attrs[] = {
 	&class_device_attr_link_power_management_policy,
+	&class_device_attr_em_message_type,
+	&class_device_attr_em_message,
+	NULL
+};
+
+static struct device_attribute *ahci_sdev_attrs[] = {
+	&dev_attr_sw_activity,
 	NULL
 };
 
@@ -286,6 +322,7 @@ static struct scsi_host_template ahci_sh
 	.slave_destroy		= ata_scsi_slave_destroy,
 	.bios_param		= ata_std_bios_param,
 	.shost_attrs		= ahci_shost_attrs,
+	.sdev_attrs		= ahci_sdev_attrs,
 };
 
 static const struct ata_port_operations ahci_ops = {
@@ -320,6 +357,11 @@ static const struct ata_port_operations 
 	.enable_pm		= ahci_enable_alpm,
 	.disable_pm		= ahci_disable_alpm,
 
+	.em_show		= ahci_led_show,
+	.em_store		= ahci_led_store,
+	.sw_activity_show	= ahci_activity_show,
+	.sw_activity_store	= ahci_activity_store,
+
 	.port_start		= ahci_port_start,
 	.port_stop		= ahci_port_stop,
 };
@@ -578,6 +620,11 @@ static struct pci_driver ahci_pci_driver
 #endif
 };
 
+static int ahci_em_messages = 1;
+module_param(ahci_em_messages, int, 0444);
+/* add other LED protocol types when they become supported */
+MODULE_PARM_DESC(ahci_em_messages,
+	"Set AHCI Enclosure Management Message type (0 = disabled, 1 = LED");
 
 static inline int ahci_nr_ports(u32 cap)
 {
@@ -1005,11 +1052,28 @@ static void ahci_power_down(struct ata_p
 
 static void ahci_start_port(struct ata_port *ap)
 {
+	struct ahci_port_priv *pp = ap->private_data;
+	struct ata_link *link;
+	struct ahci_em_priv *emp;
+
 	/* enable FIS reception */
 	ahci_start_fis_rx(ap);
 
 	/* enable DMA */
 	ahci_start_engine(ap);
+
+	/* turn on LEDs */
+	if (ap->flags & ATA_FLAG_EM) {
+		ata_port_for_each_link(link, ap) {
+			emp = &pp->em_priv[link->pmp];
+			ahci_transmit_led_message(ap, emp->led_state, 4);
+		}
+	}
+
+	if (ap->flags & ATA_FLAG_SW_ACTIVITY)
+		ata_port_for_each_link(link, ap)
+			ahci_init_sw_activity(link);
+
 }
 
 static int ahci_deinit_port(struct ata_port *ap, const char **emsg)
@@ -1085,6 +1149,230 @@ static int ahci_reset_controller(struct 
 	return 0;
 }
 
+static void ahci_sw_activity(struct ata_link *link)
+{
+	struct ata_port *ap = link->ap;
+	struct ahci_port_priv *pp = ap->private_data;
+	struct ahci_em_priv *emp = &pp->em_priv[link->pmp];
+
+	if (!(link->flags & ATA_LFLAG_SW_ACTIVITY))
+		return;
+
+	emp->activity++;
+	if (!timer_pending(&emp->timer))
+		mod_timer(&emp->timer, jiffies + msecs_to_jiffies(10));
+}
+
+static void ahci_sw_activity_blink(unsigned long arg)
+{
+	struct ata_link *link = (struct ata_link *)arg;
+	struct ata_port *ap = link->ap;
+	struct ahci_port_priv *pp = ap->private_data;
+	struct ahci_em_priv *emp = &pp->em_priv[link->pmp];
+	unsigned long led_message = emp->led_state;
+	u32 activity_led_state;
+
+	led_message &= 0xffff0000;
+	led_message |= ap->port_no | (link->pmp << 8);
+
+	/* check to see if we've had activity.  If so,
+	 * toggle state of LED and reset timer.  If not,
+	 * turn LED to desired idle state.
+	 */
+	if (emp->saved_activity != emp->activity) {
+		emp->saved_activity = emp->activity;
+		/* get the current LED state */
+		activity_led_state = led_message & 0x00010000;
+
+		if (activity_led_state)
+			activity_led_state = 0;
+		else
+			activity_led_state = 1;
+
+		/* clear old state */
+		led_message &= 0xfff8ffff;
+
+		/* toggle state */
+		led_message |= (activity_led_state << 16);
+		mod_timer(&emp->timer, jiffies + msecs_to_jiffies(100));
+	} else {
+		/* switch to idle */
+		led_message &= 0xfff8ffff;
+		if (emp->blink_policy == BLINK_OFF)
+			led_message |= (1 << 16);
+	}
+	ahci_transmit_led_message(ap, led_message, 4);
+}
+
+static void ahci_init_sw_activity(struct ata_link *link)
+{
+	struct ata_port *ap = link->ap;
+	struct ahci_port_priv *pp = ap->private_data;
+	struct ahci_em_priv *emp = &pp->em_priv[link->pmp];
+
+	/* init activity stats, setup timer */
+	emp->saved_activity = emp->activity = 0;
+	setup_timer(&emp->timer, ahci_sw_activity_blink, (unsigned long)link);
+
+	/* check our blink policy and set flag for link if it's enabled */
+	if (emp->blink_policy)
+		link->flags |= ATA_LFLAG_SW_ACTIVITY;
+}
+
+static int ahci_reset_em(struct ata_host *host)
+{
+	void __iomem *mmio = host->iomap[AHCI_PCI_BAR];
+	u32 em_ctl;
+
+	em_ctl = readl(mmio + HOST_EM_CTL);
+	if ((em_ctl & EM_CTL_TM) || (em_ctl & EM_CTL_RST))
+		return -EINVAL;
+
+	writel(em_ctl | EM_CTL_RST, mmio + HOST_EM_CTL);
+	return 0;
+}
+
+static ssize_t ahci_transmit_led_message(struct ata_port *ap, u32 state,
+					ssize_t size)
+{
+	struct ahci_host_priv *hpriv = ap->host->private_data;
+	struct ahci_port_priv *pp = ap->private_data;
+	void __iomem *mmio = ap->host->iomap[AHCI_PCI_BAR];
+	u32 em_ctl;
+	u32 message[] = {0, 0};
+	unsigned int flags;
+	int pmp;
+	struct ahci_em_priv *emp;
+
+	/* get the slot number from the message */
+	pmp = (state & 0x0000ff00) >> 8;
+	if (pmp < MAX_SLOTS)
+		emp = &pp->em_priv[pmp];
+	else
+		return -EINVAL;
+
+	spin_lock_irqsave(ap->lock, flags);
+
+	/*
+	 * if we are still busy transmitting a previous message,
+	 * do not allow
+	 */
+	em_ctl = readl(mmio + HOST_EM_CTL);
+	if (em_ctl & EM_CTL_TM) {
+		spin_unlock_irqrestore(ap->lock, flags);
+		return -EINVAL;
+	}
+
+	/*
+	 * create message header - this is all zero except for
+	 * the message size, which is 4 bytes.
+	 */
+	message[0] |= (4 << 8);
+
+	/* ignore 0:4 of byte zero, fill in port info yourself */
+	message[1] = ((state & 0xfffffff0) | ap->port_no);
+
+	/* write message to EM_LOC */
+	writel(message[0], mmio + hpriv->em_loc);
+	writel(message[1], mmio + hpriv->em_loc+4);
+
+	/* save off new led state for port/slot */
+	emp->led_state = message[1];
+
+	/*
+	 * tell hardware to transmit the message
+	 */
+	writel(em_ctl | EM_CTL_TM, mmio + HOST_EM_CTL);
+
+	spin_unlock_irqrestore(ap->lock, flags);
+	return size;
+}
+
+static ssize_t ahci_led_show(struct ata_port *ap, char *buf)
+{
+	struct ahci_port_priv *pp = ap->private_data;
+	struct ata_link *link;
+	struct ahci_em_priv *emp;
+	int rc = 0;
+
+	ata_port_for_each_link(link, ap) {
+		emp = &pp->em_priv[link->pmp];
+		rc += sprintf(buf, "%lx\n", emp->led_state);
+	}
+	return rc;
+}
+
+static ssize_t ahci_led_store(struct ata_port *ap, const char *buf,
+				size_t size)
+{
+	int state;
+	int pmp;
+	struct ahci_port_priv *pp = ap->private_data;
+	struct ahci_em_priv *emp;
+
+	state = simple_strtoul(buf, NULL, 0);
+
+	/* get the slot number from the message */
+	pmp = (state & 0x0000ff00) >> 8;
+	if (pmp < MAX_SLOTS)
+		emp = &pp->em_priv[pmp];
+	else
+		return -EINVAL;
+
+	/* mask off the activity bits if we are in sw_activity
+	 * mode, user should turn off sw_activity before setting
+	 * activity led through em_message
+	 */
+	if (emp->blink_policy)
+		state &= 0xfff8ffff;
+
+	return ahci_transmit_led_message(ap, state, size);
+}
+
+static ssize_t ahci_activity_store(struct ata_device *dev, enum sw_activity val)
+{
+	struct ata_link *link = dev->link;
+	struct ata_port *ap = link->ap;
+	struct ahci_port_priv *pp = ap->private_data;
+	struct ahci_em_priv *emp = &pp->em_priv[link->pmp];
+	u32 port_led_state = emp->led_state;
+
+	/* save the desired Activity LED behavior */
+	if (val == OFF) {
+		/* clear LFLAG */
+		link->flags &= ~(ATA_LFLAG_SW_ACTIVITY);
+
+		/* set the LED to OFF */
+		port_led_state &= 0xfff80000;
+		port_led_state |= (ap->port_no | (link->pmp << 8));
+		ahci_transmit_led_message(ap, port_led_state, 4);
+	} else {
+		link->flags |= ATA_LFLAG_SW_ACTIVITY;
+		if (val == BLINK_OFF) {
+			/* set LED to ON for idle */
+			port_led_state &= 0xfff80000;
+			port_led_state |= (ap->port_no | (link->pmp << 8));
+			port_led_state |= 0x00010000; /* check this */
+			ahci_transmit_led_message(ap, port_led_state, 4);
+		}
+	}
+	emp->blink_policy = val;
+	return 0;
+}
+
+static ssize_t ahci_activity_show(struct ata_device *dev, char *buf)
+{
+	struct ata_link *link = dev->link;
+	struct ata_port *ap = link->ap;
+	struct ahci_port_priv *pp = ap->private_data;
+	struct ahci_em_priv *emp = &pp->em_priv[link->pmp];
+
+	/* display the saved value of activity behavior for this
+	 * disk.
+	 */
+	return sprintf(buf, "%d\n", emp->blink_policy);
+}
+
 static void ahci_port_init(struct pci_dev *pdev, struct ata_port *ap,
 			   int port_no, void __iomem *mmio,
 			   void __iomem *port_mmio)
@@ -1781,6 +2069,8 @@ static unsigned int ahci_qc_issue(struct
 	writel(1 << qc->tag, port_mmio + PORT_CMD_ISSUE);
 	readl(port_mmio + PORT_CMD_ISSUE);	/* flush */
 
+	ahci_sw_activity(qc->dev->link);
+
 	return 0;
 }
 
@@ -2113,7 +2403,8 @@ static void ahci_print_info(struct ata_h
 	dev_printk(KERN_INFO, &pdev->dev,
 		"flags: "
 		"%s%s%s%s%s%s%s"
-		"%s%s%s%s%s%s%s\n"
+		"%s%s%s%s%s%s%s"
+		"%s\n"
 		,
 
 		cap & (1 << 31) ? "64bit " : "",
@@ -2130,7 +2421,8 @@ static void ahci_print_info(struct ata_h
 		cap & (1 << 17) ? "pmp " : "",
 		cap & (1 << 15) ? "pio " : "",
 		cap & (1 << 14) ? "slum " : "",
-		cap & (1 << 13) ? "part " : ""
+		cap & (1 << 13) ? "part " : "",
+		cap & (1 << 6) ? "ems ": ""
 		);
 }
 
@@ -2241,12 +2533,33 @@ static int ahci_init_one(struct pci_dev 
 	if (hpriv->cap & HOST_CAP_PMP)
 		pi.flags |= ATA_FLAG_PMP;
 
+	if (ahci_em_messages && (hpriv->cap & HOST_CAP_EMS)) {
+		u8 messages;
+		void __iomem *mmio = pcim_iomap_table(pdev)[AHCI_PCI_BAR];
+		u32 em_loc = readl(mmio + HOST_EM_LOC);
+		u32 em_ctl = readl(mmio + HOST_EM_CTL);
+
+		messages = (em_ctl & 0x000f0000) >> 16;
+
+		/* we only support LED message type right now */
+		if ((messages & 0x01) && (ahci_em_messages == 1)) {
+			/* store em_loc */
+			hpriv->em_loc = ((em_loc >> 16) * 4);
+			pi.flags |= ATA_FLAG_EM;
+			if (!(em_ctl & EM_CTL_ALHD))
+				pi.flags |= ATA_FLAG_SW_ACTIVITY;
+		}
+	}
+
 	host = ata_host_alloc_pinfo(&pdev->dev, ppi, fls(hpriv->port_map));
 	if (!host)
 		return -ENOMEM;
 	host->iomap = pcim_iomap_table(pdev);
 	host->private_data = hpriv;
 
+	if (pi.flags & ATA_FLAG_EM)
+		ahci_reset_em(host);
+
 	for (i = 0; i < host->n_ports; i++) {
 		struct ata_port *ap = host->ports[i];
 		void __iomem *port_mmio = ahci_port_base(ap);
@@ -2258,6 +2571,10 @@ static int ahci_init_one(struct pci_dev 
 		/* set initial link pm policy */
 		ap->pm_policy = NOT_AVAILABLE;
 
+		/* set enclosure management message type */
+		if (ap->flags & ATA_FLAG_EM)
+			ap->em_message_type = ahci_em_messages;
+
 		/* standard SATA port setup */
 		if (hpriv->port_map & (1 << i))
 			ap->ioaddr.cmd_addr = port_mmio;
drivers/ata/libata-scsi.c +77 -0

83 lines not on this page · raw message

include/linux/libata.h +22 -0
Index: linux-2.6/include/linux/libata.h
===================================================================
@@ -169,6 +169,7 @@ enum {
 	ATA_LFLAG_ASSUME_CLASS	= ATA_LFLAG_ASSUME_ATA | ATA_LFLAG_ASSUME_SEMB,
 	ATA_LFLAG_NO_RETRY	= (1 << 5), /* don't retry this link */
 	ATA_LFLAG_DISABLED	= (1 << 6), /* link is disabled */
+	ATA_LFLAG_SW_ACTIVITY	= (1 << 7), /* keep activity stats */
 
 	/* struct ata_port flags */
 	ATA_FLAG_SLAVE_POSS	= (1 << 0), /* host supports slave dev */
@@ -191,6 +192,10 @@ enum {
 	ATA_FLAG_AN		= (1 << 18), /* controller supports AN */
 	ATA_FLAG_PMP		= (1 << 19), /* controller supports PMP */
 	ATA_FLAG_IPM		= (1 << 20), /* driver can handle IPM */
+	ATA_FLAG_EM		= (1 << 21), /* driver supports enclosure
+					      * management */
+	ATA_FLAG_SW_ACTIVITY	= (1 << 22), /* driver supports sw activity
+					      * led */
 
 	/* The following flag belongs to ap->pflags but is kept in
 	 * ap->flags because it's referenced in many LLDs and will be
@@ -398,7 +403,17 @@ enum link_pm {
 	MAX_PERFORMANCE,
 	MEDIUM_POWER,
 };
+
+enum sw_activity {
+	OFF,
+	BLINK_ON,
+	BLINK_OFF,
+};
+
 extern struct class_device_attribute class_device_attr_link_power_management_policy;
+extern struct class_device_attribute class_device_attr_em_message_type;
+extern struct class_device_attribute class_device_attr_em_message;
+extern struct device_attribute dev_attr_sw_activity;
 
 struct ata_ioports {
 	void __iomem		*cmd_addr;
@@ -652,6 +667,7 @@ struct ata_port {
 	struct timer_list	fastdrain_timer;
 	unsigned long		fastdrain_cnt;
 
+	int			em_message_type;
 	void			*private_data;
 
 #ifdef CONFIG_ATA_ACPI
@@ -724,6 +740,12 @@ struct ata_port_operations {
 
 	void (*bmdma_stop) (struct ata_queued_cmd *qc);
 	u8   (*bmdma_status) (struct ata_port *ap);
+	ssize_t (*em_show)(struct ata_port *ap, char *buf);
+	ssize_t (*em_store)(struct ata_port *ap, const char *message,
+			    size_t size);
+	ssize_t (*sw_activity_show)(struct ata_device *dev, char *buf);
+	ssize_t (*sw_activity_store)(struct ata_device *dev,
+				     enum sw_activity val);
 };
 
 struct ata_port_info {
#1 lore raw
Quoted 17 lines · Kristen Carlson Accardi

Add Enclosure Management support to libata and ahci.

This patch adds support for the LED protocol, as defined in the AHCI spec. It adds a generic em_message and em_type sysfs entry per host. It also adds a sw_activity field per existing drive.

The em_message field can be used by the driver to take enclosure management commands from userspace. In the case of the LED protocol, writes and reads from em_message correspond to the LED message format as defined in the AHCI spec.

em_message type is a read only file that displays the current enclosure management protocol that is used by the driver.

sw_activity is used by drivers which support software controlled activity LEDs. It has the following valid values:

Quoted 7 lines

0 OFF - the LED is not activated on activity
1 BLINK_ON - the LED blinks on every 10ms when activity is detected.
2 BLINK_OFF - the LED is on when idle, and blinks off every 10ms when
activity is detected.

It's important to note that the user must turn sw_activity OFF it they wish to control the activity LED via the em_message file.

One of the things we really need to do is to get some type of generic enclosure support. I note that ahci support three standard eclosure management protocols (SAF-TE, SES-2, SFF-8485 SGPIO) as well as the one proprietary one you've chosen to implement. Is that because no-one in the field has actually connected AHCI up to anything supporting one of the standard protocols?

I'm looking at this from slightly the other way around: the SAS protocol is virtually mandating SFF-8485 as the enclosure protocol to the point that it's actually built into the sas management protocol ... I was starting to wonder how we should be taking advantage of this.

The implementation probably should be generic (above SCSI or IDE or ATA) but it would obviously need to tap into the subsytem/transport/device specific pieces, so possibly block looks to be the right place to start?

James

#2 lore raw
Quoted 26 lines · On Thu, 17 Jan 2008 16:50:42 -0600 James Bottomley…
Quoted 17 lines · Kristen Carlson Accardi

Add Enclosure Management support to libata and ahci.

This patch adds support for the LED protocol, as defined in the AHCI spec. It adds a generic em_message and em_type sysfs entry per host. It also adds a sw_activity field per existing drive.

The em_message field can be used by the driver to take enclosure management commands from userspace. In the case of the LED protocol, writes and reads from em_message correspond to the LED message format as defined in the AHCI spec.

em_message type is a read only file that displays the current enclosure management protocol that is used by the driver.

sw_activity is used by drivers which support software controlled activity LEDs. It has the following valid values:

Quoted 7 lines

0 OFF - the LED is not activated on activity
1 BLINK_ON - the LED blinks on every 10ms when activity is
detected. 2 BLINK_OFF - the LED is on when idle, and blinks
off every 10ms when activity is detected.

It's important to note that the user must turn sw_activity OFF it they wish to control the activity LED via the em_message file.

Quoted 6 lines

One of the things we really need to do is to get some type of generic enclosure support. I note that ahci support three standard eclosure management protocols (SAF-TE, SES-2, SFF-8485 SGPIO) as well as the one proprietary one you've chosen to implement. Is that because no-one in the field has actually connected AHCI up to anything supporting one of the standard protocols?

Correct - I've not seen any AHCI hardware that supports anything but the LED protocol so far.

#3 lore raw
In reply to James Bottomley
Quoted 6 lines · James Bottomley

One of the things we really need to do is to get some type of generic enclosure support. I note that ahci support three standard eclosure management protocols (SAF-TE, SES-2, SFF-8485 SGPIO) as well as the one proprietary one you've chosen to implement. Is that because no-one in the field has actually connected AHCI up to anything supporting one of the standard protocols?

NVIDIA posted SGPIO support, FWIW...

Jeff

#4 lore raw
In reply to James Bottomley
Quoted 39 lines · On Thu, 17 Jan 2008 16:50:42 -0600 James Bottomley…
Quoted 17 lines · Kristen Carlson Accardi

Add Enclosure Management support to libata and ahci.

This patch adds support for the LED protocol, as defined in the AHCI spec. It adds a generic em_message and em_type sysfs entry per host. It also adds a sw_activity field per existing drive.

The em_message field can be used by the driver to take enclosure management commands from userspace. In the case of the LED protocol, writes and reads from em_message correspond to the LED message format as defined in the AHCI spec.

em_message type is a read only file that displays the current enclosure management protocol that is used by the driver.

sw_activity is used by drivers which support software controlled activity LEDs. It has the following valid values:

Quoted 7 lines

0 OFF - the LED is not activated on activity
1 BLINK_ON - the LED blinks on every 10ms when activity is
detected. 2 BLINK_OFF - the LED is on when idle, and blinks
off every 10ms when activity is detected.

It's important to note that the user must turn sw_activity OFF it they wish to control the activity LED via the em_message file.

One of the things we really need to do is to get some type of generic enclosure support. I note that ahci support three standard eclosure management protocols (SAF-TE, SES-2, SFF-8485 SGPIO) as well as the one proprietary one you've chosen to implement. Is that because no-one in the field has actually connected AHCI up to anything supporting one of the standard protocols?

I'm looking at this from slightly the other way around: the SAS protocol is virtually mandating SFF-8485 as the enclosure protocol to the point that it's actually built into the sas management protocol ... I was starting to wonder how we should be taking advantage of this.

Quoted 8 lines

The implementation probably should be generic (above SCSI or IDE or ATA) but it would obviously need to tap into the subsytem/transport/device specific pieces, so possibly block looks to be the right place to start?

James

I originally thought to try to make a generic enclosure management framework that we could hook individual EM protocols into. Then I started to wonder why we needed to add knowledge of these protocols into the kernel. At least the AHCI hardware which I'm familiar with, has no need to know anything about the protocol. It abstracts everything into just a message. So, the design that I did in this patch does the same thing. You export the type of protocol the driver is configured to accept, then the message buffer and leave it up to user space to understand the individual protocol. This works for all supported EM protocols. As far as I can see, most of these management protocols are better suited to being implemented in user space anyway.

As far as block, I'm not sure that makes sense, but maybe I'm misunderstanding what you want. The em message needs to be associated with the controller, not with individual devices. The reason for this is that the user may wish to locate a drive bay that has no disk in it, so they need to be able to send enclosure messages regardless of whether there's a block device associated with it.

Kristen

#5 lore raw
Quoted 51 lines · Kristen Carlson Accardi
Quoted 39 lines · On Thu, 17 Jan 2008 16:50:42 -0600 James Bottomley…
Quoted 17 lines · Kristen Carlson Accardi

Add Enclosure Management support to libata and ahci.

This patch adds support for the LED protocol, as defined in the AHCI spec. It adds a generic em_message and em_type sysfs entry per host. It also adds a sw_activity field per existing drive.

The em_message field can be used by the driver to take enclosure management commands from userspace. In the case of the LED protocol, writes and reads from em_message correspond to the LED message format as defined in the AHCI spec.

em_message type is a read only file that displays the current enclosure management protocol that is used by the driver.

sw_activity is used by drivers which support software controlled activity LEDs. It has the following valid values:

Quoted 7 lines

0 OFF - the LED is not activated on activity
1 BLINK_ON - the LED blinks on every 10ms when activity is
detected. 2 BLINK_OFF - the LED is on when idle, and blinks
off every 10ms when activity is detected.

It's important to note that the user must turn sw_activity OFF it they wish to control the activity LED via the em_message file.

One of the things we really need to do is to get some type of generic enclosure support. I note that ahci support three standard eclosure management protocols (SAF-TE, SES-2, SFF-8485 SGPIO) as well as the one proprietary one you've chosen to implement. Is that because no-one in the field has actually connected AHCI up to anything supporting one of the standard protocols?

I'm looking at this from slightly the other way around: the SAS protocol is virtually mandating SFF-8485 as the enclosure protocol to the point that it's actually built into the sas management protocol ... I was starting to wonder how we should be taking advantage of this.

Quoted 8 lines

The implementation probably should be generic (above SCSI or IDE or ATA) but it would obviously need to tap into the subsytem/transport/device specific pieces, so possibly block looks to be the right place to start?

James

Quoted 12 lines

I originally thought to try to make a generic enclosure management framework that we could hook individual EM protocols into. Then I started to wonder why we needed to add knowledge of these protocols into the kernel. At least the AHCI hardware which I'm familiar with, has no need to know anything about the protocol. It abstracts everything into just a message. So, the design that I did in this patch does the same thing. You export the type of protocol the driver is configured to accept, then the message buffer and leave it up to user space to understand the individual protocol. This works for all supported EM protocols. As far as I can see, most of these management protocols are better suited to being implemented in user space anyway.

It's one way to look at it, if we go with SFF-8485 and the AHCI specific protocol. Basically both of them are only about flashing LEDs. The SAF-TE and SES protocols are much more comprehensive (and include things like environmental monitors, temperature, fans, etc.).

I think SFF-8485 still needs the LED frequency generators for RAW mode, so putting them in AHCI is a bit too low down. There's also the question of a common user space interface for both.

Quoted 6 lines

As far as block, I'm not sure that makes sense, but maybe I'm misunderstanding what you want. The em message needs to be associated with the controller, not with individual devices. The reason for this is that the user may wish to locate a drive bay that has no disk in it, so they need to be able to send enclosure messages regardless of whether there's a block device associated with it.

It's actually worse than that: enclosures aren't tied to HBAs even. They're things that appear on Busses. Take FC as the logical extreme:
you can have tons of different enclosures on a single FC bus.

But you can see from this, that enclosures are really separate devices (separate from their contents or their connected HBA).

The thought about block is basically that SGPIO is a frame in/frame out protocol. It would probably have a raw interface via bsg a bit like SMP does. However, I wouldn't necessarily tie it to block. It would probably be tied to generic devices which get placed in the device tree at appropriate locations. Ideally, we can place a SGPIO enclosure device properly whether it's tied to SAS, FC or AHCI.

James

#6 lore raw
Quoted 68 lines · On Fri, 18 Jan 2008 11:11:21 -0600 James Bottomley…
Quoted 53 lines · Kristen Carlson Accardi
Quoted 41 lines · On Thu, 17 Jan 2008 16:50:42 -0600 James Bottomley…
Quoted 17 lines · Kristen Carlson Accardi

Add Enclosure Management support to libata and ahci.

This patch adds support for the LED protocol, as defined in the AHCI spec. It adds a generic em_message and em_type sysfs entry per host. It also adds a sw_activity field per existing drive.

The em_message field can be used by the driver to take enclosure management commands from userspace. In the case of the LED protocol, writes and reads from em_message correspond to the LED message format as defined in the AHCI spec.

em_message type is a read only file that displays the current enclosure management protocol that is used by the driver.

sw_activity is used by drivers which support software controlled activity LEDs. It has the following valid values:

Quoted 8 lines

0 OFF - the LED is not activated on activity
1 BLINK_ON - the LED blinks on every 10ms when activity
is detected. 2 BLINK_OFF - the LED is on when idle, and
blinks off every 10ms when activity is detected.

It's important to note that the user must turn sw_activity OFF it they wish to control the activity LED via the em_message file.

One of the things we really need to do is to get some type of generic enclosure support. I note that ahci support three standard eclosure management protocols (SAF-TE, SES-2, SFF-8485 SGPIO) as well as the one proprietary one you've chosen to implement. Is that because no-one in the field has actually connected AHCI up to anything supporting one of the standard protocols?

I'm looking at this from slightly the other way around: the SAS protocol is virtually mandating SFF-8485 as the enclosure protocol to the point that it's actually built into the sas management protocol ... I was starting to wonder how we should be taking advantage of this.

Quoted 8 lines

The implementation probably should be generic (above SCSI or IDE or ATA) but it would obviously need to tap into the subsytem/transport/device specific pieces, so possibly block looks to be the right place to start?

James

Quoted 12 lines

I originally thought to try to make a generic enclosure management framework that we could hook individual EM protocols into. Then I started to wonder why we needed to add knowledge of these protocols into the kernel. At least the AHCI hardware which I'm familiar with, has no need to know anything about the protocol. It abstracts everything into just a message. So, the design that I did in this patch does the same thing. You export the type of protocol the driver is configured to accept, then the message buffer and leave it up to user space to understand the individual protocol. This works for all supported EM protocols. As far as I can see, most of these management protocols are better suited to being implemented in user space anyway.

Quoted 4 lines

It's one way to look at it, if we go with SFF-8485 and the AHCI specific protocol. Basically both of them are only about flashing LEDs. The SAF-TE and SES protocols are much more comprehensive (and include things like environmental monitors, temperature, fans, etc.).

Even these though can be boiled down to read a message/write a message.

Quoted 4 lines

I think SFF-8485 still needs the LED frequency generators for RAW mode, so putting them in AHCI is a bit too low down. There's also the question of a common user space interface for both.

My reading of SFF-8485 leads me to believe that even in raw bit stream mode you are still just reading/writing message buffers.

Quoted 9 lines
Quoted 8 lines

As far as block, I'm not sure that makes sense, but maybe I'm misunderstanding what you want. The em message needs to be associated with the controller, not with individual devices. The reason for this is that the user may wish to locate a drive bay that has no disk in it, so they need to be able to send enclosure messages regardless of whether there's a block device associated with it.

Quoted 3 lines

It's actually worse than that: enclosures aren't tied to HBAs even. They're things that appear on Busses. Take FC as the logical extreme:
you can have tons of different enclosures on a single FC bus.

For SATA they are tied to the controller. Maybe it's not feasible to come up with a solution that is generic to something like FC and SATA on the other end.

Quoted 4 lines

But you can see from this, that enclosures are really separate devices (separate from their contents or their connected HBA).

Quoted 10 lines

The thought about block is basically that SGPIO is a frame in/frame out protocol. It would probably have a raw interface via bsg a bit like SMP does. However, I wouldn't necessarily tie it to block. It would probably be tied to generic devices which get placed in the device tree at appropriate locations. Ideally, we can place a SGPIO enclosure device properly whether it's tied to SAS, FC or AHCI.

James

This seems like maybe something we could work on in an evolutionary way as the need presents itself. Honestly, without any SATA hardware that supports something beyond what this patch can support, it seems a lot of effort for little gain to try to share code, especially since the SATA devices wouldn't even use it. With both the AHCI and the nvidia EM solutions that are out there, that seems unneccessary.

#7 lore raw
Quoted 71 lines · Kristen Carlson Accardi
Quoted 68 lines · On Fri, 18 Jan 2008 11:11:21 -0600 James Bottomley…
Quoted 65 lines · Kristen Carlson Accardi
Quoted 41 lines · On Thu, 17 Jan 2008 16:50:42 -0600 James Bottomley…
Quoted 17 lines · Kristen Carlson Accardi

Add Enclosure Management support to libata and ahci.

This patch adds support for the LED protocol, as defined in the AHCI spec. It adds a generic em_message and em_type sysfs entry per host. It also adds a sw_activity field per existing drive.

The em_message field can be used by the driver to take enclosure management commands from userspace. In the case of the LED protocol, writes and reads from em_message correspond to the LED message format as defined in the AHCI spec.

em_message type is a read only file that displays the current enclosure management protocol that is used by the driver.

sw_activity is used by drivers which support software controlled activity LEDs. It has the following valid values:

Quoted 8 lines

0 OFF - the LED is not activated on activity
1 BLINK_ON - the LED blinks on every 10ms when activity
is detected. 2 BLINK_OFF - the LED is on when idle, and
blinks off every 10ms when activity is detected.

It's important to note that the user must turn sw_activity OFF it they wish to control the activity LED via the em_message file.

One of the things we really need to do is to get some type of generic enclosure support. I note that ahci support three standard eclosure management protocols (SAF-TE, SES-2, SFF-8485 SGPIO) as well as the one proprietary one you've chosen to implement. Is that because no-one in the field has actually connected AHCI up to anything supporting one of the standard protocols?

I'm looking at this from slightly the other way around: the SAS protocol is virtually mandating SFF-8485 as the enclosure protocol to the point that it's actually built into the sas management protocol ... I was starting to wonder how we should be taking advantage of this.

Quoted 8 lines

The implementation probably should be generic (above SCSI or IDE or ATA) but it would obviously need to tap into the subsytem/transport/device specific pieces, so possibly block looks to be the right place to start?

James

I originally thought to try to make a generic enclosure management framework that we could hook individual EM protocols into. Then I started to wonder why we needed to add knowledge of these protocols into the kernel. At least the AHCI hardware which I'm familiar with, has no need to know anything about the protocol. It abstracts everything into just a message. So, the design that I did in this patch does the same thing. You export the type of protocol the driver is configured to accept, then the message buffer and leave it up to user space to understand the individual protocol. This works for all supported EM protocols. As far as I can see, most of these management protocols are better suited to being implemented in user space anyway.

Quoted 7 lines
Quoted 4 lines

It's one way to look at it, if we go with SFF-8485 and the AHCI specific protocol. Basically both of them are only about flashing LEDs. The SAF-TE and SES protocols are much more comprehensive (and include things like environmental monitors, temperature, fans, etc.).

Even these though can be boiled down to read a message/write a message.

That's true of almost every protocol in the end. I was thinking of the abstraction. The messages lead to flashing lights in the enclosures. They also have interactive knobs that users twiddle on the other end. We really need a uniform user interface abstraction for enclosures.

Quoted 17 lines
Quoted 4 lines

I think SFF-8485 still needs the LED frequency generators for RAW mode, so putting them in AHCI is a bit too low down. There's also the question of a common user space interface for both.

My reading of SFF-8485 leads me to believe that even in raw bit stream mode you are still just reading/writing message buffers.

Quoted 9 lines
Quoted 8 lines

As far as block, I'm not sure that makes sense, but maybe I'm misunderstanding what you want. The em message needs to be associated with the controller, not with individual devices. The reason for this is that the user may wish to locate a drive bay that has no disk in it, so they need to be able to send enclosure messages regardless of whether there's a block device associated with it.

Quoted 7 lines
Quoted 3 lines

It's actually worse than that: enclosures aren't tied to HBAs even. They're things that appear on Busses. Take FC as the logical extreme:
you can have tons of different enclosures on a single FC bus.

For SATA they are tied to the controller. Maybe it's not feasible to come up with a solution that is generic to something like FC and SATA on the other end.

So how does this work if the enclosure includes a SATA Port Multiplier?

Quoted 15 lines
Quoted 4 lines

But you can see from this, that enclosures are really separate devices (separate from their contents or their connected HBA).

Quoted 10 lines

The thought about block is basically that SGPIO is a frame in/frame out protocol. It would probably have a raw interface via bsg a bit like SMP does. However, I wouldn't necessarily tie it to block. It would probably be tied to generic devices which get placed in the device tree at appropriate locations. Ideally, we can place a SGPIO enclosure device properly whether it's tied to SAS, FC or AHCI.

James

Quoted 6 lines

This seems like maybe something we could work on in an evolutionary way as the need presents itself. Honestly, without any SATA hardware that supports something beyond what this patch can support, it seems a lot of effort for little gain to try to share code, especially since the SATA devices wouldn't even use it. With both the AHCI and the nvidia EM solutions that are out there, that seems unneccessary.

Unfortunately, all the dual SAS/SATA enclosures seem to be coming with either SGPIO devices or full fledged SES-2 devices. I've actually got both (a backplane with SGPIO and an internal SAS/SATA enclosure with SES-2). Unfortunately, I don't have the necessary information to drive the SGPIO one ... it's connected directly to an aix94xx using the mini4i SGPIO signals ... I think aic94xx can drive them, we just don't have the programming information. The other is a standard SES-2 device, which I think I might be able to get working.

James

#8 lore raw
Quoted 115 lines · On Fri, 18 Jan 2008 18:16:34 -0600 James Bottomley…
Quoted 77 lines · Kristen Carlson Accardi
Quoted 74 lines · On Fri, 18 Jan 2008 11:11:21 -0600 James Bottomley…
Quoted 71 lines · Kristen Carlson Accardi
Quoted 46 lines · On Thu, 17 Jan 2008 16:50:42 -0600 James Bottomley…
Quoted 26 lines · Kristen Carlson Accardi

Add Enclosure Management support to libata and ahci.

This patch adds support for the LED protocol, as defined in the AHCI spec. It adds a generic em_message and em_type sysfs entry per host. It also adds a sw_activity field per existing drive.

The em_message field can be used by the driver to take enclosure management commands from userspace. In the case of the LED protocol, writes and reads from em_message correspond to the LED message format as defined in the AHCI spec.

em_message type is a read only file that displays the current enclosure management protocol that is used by the driver.

sw_activity is used by drivers which support software controlled activity LEDs. It has the following valid values:

0 OFF - the LED is not activated on activity
1 BLINK_ON - the LED blinks on every 10ms when
activity is detected. 2 BLINK_OFF - the LED is on
when idle, and blinks off every 10ms when activity is detected.

Quoted 3 lines

It's important to note that the user must turn sw_activity OFF it they wish to control the activity LED via the em_message file.

One of the things we really need to do is to get some type of generic enclosure support. I note that ahci support three standard eclosure management protocols (SAF-TE, SES-2, SFF-8485 SGPIO) as well as the one proprietary one you've chosen to implement. Is that because no-one in the field has actually connected AHCI up to anything supporting one of the standard protocols?

I'm looking at this from slightly the other way around: the SAS protocol is virtually mandating SFF-8485 as the enclosure protocol to the point that it's actually built into the sas management protocol ... I was starting to wonder how we should be taking advantage of this.

Quoted 8 lines

The implementation probably should be generic (above SCSI or IDE or ATA) but it would obviously need to tap into the subsytem/transport/device specific pieces, so possibly block looks to be the right place to start?

James

I originally thought to try to make a generic enclosure management framework that we could hook individual EM protocols into. Then I started to wonder why we needed to add knowledge of these protocols into the kernel. At least the AHCI hardware which I'm familiar with, has no need to know anything about the protocol. It abstracts everything into just a message. So, the design that I did in this patch does the same thing. You export the type of protocol the driver is configured to accept, then the message buffer and leave it up to user space to understand the individual protocol. This works for all supported EM protocols. As far as I can see, most of these management protocols are better suited to being implemented in user space anyway.

Quoted 8 lines
Quoted 5 lines

It's one way to look at it, if we go with SFF-8485 and the AHCI specific protocol. Basically both of them are only about flashing LEDs. The SAF-TE and SES protocols are much more comprehensive (and include things like environmental monitors, temperature, fans, etc.).

Even these though can be boiled down to read a message/write a message.

That's true of almost every protocol in the end. I was thinking of the abstraction. The messages lead to flashing lights in the enclosures. They also have interactive knobs that users twiddle on the other end. We really need a uniform user interface abstraction for enclosures.

Quoted 22 lines
Quoted 4 lines

I think SFF-8485 still needs the LED frequency generators for RAW mode, so putting them in AHCI is a bit too low down. There's also the question of a common user space interface for both.

My reading of SFF-8485 leads me to believe that even in raw bit stream mode you are still just reading/writing message buffers.

Quoted 13 lines
Quoted 8 lines

As far as block, I'm not sure that makes sense, but maybe I'm misunderstanding what you want. The em message needs to be associated with the controller, not with individual devices. The reason for this is that the user may wish to locate a drive bay that has no disk in it, so they need to be able to send enclosure messages regardless of whether there's a block device associated with it.

It's actually worse than that: enclosures aren't tied to HBAs even. They're things that appear on Busses. Take FC as the logical extreme: you can have tons of different enclosures on a single FC bus.

Quoted 6 lines
Quoted 3 lines

For SATA they are tied to the controller. Maybe it's not feasible to come up with a solution that is generic to something like FC and SATA on the other end.

So how does this work if the enclosure includes a SATA Port Multiplier?

The protocol specifies the disk number, which is included in the message. For the AHCI LED protocol, the message contains the AP and the PM slot number.

<snip>

Quoted 9 lines

Unfortunately, all the dual SAS/SATA enclosures seem to be coming with either SGPIO devices or full fledged SES-2 devices. I've actually got both (a backplane with SGPIO and an internal SAS/SATA enclosure with SES-2). Unfortunately, I don't have the necessary information to drive the SGPIO one ... it's connected directly to an aix94xx using the mini4i SGPIO signals ... I think aic94xx can drive them, we just don't have the programming information. The other is a standard SES-2 device, which I think I might be able to get working.

Having documentation would be pretty helpful :). I know for ICH8, if you read the docs it says that it supports SGPIO as well. But then you realize it supports SGPIO via the LED protocol, wired up to translate LED to SGPIO via hardware. But, even if it did support straight SGPIO, this design can accommodate that. Can we see the documentation for the SES-2 device?

#9 lore raw
Quoted 10 lines · Kristen Carlson Accardi
Quoted 9 lines

Unfortunately, all the dual SAS/SATA enclosures seem to be coming with either SGPIO devices or full fledged SES-2 devices. I've actually got both (a backplane with SGPIO and an internal SAS/SATA enclosure with SES-2). Unfortunately, I don't have the necessary information to drive the SGPIO one ... it's connected directly to an aix94xx using the mini4i SGPIO signals ... I think aic94xx can drive them, we just don't have the programming information. The other is a standard SES-2 device, which I think I might be able to get working.

Quoted 6 lines

Having documentation would be pretty helpful :). I know for ICH8, if you read the docs it says that it supports SGPIO as well. But then you realize it supports SGPIO via the LED protocol, wired up to translate LED to SGPIO via hardware. But, even if it did support straight SGPIO, this design can accommodate that. Can we see the documentation for the SES-2 device?

Yes, sure; SES-2 is here (usual place, since it's a SCSI standard):

http://www.t10.org/ftp/t10/drafts/ses2/ses2r19a.pdf

SGPIO is more convoluted. The canonical link is
http://www.sffcommittee.com/ but that just seems to send you back to seagate. The actual standard is this one:

ftp://ftp.seagate.com/sff/SFF-8485.PDF

James

#10 lore raw
Quoted 23 lines · On Fri, 18 Jan 2008 18:47:18 -0600 James Bottomley…
Quoted 11 lines · Kristen Carlson Accardi
Quoted 10 lines

Unfortunately, all the dual SAS/SATA enclosures seem to be coming with either SGPIO devices or full fledged SES-2 devices. I've actually got both (a backplane with SGPIO and an internal SAS/SATA enclosure with SES-2). Unfortunately, I don't have the necessary information to drive the SGPIO one ... it's connected directly to an aix94xx using the mini4i SGPIO signals ... I think aic94xx can drive them, we just don't have the programming information. The other is a standard SES-2 device, which I think I might be able to get working.

Quoted 6 lines

Having documentation would be pretty helpful :). I know for ICH8, if you read the docs it says that it supports SGPIO as well. But then you realize it supports SGPIO via the LED protocol, wired up to translate LED to SGPIO via hardware. But, even if it did support straight SGPIO, this design can accommodate that. Can we see the documentation for the SES-2 device?

Yes, sure; SES-2 is here (usual place, since it's a SCSI standard):

http://www.t10.org/ftp/t10/drafts/ses2/ses2r19a.pdf

Quoted 9 lines

SGPIO is more convoluted. The canonical link is
http://www.sffcommittee.com/ but that just seems to send you back to seagate. The actual standard is this one:

ftp://ftp.seagate.com/sff/SFF-8485.PDF

James

No, I meant for the actual device. The specs don't help all that much in the area of actually transmitting the messages at the driver level - at least they don't for AHCI.

#11 lore raw
Quoted 32 lines · Kristen Carlson Accardi
Quoted 29 lines · On Fri, 18 Jan 2008 18:47:18 -0600 James Bottomley…
Quoted 11 lines · Kristen Carlson Accardi
Quoted 10 lines

Unfortunately, all the dual SAS/SATA enclosures seem to be coming with either SGPIO devices or full fledged SES-2 devices. I've actually got both (a backplane with SGPIO and an internal SAS/SATA enclosure with SES-2). Unfortunately, I don't have the necessary information to drive the SGPIO one ... it's connected directly to an aix94xx using the mini4i SGPIO signals ... I think aic94xx can drive them, we just don't have the programming information. The other is a standard SES-2 device, which I think I might be able to get working.

Quoted 6 lines

Having documentation would be pretty helpful :). I know for ICH8, if you read the docs it says that it supports SGPIO as well. But then you realize it supports SGPIO via the LED protocol, wired up to translate LED to SGPIO via hardware. But, even if it did support straight SGPIO, this design can accommodate that. Can we see the documentation for the SES-2 device?

Yes, sure; SES-2 is here (usual place, since it's a SCSI standard):

http://www.t10.org/ftp/t10/drafts/ses2/ses2r19a.pdf

SGPIO is more convoluted. The canonical link is
http://www.sffcommittee.com/ but that just seems to send you back to seagate. The actual standard is this one:

ftp://ftp.seagate.com/sff/SFF-8485.PDF

Quoted 7 lines
Quoted 3 lines

James

No, I meant for the actual device. The specs don't help all that much in the area of actually transmitting the messages at the driver level - at least they don't for AHCI.

OK, now I'm confused. A SES-2 device is a SCSI device. The standard defines everything for them. They sit on the bus like any other SCSI device.

SGPIO is a separate bus; it's also fully defined in SFF-8485, so my SFF-8485 compliant backplane should be fully defined by the spec as well. If you're asking how the SGPIO transciever in the aic94xx works, that's the piece I don't know ... it's not in the RAZOR spec.

James

#12 lore raw
In reply to James Bottomley
Quoted 84 lines · On Fri, 18 Jan 2008 18:16:34 -0600 James Bottomley…
Quoted 83 lines · Kristen Carlson Accardi
Quoted 79 lines · On Fri, 18 Jan 2008 11:11:21 -0600 James Bottomley…
Quoted 58 lines · Kristen Carlson Accardi
Quoted 46 lines · On Thu, 17 Jan 2008 16:50:42 -0600 James Bottomley…
Quoted 26 lines · Kristen Carlson Accardi

Add Enclosure Management support to libata and ahci.

This patch adds support for the LED protocol, as defined in the AHCI spec. It adds a generic em_message and em_type sysfs entry per host. It also adds a sw_activity field per existing drive.

The em_message field can be used by the driver to take enclosure management commands from userspace. In the case of the LED protocol, writes and reads from em_message correspond to the LED message format as defined in the AHCI spec.

em_message type is a read only file that displays the current enclosure management protocol that is used by the driver.

sw_activity is used by drivers which support software controlled activity LEDs. It has the following valid values:

0 OFF - the LED is not activated on activity
1 BLINK_ON - the LED blinks on every 10ms when
activity is detected. 2 BLINK_OFF - the LED is on
when idle, and blinks off every 10ms when activity is detected.

Quoted 3 lines

It's important to note that the user must turn sw_activity OFF it they wish to control the activity LED via the em_message file.

One of the things we really need to do is to get some type of generic enclosure support. I note that ahci support three standard eclosure management protocols (SAF-TE, SES-2, SFF-8485 SGPIO) as well as the one proprietary one you've chosen to implement. Is that because no-one in the field has actually connected AHCI up to anything supporting one of the standard protocols?

I'm looking at this from slightly the other way around: the SAS protocol is virtually mandating SFF-8485 as the enclosure protocol to the point that it's actually built into the sas management protocol ... I was starting to wonder how we should be taking advantage of this.

Quoted 8 lines

The implementation probably should be generic (above SCSI or IDE or ATA) but it would obviously need to tap into the subsytem/transport/device specific pieces, so possibly block looks to be the right place to start?

James

Quoted 13 lines

I originally thought to try to make a generic enclosure management framework that we could hook individual EM protocols into. Then I started to wonder why we needed to add knowledge of these protocols into the kernel. At least the AHCI hardware which I'm familiar with, has no need to know anything about the protocol. It abstracts everything into just a message. So, the design that I did in this patch does the same thing. You export the type of protocol the driver is configured to accept, then the message buffer and leave it up to user space to understand the individual protocol. This works for all supported EM protocols. As far as I can see, most of these management protocols are better suited to being implemented in user space anyway.

It's one way to look at it, if we go with SFF-8485 and the AHCI specific protocol. Basically both of them are only about flashing LEDs. The SAF-TE and SES protocols are much more comprehensive (and include things like environmental monitors, temperature, fans, etc.).

Quoted 9 lines
Quoted 2 lines

Even these though can be boiled down to read a message/write a message.

That's true of almost every protocol in the end. I was thinking of the abstraction. The messages lead to flashing lights in the enclosures. They also have interactive knobs that users twiddle on the other end. We really need a uniform user interface abstraction for enclosures.

I guess I'm still not seeing why this abstraction needs to be in the kernel. Why can't it be a user space library with a generic buffer to send/receive messages.

#13 lore raw
Quoted 97 lines · Kristen Carlson Accardi
Quoted 84 lines · On Fri, 18 Jan 2008 18:16:34 -0600 James Bottomley…
Quoted 83 lines · Kristen Carlson Accardi
Quoted 79 lines · On Fri, 18 Jan 2008 11:11:21 -0600 James Bottomley…
Quoted 58 lines · Kristen Carlson Accardi
Quoted 46 lines · On Thu, 17 Jan 2008 16:50:42 -0600 James Bottomley…
Quoted 26 lines · Kristen Carlson Accardi

Add Enclosure Management support to libata and ahci.

This patch adds support for the LED protocol, as defined in the AHCI spec. It adds a generic em_message and em_type sysfs entry per host. It also adds a sw_activity field per existing drive.

The em_message field can be used by the driver to take enclosure management commands from userspace. In the case of the LED protocol, writes and reads from em_message correspond to the LED message format as defined in the AHCI spec.

em_message type is a read only file that displays the current enclosure management protocol that is used by the driver.

sw_activity is used by drivers which support software controlled activity LEDs. It has the following valid values:

0 OFF - the LED is not activated on activity
1 BLINK_ON - the LED blinks on every 10ms when
activity is detected. 2 BLINK_OFF - the LED is on
when idle, and blinks off every 10ms when activity is detected.

Quoted 3 lines

It's important to note that the user must turn sw_activity OFF it they wish to control the activity LED via the em_message file.

One of the things we really need to do is to get some type of generic enclosure support. I note that ahci support three standard eclosure management protocols (SAF-TE, SES-2, SFF-8485 SGPIO) as well as the one proprietary one you've chosen to implement. Is that because no-one in the field has actually connected AHCI up to anything supporting one of the standard protocols?

I'm looking at this from slightly the other way around: the SAS protocol is virtually mandating SFF-8485 as the enclosure protocol to the point that it's actually built into the sas management protocol ... I was starting to wonder how we should be taking advantage of this.

Quoted 8 lines

The implementation probably should be generic (above SCSI or IDE or ATA) but it would obviously need to tap into the subsytem/transport/device specific pieces, so possibly block looks to be the right place to start?

James

Quoted 13 lines

I originally thought to try to make a generic enclosure management framework that we could hook individual EM protocols into. Then I started to wonder why we needed to add knowledge of these protocols into the kernel. At least the AHCI hardware which I'm familiar with, has no need to know anything about the protocol. It abstracts everything into just a message. So, the design that I did in this patch does the same thing. You export the type of protocol the driver is configured to accept, then the message buffer and leave it up to user space to understand the individual protocol. This works for all supported EM protocols. As far as I can see, most of these management protocols are better suited to being implemented in user space anyway.

It's one way to look at it, if we go with SFF-8485 and the AHCI specific protocol. Basically both of them are only about flashing LEDs. The SAF-TE and SES protocols are much more comprehensive (and include things like environmental monitors, temperature, fans, etc.).

Quoted 9 lines
Quoted 2 lines

Even these though can be boiled down to read a message/write a message.

That's true of almost every protocol in the end. I was thinking of the abstraction. The messages lead to flashing lights in the enclosures. They also have interactive knobs that users twiddle on the other end. We really need a uniform user interface abstraction for enclosures.

Quoted 3 lines

I guess I'm still not seeing why this abstraction needs to be in the kernel. Why can't it be a user space library with a generic buffer to send/receive messages.

OK, code demonstrates better I suppose. Here's an enclosure abstraction that manifests correctly in sysfs and should allow us all (AHCI, SGPIO and SES) to play in the same sandbox.

James

---

Quoted 1 line

From c4d1deff6105831ec7d71641aeb74b945474fef2 Mon Sep 17 00:00:00 2001

From: James Bottomley <[email protected]>
Date: Sun, 20 Jan 2008 07:34:58 -0600
Subject: [SCSI] enclosure: add support for enclosure services

The enclosure misc device is really just a library providing sysfs support for physical enclosure devices and their components.

---
 drivers/misc/Kconfig      |   10 +
 drivers/misc/Makefile     |    1 +
 drivers/misc/enclosure.c  |  409 +++++++++++++++++++++++++++++++++++++++++++++
 include/linux/enclosure.h |  116 +++++++++++++
 4 files changed, 536 insertions(+), 0 deletions(-)
 create mode 100644 drivers/misc/enclosure.c
 create mode 100644 include/linux/enclosure.h
drivers/misc/Kconfig +10 -0
index b5e67c0..c6e5c09 100644
@@ -11,6 +11,7 @@ menuconfig MISC_DEVICES
 
 	  If you say N, all options in this submenu will be skipped and disabled.
 
+
 if MISC_DEVICES
 
 config IBM_ASM
@@ -232,4 +233,13 @@ config ATMEL_SSC
 
 	  If unsure, say N.
 
+config ENCLOSURE_SERVICES
+	tristate "Enclosure Services"
+	default n
+	help
+	  Provides support for intelligent enclosures (bays which
+	  contain storage devices).  You also need either a host
+	  driver (SCSI/ATA) which supports enclosures
+	  or a SCSI enclosure device (SES) to use these services.
+
 endif # MISC_DEVICES
drivers/misc/Makefile +1 -0
index 87f2685..de9f1f5 100644
@@ -17,3 +17,4 @@ obj-$(CONFIG_SONY_LAPTOP)	+= sony-laptop.o
 obj-$(CONFIG_THINKPAD_ACPI)	+= thinkpad_acpi.o
 obj-$(CONFIG_FUJITSU_LAPTOP)	+= fujitsu-laptop.o
 obj-$(CONFIG_EEPROM_93CX6)	+= eeprom_93cx6.o
+obj-$(CONFIG_ENCLOSURE_SERVICES) += enclosure.o
\ No newline at end of file
drivers/misc/enclosure.c new file +409 -0

409 lines not on this page · raw message

include/linux/enclosure.h new file +116 -0

116 lines not on this page · raw message

Signature · 1 line
1.5.3.8