diff options
-rw-r--r-- | drivers/scsi/fcoe/fcoe.c | 6 | ||||
-rw-r--r-- | drivers/scsi/libfc/fc_lport.c | 91 | ||||
-rw-r--r-- | include/scsi/fc/fc_ns.h | 10 | ||||
-rw-r--r-- | include/scsi/fc_encode.h | 10 | ||||
-rw-r--r-- | include/scsi/libfc.h | 1 |
5 files changed, 115 insertions, 3 deletions
diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c index f23cdb38d5c3..437eacf2732d 100644 --- a/drivers/scsi/fcoe/fcoe.c +++ b/drivers/scsi/fcoe/fcoe.c | |||
@@ -591,9 +591,9 @@ static int fcoe_shost_config(struct fc_lport *lp, struct Scsi_Host *shost, | |||
591 | if (!lp->vport) | 591 | if (!lp->vport) |
592 | fc_host_max_npiv_vports(lp->host) = USHORT_MAX; | 592 | fc_host_max_npiv_vports(lp->host) = USHORT_MAX; |
593 | 593 | ||
594 | sprintf(fc_host_symbolic_name(lp->host), "%s v%s over %s", | 594 | snprintf(fc_host_symbolic_name(lp->host), FC_SYMBOLIC_NAME_SIZE, |
595 | FCOE_NAME, FCOE_VERSION, | 595 | "%s v%s over %s", FCOE_NAME, FCOE_VERSION, |
596 | fcoe_netdev(lp)->name); | 596 | fcoe_netdev(lp)->name); |
597 | 597 | ||
598 | return 0; | 598 | return 0; |
599 | } | 599 | } |
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; |
diff --git a/include/scsi/fc/fc_ns.h b/include/scsi/fc/fc_ns.h index 790d7b97d4bc..fa8283056325 100644 --- a/include/scsi/fc/fc_ns.h +++ b/include/scsi/fc/fc_ns.h | |||
@@ -47,6 +47,7 @@ enum fc_ns_req { | |||
47 | FC_NS_RFT_ID = 0x0217, /* reg FC4 type for ID */ | 47 | FC_NS_RFT_ID = 0x0217, /* reg FC4 type for ID */ |
48 | FC_NS_RPN_ID = 0x0212, /* reg port name for ID */ | 48 | FC_NS_RPN_ID = 0x0212, /* reg port name for ID */ |
49 | FC_NS_RNN_ID = 0x0213, /* reg node name for ID */ | 49 | FC_NS_RNN_ID = 0x0213, /* reg node name for ID */ |
50 | FC_NS_RSNN_NN = 0x0239, /* reg symbolic node name */ | ||
50 | }; | 51 | }; |
51 | 52 | ||
52 | /* | 53 | /* |
@@ -156,4 +157,13 @@ struct fc_ns_rn_id { | |||
156 | __be64 fr_wwn; /* node name or port name */ | 157 | __be64 fr_wwn; /* node name or port name */ |
157 | } __attribute__((__packed__)); | 158 | } __attribute__((__packed__)); |
158 | 159 | ||
160 | /* | ||
161 | * RSNN_NN request - register symbolic node name | ||
162 | */ | ||
163 | struct fc_ns_rsnn { | ||
164 | __be64 fr_wwn; /* node name */ | ||
165 | __u8 fr_name_len; | ||
166 | char fr_name[]; | ||
167 | } __attribute__((__packed__)); | ||
168 | |||
159 | #endif /* _FC_NS_H_ */ | 169 | #endif /* _FC_NS_H_ */ |
diff --git a/include/scsi/fc_encode.h b/include/scsi/fc_encode.h index ad13cb1c3eec..89981afba72d 100644 --- a/include/scsi/fc_encode.h +++ b/include/scsi/fc_encode.h | |||
@@ -33,6 +33,7 @@ struct fc_ct_req { | |||
33 | struct fc_ns_rn_id rn; | 33 | struct fc_ns_rn_id rn; |
34 | struct fc_ns_rft rft; | 34 | struct fc_ns_rft rft; |
35 | struct fc_ns_fid fid; | 35 | struct fc_ns_fid fid; |
36 | struct fc_ns_rsnn snn; | ||
36 | } payload; | 37 | } payload; |
37 | }; | 38 | }; |
38 | 39 | ||
@@ -136,6 +137,15 @@ static inline int fc_ct_fill(struct fc_lport *lport, | |||
136 | put_unaligned_be64(lport->wwnn, &ct->payload.rn.fr_wwn); | 137 | put_unaligned_be64(lport->wwnn, &ct->payload.rn.fr_wwn); |
137 | break; | 138 | break; |
138 | 139 | ||
140 | case FC_NS_RSNN_NN: | ||
141 | ct = fc_ct_hdr_fill(fp, op, sizeof(struct fc_ns_rsnn)); | ||
142 | put_unaligned_be64(lport->wwnn, &ct->payload.snn.fr_wwn); | ||
143 | strncpy(ct->payload.snn.fr_name, | ||
144 | fc_host_symbolic_name(lport->host), 255); | ||
145 | ct->payload.snn.fr_name_len = | ||
146 | strnlen(ct->payload.snn.fr_name, 255); | ||
147 | break; | ||
148 | |||
139 | default: | 149 | default: |
140 | return -EINVAL; | 150 | return -EINVAL; |
141 | } | 151 | } |
diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h index 3d22dfd67209..1a632069c402 100644 --- a/include/scsi/libfc.h +++ b/include/scsi/libfc.h | |||
@@ -62,6 +62,7 @@ enum fc_lport_state { | |||
62 | LPORT_ST_FLOGI, | 62 | LPORT_ST_FLOGI, |
63 | LPORT_ST_DNS, | 63 | LPORT_ST_DNS, |
64 | LPORT_ST_RNN_ID, | 64 | LPORT_ST_RNN_ID, |
65 | LPORT_ST_RSNN_NN, | ||
65 | LPORT_ST_RFT_ID, | 66 | LPORT_ST_RFT_ID, |
66 | LPORT_ST_SCR, | 67 | LPORT_ST_SCR, |
67 | LPORT_ST_READY, | 68 | LPORT_ST_READY, |