blob: fb6b854db85843775f7435d686435bd770e5ead1 [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_INTERNAL_H
30#define GLINK_INTERNAL_H
31
32/*===========================================================================
33
34 GLink Core Internal Header File
35
36===========================================================================*/
37
38/*===========================================================================
Sridhar Parasurambf391322015-01-23 09:29:07 -080039 INCLUDE FILES
Sridhar Parasurambf391322015-01-23 09:29:07 -080040===========================================================================*/
41#include "smem_list.h"
42#include "glink.h"
43#include "glink_os_utils.h"
44#include "glink_core_if.h"
45
Sridhar Parasurambf391322015-01-23 09:29:07 -080046#ifdef __cplusplus
47extern "C" {
48#endif
49
50/*===========================================================================
51 FEATURE DEFINITIONS
52===========================================================================*/
53#define GLINK_VERSION 0
54#define GLINK_FEATURE_FLAGS 0
55#define GLINK_NUM_HOSTS 7
Steven Cahail338e2f22015-08-24 15:11:53 -060056#define GLINK_INVALID_CID 0
Sridhar Parasurambf391322015-01-23 09:29:07 -080057
58/*===========================================================================
59 MACRO DEFINITIONS
60===========================================================================*/
Sridhar Parasurambf391322015-01-23 09:29:07 -080061
Steven Cahailb850bb62015-08-21 14:39:38 -060062/* Macros to enable/select glink logging and stats collection
63 * GLINK_MEMORY_LOGGING --> Enable memory based logging
64 * GLINK_OS_DEFINED_LOGGING --> Enable OS defined logging (uLog for ADSP/MPSS/SLPI)
65 * These will be selectively defined by the top level Glink Scons file
66 */
67/**** Logging macros GLINK_LOG_* ****/
68#if defined(GLINK_MEMORY_LOGGING)
Sridhar Parasurambf391322015-01-23 09:29:07 -080069#define GLINK_MEM_LOG_SIZE 128
70
Steven Cahailb850bb62015-08-21 14:39:38 -060071/* Used for xport logging where channel name information is unavaliable */
72#define GLINK_LOG_EVENT_NO_FILTER(type, ch_name, xport, remote_ss, param) \
73 glink_mem_log(type, ch_name, xport, remote_ss, param);
74
75/* Filtering based on ch_ctx, If ch_ctx is not available we should be using
76 *_NO_FILTER macro for logging */
77#define GLINK_LOG_EVENT(chnl_ctx, type, ch_name, xport, remote_ss, param) \
78 if ((log_filter_cfg.ch_filter_status == FALSE) || \
79 ((chnl_ctx) == log_filter_cfg.ch_ctx)) \
80 { \
81 glink_mem_log(type, ch_name, xport, remote_ss, param); \
82 }
83
84#define GLINK_LOG_ERROR_EVENT(type, ch_name, xport, remote_ss, param) \
85 glink_mem_log(type, ch_name, xport, remote_ss, param);
86
87#elif defined(GLINK_OS_DEFINED_LOGGING)
88
89/* Used for xport logging where channel name information is unavaliable */
90#define GLINK_LOG_EVENT_NO_FILTER(type, ch_name, xport, remote_ss, param) \
91 OS_LOG_MSG(5, "[%x, %s, %s, %s, %x]" , type, ch_name, \
92 xport, remote_ss, param);
93
94/* Filtering based on ch_ctx, If ch_ctx is not available we should be using
95 *_NO_FILTER macro for logging */
96#define GLINK_LOG_EVENT(chnl_ctx, type, ch_name, xport, remote_ss, param) \
97 if ((log_filter_cfg.ch_filter_status == FALSE) || \
98 ((chnl_ctx) == log_filter_cfg.ch_ctx)) \
99 { \
100 OS_LOG_MSG(5, "[%x, %s, %s, %s, %x]" , type, ch_name, \
101 xport, remote_ss, param); \
102 }
103
104#define GLINK_LOG_ERROR_EVENT(type, ch_name, xport, remote_ss, param) \
105 OS_LOG_ERROR(5, "[%x, %s, %s, %s, %x]" , type, ch_name, \
106 xport, remote_ss, param);
107#else
108#define GLINK_LOG_EVENT(lcid, type, ch_name, xport, remote_ss, param)
109#define GLINK_LOG_ERROR_EVENT(type, ch_name, xport, remote_ss, param)
110#define GLINK_LOG_EVENT_NO_FILTER(type, ch_name, xport, remote_ss, param)
111#endif
112
113/**** Macros used for collecting channel stats ****/
114#if defined(GLINK_CHANNEL_STATS_ENABLED)
115#define GLINK_UPDATE_CHANNEL_STATS(ch_stats, var_name, size_in_bytes) \
116 { \
117 (ch_stats).var_name##_count++; \
118 (ch_stats).var_name##_bytes += (size_in_bytes); \
119 }
120#else
121#define GLINK_UPDATE_CHANNEL_STATS(ch_stats, var_name, size_in_bytes)
122#endif
123
Sridhar Parasurambf391322015-01-23 09:29:07 -0800124/*===========================================================================
125 TYPE DEFINITIONS
126===========================================================================*/
127typedef enum {
128 GLINK_EVENT_INIT,
129 GLINK_EVENT_REGISTER_XPORT,
130 GLINK_EVENT_CH_OPEN,
131 GLINK_EVENT_CH_CLOSE,
132 GLINK_EVENT_CH_TX,
133 GLINK_EVENT_CH_Q_RX_INTENT,
134 GLINK_EVENT_CH_RX_DONE,
135 GLINK_EVENT_LINK_UP,
136 GLINK_EVENT_RX_CMD_VER,
137 GLINK_EVENT_RM_CH_OPEN,
138 GLINK_EVENT_CH_OPEN_ACK,
139 GLINK_EVENT_CH_CLOSE_ACK,
140 GLINK_EVENT_CH_REMOTE_CLOSE,
141 GLINK_EVENT_CH_STATE_TRANS,
142 GLINK_EVENT_CH_INTENT_PUT,
143 GLINK_EVENT_CH_RX_DATA,
144 GLINK_EVENT_CH_RX_DATA_FRAG,
145 GLINK_EVENT_CH_GET_PKT_CTX,
146 GLINK_EVENT_CH_PUT_PKT_CTX,
147 GLINK_EVENT_CH_TX_DONE,
148 GLINK_EVENT_CH_SIG_SET,
149 GLINK_EVENT_CH_SIG_L_GET,
150 GLINK_EVENT_CH_SIG_R_GET,
Sridhar Parasuram3b058122015-05-11 16:15:03 -0700151 GLINK_EVENT_CH_NO_MIGRATION,
152 GLINK_EVENT_CH_MIGRATION_IN_PROGRESS,
Sridhar Parasurambf391322015-01-23 09:29:07 -0800153 GLINK_EVENT_XPORT_INTERNAL,
Sridhar Parasuram3b058122015-05-11 16:15:03 -0700154 GLINK_EVENT_TRACER_PKT_FAILURE,
Steven Cahail79783352015-08-20 15:24:04 -0600155 GLINK_EVENT_TXV_INVALID_BUFFER,
156 GLINK_EVENT_CH_QOS_REG,
157 GLINK_EVENT_CH_QOS_CANCEL,
158 GLINK_EVENT_CH_QOS_START,
159 GLINK_EVENT_CH_QOS_STOP,
Steven Cahailb850bb62015-08-21 14:39:38 -0600160 GLINK_EVENT_INVALID_REMOTE_SS,
161 GLINK_EVENT_REGISTER_LINK_STATE_CB,
162 GLINK_EVENT_DEREGISTER_LINK_STATE_CB,
Steven Cahail7af13a02015-08-24 16:40:24 -0600163 GLINK_EVENT_LB_CLIENT,
164 GLINK_EVENT_SSR
Sridhar Parasurambf391322015-01-23 09:29:07 -0800165}glink_log_event_type;
166
Steven Cahailb850bb62015-08-21 14:39:38 -0600167/*Bit index of logging mask of differnt xport. The corresponding bit index
168 in glink_xport_log_filter_mask will disable(0) or enable(1) logging*/
169typedef enum {
170 GLINK_XPORT_RPM_MASK_BIT,
171 GLINK_XPORT_SMEM_MASK_BIT,
172 GLINK_XPORT_SMD_MASK_BIT,
173 GLINK_XPORT_UART_MASK_BIT
174}glink_xport_logging_mask_type;
175
Sridhar Parasurambf391322015-01-23 09:29:07 -0800176typedef struct _glink_channel_intents_type {
Sridhar Parasuram3b058122015-05-11 16:15:03 -0700177
178 /* Link for a channel in Tx queue */
179 struct _glink_channel_intents_type* next;
180
Steven Cahail79783352015-08-20 15:24:04 -0600181 /* Pointer to channel context */
182 glink_channel_ctx_type *ch_ctx;
183
Sridhar Parasurambf391322015-01-23 09:29:07 -0800184 /* Critical section to protest access to intent queues */
185 os_cs_type intent_q_cs;
186
187 /* Event that glink_tx waits on and blocks until remote rx_intents
188 * are available */
189 os_event_type rm_intent_avail_evt;
190
191 /* Size of requested intent that this channel wait on */
192 size_t rm_intent_req_size;
193
194 /* Linked list of remote Rx intents. Data can be transmitted only when
195 * remote intents are available */
196 smem_list_type remote_intent_q;
197
198 /* Linked list of remote Rx intents which local GLink core has used to
199 * transmit data, and are pending Tx complete */
200 smem_list_type remote_intent_pending_tx_q;
201
202 /* Linked list of local Rx intents. Data can be received only when
203 * local intents are available */
204 smem_list_type local_intent_q;
205
206 /* Linked list of remote Rx intents held by the clients */
207 smem_list_type local_intent_client_q;
208
209 /* Read intent being gathered */
210 glink_rx_intent_type *cur_read_intent;
211
Sridhar Parasuram3b058122015-05-11 16:15:03 -0700212 /* Linked list of Tx packets in the order they where submitted by
213 * the channel owner */
214 smem_list_type tx_pkt_q;
215
Sridhar Parasurambf391322015-01-23 09:29:07 -0800216} glink_channel_intents_type;
217
Steven Cahail79783352015-08-20 15:24:04 -0600218
219typedef struct _glink_channel_qos_type {
220 /* qos request count */
221 uint32 qos_req_count;
222
223 /* qos request packet size */
224 size_t qos_pkt_size;
225
226 /* qos request latency */
227 uint32 qos_latency_us;
228
229 /* qos request rate */
230 uint32 qos_rate;
231
232 /* qos priority */
233 uint32 qos_tokens;
234
235 /* qos transport context */
236 void *qos_transport_ctx;
237
238 /* qos start time for priority balancing */
239 os_timetick_type qos_start_priority_time;
240
241} glink_channel_qos_type;
242
Steven Cahailb850bb62015-08-21 14:39:38 -0600243/*This structure holds all the relevant stats per channel used for debugging*/
244typedef struct _glink_channel_stats_type {
245 /* Total number of bytes sent by the client */
246 uint64 tx_request_bytes;
247
248 /* Total number of bytes sent by the client for which we got tx_done */
249 uint64 tx_done_bytes;
250
251 /* Total number of tx requests */
252 uint32 tx_request_count;
253
254 /* total number of tx_done events */
255 uint32 tx_done_count;
256
257 /* Total number of bytes recieved by the client */
258 uint64 rx_notify_bytes;
259
260 /* Total number of bytes for which we got rx_done */
261 uint64 rx_done_bytes;
262
263 /* Total number of rx_notify events */
264 uint32 rx_notify_count;
265
266 /* Total number of rx_done events */
267 uint32 rx_done_count;
268
269} glink_channel_stats_type;
270
271/* Contains the configuration for logging within core and xport */
272typedef struct _glink_logging_filter_cfg {
273
274 /* GLink channel filter status */
275 boolean ch_filter_status;
276
277 /* channel filter name */
278 char ch_name[GLINK_CH_NAME_LEN];
279
280 /* corresponding lcid of the filter */
281 uint32 ch_lcid;
282
283 /* corresponding rcid of the filter*/
284 uint32 ch_rcid;
285
286 /* corresponding remote host*/
287 uint32 remote_host;
288
289 /* Corresponding channel context */
290 glink_channel_ctx_type *ch_ctx;
291
292 /* xport logging mask */
293 uint32 xport_filter_mask;
294
295}glink_logging_filter_cfg_type;
Steven Cahail79783352015-08-20 15:24:04 -0600296
Sridhar Parasurambf391322015-01-23 09:29:07 -0800297struct glink_channel_ctx {
298 /* Link needed for use with list APIs. Must be at the head of the struct */
Sridhar Parasuram3b058122015-05-11 16:15:03 -0700299 smem_list_link_type link;
Sridhar Parasurambf391322015-01-23 09:29:07 -0800300
301 /* Channel name */
Sridhar Parasuram3b058122015-05-11 16:15:03 -0700302 char name[GLINK_CH_NAME_LEN];
Sridhar Parasurambf391322015-01-23 09:29:07 -0800303
304 /* Local channel ID */
Sridhar Parasuram3b058122015-05-11 16:15:03 -0700305 uint32 lcid;
Sridhar Parasurambf391322015-01-23 09:29:07 -0800306
307 /* Remote Channel ID */
Sridhar Parasuram3b058122015-05-11 16:15:03 -0700308 uint32 rcid;
Sridhar Parasurambf391322015-01-23 09:29:07 -0800309
Sridhar Parasuram3b058122015-05-11 16:15:03 -0700310 /* Local Channel state */
311 glink_local_state_type local_state;
312
313 /* Remote channel state */
314 glink_remote_state_type remote_state;
315
Sridhar Parasurambf391322015-01-23 09:29:07 -0800316 /* Channel local control signal state */
Sridhar Parasuram3b058122015-05-11 16:15:03 -0700317 uint32 local_sigs;
Sridhar Parasurambf391322015-01-23 09:29:07 -0800318
319 /* Channel remote control signal state */
Sridhar Parasuram3b058122015-05-11 16:15:03 -0700320 uint32 remote_sigs;
Sridhar Parasurambf391322015-01-23 09:29:07 -0800321
322 /* Critical section to protect tx operations */
Sridhar Parasuram3b058122015-05-11 16:15:03 -0700323 os_cs_type tx_cs;
Sridhar Parasurambf391322015-01-23 09:29:07 -0800324
325 /* channel intent collection */
Sridhar Parasuram3b058122015-05-11 16:15:03 -0700326 glink_channel_intents_type *pintents;
Sridhar Parasurambf391322015-01-23 09:29:07 -0800327
Steven Cahail79783352015-08-20 15:24:04 -0600328 /* Critical section to protest access to QoS context */
329 os_cs_type qos_cs;
330
331 /* qos priority */
332 uint32 qos_priority;
333
334 /* channel QoS context */
335 glink_channel_qos_type *qosctx;
336
Sridhar Parasurambf391322015-01-23 09:29:07 -0800337 /* Interface pointer with with this channel is registered */
Sridhar Parasuram3b058122015-05-11 16:15:03 -0700338 glink_transport_if_type *if_ptr;
Sridhar Parasurambf391322015-01-23 09:29:07 -0800339
340 /** Private data for client to maintain context. This data is passed back
341 * to client in the notification callbacks */
Sridhar Parasuram3b058122015-05-11 16:15:03 -0700342 const void *priv;
Sridhar Parasurambf391322015-01-23 09:29:07 -0800343
344 /** Data receive notification callback */
Sridhar Parasuram3b058122015-05-11 16:15:03 -0700345 glink_rx_notification_cb notify_rx;
346
347 /** Tracer Packet data receive notification callback */
348 glink_rx_tracer_pkt_notification_cb notify_rx_tracer_pkt;
Sridhar Parasurambf391322015-01-23 09:29:07 -0800349
350 /** Vector receive notification callback */
Sridhar Parasuram3b058122015-05-11 16:15:03 -0700351 glink_rxv_notification_cb notify_rxv;
Sridhar Parasurambf391322015-01-23 09:29:07 -0800352
353 /** Data transmit notification callback */
Sridhar Parasuram3b058122015-05-11 16:15:03 -0700354 glink_tx_notification_cb notify_tx_done;
Sridhar Parasurambf391322015-01-23 09:29:07 -0800355
356 /** GLink channel state notification callback */
Sridhar Parasuram3b058122015-05-11 16:15:03 -0700357 glink_state_notification_cb notify_state;
Sridhar Parasurambf391322015-01-23 09:29:07 -0800358
359 /** Intent request from the remote side */
Sridhar Parasuram3b058122015-05-11 16:15:03 -0700360 glink_notify_rx_intent_req_cb notify_rx_intent_req;
Sridhar Parasurambf391322015-01-23 09:29:07 -0800361
362 /** New intent arrival from the remote side */
Sridhar Parasuram3b058122015-05-11 16:15:03 -0700363 glink_notify_rx_intent_cb notify_rx_intent;
Sridhar Parasurambf391322015-01-23 09:29:07 -0800364
365 /** Control signal change notification - Invoked when remote side
366 * alters its control signals */
Sridhar Parasuram3b058122015-05-11 16:15:03 -0700367 glink_notify_rx_sigs_cb notify_rx_sigs;
Sridhar Parasurambf391322015-01-23 09:29:07 -0800368
369 /** rx_intent abort notification. This callback would be invoked for
370 * every rx_intent that is queued with GLink core at the time the
371 * remote side or local side decides to close the port. Optional */
Sridhar Parasuram3b058122015-05-11 16:15:03 -0700372 glink_notify_rx_abort_cb notify_rx_abort;
Sridhar Parasurambf391322015-01-23 09:29:07 -0800373
374 /** tx abort notification. This callback would be invoked if client
375 * had queued a tx buffer with glink and it had not been transmitted i.e.
376 * tx_done callback has not been called for this buffer and remote side
377 * or local side closed the port. Optional */
Sridhar Parasuram3b058122015-05-11 16:15:03 -0700378 glink_notify_tx_abort_cb notify_tx_abort;
Sridhar Parasurambf391322015-01-23 09:29:07 -0800379
Sridhar Parasurambf391322015-01-23 09:29:07 -0800380 /* save glink open config options */
Sridhar Parasuram3b058122015-05-11 16:15:03 -0700381 uint32 ch_open_options;
Steven Cahailb850bb62015-08-21 14:39:38 -0600382#if defined(GLINK_CHANNEL_STATS_ENABLED)
383 /* Structure that constains per channel stats */
384 glink_channel_stats_type ch_stats;
385#endif
Sridhar Parasurambf391322015-01-23 09:29:07 -0800386};
387
388
389typedef struct _glink_mem_log_entry_type {
Sridhar Parasurambf391322015-01-23 09:29:07 -0800390 glink_log_event_type type;
391 const char *msg;
392 const char *xport;
393 const char *remote_ss;
394 uint32 param;
395} glink_mem_log_entry_type;
396
397/* Structure to store link notification callbacks */
398typedef struct {
399 /* Link needed for use with list APIs. Must be at the head of the struct */
400 smem_list_link_type link;
401
402 const char* xport; /* NULL = any transport */
403 const char* remote_ss; /* NULL = any subsystem */
404 glink_link_state_notif_cb link_notifier; /* Notification callback */
405 void *priv; /* Notification priv ptr */
406} glink_link_notif_data_type;
407
Steven Cahail964ff2f2015-08-20 19:01:56 -0600408
409/* Function pointer used to iterate glink registered transports
410 * glink_client_cond_fn is used to find specifc transport client wants
411 * glink_client_ex_fn will execute client's operation on specific/all transports
412 * depends on client's choice */
413typedef boolean (*glink_client_cond_fn)
414(
415 glink_transport_if_type *if_ptr,
416 void *cond1, /* First condition to compare */
417 uint32 cond2, /* Second condition to compare */
418 void **out /* Client private return value */
419);
420
421typedef void (*glink_client_ex_fn)
422(
423 glink_transport_if_type *if_ptr,
424 void *param1, /* First parameter */
425 uint32 param2, /* Second parameter */
426 void **out /* Client private return value */
427);
428
Sridhar Parasurambf391322015-01-23 09:29:07 -0800429/*===========================================================================
430 GLOBAL DATA DECLARATIONS
431===========================================================================*/
Sridhar Parasurambf391322015-01-23 09:29:07 -0800432extern const char *glink_hosts_supported[GLINK_NUM_HOSTS];
Sridhar Parasurambf391322015-01-23 09:29:07 -0800433
Steven Cahailb850bb62015-08-21 14:39:38 -0600434/* Used for filtering logs*/
435extern glink_logging_filter_cfg_type log_filter_cfg;
Sridhar Parasurambf391322015-01-23 09:29:07 -0800436/*===========================================================================
437 LOCAL FUNCTION DEFINITIONS
438===========================================================================*/
Sridhar Parasurambf391322015-01-23 09:29:07 -0800439/*===========================================================================
440 EXTERNAL FUNCTION DEFINITIONS
441===========================================================================*/
442/*===========================================================================
443FUNCTION glink_link_up
444
445DESCRIPTION Indicates that transport is now ready to start negotiation
446 using the v0 configuration
447
448ARGUMENTS *if_ptr Pointer to interface instance; must be unique
449 for each edge
450
451RETURN VALUE None.
452
453SIDE EFFECTS None
454===========================================================================*/
455void glink_link_up
456(
457 glink_transport_if_type *if_ptr
458);
459
460/*===========================================================================
461FUNCTION glink_rx_cmd_version
462
463DESCRIPTION Receive transport version for remote-initiated version
464 negotiation
465
466ARGUMENTS *if_ptr Pointer to interface instance; must be unique
467 for each edge
468
469 version Remote Version
470
471 features Remote Features
472
473RETURN VALUE None.
474
475SIDE EFFECTS None
476===========================================================================*/
477void glink_rx_cmd_version
478(
479 glink_transport_if_type *if_ptr,
480 uint32 version,
481 uint32 features
482);
483
484/*===========================================================================
485FUNCTION glink_rx_cmd_version_ack
486
487DESCRIPTION Receive ACK to previous glink_transport_if::tx_cmd_version
488 command
489
490ARGUMENTS *if_ptr Pointer to interface instance; must be unique
491 for each edge
492
493 version Remote Version
494
495 features Remote Features
496
497RETURN VALUE None.
498
499SIDE EFFECTS None
500===========================================================================*/
501void glink_rx_cmd_version_ack
502(
503 glink_transport_if_type *if_ptr,
504 uint32 version,
505 uint32 features
506);
507
508/*===========================================================================
509FUNCTION glink_rx_cmd_ch_remote_open
510
511DESCRIPTION Receive remote channel open request; Calls
512 glink_transport_if:: tx_cmd_ch_remote_open_ack as a result
513
514ARGUMENTS *if_ptr Pointer to interface instance; must be unique
515 for each edge
516
517 rcid Remote Channel ID
518
519 *name String name for logical channel
520
521 prio requested xport priority from remote side
522
523RETURN VALUE None.
524
525SIDE EFFECTS None
526===========================================================================*/
527void glink_rx_cmd_ch_remote_open
528(
529 glink_transport_if_type *if_ptr,
530 uint32 rcid,
531 const char *name,
532 glink_xport_priority prio
533);
534
535/*===========================================================================
536FUNCTION glink_rx_cmd_ch_open_ack
537
538DESCRIPTION This function is invoked by the transport in response to
539 glink_transport_if:: tx_cmd_ch_open
540
541ARGUMENTS *if_ptr Pointer to interface instance; must be unique
542 for each edge
543
544 lcid Local Channel ID
545
546 prio Negotiated xport priority obtained from remote side
547 after negotiation happened on remote side
548
549RETURN VALUE None.
550
551SIDE EFFECTS None
552===========================================================================*/
553void glink_rx_cmd_ch_open_ack
554(
555 glink_transport_if_type *if_ptr,
556 uint32 lcid,
557 glink_xport_priority prio
558);
559
560/*===========================================================================
561FUNCTION glink_rx_cmd_ch_close_ack
562
563DESCRIPTION This function is invoked by the transport in response to
564 glink_transport_if_type:: tx_cmd_ch_close
565
566ARGUMENTS *if_ptr Pointer to interface instance; must be unique
567 for each edge
568
569 lcid Local Channel ID
570
571RETURN VALUE None.
572
573SIDE EFFECTS None
574===========================================================================*/
575void glink_rx_cmd_ch_close_ack
576(
577 glink_transport_if_type *if_ptr, /* Pointer to the interface instance */
578 uint32 lcid /* Local channel ID */
579);
580
581/*===========================================================================
582FUNCTION glink_rx_cmd_ch_remote_close
583
584DESCRIPTION Remote channel close request; will result in sending
585 glink_transport_if_type:: tx_cmd_ch_remote_close_ack
586
587ARGUMENTS *if_ptr Pointer to interface instance; must be unique
588 for each edge
589
590 rcid Remote Channel ID
591
592RETURN VALUE None.
593
594SIDE EFFECTS None
595===========================================================================*/
596void glink_rx_cmd_ch_remote_close
597(
598 glink_transport_if_type *if_ptr, /* Pointer to the interface instance */
599 uint32 rcid /* Remote channel ID */
600);
601
602/*===========================================================================
Sridhar Parasurambf391322015-01-23 09:29:07 -0800603FUNCTION glink_rx_put_pkt_ctx
604
605DESCRIPTION Transport invokes this call to receive a packet fragment (must
606 have previously received an rx_cmd_rx_data packet)
607
608ARGUMENTS *if_ptr Pointer to interface instance; must be unique
609 for each edge
610
611 rcid Remote Channel ID
612
613 *intent_ptr Pointer to the intent fragment
614
615 complete True if pkt is complete
616
617RETURN VALUE None
618
619SIDE EFFECTS None
620===========================================================================*/
621void glink_rx_put_pkt_ctx
622(
623 glink_transport_if_type *if_ptr, /* Pointer to the interface instance */
624 uint32 rcid, /* Remote channel ID */
625 glink_rx_intent_type *intent_ptr, /* Fragment ptr */
626 boolean complete /* True if pkt is complete */
627);
628
629/*===========================================================================
630FUNCTION glink_rx_cmd_remote_sigs
631
632DESCRIPTION Transport invokes this call to inform GLink of remote side
633 changing its control signals
634
635ARGUMENTS *if_ptr Pointer to interface instance; must be unique
636 for each edge
637
638 rcid Remote Channel ID
639
640 remote_sigs Remote signal state.
641
642RETURN VALUE None.
643
644SIDE EFFECTS None
645===========================================================================*/
646void glink_rx_cmd_remote_sigs
647(
648 glink_transport_if_type *if_ptr, /* Pointer to the interface instance */
649 uint32 rcid, /* Remote channel ID */
650 uint32 remote_sigs /* Remote control signals */
651);
652
653/*===========================================================================
Sridhar Parasuram3b058122015-05-11 16:15:03 -0700654 FUNCTION glinki_add_ch_to_xport
Sridhar Parasurambf391322015-01-23 09:29:07 -0800655===========================================================================*/
Sridhar Parasuram3b058122015-05-11 16:15:03 -0700656/**
657 * Add remote/local channel context to xport open channel queue
658 *
659 * @param[in] if_ptr Pointer to xport if on which channel is to
660 * be opened
Sridhar Parasuram3b058122015-05-11 16:15:03 -0700661 * @param[in] ch_ctx channel context
662 * @param[out] allocated_ch_ctx Pointer to channel context pointer
663 * @param[in] local_open flag to determine if channel is opened
664 * locally or remotely
665 * @param[in] prio negotiated xport priority
666 * (used to send priority via remote_open_ack to
667 * remote side)
668 *
669 * @return pointer to glink_transport_if_type struct
670 *
671 * @sideeffects NONE
672 */
673/*=========================================================================*/
Sridhar Parasurambf391322015-01-23 09:29:07 -0800674glink_err_type glinki_add_ch_to_xport
675(
676 glink_transport_if_type *if_ptr,
Sridhar Parasurambf391322015-01-23 09:29:07 -0800677 glink_channel_ctx_type *ch_ctx,
Sridhar Parasuram3b058122015-05-11 16:15:03 -0700678 glink_channel_ctx_type **allocated_ch_ctx,
Sridhar Parasurambf391322015-01-23 09:29:07 -0800679 unsigned int local_open,
Sridhar Parasuram3b058122015-05-11 16:15:03 -0700680 glink_xport_priority prio
Sridhar Parasurambf391322015-01-23 09:29:07 -0800681);
682
683void glink_mem_log
684(
Sridhar Parasurambf391322015-01-23 09:29:07 -0800685 glink_log_event_type type,
686 const char *msg,
687 const char *xport,
688 const char *remote_ss,
689 uint32 param
690);
691
692/*===========================================================================
693FUNCTION glink_core_setup
694===========================================================================*/
695/**
696
697 Initializes internal core functions based on the transport capabilities.
698
699 @param[in] if_ptr The Pointer to the interface instance.
700
701 @return None.
702
703 @sideeffects None.
704*/
705/*=========================================================================*/
706void glink_core_setup(glink_transport_if_type *if_ptr);
707
708/*===========================================================================
Sridhar Parasuram3b058122015-05-11 16:15:03 -0700709FUNCTION glink_core_get_default_interface
710===========================================================================*/
711/**
712
713 Provides default core interface.
714
715 @return Pointer to the default core interface.
716
717 @sideeffects None.
718*/
719/*=========================================================================*/
720glink_core_if_type* glink_core_get_default_interface(void);
721
722/*===========================================================================
Sridhar Parasurambf391322015-01-23 09:29:07 -0800723FUNCTION glink_core_setup_full_xport
724===========================================================================*/
725/**
726
727 Initializes internal core functions for the full-featured transport.
728
729 @param[in] if_ptr The Pointer to the interface instance.
730
731 @return None.
732
733 @sideeffects None.
734*/
735/*=========================================================================*/
736void glink_core_setup_full_xport(glink_transport_if_type *if_ptr);
737
738/*===========================================================================
739FUNCTION glink_core_setup_intentless_xport
740===========================================================================*/
741/**
742
743 Initializes internal core functions for the intentless transport.
744
745 @param[in] if_ptr The Pointer to the interface instance.
746
747 @return None.
748
749 @sideeffects None.
750*/
751/*=========================================================================*/
752void glink_core_setup_intentless_xport(glink_transport_if_type *if_ptr);
753
Steven Cahail79783352015-08-20 15:24:04 -0600754/*===========================================================================
Steven Cahail964ff2f2015-08-20 19:01:56 -0600755 FUNCTION glink_core_setup_intent_xport
756===========================================================================*/
757/**
758
759 Initializes internal core functions based on the transport capabilities.
760
761 @param[in] if_ptr The Pointer to the interface instance.
762
763 @return None.
764
765 @sideeffects None.
766*/
767/*=========================================================================*/
768void glink_core_setup_intent_xport(glink_transport_if_type *if_ptr);
769
770/*===========================================================================
Steven Cahail79783352015-08-20 15:24:04 -0600771 FUNCTION glink_core_qos_get_priority
772===========================================================================*/
773/**
774
775 Calculates pinitial priority for QoS request.
776
777 @param[in] if_ptr The Pointer to the interface instance.
778 @param[in] req_rate The requested rate.
779
780 @return Priority.
781
782 @sideeffects None.
783*/
784/*=========================================================================*/
785uint32 glink_core_qos_get_priority(glink_transport_if_type *if_ptr, uint32 req_rate);
786
787/*===========================================================================
Steven Cahail964ff2f2015-08-20 19:01:56 -0600788 FUNCTION glinki_channel_fully_opened
789===========================================================================*/
790/**
791 * Check whether this channel is fully opened or not (local & remote)
792 * This also checks transport status
793 *
794 * @param[in] handle glink channel handle
795 *
796 * @return TRUE, if channel is fully opened
797 * FASLE, otherwise
798 *
799 * @sideeffects NONE
800 */
801/*=========================================================================*/
802boolean glinki_channel_fully_opened
803(
804 glink_handle_type handle
805);
806
807/*===========================================================================
Steven Cahail79783352015-08-20 15:24:04 -0600808 FUNCTION glink_core_qos_cancel
809===========================================================================*/
810/**
811
812 Releases QoS resources.
813
814 @param[in] open_ch_ctx Pointer to the channel context.
815
816 @return None.
817
818 @sideeffects None.
819*/
820/*=========================================================================*/
821void glink_core_qos_cancel(glink_channel_ctx_type *open_ch_ctx);
822
Steven Cahail964ff2f2015-08-20 19:01:56 -0600823/*===========================================================================
824 FUNCTION glinki_register_link_notif_data
825===========================================================================*/
826/**
827 * Register link notification data
828 *
829 * @param[in] link_notif_data parameter for link notif data
830 *
831 * @return NONE
832 *
833 * @sideeffects NONE
834 */
835/*=========================================================================*/
836void glinki_register_link_notif_data
837(
838 glink_link_notif_data_type *link_notif_data
839);
840
841/*===========================================================================
842 FUNCTION glinki_deregister_link_notif_data
843===========================================================================*/
844/**
845 * Deregister link notification data
846 *
847 * @param[in] link_notif_data parameter for link notif data
848 *
849 * @return NONE
850 *
851 * @sideeffects NONE
852 */
853/*=========================================================================*/
854void glinki_deregister_link_notif_data
855(
856 glink_link_notif_data_type *link_notif_data
857);
858
859/*===========================================================================
860 FUNCTION glinki_scan_xports_and_notify
861===========================================================================*/
862/**
863 * Scan xports and notify link up state event
864 *
865 * @param[in] link_notif_data parameter for link notif data
866 *
867 * @return NONE
868 *
869 * @sideeffects NONE
870 */
871/*=========================================================================*/
872void glinki_scan_xports_and_notify
873(
874 glink_link_notif_data_type *link_notif_data
875);
876
877/*===========================================================================
878 FUNCTION glinki_scan_notif_list_and_notify
879===========================================================================*/
880/**
881 * Scan registered link notification list and notify of xport link state change
882 *
883 * @param[in] if_ptr pointer to xport interface
884 * @param[in] state link state to notify
885 *
886 * @return NONE
887 *
888 * @sideeffects NONE
889 */
890/*=========================================================================*/
891void glinki_scan_notif_list_and_notify
892(
893 glink_transport_if_type *if_ptr,
894 glink_link_state_type state
895);
896
897/*===========================================================================
898 FUNCTION glinki_xport_linkup
899===========================================================================*/
900/**
901 * Check whether this transport is in linkup state or not
902 *
903 * @param[in] if_ptr transport interface pointer
904 *
905 * @return TRUE if this xport is in link up state
906 * FALSE otherwise
907 *
908 * @sideeffects NONE
909 */
910/*=========================================================================*/
911boolean glinki_xport_linkup
912(
913 glink_transport_if_type *if_ptr
914);
915
916/*===========================================================================
917 FUNCTION glinki_xports_for_each
918===========================================================================*/
919/**
920 * Scan all the transports in given edge and perform client's function for each
921 * transport
922 *
923 * @param[in] remote_ss name of remote subsystem, NULL string not accepted
924 * @param[in] client_ex_fn client function to perform when desired xport is
925 * found
926 * @param[in] cond1 first condition to use in client_ex_fn
927 * @param[in] cond2 second condition to use in client_ex_fn
928 * @param[out] out value to return in case client wants
929 *
930 * @return None.
931 *
932 * @sideeffects None.
933 */
934/*=========================================================================*/
935void glinki_xports_for_each
936(
937 const char *remote_ss,
938 glink_client_ex_fn client_ex_fn,
939 void *param1,
940 uint32 param2,
941 void **out
942);
943
944/*===========================================================================
945 FUNCTION glinki_xports_find
946===========================================================================*/
947/**
948 * Scan all the transports in given edge and finds transport that satisfy
949 * client's condition
950 *
951 * @param[in] remote_ss name of remote subsystem, NULL string not accepted
952 * @param[in] client_cond_fn client function to check if this transport is
953 * what client is looking for
954 * @param[in] cond1 first condition to use in client_ex_fn
955 * @param[in] cond2 second condition to use in client_ex_fn
956 * @param[out] out value to return in case client wants
957 *
958 * @return pointer to glink_transport_if_type struct
959 * NULL if there isn't any xport matches client's search condition
960 *
961 * @sideeffects None.
962 */
963/*=========================================================================*/
964glink_transport_if_type *glinki_xports_find
965(
966 const char *remote_ss,
967 glink_client_cond_fn client_cond_fn,
968 void *cond1,
969 uint32 cond2,
970 void **out
971);
972
973/*===========================================================================
974 FUNCTION glinki_find_ch_ctx_by_lcid
975===========================================================================*/
976/**
977 * Find channel context by lcid
978 *
979 * @param[in] xport_ctx Pointer to transport private context
980 * @param[in] lcid local channel ID
981 *
982 * @return pointer to glink channel context
983 *
984 * @sideeffects This function needs to be protected by channel_q_cs
985 * Caller is responsible grab/release mutex when calling this
986 */
987/*=========================================================================*/
988glink_channel_ctx_type *glinki_find_ch_ctx_by_lcid
989(
990 glink_core_xport_ctx_type *xport_ctx,
991 uint32 lcid
992);
993
994/*===========================================================================
995 FUNCTION glinki_find_ch_ctx_by_rcid
996===========================================================================*/
997/**
998 * Find channel context by rcid
999 *
1000 * @param[in] xport_ctx Pointer to transport private context
1001 * @param[in] rcid remote channel ID
1002 *
1003 * @return pointer to glink channel context
1004 *
1005 * @sideeffects This function needs to be protected by channel_q_cs
1006 * Caller is responsible grab/release mutex when calling this
1007 */
1008/*=========================================================================*/
1009glink_channel_ctx_type *glinki_find_ch_ctx_by_rcid
1010(
1011 glink_core_xport_ctx_type *xport_ctx,
1012 uint32 rcid
1013);
1014
1015/*===========================================================================
1016 FUNCTION glinki_find_ch_ctx_by_name
1017===========================================================================*/
1018/**
Steven Cahail338e2f22015-08-24 15:11:53 -06001019 * Find channel context by channel name, called by local/remote open function
1020 * This function will also indicate (valid_open_call) if this open call would
1021 * be valid or not
Steven Cahail964ff2f2015-08-20 19:01:56 -06001022 *
1023 * @param[in] xport_ctx Pointer to transport private context
1024 * @param[in] ch_name channel name
Steven Cahail338e2f22015-08-24 15:11:53 -06001025 * @param[in] local_open flag to indicate this is local open call
1026 * @param[out] valid_open_call tell whether this open call would be valid
1027 * or not
Steven Cahail964ff2f2015-08-20 19:01:56 -06001028 *
1029 * @return pointer to glink channel context
1030 * NULL if channel doesn't exist
1031 *
1032 * @sideeffects This function needs to be protected by channel_q_cs
1033 * Caller is responsible grab/release mutex when calling this
1034 */
1035/*=========================================================================*/
1036glink_channel_ctx_type *glinki_find_ch_ctx_by_name
1037(
1038 glink_core_xport_ctx_type *xport_ctx,
Steven Cahail338e2f22015-08-24 15:11:53 -06001039 const char *ch_name,
1040 boolean local_open,
1041 boolean *valid_open_call
Steven Cahail964ff2f2015-08-20 19:01:56 -06001042);
1043
1044/*===========================================================================
1045 FUNCTION glinki_find_remote_host
1046===========================================================================*/
1047/**
1048 * return remote subsystem ID based on remote subsystem name
1049 *
1050 * @param[in] remote_ss remote subsystem name
1051 *
1052 * @return remote subsystem ID
1053 *
1054 * @sideeffects None.
1055 */
1056/*=========================================================================*/
1057uint32 glinki_find_remote_host
1058(
1059 const char *remote_ss
1060);
1061
1062/*===========================================================================
1063 FUNCTION glink_get_best_xport
1064===========================================================================*/
1065/**
1066 * This function gives best available transport for give edge
1067 *
1068 * @param[in] remote_ss Name of remote subsystem
1069 *
1070 * @return pointer to glink_transport_if_type
1071 *
1072 * @sideeffects NONE
1073 */
1074/*=========================================================================*/
1075glink_transport_if_type *glinki_find_best_xport
1076(
1077 const char *remote_ss
1078);
1079
1080/*===========================================================================
1081 FUNCTION glinki_find_requested_xport
1082===========================================================================*/
1083/**
1084 * Find requested or best transport depending on client's request
1085 *
1086 * @param[in] xport_name name of transport
1087 * @param[in] remote_ss remote subsystem name
1088 * @param[in] open_ch_option option client gave when called glink_open
1089 * @param[out] suggested_priority best xport priority glink suggests
1090 *
1091 * @return pointer to glink_transport_if_type struct
1092 *
1093 * @sideeffects NONE
1094 */
1095/*=========================================================================*/
1096glink_transport_if_type *glinki_find_requested_xport
1097(
1098 const char *xport_name,
1099 const char *remote_ss,
1100 uint32 open_ch_option,
1101 glink_xport_priority *suggested_priority
1102);
1103
1104/*===========================================================================
1105 FUNCTION glinki_find_xport_by_priority
1106===========================================================================*/
1107/**
1108 * This function returns glink_transport_if pointer based on transport priority
1109 *
1110 * @param[in] prio glink xport prio
1111 * @param[in] remote_ss remote subsytem name
1112 *
1113 * @return pointer to glink_transport_if_type struct
1114 *
1115 * @sideeffects NONE
1116 */
1117/*=========================================================================*/
1118glink_transport_if_type *glinki_find_xport_by_priority
1119(
1120 glink_xport_priority prio,
1121 const char *remote_ss
1122);
1123
1124/*===========================================================================
1125 FUNCTION glinki_enqueue_item
1126===========================================================================*/
1127/**
1128 * Enqueue item to smem list in protected context
1129 *
1130 * @param[in] smem_list smem list to enqueue
1131 * @param[in] item item to enqueue
1132 * @param[in] cs mutex to protect the list
1133 *
1134 * @return None.
1135 *
1136 * @sideeffects None.
1137 */
1138/*=========================================================================*/
1139void glinki_enqueue_item
1140(
1141 smem_list_type *smem_list_ptr,
1142 void *item,
1143 os_cs_type *cs
1144);
1145
1146/*===========================================================================
1147 FUNCTION glinki_dequeue_item
1148===========================================================================*/
1149/**
1150 * Dequeue item from smem list in protected context
1151 *
1152 * @param[in] smem_list smem list to dequeue from
1153 * @param[in] item item to dequeue
1154 * @param[in] cs mutex to protect the list
1155 *
1156 * @return None.
1157 *
1158 * @sideeffects None.
1159 */
1160/*=========================================================================*/
1161void glinki_dequeue_item
1162(
1163 smem_list_type *smem_list_ptr,
1164 void *item,
1165 os_cs_type *cs
1166);
1167
Steven Cahailb850bb62015-08-21 14:39:38 -06001168/*===========================================================================
1169 FUNCTION glinki_update_logging_filter
1170===========================================================================*/
1171/**
1172 * Update/Reset the logging filter if the name and remote host of the
1173 * logging filter matches to that of the passed channel context
1174 *
1175 * @param[in] chnl_ctx Channel content to match/compare
1176 * @param[in] reset Indicate Update(FALSE) or Reset(TRUE)
1177 *
1178 * @return None.
1179 */
1180/*=========================================================================*/
1181void glinki_update_logging_filter
1182(
1183 glink_channel_ctx_type *chnl_ctx,
1184 boolean reset
1185);
1186
Steven Cahail8ff053d2015-08-25 09:32:12 -06001187/*===========================================================================
1188 FUNCTION glinki_acquire_edge_lock
1189===========================================================================*/
1190/**
1191 * Acquires the transport_q_cs lock for the specified edge
1192 *
1193 * @param[in] remote_ss Name of the remote sub system on the edge
1194 *
1195 * @return None.
1196 *
1197 * @sideeffects None.
1198 */
1199/*=========================================================================*/
1200void glinki_acquire_edge_lock(const char *ss_name);
1201
1202/*===========================================================================
1203 FUNCTION glinki_release_edge_lock
1204===========================================================================*/
1205/**
1206 * Releases the transport_q_cs lock for the specified edge
1207 *
1208 * @param[in] remote_ss Name of the remote sub system on the edge
1209 *
1210 * @return None.
1211 *
1212 * @sideeffects None.
1213 */
1214/*=========================================================================*/
1215void glinki_release_edge_lock(const char *ss_name);
1216
Steven Cahail964ff2f2015-08-20 19:01:56 -06001217#ifdef FEATURE_TRACER_PACKET
1218/*===========================================================================
1219FUNCTION glink_tracer_packet_log_pctx_pkt
1220===========================================================================*/
1221/**
1222 * Log tracer packet event. Tracer packet is included in glink_core_tx_pkt
1223 * and needs to use vprovider to extract it
1224 *
1225 * @param[in] pctx pointer to glink_core_tx_pkt_type
1226 * @param[in] event_id event_id
1227 *
1228 * @return None
1229 *
1230 * @sideeffects None
1231 */
1232/*=========================================================================*/
1233void glink_tracer_packet_log_pctx_pkt
1234(
1235 glink_core_tx_pkt_type *pctx,
1236 uint32 event_id
1237);
1238#endif
1239
Sridhar Parasurambf391322015-01-23 09:29:07 -08001240#endif /* GLINK_INTERNAL_H */