aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/ulp
diff options
context:
space:
mode:
authorRoland Dreier <rolandd@cisco.com>2006-03-20 13:08:23 -0500
committerRoland Dreier <rolandd@cisco.com>2006-03-20 13:08:23 -0500
commit6ecb0c849625e830ab96495d473bb704812c30e1 (patch)
tree7f482334cd05121ed96f8c17353f8a6ae73a85f9 /drivers/infiniband/ulp
parent87fd1a11ae91ab42fac978467667c61fee9f01da (diff)
IB/srp: Add SCSI host attributes to show target port
Add SCSI host attributes in sysfs that show the ID extension, IOC GUID, service ID, P_Key and destination GID for each target port that the SRP initiator connects to. Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband/ulp')
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.c84
1 files changed, 83 insertions, 1 deletions
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index 960dae5c87d1..89ad29dc88d4 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -1237,6 +1237,87 @@ static int srp_reset_host(struct scsi_cmnd *scmnd)
1237 return ret; 1237 return ret;
1238} 1238}
1239 1239
1240static ssize_t show_id_ext(struct class_device *cdev, char *buf)
1241{
1242 struct srp_target_port *target = host_to_target(class_to_shost(cdev));
1243
1244 if (target->state == SRP_TARGET_DEAD ||
1245 target->state == SRP_TARGET_REMOVED)
1246 return -ENODEV;
1247
1248 return sprintf(buf, "0x%016llx\n",
1249 (unsigned long long) be64_to_cpu(target->id_ext));
1250}
1251
1252static ssize_t show_ioc_guid(struct class_device *cdev, char *buf)
1253{
1254 struct srp_target_port *target = host_to_target(class_to_shost(cdev));
1255
1256 if (target->state == SRP_TARGET_DEAD ||
1257 target->state == SRP_TARGET_REMOVED)
1258 return -ENODEV;
1259
1260 return sprintf(buf, "0x%016llx\n",
1261 (unsigned long long) be64_to_cpu(target->ioc_guid));
1262}
1263
1264static ssize_t show_service_id(struct class_device *cdev, char *buf)
1265{
1266 struct srp_target_port *target = host_to_target(class_to_shost(cdev));
1267
1268 if (target->state == SRP_TARGET_DEAD ||
1269 target->state == SRP_TARGET_REMOVED)
1270 return -ENODEV;
1271
1272 return sprintf(buf, "0x%016llx\n",
1273 (unsigned long long) be64_to_cpu(target->service_id));
1274}
1275
1276static ssize_t show_pkey(struct class_device *cdev, char *buf)
1277{
1278 struct srp_target_port *target = host_to_target(class_to_shost(cdev));
1279
1280 if (target->state == SRP_TARGET_DEAD ||
1281 target->state == SRP_TARGET_REMOVED)
1282 return -ENODEV;
1283
1284 return sprintf(buf, "0x%04x\n", be16_to_cpu(target->path.pkey));
1285}
1286
1287static ssize_t show_dgid(struct class_device *cdev, char *buf)
1288{
1289 struct srp_target_port *target = host_to_target(class_to_shost(cdev));
1290
1291 if (target->state == SRP_TARGET_DEAD ||
1292 target->state == SRP_TARGET_REMOVED)
1293 return -ENODEV;
1294
1295 return sprintf(buf, "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
1296 be16_to_cpu(((__be16 *) target->path.dgid.raw)[0]),
1297 be16_to_cpu(((__be16 *) target->path.dgid.raw)[1]),
1298 be16_to_cpu(((__be16 *) target->path.dgid.raw)[2]),
1299 be16_to_cpu(((__be16 *) target->path.dgid.raw)[3]),
1300 be16_to_cpu(((__be16 *) target->path.dgid.raw)[4]),
1301 be16_to_cpu(((__be16 *) target->path.dgid.raw)[5]),
1302 be16_to_cpu(((__be16 *) target->path.dgid.raw)[6]),
1303 be16_to_cpu(((__be16 *) target->path.dgid.raw)[7]));
1304}
1305
1306static CLASS_DEVICE_ATTR(id_ext, S_IRUGO, show_id_ext, NULL);
1307static CLASS_DEVICE_ATTR(ioc_guid, S_IRUGO, show_ioc_guid, NULL);
1308static CLASS_DEVICE_ATTR(service_id, S_IRUGO, show_service_id, NULL);
1309static CLASS_DEVICE_ATTR(pkey, S_IRUGO, show_pkey, NULL);
1310static CLASS_DEVICE_ATTR(dgid, S_IRUGO, show_dgid, NULL);
1311
1312static struct class_device_attribute *srp_host_attrs[] = {
1313 &class_device_attr_id_ext,
1314 &class_device_attr_ioc_guid,
1315 &class_device_attr_service_id,
1316 &class_device_attr_pkey,
1317 &class_device_attr_dgid,
1318 NULL
1319};
1320
1240static struct scsi_host_template srp_template = { 1321static struct scsi_host_template srp_template = {
1241 .module = THIS_MODULE, 1322 .module = THIS_MODULE,
1242 .name = DRV_NAME, 1323 .name = DRV_NAME,
@@ -1249,7 +1330,8 @@ static struct scsi_host_template srp_template = {
1249 .this_id = -1, 1330 .this_id = -1,
1250 .sg_tablesize = SRP_MAX_INDIRECT, 1331 .sg_tablesize = SRP_MAX_INDIRECT,
1251 .cmd_per_lun = SRP_SQ_SIZE, 1332 .cmd_per_lun = SRP_SQ_SIZE,
1252 .use_clustering = ENABLE_CLUSTERING 1333 .use_clustering = ENABLE_CLUSTERING,
1334 .shost_attrs = srp_host_attrs
1253}; 1335};
1254 1336
1255static int srp_add_target(struct srp_host *host, struct srp_target_port *target) 1337static int srp_add_target(struct srp_host *host, struct srp_target_port *target)