diff options
Diffstat (limited to 'drivers/scsi/libfc/fc_disc.c')
-rw-r--r-- | drivers/scsi/libfc/fc_disc.c | 85 |
1 files changed, 43 insertions, 42 deletions
diff --git a/drivers/scsi/libfc/fc_disc.c b/drivers/scsi/libfc/fc_disc.c index c48799e9dd8e..9b0a5192a965 100644 --- a/drivers/scsi/libfc/fc_disc.c +++ b/drivers/scsi/libfc/fc_disc.c | |||
@@ -40,6 +40,8 @@ | |||
40 | 40 | ||
41 | #include <scsi/libfc.h> | 41 | #include <scsi/libfc.h> |
42 | 42 | ||
43 | #include "fc_libfc.h" | ||
44 | |||
43 | #define FC_DISC_RETRY_LIMIT 3 /* max retries */ | 45 | #define FC_DISC_RETRY_LIMIT 3 /* max retries */ |
44 | #define FC_DISC_RETRY_DELAY 500UL /* (msecs) delay */ | 46 | #define FC_DISC_RETRY_DELAY 500UL /* (msecs) delay */ |
45 | 47 | ||
@@ -51,8 +53,8 @@ static int fc_disc_single(struct fc_lport *, struct fc_disc_port *); | |||
51 | static void fc_disc_restart(struct fc_disc *); | 53 | static void fc_disc_restart(struct fc_disc *); |
52 | 54 | ||
53 | /** | 55 | /** |
54 | * 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 |
55 | * @disc: The discovery job to stop rports on | 57 | * @disc: The discovery job to stop remote ports on |
56 | * | 58 | * |
57 | * 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 |
58 | * calling it. | 60 | * calling it. |
@@ -72,9 +74,9 @@ void fc_disc_stop_rports(struct fc_disc *disc) | |||
72 | 74 | ||
73 | /** | 75 | /** |
74 | * fc_disc_recv_rscn_req() - Handle Registered State Change Notification (RSCN) | 76 | * fc_disc_recv_rscn_req() - Handle Registered State Change Notification (RSCN) |
75 | * @sp: Current sequence of the RSCN exchange | 77 | * @sp: The sequence of the RSCN exchange |
76 | * @fp: RSCN Frame | 78 | * @fp: The RSCN frame |
77 | * @lport: Fibre Channel host port instance | 79 | * @lport: The local port that the request will be sent on |
78 | * | 80 | * |
79 | * Locking Note: This function expects that the disc_mutex is locked | 81 | * Locking Note: This function expects that the disc_mutex is locked |
80 | * before it is called. | 82 | * before it is called. |
@@ -183,9 +185,9 @@ reject: | |||
183 | 185 | ||
184 | /** | 186 | /** |
185 | * fc_disc_recv_req() - Handle incoming requests | 187 | * fc_disc_recv_req() - Handle incoming requests |
186 | * @sp: Current sequence of the request exchange | 188 | * @sp: The sequence of the request exchange |
187 | * @fp: The frame | 189 | * @fp: The request frame |
188 | * @lport: The FC local port | 190 | * @lport: The local port receiving the request |
189 | * | 191 | * |
190 | * 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 |
191 | * the disc_mutex before calling the handler for the | 193 | * the disc_mutex before calling the handler for the |
@@ -213,7 +215,7 @@ static void fc_disc_recv_req(struct fc_seq *sp, struct fc_frame *fp, | |||
213 | 215 | ||
214 | /** | 216 | /** |
215 | * fc_disc_restart() - Restart discovery | 217 | * fc_disc_restart() - Restart discovery |
216 | * @lport: FC discovery context | 218 | * @disc: The discovery object to be restarted |
217 | * | 219 | * |
218 | * Locking Note: This function expects that the disc mutex | 220 | * Locking Note: This function expects that the disc mutex |
219 | * is already locked. | 221 | * is already locked. |
@@ -240,9 +242,9 @@ static void fc_disc_restart(struct fc_disc *disc) | |||
240 | } | 242 | } |
241 | 243 | ||
242 | /** | 244 | /** |
243 | * fc_disc_start() - Fibre Channel Target discovery | 245 | * fc_disc_start() - Start discovery on a local port |
244 | * @lport: FC local port | 246 | * @lport: The local port to have discovery started on |
245 | * @disc_callback: function to be called when discovery is complete | 247 | * @disc_callback: Callback function to be called when discovery is complete |
246 | */ | 248 | */ |
247 | static void fc_disc_start(void (*disc_callback)(struct fc_lport *, | 249 | static void fc_disc_start(void (*disc_callback)(struct fc_lport *, |
248 | enum fc_disc_event), | 250 | enum fc_disc_event), |
@@ -263,8 +265,8 @@ static void fc_disc_start(void (*disc_callback)(struct fc_lport *, | |||
263 | 265 | ||
264 | /** | 266 | /** |
265 | * fc_disc_done() - Discovery has been completed | 267 | * fc_disc_done() - Discovery has been completed |
266 | * @disc: FC discovery context | 268 | * @disc: The discovery context |
267 | * @event: discovery completion status | 269 | * @event: The discovery completion status |
268 | * | 270 | * |
269 | * 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 |
270 | * 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, |
@@ -284,8 +286,8 @@ static void fc_disc_done(struct fc_disc *disc, enum fc_disc_event event) | |||
284 | } | 286 | } |
285 | 287 | ||
286 | /* | 288 | /* |
287 | * 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 |
288 | * discovery, reverify or log them in. Otherwise, log them out. | 290 | * discovery, reverify or log them in. Otherwise, log them out. |
289 | * Skip ports which were never discovered. These are the dNS port | 291 | * Skip ports which were never discovered. These are the dNS port |
290 | * and ports which were created by PLOGI. | 292 | * and ports which were created by PLOGI. |
291 | */ | 293 | */ |
@@ -305,8 +307,8 @@ static void fc_disc_done(struct fc_disc *disc, enum fc_disc_event event) | |||
305 | 307 | ||
306 | /** | 308 | /** |
307 | * fc_disc_error() - Handle error on dNS request | 309 | * fc_disc_error() - Handle error on dNS request |
308 | * @disc: FC discovery context | 310 | * @disc: The discovery context |
309 | * @fp: The frame pointer | 311 | * @fp: The error code encoded as a frame pointer |
310 | */ | 312 | */ |
311 | 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) |
312 | { | 314 | { |
@@ -342,7 +344,7 @@ static void fc_disc_error(struct fc_disc *disc, struct fc_frame *fp) | |||
342 | 344 | ||
343 | /** | 345 | /** |
344 | * 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 |
345 | * @lport: FC discovery context | 347 | * @lport: The discovery context |
346 | * | 348 | * |
347 | * Locking Note: This function expects that the disc_mutex is locked | 349 | * Locking Note: This function expects that the disc_mutex is locked |
348 | * before it is called. | 350 | * before it is called. |
@@ -368,17 +370,17 @@ static void fc_disc_gpn_ft_req(struct fc_disc *disc) | |||
368 | if (lport->tt.elsct_send(lport, 0, fp, | 370 | if (lport->tt.elsct_send(lport, 0, fp, |
369 | FC_NS_GPN_FT, | 371 | FC_NS_GPN_FT, |
370 | fc_disc_gpn_ft_resp, | 372 | fc_disc_gpn_ft_resp, |
371 | disc, lport->e_d_tov)) | 373 | disc, 3 * lport->r_a_tov)) |
372 | return; | 374 | return; |
373 | err: | 375 | err: |
374 | fc_disc_error(disc, fp); | 376 | fc_disc_error(disc, NULL); |
375 | } | 377 | } |
376 | 378 | ||
377 | /** | 379 | /** |
378 | * 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. |
379 | * @lport: Fibre Channel host port instance | 381 | * @lport: The local port the GPN_FT was received on |
380 | * @buf: GPN_FT response buffer | 382 | * @buf: The GPN_FT response buffer |
381 | * @len: size of response buffer | 383 | * @len: The size of response buffer |
382 | * | 384 | * |
383 | * 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. |
384 | */ | 386 | */ |
@@ -477,10 +479,8 @@ static int fc_disc_gpn_ft_parse(struct fc_disc *disc, void *buf, size_t len) | |||
477 | } | 479 | } |
478 | 480 | ||
479 | /** | 481 | /** |
480 | * fc_disc_timeout() - Retry handler for the disc component | 482 | * fc_disc_timeout() - Handler for discovery timeouts |
481 | * @work: Structure holding disc obj that needs retry discovery | 483 | * @work: Structure holding discovery context that needs to retry discovery |
482 | * | ||
483 | * Handle retry of memory allocation for remote ports. | ||
484 | */ | 484 | */ |
485 | static void fc_disc_timeout(struct work_struct *work) | 485 | static void fc_disc_timeout(struct work_struct *work) |
486 | { | 486 | { |
@@ -494,9 +494,9 @@ static void fc_disc_timeout(struct work_struct *work) | |||
494 | 494 | ||
495 | /** | 495 | /** |
496 | * 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) |
497 | * @sp: Current sequence of GPN_FT exchange | 497 | * @sp: The sequence that the GPN_FT response was received on |
498 | * @fp: response frame | 498 | * @fp: The GPN_FT response frame |
499 | * @lp_arg: Fibre Channel host port instance | 499 | * @lp_arg: The discovery context |
500 | * | 500 | * |
501 | * Locking Note: This function is called without disc mutex held, and | 501 | * Locking Note: This function is called without disc mutex held, and |
502 | * should do all its processing with the mutex held | 502 | * should do all its processing with the mutex held |
@@ -567,9 +567,9 @@ static void fc_disc_gpn_ft_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
567 | 567 | ||
568 | /** | 568 | /** |
569 | * 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) |
570 | * @sp: exchange sequence | 570 | * @sp: The sequence the GPN_ID is on |
571 | * @fp: response frame | 571 | * @fp: The response frame |
572 | * @rdata_arg: remote port private data | 572 | * @rdata_arg: The remote port that sent the GPN_ID response |
573 | * | 573 | * |
574 | * Locking Note: This function is called without disc mutex held. | 574 | * Locking Note: This function is called without disc mutex held. |
575 | */ | 575 | */ |
@@ -637,7 +637,7 @@ out: | |||
637 | 637 | ||
638 | /** | 638 | /** |
639 | * 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 |
640 | * @lport: local port | 640 | * @lport: The local port to initiate discovery on |
641 | * @rdata: remote port private data | 641 | * @rdata: remote port private data |
642 | * | 642 | * |
643 | * Locking Note: This function expects that the disc_mutex is locked | 643 | * Locking Note: This function expects that the disc_mutex is locked |
@@ -654,7 +654,8 @@ static int fc_disc_gpn_id_req(struct fc_lport *lport, | |||
654 | if (!fp) | 654 | if (!fp) |
655 | return -ENOMEM; | 655 | return -ENOMEM; |
656 | 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, |
657 | fc_disc_gpn_id_resp, rdata, lport->e_d_tov)) | 657 | fc_disc_gpn_id_resp, rdata, |
658 | 3 * lport->r_a_tov)) | ||
658 | return -ENOMEM; | 659 | return -ENOMEM; |
659 | kref_get(&rdata->kref); | 660 | kref_get(&rdata->kref); |
660 | return 0; | 661 | return 0; |
@@ -662,8 +663,8 @@ static int fc_disc_gpn_id_req(struct fc_lport *lport, | |||
662 | 663 | ||
663 | /** | 664 | /** |
664 | * fc_disc_single() - Discover the directory information for a single target | 665 | * fc_disc_single() - Discover the directory information for a single target |
665 | * @lport: local port | 666 | * @lport: The local port the remote port is associated with |
666 | * @dp: The port to rediscover | 667 | * @dp: The port to rediscover |
667 | * | 668 | * |
668 | * Locking Note: This function expects that the disc_mutex is locked | 669 | * Locking Note: This function expects that the disc_mutex is locked |
669 | * before it is called. | 670 | * before it is called. |
@@ -681,7 +682,7 @@ static int fc_disc_single(struct fc_lport *lport, struct fc_disc_port *dp) | |||
681 | 682 | ||
682 | /** | 683 | /** |
683 | * fc_disc_stop() - Stop discovery for a given lport | 684 | * fc_disc_stop() - Stop discovery for a given lport |
684 | * @lport: The lport that discovery should stop for | 685 | * @lport: The local port that discovery should stop on |
685 | */ | 686 | */ |
686 | void fc_disc_stop(struct fc_lport *lport) | 687 | void fc_disc_stop(struct fc_lport *lport) |
687 | { | 688 | { |
@@ -695,7 +696,7 @@ void fc_disc_stop(struct fc_lport *lport) | |||
695 | 696 | ||
696 | /** | 697 | /** |
697 | * fc_disc_stop_final() - Stop discovery for a given lport | 698 | * fc_disc_stop_final() - Stop discovery for a given lport |
698 | * @lport: The lport that discovery should stop for | 699 | * @lport: The lport that discovery should stop on |
699 | * | 700 | * |
700 | * This function will block until discovery has been | 701 | * This function will block until discovery has been |
701 | * completely stopped and all rports have been deleted. | 702 | * completely stopped and all rports have been deleted. |
@@ -707,8 +708,8 @@ void fc_disc_stop_final(struct fc_lport *lport) | |||
707 | } | 708 | } |
708 | 709 | ||
709 | /** | 710 | /** |
710 | * fc_disc_init() - Initialize the discovery block | 711 | * fc_disc_init() - Initialize the discovery layer for a local port |
711 | * @lport: FC local port | 712 | * @lport: The local port that needs the discovery layer to be initialized |
712 | */ | 713 | */ |
713 | int fc_disc_init(struct fc_lport *lport) | 714 | int fc_disc_init(struct fc_lport *lport) |
714 | { | 715 | { |