[openib-general] [PATCH] iser: add struct iser_hdr
Or Gerlitz
ogerlitz at voltaire.com
Wed Jan 18 05:42:18 PST 2006
applied in r5060
remove iser_header.h, have the iser header in struct iser_hdr which is
encoded for the wire
Signed-off-by: Or Gerlitz <ogerlitz at voltaire.com>
Index: ulp/iser/iser.h
===================================================================
--- ulp/iser/iser.h (revision 5033)
+++ ulp/iser/iser.h (revision 5060)
@@ -47,8 +47,6 @@
#include <linux/uio.h>
#include "iscsi_iser.h"
-#include "iser_header.h"
-
#include <linux/socket.h>
#include <linux/in.h>
#include <linux/in6.h>
@@ -59,8 +57,23 @@
#define PFX "iser:"
+struct iser_hdr {
+ u8 flags;
+ u8 rsvd[3];
+ __be32 write_stag; /* write rkey */
+ __be64 write_va;
+ __be32 read_stag; /* read rkey */
+ __be64 read_va;
+} __attribute__((packed));
+
+#define ISER_VER 0x10
+#define ISER_WSV 0x08
+#define ISER_RSV 0x04
+
/* Constant PDU lengths calculations */
-#define ISER_PDU_BHS_LENGTH 48
+#define ISER_HDR_LEN sizeof (struct iser_hdr)
+#define ISER_PDU_BHS_LENGTH sizeof (struct iscsi_hdr)
+
#define ISER_TOTAL_HEADERS_LEN \
(ISER_HDR_LEN + ISER_PDU_BHS_LENGTH)
Index: ulp/iser/iser_dto.c
===================================================================
--- ulp/iser/iser_dto.c (revision 5033)
+++ ulp/iser/iser_dto.c (revision 5060)
@@ -203,7 +203,8 @@ struct iser_dto *iser_dto_send_create(st
p_iser_header = (unsigned char *)p_regd_hdr->virt_addr;
memset(p_iser_header, 0, ISER_HDR_LEN);
- ISER_HDR_SET_VERSION(p_iser_header);
+ ((struct iser_hdr *)p_iser_header)->flags = ISER_VER;
+
memcpy(p_iser_header + ISER_HDR_LEN, hdr, ISER_PDU_BHS_LENGTH);
iser_dto_add_regd_buff(p_send_dto, p_regd_hdr, USE_NO_OFFSET,
USE_SIZE(ISER_TOTAL_HEADERS_LEN));
Index: ulp/iser/iser_initiator.c
===================================================================
--- ulp/iser/iser_initiator.c (revision 5033)
+++ ulp/iser/iser_initiator.c (revision 5060)
@@ -135,6 +135,7 @@ static int iser_prepare_read_cmd(struct
dma_addr_t dma_addr;
int dma_nents;
struct device *dma_device;
+ struct iser_hdr *hdr = (struct iser_hdr *)p_iser_header;
p_iser_task->dir[ISER_DIR_IN] = 1;
dma_device = p_iser_task->conn->ib_conn->p_adaptor->device->dma_device;
@@ -177,13 +178,15 @@ static int iser_prepare_read_cmd(struct
return err;
}
p_regd_buf = p_iser_task->rdma_regd[ISER_DIR_IN];
- ISER_HDR_SET_BITS(p_iser_header, RSV, 1);
- ISER_HDR_R_VADDR(p_iser_header) = cpu_to_be64(p_regd_buf->reg.va);
- ISER_HDR_R_RKEY(p_iser_header) = htonl(p_regd_buf->reg.rkey);
- iser_dbg("Cmd itt:%d, READ tags, RKEY:0x%08X VA:0x%08lX\n",
+ hdr->flags |= ISER_RSV;
+ hdr->read_stag = cpu_to_be32(p_regd_buf->reg.rkey);
+ hdr->read_va = cpu_to_be64(p_regd_buf->reg.va);
+
+ iser_err("Cmd itt:%d READ tags RKEY:%#.4X VA:%#llX\n",
p_iser_task->itt, p_regd_buf->reg.rkey,
- (unsigned long)p_regd_buf->reg.va);
+ (unsigned long long)p_regd_buf->reg.va);
+
return 0;
}
@@ -205,6 +208,7 @@ iser_prepare_write_cmd(struct iscsi_iser
dma_addr_t dma_addr;
int dma_nents;
struct device *dma_device;
+ struct iser_hdr *hdr = (struct iser_hdr *)p_iser_header;
p_iser_task->dir[ISER_DIR_OUT] = 1;
dma_device = p_iser_task->conn->ib_conn->p_adaptor->device->dma_device;
@@ -252,16 +256,14 @@ iser_prepare_write_cmd(struct iscsi_iser
p_regd_buf = p_iser_task->rdma_regd[ISER_DIR_OUT];
if(unsol_sz < edtl) {
- ISER_HDR_SET_BITS(p_iser_header, WSV, 1);
- ISER_HDR_W_VADDR(p_iser_header) = cpu_to_be64(
- p_regd_buf->reg.va + unsol_sz);
- ISER_HDR_W_RKEY(p_iser_header) = htonl(p_regd_buf->reg.rkey);
+ hdr->flags |= ISER_WSV;
+ hdr->write_stag = cpu_to_be32(p_regd_buf->reg.rkey);
+ hdr->write_va = cpu_to_be64(p_regd_buf->reg.va + unsol_sz);
- iser_dbg("Cmd itt:%d, WRITE tags, RKEY:0x%08X "
- "VA:0x%08lX + unsol:%d\n",
+ iser_err("Cmd itt:%d, WRITE tags, RKEY:%#.4X "
+ "VA:%#llX + unsol:%d\n",
p_iser_task->itt, p_regd_buf->reg.rkey,
- (unsigned long)p_regd_buf->reg.va,
- unsol_sz);
+ (unsigned long long)p_regd_buf->reg.va, unsol_sz);
}
if (imm_sz > 0) {
Index: ulp/iser/iser_header.h
===================================================================
--- ulp/iser/iser_header.h (revision 5033)
+++ ulp/iser/iser_header.h (revision 5060)
@@ -1,164 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * $Id$
- */
-
-#ifndef __ISER_HEADER_H__
-#define __ISER_HEADER_H__
-
-/*
- BYTE |0 1 2 3
- |0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-DWORD | |W|R| |
- 0 | 0001b |S|S| Reserved |
- | |V|V| |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- 1 | Write STag high (or N/A) = RKey |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- 2 | Write STag low (or N/A) = Virt.Addr. |
- 3 | |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- 4 | Read STag high (or N/A) = RKey |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- 5 | Read STag low (or N/A) = Virt.Addr. |
- 6 | |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-*/
-
-#define ISER_HDR_LEN 28
-
-/* Version */
-#define ISER_HDR_VER_OFFSET 0 /* in byte 0 */
-#define ISER_HDR_VER_SHIFT 4 /* last bit 3 */
-#define ISER_HDR_VER_MASK 0x0F /* 4 bits */
-
-/* WSV - Write STag Valid flag */
-#define ISER_HDR_WSV_OFFSET 0 /* in byte 0 */
-#define ISER_HDR_WSV_SHIFT 3 /* last bit 4 */
-#define ISER_HDR_WSV_MASK 0x01 /* 1 bit */
-
-/* RSV - Read STag Valid flag */
-#define ISER_HDR_RSV_OFFSET 0 /* in byte 0 */
-#define ISER_HDR_RSV_SHIFT 2 /* last bit 5 */
-#define ISER_HDR_RSV_MASK 0x01 /* 1 bit */
-
-/* Retrieve a bit field from a header byte array.
- Possible field names are: VER, WSV, RSV
-*/
-#define ISER_HDR_GET_BITS(p,field) \
- ((((unsigned char *)p)[ISER_HDR_ ## field ## _OFFSET] >> \
- ISER_HDR_ ## field ## _SHIFT) & \
- ISER_HDR_ ## field ## _MASK)
-
-/* Set the passed value in the bit field
- Possible field names are: VER, WSV, RSV
-*/
-#define ISER_HDR_SET_BITS(p,field,val) \
- do { \
- ((unsigned char *)p)[ISER_HDR_ ## field ## _OFFSET] &= \
- ~(ISER_HDR_ ## field ## _MASK << \
- ISER_HDR_ ## field ## _SHIFT); \
- ((unsigned char *)p)[ISER_HDR_ ## field ## _OFFSET] |= \
- ((val) & ISER_HDR_ ## field ## _MASK) << \
- ISER_HDR_ ## field ## _SHIFT; \
- } while(0)
-
-#define ISER_HDR_SET_VERSION(p) ISER_HDR_SET_BITS(p,VER,0x01)
-
-/* Access to the fields Read S-Tag, Write S-Tag by 32-bit halves.
- Returns l-value.
-*/
-#define ISER_HDR_W_RKEY(p) \
- (*(u32 *) (((unsigned char *) p) + 4))
-#define ISER_HDR_W_VADDR(p) \
- (*(u64 *) (((unsigned char *) p) + 8))
-
-#define ISER_HDR_R_RKEY(p) \
- (*(u32 *) (((unsigned char *) p) + 16))
-#define ISER_HDR_R_VADDR(p) \
- (*(u64 *) (((unsigned char *) p) + 20))
-
-/*
- BYTE |0 1 2 3
- |0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-DWORD |
- 0 | 0010b | Rsvd | MaxVer| MinVer| Reserved |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- 1 | Reserved |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- 2 | Reserved |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- 3 | IBVer | IPVer | InitiatorRecvDataSegmentLength |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- 4 | ICap | Reserved | Local Port |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- 5 | Src IP (127-96) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- 6 | Src IP ( 95-64) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- 7 | Src IP ( 63-32) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- 8 | Src IP ( 31-00) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- 9 | Dst IP (127-96) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- 10 | Dst IP ( 95-64) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- 11 | Dst IP ( 63-32) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- 12 | Dst IP ( 31-00) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-*/
-
-#define ISER_HELLO_LEN 52
-
-/*
- BYTE |0 1 2 3
- |0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-DWORD | | |R| | | |
- 0 | 0011b |Rsvd |E| MaxVer| CurVer| iSER-ORD |
- | | |J| | | |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- 1 | Reserved |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- 2 | Reserved |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- 3 | IBVer | TCap | TargetRecvDataSegmentLength |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-*/
-
-#define ISER_HELLO_REPLY_LEN 16
-
-#endif /* __ISER_HEADER_H__ */
More information about the general
mailing list