diff options
author | Adheer Chandravanshi <adheer.chandravanshi@qlogic.com> | 2013-11-22 05:28:23 -0500 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2013-12-19 23:56:27 -0500 |
commit | ea507a2530e07014b550f70819efff29f9a757d7 (patch) | |
tree | 0b439775238f92a3e1f31f400cc81ee3ed87377b | |
parent | fb734ee3eff40c1374e23be6eaf666681e6137ac (diff) |
[SCSI] qla4xxx: Recreate chap data list during get chap operation
Recreate the chap data list during the get chap operation in
qla4xxx_get_chap_list().
Signed-off-by: Adheer Chandravanshi <adheer.chandravanshi@qlogic.com>
Signed-off-by: Vikas Chaudhary <vikas.chaudhary@qlogic.com>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
-rw-r--r-- | drivers/scsi/qla4xxx/ql4_os.c | 119 |
1 files changed, 61 insertions, 58 deletions
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c index 9b8a2c342b5d..c21adc338cf1 100644 --- a/drivers/scsi/qla4xxx/ql4_os.c +++ b/drivers/scsi/qla4xxx/ql4_os.c | |||
@@ -573,6 +573,65 @@ static umode_t qla4_attr_is_visible(int param_type, int param) | |||
573 | return 0; | 573 | return 0; |
574 | } | 574 | } |
575 | 575 | ||
576 | /** | ||
577 | * qla4xxx_create chap_list - Create CHAP list from FLASH | ||
578 | * @ha: pointer to adapter structure | ||
579 | * | ||
580 | * Read flash and make a list of CHAP entries, during login when a CHAP entry | ||
581 | * is received, it will be checked in this list. If entry exist then the CHAP | ||
582 | * entry index is set in the DDB. If CHAP entry does not exist in this list | ||
583 | * then a new entry is added in FLASH in CHAP table and the index obtained is | ||
584 | * used in the DDB. | ||
585 | **/ | ||
586 | static void qla4xxx_create_chap_list(struct scsi_qla_host *ha) | ||
587 | { | ||
588 | int rval = 0; | ||
589 | uint8_t *chap_flash_data = NULL; | ||
590 | uint32_t offset; | ||
591 | dma_addr_t chap_dma; | ||
592 | uint32_t chap_size = 0; | ||
593 | |||
594 | if (is_qla40XX(ha)) | ||
595 | chap_size = MAX_CHAP_ENTRIES_40XX * | ||
596 | sizeof(struct ql4_chap_table); | ||
597 | else /* Single region contains CHAP info for both | ||
598 | * ports which is divided into half for each port. | ||
599 | */ | ||
600 | chap_size = ha->hw.flt_chap_size / 2; | ||
601 | |||
602 | chap_flash_data = dma_alloc_coherent(&ha->pdev->dev, chap_size, | ||
603 | &chap_dma, GFP_KERNEL); | ||
604 | if (!chap_flash_data) { | ||
605 | ql4_printk(KERN_ERR, ha, "No memory for chap_flash_data\n"); | ||
606 | return; | ||
607 | } | ||
608 | |||
609 | if (is_qla40XX(ha)) { | ||
610 | offset = FLASH_CHAP_OFFSET; | ||
611 | } else { | ||
612 | offset = FLASH_RAW_ACCESS_ADDR + (ha->hw.flt_region_chap << 2); | ||
613 | if (ha->port_num == 1) | ||
614 | offset += chap_size; | ||
615 | } | ||
616 | |||
617 | rval = qla4xxx_get_flash(ha, chap_dma, offset, chap_size); | ||
618 | if (rval != QLA_SUCCESS) | ||
619 | goto exit_chap_list; | ||
620 | |||
621 | if (ha->chap_list == NULL) | ||
622 | ha->chap_list = vmalloc(chap_size); | ||
623 | if (ha->chap_list == NULL) { | ||
624 | ql4_printk(KERN_ERR, ha, "No memory for ha->chap_list\n"); | ||
625 | goto exit_chap_list; | ||
626 | } | ||
627 | |||
628 | memset(ha->chap_list, 0, chap_size); | ||
629 | memcpy(ha->chap_list, chap_flash_data, chap_size); | ||
630 | |||
631 | exit_chap_list: | ||
632 | dma_free_coherent(&ha->pdev->dev, chap_size, chap_flash_data, chap_dma); | ||
633 | } | ||
634 | |||
576 | static int qla4xxx_get_chap_by_index(struct scsi_qla_host *ha, | 635 | static int qla4xxx_get_chap_by_index(struct scsi_qla_host *ha, |
577 | int16_t chap_index, | 636 | int16_t chap_index, |
578 | struct ql4_chap_table **chap_entry) | 637 | struct ql4_chap_table **chap_entry) |
@@ -686,6 +745,8 @@ static int qla4xxx_get_chap_list(struct Scsi_Host *shost, uint16_t chap_tbl_idx, | |||
686 | goto exit_get_chap_list; | 745 | goto exit_get_chap_list; |
687 | } | 746 | } |
688 | 747 | ||
748 | qla4xxx_create_chap_list(ha); | ||
749 | |||
689 | chap_rec = (struct iscsi_chap_rec *) buf; | 750 | chap_rec = (struct iscsi_chap_rec *) buf; |
690 | mutex_lock(&ha->chap_sem); | 751 | mutex_lock(&ha->chap_sem); |
691 | for (i = chap_tbl_idx; i < max_chap_entries; i++) { | 752 | for (i = chap_tbl_idx; i < max_chap_entries; i++) { |
@@ -6124,64 +6185,6 @@ kset_free: | |||
6124 | } | 6185 | } |
6125 | 6186 | ||
6126 | 6187 | ||
6127 | /** | ||
6128 | * qla4xxx_create chap_list - Create CHAP list from FLASH | ||
6129 | * @ha: pointer to adapter structure | ||
6130 | * | ||
6131 | * Read flash and make a list of CHAP entries, during login when a CHAP entry | ||
6132 | * is received, it will be checked in this list. If entry exist then the CHAP | ||
6133 | * entry index is set in the DDB. If CHAP entry does not exist in this list | ||
6134 | * then a new entry is added in FLASH in CHAP table and the index obtained is | ||
6135 | * used in the DDB. | ||
6136 | **/ | ||
6137 | static void qla4xxx_create_chap_list(struct scsi_qla_host *ha) | ||
6138 | { | ||
6139 | int rval = 0; | ||
6140 | uint8_t *chap_flash_data = NULL; | ||
6141 | uint32_t offset; | ||
6142 | dma_addr_t chap_dma; | ||
6143 | uint32_t chap_size = 0; | ||
6144 | |||
6145 | if (is_qla40XX(ha)) | ||
6146 | chap_size = MAX_CHAP_ENTRIES_40XX * | ||
6147 | sizeof(struct ql4_chap_table); | ||
6148 | else /* Single region contains CHAP info for both | ||
6149 | * ports which is divided into half for each port. | ||
6150 | */ | ||
6151 | chap_size = ha->hw.flt_chap_size / 2; | ||
6152 | |||
6153 | chap_flash_data = dma_alloc_coherent(&ha->pdev->dev, chap_size, | ||
6154 | &chap_dma, GFP_KERNEL); | ||
6155 | if (!chap_flash_data) { | ||
6156 | ql4_printk(KERN_ERR, ha, "No memory for chap_flash_data\n"); | ||
6157 | return; | ||
6158 | } | ||
6159 | if (is_qla40XX(ha)) | ||
6160 | offset = FLASH_CHAP_OFFSET; | ||
6161 | else { | ||
6162 | offset = FLASH_RAW_ACCESS_ADDR + (ha->hw.flt_region_chap << 2); | ||
6163 | if (ha->port_num == 1) | ||
6164 | offset += chap_size; | ||
6165 | } | ||
6166 | |||
6167 | rval = qla4xxx_get_flash(ha, chap_dma, offset, chap_size); | ||
6168 | if (rval != QLA_SUCCESS) | ||
6169 | goto exit_chap_list; | ||
6170 | |||
6171 | if (ha->chap_list == NULL) | ||
6172 | ha->chap_list = vmalloc(chap_size); | ||
6173 | if (ha->chap_list == NULL) { | ||
6174 | ql4_printk(KERN_ERR, ha, "No memory for ha->chap_list\n"); | ||
6175 | goto exit_chap_list; | ||
6176 | } | ||
6177 | |||
6178 | memcpy(ha->chap_list, chap_flash_data, chap_size); | ||
6179 | |||
6180 | exit_chap_list: | ||
6181 | dma_free_coherent(&ha->pdev->dev, chap_size, | ||
6182 | chap_flash_data, chap_dma); | ||
6183 | } | ||
6184 | |||
6185 | static void qla4xxx_get_param_ddb(struct ddb_entry *ddb_entry, | 6188 | static void qla4xxx_get_param_ddb(struct ddb_entry *ddb_entry, |
6186 | struct ql4_tuple_ddb *tddb) | 6189 | struct ql4_tuple_ddb *tddb) |
6187 | { | 6190 | { |