2006-09-19 19:28:00 +02:00
|
|
|
/*
|
|
|
|
* QLogic iSCSI HBA Driver
|
2013-08-16 13:03:04 +02:00
|
|
|
* Copyright (c) 2003-2013 QLogic Corporation
|
2006-09-19 19:28:00 +02:00
|
|
|
*
|
|
|
|
* See LICENSE.qla4xxx for copyright and licensing details.
|
|
|
|
*/
|
|
|
|
#include <linux/moduleparam.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 09:04:11 +01:00
|
|
|
#include <linux/slab.h>
|
2011-07-25 20:48:55 +02:00
|
|
|
#include <linux/blkdev.h>
|
|
|
|
#include <linux/iscsi_boot_sysfs.h>
|
2011-12-02 04:38:41 +01:00
|
|
|
#include <linux/inet.h>
|
2006-09-19 19:28:00 +02:00
|
|
|
|
|
|
|
#include <scsi/scsi_tcq.h>
|
|
|
|
#include <scsi/scsicam.h>
|
|
|
|
|
|
|
|
#include "ql4_def.h"
|
2007-05-24 03:03:32 +02:00
|
|
|
#include "ql4_version.h"
|
|
|
|
#include "ql4_glbl.h"
|
|
|
|
#include "ql4_dbg.h"
|
|
|
|
#include "ql4_inline.h"
|
2012-08-22 13:55:08 +02:00
|
|
|
#include "ql4_83xx.h"
|
2006-09-19 19:28:00 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Driver version
|
|
|
|
*/
|
2007-04-26 09:35:16 +02:00
|
|
|
static char qla4xxx_version_str[40];
|
2006-09-19 19:28:00 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* SRB allocation cache
|
|
|
|
*/
|
2006-12-07 05:33:20 +01:00
|
|
|
static struct kmem_cache *srb_cachep;
|
2006-09-19 19:28:00 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Module parameter information and variables
|
|
|
|
*/
|
2012-02-27 12:08:56 +01:00
|
|
|
static int ql4xdisablesysfsboot = 1;
|
2011-12-02 04:38:41 +01:00
|
|
|
module_param(ql4xdisablesysfsboot, int, S_IRUGO | S_IWUSR);
|
|
|
|
MODULE_PARM_DESC(ql4xdisablesysfsboot,
|
2012-01-11 11:44:20 +01:00
|
|
|
" Set to disable exporting boot targets to sysfs.\n"
|
|
|
|
"\t\t 0 - Export boot targets\n"
|
|
|
|
"\t\t 1 - Do not export boot targets (Default)");
|
2011-12-02 04:38:41 +01:00
|
|
|
|
2012-02-27 12:08:57 +01:00
|
|
|
int ql4xdontresethba;
|
2010-07-28 12:23:44 +02:00
|
|
|
module_param(ql4xdontresethba, int, S_IRUGO | S_IWUSR);
|
2006-09-19 19:28:00 +02:00
|
|
|
MODULE_PARM_DESC(ql4xdontresethba,
|
2012-01-11 11:44:20 +01:00
|
|
|
" Don't reset the HBA for driver recovery.\n"
|
|
|
|
"\t\t 0 - It will reset HBA (Default)\n"
|
|
|
|
"\t\t 1 - It will NOT reset HBA");
|
2006-09-19 19:28:00 +02:00
|
|
|
|
2012-01-11 11:44:20 +01:00
|
|
|
int ql4xextended_error_logging;
|
2010-07-28 12:23:44 +02:00
|
|
|
module_param(ql4xextended_error_logging, int, S_IRUGO | S_IWUSR);
|
2006-10-06 18:54:59 +02:00
|
|
|
MODULE_PARM_DESC(ql4xextended_error_logging,
|
2012-01-11 11:44:20 +01:00
|
|
|
" Option to enable extended error logging.\n"
|
|
|
|
"\t\t 0 - no logging (Default)\n"
|
|
|
|
"\t\t 2 - debug logging");
|
2006-09-19 19:28:00 +02:00
|
|
|
|
2010-07-28 12:23:44 +02:00
|
|
|
int ql4xenablemsix = 1;
|
|
|
|
module_param(ql4xenablemsix, int, S_IRUGO|S_IWUSR);
|
|
|
|
MODULE_PARM_DESC(ql4xenablemsix,
|
2012-01-11 11:44:20 +01:00
|
|
|
" Set to enable MSI or MSI-X interrupt mechanism.\n"
|
|
|
|
"\t\t 0 = enable INTx interrupt mechanism.\n"
|
|
|
|
"\t\t 1 = enable MSI-X interrupt mechanism (Default).\n"
|
|
|
|
"\t\t 2 = enable MSI interrupt mechanism.");
|
2007-01-22 21:26:11 +01:00
|
|
|
|
2008-07-12 02:50:33 +02:00
|
|
|
#define QL4_DEF_QDEPTH 32
|
2011-03-21 11:34:31 +01:00
|
|
|
static int ql4xmaxqdepth = QL4_DEF_QDEPTH;
|
|
|
|
module_param(ql4xmaxqdepth, int, S_IRUGO | S_IWUSR);
|
|
|
|
MODULE_PARM_DESC(ql4xmaxqdepth,
|
2012-01-11 11:44:20 +01:00
|
|
|
" Maximum queue depth to report for target devices.\n"
|
|
|
|
"\t\t Default: 32.");
|
2008-07-12 02:50:33 +02:00
|
|
|
|
2012-04-30 13:12:19 +02:00
|
|
|
static int ql4xqfulltracking = 1;
|
|
|
|
module_param(ql4xqfulltracking, int, S_IRUGO | S_IWUSR);
|
|
|
|
MODULE_PARM_DESC(ql4xqfulltracking,
|
|
|
|
" Enable or disable dynamic tracking and adjustment of\n"
|
|
|
|
"\t\t scsi device queue depth.\n"
|
|
|
|
"\t\t 0 - Disable.\n"
|
|
|
|
"\t\t 1 - Enable. (Default)");
|
|
|
|
|
2011-03-21 11:34:32 +01:00
|
|
|
static int ql4xsess_recovery_tmo = QL4_SESS_RECOVERY_TMO;
|
|
|
|
module_param(ql4xsess_recovery_tmo, int, S_IRUGO);
|
|
|
|
MODULE_PARM_DESC(ql4xsess_recovery_tmo,
|
2012-02-27 12:08:57 +01:00
|
|
|
" Target Session Recovery Timeout.\n"
|
2012-01-11 11:44:20 +01:00
|
|
|
"\t\t Default: 120 sec.");
|
2011-03-21 11:34:32 +01:00
|
|
|
|
2014-02-25 04:06:57 +01:00
|
|
|
int ql4xmdcapmask = 0;
|
2012-05-18 10:41:44 +02:00
|
|
|
module_param(ql4xmdcapmask, int, S_IRUGO);
|
|
|
|
MODULE_PARM_DESC(ql4xmdcapmask,
|
|
|
|
" Set the Minidump driver capture mask level.\n"
|
2014-02-25 04:06:57 +01:00
|
|
|
"\t\t Default is 0 (firmware default capture mask)\n"
|
2014-02-25 04:06:58 +01:00
|
|
|
"\t\t Can be set to 0x3, 0x7, 0xF, 0x1F, 0x3F, 0x7F, 0xFF");
|
2012-05-18 10:41:44 +02:00
|
|
|
|
|
|
|
int ql4xenablemd = 1;
|
|
|
|
module_param(ql4xenablemd, int, S_IRUGO | S_IWUSR);
|
|
|
|
MODULE_PARM_DESC(ql4xenablemd,
|
|
|
|
" Set to enable minidump.\n"
|
|
|
|
"\t\t 0 - disable minidump\n"
|
|
|
|
"\t\t 1 - enable minidump (Default)");
|
|
|
|
|
2011-07-25 20:48:53 +02:00
|
|
|
static int qla4xxx_wait_for_hba_online(struct scsi_qla_host *ha);
|
2006-09-19 19:28:00 +02:00
|
|
|
/*
|
|
|
|
* SCSI host template entry points
|
|
|
|
*/
|
2007-04-26 09:35:16 +02:00
|
|
|
static void qla4xxx_config_dma_addressing(struct scsi_qla_host *ha);
|
2006-09-19 19:28:00 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* iSCSI template entry points
|
|
|
|
*/
|
2012-02-27 12:08:54 +01:00
|
|
|
static int qla4xxx_session_get_param(struct iscsi_cls_session *cls_sess,
|
|
|
|
enum iscsi_param param, char *buf);
|
2006-09-19 19:28:00 +02:00
|
|
|
static int qla4xxx_conn_get_param(struct iscsi_cls_conn *conn,
|
|
|
|
enum iscsi_param param, char *buf);
|
2007-05-30 19:57:09 +02:00
|
|
|
static int qla4xxx_host_get_param(struct Scsi_Host *shost,
|
|
|
|
enum iscsi_host_param param, char *buf);
|
2011-10-06 10:56:59 +02:00
|
|
|
static int qla4xxx_iface_set_param(struct Scsi_Host *shost, void *data,
|
|
|
|
uint32_t len);
|
2011-07-25 20:48:41 +02:00
|
|
|
static int qla4xxx_get_iface_param(struct iscsi_iface *iface,
|
|
|
|
enum iscsi_param_type param_type,
|
|
|
|
int param, char *buf);
|
2009-07-15 22:02:59 +02:00
|
|
|
static enum blk_eh_timer_return qla4xxx_eh_cmd_timed_out(struct scsi_cmnd *sc);
|
2011-07-25 20:48:53 +02:00
|
|
|
static struct iscsi_endpoint *qla4xxx_ep_connect(struct Scsi_Host *shost,
|
|
|
|
struct sockaddr *dst_addr,
|
|
|
|
int non_blocking);
|
|
|
|
static int qla4xxx_ep_poll(struct iscsi_endpoint *ep, int timeout_ms);
|
|
|
|
static void qla4xxx_ep_disconnect(struct iscsi_endpoint *ep);
|
|
|
|
static int qla4xxx_get_ep_param(struct iscsi_endpoint *ep,
|
|
|
|
enum iscsi_param param, char *buf);
|
|
|
|
static int qla4xxx_conn_start(struct iscsi_cls_conn *conn);
|
|
|
|
static struct iscsi_cls_conn *
|
|
|
|
qla4xxx_conn_create(struct iscsi_cls_session *cls_sess, uint32_t conn_idx);
|
|
|
|
static int qla4xxx_conn_bind(struct iscsi_cls_session *cls_session,
|
|
|
|
struct iscsi_cls_conn *cls_conn,
|
|
|
|
uint64_t transport_fd, int is_leading);
|
|
|
|
static void qla4xxx_conn_destroy(struct iscsi_cls_conn *conn);
|
|
|
|
static struct iscsi_cls_session *
|
|
|
|
qla4xxx_session_create(struct iscsi_endpoint *ep, uint16_t cmds_max,
|
|
|
|
uint16_t qdepth, uint32_t initial_cmdsn);
|
|
|
|
static void qla4xxx_session_destroy(struct iscsi_cls_session *sess);
|
|
|
|
static void qla4xxx_task_work(struct work_struct *wdata);
|
|
|
|
static int qla4xxx_alloc_pdu(struct iscsi_task *, uint8_t);
|
|
|
|
static int qla4xxx_task_xmit(struct iscsi_task *);
|
|
|
|
static void qla4xxx_task_cleanup(struct iscsi_task *);
|
|
|
|
static void qla4xxx_fail_session(struct iscsi_cls_session *cls_session);
|
|
|
|
static void qla4xxx_conn_get_stats(struct iscsi_cls_conn *cls_conn,
|
|
|
|
struct iscsi_stats *stats);
|
2012-02-13 14:00:49 +01:00
|
|
|
static int qla4xxx_send_ping(struct Scsi_Host *shost, uint32_t iface_num,
|
|
|
|
uint32_t iface_type, uint32_t payload_size,
|
|
|
|
uint32_t pid, struct sockaddr *dst_addr);
|
2012-02-27 12:08:52 +01:00
|
|
|
static int qla4xxx_get_chap_list(struct Scsi_Host *shost, uint16_t chap_tbl_idx,
|
|
|
|
uint32_t *num_entries, char *buf);
|
|
|
|
static int qla4xxx_delete_chap(struct Scsi_Host *shost, uint16_t chap_tbl_idx);
|
2013-09-17 13:54:49 +02:00
|
|
|
static int qla4xxx_set_chap_entry(struct Scsi_Host *shost, void *data,
|
|
|
|
int len);
|
2013-11-22 11:28:19 +01:00
|
|
|
static int qla4xxx_get_host_stats(struct Scsi_Host *shost, char *buf, int len);
|
2012-02-13 14:00:49 +01:00
|
|
|
|
2006-09-19 19:28:00 +02:00
|
|
|
/*
|
|
|
|
* SCSI host template entry points
|
|
|
|
*/
|
2010-11-16 08:10:29 +01:00
|
|
|
static int qla4xxx_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *cmd);
|
2010-04-28 08:12:24 +02:00
|
|
|
static int qla4xxx_eh_abort(struct scsi_cmnd *cmd);
|
2006-09-19 19:28:00 +02:00
|
|
|
static int qla4xxx_eh_device_reset(struct scsi_cmnd *cmd);
|
2008-03-01 01:25:20 +01:00
|
|
|
static int qla4xxx_eh_target_reset(struct scsi_cmnd *cmd);
|
2006-09-19 19:28:00 +02:00
|
|
|
static int qla4xxx_eh_host_reset(struct scsi_cmnd *cmd);
|
|
|
|
static int qla4xxx_slave_alloc(struct scsi_device *device);
|
2012-08-22 13:55:01 +02:00
|
|
|
static umode_t qla4_attr_is_visible(int param_type, int param);
|
2011-08-12 11:51:29 +02:00
|
|
|
static int qla4xxx_host_reset(struct Scsi_Host *shost, int reset_type);
|
2006-09-19 19:28:00 +02:00
|
|
|
|
2013-03-22 12:41:31 +01:00
|
|
|
/*
|
|
|
|
* iSCSI Flash DDB sysfs entry points
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
qla4xxx_sysfs_ddb_set_param(struct iscsi_bus_flash_session *fnode_sess,
|
|
|
|
struct iscsi_bus_flash_conn *fnode_conn,
|
|
|
|
void *data, int len);
|
|
|
|
static int
|
|
|
|
qla4xxx_sysfs_ddb_get_param(struct iscsi_bus_flash_session *fnode_sess,
|
|
|
|
int param, char *buf);
|
|
|
|
static int qla4xxx_sysfs_ddb_add(struct Scsi_Host *shost, const char *buf,
|
|
|
|
int len);
|
|
|
|
static int
|
|
|
|
qla4xxx_sysfs_ddb_delete(struct iscsi_bus_flash_session *fnode_sess);
|
|
|
|
static int qla4xxx_sysfs_ddb_login(struct iscsi_bus_flash_session *fnode_sess,
|
|
|
|
struct iscsi_bus_flash_conn *fnode_conn);
|
|
|
|
static int qla4xxx_sysfs_ddb_logout(struct iscsi_bus_flash_session *fnode_sess,
|
|
|
|
struct iscsi_bus_flash_conn *fnode_conn);
|
|
|
|
static int qla4xxx_sysfs_ddb_logout_sid(struct iscsi_cls_session *cls_sess);
|
|
|
|
|
2010-07-28 12:23:44 +02:00
|
|
|
static struct qla4_8xxx_legacy_intr_set legacy_intr[] =
|
|
|
|
QLA82XX_LEGACY_INTR_CONFIG;
|
|
|
|
|
2006-09-19 19:28:00 +02:00
|
|
|
static struct scsi_host_template qla4xxx_driver_template = {
|
|
|
|
.module = THIS_MODULE,
|
|
|
|
.name = DRIVER_NAME,
|
|
|
|
.proc_name = DRIVER_NAME,
|
|
|
|
.queuecommand = qla4xxx_queuecommand,
|
|
|
|
|
2010-04-28 08:12:24 +02:00
|
|
|
.eh_abort_handler = qla4xxx_eh_abort,
|
2006-09-19 19:28:00 +02:00
|
|
|
.eh_device_reset_handler = qla4xxx_eh_device_reset,
|
2008-03-01 01:25:20 +01:00
|
|
|
.eh_target_reset_handler = qla4xxx_eh_target_reset,
|
2006-09-19 19:28:00 +02:00
|
|
|
.eh_host_reset_handler = qla4xxx_eh_host_reset,
|
2009-07-15 22:02:59 +02:00
|
|
|
.eh_timed_out = qla4xxx_eh_cmd_timed_out,
|
2006-09-19 19:28:00 +02:00
|
|
|
|
|
|
|
.slave_alloc = qla4xxx_slave_alloc,
|
2014-11-13 15:08:42 +01:00
|
|
|
.change_queue_depth = scsi_change_queue_depth,
|
2006-09-19 19:28:00 +02:00
|
|
|
|
|
|
|
.this_id = -1,
|
|
|
|
.cmd_per_lun = 3,
|
|
|
|
.use_clustering = ENABLE_CLUSTERING,
|
|
|
|
.sg_tablesize = SG_ALL,
|
|
|
|
|
|
|
|
.max_sectors = 0xFFFF,
|
2011-05-18 08:17:11 +02:00
|
|
|
.shost_attrs = qla4xxx_host_attrs,
|
2011-08-12 11:51:29 +02:00
|
|
|
.host_reset = qla4xxx_host_reset,
|
2011-07-25 20:48:51 +02:00
|
|
|
.vendor_id = SCSI_NL_VID_TYPE_PCI | PCI_VENDOR_ID_QLOGIC,
|
2006-09-19 19:28:00 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct iscsi_transport qla4xxx_iscsi_transport = {
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.name = DRIVER_NAME,
|
2011-07-25 20:48:53 +02:00
|
|
|
.caps = CAP_TEXT_NEGO |
|
|
|
|
CAP_DATA_PATH_OFFLOAD | CAP_HDRDGST |
|
|
|
|
CAP_DATADGST | CAP_LOGIN_OFFLOAD |
|
|
|
|
CAP_MULTI_R2T,
|
2012-08-22 13:55:01 +02:00
|
|
|
.attr_is_visible = qla4_attr_is_visible,
|
2011-07-25 20:48:53 +02:00
|
|
|
.create_session = qla4xxx_session_create,
|
|
|
|
.destroy_session = qla4xxx_session_destroy,
|
|
|
|
.start_conn = qla4xxx_conn_start,
|
|
|
|
.create_conn = qla4xxx_conn_create,
|
|
|
|
.bind_conn = qla4xxx_conn_bind,
|
|
|
|
.stop_conn = iscsi_conn_stop,
|
|
|
|
.destroy_conn = qla4xxx_conn_destroy,
|
|
|
|
.set_param = iscsi_set_param,
|
2006-09-19 19:28:00 +02:00
|
|
|
.get_conn_param = qla4xxx_conn_get_param,
|
2012-02-27 12:08:54 +01:00
|
|
|
.get_session_param = qla4xxx_session_get_param,
|
2011-07-25 20:48:53 +02:00
|
|
|
.get_ep_param = qla4xxx_get_ep_param,
|
|
|
|
.ep_connect = qla4xxx_ep_connect,
|
|
|
|
.ep_poll = qla4xxx_ep_poll,
|
|
|
|
.ep_disconnect = qla4xxx_ep_disconnect,
|
|
|
|
.get_stats = qla4xxx_conn_get_stats,
|
|
|
|
.send_pdu = iscsi_conn_send_pdu,
|
|
|
|
.xmit_task = qla4xxx_task_xmit,
|
|
|
|
.cleanup_task = qla4xxx_task_cleanup,
|
|
|
|
.alloc_pdu = qla4xxx_alloc_pdu,
|
|
|
|
|
2007-05-30 19:57:09 +02:00
|
|
|
.get_host_param = qla4xxx_host_get_param,
|
2011-07-25 20:48:38 +02:00
|
|
|
.set_iface_param = qla4xxx_iface_set_param,
|
2011-07-25 20:48:41 +02:00
|
|
|
.get_iface_param = qla4xxx_get_iface_param,
|
2011-07-25 20:48:51 +02:00
|
|
|
.bsg_request = qla4xxx_bsg_request,
|
2012-02-13 14:00:49 +01:00
|
|
|
.send_ping = qla4xxx_send_ping,
|
2012-02-27 12:08:52 +01:00
|
|
|
.get_chap = qla4xxx_get_chap_list,
|
|
|
|
.delete_chap = qla4xxx_delete_chap,
|
2013-09-17 13:54:49 +02:00
|
|
|
.set_chap = qla4xxx_set_chap_entry,
|
2013-03-22 12:41:31 +01:00
|
|
|
.get_flashnode_param = qla4xxx_sysfs_ddb_get_param,
|
|
|
|
.set_flashnode_param = qla4xxx_sysfs_ddb_set_param,
|
|
|
|
.new_flashnode = qla4xxx_sysfs_ddb_add,
|
|
|
|
.del_flashnode = qla4xxx_sysfs_ddb_delete,
|
|
|
|
.login_flashnode = qla4xxx_sysfs_ddb_login,
|
|
|
|
.logout_flashnode = qla4xxx_sysfs_ddb_logout,
|
|
|
|
.logout_flashnode_sid = qla4xxx_sysfs_ddb_logout_sid,
|
2013-11-22 11:28:19 +01:00
|
|
|
.get_host_stats = qla4xxx_get_host_stats,
|
2006-09-19 19:28:00 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct scsi_transport_template *qla4xxx_scsi_transport;
|
|
|
|
|
2012-02-13 14:00:49 +01:00
|
|
|
static int qla4xxx_send_ping(struct Scsi_Host *shost, uint32_t iface_num,
|
|
|
|
uint32_t iface_type, uint32_t payload_size,
|
|
|
|
uint32_t pid, struct sockaddr *dst_addr)
|
|
|
|
{
|
|
|
|
struct scsi_qla_host *ha = to_qla_host(shost);
|
|
|
|
struct sockaddr_in *addr;
|
|
|
|
struct sockaddr_in6 *addr6;
|
|
|
|
uint32_t options = 0;
|
|
|
|
uint8_t ipaddr[IPv6_ADDR_LEN];
|
|
|
|
int rval;
|
|
|
|
|
|
|
|
memset(ipaddr, 0, IPv6_ADDR_LEN);
|
|
|
|
/* IPv4 to IPv4 */
|
|
|
|
if ((iface_type == ISCSI_IFACE_TYPE_IPV4) &&
|
|
|
|
(dst_addr->sa_family == AF_INET)) {
|
|
|
|
addr = (struct sockaddr_in *)dst_addr;
|
|
|
|
memcpy(ipaddr, &addr->sin_addr.s_addr, IP_ADDR_LEN);
|
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha, "%s: IPv4 Ping src: %pI4 "
|
|
|
|
"dest: %pI4\n", __func__,
|
|
|
|
&ha->ip_config.ip_address, ipaddr));
|
|
|
|
rval = qla4xxx_ping_iocb(ha, options, payload_size, pid,
|
|
|
|
ipaddr);
|
|
|
|
if (rval)
|
|
|
|
rval = -EINVAL;
|
|
|
|
} else if ((iface_type == ISCSI_IFACE_TYPE_IPV6) &&
|
|
|
|
(dst_addr->sa_family == AF_INET6)) {
|
|
|
|
/* IPv6 to IPv6 */
|
|
|
|
addr6 = (struct sockaddr_in6 *)dst_addr;
|
|
|
|
memcpy(ipaddr, &addr6->sin6_addr.in6_u.u6_addr8, IPv6_ADDR_LEN);
|
|
|
|
|
|
|
|
options |= PING_IPV6_PROTOCOL_ENABLE;
|
|
|
|
|
|
|
|
/* Ping using LinkLocal address */
|
|
|
|
if ((iface_num == 0) || (iface_num == 1)) {
|
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha, "%s: LinkLocal Ping "
|
|
|
|
"src: %pI6 dest: %pI6\n", __func__,
|
|
|
|
&ha->ip_config.ipv6_link_local_addr,
|
|
|
|
ipaddr));
|
|
|
|
options |= PING_IPV6_LINKLOCAL_ADDR;
|
|
|
|
rval = qla4xxx_ping_iocb(ha, options, payload_size,
|
|
|
|
pid, ipaddr);
|
|
|
|
} else {
|
|
|
|
ql4_printk(KERN_WARNING, ha, "%s: iface num = %d "
|
|
|
|
"not supported\n", __func__, iface_num);
|
|
|
|
rval = -ENOSYS;
|
|
|
|
goto exit_send_ping;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If ping using LinkLocal address fails, try ping using
|
|
|
|
* IPv6 address
|
|
|
|
*/
|
|
|
|
if (rval != QLA_SUCCESS) {
|
|
|
|
options &= ~PING_IPV6_LINKLOCAL_ADDR;
|
|
|
|
if (iface_num == 0) {
|
|
|
|
options |= PING_IPV6_ADDR0;
|
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha, "%s: IPv6 "
|
|
|
|
"Ping src: %pI6 "
|
|
|
|
"dest: %pI6\n", __func__,
|
|
|
|
&ha->ip_config.ipv6_addr0,
|
|
|
|
ipaddr));
|
|
|
|
} else if (iface_num == 1) {
|
|
|
|
options |= PING_IPV6_ADDR1;
|
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha, "%s: IPv6 "
|
|
|
|
"Ping src: %pI6 "
|
|
|
|
"dest: %pI6\n", __func__,
|
|
|
|
&ha->ip_config.ipv6_addr1,
|
|
|
|
ipaddr));
|
|
|
|
}
|
|
|
|
rval = qla4xxx_ping_iocb(ha, options, payload_size,
|
|
|
|
pid, ipaddr);
|
|
|
|
if (rval)
|
|
|
|
rval = -EINVAL;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
rval = -ENOSYS;
|
|
|
|
exit_send_ping:
|
|
|
|
return rval;
|
|
|
|
}
|
|
|
|
|
2012-08-22 13:55:01 +02:00
|
|
|
static umode_t qla4_attr_is_visible(int param_type, int param)
|
2011-07-25 20:48:42 +02:00
|
|
|
{
|
|
|
|
switch (param_type) {
|
2011-07-25 20:48:45 +02:00
|
|
|
case ISCSI_HOST_PARAM:
|
|
|
|
switch (param) {
|
|
|
|
case ISCSI_HOST_PARAM_HWADDRESS:
|
|
|
|
case ISCSI_HOST_PARAM_IPADDRESS:
|
|
|
|
case ISCSI_HOST_PARAM_INITIATOR_NAME:
|
2012-01-19 12:06:56 +01:00
|
|
|
case ISCSI_HOST_PARAM_PORT_STATE:
|
|
|
|
case ISCSI_HOST_PARAM_PORT_SPEED:
|
2011-07-25 20:48:45 +02:00
|
|
|
return S_IRUGO;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
2011-07-25 20:48:42 +02:00
|
|
|
case ISCSI_PARAM:
|
|
|
|
switch (param) {
|
2011-10-18 05:42:13 +02:00
|
|
|
case ISCSI_PARAM_PERSISTENT_ADDRESS:
|
|
|
|
case ISCSI_PARAM_PERSISTENT_PORT:
|
2011-07-25 20:48:42 +02:00
|
|
|
case ISCSI_PARAM_CONN_ADDRESS:
|
|
|
|
case ISCSI_PARAM_CONN_PORT:
|
2011-07-25 20:48:43 +02:00
|
|
|
case ISCSI_PARAM_TARGET_NAME:
|
|
|
|
case ISCSI_PARAM_TPGT:
|
|
|
|
case ISCSI_PARAM_TARGET_ALIAS:
|
2011-07-25 20:48:53 +02:00
|
|
|
case ISCSI_PARAM_MAX_BURST:
|
|
|
|
case ISCSI_PARAM_MAX_R2T:
|
|
|
|
case ISCSI_PARAM_FIRST_BURST:
|
|
|
|
case ISCSI_PARAM_MAX_RECV_DLENGTH:
|
|
|
|
case ISCSI_PARAM_MAX_XMIT_DLENGTH:
|
2011-08-15 03:42:56 +02:00
|
|
|
case ISCSI_PARAM_IFACE_NAME:
|
2012-02-27 12:08:54 +01:00
|
|
|
case ISCSI_PARAM_CHAP_OUT_IDX:
|
|
|
|
case ISCSI_PARAM_CHAP_IN_IDX:
|
|
|
|
case ISCSI_PARAM_USERNAME:
|
|
|
|
case ISCSI_PARAM_PASSWORD:
|
|
|
|
case ISCSI_PARAM_USERNAME_IN:
|
|
|
|
case ISCSI_PARAM_PASSWORD_IN:
|
2013-07-01 11:54:13 +02:00
|
|
|
case ISCSI_PARAM_AUTO_SND_TGT_DISABLE:
|
|
|
|
case ISCSI_PARAM_DISCOVERY_SESS:
|
|
|
|
case ISCSI_PARAM_PORTAL_TYPE:
|
|
|
|
case ISCSI_PARAM_CHAP_AUTH_EN:
|
|
|
|
case ISCSI_PARAM_DISCOVERY_LOGOUT_EN:
|
|
|
|
case ISCSI_PARAM_BIDI_CHAP_EN:
|
|
|
|
case ISCSI_PARAM_DISCOVERY_AUTH_OPTIONAL:
|
|
|
|
case ISCSI_PARAM_DEF_TIME2WAIT:
|
|
|
|
case ISCSI_PARAM_DEF_TIME2RETAIN:
|
|
|
|
case ISCSI_PARAM_HDRDGST_EN:
|
|
|
|
case ISCSI_PARAM_DATADGST_EN:
|
|
|
|
case ISCSI_PARAM_INITIAL_R2T_EN:
|
|
|
|
case ISCSI_PARAM_IMM_DATA_EN:
|
|
|
|
case ISCSI_PARAM_PDU_INORDER_EN:
|
|
|
|
case ISCSI_PARAM_DATASEQ_INORDER_EN:
|
|
|
|
case ISCSI_PARAM_MAX_SEGMENT_SIZE:
|
|
|
|
case ISCSI_PARAM_TCP_TIMESTAMP_STAT:
|
|
|
|
case ISCSI_PARAM_TCP_WSF_DISABLE:
|
|
|
|
case ISCSI_PARAM_TCP_NAGLE_DISABLE:
|
|
|
|
case ISCSI_PARAM_TCP_TIMER_SCALE:
|
|
|
|
case ISCSI_PARAM_TCP_TIMESTAMP_EN:
|
|
|
|
case ISCSI_PARAM_TCP_XMIT_WSF:
|
|
|
|
case ISCSI_PARAM_TCP_RECV_WSF:
|
|
|
|
case ISCSI_PARAM_IP_FRAGMENT_DISABLE:
|
|
|
|
case ISCSI_PARAM_IPV4_TOS:
|
|
|
|
case ISCSI_PARAM_IPV6_TC:
|
|
|
|
case ISCSI_PARAM_IPV6_FLOW_LABEL:
|
|
|
|
case ISCSI_PARAM_IS_FW_ASSIGNED_IPV6:
|
|
|
|
case ISCSI_PARAM_KEEPALIVE_TMO:
|
|
|
|
case ISCSI_PARAM_LOCAL_PORT:
|
|
|
|
case ISCSI_PARAM_ISID:
|
|
|
|
case ISCSI_PARAM_TSID:
|
|
|
|
case ISCSI_PARAM_DEF_TASKMGMT_TMO:
|
|
|
|
case ISCSI_PARAM_ERL:
|
|
|
|
case ISCSI_PARAM_STATSN:
|
|
|
|
case ISCSI_PARAM_EXP_STATSN:
|
|
|
|
case ISCSI_PARAM_DISCOVERY_PARENT_IDX:
|
|
|
|
case ISCSI_PARAM_DISCOVERY_PARENT_TYPE:
|
2013-11-22 11:28:22 +01:00
|
|
|
case ISCSI_PARAM_LOCAL_IPADDR:
|
2011-07-25 20:48:42 +02:00
|
|
|
return S_IRUGO;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
2011-07-25 20:48:44 +02:00
|
|
|
case ISCSI_NET_PARAM:
|
|
|
|
switch (param) {
|
|
|
|
case ISCSI_NET_PARAM_IPV4_ADDR:
|
|
|
|
case ISCSI_NET_PARAM_IPV4_SUBNET:
|
|
|
|
case ISCSI_NET_PARAM_IPV4_GW:
|
|
|
|
case ISCSI_NET_PARAM_IPV4_BOOTPROTO:
|
|
|
|
case ISCSI_NET_PARAM_IFACE_ENABLE:
|
|
|
|
case ISCSI_NET_PARAM_IPV6_LINKLOCAL:
|
|
|
|
case ISCSI_NET_PARAM_IPV6_ADDR:
|
|
|
|
case ISCSI_NET_PARAM_IPV6_ROUTER:
|
|
|
|
case ISCSI_NET_PARAM_IPV6_ADDR_AUTOCFG:
|
|
|
|
case ISCSI_NET_PARAM_IPV6_LINKLOCAL_AUTOCFG:
|
2011-07-25 20:48:49 +02:00
|
|
|
case ISCSI_NET_PARAM_VLAN_ID:
|
|
|
|
case ISCSI_NET_PARAM_VLAN_PRIORITY:
|
|
|
|
case ISCSI_NET_PARAM_VLAN_ENABLED:
|
2011-08-01 12:26:13 +02:00
|
|
|
case ISCSI_NET_PARAM_MTU:
|
2011-08-01 12:26:19 +02:00
|
|
|
case ISCSI_NET_PARAM_PORT:
|
2013-10-18 15:01:42 +02:00
|
|
|
case ISCSI_NET_PARAM_IPADDR_STATE:
|
|
|
|
case ISCSI_NET_PARAM_IPV6_LINKLOCAL_STATE:
|
|
|
|
case ISCSI_NET_PARAM_IPV6_ROUTER_STATE:
|
|
|
|
case ISCSI_NET_PARAM_DELAYED_ACK_EN:
|
|
|
|
case ISCSI_NET_PARAM_TCP_NAGLE_DISABLE:
|
|
|
|
case ISCSI_NET_PARAM_TCP_WSF_DISABLE:
|
|
|
|
case ISCSI_NET_PARAM_TCP_WSF:
|
|
|
|
case ISCSI_NET_PARAM_TCP_TIMER_SCALE:
|
|
|
|
case ISCSI_NET_PARAM_TCP_TIMESTAMP_EN:
|
|
|
|
case ISCSI_NET_PARAM_CACHE_ID:
|
|
|
|
case ISCSI_NET_PARAM_IPV4_DHCP_DNS_ADDR_EN:
|
|
|
|
case ISCSI_NET_PARAM_IPV4_DHCP_SLP_DA_EN:
|
|
|
|
case ISCSI_NET_PARAM_IPV4_TOS_EN:
|
|
|
|
case ISCSI_NET_PARAM_IPV4_TOS:
|
|
|
|
case ISCSI_NET_PARAM_IPV4_GRAT_ARP_EN:
|
|
|
|
case ISCSI_NET_PARAM_IPV4_DHCP_ALT_CLIENT_ID_EN:
|
|
|
|
case ISCSI_NET_PARAM_IPV4_DHCP_ALT_CLIENT_ID:
|
|
|
|
case ISCSI_NET_PARAM_IPV4_DHCP_REQ_VENDOR_ID_EN:
|
|
|
|
case ISCSI_NET_PARAM_IPV4_DHCP_USE_VENDOR_ID_EN:
|
|
|
|
case ISCSI_NET_PARAM_IPV4_DHCP_VENDOR_ID:
|
|
|
|
case ISCSI_NET_PARAM_IPV4_DHCP_LEARN_IQN_EN:
|
|
|
|
case ISCSI_NET_PARAM_IPV4_FRAGMENT_DISABLE:
|
|
|
|
case ISCSI_NET_PARAM_IPV4_IN_FORWARD_EN:
|
|
|
|
case ISCSI_NET_PARAM_REDIRECT_EN:
|
|
|
|
case ISCSI_NET_PARAM_IPV4_TTL:
|
|
|
|
case ISCSI_NET_PARAM_IPV6_GRAT_NEIGHBOR_ADV_EN:
|
|
|
|
case ISCSI_NET_PARAM_IPV6_MLD_EN:
|
|
|
|
case ISCSI_NET_PARAM_IPV6_FLOW_LABEL:
|
|
|
|
case ISCSI_NET_PARAM_IPV6_TRAFFIC_CLASS:
|
|
|
|
case ISCSI_NET_PARAM_IPV6_HOP_LIMIT:
|
|
|
|
case ISCSI_NET_PARAM_IPV6_ND_REACHABLE_TMO:
|
|
|
|
case ISCSI_NET_PARAM_IPV6_ND_REXMIT_TIME:
|
|
|
|
case ISCSI_NET_PARAM_IPV6_ND_STALE_TMO:
|
|
|
|
case ISCSI_NET_PARAM_IPV6_DUP_ADDR_DETECT_CNT:
|
|
|
|
case ISCSI_NET_PARAM_IPV6_RTR_ADV_LINK_MTU:
|
|
|
|
return S_IRUGO;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
case ISCSI_IFACE_PARAM:
|
|
|
|
switch (param) {
|
|
|
|
case ISCSI_IFACE_PARAM_DEF_TASKMGMT_TMO:
|
|
|
|
case ISCSI_IFACE_PARAM_HDRDGST_EN:
|
|
|
|
case ISCSI_IFACE_PARAM_DATADGST_EN:
|
|
|
|
case ISCSI_IFACE_PARAM_IMM_DATA_EN:
|
|
|
|
case ISCSI_IFACE_PARAM_INITIAL_R2T_EN:
|
|
|
|
case ISCSI_IFACE_PARAM_DATASEQ_INORDER_EN:
|
|
|
|
case ISCSI_IFACE_PARAM_PDU_INORDER_EN:
|
|
|
|
case ISCSI_IFACE_PARAM_ERL:
|
|
|
|
case ISCSI_IFACE_PARAM_MAX_RECV_DLENGTH:
|
|
|
|
case ISCSI_IFACE_PARAM_FIRST_BURST:
|
|
|
|
case ISCSI_IFACE_PARAM_MAX_R2T:
|
|
|
|
case ISCSI_IFACE_PARAM_MAX_BURST:
|
|
|
|
case ISCSI_IFACE_PARAM_CHAP_AUTH_EN:
|
|
|
|
case ISCSI_IFACE_PARAM_BIDI_CHAP_EN:
|
|
|
|
case ISCSI_IFACE_PARAM_DISCOVERY_AUTH_OPTIONAL:
|
|
|
|
case ISCSI_IFACE_PARAM_DISCOVERY_LOGOUT_EN:
|
|
|
|
case ISCSI_IFACE_PARAM_STRICT_LOGIN_COMP_EN:
|
|
|
|
case ISCSI_IFACE_PARAM_INITIATOR_NAME:
|
2011-07-25 20:48:44 +02:00
|
|
|
return S_IRUGO;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
2013-03-22 12:41:31 +01:00
|
|
|
case ISCSI_FLASHNODE_PARAM:
|
|
|
|
switch (param) {
|
|
|
|
case ISCSI_FLASHNODE_IS_FW_ASSIGNED_IPV6:
|
|
|
|
case ISCSI_FLASHNODE_PORTAL_TYPE:
|
|
|
|
case ISCSI_FLASHNODE_AUTO_SND_TGT_DISABLE:
|
|
|
|
case ISCSI_FLASHNODE_DISCOVERY_SESS:
|
|
|
|
case ISCSI_FLASHNODE_ENTRY_EN:
|
|
|
|
case ISCSI_FLASHNODE_HDR_DGST_EN:
|
|
|
|
case ISCSI_FLASHNODE_DATA_DGST_EN:
|
|
|
|
case ISCSI_FLASHNODE_IMM_DATA_EN:
|
|
|
|
case ISCSI_FLASHNODE_INITIAL_R2T_EN:
|
|
|
|
case ISCSI_FLASHNODE_DATASEQ_INORDER:
|
|
|
|
case ISCSI_FLASHNODE_PDU_INORDER:
|
|
|
|
case ISCSI_FLASHNODE_CHAP_AUTH_EN:
|
|
|
|
case ISCSI_FLASHNODE_SNACK_REQ_EN:
|
|
|
|
case ISCSI_FLASHNODE_DISCOVERY_LOGOUT_EN:
|
|
|
|
case ISCSI_FLASHNODE_BIDI_CHAP_EN:
|
|
|
|
case ISCSI_FLASHNODE_DISCOVERY_AUTH_OPTIONAL:
|
|
|
|
case ISCSI_FLASHNODE_ERL:
|
|
|
|
case ISCSI_FLASHNODE_TCP_TIMESTAMP_STAT:
|
|
|
|
case ISCSI_FLASHNODE_TCP_NAGLE_DISABLE:
|
|
|
|
case ISCSI_FLASHNODE_TCP_WSF_DISABLE:
|
|
|
|
case ISCSI_FLASHNODE_TCP_TIMER_SCALE:
|
|
|
|
case ISCSI_FLASHNODE_TCP_TIMESTAMP_EN:
|
|
|
|
case ISCSI_FLASHNODE_IP_FRAG_DISABLE:
|
|
|
|
case ISCSI_FLASHNODE_MAX_RECV_DLENGTH:
|
|
|
|
case ISCSI_FLASHNODE_MAX_XMIT_DLENGTH:
|
|
|
|
case ISCSI_FLASHNODE_FIRST_BURST:
|
|
|
|
case ISCSI_FLASHNODE_DEF_TIME2WAIT:
|
|
|
|
case ISCSI_FLASHNODE_DEF_TIME2RETAIN:
|
|
|
|
case ISCSI_FLASHNODE_MAX_R2T:
|
|
|
|
case ISCSI_FLASHNODE_KEEPALIVE_TMO:
|
|
|
|
case ISCSI_FLASHNODE_ISID:
|
|
|
|
case ISCSI_FLASHNODE_TSID:
|
|
|
|
case ISCSI_FLASHNODE_PORT:
|
|
|
|
case ISCSI_FLASHNODE_MAX_BURST:
|
|
|
|
case ISCSI_FLASHNODE_DEF_TASKMGMT_TMO:
|
|
|
|
case ISCSI_FLASHNODE_IPADDR:
|
|
|
|
case ISCSI_FLASHNODE_ALIAS:
|
|
|
|
case ISCSI_FLASHNODE_REDIRECT_IPADDR:
|
|
|
|
case ISCSI_FLASHNODE_MAX_SEGMENT_SIZE:
|
|
|
|
case ISCSI_FLASHNODE_LOCAL_PORT:
|
|
|
|
case ISCSI_FLASHNODE_IPV4_TOS:
|
|
|
|
case ISCSI_FLASHNODE_IPV6_TC:
|
|
|
|
case ISCSI_FLASHNODE_IPV6_FLOW_LABEL:
|
|
|
|
case ISCSI_FLASHNODE_NAME:
|
|
|
|
case ISCSI_FLASHNODE_TPGT:
|
|
|
|
case ISCSI_FLASHNODE_LINK_LOCAL_IPV6:
|
|
|
|
case ISCSI_FLASHNODE_DISCOVERY_PARENT_IDX:
|
|
|
|
case ISCSI_FLASHNODE_DISCOVERY_PARENT_TYPE:
|
|
|
|
case ISCSI_FLASHNODE_TCP_XMIT_WSF:
|
|
|
|
case ISCSI_FLASHNODE_TCP_RECV_WSF:
|
|
|
|
case ISCSI_FLASHNODE_CHAP_OUT_IDX:
|
|
|
|
case ISCSI_FLASHNODE_USERNAME:
|
|
|
|
case ISCSI_FLASHNODE_PASSWORD:
|
|
|
|
case ISCSI_FLASHNODE_STATSN:
|
|
|
|
case ISCSI_FLASHNODE_EXP_STATSN:
|
|
|
|
case ISCSI_FLASHNODE_IS_BOOT_TGT:
|
|
|
|
return S_IRUGO;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
2011-07-25 20:48:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-11-22 11:28:23 +01:00
|
|
|
/**
|
|
|
|
* qla4xxx_create chap_list - Create CHAP list from FLASH
|
|
|
|
* @ha: pointer to adapter structure
|
|
|
|
*
|
|
|
|
* Read flash and make a list of CHAP entries, during login when a CHAP entry
|
|
|
|
* is received, it will be checked in this list. If entry exist then the CHAP
|
|
|
|
* entry index is set in the DDB. If CHAP entry does not exist in this list
|
|
|
|
* then a new entry is added in FLASH in CHAP table and the index obtained is
|
|
|
|
* used in the DDB.
|
|
|
|
**/
|
|
|
|
static void qla4xxx_create_chap_list(struct scsi_qla_host *ha)
|
|
|
|
{
|
|
|
|
int rval = 0;
|
|
|
|
uint8_t *chap_flash_data = NULL;
|
|
|
|
uint32_t offset;
|
|
|
|
dma_addr_t chap_dma;
|
|
|
|
uint32_t chap_size = 0;
|
|
|
|
|
|
|
|
if (is_qla40XX(ha))
|
|
|
|
chap_size = MAX_CHAP_ENTRIES_40XX *
|
|
|
|
sizeof(struct ql4_chap_table);
|
|
|
|
else /* Single region contains CHAP info for both
|
|
|
|
* ports which is divided into half for each port.
|
|
|
|
*/
|
|
|
|
chap_size = ha->hw.flt_chap_size / 2;
|
|
|
|
|
|
|
|
chap_flash_data = dma_alloc_coherent(&ha->pdev->dev, chap_size,
|
|
|
|
&chap_dma, GFP_KERNEL);
|
|
|
|
if (!chap_flash_data) {
|
|
|
|
ql4_printk(KERN_ERR, ha, "No memory for chap_flash_data\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (is_qla40XX(ha)) {
|
|
|
|
offset = FLASH_CHAP_OFFSET;
|
|
|
|
} else {
|
|
|
|
offset = FLASH_RAW_ACCESS_ADDR + (ha->hw.flt_region_chap << 2);
|
|
|
|
if (ha->port_num == 1)
|
|
|
|
offset += chap_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
rval = qla4xxx_get_flash(ha, chap_dma, offset, chap_size);
|
|
|
|
if (rval != QLA_SUCCESS)
|
|
|
|
goto exit_chap_list;
|
|
|
|
|
|
|
|
if (ha->chap_list == NULL)
|
|
|
|
ha->chap_list = vmalloc(chap_size);
|
|
|
|
if (ha->chap_list == NULL) {
|
|
|
|
ql4_printk(KERN_ERR, ha, "No memory for ha->chap_list\n");
|
|
|
|
goto exit_chap_list;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(ha->chap_list, 0, chap_size);
|
|
|
|
memcpy(ha->chap_list, chap_flash_data, chap_size);
|
|
|
|
|
|
|
|
exit_chap_list:
|
|
|
|
dma_free_coherent(&ha->pdev->dev, chap_size, chap_flash_data, chap_dma);
|
|
|
|
}
|
|
|
|
|
2013-09-17 13:54:49 +02:00
|
|
|
static int qla4xxx_get_chap_by_index(struct scsi_qla_host *ha,
|
|
|
|
int16_t chap_index,
|
|
|
|
struct ql4_chap_table **chap_entry)
|
|
|
|
{
|
|
|
|
int rval = QLA_ERROR;
|
|
|
|
int max_chap_entries;
|
|
|
|
|
|
|
|
if (!ha->chap_list) {
|
|
|
|
ql4_printk(KERN_ERR, ha, "CHAP table cache is empty!\n");
|
|
|
|
rval = QLA_ERROR;
|
|
|
|
goto exit_get_chap;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (is_qla80XX(ha))
|
|
|
|
max_chap_entries = (ha->hw.flt_chap_size / 2) /
|
|
|
|
sizeof(struct ql4_chap_table);
|
|
|
|
else
|
|
|
|
max_chap_entries = MAX_CHAP_ENTRIES_40XX;
|
|
|
|
|
|
|
|
if (chap_index > max_chap_entries) {
|
|
|
|
ql4_printk(KERN_ERR, ha, "Invalid Chap index\n");
|
|
|
|
rval = QLA_ERROR;
|
|
|
|
goto exit_get_chap;
|
|
|
|
}
|
|
|
|
|
|
|
|
*chap_entry = (struct ql4_chap_table *)ha->chap_list + chap_index;
|
|
|
|
if ((*chap_entry)->cookie !=
|
|
|
|
__constant_cpu_to_le16(CHAP_VALID_COOKIE)) {
|
|
|
|
rval = QLA_ERROR;
|
|
|
|
*chap_entry = NULL;
|
|
|
|
} else {
|
|
|
|
rval = QLA_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
exit_get_chap:
|
|
|
|
return rval;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* qla4xxx_find_free_chap_index - Find the first free chap index
|
|
|
|
* @ha: pointer to adapter structure
|
|
|
|
* @chap_index: CHAP index to be returned
|
|
|
|
*
|
|
|
|
* Find the first free chap index available in the chap table
|
|
|
|
*
|
|
|
|
* Note: Caller should acquire the chap lock before getting here.
|
|
|
|
**/
|
|
|
|
static int qla4xxx_find_free_chap_index(struct scsi_qla_host *ha,
|
|
|
|
uint16_t *chap_index)
|
|
|
|
{
|
|
|
|
int i, rval;
|
|
|
|
int free_index = -1;
|
|
|
|
int max_chap_entries = 0;
|
|
|
|
struct ql4_chap_table *chap_table;
|
|
|
|
|
|
|
|
if (is_qla80XX(ha))
|
|
|
|
max_chap_entries = (ha->hw.flt_chap_size / 2) /
|
|
|
|
sizeof(struct ql4_chap_table);
|
|
|
|
else
|
|
|
|
max_chap_entries = MAX_CHAP_ENTRIES_40XX;
|
|
|
|
|
|
|
|
if (!ha->chap_list) {
|
|
|
|
ql4_printk(KERN_ERR, ha, "CHAP table cache is empty!\n");
|
|
|
|
rval = QLA_ERROR;
|
|
|
|
goto exit_find_chap;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < max_chap_entries; i++) {
|
|
|
|
chap_table = (struct ql4_chap_table *)ha->chap_list + i;
|
|
|
|
|
|
|
|
if ((chap_table->cookie !=
|
|
|
|
__constant_cpu_to_le16(CHAP_VALID_COOKIE)) &&
|
|
|
|
(i > MAX_RESRV_CHAP_IDX)) {
|
|
|
|
free_index = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (free_index != -1) {
|
|
|
|
*chap_index = free_index;
|
|
|
|
rval = QLA_SUCCESS;
|
|
|
|
} else {
|
|
|
|
rval = QLA_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
exit_find_chap:
|
|
|
|
return rval;
|
|
|
|
}
|
|
|
|
|
2012-02-27 12:08:52 +01:00
|
|
|
static int qla4xxx_get_chap_list(struct Scsi_Host *shost, uint16_t chap_tbl_idx,
|
|
|
|
uint32_t *num_entries, char *buf)
|
|
|
|
{
|
|
|
|
struct scsi_qla_host *ha = to_qla_host(shost);
|
|
|
|
struct ql4_chap_table *chap_table;
|
|
|
|
struct iscsi_chap_rec *chap_rec;
|
|
|
|
int max_chap_entries = 0;
|
|
|
|
int valid_chap_entries = 0;
|
|
|
|
int ret = 0, i;
|
|
|
|
|
2013-03-22 12:08:31 +01:00
|
|
|
if (is_qla80XX(ha))
|
2012-02-27 12:08:52 +01:00
|
|
|
max_chap_entries = (ha->hw.flt_chap_size / 2) /
|
|
|
|
sizeof(struct ql4_chap_table);
|
|
|
|
else
|
|
|
|
max_chap_entries = MAX_CHAP_ENTRIES_40XX;
|
|
|
|
|
|
|
|
ql4_printk(KERN_INFO, ha, "%s: num_entries = %d, CHAP idx = %d\n",
|
|
|
|
__func__, *num_entries, chap_tbl_idx);
|
|
|
|
|
|
|
|
if (!buf) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto exit_get_chap_list;
|
|
|
|
}
|
|
|
|
|
2013-11-22 11:28:23 +01:00
|
|
|
qla4xxx_create_chap_list(ha);
|
|
|
|
|
2012-02-27 12:08:52 +01:00
|
|
|
chap_rec = (struct iscsi_chap_rec *) buf;
|
|
|
|
mutex_lock(&ha->chap_sem);
|
|
|
|
for (i = chap_tbl_idx; i < max_chap_entries; i++) {
|
|
|
|
chap_table = (struct ql4_chap_table *)ha->chap_list + i;
|
|
|
|
if (chap_table->cookie !=
|
|
|
|
__constant_cpu_to_le16(CHAP_VALID_COOKIE))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
chap_rec->chap_tbl_idx = i;
|
2014-07-26 16:49:32 +02:00
|
|
|
strlcpy(chap_rec->username, chap_table->name,
|
2012-02-27 12:08:52 +01:00
|
|
|
ISCSI_CHAP_AUTH_NAME_MAX_LEN);
|
2014-07-26 16:49:32 +02:00
|
|
|
strlcpy(chap_rec->password, chap_table->secret,
|
2012-02-27 12:08:52 +01:00
|
|
|
QL4_CHAP_MAX_SECRET_LEN);
|
|
|
|
chap_rec->password_length = chap_table->secret_len;
|
|
|
|
|
|
|
|
if (chap_table->flags & BIT_7) /* local */
|
|
|
|
chap_rec->chap_type = CHAP_TYPE_OUT;
|
|
|
|
|
|
|
|
if (chap_table->flags & BIT_6) /* peer */
|
|
|
|
chap_rec->chap_type = CHAP_TYPE_IN;
|
|
|
|
|
|
|
|
chap_rec++;
|
|
|
|
|
|
|
|
valid_chap_entries++;
|
|
|
|
if (valid_chap_entries == *num_entries)
|
|
|
|
break;
|
|
|
|
else
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
mutex_unlock(&ha->chap_sem);
|
|
|
|
|
|
|
|
exit_get_chap_list:
|
|
|
|
ql4_printk(KERN_INFO, ha, "%s: Valid CHAP Entries = %d\n",
|
|
|
|
__func__, valid_chap_entries);
|
|
|
|
*num_entries = valid_chap_entries;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __qla4xxx_is_chap_active(struct device *dev, void *data)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
uint16_t *chap_tbl_idx = (uint16_t *) data;
|
|
|
|
struct iscsi_cls_session *cls_session;
|
|
|
|
struct iscsi_session *sess;
|
|
|
|
struct ddb_entry *ddb_entry;
|
|
|
|
|
|
|
|
if (!iscsi_is_session_dev(dev))
|
|
|
|
goto exit_is_chap_active;
|
|
|
|
|
|
|
|
cls_session = iscsi_dev_to_session(dev);
|
|
|
|
sess = cls_session->dd_data;
|
|
|
|
ddb_entry = sess->dd_data;
|
|
|
|
|
|
|
|
if (iscsi_session_chkready(cls_session))
|
|
|
|
goto exit_is_chap_active;
|
|
|
|
|
|
|
|
if (ddb_entry->chap_tbl_idx == *chap_tbl_idx)
|
|
|
|
ret = 1;
|
|
|
|
|
|
|
|
exit_is_chap_active:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int qla4xxx_is_chap_active(struct Scsi_Host *shost,
|
|
|
|
uint16_t chap_tbl_idx)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
ret = device_for_each_child(&shost->shost_gendev, &chap_tbl_idx,
|
|
|
|
__qla4xxx_is_chap_active);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int qla4xxx_delete_chap(struct Scsi_Host *shost, uint16_t chap_tbl_idx)
|
|
|
|
{
|
|
|
|
struct scsi_qla_host *ha = to_qla_host(shost);
|
|
|
|
struct ql4_chap_table *chap_table;
|
|
|
|
dma_addr_t chap_dma;
|
|
|
|
int max_chap_entries = 0;
|
|
|
|
uint32_t offset = 0;
|
|
|
|
uint32_t chap_size;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
chap_table = dma_pool_alloc(ha->chap_dma_pool, GFP_KERNEL, &chap_dma);
|
|
|
|
if (chap_table == NULL)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
memset(chap_table, 0, sizeof(struct ql4_chap_table));
|
|
|
|
|
2013-03-22 12:08:31 +01:00
|
|
|
if (is_qla80XX(ha))
|
2012-02-27 12:08:52 +01:00
|
|
|
max_chap_entries = (ha->hw.flt_chap_size / 2) /
|
|
|
|
sizeof(struct ql4_chap_table);
|
|
|
|
else
|
|
|
|
max_chap_entries = MAX_CHAP_ENTRIES_40XX;
|
|
|
|
|
|
|
|
if (chap_tbl_idx > max_chap_entries) {
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto exit_delete_chap;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if chap index is in use.
|
|
|
|
* If chap is in use don't delet chap entry */
|
|
|
|
ret = qla4xxx_is_chap_active(shost, chap_tbl_idx);
|
|
|
|
if (ret) {
|
|
|
|
ql4_printk(KERN_INFO, ha, "CHAP entry %d is in use, cannot "
|
|
|
|
"delete from flash\n", chap_tbl_idx);
|
|
|
|
ret = -EBUSY;
|
|
|
|
goto exit_delete_chap;
|
|
|
|
}
|
|
|
|
|
|
|
|
chap_size = sizeof(struct ql4_chap_table);
|
|
|
|
if (is_qla40XX(ha))
|
|
|
|
offset = FLASH_CHAP_OFFSET | (chap_tbl_idx * chap_size);
|
|
|
|
else {
|
|
|
|
offset = FLASH_RAW_ACCESS_ADDR + (ha->hw.flt_region_chap << 2);
|
|
|
|
/* flt_chap_size is CHAP table size for both ports
|
|
|
|
* so divide it by 2 to calculate the offset for second port
|
|
|
|
*/
|
|
|
|
if (ha->port_num == 1)
|
|
|
|
offset += (ha->hw.flt_chap_size / 2);
|
|
|
|
offset += (chap_tbl_idx * chap_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = qla4xxx_get_flash(ha, chap_dma, offset, chap_size);
|
|
|
|
if (ret != QLA_SUCCESS) {
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto exit_delete_chap;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha, "Chap Cookie: x%x\n",
|
|
|
|
__le16_to_cpu(chap_table->cookie)));
|
|
|
|
|
|
|
|
if (__le16_to_cpu(chap_table->cookie) != CHAP_VALID_COOKIE) {
|
|
|
|
ql4_printk(KERN_ERR, ha, "No valid chap entry found\n");
|
|
|
|
goto exit_delete_chap;
|
|
|
|
}
|
|
|
|
|
|
|
|
chap_table->cookie = __constant_cpu_to_le16(0xFFFF);
|
|
|
|
|
|
|
|
offset = FLASH_CHAP_OFFSET |
|
|
|
|
(chap_tbl_idx * sizeof(struct ql4_chap_table));
|
|
|
|
ret = qla4xxx_set_flash(ha, chap_dma, offset, chap_size,
|
|
|
|
FLASH_OPT_RMW_COMMIT);
|
|
|
|
if (ret == QLA_SUCCESS && ha->chap_list) {
|
|
|
|
mutex_lock(&ha->chap_sem);
|
|
|
|
/* Update ha chap_list cache */
|
|
|
|
memcpy((struct ql4_chap_table *)ha->chap_list + chap_tbl_idx,
|
|
|
|
chap_table, sizeof(struct ql4_chap_table));
|
|
|
|
mutex_unlock(&ha->chap_sem);
|
|
|
|
}
|
|
|
|
if (ret != QLA_SUCCESS)
|
|
|
|
ret = -EINVAL;
|
|
|
|
|
|
|
|
exit_delete_chap:
|
|
|
|
dma_pool_free(ha->chap_dma_pool, chap_table, chap_dma);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-09-17 13:54:49 +02:00
|
|
|
/**
|
|
|
|
* qla4xxx_set_chap_entry - Make chap entry with given information
|
|
|
|
* @shost: pointer to host
|
|
|
|
* @data: chap info - credentials, index and type to make chap entry
|
|
|
|
* @len: length of data
|
|
|
|
*
|
|
|
|
* Add or update chap entry with the given information
|
|
|
|
**/
|
|
|
|
static int qla4xxx_set_chap_entry(struct Scsi_Host *shost, void *data, int len)
|
|
|
|
{
|
|
|
|
struct scsi_qla_host *ha = to_qla_host(shost);
|
|
|
|
struct iscsi_chap_rec chap_rec;
|
|
|
|
struct ql4_chap_table *chap_entry = NULL;
|
|
|
|
struct iscsi_param_info *param_info;
|
|
|
|
struct nlattr *attr;
|
|
|
|
int max_chap_entries = 0;
|
|
|
|
int type;
|
|
|
|
int rem = len;
|
|
|
|
int rc = 0;
|
2013-11-13 08:48:11 +01:00
|
|
|
int size;
|
2013-09-17 13:54:49 +02:00
|
|
|
|
|
|
|
memset(&chap_rec, 0, sizeof(chap_rec));
|
|
|
|
|
|
|
|
nla_for_each_attr(attr, data, len, rem) {
|
|
|
|
param_info = nla_data(attr);
|
|
|
|
|
|
|
|
switch (param_info->param) {
|
|
|
|
case ISCSI_CHAP_PARAM_INDEX:
|
|
|
|
chap_rec.chap_tbl_idx = *(uint16_t *)param_info->value;
|
|
|
|
break;
|
|
|
|
case ISCSI_CHAP_PARAM_CHAP_TYPE:
|
|
|
|
chap_rec.chap_type = param_info->value[0];
|
|
|
|
break;
|
|
|
|
case ISCSI_CHAP_PARAM_USERNAME:
|
2013-11-13 08:48:11 +01:00
|
|
|
size = min_t(size_t, sizeof(chap_rec.username),
|
|
|
|
param_info->len);
|
|
|
|
memcpy(chap_rec.username, param_info->value, size);
|
2013-09-17 13:54:49 +02:00
|
|
|
break;
|
|
|
|
case ISCSI_CHAP_PARAM_PASSWORD:
|
2013-11-13 08:48:11 +01:00
|
|
|
size = min_t(size_t, sizeof(chap_rec.password),
|
|
|
|
param_info->len);
|
|
|
|
memcpy(chap_rec.password, param_info->value, size);
|
2013-09-17 13:54:49 +02:00
|
|
|
break;
|
|
|
|
case ISCSI_CHAP_PARAM_PASSWORD_LEN:
|
|
|
|
chap_rec.password_length = param_info->value[0];
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ql4_printk(KERN_ERR, ha,
|
|
|
|
"%s: No such sysfs attribute\n", __func__);
|
|
|
|
rc = -ENOSYS;
|
|
|
|
goto exit_set_chap;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
if (chap_rec.chap_type == CHAP_TYPE_IN)
|
|
|
|
type = BIDI_CHAP;
|
|
|
|
else
|
|
|
|
type = LOCAL_CHAP;
|
|
|
|
|
|
|
|
if (is_qla80XX(ha))
|
|
|
|
max_chap_entries = (ha->hw.flt_chap_size / 2) /
|
|
|
|
sizeof(struct ql4_chap_table);
|
|
|
|
else
|
|
|
|
max_chap_entries = MAX_CHAP_ENTRIES_40XX;
|
|
|
|
|
|
|
|
mutex_lock(&ha->chap_sem);
|
|
|
|
if (chap_rec.chap_tbl_idx < max_chap_entries) {
|
|
|
|
rc = qla4xxx_get_chap_by_index(ha, chap_rec.chap_tbl_idx,
|
|
|
|
&chap_entry);
|
|
|
|
if (!rc) {
|
|
|
|
if (!(type == qla4xxx_get_chap_type(chap_entry))) {
|
|
|
|
ql4_printk(KERN_INFO, ha,
|
|
|
|
"Type mismatch for CHAP entry %d\n",
|
|
|
|
chap_rec.chap_tbl_idx);
|
|
|
|
rc = -EINVAL;
|
|
|
|
goto exit_unlock_chap;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If chap index is in use then don't modify it */
|
|
|
|
rc = qla4xxx_is_chap_active(shost,
|
|
|
|
chap_rec.chap_tbl_idx);
|
|
|
|
if (rc) {
|
|
|
|
ql4_printk(KERN_INFO, ha,
|
|
|
|
"CHAP entry %d is in use\n",
|
|
|
|
chap_rec.chap_tbl_idx);
|
|
|
|
rc = -EBUSY;
|
|
|
|
goto exit_unlock_chap;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
rc = qla4xxx_find_free_chap_index(ha, &chap_rec.chap_tbl_idx);
|
|
|
|
if (rc) {
|
|
|
|
ql4_printk(KERN_INFO, ha, "CHAP entry not available\n");
|
|
|
|
rc = -EBUSY;
|
|
|
|
goto exit_unlock_chap;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = qla4xxx_set_chap(ha, chap_rec.username, chap_rec.password,
|
|
|
|
chap_rec.chap_tbl_idx, type);
|
|
|
|
|
|
|
|
exit_unlock_chap:
|
|
|
|
mutex_unlock(&ha->chap_sem);
|
|
|
|
|
|
|
|
exit_set_chap:
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2013-11-22 11:28:19 +01:00
|
|
|
|
|
|
|
static int qla4xxx_get_host_stats(struct Scsi_Host *shost, char *buf, int len)
|
|
|
|
{
|
|
|
|
struct scsi_qla_host *ha = to_qla_host(shost);
|
|
|
|
struct iscsi_offload_host_stats *host_stats = NULL;
|
|
|
|
int host_stats_size;
|
|
|
|
int ret = 0;
|
|
|
|
int ddb_idx = 0;
|
|
|
|
struct ql_iscsi_stats *ql_iscsi_stats = NULL;
|
|
|
|
int stats_size;
|
|
|
|
dma_addr_t iscsi_stats_dma;
|
|
|
|
|
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha, "Func: %s\n", __func__));
|
|
|
|
|
|
|
|
host_stats_size = sizeof(struct iscsi_offload_host_stats);
|
|
|
|
|
|
|
|
if (host_stats_size != len) {
|
|
|
|
ql4_printk(KERN_INFO, ha, "%s: host_stats size mismatch expected = %d, is = %d\n",
|
|
|
|
__func__, len, host_stats_size);
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto exit_host_stats;
|
|
|
|
}
|
|
|
|
host_stats = (struct iscsi_offload_host_stats *)buf;
|
|
|
|
|
|
|
|
if (!buf) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto exit_host_stats;
|
|
|
|
}
|
|
|
|
|
|
|
|
stats_size = PAGE_ALIGN(sizeof(struct ql_iscsi_stats));
|
|
|
|
|
|
|
|
ql_iscsi_stats = dma_alloc_coherent(&ha->pdev->dev, stats_size,
|
|
|
|
&iscsi_stats_dma, GFP_KERNEL);
|
|
|
|
if (!ql_iscsi_stats) {
|
|
|
|
ql4_printk(KERN_ERR, ha,
|
|
|
|
"Unable to allocate memory for iscsi stats\n");
|
2014-07-12 22:51:49 +02:00
|
|
|
ret = -ENOMEM;
|
2013-11-22 11:28:19 +01:00
|
|
|
goto exit_host_stats;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = qla4xxx_get_mgmt_data(ha, ddb_idx, stats_size,
|
|
|
|
iscsi_stats_dma);
|
|
|
|
if (ret != QLA_SUCCESS) {
|
|
|
|
ql4_printk(KERN_ERR, ha,
|
|
|
|
"Unable to retrieve iscsi stats\n");
|
2014-07-12 22:51:49 +02:00
|
|
|
ret = -EIO;
|
2013-11-22 11:28:19 +01:00
|
|
|
goto exit_host_stats;
|
|
|
|
}
|
|
|
|
host_stats->mactx_frames = le64_to_cpu(ql_iscsi_stats->mac_tx_frames);
|
|
|
|
host_stats->mactx_bytes = le64_to_cpu(ql_iscsi_stats->mac_tx_bytes);
|
|
|
|
host_stats->mactx_multicast_frames =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->mac_tx_multicast_frames);
|
|
|
|
host_stats->mactx_broadcast_frames =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->mac_tx_broadcast_frames);
|
|
|
|
host_stats->mactx_pause_frames =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->mac_tx_pause_frames);
|
|
|
|
host_stats->mactx_control_frames =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->mac_tx_control_frames);
|
|
|
|
host_stats->mactx_deferral =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->mac_tx_deferral);
|
|
|
|
host_stats->mactx_excess_deferral =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->mac_tx_excess_deferral);
|
|
|
|
host_stats->mactx_late_collision =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->mac_tx_late_collision);
|
|
|
|
host_stats->mactx_abort = le64_to_cpu(ql_iscsi_stats->mac_tx_abort);
|
|
|
|
host_stats->mactx_single_collision =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->mac_tx_single_collision);
|
|
|
|
host_stats->mactx_multiple_collision =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->mac_tx_multiple_collision);
|
|
|
|
host_stats->mactx_collision =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->mac_tx_collision);
|
|
|
|
host_stats->mactx_frames_dropped =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->mac_tx_frames_dropped);
|
|
|
|
host_stats->mactx_jumbo_frames =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->mac_tx_jumbo_frames);
|
|
|
|
host_stats->macrx_frames = le64_to_cpu(ql_iscsi_stats->mac_rx_frames);
|
|
|
|
host_stats->macrx_bytes = le64_to_cpu(ql_iscsi_stats->mac_rx_bytes);
|
|
|
|
host_stats->macrx_unknown_control_frames =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->mac_rx_unknown_control_frames);
|
|
|
|
host_stats->macrx_pause_frames =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->mac_rx_pause_frames);
|
|
|
|
host_stats->macrx_control_frames =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->mac_rx_control_frames);
|
|
|
|
host_stats->macrx_dribble =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->mac_rx_dribble);
|
|
|
|
host_stats->macrx_frame_length_error =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->mac_rx_frame_length_error);
|
|
|
|
host_stats->macrx_jabber = le64_to_cpu(ql_iscsi_stats->mac_rx_jabber);
|
|
|
|
host_stats->macrx_carrier_sense_error =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->mac_rx_carrier_sense_error);
|
|
|
|
host_stats->macrx_frame_discarded =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->mac_rx_frame_discarded);
|
|
|
|
host_stats->macrx_frames_dropped =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->mac_rx_frames_dropped);
|
|
|
|
host_stats->mac_crc_error = le64_to_cpu(ql_iscsi_stats->mac_crc_error);
|
|
|
|
host_stats->mac_encoding_error =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->mac_encoding_error);
|
|
|
|
host_stats->macrx_length_error_large =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->mac_rx_length_error_large);
|
|
|
|
host_stats->macrx_length_error_small =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->mac_rx_length_error_small);
|
|
|
|
host_stats->macrx_multicast_frames =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->mac_rx_multicast_frames);
|
|
|
|
host_stats->macrx_broadcast_frames =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->mac_rx_broadcast_frames);
|
|
|
|
host_stats->iptx_packets = le64_to_cpu(ql_iscsi_stats->ip_tx_packets);
|
|
|
|
host_stats->iptx_bytes = le64_to_cpu(ql_iscsi_stats->ip_tx_bytes);
|
|
|
|
host_stats->iptx_fragments =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->ip_tx_fragments);
|
|
|
|
host_stats->iprx_packets = le64_to_cpu(ql_iscsi_stats->ip_rx_packets);
|
|
|
|
host_stats->iprx_bytes = le64_to_cpu(ql_iscsi_stats->ip_rx_bytes);
|
|
|
|
host_stats->iprx_fragments =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->ip_rx_fragments);
|
|
|
|
host_stats->ip_datagram_reassembly =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->ip_datagram_reassembly);
|
|
|
|
host_stats->ip_invalid_address_error =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->ip_invalid_address_error);
|
|
|
|
host_stats->ip_error_packets =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->ip_error_packets);
|
|
|
|
host_stats->ip_fragrx_overlap =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->ip_fragrx_overlap);
|
|
|
|
host_stats->ip_fragrx_outoforder =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->ip_fragrx_outoforder);
|
|
|
|
host_stats->ip_datagram_reassembly_timeout =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->ip_datagram_reassembly_timeout);
|
|
|
|
host_stats->ipv6tx_packets =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->ipv6_tx_packets);
|
|
|
|
host_stats->ipv6tx_bytes = le64_to_cpu(ql_iscsi_stats->ipv6_tx_bytes);
|
|
|
|
host_stats->ipv6tx_fragments =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->ipv6_tx_fragments);
|
|
|
|
host_stats->ipv6rx_packets =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->ipv6_rx_packets);
|
|
|
|
host_stats->ipv6rx_bytes = le64_to_cpu(ql_iscsi_stats->ipv6_rx_bytes);
|
|
|
|
host_stats->ipv6rx_fragments =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->ipv6_rx_fragments);
|
|
|
|
host_stats->ipv6_datagram_reassembly =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->ipv6_datagram_reassembly);
|
|
|
|
host_stats->ipv6_invalid_address_error =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->ipv6_invalid_address_error);
|
|
|
|
host_stats->ipv6_error_packets =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->ipv6_error_packets);
|
|
|
|
host_stats->ipv6_fragrx_overlap =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->ipv6_fragrx_overlap);
|
|
|
|
host_stats->ipv6_fragrx_outoforder =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->ipv6_fragrx_outoforder);
|
|
|
|
host_stats->ipv6_datagram_reassembly_timeout =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->ipv6_datagram_reassembly_timeout);
|
|
|
|
host_stats->tcptx_segments =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->tcp_tx_segments);
|
|
|
|
host_stats->tcptx_bytes = le64_to_cpu(ql_iscsi_stats->tcp_tx_bytes);
|
|
|
|
host_stats->tcprx_segments =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->tcp_rx_segments);
|
|
|
|
host_stats->tcprx_byte = le64_to_cpu(ql_iscsi_stats->tcp_rx_byte);
|
|
|
|
host_stats->tcp_duplicate_ack_retx =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->tcp_duplicate_ack_retx);
|
|
|
|
host_stats->tcp_retx_timer_expired =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->tcp_retx_timer_expired);
|
|
|
|
host_stats->tcprx_duplicate_ack =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->tcp_rx_duplicate_ack);
|
|
|
|
host_stats->tcprx_pure_ackr =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->tcp_rx_pure_ackr);
|
|
|
|
host_stats->tcptx_delayed_ack =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->tcp_tx_delayed_ack);
|
|
|
|
host_stats->tcptx_pure_ack =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->tcp_tx_pure_ack);
|
|
|
|
host_stats->tcprx_segment_error =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->tcp_rx_segment_error);
|
|
|
|
host_stats->tcprx_segment_outoforder =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->tcp_rx_segment_outoforder);
|
|
|
|
host_stats->tcprx_window_probe =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->tcp_rx_window_probe);
|
|
|
|
host_stats->tcprx_window_update =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->tcp_rx_window_update);
|
|
|
|
host_stats->tcptx_window_probe_persist =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->tcp_tx_window_probe_persist);
|
|
|
|
host_stats->ecc_error_correction =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->ecc_error_correction);
|
|
|
|
host_stats->iscsi_pdu_tx = le64_to_cpu(ql_iscsi_stats->iscsi_pdu_tx);
|
|
|
|
host_stats->iscsi_data_bytes_tx =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->iscsi_data_bytes_tx);
|
|
|
|
host_stats->iscsi_pdu_rx = le64_to_cpu(ql_iscsi_stats->iscsi_pdu_rx);
|
|
|
|
host_stats->iscsi_data_bytes_rx =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->iscsi_data_bytes_rx);
|
|
|
|
host_stats->iscsi_io_completed =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->iscsi_io_completed);
|
|
|
|
host_stats->iscsi_unexpected_io_rx =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->iscsi_unexpected_io_rx);
|
|
|
|
host_stats->iscsi_format_error =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->iscsi_format_error);
|
|
|
|
host_stats->iscsi_hdr_digest_error =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->iscsi_hdr_digest_error);
|
|
|
|
host_stats->iscsi_data_digest_error =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->iscsi_data_digest_error);
|
|
|
|
host_stats->iscsi_sequence_error =
|
|
|
|
le64_to_cpu(ql_iscsi_stats->iscsi_sequence_error);
|
|
|
|
exit_host_stats:
|
|
|
|
if (ql_iscsi_stats)
|
|
|
|
dma_free_coherent(&ha->pdev->dev, host_stats_size,
|
|
|
|
ql_iscsi_stats, iscsi_stats_dma);
|
|
|
|
|
|
|
|
ql4_printk(KERN_INFO, ha, "%s: Get host stats done\n",
|
|
|
|
__func__);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-07-25 20:48:41 +02:00
|
|
|
static int qla4xxx_get_iface_param(struct iscsi_iface *iface,
|
|
|
|
enum iscsi_param_type param_type,
|
|
|
|
int param, char *buf)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = iscsi_iface_to_shost(iface);
|
|
|
|
struct scsi_qla_host *ha = to_qla_host(shost);
|
2013-10-18 15:01:42 +02:00
|
|
|
int ival;
|
|
|
|
char *pval = NULL;
|
2011-07-25 20:48:41 +02:00
|
|
|
int len = -ENOSYS;
|
|
|
|
|
2013-10-18 15:01:42 +02:00
|
|
|
if (param_type == ISCSI_NET_PARAM) {
|
|
|
|
switch (param) {
|
|
|
|
case ISCSI_NET_PARAM_IPV4_ADDR:
|
|
|
|
len = sprintf(buf, "%pI4\n", &ha->ip_config.ip_address);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV4_SUBNET:
|
|
|
|
len = sprintf(buf, "%pI4\n",
|
|
|
|
&ha->ip_config.subnet_mask);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV4_GW:
|
|
|
|
len = sprintf(buf, "%pI4\n", &ha->ip_config.gateway);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IFACE_ENABLE:
|
|
|
|
if (iface->iface_type == ISCSI_IFACE_TYPE_IPV4) {
|
|
|
|
OP_STATE(ha->ip_config.ipv4_options,
|
|
|
|
IPOPT_IPV4_PROTOCOL_ENABLE, pval);
|
|
|
|
} else {
|
|
|
|
OP_STATE(ha->ip_config.ipv6_options,
|
|
|
|
IPV6_OPT_IPV6_PROTOCOL_ENABLE, pval);
|
|
|
|
}
|
2011-07-25 20:48:41 +02:00
|
|
|
|
2013-10-18 15:01:42 +02:00
|
|
|
len = sprintf(buf, "%s\n", pval);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV4_BOOTPROTO:
|
2011-07-25 20:48:41 +02:00
|
|
|
len = sprintf(buf, "%s\n",
|
2013-10-18 15:01:42 +02:00
|
|
|
(ha->ip_config.tcp_options &
|
|
|
|
TCPOPT_DHCP_ENABLE) ?
|
|
|
|
"dhcp" : "static");
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV6_ADDR:
|
|
|
|
if (iface->iface_num == 0)
|
|
|
|
len = sprintf(buf, "%pI6\n",
|
|
|
|
&ha->ip_config.ipv6_addr0);
|
|
|
|
if (iface->iface_num == 1)
|
|
|
|
len = sprintf(buf, "%pI6\n",
|
|
|
|
&ha->ip_config.ipv6_addr1);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV6_LINKLOCAL:
|
|
|
|
len = sprintf(buf, "%pI6\n",
|
|
|
|
&ha->ip_config.ipv6_link_local_addr);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV6_ROUTER:
|
|
|
|
len = sprintf(buf, "%pI6\n",
|
|
|
|
&ha->ip_config.ipv6_default_router_addr);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV6_ADDR_AUTOCFG:
|
|
|
|
pval = (ha->ip_config.ipv6_addl_options &
|
|
|
|
IPV6_ADDOPT_NEIGHBOR_DISCOVERY_ADDR_ENABLE) ?
|
|
|
|
"nd" : "static";
|
|
|
|
|
|
|
|
len = sprintf(buf, "%s\n", pval);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV6_LINKLOCAL_AUTOCFG:
|
|
|
|
pval = (ha->ip_config.ipv6_addl_options &
|
|
|
|
IPV6_ADDOPT_AUTOCONFIG_LINK_LOCAL_ADDR) ?
|
|
|
|
"auto" : "static";
|
|
|
|
|
|
|
|
len = sprintf(buf, "%s\n", pval);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_VLAN_ID:
|
|
|
|
if (iface->iface_type == ISCSI_IFACE_TYPE_IPV4)
|
|
|
|
ival = ha->ip_config.ipv4_vlan_tag &
|
|
|
|
ISCSI_MAX_VLAN_ID;
|
|
|
|
else
|
|
|
|
ival = ha->ip_config.ipv6_vlan_tag &
|
|
|
|
ISCSI_MAX_VLAN_ID;
|
|
|
|
|
|
|
|
len = sprintf(buf, "%d\n", ival);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_VLAN_PRIORITY:
|
|
|
|
if (iface->iface_type == ISCSI_IFACE_TYPE_IPV4)
|
|
|
|
ival = (ha->ip_config.ipv4_vlan_tag >> 13) &
|
|
|
|
ISCSI_MAX_VLAN_PRIORITY;
|
|
|
|
else
|
|
|
|
ival = (ha->ip_config.ipv6_vlan_tag >> 13) &
|
|
|
|
ISCSI_MAX_VLAN_PRIORITY;
|
|
|
|
|
|
|
|
len = sprintf(buf, "%d\n", ival);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_VLAN_ENABLED:
|
|
|
|
if (iface->iface_type == ISCSI_IFACE_TYPE_IPV4) {
|
|
|
|
OP_STATE(ha->ip_config.ipv4_options,
|
|
|
|
IPOPT_VLAN_TAGGING_ENABLE, pval);
|
|
|
|
} else {
|
|
|
|
OP_STATE(ha->ip_config.ipv6_options,
|
|
|
|
IPV6_OPT_VLAN_TAGGING_ENABLE, pval);
|
|
|
|
}
|
|
|
|
len = sprintf(buf, "%s\n", pval);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_MTU:
|
|
|
|
len = sprintf(buf, "%d\n", ha->ip_config.eth_mtu_size);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_PORT:
|
|
|
|
if (iface->iface_type == ISCSI_IFACE_TYPE_IPV4)
|
|
|
|
len = sprintf(buf, "%d\n",
|
|
|
|
ha->ip_config.ipv4_port);
|
|
|
|
else
|
|
|
|
len = sprintf(buf, "%d\n",
|
|
|
|
ha->ip_config.ipv6_port);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPADDR_STATE:
|
|
|
|
if (iface->iface_type == ISCSI_IFACE_TYPE_IPV4) {
|
|
|
|
pval = iscsi_get_ipaddress_state_name(
|
|
|
|
ha->ip_config.ipv4_addr_state);
|
|
|
|
} else {
|
|
|
|
if (iface->iface_num == 0)
|
|
|
|
pval = iscsi_get_ipaddress_state_name(
|
|
|
|
ha->ip_config.ipv6_addr0_state);
|
|
|
|
else if (iface->iface_num == 1)
|
|
|
|
pval = iscsi_get_ipaddress_state_name(
|
|
|
|
ha->ip_config.ipv6_addr1_state);
|
|
|
|
}
|
|
|
|
|
|
|
|
len = sprintf(buf, "%s\n", pval);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV6_LINKLOCAL_STATE:
|
|
|
|
pval = iscsi_get_ipaddress_state_name(
|
|
|
|
ha->ip_config.ipv6_link_local_state);
|
|
|
|
len = sprintf(buf, "%s\n", pval);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV6_ROUTER_STATE:
|
|
|
|
pval = iscsi_get_router_state_name(
|
|
|
|
ha->ip_config.ipv6_default_router_state);
|
|
|
|
len = sprintf(buf, "%s\n", pval);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_DELAYED_ACK_EN:
|
|
|
|
if (iface->iface_type == ISCSI_IFACE_TYPE_IPV4) {
|
|
|
|
OP_STATE(~ha->ip_config.tcp_options,
|
|
|
|
TCPOPT_DELAYED_ACK_DISABLE, pval);
|
|
|
|
} else {
|
|
|
|
OP_STATE(~ha->ip_config.ipv6_tcp_options,
|
|
|
|
IPV6_TCPOPT_DELAYED_ACK_DISABLE, pval);
|
|
|
|
}
|
|
|
|
len = sprintf(buf, "%s\n", pval);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_TCP_NAGLE_DISABLE:
|
|
|
|
if (iface->iface_type == ISCSI_IFACE_TYPE_IPV4) {
|
|
|
|
OP_STATE(~ha->ip_config.tcp_options,
|
|
|
|
TCPOPT_NAGLE_ALGO_DISABLE, pval);
|
|
|
|
} else {
|
|
|
|
OP_STATE(~ha->ip_config.ipv6_tcp_options,
|
|
|
|
IPV6_TCPOPT_NAGLE_ALGO_DISABLE, pval);
|
|
|
|
}
|
|
|
|
len = sprintf(buf, "%s\n", pval);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_TCP_WSF_DISABLE:
|
|
|
|
if (iface->iface_type == ISCSI_IFACE_TYPE_IPV4) {
|
|
|
|
OP_STATE(~ha->ip_config.tcp_options,
|
|
|
|
TCPOPT_WINDOW_SCALE_DISABLE, pval);
|
|
|
|
} else {
|
|
|
|
OP_STATE(~ha->ip_config.ipv6_tcp_options,
|
|
|
|
IPV6_TCPOPT_WINDOW_SCALE_DISABLE,
|
|
|
|
pval);
|
|
|
|
}
|
|
|
|
len = sprintf(buf, "%s\n", pval);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_TCP_WSF:
|
|
|
|
if (iface->iface_type == ISCSI_IFACE_TYPE_IPV4)
|
|
|
|
len = sprintf(buf, "%d\n",
|
|
|
|
ha->ip_config.tcp_wsf);
|
|
|
|
else
|
|
|
|
len = sprintf(buf, "%d\n",
|
|
|
|
ha->ip_config.ipv6_tcp_wsf);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_TCP_TIMER_SCALE:
|
|
|
|
if (iface->iface_type == ISCSI_IFACE_TYPE_IPV4)
|
|
|
|
ival = (ha->ip_config.tcp_options &
|
|
|
|
TCPOPT_TIMER_SCALE) >> 1;
|
|
|
|
else
|
|
|
|
ival = (ha->ip_config.ipv6_tcp_options &
|
|
|
|
IPV6_TCPOPT_TIMER_SCALE) >> 1;
|
|
|
|
|
|
|
|
len = sprintf(buf, "%d\n", ival);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_TCP_TIMESTAMP_EN:
|
|
|
|
if (iface->iface_type == ISCSI_IFACE_TYPE_IPV4) {
|
|
|
|
OP_STATE(ha->ip_config.tcp_options,
|
|
|
|
TCPOPT_TIMESTAMP_ENABLE, pval);
|
|
|
|
} else {
|
|
|
|
OP_STATE(ha->ip_config.ipv6_tcp_options,
|
|
|
|
IPV6_TCPOPT_TIMESTAMP_EN, pval);
|
|
|
|
}
|
|
|
|
len = sprintf(buf, "%s\n", pval);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_CACHE_ID:
|
|
|
|
if (iface->iface_type == ISCSI_IFACE_TYPE_IPV4)
|
|
|
|
len = sprintf(buf, "%d\n",
|
|
|
|
ha->ip_config.ipv4_cache_id);
|
|
|
|
else
|
|
|
|
len = sprintf(buf, "%d\n",
|
|
|
|
ha->ip_config.ipv6_cache_id);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV4_DHCP_DNS_ADDR_EN:
|
|
|
|
OP_STATE(ha->ip_config.tcp_options,
|
|
|
|
TCPOPT_DNS_SERVER_IP_EN, pval);
|
|
|
|
|
|
|
|
len = sprintf(buf, "%s\n", pval);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV4_DHCP_SLP_DA_EN:
|
|
|
|
OP_STATE(ha->ip_config.tcp_options,
|
|
|
|
TCPOPT_SLP_DA_INFO_EN, pval);
|
|
|
|
|
|
|
|
len = sprintf(buf, "%s\n", pval);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV4_TOS_EN:
|
|
|
|
OP_STATE(ha->ip_config.ipv4_options,
|
|
|
|
IPOPT_IPV4_TOS_EN, pval);
|
|
|
|
|
|
|
|
len = sprintf(buf, "%s\n", pval);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV4_TOS:
|
|
|
|
len = sprintf(buf, "%d\n", ha->ip_config.ipv4_tos);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV4_GRAT_ARP_EN:
|
|
|
|
OP_STATE(ha->ip_config.ipv4_options,
|
|
|
|
IPOPT_GRAT_ARP_EN, pval);
|
|
|
|
|
|
|
|
len = sprintf(buf, "%s\n", pval);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV4_DHCP_ALT_CLIENT_ID_EN:
|
|
|
|
OP_STATE(ha->ip_config.ipv4_options, IPOPT_ALT_CID_EN,
|
|
|
|
pval);
|
|
|
|
|
|
|
|
len = sprintf(buf, "%s\n", pval);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV4_DHCP_ALT_CLIENT_ID:
|
|
|
|
pval = (ha->ip_config.ipv4_alt_cid_len) ?
|
|
|
|
(char *)ha->ip_config.ipv4_alt_cid : "";
|
|
|
|
|
|
|
|
len = sprintf(buf, "%s\n", pval);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV4_DHCP_REQ_VENDOR_ID_EN:
|
|
|
|
OP_STATE(ha->ip_config.ipv4_options,
|
|
|
|
IPOPT_REQ_VID_EN, pval);
|
|
|
|
|
|
|
|
len = sprintf(buf, "%s\n", pval);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV4_DHCP_USE_VENDOR_ID_EN:
|
|
|
|
OP_STATE(ha->ip_config.ipv4_options,
|
|
|
|
IPOPT_USE_VID_EN, pval);
|
|
|
|
|
|
|
|
len = sprintf(buf, "%s\n", pval);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV4_DHCP_VENDOR_ID:
|
|
|
|
pval = (ha->ip_config.ipv4_vid_len) ?
|
|
|
|
(char *)ha->ip_config.ipv4_vid : "";
|
|
|
|
|
|
|
|
len = sprintf(buf, "%s\n", pval);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV4_DHCP_LEARN_IQN_EN:
|
|
|
|
OP_STATE(ha->ip_config.ipv4_options,
|
|
|
|
IPOPT_LEARN_IQN_EN, pval);
|
|
|
|
|
|
|
|
len = sprintf(buf, "%s\n", pval);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV4_FRAGMENT_DISABLE:
|
|
|
|
OP_STATE(~ha->ip_config.ipv4_options,
|
|
|
|
IPOPT_FRAGMENTATION_DISABLE, pval);
|
|
|
|
|
|
|
|
len = sprintf(buf, "%s\n", pval);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV4_IN_FORWARD_EN:
|
|
|
|
OP_STATE(ha->ip_config.ipv4_options,
|
|
|
|
IPOPT_IN_FORWARD_EN, pval);
|
|
|
|
|
|
|
|
len = sprintf(buf, "%s\n", pval);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_REDIRECT_EN:
|
|
|
|
if (iface->iface_type == ISCSI_IFACE_TYPE_IPV4) {
|
|
|
|
OP_STATE(ha->ip_config.ipv4_options,
|
|
|
|
IPOPT_ARP_REDIRECT_EN, pval);
|
|
|
|
} else {
|
|
|
|
OP_STATE(ha->ip_config.ipv6_options,
|
|
|
|
IPV6_OPT_REDIRECT_EN, pval);
|
|
|
|
}
|
|
|
|
len = sprintf(buf, "%s\n", pval);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV4_TTL:
|
|
|
|
len = sprintf(buf, "%d\n", ha->ip_config.ipv4_ttl);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV6_GRAT_NEIGHBOR_ADV_EN:
|
|
|
|
OP_STATE(ha->ip_config.ipv6_options,
|
|
|
|
IPV6_OPT_GRAT_NEIGHBOR_ADV_EN, pval);
|
|
|
|
|
|
|
|
len = sprintf(buf, "%s\n", pval);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV6_MLD_EN:
|
|
|
|
OP_STATE(ha->ip_config.ipv6_addl_options,
|
|
|
|
IPV6_ADDOPT_MLD_EN, pval);
|
|
|
|
|
|
|
|
len = sprintf(buf, "%s\n", pval);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV6_FLOW_LABEL:
|
|
|
|
len = sprintf(buf, "%u\n", ha->ip_config.ipv6_flow_lbl);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV6_TRAFFIC_CLASS:
|
2011-07-25 20:48:49 +02:00
|
|
|
len = sprintf(buf, "%d\n",
|
2013-10-18 15:01:42 +02:00
|
|
|
ha->ip_config.ipv6_traffic_class);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV6_HOP_LIMIT:
|
2011-07-25 20:48:49 +02:00
|
|
|
len = sprintf(buf, "%d\n",
|
2013-10-18 15:01:42 +02:00
|
|
|
ha->ip_config.ipv6_hop_limit);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV6_ND_REACHABLE_TMO:
|
2011-07-25 20:48:49 +02:00
|
|
|
len = sprintf(buf, "%d\n",
|
2013-10-18 15:01:42 +02:00
|
|
|
ha->ip_config.ipv6_nd_reach_time);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV6_ND_REXMIT_TIME:
|
2011-07-25 20:48:49 +02:00
|
|
|
len = sprintf(buf, "%d\n",
|
2013-10-18 15:01:42 +02:00
|
|
|
ha->ip_config.ipv6_nd_rexmit_timer);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV6_ND_STALE_TMO:
|
|
|
|
len = sprintf(buf, "%d\n",
|
|
|
|
ha->ip_config.ipv6_nd_stale_timeout);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV6_DUP_ADDR_DETECT_CNT:
|
|
|
|
len = sprintf(buf, "%d\n",
|
|
|
|
ha->ip_config.ipv6_dup_addr_detect_count);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV6_RTR_ADV_LINK_MTU:
|
|
|
|
len = sprintf(buf, "%d\n",
|
|
|
|
ha->ip_config.ipv6_gw_advrt_mtu);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
len = -ENOSYS;
|
|
|
|
}
|
|
|
|
} else if (param_type == ISCSI_IFACE_PARAM) {
|
|
|
|
switch (param) {
|
|
|
|
case ISCSI_IFACE_PARAM_DEF_TASKMGMT_TMO:
|
|
|
|
len = sprintf(buf, "%d\n", ha->ip_config.def_timeout);
|
|
|
|
break;
|
|
|
|
case ISCSI_IFACE_PARAM_HDRDGST_EN:
|
|
|
|
OP_STATE(ha->ip_config.iscsi_options,
|
|
|
|
ISCSIOPTS_HEADER_DIGEST_EN, pval);
|
|
|
|
|
|
|
|
len = sprintf(buf, "%s\n", pval);
|
|
|
|
break;
|
|
|
|
case ISCSI_IFACE_PARAM_DATADGST_EN:
|
|
|
|
OP_STATE(ha->ip_config.iscsi_options,
|
|
|
|
ISCSIOPTS_DATA_DIGEST_EN, pval);
|
|
|
|
|
|
|
|
len = sprintf(buf, "%s\n", pval);
|
|
|
|
break;
|
|
|
|
case ISCSI_IFACE_PARAM_IMM_DATA_EN:
|
|
|
|
OP_STATE(ha->ip_config.iscsi_options,
|
|
|
|
ISCSIOPTS_IMMEDIATE_DATA_EN, pval);
|
|
|
|
|
|
|
|
len = sprintf(buf, "%s\n", pval);
|
|
|
|
break;
|
|
|
|
case ISCSI_IFACE_PARAM_INITIAL_R2T_EN:
|
|
|
|
OP_STATE(ha->ip_config.iscsi_options,
|
|
|
|
ISCSIOPTS_INITIAL_R2T_EN, pval);
|
|
|
|
|
|
|
|
len = sprintf(buf, "%s\n", pval);
|
|
|
|
break;
|
|
|
|
case ISCSI_IFACE_PARAM_DATASEQ_INORDER_EN:
|
|
|
|
OP_STATE(ha->ip_config.iscsi_options,
|
|
|
|
ISCSIOPTS_DATA_SEQ_INORDER_EN, pval);
|
|
|
|
|
|
|
|
len = sprintf(buf, "%s\n", pval);
|
|
|
|
break;
|
|
|
|
case ISCSI_IFACE_PARAM_PDU_INORDER_EN:
|
|
|
|
OP_STATE(ha->ip_config.iscsi_options,
|
|
|
|
ISCSIOPTS_DATA_PDU_INORDER_EN, pval);
|
|
|
|
|
|
|
|
len = sprintf(buf, "%s\n", pval);
|
|
|
|
break;
|
|
|
|
case ISCSI_IFACE_PARAM_ERL:
|
|
|
|
len = sprintf(buf, "%d\n",
|
|
|
|
(ha->ip_config.iscsi_options &
|
|
|
|
ISCSIOPTS_ERL));
|
|
|
|
break;
|
|
|
|
case ISCSI_IFACE_PARAM_MAX_RECV_DLENGTH:
|
|
|
|
len = sprintf(buf, "%u\n",
|
|
|
|
ha->ip_config.iscsi_max_pdu_size *
|
|
|
|
BYTE_UNITS);
|
|
|
|
break;
|
|
|
|
case ISCSI_IFACE_PARAM_FIRST_BURST:
|
|
|
|
len = sprintf(buf, "%u\n",
|
|
|
|
ha->ip_config.iscsi_first_burst_len *
|
|
|
|
BYTE_UNITS);
|
|
|
|
break;
|
|
|
|
case ISCSI_IFACE_PARAM_MAX_R2T:
|
|
|
|
len = sprintf(buf, "%d\n",
|
|
|
|
ha->ip_config.iscsi_max_outstnd_r2t);
|
|
|
|
break;
|
|
|
|
case ISCSI_IFACE_PARAM_MAX_BURST:
|
|
|
|
len = sprintf(buf, "%u\n",
|
|
|
|
ha->ip_config.iscsi_max_burst_len *
|
|
|
|
BYTE_UNITS);
|
|
|
|
break;
|
|
|
|
case ISCSI_IFACE_PARAM_CHAP_AUTH_EN:
|
|
|
|
OP_STATE(ha->ip_config.iscsi_options,
|
|
|
|
ISCSIOPTS_CHAP_AUTH_EN, pval);
|
|
|
|
|
|
|
|
len = sprintf(buf, "%s\n", pval);
|
|
|
|
break;
|
|
|
|
case ISCSI_IFACE_PARAM_BIDI_CHAP_EN:
|
|
|
|
OP_STATE(ha->ip_config.iscsi_options,
|
|
|
|
ISCSIOPTS_BIDI_CHAP_EN, pval);
|
|
|
|
|
|
|
|
len = sprintf(buf, "%s\n", pval);
|
|
|
|
break;
|
|
|
|
case ISCSI_IFACE_PARAM_DISCOVERY_AUTH_OPTIONAL:
|
|
|
|
OP_STATE(ha->ip_config.iscsi_options,
|
|
|
|
ISCSIOPTS_DISCOVERY_AUTH_EN, pval);
|
|
|
|
|
|
|
|
len = sprintf(buf, "%s\n", pval);
|
|
|
|
break;
|
|
|
|
case ISCSI_IFACE_PARAM_DISCOVERY_LOGOUT_EN:
|
|
|
|
OP_STATE(ha->ip_config.iscsi_options,
|
|
|
|
ISCSIOPTS_DISCOVERY_LOGOUT_EN, pval);
|
|
|
|
|
|
|
|
len = sprintf(buf, "%s\n", pval);
|
|
|
|
break;
|
|
|
|
case ISCSI_IFACE_PARAM_STRICT_LOGIN_COMP_EN:
|
|
|
|
OP_STATE(ha->ip_config.iscsi_options,
|
|
|
|
ISCSIOPTS_STRICT_LOGIN_COMP_EN, pval);
|
|
|
|
|
|
|
|
len = sprintf(buf, "%s\n", pval);
|
|
|
|
break;
|
|
|
|
case ISCSI_IFACE_PARAM_INITIATOR_NAME:
|
|
|
|
len = sprintf(buf, "%s\n", ha->ip_config.iscsi_name);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
len = -ENOSYS;
|
|
|
|
}
|
2011-07-25 20:48:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
2011-07-25 20:48:53 +02:00
|
|
|
static struct iscsi_endpoint *
|
|
|
|
qla4xxx_ep_connect(struct Scsi_Host *shost, struct sockaddr *dst_addr,
|
|
|
|
int non_blocking)
|
2009-07-15 22:02:59 +02:00
|
|
|
{
|
2011-07-25 20:48:53 +02:00
|
|
|
int ret;
|
|
|
|
struct iscsi_endpoint *ep;
|
|
|
|
struct qla_endpoint *qla_ep;
|
|
|
|
struct scsi_qla_host *ha;
|
|
|
|
struct sockaddr_in *addr;
|
|
|
|
struct sockaddr_in6 *addr6;
|
2009-07-15 22:02:59 +02:00
|
|
|
|
2011-07-25 20:48:53 +02:00
|
|
|
if (!shost) {
|
|
|
|
ret = -ENXIO;
|
2013-12-16 12:49:48 +01:00
|
|
|
pr_err("%s: shost is NULL\n", __func__);
|
2011-07-25 20:48:53 +02:00
|
|
|
return ERR_PTR(ret);
|
|
|
|
}
|
2009-07-15 22:02:59 +02:00
|
|
|
|
2011-07-25 20:48:53 +02:00
|
|
|
ha = iscsi_host_priv(shost);
|
|
|
|
ep = iscsi_create_endpoint(sizeof(struct qla_endpoint));
|
|
|
|
if (!ep) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
return ERR_PTR(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
qla_ep = ep->dd_data;
|
|
|
|
memset(qla_ep, 0, sizeof(struct qla_endpoint));
|
|
|
|
if (dst_addr->sa_family == AF_INET) {
|
|
|
|
memcpy(&qla_ep->dst_addr, dst_addr, sizeof(struct sockaddr_in));
|
|
|
|
addr = (struct sockaddr_in *)&qla_ep->dst_addr;
|
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha, "%s: %pI4\n", __func__,
|
|
|
|
(char *)&addr->sin_addr));
|
|
|
|
} else if (dst_addr->sa_family == AF_INET6) {
|
|
|
|
memcpy(&qla_ep->dst_addr, dst_addr,
|
|
|
|
sizeof(struct sockaddr_in6));
|
|
|
|
addr6 = (struct sockaddr_in6 *)&qla_ep->dst_addr;
|
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha, "%s: %pI6\n", __func__,
|
|
|
|
(char *)&addr6->sin6_addr));
|
2013-12-16 12:49:48 +01:00
|
|
|
} else {
|
|
|
|
ql4_printk(KERN_WARNING, ha, "%s: Invalid endpoint\n",
|
|
|
|
__func__);
|
2011-07-25 20:48:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
qla_ep->host = shost;
|
|
|
|
|
|
|
|
return ep;
|
2009-07-15 22:02:59 +02:00
|
|
|
}
|
|
|
|
|
2011-07-25 20:48:53 +02:00
|
|
|
static int qla4xxx_ep_poll(struct iscsi_endpoint *ep, int timeout_ms)
|
2006-09-19 19:28:00 +02:00
|
|
|
{
|
2011-07-25 20:48:53 +02:00
|
|
|
struct qla_endpoint *qla_ep;
|
|
|
|
struct scsi_qla_host *ha;
|
|
|
|
int ret = 0;
|
2006-09-19 19:28:00 +02:00
|
|
|
|
2011-07-25 20:48:53 +02:00
|
|
|
qla_ep = ep->dd_data;
|
|
|
|
ha = to_qla_host(qla_ep->host);
|
2013-12-16 12:49:48 +01:00
|
|
|
DEBUG2(pr_info_ratelimited("%s: host: %ld\n", __func__, ha->host_no));
|
2011-07-25 20:48:53 +02:00
|
|
|
|
2011-12-02 04:38:41 +01:00
|
|
|
if (adapter_up(ha) && !test_bit(AF_BUILD_DDB_LIST, &ha->flags))
|
2011-07-25 20:48:53 +02:00
|
|
|
ret = 1;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void qla4xxx_ep_disconnect(struct iscsi_endpoint *ep)
|
|
|
|
{
|
2013-12-16 12:49:48 +01:00
|
|
|
struct qla_endpoint *qla_ep;
|
|
|
|
struct scsi_qla_host *ha;
|
|
|
|
|
|
|
|
qla_ep = ep->dd_data;
|
|
|
|
ha = to_qla_host(qla_ep->host);
|
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha, "%s: host: %ld\n", __func__,
|
|
|
|
ha->host_no));
|
2011-07-25 20:48:53 +02:00
|
|
|
iscsi_destroy_endpoint(ep);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int qla4xxx_get_ep_param(struct iscsi_endpoint *ep,
|
|
|
|
enum iscsi_param param,
|
|
|
|
char *buf)
|
|
|
|
{
|
|
|
|
struct qla_endpoint *qla_ep = ep->dd_data;
|
|
|
|
struct sockaddr *dst_addr;
|
2013-12-16 12:49:48 +01:00
|
|
|
struct scsi_qla_host *ha;
|
2011-07-25 20:48:53 +02:00
|
|
|
|
2014-04-10 03:12:27 +02:00
|
|
|
if (!qla_ep)
|
|
|
|
return -ENOTCONN;
|
|
|
|
|
2013-12-16 12:49:48 +01:00
|
|
|
ha = to_qla_host(qla_ep->host);
|
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha, "%s: host: %ld\n", __func__,
|
|
|
|
ha->host_no));
|
2011-07-25 20:48:53 +02:00
|
|
|
|
|
|
|
switch (param) {
|
|
|
|
case ISCSI_PARAM_CONN_PORT:
|
|
|
|
case ISCSI_PARAM_CONN_ADDRESS:
|
|
|
|
dst_addr = (struct sockaddr *)&qla_ep->dst_addr;
|
|
|
|
if (!dst_addr)
|
|
|
|
return -ENOTCONN;
|
|
|
|
|
|
|
|
return iscsi_conn_get_addr_param((struct sockaddr_storage *)
|
|
|
|
&qla_ep->dst_addr, param, buf);
|
|
|
|
default:
|
|
|
|
return -ENOSYS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void qla4xxx_conn_get_stats(struct iscsi_cls_conn *cls_conn,
|
|
|
|
struct iscsi_stats *stats)
|
|
|
|
{
|
|
|
|
struct iscsi_session *sess;
|
|
|
|
struct iscsi_cls_session *cls_sess;
|
|
|
|
struct ddb_entry *ddb_entry;
|
|
|
|
struct scsi_qla_host *ha;
|
|
|
|
struct ql_iscsi_stats *ql_iscsi_stats;
|
|
|
|
int stats_size;
|
|
|
|
int ret;
|
|
|
|
dma_addr_t iscsi_stats_dma;
|
|
|
|
|
|
|
|
cls_sess = iscsi_conn_to_session(cls_conn);
|
|
|
|
sess = cls_sess->dd_data;
|
|
|
|
ddb_entry = sess->dd_data;
|
|
|
|
ha = ddb_entry->ha;
|
|
|
|
|
2013-12-16 12:49:48 +01:00
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha, "%s: host: %ld\n", __func__,
|
|
|
|
ha->host_no));
|
2011-07-25 20:48:53 +02:00
|
|
|
stats_size = PAGE_ALIGN(sizeof(struct ql_iscsi_stats));
|
|
|
|
/* Allocate memory */
|
|
|
|
ql_iscsi_stats = dma_alloc_coherent(&ha->pdev->dev, stats_size,
|
|
|
|
&iscsi_stats_dma, GFP_KERNEL);
|
|
|
|
if (!ql_iscsi_stats) {
|
|
|
|
ql4_printk(KERN_ERR, ha,
|
|
|
|
"Unable to allocate memory for iscsi stats\n");
|
|
|
|
goto exit_get_stats;
|
2008-01-31 20:36:47 +01:00
|
|
|
}
|
2011-07-25 20:48:53 +02:00
|
|
|
|
|
|
|
ret = qla4xxx_get_mgmt_data(ha, ddb_entry->fw_ddb_index, stats_size,
|
|
|
|
iscsi_stats_dma);
|
|
|
|
if (ret != QLA_SUCCESS) {
|
|
|
|
ql4_printk(KERN_ERR, ha,
|
2012-04-24 17:24:16 +02:00
|
|
|
"Unable to retrieve iscsi stats\n");
|
2011-07-25 20:48:53 +02:00
|
|
|
goto free_stats;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* octets */
|
|
|
|
stats->txdata_octets = le64_to_cpu(ql_iscsi_stats->tx_data_octets);
|
|
|
|
stats->rxdata_octets = le64_to_cpu(ql_iscsi_stats->rx_data_octets);
|
|
|
|
/* xmit pdus */
|
|
|
|
stats->noptx_pdus = le32_to_cpu(ql_iscsi_stats->tx_nopout_pdus);
|
|
|
|
stats->scsicmd_pdus = le32_to_cpu(ql_iscsi_stats->tx_scsi_cmd_pdus);
|
|
|
|
stats->tmfcmd_pdus = le32_to_cpu(ql_iscsi_stats->tx_tmf_cmd_pdus);
|
|
|
|
stats->login_pdus = le32_to_cpu(ql_iscsi_stats->tx_login_cmd_pdus);
|
|
|
|
stats->text_pdus = le32_to_cpu(ql_iscsi_stats->tx_text_cmd_pdus);
|
|
|
|
stats->dataout_pdus = le32_to_cpu(ql_iscsi_stats->tx_scsi_write_pdus);
|
|
|
|
stats->logout_pdus = le32_to_cpu(ql_iscsi_stats->tx_logout_cmd_pdus);
|
|
|
|
stats->snack_pdus = le32_to_cpu(ql_iscsi_stats->tx_snack_req_pdus);
|
|
|
|
/* recv pdus */
|
|
|
|
stats->noprx_pdus = le32_to_cpu(ql_iscsi_stats->rx_nopin_pdus);
|
|
|
|
stats->scsirsp_pdus = le32_to_cpu(ql_iscsi_stats->rx_scsi_resp_pdus);
|
|
|
|
stats->tmfrsp_pdus = le32_to_cpu(ql_iscsi_stats->rx_tmf_resp_pdus);
|
|
|
|
stats->textrsp_pdus = le32_to_cpu(ql_iscsi_stats->rx_text_resp_pdus);
|
|
|
|
stats->datain_pdus = le32_to_cpu(ql_iscsi_stats->rx_scsi_read_pdus);
|
|
|
|
stats->logoutrsp_pdus =
|
|
|
|
le32_to_cpu(ql_iscsi_stats->rx_logout_resp_pdus);
|
|
|
|
stats->r2t_pdus = le32_to_cpu(ql_iscsi_stats->rx_r2t_pdus);
|
|
|
|
stats->async_pdus = le32_to_cpu(ql_iscsi_stats->rx_async_pdus);
|
|
|
|
stats->rjt_pdus = le32_to_cpu(ql_iscsi_stats->rx_reject_pdus);
|
|
|
|
|
|
|
|
free_stats:
|
|
|
|
dma_free_coherent(&ha->pdev->dev, stats_size, ql_iscsi_stats,
|
|
|
|
iscsi_stats_dma);
|
|
|
|
exit_get_stats:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum blk_eh_timer_return qla4xxx_eh_cmd_timed_out(struct scsi_cmnd *sc)
|
|
|
|
{
|
|
|
|
struct iscsi_cls_session *session;
|
|
|
|
struct iscsi_session *sess;
|
|
|
|
unsigned long flags;
|
|
|
|
enum blk_eh_timer_return ret = BLK_EH_NOT_HANDLED;
|
|
|
|
|
|
|
|
session = starget_to_session(scsi_target(sc->device));
|
|
|
|
sess = session->dd_data;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&session->lock, flags);
|
|
|
|
if (session->state == ISCSI_SESSION_FAILED)
|
|
|
|
ret = BLK_EH_RESET_TIMER;
|
|
|
|
spin_unlock_irqrestore(&session->lock, flags);
|
|
|
|
|
|
|
|
return ret;
|
2006-09-19 19:28:00 +02:00
|
|
|
}
|
|
|
|
|
2012-01-19 12:06:56 +01:00
|
|
|
static void qla4xxx_set_port_speed(struct Scsi_Host *shost)
|
|
|
|
{
|
|
|
|
struct scsi_qla_host *ha = to_qla_host(shost);
|
2012-03-02 10:55:31 +01:00
|
|
|
struct iscsi_cls_host *ihost = shost->shost_data;
|
2012-01-19 12:06:56 +01:00
|
|
|
uint32_t speed = ISCSI_PORT_SPEED_UNKNOWN;
|
|
|
|
|
|
|
|
qla4xxx_get_firmware_state(ha);
|
|
|
|
|
|
|
|
switch (ha->addl_fw_state & 0x0F00) {
|
|
|
|
case FW_ADDSTATE_LINK_SPEED_10MBPS:
|
|
|
|
speed = ISCSI_PORT_SPEED_10MBPS;
|
|
|
|
break;
|
|
|
|
case FW_ADDSTATE_LINK_SPEED_100MBPS:
|
|
|
|
speed = ISCSI_PORT_SPEED_100MBPS;
|
|
|
|
break;
|
|
|
|
case FW_ADDSTATE_LINK_SPEED_1GBPS:
|
|
|
|
speed = ISCSI_PORT_SPEED_1GBPS;
|
|
|
|
break;
|
|
|
|
case FW_ADDSTATE_LINK_SPEED_10GBPS:
|
|
|
|
speed = ISCSI_PORT_SPEED_10GBPS;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ihost->port_speed = speed;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void qla4xxx_set_port_state(struct Scsi_Host *shost)
|
|
|
|
{
|
|
|
|
struct scsi_qla_host *ha = to_qla_host(shost);
|
2012-03-02 10:55:31 +01:00
|
|
|
struct iscsi_cls_host *ihost = shost->shost_data;
|
2012-01-19 12:06:56 +01:00
|
|
|
uint32_t state = ISCSI_PORT_STATE_DOWN;
|
|
|
|
|
|
|
|
if (test_bit(AF_LINK_UP, &ha->flags))
|
|
|
|
state = ISCSI_PORT_STATE_UP;
|
|
|
|
|
|
|
|
ihost->port_state = state;
|
|
|
|
}
|
|
|
|
|
2007-05-30 19:57:09 +02:00
|
|
|
static int qla4xxx_host_get_param(struct Scsi_Host *shost,
|
|
|
|
enum iscsi_host_param param, char *buf)
|
|
|
|
{
|
|
|
|
struct scsi_qla_host *ha = to_qla_host(shost);
|
|
|
|
int len;
|
|
|
|
|
|
|
|
switch (param) {
|
|
|
|
case ISCSI_HOST_PARAM_HWADDRESS:
|
2007-12-25 06:28:09 +01:00
|
|
|
len = sysfs_format_mac(buf, ha->my_mac, MAC_ADDR_LEN);
|
2007-05-30 19:57:13 +02:00
|
|
|
break;
|
2007-05-30 19:57:24 +02:00
|
|
|
case ISCSI_HOST_PARAM_IPADDRESS:
|
2011-07-25 20:48:39 +02:00
|
|
|
len = sprintf(buf, "%pI4\n", &ha->ip_config.ip_address);
|
2007-05-30 19:57:24 +02:00
|
|
|
break;
|
2007-05-30 19:57:13 +02:00
|
|
|
case ISCSI_HOST_PARAM_INITIATOR_NAME:
|
2007-05-30 19:57:24 +02:00
|
|
|
len = sprintf(buf, "%s\n", ha->name_string);
|
2007-05-30 19:57:09 +02:00
|
|
|
break;
|
2012-01-19 12:06:56 +01:00
|
|
|
case ISCSI_HOST_PARAM_PORT_STATE:
|
|
|
|
qla4xxx_set_port_state(shost);
|
|
|
|
len = sprintf(buf, "%s\n", iscsi_get_port_state_name(shost));
|
|
|
|
break;
|
|
|
|
case ISCSI_HOST_PARAM_PORT_SPEED:
|
|
|
|
qla4xxx_set_port_speed(shost);
|
|
|
|
len = sprintf(buf, "%s\n", iscsi_get_port_speed_name(shost));
|
|
|
|
break;
|
2007-05-30 19:57:09 +02:00
|
|
|
default:
|
|
|
|
return -ENOSYS;
|
|
|
|
}
|
|
|
|
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
2011-07-25 20:48:41 +02:00
|
|
|
static void qla4xxx_create_ipv4_iface(struct scsi_qla_host *ha)
|
|
|
|
{
|
|
|
|
if (ha->iface_ipv4)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* IPv4 */
|
|
|
|
ha->iface_ipv4 = iscsi_create_iface(ha->host,
|
|
|
|
&qla4xxx_iscsi_transport,
|
|
|
|
ISCSI_IFACE_TYPE_IPV4, 0, 0);
|
|
|
|
if (!ha->iface_ipv4)
|
|
|
|
ql4_printk(KERN_ERR, ha, "Could not create IPv4 iSCSI "
|
|
|
|
"iface0.\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void qla4xxx_create_ipv6_iface(struct scsi_qla_host *ha)
|
|
|
|
{
|
|
|
|
if (!ha->iface_ipv6_0)
|
|
|
|
/* IPv6 iface-0 */
|
|
|
|
ha->iface_ipv6_0 = iscsi_create_iface(ha->host,
|
|
|
|
&qla4xxx_iscsi_transport,
|
|
|
|
ISCSI_IFACE_TYPE_IPV6, 0,
|
|
|
|
0);
|
|
|
|
if (!ha->iface_ipv6_0)
|
|
|
|
ql4_printk(KERN_ERR, ha, "Could not create IPv6 iSCSI "
|
|
|
|
"iface0.\n");
|
|
|
|
|
|
|
|
if (!ha->iface_ipv6_1)
|
|
|
|
/* IPv6 iface-1 */
|
|
|
|
ha->iface_ipv6_1 = iscsi_create_iface(ha->host,
|
|
|
|
&qla4xxx_iscsi_transport,
|
|
|
|
ISCSI_IFACE_TYPE_IPV6, 1,
|
|
|
|
0);
|
|
|
|
if (!ha->iface_ipv6_1)
|
|
|
|
ql4_printk(KERN_ERR, ha, "Could not create IPv6 iSCSI "
|
|
|
|
"iface1.\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void qla4xxx_create_ifaces(struct scsi_qla_host *ha)
|
|
|
|
{
|
|
|
|
if (ha->ip_config.ipv4_options & IPOPT_IPV4_PROTOCOL_ENABLE)
|
|
|
|
qla4xxx_create_ipv4_iface(ha);
|
|
|
|
|
|
|
|
if (ha->ip_config.ipv6_options & IPV6_OPT_IPV6_PROTOCOL_ENABLE)
|
|
|
|
qla4xxx_create_ipv6_iface(ha);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void qla4xxx_destroy_ipv4_iface(struct scsi_qla_host *ha)
|
|
|
|
{
|
|
|
|
if (ha->iface_ipv4) {
|
|
|
|
iscsi_destroy_iface(ha->iface_ipv4);
|
|
|
|
ha->iface_ipv4 = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void qla4xxx_destroy_ipv6_iface(struct scsi_qla_host *ha)
|
|
|
|
{
|
|
|
|
if (ha->iface_ipv6_0) {
|
|
|
|
iscsi_destroy_iface(ha->iface_ipv6_0);
|
|
|
|
ha->iface_ipv6_0 = NULL;
|
|
|
|
}
|
|
|
|
if (ha->iface_ipv6_1) {
|
|
|
|
iscsi_destroy_iface(ha->iface_ipv6_1);
|
|
|
|
ha->iface_ipv6_1 = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void qla4xxx_destroy_ifaces(struct scsi_qla_host *ha)
|
|
|
|
{
|
|
|
|
qla4xxx_destroy_ipv4_iface(ha);
|
|
|
|
qla4xxx_destroy_ipv6_iface(ha);
|
|
|
|
}
|
|
|
|
|
2011-07-25 20:48:38 +02:00
|
|
|
static void qla4xxx_set_ipv6(struct scsi_qla_host *ha,
|
|
|
|
struct iscsi_iface_param_info *iface_param,
|
|
|
|
struct addr_ctrl_blk *init_fw_cb)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* iface_num 0 is valid for IPv6 Addr, linklocal, router, autocfg.
|
|
|
|
* iface_num 1 is valid only for IPv6 Addr.
|
|
|
|
*/
|
|
|
|
switch (iface_param->param) {
|
|
|
|
case ISCSI_NET_PARAM_IPV6_ADDR:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
/* IPv6 Addr 1 */
|
|
|
|
memcpy(init_fw_cb->ipv6_addr1, iface_param->value,
|
|
|
|
sizeof(init_fw_cb->ipv6_addr1));
|
|
|
|
else
|
|
|
|
/* IPv6 Addr 0 */
|
|
|
|
memcpy(init_fw_cb->ipv6_addr0, iface_param->value,
|
|
|
|
sizeof(init_fw_cb->ipv6_addr0));
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV6_LINKLOCAL:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
memcpy(init_fw_cb->ipv6_if_id, &iface_param->value[8],
|
|
|
|
sizeof(init_fw_cb->ipv6_if_id));
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV6_ROUTER:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
memcpy(init_fw_cb->ipv6_dflt_rtr_addr, iface_param->value,
|
|
|
|
sizeof(init_fw_cb->ipv6_dflt_rtr_addr));
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV6_ADDR_AUTOCFG:
|
|
|
|
/* Autocfg applies to even interface */
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (iface_param->value[0] == ISCSI_IPV6_AUTOCFG_DISABLE)
|
|
|
|
init_fw_cb->ipv6_addtl_opts &=
|
|
|
|
cpu_to_le16(
|
|
|
|
~IPV6_ADDOPT_NEIGHBOR_DISCOVERY_ADDR_ENABLE);
|
|
|
|
else if (iface_param->value[0] == ISCSI_IPV6_AUTOCFG_ND_ENABLE)
|
|
|
|
init_fw_cb->ipv6_addtl_opts |=
|
|
|
|
cpu_to_le16(
|
|
|
|
IPV6_ADDOPT_NEIGHBOR_DISCOVERY_ADDR_ENABLE);
|
|
|
|
else
|
2013-10-18 15:01:42 +02:00
|
|
|
ql4_printk(KERN_ERR, ha,
|
|
|
|
"Invalid autocfg setting for IPv6 addr\n");
|
2011-07-25 20:48:38 +02:00
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV6_LINKLOCAL_AUTOCFG:
|
|
|
|
/* Autocfg applies to even interface */
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (iface_param->value[0] ==
|
|
|
|
ISCSI_IPV6_LINKLOCAL_AUTOCFG_ENABLE)
|
|
|
|
init_fw_cb->ipv6_addtl_opts |= cpu_to_le16(
|
|
|
|
IPV6_ADDOPT_AUTOCONFIG_LINK_LOCAL_ADDR);
|
|
|
|
else if (iface_param->value[0] ==
|
|
|
|
ISCSI_IPV6_LINKLOCAL_AUTOCFG_DISABLE)
|
|
|
|
init_fw_cb->ipv6_addtl_opts &= cpu_to_le16(
|
|
|
|
~IPV6_ADDOPT_AUTOCONFIG_LINK_LOCAL_ADDR);
|
|
|
|
else
|
2013-10-18 15:01:42 +02:00
|
|
|
ql4_printk(KERN_ERR, ha,
|
|
|
|
"Invalid autocfg setting for IPv6 linklocal addr\n");
|
2011-07-25 20:48:38 +02:00
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV6_ROUTER_AUTOCFG:
|
|
|
|
/* Autocfg applies to even interface */
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (iface_param->value[0] == ISCSI_IPV6_ROUTER_AUTOCFG_ENABLE)
|
|
|
|
memset(init_fw_cb->ipv6_dflt_rtr_addr, 0,
|
|
|
|
sizeof(init_fw_cb->ipv6_dflt_rtr_addr));
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IFACE_ENABLE:
|
2011-07-25 20:48:41 +02:00
|
|
|
if (iface_param->value[0] == ISCSI_IFACE_ENABLE) {
|
2011-07-25 20:48:38 +02:00
|
|
|
init_fw_cb->ipv6_opts |=
|
|
|
|
cpu_to_le16(IPV6_OPT_IPV6_PROTOCOL_ENABLE);
|
2011-07-25 20:48:41 +02:00
|
|
|
qla4xxx_create_ipv6_iface(ha);
|
|
|
|
} else {
|
2011-07-25 20:48:38 +02:00
|
|
|
init_fw_cb->ipv6_opts &=
|
|
|
|
cpu_to_le16(~IPV6_OPT_IPV6_PROTOCOL_ENABLE &
|
|
|
|
0xFFFF);
|
2011-07-25 20:48:41 +02:00
|
|
|
qla4xxx_destroy_ipv6_iface(ha);
|
|
|
|
}
|
2011-07-25 20:48:38 +02:00
|
|
|
break;
|
2011-10-12 00:55:11 +02:00
|
|
|
case ISCSI_NET_PARAM_VLAN_TAG:
|
2011-07-25 20:48:38 +02:00
|
|
|
if (iface_param->len != sizeof(init_fw_cb->ipv6_vlan_tag))
|
|
|
|
break;
|
2011-07-25 20:48:49 +02:00
|
|
|
init_fw_cb->ipv6_vlan_tag =
|
|
|
|
cpu_to_be16(*(uint16_t *)iface_param->value);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_VLAN_ENABLED:
|
|
|
|
if (iface_param->value[0] == ISCSI_VLAN_ENABLE)
|
|
|
|
init_fw_cb->ipv6_opts |=
|
|
|
|
cpu_to_le16(IPV6_OPT_VLAN_TAGGING_ENABLE);
|
|
|
|
else
|
|
|
|
init_fw_cb->ipv6_opts &=
|
|
|
|
cpu_to_le16(~IPV6_OPT_VLAN_TAGGING_ENABLE);
|
2011-07-25 20:48:38 +02:00
|
|
|
break;
|
2011-08-01 12:26:13 +02:00
|
|
|
case ISCSI_NET_PARAM_MTU:
|
|
|
|
init_fw_cb->eth_mtu_size =
|
|
|
|
cpu_to_le16(*(uint16_t *)iface_param->value);
|
|
|
|
break;
|
2011-08-01 12:26:19 +02:00
|
|
|
case ISCSI_NET_PARAM_PORT:
|
|
|
|
/* Autocfg applies to even interface */
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
|
|
|
|
init_fw_cb->ipv6_port =
|
|
|
|
cpu_to_le16(*(uint16_t *)iface_param->value);
|
|
|
|
break;
|
2013-10-18 15:01:42 +02:00
|
|
|
case ISCSI_NET_PARAM_DELAYED_ACK_EN:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
if (iface_param->value[0] == ISCSI_NET_PARAM_DISABLE)
|
|
|
|
init_fw_cb->ipv6_tcp_opts |=
|
|
|
|
cpu_to_le16(IPV6_TCPOPT_DELAYED_ACK_DISABLE);
|
|
|
|
else
|
|
|
|
init_fw_cb->ipv6_tcp_opts &=
|
2013-12-16 12:49:53 +01:00
|
|
|
cpu_to_le16(~IPV6_TCPOPT_DELAYED_ACK_DISABLE &
|
|
|
|
0xFFFF);
|
2013-10-18 15:01:42 +02:00
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_TCP_NAGLE_DISABLE:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
if (iface_param->value[0] == ISCSI_NET_PARAM_DISABLE)
|
|
|
|
init_fw_cb->ipv6_tcp_opts |=
|
|
|
|
cpu_to_le16(IPV6_TCPOPT_NAGLE_ALGO_DISABLE);
|
|
|
|
else
|
|
|
|
init_fw_cb->ipv6_tcp_opts &=
|
|
|
|
cpu_to_le16(~IPV6_TCPOPT_NAGLE_ALGO_DISABLE);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_TCP_WSF_DISABLE:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
if (iface_param->value[0] == ISCSI_NET_PARAM_DISABLE)
|
|
|
|
init_fw_cb->ipv6_tcp_opts |=
|
|
|
|
cpu_to_le16(IPV6_TCPOPT_WINDOW_SCALE_DISABLE);
|
|
|
|
else
|
|
|
|
init_fw_cb->ipv6_tcp_opts &=
|
|
|
|
cpu_to_le16(~IPV6_TCPOPT_WINDOW_SCALE_DISABLE);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_TCP_WSF:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
init_fw_cb->ipv6_tcp_wsf = iface_param->value[0];
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_TCP_TIMER_SCALE:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
init_fw_cb->ipv6_tcp_opts &=
|
|
|
|
cpu_to_le16(~IPV6_TCPOPT_TIMER_SCALE);
|
|
|
|
init_fw_cb->ipv6_tcp_opts |=
|
|
|
|
cpu_to_le16((iface_param->value[0] << 1) &
|
|
|
|
IPV6_TCPOPT_TIMER_SCALE);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_TCP_TIMESTAMP_EN:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
if (iface_param->value[0] == ISCSI_NET_PARAM_ENABLE)
|
|
|
|
init_fw_cb->ipv6_tcp_opts |=
|
|
|
|
cpu_to_le16(IPV6_TCPOPT_TIMESTAMP_EN);
|
|
|
|
else
|
|
|
|
init_fw_cb->ipv6_tcp_opts &=
|
|
|
|
cpu_to_le16(~IPV6_TCPOPT_TIMESTAMP_EN);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV6_GRAT_NEIGHBOR_ADV_EN:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
if (iface_param->value[0] == ISCSI_NET_PARAM_ENABLE)
|
|
|
|
init_fw_cb->ipv6_opts |=
|
|
|
|
cpu_to_le16(IPV6_OPT_GRAT_NEIGHBOR_ADV_EN);
|
|
|
|
else
|
|
|
|
init_fw_cb->ipv6_opts &=
|
|
|
|
cpu_to_le16(~IPV6_OPT_GRAT_NEIGHBOR_ADV_EN);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_REDIRECT_EN:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
if (iface_param->value[0] == ISCSI_NET_PARAM_ENABLE)
|
|
|
|
init_fw_cb->ipv6_opts |=
|
|
|
|
cpu_to_le16(IPV6_OPT_REDIRECT_EN);
|
|
|
|
else
|
|
|
|
init_fw_cb->ipv6_opts &=
|
|
|
|
cpu_to_le16(~IPV6_OPT_REDIRECT_EN);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV6_MLD_EN:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
if (iface_param->value[0] == ISCSI_NET_PARAM_ENABLE)
|
|
|
|
init_fw_cb->ipv6_addtl_opts |=
|
|
|
|
cpu_to_le16(IPV6_ADDOPT_MLD_EN);
|
|
|
|
else
|
|
|
|
init_fw_cb->ipv6_addtl_opts &=
|
|
|
|
cpu_to_le16(~IPV6_ADDOPT_MLD_EN);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV6_FLOW_LABEL:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
init_fw_cb->ipv6_flow_lbl =
|
|
|
|
cpu_to_le16(*(uint16_t *)iface_param->value);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV6_TRAFFIC_CLASS:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
init_fw_cb->ipv6_traffic_class = iface_param->value[0];
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV6_HOP_LIMIT:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
init_fw_cb->ipv6_hop_limit = iface_param->value[0];
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV6_ND_REACHABLE_TMO:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
init_fw_cb->ipv6_nd_reach_time =
|
|
|
|
cpu_to_le32(*(uint32_t *)iface_param->value);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV6_ND_REXMIT_TIME:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
init_fw_cb->ipv6_nd_rexmit_timer =
|
|
|
|
cpu_to_le32(*(uint32_t *)iface_param->value);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV6_ND_STALE_TMO:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
init_fw_cb->ipv6_nd_stale_timeout =
|
|
|
|
cpu_to_le32(*(uint32_t *)iface_param->value);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV6_DUP_ADDR_DETECT_CNT:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
init_fw_cb->ipv6_dup_addr_detect_count = iface_param->value[0];
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV6_RTR_ADV_LINK_MTU:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
init_fw_cb->ipv6_gw_advrt_mtu =
|
|
|
|
cpu_to_le32(*(uint32_t *)iface_param->value);
|
|
|
|
break;
|
2011-07-25 20:48:38 +02:00
|
|
|
default:
|
|
|
|
ql4_printk(KERN_ERR, ha, "Unknown IPv6 param = %d\n",
|
|
|
|
iface_param->param);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void qla4xxx_set_ipv4(struct scsi_qla_host *ha,
|
|
|
|
struct iscsi_iface_param_info *iface_param,
|
|
|
|
struct addr_ctrl_blk *init_fw_cb)
|
|
|
|
{
|
|
|
|
switch (iface_param->param) {
|
|
|
|
case ISCSI_NET_PARAM_IPV4_ADDR:
|
|
|
|
memcpy(init_fw_cb->ipv4_addr, iface_param->value,
|
|
|
|
sizeof(init_fw_cb->ipv4_addr));
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV4_SUBNET:
|
|
|
|
memcpy(init_fw_cb->ipv4_subnet, iface_param->value,
|
|
|
|
sizeof(init_fw_cb->ipv4_subnet));
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV4_GW:
|
|
|
|
memcpy(init_fw_cb->ipv4_gw_addr, iface_param->value,
|
|
|
|
sizeof(init_fw_cb->ipv4_gw_addr));
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV4_BOOTPROTO:
|
|
|
|
if (iface_param->value[0] == ISCSI_BOOTPROTO_DHCP)
|
|
|
|
init_fw_cb->ipv4_tcp_opts |=
|
|
|
|
cpu_to_le16(TCPOPT_DHCP_ENABLE);
|
|
|
|
else if (iface_param->value[0] == ISCSI_BOOTPROTO_STATIC)
|
|
|
|
init_fw_cb->ipv4_tcp_opts &=
|
|
|
|
cpu_to_le16(~TCPOPT_DHCP_ENABLE);
|
|
|
|
else
|
|
|
|
ql4_printk(KERN_ERR, ha, "Invalid IPv4 bootproto\n");
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IFACE_ENABLE:
|
2011-07-25 20:48:41 +02:00
|
|
|
if (iface_param->value[0] == ISCSI_IFACE_ENABLE) {
|
2011-07-25 20:48:38 +02:00
|
|
|
init_fw_cb->ipv4_ip_opts |=
|
2011-07-25 20:48:39 +02:00
|
|
|
cpu_to_le16(IPOPT_IPV4_PROTOCOL_ENABLE);
|
2011-07-25 20:48:41 +02:00
|
|
|
qla4xxx_create_ipv4_iface(ha);
|
|
|
|
} else {
|
2011-07-25 20:48:38 +02:00
|
|
|
init_fw_cb->ipv4_ip_opts &=
|
2011-07-25 20:48:39 +02:00
|
|
|
cpu_to_le16(~IPOPT_IPV4_PROTOCOL_ENABLE &
|
2011-07-25 20:48:38 +02:00
|
|
|
0xFFFF);
|
2011-07-25 20:48:41 +02:00
|
|
|
qla4xxx_destroy_ipv4_iface(ha);
|
|
|
|
}
|
2011-07-25 20:48:38 +02:00
|
|
|
break;
|
2011-10-12 00:55:11 +02:00
|
|
|
case ISCSI_NET_PARAM_VLAN_TAG:
|
2011-07-25 20:48:38 +02:00
|
|
|
if (iface_param->len != sizeof(init_fw_cb->ipv4_vlan_tag))
|
|
|
|
break;
|
2011-07-25 20:48:49 +02:00
|
|
|
init_fw_cb->ipv4_vlan_tag =
|
|
|
|
cpu_to_be16(*(uint16_t *)iface_param->value);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_VLAN_ENABLED:
|
|
|
|
if (iface_param->value[0] == ISCSI_VLAN_ENABLE)
|
|
|
|
init_fw_cb->ipv4_ip_opts |=
|
|
|
|
cpu_to_le16(IPOPT_VLAN_TAGGING_ENABLE);
|
|
|
|
else
|
|
|
|
init_fw_cb->ipv4_ip_opts &=
|
|
|
|
cpu_to_le16(~IPOPT_VLAN_TAGGING_ENABLE);
|
2011-07-25 20:48:38 +02:00
|
|
|
break;
|
2011-08-01 12:26:13 +02:00
|
|
|
case ISCSI_NET_PARAM_MTU:
|
|
|
|
init_fw_cb->eth_mtu_size =
|
|
|
|
cpu_to_le16(*(uint16_t *)iface_param->value);
|
|
|
|
break;
|
2011-08-01 12:26:19 +02:00
|
|
|
case ISCSI_NET_PARAM_PORT:
|
|
|
|
init_fw_cb->ipv4_port =
|
|
|
|
cpu_to_le16(*(uint16_t *)iface_param->value);
|
|
|
|
break;
|
2013-10-18 15:01:42 +02:00
|
|
|
case ISCSI_NET_PARAM_DELAYED_ACK_EN:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
if (iface_param->value[0] == ISCSI_NET_PARAM_DISABLE)
|
|
|
|
init_fw_cb->ipv4_tcp_opts |=
|
|
|
|
cpu_to_le16(TCPOPT_DELAYED_ACK_DISABLE);
|
|
|
|
else
|
|
|
|
init_fw_cb->ipv4_tcp_opts &=
|
2013-12-16 12:49:53 +01:00
|
|
|
cpu_to_le16(~TCPOPT_DELAYED_ACK_DISABLE &
|
|
|
|
0xFFFF);
|
2013-10-18 15:01:42 +02:00
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_TCP_NAGLE_DISABLE:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
if (iface_param->value[0] == ISCSI_NET_PARAM_DISABLE)
|
|
|
|
init_fw_cb->ipv4_tcp_opts |=
|
|
|
|
cpu_to_le16(TCPOPT_NAGLE_ALGO_DISABLE);
|
|
|
|
else
|
|
|
|
init_fw_cb->ipv4_tcp_opts &=
|
|
|
|
cpu_to_le16(~TCPOPT_NAGLE_ALGO_DISABLE);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_TCP_WSF_DISABLE:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
if (iface_param->value[0] == ISCSI_NET_PARAM_DISABLE)
|
|
|
|
init_fw_cb->ipv4_tcp_opts |=
|
|
|
|
cpu_to_le16(TCPOPT_WINDOW_SCALE_DISABLE);
|
|
|
|
else
|
|
|
|
init_fw_cb->ipv4_tcp_opts &=
|
|
|
|
cpu_to_le16(~TCPOPT_WINDOW_SCALE_DISABLE);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_TCP_WSF:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
init_fw_cb->ipv4_tcp_wsf = iface_param->value[0];
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_TCP_TIMER_SCALE:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
init_fw_cb->ipv4_tcp_opts &= cpu_to_le16(~TCPOPT_TIMER_SCALE);
|
|
|
|
init_fw_cb->ipv4_tcp_opts |=
|
|
|
|
cpu_to_le16((iface_param->value[0] << 1) &
|
|
|
|
TCPOPT_TIMER_SCALE);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_TCP_TIMESTAMP_EN:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
if (iface_param->value[0] == ISCSI_NET_PARAM_ENABLE)
|
|
|
|
init_fw_cb->ipv4_tcp_opts |=
|
|
|
|
cpu_to_le16(TCPOPT_TIMESTAMP_ENABLE);
|
|
|
|
else
|
|
|
|
init_fw_cb->ipv4_tcp_opts &=
|
|
|
|
cpu_to_le16(~TCPOPT_TIMESTAMP_ENABLE);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV4_DHCP_DNS_ADDR_EN:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
if (iface_param->value[0] == ISCSI_NET_PARAM_ENABLE)
|
|
|
|
init_fw_cb->ipv4_tcp_opts |=
|
|
|
|
cpu_to_le16(TCPOPT_DNS_SERVER_IP_EN);
|
|
|
|
else
|
|
|
|
init_fw_cb->ipv4_tcp_opts &=
|
|
|
|
cpu_to_le16(~TCPOPT_DNS_SERVER_IP_EN);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV4_DHCP_SLP_DA_EN:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
if (iface_param->value[0] == ISCSI_NET_PARAM_ENABLE)
|
|
|
|
init_fw_cb->ipv4_tcp_opts |=
|
|
|
|
cpu_to_le16(TCPOPT_SLP_DA_INFO_EN);
|
|
|
|
else
|
|
|
|
init_fw_cb->ipv4_tcp_opts &=
|
|
|
|
cpu_to_le16(~TCPOPT_SLP_DA_INFO_EN);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV4_TOS_EN:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
if (iface_param->value[0] == ISCSI_NET_PARAM_ENABLE)
|
|
|
|
init_fw_cb->ipv4_ip_opts |=
|
|
|
|
cpu_to_le16(IPOPT_IPV4_TOS_EN);
|
|
|
|
else
|
|
|
|
init_fw_cb->ipv4_ip_opts &=
|
|
|
|
cpu_to_le16(~IPOPT_IPV4_TOS_EN);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV4_TOS:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
init_fw_cb->ipv4_tos = iface_param->value[0];
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV4_GRAT_ARP_EN:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
if (iface_param->value[0] == ISCSI_NET_PARAM_ENABLE)
|
|
|
|
init_fw_cb->ipv4_ip_opts |=
|
|
|
|
cpu_to_le16(IPOPT_GRAT_ARP_EN);
|
|
|
|
else
|
|
|
|
init_fw_cb->ipv4_ip_opts &=
|
|
|
|
cpu_to_le16(~IPOPT_GRAT_ARP_EN);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV4_DHCP_ALT_CLIENT_ID_EN:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
if (iface_param->value[0] == ISCSI_NET_PARAM_ENABLE)
|
|
|
|
init_fw_cb->ipv4_ip_opts |=
|
|
|
|
cpu_to_le16(IPOPT_ALT_CID_EN);
|
|
|
|
else
|
|
|
|
init_fw_cb->ipv4_ip_opts &=
|
|
|
|
cpu_to_le16(~IPOPT_ALT_CID_EN);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV4_DHCP_ALT_CLIENT_ID:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
memcpy(init_fw_cb->ipv4_dhcp_alt_cid, iface_param->value,
|
|
|
|
(sizeof(init_fw_cb->ipv4_dhcp_alt_cid) - 1));
|
|
|
|
init_fw_cb->ipv4_dhcp_alt_cid_len =
|
|
|
|
strlen(init_fw_cb->ipv4_dhcp_alt_cid);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV4_DHCP_REQ_VENDOR_ID_EN:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
if (iface_param->value[0] == ISCSI_NET_PARAM_ENABLE)
|
|
|
|
init_fw_cb->ipv4_ip_opts |=
|
|
|
|
cpu_to_le16(IPOPT_REQ_VID_EN);
|
|
|
|
else
|
|
|
|
init_fw_cb->ipv4_ip_opts &=
|
|
|
|
cpu_to_le16(~IPOPT_REQ_VID_EN);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV4_DHCP_USE_VENDOR_ID_EN:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
if (iface_param->value[0] == ISCSI_NET_PARAM_ENABLE)
|
|
|
|
init_fw_cb->ipv4_ip_opts |=
|
|
|
|
cpu_to_le16(IPOPT_USE_VID_EN);
|
|
|
|
else
|
|
|
|
init_fw_cb->ipv4_ip_opts &=
|
|
|
|
cpu_to_le16(~IPOPT_USE_VID_EN);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV4_DHCP_VENDOR_ID:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
memcpy(init_fw_cb->ipv4_dhcp_vid, iface_param->value,
|
|
|
|
(sizeof(init_fw_cb->ipv4_dhcp_vid) - 1));
|
|
|
|
init_fw_cb->ipv4_dhcp_vid_len =
|
|
|
|
strlen(init_fw_cb->ipv4_dhcp_vid);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV4_DHCP_LEARN_IQN_EN:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
if (iface_param->value[0] == ISCSI_NET_PARAM_ENABLE)
|
|
|
|
init_fw_cb->ipv4_ip_opts |=
|
|
|
|
cpu_to_le16(IPOPT_LEARN_IQN_EN);
|
|
|
|
else
|
|
|
|
init_fw_cb->ipv4_ip_opts &=
|
|
|
|
cpu_to_le16(~IPOPT_LEARN_IQN_EN);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV4_FRAGMENT_DISABLE:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
if (iface_param->value[0] == ISCSI_NET_PARAM_DISABLE)
|
|
|
|
init_fw_cb->ipv4_ip_opts |=
|
|
|
|
cpu_to_le16(IPOPT_FRAGMENTATION_DISABLE);
|
|
|
|
else
|
|
|
|
init_fw_cb->ipv4_ip_opts &=
|
|
|
|
cpu_to_le16(~IPOPT_FRAGMENTATION_DISABLE);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV4_IN_FORWARD_EN:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
if (iface_param->value[0] == ISCSI_NET_PARAM_ENABLE)
|
|
|
|
init_fw_cb->ipv4_ip_opts |=
|
|
|
|
cpu_to_le16(IPOPT_IN_FORWARD_EN);
|
|
|
|
else
|
|
|
|
init_fw_cb->ipv4_ip_opts &=
|
|
|
|
cpu_to_le16(~IPOPT_IN_FORWARD_EN);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_REDIRECT_EN:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
if (iface_param->value[0] == ISCSI_NET_PARAM_ENABLE)
|
|
|
|
init_fw_cb->ipv4_ip_opts |=
|
|
|
|
cpu_to_le16(IPOPT_ARP_REDIRECT_EN);
|
|
|
|
else
|
|
|
|
init_fw_cb->ipv4_ip_opts &=
|
|
|
|
cpu_to_le16(~IPOPT_ARP_REDIRECT_EN);
|
|
|
|
break;
|
|
|
|
case ISCSI_NET_PARAM_IPV4_TTL:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
init_fw_cb->ipv4_ttl = iface_param->value[0];
|
|
|
|
break;
|
2011-07-25 20:48:38 +02:00
|
|
|
default:
|
|
|
|
ql4_printk(KERN_ERR, ha, "Unknown IPv4 param = %d\n",
|
|
|
|
iface_param->param);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-18 15:01:42 +02:00
|
|
|
static void qla4xxx_set_iscsi_param(struct scsi_qla_host *ha,
|
|
|
|
struct iscsi_iface_param_info *iface_param,
|
|
|
|
struct addr_ctrl_blk *init_fw_cb)
|
|
|
|
{
|
|
|
|
switch (iface_param->param) {
|
|
|
|
case ISCSI_IFACE_PARAM_DEF_TASKMGMT_TMO:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
init_fw_cb->def_timeout =
|
|
|
|
cpu_to_le16(*(uint16_t *)iface_param->value);
|
|
|
|
break;
|
|
|
|
case ISCSI_IFACE_PARAM_HDRDGST_EN:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
if (iface_param->value[0] == ISCSI_NET_PARAM_ENABLE)
|
|
|
|
init_fw_cb->iscsi_opts |=
|
|
|
|
cpu_to_le16(ISCSIOPTS_HEADER_DIGEST_EN);
|
|
|
|
else
|
|
|
|
init_fw_cb->iscsi_opts &=
|
|
|
|
cpu_to_le16(~ISCSIOPTS_HEADER_DIGEST_EN);
|
|
|
|
break;
|
|
|
|
case ISCSI_IFACE_PARAM_DATADGST_EN:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
if (iface_param->value[0] == ISCSI_NET_PARAM_ENABLE)
|
|
|
|
init_fw_cb->iscsi_opts |=
|
|
|
|
cpu_to_le16(ISCSIOPTS_DATA_DIGEST_EN);
|
|
|
|
else
|
|
|
|
init_fw_cb->iscsi_opts &=
|
|
|
|
cpu_to_le16(~ISCSIOPTS_DATA_DIGEST_EN);
|
|
|
|
break;
|
|
|
|
case ISCSI_IFACE_PARAM_IMM_DATA_EN:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
if (iface_param->value[0] == ISCSI_NET_PARAM_ENABLE)
|
|
|
|
init_fw_cb->iscsi_opts |=
|
|
|
|
cpu_to_le16(ISCSIOPTS_IMMEDIATE_DATA_EN);
|
|
|
|
else
|
|
|
|
init_fw_cb->iscsi_opts &=
|
|
|
|
cpu_to_le16(~ISCSIOPTS_IMMEDIATE_DATA_EN);
|
|
|
|
break;
|
|
|
|
case ISCSI_IFACE_PARAM_INITIAL_R2T_EN:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
if (iface_param->value[0] == ISCSI_NET_PARAM_ENABLE)
|
|
|
|
init_fw_cb->iscsi_opts |=
|
|
|
|
cpu_to_le16(ISCSIOPTS_INITIAL_R2T_EN);
|
|
|
|
else
|
|
|
|
init_fw_cb->iscsi_opts &=
|
|
|
|
cpu_to_le16(~ISCSIOPTS_INITIAL_R2T_EN);
|
|
|
|
break;
|
|
|
|
case ISCSI_IFACE_PARAM_DATASEQ_INORDER_EN:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
if (iface_param->value[0] == ISCSI_NET_PARAM_ENABLE)
|
|
|
|
init_fw_cb->iscsi_opts |=
|
|
|
|
cpu_to_le16(ISCSIOPTS_DATA_SEQ_INORDER_EN);
|
|
|
|
else
|
|
|
|
init_fw_cb->iscsi_opts &=
|
|
|
|
cpu_to_le16(~ISCSIOPTS_DATA_SEQ_INORDER_EN);
|
|
|
|
break;
|
|
|
|
case ISCSI_IFACE_PARAM_PDU_INORDER_EN:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
if (iface_param->value[0] == ISCSI_NET_PARAM_ENABLE)
|
|
|
|
init_fw_cb->iscsi_opts |=
|
|
|
|
cpu_to_le16(ISCSIOPTS_DATA_PDU_INORDER_EN);
|
|
|
|
else
|
|
|
|
init_fw_cb->iscsi_opts &=
|
|
|
|
cpu_to_le16(~ISCSIOPTS_DATA_PDU_INORDER_EN);
|
|
|
|
break;
|
|
|
|
case ISCSI_IFACE_PARAM_ERL:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
init_fw_cb->iscsi_opts &= cpu_to_le16(~ISCSIOPTS_ERL);
|
|
|
|
init_fw_cb->iscsi_opts |= cpu_to_le16(iface_param->value[0] &
|
|
|
|
ISCSIOPTS_ERL);
|
|
|
|
break;
|
|
|
|
case ISCSI_IFACE_PARAM_MAX_RECV_DLENGTH:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
init_fw_cb->iscsi_max_pdu_size =
|
|
|
|
cpu_to_le32(*(uint32_t *)iface_param->value) /
|
|
|
|
BYTE_UNITS;
|
|
|
|
break;
|
|
|
|
case ISCSI_IFACE_PARAM_FIRST_BURST:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
init_fw_cb->iscsi_fburst_len =
|
|
|
|
cpu_to_le32(*(uint32_t *)iface_param->value) /
|
|
|
|
BYTE_UNITS;
|
|
|
|
break;
|
|
|
|
case ISCSI_IFACE_PARAM_MAX_R2T:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
init_fw_cb->iscsi_max_outstnd_r2t =
|
|
|
|
cpu_to_le16(*(uint16_t *)iface_param->value);
|
|
|
|
break;
|
|
|
|
case ISCSI_IFACE_PARAM_MAX_BURST:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
init_fw_cb->iscsi_max_burst_len =
|
|
|
|
cpu_to_le32(*(uint32_t *)iface_param->value) /
|
|
|
|
BYTE_UNITS;
|
|
|
|
break;
|
|
|
|
case ISCSI_IFACE_PARAM_CHAP_AUTH_EN:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
if (iface_param->value[0] == ISCSI_NET_PARAM_ENABLE)
|
|
|
|
init_fw_cb->iscsi_opts |=
|
|
|
|
cpu_to_le16(ISCSIOPTS_CHAP_AUTH_EN);
|
|
|
|
else
|
|
|
|
init_fw_cb->iscsi_opts &=
|
|
|
|
cpu_to_le16(~ISCSIOPTS_CHAP_AUTH_EN);
|
|
|
|
break;
|
|
|
|
case ISCSI_IFACE_PARAM_BIDI_CHAP_EN:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
if (iface_param->value[0] == ISCSI_NET_PARAM_ENABLE)
|
|
|
|
init_fw_cb->iscsi_opts |=
|
|
|
|
cpu_to_le16(ISCSIOPTS_BIDI_CHAP_EN);
|
|
|
|
else
|
|
|
|
init_fw_cb->iscsi_opts &=
|
|
|
|
cpu_to_le16(~ISCSIOPTS_BIDI_CHAP_EN);
|
|
|
|
break;
|
|
|
|
case ISCSI_IFACE_PARAM_DISCOVERY_AUTH_OPTIONAL:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
if (iface_param->value[0] == ISCSI_NET_PARAM_ENABLE)
|
|
|
|
init_fw_cb->iscsi_opts |=
|
|
|
|
cpu_to_le16(ISCSIOPTS_DISCOVERY_AUTH_EN);
|
|
|
|
else
|
|
|
|
init_fw_cb->iscsi_opts &=
|
|
|
|
cpu_to_le16(~ISCSIOPTS_DISCOVERY_AUTH_EN);
|
|
|
|
break;
|
|
|
|
case ISCSI_IFACE_PARAM_DISCOVERY_LOGOUT_EN:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
if (iface_param->value[0] == ISCSI_NET_PARAM_ENABLE)
|
|
|
|
init_fw_cb->iscsi_opts |=
|
|
|
|
cpu_to_le16(ISCSIOPTS_DISCOVERY_LOGOUT_EN);
|
|
|
|
else
|
|
|
|
init_fw_cb->iscsi_opts &=
|
|
|
|
cpu_to_le16(~ISCSIOPTS_DISCOVERY_LOGOUT_EN);
|
|
|
|
break;
|
|
|
|
case ISCSI_IFACE_PARAM_STRICT_LOGIN_COMP_EN:
|
|
|
|
if (iface_param->iface_num & 0x1)
|
|
|
|
break;
|
|
|
|
if (iface_param->value[0] == ISCSI_NET_PARAM_ENABLE)
|
|
|
|
init_fw_cb->iscsi_opts |=
|
|
|
|
cpu_to_le16(ISCSIOPTS_STRICT_LOGIN_COMP_EN);
|
|
|
|
else
|
|
|
|
init_fw_cb->iscsi_opts &=
|
|
|
|
cpu_to_le16(~ISCSIOPTS_STRICT_LOGIN_COMP_EN);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ql4_printk(KERN_ERR, ha, "Unknown iscsi param = %d\n",
|
|
|
|
iface_param->param);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-25 20:48:38 +02:00
|
|
|
static void
|
|
|
|
qla4xxx_initcb_to_acb(struct addr_ctrl_blk *init_fw_cb)
|
|
|
|
{
|
|
|
|
struct addr_ctrl_blk_def *acb;
|
|
|
|
acb = (struct addr_ctrl_blk_def *)init_fw_cb;
|
|
|
|
memset(acb->reserved1, 0, sizeof(acb->reserved1));
|
|
|
|
memset(acb->reserved2, 0, sizeof(acb->reserved2));
|
|
|
|
memset(acb->reserved3, 0, sizeof(acb->reserved3));
|
|
|
|
memset(acb->reserved4, 0, sizeof(acb->reserved4));
|
|
|
|
memset(acb->reserved5, 0, sizeof(acb->reserved5));
|
|
|
|
memset(acb->reserved6, 0, sizeof(acb->reserved6));
|
|
|
|
memset(acb->reserved7, 0, sizeof(acb->reserved7));
|
|
|
|
memset(acb->reserved8, 0, sizeof(acb->reserved8));
|
|
|
|
memset(acb->reserved9, 0, sizeof(acb->reserved9));
|
|
|
|
memset(acb->reserved10, 0, sizeof(acb->reserved10));
|
|
|
|
memset(acb->reserved11, 0, sizeof(acb->reserved11));
|
|
|
|
memset(acb->reserved12, 0, sizeof(acb->reserved12));
|
|
|
|
memset(acb->reserved13, 0, sizeof(acb->reserved13));
|
|
|
|
memset(acb->reserved14, 0, sizeof(acb->reserved14));
|
|
|
|
memset(acb->reserved15, 0, sizeof(acb->reserved15));
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2011-10-06 10:56:59 +02:00
|
|
|
qla4xxx_iface_set_param(struct Scsi_Host *shost, void *data, uint32_t len)
|
2011-07-25 20:48:38 +02:00
|
|
|
{
|
|
|
|
struct scsi_qla_host *ha = to_qla_host(shost);
|
|
|
|
int rval = 0;
|
|
|
|
struct iscsi_iface_param_info *iface_param = NULL;
|
|
|
|
struct addr_ctrl_blk *init_fw_cb = NULL;
|
|
|
|
dma_addr_t init_fw_cb_dma;
|
|
|
|
uint32_t mbox_cmd[MBOX_REG_COUNT];
|
|
|
|
uint32_t mbox_sts[MBOX_REG_COUNT];
|
2011-10-06 10:56:59 +02:00
|
|
|
uint32_t rem = len;
|
|
|
|
struct nlattr *attr;
|
2011-07-25 20:48:38 +02:00
|
|
|
|
|
|
|
init_fw_cb = dma_alloc_coherent(&ha->pdev->dev,
|
|
|
|
sizeof(struct addr_ctrl_blk),
|
|
|
|
&init_fw_cb_dma, GFP_KERNEL);
|
|
|
|
if (!init_fw_cb) {
|
|
|
|
ql4_printk(KERN_ERR, ha, "%s: Unable to alloc init_cb\n",
|
|
|
|
__func__);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(init_fw_cb, 0, sizeof(struct addr_ctrl_blk));
|
|
|
|
memset(&mbox_cmd, 0, sizeof(mbox_cmd));
|
|
|
|
memset(&mbox_sts, 0, sizeof(mbox_sts));
|
|
|
|
|
|
|
|
if (qla4xxx_get_ifcb(ha, &mbox_cmd[0], &mbox_sts[0], init_fw_cb_dma)) {
|
|
|
|
ql4_printk(KERN_ERR, ha, "%s: get ifcb failed\n", __func__);
|
|
|
|
rval = -EIO;
|
|
|
|
goto exit_init_fw_cb;
|
|
|
|
}
|
|
|
|
|
2011-10-06 10:56:59 +02:00
|
|
|
nla_for_each_attr(attr, data, len, rem) {
|
|
|
|
iface_param = nla_data(attr);
|
2011-07-25 20:48:38 +02:00
|
|
|
|
2013-10-18 15:01:42 +02:00
|
|
|
if (iface_param->param_type == ISCSI_NET_PARAM) {
|
|
|
|
switch (iface_param->iface_type) {
|
|
|
|
case ISCSI_IFACE_TYPE_IPV4:
|
|
|
|
switch (iface_param->iface_num) {
|
|
|
|
case 0:
|
|
|
|
qla4xxx_set_ipv4(ha, iface_param,
|
|
|
|
init_fw_cb);
|
|
|
|
break;
|
|
|
|
default:
|
2011-07-25 20:48:38 +02:00
|
|
|
/* Cannot have more than one IPv4 interface */
|
2013-10-18 15:01:42 +02:00
|
|
|
ql4_printk(KERN_ERR, ha,
|
|
|
|
"Invalid IPv4 iface number = %d\n",
|
|
|
|
iface_param->iface_num);
|
|
|
|
break;
|
|
|
|
}
|
2011-07-25 20:48:38 +02:00
|
|
|
break;
|
2013-10-18 15:01:42 +02:00
|
|
|
case ISCSI_IFACE_TYPE_IPV6:
|
|
|
|
switch (iface_param->iface_num) {
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
qla4xxx_set_ipv6(ha, iface_param,
|
|
|
|
init_fw_cb);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* Cannot have more than two IPv6 interface */
|
|
|
|
ql4_printk(KERN_ERR, ha,
|
|
|
|
"Invalid IPv6 iface number = %d\n",
|
|
|
|
iface_param->iface_num);
|
|
|
|
break;
|
|
|
|
}
|
2011-07-25 20:48:38 +02:00
|
|
|
break;
|
|
|
|
default:
|
2013-10-18 15:01:42 +02:00
|
|
|
ql4_printk(KERN_ERR, ha,
|
|
|
|
"Invalid iface type\n");
|
2011-07-25 20:48:38 +02:00
|
|
|
break;
|
|
|
|
}
|
2013-10-18 15:01:42 +02:00
|
|
|
} else if (iface_param->param_type == ISCSI_IFACE_PARAM) {
|
|
|
|
qla4xxx_set_iscsi_param(ha, iface_param,
|
|
|
|
init_fw_cb);
|
|
|
|
} else {
|
|
|
|
continue;
|
2011-07-25 20:48:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
init_fw_cb->cookie = cpu_to_le32(0x11BEAD5A);
|
|
|
|
|
|
|
|
rval = qla4xxx_set_flash(ha, init_fw_cb_dma, FLASH_SEGMENT_IFCB,
|
|
|
|
sizeof(struct addr_ctrl_blk),
|
|
|
|
FLASH_OPT_RMW_COMMIT);
|
|
|
|
if (rval != QLA_SUCCESS) {
|
|
|
|
ql4_printk(KERN_ERR, ha, "%s: set flash mbx failed\n",
|
|
|
|
__func__);
|
|
|
|
rval = -EIO;
|
|
|
|
goto exit_init_fw_cb;
|
|
|
|
}
|
|
|
|
|
2011-12-02 07:42:10 +01:00
|
|
|
rval = qla4xxx_disable_acb(ha);
|
|
|
|
if (rval != QLA_SUCCESS) {
|
|
|
|
ql4_printk(KERN_ERR, ha, "%s: disable acb mbx failed\n",
|
|
|
|
__func__);
|
|
|
|
rval = -EIO;
|
|
|
|
goto exit_init_fw_cb;
|
|
|
|
}
|
|
|
|
|
|
|
|
wait_for_completion_timeout(&ha->disable_acb_comp,
|
|
|
|
DISABLE_ACB_TOV * HZ);
|
2011-07-25 20:48:38 +02:00
|
|
|
|
|
|
|
qla4xxx_initcb_to_acb(init_fw_cb);
|
|
|
|
|
|
|
|
rval = qla4xxx_set_acb(ha, &mbox_cmd[0], &mbox_sts[0], init_fw_cb_dma);
|
|
|
|
if (rval != QLA_SUCCESS) {
|
|
|
|
ql4_printk(KERN_ERR, ha, "%s: set acb mbx failed\n",
|
|
|
|
__func__);
|
|
|
|
rval = -EIO;
|
|
|
|
goto exit_init_fw_cb;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(init_fw_cb, 0, sizeof(struct addr_ctrl_blk));
|
|
|
|
qla4xxx_update_local_ifcb(ha, &mbox_cmd[0], &mbox_sts[0], init_fw_cb,
|
|
|
|
init_fw_cb_dma);
|
|
|
|
|
|
|
|
exit_init_fw_cb:
|
|
|
|
dma_free_coherent(&ha->pdev->dev, sizeof(struct addr_ctrl_blk),
|
|
|
|
init_fw_cb, init_fw_cb_dma);
|
|
|
|
|
|
|
|
return rval;
|
|
|
|
}
|
|
|
|
|
2012-02-27 12:08:54 +01:00
|
|
|
static int qla4xxx_session_get_param(struct iscsi_cls_session *cls_sess,
|
|
|
|
enum iscsi_param param, char *buf)
|
|
|
|
{
|
|
|
|
struct iscsi_session *sess = cls_sess->dd_data;
|
|
|
|
struct ddb_entry *ddb_entry = sess->dd_data;
|
|
|
|
struct scsi_qla_host *ha = ddb_entry->ha;
|
2013-09-17 13:54:50 +02:00
|
|
|
struct iscsi_cls_conn *cls_conn = ddb_entry->conn;
|
|
|
|
struct ql4_chap_table chap_tbl;
|
2012-02-27 12:08:54 +01:00
|
|
|
int rval, len;
|
|
|
|
uint16_t idx;
|
|
|
|
|
2013-09-17 13:54:50 +02:00
|
|
|
memset(&chap_tbl, 0, sizeof(chap_tbl));
|
2012-02-27 12:08:54 +01:00
|
|
|
switch (param) {
|
|
|
|
case ISCSI_PARAM_CHAP_IN_IDX:
|
|
|
|
rval = qla4xxx_get_chap_index(ha, sess->username_in,
|
|
|
|
sess->password_in, BIDI_CHAP,
|
|
|
|
&idx);
|
|
|
|
if (rval)
|
2013-01-21 05:51:04 +01:00
|
|
|
len = sprintf(buf, "\n");
|
|
|
|
else
|
|
|
|
len = sprintf(buf, "%hu\n", idx);
|
2012-02-27 12:08:54 +01:00
|
|
|
break;
|
|
|
|
case ISCSI_PARAM_CHAP_OUT_IDX:
|
2013-09-17 13:54:50 +02:00
|
|
|
if (ddb_entry->ddb_type == FLASH_DDB) {
|
|
|
|
if (ddb_entry->chap_tbl_idx != INVALID_ENTRY) {
|
|
|
|
idx = ddb_entry->chap_tbl_idx;
|
|
|
|
rval = QLA_SUCCESS;
|
|
|
|
} else {
|
|
|
|
rval = QLA_ERROR;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
rval = qla4xxx_get_chap_index(ha, sess->username,
|
|
|
|
sess->password,
|
|
|
|
LOCAL_CHAP, &idx);
|
|
|
|
}
|
2012-02-27 12:08:54 +01:00
|
|
|
if (rval)
|
2013-01-21 05:51:04 +01:00
|
|
|
len = sprintf(buf, "\n");
|
|
|
|
else
|
|
|
|
len = sprintf(buf, "%hu\n", idx);
|
2012-02-27 12:08:54 +01:00
|
|
|
break;
|
2013-09-17 13:54:50 +02:00
|
|
|
case ISCSI_PARAM_USERNAME:
|
|
|
|
case ISCSI_PARAM_PASSWORD:
|
|
|
|
/* First, populate session username and password for FLASH DDB,
|
|
|
|
* if not already done. This happens when session login fails
|
|
|
|
* for a FLASH DDB.
|
|
|
|
*/
|
|
|
|
if (ddb_entry->ddb_type == FLASH_DDB &&
|
|
|
|
ddb_entry->chap_tbl_idx != INVALID_ENTRY &&
|
|
|
|
!sess->username && !sess->password) {
|
|
|
|
idx = ddb_entry->chap_tbl_idx;
|
|
|
|
rval = qla4xxx_get_uni_chap_at_index(ha, chap_tbl.name,
|
|
|
|
chap_tbl.secret,
|
|
|
|
idx);
|
|
|
|
if (!rval) {
|
|
|
|
iscsi_set_param(cls_conn, ISCSI_PARAM_USERNAME,
|
|
|
|
(char *)chap_tbl.name,
|
|
|
|
strlen((char *)chap_tbl.name));
|
|
|
|
iscsi_set_param(cls_conn, ISCSI_PARAM_PASSWORD,
|
|
|
|
(char *)chap_tbl.secret,
|
|
|
|
chap_tbl.secret_len);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* allow fall-through */
|
2012-02-27 12:08:54 +01:00
|
|
|
default:
|
|
|
|
return iscsi_session_get_param(cls_sess, param, buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
2011-07-25 20:48:53 +02:00
|
|
|
static int qla4xxx_conn_get_param(struct iscsi_cls_conn *cls_conn,
|
2006-09-19 19:28:00 +02:00
|
|
|
enum iscsi_param param, char *buf)
|
|
|
|
{
|
2011-07-25 20:48:53 +02:00
|
|
|
struct iscsi_conn *conn;
|
|
|
|
struct qla_conn *qla_conn;
|
|
|
|
struct sockaddr *dst_addr;
|
2006-09-19 19:28:00 +02:00
|
|
|
|
2011-07-25 20:48:53 +02:00
|
|
|
conn = cls_conn->dd_data;
|
|
|
|
qla_conn = conn->dd_data;
|
2012-08-07 13:57:13 +02:00
|
|
|
dst_addr = (struct sockaddr *)&qla_conn->qla_ep->dst_addr;
|
2006-09-19 19:28:00 +02:00
|
|
|
|
|
|
|
switch (param) {
|
|
|
|
case ISCSI_PARAM_CONN_PORT:
|
|
|
|
case ISCSI_PARAM_CONN_ADDRESS:
|
2011-07-25 20:48:53 +02:00
|
|
|
return iscsi_conn_get_addr_param((struct sockaddr_storage *)
|
|
|
|
dst_addr, param, buf);
|
2006-09-19 19:28:00 +02:00
|
|
|
default:
|
2011-07-25 20:48:53 +02:00
|
|
|
return iscsi_conn_get_param(cls_conn, param, buf);
|
2006-09-19 19:28:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-02 04:38:41 +01:00
|
|
|
int qla4xxx_get_ddb_index(struct scsi_qla_host *ha, uint16_t *ddb_index)
|
|
|
|
{
|
|
|
|
uint32_t mbx_sts = 0;
|
|
|
|
uint16_t tmp_ddb_index;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
get_ddb_index:
|
|
|
|
tmp_ddb_index = find_first_zero_bit(ha->ddb_idx_map, MAX_DDB_ENTRIES);
|
|
|
|
|
|
|
|
if (tmp_ddb_index >= MAX_DDB_ENTRIES) {
|
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha,
|
|
|
|
"Free DDB index not available\n"));
|
|
|
|
ret = QLA_ERROR;
|
|
|
|
goto exit_get_ddb_index;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (test_and_set_bit(tmp_ddb_index, ha->ddb_idx_map))
|
|
|
|
goto get_ddb_index;
|
|
|
|
|
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha,
|
|
|
|
"Found a free DDB index at %d\n", tmp_ddb_index));
|
|
|
|
ret = qla4xxx_req_ddb_entry(ha, tmp_ddb_index, &mbx_sts);
|
|
|
|
if (ret == QLA_ERROR) {
|
|
|
|
if (mbx_sts == MBOX_STS_COMMAND_ERROR) {
|
|
|
|
ql4_printk(KERN_INFO, ha,
|
|
|
|
"DDB index = %d not available trying next\n",
|
|
|
|
tmp_ddb_index);
|
|
|
|
goto get_ddb_index;
|
|
|
|
}
|
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha,
|
|
|
|
"Free FW DDB not available\n"));
|
|
|
|
}
|
|
|
|
|
|
|
|
*ddb_index = tmp_ddb_index;
|
|
|
|
|
|
|
|
exit_get_ddb_index:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int qla4xxx_match_ipaddress(struct scsi_qla_host *ha,
|
|
|
|
struct ddb_entry *ddb_entry,
|
|
|
|
char *existing_ipaddr,
|
|
|
|
char *user_ipaddr)
|
|
|
|
{
|
|
|
|
uint8_t dst_ipaddr[IPv6_ADDR_LEN];
|
|
|
|
char formatted_ipaddr[DDB_IPADDR_LEN];
|
|
|
|
int status = QLA_SUCCESS, ret = 0;
|
|
|
|
|
|
|
|
if (ddb_entry->fw_ddb_entry.options & DDB_OPT_IPV6_DEVICE) {
|
|
|
|
ret = in6_pton(user_ipaddr, strlen(user_ipaddr), dst_ipaddr,
|
|
|
|
'\0', NULL);
|
|
|
|
if (ret == 0) {
|
|
|
|
status = QLA_ERROR;
|
|
|
|
goto out_match;
|
|
|
|
}
|
|
|
|
ret = sprintf(formatted_ipaddr, "%pI6", dst_ipaddr);
|
|
|
|
} else {
|
|
|
|
ret = in4_pton(user_ipaddr, strlen(user_ipaddr), dst_ipaddr,
|
|
|
|
'\0', NULL);
|
|
|
|
if (ret == 0) {
|
|
|
|
status = QLA_ERROR;
|
|
|
|
goto out_match;
|
|
|
|
}
|
|
|
|
ret = sprintf(formatted_ipaddr, "%pI4", dst_ipaddr);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcmp(existing_ipaddr, formatted_ipaddr))
|
|
|
|
status = QLA_ERROR;
|
|
|
|
|
|
|
|
out_match:
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int qla4xxx_match_fwdb_session(struct scsi_qla_host *ha,
|
|
|
|
struct iscsi_cls_conn *cls_conn)
|
|
|
|
{
|
|
|
|
int idx = 0, max_ddbs, rval;
|
|
|
|
struct iscsi_cls_session *cls_sess = iscsi_conn_to_session(cls_conn);
|
|
|
|
struct iscsi_session *sess, *existing_sess;
|
|
|
|
struct iscsi_conn *conn, *existing_conn;
|
|
|
|
struct ddb_entry *ddb_entry;
|
|
|
|
|
|
|
|
sess = cls_sess->dd_data;
|
|
|
|
conn = cls_conn->dd_data;
|
|
|
|
|
|
|
|
if (sess->targetname == NULL ||
|
|
|
|
conn->persistent_address == NULL ||
|
|
|
|
conn->persistent_port == 0)
|
|
|
|
return QLA_ERROR;
|
|
|
|
|
|
|
|
max_ddbs = is_qla40XX(ha) ? MAX_DEV_DB_ENTRIES_40XX :
|
|
|
|
MAX_DEV_DB_ENTRIES;
|
|
|
|
|
|
|
|
for (idx = 0; idx < max_ddbs; idx++) {
|
|
|
|
ddb_entry = qla4xxx_lookup_ddb_by_fw_index(ha, idx);
|
|
|
|
if (ddb_entry == NULL)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (ddb_entry->ddb_type != FLASH_DDB)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
existing_sess = ddb_entry->sess->dd_data;
|
|
|
|
existing_conn = ddb_entry->conn->dd_data;
|
|
|
|
|
|
|
|
if (existing_sess->targetname == NULL ||
|
|
|
|
existing_conn->persistent_address == NULL ||
|
|
|
|
existing_conn->persistent_port == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha,
|
|
|
|
"IQN = %s User IQN = %s\n",
|
|
|
|
existing_sess->targetname,
|
|
|
|
sess->targetname));
|
|
|
|
|
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha,
|
|
|
|
"IP = %s User IP = %s\n",
|
|
|
|
existing_conn->persistent_address,
|
|
|
|
conn->persistent_address));
|
|
|
|
|
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha,
|
|
|
|
"Port = %d User Port = %d\n",
|
|
|
|
existing_conn->persistent_port,
|
|
|
|
conn->persistent_port));
|
|
|
|
|
|
|
|
if (strcmp(existing_sess->targetname, sess->targetname))
|
|
|
|
continue;
|
|
|
|
rval = qla4xxx_match_ipaddress(ha, ddb_entry,
|
|
|
|
existing_conn->persistent_address,
|
|
|
|
conn->persistent_address);
|
|
|
|
if (rval == QLA_ERROR)
|
|
|
|
continue;
|
|
|
|
if (existing_conn->persistent_port != conn->persistent_port)
|
|
|
|
continue;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (idx == max_ddbs)
|
|
|
|
return QLA_ERROR;
|
|
|
|
|
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha,
|
|
|
|
"Match found in fwdb sessions\n"));
|
|
|
|
return QLA_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2011-07-25 20:48:53 +02:00
|
|
|
static struct iscsi_cls_session *
|
|
|
|
qla4xxx_session_create(struct iscsi_endpoint *ep,
|
|
|
|
uint16_t cmds_max, uint16_t qdepth,
|
|
|
|
uint32_t initial_cmdsn)
|
|
|
|
{
|
|
|
|
struct iscsi_cls_session *cls_sess;
|
|
|
|
struct scsi_qla_host *ha;
|
|
|
|
struct qla_endpoint *qla_ep;
|
|
|
|
struct ddb_entry *ddb_entry;
|
2011-12-02 04:38:41 +01:00
|
|
|
uint16_t ddb_index;
|
2011-07-25 20:48:53 +02:00
|
|
|
struct iscsi_session *sess;
|
|
|
|
struct sockaddr *dst_addr;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (!ep) {
|
|
|
|
printk(KERN_ERR "qla4xxx: missing ep.\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
qla_ep = ep->dd_data;
|
|
|
|
dst_addr = (struct sockaddr *)&qla_ep->dst_addr;
|
|
|
|
ha = to_qla_host(qla_ep->host);
|
2013-12-16 12:49:48 +01:00
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha, "%s: host: %ld\n", __func__,
|
|
|
|
ha->host_no));
|
2011-10-08 01:55:46 +02:00
|
|
|
|
2011-12-02 04:38:41 +01:00
|
|
|
ret = qla4xxx_get_ddb_index(ha, &ddb_index);
|
|
|
|
if (ret == QLA_ERROR)
|
2011-07-25 20:48:53 +02:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
cls_sess = iscsi_session_setup(&qla4xxx_iscsi_transport, qla_ep->host,
|
|
|
|
cmds_max, sizeof(struct ddb_entry),
|
|
|
|
sizeof(struct ql4_task_data),
|
|
|
|
initial_cmdsn, ddb_index);
|
|
|
|
if (!cls_sess)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
sess = cls_sess->dd_data;
|
|
|
|
ddb_entry = sess->dd_data;
|
|
|
|
ddb_entry->fw_ddb_index = ddb_index;
|
|
|
|
ddb_entry->fw_ddb_device_state = DDB_DS_NO_CONNECTION_ACTIVE;
|
|
|
|
ddb_entry->ha = ha;
|
|
|
|
ddb_entry->sess = cls_sess;
|
2011-12-02 04:38:41 +01:00
|
|
|
ddb_entry->unblock_sess = qla4xxx_unblock_ddb;
|
|
|
|
ddb_entry->ddb_change = qla4xxx_ddb_change;
|
2013-12-16 12:49:40 +01:00
|
|
|
clear_bit(DDB_CONN_CLOSE_FAILURE, &ddb_entry->flags);
|
2011-07-25 20:48:53 +02:00
|
|
|
cls_sess->recovery_tmo = ql4xsess_recovery_tmo;
|
|
|
|
ha->fw_ddb_index_map[ddb_entry->fw_ddb_index] = ddb_entry;
|
|
|
|
ha->tot_ddbs++;
|
|
|
|
|
|
|
|
return cls_sess;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void qla4xxx_session_destroy(struct iscsi_cls_session *cls_sess)
|
|
|
|
{
|
|
|
|
struct iscsi_session *sess;
|
|
|
|
struct ddb_entry *ddb_entry;
|
|
|
|
struct scsi_qla_host *ha;
|
2012-04-24 07:32:34 +02:00
|
|
|
unsigned long flags, wtime;
|
|
|
|
struct dev_db_entry *fw_ddb_entry = NULL;
|
|
|
|
dma_addr_t fw_ddb_entry_dma;
|
|
|
|
uint32_t ddb_state;
|
|
|
|
int ret;
|
2011-07-25 20:48:53 +02:00
|
|
|
|
|
|
|
sess = cls_sess->dd_data;
|
|
|
|
ddb_entry = sess->dd_data;
|
|
|
|
ha = ddb_entry->ha;
|
2013-12-16 12:49:48 +01:00
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha, "%s: host: %ld\n", __func__,
|
|
|
|
ha->host_no));
|
2011-07-25 20:48:53 +02:00
|
|
|
|
2012-04-24 07:32:34 +02:00
|
|
|
fw_ddb_entry = dma_alloc_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry),
|
|
|
|
&fw_ddb_entry_dma, GFP_KERNEL);
|
|
|
|
if (!fw_ddb_entry) {
|
|
|
|
ql4_printk(KERN_ERR, ha,
|
|
|
|
"%s: Unable to allocate dma buffer\n", __func__);
|
|
|
|
goto destroy_session;
|
|
|
|
}
|
|
|
|
|
|
|
|
wtime = jiffies + (HZ * LOGOUT_TOV);
|
|
|
|
do {
|
|
|
|
ret = qla4xxx_get_fwddb_entry(ha, ddb_entry->fw_ddb_index,
|
|
|
|
fw_ddb_entry, fw_ddb_entry_dma,
|
|
|
|
NULL, NULL, &ddb_state, NULL,
|
|
|
|
NULL, NULL);
|
|
|
|
if (ret == QLA_ERROR)
|
|
|
|
goto destroy_session;
|
|
|
|
|
|
|
|
if ((ddb_state == DDB_DS_NO_CONNECTION_ACTIVE) ||
|
|
|
|
(ddb_state == DDB_DS_SESSION_FAILED))
|
|
|
|
goto destroy_session;
|
|
|
|
|
|
|
|
schedule_timeout_uninterruptible(HZ);
|
|
|
|
} while ((time_after(wtime, jiffies)));
|
|
|
|
|
|
|
|
destroy_session:
|
2011-10-08 01:55:46 +02:00
|
|
|
qla4xxx_clear_ddb_entry(ha, ddb_entry->fw_ddb_index);
|
2013-12-16 12:49:40 +01:00
|
|
|
if (test_and_clear_bit(DDB_CONN_CLOSE_FAILURE, &ddb_entry->flags))
|
|
|
|
clear_bit(ddb_entry->fw_ddb_index, ha->ddb_idx_map);
|
2011-07-25 20:48:53 +02:00
|
|
|
spin_lock_irqsave(&ha->hardware_lock, flags);
|
|
|
|
qla4xxx_free_ddb(ha, ddb_entry);
|
|
|
|
spin_unlock_irqrestore(&ha->hardware_lock, flags);
|
2012-04-24 07:32:34 +02:00
|
|
|
|
2011-07-25 20:48:53 +02:00
|
|
|
iscsi_session_teardown(cls_sess);
|
2012-04-24 07:32:34 +02:00
|
|
|
|
|
|
|
if (fw_ddb_entry)
|
|
|
|
dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry),
|
|
|
|
fw_ddb_entry, fw_ddb_entry_dma);
|
2011-07-25 20:48:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct iscsi_cls_conn *
|
|
|
|
qla4xxx_conn_create(struct iscsi_cls_session *cls_sess, uint32_t conn_idx)
|
|
|
|
{
|
|
|
|
struct iscsi_cls_conn *cls_conn;
|
|
|
|
struct iscsi_session *sess;
|
|
|
|
struct ddb_entry *ddb_entry;
|
2013-12-16 12:49:48 +01:00
|
|
|
struct scsi_qla_host *ha;
|
2011-07-25 20:48:53 +02:00
|
|
|
|
|
|
|
cls_conn = iscsi_conn_setup(cls_sess, sizeof(struct qla_conn),
|
|
|
|
conn_idx);
|
2013-12-16 12:49:48 +01:00
|
|
|
if (!cls_conn) {
|
|
|
|
pr_info("%s: Can not create connection for conn_idx = %u\n",
|
|
|
|
__func__, conn_idx);
|
2011-12-02 04:38:43 +01:00
|
|
|
return NULL;
|
2013-12-16 12:49:48 +01:00
|
|
|
}
|
2011-12-02 04:38:43 +01:00
|
|
|
|
2011-07-25 20:48:53 +02:00
|
|
|
sess = cls_sess->dd_data;
|
|
|
|
ddb_entry = sess->dd_data;
|
|
|
|
ddb_entry->conn = cls_conn;
|
|
|
|
|
2013-12-16 12:49:48 +01:00
|
|
|
ha = ddb_entry->ha;
|
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha, "%s: conn_idx = %u\n", __func__,
|
|
|
|
conn_idx));
|
2011-07-25 20:48:53 +02:00
|
|
|
return cls_conn;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int qla4xxx_conn_bind(struct iscsi_cls_session *cls_session,
|
|
|
|
struct iscsi_cls_conn *cls_conn,
|
|
|
|
uint64_t transport_fd, int is_leading)
|
|
|
|
{
|
|
|
|
struct iscsi_conn *conn;
|
|
|
|
struct qla_conn *qla_conn;
|
|
|
|
struct iscsi_endpoint *ep;
|
2013-12-16 12:49:48 +01:00
|
|
|
struct ddb_entry *ddb_entry;
|
|
|
|
struct scsi_qla_host *ha;
|
|
|
|
struct iscsi_session *sess;
|
|
|
|
|
|
|
|
sess = cls_session->dd_data;
|
|
|
|
ddb_entry = sess->dd_data;
|
|
|
|
ha = ddb_entry->ha;
|
2011-07-25 20:48:53 +02:00
|
|
|
|
2013-12-16 12:49:48 +01:00
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha, "%s: sid = %d, cid = %d\n", __func__,
|
|
|
|
cls_session->sid, cls_conn->cid));
|
2011-07-25 20:48:53 +02:00
|
|
|
|
|
|
|
if (iscsi_conn_bind(cls_session, cls_conn, is_leading))
|
|
|
|
return -EINVAL;
|
|
|
|
ep = iscsi_lookup_endpoint(transport_fd);
|
|
|
|
conn = cls_conn->dd_data;
|
|
|
|
qla_conn = conn->dd_data;
|
|
|
|
qla_conn->qla_ep = ep->dd_data;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int qla4xxx_conn_start(struct iscsi_cls_conn *cls_conn)
|
|
|
|
{
|
|
|
|
struct iscsi_cls_session *cls_sess = iscsi_conn_to_session(cls_conn);
|
|
|
|
struct iscsi_session *sess;
|
|
|
|
struct ddb_entry *ddb_entry;
|
|
|
|
struct scsi_qla_host *ha;
|
2011-12-02 04:38:41 +01:00
|
|
|
struct dev_db_entry *fw_ddb_entry = NULL;
|
2011-07-25 20:48:53 +02:00
|
|
|
dma_addr_t fw_ddb_entry_dma;
|
|
|
|
uint32_t mbx_sts = 0;
|
|
|
|
int ret = 0;
|
|
|
|
int status = QLA_SUCCESS;
|
|
|
|
|
|
|
|
sess = cls_sess->dd_data;
|
|
|
|
ddb_entry = sess->dd_data;
|
|
|
|
ha = ddb_entry->ha;
|
2013-12-16 12:49:48 +01:00
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha, "%s: sid = %d, cid = %d\n", __func__,
|
|
|
|
cls_sess->sid, cls_conn->cid));
|
2011-07-25 20:48:53 +02:00
|
|
|
|
2011-12-02 04:38:41 +01:00
|
|
|
/* Check if we have matching FW DDB, if yes then do not
|
|
|
|
* login to this target. This could cause target to logout previous
|
|
|
|
* connection
|
|
|
|
*/
|
|
|
|
ret = qla4xxx_match_fwdb_session(ha, cls_conn);
|
|
|
|
if (ret == QLA_SUCCESS) {
|
|
|
|
ql4_printk(KERN_INFO, ha,
|
|
|
|
"Session already exist in FW.\n");
|
|
|
|
ret = -EEXIST;
|
|
|
|
goto exit_conn_start;
|
|
|
|
}
|
|
|
|
|
2011-07-25 20:48:53 +02:00
|
|
|
fw_ddb_entry = dma_alloc_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry),
|
|
|
|
&fw_ddb_entry_dma, GFP_KERNEL);
|
|
|
|
if (!fw_ddb_entry) {
|
|
|
|
ql4_printk(KERN_ERR, ha,
|
|
|
|
"%s: Unable to allocate dma buffer\n", __func__);
|
2011-12-02 04:38:41 +01:00
|
|
|
ret = -ENOMEM;
|
|
|
|
goto exit_conn_start;
|
2011-07-25 20:48:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ret = qla4xxx_set_param_ddbentry(ha, ddb_entry, cls_conn, &mbx_sts);
|
|
|
|
if (ret) {
|
|
|
|
/* If iscsid is stopped and started then no need to do
|
|
|
|
* set param again since ddb state will be already
|
|
|
|
* active and FW does not allow set ddb to an
|
|
|
|
* active session.
|
|
|
|
*/
|
|
|
|
if (mbx_sts)
|
|
|
|
if (ddb_entry->fw_ddb_device_state ==
|
2011-10-08 01:55:49 +02:00
|
|
|
DDB_DS_SESSION_ACTIVE) {
|
2011-12-02 04:38:41 +01:00
|
|
|
ddb_entry->unblock_sess(ddb_entry->sess);
|
2011-07-25 20:48:53 +02:00
|
|
|
goto exit_set_param;
|
2011-10-08 01:55:49 +02:00
|
|
|
}
|
2011-07-25 20:48:53 +02:00
|
|
|
|
|
|
|
ql4_printk(KERN_ERR, ha, "%s: Failed set param for index[%d]\n",
|
|
|
|
__func__, ddb_entry->fw_ddb_index);
|
|
|
|
goto exit_conn_start;
|
|
|
|
}
|
|
|
|
|
|
|
|
status = qla4xxx_conn_open(ha, ddb_entry->fw_ddb_index);
|
|
|
|
if (status == QLA_ERROR) {
|
2011-07-25 20:48:54 +02:00
|
|
|
ql4_printk(KERN_ERR, ha, "%s: Login failed: %s\n", __func__,
|
|
|
|
sess->targetname);
|
2011-07-25 20:48:53 +02:00
|
|
|
ret = -EINVAL;
|
|
|
|
goto exit_conn_start;
|
|
|
|
}
|
|
|
|
|
2011-10-08 01:55:47 +02:00
|
|
|
if (ddb_entry->fw_ddb_device_state == DDB_DS_NO_CONNECTION_ACTIVE)
|
|
|
|
ddb_entry->fw_ddb_device_state = DDB_DS_LOGIN_IN_PROCESS;
|
|
|
|
|
|
|
|
DEBUG2(printk(KERN_INFO "%s: DDB state [%d]\n", __func__,
|
|
|
|
ddb_entry->fw_ddb_device_state));
|
2011-07-25 20:48:53 +02:00
|
|
|
|
|
|
|
exit_set_param:
|
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
exit_conn_start:
|
2011-12-02 04:38:41 +01:00
|
|
|
if (fw_ddb_entry)
|
|
|
|
dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry),
|
|
|
|
fw_ddb_entry, fw_ddb_entry_dma);
|
2011-07-25 20:48:53 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void qla4xxx_conn_destroy(struct iscsi_cls_conn *cls_conn)
|
|
|
|
{
|
|
|
|
struct iscsi_cls_session *cls_sess = iscsi_conn_to_session(cls_conn);
|
|
|
|
struct iscsi_session *sess;
|
|
|
|
struct scsi_qla_host *ha;
|
|
|
|
struct ddb_entry *ddb_entry;
|
|
|
|
int options;
|
|
|
|
|
|
|
|
sess = cls_sess->dd_data;
|
|
|
|
ddb_entry = sess->dd_data;
|
|
|
|
ha = ddb_entry->ha;
|
2013-12-16 12:49:48 +01:00
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha, "%s: cid = %d\n", __func__,
|
|
|
|
cls_conn->cid));
|
2011-07-25 20:48:53 +02:00
|
|
|
|
|
|
|
options = LOGOUT_OPTION_CLOSE_SESSION;
|
|
|
|
if (qla4xxx_session_logout_ddb(ha, ddb_entry, options) == QLA_ERROR)
|
|
|
|
ql4_printk(KERN_ERR, ha, "%s: Logout failed\n", __func__);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void qla4xxx_task_work(struct work_struct *wdata)
|
|
|
|
{
|
|
|
|
struct ql4_task_data *task_data;
|
|
|
|
struct scsi_qla_host *ha;
|
|
|
|
struct passthru_status *sts;
|
|
|
|
struct iscsi_task *task;
|
|
|
|
struct iscsi_hdr *hdr;
|
|
|
|
uint8_t *data;
|
|
|
|
uint32_t data_len;
|
|
|
|
struct iscsi_conn *conn;
|
|
|
|
int hdr_len;
|
|
|
|
itt_t itt;
|
|
|
|
|
|
|
|
task_data = container_of(wdata, struct ql4_task_data, task_work);
|
|
|
|
ha = task_data->ha;
|
|
|
|
task = task_data->task;
|
|
|
|
sts = &task_data->sts;
|
|
|
|
hdr_len = sizeof(struct iscsi_hdr);
|
|
|
|
|
|
|
|
DEBUG3(printk(KERN_INFO "Status returned\n"));
|
|
|
|
DEBUG3(qla4xxx_dump_buffer(sts, 64));
|
|
|
|
DEBUG3(printk(KERN_INFO "Response buffer"));
|
|
|
|
DEBUG3(qla4xxx_dump_buffer(task_data->resp_buffer, 64));
|
|
|
|
|
|
|
|
conn = task->conn;
|
|
|
|
|
|
|
|
switch (sts->completionStatus) {
|
|
|
|
case PASSTHRU_STATUS_COMPLETE:
|
|
|
|
hdr = (struct iscsi_hdr *)task_data->resp_buffer;
|
|
|
|
/* Assign back the itt in hdr, until we use the PREASSIGN_TAG */
|
|
|
|
itt = sts->handle;
|
|
|
|
hdr->itt = itt;
|
|
|
|
data = task_data->resp_buffer + hdr_len;
|
|
|
|
data_len = task_data->resp_len - hdr_len;
|
|
|
|
iscsi_complete_pdu(conn, hdr, data, data_len);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ql4_printk(KERN_ERR, ha, "Passthru failed status = 0x%x\n",
|
|
|
|
sts->completionStatus);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int qla4xxx_alloc_pdu(struct iscsi_task *task, uint8_t opcode)
|
|
|
|
{
|
|
|
|
struct ql4_task_data *task_data;
|
|
|
|
struct iscsi_session *sess;
|
|
|
|
struct ddb_entry *ddb_entry;
|
|
|
|
struct scsi_qla_host *ha;
|
|
|
|
int hdr_len;
|
|
|
|
|
|
|
|
sess = task->conn->session;
|
|
|
|
ddb_entry = sess->dd_data;
|
|
|
|
ha = ddb_entry->ha;
|
|
|
|
task_data = task->dd_data;
|
|
|
|
memset(task_data, 0, sizeof(struct ql4_task_data));
|
|
|
|
|
|
|
|
if (task->sc) {
|
|
|
|
ql4_printk(KERN_INFO, ha,
|
|
|
|
"%s: SCSI Commands not implemented\n", __func__);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
hdr_len = sizeof(struct iscsi_hdr);
|
|
|
|
task_data->ha = ha;
|
|
|
|
task_data->task = task;
|
|
|
|
|
|
|
|
if (task->data_count) {
|
|
|
|
task_data->data_dma = dma_map_single(&ha->pdev->dev, task->data,
|
|
|
|
task->data_count,
|
|
|
|
PCI_DMA_TODEVICE);
|
|
|
|
}
|
|
|
|
|
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha, "%s: MaxRecvLen %u, iscsi hrd %d\n",
|
|
|
|
__func__, task->conn->max_recv_dlength, hdr_len));
|
|
|
|
|
2011-10-08 01:55:50 +02:00
|
|
|
task_data->resp_len = task->conn->max_recv_dlength + hdr_len;
|
2011-07-25 20:48:53 +02:00
|
|
|
task_data->resp_buffer = dma_alloc_coherent(&ha->pdev->dev,
|
|
|
|
task_data->resp_len,
|
|
|
|
&task_data->resp_dma,
|
|
|
|
GFP_ATOMIC);
|
|
|
|
if (!task_data->resp_buffer)
|
|
|
|
goto exit_alloc_pdu;
|
|
|
|
|
2011-10-08 01:55:50 +02:00
|
|
|
task_data->req_len = task->data_count + hdr_len;
|
2011-07-25 20:48:53 +02:00
|
|
|
task_data->req_buffer = dma_alloc_coherent(&ha->pdev->dev,
|
2011-10-08 01:55:50 +02:00
|
|
|
task_data->req_len,
|
2011-07-25 20:48:53 +02:00
|
|
|
&task_data->req_dma,
|
|
|
|
GFP_ATOMIC);
|
|
|
|
if (!task_data->req_buffer)
|
|
|
|
goto exit_alloc_pdu;
|
|
|
|
|
|
|
|
task->hdr = task_data->req_buffer;
|
|
|
|
|
|
|
|
INIT_WORK(&task_data->task_work, qla4xxx_task_work);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
exit_alloc_pdu:
|
|
|
|
if (task_data->resp_buffer)
|
|
|
|
dma_free_coherent(&ha->pdev->dev, task_data->resp_len,
|
|
|
|
task_data->resp_buffer, task_data->resp_dma);
|
|
|
|
|
|
|
|
if (task_data->req_buffer)
|
2011-10-08 01:55:50 +02:00
|
|
|
dma_free_coherent(&ha->pdev->dev, task_data->req_len,
|
2011-07-25 20:48:53 +02:00
|
|
|
task_data->req_buffer, task_data->req_dma);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void qla4xxx_task_cleanup(struct iscsi_task *task)
|
|
|
|
{
|
|
|
|
struct ql4_task_data *task_data;
|
|
|
|
struct iscsi_session *sess;
|
|
|
|
struct ddb_entry *ddb_entry;
|
|
|
|
struct scsi_qla_host *ha;
|
|
|
|
int hdr_len;
|
|
|
|
|
|
|
|
hdr_len = sizeof(struct iscsi_hdr);
|
|
|
|
sess = task->conn->session;
|
|
|
|
ddb_entry = sess->dd_data;
|
|
|
|
ha = ddb_entry->ha;
|
|
|
|
task_data = task->dd_data;
|
|
|
|
|
|
|
|
if (task->data_count) {
|
|
|
|
dma_unmap_single(&ha->pdev->dev, task_data->data_dma,
|
|
|
|
task->data_count, PCI_DMA_TODEVICE);
|
|
|
|
}
|
|
|
|
|
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha, "%s: MaxRecvLen %u, iscsi hrd %d\n",
|
|
|
|
__func__, task->conn->max_recv_dlength, hdr_len));
|
|
|
|
|
|
|
|
dma_free_coherent(&ha->pdev->dev, task_data->resp_len,
|
|
|
|
task_data->resp_buffer, task_data->resp_dma);
|
2011-10-08 01:55:50 +02:00
|
|
|
dma_free_coherent(&ha->pdev->dev, task_data->req_len,
|
2011-07-25 20:48:53 +02:00
|
|
|
task_data->req_buffer, task_data->req_dma);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int qla4xxx_task_xmit(struct iscsi_task *task)
|
|
|
|
{
|
|
|
|
struct scsi_cmnd *sc = task->sc;
|
|
|
|
struct iscsi_session *sess = task->conn->session;
|
|
|
|
struct ddb_entry *ddb_entry = sess->dd_data;
|
|
|
|
struct scsi_qla_host *ha = ddb_entry->ha;
|
|
|
|
|
|
|
|
if (!sc)
|
|
|
|
return qla4xxx_send_passthru0(task);
|
|
|
|
|
|
|
|
ql4_printk(KERN_INFO, ha, "%s: scsi cmd xmit not implemented\n",
|
|
|
|
__func__);
|
|
|
|
return -ENOSYS;
|
|
|
|
}
|
|
|
|
|
2013-03-22 12:41:31 +01:00
|
|
|
static int qla4xxx_copy_from_fwddb_param(struct iscsi_bus_flash_session *sess,
|
|
|
|
struct iscsi_bus_flash_conn *conn,
|
|
|
|
struct dev_db_entry *fw_ddb_entry)
|
|
|
|
{
|
|
|
|
unsigned long options = 0;
|
|
|
|
int rc = 0;
|
|
|
|
|
|
|
|
options = le16_to_cpu(fw_ddb_entry->options);
|
|
|
|
conn->is_fw_assigned_ipv6 = test_bit(OPT_IS_FW_ASSIGNED_IPV6, &options);
|
|
|
|
if (test_bit(OPT_IPV6_DEVICE, &options)) {
|
2013-03-25 13:08:32 +01:00
|
|
|
rc = iscsi_switch_str_param(&sess->portal_type,
|
|
|
|
PORTAL_TYPE_IPV6);
|
2013-03-22 12:41:31 +01:00
|
|
|
if (rc)
|
|
|
|
goto exit_copy;
|
|
|
|
} else {
|
2013-03-25 13:08:32 +01:00
|
|
|
rc = iscsi_switch_str_param(&sess->portal_type,
|
|
|
|
PORTAL_TYPE_IPV4);
|
2013-03-22 12:41:31 +01:00
|
|
|
if (rc)
|
|
|
|
goto exit_copy;
|
|
|
|
}
|
|
|
|
|
|
|
|
sess->auto_snd_tgt_disable = test_bit(OPT_AUTO_SENDTGTS_DISABLE,
|
|
|
|
&options);
|
|
|
|
sess->discovery_sess = test_bit(OPT_DISC_SESSION, &options);
|
|
|
|
sess->entry_state = test_bit(OPT_ENTRY_STATE, &options);
|
|
|
|
|
|
|
|
options = le16_to_cpu(fw_ddb_entry->iscsi_options);
|
|
|
|
conn->hdrdgst_en = test_bit(ISCSIOPT_HEADER_DIGEST_EN, &options);
|
|
|
|
conn->datadgst_en = test_bit(ISCSIOPT_DATA_DIGEST_EN, &options);
|
|
|
|
sess->imm_data_en = test_bit(ISCSIOPT_IMMEDIATE_DATA_EN, &options);
|
|
|
|
sess->initial_r2t_en = test_bit(ISCSIOPT_INITIAL_R2T_EN, &options);
|
|
|
|
sess->dataseq_inorder_en = test_bit(ISCSIOPT_DATA_SEQ_IN_ORDER,
|
|
|
|
&options);
|
|
|
|
sess->pdu_inorder_en = test_bit(ISCSIOPT_DATA_PDU_IN_ORDER, &options);
|
|
|
|
sess->chap_auth_en = test_bit(ISCSIOPT_CHAP_AUTH_EN, &options);
|
|
|
|
conn->snack_req_en = test_bit(ISCSIOPT_SNACK_REQ_EN, &options);
|
|
|
|
sess->discovery_logout_en = test_bit(ISCSIOPT_DISCOVERY_LOGOUT_EN,
|
|
|
|
&options);
|
|
|
|
sess->bidi_chap_en = test_bit(ISCSIOPT_BIDI_CHAP_EN, &options);
|
|
|
|
sess->discovery_auth_optional =
|
|
|
|
test_bit(ISCSIOPT_DISCOVERY_AUTH_OPTIONAL, &options);
|
|
|
|
if (test_bit(ISCSIOPT_ERL1, &options))
|
|
|
|
sess->erl |= BIT_1;
|
|
|
|
if (test_bit(ISCSIOPT_ERL0, &options))
|
|
|
|
sess->erl |= BIT_0;
|
|
|
|
|
|
|
|
options = le16_to_cpu(fw_ddb_entry->tcp_options);
|
|
|
|
conn->tcp_timestamp_stat = test_bit(TCPOPT_TIMESTAMP_STAT, &options);
|
|
|
|
conn->tcp_nagle_disable = test_bit(TCPOPT_NAGLE_DISABLE, &options);
|
|
|
|
conn->tcp_wsf_disable = test_bit(TCPOPT_WSF_DISABLE, &options);
|
|
|
|
if (test_bit(TCPOPT_TIMER_SCALE3, &options))
|
|
|
|
conn->tcp_timer_scale |= BIT_3;
|
|
|
|
if (test_bit(TCPOPT_TIMER_SCALE2, &options))
|
|
|
|
conn->tcp_timer_scale |= BIT_2;
|
|
|
|
if (test_bit(TCPOPT_TIMER_SCALE1, &options))
|
|
|
|
conn->tcp_timer_scale |= BIT_1;
|
|
|
|
|
|
|
|
conn->tcp_timer_scale >>= 1;
|
|
|
|
conn->tcp_timestamp_en = test_bit(TCPOPT_TIMESTAMP_EN, &options);
|
|
|
|
|
|
|
|
options = le16_to_cpu(fw_ddb_entry->ip_options);
|
|
|
|
conn->fragment_disable = test_bit(IPOPT_FRAGMENT_DISABLE, &options);
|
|
|
|
|
|
|
|
conn->max_recv_dlength = BYTE_UNITS *
|
|
|
|
le16_to_cpu(fw_ddb_entry->iscsi_max_rcv_data_seg_len);
|
|
|
|
conn->max_xmit_dlength = BYTE_UNITS *
|
|
|
|
le16_to_cpu(fw_ddb_entry->iscsi_max_snd_data_seg_len);
|
|
|
|
sess->first_burst = BYTE_UNITS *
|
|
|
|
le16_to_cpu(fw_ddb_entry->iscsi_first_burst_len);
|
|
|
|
sess->max_burst = BYTE_UNITS *
|
|
|
|
le16_to_cpu(fw_ddb_entry->iscsi_max_burst_len);
|
|
|
|
sess->max_r2t = le16_to_cpu(fw_ddb_entry->iscsi_max_outsnd_r2t);
|
|
|
|
sess->time2wait = le16_to_cpu(fw_ddb_entry->iscsi_def_time2wait);
|
|
|
|
sess->time2retain = le16_to_cpu(fw_ddb_entry->iscsi_def_time2retain);
|
|
|
|
sess->tpgt = le32_to_cpu(fw_ddb_entry->tgt_portal_grp);
|
|
|
|
conn->max_segment_size = le16_to_cpu(fw_ddb_entry->mss);
|
|
|
|
conn->tcp_xmit_wsf = fw_ddb_entry->tcp_xmt_wsf;
|
|
|
|
conn->tcp_recv_wsf = fw_ddb_entry->tcp_rcv_wsf;
|
|
|
|
conn->ipv6_flow_label = le16_to_cpu(fw_ddb_entry->ipv6_flow_lbl);
|
|
|
|
conn->keepalive_timeout = le16_to_cpu(fw_ddb_entry->ka_timeout);
|
|
|
|
conn->local_port = le16_to_cpu(fw_ddb_entry->lcl_port);
|
|
|
|
conn->statsn = le32_to_cpu(fw_ddb_entry->stat_sn);
|
|
|
|
conn->exp_statsn = le32_to_cpu(fw_ddb_entry->exp_stat_sn);
|
|
|
|
sess->discovery_parent_idx = le16_to_cpu(fw_ddb_entry->ddb_link);
|
|
|
|
sess->discovery_parent_type = le16_to_cpu(fw_ddb_entry->ddb_link);
|
|
|
|
sess->chap_out_idx = le16_to_cpu(fw_ddb_entry->chap_tbl_idx);
|
|
|
|
sess->tsid = le16_to_cpu(fw_ddb_entry->tsid);
|
|
|
|
|
|
|
|
sess->default_taskmgmt_timeout =
|
|
|
|
le16_to_cpu(fw_ddb_entry->def_timeout);
|
|
|
|
conn->port = le16_to_cpu(fw_ddb_entry->port);
|
|
|
|
|
|
|
|
options = le16_to_cpu(fw_ddb_entry->options);
|
|
|
|
conn->ipaddress = kzalloc(IPv6_ADDR_LEN, GFP_KERNEL);
|
|
|
|
if (!conn->ipaddress) {
|
|
|
|
rc = -ENOMEM;
|
|
|
|
goto exit_copy;
|
|
|
|
}
|
|
|
|
|
|
|
|
conn->redirect_ipaddr = kzalloc(IPv6_ADDR_LEN, GFP_KERNEL);
|
|
|
|
if (!conn->redirect_ipaddr) {
|
|
|
|
rc = -ENOMEM;
|
|
|
|
goto exit_copy;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(conn->ipaddress, fw_ddb_entry->ip_addr, IPv6_ADDR_LEN);
|
|
|
|
memcpy(conn->redirect_ipaddr, fw_ddb_entry->tgt_addr, IPv6_ADDR_LEN);
|
|
|
|
|
|
|
|
if (test_bit(OPT_IPV6_DEVICE, &options)) {
|
|
|
|
conn->ipv6_traffic_class = fw_ddb_entry->ipv4_tos;
|
|
|
|
|
2014-05-26 17:21:13 +02:00
|
|
|
conn->link_local_ipv6_addr = kmemdup(
|
|
|
|
fw_ddb_entry->link_local_ipv6_addr,
|
|
|
|
IPv6_ADDR_LEN, GFP_KERNEL);
|
2013-03-22 12:41:31 +01:00
|
|
|
if (!conn->link_local_ipv6_addr) {
|
|
|
|
rc = -ENOMEM;
|
|
|
|
goto exit_copy;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
conn->ipv4_tos = fw_ddb_entry->ipv4_tos;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fw_ddb_entry->iscsi_name[0]) {
|
|
|
|
rc = iscsi_switch_str_param(&sess->targetname,
|
|
|
|
(char *)fw_ddb_entry->iscsi_name);
|
|
|
|
if (rc)
|
|
|
|
goto exit_copy;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fw_ddb_entry->iscsi_alias[0]) {
|
|
|
|
rc = iscsi_switch_str_param(&sess->targetalias,
|
|
|
|
(char *)fw_ddb_entry->iscsi_alias);
|
|
|
|
if (rc)
|
|
|
|
goto exit_copy;
|
|
|
|
}
|
|
|
|
|
|
|
|
COPY_ISID(sess->isid, fw_ddb_entry->isid);
|
|
|
|
|
|
|
|
exit_copy:
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int qla4xxx_copy_to_fwddb_param(struct iscsi_bus_flash_session *sess,
|
|
|
|
struct iscsi_bus_flash_conn *conn,
|
|
|
|
struct dev_db_entry *fw_ddb_entry)
|
|
|
|
{
|
|
|
|
uint16_t options;
|
|
|
|
int rc = 0;
|
|
|
|
|
|
|
|
options = le16_to_cpu(fw_ddb_entry->options);
|
|
|
|
SET_BITVAL(conn->is_fw_assigned_ipv6, options, BIT_11);
|
2013-03-25 13:08:32 +01:00
|
|
|
if (!strncmp(sess->portal_type, PORTAL_TYPE_IPV6, 4))
|
2013-03-22 12:41:31 +01:00
|
|
|
options |= BIT_8;
|
|
|
|
else
|
|
|
|
options &= ~BIT_8;
|
|
|
|
|
|
|
|
SET_BITVAL(sess->auto_snd_tgt_disable, options, BIT_6);
|
|
|
|
SET_BITVAL(sess->discovery_sess, options, BIT_4);
|
|
|
|
SET_BITVAL(sess->entry_state, options, BIT_3);
|
|
|
|
fw_ddb_entry->options = cpu_to_le16(options);
|
|
|
|
|
|
|
|
options = le16_to_cpu(fw_ddb_entry->iscsi_options);
|
|
|
|
SET_BITVAL(conn->hdrdgst_en, options, BIT_13);
|
|
|
|
SET_BITVAL(conn->datadgst_en, options, BIT_12);
|
|
|
|
SET_BITVAL(sess->imm_data_en, options, BIT_11);
|
|
|
|
SET_BITVAL(sess->initial_r2t_en, options, BIT_10);
|
|
|
|
SET_BITVAL(sess->dataseq_inorder_en, options, BIT_9);
|
|
|
|
SET_BITVAL(sess->pdu_inorder_en, options, BIT_8);
|
|
|
|
SET_BITVAL(sess->chap_auth_en, options, BIT_7);
|
|
|
|
SET_BITVAL(conn->snack_req_en, options, BIT_6);
|
|
|
|
SET_BITVAL(sess->discovery_logout_en, options, BIT_5);
|
|
|
|
SET_BITVAL(sess->bidi_chap_en, options, BIT_4);
|
|
|
|
SET_BITVAL(sess->discovery_auth_optional, options, BIT_3);
|
|
|
|
SET_BITVAL(sess->erl & BIT_1, options, BIT_1);
|
|
|
|
SET_BITVAL(sess->erl & BIT_0, options, BIT_0);
|
|
|
|
fw_ddb_entry->iscsi_options = cpu_to_le16(options);
|
|
|
|
|
|
|
|
options = le16_to_cpu(fw_ddb_entry->tcp_options);
|
|
|
|
SET_BITVAL(conn->tcp_timestamp_stat, options, BIT_6);
|
|
|
|
SET_BITVAL(conn->tcp_nagle_disable, options, BIT_5);
|
|
|
|
SET_BITVAL(conn->tcp_wsf_disable, options, BIT_4);
|
|
|
|
SET_BITVAL(conn->tcp_timer_scale & BIT_2, options, BIT_3);
|
|
|
|
SET_BITVAL(conn->tcp_timer_scale & BIT_1, options, BIT_2);
|
|
|
|
SET_BITVAL(conn->tcp_timer_scale & BIT_0, options, BIT_1);
|
|
|
|
SET_BITVAL(conn->tcp_timestamp_en, options, BIT_0);
|
|
|
|
fw_ddb_entry->tcp_options = cpu_to_le16(options);
|
|
|
|
|
|
|
|
options = le16_to_cpu(fw_ddb_entry->ip_options);
|
|
|
|
SET_BITVAL(conn->fragment_disable, options, BIT_4);
|
|
|
|
fw_ddb_entry->ip_options = cpu_to_le16(options);
|
|
|
|
|
|
|
|
fw_ddb_entry->iscsi_max_outsnd_r2t = cpu_to_le16(sess->max_r2t);
|
|
|
|
fw_ddb_entry->iscsi_max_rcv_data_seg_len =
|
|
|
|
cpu_to_le16(conn->max_recv_dlength / BYTE_UNITS);
|
|
|
|
fw_ddb_entry->iscsi_max_snd_data_seg_len =
|
|
|
|
cpu_to_le16(conn->max_xmit_dlength / BYTE_UNITS);
|
|
|
|
fw_ddb_entry->iscsi_first_burst_len =
|
|
|
|
cpu_to_le16(sess->first_burst / BYTE_UNITS);
|
|
|
|
fw_ddb_entry->iscsi_max_burst_len = cpu_to_le16(sess->max_burst /
|
|
|
|
BYTE_UNITS);
|
|
|
|
fw_ddb_entry->iscsi_def_time2wait = cpu_to_le16(sess->time2wait);
|
|
|
|
fw_ddb_entry->iscsi_def_time2retain = cpu_to_le16(sess->time2retain);
|
|
|
|
fw_ddb_entry->tgt_portal_grp = cpu_to_le16(sess->tpgt);
|
|
|
|
fw_ddb_entry->mss = cpu_to_le16(conn->max_segment_size);
|
2013-04-17 11:15:29 +02:00
|
|
|
fw_ddb_entry->tcp_xmt_wsf = (uint8_t) cpu_to_le32(conn->tcp_xmit_wsf);
|
|
|
|
fw_ddb_entry->tcp_rcv_wsf = (uint8_t) cpu_to_le32(conn->tcp_recv_wsf);
|
2013-03-22 12:41:31 +01:00
|
|
|
fw_ddb_entry->ipv6_flow_lbl = cpu_to_le16(conn->ipv6_flow_label);
|
|
|
|
fw_ddb_entry->ka_timeout = cpu_to_le16(conn->keepalive_timeout);
|
|
|
|
fw_ddb_entry->lcl_port = cpu_to_le16(conn->local_port);
|
2013-04-17 11:15:29 +02:00
|
|
|
fw_ddb_entry->stat_sn = cpu_to_le32(conn->statsn);
|
|
|
|
fw_ddb_entry->exp_stat_sn = cpu_to_le32(conn->exp_statsn);
|
2013-07-08 14:33:06 +02:00
|
|
|
fw_ddb_entry->ddb_link = cpu_to_le16(sess->discovery_parent_idx);
|
2013-03-22 12:41:31 +01:00
|
|
|
fw_ddb_entry->chap_tbl_idx = cpu_to_le16(sess->chap_out_idx);
|
|
|
|
fw_ddb_entry->tsid = cpu_to_le16(sess->tsid);
|
|
|
|
fw_ddb_entry->port = cpu_to_le16(conn->port);
|
|
|
|
fw_ddb_entry->def_timeout =
|
|
|
|
cpu_to_le16(sess->default_taskmgmt_timeout);
|
|
|
|
|
2013-07-08 14:33:07 +02:00
|
|
|
if (!strncmp(sess->portal_type, PORTAL_TYPE_IPV6, 4))
|
|
|
|
fw_ddb_entry->ipv4_tos = conn->ipv6_traffic_class;
|
|
|
|
else
|
|
|
|
fw_ddb_entry->ipv4_tos = conn->ipv4_tos;
|
|
|
|
|
2013-03-22 12:41:31 +01:00
|
|
|
if (conn->ipaddress)
|
|
|
|
memcpy(fw_ddb_entry->ip_addr, conn->ipaddress,
|
|
|
|
sizeof(fw_ddb_entry->ip_addr));
|
|
|
|
|
|
|
|
if (conn->redirect_ipaddr)
|
|
|
|
memcpy(fw_ddb_entry->tgt_addr, conn->redirect_ipaddr,
|
|
|
|
sizeof(fw_ddb_entry->tgt_addr));
|
|
|
|
|
|
|
|
if (conn->link_local_ipv6_addr)
|
|
|
|
memcpy(fw_ddb_entry->link_local_ipv6_addr,
|
|
|
|
conn->link_local_ipv6_addr,
|
|
|
|
sizeof(fw_ddb_entry->link_local_ipv6_addr));
|
|
|
|
|
|
|
|
if (sess->targetname)
|
|
|
|
memcpy(fw_ddb_entry->iscsi_name, sess->targetname,
|
|
|
|
sizeof(fw_ddb_entry->iscsi_name));
|
|
|
|
|
|
|
|
if (sess->targetalias)
|
|
|
|
memcpy(fw_ddb_entry->iscsi_alias, sess->targetalias,
|
|
|
|
sizeof(fw_ddb_entry->iscsi_alias));
|
|
|
|
|
|
|
|
COPY_ISID(fw_ddb_entry->isid, sess->isid);
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2013-07-01 11:54:13 +02:00
|
|
|
static void qla4xxx_copy_to_sess_conn_params(struct iscsi_conn *conn,
|
|
|
|
struct iscsi_session *sess,
|
|
|
|
struct dev_db_entry *fw_ddb_entry)
|
|
|
|
{
|
|
|
|
unsigned long options = 0;
|
|
|
|
uint16_t ddb_link;
|
|
|
|
uint16_t disc_parent;
|
2013-11-22 11:28:22 +01:00
|
|
|
char ip_addr[DDB_IPADDR_LEN];
|
2013-07-01 11:54:13 +02:00
|
|
|
|
|
|
|
options = le16_to_cpu(fw_ddb_entry->options);
|
|
|
|
conn->is_fw_assigned_ipv6 = test_bit(OPT_IS_FW_ASSIGNED_IPV6, &options);
|
|
|
|
sess->auto_snd_tgt_disable = test_bit(OPT_AUTO_SENDTGTS_DISABLE,
|
|
|
|
&options);
|
|
|
|
sess->discovery_sess = test_bit(OPT_DISC_SESSION, &options);
|
|
|
|
|
|
|
|
options = le16_to_cpu(fw_ddb_entry->iscsi_options);
|
|
|
|
conn->hdrdgst_en = test_bit(ISCSIOPT_HEADER_DIGEST_EN, &options);
|
|
|
|
conn->datadgst_en = test_bit(ISCSIOPT_DATA_DIGEST_EN, &options);
|
|
|
|
sess->imm_data_en = test_bit(ISCSIOPT_IMMEDIATE_DATA_EN, &options);
|
|
|
|
sess->initial_r2t_en = test_bit(ISCSIOPT_INITIAL_R2T_EN, &options);
|
|
|
|
sess->dataseq_inorder_en = test_bit(ISCSIOPT_DATA_SEQ_IN_ORDER,
|
|
|
|
&options);
|
|
|
|
sess->pdu_inorder_en = test_bit(ISCSIOPT_DATA_PDU_IN_ORDER, &options);
|
|
|
|
sess->chap_auth_en = test_bit(ISCSIOPT_CHAP_AUTH_EN, &options);
|
|
|
|
sess->discovery_logout_en = test_bit(ISCSIOPT_DISCOVERY_LOGOUT_EN,
|
|
|
|
&options);
|
|
|
|
sess->bidi_chap_en = test_bit(ISCSIOPT_BIDI_CHAP_EN, &options);
|
|
|
|
sess->discovery_auth_optional =
|
|
|
|
test_bit(ISCSIOPT_DISCOVERY_AUTH_OPTIONAL, &options);
|
|
|
|
if (test_bit(ISCSIOPT_ERL1, &options))
|
|
|
|
sess->erl |= BIT_1;
|
|
|
|
if (test_bit(ISCSIOPT_ERL0, &options))
|
|
|
|
sess->erl |= BIT_0;
|
|
|
|
|
|
|
|
options = le16_to_cpu(fw_ddb_entry->tcp_options);
|
|
|
|
conn->tcp_timestamp_stat = test_bit(TCPOPT_TIMESTAMP_STAT, &options);
|
|
|
|
conn->tcp_nagle_disable = test_bit(TCPOPT_NAGLE_DISABLE, &options);
|
|
|
|
conn->tcp_wsf_disable = test_bit(TCPOPT_WSF_DISABLE, &options);
|
|
|
|
if (test_bit(TCPOPT_TIMER_SCALE3, &options))
|
|
|
|
conn->tcp_timer_scale |= BIT_3;
|
|
|
|
if (test_bit(TCPOPT_TIMER_SCALE2, &options))
|
|
|
|
conn->tcp_timer_scale |= BIT_2;
|
|
|
|
if (test_bit(TCPOPT_TIMER_SCALE1, &options))
|
|
|
|
conn->tcp_timer_scale |= BIT_1;
|
|
|
|
|
|
|
|
conn->tcp_timer_scale >>= 1;
|
|
|
|
conn->tcp_timestamp_en = test_bit(TCPOPT_TIMESTAMP_EN, &options);
|
|
|
|
|
|
|
|
options = le16_to_cpu(fw_ddb_entry->ip_options);
|
|
|
|
conn->fragment_disable = test_bit(IPOPT_FRAGMENT_DISABLE, &options);
|
|
|
|
|
|
|
|
conn->max_recv_dlength = BYTE_UNITS *
|
|
|
|
le16_to_cpu(fw_ddb_entry->iscsi_max_rcv_data_seg_len);
|
|
|
|
conn->max_xmit_dlength = BYTE_UNITS *
|
|
|
|
le16_to_cpu(fw_ddb_entry->iscsi_max_snd_data_seg_len);
|
|
|
|
sess->max_r2t = le16_to_cpu(fw_ddb_entry->iscsi_max_outsnd_r2t);
|
|
|
|
sess->first_burst = BYTE_UNITS *
|
|
|
|
le16_to_cpu(fw_ddb_entry->iscsi_first_burst_len);
|
|
|
|
sess->max_burst = BYTE_UNITS *
|
|
|
|
le16_to_cpu(fw_ddb_entry->iscsi_max_burst_len);
|
|
|
|
sess->time2wait = le16_to_cpu(fw_ddb_entry->iscsi_def_time2wait);
|
|
|
|
sess->time2retain = le16_to_cpu(fw_ddb_entry->iscsi_def_time2retain);
|
|
|
|
sess->tpgt = le32_to_cpu(fw_ddb_entry->tgt_portal_grp);
|
|
|
|
conn->max_segment_size = le16_to_cpu(fw_ddb_entry->mss);
|
|
|
|
conn->tcp_xmit_wsf = fw_ddb_entry->tcp_xmt_wsf;
|
|
|
|
conn->tcp_recv_wsf = fw_ddb_entry->tcp_rcv_wsf;
|
|
|
|
conn->ipv4_tos = fw_ddb_entry->ipv4_tos;
|
|
|
|
conn->keepalive_tmo = le16_to_cpu(fw_ddb_entry->ka_timeout);
|
|
|
|
conn->local_port = le16_to_cpu(fw_ddb_entry->lcl_port);
|
|
|
|
conn->statsn = le32_to_cpu(fw_ddb_entry->stat_sn);
|
|
|
|
conn->exp_statsn = le32_to_cpu(fw_ddb_entry->exp_stat_sn);
|
|
|
|
sess->tsid = le16_to_cpu(fw_ddb_entry->tsid);
|
|
|
|
COPY_ISID(sess->isid, fw_ddb_entry->isid);
|
|
|
|
|
|
|
|
ddb_link = le16_to_cpu(fw_ddb_entry->ddb_link);
|
|
|
|
if (ddb_link == DDB_ISNS)
|
|
|
|
disc_parent = ISCSI_DISC_PARENT_ISNS;
|
|
|
|
else if (ddb_link == DDB_NO_LINK)
|
|
|
|
disc_parent = ISCSI_DISC_PARENT_UNKNOWN;
|
|
|
|
else if (ddb_link < MAX_DDB_ENTRIES)
|
|
|
|
disc_parent = ISCSI_DISC_PARENT_SENDTGT;
|
|
|
|
else
|
|
|
|
disc_parent = ISCSI_DISC_PARENT_UNKNOWN;
|
|
|
|
|
|
|
|
iscsi_set_param(conn->cls_conn, ISCSI_PARAM_DISCOVERY_PARENT_TYPE,
|
|
|
|
iscsi_get_discovery_parent_name(disc_parent), 0);
|
|
|
|
|
|
|
|
iscsi_set_param(conn->cls_conn, ISCSI_PARAM_TARGET_ALIAS,
|
|
|
|
(char *)fw_ddb_entry->iscsi_alias, 0);
|
2013-11-22 11:28:22 +01:00
|
|
|
|
|
|
|
options = le16_to_cpu(fw_ddb_entry->options);
|
|
|
|
if (options & DDB_OPT_IPV6_DEVICE) {
|
|
|
|
memset(ip_addr, 0, sizeof(ip_addr));
|
|
|
|
sprintf(ip_addr, "%pI6", fw_ddb_entry->link_local_ipv6_addr);
|
|
|
|
iscsi_set_param(conn->cls_conn, ISCSI_PARAM_LOCAL_IPADDR,
|
|
|
|
(char *)ip_addr, 0);
|
|
|
|
}
|
2013-07-01 11:54:13 +02:00
|
|
|
}
|
|
|
|
|
2011-12-02 04:38:41 +01:00
|
|
|
static void qla4xxx_copy_fwddb_param(struct scsi_qla_host *ha,
|
|
|
|
struct dev_db_entry *fw_ddb_entry,
|
|
|
|
struct iscsi_cls_session *cls_sess,
|
|
|
|
struct iscsi_cls_conn *cls_conn)
|
|
|
|
{
|
|
|
|
int buflen = 0;
|
|
|
|
struct iscsi_session *sess;
|
2012-02-27 12:08:52 +01:00
|
|
|
struct ddb_entry *ddb_entry;
|
2013-09-17 13:54:46 +02:00
|
|
|
struct ql4_chap_table chap_tbl;
|
2011-12-02 04:38:41 +01:00
|
|
|
struct iscsi_conn *conn;
|
|
|
|
char ip_addr[DDB_IPADDR_LEN];
|
|
|
|
uint16_t options = 0;
|
|
|
|
|
|
|
|
sess = cls_sess->dd_data;
|
2012-02-27 12:08:52 +01:00
|
|
|
ddb_entry = sess->dd_data;
|
2011-12-02 04:38:41 +01:00
|
|
|
conn = cls_conn->dd_data;
|
2013-09-17 13:54:46 +02:00
|
|
|
memset(&chap_tbl, 0, sizeof(chap_tbl));
|
2011-12-02 04:38:41 +01:00
|
|
|
|
2012-02-27 12:08:52 +01:00
|
|
|
ddb_entry->chap_tbl_idx = le16_to_cpu(fw_ddb_entry->chap_tbl_idx);
|
|
|
|
|
2013-07-01 11:54:13 +02:00
|
|
|
qla4xxx_copy_to_sess_conn_params(conn, sess, fw_ddb_entry);
|
2011-12-02 04:38:41 +01:00
|
|
|
|
2013-07-01 11:54:13 +02:00
|
|
|
sess->def_taskmgmt_tmo = le16_to_cpu(fw_ddb_entry->def_timeout);
|
2011-12-02 04:38:41 +01:00
|
|
|
conn->persistent_port = le16_to_cpu(fw_ddb_entry->port);
|
|
|
|
|
2013-07-01 11:54:13 +02:00
|
|
|
memset(ip_addr, 0, sizeof(ip_addr));
|
2011-12-02 04:38:41 +01:00
|
|
|
options = le16_to_cpu(fw_ddb_entry->options);
|
2013-07-01 11:54:13 +02:00
|
|
|
if (options & DDB_OPT_IPV6_DEVICE) {
|
|
|
|
iscsi_set_param(cls_conn, ISCSI_PARAM_PORTAL_TYPE, "ipv6", 4);
|
|
|
|
|
|
|
|
memset(ip_addr, 0, sizeof(ip_addr));
|
2011-12-02 04:38:41 +01:00
|
|
|
sprintf(ip_addr, "%pI6", fw_ddb_entry->ip_addr);
|
2013-07-01 11:54:13 +02:00
|
|
|
} else {
|
|
|
|
iscsi_set_param(cls_conn, ISCSI_PARAM_PORTAL_TYPE, "ipv4", 4);
|
2011-12-02 04:38:41 +01:00
|
|
|
sprintf(ip_addr, "%pI4", fw_ddb_entry->ip_addr);
|
2013-07-01 11:54:13 +02:00
|
|
|
}
|
2011-12-02 04:38:41 +01:00
|
|
|
|
2013-07-01 11:54:13 +02:00
|
|
|
iscsi_set_param(cls_conn, ISCSI_PARAM_PERSISTENT_ADDRESS,
|
|
|
|
(char *)ip_addr, buflen);
|
2011-12-02 04:38:41 +01:00
|
|
|
iscsi_set_param(cls_conn, ISCSI_PARAM_TARGET_NAME,
|
|
|
|
(char *)fw_ddb_entry->iscsi_name, buflen);
|
|
|
|
iscsi_set_param(cls_conn, ISCSI_PARAM_INITIATOR_NAME,
|
|
|
|
(char *)ha->name_string, buflen);
|
2013-09-17 13:54:46 +02:00
|
|
|
|
|
|
|
if (ddb_entry->chap_tbl_idx != INVALID_ENTRY) {
|
|
|
|
if (!qla4xxx_get_uni_chap_at_index(ha, chap_tbl.name,
|
|
|
|
chap_tbl.secret,
|
|
|
|
ddb_entry->chap_tbl_idx)) {
|
|
|
|
iscsi_set_param(cls_conn, ISCSI_PARAM_USERNAME,
|
|
|
|
(char *)chap_tbl.name,
|
|
|
|
strlen((char *)chap_tbl.name));
|
|
|
|
iscsi_set_param(cls_conn, ISCSI_PARAM_PASSWORD,
|
|
|
|
(char *)chap_tbl.secret,
|
|
|
|
chap_tbl.secret_len);
|
|
|
|
}
|
|
|
|
}
|
2011-12-02 04:38:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void qla4xxx_update_session_conn_fwddb_param(struct scsi_qla_host *ha,
|
|
|
|
struct ddb_entry *ddb_entry)
|
|
|
|
{
|
|
|
|
struct iscsi_cls_session *cls_sess;
|
|
|
|
struct iscsi_cls_conn *cls_conn;
|
|
|
|
uint32_t ddb_state;
|
|
|
|
dma_addr_t fw_ddb_entry_dma;
|
|
|
|
struct dev_db_entry *fw_ddb_entry;
|
|
|
|
|
|
|
|
fw_ddb_entry = dma_alloc_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry),
|
|
|
|
&fw_ddb_entry_dma, GFP_KERNEL);
|
|
|
|
if (!fw_ddb_entry) {
|
|
|
|
ql4_printk(KERN_ERR, ha,
|
|
|
|
"%s: Unable to allocate dma buffer\n", __func__);
|
|
|
|
goto exit_session_conn_fwddb_param;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (qla4xxx_get_fwddb_entry(ha, ddb_entry->fw_ddb_index, fw_ddb_entry,
|
|
|
|
fw_ddb_entry_dma, NULL, NULL, &ddb_state,
|
|
|
|
NULL, NULL, NULL) == QLA_ERROR) {
|
|
|
|
DEBUG2(ql4_printk(KERN_ERR, ha, "scsi%ld: %s: failed "
|
|
|
|
"get_ddb_entry for fw_ddb_index %d\n",
|
|
|
|
ha->host_no, __func__,
|
|
|
|
ddb_entry->fw_ddb_index));
|
|
|
|
goto exit_session_conn_fwddb_param;
|
|
|
|
}
|
|
|
|
|
|
|
|
cls_sess = ddb_entry->sess;
|
|
|
|
|
|
|
|
cls_conn = ddb_entry->conn;
|
|
|
|
|
|
|
|
/* Update params */
|
|
|
|
qla4xxx_copy_fwddb_param(ha, fw_ddb_entry, cls_sess, cls_conn);
|
|
|
|
|
|
|
|
exit_session_conn_fwddb_param:
|
|
|
|
if (fw_ddb_entry)
|
|
|
|
dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry),
|
|
|
|
fw_ddb_entry, fw_ddb_entry_dma);
|
|
|
|
}
|
|
|
|
|
2011-07-25 20:48:53 +02:00
|
|
|
void qla4xxx_update_session_conn_param(struct scsi_qla_host *ha,
|
|
|
|
struct ddb_entry *ddb_entry)
|
|
|
|
{
|
|
|
|
struct iscsi_cls_session *cls_sess;
|
|
|
|
struct iscsi_cls_conn *cls_conn;
|
|
|
|
struct iscsi_session *sess;
|
|
|
|
struct iscsi_conn *conn;
|
|
|
|
uint32_t ddb_state;
|
|
|
|
dma_addr_t fw_ddb_entry_dma;
|
|
|
|
struct dev_db_entry *fw_ddb_entry;
|
|
|
|
|
|
|
|
fw_ddb_entry = dma_alloc_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry),
|
|
|
|
&fw_ddb_entry_dma, GFP_KERNEL);
|
|
|
|
if (!fw_ddb_entry) {
|
|
|
|
ql4_printk(KERN_ERR, ha,
|
|
|
|
"%s: Unable to allocate dma buffer\n", __func__);
|
2011-12-02 04:38:41 +01:00
|
|
|
goto exit_session_conn_param;
|
2011-07-25 20:48:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (qla4xxx_get_fwddb_entry(ha, ddb_entry->fw_ddb_index, fw_ddb_entry,
|
|
|
|
fw_ddb_entry_dma, NULL, NULL, &ddb_state,
|
|
|
|
NULL, NULL, NULL) == QLA_ERROR) {
|
|
|
|
DEBUG2(ql4_printk(KERN_ERR, ha, "scsi%ld: %s: failed "
|
|
|
|
"get_ddb_entry for fw_ddb_index %d\n",
|
|
|
|
ha->host_no, __func__,
|
|
|
|
ddb_entry->fw_ddb_index));
|
2011-12-02 04:38:41 +01:00
|
|
|
goto exit_session_conn_param;
|
2011-07-25 20:48:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
cls_sess = ddb_entry->sess;
|
|
|
|
sess = cls_sess->dd_data;
|
|
|
|
|
|
|
|
cls_conn = ddb_entry->conn;
|
|
|
|
conn = cls_conn->dd_data;
|
|
|
|
|
2011-12-02 04:38:41 +01:00
|
|
|
/* Update timers after login */
|
|
|
|
ddb_entry->default_relogin_timeout =
|
2011-12-19 06:40:44 +01:00
|
|
|
(le16_to_cpu(fw_ddb_entry->def_timeout) > LOGIN_TOV) &&
|
|
|
|
(le16_to_cpu(fw_ddb_entry->def_timeout) < LOGIN_TOV * 10) ?
|
|
|
|
le16_to_cpu(fw_ddb_entry->def_timeout) : LOGIN_TOV;
|
2011-12-02 04:38:41 +01:00
|
|
|
ddb_entry->default_time2wait =
|
|
|
|
le16_to_cpu(fw_ddb_entry->iscsi_def_time2wait);
|
|
|
|
|
2011-07-25 20:48:53 +02:00
|
|
|
/* Update params */
|
2012-02-27 12:08:52 +01:00
|
|
|
ddb_entry->chap_tbl_idx = le16_to_cpu(fw_ddb_entry->chap_tbl_idx);
|
2013-07-01 11:54:13 +02:00
|
|
|
qla4xxx_copy_to_sess_conn_params(conn, sess, fw_ddb_entry);
|
2011-07-25 20:48:53 +02:00
|
|
|
|
|
|
|
memcpy(sess->initiatorname, ha->name_string,
|
|
|
|
min(sizeof(ha->name_string), sizeof(sess->initiatorname)));
|
2011-12-02 04:38:41 +01:00
|
|
|
|
|
|
|
exit_session_conn_param:
|
|
|
|
if (fw_ddb_entry)
|
|
|
|
dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry),
|
|
|
|
fw_ddb_entry, fw_ddb_entry_dma);
|
2011-07-25 20:48:53 +02:00
|
|
|
}
|
|
|
|
|
2006-09-19 19:28:00 +02:00
|
|
|
/*
|
|
|
|
* Timer routines
|
|
|
|
*/
|
2017-10-21 17:39:39 +02:00
|
|
|
static void qla4xxx_timer(struct timer_list *t);
|
2006-09-19 19:28:00 +02:00
|
|
|
|
2017-10-21 17:39:39 +02:00
|
|
|
static void qla4xxx_start_timer(struct scsi_qla_host *ha,
|
2006-09-19 19:28:00 +02:00
|
|
|
unsigned long interval)
|
|
|
|
{
|
|
|
|
DEBUG(printk("scsi: %s: Starting timer thread for adapter %d\n",
|
|
|
|
__func__, ha->host->host_no));
|
2017-10-21 17:39:39 +02:00
|
|
|
timer_setup(&ha->timer, qla4xxx_timer, 0);
|
2006-09-19 19:28:00 +02:00
|
|
|
ha->timer.expires = jiffies + interval * HZ;
|
|
|
|
add_timer(&ha->timer);
|
|
|
|
ha->timer_active = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void qla4xxx_stop_timer(struct scsi_qla_host *ha)
|
|
|
|
{
|
|
|
|
del_timer_sync(&ha->timer);
|
|
|
|
ha->timer_active = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***
|
2011-07-25 20:48:53 +02:00
|
|
|
* qla4xxx_mark_device_missing - blocks the session
|
|
|
|
* @cls_session: Pointer to the session to be blocked
|
2006-09-19 19:28:00 +02:00
|
|
|
* @ddb_entry: Pointer to device database entry
|
|
|
|
*
|
2010-07-28 12:23:44 +02:00
|
|
|
* This routine marks a device missing and close connection.
|
2006-09-19 19:28:00 +02:00
|
|
|
**/
|
2011-07-25 20:48:53 +02:00
|
|
|
void qla4xxx_mark_device_missing(struct iscsi_cls_session *cls_session)
|
2006-09-19 19:28:00 +02:00
|
|
|
{
|
2011-07-25 20:48:53 +02:00
|
|
|
iscsi_block_session(cls_session);
|
2006-09-19 19:28:00 +02:00
|
|
|
}
|
|
|
|
|
2010-07-28 12:23:44 +02:00
|
|
|
/**
|
|
|
|
* qla4xxx_mark_all_devices_missing - mark all devices as missing.
|
|
|
|
* @ha: Pointer to host adapter structure.
|
|
|
|
*
|
|
|
|
* This routine marks a device missing and resets the relogin retry count.
|
|
|
|
**/
|
|
|
|
void qla4xxx_mark_all_devices_missing(struct scsi_qla_host *ha)
|
|
|
|
{
|
2011-07-25 20:48:53 +02:00
|
|
|
iscsi_host_for_each_session(ha->host, qla4xxx_mark_device_missing);
|
2010-07-28 12:23:44 +02:00
|
|
|
}
|
|
|
|
|
2006-09-19 19:28:00 +02:00
|
|
|
static struct srb* qla4xxx_get_new_srb(struct scsi_qla_host *ha,
|
|
|
|
struct ddb_entry *ddb_entry,
|
2011-05-18 08:17:10 +02:00
|
|
|
struct scsi_cmnd *cmd)
|
2006-09-19 19:28:00 +02:00
|
|
|
{
|
|
|
|
struct srb *srb;
|
|
|
|
|
|
|
|
srb = mempool_alloc(ha->srb_mempool, GFP_ATOMIC);
|
|
|
|
if (!srb)
|
|
|
|
return srb;
|
|
|
|
|
2010-04-28 08:12:24 +02:00
|
|
|
kref_init(&srb->srb_ref);
|
2006-09-19 19:28:00 +02:00
|
|
|
srb->ha = ha;
|
|
|
|
srb->ddb = ddb_entry;
|
|
|
|
srb->cmd = cmd;
|
|
|
|
srb->flags = 0;
|
2010-04-28 08:11:59 +02:00
|
|
|
CMD_SP(cmd) = (void *)srb;
|
2006-09-19 19:28:00 +02:00
|
|
|
|
|
|
|
return srb;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void qla4xxx_srb_free_dma(struct scsi_qla_host *ha, struct srb *srb)
|
|
|
|
{
|
|
|
|
struct scsi_cmnd *cmd = srb->cmd;
|
|
|
|
|
|
|
|
if (srb->flags & SRB_DMA_VALID) {
|
2007-05-26 07:08:20 +02:00
|
|
|
scsi_dma_unmap(cmd);
|
2006-09-19 19:28:00 +02:00
|
|
|
srb->flags &= ~SRB_DMA_VALID;
|
|
|
|
}
|
2010-04-28 08:11:59 +02:00
|
|
|
CMD_SP(cmd) = NULL;
|
2006-09-19 19:28:00 +02:00
|
|
|
}
|
|
|
|
|
2010-04-28 08:12:24 +02:00
|
|
|
void qla4xxx_srb_compl(struct kref *ref)
|
2006-09-19 19:28:00 +02:00
|
|
|
{
|
2010-04-28 08:12:24 +02:00
|
|
|
struct srb *srb = container_of(ref, struct srb, srb_ref);
|
2006-09-19 19:28:00 +02:00
|
|
|
struct scsi_cmnd *cmd = srb->cmd;
|
2010-04-28 08:12:24 +02:00
|
|
|
struct scsi_qla_host *ha = srb->ha;
|
2006-09-19 19:28:00 +02:00
|
|
|
|
|
|
|
qla4xxx_srb_free_dma(ha, srb);
|
|
|
|
|
|
|
|
mempool_free(srb, ha->srb_mempool);
|
|
|
|
|
|
|
|
cmd->scsi_done(cmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* qla4xxx_queuecommand - scsi layer issues scsi command to driver.
|
2011-05-18 08:17:10 +02:00
|
|
|
* @host: scsi host
|
2006-09-19 19:28:00 +02:00
|
|
|
* @cmd: Pointer to Linux's SCSI command structure
|
|
|
|
*
|
|
|
|
* Remarks:
|
|
|
|
* This routine is invoked by Linux to send a SCSI command to the driver.
|
|
|
|
* The mid-level driver tries to ensure that queuecommand never gets
|
|
|
|
* invoked concurrently with itself or the interrupt handler (although
|
|
|
|
* the interrupt handler may call this routine as part of request-
|
|
|
|
* completion handling). Unfortunely, it sometimes calls the scheduler
|
|
|
|
* in interrupt context which is a big NO! NO!.
|
|
|
|
**/
|
2011-05-18 08:17:10 +02:00
|
|
|
static int qla4xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)
|
2006-09-19 19:28:00 +02:00
|
|
|
{
|
2011-05-18 08:17:10 +02:00
|
|
|
struct scsi_qla_host *ha = to_qla_host(host);
|
2006-09-19 19:28:00 +02:00
|
|
|
struct ddb_entry *ddb_entry = cmd->device->hostdata;
|
2008-01-31 20:36:45 +01:00
|
|
|
struct iscsi_cls_session *sess = ddb_entry->sess;
|
2006-09-19 19:28:00 +02:00
|
|
|
struct srb *srb;
|
|
|
|
int rval;
|
|
|
|
|
2010-07-30 11:08:47 +02:00
|
|
|
if (test_bit(AF_EEH_BUSY, &ha->flags)) {
|
|
|
|
if (test_bit(AF_PCI_CHANNEL_IO_PERM_FAILURE, &ha->flags))
|
|
|
|
cmd->result = DID_NO_CONNECT << 16;
|
|
|
|
else
|
|
|
|
cmd->result = DID_REQUEUE << 16;
|
|
|
|
goto qc_fail_command;
|
|
|
|
}
|
|
|
|
|
2008-01-31 20:36:45 +01:00
|
|
|
if (!sess) {
|
|
|
|
cmd->result = DID_IMM_RETRY << 16;
|
|
|
|
goto qc_fail_command;
|
|
|
|
}
|
|
|
|
|
|
|
|
rval = iscsi_session_chkready(sess);
|
|
|
|
if (rval) {
|
|
|
|
cmd->result = rval;
|
|
|
|
goto qc_fail_command;
|
|
|
|
}
|
|
|
|
|
2010-07-28 12:23:44 +02:00
|
|
|
if (test_bit(DPC_RESET_HA_INTR, &ha->dpc_flags) ||
|
|
|
|
test_bit(DPC_RESET_ACTIVE, &ha->dpc_flags) ||
|
|
|
|
test_bit(DPC_RESET_HA, &ha->dpc_flags) ||
|
|
|
|
test_bit(DPC_HA_UNRECOVERABLE, &ha->dpc_flags) ||
|
|
|
|
test_bit(DPC_HA_NEED_QUIESCENT, &ha->dpc_flags) ||
|
|
|
|
!test_bit(AF_ONLINE, &ha->flags) ||
|
2011-07-25 20:48:53 +02:00
|
|
|
!test_bit(AF_LINK_UP, &ha->flags) ||
|
2013-01-21 05:50:58 +01:00
|
|
|
test_bit(AF_LOOPBACK, &ha->flags) ||
|
2013-08-16 13:03:03 +02:00
|
|
|
test_bit(DPC_POST_IDC_ACK, &ha->dpc_flags) ||
|
|
|
|
test_bit(DPC_RESTORE_ACB, &ha->dpc_flags) ||
|
2010-07-28 12:23:44 +02:00
|
|
|
test_bit(DPC_RESET_HA_FW_CONTEXT, &ha->dpc_flags))
|
2007-01-22 21:26:11 +01:00
|
|
|
goto qc_host_busy;
|
|
|
|
|
2011-05-18 08:17:10 +02:00
|
|
|
srb = qla4xxx_get_new_srb(ha, ddb_entry, cmd);
|
2006-09-19 19:28:00 +02:00
|
|
|
if (!srb)
|
2011-05-18 08:17:10 +02:00
|
|
|
goto qc_host_busy;
|
2006-09-19 19:28:00 +02:00
|
|
|
|
|
|
|
rval = qla4xxx_send_command_to_isp(ha, srb);
|
|
|
|
if (rval != QLA_SUCCESS)
|
|
|
|
goto qc_host_busy_free_sp;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
qc_host_busy_free_sp:
|
|
|
|
qla4xxx_srb_free_dma(ha, srb);
|
|
|
|
mempool_free(srb, ha->srb_mempool);
|
|
|
|
|
|
|
|
qc_host_busy:
|
|
|
|
return SCSI_MLQUEUE_HOST_BUSY;
|
|
|
|
|
|
|
|
qc_fail_command:
|
2011-05-18 08:17:10 +02:00
|
|
|
cmd->scsi_done(cmd);
|
2006-09-19 19:28:00 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* qla4xxx_mem_free - frees memory allocated to adapter
|
|
|
|
* @ha: Pointer to host adapter structure.
|
|
|
|
*
|
|
|
|
* Frees memory previously allocated by qla4xxx_mem_alloc
|
|
|
|
**/
|
|
|
|
static void qla4xxx_mem_free(struct scsi_qla_host *ha)
|
|
|
|
{
|
|
|
|
if (ha->queues)
|
|
|
|
dma_free_coherent(&ha->pdev->dev, ha->queues_len, ha->queues,
|
|
|
|
ha->queues_dma);
|
|
|
|
|
2012-05-18 10:41:44 +02:00
|
|
|
if (ha->fw_dump)
|
|
|
|
vfree(ha->fw_dump);
|
|
|
|
|
2006-09-19 19:28:00 +02:00
|
|
|
ha->queues_len = 0;
|
|
|
|
ha->queues = NULL;
|
|
|
|
ha->queues_dma = 0;
|
|
|
|
ha->request_ring = NULL;
|
|
|
|
ha->request_dma = 0;
|
|
|
|
ha->response_ring = NULL;
|
|
|
|
ha->response_dma = 0;
|
|
|
|
ha->shadow_regs = NULL;
|
|
|
|
ha->shadow_regs_dma = 0;
|
2012-05-18 10:41:44 +02:00
|
|
|
ha->fw_dump = NULL;
|
|
|
|
ha->fw_dump_size = 0;
|
2006-09-19 19:28:00 +02:00
|
|
|
|
|
|
|
/* Free srb pool. */
|
|
|
|
if (ha->srb_mempool)
|
|
|
|
mempool_destroy(ha->srb_mempool);
|
|
|
|
|
|
|
|
ha->srb_mempool = NULL;
|
|
|
|
|
2011-07-25 20:48:53 +02:00
|
|
|
if (ha->chap_dma_pool)
|
|
|
|
dma_pool_destroy(ha->chap_dma_pool);
|
|
|
|
|
2011-10-08 01:55:42 +02:00
|
|
|
if (ha->chap_list)
|
|
|
|
vfree(ha->chap_list);
|
|
|
|
ha->chap_list = NULL;
|
|
|
|
|
2011-12-02 04:38:41 +01:00
|
|
|
if (ha->fw_ddb_dma_pool)
|
|
|
|
dma_pool_destroy(ha->fw_ddb_dma_pool);
|
|
|
|
|
2006-09-19 19:28:00 +02:00
|
|
|
/* release io space registers */
|
2010-07-28 12:23:44 +02:00
|
|
|
if (is_qla8022(ha)) {
|
|
|
|
if (ha->nx_pcibase)
|
|
|
|
iounmap(
|
|
|
|
(struct device_reg_82xx __iomem *)ha->nx_pcibase);
|
2013-08-16 13:03:02 +02:00
|
|
|
} else if (is_qla8032(ha) || is_qla8042(ha)) {
|
2012-08-22 13:55:08 +02:00
|
|
|
if (ha->nx_pcibase)
|
|
|
|
iounmap(
|
|
|
|
(struct device_reg_83xx __iomem *)ha->nx_pcibase);
|
|
|
|
} else if (ha->reg) {
|
2006-09-19 19:28:00 +02:00
|
|
|
iounmap(ha->reg);
|
2012-08-22 13:55:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ha->reset_tmplt.buff)
|
|
|
|
vfree(ha->reset_tmplt.buff);
|
|
|
|
|
2006-09-19 19:28:00 +02:00
|
|
|
pci_release_regions(ha->pdev);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* qla4xxx_mem_alloc - allocates memory for use by adapter.
|
|
|
|
* @ha: Pointer to host adapter structure
|
|
|
|
*
|
|
|
|
* Allocates DMA memory for request and response queues. Also allocates memory
|
|
|
|
* for srbs.
|
|
|
|
**/
|
|
|
|
static int qla4xxx_mem_alloc(struct scsi_qla_host *ha)
|
|
|
|
{
|
|
|
|
unsigned long align;
|
|
|
|
|
|
|
|
/* Allocate contiguous block of DMA memory for queues. */
|
|
|
|
ha->queues_len = ((REQUEST_QUEUE_DEPTH * QUEUE_SIZE) +
|
|
|
|
(RESPONSE_QUEUE_DEPTH * QUEUE_SIZE) +
|
|
|
|
sizeof(struct shadow_regs) +
|
|
|
|
MEM_ALIGN_VALUE +
|
|
|
|
(PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1);
|
|
|
|
ha->queues = dma_alloc_coherent(&ha->pdev->dev, ha->queues_len,
|
|
|
|
&ha->queues_dma, GFP_KERNEL);
|
|
|
|
if (ha->queues == NULL) {
|
2010-07-10 11:21:02 +02:00
|
|
|
ql4_printk(KERN_WARNING, ha,
|
|
|
|
"Memory Allocation failed - queues.\n");
|
2006-09-19 19:28:00 +02:00
|
|
|
|
|
|
|
goto mem_alloc_error_exit;
|
|
|
|
}
|
|
|
|
memset(ha->queues, 0, ha->queues_len);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* As per RISC alignment requirements -- the bus-address must be a
|
|
|
|
* multiple of the request-ring size (in bytes).
|
|
|
|
*/
|
|
|
|
align = 0;
|
|
|
|
if ((unsigned long)ha->queues_dma & (MEM_ALIGN_VALUE - 1))
|
|
|
|
align = MEM_ALIGN_VALUE - ((unsigned long)ha->queues_dma &
|
|
|
|
(MEM_ALIGN_VALUE - 1));
|
|
|
|
|
|
|
|
/* Update request and response queue pointers. */
|
|
|
|
ha->request_dma = ha->queues_dma + align;
|
|
|
|
ha->request_ring = (struct queue_entry *) (ha->queues + align);
|
|
|
|
ha->response_dma = ha->queues_dma + align +
|
|
|
|
(REQUEST_QUEUE_DEPTH * QUEUE_SIZE);
|
|
|
|
ha->response_ring = (struct queue_entry *) (ha->queues + align +
|
|
|
|
(REQUEST_QUEUE_DEPTH *
|
|
|
|
QUEUE_SIZE));
|
|
|
|
ha->shadow_regs_dma = ha->queues_dma + align +
|
|
|
|
(REQUEST_QUEUE_DEPTH * QUEUE_SIZE) +
|
|
|
|
(RESPONSE_QUEUE_DEPTH * QUEUE_SIZE);
|
|
|
|
ha->shadow_regs = (struct shadow_regs *) (ha->queues + align +
|
|
|
|
(REQUEST_QUEUE_DEPTH *
|
|
|
|
QUEUE_SIZE) +
|
|
|
|
(RESPONSE_QUEUE_DEPTH *
|
|
|
|
QUEUE_SIZE));
|
|
|
|
|
|
|
|
/* Allocate memory for srb pool. */
|
|
|
|
ha->srb_mempool = mempool_create(SRB_MIN_REQ, mempool_alloc_slab,
|
|
|
|
mempool_free_slab, srb_cachep);
|
|
|
|
if (ha->srb_mempool == NULL) {
|
2010-07-10 11:21:02 +02:00
|
|
|
ql4_printk(KERN_WARNING, ha,
|
|
|
|
"Memory Allocation failed - SRB Pool.\n");
|
2006-09-19 19:28:00 +02:00
|
|
|
|
|
|
|
goto mem_alloc_error_exit;
|
|
|
|
}
|
|
|
|
|
2011-07-25 20:48:53 +02:00
|
|
|
ha->chap_dma_pool = dma_pool_create("ql4_chap", &ha->pdev->dev,
|
|
|
|
CHAP_DMA_BLOCK_SIZE, 8, 0);
|
|
|
|
|
|
|
|
if (ha->chap_dma_pool == NULL) {
|
|
|
|
ql4_printk(KERN_WARNING, ha,
|
|
|
|
"%s: chap_dma_pool allocation failed..\n", __func__);
|
|
|
|
goto mem_alloc_error_exit;
|
|
|
|
}
|
|
|
|
|
2011-12-02 04:38:41 +01:00
|
|
|
ha->fw_ddb_dma_pool = dma_pool_create("ql4_fw_ddb", &ha->pdev->dev,
|
|
|
|
DDB_DMA_BLOCK_SIZE, 8, 0);
|
|
|
|
|
|
|
|
if (ha->fw_ddb_dma_pool == NULL) {
|
|
|
|
ql4_printk(KERN_WARNING, ha,
|
|
|
|
"%s: fw_ddb_dma_pool allocation failed..\n",
|
|
|
|
__func__);
|
|
|
|
goto mem_alloc_error_exit;
|
|
|
|
}
|
|
|
|
|
2006-09-19 19:28:00 +02:00
|
|
|
return QLA_SUCCESS;
|
|
|
|
|
|
|
|
mem_alloc_error_exit:
|
|
|
|
qla4xxx_mem_free(ha);
|
|
|
|
return QLA_ERROR;
|
|
|
|
}
|
|
|
|
|
2012-01-11 11:44:15 +01:00
|
|
|
/**
|
|
|
|
* qla4_8xxx_check_temp - Check the ISP82XX temperature.
|
|
|
|
* @ha: adapter block pointer.
|
|
|
|
*
|
|
|
|
* Note: The caller should not hold the idc lock.
|
|
|
|
**/
|
|
|
|
static int qla4_8xxx_check_temp(struct scsi_qla_host *ha)
|
|
|
|
{
|
|
|
|
uint32_t temp, temp_state, temp_val;
|
|
|
|
int status = QLA_SUCCESS;
|
|
|
|
|
2012-08-22 13:55:04 +02:00
|
|
|
temp = qla4_8xxx_rd_direct(ha, QLA8XXX_CRB_TEMP_STATE);
|
2012-01-11 11:44:15 +01:00
|
|
|
|
|
|
|
temp_state = qla82xx_get_temp_state(temp);
|
|
|
|
temp_val = qla82xx_get_temp_val(temp);
|
|
|
|
|
|
|
|
if (temp_state == QLA82XX_TEMP_PANIC) {
|
|
|
|
ql4_printk(KERN_WARNING, ha, "Device temperature %d degrees C"
|
|
|
|
" exceeds maximum allowed. Hardware has been shut"
|
|
|
|
" down.\n", temp_val);
|
|
|
|
status = QLA_ERROR;
|
|
|
|
} else if (temp_state == QLA82XX_TEMP_WARN) {
|
|
|
|
if (ha->temperature == QLA82XX_TEMP_NORMAL)
|
|
|
|
ql4_printk(KERN_WARNING, ha, "Device temperature %d"
|
|
|
|
" degrees C exceeds operating range."
|
|
|
|
" Immediate action needed.\n", temp_val);
|
|
|
|
} else {
|
|
|
|
if (ha->temperature == QLA82XX_TEMP_WARN)
|
|
|
|
ql4_printk(KERN_INFO, ha, "Device temperature is"
|
|
|
|
" now %d degrees C in normal range.\n",
|
|
|
|
temp_val);
|
|
|
|
}
|
|
|
|
ha->temperature = temp_state;
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2010-07-28 12:23:44 +02:00
|
|
|
/**
|
|
|
|
* qla4_8xxx_check_fw_alive - Check firmware health
|
|
|
|
* @ha: Pointer to host adapter structure.
|
|
|
|
*
|
|
|
|
* Context: Interrupt
|
|
|
|
**/
|
2011-12-02 07:42:13 +01:00
|
|
|
static int qla4_8xxx_check_fw_alive(struct scsi_qla_host *ha)
|
2010-07-28 12:23:44 +02:00
|
|
|
{
|
2011-12-02 07:42:13 +01:00
|
|
|
uint32_t fw_heartbeat_counter;
|
|
|
|
int status = QLA_SUCCESS;
|
2010-07-28 12:23:44 +02:00
|
|
|
|
2012-08-22 13:55:04 +02:00
|
|
|
fw_heartbeat_counter = qla4_8xxx_rd_direct(ha,
|
|
|
|
QLA8XXX_PEG_ALIVE_COUNTER);
|
2010-07-30 11:08:47 +02:00
|
|
|
/* If PEG_ALIVE_COUNTER is 0xffffffff, AER/EEH is in progress, ignore */
|
|
|
|
if (fw_heartbeat_counter == 0xffffffff) {
|
|
|
|
DEBUG2(printk(KERN_WARNING "scsi%ld: %s: Device in frozen "
|
|
|
|
"state, QLA82XX_PEG_ALIVE_COUNTER is 0xffffffff\n",
|
|
|
|
ha->host_no, __func__));
|
2011-12-02 07:42:13 +01:00
|
|
|
return status;
|
2010-07-30 11:08:47 +02:00
|
|
|
}
|
2010-07-28 12:23:44 +02:00
|
|
|
|
|
|
|
if (ha->fw_heartbeat_counter == fw_heartbeat_counter) {
|
|
|
|
ha->seconds_since_last_heartbeat++;
|
|
|
|
/* FW not alive after 2 seconds */
|
|
|
|
if (ha->seconds_since_last_heartbeat == 2) {
|
|
|
|
ha->seconds_since_last_heartbeat = 0;
|
2012-08-22 13:55:08 +02:00
|
|
|
qla4_8xxx_dump_peg_reg(ha);
|
2011-12-02 07:42:13 +01:00
|
|
|
status = QLA_ERROR;
|
2010-07-28 12:23:44 +02:00
|
|
|
}
|
2010-10-07 07:49:32 +02:00
|
|
|
} else
|
|
|
|
ha->seconds_since_last_heartbeat = 0;
|
|
|
|
|
2010-07-28 12:23:44 +02:00
|
|
|
ha->fw_heartbeat_counter = fw_heartbeat_counter;
|
2011-12-02 07:42:13 +01:00
|
|
|
return status;
|
2010-07-28 12:23:44 +02:00
|
|
|
}
|
|
|
|
|
2012-08-22 13:55:08 +02:00
|
|
|
static void qla4_8xxx_process_fw_error(struct scsi_qla_host *ha)
|
|
|
|
{
|
|
|
|
uint32_t halt_status;
|
|
|
|
int halt_status_unrecoverable = 0;
|
|
|
|
|
|
|
|
halt_status = qla4_8xxx_rd_direct(ha, QLA8XXX_PEG_HALT_STATUS1);
|
|
|
|
|
|
|
|
if (is_qla8022(ha)) {
|
|
|
|
ql4_printk(KERN_INFO, ha, "%s: disabling pause transmit on port 0 & 1.\n",
|
|
|
|
__func__);
|
|
|
|
qla4_82xx_wr_32(ha, QLA82XX_CRB_NIU + 0x98,
|
|
|
|
CRB_NIU_XG_PAUSE_CTL_P0 |
|
|
|
|
CRB_NIU_XG_PAUSE_CTL_P1);
|
|
|
|
|
|
|
|
if (QLA82XX_FWERROR_CODE(halt_status) == 0x67)
|
|
|
|
ql4_printk(KERN_ERR, ha, "%s: Firmware aborted with error code 0x00006700. Device is being reset\n",
|
|
|
|
__func__);
|
|
|
|
if (halt_status & HALT_STATUS_UNRECOVERABLE)
|
|
|
|
halt_status_unrecoverable = 1;
|
2013-08-16 13:03:02 +02:00
|
|
|
} else if (is_qla8032(ha) || is_qla8042(ha)) {
|
2012-08-22 13:55:08 +02:00
|
|
|
if (halt_status & QLA83XX_HALT_STATUS_FW_RESET)
|
|
|
|
ql4_printk(KERN_ERR, ha, "%s: Firmware error detected device is being reset\n",
|
|
|
|
__func__);
|
|
|
|
else if (halt_status & QLA83XX_HALT_STATUS_UNRECOVERABLE)
|
|
|
|
halt_status_unrecoverable = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Since we cannot change dev_state in interrupt context,
|
|
|
|
* set appropriate DPC flag then wakeup DPC
|
|
|
|
*/
|
|
|
|
if (halt_status_unrecoverable) {
|
|
|
|
set_bit(DPC_HA_UNRECOVERABLE, &ha->dpc_flags);
|
|
|
|
} else {
|
|
|
|
ql4_printk(KERN_INFO, ha, "%s: detect abort needed!\n",
|
|
|
|
__func__);
|
|
|
|
set_bit(DPC_RESET_HA, &ha->dpc_flags);
|
|
|
|
}
|
|
|
|
qla4xxx_mailbox_premature_completion(ha);
|
|
|
|
qla4xxx_wake_dpc(ha);
|
|
|
|
}
|
|
|
|
|
2010-07-28 12:23:44 +02:00
|
|
|
/**
|
|
|
|
* qla4_8xxx_watchdog - Poll dev state
|
|
|
|
* @ha: Pointer to host adapter structure.
|
|
|
|
*
|
|
|
|
* Context: Interrupt
|
|
|
|
**/
|
|
|
|
void qla4_8xxx_watchdog(struct scsi_qla_host *ha)
|
|
|
|
{
|
2012-08-22 13:55:08 +02:00
|
|
|
uint32_t dev_state;
|
2013-03-07 11:43:10 +01:00
|
|
|
uint32_t idc_ctrl;
|
2010-07-28 12:23:44 +02:00
|
|
|
|
2013-12-16 12:49:32 +01:00
|
|
|
if (is_qla8032(ha) &&
|
|
|
|
(qla4_83xx_is_detached(ha) == QLA_SUCCESS))
|
|
|
|
WARN_ONCE(1, "%s: iSCSI function %d marked invisible\n",
|
|
|
|
__func__, ha->func_num);
|
|
|
|
|
2010-07-28 12:23:44 +02:00
|
|
|
/* don't poll if reset is going on */
|
2010-12-03 07:12:45 +01:00
|
|
|
if (!(test_bit(DPC_RESET_ACTIVE, &ha->dpc_flags) ||
|
|
|
|
test_bit(DPC_RESET_HA, &ha->dpc_flags) ||
|
2011-05-18 08:17:08 +02:00
|
|
|
test_bit(DPC_RETRY_RESET_HA, &ha->dpc_flags))) {
|
2012-08-22 13:55:04 +02:00
|
|
|
dev_state = qla4_8xxx_rd_direct(ha, QLA8XXX_CRB_DEV_STATE);
|
2012-01-11 11:44:15 +01:00
|
|
|
|
|
|
|
if (qla4_8xxx_check_temp(ha)) {
|
2012-08-22 13:55:08 +02:00
|
|
|
if (is_qla8022(ha)) {
|
|
|
|
ql4_printk(KERN_INFO, ha, "disabling pause transmit on port 0 & 1.\n");
|
|
|
|
qla4_82xx_wr_32(ha, QLA82XX_CRB_NIU + 0x98,
|
|
|
|
CRB_NIU_XG_PAUSE_CTL_P0 |
|
|
|
|
CRB_NIU_XG_PAUSE_CTL_P1);
|
|
|
|
}
|
2012-01-11 11:44:15 +01:00
|
|
|
set_bit(DPC_HA_UNRECOVERABLE, &ha->dpc_flags);
|
|
|
|
qla4xxx_wake_dpc(ha);
|
2012-08-22 15:14:24 +02:00
|
|
|
} else if (dev_state == QLA8XXX_DEV_NEED_RESET &&
|
2012-08-22 13:55:08 +02:00
|
|
|
!test_bit(DPC_RESET_HA, &ha->dpc_flags)) {
|
2013-03-07 11:43:10 +01:00
|
|
|
|
|
|
|
ql4_printk(KERN_INFO, ha, "%s: HW State: NEED RESET!\n",
|
|
|
|
__func__);
|
|
|
|
|
2013-08-16 13:03:02 +02:00
|
|
|
if (is_qla8032(ha) || is_qla8042(ha)) {
|
2013-03-07 11:43:10 +01:00
|
|
|
idc_ctrl = qla4_83xx_rd_reg(ha,
|
|
|
|
QLA83XX_IDC_DRV_CTRL);
|
|
|
|
if (!(idc_ctrl & GRACEFUL_RESET_BIT1)) {
|
|
|
|
ql4_printk(KERN_INFO, ha, "%s: Graceful reset bit is not set\n",
|
|
|
|
__func__);
|
|
|
|
qla4xxx_mailbox_premature_completion(
|
|
|
|
ha);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-16 13:03:02 +02:00
|
|
|
if ((is_qla8032(ha) || is_qla8042(ha)) ||
|
2012-08-22 13:55:08 +02:00
|
|
|
(is_qla8022(ha) && !ql4xdontresethba)) {
|
2010-12-03 07:12:47 +01:00
|
|
|
set_bit(DPC_RESET_HA, &ha->dpc_flags);
|
|
|
|
qla4xxx_wake_dpc(ha);
|
|
|
|
}
|
2012-08-22 15:14:24 +02:00
|
|
|
} else if (dev_state == QLA8XXX_DEV_NEED_QUIESCENT &&
|
2010-07-28 12:23:44 +02:00
|
|
|
!test_bit(DPC_HA_NEED_QUIESCENT, &ha->dpc_flags)) {
|
2010-12-03 07:12:47 +01:00
|
|
|
ql4_printk(KERN_INFO, ha, "%s: HW State: NEED QUIES!\n",
|
|
|
|
__func__);
|
2010-07-28 12:23:44 +02:00
|
|
|
set_bit(DPC_HA_NEED_QUIESCENT, &ha->dpc_flags);
|
|
|
|
qla4xxx_wake_dpc(ha);
|
|
|
|
} else {
|
|
|
|
/* Check firmware health */
|
2012-08-22 13:55:08 +02:00
|
|
|
if (qla4_8xxx_check_fw_alive(ha))
|
|
|
|
qla4_8xxx_process_fw_error(ha);
|
2010-07-28 12:23:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-16 10:58:55 +01:00
|
|
|
static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
|
2011-12-02 04:38:41 +01:00
|
|
|
{
|
|
|
|
struct iscsi_session *sess;
|
|
|
|
struct ddb_entry *ddb_entry;
|
|
|
|
struct scsi_qla_host *ha;
|
|
|
|
|
|
|
|
sess = cls_sess->dd_data;
|
|
|
|
ddb_entry = sess->dd_data;
|
|
|
|
ha = ddb_entry->ha;
|
|
|
|
|
|
|
|
if (!(ddb_entry->ddb_type == FLASH_DDB))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (adapter_up(ha) && !test_bit(DF_RELOGIN, &ddb_entry->flags) &&
|
|
|
|
!iscsi_is_session_online(cls_sess)) {
|
|
|
|
if (atomic_read(&ddb_entry->retry_relogin_timer) !=
|
|
|
|
INVALID_ENTRY) {
|
|
|
|
if (atomic_read(&ddb_entry->retry_relogin_timer) ==
|
|
|
|
0) {
|
|
|
|
atomic_set(&ddb_entry->retry_relogin_timer,
|
|
|
|
INVALID_ENTRY);
|
|
|
|
set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
|
|
|
|
set_bit(DF_RELOGIN, &ddb_entry->flags);
|
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha,
|
|
|
|
"%s: index [%d] login device\n",
|
|
|
|
__func__, ddb_entry->fw_ddb_index));
|
|
|
|
} else
|
|
|
|
atomic_dec(&ddb_entry->retry_relogin_timer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Wait for relogin to timeout */
|
|
|
|
if (atomic_read(&ddb_entry->relogin_timer) &&
|
|
|
|
(atomic_dec_and_test(&ddb_entry->relogin_timer) != 0)) {
|
|
|
|
/*
|
|
|
|
* If the relogin times out and the device is
|
|
|
|
* still NOT ONLINE then try and relogin again.
|
|
|
|
*/
|
|
|
|
if (!iscsi_is_session_online(cls_sess)) {
|
|
|
|
/* Reset retry relogin timer */
|
|
|
|
atomic_inc(&ddb_entry->relogin_retry_count);
|
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha,
|
|
|
|
"%s: index[%d] relogin timed out-retrying"
|
|
|
|
" relogin (%d), retry (%d)\n", __func__,
|
|
|
|
ddb_entry->fw_ddb_index,
|
|
|
|
atomic_read(&ddb_entry->relogin_retry_count),
|
|
|
|
ddb_entry->default_time2wait + 4));
|
|
|
|
set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
|
|
|
|
atomic_set(&ddb_entry->retry_relogin_timer,
|
|
|
|
ddb_entry->default_time2wait + 4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-19 19:28:00 +02:00
|
|
|
/**
|
|
|
|
* qla4xxx_timer - checks every second for work to do.
|
|
|
|
* @ha: Pointer to host adapter structure.
|
|
|
|
**/
|
2017-10-21 17:39:39 +02:00
|
|
|
static void qla4xxx_timer(struct timer_list *t)
|
2006-09-19 19:28:00 +02:00
|
|
|
{
|
2017-10-21 17:39:39 +02:00
|
|
|
struct scsi_qla_host *ha = from_timer(ha, t, timer);
|
2006-09-19 19:28:00 +02:00
|
|
|
int start_dpc = 0;
|
2010-07-30 11:08:47 +02:00
|
|
|
uint16_t w;
|
|
|
|
|
2011-12-02 04:38:41 +01:00
|
|
|
iscsi_host_for_each_session(ha->host, qla4xxx_check_relogin_flash_ddb);
|
|
|
|
|
2010-07-30 11:08:47 +02:00
|
|
|
/* If we are in the middle of AER/EEH processing
|
|
|
|
* skip any processing and reschedule the timer
|
|
|
|
*/
|
|
|
|
if (test_bit(AF_EEH_BUSY, &ha->flags)) {
|
|
|
|
mod_timer(&ha->timer, jiffies + HZ);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Hardware read to trigger an EEH error during mailbox waits. */
|
|
|
|
if (!pci_channel_offline(ha->pdev))
|
|
|
|
pci_read_config_word(ha->pdev, PCI_VENDOR_ID, &w);
|
2006-09-19 19:28:00 +02:00
|
|
|
|
2012-08-22 13:55:08 +02:00
|
|
|
if (is_qla80XX(ha))
|
2010-07-28 12:23:44 +02:00
|
|
|
qla4_8xxx_watchdog(ha);
|
|
|
|
|
2012-08-22 13:55:05 +02:00
|
|
|
if (is_qla40XX(ha)) {
|
2010-07-28 12:23:44 +02:00
|
|
|
/* Check for heartbeat interval. */
|
|
|
|
if (ha->firmware_options & FWOPT_HEARTBEAT_ENABLE &&
|
|
|
|
ha->heartbeat_interval != 0) {
|
|
|
|
ha->seconds_since_last_heartbeat++;
|
|
|
|
if (ha->seconds_since_last_heartbeat >
|
|
|
|
ha->heartbeat_interval + 2)
|
|
|
|
set_bit(DPC_RESET_HA, &ha->dpc_flags);
|
|
|
|
}
|
2006-09-19 19:28:00 +02:00
|
|
|
}
|
|
|
|
|
2011-08-29 20:13:02 +02:00
|
|
|
/* Process any deferred work. */
|
|
|
|
if (!list_empty(&ha->work_list))
|
|
|
|
start_dpc++;
|
|
|
|
|
2006-09-19 19:28:00 +02:00
|
|
|
/* Wakeup the dpc routine for this adapter, if needed. */
|
2011-05-18 08:17:09 +02:00
|
|
|
if (start_dpc ||
|
2006-09-19 19:28:00 +02:00
|
|
|
test_bit(DPC_RESET_HA, &ha->dpc_flags) ||
|
|
|
|
test_bit(DPC_RETRY_RESET_HA, &ha->dpc_flags) ||
|
|
|
|
test_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags) ||
|
2010-07-28 12:23:44 +02:00
|
|
|
test_bit(DPC_RESET_HA_FW_CONTEXT, &ha->dpc_flags) ||
|
2006-09-19 19:28:00 +02:00
|
|
|
test_bit(DPC_RESET_HA_INTR, &ha->dpc_flags) ||
|
|
|
|
test_bit(DPC_GET_DHCP_IP_ADDR, &ha->dpc_flags) ||
|
2010-04-28 08:08:11 +02:00
|
|
|
test_bit(DPC_LINK_CHANGED, &ha->dpc_flags) ||
|
2010-07-28 12:23:44 +02:00
|
|
|
test_bit(DPC_HA_UNRECOVERABLE, &ha->dpc_flags) ||
|
|
|
|
test_bit(DPC_HA_NEED_QUIESCENT, &ha->dpc_flags) ||
|
2014-04-10 03:12:25 +02:00
|
|
|
test_bit(DPC_SYSFS_DDB_EXPORT, &ha->dpc_flags) ||
|
2011-05-18 08:17:09 +02:00
|
|
|
test_bit(DPC_AEN, &ha->dpc_flags)) {
|
2006-09-19 19:28:00 +02:00
|
|
|
DEBUG2(printk("scsi%ld: %s: scheduling dpc routine"
|
|
|
|
" - dpc flags = 0x%lx\n",
|
|
|
|
ha->host_no, __func__, ha->dpc_flags));
|
2010-07-28 12:23:44 +02:00
|
|
|
qla4xxx_wake_dpc(ha);
|
2006-09-19 19:28:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Reschedule timer thread to call us back in one second */
|
|
|
|
mod_timer(&ha->timer, jiffies + HZ);
|
|
|
|
|
|
|
|
DEBUG2(ha->seconds_since_last_intr++);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* qla4xxx_cmd_wait - waits for all outstanding commands to complete
|
|
|
|
* @ha: Pointer to host adapter structure.
|
|
|
|
*
|
|
|
|
* This routine stalls the driver until all outstanding commands are returned.
|
|
|
|
* Caller must release the Hardware Lock prior to calling this routine.
|
|
|
|
**/
|
|
|
|
static int qla4xxx_cmd_wait(struct scsi_qla_host *ha)
|
|
|
|
{
|
|
|
|
uint32_t index = 0;
|
|
|
|
unsigned long flags;
|
|
|
|
struct scsi_cmnd *cmd;
|
2013-12-16 12:49:43 +01:00
|
|
|
unsigned long wtime;
|
|
|
|
uint32_t wtmo;
|
2006-09-19 19:28:00 +02:00
|
|
|
|
2013-12-16 12:49:43 +01:00
|
|
|
if (is_qla40XX(ha))
|
|
|
|
wtmo = WAIT_CMD_TOV;
|
|
|
|
else
|
|
|
|
wtmo = ha->nx_reset_timeout / 2;
|
|
|
|
|
|
|
|
wtime = jiffies + (wtmo * HZ);
|
2010-07-28 12:23:44 +02:00
|
|
|
|
2013-12-16 12:49:43 +01:00
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha,
|
|
|
|
"Wait up to %u seconds for cmds to complete\n",
|
|
|
|
wtmo));
|
2010-07-28 12:23:44 +02:00
|
|
|
|
|
|
|
while (!time_after_eq(jiffies, wtime)) {
|
2006-09-19 19:28:00 +02:00
|
|
|
spin_lock_irqsave(&ha->hardware_lock, flags);
|
|
|
|
/* Find a command that hasn't completed. */
|
|
|
|
for (index = 0; index < ha->host->can_queue; index++) {
|
|
|
|
cmd = scsi_host_find_tag(ha->host, index);
|
2010-10-26 14:45:30 +02:00
|
|
|
/*
|
|
|
|
* We cannot just check if the index is valid,
|
|
|
|
* becase if we are run from the scsi eh, then
|
|
|
|
* the scsi/block layer is going to prevent
|
|
|
|
* the tag from being released.
|
|
|
|
*/
|
|
|
|
if (cmd != NULL && CMD_SP(cmd))
|
2006-09-19 19:28:00 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&ha->hardware_lock, flags);
|
|
|
|
|
|
|
|
/* If No Commands are pending, wait is complete */
|
2010-07-28 12:23:44 +02:00
|
|
|
if (index == ha->host->can_queue)
|
|
|
|
return QLA_SUCCESS;
|
2006-09-19 19:28:00 +02:00
|
|
|
|
2010-07-28 12:23:44 +02:00
|
|
|
msleep(1000);
|
|
|
|
}
|
|
|
|
/* If we timed out on waiting for commands to come back
|
|
|
|
* return ERROR. */
|
|
|
|
return QLA_ERROR;
|
2006-09-19 19:28:00 +02:00
|
|
|
}
|
|
|
|
|
2010-07-28 12:23:44 +02:00
|
|
|
int qla4xxx_hw_reset(struct scsi_qla_host *ha)
|
2006-09-19 19:28:00 +02:00
|
|
|
{
|
|
|
|
uint32_t ctrl_status;
|
2007-01-22 21:26:11 +01:00
|
|
|
unsigned long flags = 0;
|
|
|
|
|
|
|
|
DEBUG2(printk(KERN_ERR "scsi%ld: %s\n", ha->host_no, __func__));
|
2006-09-19 19:28:00 +02:00
|
|
|
|
2010-07-28 12:23:44 +02:00
|
|
|
if (ql4xxx_lock_drvr_wait(ha) != QLA_SUCCESS)
|
|
|
|
return QLA_ERROR;
|
|
|
|
|
2006-09-19 19:28:00 +02:00
|
|
|
spin_lock_irqsave(&ha->hardware_lock, flags);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the SCSI Reset Interrupt bit is set, clear it.
|
|
|
|
* Otherwise, the Soft Reset won't work.
|
|
|
|
*/
|
|
|
|
ctrl_status = readw(&ha->reg->ctrl_status);
|
|
|
|
if ((ctrl_status & CSR_SCSI_RESET_INTR) != 0)
|
|
|
|
writel(set_rmask(CSR_SCSI_RESET_INTR), &ha->reg->ctrl_status);
|
|
|
|
|
|
|
|
/* Issue Soft Reset */
|
|
|
|
writel(set_rmask(CSR_SOFT_RESET), &ha->reg->ctrl_status);
|
|
|
|
readl(&ha->reg->ctrl_status);
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&ha->hardware_lock, flags);
|
2010-07-28 12:23:44 +02:00
|
|
|
return QLA_SUCCESS;
|
2007-01-22 21:26:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* qla4xxx_soft_reset - performs soft reset.
|
|
|
|
* @ha: Pointer to host adapter structure.
|
|
|
|
**/
|
|
|
|
int qla4xxx_soft_reset(struct scsi_qla_host *ha)
|
|
|
|
{
|
|
|
|
uint32_t max_wait_time;
|
|
|
|
unsigned long flags = 0;
|
2010-10-07 07:48:07 +02:00
|
|
|
int status;
|
2007-01-22 21:26:11 +01:00
|
|
|
uint32_t ctrl_status;
|
|
|
|
|
2010-10-07 07:48:07 +02:00
|
|
|
status = qla4xxx_hw_reset(ha);
|
|
|
|
if (status != QLA_SUCCESS)
|
|
|
|
return status;
|
2006-09-19 19:28:00 +02:00
|
|
|
|
2010-10-07 07:48:07 +02:00
|
|
|
status = QLA_ERROR;
|
2006-09-19 19:28:00 +02:00
|
|
|
/* Wait until the Network Reset Intr bit is cleared */
|
|
|
|
max_wait_time = RESET_INTR_TOV;
|
|
|
|
do {
|
|
|
|
spin_lock_irqsave(&ha->hardware_lock, flags);
|
|
|
|
ctrl_status = readw(&ha->reg->ctrl_status);
|
|
|
|
spin_unlock_irqrestore(&ha->hardware_lock, flags);
|
|
|
|
|
|
|
|
if ((ctrl_status & CSR_NET_RESET_INTR) == 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
msleep(1000);
|
|
|
|
} while ((--max_wait_time));
|
|
|
|
|
|
|
|
if ((ctrl_status & CSR_NET_RESET_INTR) != 0) {
|
|
|
|
DEBUG2(printk(KERN_WARNING
|
|
|
|
"scsi%ld: Network Reset Intr not cleared by "
|
|
|
|
"Network function, clearing it now!\n",
|
|
|
|
ha->host_no));
|
|
|
|
spin_lock_irqsave(&ha->hardware_lock, flags);
|
|
|
|
writel(set_rmask(CSR_NET_RESET_INTR), &ha->reg->ctrl_status);
|
|
|
|
readl(&ha->reg->ctrl_status);
|
|
|
|
spin_unlock_irqrestore(&ha->hardware_lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Wait until the firmware tells us the Soft Reset is done */
|
|
|
|
max_wait_time = SOFT_RESET_TOV;
|
|
|
|
do {
|
|
|
|
spin_lock_irqsave(&ha->hardware_lock, flags);
|
|
|
|
ctrl_status = readw(&ha->reg->ctrl_status);
|
|
|
|
spin_unlock_irqrestore(&ha->hardware_lock, flags);
|
|
|
|
|
|
|
|
if ((ctrl_status & CSR_SOFT_RESET) == 0) {
|
|
|
|
status = QLA_SUCCESS;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
msleep(1000);
|
|
|
|
} while ((--max_wait_time));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Also, make sure that the SCSI Reset Interrupt bit has been cleared
|
|
|
|
* after the soft reset has taken place.
|
|
|
|
*/
|
|
|
|
spin_lock_irqsave(&ha->hardware_lock, flags);
|
|
|
|
ctrl_status = readw(&ha->reg->ctrl_status);
|
|
|
|
if ((ctrl_status & CSR_SCSI_RESET_INTR) != 0) {
|
|
|
|
writel(set_rmask(CSR_SCSI_RESET_INTR), &ha->reg->ctrl_status);
|
|
|
|
readl(&ha->reg->ctrl_status);
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&ha->hardware_lock, flags);
|
|
|
|
|
|
|
|
/* If soft reset fails then most probably the bios on other
|
|
|
|
* function is also enabled.
|
|
|
|
* Since the initialization is sequential the other fn
|
|
|
|
* wont be able to acknowledge the soft reset.
|
|
|
|
* Issue a force soft reset to workaround this scenario.
|
|
|
|
*/
|
|
|
|
if (max_wait_time == 0) {
|
|
|
|
/* Issue Force Soft Reset */
|
|
|
|
spin_lock_irqsave(&ha->hardware_lock, flags);
|
|
|
|
writel(set_rmask(CSR_FORCE_SOFT_RESET), &ha->reg->ctrl_status);
|
|
|
|
readl(&ha->reg->ctrl_status);
|
|
|
|
spin_unlock_irqrestore(&ha->hardware_lock, flags);
|
|
|
|
/* Wait until the firmware tells us the Soft Reset is done */
|
|
|
|
max_wait_time = SOFT_RESET_TOV;
|
|
|
|
do {
|
|
|
|
spin_lock_irqsave(&ha->hardware_lock, flags);
|
|
|
|
ctrl_status = readw(&ha->reg->ctrl_status);
|
|
|
|
spin_unlock_irqrestore(&ha->hardware_lock, flags);
|
|
|
|
|
|
|
|
if ((ctrl_status & CSR_FORCE_SOFT_RESET) == 0) {
|
|
|
|
status = QLA_SUCCESS;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
msleep(1000);
|
|
|
|
} while ((--max_wait_time));
|
|
|
|
}
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-07-28 12:23:44 +02:00
|
|
|
* qla4xxx_abort_active_cmds - returns all outstanding i/o requests to O.S.
|
2006-09-19 19:28:00 +02:00
|
|
|
* @ha: Pointer to host adapter structure.
|
2010-07-28 12:23:44 +02:00
|
|
|
* @res: returned scsi status
|
2006-09-19 19:28:00 +02:00
|
|
|
*
|
|
|
|
* This routine is called just prior to a HARD RESET to return all
|
|
|
|
* outstanding commands back to the Operating System.
|
|
|
|
* Caller should make sure that the following locks are released
|
|
|
|
* before this calling routine: Hardware lock, and io_request_lock.
|
|
|
|
**/
|
2010-07-28 12:23:44 +02:00
|
|
|
static void qla4xxx_abort_active_cmds(struct scsi_qla_host *ha, int res)
|
2006-09-19 19:28:00 +02:00
|
|
|
{
|
|
|
|
struct srb *srb;
|
|
|
|
int i;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&ha->hardware_lock, flags);
|
|
|
|
for (i = 0; i < ha->host->can_queue; i++) {
|
|
|
|
srb = qla4xxx_del_from_active_array(ha, i);
|
|
|
|
if (srb != NULL) {
|
2010-07-28 12:23:44 +02:00
|
|
|
srb->cmd->result = res;
|
2010-04-28 08:12:24 +02:00
|
|
|
kref_put(&srb->srb_ref, qla4xxx_srb_compl);
|
2006-09-19 19:28:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&ha->hardware_lock, flags);
|
|
|
|
}
|
|
|
|
|
2010-07-28 12:23:44 +02:00
|
|
|
void qla4xxx_dead_adapter_cleanup(struct scsi_qla_host *ha)
|
|
|
|
{
|
|
|
|
clear_bit(AF_ONLINE, &ha->flags);
|
|
|
|
|
|
|
|
/* Disable the board */
|
|
|
|
ql4_printk(KERN_INFO, ha, "Disabling the board\n");
|
|
|
|
|
|
|
|
qla4xxx_abort_active_cmds(ha, DID_NO_CONNECT << 16);
|
|
|
|
qla4xxx_mark_all_devices_missing(ha);
|
|
|
|
clear_bit(AF_INIT_DONE, &ha->flags);
|
|
|
|
}
|
|
|
|
|
2011-07-25 20:48:53 +02:00
|
|
|
static void qla4xxx_fail_session(struct iscsi_cls_session *cls_session)
|
|
|
|
{
|
|
|
|
struct iscsi_session *sess;
|
|
|
|
struct ddb_entry *ddb_entry;
|
|
|
|
|
|
|
|
sess = cls_session->dd_data;
|
|
|
|
ddb_entry = sess->dd_data;
|
|
|
|
ddb_entry->fw_ddb_device_state = DDB_DS_SESSION_FAILED;
|
2011-12-02 04:38:41 +01:00
|
|
|
|
|
|
|
if (ddb_entry->ddb_type == FLASH_DDB)
|
|
|
|
iscsi_block_session(ddb_entry->sess);
|
|
|
|
else
|
|
|
|
iscsi_session_failure(cls_session->dd_data,
|
|
|
|
ISCSI_ERR_CONN_FAILED);
|
2011-07-25 20:48:53 +02:00
|
|
|
}
|
|
|
|
|
2006-09-19 19:28:00 +02:00
|
|
|
/**
|
|
|
|
* qla4xxx_recover_adapter - recovers adapter after a fatal error
|
|
|
|
* @ha: Pointer to host adapter structure.
|
|
|
|
**/
|
2010-07-28 12:23:44 +02:00
|
|
|
static int qla4xxx_recover_adapter(struct scsi_qla_host *ha)
|
2006-09-19 19:28:00 +02:00
|
|
|
{
|
2010-07-28 12:23:44 +02:00
|
|
|
int status = QLA_ERROR;
|
|
|
|
uint8_t reset_chip = 0;
|
2011-12-02 07:42:09 +01:00
|
|
|
uint32_t dev_state;
|
2011-12-02 07:42:13 +01:00
|
|
|
unsigned long wait;
|
2006-09-19 19:28:00 +02:00
|
|
|
|
|
|
|
/* Stall incoming I/O until we are done */
|
2010-07-28 12:23:44 +02:00
|
|
|
scsi_block_requests(ha->host);
|
2006-09-19 19:28:00 +02:00
|
|
|
clear_bit(AF_ONLINE, &ha->flags);
|
2011-07-25 20:48:53 +02:00
|
|
|
clear_bit(AF_LINK_UP, &ha->flags);
|
2008-03-04 20:26:53 +01:00
|
|
|
|
2010-07-28 12:23:44 +02:00
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha, "%s: adapter OFFLINE\n", __func__));
|
2006-09-19 19:28:00 +02:00
|
|
|
|
2010-07-28 12:23:44 +02:00
|
|
|
set_bit(DPC_RESET_ACTIVE, &ha->dpc_flags);
|
2006-09-19 19:28:00 +02:00
|
|
|
|
2013-08-16 13:03:02 +02:00
|
|
|
if ((is_qla8032(ha) || is_qla8042(ha)) &&
|
2012-09-20 13:35:12 +02:00
|
|
|
!test_bit(DPC_RESET_HA_FW_CONTEXT, &ha->dpc_flags)) {
|
|
|
|
ql4_printk(KERN_INFO, ha, "%s: disabling pause transmit on port 0 & 1.\n",
|
|
|
|
__func__);
|
|
|
|
/* disable pause frame for ISP83xx */
|
|
|
|
qla4_83xx_disable_pause(ha);
|
|
|
|
}
|
|
|
|
|
2011-07-25 20:48:53 +02:00
|
|
|
iscsi_host_for_each_session(ha->host, qla4xxx_fail_session);
|
|
|
|
|
2010-07-28 12:23:44 +02:00
|
|
|
if (test_bit(DPC_RESET_HA, &ha->dpc_flags))
|
|
|
|
reset_chip = 1;
|
2006-09-19 19:28:00 +02:00
|
|
|
|
2010-07-28 12:23:44 +02:00
|
|
|
/* For the DPC_RESET_HA_INTR case (ISP-4xxx specific)
|
|
|
|
* do not reset adapter, jump to initialize_adapter */
|
|
|
|
if (test_bit(DPC_RESET_HA_INTR, &ha->dpc_flags)) {
|
|
|
|
status = QLA_SUCCESS;
|
|
|
|
goto recover_ha_init_adapter;
|
|
|
|
}
|
2006-09-19 19:28:00 +02:00
|
|
|
|
2012-08-22 13:55:08 +02:00
|
|
|
/* For the ISP-8xxx adapter, issue a stop_firmware if invoked
|
2010-07-28 12:23:44 +02:00
|
|
|
* from eh_host_reset or ioctl module */
|
2012-08-22 13:55:08 +02:00
|
|
|
if (is_qla80XX(ha) && !reset_chip &&
|
2010-07-28 12:23:44 +02:00
|
|
|
test_bit(DPC_RESET_HA_FW_CONTEXT, &ha->dpc_flags)) {
|
|
|
|
|
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha,
|
|
|
|
"scsi%ld: %s - Performing stop_firmware...\n",
|
|
|
|
ha->host_no, __func__));
|
|
|
|
status = ha->isp_ops->reset_firmware(ha);
|
|
|
|
if (status == QLA_SUCCESS) {
|
|
|
|
ha->isp_ops->disable_intrs(ha);
|
|
|
|
qla4xxx_process_aen(ha, FLUSH_DDB_CHANGED_AENS);
|
|
|
|
qla4xxx_abort_active_cmds(ha, DID_RESET << 16);
|
|
|
|
} else {
|
|
|
|
/* If the stop_firmware fails then
|
|
|
|
* reset the entire chip */
|
|
|
|
reset_chip = 1;
|
|
|
|
clear_bit(DPC_RESET_HA_FW_CONTEXT, &ha->dpc_flags);
|
|
|
|
set_bit(DPC_RESET_HA, &ha->dpc_flags);
|
|
|
|
}
|
|
|
|
}
|
2009-07-15 22:03:00 +02:00
|
|
|
|
2010-07-28 12:23:44 +02:00
|
|
|
/* Issue full chip reset if recovering from a catastrophic error,
|
2012-08-22 13:55:08 +02:00
|
|
|
* or if stop_firmware fails for ISP-8xxx.
|
2010-07-28 12:23:44 +02:00
|
|
|
* This is the default case for ISP-4xxx */
|
2012-08-22 13:55:05 +02:00
|
|
|
if (is_qla40XX(ha) || reset_chip) {
|
|
|
|
if (is_qla40XX(ha))
|
2011-12-02 07:42:13 +01:00
|
|
|
goto chip_reset;
|
|
|
|
|
2012-08-22 13:55:08 +02:00
|
|
|
/* Check if 8XXX firmware is alive or not
|
2011-12-02 07:42:13 +01:00
|
|
|
* We may have arrived here from NEED_RESET
|
|
|
|
* detection only */
|
|
|
|
if (test_bit(AF_FW_RECOVERY, &ha->flags))
|
|
|
|
goto chip_reset;
|
|
|
|
|
|
|
|
wait = jiffies + (FW_ALIVE_WAIT_TOV * HZ);
|
|
|
|
while (time_before(jiffies, wait)) {
|
|
|
|
if (qla4_8xxx_check_fw_alive(ha)) {
|
|
|
|
qla4xxx_mailbox_premature_completion(ha);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
set_current_state(TASK_UNINTERRUPTIBLE);
|
|
|
|
schedule_timeout(HZ);
|
|
|
|
}
|
2012-08-22 13:45:26 +02:00
|
|
|
chip_reset:
|
2010-10-07 07:49:20 +02:00
|
|
|
if (!test_bit(AF_FW_RECOVERY, &ha->flags))
|
|
|
|
qla4xxx_cmd_wait(ha);
|
2012-08-22 13:45:26 +02:00
|
|
|
|
2010-07-28 12:23:44 +02:00
|
|
|
qla4xxx_process_aen(ha, FLUSH_DDB_CHANGED_AENS);
|
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha,
|
|
|
|
"scsi%ld: %s - Performing chip reset..\n",
|
|
|
|
ha->host_no, __func__));
|
|
|
|
status = ha->isp_ops->reset_chip(ha);
|
2013-12-16 12:49:43 +01:00
|
|
|
qla4xxx_abort_active_cmds(ha, DID_RESET << 16);
|
2010-07-28 12:23:44 +02:00
|
|
|
}
|
2006-09-19 19:28:00 +02:00
|
|
|
|
|
|
|
/* Flush any pending ddb changed AENs */
|
|
|
|
qla4xxx_process_aen(ha, FLUSH_DDB_CHANGED_AENS);
|
|
|
|
|
2010-07-28 12:23:44 +02:00
|
|
|
recover_ha_init_adapter:
|
|
|
|
/* Upon successful firmware/chip reset, re-initialize the adapter */
|
2006-09-19 19:28:00 +02:00
|
|
|
if (status == QLA_SUCCESS) {
|
2010-07-28 12:23:44 +02:00
|
|
|
/* For ISP-4xxx, force function 1 to always initialize
|
|
|
|
* before function 3 to prevent both funcions from
|
|
|
|
* stepping on top of the other */
|
2012-08-22 13:55:05 +02:00
|
|
|
if (is_qla40XX(ha) && (ha->mac_index == 3))
|
2010-07-28 12:23:44 +02:00
|
|
|
ssleep(6);
|
|
|
|
|
|
|
|
/* NOTE: AF_ONLINE flag set upon successful completion of
|
2013-12-16 12:49:31 +01:00
|
|
|
* qla4xxx_initialize_adapter */
|
2011-12-02 04:38:41 +01:00
|
|
|
status = qla4xxx_initialize_adapter(ha, RESET_ADAPTER);
|
2013-12-16 12:49:31 +01:00
|
|
|
if (is_qla80XX(ha) && (status == QLA_ERROR)) {
|
|
|
|
status = qla4_8xxx_check_init_adapter_retry(ha);
|
|
|
|
if (status == QLA_ERROR) {
|
|
|
|
ql4_printk(KERN_INFO, ha, "scsi%ld: %s: Don't retry recover adapter\n",
|
|
|
|
ha->host_no, __func__);
|
|
|
|
qla4xxx_dead_adapter_cleanup(ha);
|
|
|
|
clear_bit(DPC_RETRY_RESET_HA, &ha->dpc_flags);
|
|
|
|
clear_bit(DPC_RESET_HA, &ha->dpc_flags);
|
|
|
|
clear_bit(DPC_RESET_HA_FW_CONTEXT,
|
|
|
|
&ha->dpc_flags);
|
|
|
|
goto exit_recover;
|
|
|
|
}
|
|
|
|
}
|
2006-09-19 19:28:00 +02:00
|
|
|
}
|
|
|
|
|
2010-07-28 12:23:44 +02:00
|
|
|
/* Retry failed adapter initialization, if necessary
|
|
|
|
* Do not retry initialize_adapter for RESET_HA_INTR (ISP-4xxx specific)
|
|
|
|
* case to prevent ping-pong resets between functions */
|
|
|
|
if (!test_bit(AF_ONLINE, &ha->flags) &&
|
|
|
|
!test_bit(DPC_RESET_HA_INTR, &ha->dpc_flags)) {
|
2006-09-19 19:28:00 +02:00
|
|
|
/* Adapter initialization failed, see if we can retry
|
2010-07-28 12:23:44 +02:00
|
|
|
* resetting the ha.
|
|
|
|
* Since we don't want to block the DPC for too long
|
|
|
|
* with multiple resets in the same thread,
|
|
|
|
* utilize DPC to retry */
|
2012-08-22 13:55:08 +02:00
|
|
|
if (is_qla80XX(ha)) {
|
2012-08-22 13:55:04 +02:00
|
|
|
ha->isp_ops->idc_lock(ha);
|
|
|
|
dev_state = qla4_8xxx_rd_direct(ha,
|
|
|
|
QLA8XXX_CRB_DEV_STATE);
|
|
|
|
ha->isp_ops->idc_unlock(ha);
|
2012-08-22 15:14:24 +02:00
|
|
|
if (dev_state == QLA8XXX_DEV_FAILED) {
|
2011-12-02 07:42:09 +01:00
|
|
|
ql4_printk(KERN_INFO, ha, "%s: don't retry "
|
|
|
|
"recover adapter. H/W is in Failed "
|
|
|
|
"state\n", __func__);
|
|
|
|
qla4xxx_dead_adapter_cleanup(ha);
|
|
|
|
clear_bit(DPC_RETRY_RESET_HA, &ha->dpc_flags);
|
|
|
|
clear_bit(DPC_RESET_HA, &ha->dpc_flags);
|
|
|
|
clear_bit(DPC_RESET_HA_FW_CONTEXT,
|
|
|
|
&ha->dpc_flags);
|
|
|
|
status = QLA_ERROR;
|
|
|
|
|
|
|
|
goto exit_recover;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-19 19:28:00 +02:00
|
|
|
if (!test_bit(DPC_RETRY_RESET_HA, &ha->dpc_flags)) {
|
|
|
|
ha->retry_reset_ha_cnt = MAX_RESET_HA_RETRIES;
|
|
|
|
DEBUG2(printk("scsi%ld: recover adapter - retrying "
|
|
|
|
"(%d) more times\n", ha->host_no,
|
|
|
|
ha->retry_reset_ha_cnt));
|
|
|
|
set_bit(DPC_RETRY_RESET_HA, &ha->dpc_flags);
|
|
|
|
status = QLA_ERROR;
|
|
|
|
} else {
|
|
|
|
if (ha->retry_reset_ha_cnt > 0) {
|
|
|
|
/* Schedule another Reset HA--DPC will retry */
|
|
|
|
ha->retry_reset_ha_cnt--;
|
|
|
|
DEBUG2(printk("scsi%ld: recover adapter - "
|
|
|
|
"retry remaining %d\n",
|
|
|
|
ha->host_no,
|
|
|
|
ha->retry_reset_ha_cnt));
|
|
|
|
status = QLA_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ha->retry_reset_ha_cnt == 0) {
|
|
|
|
/* Recover adapter retries have been exhausted.
|
|
|
|
* Adapter DEAD */
|
|
|
|
DEBUG2(printk("scsi%ld: recover adapter "
|
|
|
|
"failed - board disabled\n",
|
|
|
|
ha->host_no));
|
2010-07-28 12:23:44 +02:00
|
|
|
qla4xxx_dead_adapter_cleanup(ha);
|
2006-09-19 19:28:00 +02:00
|
|
|
clear_bit(DPC_RETRY_RESET_HA, &ha->dpc_flags);
|
|
|
|
clear_bit(DPC_RESET_HA, &ha->dpc_flags);
|
2010-07-28 12:23:44 +02:00
|
|
|
clear_bit(DPC_RESET_HA_FW_CONTEXT,
|
2006-09-19 19:28:00 +02:00
|
|
|
&ha->dpc_flags);
|
|
|
|
status = QLA_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
clear_bit(DPC_RESET_HA, &ha->dpc_flags);
|
2010-07-28 12:23:44 +02:00
|
|
|
clear_bit(DPC_RESET_HA_FW_CONTEXT, &ha->dpc_flags);
|
2006-09-19 19:28:00 +02:00
|
|
|
clear_bit(DPC_RETRY_RESET_HA, &ha->dpc_flags);
|
|
|
|
}
|
|
|
|
|
2011-12-02 07:42:09 +01:00
|
|
|
exit_recover:
|
2006-09-19 19:28:00 +02:00
|
|
|
ha->adapter_error_count++;
|
|
|
|
|
2010-07-28 12:23:44 +02:00
|
|
|
if (test_bit(AF_ONLINE, &ha->flags))
|
|
|
|
ha->isp_ops->enable_intrs(ha);
|
|
|
|
|
|
|
|
scsi_unblock_requests(ha->host);
|
|
|
|
|
|
|
|
clear_bit(DPC_RESET_ACTIVE, &ha->dpc_flags);
|
|
|
|
DEBUG2(printk("scsi%ld: recover adapter: %s\n", ha->host_no,
|
2011-03-31 03:57:33 +02:00
|
|
|
status == QLA_ERROR ? "FAILED" : "SUCCEEDED"));
|
2006-09-19 19:28:00 +02:00
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2011-07-25 20:48:53 +02:00
|
|
|
static void qla4xxx_relogin_devices(struct iscsi_cls_session *cls_session)
|
2011-03-21 11:34:33 +01:00
|
|
|
{
|
2011-07-25 20:48:53 +02:00
|
|
|
struct iscsi_session *sess;
|
|
|
|
struct ddb_entry *ddb_entry;
|
|
|
|
struct scsi_qla_host *ha;
|
2011-03-21 11:34:33 +01:00
|
|
|
|
2011-07-25 20:48:53 +02:00
|
|
|
sess = cls_session->dd_data;
|
|
|
|
ddb_entry = sess->dd_data;
|
|
|
|
ha = ddb_entry->ha;
|
|
|
|
if (!iscsi_is_session_online(cls_session)) {
|
|
|
|
if (ddb_entry->fw_ddb_device_state == DDB_DS_SESSION_ACTIVE) {
|
|
|
|
ql4_printk(KERN_INFO, ha, "scsi%ld: %s: ddb[%d]"
|
|
|
|
" unblock session\n", ha->host_no, __func__,
|
|
|
|
ddb_entry->fw_ddb_index);
|
|
|
|
iscsi_unblock_session(ddb_entry->sess);
|
|
|
|
} else {
|
|
|
|
/* Trigger relogin */
|
2011-12-02 04:38:41 +01:00
|
|
|
if (ddb_entry->ddb_type == FLASH_DDB) {
|
2013-07-08 14:33:05 +02:00
|
|
|
if (!(test_bit(DF_RELOGIN, &ddb_entry->flags) ||
|
|
|
|
test_bit(DF_DISABLE_RELOGIN,
|
|
|
|
&ddb_entry->flags)))
|
2011-12-02 04:38:41 +01:00
|
|
|
qla4xxx_arm_relogin_timer(ddb_entry);
|
|
|
|
} else
|
|
|
|
iscsi_session_failure(cls_session->dd_data,
|
|
|
|
ISCSI_ERR_CONN_FAILED);
|
2011-03-21 11:34:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-02 04:38:41 +01:00
|
|
|
int qla4xxx_unblock_flash_ddb(struct iscsi_cls_session *cls_session)
|
|
|
|
{
|
|
|
|
struct iscsi_session *sess;
|
|
|
|
struct ddb_entry *ddb_entry;
|
|
|
|
struct scsi_qla_host *ha;
|
|
|
|
|
|
|
|
sess = cls_session->dd_data;
|
|
|
|
ddb_entry = sess->dd_data;
|
|
|
|
ha = ddb_entry->ha;
|
|
|
|
ql4_printk(KERN_INFO, ha, "scsi%ld: %s: ddb[%d]"
|
|
|
|
" unblock session\n", ha->host_no, __func__,
|
|
|
|
ddb_entry->fw_ddb_index);
|
|
|
|
|
|
|
|
iscsi_unblock_session(ddb_entry->sess);
|
|
|
|
|
|
|
|
/* Start scan target */
|
|
|
|
if (test_bit(AF_ONLINE, &ha->flags)) {
|
|
|
|
ql4_printk(KERN_INFO, ha, "scsi%ld: %s: ddb[%d]"
|
|
|
|
" start scan\n", ha->host_no, __func__,
|
|
|
|
ddb_entry->fw_ddb_index);
|
|
|
|
scsi_queue_work(ha->host, &ddb_entry->sess->scan_work);
|
|
|
|
}
|
|
|
|
return QLA_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
int qla4xxx_unblock_ddb(struct iscsi_cls_session *cls_session)
|
|
|
|
{
|
|
|
|
struct iscsi_session *sess;
|
|
|
|
struct ddb_entry *ddb_entry;
|
|
|
|
struct scsi_qla_host *ha;
|
2012-08-07 13:57:15 +02:00
|
|
|
int status = QLA_SUCCESS;
|
2011-12-02 04:38:41 +01:00
|
|
|
|
|
|
|
sess = cls_session->dd_data;
|
|
|
|
ddb_entry = sess->dd_data;
|
|
|
|
ha = ddb_entry->ha;
|
|
|
|
ql4_printk(KERN_INFO, ha, "scsi%ld: %s: ddb[%d]"
|
|
|
|
" unblock user space session\n", ha->host_no, __func__,
|
|
|
|
ddb_entry->fw_ddb_index);
|
|
|
|
|
2012-08-07 13:57:15 +02:00
|
|
|
if (!iscsi_is_session_online(cls_session)) {
|
|
|
|
iscsi_conn_start(ddb_entry->conn);
|
|
|
|
iscsi_conn_login_event(ddb_entry->conn,
|
|
|
|
ISCSI_CONN_STATE_LOGGED_IN);
|
|
|
|
} else {
|
|
|
|
ql4_printk(KERN_INFO, ha,
|
|
|
|
"scsi%ld: %s: ddb[%d] session [%d] already logged in\n",
|
|
|
|
ha->host_no, __func__, ddb_entry->fw_ddb_index,
|
|
|
|
cls_session->sid);
|
|
|
|
status = QLA_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
return status;
|
2011-12-02 04:38:41 +01:00
|
|
|
}
|
|
|
|
|
2011-07-25 20:48:53 +02:00
|
|
|
static void qla4xxx_relogin_all_devices(struct scsi_qla_host *ha)
|
|
|
|
{
|
|
|
|
iscsi_host_for_each_session(ha->host, qla4xxx_relogin_devices);
|
|
|
|
}
|
|
|
|
|
2011-12-02 04:38:41 +01:00
|
|
|
static void qla4xxx_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
|
|
|
|
{
|
|
|
|
uint16_t relogin_timer;
|
|
|
|
struct iscsi_session *sess;
|
|
|
|
struct ddb_entry *ddb_entry;
|
|
|
|
struct scsi_qla_host *ha;
|
|
|
|
|
|
|
|
sess = cls_sess->dd_data;
|
|
|
|
ddb_entry = sess->dd_data;
|
|
|
|
ha = ddb_entry->ha;
|
|
|
|
|
|
|
|
relogin_timer = max(ddb_entry->default_relogin_timeout,
|
|
|
|
(uint16_t)RELOGIN_TOV);
|
|
|
|
atomic_set(&ddb_entry->relogin_timer, relogin_timer);
|
|
|
|
|
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha,
|
|
|
|
"scsi%ld: Relogin index [%d]. TOV=%d\n", ha->host_no,
|
|
|
|
ddb_entry->fw_ddb_index, relogin_timer));
|
|
|
|
|
|
|
|
qla4xxx_login_flash_ddb(cls_sess);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void qla4xxx_dpc_relogin(struct iscsi_cls_session *cls_sess)
|
|
|
|
{
|
|
|
|
struct iscsi_session *sess;
|
|
|
|
struct ddb_entry *ddb_entry;
|
|
|
|
struct scsi_qla_host *ha;
|
|
|
|
|
|
|
|
sess = cls_sess->dd_data;
|
|
|
|
ddb_entry = sess->dd_data;
|
|
|
|
ha = ddb_entry->ha;
|
|
|
|
|
|
|
|
if (!(ddb_entry->ddb_type == FLASH_DDB))
|
|
|
|
return;
|
|
|
|
|
2013-07-08 14:33:05 +02:00
|
|
|
if (test_bit(DF_DISABLE_RELOGIN, &ddb_entry->flags))
|
|
|
|
return;
|
|
|
|
|
2011-12-02 04:38:41 +01:00
|
|
|
if (test_and_clear_bit(DF_RELOGIN, &ddb_entry->flags) &&
|
|
|
|
!iscsi_is_session_online(cls_sess)) {
|
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha,
|
|
|
|
"relogin issued\n"));
|
|
|
|
qla4xxx_relogin_flash_ddb(cls_sess);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-28 12:23:44 +02:00
|
|
|
void qla4xxx_wake_dpc(struct scsi_qla_host *ha)
|
|
|
|
{
|
2011-05-18 08:17:09 +02:00
|
|
|
if (ha->dpc_thread)
|
2010-07-28 12:23:44 +02:00
|
|
|
queue_work(ha->dpc_thread, &ha->dpc_work);
|
|
|
|
}
|
|
|
|
|
2011-08-29 20:13:02 +02:00
|
|
|
static struct qla4_work_evt *
|
|
|
|
qla4xxx_alloc_work(struct scsi_qla_host *ha, uint32_t data_size,
|
|
|
|
enum qla4_work_type type)
|
|
|
|
{
|
|
|
|
struct qla4_work_evt *e;
|
|
|
|
uint32_t size = sizeof(struct qla4_work_evt) + data_size;
|
|
|
|
|
|
|
|
e = kzalloc(size, GFP_ATOMIC);
|
|
|
|
if (!e)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
INIT_LIST_HEAD(&e->list);
|
|
|
|
e->type = type;
|
|
|
|
return e;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void qla4xxx_post_work(struct scsi_qla_host *ha,
|
|
|
|
struct qla4_work_evt *e)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&ha->work_lock, flags);
|
|
|
|
list_add_tail(&e->list, &ha->work_list);
|
|
|
|
spin_unlock_irqrestore(&ha->work_lock, flags);
|
|
|
|
qla4xxx_wake_dpc(ha);
|
|
|
|
}
|
|
|
|
|
|
|
|
int qla4xxx_post_aen_work(struct scsi_qla_host *ha,
|
|
|
|
enum iscsi_host_event_code aen_code,
|
|
|
|
uint32_t data_size, uint8_t *data)
|
|
|
|
{
|
|
|
|
struct qla4_work_evt *e;
|
|
|
|
|
|
|
|
e = qla4xxx_alloc_work(ha, data_size, QLA4_EVENT_AEN);
|
|
|
|
if (!e)
|
|
|
|
return QLA_ERROR;
|
|
|
|
|
|
|
|
e->u.aen.code = aen_code;
|
|
|
|
e->u.aen.data_size = data_size;
|
|
|
|
memcpy(e->u.aen.data, data, data_size);
|
|
|
|
|
|
|
|
qla4xxx_post_work(ha, e);
|
|
|
|
|
|
|
|
return QLA_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-02-13 14:00:49 +01:00
|
|
|
int qla4xxx_post_ping_evt_work(struct scsi_qla_host *ha,
|
|
|
|
uint32_t status, uint32_t pid,
|
|
|
|
uint32_t data_size, uint8_t *data)
|
|
|
|
{
|
|
|
|
struct qla4_work_evt *e;
|
|
|
|
|
|
|
|
e = qla4xxx_alloc_work(ha, data_size, QLA4_EVENT_PING_STATUS);
|
|
|
|
if (!e)
|
|
|
|
return QLA_ERROR;
|
|
|
|
|
|
|
|
e->u.ping.status = status;
|
|
|
|
e->u.ping.pid = pid;
|
|
|
|
e->u.ping.data_size = data_size;
|
|
|
|
memcpy(e->u.ping.data, data, data_size);
|
|
|
|
|
|
|
|
qla4xxx_post_work(ha, e);
|
|
|
|
|
|
|
|
return QLA_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-02-27 12:08:56 +01:00
|
|
|
static void qla4xxx_do_work(struct scsi_qla_host *ha)
|
2011-08-29 20:13:02 +02:00
|
|
|
{
|
|
|
|
struct qla4_work_evt *e, *tmp;
|
|
|
|
unsigned long flags;
|
|
|
|
LIST_HEAD(work);
|
|
|
|
|
|
|
|
spin_lock_irqsave(&ha->work_lock, flags);
|
|
|
|
list_splice_init(&ha->work_list, &work);
|
|
|
|
spin_unlock_irqrestore(&ha->work_lock, flags);
|
|
|
|
|
|
|
|
list_for_each_entry_safe(e, tmp, &work, list) {
|
|
|
|
list_del_init(&e->list);
|
|
|
|
|
|
|
|
switch (e->type) {
|
|
|
|
case QLA4_EVENT_AEN:
|
|
|
|
iscsi_post_host_event(ha->host_no,
|
|
|
|
&qla4xxx_iscsi_transport,
|
|
|
|
e->u.aen.code,
|
|
|
|
e->u.aen.data_size,
|
|
|
|
e->u.aen.data);
|
|
|
|
break;
|
2012-02-13 14:00:49 +01:00
|
|
|
case QLA4_EVENT_PING_STATUS:
|
|
|
|
iscsi_ping_comp_event(ha->host_no,
|
|
|
|
&qla4xxx_iscsi_transport,
|
|
|
|
e->u.ping.status,
|
|
|
|
e->u.ping.pid,
|
|
|
|
e->u.ping.data_size,
|
|
|
|
e->u.ping.data);
|
|
|
|
break;
|
2011-08-29 20:13:02 +02:00
|
|
|
default:
|
|
|
|
ql4_printk(KERN_WARNING, ha, "event type: 0x%x not "
|
|
|
|
"supported", e->type);
|
|
|
|
}
|
|
|
|
kfree(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-19 19:28:00 +02:00
|
|
|
/**
|
|
|
|
* qla4xxx_do_dpc - dpc routine
|
|
|
|
* @data: in our case pointer to adapter structure
|
|
|
|
*
|
|
|
|
* This routine is a task that is schedule by the interrupt handler
|
|
|
|
* to perform the background processing for interrupts. We put it
|
|
|
|
* on a task queue that is consumed whenever the scheduler runs; that's
|
|
|
|
* so you can do anything (i.e. put the process to sleep etc). In fact,
|
|
|
|
* the mid-level tries to sleep when it reaches the driver threshold
|
|
|
|
* "host->can_queue". This can cause a panic if we were in our interrupt code.
|
|
|
|
**/
|
2006-11-22 15:57:56 +01:00
|
|
|
static void qla4xxx_do_dpc(struct work_struct *work)
|
2006-09-19 19:28:00 +02:00
|
|
|
{
|
2006-11-22 15:57:56 +01:00
|
|
|
struct scsi_qla_host *ha =
|
|
|
|
container_of(work, struct scsi_qla_host, dpc_work);
|
2007-01-22 21:26:11 +01:00
|
|
|
int status = QLA_ERROR;
|
2006-09-19 19:28:00 +02:00
|
|
|
|
2013-12-16 12:49:51 +01:00
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha,
|
|
|
|
"scsi%ld: %s: DPC handler waking up. flags = 0x%08lx, dpc_flags = 0x%08lx\n",
|
|
|
|
ha->host_no, __func__, ha->flags, ha->dpc_flags));
|
2006-09-19 19:28:00 +02:00
|
|
|
|
|
|
|
/* Initialization not yet finished. Don't do anything yet. */
|
|
|
|
if (!test_bit(AF_INIT_DONE, &ha->flags))
|
2011-05-18 08:17:09 +02:00
|
|
|
return;
|
2006-09-19 19:28:00 +02:00
|
|
|
|
2010-07-30 11:08:47 +02:00
|
|
|
if (test_bit(AF_EEH_BUSY, &ha->flags)) {
|
|
|
|
DEBUG2(printk(KERN_INFO "scsi%ld: %s: flags = %lx\n",
|
|
|
|
ha->host_no, __func__, ha->flags));
|
2011-05-18 08:17:09 +02:00
|
|
|
return;
|
2010-07-30 11:08:47 +02:00
|
|
|
}
|
|
|
|
|
2011-08-29 20:13:02 +02:00
|
|
|
/* post events to application */
|
|
|
|
qla4xxx_do_work(ha);
|
|
|
|
|
2012-08-22 13:55:08 +02:00
|
|
|
if (is_qla80XX(ha)) {
|
2010-07-28 12:23:44 +02:00
|
|
|
if (test_bit(DPC_HA_UNRECOVERABLE, &ha->dpc_flags)) {
|
2013-08-16 13:03:02 +02:00
|
|
|
if (is_qla8032(ha) || is_qla8042(ha)) {
|
2012-09-20 13:35:12 +02:00
|
|
|
ql4_printk(KERN_INFO, ha, "%s: disabling pause transmit on port 0 & 1.\n",
|
|
|
|
__func__);
|
|
|
|
/* disable pause frame for ISP83xx */
|
|
|
|
qla4_83xx_disable_pause(ha);
|
|
|
|
}
|
|
|
|
|
2012-08-22 13:55:04 +02:00
|
|
|
ha->isp_ops->idc_lock(ha);
|
|
|
|
qla4_8xxx_wr_direct(ha, QLA8XXX_CRB_DEV_STATE,
|
|
|
|
QLA8XXX_DEV_FAILED);
|
|
|
|
ha->isp_ops->idc_unlock(ha);
|
2010-07-28 12:23:44 +02:00
|
|
|
ql4_printk(KERN_INFO, ha, "HW State: FAILED\n");
|
|
|
|
qla4_8xxx_device_state_handler(ha);
|
|
|
|
}
|
2012-09-20 13:35:10 +02:00
|
|
|
|
2013-08-16 13:03:03 +02:00
|
|
|
if (test_bit(DPC_POST_IDC_ACK, &ha->dpc_flags)) {
|
|
|
|
if (is_qla8042(ha)) {
|
|
|
|
if (ha->idc_info.info2 &
|
|
|
|
ENABLE_INTERNAL_LOOPBACK) {
|
|
|
|
ql4_printk(KERN_INFO, ha, "%s: Disabling ACB\n",
|
|
|
|
__func__);
|
|
|
|
status = qla4_84xx_config_acb(ha,
|
|
|
|
ACB_CONFIG_DISABLE);
|
|
|
|
if (status != QLA_SUCCESS) {
|
|
|
|
ql4_printk(KERN_INFO, ha, "%s: ACB config failed\n",
|
|
|
|
__func__);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-09-20 13:35:10 +02:00
|
|
|
qla4_83xx_post_idc_ack(ha);
|
2013-08-16 13:03:03 +02:00
|
|
|
clear_bit(DPC_POST_IDC_ACK, &ha->dpc_flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (is_qla8042(ha) &&
|
|
|
|
test_bit(DPC_RESTORE_ACB, &ha->dpc_flags)) {
|
|
|
|
ql4_printk(KERN_INFO, ha, "%s: Restoring ACB\n",
|
|
|
|
__func__);
|
|
|
|
if (qla4_84xx_config_acb(ha, ACB_CONFIG_SET) !=
|
|
|
|
QLA_SUCCESS) {
|
|
|
|
ql4_printk(KERN_INFO, ha, "%s: ACB config failed ",
|
|
|
|
__func__);
|
|
|
|
}
|
|
|
|
clear_bit(DPC_RESTORE_ACB, &ha->dpc_flags);
|
|
|
|
}
|
2012-09-20 13:35:10 +02:00
|
|
|
|
2010-07-28 12:23:44 +02:00
|
|
|
if (test_and_clear_bit(DPC_HA_NEED_QUIESCENT, &ha->dpc_flags)) {
|
|
|
|
qla4_8xxx_need_qsnt_handler(ha);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!test_bit(DPC_RESET_ACTIVE, &ha->dpc_flags) &&
|
|
|
|
(test_bit(DPC_RESET_HA, &ha->dpc_flags) ||
|
2006-09-19 19:28:00 +02:00
|
|
|
test_bit(DPC_RESET_HA_INTR, &ha->dpc_flags) ||
|
2010-07-28 12:23:44 +02:00
|
|
|
test_bit(DPC_RESET_HA_FW_CONTEXT, &ha->dpc_flags))) {
|
2012-08-22 13:55:08 +02:00
|
|
|
if ((is_qla8022(ha) && ql4xdontresethba) ||
|
2013-08-16 13:03:02 +02:00
|
|
|
((is_qla8032(ha) || is_qla8042(ha)) &&
|
|
|
|
qla4_83xx_idc_dontreset(ha))) {
|
2010-07-28 12:23:44 +02:00
|
|
|
DEBUG2(printk("scsi%ld: %s: Don't Reset HBA\n",
|
|
|
|
ha->host_no, __func__));
|
|
|
|
clear_bit(DPC_RESET_HA, &ha->dpc_flags);
|
|
|
|
clear_bit(DPC_RESET_HA_INTR, &ha->dpc_flags);
|
|
|
|
clear_bit(DPC_RESET_HA_FW_CONTEXT, &ha->dpc_flags);
|
|
|
|
goto dpc_post_reset_ha;
|
|
|
|
}
|
|
|
|
if (test_bit(DPC_RESET_HA_FW_CONTEXT, &ha->dpc_flags) ||
|
|
|
|
test_bit(DPC_RESET_HA, &ha->dpc_flags))
|
|
|
|
qla4xxx_recover_adapter(ha);
|
2006-09-19 19:28:00 +02:00
|
|
|
|
2007-01-22 21:26:11 +01:00
|
|
|
if (test_bit(DPC_RESET_HA_INTR, &ha->dpc_flags)) {
|
2006-09-19 19:28:00 +02:00
|
|
|
uint8_t wait_time = RESET_INTR_TOV;
|
|
|
|
|
|
|
|
while ((readw(&ha->reg->ctrl_status) &
|
|
|
|
(CSR_SOFT_RESET | CSR_FORCE_SOFT_RESET)) != 0) {
|
|
|
|
if (--wait_time == 0)
|
|
|
|
break;
|
|
|
|
msleep(1000);
|
|
|
|
}
|
|
|
|
if (wait_time == 0)
|
|
|
|
DEBUG2(printk("scsi%ld: %s: SR|FSR "
|
|
|
|
"bit not cleared-- resetting\n",
|
|
|
|
ha->host_no, __func__));
|
2010-07-28 12:23:44 +02:00
|
|
|
qla4xxx_abort_active_cmds(ha, DID_RESET << 16);
|
2007-01-22 21:26:11 +01:00
|
|
|
if (ql4xxx_lock_drvr_wait(ha) == QLA_SUCCESS) {
|
|
|
|
qla4xxx_process_aen(ha, FLUSH_DDB_CHANGED_AENS);
|
2010-07-28 12:23:44 +02:00
|
|
|
status = qla4xxx_recover_adapter(ha);
|
2007-01-22 21:26:11 +01:00
|
|
|
}
|
|
|
|
clear_bit(DPC_RESET_HA_INTR, &ha->dpc_flags);
|
|
|
|
if (status == QLA_SUCCESS)
|
2010-07-28 12:23:44 +02:00
|
|
|
ha->isp_ops->enable_intrs(ha);
|
2006-09-19 19:28:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-28 12:23:44 +02:00
|
|
|
dpc_post_reset_ha:
|
2006-09-19 19:28:00 +02:00
|
|
|
/* ---- process AEN? --- */
|
|
|
|
if (test_and_clear_bit(DPC_AEN, &ha->dpc_flags))
|
|
|
|
qla4xxx_process_aen(ha, PROCESS_ALL_AENS);
|
|
|
|
|
|
|
|
/* ---- Get DHCP IP Address? --- */
|
|
|
|
if (test_and_clear_bit(DPC_GET_DHCP_IP_ADDR, &ha->dpc_flags))
|
|
|
|
qla4xxx_get_dhcp_ip_address(ha);
|
|
|
|
|
2011-12-02 04:38:41 +01:00
|
|
|
/* ---- relogin device? --- */
|
|
|
|
if (adapter_up(ha) &&
|
|
|
|
test_and_clear_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags)) {
|
|
|
|
iscsi_host_for_each_session(ha->host, qla4xxx_dpc_relogin);
|
|
|
|
}
|
|
|
|
|
2010-04-28 08:08:11 +02:00
|
|
|
/* ---- link change? --- */
|
2013-01-21 05:50:58 +01:00
|
|
|
if (!test_bit(AF_LOOPBACK, &ha->flags) &&
|
|
|
|
test_and_clear_bit(DPC_LINK_CHANGED, &ha->dpc_flags)) {
|
2010-04-28 08:08:11 +02:00
|
|
|
if (!test_bit(AF_LINK_UP, &ha->flags)) {
|
|
|
|
/* ---- link down? --- */
|
2011-03-21 11:34:33 +01:00
|
|
|
qla4xxx_mark_all_devices_missing(ha);
|
2010-04-28 08:08:11 +02:00
|
|
|
} else {
|
|
|
|
/* ---- link up? --- *
|
|
|
|
* F/W will auto login to all devices ONLY ONCE after
|
|
|
|
* link up during driver initialization and runtime
|
|
|
|
* fatal error recovery. Therefore, the driver must
|
|
|
|
* manually relogin to devices when recovering from
|
|
|
|
* connection failures, logouts, expired KATO, etc. */
|
2011-12-02 04:38:41 +01:00
|
|
|
if (test_and_clear_bit(AF_BUILD_DDB_LIST, &ha->flags)) {
|
|
|
|
qla4xxx_build_ddb_list(ha, ha->is_reset);
|
|
|
|
iscsi_host_for_each_session(ha->host,
|
|
|
|
qla4xxx_login_flash_ddb);
|
|
|
|
} else
|
|
|
|
qla4xxx_relogin_all_devices(ha);
|
2010-04-28 08:08:11 +02:00
|
|
|
}
|
|
|
|
}
|
2014-04-10 03:12:25 +02:00
|
|
|
if (test_and_clear_bit(DPC_SYSFS_DDB_EXPORT, &ha->dpc_flags)) {
|
|
|
|
if (qla4xxx_sysfs_ddb_export(ha))
|
|
|
|
ql4_printk(KERN_ERR, ha, "%s: Error exporting ddb to sysfs\n",
|
|
|
|
__func__);
|
|
|
|
}
|
2006-09-19 19:28:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* qla4xxx_free_adapter - release the adapter
|
|
|
|
* @ha: pointer to adapter structure
|
|
|
|
**/
|
|
|
|
static void qla4xxx_free_adapter(struct scsi_qla_host *ha)
|
|
|
|
{
|
2011-12-06 11:34:10 +01:00
|
|
|
qla4xxx_abort_active_cmds(ha, DID_NO_CONNECT << 16);
|
2006-09-19 19:28:00 +02:00
|
|
|
|
2012-11-23 12:58:38 +01:00
|
|
|
/* Turn-off interrupts on the card. */
|
|
|
|
ha->isp_ops->disable_intrs(ha);
|
2006-09-19 19:28:00 +02:00
|
|
|
|
2012-08-22 13:45:25 +02:00
|
|
|
if (is_qla40XX(ha)) {
|
|
|
|
writel(set_rmask(CSR_SCSI_PROCESSOR_INTR),
|
|
|
|
&ha->reg->ctrl_status);
|
|
|
|
readl(&ha->reg->ctrl_status);
|
|
|
|
} else if (is_qla8022(ha)) {
|
2012-08-22 13:55:00 +02:00
|
|
|
writel(0, &ha->qla4_82xx_reg->host_int);
|
|
|
|
readl(&ha->qla4_82xx_reg->host_int);
|
2013-08-16 13:03:02 +02:00
|
|
|
} else if (is_qla8032(ha) || is_qla8042(ha)) {
|
2012-09-20 13:35:03 +02:00
|
|
|
writel(0, &ha->qla4_83xx_reg->risc_intr);
|
|
|
|
readl(&ha->qla4_83xx_reg->risc_intr);
|
2012-08-22 13:45:25 +02:00
|
|
|
}
|
|
|
|
|
2010-07-28 12:23:44 +02:00
|
|
|
/* Remove timer thread, if present */
|
|
|
|
if (ha->timer_active)
|
|
|
|
qla4xxx_stop_timer(ha);
|
|
|
|
|
2006-09-19 19:28:00 +02:00
|
|
|
/* Kill the kernel thread for this host */
|
|
|
|
if (ha->dpc_thread)
|
|
|
|
destroy_workqueue(ha->dpc_thread);
|
|
|
|
|
2011-07-25 20:48:53 +02:00
|
|
|
/* Kill the kernel thread for this host */
|
|
|
|
if (ha->task_wq)
|
|
|
|
destroy_workqueue(ha->task_wq);
|
|
|
|
|
2010-07-28 12:23:44 +02:00
|
|
|
/* Put firmware in known state */
|
|
|
|
ha->isp_ops->reset_firmware(ha);
|
2006-09-19 19:28:00 +02:00
|
|
|
|
2012-08-22 13:55:08 +02:00
|
|
|
if (is_qla80XX(ha)) {
|
2012-08-22 13:55:04 +02:00
|
|
|
ha->isp_ops->idc_lock(ha);
|
2010-07-28 12:23:44 +02:00
|
|
|
qla4_8xxx_clear_drv_active(ha);
|
2012-08-22 13:55:04 +02:00
|
|
|
ha->isp_ops->idc_unlock(ha);
|
2010-07-28 12:23:44 +02:00
|
|
|
}
|
2006-09-19 19:28:00 +02:00
|
|
|
|
|
|
|
/* Detach interrupts */
|
2012-11-23 12:58:38 +01:00
|
|
|
qla4xxx_free_irqs(ha);
|
2006-09-19 19:28:00 +02:00
|
|
|
|
2007-05-24 03:03:32 +02:00
|
|
|
/* free extra memory */
|
|
|
|
qla4xxx_mem_free(ha);
|
2010-07-28 12:23:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int qla4_8xxx_iospace_config(struct scsi_qla_host *ha)
|
|
|
|
{
|
|
|
|
int status = 0;
|
|
|
|
unsigned long mem_base, mem_len, db_base, db_len;
|
|
|
|
struct pci_dev *pdev = ha->pdev;
|
|
|
|
|
|
|
|
status = pci_request_regions(pdev, DRIVER_NAME);
|
|
|
|
if (status) {
|
|
|
|
printk(KERN_WARNING
|
|
|
|
"scsi(%ld) Failed to reserve PIO regions (%s) "
|
|
|
|
"status=%d\n", ha->host_no, pci_name(pdev), status);
|
|
|
|
goto iospace_error_exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEBUG2(printk(KERN_INFO "%s: revision-id=%d\n",
|
2012-03-14 20:04:30 +01:00
|
|
|
__func__, pdev->revision));
|
|
|
|
ha->revision_id = pdev->revision;
|
2007-05-24 03:03:32 +02:00
|
|
|
|
2010-07-28 12:23:44 +02:00
|
|
|
/* remap phys address */
|
|
|
|
mem_base = pci_resource_start(pdev, 0); /* 0 is for BAR 0 */
|
|
|
|
mem_len = pci_resource_len(pdev, 0);
|
|
|
|
DEBUG2(printk(KERN_INFO "%s: ioremap from %lx a size of %lx\n",
|
|
|
|
__func__, mem_base, mem_len));
|
2006-09-19 19:28:00 +02:00
|
|
|
|
2010-07-28 12:23:44 +02:00
|
|
|
/* mapping of pcibase pointer */
|
|
|
|
ha->nx_pcibase = (unsigned long)ioremap(mem_base, mem_len);
|
|
|
|
if (!ha->nx_pcibase) {
|
|
|
|
printk(KERN_ERR
|
|
|
|
"cannot remap MMIO (%s), aborting\n", pci_name(pdev));
|
|
|
|
pci_release_regions(ha->pdev);
|
|
|
|
goto iospace_error_exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Mapping of IO base pointer, door bell read and write pointer */
|
|
|
|
|
|
|
|
/* mapping of IO base pointer */
|
2012-08-22 13:55:08 +02:00
|
|
|
if (is_qla8022(ha)) {
|
|
|
|
ha->qla4_82xx_reg = (struct device_reg_82xx __iomem *)
|
|
|
|
((uint8_t *)ha->nx_pcibase + 0xbc000 +
|
|
|
|
(ha->pdev->devfn << 11));
|
|
|
|
ha->nx_db_wr_ptr = (ha->pdev->devfn == 4 ? QLA82XX_CAM_RAM_DB1 :
|
|
|
|
QLA82XX_CAM_RAM_DB2);
|
2013-08-16 13:03:02 +02:00
|
|
|
} else if (is_qla8032(ha) || is_qla8042(ha)) {
|
2012-08-22 13:55:08 +02:00
|
|
|
ha->qla4_83xx_reg = (struct device_reg_83xx __iomem *)
|
|
|
|
((uint8_t *)ha->nx_pcibase);
|
|
|
|
}
|
2010-07-28 12:23:44 +02:00
|
|
|
|
|
|
|
db_base = pci_resource_start(pdev, 4); /* doorbell is on bar 4 */
|
|
|
|
db_len = pci_resource_len(pdev, 4);
|
|
|
|
|
2010-10-07 07:50:29 +02:00
|
|
|
return 0;
|
2010-07-28 12:23:44 +02:00
|
|
|
iospace_error_exit:
|
|
|
|
return -ENOMEM;
|
2006-09-19 19:28:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***
|
|
|
|
* qla4xxx_iospace_config - maps registers
|
|
|
|
* @ha: pointer to adapter structure
|
|
|
|
*
|
|
|
|
* This routines maps HBA's registers from the pci address space
|
|
|
|
* into the kernel virtual address space for memory mapped i/o.
|
|
|
|
**/
|
2010-07-28 12:23:44 +02:00
|
|
|
int qla4xxx_iospace_config(struct scsi_qla_host *ha)
|
2006-09-19 19:28:00 +02:00
|
|
|
{
|
|
|
|
unsigned long pio, pio_len, pio_flags;
|
|
|
|
unsigned long mmio, mmio_len, mmio_flags;
|
|
|
|
|
|
|
|
pio = pci_resource_start(ha->pdev, 0);
|
|
|
|
pio_len = pci_resource_len(ha->pdev, 0);
|
|
|
|
pio_flags = pci_resource_flags(ha->pdev, 0);
|
|
|
|
if (pio_flags & IORESOURCE_IO) {
|
|
|
|
if (pio_len < MIN_IOBASE_LEN) {
|
2010-07-10 11:21:02 +02:00
|
|
|
ql4_printk(KERN_WARNING, ha,
|
2006-09-19 19:28:00 +02:00
|
|
|
"Invalid PCI I/O region size\n");
|
|
|
|
pio = 0;
|
|
|
|
}
|
|
|
|
} else {
|
2010-07-10 11:21:02 +02:00
|
|
|
ql4_printk(KERN_WARNING, ha, "region #0 not a PIO resource\n");
|
2006-09-19 19:28:00 +02:00
|
|
|
pio = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Use MMIO operations for all accesses. */
|
|
|
|
mmio = pci_resource_start(ha->pdev, 1);
|
|
|
|
mmio_len = pci_resource_len(ha->pdev, 1);
|
|
|
|
mmio_flags = pci_resource_flags(ha->pdev, 1);
|
|
|
|
|
|
|
|
if (!(mmio_flags & IORESOURCE_MEM)) {
|
2010-07-10 11:21:02 +02:00
|
|
|
ql4_printk(KERN_ERR, ha,
|
|
|
|
"region #0 not an MMIO resource, aborting\n");
|
2006-09-19 19:28:00 +02:00
|
|
|
|
|
|
|
goto iospace_error_exit;
|
|
|
|
}
|
2010-07-10 11:21:02 +02:00
|
|
|
|
2006-09-19 19:28:00 +02:00
|
|
|
if (mmio_len < MIN_IOBASE_LEN) {
|
2010-07-10 11:21:02 +02:00
|
|
|
ql4_printk(KERN_ERR, ha,
|
|
|
|
"Invalid PCI mem region size, aborting\n");
|
2006-09-19 19:28:00 +02:00
|
|
|
goto iospace_error_exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pci_request_regions(ha->pdev, DRIVER_NAME)) {
|
2010-07-10 11:21:02 +02:00
|
|
|
ql4_printk(KERN_WARNING, ha,
|
|
|
|
"Failed to reserve PIO/MMIO regions\n");
|
2006-09-19 19:28:00 +02:00
|
|
|
|
|
|
|
goto iospace_error_exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
ha->pio_address = pio;
|
|
|
|
ha->pio_length = pio_len;
|
|
|
|
ha->reg = ioremap(mmio, MIN_IOBASE_LEN);
|
|
|
|
if (!ha->reg) {
|
2010-07-10 11:21:02 +02:00
|
|
|
ql4_printk(KERN_ERR, ha,
|
|
|
|
"cannot remap MMIO, aborting\n");
|
2006-09-19 19:28:00 +02:00
|
|
|
|
|
|
|
goto iospace_error_exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
iospace_error_exit:
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2010-07-28 12:23:44 +02:00
|
|
|
static struct isp_operations qla4xxx_isp_ops = {
|
|
|
|
.iospace_config = qla4xxx_iospace_config,
|
|
|
|
.pci_config = qla4xxx_pci_config,
|
|
|
|
.disable_intrs = qla4xxx_disable_intrs,
|
|
|
|
.enable_intrs = qla4xxx_enable_intrs,
|
|
|
|
.start_firmware = qla4xxx_start_firmware,
|
|
|
|
.intr_handler = qla4xxx_intr_handler,
|
|
|
|
.interrupt_service_routine = qla4xxx_interrupt_service_routine,
|
|
|
|
.reset_chip = qla4xxx_soft_reset,
|
|
|
|
.reset_firmware = qla4xxx_hw_reset,
|
|
|
|
.queue_iocb = qla4xxx_queue_iocb,
|
|
|
|
.complete_iocb = qla4xxx_complete_iocb,
|
|
|
|
.rd_shdw_req_q_out = qla4xxx_rd_shdw_req_q_out,
|
|
|
|
.rd_shdw_rsp_q_in = qla4xxx_rd_shdw_rsp_q_in,
|
|
|
|
.get_sys_info = qla4xxx_get_sys_info,
|
2012-08-22 13:55:04 +02:00
|
|
|
.queue_mailbox_command = qla4xxx_queue_mbox_cmd,
|
|
|
|
.process_mailbox_interrupt = qla4xxx_process_mbox_intr,
|
2010-07-28 12:23:44 +02:00
|
|
|
};
|
|
|
|
|
2012-08-22 13:55:00 +02:00
|
|
|
static struct isp_operations qla4_82xx_isp_ops = {
|
2010-07-28 12:23:44 +02:00
|
|
|
.iospace_config = qla4_8xxx_iospace_config,
|
|
|
|
.pci_config = qla4_8xxx_pci_config,
|
2012-08-22 13:54:59 +02:00
|
|
|
.disable_intrs = qla4_82xx_disable_intrs,
|
|
|
|
.enable_intrs = qla4_82xx_enable_intrs,
|
2010-07-28 12:23:44 +02:00
|
|
|
.start_firmware = qla4_8xxx_load_risc,
|
2012-08-22 13:55:04 +02:00
|
|
|
.restart_firmware = qla4_82xx_try_start_fw,
|
2012-08-22 13:54:59 +02:00
|
|
|
.intr_handler = qla4_82xx_intr_handler,
|
|
|
|
.interrupt_service_routine = qla4_82xx_interrupt_service_routine,
|
2012-08-22 13:55:04 +02:00
|
|
|
.need_reset = qla4_8xxx_need_reset,
|
2012-08-22 13:54:59 +02:00
|
|
|
.reset_chip = qla4_82xx_isp_reset,
|
2010-07-28 12:23:44 +02:00
|
|
|
.reset_firmware = qla4_8xxx_stop_firmware,
|
2012-08-22 13:54:59 +02:00
|
|
|
.queue_iocb = qla4_82xx_queue_iocb,
|
|
|
|
.complete_iocb = qla4_82xx_complete_iocb,
|
|
|
|
.rd_shdw_req_q_out = qla4_82xx_rd_shdw_req_q_out,
|
|
|
|
.rd_shdw_rsp_q_in = qla4_82xx_rd_shdw_rsp_q_in,
|
2010-07-28 12:23:44 +02:00
|
|
|
.get_sys_info = qla4_8xxx_get_sys_info,
|
2012-08-22 13:55:04 +02:00
|
|
|
.rd_reg_direct = qla4_82xx_rd_32,
|
|
|
|
.wr_reg_direct = qla4_82xx_wr_32,
|
|
|
|
.rd_reg_indirect = qla4_82xx_md_rd_32,
|
|
|
|
.wr_reg_indirect = qla4_82xx_md_wr_32,
|
|
|
|
.idc_lock = qla4_82xx_idc_lock,
|
|
|
|
.idc_unlock = qla4_82xx_idc_unlock,
|
|
|
|
.rom_lock_recovery = qla4_82xx_rom_lock_recovery,
|
|
|
|
.queue_mailbox_command = qla4_82xx_queue_mbox_cmd,
|
|
|
|
.process_mailbox_interrupt = qla4_82xx_process_mbox_intr,
|
2010-07-28 12:23:44 +02:00
|
|
|
};
|
|
|
|
|
2012-08-22 13:55:08 +02:00
|
|
|
static struct isp_operations qla4_83xx_isp_ops = {
|
|
|
|
.iospace_config = qla4_8xxx_iospace_config,
|
|
|
|
.pci_config = qla4_8xxx_pci_config,
|
|
|
|
.disable_intrs = qla4_83xx_disable_intrs,
|
|
|
|
.enable_intrs = qla4_83xx_enable_intrs,
|
|
|
|
.start_firmware = qla4_8xxx_load_risc,
|
|
|
|
.restart_firmware = qla4_83xx_start_firmware,
|
|
|
|
.intr_handler = qla4_83xx_intr_handler,
|
|
|
|
.interrupt_service_routine = qla4_83xx_interrupt_service_routine,
|
|
|
|
.need_reset = qla4_8xxx_need_reset,
|
|
|
|
.reset_chip = qla4_83xx_isp_reset,
|
|
|
|
.reset_firmware = qla4_8xxx_stop_firmware,
|
|
|
|
.queue_iocb = qla4_83xx_queue_iocb,
|
|
|
|
.complete_iocb = qla4_83xx_complete_iocb,
|
2013-03-07 11:43:13 +01:00
|
|
|
.rd_shdw_req_q_out = qla4xxx_rd_shdw_req_q_out,
|
|
|
|
.rd_shdw_rsp_q_in = qla4xxx_rd_shdw_rsp_q_in,
|
2012-08-22 13:55:08 +02:00
|
|
|
.get_sys_info = qla4_8xxx_get_sys_info,
|
|
|
|
.rd_reg_direct = qla4_83xx_rd_reg,
|
|
|
|
.wr_reg_direct = qla4_83xx_wr_reg,
|
|
|
|
.rd_reg_indirect = qla4_83xx_rd_reg_indirect,
|
|
|
|
.wr_reg_indirect = qla4_83xx_wr_reg_indirect,
|
|
|
|
.idc_lock = qla4_83xx_drv_lock,
|
|
|
|
.idc_unlock = qla4_83xx_drv_unlock,
|
|
|
|
.rom_lock_recovery = qla4_83xx_rom_lock_recovery,
|
|
|
|
.queue_mailbox_command = qla4_83xx_queue_mbox_cmd,
|
|
|
|
.process_mailbox_interrupt = qla4_83xx_process_mbox_intr,
|
2010-07-28 12:23:44 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
uint16_t qla4xxx_rd_shdw_req_q_out(struct scsi_qla_host *ha)
|
|
|
|
{
|
|
|
|
return (uint16_t)le32_to_cpu(ha->shadow_regs->req_q_out);
|
|
|
|
}
|
|
|
|
|
2012-08-22 13:54:59 +02:00
|
|
|
uint16_t qla4_82xx_rd_shdw_req_q_out(struct scsi_qla_host *ha)
|
2010-07-28 12:23:44 +02:00
|
|
|
{
|
2012-08-22 13:55:00 +02:00
|
|
|
return (uint16_t)le32_to_cpu(readl(&ha->qla4_82xx_reg->req_q_out));
|
2010-07-28 12:23:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
uint16_t qla4xxx_rd_shdw_rsp_q_in(struct scsi_qla_host *ha)
|
|
|
|
{
|
|
|
|
return (uint16_t)le32_to_cpu(ha->shadow_regs->rsp_q_in);
|
|
|
|
}
|
|
|
|
|
2012-08-22 13:54:59 +02:00
|
|
|
uint16_t qla4_82xx_rd_shdw_rsp_q_in(struct scsi_qla_host *ha)
|
2010-07-28 12:23:44 +02:00
|
|
|
{
|
2012-08-22 13:55:00 +02:00
|
|
|
return (uint16_t)le32_to_cpu(readl(&ha->qla4_82xx_reg->rsp_q_in));
|
2010-07-28 12:23:44 +02:00
|
|
|
}
|
|
|
|
|
2011-07-25 20:48:55 +02:00
|
|
|
static ssize_t qla4xxx_show_boot_eth_info(void *data, int type, char *buf)
|
|
|
|
{
|
|
|
|
struct scsi_qla_host *ha = data;
|
|
|
|
char *str = buf;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case ISCSI_BOOT_ETH_FLAGS:
|
|
|
|
rc = sprintf(str, "%d\n", SYSFS_FLAG_FW_SEL_BOOT);
|
|
|
|
break;
|
|
|
|
case ISCSI_BOOT_ETH_INDEX:
|
|
|
|
rc = sprintf(str, "0\n");
|
|
|
|
break;
|
|
|
|
case ISCSI_BOOT_ETH_MAC:
|
|
|
|
rc = sysfs_format_mac(str, ha->my_mac,
|
|
|
|
MAC_ADDR_LEN);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
rc = -ENOSYS;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-07-24 05:11:19 +02:00
|
|
|
static umode_t qla4xxx_eth_get_attr_visibility(void *data, int type)
|
2011-07-25 20:48:55 +02:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case ISCSI_BOOT_ETH_FLAGS:
|
|
|
|
case ISCSI_BOOT_ETH_MAC:
|
|
|
|
case ISCSI_BOOT_ETH_INDEX:
|
|
|
|
rc = S_IRUGO;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
rc = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t qla4xxx_show_boot_ini_info(void *data, int type, char *buf)
|
|
|
|
{
|
|
|
|
struct scsi_qla_host *ha = data;
|
|
|
|
char *str = buf;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case ISCSI_BOOT_INI_INITIATOR_NAME:
|
|
|
|
rc = sprintf(str, "%s\n", ha->name_string);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
rc = -ENOSYS;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-07-24 05:11:19 +02:00
|
|
|
static umode_t qla4xxx_ini_get_attr_visibility(void *data, int type)
|
2011-07-25 20:48:55 +02:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case ISCSI_BOOT_INI_INITIATOR_NAME:
|
|
|
|
rc = S_IRUGO;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
rc = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t
|
|
|
|
qla4xxx_show_boot_tgt_info(struct ql4_boot_session_info *boot_sess, int type,
|
|
|
|
char *buf)
|
|
|
|
{
|
|
|
|
struct ql4_conn_info *boot_conn = &boot_sess->conn_list[0];
|
|
|
|
char *str = buf;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case ISCSI_BOOT_TGT_NAME:
|
|
|
|
rc = sprintf(buf, "%s\n", (char *)&boot_sess->target_name);
|
|
|
|
break;
|
|
|
|
case ISCSI_BOOT_TGT_IP_ADDR:
|
|
|
|
if (boot_sess->conn_list[0].dest_ipaddr.ip_type == 0x1)
|
|
|
|
rc = sprintf(buf, "%pI4\n",
|
|
|
|
&boot_conn->dest_ipaddr.ip_address);
|
|
|
|
else
|
|
|
|
rc = sprintf(str, "%pI6\n",
|
|
|
|
&boot_conn->dest_ipaddr.ip_address);
|
|
|
|
break;
|
|
|
|
case ISCSI_BOOT_TGT_PORT:
|
|
|
|
rc = sprintf(str, "%d\n", boot_conn->dest_port);
|
|
|
|
break;
|
|
|
|
case ISCSI_BOOT_TGT_CHAP_NAME:
|
|
|
|
rc = sprintf(str, "%.*s\n",
|
|
|
|
boot_conn->chap.target_chap_name_length,
|
|
|
|
(char *)&boot_conn->chap.target_chap_name);
|
|
|
|
break;
|
|
|
|
case ISCSI_BOOT_TGT_CHAP_SECRET:
|
|
|
|
rc = sprintf(str, "%.*s\n",
|
|
|
|
boot_conn->chap.target_secret_length,
|
|
|
|
(char *)&boot_conn->chap.target_secret);
|
|
|
|
break;
|
|
|
|
case ISCSI_BOOT_TGT_REV_CHAP_NAME:
|
|
|
|
rc = sprintf(str, "%.*s\n",
|
|
|
|
boot_conn->chap.intr_chap_name_length,
|
|
|
|
(char *)&boot_conn->chap.intr_chap_name);
|
|
|
|
break;
|
|
|
|
case ISCSI_BOOT_TGT_REV_CHAP_SECRET:
|
|
|
|
rc = sprintf(str, "%.*s\n",
|
|
|
|
boot_conn->chap.intr_secret_length,
|
|
|
|
(char *)&boot_conn->chap.intr_secret);
|
|
|
|
break;
|
|
|
|
case ISCSI_BOOT_TGT_FLAGS:
|
|
|
|
rc = sprintf(str, "%d\n", SYSFS_FLAG_FW_SEL_BOOT);
|
|
|
|
break;
|
|
|
|
case ISCSI_BOOT_TGT_NIC_ASSOC:
|
|
|
|
rc = sprintf(str, "0\n");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
rc = -ENOSYS;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t qla4xxx_show_boot_tgt_pri_info(void *data, int type, char *buf)
|
|
|
|
{
|
|
|
|
struct scsi_qla_host *ha = data;
|
|
|
|
struct ql4_boot_session_info *boot_sess = &(ha->boot_tgt.boot_pri_sess);
|
|
|
|
|
|
|
|
return qla4xxx_show_boot_tgt_info(boot_sess, type, buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t qla4xxx_show_boot_tgt_sec_info(void *data, int type, char *buf)
|
|
|
|
{
|
|
|
|
struct scsi_qla_host *ha = data;
|
|
|
|
struct ql4_boot_session_info *boot_sess = &(ha->boot_tgt.boot_sec_sess);
|
|
|
|
|
|
|
|
return qla4xxx_show_boot_tgt_info(boot_sess, type, buf);
|
|
|
|
}
|
|
|
|
|
2011-07-24 05:11:19 +02:00
|
|
|
static umode_t qla4xxx_tgt_get_attr_visibility(void *data, int type)
|
2011-07-25 20:48:55 +02:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case ISCSI_BOOT_TGT_NAME:
|
|
|
|
case ISCSI_BOOT_TGT_IP_ADDR:
|
|
|
|
case ISCSI_BOOT_TGT_PORT:
|
|
|
|
case ISCSI_BOOT_TGT_CHAP_NAME:
|
|
|
|
case ISCSI_BOOT_TGT_CHAP_SECRET:
|
|
|
|
case ISCSI_BOOT_TGT_REV_CHAP_NAME:
|
|
|
|
case ISCSI_BOOT_TGT_REV_CHAP_SECRET:
|
|
|
|
case ISCSI_BOOT_TGT_NIC_ASSOC:
|
|
|
|
case ISCSI_BOOT_TGT_FLAGS:
|
|
|
|
rc = S_IRUGO;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
rc = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void qla4xxx_boot_release(void *data)
|
|
|
|
{
|
|
|
|
struct scsi_qla_host *ha = data;
|
|
|
|
|
|
|
|
scsi_host_put(ha->host);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int get_fw_boot_info(struct scsi_qla_host *ha, uint16_t ddb_index[])
|
|
|
|
{
|
|
|
|
dma_addr_t buf_dma;
|
|
|
|
uint32_t addr, pri_addr, sec_addr;
|
|
|
|
uint32_t offset;
|
|
|
|
uint16_t func_num;
|
|
|
|
uint8_t val;
|
|
|
|
uint8_t *buf = NULL;
|
|
|
|
size_t size = 13 * sizeof(uint8_t);
|
|
|
|
int ret = QLA_SUCCESS;
|
|
|
|
|
|
|
|
func_num = PCI_FUNC(ha->pdev->devfn);
|
|
|
|
|
2011-10-08 01:55:51 +02:00
|
|
|
ql4_printk(KERN_INFO, ha, "%s: Get FW boot info for 0x%x func %d\n",
|
|
|
|
__func__, ha->pdev->device, func_num);
|
2011-07-25 20:48:55 +02:00
|
|
|
|
2011-10-08 01:55:51 +02:00
|
|
|
if (is_qla40XX(ha)) {
|
2011-07-25 20:48:55 +02:00
|
|
|
if (func_num == 1) {
|
|
|
|
addr = NVRAM_PORT0_BOOT_MODE;
|
|
|
|
pri_addr = NVRAM_PORT0_BOOT_PRI_TGT;
|
|
|
|
sec_addr = NVRAM_PORT0_BOOT_SEC_TGT;
|
|
|
|
} else if (func_num == 3) {
|
|
|
|
addr = NVRAM_PORT1_BOOT_MODE;
|
|
|
|
pri_addr = NVRAM_PORT1_BOOT_PRI_TGT;
|
|
|
|
sec_addr = NVRAM_PORT1_BOOT_SEC_TGT;
|
|
|
|
} else {
|
|
|
|
ret = QLA_ERROR;
|
|
|
|
goto exit_boot_info;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check Boot Mode */
|
|
|
|
val = rd_nvram_byte(ha, addr);
|
|
|
|
if (!(val & 0x07)) {
|
2012-02-13 14:00:43 +01:00
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha, "%s: Adapter boot "
|
|
|
|
"options : 0x%x\n", __func__, val));
|
2011-07-25 20:48:55 +02:00
|
|
|
ret = QLA_ERROR;
|
|
|
|
goto exit_boot_info;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* get primary valid target index */
|
|
|
|
val = rd_nvram_byte(ha, pri_addr);
|
|
|
|
if (val & BIT_7)
|
|
|
|
ddb_index[0] = (val & 0x7f);
|
|
|
|
|
|
|
|
/* get secondary valid target index */
|
|
|
|
val = rd_nvram_byte(ha, sec_addr);
|
|
|
|
if (val & BIT_7)
|
|
|
|
ddb_index[1] = (val & 0x7f);
|
|
|
|
|
2013-03-07 11:43:08 +01:00
|
|
|
} else if (is_qla80XX(ha)) {
|
2011-07-25 20:48:55 +02:00
|
|
|
buf = dma_alloc_coherent(&ha->pdev->dev, size,
|
|
|
|
&buf_dma, GFP_KERNEL);
|
|
|
|
if (!buf) {
|
|
|
|
DEBUG2(ql4_printk(KERN_ERR, ha,
|
|
|
|
"%s: Unable to allocate dma buffer\n",
|
|
|
|
__func__));
|
|
|
|
ret = QLA_ERROR;
|
|
|
|
goto exit_boot_info;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ha->port_num == 0)
|
|
|
|
offset = BOOT_PARAM_OFFSET_PORT0;
|
|
|
|
else if (ha->port_num == 1)
|
|
|
|
offset = BOOT_PARAM_OFFSET_PORT1;
|
|
|
|
else {
|
|
|
|
ret = QLA_ERROR;
|
|
|
|
goto exit_boot_info_free;
|
|
|
|
}
|
|
|
|
addr = FLASH_RAW_ACCESS_ADDR + (ha->hw.flt_iscsi_param * 4) +
|
|
|
|
offset;
|
|
|
|
if (qla4xxx_get_flash(ha, buf_dma, addr,
|
|
|
|
13 * sizeof(uint8_t)) != QLA_SUCCESS) {
|
|
|
|
DEBUG2(ql4_printk(KERN_ERR, ha, "scsi%ld: %s: Get Flash"
|
2012-02-24 16:32:59 +01:00
|
|
|
" failed\n", ha->host_no, __func__));
|
2011-07-25 20:48:55 +02:00
|
|
|
ret = QLA_ERROR;
|
|
|
|
goto exit_boot_info_free;
|
|
|
|
}
|
|
|
|
/* Check Boot Mode */
|
|
|
|
if (!(buf[1] & 0x07)) {
|
2012-02-13 14:00:43 +01:00
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha, "Firmware boot options"
|
|
|
|
" : 0x%x\n", buf[1]));
|
2011-07-25 20:48:55 +02:00
|
|
|
ret = QLA_ERROR;
|
|
|
|
goto exit_boot_info_free;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* get primary valid target index */
|
|
|
|
if (buf[2] & BIT_7)
|
|
|
|
ddb_index[0] = buf[2] & 0x7f;
|
|
|
|
|
|
|
|
/* get secondary valid target index */
|
|
|
|
if (buf[11] & BIT_7)
|
|
|
|
ddb_index[1] = buf[11] & 0x7f;
|
|
|
|
} else {
|
|
|
|
ret = QLA_ERROR;
|
|
|
|
goto exit_boot_info;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha, "%s: Primary target ID %d, Secondary"
|
|
|
|
" target ID %d\n", __func__, ddb_index[0],
|
|
|
|
ddb_index[1]));
|
|
|
|
|
|
|
|
exit_boot_info_free:
|
|
|
|
dma_free_coherent(&ha->pdev->dev, size, buf, buf_dma);
|
|
|
|
exit_boot_info:
|
2012-02-13 14:00:42 +01:00
|
|
|
ha->pri_ddb_idx = ddb_index[0];
|
|
|
|
ha->sec_ddb_idx = ddb_index[1];
|
2011-07-25 20:48:55 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-10-08 01:55:44 +02:00
|
|
|
/**
|
|
|
|
* qla4xxx_get_bidi_chap - Get a BIDI CHAP user and password
|
|
|
|
* @ha: pointer to adapter structure
|
|
|
|
* @username: CHAP username to be returned
|
|
|
|
* @password: CHAP password to be returned
|
|
|
|
*
|
|
|
|
* If a boot entry has BIDI CHAP enabled then we need to set the BIDI CHAP
|
|
|
|
* user and password in the sysfs entry in /sys/firmware/iscsi_boot#/.
|
|
|
|
* So from the CHAP cache find the first BIDI CHAP entry and set it
|
|
|
|
* to the boot record in sysfs.
|
|
|
|
**/
|
|
|
|
static int qla4xxx_get_bidi_chap(struct scsi_qla_host *ha, char *username,
|
|
|
|
char *password)
|
|
|
|
{
|
|
|
|
int i, ret = -EINVAL;
|
|
|
|
int max_chap_entries = 0;
|
|
|
|
struct ql4_chap_table *chap_table;
|
|
|
|
|
2013-03-22 12:08:31 +01:00
|
|
|
if (is_qla80XX(ha))
|
2011-10-08 01:55:44 +02:00
|
|
|
max_chap_entries = (ha->hw.flt_chap_size / 2) /
|
|
|
|
sizeof(struct ql4_chap_table);
|
|
|
|
else
|
|
|
|
max_chap_entries = MAX_CHAP_ENTRIES_40XX;
|
|
|
|
|
|
|
|
if (!ha->chap_list) {
|
|
|
|
ql4_printk(KERN_ERR, ha, "Do not have CHAP table cache\n");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
mutex_lock(&ha->chap_sem);
|
|
|
|
for (i = 0; i < max_chap_entries; i++) {
|
|
|
|
chap_table = (struct ql4_chap_table *)ha->chap_list + i;
|
|
|
|
if (chap_table->cookie !=
|
|
|
|
__constant_cpu_to_le16(CHAP_VALID_COOKIE)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (chap_table->flags & BIT_7) /* local */
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!(chap_table->flags & BIT_6)) /* Not BIDI */
|
|
|
|
continue;
|
|
|
|
|
2014-07-26 16:49:32 +02:00
|
|
|
strlcpy(password, chap_table->secret, QL4_CHAP_MAX_SECRET_LEN);
|
|
|
|
strlcpy(username, chap_table->name, QL4_CHAP_MAX_NAME_LEN);
|
2011-10-08 01:55:44 +02:00
|
|
|
ret = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
mutex_unlock(&ha->chap_sem);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-07-25 20:48:55 +02:00
|
|
|
static int qla4xxx_get_boot_target(struct scsi_qla_host *ha,
|
|
|
|
struct ql4_boot_session_info *boot_sess,
|
|
|
|
uint16_t ddb_index)
|
|
|
|
{
|
|
|
|
struct ql4_conn_info *boot_conn = &boot_sess->conn_list[0];
|
|
|
|
struct dev_db_entry *fw_ddb_entry;
|
|
|
|
dma_addr_t fw_ddb_entry_dma;
|
|
|
|
uint16_t idx;
|
|
|
|
uint16_t options;
|
|
|
|
int ret = QLA_SUCCESS;
|
|
|
|
|
|
|
|
fw_ddb_entry = dma_alloc_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry),
|
|
|
|
&fw_ddb_entry_dma, GFP_KERNEL);
|
|
|
|
if (!fw_ddb_entry) {
|
|
|
|
DEBUG2(ql4_printk(KERN_ERR, ha,
|
|
|
|
"%s: Unable to allocate dma buffer.\n",
|
|
|
|
__func__));
|
|
|
|
ret = QLA_ERROR;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (qla4xxx_bootdb_by_index(ha, fw_ddb_entry,
|
|
|
|
fw_ddb_entry_dma, ddb_index)) {
|
2012-02-13 14:00:43 +01:00
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha, "%s: No Flash DDB found at "
|
|
|
|
"index [%d]\n", __func__, ddb_index));
|
2011-07-25 20:48:55 +02:00
|
|
|
ret = QLA_ERROR;
|
|
|
|
goto exit_boot_target;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Update target name and IP from DDB */
|
|
|
|
memcpy(boot_sess->target_name, fw_ddb_entry->iscsi_name,
|
|
|
|
min(sizeof(boot_sess->target_name),
|
|
|
|
sizeof(fw_ddb_entry->iscsi_name)));
|
|
|
|
|
|
|
|
options = le16_to_cpu(fw_ddb_entry->options);
|
|
|
|
if (options & DDB_OPT_IPV6_DEVICE) {
|
|
|
|
memcpy(&boot_conn->dest_ipaddr.ip_address,
|
|
|
|
&fw_ddb_entry->ip_addr[0], IPv6_ADDR_LEN);
|
|
|
|
} else {
|
|
|
|
boot_conn->dest_ipaddr.ip_type = 0x1;
|
|
|
|
memcpy(&boot_conn->dest_ipaddr.ip_address,
|
|
|
|
&fw_ddb_entry->ip_addr[0], IP_ADDR_LEN);
|
|
|
|
}
|
|
|
|
|
|
|
|
boot_conn->dest_port = le16_to_cpu(fw_ddb_entry->port);
|
|
|
|
|
|
|
|
/* update chap information */
|
|
|
|
idx = __le16_to_cpu(fw_ddb_entry->chap_tbl_idx);
|
|
|
|
|
|
|
|
if (BIT_7 & le16_to_cpu(fw_ddb_entry->iscsi_options)) {
|
|
|
|
|
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha, "Setting chap\n"));
|
|
|
|
|
|
|
|
ret = qla4xxx_get_chap(ha, (char *)&boot_conn->chap.
|
|
|
|
target_chap_name,
|
|
|
|
(char *)&boot_conn->chap.target_secret,
|
|
|
|
idx);
|
|
|
|
if (ret) {
|
|
|
|
ql4_printk(KERN_ERR, ha, "Failed to set chap\n");
|
|
|
|
ret = QLA_ERROR;
|
|
|
|
goto exit_boot_target;
|
|
|
|
}
|
|
|
|
|
|
|
|
boot_conn->chap.target_chap_name_length = QL4_CHAP_MAX_NAME_LEN;
|
|
|
|
boot_conn->chap.target_secret_length = QL4_CHAP_MAX_SECRET_LEN;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (BIT_4 & le16_to_cpu(fw_ddb_entry->iscsi_options)) {
|
|
|
|
|
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha, "Setting BIDI chap\n"));
|
|
|
|
|
2011-10-08 01:55:44 +02:00
|
|
|
ret = qla4xxx_get_bidi_chap(ha,
|
|
|
|
(char *)&boot_conn->chap.intr_chap_name,
|
|
|
|
(char *)&boot_conn->chap.intr_secret);
|
|
|
|
|
2011-07-25 20:48:55 +02:00
|
|
|
if (ret) {
|
|
|
|
ql4_printk(KERN_ERR, ha, "Failed to set BIDI chap\n");
|
|
|
|
ret = QLA_ERROR;
|
|
|
|
goto exit_boot_target;
|
|
|
|
}
|
|
|
|
|
|
|
|
boot_conn->chap.intr_chap_name_length = QL4_CHAP_MAX_NAME_LEN;
|
|
|
|
boot_conn->chap.intr_secret_length = QL4_CHAP_MAX_SECRET_LEN;
|
|
|
|
}
|
|
|
|
|
|
|
|
exit_boot_target:
|
|
|
|
dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry),
|
|
|
|
fw_ddb_entry, fw_ddb_entry_dma);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int qla4xxx_get_boot_info(struct scsi_qla_host *ha)
|
|
|
|
{
|
|
|
|
uint16_t ddb_index[2];
|
2011-10-08 01:55:43 +02:00
|
|
|
int ret = QLA_ERROR;
|
|
|
|
int rval;
|
2011-07-25 20:48:55 +02:00
|
|
|
|
|
|
|
memset(ddb_index, 0, sizeof(ddb_index));
|
2011-10-08 01:55:43 +02:00
|
|
|
ddb_index[0] = 0xffff;
|
|
|
|
ddb_index[1] = 0xffff;
|
2011-07-25 20:48:55 +02:00
|
|
|
ret = get_fw_boot_info(ha, ddb_index);
|
|
|
|
if (ret != QLA_SUCCESS) {
|
2012-02-13 14:00:43 +01:00
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha,
|
|
|
|
"%s: No boot target configured.\n", __func__));
|
2011-07-25 20:48:55 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-12-02 04:38:41 +01:00
|
|
|
if (ql4xdisablesysfsboot)
|
|
|
|
return QLA_SUCCESS;
|
|
|
|
|
2011-10-08 01:55:43 +02:00
|
|
|
if (ddb_index[0] == 0xffff)
|
|
|
|
goto sec_target;
|
|
|
|
|
|
|
|
rval = qla4xxx_get_boot_target(ha, &(ha->boot_tgt.boot_pri_sess),
|
2011-07-25 20:48:55 +02:00
|
|
|
ddb_index[0]);
|
2011-10-08 01:55:43 +02:00
|
|
|
if (rval != QLA_SUCCESS) {
|
2012-02-13 14:00:43 +01:00
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha, "%s: Primary boot target not "
|
|
|
|
"configured\n", __func__));
|
2011-10-08 01:55:43 +02:00
|
|
|
} else
|
|
|
|
ret = QLA_SUCCESS;
|
2011-07-25 20:48:55 +02:00
|
|
|
|
2011-10-08 01:55:43 +02:00
|
|
|
sec_target:
|
|
|
|
if (ddb_index[1] == 0xffff)
|
|
|
|
goto exit_get_boot_info;
|
|
|
|
|
|
|
|
rval = qla4xxx_get_boot_target(ha, &(ha->boot_tgt.boot_sec_sess),
|
2011-07-25 20:48:55 +02:00
|
|
|
ddb_index[1]);
|
2011-10-08 01:55:43 +02:00
|
|
|
if (rval != QLA_SUCCESS) {
|
2012-02-13 14:00:43 +01:00
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha, "%s: Secondary boot target not"
|
|
|
|
" configured\n", __func__));
|
2011-10-08 01:55:43 +02:00
|
|
|
} else
|
|
|
|
ret = QLA_SUCCESS;
|
|
|
|
|
|
|
|
exit_get_boot_info:
|
2011-07-25 20:48:55 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int qla4xxx_setup_boot_info(struct scsi_qla_host *ha)
|
|
|
|
{
|
|
|
|
struct iscsi_boot_kobj *boot_kobj;
|
|
|
|
|
|
|
|
if (qla4xxx_get_boot_info(ha) != QLA_SUCCESS)
|
2011-12-02 04:38:41 +01:00
|
|
|
return QLA_ERROR;
|
|
|
|
|
|
|
|
if (ql4xdisablesysfsboot) {
|
|
|
|
ql4_printk(KERN_INFO, ha,
|
2012-02-24 16:32:59 +01:00
|
|
|
"%s: syfsboot disabled - driver will trigger login "
|
2011-12-02 04:38:41 +01:00
|
|
|
"and publish session for discovery .\n", __func__);
|
|
|
|
return QLA_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2011-07-25 20:48:55 +02:00
|
|
|
|
|
|
|
ha->boot_kset = iscsi_boot_create_host_kset(ha->host->host_no);
|
|
|
|
if (!ha->boot_kset)
|
|
|
|
goto kset_free;
|
|
|
|
|
|
|
|
if (!scsi_host_get(ha->host))
|
|
|
|
goto kset_free;
|
|
|
|
boot_kobj = iscsi_boot_create_target(ha->boot_kset, 0, ha,
|
|
|
|
qla4xxx_show_boot_tgt_pri_info,
|
|
|
|
qla4xxx_tgt_get_attr_visibility,
|
|
|
|
qla4xxx_boot_release);
|
|
|
|
if (!boot_kobj)
|
|
|
|
goto put_host;
|
|
|
|
|
|
|
|
if (!scsi_host_get(ha->host))
|
|
|
|
goto kset_free;
|
|
|
|
boot_kobj = iscsi_boot_create_target(ha->boot_kset, 1, ha,
|
|
|
|
qla4xxx_show_boot_tgt_sec_info,
|
|
|
|
qla4xxx_tgt_get_attr_visibility,
|
|
|
|
qla4xxx_boot_release);
|
|
|
|
if (!boot_kobj)
|
|
|
|
goto put_host;
|
|
|
|
|
|
|
|
if (!scsi_host_get(ha->host))
|
|
|
|
goto kset_free;
|
|
|
|
boot_kobj = iscsi_boot_create_initiator(ha->boot_kset, 0, ha,
|
|
|
|
qla4xxx_show_boot_ini_info,
|
|
|
|
qla4xxx_ini_get_attr_visibility,
|
|
|
|
qla4xxx_boot_release);
|
|
|
|
if (!boot_kobj)
|
|
|
|
goto put_host;
|
|
|
|
|
|
|
|
if (!scsi_host_get(ha->host))
|
|
|
|
goto kset_free;
|
|
|
|
boot_kobj = iscsi_boot_create_ethernet(ha->boot_kset, 0, ha,
|
|
|
|
qla4xxx_show_boot_eth_info,
|
|
|
|
qla4xxx_eth_get_attr_visibility,
|
|
|
|
qla4xxx_boot_release);
|
|
|
|
if (!boot_kobj)
|
|
|
|
goto put_host;
|
|
|
|
|
2011-12-02 04:38:41 +01:00
|
|
|
return QLA_SUCCESS;
|
2011-07-25 20:48:55 +02:00
|
|
|
|
|
|
|
put_host:
|
|
|
|
scsi_host_put(ha->host);
|
|
|
|
kset_free:
|
|
|
|
iscsi_boot_destroy_kset(ha->boot_kset);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2011-10-08 01:55:42 +02:00
|
|
|
|
2011-12-02 04:38:41 +01:00
|
|
|
static void qla4xxx_get_param_ddb(struct ddb_entry *ddb_entry,
|
|
|
|
struct ql4_tuple_ddb *tddb)
|
|
|
|
{
|
|
|
|
struct scsi_qla_host *ha;
|
|
|
|
struct iscsi_cls_session *cls_sess;
|
|
|
|
struct iscsi_cls_conn *cls_conn;
|
|
|
|
struct iscsi_session *sess;
|
|
|
|
struct iscsi_conn *conn;
|
|
|
|
|
|
|
|
DEBUG2(printk(KERN_INFO "Func: %s\n", __func__));
|
|
|
|
ha = ddb_entry->ha;
|
|
|
|
cls_sess = ddb_entry->sess;
|
|
|
|
sess = cls_sess->dd_data;
|
|
|
|
cls_conn = ddb_entry->conn;
|
|
|
|
conn = cls_conn->dd_data;
|
|
|
|
|
|
|
|
tddb->tpgt = sess->tpgt;
|
|
|
|
tddb->port = conn->persistent_port;
|
2014-07-26 16:49:32 +02:00
|
|
|
strlcpy(tddb->iscsi_name, sess->targetname, ISCSI_NAME_SIZE);
|
|
|
|
strlcpy(tddb->ip_addr, conn->persistent_address, DDB_IPADDR_LEN);
|
2011-12-02 04:38:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void qla4xxx_convert_param_ddb(struct dev_db_entry *fw_ddb_entry,
|
2012-06-14 12:35:48 +02:00
|
|
|
struct ql4_tuple_ddb *tddb,
|
|
|
|
uint8_t *flash_isid)
|
2011-12-02 04:38:41 +01:00
|
|
|
{
|
|
|
|
uint16_t options = 0;
|
|
|
|
|
|
|
|
tddb->tpgt = le32_to_cpu(fw_ddb_entry->tgt_portal_grp);
|
|
|
|
memcpy(&tddb->iscsi_name[0], &fw_ddb_entry->iscsi_name[0],
|
|
|
|
min(sizeof(tddb->iscsi_name), sizeof(fw_ddb_entry->iscsi_name)));
|
|
|
|
|
|
|
|
options = le16_to_cpu(fw_ddb_entry->options);
|
|
|
|
if (options & DDB_OPT_IPV6_DEVICE)
|
|
|
|
sprintf(tddb->ip_addr, "%pI6", fw_ddb_entry->ip_addr);
|
|
|
|
else
|
|
|
|
sprintf(tddb->ip_addr, "%pI4", fw_ddb_entry->ip_addr);
|
|
|
|
|
|
|
|
tddb->port = le16_to_cpu(fw_ddb_entry->port);
|
2012-06-14 12:35:48 +02:00
|
|
|
|
|
|
|
if (flash_isid == NULL)
|
|
|
|
memcpy(&tddb->isid[0], &fw_ddb_entry->isid[0],
|
|
|
|
sizeof(tddb->isid));
|
|
|
|
else
|
|
|
|
memcpy(&tddb->isid[0], &flash_isid[0], sizeof(tddb->isid));
|
2011-12-02 04:38:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int qla4xxx_compare_tuple_ddb(struct scsi_qla_host *ha,
|
|
|
|
struct ql4_tuple_ddb *old_tddb,
|
2012-02-27 12:08:55 +01:00
|
|
|
struct ql4_tuple_ddb *new_tddb,
|
|
|
|
uint8_t is_isid_compare)
|
2011-12-02 04:38:41 +01:00
|
|
|
{
|
|
|
|
if (strcmp(old_tddb->iscsi_name, new_tddb->iscsi_name))
|
|
|
|
return QLA_ERROR;
|
|
|
|
|
|
|
|
if (strcmp(old_tddb->ip_addr, new_tddb->ip_addr))
|
|
|
|
return QLA_ERROR;
|
|
|
|
|
|
|
|
if (old_tddb->port != new_tddb->port)
|
|
|
|
return QLA_ERROR;
|
|
|
|
|
2012-02-27 12:08:55 +01:00
|
|
|
/* For multi sessions, driver generates the ISID, so do not compare
|
2012-04-24 17:24:16 +02:00
|
|
|
* ISID in reset path since it would be a comparison between the
|
2012-02-27 12:08:55 +01:00
|
|
|
* driver generated ISID and firmware generated ISID. This could
|
|
|
|
* lead to adding duplicated DDBs in the list as driver generated
|
|
|
|
* ISID would not match firmware generated ISID.
|
|
|
|
*/
|
|
|
|
if (is_isid_compare) {
|
2016-10-22 19:32:28 +02:00
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha,
|
|
|
|
"%s: old ISID [%pmR] New ISID [%pmR]\n",
|
|
|
|
__func__, old_tddb->isid, new_tddb->isid));
|
2012-02-27 12:08:55 +01:00
|
|
|
|
|
|
|
if (memcmp(&old_tddb->isid[0], &new_tddb->isid[0],
|
|
|
|
sizeof(old_tddb->isid)))
|
|
|
|
return QLA_ERROR;
|
|
|
|
}
|
|
|
|
|
2011-12-02 04:38:41 +01:00
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha,
|
|
|
|
"Match Found, fw[%d,%d,%s,%s], [%d,%d,%s,%s]",
|
|
|
|
old_tddb->port, old_tddb->tpgt, old_tddb->ip_addr,
|
|
|
|
old_tddb->iscsi_name, new_tddb->port, new_tddb->tpgt,
|
|
|
|
new_tddb->ip_addr, new_tddb->iscsi_name));
|
|
|
|
|
|
|
|
return QLA_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int qla4xxx_is_session_exists(struct scsi_qla_host *ha,
|
2013-09-17 13:30:02 +02:00
|
|
|
struct dev_db_entry *fw_ddb_entry,
|
|
|
|
uint32_t *index)
|
2011-12-02 04:38:41 +01:00
|
|
|
{
|
|
|
|
struct ddb_entry *ddb_entry;
|
|
|
|
struct ql4_tuple_ddb *fw_tddb = NULL;
|
|
|
|
struct ql4_tuple_ddb *tmp_tddb = NULL;
|
|
|
|
int idx;
|
|
|
|
int ret = QLA_ERROR;
|
|
|
|
|
|
|
|
fw_tddb = vzalloc(sizeof(*fw_tddb));
|
|
|
|
if (!fw_tddb) {
|
|
|
|
DEBUG2(ql4_printk(KERN_WARNING, ha,
|
|
|
|
"Memory Allocation failed.\n"));
|
|
|
|
ret = QLA_SUCCESS;
|
|
|
|
goto exit_check;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp_tddb = vzalloc(sizeof(*tmp_tddb));
|
|
|
|
if (!tmp_tddb) {
|
|
|
|
DEBUG2(ql4_printk(KERN_WARNING, ha,
|
|
|
|
"Memory Allocation failed.\n"));
|
|
|
|
ret = QLA_SUCCESS;
|
|
|
|
goto exit_check;
|
|
|
|
}
|
|
|
|
|
2012-06-14 12:35:48 +02:00
|
|
|
qla4xxx_convert_param_ddb(fw_ddb_entry, fw_tddb, NULL);
|
2011-12-02 04:38:41 +01:00
|
|
|
|
|
|
|
for (idx = 0; idx < MAX_DDB_ENTRIES; idx++) {
|
|
|
|
ddb_entry = qla4xxx_lookup_ddb_by_fw_index(ha, idx);
|
|
|
|
if (ddb_entry == NULL)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
qla4xxx_get_param_ddb(ddb_entry, tmp_tddb);
|
2012-02-27 12:08:55 +01:00
|
|
|
if (!qla4xxx_compare_tuple_ddb(ha, fw_tddb, tmp_tddb, false)) {
|
2011-12-02 04:38:41 +01:00
|
|
|
ret = QLA_SUCCESS; /* found */
|
2013-09-17 13:30:02 +02:00
|
|
|
if (index != NULL)
|
|
|
|
*index = idx;
|
2011-12-02 04:38:41 +01:00
|
|
|
goto exit_check;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
exit_check:
|
|
|
|
if (fw_tddb)
|
|
|
|
vfree(fw_tddb);
|
|
|
|
if (tmp_tddb)
|
|
|
|
vfree(tmp_tddb);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-06-14 12:35:48 +02:00
|
|
|
/**
|
|
|
|
* qla4xxx_check_existing_isid - check if target with same isid exist
|
|
|
|
* in target list
|
|
|
|
* @list_nt: list of target
|
|
|
|
* @isid: isid to check
|
|
|
|
*
|
|
|
|
* This routine return QLA_SUCCESS if target with same isid exist
|
|
|
|
**/
|
|
|
|
static int qla4xxx_check_existing_isid(struct list_head *list_nt, uint8_t *isid)
|
|
|
|
{
|
|
|
|
struct qla_ddb_index *nt_ddb_idx, *nt_ddb_idx_tmp;
|
|
|
|
struct dev_db_entry *fw_ddb_entry;
|
|
|
|
|
|
|
|
list_for_each_entry_safe(nt_ddb_idx, nt_ddb_idx_tmp, list_nt, list) {
|
|
|
|
fw_ddb_entry = &nt_ddb_idx->fw_ddb;
|
|
|
|
|
|
|
|
if (memcmp(&fw_ddb_entry->isid[0], &isid[0],
|
|
|
|
sizeof(nt_ddb_idx->fw_ddb.isid)) == 0) {
|
|
|
|
return QLA_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return QLA_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* qla4xxx_update_isid - compare ddbs and updated isid
|
|
|
|
* @ha: Pointer to host adapter structure.
|
|
|
|
* @list_nt: list of nt target
|
|
|
|
* @fw_ddb_entry: firmware ddb entry
|
|
|
|
*
|
|
|
|
* This routine update isid if ddbs have same iqn, same isid and
|
|
|
|
* different IP addr.
|
|
|
|
* Return QLA_SUCCESS if isid is updated.
|
|
|
|
**/
|
|
|
|
static int qla4xxx_update_isid(struct scsi_qla_host *ha,
|
|
|
|
struct list_head *list_nt,
|
|
|
|
struct dev_db_entry *fw_ddb_entry)
|
|
|
|
{
|
|
|
|
uint8_t base_value, i;
|
|
|
|
|
|
|
|
base_value = fw_ddb_entry->isid[1] & 0x1f;
|
|
|
|
for (i = 0; i < 8; i++) {
|
|
|
|
fw_ddb_entry->isid[1] = (base_value | (i << 5));
|
|
|
|
if (qla4xxx_check_existing_isid(list_nt, fw_ddb_entry->isid))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!qla4xxx_check_existing_isid(list_nt, fw_ddb_entry->isid))
|
|
|
|
return QLA_ERROR;
|
|
|
|
|
|
|
|
return QLA_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* qla4xxx_should_update_isid - check if isid need to update
|
|
|
|
* @ha: Pointer to host adapter structure.
|
|
|
|
* @old_tddb: ddb tuple
|
|
|
|
* @new_tddb: ddb tuple
|
|
|
|
*
|
|
|
|
* Return QLA_SUCCESS if different IP, different PORT, same iqn,
|
|
|
|
* same isid
|
|
|
|
**/
|
|
|
|
static int qla4xxx_should_update_isid(struct scsi_qla_host *ha,
|
|
|
|
struct ql4_tuple_ddb *old_tddb,
|
|
|
|
struct ql4_tuple_ddb *new_tddb)
|
|
|
|
{
|
|
|
|
if (strcmp(old_tddb->ip_addr, new_tddb->ip_addr) == 0) {
|
|
|
|
/* Same ip */
|
|
|
|
if (old_tddb->port == new_tddb->port)
|
|
|
|
return QLA_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcmp(old_tddb->iscsi_name, new_tddb->iscsi_name))
|
|
|
|
/* different iqn */
|
|
|
|
return QLA_ERROR;
|
|
|
|
|
|
|
|
if (memcmp(&old_tddb->isid[0], &new_tddb->isid[0],
|
|
|
|
sizeof(old_tddb->isid)))
|
|
|
|
/* different isid */
|
|
|
|
return QLA_ERROR;
|
|
|
|
|
|
|
|
return QLA_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* qla4xxx_is_flash_ddb_exists - check if fw_ddb_entry already exists in list_nt
|
|
|
|
* @ha: Pointer to host adapter structure.
|
|
|
|
* @list_nt: list of nt target.
|
|
|
|
* @fw_ddb_entry: firmware ddb entry.
|
|
|
|
*
|
|
|
|
* This routine check if fw_ddb_entry already exists in list_nt to avoid
|
|
|
|
* duplicate ddb in list_nt.
|
|
|
|
* Return QLA_SUCCESS if duplicate ddb exit in list_nl.
|
|
|
|
* Note: This function also update isid of DDB if required.
|
|
|
|
**/
|
|
|
|
|
2011-12-02 04:38:41 +01:00
|
|
|
static int qla4xxx_is_flash_ddb_exists(struct scsi_qla_host *ha,
|
|
|
|
struct list_head *list_nt,
|
|
|
|
struct dev_db_entry *fw_ddb_entry)
|
|
|
|
{
|
|
|
|
struct qla_ddb_index *nt_ddb_idx, *nt_ddb_idx_tmp;
|
|
|
|
struct ql4_tuple_ddb *fw_tddb = NULL;
|
|
|
|
struct ql4_tuple_ddb *tmp_tddb = NULL;
|
2012-06-14 12:35:48 +02:00
|
|
|
int rval, ret = QLA_ERROR;
|
2011-12-02 04:38:41 +01:00
|
|
|
|
|
|
|
fw_tddb = vzalloc(sizeof(*fw_tddb));
|
|
|
|
if (!fw_tddb) {
|
|
|
|
DEBUG2(ql4_printk(KERN_WARNING, ha,
|
|
|
|
"Memory Allocation failed.\n"));
|
|
|
|
ret = QLA_SUCCESS;
|
|
|
|
goto exit_check;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp_tddb = vzalloc(sizeof(*tmp_tddb));
|
|
|
|
if (!tmp_tddb) {
|
|
|
|
DEBUG2(ql4_printk(KERN_WARNING, ha,
|
|
|
|
"Memory Allocation failed.\n"));
|
|
|
|
ret = QLA_SUCCESS;
|
|
|
|
goto exit_check;
|
|
|
|
}
|
|
|
|
|
2012-06-14 12:35:48 +02:00
|
|
|
qla4xxx_convert_param_ddb(fw_ddb_entry, fw_tddb, NULL);
|
2011-12-02 04:38:41 +01:00
|
|
|
|
|
|
|
list_for_each_entry_safe(nt_ddb_idx, nt_ddb_idx_tmp, list_nt, list) {
|
2012-06-14 12:35:48 +02:00
|
|
|
qla4xxx_convert_param_ddb(&nt_ddb_idx->fw_ddb, tmp_tddb,
|
|
|
|
nt_ddb_idx->flash_isid);
|
|
|
|
ret = qla4xxx_compare_tuple_ddb(ha, fw_tddb, tmp_tddb, true);
|
|
|
|
/* found duplicate ddb */
|
|
|
|
if (ret == QLA_SUCCESS)
|
|
|
|
goto exit_check;
|
|
|
|
}
|
|
|
|
|
|
|
|
list_for_each_entry_safe(nt_ddb_idx, nt_ddb_idx_tmp, list_nt, list) {
|
|
|
|
qla4xxx_convert_param_ddb(&nt_ddb_idx->fw_ddb, tmp_tddb, NULL);
|
|
|
|
|
|
|
|
ret = qla4xxx_should_update_isid(ha, tmp_tddb, fw_tddb);
|
|
|
|
if (ret == QLA_SUCCESS) {
|
|
|
|
rval = qla4xxx_update_isid(ha, list_nt, fw_ddb_entry);
|
|
|
|
if (rval == QLA_SUCCESS)
|
|
|
|
ret = QLA_ERROR;
|
|
|
|
else
|
|
|
|
ret = QLA_SUCCESS;
|
|
|
|
|
2011-12-02 04:38:41 +01:00
|
|
|
goto exit_check;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
exit_check:
|
|
|
|
if (fw_tddb)
|
|
|
|
vfree(fw_tddb);
|
|
|
|
if (tmp_tddb)
|
|
|
|
vfree(tmp_tddb);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-12-16 10:58:55 +01:00
|
|
|
static void qla4xxx_free_ddb_list(struct list_head *list_ddb)
|
2011-12-02 04:38:41 +01:00
|
|
|
{
|
2011-12-16 10:58:55 +01:00
|
|
|
struct qla_ddb_index *ddb_idx, *ddb_idx_tmp;
|
2011-12-02 04:38:41 +01:00
|
|
|
|
2011-12-16 10:58:55 +01:00
|
|
|
list_for_each_entry_safe(ddb_idx, ddb_idx_tmp, list_ddb, list) {
|
|
|
|
list_del_init(&ddb_idx->list);
|
|
|
|
vfree(ddb_idx);
|
2011-12-02 04:38:41 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct iscsi_endpoint *qla4xxx_get_ep_fwdb(struct scsi_qla_host *ha,
|
|
|
|
struct dev_db_entry *fw_ddb_entry)
|
|
|
|
{
|
|
|
|
struct iscsi_endpoint *ep;
|
|
|
|
struct sockaddr_in *addr;
|
|
|
|
struct sockaddr_in6 *addr6;
|
2012-11-23 12:58:40 +01:00
|
|
|
struct sockaddr *t_addr;
|
|
|
|
struct sockaddr_storage *dst_addr;
|
2011-12-02 04:38:41 +01:00
|
|
|
char *ip;
|
|
|
|
|
|
|
|
/* TODO: need to destroy on unload iscsi_endpoint*/
|
|
|
|
dst_addr = vmalloc(sizeof(*dst_addr));
|
|
|
|
if (!dst_addr)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (fw_ddb_entry->options & DDB_OPT_IPV6_DEVICE) {
|
2012-11-23 12:58:40 +01:00
|
|
|
t_addr = (struct sockaddr *)dst_addr;
|
|
|
|
t_addr->sa_family = AF_INET6;
|
2011-12-02 04:38:41 +01:00
|
|
|
addr6 = (struct sockaddr_in6 *)dst_addr;
|
|
|
|
ip = (char *)&addr6->sin6_addr;
|
|
|
|
memcpy(ip, fw_ddb_entry->ip_addr, IPv6_ADDR_LEN);
|
|
|
|
addr6->sin6_port = htons(le16_to_cpu(fw_ddb_entry->port));
|
|
|
|
|
|
|
|
} else {
|
2012-11-23 12:58:40 +01:00
|
|
|
t_addr = (struct sockaddr *)dst_addr;
|
|
|
|
t_addr->sa_family = AF_INET;
|
2011-12-02 04:38:41 +01:00
|
|
|
addr = (struct sockaddr_in *)dst_addr;
|
|
|
|
ip = (char *)&addr->sin_addr;
|
|
|
|
memcpy(ip, fw_ddb_entry->ip_addr, IP_ADDR_LEN);
|
|
|
|
addr->sin_port = htons(le16_to_cpu(fw_ddb_entry->port));
|
|
|
|
}
|
|
|
|
|
2012-11-23 12:58:40 +01:00
|
|
|
ep = qla4xxx_ep_connect(ha->host, (struct sockaddr *)dst_addr, 0);
|
2011-12-02 04:38:41 +01:00
|
|
|
vfree(dst_addr);
|
|
|
|
return ep;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int qla4xxx_verify_boot_idx(struct scsi_qla_host *ha, uint16_t idx)
|
|
|
|
{
|
|
|
|
if (ql4xdisablesysfsboot)
|
|
|
|
return QLA_SUCCESS;
|
|
|
|
if (idx == ha->pri_ddb_idx || idx == ha->sec_ddb_idx)
|
|
|
|
return QLA_ERROR;
|
|
|
|
return QLA_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
|
2013-01-21 05:51:03 +01:00
|
|
|
struct ddb_entry *ddb_entry,
|
|
|
|
uint16_t idx)
|
2011-12-02 04:38:41 +01:00
|
|
|
{
|
2011-12-19 06:40:44 +01:00
|
|
|
uint16_t def_timeout;
|
|
|
|
|
2011-12-02 04:38:41 +01:00
|
|
|
ddb_entry->ddb_type = FLASH_DDB;
|
|
|
|
ddb_entry->fw_ddb_index = INVALID_ENTRY;
|
|
|
|
ddb_entry->fw_ddb_device_state = DDB_DS_NO_CONNECTION_ACTIVE;
|
|
|
|
ddb_entry->ha = ha;
|
|
|
|
ddb_entry->unblock_sess = qla4xxx_unblock_flash_ddb;
|
|
|
|
ddb_entry->ddb_change = qla4xxx_flash_ddb_change;
|
2013-09-17 13:54:46 +02:00
|
|
|
ddb_entry->chap_tbl_idx = INVALID_ENTRY;
|
2011-12-02 04:38:41 +01:00
|
|
|
|
|
|
|
atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
|
|
|
|
atomic_set(&ddb_entry->relogin_timer, 0);
|
|
|
|
atomic_set(&ddb_entry->relogin_retry_count, 0);
|
2011-12-19 06:40:44 +01:00
|
|
|
def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
|
2011-12-02 04:38:41 +01:00
|
|
|
ddb_entry->default_relogin_timeout =
|
2011-12-19 06:40:44 +01:00
|
|
|
(def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
|
|
|
|
def_timeout : LOGIN_TOV;
|
2011-12-02 04:38:41 +01:00
|
|
|
ddb_entry->default_time2wait =
|
|
|
|
le16_to_cpu(ddb_entry->fw_ddb_entry.iscsi_def_time2wait);
|
2013-01-21 05:51:03 +01:00
|
|
|
|
|
|
|
if (ql4xdisablesysfsboot &&
|
|
|
|
(idx == ha->pri_ddb_idx || idx == ha->sec_ddb_idx))
|
|
|
|
set_bit(DF_BOOT_TGT, &ddb_entry->flags);
|
2011-12-02 04:38:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void qla4xxx_wait_for_ip_configuration(struct scsi_qla_host *ha)
|
|
|
|
{
|
|
|
|
uint32_t idx = 0;
|
|
|
|
uint32_t ip_idx[IP_ADDR_COUNT] = {0, 1, 2, 3}; /* 4 IP interfaces */
|
|
|
|
uint32_t sts[MBOX_REG_COUNT];
|
|
|
|
uint32_t ip_state;
|
|
|
|
unsigned long wtime;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
wtime = jiffies + (HZ * IP_CONFIG_TOV);
|
|
|
|
do {
|
|
|
|
for (idx = 0; idx < IP_ADDR_COUNT; idx++) {
|
|
|
|
if (ip_idx[idx] == -1)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
ret = qla4xxx_get_ip_state(ha, 0, ip_idx[idx], sts);
|
|
|
|
|
|
|
|
if (ret == QLA_ERROR) {
|
|
|
|
ip_idx[idx] = -1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
ip_state = (sts[1] & IP_STATE_MASK) >> IP_STATE_SHIFT;
|
|
|
|
|
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha,
|
|
|
|
"Waiting for IP state for idx = %d, state = 0x%x\n",
|
|
|
|
ip_idx[idx], ip_state));
|
|
|
|
if (ip_state == IP_ADDRSTATE_UNCONFIGURED ||
|
|
|
|
ip_state == IP_ADDRSTATE_INVALID ||
|
|
|
|
ip_state == IP_ADDRSTATE_PREFERRED ||
|
|
|
|
ip_state == IP_ADDRSTATE_DEPRICATED ||
|
|
|
|
ip_state == IP_ADDRSTATE_DISABLING)
|
|
|
|
ip_idx[idx] = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Break if all IP states checked */
|
|
|
|
if ((ip_idx[0] == -1) &&
|
|
|
|
(ip_idx[1] == -1) &&
|
|
|
|
(ip_idx[2] == -1) &&
|
|
|
|
(ip_idx[3] == -1))
|
|
|
|
break;
|
|
|
|
schedule_timeout_uninterruptible(HZ);
|
|
|
|
} while (time_after(wtime, jiffies));
|
|
|
|
}
|
|
|
|
|
2013-09-17 13:30:02 +02:00
|
|
|
static int qla4xxx_cmp_fw_stentry(struct dev_db_entry *fw_ddb_entry,
|
|
|
|
struct dev_db_entry *flash_ddb_entry)
|
|
|
|
{
|
|
|
|
uint16_t options = 0;
|
|
|
|
size_t ip_len = IP_ADDR_LEN;
|
|
|
|
|
|
|
|
options = le16_to_cpu(fw_ddb_entry->options);
|
|
|
|
if (options & DDB_OPT_IPV6_DEVICE)
|
|
|
|
ip_len = IPv6_ADDR_LEN;
|
|
|
|
|
|
|
|
if (memcmp(fw_ddb_entry->ip_addr, flash_ddb_entry->ip_addr, ip_len))
|
|
|
|
return QLA_ERROR;
|
|
|
|
|
|
|
|
if (memcmp(&fw_ddb_entry->isid[0], &flash_ddb_entry->isid[0],
|
|
|
|
sizeof(fw_ddb_entry->isid)))
|
|
|
|
return QLA_ERROR;
|
|
|
|
|
|
|
|
if (memcmp(&fw_ddb_entry->port, &flash_ddb_entry->port,
|
|
|
|
sizeof(fw_ddb_entry->port)))
|
|
|
|
return QLA_ERROR;
|
|
|
|
|
|
|
|
return QLA_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int qla4xxx_find_flash_st_idx(struct scsi_qla_host *ha,
|
|
|
|
struct dev_db_entry *fw_ddb_entry,
|
|
|
|
uint32_t fw_idx, uint32_t *flash_index)
|
|
|
|
{
|
|
|
|
struct dev_db_entry *flash_ddb_entry;
|
|
|
|
dma_addr_t flash_ddb_entry_dma;
|
|
|
|
uint32_t idx = 0;
|
|
|
|
int max_ddbs;
|
|
|
|
int ret = QLA_ERROR, status;
|
|
|
|
|
|
|
|
max_ddbs = is_qla40XX(ha) ? MAX_DEV_DB_ENTRIES_40XX :
|
|
|
|
MAX_DEV_DB_ENTRIES;
|
|
|
|
|
|
|
|
flash_ddb_entry = dma_pool_alloc(ha->fw_ddb_dma_pool, GFP_KERNEL,
|
|
|
|
&flash_ddb_entry_dma);
|
|
|
|
if (flash_ddb_entry == NULL || fw_ddb_entry == NULL) {
|
|
|
|
ql4_printk(KERN_ERR, ha, "Out of memory\n");
|
|
|
|
goto exit_find_st_idx;
|
|
|
|
}
|
|
|
|
|
|
|
|
status = qla4xxx_flashdb_by_index(ha, flash_ddb_entry,
|
|
|
|
flash_ddb_entry_dma, fw_idx);
|
|
|
|
if (status == QLA_SUCCESS) {
|
|
|
|
status = qla4xxx_cmp_fw_stentry(fw_ddb_entry, flash_ddb_entry);
|
|
|
|
if (status == QLA_SUCCESS) {
|
|
|
|
*flash_index = fw_idx;
|
|
|
|
ret = QLA_SUCCESS;
|
|
|
|
goto exit_find_st_idx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (idx = 0; idx < max_ddbs; idx++) {
|
|
|
|
status = qla4xxx_flashdb_by_index(ha, flash_ddb_entry,
|
|
|
|
flash_ddb_entry_dma, idx);
|
|
|
|
if (status == QLA_ERROR)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
status = qla4xxx_cmp_fw_stentry(fw_ddb_entry, flash_ddb_entry);
|
|
|
|
if (status == QLA_SUCCESS) {
|
|
|
|
*flash_index = idx;
|
|
|
|
ret = QLA_SUCCESS;
|
|
|
|
goto exit_find_st_idx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (idx == max_ddbs)
|
|
|
|
ql4_printk(KERN_ERR, ha, "Failed to find ST [%d] in flash\n",
|
|
|
|
fw_idx);
|
|
|
|
|
|
|
|
exit_find_st_idx:
|
|
|
|
if (flash_ddb_entry)
|
|
|
|
dma_pool_free(ha->fw_ddb_dma_pool, flash_ddb_entry,
|
|
|
|
flash_ddb_entry_dma);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-12-16 10:58:55 +01:00
|
|
|
static void qla4xxx_build_st_list(struct scsi_qla_host *ha,
|
|
|
|
struct list_head *list_st)
|
2011-12-02 04:38:41 +01:00
|
|
|
{
|
2011-12-16 10:58:55 +01:00
|
|
|
struct qla_ddb_index *st_ddb_idx;
|
2011-12-02 04:38:41 +01:00
|
|
|
int max_ddbs;
|
2011-12-16 10:58:55 +01:00
|
|
|
int fw_idx_size;
|
|
|
|
struct dev_db_entry *fw_ddb_entry;
|
|
|
|
dma_addr_t fw_ddb_dma;
|
2011-12-02 04:38:41 +01:00
|
|
|
int ret;
|
|
|
|
uint32_t idx = 0, next_idx = 0;
|
|
|
|
uint32_t state = 0, conn_err = 0;
|
2013-09-17 13:30:02 +02:00
|
|
|
uint32_t flash_index = -1;
|
2011-12-16 10:58:55 +01:00
|
|
|
uint16_t conn_id = 0;
|
2011-12-02 04:38:41 +01:00
|
|
|
|
|
|
|
fw_ddb_entry = dma_pool_alloc(ha->fw_ddb_dma_pool, GFP_KERNEL,
|
|
|
|
&fw_ddb_dma);
|
|
|
|
if (fw_ddb_entry == NULL) {
|
|
|
|
DEBUG2(ql4_printk(KERN_ERR, ha, "Out of memory\n"));
|
2011-12-16 10:58:55 +01:00
|
|
|
goto exit_st_list;
|
2011-12-02 04:38:41 +01:00
|
|
|
}
|
|
|
|
|
2011-12-16 10:58:55 +01:00
|
|
|
max_ddbs = is_qla40XX(ha) ? MAX_DEV_DB_ENTRIES_40XX :
|
|
|
|
MAX_DEV_DB_ENTRIES;
|
2011-12-02 04:38:41 +01:00
|
|
|
fw_idx_size = sizeof(struct qla_ddb_index);
|
|
|
|
|
|
|
|
for (idx = 0; idx < max_ddbs; idx = next_idx) {
|
2011-12-16 10:58:55 +01:00
|
|
|
ret = qla4xxx_get_fwddb_entry(ha, idx, fw_ddb_entry, fw_ddb_dma,
|
|
|
|
NULL, &next_idx, &state,
|
|
|
|
&conn_err, NULL, &conn_id);
|
2011-12-02 04:38:41 +01:00
|
|
|
if (ret == QLA_ERROR)
|
|
|
|
break;
|
|
|
|
|
2012-02-13 14:00:41 +01:00
|
|
|
/* Ignore DDB if invalid state (unassigned) */
|
|
|
|
if (state == DDB_DS_UNASSIGNED)
|
|
|
|
goto continue_next_st;
|
|
|
|
|
2011-12-02 04:38:41 +01:00
|
|
|
/* Check if ST, add to the list_st */
|
|
|
|
if (strlen((char *) fw_ddb_entry->iscsi_name) != 0)
|
|
|
|
goto continue_next_st;
|
|
|
|
|
|
|
|
st_ddb_idx = vzalloc(fw_idx_size);
|
|
|
|
if (!st_ddb_idx)
|
|
|
|
break;
|
|
|
|
|
2013-09-17 13:30:02 +02:00
|
|
|
ret = qla4xxx_find_flash_st_idx(ha, fw_ddb_entry, idx,
|
|
|
|
&flash_index);
|
|
|
|
if (ret == QLA_ERROR) {
|
|
|
|
ql4_printk(KERN_ERR, ha,
|
|
|
|
"No flash entry for ST at idx [%d]\n", idx);
|
|
|
|
st_ddb_idx->flash_ddb_idx = idx;
|
|
|
|
} else {
|
|
|
|
ql4_printk(KERN_INFO, ha,
|
|
|
|
"ST at idx [%d] is stored at flash [%d]\n",
|
|
|
|
idx, flash_index);
|
|
|
|
st_ddb_idx->flash_ddb_idx = flash_index;
|
|
|
|
}
|
|
|
|
|
2011-12-02 04:38:41 +01:00
|
|
|
st_ddb_idx->fw_ddb_idx = idx;
|
|
|
|
|
2011-12-16 10:58:55 +01:00
|
|
|
list_add_tail(&st_ddb_idx->list, list_st);
|
2011-12-02 04:38:41 +01:00
|
|
|
continue_next_st:
|
|
|
|
if (next_idx == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-12-16 10:58:55 +01:00
|
|
|
exit_st_list:
|
|
|
|
if (fw_ddb_entry)
|
|
|
|
dma_pool_free(ha->fw_ddb_dma_pool, fw_ddb_entry, fw_ddb_dma);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* qla4xxx_remove_failed_ddb - Remove inactive or failed ddb from list
|
|
|
|
* @ha: pointer to adapter structure
|
|
|
|
* @list_ddb: List from which failed ddb to be removed
|
|
|
|
*
|
|
|
|
* Iterate over the list of DDBs and find and remove DDBs that are either in
|
|
|
|
* no connection active state or failed state
|
|
|
|
**/
|
|
|
|
static void qla4xxx_remove_failed_ddb(struct scsi_qla_host *ha,
|
|
|
|
struct list_head *list_ddb)
|
|
|
|
{
|
|
|
|
struct qla_ddb_index *ddb_idx, *ddb_idx_tmp;
|
|
|
|
uint32_t next_idx = 0;
|
|
|
|
uint32_t state = 0, conn_err = 0;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
list_for_each_entry_safe(ddb_idx, ddb_idx_tmp, list_ddb, list) {
|
|
|
|
ret = qla4xxx_get_fwddb_entry(ha, ddb_idx->fw_ddb_idx,
|
|
|
|
NULL, 0, NULL, &next_idx, &state,
|
|
|
|
&conn_err, NULL, NULL);
|
|
|
|
if (ret == QLA_ERROR)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (state == DDB_DS_NO_CONNECTION_ACTIVE ||
|
|
|
|
state == DDB_DS_SESSION_FAILED) {
|
|
|
|
list_del_init(&ddb_idx->list);
|
|
|
|
vfree(ddb_idx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-17 13:30:02 +02:00
|
|
|
static void qla4xxx_update_sess_disc_idx(struct scsi_qla_host *ha,
|
|
|
|
struct ddb_entry *ddb_entry,
|
|
|
|
struct dev_db_entry *fw_ddb_entry)
|
|
|
|
{
|
|
|
|
struct iscsi_cls_session *cls_sess;
|
|
|
|
struct iscsi_session *sess;
|
|
|
|
uint32_t max_ddbs = 0;
|
|
|
|
uint16_t ddb_link = -1;
|
|
|
|
|
|
|
|
max_ddbs = is_qla40XX(ha) ? MAX_DEV_DB_ENTRIES_40XX :
|
|
|
|
MAX_DEV_DB_ENTRIES;
|
|
|
|
|
|
|
|
cls_sess = ddb_entry->sess;
|
|
|
|
sess = cls_sess->dd_data;
|
|
|
|
|
|
|
|
ddb_link = le16_to_cpu(fw_ddb_entry->ddb_link);
|
|
|
|
if (ddb_link < max_ddbs)
|
|
|
|
sess->discovery_parent_idx = ddb_link;
|
|
|
|
else
|
|
|
|
sess->discovery_parent_idx = DDB_NO_LINK;
|
|
|
|
}
|
|
|
|
|
2011-12-16 10:58:55 +01:00
|
|
|
static int qla4xxx_sess_conn_setup(struct scsi_qla_host *ha,
|
|
|
|
struct dev_db_entry *fw_ddb_entry,
|
2013-01-21 05:51:03 +01:00
|
|
|
int is_reset, uint16_t idx)
|
2011-12-16 10:58:55 +01:00
|
|
|
{
|
|
|
|
struct iscsi_cls_session *cls_sess;
|
|
|
|
struct iscsi_session *sess;
|
|
|
|
struct iscsi_cls_conn *cls_conn;
|
|
|
|
struct iscsi_endpoint *ep;
|
|
|
|
uint16_t cmds_max = 32;
|
|
|
|
uint16_t conn_id = 0;
|
|
|
|
uint32_t initial_cmdsn = 0;
|
|
|
|
int ret = QLA_SUCCESS;
|
|
|
|
|
|
|
|
struct ddb_entry *ddb_entry = NULL;
|
|
|
|
|
|
|
|
/* Create session object, with INVALID_ENTRY,
|
|
|
|
* the targer_id would get set when we issue the login
|
2011-12-02 04:38:41 +01:00
|
|
|
*/
|
2011-12-16 10:58:55 +01:00
|
|
|
cls_sess = iscsi_session_setup(&qla4xxx_iscsi_transport, ha->host,
|
|
|
|
cmds_max, sizeof(struct ddb_entry),
|
|
|
|
sizeof(struct ql4_task_data),
|
|
|
|
initial_cmdsn, INVALID_ENTRY);
|
|
|
|
if (!cls_sess) {
|
|
|
|
ret = QLA_ERROR;
|
|
|
|
goto exit_setup;
|
|
|
|
}
|
2011-12-02 04:38:41 +01:00
|
|
|
|
2011-12-16 10:58:55 +01:00
|
|
|
/*
|
|
|
|
* so calling module_put function to decrement the
|
|
|
|
* reference count.
|
|
|
|
**/
|
|
|
|
module_put(qla4xxx_iscsi_transport.owner);
|
|
|
|
sess = cls_sess->dd_data;
|
|
|
|
ddb_entry = sess->dd_data;
|
|
|
|
ddb_entry->sess = cls_sess;
|
|
|
|
|
|
|
|
cls_sess->recovery_tmo = ql4xsess_recovery_tmo;
|
|
|
|
memcpy(&ddb_entry->fw_ddb_entry, fw_ddb_entry,
|
|
|
|
sizeof(struct dev_db_entry));
|
|
|
|
|
2013-01-21 05:51:03 +01:00
|
|
|
qla4xxx_setup_flash_ddb_entry(ha, ddb_entry, idx);
|
2011-12-16 10:58:55 +01:00
|
|
|
|
|
|
|
cls_conn = iscsi_conn_setup(cls_sess, sizeof(struct qla_conn), conn_id);
|
|
|
|
|
|
|
|
if (!cls_conn) {
|
|
|
|
ret = QLA_ERROR;
|
|
|
|
goto exit_setup;
|
2011-12-02 04:38:41 +01:00
|
|
|
}
|
|
|
|
|
2011-12-16 10:58:55 +01:00
|
|
|
ddb_entry->conn = cls_conn;
|
2011-12-02 04:38:41 +01:00
|
|
|
|
2011-12-16 10:58:55 +01:00
|
|
|
/* Setup ep, for displaying attributes in sysfs */
|
|
|
|
ep = qla4xxx_get_ep_fwdb(ha, fw_ddb_entry);
|
|
|
|
if (ep) {
|
|
|
|
ep->conn = cls_conn;
|
|
|
|
cls_conn->ep = ep;
|
|
|
|
} else {
|
|
|
|
DEBUG2(ql4_printk(KERN_ERR, ha, "Unable to get ep\n"));
|
|
|
|
ret = QLA_ERROR;
|
|
|
|
goto exit_setup;
|
|
|
|
}
|
2011-12-02 04:38:41 +01:00
|
|
|
|
2011-12-16 10:58:55 +01:00
|
|
|
/* Update sess/conn params */
|
|
|
|
qla4xxx_copy_fwddb_param(ha, fw_ddb_entry, cls_sess, cls_conn);
|
2013-09-17 13:30:02 +02:00
|
|
|
qla4xxx_update_sess_disc_idx(ha, ddb_entry, fw_ddb_entry);
|
2011-12-02 04:38:41 +01:00
|
|
|
|
2011-12-16 10:58:55 +01:00
|
|
|
if (is_reset == RESET_ADAPTER) {
|
|
|
|
iscsi_block_session(cls_sess);
|
|
|
|
/* Use the relogin path to discover new devices
|
|
|
|
* by short-circuting the logic of setting
|
|
|
|
* timer to relogin - instead set the flags
|
|
|
|
* to initiate login right away.
|
|
|
|
*/
|
|
|
|
set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
|
|
|
|
set_bit(DF_RELOGIN, &ddb_entry->flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
exit_setup:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-09-17 13:30:02 +02:00
|
|
|
static void qla4xxx_update_fw_ddb_link(struct scsi_qla_host *ha,
|
|
|
|
struct list_head *list_ddb,
|
|
|
|
struct dev_db_entry *fw_ddb_entry)
|
|
|
|
{
|
|
|
|
struct qla_ddb_index *ddb_idx, *ddb_idx_tmp;
|
|
|
|
uint16_t ddb_link;
|
|
|
|
|
|
|
|
ddb_link = le16_to_cpu(fw_ddb_entry->ddb_link);
|
|
|
|
|
|
|
|
list_for_each_entry_safe(ddb_idx, ddb_idx_tmp, list_ddb, list) {
|
|
|
|
if (ddb_idx->fw_ddb_idx == ddb_link) {
|
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha,
|
|
|
|
"Updating NT parent idx from [%d] to [%d]\n",
|
|
|
|
ddb_link, ddb_idx->flash_ddb_idx));
|
|
|
|
fw_ddb_entry->ddb_link =
|
|
|
|
cpu_to_le16(ddb_idx->flash_ddb_idx);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-16 10:58:55 +01:00
|
|
|
static void qla4xxx_build_nt_list(struct scsi_qla_host *ha,
|
2013-09-17 13:30:02 +02:00
|
|
|
struct list_head *list_nt,
|
|
|
|
struct list_head *list_st,
|
|
|
|
int is_reset)
|
2011-12-16 10:58:55 +01:00
|
|
|
{
|
|
|
|
struct dev_db_entry *fw_ddb_entry;
|
2013-09-17 13:30:02 +02:00
|
|
|
struct ddb_entry *ddb_entry = NULL;
|
2011-12-16 10:58:55 +01:00
|
|
|
dma_addr_t fw_ddb_dma;
|
|
|
|
int max_ddbs;
|
|
|
|
int fw_idx_size;
|
|
|
|
int ret;
|
|
|
|
uint32_t idx = 0, next_idx = 0;
|
|
|
|
uint32_t state = 0, conn_err = 0;
|
2013-09-17 13:30:02 +02:00
|
|
|
uint32_t ddb_idx = -1;
|
2011-12-16 10:58:55 +01:00
|
|
|
uint16_t conn_id = 0;
|
2013-09-17 13:30:02 +02:00
|
|
|
uint16_t ddb_link = -1;
|
2011-12-16 10:58:55 +01:00
|
|
|
struct qla_ddb_index *nt_ddb_idx;
|
|
|
|
|
|
|
|
fw_ddb_entry = dma_pool_alloc(ha->fw_ddb_dma_pool, GFP_KERNEL,
|
|
|
|
&fw_ddb_dma);
|
|
|
|
if (fw_ddb_entry == NULL) {
|
|
|
|
DEBUG2(ql4_printk(KERN_ERR, ha, "Out of memory\n"));
|
|
|
|
goto exit_nt_list;
|
2011-12-02 04:38:41 +01:00
|
|
|
}
|
2011-12-16 10:58:55 +01:00
|
|
|
max_ddbs = is_qla40XX(ha) ? MAX_DEV_DB_ENTRIES_40XX :
|
|
|
|
MAX_DEV_DB_ENTRIES;
|
|
|
|
fw_idx_size = sizeof(struct qla_ddb_index);
|
2011-12-02 04:38:41 +01:00
|
|
|
|
|
|
|
for (idx = 0; idx < max_ddbs; idx = next_idx) {
|
2011-12-16 10:58:55 +01:00
|
|
|
ret = qla4xxx_get_fwddb_entry(ha, idx, fw_ddb_entry, fw_ddb_dma,
|
|
|
|
NULL, &next_idx, &state,
|
|
|
|
&conn_err, NULL, &conn_id);
|
2011-12-02 04:38:41 +01:00
|
|
|
if (ret == QLA_ERROR)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (qla4xxx_verify_boot_idx(ha, idx) != QLA_SUCCESS)
|
|
|
|
goto continue_next_nt;
|
|
|
|
|
|
|
|
/* Check if NT, then add to list it */
|
|
|
|
if (strlen((char *) fw_ddb_entry->iscsi_name) == 0)
|
|
|
|
goto continue_next_nt;
|
|
|
|
|
2013-09-17 13:30:02 +02:00
|
|
|
ddb_link = le16_to_cpu(fw_ddb_entry->ddb_link);
|
|
|
|
if (ddb_link < max_ddbs)
|
|
|
|
qla4xxx_update_fw_ddb_link(ha, list_st, fw_ddb_entry);
|
|
|
|
|
2011-12-16 10:58:55 +01:00
|
|
|
if (!(state == DDB_DS_NO_CONNECTION_ACTIVE ||
|
2013-09-17 13:30:02 +02:00
|
|
|
state == DDB_DS_SESSION_FAILED) &&
|
|
|
|
(is_reset == INIT_ADAPTER))
|
2011-12-16 10:58:55 +01:00
|
|
|
goto continue_next_nt;
|
2011-12-02 04:38:41 +01:00
|
|
|
|
2011-12-16 10:58:55 +01:00
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha,
|
|
|
|
"Adding DDB to session = 0x%x\n", idx));
|
2013-09-17 13:30:02 +02:00
|
|
|
|
2011-12-16 10:58:55 +01:00
|
|
|
if (is_reset == INIT_ADAPTER) {
|
|
|
|
nt_ddb_idx = vmalloc(fw_idx_size);
|
|
|
|
if (!nt_ddb_idx)
|
|
|
|
break;
|
2011-12-02 04:38:41 +01:00
|
|
|
|
2011-12-16 10:58:55 +01:00
|
|
|
nt_ddb_idx->fw_ddb_idx = idx;
|
2011-12-02 04:38:41 +01:00
|
|
|
|
2012-06-14 12:35:48 +02:00
|
|
|
/* Copy original isid as it may get updated in function
|
|
|
|
* qla4xxx_update_isid(). We need original isid in
|
|
|
|
* function qla4xxx_compare_tuple_ddb to find duplicate
|
|
|
|
* target */
|
|
|
|
memcpy(&nt_ddb_idx->flash_isid[0],
|
|
|
|
&fw_ddb_entry->isid[0],
|
|
|
|
sizeof(nt_ddb_idx->flash_isid));
|
|
|
|
|
|
|
|
ret = qla4xxx_is_flash_ddb_exists(ha, list_nt,
|
|
|
|
fw_ddb_entry);
|
|
|
|
if (ret == QLA_SUCCESS) {
|
|
|
|
/* free nt_ddb_idx and do not add to list_nt */
|
2011-12-16 10:58:55 +01:00
|
|
|
vfree(nt_ddb_idx);
|
|
|
|
goto continue_next_nt;
|
2011-12-02 04:38:41 +01:00
|
|
|
}
|
2012-06-14 12:35:48 +02:00
|
|
|
|
|
|
|
/* Copy updated isid */
|
|
|
|
memcpy(&nt_ddb_idx->fw_ddb, fw_ddb_entry,
|
|
|
|
sizeof(struct dev_db_entry));
|
|
|
|
|
2011-12-16 10:58:55 +01:00
|
|
|
list_add_tail(&nt_ddb_idx->list, list_nt);
|
|
|
|
} else if (is_reset == RESET_ADAPTER) {
|
2013-09-17 13:30:02 +02:00
|
|
|
ret = qla4xxx_is_session_exists(ha, fw_ddb_entry,
|
|
|
|
&ddb_idx);
|
|
|
|
if (ret == QLA_SUCCESS) {
|
|
|
|
ddb_entry = qla4xxx_lookup_ddb_by_fw_index(ha,
|
|
|
|
ddb_idx);
|
|
|
|
if (ddb_entry != NULL)
|
|
|
|
qla4xxx_update_sess_disc_idx(ha,
|
|
|
|
ddb_entry,
|
|
|
|
fw_ddb_entry);
|
2011-12-16 10:58:55 +01:00
|
|
|
goto continue_next_nt;
|
2013-09-17 13:30:02 +02:00
|
|
|
}
|
2011-12-02 04:38:41 +01:00
|
|
|
}
|
2011-12-16 10:58:55 +01:00
|
|
|
|
2013-01-21 05:51:03 +01:00
|
|
|
ret = qla4xxx_sess_conn_setup(ha, fw_ddb_entry, is_reset, idx);
|
2011-12-16 10:58:55 +01:00
|
|
|
if (ret == QLA_ERROR)
|
|
|
|
goto exit_nt_list;
|
|
|
|
|
2011-12-02 04:38:41 +01:00
|
|
|
continue_next_nt:
|
|
|
|
if (next_idx == 0)
|
|
|
|
break;
|
|
|
|
}
|
2011-12-16 10:58:55 +01:00
|
|
|
|
|
|
|
exit_nt_list:
|
2011-12-02 04:38:41 +01:00
|
|
|
if (fw_ddb_entry)
|
|
|
|
dma_pool_free(ha->fw_ddb_dma_pool, fw_ddb_entry, fw_ddb_dma);
|
2011-12-16 10:58:55 +01:00
|
|
|
}
|
|
|
|
|
2013-03-22 12:41:31 +01:00
|
|
|
static void qla4xxx_build_new_nt_list(struct scsi_qla_host *ha,
|
2013-09-17 13:30:02 +02:00
|
|
|
struct list_head *list_nt,
|
|
|
|
uint16_t target_id)
|
2013-03-22 12:41:31 +01:00
|
|
|
{
|
|
|
|
struct dev_db_entry *fw_ddb_entry;
|
|
|
|
dma_addr_t fw_ddb_dma;
|
|
|
|
int max_ddbs;
|
|
|
|
int fw_idx_size;
|
|
|
|
int ret;
|
|
|
|
uint32_t idx = 0, next_idx = 0;
|
|
|
|
uint32_t state = 0, conn_err = 0;
|
|
|
|
uint16_t conn_id = 0;
|
|
|
|
struct qla_ddb_index *nt_ddb_idx;
|
|
|
|
|
|
|
|
fw_ddb_entry = dma_pool_alloc(ha->fw_ddb_dma_pool, GFP_KERNEL,
|
|
|
|
&fw_ddb_dma);
|
|
|
|
if (fw_ddb_entry == NULL) {
|
|
|
|
DEBUG2(ql4_printk(KERN_ERR, ha, "Out of memory\n"));
|
|
|
|
goto exit_new_nt_list;
|
|
|
|
}
|
|
|
|
max_ddbs = is_qla40XX(ha) ? MAX_DEV_DB_ENTRIES_40XX :
|
|
|
|
MAX_DEV_DB_ENTRIES;
|
|
|
|
fw_idx_size = sizeof(struct qla_ddb_index);
|
|
|
|
|
|
|
|
for (idx = 0; idx < max_ddbs; idx = next_idx) {
|
|
|
|
ret = qla4xxx_get_fwddb_entry(ha, idx, fw_ddb_entry, fw_ddb_dma,
|
|
|
|
NULL, &next_idx, &state,
|
|
|
|
&conn_err, NULL, &conn_id);
|
|
|
|
if (ret == QLA_ERROR)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Check if NT, then add it to list */
|
|
|
|
if (strlen((char *)fw_ddb_entry->iscsi_name) == 0)
|
|
|
|
goto continue_next_new_nt;
|
|
|
|
|
|
|
|
if (!(state == DDB_DS_NO_CONNECTION_ACTIVE))
|
|
|
|
goto continue_next_new_nt;
|
|
|
|
|
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha,
|
|
|
|
"Adding DDB to session = 0x%x\n", idx));
|
|
|
|
|
|
|
|
nt_ddb_idx = vmalloc(fw_idx_size);
|
|
|
|
if (!nt_ddb_idx)
|
|
|
|
break;
|
|
|
|
|
|
|
|
nt_ddb_idx->fw_ddb_idx = idx;
|
|
|
|
|
2013-09-17 13:30:02 +02:00
|
|
|
ret = qla4xxx_is_session_exists(ha, fw_ddb_entry, NULL);
|
2013-03-22 12:41:31 +01:00
|
|
|
if (ret == QLA_SUCCESS) {
|
|
|
|
/* free nt_ddb_idx and do not add to list_nt */
|
|
|
|
vfree(nt_ddb_idx);
|
|
|
|
goto continue_next_new_nt;
|
|
|
|
}
|
|
|
|
|
2013-09-17 13:30:02 +02:00
|
|
|
if (target_id < max_ddbs)
|
|
|
|
fw_ddb_entry->ddb_link = cpu_to_le16(target_id);
|
|
|
|
|
2013-03-22 12:41:31 +01:00
|
|
|
list_add_tail(&nt_ddb_idx->list, list_nt);
|
|
|
|
|
|
|
|
ret = qla4xxx_sess_conn_setup(ha, fw_ddb_entry, RESET_ADAPTER,
|
|
|
|
idx);
|
|
|
|
if (ret == QLA_ERROR)
|
|
|
|
goto exit_new_nt_list;
|
|
|
|
|
|
|
|
continue_next_new_nt:
|
|
|
|
if (next_idx == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
exit_new_nt_list:
|
|
|
|
if (fw_ddb_entry)
|
|
|
|
dma_pool_free(ha->fw_ddb_dma_pool, fw_ddb_entry, fw_ddb_dma);
|
|
|
|
}
|
|
|
|
|
2011-12-16 10:58:55 +01:00
|
|
|
/**
|
2013-03-22 12:41:31 +01:00
|
|
|
* qla4xxx_sysfs_ddb_is_non_persistent - check for non-persistence of ddb entry
|
|
|
|
* @dev: dev associated with the sysfs entry
|
|
|
|
* @data: pointer to flashnode session object
|
2011-12-16 10:58:55 +01:00
|
|
|
*
|
2013-03-22 12:41:31 +01:00
|
|
|
* Returns:
|
|
|
|
* 1: if flashnode entry is non-persistent
|
|
|
|
* 0: if flashnode entry is persistent
|
2011-12-16 10:58:55 +01:00
|
|
|
**/
|
2013-03-22 12:41:31 +01:00
|
|
|
static int qla4xxx_sysfs_ddb_is_non_persistent(struct device *dev, void *data)
|
2011-12-16 10:58:55 +01:00
|
|
|
{
|
2013-03-22 12:41:31 +01:00
|
|
|
struct iscsi_bus_flash_session *fnode_sess;
|
2011-12-16 10:58:55 +01:00
|
|
|
|
2013-03-22 12:41:31 +01:00
|
|
|
if (!iscsi_flashnode_bus_match(dev, NULL))
|
|
|
|
return 0;
|
2011-12-16 10:58:55 +01:00
|
|
|
|
2013-03-22 12:41:31 +01:00
|
|
|
fnode_sess = iscsi_dev_to_flash_session(dev);
|
2011-12-16 10:58:55 +01:00
|
|
|
|
2013-03-22 12:41:31 +01:00
|
|
|
return (fnode_sess->flash_state == DEV_DB_NON_PERSISTENT);
|
|
|
|
}
|
2011-12-16 10:58:55 +01:00
|
|
|
|
2013-03-22 12:41:31 +01:00
|
|
|
/**
|
|
|
|
* qla4xxx_sysfs_ddb_tgt_create - Create sysfs entry for target
|
|
|
|
* @ha: pointer to host
|
|
|
|
* @fw_ddb_entry: flash ddb data
|
|
|
|
* @idx: target index
|
|
|
|
* @user: if set then this call is made from userland else from kernel
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* On sucess: QLA_SUCCESS
|
|
|
|
* On failure: QLA_ERROR
|
|
|
|
*
|
|
|
|
* This create separate sysfs entries for session and connection attributes of
|
|
|
|
* the given fw ddb entry.
|
|
|
|
* If this is invoked as a result of a userspace call then the entry is marked
|
|
|
|
* as nonpersistent using flash_state field.
|
|
|
|
**/
|
2013-04-17 11:15:27 +02:00
|
|
|
static int qla4xxx_sysfs_ddb_tgt_create(struct scsi_qla_host *ha,
|
|
|
|
struct dev_db_entry *fw_ddb_entry,
|
|
|
|
uint16_t *idx, int user)
|
2013-03-22 12:41:31 +01:00
|
|
|
{
|
|
|
|
struct iscsi_bus_flash_session *fnode_sess = NULL;
|
|
|
|
struct iscsi_bus_flash_conn *fnode_conn = NULL;
|
|
|
|
int rc = QLA_ERROR;
|
2011-12-16 10:58:55 +01:00
|
|
|
|
2013-03-22 12:41:31 +01:00
|
|
|
fnode_sess = iscsi_create_flashnode_sess(ha->host, *idx,
|
|
|
|
&qla4xxx_iscsi_transport, 0);
|
|
|
|
if (!fnode_sess) {
|
|
|
|
ql4_printk(KERN_ERR, ha,
|
|
|
|
"%s: Unable to create session sysfs entry for flashnode %d of host%lu\n",
|
|
|
|
__func__, *idx, ha->host_no);
|
|
|
|
goto exit_tgt_create;
|
2011-12-16 10:58:55 +01:00
|
|
|
}
|
|
|
|
|
2013-03-22 12:41:31 +01:00
|
|
|
fnode_conn = iscsi_create_flashnode_conn(ha->host, fnode_sess,
|
|
|
|
&qla4xxx_iscsi_transport, 0);
|
|
|
|
if (!fnode_conn) {
|
|
|
|
ql4_printk(KERN_ERR, ha,
|
|
|
|
"%s: Unable to create conn sysfs entry for flashnode %d of host%lu\n",
|
|
|
|
__func__, *idx, ha->host_no);
|
|
|
|
goto free_sess;
|
|
|
|
}
|
2011-12-19 06:40:44 +01:00
|
|
|
|
2013-03-22 12:41:31 +01:00
|
|
|
if (user) {
|
|
|
|
fnode_sess->flash_state = DEV_DB_NON_PERSISTENT;
|
|
|
|
} else {
|
|
|
|
fnode_sess->flash_state = DEV_DB_PERSISTENT;
|
2011-12-16 10:58:55 +01:00
|
|
|
|
2013-03-22 12:41:31 +01:00
|
|
|
if (*idx == ha->pri_ddb_idx || *idx == ha->sec_ddb_idx)
|
|
|
|
fnode_sess->is_boot_target = 1;
|
|
|
|
else
|
|
|
|
fnode_sess->is_boot_target = 0;
|
|
|
|
}
|
2011-12-16 10:58:57 +01:00
|
|
|
|
2013-03-22 12:41:31 +01:00
|
|
|
rc = qla4xxx_copy_from_fwddb_param(fnode_sess, fnode_conn,
|
|
|
|
fw_ddb_entry);
|
2011-12-16 10:58:55 +01:00
|
|
|
|
2013-03-22 12:41:31 +01:00
|
|
|
ql4_printk(KERN_INFO, ha, "%s: sysfs entry %s created\n",
|
|
|
|
__func__, fnode_sess->dev.kobj.name);
|
2011-12-16 10:58:55 +01:00
|
|
|
|
2013-03-22 12:41:31 +01:00
|
|
|
ql4_printk(KERN_INFO, ha, "%s: sysfs entry %s created\n",
|
|
|
|
__func__, fnode_conn->dev.kobj.name);
|
2011-12-16 10:58:55 +01:00
|
|
|
|
2013-03-22 12:41:31 +01:00
|
|
|
return QLA_SUCCESS;
|
2011-12-02 04:38:41 +01:00
|
|
|
|
2013-03-22 12:41:31 +01:00
|
|
|
free_sess:
|
|
|
|
iscsi_destroy_flashnode_sess(fnode_sess);
|
|
|
|
|
|
|
|
exit_tgt_create:
|
|
|
|
return QLA_ERROR;
|
2011-12-02 04:38:41 +01:00
|
|
|
}
|
|
|
|
|
2013-01-21 05:51:03 +01:00
|
|
|
/**
|
2013-03-22 12:41:31 +01:00
|
|
|
* qla4xxx_sysfs_ddb_add - Add new ddb entry in flash
|
|
|
|
* @shost: pointer to host
|
|
|
|
* @buf: type of ddb entry (ipv4/ipv6)
|
|
|
|
* @len: length of buf
|
2013-01-21 05:51:03 +01:00
|
|
|
*
|
2013-03-22 12:41:31 +01:00
|
|
|
* This creates new ddb entry in the flash by finding first free index and
|
|
|
|
* storing default ddb there. And then create sysfs entry for the new ddb entry.
|
2013-01-21 05:51:03 +01:00
|
|
|
**/
|
2013-03-22 12:41:31 +01:00
|
|
|
static int qla4xxx_sysfs_ddb_add(struct Scsi_Host *shost, const char *buf,
|
|
|
|
int len)
|
2013-01-21 05:51:03 +01:00
|
|
|
{
|
2013-03-22 12:41:31 +01:00
|
|
|
struct scsi_qla_host *ha = to_qla_host(shost);
|
2013-01-21 05:51:03 +01:00
|
|
|
struct dev_db_entry *fw_ddb_entry = NULL;
|
|
|
|
dma_addr_t fw_ddb_entry_dma;
|
2013-03-22 12:41:31 +01:00
|
|
|
struct device *dev;
|
|
|
|
uint16_t idx = 0;
|
|
|
|
uint16_t max_ddbs = 0;
|
|
|
|
uint32_t options = 0;
|
|
|
|
uint32_t rval = QLA_ERROR;
|
|
|
|
|
2013-03-25 13:08:32 +01:00
|
|
|
if (strncasecmp(PORTAL_TYPE_IPV4, buf, 4) &&
|
|
|
|
strncasecmp(PORTAL_TYPE_IPV6, buf, 4)) {
|
2013-03-22 12:41:31 +01:00
|
|
|
DEBUG2(ql4_printk(KERN_ERR, ha, "%s: Invalid portal type\n",
|
|
|
|
__func__));
|
|
|
|
goto exit_ddb_add;
|
|
|
|
}
|
2013-01-21 05:51:03 +01:00
|
|
|
|
2013-04-05 13:06:08 +02:00
|
|
|
max_ddbs = is_qla40XX(ha) ? MAX_PRST_DEV_DB_ENTRIES :
|
2013-01-21 05:51:03 +01:00
|
|
|
MAX_DEV_DB_ENTRIES;
|
|
|
|
|
|
|
|
fw_ddb_entry = dma_alloc_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry),
|
|
|
|
&fw_ddb_entry_dma, GFP_KERNEL);
|
|
|
|
if (!fw_ddb_entry) {
|
2013-03-22 12:41:31 +01:00
|
|
|
DEBUG2(ql4_printk(KERN_ERR, ha,
|
|
|
|
"%s: Unable to allocate dma buffer\n",
|
|
|
|
__func__));
|
|
|
|
goto exit_ddb_add;
|
2013-01-21 05:51:03 +01:00
|
|
|
}
|
|
|
|
|
2013-03-22 12:41:31 +01:00
|
|
|
dev = iscsi_find_flashnode_sess(ha->host, NULL,
|
|
|
|
qla4xxx_sysfs_ddb_is_non_persistent);
|
|
|
|
if (dev) {
|
|
|
|
ql4_printk(KERN_ERR, ha,
|
|
|
|
"%s: A non-persistent entry %s found\n",
|
|
|
|
__func__, dev->kobj.name);
|
2013-05-06 19:06:56 +02:00
|
|
|
put_device(dev);
|
2013-03-22 12:41:31 +01:00
|
|
|
goto exit_ddb_add;
|
|
|
|
}
|
2013-01-21 05:51:03 +01:00
|
|
|
|
2013-07-08 14:33:09 +02:00
|
|
|
/* Index 0 and 1 are reserved for boot target entries */
|
|
|
|
for (idx = 2; idx < max_ddbs; idx++) {
|
2013-03-22 12:41:31 +01:00
|
|
|
if (qla4xxx_flashdb_by_index(ha, fw_ddb_entry,
|
|
|
|
fw_ddb_entry_dma, idx))
|
|
|
|
break;
|
|
|
|
}
|
2013-01-21 05:51:03 +01:00
|
|
|
|
2013-03-22 12:41:31 +01:00
|
|
|
if (idx == max_ddbs)
|
|
|
|
goto exit_ddb_add;
|
2013-01-21 05:51:03 +01:00
|
|
|
|
2013-03-22 12:41:31 +01:00
|
|
|
if (!strncasecmp("ipv6", buf, 4))
|
|
|
|
options |= IPV6_DEFAULT_DDB_ENTRY;
|
2013-01-21 05:51:03 +01:00
|
|
|
|
2013-03-22 12:41:31 +01:00
|
|
|
rval = qla4xxx_get_default_ddb(ha, options, fw_ddb_entry_dma);
|
|
|
|
if (rval == QLA_ERROR)
|
|
|
|
goto exit_ddb_add;
|
2013-01-21 05:51:03 +01:00
|
|
|
|
2013-03-22 12:41:31 +01:00
|
|
|
rval = qla4xxx_sysfs_ddb_tgt_create(ha, fw_ddb_entry, &idx, 1);
|
2013-01-21 05:51:03 +01:00
|
|
|
|
2013-03-22 12:41:31 +01:00
|
|
|
exit_ddb_add:
|
2013-01-21 05:51:03 +01:00
|
|
|
if (fw_ddb_entry)
|
|
|
|
dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry),
|
|
|
|
fw_ddb_entry, fw_ddb_entry_dma);
|
2013-03-22 12:41:31 +01:00
|
|
|
if (rval == QLA_SUCCESS)
|
|
|
|
return idx;
|
|
|
|
else
|
|
|
|
return -EIO;
|
2013-01-21 05:51:03 +01:00
|
|
|
}
|
|
|
|
|
2006-09-19 19:28:00 +02:00
|
|
|
/**
|
2013-03-22 12:41:31 +01:00
|
|
|
* qla4xxx_sysfs_ddb_apply - write the target ddb contents to Flash
|
|
|
|
* @fnode_sess: pointer to session attrs of flash ddb entry
|
|
|
|
* @fnode_conn: pointer to connection attrs of flash ddb entry
|
2006-09-19 19:28:00 +02:00
|
|
|
*
|
2013-03-22 12:41:31 +01:00
|
|
|
* This writes the contents of target ddb buffer to Flash with a valid cookie
|
|
|
|
* value in order to make the ddb entry persistent.
|
2006-09-19 19:28:00 +02:00
|
|
|
**/
|
2013-03-22 12:41:31 +01:00
|
|
|
static int qla4xxx_sysfs_ddb_apply(struct iscsi_bus_flash_session *fnode_sess,
|
|
|
|
struct iscsi_bus_flash_conn *fnode_conn)
|
2006-09-19 19:28:00 +02:00
|
|
|
{
|
2013-03-22 12:41:31 +01:00
|
|
|
struct Scsi_Host *shost = iscsi_flash_session_to_shost(fnode_sess);
|
|
|
|
struct scsi_qla_host *ha = to_qla_host(shost);
|
|
|
|
uint32_t dev_db_start_offset = FLASH_OFFSET_DB_INFO;
|
|
|
|
struct dev_db_entry *fw_ddb_entry = NULL;
|
|
|
|
dma_addr_t fw_ddb_entry_dma;
|
|
|
|
uint32_t options = 0;
|
|
|
|
int rval = 0;
|
2006-09-19 19:28:00 +02:00
|
|
|
|
2013-03-22 12:41:31 +01:00
|
|
|
fw_ddb_entry = dma_alloc_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry),
|
|
|
|
&fw_ddb_entry_dma, GFP_KERNEL);
|
|
|
|
if (!fw_ddb_entry) {
|
|
|
|
DEBUG2(ql4_printk(KERN_ERR, ha,
|
|
|
|
"%s: Unable to allocate dma buffer\n",
|
|
|
|
__func__));
|
|
|
|
rval = -ENOMEM;
|
|
|
|
goto exit_ddb_apply;
|
|
|
|
}
|
2006-09-19 19:28:00 +02:00
|
|
|
|
2013-03-25 13:08:32 +01:00
|
|
|
if (!strncasecmp(fnode_sess->portal_type, PORTAL_TYPE_IPV6, 4))
|
2013-03-22 12:41:31 +01:00
|
|
|
options |= IPV6_DEFAULT_DDB_ENTRY;
|
|
|
|
|
|
|
|
rval = qla4xxx_get_default_ddb(ha, options, fw_ddb_entry_dma);
|
|
|
|
if (rval == QLA_ERROR)
|
|
|
|
goto exit_ddb_apply;
|
|
|
|
|
|
|
|
dev_db_start_offset += (fnode_sess->target_id *
|
|
|
|
sizeof(*fw_ddb_entry));
|
|
|
|
|
|
|
|
qla4xxx_copy_to_fwddb_param(fnode_sess, fnode_conn, fw_ddb_entry);
|
|
|
|
fw_ddb_entry->cookie = DDB_VALID_COOKIE;
|
|
|
|
|
|
|
|
rval = qla4xxx_set_flash(ha, fw_ddb_entry_dma, dev_db_start_offset,
|
|
|
|
sizeof(*fw_ddb_entry), FLASH_OPT_RMW_COMMIT);
|
|
|
|
|
|
|
|
if (rval == QLA_SUCCESS) {
|
|
|
|
fnode_sess->flash_state = DEV_DB_PERSISTENT;
|
|
|
|
ql4_printk(KERN_INFO, ha,
|
|
|
|
"%s: flash node %u of host %lu written to flash\n",
|
|
|
|
__func__, fnode_sess->target_id, ha->host_no);
|
|
|
|
} else {
|
|
|
|
rval = -EIO;
|
|
|
|
ql4_printk(KERN_ERR, ha,
|
|
|
|
"%s: Error while writing flash node %u of host %lu to flash\n",
|
|
|
|
__func__, fnode_sess->target_id, ha->host_no);
|
|
|
|
}
|
|
|
|
|
|
|
|
exit_ddb_apply:
|
|
|
|
if (fw_ddb_entry)
|
|
|
|
dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry),
|
|
|
|
fw_ddb_entry, fw_ddb_entry_dma);
|
|
|
|
return rval;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t qla4xxx_sysfs_ddb_conn_open(struct scsi_qla_host *ha,
|
|
|
|
struct dev_db_entry *fw_ddb_entry,
|
|
|
|
uint16_t idx)
|
|
|
|
{
|
|
|
|
struct dev_db_entry *ddb_entry = NULL;
|
|
|
|
dma_addr_t ddb_entry_dma;
|
|
|
|
unsigned long wtime;
|
|
|
|
uint32_t mbx_sts = 0;
|
|
|
|
uint32_t state = 0, conn_err = 0;
|
|
|
|
uint16_t tmo = 0;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
ddb_entry = dma_alloc_coherent(&ha->pdev->dev, sizeof(*ddb_entry),
|
|
|
|
&ddb_entry_dma, GFP_KERNEL);
|
|
|
|
if (!ddb_entry) {
|
|
|
|
DEBUG2(ql4_printk(KERN_ERR, ha,
|
|
|
|
"%s: Unable to allocate dma buffer\n",
|
|
|
|
__func__));
|
|
|
|
return QLA_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(ddb_entry, fw_ddb_entry, sizeof(*ddb_entry));
|
|
|
|
|
|
|
|
ret = qla4xxx_set_ddb_entry(ha, idx, ddb_entry_dma, &mbx_sts);
|
|
|
|
if (ret != QLA_SUCCESS) {
|
|
|
|
DEBUG2(ql4_printk(KERN_ERR, ha,
|
|
|
|
"%s: Unable to set ddb entry for index %d\n",
|
|
|
|
__func__, idx));
|
|
|
|
goto exit_ddb_conn_open;
|
|
|
|
}
|
|
|
|
|
|
|
|
qla4xxx_conn_open(ha, idx);
|
|
|
|
|
|
|
|
/* To ensure that sendtargets is done, wait for at least 12 secs */
|
|
|
|
tmo = ((ha->def_timeout > LOGIN_TOV) &&
|
|
|
|
(ha->def_timeout < LOGIN_TOV * 10) ?
|
|
|
|
ha->def_timeout : LOGIN_TOV);
|
|
|
|
|
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha,
|
|
|
|
"Default time to wait for login to ddb %d\n", tmo));
|
|
|
|
|
|
|
|
wtime = jiffies + (HZ * tmo);
|
|
|
|
do {
|
|
|
|
ret = qla4xxx_get_fwddb_entry(ha, idx, NULL, 0, NULL,
|
|
|
|
NULL, &state, &conn_err, NULL,
|
|
|
|
NULL);
|
|
|
|
if (ret == QLA_ERROR)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (state == DDB_DS_NO_CONNECTION_ACTIVE ||
|
|
|
|
state == DDB_DS_SESSION_FAILED)
|
|
|
|
break;
|
|
|
|
|
|
|
|
schedule_timeout_uninterruptible(HZ / 10);
|
|
|
|
} while (time_after(wtime, jiffies));
|
|
|
|
|
|
|
|
exit_ddb_conn_open:
|
|
|
|
if (ddb_entry)
|
|
|
|
dma_free_coherent(&ha->pdev->dev, sizeof(*ddb_entry),
|
|
|
|
ddb_entry, ddb_entry_dma);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int qla4xxx_ddb_login_st(struct scsi_qla_host *ha,
|
2013-09-17 13:30:02 +02:00
|
|
|
struct dev_db_entry *fw_ddb_entry,
|
|
|
|
uint16_t target_id)
|
2013-03-22 12:41:31 +01:00
|
|
|
{
|
|
|
|
struct qla_ddb_index *ddb_idx, *ddb_idx_tmp;
|
|
|
|
struct list_head list_nt;
|
|
|
|
uint16_t ddb_index;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
if (test_bit(AF_ST_DISCOVERY_IN_PROGRESS, &ha->flags)) {
|
|
|
|
ql4_printk(KERN_WARNING, ha,
|
|
|
|
"%s: A discovery already in progress!\n", __func__);
|
|
|
|
return QLA_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
INIT_LIST_HEAD(&list_nt);
|
|
|
|
|
|
|
|
set_bit(AF_ST_DISCOVERY_IN_PROGRESS, &ha->flags);
|
|
|
|
|
|
|
|
ret = qla4xxx_get_ddb_index(ha, &ddb_index);
|
|
|
|
if (ret == QLA_ERROR)
|
|
|
|
goto exit_login_st_clr_bit;
|
|
|
|
|
|
|
|
ret = qla4xxx_sysfs_ddb_conn_open(ha, fw_ddb_entry, ddb_index);
|
|
|
|
if (ret == QLA_ERROR)
|
|
|
|
goto exit_login_st;
|
|
|
|
|
2013-09-17 13:30:02 +02:00
|
|
|
qla4xxx_build_new_nt_list(ha, &list_nt, target_id);
|
2013-03-22 12:41:31 +01:00
|
|
|
|
|
|
|
list_for_each_entry_safe(ddb_idx, ddb_idx_tmp, &list_nt, list) {
|
|
|
|
list_del_init(&ddb_idx->list);
|
|
|
|
qla4xxx_clear_ddb_entry(ha, ddb_idx->fw_ddb_idx);
|
|
|
|
vfree(ddb_idx);
|
|
|
|
}
|
|
|
|
|
|
|
|
exit_login_st:
|
|
|
|
if (qla4xxx_clear_ddb_entry(ha, ddb_index) == QLA_ERROR) {
|
|
|
|
ql4_printk(KERN_ERR, ha,
|
|
|
|
"Unable to clear DDB index = 0x%x\n", ddb_index);
|
|
|
|
}
|
|
|
|
|
|
|
|
clear_bit(ddb_index, ha->ddb_idx_map);
|
|
|
|
|
|
|
|
exit_login_st_clr_bit:
|
|
|
|
clear_bit(AF_ST_DISCOVERY_IN_PROGRESS, &ha->flags);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int qla4xxx_ddb_login_nt(struct scsi_qla_host *ha,
|
|
|
|
struct dev_db_entry *fw_ddb_entry,
|
|
|
|
uint16_t idx)
|
|
|
|
{
|
|
|
|
int ret = QLA_ERROR;
|
|
|
|
|
2013-09-17 13:30:02 +02:00
|
|
|
ret = qla4xxx_is_session_exists(ha, fw_ddb_entry, NULL);
|
2013-03-22 12:41:31 +01:00
|
|
|
if (ret != QLA_SUCCESS)
|
|
|
|
ret = qla4xxx_sess_conn_setup(ha, fw_ddb_entry, RESET_ADAPTER,
|
|
|
|
idx);
|
|
|
|
else
|
|
|
|
ret = -EPERM;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* qla4xxx_sysfs_ddb_login - Login to the specified target
|
|
|
|
* @fnode_sess: pointer to session attrs of flash ddb entry
|
|
|
|
* @fnode_conn: pointer to connection attrs of flash ddb entry
|
|
|
|
*
|
|
|
|
* This logs in to the specified target
|
|
|
|
**/
|
|
|
|
static int qla4xxx_sysfs_ddb_login(struct iscsi_bus_flash_session *fnode_sess,
|
|
|
|
struct iscsi_bus_flash_conn *fnode_conn)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = iscsi_flash_session_to_shost(fnode_sess);
|
|
|
|
struct scsi_qla_host *ha = to_qla_host(shost);
|
|
|
|
struct dev_db_entry *fw_ddb_entry = NULL;
|
|
|
|
dma_addr_t fw_ddb_entry_dma;
|
|
|
|
uint32_t options = 0;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
if (fnode_sess->flash_state == DEV_DB_NON_PERSISTENT) {
|
|
|
|
ql4_printk(KERN_ERR, ha,
|
|
|
|
"%s: Target info is not persistent\n", __func__);
|
|
|
|
ret = -EIO;
|
|
|
|
goto exit_ddb_login;
|
|
|
|
}
|
|
|
|
|
|
|
|
fw_ddb_entry = dma_alloc_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry),
|
|
|
|
&fw_ddb_entry_dma, GFP_KERNEL);
|
|
|
|
if (!fw_ddb_entry) {
|
|
|
|
DEBUG2(ql4_printk(KERN_ERR, ha,
|
|
|
|
"%s: Unable to allocate dma buffer\n",
|
|
|
|
__func__));
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto exit_ddb_login;
|
|
|
|
}
|
|
|
|
|
2013-03-25 13:08:32 +01:00
|
|
|
if (!strncasecmp(fnode_sess->portal_type, PORTAL_TYPE_IPV6, 4))
|
2013-03-22 12:41:31 +01:00
|
|
|
options |= IPV6_DEFAULT_DDB_ENTRY;
|
|
|
|
|
|
|
|
ret = qla4xxx_get_default_ddb(ha, options, fw_ddb_entry_dma);
|
|
|
|
if (ret == QLA_ERROR)
|
|
|
|
goto exit_ddb_login;
|
|
|
|
|
|
|
|
qla4xxx_copy_to_fwddb_param(fnode_sess, fnode_conn, fw_ddb_entry);
|
|
|
|
fw_ddb_entry->cookie = DDB_VALID_COOKIE;
|
|
|
|
|
|
|
|
if (strlen((char *)fw_ddb_entry->iscsi_name) == 0)
|
2013-09-17 13:30:02 +02:00
|
|
|
ret = qla4xxx_ddb_login_st(ha, fw_ddb_entry,
|
|
|
|
fnode_sess->target_id);
|
2013-03-22 12:41:31 +01:00
|
|
|
else
|
|
|
|
ret = qla4xxx_ddb_login_nt(ha, fw_ddb_entry,
|
|
|
|
fnode_sess->target_id);
|
|
|
|
|
|
|
|
if (ret > 0)
|
|
|
|
ret = -EIO;
|
|
|
|
|
|
|
|
exit_ddb_login:
|
|
|
|
if (fw_ddb_entry)
|
|
|
|
dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry),
|
|
|
|
fw_ddb_entry, fw_ddb_entry_dma);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* qla4xxx_sysfs_ddb_logout_sid - Logout session for the specified target
|
|
|
|
* @cls_sess: pointer to session to be logged out
|
|
|
|
*
|
|
|
|
* This performs session log out from the specified target
|
|
|
|
**/
|
|
|
|
static int qla4xxx_sysfs_ddb_logout_sid(struct iscsi_cls_session *cls_sess)
|
|
|
|
{
|
|
|
|
struct iscsi_session *sess;
|
|
|
|
struct ddb_entry *ddb_entry = NULL;
|
|
|
|
struct scsi_qla_host *ha;
|
|
|
|
struct dev_db_entry *fw_ddb_entry = NULL;
|
|
|
|
dma_addr_t fw_ddb_entry_dma;
|
|
|
|
unsigned long flags;
|
|
|
|
unsigned long wtime;
|
|
|
|
uint32_t ddb_state;
|
|
|
|
int options;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
sess = cls_sess->dd_data;
|
|
|
|
ddb_entry = sess->dd_data;
|
|
|
|
ha = ddb_entry->ha;
|
|
|
|
|
|
|
|
if (ddb_entry->ddb_type != FLASH_DDB) {
|
|
|
|
ql4_printk(KERN_ERR, ha, "%s: Not a flash node session\n",
|
|
|
|
__func__);
|
|
|
|
ret = -ENXIO;
|
|
|
|
goto exit_ddb_logout;
|
|
|
|
}
|
|
|
|
|
2013-04-05 13:06:07 +02:00
|
|
|
if (test_bit(DF_BOOT_TGT, &ddb_entry->flags)) {
|
|
|
|
ql4_printk(KERN_ERR, ha,
|
|
|
|
"%s: Logout from boot target entry is not permitted.\n",
|
|
|
|
__func__);
|
|
|
|
ret = -EPERM;
|
|
|
|
goto exit_ddb_logout;
|
|
|
|
}
|
|
|
|
|
2013-03-22 12:41:31 +01:00
|
|
|
fw_ddb_entry = dma_alloc_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry),
|
|
|
|
&fw_ddb_entry_dma, GFP_KERNEL);
|
|
|
|
if (!fw_ddb_entry) {
|
|
|
|
ql4_printk(KERN_ERR, ha,
|
|
|
|
"%s: Unable to allocate dma buffer\n", __func__);
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto exit_ddb_logout;
|
|
|
|
}
|
|
|
|
|
2013-07-08 14:33:05 +02:00
|
|
|
if (test_and_set_bit(DF_DISABLE_RELOGIN, &ddb_entry->flags))
|
|
|
|
goto ddb_logout_init;
|
|
|
|
|
|
|
|
ret = qla4xxx_get_fwddb_entry(ha, ddb_entry->fw_ddb_index,
|
|
|
|
fw_ddb_entry, fw_ddb_entry_dma,
|
|
|
|
NULL, NULL, &ddb_state, NULL,
|
|
|
|
NULL, NULL);
|
|
|
|
if (ret == QLA_ERROR)
|
|
|
|
goto ddb_logout_init;
|
|
|
|
|
|
|
|
if (ddb_state == DDB_DS_SESSION_ACTIVE)
|
|
|
|
goto ddb_logout_init;
|
|
|
|
|
|
|
|
/* wait until next relogin is triggered using DF_RELOGIN and
|
|
|
|
* clear DF_RELOGIN to avoid invocation of further relogin
|
|
|
|
*/
|
|
|
|
wtime = jiffies + (HZ * RELOGIN_TOV);
|
|
|
|
do {
|
|
|
|
if (test_and_clear_bit(DF_RELOGIN, &ddb_entry->flags))
|
|
|
|
goto ddb_logout_init;
|
|
|
|
|
|
|
|
schedule_timeout_uninterruptible(HZ);
|
|
|
|
} while ((time_after(wtime, jiffies)));
|
|
|
|
|
|
|
|
ddb_logout_init:
|
|
|
|
atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
|
|
|
|
atomic_set(&ddb_entry->relogin_timer, 0);
|
|
|
|
|
|
|
|
options = LOGOUT_OPTION_CLOSE_SESSION;
|
|
|
|
qla4xxx_session_logout_ddb(ha, ddb_entry, options);
|
|
|
|
|
|
|
|
memset(fw_ddb_entry, 0, sizeof(*fw_ddb_entry));
|
2013-03-22 12:41:31 +01:00
|
|
|
wtime = jiffies + (HZ * LOGOUT_TOV);
|
|
|
|
do {
|
|
|
|
ret = qla4xxx_get_fwddb_entry(ha, ddb_entry->fw_ddb_index,
|
|
|
|
fw_ddb_entry, fw_ddb_entry_dma,
|
|
|
|
NULL, NULL, &ddb_state, NULL,
|
|
|
|
NULL, NULL);
|
|
|
|
if (ret == QLA_ERROR)
|
|
|
|
goto ddb_logout_clr_sess;
|
|
|
|
|
|
|
|
if ((ddb_state == DDB_DS_NO_CONNECTION_ACTIVE) ||
|
|
|
|
(ddb_state == DDB_DS_SESSION_FAILED))
|
|
|
|
goto ddb_logout_clr_sess;
|
|
|
|
|
|
|
|
schedule_timeout_uninterruptible(HZ);
|
|
|
|
} while ((time_after(wtime, jiffies)));
|
|
|
|
|
|
|
|
ddb_logout_clr_sess:
|
|
|
|
qla4xxx_clear_ddb_entry(ha, ddb_entry->fw_ddb_index);
|
|
|
|
/*
|
|
|
|
* we have decremented the reference count of the driver
|
|
|
|
* when we setup the session to have the driver unload
|
|
|
|
* to be seamless without actually destroying the
|
|
|
|
* session
|
|
|
|
**/
|
|
|
|
try_module_get(qla4xxx_iscsi_transport.owner);
|
|
|
|
iscsi_destroy_endpoint(ddb_entry->conn->ep);
|
|
|
|
|
|
|
|
spin_lock_irqsave(&ha->hardware_lock, flags);
|
|
|
|
qla4xxx_free_ddb(ha, ddb_entry);
|
2013-07-08 14:33:05 +02:00
|
|
|
clear_bit(ddb_entry->fw_ddb_index, ha->ddb_idx_map);
|
2013-03-22 12:41:31 +01:00
|
|
|
spin_unlock_irqrestore(&ha->hardware_lock, flags);
|
|
|
|
|
|
|
|
iscsi_session_teardown(ddb_entry->sess);
|
|
|
|
|
2013-07-08 14:33:05 +02:00
|
|
|
clear_bit(DF_DISABLE_RELOGIN, &ddb_entry->flags);
|
2013-03-22 12:41:31 +01:00
|
|
|
ret = QLA_SUCCESS;
|
|
|
|
|
|
|
|
exit_ddb_logout:
|
|
|
|
if (fw_ddb_entry)
|
|
|
|
dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry),
|
|
|
|
fw_ddb_entry, fw_ddb_entry_dma);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* qla4xxx_sysfs_ddb_logout - Logout from the specified target
|
|
|
|
* @fnode_sess: pointer to session attrs of flash ddb entry
|
|
|
|
* @fnode_conn: pointer to connection attrs of flash ddb entry
|
|
|
|
*
|
|
|
|
* This performs log out from the specified target
|
|
|
|
**/
|
|
|
|
static int qla4xxx_sysfs_ddb_logout(struct iscsi_bus_flash_session *fnode_sess,
|
|
|
|
struct iscsi_bus_flash_conn *fnode_conn)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = iscsi_flash_session_to_shost(fnode_sess);
|
|
|
|
struct scsi_qla_host *ha = to_qla_host(shost);
|
|
|
|
struct ql4_tuple_ddb *flash_tddb = NULL;
|
|
|
|
struct ql4_tuple_ddb *tmp_tddb = NULL;
|
|
|
|
struct dev_db_entry *fw_ddb_entry = NULL;
|
|
|
|
struct ddb_entry *ddb_entry = NULL;
|
|
|
|
dma_addr_t fw_ddb_dma;
|
|
|
|
uint32_t next_idx = 0;
|
|
|
|
uint32_t state = 0, conn_err = 0;
|
|
|
|
uint16_t conn_id = 0;
|
|
|
|
int idx, index;
|
|
|
|
int status, ret = 0;
|
|
|
|
|
|
|
|
fw_ddb_entry = dma_pool_alloc(ha->fw_ddb_dma_pool, GFP_KERNEL,
|
|
|
|
&fw_ddb_dma);
|
|
|
|
if (fw_ddb_entry == NULL) {
|
|
|
|
ql4_printk(KERN_ERR, ha, "%s:Out of memory\n", __func__);
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto exit_ddb_logout;
|
|
|
|
}
|
|
|
|
|
|
|
|
flash_tddb = vzalloc(sizeof(*flash_tddb));
|
|
|
|
if (!flash_tddb) {
|
|
|
|
ql4_printk(KERN_WARNING, ha,
|
|
|
|
"%s:Memory Allocation failed.\n", __func__);
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto exit_ddb_logout;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp_tddb = vzalloc(sizeof(*tmp_tddb));
|
|
|
|
if (!tmp_tddb) {
|
|
|
|
ql4_printk(KERN_WARNING, ha,
|
|
|
|
"%s:Memory Allocation failed.\n", __func__);
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto exit_ddb_logout;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!fnode_sess->targetname) {
|
|
|
|
ql4_printk(KERN_ERR, ha,
|
|
|
|
"%s:Cannot logout from SendTarget entry\n",
|
|
|
|
__func__);
|
|
|
|
ret = -EPERM;
|
|
|
|
goto exit_ddb_logout;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fnode_sess->is_boot_target) {
|
|
|
|
ql4_printk(KERN_ERR, ha,
|
|
|
|
"%s: Logout from boot target entry is not permitted.\n",
|
|
|
|
__func__);
|
|
|
|
ret = -EPERM;
|
|
|
|
goto exit_ddb_logout;
|
|
|
|
}
|
|
|
|
|
2014-07-26 16:49:32 +02:00
|
|
|
strlcpy(flash_tddb->iscsi_name, fnode_sess->targetname,
|
2013-03-22 12:41:31 +01:00
|
|
|
ISCSI_NAME_SIZE);
|
|
|
|
|
2013-03-25 13:08:32 +01:00
|
|
|
if (!strncmp(fnode_sess->portal_type, PORTAL_TYPE_IPV6, 4))
|
2013-03-22 12:41:31 +01:00
|
|
|
sprintf(flash_tddb->ip_addr, "%pI6", fnode_conn->ipaddress);
|
|
|
|
else
|
|
|
|
sprintf(flash_tddb->ip_addr, "%pI4", fnode_conn->ipaddress);
|
|
|
|
|
|
|
|
flash_tddb->tpgt = fnode_sess->tpgt;
|
|
|
|
flash_tddb->port = fnode_conn->port;
|
|
|
|
|
|
|
|
COPY_ISID(flash_tddb->isid, fnode_sess->isid);
|
|
|
|
|
|
|
|
for (idx = 0; idx < MAX_DDB_ENTRIES; idx++) {
|
|
|
|
ddb_entry = qla4xxx_lookup_ddb_by_fw_index(ha, idx);
|
|
|
|
if (ddb_entry == NULL)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (ddb_entry->ddb_type != FLASH_DDB)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
index = ddb_entry->sess->target_id;
|
|
|
|
status = qla4xxx_get_fwddb_entry(ha, index, fw_ddb_entry,
|
|
|
|
fw_ddb_dma, NULL, &next_idx,
|
|
|
|
&state, &conn_err, NULL,
|
|
|
|
&conn_id);
|
|
|
|
if (status == QLA_ERROR) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
qla4xxx_convert_param_ddb(fw_ddb_entry, tmp_tddb, NULL);
|
|
|
|
|
|
|
|
status = qla4xxx_compare_tuple_ddb(ha, flash_tddb, tmp_tddb,
|
|
|
|
true);
|
|
|
|
if (status == QLA_SUCCESS) {
|
|
|
|
ret = qla4xxx_sysfs_ddb_logout_sid(ddb_entry->sess);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (idx == MAX_DDB_ENTRIES)
|
|
|
|
ret = -ESRCH;
|
|
|
|
|
|
|
|
exit_ddb_logout:
|
|
|
|
if (flash_tddb)
|
|
|
|
vfree(flash_tddb);
|
|
|
|
if (tmp_tddb)
|
|
|
|
vfree(tmp_tddb);
|
|
|
|
if (fw_ddb_entry)
|
|
|
|
dma_pool_free(ha->fw_ddb_dma_pool, fw_ddb_entry, fw_ddb_dma);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
qla4xxx_sysfs_ddb_get_param(struct iscsi_bus_flash_session *fnode_sess,
|
|
|
|
int param, char *buf)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = iscsi_flash_session_to_shost(fnode_sess);
|
|
|
|
struct scsi_qla_host *ha = to_qla_host(shost);
|
|
|
|
struct iscsi_bus_flash_conn *fnode_conn;
|
|
|
|
struct ql4_chap_table chap_tbl;
|
|
|
|
struct device *dev;
|
2013-07-08 14:33:08 +02:00
|
|
|
int parent_type;
|
2013-03-22 12:41:31 +01:00
|
|
|
int rc = 0;
|
|
|
|
|
2013-05-06 19:06:56 +02:00
|
|
|
dev = iscsi_find_flashnode_conn(fnode_sess);
|
2013-03-22 12:41:31 +01:00
|
|
|
if (!dev)
|
|
|
|
return -EIO;
|
|
|
|
|
|
|
|
fnode_conn = iscsi_dev_to_flash_conn(dev);
|
|
|
|
|
|
|
|
switch (param) {
|
|
|
|
case ISCSI_FLASHNODE_IS_FW_ASSIGNED_IPV6:
|
|
|
|
rc = sprintf(buf, "%u\n", fnode_conn->is_fw_assigned_ipv6);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_PORTAL_TYPE:
|
|
|
|
rc = sprintf(buf, "%s\n", fnode_sess->portal_type);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_AUTO_SND_TGT_DISABLE:
|
|
|
|
rc = sprintf(buf, "%u\n", fnode_sess->auto_snd_tgt_disable);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_DISCOVERY_SESS:
|
|
|
|
rc = sprintf(buf, "%u\n", fnode_sess->discovery_sess);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_ENTRY_EN:
|
|
|
|
rc = sprintf(buf, "%u\n", fnode_sess->entry_state);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_HDR_DGST_EN:
|
|
|
|
rc = sprintf(buf, "%u\n", fnode_conn->hdrdgst_en);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_DATA_DGST_EN:
|
|
|
|
rc = sprintf(buf, "%u\n", fnode_conn->datadgst_en);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_IMM_DATA_EN:
|
|
|
|
rc = sprintf(buf, "%u\n", fnode_sess->imm_data_en);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_INITIAL_R2T_EN:
|
|
|
|
rc = sprintf(buf, "%u\n", fnode_sess->initial_r2t_en);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_DATASEQ_INORDER:
|
|
|
|
rc = sprintf(buf, "%u\n", fnode_sess->dataseq_inorder_en);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_PDU_INORDER:
|
|
|
|
rc = sprintf(buf, "%u\n", fnode_sess->pdu_inorder_en);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_CHAP_AUTH_EN:
|
|
|
|
rc = sprintf(buf, "%u\n", fnode_sess->chap_auth_en);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_SNACK_REQ_EN:
|
|
|
|
rc = sprintf(buf, "%u\n", fnode_conn->snack_req_en);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_DISCOVERY_LOGOUT_EN:
|
|
|
|
rc = sprintf(buf, "%u\n", fnode_sess->discovery_logout_en);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_BIDI_CHAP_EN:
|
|
|
|
rc = sprintf(buf, "%u\n", fnode_sess->bidi_chap_en);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_DISCOVERY_AUTH_OPTIONAL:
|
|
|
|
rc = sprintf(buf, "%u\n", fnode_sess->discovery_auth_optional);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_ERL:
|
|
|
|
rc = sprintf(buf, "%u\n", fnode_sess->erl);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_TCP_TIMESTAMP_STAT:
|
|
|
|
rc = sprintf(buf, "%u\n", fnode_conn->tcp_timestamp_stat);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_TCP_NAGLE_DISABLE:
|
|
|
|
rc = sprintf(buf, "%u\n", fnode_conn->tcp_nagle_disable);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_TCP_WSF_DISABLE:
|
|
|
|
rc = sprintf(buf, "%u\n", fnode_conn->tcp_wsf_disable);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_TCP_TIMER_SCALE:
|
|
|
|
rc = sprintf(buf, "%u\n", fnode_conn->tcp_timer_scale);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_TCP_TIMESTAMP_EN:
|
|
|
|
rc = sprintf(buf, "%u\n", fnode_conn->tcp_timestamp_en);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_IP_FRAG_DISABLE:
|
|
|
|
rc = sprintf(buf, "%u\n", fnode_conn->fragment_disable);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_MAX_RECV_DLENGTH:
|
|
|
|
rc = sprintf(buf, "%u\n", fnode_conn->max_recv_dlength);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_MAX_XMIT_DLENGTH:
|
|
|
|
rc = sprintf(buf, "%u\n", fnode_conn->max_xmit_dlength);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_FIRST_BURST:
|
|
|
|
rc = sprintf(buf, "%u\n", fnode_sess->first_burst);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_DEF_TIME2WAIT:
|
|
|
|
rc = sprintf(buf, "%u\n", fnode_sess->time2wait);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_DEF_TIME2RETAIN:
|
|
|
|
rc = sprintf(buf, "%u\n", fnode_sess->time2retain);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_MAX_R2T:
|
|
|
|
rc = sprintf(buf, "%u\n", fnode_sess->max_r2t);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_KEEPALIVE_TMO:
|
|
|
|
rc = sprintf(buf, "%u\n", fnode_conn->keepalive_timeout);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_ISID:
|
2016-10-22 19:32:28 +02:00
|
|
|
rc = sprintf(buf, "%pm\n", fnode_sess->isid);
|
2013-03-22 12:41:31 +01:00
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_TSID:
|
|
|
|
rc = sprintf(buf, "%u\n", fnode_sess->tsid);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_PORT:
|
|
|
|
rc = sprintf(buf, "%d\n", fnode_conn->port);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_MAX_BURST:
|
|
|
|
rc = sprintf(buf, "%u\n", fnode_sess->max_burst);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_DEF_TASKMGMT_TMO:
|
|
|
|
rc = sprintf(buf, "%u\n",
|
|
|
|
fnode_sess->default_taskmgmt_timeout);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_IPADDR:
|
2013-03-25 13:08:32 +01:00
|
|
|
if (!strncmp(fnode_sess->portal_type, PORTAL_TYPE_IPV6, 4))
|
2013-03-22 12:41:31 +01:00
|
|
|
rc = sprintf(buf, "%pI6\n", fnode_conn->ipaddress);
|
|
|
|
else
|
|
|
|
rc = sprintf(buf, "%pI4\n", fnode_conn->ipaddress);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_ALIAS:
|
|
|
|
if (fnode_sess->targetalias)
|
|
|
|
rc = sprintf(buf, "%s\n", fnode_sess->targetalias);
|
|
|
|
else
|
|
|
|
rc = sprintf(buf, "\n");
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_REDIRECT_IPADDR:
|
2013-03-25 13:08:32 +01:00
|
|
|
if (!strncmp(fnode_sess->portal_type, PORTAL_TYPE_IPV6, 4))
|
2013-03-22 12:41:31 +01:00
|
|
|
rc = sprintf(buf, "%pI6\n",
|
|
|
|
fnode_conn->redirect_ipaddr);
|
|
|
|
else
|
|
|
|
rc = sprintf(buf, "%pI4\n",
|
|
|
|
fnode_conn->redirect_ipaddr);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_MAX_SEGMENT_SIZE:
|
|
|
|
rc = sprintf(buf, "%u\n", fnode_conn->max_segment_size);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_LOCAL_PORT:
|
|
|
|
rc = sprintf(buf, "%u\n", fnode_conn->local_port);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_IPV4_TOS:
|
|
|
|
rc = sprintf(buf, "%u\n", fnode_conn->ipv4_tos);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_IPV6_TC:
|
2013-03-25 13:08:32 +01:00
|
|
|
if (!strncmp(fnode_sess->portal_type, PORTAL_TYPE_IPV6, 4))
|
2013-03-22 12:41:31 +01:00
|
|
|
rc = sprintf(buf, "%u\n",
|
|
|
|
fnode_conn->ipv6_traffic_class);
|
|
|
|
else
|
|
|
|
rc = sprintf(buf, "\n");
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_IPV6_FLOW_LABEL:
|
|
|
|
rc = sprintf(buf, "%u\n", fnode_conn->ipv6_flow_label);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_LINK_LOCAL_IPV6:
|
2013-03-25 13:08:32 +01:00
|
|
|
if (!strncmp(fnode_sess->portal_type, PORTAL_TYPE_IPV6, 4))
|
2013-03-22 12:41:31 +01:00
|
|
|
rc = sprintf(buf, "%pI6\n",
|
|
|
|
fnode_conn->link_local_ipv6_addr);
|
|
|
|
else
|
|
|
|
rc = sprintf(buf, "\n");
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_DISCOVERY_PARENT_IDX:
|
2013-07-08 14:33:08 +02:00
|
|
|
rc = sprintf(buf, "%u\n", fnode_sess->discovery_parent_idx);
|
2013-03-22 12:41:31 +01:00
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_DISCOVERY_PARENT_TYPE:
|
|
|
|
if (fnode_sess->discovery_parent_type == DDB_ISNS)
|
|
|
|
parent_type = ISCSI_DISC_PARENT_ISNS;
|
|
|
|
else if (fnode_sess->discovery_parent_type == DDB_NO_LINK)
|
|
|
|
parent_type = ISCSI_DISC_PARENT_UNKNOWN;
|
2013-04-17 11:15:26 +02:00
|
|
|
else if (fnode_sess->discovery_parent_type < MAX_DDB_ENTRIES)
|
2013-03-22 12:41:31 +01:00
|
|
|
parent_type = ISCSI_DISC_PARENT_SENDTGT;
|
|
|
|
else
|
|
|
|
parent_type = ISCSI_DISC_PARENT_UNKNOWN;
|
|
|
|
|
|
|
|
rc = sprintf(buf, "%s\n",
|
|
|
|
iscsi_get_discovery_parent_name(parent_type));
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_NAME:
|
|
|
|
if (fnode_sess->targetname)
|
|
|
|
rc = sprintf(buf, "%s\n", fnode_sess->targetname);
|
|
|
|
else
|
|
|
|
rc = sprintf(buf, "\n");
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_TPGT:
|
|
|
|
rc = sprintf(buf, "%u\n", fnode_sess->tpgt);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_TCP_XMIT_WSF:
|
|
|
|
rc = sprintf(buf, "%u\n", fnode_conn->tcp_xmit_wsf);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_TCP_RECV_WSF:
|
|
|
|
rc = sprintf(buf, "%u\n", fnode_conn->tcp_recv_wsf);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_CHAP_OUT_IDX:
|
|
|
|
rc = sprintf(buf, "%u\n", fnode_sess->chap_out_idx);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_USERNAME:
|
|
|
|
if (fnode_sess->chap_auth_en) {
|
|
|
|
qla4xxx_get_uni_chap_at_index(ha,
|
|
|
|
chap_tbl.name,
|
|
|
|
chap_tbl.secret,
|
|
|
|
fnode_sess->chap_out_idx);
|
|
|
|
rc = sprintf(buf, "%s\n", chap_tbl.name);
|
|
|
|
} else {
|
|
|
|
rc = sprintf(buf, "\n");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_PASSWORD:
|
|
|
|
if (fnode_sess->chap_auth_en) {
|
|
|
|
qla4xxx_get_uni_chap_at_index(ha,
|
|
|
|
chap_tbl.name,
|
|
|
|
chap_tbl.secret,
|
|
|
|
fnode_sess->chap_out_idx);
|
|
|
|
rc = sprintf(buf, "%s\n", chap_tbl.secret);
|
|
|
|
} else {
|
|
|
|
rc = sprintf(buf, "\n");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_STATSN:
|
|
|
|
rc = sprintf(buf, "%u\n", fnode_conn->statsn);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_EXP_STATSN:
|
|
|
|
rc = sprintf(buf, "%u\n", fnode_conn->exp_statsn);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_IS_BOOT_TGT:
|
|
|
|
rc = sprintf(buf, "%u\n", fnode_sess->is_boot_target);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
rc = -ENOSYS;
|
|
|
|
break;
|
|
|
|
}
|
2013-05-06 19:06:56 +02:00
|
|
|
|
|
|
|
put_device(dev);
|
2013-03-22 12:41:31 +01:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* qla4xxx_sysfs_ddb_set_param - Set parameter for firmware DDB entry
|
|
|
|
* @fnode_sess: pointer to session attrs of flash ddb entry
|
|
|
|
* @fnode_conn: pointer to connection attrs of flash ddb entry
|
|
|
|
* @data: Parameters and their values to update
|
|
|
|
* @len: len of data
|
|
|
|
*
|
|
|
|
* This sets the parameter of flash ddb entry and writes them to flash
|
|
|
|
**/
|
|
|
|
static int
|
|
|
|
qla4xxx_sysfs_ddb_set_param(struct iscsi_bus_flash_session *fnode_sess,
|
|
|
|
struct iscsi_bus_flash_conn *fnode_conn,
|
|
|
|
void *data, int len)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = iscsi_flash_session_to_shost(fnode_sess);
|
|
|
|
struct scsi_qla_host *ha = to_qla_host(shost);
|
|
|
|
struct iscsi_flashnode_param_info *fnode_param;
|
2013-09-17 13:54:45 +02:00
|
|
|
struct ql4_chap_table chap_tbl;
|
2013-03-22 12:41:31 +01:00
|
|
|
struct nlattr *attr;
|
2013-09-17 13:54:45 +02:00
|
|
|
uint16_t chap_out_idx = INVALID_ENTRY;
|
2013-03-22 12:41:31 +01:00
|
|
|
int rc = QLA_ERROR;
|
|
|
|
uint32_t rem = len;
|
|
|
|
|
2013-09-17 13:54:45 +02:00
|
|
|
memset((void *)&chap_tbl, 0, sizeof(chap_tbl));
|
2013-03-22 12:41:31 +01:00
|
|
|
nla_for_each_attr(attr, data, len, rem) {
|
|
|
|
fnode_param = nla_data(attr);
|
|
|
|
|
|
|
|
switch (fnode_param->param) {
|
|
|
|
case ISCSI_FLASHNODE_IS_FW_ASSIGNED_IPV6:
|
|
|
|
fnode_conn->is_fw_assigned_ipv6 = fnode_param->value[0];
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_PORTAL_TYPE:
|
|
|
|
memcpy(fnode_sess->portal_type, fnode_param->value,
|
|
|
|
strlen(fnode_sess->portal_type));
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_AUTO_SND_TGT_DISABLE:
|
|
|
|
fnode_sess->auto_snd_tgt_disable =
|
|
|
|
fnode_param->value[0];
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_DISCOVERY_SESS:
|
|
|
|
fnode_sess->discovery_sess = fnode_param->value[0];
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_ENTRY_EN:
|
|
|
|
fnode_sess->entry_state = fnode_param->value[0];
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_HDR_DGST_EN:
|
|
|
|
fnode_conn->hdrdgst_en = fnode_param->value[0];
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_DATA_DGST_EN:
|
|
|
|
fnode_conn->datadgst_en = fnode_param->value[0];
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_IMM_DATA_EN:
|
|
|
|
fnode_sess->imm_data_en = fnode_param->value[0];
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_INITIAL_R2T_EN:
|
|
|
|
fnode_sess->initial_r2t_en = fnode_param->value[0];
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_DATASEQ_INORDER:
|
|
|
|
fnode_sess->dataseq_inorder_en = fnode_param->value[0];
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_PDU_INORDER:
|
|
|
|
fnode_sess->pdu_inorder_en = fnode_param->value[0];
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_CHAP_AUTH_EN:
|
|
|
|
fnode_sess->chap_auth_en = fnode_param->value[0];
|
2013-09-17 13:54:45 +02:00
|
|
|
/* Invalidate chap index if chap auth is disabled */
|
|
|
|
if (!fnode_sess->chap_auth_en)
|
|
|
|
fnode_sess->chap_out_idx = INVALID_ENTRY;
|
|
|
|
|
2013-03-22 12:41:31 +01:00
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_SNACK_REQ_EN:
|
|
|
|
fnode_conn->snack_req_en = fnode_param->value[0];
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_DISCOVERY_LOGOUT_EN:
|
|
|
|
fnode_sess->discovery_logout_en = fnode_param->value[0];
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_BIDI_CHAP_EN:
|
|
|
|
fnode_sess->bidi_chap_en = fnode_param->value[0];
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_DISCOVERY_AUTH_OPTIONAL:
|
|
|
|
fnode_sess->discovery_auth_optional =
|
|
|
|
fnode_param->value[0];
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_ERL:
|
|
|
|
fnode_sess->erl = fnode_param->value[0];
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_TCP_TIMESTAMP_STAT:
|
|
|
|
fnode_conn->tcp_timestamp_stat = fnode_param->value[0];
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_TCP_NAGLE_DISABLE:
|
|
|
|
fnode_conn->tcp_nagle_disable = fnode_param->value[0];
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_TCP_WSF_DISABLE:
|
|
|
|
fnode_conn->tcp_wsf_disable = fnode_param->value[0];
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_TCP_TIMER_SCALE:
|
|
|
|
fnode_conn->tcp_timer_scale = fnode_param->value[0];
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_TCP_TIMESTAMP_EN:
|
|
|
|
fnode_conn->tcp_timestamp_en = fnode_param->value[0];
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_IP_FRAG_DISABLE:
|
|
|
|
fnode_conn->fragment_disable = fnode_param->value[0];
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_MAX_RECV_DLENGTH:
|
|
|
|
fnode_conn->max_recv_dlength =
|
|
|
|
*(unsigned *)fnode_param->value;
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_MAX_XMIT_DLENGTH:
|
|
|
|
fnode_conn->max_xmit_dlength =
|
|
|
|
*(unsigned *)fnode_param->value;
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_FIRST_BURST:
|
|
|
|
fnode_sess->first_burst =
|
|
|
|
*(unsigned *)fnode_param->value;
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_DEF_TIME2WAIT:
|
|
|
|
fnode_sess->time2wait = *(uint16_t *)fnode_param->value;
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_DEF_TIME2RETAIN:
|
|
|
|
fnode_sess->time2retain =
|
|
|
|
*(uint16_t *)fnode_param->value;
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_MAX_R2T:
|
|
|
|
fnode_sess->max_r2t =
|
|
|
|
*(uint16_t *)fnode_param->value;
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_KEEPALIVE_TMO:
|
|
|
|
fnode_conn->keepalive_timeout =
|
|
|
|
*(uint16_t *)fnode_param->value;
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_ISID:
|
|
|
|
memcpy(fnode_sess->isid, fnode_param->value,
|
|
|
|
sizeof(fnode_sess->isid));
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_TSID:
|
|
|
|
fnode_sess->tsid = *(uint16_t *)fnode_param->value;
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_PORT:
|
|
|
|
fnode_conn->port = *(uint16_t *)fnode_param->value;
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_MAX_BURST:
|
|
|
|
fnode_sess->max_burst = *(unsigned *)fnode_param->value;
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_DEF_TASKMGMT_TMO:
|
|
|
|
fnode_sess->default_taskmgmt_timeout =
|
|
|
|
*(uint16_t *)fnode_param->value;
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_IPADDR:
|
|
|
|
memcpy(fnode_conn->ipaddress, fnode_param->value,
|
|
|
|
IPv6_ADDR_LEN);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_ALIAS:
|
|
|
|
rc = iscsi_switch_str_param(&fnode_sess->targetalias,
|
|
|
|
(char *)fnode_param->value);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_REDIRECT_IPADDR:
|
|
|
|
memcpy(fnode_conn->redirect_ipaddr, fnode_param->value,
|
|
|
|
IPv6_ADDR_LEN);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_MAX_SEGMENT_SIZE:
|
|
|
|
fnode_conn->max_segment_size =
|
|
|
|
*(unsigned *)fnode_param->value;
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_LOCAL_PORT:
|
|
|
|
fnode_conn->local_port =
|
|
|
|
*(uint16_t *)fnode_param->value;
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_IPV4_TOS:
|
|
|
|
fnode_conn->ipv4_tos = fnode_param->value[0];
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_IPV6_TC:
|
|
|
|
fnode_conn->ipv6_traffic_class = fnode_param->value[0];
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_IPV6_FLOW_LABEL:
|
|
|
|
fnode_conn->ipv6_flow_label = fnode_param->value[0];
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_NAME:
|
|
|
|
rc = iscsi_switch_str_param(&fnode_sess->targetname,
|
|
|
|
(char *)fnode_param->value);
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_TPGT:
|
|
|
|
fnode_sess->tpgt = *(uint16_t *)fnode_param->value;
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_LINK_LOCAL_IPV6:
|
|
|
|
memcpy(fnode_conn->link_local_ipv6_addr,
|
|
|
|
fnode_param->value, IPv6_ADDR_LEN);
|
|
|
|
break;
|
2013-07-08 14:33:06 +02:00
|
|
|
case ISCSI_FLASHNODE_DISCOVERY_PARENT_IDX:
|
|
|
|
fnode_sess->discovery_parent_idx =
|
2013-03-22 12:41:31 +01:00
|
|
|
*(uint16_t *)fnode_param->value;
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_TCP_XMIT_WSF:
|
|
|
|
fnode_conn->tcp_xmit_wsf =
|
|
|
|
*(uint8_t *)fnode_param->value;
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_TCP_RECV_WSF:
|
|
|
|
fnode_conn->tcp_recv_wsf =
|
|
|
|
*(uint8_t *)fnode_param->value;
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_STATSN:
|
|
|
|
fnode_conn->statsn = *(uint32_t *)fnode_param->value;
|
|
|
|
break;
|
|
|
|
case ISCSI_FLASHNODE_EXP_STATSN:
|
|
|
|
fnode_conn->exp_statsn =
|
|
|
|
*(uint32_t *)fnode_param->value;
|
|
|
|
break;
|
2013-09-17 13:54:45 +02:00
|
|
|
case ISCSI_FLASHNODE_CHAP_OUT_IDX:
|
|
|
|
chap_out_idx = *(uint16_t *)fnode_param->value;
|
|
|
|
if (!qla4xxx_get_uni_chap_at_index(ha,
|
|
|
|
chap_tbl.name,
|
|
|
|
chap_tbl.secret,
|
|
|
|
chap_out_idx)) {
|
|
|
|
fnode_sess->chap_out_idx = chap_out_idx;
|
|
|
|
/* Enable chap auth if chap index is valid */
|
|
|
|
fnode_sess->chap_auth_en = QL4_PARAM_ENABLE;
|
|
|
|
}
|
|
|
|
break;
|
2013-03-22 12:41:31 +01:00
|
|
|
default:
|
|
|
|
ql4_printk(KERN_ERR, ha,
|
|
|
|
"%s: No such sysfs attribute\n", __func__);
|
|
|
|
rc = -ENOSYS;
|
|
|
|
goto exit_set_param;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = qla4xxx_sysfs_ddb_apply(fnode_sess, fnode_conn);
|
|
|
|
|
|
|
|
exit_set_param:
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* qla4xxx_sysfs_ddb_delete - Delete firmware DDB entry
|
|
|
|
* @fnode_sess: pointer to session attrs of flash ddb entry
|
|
|
|
*
|
|
|
|
* This invalidates the flash ddb entry at the given index
|
|
|
|
**/
|
|
|
|
static int qla4xxx_sysfs_ddb_delete(struct iscsi_bus_flash_session *fnode_sess)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = iscsi_flash_session_to_shost(fnode_sess);
|
|
|
|
struct scsi_qla_host *ha = to_qla_host(shost);
|
|
|
|
uint32_t dev_db_start_offset;
|
|
|
|
uint32_t dev_db_end_offset;
|
|
|
|
struct dev_db_entry *fw_ddb_entry = NULL;
|
|
|
|
dma_addr_t fw_ddb_entry_dma;
|
|
|
|
uint16_t *ddb_cookie = NULL;
|
2013-04-17 11:15:26 +02:00
|
|
|
size_t ddb_size = 0;
|
2013-04-05 13:06:06 +02:00
|
|
|
void *pddb = NULL;
|
2013-03-22 12:41:31 +01:00
|
|
|
int target_id;
|
|
|
|
int rc = 0;
|
|
|
|
|
|
|
|
if (fnode_sess->is_boot_target) {
|
|
|
|
rc = -EPERM;
|
|
|
|
DEBUG2(ql4_printk(KERN_ERR, ha,
|
|
|
|
"%s: Deletion of boot target entry is not permitted.\n",
|
|
|
|
__func__));
|
|
|
|
goto exit_ddb_del;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fnode_sess->flash_state == DEV_DB_NON_PERSISTENT)
|
|
|
|
goto sysfs_ddb_del;
|
|
|
|
|
|
|
|
if (is_qla40XX(ha)) {
|
|
|
|
dev_db_start_offset = FLASH_OFFSET_DB_INFO;
|
2013-04-05 13:06:06 +02:00
|
|
|
dev_db_end_offset = FLASH_OFFSET_DB_END;
|
|
|
|
dev_db_start_offset += (fnode_sess->target_id *
|
|
|
|
sizeof(*fw_ddb_entry));
|
|
|
|
ddb_size = sizeof(*fw_ddb_entry);
|
2013-03-22 12:41:31 +01:00
|
|
|
} else {
|
|
|
|
dev_db_start_offset = FLASH_RAW_ACCESS_ADDR +
|
|
|
|
(ha->hw.flt_region_ddb << 2);
|
|
|
|
/* flt_ddb_size is DDB table size for both ports
|
|
|
|
* so divide it by 2 to calculate the offset for second port
|
|
|
|
*/
|
|
|
|
if (ha->port_num == 1)
|
|
|
|
dev_db_start_offset += (ha->hw.flt_ddb_size / 2);
|
|
|
|
|
2013-04-05 13:06:06 +02:00
|
|
|
dev_db_end_offset = dev_db_start_offset +
|
|
|
|
(ha->hw.flt_ddb_size / 2);
|
|
|
|
|
|
|
|
dev_db_start_offset += (fnode_sess->target_id *
|
|
|
|
sizeof(*fw_ddb_entry));
|
2013-04-17 11:15:28 +02:00
|
|
|
dev_db_start_offset += offsetof(struct dev_db_entry, cookie);
|
2013-04-05 13:06:06 +02:00
|
|
|
|
|
|
|
ddb_size = sizeof(*ddb_cookie);
|
|
|
|
}
|
2013-03-22 12:41:31 +01:00
|
|
|
|
|
|
|
DEBUG2(ql4_printk(KERN_ERR, ha, "%s: start offset=%u, end offset=%u\n",
|
|
|
|
__func__, dev_db_start_offset, dev_db_end_offset));
|
|
|
|
|
|
|
|
if (dev_db_start_offset > dev_db_end_offset) {
|
|
|
|
rc = -EIO;
|
|
|
|
DEBUG2(ql4_printk(KERN_ERR, ha, "%s:Invalid DDB index %u\n",
|
|
|
|
__func__, fnode_sess->target_id));
|
|
|
|
goto exit_ddb_del;
|
|
|
|
}
|
|
|
|
|
2013-04-05 13:06:06 +02:00
|
|
|
pddb = dma_alloc_coherent(&ha->pdev->dev, ddb_size,
|
|
|
|
&fw_ddb_entry_dma, GFP_KERNEL);
|
|
|
|
if (!pddb) {
|
|
|
|
rc = -ENOMEM;
|
|
|
|
DEBUG2(ql4_printk(KERN_ERR, ha,
|
|
|
|
"%s: Unable to allocate dma buffer\n",
|
|
|
|
__func__));
|
|
|
|
goto exit_ddb_del;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (is_qla40XX(ha)) {
|
|
|
|
fw_ddb_entry = pddb;
|
|
|
|
memset(fw_ddb_entry, 0, ddb_size);
|
|
|
|
ddb_cookie = &fw_ddb_entry->cookie;
|
|
|
|
} else {
|
|
|
|
ddb_cookie = pddb;
|
|
|
|
}
|
|
|
|
|
2013-03-22 12:41:31 +01:00
|
|
|
/* invalidate the cookie */
|
|
|
|
*ddb_cookie = 0xFFEE;
|
|
|
|
qla4xxx_set_flash(ha, fw_ddb_entry_dma, dev_db_start_offset,
|
2013-04-05 13:06:06 +02:00
|
|
|
ddb_size, FLASH_OPT_RMW_COMMIT);
|
2013-03-22 12:41:31 +01:00
|
|
|
|
|
|
|
sysfs_ddb_del:
|
|
|
|
target_id = fnode_sess->target_id;
|
|
|
|
iscsi_destroy_flashnode_sess(fnode_sess);
|
|
|
|
ql4_printk(KERN_INFO, ha,
|
|
|
|
"%s: session and conn entries for flashnode %u of host %lu deleted\n",
|
|
|
|
__func__, target_id, ha->host_no);
|
|
|
|
exit_ddb_del:
|
2013-04-05 13:06:06 +02:00
|
|
|
if (pddb)
|
|
|
|
dma_free_coherent(&ha->pdev->dev, ddb_size, pddb,
|
|
|
|
fw_ddb_entry_dma);
|
2013-03-22 12:41:31 +01:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* qla4xxx_sysfs_ddb_export - Create sysfs entries for firmware DDBs
|
|
|
|
* @ha: pointer to adapter structure
|
|
|
|
*
|
|
|
|
* Export the firmware DDB for all send targets and normal targets to sysfs.
|
|
|
|
**/
|
2014-04-10 03:12:25 +02:00
|
|
|
int qla4xxx_sysfs_ddb_export(struct scsi_qla_host *ha)
|
2013-03-22 12:41:31 +01:00
|
|
|
{
|
|
|
|
struct dev_db_entry *fw_ddb_entry = NULL;
|
|
|
|
dma_addr_t fw_ddb_entry_dma;
|
|
|
|
uint16_t max_ddbs;
|
|
|
|
uint16_t idx = 0;
|
|
|
|
int ret = QLA_SUCCESS;
|
|
|
|
|
|
|
|
fw_ddb_entry = dma_alloc_coherent(&ha->pdev->dev,
|
|
|
|
sizeof(*fw_ddb_entry),
|
|
|
|
&fw_ddb_entry_dma, GFP_KERNEL);
|
|
|
|
if (!fw_ddb_entry) {
|
|
|
|
DEBUG2(ql4_printk(KERN_ERR, ha,
|
|
|
|
"%s: Unable to allocate dma buffer\n",
|
|
|
|
__func__));
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2013-04-05 13:06:08 +02:00
|
|
|
max_ddbs = is_qla40XX(ha) ? MAX_PRST_DEV_DB_ENTRIES :
|
2013-03-22 12:41:31 +01:00
|
|
|
MAX_DEV_DB_ENTRIES;
|
|
|
|
|
|
|
|
for (idx = 0; idx < max_ddbs; idx++) {
|
|
|
|
if (qla4xxx_flashdb_by_index(ha, fw_ddb_entry, fw_ddb_entry_dma,
|
|
|
|
idx))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
ret = qla4xxx_sysfs_ddb_tgt_create(ha, fw_ddb_entry, &idx, 0);
|
|
|
|
if (ret) {
|
|
|
|
ret = -EIO;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry), fw_ddb_entry,
|
|
|
|
fw_ddb_entry_dma);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void qla4xxx_sysfs_ddb_remove(struct scsi_qla_host *ha)
|
|
|
|
{
|
|
|
|
iscsi_destroy_all_flashnode(ha->host);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* qla4xxx_build_ddb_list - Build ddb list and setup sessions
|
|
|
|
* @ha: pointer to adapter structure
|
|
|
|
* @is_reset: Is this init path or reset path
|
|
|
|
*
|
|
|
|
* Create a list of sendtargets (st) from firmware DDBs, issue send targets
|
|
|
|
* using connection open, then create the list of normal targets (nt)
|
|
|
|
* from firmware DDBs. Based on the list of nt setup session and connection
|
|
|
|
* objects.
|
|
|
|
**/
|
|
|
|
void qla4xxx_build_ddb_list(struct scsi_qla_host *ha, int is_reset)
|
|
|
|
{
|
|
|
|
uint16_t tmo = 0;
|
|
|
|
struct list_head list_st, list_nt;
|
|
|
|
struct qla_ddb_index *st_ddb_idx, *st_ddb_idx_tmp;
|
|
|
|
unsigned long wtime;
|
|
|
|
|
|
|
|
if (!test_bit(AF_LINK_UP, &ha->flags)) {
|
|
|
|
set_bit(AF_BUILD_DDB_LIST, &ha->flags);
|
|
|
|
ha->is_reset = is_reset;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
INIT_LIST_HEAD(&list_st);
|
|
|
|
INIT_LIST_HEAD(&list_nt);
|
|
|
|
|
|
|
|
qla4xxx_build_st_list(ha, &list_st);
|
|
|
|
|
|
|
|
/* Before issuing conn open mbox, ensure all IPs states are configured
|
|
|
|
* Note, conn open fails if IPs are not configured
|
|
|
|
*/
|
|
|
|
qla4xxx_wait_for_ip_configuration(ha);
|
|
|
|
|
|
|
|
/* Go thru the STs and fire the sendtargets by issuing conn open mbx */
|
|
|
|
list_for_each_entry_safe(st_ddb_idx, st_ddb_idx_tmp, &list_st, list) {
|
|
|
|
qla4xxx_conn_open(ha, st_ddb_idx->fw_ddb_idx);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Wait to ensure all sendtargets are done for min 12 sec wait */
|
|
|
|
tmo = ((ha->def_timeout > LOGIN_TOV) &&
|
|
|
|
(ha->def_timeout < LOGIN_TOV * 10) ?
|
|
|
|
ha->def_timeout : LOGIN_TOV);
|
|
|
|
|
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha,
|
|
|
|
"Default time to wait for build ddb %d\n", tmo));
|
|
|
|
|
|
|
|
wtime = jiffies + (HZ * tmo);
|
|
|
|
do {
|
|
|
|
if (list_empty(&list_st))
|
|
|
|
break;
|
|
|
|
|
|
|
|
qla4xxx_remove_failed_ddb(ha, &list_st);
|
|
|
|
schedule_timeout_uninterruptible(HZ / 10);
|
|
|
|
} while (time_after(wtime, jiffies));
|
|
|
|
|
|
|
|
|
2013-09-17 13:30:02 +02:00
|
|
|
qla4xxx_build_nt_list(ha, &list_nt, &list_st, is_reset);
|
2013-03-22 12:41:31 +01:00
|
|
|
|
2013-09-17 13:30:02 +02:00
|
|
|
qla4xxx_free_ddb_list(&list_st);
|
2013-03-22 12:41:31 +01:00
|
|
|
qla4xxx_free_ddb_list(&list_nt);
|
|
|
|
|
|
|
|
qla4xxx_free_ddb_index(ha);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* qla4xxx_wait_login_resp_boot_tgt - Wait for iSCSI boot target login
|
|
|
|
* response.
|
|
|
|
* @ha: pointer to adapter structure
|
|
|
|
*
|
|
|
|
* When the boot entry is normal iSCSI target then DF_BOOT_TGT flag will be
|
|
|
|
* set in DDB and we will wait for login response of boot targets during
|
|
|
|
* probe.
|
|
|
|
**/
|
|
|
|
static void qla4xxx_wait_login_resp_boot_tgt(struct scsi_qla_host *ha)
|
|
|
|
{
|
|
|
|
struct ddb_entry *ddb_entry;
|
|
|
|
struct dev_db_entry *fw_ddb_entry = NULL;
|
|
|
|
dma_addr_t fw_ddb_entry_dma;
|
|
|
|
unsigned long wtime;
|
|
|
|
uint32_t ddb_state;
|
|
|
|
int max_ddbs, idx, ret;
|
|
|
|
|
|
|
|
max_ddbs = is_qla40XX(ha) ? MAX_DEV_DB_ENTRIES_40XX :
|
|
|
|
MAX_DEV_DB_ENTRIES;
|
|
|
|
|
|
|
|
fw_ddb_entry = dma_alloc_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry),
|
|
|
|
&fw_ddb_entry_dma, GFP_KERNEL);
|
|
|
|
if (!fw_ddb_entry) {
|
|
|
|
ql4_printk(KERN_ERR, ha,
|
|
|
|
"%s: Unable to allocate dma buffer\n", __func__);
|
|
|
|
goto exit_login_resp;
|
|
|
|
}
|
|
|
|
|
|
|
|
wtime = jiffies + (HZ * BOOT_LOGIN_RESP_TOV);
|
|
|
|
|
|
|
|
for (idx = 0; idx < max_ddbs; idx++) {
|
|
|
|
ddb_entry = qla4xxx_lookup_ddb_by_fw_index(ha, idx);
|
|
|
|
if (ddb_entry == NULL)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (test_bit(DF_BOOT_TGT, &ddb_entry->flags)) {
|
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha,
|
|
|
|
"%s: DDB index [%d]\n", __func__,
|
|
|
|
ddb_entry->fw_ddb_index));
|
|
|
|
do {
|
|
|
|
ret = qla4xxx_get_fwddb_entry(ha,
|
|
|
|
ddb_entry->fw_ddb_index,
|
|
|
|
fw_ddb_entry, fw_ddb_entry_dma,
|
|
|
|
NULL, NULL, &ddb_state, NULL,
|
|
|
|
NULL, NULL);
|
|
|
|
if (ret == QLA_ERROR)
|
|
|
|
goto exit_login_resp;
|
|
|
|
|
|
|
|
if ((ddb_state == DDB_DS_SESSION_ACTIVE) ||
|
|
|
|
(ddb_state == DDB_DS_SESSION_FAILED))
|
|
|
|
break;
|
|
|
|
|
|
|
|
schedule_timeout_uninterruptible(HZ);
|
|
|
|
|
|
|
|
} while ((time_after(wtime, jiffies)));
|
|
|
|
|
|
|
|
if (!time_after(wtime, jiffies)) {
|
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha,
|
|
|
|
"%s: Login response wait timer expired\n",
|
|
|
|
__func__));
|
|
|
|
goto exit_login_resp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
exit_login_resp:
|
|
|
|
if (fw_ddb_entry)
|
|
|
|
dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry),
|
|
|
|
fw_ddb_entry, fw_ddb_entry_dma);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* qla4xxx_probe_adapter - callback function to probe HBA
|
|
|
|
* @pdev: pointer to pci_dev structure
|
|
|
|
* @pci_device_id: pointer to pci_device entry
|
|
|
|
*
|
|
|
|
* This routine will probe for Qlogic 4xxx iSCSI host adapters.
|
|
|
|
* It returns zero if successful. It also initializes all data necessary for
|
|
|
|
* the driver.
|
|
|
|
**/
|
|
|
|
static int qla4xxx_probe_adapter(struct pci_dev *pdev,
|
|
|
|
const struct pci_device_id *ent)
|
|
|
|
{
|
|
|
|
int ret = -ENODEV, status;
|
|
|
|
struct Scsi_Host *host;
|
|
|
|
struct scsi_qla_host *ha;
|
|
|
|
uint8_t init_retry_count = 0;
|
|
|
|
char buf[34];
|
|
|
|
struct qla4_8xxx_legacy_intr_set *nx_legacy_intr;
|
|
|
|
uint32_t dev_state;
|
|
|
|
|
|
|
|
if (pci_enable_device(pdev))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
host = iscsi_host_alloc(&qla4xxx_driver_template, sizeof(*ha), 0);
|
|
|
|
if (host == NULL) {
|
2006-09-19 19:28:00 +02:00
|
|
|
printk(KERN_WARNING
|
|
|
|
"qla4xxx: Couldn't allocate host from scsi layer!\n");
|
|
|
|
goto probe_disable_device;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Clear our data area */
|
2011-07-25 20:48:53 +02:00
|
|
|
ha = to_qla_host(host);
|
2006-09-19 19:28:00 +02:00
|
|
|
memset(ha, 0, sizeof(*ha));
|
|
|
|
|
|
|
|
/* Save the information from PCI BIOS. */
|
|
|
|
ha->pdev = pdev;
|
|
|
|
ha->host = host;
|
|
|
|
ha->host_no = host->host_no;
|
2012-08-22 13:55:08 +02:00
|
|
|
ha->func_num = PCI_FUNC(ha->pdev->devfn);
|
2006-09-19 19:28:00 +02:00
|
|
|
|
2010-07-30 11:08:47 +02:00
|
|
|
pci_enable_pcie_error_reporting(pdev);
|
|
|
|
|
2010-07-28 12:23:44 +02:00
|
|
|
/* Setup Runtime configurable options */
|
|
|
|
if (is_qla8022(ha)) {
|
2012-08-22 13:55:00 +02:00
|
|
|
ha->isp_ops = &qla4_82xx_isp_ops;
|
2012-08-22 13:55:04 +02:00
|
|
|
ha->reg_tbl = (uint32_t *) qla4_82xx_reg_tbl;
|
2010-07-28 12:23:44 +02:00
|
|
|
ha->qdr_sn_window = -1;
|
|
|
|
ha->ddr_mn_window = -1;
|
|
|
|
ha->curr_window = 255;
|
|
|
|
nx_legacy_intr = &legacy_intr[ha->func_num];
|
|
|
|
ha->nx_legacy_intr.int_vec_bit = nx_legacy_intr->int_vec_bit;
|
|
|
|
ha->nx_legacy_intr.tgt_status_reg =
|
|
|
|
nx_legacy_intr->tgt_status_reg;
|
|
|
|
ha->nx_legacy_intr.tgt_mask_reg = nx_legacy_intr->tgt_mask_reg;
|
|
|
|
ha->nx_legacy_intr.pci_int_reg = nx_legacy_intr->pci_int_reg;
|
2013-08-16 13:03:02 +02:00
|
|
|
} else if (is_qla8032(ha) || is_qla8042(ha)) {
|
2012-08-22 13:55:08 +02:00
|
|
|
ha->isp_ops = &qla4_83xx_isp_ops;
|
|
|
|
ha->reg_tbl = (uint32_t *)qla4_83xx_reg_tbl;
|
2010-07-28 12:23:44 +02:00
|
|
|
} else {
|
|
|
|
ha->isp_ops = &qla4xxx_isp_ops;
|
|
|
|
}
|
|
|
|
|
2012-08-22 13:55:08 +02:00
|
|
|
if (is_qla80XX(ha)) {
|
|
|
|
rwlock_init(&ha->hw_lock);
|
|
|
|
ha->pf_bit = ha->func_num << 16;
|
|
|
|
/* Set EEH reset type to fundamental if required by hba */
|
2010-07-30 11:08:47 +02:00
|
|
|
pdev->needs_freset = 1;
|
2012-08-22 13:55:08 +02:00
|
|
|
}
|
2010-07-30 11:08:47 +02:00
|
|
|
|
2006-09-19 19:28:00 +02:00
|
|
|
/* Configure PCI I/O space. */
|
2010-07-28 12:23:44 +02:00
|
|
|
ret = ha->isp_ops->iospace_config(ha);
|
2006-09-19 19:28:00 +02:00
|
|
|
if (ret)
|
2010-07-28 12:23:44 +02:00
|
|
|
goto probe_failed_ioconfig;
|
2006-09-19 19:28:00 +02:00
|
|
|
|
2010-07-10 11:21:02 +02:00
|
|
|
ql4_printk(KERN_INFO, ha, "Found an ISP%04x, irq %d, iobase 0x%p\n",
|
2006-09-19 19:28:00 +02:00
|
|
|
pdev->device, pdev->irq, ha->reg);
|
|
|
|
|
|
|
|
qla4xxx_config_dma_addressing(ha);
|
|
|
|
|
|
|
|
/* Initialize lists and spinlocks. */
|
|
|
|
INIT_LIST_HEAD(&ha->free_srb_q);
|
|
|
|
|
|
|
|
mutex_init(&ha->mbox_sem);
|
2011-10-08 01:55:42 +02:00
|
|
|
mutex_init(&ha->chap_sem);
|
2010-07-28 12:23:44 +02:00
|
|
|
init_completion(&ha->mbx_intr_comp);
|
2011-08-12 11:51:29 +02:00
|
|
|
init_completion(&ha->disable_acb_comp);
|
2013-11-22 11:28:17 +01:00
|
|
|
init_completion(&ha->idc_comp);
|
|
|
|
init_completion(&ha->link_up_comp);
|
2006-09-19 19:28:00 +02:00
|
|
|
|
|
|
|
spin_lock_init(&ha->hardware_lock);
|
2012-08-22 13:45:24 +02:00
|
|
|
spin_lock_init(&ha->work_lock);
|
2006-09-19 19:28:00 +02:00
|
|
|
|
2011-08-29 20:13:02 +02:00
|
|
|
/* Initialize work list */
|
|
|
|
INIT_LIST_HEAD(&ha->work_list);
|
|
|
|
|
2006-09-19 19:28:00 +02:00
|
|
|
/* Allocate dma buffers */
|
|
|
|
if (qla4xxx_mem_alloc(ha)) {
|
2010-07-10 11:21:02 +02:00
|
|
|
ql4_printk(KERN_WARNING, ha,
|
|
|
|
"[ERROR] Failed to allocate memory for adapter\n");
|
2006-09-19 19:28:00 +02:00
|
|
|
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto probe_failed;
|
|
|
|
}
|
|
|
|
|
2011-07-25 20:48:53 +02:00
|
|
|
host->cmd_per_lun = 3;
|
|
|
|
host->max_channel = 0;
|
|
|
|
host->max_lun = MAX_LUNS - 1;
|
|
|
|
host->max_id = MAX_TARGETS;
|
|
|
|
host->max_cmd_len = IOCB_MAX_CDB_LEN;
|
|
|
|
host->can_queue = MAX_SRBS ;
|
|
|
|
host->transportt = qla4xxx_scsi_transport;
|
|
|
|
|
|
|
|
pci_set_drvdata(pdev, ha);
|
|
|
|
|
|
|
|
ret = scsi_add_host(host, &pdev->dev);
|
|
|
|
if (ret)
|
|
|
|
goto probe_failed;
|
|
|
|
|
2012-08-22 13:55:08 +02:00
|
|
|
if (is_qla80XX(ha))
|
|
|
|
qla4_8xxx_get_flash_info(ha);
|
|
|
|
|
2013-08-16 13:03:02 +02:00
|
|
|
if (is_qla8032(ha) || is_qla8042(ha)) {
|
2012-08-22 13:55:08 +02:00
|
|
|
qla4_83xx_read_reset_template(ha);
|
|
|
|
/*
|
|
|
|
* NOTE: If ql4dontresethba==1, set IDC_CTRL DONTRESET_BIT0.
|
|
|
|
* If DONRESET_BIT0 is set, drivers should not set dev_state
|
|
|
|
* to NEED_RESET. But if NEED_RESET is set, drivers should
|
|
|
|
* should honor the reset.
|
|
|
|
*/
|
|
|
|
if (ql4xdontresethba == 1)
|
|
|
|
qla4_83xx_set_idc_dontreset(ha);
|
|
|
|
}
|
2010-07-28 12:23:44 +02:00
|
|
|
|
2006-09-19 19:28:00 +02:00
|
|
|
/*
|
|
|
|
* Initialize the Host adapter request/response queues and
|
|
|
|
* firmware
|
|
|
|
* NOTE: interrupts enabled upon successful completion
|
|
|
|
*/
|
2011-12-02 04:38:41 +01:00
|
|
|
status = qla4xxx_initialize_adapter(ha, INIT_ADAPTER);
|
2012-09-20 13:35:07 +02:00
|
|
|
|
|
|
|
/* Dont retry adapter initialization if IRQ allocation failed */
|
2013-12-16 12:49:31 +01:00
|
|
|
if (is_qla80XX(ha) && (status == QLA_ERROR))
|
2012-09-20 13:35:07 +02:00
|
|
|
goto skip_retry_init;
|
|
|
|
|
2010-07-28 12:23:44 +02:00
|
|
|
while ((!test_bit(AF_ONLINE, &ha->flags)) &&
|
|
|
|
init_retry_count++ < MAX_INIT_RETRIES) {
|
2011-03-21 11:34:26 +01:00
|
|
|
|
2012-08-22 13:55:08 +02:00
|
|
|
if (is_qla80XX(ha)) {
|
2012-08-22 13:55:04 +02:00
|
|
|
ha->isp_ops->idc_lock(ha);
|
|
|
|
dev_state = qla4_8xxx_rd_direct(ha,
|
2012-12-29 08:24:52 +01:00
|
|
|
QLA8XXX_CRB_DEV_STATE);
|
2012-08-22 13:55:04 +02:00
|
|
|
ha->isp_ops->idc_unlock(ha);
|
2012-08-22 15:14:24 +02:00
|
|
|
if (dev_state == QLA8XXX_DEV_FAILED) {
|
2011-03-21 11:34:26 +01:00
|
|
|
ql4_printk(KERN_WARNING, ha, "%s: don't retry "
|
|
|
|
"initialize adapter. H/W is in failed state\n",
|
|
|
|
__func__);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-09-19 19:28:00 +02:00
|
|
|
DEBUG2(printk("scsi: %s: retrying adapter initialization "
|
|
|
|
"(%d)\n", __func__, init_retry_count));
|
2010-07-28 12:23:44 +02:00
|
|
|
|
|
|
|
if (ha->isp_ops->reset_chip(ha) == QLA_ERROR)
|
|
|
|
continue;
|
|
|
|
|
2011-12-02 04:38:41 +01:00
|
|
|
status = qla4xxx_initialize_adapter(ha, INIT_ADAPTER);
|
2013-12-16 12:49:31 +01:00
|
|
|
if (is_qla80XX(ha) && (status == QLA_ERROR)) {
|
|
|
|
if (qla4_8xxx_check_init_adapter_retry(ha) == QLA_ERROR)
|
|
|
|
goto skip_retry_init;
|
|
|
|
}
|
2006-09-19 19:28:00 +02:00
|
|
|
}
|
2010-07-28 12:23:44 +02:00
|
|
|
|
2012-09-20 13:35:07 +02:00
|
|
|
skip_retry_init:
|
2010-07-28 12:23:44 +02:00
|
|
|
if (!test_bit(AF_ONLINE, &ha->flags)) {
|
2010-07-10 11:21:02 +02:00
|
|
|
ql4_printk(KERN_WARNING, ha, "Failed to initialize adapter\n");
|
2006-09-19 19:28:00 +02:00
|
|
|
|
2012-08-22 13:55:08 +02:00
|
|
|
if ((is_qla8022(ha) && ql4xdontresethba) ||
|
2013-08-16 13:03:02 +02:00
|
|
|
((is_qla8032(ha) || is_qla8042(ha)) &&
|
|
|
|
qla4_83xx_idc_dontreset(ha))) {
|
2010-12-03 07:12:36 +01:00
|
|
|
/* Put the device in failed state. */
|
|
|
|
DEBUG2(printk(KERN_ERR "HW STATE: FAILED\n"));
|
2012-08-22 13:55:04 +02:00
|
|
|
ha->isp_ops->idc_lock(ha);
|
|
|
|
qla4_8xxx_wr_direct(ha, QLA8XXX_CRB_DEV_STATE,
|
|
|
|
QLA8XXX_DEV_FAILED);
|
|
|
|
ha->isp_ops->idc_unlock(ha);
|
2010-12-03 07:12:36 +01:00
|
|
|
}
|
2006-09-19 19:28:00 +02:00
|
|
|
ret = -ENODEV;
|
2011-07-25 20:48:53 +02:00
|
|
|
goto remove_host;
|
2006-09-19 19:28:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Startup the kernel thread for this host adapter. */
|
|
|
|
DEBUG2(printk("scsi: %s: Starting kernel thread for "
|
|
|
|
"qla4xxx_dpc\n", __func__));
|
|
|
|
sprintf(buf, "qla4xxx_%lu_dpc", ha->host_no);
|
|
|
|
ha->dpc_thread = create_singlethread_workqueue(buf);
|
|
|
|
if (!ha->dpc_thread) {
|
2010-07-10 11:21:02 +02:00
|
|
|
ql4_printk(KERN_WARNING, ha, "Unable to start DPC thread!\n");
|
2006-09-19 19:28:00 +02:00
|
|
|
ret = -ENODEV;
|
2011-07-25 20:48:53 +02:00
|
|
|
goto remove_host;
|
2006-09-19 19:28:00 +02:00
|
|
|
}
|
2006-11-22 15:57:56 +01:00
|
|
|
INIT_WORK(&ha->dpc_work, qla4xxx_do_dpc);
|
2006-09-19 19:28:00 +02:00
|
|
|
|
2013-07-04 00:04:57 +02:00
|
|
|
ha->task_wq = alloc_workqueue("qla4xxx_%lu_task", WQ_MEM_RECLAIM, 1,
|
|
|
|
ha->host_no);
|
2011-07-25 20:48:53 +02:00
|
|
|
if (!ha->task_wq) {
|
|
|
|
ql4_printk(KERN_WARNING, ha, "Unable to start task thread!\n");
|
|
|
|
ret = -ENODEV;
|
|
|
|
goto remove_host;
|
|
|
|
}
|
|
|
|
|
2012-08-22 13:55:08 +02:00
|
|
|
/*
|
|
|
|
* For ISP-8XXX, request_irqs is called in qla4_8xxx_load_risc
|
2010-07-28 12:23:44 +02:00
|
|
|
* (which is called indirectly by qla4xxx_initialize_adapter),
|
|
|
|
* so that irqs will be registered after crbinit but before
|
|
|
|
* mbx_intr_enable.
|
|
|
|
*/
|
2012-08-22 13:55:05 +02:00
|
|
|
if (is_qla40XX(ha)) {
|
2010-07-28 12:23:44 +02:00
|
|
|
ret = qla4xxx_request_irqs(ha);
|
|
|
|
if (ret) {
|
|
|
|
ql4_printk(KERN_WARNING, ha, "Failed to reserve "
|
|
|
|
"interrupt %d already in use.\n", pdev->irq);
|
2011-07-25 20:48:53 +02:00
|
|
|
goto remove_host;
|
2010-07-28 12:23:44 +02:00
|
|
|
}
|
2006-09-19 19:28:00 +02:00
|
|
|
}
|
|
|
|
|
2010-07-30 11:08:47 +02:00
|
|
|
pci_save_state(ha->pdev);
|
2010-07-28 12:23:44 +02:00
|
|
|
ha->isp_ops->enable_intrs(ha);
|
2006-09-19 19:28:00 +02:00
|
|
|
|
|
|
|
/* Start timer thread. */
|
2017-10-21 17:39:39 +02:00
|
|
|
qla4xxx_start_timer(ha, 1);
|
2006-09-19 19:28:00 +02:00
|
|
|
|
|
|
|
set_bit(AF_INIT_DONE, &ha->flags);
|
|
|
|
|
2012-05-18 10:41:44 +02:00
|
|
|
qla4_8xxx_alloc_sysfs_attr(ha);
|
|
|
|
|
2006-09-19 19:28:00 +02:00
|
|
|
printk(KERN_INFO
|
|
|
|
" QLogic iSCSI HBA Driver version: %s\n"
|
|
|
|
" QLogic ISP%04x @ %s, host#=%ld, fw=%02d.%02d.%02d.%02d\n",
|
|
|
|
qla4xxx_version_str, ha->pdev->device, pci_name(ha->pdev),
|
2013-07-08 14:33:10 +02:00
|
|
|
ha->host_no, ha->fw_info.fw_major, ha->fw_info.fw_minor,
|
|
|
|
ha->fw_info.fw_patch, ha->fw_info.fw_build);
|
2011-07-25 20:48:41 +02:00
|
|
|
|
2012-09-20 13:35:01 +02:00
|
|
|
/* Set the driver version */
|
|
|
|
if (is_qla80XX(ha))
|
|
|
|
qla4_8xxx_set_param(ha, SET_DRVR_VERSION);
|
|
|
|
|
2011-07-25 20:48:55 +02:00
|
|
|
if (qla4xxx_setup_boot_info(ha))
|
2012-02-27 12:08:57 +01:00
|
|
|
ql4_printk(KERN_ERR, ha,
|
|
|
|
"%s: No iSCSI boot target configured\n", __func__);
|
2011-07-25 20:48:55 +02:00
|
|
|
|
2014-04-10 03:12:25 +02:00
|
|
|
set_bit(DPC_SYSFS_DDB_EXPORT, &ha->dpc_flags);
|
|
|
|
/* Perform the build ddb list and login to each */
|
2011-12-02 04:38:41 +01:00
|
|
|
qla4xxx_build_ddb_list(ha, INIT_ADAPTER);
|
|
|
|
iscsi_host_for_each_session(ha->host, qla4xxx_login_flash_ddb);
|
2013-01-21 05:51:03 +01:00
|
|
|
qla4xxx_wait_login_resp_boot_tgt(ha);
|
2011-12-02 04:38:41 +01:00
|
|
|
|
|
|
|
qla4xxx_create_chap_list(ha);
|
|
|
|
|
2011-07-25 20:48:41 +02:00
|
|
|
qla4xxx_create_ifaces(ha);
|
2006-09-19 19:28:00 +02:00
|
|
|
return 0;
|
|
|
|
|
2011-07-25 20:48:53 +02:00
|
|
|
remove_host:
|
|
|
|
scsi_remove_host(ha->host);
|
|
|
|
|
2006-09-19 19:28:00 +02:00
|
|
|
probe_failed:
|
|
|
|
qla4xxx_free_adapter(ha);
|
2010-07-28 12:23:44 +02:00
|
|
|
|
|
|
|
probe_failed_ioconfig:
|
2010-07-30 11:08:47 +02:00
|
|
|
pci_disable_pcie_error_reporting(pdev);
|
2006-09-19 19:28:00 +02:00
|
|
|
scsi_host_put(ha->host);
|
|
|
|
|
|
|
|
probe_disable_device:
|
|
|
|
pci_disable_device(pdev);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-03-21 11:34:29 +01:00
|
|
|
/**
|
|
|
|
* qla4xxx_prevent_other_port_reinit - prevent other port from re-initialize
|
|
|
|
* @ha: pointer to adapter structure
|
|
|
|
*
|
|
|
|
* Mark the other ISP-4xxx port to indicate that the driver is being removed,
|
|
|
|
* so that the other port will not re-initialize while in the process of
|
|
|
|
* removing the ha due to driver unload or hba hotplug.
|
|
|
|
**/
|
|
|
|
static void qla4xxx_prevent_other_port_reinit(struct scsi_qla_host *ha)
|
|
|
|
{
|
|
|
|
struct scsi_qla_host *other_ha = NULL;
|
|
|
|
struct pci_dev *other_pdev = NULL;
|
|
|
|
int fn = ISP4XXX_PCI_FN_2;
|
|
|
|
|
|
|
|
/*iscsi function numbers for ISP4xxx is 1 and 3*/
|
|
|
|
if (PCI_FUNC(ha->pdev->devfn) & BIT_1)
|
|
|
|
fn = ISP4XXX_PCI_FN_1;
|
|
|
|
|
|
|
|
other_pdev =
|
|
|
|
pci_get_domain_bus_and_slot(pci_domain_nr(ha->pdev->bus),
|
|
|
|
ha->pdev->bus->number, PCI_DEVFN(PCI_SLOT(ha->pdev->devfn),
|
|
|
|
fn));
|
|
|
|
|
|
|
|
/* Get other_ha if other_pdev is valid and state is enable*/
|
|
|
|
if (other_pdev) {
|
|
|
|
if (atomic_read(&other_pdev->enable_cnt)) {
|
|
|
|
other_ha = pci_get_drvdata(other_pdev);
|
|
|
|
if (other_ha) {
|
|
|
|
set_bit(AF_HA_REMOVAL, &other_ha->flags);
|
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha, "%s: "
|
|
|
|
"Prevent %s reinit\n", __func__,
|
|
|
|
dev_name(&other_ha->pdev->dev)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pci_dev_put(other_pdev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-17 10:43:28 +01:00
|
|
|
static void qla4xxx_destroy_ddb(struct scsi_qla_host *ha,
|
|
|
|
struct ddb_entry *ddb_entry)
|
|
|
|
{
|
|
|
|
struct dev_db_entry *fw_ddb_entry = NULL;
|
|
|
|
dma_addr_t fw_ddb_entry_dma;
|
|
|
|
unsigned long wtime;
|
|
|
|
uint32_t ddb_state;
|
|
|
|
int options;
|
|
|
|
int status;
|
|
|
|
|
|
|
|
options = LOGOUT_OPTION_CLOSE_SESSION;
|
|
|
|
if (qla4xxx_session_logout_ddb(ha, ddb_entry, options) == QLA_ERROR) {
|
|
|
|
ql4_printk(KERN_ERR, ha, "%s: Logout failed\n", __func__);
|
|
|
|
goto clear_ddb;
|
|
|
|
}
|
|
|
|
|
|
|
|
fw_ddb_entry = dma_alloc_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry),
|
|
|
|
&fw_ddb_entry_dma, GFP_KERNEL);
|
|
|
|
if (!fw_ddb_entry) {
|
|
|
|
ql4_printk(KERN_ERR, ha,
|
|
|
|
"%s: Unable to allocate dma buffer\n", __func__);
|
|
|
|
goto clear_ddb;
|
|
|
|
}
|
|
|
|
|
|
|
|
wtime = jiffies + (HZ * LOGOUT_TOV);
|
|
|
|
do {
|
|
|
|
status = qla4xxx_get_fwddb_entry(ha, ddb_entry->fw_ddb_index,
|
|
|
|
fw_ddb_entry, fw_ddb_entry_dma,
|
|
|
|
NULL, NULL, &ddb_state, NULL,
|
|
|
|
NULL, NULL);
|
|
|
|
if (status == QLA_ERROR)
|
|
|
|
goto free_ddb;
|
|
|
|
|
|
|
|
if ((ddb_state == DDB_DS_NO_CONNECTION_ACTIVE) ||
|
|
|
|
(ddb_state == DDB_DS_SESSION_FAILED))
|
|
|
|
goto free_ddb;
|
|
|
|
|
|
|
|
schedule_timeout_uninterruptible(HZ);
|
|
|
|
} while ((time_after(wtime, jiffies)));
|
|
|
|
|
|
|
|
free_ddb:
|
|
|
|
dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry),
|
|
|
|
fw_ddb_entry, fw_ddb_entry_dma);
|
|
|
|
clear_ddb:
|
|
|
|
qla4xxx_clear_ddb_entry(ha, ddb_entry->fw_ddb_index);
|
|
|
|
}
|
|
|
|
|
2011-12-02 04:38:41 +01:00
|
|
|
static void qla4xxx_destroy_fw_ddb_session(struct scsi_qla_host *ha)
|
|
|
|
{
|
|
|
|
struct ddb_entry *ddb_entry;
|
|
|
|
int idx;
|
|
|
|
|
|
|
|
for (idx = 0; idx < MAX_DDB_ENTRIES; idx++) {
|
|
|
|
|
|
|
|
ddb_entry = qla4xxx_lookup_ddb_by_fw_index(ha, idx);
|
|
|
|
if ((ddb_entry != NULL) &&
|
|
|
|
(ddb_entry->ddb_type == FLASH_DDB)) {
|
|
|
|
|
2014-01-17 10:43:28 +01:00
|
|
|
qla4xxx_destroy_ddb(ha, ddb_entry);
|
2011-12-02 04:38:41 +01:00
|
|
|
/*
|
|
|
|
* we have decremented the reference count of the driver
|
|
|
|
* when we setup the session to have the driver unload
|
|
|
|
* to be seamless without actually destroying the
|
|
|
|
* session
|
|
|
|
**/
|
|
|
|
try_module_get(qla4xxx_iscsi_transport.owner);
|
|
|
|
iscsi_destroy_endpoint(ddb_entry->conn->ep);
|
|
|
|
qla4xxx_free_ddb(ha, ddb_entry);
|
|
|
|
iscsi_session_teardown(ddb_entry->sess);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-09-19 19:28:00 +02:00
|
|
|
/**
|
2012-04-24 17:24:16 +02:00
|
|
|
* qla4xxx_remove_adapter - callback function to remove adapter.
|
2006-09-19 19:28:00 +02:00
|
|
|
* @pci_dev: PCI device pointer
|
|
|
|
**/
|
2012-12-21 22:08:55 +01:00
|
|
|
static void qla4xxx_remove_adapter(struct pci_dev *pdev)
|
2006-09-19 19:28:00 +02:00
|
|
|
{
|
|
|
|
struct scsi_qla_host *ha;
|
|
|
|
|
2012-09-20 13:35:08 +02:00
|
|
|
/*
|
|
|
|
* If the PCI device is disabled then it means probe_adapter had
|
|
|
|
* failed and resources already cleaned up on probe_adapter exit.
|
|
|
|
*/
|
|
|
|
if (!pci_is_enabled(pdev))
|
|
|
|
return;
|
|
|
|
|
2006-09-19 19:28:00 +02:00
|
|
|
ha = pci_get_drvdata(pdev);
|
|
|
|
|
2012-08-22 13:55:05 +02:00
|
|
|
if (is_qla40XX(ha))
|
2011-03-21 11:34:29 +01:00
|
|
|
qla4xxx_prevent_other_port_reinit(ha);
|
2007-05-24 03:03:32 +02:00
|
|
|
|
2011-07-25 20:48:41 +02:00
|
|
|
/* destroy iface from sysfs */
|
|
|
|
qla4xxx_destroy_ifaces(ha);
|
|
|
|
|
2011-12-02 04:38:41 +01:00
|
|
|
if ((!ql4xdisablesysfsboot) && ha->boot_kset)
|
2011-07-25 20:48:55 +02:00
|
|
|
iscsi_boot_destroy_kset(ha->boot_kset);
|
|
|
|
|
2011-12-02 04:38:41 +01:00
|
|
|
qla4xxx_destroy_fw_ddb_session(ha);
|
2012-05-18 10:41:44 +02:00
|
|
|
qla4_8xxx_free_sysfs_attr(ha);
|
2011-12-02 04:38:41 +01:00
|
|
|
|
2013-03-22 12:41:31 +01:00
|
|
|
qla4xxx_sysfs_ddb_remove(ha);
|
2006-09-19 19:28:00 +02:00
|
|
|
scsi_remove_host(ha->host);
|
|
|
|
|
|
|
|
qla4xxx_free_adapter(ha);
|
|
|
|
|
|
|
|
scsi_host_put(ha->host);
|
|
|
|
|
2010-07-30 11:08:47 +02:00
|
|
|
pci_disable_pcie_error_reporting(pdev);
|
2010-07-28 12:23:44 +02:00
|
|
|
pci_disable_device(pdev);
|
2006-09-19 19:28:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* qla4xxx_config_dma_addressing() - Configure OS DMA addressing method.
|
|
|
|
* @ha: HA context
|
|
|
|
*
|
|
|
|
* At exit, the @ha's flags.enable_64bit_addressing set to indicated
|
|
|
|
* supported addressing method.
|
|
|
|
*/
|
2007-04-26 09:35:16 +02:00
|
|
|
static void qla4xxx_config_dma_addressing(struct scsi_qla_host *ha)
|
2006-09-19 19:28:00 +02:00
|
|
|
{
|
|
|
|
int retval;
|
|
|
|
|
|
|
|
/* Update our PCI device dma_mask for full 64 bit mask */
|
2009-04-07 04:01:13 +02:00
|
|
|
if (pci_set_dma_mask(ha->pdev, DMA_BIT_MASK(64)) == 0) {
|
|
|
|
if (pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
|
2006-09-19 19:28:00 +02:00
|
|
|
dev_dbg(&ha->pdev->dev,
|
|
|
|
"Failed to set 64 bit PCI consistent mask; "
|
|
|
|
"using 32 bit.\n");
|
|
|
|
retval = pci_set_consistent_dma_mask(ha->pdev,
|
2009-04-07 04:01:15 +02:00
|
|
|
DMA_BIT_MASK(32));
|
2006-09-19 19:28:00 +02:00
|
|
|
}
|
|
|
|
} else
|
2009-04-07 04:01:15 +02:00
|
|
|
retval = pci_set_dma_mask(ha->pdev, DMA_BIT_MASK(32));
|
2006-09-19 19:28:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int qla4xxx_slave_alloc(struct scsi_device *sdev)
|
|
|
|
{
|
2011-07-25 20:48:53 +02:00
|
|
|
struct iscsi_cls_session *cls_sess;
|
|
|
|
struct iscsi_session *sess;
|
|
|
|
struct ddb_entry *ddb;
|
2011-03-21 11:34:31 +01:00
|
|
|
int queue_depth = QL4_DEF_QDEPTH;
|
2006-09-19 19:28:00 +02:00
|
|
|
|
2011-07-25 20:48:53 +02:00
|
|
|
cls_sess = starget_to_session(sdev->sdev_target);
|
|
|
|
sess = cls_sess->dd_data;
|
|
|
|
ddb = sess->dd_data;
|
|
|
|
|
2006-09-19 19:28:00 +02:00
|
|
|
sdev->hostdata = ddb;
|
2011-03-21 11:34:31 +01:00
|
|
|
|
|
|
|
if (ql4xmaxqdepth != 0 && ql4xmaxqdepth <= 0xffffU)
|
|
|
|
queue_depth = ql4xmaxqdepth;
|
|
|
|
|
2014-11-13 15:08:42 +01:00
|
|
|
scsi_change_queue_depth(sdev, queue_depth);
|
2006-09-19 19:28:00 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* qla4xxx_del_from_active_array - returns an active srb
|
|
|
|
* @ha: Pointer to host adapter structure.
|
2009-07-16 17:13:03 +02:00
|
|
|
* @index: index into the active_array
|
2006-09-19 19:28:00 +02:00
|
|
|
*
|
|
|
|
* This routine removes and returns the srb at the specified index
|
|
|
|
**/
|
2010-07-28 12:23:44 +02:00
|
|
|
struct srb *qla4xxx_del_from_active_array(struct scsi_qla_host *ha,
|
|
|
|
uint32_t index)
|
2006-09-19 19:28:00 +02:00
|
|
|
{
|
|
|
|
struct srb *srb = NULL;
|
2010-04-28 08:11:59 +02:00
|
|
|
struct scsi_cmnd *cmd = NULL;
|
2006-09-19 19:28:00 +02:00
|
|
|
|
2010-04-28 08:11:59 +02:00
|
|
|
cmd = scsi_host_find_tag(ha->host, index);
|
|
|
|
if (!cmd)
|
2006-09-19 19:28:00 +02:00
|
|
|
return srb;
|
|
|
|
|
2010-04-28 08:11:59 +02:00
|
|
|
srb = (struct srb *)CMD_SP(cmd);
|
|
|
|
if (!srb)
|
2006-09-19 19:28:00 +02:00
|
|
|
return srb;
|
|
|
|
|
|
|
|
/* update counters */
|
|
|
|
if (srb->flags & SRB_DMA_VALID) {
|
|
|
|
ha->iocb_cnt -= srb->iocb_cnt;
|
|
|
|
if (srb->cmd)
|
2010-04-28 08:11:59 +02:00
|
|
|
srb->cmd->host_scribble =
|
|
|
|
(unsigned char *)(unsigned long) MAX_SRBS;
|
2006-09-19 19:28:00 +02:00
|
|
|
}
|
|
|
|
return srb;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* qla4xxx_eh_wait_on_command - waits for command to be returned by firmware
|
2010-04-28 08:12:24 +02:00
|
|
|
* @ha: Pointer to host adapter structure.
|
2006-09-19 19:28:00 +02:00
|
|
|
* @cmd: Scsi Command to wait on.
|
|
|
|
*
|
|
|
|
* This routine waits for the command to be returned by the Firmware
|
|
|
|
* for some max time.
|
|
|
|
**/
|
|
|
|
static int qla4xxx_eh_wait_on_command(struct scsi_qla_host *ha,
|
|
|
|
struct scsi_cmnd *cmd)
|
|
|
|
{
|
|
|
|
int done = 0;
|
|
|
|
struct srb *rp;
|
|
|
|
uint32_t max_wait_time = EH_WAIT_CMD_TOV;
|
2010-07-30 11:08:47 +02:00
|
|
|
int ret = SUCCESS;
|
|
|
|
|
|
|
|
/* Dont wait on command if PCI error is being handled
|
|
|
|
* by PCI AER driver
|
|
|
|
*/
|
|
|
|
if (unlikely(pci_channel_offline(ha->pdev)) ||
|
|
|
|
(test_bit(AF_EEH_BUSY, &ha->flags))) {
|
|
|
|
ql4_printk(KERN_WARNING, ha, "scsi%ld: Return from %s\n",
|
|
|
|
ha->host_no, __func__);
|
|
|
|
return ret;
|
|
|
|
}
|
2006-09-19 19:28:00 +02:00
|
|
|
|
|
|
|
do {
|
|
|
|
/* Checking to see if its returned to OS */
|
2010-04-28 08:11:59 +02:00
|
|
|
rp = (struct srb *) CMD_SP(cmd);
|
2006-09-19 19:28:00 +02:00
|
|
|
if (rp == NULL) {
|
|
|
|
done++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
msleep(2000);
|
|
|
|
} while (max_wait_time--);
|
|
|
|
|
|
|
|
return done;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* qla4xxx_wait_for_hba_online - waits for HBA to come online
|
|
|
|
* @ha: Pointer to host adapter structure
|
|
|
|
**/
|
|
|
|
static int qla4xxx_wait_for_hba_online(struct scsi_qla_host *ha)
|
|
|
|
{
|
|
|
|
unsigned long wait_online;
|
|
|
|
|
2010-10-07 07:47:48 +02:00
|
|
|
wait_online = jiffies + (HBA_ONLINE_TOV * HZ);
|
2006-09-19 19:28:00 +02:00
|
|
|
while (time_before(jiffies, wait_online)) {
|
|
|
|
|
|
|
|
if (adapter_up(ha))
|
|
|
|
return QLA_SUCCESS;
|
|
|
|
|
|
|
|
msleep(2000);
|
|
|
|
}
|
|
|
|
|
|
|
|
return QLA_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-03-01 01:25:20 +01:00
|
|
|
* qla4xxx_eh_wait_for_commands - wait for active cmds to finish.
|
2009-07-16 17:13:03 +02:00
|
|
|
* @ha: pointer to HBA
|
2006-09-19 19:28:00 +02:00
|
|
|
* @t: target id
|
|
|
|
* @l: lun id
|
|
|
|
*
|
|
|
|
* This function waits for all outstanding commands to a lun to complete. It
|
|
|
|
* returns 0 if all pending commands are returned and 1 otherwise.
|
|
|
|
**/
|
2008-03-01 01:25:20 +01:00
|
|
|
static int qla4xxx_eh_wait_for_commands(struct scsi_qla_host *ha,
|
|
|
|
struct scsi_target *stgt,
|
|
|
|
struct scsi_device *sdev)
|
2006-09-19 19:28:00 +02:00
|
|
|
{
|
|
|
|
int cnt;
|
|
|
|
int status = 0;
|
|
|
|
struct scsi_cmnd *cmd;
|
|
|
|
|
|
|
|
/*
|
2008-03-01 01:25:20 +01:00
|
|
|
* Waiting for all commands for the designated target or dev
|
|
|
|
* in the active array
|
2006-09-19 19:28:00 +02:00
|
|
|
*/
|
|
|
|
for (cnt = 0; cnt < ha->host->can_queue; cnt++) {
|
|
|
|
cmd = scsi_host_find_tag(ha->host, cnt);
|
2008-03-01 01:25:20 +01:00
|
|
|
if (cmd && stgt == scsi_target(cmd->device) &&
|
|
|
|
(!sdev || sdev == cmd->device)) {
|
2006-09-19 19:28:00 +02:00
|
|
|
if (!qla4xxx_eh_wait_on_command(ha, cmd)) {
|
|
|
|
status++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2010-04-28 08:12:24 +02:00
|
|
|
/**
|
|
|
|
* qla4xxx_eh_abort - callback for abort task.
|
|
|
|
* @cmd: Pointer to Linux's SCSI command structure
|
|
|
|
*
|
|
|
|
* This routine is called by the Linux OS to abort the specified
|
|
|
|
* command.
|
|
|
|
**/
|
|
|
|
static int qla4xxx_eh_abort(struct scsi_cmnd *cmd)
|
|
|
|
{
|
|
|
|
struct scsi_qla_host *ha = to_qla_host(cmd->device->host);
|
|
|
|
unsigned int id = cmd->device->id;
|
2014-06-25 15:27:36 +02:00
|
|
|
uint64_t lun = cmd->device->lun;
|
2010-10-07 07:51:17 +02:00
|
|
|
unsigned long flags;
|
2010-04-28 08:12:24 +02:00
|
|
|
struct srb *srb = NULL;
|
|
|
|
int ret = SUCCESS;
|
|
|
|
int wait = 0;
|
|
|
|
|
2014-06-25 15:27:36 +02:00
|
|
|
ql4_printk(KERN_INFO, ha, "scsi%ld:%d:%llu: Abort command issued cmd=%p, cdb=0x%x\n",
|
2013-12-16 12:49:50 +01:00
|
|
|
ha->host_no, id, lun, cmd, cmd->cmnd[0]);
|
2010-04-28 08:12:24 +02:00
|
|
|
|
2010-10-07 07:51:17 +02:00
|
|
|
spin_lock_irqsave(&ha->hardware_lock, flags);
|
2010-04-28 08:12:24 +02:00
|
|
|
srb = (struct srb *) CMD_SP(cmd);
|
2010-10-07 07:51:17 +02:00
|
|
|
if (!srb) {
|
|
|
|
spin_unlock_irqrestore(&ha->hardware_lock, flags);
|
2014-06-25 15:27:36 +02:00
|
|
|
ql4_printk(KERN_INFO, ha, "scsi%ld:%d:%llu: Specified command has already completed.\n",
|
2013-12-16 12:49:50 +01:00
|
|
|
ha->host_no, id, lun);
|
2010-04-28 08:12:24 +02:00
|
|
|
return SUCCESS;
|
2010-10-07 07:51:17 +02:00
|
|
|
}
|
2010-04-28 08:12:24 +02:00
|
|
|
kref_get(&srb->srb_ref);
|
2010-10-07 07:51:17 +02:00
|
|
|
spin_unlock_irqrestore(&ha->hardware_lock, flags);
|
2010-04-28 08:12:24 +02:00
|
|
|
|
|
|
|
if (qla4xxx_abort_task(ha, srb) != QLA_SUCCESS) {
|
2014-06-25 15:27:36 +02:00
|
|
|
DEBUG3(printk("scsi%ld:%d:%llu: Abort_task mbx failed.\n",
|
2010-04-28 08:12:24 +02:00
|
|
|
ha->host_no, id, lun));
|
|
|
|
ret = FAILED;
|
|
|
|
} else {
|
2014-06-25 15:27:36 +02:00
|
|
|
DEBUG3(printk("scsi%ld:%d:%llu: Abort_task mbx success.\n",
|
2010-04-28 08:12:24 +02:00
|
|
|
ha->host_no, id, lun));
|
|
|
|
wait = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
kref_put(&srb->srb_ref, qla4xxx_srb_compl);
|
|
|
|
|
|
|
|
/* Wait for command to complete */
|
|
|
|
if (wait) {
|
|
|
|
if (!qla4xxx_eh_wait_on_command(ha, cmd)) {
|
2014-06-25 15:27:36 +02:00
|
|
|
DEBUG2(printk("scsi%ld:%d:%llu: Abort handler timed out\n",
|
2010-04-28 08:12:24 +02:00
|
|
|
ha->host_no, id, lun));
|
|
|
|
ret = FAILED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-10 11:21:02 +02:00
|
|
|
ql4_printk(KERN_INFO, ha,
|
2014-06-25 15:27:36 +02:00
|
|
|
"scsi%ld:%d:%llu: Abort command - %s\n",
|
2011-03-31 03:57:33 +02:00
|
|
|
ha->host_no, id, lun, (ret == SUCCESS) ? "succeeded" : "failed");
|
2010-04-28 08:12:24 +02:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-09-19 19:28:00 +02:00
|
|
|
/**
|
|
|
|
* qla4xxx_eh_device_reset - callback for target reset.
|
|
|
|
* @cmd: Pointer to Linux's SCSI command structure
|
|
|
|
*
|
|
|
|
* This routine is called by the Linux OS to reset all luns on the
|
|
|
|
* specified target.
|
|
|
|
**/
|
|
|
|
static int qla4xxx_eh_device_reset(struct scsi_cmnd *cmd)
|
|
|
|
{
|
|
|
|
struct scsi_qla_host *ha = to_qla_host(cmd->device->host);
|
|
|
|
struct ddb_entry *ddb_entry = cmd->device->hostdata;
|
|
|
|
int ret = FAILED, stat;
|
|
|
|
|
2009-07-15 22:03:01 +02:00
|
|
|
if (!ddb_entry)
|
2006-09-19 19:28:00 +02:00
|
|
|
return ret;
|
|
|
|
|
2010-07-22 13:29:49 +02:00
|
|
|
ret = iscsi_block_scsi_eh(cmd);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
ret = FAILED;
|
|
|
|
|
2010-07-10 11:21:02 +02:00
|
|
|
ql4_printk(KERN_INFO, ha,
|
2014-06-25 15:27:36 +02:00
|
|
|
"scsi%ld:%d:%d:%llu: DEVICE RESET ISSUED.\n", ha->host_no,
|
2006-09-19 19:28:00 +02:00
|
|
|
cmd->device->channel, cmd->device->id, cmd->device->lun);
|
|
|
|
|
|
|
|
DEBUG2(printk(KERN_INFO
|
|
|
|
"scsi%ld: DEVICE_RESET cmd=%p jiffies = 0x%lx, to=%x,"
|
|
|
|
"dpc_flags=%lx, status=%x allowed=%d\n", ha->host_no,
|
2008-09-14 14:55:09 +02:00
|
|
|
cmd, jiffies, cmd->request->timeout / HZ,
|
2006-09-19 19:28:00 +02:00
|
|
|
ha->dpc_flags, cmd->result, cmd->allowed));
|
|
|
|
|
|
|
|
/* FIXME: wait for hba to go online */
|
|
|
|
stat = qla4xxx_reset_lun(ha, ddb_entry, cmd->device->lun);
|
|
|
|
if (stat != QLA_SUCCESS) {
|
2010-07-10 11:21:02 +02:00
|
|
|
ql4_printk(KERN_INFO, ha, "DEVICE RESET FAILED. %d\n", stat);
|
2006-09-19 19:28:00 +02:00
|
|
|
goto eh_dev_reset_done;
|
|
|
|
}
|
|
|
|
|
2008-03-01 01:25:20 +01:00
|
|
|
if (qla4xxx_eh_wait_for_commands(ha, scsi_target(cmd->device),
|
|
|
|
cmd->device)) {
|
2010-07-10 11:21:02 +02:00
|
|
|
ql4_printk(KERN_INFO, ha,
|
2008-03-01 01:25:20 +01:00
|
|
|
"DEVICE RESET FAILED - waiting for "
|
|
|
|
"commands.\n");
|
|
|
|
goto eh_dev_reset_done;
|
2006-09-19 19:28:00 +02:00
|
|
|
}
|
|
|
|
|
2008-03-19 19:23:03 +01:00
|
|
|
/* Send marker. */
|
|
|
|
if (qla4xxx_send_marker_iocb(ha, ddb_entry, cmd->device->lun,
|
|
|
|
MM_LUN_RESET) != QLA_SUCCESS)
|
|
|
|
goto eh_dev_reset_done;
|
|
|
|
|
2010-07-10 11:21:02 +02:00
|
|
|
ql4_printk(KERN_INFO, ha,
|
2014-06-25 15:27:36 +02:00
|
|
|
"scsi(%ld:%d:%d:%llu): DEVICE RESET SUCCEEDED.\n",
|
2006-09-19 19:28:00 +02:00
|
|
|
ha->host_no, cmd->device->channel, cmd->device->id,
|
|
|
|
cmd->device->lun);
|
|
|
|
|
|
|
|
ret = SUCCESS;
|
|
|
|
|
|
|
|
eh_dev_reset_done:
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2008-03-01 01:25:20 +01:00
|
|
|
/**
|
|
|
|
* qla4xxx_eh_target_reset - callback for target reset.
|
|
|
|
* @cmd: Pointer to Linux's SCSI command structure
|
|
|
|
*
|
|
|
|
* This routine is called by the Linux OS to reset the target.
|
|
|
|
**/
|
|
|
|
static int qla4xxx_eh_target_reset(struct scsi_cmnd *cmd)
|
|
|
|
{
|
|
|
|
struct scsi_qla_host *ha = to_qla_host(cmd->device->host);
|
|
|
|
struct ddb_entry *ddb_entry = cmd->device->hostdata;
|
2010-07-22 13:29:49 +02:00
|
|
|
int stat, ret;
|
2008-03-01 01:25:20 +01:00
|
|
|
|
|
|
|
if (!ddb_entry)
|
|
|
|
return FAILED;
|
|
|
|
|
2010-07-22 13:29:49 +02:00
|
|
|
ret = iscsi_block_scsi_eh(cmd);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2008-03-01 01:25:20 +01:00
|
|
|
starget_printk(KERN_INFO, scsi_target(cmd->device),
|
|
|
|
"WARM TARGET RESET ISSUED.\n");
|
|
|
|
|
|
|
|
DEBUG2(printk(KERN_INFO
|
|
|
|
"scsi%ld: TARGET_DEVICE_RESET cmd=%p jiffies = 0x%lx, "
|
|
|
|
"to=%x,dpc_flags=%lx, status=%x allowed=%d\n",
|
2008-09-14 14:55:09 +02:00
|
|
|
ha->host_no, cmd, jiffies, cmd->request->timeout / HZ,
|
2008-03-01 01:25:20 +01:00
|
|
|
ha->dpc_flags, cmd->result, cmd->allowed));
|
|
|
|
|
|
|
|
stat = qla4xxx_reset_target(ha, ddb_entry);
|
|
|
|
if (stat != QLA_SUCCESS) {
|
|
|
|
starget_printk(KERN_INFO, scsi_target(cmd->device),
|
|
|
|
"WARM TARGET RESET FAILED.\n");
|
|
|
|
return FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (qla4xxx_eh_wait_for_commands(ha, scsi_target(cmd->device),
|
|
|
|
NULL)) {
|
|
|
|
starget_printk(KERN_INFO, scsi_target(cmd->device),
|
|
|
|
"WARM TARGET DEVICE RESET FAILED - "
|
|
|
|
"waiting for commands.\n");
|
|
|
|
return FAILED;
|
|
|
|
}
|
|
|
|
|
2008-03-19 19:23:03 +01:00
|
|
|
/* Send marker. */
|
|
|
|
if (qla4xxx_send_marker_iocb(ha, ddb_entry, cmd->device->lun,
|
|
|
|
MM_TGT_WARM_RESET) != QLA_SUCCESS) {
|
|
|
|
starget_printk(KERN_INFO, scsi_target(cmd->device),
|
|
|
|
"WARM TARGET DEVICE RESET FAILED - "
|
|
|
|
"marker iocb failed.\n");
|
|
|
|
return FAILED;
|
|
|
|
}
|
|
|
|
|
2008-03-01 01:25:20 +01:00
|
|
|
starget_printk(KERN_INFO, scsi_target(cmd->device),
|
|
|
|
"WARM TARGET RESET SUCCEEDED.\n");
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
2011-12-06 11:34:10 +01:00
|
|
|
/**
|
|
|
|
* qla4xxx_is_eh_active - check if error handler is running
|
|
|
|
* @shost: Pointer to SCSI Host struct
|
|
|
|
*
|
|
|
|
* This routine finds that if reset host is called in EH
|
|
|
|
* scenario or from some application like sg_reset
|
|
|
|
**/
|
|
|
|
static int qla4xxx_is_eh_active(struct Scsi_Host *shost)
|
|
|
|
{
|
|
|
|
if (shost->shost_state == SHOST_RECOVERY)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-09-19 19:28:00 +02:00
|
|
|
/**
|
|
|
|
* qla4xxx_eh_host_reset - kernel callback
|
|
|
|
* @cmd: Pointer to Linux's SCSI command structure
|
|
|
|
*
|
|
|
|
* This routine is invoked by the Linux kernel to perform fatal error
|
|
|
|
* recovery on the specified adapter.
|
|
|
|
**/
|
|
|
|
static int qla4xxx_eh_host_reset(struct scsi_cmnd *cmd)
|
|
|
|
{
|
|
|
|
int return_status = FAILED;
|
|
|
|
struct scsi_qla_host *ha;
|
|
|
|
|
2011-07-25 20:48:53 +02:00
|
|
|
ha = to_qla_host(cmd->device->host);
|
2006-09-19 19:28:00 +02:00
|
|
|
|
2013-08-16 13:03:02 +02:00
|
|
|
if ((is_qla8032(ha) || is_qla8042(ha)) && ql4xdontresethba)
|
2012-08-22 13:55:08 +02:00
|
|
|
qla4_83xx_set_idc_dontreset(ha);
|
|
|
|
|
|
|
|
/*
|
2013-08-16 13:03:02 +02:00
|
|
|
* For ISP8324 and ISP8042, if IDC_CTRL DONTRESET_BIT0 is set by other
|
|
|
|
* protocol drivers, we should not set device_state to NEED_RESET
|
2012-08-22 13:55:08 +02:00
|
|
|
*/
|
|
|
|
if (ql4xdontresethba ||
|
2013-08-16 13:03:02 +02:00
|
|
|
((is_qla8032(ha) || is_qla8042(ha)) &&
|
|
|
|
qla4_83xx_idc_dontreset(ha))) {
|
2010-07-28 12:23:44 +02:00
|
|
|
DEBUG2(printk("scsi%ld: %s: Don't Reset HBA\n",
|
|
|
|
ha->host_no, __func__));
|
2011-12-06 11:34:10 +01:00
|
|
|
|
|
|
|
/* Clear outstanding srb in queues */
|
|
|
|
if (qla4xxx_is_eh_active(cmd->device->host))
|
|
|
|
qla4xxx_abort_active_cmds(ha, DID_ABORT << 16);
|
|
|
|
|
2010-07-28 12:23:44 +02:00
|
|
|
return FAILED;
|
|
|
|
}
|
|
|
|
|
2010-07-10 11:21:02 +02:00
|
|
|
ql4_printk(KERN_INFO, ha,
|
2014-06-25 15:27:36 +02:00
|
|
|
"scsi(%ld:%d:%d:%llu): HOST RESET ISSUED.\n", ha->host_no,
|
2006-09-19 19:28:00 +02:00
|
|
|
cmd->device->channel, cmd->device->id, cmd->device->lun);
|
|
|
|
|
|
|
|
if (qla4xxx_wait_for_hba_online(ha) != QLA_SUCCESS) {
|
|
|
|
DEBUG2(printk("scsi%ld:%d: %s: Unable to reset host. Adapter "
|
|
|
|
"DEAD.\n", ha->host_no, cmd->device->channel,
|
|
|
|
__func__));
|
|
|
|
|
|
|
|
return FAILED;
|
|
|
|
}
|
|
|
|
|
2010-07-28 12:23:44 +02:00
|
|
|
if (!test_bit(DPC_RESET_HA, &ha->dpc_flags)) {
|
2012-08-22 13:55:08 +02:00
|
|
|
if (is_qla80XX(ha))
|
2010-07-28 12:23:44 +02:00
|
|
|
set_bit(DPC_RESET_HA_FW_CONTEXT, &ha->dpc_flags);
|
|
|
|
else
|
|
|
|
set_bit(DPC_RESET_HA, &ha->dpc_flags);
|
|
|
|
}
|
2008-03-04 20:26:53 +01:00
|
|
|
|
2010-07-28 12:23:44 +02:00
|
|
|
if (qla4xxx_recover_adapter(ha) == QLA_SUCCESS)
|
2006-09-19 19:28:00 +02:00
|
|
|
return_status = SUCCESS;
|
|
|
|
|
2010-07-10 11:21:02 +02:00
|
|
|
ql4_printk(KERN_INFO, ha, "HOST RESET %s.\n",
|
2011-03-31 03:57:33 +02:00
|
|
|
return_status == FAILED ? "FAILED" : "SUCCEEDED");
|
2006-09-19 19:28:00 +02:00
|
|
|
|
|
|
|
return return_status;
|
|
|
|
}
|
|
|
|
|
2011-08-12 11:51:29 +02:00
|
|
|
static int qla4xxx_context_reset(struct scsi_qla_host *ha)
|
|
|
|
{
|
|
|
|
uint32_t mbox_cmd[MBOX_REG_COUNT];
|
|
|
|
uint32_t mbox_sts[MBOX_REG_COUNT];
|
|
|
|
struct addr_ctrl_blk_def *acb = NULL;
|
|
|
|
uint32_t acb_len = sizeof(struct addr_ctrl_blk_def);
|
|
|
|
int rval = QLA_SUCCESS;
|
|
|
|
dma_addr_t acb_dma;
|
|
|
|
|
|
|
|
acb = dma_alloc_coherent(&ha->pdev->dev,
|
|
|
|
sizeof(struct addr_ctrl_blk_def),
|
|
|
|
&acb_dma, GFP_KERNEL);
|
|
|
|
if (!acb) {
|
|
|
|
ql4_printk(KERN_ERR, ha, "%s: Unable to alloc acb\n",
|
|
|
|
__func__);
|
|
|
|
rval = -ENOMEM;
|
|
|
|
goto exit_port_reset;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(acb, 0, acb_len);
|
|
|
|
|
|
|
|
rval = qla4xxx_get_acb(ha, acb_dma, PRIMARI_ACB, acb_len);
|
|
|
|
if (rval != QLA_SUCCESS) {
|
|
|
|
rval = -EIO;
|
|
|
|
goto exit_free_acb;
|
|
|
|
}
|
|
|
|
|
|
|
|
rval = qla4xxx_disable_acb(ha);
|
|
|
|
if (rval != QLA_SUCCESS) {
|
|
|
|
rval = -EIO;
|
|
|
|
goto exit_free_acb;
|
|
|
|
}
|
|
|
|
|
|
|
|
wait_for_completion_timeout(&ha->disable_acb_comp,
|
|
|
|
DISABLE_ACB_TOV * HZ);
|
|
|
|
|
|
|
|
rval = qla4xxx_set_acb(ha, &mbox_cmd[0], &mbox_sts[0], acb_dma);
|
|
|
|
if (rval != QLA_SUCCESS) {
|
|
|
|
rval = -EIO;
|
|
|
|
goto exit_free_acb;
|
|
|
|
}
|
|
|
|
|
|
|
|
exit_free_acb:
|
|
|
|
dma_free_coherent(&ha->pdev->dev, sizeof(struct addr_ctrl_blk_def),
|
|
|
|
acb, acb_dma);
|
|
|
|
exit_port_reset:
|
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha, "%s %s\n", __func__,
|
|
|
|
rval == QLA_SUCCESS ? "SUCCEEDED" : "FAILED"));
|
|
|
|
return rval;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int qla4xxx_host_reset(struct Scsi_Host *shost, int reset_type)
|
|
|
|
{
|
|
|
|
struct scsi_qla_host *ha = to_qla_host(shost);
|
|
|
|
int rval = QLA_SUCCESS;
|
2013-03-07 11:43:09 +01:00
|
|
|
uint32_t idc_ctrl;
|
2011-08-12 11:51:29 +02:00
|
|
|
|
|
|
|
if (ql4xdontresethba) {
|
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha, "%s: Don't Reset HBA\n",
|
|
|
|
__func__));
|
|
|
|
rval = -EPERM;
|
|
|
|
goto exit_host_reset;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (test_bit(DPC_RESET_HA, &ha->dpc_flags))
|
|
|
|
goto recover_adapter;
|
|
|
|
|
|
|
|
switch (reset_type) {
|
|
|
|
case SCSI_ADAPTER_RESET:
|
|
|
|
set_bit(DPC_RESET_HA, &ha->dpc_flags);
|
|
|
|
break;
|
|
|
|
case SCSI_FIRMWARE_RESET:
|
|
|
|
if (!test_bit(DPC_RESET_HA, &ha->dpc_flags)) {
|
2012-08-22 13:55:08 +02:00
|
|
|
if (is_qla80XX(ha))
|
2011-08-12 11:51:29 +02:00
|
|
|
/* set firmware context reset */
|
|
|
|
set_bit(DPC_RESET_HA_FW_CONTEXT,
|
|
|
|
&ha->dpc_flags);
|
|
|
|
else {
|
|
|
|
rval = qla4xxx_context_reset(ha);
|
|
|
|
goto exit_host_reset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
recover_adapter:
|
2013-08-16 13:03:02 +02:00
|
|
|
/* For ISP8324 and ISP8042 set graceful reset bit in IDC_DRV_CTRL if
|
2013-03-07 11:43:09 +01:00
|
|
|
* reset is issued by application */
|
2013-08-16 13:03:02 +02:00
|
|
|
if ((is_qla8032(ha) || is_qla8042(ha)) &&
|
|
|
|
test_bit(DPC_RESET_HA, &ha->dpc_flags)) {
|
2013-03-07 11:43:09 +01:00
|
|
|
idc_ctrl = qla4_83xx_rd_reg(ha, QLA83XX_IDC_DRV_CTRL);
|
|
|
|
qla4_83xx_wr_reg(ha, QLA83XX_IDC_DRV_CTRL,
|
|
|
|
(idc_ctrl | GRACEFUL_RESET_BIT1));
|
|
|
|
}
|
|
|
|
|
2011-08-12 11:51:29 +02:00
|
|
|
rval = qla4xxx_recover_adapter(ha);
|
|
|
|
if (rval != QLA_SUCCESS) {
|
|
|
|
DEBUG2(ql4_printk(KERN_INFO, ha, "%s: recover adapter fail\n",
|
|
|
|
__func__));
|
|
|
|
rval = -EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
exit_host_reset:
|
|
|
|
return rval;
|
|
|
|
}
|
|
|
|
|
2010-07-30 11:08:47 +02:00
|
|
|
/* PCI AER driver recovers from all correctable errors w/o
|
|
|
|
* driver intervention. For uncorrectable errors PCI AER
|
|
|
|
* driver calls the following device driver's callbacks
|
|
|
|
*
|
|
|
|
* - Fatal Errors - link_reset
|
2016-12-19 07:20:29 +01:00
|
|
|
* - Non-Fatal Errors - driver's error_detected() which
|
2010-07-30 11:08:47 +02:00
|
|
|
* returns CAN_RECOVER, NEED_RESET or DISCONNECT.
|
|
|
|
*
|
|
|
|
* PCI AER driver calls
|
2016-12-19 07:20:29 +01:00
|
|
|
* CAN_RECOVER - driver's mmio_enabled(), mmio_enabled()
|
2010-07-30 11:08:47 +02:00
|
|
|
* returns RECOVERED or NEED_RESET if fw_hung
|
|
|
|
* NEED_RESET - driver's slot_reset()
|
|
|
|
* DISCONNECT - device is dead & cannot recover
|
2016-12-19 07:20:29 +01:00
|
|
|
* RECOVERED - driver's resume()
|
2010-07-30 11:08:47 +02:00
|
|
|
*/
|
|
|
|
static pci_ers_result_t
|
|
|
|
qla4xxx_pci_error_detected(struct pci_dev *pdev, pci_channel_state_t state)
|
|
|
|
{
|
|
|
|
struct scsi_qla_host *ha = pci_get_drvdata(pdev);
|
|
|
|
|
|
|
|
ql4_printk(KERN_WARNING, ha, "scsi%ld: %s: error detected:state %x\n",
|
|
|
|
ha->host_no, __func__, state);
|
|
|
|
|
|
|
|
if (!is_aer_supported(ha))
|
|
|
|
return PCI_ERS_RESULT_NONE;
|
|
|
|
|
|
|
|
switch (state) {
|
|
|
|
case pci_channel_io_normal:
|
|
|
|
clear_bit(AF_EEH_BUSY, &ha->flags);
|
|
|
|
return PCI_ERS_RESULT_CAN_RECOVER;
|
|
|
|
case pci_channel_io_frozen:
|
|
|
|
set_bit(AF_EEH_BUSY, &ha->flags);
|
|
|
|
qla4xxx_mailbox_premature_completion(ha);
|
|
|
|
qla4xxx_free_irqs(ha);
|
|
|
|
pci_disable_device(pdev);
|
2010-10-07 07:50:56 +02:00
|
|
|
/* Return back all IOs */
|
|
|
|
qla4xxx_abort_active_cmds(ha, DID_RESET << 16);
|
2010-07-30 11:08:47 +02:00
|
|
|
return PCI_ERS_RESULT_NEED_RESET;
|
|
|
|
case pci_channel_io_perm_failure:
|
|
|
|
set_bit(AF_EEH_BUSY, &ha->flags);
|
|
|
|
set_bit(AF_PCI_CHANNEL_IO_PERM_FAILURE, &ha->flags);
|
|
|
|
qla4xxx_abort_active_cmds(ha, DID_NO_CONNECT << 16);
|
|
|
|
return PCI_ERS_RESULT_DISCONNECT;
|
|
|
|
}
|
|
|
|
return PCI_ERS_RESULT_NEED_RESET;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* qla4xxx_pci_mmio_enabled() gets called if
|
|
|
|
* qla4xxx_pci_error_detected() returns PCI_ERS_RESULT_CAN_RECOVER
|
|
|
|
* and read/write to the device still works.
|
|
|
|
**/
|
|
|
|
static pci_ers_result_t
|
|
|
|
qla4xxx_pci_mmio_enabled(struct pci_dev *pdev)
|
|
|
|
{
|
|
|
|
struct scsi_qla_host *ha = pci_get_drvdata(pdev);
|
|
|
|
|
|
|
|
if (!is_aer_supported(ha))
|
|
|
|
return PCI_ERS_RESULT_NONE;
|
|
|
|
|
2010-10-07 07:50:56 +02:00
|
|
|
return PCI_ERS_RESULT_RECOVERED;
|
2010-07-30 11:08:47 +02:00
|
|
|
}
|
|
|
|
|
2010-10-07 07:50:56 +02:00
|
|
|
static uint32_t qla4_8xxx_error_recovery(struct scsi_qla_host *ha)
|
2010-07-30 11:08:47 +02:00
|
|
|
{
|
|
|
|
uint32_t rval = QLA_ERROR;
|
|
|
|
int fn;
|
|
|
|
struct pci_dev *other_pdev = NULL;
|
|
|
|
|
|
|
|
ql4_printk(KERN_WARNING, ha, "scsi%ld: In %s\n", ha->host_no, __func__);
|
|
|
|
|
|
|
|
set_bit(DPC_RESET_ACTIVE, &ha->dpc_flags);
|
|
|
|
|
|
|
|
if (test_bit(AF_ONLINE, &ha->flags)) {
|
|
|
|
clear_bit(AF_ONLINE, &ha->flags);
|
2011-07-25 20:48:53 +02:00
|
|
|
clear_bit(AF_LINK_UP, &ha->flags);
|
|
|
|
iscsi_host_for_each_session(ha->host, qla4xxx_fail_session);
|
2010-07-30 11:08:47 +02:00
|
|
|
qla4xxx_process_aen(ha, FLUSH_DDB_CHANGED_AENS);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn = PCI_FUNC(ha->pdev->devfn);
|
2013-12-16 12:49:38 +01:00
|
|
|
if (is_qla8022(ha)) {
|
|
|
|
while (fn > 0) {
|
|
|
|
fn--;
|
|
|
|
ql4_printk(KERN_INFO, ha, "scsi%ld: %s: Finding PCI device at func %x\n",
|
|
|
|
ha->host_no, __func__, fn);
|
|
|
|
/* Get the pci device given the domain, bus,
|
|
|
|
* slot/function number */
|
|
|
|
other_pdev = pci_get_domain_bus_and_slot(
|
|
|
|
pci_domain_nr(ha->pdev->bus),
|
|
|
|
ha->pdev->bus->number,
|
|
|
|
PCI_DEVFN(PCI_SLOT(ha->pdev->devfn),
|
|
|
|
fn));
|
|
|
|
|
|
|
|
if (!other_pdev)
|
|
|
|
continue;
|
2010-07-30 11:08:47 +02:00
|
|
|
|
2013-12-16 12:49:38 +01:00
|
|
|
if (atomic_read(&other_pdev->enable_cnt)) {
|
|
|
|
ql4_printk(KERN_INFO, ha, "scsi%ld: %s: Found PCI func in enabled state%x\n",
|
|
|
|
ha->host_no, __func__, fn);
|
|
|
|
pci_dev_put(other_pdev);
|
|
|
|
break;
|
|
|
|
}
|
2010-07-30 11:08:47 +02:00
|
|
|
pci_dev_put(other_pdev);
|
|
|
|
}
|
2013-12-16 12:49:38 +01:00
|
|
|
} else {
|
|
|
|
/* this case is meant for ISP83xx/ISP84xx only */
|
|
|
|
if (qla4_83xx_can_perform_reset(ha)) {
|
|
|
|
/* reset fn as iSCSI is going to perform the reset */
|
|
|
|
fn = 0;
|
|
|
|
}
|
2010-07-30 11:08:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* The first function on the card, the reset owner will
|
|
|
|
* start & initialize the firmware. The other functions
|
|
|
|
* on the card will reset the firmware context
|
|
|
|
*/
|
|
|
|
if (!fn) {
|
|
|
|
ql4_printk(KERN_INFO, ha, "scsi%ld: %s: devfn being reset "
|
|
|
|
"0x%x is the owner\n", ha->host_no, __func__,
|
|
|
|
ha->pdev->devfn);
|
|
|
|
|
2012-08-22 13:55:04 +02:00
|
|
|
ha->isp_ops->idc_lock(ha);
|
|
|
|
qla4_8xxx_wr_direct(ha, QLA8XXX_CRB_DEV_STATE,
|
|
|
|
QLA8XXX_DEV_COLD);
|
|
|
|
ha->isp_ops->idc_unlock(ha);
|
2012-09-20 13:35:05 +02:00
|
|
|
|
|
|
|
rval = qla4_8xxx_update_idc_reg(ha);
|
|
|
|
if (rval == QLA_ERROR) {
|
|
|
|
ql4_printk(KERN_INFO, ha, "scsi%ld: %s: HW State: FAILED\n",
|
|
|
|
ha->host_no, __func__);
|
|
|
|
ha->isp_ops->idc_lock(ha);
|
|
|
|
qla4_8xxx_wr_direct(ha, QLA8XXX_CRB_DEV_STATE,
|
|
|
|
QLA8XXX_DEV_FAILED);
|
|
|
|
ha->isp_ops->idc_unlock(ha);
|
|
|
|
goto exit_error_recovery;
|
|
|
|
}
|
2010-07-30 11:08:47 +02:00
|
|
|
|
|
|
|
clear_bit(AF_FW_RECOVERY, &ha->flags);
|
2011-12-02 04:38:41 +01:00
|
|
|
rval = qla4xxx_initialize_adapter(ha, RESET_ADAPTER);
|
2010-07-30 11:08:47 +02:00
|
|
|
|
|
|
|
if (rval != QLA_SUCCESS) {
|
|
|
|
ql4_printk(KERN_INFO, ha, "scsi%ld: %s: HW State: "
|
|
|
|
"FAILED\n", ha->host_no, __func__);
|
2013-12-16 12:49:31 +01:00
|
|
|
qla4xxx_free_irqs(ha);
|
2012-09-20 13:35:04 +02:00
|
|
|
ha->isp_ops->idc_lock(ha);
|
2010-07-30 11:08:47 +02:00
|
|
|
qla4_8xxx_clear_drv_active(ha);
|
2012-08-22 13:55:04 +02:00
|
|
|
qla4_8xxx_wr_direct(ha, QLA8XXX_CRB_DEV_STATE,
|
|
|
|
QLA8XXX_DEV_FAILED);
|
2012-09-20 13:35:04 +02:00
|
|
|
ha->isp_ops->idc_unlock(ha);
|
2010-07-30 11:08:47 +02:00
|
|
|
} else {
|
|
|
|
ql4_printk(KERN_INFO, ha, "scsi%ld: %s: HW State: "
|
|
|
|
"READY\n", ha->host_no, __func__);
|
2012-09-20 13:35:04 +02:00
|
|
|
ha->isp_ops->idc_lock(ha);
|
2012-08-22 13:55:04 +02:00
|
|
|
qla4_8xxx_wr_direct(ha, QLA8XXX_CRB_DEV_STATE,
|
|
|
|
QLA8XXX_DEV_READY);
|
2010-07-30 11:08:47 +02:00
|
|
|
/* Clear driver state register */
|
2012-08-22 13:55:04 +02:00
|
|
|
qla4_8xxx_wr_direct(ha, QLA8XXX_CRB_DRV_STATE, 0);
|
2010-07-30 11:08:47 +02:00
|
|
|
qla4_8xxx_set_drv_active(ha);
|
2012-09-20 13:35:04 +02:00
|
|
|
ha->isp_ops->idc_unlock(ha);
|
2013-01-21 05:51:01 +01:00
|
|
|
ha->isp_ops->enable_intrs(ha);
|
2010-07-30 11:08:47 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ql4_printk(KERN_INFO, ha, "scsi%ld: %s: devfn 0x%x is not "
|
|
|
|
"the reset owner\n", ha->host_no, __func__,
|
|
|
|
ha->pdev->devfn);
|
2012-08-22 13:55:04 +02:00
|
|
|
if ((qla4_8xxx_rd_direct(ha, QLA8XXX_CRB_DEV_STATE) ==
|
|
|
|
QLA8XXX_DEV_READY)) {
|
2010-07-30 11:08:47 +02:00
|
|
|
clear_bit(AF_FW_RECOVERY, &ha->flags);
|
2011-12-02 04:38:41 +01:00
|
|
|
rval = qla4xxx_initialize_adapter(ha, RESET_ADAPTER);
|
2013-01-21 05:51:01 +01:00
|
|
|
if (rval == QLA_SUCCESS)
|
|
|
|
ha->isp_ops->enable_intrs(ha);
|
2013-12-16 12:49:31 +01:00
|
|
|
else
|
|
|
|
qla4xxx_free_irqs(ha);
|
2013-01-21 05:51:01 +01:00
|
|
|
|
2012-08-22 13:55:04 +02:00
|
|
|
ha->isp_ops->idc_lock(ha);
|
2010-07-30 11:08:47 +02:00
|
|
|
qla4_8xxx_set_drv_active(ha);
|
2012-08-22 13:55:04 +02:00
|
|
|
ha->isp_ops->idc_unlock(ha);
|
2010-07-30 11:08:47 +02:00
|
|
|
}
|
|
|
|
}
|
2012-09-20 13:35:05 +02:00
|
|
|
exit_error_recovery:
|
2010-07-30 11:08:47 +02:00
|
|
|
clear_bit(DPC_RESET_ACTIVE, &ha->dpc_flags);
|
|
|
|
return rval;
|
|
|
|
}
|
|
|
|
|
|
|
|
static pci_ers_result_t
|
|
|
|
qla4xxx_pci_slot_reset(struct pci_dev *pdev)
|
|
|
|
{
|
|
|
|
pci_ers_result_t ret = PCI_ERS_RESULT_DISCONNECT;
|
|
|
|
struct scsi_qla_host *ha = pci_get_drvdata(pdev);
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
ql4_printk(KERN_WARNING, ha, "scsi%ld: %s: slot_reset\n",
|
|
|
|
ha->host_no, __func__);
|
|
|
|
|
|
|
|
if (!is_aer_supported(ha))
|
|
|
|
return PCI_ERS_RESULT_NONE;
|
|
|
|
|
|
|
|
/* Restore the saved state of PCIe device -
|
|
|
|
* BAR registers, PCI Config space, PCIX, MSI,
|
|
|
|
* IOV states
|
|
|
|
*/
|
|
|
|
pci_restore_state(pdev);
|
|
|
|
|
|
|
|
/* pci_restore_state() clears the saved_state flag of the device
|
|
|
|
* save restored state which resets saved_state flag
|
|
|
|
*/
|
|
|
|
pci_save_state(pdev);
|
|
|
|
|
|
|
|
/* Initialize device or resume if in suspended state */
|
|
|
|
rc = pci_enable_device(pdev);
|
|
|
|
if (rc) {
|
2011-03-31 03:57:33 +02:00
|
|
|
ql4_printk(KERN_WARNING, ha, "scsi%ld: %s: Can't re-enable "
|
2010-07-30 11:08:47 +02:00
|
|
|
"device after reset\n", ha->host_no, __func__);
|
|
|
|
goto exit_slot_reset;
|
|
|
|
}
|
|
|
|
|
2010-10-07 07:50:56 +02:00
|
|
|
ha->isp_ops->disable_intrs(ha);
|
2010-07-30 11:08:47 +02:00
|
|
|
|
2012-08-22 13:55:08 +02:00
|
|
|
if (is_qla80XX(ha)) {
|
2010-07-30 11:08:47 +02:00
|
|
|
if (qla4_8xxx_error_recovery(ha) == QLA_SUCCESS) {
|
|
|
|
ret = PCI_ERS_RESULT_RECOVERED;
|
|
|
|
goto exit_slot_reset;
|
|
|
|
} else
|
|
|
|
goto exit_slot_reset;
|
|
|
|
}
|
|
|
|
|
|
|
|
exit_slot_reset:
|
|
|
|
ql4_printk(KERN_WARNING, ha, "scsi%ld: %s: Return=%x\n"
|
|
|
|
"device after reset\n", ha->host_no, __func__, ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
qla4xxx_pci_resume(struct pci_dev *pdev)
|
|
|
|
{
|
|
|
|
struct scsi_qla_host *ha = pci_get_drvdata(pdev);
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ql4_printk(KERN_WARNING, ha, "scsi%ld: %s: pci_resume\n",
|
|
|
|
ha->host_no, __func__);
|
|
|
|
|
|
|
|
ret = qla4xxx_wait_for_hba_online(ha);
|
|
|
|
if (ret != QLA_SUCCESS) {
|
|
|
|
ql4_printk(KERN_ERR, ha, "scsi%ld: %s: the device failed to "
|
|
|
|
"resume I/O from slot/link_reset\n", ha->host_no,
|
|
|
|
__func__);
|
|
|
|
}
|
|
|
|
|
|
|
|
pci_cleanup_aer_uncorrect_error_status(pdev);
|
|
|
|
clear_bit(AF_EEH_BUSY, &ha->flags);
|
|
|
|
}
|
|
|
|
|
2012-09-07 18:33:16 +02:00
|
|
|
static const struct pci_error_handlers qla4xxx_err_handler = {
|
2010-07-30 11:08:47 +02:00
|
|
|
.error_detected = qla4xxx_pci_error_detected,
|
|
|
|
.mmio_enabled = qla4xxx_pci_mmio_enabled,
|
|
|
|
.slot_reset = qla4xxx_pci_slot_reset,
|
|
|
|
.resume = qla4xxx_pci_resume,
|
|
|
|
};
|
|
|
|
|
2006-09-19 19:28:00 +02:00
|
|
|
static struct pci_device_id qla4xxx_pci_tbl[] = {
|
|
|
|
{
|
|
|
|
.vendor = PCI_VENDOR_ID_QLOGIC,
|
|
|
|
.device = PCI_DEVICE_ID_QLOGIC_ISP4010,
|
|
|
|
.subvendor = PCI_ANY_ID,
|
|
|
|
.subdevice = PCI_ANY_ID,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.vendor = PCI_VENDOR_ID_QLOGIC,
|
|
|
|
.device = PCI_DEVICE_ID_QLOGIC_ISP4022,
|
|
|
|
.subvendor = PCI_ANY_ID,
|
|
|
|
.subdevice = PCI_ANY_ID,
|
|
|
|
},
|
2006-11-16 02:38:40 +01:00
|
|
|
{
|
|
|
|
.vendor = PCI_VENDOR_ID_QLOGIC,
|
|
|
|
.device = PCI_DEVICE_ID_QLOGIC_ISP4032,
|
|
|
|
.subvendor = PCI_ANY_ID,
|
|
|
|
.subdevice = PCI_ANY_ID,
|
|
|
|
},
|
2010-07-28 12:23:44 +02:00
|
|
|
{
|
|
|
|
.vendor = PCI_VENDOR_ID_QLOGIC,
|
|
|
|
.device = PCI_DEVICE_ID_QLOGIC_ISP8022,
|
|
|
|
.subvendor = PCI_ANY_ID,
|
|
|
|
.subdevice = PCI_ANY_ID,
|
|
|
|
},
|
2012-08-22 13:55:08 +02:00
|
|
|
{
|
|
|
|
.vendor = PCI_VENDOR_ID_QLOGIC,
|
|
|
|
.device = PCI_DEVICE_ID_QLOGIC_ISP8324,
|
|
|
|
.subvendor = PCI_ANY_ID,
|
|
|
|
.subdevice = PCI_ANY_ID,
|
|
|
|
},
|
2013-08-16 13:03:02 +02:00
|
|
|
{
|
|
|
|
.vendor = PCI_VENDOR_ID_QLOGIC,
|
|
|
|
.device = PCI_DEVICE_ID_QLOGIC_ISP8042,
|
|
|
|
.subvendor = PCI_ANY_ID,
|
|
|
|
.subdevice = PCI_ANY_ID,
|
|
|
|
},
|
2006-09-19 19:28:00 +02:00
|
|
|
{0, 0},
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(pci, qla4xxx_pci_tbl);
|
|
|
|
|
2007-04-26 09:35:16 +02:00
|
|
|
static struct pci_driver qla4xxx_pci_driver = {
|
2006-09-19 19:28:00 +02:00
|
|
|
.name = DRIVER_NAME,
|
|
|
|
.id_table = qla4xxx_pci_tbl,
|
|
|
|
.probe = qla4xxx_probe_adapter,
|
|
|
|
.remove = qla4xxx_remove_adapter,
|
2010-07-30 11:08:47 +02:00
|
|
|
.err_handler = &qla4xxx_err_handler,
|
2006-09-19 19:28:00 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static int __init qla4xxx_module_init(void)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2014-11-13 14:25:11 +01:00
|
|
|
if (ql4xqfulltracking)
|
|
|
|
qla4xxx_driver_template.track_queue_depth = 1;
|
|
|
|
|
2006-09-19 19:28:00 +02:00
|
|
|
/* Allocate cache for SRBs. */
|
|
|
|
srb_cachep = kmem_cache_create("qla4xxx_srbs", sizeof(struct srb), 0,
|
2007-07-20 03:11:58 +02:00
|
|
|
SLAB_HWCACHE_ALIGN, NULL);
|
2006-09-19 19:28:00 +02:00
|
|
|
if (srb_cachep == NULL) {
|
|
|
|
printk(KERN_ERR
|
|
|
|
"%s: Unable to allocate SRB cache..."
|
|
|
|
"Failing load!\n", DRIVER_NAME);
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto no_srp_cache;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Derive version string. */
|
|
|
|
strcpy(qla4xxx_version_str, QLA4XXX_DRIVER_VERSION);
|
2006-10-06 18:54:59 +02:00
|
|
|
if (ql4xextended_error_logging)
|
2006-09-19 19:28:00 +02:00
|
|
|
strcat(qla4xxx_version_str, "-debug");
|
|
|
|
|
|
|
|
qla4xxx_scsi_transport =
|
|
|
|
iscsi_register_transport(&qla4xxx_iscsi_transport);
|
|
|
|
if (!qla4xxx_scsi_transport){
|
|
|
|
ret = -ENODEV;
|
|
|
|
goto release_srb_cache;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = pci_register_driver(&qla4xxx_pci_driver);
|
|
|
|
if (ret)
|
|
|
|
goto unregister_transport;
|
|
|
|
|
|
|
|
printk(KERN_INFO "QLogic iSCSI HBA Driver\n");
|
|
|
|
return 0;
|
2006-10-06 06:50:07 +02:00
|
|
|
|
2006-09-19 19:28:00 +02:00
|
|
|
unregister_transport:
|
|
|
|
iscsi_unregister_transport(&qla4xxx_iscsi_transport);
|
|
|
|
release_srb_cache:
|
|
|
|
kmem_cache_destroy(srb_cachep);
|
|
|
|
no_srp_cache:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit qla4xxx_module_exit(void)
|
|
|
|
{
|
|
|
|
pci_unregister_driver(&qla4xxx_pci_driver);
|
|
|
|
iscsi_unregister_transport(&qla4xxx_iscsi_transport);
|
|
|
|
kmem_cache_destroy(srb_cachep);
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(qla4xxx_module_init);
|
|
|
|
module_exit(qla4xxx_module_exit);
|
|
|
|
|
|
|
|
MODULE_AUTHOR("QLogic Corporation");
|
|
|
|
MODULE_DESCRIPTION("QLogic iSCSI HBA Driver");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_VERSION(QLA4XXX_DRIVER_VERSION);
|