aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/scsi/libfc/fc_lport.c30
-rw-r--r--drivers/scsi/libfc/fc_rport.c78
-rw-r--r--include/scsi/libfc.h2
3 files changed, 44 insertions, 66 deletions
diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c
index caf68240bddf..d3f4e0c34f5c 100644
--- a/drivers/scsi/libfc/fc_lport.c
+++ b/drivers/scsi/libfc/fc_lport.c
@@ -812,10 +812,6 @@ static void fc_lport_recv_req(struct fc_lport *lport, struct fc_seq *sp,
812{ 812{
813 struct fc_frame_header *fh = fc_frame_header_get(fp); 813 struct fc_frame_header *fh = fc_frame_header_get(fp);
814 void (*recv) (struct fc_seq *, struct fc_frame *, struct fc_lport *); 814 void (*recv) (struct fc_seq *, struct fc_frame *, struct fc_lport *);
815 struct fc_rport_priv *rdata;
816 u32 s_id;
817 u32 d_id;
818 struct fc_seq_els_data rjt_data;
819 815
820 mutex_lock(&lport->lp_mutex); 816 mutex_lock(&lport->lp_mutex);
821 817
@@ -831,7 +827,7 @@ static void fc_lport_recv_req(struct fc_lport *lport, struct fc_seq *sp,
831 /* 827 /*
832 * Check opcode. 828 * Check opcode.
833 */ 829 */
834 recv = NULL; 830 recv = lport->tt.rport_recv_req;
835 switch (fc_frame_payload_op(fp)) { 831 switch (fc_frame_payload_op(fp)) {
836 case ELS_FLOGI: 832 case ELS_FLOGI:
837 recv = fc_lport_recv_flogi_req; 833 recv = fc_lport_recv_flogi_req;
@@ -858,29 +854,7 @@ static void fc_lport_recv_req(struct fc_lport *lport, struct fc_seq *sp,
858 break; 854 break;
859 } 855 }
860 856
861 if (recv) 857 recv(sp, fp, lport);
862 recv(sp, fp, lport);
863 else {
864 /*
865 * Find session.
866 * If this is a new incoming PLOGI, we won't find it.
867 */
868 s_id = ntoh24(fh->fh_s_id);
869 d_id = ntoh24(fh->fh_d_id);
870
871 rdata = lport->tt.rport_lookup(lport, s_id);
872 if (rdata)
873 lport->tt.rport_recv_req(sp, fp, rdata);
874 else {
875 rjt_data.fp = NULL;
876 rjt_data.reason = ELS_RJT_UNAB;
877 rjt_data.explan = ELS_EXPL_NONE;
878 lport->tt.seq_els_rsp_send(sp,
879 ELS_LS_RJT,
880 &rjt_data);
881 fc_frame_free(fp);
882 }
883 }
884 } else { 858 } else {
885 FC_LPORT_DBG(lport, "dropping invalid frame (eof %x)\n", 859 FC_LPORT_DBG(lport, "dropping invalid frame (eof %x)\n",
886 fr_eof(fp)); 860 fr_eof(fp));
diff --git a/drivers/scsi/libfc/fc_rport.c b/drivers/scsi/libfc/fc_rport.c
index cb54115c26cb..acdc72d6b873 100644
--- a/drivers/scsi/libfc/fc_rport.c
+++ b/drivers/scsi/libfc/fc_rport.c
@@ -912,57 +912,61 @@ static void fc_rport_enter_logo(struct fc_rport_priv *rdata)
912 * fc_rport_recv_req() - Receive a request from a rport 912 * fc_rport_recv_req() - Receive a request from a rport
913 * @sp: current sequence in the PLOGI exchange 913 * @sp: current sequence in the PLOGI exchange
914 * @fp: response frame 914 * @fp: response frame
915 * @rdata_arg: private remote port data 915 * @lport: Fibre Channel local port
916 * 916 *
917 * Locking Note: Called without the rport lock held. This 917 * Locking Note: Called with the lport lock held.
918 * function will hold the rport lock, call an _enter_*
919 * function and then unlock the rport.
920 */ 918 */
921void fc_rport_recv_req(struct fc_seq *sp, struct fc_frame *fp, 919void fc_rport_recv_req(struct fc_seq *sp, struct fc_frame *fp,
922 struct fc_rport_priv *rdata) 920 struct fc_lport *lport)
923{ 921{
924 struct fc_lport *lport = rdata->local_port; 922 struct fc_rport_priv *rdata;
925
926 struct fc_frame_header *fh; 923 struct fc_frame_header *fh;
927 struct fc_seq_els_data els_data; 924 struct fc_seq_els_data els_data;
925 u32 s_id;
928 u8 op; 926 u8 op;
929 927
930 mutex_lock(&rdata->rp_mutex);
931
932 els_data.fp = NULL; 928 els_data.fp = NULL;
933 els_data.explan = ELS_EXPL_NONE; 929 els_data.explan = ELS_EXPL_NONE;
934 els_data.reason = ELS_RJT_NONE; 930 els_data.reason = ELS_RJT_NONE;
935 931
936 fh = fc_frame_header_get(fp); 932 fh = fc_frame_header_get(fp);
933 s_id = ntoh24(fh->fh_s_id);
937 934
938 if (fh->fh_r_ctl == FC_RCTL_ELS_REQ && fh->fh_type == FC_TYPE_ELS) { 935 rdata = lport->tt.rport_lookup(lport, s_id);
939 op = fc_frame_payload_op(fp); 936 if (!rdata) {
940 switch (op) { 937 els_data.reason = ELS_RJT_UNAB;
941 case ELS_PLOGI: 938 lport->tt.seq_els_rsp_send(sp, ELS_LS_RJT, &els_data);
942 fc_rport_recv_plogi_req(rdata, sp, fp); 939 fc_frame_free(fp);
943 break; 940 return;
944 case ELS_PRLI: 941 }
945 fc_rport_recv_prli_req(rdata, sp, fp); 942 mutex_lock(&rdata->rp_mutex);
946 break; 943
947 case ELS_PRLO: 944 op = fc_frame_payload_op(fp);
948 fc_rport_recv_prlo_req(rdata, sp, fp); 945 switch (op) {
949 break; 946 case ELS_PLOGI:
950 case ELS_LOGO: 947 fc_rport_recv_plogi_req(rdata, sp, fp);
951 fc_rport_recv_logo_req(rdata, sp, fp); 948 break;
952 break; 949 case ELS_PRLI:
953 case ELS_RRQ: 950 fc_rport_recv_prli_req(rdata, sp, fp);
954 els_data.fp = fp; 951 break;
955 lport->tt.seq_els_rsp_send(sp, ELS_RRQ, &els_data); 952 case ELS_PRLO:
956 break; 953 fc_rport_recv_prlo_req(rdata, sp, fp);
957 case ELS_REC: 954 break;
958 els_data.fp = fp; 955 case ELS_LOGO:
959 lport->tt.seq_els_rsp_send(sp, ELS_REC, &els_data); 956 fc_rport_recv_logo_req(rdata, sp, fp);
960 break; 957 break;
961 default: 958 case ELS_RRQ:
962 els_data.reason = ELS_RJT_UNSUP; 959 els_data.fp = fp;
963 lport->tt.seq_els_rsp_send(sp, ELS_LS_RJT, &els_data); 960 lport->tt.seq_els_rsp_send(sp, ELS_RRQ, &els_data);
964 break; 961 break;
965 } 962 case ELS_REC:
963 els_data.fp = fp;
964 lport->tt.seq_els_rsp_send(sp, ELS_REC, &els_data);
965 break;
966 default:
967 els_data.reason = ELS_RJT_UNSUP;
968 lport->tt.seq_els_rsp_send(sp, ELS_LS_RJT, &els_data);
969 break;
966 } 970 }
967 971
968 mutex_unlock(&rdata->rp_mutex); 972 mutex_unlock(&rdata->rp_mutex);
diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
index cd410c123b99..265f106d9fd6 100644
--- a/include/scsi/libfc.h
+++ b/include/scsi/libfc.h
@@ -598,7 +598,7 @@ struct libfc_function_template {
598 * STATUS: OPTIONAL 598 * STATUS: OPTIONAL
599 */ 599 */
600 void (*rport_recv_req)(struct fc_seq *, struct fc_frame *, 600 void (*rport_recv_req)(struct fc_seq *, struct fc_frame *,
601 struct fc_rport_priv *); 601 struct fc_lport *);
602 602
603 /* 603 /*
604 * lookup an rport by it's port ID. 604 * lookup an rport by it's port ID.