2008-12-10 07:10:24 +08:00
|
|
|
/*
|
2009-08-26 04:59:24 +08:00
|
|
|
* Copyright(c) 2007 - 2009 Intel Corporation. All rights reserved.
|
2008-12-10 07:10:24 +08:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms and conditions of the GNU General Public License,
|
|
|
|
* version 2, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
* Maintained at www.Open-FCoE.org
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/spinlock.h>
|
|
|
|
#include <linux/netdevice.h>
|
|
|
|
#include <linux/etherdevice.h>
|
|
|
|
#include <linux/ethtool.h>
|
|
|
|
#include <linux/if_ether.h>
|
|
|
|
#include <linux/if_vlan.h>
|
|
|
|
#include <linux/crc32.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 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2008-12-10 07:10:24 +08:00
|
|
|
#include <linux/cpu.h>
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/sysfs.h>
|
|
|
|
#include <linux/ctype.h>
|
2011-01-29 08:05:32 +08:00
|
|
|
#include <linux/workqueue.h>
|
2011-11-19 05:35:56 +08:00
|
|
|
#include <net/dcbnl.h>
|
|
|
|
#include <net/dcbevent.h>
|
2008-12-10 07:10:24 +08:00
|
|
|
#include <scsi/scsi_tcq.h>
|
|
|
|
#include <scsi/scsicam.h>
|
|
|
|
#include <scsi/scsi_transport.h>
|
|
|
|
#include <scsi/scsi_transport_fc.h>
|
|
|
|
#include <net/rtnetlink.h>
|
|
|
|
|
|
|
|
#include <scsi/fc/fc_encaps.h>
|
2009-03-18 02:42:40 +08:00
|
|
|
#include <scsi/fc/fc_fip.h>
|
2012-05-23 10:06:26 +08:00
|
|
|
#include <scsi/fc/fc_fcoe.h>
|
2008-12-10 07:10:24 +08:00
|
|
|
|
|
|
|
#include <scsi/libfc.h>
|
|
|
|
#include <scsi/fc_frame.h>
|
|
|
|
#include <scsi/libfcoe.h>
|
|
|
|
|
2009-03-18 02:42:24 +08:00
|
|
|
#include "fcoe.h"
|
2009-03-28 00:06:31 +08:00
|
|
|
|
2008-12-10 07:10:24 +08:00
|
|
|
MODULE_AUTHOR("Open-FCoE.org");
|
|
|
|
MODULE_DESCRIPTION("FCoE");
|
2009-03-18 02:42:13 +08:00
|
|
|
MODULE_LICENSE("GPL v2");
|
2008-12-10 07:10:24 +08:00
|
|
|
|
2009-08-26 04:59:03 +08:00
|
|
|
/* Performance tuning parameters for fcoe */
|
2011-09-28 12:38:18 +08:00
|
|
|
static unsigned int fcoe_ddp_min = 4096;
|
2009-08-26 04:59:03 +08:00
|
|
|
module_param_named(ddp_min, fcoe_ddp_min, uint, S_IRUGO | S_IWUSR);
|
|
|
|
MODULE_PARM_DESC(ddp_min, "Minimum I/O size in bytes for " \
|
|
|
|
"Direct Data Placement (DDP).");
|
|
|
|
|
2012-01-14 09:26:25 +08:00
|
|
|
unsigned int fcoe_debug_logging;
|
|
|
|
module_param_named(debug_logging, fcoe_debug_logging, int, S_IRUGO|S_IWUSR);
|
|
|
|
MODULE_PARM_DESC(debug_logging, "a bit mask of logging levels");
|
|
|
|
|
|
|
|
static DEFINE_MUTEX(fcoe_config_mutex);
|
2009-08-26 05:00:13 +08:00
|
|
|
|
2011-01-29 08:05:32 +08:00
|
|
|
static struct workqueue_struct *fcoe_wq;
|
|
|
|
|
2008-12-10 07:10:24 +08:00
|
|
|
/* fcoe host list */
|
2009-08-26 05:00:28 +08:00
|
|
|
/* must only by accessed under the RTNL mutex */
|
2012-01-14 09:26:25 +08:00
|
|
|
static LIST_HEAD(fcoe_hostlist);
|
|
|
|
static DEFINE_PER_CPU(struct fcoe_percpu_s, fcoe_percpu);
|
2008-12-10 07:10:24 +08:00
|
|
|
|
2009-04-22 07:27:36 +08:00
|
|
|
/* Function Prototypes */
|
2009-11-04 03:47:50 +08:00
|
|
|
static int fcoe_reset(struct Scsi_Host *);
|
2009-03-18 02:42:24 +08:00
|
|
|
static int fcoe_xmit(struct fc_lport *, struct fc_frame *);
|
|
|
|
static int fcoe_rcv(struct sk_buff *, struct net_device *,
|
|
|
|
struct packet_type *, struct net_device *);
|
2009-11-04 03:47:50 +08:00
|
|
|
static void fcoe_percpu_clean(struct fc_lport *);
|
|
|
|
static int fcoe_link_ok(struct fc_lport *);
|
2009-03-18 02:42:24 +08:00
|
|
|
|
|
|
|
static struct fc_lport *fcoe_hostlist_lookup(const struct net_device *);
|
|
|
|
static int fcoe_hostlist_add(const struct fc_lport *);
|
2013-01-16 03:34:40 +08:00
|
|
|
static void fcoe_hostlist_del(const struct fc_lport *);
|
2009-03-18 02:42:24 +08:00
|
|
|
|
2008-12-10 07:10:24 +08:00
|
|
|
static int fcoe_device_notification(struct notifier_block *, ulong, void *);
|
|
|
|
static void fcoe_dev_setup(void);
|
|
|
|
static void fcoe_dev_cleanup(void);
|
2009-11-04 03:47:50 +08:00
|
|
|
static struct fcoe_interface
|
|
|
|
*fcoe_hostlist_lookup_port(const struct net_device *);
|
|
|
|
|
|
|
|
static int fcoe_fip_recv(struct sk_buff *, struct net_device *,
|
|
|
|
struct packet_type *, struct net_device *);
|
|
|
|
|
|
|
|
static void fcoe_fip_send(struct fcoe_ctlr *, struct sk_buff *);
|
|
|
|
static void fcoe_update_src_mac(struct fc_lport *, u8 *);
|
|
|
|
static u8 *fcoe_get_src_mac(struct fc_lport *);
|
|
|
|
static void fcoe_destroy_work(struct work_struct *);
|
|
|
|
|
|
|
|
static int fcoe_ddp_setup(struct fc_lport *, u16, struct scatterlist *,
|
|
|
|
unsigned int);
|
|
|
|
static int fcoe_ddp_done(struct fc_lport *, u16);
|
2011-06-21 07:59:10 +08:00
|
|
|
static int fcoe_ddp_target(struct fc_lport *, u16, struct scatterlist *,
|
|
|
|
unsigned int);
|
2011-11-19 05:35:56 +08:00
|
|
|
static int fcoe_dcb_app_notification(struct notifier_block *notifier,
|
|
|
|
ulong event, void *ptr);
|
2009-11-04 03:47:50 +08:00
|
|
|
|
2011-01-29 08:05:16 +08:00
|
|
|
static bool fcoe_match(struct net_device *netdev);
|
|
|
|
static int fcoe_create(struct net_device *netdev, enum fip_state fip_mode);
|
|
|
|
static int fcoe_destroy(struct net_device *netdev);
|
|
|
|
static int fcoe_enable(struct net_device *netdev);
|
|
|
|
static int fcoe_disable(struct net_device *netdev);
|
2009-11-04 03:47:50 +08:00
|
|
|
|
2012-11-27 14:53:35 +08:00
|
|
|
/* fcoe_syfs control interface handlers */
|
|
|
|
static int fcoe_ctlr_alloc(struct net_device *netdev);
|
|
|
|
static int fcoe_ctlr_enabled(struct fcoe_ctlr_device *cdev);
|
|
|
|
|
|
|
|
|
2009-11-04 03:47:50 +08:00
|
|
|
static struct fc_seq *fcoe_elsct_send(struct fc_lport *,
|
|
|
|
u32 did, struct fc_frame *,
|
|
|
|
unsigned int op,
|
|
|
|
void (*resp)(struct fc_seq *,
|
|
|
|
struct fc_frame *,
|
|
|
|
void *),
|
|
|
|
void *, u32 timeout);
|
2009-11-21 06:54:47 +08:00
|
|
|
static void fcoe_recv_frame(struct sk_buff *skb);
|
2009-11-04 03:47:50 +08:00
|
|
|
|
|
|
|
/* notification function for packets from net device */
|
2008-12-10 07:10:24 +08:00
|
|
|
static struct notifier_block fcoe_notifier = {
|
|
|
|
.notifier_call = fcoe_device_notification,
|
|
|
|
};
|
|
|
|
|
2011-11-19 05:35:56 +08:00
|
|
|
/* notification function for DCB events */
|
|
|
|
static struct notifier_block dcb_notifier = {
|
|
|
|
.notifier_call = fcoe_dcb_app_notification,
|
|
|
|
};
|
|
|
|
|
2011-01-29 08:05:11 +08:00
|
|
|
static struct scsi_transport_template *fcoe_nport_scsi_transport;
|
|
|
|
static struct scsi_transport_template *fcoe_vport_scsi_transport;
|
2009-03-28 00:06:31 +08:00
|
|
|
|
2009-11-04 03:47:50 +08:00
|
|
|
static int fcoe_vport_destroy(struct fc_vport *);
|
|
|
|
static int fcoe_vport_create(struct fc_vport *, bool disabled);
|
|
|
|
static int fcoe_vport_disable(struct fc_vport *, bool disable);
|
|
|
|
static void fcoe_set_vport_symbolic_name(struct fc_vport *);
|
2010-03-13 08:08:02 +08:00
|
|
|
static void fcoe_set_port_id(struct fc_lport *, u32, struct fc_frame *);
|
2012-05-23 10:06:26 +08:00
|
|
|
static void fcoe_fcf_get_vlan_id(struct fcoe_fcf_device *);
|
|
|
|
|
|
|
|
static struct fcoe_sysfs_function_template fcoe_sysfs_templ = {
|
2012-11-27 14:53:35 +08:00
|
|
|
.set_fcoe_ctlr_mode = fcoe_ctlr_set_fip_mode,
|
|
|
|
.set_fcoe_ctlr_enabled = fcoe_ctlr_enabled,
|
2012-05-23 10:06:26 +08:00
|
|
|
.get_fcoe_ctlr_link_fail = fcoe_ctlr_get_lesb,
|
|
|
|
.get_fcoe_ctlr_vlink_fail = fcoe_ctlr_get_lesb,
|
|
|
|
.get_fcoe_ctlr_miss_fka = fcoe_ctlr_get_lesb,
|
|
|
|
.get_fcoe_ctlr_symb_err = fcoe_ctlr_get_lesb,
|
|
|
|
.get_fcoe_ctlr_err_block = fcoe_ctlr_get_lesb,
|
|
|
|
.get_fcoe_ctlr_fcs_error = fcoe_ctlr_get_lesb,
|
|
|
|
|
|
|
|
.get_fcoe_fcf_selected = fcoe_fcf_get_selected,
|
|
|
|
.get_fcoe_fcf_vlan_id = fcoe_fcf_get_vlan_id,
|
|
|
|
};
|
2009-11-04 03:47:50 +08:00
|
|
|
|
|
|
|
static struct libfc_function_template fcoe_libfc_fcn_templ = {
|
|
|
|
.frame_send = fcoe_xmit,
|
|
|
|
.ddp_setup = fcoe_ddp_setup,
|
|
|
|
.ddp_done = fcoe_ddp_done,
|
2011-06-21 07:59:10 +08:00
|
|
|
.ddp_target = fcoe_ddp_target,
|
2009-11-04 03:47:50 +08:00
|
|
|
.elsct_send = fcoe_elsct_send,
|
2009-11-21 06:55:19 +08:00
|
|
|
.get_lesb = fcoe_get_lesb,
|
2010-03-13 08:08:02 +08:00
|
|
|
.lport_set_port_id = fcoe_set_port_id,
|
2009-11-04 03:47:50 +08:00
|
|
|
};
|
2009-11-04 03:46:40 +08:00
|
|
|
|
2012-01-14 09:26:25 +08:00
|
|
|
static struct fc_function_template fcoe_nport_fc_functions = {
|
2009-03-28 00:06:31 +08:00
|
|
|
.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,
|
2012-01-23 09:30:16 +08:00
|
|
|
.show_host_serial_number = 1,
|
|
|
|
.show_host_manufacturer = 1,
|
|
|
|
.show_host_model = 1,
|
|
|
|
.show_host_model_description = 1,
|
|
|
|
.show_host_hardware_version = 1,
|
|
|
|
.show_host_driver_version = 1,
|
|
|
|
.show_host_firmware_version = 1,
|
|
|
|
.show_host_optionrom_version = 1,
|
2009-03-28 00:06:31 +08:00
|
|
|
|
|
|
|
.show_host_port_id = 1,
|
|
|
|
.show_host_supported_speeds = 1,
|
|
|
|
.get_host_speed = fc_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,
|
|
|
|
|
|
|
|
.dd_fcrport_size = sizeof(struct fc_rport_libfc_priv),
|
|
|
|
.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,
|
|
|
|
.set_rport_dev_loss_tmo = fc_set_rport_loss_tmo,
|
|
|
|
.show_rport_dev_loss_tmo = 1,
|
|
|
|
.get_fc_host_stats = fc_get_host_stats,
|
|
|
|
.issue_fc_host_lip = fcoe_reset,
|
|
|
|
|
|
|
|
.terminate_rport_io = fc_rport_terminate_io,
|
2009-11-04 03:46:40 +08:00
|
|
|
|
|
|
|
.vport_create = fcoe_vport_create,
|
|
|
|
.vport_delete = fcoe_vport_destroy,
|
|
|
|
.vport_disable = fcoe_vport_disable,
|
2009-11-04 03:47:18 +08:00
|
|
|
.set_vport_symbolic_name = fcoe_set_vport_symbolic_name,
|
2009-11-04 03:47:34 +08:00
|
|
|
|
|
|
|
.bsg_request = fc_lport_bsg_request,
|
2009-03-28 00:06:31 +08:00
|
|
|
};
|
|
|
|
|
2012-01-14 09:26:25 +08:00
|
|
|
static struct fc_function_template fcoe_vport_fc_functions = {
|
2009-11-04 03:46:34 +08:00
|
|
|
.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,
|
2012-02-11 09:18:31 +08:00
|
|
|
.show_host_serial_number = 1,
|
|
|
|
.show_host_manufacturer = 1,
|
|
|
|
.show_host_model = 1,
|
|
|
|
.show_host_model_description = 1,
|
|
|
|
.show_host_hardware_version = 1,
|
|
|
|
.show_host_driver_version = 1,
|
|
|
|
.show_host_firmware_version = 1,
|
|
|
|
.show_host_optionrom_version = 1,
|
2009-11-04 03:46:34 +08:00
|
|
|
|
|
|
|
.show_host_port_id = 1,
|
|
|
|
.show_host_supported_speeds = 1,
|
|
|
|
.get_host_speed = fc_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,
|
|
|
|
|
|
|
|
.dd_fcrport_size = sizeof(struct fc_rport_libfc_priv),
|
|
|
|
.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,
|
|
|
|
.set_rport_dev_loss_tmo = fc_set_rport_loss_tmo,
|
|
|
|
.show_rport_dev_loss_tmo = 1,
|
|
|
|
.get_fc_host_stats = fc_get_host_stats,
|
|
|
|
.issue_fc_host_lip = fcoe_reset,
|
|
|
|
|
|
|
|
.terminate_rport_io = fc_rport_terminate_io,
|
2009-11-04 03:47:34 +08:00
|
|
|
|
|
|
|
.bsg_request = fc_lport_bsg_request,
|
2009-11-04 03:46:34 +08:00
|
|
|
};
|
|
|
|
|
2009-03-28 00:06:31 +08:00
|
|
|
static struct scsi_host_template fcoe_shost_template = {
|
|
|
|
.module = THIS_MODULE,
|
|
|
|
.name = "FCoE Driver",
|
|
|
|
.proc_name = FCOE_NAME,
|
|
|
|
.queuecommand = fc_queuecommand,
|
|
|
|
.eh_abort_handler = fc_eh_abort,
|
|
|
|
.eh_device_reset_handler = fc_eh_device_reset,
|
|
|
|
.eh_host_reset_handler = fc_eh_host_reset,
|
|
|
|
.slave_alloc = fc_slave_alloc,
|
2014-11-13 22:08:42 +08:00
|
|
|
.change_queue_depth = scsi_change_queue_depth,
|
2009-03-28 00:06:31 +08:00
|
|
|
.this_id = -1,
|
2009-10-16 08:46:55 +08:00
|
|
|
.cmd_per_lun = 3,
|
2009-03-28 00:06:31 +08:00
|
|
|
.can_queue = FCOE_MAX_OUTSTANDING_COMMANDS,
|
|
|
|
.use_clustering = ENABLE_CLUSTERING,
|
|
|
|
.sg_tablesize = SG_ALL,
|
|
|
|
.max_sectors = 0xffff,
|
2014-11-13 21:25:11 +08:00
|
|
|
.track_queue_depth = 1,
|
2009-03-28 00:06:31 +08:00
|
|
|
};
|
|
|
|
|
2009-08-26 05:00:07 +08:00
|
|
|
/**
|
2009-11-04 03:47:50 +08:00
|
|
|
* fcoe_interface_setup() - Setup a FCoE interface
|
|
|
|
* @fcoe: The new FCoE interface
|
|
|
|
* @netdev: The net device that the fcoe interface is on
|
2009-08-26 05:00:07 +08:00
|
|
|
*
|
|
|
|
* Returns : 0 for success
|
2009-08-26 05:00:23 +08:00
|
|
|
* Locking: must be called with the RTNL mutex held
|
2009-08-26 05:00:07 +08:00
|
|
|
*/
|
|
|
|
static int fcoe_interface_setup(struct fcoe_interface *fcoe,
|
|
|
|
struct net_device *netdev)
|
|
|
|
{
|
2012-05-23 10:06:10 +08:00
|
|
|
struct fcoe_ctlr *fip = fcoe_to_ctlr(fcoe);
|
2009-08-26 05:00:07 +08:00
|
|
|
struct netdev_hw_addr *ha;
|
2009-11-04 03:49:43 +08:00
|
|
|
struct net_device *real_dev;
|
2009-08-26 05:00:07 +08:00
|
|
|
u8 flogi_maddr[ETH_ALEN];
|
2009-10-22 07:28:03 +08:00
|
|
|
const struct net_device_ops *ops;
|
2009-08-26 05:00:07 +08:00
|
|
|
|
|
|
|
fcoe->netdev = netdev;
|
|
|
|
|
2009-10-22 07:28:03 +08:00
|
|
|
/* Let LLD initialize for FCoE */
|
|
|
|
ops = netdev->netdev_ops;
|
|
|
|
if (ops->ndo_fcoe_enable) {
|
|
|
|
if (ops->ndo_fcoe_enable(netdev))
|
|
|
|
FCOE_NETDEV_DBG(netdev, "Failed to enable FCoE"
|
|
|
|
" specific feature for LLD.\n");
|
|
|
|
}
|
|
|
|
|
2009-08-26 05:00:07 +08:00
|
|
|
/* Do not support for bonding device */
|
2011-03-02 04:05:35 +08:00
|
|
|
if (netdev->priv_flags & IFF_BONDING && netdev->flags & IFF_MASTER) {
|
2009-11-04 03:48:44 +08:00
|
|
|
FCOE_NETDEV_DBG(netdev, "Bonded interfaces not supported\n");
|
2009-08-26 05:00:07 +08:00
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* look for SAN MAC address, if multiple SAN MACs exist, only
|
|
|
|
* use the first one for SPMA */
|
2009-11-04 03:49:43 +08:00
|
|
|
real_dev = (netdev->priv_flags & IFF_802_1Q_VLAN) ?
|
|
|
|
vlan_dev_real_dev(netdev) : netdev;
|
2011-09-28 12:38:13 +08:00
|
|
|
fcoe->realdev = real_dev;
|
2009-08-26 05:00:07 +08:00
|
|
|
rcu_read_lock();
|
2009-11-04 03:49:43 +08:00
|
|
|
for_each_dev_addr(real_dev, ha) {
|
2009-08-26 05:00:07 +08:00
|
|
|
if ((ha->type == NETDEV_HW_ADDR_T_SAN) &&
|
2009-11-04 03:49:38 +08:00
|
|
|
(is_valid_ether_addr(ha->addr))) {
|
2009-08-26 05:00:07 +08:00
|
|
|
memcpy(fip->ctl_src_addr, ha->addr, ETH_ALEN);
|
|
|
|
fip->spma = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rcu_read_unlock();
|
|
|
|
|
|
|
|
/* setup Source Mac Address */
|
|
|
|
if (!fip->spma)
|
|
|
|
memcpy(fip->ctl_src_addr, netdev->dev_addr, netdev->addr_len);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Add FCoE MAC address as second unicast MAC address
|
|
|
|
* or enter promiscuous mode if not capable of listening
|
|
|
|
* for multiple unicast MACs.
|
|
|
|
*/
|
|
|
|
memcpy(flogi_maddr, (u8[6]) FC_FCOE_FLOGI_MAC, ETH_ALEN);
|
2010-04-02 05:22:09 +08:00
|
|
|
dev_uc_add(netdev, flogi_maddr);
|
2009-08-26 05:00:07 +08:00
|
|
|
if (fip->spma)
|
2010-04-02 05:22:09 +08:00
|
|
|
dev_uc_add(netdev, fip->ctl_src_addr);
|
[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-21 06:20:30 +08:00
|
|
|
if (fip->mode == FIP_MODE_VN2VN) {
|
|
|
|
dev_mc_add(netdev, FIP_ALL_VN2VN_MACS);
|
|
|
|
dev_mc_add(netdev, FIP_ALL_P2P_MACS);
|
|
|
|
} else
|
|
|
|
dev_mc_add(netdev, FIP_ALL_ENODE_MACS);
|
2009-08-26 05:00:07 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* setup the receive function from ethernet driver
|
|
|
|
* on the ethertype for the given device
|
|
|
|
*/
|
|
|
|
fcoe->fcoe_packet_type.func = fcoe_rcv;
|
2015-08-19 13:48:44 +08:00
|
|
|
fcoe->fcoe_packet_type.type = htons(ETH_P_FCOE);
|
2009-08-26 05:00:07 +08:00
|
|
|
fcoe->fcoe_packet_type.dev = netdev;
|
|
|
|
dev_add_pack(&fcoe->fcoe_packet_type);
|
|
|
|
|
|
|
|
fcoe->fip_packet_type.func = fcoe_fip_recv;
|
|
|
|
fcoe->fip_packet_type.type = htons(ETH_P_FIP);
|
|
|
|
fcoe->fip_packet_type.dev = netdev;
|
|
|
|
dev_add_pack(&fcoe->fip_packet_type);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-08-26 05:00:02 +08:00
|
|
|
/**
|
2009-11-04 03:47:50 +08:00
|
|
|
* fcoe_interface_create() - Create a FCoE interface on a net device
|
|
|
|
* @netdev: The net device to create the FCoE interface on
|
2010-07-21 06:20:46 +08:00
|
|
|
* @fip_mode: The mode to use for FIP
|
2009-08-26 05:00:02 +08:00
|
|
|
*
|
|
|
|
* Returns: pointer to a struct fcoe_interface or NULL on error
|
|
|
|
*/
|
2010-07-21 06:20:46 +08:00
|
|
|
static struct fcoe_interface *fcoe_interface_create(struct net_device *netdev,
|
|
|
|
enum fip_state fip_mode)
|
2009-08-26 05:00:02 +08:00
|
|
|
{
|
2012-05-23 10:06:26 +08:00
|
|
|
struct fcoe_ctlr_device *ctlr_dev;
|
2012-05-23 10:06:10 +08:00
|
|
|
struct fcoe_ctlr *ctlr;
|
2009-08-26 05:00:02 +08:00
|
|
|
struct fcoe_interface *fcoe;
|
2012-05-23 10:06:10 +08:00
|
|
|
int size;
|
2009-11-04 03:48:44 +08:00
|
|
|
int err;
|
2009-08-26 05:00:02 +08:00
|
|
|
|
2011-01-29 08:03:47 +08:00
|
|
|
if (!try_module_get(THIS_MODULE)) {
|
|
|
|
FCOE_NETDEV_DBG(netdev,
|
|
|
|
"Could not get a reference to the module\n");
|
|
|
|
fcoe = ERR_PTR(-EBUSY);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2012-05-23 10:06:10 +08:00
|
|
|
size = sizeof(struct fcoe_ctlr) + sizeof(struct fcoe_interface);
|
2012-05-23 10:06:26 +08:00
|
|
|
ctlr_dev = fcoe_ctlr_device_add(&netdev->dev, &fcoe_sysfs_templ,
|
|
|
|
size);
|
|
|
|
if (!ctlr_dev) {
|
|
|
|
FCOE_DBG("Failed to add fcoe_ctlr_device\n");
|
2011-01-29 08:03:47 +08:00
|
|
|
fcoe = ERR_PTR(-ENOMEM);
|
2012-02-11 09:18:36 +08:00
|
|
|
goto out_putmod;
|
2009-08-26 05:00:02 +08:00
|
|
|
}
|
|
|
|
|
2012-05-23 10:06:26 +08:00
|
|
|
ctlr = fcoe_ctlr_device_priv(ctlr_dev);
|
2013-09-05 15:47:27 +08:00
|
|
|
ctlr->cdev = ctlr_dev;
|
2012-05-23 10:06:26 +08:00
|
|
|
fcoe = fcoe_ctlr_priv(ctlr);
|
|
|
|
|
2009-08-26 05:00:23 +08:00
|
|
|
dev_hold(netdev);
|
2009-08-26 05:00:07 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize FIP.
|
|
|
|
*/
|
2012-05-23 10:06:10 +08:00
|
|
|
fcoe_ctlr_init(ctlr, fip_mode);
|
|
|
|
ctlr->send = fcoe_fip_send;
|
|
|
|
ctlr->update_mac = fcoe_update_src_mac;
|
|
|
|
ctlr->get_src_addr = fcoe_get_src_mac;
|
2009-08-26 05:00:07 +08:00
|
|
|
|
2009-11-04 03:48:44 +08:00
|
|
|
err = fcoe_interface_setup(fcoe, netdev);
|
|
|
|
if (err) {
|
2012-05-23 10:06:10 +08:00
|
|
|
fcoe_ctlr_destroy(ctlr);
|
2012-05-23 10:06:26 +08:00
|
|
|
fcoe_ctlr_device_delete(ctlr_dev);
|
2009-11-04 03:48:44 +08:00
|
|
|
dev_put(netdev);
|
2011-01-29 08:03:47 +08:00
|
|
|
fcoe = ERR_PTR(err);
|
2012-02-11 09:18:36 +08:00
|
|
|
goto out_putmod;
|
2009-11-04 03:48:44 +08:00
|
|
|
}
|
2009-08-26 05:00:02 +08:00
|
|
|
|
2011-01-29 08:03:47 +08:00
|
|
|
goto out;
|
|
|
|
|
2012-02-11 09:18:36 +08:00
|
|
|
out_putmod:
|
2011-01-29 08:03:47 +08:00
|
|
|
module_put(THIS_MODULE);
|
|
|
|
out:
|
2009-08-26 05:00:02 +08:00
|
|
|
return fcoe;
|
|
|
|
}
|
|
|
|
|
2009-08-26 05:00:07 +08:00
|
|
|
/**
|
2012-04-21 03:16:27 +08:00
|
|
|
* fcoe_interface_remove() - remove FCoE interface from netdev
|
2009-11-04 03:47:50 +08:00
|
|
|
* @fcoe: The FCoE interface to be cleaned up
|
2009-08-26 05:00:23 +08:00
|
|
|
*
|
|
|
|
* Caller must be holding the RTNL mutex
|
2009-08-26 05:00:07 +08:00
|
|
|
*/
|
2012-04-21 03:16:27 +08:00
|
|
|
static void fcoe_interface_remove(struct fcoe_interface *fcoe)
|
2009-08-26 05:00:07 +08:00
|
|
|
{
|
|
|
|
struct net_device *netdev = fcoe->netdev;
|
2012-05-23 10:06:10 +08:00
|
|
|
struct fcoe_ctlr *fip = fcoe_to_ctlr(fcoe);
|
2009-08-26 05:00:07 +08:00
|
|
|
u8 flogi_maddr[ETH_ALEN];
|
2009-10-22 07:28:03 +08:00
|
|
|
const struct net_device_ops *ops;
|
2009-08-26 05:00:07 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Don't listen for Ethernet packets anymore.
|
|
|
|
* synchronize_net() ensures that the packet handlers are not running
|
|
|
|
* on another CPU. dev_remove_pack() would do that, this calls the
|
|
|
|
* unsyncronized version __dev_remove_pack() to avoid multiple delays.
|
|
|
|
*/
|
|
|
|
__dev_remove_pack(&fcoe->fcoe_packet_type);
|
|
|
|
__dev_remove_pack(&fcoe->fip_packet_type);
|
|
|
|
synchronize_net();
|
|
|
|
|
|
|
|
/* Delete secondary MAC addresses */
|
|
|
|
memcpy(flogi_maddr, (u8[6]) FC_FCOE_FLOGI_MAC, ETH_ALEN);
|
2010-04-02 05:22:09 +08:00
|
|
|
dev_uc_del(netdev, flogi_maddr);
|
2009-08-26 05:00:07 +08:00
|
|
|
if (fip->spma)
|
2010-04-02 05:22:09 +08:00
|
|
|
dev_uc_del(netdev, fip->ctl_src_addr);
|
[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-21 06:20:30 +08:00
|
|
|
if (fip->mode == FIP_MODE_VN2VN) {
|
|
|
|
dev_mc_del(netdev, FIP_ALL_VN2VN_MACS);
|
|
|
|
dev_mc_del(netdev, FIP_ALL_P2P_MACS);
|
|
|
|
} else
|
|
|
|
dev_mc_del(netdev, FIP_ALL_ENODE_MACS);
|
2009-10-22 07:28:03 +08:00
|
|
|
|
|
|
|
/* Tell the LLD we are done w/ FCoE */
|
|
|
|
ops = netdev->netdev_ops;
|
|
|
|
if (ops->ndo_fcoe_disable) {
|
|
|
|
if (ops->ndo_fcoe_disable(netdev))
|
|
|
|
FCOE_NETDEV_DBG(netdev, "Failed to disable FCoE"
|
|
|
|
" specific feature for LLD.\n");
|
|
|
|
}
|
2012-04-21 03:16:27 +08:00
|
|
|
fcoe->removed = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* fcoe_interface_cleanup() - Clean up a FCoE interface
|
|
|
|
* @fcoe: The FCoE interface to be cleaned up
|
|
|
|
*/
|
|
|
|
static void fcoe_interface_cleanup(struct fcoe_interface *fcoe)
|
|
|
|
{
|
|
|
|
struct net_device *netdev = fcoe->netdev;
|
2012-05-23 10:06:10 +08:00
|
|
|
struct fcoe_ctlr *fip = fcoe_to_ctlr(fcoe);
|
2011-06-21 07:59:51 +08:00
|
|
|
|
2012-04-21 03:16:27 +08:00
|
|
|
rtnl_lock();
|
|
|
|
if (!fcoe->removed)
|
|
|
|
fcoe_interface_remove(fcoe);
|
[SCSI] fcoe: Fix deadlock between fip's recv_work and rtnl
The rtnl cannot be held durrng the fcoe_interface_put.
If it is the last reference on the fcoe_interface the
fcoe_ctlr_destroy will be called as a part of the
cleanup, ultimately calling cancel_work_sync(&fip->recv_work);
If we are processing a flogi response we will be in
the recv_work context and we will lock the rtnl to
add a new unicast MAC address. This is how the deadlock
can occur.
The fix is simply to move the rtnl_lock/unlock into
fcoe_interface_cleanup so that it can be unlocked before
fcoe_interface_put is called.
Here is the lockdep report:
Jul 21 11:26:35 bubba [ 223.870702]
ul 21 11:26:35 bubba [ 223.870704] =======================================================
Jul 21 11:26:35 bubba [ 223.871255] [ INFO: possible circular locking dependency detected ]
Jul 21 11:26:35 bubba [ 223.871530] 3.0.0-rc7+ #1
Jul 21 11:26:35 bubba [ 223.871797] -------------------------------------------------------
Jul 21 11:26:35 bubba [ 223.872072] lockdeptest.sh/3464 is trying to acquire lock:
Jul 21 11:26:35 bubba [ 223.872345] ((&fip->recv_work)
Jul 21 11:26:35 bubba ){+.+.+.}
Jul 21 11:26:35 bubba , at:
Jul 21 11:26:35 bubba [<ffffffff810531f1>] wait_on_work+0x0/0xbd
Jul 21 11:26:35 bubba [ 223.873022]
Jul 21 11:26:35 bubba [ 223.873023] but task is already holding lock:
Jul 21 11:26:35 bubba [ 223.873555] (rtnl_mutex
Jul 21 11:26:35 bubba ){+.+.+.}
Jul 21 11:26:35 bubba , at:
Jul 21 11:26:35 bubba [<ffffffff813e8233>] rtnl_lock+0x12/0x14
Jul 21 11:26:35 bubba [ 223.874229]
Jul 21 11:26:35 bubba [ 223.874230] which lock already depends on the new lock.
Jul 21 11:26:35 bubba [ 223.874231]
Jul 21 11:26:35 bubba [ 223.875032]
Jul 21 11:26:35 bubba [ 223.875033] the existing dependency chain (in reverse order) is:
Jul 21 11:26:35 bubba [ 223.875573]
Jul 21 11:26:35 bubba [ 223.875573] -> #1
Jul 21 11:26:35 bubba (rtnl_mutex
Jul 21 11:26:35 bubba ){+.+.+.}
Jul 21 11:26:35 bubba :
Jul 21 11:26:35 bubba [ 223.876301]
Jul 21 11:26:35 bubba [<ffffffff8106c14a>] lock_acquire+0xd2/0xf7
Jul 21 11:26:35 bubba [ 223.876645]
Jul 21 11:26:35 bubba [<ffffffff8151d975>] __mutex_lock_common+0x47/0x30d
Jul 21 11:26:35 bubba [ 223.876991]
Jul 21 11:26:35 bubba [<ffffffff8151dd36>] mutex_lock_nested+0x3b/0x40
Jul 21 11:26:35 bubba [ 223.877334]
Jul 21 11:26:35 bubba [<ffffffff813e8233>] rtnl_lock+0x12/0x14
Jul 21 11:26:35 bubba [ 223.877675]
Jul 21 11:26:35 bubba [<ffffffffa003d5a0>] fcoe_update_src_mac+0x2b/0x80 [fcoe]
Jul 21 11:26:35 bubba [ 223.878022]
Jul 21 11:26:35 bubba [<ffffffffa003d698>] fcoe_flogi_resp+0x5e/0x79 [fcoe]
Jul 21 11:26:35 bubba [ 223.878366]
Jul 21 11:26:35 bubba [<ffffffffa001566f>] fc_exch_recv+0x7f5/0x9da [libfc]
Jul 21 11:26:35 bubba [ 223.878713]
Jul 21 11:26:35 bubba [<ffffffffa00327d8>] fcoe_ctlr_recv_work+0x71f/0x10dc [libfcoe]
Jul 21 11:26:35 bubba [ 223.879258]
Jul 21 11:26:35 bubba [<ffffffff81053761>] process_one_work+0x1d7/0x347
Jul 21 11:26:35 bubba [ 223.879601]
Jul 21 11:26:35 bubba [<ffffffff81054ade>] worker_thread+0xf8/0x17c
Jul 21 11:26:35 bubba [ 223.879944]
Jul 21 11:26:35 bubba [<ffffffff81058184>] kthread+0x7d/0x85
Jul 21 11:26:35 bubba [ 223.880287]
Jul 21 11:26:35 bubba [<ffffffff81526414>] kernel_thread_helper+0x4/0x10
Jul 21 11:26:35 bubba [ 223.880634]
Jul 21 11:26:35 bubba [ 223.880635] -> #0
Jul 21 11:26:35 bubba ((&fip->recv_work)
Jul 21 11:26:35 bubba ){+.+.+.}
Jul 21 11:26:35 bubba :
Jul 21 11:26:35 bubba [ 223.881357]
Jul 21 11:26:35 bubba [<ffffffff8106b93e>] __lock_acquire+0xb1d/0xe2c
Jul 21 11:26:35 bubba [ 223.881695]
Jul 21 11:26:35 bubba [<ffffffff8106c14a>] lock_acquire+0xd2/0xf7
Jul 21 11:26:35 bubba [ 223.882033]
Jul 21 11:26:35 bubba [<ffffffff81053241>] wait_on_work+0x50/0xbd
Jul 21 11:26:35 bubba [ 223.882378]
Jul 21 11:26:35 bubba [<ffffffff81053b32>] __cancel_work_timer+0xb6/0xf4
Jul 21 11:26:35 bubba [ 223.882718]
Jul 21 11:26:35 bubba [<ffffffff81053b8a>] cancel_work_sync+0xb/0xd
Jul 21 11:26:35 bubba [ 223.883057]
Jul 21 11:26:35 bubba [<ffffffffa00317e6>] fcoe_ctlr_destroy+0x1d/0x67 [libfcoe]
Jul 21 11:26:35 bubba [ 223.883399]
Jul 21 11:26:35 bubba [<ffffffffa003e51e>] fcoe_interface_release+0x21/0x45 [fcoe]
Jul 21 11:26:35 bubba [ 223.883940]
Jul 21 11:26:35 bubba [<ffffffff811fbbe6>] kref_put+0x43/0x4d
Jul 21 11:26:35 bubba [ 223.884280]
Jul 21 11:26:35 bubba [<ffffffffa003ebba>] fcoe_interface_put+0x17/0x19 [fcoe]
Jul 21 11:26:35 bubba [ 223.884624]
Jul 21 11:26:35 bubba [<ffffffffa003f2a6>] fcoe_interface_cleanup+0x188/0x193 [fcoe]
Jul 21 11:26:35 bubba [ 223.885163]
Jul 21 11:26:35 bubba [<ffffffffa003f303>] fcoe_destroy+0x52/0x72 [fcoe]
Jul 21 11:26:35 bubba [ 223.885502]
Jul 21 11:26:35 bubba [<ffffffffa00340a4>] fcoe_transport_destroy+0xab/0x110 [libfcoe]
Jul 21 11:26:35 bubba [ 223.886045]
Jul 21 11:26:35 bubba [<ffffffff81056153>] param_attr_store+0x43/0x62
Jul 21 11:26:35 bubba [ 223.886385]
Jul 21 11:26:35 bubba [<ffffffff8105602d>] module_attr_store+0x21/0x25
Jul 21 11:26:35 bubba [ 223.886728]
Jul 21 11:26:35 bubba [<ffffffff8114c23d>] sysfs_write_file+0x103/0x13f
Jul 21 11:26:35 bubba [ 223.887068]
Jul 21 11:26:35 bubba [<ffffffff810f3e7b>] vfs_write+0xa7/0xfa
Jul 21 11:26:35 bubba [ 223.887406]
Jul 21 11:26:35 bubba [<ffffffff810f4073>] sys_write+0x45/0x69
Jul 21 11:26:35 bubba [ 223.887742]
Jul 21 11:26:35 bubba [<ffffffff815252bb>] system_call_fastpath+0x16/0x1b
Jul 21 11:26:35 bubba [ 223.888083]
Jul 21 11:26:35 bubba [ 223.888084] other info that might help us debug this:
Jul 21 11:26:35 bubba [ 223.888085]
Jul 21 11:26:35 bubba [ 223.888879] Possible unsafe locking scenario:
Jul 21 11:26:35 bubba [ 223.888881]
Jul 21 11:26:35 bubba [ 223.889411] CPU0 CPU1
Jul 21 11:26:35 bubba [ 223.889683] ---- ----
Jul 21 11:26:35 bubba [ 223.889955] lock(
Jul 21 11:26:35 bubba rtnl_mutex
Jul 21 11:26:35 bubba );
Jul 21 11:26:35 bubba [ 223.890349] lock(
Jul 21 11:26:35 bubba (&fip->recv_work)
Jul 21 11:26:35 bubba );
Jul 21 11:26:35 bubba [ 223.890751] lock(
Jul 21 11:26:35 bubba rtnl_mutex
Jul 21 11:26:35 bubba );
Jul 21 11:26:35 bubba [ 223.891154] lock(
Jul 21 11:26:35 bubba (&fip->recv_work)
Jul 21 11:26:35 bubba );
Jul 21 11:26:35 bubba [ 223.891549]
Jul 21 11:26:35 bubba [ 223.891550] *** DEADLOCK ***
Jul 21 11:26:35 bubba [ 223.891551]
Jul 21 11:26:35 bubba [ 223.892347] 6 locks held by lockdeptest.sh/3464:
Jul 21 11:26:35 bubba [ 223.892621] #0:
Jul 21 11:26:35 bubba (&buffer->mutex
Jul 21 11:26:35 bubba ){+.+.+.}
Jul 21 11:26:35 bubba , at:
Jul 21 11:26:35 bubba [<ffffffff8114c171>] sysfs_write_file+0x37/0x13f
Jul 21 11:26:35 bubba [ 223.893359] #1:
Jul 21 11:26:35 bubba (s_active
Jul 21 11:26:35 bubba ){++++.+}
Jul 21 11:26:35 bubba , at:
Jul 21 11:26:35 bubba [<ffffffff8114c21c>] sysfs_write_file+0xe2/0x13f
Jul 21 11:26:35 bubba [ 223.894094] #2:
Jul 21 11:26:35 bubba (param_lock
Jul 21 11:26:35 bubba ){+.+.+.}
Jul 21 11:26:35 bubba , at:
Jul 21 11:26:35 bubba [<ffffffff81056146>] param_attr_store+0x36/0x62
Jul 21 11:26:35 bubba [ 223.894835] #3:
Jul 21 11:26:35 bubba (ft_mutex
Jul 21 11:26:35 bubba ){+.+.+.}
Jul 21 11:26:35 bubba , at:
Jul 21 11:26:35 bubba [<ffffffffa0034017>] fcoe_transport_destroy+0x1e/0x110 [libfcoe]
Jul 21 11:26:35 bubba [ 223.895574] #4:
Jul 21 11:26:35 bubba (fcoe_config_mutex
Jul 21 11:26:35 bubba ){+.+.+.}
Jul 21 11:26:35 bubba , at:
Jul 21 11:26:35 bubba [<ffffffffa003f2c9>] fcoe_destroy+0x18/0x72 [fcoe]
Jul 21 11:26:35 bubba [ 223.896314] #5:
Jul 21 11:26:35 bubba (rtnl_mutex
Jul 21 11:26:35 bubba ){+.+.+.}
Jul 21 11:26:35 bubba , at:
Jul 21 11:26:35 bubba [<ffffffff813e8233>] rtnl_lock+0x12/0x14
Jul 21 11:26:35 bubba [ 223.897047]
Jul 21 11:26:35 bubba [ 223.897048] stack backtrace:
Jul 21 11:26:35 bubba [ 223.897578] Pid: 3464, comm: lockdeptest.sh Not tainted 3.0.0-rc7+ #1
Jul 21 11:26:35 bubba [ 223.897853] Call Trace:
Jul 21 11:26:35 bubba [ 223.898128] [<ffffffff81068e16>] print_circular_bug+0x1f8/0x209
Jul 21 11:26:35 bubba [ 223.898416] [<ffffffff8106b93e>] __lock_acquire+0xb1d/0xe2c
Jul 21 11:26:35 bubba [ 223.898699] [<ffffffff810531f1>] ? wait_on_cpu_work+0xe6/0xe6
Jul 21 11:26:35 bubba [ 223.898982] [<ffffffff8106c14a>] lock_acquire+0xd2/0xf7
Jul 21 11:26:35 bubba [ 223.899263] [<ffffffff810531f1>] ? wait_on_cpu_work+0xe6/0xe6
Jul 21 11:26:35 bubba [ 223.899547] [<ffffffff8104a097>] ? mod_timer+0x8f/0x98
Jul 21 11:26:35 bubba [ 223.899827] [<ffffffff81053241>] wait_on_work+0x50/0xbd
Jul 21 11:26:35 bubba [ 223.900108] [<ffffffff810531f1>] ? wait_on_cpu_work+0xe6/0xe6
Jul 21 11:26:35 bubba [ 223.900390] [<ffffffff81053b32>] __cancel_work_timer+0xb6/0xf4
Jul 21 11:26:35 bubba [ 223.900671] [<ffffffff81053b8a>] cancel_work_sync+0xb/0xd
Jul 21 11:26:35 bubba [ 223.900953] [<ffffffffa00317e6>] fcoe_ctlr_destroy+0x1d/0x67 [libfcoe]
Jul 21 11:26:35 bubba [ 223.901237] [<ffffffffa003e51e>] fcoe_interface_release+0x21/0x45 [fcoe]
Jul 21 11:26:35 bubba [ 223.901522] [<ffffffffa003e4fd>] ? fcoe_enable+0x6b/0x6b [fcoe]
Jul 21 11:26:35 bubba [ 223.901803] [<ffffffff811fbbe6>] kref_put+0x43/0x4d
Jul 21 11:26:35 bubba [ 223.902083] [<ffffffffa003ebba>] fcoe_interface_put+0x17/0x19 [fcoe]
Jul 21 11:26:35 bubba [ 223.902367] [<ffffffffa003f2a6>] fcoe_interface_cleanup+0x188/0x193 [fcoe]
Jul 21 11:26:35 bubba [ 223.902653] [<ffffffff8151dd36>] ? mutex_lock_nested+0x3b/0x40
Jul 21 11:26:35 bubba [ 223.902939] [<ffffffffa003f303>] fcoe_destroy+0x52/0x72 [fcoe]
Jul 21 11:26:35 bubba [ 223.903223] [<ffffffffa00340a4>] fcoe_transport_destroy+0xab/0x110 [libfcoe]
Jul 21 11:26:35 bubba [ 223.903508] [<ffffffff81056153>] param_attr_store+0x43/0x62
Jul 21 11:26:35 bubba [ 223.903792] [<ffffffff8105602d>] module_attr_store+0x21/0x25
Jul 21 11:26:35 bubba [ 223.904075] [<ffffffff8114c23d>] sysfs_write_file+0x103/0x13f
Jul 21 11:26:35 bubba [ 223.904357] [<ffffffff810f3e7b>] vfs_write+0xa7/0xfa
Jul 21 11:26:35 bubba [ 223.904642] [<ffffffff810f51d6>] ? fget_light+0x35/0x96
Jul 21 11:26:35 bubba [ 223.904923] [<ffffffff810f4073>] sys_write+0x45/0x69
Jul 21 11:26:35 bubba [ 223.905204] [<ffffffff815252bb>] system_call_fastpath+0x16/0x1b
Jul 21 11:26:36 bubba [ 223.964438] ixgbe 0000:05:00.0: eth3: detected SFP+: 5
Jul 21 11:26:37 bubba [ 225.196702] ixgbe 0000:05:00.0: eth3: NIC Link is Up 10 Gbps, Flow Control: None
Signed-off-by: Robert Love <robert.w.love@intel.com>
Tested-by: Ross Brattain <ross.b.brattain@intel.com>
Reviewed-by: Yi Zou <yi.zou@intel.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2011-08-26 03:40:47 +08:00
|
|
|
rtnl_unlock();
|
|
|
|
|
2011-06-21 07:59:51 +08:00
|
|
|
/* Release the self-reference taken during fcoe_interface_create() */
|
2012-02-11 09:18:46 +08:00
|
|
|
/* tear-down the FCoE controller */
|
|
|
|
fcoe_ctlr_destroy(fip);
|
2012-05-23 10:06:10 +08:00
|
|
|
scsi_host_put(fip->lp->host);
|
2012-02-11 09:18:46 +08:00
|
|
|
dev_put(netdev);
|
|
|
|
module_put(THIS_MODULE);
|
2009-08-26 05:00:02 +08:00
|
|
|
}
|
|
|
|
|
2009-05-17 20:33:08 +08:00
|
|
|
/**
|
2009-11-04 03:47:50 +08:00
|
|
|
* fcoe_fip_recv() - Handler for received FIP frames
|
|
|
|
* @skb: The receive skb
|
|
|
|
* @netdev: The associated net device
|
|
|
|
* @ptype: The packet_type structure which was used to register this handler
|
|
|
|
* @orig_dev: The original net_device the the skb was received on.
|
|
|
|
* (in case dev is a bond)
|
2009-05-17 20:33:08 +08:00
|
|
|
*
|
|
|
|
* Returns: 0 for success
|
|
|
|
*/
|
2009-11-04 03:47:50 +08:00
|
|
|
static int fcoe_fip_recv(struct sk_buff *skb, struct net_device *netdev,
|
2009-05-17 20:33:08 +08:00
|
|
|
struct packet_type *ptype,
|
|
|
|
struct net_device *orig_dev)
|
|
|
|
{
|
2009-08-26 04:59:41 +08:00
|
|
|
struct fcoe_interface *fcoe;
|
2012-05-23 10:06:10 +08:00
|
|
|
struct fcoe_ctlr *ctlr;
|
2009-05-17 20:33:08 +08:00
|
|
|
|
2009-08-26 04:59:41 +08:00
|
|
|
fcoe = container_of(ptype, struct fcoe_interface, fip_packet_type);
|
2012-05-23 10:06:10 +08:00
|
|
|
ctlr = fcoe_to_ctlr(fcoe);
|
|
|
|
fcoe_ctlr_recv(ctlr, skb);
|
2009-05-17 20:33:08 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-07-28 06:11:05 +08:00
|
|
|
/**
|
|
|
|
* fcoe_port_send() - Send an Ethernet-encapsulated FIP/FCoE frame
|
|
|
|
* @port: The FCoE port
|
|
|
|
* @skb: The FIP/FCoE packet to be sent
|
|
|
|
*/
|
|
|
|
static void fcoe_port_send(struct fcoe_port *port, struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
if (port->fcoe_pending_queue.qlen)
|
|
|
|
fcoe_check_wait_queue(port->lport, skb);
|
|
|
|
else if (fcoe_start_io(skb))
|
|
|
|
fcoe_check_wait_queue(port->lport, skb);
|
|
|
|
}
|
|
|
|
|
2009-05-17 20:33:08 +08:00
|
|
|
/**
|
2009-11-04 03:47:50 +08:00
|
|
|
* fcoe_fip_send() - Send an Ethernet-encapsulated FIP frame
|
|
|
|
* @fip: The FCoE controller
|
|
|
|
* @skb: The FIP packet to be sent
|
2009-05-17 20:33:08 +08:00
|
|
|
*/
|
|
|
|
static void fcoe_fip_send(struct fcoe_ctlr *fip, struct sk_buff *skb)
|
|
|
|
{
|
2009-08-26 04:59:46 +08:00
|
|
|
skb->dev = fcoe_from_ctlr(fip)->netdev;
|
2011-07-28 06:11:05 +08:00
|
|
|
fcoe_port_send(lport_priv(fip->lp), skb);
|
2009-05-17 20:33:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-11-04 03:47:50 +08:00
|
|
|
* fcoe_update_src_mac() - Update the Ethernet MAC filters
|
|
|
|
* @lport: The local port to update the source MAC on
|
|
|
|
* @addr: Unicast MAC address to add
|
2009-05-17 20:33:08 +08:00
|
|
|
*
|
|
|
|
* Remove any previously-set unicast MAC filter.
|
|
|
|
* Add secondary FCoE MAC address filter for our OUI.
|
|
|
|
*/
|
2009-11-04 03:46:29 +08:00
|
|
|
static void fcoe_update_src_mac(struct fc_lport *lport, u8 *addr)
|
2009-05-17 20:33:08 +08:00
|
|
|
{
|
2009-11-04 03:46:29 +08:00
|
|
|
struct fcoe_port *port = lport_priv(lport);
|
2011-01-29 08:05:37 +08:00
|
|
|
struct fcoe_interface *fcoe = port->priv;
|
2009-08-26 04:59:35 +08:00
|
|
|
|
2009-11-04 03:46:29 +08:00
|
|
|
if (!is_zero_ether_addr(port->data_src_addr))
|
2010-04-02 05:22:09 +08:00
|
|
|
dev_uc_del(fcoe->netdev, port->data_src_addr);
|
2009-11-04 03:46:29 +08:00
|
|
|
if (!is_zero_ether_addr(addr))
|
2010-04-02 05:22:09 +08:00
|
|
|
dev_uc_add(fcoe->netdev, addr);
|
2009-11-04 03:46:29 +08:00
|
|
|
memcpy(port->data_src_addr, addr, ETH_ALEN);
|
2009-05-17 20:33:08 +08:00
|
|
|
}
|
|
|
|
|
2009-11-04 03:46:29 +08:00
|
|
|
/**
|
|
|
|
* fcoe_get_src_mac() - return the Ethernet source address for an lport
|
|
|
|
* @lport: libfc lport
|
|
|
|
*/
|
|
|
|
static u8 *fcoe_get_src_mac(struct fc_lport *lport)
|
|
|
|
{
|
|
|
|
struct fcoe_port *port = lport_priv(lport);
|
|
|
|
|
|
|
|
return port->data_src_addr;
|
|
|
|
}
|
|
|
|
|
2009-03-28 00:06:31 +08:00
|
|
|
/**
|
2009-11-04 03:47:50 +08:00
|
|
|
* fcoe_lport_config() - Set up a local port
|
|
|
|
* @lport: The local port to be setup
|
2009-03-28 00:06:31 +08:00
|
|
|
*
|
|
|
|
* Returns: 0 for success
|
|
|
|
*/
|
2009-11-04 03:47:50 +08:00
|
|
|
static int fcoe_lport_config(struct fc_lport *lport)
|
2009-03-28 00:06:31 +08:00
|
|
|
{
|
2009-11-04 03:47:50 +08:00
|
|
|
lport->link_up = 0;
|
|
|
|
lport->qfull = 0;
|
|
|
|
lport->max_retry_count = 3;
|
|
|
|
lport->max_rport_retry_count = 3;
|
|
|
|
lport->e_d_tov = 2 * 1000; /* FC-FS default */
|
|
|
|
lport->r_a_tov = 2 * 2 * 1000;
|
|
|
|
lport->service_params = (FCP_SPPF_INIT_FCN | FCP_SPPF_RD_XRDY_DIS |
|
|
|
|
FCP_SPPF_RETRY | FCP_SPPF_CONF_COMPL);
|
|
|
|
lport->does_npiv = 1;
|
|
|
|
|
|
|
|
fc_lport_init_stats(lport);
|
2009-03-28 00:06:31 +08:00
|
|
|
|
|
|
|
/* lport fc_lport related configuration */
|
2009-11-04 03:47:50 +08:00
|
|
|
fc_lport_config(lport);
|
2009-03-28 00:06:31 +08:00
|
|
|
|
|
|
|
/* offload related configuration */
|
2009-11-04 03:47:50 +08:00
|
|
|
lport->crc_offload = 0;
|
|
|
|
lport->seq_offload = 0;
|
|
|
|
lport->lro_enabled = 0;
|
|
|
|
lport->lro_xid = 0;
|
|
|
|
lport->lso_max = 0;
|
2009-03-28 00:06:31 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-07-21 06:21:17 +08:00
|
|
|
/**
|
|
|
|
* fcoe_netdev_features_change - Updates the lport's offload flags based
|
|
|
|
* on the LLD netdev's FCoE feature flags
|
|
|
|
*/
|
|
|
|
static void fcoe_netdev_features_change(struct fc_lport *lport,
|
|
|
|
struct net_device *netdev)
|
|
|
|
{
|
|
|
|
mutex_lock(&lport->lp_mutex);
|
|
|
|
|
|
|
|
if (netdev->features & NETIF_F_SG)
|
|
|
|
lport->sg_supp = 1;
|
|
|
|
else
|
|
|
|
lport->sg_supp = 0;
|
|
|
|
|
|
|
|
if (netdev->features & NETIF_F_FCOE_CRC) {
|
|
|
|
lport->crc_offload = 1;
|
|
|
|
FCOE_NETDEV_DBG(netdev, "Supports FCCRC offload\n");
|
|
|
|
} else {
|
|
|
|
lport->crc_offload = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (netdev->features & NETIF_F_FSO) {
|
|
|
|
lport->seq_offload = 1;
|
|
|
|
lport->lso_max = netdev->gso_max_size;
|
|
|
|
FCOE_NETDEV_DBG(netdev, "Supports LSO for max len 0x%x\n",
|
|
|
|
lport->lso_max);
|
|
|
|
} else {
|
|
|
|
lport->seq_offload = 0;
|
|
|
|
lport->lso_max = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (netdev->fcoe_ddp_xid) {
|
|
|
|
lport->lro_enabled = 1;
|
|
|
|
lport->lro_xid = netdev->fcoe_ddp_xid;
|
|
|
|
FCOE_NETDEV_DBG(netdev, "Supports LRO for max xid 0x%x\n",
|
|
|
|
lport->lro_xid);
|
|
|
|
} else {
|
|
|
|
lport->lro_enabled = 0;
|
|
|
|
lport->lro_xid = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
mutex_unlock(&lport->lp_mutex);
|
|
|
|
}
|
|
|
|
|
2009-03-28 00:06:31 +08:00
|
|
|
/**
|
2009-11-04 03:47:50 +08:00
|
|
|
* fcoe_netdev_config() - Set up net devive for SW FCoE
|
|
|
|
* @lport: The local port that is associated with the net device
|
|
|
|
* @netdev: The associated net device
|
2009-03-28 00:06:31 +08:00
|
|
|
*
|
2009-11-04 03:47:50 +08:00
|
|
|
* Must be called after fcoe_lport_config() as it will use local port mutex
|
2009-03-28 00:06:31 +08:00
|
|
|
*
|
2009-11-04 03:47:50 +08:00
|
|
|
* Returns: 0 for success
|
2009-03-28 00:06:31 +08:00
|
|
|
*/
|
2009-11-04 03:47:50 +08:00
|
|
|
static int fcoe_netdev_config(struct fc_lport *lport, struct net_device *netdev)
|
2009-03-28 00:06:31 +08:00
|
|
|
{
|
|
|
|
u32 mfs;
|
|
|
|
u64 wwnn, wwpn;
|
2009-08-26 04:59:35 +08:00
|
|
|
struct fcoe_interface *fcoe;
|
2012-05-23 10:06:10 +08:00
|
|
|
struct fcoe_ctlr *ctlr;
|
2009-08-26 04:59:30 +08:00
|
|
|
struct fcoe_port *port;
|
2009-03-28 00:06:31 +08:00
|
|
|
|
|
|
|
/* Setup lport private data to point to fcoe softc */
|
2009-11-04 03:47:50 +08:00
|
|
|
port = lport_priv(lport);
|
2011-01-29 08:05:37 +08:00
|
|
|
fcoe = port->priv;
|
2012-05-23 10:06:10 +08:00
|
|
|
ctlr = fcoe_to_ctlr(fcoe);
|
2009-03-28 00:06:31 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Determine max frame size based on underlying device and optional
|
|
|
|
* user-configured limit. If the MFS is too low, fcoe_link_ok()
|
|
|
|
* will return 0, so do this first.
|
|
|
|
*/
|
2009-10-22 07:27:52 +08:00
|
|
|
mfs = netdev->mtu;
|
|
|
|
if (netdev->features & NETIF_F_FCOE_MTU) {
|
|
|
|
mfs = FCOE_MTU;
|
|
|
|
FCOE_NETDEV_DBG(netdev, "Supports FCOE_MTU of %d bytes\n", mfs);
|
|
|
|
}
|
|
|
|
mfs -= (sizeof(struct fcoe_hdr) + sizeof(struct fcoe_crc_eof));
|
2009-11-04 03:47:50 +08:00
|
|
|
if (fc_set_mfs(lport, mfs))
|
2009-03-28 00:06:31 +08:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* offload features support */
|
2010-07-21 06:21:17 +08:00
|
|
|
fcoe_netdev_features_change(lport, netdev);
|
2009-03-28 00:06:31 +08:00
|
|
|
|
2009-08-26 04:59:30 +08:00
|
|
|
skb_queue_head_init(&port->fcoe_pending_queue);
|
|
|
|
port->fcoe_pending_queue_active = 0;
|
2009-11-04 03:47:50 +08:00
|
|
|
setup_timer(&port->timer, fcoe_queue_timer, (unsigned long)lport);
|
2009-03-28 00:06:31 +08:00
|
|
|
|
2010-05-08 06:18:35 +08:00
|
|
|
fcoe_link_speed_update(lport);
|
|
|
|
|
2009-11-04 03:47:50 +08:00
|
|
|
if (!lport->vport) {
|
2009-11-21 07:22:21 +08:00
|
|
|
if (fcoe_get_wwn(netdev, &wwnn, NETDEV_FCOE_WWNN))
|
2012-05-23 10:06:10 +08:00
|
|
|
wwnn = fcoe_wwn_from_mac(ctlr->ctl_src_addr, 1, 0);
|
2009-11-04 03:47:50 +08:00
|
|
|
fc_set_wwnn(lport, wwnn);
|
2009-11-21 07:22:21 +08:00
|
|
|
if (fcoe_get_wwn(netdev, &wwpn, NETDEV_FCOE_WWPN))
|
2012-05-23 10:06:10 +08:00
|
|
|
wwpn = fcoe_wwn_from_mac(ctlr->ctl_src_addr,
|
2010-07-21 06:21:22 +08:00
|
|
|
2, 0);
|
2009-11-04 03:47:50 +08:00
|
|
|
fc_set_wwpn(lport, wwpn);
|
2009-11-04 03:46:40 +08:00
|
|
|
}
|
2009-03-28 00:06:31 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-11-04 03:47:50 +08:00
|
|
|
* fcoe_shost_config() - Set up the SCSI host associated with a local port
|
|
|
|
* @lport: The local port
|
|
|
|
* @dev: The device associated with the SCSI host
|
2009-03-28 00:06:31 +08:00
|
|
|
*
|
|
|
|
* Must be called after fcoe_lport_config() and fcoe_netdev_config()
|
|
|
|
*
|
2009-11-04 03:47:50 +08:00
|
|
|
* Returns: 0 for success
|
2009-03-28 00:06:31 +08:00
|
|
|
*/
|
2010-04-10 05:22:54 +08:00
|
|
|
static int fcoe_shost_config(struct fc_lport *lport, struct device *dev)
|
2009-03-28 00:06:31 +08:00
|
|
|
{
|
|
|
|
int rc = 0;
|
|
|
|
|
|
|
|
/* lport scsi host config */
|
2009-11-04 03:47:50 +08:00
|
|
|
lport->host->max_lun = FCOE_MAX_LUN;
|
|
|
|
lport->host->max_id = FCOE_MAX_FCP_TARGET;
|
|
|
|
lport->host->max_channel = 0;
|
2010-04-10 05:22:59 +08:00
|
|
|
lport->host->max_cmd_len = FCOE_MAX_CMD_LEN;
|
|
|
|
|
2009-11-04 03:47:50 +08:00
|
|
|
if (lport->vport)
|
2011-01-29 08:05:11 +08:00
|
|
|
lport->host->transportt = fcoe_vport_scsi_transport;
|
2009-11-04 03:46:34 +08:00
|
|
|
else
|
2011-01-29 08:05:11 +08:00
|
|
|
lport->host->transportt = fcoe_nport_scsi_transport;
|
2009-03-28 00:06:31 +08:00
|
|
|
|
|
|
|
/* add the new host to the SCSI-ml */
|
2009-11-04 03:47:50 +08:00
|
|
|
rc = scsi_add_host(lport->host, dev);
|
2009-03-28 00:06:31 +08:00
|
|
|
if (rc) {
|
2009-11-04 03:47:50 +08:00
|
|
|
FCOE_NETDEV_DBG(fcoe_netdev(lport), "fcoe_shost_config: "
|
2009-06-11 06:30:59 +08:00
|
|
|
"error on scsi_add_host\n");
|
2009-03-28 00:06:31 +08:00
|
|
|
return rc;
|
|
|
|
}
|
2009-11-04 03:46:40 +08:00
|
|
|
|
2009-11-04 03:47:50 +08:00
|
|
|
if (!lport->vport)
|
2010-05-25 05:33:03 +08:00
|
|
|
fc_host_max_npiv_vports(lport->host) = USHRT_MAX;
|
2009-11-04 03:46:40 +08:00
|
|
|
|
2009-11-04 03:47:50 +08:00
|
|
|
snprintf(fc_host_symbolic_name(lport->host), FC_SYMBOLIC_NAME_SIZE,
|
2009-11-04 03:46:56 +08:00
|
|
|
"%s v%s over %s", FCOE_NAME, FCOE_VERSION,
|
2009-11-04 03:47:50 +08:00
|
|
|
fcoe_netdev(lport)->name);
|
2009-03-28 00:06:31 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-01-23 09:30:10 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* fcoe_fdmi_info() - Get FDMI related info from net devive for SW FCoE
|
|
|
|
* @lport: The local port that is associated with the net device
|
|
|
|
* @netdev: The associated net device
|
|
|
|
*
|
|
|
|
* Must be called after fcoe_shost_config() as it will use local port mutex
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static void fcoe_fdmi_info(struct fc_lport *lport, struct net_device *netdev)
|
|
|
|
{
|
|
|
|
struct fcoe_interface *fcoe;
|
|
|
|
struct fcoe_port *port;
|
|
|
|
struct net_device *realdev;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
port = lport_priv(lport);
|
|
|
|
fcoe = port->priv;
|
|
|
|
realdev = fcoe->realdev;
|
|
|
|
|
|
|
|
if (!realdev)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* No FDMI state m/c for NPIV ports */
|
|
|
|
if (lport->vport)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (realdev->netdev_ops->ndo_fcoe_get_hbainfo) {
|
2013-05-18 13:12:28 +08:00
|
|
|
struct netdev_fcoe_hbainfo *fdmi;
|
|
|
|
fdmi = kzalloc(sizeof(*fdmi), GFP_KERNEL);
|
|
|
|
if (!fdmi)
|
|
|
|
return;
|
|
|
|
|
2012-01-23 09:30:10 +08:00
|
|
|
rc = realdev->netdev_ops->ndo_fcoe_get_hbainfo(realdev,
|
2013-05-18 13:12:28 +08:00
|
|
|
fdmi);
|
2012-01-23 09:30:10 +08:00
|
|
|
if (rc) {
|
|
|
|
printk(KERN_INFO "fcoe: Failed to retrieve FDMI "
|
|
|
|
"information from netdev.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
snprintf(fc_host_serial_number(lport->host),
|
|
|
|
FC_SERIAL_NUMBER_SIZE,
|
|
|
|
"%s",
|
2013-05-18 13:12:28 +08:00
|
|
|
fdmi->serial_number);
|
2012-01-23 09:30:10 +08:00
|
|
|
snprintf(fc_host_manufacturer(lport->host),
|
|
|
|
FC_SERIAL_NUMBER_SIZE,
|
|
|
|
"%s",
|
2013-05-18 13:12:28 +08:00
|
|
|
fdmi->manufacturer);
|
2012-01-23 09:30:10 +08:00
|
|
|
snprintf(fc_host_model(lport->host),
|
|
|
|
FC_SYMBOLIC_NAME_SIZE,
|
|
|
|
"%s",
|
2013-05-18 13:12:28 +08:00
|
|
|
fdmi->model);
|
2012-01-23 09:30:10 +08:00
|
|
|
snprintf(fc_host_model_description(lport->host),
|
|
|
|
FC_SYMBOLIC_NAME_SIZE,
|
|
|
|
"%s",
|
2013-05-18 13:12:28 +08:00
|
|
|
fdmi->model_description);
|
2012-01-23 09:30:10 +08:00
|
|
|
snprintf(fc_host_hardware_version(lport->host),
|
|
|
|
FC_VERSION_STRING_SIZE,
|
|
|
|
"%s",
|
2013-05-18 13:12:28 +08:00
|
|
|
fdmi->hardware_version);
|
2012-01-23 09:30:10 +08:00
|
|
|
snprintf(fc_host_driver_version(lport->host),
|
|
|
|
FC_VERSION_STRING_SIZE,
|
|
|
|
"%s",
|
2013-05-18 13:12:28 +08:00
|
|
|
fdmi->driver_version);
|
2012-01-23 09:30:10 +08:00
|
|
|
snprintf(fc_host_optionrom_version(lport->host),
|
|
|
|
FC_VERSION_STRING_SIZE,
|
|
|
|
"%s",
|
2013-05-18 13:12:28 +08:00
|
|
|
fdmi->optionrom_version);
|
2012-01-23 09:30:10 +08:00
|
|
|
snprintf(fc_host_firmware_version(lport->host),
|
|
|
|
FC_VERSION_STRING_SIZE,
|
|
|
|
"%s",
|
2013-05-18 13:12:28 +08:00
|
|
|
fdmi->firmware_version);
|
2012-01-23 09:30:10 +08:00
|
|
|
|
|
|
|
/* Enable FDMI lport states */
|
|
|
|
lport->fdmi_enabled = 1;
|
2013-05-18 13:12:28 +08:00
|
|
|
kfree(fdmi);
|
2012-01-23 09:30:10 +08:00
|
|
|
} else {
|
|
|
|
lport->fdmi_enabled = 0;
|
|
|
|
printk(KERN_INFO "fcoe: No FDMI support.\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-04 03:47:50 +08:00
|
|
|
/**
|
|
|
|
* fcoe_oem_match() - The match routine for the offloaded exchange manager
|
|
|
|
* @fp: The I/O frame
|
2009-07-30 08:05:21 +08:00
|
|
|
*
|
2009-11-04 03:47:50 +08:00
|
|
|
* This routine will be associated with an exchange manager (EM). When
|
|
|
|
* the libfc exchange handling code is looking for an EM to use it will
|
|
|
|
* call this routine and pass it the frame that it wishes to send. This
|
|
|
|
* routine will return True if the associated EM is to be used and False
|
|
|
|
* if the echange code should continue looking for an EM.
|
|
|
|
*
|
|
|
|
* The offload EM that this routine is associated with will handle any
|
|
|
|
* packets that are for SCSI read requests.
|
|
|
|
*
|
2011-06-21 07:59:15 +08:00
|
|
|
* This has been enhanced to work when FCoE stack is operating in target
|
|
|
|
* mode.
|
|
|
|
*
|
2009-11-04 03:47:50 +08:00
|
|
|
* Returns: True for read types I/O, otherwise returns false.
|
2009-07-30 08:05:21 +08:00
|
|
|
*/
|
2012-01-14 09:26:25 +08:00
|
|
|
static bool fcoe_oem_match(struct fc_frame *fp)
|
2009-07-30 08:05:21 +08:00
|
|
|
{
|
2011-06-21 07:59:15 +08:00
|
|
|
struct fc_frame_header *fh = fc_frame_header_get(fp);
|
|
|
|
struct fcp_cmnd *fcp;
|
|
|
|
|
|
|
|
if (fc_fcp_is_read(fr_fsp(fp)) &&
|
|
|
|
(fr_fsp(fp)->data_len > fcoe_ddp_min))
|
|
|
|
return true;
|
2012-01-14 09:26:15 +08:00
|
|
|
else if ((fr_fsp(fp) == NULL) &&
|
|
|
|
(fh->fh_r_ctl == FC_RCTL_DD_UNSOL_CMD) &&
|
|
|
|
(ntohs(fh->fh_rx_id) == FC_XID_UNKNOWN)) {
|
2011-06-21 07:59:15 +08:00
|
|
|
fcp = fc_frame_payload_get(fp, sizeof(*fcp));
|
2012-01-14 09:26:15 +08:00
|
|
|
if ((fcp->fc_flags & FCP_CFL_WRDATA) &&
|
|
|
|
(ntohl(fcp->fc_dl) > fcoe_ddp_min))
|
2011-06-21 07:59:15 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2009-07-30 08:05:21 +08:00
|
|
|
}
|
|
|
|
|
2009-03-28 00:06:31 +08:00
|
|
|
/**
|
2009-11-04 03:47:50 +08:00
|
|
|
* fcoe_em_config() - Allocate and configure an exchange manager
|
|
|
|
* @lport: The local port that the new EM will be associated with
|
2009-03-28 00:06:31 +08:00
|
|
|
*
|
2009-11-04 03:47:50 +08:00
|
|
|
* Returns: 0 on success
|
2009-03-28 00:06:31 +08:00
|
|
|
*/
|
2009-11-04 03:47:50 +08:00
|
|
|
static inline int fcoe_em_config(struct fc_lport *lport)
|
2009-03-28 00:06:31 +08:00
|
|
|
{
|
2009-11-04 03:47:50 +08:00
|
|
|
struct fcoe_port *port = lport_priv(lport);
|
2011-01-29 08:05:37 +08:00
|
|
|
struct fcoe_interface *fcoe = port->priv;
|
2009-08-26 04:59:35 +08:00
|
|
|
struct fcoe_interface *oldfcoe = NULL;
|
2009-07-30 08:05:45 +08:00
|
|
|
struct net_device *old_real_dev, *cur_real_dev;
|
2009-07-30 08:05:21 +08:00
|
|
|
u16 min_xid = FCOE_MIN_XID;
|
|
|
|
u16 max_xid = FCOE_MAX_XID;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check if need to allocate an em instance for
|
|
|
|
* offload exchange ids to be shared across all VN_PORTs/lport.
|
|
|
|
*/
|
2009-11-04 03:47:50 +08:00
|
|
|
if (!lport->lro_enabled || !lport->lro_xid ||
|
|
|
|
(lport->lro_xid >= max_xid)) {
|
|
|
|
lport->lro_xid = 0;
|
2009-07-30 08:05:21 +08:00
|
|
|
goto skip_oem;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reuse existing offload em instance in case
|
2009-07-30 08:05:45 +08:00
|
|
|
* it is already allocated on real eth device
|
2009-07-30 08:05:21 +08:00
|
|
|
*/
|
2009-08-26 04:59:35 +08:00
|
|
|
if (fcoe->netdev->priv_flags & IFF_802_1Q_VLAN)
|
|
|
|
cur_real_dev = vlan_dev_real_dev(fcoe->netdev);
|
2009-07-30 08:05:45 +08:00
|
|
|
else
|
2009-08-26 04:59:35 +08:00
|
|
|
cur_real_dev = fcoe->netdev;
|
2009-07-30 08:05:45 +08:00
|
|
|
|
2009-08-26 04:59:35 +08:00
|
|
|
list_for_each_entry(oldfcoe, &fcoe_hostlist, list) {
|
|
|
|
if (oldfcoe->netdev->priv_flags & IFF_802_1Q_VLAN)
|
|
|
|
old_real_dev = vlan_dev_real_dev(oldfcoe->netdev);
|
2009-07-30 08:05:45 +08:00
|
|
|
else
|
2009-08-26 04:59:35 +08:00
|
|
|
old_real_dev = oldfcoe->netdev;
|
2009-07-30 08:05:45 +08:00
|
|
|
|
|
|
|
if (cur_real_dev == old_real_dev) {
|
2009-08-26 04:59:51 +08:00
|
|
|
fcoe->oem = oldfcoe->oem;
|
2009-07-30 08:05:21 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-26 04:59:51 +08:00
|
|
|
if (fcoe->oem) {
|
2009-11-04 03:47:50 +08:00
|
|
|
if (!fc_exch_mgr_add(lport, fcoe->oem, fcoe_oem_match)) {
|
2009-07-30 08:05:21 +08:00
|
|
|
printk(KERN_ERR "fcoe_em_config: failed to add "
|
|
|
|
"offload em:%p on interface:%s\n",
|
2009-08-26 04:59:51 +08:00
|
|
|
fcoe->oem, fcoe->netdev->name);
|
2009-07-30 08:05:21 +08:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
} else {
|
2009-11-04 03:47:50 +08:00
|
|
|
fcoe->oem = fc_exch_mgr_alloc(lport, FC_CLASS_3,
|
|
|
|
FCOE_MIN_XID, lport->lro_xid,
|
|
|
|
fcoe_oem_match);
|
2009-08-26 04:59:51 +08:00
|
|
|
if (!fcoe->oem) {
|
2009-07-30 08:05:21 +08:00
|
|
|
printk(KERN_ERR "fcoe_em_config: failed to allocate "
|
|
|
|
"em for offload exches on interface:%s\n",
|
2009-08-26 04:59:35 +08:00
|
|
|
fcoe->netdev->name);
|
2009-07-30 08:05:21 +08:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Exclude offload EM xid range from next EM xid range.
|
|
|
|
*/
|
2009-11-04 03:47:50 +08:00
|
|
|
min_xid += lport->lro_xid + 1;
|
2009-07-30 08:05:21 +08:00
|
|
|
|
|
|
|
skip_oem:
|
2009-11-04 03:47:50 +08:00
|
|
|
if (!fc_exch_mgr_alloc(lport, FC_CLASS_3, min_xid, max_xid, NULL)) {
|
2009-07-30 08:05:21 +08:00
|
|
|
printk(KERN_ERR "fcoe_em_config: failed to "
|
2009-08-26 04:59:35 +08:00
|
|
|
"allocate em on interface %s\n", fcoe->netdev->name);
|
2009-03-28 00:06:31 +08:00
|
|
|
return -ENOMEM;
|
2009-07-30 08:05:21 +08:00
|
|
|
}
|
2009-03-28 00:06:31 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-11-04 03:47:50 +08:00
|
|
|
* fcoe_if_destroy() - Tear down a SW FCoE instance
|
|
|
|
* @lport: The local port to be destroyed
|
[SCSI] fcoe: fix a circular locking issue with rtnl and sysfs mutex
Currently rtnl mutex is grabbed during fcoe create, destroy, enable
and disable operations while sysfs s_active read mutex is already
held, but simultaneously other networking events could try grabbing
write s_active mutex while rtnl is already held and that is causing
circular lock warning, its detailed log pasted at end.
In this log, the rtnl was held before write s_active during device
renaming but there are more such cases as Joe reported another
instance with tg3 open at:-
http://www.open-fcoe.org/pipermail/devel/2010-February/008263.html
This patch fixes this issue by not waiting for rtnl mutex during
fcoe ops, that means if rtnl mutex is not immediately available
then restart_syscall() to allow others waiting in line to
grab s_active along with rtnl mutex to finish their work first
under these mutex.
Currently rtnl mutex was grabbed twice during fcoe_destroy call flow,
second grab was from fcoe_if_destroy called from fcoe_destroy after
dropping rtnl mutex before calling fcoe_if_destroy, so instead made
fcoe_if_destroy always called with rtnl mutex held to have this mutex
grabbed only once in this code path.
However left matching rtnl_unlock as-is in its original place as it was
dropped there for good reason since very next call causes synchronous
fip worker flush and if rtnl mutex is still held before flush
then that would cause new circular warning between fip->recv_work and
rtnl mutex, I've added detailed comment for this on fcoe_if_destroy
calling and rtnl muxtes unlocking.
=======================================================
[ INFO: possible circular locking dependency detected ]
2.6.33.1linux-stable-2.6.33 #1
-------------------------------------------------------
fcoemon/18823 is trying to acquire lock:
(fcoe_config_mutex){+.+.+.}, at: [<ffffffffa02ba5fc>] fcoe_create+0x27/0x4f7
[fcoe]
but task is already holding lock:
(s_active){++++.+}, at: [<ffffffff8115ef93>] sysfs_get_active_two+0x31/0x48
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #2 (s_active){++++.+}:
[<ffffffff81077bdb>] __lock_acquire+0xb73/0xd2b
[<ffffffff81077e60>] lock_acquire+0xcd/0xf1
[<ffffffff8115e5df>] sysfs_deactivate+0x8b/0xe0
[<ffffffff8115edfb>] sysfs_addrm_finish+0x36/0x55
[<ffffffff8115d0cc>] sysfs_hash_and_remove+0x53/0x6a
[<ffffffff8115f353>] sysfs_remove_link+0x21/0x23
[<ffffffff812b6c93>] device_rename+0x99/0xcb
[<ffffffff8138dbf0>] dev_change_name+0xd5/0x1d2
[<ffffffff8138deee>] dev_ifsioc+0x201/0x2ac
[<ffffffff8138e4ba>] dev_ioctl+0x521/0x632
[<ffffffff81379e43>] sock_do_ioctl+0x3d/0x47
[<ffffffff8137a254>] sock_ioctl+0x213/0x222
[<ffffffff81114614>] vfs_ioctl+0x32/0xa6
[<ffffffff81114b94>] do_vfs_ioctl+0x490/0x4d6
[<ffffffff81114c30>] sys_ioctl+0x56/0x79
[<ffffffff81009b42>] system_call_fastpath+0x16/0x1b
-> #1 (rtnl_mutex){+.+.+.}:
[<ffffffff81077bdb>] __lock_acquire+0xb73/0xd2b
[<ffffffff81077e60>] lock_acquire+0xcd/0xf1
[<ffffffff8142f343>] __mutex_lock_common+0x4b/0x383
[<ffffffff8142f73f>] mutex_lock_nested+0x3e/0x43
[<ffffffff813959f9>] rtnl_lock+0x17/0x19
[<ffffffff8138ccae>] register_netdevice_notifier+0x1e/0x19b
[<ffffffffa02580c1>] 0xffffffffa02580c1
[<ffffffff81002069>] do_one_initcall+0x5e/0x15e
[<ffffffff81084094>] sys_init_module+0xd8/0x23a
[<ffffffff81009b42>] system_call_fastpath+0x16/0x1b
-> #0 (fcoe_config_mutex){+.+.+.}:
[<ffffffff81077a85>] __lock_acquire+0xa1d/0xd2b
[<ffffffff81077e60>] lock_acquire+0xcd/0xf1
[<ffffffff8142f343>] __mutex_lock_common+0x4b/0x383
[<ffffffff8142f73f>] mutex_lock_nested+0x3e/0x43
[<ffffffffa02ba5fc>] fcoe_create+0x27/0x4f7 [fcoe]
[<ffffffff810635b1>] param_attr_store+0x27/0x35
[<ffffffff81063619>] module_attr_store+0x26/0x2a
[<ffffffff8115dae3>] sysfs_write_file+0x108/0x144
[<ffffffff81107bd1>] vfs_write+0xae/0x10b
[<ffffffff81107cee>] sys_write+0x4a/0x6e
[<ffffffff81009b42>] system_call_fastpath+0x16/0x1b
other info that might help us debug this:
3 locks held by fcoemon/18823:
#0: (&buffer->mutex){+.+.+.}, at: [<ffffffff8115da17>]
sysfs_write_file+0x3c/0x144
#1: (s_active){++++.+}, at: [<ffffffff8115ef86>]
sysfs_get_active_two+0x24/0x48
#2: (s_active){++++.+}, at: [<ffffffff8115ef93>]
sysfs_get_active_two+0x31/0x48
stack backtrace:
Pid: 18823, comm: fcoemon Tainted: G W 2.6.33.1linux-stable-2.6.33 #1
Call Trace:
[<ffffffff81076c38>] print_circular_bug+0xa8/0xb6
[<ffffffff81077a85>] __lock_acquire+0xa1d/0xd2b
[<ffffffffa02ba5fc>] ? fcoe_create+0x27/0x4f7 [fcoe]
[<ffffffff81077e60>] lock_acquire+0xcd/0xf1
[<ffffffffa02ba5fc>] ? fcoe_create+0x27/0x4f7 [fcoe]
[<ffffffffa02ba5fc>] ? fcoe_create+0x27/0x4f7 [fcoe]
[<ffffffff8142f343>] __mutex_lock_common+0x4b/0x383
[<ffffffffa02ba5fc>] ? fcoe_create+0x27/0x4f7 [fcoe]
[<ffffffff8106ac70>] ? cpu_clock+0x43/0x5e
[<ffffffff81074e12>] ? lockstat_clock+0x11/0x13
[<ffffffff81074e40>] ? lock_release_holdtime+0x2c/0x127
[<ffffffff8115ef93>] ? sysfs_get_active_two+0x31/0x48
[<ffffffff8142f73f>] mutex_lock_nested+0x3e/0x43
[<ffffffffa02ba5fc>] fcoe_create+0x27/0x4f7 [fcoe]
[<ffffffff810635b1>] param_attr_store+0x27/0x35
[<ffffffff81063619>] module_attr_store+0x26/0x2a
[<ffffffff8115dae3>] sysfs_write_file+0x108/0x144
[<ffffffff81107bd1>] vfs_write+0xae/0x10b
[<ffffffff81076596>] ? trace_hardirqs_on_caller+0x125/0x150
[<ffffffff81107cee>] sys_write+0x4a/0x6e
[<ffffffff81009b42>] system_call_fastpath+0x16/0x1b
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@suse.de>
2010-05-08 06:18:46 +08:00
|
|
|
*
|
2009-03-28 00:06:31 +08:00
|
|
|
*/
|
2009-08-26 04:59:24 +08:00
|
|
|
static void fcoe_if_destroy(struct fc_lport *lport)
|
2009-03-28 00:06:31 +08:00
|
|
|
{
|
2011-06-21 07:59:51 +08:00
|
|
|
struct fcoe_port *port = lport_priv(lport);
|
|
|
|
struct fcoe_interface *fcoe = port->priv;
|
|
|
|
struct net_device *netdev = fcoe->netdev;
|
|
|
|
|
|
|
|
FCOE_NETDEV_DBG(netdev, "Destroying interface\n");
|
|
|
|
|
|
|
|
/* Logout of the fabric */
|
|
|
|
fc_fabric_logoff(lport);
|
|
|
|
|
|
|
|
/* Cleanup the fc_lport */
|
|
|
|
fc_lport_destroy(lport);
|
|
|
|
|
|
|
|
/* Stop the transmit retry timer */
|
|
|
|
del_timer_sync(&port->timer);
|
|
|
|
|
|
|
|
/* Free existing transmit skbs */
|
|
|
|
fcoe_clean_pending_queue(lport);
|
|
|
|
|
|
|
|
rtnl_lock();
|
|
|
|
if (!is_zero_ether_addr(port->data_src_addr))
|
|
|
|
dev_uc_del(netdev, port->data_src_addr);
|
2012-04-21 03:16:27 +08:00
|
|
|
if (lport->vport)
|
|
|
|
synchronize_net();
|
|
|
|
else
|
|
|
|
fcoe_interface_remove(fcoe);
|
2011-06-21 07:59:51 +08:00
|
|
|
rtnl_unlock();
|
|
|
|
|
2009-07-30 08:04:17 +08:00
|
|
|
/* Free queued packets for the per-CPU receive threads */
|
2009-08-26 04:59:24 +08:00
|
|
|
fcoe_percpu_clean(lport);
|
2009-07-30 08:04:17 +08:00
|
|
|
|
2009-03-28 00:06:31 +08:00
|
|
|
/* Detach from the scsi-ml */
|
2009-08-26 04:59:24 +08:00
|
|
|
fc_remove_host(lport->host);
|
|
|
|
scsi_remove_host(lport->host);
|
2009-03-28 00:06:31 +08:00
|
|
|
|
[SCSI] libfc: fix NULL pointer dereference bug in fc_fcp_pkt_release
This happens when then tearing down the fcoe interface with active I/O.
The back trace shows dead000000200200 in RAX, i.e., LIST_POISON2, indicating
that the fsp is already being dequeued, which is probably why no complaining
was seen in fc_fcp_destroy() about outstanding fsp not freed, since we dequeue
it in the end of fc_io_compl() before releasing it. The bug is due to the
fact that we have already destroyed lport's scsi_pkt_pool while on-going i/o
is still accessing it through fc_fcp_pkt_release(), like this trace or the
similar code path from scsi-ml to fc_eh_abort, etc. This is fixed by moving
the fc_fcp_destroy() after lport is detached from scsi-ml since fc_fcp_destroy
is supposed to called only once where no lport lock is taken, otherwise the
fc_fcp_pkt_release() would have to grab the lport lock.
BUG: unable to handle kernel NULL pointer dereference at (null)
.......
RIP: 0010:[<0000000000000000>]
[<(null)>] (null)
RSP: 0018:ffff8803270f7b88 EFLAGS: 00010282
RAX: dead000000200200 RBX: ffff880197d2fbc0 RCX: 0000000000005908
RDX: ffff880195ea6d08 RSI: 0000000000000282 RDI: ffff880180f4fec0
RBP: ffff8803270f7bc0 R08: ffff880197d2fbe0 R09: 0000000000000000
R10: ffff88032867f090 R11: 0000000000000000 R12: ffff880195ea6d08
R13: 0000000000000282 R14: ffff880180f4fec0 R15: 0000000000000000
FS: 0000000000000000(0000) GS:ffff8801b5820000(0000) knlGS:0000000000000000
CS: 0010 DS: 0018 ES: 0018 CR0: 000000008005003b
CR2: 0000000000000000 CR3: 00000001a6eae000 CR4: 00000000000006e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
Process fc_rport_eq (pid: 5278, threadinfo ffff8803270f6000, task ffff880326254ab0)
Stack:
ffffffffa02c39ca ffff8803270f7ba0 ffff88019331cbc0 ffff880197d2fbc0
0000000000000000 ffff8801a8c895e0 ffff8801a8c895e0 ffff8803270f7c10
ffffffffa02c4962 ffff8803270f7be0 ffffffff814c94ab ffff8803270f7c10
Call Trace:
[<ffffffffa02c39ca>] ? fc_io_compl+0x10a/0x530 [libfc]
[<ffffffffa02c4962>] fc_fcp_complete_locked+0x72/0x150 [libfc]
[<ffffffff814c94ab>] ? _spin_unlock_bh+0x1b/0x20
[<ffffffffa02b98ff>] ? fc_exch_done+0x3f/0x60 [libfc]
[<ffffffffa02c4a8f>] fc_fcp_retry_cmd+0x4f/0x60 [libfc]
[<ffffffffa02c6150>] fc_fcp_recv+0x9b0/0xc30 [libfc]
[<ffffffff8106ba7a>] ? _call_console_drivers+0x4a/0x80
[<ffffffff8107d5ec>] ? lock_timer_base+0x3c/0x70
[<ffffffff8107e06b>] ? try_to_del_timer_sync+0x7b/0xe0
[<ffffffffa02b9dcf>] fc_exch_mgr_reset+0x1df/0x250 [libfc]
[<ffffffffa02c57a0>] ? fc_fcp_recv+0x0/0xc30 [libfc]
[<ffffffffa02c1042>] fc_rport_work+0xf2/0x4e0 [libfc]
[<ffffffff8109203e>] ? prepare_to_wait+0x4e/0x80
[<ffffffffa02c0f50>] ? fc_rport_work+0x0/0x4e0 [libfc]
[<ffffffff8108c6c0>] worker_thread+0x170/0x2a0
[<ffffffff81091d50>] ? autoremove_wake_function+0x0/0x40
[<ffffffff8108c550>] ? worker_thread+0x0/0x2a0
[<ffffffff810919e6>] kthread+0x96/0xa0
[<ffffffff810141ca>] child_rip+0xa/0x20
[<ffffffff81091950>] ? kthread+0x0/0xa0
[<ffffffff810141c0>] ? child_rip+0x0/0x20
Code:
Bad RIP value.
RIP
[<(null)>] (null)
RSP <ffff8803270f7b88>
CR2: 0000000000000000
Signed-off-by: Yi Zou <yi.zou@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2010-12-01 08:18:07 +08:00
|
|
|
/* Destroy lport scsi_priv */
|
|
|
|
fc_fcp_destroy(lport);
|
|
|
|
|
2009-03-28 00:06:31 +08:00
|
|
|
/* There are no more rports or I/O, free the EM */
|
2009-08-26 04:59:24 +08:00
|
|
|
fc_exch_mgr_free(lport);
|
2009-03-28 00:06:31 +08:00
|
|
|
|
|
|
|
/* Free memory used by statistical counters */
|
2009-08-26 04:59:24 +08:00
|
|
|
fc_lport_free_stats(lport);
|
2009-03-28 00:06:31 +08:00
|
|
|
|
2012-04-21 03:16:38 +08:00
|
|
|
/*
|
|
|
|
* Release the Scsi_Host for vport but hold on to
|
|
|
|
* master lport until it fcoe interface fully cleaned-up.
|
|
|
|
*/
|
|
|
|
if (lport->vport)
|
|
|
|
scsi_host_put(lport->host);
|
2009-03-28 00:06:31 +08:00
|
|
|
}
|
|
|
|
|
2009-11-04 03:47:50 +08:00
|
|
|
/**
|
|
|
|
* fcoe_ddp_setup() - Call a LLD's ddp_setup through the net device
|
|
|
|
* @lport: The local port to setup DDP for
|
|
|
|
* @xid: The exchange ID for this DDP transfer
|
|
|
|
* @sgl: The scatterlist describing this transfer
|
|
|
|
* @sgc: The number of sg items
|
2009-03-28 00:06:31 +08:00
|
|
|
*
|
2009-11-04 03:47:50 +08:00
|
|
|
* Returns: 0 if the DDP context was not configured
|
2009-03-28 00:06:31 +08:00
|
|
|
*/
|
2009-11-04 03:47:50 +08:00
|
|
|
static int fcoe_ddp_setup(struct fc_lport *lport, u16 xid,
|
|
|
|
struct scatterlist *sgl, unsigned int sgc)
|
2009-03-28 00:06:31 +08:00
|
|
|
{
|
2009-11-04 03:47:50 +08:00
|
|
|
struct net_device *netdev = fcoe_netdev(lport);
|
2009-03-28 00:06:31 +08:00
|
|
|
|
2009-11-04 03:47:50 +08:00
|
|
|
if (netdev->netdev_ops->ndo_fcoe_ddp_setup)
|
|
|
|
return netdev->netdev_ops->ndo_fcoe_ddp_setup(netdev,
|
|
|
|
xid, sgl,
|
|
|
|
sgc);
|
2009-03-28 00:06:31 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-06-21 07:59:10 +08:00
|
|
|
/**
|
|
|
|
* fcoe_ddp_target() - Call a LLD's ddp_target through the net device
|
|
|
|
* @lport: The local port to setup DDP for
|
|
|
|
* @xid: The exchange ID for this DDP transfer
|
|
|
|
* @sgl: The scatterlist describing this transfer
|
|
|
|
* @sgc: The number of sg items
|
|
|
|
*
|
|
|
|
* Returns: 0 if the DDP context was not configured
|
|
|
|
*/
|
|
|
|
static int fcoe_ddp_target(struct fc_lport *lport, u16 xid,
|
|
|
|
struct scatterlist *sgl, unsigned int sgc)
|
|
|
|
{
|
|
|
|
struct net_device *netdev = fcoe_netdev(lport);
|
|
|
|
|
|
|
|
if (netdev->netdev_ops->ndo_fcoe_ddp_target)
|
|
|
|
return netdev->netdev_ops->ndo_fcoe_ddp_target(netdev, xid,
|
|
|
|
sgl, sgc);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-04 03:47:50 +08:00
|
|
|
/**
|
|
|
|
* fcoe_ddp_done() - Call a LLD's ddp_done through the net device
|
|
|
|
* @lport: The local port to complete DDP on
|
|
|
|
* @xid: The exchange ID for this DDP transfer
|
2009-03-28 00:06:31 +08:00
|
|
|
*
|
2009-11-04 03:47:50 +08:00
|
|
|
* Returns: the length of data that have been completed by DDP
|
2009-03-28 00:06:31 +08:00
|
|
|
*/
|
2009-11-04 03:47:50 +08:00
|
|
|
static int fcoe_ddp_done(struct fc_lport *lport, u16 xid)
|
2009-03-28 00:06:31 +08:00
|
|
|
{
|
2009-11-04 03:47:50 +08:00
|
|
|
struct net_device *netdev = fcoe_netdev(lport);
|
2009-03-28 00:06:31 +08:00
|
|
|
|
2009-11-04 03:47:50 +08:00
|
|
|
if (netdev->netdev_ops->ndo_fcoe_ddp_done)
|
|
|
|
return netdev->netdev_ops->ndo_fcoe_ddp_done(netdev, xid);
|
2009-03-28 00:06:31 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-11-04 03:47:50 +08:00
|
|
|
* fcoe_if_create() - Create a FCoE instance on an interface
|
|
|
|
* @fcoe: The FCoE interface to create a local port on
|
|
|
|
* @parent: The device pointer to be the parent in sysfs for the SCSI host
|
|
|
|
* @npiv: Indicates if the port is a vport or not
|
2009-03-28 00:06:31 +08:00
|
|
|
*
|
2009-11-04 03:47:50 +08:00
|
|
|
* Creates a fc_lport instance and a Scsi_Host instance and configure them.
|
2009-03-28 00:06:31 +08:00
|
|
|
*
|
2009-11-04 03:47:50 +08:00
|
|
|
* Returns: The allocated fc_lport or an error pointer
|
2009-03-28 00:06:31 +08:00
|
|
|
*/
|
2009-08-26 05:00:02 +08:00
|
|
|
static struct fc_lport *fcoe_if_create(struct fcoe_interface *fcoe,
|
2009-11-04 03:46:40 +08:00
|
|
|
struct device *parent, int npiv)
|
2009-03-28 00:06:31 +08:00
|
|
|
{
|
2012-05-23 10:06:10 +08:00
|
|
|
struct fcoe_ctlr *ctlr = fcoe_to_ctlr(fcoe);
|
2009-11-04 03:47:50 +08:00
|
|
|
struct net_device *netdev = fcoe->netdev;
|
2011-02-26 07:03:01 +08:00
|
|
|
struct fc_lport *lport, *n_port;
|
2009-08-26 04:59:30 +08:00
|
|
|
struct fcoe_port *port;
|
2011-02-26 07:03:01 +08:00
|
|
|
struct Scsi_Host *shost;
|
2009-11-04 03:47:50 +08:00
|
|
|
int rc;
|
2009-11-04 03:46:40 +08:00
|
|
|
/*
|
|
|
|
* parent is only a vport if npiv is 1,
|
|
|
|
* but we'll only use vport in that case so go ahead and set it
|
|
|
|
*/
|
|
|
|
struct fc_vport *vport = dev_to_vport(parent);
|
2009-03-28 00:06:31 +08:00
|
|
|
|
2009-06-11 06:30:59 +08:00
|
|
|
FCOE_NETDEV_DBG(netdev, "Create Interface\n");
|
2009-03-28 00:06:31 +08:00
|
|
|
|
2011-02-26 07:03:01 +08:00
|
|
|
if (!npiv)
|
|
|
|
lport = libfc_host_alloc(&fcoe_shost_template, sizeof(*port));
|
|
|
|
else
|
|
|
|
lport = libfc_vport_create(vport, sizeof(*port));
|
|
|
|
|
2009-11-04 03:46:08 +08:00
|
|
|
if (!lport) {
|
2009-06-11 06:30:59 +08:00
|
|
|
FCOE_NETDEV_DBG(netdev, "Could not allocate host structure\n");
|
2009-08-26 04:59:24 +08:00
|
|
|
rc = -ENOMEM;
|
2009-08-26 05:00:02 +08:00
|
|
|
goto out;
|
2009-03-28 00:06:31 +08:00
|
|
|
}
|
2009-08-26 04:59:30 +08:00
|
|
|
port = lport_priv(lport);
|
2009-08-26 05:00:23 +08:00
|
|
|
port->lport = lport;
|
2011-01-29 08:05:37 +08:00
|
|
|
port->priv = fcoe;
|
2012-12-06 14:23:43 +08:00
|
|
|
port->get_netdev = fcoe_netdev;
|
2011-01-29 08:05:37 +08:00
|
|
|
port->max_queue_depth = FCOE_MAX_QUEUE_DEPTH;
|
|
|
|
port->min_queue_depth = FCOE_MIN_QUEUE_DEPTH;
|
2009-08-26 05:00:23 +08:00
|
|
|
INIT_WORK(&port->destroy_work, fcoe_destroy_work);
|
2009-03-28 00:06:31 +08:00
|
|
|
|
2013-01-16 03:34:40 +08:00
|
|
|
/*
|
|
|
|
* Need to add the lport to the hostlist
|
|
|
|
* so we catch NETDEV_CHANGE events.
|
|
|
|
*/
|
|
|
|
fcoe_hostlist_add(lport);
|
|
|
|
|
2009-11-04 03:47:50 +08:00
|
|
|
/* configure a fc_lport including the exchange manager */
|
2009-08-26 04:59:24 +08:00
|
|
|
rc = fcoe_lport_config(lport);
|
2009-03-28 00:06:31 +08:00
|
|
|
if (rc) {
|
2009-06-11 06:30:59 +08:00
|
|
|
FCOE_NETDEV_DBG(netdev, "Could not configure lport for the "
|
|
|
|
"interface\n");
|
2009-03-28 00:06:31 +08:00
|
|
|
goto out_host_put;
|
|
|
|
}
|
|
|
|
|
2009-11-04 03:46:40 +08:00
|
|
|
if (npiv) {
|
2010-04-10 05:23:16 +08:00
|
|
|
FCOE_NETDEV_DBG(netdev, "Setting vport names, "
|
|
|
|
"%16.16llx %16.16llx\n",
|
2009-11-04 03:47:50 +08:00
|
|
|
vport->node_name, vport->port_name);
|
2009-11-04 03:46:40 +08:00
|
|
|
fc_set_wwnn(lport, vport->node_name);
|
|
|
|
fc_set_wwpn(lport, vport->port_name);
|
|
|
|
}
|
|
|
|
|
2009-05-17 20:33:08 +08:00
|
|
|
/* configure lport network properties */
|
2009-08-26 04:59:24 +08:00
|
|
|
rc = fcoe_netdev_config(lport, netdev);
|
2009-05-17 20:33:08 +08:00
|
|
|
if (rc) {
|
2009-06-11 06:30:59 +08:00
|
|
|
FCOE_NETDEV_DBG(netdev, "Could not configure netdev for the "
|
|
|
|
"interface\n");
|
2009-08-26 05:00:07 +08:00
|
|
|
goto out_lp_destroy;
|
2009-05-17 20:33:08 +08:00
|
|
|
}
|
2009-03-18 02:42:40 +08:00
|
|
|
|
2009-03-28 00:06:31 +08:00
|
|
|
/* configure lport scsi host properties */
|
2010-04-10 05:22:54 +08:00
|
|
|
rc = fcoe_shost_config(lport, parent);
|
2009-03-28 00:06:31 +08:00
|
|
|
if (rc) {
|
2009-06-11 06:30:59 +08:00
|
|
|
FCOE_NETDEV_DBG(netdev, "Could not configure shost for the "
|
|
|
|
"interface\n");
|
2009-08-26 05:00:07 +08:00
|
|
|
goto out_lp_destroy;
|
2009-03-28 00:06:31 +08:00
|
|
|
}
|
|
|
|
|
2009-07-30 08:05:00 +08:00
|
|
|
/* Initialize the library */
|
2012-05-23 10:06:10 +08:00
|
|
|
rc = fcoe_libfc_config(lport, ctlr, &fcoe_libfc_fcn_templ, 1);
|
2009-03-28 00:06:31 +08:00
|
|
|
if (rc) {
|
2009-07-30 08:05:00 +08:00
|
|
|
FCOE_NETDEV_DBG(netdev, "Could not configure libfc for the "
|
2009-06-11 06:30:59 +08:00
|
|
|
"interface\n");
|
2009-07-30 08:05:00 +08:00
|
|
|
goto out_lp_destroy;
|
2009-03-28 00:06:31 +08:00
|
|
|
}
|
|
|
|
|
2012-01-23 09:30:10 +08:00
|
|
|
/* Initialized FDMI information */
|
|
|
|
fcoe_fdmi_info(lport, netdev);
|
|
|
|
|
2011-02-26 07:03:01 +08:00
|
|
|
/*
|
|
|
|
* fcoe_em_alloc() and fcoe_hostlist_add() both
|
|
|
|
* need to be atomic with respect to other changes to the
|
|
|
|
* hostlist since fcoe_em_alloc() looks for an existing EM
|
|
|
|
* instance on host list updated by fcoe_hostlist_add().
|
|
|
|
*
|
|
|
|
* This is currently handled through the fcoe_config_mutex
|
|
|
|
* begin held.
|
|
|
|
*/
|
|
|
|
if (!npiv)
|
2009-11-04 03:46:40 +08:00
|
|
|
/* lport exch manager allocation */
|
|
|
|
rc = fcoe_em_config(lport);
|
2011-02-26 07:03:01 +08:00
|
|
|
else {
|
|
|
|
shost = vport_to_shost(vport);
|
|
|
|
n_port = shost_priv(shost);
|
|
|
|
rc = fc_exch_mgr_list_clone(n_port, lport);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rc) {
|
|
|
|
FCOE_NETDEV_DBG(netdev, "Could not configure the EM\n");
|
|
|
|
goto out_lp_destroy;
|
2009-03-28 00:06:31 +08:00
|
|
|
}
|
|
|
|
|
2009-08-26 04:59:24 +08:00
|
|
|
return lport;
|
2009-03-28 00:06:31 +08:00
|
|
|
|
|
|
|
out_lp_destroy:
|
2009-08-26 04:59:24 +08:00
|
|
|
fc_exch_mgr_free(lport);
|
2009-03-28 00:06:31 +08:00
|
|
|
out_host_put:
|
2013-01-16 03:34:40 +08:00
|
|
|
fcoe_hostlist_del(lport);
|
2009-08-26 04:59:24 +08:00
|
|
|
scsi_host_put(lport->host);
|
|
|
|
out:
|
|
|
|
return ERR_PTR(rc);
|
2009-03-28 00:06:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-11-04 03:47:50 +08:00
|
|
|
* fcoe_if_init() - Initialization routine for fcoe.ko
|
2009-03-28 00:06:31 +08:00
|
|
|
*
|
2009-11-04 03:47:50 +08:00
|
|
|
* Attaches the SW FCoE transport to the FC transport
|
|
|
|
*
|
|
|
|
* Returns: 0 on success
|
2009-03-28 00:06:31 +08:00
|
|
|
*/
|
|
|
|
static int __init fcoe_if_init(void)
|
|
|
|
{
|
|
|
|
/* attach to scsi transport */
|
2011-01-29 08:05:11 +08:00
|
|
|
fcoe_nport_scsi_transport =
|
|
|
|
fc_attach_transport(&fcoe_nport_fc_functions);
|
|
|
|
fcoe_vport_scsi_transport =
|
|
|
|
fc_attach_transport(&fcoe_vport_fc_functions);
|
2009-03-28 00:06:31 +08:00
|
|
|
|
2011-01-29 08:05:11 +08:00
|
|
|
if (!fcoe_nport_scsi_transport) {
|
2009-06-11 06:30:59 +08:00
|
|
|
printk(KERN_ERR "fcoe: Failed to attach to the FC transport\n");
|
2009-03-28 00:06:31 +08:00
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-11-04 03:47:50 +08:00
|
|
|
* fcoe_if_exit() - Tear down fcoe.ko
|
|
|
|
*
|
|
|
|
* Detaches the SW FCoE transport from the FC transport
|
2009-03-28 00:06:31 +08:00
|
|
|
*
|
2009-11-04 03:47:50 +08:00
|
|
|
* Returns: 0 on success
|
2009-03-28 00:06:31 +08:00
|
|
|
*/
|
2012-01-14 09:26:25 +08:00
|
|
|
static int __exit fcoe_if_exit(void)
|
2009-03-28 00:06:31 +08:00
|
|
|
{
|
2011-01-29 08:05:11 +08:00
|
|
|
fc_release_transport(fcoe_nport_scsi_transport);
|
|
|
|
fc_release_transport(fcoe_vport_scsi_transport);
|
|
|
|
fcoe_nport_scsi_transport = NULL;
|
|
|
|
fcoe_vport_scsi_transport = NULL;
|
2009-03-28 00:06:31 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-04-12 23:16:54 +08:00
|
|
|
static void fcoe_thread_cleanup_local(unsigned int cpu)
|
2009-03-18 02:41:46 +08:00
|
|
|
{
|
|
|
|
struct page *crc_eof;
|
2016-04-12 23:16:54 +08:00
|
|
|
struct fcoe_percpu_s *p;
|
2009-03-18 02:41:46 +08:00
|
|
|
|
2016-04-12 23:16:54 +08:00
|
|
|
p = per_cpu_ptr(&fcoe_percpu, cpu);
|
2009-03-18 02:41:46 +08:00
|
|
|
spin_lock_bh(&p->fcoe_rx_list.lock);
|
|
|
|
crc_eof = p->crc_eof_page;
|
|
|
|
p->crc_eof_page = NULL;
|
|
|
|
p->crc_eof_offset = 0;
|
|
|
|
spin_unlock_bh(&p->fcoe_rx_list.lock);
|
|
|
|
|
|
|
|
if (crc_eof)
|
|
|
|
put_page(crc_eof);
|
2016-04-12 23:16:54 +08:00
|
|
|
flush_work(&p->work);
|
2009-03-18 02:41:46 +08:00
|
|
|
}
|
|
|
|
|
2011-06-21 07:59:20 +08:00
|
|
|
/**
|
|
|
|
* fcoe_select_cpu() - Selects CPU to handle post-processing of incoming
|
|
|
|
* command.
|
|
|
|
*
|
2011-07-28 06:11:10 +08:00
|
|
|
* This routine selects next CPU based on cpumask to distribute
|
|
|
|
* incoming requests in round robin.
|
2011-06-21 07:59:20 +08:00
|
|
|
*
|
2011-07-28 06:11:10 +08:00
|
|
|
* Returns: int CPU number
|
2011-06-21 07:59:20 +08:00
|
|
|
*/
|
2011-07-28 06:11:10 +08:00
|
|
|
static inline unsigned int fcoe_select_cpu(void)
|
2011-06-21 07:59:20 +08:00
|
|
|
{
|
|
|
|
static unsigned int selected_cpu;
|
|
|
|
|
2011-07-28 06:11:10 +08:00
|
|
|
selected_cpu = cpumask_next(selected_cpu, cpu_online_mask);
|
|
|
|
if (selected_cpu >= nr_cpu_ids)
|
|
|
|
selected_cpu = cpumask_first(cpu_online_mask);
|
|
|
|
|
2011-06-21 07:59:20 +08:00
|
|
|
return selected_cpu;
|
|
|
|
}
|
|
|
|
|
2008-12-10 07:10:24 +08:00
|
|
|
/**
|
2009-11-04 03:47:50 +08:00
|
|
|
* fcoe_rcv() - Receive packets from a net device
|
|
|
|
* @skb: The received packet
|
|
|
|
* @netdev: The net device that the packet was received on
|
|
|
|
* @ptype: The packet type context
|
|
|
|
* @olddev: The last device net device
|
2008-12-10 07:10:24 +08:00
|
|
|
*
|
2009-11-04 03:47:50 +08:00
|
|
|
* This routine is called by NET_RX_SOFTIRQ. It receives a packet, builds a
|
|
|
|
* FC frame and passes the frame to libfc.
|
2008-12-10 07:10:24 +08:00
|
|
|
*
|
|
|
|
* Returns: 0 for success
|
2009-02-28 02:55:45 +08:00
|
|
|
*/
|
2012-01-14 09:26:25 +08:00
|
|
|
static int fcoe_rcv(struct sk_buff *skb, struct net_device *netdev,
|
2008-12-10 07:10:24 +08:00
|
|
|
struct packet_type *ptype, struct net_device *olddev)
|
|
|
|
{
|
2009-11-04 03:47:50 +08:00
|
|
|
struct fc_lport *lport;
|
2008-12-10 07:10:24 +08:00
|
|
|
struct fcoe_rcv_info *fr;
|
2012-05-23 10:06:10 +08:00
|
|
|
struct fcoe_ctlr *ctlr;
|
2009-08-26 04:59:41 +08:00
|
|
|
struct fcoe_interface *fcoe;
|
2008-12-10 07:10:24 +08:00
|
|
|
struct fc_frame_header *fh;
|
|
|
|
struct fcoe_percpu_s *fps;
|
2010-07-21 06:19:32 +08:00
|
|
|
struct ethhdr *eh;
|
[SCSI] fcoe, libfc: fully makes use of per cpu exch pool and then removes em_lock
1. Updates fcoe_rcv() to queue incoming frames to the fcoe per
cpu thread on which this frame's exch was originated and simply
use current cpu for request exch not originated by initiator.
It is redundant to add this code under CONFIG_SMP, so removes
CONFIG_SMP uses around this code.
2. Updates fc_exch_em_alloc, fc_exch_delete, fc_exch_find to use
per cpu exch pools, here fc_exch_delete is rename of older
fc_exch_mgr_delete_ep since ep/exch are now deleted in pools
of EM and so brief new name is sufficient and better name.
Updates these functions to map exch id to their index into exch
pool using fc_cpu_mask, fc_cpu_order and EM min_xid.
This mapping is as per detailed explanation about this in
last patch and basically this is just as lower fc_cpu_mask
bits of exch id as cpu number and upper bit sum of EM min_xid
and exch index in pool.
Uses pool next_index to keep track of exch allocation from
pool along with pool_max_index as upper bound of exches array
in pool.
3. Adds exch pool ptr to fc_exch to free exch to its pool in
fc_exch_delete.
4. Updates fc_exch_mgr_reset to reset all exch pools of an EM,
this required adding fc_exch_pool_reset func to reset exches
in pool and then have fc_exch_mgr_reset call fc_exch_pool_reset
for each pool within each EM for a lport.
5. Removes no longer needed exches array, em_lock, next_xid, and
total_exches from struct fc_exch_mgr, these are not needed after
use of per cpu exch pool, also removes not used max_read,
last_read from struct fc_exch_mgr.
6. Updates locking notes for exch pool lock with fc_exch lock and
uses pool lock in exch allocation, lookup and reset.
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@suse.de>
2009-08-26 04:58:53 +08:00
|
|
|
unsigned int cpu;
|
2008-12-10 07:10:24 +08:00
|
|
|
|
2009-08-26 04:59:41 +08:00
|
|
|
fcoe = container_of(ptype, struct fcoe_interface, fcoe_packet_type);
|
2012-05-23 10:06:10 +08:00
|
|
|
ctlr = fcoe_to_ctlr(fcoe);
|
|
|
|
lport = ctlr->lp;
|
2009-11-04 03:47:50 +08:00
|
|
|
if (unlikely(!lport)) {
|
2013-08-14 23:42:09 +08:00
|
|
|
FCOE_NETDEV_DBG(netdev, "Cannot find hba structure\n");
|
2008-12-10 07:10:24 +08:00
|
|
|
goto err2;
|
|
|
|
}
|
2009-11-04 03:47:50 +08:00
|
|
|
if (!lport->link_up)
|
2009-03-18 02:42:40 +08:00
|
|
|
goto err2;
|
2008-12-10 07:10:24 +08:00
|
|
|
|
2013-08-14 23:42:09 +08:00
|
|
|
FCOE_NETDEV_DBG(netdev,
|
|
|
|
"skb_info: len:%d data_len:%d head:%p data:%p tail:%p end:%p sum:%d dev:%s\n",
|
2009-06-11 06:30:59 +08:00
|
|
|
skb->len, skb->data_len, skb->head, skb->data,
|
|
|
|
skb_tail_pointer(skb), skb_end_pointer(skb),
|
|
|
|
skb->csum, skb->dev ? skb->dev->name : "<NULL>");
|
2008-12-10 07:10:24 +08:00
|
|
|
|
2013-08-03 18:45:54 +08:00
|
|
|
|
|
|
|
skb = skb_share_check(skb, GFP_ATOMIC);
|
|
|
|
|
|
|
|
if (skb == NULL)
|
|
|
|
return NET_RX_DROP;
|
|
|
|
|
2010-07-21 06:19:32 +08:00
|
|
|
eh = eth_hdr(skb);
|
|
|
|
|
2012-05-23 10:06:10 +08:00
|
|
|
if (is_fip_mode(ctlr) &&
|
scsi: Convert uses of compare_ether_addr to ether_addr_equal
Preliminary to removing compare_ether_addr altogether:
Use the new bool function ether_addr_equal to add
some clarity and reduce the likelihood for misuse
of compare_ether_addr for sorting.
Done via cocci script:
$ cat compare_ether_addr.cocci
@@
expression a,b;
@@
- !compare_ether_addr(a, b)
+ ether_addr_equal(a, b)
@@
expression a,b;
@@
- compare_ether_addr(a, b)
+ !ether_addr_equal(a, b)
@@
expression a,b;
@@
- !ether_addr_equal(a, b) == 0
+ ether_addr_equal(a, b)
@@
expression a,b;
@@
- !ether_addr_equal(a, b) != 0
+ !ether_addr_equal(a, b)
@@
expression a,b;
@@
- ether_addr_equal(a, b) == 0
+ !ether_addr_equal(a, b)
@@
expression a,b;
@@
- ether_addr_equal(a, b) != 0
+ ether_addr_equal(a, b)
@@
expression a,b;
@@
- !!ether_addr_equal(a, b)
+ ether_addr_equal(a, b)
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
2013-09-02 11:32:33 +08:00
|
|
|
!ether_addr_equal(eh->h_source, ctlr->dest_addr)) {
|
2010-07-21 06:19:32 +08:00
|
|
|
FCOE_NETDEV_DBG(netdev, "wrong source mac address:%pM\n",
|
|
|
|
eh->h_source);
|
2008-12-10 07:10:24 +08:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check for minimum frame length, and make sure required FCoE
|
|
|
|
* and FC headers are pulled into the linear data area.
|
|
|
|
*/
|
|
|
|
if (unlikely((skb->len < FCOE_MIN_FRAME) ||
|
2009-11-04 03:47:50 +08:00
|
|
|
!pskb_may_pull(skb, FCOE_HEADER_LEN)))
|
2008-12-10 07:10:24 +08:00
|
|
|
goto err;
|
|
|
|
|
|
|
|
skb_set_transport_header(skb, sizeof(struct fcoe_hdr));
|
|
|
|
fh = (struct fc_frame_header *) skb_transport_header(skb);
|
|
|
|
|
[SCSI] fcoe: Fix broken NPIV with correction to MAC validation
A previous patch attempted to validate the destination
MAC address of a FCoE frame by checking that MAC
address against the received port's MAC address. The
implementation seems fine on the surface, but any
VN_Ports added using the NPIV feature will have their
own MAC addresses and these MACs were not being checked,
which prevented any NPIV VN_Ports from receiving frames.
In other words, the following patch has broken NPIV.
519e5135e2537c9dbc1cbcc0891b0a936ff5dcd2
[SCSI] fcoe: adds src and dest mac address
checking for fcoe frames
Part of the offending patch is correct, but the part
that broke NPIV was attempting to satisfy FC-BB-5
section D.5, 2.1-
(discard frames that) "contain a destination MAC
address/destination N_Port_ID pair that was not
assigned by an FCF to one of the VN_Ports on the ENode"
The language does _not_ say to compare the destination
FC-MAP/destination N_Port_ID, but instead to compare
the destination MAC address/destination N_Port_ID.
>From the FC-BB-5 specification,
"A properly formed FPMA is one in which the 24 most
significant bits equal the Fabric’s FC-MAP value and
the least significant 24 bits equal the N_Port_ID
assigned to the VN_Port by the FCF."
This means that we need to compare the FC Frame's
destination FCID against the embedded FCID in the
destination MAC address. This patch checks the lower
24 bits of the destination MAC address against
destination FCID in the Fibre Channel frame.
For MAC validation the first line of defense is the
hardware MAC filtering. Each VN_Port will have a
unicast MAC addresses added to the hardware's
filtering table. The Ethernet driver should drop any
MACs not destined for a programmed MAC. This patch
adds a second line of defense that very specfically
compares an element in the FC frame against an element
in the Ethernet header, which is appropriate for the
FCoE layer.
Many alternative approaches were considered, including
a LLD callback from libfc. The second most reasonable
approach seemed to be walking the list of NPIV ports
and check each of their MAC addresses against the
destination MAC address of the received frame. The
problem with this approach was that it is likely that
performance would suffer with the more NPIV ports added
to the system since every received frame would need to
walk this list, comparing each entry's MAC.
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2010-10-09 08:12:46 +08:00
|
|
|
if (ntoh24(&eh->h_dest[3]) != ntoh24(fh->fh_d_id)) {
|
|
|
|
FCOE_NETDEV_DBG(netdev, "FC frame d_id mismatch with MAC:%pM\n",
|
|
|
|
eh->h_dest);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2008-12-10 07:10:24 +08:00
|
|
|
fr = fcoe_dev_from_skb(skb);
|
2009-11-04 03:47:50 +08:00
|
|
|
fr->fr_dev = lport;
|
2009-03-18 02:41:35 +08:00
|
|
|
|
2008-12-10 07:10:24 +08:00
|
|
|
/*
|
[SCSI] fcoe, libfc: fully makes use of per cpu exch pool and then removes em_lock
1. Updates fcoe_rcv() to queue incoming frames to the fcoe per
cpu thread on which this frame's exch was originated and simply
use current cpu for request exch not originated by initiator.
It is redundant to add this code under CONFIG_SMP, so removes
CONFIG_SMP uses around this code.
2. Updates fc_exch_em_alloc, fc_exch_delete, fc_exch_find to use
per cpu exch pools, here fc_exch_delete is rename of older
fc_exch_mgr_delete_ep since ep/exch are now deleted in pools
of EM and so brief new name is sufficient and better name.
Updates these functions to map exch id to their index into exch
pool using fc_cpu_mask, fc_cpu_order and EM min_xid.
This mapping is as per detailed explanation about this in
last patch and basically this is just as lower fc_cpu_mask
bits of exch id as cpu number and upper bit sum of EM min_xid
and exch index in pool.
Uses pool next_index to keep track of exch allocation from
pool along with pool_max_index as upper bound of exches array
in pool.
3. Adds exch pool ptr to fc_exch to free exch to its pool in
fc_exch_delete.
4. Updates fc_exch_mgr_reset to reset all exch pools of an EM,
this required adding fc_exch_pool_reset func to reset exches
in pool and then have fc_exch_mgr_reset call fc_exch_pool_reset
for each pool within each EM for a lport.
5. Removes no longer needed exches array, em_lock, next_xid, and
total_exches from struct fc_exch_mgr, these are not needed after
use of per cpu exch pool, also removes not used max_read,
last_read from struct fc_exch_mgr.
6. Updates locking notes for exch pool lock with fc_exch lock and
uses pool lock in exch allocation, lookup and reset.
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@suse.de>
2009-08-26 04:58:53 +08:00
|
|
|
* In case the incoming frame's exchange is originated from
|
|
|
|
* the initiator, then received frame's exchange id is ANDed
|
|
|
|
* with fc_cpu_mask bits to get the same cpu on which exchange
|
2011-07-28 06:11:10 +08:00
|
|
|
* was originated, otherwise select cpu using rx exchange id
|
|
|
|
* or fcoe_select_cpu().
|
2008-12-10 07:10:24 +08:00
|
|
|
*/
|
[SCSI] fcoe, libfc: fully makes use of per cpu exch pool and then removes em_lock
1. Updates fcoe_rcv() to queue incoming frames to the fcoe per
cpu thread on which this frame's exch was originated and simply
use current cpu for request exch not originated by initiator.
It is redundant to add this code under CONFIG_SMP, so removes
CONFIG_SMP uses around this code.
2. Updates fc_exch_em_alloc, fc_exch_delete, fc_exch_find to use
per cpu exch pools, here fc_exch_delete is rename of older
fc_exch_mgr_delete_ep since ep/exch are now deleted in pools
of EM and so brief new name is sufficient and better name.
Updates these functions to map exch id to their index into exch
pool using fc_cpu_mask, fc_cpu_order and EM min_xid.
This mapping is as per detailed explanation about this in
last patch and basically this is just as lower fc_cpu_mask
bits of exch id as cpu number and upper bit sum of EM min_xid
and exch index in pool.
Uses pool next_index to keep track of exch allocation from
pool along with pool_max_index as upper bound of exches array
in pool.
3. Adds exch pool ptr to fc_exch to free exch to its pool in
fc_exch_delete.
4. Updates fc_exch_mgr_reset to reset all exch pools of an EM,
this required adding fc_exch_pool_reset func to reset exches
in pool and then have fc_exch_mgr_reset call fc_exch_pool_reset
for each pool within each EM for a lport.
5. Removes no longer needed exches array, em_lock, next_xid, and
total_exches from struct fc_exch_mgr, these are not needed after
use of per cpu exch pool, also removes not used max_read,
last_read from struct fc_exch_mgr.
6. Updates locking notes for exch pool lock with fc_exch lock and
uses pool lock in exch allocation, lookup and reset.
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@suse.de>
2009-08-26 04:58:53 +08:00
|
|
|
if (ntoh24(fh->fh_f_ctl) & FC_FC_EX_CTX)
|
|
|
|
cpu = ntohs(fh->fh_ox_id) & fc_cpu_mask;
|
2011-06-21 07:59:20 +08:00
|
|
|
else {
|
2011-07-28 06:11:10 +08:00
|
|
|
if (ntohs(fh->fh_rx_id) == FC_XID_UNKNOWN)
|
|
|
|
cpu = fcoe_select_cpu();
|
|
|
|
else
|
2011-06-21 07:59:25 +08:00
|
|
|
cpu = ntohs(fh->fh_rx_id) & fc_cpu_mask;
|
2011-06-21 07:59:20 +08:00
|
|
|
}
|
2011-07-28 06:10:39 +08:00
|
|
|
|
|
|
|
if (cpu >= nr_cpu_ids)
|
|
|
|
goto err;
|
|
|
|
|
2009-03-18 02:41:46 +08:00
|
|
|
fps = &per_cpu(fcoe_percpu, cpu);
|
2012-03-10 06:50:08 +08:00
|
|
|
spin_lock(&fps->fcoe_rx_list.lock);
|
2009-03-18 02:41:46 +08:00
|
|
|
/*
|
|
|
|
* We now have a valid CPU that we're targeting for
|
|
|
|
* this skb. We also have this receive thread locked,
|
|
|
|
* so we're free to queue skbs into it's queue.
|
|
|
|
*/
|
2008-12-10 07:10:24 +08:00
|
|
|
|
[SCSI] fcoe: Ensure fcoe_recv_frame is always called in process context
commit 859b7b649ab58ee5cbfb761491317d5b315c1b0f introduced the ability to call
fcoe_recv_frame in softirq context. While this is beneficial to performance,
its not safe to do, as it breaks the serialization of access to the lport
structure (i.e. when an fcoe interface is being torn down, theres no way to
serialize the teardown effort with the completion of receieve operations
occuring in softirq context. As a result, lport (and other) data structures can
be read and modified in parallel leading to corruption. Most notable is the
vport list, which is protected by a mutex, that will cause a panic if a softirq
receive while said mutex is locked. Additionaly, the ema_list, discussed here:
http://lists.open-fcoe.org/pipermail/devel/2012-February/011947.html
Can be corrupted if a list traversal occurs in softirq context at the same time
as a list delete in process context. And generally the lport state variables
will not be stable, and may lead to unpredictable results.
The most direct fix is to remove the bits from the above commit that allowed
fcoe_recv_frame to be called in softirq context. We just force all frames to be
handled by the per-cpu rx threads. This will allow the fcoe_if_destroy's use of
fcoe_percpu_clean to function properly, ensuring that no frames are being
received while the lport is being torn down.
Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Reviewed-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2012-03-10 06:49:48 +08:00
|
|
|
/*
|
|
|
|
* Note: We used to have a set of conditions under which we would
|
|
|
|
* call fcoe_recv_frame directly, rather than queuing to the rx list
|
|
|
|
* as it could save a few cycles, but doing so is prohibited, as
|
|
|
|
* fcoe_recv_frame has several paths that may sleep, which is forbidden
|
|
|
|
* in softirq context.
|
2009-11-21 06:54:47 +08:00
|
|
|
*/
|
[SCSI] fcoe: Ensure fcoe_recv_frame is always called in process context
commit 859b7b649ab58ee5cbfb761491317d5b315c1b0f introduced the ability to call
fcoe_recv_frame in softirq context. While this is beneficial to performance,
its not safe to do, as it breaks the serialization of access to the lport
structure (i.e. when an fcoe interface is being torn down, theres no way to
serialize the teardown effort with the completion of receieve operations
occuring in softirq context. As a result, lport (and other) data structures can
be read and modified in parallel leading to corruption. Most notable is the
vport list, which is protected by a mutex, that will cause a panic if a softirq
receive while said mutex is locked. Additionaly, the ema_list, discussed here:
http://lists.open-fcoe.org/pipermail/devel/2012-February/011947.html
Can be corrupted if a list traversal occurs in softirq context at the same time
as a list delete in process context. And generally the lport state variables
will not be stable, and may lead to unpredictable results.
The most direct fix is to remove the bits from the above commit that allowed
fcoe_recv_frame to be called in softirq context. We just force all frames to be
handled by the per-cpu rx threads. This will allow the fcoe_if_destroy's use of
fcoe_percpu_clean to function properly, ensuring that no frames are being
received while the lport is being torn down.
Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Reviewed-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2012-03-10 06:49:48 +08:00
|
|
|
__skb_queue_tail(&fps->fcoe_rx_list, skb);
|
2016-04-12 23:16:54 +08:00
|
|
|
schedule_work_on(cpu, &fps->work);
|
2012-03-10 06:50:08 +08:00
|
|
|
spin_unlock(&fps->fcoe_rx_list.lock);
|
2008-12-10 07:10:24 +08:00
|
|
|
|
2013-08-03 18:45:55 +08:00
|
|
|
return NET_RX_SUCCESS;
|
2008-12-10 07:10:24 +08:00
|
|
|
err:
|
2012-05-26 01:26:43 +08:00
|
|
|
per_cpu_ptr(lport->stats, get_cpu())->ErrorFrames++;
|
2010-03-13 08:08:55 +08:00
|
|
|
put_cpu();
|
2008-12-10 07:10:24 +08:00
|
|
|
err2:
|
|
|
|
kfree_skb(skb);
|
2013-08-03 18:45:55 +08:00
|
|
|
return NET_RX_DROP;
|
2008-12-10 07:10:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-01-29 08:05:37 +08:00
|
|
|
* fcoe_alloc_paged_crc_eof() - Allocate a page to be used for the trailer CRC
|
2009-11-04 03:47:50 +08:00
|
|
|
* @skb: The packet to be transmitted
|
|
|
|
* @tlen: The total length of the trailer
|
|
|
|
*
|
2008-12-10 07:10:24 +08:00
|
|
|
* Returns: 0 for success
|
2009-02-28 02:55:45 +08:00
|
|
|
*/
|
2011-01-29 08:05:37 +08:00
|
|
|
static int fcoe_alloc_paged_crc_eof(struct sk_buff *skb, int tlen)
|
2008-12-10 07:10:24 +08:00
|
|
|
{
|
|
|
|
struct fcoe_percpu_s *fps;
|
2011-01-29 08:05:37 +08:00
|
|
|
int rc;
|
2008-12-10 07:10:24 +08:00
|
|
|
|
2009-03-18 02:41:35 +08:00
|
|
|
fps = &get_cpu_var(fcoe_percpu);
|
2011-01-29 08:05:37 +08:00
|
|
|
rc = fcoe_get_paged_crc_eof(skb, tlen, fps);
|
2009-03-18 02:41:35 +08:00
|
|
|
put_cpu_var(fcoe_percpu);
|
2008-12-10 07:10:24 +08:00
|
|
|
|
2011-01-29 08:05:37 +08:00
|
|
|
return rc;
|
2008-12-10 07:10:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-11-04 03:47:50 +08:00
|
|
|
* fcoe_xmit() - Transmit a FCoE frame
|
|
|
|
* @lport: The local port that the frame is to be transmitted for
|
|
|
|
* @fp: The frame to be transmitted
|
2008-12-10 07:10:24 +08:00
|
|
|
*
|
2009-11-04 03:47:50 +08:00
|
|
|
* Return: 0 for success
|
2009-02-28 02:55:45 +08:00
|
|
|
*/
|
2012-01-14 09:26:25 +08:00
|
|
|
static int fcoe_xmit(struct fc_lport *lport, struct fc_frame *fp)
|
2008-12-10 07:10:24 +08:00
|
|
|
{
|
2009-05-07 01:52:34 +08:00
|
|
|
int wlen;
|
2008-12-10 07:10:24 +08:00
|
|
|
u32 crc;
|
|
|
|
struct ethhdr *eh;
|
|
|
|
struct fcoe_crc_eof *cp;
|
|
|
|
struct sk_buff *skb;
|
2012-05-26 01:26:43 +08:00
|
|
|
struct fc_stats *stats;
|
2008-12-10 07:10:24 +08:00
|
|
|
struct fc_frame_header *fh;
|
|
|
|
unsigned int hlen; /* header length implies the version */
|
|
|
|
unsigned int tlen; /* trailer length */
|
|
|
|
unsigned int elen; /* eth header, may include vlan */
|
2009-11-04 03:47:50 +08:00
|
|
|
struct fcoe_port *port = lport_priv(lport);
|
2011-01-29 08:05:37 +08:00
|
|
|
struct fcoe_interface *fcoe = port->priv;
|
2012-05-23 10:06:10 +08:00
|
|
|
struct fcoe_ctlr *ctlr = fcoe_to_ctlr(fcoe);
|
2008-12-10 07:10:24 +08:00
|
|
|
u8 sof, eof;
|
|
|
|
struct fcoe_hdr *hp;
|
|
|
|
|
|
|
|
WARN_ON((fr_len(fp) % sizeof(u32)) != 0);
|
|
|
|
|
|
|
|
fh = fc_frame_header_get(fp);
|
2009-03-18 02:42:40 +08:00
|
|
|
skb = fp_skb(fp);
|
|
|
|
wlen = skb->len / FCOE_WORD_TO_BYTE;
|
|
|
|
|
2009-11-04 03:47:50 +08:00
|
|
|
if (!lport->link_up) {
|
2009-04-22 07:27:25 +08:00
|
|
|
kfree_skb(skb);
|
2009-03-18 02:42:40 +08:00
|
|
|
return 0;
|
2008-12-10 07:10:24 +08:00
|
|
|
}
|
|
|
|
|
2010-03-13 08:07:52 +08:00
|
|
|
if (unlikely(fh->fh_type == FC_TYPE_ELS) &&
|
2012-05-23 10:06:10 +08:00
|
|
|
fcoe_ctlr_els_send(ctlr, lport, skb))
|
2009-03-18 02:42:40 +08:00
|
|
|
return 0;
|
|
|
|
|
2008-12-10 07:10:24 +08:00
|
|
|
sof = fr_sof(fp);
|
|
|
|
eof = fr_eof(fp);
|
|
|
|
|
2009-05-07 01:52:46 +08:00
|
|
|
elen = sizeof(struct ethhdr);
|
2008-12-10 07:10:24 +08:00
|
|
|
hlen = sizeof(struct fcoe_hdr);
|
|
|
|
tlen = sizeof(struct fcoe_crc_eof);
|
|
|
|
wlen = (skb->len - tlen + sizeof(crc)) / FCOE_WORD_TO_BYTE;
|
|
|
|
|
|
|
|
/* crc offload */
|
2009-11-04 03:47:50 +08:00
|
|
|
if (likely(lport->crc_offload)) {
|
2015-12-15 03:19:42 +08:00
|
|
|
skb->ip_summed = CHECKSUM_PARTIAL;
|
2008-12-10 07:10:24 +08:00
|
|
|
skb->csum_start = skb_headroom(skb);
|
|
|
|
skb->csum_offset = skb->len;
|
|
|
|
crc = 0;
|
|
|
|
} else {
|
|
|
|
skb->ip_summed = CHECKSUM_NONE;
|
|
|
|
crc = fcoe_fc_crc(fp);
|
|
|
|
}
|
|
|
|
|
2009-08-26 04:59:30 +08:00
|
|
|
/* copy port crc and eof to the skb buff */
|
2008-12-10 07:10:24 +08:00
|
|
|
if (skb_is_nonlinear(skb)) {
|
|
|
|
skb_frag_t *frag;
|
2011-01-29 08:05:37 +08:00
|
|
|
if (fcoe_alloc_paged_crc_eof(skb, tlen)) {
|
2009-02-28 02:56:22 +08:00
|
|
|
kfree_skb(skb);
|
2008-12-10 07:10:24 +08:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
frag = &skb_shinfo(skb)->frags[skb_shinfo(skb)->nr_frags - 1];
|
2011-11-25 23:14:23 +08:00
|
|
|
cp = kmap_atomic(skb_frag_page(frag))
|
2008-12-10 07:10:24 +08:00
|
|
|
+ frag->page_offset;
|
|
|
|
} else {
|
|
|
|
cp = (struct fcoe_crc_eof *)skb_put(skb, tlen);
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(cp, 0, sizeof(*cp));
|
|
|
|
cp->fcoe_eof = eof;
|
|
|
|
cp->fcoe_crc32 = cpu_to_le32(~crc);
|
|
|
|
|
|
|
|
if (skb_is_nonlinear(skb)) {
|
2011-11-25 23:14:23 +08:00
|
|
|
kunmap_atomic(cp);
|
2008-12-10 07:10:24 +08:00
|
|
|
cp = NULL;
|
|
|
|
}
|
|
|
|
|
2009-08-26 04:59:30 +08:00
|
|
|
/* adjust skb network/transport offsets to match mac/fcoe/port */
|
2008-12-10 07:10:24 +08:00
|
|
|
skb_push(skb, elen + hlen);
|
|
|
|
skb_reset_mac_header(skb);
|
|
|
|
skb_reset_network_header(skb);
|
|
|
|
skb->mac_len = elen;
|
2009-02-28 06:06:37 +08:00
|
|
|
skb->protocol = htons(ETH_P_FCOE);
|
2012-09-25 02:52:45 +08:00
|
|
|
skb->priority = fcoe->priority;
|
2011-11-19 05:35:56 +08:00
|
|
|
|
2011-09-28 12:38:13 +08:00
|
|
|
if (fcoe->netdev->priv_flags & IFF_802_1Q_VLAN &&
|
2013-04-19 10:04:27 +08:00
|
|
|
fcoe->realdev->features & NETIF_F_HW_VLAN_CTAG_TX) {
|
2013-06-19 09:56:54 +08:00
|
|
|
/* must set skb->dev before calling vlan_put_tag */
|
2011-09-28 12:38:13 +08:00
|
|
|
skb->dev = fcoe->realdev;
|
2014-11-19 21:04:56 +08:00
|
|
|
__vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q),
|
|
|
|
vlan_dev_vlan_id(fcoe->netdev));
|
2011-09-28 12:38:13 +08:00
|
|
|
} else
|
|
|
|
skb->dev = fcoe->netdev;
|
2008-12-10 07:10:24 +08:00
|
|
|
|
|
|
|
/* fill up mac and fcoe headers */
|
|
|
|
eh = eth_hdr(skb);
|
|
|
|
eh->h_proto = htons(ETH_P_FCOE);
|
2012-05-23 10:06:10 +08:00
|
|
|
memcpy(eh->h_dest, ctlr->dest_addr, ETH_ALEN);
|
|
|
|
if (ctlr->map_dest)
|
2010-07-21 06:20:40 +08:00
|
|
|
memcpy(eh->h_dest + 3, fh->fh_d_id, 3);
|
2008-12-10 07:10:24 +08:00
|
|
|
|
2012-05-23 10:06:10 +08:00
|
|
|
if (unlikely(ctlr->flogi_oxid != FC_XID_UNKNOWN))
|
|
|
|
memcpy(eh->h_source, ctlr->ctl_src_addr, ETH_ALEN);
|
2008-12-10 07:10:24 +08:00
|
|
|
else
|
2009-11-04 03:46:29 +08:00
|
|
|
memcpy(eh->h_source, port->data_src_addr, ETH_ALEN);
|
2008-12-10 07:10:24 +08:00
|
|
|
|
|
|
|
hp = (struct fcoe_hdr *)(eh + 1);
|
|
|
|
memset(hp, 0, sizeof(*hp));
|
|
|
|
if (FC_FCOE_VER)
|
|
|
|
FC_FCOE_ENCAPS_VER(hp, FC_FCOE_VER);
|
|
|
|
hp->fcoe_sof = sof;
|
|
|
|
|
2009-02-28 06:07:15 +08:00
|
|
|
/* fcoe lso, mss is in max_payload which is non-zero for FCP data */
|
2009-11-04 03:47:50 +08:00
|
|
|
if (lport->seq_offload && fr_max_payload(fp)) {
|
2009-02-28 06:07:15 +08:00
|
|
|
skb_shinfo(skb)->gso_type = SKB_GSO_FCOE;
|
|
|
|
skb_shinfo(skb)->gso_size = fr_max_payload(fp);
|
|
|
|
} else {
|
|
|
|
skb_shinfo(skb)->gso_type = 0;
|
|
|
|
skb_shinfo(skb)->gso_size = 0;
|
|
|
|
}
|
2008-12-10 07:10:24 +08:00
|
|
|
/* update tx stats: regardless if LLD fails */
|
2012-05-26 01:26:43 +08:00
|
|
|
stats = per_cpu_ptr(lport->stats, get_cpu());
|
2009-04-01 06:51:50 +08:00
|
|
|
stats->TxFrames++;
|
|
|
|
stats->TxWords += wlen;
|
2010-03-13 08:08:55 +08:00
|
|
|
put_cpu();
|
2008-12-10 07:10:24 +08:00
|
|
|
|
|
|
|
/* send down to lld */
|
2009-11-04 03:47:50 +08:00
|
|
|
fr_dev(fp) = lport;
|
2011-07-28 06:11:05 +08:00
|
|
|
fcoe_port_send(port, skb);
|
2008-12-10 07:10:24 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-01-29 08:03:52 +08:00
|
|
|
/**
|
|
|
|
* fcoe_filter_frames() - filter out bad fcoe frames, i.e. bad CRC
|
|
|
|
* @lport: The local port the frame was received on
|
|
|
|
* @fp: The received frame
|
|
|
|
*
|
|
|
|
* Return: 0 on passing filtering checks
|
|
|
|
*/
|
|
|
|
static inline int fcoe_filter_frames(struct fc_lport *lport,
|
|
|
|
struct fc_frame *fp)
|
|
|
|
{
|
2012-05-23 10:06:10 +08:00
|
|
|
struct fcoe_ctlr *ctlr;
|
2011-01-29 08:03:52 +08:00
|
|
|
struct fcoe_interface *fcoe;
|
|
|
|
struct fc_frame_header *fh;
|
|
|
|
struct sk_buff *skb = (struct sk_buff *)fp;
|
2012-05-26 01:26:43 +08:00
|
|
|
struct fc_stats *stats;
|
2011-01-29 08:03:52 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We only check CRC if no offload is available and if it is
|
|
|
|
* it's solicited data, in which case, the FCP layer would
|
|
|
|
* check it during the copy.
|
|
|
|
*/
|
|
|
|
if (lport->crc_offload && skb->ip_summed == CHECKSUM_UNNECESSARY)
|
|
|
|
fr_flags(fp) &= ~FCPHF_CRC_UNCHECKED;
|
|
|
|
else
|
|
|
|
fr_flags(fp) |= FCPHF_CRC_UNCHECKED;
|
|
|
|
|
|
|
|
fh = (struct fc_frame_header *) skb_transport_header(skb);
|
|
|
|
fh = fc_frame_header_get(fp);
|
|
|
|
if (fh->fh_r_ctl == FC_RCTL_DD_SOL_DATA && fh->fh_type == FC_TYPE_FCP)
|
|
|
|
return 0;
|
|
|
|
|
2011-01-29 08:05:37 +08:00
|
|
|
fcoe = ((struct fcoe_port *)lport_priv(lport))->priv;
|
2012-05-23 10:06:10 +08:00
|
|
|
ctlr = fcoe_to_ctlr(fcoe);
|
|
|
|
if (is_fip_mode(ctlr) && fc_frame_payload_op(fp) == ELS_LOGO &&
|
2011-01-29 08:03:52 +08:00
|
|
|
ntoh24(fh->fh_s_id) == FC_FID_FLOGI) {
|
|
|
|
FCOE_DBG("fcoe: dropping FCoE lport LOGO in fip mode\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2011-02-26 07:03:23 +08:00
|
|
|
if (!(fr_flags(fp) & FCPHF_CRC_UNCHECKED) ||
|
2011-01-29 08:03:52 +08:00
|
|
|
le32_to_cpu(fr_crc(fp)) == ~crc32(~0, skb->data, skb->len)) {
|
|
|
|
fr_flags(fp) &= ~FCPHF_CRC_UNCHECKED;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-05-26 01:26:43 +08:00
|
|
|
stats = per_cpu_ptr(lport->stats, get_cpu());
|
2011-01-29 08:03:52 +08:00
|
|
|
stats->InvalidCRCCount++;
|
|
|
|
if (stats->InvalidCRCCount < 5)
|
|
|
|
printk(KERN_WARNING "fcoe: dropping frame with CRC error\n");
|
2011-11-12 03:52:01 +08:00
|
|
|
put_cpu();
|
2011-01-29 08:03:52 +08:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2009-02-28 02:55:45 +08:00
|
|
|
/**
|
2009-11-21 06:54:47 +08:00
|
|
|
* fcoe_recv_frame() - process a single received frame
|
|
|
|
* @skb: frame to process
|
2008-12-10 07:10:24 +08:00
|
|
|
*/
|
2009-11-21 06:54:47 +08:00
|
|
|
static void fcoe_recv_frame(struct sk_buff *skb)
|
2008-12-10 07:10:24 +08:00
|
|
|
{
|
|
|
|
u32 fr_len;
|
2009-11-04 03:47:50 +08:00
|
|
|
struct fc_lport *lport;
|
2008-12-10 07:10:24 +08:00
|
|
|
struct fcoe_rcv_info *fr;
|
2012-05-26 01:26:43 +08:00
|
|
|
struct fc_stats *stats;
|
2008-12-10 07:10:24 +08:00
|
|
|
struct fcoe_crc_eof crc_eof;
|
|
|
|
struct fc_frame *fp;
|
2009-08-26 04:59:30 +08:00
|
|
|
struct fcoe_port *port;
|
2008-12-10 07:10:24 +08:00
|
|
|
struct fcoe_hdr *hp;
|
|
|
|
|
2009-11-21 06:54:47 +08:00
|
|
|
fr = fcoe_dev_from_skb(skb);
|
|
|
|
lport = fr->fr_dev;
|
|
|
|
if (unlikely(!lport)) {
|
2016-04-12 23:16:54 +08:00
|
|
|
FCOE_NETDEV_DBG(skb->dev, "NULL lport in skb\n");
|
2009-11-21 06:54:47 +08:00
|
|
|
kfree_skb(skb);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-08-14 23:42:09 +08:00
|
|
|
FCOE_NETDEV_DBG(skb->dev,
|
|
|
|
"skb_info: len:%d data_len:%d head:%p data:%p tail:%p end:%p sum:%d dev:%s\n",
|
2009-11-21 06:54:47 +08:00
|
|
|
skb->len, skb->data_len,
|
|
|
|
skb->head, skb->data, skb_tail_pointer(skb),
|
|
|
|
skb_end_pointer(skb), skb->csum,
|
|
|
|
skb->dev ? skb->dev->name : "<NULL>");
|
|
|
|
|
|
|
|
port = lport_priv(lport);
|
2011-12-17 06:24:49 +08:00
|
|
|
skb_linearize(skb); /* check for skb_is_nonlinear is within skb_linearize */
|
2009-11-21 06:54:47 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Frame length checks and setting up the header pointers
|
|
|
|
* was done in fcoe_rcv already.
|
|
|
|
*/
|
|
|
|
hp = (struct fcoe_hdr *) skb_network_header(skb);
|
|
|
|
|
2012-05-26 01:26:43 +08:00
|
|
|
stats = per_cpu_ptr(lport->stats, get_cpu());
|
2009-11-21 06:54:47 +08:00
|
|
|
if (unlikely(FC_FCOE_DECAPS_VER(hp) != FC_FCOE_VER)) {
|
|
|
|
if (stats->ErrorFrames < 5)
|
|
|
|
printk(KERN_WARNING "fcoe: FCoE version "
|
|
|
|
"mismatch: The frame has "
|
|
|
|
"version %x, but the "
|
|
|
|
"initiator supports version "
|
|
|
|
"%x\n", FC_FCOE_DECAPS_VER(hp),
|
|
|
|
FC_FCOE_VER);
|
2010-03-13 08:08:55 +08:00
|
|
|
goto drop;
|
2009-11-21 06:54:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
skb_pull(skb, sizeof(struct fcoe_hdr));
|
|
|
|
fr_len = skb->len - sizeof(struct fcoe_crc_eof);
|
|
|
|
|
|
|
|
stats->RxFrames++;
|
|
|
|
stats->RxWords += fr_len / FCOE_WORD_TO_BYTE;
|
|
|
|
|
|
|
|
fp = (struct fc_frame *)skb;
|
|
|
|
fc_frame_init(fp);
|
|
|
|
fr_dev(fp) = lport;
|
|
|
|
fr_sof(fp) = hp->fcoe_sof;
|
|
|
|
|
|
|
|
/* Copy out the CRC and EOF trailer for access */
|
2010-03-13 08:08:55 +08:00
|
|
|
if (skb_copy_bits(skb, fr_len, &crc_eof, sizeof(crc_eof)))
|
|
|
|
goto drop;
|
2009-11-21 06:54:47 +08:00
|
|
|
fr_eof(fp) = crc_eof.fcoe_eof;
|
|
|
|
fr_crc(fp) = crc_eof.fcoe_crc32;
|
2010-03-13 08:08:55 +08:00
|
|
|
if (pskb_trim(skb, fr_len))
|
|
|
|
goto drop;
|
2009-11-21 06:54:47 +08:00
|
|
|
|
2011-01-29 08:03:52 +08:00
|
|
|
if (!fcoe_filter_frames(lport, fp)) {
|
|
|
|
put_cpu();
|
|
|
|
fc_exch_recv(lport, fp);
|
|
|
|
return;
|
2009-11-21 06:54:47 +08:00
|
|
|
}
|
2010-03-13 08:08:55 +08:00
|
|
|
drop:
|
|
|
|
stats->ErrorFrames++;
|
|
|
|
put_cpu();
|
|
|
|
kfree_skb(skb);
|
2009-11-21 06:54:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-04-12 23:16:54 +08:00
|
|
|
* fcoe_receive_work() - The per-CPU worker
|
|
|
|
* @work: The work struct
|
2009-11-21 06:54:47 +08:00
|
|
|
*
|
|
|
|
*/
|
2016-04-12 23:16:54 +08:00
|
|
|
static void fcoe_receive_work(struct work_struct *work)
|
2009-11-21 06:54:47 +08:00
|
|
|
{
|
2016-04-12 23:16:54 +08:00
|
|
|
struct fcoe_percpu_s *p;
|
2009-11-21 06:54:47 +08:00
|
|
|
struct sk_buff *skb;
|
2012-03-10 06:50:24 +08:00
|
|
|
struct sk_buff_head tmp;
|
|
|
|
|
2016-04-12 23:16:54 +08:00
|
|
|
p = container_of(work, struct fcoe_percpu_s, work);
|
2012-03-10 06:50:24 +08:00
|
|
|
skb_queue_head_init(&tmp);
|
2009-11-21 06:54:47 +08:00
|
|
|
|
2016-04-12 23:16:54 +08:00
|
|
|
spin_lock_bh(&p->fcoe_rx_list.lock);
|
|
|
|
skb_queue_splice_init(&p->fcoe_rx_list, &tmp);
|
|
|
|
spin_unlock_bh(&p->fcoe_rx_list.lock);
|
2012-07-07 01:40:05 +08:00
|
|
|
|
2016-04-12 23:16:54 +08:00
|
|
|
if (!skb_queue_len(&tmp))
|
|
|
|
return;
|
2012-07-07 01:40:05 +08:00
|
|
|
|
2016-04-12 23:16:54 +08:00
|
|
|
while ((skb = __skb_dequeue(&tmp)))
|
|
|
|
fcoe_recv_frame(skb);
|
2008-12-10 07:10:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-11-04 03:47:50 +08:00
|
|
|
* fcoe_dev_setup() - Setup the link change notification interface
|
2009-02-28 02:55:45 +08:00
|
|
|
*/
|
2009-04-28 12:49:31 +08:00
|
|
|
static void fcoe_dev_setup(void)
|
2008-12-10 07:10:24 +08:00
|
|
|
{
|
2011-11-19 05:35:56 +08:00
|
|
|
register_dcbevent_notifier(&dcb_notifier);
|
2008-12-10 07:10:24 +08:00
|
|
|
register_netdevice_notifier(&fcoe_notifier);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-11-04 03:47:50 +08:00
|
|
|
* fcoe_dev_cleanup() - Cleanup the link change notification interface
|
2009-02-28 02:55:45 +08:00
|
|
|
*/
|
2008-12-10 07:10:24 +08:00
|
|
|
static void fcoe_dev_cleanup(void)
|
|
|
|
{
|
2011-11-19 05:35:56 +08:00
|
|
|
unregister_dcbevent_notifier(&dcb_notifier);
|
2008-12-10 07:10:24 +08:00
|
|
|
unregister_netdevice_notifier(&fcoe_notifier);
|
|
|
|
}
|
|
|
|
|
2011-11-19 05:35:56 +08:00
|
|
|
static struct fcoe_interface *
|
|
|
|
fcoe_hostlist_lookup_realdev_port(struct net_device *netdev)
|
|
|
|
{
|
|
|
|
struct fcoe_interface *fcoe;
|
|
|
|
struct net_device *real_dev;
|
|
|
|
|
|
|
|
list_for_each_entry(fcoe, &fcoe_hostlist, list) {
|
|
|
|
if (fcoe->netdev->priv_flags & IFF_802_1Q_VLAN)
|
|
|
|
real_dev = vlan_dev_real_dev(fcoe->netdev);
|
|
|
|
else
|
|
|
|
real_dev = fcoe->netdev;
|
|
|
|
|
|
|
|
if (netdev == real_dev)
|
|
|
|
return fcoe;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int fcoe_dcb_app_notification(struct notifier_block *notifier,
|
|
|
|
ulong event, void *ptr)
|
|
|
|
{
|
|
|
|
struct dcb_app_type *entry = ptr;
|
2012-05-23 10:06:10 +08:00
|
|
|
struct fcoe_ctlr *ctlr;
|
2011-11-19 05:35:56 +08:00
|
|
|
struct fcoe_interface *fcoe;
|
|
|
|
struct net_device *netdev;
|
|
|
|
int prio;
|
|
|
|
|
|
|
|
if (entry->app.selector != DCB_APP_IDTYPE_ETHTYPE)
|
|
|
|
return NOTIFY_OK;
|
|
|
|
|
|
|
|
netdev = dev_get_by_index(&init_net, entry->ifindex);
|
|
|
|
if (!netdev)
|
|
|
|
return NOTIFY_OK;
|
|
|
|
|
|
|
|
fcoe = fcoe_hostlist_lookup_realdev_port(netdev);
|
|
|
|
dev_put(netdev);
|
|
|
|
if (!fcoe)
|
|
|
|
return NOTIFY_OK;
|
|
|
|
|
2012-05-23 10:06:10 +08:00
|
|
|
ctlr = fcoe_to_ctlr(fcoe);
|
|
|
|
|
2011-11-19 05:35:56 +08:00
|
|
|
if (entry->dcbx & DCB_CAP_DCBX_VER_CEE)
|
|
|
|
prio = ffs(entry->app.priority) - 1;
|
|
|
|
else
|
|
|
|
prio = entry->app.priority;
|
|
|
|
|
|
|
|
if (prio < 0)
|
|
|
|
return NOTIFY_OK;
|
|
|
|
|
|
|
|
if (entry->app.protocol == ETH_P_FIP ||
|
|
|
|
entry->app.protocol == ETH_P_FCOE)
|
2012-05-23 10:06:10 +08:00
|
|
|
ctlr->priority = prio;
|
2011-11-19 05:35:56 +08:00
|
|
|
|
2012-09-25 02:52:45 +08:00
|
|
|
if (entry->app.protocol == ETH_P_FCOE)
|
|
|
|
fcoe->priority = prio;
|
2011-11-19 05:35:56 +08:00
|
|
|
|
|
|
|
return NOTIFY_OK;
|
|
|
|
}
|
|
|
|
|
2008-12-10 07:10:24 +08:00
|
|
|
/**
|
2009-11-04 03:47:50 +08:00
|
|
|
* fcoe_device_notification() - Handler for net device events
|
|
|
|
* @notifier: The context of the notification
|
|
|
|
* @event: The type of event
|
|
|
|
* @ptr: The net device that the event was on
|
2008-12-10 07:10:24 +08:00
|
|
|
*
|
2009-11-04 03:47:50 +08:00
|
|
|
* This function is called by the Ethernet driver in case of link change event.
|
2008-12-10 07:10:24 +08:00
|
|
|
*
|
|
|
|
* Returns: 0 for success
|
2009-02-28 02:55:45 +08:00
|
|
|
*/
|
2008-12-10 07:10:24 +08:00
|
|
|
static int fcoe_device_notification(struct notifier_block *notifier,
|
|
|
|
ulong event, void *ptr)
|
|
|
|
{
|
2012-11-27 14:53:35 +08:00
|
|
|
struct fcoe_ctlr_device *cdev;
|
2009-11-04 03:47:50 +08:00
|
|
|
struct fc_lport *lport = NULL;
|
2013-05-28 09:30:21 +08:00
|
|
|
struct net_device *netdev = netdev_notifier_info_to_dev(ptr);
|
2012-05-23 10:06:10 +08:00
|
|
|
struct fcoe_ctlr *ctlr;
|
2009-08-26 04:59:30 +08:00
|
|
|
struct fcoe_interface *fcoe;
|
2009-08-26 05:00:23 +08:00
|
|
|
struct fcoe_port *port;
|
2012-05-26 01:26:43 +08:00
|
|
|
struct fc_stats *stats;
|
2009-03-18 02:42:40 +08:00
|
|
|
u32 link_possible = 1;
|
2008-12-10 07:10:24 +08:00
|
|
|
u32 mfs;
|
|
|
|
int rc = NOTIFY_OK;
|
|
|
|
|
2009-08-26 04:59:30 +08:00
|
|
|
list_for_each_entry(fcoe, &fcoe_hostlist, list) {
|
2009-08-26 04:59:35 +08:00
|
|
|
if (fcoe->netdev == netdev) {
|
2012-05-23 10:06:10 +08:00
|
|
|
ctlr = fcoe_to_ctlr(fcoe);
|
|
|
|
lport = ctlr->lp;
|
2008-12-10 07:10:24 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-11-04 03:47:50 +08:00
|
|
|
if (!lport) {
|
2008-12-10 07:10:24 +08:00
|
|
|
rc = NOTIFY_DONE;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (event) {
|
|
|
|
case NETDEV_DOWN:
|
|
|
|
case NETDEV_GOING_DOWN:
|
2009-03-18 02:42:40 +08:00
|
|
|
link_possible = 0;
|
2008-12-10 07:10:24 +08:00
|
|
|
break;
|
|
|
|
case NETDEV_UP:
|
|
|
|
case NETDEV_CHANGE:
|
|
|
|
break;
|
|
|
|
case NETDEV_CHANGEMTU:
|
2009-10-22 07:27:52 +08:00
|
|
|
if (netdev->features & NETIF_F_FCOE_MTU)
|
|
|
|
break;
|
2009-07-30 08:05:45 +08:00
|
|
|
mfs = netdev->mtu - (sizeof(struct fcoe_hdr) +
|
|
|
|
sizeof(struct fcoe_crc_eof));
|
2008-12-10 07:10:24 +08:00
|
|
|
if (mfs >= FC_MIN_MAX_FRAME)
|
2009-11-04 03:47:50 +08:00
|
|
|
fc_set_mfs(lport, mfs);
|
2008-12-10 07:10:24 +08:00
|
|
|
break;
|
|
|
|
case NETDEV_REGISTER:
|
|
|
|
break;
|
2009-08-26 05:00:23 +08:00
|
|
|
case NETDEV_UNREGISTER:
|
|
|
|
list_del(&fcoe->list);
|
2012-05-23 10:06:10 +08:00
|
|
|
port = lport_priv(ctlr->lp);
|
2011-01-29 08:05:32 +08:00
|
|
|
queue_work(fcoe_wq, &port->destroy_work);
|
2009-08-26 05:00:23 +08:00
|
|
|
goto out;
|
|
|
|
break;
|
2010-07-21 06:21:17 +08:00
|
|
|
case NETDEV_FEAT_CHANGE:
|
|
|
|
fcoe_netdev_features_change(lport, netdev);
|
|
|
|
break;
|
2008-12-10 07:10:24 +08:00
|
|
|
default:
|
2009-07-30 08:05:45 +08:00
|
|
|
FCOE_NETDEV_DBG(netdev, "Unknown event %ld "
|
2009-06-11 06:30:59 +08:00
|
|
|
"from netdev netlink\n", event);
|
2008-12-10 07:10:24 +08:00
|
|
|
}
|
2010-05-08 06:18:35 +08:00
|
|
|
|
|
|
|
fcoe_link_speed_update(lport);
|
|
|
|
|
2012-11-27 14:53:35 +08:00
|
|
|
cdev = fcoe_ctlr_to_ctlr_dev(ctlr);
|
|
|
|
|
|
|
|
if (link_possible && !fcoe_link_ok(lport)) {
|
|
|
|
switch (cdev->enabled) {
|
|
|
|
case FCOE_CTLR_DISABLED:
|
|
|
|
pr_info("Link up while interface is disabled.\n");
|
|
|
|
break;
|
|
|
|
case FCOE_CTLR_ENABLED:
|
|
|
|
case FCOE_CTLR_UNUSED:
|
|
|
|
fcoe_ctlr_link_up(ctlr);
|
|
|
|
};
|
|
|
|
} else if (fcoe_ctlr_link_down(ctlr)) {
|
|
|
|
switch (cdev->enabled) {
|
|
|
|
case FCOE_CTLR_DISABLED:
|
|
|
|
pr_info("Link down while interface is disabled.\n");
|
|
|
|
break;
|
|
|
|
case FCOE_CTLR_ENABLED:
|
|
|
|
case FCOE_CTLR_UNUSED:
|
|
|
|
stats = per_cpu_ptr(lport->stats, get_cpu());
|
|
|
|
stats->LinkFailureCount++;
|
|
|
|
put_cpu();
|
|
|
|
fcoe_clean_pending_queue(lport);
|
|
|
|
};
|
2008-12-10 07:10:24 +08:00
|
|
|
}
|
|
|
|
out:
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2009-12-11 01:59:31 +08:00
|
|
|
/**
|
|
|
|
* fcoe_disable() - Disables a FCoE interface
|
2011-01-29 08:05:16 +08:00
|
|
|
* @netdev : The net_device object the Ethernet interface to create on
|
2009-12-11 01:59:31 +08:00
|
|
|
*
|
2011-01-29 08:05:16 +08:00
|
|
|
* Called from fcoe transport.
|
2009-12-11 01:59:31 +08:00
|
|
|
*
|
|
|
|
* Returns: 0 for success
|
2012-11-27 14:53:35 +08:00
|
|
|
*
|
|
|
|
* Deprecated: use fcoe_ctlr_enabled()
|
2009-12-11 01:59:31 +08:00
|
|
|
*/
|
2011-01-29 08:05:16 +08:00
|
|
|
static int fcoe_disable(struct net_device *netdev)
|
2009-12-11 01:59:31 +08:00
|
|
|
{
|
2012-05-23 10:06:10 +08:00
|
|
|
struct fcoe_ctlr *ctlr;
|
2009-12-11 01:59:31 +08:00
|
|
|
struct fcoe_interface *fcoe;
|
|
|
|
int rc = 0;
|
|
|
|
|
|
|
|
mutex_lock(&fcoe_config_mutex);
|
|
|
|
|
2011-04-02 07:05:59 +08:00
|
|
|
rtnl_lock();
|
2009-12-11 01:59:31 +08:00
|
|
|
fcoe = fcoe_hostlist_lookup_port(netdev);
|
|
|
|
rtnl_unlock();
|
|
|
|
|
2010-04-10 05:22:23 +08:00
|
|
|
if (fcoe) {
|
2012-05-23 10:06:10 +08:00
|
|
|
ctlr = fcoe_to_ctlr(fcoe);
|
|
|
|
fcoe_ctlr_link_down(ctlr);
|
|
|
|
fcoe_clean_pending_queue(ctlr->lp);
|
2010-04-10 05:22:23 +08:00
|
|
|
} else
|
2009-12-11 01:59:31 +08:00
|
|
|
rc = -ENODEV;
|
|
|
|
|
|
|
|
mutex_unlock(&fcoe_config_mutex);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* fcoe_enable() - Enables a FCoE interface
|
2011-01-29 08:05:16 +08:00
|
|
|
* @netdev : The net_device object the Ethernet interface to create on
|
2009-12-11 01:59:31 +08:00
|
|
|
*
|
2011-01-29 08:05:16 +08:00
|
|
|
* Called from fcoe transport.
|
2009-12-11 01:59:31 +08:00
|
|
|
*
|
|
|
|
* Returns: 0 for success
|
|
|
|
*/
|
2011-01-29 08:05:16 +08:00
|
|
|
static int fcoe_enable(struct net_device *netdev)
|
2009-12-11 01:59:31 +08:00
|
|
|
{
|
2012-05-23 10:06:10 +08:00
|
|
|
struct fcoe_ctlr *ctlr;
|
2009-12-11 01:59:31 +08:00
|
|
|
struct fcoe_interface *fcoe;
|
|
|
|
int rc = 0;
|
|
|
|
|
|
|
|
mutex_lock(&fcoe_config_mutex);
|
2011-04-02 07:05:59 +08:00
|
|
|
rtnl_lock();
|
2009-12-11 01:59:31 +08:00
|
|
|
fcoe = fcoe_hostlist_lookup_port(netdev);
|
|
|
|
rtnl_unlock();
|
|
|
|
|
2012-05-23 10:06:10 +08:00
|
|
|
if (!fcoe) {
|
2009-12-11 01:59:31 +08:00
|
|
|
rc = -ENODEV;
|
2012-05-23 10:06:10 +08:00
|
|
|
goto out;
|
|
|
|
}
|
2009-12-11 01:59:31 +08:00
|
|
|
|
2012-05-23 10:06:10 +08:00
|
|
|
ctlr = fcoe_to_ctlr(fcoe);
|
|
|
|
|
|
|
|
if (!fcoe_link_ok(ctlr->lp))
|
|
|
|
fcoe_ctlr_link_up(ctlr);
|
|
|
|
|
|
|
|
out:
|
2009-12-11 01:59:31 +08:00
|
|
|
mutex_unlock(&fcoe_config_mutex);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2012-11-27 14:53:35 +08:00
|
|
|
/**
|
|
|
|
* fcoe_ctlr_enabled() - Enable or disable an FCoE Controller
|
|
|
|
* @cdev: The FCoE Controller that is being enabled or disabled
|
|
|
|
*
|
|
|
|
* fcoe_sysfs will ensure that the state of 'enabled' has
|
|
|
|
* changed, so no checking is necessary here. This routine simply
|
|
|
|
* calls fcoe_enable or fcoe_disable, both of which are deprecated.
|
|
|
|
* When those routines are removed the functionality can be merged
|
|
|
|
* here.
|
|
|
|
*/
|
|
|
|
static int fcoe_ctlr_enabled(struct fcoe_ctlr_device *cdev)
|
|
|
|
{
|
|
|
|
struct fcoe_ctlr *ctlr = fcoe_ctlr_device_priv(cdev);
|
|
|
|
struct fc_lport *lport = ctlr->lp;
|
|
|
|
struct net_device *netdev = fcoe_netdev(lport);
|
|
|
|
|
|
|
|
switch (cdev->enabled) {
|
|
|
|
case FCOE_CTLR_ENABLED:
|
|
|
|
return fcoe_enable(netdev);
|
|
|
|
case FCOE_CTLR_DISABLED:
|
|
|
|
return fcoe_disable(netdev);
|
|
|
|
case FCOE_CTLR_UNUSED:
|
|
|
|
default:
|
|
|
|
return -ENOTSUPP;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2008-12-10 07:10:24 +08:00
|
|
|
/**
|
2009-11-04 03:47:50 +08:00
|
|
|
* fcoe_destroy() - Destroy a FCoE interface
|
2011-01-29 08:05:16 +08:00
|
|
|
* @netdev : The net_device object the Ethernet interface to create on
|
2009-11-04 03:47:50 +08:00
|
|
|
*
|
2011-01-29 08:05:16 +08:00
|
|
|
* Called from fcoe transport
|
2008-12-10 07:10:24 +08:00
|
|
|
*
|
|
|
|
* Returns: 0 for success
|
2009-02-28 02:55:45 +08:00
|
|
|
*/
|
2011-01-29 08:05:16 +08:00
|
|
|
static int fcoe_destroy(struct net_device *netdev)
|
2008-12-10 07:10:24 +08:00
|
|
|
{
|
2012-05-23 10:06:10 +08:00
|
|
|
struct fcoe_ctlr *ctlr;
|
2009-08-26 05:00:02 +08:00
|
|
|
struct fcoe_interface *fcoe;
|
2011-04-02 07:06:45 +08:00
|
|
|
struct fc_lport *lport;
|
2011-06-21 07:59:51 +08:00
|
|
|
struct fcoe_port *port;
|
2009-10-22 07:27:44 +08:00
|
|
|
int rc = 0;
|
2008-12-10 07:10:24 +08:00
|
|
|
|
2009-08-26 05:00:13 +08:00
|
|
|
mutex_lock(&fcoe_config_mutex);
|
2011-04-02 07:05:59 +08:00
|
|
|
rtnl_lock();
|
2009-08-26 05:00:23 +08:00
|
|
|
fcoe = fcoe_hostlist_lookup_port(netdev);
|
|
|
|
if (!fcoe) {
|
2008-12-10 07:10:24 +08:00
|
|
|
rc = -ENODEV;
|
2011-01-29 08:05:16 +08:00
|
|
|
goto out_nodev;
|
2008-12-10 07:10:24 +08:00
|
|
|
}
|
2012-05-23 10:06:10 +08:00
|
|
|
ctlr = fcoe_to_ctlr(fcoe);
|
|
|
|
lport = ctlr->lp;
|
2011-06-21 07:59:51 +08:00
|
|
|
port = lport_priv(lport);
|
2010-07-21 06:21:17 +08:00
|
|
|
list_del(&fcoe->list);
|
2011-06-21 07:59:51 +08:00
|
|
|
queue_work(fcoe_wq, &port->destroy_work);
|
2008-12-10 07:10:24 +08:00
|
|
|
out_nodev:
|
2011-06-21 07:59:51 +08:00
|
|
|
rtnl_unlock();
|
2009-08-26 05:00:13 +08:00
|
|
|
mutex_unlock(&fcoe_config_mutex);
|
2008-12-10 07:10:24 +08:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2009-11-04 03:47:50 +08:00
|
|
|
/**
|
|
|
|
* fcoe_destroy_work() - Destroy a FCoE port in a deferred work context
|
|
|
|
* @work: Handle to the FCoE port to be destroyed
|
|
|
|
*/
|
2009-08-26 05:00:23 +08:00
|
|
|
static void fcoe_destroy_work(struct work_struct *work)
|
|
|
|
{
|
2013-03-26 02:00:27 +08:00
|
|
|
struct fcoe_ctlr_device *cdev;
|
|
|
|
struct fcoe_ctlr *ctlr;
|
2009-08-26 05:00:23 +08:00
|
|
|
struct fcoe_port *port;
|
2011-06-21 07:59:51 +08:00
|
|
|
struct fcoe_interface *fcoe;
|
2013-01-16 07:42:38 +08:00
|
|
|
struct Scsi_Host *shost;
|
|
|
|
struct fc_host_attrs *fc_host;
|
|
|
|
unsigned long flags;
|
|
|
|
struct fc_vport *vport;
|
|
|
|
struct fc_vport *next_vport;
|
2009-08-26 05:00:23 +08:00
|
|
|
|
|
|
|
port = container_of(work, struct fcoe_port, destroy_work);
|
2013-01-16 07:42:38 +08:00
|
|
|
shost = port->lport->host;
|
|
|
|
fc_host = shost_to_fc_host(shost);
|
|
|
|
|
|
|
|
/* Loop through all the vports and mark them for deletion */
|
|
|
|
spin_lock_irqsave(shost->host_lock, flags);
|
|
|
|
list_for_each_entry_safe(vport, next_vport, &fc_host->vports, peers) {
|
|
|
|
if (vport->flags & (FC_VPORT_DEL | FC_VPORT_CREATING)) {
|
|
|
|
continue;
|
|
|
|
} else {
|
|
|
|
vport->flags |= FC_VPORT_DELETING;
|
|
|
|
queue_work(fc_host_work_q(shost),
|
|
|
|
&vport->vport_delete_work);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(shost->host_lock, flags);
|
|
|
|
|
|
|
|
flush_workqueue(fc_host_work_q(shost));
|
|
|
|
|
2009-08-26 05:00:23 +08:00
|
|
|
mutex_lock(&fcoe_config_mutex);
|
2011-06-21 07:59:51 +08:00
|
|
|
|
|
|
|
fcoe = port->priv;
|
2013-03-26 02:00:27 +08:00
|
|
|
ctlr = fcoe_to_ctlr(fcoe);
|
|
|
|
cdev = fcoe_ctlr_to_ctlr_dev(ctlr);
|
|
|
|
|
2009-08-26 05:00:23 +08:00
|
|
|
fcoe_if_destroy(port->lport);
|
2012-02-11 09:18:41 +08:00
|
|
|
fcoe_interface_cleanup(fcoe);
|
2011-06-21 07:59:51 +08:00
|
|
|
|
2009-08-26 05:00:23 +08:00
|
|
|
mutex_unlock(&fcoe_config_mutex);
|
2013-03-26 02:00:27 +08:00
|
|
|
|
|
|
|
fcoe_ctlr_device_delete(cdev);
|
2009-08-26 05:00:23 +08:00
|
|
|
}
|
|
|
|
|
2011-01-29 08:05:16 +08:00
|
|
|
/**
|
|
|
|
* fcoe_match() - Check if the FCoE is supported on the given netdevice
|
|
|
|
* @netdev : The net_device object the Ethernet interface to create on
|
|
|
|
*
|
|
|
|
* Called from fcoe transport.
|
|
|
|
*
|
|
|
|
* Returns: always returns true as this is the default FCoE transport,
|
|
|
|
* i.e., support all netdevs.
|
|
|
|
*/
|
|
|
|
static bool fcoe_match(struct net_device *netdev)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-11-19 05:35:56 +08:00
|
|
|
/**
|
|
|
|
* fcoe_dcb_create() - Initialize DCB attributes and hooks
|
|
|
|
* @netdev: The net_device object of the L2 link that should be queried
|
|
|
|
* @port: The fcoe_port to bind FCoE APP priority with
|
|
|
|
* @
|
|
|
|
*/
|
|
|
|
static void fcoe_dcb_create(struct fcoe_interface *fcoe)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_DCB
|
|
|
|
int dcbx;
|
|
|
|
u8 fup, up;
|
|
|
|
struct net_device *netdev = fcoe->realdev;
|
2012-05-23 10:06:10 +08:00
|
|
|
struct fcoe_ctlr *ctlr = fcoe_to_ctlr(fcoe);
|
2011-11-19 05:35:56 +08:00
|
|
|
struct dcb_app app = {
|
|
|
|
.priority = 0,
|
|
|
|
.protocol = ETH_P_FCOE
|
|
|
|
};
|
|
|
|
|
|
|
|
/* setup DCB priority attributes. */
|
|
|
|
if (netdev && netdev->dcbnl_ops && netdev->dcbnl_ops->getdcbx) {
|
|
|
|
dcbx = netdev->dcbnl_ops->getdcbx(netdev);
|
|
|
|
|
|
|
|
if (dcbx & DCB_CAP_DCBX_VER_IEEE) {
|
|
|
|
app.selector = IEEE_8021QAZ_APP_SEL_ETHERTYPE;
|
|
|
|
up = dcb_ieee_getapp_mask(netdev, &app);
|
|
|
|
app.protocol = ETH_P_FIP;
|
|
|
|
fup = dcb_ieee_getapp_mask(netdev, &app);
|
|
|
|
} else {
|
|
|
|
app.selector = DCB_APP_IDTYPE_ETHTYPE;
|
|
|
|
up = dcb_getapp(netdev, &app);
|
|
|
|
app.protocol = ETH_P_FIP;
|
|
|
|
fup = dcb_getapp(netdev, &app);
|
|
|
|
}
|
|
|
|
|
2012-09-25 02:52:45 +08:00
|
|
|
fcoe->priority = ffs(up) ? ffs(up) - 1 : 0;
|
|
|
|
ctlr->priority = ffs(fup) ? ffs(fup) - 1 : fcoe->priority;
|
2011-11-19 05:35:56 +08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2012-11-27 14:53:35 +08:00
|
|
|
enum fcoe_create_link_state {
|
|
|
|
FCOE_CREATE_LINK_DOWN,
|
|
|
|
FCOE_CREATE_LINK_UP,
|
|
|
|
};
|
|
|
|
|
2008-12-10 07:10:24 +08:00
|
|
|
/**
|
2012-11-27 14:53:35 +08:00
|
|
|
* _fcoe_create() - (internal) Create a fcoe interface
|
|
|
|
* @netdev : The net_device object the Ethernet interface to create on
|
|
|
|
* @fip_mode: The FIP mode for this creation
|
|
|
|
* @link_state: The ctlr link state on creation
|
2009-11-04 03:47:50 +08:00
|
|
|
*
|
2012-11-27 14:53:35 +08:00
|
|
|
* Called from either the libfcoe 'create' module parameter
|
|
|
|
* via fcoe_create or from fcoe_syfs's ctlr_create file.
|
2008-12-10 07:10:24 +08:00
|
|
|
*
|
2012-11-27 14:53:35 +08:00
|
|
|
* libfcoe's 'create' module parameter is deprecated so some
|
|
|
|
* consolidation of code can be done when that interface is
|
|
|
|
* removed.
|
2009-02-28 02:55:45 +08:00
|
|
|
*/
|
2012-11-27 14:53:35 +08:00
|
|
|
static int _fcoe_create(struct net_device *netdev, enum fip_state fip_mode,
|
|
|
|
enum fcoe_create_link_state link_state)
|
2008-12-10 07:10:24 +08:00
|
|
|
{
|
2011-06-21 07:59:51 +08:00
|
|
|
int rc = 0;
|
2012-05-23 10:06:26 +08:00
|
|
|
struct fcoe_ctlr_device *ctlr_dev;
|
2012-05-23 10:06:10 +08:00
|
|
|
struct fcoe_ctlr *ctlr;
|
2009-08-26 05:00:02 +08:00
|
|
|
struct fcoe_interface *fcoe;
|
2009-08-26 04:59:24 +08:00
|
|
|
struct fc_lport *lport;
|
2008-12-10 07:10:24 +08:00
|
|
|
|
2009-08-26 05:00:13 +08:00
|
|
|
mutex_lock(&fcoe_config_mutex);
|
2011-04-02 07:05:59 +08:00
|
|
|
rtnl_lock();
|
[SCSI] fcoe: fix a circular locking issue with rtnl and sysfs mutex
Currently rtnl mutex is grabbed during fcoe create, destroy, enable
and disable operations while sysfs s_active read mutex is already
held, but simultaneously other networking events could try grabbing
write s_active mutex while rtnl is already held and that is causing
circular lock warning, its detailed log pasted at end.
In this log, the rtnl was held before write s_active during device
renaming but there are more such cases as Joe reported another
instance with tg3 open at:-
http://www.open-fcoe.org/pipermail/devel/2010-February/008263.html
This patch fixes this issue by not waiting for rtnl mutex during
fcoe ops, that means if rtnl mutex is not immediately available
then restart_syscall() to allow others waiting in line to
grab s_active along with rtnl mutex to finish their work first
under these mutex.
Currently rtnl mutex was grabbed twice during fcoe_destroy call flow,
second grab was from fcoe_if_destroy called from fcoe_destroy after
dropping rtnl mutex before calling fcoe_if_destroy, so instead made
fcoe_if_destroy always called with rtnl mutex held to have this mutex
grabbed only once in this code path.
However left matching rtnl_unlock as-is in its original place as it was
dropped there for good reason since very next call causes synchronous
fip worker flush and if rtnl mutex is still held before flush
then that would cause new circular warning between fip->recv_work and
rtnl mutex, I've added detailed comment for this on fcoe_if_destroy
calling and rtnl muxtes unlocking.
=======================================================
[ INFO: possible circular locking dependency detected ]
2.6.33.1linux-stable-2.6.33 #1
-------------------------------------------------------
fcoemon/18823 is trying to acquire lock:
(fcoe_config_mutex){+.+.+.}, at: [<ffffffffa02ba5fc>] fcoe_create+0x27/0x4f7
[fcoe]
but task is already holding lock:
(s_active){++++.+}, at: [<ffffffff8115ef93>] sysfs_get_active_two+0x31/0x48
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #2 (s_active){++++.+}:
[<ffffffff81077bdb>] __lock_acquire+0xb73/0xd2b
[<ffffffff81077e60>] lock_acquire+0xcd/0xf1
[<ffffffff8115e5df>] sysfs_deactivate+0x8b/0xe0
[<ffffffff8115edfb>] sysfs_addrm_finish+0x36/0x55
[<ffffffff8115d0cc>] sysfs_hash_and_remove+0x53/0x6a
[<ffffffff8115f353>] sysfs_remove_link+0x21/0x23
[<ffffffff812b6c93>] device_rename+0x99/0xcb
[<ffffffff8138dbf0>] dev_change_name+0xd5/0x1d2
[<ffffffff8138deee>] dev_ifsioc+0x201/0x2ac
[<ffffffff8138e4ba>] dev_ioctl+0x521/0x632
[<ffffffff81379e43>] sock_do_ioctl+0x3d/0x47
[<ffffffff8137a254>] sock_ioctl+0x213/0x222
[<ffffffff81114614>] vfs_ioctl+0x32/0xa6
[<ffffffff81114b94>] do_vfs_ioctl+0x490/0x4d6
[<ffffffff81114c30>] sys_ioctl+0x56/0x79
[<ffffffff81009b42>] system_call_fastpath+0x16/0x1b
-> #1 (rtnl_mutex){+.+.+.}:
[<ffffffff81077bdb>] __lock_acquire+0xb73/0xd2b
[<ffffffff81077e60>] lock_acquire+0xcd/0xf1
[<ffffffff8142f343>] __mutex_lock_common+0x4b/0x383
[<ffffffff8142f73f>] mutex_lock_nested+0x3e/0x43
[<ffffffff813959f9>] rtnl_lock+0x17/0x19
[<ffffffff8138ccae>] register_netdevice_notifier+0x1e/0x19b
[<ffffffffa02580c1>] 0xffffffffa02580c1
[<ffffffff81002069>] do_one_initcall+0x5e/0x15e
[<ffffffff81084094>] sys_init_module+0xd8/0x23a
[<ffffffff81009b42>] system_call_fastpath+0x16/0x1b
-> #0 (fcoe_config_mutex){+.+.+.}:
[<ffffffff81077a85>] __lock_acquire+0xa1d/0xd2b
[<ffffffff81077e60>] lock_acquire+0xcd/0xf1
[<ffffffff8142f343>] __mutex_lock_common+0x4b/0x383
[<ffffffff8142f73f>] mutex_lock_nested+0x3e/0x43
[<ffffffffa02ba5fc>] fcoe_create+0x27/0x4f7 [fcoe]
[<ffffffff810635b1>] param_attr_store+0x27/0x35
[<ffffffff81063619>] module_attr_store+0x26/0x2a
[<ffffffff8115dae3>] sysfs_write_file+0x108/0x144
[<ffffffff81107bd1>] vfs_write+0xae/0x10b
[<ffffffff81107cee>] sys_write+0x4a/0x6e
[<ffffffff81009b42>] system_call_fastpath+0x16/0x1b
other info that might help us debug this:
3 locks held by fcoemon/18823:
#0: (&buffer->mutex){+.+.+.}, at: [<ffffffff8115da17>]
sysfs_write_file+0x3c/0x144
#1: (s_active){++++.+}, at: [<ffffffff8115ef86>]
sysfs_get_active_two+0x24/0x48
#2: (s_active){++++.+}, at: [<ffffffff8115ef93>]
sysfs_get_active_two+0x31/0x48
stack backtrace:
Pid: 18823, comm: fcoemon Tainted: G W 2.6.33.1linux-stable-2.6.33 #1
Call Trace:
[<ffffffff81076c38>] print_circular_bug+0xa8/0xb6
[<ffffffff81077a85>] __lock_acquire+0xa1d/0xd2b
[<ffffffffa02ba5fc>] ? fcoe_create+0x27/0x4f7 [fcoe]
[<ffffffff81077e60>] lock_acquire+0xcd/0xf1
[<ffffffffa02ba5fc>] ? fcoe_create+0x27/0x4f7 [fcoe]
[<ffffffffa02ba5fc>] ? fcoe_create+0x27/0x4f7 [fcoe]
[<ffffffff8142f343>] __mutex_lock_common+0x4b/0x383
[<ffffffffa02ba5fc>] ? fcoe_create+0x27/0x4f7 [fcoe]
[<ffffffff8106ac70>] ? cpu_clock+0x43/0x5e
[<ffffffff81074e12>] ? lockstat_clock+0x11/0x13
[<ffffffff81074e40>] ? lock_release_holdtime+0x2c/0x127
[<ffffffff8115ef93>] ? sysfs_get_active_two+0x31/0x48
[<ffffffff8142f73f>] mutex_lock_nested+0x3e/0x43
[<ffffffffa02ba5fc>] fcoe_create+0x27/0x4f7 [fcoe]
[<ffffffff810635b1>] param_attr_store+0x27/0x35
[<ffffffff81063619>] module_attr_store+0x26/0x2a
[<ffffffff8115dae3>] sysfs_write_file+0x108/0x144
[<ffffffff81107bd1>] vfs_write+0xae/0x10b
[<ffffffff81076596>] ? trace_hardirqs_on_caller+0x125/0x150
[<ffffffff81107cee>] sys_write+0x4a/0x6e
[<ffffffff81009b42>] system_call_fastpath+0x16/0x1b
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@suse.de>
2010-05-08 06:18:46 +08:00
|
|
|
|
2008-12-10 07:10:24 +08:00
|
|
|
/* look for existing lport */
|
|
|
|
if (fcoe_hostlist_lookup(netdev)) {
|
|
|
|
rc = -EEXIST;
|
2011-01-29 08:05:16 +08:00
|
|
|
goto out_nodev;
|
2008-12-10 07:10:24 +08:00
|
|
|
}
|
|
|
|
|
2010-07-21 06:20:46 +08:00
|
|
|
fcoe = fcoe_interface_create(netdev, fip_mode);
|
2011-01-29 08:03:47 +08:00
|
|
|
if (IS_ERR(fcoe)) {
|
|
|
|
rc = PTR_ERR(fcoe);
|
2011-01-29 08:05:16 +08:00
|
|
|
goto out_nodev;
|
2009-08-26 05:00:02 +08:00
|
|
|
}
|
|
|
|
|
2012-05-23 10:06:10 +08:00
|
|
|
ctlr = fcoe_to_ctlr(fcoe);
|
2012-05-23 10:06:26 +08:00
|
|
|
ctlr_dev = fcoe_ctlr_to_ctlr_dev(ctlr);
|
|
|
|
lport = fcoe_if_create(fcoe, &ctlr_dev->dev, 0);
|
2009-08-26 04:59:24 +08:00
|
|
|
if (IS_ERR(lport)) {
|
2009-06-11 06:30:59 +08:00
|
|
|
printk(KERN_ERR "fcoe: Failed to create interface (%s)\n",
|
2008-12-10 07:10:24 +08:00
|
|
|
netdev->name);
|
|
|
|
rc = -EIO;
|
[SCSI] fcoe: Fix deadlock between fip's recv_work and rtnl
The rtnl cannot be held durrng the fcoe_interface_put.
If it is the last reference on the fcoe_interface the
fcoe_ctlr_destroy will be called as a part of the
cleanup, ultimately calling cancel_work_sync(&fip->recv_work);
If we are processing a flogi response we will be in
the recv_work context and we will lock the rtnl to
add a new unicast MAC address. This is how the deadlock
can occur.
The fix is simply to move the rtnl_lock/unlock into
fcoe_interface_cleanup so that it can be unlocked before
fcoe_interface_put is called.
Here is the lockdep report:
Jul 21 11:26:35 bubba [ 223.870702]
ul 21 11:26:35 bubba [ 223.870704] =======================================================
Jul 21 11:26:35 bubba [ 223.871255] [ INFO: possible circular locking dependency detected ]
Jul 21 11:26:35 bubba [ 223.871530] 3.0.0-rc7+ #1
Jul 21 11:26:35 bubba [ 223.871797] -------------------------------------------------------
Jul 21 11:26:35 bubba [ 223.872072] lockdeptest.sh/3464 is trying to acquire lock:
Jul 21 11:26:35 bubba [ 223.872345] ((&fip->recv_work)
Jul 21 11:26:35 bubba ){+.+.+.}
Jul 21 11:26:35 bubba , at:
Jul 21 11:26:35 bubba [<ffffffff810531f1>] wait_on_work+0x0/0xbd
Jul 21 11:26:35 bubba [ 223.873022]
Jul 21 11:26:35 bubba [ 223.873023] but task is already holding lock:
Jul 21 11:26:35 bubba [ 223.873555] (rtnl_mutex
Jul 21 11:26:35 bubba ){+.+.+.}
Jul 21 11:26:35 bubba , at:
Jul 21 11:26:35 bubba [<ffffffff813e8233>] rtnl_lock+0x12/0x14
Jul 21 11:26:35 bubba [ 223.874229]
Jul 21 11:26:35 bubba [ 223.874230] which lock already depends on the new lock.
Jul 21 11:26:35 bubba [ 223.874231]
Jul 21 11:26:35 bubba [ 223.875032]
Jul 21 11:26:35 bubba [ 223.875033] the existing dependency chain (in reverse order) is:
Jul 21 11:26:35 bubba [ 223.875573]
Jul 21 11:26:35 bubba [ 223.875573] -> #1
Jul 21 11:26:35 bubba (rtnl_mutex
Jul 21 11:26:35 bubba ){+.+.+.}
Jul 21 11:26:35 bubba :
Jul 21 11:26:35 bubba [ 223.876301]
Jul 21 11:26:35 bubba [<ffffffff8106c14a>] lock_acquire+0xd2/0xf7
Jul 21 11:26:35 bubba [ 223.876645]
Jul 21 11:26:35 bubba [<ffffffff8151d975>] __mutex_lock_common+0x47/0x30d
Jul 21 11:26:35 bubba [ 223.876991]
Jul 21 11:26:35 bubba [<ffffffff8151dd36>] mutex_lock_nested+0x3b/0x40
Jul 21 11:26:35 bubba [ 223.877334]
Jul 21 11:26:35 bubba [<ffffffff813e8233>] rtnl_lock+0x12/0x14
Jul 21 11:26:35 bubba [ 223.877675]
Jul 21 11:26:35 bubba [<ffffffffa003d5a0>] fcoe_update_src_mac+0x2b/0x80 [fcoe]
Jul 21 11:26:35 bubba [ 223.878022]
Jul 21 11:26:35 bubba [<ffffffffa003d698>] fcoe_flogi_resp+0x5e/0x79 [fcoe]
Jul 21 11:26:35 bubba [ 223.878366]
Jul 21 11:26:35 bubba [<ffffffffa001566f>] fc_exch_recv+0x7f5/0x9da [libfc]
Jul 21 11:26:35 bubba [ 223.878713]
Jul 21 11:26:35 bubba [<ffffffffa00327d8>] fcoe_ctlr_recv_work+0x71f/0x10dc [libfcoe]
Jul 21 11:26:35 bubba [ 223.879258]
Jul 21 11:26:35 bubba [<ffffffff81053761>] process_one_work+0x1d7/0x347
Jul 21 11:26:35 bubba [ 223.879601]
Jul 21 11:26:35 bubba [<ffffffff81054ade>] worker_thread+0xf8/0x17c
Jul 21 11:26:35 bubba [ 223.879944]
Jul 21 11:26:35 bubba [<ffffffff81058184>] kthread+0x7d/0x85
Jul 21 11:26:35 bubba [ 223.880287]
Jul 21 11:26:35 bubba [<ffffffff81526414>] kernel_thread_helper+0x4/0x10
Jul 21 11:26:35 bubba [ 223.880634]
Jul 21 11:26:35 bubba [ 223.880635] -> #0
Jul 21 11:26:35 bubba ((&fip->recv_work)
Jul 21 11:26:35 bubba ){+.+.+.}
Jul 21 11:26:35 bubba :
Jul 21 11:26:35 bubba [ 223.881357]
Jul 21 11:26:35 bubba [<ffffffff8106b93e>] __lock_acquire+0xb1d/0xe2c
Jul 21 11:26:35 bubba [ 223.881695]
Jul 21 11:26:35 bubba [<ffffffff8106c14a>] lock_acquire+0xd2/0xf7
Jul 21 11:26:35 bubba [ 223.882033]
Jul 21 11:26:35 bubba [<ffffffff81053241>] wait_on_work+0x50/0xbd
Jul 21 11:26:35 bubba [ 223.882378]
Jul 21 11:26:35 bubba [<ffffffff81053b32>] __cancel_work_timer+0xb6/0xf4
Jul 21 11:26:35 bubba [ 223.882718]
Jul 21 11:26:35 bubba [<ffffffff81053b8a>] cancel_work_sync+0xb/0xd
Jul 21 11:26:35 bubba [ 223.883057]
Jul 21 11:26:35 bubba [<ffffffffa00317e6>] fcoe_ctlr_destroy+0x1d/0x67 [libfcoe]
Jul 21 11:26:35 bubba [ 223.883399]
Jul 21 11:26:35 bubba [<ffffffffa003e51e>] fcoe_interface_release+0x21/0x45 [fcoe]
Jul 21 11:26:35 bubba [ 223.883940]
Jul 21 11:26:35 bubba [<ffffffff811fbbe6>] kref_put+0x43/0x4d
Jul 21 11:26:35 bubba [ 223.884280]
Jul 21 11:26:35 bubba [<ffffffffa003ebba>] fcoe_interface_put+0x17/0x19 [fcoe]
Jul 21 11:26:35 bubba [ 223.884624]
Jul 21 11:26:35 bubba [<ffffffffa003f2a6>] fcoe_interface_cleanup+0x188/0x193 [fcoe]
Jul 21 11:26:35 bubba [ 223.885163]
Jul 21 11:26:35 bubba [<ffffffffa003f303>] fcoe_destroy+0x52/0x72 [fcoe]
Jul 21 11:26:35 bubba [ 223.885502]
Jul 21 11:26:35 bubba [<ffffffffa00340a4>] fcoe_transport_destroy+0xab/0x110 [libfcoe]
Jul 21 11:26:35 bubba [ 223.886045]
Jul 21 11:26:35 bubba [<ffffffff81056153>] param_attr_store+0x43/0x62
Jul 21 11:26:35 bubba [ 223.886385]
Jul 21 11:26:35 bubba [<ffffffff8105602d>] module_attr_store+0x21/0x25
Jul 21 11:26:35 bubba [ 223.886728]
Jul 21 11:26:35 bubba [<ffffffff8114c23d>] sysfs_write_file+0x103/0x13f
Jul 21 11:26:35 bubba [ 223.887068]
Jul 21 11:26:35 bubba [<ffffffff810f3e7b>] vfs_write+0xa7/0xfa
Jul 21 11:26:35 bubba [ 223.887406]
Jul 21 11:26:35 bubba [<ffffffff810f4073>] sys_write+0x45/0x69
Jul 21 11:26:35 bubba [ 223.887742]
Jul 21 11:26:35 bubba [<ffffffff815252bb>] system_call_fastpath+0x16/0x1b
Jul 21 11:26:35 bubba [ 223.888083]
Jul 21 11:26:35 bubba [ 223.888084] other info that might help us debug this:
Jul 21 11:26:35 bubba [ 223.888085]
Jul 21 11:26:35 bubba [ 223.888879] Possible unsafe locking scenario:
Jul 21 11:26:35 bubba [ 223.888881]
Jul 21 11:26:35 bubba [ 223.889411] CPU0 CPU1
Jul 21 11:26:35 bubba [ 223.889683] ---- ----
Jul 21 11:26:35 bubba [ 223.889955] lock(
Jul 21 11:26:35 bubba rtnl_mutex
Jul 21 11:26:35 bubba );
Jul 21 11:26:35 bubba [ 223.890349] lock(
Jul 21 11:26:35 bubba (&fip->recv_work)
Jul 21 11:26:35 bubba );
Jul 21 11:26:35 bubba [ 223.890751] lock(
Jul 21 11:26:35 bubba rtnl_mutex
Jul 21 11:26:35 bubba );
Jul 21 11:26:35 bubba [ 223.891154] lock(
Jul 21 11:26:35 bubba (&fip->recv_work)
Jul 21 11:26:35 bubba );
Jul 21 11:26:35 bubba [ 223.891549]
Jul 21 11:26:35 bubba [ 223.891550] *** DEADLOCK ***
Jul 21 11:26:35 bubba [ 223.891551]
Jul 21 11:26:35 bubba [ 223.892347] 6 locks held by lockdeptest.sh/3464:
Jul 21 11:26:35 bubba [ 223.892621] #0:
Jul 21 11:26:35 bubba (&buffer->mutex
Jul 21 11:26:35 bubba ){+.+.+.}
Jul 21 11:26:35 bubba , at:
Jul 21 11:26:35 bubba [<ffffffff8114c171>] sysfs_write_file+0x37/0x13f
Jul 21 11:26:35 bubba [ 223.893359] #1:
Jul 21 11:26:35 bubba (s_active
Jul 21 11:26:35 bubba ){++++.+}
Jul 21 11:26:35 bubba , at:
Jul 21 11:26:35 bubba [<ffffffff8114c21c>] sysfs_write_file+0xe2/0x13f
Jul 21 11:26:35 bubba [ 223.894094] #2:
Jul 21 11:26:35 bubba (param_lock
Jul 21 11:26:35 bubba ){+.+.+.}
Jul 21 11:26:35 bubba , at:
Jul 21 11:26:35 bubba [<ffffffff81056146>] param_attr_store+0x36/0x62
Jul 21 11:26:35 bubba [ 223.894835] #3:
Jul 21 11:26:35 bubba (ft_mutex
Jul 21 11:26:35 bubba ){+.+.+.}
Jul 21 11:26:35 bubba , at:
Jul 21 11:26:35 bubba [<ffffffffa0034017>] fcoe_transport_destroy+0x1e/0x110 [libfcoe]
Jul 21 11:26:35 bubba [ 223.895574] #4:
Jul 21 11:26:35 bubba (fcoe_config_mutex
Jul 21 11:26:35 bubba ){+.+.+.}
Jul 21 11:26:35 bubba , at:
Jul 21 11:26:35 bubba [<ffffffffa003f2c9>] fcoe_destroy+0x18/0x72 [fcoe]
Jul 21 11:26:35 bubba [ 223.896314] #5:
Jul 21 11:26:35 bubba (rtnl_mutex
Jul 21 11:26:35 bubba ){+.+.+.}
Jul 21 11:26:35 bubba , at:
Jul 21 11:26:35 bubba [<ffffffff813e8233>] rtnl_lock+0x12/0x14
Jul 21 11:26:35 bubba [ 223.897047]
Jul 21 11:26:35 bubba [ 223.897048] stack backtrace:
Jul 21 11:26:35 bubba [ 223.897578] Pid: 3464, comm: lockdeptest.sh Not tainted 3.0.0-rc7+ #1
Jul 21 11:26:35 bubba [ 223.897853] Call Trace:
Jul 21 11:26:35 bubba [ 223.898128] [<ffffffff81068e16>] print_circular_bug+0x1f8/0x209
Jul 21 11:26:35 bubba [ 223.898416] [<ffffffff8106b93e>] __lock_acquire+0xb1d/0xe2c
Jul 21 11:26:35 bubba [ 223.898699] [<ffffffff810531f1>] ? wait_on_cpu_work+0xe6/0xe6
Jul 21 11:26:35 bubba [ 223.898982] [<ffffffff8106c14a>] lock_acquire+0xd2/0xf7
Jul 21 11:26:35 bubba [ 223.899263] [<ffffffff810531f1>] ? wait_on_cpu_work+0xe6/0xe6
Jul 21 11:26:35 bubba [ 223.899547] [<ffffffff8104a097>] ? mod_timer+0x8f/0x98
Jul 21 11:26:35 bubba [ 223.899827] [<ffffffff81053241>] wait_on_work+0x50/0xbd
Jul 21 11:26:35 bubba [ 223.900108] [<ffffffff810531f1>] ? wait_on_cpu_work+0xe6/0xe6
Jul 21 11:26:35 bubba [ 223.900390] [<ffffffff81053b32>] __cancel_work_timer+0xb6/0xf4
Jul 21 11:26:35 bubba [ 223.900671] [<ffffffff81053b8a>] cancel_work_sync+0xb/0xd
Jul 21 11:26:35 bubba [ 223.900953] [<ffffffffa00317e6>] fcoe_ctlr_destroy+0x1d/0x67 [libfcoe]
Jul 21 11:26:35 bubba [ 223.901237] [<ffffffffa003e51e>] fcoe_interface_release+0x21/0x45 [fcoe]
Jul 21 11:26:35 bubba [ 223.901522] [<ffffffffa003e4fd>] ? fcoe_enable+0x6b/0x6b [fcoe]
Jul 21 11:26:35 bubba [ 223.901803] [<ffffffff811fbbe6>] kref_put+0x43/0x4d
Jul 21 11:26:35 bubba [ 223.902083] [<ffffffffa003ebba>] fcoe_interface_put+0x17/0x19 [fcoe]
Jul 21 11:26:35 bubba [ 223.902367] [<ffffffffa003f2a6>] fcoe_interface_cleanup+0x188/0x193 [fcoe]
Jul 21 11:26:35 bubba [ 223.902653] [<ffffffff8151dd36>] ? mutex_lock_nested+0x3b/0x40
Jul 21 11:26:35 bubba [ 223.902939] [<ffffffffa003f303>] fcoe_destroy+0x52/0x72 [fcoe]
Jul 21 11:26:35 bubba [ 223.903223] [<ffffffffa00340a4>] fcoe_transport_destroy+0xab/0x110 [libfcoe]
Jul 21 11:26:35 bubba [ 223.903508] [<ffffffff81056153>] param_attr_store+0x43/0x62
Jul 21 11:26:35 bubba [ 223.903792] [<ffffffff8105602d>] module_attr_store+0x21/0x25
Jul 21 11:26:35 bubba [ 223.904075] [<ffffffff8114c23d>] sysfs_write_file+0x103/0x13f
Jul 21 11:26:35 bubba [ 223.904357] [<ffffffff810f3e7b>] vfs_write+0xa7/0xfa
Jul 21 11:26:35 bubba [ 223.904642] [<ffffffff810f51d6>] ? fget_light+0x35/0x96
Jul 21 11:26:35 bubba [ 223.904923] [<ffffffff810f4073>] sys_write+0x45/0x69
Jul 21 11:26:35 bubba [ 223.905204] [<ffffffff815252bb>] system_call_fastpath+0x16/0x1b
Jul 21 11:26:36 bubba [ 223.964438] ixgbe 0000:05:00.0: eth3: detected SFP+: 5
Jul 21 11:26:37 bubba [ 225.196702] ixgbe 0000:05:00.0: eth3: NIC Link is Up 10 Gbps, Flow Control: None
Signed-off-by: Robert Love <robert.w.love@intel.com>
Tested-by: Ross Brattain <ross.b.brattain@intel.com>
Reviewed-by: Yi Zou <yi.zou@intel.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2011-08-26 03:40:47 +08:00
|
|
|
rtnl_unlock();
|
2009-08-26 05:00:23 +08:00
|
|
|
fcoe_interface_cleanup(fcoe);
|
2013-03-26 02:00:27 +08:00
|
|
|
mutex_unlock(&fcoe_config_mutex);
|
|
|
|
fcoe_ctlr_device_delete(ctlr_dev);
|
|
|
|
goto out;
|
2008-12-10 07:10:24 +08:00
|
|
|
}
|
2009-08-26 05:00:02 +08:00
|
|
|
|
2009-08-26 05:00:07 +08:00
|
|
|
/* Make this the "master" N_Port */
|
2012-05-23 10:06:10 +08:00
|
|
|
ctlr->lp = lport;
|
2009-08-26 05:00:07 +08:00
|
|
|
|
2011-11-19 05:35:56 +08:00
|
|
|
/* setup DCB priority attributes. */
|
|
|
|
fcoe_dcb_create(fcoe);
|
|
|
|
|
2009-08-26 05:00:07 +08:00
|
|
|
/* start FIP Discovery and FLOGI */
|
|
|
|
lport->boot_time = jiffies;
|
|
|
|
fc_fabric_login(lport);
|
2012-11-27 14:53:35 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If the fcoe_ctlr_device is to be set to DISABLED
|
|
|
|
* it must be done after the lport is added to the
|
|
|
|
* hostlist, but before the rtnl_lock is released.
|
|
|
|
* This is because the rtnl_lock protects the
|
|
|
|
* hostlist that fcoe_device_notification uses. If
|
|
|
|
* the FCoE Controller is intended to be created
|
|
|
|
* DISABLED then 'enabled' needs to be considered
|
|
|
|
* handling link events. 'enabled' must be set
|
|
|
|
* before the lport can be found in the hostlist
|
|
|
|
* when a link up event is received.
|
|
|
|
*/
|
|
|
|
if (link_state == FCOE_CREATE_LINK_UP)
|
|
|
|
ctlr_dev->enabled = FCOE_CTLR_ENABLED;
|
|
|
|
else
|
|
|
|
ctlr_dev->enabled = FCOE_CTLR_DISABLED;
|
|
|
|
|
|
|
|
if (link_state == FCOE_CREATE_LINK_UP &&
|
|
|
|
!fcoe_link_ok(lport)) {
|
2012-03-14 09:22:12 +08:00
|
|
|
rtnl_unlock();
|
2012-05-23 10:06:10 +08:00
|
|
|
fcoe_ctlr_link_up(ctlr);
|
2012-03-14 09:22:12 +08:00
|
|
|
mutex_unlock(&fcoe_config_mutex);
|
|
|
|
return rc;
|
|
|
|
}
|
2009-08-26 05:00:02 +08:00
|
|
|
|
2008-12-10 07:10:24 +08:00
|
|
|
out_nodev:
|
[SCSI] fcoe: fix a circular locking issue with rtnl and sysfs mutex
Currently rtnl mutex is grabbed during fcoe create, destroy, enable
and disable operations while sysfs s_active read mutex is already
held, but simultaneously other networking events could try grabbing
write s_active mutex while rtnl is already held and that is causing
circular lock warning, its detailed log pasted at end.
In this log, the rtnl was held before write s_active during device
renaming but there are more such cases as Joe reported another
instance with tg3 open at:-
http://www.open-fcoe.org/pipermail/devel/2010-February/008263.html
This patch fixes this issue by not waiting for rtnl mutex during
fcoe ops, that means if rtnl mutex is not immediately available
then restart_syscall() to allow others waiting in line to
grab s_active along with rtnl mutex to finish their work first
under these mutex.
Currently rtnl mutex was grabbed twice during fcoe_destroy call flow,
second grab was from fcoe_if_destroy called from fcoe_destroy after
dropping rtnl mutex before calling fcoe_if_destroy, so instead made
fcoe_if_destroy always called with rtnl mutex held to have this mutex
grabbed only once in this code path.
However left matching rtnl_unlock as-is in its original place as it was
dropped there for good reason since very next call causes synchronous
fip worker flush and if rtnl mutex is still held before flush
then that would cause new circular warning between fip->recv_work and
rtnl mutex, I've added detailed comment for this on fcoe_if_destroy
calling and rtnl muxtes unlocking.
=======================================================
[ INFO: possible circular locking dependency detected ]
2.6.33.1linux-stable-2.6.33 #1
-------------------------------------------------------
fcoemon/18823 is trying to acquire lock:
(fcoe_config_mutex){+.+.+.}, at: [<ffffffffa02ba5fc>] fcoe_create+0x27/0x4f7
[fcoe]
but task is already holding lock:
(s_active){++++.+}, at: [<ffffffff8115ef93>] sysfs_get_active_two+0x31/0x48
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #2 (s_active){++++.+}:
[<ffffffff81077bdb>] __lock_acquire+0xb73/0xd2b
[<ffffffff81077e60>] lock_acquire+0xcd/0xf1
[<ffffffff8115e5df>] sysfs_deactivate+0x8b/0xe0
[<ffffffff8115edfb>] sysfs_addrm_finish+0x36/0x55
[<ffffffff8115d0cc>] sysfs_hash_and_remove+0x53/0x6a
[<ffffffff8115f353>] sysfs_remove_link+0x21/0x23
[<ffffffff812b6c93>] device_rename+0x99/0xcb
[<ffffffff8138dbf0>] dev_change_name+0xd5/0x1d2
[<ffffffff8138deee>] dev_ifsioc+0x201/0x2ac
[<ffffffff8138e4ba>] dev_ioctl+0x521/0x632
[<ffffffff81379e43>] sock_do_ioctl+0x3d/0x47
[<ffffffff8137a254>] sock_ioctl+0x213/0x222
[<ffffffff81114614>] vfs_ioctl+0x32/0xa6
[<ffffffff81114b94>] do_vfs_ioctl+0x490/0x4d6
[<ffffffff81114c30>] sys_ioctl+0x56/0x79
[<ffffffff81009b42>] system_call_fastpath+0x16/0x1b
-> #1 (rtnl_mutex){+.+.+.}:
[<ffffffff81077bdb>] __lock_acquire+0xb73/0xd2b
[<ffffffff81077e60>] lock_acquire+0xcd/0xf1
[<ffffffff8142f343>] __mutex_lock_common+0x4b/0x383
[<ffffffff8142f73f>] mutex_lock_nested+0x3e/0x43
[<ffffffff813959f9>] rtnl_lock+0x17/0x19
[<ffffffff8138ccae>] register_netdevice_notifier+0x1e/0x19b
[<ffffffffa02580c1>] 0xffffffffa02580c1
[<ffffffff81002069>] do_one_initcall+0x5e/0x15e
[<ffffffff81084094>] sys_init_module+0xd8/0x23a
[<ffffffff81009b42>] system_call_fastpath+0x16/0x1b
-> #0 (fcoe_config_mutex){+.+.+.}:
[<ffffffff81077a85>] __lock_acquire+0xa1d/0xd2b
[<ffffffff81077e60>] lock_acquire+0xcd/0xf1
[<ffffffff8142f343>] __mutex_lock_common+0x4b/0x383
[<ffffffff8142f73f>] mutex_lock_nested+0x3e/0x43
[<ffffffffa02ba5fc>] fcoe_create+0x27/0x4f7 [fcoe]
[<ffffffff810635b1>] param_attr_store+0x27/0x35
[<ffffffff81063619>] module_attr_store+0x26/0x2a
[<ffffffff8115dae3>] sysfs_write_file+0x108/0x144
[<ffffffff81107bd1>] vfs_write+0xae/0x10b
[<ffffffff81107cee>] sys_write+0x4a/0x6e
[<ffffffff81009b42>] system_call_fastpath+0x16/0x1b
other info that might help us debug this:
3 locks held by fcoemon/18823:
#0: (&buffer->mutex){+.+.+.}, at: [<ffffffff8115da17>]
sysfs_write_file+0x3c/0x144
#1: (s_active){++++.+}, at: [<ffffffff8115ef86>]
sysfs_get_active_two+0x24/0x48
#2: (s_active){++++.+}, at: [<ffffffff8115ef93>]
sysfs_get_active_two+0x31/0x48
stack backtrace:
Pid: 18823, comm: fcoemon Tainted: G W 2.6.33.1linux-stable-2.6.33 #1
Call Trace:
[<ffffffff81076c38>] print_circular_bug+0xa8/0xb6
[<ffffffff81077a85>] __lock_acquire+0xa1d/0xd2b
[<ffffffffa02ba5fc>] ? fcoe_create+0x27/0x4f7 [fcoe]
[<ffffffff81077e60>] lock_acquire+0xcd/0xf1
[<ffffffffa02ba5fc>] ? fcoe_create+0x27/0x4f7 [fcoe]
[<ffffffffa02ba5fc>] ? fcoe_create+0x27/0x4f7 [fcoe]
[<ffffffff8142f343>] __mutex_lock_common+0x4b/0x383
[<ffffffffa02ba5fc>] ? fcoe_create+0x27/0x4f7 [fcoe]
[<ffffffff8106ac70>] ? cpu_clock+0x43/0x5e
[<ffffffff81074e12>] ? lockstat_clock+0x11/0x13
[<ffffffff81074e40>] ? lock_release_holdtime+0x2c/0x127
[<ffffffff8115ef93>] ? sysfs_get_active_two+0x31/0x48
[<ffffffff8142f73f>] mutex_lock_nested+0x3e/0x43
[<ffffffffa02ba5fc>] fcoe_create+0x27/0x4f7 [fcoe]
[<ffffffff810635b1>] param_attr_store+0x27/0x35
[<ffffffff81063619>] module_attr_store+0x26/0x2a
[<ffffffff8115dae3>] sysfs_write_file+0x108/0x144
[<ffffffff81107bd1>] vfs_write+0xae/0x10b
[<ffffffff81076596>] ? trace_hardirqs_on_caller+0x125/0x150
[<ffffffff81107cee>] sys_write+0x4a/0x6e
[<ffffffff81009b42>] system_call_fastpath+0x16/0x1b
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@suse.de>
2010-05-08 06:18:46 +08:00
|
|
|
rtnl_unlock();
|
2009-08-26 05:00:13 +08:00
|
|
|
mutex_unlock(&fcoe_config_mutex);
|
2013-03-26 02:00:27 +08:00
|
|
|
out:
|
2008-12-10 07:10:24 +08:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2012-11-27 14:53:35 +08:00
|
|
|
/**
|
|
|
|
* fcoe_create() - Create a fcoe interface
|
|
|
|
* @netdev : The net_device object the Ethernet interface to create on
|
|
|
|
* @fip_mode: The FIP mode for this creation
|
|
|
|
*
|
|
|
|
* Called from fcoe transport
|
|
|
|
*
|
|
|
|
* Returns: 0 for success
|
|
|
|
*/
|
|
|
|
static int fcoe_create(struct net_device *netdev, enum fip_state fip_mode)
|
|
|
|
{
|
|
|
|
return _fcoe_create(netdev, fip_mode, FCOE_CREATE_LINK_UP);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* fcoe_ctlr_alloc() - Allocate a fcoe interface from fcoe_sysfs
|
|
|
|
* @netdev: The net_device to be used by the allocated FCoE Controller
|
|
|
|
*
|
|
|
|
* This routine is called from fcoe_sysfs. It will start the fcoe_ctlr
|
|
|
|
* in a link_down state. The allows the user an opportunity to configure
|
|
|
|
* the FCoE Controller from sysfs before enabling the FCoE Controller.
|
|
|
|
*
|
|
|
|
* Creating in with this routine starts the FCoE Controller in Fabric
|
|
|
|
* mode. The user can change to VN2VN or another mode before enabling.
|
|
|
|
*/
|
|
|
|
static int fcoe_ctlr_alloc(struct net_device *netdev)
|
|
|
|
{
|
|
|
|
return _fcoe_create(netdev, FIP_MODE_FABRIC,
|
|
|
|
FCOE_CREATE_LINK_DOWN);
|
|
|
|
}
|
|
|
|
|
2010-05-08 06:18:35 +08:00
|
|
|
/**
|
|
|
|
* fcoe_link_ok() - Check if the link is OK for a local port
|
|
|
|
* @lport: The local port to check link on
|
|
|
|
*
|
|
|
|
* Returns: 0 if link is UP and OK, -1 if not
|
|
|
|
*
|
|
|
|
*/
|
2012-01-14 09:26:25 +08:00
|
|
|
static int fcoe_link_ok(struct fc_lport *lport)
|
2010-05-08 06:18:35 +08:00
|
|
|
{
|
2011-01-29 08:05:37 +08:00
|
|
|
struct net_device *netdev = fcoe_netdev(lport);
|
2010-05-08 06:18:35 +08:00
|
|
|
|
|
|
|
if (netif_oper_up(netdev))
|
|
|
|
return 0;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-02-28 02:55:45 +08:00
|
|
|
/**
|
2009-11-04 03:47:50 +08:00
|
|
|
* fcoe_percpu_clean() - Clear all pending skbs for an local port
|
|
|
|
* @lport: The local port whose skbs are to be cleared
|
2009-08-26 05:04:08 +08:00
|
|
|
*
|
|
|
|
* Must be called with fcoe_create_mutex held to single-thread completion.
|
|
|
|
*
|
2016-04-12 23:16:54 +08:00
|
|
|
* This flushes the pending skbs by flush the work item for each CPU. The work
|
|
|
|
* item on each possible CPU is flushed because we may have used the per-CPU
|
|
|
|
* struct of an offline CPU.
|
2008-12-10 07:10:24 +08:00
|
|
|
*/
|
2012-01-14 09:26:25 +08:00
|
|
|
static void fcoe_percpu_clean(struct fc_lport *lport)
|
2008-12-10 07:10:24 +08:00
|
|
|
{
|
|
|
|
struct fcoe_percpu_s *pp;
|
2009-03-18 02:41:35 +08:00
|
|
|
unsigned int cpu;
|
2008-12-10 07:10:24 +08:00
|
|
|
|
2009-03-18 02:41:35 +08:00
|
|
|
for_each_possible_cpu(cpu) {
|
|
|
|
pp = &per_cpu(fcoe_percpu, cpu);
|
2009-08-26 05:04:08 +08:00
|
|
|
|
2016-04-12 23:16:54 +08:00
|
|
|
flush_work(&pp->work);
|
2008-12-10 07:10:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-28 02:55:45 +08:00
|
|
|
/**
|
2009-11-04 03:47:50 +08:00
|
|
|
* fcoe_reset() - Reset a local port
|
|
|
|
* @shost: The SCSI host associated with the local port to be reset
|
2008-12-10 07:10:24 +08:00
|
|
|
*
|
2009-11-04 03:47:50 +08:00
|
|
|
* Returns: Always 0 (return value required by FC transport template)
|
2008-12-10 07:10:24 +08:00
|
|
|
*/
|
2012-01-14 09:26:25 +08:00
|
|
|
static int fcoe_reset(struct Scsi_Host *shost)
|
2008-12-10 07:10:24 +08:00
|
|
|
{
|
|
|
|
struct fc_lport *lport = shost_priv(shost);
|
2011-02-26 07:03:28 +08:00
|
|
|
struct fcoe_port *port = lport_priv(lport);
|
|
|
|
struct fcoe_interface *fcoe = port->priv;
|
2012-05-23 10:06:10 +08:00
|
|
|
struct fcoe_ctlr *ctlr = fcoe_to_ctlr(fcoe);
|
2012-11-27 14:53:35 +08:00
|
|
|
struct fcoe_ctlr_device *cdev = fcoe_ctlr_to_ctlr_dev(ctlr);
|
2011-02-26 07:03:28 +08:00
|
|
|
|
2012-05-23 10:06:10 +08:00
|
|
|
fcoe_ctlr_link_down(ctlr);
|
|
|
|
fcoe_clean_pending_queue(ctlr->lp);
|
2012-11-27 14:53:35 +08:00
|
|
|
|
|
|
|
if (cdev->enabled != FCOE_CTLR_DISABLED &&
|
|
|
|
!fcoe_link_ok(ctlr->lp))
|
2012-05-23 10:06:10 +08:00
|
|
|
fcoe_ctlr_link_up(ctlr);
|
2008-12-10 07:10:24 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-02-28 02:55:45 +08:00
|
|
|
/**
|
2009-11-04 03:47:50 +08:00
|
|
|
* fcoe_hostlist_lookup_port() - Find the FCoE interface associated with a net device
|
|
|
|
* @netdev: The net device used as a key
|
2008-12-10 07:10:24 +08:00
|
|
|
*
|
2009-11-04 03:47:50 +08:00
|
|
|
* Locking: Must be called with the RNL mutex held.
|
|
|
|
*
|
|
|
|
* Returns: NULL or the FCoE interface
|
2008-12-10 07:10:24 +08:00
|
|
|
*/
|
2009-08-26 04:59:30 +08:00
|
|
|
static struct fcoe_interface *
|
2009-11-04 03:47:50 +08:00
|
|
|
fcoe_hostlist_lookup_port(const struct net_device *netdev)
|
2008-12-10 07:10:24 +08:00
|
|
|
{
|
2009-08-26 04:59:30 +08:00
|
|
|
struct fcoe_interface *fcoe;
|
2008-12-10 07:10:24 +08:00
|
|
|
|
2009-08-26 04:59:30 +08:00
|
|
|
list_for_each_entry(fcoe, &fcoe_hostlist, list) {
|
2009-11-04 03:47:50 +08:00
|
|
|
if (fcoe->netdev == netdev)
|
2009-08-26 04:59:30 +08:00
|
|
|
return fcoe;
|
2008-12-10 07:10:24 +08:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-02-28 02:55:45 +08:00
|
|
|
/**
|
2009-11-04 03:47:50 +08:00
|
|
|
* fcoe_hostlist_lookup() - Find the local port associated with a
|
|
|
|
* given net device
|
|
|
|
* @netdev: The netdevice used as a key
|
2008-12-10 07:10:24 +08:00
|
|
|
*
|
2009-11-04 03:47:50 +08:00
|
|
|
* Locking: Must be called with the RTNL mutex held
|
|
|
|
*
|
|
|
|
* Returns: NULL or the local port
|
2008-12-10 07:10:24 +08:00
|
|
|
*/
|
2009-08-26 05:00:28 +08:00
|
|
|
static struct fc_lport *fcoe_hostlist_lookup(const struct net_device *netdev)
|
2008-12-10 07:10:24 +08:00
|
|
|
{
|
2012-05-23 10:06:10 +08:00
|
|
|
struct fcoe_ctlr *ctlr;
|
2009-08-26 04:59:30 +08:00
|
|
|
struct fcoe_interface *fcoe;
|
2008-12-10 07:10:24 +08:00
|
|
|
|
2009-08-26 04:59:30 +08:00
|
|
|
fcoe = fcoe_hostlist_lookup_port(netdev);
|
2012-05-23 10:06:10 +08:00
|
|
|
ctlr = fcoe_to_ctlr(fcoe);
|
|
|
|
return (fcoe) ? ctlr->lp : NULL;
|
2008-12-10 07:10:24 +08:00
|
|
|
}
|
|
|
|
|
2009-02-28 02:55:45 +08:00
|
|
|
/**
|
2009-11-04 03:47:50 +08:00
|
|
|
* fcoe_hostlist_add() - Add the FCoE interface identified by a local
|
|
|
|
* port to the hostlist
|
|
|
|
* @lport: The local port that identifies the FCoE interface to be added
|
2008-12-10 07:10:24 +08:00
|
|
|
*
|
2009-08-26 05:00:28 +08:00
|
|
|
* Locking: must be called with the RTNL mutex held
|
2009-11-04 03:47:50 +08:00
|
|
|
*
|
|
|
|
* Returns: 0 for success
|
2008-12-10 07:10:24 +08:00
|
|
|
*/
|
2009-08-26 05:00:28 +08:00
|
|
|
static int fcoe_hostlist_add(const struct fc_lport *lport)
|
2008-12-10 07:10:24 +08:00
|
|
|
{
|
2009-08-26 04:59:30 +08:00
|
|
|
struct fcoe_interface *fcoe;
|
|
|
|
struct fcoe_port *port;
|
|
|
|
|
|
|
|
fcoe = fcoe_hostlist_lookup_port(fcoe_netdev(lport));
|
|
|
|
if (!fcoe) {
|
|
|
|
port = lport_priv(lport);
|
2011-01-29 08:05:37 +08:00
|
|
|
fcoe = port->priv;
|
2009-08-26 04:59:30 +08:00
|
|
|
list_add_tail(&fcoe->list, &fcoe_hostlist);
|
2008-12-10 07:10:24 +08:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-01-16 03:34:40 +08:00
|
|
|
/**
|
|
|
|
* fcoe_hostlist_del() - Remove the FCoE interface identified by a local
|
|
|
|
* port to the hostlist
|
|
|
|
* @lport: The local port that identifies the FCoE interface to be added
|
|
|
|
*
|
|
|
|
* Locking: must be called with the RTNL mutex held
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static void fcoe_hostlist_del(const struct fc_lport *lport)
|
|
|
|
{
|
|
|
|
struct fcoe_interface *fcoe;
|
|
|
|
struct fcoe_port *port;
|
|
|
|
|
|
|
|
port = lport_priv(lport);
|
|
|
|
fcoe = port->priv;
|
|
|
|
list_del(&fcoe->list);
|
|
|
|
return;
|
|
|
|
}
|
2011-01-29 08:05:16 +08:00
|
|
|
|
|
|
|
static struct fcoe_transport fcoe_sw_transport = {
|
|
|
|
.name = {FCOE_TRANSPORT_DEFAULT},
|
|
|
|
.attached = false,
|
|
|
|
.list = LIST_HEAD_INIT(fcoe_sw_transport.list),
|
|
|
|
.match = fcoe_match,
|
2012-11-27 14:53:35 +08:00
|
|
|
.alloc = fcoe_ctlr_alloc,
|
2011-01-29 08:05:16 +08:00
|
|
|
.create = fcoe_create,
|
|
|
|
.destroy = fcoe_destroy,
|
|
|
|
.enable = fcoe_enable,
|
|
|
|
.disable = fcoe_disable,
|
|
|
|
};
|
|
|
|
|
2008-12-10 07:10:24 +08:00
|
|
|
/**
|
2009-11-04 03:47:50 +08:00
|
|
|
* fcoe_init() - Initialize fcoe.ko
|
2008-12-10 07:10:24 +08:00
|
|
|
*
|
2009-11-04 03:47:50 +08:00
|
|
|
* Returns: 0 on success, or a negative value on failure
|
2009-02-28 02:55:45 +08:00
|
|
|
*/
|
2008-12-10 07:10:24 +08:00
|
|
|
static int __init fcoe_init(void)
|
|
|
|
{
|
2009-11-04 03:47:50 +08:00
|
|
|
struct fcoe_percpu_s *p;
|
2009-03-18 02:41:30 +08:00
|
|
|
unsigned int cpu;
|
2009-03-18 02:41:46 +08:00
|
|
|
int rc = 0;
|
2008-12-10 07:10:24 +08:00
|
|
|
|
2011-01-29 08:05:32 +08:00
|
|
|
fcoe_wq = alloc_workqueue("fcoe", 0, 0);
|
|
|
|
if (!fcoe_wq)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2011-01-29 08:05:16 +08:00
|
|
|
/* register as a fcoe transport */
|
|
|
|
rc = fcoe_transport_attach(&fcoe_sw_transport);
|
|
|
|
if (rc) {
|
|
|
|
printk(KERN_ERR "failed to register an fcoe transport, check "
|
|
|
|
"if libfcoe is loaded\n");
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2009-08-26 05:00:13 +08:00
|
|
|
mutex_lock(&fcoe_config_mutex);
|
|
|
|
|
2009-03-18 02:41:30 +08:00
|
|
|
for_each_possible_cpu(cpu) {
|
2016-04-12 23:16:54 +08:00
|
|
|
p = per_cpu_ptr(&fcoe_percpu, cpu);
|
|
|
|
INIT_WORK(&p->work, fcoe_receive_work);
|
2009-03-18 02:41:30 +08:00
|
|
|
skb_queue_head_init(&p->fcoe_rx_list);
|
|
|
|
}
|
|
|
|
|
2009-03-18 02:41:46 +08:00
|
|
|
/* Setup link change notification */
|
2008-12-10 07:10:24 +08:00
|
|
|
fcoe_dev_setup();
|
|
|
|
|
2009-08-26 04:59:14 +08:00
|
|
|
rc = fcoe_if_init();
|
|
|
|
if (rc)
|
|
|
|
goto out_free;
|
2008-12-10 07:10:24 +08:00
|
|
|
|
2009-08-26 05:00:13 +08:00
|
|
|
mutex_unlock(&fcoe_config_mutex);
|
2008-12-10 07:10:24 +08:00
|
|
|
return 0;
|
2009-03-18 02:41:46 +08:00
|
|
|
|
|
|
|
out_free:
|
2009-08-26 05:00:13 +08:00
|
|
|
mutex_unlock(&fcoe_config_mutex);
|
2011-01-29 08:05:32 +08:00
|
|
|
destroy_workqueue(fcoe_wq);
|
2009-03-18 02:41:46 +08:00
|
|
|
return rc;
|
2008-12-10 07:10:24 +08:00
|
|
|
}
|
|
|
|
module_init(fcoe_init);
|
|
|
|
|
|
|
|
/**
|
2009-11-04 03:47:50 +08:00
|
|
|
* fcoe_exit() - Clean up fcoe.ko
|
2008-12-10 07:10:24 +08:00
|
|
|
*
|
2009-11-04 03:47:50 +08:00
|
|
|
* Returns: 0 on success or a negative value on failure
|
2009-02-28 02:55:45 +08:00
|
|
|
*/
|
2008-12-10 07:10:24 +08:00
|
|
|
static void __exit fcoe_exit(void)
|
|
|
|
{
|
2009-08-26 04:59:30 +08:00
|
|
|
struct fcoe_interface *fcoe, *tmp;
|
2012-05-23 10:06:10 +08:00
|
|
|
struct fcoe_ctlr *ctlr;
|
2009-08-26 05:00:23 +08:00
|
|
|
struct fcoe_port *port;
|
2009-11-04 03:47:50 +08:00
|
|
|
unsigned int cpu;
|
2008-12-10 07:10:24 +08:00
|
|
|
|
2009-08-26 05:00:13 +08:00
|
|
|
mutex_lock(&fcoe_config_mutex);
|
|
|
|
|
2008-12-10 07:10:24 +08:00
|
|
|
fcoe_dev_cleanup();
|
|
|
|
|
2009-03-28 00:03:29 +08:00
|
|
|
/* releases the associated fcoe hosts */
|
2009-08-26 05:00:28 +08:00
|
|
|
rtnl_lock();
|
|
|
|
list_for_each_entry_safe(fcoe, tmp, &fcoe_hostlist, list) {
|
2012-05-23 10:06:10 +08:00
|
|
|
ctlr = fcoe_to_ctlr(fcoe);
|
|
|
|
port = lport_priv(ctlr->lp);
|
2013-01-16 03:34:40 +08:00
|
|
|
fcoe_hostlist_del(port->lport);
|
2011-01-29 08:05:32 +08:00
|
|
|
queue_work(fcoe_wq, &port->destroy_work);
|
2009-08-26 05:00:18 +08:00
|
|
|
}
|
2009-08-26 05:00:28 +08:00
|
|
|
rtnl_unlock();
|
2008-12-10 07:10:24 +08:00
|
|
|
|
2016-04-12 23:16:54 +08:00
|
|
|
for_each_possible_cpu(cpu)
|
|
|
|
fcoe_thread_cleanup_local(cpu);
|
2014-03-11 04:39:52 +08:00
|
|
|
|
2009-08-26 05:00:13 +08:00
|
|
|
mutex_unlock(&fcoe_config_mutex);
|
2009-08-26 05:00:23 +08:00
|
|
|
|
2011-01-29 08:05:32 +08:00
|
|
|
/*
|
|
|
|
* destroy_work's may be chained but destroy_workqueue()
|
|
|
|
* can take care of them. Just kill the fcoe_wq.
|
|
|
|
*/
|
|
|
|
destroy_workqueue(fcoe_wq);
|
2009-08-26 05:00:23 +08:00
|
|
|
|
2011-01-29 08:05:32 +08:00
|
|
|
/*
|
|
|
|
* Detaching from the scsi transport must happen after all
|
|
|
|
* destroys are done on the fcoe_wq. destroy_workqueue will
|
|
|
|
* enusre the fcoe_wq is flushed.
|
|
|
|
*/
|
2009-08-26 05:00:23 +08:00
|
|
|
fcoe_if_exit();
|
2011-01-29 08:05:16 +08:00
|
|
|
|
|
|
|
/* detach from fcoe transport */
|
|
|
|
fcoe_transport_detach(&fcoe_sw_transport);
|
2008-12-10 07:10:24 +08:00
|
|
|
}
|
|
|
|
module_exit(fcoe_exit);
|
2009-11-04 03:46:29 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* fcoe_flogi_resp() - FCoE specific FLOGI and FDISC response handler
|
|
|
|
* @seq: active sequence in the FLOGI or FDISC exchange
|
|
|
|
* @fp: response frame, or error encoded in a pointer (timeout)
|
|
|
|
* @arg: pointer the the fcoe_ctlr structure
|
|
|
|
*
|
2010-06-11 18:17:01 +08:00
|
|
|
* This handles MAC address management for FCoE, then passes control on to
|
2009-11-04 03:46:29 +08:00
|
|
|
* the libfc FLOGI response handler.
|
|
|
|
*/
|
|
|
|
static void fcoe_flogi_resp(struct fc_seq *seq, struct fc_frame *fp, void *arg)
|
|
|
|
{
|
|
|
|
struct fcoe_ctlr *fip = arg;
|
|
|
|
struct fc_exch *exch = fc_seq_exch(seq);
|
|
|
|
struct fc_lport *lport = exch->lp;
|
|
|
|
u8 *mac;
|
|
|
|
|
|
|
|
if (IS_ERR(fp))
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
mac = fr_cb(fp)->granted_mac;
|
2011-10-29 02:34:23 +08:00
|
|
|
/* pre-FIP */
|
|
|
|
if (is_zero_ether_addr(mac))
|
|
|
|
fcoe_ctlr_recv_flogi(fip, lport, fp);
|
|
|
|
if (!is_zero_ether_addr(mac))
|
|
|
|
fcoe_update_src_mac(lport, mac);
|
2009-11-04 03:46:29 +08:00
|
|
|
done:
|
|
|
|
fc_lport_flogi_resp(seq, fp, lport);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* fcoe_logo_resp() - FCoE specific LOGO response handler
|
|
|
|
* @seq: active sequence in the LOGO exchange
|
|
|
|
* @fp: response frame, or error encoded in a pointer (timeout)
|
|
|
|
* @arg: pointer the the fcoe_ctlr structure
|
|
|
|
*
|
2010-06-11 18:17:01 +08:00
|
|
|
* This handles MAC address management for FCoE, then passes control on to
|
2009-11-04 03:46:29 +08:00
|
|
|
* the libfc LOGO response handler.
|
|
|
|
*/
|
|
|
|
static void fcoe_logo_resp(struct fc_seq *seq, struct fc_frame *fp, void *arg)
|
|
|
|
{
|
2009-11-04 03:49:16 +08:00
|
|
|
struct fc_lport *lport = arg;
|
2009-11-04 03:46:29 +08:00
|
|
|
static u8 zero_mac[ETH_ALEN] = { 0 };
|
|
|
|
|
|
|
|
if (!IS_ERR(fp))
|
2009-11-04 03:49:16 +08:00
|
|
|
fcoe_update_src_mac(lport, zero_mac);
|
2009-11-04 03:46:29 +08:00
|
|
|
fc_lport_logo_resp(seq, fp, lport);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* fcoe_elsct_send - FCoE specific ELS handler
|
|
|
|
*
|
|
|
|
* This does special case handling of FIP encapsualted ELS exchanges for FCoE,
|
|
|
|
* using FCoE specific response handlers and passing the FIP controller as
|
|
|
|
* the argument (the lport is still available from the exchange).
|
|
|
|
*
|
|
|
|
* Most of the work here is just handed off to the libfc routine.
|
|
|
|
*/
|
2009-11-04 03:47:50 +08:00
|
|
|
static struct fc_seq *fcoe_elsct_send(struct fc_lport *lport, u32 did,
|
|
|
|
struct fc_frame *fp, unsigned int op,
|
|
|
|
void (*resp)(struct fc_seq *,
|
|
|
|
struct fc_frame *,
|
|
|
|
void *),
|
|
|
|
void *arg, u32 timeout)
|
2009-11-04 03:46:29 +08:00
|
|
|
{
|
|
|
|
struct fcoe_port *port = lport_priv(lport);
|
2011-01-29 08:05:37 +08:00
|
|
|
struct fcoe_interface *fcoe = port->priv;
|
2012-05-23 10:06:10 +08:00
|
|
|
struct fcoe_ctlr *fip = fcoe_to_ctlr(fcoe);
|
2009-11-04 03:46:29 +08:00
|
|
|
struct fc_frame_header *fh = fc_frame_header_get(fp);
|
|
|
|
|
|
|
|
switch (op) {
|
|
|
|
case ELS_FLOGI:
|
|
|
|
case ELS_FDISC:
|
[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-21 06:20:30 +08:00
|
|
|
if (lport->point_to_multipoint)
|
|
|
|
break;
|
2009-11-04 03:46:29 +08:00
|
|
|
return fc_elsct_send(lport, did, fp, op, fcoe_flogi_resp,
|
|
|
|
fip, timeout);
|
|
|
|
case ELS_LOGO:
|
|
|
|
/* only hook onto fabric logouts, not port logouts */
|
|
|
|
if (ntoh24(fh->fh_d_id) != FC_FID_FLOGI)
|
|
|
|
break;
|
|
|
|
return fc_elsct_send(lport, did, fp, op, fcoe_logo_resp,
|
2009-11-04 03:49:16 +08:00
|
|
|
lport, timeout);
|
2009-11-04 03:46:29 +08:00
|
|
|
}
|
|
|
|
return fc_elsct_send(lport, did, fp, op, resp, arg, timeout);
|
|
|
|
}
|
|
|
|
|
2009-11-04 03:46:40 +08:00
|
|
|
/**
|
|
|
|
* fcoe_vport_create() - create an fc_host/scsi_host for a vport
|
|
|
|
* @vport: fc_vport object to create a new fc_host for
|
|
|
|
* @disabled: start the new fc_host in a disabled state by default?
|
|
|
|
*
|
|
|
|
* Returns: 0 for success
|
|
|
|
*/
|
|
|
|
static int fcoe_vport_create(struct fc_vport *vport, bool disabled)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = vport_to_shost(vport);
|
|
|
|
struct fc_lport *n_port = shost_priv(shost);
|
|
|
|
struct fcoe_port *port = lport_priv(n_port);
|
2011-01-29 08:05:37 +08:00
|
|
|
struct fcoe_interface *fcoe = port->priv;
|
2009-11-04 03:46:40 +08:00
|
|
|
struct net_device *netdev = fcoe->netdev;
|
|
|
|
struct fc_lport *vn_port;
|
2011-05-17 07:45:29 +08:00
|
|
|
int rc;
|
|
|
|
char buf[32];
|
|
|
|
|
|
|
|
rc = fcoe_validate_vport_create(vport);
|
|
|
|
if (rc) {
|
2011-08-05 08:38:49 +08:00
|
|
|
fcoe_wwn_to_str(vport->port_name, buf, sizeof(buf));
|
2011-05-17 07:45:29 +08:00
|
|
|
printk(KERN_ERR "fcoe: Failed to create vport, "
|
|
|
|
"WWPN (0x%s) already exists\n",
|
|
|
|
buf);
|
|
|
|
return rc;
|
|
|
|
}
|
2009-11-04 03:46:40 +08:00
|
|
|
|
|
|
|
mutex_lock(&fcoe_config_mutex);
|
2011-09-03 11:34:30 +08:00
|
|
|
rtnl_lock();
|
2009-11-04 03:46:40 +08:00
|
|
|
vn_port = fcoe_if_create(fcoe, &vport->dev, 1);
|
2011-09-03 11:34:30 +08:00
|
|
|
rtnl_unlock();
|
2009-11-04 03:46:40 +08:00
|
|
|
mutex_unlock(&fcoe_config_mutex);
|
|
|
|
|
|
|
|
if (IS_ERR(vn_port)) {
|
|
|
|
printk(KERN_ERR "fcoe: fcoe_vport_create(%s) failed\n",
|
|
|
|
netdev->name);
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (disabled) {
|
|
|
|
fc_vport_set_state(vport, FC_VPORT_DISABLED);
|
|
|
|
} else {
|
|
|
|
vn_port->boot_time = jiffies;
|
|
|
|
fc_fabric_login(vn_port);
|
|
|
|
fc_vport_setlink(vn_port);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* fcoe_vport_destroy() - destroy the fc_host/scsi_host for a vport
|
|
|
|
* @vport: fc_vport object that is being destroyed
|
|
|
|
*
|
|
|
|
* Returns: 0 for success
|
|
|
|
*/
|
|
|
|
static int fcoe_vport_destroy(struct fc_vport *vport)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = vport_to_shost(vport);
|
|
|
|
struct fc_lport *n_port = shost_priv(shost);
|
|
|
|
struct fc_lport *vn_port = vport->dd_data;
|
|
|
|
|
|
|
|
mutex_lock(&n_port->lp_mutex);
|
|
|
|
list_del(&vn_port->list);
|
|
|
|
mutex_unlock(&n_port->lp_mutex);
|
2012-02-11 09:18:41 +08:00
|
|
|
|
|
|
|
mutex_lock(&fcoe_config_mutex);
|
|
|
|
fcoe_if_destroy(vn_port);
|
|
|
|
mutex_unlock(&fcoe_config_mutex);
|
|
|
|
|
2009-11-04 03:46:40 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* fcoe_vport_disable() - change vport state
|
|
|
|
* @vport: vport to bring online/offline
|
|
|
|
* @disable: should the vport be disabled?
|
|
|
|
*/
|
|
|
|
static int fcoe_vport_disable(struct fc_vport *vport, bool disable)
|
|
|
|
{
|
|
|
|
struct fc_lport *lport = vport->dd_data;
|
|
|
|
|
|
|
|
if (disable) {
|
|
|
|
fc_vport_set_state(vport, FC_VPORT_DISABLED);
|
|
|
|
fc_fabric_logoff(lport);
|
|
|
|
} else {
|
|
|
|
lport->boot_time = jiffies;
|
|
|
|
fc_fabric_login(lport);
|
|
|
|
fc_vport_setlink(lport);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-11-04 03:47:18 +08:00
|
|
|
/**
|
|
|
|
* fcoe_vport_set_symbolic_name() - append vport string to symbolic name
|
|
|
|
* @vport: fc_vport with a new symbolic name string
|
|
|
|
*
|
|
|
|
* After generating a new symbolic name string, a new RSPN_ID request is
|
|
|
|
* sent to the name server. There is no response handler, so if it fails
|
|
|
|
* for some reason it will not be retried.
|
|
|
|
*/
|
|
|
|
static void fcoe_set_vport_symbolic_name(struct fc_vport *vport)
|
|
|
|
{
|
|
|
|
struct fc_lport *lport = vport->dd_data;
|
|
|
|
struct fc_frame *fp;
|
|
|
|
size_t len;
|
|
|
|
|
|
|
|
snprintf(fc_host_symbolic_name(lport->host), FC_SYMBOLIC_NAME_SIZE,
|
|
|
|
"%s v%s over %s : %s", FCOE_NAME, FCOE_VERSION,
|
|
|
|
fcoe_netdev(lport)->name, vport->symbolic_name);
|
|
|
|
|
|
|
|
if (lport->state != LPORT_ST_READY)
|
|
|
|
return;
|
|
|
|
|
|
|
|
len = strnlen(fc_host_symbolic_name(lport->host), 255);
|
|
|
|
fp = fc_frame_alloc(lport,
|
|
|
|
sizeof(struct fc_ct_hdr) +
|
|
|
|
sizeof(struct fc_ns_rspn) + len);
|
|
|
|
if (!fp)
|
|
|
|
return;
|
|
|
|
lport->tt.elsct_send(lport, FC_FID_DIR_SERV, fp, FC_NS_RSPN_ID,
|
2009-11-04 03:50:21 +08:00
|
|
|
NULL, NULL, 3 * lport->r_a_tov);
|
2009-11-04 03:47:18 +08:00
|
|
|
}
|
2009-11-21 06:55:19 +08:00
|
|
|
|
2012-05-23 10:06:26 +08:00
|
|
|
static void fcoe_fcf_get_vlan_id(struct fcoe_fcf_device *fcf_dev)
|
|
|
|
{
|
|
|
|
struct fcoe_ctlr_device *ctlr_dev =
|
|
|
|
fcoe_fcf_dev_to_ctlr_dev(fcf_dev);
|
|
|
|
struct fcoe_ctlr *ctlr = fcoe_ctlr_device_priv(ctlr_dev);
|
|
|
|
struct fcoe_interface *fcoe = fcoe_ctlr_priv(ctlr);
|
|
|
|
|
|
|
|
fcf_dev->vlan_id = vlan_dev_vlan_id(fcoe->netdev);
|
|
|
|
}
|
|
|
|
|
2010-03-13 08:08:02 +08:00
|
|
|
/**
|
|
|
|
* fcoe_set_port_id() - Callback from libfc when Port_ID is set.
|
|
|
|
* @lport: the local port
|
|
|
|
* @port_id: the port ID
|
|
|
|
* @fp: the received frame, if any, that caused the port_id to be set.
|
|
|
|
*
|
|
|
|
* This routine handles the case where we received a FLOGI and are
|
|
|
|
* entering point-to-point mode. We need to call fcoe_ctlr_recv_flogi()
|
|
|
|
* so it can set the non-mapped mode and gateway address.
|
|
|
|
*
|
|
|
|
* The FLOGI LS_ACC is handled by fcoe_flogi_resp().
|
|
|
|
*/
|
|
|
|
static void fcoe_set_port_id(struct fc_lport *lport,
|
|
|
|
u32 port_id, struct fc_frame *fp)
|
|
|
|
{
|
|
|
|
struct fcoe_port *port = lport_priv(lport);
|
2011-01-29 08:05:37 +08:00
|
|
|
struct fcoe_interface *fcoe = port->priv;
|
2012-05-23 10:06:10 +08:00
|
|
|
struct fcoe_ctlr *ctlr = fcoe_to_ctlr(fcoe);
|
2010-03-13 08:08:02 +08:00
|
|
|
|
|
|
|
if (fp && fc_frame_payload_op(fp) == ELS_FLOGI)
|
2012-05-23 10:06:10 +08:00
|
|
|
fcoe_ctlr_recv_flogi(ctlr, lport, fp);
|
2010-03-13 08:08:02 +08:00
|
|
|
}
|