0001
0002
0003
0004
0005
0006
0007 #ifndef _FC_ENCAPS_H_
0008 #define _FC_ENCAPS_H_
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #define FC_ENCAPS_MIN_FRAME_LEN 64
0019 #define FC_ENCAPS_MAX_FRAME_LEN (FC_ENCAPS_MIN_FRAME_LEN + FC_MAX_PAYLOAD)
0020
0021 #define FC_ENCAPS_VER 1
0022
0023 struct fc_encaps_hdr {
0024 __u8 fc_proto;
0025 __u8 fc_ver;
0026 __u8 fc_proto_n;
0027 __u8 fc_ver_n;
0028
0029 unsigned char fc_proto_data[8];
0030
0031 __be16 fc_len_flags;
0032 __be16 fc_len_flags_n;
0033
0034
0035
0036
0037 __be32 fc_time[2];
0038 __be32 fc_crc;
0039 __be32 fc_sof;
0040
0041
0042 };
0043
0044 #define FCIP_ENCAPS_HDR_LEN 0x20
0045
0046
0047
0048
0049 #define FC_XY(x, y) ((((x) & 0xff) << 8) | ((y) & 0xff))
0050 #define FC_XYXY(x, y) ((FCIP_XY(x, y) << 16) | FCIP_XY(x, y))
0051 #define FC_XYNN(x, y) (FCIP_XYXY(x, y) ^ 0xffff)
0052
0053 #define FC_SOF_ENCODE(n) FC_XYNN(n, n)
0054 #define FC_EOF_ENCODE(n) FC_XYNN(n, n)
0055
0056
0057
0058
0059 enum fc_sof {
0060 FC_SOF_F = 0x28,
0061 FC_SOF_I4 = 0x29,
0062 FC_SOF_I2 = 0x2d,
0063 FC_SOF_I3 = 0x2e,
0064 FC_SOF_N4 = 0x31,
0065 FC_SOF_N2 = 0x35,
0066 FC_SOF_N3 = 0x36,
0067 FC_SOF_C4 = 0x39,
0068 } __attribute__((packed));
0069
0070 enum fc_eof {
0071 FC_EOF_N = 0x41,
0072 FC_EOF_T = 0x42,
0073 FC_EOF_RT = 0x44,
0074 FC_EOF_DT = 0x46,
0075 FC_EOF_NI = 0x49,
0076 FC_EOF_DTI = 0x4e,
0077 FC_EOF_RTI = 0x4f,
0078 FC_EOF_A = 0x50,
0079 } __attribute__((packed));
0080
0081 #define FC_SOF_CLASS_MASK 0x06
0082
0083
0084
0085
0086 enum fc_class {
0087 FC_CLASS_NONE = 0,
0088 FC_CLASS_2 = FC_SOF_I2,
0089 FC_CLASS_3 = FC_SOF_I3,
0090 FC_CLASS_4 = FC_SOF_I4,
0091 FC_CLASS_F = FC_SOF_F,
0092 };
0093
0094
0095
0096
0097 static inline int fc_sof_needs_ack(enum fc_sof sof)
0098 {
0099 return (~sof) & 0x02;
0100 }
0101
0102
0103
0104
0105 static inline enum fc_sof fc_sof_normal(enum fc_class class)
0106 {
0107 return class + FC_SOF_N3 - FC_SOF_I3;
0108 }
0109
0110
0111
0112
0113 static inline enum fc_class fc_sof_class(enum fc_sof sof)
0114 {
0115 return (sof & 0x7) | FC_SOF_F;
0116 }
0117
0118
0119
0120
0121 static inline int fc_sof_is_init(enum fc_sof sof)
0122 {
0123 return sof < 0x30;
0124 }
0125
0126 #endif