glink.txt 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239
  1. Introduction
  2. ============
  3. G-Link, short for Generic Link, is a generic link-layer transport that supports
  4. a plug-in framework for physical transports. This allows it to adapt to
  5. different physical transports such as shared memory, UARTs, buses, and DMA.
  6. It is designed to enable zero copy, is power aware, and supports version and
  7. feature negotiation to enable phased upgrades. The design is symmetrical with
  8. the same high-level design and the same client API across all subsystems
  9. regardless of OS.
  10. Hardware description
  11. ====================
  12. The hardware is managed by the transport plug-in. In the initial
  13. driver version, this is done by the SMEM Native Transport which requires
  14. shared memory and an interrupt in each direction between the local and remote
  15. subsystems. This transport is a replacement for SMD.
  16. Software description
  17. =================================
  18. G-Link consists of:
  19. * Client API
  20. * Core that implements the high-level protocol
  21. * Transport plug-ins that handle translation of the high-level protocol to wire
  22. format
  23. The below diagram shows the organization of G-Link. Clients use G-Link to
  24. interface with the Transport Plug-in, which interfaces directly with the
  25. physical transport. The G-Link component is shown in further detail in the
  26. "Design" section.
  27. +-----------+ +---------+ +-----------+
  28. | G-Link |---->|Transport|----->| Physical |
  29. | |<----| Plug-in |<-----| Transport |
  30. +-----------+ +---------+ +-----------+
  31. Design
  32. ======
  33. G-Link is conceptually broken down into a command and data queue. The command
  34. queue is used to pass commands for synchronizing buffer status, channel state,
  35. and for the equivalent of packet headers. The data queue is reserved for raw
  36. client data.
  37. For every packet in the data queue, there is at least one command
  38. that acts as the packet header that goes through the command queue. This
  39. separation is necessary to support the zero-copy use case for data packets and
  40. for DMA-type transports that need to have the transfer size known ahead of time.
  41. For copy-based transports, the command and data transports can be merged
  42. together in the transport plug-in resulting in traditional packet headers like
  43. we have today in other common protocols such as IP.
  44. As shown in the diagram below, the client itself communicates directly with the
  45. G-Link core, and uses the Transport Interface and the G-Link Core interface to
  46. create the transport plug-in.
  47. +-----------+
  48. +------+ +---------+ | |
  49. | |<---|Transport|-| |
  50. +-------+ | | | IF | | |
  51. |Clients|<-->| | +---------+ | Transport |
  52. +-------+ |G-Link| | Plug-in |
  53. | Core | | |
  54. | | +-------+ | |
  55. | |-|G-Link |----->| |
  56. | | |Core IF| | |
  57. +------+ +-------+ | |
  58. +-----------+
  59. A channel is a discrete data pipe used by a client to communicate with a
  60. remote system. All channels are multiplexed onto one or more physical
  61. transports.
  62. A receive intent is queued by a client to indicate that it is ready to receive
  63. a packet up to the specified size. The intent is sent to the remote side to
  64. let clients know that they can transmit and expect the client to be able to
  65. process it.
  66. Intents provide back-pressure to transmitting clients and remove the
  67. requirement for flow control. In addition, the intent size is used for
  68. copy-based transports to either reserve buffer space or allocate buffers to
  69. receive data to prevent blocking the underlying transport. Multiple intents
  70. can be queued.
  71. Transport Plug-in
  72. -----------------
  73. The transport plug-in is responsible for marshaling data and commands between
  74. the G-Link core and the physical transport. If the remote side is not running
  75. G-Link, then the transport plug-in will be more complex and will handle
  76. translating G-Link core commands and data into the proper protocol to
  77. interact with the remote system.
  78. Client API
  79. ----------
  80. The API into the G-Link core is asynchronous by default, but may have blocking
  81. variants. If necessary, a thin client layer can be built on top of the
  82. asynchronous API to create a synchronous API for clients. All client
  83. notifications are serialized to ensure in-order notification of events.
  84. The G-Link client API includes the following functions for the following
  85. operations. Details of each function are described later in this section.
  86. * glink_open() - Open a G-Link channel
  87. * glink_close() - Close a G-Link channel
  88. * glink_tx() - Transmit data
  89. * glink_txv() - Transmit a buffer chain
  90. * glink_queue_rx_intent() - Queue a receive intent
  91. * glink_rx_done() - Signal consumption of the receive buffer
  92. * glink_sigs_set() - Set a 32-bit signal field for client-specific signaling.
  93. Standard TIOCM bits are reserved in the upper bits of the
  94. field as a conviencence for users, but they are 100
  95. percent pass-through.
  96. * glink_sigs_local_get() - Get the local 32-bit control signal field
  97. * glink_sigs_remote_get() - Get the remote 32-bit control signal field
  98. The TIOCM bitmasks are defined as follows:
  99. #define SMD_CTR_SIG_SHFT 31
  100. #define SMD_CTS_SIG_SHFT 30
  101. #define SMD_CD_SIG_SHFT 29
  102. #define SMD_RI_SIG_SHFT 28
  103. When a channel is opened by a client, the client provides an open
  104. configuration to the G-Link core as a parameter to the glink_open() function.
  105. This open configuration contains the following information:
  106. * The name of the transport (optional)
  107. * The name of the edge (remote processor)
  108. * The name of the channel
  109. The open configuration also contains function pointers for the following
  110. operations, which are defined by the client:
  111. * notify_rx() - Notify the client that data has been received
  112. * notify_rxv() - Notify the client that vector data has been received
  113. * notify_tx_done() - Notify the client that data has been transmitted
  114. * notify_state() - Notify the client that the channel's state has changed
  115. * notify_rx_intent_req() - Notify the client whether their request for a
  116. receive intent was granted
  117. * notify_rx_sigs() - Notify the client that there has been a change in the
  118. state of the remote side's control signals
  119. * notify_rx_abort() - During channel close, return structures associated
  120. with receive intents to the client
  121. * notify_tx_abort() - During channel close, return structures associated
  122. with TX packets to the client
  123. * notify_rx_tracer_pkt() - Notify the client that a tracer packet has been
  124. received
  125. Buffer ownership is transferred between the local G-Link and the remote G-Link
  126. using message passing. A typical transmit sequence is as follows:
  127. 1. The remote side queues an RX intent. When the remote client queues the
  128. intent by calling glink_queue_rx_intent(), the ownership of the buffer
  129. transfers to the remote G-Link core, which notifies the local G-Link core
  130. of the receive intent. The remote G-Link core is now ready to receive data
  131. from the local client. In the zero-copy case, the remote G-Link core does
  132. not need to allocate a buffer.
  133. +------+ +------+ +------+
  134. |Local | |Remote| |Remote|
  135. |G-Link| |G-Link| |Client|
  136. +------+ +------+ +------+
  137. | | |
  138. | | glink_queue_rx_intent()|
  139. | +-+<---------------------+-+
  140. | |-| |-|
  141. | |-|(allocate/reserve |-|
  142. | |-| buffer) |-|
  143. | |-|-----+ |-|
  144. | |-| | |-|
  145. | |-|<----+ |-|
  146. | +-+ +-+
  147. | send_intent() | |
  148. |<--------------------------+ |
  149. | | |
  150. | (signal) | |
  151. +-+<-------------------------| |
  152. |-| | |
  153. |-| | |
  154. |-| | |
  155. +-+ | |
  156. | | |
  157. +------+ +------+ +------+
  158. |Local | |Remote| |Remote|
  159. |G-Link| |G-Link| |Client|
  160. +------+ +------+ +------+
  161. 2. The local client can allocate a buffer, fill it, and send it to the remote
  162. side. If multiple receive intents are available, then a first-fit
  163. algorithm is used to select the receive intent.
  164. +------+ +------+ +------+ +------+
  165. |Local | |Local | |Remote| |Remote|
  166. |Client| |G-Link| |G-Link| |Client|
  167. +------+ +------+ +------+ +------+
  168. | | | |
  169. | (Allocate tx buffer) | | |
  170. +-+--------+ | | |
  171. |-| | | | |
  172. |-|<-------+ | | |
  173. |-| | | |
  174. |-| (Copy data into | | |
  175. |-| tx buffer) | | |
  176. |-|--------+ | | |
  177. |-| | | | |
  178. |-|<-------+ | | |
  179. |-| | | |
  180. |-| glink_tx() | | |
  181. |-|------------------->+-+ tx() | |
  182. |-| |-|---------->+-+ notify_rx() |
  183. |-| |-| |-|------------>+-+
  184. +-+ |-| (signal) |-| |-|
  185. | |-|---------->|-| |-|
  186. | +-+ |-| |-|
  187. | | +-+ |-|
  188. | | | +-+
  189. | | | |
  190. +------+ +------+ +------+ +------+
  191. |Local | |Local | |Remote| |Remote|
  192. |Client| |G-Link| |G-Link| |Client|
  193. +------+ +------+ +------+ +------+
  194. 3. The transmit buffer ownership is returned to the local client after the
  195. remote client has finished with it. At this point, the local client can
  196. destroy/reuse the buffer.
  197. +------+ +------+ +------+ +------+
  198. |Local | |Local | |Remote| |Remote|
  199. |Client| |G-Link| |G-Link| |Client|
  200. +------+ +------+ +------+ +------+
  201. | | | |
  202. | | | glink_rx_done() |
  203. | | +-+<----------------+-+
  204. | | |-| |-|
  205. | | |-| (copy-based |-|
  206. | | |-| transport: |-|
  207. | | |-| destroy/reuse |-|
  208. | | |-| buffer) |-|
  209. | | |-|----------+ +-+
  210. | | |-| | |
  211. | | |-| | |
  212. | | |-|<---------+ |
  213. | | tx_done()|-| |
  214. | +-+<----------|-| |
  215. | |-| |-| |
  216. | |-| (signal) |-| |
  217. | notify_tx_done()|-|<----------|-| |
  218. +-+<---------------|-| |-| |
  219. |-| |-| +-+ |
  220. |-| |-| | |
  221. |-| +-+ | |
  222. +-+ | | |
  223. | | | |
  224. +------+ +------+ +------+ +------+
  225. |Local | |Local | |Remote| |Remote|
  226. |Client| |G-Link| |G-Link| |Client|
  227. +------+ +------+ +------+ +------+
  228. Transport Interface
  229. -------------------
  230. The transport interface is used for function calls from the G-Link core to a
  231. G-Link transport. Modules which implement this interface are G-Link
  232. transports. All function calls include the pointer to the transport instance
  233. and the data fields that should be encoded into a command packet to be sent to
  234. the remote processor. These functions act on the transport itself - they
  235. translate the commands into actions for each different transport. This interface
  236. contains APIs for transport negotiation, channel state, channel data, and
  237. power. Requests that change state always have an ACK to synchronize
  238. the state between the local and remote subsystems.
  239. The transport interface is implemented as follows:
  240. struct glink_transport_if {
  241. /* Negotiation */
  242. void (*tx_cmd_version)(struct glink_transport_if *if_ptr,
  243. uint32_t version,
  244. uint32_t features);
  245. void (*tx_cmd_version_ack)(struct glink_transport_if *if_ptr,
  246. uint32_t version,
  247. uint32_t features);
  248. void (*set_version)(struct glink_transport_if *if_ptr, uint32_t version,
  249. uint32_t features);
  250. /* channel state */
  251. int (*tx_cmd_ch_open)(struct glink_transport_if *if_ptr, uint32_t lcid,
  252. const char *name);
  253. int (*tx_cmd_ch_close)(struct glink_transport_if *if_ptr,
  254. uint32_t lcid);
  255. void (*tx_cmd_ch_remote_open_ack)(struct glink_transport_if *if_ptr,
  256. uint32_t rcid);
  257. void (*tx_cmd_ch_remote_close_ack)(struct glink_transport_if *if_ptr,
  258. uint32_t rcid);
  259. int (*ssr)(struct glink_transport_if *if_ptr);
  260. /* channel data */
  261. int (*allocate_rx_intent)(size_t size,
  262. struct glink_core_rx_intent *intent);
  263. int (*deallocate_rx_intent)(struct glink_core_rx_intent *intent);
  264. int (*tx_cmd_local_rx_intent)(struct glink_transport_if *if_ptr,
  265. uint32_t lcid, size_t size, uint32_t liid);
  266. void (*tx_cmd_local_rx_done)(struct glink_transport_if *if_ptr,
  267. uint32_t lcid, uint32_t liid);
  268. int (*tx)(struct glink_transport_if *if_ptr, uint32_t lcid,
  269. struct glink_core_tx_pkt *pctx);
  270. int (*tx_cmd_rx_intent_req)(struct glink_transport_if *if_ptr,
  271. uint32_t lcid, size_t size);
  272. int (*tx_cmd_remote_rx_intent_req_ack)(
  273. struct glink_transport_if *if_ptr,
  274. uint32_t lcid, bool granted);
  275. int (*tx_cmd_set_sigs)(struct glink_transport_if *if_ptr,
  276. uint32_t lcid, uint32_t sigs);
  277. /* Optional. If NULL at xprt registration, dummies will be used */
  278. int (*poll)(struct glink_transport_if *if_ptr, uint32_t lcid);
  279. int (*mask_rx_irq)(struct glink_transport_if *if_ptr, uint32_t lcid,
  280. bool mask, void *pstruct);
  281. int (*wait_link_down)(struct glink_transport_if *if_ptr);
  282. int (*tx_cmd_tracer_pkt)(struct glink_transport_if *if_ptr,
  283. uint32_t lcid, struct glink_core_tx_pkt *pctx);
  284. /* private pointer for core */
  285. struct glink_core_xprt_ctx *glink_core_priv;
  286. /* core pointer (set during transport registration) */
  287. struct glink_core_if *glink_core_if_ptr;
  288. };
  289. G-Link Core Interface
  290. ---------------------
  291. The G-Link Core Interface is used by the transport to call back into G-Link
  292. core for messages or events received from the transport. This interface has
  293. APIs for transport negotiation, power, channel state, and channel data.
  294. Like the transport interface, requests that change state always have an ACK
  295. to synchronize the state between the local and remote subsystems.
  296. The G-Link Core Interface is implemented as follows:
  297. struct glink_core_if {
  298. /* Negotiation */
  299. void (*link_up)(struct glink_transport_if *if_ptr);
  300. void (*rx_cmd_version)(struct glink_transport_if *if_ptr,
  301. uint32_t version,
  302. uint32_t features);
  303. void (*rx_cmd_version_ack)(struct glink_transport_if *if_ptr,
  304. uint32_t version,
  305. uint32_t features);
  306. /* channel management */
  307. void (*rx_cmd_ch_remote_open)(struct glink_transport_if *if_ptr,
  308. uint32_t rcid, const char *name);
  309. void (*rx_cmd_ch_open_ack)(struct glink_transport_if *if_ptr,
  310. uint32_t lcid);
  311. void (*rx_cmd_ch_remote_close)(struct glink_transport_if *if_ptr,
  312. uint32_t rcid);
  313. void (*rx_cmd_ch_close_ack)(struct glink_transport_if *if_ptr,
  314. uint32_t lcid);
  315. void (*ch_state_local_trans)(struct glink_transport_if *if_ptr,
  316. uint32_t lcid,
  317. enum local_channel_state_e new_state);
  318. /* channel data */
  319. struct glink_core_rx_intent *(*rx_get_pkt_ctx)(
  320. struct glink_transport_if *if_ptr,
  321. uint32_t rcid, uint32_t liid);
  322. void (*rx_put_pkt_ctx)(struct glink_transport_if *if_ptr, uint32_t rcid,
  323. struct glink_core_rx_intent *intent_ptr, bool complete);
  324. void (*rx_cmd_remote_rx_intent_put)(struct glink_transport_if *if_ptr,
  325. uint32_t rcid, uint32_t riid, size_t size);
  326. void (*rx_cmd_tx_done)(struct glink_transport_if *if_ptr, uint32_t rcid,
  327. uint32_t riid);
  328. void (*rx_cmd_remote_rx_intent_req)(struct glink_transport_if *if_ptr,
  329. uint32_t rcid, size_t size);
  330. void (*rx_cmd_rx_intent_req_ack)(struct glink_transport_if *if_ptr,
  331. uint32_t rcid, bool granted);
  332. void (*rx_cmd_remote_sigs)(struct glink_transport_if *if_ptr,
  333. uint32_t rcid, uint32_t sigs);
  334. /* channel scheduling */
  335. void (*tx_resume)(struct glink_transport_if *if_ptr);
  336. };
  337. Power Management
  338. ================
  339. Power management has yet to be implemented. See the "To do" section for more
  340. information.
  341. SMP/multi-core
  342. ==============
  343. Locking and synchronization will be done using mutexes or spinlocks where
  344. appropriate.
  345. Security
  346. ========
  347. No known security issues.
  348. Performance
  349. ===========
  350. No known performance issues.
  351. Client Interface
  352. ================
  353. Open
  354. ----
  355. void *glink_open(const struct glink_open_config *cfg)
  356. Opens a logical channel. When this function is called, a notification is sent
  357. to the remote processor. Once the remote processor responds with an open
  358. command, the channel will be opened locally. At this point, the channel is
  359. considered fully open and ready for data operations. The client will be notified
  360. at this point with a GLINK_CONNECTED notification.
  361. When a channel is opened by calling glink_open(), a structure of configuration
  362. information (struct glink_open_config) is passed to it. This includes the name
  363. of the transport, the name of the edge, and the name of the channel, along with
  364. pointers to notification functions:
  365. * notify_rx() - Notify the client that data has been received
  366. * notify_tx_done() - Notify the client that data has been transmitted
  367. * notify_state() - Notify the client that the channel's state has
  368. changed
  369. * notify_rx_intent_req() - Notify the client whether their request for a
  370. receive intent was granted
  371. * notify_rxv() - Receive notification for vector buffers
  372. * notify_rx_sigs() - Notification callback for change in state of remote
  373. side's control signals.
  374. * notify_rx_abort() - During channel close, return structures associated with
  375. receive intents to the client.
  376. * notify_tx_abort() - During channel close, return structures associated with
  377. TX packets to the client.
  378. * notify_rx_tracer_pkt() - Receive notification for tracer packet
  379. This structure is copied internally during the glink_open() call. The full
  380. definition of the structure is below:
  381. struct glink_open_config {
  382. unsigned options;
  383. const char *transport;
  384. const char *edge;
  385. const char *name;
  386. struct glink_ch_ctx (*notify_rx)(void *handle, const void *priv,
  387. const void *pkt_priv, const void *ptr, size_t size);
  388. struct glink_ch_ctx (*notify_tx_done)(void *handle, const void *priv,
  389. const void *pkt_priv, const void *ptr);
  390. struct glink_ch_ctx (*notify_state)(void *handle, const void *priv,
  391. unsigned event);
  392. bool (*notify_rx_intent_req)(void *handle, const void *priv,
  393. size_t req_size);
  394. struct glink_ch_ctx (*notify_rxv)(void *handle, const void *priv,
  395. const void *pkt_priv, void *iovec, size_t size,
  396. void *(*vbuf_provider)(void *iovec, size_t offset,
  397. size_t *size),
  398. void *(*pbuf_provider)(void *iovec, size_t offset,
  399. size_t *size));
  400. struct glink_ch_ctx (*notify_rx_sigs)(void *handle, const void *priv,
  401. uint32_t old_sigs, uint32_t new_sigs);
  402. struct glink_ch_ctx (*notify_rx_abort)(void *handle, const void *priv,
  403. const void *pkt_priv);
  404. struct glink_ch_ctx (*notify_tx_abort)(void *handle, const void *priv,
  405. const void *pkt_priv);
  406. struct glink_ch_ctx (*notify_rx_tracer_pkt)(void *handle,
  407. const void *priv, const void *pkt_priv, const void *ptr,
  408. size_t size);
  409. };
  410. The following are the possible event notification values. The GLINK_CONNECTED
  411. notification is sent using the notify_state() callback once the channel has
  412. been fully opened. See the Close section for the closing state details.
  413. enum {
  414. GLINK_CONNECTED,
  415. GLINK_LOCAL_DISCONNECTED,
  416. GLINK_REMOTE_DISCONNECTED,
  417. };
  418. glink_open() returns the following standard error codes:
  419. * ERR_PTR(-EINVAL) - The glink_open_config structure which was passed to
  420. glink_open() is invalid.
  421. * ERR_PTR(-ENODEV) - No transport is available.
  422. * ERR_PTR(-EBUSY) - The requested channel is not ready to be re-opened.
  423. Close
  424. -----
  425. int glink_close (void *handle)
  426. Closes the logical channel. Once the close request has been processed by the
  427. remote processor, the GLINK_LOCAL_DISCONNECTED notification is sent to the
  428. client. If the remote processor closes the channel first, then the
  429. GLINK_REMOTE_DISCONNECTED notification is sent to the client. After the
  430. GLINK_LOCAL_DISCONNECTED notification is sent, no additional activity will occur
  431. on the channel, regardless of whether the GLINK_REMOTE_DISCONNECTED notification
  432. was sent or not. At this point, it's safe for the callbacks and/or their
  433. resources to be destroyed. If the client wishes to re-establish communication
  434. on the channel, then the client will need to re-open the channel.
  435. glink_close() returns the following standard error codes:
  436. * -EINVAL - The channel to be closed is NULL.
  437. * -EBUSY - The channel to be closed is already closing.
  438. If the channel to be closed is already closed, 0 is returned.
  439. Transmit Data
  440. -------------
  441. int glink_tx(void *handle, void *pkt_priv, void *data, size_t size,
  442. bool req_intent)
  443. Arguments:
  444. handle: The handle returned by glink_open()
  445. pkt_priv: Opaque data value that will be returned to client with the
  446. notify_tx_done() notification
  447. data: Pointer to the data being sent
  448. size: Size of the data being sent
  449. req_intent: Boolean indicating whether or not to request an intent from the
  450. remote channel
  451. Transmit data packet for a matching RX Intent.
  452. If a client would like to transmit a packet, but a suitable RX Intent has not
  453. been queued, the client can request that glink_tx() block and request a
  454. receive intent from the remote system. The remote system can still deny the
  455. request at which point glink_tx() will return -EAGAIN to the client. The call
  456. sequence for this exchange is:
  457. 1. Client wants to transmit a packet, and sets the req_intent flag to true in
  458. the call to glink_tx() in order to request an intent if one is not already
  459. available.
  460. 3. Remote G-Link calls its client's notify_rx_intent_req() function and that
  461. client returns a boolean indicating whether the intent will be granted or
  462. not
  463. 4. If the client grants the remote intent request, glink_tx() receives the
  464. intent and returns success
  465. 5. If the client rejects the remote intent request, glink_tx() returns an error
  466. int glink_txv(void *handle, void* pkt_priv, const void *iovec, size_t size,
  467. glink_buffer_provider_fn vbuff_provider,
  468. glink_buffer_proivder_fn pbuff_provider,
  469. bool req_intent)
  470. Arguments:
  471. handle: The handle returned by glink_open()
  472. pkt_priv: Opaque data value that will be returned to client with the
  473. notify_tx_done() notification
  474. iovec: Pointer to the vector
  475. size: Size of the data being sent
  476. vbuf_provider: Client-provided helper function to iterate the vector in
  477. virtual address space
  478. pbuf_provider: Client-provided helper function to iterate the vector in
  479. physical address space
  480. req_intent: Boolean indicating whether or not to request an intent from the
  481. remote channel
  482. glink_txv() provides a transmit function that accommodates clients using vector
  483. buffer implementations (DSM, SKB, etc.), and allows transports to operate on
  484. virtual or physical address mappings when necessary. This is done through the
  485. vbuf_provider() and pbuf_provider() functions, which are defined by the client
  486. and return a pointer to the contiguous vector data after iteration. After
  487. assembling the data from the vector, the call sequence is the same as
  488. glink_tx().
  489. Queue Receive Intent
  490. --------------------
  491. int glink_queue_rx_intent(void *handle, const void *pkt_priv, size_t size)
  492. Queues a receive intent. A receive intent indicates that the client is ready to
  493. receive a packet up to the specified size. The transport interface will either
  494. reserve space for this packet or allocate a buffer to receive this packet such
  495. that the packet can be received without stalling the physical transport.
  496. The pkt_priv parameter is an opaque value provided by the client that is
  497. returned in the notify_rx() callback.
  498. Signal Consumption of Receive Buffer
  499. ------------------------------------
  500. int glink_rx_done(void *handle, const void *ptr)
  501. This function is called by the client to signal that they are done with the
  502. receive buffer. The remote client is notified that it now owns the buffer again.
  503. Set Control Signal Field
  504. ------------------------
  505. glink_sigs_set(void *handle, uint32 *sig_value)
  506. This function is called by the client to set a 32-bit control signal field.
  507. Depending on the transport, it may take appropriate actions on the set bit-mask,
  508. or transmit the entire 32-bit value to the remote host.
  509. Get Local Control Signal Field
  510. ------------------------------
  511. glink_sigs_local_get(void *handle, uint32 *sig_value)
  512. This function is called by the client to retrieve the cached signals sent
  513. using glink_sigs_set().
  514. Get Remote Control Signal Field
  515. -------------------------------
  516. glink_sigs_remote_get(void *handle, uint32 *sig_value)
  517. This function is called by the client to retrieve the cached remote signals
  518. that were passed to notify_rx_sigs().
  519. Register a Transport
  520. --------------------
  521. int glink_core_register_transport(struct glink_transport_if *if_ptr,
  522. struct glink_core_transport_cfg *cfg)
  523. Register a new transport with the G-Link Core. The if_ptr parameter is the
  524. interface to the transport, and the cfg parameter is the configuration, which
  525. contains the following information:
  526. * The name of the transport
  527. * The edge of the transport, i.e. remote processor name
  528. * An array of the transport versions supported
  529. * The maximum number of entries in the versions array
  530. * The maximum number of channel identifiers supported
  531. * The maximum number of intent identifiers supported
  532. The implementation of this transport configuration structure is below.
  533. struct glink_core_transport_cfg {
  534. const char *name;
  535. const char *edge;
  536. const struct glink_core_version *versions;
  537. size_t versions_count;
  538. uint32_t max_cid;
  539. uint32_t max_iid;
  540. };
  541. The initial state of a transport after it is registered is GLINK_XPRT_DOWN.
  542. The possible states of a transport are as follows:
  543. enum transport_state_e {
  544. GLINK_XPRT_DOWN,
  545. GLINK_XPRT_NEGOTIATING,
  546. GLINK_XPRT_OPENED,
  547. GLINK_XPRT_FAILED,
  548. }
  549. Unregister a Transport
  550. ----------------------
  551. void glink_core_unregister_transport(struct glink_transport_if *if_ptr)
  552. Unregister/destroy an existing transport. The transport's state is changed to
  553. GLINK_XPRT_DOWN, and the following values are reset:
  554. * the next local channel ID
  555. * The local version index
  556. * The remote version index
  557. * The version negotiation completion flag
  558. * The list of channels on the transport (list is deleted)
  559. Driver parameters
  560. =================
  561. The G-Link core and G-Link Loopback Server modules both have a module parameter
  562. called "debug_mask". The possible values are detailed in the "Config options"
  563. section.
  564. Config options
  565. ==============
  566. G-Link supports several logging configurations. The following options are
  567. available for the core and loopback client. They can be bitwise OR'ed together
  568. to have multiple options at once.
  569. QCOM_GLINK_INFO - The default option. Turn on only INFO messages
  570. QCOM_GLINK_DEBUG - Turn on debug log messages - much more verbose logging to
  571. aid in debugging.
  572. QCOM_GLINK_PERF - Performance logging. This removes all other logging except
  573. for logging messages that are created through a special
  574. set of macros. These logs can be post-processed for
  575. performance metrics.
  576. The values of these options are as follows:
  577. enum {
  578. QCOM_GLINK_INFO = 1U << 0,
  579. QCOM_GLINK_DEBUG = 1U << 1,
  580. QCOM_GLINK_PERF = 1U << 2,
  581. };
  582. Dependencies
  583. ============
  584. IPC Logging is a dependency of the G-Link core. The Transport Plug-ins will have
  585. their own dependencies. The SMEM Native Transport depends on SMEM and the
  586. interrupt subsystem.
  587. DebugFS
  588. =======
  589. Several DebugFS nodes are exported under the glink directory for testing and
  590. debugging. The directory structure below allows listing information by
  591. subsystem, channel, and transport.
  592. glink Directory
  593. ---------------
  594. `-- debugfs
  595. `-- glink
  596. |-- channel
  597. | |-- channels <- lists all of the channels in the system, their
  598. | | state, the transport they are assigned to, etc.
  599. | |-- SUBSYSTEM_NAME <- directory (such as "mpss")
  600. | | `-- CHANNEL_NAME <- one directory per channel
  601. | | |-- intents <- list of all open intents, their size, and
  602. | | | their ID
  603. | | `-- stats <- statistics for the channel (contents TBD)
  604. `-- xprt
  605. |-- xprts <- lists all of the transports in the system and basic
  606. | transport-specific state
  607. |-- XPRT_NAME <-- directory (such as "smem")
  608. `-- XPRT_INFO <-- transport specific files
  609. User space utilities
  610. ====================
  611. A user space driver is provided which can export a character device for a single
  612. channel based upon Device Tree configuration. The full DT schema is detailed in
  613. Documentation/devicetree/bindings/arm/msm/glinkpkt.txt. The user space driver
  614. implements the standard file operations of open, release, read, write, poll, and
  615. mmap. An ioctl is defined to queue RX intents.
  616. The file operations map to the G-Link Client API as follows:
  617. open() -> glink_open() (Open a channel. Exported channels configured
  618. through DT)
  619. write() -> glink_tx() (Transmit data)
  620. read() -> Receive data and send RX done notification (glink_rx_done())
  621. release() -> glink_close() (Close a channel)
  622. ioctl() -> glink_queue_rx_intent()
  623. Other operations are:
  624. poll() -> Poll waiting for the channel to become available
  625. mmap() -> Prevent having to do a copy between kernel space and user space
  626. for clients that need that performance.
  627. A typical transmit and receive call flow is as follows:
  628. 1. G-Link user space driver opens the channel using open(), which returns a
  629. file descriptor for the channel
  630. 2. An ioctl is sent to queue an RX intent on the channel
  631. 3. Data is transmitted on the channel using write()
  632. 4. The data is received using read(). read() also sends an RX done
  633. notification.
  634. Version/Feature Negotiation
  635. ===========================
  636. To enable upgrading transports, G-Link supports a version number and feature
  637. flags for each transport. The combination of the version number and feature
  638. flags enable:
  639. 1. G-Link software updates to be rolled out to each processor
  640. separately.
  641. 2. Individual features to be enabled or disabled on an edge-by-edge
  642. basis.
  643. Endpoints negotiate both the version and the feature flags when the transport
  644. is opened; they cannot be changed after negotiation has been completed.
  645. The version number represents any change in G-Link or the transport that
  646. breaks compatibility between processors. Examples would be a change in the
  647. shared data structures or changes to fundamental behavior in either the
  648. transport or in G-Link Core. Each full implementation of G-Link must support a
  649. minimum of the current version, the previous version, and the base negotiation
  650. version called v0. For resource-constrained devices, this can be relaxed to
  651. only support the latest version of the protocol and the v0 version.
  652. The feature flags represent any changes in G-Link that are optional and
  653. backwards-compatible. Feature flags can be version-specific, but to limit code
  654. maintenance and documentation overhead, feature flags should not be re-used
  655. unless the limit of 32 feature flags has been reached.
  656. Negotiation Algorithm
  657. ---------------------
  658. After a transport is registered with G-Link core, it should be configured with
  659. the v0 transport settings. Once communication can be done without losing
  660. messages, the link_up() call in the G-Link core should be made to start the
  661. negotiation process. Both the local and remote sides will follow the same
  662. negotiation state machines.
  663. Since both sides follow the same sequence and both sides start once the link is
  664. up, it is possible that both sides may start the negotiation sequence at the
  665. same time resulting in a perceived race condition. However, both negotiation
  666. sequences are independent and the transport is not considered opened until both
  667. negotiation sequences are complete, so this is not a true race condition and
  668. both sides will converge to the same version and feature set even if they
  669. start with different versions and feature sets. Since this sequence is not
  670. performance-critical, the extra complexity in the negotiation algorithm to
  671. short-circuit the process is not deemed necessary.
  672. Local-Initiated Negotiation Sequence
  673. ------------------------------------
  674. The following local negotiation sequence is initiated and followed by each
  675. side. The processor that is running this algorithm will be matched by the
  676. remote processor following the Remote-Initiated Negotiation Sequence.
  677. 1. Set current version and feature variables to the maximum supported version
  678. and feature set
  679. 2. Send Version Command (glink_transport_if::tx_cmd_version()) with local
  680. version and feature set
  681. 3. If version is 0, then negotiation has failed and the transport should be
  682. marked as having failed negotiation and the negotiation sequence
  683. terminated.
  684. 4. When Version ACK is received (glink_core_if::rx_cmd_version_ack()):
  685. a. Compare ACK version to the sent version and:
  686. i. If equal, we are done with version negotiation
  687. ii. Else set current version to the lower of:
  688. 1. Remote version number
  689. 2. Highest supported local version
  690. b. Compare ACK features to the sent features and:
  691. i. If equal, we are done with the negotiation sequence
  692. ii. Else, call glink_core_version:: negotiate_features() for the
  693. current version to set the features to either the bitwise AND of
  694. the ACK features and the locally supported features or a lesser
  695. feature set for cases where only certain combinations of features
  696. are valid.
  697. c. Go back to step 2 to send the updated version/feature set
  698. Remote-Initiated Negotiation Sequence
  699. -------------------------------------
  700. The following remote negotiation sequence is followed by each side based upon
  701. receiving a Version Command.
  702. 1. Receive Version Command (glink_core_if::rx_cmd_version())
  703. 2. Compare received version with the locally supported version and:
  704. a. If equal, set ACK version to the received version
  705. b. Else, set ACK version to the lower of:
  706. i. Remote version number
  707. ii. Highest supported local version
  708. iii. Version 0 if no supported version less than or equal to
  709. the remote version number can be found.
  710. 3. Compare received features with the locally supported features and:
  711. a. If equal, set ACK features to the received features
  712. b. Else, call glink_core_version:: negotiate_features() for the current
  713. version to set the features to either the bitwise AND of the ACK
  714. features and the locally supported features or a lesser feature set
  715. for cases where only certain combinations of features are valid.
  716. 4. Send the Version ACK Command (glink_transport_if::tx_cmd_version_ack()).
  717. Packets
  718. =======
  719. Packets are scheduled in a round-robin fashion from all active channels. Large
  720. packets can be fragmented by the transport to ensure fairness between channels
  721. and ensure latency.
  722. Channel Migration
  723. =================
  724. The G-Link core has the capability of selecting the best transport available on
  725. an edge-by-edge basis. The transport is selected based upon a pre-defined
  726. transport priority and from optional transport selection information passed in
  727. by the client in the glink_open_config structure.
  728. Subsystem Restart (SSR)
  729. =======================
  730. In order to properly clean up channel state and recover buffer ownership
  731. consistently across different physical transports, G-Link requires an
  732. additional SSR notification system on top of the existing SSR framework. The
  733. notification system is a star topology with the application processor as the
  734. master. When a subsystem is restarted, all other subsystems are notified by the
  735. application processor and must respond after cleaning up all affected channels
  736. before the SSR event is allowed to continue.
  737. The solution has four components:
  738. 1. Target-specific configuration for each subsystem, which consists of a list
  739. of which subsystems should be notified in the event of SSR, specified in
  740. Device Tree
  741. 2. SSR module that uses the G-Link Client API to isolate SSR functionality,
  742. and handles calls to the SSR Framework, Device Tree parsing, etc.
  743. 3. SSR notification messages between the application processor and
  744. other subsystems, which will be exchanged using G-Link.
  745. 4. SSR API:
  746. a. glink_ssr(const char *subsystem_name) - G-Link Client API
  747. b. ssr(struct glink_transport_if *if_ptr) - Transport Interface
  748. 1. Target-specific configuration using Device Tree
  749. --------------------------------------------------
  750. The target-specific configuration provides the G-Link SSR module with a list
  751. of subsystems that should be notified in the event of SSR. This is necessary
  752. to simplify handling of cases where there are multiple SoCs in one device -
  753. there is no need to notify a subsystem on a second SoC of a restart in the
  754. first SoC. The configuration also provides a mapping of the subsystem's name
  755. in the SSR framework to its name as a G-Link edge, and allows the specification
  756. of a transport for each notification. The figures below provide an example:
  757. +----+ +------+ +-------------------+
  758. |SSR |----->|G-Link|------->|Subsystem A |
  759. |Name| |Name | |Subsystem B: xprt x|
  760. +----+ +------+ |Subsystem C |
  761. +-------------------+
  762. +-------+ +------+ +--------------+
  763. |"modem"|----->|"mpss"|------->|"wcnss" |
  764. +-------+ +------+ |"lpass": "smd"|
  765. |"dsps" |
  766. +--------------+
  767. The above configuration tells the G-Link SSR module to notify all subsystems
  768. on G-Link edges "wcnss", "lpass", and "dsps" that the subsystem on edge "mpss"
  769. has restarted, and to send the notifications to the "lpass" edge on the "smd"
  770. transport.
  771. 2. G-Link SSR Module (glink_ssr)
  772. --------------------------------
  773. This module is a G-Link client which handles notifications from the SSR
  774. framework on the application processor and triggers local clean-up in response
  775. to these notifications by calling glink_ssr(const char *subsystem). This
  776. module also sends notifications to any subsystems that need to be notified of
  777. the SSR event, and ensures that they respond within the standard timeout (500
  778. ms). If the subsystem fails to respond, it is restarted.
  779. 3. G-Link SSR Messages
  780. ----------------------
  781. When an SSR event occurs, the application processor notifies all necessary
  782. subsystems by sending a "do_cleanup" message. After the subsystem performs the
  783. necessary clean-up, it sends back a "cleanup_done" message. If the
  784. "cleanup_done" message for a given subsystem is not received within the
  785. standard timeout (500 ms), the subsystem is restarted.
  786. SSR "do_cleanup" Message
  787. ------------------------
  788. +-----------------+-----------------------+------------------------------+
  789. | Element | Type | Description |
  790. +=================+=======================+==============================+
  791. | version | uint32_t | G-Link SSR Protocol Version |
  792. +-----------------+-----------------------+------------------------------+
  793. | command | uint32_t | do_cleanup message (0) |
  794. +-----------------+-----------------------+------------------------------+
  795. | sequence_number | uint32_t | Sequence number |
  796. +-----------------+-----------------------+------------------------------+
  797. | name_len | uint32_t | Name length of the subsystem |
  798. | | | being restarted |
  799. +-----------------+-----------------------+------------------------------+
  800. | name | char[GLINK_NAME_SIZE] | NULL-terminated name of the |
  801. | | | subsystem being restarted |
  802. | | | (GLINK_NAME_SIZE == 32) |
  803. +-----------------+-----------------------+------------------------------+
  804. SSR "cleanup_done" Message
  805. --------------------------
  806. +-----------------+-----------------------+------------------------------+
  807. | Element | Type | Description |
  808. +=================+=======================+==============================+
  809. | version | uint32_t | G-Link SSR Protocol Version |
  810. +-----------------+-----------------------+------------------------------+
  811. | response | uint32_t | cleanup_done message (1) |
  812. +-----------------+-----------------------+------------------------------+
  813. | sequence_number | uint32_t | Sequence number |
  814. +-----------------+-----------------------+------------------------------+
  815. G-Link SSR Protocol Sequence Diagram
  816. ------------------------------------
  817. +------+ +------+
  818. +---------+ |G-Link| |G-Link| +----------+
  819. |SSR | |SSR | |Client| +---------+ |Remote |
  820. |Framework| |Module| |API | |Transport| |Processors|
  821. +---------+ +------+ +------+ +---------+ +----------+
  822. | | | | |
  823. | SSR | | | |
  824. | Notification | | | |
  825. +--------------->| | | |
  826. | | | | |
  827. | | | | |
  828. | | | | |
  829. | | do_cleanup | | |
  830. | +------------------------------------------------>|
  831. | | | | |
  832. | | glink_ssr(subsystem) | |
  833. | +------------->| | |
  834. | | | | |
  835. | | | | |
  836. | | | ssr(if_ptr) | |
  837. | | +-------------->| |
  838. | | | | |
  839. | | | | |
  840. | | | | |
  841. | | | | cleanup_done |
  842. | |<------------------------------------------------+
  843. | | | | |
  844. | | | | |
  845. | | | | |
  846. | ssr(subsystem)| | | |
  847. |<---------------+ | | |
  848. | | | | |
  849. | +-----------+---------+ | | |
  850. | |If no cleanup_done | | | |
  851. | |response is received,| | | |
  852. | |restart the subsystem| | | |
  853. | +-----------+---------+ | | |
  854. | | | | |
  855. | | | | |
  856. | | | | |
  857. | | | | |
  858. | | | | |
  859. +---------+ +------+ +------+ +---------+ +----------+
  860. |SSR | |G-Link| |G-Link| |Transport| |Remote |
  861. |Framework| |SSR | |Client| +---------+ |Processors|
  862. +---------+ |Module| |API | +----------+
  863. +------+ +------+
  864. 4. SSR API
  865. ----------
  866. glink_ssr(const char *subsystem_name)
  867. -------------------------------------
  868. Called by the G-Link SSR Module, this function calls into the transport using
  869. ssr(struct glink_transport_if *if_ptr) to allow the transport to perform any
  870. necessary clean-up, and simulates receiving a remote close from the restarting
  871. subsystem for all channels on the affected edge.
  872. ssr(struct glink_transport_if *if_ptr)
  873. --------------------------------------
  874. The ssr() function is part of the Transport Interface, and as mentioned above is
  875. used to perform any necessary clean-up on the transport.
  876. Tracer Packet Framework
  877. =======================
  878. A tracer packet is a special type of packet that can be used to trace the timing
  879. of events. This helps profile the latency experienced by a packet, and provides
  880. granular information regarding the individual latencies that make up the overall
  881. latency. The information obtained using the tracer packet can be used to
  882. configure the Power Management Quality of Service (PM QoS) in the system in
  883. order to achieve a client's desired packet latency. The tracer packet moves
  884. through the system along with other normal traffic without any impact on the
  885. normal traffic.
  886. When a transport is registered with the local G-Link core, it performs a
  887. transport-specific version and feature negotiation with the remote G-Link core.
  888. Based on this negotiation, the transport reports its capability of supporting
  889. tracer packets to the local G-Link core.
  890. Once the transport has successfully completed the negotiation, the clients open
  891. the G-Link channel over the concerned transport. After the channel is open, the
  892. clients can exchange tracer packets over G-Link, in a way similar to normal
  893. traffic.
  894. When a tracer packet is exchanged over a G-Link channel, the G-Link core and the
  895. transport log events related to packet exchange and their time.
  896. 1. Tracer Packet Format
  897. -----------------------
  898. The tracer packet contains a header and a payload. The header contains
  899. identification and configuration information associated with a tracer packet.
  900. The payload contains a series of event logs. The below diagram shows the layout
  901. of the tracer packet:
  902. Tracer Packet Header Layout
  903. ---------------------------
  904. 31 16 15 14 13 12 11 4 3 0
  905. +-------------------------------+-----+---+----+------+---------+
  906. | Packet Length (words) | CCL | Q | ID | Res. | Version |
  907. +-------------------------------+-------------------------------+
  908. | Client Event Cfg. | Packet Offset (words) |
  909. | Bit Mask | |
  910. +-------------------------------+-------------------------------+
  911. | G-Link Event Config Bit Mask |
  912. +---------------------------------------------------------------+
  913. | Base Timestamp (MS 32 bits) |
  914. +---------------------------------------------------------------+
  915. | Base Timestamp (LS 32 bits) |
  916. +---------------------------------------------------------------+
  917. | Client Cookie |
  918. +---------------------------------------------------------------+
  919. Tracer Packet Payload Layout
  920. ----------------------------
  921. 31 16 15 0
  922. +-------------------------------+-------------------------------+
  923. | Reserved | Event 1 ID |
  924. +-------------------------------+-------------------------------+
  925. | Event 1 Timestamp (LS 32 bits) |
  926. +---------------------------------------------------------------+
  927. .
  928. .
  929. .
  930. +-------------------------------+-------------------------------+
  931. | Reserved | Event N ID |
  932. +-------------------------------+-------------------------------+
  933. | Event N Timestamp (LS 32 bits) |
  934. +---------------------------------------------------------------+
  935. Tracer Packet Header Fields
  936. ---------------------------
  937. Version - This field contains the tracer packet version. The current version
  938. of tracer packet supported by G-Link is 1. If a version of the tracer
  939. packet is not supported by G-Link or its transport abstraction layer,
  940. the tracer packet is still exchanged, but no events are logged.
  941. Reserved - The reserved bit fields are set to 0 and can be used for future
  942. extension of tracer packet functionality.
  943. ID - The ID bit field indicates the presence or absence of the Source Processor
  944. ID, Destination Processor ID and Transport ID fields in the tracer
  945. packet. Currently this field is set to 0 and the concerned IDs are not
  946. defined.
  947. CoreSight ("Q" in the diagram above) - This bit field is used to indicate the
  948. location of the log events. If this bit
  949. field is set, the log events are logged
  950. into CoreSight, otherwise the log events
  951. are logged into the packet itself. If the
  952. log events are logged into the packet,
  953. then the number of events logged into the
  954. packet depends on the size of the packet.
  955. CCL - The tracer packet framework allows clients to differentiate multiple
  956. tracer packets through a client-specified cookie. The Client Cookie Length
  957. (CCL) bit field indicates the length of that cookie in units of words.
  958. Packet Length - These 16 bits indicate the length of the tracer packet in units
  959. of words.
  960. Packet Offset - This field is used when events are logged into the packet. This
  961. 16-bit field indicates the offset into the packet, in units of
  962. words, to log an event. Once an event is logged, this field is
  963. updated with the appropriate offset to log future events.
  964. Client Configuration Bit Mask - This bit-mask is used to enable/disable the
  965. G-Link client-specific events. The procedure to
  966. enable/disable client events is dependent upon
  967. the client's implementation and is not included
  968. in this document.
  969. G-Link Configuration Bit Mask - This bit-mask is used to enable/disable the
  970. G-Link-specific events. When a bit is set, the
  971. concerned event logging is enabled.
  972. Base Timestamp - The base timestamp contains the starting time of the tracer
  973. packet exchange. The timestamp logged along with the event is
  974. used as an offset from this base timestamp. This optimization
  975. helps in reducing the log size of an event.
  976. Client Cookie - The tracer packet framework allows clients to differentiate
  977. multiple tracer packets through a client-specified cookie.
  978. Tracer Packet Payload Fields
  979. ----------------------------
  980. Event ID - The Event ID field uniquely identifies the G-Link and client-specific
  981. tracer packet events. This field is present only when the events are
  982. logged into the packet. The G-Link and client event IDs are assigned
  983. a unique range. Refer to the table below for more information
  984. regarding the event ID definition.
  985. Reserved - The reserved field is set to 0 and can be used for future extension
  986. of tracer packet functionality.
  987. Event Timestamp - The Event Timestamp field contains the time at which the event
  988. is logged. This field is used as an offset from the Base
  989. Timestamp field in the header to calculate the actual event
  990. timestamp. This field is present only when the events are
  991. logged into the packet.
  992. 2. Tracer Packet Events
  993. -----------------------
  994. Each event has a uniquely defined ID. Since G-Link clients can use the tracer
  995. packet framework, G-Link events and G-Link client events are defined in mutually
  996. exclusive ranges. Since client events are client-context specific, the event
  997. IDs can be reused among the clients. The ranges are detailed in the table below:
  998. +--------------------------+-----------------------+
  999. | Event Type | Range |
  1000. +==========================+=======================+
  1001. | G-Link | 1-255 |
  1002. +--------------------------+-----------------------+
  1003. | Client | 255 and above |
  1004. +--------------------------+-----------------------+
  1005. The G-Link specific events and their associated IDs are defined in the below
  1006. table:
  1007. +--------------------------+-----------------------+
  1008. | G-Link Event | ID |
  1009. +==========================+=======================+
  1010. | GLINK_CORE_TX | 1 |
  1011. +--------------------------+-----------------------+
  1012. | GLINK_QUEUE_TO_SCHEDULER | 2 |
  1013. +--------------------------+-----------------------+
  1014. | GLINK_SCHEDULER_TX | 3 |
  1015. +--------------------------+-----------------------+
  1016. | GLINK_XPRT_TX | 4 |
  1017. +--------------------------+-----------------------+
  1018. | GLINK_XPRT_RX | 5 |
  1019. +--------------------------+-----------------------+
  1020. | GLINK_CORE_RX | 6 |
  1021. +--------------------------+-----------------------+
  1022. 3. Tracer Packet API
  1023. --------------------
  1024. tracer_pkt_init(void *data, size_t data_len, uint16_t client_event_cfg,
  1025. uint32_t glink_event_cfg, void *pkt_priv, size_t pkt_priv_len)
  1026. --------------------------------------------------------------------------
  1027. Initialize a buffer with the tracer packet header. The tracer packet header
  1028. includes the data passed in the parameters.
  1029. tracer_pkt_set_event_cfg(void *data, uint16_t client_event_cfg,
  1030. uint32_t glink_event_cfg)
  1031. ---------------------------------------------------------------
  1032. Initialize a buffer with the event configuration mask passed in the parameters.
  1033. tracer_pkt_log_event(void *data, uint32_t event_id)
  1034. ---------------------------------------------------
  1035. Log an event specific to the tracer packet. The event is logged either into
  1036. the tracer packet itself or a different tracing mechanism as configured.
  1037. tracer_pkt_calc_hex_dump_size(void *data, size_t data_len)
  1038. ----------------------------------------------------------
  1039. Calculate the length of the buffer required to hold the hex dump of the tracer
  1040. packet.
  1041. tracer_pkt_hex_dump(void *buf, size_t buf_len, void *data, size_t data_len)
  1042. ---------------------------------------------------------------------------
  1043. Dump the contents of the tracer packet into a buffer in a specific hexadecimal
  1044. format. The hex dump buffer can then be dumped through debugfs.
  1045. Known issues
  1046. ============
  1047. No known issues.
  1048. To do
  1049. =====
  1050. Power Management
  1051. ----------------
  1052. An internal power voting API will be defined to bring the transport out of power
  1053. collapse for SMUX and BAM DMUX-type systems. In addition, power for
  1054. request/response type systems can be optimized to prevent powering down
  1055. unnecessarily after sending a request only to power up immediately to process
  1056. the response.
  1057. Round-Robin Scheduling
  1058. ----------------------
  1059. Add deficit round-robin schedule to ensure fairness between channels that have
  1060. a large number of small packets and channels that are sending the maximum
  1061. MTU-sized packets.
  1062. Transport Filter Internal API
  1063. -----------------------------
  1064. An internal transport filter API will be defined. This can be plugged into a
  1065. filter chain at the transport level to easily add data coding, encryption,
  1066. integrity hashes, etc.