diff options
author | James Smart <James.Smart@Emulex.Com> | 2006-08-17 08:00:43 -0400 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.il.steeleye.com> | 2006-08-19 16:43:10 -0400 |
commit | b8d08210126a7b769b857720a59721a453a57a1e (patch) | |
tree | d68487391ade14febcce5894e8e16d75e4224d4b | |
parent | f3d7271c5ac9029d19fc0252a85bc045334382cc (diff) |
[SCSI] fc transport: add fc_host system_hostname attribute and u64_to_wwn()
This patch updates the fc transport for the following:
- Addition of a new attribute "system_hostname" which can be
used to set the fully qualified hostname that the fc_host
is attached to. The fc_host can then register this string
as the FDMI-based host name attribute.
Note: for NPIV, a fc_host could be associated with a system which
is not the local system.
- Add the inline function u64_to_wwn(), which is the inverse of the
existing wwn_to_u64() function.
- Slight reorg, just to keep dynamic attributes with each other, etc
Signed-off-by: James Smart <James.Smart@emulex.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
-rw-r--r-- | drivers/scsi/scsi_transport_fc.c | 30 | ||||
-rw-r--r-- | include/scsi/scsi_transport_fc.h | 38 |
2 files changed, 55 insertions, 13 deletions
diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c index c1c5cdffca38..79d31ca2b741 100644 --- a/drivers/scsi/scsi_transport_fc.c +++ b/drivers/scsi/scsi_transport_fc.c | |||
@@ -301,8 +301,6 @@ static int fc_host_setup(struct transport_container *tc, struct device *dev, | |||
301 | fc_host->supported_classes = FC_COS_UNSPECIFIED; | 301 | fc_host->supported_classes = FC_COS_UNSPECIFIED; |
302 | memset(fc_host->supported_fc4s, 0, | 302 | memset(fc_host->supported_fc4s, 0, |
303 | sizeof(fc_host->supported_fc4s)); | 303 | sizeof(fc_host->supported_fc4s)); |
304 | memset(fc_host->symbolic_name, 0, | ||
305 | sizeof(fc_host->symbolic_name)); | ||
306 | fc_host->supported_speeds = FC_PORTSPEED_UNKNOWN; | 304 | fc_host->supported_speeds = FC_PORTSPEED_UNKNOWN; |
307 | fc_host->maxframe_size = -1; | 305 | fc_host->maxframe_size = -1; |
308 | memset(fc_host->serial_number, 0, | 306 | memset(fc_host->serial_number, 0, |
@@ -315,6 +313,8 @@ static int fc_host_setup(struct transport_container *tc, struct device *dev, | |||
315 | sizeof(fc_host->active_fc4s)); | 313 | sizeof(fc_host->active_fc4s)); |
316 | fc_host->speed = FC_PORTSPEED_UNKNOWN; | 314 | fc_host->speed = FC_PORTSPEED_UNKNOWN; |
317 | fc_host->fabric_name = -1; | 315 | fc_host->fabric_name = -1; |
316 | memset(fc_host->symbolic_name, 0, sizeof(fc_host->symbolic_name)); | ||
317 | memset(fc_host->system_hostname, 0, sizeof(fc_host->system_hostname)); | ||
318 | 318 | ||
319 | fc_host->tgtid_bind_type = FC_TGTID_BIND_BY_WWPN; | 319 | fc_host->tgtid_bind_type = FC_TGTID_BIND_BY_WWPN; |
320 | 320 | ||
@@ -688,6 +688,25 @@ store_fc_host_##field(struct class_device *cdev, const char *buf, \ | |||
688 | return count; \ | 688 | return count; \ |
689 | } | 689 | } |
690 | 690 | ||
691 | #define fc_host_store_str_function(field, slen) \ | ||
692 | static ssize_t \ | ||
693 | store_fc_host_##field(struct class_device *cdev, const char *buf, \ | ||
694 | size_t count) \ | ||
695 | { \ | ||
696 | struct Scsi_Host *shost = transport_class_to_shost(cdev); \ | ||
697 | struct fc_internal *i = to_fc_internal(shost->transportt); \ | ||
698 | unsigned int cnt=count; \ | ||
699 | \ | ||
700 | /* count may include a LF at end of string */ \ | ||
701 | if (buf[cnt-1] == '\n') \ | ||
702 | cnt--; \ | ||
703 | if (cnt > ((slen) - 1)) \ | ||
704 | return -EINVAL; \ | ||
705 | memcpy(fc_host_##field(shost), buf, cnt); \ | ||
706 | i->f->set_host_##field(shost); \ | ||
707 | return count; \ | ||
708 | } | ||
709 | |||
691 | #define fc_host_rd_attr(field, format_string, sz) \ | 710 | #define fc_host_rd_attr(field, format_string, sz) \ |
692 | fc_host_show_function(field, format_string, sz, ) \ | 711 | fc_host_show_function(field, format_string, sz, ) \ |
693 | static FC_CLASS_DEVICE_ATTR(host, field, S_IRUGO, \ | 712 | static FC_CLASS_DEVICE_ATTR(host, field, S_IRUGO, \ |
@@ -859,6 +878,12 @@ fc_host_rd_enum_attr(port_state, FC_PORTSTATE_MAX_NAMELEN); | |||
859 | fc_host_rd_attr_cast(fabric_name, "0x%llx\n", 20, unsigned long long); | 878 | fc_host_rd_attr_cast(fabric_name, "0x%llx\n", 20, unsigned long long); |
860 | fc_host_rd_attr(symbolic_name, "%s\n", FC_SYMBOLIC_NAME_SIZE + 1); | 879 | fc_host_rd_attr(symbolic_name, "%s\n", FC_SYMBOLIC_NAME_SIZE + 1); |
861 | 880 | ||
881 | fc_private_host_show_function(system_hostname, "%s\n", | ||
882 | FC_SYMBOLIC_NAME_SIZE + 1, ) | ||
883 | fc_host_store_str_function(system_hostname, FC_SYMBOLIC_NAME_SIZE) | ||
884 | static FC_CLASS_DEVICE_ATTR(host, system_hostname, S_IRUGO | S_IWUSR, | ||
885 | show_fc_host_system_hostname, store_fc_host_system_hostname); | ||
886 | |||
862 | 887 | ||
863 | /* Private Host Attributes */ | 888 | /* Private Host Attributes */ |
864 | 889 | ||
@@ -1234,6 +1259,7 @@ fc_attach_transport(struct fc_function_template *ft) | |||
1234 | SETUP_HOST_ATTRIBUTE_RD(speed); | 1259 | SETUP_HOST_ATTRIBUTE_RD(speed); |
1235 | SETUP_HOST_ATTRIBUTE_RD(fabric_name); | 1260 | SETUP_HOST_ATTRIBUTE_RD(fabric_name); |
1236 | SETUP_HOST_ATTRIBUTE_RD(symbolic_name); | 1261 | SETUP_HOST_ATTRIBUTE_RD(symbolic_name); |
1262 | SETUP_HOST_ATTRIBUTE_RW(system_hostname); | ||
1237 | 1263 | ||
1238 | /* Transport-managed attributes */ | 1264 | /* Transport-managed attributes */ |
1239 | SETUP_PRIVATE_HOST_ATTRIBUTE_RW(tgtid_bind_type); | 1265 | SETUP_PRIVATE_HOST_ATTRIBUTE_RW(tgtid_bind_type); |
diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h index b7f62b85f0b3..c74be5dabfeb 100644 --- a/include/scsi/scsi_transport_fc.h +++ b/include/scsi/scsi_transport_fc.h | |||
@@ -312,7 +312,6 @@ struct fc_host_attrs { | |||
312 | u64 permanent_port_name; | 312 | u64 permanent_port_name; |
313 | u32 supported_classes; | 313 | u32 supported_classes; |
314 | u8 supported_fc4s[FC_FC4_LIST_SIZE]; | 314 | u8 supported_fc4s[FC_FC4_LIST_SIZE]; |
315 | char symbolic_name[FC_SYMBOLIC_NAME_SIZE]; | ||
316 | u32 supported_speeds; | 315 | u32 supported_speeds; |
317 | u32 maxframe_size; | 316 | u32 maxframe_size; |
318 | char serial_number[FC_SERIAL_NUMBER_SIZE]; | 317 | char serial_number[FC_SERIAL_NUMBER_SIZE]; |
@@ -324,6 +323,8 @@ struct fc_host_attrs { | |||
324 | u8 active_fc4s[FC_FC4_LIST_SIZE]; | 323 | u8 active_fc4s[FC_FC4_LIST_SIZE]; |
325 | u32 speed; | 324 | u32 speed; |
326 | u64 fabric_name; | 325 | u64 fabric_name; |
326 | char symbolic_name[FC_SYMBOLIC_NAME_SIZE]; | ||
327 | char system_hostname[FC_SYMBOLIC_NAME_SIZE]; | ||
327 | 328 | ||
328 | /* Private (Transport-managed) Attributes */ | 329 | /* Private (Transport-managed) Attributes */ |
329 | enum fc_tgtid_binding_type tgtid_bind_type; | 330 | enum fc_tgtid_binding_type tgtid_bind_type; |
@@ -354,8 +355,6 @@ struct fc_host_attrs { | |||
354 | (((struct fc_host_attrs *)(x)->shost_data)->supported_classes) | 355 | (((struct fc_host_attrs *)(x)->shost_data)->supported_classes) |
355 | #define fc_host_supported_fc4s(x) \ | 356 | #define fc_host_supported_fc4s(x) \ |
356 | (((struct fc_host_attrs *)(x)->shost_data)->supported_fc4s) | 357 | (((struct fc_host_attrs *)(x)->shost_data)->supported_fc4s) |
357 | #define fc_host_symbolic_name(x) \ | ||
358 | (((struct fc_host_attrs *)(x)->shost_data)->symbolic_name) | ||
359 | #define fc_host_supported_speeds(x) \ | 358 | #define fc_host_supported_speeds(x) \ |
360 | (((struct fc_host_attrs *)(x)->shost_data)->supported_speeds) | 359 | (((struct fc_host_attrs *)(x)->shost_data)->supported_speeds) |
361 | #define fc_host_maxframe_size(x) \ | 360 | #define fc_host_maxframe_size(x) \ |
@@ -374,6 +373,10 @@ struct fc_host_attrs { | |||
374 | (((struct fc_host_attrs *)(x)->shost_data)->speed) | 373 | (((struct fc_host_attrs *)(x)->shost_data)->speed) |
375 | #define fc_host_fabric_name(x) \ | 374 | #define fc_host_fabric_name(x) \ |
376 | (((struct fc_host_attrs *)(x)->shost_data)->fabric_name) | 375 | (((struct fc_host_attrs *)(x)->shost_data)->fabric_name) |
376 | #define fc_host_symbolic_name(x) \ | ||
377 | (((struct fc_host_attrs *)(x)->shost_data)->symbolic_name) | ||
378 | #define fc_host_system_hostname(x) \ | ||
379 | (((struct fc_host_attrs *)(x)->shost_data)->system_hostname) | ||
377 | #define fc_host_tgtid_bind_type(x) \ | 380 | #define fc_host_tgtid_bind_type(x) \ |
378 | (((struct fc_host_attrs *)(x)->shost_data)->tgtid_bind_type) | 381 | (((struct fc_host_attrs *)(x)->shost_data)->tgtid_bind_type) |
379 | #define fc_host_rports(x) \ | 382 | #define fc_host_rports(x) \ |
@@ -410,6 +413,7 @@ struct fc_function_template { | |||
410 | void (*get_host_speed)(struct Scsi_Host *); | 413 | void (*get_host_speed)(struct Scsi_Host *); |
411 | void (*get_host_fabric_name)(struct Scsi_Host *); | 414 | void (*get_host_fabric_name)(struct Scsi_Host *); |
412 | void (*get_host_symbolic_name)(struct Scsi_Host *); | 415 | void (*get_host_symbolic_name)(struct Scsi_Host *); |
416 | void (*set_host_system_hostname)(struct Scsi_Host *); | ||
413 | 417 | ||
414 | struct fc_host_statistics * (*get_fc_host_stats)(struct Scsi_Host *); | 418 | struct fc_host_statistics * (*get_fc_host_stats)(struct Scsi_Host *); |
415 | void (*reset_fc_host_stats)(struct Scsi_Host *); | 419 | void (*reset_fc_host_stats)(struct Scsi_Host *); |
@@ -457,6 +461,7 @@ struct fc_function_template { | |||
457 | unsigned long show_host_speed:1; | 461 | unsigned long show_host_speed:1; |
458 | unsigned long show_host_fabric_name:1; | 462 | unsigned long show_host_fabric_name:1; |
459 | unsigned long show_host_symbolic_name:1; | 463 | unsigned long show_host_symbolic_name:1; |
464 | unsigned long show_host_system_hostname:1; | ||
460 | }; | 465 | }; |
461 | 466 | ||
462 | 467 | ||
@@ -492,6 +497,25 @@ fc_remote_port_chkready(struct fc_rport *rport) | |||
492 | return result; | 497 | return result; |
493 | } | 498 | } |
494 | 499 | ||
500 | static inline u64 wwn_to_u64(u8 *wwn) | ||
501 | { | ||
502 | return (u64)wwn[0] << 56 | (u64)wwn[1] << 48 | | ||
503 | (u64)wwn[2] << 40 | (u64)wwn[3] << 32 | | ||
504 | (u64)wwn[4] << 24 | (u64)wwn[5] << 16 | | ||
505 | (u64)wwn[6] << 8 | (u64)wwn[7]; | ||
506 | } | ||
507 | |||
508 | static inline void u64_to_wwn(u64 inm, u8 *wwn) | ||
509 | { | ||
510 | wwn[0] = (inm >> 56) & 0xff; | ||
511 | wwn[1] = (inm >> 48) & 0xff; | ||
512 | wwn[2] = (inm >> 40) & 0xff; | ||
513 | wwn[3] = (inm >> 32) & 0xff; | ||
514 | wwn[4] = (inm >> 24) & 0xff; | ||
515 | wwn[5] = (inm >> 16) & 0xff; | ||
516 | wwn[6] = (inm >> 8) & 0xff; | ||
517 | wwn[7] = inm & 0xff; | ||
518 | } | ||
495 | 519 | ||
496 | struct scsi_transport_template *fc_attach_transport( | 520 | struct scsi_transport_template *fc_attach_transport( |
497 | struct fc_function_template *); | 521 | struct fc_function_template *); |
@@ -503,12 +527,4 @@ void fc_remote_port_delete(struct fc_rport *rport); | |||
503 | void fc_remote_port_rolechg(struct fc_rport *rport, u32 roles); | 527 | void fc_remote_port_rolechg(struct fc_rport *rport, u32 roles); |
504 | int scsi_is_fc_rport(const struct device *); | 528 | int scsi_is_fc_rport(const struct device *); |
505 | 529 | ||
506 | static inline u64 wwn_to_u64(u8 *wwn) | ||
507 | { | ||
508 | return (u64)wwn[0] << 56 | (u64)wwn[1] << 48 | | ||
509 | (u64)wwn[2] << 40 | (u64)wwn[3] << 32 | | ||
510 | (u64)wwn[4] << 24 | (u64)wwn[5] << 16 | | ||
511 | (u64)wwn[6] << 8 | (u64)wwn[7]; | ||
512 | } | ||
513 | |||
514 | #endif /* SCSI_TRANSPORT_FC_H */ | 530 | #endif /* SCSI_TRANSPORT_FC_H */ |