lpfc_attr.c
来自「linux 内核源代码」· C语言 代码 · 共 2,217 行 · 第 1/5 页
C
2,217 行
} vport->cfg_restrict_login = val; return 0;}lpfc_vport_param_store(restrict_login);static CLASS_DEVICE_ATTR(lpfc_restrict_login, S_IRUGO | S_IWUSR, lpfc_restrict_login_show, lpfc_restrict_login_store);/*# Some disk devices have a "select ID" or "select Target" capability.# From a protocol standpoint "select ID" usually means select the# Fibre channel "ALPA". In the FC-AL Profile there is an "informative# annex" which contains a table that maps a "select ID" (a number# between 0 and 7F) to an ALPA. By default, for compatibility with# older drivers, the lpfc driver scans this table from low ALPA to high# ALPA.## Turning on the scan-down variable (on = 1, off = 0) will# cause the lpfc driver to use an inverted table, effectively# scanning ALPAs from high to low. Value range is [0,1]. Default value is 1.## (Note: This "select ID" functionality is a LOOP ONLY characteristic# and will not work across a fabric. Also this parameter will take# effect only in the case when ALPA map is not available.)*/LPFC_VPORT_ATTR_R(scan_down, 1, 0, 1, "Start scanning for devices from highest ALPA to lowest");/*# lpfc_topology: link topology for init link# 0x0 = attempt loop mode then point-to-point# 0x01 = internal loopback mode# 0x02 = attempt point-to-point mode only# 0x04 = attempt loop mode only# 0x06 = attempt point-to-point mode then loop# Set point-to-point mode if you want to run as an N_Port.# Set loop mode if you want to run as an NL_Port. Value range is [0,0x6].# Default value is 0.*/LPFC_ATTR_RW(topology, 0, 0, 6, "Select Fibre Channel topology");/*# lpfc_link_speed: Link speed selection for initializing the Fibre Channel# connection.# 0 = auto select (default)# 1 = 1 Gigabaud# 2 = 2 Gigabaud# 4 = 4 Gigabaud# 8 = 8 Gigabaud# Value range is [0,8]. Default value is 0.*/LPFC_ATTR_R(link_speed, 0, 0, 8, "Select link speed");/*# lpfc_fcp_class: Determines FC class to use for the FCP protocol.# Value range is [2,3]. Default value is 3.*/LPFC_VPORT_ATTR_R(fcp_class, 3, 2, 3, "Select Fibre Channel class of service for FCP sequences");/*# lpfc_use_adisc: Use ADISC for FCP rediscovery instead of PLOGI. Value range# is [0,1]. Default value is 0.*/LPFC_VPORT_ATTR_RW(use_adisc, 0, 0, 1, "Use ADISC on rediscovery to authenticate FCP devices");/*# lpfc_ack0: Use ACK0, instead of ACK1 for class 2 acknowledgement. Value# range is [0,1]. Default value is 0.*/LPFC_ATTR_R(ack0, 0, 0, 1, "Enable ACK0 support");/*# lpfc_cr_delay & lpfc_cr_count: Default values for I/O colaesing# cr_delay (msec) or cr_count outstanding commands. cr_delay can take# value [0,63]. cr_count can take value [1,255]. Default value of cr_delay# is 0. Default value of cr_count is 1. The cr_count feature is disabled if# cr_delay is set to 0.*/LPFC_ATTR_RW(cr_delay, 0, 0, 63, "A count of milliseconds after which an " "interrupt response is generated");LPFC_ATTR_RW(cr_count, 1, 1, 255, "A count of I/O completions after which an " "interrupt response is generated");/*# lpfc_multi_ring_support: Determines how many rings to spread available# cmd/rsp IOCB entries across.# Value range is [1,2]. Default value is 1.*/LPFC_ATTR_R(multi_ring_support, 1, 1, 2, "Determines number of primary " "SLI rings to spread IOCB entries across");/*# lpfc_multi_ring_rctl: If lpfc_multi_ring_support is enabled, this# identifies what rctl value to configure the additional ring for.# Value range is [1,0xff]. Default value is 4 (Unsolicated Data).*/LPFC_ATTR_R(multi_ring_rctl, FC_UNSOL_DATA, 1, 255, "Identifies RCTL for additional ring configuration");/*# lpfc_multi_ring_type: If lpfc_multi_ring_support is enabled, this# identifies what type value to configure the additional ring for.# Value range is [1,0xff]. Default value is 5 (LLC/SNAP).*/LPFC_ATTR_R(multi_ring_type, FC_LLC_SNAP, 1, 255, "Identifies TYPE for additional ring configuration");/*# lpfc_fdmi_on: controls FDMI support.# 0 = no FDMI support# 1 = support FDMI without attribute of hostname# 2 = support FDMI with attribute of hostname# Value range [0,2]. Default value is 0.*/LPFC_VPORT_ATTR_RW(fdmi_on, 0, 0, 2, "Enable FDMI support");/*# Specifies the maximum number of ELS cmds we can have outstanding (for# discovery). Value range is [1,64]. Default value = 32.*/LPFC_VPORT_ATTR(discovery_threads, 32, 1, 64, "Maximum number of ELS commands " "during discovery");/*# lpfc_max_luns: maximum allowed LUN.# Value range is [0,65535]. Default value is 255.# NOTE: The SCSI layer might probe all allowed LUN on some old targets.*/LPFC_VPORT_ATTR_R(max_luns, 255, 0, 65535, "Maximum allowed LUN");/*# lpfc_poll_tmo: .Milliseconds driver will wait between polling FCP ring.# Value range is [1,255], default value is 10.*/LPFC_ATTR_RW(poll_tmo, 10, 1, 255, "Milliseconds driver will wait between polling FCP ring");/*# lpfc_use_msi: Use MSI (Message Signaled Interrupts) in systems that# support this feature# 0 = MSI disabled (default)# 1 = MSI enabled# Value range is [0,1]. Default value is 0.*/LPFC_ATTR_R(use_msi, 0, 0, 1, "Use Message Signaled Interrupts, if possible");struct class_device_attribute *lpfc_hba_attrs[] = { &class_device_attr_info, &class_device_attr_serialnum, &class_device_attr_modeldesc, &class_device_attr_modelname, &class_device_attr_programtype, &class_device_attr_portnum, &class_device_attr_fwrev, &class_device_attr_hdw, &class_device_attr_option_rom_version, &class_device_attr_state, &class_device_attr_num_discovered_ports, &class_device_attr_lpfc_drvr_version, &class_device_attr_lpfc_log_verbose, &class_device_attr_lpfc_lun_queue_depth, &class_device_attr_lpfc_hba_queue_depth, &class_device_attr_lpfc_peer_port_login, &class_device_attr_lpfc_nodev_tmo, &class_device_attr_lpfc_devloss_tmo, &class_device_attr_lpfc_fcp_class, &class_device_attr_lpfc_use_adisc, &class_device_attr_lpfc_ack0, &class_device_attr_lpfc_topology, &class_device_attr_lpfc_scan_down, &class_device_attr_lpfc_link_speed, &class_device_attr_lpfc_cr_delay, &class_device_attr_lpfc_cr_count, &class_device_attr_lpfc_multi_ring_support, &class_device_attr_lpfc_multi_ring_rctl, &class_device_attr_lpfc_multi_ring_type, &class_device_attr_lpfc_fdmi_on, &class_device_attr_lpfc_max_luns, &class_device_attr_lpfc_enable_npiv, &class_device_attr_nport_evt_cnt, &class_device_attr_board_mode, &class_device_attr_max_vpi, &class_device_attr_used_vpi, &class_device_attr_max_rpi, &class_device_attr_used_rpi, &class_device_attr_max_xri, &class_device_attr_used_xri, &class_device_attr_npiv_info, &class_device_attr_issue_reset, &class_device_attr_lpfc_poll, &class_device_attr_lpfc_poll_tmo, &class_device_attr_lpfc_use_msi, &class_device_attr_lpfc_soft_wwnn, &class_device_attr_lpfc_soft_wwpn, &class_device_attr_lpfc_soft_wwn_enable, NULL,};struct class_device_attribute *lpfc_vport_attrs[] = { &class_device_attr_info, &class_device_attr_state, &class_device_attr_num_discovered_ports, &class_device_attr_lpfc_drvr_version, &class_device_attr_lpfc_log_verbose, &class_device_attr_lpfc_lun_queue_depth, &class_device_attr_lpfc_nodev_tmo, &class_device_attr_lpfc_devloss_tmo, &class_device_attr_lpfc_hba_queue_depth, &class_device_attr_lpfc_peer_port_login, &class_device_attr_lpfc_restrict_login, &class_device_attr_lpfc_fcp_class, &class_device_attr_lpfc_use_adisc, &class_device_attr_lpfc_fdmi_on, &class_device_attr_lpfc_max_luns, &class_device_attr_nport_evt_cnt, &class_device_attr_npiv_info, NULL,};static ssize_tsysfs_ctlreg_write(struct kobject *kobj, struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count){ size_t buf_off; struct class_device *cdev = container_of(kobj, struct class_device, kobj); struct Scsi_Host *shost = class_to_shost(cdev); struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; struct lpfc_hba *phba = vport->phba; if ((off + count) > FF_REG_AREA_SIZE) return -ERANGE; if (count == 0) return 0; if (off % 4 || count % 4 || (unsigned long)buf % 4) return -EINVAL; if (!(vport->fc_flag & FC_OFFLINE_MODE)) { return -EPERM; } spin_lock_irq(&phba->hbalock); for (buf_off = 0; buf_off < count; buf_off += sizeof(uint32_t)) writel(*((uint32_t *)(buf + buf_off)), phba->ctrl_regs_memmap_p + off + buf_off); spin_unlock_irq(&phba->hbalock); return count;}static ssize_tsysfs_ctlreg_read(struct kobject *kobj, struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count){ size_t buf_off; uint32_t * tmp_ptr; struct class_device *cdev = container_of(kobj, struct class_device, kobj); struct Scsi_Host *shost = class_to_shost(cdev); struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; struct lpfc_hba *phba = vport->phba; if (off > FF_REG_AREA_SIZE) return -ERANGE; if ((off + count) > FF_REG_AREA_SIZE) count = FF_REG_AREA_SIZE - off; if (count == 0) return 0; if (off % 4 || count % 4 || (unsigned long)buf % 4) return -EINVAL; spin_lock_irq(&phba->hbalock); for (buf_off = 0; buf_off < count; buf_off += sizeof(uint32_t)) { tmp_ptr = (uint32_t *)(buf + buf_off); *tmp_ptr = readl(phba->ctrl_regs_memmap_p + off + buf_off); } spin_unlock_irq(&phba->hbalock); return count;}static struct bin_attribute sysfs_ctlreg_attr = { .attr = { .name = "ctlreg", .mode = S_IRUSR | S_IWUSR, }, .size = 256, .read = sysfs_ctlreg_read, .write = sysfs_ctlreg_write,};static voidsysfs_mbox_idle(struct lpfc_hba *phba){ phba->sysfs_mbox.state = SMBOX_IDLE; phba->sysfs_mbox.offset = 0; if (phba->sysfs_mbox.mbox) { mempool_free(phba->sysfs_mbox.mbox, phba->mbox_mem_pool); phba->sysfs_mbox.mbox = NULL; }}static ssize_tsysfs_mbox_write(struct kobject *kobj, struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count){ struct class_device *cdev = container_of(kobj, struct class_device, kobj); struct Scsi_Host *shost = class_to_shost(cdev); struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; struct lpfc_hba *phba = vport->phba; struct lpfcMboxq *mbox = NULL; if ((count + off) > MAILBOX_CMD_SIZE) return -ERANGE; if (off % 4 || count % 4 || (unsigned long)buf % 4) return -EINVAL; if (count == 0) return 0; if (off == 0) { mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); if (!mbox) return -ENOMEM; memset(mbox, 0, sizeof (LPFC_MBOXQ_t)); } spin_lock_irq(&phba->hbalock); if (off == 0) { if (phba->sysfs_mbox.mbox) mempool_free(mbox, phba->mbox_mem_pool); else phba->sysfs_mbox.mbox = mbox; phba->sysfs_mbox.state = SMBOX_WRITING; } else { if (phba->sysfs_mbox.state != SMBOX_WRITING || phba->sysfs_mbox.offset != off || phba->sysfs_mbox.mbox == NULL) { sysfs_mbox_idle(phba); spin_unlock_irq(&phba->hbalock); return -EAGAIN; } } memcpy((uint8_t *) & phba->sysfs_mbox.mbox->mb + off, buf, count); phba->sysfs_mbox.offset = off + count; spin_unlock_irq(&phba->hbalock); return count;}static ssize_tsysfs_mbox_read(struct kobject *kobj, struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count){ struct class_device *cdev = container_of(kobj, struct class_device, kobj); struct Scsi_Host *shost = class_to_shost(cdev); struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; struct lpfc_hba *phba = vport->phba; int rc; if (off > MAILBOX_CMD_SIZE) return -ERANGE; if ((count + off) > MAILBOX_CMD_SIZE) count = MAILBOX_CMD_SIZE - off; if (off % 4 || count % 4 || (unsigned long)buf % 4) return -EINVAL; if (off && count == 0) return 0; spin_lock_irq(&phba->hbalock); if (off == 0 && phba->sysfs_mbox.state == SMBOX_WRITING && phba->sysfs_mbox.offset >= 2 * sizeof(uint32_t)) { switch (phba->sysfs_mbox.mbox->mb.mbxCommand) { /* Offline only */ case MBX_WRITE_NV: case MBX_INIT_LINK: case MBX_DOWN_LINK: case MBX_CONFIG_LINK: case MBX_CONFIG_RING: case MBX_RESET_RING: case MBX_UNREG_LOGIN: case MBX_CLEAR_LA: case MBX_DUMP_CONTEXT: case MBX_RUN_DIAGS: case MBX_RESTART: case MBX_FLASH_WR_ULA: case MBX_SET_MASK: case MBX_SET_SLIM: case MBX_SET_DEBUG: if (!(vport->fc_flag & FC_OFFLINE_MODE)) { printk(KERN_WARNING "mbox_read:Command 0x%x " "is illegal in on-line state\n", phba->sysfs_mbox.mbox->mb.mbxCommand); sysfs_mbox_idle(phba); spin_unlock_irq(&phba->hbalock); return -EPERM; } case MBX_LOAD_SM: case MBX_READ_NV: case MBX_READ_CONFIG: case MBX_READ_RCONFIG: case MBX_READ_STATUS: case MBX_READ_XRI: case MBX_READ_REV: case MBX_READ_LNK_STAT: case MBX_DUMP_MEMORY: case MBX_DOWN_LOAD: case MBX_UPDATE_CFG: case MBX_KILL_BOARD: case MBX_LOAD_AREA: case MBX_LOAD_EXP_ROM: case MBX_BEACON: case MBX_DEL_LD_ENTRY: break; case MBX_READ_SPARM64:
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?