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

scsi: lpfc: Remove failing soft_wwn support

The soft_wwpn/soft_wwn functionality, which allows the driver to modify
service parameters in an attempt to override the adapter-assigned WWN, was
originally attempted to be removed roughly 6 yrs ago as new fabric features
were being introduced that clashed with the implementation. In the end,
the feature was left in with the user being responsible if things went
south.

We've reached a point where soft_wwn is no longer functional and is failing
in almost all production use cases. Use of Fabric features such as Fabric
Assigned WWPN and Automatic DPORT is now prevalent and the features require
coordination between the adapter and driver that can't be solved by the
simplistic update of the service parameters. As it is no longer functional,
the feature is to be removed.

There are still ways to override the adapter-assigned WWN but they require
the admin to invoke bios/efi level menus.

Link: https://lore.kernel.org/r/20220310154845.11125-1-jsmart2021@gmail.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Co-developed-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

James Smart and committed by
Martin K. Petersen
2ea3a393 2bd3b6b7

+1 -242
-3
drivers/scsi/lpfc/lpfc.h
··· 1135 1135 uint32_t cfg_nvme_seg_cnt; 1136 1136 uint32_t cfg_scsi_seg_cnt; 1137 1137 uint32_t cfg_sg_dma_buf_size; 1138 - uint64_t cfg_soft_wwnn; 1139 - uint64_t cfg_soft_wwpn; 1140 1138 uint32_t cfg_hba_queue_depth; 1141 1139 uint32_t cfg_enable_hba_reset; 1142 1140 uint32_t cfg_enable_hba_heartbeat; ··· 1266 1268 #define VPD_PORT 0x8 /* valid vpd port data */ 1267 1269 #define VPD_MASK 0xf /* mask for any vpd data */ 1268 1270 1269 - uint8_t soft_wwn_enable; 1270 1271 1271 1272 struct timer_list fcp_poll_timer; 1272 1273 struct timer_list eratt_poll;
-228
drivers/scsi/lpfc/lpfc_attr.c
··· 2835 2835 NULL); 2836 2836 static DEVICE_ATTR(cmf_info, 0444, lpfc_cmf_info_show, NULL); 2837 2837 2838 - static char *lpfc_soft_wwn_key = "C99G71SL8032A"; 2839 2838 #define WWN_SZ 8 2840 2839 /** 2841 2840 * lpfc_wwn_set - Convert string to the 8 byte WWN value. ··· 2878 2879 } 2879 2880 return 0; 2880 2881 } 2881 - /** 2882 - * lpfc_soft_wwn_enable_store - Allows setting of the wwn if the key is valid 2883 - * @dev: class device that is converted into a Scsi_host. 2884 - * @attr: device attribute, not used. 2885 - * @buf: containing the string lpfc_soft_wwn_key. 2886 - * @count: must be size of lpfc_soft_wwn_key. 2887 - * 2888 - * Returns: 2889 - * -EINVAL if the buffer does not contain lpfc_soft_wwn_key 2890 - * length of buf indicates success 2891 - **/ 2892 - static ssize_t 2893 - lpfc_soft_wwn_enable_store(struct device *dev, struct device_attribute *attr, 2894 - const char *buf, size_t count) 2895 - { 2896 - struct Scsi_Host *shost = class_to_shost(dev); 2897 - struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 2898 - struct lpfc_hba *phba = vport->phba; 2899 - unsigned int cnt = count; 2900 - uint8_t vvvl = vport->fc_sparam.cmn.valid_vendor_ver_level; 2901 - u32 *fawwpn_key = (uint32_t *)&vport->fc_sparam.un.vendorVersion[0]; 2902 2882 2903 - /* 2904 - * We're doing a simple sanity check for soft_wwpn setting. 2905 - * We require that the user write a specific key to enable 2906 - * the soft_wwpn attribute to be settable. Once the attribute 2907 - * is written, the enable key resets. If further updates are 2908 - * desired, the key must be written again to re-enable the 2909 - * attribute. 2910 - * 2911 - * The "key" is not secret - it is a hardcoded string shown 2912 - * here. The intent is to protect against the random user or 2913 - * application that is just writing attributes. 2914 - */ 2915 - if (vvvl == 1 && cpu_to_be32(*fawwpn_key) == FAPWWN_KEY_VENDOR) { 2916 - lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 2917 - "0051 lpfc soft wwpn can not be enabled: " 2918 - "fawwpn is enabled\n"); 2919 - return -EINVAL; 2920 - } 2921 - 2922 - /* count may include a LF at end of string */ 2923 - if (buf[cnt-1] == '\n') 2924 - cnt--; 2925 - 2926 - if ((cnt != strlen(lpfc_soft_wwn_key)) || 2927 - (strncmp(buf, lpfc_soft_wwn_key, strlen(lpfc_soft_wwn_key)) != 0)) 2928 - return -EINVAL; 2929 - 2930 - phba->soft_wwn_enable = 1; 2931 - 2932 - dev_printk(KERN_WARNING, &phba->pcidev->dev, 2933 - "lpfc%d: soft_wwpn assignment has been enabled.\n", 2934 - phba->brd_no); 2935 - dev_printk(KERN_WARNING, &phba->pcidev->dev, 2936 - " The soft_wwpn feature is not supported by Broadcom."); 2937 - 2938 - return count; 2939 - } 2940 - static DEVICE_ATTR_WO(lpfc_soft_wwn_enable); 2941 - 2942 - /** 2943 - * lpfc_soft_wwpn_show - Return the cfg soft ww port name of the adapter 2944 - * @dev: class device that is converted into a Scsi_host. 2945 - * @attr: device attribute, not used. 2946 - * @buf: on return contains the wwpn in hexadecimal. 2947 - * 2948 - * Returns: size of formatted string. 2949 - **/ 2950 - static ssize_t 2951 - lpfc_soft_wwpn_show(struct device *dev, struct device_attribute *attr, 2952 - char *buf) 2953 - { 2954 - struct Scsi_Host *shost = class_to_shost(dev); 2955 - struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 2956 - struct lpfc_hba *phba = vport->phba; 2957 - 2958 - return scnprintf(buf, PAGE_SIZE, "0x%llx\n", 2959 - (unsigned long long)phba->cfg_soft_wwpn); 2960 - } 2961 - 2962 - /** 2963 - * lpfc_soft_wwpn_store - Set the ww port name of the adapter 2964 - * @dev: class device that is converted into a Scsi_host. 2965 - * @attr: device attribute, not used. 2966 - * @buf: contains the wwpn in hexadecimal. 2967 - * @count: number of wwpn bytes in buf 2968 - * 2969 - * Returns: 2970 - * -EACCES hba reset not enabled, adapter over temp 2971 - * -EINVAL soft wwn not enabled, count is invalid, invalid wwpn byte invalid 2972 - * -EIO error taking adapter offline or online 2973 - * value of count on success 2974 - **/ 2975 - static ssize_t 2976 - lpfc_soft_wwpn_store(struct device *dev, struct device_attribute *attr, 2977 - const char *buf, size_t count) 2978 - { 2979 - struct Scsi_Host *shost = class_to_shost(dev); 2980 - struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 2981 - struct lpfc_hba *phba = vport->phba; 2982 - struct completion online_compl; 2983 - int stat1 = 0, stat2 = 0; 2984 - unsigned int cnt = count; 2985 - u8 wwpn[WWN_SZ]; 2986 - int rc; 2987 - 2988 - if (!phba->cfg_enable_hba_reset) 2989 - return -EACCES; 2990 - spin_lock_irq(&phba->hbalock); 2991 - if (phba->over_temp_state == HBA_OVER_TEMP) { 2992 - spin_unlock_irq(&phba->hbalock); 2993 - return -EACCES; 2994 - } 2995 - spin_unlock_irq(&phba->hbalock); 2996 - /* count may include a LF at end of string */ 2997 - if (buf[cnt-1] == '\n') 2998 - cnt--; 2999 - 3000 - if (!phba->soft_wwn_enable) 3001 - return -EINVAL; 3002 - 3003 - /* lock setting wwpn, wwnn down */ 3004 - phba->soft_wwn_enable = 0; 3005 - 3006 - rc = lpfc_wwn_set(buf, cnt, wwpn); 3007 - if (rc) { 3008 - /* not able to set wwpn, unlock it */ 3009 - phba->soft_wwn_enable = 1; 3010 - return rc; 3011 - } 3012 - 3013 - phba->cfg_soft_wwpn = wwn_to_u64(wwpn); 3014 - fc_host_port_name(shost) = phba->cfg_soft_wwpn; 3015 - if (phba->cfg_soft_wwnn) 3016 - fc_host_node_name(shost) = phba->cfg_soft_wwnn; 3017 - 3018 - dev_printk(KERN_NOTICE, &phba->pcidev->dev, 3019 - "lpfc%d: Reinitializing to use soft_wwpn\n", phba->brd_no); 3020 - 3021 - stat1 = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); 3022 - if (stat1) 3023 - lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 3024 - "0463 lpfc_soft_wwpn attribute set failed to " 3025 - "reinit adapter - %d\n", stat1); 3026 - init_completion(&online_compl); 3027 - rc = lpfc_workq_post_event(phba, &stat2, &online_compl, 3028 - LPFC_EVT_ONLINE); 3029 - if (rc == 0) 3030 - return -ENOMEM; 3031 - 3032 - wait_for_completion(&online_compl); 3033 - if (stat2) 3034 - lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 3035 - "0464 lpfc_soft_wwpn attribute set failed to " 3036 - "reinit adapter - %d\n", stat2); 3037 - return (stat1 || stat2) ? -EIO : count; 3038 - } 3039 - static DEVICE_ATTR_RW(lpfc_soft_wwpn); 3040 - 3041 - /** 3042 - * lpfc_soft_wwnn_show - Return the cfg soft ww node name for the adapter 3043 - * @dev: class device that is converted into a Scsi_host. 3044 - * @attr: device attribute, not used. 3045 - * @buf: on return contains the wwnn in hexadecimal. 3046 - * 3047 - * Returns: size of formatted string. 3048 - **/ 3049 - static ssize_t 3050 - lpfc_soft_wwnn_show(struct device *dev, struct device_attribute *attr, 3051 - char *buf) 3052 - { 3053 - struct Scsi_Host *shost = class_to_shost(dev); 3054 - struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; 3055 - return scnprintf(buf, PAGE_SIZE, "0x%llx\n", 3056 - (unsigned long long)phba->cfg_soft_wwnn); 3057 - } 3058 - 3059 - /** 3060 - * lpfc_soft_wwnn_store - sets the ww node name of the adapter 3061 - * @dev: class device that is converted into a Scsi_host. 3062 - * @attr: device attribute, not used. 3063 - * @buf: contains the ww node name in hexadecimal. 3064 - * @count: number of wwnn bytes in buf. 3065 - * 3066 - * Returns: 3067 - * -EINVAL soft wwn not enabled, count is invalid, invalid wwnn byte invalid 3068 - * value of count on success 3069 - **/ 3070 - static ssize_t 3071 - lpfc_soft_wwnn_store(struct device *dev, struct device_attribute *attr, 3072 - const char *buf, size_t count) 3073 - { 3074 - struct Scsi_Host *shost = class_to_shost(dev); 3075 - struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; 3076 - unsigned int cnt = count; 3077 - u8 wwnn[WWN_SZ]; 3078 - int rc; 3079 - 3080 - /* count may include a LF at end of string */ 3081 - if (buf[cnt-1] == '\n') 3082 - cnt--; 3083 - 3084 - if (!phba->soft_wwn_enable) 3085 - return -EINVAL; 3086 - 3087 - rc = lpfc_wwn_set(buf, cnt, wwnn); 3088 - if (rc) { 3089 - /* Allow wwnn to be set many times, as long as the enable 3090 - * is set. However, once the wwpn is set, everything locks. 3091 - */ 3092 - return rc; 3093 - } 3094 - 3095 - phba->cfg_soft_wwnn = wwn_to_u64(wwnn); 3096 - 3097 - dev_printk(KERN_NOTICE, &phba->pcidev->dev, 3098 - "lpfc%d: soft_wwnn set. Value will take effect upon " 3099 - "setting of the soft_wwpn\n", phba->brd_no); 3100 - 3101 - return count; 3102 - } 3103 - static DEVICE_ATTR_RW(lpfc_soft_wwnn); 3104 2883 3105 2884 /** 3106 2885 * lpfc_oas_tgt_show - Return wwpn of target whose luns maybe enabled for ··· 6272 6495 &dev_attr_lpfc_nvme_enable_fb.attr, 6273 6496 &dev_attr_lpfc_nvmet_fb_size.attr, 6274 6497 &dev_attr_lpfc_enable_bg.attr, 6275 - &dev_attr_lpfc_soft_wwnn.attr, 6276 - &dev_attr_lpfc_soft_wwpn.attr, 6277 - &dev_attr_lpfc_soft_wwn_enable.attr, 6278 6498 &dev_attr_lpfc_enable_hba_reset.attr, 6279 6499 &dev_attr_lpfc_enable_hba_heartbeat.attr, 6280 6500 &dev_attr_lpfc_EnableXLane.attr, ··· 7501 7727 phba->sli_rev == LPFC_SLI_REV4) 7502 7728 phba->cfg_irq_chann = phba->cfg_hdw_queue; 7503 7729 7504 - phba->cfg_soft_wwnn = 0L; 7505 - phba->cfg_soft_wwpn = 0L; 7506 7730 lpfc_sg_seg_cnt_init(phba, lpfc_sg_seg_cnt); 7507 7731 lpfc_hba_queue_depth_init(phba, lpfc_hba_queue_depth); 7508 7732 lpfc_aer_support_init(phba, lpfc_aer_support);
+1 -11
drivers/scsi/lpfc/lpfc_init.c
··· 340 340 341 341 /** 342 342 * lpfc_update_vport_wwn - Updates the fc_nodename, fc_portname, 343 - * cfg_soft_wwnn, cfg_soft_wwpn 344 343 * @vport: pointer to lpfc vport data structure. 345 344 * 346 345 * ··· 352 353 uint8_t vvvl = vport->fc_sparam.cmn.valid_vendor_ver_level; 353 354 u32 *fawwpn_key = (u32 *)&vport->fc_sparam.un.vendorVersion[0]; 354 355 355 - /* If the soft name exists then update it using the service params */ 356 - if (vport->phba->cfg_soft_wwnn) 357 - u64_to_wwn(vport->phba->cfg_soft_wwnn, 358 - vport->fc_sparam.nodeName.u.wwn); 359 - if (vport->phba->cfg_soft_wwpn) 360 - u64_to_wwn(vport->phba->cfg_soft_wwpn, 361 - vport->fc_sparam.portName.u.wwn); 362 - 363 356 /* 364 357 * If the name is empty or there exists a soft name 365 358 * then copy the service params name, otherwise use the fc name 366 359 */ 367 - if (vport->fc_nodename.u.wwn[0] == 0 || vport->phba->cfg_soft_wwnn) 360 + if (vport->fc_nodename.u.wwn[0] == 0) 368 361 memcpy(&vport->fc_nodename, &vport->fc_sparam.nodeName, 369 362 sizeof(struct lpfc_name)); 370 363 else ··· 373 382 vport->vport_flag |= FAWWPN_PARAM_CHG; 374 383 375 384 if (vport->fc_portname.u.wwn[0] == 0 || 376 - vport->phba->cfg_soft_wwpn || 377 385 (vvvl == 1 && cpu_to_be32(*fawwpn_key) == FAPWWN_KEY_VENDOR) || 378 386 vport->vport_flag & FAWWPN_SET) { 379 387 memcpy(&vport->fc_portname, &vport->fc_sparam.portName,