blob: 0aa4bd381becd823f17e7fd1fa75d429efafca90 [file] [log] [blame]
Sjur Braendelandedc76162010-03-30 13:56:29 +00001Linux CAIF
2===========
3copyright (C) ST-Ericsson AB 2010
4Author: Sjur Brendeland/ sjur.brandeland@stericsson.com
5License terms: GNU General Public License (GPL) version 2
6
7
8Introduction
9------------
10CAIF is a MUX protocol used by ST-Ericsson cellular modems for
11communication between Modem and host. The host processes can open virtual AT
12channels, initiate GPRS Data connections, Video channels and Utility Channels.
13The Utility Channels are general purpose pipes between modem and host.
14
15ST-Ericsson modems support a number of transports between modem
16and host. Currently, UART and Loopback are available for Linux.
17
18
19Architecture:
20------------
21The implementation of CAIF is divided into:
Sjur Brændeland5051c942012-06-25 07:49:40 +000022* CAIF Socket Layer and GPRS IP Interface.
Sjur Braendelandedc76162010-03-30 13:56:29 +000023* CAIF Core Protocol Implementation
24* CAIF Link Layer, implemented as NET devices.
25
26
27 RTNL
28 !
Sjur Brændeland5051c942012-06-25 07:49:40 +000029 ! +------+ +------+
30 ! +------+! +------+!
31 ! ! IP !! !Socket!!
32 +-------> !interf!+ ! API !+ <- CAIF Client APIs
33 ! +------+ +------!
34 ! ! !
35 ! +-----------+
36 ! !
37 ! +------+ <- CAIF Core Protocol
38 ! ! CAIF !
39 ! ! Core !
40 ! +------+
41 ! +----------!---------+
42 ! ! ! !
43 ! +------+ +-----+ +------+
44 +--> ! HSI ! ! TTY ! ! USB ! <- Link Layer (Net Devices)
45 +------+ +-----+ +------+
Sjur Braendelandedc76162010-03-30 13:56:29 +000046
47
Sjur Braendelandedc76162010-03-30 13:56:29 +000048
49I M P L E M E N T A T I O N
50===========================
Sjur Brændeland5051c942012-06-25 07:49:40 +000051
Sjur Braendelandedc76162010-03-30 13:56:29 +000052
53CAIF Core Protocol Layer
54=========================================
55
56CAIF Core layer implements the CAIF protocol as defined by ST-Ericsson.
57It implements the CAIF protocol stack in a layered approach, where
58each layer described in the specification is implemented as a separate layer.
59The architecture is inspired by the design patterns "Protocol Layer" and
60"Protocol Packet".
61
62== CAIF structure ==
63The 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.
Sjur Braendelandedc76162010-03-30 13:56:29 +000067 - 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
71 Client layer.
72 - When receiving / transmitting CAIF Packets (cfpkt), ownership is passed
Sjur Brændeland5051c942012-06-25 07:49:40 +000073 to the called function (except for framing layers' receive function)
Sjur Braendelandedc76162010-03-30 13:56:29 +000074
75Layered Architecture
76--------------------
77The CAIF protocol can be divided into two parts: Support functions and Protocol
78Implementation. The support functions include:
79
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.
83
Sjur Braendelandedc76162010-03-30 13:56:29 +000084The CAIF Protocol implementation contains:
85
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.
89
90 - CFCTRL CAIF Control layer. Encodes and Decodes control messages
91 such as enumeration and channel setup. Also matches request and
92 response messages.
93
94 - CFSERVL General CAIF Service Layer functionality; handles flow
95 control and remote shutdown requests.
96
97 - CFVEI CAIF VEI layer. Handles CAIF AT Channels on VEI (Virtual
Sjur Brændeland5051c942012-06-25 07:49:40 +000098 External Interface). This layer encodes/decodes VEI frames.
Sjur Braendelandedc76162010-03-30 13:56:29 +000099
100 - CFDGML CAIF Datagram layer. Handles CAIF Datagram layer (IP
101 traffic), encodes/decodes Datagram frames.
102
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
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300106 Physical Instances and selects the appropriate instance based
Sjur Braendelandedc76162010-03-30 13:56:29 +0000107 on Channel-Id and Physical-ID.
108
109 - CFFRML CAIF Framing layer. Handles Framing i.e. Frame length
110 and frame checksum.
111
112 - CFSERL CAIF Serial layer. Handles concatenation/split of frames
113 into CAIF Frames with correct length.
114
115
116
117 +---------+
118 | Config |
119 | CFCNFG |
120 +---------+
121 !
122 +---------+ +---------+ +---------+
123 | AT | | Control | | Datagram|
124 | CFVEIL | | CFCTRL | | CFDGML |
125 +---------+ +---------+ +---------+
126 \_____________!______________/
127 !
128 +---------+
129 | MUX |
130 | |
131 +---------+
132 _____!_____
133 / \
134 +---------+ +---------+
135 | CFFRML | | CFFRML |
136 | Framing | | Framing |
137 +---------+ +---------+
138 ! !
139 +---------+ +---------+
Sjur Brændeland5051c942012-06-25 07:49:40 +0000140 | | | Serial |
Sjur Braendelandedc76162010-03-30 13:56:29 +0000141 | | | CFSERL |
142 +---------+ +---------+
143
144
145In 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);
154
155
Sjur Brændeland5051c942012-06-25 07:49:40 +0000156CAIF Socket and IP interface
Sjur Braendelandedc76162010-03-30 13:56:29 +0000157===========================
158
Sjur Brændeland5051c942012-06-25 07:49:40 +0000159The IP interface and CAIF socket API are implemented on top of the
160CAIF Core protocol. The IP Interface and CAIF socket have an instance of
Sjur Braendelandedc76162010-03-30 13:56:29 +0000161'struct cflayer', just like the CAIF Core protocol stack.
162Net 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
164receive of packets is handled as by the rest of the layers: the 'dn->transmit()'
165function is called in order to transmit data.
166
Sjur Braendelandedc76162010-03-30 13:56:29 +0000167Configuration of Link Layer
168---------------------------
Sjur Brændeland5051c942012-06-25 07:49:40 +0000169The Link Layer is implemented as Linux network devices (struct net_device).
Sjur Braendelandedc76162010-03-30 13:56:29 +0000170Payload handling and registration is done using standard Linux mechanisms.
171
172The CAIF Protocol relies on a loss-less link layer without implementing
173retransmission. This implies that packet drops must not happen.
174Therefore a flow-control mechanism is implemented where the physical
175interface can initiate flow stop for all CAIF Channels.