Lines Matching refs:ep
247 static inline void fc_exch_hold(struct fc_exch *ep) in fc_exch_hold() argument
249 atomic_inc(&ep->ex_refcnt); in fc_exch_hold()
262 static void fc_exch_setup_hdr(struct fc_exch *ep, struct fc_frame *fp, in fc_exch_setup_hdr() argument
268 fr_sof(fp) = ep->class; in fc_exch_setup_hdr()
269 if (ep->seq.cnt) in fc_exch_setup_hdr()
270 fr_sof(fp) = fc_sof_normal(ep->class); in fc_exch_setup_hdr()
274 if (fc_sof_needs_ack((enum fc_sof)ep->class)) in fc_exch_setup_hdr()
298 fh->fh_ox_id = htons(ep->oxid); in fc_exch_setup_hdr()
299 fh->fh_rx_id = htons(ep->rxid); in fc_exch_setup_hdr()
300 fh->fh_seq_id = ep->seq.id; in fc_exch_setup_hdr()
301 fh->fh_seq_cnt = htons(ep->seq.cnt); in fc_exch_setup_hdr()
311 static void fc_exch_release(struct fc_exch *ep) in fc_exch_release() argument
315 if (atomic_dec_and_test(&ep->ex_refcnt)) { in fc_exch_release()
316 mp = ep->em; in fc_exch_release()
317 if (ep->destructor) in fc_exch_release()
318 ep->destructor(&ep->seq, ep->arg); in fc_exch_release()
319 WARN_ON(!(ep->esb_stat & ESB_ST_COMPLETE)); in fc_exch_release()
320 mempool_free(ep, mp->ep_pool); in fc_exch_release()
328 static inline void fc_exch_timer_cancel(struct fc_exch *ep) in fc_exch_timer_cancel() argument
330 if (cancel_delayed_work(&ep->timeout_work)) { in fc_exch_timer_cancel()
331 FC_EXCH_DBG(ep, "Exchange timer canceled\n"); in fc_exch_timer_cancel()
332 atomic_dec(&ep->ex_refcnt); /* drop hold for timer */ in fc_exch_timer_cancel()
345 static inline void fc_exch_timer_set_locked(struct fc_exch *ep, in fc_exch_timer_set_locked() argument
348 if (ep->state & (FC_EX_RST_CLEANUP | FC_EX_DONE)) in fc_exch_timer_set_locked()
351 FC_EXCH_DBG(ep, "Exchange timer armed : %d msecs\n", timer_msec); in fc_exch_timer_set_locked()
353 fc_exch_hold(ep); /* hold for timer */ in fc_exch_timer_set_locked()
354 if (!queue_delayed_work(fc_exch_workqueue, &ep->timeout_work, in fc_exch_timer_set_locked()
356 FC_EXCH_DBG(ep, "Exchange already queued\n"); in fc_exch_timer_set_locked()
357 fc_exch_release(ep); in fc_exch_timer_set_locked()
366 static void fc_exch_timer_set(struct fc_exch *ep, unsigned int timer_msec) in fc_exch_timer_set() argument
368 spin_lock_bh(&ep->ex_lock); in fc_exch_timer_set()
369 fc_exch_timer_set_locked(ep, timer_msec); in fc_exch_timer_set()
370 spin_unlock_bh(&ep->ex_lock); in fc_exch_timer_set()
379 static int fc_exch_done_locked(struct fc_exch *ep) in fc_exch_done_locked() argument
389 if (ep->state & FC_EX_DONE) in fc_exch_done_locked()
391 ep->esb_stat |= ESB_ST_COMPLETE; in fc_exch_done_locked()
393 if (!(ep->esb_stat & ESB_ST_REC_QUAL)) { in fc_exch_done_locked()
394 ep->state |= FC_EX_DONE; in fc_exch_done_locked()
395 fc_exch_timer_cancel(ep); in fc_exch_done_locked()
426 struct fc_exch *ep) in fc_exch_ptr_set() argument
428 ((struct fc_exch **)(pool + 1))[index] = ep; in fc_exch_ptr_set()
435 static void fc_exch_delete(struct fc_exch *ep) in fc_exch_delete() argument
440 pool = ep->pool; in fc_exch_delete()
446 index = (ep->xid - ep->em->min_xid) >> fc_cpu_order; in fc_exch_delete()
447 if (!(ep->state & FC_EX_QUARANTINE)) { in fc_exch_delete()
458 list_del(&ep->ex_list); in fc_exch_delete()
460 fc_exch_release(ep); /* drop hold for exch in mp */ in fc_exch_delete()
466 struct fc_exch *ep; in fc_seq_send_locked() local
472 ep = fc_seq_exch(sp); in fc_seq_send_locked()
474 if (ep->esb_stat & (ESB_ST_COMPLETE | ESB_ST_ABNORMAL)) { in fc_seq_send_locked()
479 WARN_ON(!(ep->esb_stat & ESB_ST_SEQ_INIT)); in fc_seq_send_locked()
482 fc_exch_setup_hdr(ep, fp, f_ctl); in fc_seq_send_locked()
483 fr_encaps(fp) = ep->encaps; in fc_seq_send_locked()
509 ep->f_ctl = f_ctl & ~FC_FC_FIRST_SEQ; /* not first seq */ in fc_seq_send_locked()
511 ep->esb_stat &= ~ESB_ST_SEQ_INIT; in fc_seq_send_locked()
527 struct fc_exch *ep; in fc_seq_send() local
529 ep = fc_seq_exch(sp); in fc_seq_send()
530 spin_lock_bh(&ep->ex_lock); in fc_seq_send()
532 spin_unlock_bh(&ep->ex_lock); in fc_seq_send()
546 static struct fc_seq *fc_seq_alloc(struct fc_exch *ep, u8 seq_id) in fc_seq_alloc() argument
550 sp = &ep->seq; in fc_seq_alloc()
564 struct fc_exch *ep = fc_seq_exch(sp); in fc_seq_start_next_locked() local
566 sp = fc_seq_alloc(ep, ep->seq_id++); in fc_seq_start_next_locked()
567 FC_EXCH_DBG(ep, "f_ctl %6x seq %2x\n", in fc_seq_start_next_locked()
568 ep->f_ctl, sp->id); in fc_seq_start_next_locked()
579 struct fc_exch *ep = fc_seq_exch(sp); in fc_seq_start_next() local
581 spin_lock_bh(&ep->ex_lock); in fc_seq_start_next()
583 spin_unlock_bh(&ep->ex_lock); in fc_seq_start_next()
598 struct fc_exch *ep = fc_seq_exch(sp); in fc_seq_set_resp() local
601 spin_lock_bh(&ep->ex_lock); in fc_seq_set_resp()
602 while (ep->resp_active && ep->resp_task != current) { in fc_seq_set_resp()
603 prepare_to_wait(&ep->resp_wq, &wait, TASK_UNINTERRUPTIBLE); in fc_seq_set_resp()
604 spin_unlock_bh(&ep->ex_lock); in fc_seq_set_resp()
608 spin_lock_bh(&ep->ex_lock); in fc_seq_set_resp()
610 finish_wait(&ep->resp_wq, &wait); in fc_seq_set_resp()
611 ep->resp = resp; in fc_seq_set_resp()
612 ep->arg = arg; in fc_seq_set_resp()
613 spin_unlock_bh(&ep->ex_lock); in fc_seq_set_resp()
633 static int fc_exch_abort_locked(struct fc_exch *ep, in fc_exch_abort_locked() argument
640 FC_EXCH_DBG(ep, "exch: abort, time %d msecs\n", timer_msec); in fc_exch_abort_locked()
641 if (ep->esb_stat & (ESB_ST_COMPLETE | ESB_ST_ABNORMAL) || in fc_exch_abort_locked()
642 ep->state & (FC_EX_DONE | FC_EX_RST_CLEANUP)) { in fc_exch_abort_locked()
643 FC_EXCH_DBG(ep, "exch: already completed esb %x state %x\n", in fc_exch_abort_locked()
644 ep->esb_stat, ep->state); in fc_exch_abort_locked()
651 sp = fc_seq_start_next_locked(&ep->seq); in fc_exch_abort_locked()
656 fc_exch_timer_set_locked(ep, timer_msec); in fc_exch_abort_locked()
658 if (ep->sid) { in fc_exch_abort_locked()
662 fp = fc_frame_alloc(ep->lp, 0); in fc_exch_abort_locked()
664 ep->esb_stat |= ESB_ST_SEQ_INIT; in fc_exch_abort_locked()
665 fc_fill_fc_hdr(fp, FC_RCTL_BA_ABTS, ep->did, ep->sid, in fc_exch_abort_locked()
668 error = fc_seq_send_locked(ep->lp, sp, fp); in fc_exch_abort_locked()
679 ep->esb_stat |= ESB_ST_ABNORMAL; in fc_exch_abort_locked()
694 struct fc_exch *ep; in fc_seq_exch_abort() local
697 ep = fc_seq_exch(req_sp); in fc_seq_exch_abort()
698 spin_lock_bh(&ep->ex_lock); in fc_seq_exch_abort()
699 error = fc_exch_abort_locked(ep, timer_msec); in fc_seq_exch_abort()
700 spin_unlock_bh(&ep->ex_lock); in fc_seq_exch_abort()
729 static bool fc_invoke_resp(struct fc_exch *ep, struct fc_seq *sp, in fc_invoke_resp() argument
736 spin_lock_bh(&ep->ex_lock); in fc_invoke_resp()
737 ep->resp_active++; in fc_invoke_resp()
738 if (ep->resp_task != current) in fc_invoke_resp()
739 ep->resp_task = !ep->resp_task ? current : NULL; in fc_invoke_resp()
740 resp = ep->resp; in fc_invoke_resp()
741 arg = ep->arg; in fc_invoke_resp()
742 spin_unlock_bh(&ep->ex_lock); in fc_invoke_resp()
749 spin_lock_bh(&ep->ex_lock); in fc_invoke_resp()
750 if (--ep->resp_active == 0) in fc_invoke_resp()
751 ep->resp_task = NULL; in fc_invoke_resp()
752 spin_unlock_bh(&ep->ex_lock); in fc_invoke_resp()
754 if (ep->resp_active == 0) in fc_invoke_resp()
755 wake_up(&ep->resp_wq); in fc_invoke_resp()
766 struct fc_exch *ep = container_of(work, struct fc_exch, in fc_exch_timeout() local
768 struct fc_seq *sp = &ep->seq; in fc_exch_timeout()
772 FC_EXCH_DBG(ep, "Exchange timed out state %x\n", ep->state); in fc_exch_timeout()
774 spin_lock_bh(&ep->ex_lock); in fc_exch_timeout()
775 if (ep->state & (FC_EX_RST_CLEANUP | FC_EX_DONE)) in fc_exch_timeout()
778 e_stat = ep->esb_stat; in fc_exch_timeout()
780 ep->esb_stat = e_stat & ~ESB_ST_REC_QUAL; in fc_exch_timeout()
781 spin_unlock_bh(&ep->ex_lock); in fc_exch_timeout()
783 fc_exch_rrq(ep); in fc_exch_timeout()
787 rc = fc_exch_done_locked(ep); in fc_exch_timeout()
788 spin_unlock_bh(&ep->ex_lock); in fc_exch_timeout()
790 fc_exch_delete(ep); in fc_exch_timeout()
791 fc_invoke_resp(ep, sp, ERR_PTR(-FC_EX_TIMEOUT)); in fc_exch_timeout()
792 fc_seq_set_resp(sp, NULL, ep->arg); in fc_exch_timeout()
793 fc_seq_exch_abort(sp, 2 * ep->r_a_tov); in fc_exch_timeout()
797 spin_unlock_bh(&ep->ex_lock); in fc_exch_timeout()
802 fc_exch_release(ep); in fc_exch_timeout()
815 struct fc_exch *ep; in fc_exch_em_alloc() local
821 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC); in fc_exch_em_alloc()
822 if (!ep) { in fc_exch_em_alloc()
826 memset(ep, 0, sizeof(*ep)); in fc_exch_em_alloc()
857 fc_exch_hold(ep); /* hold for exch in mp */ in fc_exch_em_alloc()
858 spin_lock_init(&ep->ex_lock); in fc_exch_em_alloc()
864 spin_lock_bh(&ep->ex_lock); in fc_exch_em_alloc()
866 fc_exch_ptr_set(pool, index, ep); in fc_exch_em_alloc()
867 list_add_tail(&ep->ex_list, &pool->ex_list); in fc_exch_em_alloc()
868 fc_seq_alloc(ep, ep->seq_id++); in fc_exch_em_alloc()
875 ep->oxid = ep->xid = (index << fc_cpu_order | cpu) + mp->min_xid; in fc_exch_em_alloc()
876 ep->em = mp; in fc_exch_em_alloc()
877 ep->pool = pool; in fc_exch_em_alloc()
878 ep->lp = lport; in fc_exch_em_alloc()
879 ep->f_ctl = FC_FC_FIRST_SEQ; /* next seq is first seq */ in fc_exch_em_alloc()
880 ep->rxid = FC_XID_UNKNOWN; in fc_exch_em_alloc()
881 ep->class = mp->class; in fc_exch_em_alloc()
882 ep->resp_active = 0; in fc_exch_em_alloc()
883 init_waitqueue_head(&ep->resp_wq); in fc_exch_em_alloc()
884 INIT_DELAYED_WORK(&ep->timeout_work, fc_exch_timeout); in fc_exch_em_alloc()
886 return ep; in fc_exch_em_alloc()
890 mempool_free(ep, mp->ep_pool); in fc_exch_em_alloc()
909 struct fc_exch *ep; in fc_exch_alloc() local
913 ep = fc_exch_em_alloc(lport, ema->mp); in fc_exch_alloc()
914 if (ep) in fc_exch_alloc()
915 return ep; in fc_exch_alloc()
930 struct fc_exch *ep = NULL; in fc_exch_find() local
945 ep = fc_exch_ptr_get(pool, (xid - mp->min_xid) >> fc_cpu_order); in fc_exch_find()
946 if (ep == &fc_quarantine_exch) { in fc_exch_find()
948 ep = NULL; in fc_exch_find()
950 if (ep) { in fc_exch_find()
951 WARN_ON(ep->xid != xid); in fc_exch_find()
952 fc_exch_hold(ep); in fc_exch_find()
956 return ep; in fc_exch_find()
969 struct fc_exch *ep = fc_seq_exch(sp); in fc_exch_done() local
972 spin_lock_bh(&ep->ex_lock); in fc_exch_done()
973 rc = fc_exch_done_locked(ep); in fc_exch_done()
974 spin_unlock_bh(&ep->ex_lock); in fc_exch_done()
976 fc_seq_set_resp(sp, NULL, ep->arg); in fc_exch_done()
978 fc_exch_delete(ep); in fc_exch_done()
994 struct fc_exch *ep; in fc_exch_resp() local
997 ep = fc_exch_alloc(lport, fp); in fc_exch_resp()
998 if (ep) { in fc_exch_resp()
999 ep->class = fc_frame_class(fp); in fc_exch_resp()
1004 ep->f_ctl |= FC_FC_EX_CTX; /* we're responding */ in fc_exch_resp()
1005 ep->f_ctl &= ~FC_FC_FIRST_SEQ; /* not new */ in fc_exch_resp()
1007 ep->sid = ntoh24(fh->fh_d_id); in fc_exch_resp()
1008 ep->did = ntoh24(fh->fh_s_id); in fc_exch_resp()
1009 ep->oid = ep->did; in fc_exch_resp()
1016 ep->rxid = ep->xid; in fc_exch_resp()
1017 ep->oxid = ntohs(fh->fh_ox_id); in fc_exch_resp()
1018 ep->esb_stat |= ESB_ST_RESP | ESB_ST_SEQ_INIT; in fc_exch_resp()
1020 ep->esb_stat &= ~ESB_ST_SEQ_INIT; in fc_exch_resp()
1022 fc_exch_hold(ep); /* hold for caller */ in fc_exch_resp()
1023 spin_unlock_bh(&ep->ex_lock); /* lock from fc_exch_alloc */ in fc_exch_resp()
1025 return ep; in fc_exch_resp()
1043 struct fc_exch *ep = NULL; in fc_seq_lookup_recip() local
1057 ep = fc_exch_find(mp, xid); in fc_seq_lookup_recip()
1058 if (!ep) { in fc_seq_lookup_recip()
1063 if (ep->rxid == FC_XID_UNKNOWN) in fc_seq_lookup_recip()
1064 ep->rxid = ntohs(fh->fh_rx_id); in fc_seq_lookup_recip()
1065 else if (ep->rxid != ntohs(fh->fh_rx_id)) { in fc_seq_lookup_recip()
1086 ep = fc_exch_find(mp, xid); in fc_seq_lookup_recip()
1088 if (ep) { in fc_seq_lookup_recip()
1093 ep = fc_exch_resp(lport, mp, fp); in fc_seq_lookup_recip()
1094 if (!ep) { in fc_seq_lookup_recip()
1098 xid = ep->xid; /* get our XID */ in fc_seq_lookup_recip()
1099 } else if (!ep) { in fc_seq_lookup_recip()
1106 spin_lock_bh(&ep->ex_lock); in fc_seq_lookup_recip()
1112 sp = &ep->seq; in fc_seq_lookup_recip()
1116 sp = &ep->seq; in fc_seq_lookup_recip()
1137 spin_unlock_bh(&ep->ex_lock); in fc_seq_lookup_recip()
1145 WARN_ON(ep != fc_seq_exch(sp)); in fc_seq_lookup_recip()
1148 ep->esb_stat |= ESB_ST_SEQ_INIT; in fc_seq_lookup_recip()
1149 spin_unlock_bh(&ep->ex_lock); in fc_seq_lookup_recip()
1155 fc_exch_done(&ep->seq); in fc_seq_lookup_recip()
1156 fc_exch_release(ep); /* hold from fc_exch_find/fc_exch_resp */ in fc_seq_lookup_recip()
1172 struct fc_exch *ep; in fc_seq_lookup_orig() local
1180 ep = fc_exch_find(mp, xid); in fc_seq_lookup_orig()
1181 if (!ep) in fc_seq_lookup_orig()
1183 if (ep->seq.id == fh->fh_seq_id) { in fc_seq_lookup_orig()
1187 sp = &ep->seq; in fc_seq_lookup_orig()
1189 ep->rxid == FC_XID_UNKNOWN) { in fc_seq_lookup_orig()
1190 ep->rxid = ntohs(fh->fh_rx_id); in fc_seq_lookup_orig()
1193 fc_exch_release(ep); in fc_seq_lookup_orig()
1205 static void fc_exch_set_addr(struct fc_exch *ep, in fc_exch_set_addr() argument
1208 ep->oid = orig_id; in fc_exch_set_addr()
1209 if (ep->esb_stat & ESB_ST_RESP) { in fc_exch_set_addr()
1210 ep->sid = resp_id; in fc_exch_set_addr()
1211 ep->did = orig_id; in fc_exch_set_addr()
1213 ep->sid = orig_id; in fc_exch_set_addr()
1214 ep->did = resp_id; in fc_exch_set_addr()
1260 struct fc_exch *ep = fc_seq_exch(sp); in fc_seq_send_last() local
1263 f_ctl |= ep->f_ctl; in fc_seq_send_last()
1264 fc_fill_fc_hdr(fp, rctl, ep->did, ep->sid, fh_type, f_ctl, 0); in fc_seq_send_last()
1265 fc_seq_send_locked(ep->lp, sp, fp); in fc_seq_send_last()
1280 struct fc_exch *ep = fc_seq_exch(sp); in fc_seq_send_ack() local
1281 struct fc_lport *lport = ep->lp; in fc_seq_send_ack()
1290 FC_EXCH_DBG(ep, "Drop ACK request, out of memory\n"); in fc_seq_send_ack()
1314 fc_exch_setup_hdr(ep, fp, f_ctl); in fc_seq_send_ack()
1411 static void fc_exch_recv_abts(struct fc_exch *ep, struct fc_frame *rx_fp) in fc_exch_recv_abts() argument
1418 if (!ep) in fc_exch_recv_abts()
1421 FC_EXCH_DBG(ep, "exch: ABTS received\n"); in fc_exch_recv_abts()
1422 fp = fc_frame_alloc(ep->lp, sizeof(*ap)); in fc_exch_recv_abts()
1424 FC_EXCH_DBG(ep, "Drop ABTS request, out of memory\n"); in fc_exch_recv_abts()
1428 spin_lock_bh(&ep->ex_lock); in fc_exch_recv_abts()
1429 if (ep->esb_stat & ESB_ST_COMPLETE) { in fc_exch_recv_abts()
1430 spin_unlock_bh(&ep->ex_lock); in fc_exch_recv_abts()
1431 FC_EXCH_DBG(ep, "exch: ABTS rejected, exchange complete\n"); in fc_exch_recv_abts()
1435 if (!(ep->esb_stat & ESB_ST_REC_QUAL)) { in fc_exch_recv_abts()
1436 ep->esb_stat |= ESB_ST_REC_QUAL; in fc_exch_recv_abts()
1437 fc_exch_hold(ep); /* hold for REC_QUAL */ in fc_exch_recv_abts()
1439 fc_exch_timer_set_locked(ep, ep->r_a_tov); in fc_exch_recv_abts()
1443 sp = &ep->seq; in fc_exch_recv_abts()
1453 ep->esb_stat |= ESB_ST_ABNORMAL; in fc_exch_recv_abts()
1454 spin_unlock_bh(&ep->ex_lock); in fc_exch_recv_abts()
1514 struct fc_exch *ep = NULL; in fc_exch_recv_req() local
1539 ep = fc_seq_exch(sp); in fc_exch_recv_req()
1541 ep->encaps = fr_encaps(fp); in fc_exch_recv_req()
1554 if (!fc_invoke_resp(ep, sp, fp)) in fc_exch_recv_req()
1556 fc_exch_release(ep); /* release from lookup */ in fc_exch_recv_req()
1575 struct fc_exch *ep; in fc_exch_recv_seq_resp() local
1580 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id)); in fc_exch_recv_seq_resp()
1581 if (!ep) { in fc_exch_recv_seq_resp()
1585 if (ep->esb_stat & ESB_ST_COMPLETE) { in fc_exch_recv_seq_resp()
1589 if (ep->rxid == FC_XID_UNKNOWN) in fc_exch_recv_seq_resp()
1590 ep->rxid = ntohs(fh->fh_rx_id); in fc_exch_recv_seq_resp()
1591 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) { in fc_exch_recv_seq_resp()
1595 if (ep->did != ntoh24(fh->fh_s_id) && in fc_exch_recv_seq_resp()
1596 ep->did != FC_FID_FLOGI) { in fc_exch_recv_seq_resp()
1601 sp = &ep->seq; in fc_exch_recv_seq_resp()
1610 spin_lock_bh(&ep->ex_lock); in fc_exch_recv_seq_resp()
1612 ep->esb_stat |= ESB_ST_SEQ_INIT; in fc_exch_recv_seq_resp()
1613 spin_unlock_bh(&ep->ex_lock); in fc_exch_recv_seq_resp()
1621 spin_lock_bh(&ep->ex_lock); in fc_exch_recv_seq_resp()
1622 rc = fc_exch_done_locked(ep); in fc_exch_recv_seq_resp()
1623 WARN_ON(fc_seq_exch(sp) != ep); in fc_exch_recv_seq_resp()
1624 spin_unlock_bh(&ep->ex_lock); in fc_exch_recv_seq_resp()
1626 fc_exch_delete(ep); in fc_exch_recv_seq_resp()
1628 FC_EXCH_DBG(ep, "ep is completed already," in fc_exch_recv_seq_resp()
1647 if (!fc_invoke_resp(ep, sp, fp)) in fc_exch_recv_seq_resp()
1651 fc_exch_release(ep); in fc_exch_recv_seq_resp()
1654 fc_exch_release(ep); in fc_exch_recv_seq_resp()
1687 static void fc_exch_abts_resp(struct fc_exch *ep, struct fc_frame *fp) in fc_exch_abts_resp() argument
1697 FC_EXCH_DBG(ep, "exch: BLS rctl %x - %s\n", fh->fh_r_ctl, in fc_exch_abts_resp()
1700 if (cancel_delayed_work_sync(&ep->timeout_work)) { in fc_exch_abts_resp()
1701 FC_EXCH_DBG(ep, "Exchange timer canceled due to ABTS response\n"); in fc_exch_abts_resp()
1702 fc_exch_release(ep); /* release from pending timer hold */ in fc_exch_abts_resp()
1706 spin_lock_bh(&ep->ex_lock); in fc_exch_abts_resp()
1720 if ((ep->esb_stat & ESB_ST_REC_QUAL) == 0 && in fc_exch_abts_resp()
1722 ap->ba_seq_id == ep->seq_id) && low != high) { in fc_exch_abts_resp()
1723 ep->esb_stat |= ESB_ST_REC_QUAL; in fc_exch_abts_resp()
1724 fc_exch_hold(ep); /* hold for recovery qualifier */ in fc_exch_abts_resp()
1737 sp = &ep->seq; in fc_exch_abts_resp()
1741 if (ep->fh_type != FC_TYPE_FCP && in fc_exch_abts_resp()
1743 rc = fc_exch_done_locked(ep); in fc_exch_abts_resp()
1744 spin_unlock_bh(&ep->ex_lock); in fc_exch_abts_resp()
1746 fc_exch_hold(ep); in fc_exch_abts_resp()
1748 fc_exch_delete(ep); in fc_exch_abts_resp()
1749 if (!fc_invoke_resp(ep, sp, fp)) in fc_exch_abts_resp()
1752 fc_exch_timer_set(ep, ep->r_a_tov); in fc_exch_abts_resp()
1753 fc_exch_release(ep); in fc_exch_abts_resp()
1767 struct fc_exch *ep; in fc_exch_recv_bls() local
1774 ep = fc_exch_find(mp, (f_ctl & FC_FC_EX_CTX) ? in fc_exch_recv_bls()
1776 if (ep && (f_ctl & FC_FC_SEQ_INIT)) { in fc_exch_recv_bls()
1777 spin_lock_bh(&ep->ex_lock); in fc_exch_recv_bls()
1778 ep->esb_stat |= ESB_ST_SEQ_INIT; in fc_exch_recv_bls()
1779 spin_unlock_bh(&ep->ex_lock); in fc_exch_recv_bls()
1791 if (ep) in fc_exch_recv_bls()
1792 FC_EXCH_DBG(ep, "BLS rctl %x - %s received\n", in fc_exch_recv_bls()
1802 if (ep) in fc_exch_recv_bls()
1803 fc_exch_abts_resp(ep, fp); in fc_exch_recv_bls()
1808 if (ep) in fc_exch_recv_bls()
1809 fc_exch_recv_abts(ep, fp); in fc_exch_recv_bls()
1818 if (ep) in fc_exch_recv_bls()
1819 fc_exch_release(ep); /* release hold taken by fc_exch_find */ in fc_exch_recv_bls()
1891 static void fc_exch_reset(struct fc_exch *ep) in fc_exch_reset() argument
1896 spin_lock_bh(&ep->ex_lock); in fc_exch_reset()
1897 ep->state |= FC_EX_RST_CLEANUP; in fc_exch_reset()
1898 fc_exch_timer_cancel(ep); in fc_exch_reset()
1899 if (ep->esb_stat & ESB_ST_REC_QUAL) in fc_exch_reset()
1900 atomic_dec(&ep->ex_refcnt); /* drop hold for rec_qual */ in fc_exch_reset()
1901 ep->esb_stat &= ~ESB_ST_REC_QUAL; in fc_exch_reset()
1902 sp = &ep->seq; in fc_exch_reset()
1903 rc = fc_exch_done_locked(ep); in fc_exch_reset()
1904 spin_unlock_bh(&ep->ex_lock); in fc_exch_reset()
1906 fc_exch_hold(ep); in fc_exch_reset()
1909 fc_exch_delete(ep); in fc_exch_reset()
1911 FC_EXCH_DBG(ep, "ep is completed already," in fc_exch_reset()
1916 fc_invoke_resp(ep, sp, ERR_PTR(-FC_EX_CLOSED)); in fc_exch_reset()
1918 fc_seq_set_resp(sp, NULL, ep->arg); in fc_exch_reset()
1919 fc_exch_release(ep); in fc_exch_reset()
1938 struct fc_exch *ep; in fc_exch_pool_reset() local
1943 list_for_each_entry_safe(ep, next, &pool->ex_list, ex_list) { in fc_exch_pool_reset()
1944 if ((lport == ep->lp) && in fc_exch_pool_reset()
1945 (sid == 0 || sid == ep->sid) && in fc_exch_pool_reset()
1946 (did == 0 || did == ep->did)) { in fc_exch_pool_reset()
1947 fc_exch_hold(ep); in fc_exch_pool_reset()
1950 fc_exch_reset(ep); in fc_exch_pool_reset()
1952 fc_exch_release(ep); in fc_exch_pool_reset()
2020 struct fc_exch *ep; in fc_exch_els_rec() local
2048 ep = fc_exch_lookup(lport, xid); in fc_exch_els_rec()
2049 if (!ep) { in fc_exch_els_rec()
2055 FC_EXCH_DBG(ep, "REC request from %x: rxid %x oxid %x\n", in fc_exch_els_rec()
2057 if (ep->oid != sid || oxid != ep->oxid) in fc_exch_els_rec()
2059 if (rxid != FC_XID_UNKNOWN && rxid != ep->rxid) in fc_exch_els_rec()
2063 FC_EXCH_DBG(ep, "Drop REC request, out of memory\n"); in fc_exch_els_rec()
2072 acc->reca_rx_id = htons(ep->rxid); in fc_exch_els_rec()
2073 if (ep->sid == ep->oid) in fc_exch_els_rec()
2074 hton24(acc->reca_rfid, ep->did); in fc_exch_els_rec()
2076 hton24(acc->reca_rfid, ep->sid); in fc_exch_els_rec()
2077 acc->reca_fc4value = htonl(ep->seq.rec_data); in fc_exch_els_rec()
2078 acc->reca_e_stat = htonl(ep->esb_stat & (ESB_ST_RESP | in fc_exch_els_rec()
2084 fc_exch_release(ep); in fc_exch_els_rec()
2088 fc_exch_release(ep); in fc_exch_els_rec()
2183 struct fc_exch *ep; in fc_exch_seq_send() local
2189 ep = fc_exch_alloc(lport, fp); in fc_exch_seq_send()
2190 if (!ep) { in fc_exch_seq_send()
2194 ep->esb_stat |= ESB_ST_SEQ_INIT; in fc_exch_seq_send()
2196 fc_exch_set_addr(ep, ntoh24(fh->fh_s_id), ntoh24(fh->fh_d_id)); in fc_exch_seq_send()
2197 ep->resp = resp; in fc_exch_seq_send()
2198 ep->destructor = destructor; in fc_exch_seq_send()
2199 ep->arg = arg; in fc_exch_seq_send()
2200 ep->r_a_tov = lport->r_a_tov; in fc_exch_seq_send()
2201 ep->lp = lport; in fc_exch_seq_send()
2202 sp = &ep->seq; in fc_exch_seq_send()
2204 ep->fh_type = fh->fh_type; /* save for possbile timeout handling */ in fc_exch_seq_send()
2205 ep->f_ctl = ntoh24(fh->fh_f_ctl); in fc_exch_seq_send()
2206 fc_exch_setup_hdr(ep, fp, ep->f_ctl); in fc_exch_seq_send()
2209 if (ep->xid <= lport->lro_xid && fh->fh_r_ctl == FC_RCTL_DD_UNSOL_CMD) { in fc_exch_seq_send()
2211 fc_fcp_ddp_setup(fr_fsp(fp), ep->xid); in fc_exch_seq_send()
2218 fc_exch_timer_set_locked(ep, timer_msec); in fc_exch_seq_send()
2219 ep->f_ctl &= ~FC_FC_FIRST_SEQ; /* not first seq */ in fc_exch_seq_send()
2221 if (ep->f_ctl & FC_FC_SEQ_INIT) in fc_exch_seq_send()
2222 ep->esb_stat &= ~ESB_ST_SEQ_INIT; in fc_exch_seq_send()
2223 spin_unlock_bh(&ep->ex_lock); in fc_exch_seq_send()
2228 rc = fc_exch_done_locked(ep); in fc_exch_seq_send()
2229 spin_unlock_bh(&ep->ex_lock); in fc_exch_seq_send()
2231 fc_exch_delete(ep); in fc_exch_seq_send()
2243 static void fc_exch_rrq(struct fc_exch *ep) in fc_exch_rrq() argument
2250 lport = ep->lp; in fc_exch_rrq()
2259 hton24(rrq->rrq_s_id, ep->sid); in fc_exch_rrq()
2260 rrq->rrq_ox_id = htons(ep->oxid); in fc_exch_rrq()
2261 rrq->rrq_rx_id = htons(ep->rxid); in fc_exch_rrq()
2263 did = ep->did; in fc_exch_rrq()
2264 if (ep->esb_stat & ESB_ST_RESP) in fc_exch_rrq()
2265 did = ep->sid; in fc_exch_rrq()
2271 if (fc_exch_seq_send(lport, fp, fc_exch_rrq_resp, NULL, ep, in fc_exch_rrq()
2276 FC_EXCH_DBG(ep, "exch: RRQ send failed\n"); in fc_exch_rrq()
2277 spin_lock_bh(&ep->ex_lock); in fc_exch_rrq()
2278 if (ep->state & (FC_EX_RST_CLEANUP | FC_EX_DONE)) { in fc_exch_rrq()
2279 spin_unlock_bh(&ep->ex_lock); in fc_exch_rrq()
2281 fc_exch_release(ep); in fc_exch_rrq()
2284 ep->esb_stat |= ESB_ST_REC_QUAL; in fc_exch_rrq()
2285 fc_exch_timer_set_locked(ep, ep->r_a_tov); in fc_exch_rrq()
2286 spin_unlock_bh(&ep->ex_lock); in fc_exch_rrq()
2296 struct fc_exch *ep = NULL; /* request or subject exchange */ in fc_exch_els_rrq() local
2314 ep = fc_exch_lookup(lport, xid); in fc_exch_els_rrq()
2316 if (!ep) in fc_exch_els_rrq()
2318 spin_lock_bh(&ep->ex_lock); in fc_exch_els_rrq()
2319 FC_EXCH_DBG(ep, "RRQ request from %x: xid %x rxid %x oxid %x\n", in fc_exch_els_rrq()
2321 if (ep->oxid != ntohs(rp->rrq_ox_id)) in fc_exch_els_rrq()
2323 if (ep->rxid != ntohs(rp->rrq_rx_id) && in fc_exch_els_rrq()
2324 ep->rxid != FC_XID_UNKNOWN) in fc_exch_els_rrq()
2327 if (ep->sid != sid) in fc_exch_els_rrq()
2333 if (ep->esb_stat & ESB_ST_REC_QUAL) { in fc_exch_els_rrq()
2334 ep->esb_stat &= ~ESB_ST_REC_QUAL; in fc_exch_els_rrq()
2335 atomic_dec(&ep->ex_refcnt); /* drop hold for rec qual */ in fc_exch_els_rrq()
2337 if (ep->esb_stat & ESB_ST_COMPLETE) in fc_exch_els_rrq()
2338 fc_exch_timer_cancel(ep); in fc_exch_els_rrq()
2340 spin_unlock_bh(&ep->ex_lock); in fc_exch_els_rrq()
2349 spin_unlock_bh(&ep->ex_lock); in fc_exch_els_rrq()
2353 if (ep) in fc_exch_els_rrq()
2354 fc_exch_release(ep); /* drop hold from fc_exch_find */ in fc_exch_els_rrq()