mirror of
https://github.com/AetherDroid/android_kernel_samsung_on5xelte.git
synced 2025-09-08 17:18:05 -04:00
Fixed MTP to work with TWRP
This commit is contained in:
commit
f6dfaef42e
50820 changed files with 20846062 additions and 0 deletions
14
drivers/scsi/libfc/Makefile
Normal file
14
drivers/scsi/libfc/Makefile
Normal file
|
@ -0,0 +1,14 @@
|
|||
# $Id: Makefile
|
||||
|
||||
obj-$(CONFIG_LIBFC) += libfc.o
|
||||
|
||||
libfc-objs := \
|
||||
fc_libfc.o \
|
||||
fc_disc.o \
|
||||
fc_exch.o \
|
||||
fc_elsct.o \
|
||||
fc_frame.o \
|
||||
fc_lport.o \
|
||||
fc_rport.o \
|
||||
fc_fcp.o \
|
||||
fc_npiv.o
|
753
drivers/scsi/libfc/fc_disc.c
Normal file
753
drivers/scsi/libfc/fc_disc.c
Normal file
|
@ -0,0 +1,753 @@
|
|||
/*
|
||||
* 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 <linux/slab.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/export.h>
|
||||
#include <asm/unaligned.h>
|
||||
|
||||
#include <scsi/fc/fc_gs.h>
|
||||
|
||||
#include <scsi/libfc.h>
|
||||
|
||||
#include "fc_libfc.h"
|
||||
|
||||
#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 *);
|
||||
static void fc_disc_done(struct fc_disc *, enum fc_disc_event);
|
||||
static void fc_disc_timeout(struct work_struct *);
|
||||
static int fc_disc_single(struct fc_lport *, struct fc_disc_port *);
|
||||
static void fc_disc_restart(struct fc_disc *);
|
||||
|
||||
/**
|
||||
* fc_disc_stop_rports() - Delete all the remote ports associated with the lport
|
||||
* @disc: The discovery job to stop remote ports on
|
||||
*
|
||||
* Locking Note: This function expects that the lport mutex is locked before
|
||||
* calling it.
|
||||
*/
|
||||
static void fc_disc_stop_rports(struct fc_disc *disc)
|
||||
{
|
||||
struct fc_lport *lport;
|
||||
struct fc_rport_priv *rdata;
|
||||
|
||||
lport = fc_disc_lport(disc);
|
||||
|
||||
mutex_lock(&disc->disc_mutex);
|
||||
list_for_each_entry_rcu(rdata, &disc->rports, peers)
|
||||
lport->tt.rport_logoff(rdata);
|
||||
mutex_unlock(&disc->disc_mutex);
|
||||
}
|
||||
|
||||
/**
|
||||
* fc_disc_recv_rscn_req() - Handle Registered State Change Notification (RSCN)
|
||||
* @disc: The discovery object to which the RSCN applies
|
||||
* @fp: The RSCN frame
|
||||
*
|
||||
* Locking Note: This function expects that the disc_mutex is locked
|
||||
* before it is called.
|
||||
*/
|
||||
static void fc_disc_recv_rscn_req(struct fc_disc *disc, struct fc_frame *fp)
|
||||
{
|
||||
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;
|
||||
|
||||
lport = fc_disc_lport(disc);
|
||||
|
||||
FC_DISC_DBG(disc, "Received an RSCN event\n");
|
||||
|
||||
/* 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:
|
||||
FC_DISC_DBG(disc, "Port address format for port "
|
||||
"(%6.6x)\n", ntoh24(pp->rscn_fid));
|
||||
dp = kzalloc(sizeof(*dp), GFP_KERNEL);
|
||||
if (!dp) {
|
||||
redisc = 1;
|
||||
break;
|
||||
}
|
||||
dp->lp = lport;
|
||||
dp->port_id = ntoh24(pp->rscn_fid);
|
||||
list_add_tail(&dp->peers, &disc_ports);
|
||||
break;
|
||||
case ELS_ADDR_FMT_AREA:
|
||||
case ELS_ADDR_FMT_DOM:
|
||||
case ELS_ADDR_FMT_FAB:
|
||||
default:
|
||||
FC_DISC_DBG(disc, "Address format is (%d)\n", fmt);
|
||||
redisc = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
lport->tt.seq_els_rsp_send(fp, ELS_LS_ACC, NULL);
|
||||
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
if (redisc) {
|
||||
FC_DISC_DBG(disc, "RSCN received: rediscovering\n");
|
||||
fc_disc_restart(disc);
|
||||
} else {
|
||||
FC_DISC_DBG(disc, "RSCN received: not rediscovering. "
|
||||
"redisc %d state %d in_prog %d\n",
|
||||
redisc, lport->state, disc->pending);
|
||||
}
|
||||
fc_frame_free(fp);
|
||||
return;
|
||||
reject:
|
||||
FC_DISC_DBG(disc, "Received a bad RSCN frame\n");
|
||||
rjt_data.reason = ELS_RJT_LOGIC;
|
||||
rjt_data.explan = ELS_EXPL_NONE;
|
||||
lport->tt.seq_els_rsp_send(fp, ELS_LS_RJT, &rjt_data);
|
||||
fc_frame_free(fp);
|
||||
}
|
||||
|
||||
/**
|
||||
* fc_disc_recv_req() - Handle incoming requests
|
||||
* @lport: The local port receiving the request
|
||||
* @fp: The request frame
|
||||
*
|
||||
* Locking Note: This function is called from the EM and will lock
|
||||
* the disc_mutex before calling the handler for the
|
||||
* request.
|
||||
*/
|
||||
static void fc_disc_recv_req(struct fc_lport *lport, struct fc_frame *fp)
|
||||
{
|
||||
u8 op;
|
||||
struct fc_disc *disc = &lport->disc;
|
||||
|
||||
op = fc_frame_payload_op(fp);
|
||||
switch (op) {
|
||||
case ELS_RSCN:
|
||||
mutex_lock(&disc->disc_mutex);
|
||||
fc_disc_recv_rscn_req(disc, fp);
|
||||
mutex_unlock(&disc->disc_mutex);
|
||||
break;
|
||||
default:
|
||||
FC_DISC_DBG(disc, "Received an unsupported request, "
|
||||
"the opcode is (%x)\n", op);
|
||||
fc_frame_free(fp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* fc_disc_restart() - Restart discovery
|
||||
* @disc: The discovery object to be restarted
|
||||
*
|
||||
* Locking Note: This function expects that the disc mutex
|
||||
* is already locked.
|
||||
*/
|
||||
static void fc_disc_restart(struct fc_disc *disc)
|
||||
{
|
||||
if (!disc->disc_callback)
|
||||
return;
|
||||
|
||||
FC_DISC_DBG(disc, "Restarting discovery\n");
|
||||
|
||||
disc->requested = 1;
|
||||
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;
|
||||
disc->retry_count = 0;
|
||||
fc_disc_gpn_ft_req(disc);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
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;
|
||||
fc_disc_restart(disc);
|
||||
mutex_unlock(&disc->disc_mutex);
|
||||
}
|
||||
|
||||
/**
|
||||
* fc_disc_done() - Discovery has been completed
|
||||
* @disc: The discovery context
|
||||
* @event: The discovery completion status
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
static void fc_disc_done(struct fc_disc *disc, enum fc_disc_event event)
|
||||
{
|
||||
struct fc_lport *lport = fc_disc_lport(disc);
|
||||
struct fc_rport_priv *rdata;
|
||||
|
||||
FC_DISC_DBG(disc, "Discovery complete\n");
|
||||
|
||||
disc->pending = 0;
|
||||
if (disc->requested) {
|
||||
fc_disc_restart(disc);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Go through all remote ports. If they were found in the latest
|
||||
* discovery, reverify or log them in. Otherwise, log them out.
|
||||
* Skip ports which were never discovered. These are the dNS port
|
||||
* and ports which were created by PLOGI.
|
||||
*/
|
||||
list_for_each_entry_rcu(rdata, &disc->rports, peers) {
|
||||
if (!rdata->disc_id)
|
||||
continue;
|
||||
if (rdata->disc_id == disc->disc_id)
|
||||
lport->tt.rport_login(rdata);
|
||||
else
|
||||
lport->tt.rport_logoff(rdata);
|
||||
}
|
||||
|
||||
mutex_unlock(&disc->disc_mutex);
|
||||
disc->disc_callback(lport, event);
|
||||
mutex_lock(&disc->disc_mutex);
|
||||
}
|
||||
|
||||
/**
|
||||
* fc_disc_error() - Handle error on dNS request
|
||||
* @disc: The discovery context
|
||||
* @fp: The error code encoded as a frame pointer
|
||||
*/
|
||||
static void fc_disc_error(struct fc_disc *disc, struct fc_frame *fp)
|
||||
{
|
||||
struct fc_lport *lport = fc_disc_lport(disc);
|
||||
unsigned long delay = 0;
|
||||
|
||||
FC_DISC_DBG(disc, "Error %ld, retries %d/%d\n",
|
||||
PTR_ERR(fp), disc->retry_count,
|
||||
FC_DISC_RETRY_LIMIT);
|
||||
|
||||
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);
|
||||
} else
|
||||
fc_disc_done(disc, DISC_EV_FAILED);
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* fc_disc_gpn_ft_req() - Send Get Port Names by FC-4 type (GPN_FT) request
|
||||
* @lport: The discovery context
|
||||
*
|
||||
* 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;
|
||||
struct fc_lport *lport = fc_disc_lport(disc);
|
||||
|
||||
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;
|
||||
|
||||
if (lport->tt.elsct_send(lport, 0, fp,
|
||||
FC_NS_GPN_FT,
|
||||
fc_disc_gpn_ft_resp,
|
||||
disc, 3 * lport->r_a_tov))
|
||||
return;
|
||||
err:
|
||||
fc_disc_error(disc, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* fc_disc_gpn_ft_parse() - Parse the body of the dNS GPN_FT response.
|
||||
* @lport: The local port the GPN_FT was received on
|
||||
* @buf: The GPN_FT response buffer
|
||||
* @len: The size of response buffer
|
||||
*
|
||||
* Goes through the list of IDs and names resulting from a request.
|
||||
*/
|
||||
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;
|
||||
struct fc_rport_identifiers ids;
|
||||
struct fc_rport_priv *rdata;
|
||||
|
||||
lport = fc_disc_lport(disc);
|
||||
disc->seq_count++;
|
||||
|
||||
/*
|
||||
* Handle partial name record left over from previous call.
|
||||
*/
|
||||
bp = buf;
|
||||
plen = len;
|
||||
np = (struct fc_gpn_ft_resp *)bp;
|
||||
tlen = disc->buf_len;
|
||||
disc->buf_len = 0;
|
||||
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)) {
|
||||
ids.port_id = ntoh24(np->fp_fid);
|
||||
ids.port_name = ntohll(np->fp_wwpn);
|
||||
|
||||
if (ids.port_id != lport->port_id &&
|
||||
ids.port_name != lport->wwpn) {
|
||||
rdata = lport->tt.rport_create(lport, ids.port_id);
|
||||
if (rdata) {
|
||||
rdata->ids.port_name = ids.port_name;
|
||||
rdata->disc_id = disc->disc_id;
|
||||
} else {
|
||||
printk(KERN_WARNING "libfc: Failed to allocate "
|
||||
"memory for the newly discovered port "
|
||||
"(%6.6x)\n", ids.port_id);
|
||||
error = -ENOMEM;
|
||||
}
|
||||
}
|
||||
|
||||
if (np->fp_flags & FC_NS_FID_LAST) {
|
||||
fc_disc_done(disc, DISC_EV_SUCCESS);
|
||||
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) {
|
||||
FC_DISC_DBG(disc, "Partial buffer remains "
|
||||
"for discovery\n");
|
||||
memcpy(&disc->partial_buf, np, len);
|
||||
}
|
||||
disc->buf_len = (unsigned char) len;
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
/**
|
||||
* fc_disc_timeout() - Handler for discovery timeouts
|
||||
* @work: Structure holding discovery context that needs to retry discovery
|
||||
*/
|
||||
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);
|
||||
fc_disc_gpn_ft_req(disc);
|
||||
mutex_unlock(&disc->disc_mutex);
|
||||
}
|
||||
|
||||
/**
|
||||
* fc_disc_gpn_ft_resp() - Handle a response frame from Get Port Names (GPN_FT)
|
||||
* @sp: The sequence that the GPN_FT response was received on
|
||||
* @fp: The GPN_FT response frame
|
||||
* @lp_arg: The discovery context
|
||||
*
|
||||
* Locking Note: This function is called without disc mutex held, and
|
||||
* should do all its processing with the mutex held
|
||||
*/
|
||||
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;
|
||||
enum fc_disc_event event = DISC_EV_NONE;
|
||||
unsigned int seq_cnt;
|
||||
unsigned int len;
|
||||
int error = 0;
|
||||
|
||||
mutex_lock(&disc->disc_mutex);
|
||||
FC_DISC_DBG(disc, "Received a GPN_FT response\n");
|
||||
|
||||
if (IS_ERR(fp)) {
|
||||
fc_disc_error(disc, fp);
|
||||
mutex_unlock(&disc->disc_mutex);
|
||||
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);
|
||||
if (fr_sof(fp) == FC_SOF_I3 && seq_cnt == 0 && disc->seq_count == 0) {
|
||||
cp = fc_frame_payload_get(fp, sizeof(*cp));
|
||||
if (!cp) {
|
||||
FC_DISC_DBG(disc, "GPN_FT response too short, len %d\n",
|
||||
fr_len(fp));
|
||||
event = DISC_EV_FAILED;
|
||||
} else if (ntohs(cp->ct_cmd) == FC_FS_ACC) {
|
||||
|
||||
/* Accepted, parse the response. */
|
||||
len -= sizeof(*cp);
|
||||
error = fc_disc_gpn_ft_parse(disc, cp + 1, len);
|
||||
} else if (ntohs(cp->ct_cmd) == FC_FS_RJT) {
|
||||
FC_DISC_DBG(disc, "GPN_FT rejected reason %x exp %x "
|
||||
"(check zoning)\n", cp->ct_reason,
|
||||
cp->ct_explan);
|
||||
event = DISC_EV_FAILED;
|
||||
if (cp->ct_reason == FC_FS_RJT_UNABL &&
|
||||
cp->ct_explan == FC_FS_EXP_FTNR)
|
||||
event = DISC_EV_SUCCESS;
|
||||
} else {
|
||||
FC_DISC_DBG(disc, "GPN_FT unexpected response code "
|
||||
"%x\n", ntohs(cp->ct_cmd));
|
||||
event = DISC_EV_FAILED;
|
||||
}
|
||||
} else if (fr_sof(fp) == FC_SOF_N3 && seq_cnt == disc->seq_count) {
|
||||
error = fc_disc_gpn_ft_parse(disc, fh + 1, len);
|
||||
} else {
|
||||
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));
|
||||
event = DISC_EV_FAILED;
|
||||
}
|
||||
if (error)
|
||||
fc_disc_error(disc, fp);
|
||||
else if (event != DISC_EV_NONE)
|
||||
fc_disc_done(disc, event);
|
||||
fc_frame_free(fp);
|
||||
mutex_unlock(&disc->disc_mutex);
|
||||
}
|
||||
|
||||
/**
|
||||
* fc_disc_gpn_id_resp() - Handle a response frame from Get Port Names (GPN_ID)
|
||||
* @sp: The sequence the GPN_ID is on
|
||||
* @fp: The response frame
|
||||
* @rdata_arg: The remote port that sent the GPN_ID response
|
||||
*
|
||||
* Locking Note: This function is called without disc mutex held.
|
||||
*/
|
||||
static void fc_disc_gpn_id_resp(struct fc_seq *sp, struct fc_frame *fp,
|
||||
void *rdata_arg)
|
||||
{
|
||||
struct fc_rport_priv *rdata = rdata_arg;
|
||||
struct fc_rport_priv *new_rdata;
|
||||
struct fc_lport *lport;
|
||||
struct fc_disc *disc;
|
||||
struct fc_ct_hdr *cp;
|
||||
struct fc_ns_gid_pn *pn;
|
||||
u64 port_name;
|
||||
|
||||
lport = rdata->local_port;
|
||||
disc = &lport->disc;
|
||||
|
||||
mutex_lock(&disc->disc_mutex);
|
||||
if (PTR_ERR(fp) == -FC_EX_CLOSED)
|
||||
goto out;
|
||||
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);
|
||||
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. "
|
||||
"Port-id %6.6x wwpn %16.16llx\n",
|
||||
rdata->ids.port_id, port_name);
|
||||
lport->tt.rport_logoff(rdata);
|
||||
|
||||
new_rdata = lport->tt.rport_create(lport,
|
||||
rdata->ids.port_id);
|
||||
if (new_rdata) {
|
||||
new_rdata->disc_id = disc->disc_id;
|
||||
lport->tt.rport_login(new_rdata);
|
||||
}
|
||||
goto out;
|
||||
}
|
||||
rdata->disc_id = disc->disc_id;
|
||||
lport->tt.rport_login(rdata);
|
||||
} 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:
|
||||
fc_disc_restart(disc);
|
||||
}
|
||||
out:
|
||||
mutex_unlock(&disc->disc_mutex);
|
||||
kref_put(&rdata->kref, lport->tt.rport_destroy);
|
||||
}
|
||||
|
||||
/**
|
||||
* fc_disc_gpn_id_req() - Send Get Port Names by ID (GPN_ID) request
|
||||
* @lport: The local port to initiate discovery on
|
||||
* @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,
|
||||
fc_disc_gpn_id_resp, rdata,
|
||||
3 * lport->r_a_tov))
|
||||
return -ENOMEM;
|
||||
kref_get(&rdata->kref);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* fc_disc_single() - Discover the directory information for a single target
|
||||
* @lport: The local port the remote port is associated with
|
||||
* @dp: The port to rediscover
|
||||
*
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* fc_disc_stop() - Stop discovery for a given lport
|
||||
* @lport: The local port that discovery should stop on
|
||||
*/
|
||||
static void fc_disc_stop(struct fc_lport *lport)
|
||||
{
|
||||
struct fc_disc *disc = &lport->disc;
|
||||
|
||||
if (disc->pending)
|
||||
cancel_delayed_work_sync(&disc->disc_work);
|
||||
fc_disc_stop_rports(disc);
|
||||
}
|
||||
|
||||
/**
|
||||
* fc_disc_stop_final() - Stop discovery for a given lport
|
||||
* @lport: The lport that discovery should stop on
|
||||
*
|
||||
* This function will block until discovery has been
|
||||
* completely stopped and all rports have been deleted.
|
||||
*/
|
||||
static void fc_disc_stop_final(struct fc_lport *lport)
|
||||
{
|
||||
fc_disc_stop(lport);
|
||||
lport->tt.rport_flush_queue();
|
||||
}
|
||||
|
||||
/**
|
||||
* fc_disc_config() - Configure the discovery layer for a local port
|
||||
* @lport: The local port that needs the discovery layer to be configured
|
||||
* @priv: Private data structre for users of the discovery layer
|
||||
*/
|
||||
void fc_disc_config(struct fc_lport *lport, void *priv)
|
||||
{
|
||||
struct fc_disc *disc = &lport->disc;
|
||||
|
||||
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;
|
||||
|
||||
disc->priv = priv;
|
||||
}
|
||||
EXPORT_SYMBOL(fc_disc_config);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
EXPORT_SYMBOL(fc_disc_init);
|
152
drivers/scsi/libfc/fc_elsct.c
Normal file
152
drivers/scsi/libfc/fc_elsct.c
Normal file
|
@ -0,0 +1,152 @@
|
|||
/*
|
||||
* Copyright(c) 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
|
||||
*/
|
||||
|
||||
/*
|
||||
* Provide interface to send ELS/CT FC frames
|
||||
*/
|
||||
|
||||
#include <linux/export.h>
|
||||
#include <asm/unaligned.h>
|
||||
#include <scsi/fc/fc_gs.h>
|
||||
#include <scsi/fc/fc_ns.h>
|
||||
#include <scsi/fc/fc_els.h>
|
||||
#include <scsi/libfc.h>
|
||||
#include <scsi/fc_encode.h>
|
||||
#include "fc_libfc.h"
|
||||
|
||||
/**
|
||||
* fc_elsct_send() - Send an ELS or CT frame
|
||||
* @lport: The local port to send the frame on
|
||||
* @did: The destination ID for the frame
|
||||
* @fp: The frame to be sent
|
||||
* @op: The operational code
|
||||
* @resp: The callback routine when the response is received
|
||||
* @arg: The argument to pass to the response callback routine
|
||||
* @timer_msec: The timeout period for the frame (in msecs)
|
||||
*/
|
||||
struct fc_seq *fc_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 timer_msec)
|
||||
{
|
||||
enum fc_rctl r_ctl;
|
||||
enum fc_fh_type fh_type;
|
||||
int rc;
|
||||
|
||||
/* ELS requests */
|
||||
if ((op >= ELS_LS_RJT) && (op <= ELS_AUTH_ELS))
|
||||
rc = fc_els_fill(lport, did, fp, op, &r_ctl, &fh_type);
|
||||
else {
|
||||
/* CT requests */
|
||||
rc = fc_ct_fill(lport, did, fp, op, &r_ctl, &fh_type, &did);
|
||||
}
|
||||
|
||||
if (rc) {
|
||||
fc_frame_free(fp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fc_fill_fc_hdr(fp, r_ctl, did, lport->port_id, fh_type,
|
||||
FC_FCTL_REQ, 0);
|
||||
|
||||
return lport->tt.exch_seq_send(lport, fp, resp, NULL, arg, timer_msec);
|
||||
}
|
||||
EXPORT_SYMBOL(fc_elsct_send);
|
||||
|
||||
/**
|
||||
* fc_elsct_init() - Initialize the ELS/CT layer
|
||||
* @lport: The local port to initialize the ELS/CT layer for
|
||||
*/
|
||||
int fc_elsct_init(struct fc_lport *lport)
|
||||
{
|
||||
if (!lport->tt.elsct_send)
|
||||
lport->tt.elsct_send = fc_elsct_send;
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(fc_elsct_init);
|
||||
|
||||
/**
|
||||
* fc_els_resp_type() - Return a string describing the ELS response
|
||||
* @fp: The frame pointer or possible error code
|
||||
*/
|
||||
const char *fc_els_resp_type(struct fc_frame *fp)
|
||||
{
|
||||
const char *msg;
|
||||
struct fc_frame_header *fh;
|
||||
struct fc_ct_hdr *ct;
|
||||
|
||||
if (IS_ERR(fp)) {
|
||||
switch (-PTR_ERR(fp)) {
|
||||
case FC_NO_ERR:
|
||||
msg = "response no error";
|
||||
break;
|
||||
case FC_EX_TIMEOUT:
|
||||
msg = "response timeout";
|
||||
break;
|
||||
case FC_EX_CLOSED:
|
||||
msg = "response closed";
|
||||
break;
|
||||
default:
|
||||
msg = "response unknown error";
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
fh = fc_frame_header_get(fp);
|
||||
switch (fh->fh_type) {
|
||||
case FC_TYPE_ELS:
|
||||
switch (fc_frame_payload_op(fp)) {
|
||||
case ELS_LS_ACC:
|
||||
msg = "accept";
|
||||
break;
|
||||
case ELS_LS_RJT:
|
||||
msg = "reject";
|
||||
break;
|
||||
default:
|
||||
msg = "response unknown ELS";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case FC_TYPE_CT:
|
||||
ct = fc_frame_payload_get(fp, sizeof(*ct));
|
||||
if (ct) {
|
||||
switch (ntohs(ct->ct_cmd)) {
|
||||
case FC_FS_ACC:
|
||||
msg = "CT accept";
|
||||
break;
|
||||
case FC_FS_RJT:
|
||||
msg = "CT reject";
|
||||
break;
|
||||
default:
|
||||
msg = "response unknown CT";
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
msg = "short CT response";
|
||||
}
|
||||
break;
|
||||
default:
|
||||
msg = "response not ELS or CT";
|
||||
break;
|
||||
}
|
||||
}
|
||||
return msg;
|
||||
}
|
2631
drivers/scsi/libfc/fc_exch.c
Normal file
2631
drivers/scsi/libfc/fc_exch.c
Normal file
File diff suppressed because it is too large
Load diff
2295
drivers/scsi/libfc/fc_fcp.c
Normal file
2295
drivers/scsi/libfc/fc_fcp.c
Normal file
File diff suppressed because it is too large
Load diff
91
drivers/scsi/libfc/fc_frame.c
Normal file
91
drivers/scsi/libfc/fc_frame.c
Normal file
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* Copyright(c) 2007 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
|
||||
*/
|
||||
|
||||
/*
|
||||
* Frame allocation.
|
||||
*/
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/skbuff.h>
|
||||
#include <linux/crc32.h>
|
||||
#include <linux/gfp.h>
|
||||
|
||||
#include <scsi/fc_frame.h>
|
||||
|
||||
/*
|
||||
* Check the CRC in a frame.
|
||||
*/
|
||||
u32 fc_frame_crc_check(struct fc_frame *fp)
|
||||
{
|
||||
u32 crc;
|
||||
u32 error;
|
||||
const u8 *bp;
|
||||
unsigned int len;
|
||||
|
||||
WARN_ON(!fc_frame_is_linear(fp));
|
||||
fr_flags(fp) &= ~FCPHF_CRC_UNCHECKED;
|
||||
len = (fr_len(fp) + 3) & ~3; /* round up length to include fill */
|
||||
bp = (const u8 *) fr_hdr(fp);
|
||||
crc = ~crc32(~0, bp, len);
|
||||
error = crc ^ fr_crc(fp);
|
||||
return error;
|
||||
}
|
||||
EXPORT_SYMBOL(fc_frame_crc_check);
|
||||
|
||||
/*
|
||||
* Allocate a frame intended to be sent.
|
||||
* Get an sk_buff for the frame and set the length.
|
||||
*/
|
||||
struct fc_frame *_fc_frame_alloc(size_t len)
|
||||
{
|
||||
struct fc_frame *fp;
|
||||
struct sk_buff *skb;
|
||||
|
||||
WARN_ON((len % sizeof(u32)) != 0);
|
||||
len += sizeof(struct fc_frame_header);
|
||||
skb = alloc_skb_fclone(len + FC_FRAME_HEADROOM + FC_FRAME_TAILROOM +
|
||||
NET_SKB_PAD, GFP_ATOMIC);
|
||||
if (!skb)
|
||||
return NULL;
|
||||
skb_reserve(skb, NET_SKB_PAD + FC_FRAME_HEADROOM);
|
||||
fp = (struct fc_frame *) skb;
|
||||
fc_frame_init(fp);
|
||||
skb_put(skb, len);
|
||||
return fp;
|
||||
}
|
||||
EXPORT_SYMBOL(_fc_frame_alloc);
|
||||
|
||||
struct fc_frame *fc_frame_alloc_fill(struct fc_lport *lp, size_t payload_len)
|
||||
{
|
||||
struct fc_frame *fp;
|
||||
size_t fill;
|
||||
|
||||
fill = payload_len % 4;
|
||||
if (fill != 0)
|
||||
fill = 4 - fill;
|
||||
fp = _fc_frame_alloc(payload_len + fill);
|
||||
if (fp) {
|
||||
memset((char *) fr_hdr(fp) + payload_len, 0, fill);
|
||||
/* trim is OK, we just allocated it so there are no fragments */
|
||||
skb_trim(fp_skb(fp),
|
||||
payload_len + sizeof(struct fc_frame_header));
|
||||
}
|
||||
return fp;
|
||||
}
|
||||
EXPORT_SYMBOL(fc_frame_alloc_fill);
|
331
drivers/scsi/libfc/fc_libfc.c
Normal file
331
drivers/scsi/libfc/fc_libfc.c
Normal file
|
@ -0,0 +1,331 @@
|
|||
/*
|
||||
* Copyright(c) 2009 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
|
||||
*/
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/scatterlist.h>
|
||||
#include <linux/crc32.h>
|
||||
#include <linux/module.h>
|
||||
|
||||
#include <scsi/libfc.h>
|
||||
#include <scsi/fc_encode.h>
|
||||
|
||||
#include "fc_libfc.h"
|
||||
|
||||
MODULE_AUTHOR("Open-FCoE.org");
|
||||
MODULE_DESCRIPTION("libfc");
|
||||
MODULE_LICENSE("GPL v2");
|
||||
|
||||
unsigned int fc_debug_logging;
|
||||
module_param_named(debug_logging, fc_debug_logging, int, S_IRUGO|S_IWUSR);
|
||||
MODULE_PARM_DESC(debug_logging, "a bit mask of logging levels");
|
||||
|
||||
DEFINE_MUTEX(fc_prov_mutex);
|
||||
static LIST_HEAD(fc_local_ports);
|
||||
struct blocking_notifier_head fc_lport_notifier_head =
|
||||
BLOCKING_NOTIFIER_INIT(fc_lport_notifier_head);
|
||||
EXPORT_SYMBOL(fc_lport_notifier_head);
|
||||
|
||||
/*
|
||||
* Providers which primarily send requests and PRLIs.
|
||||
*/
|
||||
struct fc4_prov *fc_active_prov[FC_FC4_PROV_SIZE] = {
|
||||
[0] = &fc_rport_t0_prov,
|
||||
[FC_TYPE_FCP] = &fc_rport_fcp_init,
|
||||
};
|
||||
|
||||
/*
|
||||
* Providers which receive requests.
|
||||
*/
|
||||
struct fc4_prov *fc_passive_prov[FC_FC4_PROV_SIZE] = {
|
||||
[FC_TYPE_ELS] = &fc_lport_els_prov,
|
||||
};
|
||||
|
||||
/**
|
||||
* libfc_init() - Initialize libfc.ko
|
||||
*/
|
||||
static int __init libfc_init(void)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
rc = fc_setup_fcp();
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
rc = fc_setup_exch_mgr();
|
||||
if (rc)
|
||||
goto destroy_pkt_cache;
|
||||
|
||||
rc = fc_setup_rport();
|
||||
if (rc)
|
||||
goto destroy_em;
|
||||
|
||||
return rc;
|
||||
destroy_em:
|
||||
fc_destroy_exch_mgr();
|
||||
destroy_pkt_cache:
|
||||
fc_destroy_fcp();
|
||||
return rc;
|
||||
}
|
||||
module_init(libfc_init);
|
||||
|
||||
/**
|
||||
* libfc_exit() - Tear down libfc.ko
|
||||
*/
|
||||
static void __exit libfc_exit(void)
|
||||
{
|
||||
fc_destroy_fcp();
|
||||
fc_destroy_exch_mgr();
|
||||
fc_destroy_rport();
|
||||
}
|
||||
module_exit(libfc_exit);
|
||||
|
||||
/**
|
||||
* fc_copy_buffer_to_sglist() - This routine copies the data of a buffer
|
||||
* into a scatter-gather list (SG list).
|
||||
*
|
||||
* @buf: pointer to the data buffer.
|
||||
* @len: the byte-length of the data buffer.
|
||||
* @sg: pointer to the pointer of the SG list.
|
||||
* @nents: pointer to the remaining number of entries in the SG list.
|
||||
* @offset: pointer to the current offset in the SG list.
|
||||
* @crc: pointer to the 32-bit crc value.
|
||||
* If crc is NULL, CRC is not calculated.
|
||||
*/
|
||||
u32 fc_copy_buffer_to_sglist(void *buf, size_t len,
|
||||
struct scatterlist *sg,
|
||||
u32 *nents, size_t *offset,
|
||||
u32 *crc)
|
||||
{
|
||||
size_t remaining = len;
|
||||
u32 copy_len = 0;
|
||||
|
||||
while (remaining > 0 && sg) {
|
||||
size_t off, sg_bytes;
|
||||
void *page_addr;
|
||||
|
||||
if (*offset >= sg->length) {
|
||||
/*
|
||||
* Check for end and drop resources
|
||||
* from the last iteration.
|
||||
*/
|
||||
if (!(*nents))
|
||||
break;
|
||||
--(*nents);
|
||||
*offset -= sg->length;
|
||||
sg = sg_next(sg);
|
||||
continue;
|
||||
}
|
||||
sg_bytes = min(remaining, sg->length - *offset);
|
||||
|
||||
/*
|
||||
* The scatterlist item may be bigger than PAGE_SIZE,
|
||||
* but we are limited to mapping PAGE_SIZE at a time.
|
||||
*/
|
||||
off = *offset + sg->offset;
|
||||
sg_bytes = min(sg_bytes,
|
||||
(size_t)(PAGE_SIZE - (off & ~PAGE_MASK)));
|
||||
page_addr = kmap_atomic(sg_page(sg) + (off >> PAGE_SHIFT));
|
||||
if (crc)
|
||||
*crc = crc32(*crc, buf, sg_bytes);
|
||||
memcpy((char *)page_addr + (off & ~PAGE_MASK), buf, sg_bytes);
|
||||
kunmap_atomic(page_addr);
|
||||
buf += sg_bytes;
|
||||
*offset += sg_bytes;
|
||||
remaining -= sg_bytes;
|
||||
copy_len += sg_bytes;
|
||||
}
|
||||
return copy_len;
|
||||
}
|
||||
|
||||
/**
|
||||
* fc_fill_hdr() - fill FC header fields based on request
|
||||
* @fp: reply frame containing header to be filled in
|
||||
* @in_fp: request frame containing header to use in filling in reply
|
||||
* @r_ctl: R_CTL value for header
|
||||
* @f_ctl: F_CTL value for header, with 0 pad
|
||||
* @seq_cnt: sequence count for the header, ignored if frame has a sequence
|
||||
* @parm_offset: parameter / offset value
|
||||
*/
|
||||
void fc_fill_hdr(struct fc_frame *fp, const struct fc_frame *in_fp,
|
||||
enum fc_rctl r_ctl, u32 f_ctl, u16 seq_cnt, u32 parm_offset)
|
||||
{
|
||||
struct fc_frame_header *fh;
|
||||
struct fc_frame_header *in_fh;
|
||||
struct fc_seq *sp;
|
||||
u32 fill;
|
||||
|
||||
fh = __fc_frame_header_get(fp);
|
||||
in_fh = __fc_frame_header_get(in_fp);
|
||||
|
||||
if (f_ctl & FC_FC_END_SEQ) {
|
||||
fill = -fr_len(fp) & 3;
|
||||
if (fill) {
|
||||
/* TODO, this may be a problem with fragmented skb */
|
||||
memset(skb_put(fp_skb(fp), fill), 0, fill);
|
||||
f_ctl |= fill;
|
||||
}
|
||||
fr_eof(fp) = FC_EOF_T;
|
||||
} else {
|
||||
WARN_ON(fr_len(fp) % 4 != 0); /* no pad to non last frame */
|
||||
fr_eof(fp) = FC_EOF_N;
|
||||
}
|
||||
|
||||
fh->fh_r_ctl = r_ctl;
|
||||
memcpy(fh->fh_d_id, in_fh->fh_s_id, sizeof(fh->fh_d_id));
|
||||
memcpy(fh->fh_s_id, in_fh->fh_d_id, sizeof(fh->fh_s_id));
|
||||
fh->fh_type = in_fh->fh_type;
|
||||
hton24(fh->fh_f_ctl, f_ctl);
|
||||
fh->fh_ox_id = in_fh->fh_ox_id;
|
||||
fh->fh_rx_id = in_fh->fh_rx_id;
|
||||
fh->fh_cs_ctl = 0;
|
||||
fh->fh_df_ctl = 0;
|
||||
fh->fh_parm_offset = htonl(parm_offset);
|
||||
|
||||
sp = fr_seq(in_fp);
|
||||
if (sp) {
|
||||
fr_seq(fp) = sp;
|
||||
fh->fh_seq_id = sp->id;
|
||||
seq_cnt = sp->cnt;
|
||||
} else {
|
||||
fh->fh_seq_id = 0;
|
||||
}
|
||||
fh->fh_seq_cnt = ntohs(seq_cnt);
|
||||
fr_sof(fp) = seq_cnt ? FC_SOF_N3 : FC_SOF_I3;
|
||||
fr_encaps(fp) = fr_encaps(in_fp);
|
||||
}
|
||||
EXPORT_SYMBOL(fc_fill_hdr);
|
||||
|
||||
/**
|
||||
* fc_fill_reply_hdr() - fill FC reply header fields based on request
|
||||
* @fp: reply frame containing header to be filled in
|
||||
* @in_fp: request frame containing header to use in filling in reply
|
||||
* @r_ctl: R_CTL value for reply
|
||||
* @parm_offset: parameter / offset value
|
||||
*/
|
||||
void fc_fill_reply_hdr(struct fc_frame *fp, const struct fc_frame *in_fp,
|
||||
enum fc_rctl r_ctl, u32 parm_offset)
|
||||
{
|
||||
struct fc_seq *sp;
|
||||
|
||||
sp = fr_seq(in_fp);
|
||||
if (sp)
|
||||
fr_seq(fp) = fr_dev(in_fp)->tt.seq_start_next(sp);
|
||||
fc_fill_hdr(fp, in_fp, r_ctl, FC_FCTL_RESP, 0, parm_offset);
|
||||
}
|
||||
EXPORT_SYMBOL(fc_fill_reply_hdr);
|
||||
|
||||
/**
|
||||
* fc_fc4_conf_lport_params() - Modify "service_params" of specified lport
|
||||
* if there is service provider (target provider) registered with libfc
|
||||
* for specified "fc_ft_type"
|
||||
* @lport: Local port which service_params needs to be modified
|
||||
* @type: FC-4 type, such as FC_TYPE_FCP
|
||||
*/
|
||||
void fc_fc4_conf_lport_params(struct fc_lport *lport, enum fc_fh_type type)
|
||||
{
|
||||
struct fc4_prov *prov_entry;
|
||||
BUG_ON(type >= FC_FC4_PROV_SIZE);
|
||||
BUG_ON(!lport);
|
||||
prov_entry = fc_passive_prov[type];
|
||||
if (type == FC_TYPE_FCP) {
|
||||
if (prov_entry && prov_entry->recv)
|
||||
lport->service_params |= FCP_SPPF_TARG_FCN;
|
||||
}
|
||||
}
|
||||
|
||||
void fc_lport_iterate(void (*notify)(struct fc_lport *, void *), void *arg)
|
||||
{
|
||||
struct fc_lport *lport;
|
||||
|
||||
mutex_lock(&fc_prov_mutex);
|
||||
list_for_each_entry(lport, &fc_local_ports, lport_list)
|
||||
notify(lport, arg);
|
||||
mutex_unlock(&fc_prov_mutex);
|
||||
}
|
||||
EXPORT_SYMBOL(fc_lport_iterate);
|
||||
|
||||
/**
|
||||
* fc_fc4_register_provider() - register FC-4 upper-level provider.
|
||||
* @type: FC-4 type, such as FC_TYPE_FCP
|
||||
* @prov: structure describing provider including ops vector.
|
||||
*
|
||||
* Returns 0 on success, negative error otherwise.
|
||||
*/
|
||||
int fc_fc4_register_provider(enum fc_fh_type type, struct fc4_prov *prov)
|
||||
{
|
||||
struct fc4_prov **prov_entry;
|
||||
int ret = 0;
|
||||
|
||||
if (type >= FC_FC4_PROV_SIZE)
|
||||
return -EINVAL;
|
||||
mutex_lock(&fc_prov_mutex);
|
||||
prov_entry = (prov->recv ? fc_passive_prov : fc_active_prov) + type;
|
||||
if (*prov_entry)
|
||||
ret = -EBUSY;
|
||||
else
|
||||
*prov_entry = prov;
|
||||
mutex_unlock(&fc_prov_mutex);
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(fc_fc4_register_provider);
|
||||
|
||||
/**
|
||||
* fc_fc4_deregister_provider() - deregister FC-4 upper-level provider.
|
||||
* @type: FC-4 type, such as FC_TYPE_FCP
|
||||
* @prov: structure describing provider including ops vector.
|
||||
*/
|
||||
void fc_fc4_deregister_provider(enum fc_fh_type type, struct fc4_prov *prov)
|
||||
{
|
||||
BUG_ON(type >= FC_FC4_PROV_SIZE);
|
||||
mutex_lock(&fc_prov_mutex);
|
||||
if (prov->recv)
|
||||
RCU_INIT_POINTER(fc_passive_prov[type], NULL);
|
||||
else
|
||||
RCU_INIT_POINTER(fc_active_prov[type], NULL);
|
||||
mutex_unlock(&fc_prov_mutex);
|
||||
synchronize_rcu();
|
||||
}
|
||||
EXPORT_SYMBOL(fc_fc4_deregister_provider);
|
||||
|
||||
/**
|
||||
* fc_fc4_add_lport() - add new local port to list and run notifiers.
|
||||
* @lport: The new local port.
|
||||
*/
|
||||
void fc_fc4_add_lport(struct fc_lport *lport)
|
||||
{
|
||||
mutex_lock(&fc_prov_mutex);
|
||||
list_add_tail(&lport->lport_list, &fc_local_ports);
|
||||
blocking_notifier_call_chain(&fc_lport_notifier_head,
|
||||
FC_LPORT_EV_ADD, lport);
|
||||
mutex_unlock(&fc_prov_mutex);
|
||||
}
|
||||
|
||||
/**
|
||||
* fc_fc4_del_lport() - remove local port from list and run notifiers.
|
||||
* @lport: The new local port.
|
||||
*/
|
||||
void fc_fc4_del_lport(struct fc_lport *lport)
|
||||
{
|
||||
mutex_lock(&fc_prov_mutex);
|
||||
list_del(&lport->lport_list);
|
||||
blocking_notifier_call_chain(&fc_lport_notifier_head,
|
||||
FC_LPORT_EV_DEL, lport);
|
||||
mutex_unlock(&fc_prov_mutex);
|
||||
}
|
139
drivers/scsi/libfc/fc_libfc.h
Normal file
139
drivers/scsi/libfc/fc_libfc.h
Normal file
|
@ -0,0 +1,139 @@
|
|||
/*
|
||||
* Copyright(c) 2009 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
|
||||
*/
|
||||
|
||||
#ifndef _FC_LIBFC_H_
|
||||
#define _FC_LIBFC_H_
|
||||
|
||||
#define FC_LIBFC_LOGGING 0x01 /* General logging, not categorized */
|
||||
#define FC_LPORT_LOGGING 0x02 /* lport layer logging */
|
||||
#define FC_DISC_LOGGING 0x04 /* discovery layer logging */
|
||||
#define FC_RPORT_LOGGING 0x08 /* rport layer logging */
|
||||
#define FC_FCP_LOGGING 0x10 /* I/O path logging */
|
||||
#define FC_EM_LOGGING 0x20 /* Exchange Manager logging */
|
||||
#define FC_EXCH_LOGGING 0x40 /* Exchange/Sequence logging */
|
||||
#define FC_SCSI_LOGGING 0x80 /* SCSI logging (mostly error handling) */
|
||||
|
||||
extern unsigned int fc_debug_logging;
|
||||
|
||||
#define FC_CHECK_LOGGING(LEVEL, CMD) \
|
||||
do { \
|
||||
if (unlikely(fc_debug_logging & LEVEL)) \
|
||||
do { \
|
||||
CMD; \
|
||||
} while (0); \
|
||||
} while (0)
|
||||
|
||||
#define FC_LIBFC_DBG(fmt, args...) \
|
||||
FC_CHECK_LOGGING(FC_LIBFC_LOGGING, \
|
||||
pr_info("libfc: " fmt, ##args))
|
||||
|
||||
#define FC_LPORT_DBG(lport, fmt, args...) \
|
||||
FC_CHECK_LOGGING(FC_LPORT_LOGGING, \
|
||||
pr_info("host%u: lport %6.6x: " fmt, \
|
||||
(lport)->host->host_no, \
|
||||
(lport)->port_id, ##args))
|
||||
|
||||
#define FC_DISC_DBG(disc, fmt, args...) \
|
||||
FC_CHECK_LOGGING(FC_DISC_LOGGING, \
|
||||
pr_info("host%u: disc: " fmt, \
|
||||
fc_disc_lport(disc)->host->host_no, \
|
||||
##args))
|
||||
|
||||
#define FC_RPORT_ID_DBG(lport, port_id, fmt, args...) \
|
||||
FC_CHECK_LOGGING(FC_RPORT_LOGGING, \
|
||||
pr_info("host%u: rport %6.6x: " fmt, \
|
||||
(lport)->host->host_no, \
|
||||
(port_id), ##args))
|
||||
|
||||
#define FC_RPORT_DBG(rdata, fmt, args...) \
|
||||
FC_RPORT_ID_DBG((rdata)->local_port, (rdata)->ids.port_id, fmt, ##args)
|
||||
|
||||
#define FC_FCP_DBG(pkt, fmt, args...) \
|
||||
FC_CHECK_LOGGING(FC_FCP_LOGGING, \
|
||||
{ \
|
||||
if ((pkt)->seq_ptr) { \
|
||||
struct fc_exch *_ep = NULL; \
|
||||
_ep = fc_seq_exch((pkt)->seq_ptr); \
|
||||
pr_info("host%u: fcp: %6.6x: " \
|
||||
"xid %04x-%04x: " fmt, \
|
||||
(pkt)->lp->host->host_no, \
|
||||
(pkt)->rport->port_id, \
|
||||
(_ep)->oxid, (_ep)->rxid, ##args); \
|
||||
} else { \
|
||||
pr_info("host%u: fcp: %6.6x: " fmt, \
|
||||
(pkt)->lp->host->host_no, \
|
||||
(pkt)->rport->port_id, ##args); \
|
||||
} \
|
||||
})
|
||||
|
||||
#define FC_EXCH_DBG(exch, fmt, args...) \
|
||||
FC_CHECK_LOGGING(FC_EXCH_LOGGING, \
|
||||
pr_info("host%u: xid %4x: " fmt, \
|
||||
(exch)->lp->host->host_no, \
|
||||
exch->xid, ##args))
|
||||
|
||||
#define FC_SCSI_DBG(lport, fmt, args...) \
|
||||
FC_CHECK_LOGGING(FC_SCSI_LOGGING, \
|
||||
pr_info("host%u: scsi: " fmt, \
|
||||
(lport)->host->host_no, ##args))
|
||||
|
||||
/*
|
||||
* FC-4 Providers.
|
||||
*/
|
||||
extern struct fc4_prov *fc_active_prov[]; /* providers without recv */
|
||||
extern struct fc4_prov *fc_passive_prov[]; /* providers with recv */
|
||||
extern struct mutex fc_prov_mutex; /* lock over table changes */
|
||||
|
||||
extern struct fc4_prov fc_rport_t0_prov; /* type 0 provider */
|
||||
extern struct fc4_prov fc_lport_els_prov; /* ELS provider */
|
||||
extern struct fc4_prov fc_rport_fcp_init; /* FCP initiator provider */
|
||||
|
||||
/*
|
||||
* Set up direct-data placement for this I/O request
|
||||
*/
|
||||
void fc_fcp_ddp_setup(struct fc_fcp_pkt *fsp, u16 xid);
|
||||
void fc_fcp_ddp_done(struct fc_fcp_pkt *fsp);
|
||||
|
||||
/*
|
||||
* Module setup functions
|
||||
*/
|
||||
int fc_setup_exch_mgr(void);
|
||||
void fc_destroy_exch_mgr(void);
|
||||
int fc_setup_rport(void);
|
||||
void fc_destroy_rport(void);
|
||||
int fc_setup_fcp(void);
|
||||
void fc_destroy_fcp(void);
|
||||
|
||||
/*
|
||||
* Internal libfc functions
|
||||
*/
|
||||
const char *fc_els_resp_type(struct fc_frame *);
|
||||
extern void fc_fc4_add_lport(struct fc_lport *);
|
||||
extern void fc_fc4_del_lport(struct fc_lport *);
|
||||
extern void fc_fc4_conf_lport_params(struct fc_lport *, enum fc_fh_type);
|
||||
|
||||
/*
|
||||
* Copies a buffer into an sg list
|
||||
*/
|
||||
u32 fc_copy_buffer_to_sglist(void *buf, size_t len,
|
||||
struct scatterlist *sg,
|
||||
u32 *nents, size_t *offset,
|
||||
u32 *crc);
|
||||
|
||||
#endif /* _FC_LIBFC_H_ */
|
2144
drivers/scsi/libfc/fc_lport.c
Normal file
2144
drivers/scsi/libfc/fc_lport.c
Normal file
File diff suppressed because it is too large
Load diff
159
drivers/scsi/libfc/fc_npiv.c
Normal file
159
drivers/scsi/libfc/fc_npiv.c
Normal file
|
@ -0,0 +1,159 @@
|
|||
/*
|
||||
* Copyright(c) 2009 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
|
||||
*/
|
||||
|
||||
/*
|
||||
* NPIV VN_Port helper functions for libfc
|
||||
*/
|
||||
|
||||
#include <scsi/libfc.h>
|
||||
#include <linux/export.h>
|
||||
|
||||
/**
|
||||
* fc_vport_create() - Create a new NPIV vport instance
|
||||
* @vport: fc_vport structure from scsi_transport_fc
|
||||
* @privsize: driver private data size to allocate along with the Scsi_Host
|
||||
*/
|
||||
|
||||
struct fc_lport *libfc_vport_create(struct fc_vport *vport, int privsize)
|
||||
{
|
||||
struct Scsi_Host *shost = vport_to_shost(vport);
|
||||
struct fc_lport *n_port = shost_priv(shost);
|
||||
struct fc_lport *vn_port;
|
||||
|
||||
vn_port = libfc_host_alloc(shost->hostt, privsize);
|
||||
if (!vn_port)
|
||||
return vn_port;
|
||||
|
||||
vn_port->vport = vport;
|
||||
vport->dd_data = vn_port;
|
||||
|
||||
mutex_lock(&n_port->lp_mutex);
|
||||
list_add_tail(&vn_port->list, &n_port->vports);
|
||||
mutex_unlock(&n_port->lp_mutex);
|
||||
|
||||
return vn_port;
|
||||
}
|
||||
EXPORT_SYMBOL(libfc_vport_create);
|
||||
|
||||
/**
|
||||
* fc_vport_id_lookup() - find NPIV lport that matches a given fabric ID
|
||||
* @n_port: Top level N_Port which may have multiple NPIV VN_Ports
|
||||
* @port_id: Fabric ID to find a match for
|
||||
*
|
||||
* Returns: matching lport pointer or NULL if there is no match
|
||||
*/
|
||||
struct fc_lport *fc_vport_id_lookup(struct fc_lport *n_port, u32 port_id)
|
||||
{
|
||||
struct fc_lport *lport = NULL;
|
||||
struct fc_lport *vn_port;
|
||||
|
||||
if (n_port->port_id == port_id)
|
||||
return n_port;
|
||||
|
||||
if (port_id == FC_FID_FLOGI)
|
||||
return n_port; /* for point-to-point */
|
||||
|
||||
mutex_lock(&n_port->lp_mutex);
|
||||
list_for_each_entry(vn_port, &n_port->vports, list) {
|
||||
if (vn_port->port_id == port_id) {
|
||||
lport = vn_port;
|
||||
break;
|
||||
}
|
||||
}
|
||||
mutex_unlock(&n_port->lp_mutex);
|
||||
|
||||
return lport;
|
||||
}
|
||||
EXPORT_SYMBOL(fc_vport_id_lookup);
|
||||
|
||||
/*
|
||||
* When setting the link state of vports during an lport state change, it's
|
||||
* necessary to hold the lp_mutex of both the N_Port and the VN_Port.
|
||||
* This tells the lockdep engine to treat the nested locking of the VN_Port
|
||||
* as a different lock class.
|
||||
*/
|
||||
enum libfc_lport_mutex_class {
|
||||
LPORT_MUTEX_NORMAL = 0,
|
||||
LPORT_MUTEX_VN_PORT = 1,
|
||||
};
|
||||
|
||||
/**
|
||||
* __fc_vport_setlink() - update link and status on a VN_Port
|
||||
* @n_port: parent N_Port
|
||||
* @vn_port: VN_Port to update
|
||||
*
|
||||
* Locking: must be called with both the N_Port and VN_Port lp_mutex held
|
||||
*/
|
||||
static void __fc_vport_setlink(struct fc_lport *n_port,
|
||||
struct fc_lport *vn_port)
|
||||
{
|
||||
struct fc_vport *vport = vn_port->vport;
|
||||
|
||||
if (vn_port->state == LPORT_ST_DISABLED)
|
||||
return;
|
||||
|
||||
if (n_port->state == LPORT_ST_READY) {
|
||||
if (n_port->npiv_enabled) {
|
||||
fc_vport_set_state(vport, FC_VPORT_INITIALIZING);
|
||||
__fc_linkup(vn_port);
|
||||
} else {
|
||||
fc_vport_set_state(vport, FC_VPORT_NO_FABRIC_SUPP);
|
||||
__fc_linkdown(vn_port);
|
||||
}
|
||||
} else {
|
||||
fc_vport_set_state(vport, FC_VPORT_LINKDOWN);
|
||||
__fc_linkdown(vn_port);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* fc_vport_setlink() - update link and status on a VN_Port
|
||||
* @vn_port: virtual port to update
|
||||
*/
|
||||
void fc_vport_setlink(struct fc_lport *vn_port)
|
||||
{
|
||||
struct fc_vport *vport = vn_port->vport;
|
||||
struct Scsi_Host *shost = vport_to_shost(vport);
|
||||
struct fc_lport *n_port = shost_priv(shost);
|
||||
|
||||
mutex_lock(&n_port->lp_mutex);
|
||||
mutex_lock_nested(&vn_port->lp_mutex, LPORT_MUTEX_VN_PORT);
|
||||
__fc_vport_setlink(n_port, vn_port);
|
||||
mutex_unlock(&vn_port->lp_mutex);
|
||||
mutex_unlock(&n_port->lp_mutex);
|
||||
}
|
||||
EXPORT_SYMBOL(fc_vport_setlink);
|
||||
|
||||
/**
|
||||
* fc_vports_linkchange() - change the link state of all vports
|
||||
* @n_port: Parent N_Port that has changed state
|
||||
*
|
||||
* Locking: called with the n_port lp_mutex held
|
||||
*/
|
||||
void fc_vports_linkchange(struct fc_lport *n_port)
|
||||
{
|
||||
struct fc_lport *vn_port;
|
||||
|
||||
list_for_each_entry(vn_port, &n_port->vports, list) {
|
||||
mutex_lock_nested(&vn_port->lp_mutex, LPORT_MUTEX_VN_PORT);
|
||||
__fc_vport_setlink(n_port, vn_port);
|
||||
mutex_unlock(&vn_port->lp_mutex);
|
||||
}
|
||||
}
|
||||
|
2069
drivers/scsi/libfc/fc_rport.c
Normal file
2069
drivers/scsi/libfc/fc_rport.c
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue