aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-sparc64/ldc.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/asm-sparc64/ldc.h')
-rw-r--r--include/asm-sparc64/ldc.h136
1 files changed, 136 insertions, 0 deletions
diff --git a/include/asm-sparc64/ldc.h b/include/asm-sparc64/ldc.h
new file mode 100644
index 000000000000..24fd2367d33a
--- /dev/null
+++ b/include/asm-sparc64/ldc.h
@@ -0,0 +1,136 @@
1#ifndef _SPARC64_LDC_H
2#define _SPARC64_LDC_H
3
4#include <asm/hypervisor.h>
5
6extern int ldom_domaining_enabled;
7
8/* The event handler will be evoked when link state changes
9 * or data becomes available on the receive side.
10 *
11 * For non-RAW links, if the LDC_EVENT_RESET event arrives the
12 * driver should reset all of it's internal state and reinvoke
13 * ldc_connect() to try and bring the link up again.
14 *
15 * For RAW links, ldc_connect() is not used. Instead the driver
16 * just waits for the LDC_EVENT_UP event.
17 */
18struct ldc_channel_config {
19 void (*event)(void *arg, int event);
20
21 u32 mtu;
22 unsigned int rx_irq;
23 unsigned int tx_irq;
24 u8 mode;
25#define LDC_MODE_RAW 0x00
26#define LDC_MODE_UNRELIABLE 0x01
27#define LDC_MODE_RESERVED 0x02
28#define LDC_MODE_RELIABLE 0x03
29#define LDC_MODE_STREAM 0x04
30
31 u8 debug;
32#define LDC_DEBUG_HS 0x01
33#define LDC_DEBUG_STATE 0x02
34#define LDC_DEBUG_RX 0x04
35#define LDC_DEBUG_TX 0x08
36#define LDC_DEBUG_DATA 0x10
37};
38
39#define LDC_EVENT_RESET 0x01
40#define LDC_EVENT_UP 0x02
41#define LDC_EVENT_DATA_READY 0x04
42
43#define LDC_STATE_INVALID 0x00
44#define LDC_STATE_INIT 0x01
45#define LDC_STATE_BOUND 0x02
46#define LDC_STATE_READY 0x03
47#define LDC_STATE_CONNECTED 0x04
48
49struct ldc_channel;
50
51/* Allocate state for a channel. */
52extern struct ldc_channel *ldc_alloc(unsigned long id,
53 const struct ldc_channel_config *cfgp,
54 void *event_arg);
55
56/* Shut down and free state for a channel. */
57extern void ldc_free(struct ldc_channel *lp);
58
59/* Register TX and RX queues of the link with the hypervisor. */
60extern int ldc_bind(struct ldc_channel *lp);
61
62/* For non-RAW protocols we need to complete a handshake before
63 * communication can proceed. ldc_connect() does that, if the
64 * handshake completes successfully, an LDC_EVENT_UP event will
65 * be sent up to the driver.
66 */
67extern int ldc_connect(struct ldc_channel *lp);
68extern int ldc_disconnect(struct ldc_channel *lp);
69
70extern int ldc_state(struct ldc_channel *lp);
71
72/* Read and write operations. Only valid when the link is up. */
73extern int ldc_write(struct ldc_channel *lp, const void *buf,
74 unsigned int size);
75extern int ldc_read(struct ldc_channel *lp, void *buf, unsigned int size);
76
77#define LDC_MAP_SHADOW 0x01
78#define LDC_MAP_DIRECT 0x02
79#define LDC_MAP_IO 0x04
80#define LDC_MAP_R 0x08
81#define LDC_MAP_W 0x10
82#define LDC_MAP_X 0x20
83#define LDC_MAP_RW (LDC_MAP_R | LDC_MAP_W)
84#define LDC_MAP_RWX (LDC_MAP_R | LDC_MAP_W | LDC_MAP_X)
85#define LDC_MAP_ALL 0x03f
86
87struct ldc_trans_cookie {
88 u64 cookie_addr;
89 u64 cookie_size;
90};
91
92struct scatterlist;
93extern int ldc_map_sg(struct ldc_channel *lp,
94 struct scatterlist *sg, int num_sg,
95 struct ldc_trans_cookie *cookies, int ncookies,
96 unsigned int map_perm);
97
98extern int ldc_map_single(struct ldc_channel *lp,
99 void *buf, unsigned int len,
100 struct ldc_trans_cookie *cookies, int ncookies,
101 unsigned int map_perm);
102
103extern void ldc_unmap(struct ldc_channel *lp, struct ldc_trans_cookie *cookies,
104 int ncookies);
105
106extern int ldc_copy(struct ldc_channel *lp, int copy_dir,
107 void *buf, unsigned int len, unsigned long offset,
108 struct ldc_trans_cookie *cookies, int ncookies);
109
110static inline int ldc_get_dring_entry(struct ldc_channel *lp,
111 void *buf, unsigned int len,
112 unsigned long offset,
113 struct ldc_trans_cookie *cookies,
114 int ncookies)
115{
116 return ldc_copy(lp, LDC_COPY_IN, buf, len, offset, cookies, ncookies);
117}
118
119static inline int ldc_put_dring_entry(struct ldc_channel *lp,
120 void *buf, unsigned int len,
121 unsigned long offset,
122 struct ldc_trans_cookie *cookies,
123 int ncookies)
124{
125 return ldc_copy(lp, LDC_COPY_OUT, buf, len, offset, cookies, ncookies);
126}
127
128extern void *ldc_alloc_exp_dring(struct ldc_channel *lp, unsigned int len,
129 struct ldc_trans_cookie *cookies,
130 int *ncookies, unsigned int map_perm);
131
132extern void ldc_free_exp_dring(struct ldc_channel *lp, void *buf,
133 unsigned int len,
134 struct ldc_trans_cookie *cookies, int ncookies);
135
136#endif /* _SPARC64_LDC_H */