linux/drivers/misc/sgi-xp/xpc.h

/*
 * This file is subject to the terms and conditions of the GNU General Public
 * License.  See the file "COPYING" in the main directory of this archive
 * for more details.
 *
 * Copyright (c) 2004-2009 Silicon Graphics, Inc.  All Rights Reserved.
 */

/*
 * Cross Partition Communication (XPC) structures and macros.
 */

#ifndef _DRIVERS_MISC_SGIXP_XPC_H
#define _DRIVERS_MISC_SGIXP_XPC_H

#include <linux/wait.h>
#include <linux/completion.h>
#include <linux/timer.h>
#include <linux/sched.h>
#include "xp.h"

/*
 * XPC Version numbers consist of a major and minor number. XPC can always
 * talk to versions with same major #, and never talk to versions with a
 * different major #.
 */
#define _XPC_VERSION(_maj, _min)
#define XPC_VERSION_MAJOR(_v)
#define XPC_VERSION_MINOR(_v)

/* define frequency of the heartbeat and frequency how often it's checked */
#define XPC_HB_DEFAULT_INTERVAL
#define XPC_HB_CHECK_DEFAULT_INTERVAL

/* define the process name of HB checker and the CPU it is pinned to */
#define XPC_HB_CHECK_THREAD_NAME
#define XPC_HB_CHECK_CPU

/* define the process name of the discovery thread */
#define XPC_DISCOVERY_THREAD_NAME

/*
 * the reserved page
 *
 *   SAL reserves one page of memory per partition for XPC. Though a full page
 *   in length (16384 bytes), its starting address is not page aligned, but it
 *   is cacheline aligned. The reserved page consists of the following:
 *
 *   reserved page header
 *
 *     The first two 64-byte cachelines of the reserved page contain the
 *     header (struct xpc_rsvd_page). Before SAL initialization has completed,
 *     SAL has set up the following fields of the reserved page header:
 *     SAL_signature, SAL_version, SAL_partid, and SAL_nasids_size. The
 *     other fields are set up by XPC. (xpc_rsvd_page points to the local
 *     partition's reserved page.)
 *
 *   part_nasids mask
 *   mach_nasids mask
 *
 *     SAL also sets up two bitmaps (or masks), one that reflects the actual
 *     nasids in this partition (part_nasids), and the other that reflects
 *     the actual nasids in the entire machine (mach_nasids). We're only
 *     interested in the even numbered nasids (which contain the processors
 *     and/or memory), so we only need half as many bits to represent the
 *     nasids. When mapping nasid to bit in a mask (or bit to nasid) be sure
 *     to either divide or multiply by 2. The part_nasids mask is located
 *     starting at the first cacheline following the reserved page header. The
 *     mach_nasids mask follows right after the part_nasids mask. The size in
 *     bytes of each mask is reflected by the reserved page header field
 *     'SAL_nasids_size'. (Local partition's mask pointers are xpc_part_nasids
 *     and xpc_mach_nasids.)
 *
 *     Immediately following the mach_nasids mask are the XPC variables
 *     required by other partitions. First are those that are generic to all
 *     partitions (vars), followed on the next available cacheline by those
 *     which are partition specific (vars part). These are setup by XPC.
 *
 * Note: Until 'ts_jiffies' is set non-zero, the partition XPC code has not been
 *       initialized.
 */
struct xpc_rsvd_page {};

#define XPC_RP_VERSION

/* the reserved page sizes and offsets */

#define XPC_RP_HEADER_SIZE

#define XPC_RP_PART_NASIDS(_rp)
#define XPC_RP_MACH_NASIDS(_rp)


/*
 * The following structure describes the partition's heartbeat info which
 * will be periodically read by other partitions to determine whether this
 * XPC is still 'alive'.
 */
struct xpc_heartbeat_uv {};

/*
 * Info pertinent to a GRU message queue using a watch list for irq generation.
 */
struct xpc_gru_mq_uv {};

/*
 * The activate_mq is used to send/receive GRU messages that affect XPC's
 * partition active state and channel state. This is uv only.
 */
struct xpc_activate_mq_msghdr_uv {};

/* activate_mq defined message types */
#define XPC_ACTIVATE_MQ_MSG_SYNC_ACT_STATE_UV

#define XPC_ACTIVATE_MQ_MSG_ACTIVATE_REQ_UV
#define XPC_ACTIVATE_MQ_MSG_DEACTIVATE_REQ_UV

#define XPC_ACTIVATE_MQ_MSG_CHCTL_CLOSEREQUEST_UV
#define XPC_ACTIVATE_MQ_MSG_CHCTL_CLOSEREPLY_UV
#define XPC_ACTIVATE_MQ_MSG_CHCTL_OPENREQUEST_UV
#define XPC_ACTIVATE_MQ_MSG_CHCTL_OPENREPLY_UV
#define XPC_ACTIVATE_MQ_MSG_CHCTL_OPENCOMPLETE_UV

#define XPC_ACTIVATE_MQ_MSG_MARK_ENGAGED_UV
#define XPC_ACTIVATE_MQ_MSG_MARK_DISENGAGED_UV

struct xpc_activate_mq_msg_uv {};

struct xpc_activate_mq_msg_activate_req_uv {};

struct xpc_activate_mq_msg_deactivate_req_uv {};

struct xpc_activate_mq_msg_chctl_closerequest_uv {};

struct xpc_activate_mq_msg_chctl_closereply_uv {};

struct xpc_activate_mq_msg_chctl_openrequest_uv {};

struct xpc_activate_mq_msg_chctl_openreply_uv {};

struct xpc_activate_mq_msg_chctl_opencomplete_uv {};

/*
 * Functions registered by add_timer() or called by kernel_thread() only
 * allow for a single 64-bit argument. The following macros can be used to
 * pack and unpack two (32-bit, 16-bit or 8-bit) arguments into or out from
 * the passed argument.
 */
#define XPC_PACK_ARGS(_arg1, _arg2)

#define XPC_UNPACK_ARG1(_args)
#define XPC_UNPACK_ARG2(_args)

/*
 * Define a structure that contains arguments associated with opening and
 * closing a channel.
 */
struct xpc_openclose_args {};

#define XPC_OPENCLOSE_ARGS_SIZE


/*
 * Structures to define a fifo singly-linked list.
 */

struct xpc_fifo_entry_uv {};

struct xpc_fifo_head_uv {};

/*
 * The format of a uv XPC notify_mq GRU message is as follows:
 *
 * A user-defined message resides in the payload area. The max size of the
 * payload is defined by the user via xpc_connect().
 *
 * The size of a message (payload and header) sent via the GRU must be either 1
 * or 2 GRU_CACHE_LINE_BYTES in length.
 */

struct xpc_notify_mq_msghdr_uv {};

struct xpc_notify_mq_msg_uv {};

/* struct xpc_notify_sn2 type of notification */

#define XPC_N_CALL

/*
 * Define uv's version of the notify entry. It additionally is used to allocate
 * a msg slot on the remote partition into which is copied a sent message.
 */
struct xpc_send_msg_slot_uv {};

/*
 * Define the structure that manages all the stuff required by a channel. In
 * particular, they are used to manage the messages sent across the channel.
 *
 * This structure is private to a partition, and is NOT shared across the
 * partition boundary.
 *
 * There is an array of these structures for each remote partition. It is
 * allocated at the time a partition becomes active. The array contains one
 * of these structures for each potential channel connection to that partition.
 */

struct xpc_channel_uv {};

struct xpc_channel {} ____cacheline_aligned;

/* struct xpc_channel flags */

#define XPC_C_WASCONNECTED

#define XPC_C_ROPENCOMPLETE
#define XPC_C_OPENCOMPLETE
#define XPC_C_ROPENREPLY
#define XPC_C_OPENREPLY
#define XPC_C_ROPENREQUEST
#define XPC_C_OPENREQUEST

#define XPC_C_SETUP
#define XPC_C_CONNECTEDCALLOUT
#define XPC_C_CONNECTEDCALLOUT_MADE
#define XPC_C_CONNECTED
#define XPC_C_CONNECTING

#define XPC_C_RCLOSEREPLY
#define XPC_C_CLOSEREPLY
#define XPC_C_RCLOSEREQUEST
#define XPC_C_CLOSEREQUEST

#define XPC_C_DISCONNECTED
#define XPC_C_DISCONNECTING
#define XPC_C_DISCONNECTINGCALLOUT
#define XPC_C_DISCONNECTINGCALLOUT_MADE
#define XPC_C_WDISCONNECT

/*
 * The channel control flags (chctl) union consists of a 64-bit variable which
 * is divided up into eight bytes, ordered from right to left. Byte zero
 * pertains to channel 0, byte one to channel 1, and so on. Each channel's byte
 * can have one or more of the chctl flags set in it.
 */

xpc_channel_ctl_flags;

/* chctl flags */
#define XPC_CHCTL_CLOSEREQUEST
#define XPC_CHCTL_CLOSEREPLY
#define XPC_CHCTL_OPENREQUEST
#define XPC_CHCTL_OPENREPLY
#define XPC_CHCTL_OPENCOMPLETE
#define XPC_CHCTL_MSGREQUEST

#define XPC_OPENCLOSE_CHCTL_FLAGS
#define XPC_MSG_CHCTL_FLAGS

static inline int
xpc_any_openclose_chctl_flags_set(union xpc_channel_ctl_flags *chctl)
{}

static inline int
xpc_any_msg_chctl_flags_set(union xpc_channel_ctl_flags *chctl)
{}

struct xpc_partition_uv {};

/* struct xpc_partition_uv flags */

#define XPC_P_CACHED_ACTIVATE_GRU_MQ_DESC_UV
#define XPC_P_ENGAGED_UV

/* struct xpc_partition_uv act_state change requests */

#define XPC_P_ASR_ACTIVATE_UV
#define XPC_P_ASR_REACTIVATE_UV
#define XPC_P_ASR_DEACTIVATE_UV

struct xpc_partition {} ____cacheline_aligned;

struct xpc_arch_operations {};

/* struct xpc_partition act_state values (for XPC HB) */

#define XPC_P_AS_INACTIVE
#define XPC_P_AS_ACTIVATION_REQ
#define XPC_P_AS_ACTIVATING
#define XPC_P_AS_ACTIVE
#define XPC_P_AS_DEACTIVATING

#define XPC_DEACTIVATE_PARTITION(_p, _reason)

/* struct xpc_partition setup_state values */

#define XPC_P_SS_UNSET
#define XPC_P_SS_SETUP
#define XPC_P_SS_WTEARDOWN
#define XPC_P_SS_TORNDOWN

/* number of seconds to wait for other partitions to disengage */
#define XPC_DISENGAGE_DEFAULT_TIMELIMIT

/* interval in seconds to print 'waiting deactivation' messages */
#define XPC_DEACTIVATE_PRINTMSG_INTERVAL

#define XPC_PARTID(_p)

/* found in xp_main.c */
extern struct xpc_registration xpc_registrations[];

/* found in xpc_main.c */
extern struct device *xpc_part;
extern struct device *xpc_chan;
extern struct xpc_arch_operations xpc_arch_ops;
extern int xpc_disengage_timelimit;
extern int xpc_disengage_timedout;
extern int xpc_activate_IRQ_rcvd;
extern spinlock_t xpc_activate_IRQ_rcvd_lock;
extern wait_queue_head_t xpc_activate_IRQ_wq;
extern void *xpc_kzalloc_cacheline_aligned(size_t, gfp_t, void **);
extern void xpc_activate_partition(struct xpc_partition *);
extern void xpc_activate_kthreads(struct xpc_channel *, int);
extern void xpc_create_kthreads(struct xpc_channel *, int, int);
extern void xpc_disconnect_wait(int);

/* found in xpc_uv.c */
extern int xpc_init_uv(void);
extern void xpc_exit_uv(void);

/* found in xpc_partition.c */
extern int xpc_exiting;
extern int xpc_nasid_mask_nlongs;
extern struct xpc_rsvd_page *xpc_rsvd_page;
extern unsigned long *xpc_mach_nasids;
extern struct xpc_partition *xpc_partitions;
extern void *xpc_kmalloc_cacheline_aligned(size_t, gfp_t, void **);
extern int xpc_setup_rsvd_page(void);
extern void xpc_teardown_rsvd_page(void);
extern int xpc_identify_activate_IRQ_sender(void);
extern int xpc_partition_disengaged(struct xpc_partition *);
extern int xpc_partition_disengaged_from_timer(struct xpc_partition *part);
extern enum xp_retval xpc_mark_partition_active(struct xpc_partition *);
extern void xpc_mark_partition_inactive(struct xpc_partition *);
extern void xpc_discovery(void);
extern enum xp_retval xpc_get_remote_rp(int, unsigned long *,
					struct xpc_rsvd_page *,
					unsigned long *);
extern void xpc_deactivate_partition(const int, struct xpc_partition *,
				     enum xp_retval);
extern enum xp_retval xpc_initiate_partid_to_nasids(short, void *);

/* found in xpc_channel.c */
extern void xpc_initiate_connect(int);
extern void xpc_initiate_disconnect(int);
extern enum xp_retval xpc_allocate_msg_wait(struct xpc_channel *);
extern enum xp_retval xpc_initiate_send(short, int, u32, void *, u16);
extern enum xp_retval xpc_initiate_send_notify(short, int, u32, void *, u16,
					       xpc_notify_func, void *);
extern void xpc_initiate_received(short, int, void *);
extern void xpc_process_sent_chctl_flags(struct xpc_partition *);
extern void xpc_connected_callout(struct xpc_channel *);
extern void xpc_deliver_payload(struct xpc_channel *);
extern void xpc_disconnect_channel(const int, struct xpc_channel *,
				   enum xp_retval, unsigned long *);
extern void xpc_disconnect_callout(struct xpc_channel *, enum xp_retval);
extern void xpc_partition_going_down(struct xpc_partition *, enum xp_retval);

static inline void
xpc_wakeup_channel_mgr(struct xpc_partition *part)
{}

/*
 * These next two inlines are used to keep us from tearing down a channel's
 * msg queues while a thread may be referencing them.
 */
static inline void
xpc_msgqueue_ref(struct xpc_channel *ch)
{}

static inline void
xpc_msgqueue_deref(struct xpc_channel *ch)
{}

#define XPC_DISCONNECT_CHANNEL(_ch, _reason, _irqflgs)

/*
 * These two inlines are used to keep us from tearing down a partition's
 * setup infrastructure while a thread may be referencing it.
 */
static inline void
xpc_part_deref(struct xpc_partition *part)
{}

static inline int
xpc_part_ref(struct xpc_partition *part)
{}

/*
 * The following macro is to be used for the setting of the reason and
 * reason_line fields in both the struct xpc_channel and struct xpc_partition
 * structures.
 */
#define XPC_SET_REASON(_p, _reason, _line)

#endif /* _DRIVERS_MISC_SGIXP_XPC_H */