@@ -49,7 +49,6 @@ static void fc_disc_gpn_ft_req(struct fc_disc *);
4949static void fc_disc_gpn_ft_resp (struct fc_seq * , struct fc_frame * , void * );
5050static int fc_disc_new_target (struct fc_disc * , struct fc_rport * ,
5151 struct fc_rport_identifiers * );
52- static void fc_disc_del_target (struct fc_disc * , struct fc_rport * );
5352static void fc_disc_done (struct fc_disc * );
5453static void fc_disc_timeout (struct work_struct * );
5554static void fc_disc_single (struct fc_disc * , struct fc_disc_port * );
@@ -60,27 +59,19 @@ static void fc_disc_restart(struct fc_disc *);
6059 * @lport: Fibre Channel host port instance
6160 * @port_id: remote port port_id to match
6261 */
63- struct fc_rport * fc_disc_lookup_rport (const struct fc_lport * lport ,
64- u32 port_id )
62+ struct fc_rport_priv * fc_disc_lookup_rport (const struct fc_lport * lport ,
63+ u32 port_id )
6564{
6665 const struct fc_disc * disc = & lport -> disc ;
67- struct fc_rport * rport , * found = NULL ;
66+ struct fc_rport * rport ;
6867 struct fc_rport_priv * rdata ;
69- int disc_found = 0 ;
7068
7169 list_for_each_entry (rdata , & disc -> rports , peers ) {
7270 rport = PRIV_TO_RPORT (rdata );
73- if (rport -> port_id == port_id ) {
74- disc_found = 1 ;
75- found = rport ;
76- break ;
77- }
71+ if (rport -> port_id == port_id )
72+ return rdata ;
7873 }
79-
80- if (!disc_found )
81- found = NULL ;
82-
83- return found ;
74+ return NULL ;
8475}
8576
8677/**
@@ -93,21 +84,18 @@ struct fc_rport *fc_disc_lookup_rport(const struct fc_lport *lport,
9384void fc_disc_stop_rports (struct fc_disc * disc )
9485{
9586 struct fc_lport * lport ;
96- struct fc_rport * rport ;
9787 struct fc_rport_priv * rdata , * next ;
9888
9989 lport = disc -> lport ;
10090
10191 mutex_lock (& disc -> disc_mutex );
10292 list_for_each_entry_safe (rdata , next , & disc -> rports , peers ) {
103- rport = PRIV_TO_RPORT (rdata );
10493 list_del (& rdata -> peers );
105- lport -> tt .rport_logoff (rport );
94+ lport -> tt .rport_logoff (rdata );
10695 }
10796
10897 list_for_each_entry_safe (rdata , next , & disc -> rogue_rports , peers ) {
109- rport = PRIV_TO_RPORT (rdata );
110- lport -> tt .rport_logoff (rport );
98+ lport -> tt .rport_logoff (rdata );
11199 }
112100
113101 mutex_unlock (& disc -> disc_mutex );
@@ -116,18 +104,18 @@ void fc_disc_stop_rports(struct fc_disc *disc)
116104/**
117105 * fc_disc_rport_callback() - Event handler for rport events
118106 * @lport: The lport which is receiving the event
119- * @rport: The rport which the event has occured on
107+ * @rdata: private remote port data
120108 * @event: The event that occured
121109 *
122110 * Locking Note: The rport lock should not be held when calling
123111 * this function.
124112 */
125113static void fc_disc_rport_callback (struct fc_lport * lport ,
126- struct fc_rport * rport ,
114+ struct fc_rport_priv * rdata ,
127115 enum fc_rport_event event )
128116{
129- struct fc_rport_priv * rdata = rport -> dd_data ;
130117 struct fc_disc * disc = & lport -> disc ;
118+ struct fc_rport * rport = PRIV_TO_RPORT (rdata );
131119
132120 FC_DISC_DBG (disc , "Received a %d event for port (%6x)\n" , event ,
133121 rport -> port_id );
@@ -169,7 +157,6 @@ static void fc_disc_recv_rscn_req(struct fc_seq *sp, struct fc_frame *fp,
169157 struct fc_disc * disc )
170158{
171159 struct fc_lport * lport ;
172- struct fc_rport * rport ;
173160 struct fc_rport_priv * rdata ;
174161 struct fc_els_rscn * rp ;
175162 struct fc_els_rscn_page * pp ;
@@ -249,11 +236,10 @@ static void fc_disc_recv_rscn_req(struct fc_seq *sp, struct fc_frame *fp,
249236 redisc , lport -> state , disc -> pending );
250237 list_for_each_entry_safe (dp , next , & disc_ports , peers ) {
251238 list_del (& dp -> peers );
252- rport = lport -> tt .rport_lookup (lport , dp -> ids .port_id );
253- if (rport ) {
254- rdata = rport -> dd_data ;
239+ rdata = lport -> tt .rport_lookup (lport , dp -> ids .port_id );
240+ if (rdata ) {
255241 list_del (& rdata -> peers );
256- lport -> tt .rport_logoff (rport );
242+ lport -> tt .rport_logoff (rdata );
257243 }
258244 fc_disc_single (disc , dp );
259245 }
@@ -308,16 +294,14 @@ static void fc_disc_recv_req(struct fc_seq *sp, struct fc_frame *fp,
308294 */
309295static void fc_disc_restart (struct fc_disc * disc )
310296{
311- struct fc_rport * rport ;
312297 struct fc_rport_priv * rdata , * next ;
313298 struct fc_lport * lport = disc -> lport ;
314299
315300 FC_DISC_DBG (disc , "Restarting discovery\n" );
316301
317302 list_for_each_entry_safe (rdata , next , & disc -> rports , peers ) {
318- rport = PRIV_TO_RPORT (rdata );
319303 list_del (& rdata -> peers );
320- lport -> tt .rport_logoff (rport );
304+ lport -> tt .rport_logoff (rdata );
321305 }
322306
323307 disc -> requested = 1 ;
@@ -335,6 +319,7 @@ static void fc_disc_start(void (*disc_callback)(struct fc_lport *,
335319 enum fc_disc_event ),
336320 struct fc_lport * lport )
337321{
322+ struct fc_rport_priv * rdata ;
338323 struct fc_rport * rport ;
339324 struct fc_rport_identifiers ids ;
340325 struct fc_disc * disc = & lport -> disc ;
@@ -362,8 +347,9 @@ static void fc_disc_start(void (*disc_callback)(struct fc_lport *,
362347 * Handle point-to-point mode as a simple discovery
363348 * of the remote port. Yucky, yucky, yuck, yuck!
364349 */
365- rport = disc -> lport -> ptp_rp ;
366- if (rport ) {
350+ rdata = disc -> lport -> ptp_rp ;
351+ if (rdata ) {
352+ rport = PRIV_TO_RPORT (rdata );
367353 ids .port_id = rport -> port_id ;
368354 ids .port_name = rport -> port_name ;
369355 ids .node_name = rport -> node_name ;
@@ -418,45 +404,36 @@ static int fc_disc_new_target(struct fc_disc *disc,
418404 * assigned the same FCID. This should be rare.
419405 * Delete the old one and fall thru to re-create.
420406 */
421- fc_disc_del_target (disc , rport );
407+ rdata = rport -> dd_data ;
408+ list_del (& rdata -> peers );
409+ lport -> tt .rport_logoff (rdata );
422410 rport = NULL ;
423411 }
424412 }
425413 if (((ids -> port_name != -1 ) || (ids -> port_id != -1 )) &&
426414 ids -> port_id != fc_host_port_id (lport -> host ) &&
427415 ids -> port_name != lport -> wwpn ) {
428416 if (!rport ) {
429- rport = lport -> tt .rport_lookup (lport , ids -> port_id );
417+ rdata = lport -> tt .rport_lookup (lport , ids -> port_id );
430418 if (!rport ) {
431- rport = lport -> tt .rport_create (lport , ids );
419+ rdata = lport -> tt .rport_create (lport , ids );
432420 }
433- if (!rport )
421+ if (!rdata )
434422 error = - ENOMEM ;
423+ else
424+ rport = PRIV_TO_RPORT (rdata );
435425 }
436426 if (rport ) {
437427 rdata = rport -> dd_data ;
438428 rdata -> ops = & fc_disc_rport_ops ;
439429 rdata -> rp_state = RPORT_ST_INIT ;
440430 list_add_tail (& rdata -> peers , & disc -> rogue_rports );
441- lport -> tt .rport_login (rport );
431+ lport -> tt .rport_login (rdata );
442432 }
443433 }
444434 return error ;
445435}
446436
447- /**
448- * fc_disc_del_target() - Delete a target
449- * @disc: FC discovery context
450- * @rport: The remote port to be removed
451- */
452- static void fc_disc_del_target (struct fc_disc * disc , struct fc_rport * rport )
453- {
454- struct fc_lport * lport = disc -> lport ;
455- struct fc_rport_priv * rdata = rport -> dd_data ;
456- list_del (& rdata -> peers );
457- lport -> tt .rport_logoff (rport );
458- }
459-
460437/**
461438 * fc_disc_done() - Discovery has been completed
462439 * @disc: FC discovery context
@@ -573,7 +550,6 @@ static int fc_disc_gpn_ft_parse(struct fc_disc *disc, void *buf, size_t len)
573550 size_t tlen ;
574551 int error = 0 ;
575552 struct fc_rport_identifiers ids ;
576- struct fc_rport * rport ;
577553 struct fc_rport_priv * rdata ;
578554
579555 lport = disc -> lport ;
@@ -622,14 +598,13 @@ static int fc_disc_gpn_ft_parse(struct fc_disc *disc, void *buf, size_t len)
622598
623599 if (ids .port_id != fc_host_port_id (lport -> host ) &&
624600 ids .port_name != lport -> wwpn ) {
625- rport = lport -> tt .rport_create (lport , & ids );
626- if (rport ) {
627- rdata = rport -> dd_data ;
601+ rdata = lport -> tt .rport_create (lport , & ids );
602+ if (rdata ) {
628603 rdata -> ops = & fc_disc_rport_ops ;
629604 rdata -> local_port = lport ;
630605 list_add_tail (& rdata -> peers ,
631606 & disc -> rogue_rports );
632- lport -> tt .rport_login (rport );
607+ lport -> tt .rport_login (rdata );
633608 } else
634609 printk (KERN_WARNING "libfc: Failed to allocate "
635610 "memory for the newly discovered port "
@@ -766,21 +741,19 @@ static void fc_disc_gpn_ft_resp(struct fc_seq *sp, struct fc_frame *fp,
766741static void fc_disc_single (struct fc_disc * disc , struct fc_disc_port * dp )
767742{
768743 struct fc_lport * lport ;
769- struct fc_rport * new_rport ;
770744 struct fc_rport_priv * rdata ;
771745
772746 lport = disc -> lport ;
773747
774748 if (dp -> ids .port_id == fc_host_port_id (lport -> host ))
775749 goto out ;
776750
777- new_rport = lport -> tt .rport_create (lport , & dp -> ids );
778- if (new_rport ) {
779- rdata = new_rport -> dd_data ;
751+ rdata = lport -> tt .rport_create (lport , & dp -> ids );
752+ if (rdata ) {
780753 rdata -> ops = & fc_disc_rport_ops ;
781754 kfree (dp );
782755 list_add_tail (& rdata -> peers , & disc -> rogue_rports );
783- lport -> tt .rport_login (new_rport );
756+ lport -> tt .rport_login (rdata );
784757 }
785758 return ;
786759out :
0 commit comments