Lines Matching refs:disc
51 static void fc_disc_stop_rports(struct fc_disc *disc) in fc_disc_stop_rports() argument
55 lockdep_assert_held(&disc->disc_mutex); in fc_disc_stop_rports()
57 list_for_each_entry(rdata, &disc->rports, peers) { in fc_disc_stop_rports()
70 static void fc_disc_recv_rscn_req(struct fc_disc *disc, struct fc_frame *fp) in fc_disc_recv_rscn_req() argument
82 lockdep_assert_held(&disc->disc_mutex); in fc_disc_recv_rscn_req()
84 lport = fc_disc_lport(disc); in fc_disc_recv_rscn_req()
86 FC_DISC_DBG(disc, "Received an RSCN event\n"); in fc_disc_recv_rscn_req()
117 FC_DISC_DBG(disc, "Port address format for port " in fc_disc_recv_rscn_req()
132 FC_DISC_DBG(disc, "Address format is (%d)\n", fmt); in fc_disc_recv_rscn_req()
152 FC_DISC_DBG(disc, "RSCN received: rediscovering\n"); in fc_disc_recv_rscn_req()
153 fc_disc_restart(disc); in fc_disc_recv_rscn_req()
155 FC_DISC_DBG(disc, "RSCN received: not rediscovering. " in fc_disc_recv_rscn_req()
157 redisc, lport->state, disc->pending); in fc_disc_recv_rscn_req()
162 FC_DISC_DBG(disc, "Received a bad RSCN frame\n"); in fc_disc_recv_rscn_req()
181 struct fc_disc *disc = &lport->disc; in fc_disc_recv_req() local
186 mutex_lock(&disc->disc_mutex); in fc_disc_recv_req()
187 fc_disc_recv_rscn_req(disc, fp); in fc_disc_recv_req()
188 mutex_unlock(&disc->disc_mutex); in fc_disc_recv_req()
191 FC_DISC_DBG(disc, "Received an unsupported request, " in fc_disc_recv_req()
202 static void fc_disc_restart(struct fc_disc *disc) in fc_disc_restart() argument
204 lockdep_assert_held(&disc->disc_mutex); in fc_disc_restart()
206 if (!disc->disc_callback) in fc_disc_restart()
209 FC_DISC_DBG(disc, "Restarting discovery\n"); in fc_disc_restart()
211 disc->requested = 1; in fc_disc_restart()
212 if (disc->pending) in fc_disc_restart()
220 disc->disc_id = (disc->disc_id + 2) | 1; in fc_disc_restart()
221 disc->retry_count = 0; in fc_disc_restart()
222 fc_disc_gpn_ft_req(disc); in fc_disc_restart()
234 struct fc_disc *disc = &lport->disc; in fc_disc_start() local
241 mutex_lock(&disc->disc_mutex); in fc_disc_start()
242 disc->disc_callback = disc_callback; in fc_disc_start()
243 fc_disc_restart(disc); in fc_disc_start()
244 mutex_unlock(&disc->disc_mutex); in fc_disc_start()
252 static void fc_disc_done(struct fc_disc *disc, enum fc_disc_event event) in fc_disc_done() argument
254 struct fc_lport *lport = fc_disc_lport(disc); in fc_disc_done()
257 lockdep_assert_held(&disc->disc_mutex); in fc_disc_done()
258 FC_DISC_DBG(disc, "Discovery complete\n"); in fc_disc_done()
260 disc->pending = 0; in fc_disc_done()
261 if (disc->requested) { in fc_disc_done()
262 fc_disc_restart(disc); in fc_disc_done()
275 list_for_each_entry(rdata, &disc->rports, peers) { in fc_disc_done()
279 if (rdata->disc_id == disc->disc_id) in fc_disc_done()
286 mutex_unlock(&disc->disc_mutex); in fc_disc_done()
287 disc->disc_callback(lport, event); in fc_disc_done()
288 mutex_lock(&disc->disc_mutex); in fc_disc_done()
296 static void fc_disc_error(struct fc_disc *disc, struct fc_frame *fp) in fc_disc_error() argument
298 struct fc_lport *lport = fc_disc_lport(disc); in fc_disc_error()
301 FC_DISC_DBG(disc, "Error %d, retries %d/%d\n", in fc_disc_error()
302 PTR_ERR_OR_ZERO(fp), disc->retry_count, in fc_disc_error()
310 if (disc->retry_count < FC_DISC_RETRY_LIMIT) { in fc_disc_error()
318 if (!disc->retry_count) in fc_disc_error()
321 disc->retry_count++; in fc_disc_error()
322 schedule_delayed_work(&disc->disc_work, delay); in fc_disc_error()
324 fc_disc_done(disc, DISC_EV_FAILED); in fc_disc_error()
331 disc->pending = 0; in fc_disc_error()
339 static void fc_disc_gpn_ft_req(struct fc_disc *disc) in fc_disc_gpn_ft_req() argument
342 struct fc_lport *lport = fc_disc_lport(disc); in fc_disc_gpn_ft_req()
344 lockdep_assert_held(&disc->disc_mutex); in fc_disc_gpn_ft_req()
348 disc->pending = 1; in fc_disc_gpn_ft_req()
349 disc->requested = 0; in fc_disc_gpn_ft_req()
351 disc->buf_len = 0; in fc_disc_gpn_ft_req()
352 disc->seq_count = 0; in fc_disc_gpn_ft_req()
362 disc, 3 * lport->r_a_tov)) in fc_disc_gpn_ft_req()
365 fc_disc_error(disc, NULL); in fc_disc_gpn_ft_req()
376 static int fc_disc_gpn_ft_parse(struct fc_disc *disc, void *buf, size_t len) in fc_disc_gpn_ft_parse() argument
387 lport = fc_disc_lport(disc); in fc_disc_gpn_ft_parse()
388 disc->seq_count++; in fc_disc_gpn_ft_parse()
396 tlen = disc->buf_len; in fc_disc_gpn_ft_parse()
397 disc->buf_len = 0; in fc_disc_gpn_ft_parse()
405 np = &disc->partial_buf; in fc_disc_gpn_ft_parse()
415 disc->buf_len = (unsigned char) plen; in fc_disc_gpn_ft_parse()
417 disc->buf_len = 0; in fc_disc_gpn_ft_parse()
436 rdata->disc_id = disc->disc_id; in fc_disc_gpn_ft_parse()
446 fc_disc_done(disc, DISC_EV_SUCCESS); in fc_disc_gpn_ft_parse()
460 if (np != &disc->partial_buf) { in fc_disc_gpn_ft_parse()
461 FC_DISC_DBG(disc, "Partial buffer remains " in fc_disc_gpn_ft_parse()
463 memcpy(&disc->partial_buf, np, len); in fc_disc_gpn_ft_parse()
465 disc->buf_len = (unsigned char) len; in fc_disc_gpn_ft_parse()
476 struct fc_disc *disc = container_of(work, in fc_disc_timeout() local
479 mutex_lock(&disc->disc_mutex); in fc_disc_timeout()
480 fc_disc_gpn_ft_req(disc); in fc_disc_timeout()
481 mutex_unlock(&disc->disc_mutex); in fc_disc_timeout()
496 struct fc_disc *disc = disc_arg; in fc_disc_gpn_ft_resp() local
504 mutex_lock(&disc->disc_mutex); in fc_disc_gpn_ft_resp()
505 FC_DISC_DBG(disc, "Received a GPN_FT response\n"); in fc_disc_gpn_ft_resp()
508 fc_disc_error(disc, fp); in fc_disc_gpn_ft_resp()
509 mutex_unlock(&disc->disc_mutex); in fc_disc_gpn_ft_resp()
517 if (fr_sof(fp) == FC_SOF_I3 && seq_cnt == 0 && disc->seq_count == 0) { in fc_disc_gpn_ft_resp()
520 FC_DISC_DBG(disc, "GPN_FT response too short, len %d\n", in fc_disc_gpn_ft_resp()
527 error = fc_disc_gpn_ft_parse(disc, cp + 1, len); in fc_disc_gpn_ft_resp()
529 FC_DISC_DBG(disc, "GPN_FT rejected reason %x exp %x " in fc_disc_gpn_ft_resp()
537 FC_DISC_DBG(disc, "GPN_FT unexpected response code " in fc_disc_gpn_ft_resp()
541 } else if (fr_sof(fp) == FC_SOF_N3 && seq_cnt == disc->seq_count) { in fc_disc_gpn_ft_resp()
542 error = fc_disc_gpn_ft_parse(disc, fh + 1, len); in fc_disc_gpn_ft_resp()
544 FC_DISC_DBG(disc, "GPN_FT unexpected frame - out of sequence? " in fc_disc_gpn_ft_resp()
546 seq_cnt, disc->seq_count, fr_sof(fp), fr_eof(fp)); in fc_disc_gpn_ft_resp()
550 fc_disc_error(disc, ERR_PTR(error)); in fc_disc_gpn_ft_resp()
552 fc_disc_done(disc, event); in fc_disc_gpn_ft_resp()
554 mutex_unlock(&disc->disc_mutex); in fc_disc_gpn_ft_resp()
571 struct fc_disc *disc; in fc_disc_gpn_id_resp() local
577 disc = &lport->disc; in fc_disc_gpn_id_resp()
582 mutex_lock(&disc->disc_mutex); in fc_disc_gpn_id_resp()
583 fc_disc_restart(disc); in fc_disc_gpn_id_resp()
584 mutex_unlock(&disc->disc_mutex); in fc_disc_gpn_id_resp()
601 FC_DISC_DBG(disc, "GPN_ID accepted. WWPN changed. " in fc_disc_gpn_id_resp()
606 mutex_lock(&lport->disc.disc_mutex); in fc_disc_gpn_id_resp()
608 mutex_unlock(&lport->disc.disc_mutex); in fc_disc_gpn_id_resp()
610 new_rdata->disc_id = disc->disc_id; in fc_disc_gpn_id_resp()
615 rdata->disc_id = disc->disc_id; in fc_disc_gpn_id_resp()
619 FC_DISC_DBG(disc, "GPN_ID rejected reason %x exp %x\n", in fc_disc_gpn_id_resp()
623 FC_DISC_DBG(disc, "GPN_ID unexpected response code %x\n", in fc_disc_gpn_id_resp()
626 mutex_lock(&disc->disc_mutex); in fc_disc_gpn_id_resp()
627 fc_disc_restart(disc); in fc_disc_gpn_id_resp()
628 mutex_unlock(&disc->disc_mutex); in fc_disc_gpn_id_resp()
648 lockdep_assert_held(&lport->disc.disc_mutex); in fc_disc_gpn_id_req()
670 lockdep_assert_held(&lport->disc.disc_mutex); in fc_disc_single()
685 struct fc_disc *disc = &lport->disc; in fc_disc_stop() local
687 if (disc->pending) in fc_disc_stop()
688 cancel_delayed_work_sync(&disc->disc_work); in fc_disc_stop()
689 mutex_lock(&disc->disc_mutex); in fc_disc_stop()
690 fc_disc_stop_rports(disc); in fc_disc_stop()
691 mutex_unlock(&disc->disc_mutex); in fc_disc_stop()
714 struct fc_disc *disc; in fc_disc_config() local
728 disc = &lport->disc; in fc_disc_config()
730 disc->priv = priv; in fc_disc_config()
740 struct fc_disc *disc = &lport->disc; in fc_disc_init() local
742 INIT_DELAYED_WORK(&disc->disc_work, fc_disc_timeout); in fc_disc_init()
743 mutex_init(&disc->disc_mutex); in fc_disc_init()
744 INIT_LIST_HEAD(&disc->rports); in fc_disc_init()