Release 4.7 drivers/scsi/qla2xxx/qla_mid.c
  
  
/*
 * QLogic Fibre Channel HBA Driver
 * Copyright (c)  2003-2014 QLogic Corporation
 *
 * See LICENSE.qla2xxx for copyright and licensing details.
 */
#include "qla_def.h"
#include "qla_gbl.h"
#include "qla_target.h"
#include <linux/moduleparam.h>
#include <linux/vmalloc.h>
#include <linux/slab.h>
#include <linux/list.h>
#include <scsi/scsi_tcq.h>
#include <scsi/scsicam.h>
#include <linux/delay.h>
void
qla2x00_vp_stop_timer(scsi_qla_host_t *vha)
{
	if (vha->vp_idx && vha->timer_active) {
		del_timer_sync(&vha->timer);
		vha->timer_active = 0;
	}
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| seokmann ju | seokmann ju | 34 | 97.14% | 1 | 50.00% | 
| anirban chakraborty | anirban chakraborty | 1 | 2.86% | 1 | 50.00% | 
 | Total | 35 | 100.00% | 2 | 100.00% | 
static uint32_t
qla24xx_allocate_vp_id(scsi_qla_host_t *vha)
{
	uint32_t vp_id;
	struct qla_hw_data *ha = vha->hw;
	unsigned long flags;
	/* Find an empty slot and assign an vp_id */
	mutex_lock(&ha->vport_lock);
	vp_id = find_first_zero_bit(ha->vp_idx_map, ha->max_npiv_vports + 1);
	if (vp_id > ha->max_npiv_vports) {
		ql_dbg(ql_dbg_vport, vha, 0xa000,
		    "vp_id %d is bigger than max-supported %d.\n",
		    vp_id, ha->max_npiv_vports);
		mutex_unlock(&ha->vport_lock);
		return vp_id;
	}
	set_bit(vp_id, ha->vp_idx_map);
	ha->num_vhosts++;
	vha->vp_idx = vp_id;
	spin_lock_irqsave(&ha->vport_slock, flags);
	list_add_tail(&vha->list, &ha->vp_list);
	qlt_update_vp_map(vha, SET_VP_IDX);
	spin_unlock_irqrestore(&ha->vport_slock, flags);
	mutex_unlock(&ha->vport_lock);
	return vp_id;
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| seokmann ju | seokmann ju | 97 | 61.01% | 1 | 12.50% | 
| arun easi | arun easi | 24 | 15.09% | 1 | 12.50% | 
| andrew vasquez | andrew vasquez | 13 | 8.18% | 1 | 12.50% | 
| nicholas bellinger | nicholas bellinger | 7 | 4.40% | 1 | 12.50% | 
| saurav kashyap | saurav kashyap | 7 | 4.40% | 1 | 12.50% | 
| matthias kaehlcke | matthias kaehlcke | 6 | 3.77% | 1 | 12.50% | 
| anirban chakraborty | anirban chakraborty | 4 | 2.52% | 1 | 12.50% | 
| adrian bunk | adrian bunk | 1 | 0.63% | 1 | 12.50% | 
 | Total | 159 | 100.00% | 8 | 100.00% | 
void
qla24xx_deallocate_vp_id(scsi_qla_host_t *vha)
{
	uint16_t vp_id;
	struct qla_hw_data *ha = vha->hw;
	unsigned long flags = 0;
	mutex_lock(&ha->vport_lock);
	/*
         * Wait for all pending activities to finish before removing vport from
         * the list.
         * Lock needs to be held for safe removal from the list (it
         * ensures no active vp_list traversal while the vport is removed
         * from the queue)
         */
	spin_lock_irqsave(&ha->vport_slock, flags);
	while (atomic_read(&vha->vref_count)) {
		spin_unlock_irqrestore(&ha->vport_slock, flags);
		msleep(500);
		spin_lock_irqsave(&ha->vport_slock, flags);
	}
	list_del(&vha->list);
	qlt_update_vp_map(vha, RESET_VP_IDX);
	spin_unlock_irqrestore(&ha->vport_slock, flags);
	vp_id = vha->vp_idx;
	ha->num_vhosts--;
	clear_bit(vp_id, ha->vp_idx_map);
	mutex_unlock(&ha->vport_lock);
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| arun easi | arun easi | 72 | 52.94% | 1 | 20.00% | 
| seokmann ju | seokmann ju | 50 | 36.76% | 1 | 20.00% | 
| nicholas bellinger | nicholas bellinger | 7 | 5.15% | 1 | 20.00% | 
| matthias kaehlcke | matthias kaehlcke | 4 | 2.94% | 1 | 20.00% | 
| anirban chakraborty | anirban chakraborty | 3 | 2.21% | 1 | 20.00% | 
 | Total | 136 | 100.00% | 5 | 100.00% | 
static scsi_qla_host_t *
qla24xx_find_vhost_by_name(struct qla_hw_data *ha, uint8_t *port_name)
{
	scsi_qla_host_t *vha;
	struct scsi_qla_host *tvha;
	unsigned long flags;
	spin_lock_irqsave(&ha->vport_slock, flags);
	/* Locate matching device in database. */
	list_for_each_entry_safe(vha, tvha, &ha->vp_list, list) {
		if (!memcmp(port_name, vha->port_name, WWN_SIZE)) {
			spin_unlock_irqrestore(&ha->vport_slock, flags);
			return vha;
		}
	}
	spin_unlock_irqrestore(&ha->vport_slock, flags);
	return NULL;
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| seokmann ju | seokmann ju | 46 | 48.94% | 1 | 20.00% | 
| arun easi | arun easi | 36 | 38.30% | 1 | 20.00% | 
| anirban chakraborty | anirban chakraborty | 11 | 11.70% | 2 | 40.00% | 
| adrian bunk | adrian bunk | 1 | 1.06% | 1 | 20.00% | 
 | Total | 94 | 100.00% | 5 | 100.00% | 
/*
 * qla2x00_mark_vp_devices_dead
 *      Updates fcport state when device goes offline.
 *
 * Input:
 *      ha = adapter block pointer.
 *      fcport = port structure pointer.
 *
 * Return:
 *      None.
 *
 * Context:
 */
static void
qla2x00_mark_vp_devices_dead(scsi_qla_host_t *vha)
{
	/*
         * !!! NOTE !!!
         * This function, if called in contexts other than vp create, disable
         * or delete, please make sure this is synchronized with the
         * delete thread.
         */
	fc_port_t *fcport;
	list_for_each_entry(fcport, &vha->vp_fcports, list) {
		ql_dbg(ql_dbg_vport, vha, 0xa001,
		    "Marking port dead, loop_id=0x%04x : %x.\n",
		    fcport->loop_id, fcport->vha->vp_idx);
		qla2x00_mark_device_lost(vha, fcport, 0, 0);
		qla2x00_set_fcport_state(fcport, FCS_UNCONFIGURED);
	}
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| seokmann ju | seokmann ju | 46 | 71.88% | 1 | 12.50% | 
| andrew vasquez | andrew vasquez | 7 | 10.94% | 2 | 25.00% | 
| saurav kashyap | saurav kashyap | 6 | 9.38% | 1 | 12.50% | 
| joe carnuccio | joe carnuccio | 2 | 3.12% | 1 | 12.50% | 
| arun easi | arun easi | 1 | 1.56% | 1 | 12.50% | 
| anirban chakraborty | anirban chakraborty | 1 | 1.56% | 1 | 12.50% | 
| chad dupuis | chad dupuis | 1 | 1.56% | 1 | 12.50% | 
 | Total | 64 | 100.00% | 8 | 100.00% | 
int
qla24xx_disable_vp(scsi_qla_host_t *vha)
{
	unsigned long flags;
	int ret;
	ret = qla24xx_control_vp(vha, VCE_COMMAND_DISABLE_VPS_LOGO_ALL);
	atomic_set(&vha->loop_state, LOOP_DOWN);
	atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME);
	/* Remove port id from vp target map */
	spin_lock_irqsave(&vha->hw->vport_slock, flags);
	qlt_update_vp_map(vha, RESET_AL_PA);
	spin_unlock_irqrestore(&vha->hw->vport_slock, flags);
	qla2x00_mark_vp_devices_dead(vha);
	atomic_set(&vha->vp_state, VP_FAILED);
	vha->flags.management_server_logged_in = 0;
	if (ret == QLA_SUCCESS) {
		fc_vport_set_state(vha->fc_vport, FC_VPORT_DISABLED);
	} else {
		fc_vport_set_state(vha->fc_vport, FC_VPORT_FAILED);
		return -1;
	}
	return 0;
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| seokmann ju | seokmann ju | 100 | 73.53% | 1 | 33.33% | 
| nicholas bellinger | nicholas bellinger | 36 | 26.47% | 2 | 66.67% | 
 | Total | 136 | 100.00% | 3 | 100.00% | 
int
qla24xx_enable_vp(scsi_qla_host_t *vha)
{
	int ret;
	struct qla_hw_data *ha = vha->hw;
	scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev);
	/* Check if physical ha port is Up */
	if (atomic_read(&base_vha->loop_state) == LOOP_DOWN  ||
		atomic_read(&base_vha->loop_state) == LOOP_DEAD ||
		!(ha->current_topology & ISP_CFG_F)) {
		vha->vp_err_state =  VP_ERR_PORTDWN;
		fc_vport_set_state(vha->fc_vport, FC_VPORT_LINKDOWN);
		goto enable_failed;
	}
	/* Initialize the new vport unless it is a persistent port */
	mutex_lock(&ha->vport_lock);
	ret = qla24xx_modify_vp_config(vha);
	mutex_unlock(&ha->vport_lock);
	if (ret != QLA_SUCCESS) {
		fc_vport_set_state(vha->fc_vport, FC_VPORT_FAILED);
		goto enable_failed;
	}
	ql_dbg(ql_dbg_taskm, vha, 0x801a,
	    "Virtual port with id: %d - Enabled.\n", vha->vp_idx);
	return 0;
enable_failed:
	ql_dbg(ql_dbg_taskm, vha, 0x801b,
	    "Virtual port with id: %d - Disabled.\n", vha->vp_idx);
	return 1;
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| seokmann ju | seokmann ju | 125 | 75.30% | 1 | 20.00% | 
| anirban chakraborty | anirban chakraborty | 16 | 9.64% | 1 | 20.00% | 
| saurav kashyap | saurav kashyap | 12 | 7.23% | 1 | 20.00% | 
| lalit chandivade | lalit chandivade | 9 | 5.42% | 1 | 20.00% | 
| matthias kaehlcke | matthias kaehlcke | 4 | 2.41% | 1 | 20.00% | 
 | Total | 166 | 100.00% | 5 | 100.00% | 
static void
qla24xx_configure_vp(scsi_qla_host_t *vha)
{
	struct fc_vport *fc_vport;
	int ret;
	fc_vport = vha->fc_vport;
	ql_dbg(ql_dbg_vport, vha, 0xa002,
	    "%s: change request #3.\n", __func__);
	ret = qla2x00_send_change_request(vha, 0x3, vha->vp_idx);
	if (ret != QLA_SUCCESS) {
		ql_dbg(ql_dbg_vport, vha, 0xa003, "Failed to enable "
		    "receiving of RSCN requests: 0x%x.\n", ret);
		return;
	} else {
		/* Corresponds to SCR enabled */
		clear_bit(VP_SCR_NEEDED, &vha->vp_flags);
	}
	vha->flags.online = 1;
	if (qla24xx_configure_vhba(vha))
		return;
	atomic_set(&vha->vp_state, VP_ACTIVE);
	fc_vport_set_state(fc_vport, FC_VPORT_ACTIVE);
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| seokmann ju | seokmann ju | 107 | 89.17% | 1 | 25.00% | 
| saurav kashyap | saurav kashyap | 11 | 9.17% | 1 | 25.00% | 
| anirban chakraborty | anirban chakraborty | 1 | 0.83% | 1 | 25.00% | 
| andrew vasquez | andrew vasquez | 1 | 0.83% | 1 | 25.00% | 
 | Total | 120 | 100.00% | 4 | 100.00% | 
void
qla2x00_alert_all_vps(struct rsp_que *rsp, uint16_t *mb)
{
	scsi_qla_host_t *vha;
	struct qla_hw_data *ha = rsp->hw;
	int i = 0;
	unsigned long flags;
	spin_lock_irqsave(&ha->vport_slock, flags);
	list_for_each_entry(vha, &ha->vp_list, list) {
		if (vha->vp_idx) {
			atomic_inc(&vha->vref_count);
			spin_unlock_irqrestore(&ha->vport_slock, flags);
			switch (mb[0]) {
			case MBA_LIP_OCCURRED:
			case MBA_LOOP_UP:
			case MBA_LOOP_DOWN:
			case MBA_LIP_RESET:
			case MBA_POINT_TO_POINT:
			case MBA_CHG_IN_CONNECTION:
			case MBA_PORT_UPDATE:
			case MBA_RSCN_UPDATE:
				ql_dbg(ql_dbg_async, vha, 0x5024,
				    "Async_event for VP[%d], mb=0x%x vha=%p.\n",
				    i, *mb, vha);
				qla2x00_async_event(vha, rsp, mb);
				break;
			}
			spin_lock_irqsave(&ha->vport_slock, flags);
			atomic_dec(&vha->vref_count);
		}
		i++;
	}
	spin_unlock_irqrestore(&ha->vport_slock, flags);
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| seokmann ju | seokmann ju | 85 | 48.85% | 1 | 16.67% | 
| arun easi | arun easi | 61 | 35.06% | 1 | 16.67% | 
| anirban chakraborty | anirban chakraborty | 23 | 13.22% | 3 | 50.00% | 
| saurav kashyap | saurav kashyap | 5 | 2.87% | 1 | 16.67% | 
 | Total | 174 | 100.00% | 6 | 100.00% | 
int
qla2x00_vp_abort_isp(scsi_qla_host_t *vha)
{
	/*
         * Physical port will do most of the abort and recovery work. We can
         * just treat it as a loop down
         */
	if (atomic_read(&vha->loop_state) != LOOP_DOWN) {
		atomic_set(&vha->loop_state, LOOP_DOWN);
		qla2x00_mark_all_devices_lost(vha, 0);
	} else {
		if (!atomic_read(&vha->loop_down_timer))
			atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME);
	}
	/*
         * To exclusively reset vport, we need to log it out first.  Note: this
         * control_vp can fail if ISP reset is already issued, this is
         * expected, as the vp would be already logged out due to ISP reset.
         */
	if (!test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags))
		qla24xx_control_vp(vha, VCE_COMMAND_DISABLE_VPS_LOGO_ALL);
	ql_dbg(ql_dbg_taskm, vha, 0x801d,
	    "Scheduling enable of Vport %d.\n", vha->vp_idx);
	return qla24xx_enable_vp(vha);
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| seokmann ju | seokmann ju | 77 | 71.96% | 1 | 25.00% | 
| anirban chakraborty | anirban chakraborty | 23 | 21.50% | 1 | 25.00% | 
| saurav kashyap | saurav kashyap | 6 | 5.61% | 1 | 25.00% | 
| andrew vasquez | andrew vasquez | 1 | 0.93% | 1 | 25.00% | 
 | Total | 107 | 100.00% | 4 | 100.00% | 
static int
qla2x00_do_dpc_vp(scsi_qla_host_t *vha)
{
	struct qla_hw_data *ha = vha->hw;
	scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev);
	ql_dbg(ql_dbg_dpc + ql_dbg_verbose, vha, 0x4012,
	    "Entering %s vp_flags: 0x%lx.\n", __func__, vha->vp_flags);
	qla2x00_do_work(vha);
	/* Check if Fw is ready to configure VP first */
	if (test_bit(VP_CONFIG_OK, &base_vha->vp_flags)) {
		if (test_and_clear_bit(VP_IDX_ACQUIRED, &vha->vp_flags)) {
			/* VP acquired. complete port configuration */
			ql_dbg(ql_dbg_dpc, vha, 0x4014,
			    "Configure VP scheduled.\n");
			qla24xx_configure_vp(vha);
			ql_dbg(ql_dbg_dpc, vha, 0x4015,
			    "Configure VP end.\n");
			return 0;
		}
	}
	if (test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags)) {
		ql_dbg(ql_dbg_dpc, vha, 0x4016,
		    "FCPort update scheduled.\n");
		qla2x00_update_fcports(vha);
		clear_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags);
		ql_dbg(ql_dbg_dpc, vha, 0x4017,
		    "FCPort update end.\n");
	}
	if ((test_and_clear_bit(RELOGIN_NEEDED, &vha->dpc_flags)) &&
		!test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags) &&
		atomic_read(&vha->loop_state) != LOOP_DOWN) {
		ql_dbg(ql_dbg_dpc, vha, 0x4018,
		    "Relogin needed scheduled.\n");
		qla2x00_relogin(vha);
		ql_dbg(ql_dbg_dpc, vha, 0x4019,
		    "Relogin needed end.\n");
	}
	if (test_and_clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags) &&
	    (!(test_and_set_bit(RESET_ACTIVE, &vha->dpc_flags)))) {
		clear_bit(RESET_ACTIVE, &vha->dpc_flags);
	}
	if (test_and_clear_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) {
		if (!(test_and_set_bit(LOOP_RESYNC_ACTIVE, &vha->dpc_flags))) {
			ql_dbg(ql_dbg_dpc, vha, 0x401a,
			    "Loop resync scheduled.\n");
			qla2x00_loop_resync(vha);
			clear_bit(LOOP_RESYNC_ACTIVE, &vha->dpc_flags);
			ql_dbg(ql_dbg_dpc, vha, 0x401b,
			    "Loop resync end.\n");
		}
	}
	ql_dbg(ql_dbg_dpc + ql_dbg_verbose, vha, 0x401c,
	    "Exiting %s.\n", __func__);
	return 0;
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| seokmann ju | seokmann ju | 133 | 37.57% | 1 | 12.50% | 
| saurav kashyap | saurav kashyap | 112 | 31.64% | 2 | 25.00% | 
| anirban chakraborty | anirban chakraborty | 66 | 18.64% | 1 | 12.50% | 
| sawan chandak | sawan chandak | 35 | 9.89% | 1 | 12.50% | 
| andrew vasquez | andrew vasquez | 5 | 1.41% | 1 | 12.50% | 
| lalit chandivade | lalit chandivade | 2 | 0.56% | 1 | 12.50% | 
| adrian bunk | adrian bunk | 1 | 0.28% | 1 | 12.50% | 
 | Total | 354 | 100.00% | 8 | 100.00% | 
void
qla2x00_do_dpc_all_vps(scsi_qla_host_t *vha)
{
	struct qla_hw_data *ha = vha->hw;
	scsi_qla_host_t *vp;
	unsigned long flags = 0;
	if (vha->vp_idx)
		return;
	if (list_empty(&ha->vp_list))
		return;
	clear_bit(VP_DPC_NEEDED, &vha->dpc_flags);
	if (!(ha->current_topology & ISP_CFG_F))
		return;
	spin_lock_irqsave(&ha->vport_slock, flags);
	list_for_each_entry(vp, &ha->vp_list, list) {
		if (vp->vp_idx) {
			atomic_inc(&vp->vref_count);
			spin_unlock_irqrestore(&ha->vport_slock, flags);
			qla2x00_do_dpc_vp(vp);
			spin_lock_irqsave(&ha->vport_slock, flags);
			atomic_dec(&vp->vref_count);
		}
	}
	spin_unlock_irqrestore(&ha->vport_slock, flags);
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| arun easi | arun easi | 64 | 43.54% | 1 | 20.00% | 
| seokmann ju | seokmann ju | 53 | 36.05% | 1 | 20.00% | 
| anirban chakraborty | anirban chakraborty | 18 | 12.24% | 2 | 40.00% | 
| andrew vasquez | andrew vasquez | 12 | 8.16% | 1 | 20.00% | 
 | Total | 147 | 100.00% | 5 | 100.00% | 
int
qla24xx_vport_create_req_sanity_check(struct fc_vport *fc_vport)
{
	scsi_qla_host_t *base_vha = shost_priv(fc_vport->shost);
	struct qla_hw_data *ha = base_vha->hw;
	scsi_qla_host_t *vha;
	uint8_t port_name[WWN_SIZE];
	if (fc_vport->roles != FC_PORT_ROLE_FCP_INITIATOR)
		return VPCERR_UNSUPPORTED;
	/* Check up the F/W and H/W support NPIV */
	if (!ha->flags.npiv_supported)
		return VPCERR_UNSUPPORTED;
	/* Check up whether npiv supported switch presented */
	if (!(ha->switch_cap & FLOGI_MID_SUPPORT))
		return VPCERR_NO_FABRIC_SUPP;
	/* Check up unique WWPN */
	u64_to_wwn(fc_vport->port_name, port_name);
	if (!memcmp(port_name, base_vha->port_name, WWN_SIZE))
		return VPCERR_BAD_WWN;
	vha = qla24xx_find_vhost_by_name(ha, port_name);
	if (vha)
		return VPCERR_BAD_WWN;
	/* Check up max-npiv-supports */
	if (ha->num_vhosts > ha->max_npiv_vports) {
		ql_dbg(ql_dbg_vport, vha, 0xa004,
		    "num_vhosts %ud is bigger "
		    "than max_npiv_vports %ud.\n",
		    ha->num_vhosts, ha->max_npiv_vports);
		return VPCERR_UNSUPPORTED;
	}
	return 0;
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| seokmann ju | seokmann ju | 139 | 86.34% | 2 | 40.00% | 
| anirban chakraborty | anirban chakraborty | 11 | 6.83% | 1 | 20.00% | 
| saurav kashyap | saurav kashyap | 8 | 4.97% | 1 | 20.00% | 
| andrew vasquez | andrew vasquez | 3 | 1.86% | 1 | 20.00% | 
 | Total | 161 | 100.00% | 5 | 100.00% | 
scsi_qla_host_t *
qla24xx_create_vhost(struct fc_vport *fc_vport)
{
	scsi_qla_host_t *base_vha = shost_priv(fc_vport->shost);
	struct qla_hw_data *ha = base_vha->hw;
	scsi_qla_host_t *vha;
	struct scsi_host_template *sht = &qla2xxx_driver_template;
	struct Scsi_Host *host;
	vha = qla2x00_create_host(sht, ha);
	if (!vha) {
		ql_log(ql_log_warn, vha, 0xa005,
		    "scsi_host_alloc() failed for vport.\n");
		return(NULL);
	}
	host = vha->host;
	fc_vport->dd_data = vha;
	/* New host info */
	u64_to_wwn(fc_vport->node_name, vha->node_name);
	u64_to_wwn(fc_vport->port_name, vha->port_name);
	vha->fc_vport = fc_vport;
	vha->device_flags = 0;
	vha->vp_idx = qla24xx_allocate_vp_id(vha);
	if (vha->vp_idx > ha->max_npiv_vports) {
		ql_dbg(ql_dbg_vport, vha, 0xa006,
		    "Couldn't allocate vp_id.\n");
		goto create_vhost_failed;
	}
	vha->mgmt_svr_loop_id = 10 + vha->vp_idx;
	vha->dpc_flags = 0L;
	/*
         * To fix the issue of processing a parent's RSCN for the vport before
         * its SCR is complete.
         */
	set_bit(VP_SCR_NEEDED, &vha->vp_flags);
	atomic_set(&vha->loop_state, LOOP_DOWN);
	atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME);
	qla2x00_start_timer(vha, qla2x00_timer, WATCH_INTERVAL);
	vha->req = base_vha->req;
	host->can_queue = base_vha->req->length + 128;
	host->cmd_per_lun = 3;
	if (IS_T10_PI_CAPABLE(ha) && ql2xenabledif)
		host->max_cmd_len = 32;
	else
		host->max_cmd_len = MAX_CMDSZ;
	host->max_channel = MAX_BUSES - 1;
	host->max_lun = ql2xmaxlun;
	host->unique_id = host->host_no;
	host->max_id = ha->max_fibre_devices;
	host->transportt = qla2xxx_transport_vport_template;
	ql_dbg(ql_dbg_vport, vha, 0xa007,
	    "Detect vport hba %ld at address = %p.\n",
	    vha->host_no, vha);
	vha->flags.init_done = 1;
	mutex_lock(&ha->vport_lock);
	set_bit(vha->vp_idx, ha->vp_idx_map);
	ha->cur_vport_count++;
	mutex_unlock(&ha->vport_lock);
	return vha;
create_vhost_failed:
	return NULL;
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| seokmann ju | seokmann ju | 249 | 67.85% | 2 | 15.38% | 
| anirban chakraborty | anirban chakraborty | 40 | 10.90% | 3 | 23.08% | 
| andrew vasquez | andrew vasquez | 36 | 9.81% | 3 | 23.08% | 
| saurav kashyap | saurav kashyap | 22 | 5.99% | 1 | 7.69% | 
| arun easi | arun easi | 16 | 4.36% | 2 | 15.38% | 
| chad dupuis | chad dupuis | 3 | 0.82% | 1 | 7.69% | 
| giridhar malavali | giridhar malavali | 1 | 0.27% | 1 | 7.69% | 
 | Total | 367 | 100.00% | 13 | 100.00% | 
static void
qla25xx_free_req_que(struct scsi_qla_host *vha, struct req_que *req)
{
	struct qla_hw_data *ha = vha->hw;
	uint16_t que_id = req->id;
	dma_free_coherent(&ha->pdev->dev, (req->length + 1) *
		sizeof(request_t), req->ring, req->dma);
	req->ring = NULL;
	req->dma = 0;
	if (que_id) {
		ha->req_q_map[que_id] = NULL;
		mutex_lock(&ha->vport_lock);
		clear_bit(que_id, ha->req_qid_map);
		mutex_unlock(&ha->vport_lock);
	}
	kfree(req->outstanding_cmds);
	kfree(req);
	req = NULL;
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| anirban chakraborty | anirban chakraborty | 124 | 94.66% | 1 | 50.00% | 
| chad dupuis | chad dupuis | 7 | 5.34% | 1 | 50.00% | 
 | Total | 131 | 100.00% | 2 | 100.00% | 
static void
qla25xx_free_rsp_que(struct scsi_qla_host *vha, struct rsp_que *rsp)
{
	struct qla_hw_data *ha = vha->hw;
	uint16_t que_id = rsp->id;
	if (rsp->msix && rsp->msix->have_irq) {
		free_irq(rsp->msix->vector, rsp);
		rsp->msix->have_irq = 0;
		rsp->msix->rsp = NULL;
	}
	dma_free_coherent(&ha->pdev->dev, (rsp->length + 1) *
		sizeof(response_t), rsp->ring, rsp->dma);
	rsp->ring = NULL;
	rsp->dma = 0;
	if (que_id) {
		ha->rsp_q_map[que_id] = NULL;
		mutex_lock(&ha->vport_lock);
		clear_bit(que_id, ha->rsp_qid_map);
		mutex_unlock(&ha->vport_lock);
	}
	kfree(rsp);
	rsp = NULL;
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| anirban chakraborty | anirban chakraborty | 165 | 100.00% | 1 | 100.00% | 
 | Total | 165 | 100.00% | 1 | 100.00% | 
int
qla25xx_delete_req_que(struct scsi_qla_host *vha, struct req_que *req)
{
	int ret = -1;
	if (req) {
		req->options |= BIT_0;
		ret = qla25xx_init_req_que(vha, req);
	}
	if (ret == QLA_SUCCESS)
		qla25xx_free_req_que(vha, req);
	return ret;
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| anirban chakraborty | anirban chakraborty | 58 | 100.00% | 1 | 100.00% | 
 | Total | 58 | 100.00% | 1 | 100.00% | 
static int
qla25xx_delete_rsp_que(struct scsi_qla_host *vha, struct rsp_que *rsp)
{
	int ret = -1;
	if (rsp) {
		rsp->options |= BIT_0;
		ret = qla25xx_init_rsp_que(vha, rsp);
	}
	if (ret == QLA_SUCCESS)
		qla25xx_free_rsp_que(vha, rsp);
	return ret;
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| anirban chakraborty | anirban chakraborty | 58 | 98.31% | 1 | 50.00% | 
| andrew vasquez | andrew vasquez | 1 | 1.69% | 1 | 50.00% | 
 | Total | 59 | 100.00% | 2 | 100.00% | 
/* Delete all queues for a given vhost */
int
qla25xx_delete_queues(struct scsi_qla_host *vha)
{
	int cnt, ret = 0;
	struct req_que *req = NULL;
	struct rsp_que *rsp = NULL;
	struct qla_hw_data *ha = vha->hw;
	/* Delete request queues */
	for (cnt = 1; cnt < ha->max_req_queues; cnt++) {
		req = ha->req_q_map[cnt];
		if (req && test_bit(cnt, ha->req_qid_map)) {
			ret = qla25xx_delete_req_que(vha, req);
			if (ret != QLA_SUCCESS) {
				ql_log(ql_log_warn, vha, 0x00ea,
				    "Couldn't delete req que %d.\n",
				    req->id);
				return ret;
			}
		}
	}
	/* Delete response queues */
	for (cnt = 1; cnt < ha->max_rsp_queues; cnt++) {
		rsp = ha->rsp_q_map[cnt];
		if (rsp && test_bit(cnt, ha->rsp_qid_map)) {
			ret = qla25xx_delete_rsp_que(vha, rsp);
			if (ret != QLA_SUCCESS) {
				ql_log(ql_log_warn, vha, 0x00eb,
				    "Couldn't delete rsp que %d.\n",
				    rsp->id);
				return ret;
			}
		}
	}
	return ret;
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| anirban chakraborty | anirban chakraborty | 167 | 84.77% | 2 | 50.00% | 
| quinn tran | quinn tran | 18 | 9.14% | 1 | 25.00% | 
| saurav kashyap | saurav kashyap | 12 | 6.09% | 1 | 25.00% | 
 | Total | 197 | 100.00% | 4 | 100.00% | 
int
qla25xx_create_req_que(struct qla_hw_data *ha, uint16_t options,
	uint8_t vp_idx, uint16_t rid, int rsp_que, uint8_t qos)
{
	int ret = 0;
	struct req_que *req = NULL;
	struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
	uint16_t que_id = 0;
	device_reg_t *reg;
	uint32_t cnt;
	req = kzalloc(sizeof(struct req_que), GFP_KERNEL);
	if (req == NULL) {
		ql_log(ql_log_fatal, base_vha, 0x00d9,
		    "Failed to allocate memory for request queue.\n");
		goto failed;
	}
	req->length = REQUEST_ENTRY_CNT_24XX;
	req->ring = dma_alloc_coherent(&ha->pdev->dev,
			(req->length + 1) * sizeof(request_t),
			&req->dma, GFP_KERNEL);
	if (req->ring == NULL) {
		ql_log(ql_log_fatal, base_vha, 0x00da,
		    "Failed to allocate memory for request_ring.\n");
		goto que_failed;
	}
	ret = qla2x00_alloc_outstanding_cmds(ha, req);
	if (ret != QLA_SUCCESS)
		goto que_failed;
	mutex_lock(&ha->vport_lock);
	que_id = find_first_zero_bit(ha->req_qid_map, ha->max_req_queues);
	if (que_id >= ha->max_req_queues) {
		mutex_unlock(&ha->vport_lock);
		ql_log(ql_log_warn, base_vha, 0x00db,
		    "No resources to create additional request queue.\n");
		goto que_failed;
	}
	set_bit(que_id, ha->req_qid_map);
	ha->req_q_map[que_id] = req;
	req->rid = rid;
	req->vp_idx = vp_idx;
	req->qos = qos;
	ql_dbg(ql_dbg_multiq, base_vha, 0xc002,
	    "queue_id=%d rid=%d vp_idx=%d qos=%d.\n",
	    que_id, req->rid, req->vp_idx, req->qos);
	ql_dbg(ql_dbg_init, base_vha, 0x00dc,
	    "queue_id=%d rid=%d vp_idx=%d qos=%d.\n",
	    que_id, req->rid, req->vp_idx, req->qos);
	if (rsp_que < 0)
		req->rsp = NULL;
	else
		req->rsp = ha->rsp_q_map[rsp_que];
	/* Use alternate PCI bus number */
	if (MSB(req->rid))
		options |= BIT_4;
	/* Use alternate PCI devfn */
	if (LSB(req->rid))
		options |= BIT_5;
	req->options = options;
	ql_dbg(ql_dbg_multiq, base_vha, 0xc003,
	    "options=0x%x.\n", req->options);
	ql_dbg(ql_dbg_init, base_vha, 0x00dd,
	    "options=0x%x.\n", req->options);
	for (cnt = 1; cnt < req->num_outstanding_cmds; cnt++)
		req->outstanding_cmds[cnt] = NULL;
	req->current_outstanding_cmd = 1;
	req->ring_ptr = req->ring;
	req->ring_index = 0;
	req->cnt = req->length;
	req->id = que_id;
	reg = ISP_QUE_REG(ha, que_id);
	req->req_q_in = ®->isp25mq.req_q_in;
	req->req_q_out = ®->isp25mq.req_q_out;
	req->max_q_depth = ha->req_q_map[0]->max_q_depth;
	req->out_ptr = (void *)(req->ring + req->length);
	mutex_unlock(&ha->vport_lock);
	ql_dbg(ql_dbg_multiq, base_vha, 0xc004,
	    "ring_ptr=%p ring_index=%d, "
	    "cnt=%d id=%d max_q_depth=%d.\n",
	    req->ring_ptr, req->ring_index,
	    req->cnt, req->id, req->max_q_depth);
	ql_dbg(ql_dbg_init, base_vha, 0x00de,
	    "ring_ptr=%p ring_index=%d, "
	    "cnt=%d id=%d max_q_depth=%d.\n",
	    req->ring_ptr, req->ring_index, req->cnt,
	    req->id, req->max_q_depth);
	ret = qla25xx_init_req_que(base_vha, req);
	if (ret != QLA_SUCCESS) {
		ql_log(ql_log_fatal, base_vha, 0x00df,
		    "%s failed.\n", __func__);
		mutex_lock(&ha->vport_lock);
		clear_bit(que_id, ha->req_qid_map);
		mutex_unlock(&ha->vport_lock);
		goto que_failed;
	}
	return req->id;
que_failed:
	qla25xx_free_req_que(base_vha, req);
failed:
	return 0;
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| anirban chakraborty | anirban chakraborty | 430 | 63.80% | 4 | 40.00% | 
| saurav kashyap | saurav kashyap | 167 | 24.78% | 1 | 10.00% | 
| andrew vasquez | andrew vasquez | 37 | 5.49% | 2 | 20.00% | 
| chad dupuis | chad dupuis | 21 | 3.12% | 1 | 10.00% | 
| joe carnuccio | joe carnuccio | 18 | 2.67% | 1 | 10.00% | 
| masanari iida | masanari iida | 1 | 0.15% | 1 | 10.00% | 
 | Total | 674 | 100.00% | 10 | 100.00% | 
static void qla_do_work(struct work_struct *work)
{
	unsigned long flags;
	struct rsp_que *rsp = container_of(work, struct rsp_que, q_work);
	struct scsi_qla_host *vha;
	struct qla_hw_data *ha = rsp->hw;
	spin_lock_irqsave(&rsp->hw->hardware_lock, flags);
	vha = pci_get_drvdata(ha->pdev);
	qla24xx_process_response_queue(vha, rsp);
	spin_unlock_irqrestore(&rsp->hw->hardware_lock, flags);
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| anirban chakraborty | anirban chakraborty | 84 | 100.00% | 3 | 100.00% | 
 | Total | 84 | 100.00% | 3 | 100.00% | 
/* create response queue */
int
qla25xx_create_rsp_que(struct qla_hw_data *ha, uint16_t options,
	uint8_t vp_idx, uint16_t rid, int req)
{
	int ret = 0;
	struct rsp_que *rsp = NULL;
	struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
	uint16_t que_id = 0;
	device_reg_t *reg;
	rsp = kzalloc(sizeof(struct rsp_que), GFP_KERNEL);
	if (rsp == NULL) {
		ql_log(ql_log_warn, base_vha, 0x0066,
		    "Failed to allocate memory for response queue.\n");
		goto failed;
	}
	rsp->length = RESPONSE_ENTRY_CNT_MQ;
	rsp->ring = dma_alloc_coherent(&ha->pdev->dev,
			(rsp->length + 1) * sizeof(response_t),
			&rsp->dma, GFP_KERNEL);
	if (rsp->ring == NULL) {
		ql_log(ql_log_warn, base_vha, 0x00e1,
		    "Failed to allocate memory for response ring.\n");
		goto que_failed;
	}
	mutex_lock(&ha->vport_lock);
	que_id = find_first_zero_bit(ha->rsp_qid_map, ha->max_rsp_queues);
	if (que_id >= ha->max_rsp_queues) {
		mutex_unlock(&ha->vport_lock);
		ql_log(ql_log_warn, base_vha, 0x00e2,
		    "No resources to create additional request queue.\n");
		goto que_failed;
	}
	set_bit(que_id, ha->rsp_qid_map);
	if (ha->flags.msix_enabled)
		rsp->msix = &ha->msix_entries[que_id + 1];
	else
		ql_log(ql_log_warn, base_vha, 0x00e3,
		    "MSIX not enabled.\n");
	ha->rsp_q_map[que_id] = rsp;
	rsp->rid = rid;
	rsp->vp_idx = vp_idx;
	rsp->hw = ha;
	ql_dbg(ql_dbg_init, base_vha, 0x00e4,
	    "queue_id=%d rid=%d vp_idx=%d hw=%p.\n",
	    que_id, rsp->rid, rsp->vp_idx, rsp->hw);
	/* Use alternate PCI bus number */
	if (MSB(rsp->rid))
		options |= BIT_4;
	/* Use alternate PCI devfn */
	if (LSB(rsp->rid))
		options |= BIT_5;
	/* Enable MSIX handshake mode on for uncapable adapters */
	if (!IS_MSIX_NACK_CAPABLE(ha))
		options |= BIT_6;
	rsp->options = options;
	rsp->id = que_id;
	reg = ISP_QUE_REG(ha, que_id);
	rsp->rsp_q_in = ®->isp25mq.rsp_q_in;
	rsp->rsp_q_out = ®->isp25mq.rsp_q_out;
	rsp->in_ptr = (void *)(rsp->ring + rsp->length);
	mutex_unlock(&ha->vport_lock);
	ql_dbg(ql_dbg_multiq, base_vha, 0xc00b,
	    "options=%x id=%d rsp_q_in=%p rsp_q_out=%p",
	    rsp->options, rsp->id, rsp->rsp_q_in,
	    rsp->rsp_q_out);
	ql_dbg(ql_dbg_init, base_vha, 0x00e5,
	    "options=%x id=%d rsp_q_in=%p rsp_q_out=%p",
	    rsp->options, rsp->id, rsp->rsp_q_in,
	    rsp->rsp_q_out);
	ret = qla25xx_request_irq(rsp);
	if (ret)
		goto que_failed;
	ret = qla25xx_init_rsp_que(base_vha, rsp);
	if (ret != QLA_SUCCESS) {
		ql_log(ql_log_fatal, base_vha, 0x00e7,
		    "%s failed.\n", __func__);
		mutex_lock(&ha->vport_lock);
		clear_bit(que_id, ha->rsp_qid_map);
		mutex_unlock(&ha->vport_lock);
		goto que_failed;
	}
	if (req >= 0)
		rsp->req = ha->req_q_map[req];
	else
		rsp->req = NULL;
	qla2x00_init_response_q_entries(rsp);
	if (rsp->hw->wq)
		INIT_WORK(&rsp->q_work, qla_do_work);
	return rsp->id;
que_failed:
	qla25xx_free_rsp_que(base_vha, rsp);
failed:
	return 0;
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| anirban chakraborty | anirban chakraborty | 442 | 73.18% | 5 | 55.56% | 
| saurav kashyap | saurav kashyap | 108 | 17.88% | 1 | 11.11% | 
| andrew vasquez | andrew vasquez | 35 | 5.79% | 1 | 11.11% | 
| joe carnuccio | joe carnuccio | 18 | 2.98% | 1 | 11.11% | 
| yannick guerrini | yannick guerrini | 1 | 0.17% | 1 | 11.11% | 
 | Total | 604 | 100.00% | 9 | 100.00% | 
Overall Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| anirban chakraborty | anirban chakraborty | 1751 | 41.43% | 10 | 21.74% | 
| seokmann ju | seokmann ju | 1363 | 32.25% | 3 | 6.52% | 
| saurav kashyap | saurav kashyap | 476 | 11.26% | 2 | 4.35% | 
| arun easi | arun easi | 274 | 6.48% | 3 | 6.52% | 
| andrew vasquez | andrew vasquez | 151 | 3.57% | 10 | 21.74% | 
| nicholas bellinger | nicholas bellinger | 53 | 1.25% | 2 | 4.35% | 
| joe carnuccio | joe carnuccio | 38 | 0.90% | 2 | 4.35% | 
| sawan chandak | sawan chandak | 35 | 0.83% | 1 | 2.17% | 
| chad dupuis | chad dupuis | 32 | 0.76% | 3 | 6.52% | 
| quinn tran | quinn tran | 18 | 0.43% | 1 | 2.17% | 
| matthias kaehlcke | matthias kaehlcke | 14 | 0.33% | 1 | 2.17% | 
| lalit chandivade | lalit chandivade | 11 | 0.26% | 2 | 4.35% | 
| tejun heo | tejun heo | 3 | 0.07% | 1 | 2.17% | 
| adrian bunk | adrian bunk | 3 | 0.07% | 1 | 2.17% | 
| armen baloyan | armen baloyan | 1 | 0.02% | 1 | 2.17% | 
| yannick guerrini | yannick guerrini | 1 | 0.02% | 1 | 2.17% | 
| masanari iida | masanari iida | 1 | 0.02% | 1 | 2.17% | 
| giridhar malavali | giridhar malavali | 1 | 0.02% | 1 | 2.17% | 
 | Total | 4226 | 100.00% | 46 | 100.00% | 
  
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.