18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public
38c2ecf20Sopenharmony_ci * License.  See the file "COPYING" in the main directory of this archive
48c2ecf20Sopenharmony_ci * for more details.
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * (C) Copyright 2020 Hewlett Packard Enterprise Development LP
78c2ecf20Sopenharmony_ci * Copyright (C) 2004-2008 Silicon Graphics, Inc. All rights reserved.
88c2ecf20Sopenharmony_ci */
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci/*
118c2ecf20Sopenharmony_ci * External Cross Partition (XP) structures and defines.
128c2ecf20Sopenharmony_ci */
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#ifndef _DRIVERS_MISC_SGIXP_XP_H
158c2ecf20Sopenharmony_ci#define _DRIVERS_MISC_SGIXP_XP_H
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#include <linux/mutex.h>
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#if defined CONFIG_X86_UV || defined CONFIG_IA64_SGI_UV
208c2ecf20Sopenharmony_ci#include <asm/uv/uv.h>
218c2ecf20Sopenharmony_ci#endif
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci#ifdef USE_DBUG_ON
248c2ecf20Sopenharmony_ci#define DBUG_ON(condition)	BUG_ON(condition)
258c2ecf20Sopenharmony_ci#else
268c2ecf20Sopenharmony_ci#define DBUG_ON(condition)
278c2ecf20Sopenharmony_ci#endif
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci/*
308c2ecf20Sopenharmony_ci * Define the maximum number of partitions the system can possibly support.
318c2ecf20Sopenharmony_ci * It is based on the maximum number of hardware partitionable regions. The
328c2ecf20Sopenharmony_ci * term 'region' in this context refers to the minimum number of nodes that
338c2ecf20Sopenharmony_ci * can comprise an access protection grouping. The access protection is in
348c2ecf20Sopenharmony_ci * regards to memory, IPI and IOI.
358c2ecf20Sopenharmony_ci *
368c2ecf20Sopenharmony_ci * The maximum number of hardware partitionable regions is equal to the
378c2ecf20Sopenharmony_ci * maximum number of nodes in the entire system divided by the minimum number
388c2ecf20Sopenharmony_ci * of nodes that comprise an access protection grouping.
398c2ecf20Sopenharmony_ci */
408c2ecf20Sopenharmony_ci#define XP_MAX_NPARTITIONS_SN2	64
418c2ecf20Sopenharmony_ci#define XP_MAX_NPARTITIONS_UV	256
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci/*
448c2ecf20Sopenharmony_ci * XPC establishes channel connections between the local partition and any
458c2ecf20Sopenharmony_ci * other partition that is currently up. Over these channels, kernel-level
468c2ecf20Sopenharmony_ci * `users' can communicate with their counterparts on the other partitions.
478c2ecf20Sopenharmony_ci *
488c2ecf20Sopenharmony_ci * If the need for additional channels arises, one can simply increase
498c2ecf20Sopenharmony_ci * XPC_MAX_NCHANNELS accordingly. If the day should come where that number
508c2ecf20Sopenharmony_ci * exceeds the absolute MAXIMUM number of channels possible (eight), then one
518c2ecf20Sopenharmony_ci * will need to make changes to the XPC code to accommodate for this.
528c2ecf20Sopenharmony_ci *
538c2ecf20Sopenharmony_ci * The absolute maximum number of channels possible is limited to eight for
548c2ecf20Sopenharmony_ci * performance reasons on sn2 hardware. The internal cross partition structures
558c2ecf20Sopenharmony_ci * require sixteen bytes per channel, and eight allows all of this
568c2ecf20Sopenharmony_ci * interface-shared info to fit in one 128-byte cacheline.
578c2ecf20Sopenharmony_ci */
588c2ecf20Sopenharmony_ci#define XPC_MEM_CHANNEL		0	/* memory channel number */
598c2ecf20Sopenharmony_ci#define	XPC_NET_CHANNEL		1	/* network channel number */
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci#define XPC_MAX_NCHANNELS	2	/* max #of channels allowed */
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci#if XPC_MAX_NCHANNELS > 8
648c2ecf20Sopenharmony_ci#error	XPC_MAX_NCHANNELS exceeds absolute MAXIMUM possible.
658c2ecf20Sopenharmony_ci#endif
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ci/*
688c2ecf20Sopenharmony_ci * Define macro, XPC_MSG_SIZE(), is provided for the user
698c2ecf20Sopenharmony_ci * that wants to fit as many msg entries as possible in a given memory size
708c2ecf20Sopenharmony_ci * (e.g. a memory page).
718c2ecf20Sopenharmony_ci */
728c2ecf20Sopenharmony_ci#define XPC_MSG_MAX_SIZE	128
738c2ecf20Sopenharmony_ci#define XPC_MSG_HDR_MAX_SIZE	16
748c2ecf20Sopenharmony_ci#define XPC_MSG_PAYLOAD_MAX_SIZE (XPC_MSG_MAX_SIZE - XPC_MSG_HDR_MAX_SIZE)
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci#define XPC_MSG_SIZE(_payload_size) \
778c2ecf20Sopenharmony_ci				ALIGN(XPC_MSG_HDR_MAX_SIZE + (_payload_size), \
788c2ecf20Sopenharmony_ci				      is_uv_system() ? 64 : 128)
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ci/*
828c2ecf20Sopenharmony_ci * Define the return values and values passed to user's callout functions.
838c2ecf20Sopenharmony_ci * (It is important to add new value codes at the end just preceding
848c2ecf20Sopenharmony_ci * xpUnknownReason, which must have the highest numerical value.)
858c2ecf20Sopenharmony_ci */
868c2ecf20Sopenharmony_cienum xp_retval {
878c2ecf20Sopenharmony_ci	xpSuccess = 0,
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci	xpNotConnected,		/*  1: channel is not connected */
908c2ecf20Sopenharmony_ci	xpConnected,		/*  2: channel connected (opened) */
918c2ecf20Sopenharmony_ci	xpRETIRED1,		/*  3: (formerly xpDisconnected) */
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci	xpMsgReceived,		/*  4: message received */
948c2ecf20Sopenharmony_ci	xpMsgDelivered,		/*  5: message delivered and acknowledged */
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ci	xpRETIRED2,		/*  6: (formerly xpTransferFailed) */
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci	xpNoWait,		/*  7: operation would require wait */
998c2ecf20Sopenharmony_ci	xpRetry,		/*  8: retry operation */
1008c2ecf20Sopenharmony_ci	xpTimeout,		/*  9: timeout in xpc_allocate_msg_wait() */
1018c2ecf20Sopenharmony_ci	xpInterrupted,		/* 10: interrupted wait */
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_ci	xpUnequalMsgSizes,	/* 11: message size disparity between sides */
1048c2ecf20Sopenharmony_ci	xpInvalidAddress,	/* 12: invalid address */
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_ci	xpNoMemory,		/* 13: no memory available for XPC structures */
1078c2ecf20Sopenharmony_ci	xpLackOfResources,	/* 14: insufficient resources for operation */
1088c2ecf20Sopenharmony_ci	xpUnregistered,		/* 15: channel is not registered */
1098c2ecf20Sopenharmony_ci	xpAlreadyRegistered,	/* 16: channel is already registered */
1108c2ecf20Sopenharmony_ci
1118c2ecf20Sopenharmony_ci	xpPartitionDown,	/* 17: remote partition is down */
1128c2ecf20Sopenharmony_ci	xpNotLoaded,		/* 18: XPC module is not loaded */
1138c2ecf20Sopenharmony_ci	xpUnloading,		/* 19: this side is unloading XPC module */
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ci	xpBadMagic,		/* 20: XPC MAGIC string not found */
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_ci	xpReactivating,		/* 21: remote partition was reactivated */
1188c2ecf20Sopenharmony_ci
1198c2ecf20Sopenharmony_ci	xpUnregistering,	/* 22: this side is unregistering channel */
1208c2ecf20Sopenharmony_ci	xpOtherUnregistering,	/* 23: other side is unregistering channel */
1218c2ecf20Sopenharmony_ci
1228c2ecf20Sopenharmony_ci	xpCloneKThread,		/* 24: cloning kernel thread */
1238c2ecf20Sopenharmony_ci	xpCloneKThreadFailed,	/* 25: cloning kernel thread failed */
1248c2ecf20Sopenharmony_ci
1258c2ecf20Sopenharmony_ci	xpNoHeartbeat,		/* 26: remote partition has no heartbeat */
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci	xpPioReadError,		/* 27: PIO read error */
1288c2ecf20Sopenharmony_ci	xpPhysAddrRegFailed,	/* 28: registration of phys addr range failed */
1298c2ecf20Sopenharmony_ci
1308c2ecf20Sopenharmony_ci	xpRETIRED3,		/* 29: (formerly xpBteDirectoryError) */
1318c2ecf20Sopenharmony_ci	xpRETIRED4,		/* 30: (formerly xpBtePoisonError) */
1328c2ecf20Sopenharmony_ci	xpRETIRED5,		/* 31: (formerly xpBteWriteError) */
1338c2ecf20Sopenharmony_ci	xpRETIRED6,		/* 32: (formerly xpBteAccessError) */
1348c2ecf20Sopenharmony_ci	xpRETIRED7,		/* 33: (formerly xpBtePWriteError) */
1358c2ecf20Sopenharmony_ci	xpRETIRED8,		/* 34: (formerly xpBtePReadError) */
1368c2ecf20Sopenharmony_ci	xpRETIRED9,		/* 35: (formerly xpBteTimeOutError) */
1378c2ecf20Sopenharmony_ci	xpRETIRED10,		/* 36: (formerly xpBteXtalkError) */
1388c2ecf20Sopenharmony_ci	xpRETIRED11,		/* 37: (formerly xpBteNotAvailable) */
1398c2ecf20Sopenharmony_ci	xpRETIRED12,		/* 38: (formerly xpBteUnmappedError) */
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_ci	xpBadVersion,		/* 39: bad version number */
1428c2ecf20Sopenharmony_ci	xpVarsNotSet,		/* 40: the XPC variables are not set up */
1438c2ecf20Sopenharmony_ci	xpNoRsvdPageAddr,	/* 41: unable to get rsvd page's phys addr */
1448c2ecf20Sopenharmony_ci	xpInvalidPartid,	/* 42: invalid partition ID */
1458c2ecf20Sopenharmony_ci	xpLocalPartid,		/* 43: local partition ID */
1468c2ecf20Sopenharmony_ci
1478c2ecf20Sopenharmony_ci	xpOtherGoingDown,	/* 44: other side going down, reason unknown */
1488c2ecf20Sopenharmony_ci	xpSystemGoingDown,	/* 45: system is going down, reason unknown */
1498c2ecf20Sopenharmony_ci	xpSystemHalt,		/* 46: system is being halted */
1508c2ecf20Sopenharmony_ci	xpSystemReboot,		/* 47: system is being rebooted */
1518c2ecf20Sopenharmony_ci	xpSystemPoweroff,	/* 48: system is being powered off */
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_ci	xpDisconnecting,	/* 49: channel disconnecting (closing) */
1548c2ecf20Sopenharmony_ci
1558c2ecf20Sopenharmony_ci	xpOpenCloseError,	/* 50: channel open/close protocol error */
1568c2ecf20Sopenharmony_ci
1578c2ecf20Sopenharmony_ci	xpDisconnected,		/* 51: channel disconnected (closed) */
1588c2ecf20Sopenharmony_ci
1598c2ecf20Sopenharmony_ci	xpBteCopyError,		/* 52: bte_copy() returned error */
1608c2ecf20Sopenharmony_ci	xpSalError,		/* 53: sn SAL error */
1618c2ecf20Sopenharmony_ci	xpRsvdPageNotSet,	/* 54: the reserved page is not set up */
1628c2ecf20Sopenharmony_ci	xpPayloadTooBig,	/* 55: payload too large for message slot */
1638c2ecf20Sopenharmony_ci
1648c2ecf20Sopenharmony_ci	xpUnsupported,		/* 56: unsupported functionality or resource */
1658c2ecf20Sopenharmony_ci	xpNeedMoreInfo,		/* 57: more info is needed by SAL */
1668c2ecf20Sopenharmony_ci
1678c2ecf20Sopenharmony_ci	xpGruCopyError,		/* 58: gru_copy_gru() returned error */
1688c2ecf20Sopenharmony_ci	xpGruSendMqError,	/* 59: gru send message queue related error */
1698c2ecf20Sopenharmony_ci
1708c2ecf20Sopenharmony_ci	xpBadChannelNumber,	/* 60: invalid channel number */
1718c2ecf20Sopenharmony_ci	xpBadMsgType,		/* 61: invalid message type */
1728c2ecf20Sopenharmony_ci	xpBiosError,		/* 62: BIOS error */
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_ci	xpUnknownReason		/* 63: unknown reason - must be last in enum */
1758c2ecf20Sopenharmony_ci};
1768c2ecf20Sopenharmony_ci
1778c2ecf20Sopenharmony_ci/*
1788c2ecf20Sopenharmony_ci * Define the callout function type used by XPC to update the user on
1798c2ecf20Sopenharmony_ci * connection activity and state changes via the user function registered
1808c2ecf20Sopenharmony_ci * by xpc_connect().
1818c2ecf20Sopenharmony_ci *
1828c2ecf20Sopenharmony_ci * Arguments:
1838c2ecf20Sopenharmony_ci *
1848c2ecf20Sopenharmony_ci *	reason - reason code.
1858c2ecf20Sopenharmony_ci *	partid - partition ID associated with condition.
1868c2ecf20Sopenharmony_ci *	ch_number - channel # associated with condition.
1878c2ecf20Sopenharmony_ci *	data - pointer to optional data.
1888c2ecf20Sopenharmony_ci *	key - pointer to optional user-defined value provided as the "key"
1898c2ecf20Sopenharmony_ci *	      argument to xpc_connect().
1908c2ecf20Sopenharmony_ci *
1918c2ecf20Sopenharmony_ci * A reason code of xpConnected indicates that a connection has been
1928c2ecf20Sopenharmony_ci * established to the specified partition on the specified channel. The data
1938c2ecf20Sopenharmony_ci * argument indicates the max number of entries allowed in the message queue.
1948c2ecf20Sopenharmony_ci *
1958c2ecf20Sopenharmony_ci * A reason code of xpMsgReceived indicates that a XPC message arrived from
1968c2ecf20Sopenharmony_ci * the specified partition on the specified channel. The data argument
1978c2ecf20Sopenharmony_ci * specifies the address of the message's payload. The user must call
1988c2ecf20Sopenharmony_ci * xpc_received() when finished with the payload.
1998c2ecf20Sopenharmony_ci *
2008c2ecf20Sopenharmony_ci * All other reason codes indicate failure. The data argmument is NULL.
2018c2ecf20Sopenharmony_ci * When a failure reason code is received, one can assume that the channel
2028c2ecf20Sopenharmony_ci * is not connected.
2038c2ecf20Sopenharmony_ci */
2048c2ecf20Sopenharmony_citypedef void (*xpc_channel_func) (enum xp_retval reason, short partid,
2058c2ecf20Sopenharmony_ci				  int ch_number, void *data, void *key);
2068c2ecf20Sopenharmony_ci
2078c2ecf20Sopenharmony_ci/*
2088c2ecf20Sopenharmony_ci * Define the callout function type used by XPC to notify the user of
2098c2ecf20Sopenharmony_ci * messages received and delivered via the user function registered by
2108c2ecf20Sopenharmony_ci * xpc_send_notify().
2118c2ecf20Sopenharmony_ci *
2128c2ecf20Sopenharmony_ci * Arguments:
2138c2ecf20Sopenharmony_ci *
2148c2ecf20Sopenharmony_ci *	reason - reason code.
2158c2ecf20Sopenharmony_ci *	partid - partition ID associated with condition.
2168c2ecf20Sopenharmony_ci *	ch_number - channel # associated with condition.
2178c2ecf20Sopenharmony_ci *	key - pointer to optional user-defined value provided as the "key"
2188c2ecf20Sopenharmony_ci *	      argument to xpc_send_notify().
2198c2ecf20Sopenharmony_ci *
2208c2ecf20Sopenharmony_ci * A reason code of xpMsgDelivered indicates that the message was delivered
2218c2ecf20Sopenharmony_ci * to the intended recipient and that they have acknowledged its receipt by
2228c2ecf20Sopenharmony_ci * calling xpc_received().
2238c2ecf20Sopenharmony_ci *
2248c2ecf20Sopenharmony_ci * All other reason codes indicate failure.
2258c2ecf20Sopenharmony_ci *
2268c2ecf20Sopenharmony_ci * NOTE: The user defined function must be callable by an interrupt handler
2278c2ecf20Sopenharmony_ci *       and thus cannot block.
2288c2ecf20Sopenharmony_ci */
2298c2ecf20Sopenharmony_citypedef void (*xpc_notify_func) (enum xp_retval reason, short partid,
2308c2ecf20Sopenharmony_ci				 int ch_number, void *key);
2318c2ecf20Sopenharmony_ci
2328c2ecf20Sopenharmony_ci/*
2338c2ecf20Sopenharmony_ci * The following is a registration entry. There is a global array of these,
2348c2ecf20Sopenharmony_ci * one per channel. It is used to record the connection registration made
2358c2ecf20Sopenharmony_ci * by the users of XPC. As long as a registration entry exists, for any
2368c2ecf20Sopenharmony_ci * partition that comes up, XPC will attempt to establish a connection on
2378c2ecf20Sopenharmony_ci * that channel. Notification that a connection has been made will occur via
2388c2ecf20Sopenharmony_ci * the xpc_channel_func function.
2398c2ecf20Sopenharmony_ci *
2408c2ecf20Sopenharmony_ci * The 'func' field points to the function to call when aynchronous
2418c2ecf20Sopenharmony_ci * notification is required for such events as: a connection established/lost,
2428c2ecf20Sopenharmony_ci * or an incoming message received, or an error condition encountered. A
2438c2ecf20Sopenharmony_ci * non-NULL 'func' field indicates that there is an active registration for
2448c2ecf20Sopenharmony_ci * the channel.
2458c2ecf20Sopenharmony_ci */
2468c2ecf20Sopenharmony_cistruct xpc_registration {
2478c2ecf20Sopenharmony_ci	struct mutex mutex;
2488c2ecf20Sopenharmony_ci	xpc_channel_func func;	/* function to call */
2498c2ecf20Sopenharmony_ci	void *key;		/* pointer to user's key */
2508c2ecf20Sopenharmony_ci	u16 nentries;		/* #of msg entries in local msg queue */
2518c2ecf20Sopenharmony_ci	u16 entry_size;		/* message queue's message entry size */
2528c2ecf20Sopenharmony_ci	u32 assigned_limit;	/* limit on #of assigned kthreads */
2538c2ecf20Sopenharmony_ci	u32 idle_limit;		/* limit on #of idle kthreads */
2548c2ecf20Sopenharmony_ci} ____cacheline_aligned;
2558c2ecf20Sopenharmony_ci
2568c2ecf20Sopenharmony_ci#define XPC_CHANNEL_REGISTERED(_c)	(xpc_registrations[_c].func != NULL)
2578c2ecf20Sopenharmony_ci
2588c2ecf20Sopenharmony_ci/* the following are valid xpc_send() or xpc_send_notify() flags */
2598c2ecf20Sopenharmony_ci#define XPC_WAIT	0	/* wait flag */
2608c2ecf20Sopenharmony_ci#define XPC_NOWAIT	1	/* no wait flag */
2618c2ecf20Sopenharmony_ci
2628c2ecf20Sopenharmony_cistruct xpc_interface {
2638c2ecf20Sopenharmony_ci	void (*connect) (int);
2648c2ecf20Sopenharmony_ci	void (*disconnect) (int);
2658c2ecf20Sopenharmony_ci	enum xp_retval (*send) (short, int, u32, void *, u16);
2668c2ecf20Sopenharmony_ci	enum xp_retval (*send_notify) (short, int, u32, void *, u16,
2678c2ecf20Sopenharmony_ci					xpc_notify_func, void *);
2688c2ecf20Sopenharmony_ci	void (*received) (short, int, void *);
2698c2ecf20Sopenharmony_ci	enum xp_retval (*partid_to_nasids) (short, void *);
2708c2ecf20Sopenharmony_ci};
2718c2ecf20Sopenharmony_ci
2728c2ecf20Sopenharmony_ciextern struct xpc_interface xpc_interface;
2738c2ecf20Sopenharmony_ci
2748c2ecf20Sopenharmony_ciextern void xpc_set_interface(void (*)(int),
2758c2ecf20Sopenharmony_ci			      void (*)(int),
2768c2ecf20Sopenharmony_ci			      enum xp_retval (*)(short, int, u32, void *, u16),
2778c2ecf20Sopenharmony_ci			      enum xp_retval (*)(short, int, u32, void *, u16,
2788c2ecf20Sopenharmony_ci						 xpc_notify_func, void *),
2798c2ecf20Sopenharmony_ci			      void (*)(short, int, void *),
2808c2ecf20Sopenharmony_ci			      enum xp_retval (*)(short, void *));
2818c2ecf20Sopenharmony_ciextern void xpc_clear_interface(void);
2828c2ecf20Sopenharmony_ci
2838c2ecf20Sopenharmony_ciextern enum xp_retval xpc_connect(int, xpc_channel_func, void *, u16,
2848c2ecf20Sopenharmony_ci				   u16, u32, u32);
2858c2ecf20Sopenharmony_ciextern void xpc_disconnect(int);
2868c2ecf20Sopenharmony_ci
2878c2ecf20Sopenharmony_cistatic inline enum xp_retval
2888c2ecf20Sopenharmony_cixpc_send(short partid, int ch_number, u32 flags, void *payload,
2898c2ecf20Sopenharmony_ci	 u16 payload_size)
2908c2ecf20Sopenharmony_ci{
2918c2ecf20Sopenharmony_ci	if (!xpc_interface.send)
2928c2ecf20Sopenharmony_ci		return xpNotLoaded;
2938c2ecf20Sopenharmony_ci
2948c2ecf20Sopenharmony_ci	return xpc_interface.send(partid, ch_number, flags, payload,
2958c2ecf20Sopenharmony_ci				  payload_size);
2968c2ecf20Sopenharmony_ci}
2978c2ecf20Sopenharmony_ci
2988c2ecf20Sopenharmony_cistatic inline enum xp_retval
2998c2ecf20Sopenharmony_cixpc_send_notify(short partid, int ch_number, u32 flags, void *payload,
3008c2ecf20Sopenharmony_ci		u16 payload_size, xpc_notify_func func, void *key)
3018c2ecf20Sopenharmony_ci{
3028c2ecf20Sopenharmony_ci	if (!xpc_interface.send_notify)
3038c2ecf20Sopenharmony_ci		return xpNotLoaded;
3048c2ecf20Sopenharmony_ci
3058c2ecf20Sopenharmony_ci	return xpc_interface.send_notify(partid, ch_number, flags, payload,
3068c2ecf20Sopenharmony_ci					 payload_size, func, key);
3078c2ecf20Sopenharmony_ci}
3088c2ecf20Sopenharmony_ci
3098c2ecf20Sopenharmony_cistatic inline void
3108c2ecf20Sopenharmony_cixpc_received(short partid, int ch_number, void *payload)
3118c2ecf20Sopenharmony_ci{
3128c2ecf20Sopenharmony_ci	if (xpc_interface.received)
3138c2ecf20Sopenharmony_ci		xpc_interface.received(partid, ch_number, payload);
3148c2ecf20Sopenharmony_ci}
3158c2ecf20Sopenharmony_ci
3168c2ecf20Sopenharmony_cistatic inline enum xp_retval
3178c2ecf20Sopenharmony_cixpc_partid_to_nasids(short partid, void *nasids)
3188c2ecf20Sopenharmony_ci{
3198c2ecf20Sopenharmony_ci	if (!xpc_interface.partid_to_nasids)
3208c2ecf20Sopenharmony_ci		return xpNotLoaded;
3218c2ecf20Sopenharmony_ci
3228c2ecf20Sopenharmony_ci	return xpc_interface.partid_to_nasids(partid, nasids);
3238c2ecf20Sopenharmony_ci}
3248c2ecf20Sopenharmony_ci
3258c2ecf20Sopenharmony_ciextern short xp_max_npartitions;
3268c2ecf20Sopenharmony_ciextern short xp_partition_id;
3278c2ecf20Sopenharmony_ciextern u8 xp_region_size;
3288c2ecf20Sopenharmony_ci
3298c2ecf20Sopenharmony_ciextern unsigned long (*xp_pa) (void *);
3308c2ecf20Sopenharmony_ciextern unsigned long (*xp_socket_pa) (unsigned long);
3318c2ecf20Sopenharmony_ciextern enum xp_retval (*xp_remote_memcpy) (unsigned long, const unsigned long,
3328c2ecf20Sopenharmony_ci		       size_t);
3338c2ecf20Sopenharmony_ciextern int (*xp_cpu_to_nasid) (int);
3348c2ecf20Sopenharmony_ciextern enum xp_retval (*xp_expand_memprotect) (unsigned long, unsigned long);
3358c2ecf20Sopenharmony_ciextern enum xp_retval (*xp_restrict_memprotect) (unsigned long, unsigned long);
3368c2ecf20Sopenharmony_ci
3378c2ecf20Sopenharmony_ciextern u64 xp_nofault_PIOR_target;
3388c2ecf20Sopenharmony_ciextern int xp_nofault_PIOR(void *);
3398c2ecf20Sopenharmony_ciextern int xp_error_PIOR(void);
3408c2ecf20Sopenharmony_ci
3418c2ecf20Sopenharmony_ciextern struct device *xp;
3428c2ecf20Sopenharmony_ciextern enum xp_retval xp_init_uv(void);
3438c2ecf20Sopenharmony_ciextern void xp_exit_uv(void);
3448c2ecf20Sopenharmony_ci
3458c2ecf20Sopenharmony_ci#endif /* _DRIVERS_MISC_SGIXP_XP_H */
346