diff options
author | Robert Love <robert.w.love@intel.com> | 2009-11-03 14:47:39 -0500 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2009-12-04 13:01:07 -0500 |
commit | 3a3b42bf89a9b90ae9ed2c57fdc378e5473a0ef9 (patch) | |
tree | 6d41d669a3c7b4a3bb5219ded856251c148e7ab6 | |
parent | a51ab39606042e76a483547620699530caa12c40 (diff) |
[SCSI] libfc: Formatting cleanups across libfc
This patch makes a variety of cleanup changes to all libfc files.
This patch adds kernel-doc headers to all functions lacking them
and attempts to better format existing headers. It also add kernel-doc
headers to structures.
This patch ensures that the current naming conventions for local ports,
remote ports and remote port private data is upheld in the following
manner.
struct instance (i.e. variable name)
--------------------------------------------------
fc_lport lport
fc_rport rport
fc_rport_libfc_priv rpriv
fc_rport_priv rdata
I also renamed dns_rp and ptp_rp to dns_rdata and ptp_rdata
respectively.
I used emacs 'indent-region' and 'tabify' on all libfc files
to correct spacing alignments.
I feel sorry for anyone attempting to review this patch.
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
-rw-r--r-- | drivers/scsi/libfc/fc_disc.c | 78 | ||||
-rw-r--r-- | drivers/scsi/libfc/fc_elsct.c | 33 | ||||
-rw-r--r-- | drivers/scsi/libfc/fc_exch.c | 587 | ||||
-rw-r--r-- | drivers/scsi/libfc/fc_fcp.c | 667 | ||||
-rw-r--r-- | drivers/scsi/libfc/fc_libfc.c | 4 | ||||
-rw-r--r-- | drivers/scsi/libfc/fc_libfc.h | 34 | ||||
-rw-r--r-- | drivers/scsi/libfc/fc_lport.c | 247 | ||||
-rw-r--r-- | drivers/scsi/libfc/fc_rport.c | 235 | ||||
-rw-r--r-- | include/scsi/libfc.h | 994 |
9 files changed, 1624 insertions, 1255 deletions
diff --git a/drivers/scsi/libfc/fc_disc.c b/drivers/scsi/libfc/fc_disc.c index a4bdec28fef5..7b790ad15a93 100644 --- a/drivers/scsi/libfc/fc_disc.c +++ b/drivers/scsi/libfc/fc_disc.c | |||
@@ -53,8 +53,8 @@ static int fc_disc_single(struct fc_lport *, struct fc_disc_port *); | |||
53 | static void fc_disc_restart(struct fc_disc *); | 53 | static void fc_disc_restart(struct fc_disc *); |
54 | 54 | ||
55 | /** | 55 | /** |
56 | * fc_disc_stop_rports() - delete all the remote ports associated with the lport | 56 | * fc_disc_stop_rports() - Delete all the remote ports associated with the lport |
57 | * @disc: The discovery job to stop rports on | 57 | * @disc: The discovery job to stop remote ports on |
58 | * | 58 | * |
59 | * Locking Note: This function expects that the lport mutex is locked before | 59 | * Locking Note: This function expects that the lport mutex is locked before |
60 | * calling it. | 60 | * calling it. |
@@ -74,9 +74,9 @@ void fc_disc_stop_rports(struct fc_disc *disc) | |||
74 | 74 | ||
75 | /** | 75 | /** |
76 | * fc_disc_recv_rscn_req() - Handle Registered State Change Notification (RSCN) | 76 | * fc_disc_recv_rscn_req() - Handle Registered State Change Notification (RSCN) |
77 | * @sp: Current sequence of the RSCN exchange | 77 | * @sp: The sequence of the RSCN exchange |
78 | * @fp: RSCN Frame | 78 | * @fp: The RSCN frame |
79 | * @lport: Fibre Channel host port instance | 79 | * @lport: The local port that the request will be sent on |
80 | * | 80 | * |
81 | * Locking Note: This function expects that the disc_mutex is locked | 81 | * Locking Note: This function expects that the disc_mutex is locked |
82 | * before it is called. | 82 | * before it is called. |
@@ -185,9 +185,9 @@ reject: | |||
185 | 185 | ||
186 | /** | 186 | /** |
187 | * fc_disc_recv_req() - Handle incoming requests | 187 | * fc_disc_recv_req() - Handle incoming requests |
188 | * @sp: Current sequence of the request exchange | 188 | * @sp: The sequence of the request exchange |
189 | * @fp: The frame | 189 | * @fp: The request frame |
190 | * @lport: The FC local port | 190 | * @lport: The local port receiving the request |
191 | * | 191 | * |
192 | * Locking Note: This function is called from the EM and will lock | 192 | * Locking Note: This function is called from the EM and will lock |
193 | * the disc_mutex before calling the handler for the | 193 | * the disc_mutex before calling the handler for the |
@@ -215,7 +215,7 @@ static void fc_disc_recv_req(struct fc_seq *sp, struct fc_frame *fp, | |||
215 | 215 | ||
216 | /** | 216 | /** |
217 | * fc_disc_restart() - Restart discovery | 217 | * fc_disc_restart() - Restart discovery |
218 | * @lport: FC discovery context | 218 | * @disc: The discovery object to be restarted |
219 | * | 219 | * |
220 | * Locking Note: This function expects that the disc mutex | 220 | * Locking Note: This function expects that the disc mutex |
221 | * is already locked. | 221 | * is already locked. |
@@ -242,9 +242,9 @@ static void fc_disc_restart(struct fc_disc *disc) | |||
242 | } | 242 | } |
243 | 243 | ||
244 | /** | 244 | /** |
245 | * fc_disc_start() - Fibre Channel Target discovery | 245 | * fc_disc_start() - Start discovery on a local port |
246 | * @lport: FC local port | 246 | * @lport: The local port to have discovery started on |
247 | * @disc_callback: function to be called when discovery is complete | 247 | * @disc_callback: Callback function to be called when discovery is complete |
248 | */ | 248 | */ |
249 | static void fc_disc_start(void (*disc_callback)(struct fc_lport *, | 249 | static void fc_disc_start(void (*disc_callback)(struct fc_lport *, |
250 | enum fc_disc_event), | 250 | enum fc_disc_event), |
@@ -265,8 +265,8 @@ static void fc_disc_start(void (*disc_callback)(struct fc_lport *, | |||
265 | 265 | ||
266 | /** | 266 | /** |
267 | * fc_disc_done() - Discovery has been completed | 267 | * fc_disc_done() - Discovery has been completed |
268 | * @disc: FC discovery context | 268 | * @disc: The discovery context |
269 | * @event: discovery completion status | 269 | * @event: The discovery completion status |
270 | * | 270 | * |
271 | * Locking Note: This function expects that the disc mutex is locked before | 271 | * Locking Note: This function expects that the disc mutex is locked before |
272 | * it is called. The discovery callback is then made with the lock released, | 272 | * it is called. The discovery callback is then made with the lock released, |
@@ -286,8 +286,8 @@ static void fc_disc_done(struct fc_disc *disc, enum fc_disc_event event) | |||
286 | } | 286 | } |
287 | 287 | ||
288 | /* | 288 | /* |
289 | * Go through all remote ports. If they were found in the latest | 289 | * Go through all remote ports. If they were found in the latest |
290 | * discovery, reverify or log them in. Otherwise, log them out. | 290 | * discovery, reverify or log them in. Otherwise, log them out. |
291 | * Skip ports which were never discovered. These are the dNS port | 291 | * Skip ports which were never discovered. These are the dNS port |
292 | * and ports which were created by PLOGI. | 292 | * and ports which were created by PLOGI. |
293 | */ | 293 | */ |
@@ -307,8 +307,8 @@ static void fc_disc_done(struct fc_disc *disc, enum fc_disc_event event) | |||
307 | 307 | ||
308 | /** | 308 | /** |
309 | * fc_disc_error() - Handle error on dNS request | 309 | * fc_disc_error() - Handle error on dNS request |
310 | * @disc: FC discovery context | 310 | * @disc: The discovery context |
311 | * @fp: The frame pointer | 311 | * @fp: The error code encoded as a frame pointer |
312 | */ | 312 | */ |
313 | static void fc_disc_error(struct fc_disc *disc, struct fc_frame *fp) | 313 | static void fc_disc_error(struct fc_disc *disc, struct fc_frame *fp) |
314 | { | 314 | { |
@@ -344,7 +344,7 @@ static void fc_disc_error(struct fc_disc *disc, struct fc_frame *fp) | |||
344 | 344 | ||
345 | /** | 345 | /** |
346 | * fc_disc_gpn_ft_req() - Send Get Port Names by FC-4 type (GPN_FT) request | 346 | * fc_disc_gpn_ft_req() - Send Get Port Names by FC-4 type (GPN_FT) request |
347 | * @lport: FC discovery context | 347 | * @lport: The discovery context |
348 | * | 348 | * |
349 | * Locking Note: This function expects that the disc_mutex is locked | 349 | * Locking Note: This function expects that the disc_mutex is locked |
350 | * before it is called. | 350 | * before it is called. |
@@ -378,9 +378,9 @@ err: | |||
378 | 378 | ||
379 | /** | 379 | /** |
380 | * fc_disc_gpn_ft_parse() - Parse the body of the dNS GPN_FT response. | 380 | * fc_disc_gpn_ft_parse() - Parse the body of the dNS GPN_FT response. |
381 | * @lport: Fibre Channel host port instance | 381 | * @lport: The local port the GPN_FT was received on |
382 | * @buf: GPN_FT response buffer | 382 | * @buf: The GPN_FT response buffer |
383 | * @len: size of response buffer | 383 | * @len: The size of response buffer |
384 | * | 384 | * |
385 | * Goes through the list of IDs and names resulting from a request. | 385 | * Goes through the list of IDs and names resulting from a request. |
386 | */ | 386 | */ |
@@ -479,10 +479,8 @@ static int fc_disc_gpn_ft_parse(struct fc_disc *disc, void *buf, size_t len) | |||
479 | } | 479 | } |
480 | 480 | ||
481 | /** | 481 | /** |
482 | * fc_disc_timeout() - Retry handler for the disc component | 482 | * fc_disc_timeout() - Handler for discovery timeouts |
483 | * @work: Structure holding disc obj that needs retry discovery | 483 | * @work: Structure holding discovery context that needs to retry discovery |
484 | * | ||
485 | * Handle retry of memory allocation for remote ports. | ||
486 | */ | 484 | */ |
487 | static void fc_disc_timeout(struct work_struct *work) | 485 | static void fc_disc_timeout(struct work_struct *work) |
488 | { | 486 | { |
@@ -496,9 +494,9 @@ static void fc_disc_timeout(struct work_struct *work) | |||
496 | 494 | ||
497 | /** | 495 | /** |
498 | * fc_disc_gpn_ft_resp() - Handle a response frame from Get Port Names (GPN_FT) | 496 | * fc_disc_gpn_ft_resp() - Handle a response frame from Get Port Names (GPN_FT) |
499 | * @sp: Current sequence of GPN_FT exchange | 497 | * @sp: The sequence that the GPN_FT response was received on |
500 | * @fp: response frame | 498 | * @fp: The GPN_FT response frame |
501 | * @lp_arg: Fibre Channel host port instance | 499 | * @lp_arg: The discovery context |
502 | * | 500 | * |
503 | * Locking Note: This function is called without disc mutex held, and | 501 | * Locking Note: This function is called without disc mutex held, and |
504 | * should do all its processing with the mutex held | 502 | * should do all its processing with the mutex held |
@@ -569,9 +567,9 @@ static void fc_disc_gpn_ft_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
569 | 567 | ||
570 | /** | 568 | /** |
571 | * fc_disc_gpn_id_resp() - Handle a response frame from Get Port Names (GPN_ID) | 569 | * fc_disc_gpn_id_resp() - Handle a response frame from Get Port Names (GPN_ID) |
572 | * @sp: exchange sequence | 570 | * @sp: The sequence the GPN_ID is on |
573 | * @fp: response frame | 571 | * @fp: The response frame |
574 | * @rdata_arg: remote port private data | 572 | * @rdata_arg: The remote port that sent the GPN_ID response |
575 | * | 573 | * |
576 | * Locking Note: This function is called without disc mutex held. | 574 | * Locking Note: This function is called without disc mutex held. |
577 | */ | 575 | */ |
@@ -639,7 +637,7 @@ out: | |||
639 | 637 | ||
640 | /** | 638 | /** |
641 | * fc_disc_gpn_id_req() - Send Get Port Names by ID (GPN_ID) request | 639 | * fc_disc_gpn_id_req() - Send Get Port Names by ID (GPN_ID) request |
642 | * @lport: local port | 640 | * @lport: The local port to initiate discovery on |
643 | * @rdata: remote port private data | 641 | * @rdata: remote port private data |
644 | * | 642 | * |
645 | * Locking Note: This function expects that the disc_mutex is locked | 643 | * Locking Note: This function expects that the disc_mutex is locked |
@@ -656,7 +654,7 @@ static int fc_disc_gpn_id_req(struct fc_lport *lport, | |||
656 | if (!fp) | 654 | if (!fp) |
657 | return -ENOMEM; | 655 | return -ENOMEM; |
658 | if (!lport->tt.elsct_send(lport, rdata->ids.port_id, fp, FC_NS_GPN_ID, | 656 | if (!lport->tt.elsct_send(lport, rdata->ids.port_id, fp, FC_NS_GPN_ID, |
659 | fc_disc_gpn_id_resp, rdata, lport->e_d_tov)) | 657 | fc_disc_gpn_id_resp, rdata, lport->e_d_tov)) |
660 | return -ENOMEM; | 658 | return -ENOMEM; |
661 | kref_get(&rdata->kref); | 659 | kref_get(&rdata->kref); |
662 | return 0; | 660 | return 0; |
@@ -664,8 +662,8 @@ static int fc_disc_gpn_id_req(struct fc_lport *lport, | |||
664 | 662 | ||
665 | /** | 663 | /** |
666 | * fc_disc_single() - Discover the directory information for a single target | 664 | * fc_disc_single() - Discover the directory information for a single target |
667 | * @lport: local port | 665 | * @lport: The local port the remote port is associated with |
668 | * @dp: The port to rediscover | 666 | * @dp: The port to rediscover |
669 | * | 667 | * |
670 | * Locking Note: This function expects that the disc_mutex is locked | 668 | * Locking Note: This function expects that the disc_mutex is locked |
671 | * before it is called. | 669 | * before it is called. |
@@ -683,7 +681,7 @@ static int fc_disc_single(struct fc_lport *lport, struct fc_disc_port *dp) | |||
683 | 681 | ||
684 | /** | 682 | /** |
685 | * fc_disc_stop() - Stop discovery for a given lport | 683 | * fc_disc_stop() - Stop discovery for a given lport |
686 | * @lport: The lport that discovery should stop for | 684 | * @lport: The local port that discovery should stop on |
687 | */ | 685 | */ |
688 | void fc_disc_stop(struct fc_lport *lport) | 686 | void fc_disc_stop(struct fc_lport *lport) |
689 | { | 687 | { |
@@ -697,7 +695,7 @@ void fc_disc_stop(struct fc_lport *lport) | |||
697 | 695 | ||
698 | /** | 696 | /** |
699 | * fc_disc_stop_final() - Stop discovery for a given lport | 697 | * fc_disc_stop_final() - Stop discovery for a given lport |
700 | * @lport: The lport that discovery should stop for | 698 | * @lport: The lport that discovery should stop on |
701 | * | 699 | * |
702 | * This function will block until discovery has been | 700 | * This function will block until discovery has been |
703 | * completely stopped and all rports have been deleted. | 701 | * completely stopped and all rports have been deleted. |
@@ -709,8 +707,8 @@ void fc_disc_stop_final(struct fc_lport *lport) | |||
709 | } | 707 | } |
710 | 708 | ||
711 | /** | 709 | /** |
712 | * fc_disc_init() - Initialize the discovery block | 710 | * fc_disc_init() - Initialize the discovery layer for a local port |
713 | * @lport: FC local port | 711 | * @lport: The local port that needs the discovery layer to be initialized |
714 | */ | 712 | */ |
715 | int fc_disc_init(struct fc_lport *lport) | 713 | int fc_disc_init(struct fc_lport *lport) |
716 | { | 714 | { |
diff --git a/drivers/scsi/libfc/fc_elsct.c b/drivers/scsi/libfc/fc_elsct.c index aae54fe3b299..01be43f80f34 100644 --- a/drivers/scsi/libfc/fc_elsct.c +++ b/drivers/scsi/libfc/fc_elsct.c | |||
@@ -28,17 +28,22 @@ | |||
28 | #include <scsi/libfc.h> | 28 | #include <scsi/libfc.h> |
29 | #include <scsi/fc_encode.h> | 29 | #include <scsi/fc_encode.h> |
30 | 30 | ||
31 | /* | 31 | /** |
32 | * fc_elsct_send - sends ELS/CT frame | 32 | * fc_elsct_send() - Send an ELS or CT frame |
33 | * @lport: The local port to send the frame on | ||
34 | * @did: The destination ID for the frame | ||
35 | * @fp: The frame to be sent | ||
36 | * @op: The operational code | ||
37 | * @resp: The callback routine when the response is received | ||
38 | * @arg: The argument to pass to the response callback routine | ||
39 | * @timer_msec: The timeout period for the frame (in msecs) | ||
33 | */ | 40 | */ |
34 | struct fc_seq *fc_elsct_send(struct fc_lport *lport, | 41 | struct fc_seq *fc_elsct_send(struct fc_lport *lport, u32 did, |
35 | u32 did, | 42 | struct fc_frame *fp, unsigned int op, |
36 | struct fc_frame *fp, | 43 | void (*resp)(struct fc_seq *, |
37 | unsigned int op, | 44 | struct fc_frame *, |
38 | void (*resp)(struct fc_seq *, | 45 | void *), |
39 | struct fc_frame *fp, | 46 | void *arg, u32 timer_msec) |
40 | void *arg), | ||
41 | void *arg, u32 timer_msec) | ||
42 | { | 47 | { |
43 | enum fc_rctl r_ctl; | 48 | enum fc_rctl r_ctl; |
44 | enum fc_fh_type fh_type; | 49 | enum fc_fh_type fh_type; |
@@ -65,6 +70,10 @@ struct fc_seq *fc_elsct_send(struct fc_lport *lport, | |||
65 | } | 70 | } |
66 | EXPORT_SYMBOL(fc_elsct_send); | 71 | EXPORT_SYMBOL(fc_elsct_send); |
67 | 72 | ||
73 | /** | ||
74 | * fc_elsct_init() - Initialize the ELS/CT layer | ||
75 | * @lport: The local port to initialize the ELS/CT layer for | ||
76 | */ | ||
68 | int fc_elsct_init(struct fc_lport *lport) | 77 | int fc_elsct_init(struct fc_lport *lport) |
69 | { | 78 | { |
70 | if (!lport->tt.elsct_send) | 79 | if (!lport->tt.elsct_send) |
@@ -75,8 +84,8 @@ int fc_elsct_init(struct fc_lport *lport) | |||
75 | EXPORT_SYMBOL(fc_elsct_init); | 84 | EXPORT_SYMBOL(fc_elsct_init); |
76 | 85 | ||
77 | /** | 86 | /** |
78 | * fc_els_resp_type() - return string describing ELS response for debug. | 87 | * fc_els_resp_type() - Return a string describing the ELS response |
79 | * @fp: frame pointer with possible error code. | 88 | * @fp: The frame pointer or possible error code |
80 | */ | 89 | */ |
81 | const char *fc_els_resp_type(struct fc_frame *fp) | 90 | const char *fc_els_resp_type(struct fc_frame *fp) |
82 | { | 91 | { |
diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c index 751a485685d9..0f45bb8521f1 100644 --- a/drivers/scsi/libfc/fc_exch.c +++ b/drivers/scsi/libfc/fc_exch.c | |||
@@ -37,7 +37,7 @@ | |||
37 | u16 fc_cpu_mask; /* cpu mask for possible cpus */ | 37 | u16 fc_cpu_mask; /* cpu mask for possible cpus */ |
38 | EXPORT_SYMBOL(fc_cpu_mask); | 38 | EXPORT_SYMBOL(fc_cpu_mask); |
39 | static u16 fc_cpu_order; /* 2's power to represent total possible cpus */ | 39 | static u16 fc_cpu_order; /* 2's power to represent total possible cpus */ |
40 | static struct kmem_cache *fc_em_cachep; /* cache for exchanges */ | 40 | static struct kmem_cache *fc_em_cachep; /* cache for exchanges */ |
41 | 41 | ||
42 | /* | 42 | /* |
43 | * Structure and function definitions for managing Fibre Channel Exchanges | 43 | * Structure and function definitions for managing Fibre Channel Exchanges |
@@ -52,34 +52,46 @@ static struct kmem_cache *fc_em_cachep; /* cache for exchanges */ | |||
52 | * fc_seq holds the state for an individual sequence. | 52 | * fc_seq holds the state for an individual sequence. |
53 | */ | 53 | */ |
54 | 54 | ||
55 | /* | 55 | /** |
56 | * Per cpu exchange pool | 56 | * struct fc_exch_pool - Per cpu exchange pool |
57 | * @next_index: Next possible free exchange index | ||
58 | * @total_exches: Total allocated exchanges | ||
59 | * @lock: Exch pool lock | ||
60 | * @ex_list: List of exchanges | ||
57 | * | 61 | * |
58 | * This structure manages per cpu exchanges in array of exchange pointers. | 62 | * This structure manages per cpu exchanges in array of exchange pointers. |
59 | * This array is allocated followed by struct fc_exch_pool memory for | 63 | * This array is allocated followed by struct fc_exch_pool memory for |
60 | * assigned range of exchanges to per cpu pool. | 64 | * assigned range of exchanges to per cpu pool. |
61 | */ | 65 | */ |
62 | struct fc_exch_pool { | 66 | struct fc_exch_pool { |
63 | u16 next_index; /* next possible free exchange index */ | 67 | u16 next_index; |
64 | u16 total_exches; /* total allocated exchanges */ | 68 | u16 total_exches; |
65 | spinlock_t lock; /* exch pool lock */ | 69 | spinlock_t lock; |
66 | struct list_head ex_list; /* allocated exchanges list */ | 70 | struct list_head ex_list; |
67 | }; | 71 | }; |
68 | 72 | ||
69 | /* | 73 | /** |
70 | * Exchange manager. | 74 | * struct fc_exch_mgr - The Exchange Manager (EM). |
75 | * @class: Default class for new sequences | ||
76 | * @kref: Reference counter | ||
77 | * @min_xid: Minimum exchange ID | ||
78 | * @max_xid: Maximum exchange ID | ||
79 | * @ep_pool: Reserved exchange pointers | ||
80 | * @pool_max_index: Max exch array index in exch pool | ||
81 | * @pool: Per cpu exch pool | ||
82 | * @stats: Statistics structure | ||
71 | * | 83 | * |
72 | * This structure is the center for creating exchanges and sequences. | 84 | * This structure is the center for creating exchanges and sequences. |
73 | * It manages the allocation of exchange IDs. | 85 | * It manages the allocation of exchange IDs. |
74 | */ | 86 | */ |
75 | struct fc_exch_mgr { | 87 | struct fc_exch_mgr { |
76 | enum fc_class class; /* default class for sequences */ | 88 | enum fc_class class; |
77 | struct kref kref; /* exchange mgr reference count */ | 89 | struct kref kref; |
78 | u16 min_xid; /* min exchange ID */ | 90 | u16 min_xid; |
79 | u16 max_xid; /* max exchange ID */ | 91 | u16 max_xid; |
80 | mempool_t *ep_pool; /* reserve ep's */ | 92 | mempool_t *ep_pool; |
81 | u16 pool_max_index; /* max exch array index in exch pool */ | 93 | u16 pool_max_index; |
82 | struct fc_exch_pool *pool; /* per cpu exch pool */ | 94 | struct fc_exch_pool *pool; |
83 | 95 | ||
84 | /* | 96 | /* |
85 | * currently exchange mgr stats are updated but not used. | 97 | * currently exchange mgr stats are updated but not used. |
@@ -97,6 +109,18 @@ struct fc_exch_mgr { | |||
97 | }; | 109 | }; |
98 | #define fc_seq_exch(sp) container_of(sp, struct fc_exch, seq) | 110 | #define fc_seq_exch(sp) container_of(sp, struct fc_exch, seq) |
99 | 111 | ||
112 | /** | ||
113 | * struct fc_exch_mgr_anchor - primary structure for list of EMs | ||
114 | * @ema_list: Exchange Manager Anchor list | ||
115 | * @mp: Exchange Manager associated with this anchor | ||
116 | * @match: Routine to determine if this anchor's EM should be used | ||
117 | * | ||
118 | * When walking the list of anchors the match routine will be called | ||
119 | * for each anchor to determine if that EM should be used. The last | ||
120 | * anchor in the list will always match to handle any exchanges not | ||
121 | * handled by other EMs. The non-default EMs would be added to the | ||
122 | * anchor list by HW that provides FCoE offloads. | ||
123 | */ | ||
100 | struct fc_exch_mgr_anchor { | 124 | struct fc_exch_mgr_anchor { |
101 | struct list_head ema_list; | 125 | struct list_head ema_list; |
102 | struct fc_exch_mgr *mp; | 126 | struct fc_exch_mgr *mp; |
@@ -196,6 +220,15 @@ static char *fc_exch_rctl_names[] = FC_RCTL_NAMES_INIT; | |||
196 | 220 | ||
197 | #define FC_TABLE_SIZE(x) (sizeof(x) / sizeof(x[0])) | 221 | #define FC_TABLE_SIZE(x) (sizeof(x) / sizeof(x[0])) |
198 | 222 | ||
223 | /** | ||
224 | * fc_exch_name_lookup() - Lookup name by opcode | ||
225 | * @op: Opcode to be looked up | ||
226 | * @table: Opcode/name table | ||
227 | * @max_index: Index not to be exceeded | ||
228 | * | ||
229 | * This routine is used to determine a human-readable string identifying | ||
230 | * a R_CTL opcode. | ||
231 | */ | ||
199 | static inline const char *fc_exch_name_lookup(unsigned int op, char **table, | 232 | static inline const char *fc_exch_name_lookup(unsigned int op, char **table, |
200 | unsigned int max_index) | 233 | unsigned int max_index) |
201 | { | 234 | { |
@@ -208,25 +241,34 @@ static inline const char *fc_exch_name_lookup(unsigned int op, char **table, | |||
208 | return name; | 241 | return name; |
209 | } | 242 | } |
210 | 243 | ||
244 | /** | ||
245 | * fc_exch_rctl_name() - Wrapper routine for fc_exch_name_lookup() | ||
246 | * @op: The opcode to be looked up | ||
247 | */ | ||
211 | static const char *fc_exch_rctl_name(unsigned int op) | 248 | static const char *fc_exch_rctl_name(unsigned int op) |
212 | { | 249 | { |
213 | return fc_exch_name_lookup(op, fc_exch_rctl_names, | 250 | return fc_exch_name_lookup(op, fc_exch_rctl_names, |
214 | FC_TABLE_SIZE(fc_exch_rctl_names)); | 251 | FC_TABLE_SIZE(fc_exch_rctl_names)); |
215 | } | 252 | } |
216 | 253 | ||
217 | /* | 254 | /** |
218 | * Hold an exchange - keep it from being freed. | 255 | * fc_exch_hold() - Increment an exchange's reference count |
256 | * @ep: Echange to be held | ||
219 | */ | 257 | */ |
220 | static void fc_exch_hold(struct fc_exch *ep) | 258 | static inline void fc_exch_hold(struct fc_exch *ep) |
221 | { | 259 | { |
222 | atomic_inc(&ep->ex_refcnt); | 260 | atomic_inc(&ep->ex_refcnt); |
223 | } | 261 | } |
224 | 262 | ||
225 | /* | 263 | /** |
226 | * setup fc hdr by initializing few more FC header fields and sof/eof. | 264 | * fc_exch_setup_hdr() - Initialize a FC header by initializing some fields |
227 | * Initialized fields by this func: | 265 | * and determine SOF and EOF. |
228 | * - fh_ox_id, fh_rx_id, fh_seq_id, fh_seq_cnt | 266 | * @ep: The exchange to that will use the header |
229 | * - sof and eof | 267 | * @fp: The frame whose header is to be modified |
268 | * @f_ctl: F_CTL bits that will be used for the frame header | ||
269 | * | ||
270 | * The fields initialized by this routine are: fh_ox_id, fh_rx_id, | ||
271 | * fh_seq_id, fh_seq_cnt and the SOF and EOF. | ||
230 | */ | 272 | */ |
231 | static void fc_exch_setup_hdr(struct fc_exch *ep, struct fc_frame *fp, | 273 | static void fc_exch_setup_hdr(struct fc_exch *ep, struct fc_frame *fp, |
232 | u32 f_ctl) | 274 | u32 f_ctl) |
@@ -243,7 +285,7 @@ static void fc_exch_setup_hdr(struct fc_exch *ep, struct fc_frame *fp, | |||
243 | if (fc_sof_needs_ack(ep->class)) | 285 | if (fc_sof_needs_ack(ep->class)) |
244 | fr_eof(fp) = FC_EOF_N; | 286 | fr_eof(fp) = FC_EOF_N; |
245 | /* | 287 | /* |
246 | * Form f_ctl. | 288 | * From F_CTL. |
247 | * The number of fill bytes to make the length a 4-byte | 289 | * The number of fill bytes to make the length a 4-byte |
248 | * multiple is the low order 2-bits of the f_ctl. | 290 | * multiple is the low order 2-bits of the f_ctl. |
249 | * The fill itself will have been cleared by the frame | 291 | * The fill itself will have been cleared by the frame |
@@ -273,9 +315,12 @@ static void fc_exch_setup_hdr(struct fc_exch *ep, struct fc_frame *fp, | |||
273 | fh->fh_seq_cnt = htons(ep->seq.cnt); | 315 | fh->fh_seq_cnt = htons(ep->seq.cnt); |
274 | } | 316 | } |
275 | 317 | ||
276 | /* | 318 | /** |
277 | * Release a reference to an exchange. | 319 | * fc_exch_release() - Decrement an exchange's reference count |
278 | * If the refcnt goes to zero and the exchange is complete, it is freed. | 320 | * @ep: Exchange to be released |
321 | * | ||
322 | * If the reference count reaches zero and the exchange is complete, | ||
323 | * it is freed. | ||
279 | */ | 324 | */ |
280 | static void fc_exch_release(struct fc_exch *ep) | 325 | static void fc_exch_release(struct fc_exch *ep) |
281 | { | 326 | { |
@@ -290,6 +335,10 @@ static void fc_exch_release(struct fc_exch *ep) | |||
290 | } | 335 | } |
291 | } | 336 | } |
292 | 337 | ||
338 | /** | ||
339 | * fc_exch_done_locked() - Complete an exchange with the exchange lock held | ||
340 | * @ep: The exchange that is complete | ||
341 | */ | ||
293 | static int fc_exch_done_locked(struct fc_exch *ep) | 342 | static int fc_exch_done_locked(struct fc_exch *ep) |
294 | { | 343 | { |
295 | int rc = 1; | 344 | int rc = 1; |
@@ -314,6 +363,15 @@ static int fc_exch_done_locked(struct fc_exch *ep) | |||
314 | return rc; | 363 | return rc; |
315 | } | 364 | } |
316 | 365 | ||
366 | /** | ||
367 | * fc_exch_ptr_get() - Return an exchange from an exchange pool | ||
368 | * @pool: Exchange Pool to get an exchange from | ||
369 | * @index: Index of the exchange within the pool | ||
370 | * | ||
371 | * Use the index to get an exchange from within an exchange pool. exches | ||
372 | * will point to an array of exchange pointers. The index will select | ||
373 | * the exchange within the array. | ||
374 | */ | ||
317 | static inline struct fc_exch *fc_exch_ptr_get(struct fc_exch_pool *pool, | 375 | static inline struct fc_exch *fc_exch_ptr_get(struct fc_exch_pool *pool, |
318 | u16 index) | 376 | u16 index) |
319 | { | 377 | { |
@@ -321,12 +379,22 @@ static inline struct fc_exch *fc_exch_ptr_get(struct fc_exch_pool *pool, | |||
321 | return exches[index]; | 379 | return exches[index]; |
322 | } | 380 | } |
323 | 381 | ||
382 | /** | ||
383 | * fc_exch_ptr_set() - Assign an exchange to a slot in an exchange pool | ||
384 | * @pool: The pool to assign the exchange to | ||
385 | * @index: The index in the pool where the exchange will be assigned | ||
386 | * @ep: The exchange to assign to the pool | ||
387 | */ | ||
324 | static inline void fc_exch_ptr_set(struct fc_exch_pool *pool, u16 index, | 388 | static inline void fc_exch_ptr_set(struct fc_exch_pool *pool, u16 index, |
325 | struct fc_exch *ep) | 389 | struct fc_exch *ep) |
326 | { | 390 | { |
327 | ((struct fc_exch **)(pool + 1))[index] = ep; | 391 | ((struct fc_exch **)(pool + 1))[index] = ep; |
328 | } | 392 | } |
329 | 393 | ||
394 | /** | ||
395 | * fc_exch_delete() - Delete an exchange | ||
396 | * @ep: The exchange to be deleted | ||
397 | */ | ||
330 | static void fc_exch_delete(struct fc_exch *ep) | 398 | static void fc_exch_delete(struct fc_exch *ep) |
331 | { | 399 | { |
332 | struct fc_exch_pool *pool; | 400 | struct fc_exch_pool *pool; |
@@ -342,8 +410,14 @@ static void fc_exch_delete(struct fc_exch *ep) | |||
342 | fc_exch_release(ep); /* drop hold for exch in mp */ | 410 | fc_exch_release(ep); /* drop hold for exch in mp */ |
343 | } | 411 | } |
344 | 412 | ||
345 | /* | 413 | /** |
346 | * Internal version of fc_exch_timer_set - used with lock held. | 414 | * fc_exch_timer_set_locked() - Start a timer for an exchange w/ the |
415 | * the exchange lock held | ||
416 | * @ep: The exchange whose timer will start | ||
417 | * @timer_msec: The timeout period | ||
418 | * | ||
419 | * Used for upper level protocols to time out the exchange. | ||
420 | * The timer is cancelled when it fires or when the exchange completes. | ||
347 | */ | 421 | */ |
348 | static inline void fc_exch_timer_set_locked(struct fc_exch *ep, | 422 | static inline void fc_exch_timer_set_locked(struct fc_exch *ep, |
349 | unsigned int timer_msec) | 423 | unsigned int timer_msec) |
@@ -358,12 +432,10 @@ static inline void fc_exch_timer_set_locked(struct fc_exch *ep, | |||
358 | fc_exch_hold(ep); /* hold for timer */ | 432 | fc_exch_hold(ep); /* hold for timer */ |
359 | } | 433 | } |
360 | 434 | ||
361 | /* | 435 | /** |
362 | * Set timer for an exchange. | 436 | * fc_exch_timer_set() - Lock the exchange and set the timer |
363 | * The time is a minimum delay in milliseconds until the timer fires. | 437 | * @ep: The exchange whose timer will start |
364 | * Used for upper level protocols to time out the exchange. | 438 | * @timer_msec: The timeout period |
365 | * The timer is cancelled when it fires or when the exchange completes. | ||
366 | * Returns non-zero if a timer couldn't be allocated. | ||
367 | */ | 439 | */ |
368 | static void fc_exch_timer_set(struct fc_exch *ep, unsigned int timer_msec) | 440 | static void fc_exch_timer_set(struct fc_exch *ep, unsigned int timer_msec) |
369 | { | 441 | { |
@@ -373,15 +445,18 @@ static void fc_exch_timer_set(struct fc_exch *ep, unsigned int timer_msec) | |||
373 | } | 445 | } |
374 | 446 | ||
375 | /** | 447 | /** |
376 | * send a frame using existing sequence and exchange. | 448 | * fc_seq_send() - Send a frame using existing sequence/exchange pair |
449 | * @lport: The local port that the exchange will be sent on | ||
450 | * @sp: The sequence to be sent | ||
451 | * @fp: The frame to be sent on the exchange | ||
377 | */ | 452 | */ |
378 | static int fc_seq_send(struct fc_lport *lp, struct fc_seq *sp, | 453 | static int fc_seq_send(struct fc_lport *lport, struct fc_seq *sp, |
379 | struct fc_frame *fp) | 454 | struct fc_frame *fp) |
380 | { | 455 | { |
381 | struct fc_exch *ep; | 456 | struct fc_exch *ep; |
382 | struct fc_frame_header *fh = fc_frame_header_get(fp); | 457 | struct fc_frame_header *fh = fc_frame_header_get(fp); |
383 | int error; | 458 | int error; |
384 | u32 f_ctl; | 459 | u32 f_ctl; |
385 | 460 | ||
386 | ep = fc_seq_exch(sp); | 461 | ep = fc_seq_exch(sp); |
387 | WARN_ON((ep->esb_stat & ESB_ST_SEQ_INIT) != ESB_ST_SEQ_INIT); | 462 | WARN_ON((ep->esb_stat & ESB_ST_SEQ_INIT) != ESB_ST_SEQ_INIT); |
@@ -403,7 +478,7 @@ static int fc_seq_send(struct fc_lport *lp, struct fc_seq *sp, | |||
403 | /* | 478 | /* |
404 | * Send the frame. | 479 | * Send the frame. |
405 | */ | 480 | */ |
406 | error = lp->tt.frame_send(lp, fp); | 481 | error = lport->tt.frame_send(lport, fp); |
407 | 482 | ||
408 | /* | 483 | /* |
409 | * Update the exchange and sequence flags, | 484 | * Update the exchange and sequence flags, |
@@ -419,9 +494,9 @@ static int fc_seq_send(struct fc_lport *lp, struct fc_seq *sp, | |||
419 | } | 494 | } |
420 | 495 | ||
421 | /** | 496 | /** |
422 | * fc_seq_alloc() - Allocate a sequence. | 497 | * fc_seq_alloc() - Allocate a sequence for a given exchange |
423 | * @ep: Exchange pointer | 498 | * @ep: The exchange to allocate a new sequence for |
424 | * @seq_id: Sequence ID to allocate a sequence for | 499 | * @seq_id: The sequence ID to be used |
425 | * | 500 | * |
426 | * We don't support multiple originated sequences on the same exchange. | 501 | * We don't support multiple originated sequences on the same exchange. |
427 | * By implication, any previously originated sequence on this exchange | 502 | * By implication, any previously originated sequence on this exchange |
@@ -438,6 +513,11 @@ static struct fc_seq *fc_seq_alloc(struct fc_exch *ep, u8 seq_id) | |||
438 | return sp; | 513 | return sp; |
439 | } | 514 | } |
440 | 515 | ||
516 | /** | ||
517 | * fc_seq_start_next_locked() - Allocate a new sequence on the same | ||
518 | * exchange as the supplied sequence | ||
519 | * @sp: The sequence/exchange to get a new sequence for | ||
520 | */ | ||
441 | static struct fc_seq *fc_seq_start_next_locked(struct fc_seq *sp) | 521 | static struct fc_seq *fc_seq_start_next_locked(struct fc_seq *sp) |
442 | { | 522 | { |
443 | struct fc_exch *ep = fc_seq_exch(sp); | 523 | struct fc_exch *ep = fc_seq_exch(sp); |
@@ -449,8 +529,9 @@ static struct fc_seq *fc_seq_start_next_locked(struct fc_seq *sp) | |||
449 | } | 529 | } |
450 | 530 | ||
451 | /** | 531 | /** |
452 | * Allocate a new sequence on the same exchange as the supplied sequence. | 532 | * fc_seq_start_next() - Lock the exchange and get a new sequence |
453 | * This will never return NULL. | 533 | * for a given sequence/exchange pair |
534 | * @sp: The sequence/exchange to get a new exchange for | ||
454 | */ | 535 | */ |
455 | static struct fc_seq *fc_seq_start_next(struct fc_seq *sp) | 536 | static struct fc_seq *fc_seq_start_next(struct fc_seq *sp) |
456 | { | 537 | { |
@@ -464,9 +545,11 @@ static struct fc_seq *fc_seq_start_next(struct fc_seq *sp) | |||
464 | } | 545 | } |
465 | 546 | ||
466 | /** | 547 | /** |
467 | * This function is for seq_exch_abort function pointer in | 548 | * fc_seq_exch_abort() - Abort an exchange and sequence |
468 | * struct libfc_function_template, see comment block on | 549 | * @req_sp: The sequence to be aborted |
469 | * seq_exch_abort for description of this function. | 550 | * @timer_msec: The period of time to wait before aborting |
551 | * | ||
552 | * Generally called because of a timeout or an abort from the upper layer. | ||
470 | */ | 553 | */ |
471 | static int fc_seq_exch_abort(const struct fc_seq *req_sp, | 554 | static int fc_seq_exch_abort(const struct fc_seq *req_sp, |
472 | unsigned int timer_msec) | 555 | unsigned int timer_msec) |
@@ -519,9 +602,9 @@ static int fc_seq_exch_abort(const struct fc_seq *req_sp, | |||
519 | return error; | 602 | return error; |
520 | } | 603 | } |
521 | 604 | ||
522 | /* | 605 | /** |
523 | * Exchange timeout - handle exchange timer expiration. | 606 | * fc_exch_timeout() - Handle exchange timer expiration |
524 | * The timer will have been cancelled before this is called. | 607 | * @work: The work_struct identifying the exchange that timed out |
525 | */ | 608 | */ |
526 | static void fc_exch_timeout(struct work_struct *work) | 609 | static void fc_exch_timeout(struct work_struct *work) |
527 | { | 610 | { |
@@ -570,9 +653,9 @@ done: | |||
570 | } | 653 | } |
571 | 654 | ||
572 | /** | 655 | /** |
573 | * fc_exch_em_alloc() - allocate an exchange from a specified EM. | 656 | * fc_exch_em_alloc() - Allocate an exchange from a specified EM. |
574 | * @lport: ptr to the local port | 657 | * @lport: The local port that the exchange is for |
575 | * @mp: ptr to the exchange manager | 658 | * @mp: The exchange manager that will allocate the exchange |
576 | * | 659 | * |
577 | * Returns pointer to allocated fc_exch with exch lock held. | 660 | * Returns pointer to allocated fc_exch with exch lock held. |
578 | */ | 661 | */ |
@@ -640,14 +723,15 @@ err: | |||
640 | } | 723 | } |
641 | 724 | ||
642 | /** | 725 | /** |
643 | * fc_exch_alloc() - allocate an exchange. | 726 | * fc_exch_alloc() - Allocate an exchange from an EM on a |
644 | * @lport: ptr to the local port | 727 | * local port's list of EMs. |
645 | * @fp: ptr to the FC frame | 728 | * @lport: The local port that will own the exchange |
729 | * @fp: The FC frame that the exchange will be for | ||
646 | * | 730 | * |
647 | * This function walks the list of the exchange manager(EM) | 731 | * This function walks the list of exchange manager(EM) |
648 | * anchors to select a EM for new exchange allocation. The | 732 | * anchors to select an EM for a new exchange allocation. The |
649 | * EM is selected having either a NULL match function pointer | 733 | * EM is selected when a NULL match function pointer is encountered |
650 | * or call to match function returning true. | 734 | * or when a call to a match function returns true. |
651 | */ | 735 | */ |
652 | static struct fc_exch *fc_exch_alloc(struct fc_lport *lport, | 736 | static struct fc_exch *fc_exch_alloc(struct fc_lport *lport, |
653 | struct fc_frame *fp) | 737 | struct fc_frame *fp) |
@@ -665,8 +749,10 @@ static struct fc_exch *fc_exch_alloc(struct fc_lport *lport, | |||
665 | return NULL; | 749 | return NULL; |
666 | } | 750 | } |
667 | 751 | ||
668 | /* | 752 | /** |
669 | * Lookup and hold an exchange. | 753 | * fc_exch_find() - Lookup and hold an exchange |
754 | * @mp: The exchange manager to lookup the exchange from | ||
755 | * @xid: The XID of the exchange to look up | ||
670 | */ | 756 | */ |
671 | static struct fc_exch *fc_exch_find(struct fc_exch_mgr *mp, u16 xid) | 757 | static struct fc_exch *fc_exch_find(struct fc_exch_mgr *mp, u16 xid) |
672 | { | 758 | { |
@@ -689,8 +775,8 @@ static struct fc_exch *fc_exch_find(struct fc_exch_mgr *mp, u16 xid) | |||
689 | 775 | ||
690 | /** | 776 | /** |
691 | * fc_exch_done() - Indicate that an exchange/sequence tuple is complete and | 777 | * fc_exch_done() - Indicate that an exchange/sequence tuple is complete and |
692 | * the memory allocated for the related objects may be freed. | 778 | * the memory allocated for the related objects may be freed. |
693 | * @sp: Sequence pointer | 779 | * @sp: The sequence that has completed |
694 | */ | 780 | */ |
695 | static void fc_exch_done(struct fc_seq *sp) | 781 | static void fc_exch_done(struct fc_seq *sp) |
696 | { | 782 | { |
@@ -704,8 +790,12 @@ static void fc_exch_done(struct fc_seq *sp) | |||
704 | fc_exch_delete(ep); | 790 | fc_exch_delete(ep); |
705 | } | 791 | } |
706 | 792 | ||
707 | /* | 793 | /** |
708 | * Allocate a new exchange as responder. | 794 | * fc_exch_resp() - Allocate a new exchange for a response frame |
795 | * @lport: The local port that the exchange was for | ||
796 | * @mp: The exchange manager to allocate the exchange from | ||
797 | * @fp: The response frame | ||
798 | * | ||
709 | * Sets the responder ID in the frame header. | 799 | * Sets the responder ID in the frame header. |
710 | */ | 800 | */ |
711 | static struct fc_exch *fc_exch_resp(struct fc_lport *lport, | 801 | static struct fc_exch *fc_exch_resp(struct fc_lport *lport, |
@@ -746,8 +836,13 @@ static struct fc_exch *fc_exch_resp(struct fc_lport *lport, | |||
746 | return ep; | 836 | return ep; |
747 | } | 837 | } |
748 | 838 | ||
749 | /* | 839 | /** |
750 | * Find a sequence for receive where the other end is originating the sequence. | 840 | * fc_seq_lookup_recip() - Find a sequence where the other end |
841 | * originated the sequence | ||
842 | * @lport: The local port that the frame was sent to | ||
843 | * @mp: The Exchange Manager to lookup the exchange from | ||
844 | * @fp: The frame associated with the sequence we're looking for | ||
845 | * | ||
751 | * If fc_pf_rjt_reason is FC_RJT_NONE then this function will have a hold | 846 | * If fc_pf_rjt_reason is FC_RJT_NONE then this function will have a hold |
752 | * on the ep that should be released by the caller. | 847 | * on the ep that should be released by the caller. |
753 | */ | 848 | */ |
@@ -853,10 +948,12 @@ rel: | |||
853 | return reject; | 948 | return reject; |
854 | } | 949 | } |
855 | 950 | ||
856 | /* | 951 | /** |
857 | * Find the sequence for a frame being received. | 952 | * fc_seq_lookup_orig() - Find a sequence where this end |
858 | * We originated the sequence, so it should be found. | 953 | * originated the sequence |
859 | * We may or may not have originated the exchange. | 954 | * @mp: The Exchange Manager to lookup the exchange from |
955 | * @fp: The frame associated with the sequence we're looking for | ||
956 | * | ||
860 | * Does not hold the sequence for the caller. | 957 | * Does not hold the sequence for the caller. |
861 | */ | 958 | */ |
862 | static struct fc_seq *fc_seq_lookup_orig(struct fc_exch_mgr *mp, | 959 | static struct fc_seq *fc_seq_lookup_orig(struct fc_exch_mgr *mp, |
@@ -888,8 +985,12 @@ static struct fc_seq *fc_seq_lookup_orig(struct fc_exch_mgr *mp, | |||
888 | return sp; | 985 | return sp; |
889 | } | 986 | } |
890 | 987 | ||
891 | /* | 988 | /** |
892 | * Set addresses for an exchange. | 989 | * fc_exch_set_addr() - Set the source and destination IDs for an exchange |
990 | * @ep: The exchange to set the addresses for | ||
991 | * @orig_id: The originator's ID | ||
992 | * @resp_id: The responder's ID | ||
993 | * | ||
893 | * Note this must be done before the first sequence of the exchange is sent. | 994 | * Note this must be done before the first sequence of the exchange is sent. |
894 | */ | 995 | */ |
895 | static void fc_exch_set_addr(struct fc_exch *ep, | 996 | static void fc_exch_set_addr(struct fc_exch *ep, |
@@ -906,11 +1007,11 @@ static void fc_exch_set_addr(struct fc_exch *ep, | |||
906 | } | 1007 | } |
907 | 1008 | ||
908 | /** | 1009 | /** |
909 | * fc_seq_els_rsp_send() - Send ELS response using mainly infomation | 1010 | * fc_seq_els_rsp_send() - Send an ELS response using infomation from |
910 | * in exchange and sequence in EM layer. | 1011 | * the existing sequence/exchange. |
911 | * @sp: Sequence pointer | 1012 | * @sp: The sequence/exchange to get information from |
912 | * @els_cmd: ELS command | 1013 | * @els_cmd: The ELS command to be sent |
913 | * @els_data: ELS data | 1014 | * @els_data: The ELS data to be sent |
914 | */ | 1015 | */ |
915 | static void fc_seq_els_rsp_send(struct fc_seq *sp, enum fc_els_cmd els_cmd, | 1016 | static void fc_seq_els_rsp_send(struct fc_seq *sp, enum fc_els_cmd els_cmd, |
916 | struct fc_seq_els_data *els_data) | 1017 | struct fc_seq_els_data *els_data) |
@@ -933,8 +1034,12 @@ static void fc_seq_els_rsp_send(struct fc_seq *sp, enum fc_els_cmd els_cmd, | |||
933 | } | 1034 | } |
934 | } | 1035 | } |
935 | 1036 | ||
936 | /* | 1037 | /** |
937 | * Send a sequence, which is also the last sequence in the exchange. | 1038 | * fc_seq_send_last() - Send a sequence that is the last in the exchange |
1039 | * @sp: The sequence that is to be sent | ||
1040 | * @fp: The frame that will be sent on the sequence | ||
1041 | * @rctl: The R_CTL information to be sent | ||
1042 | * @fh_type: The frame header type | ||
938 | */ | 1043 | */ |
939 | static void fc_seq_send_last(struct fc_seq *sp, struct fc_frame *fp, | 1044 | static void fc_seq_send_last(struct fc_seq *sp, struct fc_frame *fp, |
940 | enum fc_rctl rctl, enum fc_fh_type fh_type) | 1045 | enum fc_rctl rctl, enum fc_fh_type fh_type) |
@@ -948,9 +1053,12 @@ static void fc_seq_send_last(struct fc_seq *sp, struct fc_frame *fp, | |||
948 | fc_seq_send(ep->lp, sp, fp); | 1053 | fc_seq_send(ep->lp, sp, fp); |
949 | } | 1054 | } |
950 | 1055 | ||
951 | /* | 1056 | /** |
1057 | * fc_seq_send_ack() - Send an acknowledgement that we've received a frame | ||
1058 | * @sp: The sequence to send the ACK on | ||
1059 | * @rx_fp: The received frame that is being acknoledged | ||
1060 | * | ||
952 | * Send ACK_1 (or equiv.) indicating we received something. | 1061 | * Send ACK_1 (or equiv.) indicating we received something. |
953 | * The frame we're acking is supplied. | ||
954 | */ | 1062 | */ |
955 | static void fc_seq_send_ack(struct fc_seq *sp, const struct fc_frame *rx_fp) | 1063 | static void fc_seq_send_ack(struct fc_seq *sp, const struct fc_frame *rx_fp) |
956 | { | 1064 | { |
@@ -958,14 +1066,14 @@ static void fc_seq_send_ack(struct fc_seq *sp, const struct fc_frame *rx_fp) | |||
958 | struct fc_frame_header *rx_fh; | 1066 | struct fc_frame_header *rx_fh; |
959 | struct fc_frame_header *fh; | 1067 | struct fc_frame_header *fh; |
960 | struct fc_exch *ep = fc_seq_exch(sp); | 1068 | struct fc_exch *ep = fc_seq_exch(sp); |
961 | struct fc_lport *lp = ep->lp; | 1069 | struct fc_lport *lport = ep->lp; |
962 | unsigned int f_ctl; | 1070 | unsigned int f_ctl; |
963 | 1071 | ||
964 | /* | 1072 | /* |
965 | * Don't send ACKs for class 3. | 1073 | * Don't send ACKs for class 3. |
966 | */ | 1074 | */ |
967 | if (fc_sof_needs_ack(fr_sof(rx_fp))) { | 1075 | if (fc_sof_needs_ack(fr_sof(rx_fp))) { |
968 | fp = fc_frame_alloc(lp, 0); | 1076 | fp = fc_frame_alloc(lport, 0); |
969 | if (!fp) | 1077 | if (!fp) |
970 | return; | 1078 | return; |
971 | 1079 | ||
@@ -1000,12 +1108,16 @@ static void fc_seq_send_ack(struct fc_seq *sp, const struct fc_frame *rx_fp) | |||
1000 | else | 1108 | else |
1001 | fr_eof(fp) = FC_EOF_N; | 1109 | fr_eof(fp) = FC_EOF_N; |
1002 | 1110 | ||
1003 | (void) lp->tt.frame_send(lp, fp); | 1111 | lport->tt.frame_send(lport, fp); |
1004 | } | 1112 | } |
1005 | } | 1113 | } |
1006 | 1114 | ||
1007 | /* | 1115 | /** |
1008 | * Send BLS Reject. | 1116 | * fc_exch_send_ba_rjt() - Send BLS Reject |
1117 | * @rx_fp: The frame being rejected | ||
1118 | * @reason: The reason the frame is being rejected | ||
1119 | * @explan: The explaination for the rejection | ||
1120 | * | ||
1009 | * This is for rejecting BA_ABTS only. | 1121 | * This is for rejecting BA_ABTS only. |
1010 | */ | 1122 | */ |
1011 | static void fc_exch_send_ba_rjt(struct fc_frame *rx_fp, | 1123 | static void fc_exch_send_ba_rjt(struct fc_frame *rx_fp, |
@@ -1016,11 +1128,11 @@ static void fc_exch_send_ba_rjt(struct fc_frame *rx_fp, | |||
1016 | struct fc_frame_header *rx_fh; | 1128 | struct fc_frame_header *rx_fh; |
1017 | struct fc_frame_header *fh; | 1129 | struct fc_frame_header *fh; |
1018 | struct fc_ba_rjt *rp; | 1130 | struct fc_ba_rjt *rp; |
1019 | struct fc_lport *lp; | 1131 | struct fc_lport *lport; |
1020 | unsigned int f_ctl; | 1132 | unsigned int f_ctl; |
1021 | 1133 | ||
1022 | lp = fr_dev(rx_fp); | 1134 | lport = fr_dev(rx_fp); |
1023 | fp = fc_frame_alloc(lp, sizeof(*rp)); | 1135 | fp = fc_frame_alloc(lport, sizeof(*rp)); |
1024 | if (!fp) | 1136 | if (!fp) |
1025 | return; | 1137 | return; |
1026 | fh = fc_frame_header_get(fp); | 1138 | fh = fc_frame_header_get(fp); |
@@ -1065,13 +1177,17 @@ static void fc_exch_send_ba_rjt(struct fc_frame *rx_fp, | |||
1065 | if (fc_sof_needs_ack(fr_sof(fp))) | 1177 | if (fc_sof_needs_ack(fr_sof(fp))) |
1066 | fr_eof(fp) = FC_EOF_N; | 1178 | fr_eof(fp) = FC_EOF_N; |
1067 | 1179 | ||
1068 | (void) lp->tt.frame_send(lp, fp); | 1180 | lport->tt.frame_send(lport, fp); |
1069 | } | 1181 | } |
1070 | 1182 | ||
1071 | /* | 1183 | /** |
1072 | * Handle an incoming ABTS. This would be for target mode usually, | 1184 | * fc_exch_recv_abts() - Handle an incoming ABTS |
1073 | * but could be due to lost FCP transfer ready, confirm or RRQ. | 1185 | * @ep: The exchange the abort was on |
1074 | * We always handle this as an exchange abort, ignoring the parameter. | 1186 | * @rx_fp: The ABTS frame |
1187 | * | ||
1188 | * This would be for target mode usually, but could be due to lost | ||
1189 | * FCP transfer ready, confirm or RRQ. We always handle this as an | ||
1190 | * exchange abort, ignoring the parameter. | ||
1075 | */ | 1191 | */ |
1076 | static void fc_exch_recv_abts(struct fc_exch *ep, struct fc_frame *rx_fp) | 1192 | static void fc_exch_recv_abts(struct fc_exch *ep, struct fc_frame *rx_fp) |
1077 | { | 1193 | { |
@@ -1120,10 +1236,14 @@ free: | |||
1120 | fc_frame_free(rx_fp); | 1236 | fc_frame_free(rx_fp); |
1121 | } | 1237 | } |
1122 | 1238 | ||
1123 | /* | 1239 | /** |
1124 | * Handle receive where the other end is originating the sequence. | 1240 | * fc_exch_recv_req() - Handler for an incoming request where is other |
1241 | * end is originating the sequence | ||
1242 | * @lport: The local port that received the request | ||
1243 | * @mp: The EM that the exchange is on | ||
1244 | * @fp: The request frame | ||
1125 | */ | 1245 | */ |
1126 | static void fc_exch_recv_req(struct fc_lport *lp, struct fc_exch_mgr *mp, | 1246 | static void fc_exch_recv_req(struct fc_lport *lport, struct fc_exch_mgr *mp, |
1127 | struct fc_frame *fp) | 1247 | struct fc_frame *fp) |
1128 | { | 1248 | { |
1129 | struct fc_frame_header *fh = fc_frame_header_get(fp); | 1249 | struct fc_frame_header *fh = fc_frame_header_get(fp); |
@@ -1137,14 +1257,14 @@ static void fc_exch_recv_req(struct fc_lport *lp, struct fc_exch_mgr *mp, | |||
1137 | /* We can have the wrong fc_lport at this point with NPIV, which is a | 1257 | /* We can have the wrong fc_lport at this point with NPIV, which is a |
1138 | * problem now that we know a new exchange needs to be allocated | 1258 | * problem now that we know a new exchange needs to be allocated |
1139 | */ | 1259 | */ |
1140 | lp = fc_vport_id_lookup(lp, ntoh24(fh->fh_d_id)); | 1260 | lport = fc_vport_id_lookup(lport, ntoh24(fh->fh_d_id)); |
1141 | if (!lp) { | 1261 | if (!lport) { |
1142 | fc_frame_free(fp); | 1262 | fc_frame_free(fp); |
1143 | return; | 1263 | return; |
1144 | } | 1264 | } |
1145 | 1265 | ||
1146 | fr_seq(fp) = NULL; | 1266 | fr_seq(fp) = NULL; |
1147 | reject = fc_seq_lookup_recip(lp, mp, fp); | 1267 | reject = fc_seq_lookup_recip(lport, mp, fp); |
1148 | if (reject == FC_RJT_NONE) { | 1268 | if (reject == FC_RJT_NONE) { |
1149 | sp = fr_seq(fp); /* sequence will be held */ | 1269 | sp = fr_seq(fp); /* sequence will be held */ |
1150 | ep = fc_seq_exch(sp); | 1270 | ep = fc_seq_exch(sp); |
@@ -1167,17 +1287,21 @@ static void fc_exch_recv_req(struct fc_lport *lp, struct fc_exch_mgr *mp, | |||
1167 | if (ep->resp) | 1287 | if (ep->resp) |
1168 | ep->resp(sp, fp, ep->arg); | 1288 | ep->resp(sp, fp, ep->arg); |
1169 | else | 1289 | else |
1170 | lp->tt.lport_recv(lp, sp, fp); | 1290 | lport->tt.lport_recv(lport, sp, fp); |
1171 | fc_exch_release(ep); /* release from lookup */ | 1291 | fc_exch_release(ep); /* release from lookup */ |
1172 | } else { | 1292 | } else { |
1173 | FC_LPORT_DBG(lp, "exch/seq lookup failed: reject %x\n", reject); | 1293 | FC_LPORT_DBG(lport, "exch/seq lookup failed: reject %x\n", |
1294 | reject); | ||
1174 | fc_frame_free(fp); | 1295 | fc_frame_free(fp); |
1175 | } | 1296 | } |
1176 | } | 1297 | } |
1177 | 1298 | ||
1178 | /* | 1299 | /** |
1179 | * Handle receive where the other end is originating the sequence in | 1300 | * fc_exch_recv_seq_resp() - Handler for an incoming response where the other |
1180 | * response to our exchange. | 1301 | * end is the originator of the sequence that is a |
1302 | * response to our initial exchange | ||
1303 | * @mp: The EM that the exchange is on | ||
1304 | * @fp: The response frame | ||
1181 | */ | 1305 | */ |
1182 | static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp) | 1306 | static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp) |
1183 | { | 1307 | { |
@@ -1268,8 +1392,11 @@ out: | |||
1268 | fc_frame_free(fp); | 1392 | fc_frame_free(fp); |
1269 | } | 1393 | } |
1270 | 1394 | ||
1271 | /* | 1395 | /** |
1272 | * Handle receive for a sequence where other end is responding to our sequence. | 1396 | * fc_exch_recv_resp() - Handler for a sequence where other end is |
1397 | * responding to our sequence | ||
1398 | * @mp: The EM that the exchange is on | ||
1399 | * @fp: The response frame | ||
1273 | */ | 1400 | */ |
1274 | static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp) | 1401 | static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp) |
1275 | { | 1402 | { |
@@ -1285,9 +1412,13 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp) | |||
1285 | fc_frame_free(fp); | 1412 | fc_frame_free(fp); |
1286 | } | 1413 | } |
1287 | 1414 | ||
1288 | /* | 1415 | /** |
1289 | * Handle the response to an ABTS for exchange or sequence. | 1416 | * fc_exch_abts_resp() - Handler for a response to an ABT |
1290 | * This can be BA_ACC or BA_RJT. | 1417 | * @ep: The exchange that the frame is on |
1418 | * @fp: The response frame | ||
1419 | * | ||
1420 | * This response would be to an ABTS cancelling an exchange or sequence. | ||
1421 | * The response can be either BA_ACC or BA_RJT | ||
1291 | */ | 1422 | */ |
1292 | static void fc_exch_abts_resp(struct fc_exch *ep, struct fc_frame *fp) | 1423 | static void fc_exch_abts_resp(struct fc_exch *ep, struct fc_frame *fp) |
1293 | { | 1424 | { |
@@ -1362,9 +1493,12 @@ static void fc_exch_abts_resp(struct fc_exch *ep, struct fc_frame *fp) | |||
1362 | 1493 | ||
1363 | } | 1494 | } |
1364 | 1495 | ||
1365 | /* | 1496 | /** |
1366 | * Receive BLS sequence. | 1497 | * fc_exch_recv_bls() - Handler for a BLS sequence |
1367 | * This is always a sequence initiated by the remote side. | 1498 | * @mp: The EM that the exchange is on |
1499 | * @fp: The request frame | ||
1500 | * | ||
1501 | * The BLS frame is always a sequence initiated by the remote side. | ||
1368 | * We may be either the originator or recipient of the exchange. | 1502 | * We may be either the originator or recipient of the exchange. |
1369 | */ | 1503 | */ |
1370 | static void fc_exch_recv_bls(struct fc_exch_mgr *mp, struct fc_frame *fp) | 1504 | static void fc_exch_recv_bls(struct fc_exch_mgr *mp, struct fc_frame *fp) |
@@ -1421,8 +1555,10 @@ static void fc_exch_recv_bls(struct fc_exch_mgr *mp, struct fc_frame *fp) | |||
1421 | fc_exch_release(ep); /* release hold taken by fc_exch_find */ | 1555 | fc_exch_release(ep); /* release hold taken by fc_exch_find */ |
1422 | } | 1556 | } |
1423 | 1557 | ||
1424 | /* | 1558 | /** |
1425 | * Accept sequence with LS_ACC. | 1559 | * fc_seq_ls_acc() - Accept sequence with LS_ACC |
1560 | * @req_sp: The request sequence | ||
1561 | * | ||
1426 | * If this fails due to allocation or transmit congestion, assume the | 1562 | * If this fails due to allocation or transmit congestion, assume the |
1427 | * originator will repeat the sequence. | 1563 | * originator will repeat the sequence. |
1428 | */ | 1564 | */ |
@@ -1442,8 +1578,12 @@ static void fc_seq_ls_acc(struct fc_seq *req_sp) | |||
1442 | } | 1578 | } |
1443 | } | 1579 | } |
1444 | 1580 | ||
1445 | /* | 1581 | /** |
1446 | * Reject sequence with ELS LS_RJT. | 1582 | * fc_seq_ls_rjt() - Reject a sequence with ELS LS_RJT |
1583 | * @req_sp: The request sequence | ||
1584 | * @reason: The reason the sequence is being rejected | ||
1585 | * @explan: The explaination for the rejection | ||
1586 | * | ||
1447 | * If this fails due to allocation or transmit congestion, assume the | 1587 | * If this fails due to allocation or transmit congestion, assume the |
1448 | * originator will repeat the sequence. | 1588 | * originator will repeat the sequence. |
1449 | */ | 1589 | */ |
@@ -1466,6 +1606,10 @@ static void fc_seq_ls_rjt(struct fc_seq *req_sp, enum fc_els_rjt_reason reason, | |||
1466 | } | 1606 | } |
1467 | } | 1607 | } |
1468 | 1608 | ||
1609 | /** | ||
1610 | * fc_exch_reset() - Reset an exchange | ||
1611 | * @ep: The exchange to be reset | ||
1612 | */ | ||
1469 | static void fc_exch_reset(struct fc_exch *ep) | 1613 | static void fc_exch_reset(struct fc_exch *ep) |
1470 | { | 1614 | { |
1471 | struct fc_seq *sp; | 1615 | struct fc_seq *sp; |
@@ -1500,16 +1644,16 @@ static void fc_exch_reset(struct fc_exch *ep) | |||
1500 | } | 1644 | } |
1501 | 1645 | ||
1502 | /** | 1646 | /** |
1503 | * fc_exch_pool_reset() - Resets an per cpu exches pool. | 1647 | * fc_exch_pool_reset() - Reset a per cpu exchange pool |
1504 | * @lport: ptr to the local port | 1648 | * @lport: The local port that the exchange pool is on |
1505 | * @pool: ptr to the per cpu exches pool | 1649 | * @pool: The exchange pool to be reset |
1506 | * @sid: source FC ID | 1650 | * @sid: The source ID |
1507 | * @did: destination FC ID | 1651 | * @did: The destination ID |
1508 | * | 1652 | * |
1509 | * Resets an per cpu exches pool, releasing its all sequences | 1653 | * Resets a per cpu exches pool, releasing all of its sequences |
1510 | * and exchanges. If sid is non-zero, then reset only exchanges | 1654 | * and exchanges. If sid is non-zero then reset only exchanges |
1511 | * we sourced from that FID. If did is non-zero, reset only | 1655 | * we sourced from the local port's FID. If did is non-zero then |
1512 | * exchanges destined to that FID. | 1656 | * only reset exchanges destined for the local port's FID. |
1513 | */ | 1657 | */ |
1514 | static void fc_exch_pool_reset(struct fc_lport *lport, | 1658 | static void fc_exch_pool_reset(struct fc_lport *lport, |
1515 | struct fc_exch_pool *pool, | 1659 | struct fc_exch_pool *pool, |
@@ -1543,15 +1687,15 @@ restart: | |||
1543 | } | 1687 | } |
1544 | 1688 | ||
1545 | /** | 1689 | /** |
1546 | * fc_exch_mgr_reset() - Resets all EMs of a lport | 1690 | * fc_exch_mgr_reset() - Reset all EMs of a local port |
1547 | * @lport: ptr to the local port | 1691 | * @lport: The local port whose EMs are to be reset |
1548 | * @sid: source FC ID | 1692 | * @sid: The source ID |
1549 | * @did: destination FC ID | 1693 | * @did: The destination ID |
1550 | * | 1694 | * |
1551 | * Reset all EMs of a lport, releasing its all sequences and | 1695 | * Reset all EMs associated with a given local port. Release all |
1552 | * exchanges. If sid is non-zero, then reset only exchanges | 1696 | * sequences and exchanges. If sid is non-zero then reset only the |
1553 | * we sourced from that FID. If did is non-zero, reset only | 1697 | * exchanges sent from the local port's FID. If did is non-zero then |
1554 | * exchanges destined to that FID. | 1698 | * reset only exchanges destined for the local port's FID. |
1555 | */ | 1699 | */ |
1556 | void fc_exch_mgr_reset(struct fc_lport *lport, u32 sid, u32 did) | 1700 | void fc_exch_mgr_reset(struct fc_lport *lport, u32 sid, u32 did) |
1557 | { | 1701 | { |
@@ -1567,8 +1711,11 @@ void fc_exch_mgr_reset(struct fc_lport *lport, u32 sid, u32 did) | |||
1567 | } | 1711 | } |
1568 | EXPORT_SYMBOL(fc_exch_mgr_reset); | 1712 | EXPORT_SYMBOL(fc_exch_mgr_reset); |
1569 | 1713 | ||
1570 | /* | 1714 | /** |
1571 | * Handle incoming ELS REC - Read Exchange Concise. | 1715 | * fc_exch_els_rec() - Handler for ELS REC (Read Exchange Concise) requests |
1716 | * @sp: The sequence the REC is on | ||
1717 | * @rfp: The REC frame | ||
1718 | * | ||
1572 | * Note that the requesting port may be different than the S_ID in the request. | 1719 | * Note that the requesting port may be different than the S_ID in the request. |
1573 | */ | 1720 | */ |
1574 | static void fc_exch_els_rec(struct fc_seq *sp, struct fc_frame *rfp) | 1721 | static void fc_exch_els_rec(struct fc_seq *sp, struct fc_frame *rfp) |
@@ -1650,10 +1797,11 @@ reject: | |||
1650 | fc_frame_free(rfp); | 1797 | fc_frame_free(rfp); |
1651 | } | 1798 | } |
1652 | 1799 | ||
1653 | /* | 1800 | /** |
1654 | * Handle response from RRQ. | 1801 | * fc_exch_rrq_resp() - Handler for RRQ responses |
1655 | * Not much to do here, really. | 1802 | * @sp: The sequence that the RRQ is on |
1656 | * Should report errors. | 1803 | * @fp: The RRQ frame |
1804 | * @arg: The exchange that the RRQ is on | ||
1657 | * | 1805 | * |
1658 | * TODO: fix error handler. | 1806 | * TODO: fix error handler. |
1659 | */ | 1807 | */ |
@@ -1695,11 +1843,25 @@ cleanup: | |||
1695 | 1843 | ||
1696 | 1844 | ||
1697 | /** | 1845 | /** |
1698 | * This function is for exch_seq_send function pointer in | 1846 | * fc_exch_seq_send() - Send a frame using a new exchange and sequence |
1699 | * struct libfc_function_template, see comment block on | 1847 | * @lport: The local port to send the frame on |
1700 | * exch_seq_send for description of this function. | 1848 | * @fp: The frame to be sent |
1849 | * @resp: The response handler for this request | ||
1850 | * @destructor: The destructor for the exchange | ||
1851 | * @arg: The argument to be passed to the response handler | ||
1852 | * @timer_msec: The timeout period for the exchange | ||
1853 | * | ||
1854 | * The frame pointer with some of the header's fields must be | ||
1855 | * filled before calling this routine, those fields are: | ||
1856 | * | ||
1857 | * - routing control | ||
1858 | * - FC port did | ||
1859 | * - FC port sid | ||
1860 | * - FC header type | ||
1861 | * - frame control | ||
1862 | * - parameter or relative offset | ||
1701 | */ | 1863 | */ |
1702 | static struct fc_seq *fc_exch_seq_send(struct fc_lport *lp, | 1864 | static struct fc_seq *fc_exch_seq_send(struct fc_lport *lport, |
1703 | struct fc_frame *fp, | 1865 | struct fc_frame *fp, |
1704 | void (*resp)(struct fc_seq *, | 1866 | void (*resp)(struct fc_seq *, |
1705 | struct fc_frame *fp, | 1867 | struct fc_frame *fp, |
@@ -1713,7 +1875,7 @@ static struct fc_seq *fc_exch_seq_send(struct fc_lport *lp, | |||
1713 | struct fc_frame_header *fh; | 1875 | struct fc_frame_header *fh; |
1714 | int rc = 1; | 1876 | int rc = 1; |
1715 | 1877 | ||
1716 | ep = fc_exch_alloc(lp, fp); | 1878 | ep = fc_exch_alloc(lport, fp); |
1717 | if (!ep) { | 1879 | if (!ep) { |
1718 | fc_frame_free(fp); | 1880 | fc_frame_free(fp); |
1719 | return NULL; | 1881 | return NULL; |
@@ -1725,7 +1887,7 @@ static struct fc_seq *fc_exch_seq_send(struct fc_lport *lp, | |||
1725 | ep->destructor = destructor; | 1887 | ep->destructor = destructor; |
1726 | ep->arg = arg; | 1888 | ep->arg = arg; |
1727 | ep->r_a_tov = FC_DEF_R_A_TOV; | 1889 | ep->r_a_tov = FC_DEF_R_A_TOV; |
1728 | ep->lp = lp; | 1890 | ep->lp = lport; |
1729 | sp = &ep->seq; | 1891 | sp = &ep->seq; |
1730 | 1892 | ||
1731 | ep->fh_type = fh->fh_type; /* save for possbile timeout handling */ | 1893 | ep->fh_type = fh->fh_type; /* save for possbile timeout handling */ |
@@ -1733,10 +1895,10 @@ static struct fc_seq *fc_exch_seq_send(struct fc_lport *lp, | |||
1733 | fc_exch_setup_hdr(ep, fp, ep->f_ctl); | 1895 | fc_exch_setup_hdr(ep, fp, ep->f_ctl); |
1734 | sp->cnt++; | 1896 | sp->cnt++; |
1735 | 1897 | ||
1736 | if (ep->xid <= lp->lro_xid) | 1898 | if (ep->xid <= lport->lro_xid) |
1737 | fc_fcp_ddp_setup(fr_fsp(fp), ep->xid); | 1899 | fc_fcp_ddp_setup(fr_fsp(fp), ep->xid); |
1738 | 1900 | ||
1739 | if (unlikely(lp->tt.frame_send(lp, fp))) | 1901 | if (unlikely(lport->tt.frame_send(lport, fp))) |
1740 | goto err; | 1902 | goto err; |
1741 | 1903 | ||
1742 | if (timer_msec) | 1904 | if (timer_msec) |
@@ -1755,21 +1917,23 @@ err: | |||
1755 | return NULL; | 1917 | return NULL; |
1756 | } | 1918 | } |
1757 | 1919 | ||
1758 | /* | 1920 | /** |
1759 | * Send ELS RRQ - Reinstate Recovery Qualifier. | 1921 | * fc_exch_rrq() - Send an ELS RRQ (Reinstate Recovery Qualifier) command |
1922 | * @ep: The exchange to send the RRQ on | ||
1923 | * | ||
1760 | * This tells the remote port to stop blocking the use of | 1924 | * This tells the remote port to stop blocking the use of |
1761 | * the exchange and the seq_cnt range. | 1925 | * the exchange and the seq_cnt range. |
1762 | */ | 1926 | */ |
1763 | static void fc_exch_rrq(struct fc_exch *ep) | 1927 | static void fc_exch_rrq(struct fc_exch *ep) |
1764 | { | 1928 | { |
1765 | struct fc_lport *lp; | 1929 | struct fc_lport *lport; |
1766 | struct fc_els_rrq *rrq; | 1930 | struct fc_els_rrq *rrq; |
1767 | struct fc_frame *fp; | 1931 | struct fc_frame *fp; |
1768 | u32 did; | 1932 | u32 did; |
1769 | 1933 | ||
1770 | lp = ep->lp; | 1934 | lport = ep->lp; |
1771 | 1935 | ||
1772 | fp = fc_frame_alloc(lp, sizeof(*rrq)); | 1936 | fp = fc_frame_alloc(lport, sizeof(*rrq)); |
1773 | if (!fp) | 1937 | if (!fp) |
1774 | goto retry; | 1938 | goto retry; |
1775 | 1939 | ||
@@ -1785,10 +1949,11 @@ static void fc_exch_rrq(struct fc_exch *ep) | |||
1785 | did = ep->sid; | 1949 | did = ep->sid; |
1786 | 1950 | ||
1787 | fc_fill_fc_hdr(fp, FC_RCTL_ELS_REQ, did, | 1951 | fc_fill_fc_hdr(fp, FC_RCTL_ELS_REQ, did, |
1788 | fc_host_port_id(lp->host), FC_TYPE_ELS, | 1952 | fc_host_port_id(lport->host), FC_TYPE_ELS, |
1789 | FC_FC_FIRST_SEQ | FC_FC_END_SEQ | FC_FC_SEQ_INIT, 0); | 1953 | FC_FC_FIRST_SEQ | FC_FC_END_SEQ | FC_FC_SEQ_INIT, 0); |
1790 | 1954 | ||
1791 | if (fc_exch_seq_send(lp, fp, fc_exch_rrq_resp, NULL, ep, lp->e_d_tov)) | 1955 | if (fc_exch_seq_send(lport, fp, fc_exch_rrq_resp, NULL, ep, |
1956 | lport->e_d_tov)) | ||
1792 | return; | 1957 | return; |
1793 | 1958 | ||
1794 | retry: | 1959 | retry: |
@@ -1805,8 +1970,10 @@ retry: | |||
1805 | } | 1970 | } |
1806 | 1971 | ||
1807 | 1972 | ||
1808 | /* | 1973 | /** |
1809 | * Handle incoming ELS RRQ - Reset Recovery Qualifier. | 1974 | * fc_exch_els_rrq() - Handler for ELS RRQ (Reset Recovery Qualifier) requests |
1975 | * @sp: The sequence that the RRQ is on | ||
1976 | * @fp: The RRQ frame | ||
1810 | */ | 1977 | */ |
1811 | static void fc_exch_els_rrq(struct fc_seq *sp, struct fc_frame *fp) | 1978 | static void fc_exch_els_rrq(struct fc_seq *sp, struct fc_frame *fp) |
1812 | { | 1979 | { |
@@ -1872,6 +2039,12 @@ out: | |||
1872 | fc_exch_release(ep); /* drop hold from fc_exch_find */ | 2039 | fc_exch_release(ep); /* drop hold from fc_exch_find */ |
1873 | } | 2040 | } |
1874 | 2041 | ||
2042 | /** | ||
2043 | * fc_exch_mgr_add() - Add an exchange manager to a local port's list of EMs | ||
2044 | * @lport: The local port to add the exchange manager to | ||
2045 | * @mp: The exchange manager to be added to the local port | ||
2046 | * @match: The match routine that indicates when this EM should be used | ||
2047 | */ | ||
1875 | struct fc_exch_mgr_anchor *fc_exch_mgr_add(struct fc_lport *lport, | 2048 | struct fc_exch_mgr_anchor *fc_exch_mgr_add(struct fc_lport *lport, |
1876 | struct fc_exch_mgr *mp, | 2049 | struct fc_exch_mgr *mp, |
1877 | bool (*match)(struct fc_frame *)) | 2050 | bool (*match)(struct fc_frame *)) |
@@ -1891,6 +2064,10 @@ struct fc_exch_mgr_anchor *fc_exch_mgr_add(struct fc_lport *lport, | |||
1891 | } | 2064 | } |
1892 | EXPORT_SYMBOL(fc_exch_mgr_add); | 2065 | EXPORT_SYMBOL(fc_exch_mgr_add); |
1893 | 2066 | ||
2067 | /** | ||
2068 | * fc_exch_mgr_destroy() - Destroy an exchange manager | ||
2069 | * @kref: The reference to the EM to be destroyed | ||
2070 | */ | ||
1894 | static void fc_exch_mgr_destroy(struct kref *kref) | 2071 | static void fc_exch_mgr_destroy(struct kref *kref) |
1895 | { | 2072 | { |
1896 | struct fc_exch_mgr *mp = container_of(kref, struct fc_exch_mgr, kref); | 2073 | struct fc_exch_mgr *mp = container_of(kref, struct fc_exch_mgr, kref); |
@@ -1900,6 +2077,10 @@ static void fc_exch_mgr_destroy(struct kref *kref) | |||
1900 | kfree(mp); | 2077 | kfree(mp); |
1901 | } | 2078 | } |
1902 | 2079 | ||
2080 | /** | ||
2081 | * fc_exch_mgr_del() - Delete an EM from a local port's list | ||
2082 | * @ema: The exchange manager anchor identifying the EM to be deleted | ||
2083 | */ | ||
1903 | void fc_exch_mgr_del(struct fc_exch_mgr_anchor *ema) | 2084 | void fc_exch_mgr_del(struct fc_exch_mgr_anchor *ema) |
1904 | { | 2085 | { |
1905 | /* remove EM anchor from EM anchors list */ | 2086 | /* remove EM anchor from EM anchors list */ |
@@ -1910,9 +2091,9 @@ void fc_exch_mgr_del(struct fc_exch_mgr_anchor *ema) | |||
1910 | EXPORT_SYMBOL(fc_exch_mgr_del); | 2091 | EXPORT_SYMBOL(fc_exch_mgr_del); |
1911 | 2092 | ||
1912 | /** | 2093 | /** |
1913 | * fc_exch_mgr_list_clone() - share all exchange manager objects | 2094 | * fc_exch_mgr_list_clone() - Share all exchange manager objects |
1914 | * @src: source lport to clone exchange managers from | 2095 | * @src: Source lport to clone exchange managers from |
1915 | * @dst: new lport that takes references to all the exchange managers | 2096 | * @dst: New lport that takes references to all the exchange managers |
1916 | */ | 2097 | */ |
1917 | int fc_exch_mgr_list_clone(struct fc_lport *src, struct fc_lport *dst) | 2098 | int fc_exch_mgr_list_clone(struct fc_lport *src, struct fc_lport *dst) |
1918 | { | 2099 | { |
@@ -1929,7 +2110,15 @@ err: | |||
1929 | return -ENOMEM; | 2110 | return -ENOMEM; |
1930 | } | 2111 | } |
1931 | 2112 | ||
1932 | struct fc_exch_mgr *fc_exch_mgr_alloc(struct fc_lport *lp, | 2113 | /** |
2114 | * fc_exch_mgr_alloc() - Allocate an exchange manager | ||
2115 | * @lport: The local port that the new EM will be associated with | ||
2116 | * @class: The default FC class for new exchanges | ||
2117 | * @min_xid: The minimum XID for exchanges from the new EM | ||
2118 | * @max_xid: The maximum XID for exchanges from the new EM | ||
2119 | * @match: The match routine for the new EM | ||
2120 | */ | ||
2121 | struct fc_exch_mgr *fc_exch_mgr_alloc(struct fc_lport *lport, | ||
1933 | enum fc_class class, | 2122 | enum fc_class class, |
1934 | u16 min_xid, u16 max_xid, | 2123 | u16 min_xid, u16 max_xid, |
1935 | bool (*match)(struct fc_frame *)) | 2124 | bool (*match)(struct fc_frame *)) |
@@ -1942,7 +2131,7 @@ struct fc_exch_mgr *fc_exch_mgr_alloc(struct fc_lport *lp, | |||
1942 | 2131 | ||
1943 | if (max_xid <= min_xid || max_xid == FC_XID_UNKNOWN || | 2132 | if (max_xid <= min_xid || max_xid == FC_XID_UNKNOWN || |
1944 | (min_xid & fc_cpu_mask) != 0) { | 2133 | (min_xid & fc_cpu_mask) != 0) { |
1945 | FC_LPORT_DBG(lp, "Invalid min_xid 0x:%x and max_xid 0x:%x\n", | 2134 | FC_LPORT_DBG(lport, "Invalid min_xid 0x:%x and max_xid 0x:%x\n", |
1946 | min_xid, max_xid); | 2135 | min_xid, max_xid); |
1947 | return NULL; | 2136 | return NULL; |
1948 | } | 2137 | } |
@@ -1985,7 +2174,7 @@ struct fc_exch_mgr *fc_exch_mgr_alloc(struct fc_lport *lp, | |||
1985 | } | 2174 | } |
1986 | 2175 | ||
1987 | kref_init(&mp->kref); | 2176 | kref_init(&mp->kref); |
1988 | if (!fc_exch_mgr_add(lp, mp, match)) { | 2177 | if (!fc_exch_mgr_add(lport, mp, match)) { |
1989 | free_percpu(mp->pool); | 2178 | free_percpu(mp->pool); |
1990 | goto free_mempool; | 2179 | goto free_mempool; |
1991 | } | 2180 | } |
@@ -2006,6 +2195,10 @@ free_mp: | |||
2006 | } | 2195 | } |
2007 | EXPORT_SYMBOL(fc_exch_mgr_alloc); | 2196 | EXPORT_SYMBOL(fc_exch_mgr_alloc); |
2008 | 2197 | ||
2198 | /** | ||
2199 | * fc_exch_mgr_free() - Free all exchange managers on a local port | ||
2200 | * @lport: The local port whose EMs are to be freed | ||
2201 | */ | ||
2009 | void fc_exch_mgr_free(struct fc_lport *lport) | 2202 | void fc_exch_mgr_free(struct fc_lport *lport) |
2010 | { | 2203 | { |
2011 | struct fc_exch_mgr_anchor *ema, *next; | 2204 | struct fc_exch_mgr_anchor *ema, *next; |
@@ -2015,10 +2208,12 @@ void fc_exch_mgr_free(struct fc_lport *lport) | |||
2015 | } | 2208 | } |
2016 | EXPORT_SYMBOL(fc_exch_mgr_free); | 2209 | EXPORT_SYMBOL(fc_exch_mgr_free); |
2017 | 2210 | ||
2018 | /* | 2211 | /** |
2019 | * Receive a frame | 2212 | * fc_exch_recv() - Handler for received frames |
2213 | * @lport: The local port the frame was received on | ||
2214 | * @fp: The received frame | ||
2020 | */ | 2215 | */ |
2021 | void fc_exch_recv(struct fc_lport *lp, struct fc_frame *fp) | 2216 | void fc_exch_recv(struct fc_lport *lport, struct fc_frame *fp) |
2022 | { | 2217 | { |
2023 | struct fc_frame_header *fh = fc_frame_header_get(fp); | 2218 | struct fc_frame_header *fh = fc_frame_header_get(fp); |
2024 | struct fc_exch_mgr_anchor *ema; | 2219 | struct fc_exch_mgr_anchor *ema; |
@@ -2026,8 +2221,8 @@ void fc_exch_recv(struct fc_lport *lp, struct fc_frame *fp) | |||
2026 | u16 oxid; | 2221 | u16 oxid; |
2027 | 2222 | ||
2028 | /* lport lock ? */ | 2223 | /* lport lock ? */ |
2029 | if (!lp || lp->state == LPORT_ST_DISABLED) { | 2224 | if (!lport || lport->state == LPORT_ST_DISABLED) { |
2030 | FC_LPORT_DBG(lp, "Receiving frames for an lport that " | 2225 | FC_LPORT_DBG(lport, "Receiving frames for an lport that " |
2031 | "has not been initialized correctly\n"); | 2226 | "has not been initialized correctly\n"); |
2032 | fc_frame_free(fp); | 2227 | fc_frame_free(fp); |
2033 | return; | 2228 | return; |
@@ -2036,7 +2231,7 @@ void fc_exch_recv(struct fc_lport *lp, struct fc_frame *fp) | |||
2036 | f_ctl = ntoh24(fh->fh_f_ctl); | 2231 | f_ctl = ntoh24(fh->fh_f_ctl); |
2037 | oxid = ntohs(fh->fh_ox_id); | 2232 | oxid = ntohs(fh->fh_ox_id); |
2038 | if (f_ctl & FC_FC_EX_CTX) { | 2233 | if (f_ctl & FC_FC_EX_CTX) { |
2039 | list_for_each_entry(ema, &lp->ema_list, ema_list) { | 2234 | list_for_each_entry(ema, &lport->ema_list, ema_list) { |
2040 | if ((oxid >= ema->mp->min_xid) && | 2235 | if ((oxid >= ema->mp->min_xid) && |
2041 | (oxid <= ema->mp->max_xid)) { | 2236 | (oxid <= ema->mp->max_xid)) { |
2042 | found = 1; | 2237 | found = 1; |
@@ -2045,13 +2240,13 @@ void fc_exch_recv(struct fc_lport *lp, struct fc_frame *fp) | |||
2045 | } | 2240 | } |
2046 | 2241 | ||
2047 | if (!found) { | 2242 | if (!found) { |
2048 | FC_LPORT_DBG(lp, "Received response for out " | 2243 | FC_LPORT_DBG(lport, "Received response for out " |
2049 | "of range oxid:%hx\n", oxid); | 2244 | "of range oxid:%hx\n", oxid); |
2050 | fc_frame_free(fp); | 2245 | fc_frame_free(fp); |
2051 | return; | 2246 | return; |
2052 | } | 2247 | } |
2053 | } else | 2248 | } else |
2054 | ema = list_entry(lp->ema_list.prev, typeof(*ema), ema_list); | 2249 | ema = list_entry(lport->ema_list.prev, typeof(*ema), ema_list); |
2055 | 2250 | ||
2056 | /* | 2251 | /* |
2057 | * If frame is marked invalid, just drop it. | 2252 | * If frame is marked invalid, just drop it. |
@@ -2070,37 +2265,42 @@ void fc_exch_recv(struct fc_lport *lp, struct fc_frame *fp) | |||
2070 | else if (f_ctl & FC_FC_SEQ_CTX) | 2265 | else if (f_ctl & FC_FC_SEQ_CTX) |
2071 | fc_exch_recv_resp(ema->mp, fp); | 2266 | fc_exch_recv_resp(ema->mp, fp); |
2072 | else | 2267 | else |
2073 | fc_exch_recv_req(lp, ema->mp, fp); | 2268 | fc_exch_recv_req(lport, ema->mp, fp); |
2074 | break; | 2269 | break; |
2075 | default: | 2270 | default: |
2076 | FC_LPORT_DBG(lp, "dropping invalid frame (eof %x)", fr_eof(fp)); | 2271 | FC_LPORT_DBG(lport, "dropping invalid frame (eof %x)", |
2272 | fr_eof(fp)); | ||
2077 | fc_frame_free(fp); | 2273 | fc_frame_free(fp); |
2078 | } | 2274 | } |
2079 | } | 2275 | } |
2080 | EXPORT_SYMBOL(fc_exch_recv); | 2276 | EXPORT_SYMBOL(fc_exch_recv); |
2081 | 2277 | ||
2082 | int fc_exch_init(struct fc_lport *lp) | 2278 | /** |
2279 | * fc_exch_init() - Initialize the exchange layer for a local port | ||
2280 | * @lport: The local port to initialize the exchange layer for | ||
2281 | */ | ||
2282 | int fc_exch_init(struct fc_lport *lport) | ||
2083 | { | 2283 | { |
2084 | if (!lp->tt.seq_start_next) | 2284 | if (!lport->tt.seq_start_next) |
2085 | lp->tt.seq_start_next = fc_seq_start_next; | 2285 | lport->tt.seq_start_next = fc_seq_start_next; |
2086 | 2286 | ||
2087 | if (!lp->tt.exch_seq_send) | 2287 | if (!lport->tt.exch_seq_send) |
2088 | lp->tt.exch_seq_send = fc_exch_seq_send; | 2288 | lport->tt.exch_seq_send = fc_exch_seq_send; |
2089 | 2289 | ||
2090 | if (!lp->tt.seq_send) | 2290 | if (!lport->tt.seq_send) |
2091 | lp->tt.seq_send = fc_seq_send; | 2291 | lport->tt.seq_send = fc_seq_send; |
2092 | 2292 | ||
2093 | if (!lp->tt.seq_els_rsp_send) | 2293 | if (!lport->tt.seq_els_rsp_send) |
2094 | lp->tt.seq_els_rsp_send = fc_seq_els_rsp_send; | 2294 | lport->tt.seq_els_rsp_send = fc_seq_els_rsp_send; |
2095 | 2295 | ||
2096 | if (!lp->tt.exch_done) | 2296 | if (!lport->tt.exch_done) |
2097 | lp->tt.exch_done = fc_exch_done; | 2297 | lport->tt.exch_done = fc_exch_done; |
2098 | 2298 | ||
2099 | if (!lp->tt.exch_mgr_reset) | 2299 | if (!lport->tt.exch_mgr_reset) |
2100 | lp->tt.exch_mgr_reset = fc_exch_mgr_reset; | 2300 | lport->tt.exch_mgr_reset = fc_exch_mgr_reset; |
2101 | 2301 | ||
2102 | if (!lp->tt.seq_exch_abort) | 2302 | if (!lport->tt.seq_exch_abort) |
2103 | lp->tt.seq_exch_abort = fc_seq_exch_abort; | 2303 | lport->tt.seq_exch_abort = fc_seq_exch_abort; |
2104 | 2304 | ||
2105 | return 0; | 2305 | return 0; |
2106 | } | 2306 | } |
@@ -2141,7 +2341,10 @@ int fc_setup_exch_mgr() | |||
2141 | return 0; | 2341 | return 0; |
2142 | } | 2342 | } |
2143 | 2343 | ||
2144 | void fc_destroy_exch_mgr(void) | 2344 | /** |
2345 | * fc_destroy_exch_mgr() - Destroy an exchange manager | ||
2346 | */ | ||
2347 | void fc_destroy_exch_mgr() | ||
2145 | { | 2348 | { |
2146 | kmem_cache_destroy(fc_em_cachep); | 2349 | kmem_cache_destroy(fc_em_cachep); |
2147 | } | 2350 | } |
diff --git a/drivers/scsi/libfc/fc_fcp.c b/drivers/scsi/libfc/fc_fcp.c index 98279fe0d0c7..970b54f653b7 100644 --- a/drivers/scsi/libfc/fc_fcp.c +++ b/drivers/scsi/libfc/fc_fcp.c | |||
@@ -67,10 +67,16 @@ struct kmem_cache *scsi_pkt_cachep; | |||
67 | #define CMD_SCSI_STATUS(Cmnd) ((Cmnd)->SCp.Status) | 67 | #define CMD_SCSI_STATUS(Cmnd) ((Cmnd)->SCp.Status) |
68 | #define CMD_RESID_LEN(Cmnd) ((Cmnd)->SCp.buffers_residual) | 68 | #define CMD_RESID_LEN(Cmnd) ((Cmnd)->SCp.buffers_residual) |
69 | 69 | ||
70 | /** | ||
71 | * struct fc_fcp_internal - FCP layer internal data | ||
72 | * @scsi_pkt_pool: Memory pool to draw FCP packets from | ||
73 | * @scsi_pkt_queue: Current FCP packets | ||
74 | * @throttled: The FCP packet queue is throttled | ||
75 | */ | ||
70 | struct fc_fcp_internal { | 76 | struct fc_fcp_internal { |
71 | mempool_t *scsi_pkt_pool; | 77 | mempool_t *scsi_pkt_pool; |
72 | struct list_head scsi_pkt_queue; | 78 | struct list_head scsi_pkt_queue; |
73 | u8 throttled; | 79 | u8 throttled; |
74 | }; | 80 | }; |
75 | 81 | ||
76 | #define fc_get_scsi_internal(x) ((struct fc_fcp_internal *)(x)->scsi_priv) | 82 | #define fc_get_scsi_internal(x) ((struct fc_fcp_internal *)(x)->scsi_priv) |
@@ -84,9 +90,9 @@ static void fc_fcp_recv(struct fc_seq *, struct fc_frame *, void *); | |||
84 | static void fc_fcp_resp(struct fc_fcp_pkt *, struct fc_frame *); | 90 | static void fc_fcp_resp(struct fc_fcp_pkt *, struct fc_frame *); |
85 | static void fc_fcp_complete_locked(struct fc_fcp_pkt *); | 91 | static void fc_fcp_complete_locked(struct fc_fcp_pkt *); |
86 | static void fc_tm_done(struct fc_seq *, struct fc_frame *, void *); | 92 | static void fc_tm_done(struct fc_seq *, struct fc_frame *, void *); |
87 | static void fc_fcp_error(struct fc_fcp_pkt *fsp, struct fc_frame *fp); | 93 | static void fc_fcp_error(struct fc_fcp_pkt *, struct fc_frame *); |
88 | static void fc_timeout_error(struct fc_fcp_pkt *); | 94 | static void fc_timeout_error(struct fc_fcp_pkt *); |
89 | static void fc_fcp_timeout(unsigned long data); | 95 | static void fc_fcp_timeout(unsigned long); |
90 | static void fc_fcp_rec(struct fc_fcp_pkt *); | 96 | static void fc_fcp_rec(struct fc_fcp_pkt *); |
91 | static void fc_fcp_rec_error(struct fc_fcp_pkt *, struct fc_frame *); | 97 | static void fc_fcp_rec_error(struct fc_fcp_pkt *, struct fc_frame *); |
92 | static void fc_fcp_rec_resp(struct fc_seq *, struct fc_frame *, void *); | 98 | static void fc_fcp_rec_resp(struct fc_seq *, struct fc_frame *, void *); |
@@ -125,23 +131,22 @@ static void fc_fcp_srr_error(struct fc_fcp_pkt *, struct fc_frame *); | |||
125 | #define FC_FCP_DFLT_QUEUE_DEPTH 32 | 131 | #define FC_FCP_DFLT_QUEUE_DEPTH 32 |
126 | 132 | ||
127 | /** | 133 | /** |
128 | * fc_fcp_pkt_alloc - allocation routine for scsi_pkt packet | 134 | * fc_fcp_pkt_alloc() - Allocate a fcp_pkt |
129 | * @lp: fc lport struct | 135 | * @lport: The local port that the FCP packet is for |
130 | * @gfp: gfp flags for allocation | 136 | * @gfp: GFP flags for allocation |
131 | * | 137 | * |
132 | * This is used by upper layer scsi driver. | 138 | * Return value: fcp_pkt structure or null on allocation failure. |
133 | * Return Value : scsi_pkt structure or null on allocation failure. | 139 | * Context: Can be called from process context, no lock is required. |
134 | * Context : call from process context. no locking required. | ||
135 | */ | 140 | */ |
136 | static struct fc_fcp_pkt *fc_fcp_pkt_alloc(struct fc_lport *lp, gfp_t gfp) | 141 | static struct fc_fcp_pkt *fc_fcp_pkt_alloc(struct fc_lport *lport, gfp_t gfp) |
137 | { | 142 | { |
138 | struct fc_fcp_internal *si = fc_get_scsi_internal(lp); | 143 | struct fc_fcp_internal *si = fc_get_scsi_internal(lport); |
139 | struct fc_fcp_pkt *fsp; | 144 | struct fc_fcp_pkt *fsp; |
140 | 145 | ||
141 | fsp = mempool_alloc(si->scsi_pkt_pool, gfp); | 146 | fsp = mempool_alloc(si->scsi_pkt_pool, gfp); |
142 | if (fsp) { | 147 | if (fsp) { |
143 | memset(fsp, 0, sizeof(*fsp)); | 148 | memset(fsp, 0, sizeof(*fsp)); |
144 | fsp->lp = lp; | 149 | fsp->lp = lport; |
145 | atomic_set(&fsp->ref_cnt, 1); | 150 | atomic_set(&fsp->ref_cnt, 1); |
146 | init_timer(&fsp->timer); | 151 | init_timer(&fsp->timer); |
147 | INIT_LIST_HEAD(&fsp->list); | 152 | INIT_LIST_HEAD(&fsp->list); |
@@ -151,12 +156,11 @@ static struct fc_fcp_pkt *fc_fcp_pkt_alloc(struct fc_lport *lp, gfp_t gfp) | |||
151 | } | 156 | } |
152 | 157 | ||
153 | /** | 158 | /** |
154 | * fc_fcp_pkt_release() - release hold on scsi_pkt packet | 159 | * fc_fcp_pkt_release() - Release hold on a fcp_pkt |
155 | * @fsp: fcp packet struct | 160 | * @fsp: The FCP packet to be released |
156 | * | 161 | * |
157 | * This is used by upper layer scsi driver. | 162 | * Context: Can be called from process or interrupt context, |
158 | * Context : call from process and interrupt context. | 163 | * no lock is required. |
159 | * no locking required | ||
160 | */ | 164 | */ |
161 | static void fc_fcp_pkt_release(struct fc_fcp_pkt *fsp) | 165 | static void fc_fcp_pkt_release(struct fc_fcp_pkt *fsp) |
162 | { | 166 | { |
@@ -167,20 +171,25 @@ static void fc_fcp_pkt_release(struct fc_fcp_pkt *fsp) | |||
167 | } | 171 | } |
168 | } | 172 | } |
169 | 173 | ||
174 | /** | ||
175 | * fc_fcp_pkt_hold() - Hold a fcp_pkt | ||
176 | * @fsp: The FCP packet to be held | ||
177 | */ | ||
170 | static void fc_fcp_pkt_hold(struct fc_fcp_pkt *fsp) | 178 | static void fc_fcp_pkt_hold(struct fc_fcp_pkt *fsp) |
171 | { | 179 | { |
172 | atomic_inc(&fsp->ref_cnt); | 180 | atomic_inc(&fsp->ref_cnt); |
173 | } | 181 | } |
174 | 182 | ||
175 | /** | 183 | /** |
176 | * fc_fcp_pkt_destory() - release hold on scsi_pkt packet | 184 | * fc_fcp_pkt_destory() - Release hold on a fcp_pkt |
177 | * @seq: exchange sequence | 185 | * @seq: The sequence that the FCP packet is on (required by destructor API) |
178 | * @fsp: fcp packet struct | 186 | * @fsp: The FCP packet to be released |
187 | * | ||
188 | * This routine is called by a destructor callback in the exch_seq_send() | ||
189 | * routine of the libfc Transport Template. The 'struct fc_seq' is a required | ||
190 | * argument even though it is not used by this routine. | ||
179 | * | 191 | * |
180 | * Release hold on scsi_pkt packet set to keep scsi_pkt | 192 | * Context: No locking required. |
181 | * till EM layer exch resource is not freed. | ||
182 | * Context : called from from EM layer. | ||
183 | * no locking required | ||
184 | */ | 193 | */ |
185 | static void fc_fcp_pkt_destroy(struct fc_seq *seq, void *fsp) | 194 | static void fc_fcp_pkt_destroy(struct fc_seq *seq, void *fsp) |
186 | { | 195 | { |
@@ -188,10 +197,10 @@ static void fc_fcp_pkt_destroy(struct fc_seq *seq, void *fsp) | |||
188 | } | 197 | } |
189 | 198 | ||
190 | /** | 199 | /** |
191 | * fc_fcp_lock_pkt() - lock a packet and get a ref to it. | 200 | * fc_fcp_lock_pkt() - Lock a fcp_pkt and increase its reference count |
192 | * @fsp: fcp packet | 201 | * @fsp: The FCP packet to be locked and incremented |
193 | * | 202 | * |
194 | * We should only return error if we return a command to scsi-ml before | 203 | * We should only return error if we return a command to SCSI-ml before |
195 | * getting a response. This can happen in cases where we send a abort, but | 204 | * getting a response. This can happen in cases where we send a abort, but |
196 | * do not wait for the response and the abort and command can be passing | 205 | * do not wait for the response and the abort and command can be passing |
197 | * each other on the wire/network-layer. | 206 | * each other on the wire/network-layer. |
@@ -216,18 +225,33 @@ static inline int fc_fcp_lock_pkt(struct fc_fcp_pkt *fsp) | |||
216 | return 0; | 225 | return 0; |
217 | } | 226 | } |
218 | 227 | ||
228 | /** | ||
229 | * fc_fcp_unlock_pkt() - Release a fcp_pkt's lock and decrement its | ||
230 | * reference count | ||
231 | * @fsp: The FCP packet to be unlocked and decremented | ||
232 | */ | ||
219 | static inline void fc_fcp_unlock_pkt(struct fc_fcp_pkt *fsp) | 233 | static inline void fc_fcp_unlock_pkt(struct fc_fcp_pkt *fsp) |
220 | { | 234 | { |
221 | spin_unlock_bh(&fsp->scsi_pkt_lock); | 235 | spin_unlock_bh(&fsp->scsi_pkt_lock); |
222 | fc_fcp_pkt_release(fsp); | 236 | fc_fcp_pkt_release(fsp); |
223 | } | 237 | } |
224 | 238 | ||
239 | /** | ||
240 | * fc_fcp_timer_set() - Start a timer for a fcp_pkt | ||
241 | * @fsp: The FCP packet to start a timer for | ||
242 | * @delay: The timeout period for the timer | ||
243 | */ | ||
225 | static void fc_fcp_timer_set(struct fc_fcp_pkt *fsp, unsigned long delay) | 244 | static void fc_fcp_timer_set(struct fc_fcp_pkt *fsp, unsigned long delay) |
226 | { | 245 | { |
227 | if (!(fsp->state & FC_SRB_COMPL)) | 246 | if (!(fsp->state & FC_SRB_COMPL)) |
228 | mod_timer(&fsp->timer, jiffies + delay); | 247 | mod_timer(&fsp->timer, jiffies + delay); |
229 | } | 248 | } |
230 | 249 | ||
250 | /** | ||
251 | * fc_fcp_send_abort() - Send an abort for exchanges associated with a | ||
252 | * fcp_pkt | ||
253 | * @fsp: The FCP packet to abort exchanges on | ||
254 | */ | ||
231 | static int fc_fcp_send_abort(struct fc_fcp_pkt *fsp) | 255 | static int fc_fcp_send_abort(struct fc_fcp_pkt *fsp) |
232 | { | 256 | { |
233 | if (!fsp->seq_ptr) | 257 | if (!fsp->seq_ptr) |
@@ -237,9 +261,14 @@ static int fc_fcp_send_abort(struct fc_fcp_pkt *fsp) | |||
237 | return fsp->lp->tt.seq_exch_abort(fsp->seq_ptr, 0); | 261 | return fsp->lp->tt.seq_exch_abort(fsp->seq_ptr, 0); |
238 | } | 262 | } |
239 | 263 | ||
240 | /* | 264 | /** |
241 | * Retry command. | 265 | * fc_fcp_retry_cmd() - Retry a fcp_pkt |
242 | * An abort isn't needed. | 266 | * @fsp: The FCP packet to be retried |
267 | * | ||
268 | * Sets the status code to be FC_ERROR and then calls | ||
269 | * fc_fcp_complete_locked() which in turn calls fc_io_compl(). | ||
270 | * fc_io_compl() will notify the SCSI-ml that the I/O is done. | ||
271 | * The SCSI-ml will retry the command. | ||
243 | */ | 272 | */ |
244 | static void fc_fcp_retry_cmd(struct fc_fcp_pkt *fsp) | 273 | static void fc_fcp_retry_cmd(struct fc_fcp_pkt *fsp) |
245 | { | 274 | { |
@@ -254,43 +283,35 @@ static void fc_fcp_retry_cmd(struct fc_fcp_pkt *fsp) | |||
254 | fc_fcp_complete_locked(fsp); | 283 | fc_fcp_complete_locked(fsp); |
255 | } | 284 | } |
256 | 285 | ||
257 | /* | 286 | /** |
258 | * fc_fcp_ddp_setup - calls to LLD's ddp_setup to set up DDP | 287 | * fc_fcp_ddp_setup() - Calls a LLD's ddp_setup routine to set up DDP context |
259 | * transfer for a read I/O indicated by the fc_fcp_pkt. | 288 | * @fsp: The FCP packet that will manage the DDP frames |
260 | * @fsp: ptr to the fc_fcp_pkt | 289 | * @xid: The XID that will be used for the DDP exchange |
261 | * | ||
262 | * This is called in exch_seq_send() when we have a newly allocated | ||
263 | * exchange with a valid exchange id to setup ddp. | ||
264 | * | ||
265 | * returns: none | ||
266 | */ | 290 | */ |
267 | void fc_fcp_ddp_setup(struct fc_fcp_pkt *fsp, u16 xid) | 291 | void fc_fcp_ddp_setup(struct fc_fcp_pkt *fsp, u16 xid) |
268 | { | 292 | { |
269 | struct fc_lport *lp; | 293 | struct fc_lport *lport; |
270 | 294 | ||
271 | if (!fsp) | 295 | if (!fsp) |
272 | return; | 296 | return; |
273 | 297 | ||
274 | lp = fsp->lp; | 298 | lport = fsp->lp; |
275 | if ((fsp->req_flags & FC_SRB_READ) && | 299 | if ((fsp->req_flags & FC_SRB_READ) && |
276 | (lp->lro_enabled) && (lp->tt.ddp_setup)) { | 300 | (lport->lro_enabled) && (lport->tt.ddp_setup)) { |
277 | if (lp->tt.ddp_setup(lp, xid, scsi_sglist(fsp->cmd), | 301 | if (lport->tt.ddp_setup(lport, xid, scsi_sglist(fsp->cmd), |
278 | scsi_sg_count(fsp->cmd))) | 302 | scsi_sg_count(fsp->cmd))) |
279 | fsp->xfer_ddp = xid; | 303 | fsp->xfer_ddp = xid; |
280 | } | 304 | } |
281 | } | 305 | } |
282 | 306 | ||
283 | /* | 307 | /** |
284 | * fc_fcp_ddp_done - calls to LLD's ddp_done to release any | 308 | * fc_fcp_ddp_done() - Calls a LLD's ddp_done routine to release any |
285 | * DDP related resources for this I/O if it is initialized | 309 | * DDP related resources for a fcp_pkt |
286 | * as a ddp transfer | 310 | * @fsp: The FCP packet that DDP had been used on |
287 | * @fsp: ptr to the fc_fcp_pkt | ||
288 | * | ||
289 | * returns: none | ||
290 | */ | 311 | */ |
291 | static void fc_fcp_ddp_done(struct fc_fcp_pkt *fsp) | 312 | static void fc_fcp_ddp_done(struct fc_fcp_pkt *fsp) |
292 | { | 313 | { |
293 | struct fc_lport *lp; | 314 | struct fc_lport *lport; |
294 | 315 | ||
295 | if (!fsp) | 316 | if (!fsp) |
296 | return; | 317 | return; |
@@ -298,22 +319,22 @@ static void fc_fcp_ddp_done(struct fc_fcp_pkt *fsp) | |||
298 | if (fsp->xfer_ddp == FC_XID_UNKNOWN) | 319 | if (fsp->xfer_ddp == FC_XID_UNKNOWN) |
299 | return; | 320 | return; |
300 | 321 | ||
301 | lp = fsp->lp; | 322 | lport = fsp->lp; |
302 | if (lp->tt.ddp_done) { | 323 | if (lport->tt.ddp_done) { |
303 | fsp->xfer_len = lp->tt.ddp_done(lp, fsp->xfer_ddp); | 324 | fsp->xfer_len = lport->tt.ddp_done(lport, fsp->xfer_ddp); |
304 | fsp->xfer_ddp = FC_XID_UNKNOWN; | 325 | fsp->xfer_ddp = FC_XID_UNKNOWN; |
305 | } | 326 | } |
306 | } | 327 | } |
307 | 328 | ||
308 | 329 | /** | |
309 | /* | 330 | * fc_fcp_recv_data() - Handler for receiving SCSI-FCP data from a target |
310 | * Receive SCSI data from target. | 331 | * @fsp: The FCP packet the data is on |
311 | * Called after receiving solicited data. | 332 | * @fp: The data frame |
312 | */ | 333 | */ |
313 | static void fc_fcp_recv_data(struct fc_fcp_pkt *fsp, struct fc_frame *fp) | 334 | static void fc_fcp_recv_data(struct fc_fcp_pkt *fsp, struct fc_frame *fp) |
314 | { | 335 | { |
315 | struct scsi_cmnd *sc = fsp->cmd; | 336 | struct scsi_cmnd *sc = fsp->cmd; |
316 | struct fc_lport *lp = fsp->lp; | 337 | struct fc_lport *lport = fsp->lp; |
317 | struct fcoe_dev_stats *stats; | 338 | struct fcoe_dev_stats *stats; |
318 | struct fc_frame_header *fh; | 339 | struct fc_frame_header *fh; |
319 | size_t start_offset; | 340 | size_t start_offset; |
@@ -363,13 +384,13 @@ static void fc_fcp_recv_data(struct fc_fcp_pkt *fsp, struct fc_frame *fp) | |||
363 | 384 | ||
364 | if (~crc != le32_to_cpu(fr_crc(fp))) { | 385 | if (~crc != le32_to_cpu(fr_crc(fp))) { |
365 | crc_err: | 386 | crc_err: |
366 | stats = fc_lport_get_stats(lp); | 387 | stats = fc_lport_get_stats(lport); |
367 | stats->ErrorFrames++; | 388 | stats->ErrorFrames++; |
368 | /* FIXME - per cpu count, not total count! */ | 389 | /* FIXME - per cpu count, not total count! */ |
369 | if (stats->InvalidCRCCount++ < 5) | 390 | if (stats->InvalidCRCCount++ < 5) |
370 | printk(KERN_WARNING "libfc: CRC error on data " | 391 | printk(KERN_WARNING "libfc: CRC error on data " |
371 | "frame for port (%6x)\n", | 392 | "frame for port (%6x)\n", |
372 | fc_host_port_id(lp->host)); | 393 | fc_host_port_id(lport->host)); |
373 | /* | 394 | /* |
374 | * Assume the frame is total garbage. | 395 | * Assume the frame is total garbage. |
375 | * We may have copied it over the good part | 396 | * We may have copied it over the good part |
@@ -397,18 +418,17 @@ crc_err: | |||
397 | } | 418 | } |
398 | 419 | ||
399 | /** | 420 | /** |
400 | * fc_fcp_send_data() - Send SCSI data to target. | 421 | * fc_fcp_send_data() - Send SCSI data to a target |
401 | * @fsp: ptr to fc_fcp_pkt | 422 | * @fsp: The FCP packet the data is on |
402 | * @sp: ptr to this sequence | 423 | * @sp: The sequence the data is to be sent on |
403 | * @offset: starting offset for this data request | 424 | * @offset: The starting offset for this data request |
404 | * @seq_blen: the burst length for this data request | 425 | * @seq_blen: The burst length for this data request |
405 | * | 426 | * |
406 | * Called after receiving a Transfer Ready data descriptor. | 427 | * Called after receiving a Transfer Ready data descriptor. |
407 | * if LLD is capable of seq offload then send down seq_blen | 428 | * If the LLD is capable of sequence offload then send down the |
408 | * size of data in single frame, otherwise send multiple FC | 429 | * seq_blen ammount of data in single frame, otherwise send |
409 | * frames of max FC frame payload supported by target port. | 430 | * multiple frames of the maximum frame payload supported by |
410 | * | 431 | * the target port. |
411 | * Returns : 0 for success. | ||
412 | */ | 432 | */ |
413 | static int fc_fcp_send_data(struct fc_fcp_pkt *fsp, struct fc_seq *seq, | 433 | static int fc_fcp_send_data(struct fc_fcp_pkt *fsp, struct fc_seq *seq, |
414 | size_t offset, size_t seq_blen) | 434 | size_t offset, size_t seq_blen) |
@@ -417,7 +437,7 @@ static int fc_fcp_send_data(struct fc_fcp_pkt *fsp, struct fc_seq *seq, | |||
417 | struct scsi_cmnd *sc; | 437 | struct scsi_cmnd *sc; |
418 | struct scatterlist *sg; | 438 | struct scatterlist *sg; |
419 | struct fc_frame *fp = NULL; | 439 | struct fc_frame *fp = NULL; |
420 | struct fc_lport *lp = fsp->lp; | 440 | struct fc_lport *lport = fsp->lp; |
421 | size_t remaining; | 441 | size_t remaining; |
422 | size_t t_blen; | 442 | size_t t_blen; |
423 | size_t tlen; | 443 | size_t tlen; |
@@ -426,7 +446,7 @@ static int fc_fcp_send_data(struct fc_fcp_pkt *fsp, struct fc_seq *seq, | |||
426 | int error; | 446 | int error; |
427 | void *data = NULL; | 447 | void *data = NULL; |
428 | void *page_addr; | 448 | void *page_addr; |
429 | int using_sg = lp->sg_supp; | 449 | int using_sg = lport->sg_supp; |
430 | u32 f_ctl; | 450 | u32 f_ctl; |
431 | 451 | ||
432 | WARN_ON(seq_blen <= 0); | 452 | WARN_ON(seq_blen <= 0); |
@@ -448,10 +468,10 @@ static int fc_fcp_send_data(struct fc_fcp_pkt *fsp, struct fc_seq *seq, | |||
448 | * to max FC frame payload previously set in fsp->max_payload. | 468 | * to max FC frame payload previously set in fsp->max_payload. |
449 | */ | 469 | */ |
450 | t_blen = fsp->max_payload; | 470 | t_blen = fsp->max_payload; |
451 | if (lp->seq_offload) { | 471 | if (lport->seq_offload) { |
452 | t_blen = min(seq_blen, (size_t)lp->lso_max); | 472 | t_blen = min(seq_blen, (size_t)lport->lso_max); |
453 | FC_FCP_DBG(fsp, "fsp=%p:lso:blen=%zx lso_max=0x%x t_blen=%zx\n", | 473 | FC_FCP_DBG(fsp, "fsp=%p:lso:blen=%zx lso_max=0x%x t_blen=%zx\n", |
454 | fsp, seq_blen, lp->lso_max, t_blen); | 474 | fsp, seq_blen, lport->lso_max, t_blen); |
455 | } | 475 | } |
456 | 476 | ||
457 | WARN_ON(t_blen < FC_MIN_MAX_PAYLOAD); | 477 | WARN_ON(t_blen < FC_MIN_MAX_PAYLOAD); |
@@ -463,7 +483,7 @@ static int fc_fcp_send_data(struct fc_fcp_pkt *fsp, struct fc_seq *seq, | |||
463 | remaining = seq_blen; | 483 | remaining = seq_blen; |
464 | fh_parm_offset = frame_offset = offset; | 484 | fh_parm_offset = frame_offset = offset; |
465 | tlen = 0; | 485 | tlen = 0; |
466 | seq = lp->tt.seq_start_next(seq); | 486 | seq = lport->tt.seq_start_next(seq); |
467 | f_ctl = FC_FC_REL_OFF; | 487 | f_ctl = FC_FC_REL_OFF; |
468 | WARN_ON(!seq); | 488 | WARN_ON(!seq); |
469 | 489 | ||
@@ -486,11 +506,11 @@ static int fc_fcp_send_data(struct fc_fcp_pkt *fsp, struct fc_seq *seq, | |||
486 | if (tlen % 4) | 506 | if (tlen % 4) |
487 | using_sg = 0; | 507 | using_sg = 0; |
488 | if (using_sg) { | 508 | if (using_sg) { |
489 | fp = _fc_frame_alloc(lp, 0); | 509 | fp = _fc_frame_alloc(lport, 0); |
490 | if (!fp) | 510 | if (!fp) |
491 | return -ENOMEM; | 511 | return -ENOMEM; |
492 | } else { | 512 | } else { |
493 | fp = fc_frame_alloc(lp, tlen); | 513 | fp = fc_frame_alloc(lport, tlen); |
494 | if (!fp) | 514 | if (!fp) |
495 | return -ENOMEM; | 515 | return -ENOMEM; |
496 | 516 | ||
@@ -550,7 +570,7 @@ static int fc_fcp_send_data(struct fc_fcp_pkt *fsp, struct fc_seq *seq, | |||
550 | /* | 570 | /* |
551 | * send fragment using for a sequence. | 571 | * send fragment using for a sequence. |
552 | */ | 572 | */ |
553 | error = lp->tt.seq_send(lp, seq, fp); | 573 | error = lport->tt.seq_send(lport, seq, fp); |
554 | if (error) { | 574 | if (error) { |
555 | WARN_ON(1); /* send error should be rare */ | 575 | WARN_ON(1); /* send error should be rare */ |
556 | fc_fcp_retry_cmd(fsp); | 576 | fc_fcp_retry_cmd(fsp); |
@@ -562,6 +582,11 @@ static int fc_fcp_send_data(struct fc_fcp_pkt *fsp, struct fc_seq *seq, | |||
562 | return 0; | 582 | return 0; |
563 | } | 583 | } |
564 | 584 | ||
585 | /** | ||
586 | * fc_fcp_abts_resp() - Send an ABTS response | ||
587 | * @fsp: The FCP packet that is being aborted | ||
588 | * @fp: The response frame | ||
589 | */ | ||
565 | static void fc_fcp_abts_resp(struct fc_fcp_pkt *fsp, struct fc_frame *fp) | 590 | static void fc_fcp_abts_resp(struct fc_fcp_pkt *fsp, struct fc_frame *fp) |
566 | { | 591 | { |
567 | int ba_done = 1; | 592 | int ba_done = 1; |
@@ -598,8 +623,8 @@ static void fc_fcp_abts_resp(struct fc_fcp_pkt *fsp, struct fc_frame *fp) | |||
598 | } | 623 | } |
599 | 624 | ||
600 | /** | 625 | /** |
601 | * fc_fcp_reduce_can_queue() - drop can_queue | 626 | * fc_fcp_reduce_can_queue() - Reduce the can_queue value for a local port |
602 | * @lp: lport to drop queueing for | 627 | * @lport: The local port to reduce can_queue on |
603 | * | 628 | * |
604 | * If we are getting memory allocation failures, then we may | 629 | * If we are getting memory allocation failures, then we may |
605 | * be trying to execute too many commands. We let the running | 630 | * be trying to execute too many commands. We let the running |
@@ -607,37 +632,36 @@ static void fc_fcp_abts_resp(struct fc_fcp_pkt *fsp, struct fc_frame *fp) | |||
607 | * can_queue. Eventually we will hit the point where we run | 632 | * can_queue. Eventually we will hit the point where we run |
608 | * on all reserved structs. | 633 | * on all reserved structs. |
609 | */ | 634 | */ |
610 | static void fc_fcp_reduce_can_queue(struct fc_lport *lp) | 635 | static void fc_fcp_reduce_can_queue(struct fc_lport *lport) |
611 | { | 636 | { |
612 | struct fc_fcp_internal *si = fc_get_scsi_internal(lp); | 637 | struct fc_fcp_internal *si = fc_get_scsi_internal(lport); |
613 | unsigned long flags; | 638 | unsigned long flags; |
614 | int can_queue; | 639 | int can_queue; |
615 | 640 | ||
616 | spin_lock_irqsave(lp->host->host_lock, flags); | 641 | spin_lock_irqsave(lport->host->host_lock, flags); |
617 | if (si->throttled) | 642 | if (si->throttled) |
618 | goto done; | 643 | goto done; |
619 | si->throttled = 1; | 644 | si->throttled = 1; |
620 | 645 | ||
621 | can_queue = lp->host->can_queue; | 646 | can_queue = lport->host->can_queue; |
622 | can_queue >>= 1; | 647 | can_queue >>= 1; |
623 | if (!can_queue) | 648 | if (!can_queue) |
624 | can_queue = 1; | 649 | can_queue = 1; |
625 | lp->host->can_queue = can_queue; | 650 | lport->host->can_queue = can_queue; |
626 | shost_printk(KERN_ERR, lp->host, "libfc: Could not allocate frame.\n" | 651 | shost_printk(KERN_ERR, lport->host, "libfc: Could not allocate frame.\n" |
627 | "Reducing can_queue to %d.\n", can_queue); | 652 | "Reducing can_queue to %d.\n", can_queue); |
628 | done: | 653 | done: |
629 | spin_unlock_irqrestore(lp->host->host_lock, flags); | 654 | spin_unlock_irqrestore(lport->host->host_lock, flags); |
630 | } | 655 | } |
631 | 656 | ||
632 | /** | 657 | /** |
633 | * fc_fcp_recv() - Reveive FCP frames | 658 | * fc_fcp_recv() - Reveive an FCP frame |
634 | * @seq: The sequence the frame is on | 659 | * @seq: The sequence the frame is on |
635 | * @fp: The FC frame | 660 | * @fp: The received frame |
636 | * @arg: The related FCP packet | 661 | * @arg: The related FCP packet |
637 | * | 662 | * |
638 | * Return : None | 663 | * Context: Called from Soft IRQ context. Can not be called |
639 | * Context : called from Soft IRQ context | 664 | * holding the FCP packet list lock. |
640 | * can not called holding list lock | ||
641 | */ | 665 | */ |
642 | static void fc_fcp_recv(struct fc_seq *seq, struct fc_frame *fp, void *arg) | 666 | static void fc_fcp_recv(struct fc_seq *seq, struct fc_frame *fp, void *arg) |
643 | { | 667 | { |
@@ -710,6 +734,11 @@ errout: | |||
710 | fc_fcp_reduce_can_queue(lport); | 734 | fc_fcp_reduce_can_queue(lport); |
711 | } | 735 | } |
712 | 736 | ||
737 | /** | ||
738 | * fc_fcp_resp() - Handler for FCP responses | ||
739 | * @fsp: The FCP packet the response is for | ||
740 | * @fp: The response frame | ||
741 | */ | ||
713 | static void fc_fcp_resp(struct fc_fcp_pkt *fsp, struct fc_frame *fp) | 742 | static void fc_fcp_resp(struct fc_fcp_pkt *fsp, struct fc_frame *fp) |
714 | { | 743 | { |
715 | struct fc_frame_header *fh; | 744 | struct fc_frame_header *fh; |
@@ -823,15 +852,16 @@ err: | |||
823 | } | 852 | } |
824 | 853 | ||
825 | /** | 854 | /** |
826 | * fc_fcp_complete_locked() - complete processing of a fcp packet | 855 | * fc_fcp_complete_locked() - Complete processing of a fcp_pkt with the |
827 | * @fsp: fcp packet | 856 | * fcp_pkt lock held |
857 | * @fsp: The FCP packet to be completed | ||
828 | * | 858 | * |
829 | * This function may sleep if a timer is pending. The packet lock must be | 859 | * This function may sleep if a timer is pending. The packet lock must be |
830 | * held, and the host lock must not be held. | 860 | * held, and the host lock must not be held. |
831 | */ | 861 | */ |
832 | static void fc_fcp_complete_locked(struct fc_fcp_pkt *fsp) | 862 | static void fc_fcp_complete_locked(struct fc_fcp_pkt *fsp) |
833 | { | 863 | { |
834 | struct fc_lport *lp = fsp->lp; | 864 | struct fc_lport *lport = fsp->lp; |
835 | struct fc_seq *seq; | 865 | struct fc_seq *seq; |
836 | struct fc_exch *ep; | 866 | struct fc_exch *ep; |
837 | u32 f_ctl; | 867 | u32 f_ctl; |
@@ -862,7 +892,7 @@ static void fc_fcp_complete_locked(struct fc_fcp_pkt *fsp) | |||
862 | struct fc_frame *conf_frame; | 892 | struct fc_frame *conf_frame; |
863 | struct fc_seq *csp; | 893 | struct fc_seq *csp; |
864 | 894 | ||
865 | csp = lp->tt.seq_start_next(seq); | 895 | csp = lport->tt.seq_start_next(seq); |
866 | conf_frame = fc_frame_alloc(fsp->lp, 0); | 896 | conf_frame = fc_frame_alloc(fsp->lp, 0); |
867 | if (conf_frame) { | 897 | if (conf_frame) { |
868 | f_ctl = FC_FC_SEQ_INIT; | 898 | f_ctl = FC_FC_SEQ_INIT; |
@@ -871,43 +901,48 @@ static void fc_fcp_complete_locked(struct fc_fcp_pkt *fsp) | |||
871 | fc_fill_fc_hdr(conf_frame, FC_RCTL_DD_SOL_CTL, | 901 | fc_fill_fc_hdr(conf_frame, FC_RCTL_DD_SOL_CTL, |
872 | ep->did, ep->sid, | 902 | ep->did, ep->sid, |
873 | FC_TYPE_FCP, f_ctl, 0); | 903 | FC_TYPE_FCP, f_ctl, 0); |
874 | lp->tt.seq_send(lp, csp, conf_frame); | 904 | lport->tt.seq_send(lport, csp, conf_frame); |
875 | } | 905 | } |
876 | } | 906 | } |
877 | lp->tt.exch_done(seq); | 907 | lport->tt.exch_done(seq); |
878 | } | 908 | } |
879 | fc_io_compl(fsp); | 909 | fc_io_compl(fsp); |
880 | } | 910 | } |
881 | 911 | ||
912 | /** | ||
913 | * fc_fcp_cleanup_cmd() - Cancel the active exchange on a fcp_pkt | ||
914 | * @fsp: The FCP packet whose exchanges should be canceled | ||
915 | * @error: The reason for the cancellation | ||
916 | */ | ||
882 | static void fc_fcp_cleanup_cmd(struct fc_fcp_pkt *fsp, int error) | 917 | static void fc_fcp_cleanup_cmd(struct fc_fcp_pkt *fsp, int error) |
883 | { | 918 | { |
884 | struct fc_lport *lp = fsp->lp; | 919 | struct fc_lport *lport = fsp->lp; |
885 | 920 | ||
886 | if (fsp->seq_ptr) { | 921 | if (fsp->seq_ptr) { |
887 | lp->tt.exch_done(fsp->seq_ptr); | 922 | lport->tt.exch_done(fsp->seq_ptr); |
888 | fsp->seq_ptr = NULL; | 923 | fsp->seq_ptr = NULL; |
889 | } | 924 | } |
890 | fsp->status_code = error; | 925 | fsp->status_code = error; |
891 | } | 926 | } |
892 | 927 | ||
893 | /** | 928 | /** |
894 | * fc_fcp_cleanup_each_cmd() - Cleanup active commads | 929 | * fc_fcp_cleanup_each_cmd() - Cancel all exchanges on a local port |
895 | * @lp: logical port | 930 | * @lport: The local port whose exchanges should be canceled |
896 | * @id: target id | 931 | * @id: The target's ID |
897 | * @lun: lun | 932 | * @lun: The LUN |
898 | * @error: fsp status code | 933 | * @error: The reason for cancellation |
899 | * | 934 | * |
900 | * If lun or id is -1, they are ignored. | 935 | * If lun or id is -1, they are ignored. |
901 | */ | 936 | */ |
902 | static void fc_fcp_cleanup_each_cmd(struct fc_lport *lp, unsigned int id, | 937 | static void fc_fcp_cleanup_each_cmd(struct fc_lport *lport, unsigned int id, |
903 | unsigned int lun, int error) | 938 | unsigned int lun, int error) |
904 | { | 939 | { |
905 | struct fc_fcp_internal *si = fc_get_scsi_internal(lp); | 940 | struct fc_fcp_internal *si = fc_get_scsi_internal(lport); |
906 | struct fc_fcp_pkt *fsp; | 941 | struct fc_fcp_pkt *fsp; |
907 | struct scsi_cmnd *sc_cmd; | 942 | struct scsi_cmnd *sc_cmd; |
908 | unsigned long flags; | 943 | unsigned long flags; |
909 | 944 | ||
910 | spin_lock_irqsave(lp->host->host_lock, flags); | 945 | spin_lock_irqsave(lport->host->host_lock, flags); |
911 | restart: | 946 | restart: |
912 | list_for_each_entry(fsp, &si->scsi_pkt_queue, list) { | 947 | list_for_each_entry(fsp, &si->scsi_pkt_queue, list) { |
913 | sc_cmd = fsp->cmd; | 948 | sc_cmd = fsp->cmd; |
@@ -918,7 +953,7 @@ restart: | |||
918 | continue; | 953 | continue; |
919 | 954 | ||
920 | fc_fcp_pkt_hold(fsp); | 955 | fc_fcp_pkt_hold(fsp); |
921 | spin_unlock_irqrestore(lp->host->host_lock, flags); | 956 | spin_unlock_irqrestore(lport->host->host_lock, flags); |
922 | 957 | ||
923 | if (!fc_fcp_lock_pkt(fsp)) { | 958 | if (!fc_fcp_lock_pkt(fsp)) { |
924 | fc_fcp_cleanup_cmd(fsp, error); | 959 | fc_fcp_cleanup_cmd(fsp, error); |
@@ -927,35 +962,36 @@ restart: | |||
927 | } | 962 | } |
928 | 963 | ||
929 | fc_fcp_pkt_release(fsp); | 964 | fc_fcp_pkt_release(fsp); |
930 | spin_lock_irqsave(lp->host->host_lock, flags); | 965 | spin_lock_irqsave(lport->host->host_lock, flags); |
931 | /* | 966 | /* |
932 | * while we dropped the lock multiple pkts could | 967 | * while we dropped the lock multiple pkts could |
933 | * have been released, so we have to start over. | 968 | * have been released, so we have to start over. |
934 | */ | 969 | */ |
935 | goto restart; | 970 | goto restart; |
936 | } | 971 | } |
937 | spin_unlock_irqrestore(lp->host->host_lock, flags); | 972 | spin_unlock_irqrestore(lport->host->host_lock, flags); |
938 | } | 973 | } |
939 | 974 | ||
940 | static void fc_fcp_abort_io(struct fc_lport *lp) | 975 | /** |
976 | * fc_fcp_abort_io() - Abort all FCP-SCSI exchanges on a local port | ||
977 | * @lport: The local port whose exchanges are to be aborted | ||
978 | */ | ||
979 | static void fc_fcp_abort_io(struct fc_lport *lport) | ||
941 | { | 980 | { |
942 | fc_fcp_cleanup_each_cmd(lp, -1, -1, FC_HRD_ERROR); | 981 | fc_fcp_cleanup_each_cmd(lport, -1, -1, FC_HRD_ERROR); |
943 | } | 982 | } |
944 | 983 | ||
945 | /** | 984 | /** |
946 | * fc_fcp_pkt_send() - send a fcp packet to the lower level. | 985 | * fc_fcp_pkt_send() - Send a fcp_pkt |
947 | * @lp: fc lport | 986 | * @lport: The local port to send the FCP packet on |
948 | * @fsp: fc packet. | 987 | * @fsp: The FCP packet to send |
949 | * | 988 | * |
950 | * This is called by upper layer protocol. | 989 | * Return: Zero for success and -1 for failure |
951 | * Return : zero for success and -1 for failure | 990 | * Locks: Called with the host lock and irqs disabled. |
952 | * Context : called from queuecommand which can be called from process | ||
953 | * or scsi soft irq. | ||
954 | * Locks : called with the host lock and irqs disabled. | ||
955 | */ | 991 | */ |
956 | static int fc_fcp_pkt_send(struct fc_lport *lp, struct fc_fcp_pkt *fsp) | 992 | static int fc_fcp_pkt_send(struct fc_lport *lport, struct fc_fcp_pkt *fsp) |
957 | { | 993 | { |
958 | struct fc_fcp_internal *si = fc_get_scsi_internal(lp); | 994 | struct fc_fcp_internal *si = fc_get_scsi_internal(lport); |
959 | int rc; | 995 | int rc; |
960 | 996 | ||
961 | fsp->cmd->SCp.ptr = (char *)fsp; | 997 | fsp->cmd->SCp.ptr = (char *)fsp; |
@@ -967,16 +1003,22 @@ static int fc_fcp_pkt_send(struct fc_lport *lp, struct fc_fcp_pkt *fsp) | |||
967 | memcpy(fsp->cdb_cmd.fc_cdb, fsp->cmd->cmnd, fsp->cmd->cmd_len); | 1003 | memcpy(fsp->cdb_cmd.fc_cdb, fsp->cmd->cmnd, fsp->cmd->cmd_len); |
968 | list_add_tail(&fsp->list, &si->scsi_pkt_queue); | 1004 | list_add_tail(&fsp->list, &si->scsi_pkt_queue); |
969 | 1005 | ||
970 | spin_unlock_irq(lp->host->host_lock); | 1006 | spin_unlock_irq(lport->host->host_lock); |
971 | rc = lp->tt.fcp_cmd_send(lp, fsp, fc_fcp_recv); | 1007 | rc = lport->tt.fcp_cmd_send(lport, fsp, fc_fcp_recv); |
972 | spin_lock_irq(lp->host->host_lock); | 1008 | spin_lock_irq(lport->host->host_lock); |
973 | if (rc) | 1009 | if (rc) |
974 | list_del(&fsp->list); | 1010 | list_del(&fsp->list); |
975 | 1011 | ||
976 | return rc; | 1012 | return rc; |
977 | } | 1013 | } |
978 | 1014 | ||
979 | static int fc_fcp_cmd_send(struct fc_lport *lp, struct fc_fcp_pkt *fsp, | 1015 | /** |
1016 | * fc_fcp_cmd_send() - Send a FCP command | ||
1017 | * @lport: The local port to send the command on | ||
1018 | * @fsp: The FCP packet the command is on | ||
1019 | * @resp: The handler for the response | ||
1020 | */ | ||
1021 | static int fc_fcp_cmd_send(struct fc_lport *lport, struct fc_fcp_pkt *fsp, | ||
980 | void (*resp)(struct fc_seq *, | 1022 | void (*resp)(struct fc_seq *, |
981 | struct fc_frame *fp, | 1023 | struct fc_frame *fp, |
982 | void *arg)) | 1024 | void *arg)) |
@@ -984,14 +1026,14 @@ static int fc_fcp_cmd_send(struct fc_lport *lp, struct fc_fcp_pkt *fsp, | |||
984 | struct fc_frame *fp; | 1026 | struct fc_frame *fp; |
985 | struct fc_seq *seq; | 1027 | struct fc_seq *seq; |
986 | struct fc_rport *rport; | 1028 | struct fc_rport *rport; |
987 | struct fc_rport_libfc_priv *rp; | 1029 | struct fc_rport_libfc_priv *rpriv; |
988 | const size_t len = sizeof(fsp->cdb_cmd); | 1030 | const size_t len = sizeof(fsp->cdb_cmd); |
989 | int rc = 0; | 1031 | int rc = 0; |
990 | 1032 | ||
991 | if (fc_fcp_lock_pkt(fsp)) | 1033 | if (fc_fcp_lock_pkt(fsp)) |
992 | return 0; | 1034 | return 0; |
993 | 1035 | ||
994 | fp = fc_frame_alloc(lp, sizeof(fsp->cdb_cmd)); | 1036 | fp = fc_frame_alloc(lport, sizeof(fsp->cdb_cmd)); |
995 | if (!fp) { | 1037 | if (!fp) { |
996 | rc = -1; | 1038 | rc = -1; |
997 | goto unlock; | 1039 | goto unlock; |
@@ -1001,13 +1043,14 @@ static int fc_fcp_cmd_send(struct fc_lport *lp, struct fc_fcp_pkt *fsp, | |||
1001 | fr_fsp(fp) = fsp; | 1043 | fr_fsp(fp) = fsp; |
1002 | rport = fsp->rport; | 1044 | rport = fsp->rport; |
1003 | fsp->max_payload = rport->maxframe_size; | 1045 | fsp->max_payload = rport->maxframe_size; |
1004 | rp = rport->dd_data; | 1046 | rpriv = rport->dd_data; |
1005 | 1047 | ||
1006 | fc_fill_fc_hdr(fp, FC_RCTL_DD_UNSOL_CMD, rport->port_id, | 1048 | fc_fill_fc_hdr(fp, FC_RCTL_DD_UNSOL_CMD, rport->port_id, |
1007 | fc_host_port_id(rp->local_port->host), FC_TYPE_FCP, | 1049 | fc_host_port_id(rpriv->local_port->host), FC_TYPE_FCP, |
1008 | FC_FC_FIRST_SEQ | FC_FC_END_SEQ | FC_FC_SEQ_INIT, 0); | 1050 | FC_FC_FIRST_SEQ | FC_FC_END_SEQ | FC_FC_SEQ_INIT, 0); |
1009 | 1051 | ||
1010 | seq = lp->tt.exch_seq_send(lp, fp, resp, fc_fcp_pkt_destroy, fsp, 0); | 1052 | seq = lport->tt.exch_seq_send(lport, fp, resp, fc_fcp_pkt_destroy, |
1053 | fsp, 0); | ||
1011 | if (!seq) { | 1054 | if (!seq) { |
1012 | rc = -1; | 1055 | rc = -1; |
1013 | goto unlock; | 1056 | goto unlock; |
@@ -1025,8 +1068,10 @@ unlock: | |||
1025 | return rc; | 1068 | return rc; |
1026 | } | 1069 | } |
1027 | 1070 | ||
1028 | /* | 1071 | /** |
1029 | * transport error handler | 1072 | * fc_fcp_error() - Handler for FCP layer errors |
1073 | * @fsp: The FCP packet the error is on | ||
1074 | * @fp: The frame that has errored | ||
1030 | */ | 1075 | */ |
1031 | static void fc_fcp_error(struct fc_fcp_pkt *fsp, struct fc_frame *fp) | 1076 | static void fc_fcp_error(struct fc_fcp_pkt *fsp, struct fc_frame *fp) |
1032 | { | 1077 | { |
@@ -1051,9 +1096,11 @@ unlock: | |||
1051 | fc_fcp_unlock_pkt(fsp); | 1096 | fc_fcp_unlock_pkt(fsp); |
1052 | } | 1097 | } |
1053 | 1098 | ||
1054 | /* | 1099 | /** |
1055 | * Scsi abort handler- calls to send an abort | 1100 | * fc_fcp_pkt_abort() - Abort a fcp_pkt |
1056 | * and then wait for abort completion | 1101 | * @fsp: The FCP packet to abort on |
1102 | * | ||
1103 | * Called to send an abort and then wait for abort completion | ||
1057 | */ | 1104 | */ |
1058 | static int fc_fcp_pkt_abort(struct fc_fcp_pkt *fsp) | 1105 | static int fc_fcp_pkt_abort(struct fc_fcp_pkt *fsp) |
1059 | { | 1106 | { |
@@ -1082,14 +1129,15 @@ static int fc_fcp_pkt_abort(struct fc_fcp_pkt *fsp) | |||
1082 | return rc; | 1129 | return rc; |
1083 | } | 1130 | } |
1084 | 1131 | ||
1085 | /* | 1132 | /** |
1086 | * Retry LUN reset after resource allocation failed. | 1133 | * fc_lun_reset_send() - Send LUN reset command |
1134 | * @data: The FCP packet that identifies the LUN to be reset | ||
1087 | */ | 1135 | */ |
1088 | static void fc_lun_reset_send(unsigned long data) | 1136 | static void fc_lun_reset_send(unsigned long data) |
1089 | { | 1137 | { |
1090 | struct fc_fcp_pkt *fsp = (struct fc_fcp_pkt *)data; | 1138 | struct fc_fcp_pkt *fsp = (struct fc_fcp_pkt *)data; |
1091 | struct fc_lport *lp = fsp->lp; | 1139 | struct fc_lport *lport = fsp->lp; |
1092 | if (lp->tt.fcp_cmd_send(lp, fsp, fc_tm_done)) { | 1140 | if (lport->tt.fcp_cmd_send(lport, fsp, fc_tm_done)) { |
1093 | if (fsp->recov_retry++ >= FC_MAX_RECOV_RETRY) | 1141 | if (fsp->recov_retry++ >= FC_MAX_RECOV_RETRY) |
1094 | return; | 1142 | return; |
1095 | if (fc_fcp_lock_pkt(fsp)) | 1143 | if (fc_fcp_lock_pkt(fsp)) |
@@ -1100,11 +1148,15 @@ static void fc_lun_reset_send(unsigned long data) | |||
1100 | } | 1148 | } |
1101 | } | 1149 | } |
1102 | 1150 | ||
1103 | /* | 1151 | /** |
1104 | * Scsi device reset handler- send a LUN RESET to the device | 1152 | * fc_lun_reset() - Send a LUN RESET command to a device |
1105 | * and wait for reset reply | 1153 | * and wait for the reply |
1154 | * @lport: The local port to sent the comand on | ||
1155 | * @fsp: The FCP packet that identifies the LUN to be reset | ||
1156 | * @id: The SCSI command ID | ||
1157 | * @lun: The LUN ID to be reset | ||
1106 | */ | 1158 | */ |
1107 | static int fc_lun_reset(struct fc_lport *lp, struct fc_fcp_pkt *fsp, | 1159 | static int fc_lun_reset(struct fc_lport *lport, struct fc_fcp_pkt *fsp, |
1108 | unsigned int id, unsigned int lun) | 1160 | unsigned int id, unsigned int lun) |
1109 | { | 1161 | { |
1110 | int rc; | 1162 | int rc; |
@@ -1132,14 +1184,14 @@ static int fc_lun_reset(struct fc_lport *lp, struct fc_fcp_pkt *fsp, | |||
1132 | 1184 | ||
1133 | spin_lock_bh(&fsp->scsi_pkt_lock); | 1185 | spin_lock_bh(&fsp->scsi_pkt_lock); |
1134 | if (fsp->seq_ptr) { | 1186 | if (fsp->seq_ptr) { |
1135 | lp->tt.exch_done(fsp->seq_ptr); | 1187 | lport->tt.exch_done(fsp->seq_ptr); |
1136 | fsp->seq_ptr = NULL; | 1188 | fsp->seq_ptr = NULL; |
1137 | } | 1189 | } |
1138 | fsp->wait_for_comp = 0; | 1190 | fsp->wait_for_comp = 0; |
1139 | spin_unlock_bh(&fsp->scsi_pkt_lock); | 1191 | spin_unlock_bh(&fsp->scsi_pkt_lock); |
1140 | 1192 | ||
1141 | if (!rc) { | 1193 | if (!rc) { |
1142 | FC_SCSI_DBG(lp, "lun reset failed\n"); | 1194 | FC_SCSI_DBG(lport, "lun reset failed\n"); |
1143 | return FAILED; | 1195 | return FAILED; |
1144 | } | 1196 | } |
1145 | 1197 | ||
@@ -1147,13 +1199,16 @@ static int fc_lun_reset(struct fc_lport *lp, struct fc_fcp_pkt *fsp, | |||
1147 | if (fsp->cdb_status != FCP_TMF_CMPL) | 1199 | if (fsp->cdb_status != FCP_TMF_CMPL) |
1148 | return FAILED; | 1200 | return FAILED; |
1149 | 1201 | ||
1150 | FC_SCSI_DBG(lp, "lun reset to lun %u completed\n", lun); | 1202 | FC_SCSI_DBG(lport, "lun reset to lun %u completed\n", lun); |
1151 | fc_fcp_cleanup_each_cmd(lp, id, lun, FC_CMD_ABORTED); | 1203 | fc_fcp_cleanup_each_cmd(lport, id, lun, FC_CMD_ABORTED); |
1152 | return SUCCESS; | 1204 | return SUCCESS; |
1153 | } | 1205 | } |
1154 | 1206 | ||
1155 | /* | 1207 | /** |
1156 | * Task Managment response handler | 1208 | * fc_tm_done() - Task Managment response handler |
1209 | * @seq: The sequence that the response is on | ||
1210 | * @fp: The response frame | ||
1211 | * @arg: The FCP packet the response is for | ||
1157 | */ | 1212 | */ |
1158 | static void fc_tm_done(struct fc_seq *seq, struct fc_frame *fp, void *arg) | 1213 | static void fc_tm_done(struct fc_seq *seq, struct fc_frame *fp, void *arg) |
1159 | { | 1214 | { |
@@ -1190,34 +1245,31 @@ static void fc_tm_done(struct fc_seq *seq, struct fc_frame *fp, void *arg) | |||
1190 | fc_fcp_unlock_pkt(fsp); | 1245 | fc_fcp_unlock_pkt(fsp); |
1191 | } | 1246 | } |
1192 | 1247 | ||
1193 | static void fc_fcp_cleanup(struct fc_lport *lp) | 1248 | /** |
1249 | * fc_fcp_cleanup() - Cleanup all FCP exchanges on a local port | ||
1250 | * @lport: The local port to be cleaned up | ||
1251 | */ | ||
1252 | static void fc_fcp_cleanup(struct fc_lport *lport) | ||
1194 | { | 1253 | { |
1195 | fc_fcp_cleanup_each_cmd(lp, -1, -1, FC_ERROR); | 1254 | fc_fcp_cleanup_each_cmd(lport, -1, -1, FC_ERROR); |
1196 | } | 1255 | } |
1197 | 1256 | ||
1198 | /* | 1257 | /** |
1199 | * fc_fcp_timeout: called by OS timer function. | 1258 | * fc_fcp_timeout() - Handler for fcp_pkt timeouts |
1200 | * | 1259 | * @data: The FCP packet that has timed out |
1201 | * The timer has been inactivated and must be reactivated if desired | ||
1202 | * using fc_fcp_timer_set(). | ||
1203 | * | ||
1204 | * Algorithm: | ||
1205 | * | ||
1206 | * If REC is supported, just issue it, and return. The REC exchange will | ||
1207 | * complete or time out, and recovery can continue at that point. | ||
1208 | * | ||
1209 | * Otherwise, if the response has been received without all the data, | ||
1210 | * it has been ER_TIMEOUT since the response was received. | ||
1211 | * | 1260 | * |
1212 | * If the response has not been received, | 1261 | * If REC is supported then just issue it and return. The REC exchange will |
1213 | * we see if data was received recently. If it has been, we continue waiting, | 1262 | * complete or time out and recovery can continue at that point. Otherwise, |
1214 | * otherwise, we abort the command. | 1263 | * if the response has been received without all the data it has been |
1264 | * ER_TIMEOUT since the response was received. If the response has not been | ||
1265 | * received we see if data was received recently. If it has been then we | ||
1266 | * continue waiting, otherwise, we abort the command. | ||
1215 | */ | 1267 | */ |
1216 | static void fc_fcp_timeout(unsigned long data) | 1268 | static void fc_fcp_timeout(unsigned long data) |
1217 | { | 1269 | { |
1218 | struct fc_fcp_pkt *fsp = (struct fc_fcp_pkt *)data; | 1270 | struct fc_fcp_pkt *fsp = (struct fc_fcp_pkt *)data; |
1219 | struct fc_rport *rport = fsp->rport; | 1271 | struct fc_rport *rport = fsp->rport; |
1220 | struct fc_rport_libfc_priv *rp = rport->dd_data; | 1272 | struct fc_rport_libfc_priv *rpriv = rport->dd_data; |
1221 | 1273 | ||
1222 | if (fc_fcp_lock_pkt(fsp)) | 1274 | if (fc_fcp_lock_pkt(fsp)) |
1223 | return; | 1275 | return; |
@@ -1227,7 +1279,7 @@ static void fc_fcp_timeout(unsigned long data) | |||
1227 | 1279 | ||
1228 | fsp->state |= FC_SRB_FCP_PROCESSING_TMO; | 1280 | fsp->state |= FC_SRB_FCP_PROCESSING_TMO; |
1229 | 1281 | ||
1230 | if (rp->flags & FC_RP_FLAGS_REC_SUPPORTED) | 1282 | if (rpriv->flags & FC_RP_FLAGS_REC_SUPPORTED) |
1231 | fc_fcp_rec(fsp); | 1283 | fc_fcp_rec(fsp); |
1232 | else if (time_after_eq(fsp->last_pkt_time + (FC_SCSI_ER_TIMEOUT / 2), | 1284 | else if (time_after_eq(fsp->last_pkt_time + (FC_SCSI_ER_TIMEOUT / 2), |
1233 | jiffies)) | 1285 | jiffies)) |
@@ -1241,35 +1293,37 @@ unlock: | |||
1241 | fc_fcp_unlock_pkt(fsp); | 1293 | fc_fcp_unlock_pkt(fsp); |
1242 | } | 1294 | } |
1243 | 1295 | ||
1244 | /* | 1296 | /** |
1245 | * Send a REC ELS request | 1297 | * fc_fcp_rec() - Send a REC ELS request |
1298 | * @fsp: The FCP packet to send the REC request on | ||
1246 | */ | 1299 | */ |
1247 | static void fc_fcp_rec(struct fc_fcp_pkt *fsp) | 1300 | static void fc_fcp_rec(struct fc_fcp_pkt *fsp) |
1248 | { | 1301 | { |
1249 | struct fc_lport *lp; | 1302 | struct fc_lport *lport; |
1250 | struct fc_frame *fp; | 1303 | struct fc_frame *fp; |
1251 | struct fc_rport *rport; | 1304 | struct fc_rport *rport; |
1252 | struct fc_rport_libfc_priv *rp; | 1305 | struct fc_rport_libfc_priv *rpriv; |
1253 | 1306 | ||
1254 | lp = fsp->lp; | 1307 | lport = fsp->lp; |
1255 | rport = fsp->rport; | 1308 | rport = fsp->rport; |
1256 | rp = rport->dd_data; | 1309 | rpriv = rport->dd_data; |
1257 | if (!fsp->seq_ptr || rp->rp_state != RPORT_ST_READY) { | 1310 | if (!fsp->seq_ptr || rpriv->rp_state != RPORT_ST_READY) { |
1258 | fsp->status_code = FC_HRD_ERROR; | 1311 | fsp->status_code = FC_HRD_ERROR; |
1259 | fsp->io_status = 0; | 1312 | fsp->io_status = 0; |
1260 | fc_fcp_complete_locked(fsp); | 1313 | fc_fcp_complete_locked(fsp); |
1261 | return; | 1314 | return; |
1262 | } | 1315 | } |
1263 | fp = fc_frame_alloc(lp, sizeof(struct fc_els_rec)); | 1316 | fp = fc_frame_alloc(lport, sizeof(struct fc_els_rec)); |
1264 | if (!fp) | 1317 | if (!fp) |
1265 | goto retry; | 1318 | goto retry; |
1266 | 1319 | ||
1267 | fr_seq(fp) = fsp->seq_ptr; | 1320 | fr_seq(fp) = fsp->seq_ptr; |
1268 | fc_fill_fc_hdr(fp, FC_RCTL_ELS_REQ, rport->port_id, | 1321 | fc_fill_fc_hdr(fp, FC_RCTL_ELS_REQ, rport->port_id, |
1269 | fc_host_port_id(rp->local_port->host), FC_TYPE_ELS, | 1322 | fc_host_port_id(rpriv->local_port->host), FC_TYPE_ELS, |
1270 | FC_FC_FIRST_SEQ | FC_FC_END_SEQ | FC_FC_SEQ_INIT, 0); | 1323 | FC_FC_FIRST_SEQ | FC_FC_END_SEQ | FC_FC_SEQ_INIT, 0); |
1271 | if (lp->tt.elsct_send(lp, rport->port_id, fp, ELS_REC, fc_fcp_rec_resp, | 1324 | if (lport->tt.elsct_send(lport, rport->port_id, fp, ELS_REC, |
1272 | fsp, jiffies_to_msecs(FC_SCSI_REC_TOV))) { | 1325 | fc_fcp_rec_resp, fsp, |
1326 | jiffies_to_msecs(FC_SCSI_REC_TOV))) { | ||
1273 | fc_fcp_pkt_hold(fsp); /* hold while REC outstanding */ | 1327 | fc_fcp_pkt_hold(fsp); /* hold while REC outstanding */ |
1274 | return; | 1328 | return; |
1275 | } | 1329 | } |
@@ -1280,12 +1334,16 @@ retry: | |||
1280 | fc_timeout_error(fsp); | 1334 | fc_timeout_error(fsp); |
1281 | } | 1335 | } |
1282 | 1336 | ||
1283 | /* | 1337 | /** |
1284 | * Receive handler for REC ELS frame | 1338 | * fc_fcp_rec_resp() - Handler for REC ELS responses |
1285 | * if it is a reject then let the scsi layer to handle | 1339 | * @seq: The sequence the response is on |
1286 | * the timeout. if it is a LS_ACC then if the io was not completed | 1340 | * @fp: The response frame |
1287 | * then set the timeout and return otherwise complete the exchange | 1341 | * @arg: The FCP packet the response is on |
1288 | * and tell the scsi layer to restart the I/O. | 1342 | * |
1343 | * If the response is a reject then the scsi layer will handle | ||
1344 | * the timeout. If the response is a LS_ACC then if the I/O was not completed | ||
1345 | * set the timeout and return. If the I/O was completed then complete the | ||
1346 | * exchange and tell the SCSI layer. | ||
1289 | */ | 1347 | */ |
1290 | static void fc_fcp_rec_resp(struct fc_seq *seq, struct fc_frame *fp, void *arg) | 1348 | static void fc_fcp_rec_resp(struct fc_seq *seq, struct fc_frame *fp, void *arg) |
1291 | { | 1349 | { |
@@ -1297,7 +1355,7 @@ static void fc_fcp_rec_resp(struct fc_seq *seq, struct fc_frame *fp, void *arg) | |||
1297 | u32 offset; | 1355 | u32 offset; |
1298 | enum dma_data_direction data_dir; | 1356 | enum dma_data_direction data_dir; |
1299 | enum fc_rctl r_ctl; | 1357 | enum fc_rctl r_ctl; |
1300 | struct fc_rport_libfc_priv *rp; | 1358 | struct fc_rport_libfc_priv *rpriv; |
1301 | 1359 | ||
1302 | if (IS_ERR(fp)) { | 1360 | if (IS_ERR(fp)) { |
1303 | fc_fcp_rec_error(fsp, fp); | 1361 | fc_fcp_rec_error(fsp, fp); |
@@ -1320,13 +1378,13 @@ static void fc_fcp_rec_resp(struct fc_seq *seq, struct fc_frame *fp, void *arg) | |||
1320 | /* fall through */ | 1378 | /* fall through */ |
1321 | case ELS_RJT_UNSUP: | 1379 | case ELS_RJT_UNSUP: |
1322 | FC_FCP_DBG(fsp, "device does not support REC\n"); | 1380 | FC_FCP_DBG(fsp, "device does not support REC\n"); |
1323 | rp = fsp->rport->dd_data; | 1381 | rpriv = fsp->rport->dd_data; |
1324 | /* | 1382 | /* |
1325 | * if we do not spport RECs or got some bogus | 1383 | * if we do not spport RECs or got some bogus |
1326 | * reason then resetup timer so we check for | 1384 | * reason then resetup timer so we check for |
1327 | * making progress. | 1385 | * making progress. |
1328 | */ | 1386 | */ |
1329 | rp->flags &= ~FC_RP_FLAGS_REC_SUPPORTED; | 1387 | rpriv->flags &= ~FC_RP_FLAGS_REC_SUPPORTED; |
1330 | fc_fcp_timer_set(fsp, FC_SCSI_ER_TIMEOUT); | 1388 | fc_fcp_timer_set(fsp, FC_SCSI_ER_TIMEOUT); |
1331 | break; | 1389 | break; |
1332 | case ELS_RJT_LOGIC: | 1390 | case ELS_RJT_LOGIC: |
@@ -1423,8 +1481,10 @@ out: | |||
1423 | fc_frame_free(fp); | 1481 | fc_frame_free(fp); |
1424 | } | 1482 | } |
1425 | 1483 | ||
1426 | /* | 1484 | /** |
1427 | * Handle error response or timeout for REC exchange. | 1485 | * fc_fcp_rec_error() - Handler for REC errors |
1486 | * @fsp: The FCP packet the error is on | ||
1487 | * @fp: The REC frame | ||
1428 | */ | 1488 | */ |
1429 | static void fc_fcp_rec_error(struct fc_fcp_pkt *fsp, struct fc_frame *fp) | 1489 | static void fc_fcp_rec_error(struct fc_fcp_pkt *fsp, struct fc_frame *fp) |
1430 | { | 1490 | { |
@@ -1463,10 +1523,9 @@ out: | |||
1463 | fc_fcp_pkt_release(fsp); /* drop hold for outstanding REC */ | 1523 | fc_fcp_pkt_release(fsp); /* drop hold for outstanding REC */ |
1464 | } | 1524 | } |
1465 | 1525 | ||
1466 | /* | 1526 | /** |
1467 | * Time out error routine: | 1527 | * fc_timeout_error() - Handler for fcp_pkt timeouts |
1468 | * abort's the I/O close the exchange and | 1528 | * @fsp: The FCP packt that has timed out |
1469 | * send completion notification to scsi layer | ||
1470 | */ | 1529 | */ |
1471 | static void fc_timeout_error(struct fc_fcp_pkt *fsp) | 1530 | static void fc_timeout_error(struct fc_fcp_pkt *fsp) |
1472 | { | 1531 | { |
@@ -1480,16 +1539,18 @@ static void fc_timeout_error(struct fc_fcp_pkt *fsp) | |||
1480 | fc_fcp_send_abort(fsp); | 1539 | fc_fcp_send_abort(fsp); |
1481 | } | 1540 | } |
1482 | 1541 | ||
1483 | /* | 1542 | /** |
1484 | * Sequence retransmission request. | 1543 | * fc_fcp_srr() - Send a SRR request (Sequence Retransmission Request) |
1544 | * @fsp: The FCP packet the SRR is to be sent on | ||
1545 | * @r_ctl: The R_CTL field for the SRR request | ||
1485 | * This is called after receiving status but insufficient data, or | 1546 | * This is called after receiving status but insufficient data, or |
1486 | * when expecting status but the request has timed out. | 1547 | * when expecting status but the request has timed out. |
1487 | */ | 1548 | */ |
1488 | static void fc_fcp_srr(struct fc_fcp_pkt *fsp, enum fc_rctl r_ctl, u32 offset) | 1549 | static void fc_fcp_srr(struct fc_fcp_pkt *fsp, enum fc_rctl r_ctl, u32 offset) |
1489 | { | 1550 | { |
1490 | struct fc_lport *lp = fsp->lp; | 1551 | struct fc_lport *lport = fsp->lp; |
1491 | struct fc_rport *rport; | 1552 | struct fc_rport *rport; |
1492 | struct fc_rport_libfc_priv *rp; | 1553 | struct fc_rport_libfc_priv *rpriv; |
1493 | struct fc_exch *ep = fc_seq_exch(fsp->seq_ptr); | 1554 | struct fc_exch *ep = fc_seq_exch(fsp->seq_ptr); |
1494 | struct fc_seq *seq; | 1555 | struct fc_seq *seq; |
1495 | struct fcp_srr *srr; | 1556 | struct fcp_srr *srr; |
@@ -1497,12 +1558,13 @@ static void fc_fcp_srr(struct fc_fcp_pkt *fsp, enum fc_rctl r_ctl, u32 offset) | |||
1497 | u8 cdb_op; | 1558 | u8 cdb_op; |
1498 | 1559 | ||
1499 | rport = fsp->rport; | 1560 | rport = fsp->rport; |
1500 | rp = rport->dd_data; | 1561 | rpriv = rport->dd_data; |
1501 | cdb_op = fsp->cdb_cmd.fc_cdb[0]; | 1562 | cdb_op = fsp->cdb_cmd.fc_cdb[0]; |
1502 | 1563 | ||
1503 | if (!(rp->flags & FC_RP_FLAGS_RETRY) || rp->rp_state != RPORT_ST_READY) | 1564 | if (!(rpriv->flags & FC_RP_FLAGS_RETRY) || |
1565 | rpriv->rp_state != RPORT_ST_READY) | ||
1504 | goto retry; /* shouldn't happen */ | 1566 | goto retry; /* shouldn't happen */ |
1505 | fp = fc_frame_alloc(lp, sizeof(*srr)); | 1567 | fp = fc_frame_alloc(lport, sizeof(*srr)); |
1506 | if (!fp) | 1568 | if (!fp) |
1507 | goto retry; | 1569 | goto retry; |
1508 | 1570 | ||
@@ -1515,11 +1577,11 @@ static void fc_fcp_srr(struct fc_fcp_pkt *fsp, enum fc_rctl r_ctl, u32 offset) | |||
1515 | srr->srr_rel_off = htonl(offset); | 1577 | srr->srr_rel_off = htonl(offset); |
1516 | 1578 | ||
1517 | fc_fill_fc_hdr(fp, FC_RCTL_ELS4_REQ, rport->port_id, | 1579 | fc_fill_fc_hdr(fp, FC_RCTL_ELS4_REQ, rport->port_id, |
1518 | fc_host_port_id(rp->local_port->host), FC_TYPE_FCP, | 1580 | fc_host_port_id(rpriv->local_port->host), FC_TYPE_FCP, |
1519 | FC_FC_FIRST_SEQ | FC_FC_END_SEQ | FC_FC_SEQ_INIT, 0); | 1581 | FC_FC_FIRST_SEQ | FC_FC_END_SEQ | FC_FC_SEQ_INIT, 0); |
1520 | 1582 | ||
1521 | seq = lp->tt.exch_seq_send(lp, fp, fc_fcp_srr_resp, NULL, | 1583 | seq = lport->tt.exch_seq_send(lport, fp, fc_fcp_srr_resp, NULL, |
1522 | fsp, jiffies_to_msecs(FC_SCSI_REC_TOV)); | 1584 | fsp, jiffies_to_msecs(FC_SCSI_REC_TOV)); |
1523 | if (!seq) | 1585 | if (!seq) |
1524 | goto retry; | 1586 | goto retry; |
1525 | 1587 | ||
@@ -1533,8 +1595,11 @@ retry: | |||
1533 | fc_fcp_retry_cmd(fsp); | 1595 | fc_fcp_retry_cmd(fsp); |
1534 | } | 1596 | } |
1535 | 1597 | ||
1536 | /* | 1598 | /** |
1537 | * Handle response from SRR. | 1599 | * fc_fcp_srr_resp() - Handler for SRR response |
1600 | * @seq: The sequence the SRR is on | ||
1601 | * @fp: The SRR frame | ||
1602 | * @arg: The FCP packet the SRR is on | ||
1538 | */ | 1603 | */ |
1539 | static void fc_fcp_srr_resp(struct fc_seq *seq, struct fc_frame *fp, void *arg) | 1604 | static void fc_fcp_srr_resp(struct fc_seq *seq, struct fc_frame *fp, void *arg) |
1540 | { | 1605 | { |
@@ -1580,6 +1645,11 @@ out: | |||
1580 | fc_fcp_pkt_release(fsp); /* drop hold for outstanding SRR */ | 1645 | fc_fcp_pkt_release(fsp); /* drop hold for outstanding SRR */ |
1581 | } | 1646 | } |
1582 | 1647 | ||
1648 | /** | ||
1649 | * fc_fcp_srr_error() - Handler for SRR errors | ||
1650 | * @fsp: The FCP packet that the SRR error is on | ||
1651 | * @fp: The SRR frame | ||
1652 | */ | ||
1583 | static void fc_fcp_srr_error(struct fc_fcp_pkt *fsp, struct fc_frame *fp) | 1653 | static void fc_fcp_srr_error(struct fc_fcp_pkt *fsp, struct fc_frame *fp) |
1584 | { | 1654 | { |
1585 | if (fc_fcp_lock_pkt(fsp)) | 1655 | if (fc_fcp_lock_pkt(fsp)) |
@@ -1604,31 +1674,36 @@ out: | |||
1604 | fc_fcp_pkt_release(fsp); /* drop hold for outstanding SRR */ | 1674 | fc_fcp_pkt_release(fsp); /* drop hold for outstanding SRR */ |
1605 | } | 1675 | } |
1606 | 1676 | ||
1607 | static inline int fc_fcp_lport_queue_ready(struct fc_lport *lp) | 1677 | /** |
1678 | * fc_fcp_lport_queue_ready() - Determine if the lport and it's queue is ready | ||
1679 | * @lport: The local port to be checked | ||
1680 | */ | ||
1681 | static inline int fc_fcp_lport_queue_ready(struct fc_lport *lport) | ||
1608 | { | 1682 | { |
1609 | /* lock ? */ | 1683 | /* lock ? */ |
1610 | return (lp->state == LPORT_ST_READY) && lp->link_up && !lp->qfull; | 1684 | return (lport->state == LPORT_ST_READY) && |
1685 | lport->link_up && !lport->qfull; | ||
1611 | } | 1686 | } |
1612 | 1687 | ||
1613 | /** | 1688 | /** |
1614 | * fc_queuecommand - The queuecommand function of the scsi template | 1689 | * fc_queuecommand() - The queuecommand function of the SCSI template |
1615 | * @cmd: struct scsi_cmnd to be executed | 1690 | * @cmd: The scsi_cmnd to be executed |
1616 | * @done: Callback function to be called when cmd is completed | 1691 | * @done: The callback function to be called when the scsi_cmnd is complete |
1617 | * | 1692 | * |
1618 | * this is the i/o strategy routine, called by the scsi layer | 1693 | * This is the i/o strategy routine, called by the SCSI layer. This routine |
1619 | * this routine is called with holding the host_lock. | 1694 | * is called with the host_lock held. |
1620 | */ | 1695 | */ |
1621 | int fc_queuecommand(struct scsi_cmnd *sc_cmd, void (*done)(struct scsi_cmnd *)) | 1696 | int fc_queuecommand(struct scsi_cmnd *sc_cmd, void (*done)(struct scsi_cmnd *)) |
1622 | { | 1697 | { |
1623 | struct fc_lport *lp; | 1698 | struct fc_lport *lport; |
1624 | struct fc_rport *rport = starget_to_rport(scsi_target(sc_cmd->device)); | 1699 | struct fc_rport *rport = starget_to_rport(scsi_target(sc_cmd->device)); |
1625 | struct fc_fcp_pkt *fsp; | 1700 | struct fc_fcp_pkt *fsp; |
1626 | struct fc_rport_libfc_priv *rp; | 1701 | struct fc_rport_libfc_priv *rpriv; |
1627 | int rval; | 1702 | int rval; |
1628 | int rc = 0; | 1703 | int rc = 0; |
1629 | struct fcoe_dev_stats *stats; | 1704 | struct fcoe_dev_stats *stats; |
1630 | 1705 | ||
1631 | lp = shost_priv(sc_cmd->device->host); | 1706 | lport = shost_priv(sc_cmd->device->host); |
1632 | 1707 | ||
1633 | rval = fc_remote_port_chkready(rport); | 1708 | rval = fc_remote_port_chkready(rport); |
1634 | if (rval) { | 1709 | if (rval) { |
@@ -1647,14 +1722,14 @@ int fc_queuecommand(struct scsi_cmnd *sc_cmd, void (*done)(struct scsi_cmnd *)) | |||
1647 | goto out; | 1722 | goto out; |
1648 | } | 1723 | } |
1649 | 1724 | ||
1650 | rp = rport->dd_data; | 1725 | rpriv = rport->dd_data; |
1651 | 1726 | ||
1652 | if (!fc_fcp_lport_queue_ready(lp)) { | 1727 | if (!fc_fcp_lport_queue_ready(lport)) { |
1653 | rc = SCSI_MLQUEUE_HOST_BUSY; | 1728 | rc = SCSI_MLQUEUE_HOST_BUSY; |
1654 | goto out; | 1729 | goto out; |
1655 | } | 1730 | } |
1656 | 1731 | ||
1657 | fsp = fc_fcp_pkt_alloc(lp, GFP_ATOMIC); | 1732 | fsp = fc_fcp_pkt_alloc(lport, GFP_ATOMIC); |
1658 | if (fsp == NULL) { | 1733 | if (fsp == NULL) { |
1659 | rc = SCSI_MLQUEUE_HOST_BUSY; | 1734 | rc = SCSI_MLQUEUE_HOST_BUSY; |
1660 | goto out; | 1735 | goto out; |
@@ -1664,7 +1739,7 @@ int fc_queuecommand(struct scsi_cmnd *sc_cmd, void (*done)(struct scsi_cmnd *)) | |||
1664 | * build the libfc request pkt | 1739 | * build the libfc request pkt |
1665 | */ | 1740 | */ |
1666 | fsp->cmd = sc_cmd; /* save the cmd */ | 1741 | fsp->cmd = sc_cmd; /* save the cmd */ |
1667 | fsp->lp = lp; /* save the softc ptr */ | 1742 | fsp->lp = lport; /* save the softc ptr */ |
1668 | fsp->rport = rport; /* set the remote port ptr */ | 1743 | fsp->rport = rport; /* set the remote port ptr */ |
1669 | fsp->xfer_ddp = FC_XID_UNKNOWN; | 1744 | fsp->xfer_ddp = FC_XID_UNKNOWN; |
1670 | sc_cmd->scsi_done = done; | 1745 | sc_cmd->scsi_done = done; |
@@ -1678,7 +1753,7 @@ int fc_queuecommand(struct scsi_cmnd *sc_cmd, void (*done)(struct scsi_cmnd *)) | |||
1678 | /* | 1753 | /* |
1679 | * setup the data direction | 1754 | * setup the data direction |
1680 | */ | 1755 | */ |
1681 | stats = fc_lport_get_stats(lp); | 1756 | stats = fc_lport_get_stats(lport); |
1682 | if (sc_cmd->sc_data_direction == DMA_FROM_DEVICE) { | 1757 | if (sc_cmd->sc_data_direction == DMA_FROM_DEVICE) { |
1683 | fsp->req_flags = FC_SRB_READ; | 1758 | fsp->req_flags = FC_SRB_READ; |
1684 | stats->InputRequests++; | 1759 | stats->InputRequests++; |
@@ -1692,7 +1767,7 @@ int fc_queuecommand(struct scsi_cmnd *sc_cmd, void (*done)(struct scsi_cmnd *)) | |||
1692 | stats->ControlRequests++; | 1767 | stats->ControlRequests++; |
1693 | } | 1768 | } |
1694 | 1769 | ||
1695 | fsp->tgt_flags = rp->flags; | 1770 | fsp->tgt_flags = rpriv->flags; |
1696 | 1771 | ||
1697 | init_timer(&fsp->timer); | 1772 | init_timer(&fsp->timer); |
1698 | fsp->timer.data = (unsigned long)fsp; | 1773 | fsp->timer.data = (unsigned long)fsp; |
@@ -1702,7 +1777,7 @@ int fc_queuecommand(struct scsi_cmnd *sc_cmd, void (*done)(struct scsi_cmnd *)) | |||
1702 | * if we get -1 return then put the request in the pending | 1777 | * if we get -1 return then put the request in the pending |
1703 | * queue. | 1778 | * queue. |
1704 | */ | 1779 | */ |
1705 | rval = fc_fcp_pkt_send(lp, fsp); | 1780 | rval = fc_fcp_pkt_send(lport, fsp); |
1706 | if (rval != 0) { | 1781 | if (rval != 0) { |
1707 | fsp->state = FC_SRB_FREE; | 1782 | fsp->state = FC_SRB_FREE; |
1708 | fc_fcp_pkt_release(fsp); | 1783 | fc_fcp_pkt_release(fsp); |
@@ -1714,18 +1789,17 @@ out: | |||
1714 | EXPORT_SYMBOL(fc_queuecommand); | 1789 | EXPORT_SYMBOL(fc_queuecommand); |
1715 | 1790 | ||
1716 | /** | 1791 | /** |
1717 | * fc_io_compl() - Handle responses for completed commands | 1792 | * fc_io_compl() - Handle responses for completed commands |
1718 | * @fsp: scsi packet | 1793 | * @fsp: The FCP packet that is complete |
1719 | * | ||
1720 | * Translates a error to a Linux SCSI error. | ||
1721 | * | 1794 | * |
1795 | * Translates fcp_pkt errors to a Linux SCSI errors. | ||
1722 | * The fcp packet lock must be held when calling. | 1796 | * The fcp packet lock must be held when calling. |
1723 | */ | 1797 | */ |
1724 | static void fc_io_compl(struct fc_fcp_pkt *fsp) | 1798 | static void fc_io_compl(struct fc_fcp_pkt *fsp) |
1725 | { | 1799 | { |
1726 | struct fc_fcp_internal *si; | 1800 | struct fc_fcp_internal *si; |
1727 | struct scsi_cmnd *sc_cmd; | 1801 | struct scsi_cmnd *sc_cmd; |
1728 | struct fc_lport *lp; | 1802 | struct fc_lport *lport; |
1729 | unsigned long flags; | 1803 | unsigned long flags; |
1730 | 1804 | ||
1731 | /* release outstanding ddp context */ | 1805 | /* release outstanding ddp context */ |
@@ -1738,11 +1812,11 @@ static void fc_io_compl(struct fc_fcp_pkt *fsp) | |||
1738 | spin_lock_bh(&fsp->scsi_pkt_lock); | 1812 | spin_lock_bh(&fsp->scsi_pkt_lock); |
1739 | } | 1813 | } |
1740 | 1814 | ||
1741 | lp = fsp->lp; | 1815 | lport = fsp->lp; |
1742 | si = fc_get_scsi_internal(lp); | 1816 | si = fc_get_scsi_internal(lport); |
1743 | spin_lock_irqsave(lp->host->host_lock, flags); | 1817 | spin_lock_irqsave(lport->host->host_lock, flags); |
1744 | if (!fsp->cmd) { | 1818 | if (!fsp->cmd) { |
1745 | spin_unlock_irqrestore(lp->host->host_lock, flags); | 1819 | spin_unlock_irqrestore(lport->host->host_lock, flags); |
1746 | return; | 1820 | return; |
1747 | } | 1821 | } |
1748 | 1822 | ||
@@ -1759,7 +1833,7 @@ static void fc_io_compl(struct fc_fcp_pkt *fsp) | |||
1759 | fsp->cmd = NULL; | 1833 | fsp->cmd = NULL; |
1760 | 1834 | ||
1761 | if (!sc_cmd->SCp.ptr) { | 1835 | if (!sc_cmd->SCp.ptr) { |
1762 | spin_unlock_irqrestore(lp->host->host_lock, flags); | 1836 | spin_unlock_irqrestore(lport->host->host_lock, flags); |
1763 | return; | 1837 | return; |
1764 | } | 1838 | } |
1765 | 1839 | ||
@@ -1826,7 +1900,7 @@ static void fc_io_compl(struct fc_fcp_pkt *fsp) | |||
1826 | list_del(&fsp->list); | 1900 | list_del(&fsp->list); |
1827 | sc_cmd->SCp.ptr = NULL; | 1901 | sc_cmd->SCp.ptr = NULL; |
1828 | sc_cmd->scsi_done(sc_cmd); | 1902 | sc_cmd->scsi_done(sc_cmd); |
1829 | spin_unlock_irqrestore(lp->host->host_lock, flags); | 1903 | spin_unlock_irqrestore(lport->host->host_lock, flags); |
1830 | 1904 | ||
1831 | /* release ref from initial allocation in queue command */ | 1905 | /* release ref from initial allocation in queue command */ |
1832 | fc_fcp_pkt_release(fsp); | 1906 | fc_fcp_pkt_release(fsp); |
@@ -1834,35 +1908,34 @@ static void fc_io_compl(struct fc_fcp_pkt *fsp) | |||
1834 | 1908 | ||
1835 | /** | 1909 | /** |
1836 | * fc_eh_abort() - Abort a command | 1910 | * fc_eh_abort() - Abort a command |
1837 | * @sc_cmd: scsi command to abort | 1911 | * @sc_cmd: The SCSI command to abort |
1838 | * | 1912 | * |
1839 | * From scsi host template. | 1913 | * From SCSI host template. |
1840 | * send ABTS to the target device and wait for the response | 1914 | * Send an ABTS to the target device and wait for the response. |
1841 | * sc_cmd is the pointer to the command to be aborted. | ||
1842 | */ | 1915 | */ |
1843 | int fc_eh_abort(struct scsi_cmnd *sc_cmd) | 1916 | int fc_eh_abort(struct scsi_cmnd *sc_cmd) |
1844 | { | 1917 | { |
1845 | struct fc_fcp_pkt *fsp; | 1918 | struct fc_fcp_pkt *fsp; |
1846 | struct fc_lport *lp; | 1919 | struct fc_lport *lport; |
1847 | int rc = FAILED; | 1920 | int rc = FAILED; |
1848 | unsigned long flags; | 1921 | unsigned long flags; |
1849 | 1922 | ||
1850 | lp = shost_priv(sc_cmd->device->host); | 1923 | lport = shost_priv(sc_cmd->device->host); |
1851 | if (lp->state != LPORT_ST_READY) | 1924 | if (lport->state != LPORT_ST_READY) |
1852 | return rc; | 1925 | return rc; |
1853 | else if (!lp->link_up) | 1926 | else if (!lport->link_up) |
1854 | return rc; | 1927 | return rc; |
1855 | 1928 | ||
1856 | spin_lock_irqsave(lp->host->host_lock, flags); | 1929 | spin_lock_irqsave(lport->host->host_lock, flags); |
1857 | fsp = CMD_SP(sc_cmd); | 1930 | fsp = CMD_SP(sc_cmd); |
1858 | if (!fsp) { | 1931 | if (!fsp) { |
1859 | /* command completed while scsi eh was setting up */ | 1932 | /* command completed while scsi eh was setting up */ |
1860 | spin_unlock_irqrestore(lp->host->host_lock, flags); | 1933 | spin_unlock_irqrestore(lport->host->host_lock, flags); |
1861 | return SUCCESS; | 1934 | return SUCCESS; |
1862 | } | 1935 | } |
1863 | /* grab a ref so the fsp and sc_cmd cannot be relased from under us */ | 1936 | /* grab a ref so the fsp and sc_cmd cannot be relased from under us */ |
1864 | fc_fcp_pkt_hold(fsp); | 1937 | fc_fcp_pkt_hold(fsp); |
1865 | spin_unlock_irqrestore(lp->host->host_lock, flags); | 1938 | spin_unlock_irqrestore(lport->host->host_lock, flags); |
1866 | 1939 | ||
1867 | if (fc_fcp_lock_pkt(fsp)) { | 1940 | if (fc_fcp_lock_pkt(fsp)) { |
1868 | /* completed while we were waiting for timer to be deleted */ | 1941 | /* completed while we were waiting for timer to be deleted */ |
@@ -1880,34 +1953,32 @@ release_pkt: | |||
1880 | EXPORT_SYMBOL(fc_eh_abort); | 1953 | EXPORT_SYMBOL(fc_eh_abort); |
1881 | 1954 | ||
1882 | /** | 1955 | /** |
1883 | * fc_eh_device_reset() Reset a single LUN | 1956 | * fc_eh_device_reset() - Reset a single LUN |
1884 | * @sc_cmd: scsi command | 1957 | * @sc_cmd: The SCSI command which identifies the device whose |
1958 | * LUN is to be reset | ||
1885 | * | 1959 | * |
1886 | * Set from scsi host template to send tm cmd to the target and wait for the | 1960 | * Set from SCSI host template. |
1887 | * response. | ||
1888 | */ | 1961 | */ |
1889 | int fc_eh_device_reset(struct scsi_cmnd *sc_cmd) | 1962 | int fc_eh_device_reset(struct scsi_cmnd *sc_cmd) |
1890 | { | 1963 | { |
1891 | struct fc_lport *lp; | 1964 | struct fc_lport *lport; |
1892 | struct fc_fcp_pkt *fsp; | 1965 | struct fc_fcp_pkt *fsp; |
1893 | struct fc_rport *rport = starget_to_rport(scsi_target(sc_cmd->device)); | 1966 | struct fc_rport *rport = starget_to_rport(scsi_target(sc_cmd->device)); |
1894 | int rc = FAILED; | 1967 | int rc = FAILED; |
1895 | struct fc_rport_libfc_priv *rp; | ||
1896 | int rval; | 1968 | int rval; |
1897 | 1969 | ||
1898 | rval = fc_remote_port_chkready(rport); | 1970 | rval = fc_remote_port_chkready(rport); |
1899 | if (rval) | 1971 | if (rval) |
1900 | goto out; | 1972 | goto out; |
1901 | 1973 | ||
1902 | rp = rport->dd_data; | 1974 | lport = shost_priv(sc_cmd->device->host); |
1903 | lp = shost_priv(sc_cmd->device->host); | ||
1904 | 1975 | ||
1905 | if (lp->state != LPORT_ST_READY) | 1976 | if (lport->state != LPORT_ST_READY) |
1906 | return rc; | 1977 | return rc; |
1907 | 1978 | ||
1908 | FC_SCSI_DBG(lp, "Resetting rport (%6x)\n", rport->port_id); | 1979 | FC_SCSI_DBG(lport, "Resetting rport (%6x)\n", rport->port_id); |
1909 | 1980 | ||
1910 | fsp = fc_fcp_pkt_alloc(lp, GFP_NOIO); | 1981 | fsp = fc_fcp_pkt_alloc(lport, GFP_NOIO); |
1911 | if (fsp == NULL) { | 1982 | if (fsp == NULL) { |
1912 | printk(KERN_WARNING "libfc: could not allocate scsi_pkt\n"); | 1983 | printk(KERN_WARNING "libfc: could not allocate scsi_pkt\n"); |
1913 | sc_cmd->result = DID_NO_CONNECT << 16; | 1984 | sc_cmd->result = DID_NO_CONNECT << 16; |
@@ -1919,13 +1990,13 @@ int fc_eh_device_reset(struct scsi_cmnd *sc_cmd) | |||
1919 | * the sc passed in is not setup for execution like when sent | 1990 | * the sc passed in is not setup for execution like when sent |
1920 | * through the queuecommand callout. | 1991 | * through the queuecommand callout. |
1921 | */ | 1992 | */ |
1922 | fsp->lp = lp; /* save the softc ptr */ | 1993 | fsp->lp = lport; /* save the softc ptr */ |
1923 | fsp->rport = rport; /* set the remote port ptr */ | 1994 | fsp->rport = rport; /* set the remote port ptr */ |
1924 | 1995 | ||
1925 | /* | 1996 | /* |
1926 | * flush outstanding commands | 1997 | * flush outstanding commands |
1927 | */ | 1998 | */ |
1928 | rc = fc_lun_reset(lp, fsp, scmd_id(sc_cmd), sc_cmd->device->lun); | 1999 | rc = fc_lun_reset(lport, fsp, scmd_id(sc_cmd), sc_cmd->device->lun); |
1929 | fsp->state = FC_SRB_FREE; | 2000 | fsp->state = FC_SRB_FREE; |
1930 | fc_fcp_pkt_release(fsp); | 2001 | fc_fcp_pkt_release(fsp); |
1931 | 2002 | ||
@@ -1935,38 +2006,39 @@ out: | |||
1935 | EXPORT_SYMBOL(fc_eh_device_reset); | 2006 | EXPORT_SYMBOL(fc_eh_device_reset); |
1936 | 2007 | ||
1937 | /** | 2008 | /** |
1938 | * fc_eh_host_reset() - The reset function will reset the ports on the host. | 2009 | * fc_eh_host_reset() - Reset a Scsi_Host. |
1939 | * @sc_cmd: scsi command | 2010 | * @sc_cmd: The SCSI command that identifies the SCSI host to be reset |
1940 | */ | 2011 | */ |
1941 | int fc_eh_host_reset(struct scsi_cmnd *sc_cmd) | 2012 | int fc_eh_host_reset(struct scsi_cmnd *sc_cmd) |
1942 | { | 2013 | { |
1943 | struct Scsi_Host *shost = sc_cmd->device->host; | 2014 | struct Scsi_Host *shost = sc_cmd->device->host; |
1944 | struct fc_lport *lp = shost_priv(shost); | 2015 | struct fc_lport *lport = shost_priv(shost); |
1945 | unsigned long wait_tmo; | 2016 | unsigned long wait_tmo; |
1946 | 2017 | ||
1947 | FC_SCSI_DBG(lp, "Resetting host\n"); | 2018 | FC_SCSI_DBG(lport, "Resetting host\n"); |
1948 | 2019 | ||
1949 | lp->tt.lport_reset(lp); | 2020 | lport->tt.lport_reset(lport); |
1950 | wait_tmo = jiffies + FC_HOST_RESET_TIMEOUT; | 2021 | wait_tmo = jiffies + FC_HOST_RESET_TIMEOUT; |
1951 | while (!fc_fcp_lport_queue_ready(lp) && time_before(jiffies, wait_tmo)) | 2022 | while (!fc_fcp_lport_queue_ready(lport) && time_before(jiffies, |
2023 | wait_tmo)) | ||
1952 | msleep(1000); | 2024 | msleep(1000); |
1953 | 2025 | ||
1954 | if (fc_fcp_lport_queue_ready(lp)) { | 2026 | if (fc_fcp_lport_queue_ready(lport)) { |
1955 | shost_printk(KERN_INFO, shost, "libfc: Host reset succeeded " | 2027 | shost_printk(KERN_INFO, shost, "libfc: Host reset succeeded " |
1956 | "on port (%6x)\n", fc_host_port_id(lp->host)); | 2028 | "on port (%6x)\n", fc_host_port_id(lport->host)); |
1957 | return SUCCESS; | 2029 | return SUCCESS; |
1958 | } else { | 2030 | } else { |
1959 | shost_printk(KERN_INFO, shost, "libfc: Host reset failed, " | 2031 | shost_printk(KERN_INFO, shost, "libfc: Host reset failed, " |
1960 | "port (%6x) is not ready.\n", | 2032 | "port (%6x) is not ready.\n", |
1961 | fc_host_port_id(lp->host)); | 2033 | fc_host_port_id(lport->host)); |
1962 | return FAILED; | 2034 | return FAILED; |
1963 | } | 2035 | } |
1964 | } | 2036 | } |
1965 | EXPORT_SYMBOL(fc_eh_host_reset); | 2037 | EXPORT_SYMBOL(fc_eh_host_reset); |
1966 | 2038 | ||
1967 | /** | 2039 | /** |
1968 | * fc_slave_alloc() - configure queue depth | 2040 | * fc_slave_alloc() - Configure the queue depth of a Scsi_Host |
1969 | * @sdev: scsi device | 2041 | * @sdev: The SCSI device that identifies the SCSI host |
1970 | * | 2042 | * |
1971 | * Configures queue depth based on host's cmd_per_len. If not set | 2043 | * Configures queue depth based on host's cmd_per_len. If not set |
1972 | * then we use the libfc default. | 2044 | * then we use the libfc default. |
@@ -1988,6 +2060,12 @@ int fc_slave_alloc(struct scsi_device *sdev) | |||
1988 | } | 2060 | } |
1989 | EXPORT_SYMBOL(fc_slave_alloc); | 2061 | EXPORT_SYMBOL(fc_slave_alloc); |
1990 | 2062 | ||
2063 | /** | ||
2064 | * fc_change_queue_depth() - Change a device's queue depth | ||
2065 | * @sdev: The SCSI device whose queue depth is to change | ||
2066 | * @qdepth: The new queue depth | ||
2067 | * @reason: The resason for the change | ||
2068 | */ | ||
1991 | int fc_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason) | 2069 | int fc_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason) |
1992 | { | 2070 | { |
1993 | switch (reason) { | 2071 | switch (reason) { |
@@ -2007,6 +2085,11 @@ int fc_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason) | |||
2007 | } | 2085 | } |
2008 | EXPORT_SYMBOL(fc_change_queue_depth); | 2086 | EXPORT_SYMBOL(fc_change_queue_depth); |
2009 | 2087 | ||
2088 | /** | ||
2089 | * fc_change_queue_type() - Change a device's queue type | ||
2090 | * @sdev: The SCSI device whose queue depth is to change | ||
2091 | * @tag_type: Identifier for queue type | ||
2092 | */ | ||
2010 | int fc_change_queue_type(struct scsi_device *sdev, int tag_type) | 2093 | int fc_change_queue_type(struct scsi_device *sdev, int tag_type) |
2011 | { | 2094 | { |
2012 | if (sdev->tagged_supported) { | 2095 | if (sdev->tagged_supported) { |
@@ -2022,17 +2105,21 @@ int fc_change_queue_type(struct scsi_device *sdev, int tag_type) | |||
2022 | } | 2105 | } |
2023 | EXPORT_SYMBOL(fc_change_queue_type); | 2106 | EXPORT_SYMBOL(fc_change_queue_type); |
2024 | 2107 | ||
2025 | void fc_fcp_destroy(struct fc_lport *lp) | 2108 | /** |
2109 | * fc_fcp_destory() - Tear down the FCP layer for a given local port | ||
2110 | * @lport: The local port that no longer needs the FCP layer | ||
2111 | */ | ||
2112 | void fc_fcp_destroy(struct fc_lport *lport) | ||
2026 | { | 2113 | { |
2027 | struct fc_fcp_internal *si = fc_get_scsi_internal(lp); | 2114 | struct fc_fcp_internal *si = fc_get_scsi_internal(lport); |
2028 | 2115 | ||
2029 | if (!list_empty(&si->scsi_pkt_queue)) | 2116 | if (!list_empty(&si->scsi_pkt_queue)) |
2030 | printk(KERN_ERR "libfc: Leaked SCSI packets when destroying " | 2117 | printk(KERN_ERR "libfc: Leaked SCSI packets when destroying " |
2031 | "port (%6x)\n", fc_host_port_id(lp->host)); | 2118 | "port (%6x)\n", fc_host_port_id(lport->host)); |
2032 | 2119 | ||
2033 | mempool_destroy(si->scsi_pkt_pool); | 2120 | mempool_destroy(si->scsi_pkt_pool); |
2034 | kfree(si); | 2121 | kfree(si); |
2035 | lp->scsi_priv = NULL; | 2122 | lport->scsi_priv = NULL; |
2036 | } | 2123 | } |
2037 | EXPORT_SYMBOL(fc_fcp_destroy); | 2124 | EXPORT_SYMBOL(fc_fcp_destroy); |
2038 | 2125 | ||
@@ -2058,24 +2145,28 @@ void fc_destroy_fcp() | |||
2058 | kmem_cache_destroy(scsi_pkt_cachep); | 2145 | kmem_cache_destroy(scsi_pkt_cachep); |
2059 | } | 2146 | } |
2060 | 2147 | ||
2061 | int fc_fcp_init(struct fc_lport *lp) | 2148 | /** |
2149 | * fc_fcp_init() - Initialize the FCP layer for a local port | ||
2150 | * @lport: The local port to initialize the exchange layer for | ||
2151 | */ | ||
2152 | int fc_fcp_init(struct fc_lport *lport) | ||
2062 | { | 2153 | { |
2063 | int rc; | 2154 | int rc; |
2064 | struct fc_fcp_internal *si; | 2155 | struct fc_fcp_internal *si; |
2065 | 2156 | ||
2066 | if (!lp->tt.fcp_cmd_send) | 2157 | if (!lport->tt.fcp_cmd_send) |
2067 | lp->tt.fcp_cmd_send = fc_fcp_cmd_send; | 2158 | lport->tt.fcp_cmd_send = fc_fcp_cmd_send; |
2068 | 2159 | ||
2069 | if (!lp->tt.fcp_cleanup) | 2160 | if (!lport->tt.fcp_cleanup) |
2070 | lp->tt.fcp_cleanup = fc_fcp_cleanup; | 2161 | lport->tt.fcp_cleanup = fc_fcp_cleanup; |
2071 | 2162 | ||
2072 | if (!lp->tt.fcp_abort_io) | 2163 | if (!lport->tt.fcp_abort_io) |
2073 | lp->tt.fcp_abort_io = fc_fcp_abort_io; | 2164 | lport->tt.fcp_abort_io = fc_fcp_abort_io; |
2074 | 2165 | ||
2075 | si = kzalloc(sizeof(struct fc_fcp_internal), GFP_KERNEL); | 2166 | si = kzalloc(sizeof(struct fc_fcp_internal), GFP_KERNEL); |
2076 | if (!si) | 2167 | if (!si) |
2077 | return -ENOMEM; | 2168 | return -ENOMEM; |
2078 | lp->scsi_priv = si; | 2169 | lport->scsi_priv = si; |
2079 | INIT_LIST_HEAD(&si->scsi_pkt_queue); | 2170 | INIT_LIST_HEAD(&si->scsi_pkt_queue); |
2080 | 2171 | ||
2081 | si->scsi_pkt_pool = mempool_create_slab_pool(2, scsi_pkt_cachep); | 2172 | si->scsi_pkt_pool = mempool_create_slab_pool(2, scsi_pkt_cachep); |
diff --git a/drivers/scsi/libfc/fc_libfc.c b/drivers/scsi/libfc/fc_libfc.c index 295eafb0316f..39f4b6ab04b4 100644 --- a/drivers/scsi/libfc/fc_libfc.c +++ b/drivers/scsi/libfc/fc_libfc.c | |||
@@ -75,7 +75,7 @@ module_exit(libfc_exit); | |||
75 | 75 | ||
76 | /** | 76 | /** |
77 | * fc_copy_buffer_to_sglist() - This routine copies the data of a buffer | 77 | * fc_copy_buffer_to_sglist() - This routine copies the data of a buffer |
78 | * into a scatter-gather list (SG list). | 78 | * into a scatter-gather list (SG list). |
79 | * | 79 | * |
80 | * @buf: pointer to the data buffer. | 80 | * @buf: pointer to the data buffer. |
81 | * @len: the byte-length of the data buffer. | 81 | * @len: the byte-length of the data buffer. |
@@ -84,7 +84,7 @@ module_exit(libfc_exit); | |||
84 | * @offset: pointer to the current offset in the SG list. | 84 | * @offset: pointer to the current offset in the SG list. |
85 | * @km_type: dedicated page table slot type for kmap_atomic. | 85 | * @km_type: dedicated page table slot type for kmap_atomic. |
86 | * @crc: pointer to the 32-bit crc value. | 86 | * @crc: pointer to the 32-bit crc value. |
87 | * If crc is NULL, CRC is not calculated. | 87 | * If crc is NULL, CRC is not calculated. |
88 | */ | 88 | */ |
89 | u32 fc_copy_buffer_to_sglist(void *buf, size_t len, | 89 | u32 fc_copy_buffer_to_sglist(void *buf, size_t len, |
90 | struct scatterlist *sg, | 90 | struct scatterlist *sg, |
diff --git a/drivers/scsi/libfc/fc_libfc.h b/drivers/scsi/libfc/fc_libfc.h index e4b5e9280cb0..741fd5c72e13 100644 --- a/drivers/scsi/libfc/fc_libfc.h +++ b/drivers/scsi/libfc/fc_libfc.h | |||
@@ -22,22 +22,22 @@ | |||
22 | 22 | ||
23 | #define FC_LIBFC_LOGGING 0x01 /* General logging, not categorized */ | 23 | #define FC_LIBFC_LOGGING 0x01 /* General logging, not categorized */ |
24 | #define FC_LPORT_LOGGING 0x02 /* lport layer logging */ | 24 | #define FC_LPORT_LOGGING 0x02 /* lport layer logging */ |
25 | #define FC_DISC_LOGGING 0x04 /* discovery layer logging */ | 25 | #define FC_DISC_LOGGING 0x04 /* discovery layer logging */ |
26 | #define FC_RPORT_LOGGING 0x08 /* rport layer logging */ | 26 | #define FC_RPORT_LOGGING 0x08 /* rport layer logging */ |
27 | #define FC_FCP_LOGGING 0x10 /* I/O path logging */ | 27 | #define FC_FCP_LOGGING 0x10 /* I/O path logging */ |
28 | #define FC_EM_LOGGING 0x20 /* Exchange Manager logging */ | 28 | #define FC_EM_LOGGING 0x20 /* Exchange Manager logging */ |
29 | #define FC_EXCH_LOGGING 0x40 /* Exchange/Sequence logging */ | 29 | #define FC_EXCH_LOGGING 0x40 /* Exchange/Sequence logging */ |
30 | #define FC_SCSI_LOGGING 0x80 /* SCSI logging (mostly error handling) */ | 30 | #define FC_SCSI_LOGGING 0x80 /* SCSI logging (mostly error handling) */ |
31 | 31 | ||
32 | extern unsigned int fc_debug_logging; | 32 | extern unsigned int fc_debug_logging; |
33 | 33 | ||
34 | #define FC_CHECK_LOGGING(LEVEL, CMD) \ | 34 | #define FC_CHECK_LOGGING(LEVEL, CMD) \ |
35 | do { \ | 35 | do { \ |
36 | if (unlikely(fc_debug_logging & LEVEL)) \ | 36 | if (unlikely(fc_debug_logging & LEVEL)) \ |
37 | do { \ | 37 | do { \ |
38 | CMD; \ | 38 | CMD; \ |
39 | } while (0); \ | 39 | } while (0); \ |
40 | } while (0) | 40 | } while (0) |
41 | 41 | ||
42 | #define FC_LIBFC_DBG(fmt, args...) \ | 42 | #define FC_LIBFC_DBG(fmt, args...) \ |
43 | FC_CHECK_LOGGING(FC_LIBFC_LOGGING, \ | 43 | FC_CHECK_LOGGING(FC_LIBFC_LOGGING, \ |
@@ -49,10 +49,10 @@ do { \ | |||
49 | (lport)->host->host_no, \ | 49 | (lport)->host->host_no, \ |
50 | fc_host_port_id((lport)->host), ##args)) | 50 | fc_host_port_id((lport)->host), ##args)) |
51 | 51 | ||
52 | #define FC_DISC_DBG(disc, fmt, args...) \ | 52 | #define FC_DISC_DBG(disc, fmt, args...) \ |
53 | FC_CHECK_LOGGING(FC_DISC_LOGGING, \ | 53 | FC_CHECK_LOGGING(FC_DISC_LOGGING, \ |
54 | printk(KERN_INFO "host%u: disc: " fmt, \ | 54 | printk(KERN_INFO "host%u: disc: " fmt, \ |
55 | (disc)->lport->host->host_no, \ | 55 | (disc)->lport->host->host_no, \ |
56 | ##args)) | 56 | ##args)) |
57 | 57 | ||
58 | #define FC_RPORT_ID_DBG(lport, port_id, fmt, args...) \ | 58 | #define FC_RPORT_ID_DBG(lport, port_id, fmt, args...) \ |
@@ -77,7 +77,7 @@ do { \ | |||
77 | exch->xid, ##args)) | 77 | exch->xid, ##args)) |
78 | 78 | ||
79 | #define FC_SCSI_DBG(lport, fmt, args...) \ | 79 | #define FC_SCSI_DBG(lport, fmt, args...) \ |
80 | FC_CHECK_LOGGING(FC_SCSI_LOGGING, \ | 80 | FC_CHECK_LOGGING(FC_SCSI_LOGGING, \ |
81 | printk(KERN_INFO "host%u: scsi: " fmt, \ | 81 | printk(KERN_INFO "host%u: scsi: " fmt, \ |
82 | (lport)->host->host_no, ##args)) | 82 | (lport)->host->host_no, ##args)) |
83 | 83 | ||
diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c index 2162e6b0f43e..90930c435455 100644 --- a/drivers/scsi/libfc/fc_lport.c +++ b/drivers/scsi/libfc/fc_lport.c | |||
@@ -133,7 +133,7 @@ static const char *fc_lport_state_names[] = { | |||
133 | * @job: The passthrough job | 133 | * @job: The passthrough job |
134 | * @lport: The local port to pass through a command | 134 | * @lport: The local port to pass through a command |
135 | * @rsp_code: The expected response code | 135 | * @rsp_code: The expected response code |
136 | * @sg: job->reply_payload.sg_list | 136 | * @sg: job->reply_payload.sg_list |
137 | * @nents: job->reply_payload.sg_cnt | 137 | * @nents: job->reply_payload.sg_cnt |
138 | * @offset: The offset into the response data | 138 | * @offset: The offset into the response data |
139 | */ | 139 | */ |
@@ -146,6 +146,11 @@ struct fc_bsg_info { | |||
146 | size_t offset; | 146 | size_t offset; |
147 | }; | 147 | }; |
148 | 148 | ||
149 | /** | ||
150 | * fc_frame_drop() - Dummy frame handler | ||
151 | * @lport: The local port the frame was received on | ||
152 | * @fp: The received frame | ||
153 | */ | ||
149 | static int fc_frame_drop(struct fc_lport *lport, struct fc_frame *fp) | 154 | static int fc_frame_drop(struct fc_lport *lport, struct fc_frame *fp) |
150 | { | 155 | { |
151 | fc_frame_free(fp); | 156 | fc_frame_free(fp); |
@@ -172,7 +177,7 @@ static void fc_lport_rport_callback(struct fc_lport *lport, | |||
172 | switch (event) { | 177 | switch (event) { |
173 | case RPORT_EV_READY: | 178 | case RPORT_EV_READY: |
174 | if (lport->state == LPORT_ST_DNS) { | 179 | if (lport->state == LPORT_ST_DNS) { |
175 | lport->dns_rp = rdata; | 180 | lport->dns_rdata = rdata; |
176 | fc_lport_enter_ns(lport, LPORT_ST_RNN_ID); | 181 | fc_lport_enter_ns(lport, LPORT_ST_RNN_ID); |
177 | } else { | 182 | } else { |
178 | FC_LPORT_DBG(lport, "Received an READY event " | 183 | FC_LPORT_DBG(lport, "Received an READY event " |
@@ -187,7 +192,7 @@ static void fc_lport_rport_callback(struct fc_lport *lport, | |||
187 | case RPORT_EV_LOGO: | 192 | case RPORT_EV_LOGO: |
188 | case RPORT_EV_FAILED: | 193 | case RPORT_EV_FAILED: |
189 | case RPORT_EV_STOP: | 194 | case RPORT_EV_STOP: |
190 | lport->dns_rp = NULL; | 195 | lport->dns_rdata = NULL; |
191 | break; | 196 | break; |
192 | case RPORT_EV_NONE: | 197 | case RPORT_EV_NONE: |
193 | break; | 198 | break; |
@@ -211,8 +216,8 @@ static const char *fc_lport_state(struct fc_lport *lport) | |||
211 | 216 | ||
212 | /** | 217 | /** |
213 | * fc_lport_ptp_setup() - Create an rport for point-to-point mode | 218 | * fc_lport_ptp_setup() - Create an rport for point-to-point mode |
214 | * @lport: The lport to attach the ptp rport to | 219 | * @lport: The lport to attach the ptp rport to |
215 | * @fid: The FID of the ptp rport | 220 | * @remote_fid: The FID of the ptp rport |
216 | * @remote_wwpn: The WWPN of the ptp rport | 221 | * @remote_wwpn: The WWPN of the ptp rport |
217 | * @remote_wwnn: The WWNN of the ptp rport | 222 | * @remote_wwnn: The WWNN of the ptp rport |
218 | */ | 223 | */ |
@@ -221,18 +226,22 @@ static void fc_lport_ptp_setup(struct fc_lport *lport, | |||
221 | u64 remote_wwnn) | 226 | u64 remote_wwnn) |
222 | { | 227 | { |
223 | mutex_lock(&lport->disc.disc_mutex); | 228 | mutex_lock(&lport->disc.disc_mutex); |
224 | if (lport->ptp_rp) | 229 | if (lport->ptp_rdata) |
225 | lport->tt.rport_logoff(lport->ptp_rp); | 230 | lport->tt.rport_logoff(lport->ptp_rdata); |
226 | lport->ptp_rp = lport->tt.rport_create(lport, remote_fid); | 231 | lport->ptp_rdata = lport->tt.rport_create(lport, remote_fid); |
227 | lport->ptp_rp->ids.port_name = remote_wwpn; | 232 | lport->ptp_rdata->ids.port_name = remote_wwpn; |
228 | lport->ptp_rp->ids.node_name = remote_wwnn; | 233 | lport->ptp_rdata->ids.node_name = remote_wwnn; |
229 | mutex_unlock(&lport->disc.disc_mutex); | 234 | mutex_unlock(&lport->disc.disc_mutex); |
230 | 235 | ||
231 | lport->tt.rport_login(lport->ptp_rp); | 236 | lport->tt.rport_login(lport->ptp_rdata); |
232 | 237 | ||
233 | fc_lport_enter_ready(lport); | 238 | fc_lport_enter_ready(lport); |
234 | } | 239 | } |
235 | 240 | ||
241 | /** | ||
242 | * fc_get_host_port_type() - Return the port type of the given Scsi_Host | ||
243 | * @shost: The SCSI host whose port type is to be determined | ||
244 | */ | ||
236 | void fc_get_host_port_type(struct Scsi_Host *shost) | 245 | void fc_get_host_port_type(struct Scsi_Host *shost) |
237 | { | 246 | { |
238 | /* TODO - currently just NPORT */ | 247 | /* TODO - currently just NPORT */ |
@@ -240,25 +249,33 @@ void fc_get_host_port_type(struct Scsi_Host *shost) | |||
240 | } | 249 | } |
241 | EXPORT_SYMBOL(fc_get_host_port_type); | 250 | EXPORT_SYMBOL(fc_get_host_port_type); |
242 | 251 | ||
252 | /** | ||
253 | * fc_get_host_port_state() - Return the port state of the given Scsi_Host | ||
254 | * @shost: The SCSI host whose port state is to be determined | ||
255 | */ | ||
243 | void fc_get_host_port_state(struct Scsi_Host *shost) | 256 | void fc_get_host_port_state(struct Scsi_Host *shost) |
244 | { | 257 | { |
245 | struct fc_lport *lp = shost_priv(shost); | 258 | struct fc_lport *lport = shost_priv(shost); |
246 | 259 | ||
247 | mutex_lock(&lp->lp_mutex); | 260 | mutex_lock(&lport->lp_mutex); |
248 | if (!lp->link_up) | 261 | if (!lport->link_up) |
249 | fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN; | 262 | fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN; |
250 | else | 263 | else |
251 | switch (lp->state) { | 264 | switch (lport->state) { |
252 | case LPORT_ST_READY: | 265 | case LPORT_ST_READY: |
253 | fc_host_port_state(shost) = FC_PORTSTATE_ONLINE; | 266 | fc_host_port_state(shost) = FC_PORTSTATE_ONLINE; |
254 | break; | 267 | break; |
255 | default: | 268 | default: |
256 | fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE; | 269 | fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE; |
257 | } | 270 | } |
258 | mutex_unlock(&lp->lp_mutex); | 271 | mutex_unlock(&lport->lp_mutex); |
259 | } | 272 | } |
260 | EXPORT_SYMBOL(fc_get_host_port_state); | 273 | EXPORT_SYMBOL(fc_get_host_port_state); |
261 | 274 | ||
275 | /** | ||
276 | * fc_get_host_speed() - Return the speed of the given Scsi_Host | ||
277 | * @shost: The SCSI host whose port speed is to be determined | ||
278 | */ | ||
262 | void fc_get_host_speed(struct Scsi_Host *shost) | 279 | void fc_get_host_speed(struct Scsi_Host *shost) |
263 | { | 280 | { |
264 | struct fc_lport *lport = shost_priv(shost); | 281 | struct fc_lport *lport = shost_priv(shost); |
@@ -267,24 +284,28 @@ void fc_get_host_speed(struct Scsi_Host *shost) | |||
267 | } | 284 | } |
268 | EXPORT_SYMBOL(fc_get_host_speed); | 285 | EXPORT_SYMBOL(fc_get_host_speed); |
269 | 286 | ||
287 | /** | ||
288 | * fc_get_host_stats() - Return the Scsi_Host's statistics | ||
289 | * @shost: The SCSI host whose statistics are to be returned | ||
290 | */ | ||
270 | struct fc_host_statistics *fc_get_host_stats(struct Scsi_Host *shost) | 291 | struct fc_host_statistics *fc_get_host_stats(struct Scsi_Host *shost) |
271 | { | 292 | { |
272 | struct fc_host_statistics *fcoe_stats; | 293 | struct fc_host_statistics *fcoe_stats; |
273 | struct fc_lport *lp = shost_priv(shost); | 294 | struct fc_lport *lport = shost_priv(shost); |
274 | struct timespec v0, v1; | 295 | struct timespec v0, v1; |
275 | unsigned int cpu; | 296 | unsigned int cpu; |
276 | 297 | ||
277 | fcoe_stats = &lp->host_stats; | 298 | fcoe_stats = &lport->host_stats; |
278 | memset(fcoe_stats, 0, sizeof(struct fc_host_statistics)); | 299 | memset(fcoe_stats, 0, sizeof(struct fc_host_statistics)); |
279 | 300 | ||
280 | jiffies_to_timespec(jiffies, &v0); | 301 | jiffies_to_timespec(jiffies, &v0); |
281 | jiffies_to_timespec(lp->boot_time, &v1); | 302 | jiffies_to_timespec(lport->boot_time, &v1); |
282 | fcoe_stats->seconds_since_last_reset = (v0.tv_sec - v1.tv_sec); | 303 | fcoe_stats->seconds_since_last_reset = (v0.tv_sec - v1.tv_sec); |
283 | 304 | ||
284 | for_each_possible_cpu(cpu) { | 305 | for_each_possible_cpu(cpu) { |
285 | struct fcoe_dev_stats *stats; | 306 | struct fcoe_dev_stats *stats; |
286 | 307 | ||
287 | stats = per_cpu_ptr(lp->dev_stats, cpu); | 308 | stats = per_cpu_ptr(lport->dev_stats, cpu); |
288 | 309 | ||
289 | fcoe_stats->tx_frames += stats->TxFrames; | 310 | fcoe_stats->tx_frames += stats->TxFrames; |
290 | fcoe_stats->tx_words += stats->TxWords; | 311 | fcoe_stats->tx_words += stats->TxWords; |
@@ -309,12 +330,15 @@ struct fc_host_statistics *fc_get_host_stats(struct Scsi_Host *shost) | |||
309 | } | 330 | } |
310 | EXPORT_SYMBOL(fc_get_host_stats); | 331 | EXPORT_SYMBOL(fc_get_host_stats); |
311 | 332 | ||
312 | /* | 333 | /** |
313 | * Fill in FLOGI command for request. | 334 | * fc_lport_flogi_fill() - Fill in FLOGI command for request |
335 | * @lport: The local port the FLOGI is for | ||
336 | * @flogi: The FLOGI command | ||
337 | * @op: The opcode | ||
314 | */ | 338 | */ |
315 | static void | 339 | static void fc_lport_flogi_fill(struct fc_lport *lport, |
316 | fc_lport_flogi_fill(struct fc_lport *lport, struct fc_els_flogi *flogi, | 340 | struct fc_els_flogi *flogi, |
317 | unsigned int op) | 341 | unsigned int op) |
318 | { | 342 | { |
319 | struct fc_els_csp *sp; | 343 | struct fc_els_csp *sp; |
320 | struct fc_els_cssp *cp; | 344 | struct fc_els_cssp *cp; |
@@ -342,8 +366,10 @@ fc_lport_flogi_fill(struct fc_lport *lport, struct fc_els_flogi *flogi, | |||
342 | } | 366 | } |
343 | } | 367 | } |
344 | 368 | ||
345 | /* | 369 | /** |
346 | * Add a supported FC-4 type. | 370 | * fc_lport_add_fc4_type() - Add a supported FC-4 type to a local port |
371 | * @lport: The local port to add a new FC-4 type to | ||
372 | * @type: The new FC-4 type | ||
347 | */ | 373 | */ |
348 | static void fc_lport_add_fc4_type(struct fc_lport *lport, enum fc_fh_type type) | 374 | static void fc_lport_add_fc4_type(struct fc_lport *lport, enum fc_fh_type type) |
349 | { | 375 | { |
@@ -355,9 +381,9 @@ static void fc_lport_add_fc4_type(struct fc_lport *lport, enum fc_fh_type type) | |||
355 | 381 | ||
356 | /** | 382 | /** |
357 | * fc_lport_recv_rlir_req() - Handle received Registered Link Incident Report. | 383 | * fc_lport_recv_rlir_req() - Handle received Registered Link Incident Report. |
384 | * @sp: The sequence in the RLIR exchange | ||
385 | * @fp: The RLIR request frame | ||
358 | * @lport: Fibre Channel local port recieving the RLIR | 386 | * @lport: Fibre Channel local port recieving the RLIR |
359 | * @sp: current sequence in the RLIR exchange | ||
360 | * @fp: RLIR request frame | ||
361 | * | 387 | * |
362 | * Locking Note: The lport lock is expected to be held before calling | 388 | * Locking Note: The lport lock is expected to be held before calling |
363 | * this function. | 389 | * this function. |
@@ -374,9 +400,9 @@ static void fc_lport_recv_rlir_req(struct fc_seq *sp, struct fc_frame *fp, | |||
374 | 400 | ||
375 | /** | 401 | /** |
376 | * fc_lport_recv_echo_req() - Handle received ECHO request | 402 | * fc_lport_recv_echo_req() - Handle received ECHO request |
377 | * @lport: Fibre Channel local port recieving the ECHO | 403 | * @sp: The sequence in the ECHO exchange |
378 | * @sp: current sequence in the ECHO exchange | 404 | * @fp: ECHO request frame |
379 | * @fp: ECHO request frame | 405 | * @lport: The local port recieving the ECHO |
380 | * | 406 | * |
381 | * Locking Note: The lport lock is expected to be held before calling | 407 | * Locking Note: The lport lock is expected to be held before calling |
382 | * this function. | 408 | * this function. |
@@ -483,9 +509,9 @@ static void fc_lport_recv_rnid_req(struct fc_seq *sp, struct fc_frame *in_fp, | |||
483 | 509 | ||
484 | /** | 510 | /** |
485 | * fc_lport_recv_logo_req() - Handle received fabric LOGO request | 511 | * fc_lport_recv_logo_req() - Handle received fabric LOGO request |
486 | * @lport: Fibre Channel local port recieving the LOGO | 512 | * @sp: The sequence in the LOGO exchange |
487 | * @sp: current sequence in the LOGO exchange | 513 | * @fp: The LOGO request frame |
488 | * @fp: LOGO request frame | 514 | * @lport: The local port recieving the LOGO |
489 | * | 515 | * |
490 | * Locking Note: The lport lock is exected to be held before calling | 516 | * Locking Note: The lport lock is exected to be held before calling |
491 | * this function. | 517 | * this function. |
@@ -500,7 +526,7 @@ static void fc_lport_recv_logo_req(struct fc_seq *sp, struct fc_frame *fp, | |||
500 | 526 | ||
501 | /** | 527 | /** |
502 | * fc_fabric_login() - Start the lport state machine | 528 | * fc_fabric_login() - Start the lport state machine |
503 | * @lport: The lport that should log into the fabric | 529 | * @lport: The local port that should log into the fabric |
504 | * | 530 | * |
505 | * Locking Note: This function should not be called | 531 | * Locking Note: This function should not be called |
506 | * with the lport lock held. | 532 | * with the lport lock held. |
@@ -538,7 +564,7 @@ void __fc_linkup(struct fc_lport *lport) | |||
538 | 564 | ||
539 | /** | 565 | /** |
540 | * fc_linkup() - Handler for transport linkup events | 566 | * fc_linkup() - Handler for transport linkup events |
541 | * @lport: The lport whose link is up | 567 | * @lport: The local port whose link is up |
542 | */ | 568 | */ |
543 | void fc_linkup(struct fc_lport *lport) | 569 | void fc_linkup(struct fc_lport *lport) |
544 | { | 570 | { |
@@ -568,7 +594,7 @@ void __fc_linkdown(struct fc_lport *lport) | |||
568 | 594 | ||
569 | /** | 595 | /** |
570 | * fc_linkdown() - Handler for transport linkdown events | 596 | * fc_linkdown() - Handler for transport linkdown events |
571 | * @lport: The lport whose link is down | 597 | * @lport: The local port whose link is down |
572 | */ | 598 | */ |
573 | void fc_linkdown(struct fc_lport *lport) | 599 | void fc_linkdown(struct fc_lport *lport) |
574 | { | 600 | { |
@@ -583,7 +609,7 @@ EXPORT_SYMBOL(fc_linkdown); | |||
583 | 609 | ||
584 | /** | 610 | /** |
585 | * fc_fabric_logoff() - Logout of the fabric | 611 | * fc_fabric_logoff() - Logout of the fabric |
586 | * @lport: fc_lport pointer to logoff the fabric | 612 | * @lport: The local port to logoff the fabric |
587 | * | 613 | * |
588 | * Return value: | 614 | * Return value: |
589 | * 0 for success, -1 for failure | 615 | * 0 for success, -1 for failure |
@@ -592,8 +618,8 @@ int fc_fabric_logoff(struct fc_lport *lport) | |||
592 | { | 618 | { |
593 | lport->tt.disc_stop_final(lport); | 619 | lport->tt.disc_stop_final(lport); |
594 | mutex_lock(&lport->lp_mutex); | 620 | mutex_lock(&lport->lp_mutex); |
595 | if (lport->dns_rp) | 621 | if (lport->dns_rdata) |
596 | lport->tt.rport_logoff(lport->dns_rp); | 622 | lport->tt.rport_logoff(lport->dns_rdata); |
597 | mutex_unlock(&lport->lp_mutex); | 623 | mutex_unlock(&lport->lp_mutex); |
598 | lport->tt.rport_flush_queue(); | 624 | lport->tt.rport_flush_queue(); |
599 | mutex_lock(&lport->lp_mutex); | 625 | mutex_lock(&lport->lp_mutex); |
@@ -605,11 +631,9 @@ int fc_fabric_logoff(struct fc_lport *lport) | |||
605 | EXPORT_SYMBOL(fc_fabric_logoff); | 631 | EXPORT_SYMBOL(fc_fabric_logoff); |
606 | 632 | ||
607 | /** | 633 | /** |
608 | * fc_lport_destroy() - unregister a fc_lport | 634 | * fc_lport_destroy() - Unregister a fc_lport |
609 | * @lport: fc_lport pointer to unregister | 635 | * @lport: The local port to unregister |
610 | * | 636 | * |
611 | * Return value: | ||
612 | * None | ||
613 | * Note: | 637 | * Note: |
614 | * exit routine for fc_lport instance | 638 | * exit routine for fc_lport instance |
615 | * clean-up all the allocated memory | 639 | * clean-up all the allocated memory |
@@ -632,13 +656,9 @@ int fc_lport_destroy(struct fc_lport *lport) | |||
632 | EXPORT_SYMBOL(fc_lport_destroy); | 656 | EXPORT_SYMBOL(fc_lport_destroy); |
633 | 657 | ||
634 | /** | 658 | /** |
635 | * fc_set_mfs() - sets up the mfs for the corresponding fc_lport | 659 | * fc_set_mfs() - Set the maximum frame size for a local port |
636 | * @lport: fc_lport pointer to unregister | 660 | * @lport: The local port to set the MFS for |
637 | * @mfs: the new mfs for fc_lport | 661 | * @mfs: The new MFS |
638 | * | ||
639 | * Set mfs for the given fc_lport to the new mfs. | ||
640 | * | ||
641 | * Return: 0 for success | ||
642 | */ | 662 | */ |
643 | int fc_set_mfs(struct fc_lport *lport, u32 mfs) | 663 | int fc_set_mfs(struct fc_lport *lport, u32 mfs) |
644 | { | 664 | { |
@@ -669,7 +689,7 @@ EXPORT_SYMBOL(fc_set_mfs); | |||
669 | 689 | ||
670 | /** | 690 | /** |
671 | * fc_lport_disc_callback() - Callback for discovery events | 691 | * fc_lport_disc_callback() - Callback for discovery events |
672 | * @lport: FC local port | 692 | * @lport: The local port receiving the event |
673 | * @event: The discovery event | 693 | * @event: The discovery event |
674 | */ | 694 | */ |
675 | void fc_lport_disc_callback(struct fc_lport *lport, enum fc_disc_event event) | 695 | void fc_lport_disc_callback(struct fc_lport *lport, enum fc_disc_event event) |
@@ -693,7 +713,7 @@ void fc_lport_disc_callback(struct fc_lport *lport, enum fc_disc_event event) | |||
693 | 713 | ||
694 | /** | 714 | /** |
695 | * fc_rport_enter_ready() - Enter the ready state and start discovery | 715 | * fc_rport_enter_ready() - Enter the ready state and start discovery |
696 | * @lport: Fibre Channel local port that is ready | 716 | * @lport: The local port that is ready |
697 | * | 717 | * |
698 | * Locking Note: The lport lock is expected to be held before calling | 718 | * Locking Note: The lport lock is expected to be held before calling |
699 | * this routine. | 719 | * this routine. |
@@ -708,15 +728,15 @@ static void fc_lport_enter_ready(struct fc_lport *lport) | |||
708 | fc_vport_set_state(lport->vport, FC_VPORT_ACTIVE); | 728 | fc_vport_set_state(lport->vport, FC_VPORT_ACTIVE); |
709 | fc_vports_linkchange(lport); | 729 | fc_vports_linkchange(lport); |
710 | 730 | ||
711 | if (!lport->ptp_rp) | 731 | if (!lport->ptp_rdata) |
712 | lport->tt.disc_start(fc_lport_disc_callback, lport); | 732 | lport->tt.disc_start(fc_lport_disc_callback, lport); |
713 | } | 733 | } |
714 | 734 | ||
715 | /** | 735 | /** |
716 | * fc_lport_recv_flogi_req() - Receive a FLOGI request | 736 | * fc_lport_recv_flogi_req() - Receive a FLOGI request |
717 | * @sp_in: The sequence the FLOGI is on | 737 | * @sp_in: The sequence the FLOGI is on |
718 | * @rx_fp: The frame the FLOGI is in | 738 | * @rx_fp: The FLOGI frame |
719 | * @lport: The lport that recieved the request | 739 | * @lport: The local port that recieved the request |
720 | * | 740 | * |
721 | * A received FLOGI request indicates a point-to-point connection. | 741 | * A received FLOGI request indicates a point-to-point connection. |
722 | * Accept it with the common service parameters indicating our N port. | 742 | * Accept it with the common service parameters indicating our N port. |
@@ -802,9 +822,9 @@ out: | |||
802 | 822 | ||
803 | /** | 823 | /** |
804 | * fc_lport_recv_req() - The generic lport request handler | 824 | * fc_lport_recv_req() - The generic lport request handler |
805 | * @lport: The lport that received the request | 825 | * @lport: The local port that received the request |
806 | * @sp: The sequence the request is on | 826 | * @sp: The sequence the request is on |
807 | * @fp: The frame the request is in | 827 | * @fp: The request frame |
808 | * | 828 | * |
809 | * This function will see if the lport handles the request or | 829 | * This function will see if the lport handles the request or |
810 | * if an rport should handle the request. | 830 | * if an rport should handle the request. |
@@ -872,8 +892,8 @@ static void fc_lport_recv_req(struct fc_lport *lport, struct fc_seq *sp, | |||
872 | } | 892 | } |
873 | 893 | ||
874 | /** | 894 | /** |
875 | * fc_lport_reset() - Reset an lport | 895 | * fc_lport_reset() - Reset a local port |
876 | * @lport: The lport which should be reset | 896 | * @lport: The local port which should be reset |
877 | * | 897 | * |
878 | * Locking Note: This functions should not be called with the | 898 | * Locking Note: This functions should not be called with the |
879 | * lport lock held. | 899 | * lport lock held. |
@@ -889,18 +909,18 @@ int fc_lport_reset(struct fc_lport *lport) | |||
889 | EXPORT_SYMBOL(fc_lport_reset); | 909 | EXPORT_SYMBOL(fc_lport_reset); |
890 | 910 | ||
891 | /** | 911 | /** |
892 | * fc_lport_reset_locked() - Reset the local port | 912 | * fc_lport_reset_locked() - Reset the local port w/ the lport lock held |
893 | * @lport: Fibre Channel local port to be reset | 913 | * @lport: The local port to be reset |
894 | * | 914 | * |
895 | * Locking Note: The lport lock is expected to be held before calling | 915 | * Locking Note: The lport lock is expected to be held before calling |
896 | * this routine. | 916 | * this routine. |
897 | */ | 917 | */ |
898 | static void fc_lport_reset_locked(struct fc_lport *lport) | 918 | static void fc_lport_reset_locked(struct fc_lport *lport) |
899 | { | 919 | { |
900 | if (lport->dns_rp) | 920 | if (lport->dns_rdata) |
901 | lport->tt.rport_logoff(lport->dns_rp); | 921 | lport->tt.rport_logoff(lport->dns_rdata); |
902 | 922 | ||
903 | lport->ptp_rp = NULL; | 923 | lport->ptp_rdata = NULL; |
904 | 924 | ||
905 | lport->tt.disc_stop(lport); | 925 | lport->tt.disc_stop(lport); |
906 | 926 | ||
@@ -911,7 +931,7 @@ static void fc_lport_reset_locked(struct fc_lport *lport) | |||
911 | 931 | ||
912 | /** | 932 | /** |
913 | * fc_lport_enter_reset() - Reset the local port | 933 | * fc_lport_enter_reset() - Reset the local port |
914 | * @lport: Fibre Channel local port to be reset | 934 | * @lport: The local port to be reset |
915 | * | 935 | * |
916 | * Locking Note: The lport lock is expected to be held before calling | 936 | * Locking Note: The lport lock is expected to be held before calling |
917 | * this routine. | 937 | * this routine. |
@@ -935,8 +955,8 @@ static void fc_lport_enter_reset(struct fc_lport *lport) | |||
935 | } | 955 | } |
936 | 956 | ||
937 | /** | 957 | /** |
938 | * fc_lport_enter_disabled() - disable the local port | 958 | * fc_lport_enter_disabled() - Disable the local port |
939 | * @lport: Fibre Channel local port to be reset | 959 | * @lport: The local port to be reset |
940 | * | 960 | * |
941 | * Locking Note: The lport lock is expected to be held before calling | 961 | * Locking Note: The lport lock is expected to be held before calling |
942 | * this routine. | 962 | * this routine. |
@@ -953,8 +973,8 @@ static void fc_lport_enter_disabled(struct fc_lport *lport) | |||
953 | 973 | ||
954 | /** | 974 | /** |
955 | * fc_lport_error() - Handler for any errors | 975 | * fc_lport_error() - Handler for any errors |
956 | * @lport: The fc_lport object | 976 | * @lport: The local port that the error was on |
957 | * @fp: The frame pointer | 977 | * @fp: The error code encoded in a frame pointer |
958 | * | 978 | * |
959 | * If the error was caused by a resource allocation failure | 979 | * If the error was caused by a resource allocation failure |
960 | * then wait for half a second and retry, otherwise retry | 980 | * then wait for half a second and retry, otherwise retry |
@@ -1002,13 +1022,13 @@ static void fc_lport_error(struct fc_lport *lport, struct fc_frame *fp) | |||
1002 | 1022 | ||
1003 | /** | 1023 | /** |
1004 | * fc_lport_ns_resp() - Handle response to a name server | 1024 | * fc_lport_ns_resp() - Handle response to a name server |
1005 | * registration exchange | 1025 | * registration exchange |
1006 | * @sp: current sequence in exchange | 1026 | * @sp: current sequence in exchange |
1007 | * @fp: response frame | 1027 | * @fp: response frame |
1008 | * @lp_arg: Fibre Channel host port instance | 1028 | * @lp_arg: Fibre Channel host port instance |
1009 | * | 1029 | * |
1010 | * Locking Note: This function will be called without the lport lock | 1030 | * Locking Note: This function will be called without the lport lock |
1011 | * held, but it will lock, call an _enter_* function or fc_lport_error | 1031 | * held, but it will lock, call an _enter_* function or fc_lport_error() |
1012 | * and then unlock the lport. | 1032 | * and then unlock the lport. |
1013 | */ | 1033 | */ |
1014 | static void fc_lport_ns_resp(struct fc_seq *sp, struct fc_frame *fp, | 1034 | static void fc_lport_ns_resp(struct fc_seq *sp, struct fc_frame *fp, |
@@ -1027,7 +1047,7 @@ static void fc_lport_ns_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
1027 | 1047 | ||
1028 | if (lport->state < LPORT_ST_RNN_ID || lport->state > LPORT_ST_RFT_ID) { | 1048 | if (lport->state < LPORT_ST_RNN_ID || lport->state > LPORT_ST_RFT_ID) { |
1029 | FC_LPORT_DBG(lport, "Received a name server response, " | 1049 | FC_LPORT_DBG(lport, "Received a name server response, " |
1030 | "but in state %s\n", fc_lport_state(lport)); | 1050 | "but in state %s\n", fc_lport_state(lport)); |
1031 | if (IS_ERR(fp)) | 1051 | if (IS_ERR(fp)) |
1032 | goto err; | 1052 | goto err; |
1033 | goto out; | 1053 | goto out; |
@@ -1072,8 +1092,8 @@ err: | |||
1072 | 1092 | ||
1073 | /** | 1093 | /** |
1074 | * fc_lport_scr_resp() - Handle response to State Change Register (SCR) request | 1094 | * fc_lport_scr_resp() - Handle response to State Change Register (SCR) request |
1075 | * @sp: current sequence in SCR exchange | 1095 | * @sp: current sequence in SCR exchange |
1076 | * @fp: response frame | 1096 | * @fp: response frame |
1077 | * @lp_arg: Fibre Channel lport port instance that sent the registration request | 1097 | * @lp_arg: Fibre Channel lport port instance that sent the registration request |
1078 | * | 1098 | * |
1079 | * Locking Note: This function will be called without the lport lock | 1099 | * Locking Note: This function will be called without the lport lock |
@@ -1119,8 +1139,8 @@ err: | |||
1119 | } | 1139 | } |
1120 | 1140 | ||
1121 | /** | 1141 | /** |
1122 | * fc_lport_enter_scr() - Send a State Change Register (SCR) request | 1142 | * fc_lport_enter_scr() - Send a SCR (State Change Register) request |
1123 | * @lport: Fibre Channel local port to register for state changes | 1143 | * @lport: The local port to register for state changes |
1124 | * | 1144 | * |
1125 | * Locking Note: The lport lock is expected to be held before calling | 1145 | * Locking Note: The lport lock is expected to be held before calling |
1126 | * this routine. | 1146 | * this routine. |
@@ -1212,8 +1232,8 @@ static struct fc_rport_operations fc_lport_rport_ops = { | |||
1212 | }; | 1232 | }; |
1213 | 1233 | ||
1214 | /** | 1234 | /** |
1215 | * fc_rport_enter_dns() - Create a rport to the name server | 1235 | * fc_rport_enter_dns() - Create a fc_rport for the name server |
1216 | * @lport: Fibre Channel local port requesting a rport for the name server | 1236 | * @lport: The local port requesting a remote port for the name server |
1217 | * | 1237 | * |
1218 | * Locking Note: The lport lock is expected to be held before calling | 1238 | * Locking Note: The lport lock is expected to be held before calling |
1219 | * this routine. | 1239 | * this routine. |
@@ -1242,8 +1262,8 @@ err: | |||
1242 | } | 1262 | } |
1243 | 1263 | ||
1244 | /** | 1264 | /** |
1245 | * fc_lport_timeout() - Handler for the retry_work timer. | 1265 | * fc_lport_timeout() - Handler for the retry_work timer |
1246 | * @work: The work struct of the fc_lport | 1266 | * @work: The work struct of the local port |
1247 | */ | 1267 | */ |
1248 | static void fc_lport_timeout(struct work_struct *work) | 1268 | static void fc_lport_timeout(struct work_struct *work) |
1249 | { | 1269 | { |
@@ -1287,16 +1307,16 @@ static void fc_lport_timeout(struct work_struct *work) | |||
1287 | 1307 | ||
1288 | /** | 1308 | /** |
1289 | * fc_lport_logo_resp() - Handle response to LOGO request | 1309 | * fc_lport_logo_resp() - Handle response to LOGO request |
1290 | * @sp: current sequence in LOGO exchange | 1310 | * @sp: The sequence that the LOGO was on |
1291 | * @fp: response frame | 1311 | * @fp: The LOGO frame |
1292 | * @lp_arg: Fibre Channel lport port instance that sent the LOGO request | 1312 | * @lp_arg: The lport port that received the LOGO request |
1293 | * | 1313 | * |
1294 | * Locking Note: This function will be called without the lport lock | 1314 | * Locking Note: This function will be called without the lport lock |
1295 | * held, but it will lock, call an _enter_* function or fc_lport_error | 1315 | * held, but it will lock, call an _enter_* function or fc_lport_error() |
1296 | * and then unlock the lport. | 1316 | * and then unlock the lport. |
1297 | */ | 1317 | */ |
1298 | void fc_lport_logo_resp(struct fc_seq *sp, struct fc_frame *fp, | 1318 | void fc_lport_logo_resp(struct fc_seq *sp, struct fc_frame *fp, |
1299 | void *lp_arg) | 1319 | void *lp_arg) |
1300 | { | 1320 | { |
1301 | struct fc_lport *lport = lp_arg; | 1321 | struct fc_lport *lport = lp_arg; |
1302 | u8 op; | 1322 | u8 op; |
@@ -1336,7 +1356,7 @@ EXPORT_SYMBOL(fc_lport_logo_resp); | |||
1336 | 1356 | ||
1337 | /** | 1357 | /** |
1338 | * fc_rport_enter_logo() - Logout of the fabric | 1358 | * fc_rport_enter_logo() - Logout of the fabric |
1339 | * @lport: Fibre Channel local port to be logged out | 1359 | * @lport: The local port to be logged out |
1340 | * | 1360 | * |
1341 | * Locking Note: The lport lock is expected to be held before calling | 1361 | * Locking Note: The lport lock is expected to be held before calling |
1342 | * this routine. | 1362 | * this routine. |
@@ -1365,16 +1385,16 @@ static void fc_lport_enter_logo(struct fc_lport *lport) | |||
1365 | 1385 | ||
1366 | /** | 1386 | /** |
1367 | * fc_lport_flogi_resp() - Handle response to FLOGI request | 1387 | * fc_lport_flogi_resp() - Handle response to FLOGI request |
1368 | * @sp: current sequence in FLOGI exchange | 1388 | * @sp: The sequence that the FLOGI was on |
1369 | * @fp: response frame | 1389 | * @fp: The FLOGI response frame |
1370 | * @lp_arg: Fibre Channel lport port instance that sent the FLOGI request | 1390 | * @lp_arg: The lport port that received the FLOGI response |
1371 | * | 1391 | * |
1372 | * Locking Note: This function will be called without the lport lock | 1392 | * Locking Note: This function will be called without the lport lock |
1373 | * held, but it will lock, call an _enter_* function or fc_lport_error | 1393 | * held, but it will lock, call an _enter_* function or fc_lport_error() |
1374 | * and then unlock the lport. | 1394 | * and then unlock the lport. |
1375 | */ | 1395 | */ |
1376 | void fc_lport_flogi_resp(struct fc_seq *sp, struct fc_frame *fp, | 1396 | void fc_lport_flogi_resp(struct fc_seq *sp, struct fc_frame *fp, |
1377 | void *lp_arg) | 1397 | void *lp_arg) |
1378 | { | 1398 | { |
1379 | struct fc_lport *lport = lp_arg; | 1399 | struct fc_lport *lport = lp_arg; |
1380 | struct fc_frame_header *fh; | 1400 | struct fc_frame_header *fh; |
@@ -1484,7 +1504,10 @@ void fc_lport_enter_flogi(struct fc_lport *lport) | |||
1484 | fc_lport_error(lport, NULL); | 1504 | fc_lport_error(lport, NULL); |
1485 | } | 1505 | } |
1486 | 1506 | ||
1487 | /* Configure a fc_lport */ | 1507 | /** |
1508 | * fc_lport_config() - Configure a fc_lport | ||
1509 | * @lport: The local port to be configured | ||
1510 | */ | ||
1488 | int fc_lport_config(struct fc_lport *lport) | 1511 | int fc_lport_config(struct fc_lport *lport) |
1489 | { | 1512 | { |
1490 | INIT_DELAYED_WORK(&lport->retry_work, fc_lport_timeout); | 1513 | INIT_DELAYED_WORK(&lport->retry_work, fc_lport_timeout); |
@@ -1499,6 +1522,10 @@ int fc_lport_config(struct fc_lport *lport) | |||
1499 | } | 1522 | } |
1500 | EXPORT_SYMBOL(fc_lport_config); | 1523 | EXPORT_SYMBOL(fc_lport_config); |
1501 | 1524 | ||
1525 | /** | ||
1526 | * fc_lport_init() - Initialize the lport layer for a local port | ||
1527 | * @lport: The local port to initialize the exchange layer for | ||
1528 | */ | ||
1502 | int fc_lport_init(struct fc_lport *lport) | 1529 | int fc_lport_init(struct fc_lport *lport) |
1503 | { | 1530 | { |
1504 | if (!lport->tt.lport_recv) | 1531 | if (!lport->tt.lport_recv) |
@@ -1533,10 +1560,10 @@ int fc_lport_init(struct fc_lport *lport) | |||
1533 | EXPORT_SYMBOL(fc_lport_init); | 1560 | EXPORT_SYMBOL(fc_lport_init); |
1534 | 1561 | ||
1535 | /** | 1562 | /** |
1536 | * fc_lport_bsg_resp() - The common response handler for fc pass-thru requests | 1563 | * fc_lport_bsg_resp() - The common response handler for FC Passthrough requests |
1537 | * @sp: current sequence in the fc pass-thru request exchange | 1564 | * @sp: The sequence for the FC Passthrough response |
1538 | * @fp: received response frame | 1565 | * @fp: The response frame |
1539 | * @info_arg: pointer to struct fc_bsg_info | 1566 | * @info_arg: The BSG info that the response is for |
1540 | */ | 1567 | */ |
1541 | static void fc_lport_bsg_resp(struct fc_seq *sp, struct fc_frame *fp, | 1568 | static void fc_lport_bsg_resp(struct fc_seq *sp, struct fc_frame *fp, |
1542 | void *info_arg) | 1569 | void *info_arg) |
@@ -1596,10 +1623,10 @@ static void fc_lport_bsg_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
1596 | } | 1623 | } |
1597 | 1624 | ||
1598 | /** | 1625 | /** |
1599 | * fc_lport_els_request() - Send ELS pass-thru request | 1626 | * fc_lport_els_request() - Send ELS passthrough request |
1600 | * @job: The bsg fc pass-thru job structure | 1627 | * @job: The BSG Passthrough job |
1601 | * @lport: The local port sending the request | 1628 | * @lport: The local port sending the request |
1602 | * @did: The destination port id. | 1629 | * @did: The destination port id |
1603 | * | 1630 | * |
1604 | * Locking Note: The lport lock is expected to be held before calling | 1631 | * Locking Note: The lport lock is expected to be held before calling |
1605 | * this routine. | 1632 | * this routine. |
@@ -1656,11 +1683,11 @@ static int fc_lport_els_request(struct fc_bsg_job *job, | |||
1656 | } | 1683 | } |
1657 | 1684 | ||
1658 | /** | 1685 | /** |
1659 | * fc_lport_ct_request() - Send CT pass-thru request | 1686 | * fc_lport_ct_request() - Send CT Passthrough request |
1660 | * @job: The bsg fc pass-thru job structure | 1687 | * @job: The BSG Passthrough job |
1661 | * @lport: The local port sending the request | 1688 | * @lport: The local port sending the request |
1662 | * @did: The destination FC-ID | 1689 | * @did: The destination FC-ID |
1663 | * @tov: The time to wait for a response | 1690 | * @tov: The timeout period to wait for the response |
1664 | * | 1691 | * |
1665 | * Locking Note: The lport lock is expected to be held before calling | 1692 | * Locking Note: The lport lock is expected to be held before calling |
1666 | * this routine. | 1693 | * this routine. |
@@ -1717,8 +1744,8 @@ static int fc_lport_ct_request(struct fc_bsg_job *job, | |||
1717 | 1744 | ||
1718 | /** | 1745 | /** |
1719 | * fc_lport_bsg_request() - The common entry point for sending | 1746 | * fc_lport_bsg_request() - The common entry point for sending |
1720 | * fc pass-thru requests | 1747 | * FC Passthrough requests |
1721 | * @job: The fc pass-thru job structure | 1748 | * @job: The BSG passthrough job |
1722 | */ | 1749 | */ |
1723 | int fc_lport_bsg_request(struct fc_bsg_job *job) | 1750 | int fc_lport_bsg_request(struct fc_bsg_job *job) |
1724 | { | 1751 | { |
@@ -1759,7 +1786,7 @@ int fc_lport_bsg_request(struct fc_bsg_job *job) | |||
1759 | case FC_BSG_HST_CT: | 1786 | case FC_BSG_HST_CT: |
1760 | did = ntoh24(job->request->rqst_data.h_ct.port_id); | 1787 | did = ntoh24(job->request->rqst_data.h_ct.port_id); |
1761 | if (did == FC_FID_DIR_SERV) | 1788 | if (did == FC_FID_DIR_SERV) |
1762 | rdata = lport->dns_rp; | 1789 | rdata = lport->dns_rdata; |
1763 | else | 1790 | else |
1764 | rdata = lport->tt.rport_lookup(lport, did); | 1791 | rdata = lport->tt.rport_lookup(lport, did); |
1765 | 1792 | ||
diff --git a/drivers/scsi/libfc/fc_rport.c b/drivers/scsi/libfc/fc_rport.c index 622285c81fef..6578968a753d 100644 --- a/drivers/scsi/libfc/fc_rport.c +++ b/drivers/scsi/libfc/fc_rport.c | |||
@@ -92,9 +92,9 @@ static const char *fc_rport_state_names[] = { | |||
92 | }; | 92 | }; |
93 | 93 | ||
94 | /** | 94 | /** |
95 | * fc_rport_lookup() - lookup a remote port by port_id | 95 | * fc_rport_lookup() - Lookup a remote port by port_id |
96 | * @lport: Fibre Channel host port instance | 96 | * @lport: The local port to lookup the remote port on |
97 | * @port_id: remote port port_id to match | 97 | * @port_id: The remote port ID to look up |
98 | */ | 98 | */ |
99 | static struct fc_rport_priv *fc_rport_lookup(const struct fc_lport *lport, | 99 | static struct fc_rport_priv *fc_rport_lookup(const struct fc_lport *lport, |
100 | u32 port_id) | 100 | u32 port_id) |
@@ -109,8 +109,10 @@ static struct fc_rport_priv *fc_rport_lookup(const struct fc_lport *lport, | |||
109 | 109 | ||
110 | /** | 110 | /** |
111 | * fc_rport_create() - Create a new remote port | 111 | * fc_rport_create() - Create a new remote port |
112 | * @lport: The local port that the new remote port is for | 112 | * @lport: The local port this remote port will be associated with |
113 | * @port_id: The port ID for the new remote port | 113 | * @ids: The identifiers for the new remote port |
114 | * | ||
115 | * The remote port will start in the INIT state. | ||
114 | * | 116 | * |
115 | * Locking note: must be called with the disc_mutex held. | 117 | * Locking note: must be called with the disc_mutex held. |
116 | */ | 118 | */ |
@@ -149,8 +151,8 @@ static struct fc_rport_priv *fc_rport_create(struct fc_lport *lport, | |||
149 | } | 151 | } |
150 | 152 | ||
151 | /** | 153 | /** |
152 | * fc_rport_destroy() - free a remote port after last reference is released. | 154 | * fc_rport_destroy() - Free a remote port after last reference is released |
153 | * @kref: pointer to kref inside struct fc_rport_priv | 155 | * @kref: The remote port's kref |
154 | */ | 156 | */ |
155 | static void fc_rport_destroy(struct kref *kref) | 157 | static void fc_rport_destroy(struct kref *kref) |
156 | { | 158 | { |
@@ -161,8 +163,8 @@ static void fc_rport_destroy(struct kref *kref) | |||
161 | } | 163 | } |
162 | 164 | ||
163 | /** | 165 | /** |
164 | * fc_rport_state() - return a string for the state the rport is in | 166 | * fc_rport_state() - Return a string identifying the remote port's state |
165 | * @rdata: remote port private data | 167 | * @rdata: The remote port |
166 | */ | 168 | */ |
167 | static const char *fc_rport_state(struct fc_rport_priv *rdata) | 169 | static const char *fc_rport_state(struct fc_rport_priv *rdata) |
168 | { | 170 | { |
@@ -175,9 +177,9 @@ static const char *fc_rport_state(struct fc_rport_priv *rdata) | |||
175 | } | 177 | } |
176 | 178 | ||
177 | /** | 179 | /** |
178 | * fc_set_rport_loss_tmo() - Set the remote port loss timeout in seconds. | 180 | * fc_set_rport_loss_tmo() - Set the remote port loss timeout |
179 | * @rport: Pointer to Fibre Channel remote port structure | 181 | * @rport: The remote port that gets a new timeout value |
180 | * @timeout: timeout in seconds | 182 | * @timeout: The new timeout value (in seconds) |
181 | */ | 183 | */ |
182 | void fc_set_rport_loss_tmo(struct fc_rport *rport, u32 timeout) | 184 | void fc_set_rport_loss_tmo(struct fc_rport *rport, u32 timeout) |
183 | { | 185 | { |
@@ -189,9 +191,11 @@ void fc_set_rport_loss_tmo(struct fc_rport *rport, u32 timeout) | |||
189 | EXPORT_SYMBOL(fc_set_rport_loss_tmo); | 191 | EXPORT_SYMBOL(fc_set_rport_loss_tmo); |
190 | 192 | ||
191 | /** | 193 | /** |
192 | * fc_plogi_get_maxframe() - Get max payload from the common service parameters | 194 | * fc_plogi_get_maxframe() - Get the maximum payload from the common service |
193 | * @flp: FLOGI payload structure | 195 | * parameters in a FLOGI frame |
194 | * @maxval: upper limit, may be less than what is in the service parameters | 196 | * @flp: The FLOGI payload |
197 | * @maxval: The maximum frame size upper limit; this may be less than what | ||
198 | * is in the service parameters | ||
195 | */ | 199 | */ |
196 | static unsigned int fc_plogi_get_maxframe(struct fc_els_flogi *flp, | 200 | static unsigned int fc_plogi_get_maxframe(struct fc_els_flogi *flp, |
197 | unsigned int maxval) | 201 | unsigned int maxval) |
@@ -212,9 +216,9 @@ static unsigned int fc_plogi_get_maxframe(struct fc_els_flogi *flp, | |||
212 | } | 216 | } |
213 | 217 | ||
214 | /** | 218 | /** |
215 | * fc_rport_state_enter() - Change the rport's state | 219 | * fc_rport_state_enter() - Change the state of a remote port |
216 | * @rdata: The rport whose state should change | 220 | * @rdata: The remote port whose state should change |
217 | * @new: The new state of the rport | 221 | * @new: The new state |
218 | * | 222 | * |
219 | * Locking Note: Called with the rport lock held | 223 | * Locking Note: Called with the rport lock held |
220 | */ | 224 | */ |
@@ -226,12 +230,16 @@ static void fc_rport_state_enter(struct fc_rport_priv *rdata, | |||
226 | rdata->rp_state = new; | 230 | rdata->rp_state = new; |
227 | } | 231 | } |
228 | 232 | ||
233 | /** | ||
234 | * fc_rport_work() - Handler for remote port events in the rport_event_queue | ||
235 | * @work: Handle to the remote port being dequeued | ||
236 | */ | ||
229 | static void fc_rport_work(struct work_struct *work) | 237 | static void fc_rport_work(struct work_struct *work) |
230 | { | 238 | { |
231 | u32 port_id; | 239 | u32 port_id; |
232 | struct fc_rport_priv *rdata = | 240 | struct fc_rport_priv *rdata = |
233 | container_of(work, struct fc_rport_priv, event_work); | 241 | container_of(work, struct fc_rport_priv, event_work); |
234 | struct fc_rport_libfc_priv *rp; | 242 | struct fc_rport_libfc_priv *rpriv; |
235 | enum fc_rport_event event; | 243 | enum fc_rport_event event; |
236 | struct fc_lport *lport = rdata->local_port; | 244 | struct fc_lport *lport = rdata->local_port; |
237 | struct fc_rport_operations *rport_ops; | 245 | struct fc_rport_operations *rport_ops; |
@@ -268,12 +276,12 @@ static void fc_rport_work(struct work_struct *work) | |||
268 | rport->maxframe_size = rdata->maxframe_size; | 276 | rport->maxframe_size = rdata->maxframe_size; |
269 | rport->supported_classes = rdata->supported_classes; | 277 | rport->supported_classes = rdata->supported_classes; |
270 | 278 | ||
271 | rp = rport->dd_data; | 279 | rpriv = rport->dd_data; |
272 | rp->local_port = lport; | 280 | rpriv->local_port = lport; |
273 | rp->rp_state = rdata->rp_state; | 281 | rpriv->rp_state = rdata->rp_state; |
274 | rp->flags = rdata->flags; | 282 | rpriv->flags = rdata->flags; |
275 | rp->e_d_tov = rdata->e_d_tov; | 283 | rpriv->e_d_tov = rdata->e_d_tov; |
276 | rp->r_a_tov = rdata->r_a_tov; | 284 | rpriv->r_a_tov = rdata->r_a_tov; |
277 | mutex_unlock(&rdata->rp_mutex); | 285 | mutex_unlock(&rdata->rp_mutex); |
278 | 286 | ||
279 | if (rport_ops && rport_ops->event_callback) { | 287 | if (rport_ops && rport_ops->event_callback) { |
@@ -319,8 +327,8 @@ static void fc_rport_work(struct work_struct *work) | |||
319 | lport->tt.exch_mgr_reset(lport, port_id, 0); | 327 | lport->tt.exch_mgr_reset(lport, port_id, 0); |
320 | 328 | ||
321 | if (rport) { | 329 | if (rport) { |
322 | rp = rport->dd_data; | 330 | rpriv = rport->dd_data; |
323 | rp->rp_state = RPORT_ST_DELETE; | 331 | rpriv->rp_state = RPORT_ST_DELETE; |
324 | mutex_lock(&rdata->rp_mutex); | 332 | mutex_lock(&rdata->rp_mutex); |
325 | rdata->rport = NULL; | 333 | rdata->rport = NULL; |
326 | mutex_unlock(&rdata->rp_mutex); | 334 | mutex_unlock(&rdata->rp_mutex); |
@@ -343,7 +351,7 @@ static void fc_rport_work(struct work_struct *work) | |||
343 | 351 | ||
344 | /** | 352 | /** |
345 | * fc_rport_login() - Start the remote port login state machine | 353 | * fc_rport_login() - Start the remote port login state machine |
346 | * @rdata: private remote port | 354 | * @rdata: The remote port to be logged in to |
347 | * | 355 | * |
348 | * Locking Note: Called without the rport lock held. This | 356 | * Locking Note: Called without the rport lock held. This |
349 | * function will hold the rport lock, call an _enter_* | 357 | * function will hold the rport lock, call an _enter_* |
@@ -379,9 +387,9 @@ int fc_rport_login(struct fc_rport_priv *rdata) | |||
379 | } | 387 | } |
380 | 388 | ||
381 | /** | 389 | /** |
382 | * fc_rport_enter_delete() - schedule a remote port to be deleted. | 390 | * fc_rport_enter_delete() - Schedule a remote port to be deleted |
383 | * @rdata: private remote port | 391 | * @rdata: The remote port to be deleted |
384 | * @event: event to report as the reason for deletion | 392 | * @event: The event to report as the reason for deletion |
385 | * | 393 | * |
386 | * Locking Note: Called with the rport lock held. | 394 | * Locking Note: Called with the rport lock held. |
387 | * | 395 | * |
@@ -408,8 +416,8 @@ static void fc_rport_enter_delete(struct fc_rport_priv *rdata, | |||
408 | } | 416 | } |
409 | 417 | ||
410 | /** | 418 | /** |
411 | * fc_rport_logoff() - Logoff and remove an rport | 419 | * fc_rport_logoff() - Logoff and remove a remote port |
412 | * @rdata: private remote port | 420 | * @rdata: The remote port to be logged off of |
413 | * | 421 | * |
414 | * Locking Note: Called without the rport lock held. This | 422 | * Locking Note: Called without the rport lock held. This |
415 | * function will hold the rport lock, call an _enter_* | 423 | * function will hold the rport lock, call an _enter_* |
@@ -442,8 +450,8 @@ out: | |||
442 | } | 450 | } |
443 | 451 | ||
444 | /** | 452 | /** |
445 | * fc_rport_enter_ready() - The rport is ready | 453 | * fc_rport_enter_ready() - Transition to the RPORT_ST_READY state |
446 | * @rdata: private remote port | 454 | * @rdata: The remote port that is ready |
447 | * | 455 | * |
448 | * Locking Note: The rport lock is expected to be held before calling | 456 | * Locking Note: The rport lock is expected to be held before calling |
449 | * this routine. | 457 | * this routine. |
@@ -460,8 +468,8 @@ static void fc_rport_enter_ready(struct fc_rport_priv *rdata) | |||
460 | } | 468 | } |
461 | 469 | ||
462 | /** | 470 | /** |
463 | * fc_rport_timeout() - Handler for the retry_work timer. | 471 | * fc_rport_timeout() - Handler for the retry_work timer |
464 | * @work: The work struct of the fc_rport_priv | 472 | * @work: Handle to the remote port that has timed out |
465 | * | 473 | * |
466 | * Locking Note: Called without the rport lock held. This | 474 | * Locking Note: Called without the rport lock held. This |
467 | * function will hold the rport lock, call an _enter_* | 475 | * function will hold the rport lock, call an _enter_* |
@@ -502,8 +510,8 @@ static void fc_rport_timeout(struct work_struct *work) | |||
502 | 510 | ||
503 | /** | 511 | /** |
504 | * fc_rport_error() - Error handler, called once retries have been exhausted | 512 | * fc_rport_error() - Error handler, called once retries have been exhausted |
505 | * @rdata: private remote port | 513 | * @rdata: The remote port the error is happened on |
506 | * @fp: The frame pointer | 514 | * @fp: The error code encapsulated in a frame pointer |
507 | * | 515 | * |
508 | * Locking Note: The rport lock is expected to be held before | 516 | * Locking Note: The rport lock is expected to be held before |
509 | * calling this routine | 517 | * calling this routine |
@@ -535,9 +543,9 @@ static void fc_rport_error(struct fc_rport_priv *rdata, struct fc_frame *fp) | |||
535 | } | 543 | } |
536 | 544 | ||
537 | /** | 545 | /** |
538 | * fc_rport_error_retry() - Error handler when retries are desired | 546 | * fc_rport_error_retry() - Handler for remote port state retries |
539 | * @rdata: private remote port data | 547 | * @rdata: The remote port whose state is to be retried |
540 | * @fp: The frame pointer | 548 | * @fp: The error code encapsulated in a frame pointer |
541 | * | 549 | * |
542 | * If the error was an exchange timeout retry immediately, | 550 | * If the error was an exchange timeout retry immediately, |
543 | * otherwise wait for E_D_TOV. | 551 | * otherwise wait for E_D_TOV. |
@@ -569,10 +577,10 @@ static void fc_rport_error_retry(struct fc_rport_priv *rdata, | |||
569 | } | 577 | } |
570 | 578 | ||
571 | /** | 579 | /** |
572 | * fc_rport_plogi_recv_resp() - Handle incoming ELS PLOGI response | 580 | * fc_rport_plogi_recv_resp() - Handler for ELS PLOGI responses |
573 | * @sp: current sequence in the PLOGI exchange | 581 | * @sp: The sequence the PLOGI is on |
574 | * @fp: response frame | 582 | * @fp: The PLOGI response frame |
575 | * @rdata_arg: private remote port data | 583 | * @rdata_arg: The remote port that sent the PLOGI response |
576 | * | 584 | * |
577 | * Locking Note: This function will be called without the rport lock | 585 | * Locking Note: This function will be called without the rport lock |
578 | * held, but it will lock, call an _enter_* function or fc_rport_error | 586 | * held, but it will lock, call an _enter_* function or fc_rport_error |
@@ -635,8 +643,8 @@ err: | |||
635 | } | 643 | } |
636 | 644 | ||
637 | /** | 645 | /** |
638 | * fc_rport_enter_plogi() - Send Port Login (PLOGI) request to peer | 646 | * fc_rport_enter_plogi() - Send Port Login (PLOGI) request |
639 | * @rdata: private remote port data | 647 | * @rdata: The remote port to send a PLOGI to |
640 | * | 648 | * |
641 | * Locking Note: The rport lock is expected to be held before calling | 649 | * Locking Note: The rport lock is expected to be held before calling |
642 | * this routine. | 650 | * this routine. |
@@ -668,9 +676,9 @@ static void fc_rport_enter_plogi(struct fc_rport_priv *rdata) | |||
668 | 676 | ||
669 | /** | 677 | /** |
670 | * fc_rport_prli_resp() - Process Login (PRLI) response handler | 678 | * fc_rport_prli_resp() - Process Login (PRLI) response handler |
671 | * @sp: current sequence in the PRLI exchange | 679 | * @sp: The sequence the PRLI response was on |
672 | * @fp: response frame | 680 | * @fp: The PRLI response frame |
673 | * @rdata_arg: private remote port data | 681 | * @rdata_arg: The remote port that sent the PRLI response |
674 | * | 682 | * |
675 | * Locking Note: This function will be called without the rport lock | 683 | * Locking Note: This function will be called without the rport lock |
676 | * held, but it will lock, call an _enter_* function or fc_rport_error | 684 | * held, but it will lock, call an _enter_* function or fc_rport_error |
@@ -739,10 +747,10 @@ err: | |||
739 | } | 747 | } |
740 | 748 | ||
741 | /** | 749 | /** |
742 | * fc_rport_logo_resp() - Logout (LOGO) response handler | 750 | * fc_rport_logo_resp() - Handler for logout (LOGO) responses |
743 | * @sp: current sequence in the LOGO exchange | 751 | * @sp: The sequence the LOGO was on |
744 | * @fp: response frame | 752 | * @fp: The LOGO response frame |
745 | * @rdata_arg: private remote port data | 753 | * @rdata_arg: The remote port that sent the LOGO response |
746 | * | 754 | * |
747 | * Locking Note: This function will be called without the rport lock | 755 | * Locking Note: This function will be called without the rport lock |
748 | * held, but it will lock, call an _enter_* function or fc_rport_error | 756 | * held, but it will lock, call an _enter_* function or fc_rport_error |
@@ -785,8 +793,8 @@ err: | |||
785 | } | 793 | } |
786 | 794 | ||
787 | /** | 795 | /** |
788 | * fc_rport_enter_prli() - Send Process Login (PRLI) request to peer | 796 | * fc_rport_enter_prli() - Send Process Login (PRLI) request |
789 | * @rdata: private remote port data | 797 | * @rdata: The remote port to send the PRLI request to |
790 | * | 798 | * |
791 | * Locking Note: The rport lock is expected to be held before calling | 799 | * Locking Note: The rport lock is expected to be held before calling |
792 | * this routine. | 800 | * this routine. |
@@ -828,10 +836,10 @@ static void fc_rport_enter_prli(struct fc_rport_priv *rdata) | |||
828 | } | 836 | } |
829 | 837 | ||
830 | /** | 838 | /** |
831 | * fc_rport_els_rtv_resp() - Request Timeout Value response handler | 839 | * fc_rport_els_rtv_resp() - Handler for Request Timeout Value (RTV) responses |
832 | * @sp: current sequence in the RTV exchange | 840 | * @sp: The sequence the RTV was on |
833 | * @fp: response frame | 841 | * @fp: The RTV response frame |
834 | * @rdata_arg: private remote port data | 842 | * @rdata_arg: The remote port that sent the RTV response |
835 | * | 843 | * |
836 | * Many targets don't seem to support this. | 844 | * Many targets don't seem to support this. |
837 | * | 845 | * |
@@ -894,8 +902,8 @@ err: | |||
894 | } | 902 | } |
895 | 903 | ||
896 | /** | 904 | /** |
897 | * fc_rport_enter_rtv() - Send Request Timeout Value (RTV) request to peer | 905 | * fc_rport_enter_rtv() - Send Request Timeout Value (RTV) request |
898 | * @rdata: private remote port data | 906 | * @rdata: The remote port to send the RTV request to |
899 | * | 907 | * |
900 | * Locking Note: The rport lock is expected to be held before calling | 908 | * Locking Note: The rport lock is expected to be held before calling |
901 | * this routine. | 909 | * this routine. |
@@ -917,15 +925,15 @@ static void fc_rport_enter_rtv(struct fc_rport_priv *rdata) | |||
917 | } | 925 | } |
918 | 926 | ||
919 | if (!lport->tt.elsct_send(lport, rdata->ids.port_id, fp, ELS_RTV, | 927 | if (!lport->tt.elsct_send(lport, rdata->ids.port_id, fp, ELS_RTV, |
920 | fc_rport_rtv_resp, rdata, lport->e_d_tov)) | 928 | fc_rport_rtv_resp, rdata, lport->e_d_tov)) |
921 | fc_rport_error_retry(rdata, NULL); | 929 | fc_rport_error_retry(rdata, NULL); |
922 | else | 930 | else |
923 | kref_get(&rdata->kref); | 931 | kref_get(&rdata->kref); |
924 | } | 932 | } |
925 | 933 | ||
926 | /** | 934 | /** |
927 | * fc_rport_enter_logo() - Send Logout (LOGO) request to peer | 935 | * fc_rport_enter_logo() - Send a logout (LOGO) request |
928 | * @rdata: private remote port data | 936 | * @rdata: The remote port to send the LOGO request to |
929 | * | 937 | * |
930 | * Locking Note: The rport lock is expected to be held before calling | 938 | * Locking Note: The rport lock is expected to be held before calling |
931 | * this routine. | 939 | * this routine. |
@@ -954,17 +962,17 @@ static void fc_rport_enter_logo(struct fc_rport_priv *rdata) | |||
954 | } | 962 | } |
955 | 963 | ||
956 | /** | 964 | /** |
957 | * fc_rport_els_adisc_resp() - Address Discovery response handler | 965 | * fc_rport_els_adisc_resp() - Handler for Address Discovery (ADISC) responses |
958 | * @sp: current sequence in the ADISC exchange | 966 | * @sp: The sequence the ADISC response was on |
959 | * @fp: response frame | 967 | * @fp: The ADISC response frame |
960 | * @rdata_arg: remote port private. | 968 | * @rdata_arg: The remote port that sent the ADISC response |
961 | * | 969 | * |
962 | * Locking Note: This function will be called without the rport lock | 970 | * Locking Note: This function will be called without the rport lock |
963 | * held, but it will lock, call an _enter_* function or fc_rport_error | 971 | * held, but it will lock, call an _enter_* function or fc_rport_error |
964 | * and then unlock the rport. | 972 | * and then unlock the rport. |
965 | */ | 973 | */ |
966 | static void fc_rport_adisc_resp(struct fc_seq *sp, struct fc_frame *fp, | 974 | static void fc_rport_adisc_resp(struct fc_seq *sp, struct fc_frame *fp, |
967 | void *rdata_arg) | 975 | void *rdata_arg) |
968 | { | 976 | { |
969 | struct fc_rport_priv *rdata = rdata_arg; | 977 | struct fc_rport_priv *rdata = rdata_arg; |
970 | struct fc_els_adisc *adisc; | 978 | struct fc_els_adisc *adisc; |
@@ -1012,8 +1020,8 @@ err: | |||
1012 | } | 1020 | } |
1013 | 1021 | ||
1014 | /** | 1022 | /** |
1015 | * fc_rport_enter_adisc() - Send Address Discover (ADISC) request to peer | 1023 | * fc_rport_enter_adisc() - Send Address Discover (ADISC) request |
1016 | * @rdata: remote port private data | 1024 | * @rdata: The remote port to send the ADISC request to |
1017 | * | 1025 | * |
1018 | * Locking Note: The rport lock is expected to be held before calling | 1026 | * Locking Note: The rport lock is expected to be held before calling |
1019 | * this routine. | 1027 | * this routine. |
@@ -1041,10 +1049,10 @@ static void fc_rport_enter_adisc(struct fc_rport_priv *rdata) | |||
1041 | } | 1049 | } |
1042 | 1050 | ||
1043 | /** | 1051 | /** |
1044 | * fc_rport_recv_adisc_req() - Handle incoming Address Discovery (ADISC) Request | 1052 | * fc_rport_recv_adisc_req() - Handler for Address Discovery (ADISC) requests |
1045 | * @rdata: remote port private | 1053 | * @rdata: The remote port that sent the ADISC request |
1046 | * @sp: current sequence in the ADISC exchange | 1054 | * @sp: The sequence the ADISC request was on |
1047 | * @in_fp: ADISC request frame | 1055 | * @in_fp: The ADISC request frame |
1048 | * | 1056 | * |
1049 | * Locking Note: Called with the lport and rport locks held. | 1057 | * Locking Note: Called with the lport and rport locks held. |
1050 | */ | 1058 | */ |
@@ -1085,10 +1093,10 @@ drop: | |||
1085 | } | 1093 | } |
1086 | 1094 | ||
1087 | /** | 1095 | /** |
1088 | * fc_rport_recv_els_req() - handle a validated ELS request. | 1096 | * fc_rport_recv_els_req() - Handler for validated ELS requests |
1089 | * @lport: Fibre Channel local port | 1097 | * @lport: The local port that received the ELS request |
1090 | * @sp: current sequence in the PLOGI exchange | 1098 | * @sp: The sequence that the ELS request was on |
1091 | * @fp: response frame | 1099 | * @fp: The ELS request frame |
1092 | * | 1100 | * |
1093 | * Handle incoming ELS requests that require port login. | 1101 | * Handle incoming ELS requests that require port login. |
1094 | * The ELS opcode has already been validated by the caller. | 1102 | * The ELS opcode has already been validated by the caller. |
@@ -1160,10 +1168,10 @@ reject: | |||
1160 | } | 1168 | } |
1161 | 1169 | ||
1162 | /** | 1170 | /** |
1163 | * fc_rport_recv_req() - Handle a received ELS request from a rport | 1171 | * fc_rport_recv_req() - Handler for requests |
1164 | * @sp: current sequence in the PLOGI exchange | 1172 | * @sp: The sequence the request was on |
1165 | * @fp: response frame | 1173 | * @fp: The request frame |
1166 | * @lport: Fibre Channel local port | 1174 | * @lport: The local port that received the request |
1167 | * | 1175 | * |
1168 | * Locking Note: Called with the lport lock held. | 1176 | * Locking Note: Called with the lport lock held. |
1169 | */ | 1177 | */ |
@@ -1203,10 +1211,10 @@ void fc_rport_recv_req(struct fc_seq *sp, struct fc_frame *fp, | |||
1203 | } | 1211 | } |
1204 | 1212 | ||
1205 | /** | 1213 | /** |
1206 | * fc_rport_recv_plogi_req() - Handle incoming Port Login (PLOGI) request | 1214 | * fc_rport_recv_plogi_req() - Handler for Port Login (PLOGI) requests |
1207 | * @lport: local port | 1215 | * @lport: The local port that received the PLOGI request |
1208 | * @sp: current sequence in the PLOGI exchange | 1216 | * @sp: The sequence that the PLOGI request was on |
1209 | * @fp: PLOGI request frame | 1217 | * @rx_fp: The PLOGI request frame |
1210 | * | 1218 | * |
1211 | * Locking Note: The rport lock is held before calling this function. | 1219 | * Locking Note: The rport lock is held before calling this function. |
1212 | */ | 1220 | */ |
@@ -1328,10 +1336,10 @@ reject: | |||
1328 | } | 1336 | } |
1329 | 1337 | ||
1330 | /** | 1338 | /** |
1331 | * fc_rport_recv_prli_req() - Handle incoming Process Login (PRLI) request | 1339 | * fc_rport_recv_prli_req() - Handler for process login (PRLI) requests |
1332 | * @rdata: private remote port data | 1340 | * @rdata: The remote port that sent the PRLI request |
1333 | * @sp: current sequence in the PRLI exchange | 1341 | * @sp: The sequence that the PRLI was on |
1334 | * @fp: PRLI request frame | 1342 | * @rx_fp: The PRLI request frame |
1335 | * | 1343 | * |
1336 | * Locking Note: The rport lock is exected to be held before calling | 1344 | * Locking Note: The rport lock is exected to be held before calling |
1337 | * this function. | 1345 | * this function. |
@@ -1485,10 +1493,10 @@ static void fc_rport_recv_prli_req(struct fc_rport_priv *rdata, | |||
1485 | } | 1493 | } |
1486 | 1494 | ||
1487 | /** | 1495 | /** |
1488 | * fc_rport_recv_prlo_req() - Handle incoming Process Logout (PRLO) request | 1496 | * fc_rport_recv_prlo_req() - Handler for process logout (PRLO) requests |
1489 | * @rdata: private remote port data | 1497 | * @rdata: The remote port that sent the PRLO request |
1490 | * @sp: current sequence in the PRLO exchange | 1498 | * @sp: The sequence that the PRLO was on |
1491 | * @fp: PRLO request frame | 1499 | * @fp: The PRLO request frame |
1492 | * | 1500 | * |
1493 | * Locking Note: The rport lock is exected to be held before calling | 1501 | * Locking Note: The rport lock is exected to be held before calling |
1494 | * this function. | 1502 | * this function. |
@@ -1515,10 +1523,10 @@ static void fc_rport_recv_prlo_req(struct fc_rport_priv *rdata, | |||
1515 | } | 1523 | } |
1516 | 1524 | ||
1517 | /** | 1525 | /** |
1518 | * fc_rport_recv_logo_req() - Handle incoming Logout (LOGO) request | 1526 | * fc_rport_recv_logo_req() - Handler for logout (LOGO) requests |
1519 | * @lport: local port. | 1527 | * @lport: The local port that received the LOGO request |
1520 | * @sp: current sequence in the LOGO exchange | 1528 | * @sp: The sequence that the LOGO request was on |
1521 | * @fp: LOGO request frame | 1529 | * @fp: The LOGO request frame |
1522 | * | 1530 | * |
1523 | * Locking Note: The rport lock is exected to be held before calling | 1531 | * Locking Note: The rport lock is exected to be held before calling |
1524 | * this function. | 1532 | * this function. |
@@ -1559,11 +1567,18 @@ static void fc_rport_recv_logo_req(struct fc_lport *lport, | |||
1559 | fc_frame_free(fp); | 1567 | fc_frame_free(fp); |
1560 | } | 1568 | } |
1561 | 1569 | ||
1570 | /** | ||
1571 | * fc_rport_flush_queue() - Flush the rport_event_queue | ||
1572 | */ | ||
1562 | static void fc_rport_flush_queue(void) | 1573 | static void fc_rport_flush_queue(void) |
1563 | { | 1574 | { |
1564 | flush_workqueue(rport_event_queue); | 1575 | flush_workqueue(rport_event_queue); |
1565 | } | 1576 | } |
1566 | 1577 | ||
1578 | /** | ||
1579 | * fc_rport_init() - Initialize the remote port layer for a local port | ||
1580 | * @lport: The local port to initialize the remote port layer for | ||
1581 | */ | ||
1567 | int fc_rport_init(struct fc_lport *lport) | 1582 | int fc_rport_init(struct fc_lport *lport) |
1568 | { | 1583 | { |
1569 | if (!lport->tt.rport_lookup) | 1584 | if (!lport->tt.rport_lookup) |
@@ -1591,7 +1606,10 @@ int fc_rport_init(struct fc_lport *lport) | |||
1591 | } | 1606 | } |
1592 | EXPORT_SYMBOL(fc_rport_init); | 1607 | EXPORT_SYMBOL(fc_rport_init); |
1593 | 1608 | ||
1594 | int fc_setup_rport(void) | 1609 | /** |
1610 | * fc_setup_rport() - Initialize the rport_event_queue | ||
1611 | */ | ||
1612 | int fc_setup_rport() | ||
1595 | { | 1613 | { |
1596 | rport_event_queue = create_singlethread_workqueue("fc_rport_eq"); | 1614 | rport_event_queue = create_singlethread_workqueue("fc_rport_eq"); |
1597 | if (!rport_event_queue) | 1615 | if (!rport_event_queue) |
@@ -1599,15 +1617,22 @@ int fc_setup_rport(void) | |||
1599 | return 0; | 1617 | return 0; |
1600 | } | 1618 | } |
1601 | 1619 | ||
1602 | void fc_destroy_rport(void) | 1620 | /** |
1621 | * fc_destroy_rport() - Destroy the rport_event_queue | ||
1622 | */ | ||
1623 | void fc_destroy_rport() | ||
1603 | { | 1624 | { |
1604 | destroy_workqueue(rport_event_queue); | 1625 | destroy_workqueue(rport_event_queue); |
1605 | } | 1626 | } |
1606 | 1627 | ||
1628 | /** | ||
1629 | * fc_rport_terminate_io() - Stop all outstanding I/O on a remote port | ||
1630 | * @rport: The remote port whose I/O should be terminated | ||
1631 | */ | ||
1607 | void fc_rport_terminate_io(struct fc_rport *rport) | 1632 | void fc_rport_terminate_io(struct fc_rport *rport) |
1608 | { | 1633 | { |
1609 | struct fc_rport_libfc_priv *rp = rport->dd_data; | 1634 | struct fc_rport_libfc_priv *rpriv = rport->dd_data; |
1610 | struct fc_lport *lport = rp->local_port; | 1635 | struct fc_lport *lport = rpriv->local_port; |
1611 | 1636 | ||
1612 | lport->tt.exch_mgr_reset(lport, 0, rport->port_id); | 1637 | lport->tt.exch_mgr_reset(lport, 0, rport->port_id); |
1613 | lport->tt.exch_mgr_reset(lport, rport->port_id, 0); | 1638 | lport->tt.exch_mgr_reset(lport, rport->port_id, 0); |
diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h index 54df9fe00c14..310d8a22b726 100644 --- a/include/scsi/libfc.h +++ b/include/scsi/libfc.h | |||
@@ -55,8 +55,17 @@ | |||
55 | p[2] = ((v) & 0xFF); \ | 55 | p[2] = ((v) & 0xFF); \ |
56 | } while (0) | 56 | } while (0) |
57 | 57 | ||
58 | /* | 58 | /** |
59 | * FC HBA status | 59 | * enum fc_lport_state - Local port states |
60 | * @LPORT_ST_DISABLED: Disabled | ||
61 | * @LPORT_ST_FLOGI: Fabric login (FLOGI) sent | ||
62 | * @LPORT_ST_DNS: Waiting for name server remote port to become ready | ||
63 | * @LPORT_ST_RPN_ID: Register port name by ID (RPN_ID) sent | ||
64 | * @LPORT_ST_RFT_ID: Register Fibre Channel types by ID (RFT_ID) sent | ||
65 | * @LPORT_ST_SCR: State Change Register (SCR) sent | ||
66 | * @LPORT_ST_READY: Ready for use | ||
67 | * @LPORT_ST_LOGO: Local port logout (LOGO) sent | ||
68 | * @LPORT_ST_RESET: Local port reset | ||
60 | */ | 69 | */ |
61 | enum fc_lport_state { | 70 | enum fc_lport_state { |
62 | LPORT_ST_DISABLED = 0, | 71 | LPORT_ST_DISABLED = 0, |
@@ -78,16 +87,28 @@ enum fc_disc_event { | |||
78 | DISC_EV_FAILED | 87 | DISC_EV_FAILED |
79 | }; | 88 | }; |
80 | 89 | ||
90 | /** | ||
91 | * enum fc_rport_state - Remote port states | ||
92 | * @RPORT_ST_INIT: Initialized | ||
93 | * @RPORT_ST_PLOGI: Waiting for PLOGI completion | ||
94 | * @RPORT_ST_PRLI: Waiting for PRLI completion | ||
95 | * @RPORT_ST_RTV: Waiting for RTV completion | ||
96 | * @RPORT_ST_READY: Ready for use | ||
97 | * @RPORT_ST_LOGO: Remote port logout (LOGO) sent | ||
98 | * @RPORT_ST_ADISC: Discover Address sent | ||
99 | * @RPORT_ST_DELETE: Remote port being deleted | ||
100 | * @RPORT_ST_RESTART: Remote port being deleted and will restart | ||
101 | */ | ||
81 | enum fc_rport_state { | 102 | enum fc_rport_state { |
82 | RPORT_ST_INIT, /* initialized */ | 103 | RPORT_ST_INIT, |
83 | RPORT_ST_PLOGI, /* waiting for PLOGI completion */ | 104 | RPORT_ST_PLOGI, |
84 | RPORT_ST_PRLI, /* waiting for PRLI completion */ | 105 | RPORT_ST_PRLI, |
85 | RPORT_ST_RTV, /* waiting for RTV completion */ | 106 | RPORT_ST_RTV, |
86 | RPORT_ST_READY, /* ready for use */ | 107 | RPORT_ST_READY, |
87 | RPORT_ST_LOGO, /* port logout sent */ | 108 | RPORT_ST_LOGO, |
88 | RPORT_ST_ADISC, /* Discover Address sent */ | 109 | RPORT_ST_ADISC, |
89 | RPORT_ST_DELETE, /* port being deleted */ | 110 | RPORT_ST_DELETE, |
90 | RPORT_ST_RESTART, /* remote port being deleted and will restart */ | 111 | RPORT_ST_RESTART, |
91 | }; | 112 | }; |
92 | 113 | ||
93 | /** | 114 | /** |
@@ -98,12 +119,20 @@ enum fc_rport_state { | |||
98 | * @port_id: Port ID of the discovered port | 119 | * @port_id: Port ID of the discovered port |
99 | */ | 120 | */ |
100 | struct fc_disc_port { | 121 | struct fc_disc_port { |
101 | struct fc_lport *lp; | 122 | struct fc_lport *lp; |
102 | struct list_head peers; | 123 | struct list_head peers; |
103 | struct work_struct rport_work; | 124 | struct work_struct rport_work; |
104 | u32 port_id; | 125 | u32 port_id; |
105 | }; | 126 | }; |
106 | 127 | ||
128 | /** | ||
129 | * enum fc_rport_event - Remote port events | ||
130 | * @RPORT_EV_NONE: No event | ||
131 | * @RPORT_EV_READY: Remote port is ready for use | ||
132 | * @RPORT_EV_FAILED: State machine failed, remote port is not ready | ||
133 | * @RPORT_EV_STOP: Remote port has been stopped | ||
134 | * @RPORT_EV_LOGO: Remote port logout (LOGO) sent | ||
135 | */ | ||
107 | enum fc_rport_event { | 136 | enum fc_rport_event { |
108 | RPORT_EV_NONE = 0, | 137 | RPORT_EV_NONE = 0, |
109 | RPORT_EV_READY, | 138 | RPORT_EV_READY, |
@@ -114,6 +143,10 @@ enum fc_rport_event { | |||
114 | 143 | ||
115 | struct fc_rport_priv; | 144 | struct fc_rport_priv; |
116 | 145 | ||
146 | /** | ||
147 | * struct fc_rport_operations - Operations for a remote port | ||
148 | * @event_callback: Function to be called for remote port events | ||
149 | */ | ||
117 | struct fc_rport_operations { | 150 | struct fc_rport_operations { |
118 | void (*event_callback)(struct fc_lport *, struct fc_rport_priv *, | 151 | void (*event_callback)(struct fc_lport *, struct fc_rport_priv *, |
119 | enum fc_rport_event); | 152 | enum fc_rport_event); |
@@ -121,11 +154,11 @@ struct fc_rport_operations { | |||
121 | 154 | ||
122 | /** | 155 | /** |
123 | * struct fc_rport_libfc_priv - libfc internal information about a remote port | 156 | * struct fc_rport_libfc_priv - libfc internal information about a remote port |
124 | * @local_port: Fibre Channel host port instance | 157 | * @local_port: The associated local port |
125 | * @rp_state: indicates READY for I/O or DELETE when blocked. | 158 | * @rp_state: Indicates READY for I/O or DELETE when blocked |
126 | * @flags: REC and RETRY supported flags | 159 | * @flags: REC and RETRY supported flags |
127 | * @e_d_tov: error detect timeout value (in msec) | 160 | * @e_d_tov: Error detect timeout value (in msec) |
128 | * @r_a_tov: resource allocation timeout value (in msec) | 161 | * @r_a_tov: Resource allocation timeout value (in msec) |
129 | */ | 162 | */ |
130 | struct fc_rport_libfc_priv { | 163 | struct fc_rport_libfc_priv { |
131 | struct fc_lport *local_port; | 164 | struct fc_lport *local_port; |
@@ -138,47 +171,64 @@ struct fc_rport_libfc_priv { | |||
138 | }; | 171 | }; |
139 | 172 | ||
140 | /** | 173 | /** |
141 | * struct fc_rport_priv - libfc rport and discovery info about a remote port | 174 | * struct fc_rport_priv - libfc remote port and discovery info |
142 | * @local_port: Fibre Channel host port instance | 175 | * @local_port: The associated local port |
143 | * @rport: transport remote port | 176 | * @rport: The FC transport remote port |
144 | * @kref: reference counter | 177 | * @kref: Reference counter |
145 | * @rp_state: state tracks progress of PLOGI, PRLI, and RTV exchanges | 178 | * @rp_state: Enumeration that tracks progress of PLOGI, PRLI, |
146 | * @ids: remote port identifiers and roles | 179 | * and RTV exchanges |
147 | * @flags: REC and RETRY supported flags | 180 | * @ids: The remote port identifiers and roles |
148 | * @max_seq: maximum number of concurrent sequences | 181 | * @flags: REC and RETRY supported flags |
149 | * @disc_id: discovery identifier | 182 | * @max_seq: Maximum number of concurrent sequences |
150 | * @maxframe_size: maximum frame size | 183 | * @disc_id: The discovery identifier |
151 | * @retries: retry count in current state | 184 | * @maxframe_size: The maximum frame size |
152 | * @e_d_tov: error detect timeout value (in msec) | 185 | * @retries: The retry count for the current state |
153 | * @r_a_tov: resource allocation timeout value (in msec) | 186 | * @e_d_tov: Error detect timeout value (in msec) |
154 | * @rp_mutex: mutex protects rport | 187 | * @r_a_tov: Resource allocation timeout value (in msec) |
155 | * @retry_work: | 188 | * @rp_mutex: The mutex that protects the remote port |
156 | * @event_callback: Callback for rport READY, FAILED or LOGO | 189 | * @retry_work: Handle for retries |
190 | * @event_callback: Callback when READY, FAILED or LOGO states complete | ||
157 | */ | 191 | */ |
158 | struct fc_rport_priv { | 192 | struct fc_rport_priv { |
159 | struct fc_lport *local_port; | 193 | struct fc_lport *local_port; |
160 | struct fc_rport *rport; | 194 | struct fc_rport *rport; |
161 | struct kref kref; | 195 | struct kref kref; |
162 | enum fc_rport_state rp_state; | 196 | enum fc_rport_state rp_state; |
163 | struct fc_rport_identifiers ids; | 197 | struct fc_rport_identifiers ids; |
164 | u16 flags; | 198 | u16 flags; |
165 | u16 max_seq; | 199 | u16 max_seq; |
166 | u16 disc_id; | 200 | u16 disc_id; |
167 | u16 maxframe_size; | 201 | u16 maxframe_size; |
168 | unsigned int retries; | 202 | unsigned int retries; |
169 | unsigned int e_d_tov; | 203 | unsigned int e_d_tov; |
170 | unsigned int r_a_tov; | 204 | unsigned int r_a_tov; |
171 | struct mutex rp_mutex; | 205 | struct mutex rp_mutex; |
172 | struct delayed_work retry_work; | 206 | struct delayed_work retry_work; |
173 | enum fc_rport_event event; | 207 | enum fc_rport_event event; |
174 | struct fc_rport_operations *ops; | 208 | struct fc_rport_operations *ops; |
175 | struct list_head peers; | 209 | struct list_head peers; |
176 | struct work_struct event_work; | 210 | struct work_struct event_work; |
177 | u32 supported_classes; | 211 | u32 supported_classes; |
178 | }; | 212 | }; |
179 | 213 | ||
180 | /* | 214 | /** |
181 | * fcoe stats structure | 215 | * struct fcoe_dev_stats - fcoe stats structure |
216 | * @SecondsSinceLastReset: Seconds since the last reset | ||
217 | * @TxFrames: Number of transmitted frames | ||
218 | * @TxWords: Number of transmitted words | ||
219 | * @RxFrames: Number of received frames | ||
220 | * @RxWords: Number of received words | ||
221 | * @ErrorFrames: Number of received error frames | ||
222 | * @DumpedFrames: Number of dumped frames | ||
223 | * @LinkFailureCount: Number of link failures | ||
224 | * @LossOfSignalCount: Number for signal losses | ||
225 | * @InvalidTxWordCount: Number of invalid transmitted words | ||
226 | * @InvalidCRCCount: Number of invalid CRCs | ||
227 | * @InputRequests: Number of input requests | ||
228 | * @OutputRequests: Number of output requests | ||
229 | * @ControlRequests: Number of control requests | ||
230 | * @InputMegabytes: Number of received megabytes | ||
231 | * @OutputMegabytes: Number of transmitted megabytes | ||
182 | */ | 232 | */ |
183 | struct fcoe_dev_stats { | 233 | struct fcoe_dev_stats { |
184 | u64 SecondsSinceLastReset; | 234 | u64 SecondsSinceLastReset; |
@@ -199,10 +249,13 @@ struct fcoe_dev_stats { | |||
199 | u64 OutputMegabytes; | 249 | u64 OutputMegabytes; |
200 | }; | 250 | }; |
201 | 251 | ||
202 | /* | 252 | /** |
203 | * els data is used for passing ELS respone specific | 253 | * struct fc_seq_els_data - ELS data used for passing ELS specific responses |
204 | * data to send ELS response mainly using infomation | 254 | * @fp: The ELS frame |
205 | * in exchange and sequence in EM layer. | 255 | * @reason: The reason for rejection |
256 | * @explan: The explaination of the rejection | ||
257 | * | ||
258 | * Mainly used by the exchange manager layer. | ||
206 | */ | 259 | */ |
207 | struct fc_seq_els_data { | 260 | struct fc_seq_els_data { |
208 | struct fc_frame *fp; | 261 | struct fc_frame *fp; |
@@ -210,77 +263,87 @@ struct fc_seq_els_data { | |||
210 | enum fc_els_rjt_explan explan; | 263 | enum fc_els_rjt_explan explan; |
211 | }; | 264 | }; |
212 | 265 | ||
213 | /* | 266 | /** |
214 | * FCP request structure, one for each scsi cmd request | 267 | * struct fc_fcp_pkt - FCP request structure (one for each scsi_cmnd request) |
268 | * @lp: The associated local port | ||
269 | * @state: The state of the I/O | ||
270 | * @tgt_flags: Target's flags | ||
271 | * @ref_cnt: Reference count | ||
272 | * @scsi_pkt_lock: Lock to protect the SCSI packet (must be taken before the | ||
273 | * host_lock if both are to be held at the same time) | ||
274 | * @cmd: The SCSI command (set and clear with the host_lock held) | ||
275 | * @list: Tracks queued commands (accessed with the host_lock held) | ||
276 | * @timer: The command timer | ||
277 | * @tm_done: Completion indicator | ||
278 | * @wait_for_comp: Indicator to wait for completion of the I/O (in jiffies) | ||
279 | * @start_time: Timestamp indicating the start of the I/O (in jiffies) | ||
280 | * @end_time: Timestamp indicating the end of the I/O (in jiffies) | ||
281 | * @last_pkt_time: Timestamp of the last frame received (in jiffies) | ||
282 | * @data_len: The length of the data | ||
283 | * @cdb_cmd: The CDB command | ||
284 | * @xfer_len: The transfer length | ||
285 | * @xfer_ddp: Indicates if this transfer used DDP (XID of the exchange | ||
286 | * will be set here if DDP was setup) | ||
287 | * @xfer_contig_end: The offset into the buffer if the buffer is contiguous | ||
288 | * (Tx and Rx) | ||
289 | * @max_payload: The maximum payload size (in bytes) | ||
290 | * @io_status: SCSI result (upper 24 bits) | ||
291 | * @cdb_status: CDB status | ||
292 | * @status_code: FCP I/O status | ||
293 | * @scsi_comp_flags: Completion flags (bit 3 Underrun bit 2: overrun) | ||
294 | * @req_flags: Request flags (bit 0: read bit:1 write) | ||
295 | * @scsi_resid: SCSI residule length | ||
296 | * @rport: The remote port that the SCSI command is targeted at | ||
297 | * @seq_ptr: The sequence that will carry the SCSI command | ||
298 | * @recov_retry: Number of recovery retries | ||
299 | * @recov_seq: The sequence for REC or SRR | ||
215 | */ | 300 | */ |
216 | struct fc_fcp_pkt { | 301 | struct fc_fcp_pkt { |
217 | /* | 302 | /* Housekeeping information */ |
218 | * housekeeping stuff | 303 | struct fc_lport *lp; |
219 | */ | 304 | u16 state; |
220 | struct fc_lport *lp; /* handle to hba struct */ | 305 | u16 tgt_flags; |
221 | u16 state; /* scsi_pkt state state */ | 306 | atomic_t ref_cnt; |
222 | u16 tgt_flags; /* target flags */ | 307 | spinlock_t scsi_pkt_lock; |
223 | atomic_t ref_cnt; /* fcp pkt ref count */ | 308 | |
224 | spinlock_t scsi_pkt_lock; /* Must be taken before the host lock | 309 | /* SCSI I/O related information */ |
225 | * if both are held at the same time */ | 310 | struct scsi_cmnd *cmd; |
226 | /* | 311 | struct list_head list; |
227 | * SCSI I/O related stuff | 312 | |
228 | */ | 313 | /* Timeout related information */ |
229 | struct scsi_cmnd *cmd; /* scsi command pointer. set/clear | 314 | struct timer_list timer; |
230 | * under host lock */ | ||
231 | struct list_head list; /* tracks queued commands. access under | ||
232 | * host lock */ | ||
233 | /* | ||
234 | * timeout related stuff | ||
235 | */ | ||
236 | struct timer_list timer; /* command timer */ | ||
237 | struct completion tm_done; | 315 | struct completion tm_done; |
238 | int wait_for_comp; | 316 | int wait_for_comp; |
239 | unsigned long start_time; /* start jiffie */ | 317 | unsigned long start_time; |
240 | unsigned long end_time; /* end jiffie */ | 318 | unsigned long end_time; |
241 | unsigned long last_pkt_time; /* jiffies of last frame received */ | 319 | unsigned long last_pkt_time; |
242 | 320 | ||
243 | /* | 321 | /* SCSI command and data transfer information */ |
244 | * scsi cmd and data transfer information | 322 | u32 data_len; |
245 | */ | 323 | |
246 | u32 data_len; | 324 | /* Transport related veriables */ |
247 | /* | 325 | struct fcp_cmnd cdb_cmd; |
248 | * transport related veriables | 326 | size_t xfer_len; |
249 | */ | 327 | u16 xfer_ddp; |
250 | struct fcp_cmnd cdb_cmd; | 328 | u32 xfer_contig_end; |
251 | size_t xfer_len; | 329 | u16 max_payload; |
252 | u16 xfer_ddp; /* this xfer is ddped */ | 330 | |
253 | u32 xfer_contig_end; /* offset of end of contiguous xfer */ | 331 | /* SCSI/FCP return status */ |
254 | u16 max_payload; /* max payload size in bytes */ | 332 | u32 io_status; |
255 | 333 | u8 cdb_status; | |
256 | /* | 334 | u8 status_code; |
257 | * scsi/fcp return status | 335 | u8 scsi_comp_flags; |
258 | */ | 336 | u32 req_flags; |
259 | u32 io_status; /* SCSI result upper 24 bits */ | 337 | u32 scsi_resid; |
260 | u8 cdb_status; | 338 | |
261 | u8 status_code; /* FCP I/O status */ | 339 | /* Associated structures */ |
262 | /* bit 3 Underrun bit 2: overrun */ | 340 | struct fc_rport *rport; |
263 | u8 scsi_comp_flags; | 341 | struct fc_seq *seq_ptr; |
264 | u32 req_flags; /* bit 0: read bit:1 write */ | 342 | |
265 | u32 scsi_resid; /* residule length */ | 343 | /* Error Processing information */ |
266 | 344 | u8 recov_retry; | |
267 | struct fc_rport *rport; /* remote port pointer */ | 345 | struct fc_seq *recov_seq; |
268 | struct fc_seq *seq_ptr; /* current sequence pointer */ | ||
269 | /* | ||
270 | * Error Processing | ||
271 | */ | ||
272 | u8 recov_retry; /* count of recovery retries */ | ||
273 | struct fc_seq *recov_seq; /* sequence for REC or SRR */ | ||
274 | }; | 346 | }; |
275 | /* | ||
276 | * FC_FCP HELPER FUNCTIONS | ||
277 | *****************************/ | ||
278 | static inline bool fc_fcp_is_read(const struct fc_fcp_pkt *fsp) | ||
279 | { | ||
280 | if (fsp && fsp->cmd) | ||
281 | return fsp->cmd->sc_data_direction == DMA_FROM_DEVICE; | ||
282 | return false; | ||
283 | } | ||
284 | 347 | ||
285 | /* | 348 | /* |
286 | * Structure and function definitions for managing Fibre Channel Exchanges | 349 | * Structure and function definitions for managing Fibre Channel Exchanges |
@@ -293,23 +356,51 @@ static inline bool fc_fcp_is_read(const struct fc_fcp_pkt *fsp) | |||
293 | 356 | ||
294 | struct fc_exch_mgr; | 357 | struct fc_exch_mgr; |
295 | struct fc_exch_mgr_anchor; | 358 | struct fc_exch_mgr_anchor; |
296 | extern u16 fc_cpu_mask; /* cpu mask for possible cpus */ | 359 | extern u16 fc_cpu_mask; /* cpu mask for possible cpus */ |
297 | 360 | ||
298 | /* | 361 | /** |
299 | * Sequence. | 362 | * struct fc_seq - FC sequence |
363 | * @id: The sequence ID | ||
364 | * @ssb_stat: Status flags for the sequence status block (SSB) | ||
365 | * @cnt: Number of frames sent so far | ||
366 | * @rec_data: FC-4 value for REC | ||
300 | */ | 367 | */ |
301 | struct fc_seq { | 368 | struct fc_seq { |
302 | u8 id; /* seq ID */ | 369 | u8 id; |
303 | u16 ssb_stat; /* status flags for sequence status block */ | 370 | u16 ssb_stat; |
304 | u16 cnt; /* frames sent so far on sequence */ | 371 | u16 cnt; |
305 | u32 rec_data; /* FC-4 value for REC */ | 372 | u32 rec_data; |
306 | }; | 373 | }; |
307 | 374 | ||
308 | #define FC_EX_DONE (1 << 0) /* ep is completed */ | 375 | #define FC_EX_DONE (1 << 0) /* ep is completed */ |
309 | #define FC_EX_RST_CLEANUP (1 << 1) /* reset is forcing completion */ | 376 | #define FC_EX_RST_CLEANUP (1 << 1) /* reset is forcing completion */ |
310 | 377 | ||
311 | /* | 378 | /** |
312 | * Exchange. | 379 | * struct fc_exch - Fibre Channel Exchange |
380 | * @em: Exchange manager | ||
381 | * @pool: Exchange pool | ||
382 | * @state: The exchange's state | ||
383 | * @xid: The exchange ID | ||
384 | * @ex_list: Handle used by the EM to track free exchanges | ||
385 | * @ex_lock: Lock that protects the exchange | ||
386 | * @ex_refcnt: Reference count | ||
387 | * @timeout_work: Handle for timeout handler | ||
388 | * @lp: The local port that this exchange is on | ||
389 | * @oxid: Originator's exchange ID | ||
390 | * @rxid: Responder's exchange ID | ||
391 | * @oid: Originator's FCID | ||
392 | * @sid: Source FCID | ||
393 | * @did: Destination FCID | ||
394 | * @esb_stat: ESB exchange status | ||
395 | * @r_a_tov: Resouce allocation time out value (in msecs) | ||
396 | * @seq_id: The next sequence ID to use | ||
397 | * @f_ctl: F_CTL flags for the sequence | ||
398 | * @fh_type: The frame type | ||
399 | * @class: The class of service | ||
400 | * @seq: The sequence in use on this exchange | ||
401 | * @resp: Callback for responses on this exchange | ||
402 | * @destructor: Called when destroying the exchange | ||
403 | * @arg: Passed as a void pointer to the resp() callback | ||
313 | * | 404 | * |
314 | * Locking notes: The ex_lock protects following items: | 405 | * Locking notes: The ex_lock protects following items: |
315 | * state, esb_stat, f_ctl, seq.ssb_stat | 406 | * state, esb_stat, f_ctl, seq.ssb_stat |
@@ -317,76 +408,59 @@ struct fc_seq { | |||
317 | * sequence allocation | 408 | * sequence allocation |
318 | */ | 409 | */ |
319 | struct fc_exch { | 410 | struct fc_exch { |
320 | struct fc_exch_mgr *em; /* exchange manager */ | 411 | struct fc_exch_mgr *em; |
321 | struct fc_exch_pool *pool; /* per cpu exches pool */ | 412 | struct fc_exch_pool *pool; |
322 | u32 state; /* internal driver state */ | 413 | u32 state; |
323 | u16 xid; /* our exchange ID */ | 414 | u16 xid; |
324 | struct list_head ex_list; /* free or busy list linkage */ | 415 | struct list_head ex_list; |
325 | spinlock_t ex_lock; /* lock covering exchange state */ | 416 | spinlock_t ex_lock; |
326 | atomic_t ex_refcnt; /* reference counter */ | 417 | atomic_t ex_refcnt; |
327 | struct delayed_work timeout_work; /* timer for upper level protocols */ | 418 | struct delayed_work timeout_work; |
328 | struct fc_lport *lp; /* fc device instance */ | 419 | struct fc_lport *lp; |
329 | u16 oxid; /* originator's exchange ID */ | 420 | u16 oxid; |
330 | u16 rxid; /* responder's exchange ID */ | 421 | u16 rxid; |
331 | u32 oid; /* originator's FCID */ | 422 | u32 oid; |
332 | u32 sid; /* source FCID */ | 423 | u32 sid; |
333 | u32 did; /* destination FCID */ | 424 | u32 did; |
334 | u32 esb_stat; /* exchange status for ESB */ | 425 | u32 esb_stat; |
335 | u32 r_a_tov; /* r_a_tov from rport (msec) */ | 426 | u32 r_a_tov; |
336 | u8 seq_id; /* next sequence ID to use */ | 427 | u8 seq_id; |
337 | u32 f_ctl; /* F_CTL flags for sequences */ | 428 | u32 f_ctl; |
338 | u8 fh_type; /* frame type */ | 429 | u8 fh_type; |
339 | enum fc_class class; /* class of service */ | 430 | enum fc_class class; |
340 | struct fc_seq seq; /* single sequence */ | 431 | struct fc_seq seq; |
341 | /* | 432 | |
342 | * Handler for responses to this current exchange. | 433 | void (*resp)(struct fc_seq *, struct fc_frame *, void *); |
343 | */ | 434 | void *arg; |
344 | void (*resp)(struct fc_seq *, struct fc_frame *, void *); | 435 | |
345 | void (*destructor)(struct fc_seq *, void *); | 436 | void (*destructor)(struct fc_seq *, void *); |
346 | /* | 437 | |
347 | * arg is passed as void pointer to exchange | ||
348 | * resp and destructor handlers | ||
349 | */ | ||
350 | void *arg; | ||
351 | }; | 438 | }; |
352 | #define fc_seq_exch(sp) container_of(sp, struct fc_exch, seq) | 439 | #define fc_seq_exch(sp) container_of(sp, struct fc_exch, seq) |
353 | 440 | ||
354 | struct libfc_function_template { | ||
355 | 441 | ||
442 | struct libfc_function_template { | ||
356 | /* | 443 | /* |
357 | * Interface to send a FC frame | 444 | * Interface to send a FC frame |
358 | * | 445 | * |
359 | * STATUS: REQUIRED | 446 | * STATUS: REQUIRED |
360 | */ | 447 | */ |
361 | int (*frame_send)(struct fc_lport *lp, struct fc_frame *fp); | 448 | int (*frame_send)(struct fc_lport *, struct fc_frame *); |
362 | 449 | ||
363 | /* | 450 | /* |
364 | * Interface to send ELS/CT frames | 451 | * Interface to send ELS/CT frames |
365 | * | 452 | * |
366 | * STATUS: OPTIONAL | 453 | * STATUS: OPTIONAL |
367 | */ | 454 | */ |
368 | struct fc_seq *(*elsct_send)(struct fc_lport *lport, | 455 | struct fc_seq *(*elsct_send)(struct fc_lport *, u32 did, |
369 | u32 did, | 456 | struct fc_frame *, unsigned int op, |
370 | struct fc_frame *fp, | ||
371 | unsigned int op, | ||
372 | void (*resp)(struct fc_seq *, | 457 | void (*resp)(struct fc_seq *, |
373 | struct fc_frame *fp, | 458 | struct fc_frame *, void *arg), |
374 | void *arg), | ||
375 | void *arg, u32 timer_msec); | 459 | void *arg, u32 timer_msec); |
376 | 460 | ||
377 | /* | 461 | /* |
378 | * Send the FC frame payload using a new exchange and sequence. | 462 | * Send the FC frame payload using a new exchange and sequence. |
379 | * | 463 | * |
380 | * The frame pointer with some of the header's fields must be | ||
381 | * filled before calling exch_seq_send(), those fields are, | ||
382 | * | ||
383 | * - routing control | ||
384 | * - FC port did | ||
385 | * - FC port sid | ||
386 | * - FC header type | ||
387 | * - frame control | ||
388 | * - parameter or relative offset | ||
389 | * | ||
390 | * The exchange response handler is set in this routine to resp() | 464 | * The exchange response handler is set in this routine to resp() |
391 | * function pointer. It can be called in two scenarios: if a timeout | 465 | * function pointer. It can be called in two scenarios: if a timeout |
392 | * occurs or if a response frame is received for the exchange. The | 466 | * occurs or if a response frame is received for the exchange. The |
@@ -407,14 +481,13 @@ struct libfc_function_template { | |||
407 | * | 481 | * |
408 | * STATUS: OPTIONAL | 482 | * STATUS: OPTIONAL |
409 | */ | 483 | */ |
410 | struct fc_seq *(*exch_seq_send)(struct fc_lport *lp, | 484 | struct fc_seq *(*exch_seq_send)(struct fc_lport *, struct fc_frame *, |
411 | struct fc_frame *fp, | 485 | void (*resp)(struct fc_seq *, |
412 | void (*resp)(struct fc_seq *sp, | 486 | struct fc_frame *, |
413 | struct fc_frame *fp, | 487 | void *), |
414 | void *arg), | 488 | void (*destructor)(struct fc_seq *, |
415 | void (*destructor)(struct fc_seq *sp, | 489 | void *), |
416 | void *arg), | 490 | void *, unsigned int timer_msec); |
417 | void *arg, unsigned int timer_msec); | ||
418 | 491 | ||
419 | /* | 492 | /* |
420 | * Sets up the DDP context for a given exchange id on the given | 493 | * Sets up the DDP context for a given exchange id on the given |
@@ -422,22 +495,22 @@ struct libfc_function_template { | |||
422 | * | 495 | * |
423 | * STATUS: OPTIONAL | 496 | * STATUS: OPTIONAL |
424 | */ | 497 | */ |
425 | int (*ddp_setup)(struct fc_lport *lp, u16 xid, | 498 | int (*ddp_setup)(struct fc_lport *, u16, struct scatterlist *, |
426 | struct scatterlist *sgl, unsigned int sgc); | 499 | unsigned int); |
427 | /* | 500 | /* |
428 | * Completes the DDP transfer and returns the length of data DDPed | 501 | * Completes the DDP transfer and returns the length of data DDPed |
429 | * for the given exchange id. | 502 | * for the given exchange id. |
430 | * | 503 | * |
431 | * STATUS: OPTIONAL | 504 | * STATUS: OPTIONAL |
432 | */ | 505 | */ |
433 | int (*ddp_done)(struct fc_lport *lp, u16 xid); | 506 | int (*ddp_done)(struct fc_lport *, u16); |
434 | /* | 507 | /* |
435 | * Send a frame using an existing sequence and exchange. | 508 | * Send a frame using an existing sequence and exchange. |
436 | * | 509 | * |
437 | * STATUS: OPTIONAL | 510 | * STATUS: OPTIONAL |
438 | */ | 511 | */ |
439 | int (*seq_send)(struct fc_lport *lp, struct fc_seq *sp, | 512 | int (*seq_send)(struct fc_lport *, struct fc_seq *, |
440 | struct fc_frame *fp); | 513 | struct fc_frame *); |
441 | 514 | ||
442 | /* | 515 | /* |
443 | * Send an ELS response using infomation from a previous | 516 | * Send an ELS response using infomation from a previous |
@@ -445,8 +518,8 @@ struct libfc_function_template { | |||
445 | * | 518 | * |
446 | * STATUS: OPTIONAL | 519 | * STATUS: OPTIONAL |
447 | */ | 520 | */ |
448 | void (*seq_els_rsp_send)(struct fc_seq *sp, enum fc_els_cmd els_cmd, | 521 | void (*seq_els_rsp_send)(struct fc_seq *, enum fc_els_cmd, |
449 | struct fc_seq_els_data *els_data); | 522 | struct fc_seq_els_data *); |
450 | 523 | ||
451 | /* | 524 | /* |
452 | * Abort an exchange and sequence. Generally called because of a | 525 | * Abort an exchange and sequence. Generally called because of a |
@@ -458,7 +531,7 @@ struct libfc_function_template { | |||
458 | * | 531 | * |
459 | * STATUS: OPTIONAL | 532 | * STATUS: OPTIONAL |
460 | */ | 533 | */ |
461 | int (*seq_exch_abort)(const struct fc_seq *req_sp, | 534 | int (*seq_exch_abort)(const struct fc_seq *, |
462 | unsigned int timer_msec); | 535 | unsigned int timer_msec); |
463 | 536 | ||
464 | /* | 537 | /* |
@@ -467,14 +540,14 @@ struct libfc_function_template { | |||
467 | * | 540 | * |
468 | * STATUS: OPTIONAL | 541 | * STATUS: OPTIONAL |
469 | */ | 542 | */ |
470 | void (*exch_done)(struct fc_seq *sp); | 543 | void (*exch_done)(struct fc_seq *); |
471 | 544 | ||
472 | /* | 545 | /* |
473 | * Start a new sequence on the same exchange/sequence tuple. | 546 | * Start a new sequence on the same exchange/sequence tuple. |
474 | * | 547 | * |
475 | * STATUS: OPTIONAL | 548 | * STATUS: OPTIONAL |
476 | */ | 549 | */ |
477 | struct fc_seq *(*seq_start_next)(struct fc_seq *sp); | 550 | struct fc_seq *(*seq_start_next)(struct fc_seq *); |
478 | 551 | ||
479 | /* | 552 | /* |
480 | * Reset an exchange manager, completing all sequences and exchanges. | 553 | * Reset an exchange manager, completing all sequences and exchanges. |
@@ -483,8 +556,7 @@ struct libfc_function_template { | |||
483 | * | 556 | * |
484 | * STATUS: OPTIONAL | 557 | * STATUS: OPTIONAL |
485 | */ | 558 | */ |
486 | void (*exch_mgr_reset)(struct fc_lport *, | 559 | void (*exch_mgr_reset)(struct fc_lport *, u32 s_id, u32 d_id); |
487 | u32 s_id, u32 d_id); | ||
488 | 560 | ||
489 | /* | 561 | /* |
490 | * Flush the rport work queue. Generally used before shutdown. | 562 | * Flush the rport work queue. Generally used before shutdown. |
@@ -498,8 +570,8 @@ struct libfc_function_template { | |||
498 | * | 570 | * |
499 | * STATUS: OPTIONAL | 571 | * STATUS: OPTIONAL |
500 | */ | 572 | */ |
501 | void (*lport_recv)(struct fc_lport *lp, struct fc_seq *sp, | 573 | void (*lport_recv)(struct fc_lport *, struct fc_seq *, |
502 | struct fc_frame *fp); | 574 | struct fc_frame *); |
503 | 575 | ||
504 | /* | 576 | /* |
505 | * Reset the local port. | 577 | * Reset the local port. |
@@ -565,31 +637,31 @@ struct libfc_function_template { | |||
565 | * | 637 | * |
566 | * STATUS: OPTIONAL | 638 | * STATUS: OPTIONAL |
567 | */ | 639 | */ |
568 | int (*fcp_cmd_send)(struct fc_lport *lp, struct fc_fcp_pkt *fsp, | 640 | int (*fcp_cmd_send)(struct fc_lport *, struct fc_fcp_pkt *, |
569 | void (*resp)(struct fc_seq *, struct fc_frame *fp, | 641 | void (*resp)(struct fc_seq *, struct fc_frame *, |
570 | void *arg)); | 642 | void *)); |
571 | 643 | ||
572 | /* | 644 | /* |
573 | * Cleanup the FCP layer, used durring link down and reset | 645 | * Cleanup the FCP layer, used durring link down and reset |
574 | * | 646 | * |
575 | * STATUS: OPTIONAL | 647 | * STATUS: OPTIONAL |
576 | */ | 648 | */ |
577 | void (*fcp_cleanup)(struct fc_lport *lp); | 649 | void (*fcp_cleanup)(struct fc_lport *); |
578 | 650 | ||
579 | /* | 651 | /* |
580 | * Abort all I/O on a local port | 652 | * Abort all I/O on a local port |
581 | * | 653 | * |
582 | * STATUS: OPTIONAL | 654 | * STATUS: OPTIONAL |
583 | */ | 655 | */ |
584 | void (*fcp_abort_io)(struct fc_lport *lp); | 656 | void (*fcp_abort_io)(struct fc_lport *); |
585 | 657 | ||
586 | /* | 658 | /* |
587 | * Receive a request for the discovery layer. | 659 | * Receive a request for the discovery layer. |
588 | * | 660 | * |
589 | * STATUS: OPTIONAL | 661 | * STATUS: OPTIONAL |
590 | */ | 662 | */ |
591 | void (*disc_recv_req)(struct fc_seq *, | 663 | void (*disc_recv_req)(struct fc_seq *, struct fc_frame *, |
592 | struct fc_frame *, struct fc_lport *); | 664 | struct fc_lport *); |
593 | 665 | ||
594 | /* | 666 | /* |
595 | * Start discovery for a local port. | 667 | * Start discovery for a local port. |
@@ -618,133 +690,224 @@ struct libfc_function_template { | |||
618 | void (*disc_stop_final) (struct fc_lport *); | 690 | void (*disc_stop_final) (struct fc_lport *); |
619 | }; | 691 | }; |
620 | 692 | ||
621 | /* information used by the discovery layer */ | 693 | /** |
694 | * struct fc_disc - Discovery context | ||
695 | * @retry_count: Number of retries | ||
696 | * @pending: 1 if discovery is pending, 0 if not | ||
697 | * @requesting: 1 if discovery has been requested, 0 if not | ||
698 | * @seq_count: Number of sequences used for discovery | ||
699 | * @buf_len: Length of the discovery buffer | ||
700 | * @disc_id: Discovery ID | ||
701 | * @rports: List of discovered remote ports | ||
702 | * @lport: The local port that discovery is for | ||
703 | * @disc_mutex: Mutex that protects the discovery context | ||
704 | * @partial_buf: Partial name buffer (if names are returned | ||
705 | * in multiple frames) | ||
706 | * @disc_work: handle for delayed work context | ||
707 | * @disc_callback: Callback routine called when discovery completes | ||
708 | */ | ||
622 | struct fc_disc { | 709 | struct fc_disc { |
623 | unsigned char retry_count; | 710 | unsigned char retry_count; |
624 | unsigned char pending; | 711 | unsigned char pending; |
625 | unsigned char requested; | 712 | unsigned char requested; |
626 | unsigned short seq_count; | 713 | unsigned short seq_count; |
627 | unsigned char buf_len; | 714 | unsigned char buf_len; |
628 | u16 disc_id; | 715 | u16 disc_id; |
716 | |||
717 | struct list_head rports; | ||
718 | struct fc_lport *lport; | ||
719 | struct mutex disc_mutex; | ||
720 | struct fc_gpn_ft_resp partial_buf; | ||
721 | struct delayed_work disc_work; | ||
629 | 722 | ||
630 | void (*disc_callback)(struct fc_lport *, | 723 | void (*disc_callback)(struct fc_lport *, |
631 | enum fc_disc_event); | 724 | enum fc_disc_event); |
632 | |||
633 | struct list_head rports; | ||
634 | struct fc_lport *lport; | ||
635 | struct mutex disc_mutex; | ||
636 | struct fc_gpn_ft_resp partial_buf; /* partial name buffer */ | ||
637 | struct delayed_work disc_work; | ||
638 | }; | 725 | }; |
639 | 726 | ||
727 | /** | ||
728 | * struct fc_lport - Local port | ||
729 | * @host: The SCSI host associated with a local port | ||
730 | * @ema_list: Exchange manager anchor list | ||
731 | * @dns_rdata: The directory server remote port | ||
732 | * @ptp_rdata: Point to point remote port | ||
733 | * @scsi_priv: FCP layer internal data | ||
734 | * @disc: Discovery context | ||
735 | * @vports: Child vports if N_Port | ||
736 | * @vport: Parent vport if VN_Port | ||
737 | * @tt: Libfc function template | ||
738 | * @link_up: Link state (1 = link up, 0 = link down) | ||
739 | * @qfull: Queue state (1 queue is full, 0 queue is not full) | ||
740 | * @state: Identifies the state | ||
741 | * @boot_time: Timestamp indicating when the local port came online | ||
742 | * @host_stats: SCSI host statistics | ||
743 | * @dev_stats: FCoE device stats (TODO: libfc should not be | ||
744 | * FCoE aware) | ||
745 | * @retry_count: Number of retries in the current state | ||
746 | * @wwpn: World Wide Port Name | ||
747 | * @wwnn: World Wide Node Name | ||
748 | * @service_params: Common service parameters | ||
749 | * @e_d_tov: Error detection timeout value | ||
750 | * @r_a_tov: Resouce allocation timeout value | ||
751 | * @rnid_gen: RNID information | ||
752 | * @sg_supp: Indicates if scatter gather is supported | ||
753 | * @seq_offload: Indicates if sequence offload is supported | ||
754 | * @crc_offload: Indicates if CRC offload is supported | ||
755 | * @lro_enabled: Indicates if large receive offload is supported | ||
756 | * @does_npiv: Supports multiple vports | ||
757 | * @npiv_enabled: Switch/fabric allows NPIV | ||
758 | * @mfs: The maximum Fibre Channel payload size | ||
759 | * @max_retry_count: The maximum retry attempts | ||
760 | * @max_rport_retry_count: The maximum remote port retry attempts | ||
761 | * @lro_xid: The maximum XID for LRO | ||
762 | * @lso_max: The maximum large offload send size | ||
763 | * @fcts: FC-4 type mask | ||
764 | * @lp_mutex: Mutex to protect the local port | ||
765 | * @list: Handle for list of local ports | ||
766 | * @retry_work: Handle to local port for delayed retry context | ||
767 | */ | ||
640 | struct fc_lport { | 768 | struct fc_lport { |
641 | struct list_head list; | ||
642 | |||
643 | /* Associations */ | 769 | /* Associations */ |
644 | struct Scsi_Host *host; | 770 | struct Scsi_Host *host; |
645 | struct list_head ema_list; | 771 | struct list_head ema_list; |
646 | struct list_head vports; /* child vports if N_Port */ | 772 | struct fc_rport_priv *dns_rdata; |
647 | struct fc_vport *vport; /* parent vport if VN_Port */ | 773 | struct fc_rport_priv *ptp_rdata; |
648 | struct fc_rport_priv *dns_rp; | 774 | void *scsi_priv; |
649 | struct fc_rport_priv *ptp_rp; | 775 | struct fc_disc disc; |
650 | void *scsi_priv; | 776 | |
651 | struct fc_disc disc; | 777 | /* Virtual port information */ |
778 | struct list_head vports; | ||
779 | struct fc_vport *vport; | ||
652 | 780 | ||
653 | /* Operational Information */ | 781 | /* Operational Information */ |
654 | struct libfc_function_template tt; | 782 | struct libfc_function_template tt; |
655 | u8 link_up; | 783 | u8 link_up; |
656 | u8 qfull; | 784 | u8 qfull; |
657 | enum fc_lport_state state; | 785 | enum fc_lport_state state; |
658 | unsigned long boot_time; | 786 | unsigned long boot_time; |
659 | 787 | struct fc_host_statistics host_stats; | |
660 | struct fc_host_statistics host_stats; | 788 | struct fcoe_dev_stats *dev_stats; |
661 | struct fcoe_dev_stats *dev_stats; | 789 | u8 retry_count; |
662 | 790 | ||
663 | u64 wwpn; | 791 | /* Fabric information */ |
664 | u64 wwnn; | 792 | u64 wwpn; |
665 | u8 retry_count; | 793 | u64 wwnn; |
794 | unsigned int service_params; | ||
795 | unsigned int e_d_tov; | ||
796 | unsigned int r_a_tov; | ||
797 | struct fc_els_rnid_gen rnid_gen; | ||
666 | 798 | ||
667 | /* Capabilities */ | 799 | /* Capabilities */ |
668 | u32 sg_supp:1; /* scatter gather supported */ | 800 | u32 sg_supp:1; |
669 | u32 seq_offload:1; /* seq offload supported */ | 801 | u32 seq_offload:1; |
670 | u32 crc_offload:1; /* crc offload supported */ | 802 | u32 crc_offload:1; |
671 | u32 lro_enabled:1; /* large receive offload */ | 803 | u32 lro_enabled:1; |
672 | u32 does_npiv:1; /* supports multiple vports */ | 804 | u32 does_npiv:1; |
673 | u32 npiv_enabled:1; /* switch/fabric allows NPIV */ | 805 | u32 npiv_enabled:1; |
674 | u32 mfs; /* max FC payload size */ | 806 | u32 mfs; |
675 | unsigned int service_params; | 807 | u8 max_retry_count; |
676 | unsigned int e_d_tov; | 808 | u8 max_rport_retry_count; |
677 | unsigned int r_a_tov; | 809 | u16 link_speed; |
678 | u8 max_retry_count; | 810 | u16 link_supported_speeds; |
679 | u8 max_rport_retry_count; | 811 | u16 lro_xid; |
680 | u16 link_speed; | 812 | unsigned int lso_max; |
681 | u16 link_supported_speeds; | 813 | struct fc_ns_fts fcts; |
682 | u16 lro_xid; /* max xid for fcoe lro */ | ||
683 | unsigned int lso_max; /* max large send size */ | ||
684 | struct fc_ns_fts fcts; /* FC-4 type masks */ | ||
685 | struct fc_els_rnid_gen rnid_gen; /* RNID information */ | ||
686 | |||
687 | /* Semaphores */ | ||
688 | struct mutex lp_mutex; | ||
689 | 814 | ||
690 | /* Miscellaneous */ | 815 | /* Miscellaneous */ |
691 | struct delayed_work retry_work; | 816 | struct mutex lp_mutex; |
817 | struct list_head list; | ||
818 | struct delayed_work retry_work; | ||
692 | }; | 819 | }; |
693 | 820 | ||
694 | /* | 821 | /* |
695 | * FC_LPORT HELPER FUNCTIONS | 822 | * FC_LPORT HELPER FUNCTIONS |
696 | *****************************/ | 823 | *****************************/ |
697 | static inline int fc_lport_test_ready(struct fc_lport *lp) | 824 | |
825 | /** | ||
826 | * fc_lport_test_ready() - Determine if a local port is in the READY state | ||
827 | * @lport: The local port to test | ||
828 | */ | ||
829 | static inline int fc_lport_test_ready(struct fc_lport *lport) | ||
698 | { | 830 | { |
699 | return lp->state == LPORT_ST_READY; | 831 | return lport->state == LPORT_ST_READY; |
700 | } | 832 | } |
701 | 833 | ||
702 | static inline void fc_set_wwnn(struct fc_lport *lp, u64 wwnn) | 834 | /** |
835 | * fc_set_wwnn() - Set the World Wide Node Name of a local port | ||
836 | * @lport: The local port whose WWNN is to be set | ||
837 | * @wwnn: The new WWNN | ||
838 | */ | ||
839 | static inline void fc_set_wwnn(struct fc_lport *lport, u64 wwnn) | ||
703 | { | 840 | { |
704 | lp->wwnn = wwnn; | 841 | lport->wwnn = wwnn; |
705 | } | 842 | } |
706 | 843 | ||
707 | static inline void fc_set_wwpn(struct fc_lport *lp, u64 wwnn) | 844 | /** |
845 | * fc_set_wwpn() - Set the World Wide Port Name of a local port | ||
846 | * @lport: The local port whose WWPN is to be set | ||
847 | * @wwnn: The new WWPN | ||
848 | */ | ||
849 | static inline void fc_set_wwpn(struct fc_lport *lport, u64 wwnn) | ||
708 | { | 850 | { |
709 | lp->wwpn = wwnn; | 851 | lport->wwpn = wwnn; |
710 | } | 852 | } |
711 | 853 | ||
712 | static inline void fc_lport_state_enter(struct fc_lport *lp, | 854 | /** |
855 | * fc_lport_state_enter() - Change a local port's state | ||
856 | * @lport: The local port whose state is to change | ||
857 | * @state: The new state | ||
858 | */ | ||
859 | static inline void fc_lport_state_enter(struct fc_lport *lport, | ||
713 | enum fc_lport_state state) | 860 | enum fc_lport_state state) |
714 | { | 861 | { |
715 | if (state != lp->state) | 862 | if (state != lport->state) |
716 | lp->retry_count = 0; | 863 | lport->retry_count = 0; |
717 | lp->state = state; | 864 | lport->state = state; |
718 | } | 865 | } |
719 | 866 | ||
720 | static inline int fc_lport_init_stats(struct fc_lport *lp) | 867 | /** |
868 | * fc_lport_init_stats() - Allocate per-CPU statistics for a local port | ||
869 | * @lport: The local port whose statistics are to be initialized | ||
870 | */ | ||
871 | static inline int fc_lport_init_stats(struct fc_lport *lport) | ||
721 | { | 872 | { |
722 | /* allocate per cpu stats block */ | 873 | lport->dev_stats = alloc_percpu(struct fcoe_dev_stats); |
723 | lp->dev_stats = alloc_percpu(struct fcoe_dev_stats); | 874 | if (!lport->dev_stats) |
724 | if (!lp->dev_stats) | ||
725 | return -ENOMEM; | 875 | return -ENOMEM; |
726 | return 0; | 876 | return 0; |
727 | } | 877 | } |
728 | 878 | ||
729 | static inline void fc_lport_free_stats(struct fc_lport *lp) | 879 | /** |
880 | * fc_lport_free_stats() - Free memory for a local port's statistics | ||
881 | * @lport: The local port whose statistics are to be freed | ||
882 | */ | ||
883 | static inline void fc_lport_free_stats(struct fc_lport *lport) | ||
730 | { | 884 | { |
731 | free_percpu(lp->dev_stats); | 885 | free_percpu(lport->dev_stats); |
732 | } | 886 | } |
733 | 887 | ||
734 | static inline struct fcoe_dev_stats *fc_lport_get_stats(struct fc_lport *lp) | 888 | /** |
889 | * fc_lport_get_stats() - Get a local port's statistics | ||
890 | * @lport: The local port whose statistics are to be retreived | ||
891 | */ | ||
892 | static inline struct fcoe_dev_stats *fc_lport_get_stats(struct fc_lport *lport) | ||
735 | { | 893 | { |
736 | return per_cpu_ptr(lp->dev_stats, smp_processor_id()); | 894 | return per_cpu_ptr(lport->dev_stats, smp_processor_id()); |
737 | } | 895 | } |
738 | 896 | ||
739 | static inline void *lport_priv(const struct fc_lport *lp) | 897 | /** |
898 | * lport_priv() - Return the private data from a local port | ||
899 | * @lport: The local port whose private data is to be retreived | ||
900 | */ | ||
901 | static inline void *lport_priv(const struct fc_lport *lport) | ||
740 | { | 902 | { |
741 | return (void *)(lp + 1); | 903 | return (void *)(lport + 1); |
742 | } | 904 | } |
743 | 905 | ||
744 | /** | 906 | /** |
745 | * libfc_host_alloc() - Allocate a Scsi_Host with room for the fc_lport | 907 | * libfc_host_alloc() - Allocate a Scsi_Host with room for a local port and |
746 | * @sht: ptr to the scsi host templ | 908 | * LLD private data |
747 | * @priv_size: size of private data after fc_lport | 909 | * @sht: The SCSI host template |
910 | * @priv_size: Size of private data | ||
748 | * | 911 | * |
749 | * Returns: libfc lport | 912 | * Returns: libfc lport |
750 | */ | 913 | */ |
@@ -765,156 +928,73 @@ libfc_host_alloc(struct scsi_host_template *sht, int priv_size) | |||
765 | } | 928 | } |
766 | 929 | ||
767 | /* | 930 | /* |
768 | * LOCAL PORT LAYER | 931 | * FC_FCP HELPER FUNCTIONS |
769 | *****************************/ | 932 | *****************************/ |
770 | int fc_lport_init(struct fc_lport *lp); | 933 | static inline bool fc_fcp_is_read(const struct fc_fcp_pkt *fsp) |
771 | 934 | { | |
772 | /* | 935 | if (fsp && fsp->cmd) |
773 | * Destroy the specified local port by finding and freeing all | 936 | return fsp->cmd->sc_data_direction == DMA_FROM_DEVICE; |
774 | * fc_rports associated with it and then by freeing the fc_lport | 937 | return false; |
775 | * itself. | 938 | } |
776 | */ | ||
777 | int fc_lport_destroy(struct fc_lport *lp); | ||
778 | |||
779 | /* | ||
780 | * Logout the specified local port from the fabric | ||
781 | */ | ||
782 | int fc_fabric_logoff(struct fc_lport *lp); | ||
783 | |||
784 | /* | ||
785 | * Initiate the LP state machine. This handler will use fc_host_attr | ||
786 | * to store the FLOGI service parameters, so fc_host_attr must be | ||
787 | * initialized before calling this handler. | ||
788 | */ | ||
789 | int fc_fabric_login(struct fc_lport *lp); | ||
790 | 939 | ||
791 | /* | 940 | /* |
792 | * The link is up for the given local port. | 941 | * LOCAL PORT LAYER |
793 | */ | 942 | *****************************/ |
943 | int fc_lport_init(struct fc_lport *); | ||
944 | int fc_lport_destroy(struct fc_lport *); | ||
945 | int fc_fabric_logoff(struct fc_lport *); | ||
946 | int fc_fabric_login(struct fc_lport *); | ||
794 | void __fc_linkup(struct fc_lport *); | 947 | void __fc_linkup(struct fc_lport *); |
795 | void fc_linkup(struct fc_lport *); | 948 | void fc_linkup(struct fc_lport *); |
796 | |||
797 | /* | ||
798 | * Link is down for the given local port. | ||
799 | */ | ||
800 | void __fc_linkdown(struct fc_lport *); | 949 | void __fc_linkdown(struct fc_lport *); |
801 | void fc_linkdown(struct fc_lport *); | 950 | void fc_linkdown(struct fc_lport *); |
802 | 951 | void fc_vport_setlink(struct fc_lport *); | |
803 | /* | 952 | void fc_vports_linkchange(struct fc_lport *); |
804 | * Configure the local port. | ||
805 | */ | ||
806 | int fc_lport_config(struct fc_lport *); | 953 | int fc_lport_config(struct fc_lport *); |
807 | |||
808 | /* | ||
809 | * Reset the local port. | ||
810 | */ | ||
811 | int fc_lport_reset(struct fc_lport *); | 954 | int fc_lport_reset(struct fc_lport *); |
812 | 955 | int fc_set_mfs(struct fc_lport *, u32 mfs); | |
813 | /* | 956 | struct fc_lport *libfc_vport_create(struct fc_vport *, int privsize); |
814 | * Set the mfs or reset | 957 | struct fc_lport *fc_vport_id_lookup(struct fc_lport *, u32 port_id); |
815 | */ | 958 | int fc_lport_bsg_request(struct fc_bsg_job *); |
816 | int fc_set_mfs(struct fc_lport *lp, u32 mfs); | ||
817 | |||
818 | /* | ||
819 | * Allocate a new lport struct for an NPIV VN_Port | ||
820 | */ | ||
821 | struct fc_lport *libfc_vport_create(struct fc_vport *vport, int privsize); | ||
822 | |||
823 | /* | ||
824 | * Find an NPIV VN_Port by port ID | ||
825 | */ | ||
826 | struct fc_lport *fc_vport_id_lookup(struct fc_lport *n_port, u32 port_id); | ||
827 | |||
828 | /* | ||
829 | * NPIV VN_Port link state management | ||
830 | */ | ||
831 | void fc_vport_setlink(struct fc_lport *vn_port); | ||
832 | void fc_vports_linkchange(struct fc_lport *n_port); | ||
833 | |||
834 | /* | ||
835 | * Issue fc pass-thru request via bsg interface | ||
836 | */ | ||
837 | int fc_lport_bsg_request(struct fc_bsg_job *job); | ||
838 | |||
839 | 959 | ||
840 | /* | 960 | /* |
841 | * REMOTE PORT LAYER | 961 | * REMOTE PORT LAYER |
842 | *****************************/ | 962 | *****************************/ |
843 | int fc_rport_init(struct fc_lport *lp); | 963 | int fc_rport_init(struct fc_lport *); |
844 | void fc_rport_terminate_io(struct fc_rport *rp); | 964 | void fc_rport_terminate_io(struct fc_rport *); |
845 | 965 | ||
846 | /* | 966 | /* |
847 | * DISCOVERY LAYER | 967 | * DISCOVERY LAYER |
848 | *****************************/ | 968 | *****************************/ |
849 | int fc_disc_init(struct fc_lport *lp); | 969 | int fc_disc_init(struct fc_lport *); |
850 | |||
851 | 970 | ||
852 | /* | 971 | /* |
853 | * SCSI LAYER | 972 | * FCP LAYER |
854 | *****************************/ | 973 | *****************************/ |
855 | /* | ||
856 | * Initialize the SCSI block of libfc | ||
857 | */ | ||
858 | int fc_fcp_init(struct fc_lport *); | 974 | int fc_fcp_init(struct fc_lport *); |
975 | void fc_fcp_destroy(struct fc_lport *); | ||
859 | 976 | ||
860 | /* | 977 | /* |
861 | * This section provides an API which allows direct interaction | 978 | * SCSI INTERACTION LAYER |
862 | * with the SCSI-ml. Each of these functions satisfies a function | 979 | *****************************/ |
863 | * pointer defined in Scsi_Host and therefore is always called | 980 | int fc_queuecommand(struct scsi_cmnd *, |
864 | * directly from the SCSI-ml. | ||
865 | */ | ||
866 | int fc_queuecommand(struct scsi_cmnd *sc_cmd, | ||
867 | void (*done)(struct scsi_cmnd *)); | 981 | void (*done)(struct scsi_cmnd *)); |
868 | 982 | int fc_eh_abort(struct scsi_cmnd *); | |
869 | /* | 983 | int fc_eh_device_reset(struct scsi_cmnd *); |
870 | * Send an ABTS frame to the target device. The sc_cmd argument | 984 | int fc_eh_host_reset(struct scsi_cmnd *); |
871 | * is a pointer to the SCSI command to be aborted. | 985 | int fc_slave_alloc(struct scsi_device *); |
872 | */ | 986 | int fc_change_queue_depth(struct scsi_device *, int qdepth, int reason); |
873 | int fc_eh_abort(struct scsi_cmnd *sc_cmd); | 987 | int fc_change_queue_type(struct scsi_device *, int tag_type); |
874 | |||
875 | /* | ||
876 | * Reset a LUN by sending send the tm cmd to the target. | ||
877 | */ | ||
878 | int fc_eh_device_reset(struct scsi_cmnd *sc_cmd); | ||
879 | |||
880 | /* | ||
881 | * Reset the host adapter. | ||
882 | */ | ||
883 | int fc_eh_host_reset(struct scsi_cmnd *sc_cmd); | ||
884 | |||
885 | /* | ||
886 | * Check rport status. | ||
887 | */ | ||
888 | int fc_slave_alloc(struct scsi_device *sdev); | ||
889 | |||
890 | /* | ||
891 | * Adjust the queue depth. | ||
892 | */ | ||
893 | int fc_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason); | ||
894 | |||
895 | /* | ||
896 | * Change the tag type. | ||
897 | */ | ||
898 | int fc_change_queue_type(struct scsi_device *sdev, int tag_type); | ||
899 | |||
900 | /* | ||
901 | * Free memory pools used by the FCP layer. | ||
902 | */ | ||
903 | void fc_fcp_destroy(struct fc_lport *); | ||
904 | 988 | ||
905 | /* | 989 | /* |
906 | * ELS/CT interface | 990 | * ELS/CT interface |
907 | *****************************/ | 991 | *****************************/ |
908 | /* | 992 | int fc_elsct_init(struct fc_lport *); |
909 | * Initializes ELS/CT interface | 993 | struct fc_seq *fc_elsct_send(struct fc_lport *, u32 did, |
910 | */ | 994 | struct fc_frame *, |
911 | int fc_elsct_init(struct fc_lport *lp); | ||
912 | struct fc_seq *fc_elsct_send(struct fc_lport *lport, | ||
913 | u32 did, | ||
914 | struct fc_frame *fp, | ||
915 | unsigned int op, | 995 | unsigned int op, |
916 | void (*resp)(struct fc_seq *, | 996 | void (*resp)(struct fc_seq *, |
917 | struct fc_frame *fp, | 997 | struct fc_frame *, |
918 | void *arg), | 998 | void *arg), |
919 | void *arg, u32 timer_msec); | 999 | void *arg, u32 timer_msec); |
920 | void fc_lport_flogi_resp(struct fc_seq *, struct fc_frame *, void *); | 1000 | void fc_lport_flogi_resp(struct fc_seq *, struct fc_frame *, void *); |
@@ -924,90 +1004,26 @@ void fc_lport_logo_resp(struct fc_seq *, struct fc_frame *, void *); | |||
924 | /* | 1004 | /* |
925 | * EXCHANGE MANAGER LAYER | 1005 | * EXCHANGE MANAGER LAYER |
926 | *****************************/ | 1006 | *****************************/ |
927 | /* | 1007 | int fc_exch_init(struct fc_lport *); |
928 | * Initializes Exchange Manager related | 1008 | struct fc_exch_mgr_anchor *fc_exch_mgr_add(struct fc_lport *, |
929 | * function pointers in struct libfc_function_template. | 1009 | struct fc_exch_mgr *, |
930 | */ | ||
931 | int fc_exch_init(struct fc_lport *lp); | ||
932 | |||
933 | /* | ||
934 | * Adds Exchange Manager (EM) mp to lport. | ||
935 | * | ||
936 | * Adds specified mp to lport using struct fc_exch_mgr_anchor, | ||
937 | * the struct fc_exch_mgr_anchor allows same EM sharing by | ||
938 | * more than one lport with their specified match function, | ||
939 | * the match function is used in allocating exchange from | ||
940 | * added mp. | ||
941 | */ | ||
942 | struct fc_exch_mgr_anchor *fc_exch_mgr_add(struct fc_lport *lport, | ||
943 | struct fc_exch_mgr *mp, | ||
944 | bool (*match)(struct fc_frame *)); | 1010 | bool (*match)(struct fc_frame *)); |
945 | 1011 | void fc_exch_mgr_del(struct fc_exch_mgr_anchor *); | |
946 | /* | ||
947 | * Deletes Exchange Manager (EM) from lport by removing | ||
948 | * its anchor ema from lport. | ||
949 | * | ||
950 | * If removed anchor ema was the last user of its associated EM | ||
951 | * then also destroys associated EM. | ||
952 | */ | ||
953 | void fc_exch_mgr_del(struct fc_exch_mgr_anchor *ema); | ||
954 | |||
955 | /* | ||
956 | * Clone an exchange manager list, getting reference holds for each EM. | ||
957 | * This is for use with NPIV and sharing the X_ID space between VN_Ports. | ||
958 | */ | ||
959 | int fc_exch_mgr_list_clone(struct fc_lport *src, struct fc_lport *dst); | 1012 | int fc_exch_mgr_list_clone(struct fc_lport *src, struct fc_lport *dst); |
960 | 1013 | struct fc_exch_mgr *fc_exch_mgr_alloc(struct fc_lport *, enum fc_class class, | |
961 | /* | 1014 | u16 min_xid, u16 max_xid, |
962 | * Allocates an Exchange Manager (EM). | ||
963 | * | ||
964 | * The EM manages exchanges for their allocation and | ||
965 | * free, also allows exchange lookup for received | ||
966 | * frame. | ||
967 | * | ||
968 | * The class is used for initializing FC class of | ||
969 | * allocated exchange from EM. | ||
970 | * | ||
971 | * The min_xid and max_xid will limit new | ||
972 | * exchange ID (XID) within this range for | ||
973 | * a new exchange. | ||
974 | * The LLD may choose to have multiple EMs, | ||
975 | * e.g. one EM instance per CPU receive thread in LLD. | ||
976 | * | ||
977 | * Specified match function is used in allocating exchanges | ||
978 | * from newly allocated EM. | ||
979 | */ | ||
980 | struct fc_exch_mgr *fc_exch_mgr_alloc(struct fc_lport *lp, | ||
981 | enum fc_class class, | ||
982 | u16 min_xid, | ||
983 | u16 max_xid, | ||
984 | bool (*match)(struct fc_frame *)); | 1015 | bool (*match)(struct fc_frame *)); |
985 | 1016 | void fc_exch_mgr_free(struct fc_lport *); | |
986 | /* | 1017 | void fc_exch_recv(struct fc_lport *, struct fc_frame *); |
987 | * Free all exchange managers of a lport. | ||
988 | */ | ||
989 | void fc_exch_mgr_free(struct fc_lport *lport); | ||
990 | |||
991 | /* | ||
992 | * Receive a frame on specified local port and exchange manager. | ||
993 | */ | ||
994 | void fc_exch_recv(struct fc_lport *lp, struct fc_frame *fp); | ||
995 | |||
996 | /* | ||
997 | * Reset all EMs of a lport, releasing its all sequences and | ||
998 | * exchanges. If sid is non-zero, then reset only exchanges | ||
999 | * we sourced from that FID. If did is non-zero, reset only | ||
1000 | * exchanges destined to that FID. | ||
1001 | */ | ||
1002 | void fc_exch_mgr_reset(struct fc_lport *, u32 s_id, u32 d_id); | 1018 | void fc_exch_mgr_reset(struct fc_lport *, u32 s_id, u32 d_id); |
1003 | 1019 | ||
1004 | /* | 1020 | /* |
1005 | * Functions for fc_functions_template | 1021 | * Functions for fc_functions_template |
1006 | */ | 1022 | */ |
1007 | void fc_get_host_speed(struct Scsi_Host *shost); | 1023 | void fc_get_host_speed(struct Scsi_Host *); |
1008 | void fc_get_host_port_type(struct Scsi_Host *shost); | 1024 | void fc_get_host_port_type(struct Scsi_Host *); |
1009 | void fc_get_host_port_state(struct Scsi_Host *shost); | 1025 | void fc_get_host_port_state(struct Scsi_Host *); |
1010 | void fc_set_rport_loss_tmo(struct fc_rport *rport, u32 timeout); | 1026 | void fc_set_rport_loss_tmo(struct fc_rport *, u32 timeout); |
1011 | struct fc_host_statistics *fc_get_host_stats(struct Scsi_Host *); | 1027 | struct fc_host_statistics *fc_get_host_stats(struct Scsi_Host *); |
1012 | 1028 | ||
1013 | #endif /* _LIBFC_H_ */ | 1029 | #endif /* _LIBFC_H_ */ |