aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/libfc
diff options
context:
space:
mode:
authorChris Leech <christopher.leech@intel.com>2009-11-03 14:46:51 -0500
committerJames Bottomley <James.Bottomley@suse.de>2009-12-04 13:01:01 -0500
commitc9c7bd7a5e7321aa96289c9b48fdbcc828c105e6 (patch)
treee20db89880f4579abf8bd6da66ce2a2a80d0ea94 /drivers/scsi/libfc
parent28cc0e31d874af05244da421e05565f2ba72fd5c (diff)
[SCSI] libfc: RNN_ID may be required before RSNN_NN with some switches
One could interpret FC-GS-5 to say that an explicit RNN_ID is required before RSNN_NN is allowed to succeed, which is why RNN_ID was not obsoleted along with RPN_ID acording to this document: ftp://ftp.t11.org/t11/member/fc/gs-5/05-546v2.pdf Signed-off-by: Chris Leech <christopher.leech@intel.com> Signed-off-by: Robert Love <robert.w.love@intel.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi/libfc')
-rw-r--r--drivers/scsi/libfc/fc_lport.c91
1 files changed, 90 insertions, 1 deletions
diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c
index 47577e4a2e87..897b5a8487e2 100644
--- a/drivers/scsi/libfc/fc_lport.c
+++ b/drivers/scsi/libfc/fc_lport.c
@@ -108,6 +108,7 @@ static void fc_lport_error(struct fc_lport *, struct fc_frame *);
108static void fc_lport_enter_reset(struct fc_lport *); 108static void fc_lport_enter_reset(struct fc_lport *);
109static void fc_lport_enter_flogi(struct fc_lport *); 109static void fc_lport_enter_flogi(struct fc_lport *);
110static void fc_lport_enter_dns(struct fc_lport *); 110static void fc_lport_enter_dns(struct fc_lport *);
111static void fc_lport_enter_rnn_id(struct fc_lport *);
111static void fc_lport_enter_rft_id(struct fc_lport *); 112static void fc_lport_enter_rft_id(struct fc_lport *);
112static void fc_lport_enter_scr(struct fc_lport *); 113static void fc_lport_enter_scr(struct fc_lport *);
113static void fc_lport_enter_ready(struct fc_lport *); 114static void fc_lport_enter_ready(struct fc_lport *);
@@ -117,6 +118,7 @@ static const char *fc_lport_state_names[] = {
117 [LPORT_ST_DISABLED] = "disabled", 118 [LPORT_ST_DISABLED] = "disabled",
118 [LPORT_ST_FLOGI] = "FLOGI", 119 [LPORT_ST_FLOGI] = "FLOGI",
119 [LPORT_ST_DNS] = "dNS", 120 [LPORT_ST_DNS] = "dNS",
121 [LPORT_ST_RNN_ID] = "RNN_ID",
120 [LPORT_ST_RFT_ID] = "RFT_ID", 122 [LPORT_ST_RFT_ID] = "RFT_ID",
121 [LPORT_ST_SCR] = "SCR", 123 [LPORT_ST_SCR] = "SCR",
122 [LPORT_ST_READY] = "Ready", 124 [LPORT_ST_READY] = "Ready",
@@ -151,7 +153,7 @@ static void fc_lport_rport_callback(struct fc_lport *lport,
151 case RPORT_EV_READY: 153 case RPORT_EV_READY:
152 if (lport->state == LPORT_ST_DNS) { 154 if (lport->state == LPORT_ST_DNS) {
153 lport->dns_rp = rdata; 155 lport->dns_rp = rdata;
154 fc_lport_enter_rft_id(lport); 156 fc_lport_enter_rnn_id(lport);
155 } else { 157 } else {
156 FC_LPORT_DBG(lport, "Received an READY event " 158 FC_LPORT_DBG(lport, "Received an READY event "
157 "on port (%6x) for the directory " 159 "on port (%6x) for the directory "
@@ -963,6 +965,7 @@ static void fc_lport_error(struct fc_lport *lport, struct fc_frame *fp)
963 case LPORT_ST_DISABLED: 965 case LPORT_ST_DISABLED:
964 case LPORT_ST_READY: 966 case LPORT_ST_READY:
965 case LPORT_ST_RESET: 967 case LPORT_ST_RESET:
968 case LPORT_ST_RNN_ID:
966 case LPORT_ST_RFT_ID: 969 case LPORT_ST_RFT_ID:
967 case LPORT_ST_SCR: 970 case LPORT_ST_SCR:
968 case LPORT_ST_DNS: 971 case LPORT_ST_DNS:
@@ -1030,6 +1033,60 @@ err:
1030} 1033}
1031 1034
1032/** 1035/**
1036 * fc_lport_rnn_id_resp() - Handle response to Register Node
1037 * Name by ID (RNN_ID) request
1038 * @sp: current sequence in RNN_ID exchange
1039 * @fp: response frame
1040 * @lp_arg: Fibre Channel host port instance
1041 *
1042 * Locking Note: This function will be called without the lport lock
1043 * held, but it will lock, call an _enter_* function or fc_lport_error
1044 * and then unlock the lport.
1045 */
1046static void fc_lport_rnn_id_resp(struct fc_seq *sp, struct fc_frame *fp,
1047 void *lp_arg)
1048{
1049 struct fc_lport *lport = lp_arg;
1050 struct fc_frame_header *fh;
1051 struct fc_ct_hdr *ct;
1052
1053 FC_LPORT_DBG(lport, "Received a RNN_ID %s\n", fc_els_resp_type(fp));
1054
1055 if (fp == ERR_PTR(-FC_EX_CLOSED))
1056 return;
1057
1058 mutex_lock(&lport->lp_mutex);
1059
1060 if (lport->state != LPORT_ST_RNN_ID) {
1061 FC_LPORT_DBG(lport, "Received a RNN_ID response, but in state "
1062 "%s\n", fc_lport_state(lport));
1063 if (IS_ERR(fp))
1064 goto err;
1065 goto out;
1066 }
1067
1068 if (IS_ERR(fp)) {
1069 fc_lport_error(lport, fp);
1070 goto err;
1071 }
1072
1073 fh = fc_frame_header_get(fp);
1074 ct = fc_frame_payload_get(fp, sizeof(*ct));
1075 if (fh && ct && fh->fh_type == FC_TYPE_CT &&
1076 ct->ct_fs_type == FC_FST_DIR &&
1077 ct->ct_fs_subtype == FC_NS_SUBTYPE &&
1078 ntohs(ct->ct_cmd) == FC_FS_ACC)
1079 fc_lport_enter_rft_id(lport);
1080 else
1081 fc_lport_error(lport, fp);
1082
1083out:
1084 fc_frame_free(fp);
1085err:
1086 mutex_unlock(&lport->lp_mutex);
1087}
1088
1089/**
1033 * fc_lport_scr_resp() - Handle response to State Change Register (SCR) request 1090 * fc_lport_scr_resp() - Handle response to State Change Register (SCR) request
1034 * @sp: current sequence in SCR exchange 1091 * @sp: current sequence in SCR exchange
1035 * @fp: response frame 1092 * @fp: response frame
@@ -1146,6 +1203,35 @@ static void fc_lport_enter_rft_id(struct fc_lport *lport)
1146 fc_lport_error(lport, fp); 1203 fc_lport_error(lport, fp);
1147} 1204}
1148 1205
1206/**
1207 * fc_rport_enter_rnn_id() - Register node name with the name server
1208 * @lport: Fibre Channel local port to register
1209 *
1210 * Locking Note: The lport lock is expected to be held before calling
1211 * this routine.
1212 */
1213static void fc_lport_enter_rnn_id(struct fc_lport *lport)
1214{
1215 struct fc_frame *fp;
1216
1217 FC_LPORT_DBG(lport, "Entered RNN_ID state from %s state\n",
1218 fc_lport_state(lport));
1219
1220 fc_lport_state_enter(lport, LPORT_ST_RNN_ID);
1221
1222 fp = fc_frame_alloc(lport, sizeof(struct fc_ct_hdr) +
1223 sizeof(struct fc_ns_rn_id));
1224 if (!fp) {
1225 fc_lport_error(lport, fp);
1226 return;
1227 }
1228
1229 if (!lport->tt.elsct_send(lport, FC_FID_DIR_SERV, fp, FC_NS_RNN_ID,
1230 fc_lport_rnn_id_resp,
1231 lport, lport->e_d_tov))
1232 fc_lport_error(lport, fp);
1233}
1234
1149static struct fc_rport_operations fc_lport_rport_ops = { 1235static struct fc_rport_operations fc_lport_rport_ops = {
1150 .event_callback = fc_lport_rport_callback, 1236 .event_callback = fc_lport_rport_callback,
1151}; 1237};
@@ -1207,6 +1293,9 @@ static void fc_lport_timeout(struct work_struct *work)
1207 case LPORT_ST_DNS: 1293 case LPORT_ST_DNS:
1208 fc_lport_enter_dns(lport); 1294 fc_lport_enter_dns(lport);
1209 break; 1295 break;
1296 case LPORT_ST_RNN_ID:
1297 fc_lport_enter_rnn_id(lport);
1298 break;
1210 case LPORT_ST_RFT_ID: 1299 case LPORT_ST_RFT_ID:
1211 fc_lport_enter_rft_id(lport); 1300 fc_lport_enter_rft_id(lport);
1212 break; 1301 break;