Skip to content

Commit 8304bbc

Browse files
author
Nicholas Bellinger
committed
iscsi: Add Serial Number Arithmetic LT and GT into iscsi_proto.h
This patch moves the iscsi_sna_lt() and iscsi_sna_lte(), along with iscsi_sna_gt() and iscsi_sna_gte() from iscsi_target_mod into static inlines inside of include/scsi/iscsi_proto.h This patch also includes the ISCSI_HDR_LEN and ISCSI_CRC_LEN definitions. (Added JesperJ simpliciation for iscsi_sna_* usage) Signed-off-by: Mark Rustad <[email protected]> Signed-off-by: Mike Christie <[email protected]> Signed-off-by: Nicholas A. Bellinger <[email protected]>
1 parent 55bdabd commit 8304bbc

File tree

2 files changed

+30
-16
lines changed

2 files changed

+30
-16
lines changed

drivers/scsi/libiscsi.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -84,22 +84,6 @@ MODULE_PARM_DESC(debug_libiscsi_eh,
8484
__func__, ##arg); \
8585
} while (0);
8686

87-
/* Serial Number Arithmetic, 32 bits, less than, RFC1982 */
88-
#define SNA32_CHECK 2147483648UL
89-
90-
static int iscsi_sna_lt(u32 n1, u32 n2)
91-
{
92-
return n1 != n2 && ((n1 < n2 && (n2 - n1 < SNA32_CHECK)) ||
93-
(n1 > n2 && (n2 - n1 < SNA32_CHECK)));
94-
}
95-
96-
/* Serial Number Arithmetic, 32 bits, less than, RFC1982 */
97-
static int iscsi_sna_lte(u32 n1, u32 n2)
98-
{
99-
return n1 == n2 || ((n1 < n2 && (n2 - n1 < SNA32_CHECK)) ||
100-
(n1 > n2 && (n2 - n1 < SNA32_CHECK)));
101-
}
102-
10387
inline void iscsi_conn_queue_work(struct iscsi_conn *conn)
10488
{
10589
struct Scsi_Host *shost = conn->session->host;

include/scsi/iscsi_proto.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,39 @@
2929
/* default iSCSI listen port for incoming connections */
3030
#define ISCSI_LISTEN_PORT 3260
3131

32+
/* iSCSI header length */
33+
#define ISCSI_HDR_LEN 48
34+
35+
/* iSCSI CRC32C length */
36+
#define ISCSI_CRC_LEN 4
37+
3238
/* Padding word length */
3339
#define ISCSI_PAD_LEN 4
3440

41+
/*
42+
* Serial Number Arithmetic, 32 bits, RFC1982
43+
*/
44+
45+
static inline int iscsi_sna_lt(u32 n1, u32 n2)
46+
{
47+
return (s32)(n1 - n2) < 0;
48+
}
49+
50+
static inline int iscsi_sna_lte(u32 n1, u32 n2)
51+
{
52+
return (s32)(n1 - n2) <= 0;
53+
}
54+
55+
static inline int iscsi_sna_gt(u32 n1, u32 n2)
56+
{
57+
return (s32)(n1 - n2) > 0;
58+
}
59+
60+
static inline int iscsi_sna_gte(u32 n1, u32 n2)
61+
{
62+
return (s32)(n1 - n2) >= 0;
63+
}
64+
3565
/*
3666
* useful common(control and data pathes) macro
3767
*/

0 commit comments

Comments
 (0)