2007-07-05 14:16:51 -06:00
|
|
|
/*
|
2008-04-03 14:13:13 -06:00
|
|
|
* QLogic Fibre Channel HBA Driver
|
2014-04-11 14:54:24 -06:00
|
|
|
* Copyright (c) 2003-2014 QLogic Corporation
|
2007-07-05 14:16:51 -06:00
|
|
|
*
|
2008-04-03 14:13:13 -06:00
|
|
|
* See LICENSE.qla2xxx for copyright and licensing details.
|
2007-07-05 14:16:51 -06:00
|
|
|
*/
|
|
|
|
#include "qla_def.h"
|
2008-11-06 11:40:19 -07:00
|
|
|
#include "qla_gbl.h"
|
2012-05-15 12:34:28 -06:00
|
|
|
#include "qla_target.h"
|
2007-07-05 14:16:51 -06:00
|
|
|
|
|
|
|
#include <linux/moduleparam.h>
|
|
|
|
#include <linux/vmalloc.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 02:04:11 -06:00
|
|
|
#include <linux/slab.h>
|
2007-07-05 14:16:51 -06:00
|
|
|
#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)
|
|
|
|
{
|
2008-11-06 11:40:19 -07:00
|
|
|
if (vha->vp_idx && vha->timer_active) {
|
2007-07-05 14:16:51 -06:00
|
|
|
del_timer_sync(&vha->timer);
|
|
|
|
vha->timer_active = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-17 10:02:15 -07:00
|
|
|
static uint32_t
|
2007-07-05 14:16:51 -06:00
|
|
|
qla24xx_allocate_vp_id(scsi_qla_host_t *vha)
|
|
|
|
{
|
|
|
|
uint32_t vp_id;
|
2008-11-06 11:40:19 -07:00
|
|
|
struct qla_hw_data *ha = vha->hw;
|
2010-09-03 15:57:00 -06:00
|
|
|
unsigned long flags;
|
2007-07-05 14:16:51 -06:00
|
|
|
|
|
|
|
/* Find an empty slot and assign an vp_id */
|
2008-05-12 23:21:11 -06:00
|
|
|
mutex_lock(&ha->vport_lock);
|
2007-11-12 11:30:58 -07:00
|
|
|
vp_id = find_first_zero_bit(ha->vp_idx_map, ha->max_npiv_vports + 1);
|
|
|
|
if (vp_id > ha->max_npiv_vports) {
|
2011-07-14 13:00:13 -06:00
|
|
|
ql_dbg(ql_dbg_vport, vha, 0xa000,
|
|
|
|
"vp_id %d is bigger than max-supported %d.\n",
|
|
|
|
vp_id, ha->max_npiv_vports);
|
2008-05-12 23:21:11 -06:00
|
|
|
mutex_unlock(&ha->vport_lock);
|
2007-07-05 14:16:51 -06:00
|
|
|
return vp_id;
|
|
|
|
}
|
|
|
|
|
2007-11-12 11:30:58 -07:00
|
|
|
set_bit(vp_id, ha->vp_idx_map);
|
2007-07-05 14:16:51 -06:00
|
|
|
ha->num_vhosts++;
|
|
|
|
vha->vp_idx = vp_id;
|
2010-09-03 15:57:00 -06:00
|
|
|
|
|
|
|
spin_lock_irqsave(&ha->vport_slock, flags);
|
2008-11-06 11:40:19 -07:00
|
|
|
list_add_tail(&vha->list, &ha->vp_list);
|
2017-12-28 13:33:27 -07:00
|
|
|
spin_unlock_irqrestore(&ha->vport_slock, flags);
|
2012-05-15 12:34:28 -06:00
|
|
|
|
2017-12-28 13:33:27 -07:00
|
|
|
spin_lock_irqsave(&ha->hardware_lock, flags);
|
2012-05-15 12:34:28 -06:00
|
|
|
qlt_update_vp_map(vha, SET_VP_IDX);
|
2017-12-28 13:33:27 -07:00
|
|
|
spin_unlock_irqrestore(&ha->hardware_lock, flags);
|
2010-09-03 15:57:00 -06:00
|
|
|
|
2008-05-12 23:21:11 -06:00
|
|
|
mutex_unlock(&ha->vport_lock);
|
2007-07-05 14:16:51 -06:00
|
|
|
return vp_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
qla24xx_deallocate_vp_id(scsi_qla_host_t *vha)
|
|
|
|
{
|
|
|
|
uint16_t vp_id;
|
2008-11-06 11:40:19 -07:00
|
|
|
struct qla_hw_data *ha = vha->hw;
|
2010-09-03 15:57:00 -06:00
|
|
|
unsigned long flags = 0;
|
2007-07-05 14:16:51 -06:00
|
|
|
|
2008-05-12 23:21:11 -06:00
|
|
|
mutex_lock(&ha->vport_lock);
|
2010-09-03 15:57:00 -06:00
|
|
|
/*
|
|
|
|
* 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)
|
|
|
|
*/
|
2017-08-23 16:04:55 -06:00
|
|
|
wait_event_timeout(vha->vref_waitq, !atomic_read(&vha->vref_count),
|
2017-03-15 10:48:43 -06:00
|
|
|
10*HZ);
|
2010-09-03 15:57:00 -06:00
|
|
|
|
2017-03-15 10:48:43 -06:00
|
|
|
spin_lock_irqsave(&ha->vport_slock, flags);
|
|
|
|
if (atomic_read(&vha->vref_count)) {
|
|
|
|
ql_dbg(ql_dbg_vport, vha, 0xfffa,
|
|
|
|
"vha->vref_count=%u timeout\n", vha->vref_count.counter);
|
|
|
|
vha->vref_count = (atomic_t)ATOMIC_INIT(0);
|
2010-09-03 15:57:00 -06:00
|
|
|
}
|
|
|
|
list_del(&vha->list);
|
2012-05-15 12:34:28 -06:00
|
|
|
qlt_update_vp_map(vha, RESET_VP_IDX);
|
2010-09-03 15:57:00 -06:00
|
|
|
spin_unlock_irqrestore(&ha->vport_slock, flags);
|
|
|
|
|
2007-07-05 14:16:51 -06:00
|
|
|
vp_id = vha->vp_idx;
|
|
|
|
ha->num_vhosts--;
|
2007-11-12 11:30:58 -07:00
|
|
|
clear_bit(vp_id, ha->vp_idx_map);
|
2010-09-03 15:57:00 -06:00
|
|
|
|
2008-05-12 23:21:11 -06:00
|
|
|
mutex_unlock(&ha->vport_lock);
|
2007-07-05 14:16:51 -06:00
|
|
|
}
|
|
|
|
|
2008-01-17 10:02:15 -07:00
|
|
|
static scsi_qla_host_t *
|
2008-11-06 11:40:19 -07:00
|
|
|
qla24xx_find_vhost_by_name(struct qla_hw_data *ha, uint8_t *port_name)
|
2007-07-05 14:16:51 -06:00
|
|
|
{
|
|
|
|
scsi_qla_host_t *vha;
|
2009-03-05 12:07:02 -07:00
|
|
|
struct scsi_qla_host *tvha;
|
2010-09-03 15:57:00 -06:00
|
|
|
unsigned long flags;
|
2007-07-05 14:16:51 -06:00
|
|
|
|
2010-09-03 15:57:00 -06:00
|
|
|
spin_lock_irqsave(&ha->vport_slock, flags);
|
2007-07-05 14:16:51 -06:00
|
|
|
/* Locate matching device in database. */
|
2009-03-05 12:07:02 -07:00
|
|
|
list_for_each_entry_safe(vha, tvha, &ha->vp_list, list) {
|
2010-09-03 15:57:00 -06:00
|
|
|
if (!memcmp(port_name, vha->port_name, WWN_SIZE)) {
|
|
|
|
spin_unlock_irqrestore(&ha->vport_slock, flags);
|
2007-07-05 14:16:51 -06:00
|
|
|
return vha;
|
2010-09-03 15:57:00 -06:00
|
|
|
}
|
2007-07-05 14:16:51 -06:00
|
|
|
}
|
2010-09-03 15:57:00 -06:00
|
|
|
spin_unlock_irqrestore(&ha->vport_slock, flags);
|
2007-07-05 14:16:51 -06:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* qla2x00_mark_vp_devices_dead
|
|
|
|
* Updates fcport state when device goes offline.
|
|
|
|
*
|
|
|
|
* Input:
|
|
|
|
* ha = adapter block pointer.
|
|
|
|
* fcport = port structure pointer.
|
|
|
|
*
|
|
|
|
* Return:
|
|
|
|
* None.
|
|
|
|
*
|
|
|
|
* Context:
|
|
|
|
*/
|
2007-09-20 15:07:47 -06:00
|
|
|
static void
|
2007-07-05 14:16:51 -06:00
|
|
|
qla2x00_mark_vp_devices_dead(scsi_qla_host_t *vha)
|
|
|
|
{
|
2010-09-03 15:57:00 -06:00
|
|
|
/*
|
|
|
|
* !!! NOTE !!!
|
|
|
|
* This function, if called in contexts other than vp create, disable
|
|
|
|
* or delete, please make sure this is synchronized with the
|
|
|
|
* delete thread.
|
|
|
|
*/
|
2007-07-05 14:16:51 -06:00
|
|
|
fc_port_t *fcport;
|
|
|
|
|
2008-11-06 11:40:19 -07:00
|
|
|
list_for_each_entry(fcport, &vha->vp_fcports, list) {
|
2011-07-14 13:00:13 -06:00
|
|
|
ql_dbg(ql_dbg_vport, vha, 0xa001,
|
|
|
|
"Marking port dead, loop_id=0x%04x : %x.\n",
|
2012-05-15 12:34:20 -06:00
|
|
|
fcport->loop_id, fcport->vha->vp_idx);
|
2007-07-05 14:16:51 -06:00
|
|
|
|
|
|
|
qla2x00_mark_device_lost(vha, fcport, 0, 0);
|
2011-03-30 12:46:32 -06:00
|
|
|
qla2x00_set_fcport_state(fcport, FCS_UNCONFIGURED);
|
2007-07-05 14:16:51 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
qla24xx_disable_vp(scsi_qla_host_t *vha)
|
|
|
|
{
|
2012-10-09 13:12:14 -06:00
|
|
|
unsigned long flags;
|
2007-07-05 14:16:51 -06:00
|
|
|
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);
|
|
|
|
|
2012-05-15 12:34:28 -06:00
|
|
|
/* Remove port id from vp target map */
|
2017-12-28 13:33:27 -07:00
|
|
|
spin_lock_irqsave(&vha->hw->hardware_lock, flags);
|
2012-05-15 12:34:28 -06:00
|
|
|
qlt_update_vp_map(vha, RESET_AL_PA);
|
2017-12-28 13:33:27 -07:00
|
|
|
spin_unlock_irqrestore(&vha->hw->hardware_lock, flags);
|
2012-05-15 12:34:28 -06:00
|
|
|
|
2007-07-05 14:16:51 -06:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
qla24xx_enable_vp(scsi_qla_host_t *vha)
|
|
|
|
{
|
|
|
|
int ret;
|
2008-11-06 11:40:19 -07:00
|
|
|
struct qla_hw_data *ha = vha->hw;
|
|
|
|
scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev);
|
2007-07-05 14:16:51 -06:00
|
|
|
|
|
|
|
/* Check if physical ha port is Up */
|
2008-11-06 11:40:19 -07:00
|
|
|
if (atomic_read(&base_vha->loop_state) == LOOP_DOWN ||
|
2010-05-28 16:08:24 -06:00
|
|
|
atomic_read(&base_vha->loop_state) == LOOP_DEAD ||
|
|
|
|
!(ha->current_topology & ISP_CFG_F)) {
|
2007-07-05 14:16:51 -06:00
|
|
|
vha->vp_err_state = VP_ERR_PORTDWN;
|
|
|
|
fc_vport_set_state(vha->fc_vport, FC_VPORT_LINKDOWN);
|
2017-08-23 16:05:03 -06:00
|
|
|
ql_dbg(ql_dbg_taskm, vha, 0x800b,
|
|
|
|
"%s skip enable. loop_state %x topo %x\n",
|
|
|
|
__func__, base_vha->loop_state.counter,
|
|
|
|
ha->current_topology);
|
|
|
|
|
2007-07-05 14:16:51 -06:00
|
|
|
goto enable_failed;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize the new vport unless it is a persistent port */
|
2008-05-12 23:21:11 -06:00
|
|
|
mutex_lock(&ha->vport_lock);
|
2007-07-05 14:16:51 -06:00
|
|
|
ret = qla24xx_modify_vp_config(vha);
|
2008-05-12 23:21:11 -06:00
|
|
|
mutex_unlock(&ha->vport_lock);
|
2007-07-05 14:16:51 -06:00
|
|
|
|
|
|
|
if (ret != QLA_SUCCESS) {
|
|
|
|
fc_vport_set_state(vha->fc_vport, FC_VPORT_FAILED);
|
|
|
|
goto enable_failed;
|
|
|
|
}
|
|
|
|
|
2011-07-14 13:00:13 -06:00
|
|
|
ql_dbg(ql_dbg_taskm, vha, 0x801a,
|
|
|
|
"Virtual port with id: %d - Enabled.\n", vha->vp_idx);
|
2007-07-05 14:16:51 -06:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
enable_failed:
|
2011-07-14 13:00:13 -06:00
|
|
|
ql_dbg(ql_dbg_taskm, vha, 0x801b,
|
|
|
|
"Virtual port with id: %d - Disabled.\n", vha->vp_idx);
|
2007-07-05 14:16:51 -06:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2007-09-20 15:07:47 -06:00
|
|
|
static void
|
2007-07-05 14:16:51 -06:00
|
|
|
qla24xx_configure_vp(scsi_qla_host_t *vha)
|
|
|
|
{
|
|
|
|
struct fc_vport *fc_vport;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
fc_vport = vha->fc_vport;
|
|
|
|
|
2011-07-14 13:00:13 -06:00
|
|
|
ql_dbg(ql_dbg_vport, vha, 0xa002,
|
|
|
|
"%s: change request #3.\n", __func__);
|
2007-07-05 14:16:51 -06:00
|
|
|
ret = qla2x00_send_change_request(vha, 0x3, vha->vp_idx);
|
|
|
|
if (ret != QLA_SUCCESS) {
|
2011-07-14 13:00:13 -06:00
|
|
|
ql_dbg(ql_dbg_vport, vha, 0xa003, "Failed to enable "
|
|
|
|
"receiving of RSCN requests: 0x%x.\n", ret);
|
2007-07-05 14:16:51 -06:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-12-09 17:45:39 -07:00
|
|
|
qla2x00_alert_all_vps(struct rsp_que *rsp, uint16_t *mb)
|
2007-07-05 14:16:51 -06:00
|
|
|
{
|
2010-09-03 15:57:00 -06:00
|
|
|
scsi_qla_host_t *vha;
|
2008-12-09 17:45:39 -07:00
|
|
|
struct qla_hw_data *ha = rsp->hw;
|
2008-11-06 11:40:19 -07:00
|
|
|
int i = 0;
|
2010-09-03 15:57:00 -06:00
|
|
|
unsigned long flags;
|
2007-07-05 14:16:51 -06:00
|
|
|
|
2010-09-03 15:57:00 -06:00
|
|
|
spin_lock_irqsave(&ha->vport_slock, flags);
|
|
|
|
list_for_each_entry(vha, &ha->vp_list, list) {
|
2008-11-06 11:40:19 -07:00
|
|
|
if (vha->vp_idx) {
|
2010-09-03 15:57:00 -06:00
|
|
|
atomic_inc(&vha->vref_count);
|
|
|
|
spin_unlock_irqrestore(&ha->vport_slock, flags);
|
|
|
|
|
2007-07-05 14:16:51 -06:00
|
|
|
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:
|
2011-07-14 13:00:13 -06:00
|
|
|
ql_dbg(ql_dbg_async, vha, 0x5024,
|
|
|
|
"Async_event for VP[%d], mb=0x%x vha=%p.\n",
|
|
|
|
i, *mb, vha);
|
2008-12-09 17:45:39 -07:00
|
|
|
qla2x00_async_event(vha, rsp, mb);
|
2007-07-05 14:16:51 -06:00
|
|
|
break;
|
2017-12-28 13:33:29 -07:00
|
|
|
case MBA_PORT_UPDATE:
|
|
|
|
case MBA_RSCN_UPDATE:
|
|
|
|
if ((mb[3] & 0xff) == vha->vp_idx) {
|
|
|
|
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;
|
2007-07-05 14:16:51 -06:00
|
|
|
}
|
2010-09-03 15:57:00 -06:00
|
|
|
|
|
|
|
spin_lock_irqsave(&ha->vport_slock, flags);
|
|
|
|
atomic_dec(&vha->vref_count);
|
2017-03-15 10:48:43 -06:00
|
|
|
wake_up(&vha->vref_waitq);
|
2007-07-05 14:16:51 -06:00
|
|
|
}
|
2008-11-06 11:40:19 -07:00
|
|
|
i++;
|
2007-07-05 14:16:51 -06:00
|
|
|
}
|
2010-09-03 15:57:00 -06:00
|
|
|
spin_unlock_irqrestore(&ha->vport_slock, flags);
|
2007-07-05 14:16:51 -06:00
|
|
|
}
|
|
|
|
|
2008-11-06 11:40:19 -07:00
|
|
|
int
|
2007-07-05 14:16:51 -06:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2009-08-25 12:36:19 -06:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
2008-11-06 11:40:19 -07:00
|
|
|
if (!test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags))
|
|
|
|
qla24xx_control_vp(vha, VCE_COMMAND_DISABLE_VPS_LOGO_ALL);
|
|
|
|
|
2011-07-14 13:00:13 -06:00
|
|
|
ql_dbg(ql_dbg_taskm, vha, 0x801d,
|
|
|
|
"Scheduling enable of Vport %d.\n", vha->vp_idx);
|
2008-11-06 11:40:19 -07:00
|
|
|
return qla24xx_enable_vp(vha);
|
2007-07-05 14:16:51 -06:00
|
|
|
}
|
|
|
|
|
2008-01-17 10:02:15 -07:00
|
|
|
static int
|
2007-07-05 14:16:51 -06:00
|
|
|
qla2x00_do_dpc_vp(scsi_qla_host_t *vha)
|
|
|
|
{
|
2015-04-09 13:00:06 -06:00
|
|
|
struct qla_hw_data *ha = vha->hw;
|
|
|
|
scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev);
|
|
|
|
|
2012-05-15 12:34:15 -06:00
|
|
|
ql_dbg(ql_dbg_dpc + ql_dbg_verbose, vha, 0x4012,
|
|
|
|
"Entering %s vp_flags: 0x%lx.\n", __func__, vha->vp_flags);
|
2011-07-14 13:00:13 -06:00
|
|
|
|
2015-04-09 13:00:06 -06:00
|
|
|
/* 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;
|
|
|
|
}
|
2007-07-05 14:16:51 -06:00
|
|
|
}
|
|
|
|
|
2008-11-06 11:40:19 -07:00
|
|
|
if (test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags)) {
|
2011-07-14 13:00:13 -06:00
|
|
|
ql_dbg(ql_dbg_dpc, vha, 0x4016,
|
|
|
|
"FCPort update scheduled.\n");
|
2008-11-06 11:40:19 -07:00
|
|
|
qla2x00_update_fcports(vha);
|
|
|
|
clear_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags);
|
2011-07-14 13:00:13 -06:00
|
|
|
ql_dbg(ql_dbg_dpc, vha, 0x4017,
|
|
|
|
"FCPort update end.\n");
|
2008-11-06 11:40:19 -07:00
|
|
|
}
|
|
|
|
|
2017-12-04 15:45:06 -07:00
|
|
|
if (test_bit(RELOGIN_NEEDED, &vha->dpc_flags) &&
|
|
|
|
!test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags) &&
|
|
|
|
atomic_read(&vha->loop_state) != LOOP_DOWN) {
|
|
|
|
|
|
|
|
if (!vha->relogin_jif ||
|
|
|
|
time_after_eq(jiffies, vha->relogin_jif)) {
|
|
|
|
vha->relogin_jif = jiffies + HZ;
|
|
|
|
clear_bit(RELOGIN_NEEDED, &vha->dpc_flags);
|
|
|
|
|
|
|
|
ql_dbg(ql_dbg_dpc, vha, 0x4018,
|
|
|
|
"Relogin needed scheduled.\n");
|
2017-12-28 13:33:16 -07:00
|
|
|
qla24xx_post_relogin_work(vha);
|
2017-12-04 15:45:06 -07:00
|
|
|
}
|
2008-11-06 11:40:19 -07:00
|
|
|
}
|
2007-07-05 14:16:51 -06:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2008-12-09 17:45:39 -07:00
|
|
|
if (test_and_clear_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) {
|
2007-07-05 14:16:51 -06:00
|
|
|
if (!(test_and_set_bit(LOOP_RESYNC_ACTIVE, &vha->dpc_flags))) {
|
2011-07-14 13:00:13 -06:00
|
|
|
ql_dbg(ql_dbg_dpc, vha, 0x401a,
|
|
|
|
"Loop resync scheduled.\n");
|
2007-07-05 14:16:51 -06:00
|
|
|
qla2x00_loop_resync(vha);
|
|
|
|
clear_bit(LOOP_RESYNC_ACTIVE, &vha->dpc_flags);
|
2011-07-14 13:00:13 -06:00
|
|
|
ql_dbg(ql_dbg_dpc, vha, 0x401b,
|
|
|
|
"Loop resync end.\n");
|
2007-07-05 14:16:51 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-15 12:34:15 -06:00
|
|
|
ql_dbg(ql_dbg_dpc + ql_dbg_verbose, vha, 0x401c,
|
2011-07-14 13:00:13 -06:00
|
|
|
"Exiting %s.\n", __func__);
|
2007-07-05 14:16:51 -06:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-11-06 11:40:19 -07:00
|
|
|
qla2x00_do_dpc_all_vps(scsi_qla_host_t *vha)
|
2007-07-05 14:16:51 -06:00
|
|
|
{
|
2008-11-06 11:40:19 -07:00
|
|
|
struct qla_hw_data *ha = vha->hw;
|
|
|
|
scsi_qla_host_t *vp;
|
2010-09-03 15:57:00 -06:00
|
|
|
unsigned long flags = 0;
|
2007-07-05 14:16:51 -06:00
|
|
|
|
2008-11-06 11:40:19 -07:00
|
|
|
if (vha->vp_idx)
|
2007-07-05 14:16:51 -06:00
|
|
|
return;
|
|
|
|
if (list_empty(&ha->vp_list))
|
|
|
|
return;
|
|
|
|
|
2008-11-06 11:40:19 -07:00
|
|
|
clear_bit(VP_DPC_NEEDED, &vha->dpc_flags);
|
2007-07-05 14:16:51 -06:00
|
|
|
|
2009-08-25 12:36:19 -06:00
|
|
|
if (!(ha->current_topology & ISP_CFG_F))
|
|
|
|
return;
|
|
|
|
|
2010-09-03 15:57:00 -06:00
|
|
|
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);
|
|
|
|
|
2015-07-09 08:23:26 -06:00
|
|
|
qla2x00_do_dpc_vp(vp);
|
2010-09-03 15:57:00 -06:00
|
|
|
|
|
|
|
spin_lock_irqsave(&ha->vport_slock, flags);
|
|
|
|
atomic_dec(&vp->vref_count);
|
|
|
|
}
|
2007-07-05 14:16:51 -06:00
|
|
|
}
|
2010-09-03 15:57:00 -06:00
|
|
|
spin_unlock_irqrestore(&ha->vport_slock, flags);
|
2007-07-05 14:16:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
qla24xx_vport_create_req_sanity_check(struct fc_vport *fc_vport)
|
|
|
|
{
|
2008-11-06 11:40:19 -07:00
|
|
|
scsi_qla_host_t *base_vha = shost_priv(fc_vport->shost);
|
|
|
|
struct qla_hw_data *ha = base_vha->hw;
|
2007-07-05 14:16:51 -06:00
|
|
|
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);
|
2008-11-06 11:40:19 -07:00
|
|
|
if (!memcmp(port_name, base_vha->port_name, WWN_SIZE))
|
2008-01-17 10:02:14 -07:00
|
|
|
return VPCERR_BAD_WWN;
|
2007-07-05 14:16:51 -06:00
|
|
|
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) {
|
2011-07-14 13:00:13 -06:00
|
|
|
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);
|
2007-07-05 14:16:51 -06:00
|
|
|
return VPCERR_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
scsi_qla_host_t *
|
|
|
|
qla24xx_create_vhost(struct fc_vport *fc_vport)
|
|
|
|
{
|
2008-11-06 11:40:19 -07:00
|
|
|
scsi_qla_host_t *base_vha = shost_priv(fc_vport->shost);
|
|
|
|
struct qla_hw_data *ha = base_vha->hw;
|
2007-07-05 14:16:51 -06:00
|
|
|
scsi_qla_host_t *vha;
|
2009-03-24 10:07:56 -06:00
|
|
|
struct scsi_host_template *sht = &qla2xxx_driver_template;
|
2007-07-05 14:16:51 -06:00
|
|
|
struct Scsi_Host *host;
|
|
|
|
|
2008-11-06 11:40:19 -07:00
|
|
|
vha = qla2x00_create_host(sht, ha);
|
|
|
|
if (!vha) {
|
2011-07-14 13:00:13 -06:00
|
|
|
ql_log(ql_log_warn, vha, 0xa005,
|
|
|
|
"scsi_host_alloc() failed for vport.\n");
|
2007-07-05 14:16:51 -06:00
|
|
|
return(NULL);
|
|
|
|
}
|
|
|
|
|
2008-11-06 11:40:19 -07:00
|
|
|
host = vha->host;
|
2007-07-05 14:16:51 -06:00
|
|
|
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) {
|
2011-07-14 13:00:13 -06:00
|
|
|
ql_dbg(ql_dbg_vport, vha, 0xa006,
|
|
|
|
"Couldn't allocate vp_id.\n");
|
2008-11-06 11:40:19 -07:00
|
|
|
goto create_vhost_failed;
|
2007-07-05 14:16:51 -06:00
|
|
|
}
|
2017-12-28 13:33:25 -07:00
|
|
|
vha->mgmt_svr_loop_id = NPH_MGMT_SERVER;
|
2007-07-05 14:16:51 -06:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2017-09-03 14:23:32 -06:00
|
|
|
qla2x00_start_timer(vha, WATCH_INTERVAL);
|
2007-07-05 14:16:51 -06:00
|
|
|
|
2009-04-06 23:33:40 -06:00
|
|
|
vha->req = base_vha->req;
|
|
|
|
host->can_queue = base_vha->req->length + 128;
|
2007-07-05 14:16:51 -06:00
|
|
|
host->cmd_per_lun = 3;
|
2011-08-16 12:29:23 -06:00
|
|
|
if (IS_T10_PI_CAPABLE(ha) && ql2xenabledif)
|
2010-07-23 04:28:38 -06:00
|
|
|
host->max_cmd_len = 32;
|
|
|
|
else
|
|
|
|
host->max_cmd_len = MAX_CMDSZ;
|
2007-07-05 14:16:51 -06:00
|
|
|
host->max_channel = MAX_BUSES - 1;
|
2011-05-10 12:30:13 -06:00
|
|
|
host->max_lun = ql2xmaxlun;
|
2008-07-10 17:55:51 -06:00
|
|
|
host->unique_id = host->host_no;
|
2012-02-09 12:15:57 -07:00
|
|
|
host->max_id = ha->max_fibre_devices;
|
2007-07-05 14:16:51 -06:00
|
|
|
host->transportt = qla2xxx_transport_vport_template;
|
|
|
|
|
2011-07-14 13:00:13 -06:00
|
|
|
ql_dbg(ql_dbg_vport, vha, 0xa007,
|
|
|
|
"Detect vport hba %ld at address = %p.\n",
|
|
|
|
vha->host_no, vha);
|
2007-07-05 14:16:51 -06:00
|
|
|
|
|
|
|
vha->flags.init_done = 1;
|
|
|
|
|
2009-08-25 12:36:19 -06:00
|
|
|
mutex_lock(&ha->vport_lock);
|
|
|
|
set_bit(vha->vp_idx, ha->vp_idx_map);
|
|
|
|
ha->cur_vport_count++;
|
|
|
|
mutex_unlock(&ha->vport_lock);
|
|
|
|
|
2007-07-05 14:16:51 -06:00
|
|
|
return vha;
|
|
|
|
|
2008-11-06 11:40:19 -07:00
|
|
|
create_vhost_failed:
|
2007-07-05 14:16:51 -06:00
|
|
|
return NULL;
|
|
|
|
}
|
2008-12-09 17:45:39 -07: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);
|
|
|
|
}
|
2013-01-30 01:34:37 -07:00
|
|
|
kfree(req->outstanding_cmds);
|
2008-12-09 17:45:39 -07:00
|
|
|
kfree(req);
|
|
|
|
req = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
2016-12-12 15:40:07 -07:00
|
|
|
free_irq(rsp->msix->vector, rsp->msix->handle);
|
2008-12-09 17:45:39 -07:00
|
|
|
rsp->msix->have_irq = 0;
|
2016-12-12 15:40:07 -07:00
|
|
|
rsp->msix->in_use = 0;
|
2016-12-12 15:40:06 -07:00
|
|
|
rsp->msix->handle = NULL;
|
2008-12-09 17:45:39 -07:00
|
|
|
}
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
qla25xx_delete_req_que(struct scsi_qla_host *vha, struct req_que *req)
|
|
|
|
{
|
2017-12-04 15:45:16 -07:00
|
|
|
int ret = QLA_SUCCESS;
|
2008-12-09 17:45:39 -07:00
|
|
|
|
2017-12-04 15:45:16 -07:00
|
|
|
if (req && vha->flags.qpairs_req_created) {
|
2008-12-09 17:45:39 -07:00
|
|
|
req->options |= BIT_0;
|
2009-02-08 21:50:11 -07:00
|
|
|
ret = qla25xx_init_req_que(vha, req);
|
2017-12-04 15:45:16 -07:00
|
|
|
if (ret != QLA_SUCCESS)
|
|
|
|
return QLA_FUNCTION_FAILED;
|
2017-12-16 17:05:09 -07:00
|
|
|
|
|
|
|
qla25xx_free_req_que(vha, req);
|
2008-12-09 17:45:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2016-12-12 15:40:07 -07:00
|
|
|
int
|
2008-12-09 17:45:39 -07:00
|
|
|
qla25xx_delete_rsp_que(struct scsi_qla_host *vha, struct rsp_que *rsp)
|
|
|
|
{
|
2017-12-04 15:45:16 -07:00
|
|
|
int ret = QLA_SUCCESS;
|
2008-12-09 17:45:39 -07:00
|
|
|
|
2017-12-04 15:45:16 -07:00
|
|
|
if (rsp && vha->flags.qpairs_rsp_created) {
|
2008-12-09 17:45:39 -07:00
|
|
|
rsp->options |= BIT_0;
|
2009-02-08 21:50:11 -07:00
|
|
|
ret = qla25xx_init_rsp_que(vha, rsp);
|
2017-12-04 15:45:16 -07:00
|
|
|
if (ret != QLA_SUCCESS)
|
|
|
|
return QLA_FUNCTION_FAILED;
|
2017-12-16 17:05:09 -07:00
|
|
|
|
|
|
|
qla25xx_free_rsp_que(vha, rsp);
|
2008-12-09 17:45:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Delete all queues for a given vhost */
|
|
|
|
int
|
2009-04-06 23:33:40 -06:00
|
|
|
qla25xx_delete_queues(struct scsi_qla_host *vha)
|
2008-12-09 17:45:39 -07:00
|
|
|
{
|
|
|
|
int cnt, ret = 0;
|
|
|
|
struct req_que *req = NULL;
|
|
|
|
struct rsp_que *rsp = NULL;
|
|
|
|
struct qla_hw_data *ha = vha->hw;
|
2016-12-12 15:40:07 -07:00
|
|
|
struct qla_qpair *qpair, *tqpair;
|
2008-12-09 17:45:39 -07:00
|
|
|
|
2017-10-13 16:43:22 -06:00
|
|
|
if (ql2xmqsupport || ql2xnvmeenable) {
|
2016-12-12 15:40:07 -07:00
|
|
|
list_for_each_entry_safe(qpair, tqpair, &vha->qp_list,
|
|
|
|
qp_list_elem)
|
|
|
|
qla2xxx_delete_qpair(vha, qpair);
|
|
|
|
} else {
|
|
|
|
/* 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;
|
|
|
|
}
|
2008-12-09 17:45:39 -07:00
|
|
|
}
|
|
|
|
}
|
2009-04-06 23:33:40 -06:00
|
|
|
|
2016-12-12 15:40:07 -07:00
|
|
|
/* 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;
|
|
|
|
}
|
2008-12-09 17:45:39 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-12-12 15:40:07 -07:00
|
|
|
|
2008-12-09 17:45:39 -07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
qla25xx_create_req_que(struct qla_hw_data *ha, uint16_t options,
|
2017-06-13 21:47:17 -06:00
|
|
|
uint8_t vp_idx, uint16_t rid, int rsp_que, uint8_t qos, bool startqp)
|
2008-12-09 17:45:39 -07:00
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
struct req_que *req = NULL;
|
|
|
|
struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
|
2017-06-13 21:47:19 -06:00
|
|
|
struct scsi_qla_host *vha = pci_get_drvdata(ha->pdev);
|
2008-12-09 17:45:39 -07:00
|
|
|
uint16_t que_id = 0;
|
2014-02-26 02:15:06 -07:00
|
|
|
device_reg_t *reg;
|
2009-04-06 23:33:40 -06:00
|
|
|
uint32_t cnt;
|
2008-12-09 17:45:39 -07:00
|
|
|
|
|
|
|
req = kzalloc(sizeof(struct req_que), GFP_KERNEL);
|
|
|
|
if (req == NULL) {
|
2011-07-14 13:00:13 -06:00
|
|
|
ql_log(ql_log_fatal, base_vha, 0x00d9,
|
|
|
|
"Failed to allocate memory for request queue.\n");
|
2009-09-28 14:52:58 -06:00
|
|
|
goto failed;
|
2008-12-09 17:45:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
2011-07-14 13:00:13 -06:00
|
|
|
ql_log(ql_log_fatal, base_vha, 0x00da,
|
2012-08-22 12:20:58 -06:00
|
|
|
"Failed to allocate memory for request_ring.\n");
|
2008-12-09 17:45:39 -07:00
|
|
|
goto que_failed;
|
|
|
|
}
|
|
|
|
|
2013-01-30 01:34:37 -07:00
|
|
|
ret = qla2x00_alloc_outstanding_cmds(ha, req);
|
|
|
|
if (ret != QLA_SUCCESS)
|
|
|
|
goto que_failed;
|
|
|
|
|
2016-12-12 15:40:07 -07:00
|
|
|
mutex_lock(&ha->mq_lock);
|
2009-04-06 23:33:40 -06:00
|
|
|
que_id = find_first_zero_bit(ha->req_qid_map, ha->max_req_queues);
|
|
|
|
if (que_id >= ha->max_req_queues) {
|
2016-12-12 15:40:07 -07:00
|
|
|
mutex_unlock(&ha->mq_lock);
|
2011-07-14 13:00:13 -06:00
|
|
|
ql_log(ql_log_warn, base_vha, 0x00db,
|
|
|
|
"No resources to create additional request queue.\n");
|
2008-12-09 17:45:39 -07:00
|
|
|
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;
|
|
|
|
|
2011-07-14 13:00:13 -06:00
|
|
|
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);
|
2009-04-06 23:33:40 -06:00
|
|
|
if (rsp_que < 0)
|
|
|
|
req->rsp = NULL;
|
|
|
|
else
|
2008-12-09 17:45:39 -07:00
|
|
|
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;
|
2009-04-06 23:33:40 -06:00
|
|
|
|
2011-07-14 13:00:13 -06:00
|
|
|
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);
|
2013-01-30 01:34:37 -07:00
|
|
|
for (cnt = 1; cnt < req->num_outstanding_cmds; cnt++)
|
2009-04-06 23:33:40 -06:00
|
|
|
req->outstanding_cmds[cnt] = NULL;
|
|
|
|
req->current_outstanding_cmd = 1;
|
|
|
|
|
2008-12-09 17:45:39 -07:00
|
|
|
req->ring_ptr = req->ring;
|
|
|
|
req->ring_index = 0;
|
|
|
|
req->cnt = req->length;
|
|
|
|
req->id = que_id;
|
2009-03-24 10:07:55 -06:00
|
|
|
reg = ISP_QUE_REG(ha, que_id);
|
2013-08-26 23:37:30 -06:00
|
|
|
req->req_q_in = ®->isp25mq.req_q_in;
|
|
|
|
req->req_q_out = ®->isp25mq.req_q_out;
|
2009-01-08 16:41:08 -07:00
|
|
|
req->max_q_depth = ha->req_q_map[0]->max_q_depth;
|
2014-09-25 03:16:39 -06:00
|
|
|
req->out_ptr = (void *)(req->ring + req->length);
|
2016-12-12 15:40:07 -07:00
|
|
|
mutex_unlock(&ha->mq_lock);
|
2011-07-14 13:00:13 -06:00
|
|
|
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);
|
2008-12-09 17:45:39 -07:00
|
|
|
|
2017-06-13 21:47:17 -06:00
|
|
|
if (startqp) {
|
|
|
|
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->mq_lock);
|
|
|
|
clear_bit(que_id, ha->req_qid_map);
|
|
|
|
mutex_unlock(&ha->mq_lock);
|
|
|
|
goto que_failed;
|
|
|
|
}
|
2017-06-13 21:47:19 -06:00
|
|
|
vha->flags.qpairs_req_created = 1;
|
2008-12-09 17:45:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return req->id;
|
|
|
|
|
|
|
|
que_failed:
|
|
|
|
qla25xx_free_req_que(base_vha, req);
|
2009-09-28 14:52:58 -06:00
|
|
|
failed:
|
2008-12-09 17:45:39 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-04-06 23:33:41 -06:00
|
|
|
static void qla_do_work(struct work_struct *work)
|
|
|
|
{
|
2010-02-04 15:17:59 -07:00
|
|
|
unsigned long flags;
|
2016-12-12 15:40:07 -07:00
|
|
|
struct qla_qpair *qpair = container_of(work, struct qla_qpair, q_work);
|
2009-04-06 23:33:41 -06:00
|
|
|
struct scsi_qla_host *vha;
|
2016-12-12 15:40:07 -07:00
|
|
|
struct qla_hw_data *ha = qpair->hw;
|
2009-04-06 23:33:41 -06:00
|
|
|
|
2016-12-12 15:40:07 -07:00
|
|
|
spin_lock_irqsave(&qpair->qp_lock, flags);
|
2010-02-04 15:17:59 -07:00
|
|
|
vha = pci_get_drvdata(ha->pdev);
|
2016-12-12 15:40:07 -07:00
|
|
|
qla24xx_process_response_queue(vha, qpair->rsp);
|
|
|
|
spin_unlock_irqrestore(&qpair->qp_lock, flags);
|
2017-08-23 16:04:58 -06:00
|
|
|
|
2009-04-06 23:33:41 -06:00
|
|
|
}
|
|
|
|
|
2008-12-09 17:45:39 -07:00
|
|
|
/* create response queue */
|
|
|
|
int
|
|
|
|
qla25xx_create_rsp_que(struct qla_hw_data *ha, uint16_t options,
|
2017-06-13 21:47:17 -06:00
|
|
|
uint8_t vp_idx, uint16_t rid, struct qla_qpair *qpair, bool startqp)
|
2008-12-09 17:45:39 -07:00
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
struct rsp_que *rsp = NULL;
|
|
|
|
struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
|
2017-06-13 21:47:19 -06:00
|
|
|
struct scsi_qla_host *vha = pci_get_drvdata(ha->pdev);
|
2009-03-24 10:07:55 -06:00
|
|
|
uint16_t que_id = 0;
|
2014-02-26 02:15:06 -07:00
|
|
|
device_reg_t *reg;
|
2008-12-09 17:45:39 -07:00
|
|
|
|
|
|
|
rsp = kzalloc(sizeof(struct rsp_que), GFP_KERNEL);
|
|
|
|
if (rsp == NULL) {
|
2011-07-14 13:00:13 -06:00
|
|
|
ql_log(ql_log_warn, base_vha, 0x0066,
|
|
|
|
"Failed to allocate memory for response queue.\n");
|
2009-09-28 14:52:58 -06:00
|
|
|
goto failed;
|
2008-12-09 17:45:39 -07:00
|
|
|
}
|
|
|
|
|
2009-04-06 23:33:40 -06:00
|
|
|
rsp->length = RESPONSE_ENTRY_CNT_MQ;
|
2008-12-09 17:45:39 -07:00
|
|
|
rsp->ring = dma_alloc_coherent(&ha->pdev->dev,
|
|
|
|
(rsp->length + 1) * sizeof(response_t),
|
|
|
|
&rsp->dma, GFP_KERNEL);
|
|
|
|
if (rsp->ring == NULL) {
|
2011-07-14 13:00:13 -06:00
|
|
|
ql_log(ql_log_warn, base_vha, 0x00e1,
|
|
|
|
"Failed to allocate memory for response ring.\n");
|
2008-12-09 17:45:39 -07:00
|
|
|
goto que_failed;
|
|
|
|
}
|
|
|
|
|
2016-12-12 15:40:07 -07:00
|
|
|
mutex_lock(&ha->mq_lock);
|
2009-04-06 23:33:40 -06:00
|
|
|
que_id = find_first_zero_bit(ha->rsp_qid_map, ha->max_rsp_queues);
|
|
|
|
if (que_id >= ha->max_rsp_queues) {
|
2016-12-12 15:40:07 -07:00
|
|
|
mutex_unlock(&ha->mq_lock);
|
2011-07-14 13:00:13 -06:00
|
|
|
ql_log(ql_log_warn, base_vha, 0x00e2,
|
|
|
|
"No resources to create additional request queue.\n");
|
2008-12-09 17:45:39 -07:00
|
|
|
goto que_failed;
|
|
|
|
}
|
|
|
|
set_bit(que_id, ha->rsp_qid_map);
|
|
|
|
|
2016-12-12 15:40:07 -07:00
|
|
|
rsp->msix = qpair->msix;
|
2008-12-09 17:45:39 -07:00
|
|
|
|
|
|
|
ha->rsp_q_map[que_id] = rsp;
|
|
|
|
rsp->rid = rid;
|
|
|
|
rsp->vp_idx = vp_idx;
|
|
|
|
rsp->hw = ha;
|
2011-07-14 13:00:13 -06:00
|
|
|
ql_dbg(ql_dbg_init, base_vha, 0x00e4,
|
2016-12-12 15:40:07 -07:00
|
|
|
"rsp queue_id=%d rid=%d vp_idx=%d hw=%p.\n",
|
2011-07-14 13:00:13 -06:00
|
|
|
que_id, rsp->rid, rsp->vp_idx, rsp->hw);
|
2008-12-09 17:45:39 -07:00
|
|
|
/* Use alternate PCI bus number */
|
|
|
|
if (MSB(rsp->rid))
|
|
|
|
options |= BIT_4;
|
|
|
|
/* Use alternate PCI devfn */
|
|
|
|
if (LSB(rsp->rid))
|
|
|
|
options |= BIT_5;
|
2009-12-02 11:36:55 -07:00
|
|
|
/* Enable MSIX handshake mode on for uncapable adapters */
|
|
|
|
if (!IS_MSIX_NACK_CAPABLE(ha))
|
|
|
|
options |= BIT_6;
|
|
|
|
|
2016-12-12 15:40:07 -07:00
|
|
|
/* Set option to indicate response queue creation */
|
|
|
|
options |= BIT_1;
|
|
|
|
|
2008-12-09 17:45:39 -07:00
|
|
|
rsp->options = options;
|
|
|
|
rsp->id = que_id;
|
2009-03-24 10:07:55 -06:00
|
|
|
reg = ISP_QUE_REG(ha, que_id);
|
|
|
|
rsp->rsp_q_in = ®->isp25mq.rsp_q_in;
|
|
|
|
rsp->rsp_q_out = ®->isp25mq.rsp_q_out;
|
2014-09-25 03:16:39 -06:00
|
|
|
rsp->in_ptr = (void *)(rsp->ring + rsp->length);
|
2016-12-12 15:40:07 -07:00
|
|
|
mutex_unlock(&ha->mq_lock);
|
2011-07-14 13:00:13 -06:00
|
|
|
ql_dbg(ql_dbg_multiq, base_vha, 0xc00b,
|
2016-12-12 15:40:07 -07:00
|
|
|
"options=%x id=%d rsp_q_in=%p rsp_q_out=%p\n",
|
2011-07-14 13:00:13 -06:00
|
|
|
rsp->options, rsp->id, rsp->rsp_q_in,
|
|
|
|
rsp->rsp_q_out);
|
|
|
|
ql_dbg(ql_dbg_init, base_vha, 0x00e5,
|
2016-12-12 15:40:07 -07:00
|
|
|
"options=%x id=%d rsp_q_in=%p rsp_q_out=%p\n",
|
2011-07-14 13:00:13 -06:00
|
|
|
rsp->options, rsp->id, rsp->rsp_q_in,
|
|
|
|
rsp->rsp_q_out);
|
2008-12-09 17:45:39 -07:00
|
|
|
|
2016-12-12 15:40:07 -07:00
|
|
|
ret = qla25xx_request_irq(ha, qpair, qpair->msix,
|
|
|
|
QLA_MSIX_QPAIR_MULTIQ_RSP_Q);
|
2008-12-09 17:45:39 -07:00
|
|
|
if (ret)
|
|
|
|
goto que_failed;
|
|
|
|
|
2017-06-13 21:47:17 -06:00
|
|
|
if (startqp) {
|
|
|
|
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->mq_lock);
|
|
|
|
clear_bit(que_id, ha->rsp_qid_map);
|
|
|
|
mutex_unlock(&ha->mq_lock);
|
|
|
|
goto que_failed;
|
|
|
|
}
|
2017-06-13 21:47:19 -06:00
|
|
|
vha->flags.qpairs_rsp_created = 1;
|
2008-12-09 17:45:39 -07:00
|
|
|
}
|
2016-12-12 15:40:07 -07:00
|
|
|
rsp->req = NULL;
|
2008-12-09 17:45:39 -07:00
|
|
|
|
|
|
|
qla2x00_init_response_q_entries(rsp);
|
2016-12-12 15:40:07 -07:00
|
|
|
if (qpair->hw->wq)
|
|
|
|
INIT_WORK(&qpair->q_work, qla_do_work);
|
2008-12-09 17:45:39 -07:00
|
|
|
return rsp->id;
|
|
|
|
|
|
|
|
que_failed:
|
|
|
|
qla25xx_free_rsp_que(base_vha, rsp);
|
2009-09-28 14:52:58 -06:00
|
|
|
failed:
|
2008-12-09 17:45:39 -07:00
|
|
|
return 0;
|
|
|
|
}
|
2017-12-28 13:33:10 -07:00
|
|
|
|
|
|
|
static void qla_ctrlvp_sp_done(void *s, int res)
|
|
|
|
{
|
|
|
|
struct srb *sp = s;
|
|
|
|
|
|
|
|
complete(&sp->comp);
|
|
|
|
/* don't free sp here. Let the caller do the free */
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* qla24xx_control_vp() - Enable a virtual port for given host
|
|
|
|
* @vha: adapter block pointer
|
|
|
|
* @cmd: command type to be sent for enable virtual port
|
|
|
|
*
|
|
|
|
* Return: qla2xxx local function return status code.
|
|
|
|
*/
|
|
|
|
int qla24xx_control_vp(scsi_qla_host_t *vha, int cmd)
|
|
|
|
{
|
|
|
|
int rval = QLA_MEMORY_ALLOC_FAILED;
|
|
|
|
struct qla_hw_data *ha = vha->hw;
|
|
|
|
int vp_index = vha->vp_idx;
|
|
|
|
struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
|
|
|
|
srb_t *sp;
|
|
|
|
|
|
|
|
ql_dbg(ql_dbg_vport, vha, 0x10c1,
|
|
|
|
"Entered %s cmd %x index %d.\n", __func__, cmd, vp_index);
|
|
|
|
|
|
|
|
if (vp_index == 0 || vp_index >= ha->max_npiv_vports)
|
|
|
|
return QLA_PARAMETER_ERROR;
|
|
|
|
|
|
|
|
sp = qla2x00_get_sp(base_vha, NULL, GFP_KERNEL);
|
|
|
|
if (!sp)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
sp->type = SRB_CTRL_VP;
|
|
|
|
sp->name = "ctrl_vp";
|
|
|
|
sp->done = qla_ctrlvp_sp_done;
|
|
|
|
sp->u.iocb_cmd.timeout = qla2x00_async_iocb_timeout;
|
2018-03-20 15:36:14 -06:00
|
|
|
qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2);
|
2017-12-28 13:33:10 -07:00
|
|
|
sp->u.iocb_cmd.u.ctrlvp.cmd = cmd;
|
|
|
|
sp->u.iocb_cmd.u.ctrlvp.vp_index = vp_index;
|
|
|
|
|
|
|
|
rval = qla2x00_start_sp(sp);
|
|
|
|
if (rval != QLA_SUCCESS) {
|
|
|
|
ql_dbg(ql_dbg_async, vha, 0xffff,
|
|
|
|
"%s: %s Failed submission. %x.\n",
|
|
|
|
__func__, sp->name, rval);
|
|
|
|
goto done_free_sp;
|
|
|
|
}
|
|
|
|
|
|
|
|
ql_dbg(ql_dbg_vport, vha, 0x113f, "%s hndl %x submitted\n",
|
|
|
|
sp->name, sp->handle);
|
|
|
|
|
|
|
|
wait_for_completion(&sp->comp);
|
|
|
|
rval = sp->rc;
|
|
|
|
switch (rval) {
|
|
|
|
case QLA_FUNCTION_TIMEOUT:
|
|
|
|
ql_dbg(ql_dbg_vport, vha, 0xffff, "%s: %s Timeout. %x.\n",
|
|
|
|
__func__, sp->name, rval);
|
|
|
|
break;
|
|
|
|
case QLA_SUCCESS:
|
|
|
|
ql_dbg(ql_dbg_vport, vha, 0xffff, "%s: %s done.\n",
|
|
|
|
__func__, sp->name);
|
|
|
|
goto done_free_sp;
|
|
|
|
default:
|
|
|
|
ql_dbg(ql_dbg_vport, vha, 0xffff, "%s: %s Failed. %x.\n",
|
|
|
|
__func__, sp->name, rval);
|
|
|
|
goto done_free_sp;
|
|
|
|
}
|
|
|
|
done:
|
|
|
|
return rval;
|
|
|
|
|
|
|
|
done_free_sp:
|
|
|
|
sp->free(sp);
|
|
|
|
return rval;
|
|
|
|
}
|