aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/qla2xxx/qla_mid.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/qla2xxx/qla_mid.c')
-rw-r--r--drivers/scsi/qla2xxx/qla_mid.c46
1 files changed, 20 insertions, 26 deletions
diff --git a/drivers/scsi/qla2xxx/qla_mid.c b/drivers/scsi/qla2xxx/qla_mid.c
index 821ee74aadc6..cf784cdafb01 100644
--- a/drivers/scsi/qla2xxx/qla_mid.c
+++ b/drivers/scsi/qla2xxx/qla_mid.c
@@ -39,7 +39,7 @@ qla2x00_vp_stop_timer(scsi_qla_host_t *vha)
39 } 39 }
40} 40}
41 41
42uint32_t 42static uint32_t
43qla24xx_allocate_vp_id(scsi_qla_host_t *vha) 43qla24xx_allocate_vp_id(scsi_qla_host_t *vha)
44{ 44{
45 uint32_t vp_id; 45 uint32_t vp_id;
@@ -47,16 +47,15 @@ qla24xx_allocate_vp_id(scsi_qla_host_t *vha)
47 47
48 /* Find an empty slot and assign an vp_id */ 48 /* Find an empty slot and assign an vp_id */
49 down(&ha->vport_sem); 49 down(&ha->vport_sem);
50 vp_id = find_first_zero_bit((unsigned long *)ha->vp_idx_map, 50 vp_id = find_first_zero_bit(ha->vp_idx_map, ha->max_npiv_vports + 1);
51 MAX_MULTI_ID_FABRIC); 51 if (vp_id > ha->max_npiv_vports) {
52 if (vp_id > MAX_MULTI_ID_FABRIC) { 52 DEBUG15(printk ("vp_id %d is bigger than max-supported %d.\n",
53 DEBUG15(printk ("vp_id %d is bigger than MAX_MULTI_ID_FABRID\n", 53 vp_id, ha->max_npiv_vports));
54 vp_id));
55 up(&ha->vport_sem); 54 up(&ha->vport_sem);
56 return vp_id; 55 return vp_id;
57 } 56 }
58 57
59 set_bit(vp_id, (unsigned long *)ha->vp_idx_map); 58 set_bit(vp_id, ha->vp_idx_map);
60 ha->num_vhosts++; 59 ha->num_vhosts++;
61 vha->vp_idx = vp_id; 60 vha->vp_idx = vp_id;
62 list_add_tail(&vha->vp_list, &ha->vp_list); 61 list_add_tail(&vha->vp_list, &ha->vp_list);
@@ -73,12 +72,12 @@ qla24xx_deallocate_vp_id(scsi_qla_host_t *vha)
73 down(&ha->vport_sem); 72 down(&ha->vport_sem);
74 vp_id = vha->vp_idx; 73 vp_id = vha->vp_idx;
75 ha->num_vhosts--; 74 ha->num_vhosts--;
76 clear_bit(vp_id, (unsigned long *)ha->vp_idx_map); 75 clear_bit(vp_id, ha->vp_idx_map);
77 list_del(&vha->vp_list); 76 list_del(&vha->vp_list);
78 up(&ha->vport_sem); 77 up(&ha->vport_sem);
79} 78}
80 79
81scsi_qla_host_t * 80static scsi_qla_host_t *
82qla24xx_find_vhost_by_name(scsi_qla_host_t *ha, uint8_t *port_name) 81qla24xx_find_vhost_by_name(scsi_qla_host_t *ha, uint8_t *port_name)
83{ 82{
84 scsi_qla_host_t *vha; 83 scsi_qla_host_t *vha;
@@ -216,11 +215,7 @@ qla2x00_alert_all_vps(scsi_qla_host_t *ha, uint16_t *mb)
216 if (ha->parent) 215 if (ha->parent)
217 return; 216 return;
218 217
219 i = find_next_bit((unsigned long *)ha->vp_idx_map, 218 for_each_mapped_vp_idx(ha, i) {
220 MAX_MULTI_ID_FABRIC + 1, 1);
221 for (;i <= MAX_MULTI_ID_FABRIC;
222 i = find_next_bit((unsigned long *)ha->vp_idx_map,
223 MAX_MULTI_ID_FABRIC + 1, i + 1)) {
224 vp_idx_matched = 0; 219 vp_idx_matched = 0;
225 220
226 list_for_each_entry(vha, &ha->vp_list, vp_list) { 221 list_for_each_entry(vha, &ha->vp_list, vp_list) {
@@ -270,7 +265,7 @@ qla2x00_vp_abort_isp(scsi_qla_host_t *vha)
270 qla24xx_enable_vp(vha); 265 qla24xx_enable_vp(vha);
271} 266}
272 267
273int 268static int
274qla2x00_do_dpc_vp(scsi_qla_host_t *vha) 269qla2x00_do_dpc_vp(scsi_qla_host_t *vha)
275{ 270{
276 if (test_and_clear_bit(VP_IDX_ACQUIRED, &vha->vp_flags)) { 271 if (test_and_clear_bit(VP_IDX_ACQUIRED, &vha->vp_flags)) {
@@ -311,11 +306,7 @@ qla2x00_do_dpc_all_vps(scsi_qla_host_t *ha)
311 306
312 clear_bit(VP_DPC_NEEDED, &ha->dpc_flags); 307 clear_bit(VP_DPC_NEEDED, &ha->dpc_flags);
313 308
314 i = find_next_bit((unsigned long *)ha->vp_idx_map, 309 for_each_mapped_vp_idx(ha, i) {
315 MAX_MULTI_ID_FABRIC + 1, 1);
316 for (;i <= MAX_MULTI_ID_FABRIC;
317 i = find_next_bit((unsigned long *)ha->vp_idx_map,
318 MAX_MULTI_ID_FABRIC + 1, i + 1)) {
319 vp_idx_matched = 0; 310 vp_idx_matched = 0;
320 311
321 list_for_each_entry(vha, &ha->vp_list, vp_list) { 312 list_for_each_entry(vha, &ha->vp_list, vp_list) {
@@ -350,15 +341,17 @@ qla24xx_vport_create_req_sanity_check(struct fc_vport *fc_vport)
350 341
351 /* Check up unique WWPN */ 342 /* Check up unique WWPN */
352 u64_to_wwn(fc_vport->port_name, port_name); 343 u64_to_wwn(fc_vport->port_name, port_name);
344 if (!memcmp(port_name, ha->port_name, WWN_SIZE))
345 return VPCERR_BAD_WWN;
353 vha = qla24xx_find_vhost_by_name(ha, port_name); 346 vha = qla24xx_find_vhost_by_name(ha, port_name);
354 if (vha) 347 if (vha)
355 return VPCERR_BAD_WWN; 348 return VPCERR_BAD_WWN;
356 349
357 /* Check up max-npiv-supports */ 350 /* Check up max-npiv-supports */
358 if (ha->num_vhosts > ha->max_npiv_vports) { 351 if (ha->num_vhosts > ha->max_npiv_vports) {
359 DEBUG15(printk("scsi(%ld): num_vhosts %d is bigger than " 352 DEBUG15(printk("scsi(%ld): num_vhosts %ud is bigger than "
360 "max_npv_vports %d.\n", ha->host_no, 353 "max_npv_vports %ud.\n", ha->host_no,
361 (uint16_t) ha->num_vhosts, (int) ha->max_npiv_vports)); 354 ha->num_vhosts, ha->max_npiv_vports));
362 return VPCERR_UNSUPPORTED; 355 return VPCERR_UNSUPPORTED;
363 } 356 }
364 return 0; 357 return 0;
@@ -412,8 +405,9 @@ qla24xx_create_vhost(struct fc_vport *fc_vport)
412 } 405 }
413 vha->mgmt_svr_loop_id = 10 + vha->vp_idx; 406 vha->mgmt_svr_loop_id = 10 + vha->vp_idx;
414 407
415 init_MUTEX(&vha->mbx_cmd_sem); 408 init_completion(&vha->mbx_cmd_comp);
416 init_MUTEX_LOCKED(&vha->mbx_intr_sem); 409 complete(&vha->mbx_cmd_comp);
410 init_completion(&vha->mbx_intr_comp);
417 411
418 INIT_LIST_HEAD(&vha->list); 412 INIT_LIST_HEAD(&vha->list);
419 INIT_LIST_HEAD(&vha->fcports); 413 INIT_LIST_HEAD(&vha->fcports);
@@ -450,7 +444,7 @@ qla24xx_create_vhost(struct fc_vport *fc_vport)
450 num_hosts++; 444 num_hosts++;
451 445
452 down(&ha->vport_sem); 446 down(&ha->vport_sem);
453 set_bit(vha->vp_idx, (unsigned long *)ha->vp_idx_map); 447 set_bit(vha->vp_idx, ha->vp_idx_map);
454 ha->cur_vport_count++; 448 ha->cur_vport_count++;
455 up(&ha->vport_sem); 449 up(&ha->vport_sem);
456 450