2008-12-10 07:10:17 +08:00
|
|
|
/*
|
|
|
|
* Copyright(c) 2007 - 2008 Intel Corporation. All rights reserved.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Target Discovery
|
|
|
|
*
|
|
|
|
* This block discovers all FC-4 remote ports, including FCP initiators. It
|
|
|
|
* also handles RSCN events and re-discovery if necessary.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* DISC LOCKING
|
|
|
|
*
|
|
|
|
* The disc mutex is can be locked when acquiring rport locks, but may not
|
|
|
|
* be held when acquiring the lport lock. Refer to fc_lport.c for more
|
|
|
|
* details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/timer.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:17 +08:00
|
|
|
#include <linux/err.h>
|
2011-05-27 21:37:25 +08:00
|
|
|
#include <linux/export.h>
|
2008-12-10 07:10:17 +08:00
|
|
|
#include <asm/unaligned.h>
|
|
|
|
|
|
|
|
#include <scsi/fc/fc_gs.h>
|
|
|
|
|
|
|
|
#include <scsi/libfc.h>
|
|
|
|
|
2009-11-04 03:45:58 +08:00
|
|
|
#include "fc_libfc.h"
|
|
|
|
|
2008-12-10 07:10:17 +08:00
|
|
|
#define FC_DISC_RETRY_LIMIT 3 /* max retries */
|
|
|
|
#define FC_DISC_RETRY_DELAY 500UL /* (msecs) delay */
|
|
|
|
|
|
|
|
static void fc_disc_gpn_ft_req(struct fc_disc *);
|
|
|
|
static void fc_disc_gpn_ft_resp(struct fc_seq *, struct fc_frame *, void *);
|
2009-08-26 05:01:29 +08:00
|
|
|
static void fc_disc_done(struct fc_disc *, enum fc_disc_event);
|
2008-12-10 07:10:17 +08:00
|
|
|
static void fc_disc_timeout(struct work_struct *);
|
[SCSI] libfc: send GPN_ID in reaction to single-port RSCNs.
When an RSCN indicates changes to individual remote ports,
don't blindly log them out and then back in. Instead, determine
whether they're still in the directory, by doing GPN_ID.
If that is successful, call login, which will send ADISC and reverify,
otherwise, call logoff. Perhaps we should just delete the rport,
not send LOGO, but it seems safer.
Also, fix a possible issue where if a mix of records in the RSCN
cause us to queue disc_ports for disc_single and then we decide
to do full rediscovery, we leak memory for those disc_ports queued.
So, go through the list of disc_ports even if doing full discovery.
Free the disc_ports in any case. If any of the disc_single() calls
return error, do a full discovery.
The ability to fill in GPN_ID requests was added to fc_ct_fill().
For this, it needs the FC_ID to be passed in as an arg.
The did parameter for fc_elsct_send() is used for that, since the
actual D_DID will always be 0xfffffc for all CT requests so far.
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>
2009-08-26 05:03:58 +08:00
|
|
|
static int fc_disc_single(struct fc_lport *, struct fc_disc_port *);
|
2008-12-10 07:10:17 +08:00
|
|
|
static void fc_disc_restart(struct fc_disc *);
|
|
|
|
|
|
|
|
/**
|
2009-11-04 03:47:39 +08:00
|
|
|
* fc_disc_stop_rports() - Delete all the remote ports associated with the lport
|
|
|
|
* @disc: The discovery job to stop remote ports on
|
2008-12-10 07:10:17 +08:00
|
|
|
*
|
|
|
|
* Locking Note: This function expects that the lport mutex is locked before
|
|
|
|
* calling it.
|
|
|
|
*/
|
2012-01-14 09:26:20 +08:00
|
|
|
static void fc_disc_stop_rports(struct fc_disc *disc)
|
2008-12-10 07:10:17 +08:00
|
|
|
{
|
|
|
|
struct fc_lport *lport;
|
2010-07-21 06:19:37 +08:00
|
|
|
struct fc_rport_priv *rdata;
|
2008-12-10 07:10:17 +08:00
|
|
|
|
2010-07-21 06:19:53 +08:00
|
|
|
lport = fc_disc_lport(disc);
|
2008-12-10 07:10:17 +08:00
|
|
|
|
2016-09-30 17:01:15 +08:00
|
|
|
rcu_read_lock();
|
|
|
|
list_for_each_entry_rcu(rdata, &disc->rports, peers) {
|
|
|
|
if (kref_get_unless_zero(&rdata->kref)) {
|
|
|
|
lport->tt.rport_logoff(rdata);
|
|
|
|
kref_put(&rdata->kref, lport->tt.rport_destroy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rcu_read_unlock();
|
2008-12-10 07:10:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-02-28 02:55:45 +08:00
|
|
|
* fc_disc_recv_rscn_req() - Handle Registered State Change Notification (RSCN)
|
2010-07-21 06:21:12 +08:00
|
|
|
* @disc: The discovery object to which the RSCN applies
|
2009-11-04 03:47:39 +08:00
|
|
|
* @fp: The RSCN frame
|
2008-12-10 07:10:17 +08:00
|
|
|
*
|
|
|
|
* Locking Note: This function expects that the disc_mutex is locked
|
|
|
|
* before it is called.
|
|
|
|
*/
|
2010-07-21 06:21:12 +08:00
|
|
|
static void fc_disc_recv_rscn_req(struct fc_disc *disc, struct fc_frame *fp)
|
2008-12-10 07:10:17 +08:00
|
|
|
{
|
|
|
|
struct fc_lport *lport;
|
|
|
|
struct fc_els_rscn *rp;
|
|
|
|
struct fc_els_rscn_page *pp;
|
|
|
|
struct fc_seq_els_data rjt_data;
|
|
|
|
unsigned int len;
|
|
|
|
int redisc = 0;
|
|
|
|
enum fc_els_rscn_ev_qual ev_qual;
|
|
|
|
enum fc_els_rscn_addr_fmt fmt;
|
|
|
|
LIST_HEAD(disc_ports);
|
|
|
|
struct fc_disc_port *dp, *next;
|
|
|
|
|
2010-07-21 06:19:53 +08:00
|
|
|
lport = fc_disc_lport(disc);
|
2008-12-10 07:10:17 +08:00
|
|
|
|
2009-06-11 06:31:10 +08:00
|
|
|
FC_DISC_DBG(disc, "Received an RSCN event\n");
|
2008-12-10 07:10:17 +08:00
|
|
|
|
|
|
|
/* make sure the frame contains an RSCN message */
|
|
|
|
rp = fc_frame_payload_get(fp, sizeof(*rp));
|
|
|
|
if (!rp)
|
|
|
|
goto reject;
|
|
|
|
/* make sure the page length is as expected (4 bytes) */
|
|
|
|
if (rp->rscn_page_len != sizeof(*pp))
|
|
|
|
goto reject;
|
|
|
|
/* get the RSCN payload length */
|
|
|
|
len = ntohs(rp->rscn_plen);
|
|
|
|
if (len < sizeof(*rp))
|
|
|
|
goto reject;
|
|
|
|
/* make sure the frame contains the expected payload */
|
|
|
|
rp = fc_frame_payload_get(fp, len);
|
|
|
|
if (!rp)
|
|
|
|
goto reject;
|
|
|
|
/* payload must be a multiple of the RSCN page size */
|
|
|
|
len -= sizeof(*rp);
|
|
|
|
if (len % sizeof(*pp))
|
|
|
|
goto reject;
|
|
|
|
|
|
|
|
for (pp = (void *)(rp + 1); len > 0; len -= sizeof(*pp), pp++) {
|
|
|
|
ev_qual = pp->rscn_page_flags >> ELS_RSCN_EV_QUAL_BIT;
|
|
|
|
ev_qual &= ELS_RSCN_EV_QUAL_MASK;
|
|
|
|
fmt = pp->rscn_page_flags >> ELS_RSCN_ADDR_FMT_BIT;
|
|
|
|
fmt &= ELS_RSCN_ADDR_FMT_MASK;
|
|
|
|
/*
|
|
|
|
* if we get an address format other than port
|
|
|
|
* (area, domain, fabric), then do a full discovery
|
|
|
|
*/
|
|
|
|
switch (fmt) {
|
|
|
|
case ELS_ADDR_FMT_PORT:
|
2009-06-11 06:31:10 +08:00
|
|
|
FC_DISC_DBG(disc, "Port address format for port "
|
2010-04-10 05:23:10 +08:00
|
|
|
"(%6.6x)\n", ntoh24(pp->rscn_fid));
|
2008-12-10 07:10:17 +08:00
|
|
|
dp = kzalloc(sizeof(*dp), GFP_KERNEL);
|
|
|
|
if (!dp) {
|
|
|
|
redisc = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
dp->lp = lport;
|
2009-08-26 05:02:59 +08:00
|
|
|
dp->port_id = ntoh24(pp->rscn_fid);
|
2008-12-10 07:10:17 +08:00
|
|
|
list_add_tail(&dp->peers, &disc_ports);
|
|
|
|
break;
|
|
|
|
case ELS_ADDR_FMT_AREA:
|
|
|
|
case ELS_ADDR_FMT_DOM:
|
|
|
|
case ELS_ADDR_FMT_FAB:
|
|
|
|
default:
|
2009-06-11 06:31:10 +08:00
|
|
|
FC_DISC_DBG(disc, "Address format is (%d)\n", fmt);
|
2008-12-10 07:10:17 +08:00
|
|
|
redisc = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-10-18 16:01:35 +08:00
|
|
|
fc_seq_els_rsp_send(fp, ELS_LS_ACC, NULL);
|
[SCSI] libfc: send GPN_ID in reaction to single-port RSCNs.
When an RSCN indicates changes to individual remote ports,
don't blindly log them out and then back in. Instead, determine
whether they're still in the directory, by doing GPN_ID.
If that is successful, call login, which will send ADISC and reverify,
otherwise, call logoff. Perhaps we should just delete the rport,
not send LOGO, but it seems safer.
Also, fix a possible issue where if a mix of records in the RSCN
cause us to queue disc_ports for disc_single and then we decide
to do full rediscovery, we leak memory for those disc_ports queued.
So, go through the list of disc_ports even if doing full discovery.
Free the disc_ports in any case. If any of the disc_single() calls
return error, do a full discovery.
The ability to fill in GPN_ID requests was added to fc_ct_fill().
For this, it needs the FC_ID to be passed in as an arg.
The did parameter for fc_elsct_send() is used for that, since the
actual D_DID will always be 0xfffffc for all CT requests so far.
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>
2009-08-26 05:03:58 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If not doing a complete rediscovery, do GPN_ID on
|
|
|
|
* the individual ports mentioned in the list.
|
|
|
|
* If any of these get an error, do a full rediscovery.
|
|
|
|
* In any case, go through the list and free the entries.
|
|
|
|
*/
|
|
|
|
list_for_each_entry_safe(dp, next, &disc_ports, peers) {
|
|
|
|
list_del(&dp->peers);
|
|
|
|
if (!redisc)
|
|
|
|
redisc = fc_disc_single(lport, dp);
|
|
|
|
kfree(dp);
|
|
|
|
}
|
2008-12-10 07:10:17 +08:00
|
|
|
if (redisc) {
|
2009-06-11 06:31:10 +08:00
|
|
|
FC_DISC_DBG(disc, "RSCN received: rediscovering\n");
|
2008-12-10 07:10:17 +08:00
|
|
|
fc_disc_restart(disc);
|
|
|
|
} else {
|
2009-06-11 06:31:10 +08:00
|
|
|
FC_DISC_DBG(disc, "RSCN received: not rediscovering. "
|
|
|
|
"redisc %d state %d in_prog %d\n",
|
|
|
|
redisc, lport->state, disc->pending);
|
2008-12-10 07:10:17 +08:00
|
|
|
}
|
|
|
|
fc_frame_free(fp);
|
|
|
|
return;
|
|
|
|
reject:
|
2009-06-11 06:31:10 +08:00
|
|
|
FC_DISC_DBG(disc, "Received a bad RSCN frame\n");
|
2008-12-10 07:10:17 +08:00
|
|
|
rjt_data.reason = ELS_RJT_LOGIC;
|
|
|
|
rjt_data.explan = ELS_EXPL_NONE;
|
2016-10-18 16:01:35 +08:00
|
|
|
fc_seq_els_rsp_send(fp, ELS_LS_RJT, &rjt_data);
|
2008-12-10 07:10:17 +08:00
|
|
|
fc_frame_free(fp);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-02-28 02:55:45 +08:00
|
|
|
* fc_disc_recv_req() - Handle incoming requests
|
2009-11-04 03:47:39 +08:00
|
|
|
* @lport: The local port receiving the request
|
2010-07-21 06:21:12 +08:00
|
|
|
* @fp: The request frame
|
2008-12-10 07:10:17 +08:00
|
|
|
*
|
|
|
|
* Locking Note: This function is called from the EM and will lock
|
|
|
|
* the disc_mutex before calling the handler for the
|
|
|
|
* request.
|
|
|
|
*/
|
2010-07-21 06:21:12 +08:00
|
|
|
static void fc_disc_recv_req(struct fc_lport *lport, struct fc_frame *fp)
|
2008-12-10 07:10:17 +08:00
|
|
|
{
|
|
|
|
u8 op;
|
|
|
|
struct fc_disc *disc = &lport->disc;
|
|
|
|
|
|
|
|
op = fc_frame_payload_op(fp);
|
|
|
|
switch (op) {
|
|
|
|
case ELS_RSCN:
|
|
|
|
mutex_lock(&disc->disc_mutex);
|
2010-07-21 06:21:12 +08:00
|
|
|
fc_disc_recv_rscn_req(disc, fp);
|
2008-12-10 07:10:17 +08:00
|
|
|
mutex_unlock(&disc->disc_mutex);
|
|
|
|
break;
|
|
|
|
default:
|
2009-06-11 06:31:10 +08:00
|
|
|
FC_DISC_DBG(disc, "Received an unsupported request, "
|
|
|
|
"the opcode is (%x)\n", op);
|
2011-05-17 07:45:35 +08:00
|
|
|
fc_frame_free(fp);
|
2008-12-10 07:10:17 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-02-28 02:55:45 +08:00
|
|
|
* fc_disc_restart() - Restart discovery
|
2009-11-04 03:47:39 +08:00
|
|
|
* @disc: The discovery object to be restarted
|
2008-12-10 07:10:17 +08:00
|
|
|
*
|
|
|
|
* Locking Note: This function expects that the disc mutex
|
|
|
|
* is already locked.
|
|
|
|
*/
|
|
|
|
static void fc_disc_restart(struct fc_disc *disc)
|
|
|
|
{
|
2009-08-26 05:02:54 +08:00
|
|
|
if (!disc->disc_callback)
|
|
|
|
return;
|
|
|
|
|
2009-06-11 06:31:10 +08:00
|
|
|
FC_DISC_DBG(disc, "Restarting discovery\n");
|
2008-12-10 07:10:17 +08:00
|
|
|
|
|
|
|
disc->requested = 1;
|
2009-08-26 05:02:11 +08:00
|
|
|
if (disc->pending)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Advance disc_id. This is an arbitrary non-zero number that will
|
|
|
|
* match the value in the fc_rport_priv after discovery for all
|
|
|
|
* freshly-discovered remote ports. Avoid wrapping to zero.
|
|
|
|
*/
|
|
|
|
disc->disc_id = (disc->disc_id + 2) | 1;
|
2009-08-26 05:02:38 +08:00
|
|
|
disc->retry_count = 0;
|
2009-08-26 05:02:11 +08:00
|
|
|
fc_disc_gpn_ft_req(disc);
|
2008-12-10 07:10:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-11-04 03:47:39 +08:00
|
|
|
* fc_disc_start() - Start discovery on a local port
|
|
|
|
* @lport: The local port to have discovery started on
|
|
|
|
* @disc_callback: Callback function to be called when discovery is complete
|
2008-12-10 07:10:17 +08:00
|
|
|
*/
|
|
|
|
static void fc_disc_start(void (*disc_callback)(struct fc_lport *,
|
|
|
|
enum fc_disc_event),
|
|
|
|
struct fc_lport *lport)
|
|
|
|
{
|
|
|
|
struct fc_disc *disc = &lport->disc;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* At this point we may have a new disc job or an existing
|
|
|
|
* one. Either way, let's lock when we make changes to it
|
|
|
|
* and send the GPN_FT request.
|
|
|
|
*/
|
|
|
|
mutex_lock(&disc->disc_mutex);
|
|
|
|
disc->disc_callback = disc_callback;
|
2009-08-26 05:02:49 +08:00
|
|
|
fc_disc_restart(disc);
|
2008-12-10 07:10:17 +08:00
|
|
|
mutex_unlock(&disc->disc_mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-02-28 02:55:45 +08:00
|
|
|
* fc_disc_done() - Discovery has been completed
|
2009-11-04 03:47:39 +08:00
|
|
|
* @disc: The discovery context
|
|
|
|
* @event: The discovery completion status
|
2009-08-26 05:01:29 +08:00
|
|
|
*
|
2009-04-22 07:26:52 +08:00
|
|
|
* Locking Note: This function expects that the disc mutex is locked before
|
|
|
|
* it is called. The discovery callback is then made with the lock released,
|
|
|
|
* and the lock is re-taken before returning from this function
|
2008-12-10 07:10:17 +08:00
|
|
|
*/
|
2009-08-26 05:01:29 +08:00
|
|
|
static void fc_disc_done(struct fc_disc *disc, enum fc_disc_event event)
|
2008-12-10 07:10:17 +08:00
|
|
|
{
|
2010-07-21 06:19:53 +08:00
|
|
|
struct fc_lport *lport = fc_disc_lport(disc);
|
2009-08-26 05:02:11 +08:00
|
|
|
struct fc_rport_priv *rdata;
|
2008-12-10 07:10:17 +08:00
|
|
|
|
2009-06-11 06:31:10 +08:00
|
|
|
FC_DISC_DBG(disc, "Discovery complete\n");
|
2008-12-10 07:10:17 +08:00
|
|
|
|
2009-08-26 05:02:11 +08:00
|
|
|
disc->pending = 0;
|
|
|
|
if (disc->requested) {
|
|
|
|
fc_disc_restart(disc);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2009-11-04 03:47:39 +08:00
|
|
|
* Go through all remote ports. If they were found in the latest
|
|
|
|
* discovery, reverify or log them in. Otherwise, log them out.
|
2009-08-26 05:02:11 +08:00
|
|
|
* Skip ports which were never discovered. These are the dNS port
|
|
|
|
* and ports which were created by PLOGI.
|
|
|
|
*/
|
2016-09-30 17:01:15 +08:00
|
|
|
rcu_read_lock();
|
2010-07-21 06:19:37 +08:00
|
|
|
list_for_each_entry_rcu(rdata, &disc->rports, peers) {
|
2016-09-30 17:01:15 +08:00
|
|
|
if (!kref_get_unless_zero(&rdata->kref))
|
2009-08-26 05:02:11 +08:00
|
|
|
continue;
|
2016-09-30 17:01:15 +08:00
|
|
|
if (rdata->disc_id) {
|
|
|
|
if (rdata->disc_id == disc->disc_id)
|
|
|
|
lport->tt.rport_login(rdata);
|
|
|
|
else
|
|
|
|
lport->tt.rport_logoff(rdata);
|
|
|
|
}
|
|
|
|
kref_put(&rdata->kref, lport->tt.rport_destroy);
|
2009-08-26 05:02:11 +08:00
|
|
|
}
|
2016-09-30 17:01:15 +08:00
|
|
|
rcu_read_unlock();
|
2009-04-22 07:26:52 +08:00
|
|
|
mutex_unlock(&disc->disc_mutex);
|
|
|
|
disc->disc_callback(lport, event);
|
|
|
|
mutex_lock(&disc->disc_mutex);
|
2008-12-10 07:10:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-02-28 02:55:45 +08:00
|
|
|
* fc_disc_error() - Handle error on dNS request
|
2009-11-04 03:47:39 +08:00
|
|
|
* @disc: The discovery context
|
|
|
|
* @fp: The error code encoded as a frame pointer
|
2008-12-10 07:10:17 +08:00
|
|
|
*/
|
|
|
|
static void fc_disc_error(struct fc_disc *disc, struct fc_frame *fp)
|
|
|
|
{
|
2010-07-21 06:19:53 +08:00
|
|
|
struct fc_lport *lport = fc_disc_lport(disc);
|
2008-12-10 07:10:17 +08:00
|
|
|
unsigned long delay = 0;
|
2009-06-11 06:31:10 +08:00
|
|
|
|
|
|
|
FC_DISC_DBG(disc, "Error %ld, retries %d/%d\n",
|
|
|
|
PTR_ERR(fp), disc->retry_count,
|
|
|
|
FC_DISC_RETRY_LIMIT);
|
2008-12-10 07:10:17 +08:00
|
|
|
|
|
|
|
if (!fp || PTR_ERR(fp) == -FC_EX_TIMEOUT) {
|
|
|
|
/*
|
|
|
|
* Memory allocation failure, or the exchange timed out,
|
|
|
|
* retry after delay.
|
|
|
|
*/
|
|
|
|
if (disc->retry_count < FC_DISC_RETRY_LIMIT) {
|
|
|
|
/* go ahead and retry */
|
|
|
|
if (!fp)
|
|
|
|
delay = msecs_to_jiffies(FC_DISC_RETRY_DELAY);
|
|
|
|
else {
|
|
|
|
delay = msecs_to_jiffies(lport->e_d_tov);
|
|
|
|
|
|
|
|
/* timeout faster first time */
|
|
|
|
if (!disc->retry_count)
|
|
|
|
delay /= 4;
|
|
|
|
}
|
|
|
|
disc->retry_count++;
|
|
|
|
schedule_delayed_work(&disc->disc_work, delay);
|
2009-08-26 05:01:29 +08:00
|
|
|
} else
|
|
|
|
fc_disc_done(disc, DISC_EV_FAILED);
|
2012-02-11 09:18:57 +08:00
|
|
|
} else if (PTR_ERR(fp) == -FC_EX_CLOSED) {
|
|
|
|
/*
|
|
|
|
* if discovery fails due to lport reset, clear
|
|
|
|
* pending flag so that subsequent discovery can
|
|
|
|
* continue
|
|
|
|
*/
|
|
|
|
disc->pending = 0;
|
2008-12-10 07:10:17 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-02-28 02:55:45 +08:00
|
|
|
* fc_disc_gpn_ft_req() - Send Get Port Names by FC-4 type (GPN_FT) request
|
2009-11-04 03:47:39 +08:00
|
|
|
* @lport: The discovery context
|
2008-12-10 07:10:17 +08:00
|
|
|
*
|
|
|
|
* Locking Note: This function expects that the disc_mutex is locked
|
|
|
|
* before it is called.
|
|
|
|
*/
|
|
|
|
static void fc_disc_gpn_ft_req(struct fc_disc *disc)
|
|
|
|
{
|
|
|
|
struct fc_frame *fp;
|
2010-07-21 06:19:53 +08:00
|
|
|
struct fc_lport *lport = fc_disc_lport(disc);
|
2008-12-10 07:10:17 +08:00
|
|
|
|
|
|
|
WARN_ON(!fc_lport_test_ready(lport));
|
|
|
|
|
|
|
|
disc->pending = 1;
|
|
|
|
disc->requested = 0;
|
|
|
|
|
|
|
|
disc->buf_len = 0;
|
|
|
|
disc->seq_count = 0;
|
|
|
|
fp = fc_frame_alloc(lport,
|
|
|
|
sizeof(struct fc_ct_hdr) +
|
|
|
|
sizeof(struct fc_ns_gid_ft));
|
|
|
|
if (!fp)
|
|
|
|
goto err;
|
|
|
|
|
2009-08-26 05:00:55 +08:00
|
|
|
if (lport->tt.elsct_send(lport, 0, fp,
|
2008-12-10 07:10:17 +08:00
|
|
|
FC_NS_GPN_FT,
|
|
|
|
fc_disc_gpn_ft_resp,
|
2009-11-04 03:50:21 +08:00
|
|
|
disc, 3 * lport->r_a_tov))
|
2008-12-10 07:10:17 +08:00
|
|
|
return;
|
|
|
|
err:
|
2009-10-22 07:28:09 +08:00
|
|
|
fc_disc_error(disc, NULL);
|
2008-12-10 07:10:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-08-26 05:01:29 +08:00
|
|
|
* fc_disc_gpn_ft_parse() - Parse the body of the dNS GPN_FT response.
|
2009-11-04 03:47:39 +08:00
|
|
|
* @lport: The local port the GPN_FT was received on
|
|
|
|
* @buf: The GPN_FT response buffer
|
|
|
|
* @len: The size of response buffer
|
2009-08-26 05:01:29 +08:00
|
|
|
*
|
|
|
|
* Goes through the list of IDs and names resulting from a request.
|
2008-12-10 07:10:17 +08:00
|
|
|
*/
|
|
|
|
static int fc_disc_gpn_ft_parse(struct fc_disc *disc, void *buf, size_t len)
|
|
|
|
{
|
|
|
|
struct fc_lport *lport;
|
|
|
|
struct fc_gpn_ft_resp *np;
|
|
|
|
char *bp;
|
|
|
|
size_t plen;
|
|
|
|
size_t tlen;
|
|
|
|
int error = 0;
|
2009-08-26 05:00:39 +08:00
|
|
|
struct fc_rport_identifiers ids;
|
2009-08-26 05:00:34 +08:00
|
|
|
struct fc_rport_priv *rdata;
|
2008-12-10 07:10:17 +08:00
|
|
|
|
2010-07-21 06:19:53 +08:00
|
|
|
lport = fc_disc_lport(disc);
|
2009-08-26 05:02:22 +08:00
|
|
|
disc->seq_count++;
|
2008-12-10 07:10:17 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Handle partial name record left over from previous call.
|
|
|
|
*/
|
|
|
|
bp = buf;
|
|
|
|
plen = len;
|
|
|
|
np = (struct fc_gpn_ft_resp *)bp;
|
|
|
|
tlen = disc->buf_len;
|
2009-08-26 05:02:43 +08:00
|
|
|
disc->buf_len = 0;
|
2008-12-10 07:10:17 +08:00
|
|
|
if (tlen) {
|
|
|
|
WARN_ON(tlen >= sizeof(*np));
|
|
|
|
plen = sizeof(*np) - tlen;
|
|
|
|
WARN_ON(plen <= 0);
|
|
|
|
WARN_ON(plen >= sizeof(*np));
|
|
|
|
if (plen > len)
|
|
|
|
plen = len;
|
|
|
|
np = &disc->partial_buf;
|
|
|
|
memcpy((char *)np + tlen, bp, plen);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set bp so that the loop below will advance it to the
|
|
|
|
* first valid full name element.
|
|
|
|
*/
|
|
|
|
bp -= tlen;
|
|
|
|
len += tlen;
|
|
|
|
plen += tlen;
|
|
|
|
disc->buf_len = (unsigned char) plen;
|
|
|
|
if (plen == sizeof(*np))
|
|
|
|
disc->buf_len = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Handle full name records, including the one filled from above.
|
|
|
|
* Normally, np == bp and plen == len, but from the partial case above,
|
|
|
|
* bp, len describe the overall buffer, and np, plen describe the
|
|
|
|
* partial buffer, which if would usually be full now.
|
|
|
|
* After the first time through the loop, things return to "normal".
|
|
|
|
*/
|
|
|
|
while (plen >= sizeof(*np)) {
|
2009-08-26 05:00:39 +08:00
|
|
|
ids.port_id = ntoh24(np->fp_fid);
|
|
|
|
ids.port_name = ntohll(np->fp_wwpn);
|
|
|
|
|
2010-05-08 06:18:41 +08:00
|
|
|
if (ids.port_id != lport->port_id &&
|
2009-08-26 05:00:39 +08:00
|
|
|
ids.port_name != lport->wwpn) {
|
2009-08-26 05:02:59 +08:00
|
|
|
rdata = lport->tt.rport_create(lport, ids.port_id);
|
|
|
|
if (rdata) {
|
|
|
|
rdata->ids.port_name = ids.port_name;
|
2009-08-26 05:02:11 +08:00
|
|
|
rdata->disc_id = disc->disc_id;
|
2009-08-26 05:02:59 +08:00
|
|
|
} else {
|
2009-06-11 06:31:10 +08:00
|
|
|
printk(KERN_WARNING "libfc: Failed to allocate "
|
|
|
|
"memory for the newly discovered port "
|
2010-04-10 05:23:10 +08:00
|
|
|
"(%6.6x)\n", ids.port_id);
|
2009-08-26 05:02:43 +08:00
|
|
|
error = -ENOMEM;
|
|
|
|
}
|
2008-12-10 07:10:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (np->fp_flags & FC_NS_FID_LAST) {
|
2009-08-26 05:01:29 +08:00
|
|
|
fc_disc_done(disc, DISC_EV_SUCCESS);
|
2008-12-10 07:10:17 +08:00
|
|
|
len = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
len -= sizeof(*np);
|
|
|
|
bp += sizeof(*np);
|
|
|
|
np = (struct fc_gpn_ft_resp *)bp;
|
|
|
|
plen = len;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Save any partial record at the end of the buffer for next time.
|
|
|
|
*/
|
|
|
|
if (error == 0 && len > 0 && len < sizeof(*np)) {
|
|
|
|
if (np != &disc->partial_buf) {
|
2009-06-11 06:31:10 +08:00
|
|
|
FC_DISC_DBG(disc, "Partial buffer remains "
|
|
|
|
"for discovery\n");
|
2008-12-10 07:10:17 +08:00
|
|
|
memcpy(&disc->partial_buf, np, len);
|
|
|
|
}
|
|
|
|
disc->buf_len = (unsigned char) len;
|
|
|
|
}
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2009-02-28 02:55:45 +08:00
|
|
|
/**
|
2009-11-04 03:47:39 +08:00
|
|
|
* fc_disc_timeout() - Handler for discovery timeouts
|
|
|
|
* @work: Structure holding discovery context that needs to retry discovery
|
2008-12-10 07:10:17 +08:00
|
|
|
*/
|
|
|
|
static void fc_disc_timeout(struct work_struct *work)
|
|
|
|
{
|
|
|
|
struct fc_disc *disc = container_of(work,
|
|
|
|
struct fc_disc,
|
|
|
|
disc_work.work);
|
|
|
|
mutex_lock(&disc->disc_mutex);
|
2009-08-26 05:02:38 +08:00
|
|
|
fc_disc_gpn_ft_req(disc);
|
2008-12-10 07:10:17 +08:00
|
|
|
mutex_unlock(&disc->disc_mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-02-28 02:55:45 +08:00
|
|
|
* fc_disc_gpn_ft_resp() - Handle a response frame from Get Port Names (GPN_FT)
|
2009-11-04 03:47:39 +08:00
|
|
|
* @sp: The sequence that the GPN_FT response was received on
|
|
|
|
* @fp: The GPN_FT response frame
|
|
|
|
* @lp_arg: The discovery context
|
2008-12-10 07:10:17 +08:00
|
|
|
*
|
2009-04-22 07:26:52 +08:00
|
|
|
* Locking Note: This function is called without disc mutex held, and
|
|
|
|
* should do all its processing with the mutex held
|
2008-12-10 07:10:17 +08:00
|
|
|
*/
|
|
|
|
static void fc_disc_gpn_ft_resp(struct fc_seq *sp, struct fc_frame *fp,
|
|
|
|
void *disc_arg)
|
|
|
|
{
|
|
|
|
struct fc_disc *disc = disc_arg;
|
|
|
|
struct fc_ct_hdr *cp;
|
|
|
|
struct fc_frame_header *fh;
|
2009-08-26 05:02:22 +08:00
|
|
|
enum fc_disc_event event = DISC_EV_NONE;
|
2008-12-10 07:10:17 +08:00
|
|
|
unsigned int seq_cnt;
|
|
|
|
unsigned int len;
|
2009-08-26 05:02:22 +08:00
|
|
|
int error = 0;
|
2008-12-10 07:10:17 +08:00
|
|
|
|
2009-04-22 07:26:52 +08:00
|
|
|
mutex_lock(&disc->disc_mutex);
|
2009-06-11 06:31:10 +08:00
|
|
|
FC_DISC_DBG(disc, "Received a GPN_FT response\n");
|
2008-12-10 07:10:17 +08:00
|
|
|
|
|
|
|
if (IS_ERR(fp)) {
|
|
|
|
fc_disc_error(disc, fp);
|
2009-04-22 07:26:52 +08:00
|
|
|
mutex_unlock(&disc->disc_mutex);
|
2008-12-10 07:10:17 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN_ON(!fc_frame_is_linear(fp)); /* buffer must be contiguous */
|
|
|
|
fh = fc_frame_header_get(fp);
|
|
|
|
len = fr_len(fp) - sizeof(*fh);
|
|
|
|
seq_cnt = ntohs(fh->fh_seq_cnt);
|
2009-08-26 05:02:22 +08:00
|
|
|
if (fr_sof(fp) == FC_SOF_I3 && seq_cnt == 0 && disc->seq_count == 0) {
|
2008-12-10 07:10:17 +08:00
|
|
|
cp = fc_frame_payload_get(fp, sizeof(*cp));
|
|
|
|
if (!cp) {
|
2009-06-11 06:31:10 +08:00
|
|
|
FC_DISC_DBG(disc, "GPN_FT response too short, len %d\n",
|
|
|
|
fr_len(fp));
|
2009-08-26 05:02:27 +08:00
|
|
|
event = DISC_EV_FAILED;
|
2008-12-10 07:10:17 +08:00
|
|
|
} else if (ntohs(cp->ct_cmd) == FC_FS_ACC) {
|
|
|
|
|
2009-02-28 02:55:45 +08:00
|
|
|
/* Accepted, parse the response. */
|
2008-12-10 07:10:17 +08:00
|
|
|
len -= sizeof(*cp);
|
2009-08-26 05:02:22 +08:00
|
|
|
error = fc_disc_gpn_ft_parse(disc, cp + 1, len);
|
2008-12-10 07:10:17 +08:00
|
|
|
} else if (ntohs(cp->ct_cmd) == FC_FS_RJT) {
|
2009-06-11 06:31:10 +08:00
|
|
|
FC_DISC_DBG(disc, "GPN_FT rejected reason %x exp %x "
|
|
|
|
"(check zoning)\n", cp->ct_reason,
|
|
|
|
cp->ct_explan);
|
2009-08-26 05:02:22 +08:00
|
|
|
event = DISC_EV_FAILED;
|
2009-08-26 05:02:33 +08:00
|
|
|
if (cp->ct_reason == FC_FS_RJT_UNABL &&
|
|
|
|
cp->ct_explan == FC_FS_EXP_FTNR)
|
|
|
|
event = DISC_EV_SUCCESS;
|
2008-12-10 07:10:17 +08:00
|
|
|
} else {
|
2009-06-11 06:31:10 +08:00
|
|
|
FC_DISC_DBG(disc, "GPN_FT unexpected response code "
|
|
|
|
"%x\n", ntohs(cp->ct_cmd));
|
2009-08-26 05:02:27 +08:00
|
|
|
event = DISC_EV_FAILED;
|
2008-12-10 07:10:17 +08:00
|
|
|
}
|
2009-08-26 05:02:22 +08:00
|
|
|
} else if (fr_sof(fp) == FC_SOF_N3 && seq_cnt == disc->seq_count) {
|
|
|
|
error = fc_disc_gpn_ft_parse(disc, fh + 1, len);
|
2008-12-10 07:10:17 +08:00
|
|
|
} else {
|
2009-06-11 06:31:10 +08:00
|
|
|
FC_DISC_DBG(disc, "GPN_FT unexpected frame - out of sequence? "
|
|
|
|
"seq_cnt %x expected %x sof %x eof %x\n",
|
|
|
|
seq_cnt, disc->seq_count, fr_sof(fp), fr_eof(fp));
|
2009-08-26 05:02:27 +08:00
|
|
|
event = DISC_EV_FAILED;
|
2008-12-10 07:10:17 +08:00
|
|
|
}
|
2009-08-26 05:02:22 +08:00
|
|
|
if (error)
|
|
|
|
fc_disc_error(disc, fp);
|
|
|
|
else if (event != DISC_EV_NONE)
|
|
|
|
fc_disc_done(disc, event);
|
2008-12-10 07:10:17 +08:00
|
|
|
fc_frame_free(fp);
|
2009-04-22 07:26:52 +08:00
|
|
|
mutex_unlock(&disc->disc_mutex);
|
2008-12-10 07:10:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
[SCSI] libfc: send GPN_ID in reaction to single-port RSCNs.
When an RSCN indicates changes to individual remote ports,
don't blindly log them out and then back in. Instead, determine
whether they're still in the directory, by doing GPN_ID.
If that is successful, call login, which will send ADISC and reverify,
otherwise, call logoff. Perhaps we should just delete the rport,
not send LOGO, but it seems safer.
Also, fix a possible issue where if a mix of records in the RSCN
cause us to queue disc_ports for disc_single and then we decide
to do full rediscovery, we leak memory for those disc_ports queued.
So, go through the list of disc_ports even if doing full discovery.
Free the disc_ports in any case. If any of the disc_single() calls
return error, do a full discovery.
The ability to fill in GPN_ID requests was added to fc_ct_fill().
For this, it needs the FC_ID to be passed in as an arg.
The did parameter for fc_elsct_send() is used for that, since the
actual D_DID will always be 0xfffffc for all CT requests so far.
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>
2009-08-26 05:03:58 +08:00
|
|
|
* fc_disc_gpn_id_resp() - Handle a response frame from Get Port Names (GPN_ID)
|
2009-11-04 03:47:39 +08:00
|
|
|
* @sp: The sequence the GPN_ID is on
|
|
|
|
* @fp: The response frame
|
|
|
|
* @rdata_arg: The remote port that sent the GPN_ID response
|
2008-12-10 07:10:17 +08:00
|
|
|
*
|
[SCSI] libfc: send GPN_ID in reaction to single-port RSCNs.
When an RSCN indicates changes to individual remote ports,
don't blindly log them out and then back in. Instead, determine
whether they're still in the directory, by doing GPN_ID.
If that is successful, call login, which will send ADISC and reverify,
otherwise, call logoff. Perhaps we should just delete the rport,
not send LOGO, but it seems safer.
Also, fix a possible issue where if a mix of records in the RSCN
cause us to queue disc_ports for disc_single and then we decide
to do full rediscovery, we leak memory for those disc_ports queued.
So, go through the list of disc_ports even if doing full discovery.
Free the disc_ports in any case. If any of the disc_single() calls
return error, do a full discovery.
The ability to fill in GPN_ID requests was added to fc_ct_fill().
For this, it needs the FC_ID to be passed in as an arg.
The did parameter for fc_elsct_send() is used for that, since the
actual D_DID will always be 0xfffffc for all CT requests so far.
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>
2009-08-26 05:03:58 +08:00
|
|
|
* Locking Note: This function is called without disc mutex held.
|
2008-12-10 07:10:17 +08:00
|
|
|
*/
|
[SCSI] libfc: send GPN_ID in reaction to single-port RSCNs.
When an RSCN indicates changes to individual remote ports,
don't blindly log them out and then back in. Instead, determine
whether they're still in the directory, by doing GPN_ID.
If that is successful, call login, which will send ADISC and reverify,
otherwise, call logoff. Perhaps we should just delete the rport,
not send LOGO, but it seems safer.
Also, fix a possible issue where if a mix of records in the RSCN
cause us to queue disc_ports for disc_single and then we decide
to do full rediscovery, we leak memory for those disc_ports queued.
So, go through the list of disc_ports even if doing full discovery.
Free the disc_ports in any case. If any of the disc_single() calls
return error, do a full discovery.
The ability to fill in GPN_ID requests was added to fc_ct_fill().
For this, it needs the FC_ID to be passed in as an arg.
The did parameter for fc_elsct_send() is used for that, since the
actual D_DID will always be 0xfffffc for all CT requests so far.
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>
2009-08-26 05:03:58 +08:00
|
|
|
static void fc_disc_gpn_id_resp(struct fc_seq *sp, struct fc_frame *fp,
|
|
|
|
void *rdata_arg)
|
2008-12-10 07:10:17 +08:00
|
|
|
{
|
[SCSI] libfc: send GPN_ID in reaction to single-port RSCNs.
When an RSCN indicates changes to individual remote ports,
don't blindly log them out and then back in. Instead, determine
whether they're still in the directory, by doing GPN_ID.
If that is successful, call login, which will send ADISC and reverify,
otherwise, call logoff. Perhaps we should just delete the rport,
not send LOGO, but it seems safer.
Also, fix a possible issue where if a mix of records in the RSCN
cause us to queue disc_ports for disc_single and then we decide
to do full rediscovery, we leak memory for those disc_ports queued.
So, go through the list of disc_ports even if doing full discovery.
Free the disc_ports in any case. If any of the disc_single() calls
return error, do a full discovery.
The ability to fill in GPN_ID requests was added to fc_ct_fill().
For this, it needs the FC_ID to be passed in as an arg.
The did parameter for fc_elsct_send() is used for that, since the
actual D_DID will always be 0xfffffc for all CT requests so far.
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>
2009-08-26 05:03:58 +08:00
|
|
|
struct fc_rport_priv *rdata = rdata_arg;
|
|
|
|
struct fc_rport_priv *new_rdata;
|
2008-12-10 07:10:17 +08:00
|
|
|
struct fc_lport *lport;
|
[SCSI] libfc: send GPN_ID in reaction to single-port RSCNs.
When an RSCN indicates changes to individual remote ports,
don't blindly log them out and then back in. Instead, determine
whether they're still in the directory, by doing GPN_ID.
If that is successful, call login, which will send ADISC and reverify,
otherwise, call logoff. Perhaps we should just delete the rport,
not send LOGO, but it seems safer.
Also, fix a possible issue where if a mix of records in the RSCN
cause us to queue disc_ports for disc_single and then we decide
to do full rediscovery, we leak memory for those disc_ports queued.
So, go through the list of disc_ports even if doing full discovery.
Free the disc_ports in any case. If any of the disc_single() calls
return error, do a full discovery.
The ability to fill in GPN_ID requests was added to fc_ct_fill().
For this, it needs the FC_ID to be passed in as an arg.
The did parameter for fc_elsct_send() is used for that, since the
actual D_DID will always be 0xfffffc for all CT requests so far.
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>
2009-08-26 05:03:58 +08:00
|
|
|
struct fc_disc *disc;
|
|
|
|
struct fc_ct_hdr *cp;
|
|
|
|
struct fc_ns_gid_pn *pn;
|
|
|
|
u64 port_name;
|
2008-12-10 07:10:17 +08:00
|
|
|
|
[SCSI] libfc: send GPN_ID in reaction to single-port RSCNs.
When an RSCN indicates changes to individual remote ports,
don't blindly log them out and then back in. Instead, determine
whether they're still in the directory, by doing GPN_ID.
If that is successful, call login, which will send ADISC and reverify,
otherwise, call logoff. Perhaps we should just delete the rport,
not send LOGO, but it seems safer.
Also, fix a possible issue where if a mix of records in the RSCN
cause us to queue disc_ports for disc_single and then we decide
to do full rediscovery, we leak memory for those disc_ports queued.
So, go through the list of disc_ports even if doing full discovery.
Free the disc_ports in any case. If any of the disc_single() calls
return error, do a full discovery.
The ability to fill in GPN_ID requests was added to fc_ct_fill().
For this, it needs the FC_ID to be passed in as an arg.
The did parameter for fc_elsct_send() is used for that, since the
actual D_DID will always be 0xfffffc for all CT requests so far.
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>
2009-08-26 05:03:58 +08:00
|
|
|
lport = rdata->local_port;
|
|
|
|
disc = &lport->disc;
|
2008-12-10 07:10:17 +08:00
|
|
|
|
[SCSI] libfc: send GPN_ID in reaction to single-port RSCNs.
When an RSCN indicates changes to individual remote ports,
don't blindly log them out and then back in. Instead, determine
whether they're still in the directory, by doing GPN_ID.
If that is successful, call login, which will send ADISC and reverify,
otherwise, call logoff. Perhaps we should just delete the rport,
not send LOGO, but it seems safer.
Also, fix a possible issue where if a mix of records in the RSCN
cause us to queue disc_ports for disc_single and then we decide
to do full rediscovery, we leak memory for those disc_ports queued.
So, go through the list of disc_ports even if doing full discovery.
Free the disc_ports in any case. If any of the disc_single() calls
return error, do a full discovery.
The ability to fill in GPN_ID requests was added to fc_ct_fill().
For this, it needs the FC_ID to be passed in as an arg.
The did parameter for fc_elsct_send() is used for that, since the
actual D_DID will always be 0xfffffc for all CT requests so far.
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>
2009-08-26 05:03:58 +08:00
|
|
|
if (PTR_ERR(fp) == -FC_EX_CLOSED)
|
2008-12-10 07:10:17 +08:00
|
|
|
goto out;
|
[SCSI] libfc: send GPN_ID in reaction to single-port RSCNs.
When an RSCN indicates changes to individual remote ports,
don't blindly log them out and then back in. Instead, determine
whether they're still in the directory, by doing GPN_ID.
If that is successful, call login, which will send ADISC and reverify,
otherwise, call logoff. Perhaps we should just delete the rport,
not send LOGO, but it seems safer.
Also, fix a possible issue where if a mix of records in the RSCN
cause us to queue disc_ports for disc_single and then we decide
to do full rediscovery, we leak memory for those disc_ports queued.
So, go through the list of disc_ports even if doing full discovery.
Free the disc_ports in any case. If any of the disc_single() calls
return error, do a full discovery.
The ability to fill in GPN_ID requests was added to fc_ct_fill().
For this, it needs the FC_ID to be passed in as an arg.
The did parameter for fc_elsct_send() is used for that, since the
actual D_DID will always be 0xfffffc for all CT requests so far.
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>
2009-08-26 05:03:58 +08:00
|
|
|
if (IS_ERR(fp))
|
|
|
|
goto redisc;
|
|
|
|
|
|
|
|
cp = fc_frame_payload_get(fp, sizeof(*cp));
|
|
|
|
if (!cp)
|
|
|
|
goto redisc;
|
|
|
|
if (ntohs(cp->ct_cmd) == FC_FS_ACC) {
|
|
|
|
if (fr_len(fp) < sizeof(struct fc_frame_header) +
|
|
|
|
sizeof(*cp) + sizeof(*pn))
|
|
|
|
goto redisc;
|
|
|
|
pn = (struct fc_ns_gid_pn *)(cp + 1);
|
|
|
|
port_name = get_unaligned_be64(&pn->fn_wwpn);
|
2016-09-30 17:01:15 +08:00
|
|
|
mutex_lock(&rdata->rp_mutex);
|
[SCSI] libfc: send GPN_ID in reaction to single-port RSCNs.
When an RSCN indicates changes to individual remote ports,
don't blindly log them out and then back in. Instead, determine
whether they're still in the directory, by doing GPN_ID.
If that is successful, call login, which will send ADISC and reverify,
otherwise, call logoff. Perhaps we should just delete the rport,
not send LOGO, but it seems safer.
Also, fix a possible issue where if a mix of records in the RSCN
cause us to queue disc_ports for disc_single and then we decide
to do full rediscovery, we leak memory for those disc_ports queued.
So, go through the list of disc_ports even if doing full discovery.
Free the disc_ports in any case. If any of the disc_single() calls
return error, do a full discovery.
The ability to fill in GPN_ID requests was added to fc_ct_fill().
For this, it needs the FC_ID to be passed in as an arg.
The did parameter for fc_elsct_send() is used for that, since the
actual D_DID will always be 0xfffffc for all CT requests so far.
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>
2009-08-26 05:03:58 +08:00
|
|
|
if (rdata->ids.port_name == -1)
|
|
|
|
rdata->ids.port_name = port_name;
|
|
|
|
else if (rdata->ids.port_name != port_name) {
|
|
|
|
FC_DISC_DBG(disc, "GPN_ID accepted. WWPN changed. "
|
2010-04-10 05:23:16 +08:00
|
|
|
"Port-id %6.6x wwpn %16.16llx\n",
|
[SCSI] libfc: send GPN_ID in reaction to single-port RSCNs.
When an RSCN indicates changes to individual remote ports,
don't blindly log them out and then back in. Instead, determine
whether they're still in the directory, by doing GPN_ID.
If that is successful, call login, which will send ADISC and reverify,
otherwise, call logoff. Perhaps we should just delete the rport,
not send LOGO, but it seems safer.
Also, fix a possible issue where if a mix of records in the RSCN
cause us to queue disc_ports for disc_single and then we decide
to do full rediscovery, we leak memory for those disc_ports queued.
So, go through the list of disc_ports even if doing full discovery.
Free the disc_ports in any case. If any of the disc_single() calls
return error, do a full discovery.
The ability to fill in GPN_ID requests was added to fc_ct_fill().
For this, it needs the FC_ID to be passed in as an arg.
The did parameter for fc_elsct_send() is used for that, since the
actual D_DID will always be 0xfffffc for all CT requests so far.
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>
2009-08-26 05:03:58 +08:00
|
|
|
rdata->ids.port_id, port_name);
|
2016-09-30 17:01:15 +08:00
|
|
|
mutex_unlock(&rdata->rp_mutex);
|
[SCSI] libfc: send GPN_ID in reaction to single-port RSCNs.
When an RSCN indicates changes to individual remote ports,
don't blindly log them out and then back in. Instead, determine
whether they're still in the directory, by doing GPN_ID.
If that is successful, call login, which will send ADISC and reverify,
otherwise, call logoff. Perhaps we should just delete the rport,
not send LOGO, but it seems safer.
Also, fix a possible issue where if a mix of records in the RSCN
cause us to queue disc_ports for disc_single and then we decide
to do full rediscovery, we leak memory for those disc_ports queued.
So, go through the list of disc_ports even if doing full discovery.
Free the disc_ports in any case. If any of the disc_single() calls
return error, do a full discovery.
The ability to fill in GPN_ID requests was added to fc_ct_fill().
For this, it needs the FC_ID to be passed in as an arg.
The did parameter for fc_elsct_send() is used for that, since the
actual D_DID will always be 0xfffffc for all CT requests so far.
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>
2009-08-26 05:03:58 +08:00
|
|
|
lport->tt.rport_logoff(rdata);
|
2016-09-30 17:01:15 +08:00
|
|
|
mutex_lock(&lport->disc.disc_mutex);
|
[SCSI] libfc: send GPN_ID in reaction to single-port RSCNs.
When an RSCN indicates changes to individual remote ports,
don't blindly log them out and then back in. Instead, determine
whether they're still in the directory, by doing GPN_ID.
If that is successful, call login, which will send ADISC and reverify,
otherwise, call logoff. Perhaps we should just delete the rport,
not send LOGO, but it seems safer.
Also, fix a possible issue where if a mix of records in the RSCN
cause us to queue disc_ports for disc_single and then we decide
to do full rediscovery, we leak memory for those disc_ports queued.
So, go through the list of disc_ports even if doing full discovery.
Free the disc_ports in any case. If any of the disc_single() calls
return error, do a full discovery.
The ability to fill in GPN_ID requests was added to fc_ct_fill().
For this, it needs the FC_ID to be passed in as an arg.
The did parameter for fc_elsct_send() is used for that, since the
actual D_DID will always be 0xfffffc for all CT requests so far.
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>
2009-08-26 05:03:58 +08:00
|
|
|
new_rdata = lport->tt.rport_create(lport,
|
|
|
|
rdata->ids.port_id);
|
2016-09-30 17:01:15 +08:00
|
|
|
mutex_unlock(&lport->disc.disc_mutex);
|
[SCSI] libfc: send GPN_ID in reaction to single-port RSCNs.
When an RSCN indicates changes to individual remote ports,
don't blindly log them out and then back in. Instead, determine
whether they're still in the directory, by doing GPN_ID.
If that is successful, call login, which will send ADISC and reverify,
otherwise, call logoff. Perhaps we should just delete the rport,
not send LOGO, but it seems safer.
Also, fix a possible issue where if a mix of records in the RSCN
cause us to queue disc_ports for disc_single and then we decide
to do full rediscovery, we leak memory for those disc_ports queued.
So, go through the list of disc_ports even if doing full discovery.
Free the disc_ports in any case. If any of the disc_single() calls
return error, do a full discovery.
The ability to fill in GPN_ID requests was added to fc_ct_fill().
For this, it needs the FC_ID to be passed in as an arg.
The did parameter for fc_elsct_send() is used for that, since the
actual D_DID will always be 0xfffffc for all CT requests so far.
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>
2009-08-26 05:03:58 +08:00
|
|
|
if (new_rdata) {
|
|
|
|
new_rdata->disc_id = disc->disc_id;
|
|
|
|
lport->tt.rport_login(new_rdata);
|
|
|
|
}
|
|
|
|
goto out;
|
|
|
|
}
|
2009-08-26 05:02:11 +08:00
|
|
|
rdata->disc_id = disc->disc_id;
|
2016-09-30 17:01:15 +08:00
|
|
|
mutex_unlock(&rdata->rp_mutex);
|
2009-08-26 05:00:50 +08:00
|
|
|
lport->tt.rport_login(rdata);
|
[SCSI] libfc: send GPN_ID in reaction to single-port RSCNs.
When an RSCN indicates changes to individual remote ports,
don't blindly log them out and then back in. Instead, determine
whether they're still in the directory, by doing GPN_ID.
If that is successful, call login, which will send ADISC and reverify,
otherwise, call logoff. Perhaps we should just delete the rport,
not send LOGO, but it seems safer.
Also, fix a possible issue where if a mix of records in the RSCN
cause us to queue disc_ports for disc_single and then we decide
to do full rediscovery, we leak memory for those disc_ports queued.
So, go through the list of disc_ports even if doing full discovery.
Free the disc_ports in any case. If any of the disc_single() calls
return error, do a full discovery.
The ability to fill in GPN_ID requests was added to fc_ct_fill().
For this, it needs the FC_ID to be passed in as an arg.
The did parameter for fc_elsct_send() is used for that, since the
actual D_DID will always be 0xfffffc for all CT requests so far.
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>
2009-08-26 05:03:58 +08:00
|
|
|
} else if (ntohs(cp->ct_cmd) == FC_FS_RJT) {
|
|
|
|
FC_DISC_DBG(disc, "GPN_ID rejected reason %x exp %x\n",
|
|
|
|
cp->ct_reason, cp->ct_explan);
|
|
|
|
lport->tt.rport_logoff(rdata);
|
|
|
|
} else {
|
|
|
|
FC_DISC_DBG(disc, "GPN_ID unexpected response code %x\n",
|
|
|
|
ntohs(cp->ct_cmd));
|
|
|
|
redisc:
|
2016-09-30 17:01:15 +08:00
|
|
|
mutex_lock(&disc->disc_mutex);
|
[SCSI] libfc: send GPN_ID in reaction to single-port RSCNs.
When an RSCN indicates changes to individual remote ports,
don't blindly log them out and then back in. Instead, determine
whether they're still in the directory, by doing GPN_ID.
If that is successful, call login, which will send ADISC and reverify,
otherwise, call logoff. Perhaps we should just delete the rport,
not send LOGO, but it seems safer.
Also, fix a possible issue where if a mix of records in the RSCN
cause us to queue disc_ports for disc_single and then we decide
to do full rediscovery, we leak memory for those disc_ports queued.
So, go through the list of disc_ports even if doing full discovery.
Free the disc_ports in any case. If any of the disc_single() calls
return error, do a full discovery.
The ability to fill in GPN_ID requests was added to fc_ct_fill().
For this, it needs the FC_ID to be passed in as an arg.
The did parameter for fc_elsct_send() is used for that, since the
actual D_DID will always be 0xfffffc for all CT requests so far.
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>
2009-08-26 05:03:58 +08:00
|
|
|
fc_disc_restart(disc);
|
2016-09-30 17:01:15 +08:00
|
|
|
mutex_unlock(&disc->disc_mutex);
|
2008-12-10 07:10:17 +08:00
|
|
|
}
|
|
|
|
out:
|
[SCSI] libfc: send GPN_ID in reaction to single-port RSCNs.
When an RSCN indicates changes to individual remote ports,
don't blindly log them out and then back in. Instead, determine
whether they're still in the directory, by doing GPN_ID.
If that is successful, call login, which will send ADISC and reverify,
otherwise, call logoff. Perhaps we should just delete the rport,
not send LOGO, but it seems safer.
Also, fix a possible issue where if a mix of records in the RSCN
cause us to queue disc_ports for disc_single and then we decide
to do full rediscovery, we leak memory for those disc_ports queued.
So, go through the list of disc_ports even if doing full discovery.
Free the disc_ports in any case. If any of the disc_single() calls
return error, do a full discovery.
The ability to fill in GPN_ID requests was added to fc_ct_fill().
For this, it needs the FC_ID to be passed in as an arg.
The did parameter for fc_elsct_send() is used for that, since the
actual D_DID will always be 0xfffffc for all CT requests so far.
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>
2009-08-26 05:03:58 +08:00
|
|
|
kref_put(&rdata->kref, lport->tt.rport_destroy);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* fc_disc_gpn_id_req() - Send Get Port Names by ID (GPN_ID) request
|
2009-11-04 03:47:39 +08:00
|
|
|
* @lport: The local port to initiate discovery on
|
[SCSI] libfc: send GPN_ID in reaction to single-port RSCNs.
When an RSCN indicates changes to individual remote ports,
don't blindly log them out and then back in. Instead, determine
whether they're still in the directory, by doing GPN_ID.
If that is successful, call login, which will send ADISC and reverify,
otherwise, call logoff. Perhaps we should just delete the rport,
not send LOGO, but it seems safer.
Also, fix a possible issue where if a mix of records in the RSCN
cause us to queue disc_ports for disc_single and then we decide
to do full rediscovery, we leak memory for those disc_ports queued.
So, go through the list of disc_ports even if doing full discovery.
Free the disc_ports in any case. If any of the disc_single() calls
return error, do a full discovery.
The ability to fill in GPN_ID requests was added to fc_ct_fill().
For this, it needs the FC_ID to be passed in as an arg.
The did parameter for fc_elsct_send() is used for that, since the
actual D_DID will always be 0xfffffc for all CT requests so far.
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>
2009-08-26 05:03:58 +08:00
|
|
|
* @rdata: remote port private data
|
|
|
|
*
|
|
|
|
* Locking Note: This function expects that the disc_mutex is locked
|
|
|
|
* before it is called.
|
|
|
|
* On failure, an error code is returned.
|
|
|
|
*/
|
|
|
|
static int fc_disc_gpn_id_req(struct fc_lport *lport,
|
|
|
|
struct fc_rport_priv *rdata)
|
|
|
|
{
|
|
|
|
struct fc_frame *fp;
|
|
|
|
|
|
|
|
fp = fc_frame_alloc(lport, sizeof(struct fc_ct_hdr) +
|
|
|
|
sizeof(struct fc_ns_fid));
|
|
|
|
if (!fp)
|
|
|
|
return -ENOMEM;
|
|
|
|
if (!lport->tt.elsct_send(lport, rdata->ids.port_id, fp, FC_NS_GPN_ID,
|
2009-11-04 03:50:21 +08:00
|
|
|
fc_disc_gpn_id_resp, rdata,
|
|
|
|
3 * lport->r_a_tov))
|
[SCSI] libfc: send GPN_ID in reaction to single-port RSCNs.
When an RSCN indicates changes to individual remote ports,
don't blindly log them out and then back in. Instead, determine
whether they're still in the directory, by doing GPN_ID.
If that is successful, call login, which will send ADISC and reverify,
otherwise, call logoff. Perhaps we should just delete the rport,
not send LOGO, but it seems safer.
Also, fix a possible issue where if a mix of records in the RSCN
cause us to queue disc_ports for disc_single and then we decide
to do full rediscovery, we leak memory for those disc_ports queued.
So, go through the list of disc_ports even if doing full discovery.
Free the disc_ports in any case. If any of the disc_single() calls
return error, do a full discovery.
The ability to fill in GPN_ID requests was added to fc_ct_fill().
For this, it needs the FC_ID to be passed in as an arg.
The did parameter for fc_elsct_send() is used for that, since the
actual D_DID will always be 0xfffffc for all CT requests so far.
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>
2009-08-26 05:03:58 +08:00
|
|
|
return -ENOMEM;
|
|
|
|
kref_get(&rdata->kref);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* fc_disc_single() - Discover the directory information for a single target
|
2009-11-04 03:47:39 +08:00
|
|
|
* @lport: The local port the remote port is associated with
|
|
|
|
* @dp: The port to rediscover
|
[SCSI] libfc: send GPN_ID in reaction to single-port RSCNs.
When an RSCN indicates changes to individual remote ports,
don't blindly log them out and then back in. Instead, determine
whether they're still in the directory, by doing GPN_ID.
If that is successful, call login, which will send ADISC and reverify,
otherwise, call logoff. Perhaps we should just delete the rport,
not send LOGO, but it seems safer.
Also, fix a possible issue where if a mix of records in the RSCN
cause us to queue disc_ports for disc_single and then we decide
to do full rediscovery, we leak memory for those disc_ports queued.
So, go through the list of disc_ports even if doing full discovery.
Free the disc_ports in any case. If any of the disc_single() calls
return error, do a full discovery.
The ability to fill in GPN_ID requests was added to fc_ct_fill().
For this, it needs the FC_ID to be passed in as an arg.
The did parameter for fc_elsct_send() is used for that, since the
actual D_DID will always be 0xfffffc for all CT requests so far.
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>
2009-08-26 05:03:58 +08:00
|
|
|
*
|
|
|
|
* Locking Note: This function expects that the disc_mutex is locked
|
|
|
|
* before it is called.
|
|
|
|
*/
|
|
|
|
static int fc_disc_single(struct fc_lport *lport, struct fc_disc_port *dp)
|
|
|
|
{
|
|
|
|
struct fc_rport_priv *rdata;
|
|
|
|
|
|
|
|
rdata = lport->tt.rport_create(lport, dp->port_id);
|
|
|
|
if (!rdata)
|
|
|
|
return -ENOMEM;
|
|
|
|
rdata->disc_id = 0;
|
|
|
|
return fc_disc_gpn_id_req(lport, rdata);
|
2008-12-10 07:10:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-02-28 02:55:45 +08:00
|
|
|
* fc_disc_stop() - Stop discovery for a given lport
|
2009-11-04 03:47:39 +08:00
|
|
|
* @lport: The local port that discovery should stop on
|
2008-12-10 07:10:17 +08:00
|
|
|
*/
|
2012-01-14 09:26:20 +08:00
|
|
|
static void fc_disc_stop(struct fc_lport *lport)
|
2008-12-10 07:10:17 +08:00
|
|
|
{
|
|
|
|
struct fc_disc *disc = &lport->disc;
|
|
|
|
|
2010-10-09 08:12:36 +08:00
|
|
|
if (disc->pending)
|
2008-12-10 07:10:17 +08:00
|
|
|
cancel_delayed_work_sync(&disc->disc_work);
|
2010-10-09 08:12:36 +08:00
|
|
|
fc_disc_stop_rports(disc);
|
2008-12-10 07:10:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-02-28 02:55:45 +08:00
|
|
|
* fc_disc_stop_final() - Stop discovery for a given lport
|
2009-11-04 03:47:39 +08:00
|
|
|
* @lport: The lport that discovery should stop on
|
2008-12-10 07:10:17 +08:00
|
|
|
*
|
|
|
|
* This function will block until discovery has been
|
|
|
|
* completely stopped and all rports have been deleted.
|
|
|
|
*/
|
2012-01-14 09:26:20 +08:00
|
|
|
static void fc_disc_stop_final(struct fc_lport *lport)
|
2008-12-10 07:10:17 +08:00
|
|
|
{
|
|
|
|
fc_disc_stop(lport);
|
|
|
|
lport->tt.rport_flush_queue();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-03-26 02:00:28 +08:00
|
|
|
* fc_disc_config() - Configure the discovery layer for a local port
|
|
|
|
* @lport: The local port that needs the discovery layer to be configured
|
2013-03-26 02:00:27 +08:00
|
|
|
* @priv: Private data structre for users of the discovery layer
|
2008-12-10 07:10:17 +08:00
|
|
|
*/
|
2013-03-26 02:00:28 +08:00
|
|
|
void fc_disc_config(struct fc_lport *lport, void *priv)
|
2008-12-10 07:10:17 +08:00
|
|
|
{
|
2013-03-26 02:00:28 +08:00
|
|
|
struct fc_disc *disc = &lport->disc;
|
2008-12-10 07:10:17 +08:00
|
|
|
|
|
|
|
if (!lport->tt.disc_start)
|
|
|
|
lport->tt.disc_start = fc_disc_start;
|
|
|
|
|
|
|
|
if (!lport->tt.disc_stop)
|
|
|
|
lport->tt.disc_stop = fc_disc_stop;
|
|
|
|
|
|
|
|
if (!lport->tt.disc_stop_final)
|
|
|
|
lport->tt.disc_stop_final = fc_disc_stop_final;
|
|
|
|
|
|
|
|
if (!lport->tt.disc_recv_req)
|
|
|
|
lport->tt.disc_recv_req = fc_disc_recv_req;
|
|
|
|
|
|
|
|
disc = &lport->disc;
|
|
|
|
|
2013-03-26 02:00:27 +08:00
|
|
|
disc->priv = priv;
|
2013-03-26 02:00:28 +08:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(fc_disc_config);
|
2008-12-10 07:10:17 +08:00
|
|
|
|
2013-03-26 02:00:28 +08:00
|
|
|
/**
|
|
|
|
* fc_disc_init() - Initialize the discovery layer for a local port
|
|
|
|
* @lport: The local port that needs the discovery layer to be initialized
|
|
|
|
*/
|
|
|
|
void fc_disc_init(struct fc_lport *lport)
|
|
|
|
{
|
|
|
|
struct fc_disc *disc = &lport->disc;
|
|
|
|
|
|
|
|
INIT_DELAYED_WORK(&disc->disc_work, fc_disc_timeout);
|
|
|
|
mutex_init(&disc->disc_mutex);
|
|
|
|
INIT_LIST_HEAD(&disc->rports);
|
2008-12-10 07:10:17 +08:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(fc_disc_init);
|