c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar/*
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * CDDL HEADER START
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar *
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 *
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 *
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 *
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * CDDL HEADER END
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar/*
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#ifndef _SYS_IB_CLIENTS_OF_SOL_OFS_SOL_CMA_H
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#define _SYS_IB_CLIENTS_OF_SOL_OFS_SOL_CMA_H
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#ifdef __cplusplus
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarextern "C" {
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#endif
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
5c5f137104b2d56181283389fa902220f2023809Richard Lowe#include <sys/sysmacros.h>
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#include <sys/ib/clients/of/sol_ofs/sol_ofs_common.h>
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#include <sys/ib/clients/of/rdma/rdma_cm.h>
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#include <sys/ib/clients/of/sol_ofs/sol_ib_cma.h> /* Transport Specific */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#define IS_UDP_CMID(idp) ((idp)->ps == RDMA_PS_UDP || \
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar (idp)->ps == RDMA_PS_IPOIB)
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#define IS_VALID_SOCKADDR(sockaddrp) \
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar ((sockaddrp)->sa_family == AF_INET || \
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar (sockaddrp)->sa_family == AF_INET6)
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar/*
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * Global structure which contains information about all
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * CMIDs, which have called rdma_listen().
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikartypedef struct sol_cma_glbl_listen_s {
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar avl_node_t cma_listen_node;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar uint64_t cma_listen_chan_sid;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar void *cma_listen_clnt_hdl;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar void *cma_listen_svc_hdl;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar genlist_t cma_listen_chan_list;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar} sol_cma_glbl_listen_t;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar/* State of the RDMA-CM ID */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikartypedef enum {
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar SOL_CMA_CHAN_IDLE,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar SOL_CMA_CHAN_BOUND,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar SOL_CMA_CHAN_ADDR_QUERY,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar SOL_CMA_CHAN_ADDR_BOUND,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar SOL_CMA_CHAN_ADDR_RESLVD,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar SOL_CMA_CHAN_ROUTE_QUERY,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar SOL_CMA_CHAN_ROUTE_RESLVD,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar SOL_CMA_CHAN_EVENT_NOTIFIED,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar SOL_CMA_CHAN_CONNECT,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar SOL_CMA_CHAN_LISTEN,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar SOL_CMA_CHAN_DISCONNECT,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar SOL_CMA_CHAN_ACCEPT,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar SOL_CMA_CHAN_REJECT,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar SOL_CMA_CHAN_DESTROYING,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar SOL_CMA_CHAN_DESTROY_PENDING,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar SOL_CMA_CHAN_DESTROY_WAIT,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar SOL_CMA_CHAN_HCA_DOWN,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar SOL_CMA_CHAN_PORT_DOWN
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar} cma_chan_state_t;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikartypedef struct listen_info_s {
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar uint8_t listen_is_root;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar /* For Root CMIDs, pointer to global listen info */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar genlist_entry_t *listen_entry;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar sol_cma_glbl_listen_t *chan_glbl_listen_info;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar /*
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * For EP CMIDs, pointer to ib_device and root CMID
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * for HCA DR
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar genlist_entry_t *listen_ep_dev_entry;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar genlist_entry_t *listen_ep_root_entry;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar struct ib_device *listen_ep_device;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar /*
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * Count & list of EPs for this listen_info.
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * This is 0, if listen_is_root is 0.
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar uint32_t listen_eps;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar genlist_t listen_list;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar /* Transport Specific */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar union {
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar /* For Root CMID */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar ibt_srv_hdl_t _listen_srv_hdl;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar /* For Endpoint CMID */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar ibt_sbind_hdl_t _listen_sbind_hdl;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar } un_listen;
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 Gunjikar} sol_cma_listen_info_t;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikartypedef enum {
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar SOL_CMA_XPORT_NONE = 0,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar SOL_CMA_XPORT_IB,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar SOL_CMA_XPORT_IWARP
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar} sol_cma_xport_type_t;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung/*
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 *
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung * CLIENT_NONE Client side CMID for which connection
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung * has been torn down.
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung *
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung * For UDP it also represents connection
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung * established (no more IBTF CM events
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung * expected).
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung *
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung * INITIATED rdma_connect() has been called not yet
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung * established.
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung *
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung * ESTABLISHED Client CMID has connection established.
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikartypedef enum {
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar SOL_CMA_CONNECT_NONE = 0,
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung SOL_CMA_CONNECT_CLIENT_NONE,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar SOL_CMA_CONNECT_INITIATED,
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung SOL_CMA_CONNECT_ESTABLISHED,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar} sol_cma_connect_flag_t;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung/*
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung * This is used to track the state of CMIDs created for Connection
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung * Requests and listening CMID.
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung *
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung * NONE Client CMID, listen CMID with no REQs yet.
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung *
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung * SERVER_DONE REQ CMID connection done, no more events.
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung *
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung * For listening CMID all REQ CMIDs have events
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung * completed.
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung *
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung * CREATED listening CMID with > 1 REQ CMID with events
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung * pending.
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung *
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung * QUEUED REQ CMID in REQ AVL tree of listening CMID
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung *
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung * ACCEPTED REQ CMID accepted and in ACPT AVL tree of the
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung * listening CMID.
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung */
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheungtypedef enum {
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung REQ_CMID_NONE = 0,
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung REQ_CMID_SERVER_NONE,
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung REQ_CMID_CREATED,
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung REQ_CMID_QUEUED,
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung REQ_CMID_NOTIFIED,
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung REQ_CMID_ACCEPTED,
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung} cma_req_cmid_state_t;
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung#define SOL_IS_SERVER_CMID(chanp) \
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung ((chanp)->chan_req_state != REQ_CMID_NONE)
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung#define SOL_IS_CLIENT_CMID(chanp) \
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung ((chanp)->chan_connect_flag != SOL_CMA_CONNECT_NONE)
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung#define REQ_CMID_IN_REQ_AVL_TREE(chanp) \
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung ((chanp)->chan_req_state == REQ_CMID_QUEUED || \
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung (chanp)->chan_req_state == REQ_CMID_NOTIFIED)
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung#define SOL_CMID_CLOSE_REQUIRED(chanp) \
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung ((chanp)->chan_connect_flag == SOL_CMA_CONNECT_INITIATED || \
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung (chanp)->chan_connect_flag == SOL_CMA_CONNECT_ESTABLISHED || \
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung (chanp)->chan_req_state == REQ_CMID_ACCEPTED)
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung#define SOL_CMAID_CONNECTED(chanp) \
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung (SOL_CMID_CLOSE_REQUIRED(chanp) || \
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung (chanp)->chan_req_state == REQ_CMID_NOTIFIED)
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/*
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * CMID_DESTROYED - Flag to indicate rdma_destroy_id has been
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * called for this CMID
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota *
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * EVENT_PROGRESS - RDMACM Event for this CMID been passed to
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * the sol_ofs client.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota *
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * API_PROGRESS - rdma_resolve_addr() / rdma_resolve_route() /
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * rdma_listen() is in progress.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#define SOL_CMA_CALLER_CMID_DESTROYED 0x01
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#define SOL_CMA_CALLER_EVENT_PROGRESS 0x02
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#define SOL_CMA_CALLER_API_PROGRESS 0x04
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikartypedef struct {
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar struct rdma_cm_id chan_rdma_cm;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar /*
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * Below are all CMA Channel specific fields required in Solaris,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * apart from rdma_cm_id.
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar /* AVL Tree for REQs and EST CMIDs */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar avl_node_t chan_req_avl_node;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar avl_node_t chan_acpt_avl_node;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar avl_tree_t chan_req_avl_tree;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar avl_tree_t chan_acpt_avl_tree;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar /*
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.
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar uint64_t chan_req_cnt;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar uint64_t chan_req_total_cnt;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung /* State for Server side and client side CMIDs */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar cma_req_cmid_state_t chan_req_state;
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung sol_cma_connect_flag_t chan_connect_flag;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar kmutex_t chan_mutex;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar kcondvar_t chan_destroy_cv;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar cma_chan_state_t chan_state;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar uint8_t chan_cmid_destroy_state;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar /*
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 */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar sol_cma_xport_type_t chan_xport_type;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar /*
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * Passed from sol_ofs consumer, using the rdma_map_id2clnthdl
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * and rdma_map_id2qphdl
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar void *chan_ib_client_hdl;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar void *chan_iw_client_hdl;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar void *chan_qp_hdl;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar /* Data for root / endpoint CM ID. */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar sol_cma_listen_info_t *chan_listenp;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar /* Ptr to the root CMID for Endpoint & Req CMID */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar struct rdma_cm_id *listen_root;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#define CHAN_LISTEN_LIST(chanp) (((chanp)->chan_listenp)->listen_list)
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#define CHAN_LISTEN_ROOT(chanp) ((chanp)->listen_root)
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar struct rdma_conn_param chan_param;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar /* Session ID for completion */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar void *chan_session_id;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota uint32_t chan_qp_num;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota uint8_t chan_is_srq;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar union {
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar ibcma_chan_t chan_ib_xport;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar } un_xport; /* Transport specific fields */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#define chan_ib un_xport.chan_ib_xport
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar} sol_cma_chan_t;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarvoid ibcma_append_listen_list(struct rdma_cm_id *);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#ifdef IWARP_SUPPORT
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarvoid iwcma_append_listen_list(struct rdma_cm_id *);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#endif
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
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 Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarstatic inline int
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarsol_cma_any_addr(struct sockaddr *addr)
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar{
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar ASSERT(addr);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar if (addr->sa_family == AF_INET) {
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar struct sockaddr_in *in_addr;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar in_addr = (struct sockaddr_in *)addr;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar return (in_addr->sin_addr.s_addr == INADDR_ANY);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar } else if (addr->sa_family == AF_INET6) {
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar struct sockaddr_in6 *in6_addr;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar in6_addr = (struct sockaddr_in6 *)addr;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar return (IN6_IS_ADDR_UNSPECIFIED(&(in6_addr->sin6_addr)));
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar }
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar return (0);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar}
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarstatic inline struct rdma_cm_id *
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarcma_create_new_id(struct rdma_cm_id *srcid)
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar{
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar struct rdma_cm_id *newid;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar sol_cma_chan_t *new_chanp, *src_chanp;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar newid = rdma_create_id(srcid->event_handler, srcid->context,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar srcid->ps);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar if (newid == NULL)
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar return (newid);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar if (srcid->device) {
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar newid->device =
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar sol_cma_acquire_device(srcid->device->node_guid);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar }
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar bcopy(&((srcid->route).addr), &((newid->route).addr),
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar sizeof (struct rdma_addr));
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar if ((srcid->route).num_paths) {
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar int num_paths;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar num_paths = (newid->route).num_paths =
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar (srcid->route).num_paths;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar (newid->route).path_rec = kmem_zalloc(num_paths *
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar sizeof (struct ib_sa_path_rec), KM_SLEEP);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar bcopy(&((srcid->route).path_rec),
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar &((newid->route).path_rec),
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar num_paths * sizeof (struct ib_sa_path_rec));
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar }
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar newid->port_num = srcid->port_num;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar new_chanp = (sol_cma_chan_t *)newid;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar src_chanp = (sol_cma_chan_t *)srcid;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar new_chanp->chan_state = src_chanp->chan_state;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar new_chanp->chan_xport_type = src_chanp->chan_xport_type;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar if (CHAN_LISTEN_ROOT(src_chanp))
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar CHAN_LISTEN_ROOT(new_chanp) = CHAN_LISTEN_ROOT(src_chanp);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar else
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar CHAN_LISTEN_ROOT(new_chanp) = srcid;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar return (newid);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar}
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarstatic inline struct rdma_cm_id *
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarcma_get_req_idp(struct rdma_cm_id *root_idp, void *qp_hdl)
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar{
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar struct rdma_cm_id *req_idp;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar sol_cma_chan_t *root_chanp;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar root_chanp = (sol_cma_chan_t *)root_idp;
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung ASSERT(MUTEX_HELD(&root_chanp->chan_mutex));
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar req_idp = (struct rdma_cm_id *)avl_find(
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar &root_chanp->chan_req_avl_tree, (void *)qp_hdl, NULL);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar return (req_idp);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar}
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarstatic inline struct rdma_cm_id *
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarcma_get_acpt_idp(struct rdma_cm_id *root_idp, void *qp_hdl)
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar{
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar struct rdma_cm_id *acpt_idp;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar sol_cma_chan_t *root_chanp;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar root_chanp = (sol_cma_chan_t *)root_idp;
fffafeb2cc01732fd6a28ed530e4424094685eceJohnny Cheung ASSERT(MUTEX_HELD(&root_chanp->chan_mutex));
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar acpt_idp = (struct rdma_cm_id *)avl_find(
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar &root_chanp->chan_acpt_avl_tree, (void *)qp_hdl, NULL);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar return (acpt_idp);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar}
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#ifdef __cplusplus
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar}
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#endif
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#endif /* _SYS_IB_CLIENTS_OF_SOL_OFS_SOL_CMA_H */