diff options
| author | Chris Leech <christopher.leech@intel.com> | 2009-11-03 14:47:01 -0500 |
|---|---|---|
| committer | James Bottomley <James.Bottomley@suse.de> | 2009-12-04 13:01:02 -0500 |
| commit | c9866a548024c33e30f35a14bbcb71ba78266383 (patch) | |
| tree | 99c68b4f8292ccffd39645424cdd0965a867e161 | |
| parent | 5baa17c3e66fc2e414f501b2dd59b962dfc64919 (diff) | |
[SCSI] libfc: Register Symbolic Port Name (RSPN_ID)
Register the fc_host symbolic name as the symbolic port 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>
| -rw-r--r-- | drivers/scsi/libfc/fc_lport.c | 90 | ||||
| -rw-r--r-- | include/scsi/fc/fc_ns.h | 10 | ||||
| -rw-r--r-- | include/scsi/fc_encode.h | 11 | ||||
| -rw-r--r-- | include/scsi/libfc.h | 1 |
4 files changed, 112 insertions, 0 deletions
diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c index cc389c03f698..28a35da1493b 100644 --- a/drivers/scsi/libfc/fc_lport.c +++ b/drivers/scsi/libfc/fc_lport.c | |||
| @@ -110,6 +110,7 @@ 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_rsnn_nn(struct fc_lport *); |
| 113 | static void fc_lport_enter_rspn_id(struct fc_lport *); | ||
| 113 | static void fc_lport_enter_rft_id(struct fc_lport *); | 114 | static void fc_lport_enter_rft_id(struct fc_lport *); |
| 114 | static void fc_lport_enter_scr(struct fc_lport *); | 115 | static void fc_lport_enter_scr(struct fc_lport *); |
| 115 | static void fc_lport_enter_ready(struct fc_lport *); | 116 | static void fc_lport_enter_ready(struct fc_lport *); |
| @@ -121,6 +122,7 @@ static const char *fc_lport_state_names[] = { | |||
| 121 | [LPORT_ST_DNS] = "dNS", | 122 | [LPORT_ST_DNS] = "dNS", |
| 122 | [LPORT_ST_RNN_ID] = "RNN_ID", | 123 | [LPORT_ST_RNN_ID] = "RNN_ID", |
| 123 | [LPORT_ST_RSNN_NN] = "RSNN_NN", | 124 | [LPORT_ST_RSNN_NN] = "RSNN_NN", |
| 125 | [LPORT_ST_RSPN_ID] = "RSPN_ID", | ||
| 124 | [LPORT_ST_RFT_ID] = "RFT_ID", | 126 | [LPORT_ST_RFT_ID] = "RFT_ID", |
| 125 | [LPORT_ST_SCR] = "SCR", | 127 | [LPORT_ST_SCR] = "SCR", |
| 126 | [LPORT_ST_READY] = "Ready", | 128 | [LPORT_ST_READY] = "Ready", |
| @@ -969,6 +971,7 @@ static void fc_lport_error(struct fc_lport *lport, struct fc_frame *fp) | |||
| 969 | case LPORT_ST_RESET: | 971 | case LPORT_ST_RESET: |
| 970 | case LPORT_ST_RNN_ID: | 972 | case LPORT_ST_RNN_ID: |
| 971 | case LPORT_ST_RSNN_NN: | 973 | case LPORT_ST_RSNN_NN: |
| 974 | case LPORT_ST_RSPN_ID: | ||
| 972 | case LPORT_ST_RFT_ID: | 975 | case LPORT_ST_RFT_ID: |
| 973 | case LPORT_ST_SCR: | 976 | case LPORT_ST_SCR: |
| 974 | case LPORT_ST_DNS: | 977 | case LPORT_ST_DNS: |
| @@ -1036,6 +1039,59 @@ err: | |||
| 1036 | } | 1039 | } |
| 1037 | 1040 | ||
| 1038 | /** | 1041 | /** |
| 1042 | * fc_lport_rspn_id_resp() - Handle response to Register Symbolic Port Name | ||
| 1043 | * by ID (RSPN_ID) request | ||
| 1044 | * @sp: current sequence in RSPN_ID exchange | ||
| 1045 | * @fp: response frame | ||
| 1046 | * @lp_arg: Fibre Channel host port instance | ||
| 1047 | * | ||
| 1048 | * Locking Note: This function will be called without the lport lock | ||
| 1049 | * held, but it will lock, call an _enter_* function or fc_lport_error | ||
| 1050 | * and then unlock the lport. | ||
| 1051 | */ | ||
| 1052 | static void fc_lport_rspn_id_resp(struct fc_seq *sp, struct fc_frame *fp, | ||
| 1053 | void *lp_arg) | ||
| 1054 | { | ||
| 1055 | struct fc_lport *lport = lp_arg; | ||
| 1056 | struct fc_frame_header *fh; | ||
| 1057 | struct fc_ct_hdr *ct; | ||
| 1058 | |||
| 1059 | FC_LPORT_DBG(lport, "Received a RSPN_ID %s\n", fc_els_resp_type(fp)); | ||
| 1060 | |||
| 1061 | if (fp == ERR_PTR(-FC_EX_CLOSED)) | ||
| 1062 | return; | ||
| 1063 | |||
| 1064 | mutex_lock(&lport->lp_mutex); | ||
| 1065 | |||
| 1066 | if (lport->state != LPORT_ST_RSPN_ID) { | ||
| 1067 | FC_LPORT_DBG(lport, "Received a RSPN_ID response, but in state " | ||
| 1068 | "%s\n", fc_lport_state(lport)); | ||
| 1069 | if (IS_ERR(fp)) | ||
| 1070 | goto err; | ||
| 1071 | goto out; | ||
| 1072 | } | ||
| 1073 | |||
| 1074 | if (IS_ERR(fp)) { | ||
| 1075 | fc_lport_error(lport, fp); | ||
| 1076 | goto err; | ||
| 1077 | } | ||
| 1078 | |||
| 1079 | fh = fc_frame_header_get(fp); | ||
| 1080 | ct = fc_frame_payload_get(fp, sizeof(*ct)); | ||
| 1081 | if (fh && ct && fh->fh_type == FC_TYPE_CT && | ||
| 1082 | ct->ct_fs_type == FC_FST_DIR && | ||
| 1083 | ct->ct_fs_subtype == FC_NS_SUBTYPE && | ||
| 1084 | ntohs(ct->ct_cmd) == FC_FS_ACC) | ||
| 1085 | fc_lport_enter_rspn_id(lport); | ||
| 1086 | else | ||
| 1087 | fc_lport_error(lport, fp); | ||
| 1088 | |||
| 1089 | out: | ||
| 1090 | fc_frame_free(fp); | ||
| 1091 | err: | ||
| 1092 | mutex_unlock(&lport->lp_mutex); | ||
| 1093 | } | ||
| 1094 | /** | ||
| 1039 | * fc_lport_rsnn_nn_resp() - Handle response to Register Symbolic Node Name | 1095 | * fc_lport_rsnn_nn_resp() - Handle response to Register Symbolic Node Name |
| 1040 | * by Node Name (RSNN_NN) request | 1096 | * by Node Name (RSNN_NN) request |
| 1041 | * @sp: current sequence in RSNN_NN exchange | 1097 | * @sp: current sequence in RSNN_NN exchange |
| @@ -1261,6 +1317,37 @@ static void fc_lport_enter_rft_id(struct fc_lport *lport) | |||
| 1261 | } | 1317 | } |
| 1262 | 1318 | ||
| 1263 | /** | 1319 | /** |
| 1320 | * fc_rport_enter_rspn_id() - Register symbolic port name with the name server | ||
| 1321 | * @lport: Fibre Channel local port to register | ||
| 1322 | * | ||
| 1323 | * Locking Note: The lport lock is expected to be held before calling | ||
| 1324 | * this routine. | ||
| 1325 | */ | ||
| 1326 | static void fc_lport_enter_rspn_id(struct fc_lport *lport) | ||
| 1327 | { | ||
| 1328 | struct fc_frame *fp; | ||
| 1329 | size_t len; | ||
| 1330 | |||
| 1331 | FC_LPORT_DBG(lport, "Entered RSPN_ID state from %s state\n", | ||
| 1332 | fc_lport_state(lport)); | ||
| 1333 | |||
| 1334 | fc_lport_state_enter(lport, LPORT_ST_RSPN_ID); | ||
| 1335 | |||
| 1336 | len = strnlen(fc_host_symbolic_name(lport->host), 255); | ||
| 1337 | fp = fc_frame_alloc(lport, sizeof(struct fc_ct_hdr) + | ||
| 1338 | sizeof(struct fc_ns_rspn) + len); | ||
| 1339 | if (!fp) { | ||
| 1340 | fc_lport_error(lport, fp); | ||
| 1341 | return; | ||
| 1342 | } | ||
| 1343 | |||
| 1344 | if (!lport->tt.elsct_send(lport, FC_FID_DIR_SERV, fp, FC_NS_RSPN_ID, | ||
| 1345 | fc_lport_rspn_id_resp, | ||
| 1346 | lport, lport->e_d_tov)) | ||
| 1347 | fc_lport_error(lport, fp); | ||
| 1348 | } | ||
| 1349 | |||
| 1350 | /** | ||
| 1264 | * fc_rport_enter_rsnn_nn() - Register symbolic node name with the name server | 1351 | * fc_rport_enter_rsnn_nn() - Register symbolic node name with the name server |
| 1265 | * @lport: Fibre Channel local port to register | 1352 | * @lport: Fibre Channel local port to register |
| 1266 | * | 1353 | * |
| @@ -1387,6 +1474,9 @@ static void fc_lport_timeout(struct work_struct *work) | |||
| 1387 | case LPORT_ST_RSNN_NN: | 1474 | case LPORT_ST_RSNN_NN: |
| 1388 | fc_lport_enter_rsnn_nn(lport); | 1475 | fc_lport_enter_rsnn_nn(lport); |
| 1389 | break; | 1476 | break; |
| 1477 | case LPORT_ST_RSPN_ID: | ||
| 1478 | fc_lport_enter_rspn_id(lport); | ||
| 1479 | break; | ||
| 1390 | case LPORT_ST_RFT_ID: | 1480 | case LPORT_ST_RFT_ID: |
| 1391 | fc_lport_enter_rft_id(lport); | 1481 | fc_lport_enter_rft_id(lport); |
| 1392 | break; | 1482 | break; |
diff --git a/include/scsi/fc/fc_ns.h b/include/scsi/fc/fc_ns.h index fa8283056325..3fd59a2cb81f 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_RSPN_ID = 0x0218, /* reg symbolic port name */ | ||
| 50 | FC_NS_RSNN_NN = 0x0239, /* reg symbolic node name */ | 51 | FC_NS_RSNN_NN = 0x0239, /* reg symbolic node name */ |
| 51 | }; | 52 | }; |
| 52 | 53 | ||
| @@ -166,4 +167,13 @@ struct fc_ns_rsnn { | |||
| 166 | char fr_name[]; | 167 | char fr_name[]; |
| 167 | } __attribute__((__packed__)); | 168 | } __attribute__((__packed__)); |
| 168 | 169 | ||
| 170 | /* | ||
| 171 | * RSPN_ID request - register symbolic port name | ||
| 172 | */ | ||
| 173 | struct fc_ns_rspn { | ||
| 174 | struct fc_ns_fid fr_fid; /* port ID object */ | ||
| 175 | __u8 fr_name_len; | ||
| 176 | char fr_name[]; | ||
| 177 | } __attribute__((__packed__)); | ||
| 178 | |||
| 169 | #endif /* _FC_NS_H_ */ | 179 | #endif /* _FC_NS_H_ */ |
diff --git a/include/scsi/fc_encode.h b/include/scsi/fc_encode.h index 89981afba72d..9afcbb94ec30 100644 --- a/include/scsi/fc_encode.h +++ b/include/scsi/fc_encode.h | |||
| @@ -34,6 +34,7 @@ struct fc_ct_req { | |||
| 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 | struct fc_ns_rsnn snn; |
| 37 | struct fc_ns_rspn spn; | ||
| 37 | } payload; | 38 | } payload; |
| 38 | }; | 39 | }; |
| 39 | 40 | ||
| @@ -137,6 +138,16 @@ static inline int fc_ct_fill(struct fc_lport *lport, | |||
| 137 | put_unaligned_be64(lport->wwnn, &ct->payload.rn.fr_wwn); | 138 | put_unaligned_be64(lport->wwnn, &ct->payload.rn.fr_wwn); |
| 138 | break; | 139 | break; |
| 139 | 140 | ||
| 141 | case FC_NS_RSPN_ID: | ||
| 142 | ct = fc_ct_hdr_fill(fp, op, sizeof(struct fc_ns_rspn)); | ||
| 143 | hton24(ct->payload.spn.fr_fid.fp_fid, | ||
| 144 | fc_host_port_id(lport->host)); | ||
| 145 | strncpy(ct->payload.spn.fr_name, | ||
| 146 | fc_host_symbolic_name(lport->host), 255); | ||
| 147 | ct->payload.spn.fr_name_len = | ||
| 148 | strnlen(ct->payload.spn.fr_name, 255); | ||
| 149 | break; | ||
| 150 | |||
| 140 | case FC_NS_RSNN_NN: | 151 | case FC_NS_RSNN_NN: |
| 141 | ct = fc_ct_hdr_fill(fp, op, sizeof(struct fc_ns_rsnn)); | 152 | ct = fc_ct_hdr_fill(fp, op, sizeof(struct fc_ns_rsnn)); |
| 142 | put_unaligned_be64(lport->wwnn, &ct->payload.snn.fr_wwn); | 153 | put_unaligned_be64(lport->wwnn, &ct->payload.snn.fr_wwn); |
diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h index 1a632069c402..8258edfa328c 100644 --- a/include/scsi/libfc.h +++ b/include/scsi/libfc.h | |||
| @@ -63,6 +63,7 @@ enum fc_lport_state { | |||
| 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_RSNN_NN, |
| 66 | LPORT_ST_RSPN_ID, | ||
| 66 | LPORT_ST_RFT_ID, | 67 | LPORT_ST_RFT_ID, |
| 67 | LPORT_ST_SCR, | 68 | LPORT_ST_SCR, |
| 68 | LPORT_ST_READY, | 69 | LPORT_ST_READY, |
