diff options
author | Chris Leech <christopher.leech@intel.com> | 2009-11-03 14:46:56 -0500 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2009-12-04 13:01:02 -0500 |
commit | 5baa17c3e66fc2e414f501b2dd59b962dfc64919 (patch) | |
tree | 8194fcceb647f6740bdf6350da2a2d9dc393ae3e /drivers/scsi/libfc | |
parent | c9c7bd7a5e7321aa96289c9b48fdbcc828c105e6 (diff) |
[SCSI] libfc: Register Symbolic Node Name (RSNN_NN)
Register the fc_host symbolic name as the symbolic node name
with the fabric name server.
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.c | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c index 897b5a8487e2..cc389c03f698 100644 --- a/drivers/scsi/libfc/fc_lport.c +++ b/drivers/scsi/libfc/fc_lport.c | |||
@@ -109,6 +109,7 @@ static void fc_lport_enter_reset(struct fc_lport *); | |||
109 | static void fc_lport_enter_flogi(struct fc_lport *); | 109 | static void fc_lport_enter_flogi(struct fc_lport *); |
110 | static void fc_lport_enter_dns(struct fc_lport *); | 110 | static void fc_lport_enter_dns(struct fc_lport *); |
111 | static void fc_lport_enter_rnn_id(struct fc_lport *); | 111 | static void fc_lport_enter_rnn_id(struct fc_lport *); |
112 | static void fc_lport_enter_rsnn_nn(struct fc_lport *); | ||
112 | static void fc_lport_enter_rft_id(struct fc_lport *); | 113 | static void fc_lport_enter_rft_id(struct fc_lport *); |
113 | static void fc_lport_enter_scr(struct fc_lport *); | 114 | static void fc_lport_enter_scr(struct fc_lport *); |
114 | static void fc_lport_enter_ready(struct fc_lport *); | 115 | static void fc_lport_enter_ready(struct fc_lport *); |
@@ -119,6 +120,7 @@ static const char *fc_lport_state_names[] = { | |||
119 | [LPORT_ST_FLOGI] = "FLOGI", | 120 | [LPORT_ST_FLOGI] = "FLOGI", |
120 | [LPORT_ST_DNS] = "dNS", | 121 | [LPORT_ST_DNS] = "dNS", |
121 | [LPORT_ST_RNN_ID] = "RNN_ID", | 122 | [LPORT_ST_RNN_ID] = "RNN_ID", |
123 | [LPORT_ST_RSNN_NN] = "RSNN_NN", | ||
122 | [LPORT_ST_RFT_ID] = "RFT_ID", | 124 | [LPORT_ST_RFT_ID] = "RFT_ID", |
123 | [LPORT_ST_SCR] = "SCR", | 125 | [LPORT_ST_SCR] = "SCR", |
124 | [LPORT_ST_READY] = "Ready", | 126 | [LPORT_ST_READY] = "Ready", |
@@ -966,6 +968,7 @@ static void fc_lport_error(struct fc_lport *lport, struct fc_frame *fp) | |||
966 | case LPORT_ST_READY: | 968 | case LPORT_ST_READY: |
967 | case LPORT_ST_RESET: | 969 | case LPORT_ST_RESET: |
968 | case LPORT_ST_RNN_ID: | 970 | case LPORT_ST_RNN_ID: |
971 | case LPORT_ST_RSNN_NN: | ||
969 | case LPORT_ST_RFT_ID: | 972 | case LPORT_ST_RFT_ID: |
970 | case LPORT_ST_SCR: | 973 | case LPORT_ST_SCR: |
971 | case LPORT_ST_DNS: | 974 | case LPORT_ST_DNS: |
@@ -1033,6 +1036,60 @@ err: | |||
1033 | } | 1036 | } |
1034 | 1037 | ||
1035 | /** | 1038 | /** |
1039 | * fc_lport_rsnn_nn_resp() - Handle response to Register Symbolic Node Name | ||
1040 | * by Node Name (RSNN_NN) request | ||
1041 | * @sp: current sequence in RSNN_NN exchange | ||
1042 | * @fp: response frame | ||
1043 | * @lp_arg: Fibre Channel host port instance | ||
1044 | * | ||
1045 | * Locking Note: This function will be called without the lport lock | ||
1046 | * held, but it will lock, call an _enter_* function or fc_lport_error | ||
1047 | * and then unlock the lport. | ||
1048 | */ | ||
1049 | static void fc_lport_rsnn_nn_resp(struct fc_seq *sp, struct fc_frame *fp, | ||
1050 | void *lp_arg) | ||
1051 | { | ||
1052 | struct fc_lport *lport = lp_arg; | ||
1053 | struct fc_frame_header *fh; | ||
1054 | struct fc_ct_hdr *ct; | ||
1055 | |||
1056 | FC_LPORT_DBG(lport, "Received a RSNN_NN %s\n", fc_els_resp_type(fp)); | ||
1057 | |||
1058 | if (fp == ERR_PTR(-FC_EX_CLOSED)) | ||
1059 | return; | ||
1060 | |||
1061 | mutex_lock(&lport->lp_mutex); | ||
1062 | |||
1063 | if (lport->state != LPORT_ST_RSNN_NN) { | ||
1064 | FC_LPORT_DBG(lport, "Received a RSNN_NN response, but in state " | ||
1065 | "%s\n", fc_lport_state(lport)); | ||
1066 | if (IS_ERR(fp)) | ||
1067 | goto err; | ||
1068 | goto out; | ||
1069 | } | ||
1070 | |||
1071 | if (IS_ERR(fp)) { | ||
1072 | fc_lport_error(lport, fp); | ||
1073 | goto err; | ||
1074 | } | ||
1075 | |||
1076 | fh = fc_frame_header_get(fp); | ||
1077 | ct = fc_frame_payload_get(fp, sizeof(*ct)); | ||
1078 | if (fh && ct && fh->fh_type == FC_TYPE_CT && | ||
1079 | ct->ct_fs_type == FC_FST_DIR && | ||
1080 | ct->ct_fs_subtype == FC_NS_SUBTYPE && | ||
1081 | ntohs(ct->ct_cmd) == FC_FS_ACC) | ||
1082 | fc_lport_enter_rsnn_nn(lport); | ||
1083 | else | ||
1084 | fc_lport_error(lport, fp); | ||
1085 | |||
1086 | out: | ||
1087 | fc_frame_free(fp); | ||
1088 | err: | ||
1089 | mutex_unlock(&lport->lp_mutex); | ||
1090 | } | ||
1091 | |||
1092 | /** | ||
1036 | * fc_lport_rnn_id_resp() - Handle response to Register Node | 1093 | * fc_lport_rnn_id_resp() - Handle response to Register Node |
1037 | * Name by ID (RNN_ID) request | 1094 | * Name by ID (RNN_ID) request |
1038 | * @sp: current sequence in RNN_ID exchange | 1095 | * @sp: current sequence in RNN_ID exchange |
@@ -1204,6 +1261,37 @@ static void fc_lport_enter_rft_id(struct fc_lport *lport) | |||
1204 | } | 1261 | } |
1205 | 1262 | ||
1206 | /** | 1263 | /** |
1264 | * fc_rport_enter_rsnn_nn() - Register symbolic node name with the name server | ||
1265 | * @lport: Fibre Channel local port to register | ||
1266 | * | ||
1267 | * Locking Note: The lport lock is expected to be held before calling | ||
1268 | * this routine. | ||
1269 | */ | ||
1270 | static void fc_lport_enter_rsnn_nn(struct fc_lport *lport) | ||
1271 | { | ||
1272 | struct fc_frame *fp; | ||
1273 | size_t len; | ||
1274 | |||
1275 | FC_LPORT_DBG(lport, "Entered RSNN_NN state from %s state\n", | ||
1276 | fc_lport_state(lport)); | ||
1277 | |||
1278 | fc_lport_state_enter(lport, LPORT_ST_RSNN_NN); | ||
1279 | |||
1280 | len = strnlen(fc_host_symbolic_name(lport->host), 255); | ||
1281 | fp = fc_frame_alloc(lport, sizeof(struct fc_ct_hdr) + | ||
1282 | sizeof(struct fc_ns_rsnn) + len); | ||
1283 | if (!fp) { | ||
1284 | fc_lport_error(lport, fp); | ||
1285 | return; | ||
1286 | } | ||
1287 | |||
1288 | if (!lport->tt.elsct_send(lport, FC_FID_DIR_SERV, fp, FC_NS_RSNN_NN, | ||
1289 | fc_lport_rsnn_nn_resp, | ||
1290 | lport, lport->e_d_tov)) | ||
1291 | fc_lport_error(lport, fp); | ||
1292 | } | ||
1293 | |||
1294 | /** | ||
1207 | * fc_rport_enter_rnn_id() - Register node name with the name server | 1295 | * fc_rport_enter_rnn_id() - Register node name with the name server |
1208 | * @lport: Fibre Channel local port to register | 1296 | * @lport: Fibre Channel local port to register |
1209 | * | 1297 | * |
@@ -1296,6 +1384,9 @@ static void fc_lport_timeout(struct work_struct *work) | |||
1296 | case LPORT_ST_RNN_ID: | 1384 | case LPORT_ST_RNN_ID: |
1297 | fc_lport_enter_rnn_id(lport); | 1385 | fc_lport_enter_rnn_id(lport); |
1298 | break; | 1386 | break; |
1387 | case LPORT_ST_RSNN_NN: | ||
1388 | fc_lport_enter_rsnn_nn(lport); | ||
1389 | break; | ||
1299 | case LPORT_ST_RFT_ID: | 1390 | case LPORT_ST_RFT_ID: |
1300 | fc_lport_enter_rft_id(lport); | 1391 | fc_lport_enter_rft_id(lport); |
1301 | break; | 1392 | break; |