diff options
author | James Smart <jsmart2021@gmail.com> | 2017-10-25 19:43:15 -0400 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2017-11-01 11:34:36 -0400 |
commit | ac7fe82b6fcf77e757e88005c33b8147c1b7b73f (patch) | |
tree | 8ccc6d6e46b7e3cda20f238ed0974a127a3258ed | |
parent | 44c6ec77e12c387aaba420b30a54b94966f0d9e8 (diff) |
nvme-fc: add a dev_loss_tmo field to the remoteport
Add a dev_loss_tmo value, paralleling the SCSI FC transport, for device
connectivity loss.
The transport initializes the value in the nvme_fc_register_remoteport()
call. If the value is not set, a default of 60s is set.
Add a new routine to the api, nvme_fc_set_remoteport_devloss() routine,
which allows the lldd to dynamically update the value on an existing
remoteport.
Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
-rw-r--r-- | drivers/nvme/host/fc.c | 31 | ||||
-rw-r--r-- | include/linux/nvme-fc-driver.h | 11 |
2 files changed, 40 insertions, 2 deletions
diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c index e37c69f7921d..25479d3031fa 100644 --- a/drivers/nvme/host/fc.c +++ b/drivers/nvme/host/fc.c | |||
@@ -45,6 +45,8 @@ enum nvme_fc_queue_flags { | |||
45 | 45 | ||
46 | #define NVMEFC_QUEUE_DELAY 3 /* ms units */ | 46 | #define NVMEFC_QUEUE_DELAY 3 /* ms units */ |
47 | 47 | ||
48 | #define NVME_FC_DEFAULT_DEV_LOSS_TMO 60 /* seconds */ | ||
49 | |||
48 | struct nvme_fc_queue { | 50 | struct nvme_fc_queue { |
49 | struct nvme_fc_ctrl *ctrl; | 51 | struct nvme_fc_ctrl *ctrl; |
50 | struct device *dev; | 52 | struct device *dev; |
@@ -585,6 +587,11 @@ nvme_fc_register_remoteport(struct nvme_fc_local_port *localport, | |||
585 | newrec->remoteport.port_id = pinfo->port_id; | 587 | newrec->remoteport.port_id = pinfo->port_id; |
586 | newrec->remoteport.port_state = FC_OBJSTATE_ONLINE; | 588 | newrec->remoteport.port_state = FC_OBJSTATE_ONLINE; |
587 | newrec->remoteport.port_num = idx; | 589 | newrec->remoteport.port_num = idx; |
590 | /* a registration value of dev_loss_tmo=0 results in the default */ | ||
591 | if (pinfo->dev_loss_tmo) | ||
592 | newrec->remoteport.dev_loss_tmo = pinfo->dev_loss_tmo; | ||
593 | else | ||
594 | newrec->remoteport.dev_loss_tmo = NVME_FC_DEFAULT_DEV_LOSS_TMO; | ||
588 | 595 | ||
589 | spin_lock_irqsave(&nvme_fc_lock, flags); | 596 | spin_lock_irqsave(&nvme_fc_lock, flags); |
590 | list_add_tail(&newrec->endp_list, &lport->endp_list); | 597 | list_add_tail(&newrec->endp_list, &lport->endp_list); |
@@ -688,6 +695,30 @@ nvme_fc_rescan_remoteport(struct nvme_fc_remote_port *remoteport) | |||
688 | } | 695 | } |
689 | EXPORT_SYMBOL_GPL(nvme_fc_rescan_remoteport); | 696 | EXPORT_SYMBOL_GPL(nvme_fc_rescan_remoteport); |
690 | 697 | ||
698 | int | ||
699 | nvme_fc_set_remoteport_devloss(struct nvme_fc_remote_port *portptr, | ||
700 | u32 dev_loss_tmo) | ||
701 | { | ||
702 | struct nvme_fc_rport *rport = remoteport_to_rport(portptr); | ||
703 | struct nvme_fc_ctrl *ctrl; | ||
704 | unsigned long flags; | ||
705 | |||
706 | spin_lock_irqsave(&rport->lock, flags); | ||
707 | |||
708 | if (portptr->port_state != FC_OBJSTATE_ONLINE) { | ||
709 | spin_unlock_irqrestore(&rport->lock, flags); | ||
710 | return -EINVAL; | ||
711 | } | ||
712 | |||
713 | /* a dev_loss_tmo of 0 (immediate) is allowed to be set */ | ||
714 | rport->remoteport.dev_loss_tmo = dev_loss_tmo; | ||
715 | |||
716 | spin_unlock_irqrestore(&rport->lock, flags); | ||
717 | |||
718 | return 0; | ||
719 | } | ||
720 | EXPORT_SYMBOL_GPL(nvme_fc_set_remoteport_devloss); | ||
721 | |||
691 | 722 | ||
692 | /* *********************** FC-NVME DMA Handling **************************** */ | 723 | /* *********************** FC-NVME DMA Handling **************************** */ |
693 | 724 | ||
diff --git a/include/linux/nvme-fc-driver.h b/include/linux/nvme-fc-driver.h index 2be4db353937..496ff759f84c 100644 --- a/include/linux/nvme-fc-driver.h +++ b/include/linux/nvme-fc-driver.h | |||
@@ -40,6 +40,8 @@ | |||
40 | * @node_name: FC WWNN for the port | 40 | * @node_name: FC WWNN for the port |
41 | * @port_name: FC WWPN for the port | 41 | * @port_name: FC WWPN for the port |
42 | * @port_role: What NVME roles are supported (see FC_PORT_ROLE_xxx) | 42 | * @port_role: What NVME roles are supported (see FC_PORT_ROLE_xxx) |
43 | * @dev_loss_tmo: maximum delay for reconnects to an association on | ||
44 | * this device. Used only on a remoteport. | ||
43 | * | 45 | * |
44 | * Initialization values for dynamic port fields: | 46 | * Initialization values for dynamic port fields: |
45 | * @port_id: FC N_Port_ID currently assigned the port. Upper 8 bits must | 47 | * @port_id: FC N_Port_ID currently assigned the port. Upper 8 bits must |
@@ -50,6 +52,7 @@ struct nvme_fc_port_info { | |||
50 | u64 port_name; | 52 | u64 port_name; |
51 | u32 port_role; | 53 | u32 port_role; |
52 | u32 port_id; | 54 | u32 port_id; |
55 | u32 dev_loss_tmo; | ||
53 | }; | 56 | }; |
54 | 57 | ||
55 | 58 | ||
@@ -200,6 +203,9 @@ enum nvme_fc_obj_state { | |||
200 | * The length of the buffer corresponds to the local_priv_sz | 203 | * The length of the buffer corresponds to the local_priv_sz |
201 | * value specified in the nvme_fc_port_template supplied by | 204 | * value specified in the nvme_fc_port_template supplied by |
202 | * the LLDD. | 205 | * the LLDD. |
206 | * @dev_loss_tmo: maximum delay for reconnects to an association on | ||
207 | * this device. To modify, lldd must call | ||
208 | * nvme_fc_set_remoteport_devloss(). | ||
203 | * | 209 | * |
204 | * Fields with dynamic values. Values may change base on link state. LLDD | 210 | * Fields with dynamic values. Values may change base on link state. LLDD |
205 | * may reference fields directly to change them. Initialized by the | 211 | * may reference fields directly to change them. Initialized by the |
@@ -257,10 +263,9 @@ struct nvme_fc_remote_port { | |||
257 | u32 port_role; | 263 | u32 port_role; |
258 | u64 node_name; | 264 | u64 node_name; |
259 | u64 port_name; | 265 | u64 port_name; |
260 | |||
261 | struct nvme_fc_local_port *localport; | 266 | struct nvme_fc_local_port *localport; |
262 | |||
263 | void *private; | 267 | void *private; |
268 | u32 dev_loss_tmo; | ||
264 | 269 | ||
265 | /* dynamic fields */ | 270 | /* dynamic fields */ |
266 | u32 port_id; | 271 | u32 port_id; |
@@ -446,6 +451,8 @@ int nvme_fc_unregister_remoteport(struct nvme_fc_remote_port *remoteport); | |||
446 | 451 | ||
447 | void nvme_fc_rescan_remoteport(struct nvme_fc_remote_port *remoteport); | 452 | void nvme_fc_rescan_remoteport(struct nvme_fc_remote_port *remoteport); |
448 | 453 | ||
454 | int nvme_fc_set_remoteport_devloss(struct nvme_fc_remote_port *remoteport, | ||
455 | u32 dev_loss_tmo); | ||
449 | 456 | ||
450 | 457 | ||
451 | /* | 458 | /* |