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