[openib-general] [PATCH] iser: more cleanups

Or Gerlitz ogerlitz at voltaire.com
Thu Feb 2 04:37:35 PST 2006


removed two files plus more reorg and cleanups 

committed to r5262

 Makefile         |    4 -
 iscsi_iser.c     |   81 ++++++++++++++++++++++++++++---
 iscsi_iser.h     |   23 +-------
 iser_conn.c      |    2
 iser_dto.c       |  117 ---------------------------------------------
 iser_initiator.c |  128 +++++++++++++++++++++++++++++--------------------
 iser_mod.c       |  141 -------------------------------------------------------
 iser_verbs.c     |    2
 8 files changed, 157 insertions(+), 341 deletions(-)

removed iser_mod.c and iser_dto.c

Signed-off-by: Or Gerlitz <ogerlitz at voltaire.com>


Index: ulp/iser/iser_conn.c
===================================================================
--- ulp/iser/iser_conn.c	(revision 5251)
+++ ulp/iser/iser_conn.c	(revision 5262)
@@ -473,7 +473,7 @@
 
 post_receive_control_exit:
 	if(err && rx_desc) {
-		iser_dto_free(p_recv_dto);
+		iser_dto_buffs_release(p_recv_dto);
 		if(rx_desc->data != NULL)
 			kfree(rx_desc->data);
 		kmem_cache_free(ig.desc_cache, rx_desc);
Index: ulp/iser/iscsi_iser.h
===================================================================
--- ulp/iser/iscsi_iser.h	(revision 5251)
+++ ulp/iser/iscsi_iser.h	(revision 5262)
@@ -501,25 +501,14 @@
 #define USE_SIZE(size)	    (size)
 #define USE_ENTIRE_SIZE	    0
 
-int iser_dto_add_regd_buff(struct iser_dto *p_dto,
-			   struct iser_regd_buf *p_regd_buf,
-			   unsigned long use_offset,
-			   unsigned long use_size);
+void iser_dto_add_regd_buff(struct iser_dto *p_dto,
+			    struct iser_regd_buf *p_regd_buf,
+			    unsigned long use_offset,
+			    unsigned long use_size);
 
-void iser_dto_free(struct iser_dto *p_dto);
+void iser_dto_buffs_release(struct iser_dto *p_dto);
 
-void iser_dto_send_create(struct iscsi_iser_conn *p_iser_conn,
-			  struct iser_desc       *tx_desc);
-
-
 /* iser_initiator.h */
-int iser_dma_map_task_data(struct iscsi_iser_cmd_task *p_iser_task,
-			   struct iser_data_buf       *p_data,
-			   enum   iser_data_dir       iser_dir,
-			   enum   dma_data_direction  dma_dir);
-
-void iser_dma_unmap_task_data(struct iscsi_iser_cmd_task *p_iser_task);
-
 void iser_rcv_completion(struct iser_desc *p_desc,
 			     unsigned long dto_xfer_len);
 
@@ -620,8 +609,6 @@
 int iser_connect(struct iser_conn *p_iser_conn,
 		 struct sockaddr_in *dst_addr, struct sockaddr_in *src_addr);
 
-int iser_disconnect(struct iser_conn *p_iser_conn);
-
 int iser_free_qp_and_id(struct iser_conn *p_iser_conn);
 
 int iser_free_ib_conn_res(struct iser_conn *p_iser_conn);
Index: ulp/iser/iser_verbs.c
===================================================================
--- ulp/iser/iser_verbs.c	(revision 5251)
+++ ulp/iser/iser_verbs.c	(revision 5262)
@@ -644,7 +644,7 @@
 	struct iser_dto        *p_dto       = &p_desc->dto;
 	struct iscsi_iser_conn *p_iser_conn = p_dto->p_conn;
 
-	iser_dto_free(p_dto);
+	iser_dto_buffs_release(p_dto);
 
 	if(p_desc->type == ISCSI_RX) {
 		kfree(p_desc->data);
Index: ulp/iser/iser_initiator.c
===================================================================
--- ulp/iser/iser_initiator.c	(revision 5251)
+++ ulp/iser/iser_initiator.c	(revision 5262)
@@ -40,10 +40,10 @@
 
 #include "iscsi_iser.h"
 
-int iser_dma_map_task_data(struct iscsi_iser_cmd_task *p_iser_task,
-			   struct iser_data_buf       *p_data,
-			   enum   iser_data_dir       iser_dir,
-			   enum   dma_data_direction  dma_dir)
+static int iser_dma_map_task_data(struct iscsi_iser_cmd_task *p_iser_task,
+				  struct iser_data_buf       *p_data,
+				  enum   iser_data_dir       iser_dir,
+				  enum   dma_data_direction  dma_dir)
 {
 	struct device *dma_device;
 	dma_addr_t     dma_addr;
@@ -74,7 +74,7 @@
 	return 0;
 }
 
-void iser_dma_unmap_task_data(struct iscsi_iser_cmd_task *p_iser_task)
+static void iser_dma_unmap_task_data(struct iscsi_iser_cmd_task *p_iser_task)
 {
 	struct device  *dma_device;
 	struct iser_data_buf *p_data;
@@ -279,6 +279,30 @@
 	return 0;
 }
 
+
+/* creates a new tx descriptor and adds header regd buffer */
+static void iser_create_send_desc(struct iscsi_iser_conn *p_iser_conn,
+				  struct iser_desc       *tx_desc)
+{
+	struct iser_regd_buf *p_regd_hdr = &tx_desc->hdr_regd_buf;
+	struct iser_dto      *p_send_dto = &tx_desc->dto;
+
+	memset(p_regd_hdr, 0, sizeof(struct iser_regd_buf));
+	p_regd_hdr->p_adaptor  = p_iser_conn->ib_conn->p_adaptor;
+	p_regd_hdr->virt_addr  = tx_desc; /* == &tx_desc->iser_header */
+	p_regd_hdr->data_size  = ISER_TOTAL_HEADERS_LEN;
+
+	p_send_dto->p_conn          = p_iser_conn;
+	p_send_dto->notify_enable   = 1;
+	p_send_dto->regd_vector_len = 0;
+
+	memset(&tx_desc->iser_header, 0, ISER_HDR_LEN);
+	tx_desc->iser_header.flags = ISER_VER;
+
+	iser_dto_add_regd_buff(p_send_dto, p_regd_hdr,
+			       USE_NO_OFFSET, USE_ENTIRE_SIZE);
+}
+
 static int
 iser_check_xmit(struct iscsi_iser_conn  *conn, void *task)
 {
@@ -325,7 +349,7 @@
 	p_ctask->desc.type = ISCSI_TX_SCSI_COMMAND;
 	p_send_dto = &p_ctask->desc.dto;
 	p_send_dto->p_task = p_ctask;
-	iser_dto_send_create(p_iser_conn, &p_ctask->desc);
+	iser_create_send_desc(p_iser_conn, &p_ctask->desc);
 
 	if (sc->use_sg) { /* using a scatter list */
 		data_buf.p_buf = sc->request_buffer;
@@ -367,7 +391,7 @@
 
 send_command_error:
 	if (p_send_dto != NULL) {
-		iser_dto_free(p_send_dto);
+		iser_dto_buffs_release(p_send_dto);
 		/* FIXME we need to dec the ref count */
 	}
 	if (p_iser_conn != NULL) {
@@ -420,7 +444,7 @@
 	/* build the tx desc regd header and add it to the tx desc dto */
 	p_send_dto = &tx_desc->dto;
 	p_send_dto->p_task = p_ctask;
-	iser_dto_send_create(p_iser_conn, tx_desc);
+	iser_create_send_desc(p_iser_conn, tx_desc);
 
 	iser_reg_single(p_iser_conn->ib_conn->p_adaptor,
 			p_send_dto->regd[0], DMA_TO_DEVICE);
@@ -449,7 +473,7 @@
 
 send_data_out_error:
 	if (p_send_dto != NULL)
-		iser_dto_free(p_send_dto);
+		iser_dto_buffs_release(p_send_dto);
 	if (tx_desc != NULL)
 		kmem_cache_free(ig.desc_cache, tx_desc);
 
@@ -484,7 +508,7 @@
 	p_mtask->desc.type = ISCSI_TX_CONTROL;
 	p_send_dto = &p_mtask->desc.dto;
 	p_send_dto->p_task = NULL;
-	iser_dto_send_create(p_iser_conn, &p_mtask->desc);
+	iser_create_send_desc(p_iser_conn, &p_mtask->desc);
 
 	p_iser_adaptor = p_iser_conn->ib_conn->p_adaptor;
 
@@ -492,37 +516,19 @@
 
 	itt = ntohl(p_mtask->hdr->itt);
 	opcode = p_mtask->hdr->opcode & ISCSI_OPCODE_MASK;
+	data_seg_len = ntoh24(p_mtask->hdr->dlength);
 
-	/* no need to copy when there's data b/c the mtask is not reallocated *
-	 * till the response related to this ITT is received	              */
-	switch (opcode) {
-
-	case ISCSI_OP_SCSI_TMFUNC:
-		/* ToDo p_ctrl_pdu->data.task_mgt_req.buf_in */
-	case ISCSI_OP_NOOP_OUT:
-	case ISCSI_OP_LOGIN:
-	case ISCSI_OP_TEXT:
-	case ISCSI_OP_LOGOUT:
-		data_seg_len = ntoh24(p_mtask->hdr->dlength);
-		if (data_seg_len > 0) {
-			p_regd_buf = &p_mtask->desc.data_regd_buf;
-			memset(p_regd_buf, 0, sizeof(struct iser_regd_buf));
-			p_regd_buf->p_adaptor = p_iser_adaptor;
-			p_regd_buf->virt_addr = p_mtask->data;
-			p_regd_buf->data_size = p_mtask->data_count;
-			iser_reg_single(p_iser_adaptor, p_regd_buf,
-					DMA_TO_DEVICE);
-			iser_dto_add_regd_buff(p_send_dto, p_regd_buf,
-					       USE_NO_OFFSET,
-					       USE_SIZE(data_seg_len));
-		}
-		break;
-
-	default:
-		iser_err("Unsupported opcode = %d\n", opcode);
-		err = -EINVAL;
-		goto send_control_error;
-		break;
+	if (data_seg_len > 0) {
+		p_regd_buf = &p_mtask->desc.data_regd_buf;
+		memset(p_regd_buf, 0, sizeof(struct iser_regd_buf));
+		p_regd_buf->p_adaptor = p_iser_adaptor;
+		p_regd_buf->virt_addr = p_mtask->data;
+		p_regd_buf->data_size = p_mtask->data_count;
+		iser_reg_single(p_iser_adaptor, p_regd_buf,
+				DMA_TO_DEVICE);
+		iser_dto_add_regd_buff(p_send_dto, p_regd_buf,
+				       USE_NO_OFFSET,
+				       USE_SIZE(data_seg_len));
 	}
 
 	if (iser_post_receive_control(p_iser_conn) != 0) {
@@ -537,7 +543,7 @@
 
 send_control_error:
 	if (p_send_dto != NULL)
-		iser_dto_free(p_send_dto);
+		iser_dto_buffs_release(p_send_dto);
 	if (p_iser_conn != NULL) {
 		/* drop the conn, open tasks are deleted during shutdown */
 		iser_err("send ctrl failed, drop conn:0x%p\n", p_iser_conn);
@@ -574,15 +580,6 @@
 
 	opcode = p_hdr->opcode & ISCSI_OPCODE_MASK;
 
-	/* FIXME - "task" handles for non cmds */
-	/*
-	if (itt == ISCSI_INVALID_ITT ||
-	    (opcode != ISCSI_OP_SCSI_CMD_RSP &&
-	     opcode != ISCSI_OP_NOOP_IN &&
-	     opcode != ISCSI_OP_TMFUNC_RSP &&
-	     opcode != ISCSI_OP_LOGIN_RSP &&
-	     opcode != ISCSI_OP_TEXT_RSP && opcode != ISCSI_OP_LOGOUT_RSP))
-	*/
 	if (opcode == ISCSI_OP_SCSI_CMD_RSP) {
 		p_session = p_iser_conn->session;
 	        itt = p_hdr->itt;
@@ -610,7 +607,7 @@
 	if(rc)
 		iscsi_iser_conn_failure(p_iser_conn, rc);
 
-	iser_dto_free(p_dto);
+	iser_dto_buffs_release(p_dto);
 	kfree(p_rx_desc->data);
 	kmem_cache_free(ig.desc_cache, p_rx_desc);
 
@@ -628,7 +625,7 @@
 
 	iser_dbg("Initiator, Data sent p_dto=0x%p\n", p_dto);
 
-	iser_dto_free(p_dto);
+	iser_dto_buffs_release(p_dto);
 
 	if(p_tx_desc->type == ISCSI_TX_DATAOUT)
 		kmem_cache_free(ig.desc_cache, p_tx_desc);
@@ -681,3 +678,30 @@
 
 	iser_dma_unmap_task_data(p_iser_task);
 }
+
+/* iser_dto_add_regd_buff - increments the reference count for *
+ * the registered buffer & adds it to the DTO object           */
+void iser_dto_add_regd_buff(struct iser_dto *p_dto,
+			    struct iser_regd_buf *p_regd_buf,
+			    unsigned long use_offset,
+			    unsigned long use_size)
+{
+	int add_idx;
+
+	iser_regd_buff_ref(p_regd_buf);
+
+	add_idx = p_dto->regd_vector_len;
+	p_dto->regd[add_idx] = p_regd_buf;
+	p_dto->used_sz[add_idx] = use_size;
+	p_dto->offset[add_idx] = use_offset;
+
+	p_dto->regd_vector_len++;
+}
+
+void iser_dto_buffs_release(struct iser_dto *p_dto)
+{
+	int i;
+
+	for (i = 0; i < p_dto->regd_vector_len; i++)
+		iser_regd_buff_release(p_dto->regd[i]);
+}
Index: ulp/iser/Makefile
===================================================================
--- ulp/iser/Makefile	(revision 5251)
+++ ulp/iser/Makefile	(revision 5262)
@@ -2,11 +2,9 @@
 
 obj-$(CONFIG_INFINIBAND_ISER)	+= ib_iser.o
 
-ib_iser-y			:= iser_mod.o \
-				   iser_verbs.o \
+ib_iser-y			:= iser_verbs.o \
 				   iser_initiator.o \
 				   iser_memory.o \
-				   iser_dto.o \
 				   iser_socket.o \
 				   iscsi_iser.o \
 				   iser_conn.o \
Index: ulp/iser/iscsi_iser.c
===================================================================
--- ulp/iser/iscsi_iser.c	(revision 5251)
+++ ulp/iser/iscsi_iser.c	(revision 5262)
@@ -4,6 +4,7 @@
  * Copyright (C) 2004 Dmitry Yusupov
  * Copyright (C) 2004 Alex Aizman
  * Copyright (C) 2005 Mike Christie
+ * Copyright (c) 2005, 2006 Voltaire, Inc. All rights reserved.
  * maintained by openib-general at openib.org
  *
  * This program is free software; you can redistribute it and/or modify
@@ -26,7 +27,6 @@
  * Modified by:
  *      Erez Zilber
  *
- * Copyright (c) 2005 Voltaire, Inc. All rights reserved.
  *
  * $Id$
  */
@@ -78,6 +78,21 @@
 static unsigned int iscsi_max_lun = 512;
 module_param_named(max_lun, iscsi_max_lun, uint, S_IRUGO);
 
+#define DRV_VER	     "$Rev$"
+#define DRV_DATE     "$LastChangedDate$"
+
+int iser_debug_level = 0;
+
+MODULE_DESCRIPTION("iSER (iSCSI Extensions for RDMA) Datamover "
+		   "v" DRV_VER "(" DRV_DATE ")");
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_AUTHOR("Alex Nezhinsky, Dan Bar Dov");
+
+module_param_named(debug_level, iser_debug_level, int, 0644);
+MODULE_PARM_DESC(debug_level,"Enable debug tracing if > 0 (default:disabled)");
+
+struct iser_global ig;
+
 /**
  * iscsi_iser_cmd_init - Initialize iSCSI SCSI_READ or SCSI_WRITE commands
  *
@@ -1783,26 +1798,76 @@
 	return rc;
 }
 
-int iscsi_iser_init(void)
+static int __init iser_init(void)
 {
-	int error;
+	int err;
 
+	iser_dbg( "Starting iSER datamover...\n");
+
 	if (iscsi_max_lun < 1) {
 		printk(KERN_ERR "Invalid max_lun value of %u\n", iscsi_max_lun);
 		return -EINVAL;
 	}
+
 	iscsi_iser_transport.max_lun = iscsi_max_lun;
 
-	error = iscsi_register_transport(&iscsi_iser_transport);
-	if (error) {
-		printk(KERN_ERR "iscsi_register_transport failed\n");
-		return error;
+	memset(&ig, 0, sizeof(struct iser_global));
+
+	ig.desc_cache = kmem_cache_create("iser_descriptors",
+					  sizeof (struct iser_desc),
+					  0, SLAB_HWCACHE_ALIGN,
+					  NULL, NULL);
+	if (ig.desc_cache == NULL)
+		return -ENOMEM;
+
+	/* adaptor init is called only after the first addr resolution */
+	init_MUTEX(&ig.adaptor_list_sem);
+	INIT_LIST_HEAD(&ig.adaptor_list);
+	ig.num_adaptors = 0;
+
+	err = iser_register_sockets();
+	if (err) {
+		iser_err("iser socket init failed!\n");
+		goto register_socket_failure;
 	}
+
+	err = iscsi_register_transport(&iscsi_iser_transport);
+	if (err) {
+		iser_err("iscsi_register_transport failed\n");
+		goto register_transport_failure;
+	}
+
 	return 0;
+
+register_transport_failure:
+	iser_unreg_sockets();
+register_socket_failure:
+	kmem_cache_destroy(ig.desc_cache);
+
+	return err;
 }
 
-void iscsi_iser_exit(void)
+static void __exit iser_exit(void)
 {
+	struct iser_adaptor *p_adaptor;
+
+	iser_dbg( "Removing iSER datamover...\n");
+
 	iscsi_unregister_transport(&iscsi_iser_transport);
+
+	while(!list_empty(&ig.adaptor_list)) {
+		p_adaptor = list_entry(ig.adaptor_list.next,
+				       struct iser_adaptor, ig_list);
+		list_del(&p_adaptor->ig_list);
+		iser_adaptor_release(p_adaptor);
+		kfree(p_adaptor);
+		ig.num_adaptors--;
+	}
+
+	kmem_cache_destroy(ig.desc_cache);
+
+	iser_unreg_sockets();
 }
 
+module_init(iser_init);
+module_exit(iser_exit);
Index: ulp/iser/iser_mod.c
===================================================================
--- ulp/iser/iser_mod.c	(revision 5251)
+++ ulp/iser/iser_mod.c	(revision 5262)
@@ -1,141 +0,0 @@
-/*
- * Copyright (c) 2004, 2005, 2006 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 MODULE
-#define MODULE
-#endif
-
-#ifndef __KERNEL__
-#define __KERNEL__
-#endif
-
-#include <linux/config.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/slab.h>
-#include <linux/proc_fs.h>
-#include <linux/ctype.h>
-#include <linux/interrupt.h>
-
-#include "iscsi_iser.h"
-#include "iser_socket.h"
-
-#define DRV_VER	     "$Rev: 135 $"
-#define DRV_DATE     "$LastChangedDate: 2005-11-29 15:24:35 +0200 (Tue, 29 Nov 2005) $"
-
-int iser_debug_level = 0;
-
-MODULE_DESCRIPTION("iSER (iSCSI Extensions for RDMA) Datamover "
-		   "v" DRV_VER "(" DRV_DATE ")");
-MODULE_LICENSE("Dual BSD/GPL");
-MODULE_AUTHOR("Alex Nezhinsky, Dan Bar Dov");
-
-module_param_named(debug_level, iser_debug_level, int, 0644);
-MODULE_PARM_DESC(debug_level,"Enable debug tracing if > 0 (default:disabled)");
-
-struct iser_global ig;
-
-static void iser_global_release(void);
-
-/**
- * init_module - module initialization function
- */
-int init_module(void)
-{
-	int err;
-
-	iser_dbg( "Starting iSER datamover...\n");
-
-	memset(&ig, 0, sizeof(struct iser_global));
-
-	ig.desc_cache = kmem_cache_create("iser_descriptors",
-					  sizeof (struct iser_desc),
-					  0, SLAB_HWCACHE_ALIGN,
-					  NULL, NULL);
-	if (ig.desc_cache == NULL)
-		return -ENOMEM;
-
-	/* adaptor init is called only after the first addr resolution */
-	init_MUTEX(&ig.adaptor_list_sem);
-	INIT_LIST_HEAD(&ig.adaptor_list);
-	ig.num_adaptors = 0;
-
-	err = iser_register_sockets();
-	if (err) {
-		iser_err("iser socket init failed!\n");
-		iser_global_release();
-		return err;
-	}
-
-	return iscsi_iser_init();
-}
-
-/**
- * iser_global_release - Releases all resources
- */
-static void iser_global_release(void)
-{
-	int err;
-	struct iser_adaptor *p_adaptor;
-
-	iscsi_iser_exit();
-
-	while(!list_empty(&ig.adaptor_list)) {
-		p_adaptor = list_entry(ig.adaptor_list.next,
-				       struct iser_adaptor, ig_list);
-		list_del(&p_adaptor->ig_list);
-		iser_adaptor_release(p_adaptor);
-		kfree(p_adaptor);
-		ig.num_adaptors--;
-	}
-
-	if (ig.desc_cache != NULL) {
-		err = kmem_cache_destroy(ig.desc_cache);
-		if(err)
-			iser_err("kmem_cache_destory returned %d\n",err);
-		ig.desc_cache = NULL;
-	}
-
-	iser_unreg_sockets();
-}
-
-/**
- * cleanup_module - module cleanup function
- */
-void cleanup_module(void)
-{
-	iser_dbg( "Removing iSER datamover...\n");
-	iser_global_release();
-}
Index: ulp/iser/iser_dto.c
===================================================================
--- ulp/iser/iser_dto.c	(revision 5251)
+++ ulp/iser/iser_dto.c	(revision 5262)
@@ -1,117 +0,0 @@
-/*
- * Copyright (c) 2004, 2005, 2006 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$
- */
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <asm/io.h>
-
-#include "iscsi_iser.h"
-
-/**
- * iser_dto_add_regd_buff - Increments the reference count for the registered
- *	buffer & adds it to the DTO object
- *
- * returns index of used buffer
- */
-int iser_dto_add_regd_buff(struct iser_dto *p_dto,
-			   struct iser_regd_buf *p_regd_buf,
-			   unsigned long use_offset,
-			   unsigned long use_size)
-{
-	int add_idx;
-
-	iser_regd_buff_ref(p_regd_buf);
-
-	add_idx = p_dto->regd_vector_len;
-	p_dto->regd[add_idx] = p_regd_buf;
-	p_dto->used_sz[add_idx] = use_size;
-	p_dto->offset[add_idx] = use_offset;
-
-	p_dto->regd_vector_len++;
-
-	return add_idx;
-}
-
-/**
- *  iser_dto_buffs_release - free all registered buffers
- */
-void iser_dto_buffs_release(struct iser_dto *p_dto)
-{
-	int i;
-
-	for (i = 0; i < p_dto->regd_vector_len; i++) {
-		iser_dbg("Releasing DTO:0x%p, regd.buf:0x%p, #%d\n",
-			 p_dto, p_dto->regd[i], i);
-		iser_regd_buff_release(p_dto->regd[i]);
-		p_dto->regd[i] = NULL;
-	}
-}
-
-/**
- * iser_dto_free - Frees DTO descriptor and all associated buffers
- */
-void iser_dto_free(struct iser_dto *p_dto)
-{
-	iser_dto_buffs_release(p_dto);
-}
-
-
-/**
- * Creates a new send DTO descriptor,
- * adds header regd buffer
- *
- */
-void iser_dto_send_create(struct iscsi_iser_conn *p_iser_conn,
-			  struct iser_desc       *tx_desc)
-{
-	struct iser_regd_buf *p_regd_hdr = &tx_desc->hdr_regd_buf;
-	struct iser_dto      *p_send_dto = &tx_desc->dto;
-
-	memset(p_regd_hdr, 0, sizeof(struct iser_regd_buf));
-	p_regd_hdr->p_adaptor  = p_iser_conn->ib_conn->p_adaptor;
-	p_regd_hdr->virt_addr  = tx_desc; /* == &tx_desc->iser_header */
-	p_regd_hdr->data_size  = ISER_TOTAL_HEADERS_LEN;
-
-	p_send_dto->p_conn          = p_iser_conn;
-	p_send_dto->notify_enable   = 1;
-	p_send_dto->regd_vector_len = 0;
-
-	memset(&tx_desc->iser_header, 0, ISER_HDR_LEN);
-	tx_desc->iser_header.flags = ISER_VER;
-
-	iser_dto_add_regd_buff(p_send_dto, p_regd_hdr,
-			       USE_NO_OFFSET, USE_ENTIRE_SIZE);
-}
-




More information about the general mailing list