Linux-CAIF.txt 6.0 KB

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