Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

James Smart and committed by
Christoph Hellwig
ac7fe82b 44c6ec77

+40 -2
+31
drivers/nvme/host/fc.c
··· 45 45 46 46 #define NVMEFC_QUEUE_DELAY 3 /* ms units */ 47 47 48 + #define NVME_FC_DEFAULT_DEV_LOSS_TMO 60 /* seconds */ 49 + 48 50 struct nvme_fc_queue { 49 51 struct nvme_fc_ctrl *ctrl; 50 52 struct device *dev; ··· 587 585 newrec->remoteport.port_id = pinfo->port_id; 588 586 newrec->remoteport.port_state = FC_OBJSTATE_ONLINE; 589 587 newrec->remoteport.port_num = idx; 588 + /* a registration value of dev_loss_tmo=0 results in the default */ 589 + if (pinfo->dev_loss_tmo) 590 + newrec->remoteport.dev_loss_tmo = pinfo->dev_loss_tmo; 591 + else 592 + newrec->remoteport.dev_loss_tmo = NVME_FC_DEFAULT_DEV_LOSS_TMO; 590 593 591 594 spin_lock_irqsave(&nvme_fc_lock, flags); 592 595 list_add_tail(&newrec->endp_list, &lport->endp_list); ··· 694 687 nvme_fc_signal_discovery_scan(rport->lport, rport); 695 688 } 696 689 EXPORT_SYMBOL_GPL(nvme_fc_rescan_remoteport); 690 + 691 + int 692 + nvme_fc_set_remoteport_devloss(struct nvme_fc_remote_port *portptr, 693 + u32 dev_loss_tmo) 694 + { 695 + struct nvme_fc_rport *rport = remoteport_to_rport(portptr); 696 + struct nvme_fc_ctrl *ctrl; 697 + unsigned long flags; 698 + 699 + spin_lock_irqsave(&rport->lock, flags); 700 + 701 + if (portptr->port_state != FC_OBJSTATE_ONLINE) { 702 + spin_unlock_irqrestore(&rport->lock, flags); 703 + return -EINVAL; 704 + } 705 + 706 + /* a dev_loss_tmo of 0 (immediate) is allowed to be set */ 707 + rport->remoteport.dev_loss_tmo = dev_loss_tmo; 708 + 709 + spin_unlock_irqrestore(&rport->lock, flags); 710 + 711 + return 0; 712 + } 713 + EXPORT_SYMBOL_GPL(nvme_fc_set_remoteport_devloss); 697 714 698 715 699 716 /* *********************** FC-NVME DMA Handling **************************** */
+9 -2
include/linux/nvme-fc-driver.h
··· 40 40 * @node_name: FC WWNN for the port 41 41 * @port_name: FC WWPN for the port 42 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 46 * Initialization values for dynamic port fields: 45 47 * @port_id: FC N_Port_ID currently assigned the port. Upper 8 bits must ··· 52 50 u64 port_name; 53 51 u32 port_role; 54 52 u32 port_id; 53 + u32 dev_loss_tmo; 55 54 }; 56 55 57 56 ··· 203 200 * The length of the buffer corresponds to the local_priv_sz 204 201 * value specified in the nvme_fc_port_template supplied by 205 202 * the LLDD. 203 + * @dev_loss_tmo: maximum delay for reconnects to an association on 204 + * this device. To modify, lldd must call 205 + * nvme_fc_set_remoteport_devloss(). 206 206 * 207 207 * Fields with dynamic values. Values may change base on link state. LLDD 208 208 * may reference fields directly to change them. Initialized by the ··· 263 257 u32 port_role; 264 258 u64 node_name; 265 259 u64 port_name; 266 - 267 260 struct nvme_fc_local_port *localport; 268 - 269 261 void *private; 262 + u32 dev_loss_tmo; 270 263 271 264 /* dynamic fields */ 272 265 u32 port_id; ··· 451 446 452 447 void nvme_fc_rescan_remoteport(struct nvme_fc_remote_port *remoteport); 453 448 449 + int nvme_fc_set_remoteport_devloss(struct nvme_fc_remote_port *remoteport, 450 + u32 dev_loss_tmo); 454 451 455 452 456 453 /*