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

[SCSI] lpfc 8.1.11 : Add soft_wwnn sysfs attribute, rename soft_wwn_enable

The driver now allows both wwpn and wwnn to be set.

Signed-off-by: James Smart <James.Smart@emulex.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>

authored by

James Smart and committed by
James Bottomley
a12e07bc 18a3b596

+80 -11
+2 -1
drivers/scsi/lpfc/lpfc.h
··· 306 306 uint32_t cfg_use_msi; 307 307 uint32_t cfg_sg_seg_cnt; 308 308 uint32_t cfg_sg_dma_buf_size; 309 + uint64_t cfg_soft_wwnn; 309 310 uint64_t cfg_soft_wwpn; 310 311 311 312 uint32_t dev_loss_tmo_changed; ··· 359 358 #define VPD_PORT 0x8 /* valid vpd port data */ 360 359 #define VPD_MASK 0xf /* mask for any vpd data */ 361 360 362 - uint8_t soft_wwpn_enable; 361 + uint8_t soft_wwn_enable; 363 362 364 363 struct timer_list fcp_poll_timer; 365 364 struct timer_list els_tmofunc;
+74 -10
drivers/scsi/lpfc/lpfc_attr.c
··· 552 552 static CLASS_DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset); 553 553 554 554 555 - static char *lpfc_soft_wwpn_key = "C99G71SL8032A"; 555 + static char *lpfc_soft_wwn_key = "C99G71SL8032A"; 556 556 557 557 static ssize_t 558 - lpfc_soft_wwpn_enable_store(struct class_device *cdev, const char *buf, 558 + lpfc_soft_wwn_enable_store(struct class_device *cdev, const char *buf, 559 559 size_t count) 560 560 { 561 561 struct Scsi_Host *host = class_to_shost(cdev); ··· 579 579 if (buf[cnt-1] == '\n') 580 580 cnt--; 581 581 582 - if ((cnt != strlen(lpfc_soft_wwpn_key)) || 583 - (strncmp(buf, lpfc_soft_wwpn_key, strlen(lpfc_soft_wwpn_key)) != 0)) 582 + if ((cnt != strlen(lpfc_soft_wwn_key)) || 583 + (strncmp(buf, lpfc_soft_wwn_key, strlen(lpfc_soft_wwn_key)) != 0)) 584 584 return -EINVAL; 585 585 586 - phba->soft_wwpn_enable = 1; 586 + phba->soft_wwn_enable = 1; 587 587 return count; 588 588 } 589 - static CLASS_DEVICE_ATTR(lpfc_soft_wwpn_enable, S_IWUSR, NULL, 590 - lpfc_soft_wwpn_enable_store); 589 + static CLASS_DEVICE_ATTR(lpfc_soft_wwn_enable, S_IWUSR, NULL, 590 + lpfc_soft_wwn_enable_store); 591 591 592 592 static ssize_t 593 593 lpfc_soft_wwpn_show(struct class_device *cdev, char *buf) ··· 613 613 if (buf[cnt-1] == '\n') 614 614 cnt--; 615 615 616 - if (!phba->soft_wwpn_enable || (cnt < 16) || (cnt > 18) || 616 + if (!phba->soft_wwn_enable || (cnt < 16) || (cnt > 18) || 617 617 ((cnt == 17) && (*buf++ != 'x')) || 618 618 ((cnt == 18) && ((*buf++ != '0') || (*buf++ != 'x')))) 619 619 return -EINVAL; 620 620 621 - phba->soft_wwpn_enable = 0; 621 + phba->soft_wwn_enable = 0; 622 622 623 623 memset(wwpn, 0, sizeof(wwpn)); 624 624 ··· 639 639 } 640 640 phba->cfg_soft_wwpn = wwn_to_u64(wwpn); 641 641 fc_host_port_name(host) = phba->cfg_soft_wwpn; 642 + if (phba->cfg_soft_wwnn) 643 + fc_host_node_name(host) = phba->cfg_soft_wwnn; 642 644 643 645 dev_printk(KERN_NOTICE, &phba->pcidev->dev, 644 646 "lpfc%d: Reinitializing to use soft_wwpn\n", phba->brd_no); ··· 665 663 } 666 664 static CLASS_DEVICE_ATTR(lpfc_soft_wwpn, S_IRUGO | S_IWUSR,\ 667 665 lpfc_soft_wwpn_show, lpfc_soft_wwpn_store); 666 + 667 + static ssize_t 668 + lpfc_soft_wwnn_show(struct class_device *cdev, char *buf) 669 + { 670 + struct Scsi_Host *host = class_to_shost(cdev); 671 + struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata; 672 + return snprintf(buf, PAGE_SIZE, "0x%llx\n", 673 + (unsigned long long)phba->cfg_soft_wwnn); 674 + } 675 + 676 + 677 + static ssize_t 678 + lpfc_soft_wwnn_store(struct class_device *cdev, const char *buf, size_t count) 679 + { 680 + struct Scsi_Host *host = class_to_shost(cdev); 681 + struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata; 682 + unsigned int i, j, cnt=count; 683 + u8 wwnn[8]; 684 + 685 + /* count may include a LF at end of string */ 686 + if (buf[cnt-1] == '\n') 687 + cnt--; 688 + 689 + if (!phba->soft_wwn_enable || (cnt < 16) || (cnt > 18) || 690 + ((cnt == 17) && (*buf++ != 'x')) || 691 + ((cnt == 18) && ((*buf++ != '0') || (*buf++ != 'x')))) 692 + return -EINVAL; 693 + 694 + /* 695 + * Allow wwnn to be set many times, as long as the enable is set. 696 + * However, once the wwpn is set, everything locks. 697 + */ 698 + 699 + memset(wwnn, 0, sizeof(wwnn)); 700 + 701 + /* Validate and store the new name */ 702 + for (i=0, j=0; i < 16; i++) { 703 + if ((*buf >= 'a') && (*buf <= 'f')) 704 + j = ((j << 4) | ((*buf++ -'a') + 10)); 705 + else if ((*buf >= 'A') && (*buf <= 'F')) 706 + j = ((j << 4) | ((*buf++ -'A') + 10)); 707 + else if ((*buf >= '0') && (*buf <= '9')) 708 + j = ((j << 4) | (*buf++ -'0')); 709 + else 710 + return -EINVAL; 711 + if (i % 2) { 712 + wwnn[i/2] = j & 0xff; 713 + j = 0; 714 + } 715 + } 716 + phba->cfg_soft_wwnn = wwn_to_u64(wwnn); 717 + 718 + dev_printk(KERN_NOTICE, &phba->pcidev->dev, 719 + "lpfc%d: soft_wwnn set. Value will take effect upon " 720 + "setting of the soft_wwpn\n", phba->brd_no); 721 + 722 + return count; 723 + } 724 + static CLASS_DEVICE_ATTR(lpfc_soft_wwnn, S_IRUGO | S_IWUSR,\ 725 + lpfc_soft_wwnn_show, lpfc_soft_wwnn_store); 668 726 669 727 670 728 static int lpfc_poll = 0; ··· 1071 1009 &class_device_attr_lpfc_poll, 1072 1010 &class_device_attr_lpfc_poll_tmo, 1073 1011 &class_device_attr_lpfc_use_msi, 1012 + &class_device_attr_lpfc_soft_wwnn, 1074 1013 &class_device_attr_lpfc_soft_wwpn, 1075 - &class_device_attr_lpfc_soft_wwpn_enable, 1014 + &class_device_attr_lpfc_soft_wwn_enable, 1076 1015 NULL, 1077 1016 }; 1078 1017 ··· 1878 1815 lpfc_devloss_tmo_init(phba, lpfc_devloss_tmo); 1879 1816 lpfc_nodev_tmo_init(phba, lpfc_nodev_tmo); 1880 1817 phba->cfg_poll = lpfc_poll; 1818 + phba->cfg_soft_wwnn = 0L; 1881 1819 phba->cfg_soft_wwpn = 0L; 1882 1820 1883 1821 /*
+2
drivers/scsi/lpfc/lpfc_hbadisc.c
··· 672 672 673 673 memcpy((uint8_t *) & phba->fc_sparam, (uint8_t *) mp->virt, 674 674 sizeof (struct serv_parm)); 675 + if (phba->cfg_soft_wwnn) 676 + u64_to_wwn(phba->cfg_soft_wwnn, phba->fc_sparam.nodeName.u.wwn); 675 677 if (phba->cfg_soft_wwpn) 676 678 u64_to_wwn(phba->cfg_soft_wwpn, phba->fc_sparam.portName.u.wwn); 677 679 memcpy((uint8_t *) & phba->fc_nodename,
+2
drivers/scsi/lpfc/lpfc_init.c
··· 268 268 kfree(mp); 269 269 pmb->context1 = NULL; 270 270 271 + if (phba->cfg_soft_wwnn) 272 + u64_to_wwn(phba->cfg_soft_wwnn, phba->fc_sparam.nodeName.u.wwn); 271 273 if (phba->cfg_soft_wwpn) 272 274 u64_to_wwn(phba->cfg_soft_wwpn, phba->fc_sparam.portName.u.wwn); 273 275 memcpy(&phba->fc_nodename, &phba->fc_sparam.nodeName,