aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorFUJITA Tomonori <tomof@acm.org>2007-08-31 13:02:20 -0400
committerJames Bottomley <jejb@mulgrave.localdomain>2007-10-12 14:46:55 -0400
commit5dc2b89e124251662f580f4ba3c9f6195d1eaff6 (patch)
treea20051d208547da30b9e66ed3746d8a7237c289a /drivers
parent8184fe9b6e8928c8d5be3e2a1326b8b9183e409d (diff)
[SCSI] add supported_mode and active_mode attributes to the host
This adds supported_mode and active_mode attributes to /sys/class/sys_host/hostX/ for specifying the mode that a lld supports and the currently activated mode. The output format is similar to fc rport roles: luce:/sys/class/scsi_host/host0$ cat supported_mode Initiator luce:/sys/class/scsi_host/host0$ cat active_mode Initiator The mode values uses bitmap since we would support dual-mode llds in the future like this: luce:/sys/class/scsi_host/host0$ cat supported_mode Initiator, Target The supported_mode attribute looks at a scsi_host_template and the active_mode attribute looks at a scsi_host. We would add a hook to a scsi_host_template to change the active_mode attribute dynamically. But now there is no hook since no lld supports that feature. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Signed-off-by: Mike Christie <michaelc@cs.wisc.edu> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/scsi/hosts.c1
-rw-r--r--drivers/scsi/scsi_sysfs.c42
2 files changed, 43 insertions, 0 deletions
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 96bc31266c98..adc9559cb6f4 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -342,6 +342,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
342 shost->unchecked_isa_dma = sht->unchecked_isa_dma; 342 shost->unchecked_isa_dma = sht->unchecked_isa_dma;
343 shost->use_clustering = sht->use_clustering; 343 shost->use_clustering = sht->use_clustering;
344 shost->ordered_tag = sht->ordered_tag; 344 shost->ordered_tag = sht->ordered_tag;
345 shost->active_mode = sht->supported_mode;
345 346
346 if (sht->max_host_blocked) 347 if (sht->max_host_blocked)
347 shost->max_host_blocked = sht->max_host_blocked; 348 shost->max_host_blocked = sht->max_host_blocked;
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 34cdce6738a6..a3d227f3f520 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -190,6 +190,46 @@ show_shost_state(struct class_device *class_dev, char *buf)
190 190
191static CLASS_DEVICE_ATTR(state, S_IRUGO | S_IWUSR, show_shost_state, store_shost_state); 191static CLASS_DEVICE_ATTR(state, S_IRUGO | S_IWUSR, show_shost_state, store_shost_state);
192 192
193static ssize_t
194show_shost_mode(unsigned int mode, char *buf)
195{
196 ssize_t len = 0;
197
198 if (mode & MODE_INITIATOR)
199 len = sprintf(buf, "%s", "Initiator");
200
201 if (mode & MODE_TARGET)
202 len += sprintf(buf + len, "%s%s", len ? ", " : "", "Target");
203
204 len += sprintf(buf + len, "\n");
205
206 return len;
207}
208
209static ssize_t show_shost_supported_mode(struct class_device *class_dev, char *buf)
210{
211 struct Scsi_Host *shost = class_to_shost(class_dev);
212
213 if (shost->hostt->supported_mode == MODE_UNKNOWN)
214 return snprintf(buf, 20, "unknown\n");
215 else
216 return show_shost_mode(shost->hostt->supported_mode, buf);
217}
218
219static CLASS_DEVICE_ATTR(supported_mode, S_IRUGO | S_IWUSR, show_shost_supported_mode, NULL);
220
221static ssize_t show_shost_active_mode(struct class_device *class_dev, char *buf)
222{
223 struct Scsi_Host *shost = class_to_shost(class_dev);
224
225 if (shost->active_mode == MODE_UNKNOWN)
226 return snprintf(buf, 20, "unknown\n");
227 else
228 return show_shost_mode(shost->active_mode, buf);
229}
230
231static CLASS_DEVICE_ATTR(active_mode, S_IRUGO | S_IWUSR, show_shost_active_mode, NULL);
232
193shost_rd_attr(unique_id, "%u\n"); 233shost_rd_attr(unique_id, "%u\n");
194shost_rd_attr(host_busy, "%hu\n"); 234shost_rd_attr(host_busy, "%hu\n");
195shost_rd_attr(cmd_per_lun, "%hd\n"); 235shost_rd_attr(cmd_per_lun, "%hd\n");
@@ -208,6 +248,8 @@ static struct class_device_attribute *scsi_sysfs_shost_attrs[] = {
208 &class_device_attr_proc_name, 248 &class_device_attr_proc_name,
209 &class_device_attr_scan, 249 &class_device_attr_scan,
210 &class_device_attr_state, 250 &class_device_attr_state,
251 &class_device_attr_supported_mode,
252 &class_device_attr_active_mode,
211 NULL 253 NULL
212}; 254};
213 255