Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *  Copyright (c) 2008 Silicon Graphics, Inc.  All Rights Reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #ifndef __GRU_KSERVICES_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #define __GRU_KSERVICES_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  * Message queues using the GRU to send/receive messages.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  * These function allow the user to create a message queue for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  * sending/receiving 1 or 2 cacheline messages using the GRU.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  * Processes SENDING messages will use a kernel CBR/DSR to send
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  * the message. This is transparent to the caller.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  * The receiver does not use any GRU resources.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  * The functions support:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  * 	- single receiver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  * 	- multiple senders
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  *	- cross partition message
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  * Missing features ZZZ:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  * 	- user options for dealing with timeouts, queue full, etc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  * 	- gru_create_message_queue() needs interrupt vector info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) struct gru_message_queue_desc {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	void		*mq;			/* message queue vaddress */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	unsigned long	mq_gpa;			/* global address of mq */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	int		qlines;			/* queue size in CL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	int		interrupt_vector;	/* interrupt vector */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	int		interrupt_pnode;	/* pnode for interrupt */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	int		interrupt_apicid;	/* lapicid for interrupt */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)  * Initialize a user allocated chunk of memory to be used as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)  * a message queue. The caller must ensure that the queue is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43)  * in contiguous physical memory and is cacheline aligned.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45)  * Message queue size is the total number of bytes allocated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46)  * to the queue including a 2 cacheline header that is used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47)  * to manage the queue.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49)  *  Input:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50)  * 	mqd	pointer to message queue descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51)  * 	p	pointer to user allocated mesq memory.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52)  * 	bytes	size of message queue in bytes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53)  *      vector	interrupt vector (zero if no interrupts)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54)  *      nasid	nasid of blade where interrupt is delivered
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55)  *      apicid	apicid of cpu for interrupt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57)  *  Errors:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58)  *  	0	OK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59)  *  	>0	error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) extern int gru_create_message_queue(struct gru_message_queue_desc *mqd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 		void *p, unsigned int bytes, int nasid, int vector, int apicid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65)  * Send a message to a message queue.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67)  * Note: The message queue transport mechanism uses the first 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68)  * bits of the message. Users should avoid using these bits.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  *   Input:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)  * 	mqd	pointer to message queue descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)  * 	mesg	pointer to message. Must be 64-bit aligned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74)  * 	bytes	size of message in bytes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76)  *   Output:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77)  *      0	message sent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78)  *     >0	Send failure - see error codes below
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) extern int gru_send_message_gpa(struct gru_message_queue_desc *mqd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 			void *mesg, unsigned int bytes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) /* Status values for gru_send_message() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) #define MQE_OK			0	/* message sent successfully */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) #define MQE_CONGESTION		1	/* temporary congestion, try again */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) #define MQE_QUEUE_FULL		2	/* queue is full */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) #define MQE_UNEXPECTED_CB_ERR	3	/* unexpected CB error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) #define MQE_PAGE_OVERFLOW	10	/* BUG - queue overflowed a page */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) #define MQE_BUG_NO_RESOURCES	11	/* BUG - could not alloc GRU cb/dsr */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93)  * Advance the receive pointer for the message queue to the next message.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94)  * Note: current API requires messages to be gotten & freed in order. Future
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95)  * API extensions may allow for out-of-order freeing.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97)  *   Input
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98)  * 	mqd	pointer to message queue descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99)  * 	mesq	message being freed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) extern void gru_free_message(struct gru_message_queue_desc *mqd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 			     void *mesq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)  * Get next message from message queue. Returns pointer to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)  * message OR NULL if no message present.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)  * User must call gru_free_message() after message is processed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)  * in order to move the queue pointers to next message.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)  *   Input
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)  * 	mqd	pointer to message queue descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)  *   Output:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)  *	p	pointer to message
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)  *	NULL	no message available
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) extern void *gru_get_next_message(struct gru_message_queue_desc *mqd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)  * Read a GRU global GPA. Source can be located in a remote partition.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)  *    Input:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)  *    	value		memory address where MMR value is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)  *    	gpa		source numalink physical address of GPA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)  *    Output:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)  *	0		OK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)  *	>0		error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) int gru_read_gpa(unsigned long *value, unsigned long gpa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)  * Copy data using the GRU. Source or destination can be located in a remote
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)  * partition.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)  *    Input:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)  *    	dest_gpa	destination global physical address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)  *    	src_gpa		source global physical address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)  *    	bytes		number of bytes to copy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)  *    Output:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)  *	0		OK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)  *	>0		error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) extern int gru_copy_gpa(unsigned long dest_gpa, unsigned long src_gpa,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 							unsigned int bytes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)  * Reserve GRU resources to be used asynchronously.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)  * 	input:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)  * 		blade_id  - blade on which resources should be reserved
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)  * 		cbrs	  - number of CBRs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)  * 		dsr_bytes - number of DSR bytes needed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)  * 		cmp	  - completion structure for waiting for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)  * 			    async completions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)  *	output:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)  *		handle to identify resource
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)  *		(0 = no resources)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) extern unsigned long gru_reserve_async_resources(int blade_id, int cbrs, int dsr_bytes,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 				struct completion *cmp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)  * Release async resources previously reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)  *	input:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)  *		han - handle to identify resources
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) extern void gru_release_async_resources(unsigned long han);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)  * Wait for async GRU instructions to complete.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)  *	input:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)  *		han - handle to identify resources
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) extern void gru_wait_async_cbr(unsigned long han);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)  * Lock previous reserved async GRU resources
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)  *	input:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)  *		han - handle to identify resources
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)  *	output:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)  *		cb  - pointer to first CBR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)  *		dsr - pointer to first DSR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) extern void gru_lock_async_resource(unsigned long han,  void **cb, void **dsr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)  * Unlock previous reserved async GRU resources
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)  *	input:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)  *		han - handle to identify resources
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) extern void gru_unlock_async_resource(unsigned long han);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) #endif 		/* __GRU_KSERVICES_H_ */