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
10 CAIF is a MUX protocol used by ST-Ericsson cellular modems for
11 communication between Modem and host. The host processes can open virtual AT
12 channels, initiate GPRS Data connections, Video channels and Utility Channels.
13 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.
21 The implementation of CAIF is divided into:
22 * CAIF Socket Layer and GPRS IP Interface.
23 * CAIF Core Protocol Implementation
24 * CAIF Link Layer, implemented as NET devices.
32 +-------> !interf!+ ! API !+ <- CAIF Client APIs
37 ! +------+ <- CAIF Core Protocol
41 ! +----------!---------+
43 ! +------+ +-----+ +------+
44 +--> ! HSI ! ! TTY ! ! USB ! <- Link Layer (Net Devices)
45 +------+ +-----+ +------+
49 I M P L E M E N T A T I O N
50 ===========================
53 CAIF Core Protocol Layer
54 =========================================
56 CAIF Core layer implements the CAIF protocol as defined by ST-Ericsson.
57 It implements the CAIF protocol stack in a layered approach, where
58 each layer described in the specification is implemented as a separate layer.
59 The architecture is inspired by the design patterns "Protocol Layer" and
63 The Core CAIF implementation contains:
64 - Simple implementation of CAIF.
65 - Layered architecture (a la Streams), each layer in the CAIF
66 specification is implemented in a separate c-file.
67 - Clients must call configuration function to add PHY layer.
68 - Clients must implement CAIF layer to consume/produce
69 CAIF payload with receive and transmit functions.
70 - Clients must call configuration function to add and connect the
72 - When receiving / transmitting CAIF Packets (cfpkt), ownership is passed
73 to the called function (except for framing layers' receive function)
77 The CAIF protocol can be divided into two parts: Support functions and Protocol
78 Implementation. The support functions include:
80 - CFPKT CAIF Packet. Implementation of CAIF Protocol Packet. The
81 CAIF Packet has functions for creating, destroying and adding content
82 and for adding/extracting header and trailers to protocol packets.
84 The CAIF Protocol implementation contains:
86 - CFCNFG CAIF Configuration layer. Configures the CAIF Protocol
87 Stack and provides a Client interface for adding Link-Layer and
88 Driver interfaces on top of the CAIF Stack.
90 - CFCTRL CAIF Control layer. Encodes and Decodes control messages
91 such as enumeration and channel setup. Also matches request and
94 - CFSERVL General CAIF Service Layer functionality; handles flow
95 control and remote shutdown requests.
97 - CFVEI CAIF VEI layer. Handles CAIF AT Channels on VEI (Virtual
98 External Interface). This layer encodes/decodes VEI frames.
100 - CFDGML CAIF Datagram layer. Handles CAIF Datagram layer (IP
101 traffic), encodes/decodes Datagram frames.
103 - CFMUX CAIF Mux layer. Handles multiplexing between multiple
104 physical bearers and multiple channels such as VEI, Datagram, etc.
105 The MUX keeps track of the existing CAIF Channels and
106 Physical Instances and selects the appropriate instance based
107 on Channel-Id and Physical-ID.
109 - CFFRML CAIF Framing layer. Handles Framing i.e. Frame length
112 - CFSERL CAIF Serial layer. Handles concatenation/split of frames
113 into CAIF Frames with correct length.
122 +---------+ +---------+ +---------+
123 | AT | | Control | | Datagram|
124 | CFVEIL | | CFCTRL | | CFDGML |
125 +---------+ +---------+ +---------+
126 \_____________!______________/
134 +---------+ +---------+
135 | CFFRML | | CFFRML |
136 | Framing | | Framing |
137 +---------+ +---------+
139 +---------+ +---------+
142 +---------+ +---------+
145 In this layered approach the following "rules" apply.
146 - All layers embed the same structure "struct cflayer"
147 - A layer does not depend on any other layer's private data.
148 - Layers are stacked by setting the pointers
149 layer->up , layer->dn
150 - In order to send data upwards, each layer should do
151 layer->up->receive(layer->up, packet);
152 - In order to send data downwards, each layer should do
153 layer->dn->transmit(layer->dn, packet);
156 CAIF Socket and IP interface
157 ===========================
159 The IP interface and CAIF socket API are implemented on top of the
160 CAIF Core protocol. The IP Interface and CAIF socket have an instance of
161 'struct cflayer', just like the CAIF Core protocol stack.
162 Net device and Socket implement the 'receive()' function defined by
163 'struct cflayer', just like the rest of the CAIF stack. In this way, transmit and
164 receive of packets is handled as by the rest of the layers: the 'dn->transmit()'
165 function is called in order to transmit data.
167 Configuration of Link Layer
168 ---------------------------
169 The Link Layer is implemented as Linux network devices (struct net_device).
170 Payload handling and registration is done using standard Linux mechanisms.
172 The CAIF Protocol relies on a loss-less link layer without implementing
173 retransmission. This implies that packet drops must not happen.
174 Therefore a flow-control mechanism is implemented where the physical
175 interface can initiate flow stop for all CAIF Channels.