aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Love <robert.w.love@intel.com>2009-11-03 14:45:47 -0500
committerJames Bottomley <James.Bottomley@suse.de>2009-12-04 13:00:53 -0500
commit1a7b75ae719754c77ccd4d18b0d258ae5db38a25 (patch)
tree4bcc283dda206e2358678e1e340b0bf539b782ac
parent2171c225f641c5402e4c47180d791a612278040e (diff)
[SCSI] libfc: Move non-common routines and prototypes out of libfc.h
This patch moves all non-common routines and function prototypes out of libfc.h and into the appropriate .c files. It makes these routines 'static' when necessary and removes any unnecessary EXPORT_SYMBOL statements. A result of moving the fc_exch_seq_send, fc_seq_els_rsp_send, fc_exch_alloc and fc_seq_start_next prototypes out of libfc.h is that they were no longer being imported into fc_exch.c when libfc.h was included. This caused errors where routines in fc_exch.c were looking for undefined symbols. To fix this this patch reorganizes fc_seq_alloc, fc_seq_start_next and fc_seq_start_next_locked. This move also made it so that fc_seq_start_next_locked did not need to be prototyped at the top of fc_exch.c. Signed-off-by: Robert Love <robert.w.love@intel.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
-rw-r--r--drivers/scsi/libfc/fc_exch.c329
-rw-r--r--include/scsi/libfc.h49
2 files changed, 177 insertions, 201 deletions
diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
index 170cdf4bac97..659bb05287f3 100644
--- a/drivers/scsi/libfc/fc_exch.c
+++ b/drivers/scsi/libfc/fc_exch.c
@@ -107,7 +107,6 @@ static void fc_seq_ls_rjt(struct fc_seq *, enum fc_els_rjt_reason,
107 enum fc_els_rjt_explan); 107 enum fc_els_rjt_explan);
108static void fc_exch_els_rec(struct fc_seq *, struct fc_frame *); 108static void fc_exch_els_rec(struct fc_seq *, struct fc_frame *);
109static void fc_exch_els_rrq(struct fc_seq *, struct fc_frame *); 109static void fc_exch_els_rrq(struct fc_seq *, struct fc_frame *);
110static struct fc_seq *fc_seq_start_next_locked(struct fc_seq *sp);
111 110
112/* 111/*
113 * Internal implementation notes. 112 * Internal implementation notes.
@@ -272,7 +271,6 @@ static void fc_exch_setup_hdr(struct fc_exch *ep, struct fc_frame *fp,
272 fh->fh_seq_cnt = htons(ep->seq.cnt); 271 fh->fh_seq_cnt = htons(ep->seq.cnt);
273} 272}
274 273
275
276/* 274/*
277 * Release a reference to an exchange. 275 * Release a reference to an exchange.
278 * If the refcnt goes to zero and the exchange is complete, it is freed. 276 * If the refcnt goes to zero and the exchange is complete, it is freed.
@@ -372,7 +370,104 @@ static void fc_exch_timer_set(struct fc_exch *ep, unsigned int timer_msec)
372 spin_unlock_bh(&ep->ex_lock); 370 spin_unlock_bh(&ep->ex_lock);
373} 371}
374 372
375int fc_seq_exch_abort(const struct fc_seq *req_sp, unsigned int timer_msec) 373/**
374 * send a frame using existing sequence and exchange.
375 */
376static int fc_seq_send(struct fc_lport *lp, struct fc_seq *sp,
377 struct fc_frame *fp)
378{
379 struct fc_exch *ep;
380 struct fc_frame_header *fh = fc_frame_header_get(fp);
381 int error;
382 u32 f_ctl;
383
384 ep = fc_seq_exch(sp);
385 WARN_ON((ep->esb_stat & ESB_ST_SEQ_INIT) != ESB_ST_SEQ_INIT);
386
387 f_ctl = ntoh24(fh->fh_f_ctl);
388 fc_exch_setup_hdr(ep, fp, f_ctl);
389
390 /*
391 * update sequence count if this frame is carrying
392 * multiple FC frames when sequence offload is enabled
393 * by LLD.
394 */
395 if (fr_max_payload(fp))
396 sp->cnt += DIV_ROUND_UP((fr_len(fp) - sizeof(*fh)),
397 fr_max_payload(fp));
398 else
399 sp->cnt++;
400
401 /*
402 * Send the frame.
403 */
404 error = lp->tt.frame_send(lp, fp);
405
406 /*
407 * Update the exchange and sequence flags,
408 * assuming all frames for the sequence have been sent.
409 * We can only be called to send once for each sequence.
410 */
411 spin_lock_bh(&ep->ex_lock);
412 ep->f_ctl = f_ctl & ~FC_FC_FIRST_SEQ; /* not first seq */
413 if (f_ctl & (FC_FC_END_SEQ | FC_FC_SEQ_INIT))
414 ep->esb_stat &= ~ESB_ST_SEQ_INIT;
415 spin_unlock_bh(&ep->ex_lock);
416 return error;
417}
418
419/**
420 * fc_seq_alloc() - Allocate a sequence.
421 * @ep: Exchange pointer
422 * @seq_id: Sequence ID to allocate a sequence for
423 *
424 * We don't support multiple originated sequences on the same exchange.
425 * By implication, any previously originated sequence on this exchange
426 * is complete, and we reallocate the same sequence.
427 */
428static struct fc_seq *fc_seq_alloc(struct fc_exch *ep, u8 seq_id)
429{
430 struct fc_seq *sp;
431
432 sp = &ep->seq;
433 sp->ssb_stat = 0;
434 sp->cnt = 0;
435 sp->id = seq_id;
436 return sp;
437}
438
439static struct fc_seq *fc_seq_start_next_locked(struct fc_seq *sp)
440{
441 struct fc_exch *ep = fc_seq_exch(sp);
442
443 sp = fc_seq_alloc(ep, ep->seq_id++);
444 FC_EXCH_DBG(ep, "f_ctl %6x seq %2x\n",
445 ep->f_ctl, sp->id);
446 return sp;
447}
448
449/**
450 * Allocate a new sequence on the same exchange as the supplied sequence.
451 * This will never return NULL.
452 */
453static struct fc_seq *fc_seq_start_next(struct fc_seq *sp)
454{
455 struct fc_exch *ep = fc_seq_exch(sp);
456
457 spin_lock_bh(&ep->ex_lock);
458 sp = fc_seq_start_next_locked(sp);
459 spin_unlock_bh(&ep->ex_lock);
460
461 return sp;
462}
463
464/**
465 * This function is for seq_exch_abort function pointer in
466 * struct libfc_function_template, see comment block on
467 * seq_exch_abort for description of this function.
468 */
469static int fc_seq_exch_abort(const struct fc_seq *req_sp,
470 unsigned int timer_msec)
376{ 471{
377 struct fc_seq *sp; 472 struct fc_seq *sp;
378 struct fc_exch *ep; 473 struct fc_exch *ep;
@@ -472,24 +567,6 @@ done:
472 fc_exch_release(ep); 567 fc_exch_release(ep);
473} 568}
474 569
475/*
476 * Allocate a sequence.
477 *
478 * We don't support multiple originated sequences on the same exchange.
479 * By implication, any previously originated sequence on this exchange
480 * is complete, and we reallocate the same sequence.
481 */
482static struct fc_seq *fc_seq_alloc(struct fc_exch *ep, u8 seq_id)
483{
484 struct fc_seq *sp;
485
486 sp = &ep->seq;
487 sp->ssb_stat = 0;
488 sp->cnt = 0;
489 sp->id = seq_id;
490 return sp;
491}
492
493/** 570/**
494 * fc_exch_em_alloc() - allocate an exchange from a specified EM. 571 * fc_exch_em_alloc() - allocate an exchange from a specified EM.
495 * @lport: ptr to the local port 572 * @lport: ptr to the local port
@@ -570,7 +647,8 @@ err:
570 * EM is selected having either a NULL match function pointer 647 * EM is selected having either a NULL match function pointer
571 * or call to match function returning true. 648 * or call to match function returning true.
572 */ 649 */
573struct fc_exch *fc_exch_alloc(struct fc_lport *lport, struct fc_frame *fp) 650static struct fc_exch *fc_exch_alloc(struct fc_lport *lport,
651 struct fc_frame *fp)
574{ 652{
575 struct fc_exch_mgr_anchor *ema; 653 struct fc_exch_mgr_anchor *ema;
576 struct fc_exch *ep; 654 struct fc_exch *ep;
@@ -584,7 +662,6 @@ struct fc_exch *fc_exch_alloc(struct fc_lport *lport, struct fc_frame *fp)
584 } 662 }
585 return NULL; 663 return NULL;
586} 664}
587EXPORT_SYMBOL(fc_exch_alloc);
588 665
589/* 666/*
590 * Lookup and hold an exchange. 667 * Lookup and hold an exchange.
@@ -607,7 +684,13 @@ static struct fc_exch *fc_exch_find(struct fc_exch_mgr *mp, u16 xid)
607 return ep; 684 return ep;
608} 685}
609 686
610void fc_exch_done(struct fc_seq *sp) 687
688/**
689 * fc_exch_done() - Indicate that an exchange/sequence tuple is complete and
690 * the memory allocated for the related objects may be freed.
691 * @sp: Sequence pointer
692 */
693static void fc_exch_done(struct fc_seq *sp)
611{ 694{
612 struct fc_exch *ep = fc_seq_exch(sp); 695 struct fc_exch *ep = fc_seq_exch(sp);
613 int rc; 696 int rc;
@@ -618,7 +701,6 @@ void fc_exch_done(struct fc_seq *sp)
618 if (!rc) 701 if (!rc)
619 fc_exch_delete(ep); 702 fc_exch_delete(ep);
620} 703}
621EXPORT_SYMBOL(fc_exch_done);
622 704
623/* 705/*
624 * Allocate a new exchange as responder. 706 * Allocate a new exchange as responder.
@@ -821,76 +903,15 @@ static void fc_exch_set_addr(struct fc_exch *ep,
821 } 903 }
822} 904}
823 905
824static struct fc_seq *fc_seq_start_next_locked(struct fc_seq *sp) 906/**
825{ 907 * fc_seq_els_rsp_send() - Send ELS response using mainly infomation
826 struct fc_exch *ep = fc_seq_exch(sp); 908 * in exchange and sequence in EM layer.
827 909 * @sp: Sequence pointer
828 sp = fc_seq_alloc(ep, ep->seq_id++); 910 * @els_cmd: ELS command
829 FC_EXCH_DBG(ep, "f_ctl %6x seq %2x\n", 911 * @els_data: ELS data
830 ep->f_ctl, sp->id);
831 return sp;
832}
833/*
834 * Allocate a new sequence on the same exchange as the supplied sequence.
835 * This will never return NULL.
836 */ 912 */
837struct fc_seq *fc_seq_start_next(struct fc_seq *sp) 913static void fc_seq_els_rsp_send(struct fc_seq *sp, enum fc_els_cmd els_cmd,
838{ 914 struct fc_seq_els_data *els_data)
839 struct fc_exch *ep = fc_seq_exch(sp);
840
841 spin_lock_bh(&ep->ex_lock);
842 sp = fc_seq_start_next_locked(sp);
843 spin_unlock_bh(&ep->ex_lock);
844
845 return sp;
846}
847EXPORT_SYMBOL(fc_seq_start_next);
848
849int fc_seq_send(struct fc_lport *lp, struct fc_seq *sp, struct fc_frame *fp)
850{
851 struct fc_exch *ep;
852 struct fc_frame_header *fh = fc_frame_header_get(fp);
853 int error;
854 u32 f_ctl;
855
856 ep = fc_seq_exch(sp);
857 WARN_ON((ep->esb_stat & ESB_ST_SEQ_INIT) != ESB_ST_SEQ_INIT);
858
859 f_ctl = ntoh24(fh->fh_f_ctl);
860 fc_exch_setup_hdr(ep, fp, f_ctl);
861
862 /*
863 * update sequence count if this frame is carrying
864 * multiple FC frames when sequence offload is enabled
865 * by LLD.
866 */
867 if (fr_max_payload(fp))
868 sp->cnt += DIV_ROUND_UP((fr_len(fp) - sizeof(*fh)),
869 fr_max_payload(fp));
870 else
871 sp->cnt++;
872
873 /*
874 * Send the frame.
875 */
876 error = lp->tt.frame_send(lp, fp);
877
878 /*
879 * Update the exchange and sequence flags,
880 * assuming all frames for the sequence have been sent.
881 * We can only be called to send once for each sequence.
882 */
883 spin_lock_bh(&ep->ex_lock);
884 ep->f_ctl = f_ctl & ~FC_FC_FIRST_SEQ; /* not first seq */
885 if (f_ctl & (FC_FC_END_SEQ | FC_FC_SEQ_INIT))
886 ep->esb_stat &= ~ESB_ST_SEQ_INIT;
887 spin_unlock_bh(&ep->ex_lock);
888 return error;
889}
890EXPORT_SYMBOL(fc_seq_send);
891
892void fc_seq_els_rsp_send(struct fc_seq *sp, enum fc_els_cmd els_cmd,
893 struct fc_seq_els_data *els_data)
894{ 915{
895 switch (els_cmd) { 916 switch (els_cmd) {
896 case ELS_LS_RJT: 917 case ELS_LS_RJT:
@@ -909,7 +930,6 @@ void fc_seq_els_rsp_send(struct fc_seq *sp, enum fc_els_cmd els_cmd,
909 FC_EXCH_DBG(fc_seq_exch(sp), "Invalid ELS CMD:%x\n", els_cmd); 930 FC_EXCH_DBG(fc_seq_exch(sp), "Invalid ELS CMD:%x\n", els_cmd);
910 } 931 }
911} 932}
912EXPORT_SYMBOL(fc_seq_els_rsp_send);
913 933
914/* 934/*
915 * Send a sequence, which is also the last sequence in the exchange. 935 * Send a sequence, which is also the last sequence in the exchange.
@@ -1662,6 +1682,68 @@ cleanup:
1662 fc_exch_release(aborted_ep); 1682 fc_exch_release(aborted_ep);
1663} 1683}
1664 1684
1685
1686/**
1687 * This function is for exch_seq_send function pointer in
1688 * struct libfc_function_template, see comment block on
1689 * exch_seq_send for description of this function.
1690 */
1691static struct fc_seq *fc_exch_seq_send(struct fc_lport *lp,
1692 struct fc_frame *fp,
1693 void (*resp)(struct fc_seq *,
1694 struct fc_frame *fp,
1695 void *arg),
1696 void (*destructor)(struct fc_seq *,
1697 void *),
1698 void *arg, u32 timer_msec)
1699{
1700 struct fc_exch *ep;
1701 struct fc_seq *sp = NULL;
1702 struct fc_frame_header *fh;
1703 int rc = 1;
1704
1705 ep = fc_exch_alloc(lp, fp);
1706 if (!ep) {
1707 fc_frame_free(fp);
1708 return NULL;
1709 }
1710 ep->esb_stat |= ESB_ST_SEQ_INIT;
1711 fh = fc_frame_header_get(fp);
1712 fc_exch_set_addr(ep, ntoh24(fh->fh_s_id), ntoh24(fh->fh_d_id));
1713 ep->resp = resp;
1714 ep->destructor = destructor;
1715 ep->arg = arg;
1716 ep->r_a_tov = FC_DEF_R_A_TOV;
1717 ep->lp = lp;
1718 sp = &ep->seq;
1719
1720 ep->fh_type = fh->fh_type; /* save for possbile timeout handling */
1721 ep->f_ctl = ntoh24(fh->fh_f_ctl);
1722 fc_exch_setup_hdr(ep, fp, ep->f_ctl);
1723 sp->cnt++;
1724
1725 if (ep->xid <= lp->lro_xid)
1726 fc_fcp_ddp_setup(fr_fsp(fp), ep->xid);
1727
1728 if (unlikely(lp->tt.frame_send(lp, fp)))
1729 goto err;
1730
1731 if (timer_msec)
1732 fc_exch_timer_set_locked(ep, timer_msec);
1733 ep->f_ctl &= ~FC_FC_FIRST_SEQ; /* not first seq */
1734
1735 if (ep->f_ctl & FC_FC_SEQ_INIT)
1736 ep->esb_stat &= ~ESB_ST_SEQ_INIT;
1737 spin_unlock_bh(&ep->ex_lock);
1738 return sp;
1739err:
1740 rc = fc_exch_done_locked(ep);
1741 spin_unlock_bh(&ep->ex_lock);
1742 if (!rc)
1743 fc_exch_delete(ep);
1744 return NULL;
1745}
1746
1665/* 1747/*
1666 * Send ELS RRQ - Reinstate Recovery Qualifier. 1748 * Send ELS RRQ - Reinstate Recovery Qualifier.
1667 * This tells the remote port to stop blocking the use of 1749 * This tells the remote port to stop blocking the use of
@@ -1902,63 +1984,6 @@ void fc_exch_mgr_free(struct fc_lport *lport)
1902} 1984}
1903EXPORT_SYMBOL(fc_exch_mgr_free); 1985EXPORT_SYMBOL(fc_exch_mgr_free);
1904 1986
1905
1906struct fc_seq *fc_exch_seq_send(struct fc_lport *lp,
1907 struct fc_frame *fp,
1908 void (*resp)(struct fc_seq *,
1909 struct fc_frame *fp,
1910 void *arg),
1911 void (*destructor)(struct fc_seq *, void *),
1912 void *arg, u32 timer_msec)
1913{
1914 struct fc_exch *ep;
1915 struct fc_seq *sp = NULL;
1916 struct fc_frame_header *fh;
1917 int rc = 1;
1918
1919 ep = fc_exch_alloc(lp, fp);
1920 if (!ep) {
1921 fc_frame_free(fp);
1922 return NULL;
1923 }
1924 ep->esb_stat |= ESB_ST_SEQ_INIT;
1925 fh = fc_frame_header_get(fp);
1926 fc_exch_set_addr(ep, ntoh24(fh->fh_s_id), ntoh24(fh->fh_d_id));
1927 ep->resp = resp;
1928 ep->destructor = destructor;
1929 ep->arg = arg;
1930 ep->r_a_tov = FC_DEF_R_A_TOV;
1931 ep->lp = lp;
1932 sp = &ep->seq;
1933
1934 ep->fh_type = fh->fh_type; /* save for possbile timeout handling */
1935 ep->f_ctl = ntoh24(fh->fh_f_ctl);
1936 fc_exch_setup_hdr(ep, fp, ep->f_ctl);
1937 sp->cnt++;
1938
1939 if (ep->xid <= lp->lro_xid)
1940 fc_fcp_ddp_setup(fr_fsp(fp), ep->xid);
1941
1942 if (unlikely(lp->tt.frame_send(lp, fp)))
1943 goto err;
1944
1945 if (timer_msec)
1946 fc_exch_timer_set_locked(ep, timer_msec);
1947 ep->f_ctl &= ~FC_FC_FIRST_SEQ; /* not first seq */
1948
1949 if (ep->f_ctl & FC_FC_SEQ_INIT)
1950 ep->esb_stat &= ~ESB_ST_SEQ_INIT;
1951 spin_unlock_bh(&ep->ex_lock);
1952 return sp;
1953err:
1954 rc = fc_exch_done_locked(ep);
1955 spin_unlock_bh(&ep->ex_lock);
1956 if (!rc)
1957 fc_exch_delete(ep);
1958 return NULL;
1959}
1960EXPORT_SYMBOL(fc_exch_seq_send);
1961
1962/* 1987/*
1963 * Receive a frame 1988 * Receive a frame
1964 */ 1989 */
diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
index 9617f9365e45..f207b6cac06f 100644
--- a/include/scsi/libfc.h
+++ b/include/scsi/libfc.h
@@ -1012,55 +1012,6 @@ void fc_exch_mgr_free(struct fc_lport *lport);
1012void fc_exch_recv(struct fc_lport *lp, struct fc_frame *fp); 1012void fc_exch_recv(struct fc_lport *lp, struct fc_frame *fp);
1013 1013
1014/* 1014/*
1015 * This function is for exch_seq_send function pointer in
1016 * struct libfc_function_template, see comment block on
1017 * exch_seq_send for description of this function.
1018 */
1019struct fc_seq *fc_exch_seq_send(struct fc_lport *lp,
1020 struct fc_frame *fp,
1021 void (*resp)(struct fc_seq *sp,
1022 struct fc_frame *fp,
1023 void *arg),
1024 void (*destructor)(struct fc_seq *sp,
1025 void *arg),
1026 void *arg, u32 timer_msec);
1027
1028/*
1029 * send a frame using existing sequence and exchange.
1030 */
1031int fc_seq_send(struct fc_lport *lp, struct fc_seq *sp, struct fc_frame *fp);
1032
1033/*
1034 * Send ELS response using mainly infomation
1035 * in exchange and sequence in EM layer.
1036 */
1037void fc_seq_els_rsp_send(struct fc_seq *sp, enum fc_els_cmd els_cmd,
1038 struct fc_seq_els_data *els_data);
1039
1040/*
1041 * This function is for seq_exch_abort function pointer in
1042 * struct libfc_function_template, see comment block on
1043 * seq_exch_abort for description of this function.
1044 */
1045int fc_seq_exch_abort(const struct fc_seq *req_sp, unsigned int timer_msec);
1046
1047/*
1048 * Indicate that an exchange/sequence tuple is complete and the memory
1049 * allocated for the related objects may be freed.
1050 */
1051void fc_exch_done(struct fc_seq *sp);
1052
1053/*
1054 * Allocate a new exchange and sequence pair.
1055 */
1056struct fc_exch *fc_exch_alloc(struct fc_lport *lport, struct fc_frame *fp);
1057/*
1058 * Start a new sequence on the same exchange as the supplied sequence.
1059 */
1060struct fc_seq *fc_seq_start_next(struct fc_seq *sp);
1061
1062
1063/*
1064 * Reset all EMs of a lport, releasing its all sequences and 1015 * Reset all EMs of a lport, releasing its all sequences and
1065 * exchanges. If sid is non-zero, then reset only exchanges 1016 * exchanges. If sid is non-zero, then reset only exchanges
1066 * we sourced from that FID. If did is non-zero, reset only 1017 * we sourced from that FID. If did is non-zero, reset only