| 1 |
|
| 2 | |
| 3 | * Copyright(c) 2007 Intel Corporation. All rights reserved.
|
| 4 | *
|
| 5 | * Maintained at www.Open-FCoE.org
|
| 6 |
|
| 7 | #ifndef _FC_ENCAPS_H_
|
| 8 | #define _FC_ENCAPS_H_
|
| 9 |
|
| 10 | |
| 11 | * Protocol definitions from RFC 3643 - Fibre Channel Frame Encapsulation.
|
| 12 | *
|
| 13 | * Note: The frame length field is the number of 32-bit words in
|
| 14 | * the encapsulation including the fcip_encaps_header, CRC and EOF words.
|
| 15 | * The minimum frame length value in bytes is (32 + 24 + 4 + 4) * 4 = 64.
|
| 16 | * The maximum frame length value in bytes is (32 + 24 + 2112 + 4 + 4) = 2172.
|
| 17 |
|
| 18 | #define FC_ENCAPS_MIN_FRAME_LEN 64
|
| 19 | #define FC_ENCAPS_MAX_FRAME_LEN (FC_ENCAPS_MIN_FRAME_LEN + FC_MAX_PAYLOAD)
|
| 20 |
|
| 21 | #define FC_ENCAPS_VER 1
|
| 22 |
|
| 23 | struct fc_encaps_hdr {
|
| 24 | __u8 fc_proto;
|
| 25 | __u8 fc_ver;
|
| 26 | __u8 fc_proto_n;
|
| 27 | __u8 fc_ver_n;
|
| 28 |
|
| 29 | unsigned char fc_proto_data[8];
|
| 30 |
|
| 31 | __be16 fc_len_flags;
|
| 32 | __be16 fc_len_flags_n;
|
| 33 |
|
| 34 | |
| 35 | * Offset 0x10
|
| 36 |
|
| 37 | __be32 fc_time[2];
|
| 38 | __be32 fc_crc;
|
| 39 | __be32 fc_sof;
|
| 40 |
|
| 41 |
|
| 42 | };
|
| 43 |
|
| 44 | #define FCIP_ENCAPS_HDR_LEN 0x20
|
| 45 |
|
| 46 | |
| 47 | * Macro's for making redundant copies of EOF and SOF.
|
| 48 |
|
| 49 | #define FC_XY(x, y) ((((x) & 0xff) << 8) | ((y) & 0xff))
|
| 50 | #define FC_XYXY(x, y) ((FCIP_XY(x, y) << 16) | FCIP_XY(x, y))
|
| 51 | #define FC_XYNN(x, y) (FCIP_XYXY(x, y) ^ 0xffff)
|
| 52 |
|
| 53 | #define FC_SOF_ENCODE(n) FC_XYNN(n, n)
|
| 54 | #define FC_EOF_ENCODE(n) FC_XYNN(n, n)
|
| 55 |
|
| 56 | |
| 57 | * SOF / EOF bytes.
|
| 58 |
|
| 59 | enum fc_sof {
|
| 60 | FC_SOF_F = 0x28,
|
| 61 | FC_SOF_I4 = 0x29,
|
| 62 | FC_SOF_I2 = 0x2d,
|
| 63 | FC_SOF_I3 = 0x2e,
|
| 64 | FC_SOF_N4 = 0x31,
|
| 65 | FC_SOF_N2 = 0x35,
|
| 66 | FC_SOF_N3 = 0x36,
|
| 67 | FC_SOF_C4 = 0x39,
|
| 68 | } __attribute__((packed));
|
| 69 |
|
| 70 | enum fc_eof {
|
| 71 | FC_EOF_N = 0x41,
|
| 72 | FC_EOF_T = 0x42,
|
| 73 | FC_EOF_RT = 0x44,
|
| 74 | FC_EOF_DT = 0x46,
|
| 75 | FC_EOF_NI = 0x49,
|
| 76 | FC_EOF_DTI = 0x4e,
|
| 77 | FC_EOF_RTI = 0x4f,
|
| 78 | FC_EOF_A = 0x50,
|
| 79 | } __attribute__((packed));
|
| 80 |
|
| 81 | #define FC_SOF_CLASS_MASK 0x06
|
| 82 |
|
| 83 | |
| 84 | * Define classes in terms of the SOF code (initial).
|
| 85 |
|
| 86 | enum fc_class {
|
| 87 | FC_CLASS_NONE = 0,
|
| 88 | FC_CLASS_2 = FC_SOF_I2,
|
| 89 | FC_CLASS_3 = FC_SOF_I3,
|
| 90 | FC_CLASS_4 = FC_SOF_I4,
|
| 91 | FC_CLASS_F = FC_SOF_F,
|
| 92 | };
|
| 93 |
|
| 94 | |
| 95 | * Determine whether SOF code indicates the need for a BLS ACK.
|
| 96 |
|
| 97 | static inline int fc_sof_needs_ack(enum fc_sof sof)
|
| 98 | {
|
| 99 | return (~sof) & 0x02;
|
| 100 | }
|
| 101 |
|
| 102 | |
| 103 | * Given an fc_class, return the normal (non-initial) SOF value.
|
| 104 |
|
| 105 | static inline enum fc_sof fc_sof_normal(enum fc_class class)
|
| 106 | {
|
| 107 | return class + FC_SOF_N3 - FC_SOF_I3;
|
| 108 | }
|
| 109 |
|
| 110 | |
| 111 | * Compute class from SOF value.
|
| 112 |
|
| 113 | static inline enum fc_class fc_sof_class(enum fc_sof sof)
|
| 114 | {
|
| 115 | return (sof & 0x7) | FC_SOF_F;
|
| 116 | }
|
| 117 |
|
| 118 | |
| 119 | * Determine whether SOF is for the initial frame of a sequence.
|
| 120 |
|
| 121 | static inline int fc_sof_is_init(enum fc_sof sof)
|
| 122 | {
|
| 123 | return sof < 0x30;
|
| 124 | }
|
| 125 |
|
| 126 | #endif
|