[openib-general] [PATCH v2] iw_cm.h file with formatting changes

Tom Tucker tom at opengridcomputing.com
Fri Feb 24 07:58:24 PST 2006


Here is another version of the iw_cm.h file updated with the 
suggested formatting changes. Thanks for the comments.

I have not changed the size of the pdata len yet. 

WRT casting the iWARP dev_addr to an ib_gid, the purpose for doing 
this was to simplify the cma_acquire_dev logic as follows....

static int cma_acquire_dev(struct rdma_id_private *id_priv)
{
	enum rdma_node_type dev_type = id_priv->id.route.addr.dev_addr.dev_type;
	struct cma_device *cma_dev;
	union ib_gid *gid;
	int ret = -ENODEV;

	switch (rdma_node_get_transport(dev_type)) {
	case RDMA_TRANSPORT_IB:
		gid = ib_addr_get_sgid(&id_priv->id.route.addr.dev_addr);
		break;
	case RDMA_TRANSPORT_IWARP:
		gid = iw_addr_get_sgid(&id_priv->id.route.addr.dev_addr);
		break;
	default:
		return -ENODEV;
	}

	mutex_lock(&lock);
	list_for_each_entry(cma_dev, &dev_list, list) {
		ret = ib_find_cached_gid(cma_dev->device, gid,
					 &id_priv->id.port_num, NULL);
		if (!ret) {
			cma_attach_to_dev(id_priv, cma_dev);
			break;
		}
	}
	mutex_unlock(&lock);
	return ret;
}

Since iWARP devices advertise their Ethernet addresses as port 
GIDs, this all works. Although the 'name' may be (ok, it is) misleading, the 
result simplifies the logic.


Signed-off-by: Tom Tucker <tom at opengridcomputing.com>


Index: include/rdma/iw_cm.h
===================================================================
--- include/rdma/iw_cm.h	(revision 0)
+++ include/rdma/iw_cm.h	(revision 0)
@@ -0,0 +1,153 @@
+/*
+ * Copyright (c) 2005 Network Appliance, Inc. All rights reserved.
+ * Copyright (c) 2005 Open Grid Computing, 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.
+ */
+#if !defined(IW_CM_H)
+#define IW_CM_H
+
+#include <linux/in.h>
+#include <rdma/ib_cm.h>
+
+struct iw_cm_id;
+struct iw_cm_event;
+
+enum iw_cm_event_type {
+	IW_CM_EVENT_CONNECT_REQUEST = 1, /* connect request received */
+	IW_CM_EVENT_CONNECT_REPLY,	 /* reply from active connect request */
+	IW_CM_EVENT_ESTABLISHED,
+	IW_CM_EVENT_LLP_DISCONNECT,
+	IW_CM_EVENT_LLP_RESET,
+	IW_CM_EVENT_LLP_TIMEOUT,
+	IW_CM_EVENT_CLOSE
+};
+
+struct iw_cm_event {
+	enum iw_cm_event_type event;
+	int status;
+	u32 provider_id;
+	struct sockaddr_in local_addr;
+	struct sockaddr_in remote_addr;
+	void *private_data;
+	u8 private_data_len;
+};
+
+typedef int (*iw_cm_handler)(struct iw_cm_id *cm_id,
+			     struct iw_cm_event *event);
+
+enum iw_cm_state {
+	IW_CM_STATE_IDLE,             /* unbound, inactive */
+	IW_CM_STATE_LISTEN,           /* listen waiting for connect */
+	IW_CM_STATE_CONN_SENT,        /* outbound waiting for peer accept */
+	IW_CM_STATE_CONN_RECV,        /* inbound waiting for user accept */
+	IW_CM_STATE_ESTABLISHED,      /* established */
+};
+
+typedef void (*iw_event_handler)(struct iw_cm_id *cm_id,
+				 struct iw_cm_event *event);
+struct iw_cm_id {
+	iw_cm_handler	        cm_handler;      /* client callback function */
+	void		        *context;	 /* context to provide to client cb */
+	enum iw_cm_state        state;
+	struct ib_device        *device;	 
+	struct ib_qp            *qp;             /* If the qp is null, use qp_num */
+	u32                     qp_num;
+	struct sockaddr_in      local_addr;
+	struct sockaddr_in      remote_addr;
+	u64                     provider_id;     /* device handle for this conn. */
+	iw_event_handler        event_handler;   /* callback for IW CM Provider events */
+};
+
+/**
+ * iw_create_cm_id - Allocate a communication identifier.
+ * @device: Device associated with the cm_id.  All related communication will
+ * be associated with the specified device.
+ * @cm_handler: Callback invoked to notify the user of CM events.
+ * @context: User specified context associated with the communication
+ *   identifier.
+ *
+ * Communication identifiers are used to track connection states, 
+ * addr resolution requests, and listen requests.
+ */
+struct iw_cm_id *iw_create_cm_id(struct ib_device *device,
+				 iw_cm_handler cm_handler,
+				 void *context);
+
+/* This is provided in the event generated when 
+ * a remote peer accepts our connect request
+ */
+
+struct iw_cm_verbs {
+	int	(*connect)(struct iw_cm_id *cm_id,
+			   const void *private_data,
+			   u8 private_data_len);
+	
+	int	(*disconnect)(struct iw_cm_id *cm_id, 
+			      int abrupt);
+
+	int	(*accept)(struct iw_cm_id *cm_id,
+			  const void *private_data, 
+			  u8 pdata_data_len); 
+
+	int	(*reject)(struct iw_cm_id *cm_id, 
+			  const void *private_data, 
+			  u8 private_data_len); 
+
+	int	(*getpeername)(struct iw_cm_id *cm_id,
+			       struct sockaddr_in *local_addr,
+			       struct sockaddr_in *remote_addr);
+
+	int	(*create_listen)(struct iw_cm_id *cm_id,
+				 int backlog);
+
+	int	(*destroy_listen)(struct iw_cm_id *cm_id);
+
+};
+
+struct iw_cm_id *iw_create_cm_id(struct ib_device *device,
+				 iw_cm_handler cm_handler,
+				 void *context);
+void iw_destroy_cm_id(struct iw_cm_id *cm_id);
+int iw_cm_listen(struct iw_cm_id *cm_id, int backlog);
+int iw_cm_getpeername(struct iw_cm_id *cm_id,
+		      struct sockaddr_in *local_add,
+		      struct sockaddr_in *remote_addr);
+int iw_cm_reject(struct iw_cm_id *cm_id, 
+		 const void *private_data,
+		 u8 private_data_len);
+int iw_cm_accept(struct iw_cm_id *cm_id,
+		 const void *private_data,
+		 u8 private_data_len);
+int iw_cm_connect(struct iw_cm_id *cm_id, 
+		  const void *pdata, u8 pdata_len);
+int iw_cm_disconnect(struct iw_cm_id *cm_id); 
+int iw_cm_bind_qp(struct iw_cm_id *cm_id, struct ib_qp *qp);
+
+#endif /* IW_CM_H */




More information about the general mailing list