tavor_agents.h revision 9517:b4839b0aa7a4
167754Smsmith/*
267754Smsmith * CDDL HEADER START
367754Smsmith *
499679Siwasaki * The contents of this file are subject to the terms of the
567754Smsmith * Common Development and Distribution License (the "License").
667754Smsmith * You may not use this file except in compliance with the License.
767754Smsmith *
867754Smsmith * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
967754Smsmith * or http://www.opensolaris.org/os/licensing.
1067754Smsmith * See the License for the specific language governing permissions
1167754Smsmith * and limitations under the License.
1291116Smsmith *
1370243Smsmith * When distributing Covered Code, include this CDDL HEADER in each
1467754Smsmith * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1567754Smsmith * If applicable, add the following below this CDDL HEADER, with the
1667754Smsmith * fields enclosed by brackets "[]" replaced with your own identifying
1767754Smsmith * information: Portions Copyright [yyyy] [name of copyright owner]
1867754Smsmith *
1967754Smsmith * CDDL HEADER END
2067754Smsmith */
2167754Smsmith
2267754Smsmith/*
2367754Smsmith * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
2467754Smsmith * Use is subject to license terms.
2567754Smsmith */
2667754Smsmith
2767754Smsmith#ifndef	_SYS_IB_ADAPTERS_TAVOR_AGENTS_H
2867754Smsmith#define	_SYS_IB_ADAPTERS_TAVOR_AGENTS_H
2967754Smsmith
3067754Smsmith/*
3167754Smsmith * tavor_agents.h
3267754Smsmith *    Contains all of the prototypes, #defines, and structures necessary
3367754Smsmith *    for all of the Tavor Infiniband Management Agent (SMA, PMA, BMA)
3467754Smsmith *    routines
3567754Smsmith *    Specifically it contains the various flags, structures used for tracking
3667754Smsmith *    the Tavor agents, and prototypes for initialization and teardown
3767754Smsmith *    functions.
3867754Smsmith */
3967754Smsmith
4067754Smsmith#include <sys/types.h>
4167754Smsmith#include <sys/conf.h>
4267754Smsmith#include <sys/ddi.h>
4367754Smsmith#include <sys/sunddi.h>
4467754Smsmith
4567754Smsmith#include <sys/ib/mgt/ibmf/ibmf.h>
4667754Smsmith
4767754Smsmith#ifdef __cplusplus
4867754Smsmithextern "C" {
4967754Smsmith#endif
5067754Smsmith
5167754Smsmith/*
5267754Smsmith * The following defines specify the default number of (SW-assisted) agents
5367754Smsmith * per port.  It is broken down by QP number.  QP0 will have only the one
5467754Smsmith * agent, the SMA.  QP1 should have two agents, the PMA and BMA, but for now
5567754Smsmith * the Tavor firmware doesn't support a BMA.  So we do not register it with
5667754Smsmith * the IBMF.
5767754Smsmith */
5867754Smsmith#define	TAVOR_NUM_QP0_AGENTS_PER_PORT		1
5967754Smsmith#define	TAVOR_NUM_QP1_AGENTS_PER_PORT		1
6067754Smsmith
6167754Smsmith/* Number of threads for the agent handling task queue */
6267754Smsmith#define	TAVOR_TASKQ_NTHREADS			1
6367754Smsmith
6467754Smsmith/* Maximum number of tasks on task queue */
6567754Smsmith#define	TAVOR_TASKQ_MAX_TASKS			4
6667754Smsmith
6767754Smsmith/*
6867754Smsmith * The following defines the name for the task queue.  Note: this string
6967754Smsmith * will later be combined with the Tavor driver instance number to create
7067754Smsmith * a unique name for the task queue
7167754Smsmith */
7267754Smsmith#define	TAVOR_TASKQ_NAME			"tavor_taskq"
7367754Smsmith
7467754Smsmith/*
7567754Smsmith * The following macros are used when handling directed route MADs. They tell
7667754Smsmith * the driver whether a given MAD is a directed route MAD, can extract the
7767754Smsmith * "hop pointer" and "hop count" fields, and can even set the "direction" bit
7867754Smsmith * in the MAD and (if necessary) update the "hop pointer".
7967754Smsmith * More details on how these macros are used can be found in the
8067754Smsmith * tavor_agents.c source file.
8167754Smsmith */
8267754Smsmith#define	TAVOR_MAD_IS_DR(madhdrp)				\
8367754Smsmith	(((sm_dr_mad_hdr_t *)(madhdrp))->MgmtClass == 0x81)
8467754Smsmith#define	TAVOR_DRMAD_GET_HOPCOUNT(madhdrp)			\
8567754Smsmith	(((sm_dr_mad_hdr_t *)(madhdrp))->HopCount)
8667754Smsmith#define	TAVOR_DRMAD_GET_HOPPOINTER(madhdrp)			\
8767754Smsmith	(((sm_dr_mad_hdr_t *)(madhdrp))->HopPointer)
8867754Smsmith#define	TAVOR_DRMAD_SET_HOPPOINTER(madhdrp, hp)			\
8967754Smsmith	(((sm_dr_mad_hdr_t *)(madhdrp))->HopPointer = (hp))
9067754Smsmith#ifdef	_LITTLE_ENDIAN
9167754Smsmith#define	TAVOR_DRMAD_SET_DIRECTION(madhdrp)			\
9267754Smsmith	(((sm_dr_mad_hdr_t *)(madhdrp))->D_Status |= 0x0080)
9367754Smsmith#else
9467754Smsmith#define	TAVOR_DRMAD_SET_DIRECTION(madhdrp)			\
9567754Smsmith	(((sm_dr_mad_hdr_t *)(madhdrp))->D_Status |= 0x8000)
9667754Smsmith#endif
9767754Smsmith
9867754Smsmith/*
9967754Smsmith * The following macro is used to determine whether a received MAD is
10067754Smsmith * one of the special "Tavor Trap" MADs.  If it is, then some special
10167754Smsmith * processing (described in tavor_agents.c) is necessary.
10267754Smsmith */
10367754Smsmith#define	TAVOR_IS_SPECIAL_TRAP_MAD(msgp)				\
10467754Smsmith	((((msgp)->im_msgbufs_recv.im_bufs_mad_hdr->R_Method &	\
10567754Smsmith	MAD_METHOD_MASK) == MAD_METHOD_TRAP) &&			\
10667754Smsmith	((msgp)->im_local_addr.ia_remote_lid == 0))
10767754Smsmith
10867754Smsmith/*
10967754Smsmith * The following macro is used to determine whether a received MAD is
11067754Smsmith * a "TrapRepress" MAD.  If it is, then no response MAD should be sent
11167754Smsmith * (described in tavor_agents.c).
11267754Smsmith */
11367754Smsmith#define	TAVOR_IS_TRAP_REPRESS_MAD(msgp)				\
11467754Smsmith	((((msgp)->im_msgbufs_recv.im_bufs_mad_hdr->R_Method &	\
11567754Smsmith	MAD_METHOD_MASK) == MAD_METHOD_TRAP_REPRESS))
11667754Smsmith
11767754Smsmith/*
11867754Smsmith * The following define specified the offset for the start of "Return Path"
11967754Smsmith * in a directed route MAD.  Note: this is the offset from the start of the
12067754Smsmith * MAD data area (in bytes).
12167754Smsmith */
12267754Smsmith#define	TAVOR_DRMAD_RETURN_PATH_OFFSET		0x80
12380062Smsmith
12467754Smsmith/*
12577424Smsmith * The tavor_agent_list_s structure is used in the Tavor IB Management Agent
12691116Smsmith * routines to keep track of the number (and type) of each register agent.
12767754Smsmith * The primary purpose of tracking this information (port number, management
12867754Smsmith * class, and IBMF handle) is to be able to later deregister all the agents
12967754Smsmith * which are registered at attach() time.  Note: a pointer to this structure
13067754Smsmith * is returned to the driver (by the IBMF) every time the agent callback
13167754Smsmith * routine is called.  This is why the structure contains a backpointer to
13267754Smsmith * the Tavor softstate.
13367754Smsmith */
13467754Smsmithstruct tavor_agent_list_s {
13567754Smsmith	tavor_state_t		*agl_state;
13667754Smsmith	uint_t			agl_port;
13767754Smsmith	ibmf_client_type_t	agl_mgmtclass;
13867754Smsmith	ibmf_handle_t		agl_ibmfhdl;
13967754Smsmith};
14067754Smsmith
14167754Smsmith/*
14267754Smsmith * The tavor_agent_handler_arg_t structure is used in the Tavor IB Management
14367754Smsmith * Agent routines to pass request information through the task queue.  Each
14467754Smsmith * time a request is received (by the Tavor agent request callback), one
14567754Smsmith * of these structures is allocated and filled with the relevant information
14667754Smsmith * for the request.  It is then dispatched to the task queue (with a pointer
14767754Smsmith * to the structure passed as an argument).  From there it is later pulled
14867754Smsmith * apart and the individual fields of the structure used to handle the
14967754Smsmith * request.
15091116Smsmith */
15167754Smsmithtypedef struct tavor_agent_handler_arg_s {
15267754Smsmith	ibmf_handle_t		ahd_ibmfhdl;
15382367Smsmith	ibmf_msg_t		*ahd_ibmfmsg;
15482367Smsmith	tavor_agent_list_t	*ahd_agentlist;
15599146Siwasaki} tavor_agent_handler_arg_t;
15667754Smsmith
15799146Siwasakiint tavor_agent_handlers_init(tavor_state_t *state);
15867754Smsmithint tavor_agent_handlers_fini(tavor_state_t *state);
15999146Siwasaki
16067754Smsmith#ifdef __cplusplus
16167754Smsmith}
16267754Smsmith#endif
16367754Smsmith
16467754Smsmith#endif	/* _SYS_IB_ADAPTERS_TAVOR_AGENTS_H */
16567754Smsmith