diff options
author | Quinn Tran <quinn.tran@cavium.com> | 2018-08-02 16:16:53 -0400 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2018-08-02 16:56:18 -0400 |
commit | f6602f3befbb9979cdb031e32211358dd008d05e (patch) | |
tree | 898bc878331b99585bae52af95890d92ee2a7aea | |
parent | b2000805a9759d315f56eecaca7779aa9197a72f (diff) |
scsi: qla2xxx: Fix Management Server NPort handle reservation logic
After selecting the NPort handle/loop_id, set a bit in the loop_id_map to
prevent others from selecting the same NPort handle.
Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r-- | drivers/scsi/qla2xxx/qla_gbl.h | 1 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_init.c | 28 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_mid.c | 2 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_os.c | 3 |
4 files changed, 32 insertions, 2 deletions
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h index f68eb6096559..00fbd49a9a7a 100644 --- a/drivers/scsi/qla2xxx/qla_gbl.h +++ b/drivers/scsi/qla2xxx/qla_gbl.h | |||
@@ -118,6 +118,7 @@ extern int qla2x00_post_async_prlo_done_work(struct scsi_qla_host *, | |||
118 | fc_port_t *, uint16_t *); | 118 | fc_port_t *, uint16_t *); |
119 | int qla_post_iidma_work(struct scsi_qla_host *vha, fc_port_t *fcport); | 119 | int qla_post_iidma_work(struct scsi_qla_host *vha, fc_port_t *fcport); |
120 | void qla_do_iidma_work(struct scsi_qla_host *vha, fc_port_t *fcport); | 120 | void qla_do_iidma_work(struct scsi_qla_host *vha, fc_port_t *fcport); |
121 | int qla2x00_reserve_mgmt_server_loop_id(scsi_qla_host_t *); | ||
121 | /* | 122 | /* |
122 | * Global Data in qla_os.c source file. | 123 | * Global Data in qla_os.c source file. |
123 | */ | 124 | */ |
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index a10a8bb895e9..9d1a8b2c41a9 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c | |||
@@ -5616,6 +5616,34 @@ qla2x00_find_new_loop_id(scsi_qla_host_t *vha, fc_port_t *dev) | |||
5616 | } | 5616 | } |
5617 | 5617 | ||
5618 | 5618 | ||
5619 | /* FW does not set aside Loop id for MGMT Server/FFFFFAh */ | ||
5620 | int | ||
5621 | qla2x00_reserve_mgmt_server_loop_id(scsi_qla_host_t *vha) | ||
5622 | { | ||
5623 | int loop_id = FC_NO_LOOP_ID; | ||
5624 | int lid = NPH_MGMT_SERVER - vha->vp_idx; | ||
5625 | unsigned long flags; | ||
5626 | struct qla_hw_data *ha = vha->hw; | ||
5627 | |||
5628 | if (vha->vp_idx == 0) { | ||
5629 | set_bit(NPH_MGMT_SERVER, ha->loop_id_map); | ||
5630 | return NPH_MGMT_SERVER; | ||
5631 | } | ||
5632 | |||
5633 | /* pick id from high and work down to low */ | ||
5634 | spin_lock_irqsave(&ha->vport_slock, flags); | ||
5635 | for (; lid > 0; lid--) { | ||
5636 | if (!test_bit(lid, vha->hw->loop_id_map)) { | ||
5637 | set_bit(lid, vha->hw->loop_id_map); | ||
5638 | loop_id = lid; | ||
5639 | break; | ||
5640 | } | ||
5641 | } | ||
5642 | spin_unlock_irqrestore(&ha->vport_slock, flags); | ||
5643 | |||
5644 | return loop_id; | ||
5645 | } | ||
5646 | |||
5619 | /* | 5647 | /* |
5620 | * qla2x00_fabric_login | 5648 | * qla2x00_fabric_login |
5621 | * Issue fabric login command. | 5649 | * Issue fabric login command. |
diff --git a/drivers/scsi/qla2xxx/qla_mid.c b/drivers/scsi/qla2xxx/qla_mid.c index f6f0a759a7c2..14bc88bc4a5a 100644 --- a/drivers/scsi/qla2xxx/qla_mid.c +++ b/drivers/scsi/qla2xxx/qla_mid.c | |||
@@ -485,7 +485,7 @@ qla24xx_create_vhost(struct fc_vport *fc_vport) | |||
485 | "Couldn't allocate vp_id.\n"); | 485 | "Couldn't allocate vp_id.\n"); |
486 | goto create_vhost_failed; | 486 | goto create_vhost_failed; |
487 | } | 487 | } |
488 | vha->mgmt_svr_loop_id = NPH_MGMT_SERVER; | 488 | vha->mgmt_svr_loop_id = qla2x00_reserve_mgmt_server_loop_id(vha); |
489 | 489 | ||
490 | vha->dpc_flags = 0L; | 490 | vha->dpc_flags = 0L; |
491 | 491 | ||
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 04e0c7f51e68..48d1003c8178 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c | |||
@@ -3048,7 +3048,8 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
3048 | host = base_vha->host; | 3048 | host = base_vha->host; |
3049 | base_vha->req = req; | 3049 | base_vha->req = req; |
3050 | if (IS_QLA2XXX_MIDTYPE(ha)) | 3050 | if (IS_QLA2XXX_MIDTYPE(ha)) |
3051 | base_vha->mgmt_svr_loop_id = NPH_MGMT_SERVER; | 3051 | base_vha->mgmt_svr_loop_id = |
3052 | qla2x00_reserve_mgmt_server_loop_id(base_vha); | ||
3052 | else | 3053 | else |
3053 | base_vha->mgmt_svr_loop_id = MANAGEMENT_SERVER + | 3054 | base_vha->mgmt_svr_loop_id = MANAGEMENT_SERVER + |
3054 | base_vha->vp_idx; | 3055 | base_vha->vp_idx; |