blob: 84056b0f1ce1957623f519358c3c440c5bd59458 [file] [log] [blame]
Sridhar Parasurambf391322015-01-23 09:29:07 -08001/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
2
3Redistribution and use in source and binary forms, with or without
4modification, are permitted provided that the following conditions are
5met:
6 * Redistributions of source code must retain the above copyright
7 notice, this list of conditions and the following disclaimer.
8 * Redistributions in binary form must reproduce the above
9 copyright notice, this list of conditions and the following
10 disclaimer in the documentation and/or other materials provided
11 with the distribution.
12 * Neither the name of The Linux Foundation nor the names of its
13 contributors may be used to endorse or promote products derived
14 from this software without specific prior written permission.
15
16THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27*/
28
29#ifndef GLINK_TRANSPORT_IF_H
30#define GLINK_TRANSPORT_IF_H
31
32/**
33 * @file glink_transport_if.h
34 *
35 * Public API for the GLink Core to transport interface
36 */
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41
42/*===========================================================================
43 INCLUDE FILES
44===========================================================================*/
45#include <smem_list.h>
46#include <glink_os_utils.h>
47
48/*===========================================================================
49 MACRO DECLARATIONS
50===========================================================================*/
51/* GLink transport capability bit definitions */
52/* Whether transport supports signalling */
53#define GLINK_CAPABILITY_SIG_SUPPORT 0x00000001
Sridhar Parasuram3b058122015-05-11 16:15:03 -070054
Sridhar Parasurambf391322015-01-23 09:29:07 -080055/* Intentless mode of operation */
56#define GLINK_CAPABILITY_INTENTLESS 0x00000002
57
Sridhar Parasuram3b058122015-05-11 16:15:03 -070058/* Tracer packet support */
59#define GLINK_CAPABILITY_TRACER_PKT 0x00000004
60
Sridhar Parasurambf391322015-01-23 09:29:07 -080061/*===========================================================================
62 TYPE DECLARATIONS
63===========================================================================*/
64/* forward declaration */
65struct glink_transport_if;
66typedef struct glink_transport_if glink_transport_if_type;
67
68struct glink_core_xport_ctx;
69typedef struct glink_core_xport_ctx glink_core_xport_ctx_type;
70
71struct glink_core_if;
72typedef struct glink_core_if glink_core_if_type;
73
74struct glink_rx_intent;
75typedef struct glink_rx_intent glink_rx_intent_type;
76
Sridhar Parasuram3b058122015-05-11 16:15:03 -070077struct glink_channel_ctx;
78typedef struct glink_channel_ctx glink_channel_ctx_type;
79
Sridhar Parasurambf391322015-01-23 09:29:07 -080080/* Priority of transports registered with glink */
81typedef enum {
82 GLINK_XPORT_SMEM = 100,
83 GLINK_XPORT_RPM = 100,
84 GLINK_XPORT_SMD = 200,
85 GLINK_XPORT_CP_ENGINE = 300,
86 GLINK_MIN_PRIORITY = GLINK_XPORT_CP_ENGINE,
87 GLINK_INVALID_PRIORITY
88} glink_xport_priority;
89
90/** Glink core -> Xport pkt type definition */
Sridhar Parasuram3b058122015-05-11 16:15:03 -070091typedef struct glink_core_tx_pkt_s {
92 struct glink_core_tx_pkt_s *next; /* pointer to the next packet in list */
93
Sridhar Parasurambf391322015-01-23 09:29:07 -080094 void *data; /* Pointer to the data buffer to be transmitted */
95 const void *pkt_priv; /* Per packet private data */
Sridhar Parasuram3b058122015-05-11 16:15:03 -070096 uint32 cid; /* Local channel ID being used to transmit data */
Sridhar Parasurambf391322015-01-23 09:29:07 -080097 uint32 iid; /* Remote intent ID being used to transmit data */
98 size_t size; /* Size of data buffer */
99 size_t size_remaining; /* Size left to transmit */
100 void *iovec; /* Pointer to the data buffer to be transmitted */
Sridhar Parasuram3b058122015-05-11 16:15:03 -0700101 boolean tracer_pkt; /* specify if this intent is for tracer packet */
Sridhar Parasurambf391322015-01-23 09:29:07 -0800102 glink_buffer_provider_fn vprovider; /* Buffer provider for virtual space */
103 glink_buffer_provider_fn pprovider; /* Buffer provider for physical space */
104}glink_core_tx_pkt_type;
105
106/** Transmit a version command for local negotiation. The transport would call
107 * glink_transport_if_type::rx_cmd_version_ack callback as a result */
108typedef void (*tx_cmd_version_fn)
109(
110 glink_transport_if_type *if_ptr, /* Pointer to the interface instance */
111 uint32 version, /* Version */
112 uint32 features /* Features */
113);
114
115/** Transmit a version ack for remote nogotiation */
116typedef void (*tx_cmd_version_ack_fn)
117(
118 glink_transport_if_type *if_ptr, /* Pointer to the interface instance */
119 uint32 version, /* Version */
120 uint32 features /* Features */
121);
122
123/** Signals the negotiation is complete and transport can now do version
124 * specific initialization. Return uint32 transport capabilities bit field */
125typedef uint32 (*set_version_fn)
126(
127 glink_transport_if_type *if_ptr, /* Pointer to the interface instance */
128 uint32 version, /* Version */
129 uint32 features /* Features */
130);
131
132/** Sends OPEN command to transport for transport to do whatever it deems
133 * necessary to open a GLink logical channel.
134 * GLink Core expects glink_transport_if_type::rx_cmd_ch_open_ack to be called
135 * as a result of channel opening. */
136typedef glink_err_type (*tx_cmd_ch_open_fn)
137(
138 glink_transport_if_type *if_ptr,/* Pointer to the interface instance */
139 uint32 lcid, /* Local channel ID */
140 const char *name, /* String name for the logical channel */
141 glink_xport_priority prio
142);
143
144/** Sends CLOSE command to transport for transport to do whatever it deems
145 * necessary to close the specified GLink logical channel.
146 * GLink Core expects glink_transport_if_type::rx_cmd_ch_close_ack to be
147 * called as a result of channel closing. */
148typedef glink_err_type (*tx_cmd_ch_close_fn)
149(
150 glink_transport_if_type *if_ptr, /* Pointer to the interface instance */
151 uint32 lcid /* Local channel ID */
152);
153
154/** Sends the remote open ACK command in response to receiving
155 * glink_core_if_type::rx_cmd_ch_remote_open */
156typedef void (*tx_cmd_ch_remote_open_ack_fn)
157(
158 glink_transport_if_type *if_ptr, /* Pointer to the interface instance */
159 uint32 rcid, /* Remote channel ID */
160 glink_xport_priority prio
161);
162
163/** Sends the remote close ACK command in response to receiving
164 * glink_core_if_type::rx_cmd_ch_remote_close */
165typedef void (*tx_cmd_ch_remote_close_ack_fn)
166(
167 glink_transport_if_type *if_ptr, /* Pointer to the interface instance */
168 uint32 rcid /* Remote channel ID */
169);
170
171/** Allocates a receive buffer for the local rx intent */
172typedef glink_err_type (*allocate_rx_intent_fn)
173(
174 glink_transport_if_type *if_ptr, /* Pointer to the interface instance */
175 size_t size, /* Size of Rx intent */
176 glink_rx_intent_type *intent_ptr /* Intent ptr */
177);
178
179/** Deallocates a receive buffer for the local rx intent */
180typedef glink_err_type (*deallocate_rx_intent_fn)
181(
182 glink_transport_if_type *if_ptr, /* Pointer to the interface instance */
183 glink_rx_intent_type *intent_ptr /* Intent ptr */
184);
185
186/** Send receive intent ID for a given channel */
187typedef glink_err_type (*tx_cmd_local_rx_intent_fn)
188(
189 glink_transport_if_type *if_ptr, /* Pointer to the interface instance */
190 uint32 lcid, /* Local channel ID */
191 size_t size, /* Size of Rx intent */
192 uint32 liid /* Local indent ID */
193);
194
195/** Send receive done command for an intent for the specified channel */
196typedef void(*tx_cmd_local_rx_done_fn)
197(
198 glink_transport_if_type *if_ptr, /* Pointer to the interface instance */
199 uint32 lcid, /* Local channel ID */
200 uint32 liid, /* Local indent ID */
201 boolean reuse /* Reuse indent */
202);
203
204/** Send a data packet to the transport to be transmitted over the specified
205 * channel */
206typedef glink_err_type (*tx_fn)
207(
208 glink_transport_if_type *if_ptr, /* Pointer to the interface instance */
209 uint32 lcid, /* Local channel ID */
210 glink_core_tx_pkt_type *pctx /* Packet to be transmitted */
211);
212
213/** Send a intent request to the remote side to have it queue more rx intents
214 * to unblock this end's tx operation */
215typedef glink_err_type (*tx_cmd_rx_intent_req_fn)
216(
217 glink_transport_if_type *if_ptr, /* Pointer to the interface instance */
218 uint32 lcid, /* Local channel ID */
219 size_t size /* Size of the requested intent */
220);
221
222/** Send the ACK back for the rx intent request send by the other side,
223 * specifynig whether the request was granted ot not */
224typedef glink_err_type (*tx_cmd_remote_rx_intent_req_ack_fn)
225(
226 glink_transport_if_type *if_ptr, /* Pointer to the interface instance */
227 uint32 lcid, /* Local channel ID */
228 boolean granted /* Whether of not the intent request was
229 granted */
230);
231
232/** Sets the local channel signals as per the specified 32-bit mask.
233 * Transport may also send the 32-bit value as-is to the remote side. */
234typedef glink_err_type (*tx_cmd_set_sigs_fn)
235(
236 glink_transport_if_type *if_ptr, /* Pointer to the interface instance */
237 uint32 lcid, /* Local channel ID */
238 uint32 sigs /* Whether of not the intent request was
239 granted */
240);
241
242/** Lets the XAL know of SSR on that edge. */
243typedef glink_err_type (*ssr_fn)
244(
245 glink_transport_if_type *if_ptr /* Pointer to the interface instance */
246);
247
248/** Trigger a poll for any rx data / signals on transport. */
249typedef glink_err_type (*poll_fn)
250(
251 glink_transport_if_type *if_ptr /* Pointer to the interface instance */
252);
253
254/** Mask/Unmask rx interrupt associated with transport. */
255typedef glink_err_type (*mask_rx_irq_fn)
256(
257 glink_transport_if_type *if_ptr, /* Pointer to the interface instance */
258 boolean mask /* TRUE-mask, FALSE=unmask */
259);
260
261/** Wait for the link to go down. */
262typedef boolean (*wait_link_down_fn)
263(
264 glink_transport_if_type *if_ptr /* Pointer to the interface instance */
265);
266
267
268/**
269 * Data Structure for GLink Core to call into transport API
270 *
271 * This structure is used by the GLink core to operate transport
272 * This set of function pointers to to be filled in by the transport
273 * abstraction layer.
274 */
275struct glink_transport_if {
276 /* Link needed for use with list APIs. Must be at the head of the struct */
277 smem_list_link_type link;
278
279 /** Transmit a version command for local negotiation. The transport would
280 * call glink_transport_if_type::rx_cmd_version_ack callback as a result */
281 tx_cmd_version_fn tx_cmd_version;
282
283 /** Transmit a version ack for remote nogotiation */
284 tx_cmd_version_ack_fn tx_cmd_version_ack;
285
286 /** Signals the negotiation is complete and transport can now do version
287 * specific initialization */
288 set_version_fn set_version;
289
290
291 /** Sends OPEN command to transport for transport to do whatever it deems
292 * necessary to open a GLink logical channel.
293 * GLink Core expects glink_transport_if_type::rx_cmd_ch_open_ack to be
294 * called as a result of channel opening. */
295 tx_cmd_ch_open_fn tx_cmd_ch_open;
296
297
298 /** Sends CLOSE command to transport for transport to do whatever it deems
299 * necessary to close the specified GLink logical channel.
300 * GLink Core expects glink_transport_if_type::rx_cmd_ch_close_ack to be
301 * called as a result of channel closing. */
302 tx_cmd_ch_close_fn tx_cmd_ch_close;
303
304
305 /** Sends the remote open ACK command in response to receiving
306 * glink_core_if_type::rx_cmd_ch_remote_open */
307 tx_cmd_ch_remote_open_ack_fn tx_cmd_ch_remote_open_ack;
308
309 /** Sends the remote close ACK command in response to receiving
310 * glink_core_if_type::rx_cmd_ch_remote_close */
311 tx_cmd_ch_remote_close_ack_fn tx_cmd_ch_remote_close_ack;
312
313 /** Allocates a receive vector buffer for the local rx intent */
314 allocate_rx_intent_fn allocate_rx_intent;
315
316 /** Deallocates a receive vector buffer for the local rx intent */
317 deallocate_rx_intent_fn deallocate_rx_intent;
318
319 /** Send receive intent ID for a given channel */
320 tx_cmd_local_rx_intent_fn tx_cmd_local_rx_intent;
321
322
323 /** Send receive done command for an intent for the specified channel */
324 tx_cmd_local_rx_done_fn tx_cmd_local_rx_done;
325
326
327 /** Send a data packet to the transport to be transmitted over the specified
328 * channel */
329 tx_fn tx;
330
Sridhar Parasuram3b058122015-05-11 16:15:03 -0700331 /** Send request to the remote to queue more rx intents */
Sridhar Parasurambf391322015-01-23 09:29:07 -0800332 tx_cmd_rx_intent_req_fn tx_cmd_rx_intent_req;
333
334 /** Send ACK to the remote side's request to queue more rx intents */
335 tx_cmd_remote_rx_intent_req_ack_fn tx_cmd_remote_rx_intent_req_ack;
336
337 /** Sets the local channel signals as per the specified 32-bit mask.
338 * Transport may also send the 32-bit value as-is to the remote side. */
339 tx_cmd_set_sigs_fn tx_cmd_set_sigs;
340
341 /** Lets the XAL know of SSR on that edge. */
342 ssr_fn ssr;
343
344 /** Trigger a poll for any rx data / signals on transport. */
345 poll_fn poll;
346
347 /** Mask/Unmask rx interrupt associated with transport */
348 mask_rx_irq_fn mask_rx_irq;
349
350 /** Wait for the link to go down. */
351 wait_link_down_fn wait_link_down;
352
353 /** Transport specific data pointer that transport may choose fill in
354 * with some data */
355 glink_core_xport_ctx_type *glink_core_priv;
356
357 /** GLINK core interface pointer associated with this transport interface */
358 glink_core_if_type *glink_core_if_ptr;
359
360 /* glink transport priority */
361 glink_xport_priority glink_priority;
362};
363
364#endif //GLINK_TRANSPORT_IF_H