aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/lpfc/lpfc_attr.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_attr.c')
-rw-r--r--drivers/scsi/lpfc/lpfc_attr.c423
1 files changed, 287 insertions, 136 deletions
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index 860a52c090f4..80a11218b9bb 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -68,12 +68,6 @@ lpfc_drvr_version_show(struct class_device *cdev, char *buf)
68} 68}
69 69
70static ssize_t 70static ssize_t
71management_version_show(struct class_device *cdev, char *buf)
72{
73 return snprintf(buf, PAGE_SIZE, DFC_API_VERSION "\n");
74}
75
76static ssize_t
77lpfc_info_show(struct class_device *cdev, char *buf) 71lpfc_info_show(struct class_device *cdev, char *buf)
78{ 72{
79 struct Scsi_Host *host = class_to_shost(cdev); 73 struct Scsi_Host *host = class_to_shost(cdev);
@@ -319,9 +313,8 @@ lpfc_do_offline(struct lpfc_hba *phba, uint32_t type)
319 if (cnt++ > 3000) { 313 if (cnt++ > 3000) {
320 lpfc_printf_log(phba, 314 lpfc_printf_log(phba,
321 KERN_WARNING, LOG_INIT, 315 KERN_WARNING, LOG_INIT,
322 "%d:0466 Outstanding IO when " 316 "0466 Outstanding IO when "
323 "bringing Adapter offline\n", 317 "bringing Adapter offline\n");
324 phba->brd_no);
325 break; 318 break;
326 } 319 }
327 } 320 }
@@ -437,7 +430,7 @@ lpfc_board_mode_store(struct class_device *cdev, const char *buf, size_t count)
437 return -EIO; 430 return -EIO;
438} 431}
439 432
440int 433static int
441lpfc_get_hba_info(struct lpfc_hba *phba, 434lpfc_get_hba_info(struct lpfc_hba *phba,
442 uint32_t *mxri, uint32_t *axri, 435 uint32_t *mxri, uint32_t *axri,
443 uint32_t *mrpi, uint32_t *arpi, 436 uint32_t *mrpi, uint32_t *arpi,
@@ -694,9 +687,8 @@ lpfc_##attr##_init(struct lpfc_hba *phba, int val) \
694 return 0;\ 687 return 0;\
695 }\ 688 }\
696 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ 689 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
697 "%d:0449 lpfc_"#attr" attribute cannot be set to %d, "\ 690 "0449 lpfc_"#attr" attribute cannot be set to %d, "\
698 "allowed range is ["#minval", "#maxval"]\n", \ 691 "allowed range is ["#minval", "#maxval"]\n", val); \
699 phba->brd_no, val); \
700 phba->cfg_##attr = default;\ 692 phba->cfg_##attr = default;\
701 return -EINVAL;\ 693 return -EINVAL;\
702} 694}
@@ -710,9 +702,8 @@ lpfc_##attr##_set(struct lpfc_hba *phba, int val) \
710 return 0;\ 702 return 0;\
711 }\ 703 }\
712 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ 704 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
713 "%d:0450 lpfc_"#attr" attribute cannot be set to %d, "\ 705 "0450 lpfc_"#attr" attribute cannot be set to %d, "\
714 "allowed range is ["#minval", "#maxval"]\n", \ 706 "allowed range is ["#minval", "#maxval"]\n", val); \
715 phba->brd_no, val); \
716 return -EINVAL;\ 707 return -EINVAL;\
717} 708}
718 709
@@ -734,6 +725,75 @@ lpfc_##attr##_store(struct class_device *cdev, const char *buf, size_t count) \
734 return -EINVAL;\ 725 return -EINVAL;\
735} 726}
736 727
728#define lpfc_vport_param_show(attr) \
729static ssize_t \
730lpfc_##attr##_show(struct class_device *cdev, char *buf) \
731{ \
732 struct Scsi_Host *shost = class_to_shost(cdev);\
733 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
734 int val = 0;\
735 val = vport->cfg_##attr;\
736 return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_##attr);\
737}
738
739#define lpfc_vport_param_hex_show(attr) \
740static ssize_t \
741lpfc_##attr##_show(struct class_device *cdev, char *buf) \
742{ \
743 struct Scsi_Host *shost = class_to_shost(cdev);\
744 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
745 int val = 0;\
746 val = vport->cfg_##attr;\
747 return snprintf(buf, PAGE_SIZE, "%#x\n", vport->cfg_##attr);\
748}
749
750#define lpfc_vport_param_init(attr, default, minval, maxval) \
751static int \
752lpfc_##attr##_init(struct lpfc_vport *vport, int val) \
753{ \
754 if (val >= minval && val <= maxval) {\
755 vport->cfg_##attr = val;\
756 return 0;\
757 }\
758 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
759 "0449 lpfc_"#attr" attribute cannot be set to %d, "\
760 "allowed range is ["#minval", "#maxval"]\n", val); \
761 vport->cfg_##attr = default;\
762 return -EINVAL;\
763}
764
765#define lpfc_vport_param_set(attr, default, minval, maxval) \
766static int \
767lpfc_##attr##_set(struct lpfc_vport *vport, int val) \
768{ \
769 if (val >= minval && val <= maxval) {\
770 vport->cfg_##attr = val;\
771 return 0;\
772 }\
773 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
774 "0450 lpfc_"#attr" attribute cannot be set to %d, "\
775 "allowed range is ["#minval", "#maxval"]\n", val); \
776 return -EINVAL;\
777}
778
779#define lpfc_vport_param_store(attr) \
780static ssize_t \
781lpfc_##attr##_store(struct class_device *cdev, const char *buf, size_t count) \
782{ \
783 struct Scsi_Host *shost = class_to_shost(cdev);\
784 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
785 int val=0;\
786 if (!isdigit(buf[0]))\
787 return -EINVAL;\
788 if (sscanf(buf, "%i", &val) != 1)\
789 return -EINVAL;\
790 if (lpfc_##attr##_set(vport, val) == 0) \
791 return strlen(buf);\
792 else \
793 return -EINVAL;\
794}
795
796
737#define LPFC_ATTR(name, defval, minval, maxval, desc) \ 797#define LPFC_ATTR(name, defval, minval, maxval, desc) \
738static int lpfc_##name = defval;\ 798static int lpfc_##name = defval;\
739module_param(lpfc_##name, int, 0);\ 799module_param(lpfc_##name, int, 0);\
@@ -778,6 +838,50 @@ lpfc_param_store(name)\
778static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ 838static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\
779 lpfc_##name##_show, lpfc_##name##_store) 839 lpfc_##name##_show, lpfc_##name##_store)
780 840
841#define LPFC_VPORT_ATTR(name, defval, minval, maxval, desc) \
842static int lpfc_##name = defval;\
843module_param(lpfc_##name, int, 0);\
844MODULE_PARM_DESC(lpfc_##name, desc);\
845lpfc_vport_param_init(name, defval, minval, maxval)
846
847#define LPFC_VPORT_ATTR_R(name, defval, minval, maxval, desc) \
848static int lpfc_##name = defval;\
849module_param(lpfc_##name, int, 0);\
850MODULE_PARM_DESC(lpfc_##name, desc);\
851lpfc_vport_param_show(name)\
852lpfc_vport_param_init(name, defval, minval, maxval)\
853static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL)
854
855#define LPFC_VPORT_ATTR_RW(name, defval, minval, maxval, desc) \
856static int lpfc_##name = defval;\
857module_param(lpfc_##name, int, 0);\
858MODULE_PARM_DESC(lpfc_##name, desc);\
859lpfc_vport_param_show(name)\
860lpfc_vport_param_init(name, defval, minval, maxval)\
861lpfc_vport_param_set(name, defval, minval, maxval)\
862lpfc_vport_param_store(name)\
863static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\
864 lpfc_##name##_show, lpfc_##name##_store)
865
866#define LPFC_VPORT_ATTR_HEX_R(name, defval, minval, maxval, desc) \
867static int lpfc_##name = defval;\
868module_param(lpfc_##name, int, 0);\
869MODULE_PARM_DESC(lpfc_##name, desc);\
870lpfc_vport_param_hex_show(name)\
871lpfc_vport_param_init(name, defval, minval, maxval)\
872static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL)
873
874#define LPFC_VPORT_ATTR_HEX_RW(name, defval, minval, maxval, desc) \
875static int lpfc_##name = defval;\
876module_param(lpfc_##name, int, 0);\
877MODULE_PARM_DESC(lpfc_##name, desc);\
878lpfc_vport_param_hex_show(name)\
879lpfc_vport_param_init(name, defval, minval, maxval)\
880lpfc_vport_param_set(name, defval, minval, maxval)\
881lpfc_vport_param_store(name)\
882static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\
883 lpfc_##name##_show, lpfc_##name##_store)
884
781static CLASS_DEVICE_ATTR(info, S_IRUGO, lpfc_info_show, NULL); 885static CLASS_DEVICE_ATTR(info, S_IRUGO, lpfc_info_show, NULL);
782static CLASS_DEVICE_ATTR(serialnum, S_IRUGO, lpfc_serialnum_show, NULL); 886static CLASS_DEVICE_ATTR(serialnum, S_IRUGO, lpfc_serialnum_show, NULL);
783static CLASS_DEVICE_ATTR(modeldesc, S_IRUGO, lpfc_modeldesc_show, NULL); 887static CLASS_DEVICE_ATTR(modeldesc, S_IRUGO, lpfc_modeldesc_show, NULL);
@@ -794,8 +898,6 @@ static CLASS_DEVICE_ATTR(num_discovered_ports, S_IRUGO,
794static CLASS_DEVICE_ATTR(nport_evt_cnt, S_IRUGO, lpfc_nport_evt_cnt_show, NULL); 898static CLASS_DEVICE_ATTR(nport_evt_cnt, S_IRUGO, lpfc_nport_evt_cnt_show, NULL);
795static CLASS_DEVICE_ATTR(lpfc_drvr_version, S_IRUGO, lpfc_drvr_version_show, 899static CLASS_DEVICE_ATTR(lpfc_drvr_version, S_IRUGO, lpfc_drvr_version_show,
796 NULL); 900 NULL);
797static CLASS_DEVICE_ATTR(management_version, S_IRUGO, management_version_show,
798 NULL);
799static CLASS_DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR, 901static CLASS_DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR,
800 lpfc_board_mode_show, lpfc_board_mode_store); 902 lpfc_board_mode_show, lpfc_board_mode_store);
801static CLASS_DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset); 903static CLASS_DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset);
@@ -908,17 +1010,15 @@ lpfc_soft_wwpn_store(struct class_device *cdev, const char *buf, size_t count)
908 stat1 = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); 1010 stat1 = lpfc_do_offline(phba, LPFC_EVT_OFFLINE);
909 if (stat1) 1011 if (stat1)
910 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 1012 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
911 "%d:0463 lpfc_soft_wwpn attribute set failed to reinit " 1013 "0463 lpfc_soft_wwpn attribute set failed to "
912 "adapter - %d\n", phba->brd_no, stat1); 1014 "reinit adapter - %d\n", stat1);
913
914 init_completion(&online_compl); 1015 init_completion(&online_compl);
915 lpfc_workq_post_event(phba, &stat2, &online_compl, LPFC_EVT_ONLINE); 1016 lpfc_workq_post_event(phba, &stat2, &online_compl, LPFC_EVT_ONLINE);
916 wait_for_completion(&online_compl); 1017 wait_for_completion(&online_compl);
917 if (stat2) 1018 if (stat2)
918 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 1019 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
919 "%d:0464 lpfc_soft_wwpn attribute set failed to reinit " 1020 "0464 lpfc_soft_wwpn attribute set failed to "
920 "adapter - %d\n", phba->brd_no, stat2); 1021 "reinit adapter - %d\n", stat2);
921
922 return (stat1 || stat2) ? -EIO : count; 1022 return (stat1 || stat2) ? -EIO : count;
923} 1023}
924static CLASS_DEVICE_ATTR(lpfc_soft_wwpn, S_IRUGO | S_IWUSR,\ 1024static CLASS_DEVICE_ATTR(lpfc_soft_wwpn, S_IRUGO | S_IWUSR,\
@@ -927,8 +1027,8 @@ static CLASS_DEVICE_ATTR(lpfc_soft_wwpn, S_IRUGO | S_IWUSR,\
927static ssize_t 1027static ssize_t
928lpfc_soft_wwnn_show(struct class_device *cdev, char *buf) 1028lpfc_soft_wwnn_show(struct class_device *cdev, char *buf)
929{ 1029{
930 struct Scsi_Host *host = class_to_shost(cdev); 1030 struct Scsi_Host *shost = class_to_shost(cdev);
931 struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata; 1031 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
932 return snprintf(buf, PAGE_SIZE, "0x%llx\n", 1032 return snprintf(buf, PAGE_SIZE, "0x%llx\n",
933 (unsigned long long)phba->cfg_soft_wwnn); 1033 (unsigned long long)phba->cfg_soft_wwnn);
934} 1034}
@@ -937,8 +1037,8 @@ lpfc_soft_wwnn_show(struct class_device *cdev, char *buf)
937static ssize_t 1037static ssize_t
938lpfc_soft_wwnn_store(struct class_device *cdev, const char *buf, size_t count) 1038lpfc_soft_wwnn_store(struct class_device *cdev, const char *buf, size_t count)
939{ 1039{
940 struct Scsi_Host *host = class_to_shost(cdev); 1040 struct Scsi_Host *shost = class_to_shost(cdev);
941 struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata; 1041 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
942 unsigned int i, j, cnt=count; 1042 unsigned int i, j, cnt=count;
943 u8 wwnn[8]; 1043 u8 wwnn[8];
944 1044
@@ -1002,7 +1102,7 @@ MODULE_PARM_DESC(lpfc_sli_mode, "SLI mode selector:"
1002 " 2 - select SLI-2 even on SLI-3 capable HBAs," 1102 " 2 - select SLI-2 even on SLI-3 capable HBAs,"
1003 " 3 - select SLI-3"); 1103 " 3 - select SLI-3");
1004 1104
1005LPFC_ATTR_R(npiv_enable, 0, 0, 1, "Enable NPIV functionality"); 1105LPFC_ATTR_R(enable_npiv, 0, 0, 1, "Enable NPIV functionality");
1006 1106
1007/* 1107/*
1008# lpfc_nodev_tmo: If set, it will hold all I/O errors on devices that disappear 1108# lpfc_nodev_tmo: If set, it will hold all I/O errors on devices that disappear
@@ -1019,90 +1119,75 @@ lpfc_nodev_tmo_show(struct class_device *cdev, char *buf)
1019{ 1119{
1020 struct Scsi_Host *shost = class_to_shost(cdev); 1120 struct Scsi_Host *shost = class_to_shost(cdev);
1021 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 1121 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1022 struct lpfc_hba *phba = vport->phba;
1023 int val = 0; 1122 int val = 0;
1024 val = phba->cfg_devloss_tmo; 1123 val = vport->cfg_devloss_tmo;
1025 return snprintf(buf, PAGE_SIZE, "%d\n", 1124 return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_devloss_tmo);
1026 phba->cfg_devloss_tmo);
1027} 1125}
1028 1126
1029static int 1127static int
1030lpfc_nodev_tmo_init(struct lpfc_hba *phba, int val) 1128lpfc_nodev_tmo_init(struct lpfc_vport *vport, int val)
1031{ 1129{
1032 static int warned; 1130 if (vport->cfg_devloss_tmo != LPFC_DEF_DEVLOSS_TMO) {
1033 if (phba->cfg_devloss_tmo != LPFC_DEF_DEVLOSS_TMO) { 1131 vport->cfg_nodev_tmo = vport->cfg_devloss_tmo;
1034 phba->cfg_nodev_tmo = phba->cfg_devloss_tmo; 1132 if (val != LPFC_DEF_DEVLOSS_TMO)
1035 if (!warned && val != LPFC_DEF_DEVLOSS_TMO) { 1133 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1036 warned = 1; 1134 "0402 Ignoring nodev_tmo module "
1037 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 1135 "parameter because devloss_tmo is "
1038 "%d:0402 Ignoring nodev_tmo module " 1136 "set.\n");
1039 "parameter because devloss_tmo is"
1040 " set.\n",
1041 phba->brd_no);
1042 }
1043 return 0; 1137 return 0;
1044 } 1138 }
1045 1139
1046 if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { 1140 if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) {
1047 phba->cfg_nodev_tmo = val; 1141 vport->cfg_nodev_tmo = val;
1048 phba->cfg_devloss_tmo = val; 1142 vport->cfg_devloss_tmo = val;
1049 return 0; 1143 return 0;
1050 } 1144 }
1051 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 1145 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1052 "%d:0400 lpfc_nodev_tmo attribute cannot be set to %d, " 1146 "0400 lpfc_nodev_tmo attribute cannot be set to"
1053 "allowed range is [%d, %d]\n", 1147 " %d, allowed range is [%d, %d]\n",
1054 phba->brd_no, val, 1148 val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO);
1055 LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); 1149 vport->cfg_nodev_tmo = LPFC_DEF_DEVLOSS_TMO;
1056 phba->cfg_nodev_tmo = LPFC_DEF_DEVLOSS_TMO;
1057 return -EINVAL; 1150 return -EINVAL;
1058} 1151}
1059 1152
1060static void 1153static void
1061lpfc_update_rport_devloss_tmo(struct lpfc_hba *phba) 1154lpfc_update_rport_devloss_tmo(struct lpfc_vport *vport)
1062{ 1155{
1063 struct lpfc_vport *vport;
1064 struct Scsi_Host *shost; 1156 struct Scsi_Host *shost;
1065 struct lpfc_nodelist *ndlp; 1157 struct lpfc_nodelist *ndlp;
1066 1158
1067 list_for_each_entry(vport, &phba->port_list, listentry) { 1159 shost = lpfc_shost_from_vport(vport);
1068 shost = lpfc_shost_from_vport(vport); 1160 spin_lock_irq(shost->host_lock);
1069 spin_lock_irq(shost->host_lock); 1161 list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp)
1070 list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) 1162 if (ndlp->rport)
1071 if (ndlp->rport) 1163 ndlp->rport->dev_loss_tmo = vport->cfg_devloss_tmo;
1072 ndlp->rport->dev_loss_tmo = 1164 spin_unlock_irq(shost->host_lock);
1073 phba->cfg_devloss_tmo;
1074 spin_unlock_irq(shost->host_lock);
1075 }
1076} 1165}
1077 1166
1078static int 1167static int
1079lpfc_nodev_tmo_set(struct lpfc_hba *phba, int val) 1168lpfc_nodev_tmo_set(struct lpfc_vport *vport, int val)
1080{ 1169{
1081 if (phba->dev_loss_tmo_changed || 1170 if (vport->dev_loss_tmo_changed ||
1082 (lpfc_devloss_tmo != LPFC_DEF_DEVLOSS_TMO)) { 1171 (lpfc_devloss_tmo != LPFC_DEF_DEVLOSS_TMO)) {
1083 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 1172 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1084 "%d:0401 Ignoring change to nodev_tmo " 1173 "0401 Ignoring change to nodev_tmo "
1085 "because devloss_tmo is set.\n", 1174 "because devloss_tmo is set.\n");
1086 phba->brd_no);
1087 return 0; 1175 return 0;
1088 } 1176 }
1089
1090 if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { 1177 if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) {
1091 phba->cfg_nodev_tmo = val; 1178 vport->cfg_nodev_tmo = val;
1092 phba->cfg_devloss_tmo = val; 1179 vport->cfg_devloss_tmo = val;
1093 lpfc_update_rport_devloss_tmo(phba); 1180 lpfc_update_rport_devloss_tmo(vport);
1094 return 0; 1181 return 0;
1095 } 1182 }
1096 1183 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1097 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 1184 "0403 lpfc_nodev_tmo attribute cannot be set to"
1098 "%d:0403 lpfc_nodev_tmo attribute cannot be set to %d, " 1185 "%d, allowed range is [%d, %d]\n",
1099 "allowed range is [%d, %d]\n", 1186 val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO);
1100 phba->brd_no, val, LPFC_MIN_DEVLOSS_TMO,
1101 LPFC_MAX_DEVLOSS_TMO);
1102 return -EINVAL; 1187 return -EINVAL;
1103} 1188}
1104 1189
1105lpfc_param_store(nodev_tmo) 1190lpfc_vport_param_store(nodev_tmo)
1106 1191
1107static CLASS_DEVICE_ATTR(lpfc_nodev_tmo, S_IRUGO | S_IWUSR, 1192static CLASS_DEVICE_ATTR(lpfc_nodev_tmo, S_IRUGO | S_IWUSR,
1108 lpfc_nodev_tmo_show, lpfc_nodev_tmo_store); 1193 lpfc_nodev_tmo_show, lpfc_nodev_tmo_store);
@@ -1116,29 +1201,28 @@ module_param(lpfc_devloss_tmo, int, 0);
1116MODULE_PARM_DESC(lpfc_devloss_tmo, 1201MODULE_PARM_DESC(lpfc_devloss_tmo,
1117 "Seconds driver will hold I/O waiting " 1202 "Seconds driver will hold I/O waiting "
1118 "for a device to come back"); 1203 "for a device to come back");
1119lpfc_param_init(devloss_tmo, LPFC_DEF_DEVLOSS_TMO, 1204lpfc_vport_param_init(devloss_tmo, LPFC_DEF_DEVLOSS_TMO,
1120 LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO) 1205 LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO)
1121lpfc_param_show(devloss_tmo) 1206lpfc_vport_param_show(devloss_tmo)
1122static int 1207static int
1123lpfc_devloss_tmo_set(struct lpfc_hba *phba, int val) 1208lpfc_devloss_tmo_set(struct lpfc_vport *vport, int val)
1124{ 1209{
1125 if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { 1210 if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) {
1126 phba->cfg_nodev_tmo = val; 1211 vport->cfg_nodev_tmo = val;
1127 phba->cfg_devloss_tmo = val; 1212 vport->cfg_devloss_tmo = val;
1128 phba->dev_loss_tmo_changed = 1; 1213 vport->dev_loss_tmo_changed = 1;
1129 lpfc_update_rport_devloss_tmo(phba); 1214 lpfc_update_rport_devloss_tmo(vport);
1130 return 0; 1215 return 0;
1131 } 1216 }
1132 1217
1133 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 1218 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1134 "%d:0404 lpfc_devloss_tmo attribute cannot be set to" 1219 "0404 lpfc_devloss_tmo attribute cannot be set to"
1135 " %d, allowed range is [%d, %d]\n", 1220 " %d, allowed range is [%d, %d]\n",
1136 phba->brd_no, val, LPFC_MIN_DEVLOSS_TMO, 1221 val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO);
1137 LPFC_MAX_DEVLOSS_TMO);
1138 return -EINVAL; 1222 return -EINVAL;
1139} 1223}
1140 1224
1141lpfc_param_store(devloss_tmo) 1225lpfc_vport_param_store(devloss_tmo)
1142static CLASS_DEVICE_ATTR(lpfc_devloss_tmo, S_IRUGO | S_IWUSR, 1226static CLASS_DEVICE_ATTR(lpfc_devloss_tmo, S_IRUGO | S_IWUSR,
1143 lpfc_devloss_tmo_show, lpfc_devloss_tmo_store); 1227 lpfc_devloss_tmo_show, lpfc_devloss_tmo_store);
1144 1228
@@ -1160,14 +1244,15 @@ static CLASS_DEVICE_ATTR(lpfc_devloss_tmo, S_IRUGO | S_IWUSR,
1160# LOG_LIBDFC 0x2000 LIBDFC events 1244# LOG_LIBDFC 0x2000 LIBDFC events
1161# LOG_ALL_MSG 0xffff LOG all messages 1245# LOG_ALL_MSG 0xffff LOG all messages
1162*/ 1246*/
1163LPFC_ATTR_HEX_RW(log_verbose, 0x0, 0x0, 0xffff, "Verbose logging bit-mask"); 1247LPFC_VPORT_ATTR_HEX_RW(log_verbose, 0x0, 0x0, 0xffff,
1248 "Verbose logging bit-mask");
1164 1249
1165/* 1250/*
1166# lun_queue_depth: This parameter is used to limit the number of outstanding 1251# lun_queue_depth: This parameter is used to limit the number of outstanding
1167# commands per FCP LUN. Value range is [1,128]. Default value is 30. 1252# commands per FCP LUN. Value range is [1,128]. Default value is 30.
1168*/ 1253*/
1169LPFC_ATTR_R(lun_queue_depth, 30, 1, 128, 1254LPFC_VPORT_ATTR_R(lun_queue_depth, 30, 1, 128,
1170 "Max number of FCP commands we can queue to a specific LUN"); 1255 "Max number of FCP commands we can queue to a specific LUN");
1171 1256
1172/* 1257/*
1173# hba_queue_depth: This parameter is used to limit the number of outstanding 1258# hba_queue_depth: This parameter is used to limit the number of outstanding
@@ -1188,12 +1273,12 @@ LPFC_ATTR_R(hba_queue_depth, 8192, 32, 8192,
1188# are allowed to login to each other. 1273# are allowed to login to each other.
1189# Default value of this parameter is 0. 1274# Default value of this parameter is 0.
1190*/ 1275*/
1191LPFC_ATTR_R(peer_port_login, 0, 0, 1, 1276LPFC_VPORT_ATTR_R(peer_port_login, 0, 0, 1,
1192 "Allow peer ports on the same physical port to login to each " 1277 "Allow peer ports on the same physical port to login to each "
1193 "other."); 1278 "other.");
1194 1279
1195/* 1280/*
1196# vport_restrict_login: This parameter allows/prevents logins 1281# restrict_login: This parameter allows/prevents logins
1197# between Virtual Ports and remote initiators. 1282# between Virtual Ports and remote initiators.
1198# When this parameter is not set (0) Virtual Ports will accept PLOGIs from 1283# When this parameter is not set (0) Virtual Ports will accept PLOGIs from
1199# other initiators and will attempt to PLOGI all remote ports. 1284# other initiators and will attempt to PLOGI all remote ports.
@@ -1203,8 +1288,55 @@ LPFC_ATTR_R(peer_port_login, 0, 0, 1,
1203# This parameter does not restrict logins to Fabric resident remote ports. 1288# This parameter does not restrict logins to Fabric resident remote ports.
1204# Default value of this parameter is 1. 1289# Default value of this parameter is 1.
1205*/ 1290*/
1206LPFC_ATTR_RW(vport_restrict_login, 1, 0, 1, 1291static int lpfc_restrict_login = 1;
1207 "Restrict virtual ports login to remote initiators."); 1292module_param(lpfc_restrict_login, int, 0);
1293MODULE_PARM_DESC(lpfc_restrict_login,
1294 "Restrict virtual ports login to remote initiators.");
1295lpfc_vport_param_show(restrict_login);
1296
1297static int
1298lpfc_restrict_login_init(struct lpfc_vport *vport, int val)
1299{
1300 if (val < 0 || val > 1) {
1301 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1302 "0449 lpfc_restrict_login attribute cannot "
1303 "be set to %d, allowed range is [0, 1]\n",
1304 val);
1305 vport->cfg_restrict_login = 1;
1306 return -EINVAL;
1307 }
1308 if (vport->port_type == LPFC_PHYSICAL_PORT) {
1309 vport->cfg_restrict_login = 0;
1310 return 0;
1311 }
1312 vport->cfg_restrict_login = val;
1313 return 0;
1314}
1315
1316static int
1317lpfc_restrict_login_set(struct lpfc_vport *vport, int val)
1318{
1319 if (val < 0 || val > 1) {
1320 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1321 "0450 lpfc_restrict_login attribute cannot "
1322 "be set to %d, allowed range is [0, 1]\n",
1323 val);
1324 vport->cfg_restrict_login = 1;
1325 return -EINVAL;
1326 }
1327 if (vport->port_type == LPFC_PHYSICAL_PORT && val != 0) {
1328 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1329 "0468 lpfc_restrict_login must be 0 for "
1330 "Physical ports.\n");
1331 vport->cfg_restrict_login = 0;
1332 return 0;
1333 }
1334 vport->cfg_restrict_login = val;
1335 return 0;
1336}
1337lpfc_vport_param_store(restrict_login);
1338static CLASS_DEVICE_ATTR(lpfc_restrict_login, S_IRUGO | S_IWUSR,
1339 lpfc_restrict_login_show, lpfc_restrict_login_store);
1208 1340
1209/* 1341/*
1210# Some disk devices have a "select ID" or "select Target" capability. 1342# Some disk devices have a "select ID" or "select Target" capability.
@@ -1223,8 +1355,8 @@ LPFC_ATTR_RW(vport_restrict_login, 1, 0, 1,
1223# and will not work across a fabric. Also this parameter will take 1355# and will not work across a fabric. Also this parameter will take
1224# effect only in the case when ALPA map is not available.) 1356# effect only in the case when ALPA map is not available.)
1225*/ 1357*/
1226LPFC_ATTR_R(scan_down, 1, 0, 1, 1358LPFC_VPORT_ATTR_R(scan_down, 1, 0, 1,
1227 "Start scanning for devices from highest ALPA to lowest"); 1359 "Start scanning for devices from highest ALPA to lowest");
1228 1360
1229/* 1361/*
1230# lpfc_topology: link topology for init link 1362# lpfc_topology: link topology for init link
@@ -1255,15 +1387,15 @@ LPFC_ATTR_R(link_speed, 0, 0, 8, "Select link speed");
1255# lpfc_fcp_class: Determines FC class to use for the FCP protocol. 1387# lpfc_fcp_class: Determines FC class to use for the FCP protocol.
1256# Value range is [2,3]. Default value is 3. 1388# Value range is [2,3]. Default value is 3.
1257*/ 1389*/
1258LPFC_ATTR_R(fcp_class, 3, 2, 3, 1390LPFC_VPORT_ATTR_R(fcp_class, 3, 2, 3,
1259 "Select Fibre Channel class of service for FCP sequences"); 1391 "Select Fibre Channel class of service for FCP sequences");
1260 1392
1261/* 1393/*
1262# lpfc_use_adisc: Use ADISC for FCP rediscovery instead of PLOGI. Value range 1394# lpfc_use_adisc: Use ADISC for FCP rediscovery instead of PLOGI. Value range
1263# is [0,1]. Default value is 0. 1395# is [0,1]. Default value is 0.
1264*/ 1396*/
1265LPFC_ATTR_RW(use_adisc, 0, 0, 1, 1397LPFC_VPORT_ATTR_RW(use_adisc, 0, 0, 1,
1266 "Use ADISC on rediscovery to authenticate FCP devices"); 1398 "Use ADISC on rediscovery to authenticate FCP devices");
1267 1399
1268/* 1400/*
1269# lpfc_ack0: Use ACK0, instead of ACK1 for class 2 acknowledgement. Value 1401# lpfc_ack0: Use ACK0, instead of ACK1 for class 2 acknowledgement. Value
@@ -1315,13 +1447,13 @@ LPFC_ATTR_R(multi_ring_type, FC_LLC_SNAP, 1,
1315# 2 = support FDMI with attribute of hostname 1447# 2 = support FDMI with attribute of hostname
1316# Value range [0,2]. Default value is 0. 1448# Value range [0,2]. Default value is 0.
1317*/ 1449*/
1318LPFC_ATTR_RW(fdmi_on, 0, 0, 2, "Enable FDMI support"); 1450LPFC_VPORT_ATTR_RW(fdmi_on, 0, 0, 2, "Enable FDMI support");
1319 1451
1320/* 1452/*
1321# Specifies the maximum number of ELS cmds we can have outstanding (for 1453# Specifies the maximum number of ELS cmds we can have outstanding (for
1322# discovery). Value range is [1,64]. Default value = 32. 1454# discovery). Value range is [1,64]. Default value = 32.
1323*/ 1455*/
1324LPFC_ATTR(discovery_threads, 32, 1, 64, "Maximum number of ELS commands " 1456LPFC_VPORT_ATTR(discovery_threads, 32, 1, 64, "Maximum number of ELS commands "
1325 "during discovery"); 1457 "during discovery");
1326 1458
1327/* 1459/*
@@ -1329,8 +1461,7 @@ LPFC_ATTR(discovery_threads, 32, 1, 64, "Maximum number of ELS commands "
1329# Value range is [0,65535]. Default value is 255. 1461# Value range is [0,65535]. Default value is 255.
1330# NOTE: The SCSI layer might probe all allowed LUN on some old targets. 1462# NOTE: The SCSI layer might probe all allowed LUN on some old targets.
1331*/ 1463*/
1332LPFC_ATTR_R(max_luns, 255, 0, 65535, 1464LPFC_VPORT_ATTR_R(max_luns, 255, 0, 65535, "Maximum allowed LUN");
1333 "Maximum allowed LUN");
1334 1465
1335/* 1466/*
1336# lpfc_poll_tmo: .Milliseconds driver will wait between polling FCP ring. 1467# lpfc_poll_tmo: .Milliseconds driver will wait between polling FCP ring.
@@ -1367,7 +1498,6 @@ struct class_device_attribute *lpfc_hba_attrs[] = {
1367 &class_device_attr_lpfc_lun_queue_depth, 1498 &class_device_attr_lpfc_lun_queue_depth,
1368 &class_device_attr_lpfc_hba_queue_depth, 1499 &class_device_attr_lpfc_hba_queue_depth,
1369 &class_device_attr_lpfc_peer_port_login, 1500 &class_device_attr_lpfc_peer_port_login,
1370 &class_device_attr_lpfc_vport_restrict_login,
1371 &class_device_attr_lpfc_nodev_tmo, 1501 &class_device_attr_lpfc_nodev_tmo,
1372 &class_device_attr_lpfc_devloss_tmo, 1502 &class_device_attr_lpfc_devloss_tmo,
1373 &class_device_attr_lpfc_fcp_class, 1503 &class_device_attr_lpfc_fcp_class,
@@ -1383,9 +1513,8 @@ struct class_device_attribute *lpfc_hba_attrs[] = {
1383 &class_device_attr_lpfc_multi_ring_type, 1513 &class_device_attr_lpfc_multi_ring_type,
1384 &class_device_attr_lpfc_fdmi_on, 1514 &class_device_attr_lpfc_fdmi_on,
1385 &class_device_attr_lpfc_max_luns, 1515 &class_device_attr_lpfc_max_luns,
1386 &class_device_attr_lpfc_npiv_enable, 1516 &class_device_attr_lpfc_enable_npiv,
1387 &class_device_attr_nport_evt_cnt, 1517 &class_device_attr_nport_evt_cnt,
1388 &class_device_attr_management_version,
1389 &class_device_attr_board_mode, 1518 &class_device_attr_board_mode,
1390 &class_device_attr_max_vpi, 1519 &class_device_attr_max_vpi,
1391 &class_device_attr_used_vpi, 1520 &class_device_attr_used_vpi,
@@ -1404,6 +1533,28 @@ struct class_device_attribute *lpfc_hba_attrs[] = {
1404 NULL, 1533 NULL,
1405}; 1534};
1406 1535
1536struct class_device_attribute *lpfc_vport_attrs[] = {
1537 &class_device_attr_info,
1538 &class_device_attr_state,
1539 &class_device_attr_num_discovered_ports,
1540 &class_device_attr_lpfc_drvr_version,
1541
1542 &class_device_attr_lpfc_log_verbose,
1543 &class_device_attr_lpfc_lun_queue_depth,
1544 &class_device_attr_lpfc_nodev_tmo,
1545 &class_device_attr_lpfc_devloss_tmo,
1546 &class_device_attr_lpfc_hba_queue_depth,
1547 &class_device_attr_lpfc_peer_port_login,
1548 &class_device_attr_lpfc_restrict_login,
1549 &class_device_attr_lpfc_fcp_class,
1550 &class_device_attr_lpfc_use_adisc,
1551 &class_device_attr_lpfc_fdmi_on,
1552 &class_device_attr_lpfc_max_luns,
1553 &class_device_attr_nport_evt_cnt,
1554 &class_device_attr_npiv_info,
1555 NULL,
1556};
1557
1407static ssize_t 1558static ssize_t
1408sysfs_ctlreg_write(struct kobject *kobj, struct bin_attribute *bin_attr, 1559sysfs_ctlreg_write(struct kobject *kobj, struct bin_attribute *bin_attr,
1409 char *buf, loff_t off, size_t count) 1560 char *buf, loff_t off, size_t count)
@@ -2243,7 +2394,6 @@ struct fc_function_template lpfc_vport_transport_functions = {
2243 .get_starget_port_name = lpfc_get_starget_port_name, 2394 .get_starget_port_name = lpfc_get_starget_port_name,
2244 .show_starget_port_name = 1, 2395 .show_starget_port_name = 1,
2245 2396
2246 .issue_fc_host_lip = lpfc_issue_lip,
2247 .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk, 2397 .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk,
2248 .terminate_rport_io = lpfc_terminate_rport_io, 2398 .terminate_rport_io = lpfc_terminate_rport_io,
2249 2399
@@ -2253,39 +2403,25 @@ struct fc_function_template lpfc_vport_transport_functions = {
2253void 2403void
2254lpfc_get_cfgparam(struct lpfc_hba *phba) 2404lpfc_get_cfgparam(struct lpfc_hba *phba)
2255{ 2405{
2256 lpfc_log_verbose_init(phba, lpfc_log_verbose);
2257 lpfc_cr_delay_init(phba, lpfc_cr_delay); 2406 lpfc_cr_delay_init(phba, lpfc_cr_delay);
2258 lpfc_cr_count_init(phba, lpfc_cr_count); 2407 lpfc_cr_count_init(phba, lpfc_cr_count);
2259 lpfc_multi_ring_support_init(phba, lpfc_multi_ring_support); 2408 lpfc_multi_ring_support_init(phba, lpfc_multi_ring_support);
2260 lpfc_multi_ring_rctl_init(phba, lpfc_multi_ring_rctl); 2409 lpfc_multi_ring_rctl_init(phba, lpfc_multi_ring_rctl);
2261 lpfc_multi_ring_type_init(phba, lpfc_multi_ring_type); 2410 lpfc_multi_ring_type_init(phba, lpfc_multi_ring_type);
2262 lpfc_lun_queue_depth_init(phba, lpfc_lun_queue_depth);
2263 lpfc_fcp_class_init(phba, lpfc_fcp_class);
2264 lpfc_use_adisc_init(phba, lpfc_use_adisc);
2265 lpfc_ack0_init(phba, lpfc_ack0); 2411 lpfc_ack0_init(phba, lpfc_ack0);
2266 lpfc_topology_init(phba, lpfc_topology); 2412 lpfc_topology_init(phba, lpfc_topology);
2267 lpfc_scan_down_init(phba, lpfc_scan_down);
2268 lpfc_link_speed_init(phba, lpfc_link_speed); 2413 lpfc_link_speed_init(phba, lpfc_link_speed);
2269 lpfc_fdmi_on_init(phba, lpfc_fdmi_on);
2270 lpfc_discovery_threads_init(phba, lpfc_discovery_threads);
2271 lpfc_max_luns_init(phba, lpfc_max_luns);
2272 lpfc_poll_tmo_init(phba, lpfc_poll_tmo); 2414 lpfc_poll_tmo_init(phba, lpfc_poll_tmo);
2273 lpfc_peer_port_login_init(phba, lpfc_peer_port_login); 2415 lpfc_enable_npiv_init(phba, lpfc_enable_npiv);
2274 lpfc_npiv_enable_init(phba, lpfc_npiv_enable);
2275 lpfc_vport_restrict_login_init(phba, lpfc_vport_restrict_login);
2276 lpfc_use_msi_init(phba, lpfc_use_msi); 2416 lpfc_use_msi_init(phba, lpfc_use_msi);
2277 lpfc_devloss_tmo_init(phba, lpfc_devloss_tmo);
2278 lpfc_nodev_tmo_init(phba, lpfc_nodev_tmo);
2279 phba->cfg_poll = lpfc_poll; 2417 phba->cfg_poll = lpfc_poll;
2280 phba->cfg_soft_wwnn = 0L; 2418 phba->cfg_soft_wwnn = 0L;
2281 phba->cfg_soft_wwpn = 0L; 2419 phba->cfg_soft_wwpn = 0L;
2282
2283 /* 2420 /*
2284 * The total number of segments is the configuration value plus 2 2421 * The total number of segments is the configuration value plus 2
2285 * since the IOCB need a command and response bde. 2422 * since the IOCB need a command and response bde.
2286 */ 2423 */
2287 phba->cfg_sg_seg_cnt = LPFC_SG_SEG_CNT + 2; 2424 phba->cfg_sg_seg_cnt = LPFC_SG_SEG_CNT + 2;
2288
2289 /* 2425 /*
2290 * Since the sg_tablesize is module parameter, the sg_dma_buf_size 2426 * Since the sg_tablesize is module parameter, the sg_dma_buf_size
2291 * used to create the sg_dma_buf_pool must be dynamically calculated 2427 * used to create the sg_dma_buf_pool must be dynamically calculated
@@ -2293,9 +2429,24 @@ lpfc_get_cfgparam(struct lpfc_hba *phba)
2293 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) + 2429 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) +
2294 sizeof(struct fcp_rsp) + 2430 sizeof(struct fcp_rsp) +
2295 (phba->cfg_sg_seg_cnt * sizeof(struct ulp_bde64)); 2431 (phba->cfg_sg_seg_cnt * sizeof(struct ulp_bde64));
2296
2297
2298 lpfc_hba_queue_depth_init(phba, lpfc_hba_queue_depth); 2432 lpfc_hba_queue_depth_init(phba, lpfc_hba_queue_depth);
2433 return;
2434}
2299 2435
2436void
2437lpfc_get_vport_cfgparam(struct lpfc_vport *vport)
2438{
2439 lpfc_log_verbose_init(vport, lpfc_log_verbose);
2440 lpfc_lun_queue_depth_init(vport, lpfc_lun_queue_depth);
2441 lpfc_devloss_tmo_init(vport, lpfc_devloss_tmo);
2442 lpfc_nodev_tmo_init(vport, lpfc_nodev_tmo);
2443 lpfc_peer_port_login_init(vport, lpfc_peer_port_login);
2444 lpfc_restrict_login_init(vport, lpfc_restrict_login);
2445 lpfc_fcp_class_init(vport, lpfc_fcp_class);
2446 lpfc_use_adisc_init(vport, lpfc_use_adisc);
2447 lpfc_fdmi_on_init(vport, lpfc_fdmi_on);
2448 lpfc_discovery_threads_init(vport, lpfc_discovery_threads);
2449 lpfc_max_luns_init(vport, lpfc_max_luns);
2450 lpfc_scan_down_init(vport, lpfc_scan_down);
2300 return; 2451 return;
2301} 2452}