linux_caif.rst 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. .. SPDX-License-Identifier: GPL-2.0
  2. .. include:: <isonum.txt>
  3. ==========
  4. Linux CAIF
  5. ==========
  6. Copyright |copy| ST-Ericsson AB 2010
  7. :Author: Sjur Brendeland/ sjur.brandeland@stericsson.com
  8. :License terms: GNU General Public License (GPL) version 2
  9. Introduction
  10. ============
  11. CAIF is a MUX protocol used by ST-Ericsson cellular modems for
  12. communication between Modem and host. The host processes can open virtual AT
  13. channels, initiate GPRS Data connections, Video channels and Utility Channels.
  14. The Utility Channels are general purpose pipes between modem and host.
  15. ST-Ericsson modems support a number of transports between modem
  16. and host. Currently, UART and Loopback are available for Linux.
  17. Architecture
  18. ============
  19. The implementation of CAIF is divided into:
  20. * CAIF Socket Layer and GPRS IP Interface.
  21. * CAIF Core Protocol Implementation
  22. * CAIF Link Layer, implemented as NET devices.
  23. ::
  24. RTNL
  25. !
  26. ! +------+ +------+
  27. ! +------+! +------+!
  28. ! ! IP !! !Socket!!
  29. +-------> !interf!+ ! API !+ <- CAIF Client APIs
  30. ! +------+ +------!
  31. ! ! !
  32. ! +-----------+
  33. ! !
  34. ! +------+ <- CAIF Core Protocol
  35. ! ! CAIF !
  36. ! ! Core !
  37. ! +------+
  38. ! +----------!---------+
  39. ! ! ! !
  40. ! +------+ +-----+ +------+
  41. +--> ! HSI ! ! TTY ! ! USB ! <- Link Layer (Net Devices)
  42. +------+ +-----+ +------+
  43. Implementation
  44. ==============
  45. CAIF Core Protocol Layer
  46. ------------------------
  47. CAIF Core layer implements the CAIF protocol as defined by ST-Ericsson.
  48. It implements the CAIF protocol stack in a layered approach, where
  49. each layer described in the specification is implemented as a separate layer.
  50. The architecture is inspired by the design patterns "Protocol Layer" and
  51. "Protocol Packet".
  52. CAIF structure
  53. ^^^^^^^^^^^^^^
  54. The Core CAIF implementation contains:
  55. - Simple implementation of CAIF.
  56. - Layered architecture (a la Streams), each layer in the CAIF
  57. specification is implemented in a separate c-file.
  58. - Clients must call configuration function to add PHY layer.
  59. - Clients must implement CAIF layer to consume/produce
  60. CAIF payload with receive and transmit functions.
  61. - Clients must call configuration function to add and connect the
  62. Client layer.
  63. - When receiving / transmitting CAIF Packets (cfpkt), ownership is passed
  64. to the called function (except for framing layers' receive function)
  65. Layered Architecture
  66. ====================
  67. The CAIF protocol can be divided into two parts: Support functions and Protocol
  68. Implementation. The support functions include:
  69. - CFPKT CAIF Packet. Implementation of CAIF Protocol Packet. The
  70. CAIF Packet has functions for creating, destroying and adding content
  71. and for adding/extracting header and trailers to protocol packets.
  72. The CAIF Protocol implementation contains:
  73. - CFCNFG CAIF Configuration layer. Configures the CAIF Protocol
  74. Stack and provides a Client interface for adding Link-Layer and
  75. Driver interfaces on top of the CAIF Stack.
  76. - CFCTRL CAIF Control layer. Encodes and Decodes control messages
  77. such as enumeration and channel setup. Also matches request and
  78. response messages.
  79. - CFSERVL General CAIF Service Layer functionality; handles flow
  80. control and remote shutdown requests.
  81. - CFVEI CAIF VEI layer. Handles CAIF AT Channels on VEI (Virtual
  82. External Interface). This layer encodes/decodes VEI frames.
  83. - CFDGML CAIF Datagram layer. Handles CAIF Datagram layer (IP
  84. traffic), encodes/decodes Datagram frames.
  85. - CFMUX CAIF Mux layer. Handles multiplexing between multiple
  86. physical bearers and multiple channels such as VEI, Datagram, etc.
  87. The MUX keeps track of the existing CAIF Channels and
  88. Physical Instances and selects the appropriate instance based
  89. on Channel-Id and Physical-ID.
  90. - CFFRML CAIF Framing layer. Handles Framing i.e. Frame length
  91. and frame checksum.
  92. - CFSERL CAIF Serial layer. Handles concatenation/split of frames
  93. into CAIF Frames with correct length.
  94. ::
  95. +---------+
  96. | Config |
  97. | CFCNFG |
  98. +---------+
  99. !
  100. +---------+ +---------+ +---------+
  101. | AT | | Control | | Datagram|
  102. | CFVEIL | | CFCTRL | | CFDGML |
  103. +---------+ +---------+ +---------+
  104. \_____________!______________/
  105. !
  106. +---------+
  107. | MUX |
  108. | |
  109. +---------+
  110. _____!_____
  111. / \
  112. +---------+ +---------+
  113. | CFFRML | | CFFRML |
  114. | Framing | | Framing |
  115. +---------+ +---------+
  116. ! !
  117. +---------+ +---------+
  118. | | | Serial |
  119. | | | CFSERL |
  120. +---------+ +---------+
  121. In this layered approach the following "rules" apply.
  122. - All layers embed the same structure "struct cflayer"
  123. - A layer does not depend on any other layer's private data.
  124. - Layers are stacked by setting the pointers::
  125. layer->up , layer->dn
  126. - In order to send data upwards, each layer should do::
  127. layer->up->receive(layer->up, packet);
  128. - In order to send data downwards, each layer should do::
  129. layer->dn->transmit(layer->dn, packet);
  130. CAIF Socket and IP interface
  131. ============================
  132. The IP interface and CAIF socket API are implemented on top of the
  133. CAIF Core protocol. The IP Interface and CAIF socket have an instance of
  134. 'struct cflayer', just like the CAIF Core protocol stack.
  135. Net device and Socket implement the 'receive()' function defined by
  136. 'struct cflayer', just like the rest of the CAIF stack. In this way, transmit and
  137. receive of packets is handled as by the rest of the layers: the 'dn->transmit()'
  138. function is called in order to transmit data.
  139. Configuration of Link Layer
  140. ---------------------------
  141. The Link Layer is implemented as Linux network devices (struct net_device).
  142. Payload handling and registration is done using standard Linux mechanisms.
  143. The CAIF Protocol relies on a loss-less link layer without implementing
  144. retransmission. This implies that packet drops must not happen.
  145. Therefore a flow-control mechanism is implemented where the physical
  146. interface can initiate flow stop for all CAIF Channels.