📄 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-2005 Silicon Graphics, Inc. All Rights Reserved. *//* * Cross Partition Communication (XPC) structures and macros. */#ifndef _IA64_SN_KERNEL_XPC_H#define _IA64_SN_KERNEL_XPC_H#include <linux/config.h>#include <linux/interrupt.h>#include <linux/sysctl.h>#include <linux/device.h>#include <asm/pgtable.h>#include <asm/processor.h>#include <asm/sn/bte.h>#include <asm/sn/clksupport.h>#include <asm/sn/addrs.h>#include <asm/sn/mspec.h>#include <asm/sn/shub_mmr.h>#include <asm/sn/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) (((_maj) << 4) | ((_min) & 0xf))#define XPC_VERSION_MAJOR(_v) ((_v) >> 4)#define XPC_VERSION_MINOR(_v) ((_v) & 0xf)/* * The next macros define word or bit representations for given * C-brick nasid in either the SAL provided bit array representing * nasids in the partition/machine or the AMO_t array used for * inter-partition initiation communications. * * For SN2 machines, C-Bricks are alway even numbered NASIDs. As * such, some space will be saved by insisting that nasid information * passed from SAL always be packed for C-Bricks and the * cross-partition interrupts use the same packing scheme. */#define XPC_NASID_W_INDEX(_n) (((_n) / 64) / 2)#define XPC_NASID_B_INDEX(_n) (((_n) / 2) & (64 - 1))#define XPC_NASID_IN_ARRAY(_n, _p) ((_p)[XPC_NASID_W_INDEX(_n)] & \ (1UL << XPC_NASID_B_INDEX(_n)))#define XPC_NASID_FROM_W_B(_w, _b) (((_w) * 64 + (_b)) * 2)#define XPC_HB_DEFAULT_INTERVAL 5 /* incr HB every x secs */#define XPC_HB_CHECK_DEFAULT_TIMEOUT 20 /* check HB every x secs *//* define the process name of HB checker and the CPU it is pinned to */#define XPC_HB_CHECK_THREAD_NAME "xpc_hb"#define XPC_HB_CHECK_CPU 0/* define the process name of the discovery thread */#define XPC_DISCOVERY_THREAD_NAME "xpc_discovery"#define XPC_HB_ALLOWED(_p, _v) ((_v)->heartbeating_to_mask & (1UL << (_p)))#define XPC_ALLOW_HB(_p, _v) (_v)->heartbeating_to_mask |= (1UL << (_p))#define XPC_DISALLOW_HB(_p, _v) (_v)->heartbeating_to_mask &= (~(1UL << (_p)))/* * Reserved Page provided by SAL. * * SAL provides one page per partition of reserved memory. When SAL * initialization is complete, SAL_signature, SAL_version, partid, * part_nasids, and mach_nasids are set. * * Note: Until vars_pa is set, the partition XPC code has not been initialized. */struct xpc_rsvd_page { u64 SAL_signature; /* SAL unique signature */ u64 SAL_version; /* SAL specified version */ u8 partid; /* partition ID from SAL */ u8 version; u8 pad[6]; /* pad to u64 align */ volatile u64 vars_pa; u64 part_nasids[XP_NASID_MASK_WORDS] ____cacheline_aligned; u64 mach_nasids[XP_NASID_MASK_WORDS] ____cacheline_aligned;};#define XPC_RP_VERSION _XPC_VERSION(1,0) /* version 1.0 of the reserved page */#define XPC_RSVD_PAGE_ALIGNED_SIZE \ (L1_CACHE_ALIGN(sizeof(struct xpc_rsvd_page)))/* * Define the structures by which XPC variables can be exported to other * partitions. (There are two: struct xpc_vars and struct xpc_vars_part) *//* * The following structure describes the partition generic variables * needed by other partitions in order to properly initialize. * * struct xpc_vars version number also applies to struct xpc_vars_part. * Changes to either structure and/or related functionality should be * reflected by incrementing either the major or minor version numbers * of struct xpc_vars. */struct xpc_vars { u8 version; u64 heartbeat; u64 heartbeating_to_mask; u64 kdb_status; /* 0 = machine running */ int act_nasid; int act_phys_cpuid; u64 vars_part_pa; u64 amos_page_pa; /* paddr of page of AMOs from MSPEC driver */ AMO_t *amos_page; /* vaddr of page of AMOs from MSPEC driver */ AMO_t *act_amos; /* pointer to the first activation AMO */};#define XPC_V_VERSION _XPC_VERSION(3,0) /* version 3.0 of the cross vars */#define XPC_VARS_ALIGNED_SIZE (L1_CACHE_ALIGN(sizeof(struct xpc_vars)))/* * The following structure describes the per partition specific variables. * * An array of these structures, one per partition, will be defined. As a * partition becomes active XPC will copy the array entry corresponding to * itself from that partition. It is desirable that the size of this * structure evenly divide into a cacheline, such that none of the entries * in this array crosses a cacheline boundary. As it is now, each entry * occupies half a cacheline. */struct xpc_vars_part { volatile u64 magic; u64 openclose_args_pa; /* physical address of open and close args */ u64 GPs_pa; /* physical address of Get/Put values */ u64 IPI_amo_pa; /* physical address of IPI AMO_t structure */ int IPI_nasid; /* nasid of where to send IPIs */ int IPI_phys_cpuid; /* physical CPU ID of where to send IPIs */ u8 nchannels; /* #of defined channels supported */ u8 reserved[23]; /* pad to a full 64 bytes */};/* * The vars_part MAGIC numbers play a part in the first contact protocol. * * MAGIC1 indicates that the per partition specific variables for a remote * partition have been initialized by this partition. * * MAGIC2 indicates that this partition has pulled the remote partititions * per partition variables that pertain to this partition. */#define XPC_VP_MAGIC1 0x0053524156435058L /* 'XPCVARS\0'L (little endian) */#define XPC_VP_MAGIC2 0x0073726176435058L /* 'XPCvars\0'L (little endian) *//* * 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) \ ((((u64) _arg1) & 0xffffffff) | \ ((((u64) _arg2) & 0xffffffff) << 32))#define XPC_UNPACK_ARG1(_args) (((u64) _args) & 0xffffffff)#define XPC_UNPACK_ARG2(_args) ((((u64) _args) >> 32) & 0xffffffff)/* * Define a Get/Put value pair (pointers) used with a message queue. */struct xpc_gp { volatile s64 get; /* Get value */ volatile s64 put; /* Put value */};#define XPC_GP_SIZE \ L1_CACHE_ALIGN(sizeof(struct xpc_gp) * XPC_NCHANNELS)/* * Define a structure that contains arguments associated with opening and * closing a channel. */struct xpc_openclose_args { u16 reason; /* reason why channel is closing */ u16 msg_size; /* sizeof each message entry */ u16 remote_nentries; /* #of message entries in remote msg queue */ u16 local_nentries; /* #of message entries in local msg queue */ u64 local_msgqueue_pa; /* physical address of local message queue */};#define XPC_OPENCLOSE_ARGS_SIZE \ L1_CACHE_ALIGN(sizeof(struct xpc_openclose_args) * XPC_NCHANNELS)/* struct xpc_msg flags */#define XPC_M_DONE 0x01 /* msg has been received/consumed */#define XPC_M_READY 0x02 /* msg is ready to be sent */#define XPC_M_INTERRUPT 0x04 /* send interrupt when msg consumed */#define XPC_MSG_ADDRESS(_payload) \ ((struct xpc_msg *)((u8 *)(_payload) - XPC_MSG_PAYLOAD_OFFSET))/* * Defines notify entry. * * This is used to notify a message's sender that their message was received * and consumed by the intended recipient. */struct xpc_notify { struct semaphore sema; /* notify semaphore */ volatile u8 type; /* type of notification */ /* the following two fields are only used if type == XPC_N_CALL */ xpc_notify_func func; /* user's notify function */ void *key; /* pointer to user's key */};/* struct xpc_notify type of notification */#define XPC_N_CALL 0x01 /* notify function provided by user *//* * 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. * * Each of these structures manages two message queues (circular buffers). * They are allocated at the time a channel connection is made. One of * these message queues (local_msgqueue) holds the locally created messages * that are destined for the remote partition. The other of these message * queues (remote_msgqueue) is a locally cached copy of the remote partition's * own local_msgqueue. * * The following is a description of the Get/Put pointers used to manage these * two message queues. Consider the local_msgqueue to be on one partition * and the remote_msgqueue to be its cached copy on another partition. A * description of what each of the lettered areas contains is included. * * * local_msgqueue remote_msgqueue * * |/////////| |/////////| * w_remote_GP.get --> +---------+ |/////////| * | F | |/////////| * remote_GP.get --> +---------+ +---------+ <-- local_GP->get * | | | | * | | | E | * | | | | * | | +---------+ <-- w_local_GP.get * | B | |/////////| * | | |////D////| * | | |/////////| * | | +---------+ <-- w_remote_GP.put * | | |////C////| * local_GP->put --> +---------+ +---------+ <-- remote_GP.put * | | |/////////| * | A | |/////////| * | | |/////////| * w_local_GP.put --> +---------+ |/////////| * |/////////| |/////////| * * * ( remote_GP.[get|put] are cached copies of the remote * partition's local_GP->[get|put], and thus their values can * lag behind their counterparts on the remote partition. ) * * * A - Messages that have been allocated, but have not yet been sent to the * remote partition. * * B - Messages that have been sent, but have not yet been acknowledged by the * remote partition as having been received. * * C - Area that needs to be prepared for the copying of sent messages, by * the clearing of the message flags of any previously received messages. * * D - Area into which sent messages are to be copied from the remote * partition's local_msgqueue and then delivered to their intended * recipients. [ To allow for a multi-message copy, another pointer * (next_msg_to_pull) has been added to keep track of the next message * number needing to be copied (pulled). It chases after w_remote_GP.put. * Any messages lying between w_local_GP.get and next_msg_to_pull have * been copied and are ready to be delivered. ] * * E - Messages that have been copied and delivered, but have not yet been * acknowledged by the recipient as having been received. * * F - Messages that have been acknowledged, but XPC has not yet notified the * sender that the message was received by its intended recipient. * This is also an area that needs to be prepared for the allocating of * new messages, by the clearing of the message flags of the acknowledged * messages. */struct xpc_channel { partid_t partid; /* ID of remote partition connected */ spinlock_t lock; /* lock for updating this structure */ u32 flags; /* general flags */ enum xpc_retval reason; /* reason why channel is disconnect'g */ int reason_line; /* line# disconnect initiated from */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -