[openib-general] [PATCH] [RFC] RDMA generic CMA updates

Sean Hefty sean.hefty at intel.com
Wed Sep 21 16:34:38 PDT 2005


The following patch updates the original CMA APIs.

Updated implementation to follow.

If there's agreement, can we check this into svn under the ULP directory?

Signed-off-by: Sean Hefty <sean.hefty at intel.com>


/*
 * Copyright (c) 2005 Voltaire Inc.  All rights reserved.
 * Copyright (c) 2005 Intel Corporation.  All rights reserved.
 *
 * This Software is licensed under one of the following licenses:
 *
 * 1) under the terms of the "Common Public License 1.0" a copy of which is
 *    available from the Open Source Initiative, see
 *    http://www.opensource.org/licenses/cpl.php.
 *
 * 2) under the terms of the "The BSD License" a copy of which is
 *    available from the Open Source Initiative, see
 *    http://www.opensource.org/licenses/bsd-license.php.
 *
 * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
 *    copy of which is available from the Open Source Initiative, see
 *    http://www.opensource.org/licenses/gpl-license.php.
 *
 * Licensee has the right to choose one of the above licenses.
 *
 * Redistributions of source code must retain the above copyright
 * notice and one of the license notices.
 *
 * Redistributions in binary form must reproduce both the above copyright
 * notice, one of the license notices in the documentation
 * and/or other materials provided with the distribution.
 *
 */

#if !defined(RDMA_CMA_H)
#define RDMA_CMA_H

#include <linux/socket.h>
#include <linux/in.h>
#include <rdma/ib_verbs.h>
#include <rdma/ib_sa.h>

enum rdma_cma_event_type {
	RDMA_CMA_EVENT_ROUTE_FOUND,
	RDMA_CMA_EVENT_CONNECT_REQUEST,
	RDMA_CMA_EVENT_CONNECT_ERROR,
	RDMA_CMA_EVENT_UNREACHABLE,
	RDMA_CMA_EVENT_REJECTED,
	RDMA_CMA_EVENT_ESTABLISHED,
	RDMA_CMA_EVENT_DISCONNECTED,
};

struct rdma_route {
	struct sockaddr src_addr;
	struct sockaddr dest_addr;
	struct ib_sa_path_rec path_rec;
};

struct rdma_cma_event {
	enum rdma_cma_event_type event;
	void			*private_data;
};

struct rdma_cma_id;

typedef void (*rdma_cma_event_handler)(struct rdma_cma_id *cma_id,
				       struct rdma_cma_event *event);

struct rdma_cma_id {
	struct ib_device	*device;
	void			*context;
	struct ib_qp		*qp;
	rdma_cma_event_handler	 event_handler;
	struct rdma_route	*route;
};

struct rdma_cma_id* rdma_cma_create_id(struct ib_device *device, void *context,
				       rdma_cma_event_handler event_handler);

void rdma_cma_destroy_id(struct rdma_cma_id *cma_id);

/**
 * rdma_cma_listen - this function is called by the passive side. It is
 *   listening on a the specified port for incomming connection requests.
 */
int rdma_cma_listen(struct rdma_cma_id *cma_id, struct sockaddr *addr);

int rdma_cma_get_route(struct rdma_cma_id *cma_id,
		       struct sockaddr *src_addr, struct sockaddr *dest_addr);

struct rdma_cma_conn_param {
	struct ib_qp *qp;
	const void *private_data;
	u8 private_data_len;
	u8 responder_resources;
	u8 initiator_depth;
	u8 flow_control;
	u8 retry_count;		/* ignored when accepting */
	u8 rnr_retry_count;
};

/**
 * rdma_cma_connect - this is the connect request function, called by 
 *   the active side. The consumer registers an upcall that will be 
 *   initiated by the cma with an appropriate connection event 
 *   notification (established/rejected/disconnected etc)
 *
 * Note that the QP must be in the INIT state before calling this routine.
 */
int rdma_cma_connect(struct rdma_cma_id *cma_id,
		     struct rdma_cma_conn_param *conn_param);

/**
 * rdma_cma_accept - call on the passive side to accept a connection request
 *   note that if the function returned with error - a reject message was
 *   sent to the remote side and the cma_id was destroyed.
 *
 * Note that the QP must be in the INIT state before calling this routine.
 */
int rdma_cma_accept(struct rdma_cma_id *cma_id,
		    struct rdma_cma_conn_param *conn_param);

/**
 * rdma_cma_reject - call on the passive side to reject a connection request.
 *   This call destroys the cma_id, hence when the active side accepts
 *   the reject the cma_id is already destroyed.
 * @cma_id: this handle was accepted in cma_listen callback
 * @private_data: private data to send back to the initiator
 * @private_data_len: private data length
 */
int rdma_cma_reject(struct rdma_cma_id *cma_id,
		    const void *private_data, u8 private_data_len);

/**
 * rdma_cma_disconnect - this function disconnects the associated QP.
 */
int rdma_cma_disconnect(struct rdma_cma_id *cma_id);

/* TODO: need a way to map IP address to a device or get IP addresses
   associated with a device */

#endif /* RDMA_CMA_H */






More information about the general mailing list