Skip to content

Commit 73ec6d2

Browse files
jsmart-ghmartinkpetersen
authored andcommitted
scsi: fc: Update Descriptor definition and add RDF and Link Integrity FPINs
Update the FC headers for the RDF ELS and populate out the FPIN ELS and the Link integrity FPIN payload. RDF is used to register for diagnostic events. FPIN is how the fabric reports a diagnostic event. Specifically, this patch: - Adds the formal definition of TLV descriptors that are now used in a lot of the FC spec. The simplistic fc_fn_desc structure, basically no more than the tlv definition, is removed. - Small tlv helper functions are added as defines. - The list of known Descriptor tags (identifying the TLV) is expanded and a name initializer introduced. - The LSRI descriptor, returned in many new ELS response payloads is added. - The RDF ELS code is added, and the RDF request response structures added. - The FPIN els definition is corrected. - A full definition of a Link Integrity Notification descriptor is added, [mkp: rolled in kbuild warning fix] Link: https://lore.kernel.org/r/20200210173155.547-2-jsmart2021@gmail.com Reported-by: kbuild test robot <lkp@intel.com> Signed-off-by: James Smart <jsmart2021@gmail.com> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 5693340 commit 73ec6d2

1 file changed

Lines changed: 196 additions & 15 deletions

File tree

‎include/uapi/scsi/fc/fc_els.h‎

Lines changed: 196 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#define _FC_ELS_H_
1010

1111
#include <linux/types.h>
12+
#include <asm/byteorder.h>
1213

1314
/*
1415
* Fibre Channel Switch - Enhanced Link Services definitions.
@@ -40,6 +41,7 @@ enum fc_els_cmd {
4041
ELS_REC = 0x13, /* read exchange concise */
4142
ELS_SRR = 0x14, /* sequence retransmission request */
4243
ELS_FPIN = 0x16, /* Fabric Performance Impact Notification */
44+
ELS_RDF = 0x19, /* Register Diagnostic Functions */
4345
ELS_PRLI = 0x20, /* process login */
4446
ELS_PRLO = 0x21, /* process logout */
4547
ELS_SCN = 0x22, /* state change notification */
@@ -108,6 +110,7 @@ enum fc_els_cmd {
108110
[ELS_REC] = "REC", \
109111
[ELS_SRR] = "SRR", \
110112
[ELS_FPIN] = "FPIN", \
113+
[ELS_RDF] = "RDF", \
111114
[ELS_PRLI] = "PRLI", \
112115
[ELS_PRLO] = "PRLO", \
113116
[ELS_SCN] = "SCN", \
@@ -207,6 +210,99 @@ enum fc_els_rjt_explan {
207210
/* TBD - above definitions incomplete */
208211
};
209212

213+
/*
214+
* Link Service TLV Descriptor Tag Values
215+
*/
216+
enum fc_ls_tlv_dtag {
217+
ELS_DTAG_LS_REQ_INFO = 0x00000001,
218+
/* Link Service Request Information Descriptor */
219+
ELS_DTAG_LNK_INTEGRITY = 0x00020001,
220+
/* Link Integrity Notification Descriptor */
221+
ELS_DTAG_DELIVERY = 0x00020002,
222+
/* Delivery Notification Descriptor */
223+
ELS_DTAG_PEER_CONGEST = 0x00020003,
224+
/* Peer Congestion Notification Descriptor */
225+
ELS_DTAG_CONGESTION = 0x00020004,
226+
/* Congestion Notification Descriptor */
227+
ELS_DTAG_FPIN_REGISTER = 0x00030001,
228+
/* FPIN Registration Descriptor */
229+
};
230+
231+
/*
232+
* Initializer useful for decoding table.
233+
* Please keep this in sync with the above definitions.
234+
*/
235+
#define FC_LS_TLV_DTAG_INIT { \
236+
{ ELS_DTAG_LS_REQ_INFO, "Link Service Request Information" }, \
237+
{ ELS_DTAG_LNK_INTEGRITY, "Link Integrity Notification" }, \
238+
{ ELS_DTAG_DELIVERY, "Delivery Notification Present" }, \
239+
{ ELS_DTAG_PEER_CONGEST, "Peer Congestion Notification" }, \
240+
{ ELS_DTAG_CONGESTION, "Congestion Notification" }, \
241+
{ ELS_DTAG_FPIN_REGISTER, "FPIN Registration" }, \
242+
}
243+
244+
245+
/*
246+
* Generic Link Service TLV Descriptor format
247+
*
248+
* This structure, as it defines no payload, will also be referred to
249+
* as the "tlv header" - which contains the tag and len fields.
250+
*/
251+
struct fc_tlv_desc {
252+
__be32 desc_tag; /* Notification Descriptor Tag */
253+
__be32 desc_len; /* Length of Descriptor (in bytes).
254+
* Size of descriptor excluding
255+
* desc_tag and desc_len fields.
256+
*/
257+
__u8 desc_value[0]; /* Descriptor Value */
258+
};
259+
260+
/* Descriptor tag and len fields are considered the mandatory header
261+
* for a descriptor
262+
*/
263+
#define FC_TLV_DESC_HDR_SZ sizeof(struct fc_tlv_desc)
264+
265+
/*
266+
* Macro, used when initializing payloads, to return the descriptor length.
267+
* Length is size of descriptor minus the tag and len fields.
268+
*/
269+
#define FC_TLV_DESC_LENGTH_FROM_SZ(desc) \
270+
(sizeof(desc) - FC_TLV_DESC_HDR_SZ)
271+
272+
/* Macro, used on received payloads, to return the descriptor length */
273+
#define FC_TLV_DESC_SZ_FROM_LENGTH(tlv) \
274+
(__be32_to_cpu((tlv)->desc_len) + FC_TLV_DESC_HDR_SZ)
275+
276+
/*
277+
* This helper is used to walk descriptors in a descriptor list.
278+
* Given the address of the current descriptor, which minimally contains a
279+
* tag and len field, calculate the address of the next descriptor based
280+
* on the len field.
281+
*/
282+
static inline void *fc_tlv_next_desc(void *desc)
283+
{
284+
struct fc_tlv_desc *tlv = desc;
285+
286+
return (desc + FC_TLV_DESC_SZ_FROM_LENGTH(tlv));
287+
}
288+
289+
290+
/*
291+
* Link Service Request Information Descriptor
292+
*/
293+
struct fc_els_lsri_desc {
294+
__be32 desc_tag; /* descriptor tag (0x0000 0001) */
295+
__be32 desc_len; /* Length of Descriptor (in bytes) (4).
296+
* Size of descriptor excluding
297+
* desc_tag and desc_len fields.
298+
*/
299+
struct {
300+
__u8 cmd; /* ELS cmd byte */
301+
__u8 bytes[3]; /* bytes 1..3 */
302+
} rqst_w0; /* Request word 0 */
303+
};
304+
305+
210306
/*
211307
* Common service parameters (N ports).
212308
*/
@@ -819,24 +915,61 @@ enum fc_els_clid_ic {
819915
};
820916

821917

918+
enum fc_fpin_li_event_types {
919+
FPIN_LI_UNKNOWN = 0x0,
920+
FPIN_LI_LINK_FAILURE = 0x1,
921+
FPIN_LI_LOSS_OF_SYNC = 0x2,
922+
FPIN_LI_LOSS_OF_SIG = 0x3,
923+
FPIN_LI_PRIM_SEQ_ERR = 0x4,
924+
FPIN_LI_INVALID_TX_WD = 0x5,
925+
FPIN_LI_INVALID_CRC = 0x6,
926+
FPIN_LI_DEVICE_SPEC = 0xF,
927+
};
928+
822929
/*
823-
* Fabric Notification Descriptor Tag values
930+
* Initializer useful for decoding table.
931+
* Please keep this in sync with the above definitions.
824932
*/
825-
enum fc_fn_dtag {
826-
ELS_FN_DTAG_LNK_INTEGRITY = 0x00020001, /* Link Integrity */
827-
ELS_FN_DTAG_PEER_CONGEST = 0x00020003, /* Peer Congestion */
828-
ELS_FN_DTAG_CONGESTION = 0x00020004, /* Congestion */
829-
};
933+
#define FC_FPIN_LI_EVT_TYPES_INIT { \
934+
{ FPIN_LI_UNKNOWN, "Unknown" }, \
935+
{ FPIN_LI_LINK_FAILURE, "Link Failure" }, \
936+
{ FPIN_LI_LOSS_OF_SYNC, "Loss of Synchronization" }, \
937+
{ FPIN_LI_LOSS_OF_SIG, "Loss of Signal" }, \
938+
{ FPIN_LI_PRIM_SEQ_ERR, "Primitive Sequence Protocol Error" }, \
939+
{ FPIN_LI_INVALID_TX_WD, "Invalid Transmission Word" }, \
940+
{ FPIN_LI_INVALID_CRC, "Invalid CRC" }, \
941+
{ FPIN_LI_DEVICE_SPEC, "Device Specific" }, \
942+
}
943+
830944

831945
/*
832-
* Fabric Notification Descriptor
946+
* Link Integrity Notification Descriptor
833947
*/
834-
struct fc_fn_desc {
835-
__be32 fn_desc_tag; /* Notification Descriptor Tag */
836-
__be32 fn_desc_value_len; /* Length of Descriptor Value field
837-
* (in bytes)
838-
*/
839-
__u8 fn_desc_value[0]; /* Descriptor Value */
948+
struct fc_fn_li_desc {
949+
__be32 desc_tag; /* Descriptor Tag (0x00020001) */
950+
__be32 desc_len; /* Length of Descriptor (in bytes).
951+
* Size of descriptor excluding
952+
* desc_tag and desc_len fields.
953+
*/
954+
__be64 detecting_wwpn; /* Port Name that detected event */
955+
__be64 attached_wwpn; /* Port Name of device attached to
956+
* detecting Port Name
957+
*/
958+
__be16 event_type; /* see enum fc_fpin_li_event_types */
959+
__be16 event_modifier; /* Implementation specific value
960+
* describing the event type
961+
*/
962+
__be32 event_threshold;/* duration in ms of the link
963+
* integrity detection cycle
964+
*/
965+
__be32 event_count; /* minimum number of event
966+
* occurrences during the event
967+
* threshold to caause the LI event
968+
*/
969+
__be32 pname_count; /* number of portname_list elements */
970+
__be64 pname_list[0]; /* list of N_Port_Names accessible
971+
* through the attached port
972+
*/
840973
};
841974

842975
/*
@@ -845,8 +978,56 @@ struct fc_fn_desc {
845978
struct fc_els_fpin {
846979
__u8 fpin_cmd; /* command (0x16) */
847980
__u8 fpin_zero[3]; /* specified as zero - part of cmd */
848-
__be32 fpin_desc_cnt; /* count of descriptors */
849-
struct fc_fn_desc fpin_desc[0]; /* Descriptor list */
981+
__be32 desc_len; /* Length of Descriptor List (in bytes).
982+
* Size of ELS excluding fpin_cmd,
983+
* fpin_zero and desc_len fields.
984+
*/
985+
struct fc_tlv_desc fpin_desc[0]; /* Descriptor list */
986+
};
987+
988+
/* Diagnostic Function Descriptor - FPIN Registration */
989+
struct fc_df_desc_fpin_reg {
990+
__be32 desc_tag; /* FPIN Registration (0x00030001) */
991+
__be32 desc_len; /* Length of Descriptor (in bytes).
992+
* Size of descriptor excluding
993+
* desc_tag and desc_len fields.
994+
*/
995+
__be32 count; /* Number of desc_tags elements */
996+
__be32 desc_tags[0]; /* Array of Descriptor Tags.
997+
* Each tag indicates a function
998+
* supported by the N_Port (request)
999+
* or by the N_Port and Fabric
1000+
* Controller (reply; may be a subset
1001+
* of the request).
1002+
* See ELS_FN_DTAG_xxx for tag values.
1003+
*/
8501004
};
8511005

1006+
/*
1007+
* ELS_RDF - Register Diagnostic Functions
1008+
*/
1009+
struct fc_els_rdf {
1010+
__u8 fpin_cmd; /* command (0x19) */
1011+
__u8 fpin_zero[3]; /* specified as zero - part of cmd */
1012+
__be32 desc_len; /* Length of Descriptor List (in bytes).
1013+
* Size of ELS excluding fpin_cmd,
1014+
* fpin_zero and desc_len fields.
1015+
*/
1016+
struct fc_tlv_desc desc[0]; /* Descriptor list */
1017+
};
1018+
1019+
/*
1020+
* ELS RDF LS_ACC Response.
1021+
*/
1022+
struct fc_els_rdf_resp {
1023+
struct fc_els_ls_acc acc_hdr;
1024+
__be32 desc_list_len; /* Length of response (in
1025+
* bytes). Excludes acc_hdr
1026+
* and desc_list_len fields.
1027+
*/
1028+
struct fc_els_lsri_desc lsri;
1029+
struct fc_tlv_desc desc[0]; /* Supported Descriptor list */
1030+
};
1031+
1032+
8521033
#endif /* _FC_ELS_H_ */

0 commit comments

Comments
 (0)