4 #include <asm/hypervisor.h>
6 extern int ldom_domaining_enabled;
7 void ldom_set_var(const char *var, const char *value);
8 void ldom_reboot(const char *boot_command);
9 void ldom_power_off(void);
11 /* The event handler will be evoked when link state changes
12 * or data becomes available on the receive side.
14 * For non-RAW links, if the LDC_EVENT_RESET event arrives the
15 * driver should reset all of it's internal state and reinvoke
16 * ldc_connect() to try and bring the link up again.
18 * For RAW links, ldc_connect() is not used. Instead the driver
19 * just waits for the LDC_EVENT_UP event.
21 struct ldc_channel_config {
22 void (*event)(void *arg, int event);
28 #define LDC_MODE_RAW 0x00
29 #define LDC_MODE_UNRELIABLE 0x01
30 #define LDC_MODE_RESERVED 0x02
31 #define LDC_MODE_STREAM 0x03
34 #define LDC_DEBUG_HS 0x01
35 #define LDC_DEBUG_STATE 0x02
36 #define LDC_DEBUG_RX 0x04
37 #define LDC_DEBUG_TX 0x08
38 #define LDC_DEBUG_DATA 0x10
41 #define LDC_EVENT_RESET 0x01
42 #define LDC_EVENT_UP 0x02
43 #define LDC_EVENT_DATA_READY 0x04
45 #define LDC_STATE_INVALID 0x00
46 #define LDC_STATE_INIT 0x01
47 #define LDC_STATE_BOUND 0x02
48 #define LDC_STATE_READY 0x03
49 #define LDC_STATE_CONNECTED 0x04
51 #define LDC_PACKET_SIZE 64
55 /* Allocate state for a channel. */
56 struct ldc_channel *ldc_alloc(unsigned long id,
57 const struct ldc_channel_config *cfgp,
61 /* Shut down and free state for a channel. */
62 void ldc_free(struct ldc_channel *lp);
64 /* Register TX and RX queues of the link with the hypervisor. */
65 int ldc_bind(struct ldc_channel *lp);
66 void ldc_unbind(struct ldc_channel *lp);
68 /* For non-RAW protocols we need to complete a handshake before
69 * communication can proceed. ldc_connect() does that, if the
70 * handshake completes successfully, an LDC_EVENT_UP event will
71 * be sent up to the driver.
73 int ldc_connect(struct ldc_channel *lp);
74 int ldc_disconnect(struct ldc_channel *lp);
76 int ldc_state(struct ldc_channel *lp);
77 void ldc_set_state(struct ldc_channel *lp, u8 state);
78 int ldc_mode(struct ldc_channel *lp);
79 void __ldc_print(struct ldc_channel *lp, const char *caller);
80 int ldc_rx_reset(struct ldc_channel *lp);
82 #define ldc_print(chan) __ldc_print(chan, __func__)
84 /* Read and write operations. Only valid when the link is up. */
85 int ldc_write(struct ldc_channel *lp, const void *buf,
87 int ldc_read(struct ldc_channel *lp, void *buf, unsigned int size);
89 #define LDC_MAP_SHADOW 0x01
90 #define LDC_MAP_DIRECT 0x02
91 #define LDC_MAP_IO 0x04
92 #define LDC_MAP_R 0x08
93 #define LDC_MAP_W 0x10
94 #define LDC_MAP_X 0x20
95 #define LDC_MAP_RW (LDC_MAP_R | LDC_MAP_W)
96 #define LDC_MAP_RWX (LDC_MAP_R | LDC_MAP_W | LDC_MAP_X)
97 #define LDC_MAP_ALL 0x03f
99 struct ldc_trans_cookie {
105 int ldc_map_sg(struct ldc_channel *lp,
106 struct scatterlist *sg, int num_sg,
107 struct ldc_trans_cookie *cookies, int ncookies,
108 unsigned int map_perm);
110 int ldc_map_single(struct ldc_channel *lp,
111 void *buf, unsigned int len,
112 struct ldc_trans_cookie *cookies, int ncookies,
113 unsigned int map_perm);
115 void ldc_unmap(struct ldc_channel *lp, struct ldc_trans_cookie *cookies,
118 int ldc_copy(struct ldc_channel *lp, int copy_dir,
119 void *buf, unsigned int len, unsigned long offset,
120 struct ldc_trans_cookie *cookies, int ncookies);
122 static inline int ldc_get_dring_entry(struct ldc_channel *lp,
123 void *buf, unsigned int len,
124 unsigned long offset,
125 struct ldc_trans_cookie *cookies,
128 return ldc_copy(lp, LDC_COPY_IN, buf, len, offset, cookies, ncookies);
131 static inline int ldc_put_dring_entry(struct ldc_channel *lp,
132 void *buf, unsigned int len,
133 unsigned long offset,
134 struct ldc_trans_cookie *cookies,
137 return ldc_copy(lp, LDC_COPY_OUT, buf, len, offset, cookies, ncookies);
140 void *ldc_alloc_exp_dring(struct ldc_channel *lp, unsigned int len,
141 struct ldc_trans_cookie *cookies,
142 int *ncookies, unsigned int map_perm);
144 void ldc_free_exp_dring(struct ldc_channel *lp, void *buf,
146 struct ldc_trans_cookie *cookies, int ncookies);
148 #endif /* _SPARC64_LDC_H */