diff --git a/srpt/README b/srpt/README index 9b5888385..c63404af4 100644 --- a/srpt/README +++ b/srpt/README @@ -184,6 +184,74 @@ the disk names assigned on the SCST target ("disk01" in the example below): [8:0:0:0] disk SCST_FIO disk01 102 /dev/sdb +Target names +------------ + +The name assigned by the ib_srpt target driver to an SCST target is the node +GUID of a HCA in hexadecimal form with a colon after every fourth digit. The +HCA node GUIDs can be obtained via the ibv_devices command, the ibv_devinfo +command or via sysfs. An example: + +# ibv_devices + device node GUID + ------ ---------------- + mlx4_1 0002c9030003cca2 + mlx4_0 0002c9030005f34e + +# head /sys/devices/*/*/*/infiniband/*/node_guid +==> /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/infiniband/mlx4_0/node_guid <== +0002:c903:0005:f34e + +==> /sys/devices/pci0000:00/0000:00:1c.0/0000:05:00.0/infiniband/mlx4_1/node_guid <== +0002:c903:0003:cca2 + +Once the ib_srpt driver has been loaded there will be SCST targets available +with the HCA node GUID as name: + +# ls /sys/bus/scst_target/drivers/ib_srpt/0* +0002:c903:0003:cca2 0002:c903:0005:f34e + +If you need deprecated target names in form ib_srpt_target_X, you should +set use_node_guid_in_target_name parameter of module ib_srpt to 0. + + +Session names +------------- + +The ib_srpt target driver uses the 128-bit SRP initiator port identifier for +the session name. This identifier is sent by the SRP initiator to the SRP +target via the SRP_LOGIN_REQ information unit. The Linux SRP initiator +(ib_srp) generates the initiator port identifier as follows: +- The first eight bytes are the identifier extension ('initiator_ext' parameter + specified in the login string echoed into the sysfs file 'add_target'). +- The last eight bytes are the GUID of the initiator HCA port used to + communicate with the target. + +An example: + +[ INITIATOR ] + +$ for f in /sys/devices/*/*/*/infiniband/*/ports/*/gids/0; do echo +f; cat $f | cut -c21-; done +/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/infiniband/mlx4_0/ports/1/gids/0 +0002:c903:0005:f34b +/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/infiniband/mlx4_0/ports/2/gids/0 +0002:c903:0005:f34c +/sys/devices/pci0000:00/0000:00:1c.0/0000:05:00.0/infiniband/mlx4_1/ports/1/gids/0 +0002:c903:0003:cca7 +/sys/devices/pci0000:00/0000:00:1c.0/0000:05:00.0/infiniband/mlx4_1/ports/2/gids/0 +0002:c903:0003:cca8 + +[ TARGET, after login ] + +$ ls /sys/bus/scst_target/drivers/ib_srpt/*/sessions +/sys/bus/scst_target/drivers/ib_srpt/0002:c903:0003:cca2/sessions: +0x00000000000000000002c9030003cca7 + +/sys/bus/scst_target/drivers/ib_srpt/0002:c903:0005:f34e/sessions: +0x00000000000000000002c9030005f34b + + High availability ----------------- diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index 61194c35a..7872e7cf8 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -144,6 +144,16 @@ MODULE_PARM_DESC(use_port_guid_in_session_name, "Use target port ID in the SCST session name such that" " redundant paths between multiport systems can be masked."); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31) \ + || defined(RHEL_MAJOR) && RHEL_MAJOR -0 <= 5 +static int use_node_guid_in_target_name; +#else +static bool use_node_guid_in_target_name; +#endif +module_param(use_node_guid_in_target_name, bool, 0444); +MODULE_PARM_DESC(use_node_guid_in_target_name, + "Use target node GUIDs of HCAs as SCST target names."); + static int srpt_get_u64_x(char *buffer, struct kernel_param *kp) { return sprintf(buffer, "0x%016llx", *(u64 *)kp->arg); @@ -3524,6 +3534,7 @@ static void srpt_add_one(struct ib_device *device) struct srpt_device *sdev; struct srpt_port *sport; struct ib_srq_init_attr srq_attr; + char tgt_name[24]; int i; TRACE_ENTRY(); @@ -3538,7 +3549,15 @@ static void srpt_add_one(struct ib_device *device) INIT_LIST_HEAD(&sdev->rch_list); spin_lock_init(&sdev->spinlock); - sdev->scst_tgt = scst_register_target(&srpt_template, NULL); + if (use_node_guid_in_target_name) { + snprintf(tgt_name, sizeof(tgt_name), "%04x:%04x:%04x:%04x", + be16_to_cpu(((__be16 *)&device->node_guid)[0]), + be16_to_cpu(((__be16 *)&device->node_guid)[1]), + be16_to_cpu(((__be16 *)&device->node_guid)[2]), + be16_to_cpu(((__be16 *)&device->node_guid)[3])); + sdev->scst_tgt = scst_register_target(&srpt_template, tgt_name); + } else + sdev->scst_tgt = scst_register_target(&srpt_template, NULL); if (!sdev->scst_tgt) { PRINT_ERROR("SCST registration failed for %s.", sdev->device->name); @@ -3861,6 +3880,14 @@ static int __init srpt_init_module(void) goto out; } + if (!use_node_guid_in_target_name) + PRINT_WARNING("%s", "Usage of HCA numbers as SCST target names " + "is deprecated and will be removed in one of the next " + "versions. It is strongly recommended to set " + "use_node_guid_in_target_name parameter in 1 and " + "update your SCST config file accordingly to use HCAs " + "GUIDs."); + #ifdef CONFIG_SCST_PROC ret = class_register(&srpt_class); if (ret) {