diff options
author | Joe Eykholt <jeykholt@cisco.com> | 2010-07-20 18:20:56 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2010-07-28 10:05:59 -0400 |
commit | 251748a99e631a2c46edcf9e519cfc60fae8153d (patch) | |
tree | 6255e513473fffde4691f761c53e82440d763d18 /include/scsi | |
parent | 079ecd8cfe95dfd28b74f3a00d66fdbcdfc8c611 (diff) |
[SCSI] libfc: add fc_frame_sid() and fc_frame_did() functions
To pave the way for eliminating exchanges from incoming requests,
add simple inline fc_frame_sid() and fc_frame_did() functions
which get the FC_IDs from the frame header. This can be almost
as efficient as getting them from the sequence/exchange.
Move ntohll, htonll, ntoh24 and hton24 to <scsi/fc_frame.h>
since we need them there and that's included by <scsi/libfc.h>
Signed-off-by: Joe Eykholt <jeykholt@cisco.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'include/scsi')
-rw-r--r-- | include/scsi/fc_frame.h | 45 | ||||
-rw-r--r-- | include/scsi/libfc.h | 18 |
2 files changed, 44 insertions, 19 deletions
diff --git a/include/scsi/fc_frame.h b/include/scsi/fc_frame.h index 29dd97d5b53a..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. |
@@ -139,13 +156,39 @@ static inline int fc_frame_is_linear(struct fc_frame *fp) | |||
139 | 156 | ||
140 | /* | 157 | /* |
141 | * 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. | ||
142 | * 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. |
143 | */ | 170 | */ |
144 | static inline | 171 | static inline |
145 | 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) |
146 | { | 173 | { |
147 | WARN_ON(fr_len(fp) < sizeof(struct fc_frame_header)); | 174 | WARN_ON(fr_len(fp) < sizeof(struct fc_frame_header)); |
148 | 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); | ||
149 | } | 192 | } |
150 | 193 | ||
151 | /* | 194 | /* |
diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h index e6f07fba432c..f1ce793f33b3 100644 --- a/include/scsi/libfc.h +++ b/include/scsi/libfc.h | |||
@@ -42,24 +42,6 @@ | |||
42 | #define FC_EX_TIMEOUT 1 /* Exchange timeout */ | 42 | #define FC_EX_TIMEOUT 1 /* Exchange timeout */ |
43 | #define FC_EX_CLOSED 2 /* Exchange closed */ | 43 | #define FC_EX_CLOSED 2 /* Exchange closed */ |
44 | 44 | ||
45 | /* some helpful macros */ | ||
46 | |||
47 | #define ntohll(x) be64_to_cpu(x) | ||
48 | #define htonll(x) cpu_to_be64(x) | ||
49 | |||
50 | |||
51 | static inline u32 ntoh24(const u8 *p) | ||
52 | { | ||
53 | return (p[0] << 16) | (p[1] << 8) | p[2]; | ||
54 | } | ||
55 | |||
56 | static inline void hton24(u8 *p, u32 v) | ||
57 | { | ||
58 | p[0] = (v >> 16) & 0xff; | ||
59 | p[1] = (v >> 8) & 0xff; | ||
60 | p[2] = v & 0xff; | ||
61 | } | ||
62 | |||
63 | /** | 45 | /** |
64 | * enum fc_lport_state - Local port states | 46 | * enum fc_lport_state - Local port states |
65 | * @LPORT_ST_DISABLED: Disabled | 47 | * @LPORT_ST_DISABLED: Disabled |