mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Nicholas A. Bellinger" <nab@linux-iscsi.org>
To: target-devel <target-devel@vger.kernel.org>,
	linux-scsi <linux-scsi@vger.kernel.org>,
	linux-kernel <linux-kernel@vger.kernel.org>
Cc: Christoph Hellwig <hch@lst.de>, Andy Grover <agrover@redhat.com>,
	Hannes Reinecke <hare@suse.de>,
	Roland Dreier <roland@purestorage.com>,
	James Bottomley <James.Bottomley@HansenPartnership.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Nicholas Bellinger <nab@linux-iscsi.org>
Subject: [PATCH 02/13] iscsi: Add Serial Number Arithmetic LT and GT into iscsi_proto.h
Date: Sat, 23 Jul 2011 08:45:36 +0000	[thread overview]
Message-ID: <1311410747-29947-3-git-send-email-nab@linux-iscsi.org> (raw)
In-Reply-To: <1311410747-29947-1-git-send-email-nab@linux-iscsi.org>

From: Nicholas Bellinger <nab@linux-iscsi.org>

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.

Signed-off-by: Mark Rustad <mark.d.rustad@intel.com>
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: Nicholas A. Bellinger <nab@linux-iscsi.org>
---
 drivers/scsi/libiscsi.c    |   16 ----------------
 include/scsi/iscsi_proto.h |   38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 16 deletions(-)

diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 9c3cb4e..3461a03 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -84,22 +84,6 @@ MODULE_PARM_DESC(debug_libiscsi_eh,
 					     __func__, ##arg);		\
 	} while (0);
 
-/* Serial Number Arithmetic, 32 bits, less than, RFC1982 */
-#define SNA32_CHECK 2147483648UL
-
-static int iscsi_sna_lt(u32 n1, u32 n2)
-{
-	return n1 != n2 && ((n1 < n2 && (n2 - n1 < SNA32_CHECK)) ||
-			    (n1 > n2 && (n2 - n1 < SNA32_CHECK)));
-}
-
-/* Serial Number Arithmetic, 32 bits, less than, RFC1982 */
-static int iscsi_sna_lte(u32 n1, u32 n2)
-{
-	return n1 == n2 || ((n1 < n2 && (n2 - n1 < SNA32_CHECK)) ||
-			    (n1 > n2 && (n2 - n1 < SNA32_CHECK)));
-}
-
 inline void iscsi_conn_queue_work(struct iscsi_conn *conn)
 {
 	struct Scsi_Host *shost = conn->session->host;
diff --git a/include/scsi/iscsi_proto.h b/include/scsi/iscsi_proto.h
index a9c9058..455b03a 100644
--- a/include/scsi/iscsi_proto.h
+++ b/include/scsi/iscsi_proto.h
@@ -29,10 +29,48 @@
 /* default iSCSI listen port for incoming connections */
 #define ISCSI_LISTEN_PORT	3260
 
+/* iSCSI header length */
+#define ISCSI_HDR_LEN		48
+
+/* iSCSI CRC32C length */
+#define ISCSI_CRC_LEN		4
+
 /* Padding word length */
 #define ISCSI_PAD_LEN		4
 
 /*
+ * Serial Number Arithmetic, 32 bits, RFC1982
+ */
+
+static inline int iscsi_sna_lt(u32 n1, u32 n2)
+{
+	s32 diff = n1 - n2;
+
+	return diff < 0;
+}
+
+static inline int iscsi_sna_lte(u32 n1, u32 n2)
+{
+	s32 diff = n1 - n2;
+
+	return diff <= 0;
+}
+
+static inline int iscsi_sna_gt(u32 n1, u32 n2)
+{
+	s32 diff = n1 - n2;
+
+	return diff > 0;
+}
+
+static inline int iscsi_sna_gte(u32 n1, u32 n2)
+{
+	s32 diff = n1 - n2;
+
+	return diff >= 0;
+}
+
+/*
  * useful common(control and data pathes) macro
  */
 #define ntoh24(p) (((p)[0] << 16) | ((p)[1] << 8) | ((p)[2]))
-- 
1.7.6


  parent reply	other threads:[~2011-07-23  9:09 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-23  8:45 [PATCH 00/13] iscsi-target: Merge candidate for v3.1-rc1 Nicholas A. Bellinger
2011-07-23  8:45 ` [PATCH 01/13] iscsi: Resolve iscsi_proto.h naming conflicts with drivers/target/iscsi Nicholas A. Bellinger
2011-07-23 13:34   ` Jesper Juhl
2011-07-23 21:23     ` Nicholas A. Bellinger
2011-07-23  8:45 ` Nicholas A. Bellinger [this message]
2011-07-23 14:25   ` [PATCH 02/13] iscsi: Add Serial Number Arithmetic LT and GT into iscsi_proto.h Jesper Juhl
2011-07-23 21:29     ` Nicholas A. Bellinger
2011-07-23  8:45 ` [PATCH 03/13] iscsi-target: Add iSCSI fabric support for target v4.1 Nicholas A. Bellinger
2011-07-23  8:45 ` [PATCH 04/13] iscsi-target: Add target core v4.1 compatible ConfigFS control plane Nicholas A. Bellinger
2011-07-23  8:45 ` [PATCH 05/13] iscsi-target: Add ConfigFS fabric dependent statistics Nicholas A. Bellinger
2011-07-23  8:45 ` [PATCH 06/13] iscsi-target: Add TPG and device backend logic Nicholas A. Bellinger
2011-07-23  8:45 ` [PATCH 07/13] iscsi-target: Add iSCSI Login Negotiation + Parameter logic Nicholas A. Bellinger
2011-07-23  8:45 ` [PATCH 08/13] iscsi-target: Add CHAP Authentication support using libcrypto Nicholas A. Bellinger
2011-07-23 16:39   ` James Bottomley
2011-07-23 17:51     ` Linus Torvalds
2011-07-23 18:17       ` James Bottomley
2011-07-23 21:17         ` Nicholas A. Bellinger
2011-07-24  3:08           ` Mike Christie
2011-07-24  4:59             ` Nicholas A. Bellinger
     [not found]             ` <CAJAFBLCXQLvyLKR5ZD_foaPqU5X6VJfLQX_VAKeaWpDLLfPWnA@mail.gmail.com>
2011-07-24 16:32               ` Alex Couvrard
2011-07-24  3:52           ` James Bottomley
2011-07-24  4:41             ` Nicholas A. Bellinger
2011-07-24  5:50               ` James Bottomley
2011-07-24  7:52                 ` Nicholas A. Bellinger
2011-07-25 19:31               ` Andy Grover
2011-07-25 20:42                 ` Nicholas A. Bellinger
2011-07-23  8:45 ` [PATCH 09/13] iscsi-target: Add Sequence/PDU list + DataIN response logic Nicholas A. Bellinger
2011-07-23  8:45 ` [PATCH 10/13] iscsi-target: Add iSCSI Error Recovery Hierarchy support Nicholas A. Bellinger
2011-07-28 11:42   ` Fubo Chen
2011-07-28 20:30     ` Nicholas A. Bellinger
2011-07-23  8:45 ` [PATCH 11/13] iscsi-target: Add support for task management operations Nicholas A. Bellinger
2011-07-23  8:45 ` [PATCH 12/13] iscsi-target: Add misc utility logic Nicholas A. Bellinger
2011-07-28 11:30   ` Fubo Chen
2011-07-28 20:19     ` Nicholas A. Bellinger
2011-07-23  8:45 ` [PATCH 13/13] iscsi-target: Add Makefile/Kconfig and update TCM top level Nicholas A. Bellinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1311410747-29947-3-git-send-email-nab@linux-iscsi.org \
    --to=nab@linux-iscsi.org \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=agrover@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=roland@purestorage.com \
    --cc=target-devel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®