down(&ha->vport_sem);
ha->cur_vport_count--;
- clear_bit(vha->vp_idx, (unsigned long *)ha->vp_idx_map);
+ clear_bit(vha->vp_idx, ha->vp_idx_map);
up(&ha->vport_sem);
kfree(vha->node_name);
#define WATCH_INTERVAL 1 /* number of seconds */
-/* NPIV */
-#define MAX_MULTI_ID_LOOP 126
-#define MAX_MULTI_ID_FABRIC 64
-#define MAX_NUM_VPORT_LOOP (MAX_MULTI_ID_LOOP - 1)
-#define MAX_NUM_VPORT_FABRIC (MAX_MULTI_ID_FABRIC - 1)
-#define MAX_NUM_VHBA_LOOP (MAX_MULTI_ID_LOOP - 1)
-#define MAX_NUM_VHBA_FABRIC (MAX_MULTI_ID_FABRIC - 1)
-
/*
* Linux Host Adapter structure
*/
struct list_head vp_list; /* list of VP */
struct fc_vport *fc_vport; /* holds fc_vport * for each vport */
- uint8_t vp_idx_map[16];
+ unsigned long vp_idx_map[(MAX_MULTI_ID_FABRIC / 8) / sizeof(unsigned long)];
uint16_t num_vhosts; /* number of vports created */
uint16_t num_vsans; /* number of vsan created */
uint16_t vp_idx; /* vport ID */
/* MID Support ***************************************************************/
-#define MAX_MID_VPS 125
+#define MIN_MULTI_ID_FABRIC 64 /* Must be power-of-2. */
+#define MAX_MULTI_ID_FABRIC 256 /* ... */
+
+#define for_each_mapped_vp_idx(_ha, _idx) \
+ for (_idx = find_next_bit((_ha)->vp_idx_map, \
+ (_ha)->max_npiv_vports + 1, 1); \
+ _idx <= (_ha)->max_npiv_vports; \
+ _idx = find_next_bit((_ha)->vp_idx_map, \
+ (_ha)->max_npiv_vports + 1, _idx + 1)) \
struct mid_conf_entry_24xx {
uint16_t reserved_1;
uint16_t count;
uint16_t options;
- struct mid_conf_entry_24xx entries[MAX_MID_VPS];
+ struct mid_conf_entry_24xx entries[MAX_MULTI_ID_FABRIC];
};
uint8_t reserved_1;
};
-struct mid_db_24xx {
- struct mid_db_entry_24xx entries[MAX_MID_VPS];
-};
-
/*
* Virtual Fabric ID type definition.
*/
ha->flags.npiv_supported = 1;
if ((!ha->max_npiv_vports) ||
((ha->max_npiv_vports + 1) %
- MAX_MULTI_ID_FABRIC))
+ MIN_MULTI_ID_FABRIC))
ha->max_npiv_vports =
- MAX_NUM_VPORT_FABRIC;
+ MIN_MULTI_ID_FABRIC - 1;
}
if (ql2xallocfwdump)
DEBUG(printk("scsi(%ld): Issue init firmware.\n", ha->host_no));
- mid_init_cb->count = ha->max_npiv_vports;
+ mid_init_cb->count = cpu_to_le16(ha->max_npiv_vports);
+ mid_init_cb->options = __constant_cpu_to_le16(BIT_1);
rval = qla2x00_init_firmware(ha, ha->init_cb_size);
if (rval) {
/* Bypass virtual ports of the same host. */
if (pha->num_vhosts) {
- vp_index = find_next_bit(
- (unsigned long *)pha->vp_idx_map,
- MAX_MULTI_ID_FABRIC + 1, 1);
-
- for (;vp_index <= MAX_MULTI_ID_FABRIC;
- vp_index = find_next_bit(
- (unsigned long *)pha->vp_idx_map,
- MAX_MULTI_ID_FABRIC + 1, vp_index + 1)) {
+ for_each_mapped_vp_idx(pha, vp_index) {
empty_vp_index = 1;
found_vp = 0;
list_for_each_entry(vha, &pha->vp_list,
new_fcport->d_id.b24 == vha->d_id.b24)
break;
}
- if (vp_index <= MAX_MULTI_ID_FABRIC)
+
+ if (vp_index <= pha->max_npiv_vports)
continue;
}
mcp->mb[0] = MBC_GET_ADAPTER_LOOP_ID;
mcp->mb[9] = ha->vp_idx;
- mcp->out_mb = MBX_0;
+ mcp->out_mb = MBX_9|MBX_0;
mcp->in_mb = MBX_9|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
mcp->tov = 30;
mcp->flags = 0;
DEBUG11(printk("%s(%ld): entered. Enabling index %d\n", __func__,
ha->host_no, vp_index));
- if (vp_index == 0 || vp_index >= MAX_MULTI_ID_LOOP)
+ if (vp_index == 0 || vp_index >= ha->max_npiv_vports)
return QLA_PARAMETER_ERROR;
vce = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &vce_dma);
/* Find an empty slot and assign an vp_id */
down(&ha->vport_sem);
- vp_id = find_first_zero_bit((unsigned long *)ha->vp_idx_map,
- MAX_MULTI_ID_FABRIC);
- if (vp_id > MAX_MULTI_ID_FABRIC) {
- DEBUG15(printk ("vp_id %d is bigger than MAX_MULTI_ID_FABRID\n",
- vp_id));
+ vp_id = find_first_zero_bit(ha->vp_idx_map, ha->max_npiv_vports + 1);
+ if (vp_id > ha->max_npiv_vports) {
+ DEBUG15(printk ("vp_id %d is bigger than max-supported %d.\n",
+ vp_id, ha->max_npiv_vports));
up(&ha->vport_sem);
return vp_id;
}
- set_bit(vp_id, (unsigned long *)ha->vp_idx_map);
+ set_bit(vp_id, ha->vp_idx_map);
ha->num_vhosts++;
vha->vp_idx = vp_id;
list_add_tail(&vha->vp_list, &ha->vp_list);
down(&ha->vport_sem);
vp_id = vha->vp_idx;
ha->num_vhosts--;
- clear_bit(vp_id, (unsigned long *)ha->vp_idx_map);
+ clear_bit(vp_id, ha->vp_idx_map);
list_del(&vha->vp_list);
up(&ha->vport_sem);
}
if (ha->parent)
return;
- i = find_next_bit((unsigned long *)ha->vp_idx_map,
- MAX_MULTI_ID_FABRIC + 1, 1);
- for (;i <= MAX_MULTI_ID_FABRIC;
- i = find_next_bit((unsigned long *)ha->vp_idx_map,
- MAX_MULTI_ID_FABRIC + 1, i + 1)) {
+ for_each_mapped_vp_idx(ha, i) {
vp_idx_matched = 0;
list_for_each_entry(vha, &ha->vp_list, vp_list) {
clear_bit(VP_DPC_NEEDED, &ha->dpc_flags);
- i = find_next_bit((unsigned long *)ha->vp_idx_map,
- MAX_MULTI_ID_FABRIC + 1, 1);
- for (;i <= MAX_MULTI_ID_FABRIC;
- i = find_next_bit((unsigned long *)ha->vp_idx_map,
- MAX_MULTI_ID_FABRIC + 1, i + 1)) {
+ for_each_mapped_vp_idx(ha, i) {
vp_idx_matched = 0;
list_for_each_entry(vha, &ha->vp_list, vp_list) {
/* Check up max-npiv-supports */
if (ha->num_vhosts > ha->max_npiv_vports) {
- DEBUG15(printk("scsi(%ld): num_vhosts %d is bigger than "
- "max_npv_vports %d.\n", ha->host_no,
- (uint16_t) ha->num_vhosts, (int) ha->max_npiv_vports));
+ DEBUG15(printk("scsi(%ld): num_vhosts %ud is bigger than "
+ "max_npv_vports %ud.\n", ha->host_no,
+ ha->num_vhosts, ha->max_npiv_vports));
return VPCERR_UNSUPPORTED;
}
return 0;
num_hosts++;
down(&ha->vport_sem);
- set_bit(vha->vp_idx, (unsigned long *)ha->vp_idx_map);
+ set_bit(vha->vp_idx, ha->vp_idx_map);
ha->cur_vport_count++;
up(&ha->vport_sem);