aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/libfc
diff options
context:
space:
mode:
authorChris Leech <christopher.leech@intel.com>2009-11-03 14:47:12 -0500
committerJames Bottomley <James.Bottomley@suse.de>2009-12-04 13:01:04 -0500
commitc914f7d16df6420cfd4c09399957425ba9c21f47 (patch)
tree1b0abcc574a1ee55fefd8905f22b9c9449ee9272 /drivers/scsi/libfc
parent7cccc157119be9b3f57e03a5ae197ba0a6a8a89f (diff)
[SCSI] libfc: combine name server registration request functions
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.c164
1 files changed, 42 insertions, 122 deletions
diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c
index f67ca680eb63..dfea6c572dfb 100644
--- a/drivers/scsi/libfc/fc_lport.c
+++ b/drivers/scsi/libfc/fc_lport.c
@@ -108,10 +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_ns(struct fc_lport *, enum fc_lport_state);
112static void fc_lport_enter_rsnn_nn(struct fc_lport *);
113static void fc_lport_enter_rspn_id(struct fc_lport *);
114static void fc_lport_enter_rft_id(struct fc_lport *);
115static void fc_lport_enter_scr(struct fc_lport *); 112static void fc_lport_enter_scr(struct fc_lport *);
116static void fc_lport_enter_ready(struct fc_lport *); 113static void fc_lport_enter_ready(struct fc_lport *);
117static void fc_lport_enter_logo(struct fc_lport *); 114static void fc_lport_enter_logo(struct fc_lport *);
@@ -157,7 +154,7 @@ static void fc_lport_rport_callback(struct fc_lport *lport,
157 case RPORT_EV_READY: 154 case RPORT_EV_READY:
158 if (lport->state == LPORT_ST_DNS) { 155 if (lport->state == LPORT_ST_DNS) {
159 lport->dns_rp = rdata; 156 lport->dns_rp = rdata;
160 fc_lport_enter_rnn_id(lport); 157 fc_lport_enter_ns(lport, LPORT_ST_RNN_ID);
161 } else { 158 } else {
162 FC_LPORT_DBG(lport, "Received an READY event " 159 FC_LPORT_DBG(lport, "Received an READY event "
163 "on port (%6x) for the directory " 160 "on port (%6x) for the directory "
@@ -1031,13 +1028,13 @@ static void fc_lport_ns_resp(struct fc_seq *sp, struct fc_frame *fp,
1031 ntohs(ct->ct_cmd) == FC_FS_ACC) 1028 ntohs(ct->ct_cmd) == FC_FS_ACC)
1032 switch (lport->state) { 1029 switch (lport->state) {
1033 case LPORT_ST_RNN_ID: 1030 case LPORT_ST_RNN_ID:
1034 fc_lport_enter_rsnn_nn(lport); 1031 fc_lport_enter_ns(lport, LPORT_ST_RSNN_NN);
1035 break; 1032 break;
1036 case LPORT_ST_RSNN_NN: 1033 case LPORT_ST_RSNN_NN:
1037 fc_lport_enter_rspn_id(lport); 1034 fc_lport_enter_ns(lport, LPORT_ST_RSPN_ID);
1038 break; 1035 break;
1039 case LPORT_ST_RSPN_ID: 1036 case LPORT_ST_RSPN_ID:
1040 fc_lport_enter_rft_id(lport); 1037 fc_lport_enter_ns(lport, LPORT_ST_RFT_ID);
1041 break; 1038 break;
1042 case LPORT_ST_RFT_ID: 1039 case LPORT_ST_RFT_ID:
1043 fc_lport_enter_scr(lport); 1040 fc_lport_enter_scr(lport);
@@ -1130,133 +1127,62 @@ static void fc_lport_enter_scr(struct fc_lport *lport)
1130} 1127}
1131 1128
1132/** 1129/**
1133 * fc_lport_enter_rft_id() - Register FC4-types with the name server 1130 * fc_lport_enter_ns() - register some object with the name server
1134 * @lport: Fibre Channel local port to register 1131 * @lport: Fibre Channel local port to register
1135 * 1132 *
1136 * Locking Note: The lport lock is expected to be held before calling 1133 * Locking Note: The lport lock is expected to be held before calling
1137 * this routine. 1134 * this routine.
1138 */ 1135 */
1139static void fc_lport_enter_rft_id(struct fc_lport *lport) 1136static void fc_lport_enter_ns(struct fc_lport *lport, enum fc_lport_state state)
1140{
1141 struct fc_frame *fp;
1142 struct fc_ns_fts *lps;
1143 int i;
1144
1145 FC_LPORT_DBG(lport, "Entered RFT_ID state from %s state\n",
1146 fc_lport_state(lport));
1147
1148 fc_lport_state_enter(lport, LPORT_ST_RFT_ID);
1149
1150 lps = &lport->fcts;
1151 i = sizeof(lps->ff_type_map) / sizeof(lps->ff_type_map[0]);
1152 while (--i >= 0)
1153 if (ntohl(lps->ff_type_map[i]) != 0)
1154 break;
1155 if (i < 0) {
1156 /* nothing to register, move on to SCR */
1157 fc_lport_enter_scr(lport);
1158 return;
1159 }
1160
1161 fp = fc_frame_alloc(lport, sizeof(struct fc_ct_hdr) +
1162 sizeof(struct fc_ns_rft));
1163 if (!fp) {
1164 fc_lport_error(lport, fp);
1165 return;
1166 }
1167
1168 if (!lport->tt.elsct_send(lport, FC_FID_DIR_SERV, fp, FC_NS_RFT_ID,
1169 fc_lport_ns_resp,
1170 lport, lport->e_d_tov))
1171 fc_lport_error(lport, fp);
1172}
1173
1174/**
1175 * fc_rport_enter_rspn_id() - Register symbolic port name with the name server
1176 * @lport: Fibre Channel local port to register
1177 *
1178 * Locking Note: The lport lock is expected to be held before calling
1179 * this routine.
1180 */
1181static void fc_lport_enter_rspn_id(struct fc_lport *lport)
1182{ 1137{
1183 struct fc_frame *fp; 1138 struct fc_frame *fp;
1139 enum fc_ns_req cmd;
1140 int size = sizeof(struct fc_ct_hdr);
1184 size_t len; 1141 size_t len;
1185 1142
1186 FC_LPORT_DBG(lport, "Entered RSPN_ID state from %s state\n", 1143 FC_LPORT_DBG(lport, "Entered %s state from %s state\n",
1144 fc_lport_state_names[state],
1187 fc_lport_state(lport)); 1145 fc_lport_state(lport));
1188 1146
1189 fc_lport_state_enter(lport, LPORT_ST_RSPN_ID); 1147 fc_lport_state_enter(lport, state);
1190
1191 len = strnlen(fc_host_symbolic_name(lport->host), 255);
1192 fp = fc_frame_alloc(lport, sizeof(struct fc_ct_hdr) +
1193 sizeof(struct fc_ns_rspn) + len);
1194 if (!fp) {
1195 fc_lport_error(lport, fp);
1196 return;
1197 }
1198
1199 if (!lport->tt.elsct_send(lport, FC_FID_DIR_SERV, fp, FC_NS_RSPN_ID,
1200 fc_lport_ns_resp,
1201 lport, lport->e_d_tov))
1202 fc_lport_error(lport, fp);
1203}
1204 1148
1205/** 1149 switch (state) {
1206 * fc_rport_enter_rsnn_nn() - Register symbolic node name with the name server 1150 case LPORT_ST_RNN_ID:
1207 * @lport: Fibre Channel local port to register 1151 cmd = FC_NS_RNN_ID;
1208 * 1152 size += sizeof(struct fc_ns_rn_id);
1209 * Locking Note: The lport lock is expected to be held before calling 1153 break;
1210 * this routine. 1154 case LPORT_ST_RSNN_NN:
1211 */ 1155 len = strnlen(fc_host_symbolic_name(lport->host), 255);
1212static void fc_lport_enter_rsnn_nn(struct fc_lport *lport) 1156 /* if there is no symbolic name, skip to RFT_ID */
1213{ 1157 if (!len)
1214 struct fc_frame *fp; 1158 return fc_lport_enter_ns(lport, LPORT_ST_RFT_ID);
1215 size_t len; 1159 cmd = FC_NS_RSNN_NN;
1216 1160 size += sizeof(struct fc_ns_rsnn) + len;
1217 FC_LPORT_DBG(lport, "Entered RSNN_NN state from %s state\n", 1161 break;
1218 fc_lport_state(lport)); 1162 case LPORT_ST_RSPN_ID:
1219 1163 len = strnlen(fc_host_symbolic_name(lport->host), 255);
1220 fc_lport_state_enter(lport, LPORT_ST_RSNN_NN); 1164 /* if there is no symbolic name, skip to RFT_ID */
1221 1165 if (!len)
1222 len = strnlen(fc_host_symbolic_name(lport->host), 255); 1166 return fc_lport_enter_ns(lport, LPORT_ST_RFT_ID);
1223 fp = fc_frame_alloc(lport, sizeof(struct fc_ct_hdr) + 1167 cmd = FC_NS_RSPN_ID;
1224 sizeof(struct fc_ns_rsnn) + len); 1168 size += sizeof(struct fc_ns_rspn) + len;
1225 if (!fp) { 1169 break;
1226 fc_lport_error(lport, fp); 1170 case LPORT_ST_RFT_ID:
1171 cmd = FC_NS_RFT_ID;
1172 size += sizeof(struct fc_ns_rft);
1173 break;
1174 default:
1175 fc_lport_error(lport, NULL);
1227 return; 1176 return;
1228 } 1177 }
1229 1178
1230 if (!lport->tt.elsct_send(lport, FC_FID_DIR_SERV, fp, FC_NS_RSNN_NN, 1179 fp = fc_frame_alloc(lport, size);
1231 fc_lport_ns_resp,
1232 lport, lport->e_d_tov))
1233 fc_lport_error(lport, fp);
1234}
1235
1236/**
1237 * fc_rport_enter_rnn_id() - Register node name with the name server
1238 * @lport: Fibre Channel local port to register
1239 *
1240 * Locking Note: The lport lock is expected to be held before calling
1241 * this routine.
1242 */
1243static void fc_lport_enter_rnn_id(struct fc_lport *lport)
1244{
1245 struct fc_frame *fp;
1246
1247 FC_LPORT_DBG(lport, "Entered RNN_ID state from %s state\n",
1248 fc_lport_state(lport));
1249
1250 fc_lport_state_enter(lport, LPORT_ST_RNN_ID);
1251
1252 fp = fc_frame_alloc(lport, sizeof(struct fc_ct_hdr) +
1253 sizeof(struct fc_ns_rn_id));
1254 if (!fp) { 1180 if (!fp) {
1255 fc_lport_error(lport, fp); 1181 fc_lport_error(lport, fp);
1256 return; 1182 return;
1257 } 1183 }
1258 1184
1259 if (!lport->tt.elsct_send(lport, FC_FID_DIR_SERV, fp, FC_NS_RNN_ID, 1185 if (!lport->tt.elsct_send(lport, FC_FID_DIR_SERV, fp, cmd,
1260 fc_lport_ns_resp, 1186 fc_lport_ns_resp,
1261 lport, lport->e_d_tov)) 1187 lport, lport->e_d_tov))
1262 fc_lport_error(lport, fp); 1188 fc_lport_error(lport, fp);
@@ -1324,16 +1250,10 @@ static void fc_lport_timeout(struct work_struct *work)
1324 fc_lport_enter_dns(lport); 1250 fc_lport_enter_dns(lport);
1325 break; 1251 break;
1326 case LPORT_ST_RNN_ID: 1252 case LPORT_ST_RNN_ID:
1327 fc_lport_enter_rnn_id(lport);
1328 break;
1329 case LPORT_ST_RSNN_NN: 1253 case LPORT_ST_RSNN_NN:
1330 fc_lport_enter_rsnn_nn(lport);
1331 break;
1332 case LPORT_ST_RSPN_ID: 1254 case LPORT_ST_RSPN_ID:
1333 fc_lport_enter_rspn_id(lport);
1334 break;
1335 case LPORT_ST_RFT_ID: 1255 case LPORT_ST_RFT_ID:
1336 fc_lport_enter_rft_id(lport); 1256 fc_lport_enter_ns(lport, lport->state);
1337 break; 1257 break;
1338 case LPORT_ST_SCR: 1258 case LPORT_ST_SCR:
1339 fc_lport_enter_scr(lport); 1259 fc_lport_enter_scr(lport);