2009-04-17 19:33:26 -06:00
|
|
|
/*
|
|
|
|
* Copyright 2008 Cisco Systems, Inc. All rights reserved.
|
|
|
|
* Copyright 2007 Nuova Systems, Inc. All rights reserved.
|
|
|
|
*
|
|
|
|
* This program is free software; you may redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
|
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
|
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/mempool.h>
|
|
|
|
#include <linux/string.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 02:04:11 -06:00
|
|
|
#include <linux/slab.h>
|
2009-04-17 19:33:26 -06:00
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/skbuff.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/spinlock.h>
|
|
|
|
#include <linux/workqueue.h>
|
2009-11-03 12:49:22 -07:00
|
|
|
#include <linux/if_ether.h>
|
|
|
|
#include <scsi/fc/fc_fip.h>
|
2009-04-17 19:33:26 -06:00
|
|
|
#include <scsi/scsi_host.h>
|
|
|
|
#include <scsi/scsi_transport.h>
|
|
|
|
#include <scsi/scsi_transport_fc.h>
|
|
|
|
#include <scsi/scsi_tcq.h>
|
|
|
|
#include <scsi/libfc.h>
|
|
|
|
#include <scsi/fc_frame.h>
|
|
|
|
|
|
|
|
#include "vnic_dev.h"
|
|
|
|
#include "vnic_intr.h"
|
|
|
|
#include "vnic_stats.h"
|
|
|
|
#include "fnic_io.h"
|
2013-02-25 17:18:36 -07:00
|
|
|
#include "fnic_fip.h"
|
2009-04-17 19:33:26 -06:00
|
|
|
#include "fnic.h"
|
|
|
|
|
|
|
|
#define PCI_DEVICE_ID_CISCO_FNIC 0x0045
|
|
|
|
|
|
|
|
/* Timer to poll notification area for events. Used for MSI interrupts */
|
|
|
|
#define FNIC_NOTIFY_TIMER_PERIOD (2 * HZ)
|
|
|
|
|
|
|
|
static struct kmem_cache *fnic_sgl_cache[FNIC_SGL_NUM_CACHES];
|
|
|
|
static struct kmem_cache *fnic_io_req_cache;
|
|
|
|
LIST_HEAD(fnic_list);
|
|
|
|
DEFINE_SPINLOCK(fnic_list_lock);
|
|
|
|
|
|
|
|
/* Supported devices by fnic module */
|
|
|
|
static struct pci_device_id fnic_id_table[] = {
|
|
|
|
{ PCI_DEVICE(PCI_VENDOR_ID_CISCO, PCI_DEVICE_ID_CISCO_FNIC) },
|
|
|
|
{ 0, }
|
|
|
|
};
|
|
|
|
|
|
|
|
MODULE_DESCRIPTION(DRV_DESCRIPTION);
|
|
|
|
MODULE_AUTHOR("Abhijeet Joglekar <abjoglek@cisco.com>, "
|
|
|
|
"Joseph R. Eykholt <jeykholt@cisco.com>");
|
|
|
|
MODULE_LICENSE("GPL v2");
|
|
|
|
MODULE_VERSION(DRV_VERSION);
|
|
|
|
MODULE_DEVICE_TABLE(pci, fnic_id_table);
|
|
|
|
|
|
|
|
unsigned int fnic_log_level;
|
|
|
|
module_param(fnic_log_level, int, S_IRUGO|S_IWUSR);
|
|
|
|
MODULE_PARM_DESC(fnic_log_level, "bit mask of fnic logging levels");
|
|
|
|
|
2013-02-12 18:01:02 -07:00
|
|
|
unsigned int fnic_trace_max_pages = 16;
|
|
|
|
module_param(fnic_trace_max_pages, uint, S_IRUGO|S_IWUSR);
|
|
|
|
MODULE_PARM_DESC(fnic_trace_max_pages, "Total allocated memory pages "
|
|
|
|
"for fnic trace buffer");
|
2009-04-17 19:33:26 -06:00
|
|
|
|
2014-04-18 13:28:19 -06:00
|
|
|
unsigned int fnic_fc_trace_max_pages = 64;
|
|
|
|
module_param(fnic_fc_trace_max_pages, uint, S_IRUGO|S_IWUSR);
|
|
|
|
MODULE_PARM_DESC(fnic_fc_trace_max_pages,
|
|
|
|
"Total allocated memory pages for fc trace buffer");
|
|
|
|
|
2013-09-09 14:31:51 -06:00
|
|
|
static unsigned int fnic_max_qdepth = FNIC_DFLT_QUEUE_DEPTH;
|
|
|
|
module_param(fnic_max_qdepth, uint, S_IRUGO|S_IWUSR);
|
|
|
|
MODULE_PARM_DESC(fnic_max_qdepth, "Queue depth to report for each LUN");
|
|
|
|
|
2009-04-17 19:33:26 -06:00
|
|
|
static struct libfc_function_template fnic_transport_template = {
|
|
|
|
.frame_send = fnic_send,
|
2009-11-03 12:49:22 -07:00
|
|
|
.lport_set_port_id = fnic_set_port_id,
|
2009-04-17 19:33:26 -06:00
|
|
|
.fcp_abort_io = fnic_empty_scsi_cleanup,
|
|
|
|
.fcp_cleanup = fnic_empty_scsi_cleanup,
|
|
|
|
.exch_mgr_reset = fnic_exch_mgr_reset
|
|
|
|
};
|
|
|
|
|
|
|
|
static int fnic_slave_alloc(struct scsi_device *sdev)
|
|
|
|
{
|
|
|
|
struct fc_rport *rport = starget_to_rport(scsi_target(sdev));
|
|
|
|
|
|
|
|
sdev->tagged_supported = 1;
|
|
|
|
|
|
|
|
if (!rport || fc_remote_port_chkready(rport))
|
|
|
|
return -ENXIO;
|
|
|
|
|
2013-09-09 14:31:51 -06:00
|
|
|
scsi_activate_tcq(sdev, fnic_max_qdepth);
|
2009-04-17 19:33:26 -06:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct scsi_host_template fnic_host_template = {
|
|
|
|
.module = THIS_MODULE,
|
|
|
|
.name = DRV_NAME,
|
|
|
|
.queuecommand = fnic_queuecommand,
|
|
|
|
.eh_abort_handler = fnic_abort_cmd,
|
|
|
|
.eh_device_reset_handler = fnic_device_reset,
|
|
|
|
.eh_host_reset_handler = fnic_host_reset,
|
|
|
|
.slave_alloc = fnic_slave_alloc,
|
|
|
|
.change_queue_depth = fc_change_queue_depth,
|
|
|
|
.change_queue_type = fc_change_queue_type,
|
|
|
|
.this_id = -1,
|
|
|
|
.cmd_per_lun = 3,
|
2014-04-18 13:28:17 -06:00
|
|
|
.can_queue = FNIC_DFLT_IO_REQ,
|
2009-04-17 19:33:26 -06:00
|
|
|
.use_clustering = ENABLE_CLUSTERING,
|
|
|
|
.sg_tablesize = FNIC_MAX_SG_DESC_CNT,
|
|
|
|
.max_sectors = 0xffff,
|
|
|
|
.shost_attrs = fnic_attrs,
|
|
|
|
};
|
|
|
|
|
2010-08-06 02:02:40 -06:00
|
|
|
static void
|
2010-09-15 15:52:28 -06:00
|
|
|
fnic_set_rport_dev_loss_tmo(struct fc_rport *rport, u32 timeout)
|
2010-08-06 02:02:40 -06:00
|
|
|
{
|
2010-09-15 15:52:28 -06:00
|
|
|
if (timeout)
|
|
|
|
rport->dev_loss_tmo = timeout;
|
|
|
|
else
|
|
|
|
rport->dev_loss_tmo = 1;
|
2010-08-06 02:02:40 -06:00
|
|
|
}
|
|
|
|
|
2009-04-17 19:33:26 -06:00
|
|
|
static void fnic_get_host_speed(struct Scsi_Host *shost);
|
|
|
|
static struct scsi_transport_template *fnic_fc_transport;
|
|
|
|
static struct fc_host_statistics *fnic_get_stats(struct Scsi_Host *);
|
2013-09-09 14:31:45 -06:00
|
|
|
static void fnic_reset_host_stats(struct Scsi_Host *);
|
2009-04-17 19:33:26 -06:00
|
|
|
|
|
|
|
static struct fc_function_template fnic_fc_functions = {
|
|
|
|
|
|
|
|
.show_host_node_name = 1,
|
|
|
|
.show_host_port_name = 1,
|
|
|
|
.show_host_supported_classes = 1,
|
|
|
|
.show_host_supported_fc4s = 1,
|
|
|
|
.show_host_active_fc4s = 1,
|
|
|
|
.show_host_maxframe_size = 1,
|
|
|
|
.show_host_port_id = 1,
|
|
|
|
.show_host_supported_speeds = 1,
|
|
|
|
.get_host_speed = fnic_get_host_speed,
|
|
|
|
.show_host_speed = 1,
|
|
|
|
.show_host_port_type = 1,
|
|
|
|
.get_host_port_state = fc_get_host_port_state,
|
|
|
|
.show_host_port_state = 1,
|
|
|
|
.show_host_symbolic_name = 1,
|
|
|
|
.show_rport_maxframe_size = 1,
|
|
|
|
.show_rport_supported_classes = 1,
|
|
|
|
.show_host_fabric_name = 1,
|
|
|
|
.show_starget_node_name = 1,
|
|
|
|
.show_starget_port_name = 1,
|
|
|
|
.show_starget_port_id = 1,
|
|
|
|
.show_rport_dev_loss_tmo = 1,
|
2010-09-15 15:52:28 -06:00
|
|
|
.set_rport_dev_loss_tmo = fnic_set_rport_dev_loss_tmo,
|
2009-04-17 19:33:26 -06:00
|
|
|
.issue_fc_host_lip = fnic_reset,
|
|
|
|
.get_fc_host_stats = fnic_get_stats,
|
2013-09-09 14:31:45 -06:00
|
|
|
.reset_fc_host_stats = fnic_reset_host_stats,
|
2009-04-17 19:33:26 -06:00
|
|
|
.dd_fcrport_size = sizeof(struct fc_rport_libfc_priv),
|
|
|
|
.terminate_rport_io = fnic_terminate_rport_io,
|
2009-11-03 12:49:32 -07:00
|
|
|
.bsg_request = fc_lport_bsg_request,
|
2009-04-17 19:33:26 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
static void fnic_get_host_speed(struct Scsi_Host *shost)
|
|
|
|
{
|
|
|
|
struct fc_lport *lp = shost_priv(shost);
|
|
|
|
struct fnic *fnic = lport_priv(lp);
|
|
|
|
u32 port_speed = vnic_dev_port_speed(fnic->vdev);
|
|
|
|
|
|
|
|
/* Add in other values as they get defined in fw */
|
|
|
|
switch (port_speed) {
|
|
|
|
case 10000:
|
|
|
|
fc_host_speed(shost) = FC_PORTSPEED_10GBIT;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
fc_host_speed(shost) = FC_PORTSPEED_10GBIT;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct fc_host_statistics *fnic_get_stats(struct Scsi_Host *host)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
struct fc_lport *lp = shost_priv(host);
|
|
|
|
struct fnic *fnic = lport_priv(lp);
|
|
|
|
struct fc_host_statistics *stats = &lp->host_stats;
|
|
|
|
struct vnic_stats *vs;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
if (time_before(jiffies, fnic->stats_time + HZ / FNIC_STATS_RATE_LIMIT))
|
|
|
|
return stats;
|
|
|
|
fnic->stats_time = jiffies;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&fnic->fnic_lock, flags);
|
|
|
|
ret = vnic_dev_stats_dump(fnic->vdev, &fnic->stats);
|
|
|
|
spin_unlock_irqrestore(&fnic->fnic_lock, flags);
|
|
|
|
|
|
|
|
if (ret) {
|
|
|
|
FNIC_MAIN_DBG(KERN_DEBUG, fnic->lport->host,
|
|
|
|
"fnic: Get vnic stats failed"
|
|
|
|
" 0x%x", ret);
|
|
|
|
return stats;
|
|
|
|
}
|
|
|
|
vs = fnic->stats;
|
|
|
|
stats->tx_frames = vs->tx.tx_unicast_frames_ok;
|
|
|
|
stats->tx_words = vs->tx.tx_unicast_bytes_ok / 4;
|
|
|
|
stats->rx_frames = vs->rx.rx_unicast_frames_ok;
|
|
|
|
stats->rx_words = vs->rx.rx_unicast_bytes_ok / 4;
|
|
|
|
stats->error_frames = vs->tx.tx_errors + vs->rx.rx_errors;
|
|
|
|
stats->dumped_frames = vs->tx.tx_drops + vs->rx.rx_drop;
|
|
|
|
stats->invalid_crc_count = vs->rx.rx_crc_errors;
|
2013-09-09 14:31:45 -06:00
|
|
|
stats->seconds_since_last_reset =
|
|
|
|
(jiffies - fnic->stats_reset_time) / HZ;
|
2009-04-17 19:33:26 -06:00
|
|
|
stats->fcp_input_megabytes = div_u64(fnic->fcp_input_bytes, 1000000);
|
|
|
|
stats->fcp_output_megabytes = div_u64(fnic->fcp_output_bytes, 1000000);
|
|
|
|
|
|
|
|
return stats;
|
|
|
|
}
|
|
|
|
|
2013-09-09 14:31:45 -06:00
|
|
|
/*
|
|
|
|
* fnic_dump_fchost_stats
|
|
|
|
* note : dumps fc_statistics into system logs
|
|
|
|
*/
|
|
|
|
void fnic_dump_fchost_stats(struct Scsi_Host *host,
|
|
|
|
struct fc_host_statistics *stats)
|
|
|
|
{
|
|
|
|
FNIC_MAIN_NOTE(KERN_NOTICE, host,
|
|
|
|
"fnic: seconds since last reset = %llu\n",
|
|
|
|
stats->seconds_since_last_reset);
|
|
|
|
FNIC_MAIN_NOTE(KERN_NOTICE, host,
|
|
|
|
"fnic: tx frames = %llu\n",
|
|
|
|
stats->tx_frames);
|
|
|
|
FNIC_MAIN_NOTE(KERN_NOTICE, host,
|
|
|
|
"fnic: tx words = %llu\n",
|
|
|
|
stats->tx_words);
|
|
|
|
FNIC_MAIN_NOTE(KERN_NOTICE, host,
|
|
|
|
"fnic: rx frames = %llu\n",
|
|
|
|
stats->rx_frames);
|
|
|
|
FNIC_MAIN_NOTE(KERN_NOTICE, host,
|
|
|
|
"fnic: rx words = %llu\n",
|
|
|
|
stats->rx_words);
|
|
|
|
FNIC_MAIN_NOTE(KERN_NOTICE, host,
|
|
|
|
"fnic: lip count = %llu\n",
|
|
|
|
stats->lip_count);
|
|
|
|
FNIC_MAIN_NOTE(KERN_NOTICE, host,
|
|
|
|
"fnic: nos count = %llu\n",
|
|
|
|
stats->nos_count);
|
|
|
|
FNIC_MAIN_NOTE(KERN_NOTICE, host,
|
|
|
|
"fnic: error frames = %llu\n",
|
|
|
|
stats->error_frames);
|
|
|
|
FNIC_MAIN_NOTE(KERN_NOTICE, host,
|
|
|
|
"fnic: dumped frames = %llu\n",
|
|
|
|
stats->dumped_frames);
|
|
|
|
FNIC_MAIN_NOTE(KERN_NOTICE, host,
|
|
|
|
"fnic: link failure count = %llu\n",
|
|
|
|
stats->link_failure_count);
|
|
|
|
FNIC_MAIN_NOTE(KERN_NOTICE, host,
|
|
|
|
"fnic: loss of sync count = %llu\n",
|
|
|
|
stats->loss_of_sync_count);
|
|
|
|
FNIC_MAIN_NOTE(KERN_NOTICE, host,
|
|
|
|
"fnic: loss of signal count = %llu\n",
|
|
|
|
stats->loss_of_signal_count);
|
|
|
|
FNIC_MAIN_NOTE(KERN_NOTICE, host,
|
|
|
|
"fnic: prim seq protocol err count = %llu\n",
|
|
|
|
stats->prim_seq_protocol_err_count);
|
|
|
|
FNIC_MAIN_NOTE(KERN_NOTICE, host,
|
|
|
|
"fnic: invalid tx word count= %llu\n",
|
|
|
|
stats->invalid_tx_word_count);
|
|
|
|
FNIC_MAIN_NOTE(KERN_NOTICE, host,
|
|
|
|
"fnic: invalid crc count = %llu\n",
|
|
|
|
stats->invalid_crc_count);
|
|
|
|
FNIC_MAIN_NOTE(KERN_NOTICE, host,
|
|
|
|
"fnic: fcp input requests = %llu\n",
|
|
|
|
stats->fcp_input_requests);
|
|
|
|
FNIC_MAIN_NOTE(KERN_NOTICE, host,
|
|
|
|
"fnic: fcp output requests = %llu\n",
|
|
|
|
stats->fcp_output_requests);
|
|
|
|
FNIC_MAIN_NOTE(KERN_NOTICE, host,
|
|
|
|
"fnic: fcp control requests = %llu\n",
|
|
|
|
stats->fcp_control_requests);
|
|
|
|
FNIC_MAIN_NOTE(KERN_NOTICE, host,
|
|
|
|
"fnic: fcp input megabytes = %llu\n",
|
|
|
|
stats->fcp_input_megabytes);
|
|
|
|
FNIC_MAIN_NOTE(KERN_NOTICE, host,
|
|
|
|
"fnic: fcp output megabytes = %llu\n",
|
|
|
|
stats->fcp_output_megabytes);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* fnic_reset_host_stats : clears host stats
|
|
|
|
* note : called when reset_statistics set under sysfs dir
|
|
|
|
*/
|
|
|
|
static void fnic_reset_host_stats(struct Scsi_Host *host)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
struct fc_lport *lp = shost_priv(host);
|
|
|
|
struct fnic *fnic = lport_priv(lp);
|
|
|
|
struct fc_host_statistics *stats;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
/* dump current stats, before clearing them */
|
|
|
|
stats = fnic_get_stats(host);
|
|
|
|
fnic_dump_fchost_stats(host, stats);
|
|
|
|
|
|
|
|
spin_lock_irqsave(&fnic->fnic_lock, flags);
|
|
|
|
ret = vnic_dev_stats_clear(fnic->vdev);
|
|
|
|
spin_unlock_irqrestore(&fnic->fnic_lock, flags);
|
|
|
|
|
|
|
|
if (ret) {
|
|
|
|
FNIC_MAIN_DBG(KERN_DEBUG, fnic->lport->host,
|
|
|
|
"fnic: Reset vnic stats failed"
|
|
|
|
" 0x%x", ret);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
fnic->stats_reset_time = jiffies;
|
|
|
|
memset(stats, 0, sizeof(*stats));
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-04-17 19:33:26 -06:00
|
|
|
void fnic_log_q_error(struct fnic *fnic)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
u32 error_status;
|
|
|
|
|
|
|
|
for (i = 0; i < fnic->raw_wq_count; i++) {
|
|
|
|
error_status = ioread32(&fnic->wq[i].ctrl->error_status);
|
|
|
|
if (error_status)
|
|
|
|
shost_printk(KERN_ERR, fnic->lport->host,
|
|
|
|
"WQ[%d] error_status"
|
|
|
|
" %d\n", i, error_status);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < fnic->rq_count; i++) {
|
|
|
|
error_status = ioread32(&fnic->rq[i].ctrl->error_status);
|
|
|
|
if (error_status)
|
|
|
|
shost_printk(KERN_ERR, fnic->lport->host,
|
|
|
|
"RQ[%d] error_status"
|
|
|
|
" %d\n", i, error_status);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < fnic->wq_copy_count; i++) {
|
|
|
|
error_status = ioread32(&fnic->wq_copy[i].ctrl->error_status);
|
|
|
|
if (error_status)
|
|
|
|
shost_printk(KERN_ERR, fnic->lport->host,
|
|
|
|
"CWQ[%d] error_status"
|
|
|
|
" %d\n", i, error_status);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void fnic_handle_link_event(struct fnic *fnic)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&fnic->fnic_lock, flags);
|
|
|
|
if (fnic->stop_rx_link_events) {
|
|
|
|
spin_unlock_irqrestore(&fnic->fnic_lock, flags);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&fnic->fnic_lock, flags);
|
|
|
|
|
|
|
|
queue_work(fnic_event_queue, &fnic->link_work);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static int fnic_notify_set(struct fnic *fnic)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
|
|
|
switch (vnic_dev_get_intr_mode(fnic->vdev)) {
|
|
|
|
case VNIC_DEV_INTR_MODE_INTX:
|
|
|
|
err = vnic_dev_notify_set(fnic->vdev, FNIC_INTX_NOTIFY);
|
|
|
|
break;
|
|
|
|
case VNIC_DEV_INTR_MODE_MSI:
|
|
|
|
err = vnic_dev_notify_set(fnic->vdev, -1);
|
|
|
|
break;
|
|
|
|
case VNIC_DEV_INTR_MODE_MSIX:
|
|
|
|
err = vnic_dev_notify_set(fnic->vdev, FNIC_MSIX_ERR_NOTIFY);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
shost_printk(KERN_ERR, fnic->lport->host,
|
|
|
|
"Interrupt mode should be set up"
|
|
|
|
" before devcmd notify set %d\n",
|
|
|
|
vnic_dev_get_intr_mode(fnic->vdev));
|
|
|
|
err = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void fnic_notify_timer(unsigned long data)
|
|
|
|
{
|
|
|
|
struct fnic *fnic = (struct fnic *)data;
|
|
|
|
|
|
|
|
fnic_handle_link_event(fnic);
|
|
|
|
mod_timer(&fnic->notify_timer,
|
|
|
|
round_jiffies(jiffies + FNIC_NOTIFY_TIMER_PERIOD));
|
|
|
|
}
|
|
|
|
|
2013-02-25 17:18:36 -07:00
|
|
|
static void fnic_fip_notify_timer(unsigned long data)
|
|
|
|
{
|
|
|
|
struct fnic *fnic = (struct fnic *)data;
|
|
|
|
|
|
|
|
fnic_handle_fip_timer(fnic);
|
|
|
|
}
|
|
|
|
|
2009-04-17 19:33:26 -06:00
|
|
|
static void fnic_notify_timer_start(struct fnic *fnic)
|
|
|
|
{
|
|
|
|
switch (vnic_dev_get_intr_mode(fnic->vdev)) {
|
|
|
|
case VNIC_DEV_INTR_MODE_MSI:
|
|
|
|
/*
|
|
|
|
* Schedule first timeout immediately. The driver is
|
|
|
|
* initiatialized and ready to look for link up notification
|
|
|
|
*/
|
|
|
|
mod_timer(&fnic->notify_timer, jiffies);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* Using intr for notification for INTx/MSI-X */
|
|
|
|
break;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
static int fnic_dev_wait(struct vnic_dev *vdev,
|
|
|
|
int (*start)(struct vnic_dev *, int),
|
|
|
|
int (*finished)(struct vnic_dev *, int *),
|
|
|
|
int arg)
|
|
|
|
{
|
|
|
|
unsigned long time;
|
|
|
|
int done;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
err = start(vdev, arg);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
/* Wait for func to complete...2 seconds max */
|
|
|
|
time = jiffies + (HZ * 2);
|
|
|
|
do {
|
|
|
|
err = finished(vdev, &done);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
if (done)
|
|
|
|
return 0;
|
|
|
|
schedule_timeout_uninterruptible(HZ / 10);
|
|
|
|
} while (time_after(time, jiffies));
|
|
|
|
|
|
|
|
return -ETIMEDOUT;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int fnic_cleanup(struct fnic *fnic)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
vnic_dev_disable(fnic->vdev);
|
|
|
|
for (i = 0; i < fnic->intr_count; i++)
|
|
|
|
vnic_intr_mask(&fnic->intr[i]);
|
|
|
|
|
|
|
|
for (i = 0; i < fnic->rq_count; i++) {
|
|
|
|
err = vnic_rq_disable(&fnic->rq[i]);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
for (i = 0; i < fnic->raw_wq_count; i++) {
|
|
|
|
err = vnic_wq_disable(&fnic->wq[i]);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
for (i = 0; i < fnic->wq_copy_count; i++) {
|
|
|
|
err = vnic_wq_copy_disable(&fnic->wq_copy[i]);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Clean up completed IOs and FCS frames */
|
|
|
|
fnic_wq_copy_cmpl_handler(fnic, -1);
|
|
|
|
fnic_wq_cmpl_handler(fnic, -1);
|
|
|
|
fnic_rq_cmpl_handler(fnic, -1);
|
|
|
|
|
|
|
|
/* Clean up the IOs and FCS frames that have not completed */
|
|
|
|
for (i = 0; i < fnic->raw_wq_count; i++)
|
|
|
|
vnic_wq_clean(&fnic->wq[i], fnic_free_wq_buf);
|
|
|
|
for (i = 0; i < fnic->rq_count; i++)
|
|
|
|
vnic_rq_clean(&fnic->rq[i], fnic_free_rq_buf);
|
|
|
|
for (i = 0; i < fnic->wq_copy_count; i++)
|
|
|
|
vnic_wq_copy_clean(&fnic->wq_copy[i],
|
|
|
|
fnic_wq_copy_cleanup_handler);
|
|
|
|
|
|
|
|
for (i = 0; i < fnic->cq_count; i++)
|
|
|
|
vnic_cq_clean(&fnic->cq[i]);
|
|
|
|
for (i = 0; i < fnic->intr_count; i++)
|
|
|
|
vnic_intr_clean(&fnic->intr[i]);
|
|
|
|
|
|
|
|
mempool_destroy(fnic->io_req_pool);
|
|
|
|
for (i = 0; i < FNIC_SGL_NUM_CACHES; i++)
|
|
|
|
mempool_destroy(fnic->io_sgl_pool[i]);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void fnic_iounmap(struct fnic *fnic)
|
|
|
|
{
|
|
|
|
if (fnic->bar0.vaddr)
|
|
|
|
iounmap(fnic->bar0.vaddr);
|
|
|
|
}
|
|
|
|
|
2009-11-03 12:49:22 -07:00
|
|
|
/**
|
|
|
|
* fnic_get_mac() - get assigned data MAC address for FIP code.
|
|
|
|
* @lport: local port.
|
|
|
|
*/
|
|
|
|
static u8 *fnic_get_mac(struct fc_lport *lport)
|
|
|
|
{
|
|
|
|
struct fnic *fnic = lport_priv(lport);
|
|
|
|
|
|
|
|
return fnic->data_src_addr;
|
|
|
|
}
|
|
|
|
|
2013-02-25 17:18:36 -07:00
|
|
|
static void fnic_set_vlan(struct fnic *fnic, u16 vlan_id)
|
|
|
|
{
|
|
|
|
u16 old_vlan;
|
|
|
|
old_vlan = vnic_dev_set_default_vlan(fnic->vdev, vlan_id);
|
|
|
|
}
|
|
|
|
|
2012-12-21 14:08:55 -07:00
|
|
|
static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
2009-04-17 19:33:26 -06:00
|
|
|
{
|
|
|
|
struct Scsi_Host *host;
|
|
|
|
struct fc_lport *lp;
|
|
|
|
struct fnic *fnic;
|
|
|
|
mempool_t *pool;
|
|
|
|
int err;
|
|
|
|
int i;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate SCSI Host and set up association between host,
|
|
|
|
* local port, and fnic
|
|
|
|
*/
|
2009-11-03 12:46:08 -07:00
|
|
|
lp = libfc_host_alloc(&fnic_host_template, sizeof(struct fnic));
|
|
|
|
if (!lp) {
|
|
|
|
printk(KERN_ERR PFX "Unable to alloc libfc local port\n");
|
2009-04-17 19:33:26 -06:00
|
|
|
err = -ENOMEM;
|
|
|
|
goto err_out;
|
|
|
|
}
|
2009-11-03 12:46:08 -07:00
|
|
|
host = lp->host;
|
2009-04-17 19:33:26 -06:00
|
|
|
fnic = lport_priv(lp);
|
|
|
|
fnic->lport = lp;
|
2009-11-03 12:49:22 -07:00
|
|
|
fnic->ctlr.lp = lp;
|
2009-04-17 19:33:26 -06:00
|
|
|
|
|
|
|
snprintf(fnic->name, sizeof(fnic->name) - 1, "%s%d", DRV_NAME,
|
|
|
|
host->host_no);
|
|
|
|
|
|
|
|
host->transportt = fnic_fc_transport;
|
|
|
|
|
2013-09-12 18:45:42 -06:00
|
|
|
err = fnic_stats_debugfs_init(fnic);
|
|
|
|
if (err) {
|
|
|
|
shost_printk(KERN_ERR, fnic->lport->host,
|
|
|
|
"Failed to initialize debugfs for stats\n");
|
|
|
|
fnic_stats_debugfs_remove(fnic);
|
|
|
|
}
|
|
|
|
|
2009-04-17 19:33:26 -06:00
|
|
|
/* Setup PCI resources */
|
|
|
|
pci_set_drvdata(pdev, fnic);
|
|
|
|
|
|
|
|
fnic->pdev = pdev;
|
|
|
|
|
|
|
|
err = pci_enable_device(pdev);
|
|
|
|
if (err) {
|
|
|
|
shost_printk(KERN_ERR, fnic->lport->host,
|
|
|
|
"Cannot enable PCI device, aborting.\n");
|
|
|
|
goto err_out_free_hba;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = pci_request_regions(pdev, DRV_NAME);
|
|
|
|
if (err) {
|
|
|
|
shost_printk(KERN_ERR, fnic->lport->host,
|
|
|
|
"Cannot enable PCI resources, aborting\n");
|
|
|
|
goto err_out_disable_device;
|
|
|
|
}
|
|
|
|
|
|
|
|
pci_set_master(pdev);
|
|
|
|
|
|
|
|
/* Query PCI controller on system for DMA addressing
|
2013-09-09 14:31:47 -06:00
|
|
|
* limitation for the device. Try 64-bit first, and
|
2009-04-17 19:33:26 -06:00
|
|
|
* fail to 32-bit.
|
|
|
|
*/
|
2013-09-09 14:31:47 -06:00
|
|
|
err = pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
|
2009-04-17 19:33:26 -06:00
|
|
|
if (err) {
|
2009-06-24 08:42:25 -06:00
|
|
|
err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
|
2009-04-17 19:33:26 -06:00
|
|
|
if (err) {
|
|
|
|
shost_printk(KERN_ERR, fnic->lport->host,
|
|
|
|
"No usable DMA configuration "
|
|
|
|
"aborting\n");
|
|
|
|
goto err_out_release_regions;
|
|
|
|
}
|
2009-06-24 08:42:25 -06:00
|
|
|
err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
|
2009-04-17 19:33:26 -06:00
|
|
|
if (err) {
|
|
|
|
shost_printk(KERN_ERR, fnic->lport->host,
|
|
|
|
"Unable to obtain 32-bit DMA "
|
|
|
|
"for consistent allocations, aborting.\n");
|
|
|
|
goto err_out_release_regions;
|
|
|
|
}
|
|
|
|
} else {
|
2013-09-09 14:31:47 -06:00
|
|
|
err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
|
2009-04-17 19:33:26 -06:00
|
|
|
if (err) {
|
|
|
|
shost_printk(KERN_ERR, fnic->lport->host,
|
2013-09-09 14:31:47 -06:00
|
|
|
"Unable to obtain 64-bit DMA "
|
2009-04-17 19:33:26 -06:00
|
|
|
"for consistent allocations, aborting.\n");
|
|
|
|
goto err_out_release_regions;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Map vNIC resources from BAR0 */
|
|
|
|
if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) {
|
|
|
|
shost_printk(KERN_ERR, fnic->lport->host,
|
|
|
|
"BAR0 not memory-map'able, aborting.\n");
|
|
|
|
err = -ENODEV;
|
|
|
|
goto err_out_release_regions;
|
|
|
|
}
|
|
|
|
|
|
|
|
fnic->bar0.vaddr = pci_iomap(pdev, 0, 0);
|
|
|
|
fnic->bar0.bus_addr = pci_resource_start(pdev, 0);
|
|
|
|
fnic->bar0.len = pci_resource_len(pdev, 0);
|
|
|
|
|
|
|
|
if (!fnic->bar0.vaddr) {
|
|
|
|
shost_printk(KERN_ERR, fnic->lport->host,
|
|
|
|
"Cannot memory-map BAR0 res hdr, "
|
|
|
|
"aborting.\n");
|
|
|
|
err = -ENODEV;
|
|
|
|
goto err_out_release_regions;
|
|
|
|
}
|
|
|
|
|
|
|
|
fnic->vdev = vnic_dev_register(NULL, fnic, pdev, &fnic->bar0);
|
|
|
|
if (!fnic->vdev) {
|
|
|
|
shost_printk(KERN_ERR, fnic->lport->host,
|
|
|
|
"vNIC registration failed, "
|
|
|
|
"aborting.\n");
|
|
|
|
err = -ENODEV;
|
|
|
|
goto err_out_iounmap;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = fnic_dev_wait(fnic->vdev, vnic_dev_open,
|
|
|
|
vnic_dev_open_done, 0);
|
|
|
|
if (err) {
|
|
|
|
shost_printk(KERN_ERR, fnic->lport->host,
|
|
|
|
"vNIC dev open failed, aborting.\n");
|
|
|
|
goto err_out_vnic_unregister;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = vnic_dev_init(fnic->vdev, 0);
|
|
|
|
if (err) {
|
|
|
|
shost_printk(KERN_ERR, fnic->lport->host,
|
|
|
|
"vNIC dev init failed, aborting.\n");
|
|
|
|
goto err_out_dev_close;
|
|
|
|
}
|
|
|
|
|
2009-11-03 12:49:22 -07:00
|
|
|
err = vnic_dev_mac_addr(fnic->vdev, fnic->ctlr.ctl_src_addr);
|
2009-04-17 19:33:26 -06:00
|
|
|
if (err) {
|
|
|
|
shost_printk(KERN_ERR, fnic->lport->host,
|
|
|
|
"vNIC get MAC addr failed \n");
|
|
|
|
goto err_out_dev_close;
|
|
|
|
}
|
2009-11-03 12:49:22 -07:00
|
|
|
/* set data_src for point-to-point mode and to keep it non-zero */
|
|
|
|
memcpy(fnic->data_src_addr, fnic->ctlr.ctl_src_addr, ETH_ALEN);
|
2009-04-17 19:33:26 -06:00
|
|
|
|
|
|
|
/* Get vNIC configuration */
|
|
|
|
err = fnic_get_vnic_config(fnic);
|
|
|
|
if (err) {
|
|
|
|
shost_printk(KERN_ERR, fnic->lport->host,
|
|
|
|
"Get vNIC configuration failed, "
|
|
|
|
"aborting.\n");
|
|
|
|
goto err_out_dev_close;
|
|
|
|
}
|
2013-09-09 14:31:51 -06:00
|
|
|
|
|
|
|
/* Configure Maximum Outstanding IO reqs*/
|
|
|
|
if (fnic->config.io_throttle_count != FNIC_UCSM_DFLT_THROTTLE_CNT_BLD) {
|
|
|
|
host->can_queue = min_t(u32, FNIC_MAX_IO_REQ,
|
|
|
|
max_t(u32, FNIC_MIN_IO_REQ,
|
|
|
|
fnic->config.io_throttle_count));
|
|
|
|
}
|
|
|
|
fnic->fnic_max_tag_id = host->can_queue;
|
|
|
|
|
|
|
|
err = scsi_init_shared_tag_map(host, fnic->fnic_max_tag_id);
|
|
|
|
if (err) {
|
|
|
|
shost_printk(KERN_ERR, fnic->lport->host,
|
|
|
|
"Unable to alloc shared tag map\n");
|
|
|
|
goto err_out_dev_close;
|
|
|
|
}
|
|
|
|
|
2009-04-17 19:33:26 -06:00
|
|
|
host->max_lun = fnic->config.luns_per_tgt;
|
|
|
|
host->max_id = FNIC_MAX_FCP_TARGET;
|
2010-04-09 15:22:59 -06:00
|
|
|
host->max_cmd_len = FCOE_MAX_CMD_LEN;
|
2009-04-17 19:33:26 -06:00
|
|
|
|
|
|
|
fnic_get_res_counts(fnic);
|
|
|
|
|
|
|
|
err = fnic_set_intr_mode(fnic);
|
|
|
|
if (err) {
|
|
|
|
shost_printk(KERN_ERR, fnic->lport->host,
|
|
|
|
"Failed to set intr mode, "
|
|
|
|
"aborting.\n");
|
|
|
|
goto err_out_dev_close;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = fnic_alloc_vnic_resources(fnic);
|
|
|
|
if (err) {
|
|
|
|
shost_printk(KERN_ERR, fnic->lport->host,
|
|
|
|
"Failed to alloc vNIC resources, "
|
|
|
|
"aborting.\n");
|
2009-11-03 12:45:37 -07:00
|
|
|
goto err_out_clear_intr;
|
2009-04-17 19:33:26 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* initialize all fnic locks */
|
|
|
|
spin_lock_init(&fnic->fnic_lock);
|
|
|
|
|
|
|
|
for (i = 0; i < FNIC_WQ_MAX; i++)
|
|
|
|
spin_lock_init(&fnic->wq_lock[i]);
|
|
|
|
|
|
|
|
for (i = 0; i < FNIC_WQ_COPY_MAX; i++) {
|
|
|
|
spin_lock_init(&fnic->wq_copy_lock[i]);
|
|
|
|
fnic->wq_copy_desc_low[i] = DESC_CLEAN_LOW_WATERMARK;
|
|
|
|
fnic->fw_ack_recd[i] = 0;
|
|
|
|
fnic->fw_ack_index[i] = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < FNIC_IO_LOCKS; i++)
|
|
|
|
spin_lock_init(&fnic->io_req_lock[i]);
|
|
|
|
|
|
|
|
fnic->io_req_pool = mempool_create_slab_pool(2, fnic_io_req_cache);
|
|
|
|
if (!fnic->io_req_pool)
|
|
|
|
goto err_out_free_resources;
|
|
|
|
|
2011-06-13 22:21:01 -06:00
|
|
|
pool = mempool_create_slab_pool(2, fnic_sgl_cache[FNIC_SGL_CACHE_DFLT]);
|
2009-04-17 19:33:26 -06:00
|
|
|
if (!pool)
|
|
|
|
goto err_out_free_ioreq_pool;
|
|
|
|
fnic->io_sgl_pool[FNIC_SGL_CACHE_DFLT] = pool;
|
|
|
|
|
2011-06-13 22:21:01 -06:00
|
|
|
pool = mempool_create_slab_pool(2, fnic_sgl_cache[FNIC_SGL_CACHE_MAX]);
|
2009-04-17 19:33:26 -06:00
|
|
|
if (!pool)
|
|
|
|
goto err_out_free_dflt_pool;
|
|
|
|
fnic->io_sgl_pool[FNIC_SGL_CACHE_MAX] = pool;
|
|
|
|
|
|
|
|
/* setup vlan config, hw inserts vlan header */
|
|
|
|
fnic->vlan_hw_insert = 1;
|
|
|
|
fnic->vlan_id = 0;
|
|
|
|
|
2009-11-03 12:49:22 -07:00
|
|
|
/* Initialize the FIP fcoe_ctrl struct */
|
|
|
|
fnic->ctlr.send = fnic_eth_send;
|
|
|
|
fnic->ctlr.update_mac = fnic_update_mac;
|
|
|
|
fnic->ctlr.get_src_addr = fnic_get_mac;
|
|
|
|
if (fnic->config.flags & VFCF_FIP_CAPABLE) {
|
|
|
|
shost_printk(KERN_INFO, fnic->lport->host,
|
|
|
|
"firmware supports FIP\n");
|
2010-02-16 13:15:44 -07:00
|
|
|
/* enable directed and multicast */
|
|
|
|
vnic_dev_packet_filter(fnic->vdev, 1, 1, 0, 0, 0);
|
2009-11-03 12:49:22 -07:00
|
|
|
vnic_dev_add_addr(fnic->vdev, FIP_ALL_ENODE_MACS);
|
|
|
|
vnic_dev_add_addr(fnic->vdev, fnic->ctlr.ctl_src_addr);
|
2013-02-25 17:18:36 -07:00
|
|
|
fnic->set_vlan = fnic_set_vlan;
|
2010-07-20 16:19:58 -06:00
|
|
|
fcoe_ctlr_init(&fnic->ctlr, FIP_MODE_AUTO);
|
2013-02-25 17:18:36 -07:00
|
|
|
setup_timer(&fnic->fip_timer, fnic_fip_notify_timer,
|
|
|
|
(unsigned long)fnic);
|
|
|
|
spin_lock_init(&fnic->vlans_lock);
|
|
|
|
INIT_WORK(&fnic->fip_frame_work, fnic_handle_fip_frame);
|
|
|
|
INIT_WORK(&fnic->event_work, fnic_handle_event);
|
|
|
|
skb_queue_head_init(&fnic->fip_frame_queue);
|
|
|
|
INIT_LIST_HEAD(&fnic->evlist);
|
|
|
|
INIT_LIST_HEAD(&fnic->vlans);
|
2009-11-03 12:49:22 -07:00
|
|
|
} else {
|
|
|
|
shost_printk(KERN_INFO, fnic->lport->host,
|
|
|
|
"firmware uses non-FIP mode\n");
|
2010-07-20 16:19:58 -06:00
|
|
|
fcoe_ctlr_init(&fnic->ctlr, FIP_MODE_NON_FIP);
|
2014-04-18 13:28:17 -06:00
|
|
|
fnic->ctlr.state = FIP_ST_NON_FIP;
|
2009-11-03 12:49:22 -07:00
|
|
|
}
|
2009-04-17 19:33:26 -06:00
|
|
|
fnic->state = FNIC_IN_FC_MODE;
|
|
|
|
|
[SCSI] fnic: fixing issues in device and firmware reset code
1. Handling overlapped firmware resets
This fix serialize multiple firmware resets to avoid situation where fnic
device fails to come up for link up event, when firmware resets are issued
back to back. If there are overlapped firmware resets are issued,
the firmware reset operation checks whether there is any firmware reset in
progress, if so it polls for its completion in a loop with 100ms delay.
2. Handling device reset timeout
fnic_device_reset code has been modified to handle Device reset timeout:
- Issue terminate on device reset timeout.
- Introduced flags field (one of the scratch fields in scsi_cmnd).
With this, device reset request would have DEVICE_RESET flag set for other
routines to determine the type of the request.
Also modified fnic_terminate_rport_io, fnic_rport_exch_rset, completion
routines to handle SCSI commands with DEVICE_RESET flag.
3. LUN/Device Reset hangs when issued through IOCTL using utilities like
sg_reset.
Each SCSI command is associated with a valid tag, fnic uses this tag to
retrieve associated scsi command on completion. the LUN/Device Reset issued
through IOCTL resulting into a SCSI command that is not associated with a
valid tag. So fnic fails to retrieve associated scsi command on completion,
which causes hang. This fix allocates tag, associates it with the
scsi command and frees the tag, when the operation completed.
4. Preventing IOs during firmware reset.
Current fnic implementation allows IO submissions during firmware reset.
This fix synchronizes IO submissions and firmware reset operations.
It ensures that IOs issued to fnic prior to reset will be issued to the
firmware before firmware reset.
Signed-off-by: Narsimhulu Musini <nmusini@cisco.com>
Signed-off-by: Hiral Patel <hiralpat@cisco.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2013-02-12 18:00:58 -07:00
|
|
|
atomic_set(&fnic->in_flight, 0);
|
|
|
|
fnic->state_flags = FNIC_FLAGS_NONE;
|
|
|
|
|
2009-04-17 19:33:26 -06:00
|
|
|
/* Enable hardware stripping of vlan header on ingress */
|
|
|
|
fnic_set_nic_config(fnic, 0, 0, 0, 0, 0, 0, 1);
|
|
|
|
|
|
|
|
/* Setup notification buffer area */
|
|
|
|
err = fnic_notify_set(fnic);
|
|
|
|
if (err) {
|
|
|
|
shost_printk(KERN_ERR, fnic->lport->host,
|
|
|
|
"Failed to alloc notify buffer, aborting.\n");
|
|
|
|
goto err_out_free_max_pool;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Setup notify timer when using MSI interrupts */
|
|
|
|
if (vnic_dev_get_intr_mode(fnic->vdev) == VNIC_DEV_INTR_MODE_MSI)
|
|
|
|
setup_timer(&fnic->notify_timer,
|
|
|
|
fnic_notify_timer, (unsigned long)fnic);
|
|
|
|
|
|
|
|
/* allocate RQ buffers and post them to RQ*/
|
|
|
|
for (i = 0; i < fnic->rq_count; i++) {
|
|
|
|
err = vnic_rq_fill(&fnic->rq[i], fnic_alloc_rq_frame);
|
|
|
|
if (err) {
|
|
|
|
shost_printk(KERN_ERR, fnic->lport->host,
|
|
|
|
"fnic_alloc_rq_frame can't alloc "
|
|
|
|
"frame\n");
|
|
|
|
goto err_out_free_rq_buf;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialization done with PCI system, hardware, firmware.
|
|
|
|
* Add host to SCSI
|
|
|
|
*/
|
|
|
|
err = scsi_add_host(lp->host, &pdev->dev);
|
|
|
|
if (err) {
|
|
|
|
shost_printk(KERN_ERR, fnic->lport->host,
|
|
|
|
"fnic: scsi_add_host failed...exiting\n");
|
|
|
|
goto err_out_free_rq_buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Start local port initiatialization */
|
|
|
|
|
|
|
|
lp->link_up = 0;
|
|
|
|
|
|
|
|
lp->max_retry_count = fnic->config.flogi_retries;
|
2009-05-01 11:01:26 -06:00
|
|
|
lp->max_rport_retry_count = fnic->config.plogi_retries;
|
2009-04-17 19:33:26 -06:00
|
|
|
lp->service_params = (FCP_SPPF_INIT_FCN | FCP_SPPF_RD_XRDY_DIS |
|
|
|
|
FCP_SPPF_CONF_COMPL);
|
|
|
|
if (fnic->config.flags & VFCF_FCP_SEQ_LVL_ERR)
|
|
|
|
lp->service_params |= FCP_SPPF_RETRY;
|
|
|
|
|
|
|
|
lp->boot_time = jiffies;
|
|
|
|
lp->e_d_tov = fnic->config.ed_tov;
|
|
|
|
lp->r_a_tov = fnic->config.ra_tov;
|
|
|
|
lp->link_supported_speeds = FC_PORTSPEED_10GBIT;
|
|
|
|
fc_set_wwnn(lp, fnic->config.node_wwn);
|
|
|
|
fc_set_wwpn(lp, fnic->config.port_wwn);
|
|
|
|
|
[SCSI] libfcoe: fcoe: fnic: add FIP VN2VN point-to-multipoint support
The FC-BB-6 committee is proposing a new FIP usage model called
VN_port to VN_port mode. It allows VN_ports to discover each other
over a loss-free L2 Ethernet without any FCF or Fibre-channel fabric
services. This is point-to-multipoint. There is also a variant
of this called point-to-point which provides for making sure there
is just one pair of ports operating over the Ethernet fabric.
We add these new states: VNMP_START, _PROBE1, _PROBE2, _CLAIM, and _UP.
These usually go quickly in that sequence. After waiting a random
amount of time up to 100 ms in START, we select a pseudo-random
proposed locally-unique port ID and send out probes in states PROBE1
and PROBE2, 100 ms apart. If no probe responses are heard, we
proceed to CLAIM state 400 ms later and send a claim notification.
We wait another 400 ms to receive claim responses, which give us
a list of the other nodes on the network, including their FC-4
capabilities. After another 400 ms we go to VNMP_UP state and
should start interoperating with any of the nodes for whic we
receivec claim responses. More details are in the spec.j
Add the new mode as FIP_MODE_VN2VN. The driver must specify
explicitly that it wants to operate in this mode. There is
no automatic detection between point-to-multipoint and fabric
mode, and the local port initialization is affected, so it isn't
anticipated that there will ever be any such automatic switchover.
It may eventually be possible to have both fabric and VN2VN
modes on the same L2 network, which may be done by two separate
local VN_ports (lports).
When in VN2VN mode, FIP replaces libfc's fabric-oriented discovery
module with its own simple code that adds remote ports as they
are discovered from incoming claim notifications and responses.
These hooks are placed by fcoe_disc_init().
A linear list of discovered vn_ports is maintained under the
fcoe_ctlr struct. It is expected to be short for now, and
accessed infrequently. It is kept under RCU for lock-ordering
reasons. The lport and/or rport mutexes may be held when we
need to lookup a fcoe_vnport during an ELS send.
Change fcoe_ctlr_encaps() to lookup the destination vn_port in
the list of peers for the destination MAC address of the
FIP-encapsulated frame.
Add a new function fcoe_disc_init() to initialize just the
discovery portion of libfcoe for VN2VN mode.
Signed-off-by: Joe Eykholt <jeykholt@cisco.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2010-07-20 16:20:30 -06:00
|
|
|
fcoe_libfc_config(lp, &fnic->ctlr, &fnic_transport_template, 0);
|
2009-04-17 19:33:26 -06:00
|
|
|
|
[SCSI] fcoe, fnic, libfc: modifies current code paths to use EM anchor list
Modifies current code to use EM anchor list in EM allocation, EM free,
EM reset, exch allocation and exch lookup code paths.
1. Modifies fc_exch_mgr_alloc to accept EM match function and then
have allocated EM added to the lport using fc_exch_mgr_add API
while also updating EM kref for newly added EM.
2. Updates fc_exch_mgr_free API to accept only lport pointer instead
EM and then have this API free all EMs of the lport from EM anchor
list.
3. Removes single lport pointer link from the EM, which was used in
associating lport pointer in newly allocated exchange. Instead have
lport pointer passed along new exchange allocation call path and
then store passed lport pointer in newly allocated exchange, this
will allow a single EM instance to be used across more than one
lport and used in EM reset to reset only lport specific exchanges.
4. Modifies fc_exch_mgr_reset to reset all EMs from the EM anchor list
of the lport, adds additional exch lport pointer (ep->lp) check for
shared EM case to reset exchange specific to a lport requested reset.
5. Updates exch allocation API fc_exch_alloc to use EM anchor list and
its anchor match func pointer. The fc_exch_alloc will walk the list
of EMs until it finds a match, a match will be either null match
func pointer or call to match function returning true value.
6. Updates fc_exch_recv to accept incoming frame on local port using
only lport pointer and frame pointer without specifying EM instance
of incoming frame. Instead modified fc_exch_recv to locate EM for the
incoming frame by matching xid of incoming frame against a EM xid range.
This change was required to use EM list in libfc Rx path and after this
change the lport fc_exch_mgr pointer emp is not needed anymore, so
removed emp pointer.
7. Updates fnic for removed lport emp pointer and above modified libfc APIs
fc_exch_recv, fc_exch_mgr_alloc and fc_exch_mgr_free.
8. Removes exch_get and exch_put from libfc_function_template as these
are no longer needed with EM anchor list and its match function use.
Also removes its default function fc_exch_get.
A defect this patch introduced regarding the libfc initialization order in
the fnic driver was fixed by Joe Eykholt <jeykholt@cisco.com>.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-07-29 18:05:10 -06:00
|
|
|
if (!fc_exch_mgr_alloc(lp, FC_CLASS_3, FCPIO_HOST_EXCH_RANGE_START,
|
|
|
|
FCPIO_HOST_EXCH_RANGE_END, NULL)) {
|
|
|
|
err = -ENOMEM;
|
|
|
|
goto err_out_remove_scsi_host;
|
|
|
|
}
|
|
|
|
|
2010-02-16 13:15:50 -07:00
|
|
|
fc_lport_init_stats(lp);
|
2013-09-09 14:31:45 -06:00
|
|
|
fnic->stats_reset_time = jiffies;
|
2010-02-16 13:15:50 -07:00
|
|
|
|
2009-04-17 19:33:26 -06:00
|
|
|
fc_lport_config(lp);
|
|
|
|
|
|
|
|
if (fc_set_mfs(lp, fnic->config.maxdatafieldsize +
|
|
|
|
sizeof(struct fc_frame_header))) {
|
|
|
|
err = -EINVAL;
|
|
|
|
goto err_out_free_exch_mgr;
|
|
|
|
}
|
|
|
|
fc_host_maxframe_size(lp->host) = lp->mfs;
|
2010-09-15 15:52:28 -06:00
|
|
|
fc_host_dev_loss_tmo(lp->host) = fnic->config.port_down_timeout / 1000;
|
2009-04-17 19:33:26 -06:00
|
|
|
|
|
|
|
sprintf(fc_host_symbolic_name(lp->host),
|
|
|
|
DRV_NAME " v" DRV_VERSION " over %s", fnic->name);
|
|
|
|
|
|
|
|
spin_lock_irqsave(&fnic_list_lock, flags);
|
|
|
|
list_add_tail(&fnic->list, &fnic_list);
|
|
|
|
spin_unlock_irqrestore(&fnic_list_lock, flags);
|
|
|
|
|
|
|
|
INIT_WORK(&fnic->link_work, fnic_handle_link);
|
|
|
|
INIT_WORK(&fnic->frame_work, fnic_handle_frame);
|
|
|
|
skb_queue_head_init(&fnic->frame_queue);
|
2009-11-03 12:49:22 -07:00
|
|
|
skb_queue_head_init(&fnic->tx_queue);
|
2009-04-17 19:33:26 -06:00
|
|
|
|
|
|
|
/* Enable all queues */
|
|
|
|
for (i = 0; i < fnic->raw_wq_count; i++)
|
|
|
|
vnic_wq_enable(&fnic->wq[i]);
|
|
|
|
for (i = 0; i < fnic->rq_count; i++)
|
|
|
|
vnic_rq_enable(&fnic->rq[i]);
|
|
|
|
for (i = 0; i < fnic->wq_copy_count; i++)
|
|
|
|
vnic_wq_copy_enable(&fnic->wq_copy[i]);
|
|
|
|
|
|
|
|
fc_fabric_login(lp);
|
|
|
|
|
|
|
|
vnic_dev_enable(fnic->vdev);
|
2009-11-03 12:45:37 -07:00
|
|
|
|
|
|
|
err = fnic_request_intr(fnic);
|
|
|
|
if (err) {
|
|
|
|
shost_printk(KERN_ERR, fnic->lport->host,
|
|
|
|
"Unable to request irq.\n");
|
|
|
|
goto err_out_free_exch_mgr;
|
|
|
|
}
|
|
|
|
|
2009-04-17 19:33:26 -06:00
|
|
|
for (i = 0; i < fnic->intr_count; i++)
|
|
|
|
vnic_intr_unmask(&fnic->intr[i]);
|
|
|
|
|
|
|
|
fnic_notify_timer_start(fnic);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err_out_free_exch_mgr:
|
[SCSI] fcoe, fnic, libfc: modifies current code paths to use EM anchor list
Modifies current code to use EM anchor list in EM allocation, EM free,
EM reset, exch allocation and exch lookup code paths.
1. Modifies fc_exch_mgr_alloc to accept EM match function and then
have allocated EM added to the lport using fc_exch_mgr_add API
while also updating EM kref for newly added EM.
2. Updates fc_exch_mgr_free API to accept only lport pointer instead
EM and then have this API free all EMs of the lport from EM anchor
list.
3. Removes single lport pointer link from the EM, which was used in
associating lport pointer in newly allocated exchange. Instead have
lport pointer passed along new exchange allocation call path and
then store passed lport pointer in newly allocated exchange, this
will allow a single EM instance to be used across more than one
lport and used in EM reset to reset only lport specific exchanges.
4. Modifies fc_exch_mgr_reset to reset all EMs from the EM anchor list
of the lport, adds additional exch lport pointer (ep->lp) check for
shared EM case to reset exchange specific to a lport requested reset.
5. Updates exch allocation API fc_exch_alloc to use EM anchor list and
its anchor match func pointer. The fc_exch_alloc will walk the list
of EMs until it finds a match, a match will be either null match
func pointer or call to match function returning true value.
6. Updates fc_exch_recv to accept incoming frame on local port using
only lport pointer and frame pointer without specifying EM instance
of incoming frame. Instead modified fc_exch_recv to locate EM for the
incoming frame by matching xid of incoming frame against a EM xid range.
This change was required to use EM list in libfc Rx path and after this
change the lport fc_exch_mgr pointer emp is not needed anymore, so
removed emp pointer.
7. Updates fnic for removed lport emp pointer and above modified libfc APIs
fc_exch_recv, fc_exch_mgr_alloc and fc_exch_mgr_free.
8. Removes exch_get and exch_put from libfc_function_template as these
are no longer needed with EM anchor list and its match function use.
Also removes its default function fc_exch_get.
A defect this patch introduced regarding the libfc initialization order in
the fnic driver was fixed by Joe Eykholt <jeykholt@cisco.com>.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-07-29 18:05:10 -06:00
|
|
|
fc_exch_mgr_free(lp);
|
2009-04-17 19:33:26 -06:00
|
|
|
err_out_remove_scsi_host:
|
2009-11-03 12:49:22 -07:00
|
|
|
fc_remove_host(lp->host);
|
|
|
|
scsi_remove_host(lp->host);
|
2009-04-17 19:33:26 -06:00
|
|
|
err_out_free_rq_buf:
|
|
|
|
for (i = 0; i < fnic->rq_count; i++)
|
|
|
|
vnic_rq_clean(&fnic->rq[i], fnic_free_rq_buf);
|
|
|
|
vnic_dev_notify_unset(fnic->vdev);
|
|
|
|
err_out_free_max_pool:
|
|
|
|
mempool_destroy(fnic->io_sgl_pool[FNIC_SGL_CACHE_MAX]);
|
|
|
|
err_out_free_dflt_pool:
|
|
|
|
mempool_destroy(fnic->io_sgl_pool[FNIC_SGL_CACHE_DFLT]);
|
|
|
|
err_out_free_ioreq_pool:
|
|
|
|
mempool_destroy(fnic->io_req_pool);
|
|
|
|
err_out_free_resources:
|
|
|
|
fnic_free_vnic_resources(fnic);
|
|
|
|
err_out_clear_intr:
|
|
|
|
fnic_clear_intr_mode(fnic);
|
|
|
|
err_out_dev_close:
|
|
|
|
vnic_dev_close(fnic->vdev);
|
|
|
|
err_out_vnic_unregister:
|
|
|
|
vnic_dev_unregister(fnic->vdev);
|
|
|
|
err_out_iounmap:
|
|
|
|
fnic_iounmap(fnic);
|
|
|
|
err_out_release_regions:
|
|
|
|
pci_release_regions(pdev);
|
|
|
|
err_out_disable_device:
|
|
|
|
pci_disable_device(pdev);
|
|
|
|
err_out_free_hba:
|
2013-09-12 18:45:42 -06:00
|
|
|
fnic_stats_debugfs_remove(fnic);
|
2009-04-17 19:33:26 -06:00
|
|
|
scsi_host_put(lp->host);
|
|
|
|
err_out:
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2012-12-21 14:08:55 -07:00
|
|
|
static void fnic_remove(struct pci_dev *pdev)
|
2009-04-17 19:33:26 -06:00
|
|
|
{
|
|
|
|
struct fnic *fnic = pci_get_drvdata(pdev);
|
2009-11-03 12:49:22 -07:00
|
|
|
struct fc_lport *lp = fnic->lport;
|
2009-04-17 19:33:26 -06:00
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Mark state so that the workqueue thread stops forwarding
|
|
|
|
* received frames and link events to the local port. ISR and
|
|
|
|
* other threads that can queue work items will also stop
|
|
|
|
* creating work items on the fnic workqueue
|
|
|
|
*/
|
|
|
|
spin_lock_irqsave(&fnic->fnic_lock, flags);
|
|
|
|
fnic->stop_rx_link_events = 1;
|
|
|
|
spin_unlock_irqrestore(&fnic->fnic_lock, flags);
|
|
|
|
|
|
|
|
if (vnic_dev_get_intr_mode(fnic->vdev) == VNIC_DEV_INTR_MODE_MSI)
|
|
|
|
del_timer_sync(&fnic->notify_timer);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Flush the fnic event queue. After this call, there should
|
|
|
|
* be no event queued for this fnic device in the workqueue
|
|
|
|
*/
|
|
|
|
flush_workqueue(fnic_event_queue);
|
|
|
|
skb_queue_purge(&fnic->frame_queue);
|
2009-11-03 12:49:22 -07:00
|
|
|
skb_queue_purge(&fnic->tx_queue);
|
2009-04-17 19:33:26 -06:00
|
|
|
|
2013-02-25 17:18:36 -07:00
|
|
|
if (fnic->config.flags & VFCF_FIP_CAPABLE) {
|
|
|
|
del_timer_sync(&fnic->fip_timer);
|
|
|
|
skb_queue_purge(&fnic->fip_frame_queue);
|
|
|
|
fnic_fcoe_reset_vlans(fnic);
|
|
|
|
fnic_fcoe_evlist_free(fnic);
|
|
|
|
}
|
|
|
|
|
2009-04-17 19:33:26 -06:00
|
|
|
/*
|
|
|
|
* Log off the fabric. This stops all remote ports, dns port,
|
|
|
|
* logs off the fabric. This flushes all rport, disc, lport work
|
|
|
|
* before returning
|
|
|
|
*/
|
|
|
|
fc_fabric_logoff(fnic->lport);
|
|
|
|
|
|
|
|
spin_lock_irqsave(&fnic->fnic_lock, flags);
|
|
|
|
fnic->in_remove = 1;
|
|
|
|
spin_unlock_irqrestore(&fnic->fnic_lock, flags);
|
|
|
|
|
2009-11-03 12:49:22 -07:00
|
|
|
fcoe_ctlr_destroy(&fnic->ctlr);
|
|
|
|
fc_lport_destroy(lp);
|
2013-09-12 18:45:42 -06:00
|
|
|
fnic_stats_debugfs_remove(fnic);
|
2009-04-17 19:33:26 -06:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This stops the fnic device, masks all interrupts. Completed
|
|
|
|
* CQ entries are drained. Posted WQ/RQ/Copy-WQ entries are
|
|
|
|
* cleaned up
|
|
|
|
*/
|
|
|
|
fnic_cleanup(fnic);
|
|
|
|
|
|
|
|
BUG_ON(!skb_queue_empty(&fnic->frame_queue));
|
2009-11-03 12:49:22 -07:00
|
|
|
BUG_ON(!skb_queue_empty(&fnic->tx_queue));
|
2009-04-17 19:33:26 -06:00
|
|
|
|
|
|
|
spin_lock_irqsave(&fnic_list_lock, flags);
|
|
|
|
list_del(&fnic->list);
|
|
|
|
spin_unlock_irqrestore(&fnic_list_lock, flags);
|
|
|
|
|
|
|
|
fc_remove_host(fnic->lport->host);
|
|
|
|
scsi_remove_host(fnic->lport->host);
|
[SCSI] fcoe, fnic, libfc: modifies current code paths to use EM anchor list
Modifies current code to use EM anchor list in EM allocation, EM free,
EM reset, exch allocation and exch lookup code paths.
1. Modifies fc_exch_mgr_alloc to accept EM match function and then
have allocated EM added to the lport using fc_exch_mgr_add API
while also updating EM kref for newly added EM.
2. Updates fc_exch_mgr_free API to accept only lport pointer instead
EM and then have this API free all EMs of the lport from EM anchor
list.
3. Removes single lport pointer link from the EM, which was used in
associating lport pointer in newly allocated exchange. Instead have
lport pointer passed along new exchange allocation call path and
then store passed lport pointer in newly allocated exchange, this
will allow a single EM instance to be used across more than one
lport and used in EM reset to reset only lport specific exchanges.
4. Modifies fc_exch_mgr_reset to reset all EMs from the EM anchor list
of the lport, adds additional exch lport pointer (ep->lp) check for
shared EM case to reset exchange specific to a lport requested reset.
5. Updates exch allocation API fc_exch_alloc to use EM anchor list and
its anchor match func pointer. The fc_exch_alloc will walk the list
of EMs until it finds a match, a match will be either null match
func pointer or call to match function returning true value.
6. Updates fc_exch_recv to accept incoming frame on local port using
only lport pointer and frame pointer without specifying EM instance
of incoming frame. Instead modified fc_exch_recv to locate EM for the
incoming frame by matching xid of incoming frame against a EM xid range.
This change was required to use EM list in libfc Rx path and after this
change the lport fc_exch_mgr pointer emp is not needed anymore, so
removed emp pointer.
7. Updates fnic for removed lport emp pointer and above modified libfc APIs
fc_exch_recv, fc_exch_mgr_alloc and fc_exch_mgr_free.
8. Removes exch_get and exch_put from libfc_function_template as these
are no longer needed with EM anchor list and its match function use.
Also removes its default function fc_exch_get.
A defect this patch introduced regarding the libfc initialization order in
the fnic driver was fixed by Joe Eykholt <jeykholt@cisco.com>.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-07-29 18:05:10 -06:00
|
|
|
fc_exch_mgr_free(fnic->lport);
|
2009-04-17 19:33:26 -06:00
|
|
|
vnic_dev_notify_unset(fnic->vdev);
|
|
|
|
fnic_free_intr(fnic);
|
2009-11-03 12:45:37 -07:00
|
|
|
fnic_free_vnic_resources(fnic);
|
2009-04-17 19:33:26 -06:00
|
|
|
fnic_clear_intr_mode(fnic);
|
|
|
|
vnic_dev_close(fnic->vdev);
|
|
|
|
vnic_dev_unregister(fnic->vdev);
|
|
|
|
fnic_iounmap(fnic);
|
|
|
|
pci_release_regions(pdev);
|
|
|
|
pci_disable_device(pdev);
|
2009-11-03 12:49:22 -07:00
|
|
|
scsi_host_put(lp->host);
|
2009-04-17 19:33:26 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct pci_driver fnic_driver = {
|
|
|
|
.name = DRV_NAME,
|
|
|
|
.id_table = fnic_id_table,
|
|
|
|
.probe = fnic_probe,
|
2012-12-21 14:08:55 -07:00
|
|
|
.remove = fnic_remove,
|
2009-04-17 19:33:26 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
static int __init fnic_init_module(void)
|
|
|
|
{
|
|
|
|
size_t len;
|
|
|
|
int err = 0;
|
|
|
|
|
|
|
|
printk(KERN_INFO PFX "%s, ver %s\n", DRV_DESCRIPTION, DRV_VERSION);
|
|
|
|
|
2013-09-12 18:45:42 -06:00
|
|
|
/* Create debugfs entries for fnic */
|
|
|
|
err = fnic_debugfs_init();
|
|
|
|
if (err < 0) {
|
|
|
|
printk(KERN_ERR PFX "Failed to create fnic directory "
|
|
|
|
"for tracing and stats logging\n");
|
|
|
|
fnic_debugfs_terminate();
|
|
|
|
}
|
|
|
|
|
2013-02-12 18:01:02 -07:00
|
|
|
/* Allocate memory for trace buffer */
|
|
|
|
err = fnic_trace_buf_init();
|
|
|
|
if (err < 0) {
|
2014-04-18 13:28:19 -06:00
|
|
|
printk(KERN_ERR PFX
|
|
|
|
"Trace buffer initialization Failed. "
|
|
|
|
"Fnic Tracing utility is disabled\n");
|
2013-02-12 18:01:02 -07:00
|
|
|
fnic_trace_free();
|
|
|
|
}
|
|
|
|
|
2014-04-18 13:28:19 -06:00
|
|
|
/* Allocate memory for fc trace buffer */
|
|
|
|
err = fnic_fc_trace_init();
|
|
|
|
if (err < 0) {
|
|
|
|
printk(KERN_ERR PFX "FC trace buffer initialization Failed "
|
|
|
|
"FC frame tracing utility is disabled\n");
|
|
|
|
fnic_fc_trace_free();
|
|
|
|
}
|
|
|
|
|
2009-04-17 19:33:26 -06:00
|
|
|
/* Create a cache for allocation of default size sgls */
|
|
|
|
len = sizeof(struct fnic_dflt_sgl_list);
|
|
|
|
fnic_sgl_cache[FNIC_SGL_CACHE_DFLT] = kmem_cache_create
|
|
|
|
("fnic_sgl_dflt", len + FNIC_SG_DESC_ALIGN, FNIC_SG_DESC_ALIGN,
|
2011-06-13 22:21:01 -06:00
|
|
|
SLAB_HWCACHE_ALIGN,
|
2009-04-17 19:33:26 -06:00
|
|
|
NULL);
|
|
|
|
if (!fnic_sgl_cache[FNIC_SGL_CACHE_DFLT]) {
|
|
|
|
printk(KERN_ERR PFX "failed to create fnic dflt sgl slab\n");
|
|
|
|
err = -ENOMEM;
|
|
|
|
goto err_create_fnic_sgl_slab_dflt;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create a cache for allocation of max size sgls*/
|
|
|
|
len = sizeof(struct fnic_sgl_list);
|
|
|
|
fnic_sgl_cache[FNIC_SGL_CACHE_MAX] = kmem_cache_create
|
|
|
|
("fnic_sgl_max", len + FNIC_SG_DESC_ALIGN, FNIC_SG_DESC_ALIGN,
|
2013-02-25 17:18:36 -07:00
|
|
|
SLAB_HWCACHE_ALIGN,
|
|
|
|
NULL);
|
2009-04-17 19:33:26 -06:00
|
|
|
if (!fnic_sgl_cache[FNIC_SGL_CACHE_MAX]) {
|
|
|
|
printk(KERN_ERR PFX "failed to create fnic max sgl slab\n");
|
|
|
|
err = -ENOMEM;
|
|
|
|
goto err_create_fnic_sgl_slab_max;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create a cache of io_req structs for use via mempool */
|
|
|
|
fnic_io_req_cache = kmem_cache_create("fnic_io_req",
|
|
|
|
sizeof(struct fnic_io_req),
|
|
|
|
0, SLAB_HWCACHE_ALIGN, NULL);
|
|
|
|
if (!fnic_io_req_cache) {
|
|
|
|
printk(KERN_ERR PFX "failed to create fnic io_req slab\n");
|
|
|
|
err = -ENOMEM;
|
|
|
|
goto err_create_fnic_ioreq_slab;
|
|
|
|
}
|
|
|
|
|
|
|
|
fnic_event_queue = create_singlethread_workqueue("fnic_event_wq");
|
|
|
|
if (!fnic_event_queue) {
|
|
|
|
printk(KERN_ERR PFX "fnic work queue create failed\n");
|
|
|
|
err = -ENOMEM;
|
|
|
|
goto err_create_fnic_workq;
|
|
|
|
}
|
|
|
|
|
|
|
|
spin_lock_init(&fnic_list_lock);
|
|
|
|
INIT_LIST_HEAD(&fnic_list);
|
|
|
|
|
[SCSI] fnic: BUG: sleeping function called from invalid context during probe
I hit this during driver probe with the latest fnic updates (this trace
is from a backport into a distro kernel, but the issue is the same).
> BUG: sleeping function called from invalid context at mm/slab.c:3113
> in_atomic(): 0, irqs_disabled(): 1, pid: 610, name: work_for_cpu
> INFO: lockdep is turned off.
> irq event stamp: 0
> hardirqs last enabled at (0): [<(null)>] (null)
> hardirqs last disabled at (0): [<ffffffff81070aa5>]
> copy_process+0x5e5/0x1670
> softirqs last enabled at (0): [<ffffffff81070aa5>]
> copy_process+0x5e5/0x1670
> softirqs last disabled at (0): [<(null)>] (null)
> Pid: 610, comm: work_for_cpu Not tainted
> Call Trace:
> [<ffffffff810b2d10>] ? print_irqtrace_events+0xd0/0xe0
> [<ffffffff8105c1a7>] ? __might_sleep+0xf7/0x130
> [<ffffffff81184efb>] ? kmem_cache_alloc_trace+0x20b/0x2d0
> [<ffffffff8109709e>] ? __create_workqueue_key+0x3e/0x1d0
> [<ffffffff8109709e>] ? __create_workqueue_key+0x3e/0x1d0
> [<ffffffffa00c101c>] ? fnic_probe+0x977/0x11aa [fnic]
> [<ffffffffa00c1048>] ? fnic_probe+0x9a3/0x11aa [fnic]
> [<ffffffff81096f00>] ? do_work_for_cpu+0x0/0x30
> [<ffffffff812c6da7>] ? local_pci_probe+0x17/0x20
> [<ffffffff81096f18>] ? do_work_for_cpu+0x18/0x30
> [<ffffffff8109cdc6>] ? kthread+0x96/0xa0
> [<ffffffff8100c1ca>] ? child_rip+0xa/0x20
> [<ffffffff81550f80>] ? _spin_unlock_irq+0x30/0x40
> [<ffffffff8100bb10>] ? restore_args+0x0/0x30
> [<ffffffff8109cd30>] ? kthread+0x0/0xa0
> [<ffffffff8100c1c0>] ? child_rip+0x0/0x20
The problem is in this hunk of "FIP VLAN Discovery Feature Support"
(d3c995f1dcf938f1084388d92b8fb97bec366566)
create_singlethreaded_workqueue cannot be called with irqs disabled
@@ -620,7 +634,29 @@ static int __devinit fnic_probe(struct pci_dev
*pdev,
vnic_dev_packet_filter(fnic->vdev, 1, 1, 0, 0, 0);
vnic_dev_add_addr(fnic->vdev, FIP_ALL_ENODE_MACS);
vnic_dev_add_addr(fnic->vdev, fnic->ctlr.ctl_src_addr);
+ fnic->set_vlan = fnic_set_vlan;
fcoe_ctlr_init(&fnic->ctlr, FIP_MODE_AUTO);
+ setup_timer(&fnic->fip_timer, fnic_fip_notify_timer,
+ (unsigned long)fnic);
+ spin_lock_init(&fnic->vlans_lock);
+ INIT_WORK(&fnic->fip_frame_work, fnic_handle_fip_frame);
+ INIT_WORK(&fnic->event_work, fnic_handle_event);
+ skb_queue_head_init(&fnic->fip_frame_queue);
+ spin_lock_irqsave(&fnic_list_lock, flags);
+ if (!fnic_fip_queue) {
+ fnic_fip_queue =
+ create_singlethread_workqueue("fnic_fip_q");
+ if (!fnic_fip_queue) {
+ spin_unlock_irqrestore(&fnic_list_lock, flags);
+ printk(KERN_ERR PFX "fnic FIP work queue "
+ "create failed\n");
+ err = -ENOMEM;
+ goto err_out_free_max_pool;
+ }
+ }
+ spin_unlock_irqrestore(&fnic_list_lock, flags);
+ INIT_LIST_HEAD(&fnic->evlist);
+ INIT_LIST_HEAD(&fnic->vlans);
} else {
shost_printk(KERN_INFO, fnic->lport->host,
"firmware uses non-FIP mode\n");
The attempts to make fnic_fip_queue a single instance for the driver
while it's being created in probe look awkward anyway, why is this not
created in fnic_init_module like the event workqueue?
Signed-off-by: Chris Leech <cleech@redhat.com>
Tested-by: Anantha Tungarakodi <atungara@cisco.com>
Acked-by: Hiral Patel <hiralpat@cisco.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2013-07-23 14:04:58 -06:00
|
|
|
fnic_fip_queue = create_singlethread_workqueue("fnic_fip_q");
|
|
|
|
if (!fnic_fip_queue) {
|
|
|
|
printk(KERN_ERR PFX "fnic FIP work queue create failed\n");
|
|
|
|
err = -ENOMEM;
|
|
|
|
goto err_create_fip_workq;
|
|
|
|
}
|
|
|
|
|
2009-04-17 19:33:26 -06:00
|
|
|
fnic_fc_transport = fc_attach_transport(&fnic_fc_functions);
|
|
|
|
if (!fnic_fc_transport) {
|
|
|
|
printk(KERN_ERR PFX "fc_attach_transport error\n");
|
|
|
|
err = -ENOMEM;
|
|
|
|
goto err_fc_transport;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* register the driver with PCI system */
|
|
|
|
err = pci_register_driver(&fnic_driver);
|
|
|
|
if (err < 0) {
|
|
|
|
printk(KERN_ERR PFX "pci register error\n");
|
|
|
|
goto err_pci_register;
|
|
|
|
}
|
|
|
|
return err;
|
|
|
|
|
|
|
|
err_pci_register:
|
|
|
|
fc_release_transport(fnic_fc_transport);
|
|
|
|
err_fc_transport:
|
[SCSI] fnic: BUG: sleeping function called from invalid context during probe
I hit this during driver probe with the latest fnic updates (this trace
is from a backport into a distro kernel, but the issue is the same).
> BUG: sleeping function called from invalid context at mm/slab.c:3113
> in_atomic(): 0, irqs_disabled(): 1, pid: 610, name: work_for_cpu
> INFO: lockdep is turned off.
> irq event stamp: 0
> hardirqs last enabled at (0): [<(null)>] (null)
> hardirqs last disabled at (0): [<ffffffff81070aa5>]
> copy_process+0x5e5/0x1670
> softirqs last enabled at (0): [<ffffffff81070aa5>]
> copy_process+0x5e5/0x1670
> softirqs last disabled at (0): [<(null)>] (null)
> Pid: 610, comm: work_for_cpu Not tainted
> Call Trace:
> [<ffffffff810b2d10>] ? print_irqtrace_events+0xd0/0xe0
> [<ffffffff8105c1a7>] ? __might_sleep+0xf7/0x130
> [<ffffffff81184efb>] ? kmem_cache_alloc_trace+0x20b/0x2d0
> [<ffffffff8109709e>] ? __create_workqueue_key+0x3e/0x1d0
> [<ffffffff8109709e>] ? __create_workqueue_key+0x3e/0x1d0
> [<ffffffffa00c101c>] ? fnic_probe+0x977/0x11aa [fnic]
> [<ffffffffa00c1048>] ? fnic_probe+0x9a3/0x11aa [fnic]
> [<ffffffff81096f00>] ? do_work_for_cpu+0x0/0x30
> [<ffffffff812c6da7>] ? local_pci_probe+0x17/0x20
> [<ffffffff81096f18>] ? do_work_for_cpu+0x18/0x30
> [<ffffffff8109cdc6>] ? kthread+0x96/0xa0
> [<ffffffff8100c1ca>] ? child_rip+0xa/0x20
> [<ffffffff81550f80>] ? _spin_unlock_irq+0x30/0x40
> [<ffffffff8100bb10>] ? restore_args+0x0/0x30
> [<ffffffff8109cd30>] ? kthread+0x0/0xa0
> [<ffffffff8100c1c0>] ? child_rip+0x0/0x20
The problem is in this hunk of "FIP VLAN Discovery Feature Support"
(d3c995f1dcf938f1084388d92b8fb97bec366566)
create_singlethreaded_workqueue cannot be called with irqs disabled
@@ -620,7 +634,29 @@ static int __devinit fnic_probe(struct pci_dev
*pdev,
vnic_dev_packet_filter(fnic->vdev, 1, 1, 0, 0, 0);
vnic_dev_add_addr(fnic->vdev, FIP_ALL_ENODE_MACS);
vnic_dev_add_addr(fnic->vdev, fnic->ctlr.ctl_src_addr);
+ fnic->set_vlan = fnic_set_vlan;
fcoe_ctlr_init(&fnic->ctlr, FIP_MODE_AUTO);
+ setup_timer(&fnic->fip_timer, fnic_fip_notify_timer,
+ (unsigned long)fnic);
+ spin_lock_init(&fnic->vlans_lock);
+ INIT_WORK(&fnic->fip_frame_work, fnic_handle_fip_frame);
+ INIT_WORK(&fnic->event_work, fnic_handle_event);
+ skb_queue_head_init(&fnic->fip_frame_queue);
+ spin_lock_irqsave(&fnic_list_lock, flags);
+ if (!fnic_fip_queue) {
+ fnic_fip_queue =
+ create_singlethread_workqueue("fnic_fip_q");
+ if (!fnic_fip_queue) {
+ spin_unlock_irqrestore(&fnic_list_lock, flags);
+ printk(KERN_ERR PFX "fnic FIP work queue "
+ "create failed\n");
+ err = -ENOMEM;
+ goto err_out_free_max_pool;
+ }
+ }
+ spin_unlock_irqrestore(&fnic_list_lock, flags);
+ INIT_LIST_HEAD(&fnic->evlist);
+ INIT_LIST_HEAD(&fnic->vlans);
} else {
shost_printk(KERN_INFO, fnic->lport->host,
"firmware uses non-FIP mode\n");
The attempts to make fnic_fip_queue a single instance for the driver
while it's being created in probe look awkward anyway, why is this not
created in fnic_init_module like the event workqueue?
Signed-off-by: Chris Leech <cleech@redhat.com>
Tested-by: Anantha Tungarakodi <atungara@cisco.com>
Acked-by: Hiral Patel <hiralpat@cisco.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2013-07-23 14:04:58 -06:00
|
|
|
destroy_workqueue(fnic_fip_queue);
|
|
|
|
err_create_fip_workq:
|
2009-04-17 19:33:26 -06:00
|
|
|
destroy_workqueue(fnic_event_queue);
|
|
|
|
err_create_fnic_workq:
|
|
|
|
kmem_cache_destroy(fnic_io_req_cache);
|
|
|
|
err_create_fnic_ioreq_slab:
|
|
|
|
kmem_cache_destroy(fnic_sgl_cache[FNIC_SGL_CACHE_MAX]);
|
|
|
|
err_create_fnic_sgl_slab_max:
|
|
|
|
kmem_cache_destroy(fnic_sgl_cache[FNIC_SGL_CACHE_DFLT]);
|
|
|
|
err_create_fnic_sgl_slab_dflt:
|
2013-02-12 18:01:02 -07:00
|
|
|
fnic_trace_free();
|
2014-04-18 13:28:19 -06:00
|
|
|
fnic_fc_trace_free();
|
2013-09-12 18:45:42 -06:00
|
|
|
fnic_debugfs_terminate();
|
2009-04-17 19:33:26 -06:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit fnic_cleanup_module(void)
|
|
|
|
{
|
|
|
|
pci_unregister_driver(&fnic_driver);
|
|
|
|
destroy_workqueue(fnic_event_queue);
|
2013-02-25 17:18:36 -07:00
|
|
|
if (fnic_fip_queue) {
|
|
|
|
flush_workqueue(fnic_fip_queue);
|
|
|
|
destroy_workqueue(fnic_fip_queue);
|
|
|
|
}
|
2009-04-17 19:33:26 -06:00
|
|
|
kmem_cache_destroy(fnic_sgl_cache[FNIC_SGL_CACHE_MAX]);
|
|
|
|
kmem_cache_destroy(fnic_sgl_cache[FNIC_SGL_CACHE_DFLT]);
|
|
|
|
kmem_cache_destroy(fnic_io_req_cache);
|
|
|
|
fc_release_transport(fnic_fc_transport);
|
2013-02-12 18:01:02 -07:00
|
|
|
fnic_trace_free();
|
2014-04-18 13:28:19 -06:00
|
|
|
fnic_fc_trace_free();
|
2013-09-12 18:45:42 -06:00
|
|
|
fnic_debugfs_terminate();
|
2009-04-17 19:33:26 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
module_init(fnic_init_module);
|
|
|
|
module_exit(fnic_cleanup_module);
|
|
|
|
|