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.c262
1 files changed, 244 insertions, 18 deletions
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index e1a30a16a9fa..75523603b91c 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -23,12 +23,14 @@
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/pci.h> 24#include <linux/pci.h>
25#include <linux/interrupt.h> 25#include <linux/interrupt.h>
26#include <linux/aer.h>
26 27
27#include <scsi/scsi.h> 28#include <scsi/scsi.h>
28#include <scsi/scsi_device.h> 29#include <scsi/scsi_device.h>
29#include <scsi/scsi_host.h> 30#include <scsi/scsi_host.h>
30#include <scsi/scsi_tcq.h> 31#include <scsi/scsi_tcq.h>
31#include <scsi/scsi_transport_fc.h> 32#include <scsi/scsi_transport_fc.h>
33#include <scsi/fc/fc_fs.h>
32 34
33#include "lpfc_hw4.h" 35#include "lpfc_hw4.h"
34#include "lpfc_hw.h" 36#include "lpfc_hw.h"
@@ -98,6 +100,28 @@ lpfc_drvr_version_show(struct device *dev, struct device_attribute *attr,
98 return snprintf(buf, PAGE_SIZE, LPFC_MODULE_DESC "\n"); 100 return snprintf(buf, PAGE_SIZE, LPFC_MODULE_DESC "\n");
99} 101}
100 102
103/**
104 * lpfc_enable_fip_show - Return the fip mode of the HBA
105 * @dev: class unused variable.
106 * @attr: device attribute, not used.
107 * @buf: on return contains the module description text.
108 *
109 * Returns: size of formatted string.
110 **/
111static ssize_t
112lpfc_enable_fip_show(struct device *dev, struct device_attribute *attr,
113 char *buf)
114{
115 struct Scsi_Host *shost = class_to_shost(dev);
116 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
117 struct lpfc_hba *phba = vport->phba;
118
119 if (phba->hba_flag & HBA_FIP_SUPPORT)
120 return snprintf(buf, PAGE_SIZE, "1\n");
121 else
122 return snprintf(buf, PAGE_SIZE, "0\n");
123}
124
101static ssize_t 125static ssize_t
102lpfc_bg_info_show(struct device *dev, struct device_attribute *attr, 126lpfc_bg_info_show(struct device *dev, struct device_attribute *attr,
103 char *buf) 127 char *buf)
@@ -762,9 +786,15 @@ lpfc_board_mode_store(struct device *dev, struct device_attribute *attr,
762 } else if (strncmp(buf, "offline", sizeof("offline") - 1) == 0) 786 } else if (strncmp(buf, "offline", sizeof("offline") - 1) == 0)
763 status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); 787 status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE);
764 else if (strncmp(buf, "warm", sizeof("warm") - 1) == 0) 788 else if (strncmp(buf, "warm", sizeof("warm") - 1) == 0)
765 status = lpfc_do_offline(phba, LPFC_EVT_WARM_START); 789 if (phba->sli_rev == LPFC_SLI_REV4)
790 return -EINVAL;
791 else
792 status = lpfc_do_offline(phba, LPFC_EVT_WARM_START);
766 else if (strncmp(buf, "error", sizeof("error") - 1) == 0) 793 else if (strncmp(buf, "error", sizeof("error") - 1) == 0)
767 status = lpfc_do_offline(phba, LPFC_EVT_KILL); 794 if (phba->sli_rev == LPFC_SLI_REV4)
795 return -EINVAL;
796 else
797 status = lpfc_do_offline(phba, LPFC_EVT_KILL);
768 else 798 else
769 return -EINVAL; 799 return -EINVAL;
770 800
@@ -1126,6 +1156,9 @@ lpfc_poll_store(struct device *dev, struct device_attribute *attr,
1126 if ((val & 0x3) != val) 1156 if ((val & 0x3) != val)
1127 return -EINVAL; 1157 return -EINVAL;
1128 1158
1159 if (phba->sli_rev == LPFC_SLI_REV4)
1160 val = 0;
1161
1129 spin_lock_irq(&phba->hbalock); 1162 spin_lock_irq(&phba->hbalock);
1130 1163
1131 old_val = phba->cfg_poll; 1164 old_val = phba->cfg_poll;
@@ -1589,6 +1622,7 @@ static DEVICE_ATTR(num_discovered_ports, S_IRUGO,
1589static DEVICE_ATTR(menlo_mgmt_mode, S_IRUGO, lpfc_mlomgmt_show, NULL); 1622static DEVICE_ATTR(menlo_mgmt_mode, S_IRUGO, lpfc_mlomgmt_show, NULL);
1590static DEVICE_ATTR(nport_evt_cnt, S_IRUGO, lpfc_nport_evt_cnt_show, NULL); 1623static DEVICE_ATTR(nport_evt_cnt, S_IRUGO, lpfc_nport_evt_cnt_show, NULL);
1591static DEVICE_ATTR(lpfc_drvr_version, S_IRUGO, lpfc_drvr_version_show, NULL); 1624static DEVICE_ATTR(lpfc_drvr_version, S_IRUGO, lpfc_drvr_version_show, NULL);
1625static DEVICE_ATTR(lpfc_enable_fip, S_IRUGO, lpfc_enable_fip_show, NULL);
1592static DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR, 1626static DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR,
1593 lpfc_board_mode_show, lpfc_board_mode_store); 1627 lpfc_board_mode_show, lpfc_board_mode_store);
1594static DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset); 1628static DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset);
@@ -2759,6 +2793,196 @@ static DEVICE_ATTR(lpfc_link_speed, S_IRUGO | S_IWUSR,
2759 lpfc_link_speed_show, lpfc_link_speed_store); 2793 lpfc_link_speed_show, lpfc_link_speed_store);
2760 2794
2761/* 2795/*
2796# lpfc_aer_support: Support PCIe device Advanced Error Reporting (AER)
2797# 0 = aer disabled or not supported
2798# 1 = aer supported and enabled (default)
2799# Value range is [0,1]. Default value is 1.
2800*/
2801
2802/**
2803 * lpfc_aer_support_store - Set the adapter for aer support
2804 *
2805 * @dev: class device that is converted into a Scsi_host.
2806 * @attr: device attribute, not used.
2807 * @buf: containing the string "selective".
2808 * @count: unused variable.
2809 *
2810 * Description:
2811 * If the val is 1 and currently the device's AER capability was not
2812 * enabled, invoke the kernel's enable AER helper routine, trying to
2813 * enable the device's AER capability. If the helper routine enabling
2814 * AER returns success, update the device's cfg_aer_support flag to
2815 * indicate AER is supported by the device; otherwise, if the device
2816 * AER capability is already enabled to support AER, then do nothing.
2817 *
2818 * If the val is 0 and currently the device's AER support was enabled,
2819 * invoke the kernel's disable AER helper routine. After that, update
2820 * the device's cfg_aer_support flag to indicate AER is not supported
2821 * by the device; otherwise, if the device AER capability is already
2822 * disabled from supporting AER, then do nothing.
2823 *
2824 * Returns:
2825 * length of the buf on success if val is in range the intended mode
2826 * is supported.
2827 * -EINVAL if val out of range or intended mode is not supported.
2828 **/
2829static ssize_t
2830lpfc_aer_support_store(struct device *dev, struct device_attribute *attr,
2831 const char *buf, size_t count)
2832{
2833 struct Scsi_Host *shost = class_to_shost(dev);
2834 struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata;
2835 struct lpfc_hba *phba = vport->phba;
2836 int val = 0, rc = -EINVAL;
2837
2838 /* AER not supported on OC devices yet */
2839 if (phba->pci_dev_grp == LPFC_PCI_DEV_OC)
2840 return -EPERM;
2841 if (!isdigit(buf[0]))
2842 return -EINVAL;
2843 if (sscanf(buf, "%i", &val) != 1)
2844 return -EINVAL;
2845
2846 switch (val) {
2847 case 0:
2848 if (phba->hba_flag & HBA_AER_ENABLED) {
2849 rc = pci_disable_pcie_error_reporting(phba->pcidev);
2850 if (!rc) {
2851 spin_lock_irq(&phba->hbalock);
2852 phba->hba_flag &= ~HBA_AER_ENABLED;
2853 spin_unlock_irq(&phba->hbalock);
2854 phba->cfg_aer_support = 0;
2855 rc = strlen(buf);
2856 } else
2857 rc = -EPERM;
2858 } else {
2859 phba->cfg_aer_support = 0;
2860 rc = strlen(buf);
2861 }
2862 break;
2863 case 1:
2864 if (!(phba->hba_flag & HBA_AER_ENABLED)) {
2865 rc = pci_enable_pcie_error_reporting(phba->pcidev);
2866 if (!rc) {
2867 spin_lock_irq(&phba->hbalock);
2868 phba->hba_flag |= HBA_AER_ENABLED;
2869 spin_unlock_irq(&phba->hbalock);
2870 phba->cfg_aer_support = 1;
2871 rc = strlen(buf);
2872 } else
2873 rc = -EPERM;
2874 } else {
2875 phba->cfg_aer_support = 1;
2876 rc = strlen(buf);
2877 }
2878 break;
2879 default:
2880 rc = -EINVAL;
2881 break;
2882 }
2883 return rc;
2884}
2885
2886static int lpfc_aer_support = 1;
2887module_param(lpfc_aer_support, int, 1);
2888MODULE_PARM_DESC(lpfc_aer_support, "Enable PCIe device AER support");
2889lpfc_param_show(aer_support)
2890
2891/**
2892 * lpfc_aer_support_init - Set the initial adapters aer support flag
2893 * @phba: lpfc_hba pointer.
2894 * @val: link speed value.
2895 *
2896 * Description:
2897 * If val is in a valid range [0,1], then set the adapter's initial
2898 * cfg_aer_support field. It will be up to the driver's probe_one
2899 * routine to determine whether the device's AER support can be set
2900 * or not.
2901 *
2902 * Notes:
2903 * If the value is not in range log a kernel error message, and
2904 * choose the default value of setting AER support and return.
2905 *
2906 * Returns:
2907 * zero if val saved.
2908 * -EINVAL val out of range
2909 **/
2910static int
2911lpfc_aer_support_init(struct lpfc_hba *phba, int val)
2912{
2913 /* AER not supported on OC devices yet */
2914 if (phba->pci_dev_grp == LPFC_PCI_DEV_OC) {
2915 phba->cfg_aer_support = 0;
2916 return -EPERM;
2917 }
2918
2919 if (val == 0 || val == 1) {
2920 phba->cfg_aer_support = val;
2921 return 0;
2922 }
2923 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
2924 "2712 lpfc_aer_support attribute value %d out "
2925 "of range, allowed values are 0|1, setting it "
2926 "to default value of 1\n", val);
2927 /* By default, try to enable AER on a device */
2928 phba->cfg_aer_support = 1;
2929 return -EINVAL;
2930}
2931
2932static DEVICE_ATTR(lpfc_aer_support, S_IRUGO | S_IWUSR,
2933 lpfc_aer_support_show, lpfc_aer_support_store);
2934
2935/**
2936 * lpfc_aer_cleanup_state - Clean up aer state to the aer enabled device
2937 * @dev: class device that is converted into a Scsi_host.
2938 * @attr: device attribute, not used.
2939 * @buf: containing the string "selective".
2940 * @count: unused variable.
2941 *
2942 * Description:
2943 * If the @buf contains 1 and the device currently has the AER support
2944 * enabled, then invokes the kernel AER helper routine
2945 * pci_cleanup_aer_uncorrect_error_status to clean up the uncorrectable
2946 * error status register.
2947 *
2948 * Notes:
2949 *
2950 * Returns:
2951 * -EINVAL if the buf does not contain the 1 or the device is not currently
2952 * enabled with the AER support.
2953 **/
2954static ssize_t
2955lpfc_aer_cleanup_state(struct device *dev, struct device_attribute *attr,
2956 const char *buf, size_t count)
2957{
2958 struct Scsi_Host *shost = class_to_shost(dev);
2959 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
2960 struct lpfc_hba *phba = vport->phba;
2961 int val, rc = -1;
2962
2963 /* AER not supported on OC devices yet */
2964 if (phba->pci_dev_grp == LPFC_PCI_DEV_OC)
2965 return -EPERM;
2966 if (!isdigit(buf[0]))
2967 return -EINVAL;
2968 if (sscanf(buf, "%i", &val) != 1)
2969 return -EINVAL;
2970 if (val != 1)
2971 return -EINVAL;
2972
2973 if (phba->hba_flag & HBA_AER_ENABLED)
2974 rc = pci_cleanup_aer_uncorrect_error_status(phba->pcidev);
2975
2976 if (rc == 0)
2977 return strlen(buf);
2978 else
2979 return -EPERM;
2980}
2981
2982static DEVICE_ATTR(lpfc_aer_state_cleanup, S_IWUSR, NULL,
2983 lpfc_aer_cleanup_state);
2984
2985/*
2762# lpfc_fcp_class: Determines FC class to use for the FCP protocol. 2986# lpfc_fcp_class: Determines FC class to use for the FCP protocol.
2763# Value range is [2,3]. Default value is 3. 2987# Value range is [2,3]. Default value is 3.
2764*/ 2988*/
@@ -2846,7 +3070,7 @@ LPFC_ATTR_R(multi_ring_support, 1, 1, 2, "Determines number of primary "
2846# identifies what rctl value to configure the additional ring for. 3070# identifies what rctl value to configure the additional ring for.
2847# Value range is [1,0xff]. Default value is 4 (Unsolicated Data). 3071# Value range is [1,0xff]. Default value is 4 (Unsolicated Data).
2848*/ 3072*/
2849LPFC_ATTR_R(multi_ring_rctl, FC_UNSOL_DATA, 1, 3073LPFC_ATTR_R(multi_ring_rctl, FC_RCTL_DD_UNSOL_DATA, 1,
2850 255, "Identifies RCTL for additional ring configuration"); 3074 255, "Identifies RCTL for additional ring configuration");
2851 3075
2852/* 3076/*
@@ -2854,7 +3078,7 @@ LPFC_ATTR_R(multi_ring_rctl, FC_UNSOL_DATA, 1,
2854# identifies what type value to configure the additional ring for. 3078# identifies what type value to configure the additional ring for.
2855# Value range is [1,0xff]. Default value is 5 (LLC/SNAP). 3079# Value range is [1,0xff]. Default value is 5 (LLC/SNAP).
2856*/ 3080*/
2857LPFC_ATTR_R(multi_ring_type, FC_LLC_SNAP, 1, 3081LPFC_ATTR_R(multi_ring_type, FC_TYPE_IP, 1,
2858 255, "Identifies TYPE for additional ring configuration"); 3082 255, "Identifies TYPE for additional ring configuration");
2859 3083
2860/* 3084/*
@@ -2947,15 +3171,6 @@ LPFC_ATTR_R(enable_hba_heartbeat, 1, 0, 1, "Enable HBA Heartbeat.");
2947LPFC_ATTR_R(enable_bg, 0, 0, 1, "Enable BlockGuard Support"); 3171LPFC_ATTR_R(enable_bg, 0, 0, 1, "Enable BlockGuard Support");
2948 3172
2949/* 3173/*
2950# lpfc_enable_fip: When set, FIP is required to start discovery. If not
2951# set, the driver will add an FCF record manually if the port has no
2952# FCF records available and start discovery.
2953# Value range is [0,1]. Default value is 1 (enabled)
2954*/
2955LPFC_ATTR_RW(enable_fip, 0, 0, 1, "Enable FIP Discovery");
2956
2957
2958/*
2959# lpfc_prot_mask: i 3174# lpfc_prot_mask: i
2960# - Bit mask of host protection capabilities used to register with the 3175# - Bit mask of host protection capabilities used to register with the
2961# SCSI mid-layer 3176# SCSI mid-layer
@@ -3013,6 +3228,7 @@ struct device_attribute *lpfc_hba_attrs[] = {
3013 &dev_attr_num_discovered_ports, 3228 &dev_attr_num_discovered_ports,
3014 &dev_attr_menlo_mgmt_mode, 3229 &dev_attr_menlo_mgmt_mode,
3015 &dev_attr_lpfc_drvr_version, 3230 &dev_attr_lpfc_drvr_version,
3231 &dev_attr_lpfc_enable_fip,
3016 &dev_attr_lpfc_temp_sensor, 3232 &dev_attr_lpfc_temp_sensor,
3017 &dev_attr_lpfc_log_verbose, 3233 &dev_attr_lpfc_log_verbose,
3018 &dev_attr_lpfc_lun_queue_depth, 3234 &dev_attr_lpfc_lun_queue_depth,
@@ -3020,7 +3236,6 @@ struct device_attribute *lpfc_hba_attrs[] = {
3020 &dev_attr_lpfc_peer_port_login, 3236 &dev_attr_lpfc_peer_port_login,
3021 &dev_attr_lpfc_nodev_tmo, 3237 &dev_attr_lpfc_nodev_tmo,
3022 &dev_attr_lpfc_devloss_tmo, 3238 &dev_attr_lpfc_devloss_tmo,
3023 &dev_attr_lpfc_enable_fip,
3024 &dev_attr_lpfc_fcp_class, 3239 &dev_attr_lpfc_fcp_class,
3025 &dev_attr_lpfc_use_adisc, 3240 &dev_attr_lpfc_use_adisc,
3026 &dev_attr_lpfc_ack0, 3241 &dev_attr_lpfc_ack0,
@@ -3061,6 +3276,8 @@ struct device_attribute *lpfc_hba_attrs[] = {
3061 &dev_attr_lpfc_max_scsicmpl_time, 3276 &dev_attr_lpfc_max_scsicmpl_time,
3062 &dev_attr_lpfc_stat_data_ctrl, 3277 &dev_attr_lpfc_stat_data_ctrl,
3063 &dev_attr_lpfc_prot_sg_seg_cnt, 3278 &dev_attr_lpfc_prot_sg_seg_cnt,
3279 &dev_attr_lpfc_aer_support,
3280 &dev_attr_lpfc_aer_state_cleanup,
3064 NULL, 3281 NULL,
3065}; 3282};
3066 3283
@@ -3073,7 +3290,6 @@ struct device_attribute *lpfc_vport_attrs[] = {
3073 &dev_attr_lpfc_lun_queue_depth, 3290 &dev_attr_lpfc_lun_queue_depth,
3074 &dev_attr_lpfc_nodev_tmo, 3291 &dev_attr_lpfc_nodev_tmo,
3075 &dev_attr_lpfc_devloss_tmo, 3292 &dev_attr_lpfc_devloss_tmo,
3076 &dev_attr_lpfc_enable_fip,
3077 &dev_attr_lpfc_hba_queue_depth, 3293 &dev_attr_lpfc_hba_queue_depth,
3078 &dev_attr_lpfc_peer_port_login, 3294 &dev_attr_lpfc_peer_port_login,
3079 &dev_attr_lpfc_restrict_login, 3295 &dev_attr_lpfc_restrict_login,
@@ -3815,7 +4031,11 @@ lpfc_get_stats(struct Scsi_Host *shost)
3815 hs->invalid_crc_count -= lso->invalid_crc_count; 4031 hs->invalid_crc_count -= lso->invalid_crc_count;
3816 hs->error_frames -= lso->error_frames; 4032 hs->error_frames -= lso->error_frames;
3817 4033
3818 if (phba->fc_topology == TOPOLOGY_LOOP) { 4034 if (phba->hba_flag & HBA_FCOE_SUPPORT) {
4035 hs->lip_count = -1;
4036 hs->nos_count = (phba->link_events >> 1);
4037 hs->nos_count -= lso->link_events;
4038 } else if (phba->fc_topology == TOPOLOGY_LOOP) {
3819 hs->lip_count = (phba->fc_eventTag >> 1); 4039 hs->lip_count = (phba->fc_eventTag >> 1);
3820 hs->lip_count -= lso->link_events; 4040 hs->lip_count -= lso->link_events;
3821 hs->nos_count = -1; 4041 hs->nos_count = -1;
@@ -3906,7 +4126,10 @@ lpfc_reset_stats(struct Scsi_Host *shost)
3906 lso->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord; 4126 lso->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord;
3907 lso->invalid_crc_count = pmb->un.varRdLnk.crcCnt; 4127 lso->invalid_crc_count = pmb->un.varRdLnk.crcCnt;
3908 lso->error_frames = pmb->un.varRdLnk.crcCnt; 4128 lso->error_frames = pmb->un.varRdLnk.crcCnt;
3909 lso->link_events = (phba->fc_eventTag >> 1); 4129 if (phba->hba_flag & HBA_FCOE_SUPPORT)
4130 lso->link_events = (phba->link_events >> 1);
4131 else
4132 lso->link_events = (phba->fc_eventTag >> 1);
3910 4133
3911 psli->stats_start = get_seconds(); 4134 psli->stats_start = get_seconds();
3912 4135
@@ -4222,14 +4445,17 @@ lpfc_get_cfgparam(struct lpfc_hba *phba)
4222 lpfc_enable_hba_reset_init(phba, lpfc_enable_hba_reset); 4445 lpfc_enable_hba_reset_init(phba, lpfc_enable_hba_reset);
4223 lpfc_enable_hba_heartbeat_init(phba, lpfc_enable_hba_heartbeat); 4446 lpfc_enable_hba_heartbeat_init(phba, lpfc_enable_hba_heartbeat);
4224 lpfc_enable_bg_init(phba, lpfc_enable_bg); 4447 lpfc_enable_bg_init(phba, lpfc_enable_bg);
4448 if (phba->sli_rev == LPFC_SLI_REV4)
4449 phba->cfg_poll = 0;
4450 else
4225 phba->cfg_poll = lpfc_poll; 4451 phba->cfg_poll = lpfc_poll;
4226 phba->cfg_soft_wwnn = 0L; 4452 phba->cfg_soft_wwnn = 0L;
4227 phba->cfg_soft_wwpn = 0L; 4453 phba->cfg_soft_wwpn = 0L;
4228 lpfc_sg_seg_cnt_init(phba, lpfc_sg_seg_cnt); 4454 lpfc_sg_seg_cnt_init(phba, lpfc_sg_seg_cnt);
4229 lpfc_prot_sg_seg_cnt_init(phba, lpfc_prot_sg_seg_cnt); 4455 lpfc_prot_sg_seg_cnt_init(phba, lpfc_prot_sg_seg_cnt);
4230 lpfc_hba_queue_depth_init(phba, lpfc_hba_queue_depth); 4456 lpfc_hba_queue_depth_init(phba, lpfc_hba_queue_depth);
4231 lpfc_enable_fip_init(phba, lpfc_enable_fip);
4232 lpfc_hba_log_verbose_init(phba, lpfc_log_verbose); 4457 lpfc_hba_log_verbose_init(phba, lpfc_log_verbose);
4458 lpfc_aer_support_init(phba, lpfc_aer_support);
4233 4459
4234 return; 4460 return;
4235} 4461}