diff options
Diffstat (limited to 'include/scsi/fc_frame.h')
-rw-r--r-- | include/scsi/fc_frame.h | 52 |
1 files changed, 49 insertions, 3 deletions
diff --git a/include/scsi/fc_frame.h b/include/scsi/fc_frame.h index 4d3e9c7b7c57..4ad02041b667 100644 --- a/include/scsi/fc_frame.h +++ b/include/scsi/fc_frame.h | |||
@@ -30,6 +30,23 @@ | |||
30 | 30 | ||
31 | #include <linux/if_ether.h> | 31 | #include <linux/if_ether.h> |
32 | 32 | ||
33 | /* some helpful macros */ | ||
34 | |||
35 | #define ntohll(x) be64_to_cpu(x) | ||
36 | #define htonll(x) cpu_to_be64(x) | ||
37 | |||
38 | static inline u32 ntoh24(const u8 *p) | ||
39 | { | ||
40 | return (p[0] << 16) | (p[1] << 8) | p[2]; | ||
41 | } | ||
42 | |||
43 | static inline void hton24(u8 *p, u32 v) | ||
44 | { | ||
45 | p[0] = (v >> 16) & 0xff; | ||
46 | p[1] = (v >> 8) & 0xff; | ||
47 | p[2] = v & 0xff; | ||
48 | } | ||
49 | |||
33 | /* | 50 | /* |
34 | * The fc_frame interface is used to pass frame data between functions. | 51 | * The fc_frame interface is used to pass frame data between functions. |
35 | * The frame includes the data buffer, length, and SOF / EOF delimiter types. | 52 | * The frame includes the data buffer, length, and SOF / EOF delimiter types. |
@@ -51,6 +68,7 @@ | |||
51 | #define fr_sof(fp) (fr_cb(fp)->fr_sof) | 68 | #define fr_sof(fp) (fr_cb(fp)->fr_sof) |
52 | #define fr_eof(fp) (fr_cb(fp)->fr_eof) | 69 | #define fr_eof(fp) (fr_cb(fp)->fr_eof) |
53 | #define fr_flags(fp) (fr_cb(fp)->fr_flags) | 70 | #define fr_flags(fp) (fr_cb(fp)->fr_flags) |
71 | #define fr_encaps(fp) (fr_cb(fp)->fr_encaps) | ||
54 | #define fr_max_payload(fp) (fr_cb(fp)->fr_max_payload) | 72 | #define fr_max_payload(fp) (fr_cb(fp)->fr_max_payload) |
55 | #define fr_fsp(fp) (fr_cb(fp)->fr_fsp) | 73 | #define fr_fsp(fp) (fr_cb(fp)->fr_fsp) |
56 | #define fr_crc(fp) (fr_cb(fp)->fr_crc) | 74 | #define fr_crc(fp) (fr_cb(fp)->fr_crc) |
@@ -66,9 +84,10 @@ struct fcoe_rcv_info { | |||
66 | struct fc_fcp_pkt *fr_fsp; /* for the corresponding fcp I/O */ | 84 | struct fc_fcp_pkt *fr_fsp; /* for the corresponding fcp I/O */ |
67 | u32 fr_crc; | 85 | u32 fr_crc; |
68 | u16 fr_max_payload; /* max FC payload */ | 86 | u16 fr_max_payload; /* max FC payload */ |
69 | enum fc_sof fr_sof; /* start of frame delimiter */ | 87 | u8 fr_sof; /* start of frame delimiter */ |
70 | enum fc_eof fr_eof; /* end of frame delimiter */ | 88 | u8 fr_eof; /* end of frame delimiter */ |
71 | u8 fr_flags; /* flags - see below */ | 89 | u8 fr_flags; /* flags - see below */ |
90 | u8 fr_encaps; /* LLD encapsulation info (e.g. FIP) */ | ||
72 | u8 granted_mac[ETH_ALEN]; /* FCoE MAC address */ | 91 | u8 granted_mac[ETH_ALEN]; /* FCoE MAC address */ |
73 | }; | 92 | }; |
74 | 93 | ||
@@ -97,6 +116,7 @@ static inline void fc_frame_init(struct fc_frame *fp) | |||
97 | fr_dev(fp) = NULL; | 116 | fr_dev(fp) = NULL; |
98 | fr_seq(fp) = NULL; | 117 | fr_seq(fp) = NULL; |
99 | fr_flags(fp) = 0; | 118 | fr_flags(fp) = 0; |
119 | fr_encaps(fp) = 0; | ||
100 | } | 120 | } |
101 | 121 | ||
102 | struct fc_frame *fc_frame_alloc_fill(struct fc_lport *, size_t payload_len); | 122 | struct fc_frame *fc_frame_alloc_fill(struct fc_lport *, size_t payload_len); |
@@ -136,13 +156,39 @@ static inline int fc_frame_is_linear(struct fc_frame *fp) | |||
136 | 156 | ||
137 | /* | 157 | /* |
138 | * Get frame header from message in fc_frame structure. | 158 | * Get frame header from message in fc_frame structure. |
159 | * This version doesn't do a length check. | ||
160 | */ | ||
161 | static inline | ||
162 | struct fc_frame_header *__fc_frame_header_get(const struct fc_frame *fp) | ||
163 | { | ||
164 | return (struct fc_frame_header *)fr_hdr(fp); | ||
165 | } | ||
166 | |||
167 | /* | ||
168 | * Get frame header from message in fc_frame structure. | ||
139 | * This hides a cast and provides a place to add some checking. | 169 | * This hides a cast and provides a place to add some checking. |
140 | */ | 170 | */ |
141 | static inline | 171 | static inline |
142 | struct fc_frame_header *fc_frame_header_get(const struct fc_frame *fp) | 172 | struct fc_frame_header *fc_frame_header_get(const struct fc_frame *fp) |
143 | { | 173 | { |
144 | WARN_ON(fr_len(fp) < sizeof(struct fc_frame_header)); | 174 | WARN_ON(fr_len(fp) < sizeof(struct fc_frame_header)); |
145 | return (struct fc_frame_header *) fr_hdr(fp); | 175 | return __fc_frame_header_get(fp); |
176 | } | ||
177 | |||
178 | /* | ||
179 | * Get source FC_ID (S_ID) from frame header in message. | ||
180 | */ | ||
181 | static inline u32 fc_frame_sid(const struct fc_frame *fp) | ||
182 | { | ||
183 | return ntoh24(__fc_frame_header_get(fp)->fh_s_id); | ||
184 | } | ||
185 | |||
186 | /* | ||
187 | * Get destination FC_ID (D_ID) from frame header in message. | ||
188 | */ | ||
189 | static inline u32 fc_frame_did(const struct fc_frame *fp) | ||
190 | { | ||
191 | return ntoh24(__fc_frame_header_get(fp)->fh_d_id); | ||
146 | } | 192 | } |
147 | 193 | ||
148 | /* | 194 | /* |