@@ -109,6 +109,7 @@ static void fc_lport_enter_reset(struct fc_lport *);
109109static void fc_lport_enter_flogi (struct fc_lport * );
110110static void fc_lport_enter_dns (struct fc_lport * );
111111static void fc_lport_enter_rnn_id (struct fc_lport * );
112+ static void fc_lport_enter_rsnn_nn (struct fc_lport * );
112113static void fc_lport_enter_rft_id (struct fc_lport * );
113114static void fc_lport_enter_scr (struct fc_lport * );
114115static void fc_lport_enter_ready (struct fc_lport * );
@@ -119,6 +120,7 @@ static const char *fc_lport_state_names[] = {
119120 [LPORT_ST_FLOGI ] = "FLOGI" ,
120121 [LPORT_ST_DNS ] = "dNS" ,
121122 [LPORT_ST_RNN_ID ] = "RNN_ID" ,
123+ [LPORT_ST_RSNN_NN ] = "RSNN_NN" ,
122124 [LPORT_ST_RFT_ID ] = "RFT_ID" ,
123125 [LPORT_ST_SCR ] = "SCR" ,
124126 [LPORT_ST_READY ] = "Ready" ,
@@ -966,6 +968,7 @@ static void fc_lport_error(struct fc_lport *lport, struct fc_frame *fp)
966968 case LPORT_ST_READY :
967969 case LPORT_ST_RESET :
968970 case LPORT_ST_RNN_ID :
971+ case LPORT_ST_RSNN_NN :
969972 case LPORT_ST_RFT_ID :
970973 case LPORT_ST_SCR :
971974 case LPORT_ST_DNS :
@@ -1032,6 +1035,60 @@ static void fc_lport_rft_id_resp(struct fc_seq *sp, struct fc_frame *fp,
10321035 mutex_unlock (& lport -> lp_mutex );
10331036}
10341037
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+
10351092/**
10361093 * fc_lport_rnn_id_resp() - Handle response to Register Node
10371094 * Name by ID (RNN_ID) request
@@ -1203,6 +1260,37 @@ static void fc_lport_enter_rft_id(struct fc_lport *lport)
12031260 fc_lport_error (lport , fp );
12041261}
12051262
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+
12061294/**
12071295 * fc_rport_enter_rnn_id() - Register node name with the name server
12081296 * @lport: Fibre Channel local port to register
@@ -1296,6 +1384,9 @@ static void fc_lport_timeout(struct work_struct *work)
12961384 case LPORT_ST_RNN_ID :
12971385 fc_lport_enter_rnn_id (lport );
12981386 break ;
1387+ case LPORT_ST_RSNN_NN :
1388+ fc_lport_enter_rsnn_nn (lport );
1389+ break ;
12991390 case LPORT_ST_RFT_ID :
13001391 fc_lport_enter_rft_id (lport );
13011392 break ;
0 commit comments