2008-12-09 23:10:17 +00:00
|
|
|
/*
|
|
|
|
* Copyright(c) 2007 Intel Corporation. All rights reserved.
|
|
|
|
* Copyright(c) 2008 Red Hat, Inc. All rights reserved.
|
|
|
|
* Copyright(c) 2008 Mike Christie
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Fibre Channel exchange and sequence handling.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#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 08:04:11 +00:00
|
|
|
#include <linux/slab.h>
|
2008-12-09 23:10:17 +00:00
|
|
|
#include <linux/err.h>
|
2011-05-27 13:37:25 +00:00
|
|
|
#include <linux/export.h>
|
2013-08-14 15:33:35 +00:00
|
|
|
#include <linux/log2.h>
|
2008-12-09 23:10:17 +00:00
|
|
|
|
|
|
|
#include <scsi/fc/fc_fc2.h>
|
|
|
|
|
|
|
|
#include <scsi/libfc.h>
|
|
|
|
#include <scsi/fc_encode.h>
|
|
|
|
|
2009-11-03 19:45:58 +00:00
|
|
|
#include "fc_libfc.h"
|
|
|
|
|
[SCSI] fcoe, libfc: adds per cpu exch pool within exchange manager(EM)
Adds per cpu exch pool for these reasons:-
1. Currently an EM instance is shared across all cpus to manage
all exches for all cpus. This required em_lock across all
cpus for an exch alloc, free, lookup and reset each frame
and that made em_lock expensive, so instead having per cpu
exch pool with their own per cpu pool lock will likely reduce
locking contention in fast path for an exch alloc, free and
lookup.
2. Per cpu exch pool will likely improve cache hit ratio since
all frames of an exch will be processed on the same cpu on
which exch originated.
This patch is only prep work to help in keeping complexity of next
patch low, so this patch only sets up per cpu exch pool and related
helper funcs to be used by next patch. The next patch fully makes
use of per cpu exch pool in all code paths ie. tx, rx and reset.
Divides per EM exch id range equally across all cpus to setup per
cpu exch pool. This division is such that lower bits of exch id
carries cpu number info on which exch originated, later a simple
bitwise AND operation on exch id of incoming frame with fc_cpu_mask
retrieves cpu number info to direct all frames to same cpu on which
exch originated. This required a global fc_cpu_mask and fc_cpu_order
initialized to max possible cpus number nr_cpu_ids rounded up to 2's
power, this will be used in mapping exch id and exch ptr array
index in pool during exch allocation, find or reset code paths.
Adds a check in fc_exch_mgr_alloc() to ensure specified min_xid
lower bits are zero since these bits are used to carry cpu info.
Adds and initializes struct fc_exch_pool with all required fields
to manage exches in pool.
Allocates per cpu struct fc_exch_pool with memory for exches array
for range of exches per pool. The exches array memory is followed
by struct fc_exch_pool.
Adds fc_exch_ptr_get/set() helper functions to get/set exch ptr in
pool exches array at specified array index.
Increases default FCOE_MAX_XID to 0x0FFF from 0x07EF, so that more
exches are available per cpu after above described exch id range
division across all cpus to each pool.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:47 +00:00
|
|
|
u16 fc_cpu_mask; /* cpu mask for possible cpus */
|
|
|
|
EXPORT_SYMBOL(fc_cpu_mask);
|
|
|
|
static u16 fc_cpu_order; /* 2's power to represent total possible cpus */
|
2009-11-03 19:47:39 +00:00
|
|
|
static struct kmem_cache *fc_em_cachep; /* cache for exchanges */
|
2011-01-29 00:03:57 +00:00
|
|
|
static struct workqueue_struct *fc_exch_workqueue;
|
2008-12-09 23:10:17 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Structure and function definitions for managing Fibre Channel Exchanges
|
|
|
|
* and Sequences.
|
|
|
|
*
|
|
|
|
* The three primary structures used here are fc_exch_mgr, fc_exch, and fc_seq.
|
|
|
|
*
|
|
|
|
* fc_exch_mgr holds the exchange state for an N port
|
|
|
|
*
|
|
|
|
* fc_exch holds state for one exchange and links to its active sequence.
|
|
|
|
*
|
|
|
|
* fc_seq holds the state for an individual sequence.
|
|
|
|
*/
|
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
/**
|
|
|
|
* struct fc_exch_pool - Per cpu exchange pool
|
|
|
|
* @next_index: Next possible free exchange index
|
|
|
|
* @total_exches: Total allocated exchanges
|
|
|
|
* @lock: Exch pool lock
|
|
|
|
* @ex_list: List of exchanges
|
[SCSI] fcoe, libfc: adds per cpu exch pool within exchange manager(EM)
Adds per cpu exch pool for these reasons:-
1. Currently an EM instance is shared across all cpus to manage
all exches for all cpus. This required em_lock across all
cpus for an exch alloc, free, lookup and reset each frame
and that made em_lock expensive, so instead having per cpu
exch pool with their own per cpu pool lock will likely reduce
locking contention in fast path for an exch alloc, free and
lookup.
2. Per cpu exch pool will likely improve cache hit ratio since
all frames of an exch will be processed on the same cpu on
which exch originated.
This patch is only prep work to help in keeping complexity of next
patch low, so this patch only sets up per cpu exch pool and related
helper funcs to be used by next patch. The next patch fully makes
use of per cpu exch pool in all code paths ie. tx, rx and reset.
Divides per EM exch id range equally across all cpus to setup per
cpu exch pool. This division is such that lower bits of exch id
carries cpu number info on which exch originated, later a simple
bitwise AND operation on exch id of incoming frame with fc_cpu_mask
retrieves cpu number info to direct all frames to same cpu on which
exch originated. This required a global fc_cpu_mask and fc_cpu_order
initialized to max possible cpus number nr_cpu_ids rounded up to 2's
power, this will be used in mapping exch id and exch ptr array
index in pool during exch allocation, find or reset code paths.
Adds a check in fc_exch_mgr_alloc() to ensure specified min_xid
lower bits are zero since these bits are used to carry cpu info.
Adds and initializes struct fc_exch_pool with all required fields
to manage exches in pool.
Allocates per cpu struct fc_exch_pool with memory for exches array
for range of exches per pool. The exches array memory is followed
by struct fc_exch_pool.
Adds fc_exch_ptr_get/set() helper functions to get/set exch ptr in
pool exches array at specified array index.
Increases default FCOE_MAX_XID to 0x0FFF from 0x07EF, so that more
exches are available per cpu after above described exch id range
division across all cpus to each pool.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:47 +00:00
|
|
|
*
|
|
|
|
* This structure manages per cpu exchanges in array of exchange pointers.
|
|
|
|
* This array is allocated followed by struct fc_exch_pool memory for
|
|
|
|
* assigned range of exchanges to per cpu pool.
|
|
|
|
*/
|
|
|
|
struct fc_exch_pool {
|
2011-09-28 04:38:08 +00:00
|
|
|
spinlock_t lock;
|
|
|
|
struct list_head ex_list;
|
2009-11-03 19:47:39 +00:00
|
|
|
u16 next_index;
|
|
|
|
u16 total_exches;
|
2010-12-01 00:18:17 +00:00
|
|
|
|
|
|
|
/* two cache of free slot in exch array */
|
|
|
|
u16 left;
|
|
|
|
u16 right;
|
2011-09-28 04:38:08 +00:00
|
|
|
} ____cacheline_aligned_in_smp;
|
[SCSI] fcoe, libfc: adds per cpu exch pool within exchange manager(EM)
Adds per cpu exch pool for these reasons:-
1. Currently an EM instance is shared across all cpus to manage
all exches for all cpus. This required em_lock across all
cpus for an exch alloc, free, lookup and reset each frame
and that made em_lock expensive, so instead having per cpu
exch pool with their own per cpu pool lock will likely reduce
locking contention in fast path for an exch alloc, free and
lookup.
2. Per cpu exch pool will likely improve cache hit ratio since
all frames of an exch will be processed on the same cpu on
which exch originated.
This patch is only prep work to help in keeping complexity of next
patch low, so this patch only sets up per cpu exch pool and related
helper funcs to be used by next patch. The next patch fully makes
use of per cpu exch pool in all code paths ie. tx, rx and reset.
Divides per EM exch id range equally across all cpus to setup per
cpu exch pool. This division is such that lower bits of exch id
carries cpu number info on which exch originated, later a simple
bitwise AND operation on exch id of incoming frame with fc_cpu_mask
retrieves cpu number info to direct all frames to same cpu on which
exch originated. This required a global fc_cpu_mask and fc_cpu_order
initialized to max possible cpus number nr_cpu_ids rounded up to 2's
power, this will be used in mapping exch id and exch ptr array
index in pool during exch allocation, find or reset code paths.
Adds a check in fc_exch_mgr_alloc() to ensure specified min_xid
lower bits are zero since these bits are used to carry cpu info.
Adds and initializes struct fc_exch_pool with all required fields
to manage exches in pool.
Allocates per cpu struct fc_exch_pool with memory for exches array
for range of exches per pool. The exches array memory is followed
by struct fc_exch_pool.
Adds fc_exch_ptr_get/set() helper functions to get/set exch ptr in
pool exches array at specified array index.
Increases default FCOE_MAX_XID to 0x0FFF from 0x07EF, so that more
exches are available per cpu after above described exch id range
division across all cpus to each pool.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:47 +00:00
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
/**
|
|
|
|
* struct fc_exch_mgr - The Exchange Manager (EM).
|
|
|
|
* @class: Default class for new sequences
|
|
|
|
* @kref: Reference counter
|
|
|
|
* @min_xid: Minimum exchange ID
|
|
|
|
* @max_xid: Maximum exchange ID
|
|
|
|
* @ep_pool: Reserved exchange pointers
|
|
|
|
* @pool_max_index: Max exch array index in exch pool
|
|
|
|
* @pool: Per cpu exch pool
|
|
|
|
* @stats: Statistics structure
|
2008-12-09 23:10:17 +00:00
|
|
|
*
|
|
|
|
* This structure is the center for creating exchanges and sequences.
|
|
|
|
* It manages the allocation of exchange IDs.
|
|
|
|
*/
|
|
|
|
struct fc_exch_mgr {
|
2012-01-14 01:26:20 +00:00
|
|
|
struct fc_exch_pool __percpu *pool;
|
2011-09-28 04:38:08 +00:00
|
|
|
mempool_t *ep_pool;
|
2016-10-13 13:10:50 +00:00
|
|
|
struct fc_lport *lport;
|
2009-11-03 19:47:39 +00:00
|
|
|
enum fc_class class;
|
|
|
|
struct kref kref;
|
|
|
|
u16 min_xid;
|
|
|
|
u16 max_xid;
|
|
|
|
u16 pool_max_index;
|
2008-12-09 23:10:17 +00:00
|
|
|
|
|
|
|
struct {
|
|
|
|
atomic_t no_free_exch;
|
|
|
|
atomic_t no_free_exch_xid;
|
|
|
|
atomic_t xid_not_found;
|
|
|
|
atomic_t xid_busy;
|
|
|
|
atomic_t seq_not_found;
|
|
|
|
atomic_t non_bls_resp;
|
|
|
|
} stats;
|
|
|
|
};
|
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
/**
|
|
|
|
* struct fc_exch_mgr_anchor - primary structure for list of EMs
|
|
|
|
* @ema_list: Exchange Manager Anchor list
|
|
|
|
* @mp: Exchange Manager associated with this anchor
|
|
|
|
* @match: Routine to determine if this anchor's EM should be used
|
|
|
|
*
|
|
|
|
* When walking the list of anchors the match routine will be called
|
|
|
|
* for each anchor to determine if that EM should be used. The last
|
|
|
|
* anchor in the list will always match to handle any exchanges not
|
|
|
|
* handled by other EMs. The non-default EMs would be added to the
|
2012-05-25 17:26:43 +00:00
|
|
|
* anchor list by HW that provides offloads.
|
2009-11-03 19:47:39 +00:00
|
|
|
*/
|
2009-07-30 00:05:00 +00:00
|
|
|
struct fc_exch_mgr_anchor {
|
|
|
|
struct list_head ema_list;
|
|
|
|
struct fc_exch_mgr *mp;
|
|
|
|
bool (*match)(struct fc_frame *);
|
|
|
|
};
|
|
|
|
|
2008-12-09 23:10:17 +00:00
|
|
|
static void fc_exch_rrq(struct fc_exch *);
|
2010-07-20 22:21:12 +00:00
|
|
|
static void fc_seq_ls_acc(struct fc_frame *);
|
|
|
|
static void fc_seq_ls_rjt(struct fc_frame *, enum fc_els_rjt_reason,
|
2008-12-09 23:10:17 +00:00
|
|
|
enum fc_els_rjt_explan);
|
2010-07-20 22:21:12 +00:00
|
|
|
static void fc_exch_els_rec(struct fc_frame *);
|
|
|
|
static void fc_exch_els_rrq(struct fc_frame *);
|
2008-12-09 23:10:17 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Internal implementation notes.
|
|
|
|
*
|
|
|
|
* The exchange manager is one by default in libfc but LLD may choose
|
|
|
|
* to have one per CPU. The sequence manager is one per exchange manager
|
|
|
|
* and currently never separated.
|
|
|
|
*
|
|
|
|
* Section 9.8 in FC-FS-2 specifies: "The SEQ_ID is a one-byte field
|
|
|
|
* assigned by the Sequence Initiator that shall be unique for a specific
|
|
|
|
* D_ID and S_ID pair while the Sequence is open." Note that it isn't
|
|
|
|
* qualified by exchange ID, which one might think it would be.
|
|
|
|
* In practice this limits the number of open sequences and exchanges to 256
|
|
|
|
* per session. For most targets we could treat this limit as per exchange.
|
|
|
|
*
|
|
|
|
* The exchange and its sequence are freed when the last sequence is received.
|
|
|
|
* It's possible for the remote port to leave an exchange open without
|
|
|
|
* sending any sequences.
|
|
|
|
*
|
|
|
|
* Notes on reference counts:
|
|
|
|
*
|
|
|
|
* Exchanges are reference counted and exchange gets freed when the reference
|
|
|
|
* count becomes zero.
|
|
|
|
*
|
|
|
|
* Timeouts:
|
|
|
|
* Sequences are timed out for E_D_TOV and R_A_TOV.
|
|
|
|
*
|
|
|
|
* Sequence event handling:
|
|
|
|
*
|
|
|
|
* The following events may occur on initiator sequences:
|
|
|
|
*
|
|
|
|
* Send.
|
|
|
|
* For now, the whole thing is sent.
|
|
|
|
* Receive ACK
|
|
|
|
* This applies only to class F.
|
|
|
|
* The sequence is marked complete.
|
|
|
|
* ULP completion.
|
|
|
|
* The upper layer calls fc_exch_done() when done
|
|
|
|
* with exchange and sequence tuple.
|
|
|
|
* RX-inferred completion.
|
|
|
|
* When we receive the next sequence on the same exchange, we can
|
|
|
|
* retire the previous sequence ID. (XXX not implemented).
|
|
|
|
* Timeout.
|
|
|
|
* R_A_TOV frees the sequence ID. If we're waiting for ACK,
|
|
|
|
* E_D_TOV causes abort and calls upper layer response handler
|
|
|
|
* with FC_EX_TIMEOUT error.
|
|
|
|
* Receive RJT
|
|
|
|
* XXX defer.
|
|
|
|
* Send ABTS
|
|
|
|
* On timeout.
|
|
|
|
*
|
|
|
|
* The following events may occur on recipient sequences:
|
|
|
|
*
|
|
|
|
* Receive
|
|
|
|
* Allocate sequence for first frame received.
|
|
|
|
* Hold during receive handler.
|
|
|
|
* Release when final frame received.
|
|
|
|
* Keep status of last N of these for the ELS RES command. XXX TBD.
|
|
|
|
* Receive ABTS
|
|
|
|
* Deallocate sequence
|
|
|
|
* Send RJT
|
|
|
|
* Deallocate
|
|
|
|
*
|
|
|
|
* For now, we neglect conditions where only part of a sequence was
|
|
|
|
* received or transmitted, or where out-of-order receipt is detected.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Locking notes:
|
|
|
|
*
|
|
|
|
* The EM code run in a per-CPU worker thread.
|
|
|
|
*
|
|
|
|
* To protect against concurrency between a worker thread code and timers,
|
|
|
|
* sequence allocation and deallocation must be locked.
|
|
|
|
* - exchange refcnt can be done atomicly without locks.
|
|
|
|
* - sequence allocation must be locked by exch lock.
|
[SCSI] fcoe, libfc: fully makes use of per cpu exch pool and then removes em_lock
1. Updates fcoe_rcv() to queue incoming frames to the fcoe per
cpu thread on which this frame's exch was originated and simply
use current cpu for request exch not originated by initiator.
It is redundant to add this code under CONFIG_SMP, so removes
CONFIG_SMP uses around this code.
2. Updates fc_exch_em_alloc, fc_exch_delete, fc_exch_find to use
per cpu exch pools, here fc_exch_delete is rename of older
fc_exch_mgr_delete_ep since ep/exch are now deleted in pools
of EM and so brief new name is sufficient and better name.
Updates these functions to map exch id to their index into exch
pool using fc_cpu_mask, fc_cpu_order and EM min_xid.
This mapping is as per detailed explanation about this in
last patch and basically this is just as lower fc_cpu_mask
bits of exch id as cpu number and upper bit sum of EM min_xid
and exch index in pool.
Uses pool next_index to keep track of exch allocation from
pool along with pool_max_index as upper bound of exches array
in pool.
3. Adds exch pool ptr to fc_exch to free exch to its pool in
fc_exch_delete.
4. Updates fc_exch_mgr_reset to reset all exch pools of an EM,
this required adding fc_exch_pool_reset func to reset exches
in pool and then have fc_exch_mgr_reset call fc_exch_pool_reset
for each pool within each EM for a lport.
5. Removes no longer needed exches array, em_lock, next_xid, and
total_exches from struct fc_exch_mgr, these are not needed after
use of per cpu exch pool, also removes not used max_read,
last_read from struct fc_exch_mgr.
6. Updates locking notes for exch pool lock with fc_exch lock and
uses pool lock in exch allocation, lookup and reset.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:53 +00:00
|
|
|
* - If the EM pool lock and ex_lock must be taken at the same time, then the
|
|
|
|
* EM pool lock must be taken before the ex_lock.
|
2008-12-09 23:10:17 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* opcode names for debugging.
|
|
|
|
*/
|
|
|
|
static char *fc_exch_rctl_names[] = FC_RCTL_NAMES_INIT;
|
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
/**
|
|
|
|
* fc_exch_name_lookup() - Lookup name by opcode
|
|
|
|
* @op: Opcode to be looked up
|
|
|
|
* @table: Opcode/name table
|
|
|
|
* @max_index: Index not to be exceeded
|
|
|
|
*
|
|
|
|
* This routine is used to determine a human-readable string identifying
|
|
|
|
* a R_CTL opcode.
|
|
|
|
*/
|
2008-12-09 23:10:17 +00:00
|
|
|
static inline const char *fc_exch_name_lookup(unsigned int op, char **table,
|
|
|
|
unsigned int max_index)
|
|
|
|
{
|
|
|
|
const char *name = NULL;
|
|
|
|
|
|
|
|
if (op < max_index)
|
|
|
|
name = table[op];
|
|
|
|
if (!name)
|
|
|
|
name = "unknown";
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
/**
|
|
|
|
* fc_exch_rctl_name() - Wrapper routine for fc_exch_name_lookup()
|
|
|
|
* @op: The opcode to be looked up
|
|
|
|
*/
|
2008-12-09 23:10:17 +00:00
|
|
|
static const char *fc_exch_rctl_name(unsigned int op)
|
|
|
|
{
|
|
|
|
return fc_exch_name_lookup(op, fc_exch_rctl_names,
|
2010-06-28 11:55:12 +00:00
|
|
|
ARRAY_SIZE(fc_exch_rctl_names));
|
2008-12-09 23:10:17 +00:00
|
|
|
}
|
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
/**
|
|
|
|
* fc_exch_hold() - Increment an exchange's reference count
|
|
|
|
* @ep: Echange to be held
|
2008-12-09 23:10:17 +00:00
|
|
|
*/
|
2009-11-03 19:47:39 +00:00
|
|
|
static inline void fc_exch_hold(struct fc_exch *ep)
|
2008-12-09 23:10:17 +00:00
|
|
|
{
|
|
|
|
atomic_inc(&ep->ex_refcnt);
|
|
|
|
}
|
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
/**
|
|
|
|
* fc_exch_setup_hdr() - Initialize a FC header by initializing some fields
|
|
|
|
* and determine SOF and EOF.
|
|
|
|
* @ep: The exchange to that will use the header
|
|
|
|
* @fp: The frame whose header is to be modified
|
|
|
|
* @f_ctl: F_CTL bits that will be used for the frame header
|
|
|
|
*
|
|
|
|
* The fields initialized by this routine are: fh_ox_id, fh_rx_id,
|
|
|
|
* fh_seq_id, fh_seq_cnt and the SOF and EOF.
|
2008-12-09 23:10:17 +00:00
|
|
|
*/
|
|
|
|
static void fc_exch_setup_hdr(struct fc_exch *ep, struct fc_frame *fp,
|
|
|
|
u32 f_ctl)
|
|
|
|
{
|
|
|
|
struct fc_frame_header *fh = fc_frame_header_get(fp);
|
|
|
|
u16 fill;
|
|
|
|
|
|
|
|
fr_sof(fp) = ep->class;
|
|
|
|
if (ep->seq.cnt)
|
|
|
|
fr_sof(fp) = fc_sof_normal(ep->class);
|
|
|
|
|
|
|
|
if (f_ctl & FC_FC_END_SEQ) {
|
|
|
|
fr_eof(fp) = FC_EOF_T;
|
|
|
|
if (fc_sof_needs_ack(ep->class))
|
|
|
|
fr_eof(fp) = FC_EOF_N;
|
|
|
|
/*
|
2009-11-03 19:47:39 +00:00
|
|
|
* From F_CTL.
|
2008-12-09 23:10:17 +00:00
|
|
|
* The number of fill bytes to make the length a 4-byte
|
|
|
|
* multiple is the low order 2-bits of the f_ctl.
|
|
|
|
* The fill itself will have been cleared by the frame
|
|
|
|
* allocation.
|
|
|
|
* After this, the length will be even, as expected by
|
|
|
|
* the transport.
|
|
|
|
*/
|
|
|
|
fill = fr_len(fp) & 3;
|
|
|
|
if (fill) {
|
|
|
|
fill = 4 - fill;
|
|
|
|
/* TODO, this may be a problem with fragmented skb */
|
|
|
|
skb_put(fp_skb(fp), fill);
|
|
|
|
hton24(fh->fh_f_ctl, f_ctl | fill);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
WARN_ON(fr_len(fp) % 4 != 0); /* no pad to non last frame */
|
|
|
|
fr_eof(fp) = FC_EOF_N;
|
|
|
|
}
|
|
|
|
|
2013-08-14 15:31:52 +00:00
|
|
|
/* Initialize remaining fh fields from fc_fill_fc_hdr */
|
2008-12-09 23:10:17 +00:00
|
|
|
fh->fh_ox_id = htons(ep->oxid);
|
|
|
|
fh->fh_rx_id = htons(ep->rxid);
|
|
|
|
fh->fh_seq_id = ep->seq.id;
|
|
|
|
fh->fh_seq_cnt = htons(ep->seq.cnt);
|
|
|
|
}
|
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
/**
|
|
|
|
* fc_exch_release() - Decrement an exchange's reference count
|
|
|
|
* @ep: Exchange to be released
|
|
|
|
*
|
|
|
|
* If the reference count reaches zero and the exchange is complete,
|
|
|
|
* it is freed.
|
2008-12-09 23:10:17 +00:00
|
|
|
*/
|
|
|
|
static void fc_exch_release(struct fc_exch *ep)
|
|
|
|
{
|
|
|
|
struct fc_exch_mgr *mp;
|
|
|
|
|
|
|
|
if (atomic_dec_and_test(&ep->ex_refcnt)) {
|
|
|
|
mp = ep->em;
|
|
|
|
if (ep->destructor)
|
|
|
|
ep->destructor(&ep->seq, ep->arg);
|
2009-02-04 21:17:29 +00:00
|
|
|
WARN_ON(!(ep->esb_stat & ESB_ST_COMPLETE));
|
2008-12-09 23:10:17 +00:00
|
|
|
mempool_free(ep, mp->ep_pool);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-06 17:40:10 +00:00
|
|
|
/**
|
|
|
|
* fc_exch_timer_cancel() - cancel exch timer
|
|
|
|
* @ep: The exchange whose timer to be canceled
|
|
|
|
*/
|
2013-06-11 07:28:03 +00:00
|
|
|
static inline void fc_exch_timer_cancel(struct fc_exch *ep)
|
2012-07-06 17:40:10 +00:00
|
|
|
{
|
|
|
|
if (cancel_delayed_work(&ep->timeout_work)) {
|
|
|
|
FC_EXCH_DBG(ep, "Exchange timer canceled\n");
|
|
|
|
atomic_dec(&ep->ex_refcnt); /* drop hold for timer */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* fc_exch_timer_set_locked() - Start a timer for an exchange w/ the
|
|
|
|
* the exchange lock held
|
|
|
|
* @ep: The exchange whose timer will start
|
|
|
|
* @timer_msec: The timeout period
|
|
|
|
*
|
|
|
|
* Used for upper level protocols to time out the exchange.
|
|
|
|
* The timer is cancelled when it fires or when the exchange completes.
|
|
|
|
*/
|
|
|
|
static inline void fc_exch_timer_set_locked(struct fc_exch *ep,
|
|
|
|
unsigned int timer_msec)
|
|
|
|
{
|
|
|
|
if (ep->state & (FC_EX_RST_CLEANUP | FC_EX_DONE))
|
|
|
|
return;
|
|
|
|
|
|
|
|
FC_EXCH_DBG(ep, "Exchange timer armed : %d msecs\n", timer_msec);
|
|
|
|
|
2013-08-14 15:35:29 +00:00
|
|
|
fc_exch_hold(ep); /* hold for timer */
|
|
|
|
if (!queue_delayed_work(fc_exch_workqueue, &ep->timeout_work,
|
2016-10-13 13:10:37 +00:00
|
|
|
msecs_to_jiffies(timer_msec))) {
|
|
|
|
FC_EXCH_DBG(ep, "Exchange already queued\n");
|
2013-08-14 15:35:29 +00:00
|
|
|
fc_exch_release(ep);
|
2016-10-13 13:10:37 +00:00
|
|
|
}
|
2012-07-06 17:40:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* fc_exch_timer_set() - Lock the exchange and set the timer
|
|
|
|
* @ep: The exchange whose timer will start
|
|
|
|
* @timer_msec: The timeout period
|
|
|
|
*/
|
|
|
|
static void fc_exch_timer_set(struct fc_exch *ep, unsigned int timer_msec)
|
|
|
|
{
|
|
|
|
spin_lock_bh(&ep->ex_lock);
|
|
|
|
fc_exch_timer_set_locked(ep, timer_msec);
|
|
|
|
spin_unlock_bh(&ep->ex_lock);
|
|
|
|
}
|
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
/**
|
|
|
|
* fc_exch_done_locked() - Complete an exchange with the exchange lock held
|
|
|
|
* @ep: The exchange that is complete
|
2013-08-17 20:34:43 +00:00
|
|
|
*
|
|
|
|
* Note: May sleep if invoked from outside a response handler.
|
2009-11-03 19:47:39 +00:00
|
|
|
*/
|
2008-12-09 23:10:17 +00:00
|
|
|
static int fc_exch_done_locked(struct fc_exch *ep)
|
|
|
|
{
|
|
|
|
int rc = 1;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We must check for completion in case there are two threads
|
|
|
|
* tyring to complete this. But the rrq code will reuse the
|
|
|
|
* ep, and in that case we only clear the resp and set it as
|
|
|
|
* complete, so it can be reused by the timer to send the rrq.
|
|
|
|
*/
|
|
|
|
if (ep->state & FC_EX_DONE)
|
|
|
|
return rc;
|
|
|
|
ep->esb_stat |= ESB_ST_COMPLETE;
|
|
|
|
|
|
|
|
if (!(ep->esb_stat & ESB_ST_REC_QUAL)) {
|
|
|
|
ep->state |= FC_EX_DONE;
|
2012-07-06 17:40:10 +00:00
|
|
|
fc_exch_timer_cancel(ep);
|
2008-12-09 23:10:17 +00:00
|
|
|
rc = 0;
|
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2016-10-13 13:10:50 +00:00
|
|
|
static struct fc_exch fc_quarantine_exch;
|
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
/**
|
|
|
|
* fc_exch_ptr_get() - Return an exchange from an exchange pool
|
|
|
|
* @pool: Exchange Pool to get an exchange from
|
|
|
|
* @index: Index of the exchange within the pool
|
|
|
|
*
|
|
|
|
* Use the index to get an exchange from within an exchange pool. exches
|
|
|
|
* will point to an array of exchange pointers. The index will select
|
|
|
|
* the exchange within the array.
|
|
|
|
*/
|
[SCSI] fcoe, libfc: adds per cpu exch pool within exchange manager(EM)
Adds per cpu exch pool for these reasons:-
1. Currently an EM instance is shared across all cpus to manage
all exches for all cpus. This required em_lock across all
cpus for an exch alloc, free, lookup and reset each frame
and that made em_lock expensive, so instead having per cpu
exch pool with their own per cpu pool lock will likely reduce
locking contention in fast path for an exch alloc, free and
lookup.
2. Per cpu exch pool will likely improve cache hit ratio since
all frames of an exch will be processed on the same cpu on
which exch originated.
This patch is only prep work to help in keeping complexity of next
patch low, so this patch only sets up per cpu exch pool and related
helper funcs to be used by next patch. The next patch fully makes
use of per cpu exch pool in all code paths ie. tx, rx and reset.
Divides per EM exch id range equally across all cpus to setup per
cpu exch pool. This division is such that lower bits of exch id
carries cpu number info on which exch originated, later a simple
bitwise AND operation on exch id of incoming frame with fc_cpu_mask
retrieves cpu number info to direct all frames to same cpu on which
exch originated. This required a global fc_cpu_mask and fc_cpu_order
initialized to max possible cpus number nr_cpu_ids rounded up to 2's
power, this will be used in mapping exch id and exch ptr array
index in pool during exch allocation, find or reset code paths.
Adds a check in fc_exch_mgr_alloc() to ensure specified min_xid
lower bits are zero since these bits are used to carry cpu info.
Adds and initializes struct fc_exch_pool with all required fields
to manage exches in pool.
Allocates per cpu struct fc_exch_pool with memory for exches array
for range of exches per pool. The exches array memory is followed
by struct fc_exch_pool.
Adds fc_exch_ptr_get/set() helper functions to get/set exch ptr in
pool exches array at specified array index.
Increases default FCOE_MAX_XID to 0x0FFF from 0x07EF, so that more
exches are available per cpu after above described exch id range
division across all cpus to each pool.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:47 +00:00
|
|
|
static inline struct fc_exch *fc_exch_ptr_get(struct fc_exch_pool *pool,
|
|
|
|
u16 index)
|
|
|
|
{
|
|
|
|
struct fc_exch **exches = (struct fc_exch **)(pool + 1);
|
|
|
|
return exches[index];
|
|
|
|
}
|
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
/**
|
|
|
|
* fc_exch_ptr_set() - Assign an exchange to a slot in an exchange pool
|
|
|
|
* @pool: The pool to assign the exchange to
|
|
|
|
* @index: The index in the pool where the exchange will be assigned
|
|
|
|
* @ep: The exchange to assign to the pool
|
|
|
|
*/
|
[SCSI] fcoe, libfc: adds per cpu exch pool within exchange manager(EM)
Adds per cpu exch pool for these reasons:-
1. Currently an EM instance is shared across all cpus to manage
all exches for all cpus. This required em_lock across all
cpus for an exch alloc, free, lookup and reset each frame
and that made em_lock expensive, so instead having per cpu
exch pool with their own per cpu pool lock will likely reduce
locking contention in fast path for an exch alloc, free and
lookup.
2. Per cpu exch pool will likely improve cache hit ratio since
all frames of an exch will be processed on the same cpu on
which exch originated.
This patch is only prep work to help in keeping complexity of next
patch low, so this patch only sets up per cpu exch pool and related
helper funcs to be used by next patch. The next patch fully makes
use of per cpu exch pool in all code paths ie. tx, rx and reset.
Divides per EM exch id range equally across all cpus to setup per
cpu exch pool. This division is such that lower bits of exch id
carries cpu number info on which exch originated, later a simple
bitwise AND operation on exch id of incoming frame with fc_cpu_mask
retrieves cpu number info to direct all frames to same cpu on which
exch originated. This required a global fc_cpu_mask and fc_cpu_order
initialized to max possible cpus number nr_cpu_ids rounded up to 2's
power, this will be used in mapping exch id and exch ptr array
index in pool during exch allocation, find or reset code paths.
Adds a check in fc_exch_mgr_alloc() to ensure specified min_xid
lower bits are zero since these bits are used to carry cpu info.
Adds and initializes struct fc_exch_pool with all required fields
to manage exches in pool.
Allocates per cpu struct fc_exch_pool with memory for exches array
for range of exches per pool. The exches array memory is followed
by struct fc_exch_pool.
Adds fc_exch_ptr_get/set() helper functions to get/set exch ptr in
pool exches array at specified array index.
Increases default FCOE_MAX_XID to 0x0FFF from 0x07EF, so that more
exches are available per cpu after above described exch id range
division across all cpus to each pool.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:47 +00:00
|
|
|
static inline void fc_exch_ptr_set(struct fc_exch_pool *pool, u16 index,
|
|
|
|
struct fc_exch *ep)
|
|
|
|
{
|
|
|
|
((struct fc_exch **)(pool + 1))[index] = ep;
|
|
|
|
}
|
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
/**
|
|
|
|
* fc_exch_delete() - Delete an exchange
|
|
|
|
* @ep: The exchange to be deleted
|
|
|
|
*/
|
[SCSI] fcoe, libfc: fully makes use of per cpu exch pool and then removes em_lock
1. Updates fcoe_rcv() to queue incoming frames to the fcoe per
cpu thread on which this frame's exch was originated and simply
use current cpu for request exch not originated by initiator.
It is redundant to add this code under CONFIG_SMP, so removes
CONFIG_SMP uses around this code.
2. Updates fc_exch_em_alloc, fc_exch_delete, fc_exch_find to use
per cpu exch pools, here fc_exch_delete is rename of older
fc_exch_mgr_delete_ep since ep/exch are now deleted in pools
of EM and so brief new name is sufficient and better name.
Updates these functions to map exch id to their index into exch
pool using fc_cpu_mask, fc_cpu_order and EM min_xid.
This mapping is as per detailed explanation about this in
last patch and basically this is just as lower fc_cpu_mask
bits of exch id as cpu number and upper bit sum of EM min_xid
and exch index in pool.
Uses pool next_index to keep track of exch allocation from
pool along with pool_max_index as upper bound of exches array
in pool.
3. Adds exch pool ptr to fc_exch to free exch to its pool in
fc_exch_delete.
4. Updates fc_exch_mgr_reset to reset all exch pools of an EM,
this required adding fc_exch_pool_reset func to reset exches
in pool and then have fc_exch_mgr_reset call fc_exch_pool_reset
for each pool within each EM for a lport.
5. Removes no longer needed exches array, em_lock, next_xid, and
total_exches from struct fc_exch_mgr, these are not needed after
use of per cpu exch pool, also removes not used max_read,
last_read from struct fc_exch_mgr.
6. Updates locking notes for exch pool lock with fc_exch lock and
uses pool lock in exch allocation, lookup and reset.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:53 +00:00
|
|
|
static void fc_exch_delete(struct fc_exch *ep)
|
2008-12-09 23:10:17 +00:00
|
|
|
{
|
[SCSI] fcoe, libfc: fully makes use of per cpu exch pool and then removes em_lock
1. Updates fcoe_rcv() to queue incoming frames to the fcoe per
cpu thread on which this frame's exch was originated and simply
use current cpu for request exch not originated by initiator.
It is redundant to add this code under CONFIG_SMP, so removes
CONFIG_SMP uses around this code.
2. Updates fc_exch_em_alloc, fc_exch_delete, fc_exch_find to use
per cpu exch pools, here fc_exch_delete is rename of older
fc_exch_mgr_delete_ep since ep/exch are now deleted in pools
of EM and so brief new name is sufficient and better name.
Updates these functions to map exch id to their index into exch
pool using fc_cpu_mask, fc_cpu_order and EM min_xid.
This mapping is as per detailed explanation about this in
last patch and basically this is just as lower fc_cpu_mask
bits of exch id as cpu number and upper bit sum of EM min_xid
and exch index in pool.
Uses pool next_index to keep track of exch allocation from
pool along with pool_max_index as upper bound of exches array
in pool.
3. Adds exch pool ptr to fc_exch to free exch to its pool in
fc_exch_delete.
4. Updates fc_exch_mgr_reset to reset all exch pools of an EM,
this required adding fc_exch_pool_reset func to reset exches
in pool and then have fc_exch_mgr_reset call fc_exch_pool_reset
for each pool within each EM for a lport.
5. Removes no longer needed exches array, em_lock, next_xid, and
total_exches from struct fc_exch_mgr, these are not needed after
use of per cpu exch pool, also removes not used max_read,
last_read from struct fc_exch_mgr.
6. Updates locking notes for exch pool lock with fc_exch lock and
uses pool lock in exch allocation, lookup and reset.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:53 +00:00
|
|
|
struct fc_exch_pool *pool;
|
2010-12-01 00:18:17 +00:00
|
|
|
u16 index;
|
2008-12-09 23:10:17 +00:00
|
|
|
|
[SCSI] fcoe, libfc: fully makes use of per cpu exch pool and then removes em_lock
1. Updates fcoe_rcv() to queue incoming frames to the fcoe per
cpu thread on which this frame's exch was originated and simply
use current cpu for request exch not originated by initiator.
It is redundant to add this code under CONFIG_SMP, so removes
CONFIG_SMP uses around this code.
2. Updates fc_exch_em_alloc, fc_exch_delete, fc_exch_find to use
per cpu exch pools, here fc_exch_delete is rename of older
fc_exch_mgr_delete_ep since ep/exch are now deleted in pools
of EM and so brief new name is sufficient and better name.
Updates these functions to map exch id to their index into exch
pool using fc_cpu_mask, fc_cpu_order and EM min_xid.
This mapping is as per detailed explanation about this in
last patch and basically this is just as lower fc_cpu_mask
bits of exch id as cpu number and upper bit sum of EM min_xid
and exch index in pool.
Uses pool next_index to keep track of exch allocation from
pool along with pool_max_index as upper bound of exches array
in pool.
3. Adds exch pool ptr to fc_exch to free exch to its pool in
fc_exch_delete.
4. Updates fc_exch_mgr_reset to reset all exch pools of an EM,
this required adding fc_exch_pool_reset func to reset exches
in pool and then have fc_exch_mgr_reset call fc_exch_pool_reset
for each pool within each EM for a lport.
5. Removes no longer needed exches array, em_lock, next_xid, and
total_exches from struct fc_exch_mgr, these are not needed after
use of per cpu exch pool, also removes not used max_read,
last_read from struct fc_exch_mgr.
6. Updates locking notes for exch pool lock with fc_exch lock and
uses pool lock in exch allocation, lookup and reset.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:53 +00:00
|
|
|
pool = ep->pool;
|
|
|
|
spin_lock_bh(&pool->lock);
|
|
|
|
WARN_ON(pool->total_exches <= 0);
|
|
|
|
pool->total_exches--;
|
2010-12-01 00:18:17 +00:00
|
|
|
|
|
|
|
/* update cache of free slot */
|
|
|
|
index = (ep->xid - ep->em->min_xid) >> fc_cpu_order;
|
2016-10-13 13:10:50 +00:00
|
|
|
if (!(ep->state & FC_EX_QUARANTINE)) {
|
|
|
|
if (pool->left == FC_XID_UNKNOWN)
|
|
|
|
pool->left = index;
|
|
|
|
else if (pool->right == FC_XID_UNKNOWN)
|
|
|
|
pool->right = index;
|
|
|
|
else
|
|
|
|
pool->next_index = index;
|
|
|
|
fc_exch_ptr_set(pool, index, NULL);
|
|
|
|
} else {
|
|
|
|
fc_exch_ptr_set(pool, index, &fc_quarantine_exch);
|
|
|
|
}
|
2008-12-09 23:10:17 +00:00
|
|
|
list_del(&ep->ex_list);
|
[SCSI] fcoe, libfc: fully makes use of per cpu exch pool and then removes em_lock
1. Updates fcoe_rcv() to queue incoming frames to the fcoe per
cpu thread on which this frame's exch was originated and simply
use current cpu for request exch not originated by initiator.
It is redundant to add this code under CONFIG_SMP, so removes
CONFIG_SMP uses around this code.
2. Updates fc_exch_em_alloc, fc_exch_delete, fc_exch_find to use
per cpu exch pools, here fc_exch_delete is rename of older
fc_exch_mgr_delete_ep since ep/exch are now deleted in pools
of EM and so brief new name is sufficient and better name.
Updates these functions to map exch id to their index into exch
pool using fc_cpu_mask, fc_cpu_order and EM min_xid.
This mapping is as per detailed explanation about this in
last patch and basically this is just as lower fc_cpu_mask
bits of exch id as cpu number and upper bit sum of EM min_xid
and exch index in pool.
Uses pool next_index to keep track of exch allocation from
pool along with pool_max_index as upper bound of exches array
in pool.
3. Adds exch pool ptr to fc_exch to free exch to its pool in
fc_exch_delete.
4. Updates fc_exch_mgr_reset to reset all exch pools of an EM,
this required adding fc_exch_pool_reset func to reset exches
in pool and then have fc_exch_mgr_reset call fc_exch_pool_reset
for each pool within each EM for a lport.
5. Removes no longer needed exches array, em_lock, next_xid, and
total_exches from struct fc_exch_mgr, these are not needed after
use of per cpu exch pool, also removes not used max_read,
last_read from struct fc_exch_mgr.
6. Updates locking notes for exch pool lock with fc_exch lock and
uses pool lock in exch allocation, lookup and reset.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:53 +00:00
|
|
|
spin_unlock_bh(&pool->lock);
|
2008-12-09 23:10:17 +00:00
|
|
|
fc_exch_release(ep); /* drop hold for exch in mp */
|
|
|
|
}
|
|
|
|
|
2013-05-03 19:34:15 +00:00
|
|
|
static int fc_seq_send_locked(struct fc_lport *lport, struct fc_seq *sp,
|
2013-08-14 15:37:52 +00:00
|
|
|
struct fc_frame *fp)
|
2009-11-03 19:45:47 +00:00
|
|
|
{
|
|
|
|
struct fc_exch *ep;
|
|
|
|
struct fc_frame_header *fh = fc_frame_header_get(fp);
|
2013-08-14 15:37:52 +00:00
|
|
|
int error = -ENXIO;
|
2009-11-03 19:47:39 +00:00
|
|
|
u32 f_ctl;
|
2011-10-28 18:34:12 +00:00
|
|
|
u8 fh_type = fh->fh_type;
|
2009-11-03 19:45:47 +00:00
|
|
|
|
|
|
|
ep = fc_seq_exch(sp);
|
2013-08-14 15:37:52 +00:00
|
|
|
|
|
|
|
if (ep->esb_stat & (ESB_ST_COMPLETE | ESB_ST_ABNORMAL)) {
|
|
|
|
fc_frame_free(fp);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2013-05-03 19:34:15 +00:00
|
|
|
WARN_ON(!(ep->esb_stat & ESB_ST_SEQ_INIT));
|
2009-11-03 19:45:47 +00:00
|
|
|
|
|
|
|
f_ctl = ntoh24(fh->fh_f_ctl);
|
|
|
|
fc_exch_setup_hdr(ep, fp, f_ctl);
|
[SCSI] libfc: track FIP exchanges
When an exchange is received with a FIP encapsulation, we need
to know that the response must be sent via FIP and what the original
ELS opcode was. This becomes important for VN2VN mode, where we may
receive FLOGI or LOGO from several peer VN_ports, and the LS_ACC or
LS_RJT must be sent FIP-encapsulated with the correct sub-type.
Add a field to the struct fc_frame, fr_encaps, to indicate the
encapsulation values. That term is chosen to be neutral and
LLD-agnostic in case non-FCoE/FIP LLDs might find it useful.
The frame fr_encaps is transferred from the ingress frame to the
exchange by fc_exch_recv_req(), and back to the outgoing frame
by fc_seq_send().
This is taking the last byte in the skb->cb array. If needed,
we could combine the info in sof, eof, flags, and encaps
together into one field, but it'd be better to do that if
and when its needed.
Signed-off-by: Joe Eykholt <jeykholt@cisco.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2010-07-20 22:20:14 +00:00
|
|
|
fr_encaps(fp) = ep->encaps;
|
2009-11-03 19:45:47 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* update sequence count if this frame is carrying
|
|
|
|
* multiple FC frames when sequence offload is enabled
|
|
|
|
* by LLD.
|
|
|
|
*/
|
|
|
|
if (fr_max_payload(fp))
|
|
|
|
sp->cnt += DIV_ROUND_UP((fr_len(fp) - sizeof(*fh)),
|
|
|
|
fr_max_payload(fp));
|
|
|
|
else
|
|
|
|
sp->cnt++;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Send the frame.
|
|
|
|
*/
|
2009-11-03 19:47:39 +00:00
|
|
|
error = lport->tt.frame_send(lport, fp);
|
2009-11-03 19:45:47 +00:00
|
|
|
|
2011-10-28 18:34:12 +00:00
|
|
|
if (fh_type == FC_TYPE_BLS)
|
2013-05-03 19:34:15 +00:00
|
|
|
goto out;
|
2011-08-25 19:40:52 +00:00
|
|
|
|
2009-11-03 19:45:47 +00:00
|
|
|
/*
|
|
|
|
* Update the exchange and sequence flags,
|
|
|
|
* assuming all frames for the sequence have been sent.
|
|
|
|
* We can only be called to send once for each sequence.
|
|
|
|
*/
|
|
|
|
ep->f_ctl = f_ctl & ~FC_FC_FIRST_SEQ; /* not first seq */
|
2010-03-13 00:08:29 +00:00
|
|
|
if (f_ctl & FC_FC_SEQ_INIT)
|
2009-11-03 19:45:47 +00:00
|
|
|
ep->esb_stat &= ~ESB_ST_SEQ_INIT;
|
2013-05-03 19:34:15 +00:00
|
|
|
out:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* fc_seq_send() - Send a frame using existing sequence/exchange pair
|
|
|
|
* @lport: The local port that the exchange will be sent on
|
|
|
|
* @sp: The sequence to be sent
|
|
|
|
* @fp: The frame to be sent on the exchange
|
2013-08-14 15:37:52 +00:00
|
|
|
*
|
|
|
|
* Note: The frame will be freed either by a direct call to fc_frame_free(fp)
|
|
|
|
* or indirectly by calling libfc_function_template.frame_send().
|
2013-05-03 19:34:15 +00:00
|
|
|
*/
|
2016-10-18 08:01:48 +00:00
|
|
|
int fc_seq_send(struct fc_lport *lport, struct fc_seq *sp, struct fc_frame *fp)
|
2013-05-03 19:34:15 +00:00
|
|
|
{
|
|
|
|
struct fc_exch *ep;
|
|
|
|
int error;
|
|
|
|
ep = fc_seq_exch(sp);
|
|
|
|
spin_lock_bh(&ep->ex_lock);
|
|
|
|
error = fc_seq_send_locked(lport, sp, fp);
|
2009-11-03 19:45:47 +00:00
|
|
|
spin_unlock_bh(&ep->ex_lock);
|
|
|
|
return error;
|
|
|
|
}
|
2016-10-18 08:01:48 +00:00
|
|
|
EXPORT_SYMBOL(fc_seq_send);
|
2009-11-03 19:45:47 +00:00
|
|
|
|
|
|
|
/**
|
2009-11-03 19:47:39 +00:00
|
|
|
* fc_seq_alloc() - Allocate a sequence for a given exchange
|
|
|
|
* @ep: The exchange to allocate a new sequence for
|
|
|
|
* @seq_id: The sequence ID to be used
|
2009-11-03 19:45:47 +00:00
|
|
|
*
|
|
|
|
* We don't support multiple originated sequences on the same exchange.
|
|
|
|
* By implication, any previously originated sequence on this exchange
|
|
|
|
* is complete, and we reallocate the same sequence.
|
|
|
|
*/
|
|
|
|
static struct fc_seq *fc_seq_alloc(struct fc_exch *ep, u8 seq_id)
|
|
|
|
{
|
|
|
|
struct fc_seq *sp;
|
|
|
|
|
|
|
|
sp = &ep->seq;
|
|
|
|
sp->ssb_stat = 0;
|
|
|
|
sp->cnt = 0;
|
|
|
|
sp->id = seq_id;
|
|
|
|
return sp;
|
|
|
|
}
|
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
/**
|
|
|
|
* fc_seq_start_next_locked() - Allocate a new sequence on the same
|
|
|
|
* exchange as the supplied sequence
|
|
|
|
* @sp: The sequence/exchange to get a new sequence for
|
|
|
|
*/
|
2009-11-03 19:45:47 +00:00
|
|
|
static struct fc_seq *fc_seq_start_next_locked(struct fc_seq *sp)
|
|
|
|
{
|
|
|
|
struct fc_exch *ep = fc_seq_exch(sp);
|
|
|
|
|
|
|
|
sp = fc_seq_alloc(ep, ep->seq_id++);
|
|
|
|
FC_EXCH_DBG(ep, "f_ctl %6x seq %2x\n",
|
|
|
|
ep->f_ctl, sp->id);
|
|
|
|
return sp;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-11-03 19:47:39 +00:00
|
|
|
* fc_seq_start_next() - Lock the exchange and get a new sequence
|
|
|
|
* for a given sequence/exchange pair
|
|
|
|
* @sp: The sequence/exchange to get a new exchange for
|
2009-11-03 19:45:47 +00:00
|
|
|
*/
|
2016-10-18 08:01:51 +00:00
|
|
|
struct fc_seq *fc_seq_start_next(struct fc_seq *sp)
|
2009-11-03 19:45:47 +00:00
|
|
|
{
|
|
|
|
struct fc_exch *ep = fc_seq_exch(sp);
|
|
|
|
|
|
|
|
spin_lock_bh(&ep->ex_lock);
|
|
|
|
sp = fc_seq_start_next_locked(sp);
|
|
|
|
spin_unlock_bh(&ep->ex_lock);
|
|
|
|
|
|
|
|
return sp;
|
|
|
|
}
|
2016-10-18 08:01:51 +00:00
|
|
|
EXPORT_SYMBOL(fc_seq_start_next);
|
2009-11-03 19:45:47 +00:00
|
|
|
|
2011-01-29 00:04:08 +00:00
|
|
|
/*
|
|
|
|
* Set the response handler for the exchange associated with a sequence.
|
2013-08-17 20:34:43 +00:00
|
|
|
*
|
|
|
|
* Note: May sleep if invoked from outside a response handler.
|
2011-01-29 00:04:08 +00:00
|
|
|
*/
|
2016-10-18 08:01:52 +00:00
|
|
|
void fc_seq_set_resp(struct fc_seq *sp,
|
|
|
|
void (*resp)(struct fc_seq *, struct fc_frame *, void *),
|
|
|
|
void *arg)
|
2011-01-29 00:04:08 +00:00
|
|
|
{
|
|
|
|
struct fc_exch *ep = fc_seq_exch(sp);
|
2013-08-17 20:34:43 +00:00
|
|
|
DEFINE_WAIT(wait);
|
2011-01-29 00:04:08 +00:00
|
|
|
|
|
|
|
spin_lock_bh(&ep->ex_lock);
|
2013-08-17 20:34:43 +00:00
|
|
|
while (ep->resp_active && ep->resp_task != current) {
|
|
|
|
prepare_to_wait(&ep->resp_wq, &wait, TASK_UNINTERRUPTIBLE);
|
|
|
|
spin_unlock_bh(&ep->ex_lock);
|
|
|
|
|
|
|
|
schedule();
|
|
|
|
|
|
|
|
spin_lock_bh(&ep->ex_lock);
|
|
|
|
}
|
|
|
|
finish_wait(&ep->resp_wq, &wait);
|
2011-01-29 00:04:08 +00:00
|
|
|
ep->resp = resp;
|
|
|
|
ep->arg = arg;
|
|
|
|
spin_unlock_bh(&ep->ex_lock);
|
|
|
|
}
|
2016-10-18 08:01:52 +00:00
|
|
|
EXPORT_SYMBOL(fc_seq_set_resp);
|
2011-01-29 00:04:08 +00:00
|
|
|
|
2009-11-03 19:45:47 +00:00
|
|
|
/**
|
2011-08-25 19:40:52 +00:00
|
|
|
* fc_exch_abort_locked() - Abort an exchange
|
|
|
|
* @ep: The exchange to be aborted
|
2009-11-03 19:47:39 +00:00
|
|
|
* @timer_msec: The period of time to wait before aborting
|
|
|
|
*
|
2016-10-18 08:01:49 +00:00
|
|
|
* Abort an exchange and sequence. Generally called because of a
|
|
|
|
* exchange timeout or an abort from the upper layer.
|
|
|
|
*
|
|
|
|
* A timer_msec can be specified for abort timeout, if non-zero
|
|
|
|
* timer_msec value is specified then exchange resp handler
|
|
|
|
* will be called with timeout error if no response to abort.
|
|
|
|
*
|
2011-08-25 19:40:52 +00:00
|
|
|
* Locking notes: Called with exch lock held
|
|
|
|
*
|
|
|
|
* Return value: 0 on success else error code
|
2009-11-03 19:45:47 +00:00
|
|
|
*/
|
2011-08-25 19:40:52 +00:00
|
|
|
static int fc_exch_abort_locked(struct fc_exch *ep,
|
|
|
|
unsigned int timer_msec)
|
2008-12-09 23:10:17 +00:00
|
|
|
{
|
|
|
|
struct fc_seq *sp;
|
|
|
|
struct fc_frame *fp;
|
|
|
|
int error;
|
|
|
|
|
2016-10-13 13:10:37 +00:00
|
|
|
FC_EXCH_DBG(ep, "exch: abort, time %d msecs\n", timer_msec);
|
2008-12-09 23:10:17 +00:00
|
|
|
if (ep->esb_stat & (ESB_ST_COMPLETE | ESB_ST_ABNORMAL) ||
|
2016-10-13 13:10:37 +00:00
|
|
|
ep->state & (FC_EX_DONE | FC_EX_RST_CLEANUP)) {
|
|
|
|
FC_EXCH_DBG(ep, "exch: already completed esb %x state %x\n",
|
|
|
|
ep->esb_stat, ep->state);
|
2008-12-09 23:10:17 +00:00
|
|
|
return -ENXIO;
|
2016-10-13 13:10:37 +00:00
|
|
|
}
|
2008-12-09 23:10:17 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Send the abort on a new sequence if possible.
|
|
|
|
*/
|
|
|
|
sp = fc_seq_start_next_locked(&ep->seq);
|
2011-08-25 19:40:52 +00:00
|
|
|
if (!sp)
|
2008-12-09 23:10:17 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
if (timer_msec)
|
|
|
|
fc_exch_timer_set_locked(ep, timer_msec);
|
|
|
|
|
2013-08-14 15:37:52 +00:00
|
|
|
if (ep->sid) {
|
|
|
|
/*
|
|
|
|
* Send an abort for the sequence that timed out.
|
|
|
|
*/
|
|
|
|
fp = fc_frame_alloc(ep->lp, 0);
|
|
|
|
if (fp) {
|
|
|
|
ep->esb_stat |= ESB_ST_SEQ_INIT;
|
|
|
|
fc_fill_fc_hdr(fp, FC_RCTL_BA_ABTS, ep->did, ep->sid,
|
|
|
|
FC_TYPE_BLS, FC_FC_END_SEQ |
|
|
|
|
FC_FC_SEQ_INIT, 0);
|
|
|
|
error = fc_seq_send_locked(ep->lp, sp, fp);
|
|
|
|
} else {
|
|
|
|
error = -ENOBUFS;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* If not logged into the fabric, don't send ABTS but leave
|
|
|
|
* sequence active until next timeout.
|
|
|
|
*/
|
|
|
|
error = 0;
|
|
|
|
}
|
|
|
|
ep->esb_stat |= ESB_ST_ABNORMAL;
|
2008-12-09 23:10:17 +00:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2011-08-25 19:40:52 +00:00
|
|
|
/**
|
|
|
|
* fc_seq_exch_abort() - Abort an exchange and sequence
|
|
|
|
* @req_sp: The sequence to be aborted
|
|
|
|
* @timer_msec: The period of time to wait before aborting
|
|
|
|
*
|
|
|
|
* Generally called because of a timeout or an abort from the upper layer.
|
|
|
|
*
|
|
|
|
* Return value: 0 on success else error code
|
|
|
|
*/
|
2016-10-18 08:01:49 +00:00
|
|
|
int fc_seq_exch_abort(const struct fc_seq *req_sp, unsigned int timer_msec)
|
2011-08-25 19:40:52 +00:00
|
|
|
{
|
|
|
|
struct fc_exch *ep;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
ep = fc_seq_exch(req_sp);
|
|
|
|
spin_lock_bh(&ep->ex_lock);
|
|
|
|
error = fc_exch_abort_locked(ep, timer_msec);
|
|
|
|
spin_unlock_bh(&ep->ex_lock);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2013-08-17 20:34:43 +00:00
|
|
|
/**
|
|
|
|
* fc_invoke_resp() - invoke ep->resp()
|
|
|
|
*
|
|
|
|
* Notes:
|
|
|
|
* It is assumed that after initialization finished (this means the
|
|
|
|
* first unlock of ex_lock after fc_exch_alloc()) ep->resp and ep->arg are
|
|
|
|
* modified only via fc_seq_set_resp(). This guarantees that none of these
|
|
|
|
* two variables changes if ep->resp_active > 0.
|
|
|
|
*
|
|
|
|
* If an fc_seq_set_resp() call is busy modifying ep->resp and ep->arg when
|
|
|
|
* this function is invoked, the first spin_lock_bh() call in this function
|
|
|
|
* will wait until fc_seq_set_resp() has finished modifying these variables.
|
|
|
|
*
|
|
|
|
* Since fc_exch_done() invokes fc_seq_set_resp() it is guaranteed that that
|
|
|
|
* ep->resp() won't be invoked after fc_exch_done() has returned.
|
|
|
|
*
|
|
|
|
* The response handler itself may invoke fc_exch_done(), which will clear the
|
|
|
|
* ep->resp pointer.
|
|
|
|
*
|
|
|
|
* Return value:
|
|
|
|
* Returns true if and only if ep->resp has been invoked.
|
|
|
|
*/
|
|
|
|
static bool fc_invoke_resp(struct fc_exch *ep, struct fc_seq *sp,
|
|
|
|
struct fc_frame *fp)
|
|
|
|
{
|
|
|
|
void (*resp)(struct fc_seq *, struct fc_frame *fp, void *arg);
|
|
|
|
void *arg;
|
|
|
|
bool res = false;
|
|
|
|
|
|
|
|
spin_lock_bh(&ep->ex_lock);
|
|
|
|
ep->resp_active++;
|
|
|
|
if (ep->resp_task != current)
|
|
|
|
ep->resp_task = !ep->resp_task ? current : NULL;
|
|
|
|
resp = ep->resp;
|
|
|
|
arg = ep->arg;
|
|
|
|
spin_unlock_bh(&ep->ex_lock);
|
|
|
|
|
|
|
|
if (resp) {
|
|
|
|
resp(sp, fp, arg);
|
|
|
|
res = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
spin_lock_bh(&ep->ex_lock);
|
|
|
|
if (--ep->resp_active == 0)
|
|
|
|
ep->resp_task = NULL;
|
|
|
|
spin_unlock_bh(&ep->ex_lock);
|
|
|
|
|
|
|
|
if (ep->resp_active == 0)
|
|
|
|
wake_up(&ep->resp_wq);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
/**
|
|
|
|
* fc_exch_timeout() - Handle exchange timer expiration
|
|
|
|
* @work: The work_struct identifying the exchange that timed out
|
2008-12-09 23:10:17 +00:00
|
|
|
*/
|
|
|
|
static void fc_exch_timeout(struct work_struct *work)
|
|
|
|
{
|
|
|
|
struct fc_exch *ep = container_of(work, struct fc_exch,
|
|
|
|
timeout_work.work);
|
|
|
|
struct fc_seq *sp = &ep->seq;
|
|
|
|
u32 e_stat;
|
|
|
|
int rc = 1;
|
|
|
|
|
2016-10-13 13:10:37 +00:00
|
|
|
FC_EXCH_DBG(ep, "Exchange timed out state %x\n", ep->state);
|
2009-08-25 20:58:37 +00:00
|
|
|
|
2008-12-09 23:10:17 +00:00
|
|
|
spin_lock_bh(&ep->ex_lock);
|
|
|
|
if (ep->state & (FC_EX_RST_CLEANUP | FC_EX_DONE))
|
|
|
|
goto unlock;
|
|
|
|
|
|
|
|
e_stat = ep->esb_stat;
|
|
|
|
if (e_stat & ESB_ST_COMPLETE) {
|
|
|
|
ep->esb_stat = e_stat & ~ESB_ST_REC_QUAL;
|
2009-07-29 00:33:37 +00:00
|
|
|
spin_unlock_bh(&ep->ex_lock);
|
2008-12-09 23:10:17 +00:00
|
|
|
if (e_stat & ESB_ST_REC_QUAL)
|
|
|
|
fc_exch_rrq(ep);
|
|
|
|
goto done;
|
|
|
|
} else {
|
|
|
|
if (e_stat & ESB_ST_ABNORMAL)
|
|
|
|
rc = fc_exch_done_locked(ep);
|
|
|
|
spin_unlock_bh(&ep->ex_lock);
|
2011-02-25 23:02:56 +00:00
|
|
|
if (!rc)
|
|
|
|
fc_exch_delete(ep);
|
2013-08-17 20:34:43 +00:00
|
|
|
fc_invoke_resp(ep, sp, ERR_PTR(-FC_EX_TIMEOUT));
|
|
|
|
fc_seq_set_resp(sp, NULL, ep->arg);
|
2008-12-09 23:10:17 +00:00
|
|
|
fc_seq_exch_abort(sp, 2 * ep->r_a_tov);
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
unlock:
|
|
|
|
spin_unlock_bh(&ep->ex_lock);
|
|
|
|
done:
|
|
|
|
/*
|
|
|
|
* This release matches the hold taken when the timer was set.
|
|
|
|
*/
|
|
|
|
fc_exch_release(ep);
|
|
|
|
}
|
|
|
|
|
[SCSI] fcoe, fnic, libfc: modifies current code paths to use EM anchor list
Modifies current code to use EM anchor list in EM allocation, EM free,
EM reset, exch allocation and exch lookup code paths.
1. Modifies fc_exch_mgr_alloc to accept EM match function and then
have allocated EM added to the lport using fc_exch_mgr_add API
while also updating EM kref for newly added EM.
2. Updates fc_exch_mgr_free API to accept only lport pointer instead
EM and then have this API free all EMs of the lport from EM anchor
list.
3. Removes single lport pointer link from the EM, which was used in
associating lport pointer in newly allocated exchange. Instead have
lport pointer passed along new exchange allocation call path and
then store passed lport pointer in newly allocated exchange, this
will allow a single EM instance to be used across more than one
lport and used in EM reset to reset only lport specific exchanges.
4. Modifies fc_exch_mgr_reset to reset all EMs from the EM anchor list
of the lport, adds additional exch lport pointer (ep->lp) check for
shared EM case to reset exchange specific to a lport requested reset.
5. Updates exch allocation API fc_exch_alloc to use EM anchor list and
its anchor match func pointer. The fc_exch_alloc will walk the list
of EMs until it finds a match, a match will be either null match
func pointer or call to match function returning true value.
6. Updates fc_exch_recv to accept incoming frame on local port using
only lport pointer and frame pointer without specifying EM instance
of incoming frame. Instead modified fc_exch_recv to locate EM for the
incoming frame by matching xid of incoming frame against a EM xid range.
This change was required to use EM list in libfc Rx path and after this
change the lport fc_exch_mgr pointer emp is not needed anymore, so
removed emp pointer.
7. Updates fnic for removed lport emp pointer and above modified libfc APIs
fc_exch_recv, fc_exch_mgr_alloc and fc_exch_mgr_free.
8. Removes exch_get and exch_put from libfc_function_template as these
are no longer needed with EM anchor list and its match function use.
Also removes its default function fc_exch_get.
A defect this patch introduced regarding the libfc initialization order in
the fnic driver was fixed by Joe Eykholt <jeykholt@cisco.com>.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-07-30 00:05:10 +00:00
|
|
|
/**
|
2009-11-03 19:47:39 +00:00
|
|
|
* fc_exch_em_alloc() - Allocate an exchange from a specified EM.
|
|
|
|
* @lport: The local port that the exchange is for
|
|
|
|
* @mp: The exchange manager that will allocate the exchange
|
2008-12-09 23:10:17 +00:00
|
|
|
*
|
2009-07-30 00:05:21 +00:00
|
|
|
* Returns pointer to allocated fc_exch with exch lock held.
|
2008-12-09 23:10:17 +00:00
|
|
|
*/
|
[SCSI] fcoe, fnic, libfc: modifies current code paths to use EM anchor list
Modifies current code to use EM anchor list in EM allocation, EM free,
EM reset, exch allocation and exch lookup code paths.
1. Modifies fc_exch_mgr_alloc to accept EM match function and then
have allocated EM added to the lport using fc_exch_mgr_add API
while also updating EM kref for newly added EM.
2. Updates fc_exch_mgr_free API to accept only lport pointer instead
EM and then have this API free all EMs of the lport from EM anchor
list.
3. Removes single lport pointer link from the EM, which was used in
associating lport pointer in newly allocated exchange. Instead have
lport pointer passed along new exchange allocation call path and
then store passed lport pointer in newly allocated exchange, this
will allow a single EM instance to be used across more than one
lport and used in EM reset to reset only lport specific exchanges.
4. Modifies fc_exch_mgr_reset to reset all EMs from the EM anchor list
of the lport, adds additional exch lport pointer (ep->lp) check for
shared EM case to reset exchange specific to a lport requested reset.
5. Updates exch allocation API fc_exch_alloc to use EM anchor list and
its anchor match func pointer. The fc_exch_alloc will walk the list
of EMs until it finds a match, a match will be either null match
func pointer or call to match function returning true value.
6. Updates fc_exch_recv to accept incoming frame on local port using
only lport pointer and frame pointer without specifying EM instance
of incoming frame. Instead modified fc_exch_recv to locate EM for the
incoming frame by matching xid of incoming frame against a EM xid range.
This change was required to use EM list in libfc Rx path and after this
change the lport fc_exch_mgr pointer emp is not needed anymore, so
removed emp pointer.
7. Updates fnic for removed lport emp pointer and above modified libfc APIs
fc_exch_recv, fc_exch_mgr_alloc and fc_exch_mgr_free.
8. Removes exch_get and exch_put from libfc_function_template as these
are no longer needed with EM anchor list and its match function use.
Also removes its default function fc_exch_get.
A defect this patch introduced regarding the libfc initialization order in
the fnic driver was fixed by Joe Eykholt <jeykholt@cisco.com>.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-07-30 00:05:10 +00:00
|
|
|
static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
|
2009-07-30 00:05:21 +00:00
|
|
|
struct fc_exch_mgr *mp)
|
2008-12-09 23:10:17 +00:00
|
|
|
{
|
|
|
|
struct fc_exch *ep;
|
[SCSI] fcoe, libfc: fully makes use of per cpu exch pool and then removes em_lock
1. Updates fcoe_rcv() to queue incoming frames to the fcoe per
cpu thread on which this frame's exch was originated and simply
use current cpu for request exch not originated by initiator.
It is redundant to add this code under CONFIG_SMP, so removes
CONFIG_SMP uses around this code.
2. Updates fc_exch_em_alloc, fc_exch_delete, fc_exch_find to use
per cpu exch pools, here fc_exch_delete is rename of older
fc_exch_mgr_delete_ep since ep/exch are now deleted in pools
of EM and so brief new name is sufficient and better name.
Updates these functions to map exch id to their index into exch
pool using fc_cpu_mask, fc_cpu_order and EM min_xid.
This mapping is as per detailed explanation about this in
last patch and basically this is just as lower fc_cpu_mask
bits of exch id as cpu number and upper bit sum of EM min_xid
and exch index in pool.
Uses pool next_index to keep track of exch allocation from
pool along with pool_max_index as upper bound of exches array
in pool.
3. Adds exch pool ptr to fc_exch to free exch to its pool in
fc_exch_delete.
4. Updates fc_exch_mgr_reset to reset all exch pools of an EM,
this required adding fc_exch_pool_reset func to reset exches
in pool and then have fc_exch_mgr_reset call fc_exch_pool_reset
for each pool within each EM for a lport.
5. Removes no longer needed exches array, em_lock, next_xid, and
total_exches from struct fc_exch_mgr, these are not needed after
use of per cpu exch pool, also removes not used max_read,
last_read from struct fc_exch_mgr.
6. Updates locking notes for exch pool lock with fc_exch lock and
uses pool lock in exch allocation, lookup and reset.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:53 +00:00
|
|
|
unsigned int cpu;
|
|
|
|
u16 index;
|
|
|
|
struct fc_exch_pool *pool;
|
2008-12-09 23:10:17 +00:00
|
|
|
|
|
|
|
/* allocate memory for exchange */
|
|
|
|
ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
|
|
|
|
if (!ep) {
|
|
|
|
atomic_inc(&mp->stats.no_free_exch);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
memset(ep, 0, sizeof(*ep));
|
|
|
|
|
2010-03-13 00:08:55 +00:00
|
|
|
cpu = get_cpu();
|
[SCSI] fcoe, libfc: fully makes use of per cpu exch pool and then removes em_lock
1. Updates fcoe_rcv() to queue incoming frames to the fcoe per
cpu thread on which this frame's exch was originated and simply
use current cpu for request exch not originated by initiator.
It is redundant to add this code under CONFIG_SMP, so removes
CONFIG_SMP uses around this code.
2. Updates fc_exch_em_alloc, fc_exch_delete, fc_exch_find to use
per cpu exch pools, here fc_exch_delete is rename of older
fc_exch_mgr_delete_ep since ep/exch are now deleted in pools
of EM and so brief new name is sufficient and better name.
Updates these functions to map exch id to their index into exch
pool using fc_cpu_mask, fc_cpu_order and EM min_xid.
This mapping is as per detailed explanation about this in
last patch and basically this is just as lower fc_cpu_mask
bits of exch id as cpu number and upper bit sum of EM min_xid
and exch index in pool.
Uses pool next_index to keep track of exch allocation from
pool along with pool_max_index as upper bound of exches array
in pool.
3. Adds exch pool ptr to fc_exch to free exch to its pool in
fc_exch_delete.
4. Updates fc_exch_mgr_reset to reset all exch pools of an EM,
this required adding fc_exch_pool_reset func to reset exches
in pool and then have fc_exch_mgr_reset call fc_exch_pool_reset
for each pool within each EM for a lport.
5. Removes no longer needed exches array, em_lock, next_xid, and
total_exches from struct fc_exch_mgr, these are not needed after
use of per cpu exch pool, also removes not used max_read,
last_read from struct fc_exch_mgr.
6. Updates locking notes for exch pool lock with fc_exch lock and
uses pool lock in exch allocation, lookup and reset.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:53 +00:00
|
|
|
pool = per_cpu_ptr(mp->pool, cpu);
|
|
|
|
spin_lock_bh(&pool->lock);
|
2010-03-13 00:08:55 +00:00
|
|
|
put_cpu();
|
2010-12-01 00:18:17 +00:00
|
|
|
|
|
|
|
/* peek cache of free slot */
|
|
|
|
if (pool->left != FC_XID_UNKNOWN) {
|
2016-10-13 13:10:49 +00:00
|
|
|
if (!WARN_ON(fc_exch_ptr_get(pool, pool->left))) {
|
|
|
|
index = pool->left;
|
|
|
|
pool->left = FC_XID_UNKNOWN;
|
|
|
|
goto hit;
|
|
|
|
}
|
2010-12-01 00:18:17 +00:00
|
|
|
}
|
|
|
|
if (pool->right != FC_XID_UNKNOWN) {
|
2016-10-13 13:10:49 +00:00
|
|
|
if (!WARN_ON(fc_exch_ptr_get(pool, pool->right))) {
|
|
|
|
index = pool->right;
|
|
|
|
pool->right = FC_XID_UNKNOWN;
|
|
|
|
goto hit;
|
|
|
|
}
|
2010-12-01 00:18:17 +00:00
|
|
|
}
|
|
|
|
|
[SCSI] fcoe, libfc: fully makes use of per cpu exch pool and then removes em_lock
1. Updates fcoe_rcv() to queue incoming frames to the fcoe per
cpu thread on which this frame's exch was originated and simply
use current cpu for request exch not originated by initiator.
It is redundant to add this code under CONFIG_SMP, so removes
CONFIG_SMP uses around this code.
2. Updates fc_exch_em_alloc, fc_exch_delete, fc_exch_find to use
per cpu exch pools, here fc_exch_delete is rename of older
fc_exch_mgr_delete_ep since ep/exch are now deleted in pools
of EM and so brief new name is sufficient and better name.
Updates these functions to map exch id to their index into exch
pool using fc_cpu_mask, fc_cpu_order and EM min_xid.
This mapping is as per detailed explanation about this in
last patch and basically this is just as lower fc_cpu_mask
bits of exch id as cpu number and upper bit sum of EM min_xid
and exch index in pool.
Uses pool next_index to keep track of exch allocation from
pool along with pool_max_index as upper bound of exches array
in pool.
3. Adds exch pool ptr to fc_exch to free exch to its pool in
fc_exch_delete.
4. Updates fc_exch_mgr_reset to reset all exch pools of an EM,
this required adding fc_exch_pool_reset func to reset exches
in pool and then have fc_exch_mgr_reset call fc_exch_pool_reset
for each pool within each EM for a lport.
5. Removes no longer needed exches array, em_lock, next_xid, and
total_exches from struct fc_exch_mgr, these are not needed after
use of per cpu exch pool, also removes not used max_read,
last_read from struct fc_exch_mgr.
6. Updates locking notes for exch pool lock with fc_exch lock and
uses pool lock in exch allocation, lookup and reset.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:53 +00:00
|
|
|
index = pool->next_index;
|
|
|
|
/* allocate new exch from pool */
|
|
|
|
while (fc_exch_ptr_get(pool, index)) {
|
|
|
|
index = index == mp->pool_max_index ? 0 : index + 1;
|
|
|
|
if (index == pool->next_index)
|
2008-12-09 23:10:17 +00:00
|
|
|
goto err;
|
|
|
|
}
|
[SCSI] fcoe, libfc: fully makes use of per cpu exch pool and then removes em_lock
1. Updates fcoe_rcv() to queue incoming frames to the fcoe per
cpu thread on which this frame's exch was originated and simply
use current cpu for request exch not originated by initiator.
It is redundant to add this code under CONFIG_SMP, so removes
CONFIG_SMP uses around this code.
2. Updates fc_exch_em_alloc, fc_exch_delete, fc_exch_find to use
per cpu exch pools, here fc_exch_delete is rename of older
fc_exch_mgr_delete_ep since ep/exch are now deleted in pools
of EM and so brief new name is sufficient and better name.
Updates these functions to map exch id to their index into exch
pool using fc_cpu_mask, fc_cpu_order and EM min_xid.
This mapping is as per detailed explanation about this in
last patch and basically this is just as lower fc_cpu_mask
bits of exch id as cpu number and upper bit sum of EM min_xid
and exch index in pool.
Uses pool next_index to keep track of exch allocation from
pool along with pool_max_index as upper bound of exches array
in pool.
3. Adds exch pool ptr to fc_exch to free exch to its pool in
fc_exch_delete.
4. Updates fc_exch_mgr_reset to reset all exch pools of an EM,
this required adding fc_exch_pool_reset func to reset exches
in pool and then have fc_exch_mgr_reset call fc_exch_pool_reset
for each pool within each EM for a lport.
5. Removes no longer needed exches array, em_lock, next_xid, and
total_exches from struct fc_exch_mgr, these are not needed after
use of per cpu exch pool, also removes not used max_read,
last_read from struct fc_exch_mgr.
6. Updates locking notes for exch pool lock with fc_exch lock and
uses pool lock in exch allocation, lookup and reset.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:53 +00:00
|
|
|
pool->next_index = index == mp->pool_max_index ? 0 : index + 1;
|
2010-12-01 00:18:17 +00:00
|
|
|
hit:
|
2008-12-09 23:10:17 +00:00
|
|
|
fc_exch_hold(ep); /* hold for exch in mp */
|
|
|
|
spin_lock_init(&ep->ex_lock);
|
|
|
|
/*
|
|
|
|
* Hold exch lock for caller to prevent fc_exch_reset()
|
|
|
|
* from releasing exch while fc_exch_alloc() caller is
|
|
|
|
* still working on exch.
|
|
|
|
*/
|
|
|
|
spin_lock_bh(&ep->ex_lock);
|
|
|
|
|
[SCSI] fcoe, libfc: fully makes use of per cpu exch pool and then removes em_lock
1. Updates fcoe_rcv() to queue incoming frames to the fcoe per
cpu thread on which this frame's exch was originated and simply
use current cpu for request exch not originated by initiator.
It is redundant to add this code under CONFIG_SMP, so removes
CONFIG_SMP uses around this code.
2. Updates fc_exch_em_alloc, fc_exch_delete, fc_exch_find to use
per cpu exch pools, here fc_exch_delete is rename of older
fc_exch_mgr_delete_ep since ep/exch are now deleted in pools
of EM and so brief new name is sufficient and better name.
Updates these functions to map exch id to their index into exch
pool using fc_cpu_mask, fc_cpu_order and EM min_xid.
This mapping is as per detailed explanation about this in
last patch and basically this is just as lower fc_cpu_mask
bits of exch id as cpu number and upper bit sum of EM min_xid
and exch index in pool.
Uses pool next_index to keep track of exch allocation from
pool along with pool_max_index as upper bound of exches array
in pool.
3. Adds exch pool ptr to fc_exch to free exch to its pool in
fc_exch_delete.
4. Updates fc_exch_mgr_reset to reset all exch pools of an EM,
this required adding fc_exch_pool_reset func to reset exches
in pool and then have fc_exch_mgr_reset call fc_exch_pool_reset
for each pool within each EM for a lport.
5. Removes no longer needed exches array, em_lock, next_xid, and
total_exches from struct fc_exch_mgr, these are not needed after
use of per cpu exch pool, also removes not used max_read,
last_read from struct fc_exch_mgr.
6. Updates locking notes for exch pool lock with fc_exch lock and
uses pool lock in exch allocation, lookup and reset.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:53 +00:00
|
|
|
fc_exch_ptr_set(pool, index, ep);
|
|
|
|
list_add_tail(&ep->ex_list, &pool->ex_list);
|
2008-12-09 23:10:17 +00:00
|
|
|
fc_seq_alloc(ep, ep->seq_id++);
|
[SCSI] fcoe, libfc: fully makes use of per cpu exch pool and then removes em_lock
1. Updates fcoe_rcv() to queue incoming frames to the fcoe per
cpu thread on which this frame's exch was originated and simply
use current cpu for request exch not originated by initiator.
It is redundant to add this code under CONFIG_SMP, so removes
CONFIG_SMP uses around this code.
2. Updates fc_exch_em_alloc, fc_exch_delete, fc_exch_find to use
per cpu exch pools, here fc_exch_delete is rename of older
fc_exch_mgr_delete_ep since ep/exch are now deleted in pools
of EM and so brief new name is sufficient and better name.
Updates these functions to map exch id to their index into exch
pool using fc_cpu_mask, fc_cpu_order and EM min_xid.
This mapping is as per detailed explanation about this in
last patch and basically this is just as lower fc_cpu_mask
bits of exch id as cpu number and upper bit sum of EM min_xid
and exch index in pool.
Uses pool next_index to keep track of exch allocation from
pool along with pool_max_index as upper bound of exches array
in pool.
3. Adds exch pool ptr to fc_exch to free exch to its pool in
fc_exch_delete.
4. Updates fc_exch_mgr_reset to reset all exch pools of an EM,
this required adding fc_exch_pool_reset func to reset exches
in pool and then have fc_exch_mgr_reset call fc_exch_pool_reset
for each pool within each EM for a lport.
5. Removes no longer needed exches array, em_lock, next_xid, and
total_exches from struct fc_exch_mgr, these are not needed after
use of per cpu exch pool, also removes not used max_read,
last_read from struct fc_exch_mgr.
6. Updates locking notes for exch pool lock with fc_exch lock and
uses pool lock in exch allocation, lookup and reset.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:53 +00:00
|
|
|
pool->total_exches++;
|
|
|
|
spin_unlock_bh(&pool->lock);
|
2008-12-09 23:10:17 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* update exchange
|
|
|
|
*/
|
[SCSI] fcoe, libfc: fully makes use of per cpu exch pool and then removes em_lock
1. Updates fcoe_rcv() to queue incoming frames to the fcoe per
cpu thread on which this frame's exch was originated and simply
use current cpu for request exch not originated by initiator.
It is redundant to add this code under CONFIG_SMP, so removes
CONFIG_SMP uses around this code.
2. Updates fc_exch_em_alloc, fc_exch_delete, fc_exch_find to use
per cpu exch pools, here fc_exch_delete is rename of older
fc_exch_mgr_delete_ep since ep/exch are now deleted in pools
of EM and so brief new name is sufficient and better name.
Updates these functions to map exch id to their index into exch
pool using fc_cpu_mask, fc_cpu_order and EM min_xid.
This mapping is as per detailed explanation about this in
last patch and basically this is just as lower fc_cpu_mask
bits of exch id as cpu number and upper bit sum of EM min_xid
and exch index in pool.
Uses pool next_index to keep track of exch allocation from
pool along with pool_max_index as upper bound of exches array
in pool.
3. Adds exch pool ptr to fc_exch to free exch to its pool in
fc_exch_delete.
4. Updates fc_exch_mgr_reset to reset all exch pools of an EM,
this required adding fc_exch_pool_reset func to reset exches
in pool and then have fc_exch_mgr_reset call fc_exch_pool_reset
for each pool within each EM for a lport.
5. Removes no longer needed exches array, em_lock, next_xid, and
total_exches from struct fc_exch_mgr, these are not needed after
use of per cpu exch pool, also removes not used max_read,
last_read from struct fc_exch_mgr.
6. Updates locking notes for exch pool lock with fc_exch lock and
uses pool lock in exch allocation, lookup and reset.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:53 +00:00
|
|
|
ep->oxid = ep->xid = (index << fc_cpu_order | cpu) + mp->min_xid;
|
2008-12-09 23:10:17 +00:00
|
|
|
ep->em = mp;
|
[SCSI] fcoe, libfc: fully makes use of per cpu exch pool and then removes em_lock
1. Updates fcoe_rcv() to queue incoming frames to the fcoe per
cpu thread on which this frame's exch was originated and simply
use current cpu for request exch not originated by initiator.
It is redundant to add this code under CONFIG_SMP, so removes
CONFIG_SMP uses around this code.
2. Updates fc_exch_em_alloc, fc_exch_delete, fc_exch_find to use
per cpu exch pools, here fc_exch_delete is rename of older
fc_exch_mgr_delete_ep since ep/exch are now deleted in pools
of EM and so brief new name is sufficient and better name.
Updates these functions to map exch id to their index into exch
pool using fc_cpu_mask, fc_cpu_order and EM min_xid.
This mapping is as per detailed explanation about this in
last patch and basically this is just as lower fc_cpu_mask
bits of exch id as cpu number and upper bit sum of EM min_xid
and exch index in pool.
Uses pool next_index to keep track of exch allocation from
pool along with pool_max_index as upper bound of exches array
in pool.
3. Adds exch pool ptr to fc_exch to free exch to its pool in
fc_exch_delete.
4. Updates fc_exch_mgr_reset to reset all exch pools of an EM,
this required adding fc_exch_pool_reset func to reset exches
in pool and then have fc_exch_mgr_reset call fc_exch_pool_reset
for each pool within each EM for a lport.
5. Removes no longer needed exches array, em_lock, next_xid, and
total_exches from struct fc_exch_mgr, these are not needed after
use of per cpu exch pool, also removes not used max_read,
last_read from struct fc_exch_mgr.
6. Updates locking notes for exch pool lock with fc_exch lock and
uses pool lock in exch allocation, lookup and reset.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:53 +00:00
|
|
|
ep->pool = pool;
|
[SCSI] fcoe, fnic, libfc: modifies current code paths to use EM anchor list
Modifies current code to use EM anchor list in EM allocation, EM free,
EM reset, exch allocation and exch lookup code paths.
1. Modifies fc_exch_mgr_alloc to accept EM match function and then
have allocated EM added to the lport using fc_exch_mgr_add API
while also updating EM kref for newly added EM.
2. Updates fc_exch_mgr_free API to accept only lport pointer instead
EM and then have this API free all EMs of the lport from EM anchor
list.
3. Removes single lport pointer link from the EM, which was used in
associating lport pointer in newly allocated exchange. Instead have
lport pointer passed along new exchange allocation call path and
then store passed lport pointer in newly allocated exchange, this
will allow a single EM instance to be used across more than one
lport and used in EM reset to reset only lport specific exchanges.
4. Modifies fc_exch_mgr_reset to reset all EMs from the EM anchor list
of the lport, adds additional exch lport pointer (ep->lp) check for
shared EM case to reset exchange specific to a lport requested reset.
5. Updates exch allocation API fc_exch_alloc to use EM anchor list and
its anchor match func pointer. The fc_exch_alloc will walk the list
of EMs until it finds a match, a match will be either null match
func pointer or call to match function returning true value.
6. Updates fc_exch_recv to accept incoming frame on local port using
only lport pointer and frame pointer without specifying EM instance
of incoming frame. Instead modified fc_exch_recv to locate EM for the
incoming frame by matching xid of incoming frame against a EM xid range.
This change was required to use EM list in libfc Rx path and after this
change the lport fc_exch_mgr pointer emp is not needed anymore, so
removed emp pointer.
7. Updates fnic for removed lport emp pointer and above modified libfc APIs
fc_exch_recv, fc_exch_mgr_alloc and fc_exch_mgr_free.
8. Removes exch_get and exch_put from libfc_function_template as these
are no longer needed with EM anchor list and its match function use.
Also removes its default function fc_exch_get.
A defect this patch introduced regarding the libfc initialization order in
the fnic driver was fixed by Joe Eykholt <jeykholt@cisco.com>.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-07-30 00:05:10 +00:00
|
|
|
ep->lp = lport;
|
2008-12-09 23:10:17 +00:00
|
|
|
ep->f_ctl = FC_FC_FIRST_SEQ; /* next seq is first seq */
|
|
|
|
ep->rxid = FC_XID_UNKNOWN;
|
|
|
|
ep->class = mp->class;
|
2013-08-17 20:34:43 +00:00
|
|
|
ep->resp_active = 0;
|
|
|
|
init_waitqueue_head(&ep->resp_wq);
|
2008-12-09 23:10:17 +00:00
|
|
|
INIT_DELAYED_WORK(&ep->timeout_work, fc_exch_timeout);
|
|
|
|
out:
|
|
|
|
return ep;
|
|
|
|
err:
|
[SCSI] fcoe, libfc: fully makes use of per cpu exch pool and then removes em_lock
1. Updates fcoe_rcv() to queue incoming frames to the fcoe per
cpu thread on which this frame's exch was originated and simply
use current cpu for request exch not originated by initiator.
It is redundant to add this code under CONFIG_SMP, so removes
CONFIG_SMP uses around this code.
2. Updates fc_exch_em_alloc, fc_exch_delete, fc_exch_find to use
per cpu exch pools, here fc_exch_delete is rename of older
fc_exch_mgr_delete_ep since ep/exch are now deleted in pools
of EM and so brief new name is sufficient and better name.
Updates these functions to map exch id to their index into exch
pool using fc_cpu_mask, fc_cpu_order and EM min_xid.
This mapping is as per detailed explanation about this in
last patch and basically this is just as lower fc_cpu_mask
bits of exch id as cpu number and upper bit sum of EM min_xid
and exch index in pool.
Uses pool next_index to keep track of exch allocation from
pool along with pool_max_index as upper bound of exches array
in pool.
3. Adds exch pool ptr to fc_exch to free exch to its pool in
fc_exch_delete.
4. Updates fc_exch_mgr_reset to reset all exch pools of an EM,
this required adding fc_exch_pool_reset func to reset exches
in pool and then have fc_exch_mgr_reset call fc_exch_pool_reset
for each pool within each EM for a lport.
5. Removes no longer needed exches array, em_lock, next_xid, and
total_exches from struct fc_exch_mgr, these are not needed after
use of per cpu exch pool, also removes not used max_read,
last_read from struct fc_exch_mgr.
6. Updates locking notes for exch pool lock with fc_exch lock and
uses pool lock in exch allocation, lookup and reset.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:53 +00:00
|
|
|
spin_unlock_bh(&pool->lock);
|
2008-12-09 23:10:17 +00:00
|
|
|
atomic_inc(&mp->stats.no_free_exch_xid);
|
|
|
|
mempool_free(ep, mp->ep_pool);
|
|
|
|
return NULL;
|
|
|
|
}
|
[SCSI] fcoe, fnic, libfc: modifies current code paths to use EM anchor list
Modifies current code to use EM anchor list in EM allocation, EM free,
EM reset, exch allocation and exch lookup code paths.
1. Modifies fc_exch_mgr_alloc to accept EM match function and then
have allocated EM added to the lport using fc_exch_mgr_add API
while also updating EM kref for newly added EM.
2. Updates fc_exch_mgr_free API to accept only lport pointer instead
EM and then have this API free all EMs of the lport from EM anchor
list.
3. Removes single lport pointer link from the EM, which was used in
associating lport pointer in newly allocated exchange. Instead have
lport pointer passed along new exchange allocation call path and
then store passed lport pointer in newly allocated exchange, this
will allow a single EM instance to be used across more than one
lport and used in EM reset to reset only lport specific exchanges.
4. Modifies fc_exch_mgr_reset to reset all EMs from the EM anchor list
of the lport, adds additional exch lport pointer (ep->lp) check for
shared EM case to reset exchange specific to a lport requested reset.
5. Updates exch allocation API fc_exch_alloc to use EM anchor list and
its anchor match func pointer. The fc_exch_alloc will walk the list
of EMs until it finds a match, a match will be either null match
func pointer or call to match function returning true value.
6. Updates fc_exch_recv to accept incoming frame on local port using
only lport pointer and frame pointer without specifying EM instance
of incoming frame. Instead modified fc_exch_recv to locate EM for the
incoming frame by matching xid of incoming frame against a EM xid range.
This change was required to use EM list in libfc Rx path and after this
change the lport fc_exch_mgr pointer emp is not needed anymore, so
removed emp pointer.
7. Updates fnic for removed lport emp pointer and above modified libfc APIs
fc_exch_recv, fc_exch_mgr_alloc and fc_exch_mgr_free.
8. Removes exch_get and exch_put from libfc_function_template as these
are no longer needed with EM anchor list and its match function use.
Also removes its default function fc_exch_get.
A defect this patch introduced regarding the libfc initialization order in
the fnic driver was fixed by Joe Eykholt <jeykholt@cisco.com>.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-07-30 00:05:10 +00:00
|
|
|
|
|
|
|
/**
|
2009-11-03 19:47:39 +00:00
|
|
|
* fc_exch_alloc() - Allocate an exchange from an EM on a
|
|
|
|
* local port's list of EMs.
|
|
|
|
* @lport: The local port that will own the exchange
|
|
|
|
* @fp: The FC frame that the exchange will be for
|
[SCSI] fcoe, fnic, libfc: modifies current code paths to use EM anchor list
Modifies current code to use EM anchor list in EM allocation, EM free,
EM reset, exch allocation and exch lookup code paths.
1. Modifies fc_exch_mgr_alloc to accept EM match function and then
have allocated EM added to the lport using fc_exch_mgr_add API
while also updating EM kref for newly added EM.
2. Updates fc_exch_mgr_free API to accept only lport pointer instead
EM and then have this API free all EMs of the lport from EM anchor
list.
3. Removes single lport pointer link from the EM, which was used in
associating lport pointer in newly allocated exchange. Instead have
lport pointer passed along new exchange allocation call path and
then store passed lport pointer in newly allocated exchange, this
will allow a single EM instance to be used across more than one
lport and used in EM reset to reset only lport specific exchanges.
4. Modifies fc_exch_mgr_reset to reset all EMs from the EM anchor list
of the lport, adds additional exch lport pointer (ep->lp) check for
shared EM case to reset exchange specific to a lport requested reset.
5. Updates exch allocation API fc_exch_alloc to use EM anchor list and
its anchor match func pointer. The fc_exch_alloc will walk the list
of EMs until it finds a match, a match will be either null match
func pointer or call to match function returning true value.
6. Updates fc_exch_recv to accept incoming frame on local port using
only lport pointer and frame pointer without specifying EM instance
of incoming frame. Instead modified fc_exch_recv to locate EM for the
incoming frame by matching xid of incoming frame against a EM xid range.
This change was required to use EM list in libfc Rx path and after this
change the lport fc_exch_mgr pointer emp is not needed anymore, so
removed emp pointer.
7. Updates fnic for removed lport emp pointer and above modified libfc APIs
fc_exch_recv, fc_exch_mgr_alloc and fc_exch_mgr_free.
8. Removes exch_get and exch_put from libfc_function_template as these
are no longer needed with EM anchor list and its match function use.
Also removes its default function fc_exch_get.
A defect this patch introduced regarding the libfc initialization order in
the fnic driver was fixed by Joe Eykholt <jeykholt@cisco.com>.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-07-30 00:05:10 +00:00
|
|
|
*
|
2009-11-03 19:47:39 +00:00
|
|
|
* This function walks the list of exchange manager(EM)
|
|
|
|
* anchors to select an EM for a new exchange allocation. The
|
|
|
|
* EM is selected when a NULL match function pointer is encountered
|
|
|
|
* or when a call to a match function returns true.
|
[SCSI] fcoe, fnic, libfc: modifies current code paths to use EM anchor list
Modifies current code to use EM anchor list in EM allocation, EM free,
EM reset, exch allocation and exch lookup code paths.
1. Modifies fc_exch_mgr_alloc to accept EM match function and then
have allocated EM added to the lport using fc_exch_mgr_add API
while also updating EM kref for newly added EM.
2. Updates fc_exch_mgr_free API to accept only lport pointer instead
EM and then have this API free all EMs of the lport from EM anchor
list.
3. Removes single lport pointer link from the EM, which was used in
associating lport pointer in newly allocated exchange. Instead have
lport pointer passed along new exchange allocation call path and
then store passed lport pointer in newly allocated exchange, this
will allow a single EM instance to be used across more than one
lport and used in EM reset to reset only lport specific exchanges.
4. Modifies fc_exch_mgr_reset to reset all EMs from the EM anchor list
of the lport, adds additional exch lport pointer (ep->lp) check for
shared EM case to reset exchange specific to a lport requested reset.
5. Updates exch allocation API fc_exch_alloc to use EM anchor list and
its anchor match func pointer. The fc_exch_alloc will walk the list
of EMs until it finds a match, a match will be either null match
func pointer or call to match function returning true value.
6. Updates fc_exch_recv to accept incoming frame on local port using
only lport pointer and frame pointer without specifying EM instance
of incoming frame. Instead modified fc_exch_recv to locate EM for the
incoming frame by matching xid of incoming frame against a EM xid range.
This change was required to use EM list in libfc Rx path and after this
change the lport fc_exch_mgr pointer emp is not needed anymore, so
removed emp pointer.
7. Updates fnic for removed lport emp pointer and above modified libfc APIs
fc_exch_recv, fc_exch_mgr_alloc and fc_exch_mgr_free.
8. Removes exch_get and exch_put from libfc_function_template as these
are no longer needed with EM anchor list and its match function use.
Also removes its default function fc_exch_get.
A defect this patch introduced regarding the libfc initialization order in
the fnic driver was fixed by Joe Eykholt <jeykholt@cisco.com>.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-07-30 00:05:10 +00:00
|
|
|
*/
|
2016-10-14 20:37:29 +00:00
|
|
|
static struct fc_exch *fc_exch_alloc(struct fc_lport *lport,
|
|
|
|
struct fc_frame *fp)
|
[SCSI] fcoe, fnic, libfc: modifies current code paths to use EM anchor list
Modifies current code to use EM anchor list in EM allocation, EM free,
EM reset, exch allocation and exch lookup code paths.
1. Modifies fc_exch_mgr_alloc to accept EM match function and then
have allocated EM added to the lport using fc_exch_mgr_add API
while also updating EM kref for newly added EM.
2. Updates fc_exch_mgr_free API to accept only lport pointer instead
EM and then have this API free all EMs of the lport from EM anchor
list.
3. Removes single lport pointer link from the EM, which was used in
associating lport pointer in newly allocated exchange. Instead have
lport pointer passed along new exchange allocation call path and
then store passed lport pointer in newly allocated exchange, this
will allow a single EM instance to be used across more than one
lport and used in EM reset to reset only lport specific exchanges.
4. Modifies fc_exch_mgr_reset to reset all EMs from the EM anchor list
of the lport, adds additional exch lport pointer (ep->lp) check for
shared EM case to reset exchange specific to a lport requested reset.
5. Updates exch allocation API fc_exch_alloc to use EM anchor list and
its anchor match func pointer. The fc_exch_alloc will walk the list
of EMs until it finds a match, a match will be either null match
func pointer or call to match function returning true value.
6. Updates fc_exch_recv to accept incoming frame on local port using
only lport pointer and frame pointer without specifying EM instance
of incoming frame. Instead modified fc_exch_recv to locate EM for the
incoming frame by matching xid of incoming frame against a EM xid range.
This change was required to use EM list in libfc Rx path and after this
change the lport fc_exch_mgr pointer emp is not needed anymore, so
removed emp pointer.
7. Updates fnic for removed lport emp pointer and above modified libfc APIs
fc_exch_recv, fc_exch_mgr_alloc and fc_exch_mgr_free.
8. Removes exch_get and exch_put from libfc_function_template as these
are no longer needed with EM anchor list and its match function use.
Also removes its default function fc_exch_get.
A defect this patch introduced regarding the libfc initialization order in
the fnic driver was fixed by Joe Eykholt <jeykholt@cisco.com>.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-07-30 00:05:10 +00:00
|
|
|
{
|
|
|
|
struct fc_exch_mgr_anchor *ema;
|
2016-10-14 20:37:29 +00:00
|
|
|
struct fc_exch *ep;
|
[SCSI] fcoe, fnic, libfc: modifies current code paths to use EM anchor list
Modifies current code to use EM anchor list in EM allocation, EM free,
EM reset, exch allocation and exch lookup code paths.
1. Modifies fc_exch_mgr_alloc to accept EM match function and then
have allocated EM added to the lport using fc_exch_mgr_add API
while also updating EM kref for newly added EM.
2. Updates fc_exch_mgr_free API to accept only lport pointer instead
EM and then have this API free all EMs of the lport from EM anchor
list.
3. Removes single lport pointer link from the EM, which was used in
associating lport pointer in newly allocated exchange. Instead have
lport pointer passed along new exchange allocation call path and
then store passed lport pointer in newly allocated exchange, this
will allow a single EM instance to be used across more than one
lport and used in EM reset to reset only lport specific exchanges.
4. Modifies fc_exch_mgr_reset to reset all EMs from the EM anchor list
of the lport, adds additional exch lport pointer (ep->lp) check for
shared EM case to reset exchange specific to a lport requested reset.
5. Updates exch allocation API fc_exch_alloc to use EM anchor list and
its anchor match func pointer. The fc_exch_alloc will walk the list
of EMs until it finds a match, a match will be either null match
func pointer or call to match function returning true value.
6. Updates fc_exch_recv to accept incoming frame on local port using
only lport pointer and frame pointer without specifying EM instance
of incoming frame. Instead modified fc_exch_recv to locate EM for the
incoming frame by matching xid of incoming frame against a EM xid range.
This change was required to use EM list in libfc Rx path and after this
change the lport fc_exch_mgr pointer emp is not needed anymore, so
removed emp pointer.
7. Updates fnic for removed lport emp pointer and above modified libfc APIs
fc_exch_recv, fc_exch_mgr_alloc and fc_exch_mgr_free.
8. Removes exch_get and exch_put from libfc_function_template as these
are no longer needed with EM anchor list and its match function use.
Also removes its default function fc_exch_get.
A defect this patch introduced regarding the libfc initialization order in
the fnic driver was fixed by Joe Eykholt <jeykholt@cisco.com>.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-07-30 00:05:10 +00:00
|
|
|
|
2016-10-14 20:37:29 +00:00
|
|
|
list_for_each_entry(ema, &lport->ema_list, ema_list) {
|
|
|
|
if (!ema->match || ema->match(fp)) {
|
|
|
|
ep = fc_exch_em_alloc(lport, ema->mp);
|
|
|
|
if (ep)
|
|
|
|
return ep;
|
|
|
|
}
|
|
|
|
}
|
[SCSI] fcoe, fnic, libfc: modifies current code paths to use EM anchor list
Modifies current code to use EM anchor list in EM allocation, EM free,
EM reset, exch allocation and exch lookup code paths.
1. Modifies fc_exch_mgr_alloc to accept EM match function and then
have allocated EM added to the lport using fc_exch_mgr_add API
while also updating EM kref for newly added EM.
2. Updates fc_exch_mgr_free API to accept only lport pointer instead
EM and then have this API free all EMs of the lport from EM anchor
list.
3. Removes single lport pointer link from the EM, which was used in
associating lport pointer in newly allocated exchange. Instead have
lport pointer passed along new exchange allocation call path and
then store passed lport pointer in newly allocated exchange, this
will allow a single EM instance to be used across more than one
lport and used in EM reset to reset only lport specific exchanges.
4. Modifies fc_exch_mgr_reset to reset all EMs from the EM anchor list
of the lport, adds additional exch lport pointer (ep->lp) check for
shared EM case to reset exchange specific to a lport requested reset.
5. Updates exch allocation API fc_exch_alloc to use EM anchor list and
its anchor match func pointer. The fc_exch_alloc will walk the list
of EMs until it finds a match, a match will be either null match
func pointer or call to match function returning true value.
6. Updates fc_exch_recv to accept incoming frame on local port using
only lport pointer and frame pointer without specifying EM instance
of incoming frame. Instead modified fc_exch_recv to locate EM for the
incoming frame by matching xid of incoming frame against a EM xid range.
This change was required to use EM list in libfc Rx path and after this
change the lport fc_exch_mgr pointer emp is not needed anymore, so
removed emp pointer.
7. Updates fnic for removed lport emp pointer and above modified libfc APIs
fc_exch_recv, fc_exch_mgr_alloc and fc_exch_mgr_free.
8. Removes exch_get and exch_put from libfc_function_template as these
are no longer needed with EM anchor list and its match function use.
Also removes its default function fc_exch_get.
A defect this patch introduced regarding the libfc initialization order in
the fnic driver was fixed by Joe Eykholt <jeykholt@cisco.com>.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-07-30 00:05:10 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2008-12-09 23:10:17 +00:00
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
/**
|
|
|
|
* fc_exch_find() - Lookup and hold an exchange
|
|
|
|
* @mp: The exchange manager to lookup the exchange from
|
|
|
|
* @xid: The XID of the exchange to look up
|
2008-12-09 23:10:17 +00:00
|
|
|
*/
|
|
|
|
static struct fc_exch *fc_exch_find(struct fc_exch_mgr *mp, u16 xid)
|
|
|
|
{
|
2016-10-13 13:10:50 +00:00
|
|
|
struct fc_lport *lport = mp->lport;
|
[SCSI] fcoe, libfc: fully makes use of per cpu exch pool and then removes em_lock
1. Updates fcoe_rcv() to queue incoming frames to the fcoe per
cpu thread on which this frame's exch was originated and simply
use current cpu for request exch not originated by initiator.
It is redundant to add this code under CONFIG_SMP, so removes
CONFIG_SMP uses around this code.
2. Updates fc_exch_em_alloc, fc_exch_delete, fc_exch_find to use
per cpu exch pools, here fc_exch_delete is rename of older
fc_exch_mgr_delete_ep since ep/exch are now deleted in pools
of EM and so brief new name is sufficient and better name.
Updates these functions to map exch id to their index into exch
pool using fc_cpu_mask, fc_cpu_order and EM min_xid.
This mapping is as per detailed explanation about this in
last patch and basically this is just as lower fc_cpu_mask
bits of exch id as cpu number and upper bit sum of EM min_xid
and exch index in pool.
Uses pool next_index to keep track of exch allocation from
pool along with pool_max_index as upper bound of exches array
in pool.
3. Adds exch pool ptr to fc_exch to free exch to its pool in
fc_exch_delete.
4. Updates fc_exch_mgr_reset to reset all exch pools of an EM,
this required adding fc_exch_pool_reset func to reset exches
in pool and then have fc_exch_mgr_reset call fc_exch_pool_reset
for each pool within each EM for a lport.
5. Removes no longer needed exches array, em_lock, next_xid, and
total_exches from struct fc_exch_mgr, these are not needed after
use of per cpu exch pool, also removes not used max_read,
last_read from struct fc_exch_mgr.
6. Updates locking notes for exch pool lock with fc_exch lock and
uses pool lock in exch allocation, lookup and reset.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:53 +00:00
|
|
|
struct fc_exch_pool *pool;
|
2008-12-09 23:10:17 +00:00
|
|
|
struct fc_exch *ep = NULL;
|
2016-06-30 15:32:36 +00:00
|
|
|
u16 cpu = xid & fc_cpu_mask;
|
|
|
|
|
|
|
|
if (cpu >= nr_cpu_ids || !cpu_possible(cpu)) {
|
2016-10-13 13:10:50 +00:00
|
|
|
pr_err("host%u: lport %6.6x: xid %d invalid CPU %d\n:",
|
|
|
|
lport->host->host_no, lport->port_id, xid, cpu);
|
2016-06-30 15:32:36 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2008-12-09 23:10:17 +00:00
|
|
|
|
|
|
|
if ((xid >= mp->min_xid) && (xid <= mp->max_xid)) {
|
2016-06-30 15:32:36 +00:00
|
|
|
pool = per_cpu_ptr(mp->pool, cpu);
|
[SCSI] fcoe, libfc: fully makes use of per cpu exch pool and then removes em_lock
1. Updates fcoe_rcv() to queue incoming frames to the fcoe per
cpu thread on which this frame's exch was originated and simply
use current cpu for request exch not originated by initiator.
It is redundant to add this code under CONFIG_SMP, so removes
CONFIG_SMP uses around this code.
2. Updates fc_exch_em_alloc, fc_exch_delete, fc_exch_find to use
per cpu exch pools, here fc_exch_delete is rename of older
fc_exch_mgr_delete_ep since ep/exch are now deleted in pools
of EM and so brief new name is sufficient and better name.
Updates these functions to map exch id to their index into exch
pool using fc_cpu_mask, fc_cpu_order and EM min_xid.
This mapping is as per detailed explanation about this in
last patch and basically this is just as lower fc_cpu_mask
bits of exch id as cpu number and upper bit sum of EM min_xid
and exch index in pool.
Uses pool next_index to keep track of exch allocation from
pool along with pool_max_index as upper bound of exches array
in pool.
3. Adds exch pool ptr to fc_exch to free exch to its pool in
fc_exch_delete.
4. Updates fc_exch_mgr_reset to reset all exch pools of an EM,
this required adding fc_exch_pool_reset func to reset exches
in pool and then have fc_exch_mgr_reset call fc_exch_pool_reset
for each pool within each EM for a lport.
5. Removes no longer needed exches array, em_lock, next_xid, and
total_exches from struct fc_exch_mgr, these are not needed after
use of per cpu exch pool, also removes not used max_read,
last_read from struct fc_exch_mgr.
6. Updates locking notes for exch pool lock with fc_exch lock and
uses pool lock in exch allocation, lookup and reset.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:53 +00:00
|
|
|
spin_lock_bh(&pool->lock);
|
|
|
|
ep = fc_exch_ptr_get(pool, (xid - mp->min_xid) >> fc_cpu_order);
|
2016-10-13 13:10:50 +00:00
|
|
|
if (ep == &fc_quarantine_exch) {
|
|
|
|
FC_LPORT_DBG(lport, "xid %x quarantined\n", xid);
|
|
|
|
ep = NULL;
|
|
|
|
}
|
2013-08-17 20:20:07 +00:00
|
|
|
if (ep) {
|
|
|
|
WARN_ON(ep->xid != xid);
|
2008-12-09 23:10:17 +00:00
|
|
|
fc_exch_hold(ep);
|
2013-08-17 20:20:07 +00:00
|
|
|
}
|
[SCSI] fcoe, libfc: fully makes use of per cpu exch pool and then removes em_lock
1. Updates fcoe_rcv() to queue incoming frames to the fcoe per
cpu thread on which this frame's exch was originated and simply
use current cpu for request exch not originated by initiator.
It is redundant to add this code under CONFIG_SMP, so removes
CONFIG_SMP uses around this code.
2. Updates fc_exch_em_alloc, fc_exch_delete, fc_exch_find to use
per cpu exch pools, here fc_exch_delete is rename of older
fc_exch_mgr_delete_ep since ep/exch are now deleted in pools
of EM and so brief new name is sufficient and better name.
Updates these functions to map exch id to their index into exch
pool using fc_cpu_mask, fc_cpu_order and EM min_xid.
This mapping is as per detailed explanation about this in
last patch and basically this is just as lower fc_cpu_mask
bits of exch id as cpu number and upper bit sum of EM min_xid
and exch index in pool.
Uses pool next_index to keep track of exch allocation from
pool along with pool_max_index as upper bound of exches array
in pool.
3. Adds exch pool ptr to fc_exch to free exch to its pool in
fc_exch_delete.
4. Updates fc_exch_mgr_reset to reset all exch pools of an EM,
this required adding fc_exch_pool_reset func to reset exches
in pool and then have fc_exch_mgr_reset call fc_exch_pool_reset
for each pool within each EM for a lport.
5. Removes no longer needed exches array, em_lock, next_xid, and
total_exches from struct fc_exch_mgr, these are not needed after
use of per cpu exch pool, also removes not used max_read,
last_read from struct fc_exch_mgr.
6. Updates locking notes for exch pool lock with fc_exch lock and
uses pool lock in exch allocation, lookup and reset.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:53 +00:00
|
|
|
spin_unlock_bh(&pool->lock);
|
2008-12-09 23:10:17 +00:00
|
|
|
}
|
|
|
|
return ep;
|
|
|
|
}
|
|
|
|
|
2009-11-03 19:45:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* fc_exch_done() - Indicate that an exchange/sequence tuple is complete and
|
2009-11-03 19:47:39 +00:00
|
|
|
* the memory allocated for the related objects may be freed.
|
|
|
|
* @sp: The sequence that has completed
|
2013-08-17 20:34:43 +00:00
|
|
|
*
|
|
|
|
* Note: May sleep if invoked from outside a response handler.
|
2009-11-03 19:45:47 +00:00
|
|
|
*/
|
2016-10-18 08:01:50 +00:00
|
|
|
void fc_exch_done(struct fc_seq *sp)
|
2008-12-09 23:10:17 +00:00
|
|
|
{
|
|
|
|
struct fc_exch *ep = fc_seq_exch(sp);
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
spin_lock_bh(&ep->ex_lock);
|
|
|
|
rc = fc_exch_done_locked(ep);
|
|
|
|
spin_unlock_bh(&ep->ex_lock);
|
2013-08-17 20:34:43 +00:00
|
|
|
|
|
|
|
fc_seq_set_resp(sp, NULL, ep->arg);
|
2008-12-09 23:10:17 +00:00
|
|
|
if (!rc)
|
[SCSI] fcoe, libfc: fully makes use of per cpu exch pool and then removes em_lock
1. Updates fcoe_rcv() to queue incoming frames to the fcoe per
cpu thread on which this frame's exch was originated and simply
use current cpu for request exch not originated by initiator.
It is redundant to add this code under CONFIG_SMP, so removes
CONFIG_SMP uses around this code.
2. Updates fc_exch_em_alloc, fc_exch_delete, fc_exch_find to use
per cpu exch pools, here fc_exch_delete is rename of older
fc_exch_mgr_delete_ep since ep/exch are now deleted in pools
of EM and so brief new name is sufficient and better name.
Updates these functions to map exch id to their index into exch
pool using fc_cpu_mask, fc_cpu_order and EM min_xid.
This mapping is as per detailed explanation about this in
last patch and basically this is just as lower fc_cpu_mask
bits of exch id as cpu number and upper bit sum of EM min_xid
and exch index in pool.
Uses pool next_index to keep track of exch allocation from
pool along with pool_max_index as upper bound of exches array
in pool.
3. Adds exch pool ptr to fc_exch to free exch to its pool in
fc_exch_delete.
4. Updates fc_exch_mgr_reset to reset all exch pools of an EM,
this required adding fc_exch_pool_reset func to reset exches
in pool and then have fc_exch_mgr_reset call fc_exch_pool_reset
for each pool within each EM for a lport.
5. Removes no longer needed exches array, em_lock, next_xid, and
total_exches from struct fc_exch_mgr, these are not needed after
use of per cpu exch pool, also removes not used max_read,
last_read from struct fc_exch_mgr.
6. Updates locking notes for exch pool lock with fc_exch lock and
uses pool lock in exch allocation, lookup and reset.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:53 +00:00
|
|
|
fc_exch_delete(ep);
|
2008-12-09 23:10:17 +00:00
|
|
|
}
|
2016-10-18 08:01:50 +00:00
|
|
|
EXPORT_SYMBOL(fc_exch_done);
|
2008-12-09 23:10:17 +00:00
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
/**
|
|
|
|
* fc_exch_resp() - Allocate a new exchange for a response frame
|
|
|
|
* @lport: The local port that the exchange was for
|
|
|
|
* @mp: The exchange manager to allocate the exchange from
|
|
|
|
* @fp: The response frame
|
|
|
|
*
|
2008-12-09 23:10:17 +00:00
|
|
|
* Sets the responder ID in the frame header.
|
|
|
|
*/
|
[SCSI] fcoe, fnic, libfc: modifies current code paths to use EM anchor list
Modifies current code to use EM anchor list in EM allocation, EM free,
EM reset, exch allocation and exch lookup code paths.
1. Modifies fc_exch_mgr_alloc to accept EM match function and then
have allocated EM added to the lport using fc_exch_mgr_add API
while also updating EM kref for newly added EM.
2. Updates fc_exch_mgr_free API to accept only lport pointer instead
EM and then have this API free all EMs of the lport from EM anchor
list.
3. Removes single lport pointer link from the EM, which was used in
associating lport pointer in newly allocated exchange. Instead have
lport pointer passed along new exchange allocation call path and
then store passed lport pointer in newly allocated exchange, this
will allow a single EM instance to be used across more than one
lport and used in EM reset to reset only lport specific exchanges.
4. Modifies fc_exch_mgr_reset to reset all EMs from the EM anchor list
of the lport, adds additional exch lport pointer (ep->lp) check for
shared EM case to reset exchange specific to a lport requested reset.
5. Updates exch allocation API fc_exch_alloc to use EM anchor list and
its anchor match func pointer. The fc_exch_alloc will walk the list
of EMs until it finds a match, a match will be either null match
func pointer or call to match function returning true value.
6. Updates fc_exch_recv to accept incoming frame on local port using
only lport pointer and frame pointer without specifying EM instance
of incoming frame. Instead modified fc_exch_recv to locate EM for the
incoming frame by matching xid of incoming frame against a EM xid range.
This change was required to use EM list in libfc Rx path and after this
change the lport fc_exch_mgr pointer emp is not needed anymore, so
removed emp pointer.
7. Updates fnic for removed lport emp pointer and above modified libfc APIs
fc_exch_recv, fc_exch_mgr_alloc and fc_exch_mgr_free.
8. Removes exch_get and exch_put from libfc_function_template as these
are no longer needed with EM anchor list and its match function use.
Also removes its default function fc_exch_get.
A defect this patch introduced regarding the libfc initialization order in
the fnic driver was fixed by Joe Eykholt <jeykholt@cisco.com>.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-07-30 00:05:10 +00:00
|
|
|
static struct fc_exch *fc_exch_resp(struct fc_lport *lport,
|
|
|
|
struct fc_exch_mgr *mp,
|
|
|
|
struct fc_frame *fp)
|
2008-12-09 23:10:17 +00:00
|
|
|
{
|
|
|
|
struct fc_exch *ep;
|
|
|
|
struct fc_frame_header *fh;
|
|
|
|
|
[SCSI] fcoe, fnic, libfc: modifies current code paths to use EM anchor list
Modifies current code to use EM anchor list in EM allocation, EM free,
EM reset, exch allocation and exch lookup code paths.
1. Modifies fc_exch_mgr_alloc to accept EM match function and then
have allocated EM added to the lport using fc_exch_mgr_add API
while also updating EM kref for newly added EM.
2. Updates fc_exch_mgr_free API to accept only lport pointer instead
EM and then have this API free all EMs of the lport from EM anchor
list.
3. Removes single lport pointer link from the EM, which was used in
associating lport pointer in newly allocated exchange. Instead have
lport pointer passed along new exchange allocation call path and
then store passed lport pointer in newly allocated exchange, this
will allow a single EM instance to be used across more than one
lport and used in EM reset to reset only lport specific exchanges.
4. Modifies fc_exch_mgr_reset to reset all EMs from the EM anchor list
of the lport, adds additional exch lport pointer (ep->lp) check for
shared EM case to reset exchange specific to a lport requested reset.
5. Updates exch allocation API fc_exch_alloc to use EM anchor list and
its anchor match func pointer. The fc_exch_alloc will walk the list
of EMs until it finds a match, a match will be either null match
func pointer or call to match function returning true value.
6. Updates fc_exch_recv to accept incoming frame on local port using
only lport pointer and frame pointer without specifying EM instance
of incoming frame. Instead modified fc_exch_recv to locate EM for the
incoming frame by matching xid of incoming frame against a EM xid range.
This change was required to use EM list in libfc Rx path and after this
change the lport fc_exch_mgr pointer emp is not needed anymore, so
removed emp pointer.
7. Updates fnic for removed lport emp pointer and above modified libfc APIs
fc_exch_recv, fc_exch_mgr_alloc and fc_exch_mgr_free.
8. Removes exch_get and exch_put from libfc_function_template as these
are no longer needed with EM anchor list and its match function use.
Also removes its default function fc_exch_get.
A defect this patch introduced regarding the libfc initialization order in
the fnic driver was fixed by Joe Eykholt <jeykholt@cisco.com>.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-07-30 00:05:10 +00:00
|
|
|
ep = fc_exch_alloc(lport, fp);
|
2008-12-09 23:10:17 +00:00
|
|
|
if (ep) {
|
|
|
|
ep->class = fc_frame_class(fp);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set EX_CTX indicating we're responding on this exchange.
|
|
|
|
*/
|
|
|
|
ep->f_ctl |= FC_FC_EX_CTX; /* we're responding */
|
|
|
|
ep->f_ctl &= ~FC_FC_FIRST_SEQ; /* not new */
|
|
|
|
fh = fc_frame_header_get(fp);
|
|
|
|
ep->sid = ntoh24(fh->fh_d_id);
|
|
|
|
ep->did = ntoh24(fh->fh_s_id);
|
|
|
|
ep->oid = ep->did;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocated exchange has placed the XID in the
|
|
|
|
* originator field. Move it to the responder field,
|
|
|
|
* and set the originator XID from the frame.
|
|
|
|
*/
|
|
|
|
ep->rxid = ep->xid;
|
|
|
|
ep->oxid = ntohs(fh->fh_ox_id);
|
|
|
|
ep->esb_stat |= ESB_ST_RESP | ESB_ST_SEQ_INIT;
|
|
|
|
if ((ntoh24(fh->fh_f_ctl) & FC_FC_SEQ_INIT) == 0)
|
|
|
|
ep->esb_stat &= ~ESB_ST_SEQ_INIT;
|
|
|
|
|
|
|
|
fc_exch_hold(ep); /* hold for caller */
|
[SCSI] fcoe, fnic, libfc: modifies current code paths to use EM anchor list
Modifies current code to use EM anchor list in EM allocation, EM free,
EM reset, exch allocation and exch lookup code paths.
1. Modifies fc_exch_mgr_alloc to accept EM match function and then
have allocated EM added to the lport using fc_exch_mgr_add API
while also updating EM kref for newly added EM.
2. Updates fc_exch_mgr_free API to accept only lport pointer instead
EM and then have this API free all EMs of the lport from EM anchor
list.
3. Removes single lport pointer link from the EM, which was used in
associating lport pointer in newly allocated exchange. Instead have
lport pointer passed along new exchange allocation call path and
then store passed lport pointer in newly allocated exchange, this
will allow a single EM instance to be used across more than one
lport and used in EM reset to reset only lport specific exchanges.
4. Modifies fc_exch_mgr_reset to reset all EMs from the EM anchor list
of the lport, adds additional exch lport pointer (ep->lp) check for
shared EM case to reset exchange specific to a lport requested reset.
5. Updates exch allocation API fc_exch_alloc to use EM anchor list and
its anchor match func pointer. The fc_exch_alloc will walk the list
of EMs until it finds a match, a match will be either null match
func pointer or call to match function returning true value.
6. Updates fc_exch_recv to accept incoming frame on local port using
only lport pointer and frame pointer without specifying EM instance
of incoming frame. Instead modified fc_exch_recv to locate EM for the
incoming frame by matching xid of incoming frame against a EM xid range.
This change was required to use EM list in libfc Rx path and after this
change the lport fc_exch_mgr pointer emp is not needed anymore, so
removed emp pointer.
7. Updates fnic for removed lport emp pointer and above modified libfc APIs
fc_exch_recv, fc_exch_mgr_alloc and fc_exch_mgr_free.
8. Removes exch_get and exch_put from libfc_function_template as these
are no longer needed with EM anchor list and its match function use.
Also removes its default function fc_exch_get.
A defect this patch introduced regarding the libfc initialization order in
the fnic driver was fixed by Joe Eykholt <jeykholt@cisco.com>.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-07-30 00:05:10 +00:00
|
|
|
spin_unlock_bh(&ep->ex_lock); /* lock from fc_exch_alloc */
|
2008-12-09 23:10:17 +00:00
|
|
|
}
|
|
|
|
return ep;
|
|
|
|
}
|
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
/**
|
|
|
|
* fc_seq_lookup_recip() - Find a sequence where the other end
|
|
|
|
* originated the sequence
|
|
|
|
* @lport: The local port that the frame was sent to
|
|
|
|
* @mp: The Exchange Manager to lookup the exchange from
|
|
|
|
* @fp: The frame associated with the sequence we're looking for
|
|
|
|
*
|
2008-12-09 23:10:17 +00:00
|
|
|
* If fc_pf_rjt_reason is FC_RJT_NONE then this function will have a hold
|
|
|
|
* on the ep that should be released by the caller.
|
|
|
|
*/
|
[SCSI] fcoe, fnic, libfc: modifies current code paths to use EM anchor list
Modifies current code to use EM anchor list in EM allocation, EM free,
EM reset, exch allocation and exch lookup code paths.
1. Modifies fc_exch_mgr_alloc to accept EM match function and then
have allocated EM added to the lport using fc_exch_mgr_add API
while also updating EM kref for newly added EM.
2. Updates fc_exch_mgr_free API to accept only lport pointer instead
EM and then have this API free all EMs of the lport from EM anchor
list.
3. Removes single lport pointer link from the EM, which was used in
associating lport pointer in newly allocated exchange. Instead have
lport pointer passed along new exchange allocation call path and
then store passed lport pointer in newly allocated exchange, this
will allow a single EM instance to be used across more than one
lport and used in EM reset to reset only lport specific exchanges.
4. Modifies fc_exch_mgr_reset to reset all EMs from the EM anchor list
of the lport, adds additional exch lport pointer (ep->lp) check for
shared EM case to reset exchange specific to a lport requested reset.
5. Updates exch allocation API fc_exch_alloc to use EM anchor list and
its anchor match func pointer. The fc_exch_alloc will walk the list
of EMs until it finds a match, a match will be either null match
func pointer or call to match function returning true value.
6. Updates fc_exch_recv to accept incoming frame on local port using
only lport pointer and frame pointer without specifying EM instance
of incoming frame. Instead modified fc_exch_recv to locate EM for the
incoming frame by matching xid of incoming frame against a EM xid range.
This change was required to use EM list in libfc Rx path and after this
change the lport fc_exch_mgr pointer emp is not needed anymore, so
removed emp pointer.
7. Updates fnic for removed lport emp pointer and above modified libfc APIs
fc_exch_recv, fc_exch_mgr_alloc and fc_exch_mgr_free.
8. Removes exch_get and exch_put from libfc_function_template as these
are no longer needed with EM anchor list and its match function use.
Also removes its default function fc_exch_get.
A defect this patch introduced regarding the libfc initialization order in
the fnic driver was fixed by Joe Eykholt <jeykholt@cisco.com>.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-07-30 00:05:10 +00:00
|
|
|
static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
|
|
|
|
struct fc_exch_mgr *mp,
|
2009-02-27 18:55:50 +00:00
|
|
|
struct fc_frame *fp)
|
2008-12-09 23:10:17 +00:00
|
|
|
{
|
|
|
|
struct fc_frame_header *fh = fc_frame_header_get(fp);
|
|
|
|
struct fc_exch *ep = NULL;
|
|
|
|
struct fc_seq *sp = NULL;
|
|
|
|
enum fc_pf_rjt_reason reject = FC_RJT_NONE;
|
|
|
|
u32 f_ctl;
|
|
|
|
u16 xid;
|
|
|
|
|
|
|
|
f_ctl = ntoh24(fh->fh_f_ctl);
|
|
|
|
WARN_ON((f_ctl & FC_FC_SEQ_CTX) != 0);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Lookup or create the exchange if we will be creating the sequence.
|
|
|
|
*/
|
|
|
|
if (f_ctl & FC_FC_EX_CTX) {
|
|
|
|
xid = ntohs(fh->fh_ox_id); /* we originated exch */
|
|
|
|
ep = fc_exch_find(mp, xid);
|
|
|
|
if (!ep) {
|
|
|
|
atomic_inc(&mp->stats.xid_not_found);
|
|
|
|
reject = FC_RJT_OX_ID;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
if (ep->rxid == FC_XID_UNKNOWN)
|
|
|
|
ep->rxid = ntohs(fh->fh_rx_id);
|
|
|
|
else if (ep->rxid != ntohs(fh->fh_rx_id)) {
|
|
|
|
reject = FC_RJT_OX_ID;
|
|
|
|
goto rel;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
xid = ntohs(fh->fh_rx_id); /* we are the responder */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Special case for MDS issuing an ELS TEST with a
|
|
|
|
* bad rxid of 0.
|
|
|
|
* XXX take this out once we do the proper reject.
|
|
|
|
*/
|
|
|
|
if (xid == 0 && fh->fh_r_ctl == FC_RCTL_ELS_REQ &&
|
|
|
|
fc_frame_payload_op(fp) == ELS_TEST) {
|
|
|
|
fh->fh_rx_id = htons(FC_XID_UNKNOWN);
|
|
|
|
xid = FC_XID_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* new sequence - find the exchange
|
|
|
|
*/
|
|
|
|
ep = fc_exch_find(mp, xid);
|
|
|
|
if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
|
|
|
|
if (ep) {
|
|
|
|
atomic_inc(&mp->stats.xid_busy);
|
|
|
|
reject = FC_RJT_RX_ID;
|
|
|
|
goto rel;
|
|
|
|
}
|
[SCSI] fcoe, fnic, libfc: modifies current code paths to use EM anchor list
Modifies current code to use EM anchor list in EM allocation, EM free,
EM reset, exch allocation and exch lookup code paths.
1. Modifies fc_exch_mgr_alloc to accept EM match function and then
have allocated EM added to the lport using fc_exch_mgr_add API
while also updating EM kref for newly added EM.
2. Updates fc_exch_mgr_free API to accept only lport pointer instead
EM and then have this API free all EMs of the lport from EM anchor
list.
3. Removes single lport pointer link from the EM, which was used in
associating lport pointer in newly allocated exchange. Instead have
lport pointer passed along new exchange allocation call path and
then store passed lport pointer in newly allocated exchange, this
will allow a single EM instance to be used across more than one
lport and used in EM reset to reset only lport specific exchanges.
4. Modifies fc_exch_mgr_reset to reset all EMs from the EM anchor list
of the lport, adds additional exch lport pointer (ep->lp) check for
shared EM case to reset exchange specific to a lport requested reset.
5. Updates exch allocation API fc_exch_alloc to use EM anchor list and
its anchor match func pointer. The fc_exch_alloc will walk the list
of EMs until it finds a match, a match will be either null match
func pointer or call to match function returning true value.
6. Updates fc_exch_recv to accept incoming frame on local port using
only lport pointer and frame pointer without specifying EM instance
of incoming frame. Instead modified fc_exch_recv to locate EM for the
incoming frame by matching xid of incoming frame against a EM xid range.
This change was required to use EM list in libfc Rx path and after this
change the lport fc_exch_mgr pointer emp is not needed anymore, so
removed emp pointer.
7. Updates fnic for removed lport emp pointer and above modified libfc APIs
fc_exch_recv, fc_exch_mgr_alloc and fc_exch_mgr_free.
8. Removes exch_get and exch_put from libfc_function_template as these
are no longer needed with EM anchor list and its match function use.
Also removes its default function fc_exch_get.
A defect this patch introduced regarding the libfc initialization order in
the fnic driver was fixed by Joe Eykholt <jeykholt@cisco.com>.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-07-30 00:05:10 +00:00
|
|
|
ep = fc_exch_resp(lport, mp, fp);
|
2008-12-09 23:10:17 +00:00
|
|
|
if (!ep) {
|
|
|
|
reject = FC_RJT_EXCH_EST; /* XXX */
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
xid = ep->xid; /* get our XID */
|
|
|
|
} else if (!ep) {
|
|
|
|
atomic_inc(&mp->stats.xid_not_found);
|
|
|
|
reject = FC_RJT_RX_ID; /* XID not found */
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-14 15:37:08 +00:00
|
|
|
spin_lock_bh(&ep->ex_lock);
|
2008-12-09 23:10:17 +00:00
|
|
|
/*
|
|
|
|
* At this point, we have the exchange held.
|
|
|
|
* Find or create the sequence.
|
|
|
|
*/
|
|
|
|
if (fc_sof_is_init(fr_sof(fp))) {
|
2010-03-13 00:08:34 +00:00
|
|
|
sp = &ep->seq;
|
2008-12-09 23:10:17 +00:00
|
|
|
sp->ssb_stat |= SSB_ST_RESP;
|
2010-05-07 22:18:13 +00:00
|
|
|
sp->id = fh->fh_seq_id;
|
2008-12-09 23:10:17 +00:00
|
|
|
} else {
|
|
|
|
sp = &ep->seq;
|
|
|
|
if (sp->id != fh->fh_seq_id) {
|
|
|
|
atomic_inc(&mp->stats.seq_not_found);
|
2011-06-20 23:59:30 +00:00
|
|
|
if (f_ctl & FC_FC_END_SEQ) {
|
|
|
|
/*
|
|
|
|
* Update sequence_id based on incoming last
|
|
|
|
* frame of sequence exchange. This is needed
|
2012-05-25 17:26:43 +00:00
|
|
|
* for FC target where DDP has been used
|
2011-06-20 23:59:30 +00:00
|
|
|
* on target where, stack is indicated only
|
|
|
|
* about last frame's (payload _header) header.
|
|
|
|
* Whereas "seq_id" which is part of
|
|
|
|
* frame_header is allocated by initiator
|
|
|
|
* which is totally different from "seq_id"
|
|
|
|
* allocated when XFER_RDY was sent by target.
|
|
|
|
* To avoid false -ve which results into not
|
|
|
|
* sending RSP, hence write request on other
|
|
|
|
* end never finishes.
|
|
|
|
*/
|
|
|
|
sp->ssb_stat |= SSB_ST_RESP;
|
|
|
|
sp->id = fh->fh_seq_id;
|
|
|
|
} else {
|
2013-08-14 15:37:08 +00:00
|
|
|
spin_unlock_bh(&ep->ex_lock);
|
|
|
|
|
2011-06-20 23:59:30 +00:00
|
|
|
/* sequence/exch should exist */
|
|
|
|
reject = FC_RJT_SEQ_ID;
|
|
|
|
goto rel;
|
|
|
|
}
|
2008-12-09 23:10:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
WARN_ON(ep != fc_seq_exch(sp));
|
|
|
|
|
|
|
|
if (f_ctl & FC_FC_SEQ_INIT)
|
|
|
|
ep->esb_stat |= ESB_ST_SEQ_INIT;
|
2013-08-14 15:37:08 +00:00
|
|
|
spin_unlock_bh(&ep->ex_lock);
|
2008-12-09 23:10:17 +00:00
|
|
|
|
|
|
|
fr_seq(fp) = sp;
|
|
|
|
out:
|
|
|
|
return reject;
|
|
|
|
rel:
|
|
|
|
fc_exch_done(&ep->seq);
|
|
|
|
fc_exch_release(ep); /* hold from fc_exch_find/fc_exch_resp */
|
|
|
|
return reject;
|
|
|
|
}
|
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
/**
|
|
|
|
* fc_seq_lookup_orig() - Find a sequence where this end
|
|
|
|
* originated the sequence
|
|
|
|
* @mp: The Exchange Manager to lookup the exchange from
|
|
|
|
* @fp: The frame associated with the sequence we're looking for
|
|
|
|
*
|
2008-12-09 23:10:17 +00:00
|
|
|
* Does not hold the sequence for the caller.
|
|
|
|
*/
|
|
|
|
static struct fc_seq *fc_seq_lookup_orig(struct fc_exch_mgr *mp,
|
|
|
|
struct fc_frame *fp)
|
|
|
|
{
|
|
|
|
struct fc_frame_header *fh = fc_frame_header_get(fp);
|
|
|
|
struct fc_exch *ep;
|
|
|
|
struct fc_seq *sp = NULL;
|
|
|
|
u32 f_ctl;
|
|
|
|
u16 xid;
|
|
|
|
|
|
|
|
f_ctl = ntoh24(fh->fh_f_ctl);
|
|
|
|
WARN_ON((f_ctl & FC_FC_SEQ_CTX) != FC_FC_SEQ_CTX);
|
|
|
|
xid = ntohs((f_ctl & FC_FC_EX_CTX) ? fh->fh_ox_id : fh->fh_rx_id);
|
|
|
|
ep = fc_exch_find(mp, xid);
|
|
|
|
if (!ep)
|
|
|
|
return NULL;
|
|
|
|
if (ep->seq.id == fh->fh_seq_id) {
|
|
|
|
/*
|
|
|
|
* Save the RX_ID if we didn't previously know it.
|
|
|
|
*/
|
|
|
|
sp = &ep->seq;
|
|
|
|
if ((f_ctl & FC_FC_EX_CTX) != 0 &&
|
|
|
|
ep->rxid == FC_XID_UNKNOWN) {
|
|
|
|
ep->rxid = ntohs(fh->fh_rx_id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fc_exch_release(ep);
|
|
|
|
return sp;
|
|
|
|
}
|
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
/**
|
|
|
|
* fc_exch_set_addr() - Set the source and destination IDs for an exchange
|
|
|
|
* @ep: The exchange to set the addresses for
|
|
|
|
* @orig_id: The originator's ID
|
|
|
|
* @resp_id: The responder's ID
|
|
|
|
*
|
2008-12-09 23:10:17 +00:00
|
|
|
* Note this must be done before the first sequence of the exchange is sent.
|
|
|
|
*/
|
|
|
|
static void fc_exch_set_addr(struct fc_exch *ep,
|
|
|
|
u32 orig_id, u32 resp_id)
|
|
|
|
{
|
|
|
|
ep->oid = orig_id;
|
|
|
|
if (ep->esb_stat & ESB_ST_RESP) {
|
|
|
|
ep->sid = resp_id;
|
|
|
|
ep->did = orig_id;
|
|
|
|
} else {
|
|
|
|
ep->sid = orig_id;
|
|
|
|
ep->did = resp_id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-03 19:45:47 +00:00
|
|
|
/**
|
2011-03-31 01:57:33 +00:00
|
|
|
* fc_seq_els_rsp_send() - Send an ELS response using information from
|
2009-11-03 19:47:39 +00:00
|
|
|
* the existing sequence/exchange.
|
2010-07-20 22:21:12 +00:00
|
|
|
* @fp: The received frame
|
2009-11-03 19:47:39 +00:00
|
|
|
* @els_cmd: The ELS command to be sent
|
|
|
|
* @els_data: The ELS data to be sent
|
2010-07-20 22:21:12 +00:00
|
|
|
*
|
|
|
|
* The received frame is not freed.
|
2008-12-09 23:10:17 +00:00
|
|
|
*/
|
2016-10-18 08:01:35 +00:00
|
|
|
void fc_seq_els_rsp_send(struct fc_frame *fp, enum fc_els_cmd els_cmd,
|
|
|
|
struct fc_seq_els_data *els_data)
|
2008-12-09 23:10:17 +00:00
|
|
|
{
|
|
|
|
switch (els_cmd) {
|
|
|
|
case ELS_LS_RJT:
|
2010-07-20 22:21:12 +00:00
|
|
|
fc_seq_ls_rjt(fp, els_data->reason, els_data->explan);
|
2008-12-09 23:10:17 +00:00
|
|
|
break;
|
|
|
|
case ELS_LS_ACC:
|
2010-07-20 22:21:12 +00:00
|
|
|
fc_seq_ls_acc(fp);
|
2008-12-09 23:10:17 +00:00
|
|
|
break;
|
|
|
|
case ELS_RRQ:
|
2010-07-20 22:21:12 +00:00
|
|
|
fc_exch_els_rrq(fp);
|
2008-12-09 23:10:17 +00:00
|
|
|
break;
|
|
|
|
case ELS_REC:
|
2010-07-20 22:21:12 +00:00
|
|
|
fc_exch_els_rec(fp);
|
2008-12-09 23:10:17 +00:00
|
|
|
break;
|
|
|
|
default:
|
2010-07-20 22:21:12 +00:00
|
|
|
FC_LPORT_DBG(fr_dev(fp), "Invalid ELS CMD:%x\n", els_cmd);
|
2008-12-09 23:10:17 +00:00
|
|
|
}
|
|
|
|
}
|
2016-10-18 08:01:35 +00:00
|
|
|
EXPORT_SYMBOL_GPL(fc_seq_els_rsp_send);
|
2008-12-09 23:10:17 +00:00
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
/**
|
|
|
|
* fc_seq_send_last() - Send a sequence that is the last in the exchange
|
|
|
|
* @sp: The sequence that is to be sent
|
|
|
|
* @fp: The frame that will be sent on the sequence
|
|
|
|
* @rctl: The R_CTL information to be sent
|
|
|
|
* @fh_type: The frame header type
|
2008-12-09 23:10:17 +00:00
|
|
|
*/
|
|
|
|
static void fc_seq_send_last(struct fc_seq *sp, struct fc_frame *fp,
|
|
|
|
enum fc_rctl rctl, enum fc_fh_type fh_type)
|
|
|
|
{
|
|
|
|
u32 f_ctl;
|
|
|
|
struct fc_exch *ep = fc_seq_exch(sp);
|
|
|
|
|
|
|
|
f_ctl = FC_FC_LAST_SEQ | FC_FC_END_SEQ | FC_FC_SEQ_INIT;
|
|
|
|
f_ctl |= ep->f_ctl;
|
|
|
|
fc_fill_fc_hdr(fp, rctl, ep->did, ep->sid, fh_type, f_ctl, 0);
|
2013-05-03 19:34:15 +00:00
|
|
|
fc_seq_send_locked(ep->lp, sp, fp);
|
2008-12-09 23:10:17 +00:00
|
|
|
}
|
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
/**
|
|
|
|
* fc_seq_send_ack() - Send an acknowledgement that we've received a frame
|
|
|
|
* @sp: The sequence to send the ACK on
|
|
|
|
* @rx_fp: The received frame that is being acknoledged
|
|
|
|
*
|
2008-12-09 23:10:17 +00:00
|
|
|
* Send ACK_1 (or equiv.) indicating we received something.
|
|
|
|
*/
|
|
|
|
static void fc_seq_send_ack(struct fc_seq *sp, const struct fc_frame *rx_fp)
|
|
|
|
{
|
|
|
|
struct fc_frame *fp;
|
|
|
|
struct fc_frame_header *rx_fh;
|
|
|
|
struct fc_frame_header *fh;
|
|
|
|
struct fc_exch *ep = fc_seq_exch(sp);
|
2009-11-03 19:47:39 +00:00
|
|
|
struct fc_lport *lport = ep->lp;
|
2008-12-09 23:10:17 +00:00
|
|
|
unsigned int f_ctl;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Don't send ACKs for class 3.
|
|
|
|
*/
|
|
|
|
if (fc_sof_needs_ack(fr_sof(rx_fp))) {
|
2009-11-03 19:47:39 +00:00
|
|
|
fp = fc_frame_alloc(lport, 0);
|
2016-10-13 13:10:37 +00:00
|
|
|
if (!fp) {
|
|
|
|
FC_EXCH_DBG(ep, "Drop ACK request, out of memory\n");
|
2008-12-09 23:10:17 +00:00
|
|
|
return;
|
2016-10-13 13:10:37 +00:00
|
|
|
}
|
2008-12-09 23:10:17 +00:00
|
|
|
|
|
|
|
fh = fc_frame_header_get(fp);
|
|
|
|
fh->fh_r_ctl = FC_RCTL_ACK_1;
|
|
|
|
fh->fh_type = FC_TYPE_BLS;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Form f_ctl by inverting EX_CTX and SEQ_CTX (bits 23, 22).
|
|
|
|
* Echo FIRST_SEQ, LAST_SEQ, END_SEQ, END_CONN, SEQ_INIT.
|
|
|
|
* Bits 9-8 are meaningful (retransmitted or unidirectional).
|
|
|
|
* Last ACK uses bits 7-6 (continue sequence),
|
|
|
|
* bits 5-4 are meaningful (what kind of ACK to use).
|
|
|
|
*/
|
|
|
|
rx_fh = fc_frame_header_get(rx_fp);
|
|
|
|
f_ctl = ntoh24(rx_fh->fh_f_ctl);
|
|
|
|
f_ctl &= FC_FC_EX_CTX | FC_FC_SEQ_CTX |
|
|
|
|
FC_FC_FIRST_SEQ | FC_FC_LAST_SEQ |
|
|
|
|
FC_FC_END_SEQ | FC_FC_END_CONN | FC_FC_SEQ_INIT |
|
|
|
|
FC_FC_RETX_SEQ | FC_FC_UNI_TX;
|
|
|
|
f_ctl ^= FC_FC_EX_CTX | FC_FC_SEQ_CTX;
|
|
|
|
hton24(fh->fh_f_ctl, f_ctl);
|
|
|
|
|
|
|
|
fc_exch_setup_hdr(ep, fp, f_ctl);
|
|
|
|
fh->fh_seq_id = rx_fh->fh_seq_id;
|
|
|
|
fh->fh_seq_cnt = rx_fh->fh_seq_cnt;
|
|
|
|
fh->fh_parm_offset = htonl(1); /* ack single frame */
|
|
|
|
|
|
|
|
fr_sof(fp) = fr_sof(rx_fp);
|
|
|
|
if (f_ctl & FC_FC_END_SEQ)
|
|
|
|
fr_eof(fp) = FC_EOF_T;
|
|
|
|
else
|
|
|
|
fr_eof(fp) = FC_EOF_N;
|
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
lport->tt.frame_send(lport, fp);
|
2008-12-09 23:10:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
/**
|
|
|
|
* fc_exch_send_ba_rjt() - Send BLS Reject
|
|
|
|
* @rx_fp: The frame being rejected
|
|
|
|
* @reason: The reason the frame is being rejected
|
2011-03-31 01:57:33 +00:00
|
|
|
* @explan: The explanation for the rejection
|
2009-11-03 19:47:39 +00:00
|
|
|
*
|
2008-12-09 23:10:17 +00:00
|
|
|
* This is for rejecting BA_ABTS only.
|
|
|
|
*/
|
2009-02-27 18:55:50 +00:00
|
|
|
static void fc_exch_send_ba_rjt(struct fc_frame *rx_fp,
|
|
|
|
enum fc_ba_rjt_reason reason,
|
|
|
|
enum fc_ba_rjt_explan explan)
|
2008-12-09 23:10:17 +00:00
|
|
|
{
|
|
|
|
struct fc_frame *fp;
|
|
|
|
struct fc_frame_header *rx_fh;
|
|
|
|
struct fc_frame_header *fh;
|
|
|
|
struct fc_ba_rjt *rp;
|
2016-10-13 13:10:37 +00:00
|
|
|
struct fc_seq *sp;
|
2009-11-03 19:47:39 +00:00
|
|
|
struct fc_lport *lport;
|
2008-12-09 23:10:17 +00:00
|
|
|
unsigned int f_ctl;
|
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
lport = fr_dev(rx_fp);
|
2016-10-13 13:10:37 +00:00
|
|
|
sp = fr_seq(rx_fp);
|
2009-11-03 19:47:39 +00:00
|
|
|
fp = fc_frame_alloc(lport, sizeof(*rp));
|
2016-10-13 13:10:37 +00:00
|
|
|
if (!fp) {
|
|
|
|
FC_EXCH_DBG(fc_seq_exch(sp),
|
|
|
|
"Drop BA_RJT request, out of memory\n");
|
2008-12-09 23:10:17 +00:00
|
|
|
return;
|
2016-10-13 13:10:37 +00:00
|
|
|
}
|
2008-12-09 23:10:17 +00:00
|
|
|
fh = fc_frame_header_get(fp);
|
|
|
|
rx_fh = fc_frame_header_get(rx_fp);
|
|
|
|
|
|
|
|
memset(fh, 0, sizeof(*fh) + sizeof(*rp));
|
|
|
|
|
|
|
|
rp = fc_frame_payload_get(fp, sizeof(*rp));
|
|
|
|
rp->br_reason = reason;
|
|
|
|
rp->br_explan = explan;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* seq_id, cs_ctl, df_ctl and param/offset are zero.
|
|
|
|
*/
|
|
|
|
memcpy(fh->fh_s_id, rx_fh->fh_d_id, 3);
|
|
|
|
memcpy(fh->fh_d_id, rx_fh->fh_s_id, 3);
|
2009-08-25 21:04:03 +00:00
|
|
|
fh->fh_ox_id = rx_fh->fh_ox_id;
|
|
|
|
fh->fh_rx_id = rx_fh->fh_rx_id;
|
2008-12-09 23:10:17 +00:00
|
|
|
fh->fh_seq_cnt = rx_fh->fh_seq_cnt;
|
|
|
|
fh->fh_r_ctl = FC_RCTL_BA_RJT;
|
|
|
|
fh->fh_type = FC_TYPE_BLS;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Form f_ctl by inverting EX_CTX and SEQ_CTX (bits 23, 22).
|
|
|
|
* Echo FIRST_SEQ, LAST_SEQ, END_SEQ, END_CONN, SEQ_INIT.
|
|
|
|
* Bits 9-8 are meaningful (retransmitted or unidirectional).
|
|
|
|
* Last ACK uses bits 7-6 (continue sequence),
|
|
|
|
* bits 5-4 are meaningful (what kind of ACK to use).
|
|
|
|
* Always set LAST_SEQ, END_SEQ.
|
|
|
|
*/
|
|
|
|
f_ctl = ntoh24(rx_fh->fh_f_ctl);
|
|
|
|
f_ctl &= FC_FC_EX_CTX | FC_FC_SEQ_CTX |
|
|
|
|
FC_FC_END_CONN | FC_FC_SEQ_INIT |
|
|
|
|
FC_FC_RETX_SEQ | FC_FC_UNI_TX;
|
|
|
|
f_ctl ^= FC_FC_EX_CTX | FC_FC_SEQ_CTX;
|
|
|
|
f_ctl |= FC_FC_LAST_SEQ | FC_FC_END_SEQ;
|
|
|
|
f_ctl &= ~FC_FC_FIRST_SEQ;
|
|
|
|
hton24(fh->fh_f_ctl, f_ctl);
|
|
|
|
|
|
|
|
fr_sof(fp) = fc_sof_class(fr_sof(rx_fp));
|
|
|
|
fr_eof(fp) = FC_EOF_T;
|
|
|
|
if (fc_sof_needs_ack(fr_sof(fp)))
|
|
|
|
fr_eof(fp) = FC_EOF_N;
|
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
lport->tt.frame_send(lport, fp);
|
2008-12-09 23:10:17 +00:00
|
|
|
}
|
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
/**
|
|
|
|
* fc_exch_recv_abts() - Handle an incoming ABTS
|
|
|
|
* @ep: The exchange the abort was on
|
|
|
|
* @rx_fp: The ABTS frame
|
|
|
|
*
|
|
|
|
* This would be for target mode usually, but could be due to lost
|
|
|
|
* FCP transfer ready, confirm or RRQ. We always handle this as an
|
|
|
|
* exchange abort, ignoring the parameter.
|
2008-12-09 23:10:17 +00:00
|
|
|
*/
|
|
|
|
static void fc_exch_recv_abts(struct fc_exch *ep, struct fc_frame *rx_fp)
|
|
|
|
{
|
|
|
|
struct fc_frame *fp;
|
|
|
|
struct fc_ba_acc *ap;
|
|
|
|
struct fc_frame_header *fh;
|
|
|
|
struct fc_seq *sp;
|
|
|
|
|
|
|
|
if (!ep)
|
|
|
|
goto reject;
|
2013-08-14 15:38:24 +00:00
|
|
|
|
2016-10-13 13:10:37 +00:00
|
|
|
FC_EXCH_DBG(ep, "exch: ABTS received\n");
|
2013-08-14 15:38:24 +00:00
|
|
|
fp = fc_frame_alloc(ep->lp, sizeof(*ap));
|
2016-10-13 13:10:37 +00:00
|
|
|
if (!fp) {
|
|
|
|
FC_EXCH_DBG(ep, "Drop ABTS request, out of memory\n");
|
2013-08-14 15:38:24 +00:00
|
|
|
goto free;
|
2016-10-13 13:10:37 +00:00
|
|
|
}
|
2013-08-14 15:38:24 +00:00
|
|
|
|
2008-12-09 23:10:17 +00:00
|
|
|
spin_lock_bh(&ep->ex_lock);
|
|
|
|
if (ep->esb_stat & ESB_ST_COMPLETE) {
|
|
|
|
spin_unlock_bh(&ep->ex_lock);
|
2016-10-13 13:10:37 +00:00
|
|
|
FC_EXCH_DBG(ep, "exch: ABTS rejected, exchange complete\n");
|
2013-08-14 15:38:24 +00:00
|
|
|
fc_frame_free(fp);
|
2008-12-09 23:10:17 +00:00
|
|
|
goto reject;
|
|
|
|
}
|
2013-08-14 15:37:52 +00:00
|
|
|
if (!(ep->esb_stat & ESB_ST_REC_QUAL)) {
|
|
|
|
ep->esb_stat |= ESB_ST_REC_QUAL;
|
2008-12-09 23:10:17 +00:00
|
|
|
fc_exch_hold(ep); /* hold for REC_QUAL */
|
2013-08-14 15:37:52 +00:00
|
|
|
}
|
2008-12-09 23:10:17 +00:00
|
|
|
fc_exch_timer_set_locked(ep, ep->r_a_tov);
|
|
|
|
fh = fc_frame_header_get(fp);
|
|
|
|
ap = fc_frame_payload_get(fp, sizeof(*ap));
|
|
|
|
memset(ap, 0, sizeof(*ap));
|
|
|
|
sp = &ep->seq;
|
|
|
|
ap->ba_high_seq_cnt = htons(0xffff);
|
|
|
|
if (sp->ssb_stat & SSB_ST_RESP) {
|
|
|
|
ap->ba_seq_id = sp->id;
|
|
|
|
ap->ba_seq_id_val = FC_BA_SEQ_ID_VAL;
|
|
|
|
ap->ba_high_seq_cnt = fh->fh_seq_cnt;
|
|
|
|
ap->ba_low_seq_cnt = htons(sp->cnt);
|
|
|
|
}
|
2009-02-27 18:54:51 +00:00
|
|
|
sp = fc_seq_start_next_locked(sp);
|
2008-12-09 23:10:17 +00:00
|
|
|
fc_seq_send_last(sp, fp, FC_RCTL_BA_ACC, FC_TYPE_BLS);
|
2013-08-14 15:37:52 +00:00
|
|
|
ep->esb_stat |= ESB_ST_ABNORMAL;
|
2013-05-03 19:34:15 +00:00
|
|
|
spin_unlock_bh(&ep->ex_lock);
|
2013-08-14 15:38:24 +00:00
|
|
|
|
|
|
|
free:
|
2008-12-09 23:10:17 +00:00
|
|
|
fc_frame_free(rx_fp);
|
|
|
|
return;
|
|
|
|
|
|
|
|
reject:
|
|
|
|
fc_exch_send_ba_rjt(rx_fp, FC_BA_RJT_UNABLE, FC_BA_RJT_INV_XID);
|
2013-08-14 15:38:24 +00:00
|
|
|
goto free;
|
2008-12-09 23:10:17 +00:00
|
|
|
}
|
|
|
|
|
2010-07-20 22:21:07 +00:00
|
|
|
/**
|
|
|
|
* fc_seq_assign() - Assign exchange and sequence for incoming request
|
|
|
|
* @lport: The local port that received the request
|
|
|
|
* @fp: The request frame
|
|
|
|
*
|
|
|
|
* On success, the sequence pointer will be returned and also in fr_seq(@fp).
|
2011-01-29 00:04:34 +00:00
|
|
|
* A reference will be held on the exchange/sequence for the caller, which
|
|
|
|
* must call fc_seq_release().
|
2010-07-20 22:21:07 +00:00
|
|
|
*/
|
2016-10-18 08:01:53 +00:00
|
|
|
struct fc_seq *fc_seq_assign(struct fc_lport *lport, struct fc_frame *fp)
|
2010-07-20 22:21:07 +00:00
|
|
|
{
|
|
|
|
struct fc_exch_mgr_anchor *ema;
|
|
|
|
|
|
|
|
WARN_ON(lport != fr_dev(fp));
|
|
|
|
WARN_ON(fr_seq(fp));
|
|
|
|
fr_seq(fp) = NULL;
|
|
|
|
|
|
|
|
list_for_each_entry(ema, &lport->ema_list, ema_list)
|
|
|
|
if ((!ema->match || ema->match(fp)) &&
|
2010-12-01 00:18:28 +00:00
|
|
|
fc_seq_lookup_recip(lport, ema->mp, fp) == FC_RJT_NONE)
|
2010-07-20 22:21:07 +00:00
|
|
|
break;
|
|
|
|
return fr_seq(fp);
|
|
|
|
}
|
2016-10-18 08:01:53 +00:00
|
|
|
EXPORT_SYMBOL(fc_seq_assign);
|
2010-07-20 22:21:07 +00:00
|
|
|
|
2011-01-29 00:04:34 +00:00
|
|
|
/**
|
|
|
|
* fc_seq_release() - Release the hold
|
|
|
|
* @sp: The sequence.
|
|
|
|
*/
|
|
|
|
static void fc_seq_release(struct fc_seq *sp)
|
|
|
|
{
|
|
|
|
fc_exch_release(fc_seq_exch(sp));
|
|
|
|
}
|
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
/**
|
2010-07-20 22:21:12 +00:00
|
|
|
* fc_exch_recv_req() - Handler for an incoming request
|
2009-11-03 19:47:39 +00:00
|
|
|
* @lport: The local port that received the request
|
|
|
|
* @mp: The EM that the exchange is on
|
|
|
|
* @fp: The request frame
|
2010-07-20 22:21:12 +00:00
|
|
|
*
|
|
|
|
* This is used when the other end is originating the exchange
|
|
|
|
* and the sequence.
|
2008-12-09 23:10:17 +00:00
|
|
|
*/
|
2009-11-03 19:47:39 +00:00
|
|
|
static void fc_exch_recv_req(struct fc_lport *lport, struct fc_exch_mgr *mp,
|
2008-12-09 23:10:17 +00:00
|
|
|
struct fc_frame *fp)
|
|
|
|
{
|
|
|
|
struct fc_frame_header *fh = fc_frame_header_get(fp);
|
|
|
|
struct fc_seq *sp = NULL;
|
|
|
|
struct fc_exch *ep = NULL;
|
|
|
|
enum fc_pf_rjt_reason reject;
|
|
|
|
|
2009-11-03 19:46:14 +00:00
|
|
|
/* We can have the wrong fc_lport at this point with NPIV, which is a
|
|
|
|
* problem now that we know a new exchange needs to be allocated
|
|
|
|
*/
|
2009-11-03 19:47:39 +00:00
|
|
|
lport = fc_vport_id_lookup(lport, ntoh24(fh->fh_d_id));
|
|
|
|
if (!lport) {
|
2009-11-03 19:46:14 +00:00
|
|
|
fc_frame_free(fp);
|
|
|
|
return;
|
|
|
|
}
|
2010-07-20 22:21:12 +00:00
|
|
|
fr_dev(fp) = lport;
|
|
|
|
|
|
|
|
BUG_ON(fr_seq(fp)); /* XXX remove later */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the RX_ID is 0xffff, don't allocate an exchange.
|
|
|
|
* The upper-level protocol may request one later, if needed.
|
|
|
|
*/
|
|
|
|
if (fh->fh_rx_id == htons(FC_XID_UNKNOWN))
|
2016-10-18 08:01:37 +00:00
|
|
|
return fc_lport_recv(lport, fp);
|
2009-11-03 19:46:14 +00:00
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
reject = fc_seq_lookup_recip(lport, mp, fp);
|
2008-12-09 23:10:17 +00:00
|
|
|
if (reject == FC_RJT_NONE) {
|
|
|
|
sp = fr_seq(fp); /* sequence will be held */
|
|
|
|
ep = fc_seq_exch(sp);
|
|
|
|
fc_seq_send_ack(sp, fp);
|
[SCSI] libfc: track FIP exchanges
When an exchange is received with a FIP encapsulation, we need
to know that the response must be sent via FIP and what the original
ELS opcode was. This becomes important for VN2VN mode, where we may
receive FLOGI or LOGO from several peer VN_ports, and the LS_ACC or
LS_RJT must be sent FIP-encapsulated with the correct sub-type.
Add a field to the struct fc_frame, fr_encaps, to indicate the
encapsulation values. That term is chosen to be neutral and
LLD-agnostic in case non-FCoE/FIP LLDs might find it useful.
The frame fr_encaps is transferred from the ingress frame to the
exchange by fc_exch_recv_req(), and back to the outgoing frame
by fc_seq_send().
This is taking the last byte in the skb->cb array. If needed,
we could combine the info in sof, eof, flags, and encaps
together into one field, but it'd be better to do that if
and when its needed.
Signed-off-by: Joe Eykholt <jeykholt@cisco.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2010-07-20 22:20:14 +00:00
|
|
|
ep->encaps = fr_encaps(fp);
|
2008-12-09 23:10:17 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Call the receive function.
|
|
|
|
*
|
|
|
|
* The receive function may allocate a new sequence
|
|
|
|
* over the old one, so we shouldn't change the
|
|
|
|
* sequence after this.
|
|
|
|
*
|
|
|
|
* The frame will be freed by the receive function.
|
|
|
|
* If new exch resp handler is valid then call that
|
|
|
|
* first.
|
|
|
|
*/
|
2013-08-17 20:34:43 +00:00
|
|
|
if (!fc_invoke_resp(ep, sp, fp))
|
2016-10-18 08:01:37 +00:00
|
|
|
fc_lport_recv(lport, fp);
|
2008-12-09 23:10:17 +00:00
|
|
|
fc_exch_release(ep); /* release from lookup */
|
|
|
|
} else {
|
2009-11-03 19:47:39 +00:00
|
|
|
FC_LPORT_DBG(lport, "exch/seq lookup failed: reject %x\n",
|
|
|
|
reject);
|
2008-12-09 23:10:17 +00:00
|
|
|
fc_frame_free(fp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
/**
|
|
|
|
* fc_exch_recv_seq_resp() - Handler for an incoming response where the other
|
|
|
|
* end is the originator of the sequence that is a
|
|
|
|
* response to our initial exchange
|
|
|
|
* @mp: The EM that the exchange is on
|
|
|
|
* @fp: The response frame
|
2008-12-09 23:10:17 +00:00
|
|
|
*/
|
|
|
|
static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
|
|
|
|
{
|
|
|
|
struct fc_frame_header *fh = fc_frame_header_get(fp);
|
|
|
|
struct fc_seq *sp;
|
|
|
|
struct fc_exch *ep;
|
|
|
|
enum fc_sof sof;
|
|
|
|
u32 f_ctl;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
|
|
|
|
if (!ep) {
|
|
|
|
atomic_inc(&mp->stats.xid_not_found);
|
|
|
|
goto out;
|
|
|
|
}
|
2009-05-06 17:52:29 +00:00
|
|
|
if (ep->esb_stat & ESB_ST_COMPLETE) {
|
|
|
|
atomic_inc(&mp->stats.xid_not_found);
|
2010-12-01 00:18:12 +00:00
|
|
|
goto rel;
|
2009-05-06 17:52:29 +00:00
|
|
|
}
|
2008-12-09 23:10:17 +00:00
|
|
|
if (ep->rxid == FC_XID_UNKNOWN)
|
|
|
|
ep->rxid = ntohs(fh->fh_rx_id);
|
|
|
|
if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
|
|
|
|
atomic_inc(&mp->stats.xid_not_found);
|
|
|
|
goto rel;
|
|
|
|
}
|
|
|
|
if (ep->did != ntoh24(fh->fh_s_id) &&
|
|
|
|
ep->did != FC_FID_FLOGI) {
|
|
|
|
atomic_inc(&mp->stats.xid_not_found);
|
|
|
|
goto rel;
|
|
|
|
}
|
|
|
|
sof = fr_sof(fp);
|
2010-03-13 00:08:34 +00:00
|
|
|
sp = &ep->seq;
|
2010-05-07 22:18:13 +00:00
|
|
|
if (fc_sof_is_init(sof)) {
|
2008-12-09 23:10:17 +00:00
|
|
|
sp->ssb_stat |= SSB_ST_RESP;
|
2010-05-07 22:18:13 +00:00
|
|
|
sp->id = fh->fh_seq_id;
|
2008-12-09 23:10:17 +00:00
|
|
|
}
|
2010-03-13 00:08:34 +00:00
|
|
|
|
2008-12-09 23:10:17 +00:00
|
|
|
f_ctl = ntoh24(fh->fh_f_ctl);
|
|
|
|
fr_seq(fp) = sp;
|
2013-08-14 15:37:08 +00:00
|
|
|
|
|
|
|
spin_lock_bh(&ep->ex_lock);
|
2008-12-09 23:10:17 +00:00
|
|
|
if (f_ctl & FC_FC_SEQ_INIT)
|
|
|
|
ep->esb_stat |= ESB_ST_SEQ_INIT;
|
2013-08-14 15:37:08 +00:00
|
|
|
spin_unlock_bh(&ep->ex_lock);
|
2008-12-09 23:10:17 +00:00
|
|
|
|
|
|
|
if (fc_sof_needs_ack(sof))
|
|
|
|
fc_seq_send_ack(sp, fp);
|
|
|
|
|
|
|
|
if (fh->fh_type != FC_TYPE_FCP && fr_eof(fp) == FC_EOF_T &&
|
|
|
|
(f_ctl & (FC_FC_LAST_SEQ | FC_FC_END_SEQ)) ==
|
|
|
|
(FC_FC_LAST_SEQ | FC_FC_END_SEQ)) {
|
|
|
|
spin_lock_bh(&ep->ex_lock);
|
|
|
|
rc = fc_exch_done_locked(ep);
|
|
|
|
WARN_ON(fc_seq_exch(sp) != ep);
|
|
|
|
spin_unlock_bh(&ep->ex_lock);
|
|
|
|
if (!rc)
|
[SCSI] fcoe, libfc: fully makes use of per cpu exch pool and then removes em_lock
1. Updates fcoe_rcv() to queue incoming frames to the fcoe per
cpu thread on which this frame's exch was originated and simply
use current cpu for request exch not originated by initiator.
It is redundant to add this code under CONFIG_SMP, so removes
CONFIG_SMP uses around this code.
2. Updates fc_exch_em_alloc, fc_exch_delete, fc_exch_find to use
per cpu exch pools, here fc_exch_delete is rename of older
fc_exch_mgr_delete_ep since ep/exch are now deleted in pools
of EM and so brief new name is sufficient and better name.
Updates these functions to map exch id to their index into exch
pool using fc_cpu_mask, fc_cpu_order and EM min_xid.
This mapping is as per detailed explanation about this in
last patch and basically this is just as lower fc_cpu_mask
bits of exch id as cpu number and upper bit sum of EM min_xid
and exch index in pool.
Uses pool next_index to keep track of exch allocation from
pool along with pool_max_index as upper bound of exches array
in pool.
3. Adds exch pool ptr to fc_exch to free exch to its pool in
fc_exch_delete.
4. Updates fc_exch_mgr_reset to reset all exch pools of an EM,
this required adding fc_exch_pool_reset func to reset exches
in pool and then have fc_exch_mgr_reset call fc_exch_pool_reset
for each pool within each EM for a lport.
5. Removes no longer needed exches array, em_lock, next_xid, and
total_exches from struct fc_exch_mgr, these are not needed after
use of per cpu exch pool, also removes not used max_read,
last_read from struct fc_exch_mgr.
6. Updates locking notes for exch pool lock with fc_exch lock and
uses pool lock in exch allocation, lookup and reset.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:53 +00:00
|
|
|
fc_exch_delete(ep);
|
2008-12-09 23:10:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Call the receive function.
|
|
|
|
* The sequence is held (has a refcnt) for us,
|
|
|
|
* but not for the receive function.
|
|
|
|
*
|
|
|
|
* The receive function may allocate a new sequence
|
|
|
|
* over the old one, so we shouldn't change the
|
|
|
|
* sequence after this.
|
|
|
|
*
|
|
|
|
* The frame will be freed by the receive function.
|
|
|
|
* If new exch resp handler is valid then call that
|
|
|
|
* first.
|
|
|
|
*/
|
2015-06-05 21:20:46 +00:00
|
|
|
if (!fc_invoke_resp(ep, sp, fp))
|
|
|
|
fc_frame_free(fp);
|
2013-08-17 20:34:43 +00:00
|
|
|
|
2008-12-09 23:10:17 +00:00
|
|
|
fc_exch_release(ep);
|
|
|
|
return;
|
|
|
|
rel:
|
|
|
|
fc_exch_release(ep);
|
|
|
|
out:
|
|
|
|
fc_frame_free(fp);
|
|
|
|
}
|
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
/**
|
|
|
|
* fc_exch_recv_resp() - Handler for a sequence where other end is
|
|
|
|
* responding to our sequence
|
|
|
|
* @mp: The EM that the exchange is on
|
|
|
|
* @fp: The response frame
|
2008-12-09 23:10:17 +00:00
|
|
|
*/
|
|
|
|
static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
|
|
|
|
{
|
|
|
|
struct fc_seq *sp;
|
|
|
|
|
|
|
|
sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
|
2009-07-30 00:05:05 +00:00
|
|
|
|
|
|
|
if (!sp)
|
2008-12-09 23:10:17 +00:00
|
|
|
atomic_inc(&mp->stats.xid_not_found);
|
2009-07-30 00:05:05 +00:00
|
|
|
else
|
2008-12-09 23:10:17 +00:00
|
|
|
atomic_inc(&mp->stats.non_bls_resp);
|
2009-07-30 00:05:05 +00:00
|
|
|
|
2008-12-09 23:10:17 +00:00
|
|
|
fc_frame_free(fp);
|
|
|
|
}
|
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
/**
|
|
|
|
* fc_exch_abts_resp() - Handler for a response to an ABT
|
|
|
|
* @ep: The exchange that the frame is on
|
|
|
|
* @fp: The response frame
|
|
|
|
*
|
|
|
|
* This response would be to an ABTS cancelling an exchange or sequence.
|
|
|
|
* The response can be either BA_ACC or BA_RJT
|
2008-12-09 23:10:17 +00:00
|
|
|
*/
|
|
|
|
static void fc_exch_abts_resp(struct fc_exch *ep, struct fc_frame *fp)
|
|
|
|
{
|
|
|
|
struct fc_frame_header *fh;
|
|
|
|
struct fc_ba_acc *ap;
|
|
|
|
struct fc_seq *sp;
|
|
|
|
u16 low;
|
|
|
|
u16 high;
|
|
|
|
int rc = 1, has_rec = 0;
|
|
|
|
|
|
|
|
fh = fc_frame_header_get(fp);
|
2009-06-10 22:31:10 +00:00
|
|
|
FC_EXCH_DBG(ep, "exch: BLS rctl %x - %s\n", fh->fh_r_ctl,
|
|
|
|
fc_exch_rctl_name(fh->fh_r_ctl));
|
2008-12-09 23:10:17 +00:00
|
|
|
|
2012-07-06 17:40:10 +00:00
|
|
|
if (cancel_delayed_work_sync(&ep->timeout_work)) {
|
2013-06-11 07:28:09 +00:00
|
|
|
FC_EXCH_DBG(ep, "Exchange timer canceled due to ABTS response\n");
|
2008-12-09 23:10:17 +00:00
|
|
|
fc_exch_release(ep); /* release from pending timer hold */
|
2012-07-06 17:40:10 +00:00
|
|
|
}
|
2008-12-09 23:10:17 +00:00
|
|
|
|
|
|
|
spin_lock_bh(&ep->ex_lock);
|
|
|
|
switch (fh->fh_r_ctl) {
|
|
|
|
case FC_RCTL_BA_ACC:
|
|
|
|
ap = fc_frame_payload_get(fp, sizeof(*ap));
|
|
|
|
if (!ap)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Decide whether to establish a Recovery Qualifier.
|
|
|
|
* We do this if there is a non-empty SEQ_CNT range and
|
|
|
|
* SEQ_ID is the same as the one we aborted.
|
|
|
|
*/
|
|
|
|
low = ntohs(ap->ba_low_seq_cnt);
|
|
|
|
high = ntohs(ap->ba_high_seq_cnt);
|
|
|
|
if ((ep->esb_stat & ESB_ST_REC_QUAL) == 0 &&
|
|
|
|
(ap->ba_seq_id_val != FC_BA_SEQ_ID_VAL ||
|
|
|
|
ap->ba_seq_id == ep->seq_id) && low != high) {
|
|
|
|
ep->esb_stat |= ESB_ST_REC_QUAL;
|
|
|
|
fc_exch_hold(ep); /* hold for recovery qualifier */
|
|
|
|
has_rec = 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FC_RCTL_BA_RJT:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* do we need to do some other checks here. Can we reuse more of
|
|
|
|
* fc_exch_recv_seq_resp
|
|
|
|
*/
|
|
|
|
sp = &ep->seq;
|
|
|
|
/*
|
|
|
|
* do we want to check END_SEQ as well as LAST_SEQ here?
|
|
|
|
*/
|
|
|
|
if (ep->fh_type != FC_TYPE_FCP &&
|
|
|
|
ntoh24(fh->fh_f_ctl) & FC_FC_LAST_SEQ)
|
|
|
|
rc = fc_exch_done_locked(ep);
|
|
|
|
spin_unlock_bh(&ep->ex_lock);
|
2013-08-17 20:34:43 +00:00
|
|
|
|
|
|
|
fc_exch_hold(ep);
|
2008-12-09 23:10:17 +00:00
|
|
|
if (!rc)
|
[SCSI] fcoe, libfc: fully makes use of per cpu exch pool and then removes em_lock
1. Updates fcoe_rcv() to queue incoming frames to the fcoe per
cpu thread on which this frame's exch was originated and simply
use current cpu for request exch not originated by initiator.
It is redundant to add this code under CONFIG_SMP, so removes
CONFIG_SMP uses around this code.
2. Updates fc_exch_em_alloc, fc_exch_delete, fc_exch_find to use
per cpu exch pools, here fc_exch_delete is rename of older
fc_exch_mgr_delete_ep since ep/exch are now deleted in pools
of EM and so brief new name is sufficient and better name.
Updates these functions to map exch id to their index into exch
pool using fc_cpu_mask, fc_cpu_order and EM min_xid.
This mapping is as per detailed explanation about this in
last patch and basically this is just as lower fc_cpu_mask
bits of exch id as cpu number and upper bit sum of EM min_xid
and exch index in pool.
Uses pool next_index to keep track of exch allocation from
pool along with pool_max_index as upper bound of exches array
in pool.
3. Adds exch pool ptr to fc_exch to free exch to its pool in
fc_exch_delete.
4. Updates fc_exch_mgr_reset to reset all exch pools of an EM,
this required adding fc_exch_pool_reset func to reset exches
in pool and then have fc_exch_mgr_reset call fc_exch_pool_reset
for each pool within each EM for a lport.
5. Removes no longer needed exches array, em_lock, next_xid, and
total_exches from struct fc_exch_mgr, these are not needed after
use of per cpu exch pool, also removes not used max_read,
last_read from struct fc_exch_mgr.
6. Updates locking notes for exch pool lock with fc_exch lock and
uses pool lock in exch allocation, lookup and reset.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:53 +00:00
|
|
|
fc_exch_delete(ep);
|
2015-06-05 21:20:46 +00:00
|
|
|
if (!fc_invoke_resp(ep, sp, fp))
|
|
|
|
fc_frame_free(fp);
|
2008-12-09 23:10:17 +00:00
|
|
|
if (has_rec)
|
|
|
|
fc_exch_timer_set(ep, ep->r_a_tov);
|
2013-08-17 20:34:43 +00:00
|
|
|
fc_exch_release(ep);
|
2008-12-09 23:10:17 +00:00
|
|
|
}
|
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
/**
|
|
|
|
* fc_exch_recv_bls() - Handler for a BLS sequence
|
|
|
|
* @mp: The EM that the exchange is on
|
|
|
|
* @fp: The request frame
|
|
|
|
*
|
|
|
|
* The BLS frame is always a sequence initiated by the remote side.
|
2008-12-09 23:10:17 +00:00
|
|
|
* We may be either the originator or recipient of the exchange.
|
|
|
|
*/
|
|
|
|
static void fc_exch_recv_bls(struct fc_exch_mgr *mp, struct fc_frame *fp)
|
|
|
|
{
|
|
|
|
struct fc_frame_header *fh;
|
|
|
|
struct fc_exch *ep;
|
|
|
|
u32 f_ctl;
|
|
|
|
|
|
|
|
fh = fc_frame_header_get(fp);
|
|
|
|
f_ctl = ntoh24(fh->fh_f_ctl);
|
|
|
|
fr_seq(fp) = NULL;
|
|
|
|
|
|
|
|
ep = fc_exch_find(mp, (f_ctl & FC_FC_EX_CTX) ?
|
|
|
|
ntohs(fh->fh_ox_id) : ntohs(fh->fh_rx_id));
|
|
|
|
if (ep && (f_ctl & FC_FC_SEQ_INIT)) {
|
|
|
|
spin_lock_bh(&ep->ex_lock);
|
|
|
|
ep->esb_stat |= ESB_ST_SEQ_INIT;
|
|
|
|
spin_unlock_bh(&ep->ex_lock);
|
|
|
|
}
|
|
|
|
if (f_ctl & FC_FC_SEQ_CTX) {
|
|
|
|
/*
|
|
|
|
* A response to a sequence we initiated.
|
|
|
|
* This should only be ACKs for class 2 or F.
|
|
|
|
*/
|
|
|
|
switch (fh->fh_r_ctl) {
|
|
|
|
case FC_RCTL_ACK_1:
|
|
|
|
case FC_RCTL_ACK_0:
|
|
|
|
break;
|
|
|
|
default:
|
2012-02-11 01:18:51 +00:00
|
|
|
if (ep)
|
2013-08-14 15:32:51 +00:00
|
|
|
FC_EXCH_DBG(ep, "BLS rctl %x - %s received\n",
|
2012-02-11 01:18:51 +00:00
|
|
|
fh->fh_r_ctl,
|
|
|
|
fc_exch_rctl_name(fh->fh_r_ctl));
|
2008-12-09 23:10:17 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
fc_frame_free(fp);
|
|
|
|
} else {
|
|
|
|
switch (fh->fh_r_ctl) {
|
|
|
|
case FC_RCTL_BA_RJT:
|
|
|
|
case FC_RCTL_BA_ACC:
|
|
|
|
if (ep)
|
|
|
|
fc_exch_abts_resp(ep, fp);
|
|
|
|
else
|
|
|
|
fc_frame_free(fp);
|
|
|
|
break;
|
|
|
|
case FC_RCTL_BA_ABTS:
|
2016-10-13 13:10:49 +00:00
|
|
|
if (ep)
|
|
|
|
fc_exch_recv_abts(ep, fp);
|
|
|
|
else
|
|
|
|
fc_frame_free(fp);
|
2008-12-09 23:10:17 +00:00
|
|
|
break;
|
|
|
|
default: /* ignore junk */
|
|
|
|
fc_frame_free(fp);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ep)
|
|
|
|
fc_exch_release(ep); /* release hold taken by fc_exch_find */
|
|
|
|
}
|
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
/**
|
|
|
|
* fc_seq_ls_acc() - Accept sequence with LS_ACC
|
2010-07-20 22:21:12 +00:00
|
|
|
* @rx_fp: The received frame, not freed here.
|
2009-11-03 19:47:39 +00:00
|
|
|
*
|
2008-12-09 23:10:17 +00:00
|
|
|
* If this fails due to allocation or transmit congestion, assume the
|
|
|
|
* originator will repeat the sequence.
|
|
|
|
*/
|
2010-07-20 22:21:12 +00:00
|
|
|
static void fc_seq_ls_acc(struct fc_frame *rx_fp)
|
2008-12-09 23:10:17 +00:00
|
|
|
{
|
2010-07-20 22:21:12 +00:00
|
|
|
struct fc_lport *lport;
|
2008-12-09 23:10:17 +00:00
|
|
|
struct fc_els_ls_acc *acc;
|
|
|
|
struct fc_frame *fp;
|
2016-10-13 13:10:37 +00:00
|
|
|
struct fc_seq *sp;
|
2008-12-09 23:10:17 +00:00
|
|
|
|
2010-07-20 22:21:12 +00:00
|
|
|
lport = fr_dev(rx_fp);
|
2016-10-13 13:10:37 +00:00
|
|
|
sp = fr_seq(rx_fp);
|
2010-07-20 22:21:12 +00:00
|
|
|
fp = fc_frame_alloc(lport, sizeof(*acc));
|
2016-10-13 13:10:37 +00:00
|
|
|
if (!fp) {
|
|
|
|
FC_EXCH_DBG(fc_seq_exch(sp),
|
|
|
|
"exch: drop LS_ACC, out of memory\n");
|
2010-07-20 22:21:12 +00:00
|
|
|
return;
|
2016-10-13 13:10:37 +00:00
|
|
|
}
|
2010-07-20 22:21:12 +00:00
|
|
|
acc = fc_frame_payload_get(fp, sizeof(*acc));
|
|
|
|
memset(acc, 0, sizeof(*acc));
|
|
|
|
acc->la_cmd = ELS_LS_ACC;
|
|
|
|
fc_fill_reply_hdr(fp, rx_fp, FC_RCTL_ELS_REP, 0);
|
|
|
|
lport->tt.frame_send(lport, fp);
|
2008-12-09 23:10:17 +00:00
|
|
|
}
|
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
/**
|
|
|
|
* fc_seq_ls_rjt() - Reject a sequence with ELS LS_RJT
|
2010-07-20 22:21:12 +00:00
|
|
|
* @rx_fp: The received frame, not freed here.
|
2009-11-03 19:47:39 +00:00
|
|
|
* @reason: The reason the sequence is being rejected
|
2010-07-20 22:21:12 +00:00
|
|
|
* @explan: The explanation for the rejection
|
2009-11-03 19:47:39 +00:00
|
|
|
*
|
2008-12-09 23:10:17 +00:00
|
|
|
* If this fails due to allocation or transmit congestion, assume the
|
|
|
|
* originator will repeat the sequence.
|
|
|
|
*/
|
2010-07-20 22:21:12 +00:00
|
|
|
static void fc_seq_ls_rjt(struct fc_frame *rx_fp, enum fc_els_rjt_reason reason,
|
2008-12-09 23:10:17 +00:00
|
|
|
enum fc_els_rjt_explan explan)
|
|
|
|
{
|
2010-07-20 22:21:12 +00:00
|
|
|
struct fc_lport *lport;
|
2008-12-09 23:10:17 +00:00
|
|
|
struct fc_els_ls_rjt *rjt;
|
|
|
|
struct fc_frame *fp;
|
2016-10-13 13:10:37 +00:00
|
|
|
struct fc_seq *sp;
|
2008-12-09 23:10:17 +00:00
|
|
|
|
2010-07-20 22:21:12 +00:00
|
|
|
lport = fr_dev(rx_fp);
|
2016-10-13 13:10:37 +00:00
|
|
|
sp = fr_seq(rx_fp);
|
2010-07-20 22:21:12 +00:00
|
|
|
fp = fc_frame_alloc(lport, sizeof(*rjt));
|
2016-10-13 13:10:37 +00:00
|
|
|
if (!fp) {
|
|
|
|
FC_EXCH_DBG(fc_seq_exch(sp),
|
|
|
|
"exch: drop LS_ACC, out of memory\n");
|
2010-07-20 22:21:12 +00:00
|
|
|
return;
|
2016-10-13 13:10:37 +00:00
|
|
|
}
|
2010-07-20 22:21:12 +00:00
|
|
|
rjt = fc_frame_payload_get(fp, sizeof(*rjt));
|
|
|
|
memset(rjt, 0, sizeof(*rjt));
|
|
|
|
rjt->er_cmd = ELS_LS_RJT;
|
|
|
|
rjt->er_reason = reason;
|
|
|
|
rjt->er_explan = explan;
|
|
|
|
fc_fill_reply_hdr(fp, rx_fp, FC_RCTL_ELS_REP, 0);
|
|
|
|
lport->tt.frame_send(lport, fp);
|
2008-12-09 23:10:17 +00:00
|
|
|
}
|
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
/**
|
|
|
|
* fc_exch_reset() - Reset an exchange
|
|
|
|
* @ep: The exchange to be reset
|
2013-08-17 20:34:43 +00:00
|
|
|
*
|
|
|
|
* Note: May sleep if invoked from outside a response handler.
|
2009-11-03 19:47:39 +00:00
|
|
|
*/
|
2008-12-09 23:10:17 +00:00
|
|
|
static void fc_exch_reset(struct fc_exch *ep)
|
|
|
|
{
|
|
|
|
struct fc_seq *sp;
|
|
|
|
int rc = 1;
|
|
|
|
|
|
|
|
spin_lock_bh(&ep->ex_lock);
|
|
|
|
ep->state |= FC_EX_RST_CLEANUP;
|
2012-07-06 17:40:10 +00:00
|
|
|
fc_exch_timer_cancel(ep);
|
2008-12-09 23:10:17 +00:00
|
|
|
if (ep->esb_stat & ESB_ST_REC_QUAL)
|
|
|
|
atomic_dec(&ep->ex_refcnt); /* drop hold for rec_qual */
|
|
|
|
ep->esb_stat &= ~ESB_ST_REC_QUAL;
|
|
|
|
sp = &ep->seq;
|
|
|
|
rc = fc_exch_done_locked(ep);
|
|
|
|
spin_unlock_bh(&ep->ex_lock);
|
2013-08-17 20:34:43 +00:00
|
|
|
|
|
|
|
fc_exch_hold(ep);
|
|
|
|
|
2008-12-09 23:10:17 +00:00
|
|
|
if (!rc)
|
[SCSI] fcoe, libfc: fully makes use of per cpu exch pool and then removes em_lock
1. Updates fcoe_rcv() to queue incoming frames to the fcoe per
cpu thread on which this frame's exch was originated and simply
use current cpu for request exch not originated by initiator.
It is redundant to add this code under CONFIG_SMP, so removes
CONFIG_SMP uses around this code.
2. Updates fc_exch_em_alloc, fc_exch_delete, fc_exch_find to use
per cpu exch pools, here fc_exch_delete is rename of older
fc_exch_mgr_delete_ep since ep/exch are now deleted in pools
of EM and so brief new name is sufficient and better name.
Updates these functions to map exch id to their index into exch
pool using fc_cpu_mask, fc_cpu_order and EM min_xid.
This mapping is as per detailed explanation about this in
last patch and basically this is just as lower fc_cpu_mask
bits of exch id as cpu number and upper bit sum of EM min_xid
and exch index in pool.
Uses pool next_index to keep track of exch allocation from
pool along with pool_max_index as upper bound of exches array
in pool.
3. Adds exch pool ptr to fc_exch to free exch to its pool in
fc_exch_delete.
4. Updates fc_exch_mgr_reset to reset all exch pools of an EM,
this required adding fc_exch_pool_reset func to reset exches
in pool and then have fc_exch_mgr_reset call fc_exch_pool_reset
for each pool within each EM for a lport.
5. Removes no longer needed exches array, em_lock, next_xid, and
total_exches from struct fc_exch_mgr, these are not needed after
use of per cpu exch pool, also removes not used max_read,
last_read from struct fc_exch_mgr.
6. Updates locking notes for exch pool lock with fc_exch lock and
uses pool lock in exch allocation, lookup and reset.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:53 +00:00
|
|
|
fc_exch_delete(ep);
|
2008-12-09 23:10:17 +00:00
|
|
|
|
2013-08-17 20:34:43 +00:00
|
|
|
fc_invoke_resp(ep, sp, ERR_PTR(-FC_EX_CLOSED));
|
|
|
|
fc_seq_set_resp(sp, NULL, ep->arg);
|
|
|
|
fc_exch_release(ep);
|
2008-12-09 23:10:17 +00:00
|
|
|
}
|
|
|
|
|
[SCSI] fcoe, libfc: fully makes use of per cpu exch pool and then removes em_lock
1. Updates fcoe_rcv() to queue incoming frames to the fcoe per
cpu thread on which this frame's exch was originated and simply
use current cpu for request exch not originated by initiator.
It is redundant to add this code under CONFIG_SMP, so removes
CONFIG_SMP uses around this code.
2. Updates fc_exch_em_alloc, fc_exch_delete, fc_exch_find to use
per cpu exch pools, here fc_exch_delete is rename of older
fc_exch_mgr_delete_ep since ep/exch are now deleted in pools
of EM and so brief new name is sufficient and better name.
Updates these functions to map exch id to their index into exch
pool using fc_cpu_mask, fc_cpu_order and EM min_xid.
This mapping is as per detailed explanation about this in
last patch and basically this is just as lower fc_cpu_mask
bits of exch id as cpu number and upper bit sum of EM min_xid
and exch index in pool.
Uses pool next_index to keep track of exch allocation from
pool along with pool_max_index as upper bound of exches array
in pool.
3. Adds exch pool ptr to fc_exch to free exch to its pool in
fc_exch_delete.
4. Updates fc_exch_mgr_reset to reset all exch pools of an EM,
this required adding fc_exch_pool_reset func to reset exches
in pool and then have fc_exch_mgr_reset call fc_exch_pool_reset
for each pool within each EM for a lport.
5. Removes no longer needed exches array, em_lock, next_xid, and
total_exches from struct fc_exch_mgr, these are not needed after
use of per cpu exch pool, also removes not used max_read,
last_read from struct fc_exch_mgr.
6. Updates locking notes for exch pool lock with fc_exch lock and
uses pool lock in exch allocation, lookup and reset.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:53 +00:00
|
|
|
/**
|
2009-11-03 19:47:39 +00:00
|
|
|
* fc_exch_pool_reset() - Reset a per cpu exchange pool
|
|
|
|
* @lport: The local port that the exchange pool is on
|
|
|
|
* @pool: The exchange pool to be reset
|
|
|
|
* @sid: The source ID
|
|
|
|
* @did: The destination ID
|
[SCSI] fcoe, libfc: fully makes use of per cpu exch pool and then removes em_lock
1. Updates fcoe_rcv() to queue incoming frames to the fcoe per
cpu thread on which this frame's exch was originated and simply
use current cpu for request exch not originated by initiator.
It is redundant to add this code under CONFIG_SMP, so removes
CONFIG_SMP uses around this code.
2. Updates fc_exch_em_alloc, fc_exch_delete, fc_exch_find to use
per cpu exch pools, here fc_exch_delete is rename of older
fc_exch_mgr_delete_ep since ep/exch are now deleted in pools
of EM and so brief new name is sufficient and better name.
Updates these functions to map exch id to their index into exch
pool using fc_cpu_mask, fc_cpu_order and EM min_xid.
This mapping is as per detailed explanation about this in
last patch and basically this is just as lower fc_cpu_mask
bits of exch id as cpu number and upper bit sum of EM min_xid
and exch index in pool.
Uses pool next_index to keep track of exch allocation from
pool along with pool_max_index as upper bound of exches array
in pool.
3. Adds exch pool ptr to fc_exch to free exch to its pool in
fc_exch_delete.
4. Updates fc_exch_mgr_reset to reset all exch pools of an EM,
this required adding fc_exch_pool_reset func to reset exches
in pool and then have fc_exch_mgr_reset call fc_exch_pool_reset
for each pool within each EM for a lport.
5. Removes no longer needed exches array, em_lock, next_xid, and
total_exches from struct fc_exch_mgr, these are not needed after
use of per cpu exch pool, also removes not used max_read,
last_read from struct fc_exch_mgr.
6. Updates locking notes for exch pool lock with fc_exch lock and
uses pool lock in exch allocation, lookup and reset.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:53 +00:00
|
|
|
*
|
2009-11-03 19:47:39 +00:00
|
|
|
* Resets a per cpu exches pool, releasing all of its sequences
|
|
|
|
* and exchanges. If sid is non-zero then reset only exchanges
|
|
|
|
* we sourced from the local port's FID. If did is non-zero then
|
|
|
|
* only reset exchanges destined for the local port's FID.
|
2008-12-09 23:10:17 +00:00
|
|
|
*/
|
[SCSI] fcoe, libfc: fully makes use of per cpu exch pool and then removes em_lock
1. Updates fcoe_rcv() to queue incoming frames to the fcoe per
cpu thread on which this frame's exch was originated and simply
use current cpu for request exch not originated by initiator.
It is redundant to add this code under CONFIG_SMP, so removes
CONFIG_SMP uses around this code.
2. Updates fc_exch_em_alloc, fc_exch_delete, fc_exch_find to use
per cpu exch pools, here fc_exch_delete is rename of older
fc_exch_mgr_delete_ep since ep/exch are now deleted in pools
of EM and so brief new name is sufficient and better name.
Updates these functions to map exch id to their index into exch
pool using fc_cpu_mask, fc_cpu_order and EM min_xid.
This mapping is as per detailed explanation about this in
last patch and basically this is just as lower fc_cpu_mask
bits of exch id as cpu number and upper bit sum of EM min_xid
and exch index in pool.
Uses pool next_index to keep track of exch allocation from
pool along with pool_max_index as upper bound of exches array
in pool.
3. Adds exch pool ptr to fc_exch to free exch to its pool in
fc_exch_delete.
4. Updates fc_exch_mgr_reset to reset all exch pools of an EM,
this required adding fc_exch_pool_reset func to reset exches
in pool and then have fc_exch_mgr_reset call fc_exch_pool_reset
for each pool within each EM for a lport.
5. Removes no longer needed exches array, em_lock, next_xid, and
total_exches from struct fc_exch_mgr, these are not needed after
use of per cpu exch pool, also removes not used max_read,
last_read from struct fc_exch_mgr.
6. Updates locking notes for exch pool lock with fc_exch lock and
uses pool lock in exch allocation, lookup and reset.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:53 +00:00
|
|
|
static void fc_exch_pool_reset(struct fc_lport *lport,
|
|
|
|
struct fc_exch_pool *pool,
|
|
|
|
u32 sid, u32 did)
|
2008-12-09 23:10:17 +00:00
|
|
|
{
|
|
|
|
struct fc_exch *ep;
|
|
|
|
struct fc_exch *next;
|
|
|
|
|
[SCSI] fcoe, libfc: fully makes use of per cpu exch pool and then removes em_lock
1. Updates fcoe_rcv() to queue incoming frames to the fcoe per
cpu thread on which this frame's exch was originated and simply
use current cpu for request exch not originated by initiator.
It is redundant to add this code under CONFIG_SMP, so removes
CONFIG_SMP uses around this code.
2. Updates fc_exch_em_alloc, fc_exch_delete, fc_exch_find to use
per cpu exch pools, here fc_exch_delete is rename of older
fc_exch_mgr_delete_ep since ep/exch are now deleted in pools
of EM and so brief new name is sufficient and better name.
Updates these functions to map exch id to their index into exch
pool using fc_cpu_mask, fc_cpu_order and EM min_xid.
This mapping is as per detailed explanation about this in
last patch and basically this is just as lower fc_cpu_mask
bits of exch id as cpu number and upper bit sum of EM min_xid
and exch index in pool.
Uses pool next_index to keep track of exch allocation from
pool along with pool_max_index as upper bound of exches array
in pool.
3. Adds exch pool ptr to fc_exch to free exch to its pool in
fc_exch_delete.
4. Updates fc_exch_mgr_reset to reset all exch pools of an EM,
this required adding fc_exch_pool_reset func to reset exches
in pool and then have fc_exch_mgr_reset call fc_exch_pool_reset
for each pool within each EM for a lport.
5. Removes no longer needed exches array, em_lock, next_xid, and
total_exches from struct fc_exch_mgr, these are not needed after
use of per cpu exch pool, also removes not used max_read,
last_read from struct fc_exch_mgr.
6. Updates locking notes for exch pool lock with fc_exch lock and
uses pool lock in exch allocation, lookup and reset.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:53 +00:00
|
|
|
spin_lock_bh(&pool->lock);
|
2008-12-09 23:10:17 +00:00
|
|
|
restart:
|
[SCSI] fcoe, libfc: fully makes use of per cpu exch pool and then removes em_lock
1. Updates fcoe_rcv() to queue incoming frames to the fcoe per
cpu thread on which this frame's exch was originated and simply
use current cpu for request exch not originated by initiator.
It is redundant to add this code under CONFIG_SMP, so removes
CONFIG_SMP uses around this code.
2. Updates fc_exch_em_alloc, fc_exch_delete, fc_exch_find to use
per cpu exch pools, here fc_exch_delete is rename of older
fc_exch_mgr_delete_ep since ep/exch are now deleted in pools
of EM and so brief new name is sufficient and better name.
Updates these functions to map exch id to their index into exch
pool using fc_cpu_mask, fc_cpu_order and EM min_xid.
This mapping is as per detailed explanation about this in
last patch and basically this is just as lower fc_cpu_mask
bits of exch id as cpu number and upper bit sum of EM min_xid
and exch index in pool.
Uses pool next_index to keep track of exch allocation from
pool along with pool_max_index as upper bound of exches array
in pool.
3. Adds exch pool ptr to fc_exch to free exch to its pool in
fc_exch_delete.
4. Updates fc_exch_mgr_reset to reset all exch pools of an EM,
this required adding fc_exch_pool_reset func to reset exches
in pool and then have fc_exch_mgr_reset call fc_exch_pool_reset
for each pool within each EM for a lport.
5. Removes no longer needed exches array, em_lock, next_xid, and
total_exches from struct fc_exch_mgr, these are not needed after
use of per cpu exch pool, also removes not used max_read,
last_read from struct fc_exch_mgr.
6. Updates locking notes for exch pool lock with fc_exch lock and
uses pool lock in exch allocation, lookup and reset.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:53 +00:00
|
|
|
list_for_each_entry_safe(ep, next, &pool->ex_list, ex_list) {
|
|
|
|
if ((lport == ep->lp) &&
|
|
|
|
(sid == 0 || sid == ep->sid) &&
|
|
|
|
(did == 0 || did == ep->did)) {
|
|
|
|
fc_exch_hold(ep);
|
|
|
|
spin_unlock_bh(&pool->lock);
|
|
|
|
|
|
|
|
fc_exch_reset(ep);
|
|
|
|
|
|
|
|
fc_exch_release(ep);
|
|
|
|
spin_lock_bh(&pool->lock);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* must restart loop incase while lock
|
|
|
|
* was down multiple eps were released.
|
|
|
|
*/
|
|
|
|
goto restart;
|
2008-12-09 23:10:17 +00:00
|
|
|
}
|
[SCSI] fcoe, libfc: fully makes use of per cpu exch pool and then removes em_lock
1. Updates fcoe_rcv() to queue incoming frames to the fcoe per
cpu thread on which this frame's exch was originated and simply
use current cpu for request exch not originated by initiator.
It is redundant to add this code under CONFIG_SMP, so removes
CONFIG_SMP uses around this code.
2. Updates fc_exch_em_alloc, fc_exch_delete, fc_exch_find to use
per cpu exch pools, here fc_exch_delete is rename of older
fc_exch_mgr_delete_ep since ep/exch are now deleted in pools
of EM and so brief new name is sufficient and better name.
Updates these functions to map exch id to their index into exch
pool using fc_cpu_mask, fc_cpu_order and EM min_xid.
This mapping is as per detailed explanation about this in
last patch and basically this is just as lower fc_cpu_mask
bits of exch id as cpu number and upper bit sum of EM min_xid
and exch index in pool.
Uses pool next_index to keep track of exch allocation from
pool along with pool_max_index as upper bound of exches array
in pool.
3. Adds exch pool ptr to fc_exch to free exch to its pool in
fc_exch_delete.
4. Updates fc_exch_mgr_reset to reset all exch pools of an EM,
this required adding fc_exch_pool_reset func to reset exches
in pool and then have fc_exch_mgr_reset call fc_exch_pool_reset
for each pool within each EM for a lport.
5. Removes no longer needed exches array, em_lock, next_xid, and
total_exches from struct fc_exch_mgr, these are not needed after
use of per cpu exch pool, also removes not used max_read,
last_read from struct fc_exch_mgr.
6. Updates locking notes for exch pool lock with fc_exch lock and
uses pool lock in exch allocation, lookup and reset.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:53 +00:00
|
|
|
}
|
2011-10-28 18:34:17 +00:00
|
|
|
pool->next_index = 0;
|
|
|
|
pool->left = FC_XID_UNKNOWN;
|
|
|
|
pool->right = FC_XID_UNKNOWN;
|
[SCSI] fcoe, libfc: fully makes use of per cpu exch pool and then removes em_lock
1. Updates fcoe_rcv() to queue incoming frames to the fcoe per
cpu thread on which this frame's exch was originated and simply
use current cpu for request exch not originated by initiator.
It is redundant to add this code under CONFIG_SMP, so removes
CONFIG_SMP uses around this code.
2. Updates fc_exch_em_alloc, fc_exch_delete, fc_exch_find to use
per cpu exch pools, here fc_exch_delete is rename of older
fc_exch_mgr_delete_ep since ep/exch are now deleted in pools
of EM and so brief new name is sufficient and better name.
Updates these functions to map exch id to their index into exch
pool using fc_cpu_mask, fc_cpu_order and EM min_xid.
This mapping is as per detailed explanation about this in
last patch and basically this is just as lower fc_cpu_mask
bits of exch id as cpu number and upper bit sum of EM min_xid
and exch index in pool.
Uses pool next_index to keep track of exch allocation from
pool along with pool_max_index as upper bound of exches array
in pool.
3. Adds exch pool ptr to fc_exch to free exch to its pool in
fc_exch_delete.
4. Updates fc_exch_mgr_reset to reset all exch pools of an EM,
this required adding fc_exch_pool_reset func to reset exches
in pool and then have fc_exch_mgr_reset call fc_exch_pool_reset
for each pool within each EM for a lport.
5. Removes no longer needed exches array, em_lock, next_xid, and
total_exches from struct fc_exch_mgr, these are not needed after
use of per cpu exch pool, also removes not used max_read,
last_read from struct fc_exch_mgr.
6. Updates locking notes for exch pool lock with fc_exch lock and
uses pool lock in exch allocation, lookup and reset.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:53 +00:00
|
|
|
spin_unlock_bh(&pool->lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-11-03 19:47:39 +00:00
|
|
|
* fc_exch_mgr_reset() - Reset all EMs of a local port
|
|
|
|
* @lport: The local port whose EMs are to be reset
|
|
|
|
* @sid: The source ID
|
|
|
|
* @did: The destination ID
|
[SCSI] fcoe, libfc: fully makes use of per cpu exch pool and then removes em_lock
1. Updates fcoe_rcv() to queue incoming frames to the fcoe per
cpu thread on which this frame's exch was originated and simply
use current cpu for request exch not originated by initiator.
It is redundant to add this code under CONFIG_SMP, so removes
CONFIG_SMP uses around this code.
2. Updates fc_exch_em_alloc, fc_exch_delete, fc_exch_find to use
per cpu exch pools, here fc_exch_delete is rename of older
fc_exch_mgr_delete_ep since ep/exch are now deleted in pools
of EM and so brief new name is sufficient and better name.
Updates these functions to map exch id to their index into exch
pool using fc_cpu_mask, fc_cpu_order and EM min_xid.
This mapping is as per detailed explanation about this in
last patch and basically this is just as lower fc_cpu_mask
bits of exch id as cpu number and upper bit sum of EM min_xid
and exch index in pool.
Uses pool next_index to keep track of exch allocation from
pool along with pool_max_index as upper bound of exches array
in pool.
3. Adds exch pool ptr to fc_exch to free exch to its pool in
fc_exch_delete.
4. Updates fc_exch_mgr_reset to reset all exch pools of an EM,
this required adding fc_exch_pool_reset func to reset exches
in pool and then have fc_exch_mgr_reset call fc_exch_pool_reset
for each pool within each EM for a lport.
5. Removes no longer needed exches array, em_lock, next_xid, and
total_exches from struct fc_exch_mgr, these are not needed after
use of per cpu exch pool, also removes not used max_read,
last_read from struct fc_exch_mgr.
6. Updates locking notes for exch pool lock with fc_exch lock and
uses pool lock in exch allocation, lookup and reset.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:53 +00:00
|
|
|
*
|
2009-11-03 19:47:39 +00:00
|
|
|
* Reset all EMs associated with a given local port. Release all
|
|
|
|
* sequences and exchanges. If sid is non-zero then reset only the
|
|
|
|
* exchanges sent from the local port's FID. If did is non-zero then
|
|
|
|
* reset only exchanges destined for the local port's FID.
|
[SCSI] fcoe, libfc: fully makes use of per cpu exch pool and then removes em_lock
1. Updates fcoe_rcv() to queue incoming frames to the fcoe per
cpu thread on which this frame's exch was originated and simply
use current cpu for request exch not originated by initiator.
It is redundant to add this code under CONFIG_SMP, so removes
CONFIG_SMP uses around this code.
2. Updates fc_exch_em_alloc, fc_exch_delete, fc_exch_find to use
per cpu exch pools, here fc_exch_delete is rename of older
fc_exch_mgr_delete_ep since ep/exch are now deleted in pools
of EM and so brief new name is sufficient and better name.
Updates these functions to map exch id to their index into exch
pool using fc_cpu_mask, fc_cpu_order and EM min_xid.
This mapping is as per detailed explanation about this in
last patch and basically this is just as lower fc_cpu_mask
bits of exch id as cpu number and upper bit sum of EM min_xid
and exch index in pool.
Uses pool next_index to keep track of exch allocation from
pool along with pool_max_index as upper bound of exches array
in pool.
3. Adds exch pool ptr to fc_exch to free exch to its pool in
fc_exch_delete.
4. Updates fc_exch_mgr_reset to reset all exch pools of an EM,
this required adding fc_exch_pool_reset func to reset exches
in pool and then have fc_exch_mgr_reset call fc_exch_pool_reset
for each pool within each EM for a lport.
5. Removes no longer needed exches array, em_lock, next_xid, and
total_exches from struct fc_exch_mgr, these are not needed after
use of per cpu exch pool, also removes not used max_read,
last_read from struct fc_exch_mgr.
6. Updates locking notes for exch pool lock with fc_exch lock and
uses pool lock in exch allocation, lookup and reset.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:53 +00:00
|
|
|
*/
|
|
|
|
void fc_exch_mgr_reset(struct fc_lport *lport, u32 sid, u32 did)
|
|
|
|
{
|
|
|
|
struct fc_exch_mgr_anchor *ema;
|
|
|
|
unsigned int cpu;
|
|
|
|
|
|
|
|
list_for_each_entry(ema, &lport->ema_list, ema_list) {
|
|
|
|
for_each_possible_cpu(cpu)
|
|
|
|
fc_exch_pool_reset(lport,
|
|
|
|
per_cpu_ptr(ema->mp->pool, cpu),
|
|
|
|
sid, did);
|
2008-12-09 23:10:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(fc_exch_mgr_reset);
|
|
|
|
|
2010-07-20 22:21:12 +00:00
|
|
|
/**
|
|
|
|
* fc_exch_lookup() - find an exchange
|
|
|
|
* @lport: The local port
|
|
|
|
* @xid: The exchange ID
|
|
|
|
*
|
|
|
|
* Returns exchange pointer with hold for caller, or NULL if not found.
|
|
|
|
*/
|
|
|
|
static struct fc_exch *fc_exch_lookup(struct fc_lport *lport, u32 xid)
|
|
|
|
{
|
|
|
|
struct fc_exch_mgr_anchor *ema;
|
|
|
|
|
|
|
|
list_for_each_entry(ema, &lport->ema_list, ema_list)
|
|
|
|
if (ema->mp->min_xid <= xid && xid <= ema->mp->max_xid)
|
|
|
|
return fc_exch_find(ema->mp, xid);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
/**
|
|
|
|
* fc_exch_els_rec() - Handler for ELS REC (Read Exchange Concise) requests
|
2010-07-20 22:21:12 +00:00
|
|
|
* @rfp: The REC frame, not freed here.
|
2009-11-03 19:47:39 +00:00
|
|
|
*
|
2008-12-09 23:10:17 +00:00
|
|
|
* Note that the requesting port may be different than the S_ID in the request.
|
|
|
|
*/
|
2010-07-20 22:21:12 +00:00
|
|
|
static void fc_exch_els_rec(struct fc_frame *rfp)
|
2008-12-09 23:10:17 +00:00
|
|
|
{
|
2010-07-20 22:21:12 +00:00
|
|
|
struct fc_lport *lport;
|
2008-12-09 23:10:17 +00:00
|
|
|
struct fc_frame *fp;
|
|
|
|
struct fc_exch *ep;
|
|
|
|
struct fc_els_rec *rp;
|
|
|
|
struct fc_els_rec_acc *acc;
|
|
|
|
enum fc_els_rjt_reason reason = ELS_RJT_LOGIC;
|
|
|
|
enum fc_els_rjt_explan explan;
|
|
|
|
u32 sid;
|
2016-10-13 13:10:55 +00:00
|
|
|
u16 xid, rxid, oxid;
|
2008-12-09 23:10:17 +00:00
|
|
|
|
2010-07-20 22:21:12 +00:00
|
|
|
lport = fr_dev(rfp);
|
2008-12-09 23:10:17 +00:00
|
|
|
rp = fc_frame_payload_get(rfp, sizeof(*rp));
|
|
|
|
explan = ELS_EXPL_INV_LEN;
|
|
|
|
if (!rp)
|
|
|
|
goto reject;
|
|
|
|
sid = ntoh24(rp->rec_s_id);
|
|
|
|
rxid = ntohs(rp->rec_rx_id);
|
|
|
|
oxid = ntohs(rp->rec_ox_id);
|
|
|
|
|
|
|
|
explan = ELS_EXPL_OXID_RXID;
|
2016-10-13 13:10:55 +00:00
|
|
|
if (sid == fc_host_port_id(lport->host))
|
|
|
|
xid = oxid;
|
|
|
|
else
|
|
|
|
xid = rxid;
|
|
|
|
if (xid == FC_XID_UNKNOWN) {
|
|
|
|
FC_LPORT_DBG(lport,
|
|
|
|
"REC request from %x: invalid rxid %x oxid %x\n",
|
|
|
|
sid, rxid, oxid);
|
|
|
|
goto reject;
|
|
|
|
}
|
|
|
|
ep = fc_exch_lookup(lport, xid);
|
2016-10-13 13:10:37 +00:00
|
|
|
if (!ep) {
|
|
|
|
FC_LPORT_DBG(lport,
|
|
|
|
"REC request from %x: rxid %x oxid %x not found\n",
|
|
|
|
sid, rxid, oxid);
|
2010-07-20 22:21:12 +00:00
|
|
|
goto reject;
|
2016-10-13 13:10:37 +00:00
|
|
|
}
|
|
|
|
FC_EXCH_DBG(ep, "REC request from %x: rxid %x oxid %x\n",
|
|
|
|
sid, rxid, oxid);
|
2010-07-20 22:21:12 +00:00
|
|
|
if (ep->oid != sid || oxid != ep->oxid)
|
|
|
|
goto rel;
|
|
|
|
if (rxid != FC_XID_UNKNOWN && rxid != ep->rxid)
|
|
|
|
goto rel;
|
|
|
|
fp = fc_frame_alloc(lport, sizeof(*acc));
|
2016-10-13 13:10:37 +00:00
|
|
|
if (!fp) {
|
|
|
|
FC_EXCH_DBG(ep, "Drop REC request, out of memory\n");
|
2008-12-09 23:10:17 +00:00
|
|
|
goto out;
|
2016-10-13 13:10:37 +00:00
|
|
|
}
|
2010-07-20 22:21:12 +00:00
|
|
|
|
2008-12-09 23:10:17 +00:00
|
|
|
acc = fc_frame_payload_get(fp, sizeof(*acc));
|
|
|
|
memset(acc, 0, sizeof(*acc));
|
|
|
|
acc->reca_cmd = ELS_LS_ACC;
|
|
|
|
acc->reca_ox_id = rp->rec_ox_id;
|
|
|
|
memcpy(acc->reca_ofid, rp->rec_s_id, 3);
|
|
|
|
acc->reca_rx_id = htons(ep->rxid);
|
|
|
|
if (ep->sid == ep->oid)
|
|
|
|
hton24(acc->reca_rfid, ep->did);
|
|
|
|
else
|
|
|
|
hton24(acc->reca_rfid, ep->sid);
|
|
|
|
acc->reca_fc4value = htonl(ep->seq.rec_data);
|
|
|
|
acc->reca_e_stat = htonl(ep->esb_stat & (ESB_ST_RESP |
|
|
|
|
ESB_ST_SEQ_INIT |
|
|
|
|
ESB_ST_COMPLETE));
|
2010-07-20 22:21:12 +00:00
|
|
|
fc_fill_reply_hdr(fp, rfp, FC_RCTL_ELS_REP, 0);
|
|
|
|
lport->tt.frame_send(lport, fp);
|
2008-12-09 23:10:17 +00:00
|
|
|
out:
|
|
|
|
fc_exch_release(ep);
|
|
|
|
return;
|
|
|
|
|
|
|
|
rel:
|
|
|
|
fc_exch_release(ep);
|
|
|
|
reject:
|
2010-07-20 22:21:12 +00:00
|
|
|
fc_seq_ls_rjt(rfp, reason, explan);
|
2008-12-09 23:10:17 +00:00
|
|
|
}
|
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
/**
|
|
|
|
* fc_exch_rrq_resp() - Handler for RRQ responses
|
|
|
|
* @sp: The sequence that the RRQ is on
|
|
|
|
* @fp: The RRQ frame
|
|
|
|
* @arg: The exchange that the RRQ is on
|
2008-12-09 23:10:17 +00:00
|
|
|
*
|
|
|
|
* TODO: fix error handler.
|
|
|
|
*/
|
|
|
|
static void fc_exch_rrq_resp(struct fc_seq *sp, struct fc_frame *fp, void *arg)
|
|
|
|
{
|
|
|
|
struct fc_exch *aborted_ep = arg;
|
|
|
|
unsigned int op;
|
|
|
|
|
|
|
|
if (IS_ERR(fp)) {
|
|
|
|
int err = PTR_ERR(fp);
|
|
|
|
|
2009-02-27 18:54:46 +00:00
|
|
|
if (err == -FC_EX_CLOSED || err == -FC_EX_TIMEOUT)
|
2008-12-09 23:10:17 +00:00
|
|
|
goto cleanup;
|
2009-06-10 22:31:10 +00:00
|
|
|
FC_EXCH_DBG(aborted_ep, "Cannot process RRQ, "
|
|
|
|
"frame error %d\n", err);
|
2008-12-09 23:10:17 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
op = fc_frame_payload_op(fp);
|
|
|
|
fc_frame_free(fp);
|
|
|
|
|
|
|
|
switch (op) {
|
|
|
|
case ELS_LS_RJT:
|
2013-08-14 15:32:51 +00:00
|
|
|
FC_EXCH_DBG(aborted_ep, "LS_RJT for RRQ\n");
|
2008-12-09 23:10:17 +00:00
|
|
|
/* fall through */
|
|
|
|
case ELS_LS_ACC:
|
|
|
|
goto cleanup;
|
|
|
|
default:
|
2013-08-14 15:32:51 +00:00
|
|
|
FC_EXCH_DBG(aborted_ep, "unexpected response op %x for RRQ\n",
|
|
|
|
op);
|
2008-12-09 23:10:17 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
fc_exch_done(&aborted_ep->seq);
|
|
|
|
/* drop hold for rec qual */
|
|
|
|
fc_exch_release(aborted_ep);
|
|
|
|
}
|
|
|
|
|
2009-11-03 19:45:47 +00:00
|
|
|
|
|
|
|
/**
|
2009-11-03 19:47:39 +00:00
|
|
|
* fc_exch_seq_send() - Send a frame using a new exchange and sequence
|
|
|
|
* @lport: The local port to send the frame on
|
|
|
|
* @fp: The frame to be sent
|
|
|
|
* @resp: The response handler for this request
|
|
|
|
* @destructor: The destructor for the exchange
|
|
|
|
* @arg: The argument to be passed to the response handler
|
|
|
|
* @timer_msec: The timeout period for the exchange
|
|
|
|
*
|
2016-10-18 08:01:38 +00:00
|
|
|
* The exchange response handler is set in this routine to resp()
|
|
|
|
* function pointer. It can be called in two scenarios: if a timeout
|
|
|
|
* occurs or if a response frame is received for the exchange. The
|
|
|
|
* fc_frame pointer in response handler will also indicate timeout
|
|
|
|
* as error using IS_ERR related macros.
|
|
|
|
*
|
|
|
|
* The exchange destructor handler is also set in this routine.
|
|
|
|
* The destructor handler is invoked by EM layer when exchange
|
|
|
|
* is about to free, this can be used by caller to free its
|
|
|
|
* resources along with exchange free.
|
|
|
|
*
|
|
|
|
* The arg is passed back to resp and destructor handler.
|
|
|
|
*
|
|
|
|
* The timeout value (in msec) for an exchange is set if non zero
|
|
|
|
* timer_msec argument is specified. The timer is canceled when
|
|
|
|
* it fires or when the exchange is done. The exchange timeout handler
|
|
|
|
* is registered by EM layer.
|
|
|
|
*
|
2009-11-03 19:47:39 +00:00
|
|
|
* The frame pointer with some of the header's fields must be
|
|
|
|
* filled before calling this routine, those fields are:
|
|
|
|
*
|
|
|
|
* - routing control
|
|
|
|
* - FC port did
|
|
|
|
* - FC port sid
|
|
|
|
* - FC header type
|
|
|
|
* - frame control
|
|
|
|
* - parameter or relative offset
|
2009-11-03 19:45:47 +00:00
|
|
|
*/
|
2016-10-18 08:01:38 +00:00
|
|
|
struct fc_seq *fc_exch_seq_send(struct fc_lport *lport,
|
|
|
|
struct fc_frame *fp,
|
|
|
|
void (*resp)(struct fc_seq *,
|
|
|
|
struct fc_frame *fp,
|
|
|
|
void *arg),
|
|
|
|
void (*destructor)(struct fc_seq *, void *),
|
|
|
|
void *arg, u32 timer_msec)
|
2009-11-03 19:45:47 +00:00
|
|
|
{
|
|
|
|
struct fc_exch *ep;
|
|
|
|
struct fc_seq *sp = NULL;
|
|
|
|
struct fc_frame_header *fh;
|
2011-08-25 19:41:03 +00:00
|
|
|
struct fc_fcp_pkt *fsp = NULL;
|
2009-11-03 19:45:47 +00:00
|
|
|
int rc = 1;
|
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
ep = fc_exch_alloc(lport, fp);
|
2009-11-03 19:45:47 +00:00
|
|
|
if (!ep) {
|
|
|
|
fc_frame_free(fp);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
ep->esb_stat |= ESB_ST_SEQ_INIT;
|
|
|
|
fh = fc_frame_header_get(fp);
|
|
|
|
fc_exch_set_addr(ep, ntoh24(fh->fh_s_id), ntoh24(fh->fh_d_id));
|
|
|
|
ep->resp = resp;
|
|
|
|
ep->destructor = destructor;
|
|
|
|
ep->arg = arg;
|
2016-10-13 13:10:39 +00:00
|
|
|
ep->r_a_tov = lport->r_a_tov;
|
2009-11-03 19:47:39 +00:00
|
|
|
ep->lp = lport;
|
2009-11-03 19:45:47 +00:00
|
|
|
sp = &ep->seq;
|
|
|
|
|
|
|
|
ep->fh_type = fh->fh_type; /* save for possbile timeout handling */
|
|
|
|
ep->f_ctl = ntoh24(fh->fh_f_ctl);
|
|
|
|
fc_exch_setup_hdr(ep, fp, ep->f_ctl);
|
|
|
|
sp->cnt++;
|
|
|
|
|
2011-08-25 19:41:03 +00:00
|
|
|
if (ep->xid <= lport->lro_xid && fh->fh_r_ctl == FC_RCTL_DD_UNSOL_CMD) {
|
|
|
|
fsp = fr_fsp(fp);
|
2009-11-03 19:45:47 +00:00
|
|
|
fc_fcp_ddp_setup(fr_fsp(fp), ep->xid);
|
2011-08-25 19:41:03 +00:00
|
|
|
}
|
2009-11-03 19:45:47 +00:00
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
if (unlikely(lport->tt.frame_send(lport, fp)))
|
2009-11-03 19:45:47 +00:00
|
|
|
goto err;
|
|
|
|
|
|
|
|
if (timer_msec)
|
|
|
|
fc_exch_timer_set_locked(ep, timer_msec);
|
|
|
|
ep->f_ctl &= ~FC_FC_FIRST_SEQ; /* not first seq */
|
|
|
|
|
|
|
|
if (ep->f_ctl & FC_FC_SEQ_INIT)
|
|
|
|
ep->esb_stat &= ~ESB_ST_SEQ_INIT;
|
|
|
|
spin_unlock_bh(&ep->ex_lock);
|
|
|
|
return sp;
|
|
|
|
err:
|
2011-08-25 19:41:03 +00:00
|
|
|
if (fsp)
|
|
|
|
fc_fcp_ddp_done(fsp);
|
2009-11-03 19:45:47 +00:00
|
|
|
rc = fc_exch_done_locked(ep);
|
|
|
|
spin_unlock_bh(&ep->ex_lock);
|
|
|
|
if (!rc)
|
|
|
|
fc_exch_delete(ep);
|
|
|
|
return NULL;
|
|
|
|
}
|
2016-10-18 08:01:38 +00:00
|
|
|
EXPORT_SYMBOL(fc_exch_seq_send);
|
2009-11-03 19:45:47 +00:00
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
/**
|
|
|
|
* fc_exch_rrq() - Send an ELS RRQ (Reinstate Recovery Qualifier) command
|
|
|
|
* @ep: The exchange to send the RRQ on
|
|
|
|
*
|
2008-12-09 23:10:17 +00:00
|
|
|
* This tells the remote port to stop blocking the use of
|
|
|
|
* the exchange and the seq_cnt range.
|
|
|
|
*/
|
|
|
|
static void fc_exch_rrq(struct fc_exch *ep)
|
|
|
|
{
|
2009-11-03 19:47:39 +00:00
|
|
|
struct fc_lport *lport;
|
2008-12-09 23:10:17 +00:00
|
|
|
struct fc_els_rrq *rrq;
|
|
|
|
struct fc_frame *fp;
|
|
|
|
u32 did;
|
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
lport = ep->lp;
|
2008-12-09 23:10:17 +00:00
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
fp = fc_frame_alloc(lport, sizeof(*rrq));
|
2008-12-09 23:10:17 +00:00
|
|
|
if (!fp)
|
2009-07-29 00:33:37 +00:00
|
|
|
goto retry;
|
|
|
|
|
2008-12-09 23:10:17 +00:00
|
|
|
rrq = fc_frame_payload_get(fp, sizeof(*rrq));
|
|
|
|
memset(rrq, 0, sizeof(*rrq));
|
|
|
|
rrq->rrq_cmd = ELS_RRQ;
|
|
|
|
hton24(rrq->rrq_s_id, ep->sid);
|
|
|
|
rrq->rrq_ox_id = htons(ep->oxid);
|
|
|
|
rrq->rrq_rx_id = htons(ep->rxid);
|
|
|
|
|
|
|
|
did = ep->did;
|
|
|
|
if (ep->esb_stat & ESB_ST_RESP)
|
|
|
|
did = ep->sid;
|
|
|
|
|
|
|
|
fc_fill_fc_hdr(fp, FC_RCTL_ELS_REQ, did,
|
2010-05-07 22:18:41 +00:00
|
|
|
lport->port_id, FC_TYPE_ELS,
|
2008-12-09 23:10:17 +00:00
|
|
|
FC_FC_FIRST_SEQ | FC_FC_END_SEQ | FC_FC_SEQ_INIT, 0);
|
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
if (fc_exch_seq_send(lport, fp, fc_exch_rrq_resp, NULL, ep,
|
|
|
|
lport->e_d_tov))
|
2009-07-29 00:33:37 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
retry:
|
2016-10-13 13:10:37 +00:00
|
|
|
FC_EXCH_DBG(ep, "exch: RRQ send failed\n");
|
2009-07-29 00:33:37 +00:00
|
|
|
spin_lock_bh(&ep->ex_lock);
|
|
|
|
if (ep->state & (FC_EX_RST_CLEANUP | FC_EX_DONE)) {
|
|
|
|
spin_unlock_bh(&ep->ex_lock);
|
|
|
|
/* drop hold for rec qual */
|
|
|
|
fc_exch_release(ep);
|
2008-12-09 23:10:17 +00:00
|
|
|
return;
|
|
|
|
}
|
2009-07-29 00:33:37 +00:00
|
|
|
ep->esb_stat |= ESB_ST_REC_QUAL;
|
|
|
|
fc_exch_timer_set_locked(ep, ep->r_a_tov);
|
|
|
|
spin_unlock_bh(&ep->ex_lock);
|
2008-12-09 23:10:17 +00:00
|
|
|
}
|
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
/**
|
|
|
|
* fc_exch_els_rrq() - Handler for ELS RRQ (Reset Recovery Qualifier) requests
|
2010-07-20 22:21:12 +00:00
|
|
|
* @fp: The RRQ frame, not freed here.
|
2008-12-09 23:10:17 +00:00
|
|
|
*/
|
2010-07-20 22:21:12 +00:00
|
|
|
static void fc_exch_els_rrq(struct fc_frame *fp)
|
2008-12-09 23:10:17 +00:00
|
|
|
{
|
2010-07-20 22:21:12 +00:00
|
|
|
struct fc_lport *lport;
|
2009-10-21 23:27:33 +00:00
|
|
|
struct fc_exch *ep = NULL; /* request or subject exchange */
|
2008-12-09 23:10:17 +00:00
|
|
|
struct fc_els_rrq *rp;
|
|
|
|
u32 sid;
|
|
|
|
u16 xid;
|
|
|
|
enum fc_els_rjt_explan explan;
|
|
|
|
|
2010-07-20 22:21:12 +00:00
|
|
|
lport = fr_dev(fp);
|
2008-12-09 23:10:17 +00:00
|
|
|
rp = fc_frame_payload_get(fp, sizeof(*rp));
|
|
|
|
explan = ELS_EXPL_INV_LEN;
|
|
|
|
if (!rp)
|
|
|
|
goto reject;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* lookup subject exchange.
|
|
|
|
*/
|
|
|
|
sid = ntoh24(rp->rrq_s_id); /* subject source */
|
2010-07-20 22:21:12 +00:00
|
|
|
xid = fc_host_port_id(lport->host) == sid ?
|
|
|
|
ntohs(rp->rrq_ox_id) : ntohs(rp->rrq_rx_id);
|
|
|
|
ep = fc_exch_lookup(lport, xid);
|
2008-12-09 23:10:17 +00:00
|
|
|
explan = ELS_EXPL_OXID_RXID;
|
|
|
|
if (!ep)
|
|
|
|
goto reject;
|
|
|
|
spin_lock_bh(&ep->ex_lock);
|
2016-10-13 13:10:37 +00:00
|
|
|
FC_EXCH_DBG(ep, "RRQ request from %x: xid %x rxid %x oxid %x\n",
|
|
|
|
sid, xid, ntohs(rp->rrq_rx_id), ntohs(rp->rrq_ox_id));
|
2008-12-09 23:10:17 +00:00
|
|
|
if (ep->oxid != ntohs(rp->rrq_ox_id))
|
|
|
|
goto unlock_reject;
|
|
|
|
if (ep->rxid != ntohs(rp->rrq_rx_id) &&
|
|
|
|
ep->rxid != FC_XID_UNKNOWN)
|
|
|
|
goto unlock_reject;
|
|
|
|
explan = ELS_EXPL_SID;
|
|
|
|
if (ep->sid != sid)
|
|
|
|
goto unlock_reject;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Clear Recovery Qualifier state, and cancel timer if complete.
|
|
|
|
*/
|
|
|
|
if (ep->esb_stat & ESB_ST_REC_QUAL) {
|
|
|
|
ep->esb_stat &= ~ESB_ST_REC_QUAL;
|
|
|
|
atomic_dec(&ep->ex_refcnt); /* drop hold for rec qual */
|
|
|
|
}
|
2012-07-06 17:40:10 +00:00
|
|
|
if (ep->esb_stat & ESB_ST_COMPLETE)
|
|
|
|
fc_exch_timer_cancel(ep);
|
2008-12-09 23:10:17 +00:00
|
|
|
|
|
|
|
spin_unlock_bh(&ep->ex_lock);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Send LS_ACC.
|
|
|
|
*/
|
2010-07-20 22:21:12 +00:00
|
|
|
fc_seq_ls_acc(fp);
|
2009-10-21 23:27:33 +00:00
|
|
|
goto out;
|
2008-12-09 23:10:17 +00:00
|
|
|
|
|
|
|
unlock_reject:
|
|
|
|
spin_unlock_bh(&ep->ex_lock);
|
|
|
|
reject:
|
2010-07-20 22:21:12 +00:00
|
|
|
fc_seq_ls_rjt(fp, ELS_RJT_LOGIC, explan);
|
2009-10-21 23:27:33 +00:00
|
|
|
out:
|
|
|
|
if (ep)
|
|
|
|
fc_exch_release(ep); /* drop hold from fc_exch_find */
|
2008-12-09 23:10:17 +00:00
|
|
|
}
|
|
|
|
|
2012-05-25 17:26:54 +00:00
|
|
|
/**
|
|
|
|
* fc_exch_update_stats() - update exches stats to lport
|
|
|
|
* @lport: The local port to update exchange manager stats
|
|
|
|
*/
|
|
|
|
void fc_exch_update_stats(struct fc_lport *lport)
|
|
|
|
{
|
|
|
|
struct fc_host_statistics *st;
|
|
|
|
struct fc_exch_mgr_anchor *ema;
|
|
|
|
struct fc_exch_mgr *mp;
|
|
|
|
|
|
|
|
st = &lport->host_stats;
|
|
|
|
|
|
|
|
list_for_each_entry(ema, &lport->ema_list, ema_list) {
|
|
|
|
mp = ema->mp;
|
|
|
|
st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
|
|
|
|
st->fc_no_free_exch_xid +=
|
|
|
|
atomic_read(&mp->stats.no_free_exch_xid);
|
|
|
|
st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
|
|
|
|
st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
|
|
|
|
st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
|
|
|
|
st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(fc_exch_update_stats);
|
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
/**
|
|
|
|
* fc_exch_mgr_add() - Add an exchange manager to a local port's list of EMs
|
|
|
|
* @lport: The local port to add the exchange manager to
|
|
|
|
* @mp: The exchange manager to be added to the local port
|
|
|
|
* @match: The match routine that indicates when this EM should be used
|
|
|
|
*/
|
2009-07-30 00:05:00 +00:00
|
|
|
struct fc_exch_mgr_anchor *fc_exch_mgr_add(struct fc_lport *lport,
|
|
|
|
struct fc_exch_mgr *mp,
|
|
|
|
bool (*match)(struct fc_frame *))
|
|
|
|
{
|
|
|
|
struct fc_exch_mgr_anchor *ema;
|
|
|
|
|
|
|
|
ema = kmalloc(sizeof(*ema), GFP_ATOMIC);
|
|
|
|
if (!ema)
|
|
|
|
return ema;
|
|
|
|
|
|
|
|
ema->mp = mp;
|
|
|
|
ema->match = match;
|
|
|
|
/* add EM anchor to EM anchors list */
|
|
|
|
list_add_tail(&ema->ema_list, &lport->ema_list);
|
|
|
|
kref_get(&mp->kref);
|
|
|
|
return ema;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(fc_exch_mgr_add);
|
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
/**
|
|
|
|
* fc_exch_mgr_destroy() - Destroy an exchange manager
|
|
|
|
* @kref: The reference to the EM to be destroyed
|
|
|
|
*/
|
2009-07-30 00:05:00 +00:00
|
|
|
static void fc_exch_mgr_destroy(struct kref *kref)
|
|
|
|
{
|
|
|
|
struct fc_exch_mgr *mp = container_of(kref, struct fc_exch_mgr, kref);
|
|
|
|
|
|
|
|
mempool_destroy(mp->ep_pool);
|
[SCSI] fcoe, libfc: adds per cpu exch pool within exchange manager(EM)
Adds per cpu exch pool for these reasons:-
1. Currently an EM instance is shared across all cpus to manage
all exches for all cpus. This required em_lock across all
cpus for an exch alloc, free, lookup and reset each frame
and that made em_lock expensive, so instead having per cpu
exch pool with their own per cpu pool lock will likely reduce
locking contention in fast path for an exch alloc, free and
lookup.
2. Per cpu exch pool will likely improve cache hit ratio since
all frames of an exch will be processed on the same cpu on
which exch originated.
This patch is only prep work to help in keeping complexity of next
patch low, so this patch only sets up per cpu exch pool and related
helper funcs to be used by next patch. The next patch fully makes
use of per cpu exch pool in all code paths ie. tx, rx and reset.
Divides per EM exch id range equally across all cpus to setup per
cpu exch pool. This division is such that lower bits of exch id
carries cpu number info on which exch originated, later a simple
bitwise AND operation on exch id of incoming frame with fc_cpu_mask
retrieves cpu number info to direct all frames to same cpu on which
exch originated. This required a global fc_cpu_mask and fc_cpu_order
initialized to max possible cpus number nr_cpu_ids rounded up to 2's
power, this will be used in mapping exch id and exch ptr array
index in pool during exch allocation, find or reset code paths.
Adds a check in fc_exch_mgr_alloc() to ensure specified min_xid
lower bits are zero since these bits are used to carry cpu info.
Adds and initializes struct fc_exch_pool with all required fields
to manage exches in pool.
Allocates per cpu struct fc_exch_pool with memory for exches array
for range of exches per pool. The exches array memory is followed
by struct fc_exch_pool.
Adds fc_exch_ptr_get/set() helper functions to get/set exch ptr in
pool exches array at specified array index.
Increases default FCOE_MAX_XID to 0x0FFF from 0x07EF, so that more
exches are available per cpu after above described exch id range
division across all cpus to each pool.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:47 +00:00
|
|
|
free_percpu(mp->pool);
|
2009-07-30 00:05:00 +00:00
|
|
|
kfree(mp);
|
|
|
|
}
|
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
/**
|
|
|
|
* fc_exch_mgr_del() - Delete an EM from a local port's list
|
|
|
|
* @ema: The exchange manager anchor identifying the EM to be deleted
|
|
|
|
*/
|
2009-07-30 00:05:00 +00:00
|
|
|
void fc_exch_mgr_del(struct fc_exch_mgr_anchor *ema)
|
|
|
|
{
|
|
|
|
/* remove EM anchor from EM anchors list */
|
|
|
|
list_del(&ema->ema_list);
|
|
|
|
kref_put(&ema->mp->kref, fc_exch_mgr_destroy);
|
|
|
|
kfree(ema);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(fc_exch_mgr_del);
|
|
|
|
|
2009-11-03 19:46:14 +00:00
|
|
|
/**
|
2009-11-03 19:47:39 +00:00
|
|
|
* fc_exch_mgr_list_clone() - Share all exchange manager objects
|
|
|
|
* @src: Source lport to clone exchange managers from
|
|
|
|
* @dst: New lport that takes references to all the exchange managers
|
2009-11-03 19:46:14 +00:00
|
|
|
*/
|
|
|
|
int fc_exch_mgr_list_clone(struct fc_lport *src, struct fc_lport *dst)
|
|
|
|
{
|
|
|
|
struct fc_exch_mgr_anchor *ema, *tmp;
|
|
|
|
|
|
|
|
list_for_each_entry(ema, &src->ema_list, ema_list) {
|
|
|
|
if (!fc_exch_mgr_add(dst, ema->mp, ema->match))
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
err:
|
|
|
|
list_for_each_entry_safe(ema, tmp, &dst->ema_list, ema_list)
|
|
|
|
fc_exch_mgr_del(ema);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
2011-02-25 23:03:01 +00:00
|
|
|
EXPORT_SYMBOL(fc_exch_mgr_list_clone);
|
2009-11-03 19:46:14 +00:00
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
/**
|
|
|
|
* fc_exch_mgr_alloc() - Allocate an exchange manager
|
|
|
|
* @lport: The local port that the new EM will be associated with
|
|
|
|
* @class: The default FC class for new exchanges
|
|
|
|
* @min_xid: The minimum XID for exchanges from the new EM
|
|
|
|
* @max_xid: The maximum XID for exchanges from the new EM
|
|
|
|
* @match: The match routine for the new EM
|
|
|
|
*/
|
|
|
|
struct fc_exch_mgr *fc_exch_mgr_alloc(struct fc_lport *lport,
|
2008-12-09 23:10:17 +00:00
|
|
|
enum fc_class class,
|
[SCSI] fcoe, fnic, libfc: modifies current code paths to use EM anchor list
Modifies current code to use EM anchor list in EM allocation, EM free,
EM reset, exch allocation and exch lookup code paths.
1. Modifies fc_exch_mgr_alloc to accept EM match function and then
have allocated EM added to the lport using fc_exch_mgr_add API
while also updating EM kref for newly added EM.
2. Updates fc_exch_mgr_free API to accept only lport pointer instead
EM and then have this API free all EMs of the lport from EM anchor
list.
3. Removes single lport pointer link from the EM, which was used in
associating lport pointer in newly allocated exchange. Instead have
lport pointer passed along new exchange allocation call path and
then store passed lport pointer in newly allocated exchange, this
will allow a single EM instance to be used across more than one
lport and used in EM reset to reset only lport specific exchanges.
4. Modifies fc_exch_mgr_reset to reset all EMs from the EM anchor list
of the lport, adds additional exch lport pointer (ep->lp) check for
shared EM case to reset exchange specific to a lport requested reset.
5. Updates exch allocation API fc_exch_alloc to use EM anchor list and
its anchor match func pointer. The fc_exch_alloc will walk the list
of EMs until it finds a match, a match will be either null match
func pointer or call to match function returning true value.
6. Updates fc_exch_recv to accept incoming frame on local port using
only lport pointer and frame pointer without specifying EM instance
of incoming frame. Instead modified fc_exch_recv to locate EM for the
incoming frame by matching xid of incoming frame against a EM xid range.
This change was required to use EM list in libfc Rx path and after this
change the lport fc_exch_mgr pointer emp is not needed anymore, so
removed emp pointer.
7. Updates fnic for removed lport emp pointer and above modified libfc APIs
fc_exch_recv, fc_exch_mgr_alloc and fc_exch_mgr_free.
8. Removes exch_get and exch_put from libfc_function_template as these
are no longer needed with EM anchor list and its match function use.
Also removes its default function fc_exch_get.
A defect this patch introduced regarding the libfc initialization order in
the fnic driver was fixed by Joe Eykholt <jeykholt@cisco.com>.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-07-30 00:05:10 +00:00
|
|
|
u16 min_xid, u16 max_xid,
|
|
|
|
bool (*match)(struct fc_frame *))
|
2008-12-09 23:10:17 +00:00
|
|
|
{
|
|
|
|
struct fc_exch_mgr *mp;
|
[SCSI] fcoe, libfc: adds per cpu exch pool within exchange manager(EM)
Adds per cpu exch pool for these reasons:-
1. Currently an EM instance is shared across all cpus to manage
all exches for all cpus. This required em_lock across all
cpus for an exch alloc, free, lookup and reset each frame
and that made em_lock expensive, so instead having per cpu
exch pool with their own per cpu pool lock will likely reduce
locking contention in fast path for an exch alloc, free and
lookup.
2. Per cpu exch pool will likely improve cache hit ratio since
all frames of an exch will be processed on the same cpu on
which exch originated.
This patch is only prep work to help in keeping complexity of next
patch low, so this patch only sets up per cpu exch pool and related
helper funcs to be used by next patch. The next patch fully makes
use of per cpu exch pool in all code paths ie. tx, rx and reset.
Divides per EM exch id range equally across all cpus to setup per
cpu exch pool. This division is such that lower bits of exch id
carries cpu number info on which exch originated, later a simple
bitwise AND operation on exch id of incoming frame with fc_cpu_mask
retrieves cpu number info to direct all frames to same cpu on which
exch originated. This required a global fc_cpu_mask and fc_cpu_order
initialized to max possible cpus number nr_cpu_ids rounded up to 2's
power, this will be used in mapping exch id and exch ptr array
index in pool during exch allocation, find or reset code paths.
Adds a check in fc_exch_mgr_alloc() to ensure specified min_xid
lower bits are zero since these bits are used to carry cpu info.
Adds and initializes struct fc_exch_pool with all required fields
to manage exches in pool.
Allocates per cpu struct fc_exch_pool with memory for exches array
for range of exches per pool. The exches array memory is followed
by struct fc_exch_pool.
Adds fc_exch_ptr_get/set() helper functions to get/set exch ptr in
pool exches array at specified array index.
Increases default FCOE_MAX_XID to 0x0FFF from 0x07EF, so that more
exches are available per cpu after above described exch id range
division across all cpus to each pool.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:47 +00:00
|
|
|
u16 pool_exch_range;
|
|
|
|
size_t pool_size;
|
|
|
|
unsigned int cpu;
|
|
|
|
struct fc_exch_pool *pool;
|
2008-12-09 23:10:17 +00:00
|
|
|
|
[SCSI] fcoe, libfc: adds per cpu exch pool within exchange manager(EM)
Adds per cpu exch pool for these reasons:-
1. Currently an EM instance is shared across all cpus to manage
all exches for all cpus. This required em_lock across all
cpus for an exch alloc, free, lookup and reset each frame
and that made em_lock expensive, so instead having per cpu
exch pool with their own per cpu pool lock will likely reduce
locking contention in fast path for an exch alloc, free and
lookup.
2. Per cpu exch pool will likely improve cache hit ratio since
all frames of an exch will be processed on the same cpu on
which exch originated.
This patch is only prep work to help in keeping complexity of next
patch low, so this patch only sets up per cpu exch pool and related
helper funcs to be used by next patch. The next patch fully makes
use of per cpu exch pool in all code paths ie. tx, rx and reset.
Divides per EM exch id range equally across all cpus to setup per
cpu exch pool. This division is such that lower bits of exch id
carries cpu number info on which exch originated, later a simple
bitwise AND operation on exch id of incoming frame with fc_cpu_mask
retrieves cpu number info to direct all frames to same cpu on which
exch originated. This required a global fc_cpu_mask and fc_cpu_order
initialized to max possible cpus number nr_cpu_ids rounded up to 2's
power, this will be used in mapping exch id and exch ptr array
index in pool during exch allocation, find or reset code paths.
Adds a check in fc_exch_mgr_alloc() to ensure specified min_xid
lower bits are zero since these bits are used to carry cpu info.
Adds and initializes struct fc_exch_pool with all required fields
to manage exches in pool.
Allocates per cpu struct fc_exch_pool with memory for exches array
for range of exches per pool. The exches array memory is followed
by struct fc_exch_pool.
Adds fc_exch_ptr_get/set() helper functions to get/set exch ptr in
pool exches array at specified array index.
Increases default FCOE_MAX_XID to 0x0FFF from 0x07EF, so that more
exches are available per cpu after above described exch id range
division across all cpus to each pool.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:47 +00:00
|
|
|
if (max_xid <= min_xid || max_xid == FC_XID_UNKNOWN ||
|
|
|
|
(min_xid & fc_cpu_mask) != 0) {
|
2009-11-03 19:47:39 +00:00
|
|
|
FC_LPORT_DBG(lport, "Invalid min_xid 0x:%x and max_xid 0x:%x\n",
|
2009-06-10 22:31:10 +00:00
|
|
|
min_xid, max_xid);
|
2008-12-09 23:10:17 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
[SCSI] fcoe, libfc: fully makes use of per cpu exch pool and then removes em_lock
1. Updates fcoe_rcv() to queue incoming frames to the fcoe per
cpu thread on which this frame's exch was originated and simply
use current cpu for request exch not originated by initiator.
It is redundant to add this code under CONFIG_SMP, so removes
CONFIG_SMP uses around this code.
2. Updates fc_exch_em_alloc, fc_exch_delete, fc_exch_find to use
per cpu exch pools, here fc_exch_delete is rename of older
fc_exch_mgr_delete_ep since ep/exch are now deleted in pools
of EM and so brief new name is sufficient and better name.
Updates these functions to map exch id to their index into exch
pool using fc_cpu_mask, fc_cpu_order and EM min_xid.
This mapping is as per detailed explanation about this in
last patch and basically this is just as lower fc_cpu_mask
bits of exch id as cpu number and upper bit sum of EM min_xid
and exch index in pool.
Uses pool next_index to keep track of exch allocation from
pool along with pool_max_index as upper bound of exches array
in pool.
3. Adds exch pool ptr to fc_exch to free exch to its pool in
fc_exch_delete.
4. Updates fc_exch_mgr_reset to reset all exch pools of an EM,
this required adding fc_exch_pool_reset func to reset exches
in pool and then have fc_exch_mgr_reset call fc_exch_pool_reset
for each pool within each EM for a lport.
5. Removes no longer needed exches array, em_lock, next_xid, and
total_exches from struct fc_exch_mgr, these are not needed after
use of per cpu exch pool, also removes not used max_read,
last_read from struct fc_exch_mgr.
6. Updates locking notes for exch pool lock with fc_exch lock and
uses pool lock in exch allocation, lookup and reset.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:53 +00:00
|
|
|
* allocate memory for EM
|
2008-12-09 23:10:17 +00:00
|
|
|
*/
|
[SCSI] fcoe, libfc: fully makes use of per cpu exch pool and then removes em_lock
1. Updates fcoe_rcv() to queue incoming frames to the fcoe per
cpu thread on which this frame's exch was originated and simply
use current cpu for request exch not originated by initiator.
It is redundant to add this code under CONFIG_SMP, so removes
CONFIG_SMP uses around this code.
2. Updates fc_exch_em_alloc, fc_exch_delete, fc_exch_find to use
per cpu exch pools, here fc_exch_delete is rename of older
fc_exch_mgr_delete_ep since ep/exch are now deleted in pools
of EM and so brief new name is sufficient and better name.
Updates these functions to map exch id to their index into exch
pool using fc_cpu_mask, fc_cpu_order and EM min_xid.
This mapping is as per detailed explanation about this in
last patch and basically this is just as lower fc_cpu_mask
bits of exch id as cpu number and upper bit sum of EM min_xid
and exch index in pool.
Uses pool next_index to keep track of exch allocation from
pool along with pool_max_index as upper bound of exches array
in pool.
3. Adds exch pool ptr to fc_exch to free exch to its pool in
fc_exch_delete.
4. Updates fc_exch_mgr_reset to reset all exch pools of an EM,
this required adding fc_exch_pool_reset func to reset exches
in pool and then have fc_exch_mgr_reset call fc_exch_pool_reset
for each pool within each EM for a lport.
5. Removes no longer needed exches array, em_lock, next_xid, and
total_exches from struct fc_exch_mgr, these are not needed after
use of per cpu exch pool, also removes not used max_read,
last_read from struct fc_exch_mgr.
6. Updates locking notes for exch pool lock with fc_exch lock and
uses pool lock in exch allocation, lookup and reset.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:53 +00:00
|
|
|
mp = kzalloc(sizeof(struct fc_exch_mgr), GFP_ATOMIC);
|
2008-12-09 23:10:17 +00:00
|
|
|
if (!mp)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
mp->class = class;
|
2016-10-13 13:10:50 +00:00
|
|
|
mp->lport = lport;
|
2008-12-09 23:10:17 +00:00
|
|
|
/* adjust em exch xid range for offload */
|
|
|
|
mp->min_xid = min_xid;
|
2012-03-09 22:50:30 +00:00
|
|
|
|
|
|
|
/* reduce range so per cpu pool fits into PCPU_MIN_UNIT_SIZE pool */
|
|
|
|
pool_exch_range = (PCPU_MIN_UNIT_SIZE - sizeof(*pool)) /
|
|
|
|
sizeof(struct fc_exch *);
|
|
|
|
if ((max_xid - min_xid + 1) / (fc_cpu_mask + 1) > pool_exch_range) {
|
|
|
|
mp->max_xid = pool_exch_range * (fc_cpu_mask + 1) +
|
|
|
|
min_xid - 1;
|
|
|
|
} else {
|
|
|
|
mp->max_xid = max_xid;
|
|
|
|
pool_exch_range = (mp->max_xid - mp->min_xid + 1) /
|
|
|
|
(fc_cpu_mask + 1);
|
|
|
|
}
|
2008-12-09 23:10:17 +00:00
|
|
|
|
|
|
|
mp->ep_pool = mempool_create_slab_pool(2, fc_em_cachep);
|
|
|
|
if (!mp->ep_pool)
|
|
|
|
goto free_mp;
|
|
|
|
|
[SCSI] fcoe, libfc: adds per cpu exch pool within exchange manager(EM)
Adds per cpu exch pool for these reasons:-
1. Currently an EM instance is shared across all cpus to manage
all exches for all cpus. This required em_lock across all
cpus for an exch alloc, free, lookup and reset each frame
and that made em_lock expensive, so instead having per cpu
exch pool with their own per cpu pool lock will likely reduce
locking contention in fast path for an exch alloc, free and
lookup.
2. Per cpu exch pool will likely improve cache hit ratio since
all frames of an exch will be processed on the same cpu on
which exch originated.
This patch is only prep work to help in keeping complexity of next
patch low, so this patch only sets up per cpu exch pool and related
helper funcs to be used by next patch. The next patch fully makes
use of per cpu exch pool in all code paths ie. tx, rx and reset.
Divides per EM exch id range equally across all cpus to setup per
cpu exch pool. This division is such that lower bits of exch id
carries cpu number info on which exch originated, later a simple
bitwise AND operation on exch id of incoming frame with fc_cpu_mask
retrieves cpu number info to direct all frames to same cpu on which
exch originated. This required a global fc_cpu_mask and fc_cpu_order
initialized to max possible cpus number nr_cpu_ids rounded up to 2's
power, this will be used in mapping exch id and exch ptr array
index in pool during exch allocation, find or reset code paths.
Adds a check in fc_exch_mgr_alloc() to ensure specified min_xid
lower bits are zero since these bits are used to carry cpu info.
Adds and initializes struct fc_exch_pool with all required fields
to manage exches in pool.
Allocates per cpu struct fc_exch_pool with memory for exches array
for range of exches per pool. The exches array memory is followed
by struct fc_exch_pool.
Adds fc_exch_ptr_get/set() helper functions to get/set exch ptr in
pool exches array at specified array index.
Increases default FCOE_MAX_XID to 0x0FFF from 0x07EF, so that more
exches are available per cpu after above described exch id range
division across all cpus to each pool.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:47 +00:00
|
|
|
/*
|
|
|
|
* Setup per cpu exch pool with entire exchange id range equally
|
|
|
|
* divided across all cpus. The exch pointers array memory is
|
|
|
|
* allocated for exch range per pool.
|
|
|
|
*/
|
|
|
|
mp->pool_max_index = pool_exch_range - 1;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate and initialize per cpu exch pool
|
|
|
|
*/
|
|
|
|
pool_size = sizeof(*pool) + pool_exch_range * sizeof(struct fc_exch *);
|
|
|
|
mp->pool = __alloc_percpu(pool_size, __alignof__(struct fc_exch_pool));
|
|
|
|
if (!mp->pool)
|
|
|
|
goto free_mempool;
|
|
|
|
for_each_possible_cpu(cpu) {
|
|
|
|
pool = per_cpu_ptr(mp->pool, cpu);
|
2011-10-28 18:34:17 +00:00
|
|
|
pool->next_index = 0;
|
2010-12-01 00:18:17 +00:00
|
|
|
pool->left = FC_XID_UNKNOWN;
|
|
|
|
pool->right = FC_XID_UNKNOWN;
|
[SCSI] fcoe, libfc: adds per cpu exch pool within exchange manager(EM)
Adds per cpu exch pool for these reasons:-
1. Currently an EM instance is shared across all cpus to manage
all exches for all cpus. This required em_lock across all
cpus for an exch alloc, free, lookup and reset each frame
and that made em_lock expensive, so instead having per cpu
exch pool with their own per cpu pool lock will likely reduce
locking contention in fast path for an exch alloc, free and
lookup.
2. Per cpu exch pool will likely improve cache hit ratio since
all frames of an exch will be processed on the same cpu on
which exch originated.
This patch is only prep work to help in keeping complexity of next
patch low, so this patch only sets up per cpu exch pool and related
helper funcs to be used by next patch. The next patch fully makes
use of per cpu exch pool in all code paths ie. tx, rx and reset.
Divides per EM exch id range equally across all cpus to setup per
cpu exch pool. This division is such that lower bits of exch id
carries cpu number info on which exch originated, later a simple
bitwise AND operation on exch id of incoming frame with fc_cpu_mask
retrieves cpu number info to direct all frames to same cpu on which
exch originated. This required a global fc_cpu_mask and fc_cpu_order
initialized to max possible cpus number nr_cpu_ids rounded up to 2's
power, this will be used in mapping exch id and exch ptr array
index in pool during exch allocation, find or reset code paths.
Adds a check in fc_exch_mgr_alloc() to ensure specified min_xid
lower bits are zero since these bits are used to carry cpu info.
Adds and initializes struct fc_exch_pool with all required fields
to manage exches in pool.
Allocates per cpu struct fc_exch_pool with memory for exches array
for range of exches per pool. The exches array memory is followed
by struct fc_exch_pool.
Adds fc_exch_ptr_get/set() helper functions to get/set exch ptr in
pool exches array at specified array index.
Increases default FCOE_MAX_XID to 0x0FFF from 0x07EF, so that more
exches are available per cpu after above described exch id range
division across all cpus to each pool.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:47 +00:00
|
|
|
spin_lock_init(&pool->lock);
|
|
|
|
INIT_LIST_HEAD(&pool->ex_list);
|
|
|
|
}
|
|
|
|
|
[SCSI] fcoe, fnic, libfc: modifies current code paths to use EM anchor list
Modifies current code to use EM anchor list in EM allocation, EM free,
EM reset, exch allocation and exch lookup code paths.
1. Modifies fc_exch_mgr_alloc to accept EM match function and then
have allocated EM added to the lport using fc_exch_mgr_add API
while also updating EM kref for newly added EM.
2. Updates fc_exch_mgr_free API to accept only lport pointer instead
EM and then have this API free all EMs of the lport from EM anchor
list.
3. Removes single lport pointer link from the EM, which was used in
associating lport pointer in newly allocated exchange. Instead have
lport pointer passed along new exchange allocation call path and
then store passed lport pointer in newly allocated exchange, this
will allow a single EM instance to be used across more than one
lport and used in EM reset to reset only lport specific exchanges.
4. Modifies fc_exch_mgr_reset to reset all EMs from the EM anchor list
of the lport, adds additional exch lport pointer (ep->lp) check for
shared EM case to reset exchange specific to a lport requested reset.
5. Updates exch allocation API fc_exch_alloc to use EM anchor list and
its anchor match func pointer. The fc_exch_alloc will walk the list
of EMs until it finds a match, a match will be either null match
func pointer or call to match function returning true value.
6. Updates fc_exch_recv to accept incoming frame on local port using
only lport pointer and frame pointer without specifying EM instance
of incoming frame. Instead modified fc_exch_recv to locate EM for the
incoming frame by matching xid of incoming frame against a EM xid range.
This change was required to use EM list in libfc Rx path and after this
change the lport fc_exch_mgr pointer emp is not needed anymore, so
removed emp pointer.
7. Updates fnic for removed lport emp pointer and above modified libfc APIs
fc_exch_recv, fc_exch_mgr_alloc and fc_exch_mgr_free.
8. Removes exch_get and exch_put from libfc_function_template as these
are no longer needed with EM anchor list and its match function use.
Also removes its default function fc_exch_get.
A defect this patch introduced regarding the libfc initialization order in
the fnic driver was fixed by Joe Eykholt <jeykholt@cisco.com>.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-07-30 00:05:10 +00:00
|
|
|
kref_init(&mp->kref);
|
2009-11-03 19:47:39 +00:00
|
|
|
if (!fc_exch_mgr_add(lport, mp, match)) {
|
[SCSI] fcoe, libfc: adds per cpu exch pool within exchange manager(EM)
Adds per cpu exch pool for these reasons:-
1. Currently an EM instance is shared across all cpus to manage
all exches for all cpus. This required em_lock across all
cpus for an exch alloc, free, lookup and reset each frame
and that made em_lock expensive, so instead having per cpu
exch pool with their own per cpu pool lock will likely reduce
locking contention in fast path for an exch alloc, free and
lookup.
2. Per cpu exch pool will likely improve cache hit ratio since
all frames of an exch will be processed on the same cpu on
which exch originated.
This patch is only prep work to help in keeping complexity of next
patch low, so this patch only sets up per cpu exch pool and related
helper funcs to be used by next patch. The next patch fully makes
use of per cpu exch pool in all code paths ie. tx, rx and reset.
Divides per EM exch id range equally across all cpus to setup per
cpu exch pool. This division is such that lower bits of exch id
carries cpu number info on which exch originated, later a simple
bitwise AND operation on exch id of incoming frame with fc_cpu_mask
retrieves cpu number info to direct all frames to same cpu on which
exch originated. This required a global fc_cpu_mask and fc_cpu_order
initialized to max possible cpus number nr_cpu_ids rounded up to 2's
power, this will be used in mapping exch id and exch ptr array
index in pool during exch allocation, find or reset code paths.
Adds a check in fc_exch_mgr_alloc() to ensure specified min_xid
lower bits are zero since these bits are used to carry cpu info.
Adds and initializes struct fc_exch_pool with all required fields
to manage exches in pool.
Allocates per cpu struct fc_exch_pool with memory for exches array
for range of exches per pool. The exches array memory is followed
by struct fc_exch_pool.
Adds fc_exch_ptr_get/set() helper functions to get/set exch ptr in
pool exches array at specified array index.
Increases default FCOE_MAX_XID to 0x0FFF from 0x07EF, so that more
exches are available per cpu after above described exch id range
division across all cpus to each pool.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:47 +00:00
|
|
|
free_percpu(mp->pool);
|
|
|
|
goto free_mempool;
|
[SCSI] fcoe, fnic, libfc: modifies current code paths to use EM anchor list
Modifies current code to use EM anchor list in EM allocation, EM free,
EM reset, exch allocation and exch lookup code paths.
1. Modifies fc_exch_mgr_alloc to accept EM match function and then
have allocated EM added to the lport using fc_exch_mgr_add API
while also updating EM kref for newly added EM.
2. Updates fc_exch_mgr_free API to accept only lport pointer instead
EM and then have this API free all EMs of the lport from EM anchor
list.
3. Removes single lport pointer link from the EM, which was used in
associating lport pointer in newly allocated exchange. Instead have
lport pointer passed along new exchange allocation call path and
then store passed lport pointer in newly allocated exchange, this
will allow a single EM instance to be used across more than one
lport and used in EM reset to reset only lport specific exchanges.
4. Modifies fc_exch_mgr_reset to reset all EMs from the EM anchor list
of the lport, adds additional exch lport pointer (ep->lp) check for
shared EM case to reset exchange specific to a lport requested reset.
5. Updates exch allocation API fc_exch_alloc to use EM anchor list and
its anchor match func pointer. The fc_exch_alloc will walk the list
of EMs until it finds a match, a match will be either null match
func pointer or call to match function returning true value.
6. Updates fc_exch_recv to accept incoming frame on local port using
only lport pointer and frame pointer without specifying EM instance
of incoming frame. Instead modified fc_exch_recv to locate EM for the
incoming frame by matching xid of incoming frame against a EM xid range.
This change was required to use EM list in libfc Rx path and after this
change the lport fc_exch_mgr pointer emp is not needed anymore, so
removed emp pointer.
7. Updates fnic for removed lport emp pointer and above modified libfc APIs
fc_exch_recv, fc_exch_mgr_alloc and fc_exch_mgr_free.
8. Removes exch_get and exch_put from libfc_function_template as these
are no longer needed with EM anchor list and its match function use.
Also removes its default function fc_exch_get.
A defect this patch introduced regarding the libfc initialization order in
the fnic driver was fixed by Joe Eykholt <jeykholt@cisco.com>.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-07-30 00:05:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Above kref_init() sets mp->kref to 1 and then
|
|
|
|
* call to fc_exch_mgr_add incremented mp->kref again,
|
|
|
|
* so adjust that extra increment.
|
|
|
|
*/
|
|
|
|
kref_put(&mp->kref, fc_exch_mgr_destroy);
|
2008-12-09 23:10:17 +00:00
|
|
|
return mp;
|
|
|
|
|
[SCSI] fcoe, libfc: adds per cpu exch pool within exchange manager(EM)
Adds per cpu exch pool for these reasons:-
1. Currently an EM instance is shared across all cpus to manage
all exches for all cpus. This required em_lock across all
cpus for an exch alloc, free, lookup and reset each frame
and that made em_lock expensive, so instead having per cpu
exch pool with their own per cpu pool lock will likely reduce
locking contention in fast path for an exch alloc, free and
lookup.
2. Per cpu exch pool will likely improve cache hit ratio since
all frames of an exch will be processed on the same cpu on
which exch originated.
This patch is only prep work to help in keeping complexity of next
patch low, so this patch only sets up per cpu exch pool and related
helper funcs to be used by next patch. The next patch fully makes
use of per cpu exch pool in all code paths ie. tx, rx and reset.
Divides per EM exch id range equally across all cpus to setup per
cpu exch pool. This division is such that lower bits of exch id
carries cpu number info on which exch originated, later a simple
bitwise AND operation on exch id of incoming frame with fc_cpu_mask
retrieves cpu number info to direct all frames to same cpu on which
exch originated. This required a global fc_cpu_mask and fc_cpu_order
initialized to max possible cpus number nr_cpu_ids rounded up to 2's
power, this will be used in mapping exch id and exch ptr array
index in pool during exch allocation, find or reset code paths.
Adds a check in fc_exch_mgr_alloc() to ensure specified min_xid
lower bits are zero since these bits are used to carry cpu info.
Adds and initializes struct fc_exch_pool with all required fields
to manage exches in pool.
Allocates per cpu struct fc_exch_pool with memory for exches array
for range of exches per pool. The exches array memory is followed
by struct fc_exch_pool.
Adds fc_exch_ptr_get/set() helper functions to get/set exch ptr in
pool exches array at specified array index.
Increases default FCOE_MAX_XID to 0x0FFF from 0x07EF, so that more
exches are available per cpu after above described exch id range
division across all cpus to each pool.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:47 +00:00
|
|
|
free_mempool:
|
|
|
|
mempool_destroy(mp->ep_pool);
|
2008-12-09 23:10:17 +00:00
|
|
|
free_mp:
|
|
|
|
kfree(mp);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(fc_exch_mgr_alloc);
|
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
/**
|
|
|
|
* fc_exch_mgr_free() - Free all exchange managers on a local port
|
|
|
|
* @lport: The local port whose EMs are to be freed
|
|
|
|
*/
|
[SCSI] fcoe, fnic, libfc: modifies current code paths to use EM anchor list
Modifies current code to use EM anchor list in EM allocation, EM free,
EM reset, exch allocation and exch lookup code paths.
1. Modifies fc_exch_mgr_alloc to accept EM match function and then
have allocated EM added to the lport using fc_exch_mgr_add API
while also updating EM kref for newly added EM.
2. Updates fc_exch_mgr_free API to accept only lport pointer instead
EM and then have this API free all EMs of the lport from EM anchor
list.
3. Removes single lport pointer link from the EM, which was used in
associating lport pointer in newly allocated exchange. Instead have
lport pointer passed along new exchange allocation call path and
then store passed lport pointer in newly allocated exchange, this
will allow a single EM instance to be used across more than one
lport and used in EM reset to reset only lport specific exchanges.
4. Modifies fc_exch_mgr_reset to reset all EMs from the EM anchor list
of the lport, adds additional exch lport pointer (ep->lp) check for
shared EM case to reset exchange specific to a lport requested reset.
5. Updates exch allocation API fc_exch_alloc to use EM anchor list and
its anchor match func pointer. The fc_exch_alloc will walk the list
of EMs until it finds a match, a match will be either null match
func pointer or call to match function returning true value.
6. Updates fc_exch_recv to accept incoming frame on local port using
only lport pointer and frame pointer without specifying EM instance
of incoming frame. Instead modified fc_exch_recv to locate EM for the
incoming frame by matching xid of incoming frame against a EM xid range.
This change was required to use EM list in libfc Rx path and after this
change the lport fc_exch_mgr pointer emp is not needed anymore, so
removed emp pointer.
7. Updates fnic for removed lport emp pointer and above modified libfc APIs
fc_exch_recv, fc_exch_mgr_alloc and fc_exch_mgr_free.
8. Removes exch_get and exch_put from libfc_function_template as these
are no longer needed with EM anchor list and its match function use.
Also removes its default function fc_exch_get.
A defect this patch introduced regarding the libfc initialization order in
the fnic driver was fixed by Joe Eykholt <jeykholt@cisco.com>.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-07-30 00:05:10 +00:00
|
|
|
void fc_exch_mgr_free(struct fc_lport *lport)
|
2008-12-09 23:10:17 +00:00
|
|
|
{
|
[SCSI] fcoe, fnic, libfc: modifies current code paths to use EM anchor list
Modifies current code to use EM anchor list in EM allocation, EM free,
EM reset, exch allocation and exch lookup code paths.
1. Modifies fc_exch_mgr_alloc to accept EM match function and then
have allocated EM added to the lport using fc_exch_mgr_add API
while also updating EM kref for newly added EM.
2. Updates fc_exch_mgr_free API to accept only lport pointer instead
EM and then have this API free all EMs of the lport from EM anchor
list.
3. Removes single lport pointer link from the EM, which was used in
associating lport pointer in newly allocated exchange. Instead have
lport pointer passed along new exchange allocation call path and
then store passed lport pointer in newly allocated exchange, this
will allow a single EM instance to be used across more than one
lport and used in EM reset to reset only lport specific exchanges.
4. Modifies fc_exch_mgr_reset to reset all EMs from the EM anchor list
of the lport, adds additional exch lport pointer (ep->lp) check for
shared EM case to reset exchange specific to a lport requested reset.
5. Updates exch allocation API fc_exch_alloc to use EM anchor list and
its anchor match func pointer. The fc_exch_alloc will walk the list
of EMs until it finds a match, a match will be either null match
func pointer or call to match function returning true value.
6. Updates fc_exch_recv to accept incoming frame on local port using
only lport pointer and frame pointer without specifying EM instance
of incoming frame. Instead modified fc_exch_recv to locate EM for the
incoming frame by matching xid of incoming frame against a EM xid range.
This change was required to use EM list in libfc Rx path and after this
change the lport fc_exch_mgr pointer emp is not needed anymore, so
removed emp pointer.
7. Updates fnic for removed lport emp pointer and above modified libfc APIs
fc_exch_recv, fc_exch_mgr_alloc and fc_exch_mgr_free.
8. Removes exch_get and exch_put from libfc_function_template as these
are no longer needed with EM anchor list and its match function use.
Also removes its default function fc_exch_get.
A defect this patch introduced regarding the libfc initialization order in
the fnic driver was fixed by Joe Eykholt <jeykholt@cisco.com>.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-07-30 00:05:10 +00:00
|
|
|
struct fc_exch_mgr_anchor *ema, *next;
|
|
|
|
|
2009-11-03 19:50:10 +00:00
|
|
|
flush_workqueue(fc_exch_workqueue);
|
[SCSI] fcoe, fnic, libfc: modifies current code paths to use EM anchor list
Modifies current code to use EM anchor list in EM allocation, EM free,
EM reset, exch allocation and exch lookup code paths.
1. Modifies fc_exch_mgr_alloc to accept EM match function and then
have allocated EM added to the lport using fc_exch_mgr_add API
while also updating EM kref for newly added EM.
2. Updates fc_exch_mgr_free API to accept only lport pointer instead
EM and then have this API free all EMs of the lport from EM anchor
list.
3. Removes single lport pointer link from the EM, which was used in
associating lport pointer in newly allocated exchange. Instead have
lport pointer passed along new exchange allocation call path and
then store passed lport pointer in newly allocated exchange, this
will allow a single EM instance to be used across more than one
lport and used in EM reset to reset only lport specific exchanges.
4. Modifies fc_exch_mgr_reset to reset all EMs from the EM anchor list
of the lport, adds additional exch lport pointer (ep->lp) check for
shared EM case to reset exchange specific to a lport requested reset.
5. Updates exch allocation API fc_exch_alloc to use EM anchor list and
its anchor match func pointer. The fc_exch_alloc will walk the list
of EMs until it finds a match, a match will be either null match
func pointer or call to match function returning true value.
6. Updates fc_exch_recv to accept incoming frame on local port using
only lport pointer and frame pointer without specifying EM instance
of incoming frame. Instead modified fc_exch_recv to locate EM for the
incoming frame by matching xid of incoming frame against a EM xid range.
This change was required to use EM list in libfc Rx path and after this
change the lport fc_exch_mgr pointer emp is not needed anymore, so
removed emp pointer.
7. Updates fnic for removed lport emp pointer and above modified libfc APIs
fc_exch_recv, fc_exch_mgr_alloc and fc_exch_mgr_free.
8. Removes exch_get and exch_put from libfc_function_template as these
are no longer needed with EM anchor list and its match function use.
Also removes its default function fc_exch_get.
A defect this patch introduced regarding the libfc initialization order in
the fnic driver was fixed by Joe Eykholt <jeykholt@cisco.com>.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-07-30 00:05:10 +00:00
|
|
|
list_for_each_entry_safe(ema, next, &lport->ema_list, ema_list)
|
|
|
|
fc_exch_mgr_del(ema);
|
2008-12-09 23:10:17 +00:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(fc_exch_mgr_free);
|
|
|
|
|
2011-01-29 00:04:39 +00:00
|
|
|
/**
|
|
|
|
* fc_find_ema() - Lookup and return appropriate Exchange Manager Anchor depending
|
|
|
|
* upon 'xid'.
|
|
|
|
* @f_ctl: f_ctl
|
|
|
|
* @lport: The local port the frame was received on
|
|
|
|
* @fh: The received frame header
|
|
|
|
*/
|
|
|
|
static struct fc_exch_mgr_anchor *fc_find_ema(u32 f_ctl,
|
|
|
|
struct fc_lport *lport,
|
|
|
|
struct fc_frame_header *fh)
|
|
|
|
{
|
|
|
|
struct fc_exch_mgr_anchor *ema;
|
|
|
|
u16 xid;
|
|
|
|
|
|
|
|
if (f_ctl & FC_FC_EX_CTX)
|
|
|
|
xid = ntohs(fh->fh_ox_id);
|
|
|
|
else {
|
|
|
|
xid = ntohs(fh->fh_rx_id);
|
|
|
|
if (xid == FC_XID_UNKNOWN)
|
|
|
|
return list_entry(lport->ema_list.prev,
|
|
|
|
typeof(*ema), ema_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
list_for_each_entry(ema, &lport->ema_list, ema_list) {
|
|
|
|
if ((xid >= ema->mp->min_xid) &&
|
|
|
|
(xid <= ema->mp->max_xid))
|
|
|
|
return ema;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2009-11-03 19:47:39 +00:00
|
|
|
/**
|
|
|
|
* fc_exch_recv() - Handler for received frames
|
|
|
|
* @lport: The local port the frame was received on
|
2011-01-29 00:04:39 +00:00
|
|
|
* @fp: The received frame
|
2008-12-09 23:10:17 +00:00
|
|
|
*/
|
2009-11-03 19:47:39 +00:00
|
|
|
void fc_exch_recv(struct fc_lport *lport, struct fc_frame *fp)
|
2008-12-09 23:10:17 +00:00
|
|
|
{
|
|
|
|
struct fc_frame_header *fh = fc_frame_header_get(fp);
|
[SCSI] fcoe, fnic, libfc: modifies current code paths to use EM anchor list
Modifies current code to use EM anchor list in EM allocation, EM free,
EM reset, exch allocation and exch lookup code paths.
1. Modifies fc_exch_mgr_alloc to accept EM match function and then
have allocated EM added to the lport using fc_exch_mgr_add API
while also updating EM kref for newly added EM.
2. Updates fc_exch_mgr_free API to accept only lport pointer instead
EM and then have this API free all EMs of the lport from EM anchor
list.
3. Removes single lport pointer link from the EM, which was used in
associating lport pointer in newly allocated exchange. Instead have
lport pointer passed along new exchange allocation call path and
then store passed lport pointer in newly allocated exchange, this
will allow a single EM instance to be used across more than one
lport and used in EM reset to reset only lport specific exchanges.
4. Modifies fc_exch_mgr_reset to reset all EMs from the EM anchor list
of the lport, adds additional exch lport pointer (ep->lp) check for
shared EM case to reset exchange specific to a lport requested reset.
5. Updates exch allocation API fc_exch_alloc to use EM anchor list and
its anchor match func pointer. The fc_exch_alloc will walk the list
of EMs until it finds a match, a match will be either null match
func pointer or call to match function returning true value.
6. Updates fc_exch_recv to accept incoming frame on local port using
only lport pointer and frame pointer without specifying EM instance
of incoming frame. Instead modified fc_exch_recv to locate EM for the
incoming frame by matching xid of incoming frame against a EM xid range.
This change was required to use EM list in libfc Rx path and after this
change the lport fc_exch_mgr pointer emp is not needed anymore, so
removed emp pointer.
7. Updates fnic for removed lport emp pointer and above modified libfc APIs
fc_exch_recv, fc_exch_mgr_alloc and fc_exch_mgr_free.
8. Removes exch_get and exch_put from libfc_function_template as these
are no longer needed with EM anchor list and its match function use.
Also removes its default function fc_exch_get.
A defect this patch introduced regarding the libfc initialization order in
the fnic driver was fixed by Joe Eykholt <jeykholt@cisco.com>.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-07-30 00:05:10 +00:00
|
|
|
struct fc_exch_mgr_anchor *ema;
|
2011-01-29 00:04:39 +00:00
|
|
|
u32 f_ctl;
|
2008-12-09 23:10:17 +00:00
|
|
|
|
|
|
|
/* lport lock ? */
|
2009-11-03 19:47:39 +00:00
|
|
|
if (!lport || lport->state == LPORT_ST_DISABLED) {
|
|
|
|
FC_LPORT_DBG(lport, "Receiving frames for an lport that "
|
2009-06-10 22:31:10 +00:00
|
|
|
"has not been initialized correctly\n");
|
2008-12-09 23:10:17 +00:00
|
|
|
fc_frame_free(fp);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
[SCSI] fcoe, fnic, libfc: modifies current code paths to use EM anchor list
Modifies current code to use EM anchor list in EM allocation, EM free,
EM reset, exch allocation and exch lookup code paths.
1. Modifies fc_exch_mgr_alloc to accept EM match function and then
have allocated EM added to the lport using fc_exch_mgr_add API
while also updating EM kref for newly added EM.
2. Updates fc_exch_mgr_free API to accept only lport pointer instead
EM and then have this API free all EMs of the lport from EM anchor
list.
3. Removes single lport pointer link from the EM, which was used in
associating lport pointer in newly allocated exchange. Instead have
lport pointer passed along new exchange allocation call path and
then store passed lport pointer in newly allocated exchange, this
will allow a single EM instance to be used across more than one
lport and used in EM reset to reset only lport specific exchanges.
4. Modifies fc_exch_mgr_reset to reset all EMs from the EM anchor list
of the lport, adds additional exch lport pointer (ep->lp) check for
shared EM case to reset exchange specific to a lport requested reset.
5. Updates exch allocation API fc_exch_alloc to use EM anchor list and
its anchor match func pointer. The fc_exch_alloc will walk the list
of EMs until it finds a match, a match will be either null match
func pointer or call to match function returning true value.
6. Updates fc_exch_recv to accept incoming frame on local port using
only lport pointer and frame pointer without specifying EM instance
of incoming frame. Instead modified fc_exch_recv to locate EM for the
incoming frame by matching xid of incoming frame against a EM xid range.
This change was required to use EM list in libfc Rx path and after this
change the lport fc_exch_mgr pointer emp is not needed anymore, so
removed emp pointer.
7. Updates fnic for removed lport emp pointer and above modified libfc APIs
fc_exch_recv, fc_exch_mgr_alloc and fc_exch_mgr_free.
8. Removes exch_get and exch_put from libfc_function_template as these
are no longer needed with EM anchor list and its match function use.
Also removes its default function fc_exch_get.
A defect this patch introduced regarding the libfc initialization order in
the fnic driver was fixed by Joe Eykholt <jeykholt@cisco.com>.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-07-30 00:05:10 +00:00
|
|
|
f_ctl = ntoh24(fh->fh_f_ctl);
|
2011-01-29 00:04:39 +00:00
|
|
|
ema = fc_find_ema(f_ctl, lport, fh);
|
|
|
|
if (!ema) {
|
|
|
|
FC_LPORT_DBG(lport, "Unable to find Exchange Manager Anchor,"
|
|
|
|
"fc_ctl <0x%x>, xid <0x%x>\n",
|
|
|
|
f_ctl,
|
|
|
|
(f_ctl & FC_FC_EX_CTX) ?
|
|
|
|
ntohs(fh->fh_ox_id) :
|
|
|
|
ntohs(fh->fh_rx_id));
|
|
|
|
fc_frame_free(fp);
|
|
|
|
return;
|
|
|
|
}
|
[SCSI] fcoe, fnic, libfc: modifies current code paths to use EM anchor list
Modifies current code to use EM anchor list in EM allocation, EM free,
EM reset, exch allocation and exch lookup code paths.
1. Modifies fc_exch_mgr_alloc to accept EM match function and then
have allocated EM added to the lport using fc_exch_mgr_add API
while also updating EM kref for newly added EM.
2. Updates fc_exch_mgr_free API to accept only lport pointer instead
EM and then have this API free all EMs of the lport from EM anchor
list.
3. Removes single lport pointer link from the EM, which was used in
associating lport pointer in newly allocated exchange. Instead have
lport pointer passed along new exchange allocation call path and
then store passed lport pointer in newly allocated exchange, this
will allow a single EM instance to be used across more than one
lport and used in EM reset to reset only lport specific exchanges.
4. Modifies fc_exch_mgr_reset to reset all EMs from the EM anchor list
of the lport, adds additional exch lport pointer (ep->lp) check for
shared EM case to reset exchange specific to a lport requested reset.
5. Updates exch allocation API fc_exch_alloc to use EM anchor list and
its anchor match func pointer. The fc_exch_alloc will walk the list
of EMs until it finds a match, a match will be either null match
func pointer or call to match function returning true value.
6. Updates fc_exch_recv to accept incoming frame on local port using
only lport pointer and frame pointer without specifying EM instance
of incoming frame. Instead modified fc_exch_recv to locate EM for the
incoming frame by matching xid of incoming frame against a EM xid range.
This change was required to use EM list in libfc Rx path and after this
change the lport fc_exch_mgr pointer emp is not needed anymore, so
removed emp pointer.
7. Updates fnic for removed lport emp pointer and above modified libfc APIs
fc_exch_recv, fc_exch_mgr_alloc and fc_exch_mgr_free.
8. Removes exch_get and exch_put from libfc_function_template as these
are no longer needed with EM anchor list and its match function use.
Also removes its default function fc_exch_get.
A defect this patch introduced regarding the libfc initialization order in
the fnic driver was fixed by Joe Eykholt <jeykholt@cisco.com>.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-07-30 00:05:10 +00:00
|
|
|
|
2008-12-09 23:10:17 +00:00
|
|
|
/*
|
|
|
|
* If frame is marked invalid, just drop it.
|
|
|
|
*/
|
|
|
|
switch (fr_eof(fp)) {
|
|
|
|
case FC_EOF_T:
|
|
|
|
if (f_ctl & FC_FC_END_SEQ)
|
|
|
|
skb_trim(fp_skb(fp), fr_len(fp) - FC_FC_FILL(f_ctl));
|
|
|
|
/* fall through */
|
|
|
|
case FC_EOF_N:
|
|
|
|
if (fh->fh_type == FC_TYPE_BLS)
|
[SCSI] fcoe, fnic, libfc: modifies current code paths to use EM anchor list
Modifies current code to use EM anchor list in EM allocation, EM free,
EM reset, exch allocation and exch lookup code paths.
1. Modifies fc_exch_mgr_alloc to accept EM match function and then
have allocated EM added to the lport using fc_exch_mgr_add API
while also updating EM kref for newly added EM.
2. Updates fc_exch_mgr_free API to accept only lport pointer instead
EM and then have this API free all EMs of the lport from EM anchor
list.
3. Removes single lport pointer link from the EM, which was used in
associating lport pointer in newly allocated exchange. Instead have
lport pointer passed along new exchange allocation call path and
then store passed lport pointer in newly allocated exchange, this
will allow a single EM instance to be used across more than one
lport and used in EM reset to reset only lport specific exchanges.
4. Modifies fc_exch_mgr_reset to reset all EMs from the EM anchor list
of the lport, adds additional exch lport pointer (ep->lp) check for
shared EM case to reset exchange specific to a lport requested reset.
5. Updates exch allocation API fc_exch_alloc to use EM anchor list and
its anchor match func pointer. The fc_exch_alloc will walk the list
of EMs until it finds a match, a match will be either null match
func pointer or call to match function returning true value.
6. Updates fc_exch_recv to accept incoming frame on local port using
only lport pointer and frame pointer without specifying EM instance
of incoming frame. Instead modified fc_exch_recv to locate EM for the
incoming frame by matching xid of incoming frame against a EM xid range.
This change was required to use EM list in libfc Rx path and after this
change the lport fc_exch_mgr pointer emp is not needed anymore, so
removed emp pointer.
7. Updates fnic for removed lport emp pointer and above modified libfc APIs
fc_exch_recv, fc_exch_mgr_alloc and fc_exch_mgr_free.
8. Removes exch_get and exch_put from libfc_function_template as these
are no longer needed with EM anchor list and its match function use.
Also removes its default function fc_exch_get.
A defect this patch introduced regarding the libfc initialization order in
the fnic driver was fixed by Joe Eykholt <jeykholt@cisco.com>.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-07-30 00:05:10 +00:00
|
|
|
fc_exch_recv_bls(ema->mp, fp);
|
2008-12-09 23:10:17 +00:00
|
|
|
else if ((f_ctl & (FC_FC_EX_CTX | FC_FC_SEQ_CTX)) ==
|
|
|
|
FC_FC_EX_CTX)
|
[SCSI] fcoe, fnic, libfc: modifies current code paths to use EM anchor list
Modifies current code to use EM anchor list in EM allocation, EM free,
EM reset, exch allocation and exch lookup code paths.
1. Modifies fc_exch_mgr_alloc to accept EM match function and then
have allocated EM added to the lport using fc_exch_mgr_add API
while also updating EM kref for newly added EM.
2. Updates fc_exch_mgr_free API to accept only lport pointer instead
EM and then have this API free all EMs of the lport from EM anchor
list.
3. Removes single lport pointer link from the EM, which was used in
associating lport pointer in newly allocated exchange. Instead have
lport pointer passed along new exchange allocation call path and
then store passed lport pointer in newly allocated exchange, this
will allow a single EM instance to be used across more than one
lport and used in EM reset to reset only lport specific exchanges.
4. Modifies fc_exch_mgr_reset to reset all EMs from the EM anchor list
of the lport, adds additional exch lport pointer (ep->lp) check for
shared EM case to reset exchange specific to a lport requested reset.
5. Updates exch allocation API fc_exch_alloc to use EM anchor list and
its anchor match func pointer. The fc_exch_alloc will walk the list
of EMs until it finds a match, a match will be either null match
func pointer or call to match function returning true value.
6. Updates fc_exch_recv to accept incoming frame on local port using
only lport pointer and frame pointer without specifying EM instance
of incoming frame. Instead modified fc_exch_recv to locate EM for the
incoming frame by matching xid of incoming frame against a EM xid range.
This change was required to use EM list in libfc Rx path and after this
change the lport fc_exch_mgr pointer emp is not needed anymore, so
removed emp pointer.
7. Updates fnic for removed lport emp pointer and above modified libfc APIs
fc_exch_recv, fc_exch_mgr_alloc and fc_exch_mgr_free.
8. Removes exch_get and exch_put from libfc_function_template as these
are no longer needed with EM anchor list and its match function use.
Also removes its default function fc_exch_get.
A defect this patch introduced regarding the libfc initialization order in
the fnic driver was fixed by Joe Eykholt <jeykholt@cisco.com>.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-07-30 00:05:10 +00:00
|
|
|
fc_exch_recv_seq_resp(ema->mp, fp);
|
2008-12-09 23:10:17 +00:00
|
|
|
else if (f_ctl & FC_FC_SEQ_CTX)
|
[SCSI] fcoe, fnic, libfc: modifies current code paths to use EM anchor list
Modifies current code to use EM anchor list in EM allocation, EM free,
EM reset, exch allocation and exch lookup code paths.
1. Modifies fc_exch_mgr_alloc to accept EM match function and then
have allocated EM added to the lport using fc_exch_mgr_add API
while also updating EM kref for newly added EM.
2. Updates fc_exch_mgr_free API to accept only lport pointer instead
EM and then have this API free all EMs of the lport from EM anchor
list.
3. Removes single lport pointer link from the EM, which was used in
associating lport pointer in newly allocated exchange. Instead have
lport pointer passed along new exchange allocation call path and
then store passed lport pointer in newly allocated exchange, this
will allow a single EM instance to be used across more than one
lport and used in EM reset to reset only lport specific exchanges.
4. Modifies fc_exch_mgr_reset to reset all EMs from the EM anchor list
of the lport, adds additional exch lport pointer (ep->lp) check for
shared EM case to reset exchange specific to a lport requested reset.
5. Updates exch allocation API fc_exch_alloc to use EM anchor list and
its anchor match func pointer. The fc_exch_alloc will walk the list
of EMs until it finds a match, a match will be either null match
func pointer or call to match function returning true value.
6. Updates fc_exch_recv to accept incoming frame on local port using
only lport pointer and frame pointer without specifying EM instance
of incoming frame. Instead modified fc_exch_recv to locate EM for the
incoming frame by matching xid of incoming frame against a EM xid range.
This change was required to use EM list in libfc Rx path and after this
change the lport fc_exch_mgr pointer emp is not needed anymore, so
removed emp pointer.
7. Updates fnic for removed lport emp pointer and above modified libfc APIs
fc_exch_recv, fc_exch_mgr_alloc and fc_exch_mgr_free.
8. Removes exch_get and exch_put from libfc_function_template as these
are no longer needed with EM anchor list and its match function use.
Also removes its default function fc_exch_get.
A defect this patch introduced regarding the libfc initialization order in
the fnic driver was fixed by Joe Eykholt <jeykholt@cisco.com>.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-07-30 00:05:10 +00:00
|
|
|
fc_exch_recv_resp(ema->mp, fp);
|
2010-07-20 22:21:12 +00:00
|
|
|
else /* no EX_CTX and no SEQ_CTX */
|
2009-11-03 19:47:39 +00:00
|
|
|
fc_exch_recv_req(lport, ema->mp, fp);
|
2008-12-09 23:10:17 +00:00
|
|
|
break;
|
|
|
|
default:
|
2009-11-03 19:47:39 +00:00
|
|
|
FC_LPORT_DBG(lport, "dropping invalid frame (eof %x)",
|
|
|
|
fr_eof(fp));
|
2008-12-09 23:10:17 +00:00
|
|
|
fc_frame_free(fp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(fc_exch_recv);
|
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
/**
|
|
|
|
* fc_exch_init() - Initialize the exchange layer for a local port
|
|
|
|
* @lport: The local port to initialize the exchange layer for
|
|
|
|
*/
|
|
|
|
int fc_exch_init(struct fc_lport *lport)
|
2008-12-09 23:10:17 +00:00
|
|
|
{
|
2009-11-03 19:47:39 +00:00
|
|
|
if (!lport->tt.exch_mgr_reset)
|
|
|
|
lport->tt.exch_mgr_reset = fc_exch_mgr_reset;
|
2008-12-09 23:10:17 +00:00
|
|
|
|
2011-01-29 00:04:34 +00:00
|
|
|
if (!lport->tt.seq_release)
|
|
|
|
lport->tt.seq_release = fc_seq_release;
|
|
|
|
|
2009-10-21 23:27:28 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(fc_exch_init);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* fc_setup_exch_mgr() - Setup an exchange manager
|
|
|
|
*/
|
2011-01-29 00:03:57 +00:00
|
|
|
int fc_setup_exch_mgr(void)
|
2009-10-21 23:27:28 +00:00
|
|
|
{
|
|
|
|
fc_em_cachep = kmem_cache_create("libfc_em", sizeof(struct fc_exch),
|
|
|
|
0, SLAB_HWCACHE_ALIGN, NULL);
|
|
|
|
if (!fc_em_cachep)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
[SCSI] fcoe, libfc: adds per cpu exch pool within exchange manager(EM)
Adds per cpu exch pool for these reasons:-
1. Currently an EM instance is shared across all cpus to manage
all exches for all cpus. This required em_lock across all
cpus for an exch alloc, free, lookup and reset each frame
and that made em_lock expensive, so instead having per cpu
exch pool with their own per cpu pool lock will likely reduce
locking contention in fast path for an exch alloc, free and
lookup.
2. Per cpu exch pool will likely improve cache hit ratio since
all frames of an exch will be processed on the same cpu on
which exch originated.
This patch is only prep work to help in keeping complexity of next
patch low, so this patch only sets up per cpu exch pool and related
helper funcs to be used by next patch. The next patch fully makes
use of per cpu exch pool in all code paths ie. tx, rx and reset.
Divides per EM exch id range equally across all cpus to setup per
cpu exch pool. This division is such that lower bits of exch id
carries cpu number info on which exch originated, later a simple
bitwise AND operation on exch id of incoming frame with fc_cpu_mask
retrieves cpu number info to direct all frames to same cpu on which
exch originated. This required a global fc_cpu_mask and fc_cpu_order
initialized to max possible cpus number nr_cpu_ids rounded up to 2's
power, this will be used in mapping exch id and exch ptr array
index in pool during exch allocation, find or reset code paths.
Adds a check in fc_exch_mgr_alloc() to ensure specified min_xid
lower bits are zero since these bits are used to carry cpu info.
Adds and initializes struct fc_exch_pool with all required fields
to manage exches in pool.
Allocates per cpu struct fc_exch_pool with memory for exches array
for range of exches per pool. The exches array memory is followed
by struct fc_exch_pool.
Adds fc_exch_ptr_get/set() helper functions to get/set exch ptr in
pool exches array at specified array index.
Increases default FCOE_MAX_XID to 0x0FFF from 0x07EF, so that more
exches are available per cpu after above described exch id range
division across all cpus to each pool.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:47 +00:00
|
|
|
/*
|
|
|
|
* Initialize fc_cpu_mask and fc_cpu_order. The
|
|
|
|
* fc_cpu_mask is set for nr_cpu_ids rounded up
|
|
|
|
* to order of 2's * power and order is stored
|
|
|
|
* in fc_cpu_order as this is later required in
|
|
|
|
* mapping between an exch id and exch array index
|
|
|
|
* in per cpu exch pool.
|
|
|
|
*
|
|
|
|
* This round up is required to align fc_cpu_mask
|
|
|
|
* to exchange id's lower bits such that all incoming
|
|
|
|
* frames of an exchange gets delivered to the same
|
|
|
|
* cpu on which exchange originated by simple bitwise
|
|
|
|
* AND operation between fc_cpu_mask and exchange id.
|
|
|
|
*/
|
2013-08-14 15:33:35 +00:00
|
|
|
fc_cpu_order = ilog2(roundup_pow_of_two(nr_cpu_ids));
|
|
|
|
fc_cpu_mask = (1 << fc_cpu_order) - 1;
|
[SCSI] fcoe, libfc: adds per cpu exch pool within exchange manager(EM)
Adds per cpu exch pool for these reasons:-
1. Currently an EM instance is shared across all cpus to manage
all exches for all cpus. This required em_lock across all
cpus for an exch alloc, free, lookup and reset each frame
and that made em_lock expensive, so instead having per cpu
exch pool with their own per cpu pool lock will likely reduce
locking contention in fast path for an exch alloc, free and
lookup.
2. Per cpu exch pool will likely improve cache hit ratio since
all frames of an exch will be processed on the same cpu on
which exch originated.
This patch is only prep work to help in keeping complexity of next
patch low, so this patch only sets up per cpu exch pool and related
helper funcs to be used by next patch. The next patch fully makes
use of per cpu exch pool in all code paths ie. tx, rx and reset.
Divides per EM exch id range equally across all cpus to setup per
cpu exch pool. This division is such that lower bits of exch id
carries cpu number info on which exch originated, later a simple
bitwise AND operation on exch id of incoming frame with fc_cpu_mask
retrieves cpu number info to direct all frames to same cpu on which
exch originated. This required a global fc_cpu_mask and fc_cpu_order
initialized to max possible cpus number nr_cpu_ids rounded up to 2's
power, this will be used in mapping exch id and exch ptr array
index in pool during exch allocation, find or reset code paths.
Adds a check in fc_exch_mgr_alloc() to ensure specified min_xid
lower bits are zero since these bits are used to carry cpu info.
Adds and initializes struct fc_exch_pool with all required fields
to manage exches in pool.
Allocates per cpu struct fc_exch_pool with memory for exches array
for range of exches per pool. The exches array memory is followed
by struct fc_exch_pool.
Adds fc_exch_ptr_get/set() helper functions to get/set exch ptr in
pool exches array at specified array index.
Increases default FCOE_MAX_XID to 0x0FFF from 0x07EF, so that more
exches are available per cpu after above described exch id range
division across all cpus to each pool.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2009-08-25 20:58:47 +00:00
|
|
|
|
2009-11-03 19:50:10 +00:00
|
|
|
fc_exch_workqueue = create_singlethread_workqueue("fc_exch_workqueue");
|
|
|
|
if (!fc_exch_workqueue)
|
2011-07-27 22:10:34 +00:00
|
|
|
goto err;
|
2008-12-09 23:10:17 +00:00
|
|
|
return 0;
|
2011-07-27 22:10:34 +00:00
|
|
|
err:
|
|
|
|
kmem_cache_destroy(fc_em_cachep);
|
|
|
|
return -ENOMEM;
|
2008-12-09 23:10:17 +00:00
|
|
|
}
|
|
|
|
|
2009-11-03 19:47:39 +00:00
|
|
|
/**
|
|
|
|
* fc_destroy_exch_mgr() - Destroy an exchange manager
|
|
|
|
*/
|
2011-01-29 00:03:57 +00:00
|
|
|
void fc_destroy_exch_mgr(void)
|
2008-12-09 23:10:17 +00:00
|
|
|
{
|
2009-11-03 19:50:10 +00:00
|
|
|
destroy_workqueue(fc_exch_workqueue);
|
2008-12-09 23:10:17 +00:00
|
|
|
kmem_cache_destroy(fc_em_cachep);
|
|
|
|
}
|