c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * CDDL HEADER START
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * The contents of this file are subject to the terms of the
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * Common Development and Distribution License (the "License").
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * You may not use this file except in compliance with the License.
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * or http://www.opensolaris.org/os/licensing.
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * See the License for the specific language governing permissions
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * and limitations under the License.
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * When distributing Covered Code, include this CDDL HEADER in each
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * If applicable, add the following below this CDDL HEADER, with the
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * fields enclosed by brackets "[]" replaced with your own identifying
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * information: Portions Copyright [yyyy] [name of copyright owner]
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * CDDL HEADER END
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#include <sys/ib/clients/of/sol_ofs/sol_ofs_common.h>
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#include <sys/ib/clients/of/sol_ofs/sol_ib_cma.h> /* Transport Specific */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#define IS_UDP_CMID(idp) ((idp)->ps == RDMA_PS_UDP || \
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * Global structure which contains information about all
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * CMIDs, which have called rdma_listen().
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar/* State of the RDMA-CM ID */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikartypedef enum {
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar /* For Root CMIDs, pointer to global listen info */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar sol_cma_glbl_listen_t *chan_glbl_listen_info;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * For EP CMIDs, pointer to ib_device and root CMID
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * Count & list of EPs for this listen_info.
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * This is 0, if listen_is_root is 0.
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar /* Transport Specific */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar /* For Root CMID */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar /* For Endpoint CMID */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#define listen_ib_srv_hdl un_listen._listen_srv_hdl
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#define listen_ib_sbind_hdl un_listen._listen_sbind_hdl
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikartypedef enum {
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung * This is used to track the state of a client side CMID.
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung * CONNECT_NONE Server side CMID, or CMID for which
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung * rdma_connect() has not been called.
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung * CLIENT_NONE Client side CMID for which connection
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung * has been torn down.
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung * For UDP it also represents connection
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung * established (no more IBTF CM events
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung * INITIATED rdma_connect() has been called not yet
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung * established.
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung * ESTABLISHED Client CMID has connection established.
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikartypedef enum {
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung * This is used to track the state of CMIDs created for Connection
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung * Requests and listening CMID.
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung * NONE Client CMID, listen CMID with no REQs yet.
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung * SERVER_DONE REQ CMID connection done, no more events.
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung * For listening CMID all REQ CMIDs have events
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung * CREATED listening CMID with > 1 REQ CMID with events
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung * QUEUED REQ CMID in REQ AVL tree of listening CMID
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung * ACCEPTED REQ CMID accepted and in ACPT AVL tree of the
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung * listening CMID.
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheungtypedef enum {
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung ((chanp)->chan_connect_flag != SOL_CMA_CONNECT_NONE)
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung ((chanp)->chan_req_state == REQ_CMID_QUEUED || \
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung ((chanp)->chan_connect_flag == SOL_CMA_CONNECT_INITIATED || \
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung (chanp)->chan_connect_flag == SOL_CMA_CONNECT_ESTABLISHED || \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * CMID_DESTROYED - Flag to indicate rdma_destroy_id has been
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * called for this CMID
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * EVENT_PROGRESS - RDMACM Event for this CMID been passed to
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * the sol_ofs client.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * API_PROGRESS - rdma_resolve_addr() / rdma_resolve_route() /
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * rdma_listen() is in progress.
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikartypedef struct {
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * Below are all CMA Channel specific fields required in Solaris,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * apart from rdma_cm_id.
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar /* AVL Tree for REQs and EST CMIDs */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * chan_req_cnt -
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * REQ CMIDs created not yet notified to client
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * chan_total_req_cnt -
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * REQ CMIDs created not destroy_id(0 not called.
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung /* State for Server side and client side CMIDs */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * Transport type for the rdma_id, IB or IWARP. This is set to
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * NONE, when the transport type is not yet determined.
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * Passed from sol_ofs consumer, using the rdma_map_id2clnthdl
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * and rdma_map_id2qphdl
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar /* Data for root / endpoint CM ID. */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar /* Ptr to the root CMID for Endpoint & Req CMID */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#define CHAN_LISTEN_LIST(chanp) (((chanp)->chan_listenp)->listen_list)
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#define CHAN_LISTEN_ROOT(chanp) ((chanp)->listen_root)
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar /* Session ID for completion */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarvoid ibcma_append_listen_list(struct rdma_cm_id *);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarvoid iwcma_append_listen_list(struct rdma_cm_id *);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarextern void cma_generate_event(struct rdma_cm_id *, enum rdma_cm_event_type,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar int, struct rdma_conn_param *, struct rdma_ud_param *);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarextern struct ib_device *sol_cma_acquire_device(ib_guid_t);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarstatic inline int
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar return (in_addr->sin_addr.s_addr == INADDR_ANY);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar return (IN6_IS_ADDR_UNSPECIFIED(&(in6_addr->sin6_addr)));
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarstatic inline struct rdma_cm_id *
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar newid = rdma_create_id(srcid->event_handler, srcid->context,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar sol_cma_acquire_device(srcid->device->node_guid);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar bcopy(&((srcid->route).addr), &((newid->route).addr),
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar sizeof (struct rdma_addr));
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar (newid->route).path_rec = kmem_zalloc(num_paths *
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar num_paths * sizeof (struct ib_sa_path_rec));
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar new_chanp->chan_state = src_chanp->chan_state;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar new_chanp->chan_xport_type = src_chanp->chan_xport_type;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar CHAN_LISTEN_ROOT(new_chanp) = CHAN_LISTEN_ROOT(src_chanp);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarstatic inline struct rdma_cm_id *
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarcma_get_req_idp(struct rdma_cm_id *root_idp, void *qp_hdl)
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar &root_chanp->chan_req_avl_tree, (void *)qp_hdl, NULL);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarstatic inline struct rdma_cm_id *
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarcma_get_acpt_idp(struct rdma_cm_id *root_idp, void *qp_hdl)
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar &root_chanp->chan_acpt_avl_tree, (void *)qp_hdl, NULL);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#endif /* _SYS_IB_CLIENTS_OF_SOL_OFS_SOL_CMA_H */