blob: a0480862ab8cec1781fb2b7cc00d1bac67a1b3df [file] [log] [blame]
Mauro Carvalho Chehabda50d572020-04-28 00:01:16 +02001.. SPDX-License-Identifier: GPL-2.0
2.. include:: <isonum.txt>
3
4==========
Sjur Braendelandedc76162010-03-30 13:56:29 +00005Linux CAIF
Mauro Carvalho Chehabda50d572020-04-28 00:01:16 +02006==========
7
8Copyright |copy| ST-Ericsson AB 2010
9
10:Author: Sjur Brendeland/ sjur.brandeland@stericsson.com
11:License terms: GNU General Public License (GPL) version 2
Sjur Braendelandedc76162010-03-30 13:56:29 +000012
13
14Introduction
Mauro Carvalho Chehabda50d572020-04-28 00:01:16 +020015============
16
Sjur Braendelandedc76162010-03-30 13:56:29 +000017CAIF is a MUX protocol used by ST-Ericsson cellular modems for
18communication between Modem and host. The host processes can open virtual AT
19channels, initiate GPRS Data connections, Video channels and Utility Channels.
20The Utility Channels are general purpose pipes between modem and host.
21
22ST-Ericsson modems support a number of transports between modem
23and host. Currently, UART and Loopback are available for Linux.
24
25
Mauro Carvalho Chehabda50d572020-04-28 00:01:16 +020026Architecture
27============
28
Sjur Braendelandedc76162010-03-30 13:56:29 +000029The implementation of CAIF is divided into:
Mauro Carvalho Chehabda50d572020-04-28 00:01:16 +020030
Sjur Brændeland5051c942012-06-25 07:49:40 +000031* CAIF Socket Layer and GPRS IP Interface.
Sjur Braendelandedc76162010-03-30 13:56:29 +000032* CAIF Core Protocol Implementation
33* CAIF Link Layer, implemented as NET devices.
34
Mauro Carvalho Chehabda50d572020-04-28 00:01:16 +020035::
Sjur Braendelandedc76162010-03-30 13:56:29 +000036
37 RTNL
38 !
Sjur Brændeland5051c942012-06-25 07:49:40 +000039 ! +------+ +------+
40 ! +------+! +------+!
41 ! ! IP !! !Socket!!
42 +-------> !interf!+ ! API !+ <- CAIF Client APIs
43 ! +------+ +------!
44 ! ! !
45 ! +-----------+
46 ! !
47 ! +------+ <- CAIF Core Protocol
48 ! ! CAIF !
49 ! ! Core !
50 ! +------+
51 ! +----------!---------+
52 ! ! ! !
53 ! +------+ +-----+ +------+
54 +--> ! HSI ! ! TTY ! ! USB ! <- Link Layer (Net Devices)
55 +------+ +-----+ +------+
Sjur Braendelandedc76162010-03-30 13:56:29 +000056
57
Sjur Braendelandedc76162010-03-30 13:56:29 +000058
Mauro Carvalho Chehabda50d572020-04-28 00:01:16 +020059Implementation
60==============
Sjur Brændeland5051c942012-06-25 07:49:40 +000061
Sjur Braendelandedc76162010-03-30 13:56:29 +000062
63CAIF Core Protocol Layer
Mauro Carvalho Chehabda50d572020-04-28 00:01:16 +020064------------------------
Sjur Braendelandedc76162010-03-30 13:56:29 +000065
66CAIF Core layer implements the CAIF protocol as defined by ST-Ericsson.
67It implements the CAIF protocol stack in a layered approach, where
68each layer described in the specification is implemented as a separate layer.
69The architecture is inspired by the design patterns "Protocol Layer" and
70"Protocol Packet".
71
Mauro Carvalho Chehabda50d572020-04-28 00:01:16 +020072CAIF structure
73^^^^^^^^^^^^^^
74
Sjur Braendelandedc76162010-03-30 13:56:29 +000075The Core CAIF implementation contains:
Mauro Carvalho Chehabda50d572020-04-28 00:01:16 +020076
Sjur Braendelandedc76162010-03-30 13:56:29 +000077 - Simple implementation of CAIF.
78 - Layered architecture (a la Streams), each layer in the CAIF
79 specification is implemented in a separate c-file.
Sjur Braendelandedc76162010-03-30 13:56:29 +000080 - Clients must call configuration function to add PHY layer.
81 - Clients must implement CAIF layer to consume/produce
82 CAIF payload with receive and transmit functions.
83 - Clients must call configuration function to add and connect the
84 Client layer.
85 - When receiving / transmitting CAIF Packets (cfpkt), ownership is passed
Sjur Brændeland5051c942012-06-25 07:49:40 +000086 to the called function (except for framing layers' receive function)
Sjur Braendelandedc76162010-03-30 13:56:29 +000087
88Layered Architecture
Mauro Carvalho Chehabda50d572020-04-28 00:01:16 +020089====================
90
Sjur Braendelandedc76162010-03-30 13:56:29 +000091The CAIF protocol can be divided into two parts: Support functions and Protocol
92Implementation. The support functions include:
93
94 - CFPKT CAIF Packet. Implementation of CAIF Protocol Packet. The
95 CAIF Packet has functions for creating, destroying and adding content
96 and for adding/extracting header and trailers to protocol packets.
97
Sjur Braendelandedc76162010-03-30 13:56:29 +000098The CAIF Protocol implementation contains:
99
100 - CFCNFG CAIF Configuration layer. Configures the CAIF Protocol
101 Stack and provides a Client interface for adding Link-Layer and
102 Driver interfaces on top of the CAIF Stack.
103
104 - CFCTRL CAIF Control layer. Encodes and Decodes control messages
105 such as enumeration and channel setup. Also matches request and
106 response messages.
107
108 - CFSERVL General CAIF Service Layer functionality; handles flow
109 control and remote shutdown requests.
110
111 - CFVEI CAIF VEI layer. Handles CAIF AT Channels on VEI (Virtual
Sjur Brændeland5051c942012-06-25 07:49:40 +0000112 External Interface). This layer encodes/decodes VEI frames.
Sjur Braendelandedc76162010-03-30 13:56:29 +0000113
114 - CFDGML CAIF Datagram layer. Handles CAIF Datagram layer (IP
115 traffic), encodes/decodes Datagram frames.
116
117 - CFMUX CAIF Mux layer. Handles multiplexing between multiple
118 physical bearers and multiple channels such as VEI, Datagram, etc.
119 The MUX keeps track of the existing CAIF Channels and
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300120 Physical Instances and selects the appropriate instance based
Sjur Braendelandedc76162010-03-30 13:56:29 +0000121 on Channel-Id and Physical-ID.
122
123 - CFFRML CAIF Framing layer. Handles Framing i.e. Frame length
124 and frame checksum.
125
126 - CFSERL CAIF Serial layer. Handles concatenation/split of frames
127 into CAIF Frames with correct length.
128
Mauro Carvalho Chehabda50d572020-04-28 00:01:16 +0200129::
Sjur Braendelandedc76162010-03-30 13:56:29 +0000130
131 +---------+
132 | Config |
133 | CFCNFG |
134 +---------+
135 !
136 +---------+ +---------+ +---------+
137 | AT | | Control | | Datagram|
138 | CFVEIL | | CFCTRL | | CFDGML |
139 +---------+ +---------+ +---------+
140 \_____________!______________/
141 !
142 +---------+
143 | MUX |
144 | |
145 +---------+
146 _____!_____
147 / \
148 +---------+ +---------+
149 | CFFRML | | CFFRML |
150 | Framing | | Framing |
151 +---------+ +---------+
152 ! !
153 +---------+ +---------+
Sjur Brændeland5051c942012-06-25 07:49:40 +0000154 | | | Serial |
Sjur Braendelandedc76162010-03-30 13:56:29 +0000155 | | | CFSERL |
156 +---------+ +---------+
157
158
159In this layered approach the following "rules" apply.
Mauro Carvalho Chehabda50d572020-04-28 00:01:16 +0200160
Sjur Braendelandedc76162010-03-30 13:56:29 +0000161 - All layers embed the same structure "struct cflayer"
162 - A layer does not depend on any other layer's private data.
Mauro Carvalho Chehabda50d572020-04-28 00:01:16 +0200163 - Layers are stacked by setting the pointers::
164
Sjur Braendelandedc76162010-03-30 13:56:29 +0000165 layer->up , layer->dn
Mauro Carvalho Chehabda50d572020-04-28 00:01:16 +0200166
167 - In order to send data upwards, each layer should do::
168
Sjur Braendelandedc76162010-03-30 13:56:29 +0000169 layer->up->receive(layer->up, packet);
Mauro Carvalho Chehabda50d572020-04-28 00:01:16 +0200170
171 - In order to send data downwards, each layer should do::
172
Sjur Braendelandedc76162010-03-30 13:56:29 +0000173 layer->dn->transmit(layer->dn, packet);
174
175
Sjur Brændeland5051c942012-06-25 07:49:40 +0000176CAIF Socket and IP interface
Mauro Carvalho Chehabda50d572020-04-28 00:01:16 +0200177============================
Sjur Braendelandedc76162010-03-30 13:56:29 +0000178
Sjur Brændeland5051c942012-06-25 07:49:40 +0000179The IP interface and CAIF socket API are implemented on top of the
180CAIF Core protocol. The IP Interface and CAIF socket have an instance of
Sjur Braendelandedc76162010-03-30 13:56:29 +0000181'struct cflayer', just like the CAIF Core protocol stack.
182Net device and Socket implement the 'receive()' function defined by
183'struct cflayer', just like the rest of the CAIF stack. In this way, transmit and
184receive of packets is handled as by the rest of the layers: the 'dn->transmit()'
185function is called in order to transmit data.
186
Sjur Braendelandedc76162010-03-30 13:56:29 +0000187Configuration of Link Layer
188---------------------------
Sjur Brændeland5051c942012-06-25 07:49:40 +0000189The Link Layer is implemented as Linux network devices (struct net_device).
Sjur Braendelandedc76162010-03-30 13:56:29 +0000190Payload handling and registration is done using standard Linux mechanisms.
191
192The CAIF Protocol relies on a loss-less link layer without implementing
193retransmission. This implies that packet drops must not happen.
194Therefore a flow-control mechanism is implemented where the physical
195interface can initiate flow stop for all CAIF Channels.