← Documents Documentation/networking/caif/linux_caif.rst GitHub 원문 ↗

Linux 6.18.37 · Networking

Linux CAIF

CAIF MUX protocol의 client API, core layer, framing·serial layer와 cflayer packet 흐름을 설명합니다.

Source pathDocumentation/networking/caif/linux_caif.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

linux_caif.rst:1-195

CAIF는 modem과 host 사이에서 AT, IP datagram, utility traffic을 하나 이상의 physical bearer로 multiplexing합니다. Linux 구현은 공통 `struct cflayer` 계약을 사용해 client API, service layer, MUX, framing, serial/link layer를 위아래 호출 관계로 연결합니다.

Linux CAIF 전체 architecture
RTNLIP interface / Socket APICAIF Core ProtocolHSI / TTY / USB net devices
CAIF client`struct cflayer` receive·transmitCore stackPhysical link

원문 L35-55의 수직·수평 연결을 계층형 flow로 재구성했습니다.

CAIF protocol layer stack
CFCNFG ConfigCFVEIL ATCFMUXCFFRMLPhysical bearer
CFCNFG ConfigCFCTRL ControlCFMUXCFFRMLCFSERL Serial
CFCNFG ConfigCFDGML DatagramCFMUXCFFRMLPhysical bearer

원문 L129-156의 service·MUX·framing 구조를 보존한 흐름입니다.

CAIF layer 역할
Layer역할
CFCNFGStack·client·link configuration
CFCTRLEnumeration·channel setup control
CFSERVLFlow control·remote shutdown
CFVEILVirtual AT channel
CFDGMLIP datagram
CFMUXChannel-ID·Physical-ID 기반 multiplexing
CFFRMLFrame length·checksum
CFSERLSerial frame 연결·분할

각 component가 맡는 protocol 기능입니다.

cflayer packet 방향
아래 layer`layer->up->receive(layer->up, packet)`위 layer
위 layer`layer->dn->transmit(layer->dn, packet)`아래 layer

모든 layer가 같은 호출 규칙으로 packet ownership과 흐름을 전달합니다.

Link Layer 보장 조건
조건의미
Lossless linkPacket drop이 발생하지 않아야 함
No retransmissionCAIF core가 손실 복구를 수행하지 않음
Physical flow stop모든 CAIF Channel로 backpressure 전파
Standard net_deviceLinux payload 처리·등록 mechanism 재사용

CAIF에는 retransmission이 없으므로 하위 계층의 성질이 중요합니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 .. SPDX-License-Identifier: GPL-2.0
2 .. include:: <isonum.txt>
3
4 ==========
5 Linux CAIF
6 ==========
7
8 Copyright |copy| ST-Ericsson AB 2010
9
10 :Author: Sjur Brendeland/ [email protected]
11 :License terms: GNU General Public License (GPL) version 2
12
13
14 Introduction
15 ============
16
17 CAIF is a MUX protocol used by ST-Ericsson cellular modems for
18 communication between Modem and host. The host processes can open virtual AT
19 channels, initiate GPRS Data connections, Video channels and Utility Channels.
20 The Utility Channels are general purpose pipes between modem and host.
21
22 ST-Ericsson modems support a number of transports between modem
23 and host. Currently, UART and Loopback are available for Linux.
24
25
26 Architecture
27 ============
28
29 The implementation of CAIF is divided into:
30
31 * CAIF Socket Layer and GPRS IP Interface.
32 * CAIF Core Protocol Implementation
33 * CAIF Link Layer, implemented as NET devices.
34
35 ::
36
37 RTNL
38 !
39 ! +------+ +------+
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 +------+ +-----+ +------+
56
57
58
59 Implementation
60 ==============
61
62
63 CAIF Core Protocol Layer
64 ------------------------
65
66 CAIF Core layer implements the CAIF protocol as defined by ST-Ericsson.
67 It implements the CAIF protocol stack in a layered approach, where
68 each layer described in the specification is implemented as a separate layer.
69 The architecture is inspired by the design patterns "Protocol Layer" and
70 "Protocol Packet".
71
72 CAIF structure
73 ^^^^^^^^^^^^^^
74
75 The Core CAIF implementation contains:
76
77 - Simple implementation of CAIF.
78 - Layered architecture (a la Streams), each layer in the CAIF
79 specification is implemented in a separate c-file.
80 - 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
86 to the called function (except for framing layers' receive function)
87
88 Layered Architecture
89 ====================
90
91 The CAIF protocol can be divided into two parts: Support functions and Protocol
92 Implementation. 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
98 The 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
112 External Interface). This layer encodes/decodes VEI frames.
113
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
120 Physical Instances and selects the appropriate instance based
121 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
129 ::
130
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 +---------+ +---------+
154 | | | Serial |
155 | | | CFSERL |
156 +---------+ +---------+
157
158
159 In this layered approach the following "rules" apply.
160
161 - All layers embed the same structure "struct cflayer"
162 - A layer does not depend on any other layer's private data.
163 - Layers are stacked by setting the pointers::
164
165 layer->up , layer->dn
166
167 - In order to send data upwards, each layer should do::
168
169 layer->up->receive(layer->up, packet);
170
171 - In order to send data downwards, each layer should do::
172
173 layer->dn->transmit(layer->dn, packet);
174
175
176 CAIF Socket and IP interface
177 ============================
178
179 The IP interface and CAIF socket API are implemented on top of the
180 CAIF Core protocol. The IP Interface and CAIF socket have an instance of
181 'struct cflayer', just like the CAIF Core protocol stack.
182 Net 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
184 receive of packets is handled as by the rest of the layers: the 'dn->transmit()'
185 function is called in order to transmit data.
186
187 Configuration of Link Layer
188 ---------------------------
189 The Link Layer is implemented as Linux network devices (struct net_device).
190 Payload handling and registration is done using standard Linux mechanisms.
191
192 The CAIF Protocol relies on a loss-less link layer without implementing
193 retransmission. This implies that packet drops must not happen.
194 Therefore a flow-control mechanism is implemented where the physical
195 interface can initiate flow stop for all CAIF Channels.
196

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

CAIF 소개와 전체 architecture

1-58

`.. SPDX-License-Identifier: GPL-2.0`

`.. include:: <isonum.txt>`

Linux CAIF

Copyright |copy| ST-Ericsson AB 2010

:Author: Sjur Brendeland/ [email protected]

:License terms: GNU General Public License (GPL) version 2

소개

CAIF는 ST-Ericsson cellular modem이 modem과 host 사이의 통신에 사용하는 MUX protocol입니다. Host process는 virtual AT channel을 열고 GPRS data connection, video channel, utility channel을 시작할 수 있습니다. Utility channel은 modem과 host 사이의 범용 pipe입니다.

ST-Ericsson modem은 modem과 host 사이에 여러 transport를 지원합니다. 현재 Linux에서는 UART와 Loopback을 사용할 수 있습니다.

Architecture

CAIF 구현은 다음 부분으로 나뉩니다.

  • CAIF Socket Layer와 GPRS IP Interface
  • CAIF Core Protocol 구현
  • NET device로 구현된 CAIF Link Layer

RTNL은 CAIF client API의 IP interface와 Socket API, CAIF Core Protocol, 그리고 net device인 HSI·TTY·USB link layer를 구성하고 연결합니다.

.. SPDX-License-Identifier: GPL-2.0
.. include:: <isonum.txt>

==========
Linux CAIF
==========

Copyright |copy| ST-Ericsson AB 2010

:Author: Sjur Brendeland/ [email protected]
:License terms: GNU General Public License (GPL) version 2


Introduction
============

CAIF is a MUX protocol used by ST-Ericsson cellular modems for
communication between Modem and host. The host processes can open virtual AT
channels, initiate GPRS Data connections, Video channels and Utility Channels.
The Utility Channels are general purpose pipes between modem and host.

ST-Ericsson modems support a number of transports between modem
and host. Currently, UART and Loopback are available for Linux.


Architecture
============

The implementation of CAIF is divided into:

* CAIF Socket Layer and GPRS IP Interface.
* CAIF Core Protocol Implementation
* CAIF Link Layer, implemented as NET devices.

::

  RTNL
   !
   !              +------+         +------+
   !             +------+!        +------+!
   !             !        IP  !!        !Socket!!
   +-------> !interf!+        ! API  !+        <- CAIF Client APIs
   !             +------+        +------!
   !                !            !
   !                +-----------+
   !                      !
   !                   +------+                <- CAIF Core Protocol
   !                   ! CAIF !
   !                   ! Core !
   !                   +------+
   !           +----------!---------+
   !           !              !                !
   !        +------+   +-----+   +------+
   +--> ! HSI  !   ! TTY !   ! USB  !        <- Link Layer (Net Devices)
        +------+   +-----+   +------+


CAIF Core Protocol 구조

59-87

구현

CAIF Core Protocol Layer

CAIF Core layer는 ST-Ericsson이 정의한 CAIF protocol을 구현합니다. Specification에 설명된 각 layer를 별도 layer로 구현하는 계층적 방식으로 CAIF protocol stack을 구성합니다. Architecture는 `Protocol Layer`와 `Protocol Packet` design pattern에서 영감을 받았습니다.

CAIF 구조

Core CAIF 구현에는 다음 특성이 있습니다.

  • CAIF의 단순한 구현입니다.
  • Streams와 유사한 layered architecture를 사용하며, CAIF specification의 각 layer를 별도 C file로 구현합니다.
  • Client는 configuration function을 호출해 PHY layer를 추가해야 합니다.
  • Client는 receive와 transmit function으로 CAIF payload를 소비·생성하는 CAIF layer를 구현해야 합니다.
  • Client는 configuration function을 호출해 Client layer를 추가하고 연결해야 합니다.
  • CAIF packet(`cfpkt`)을 수신하거나 전송할 때는 호출된 function으로 ownership이 넘어갑니다. 단, framing layer의 receive function은 예외입니다.
Implementation
==============


CAIF Core Protocol Layer
------------------------

CAIF Core layer implements the CAIF protocol as defined by ST-Ericsson.
It implements the CAIF protocol stack in a layered approach, where
each layer described in the specification is implemented as a separate layer.
The architecture is inspired by the design patterns "Protocol Layer" and
"Protocol Packet".

CAIF structure
^^^^^^^^^^^^^^

The Core CAIF implementation contains:

      -        Simple implementation of CAIF.
      -        Layered architecture (a la Streams), each layer in the CAIF
        specification is implemented in a separate c-file.
      -        Clients must call configuration function to add PHY layer.
      -        Clients must implement CAIF layer to consume/produce
        CAIF payload with receive and transmit functions.
      -        Clients must call configuration function to add and connect the
        Client layer.
      - When receiving / transmitting CAIF Packets (cfpkt), ownership is passed
        to the called function (except for framing layers' receive function)

계층별 component

88-128

Layered Architecture

CAIF protocol은 support function과 protocol 구현의 두 부분으로 나눌 수 있습니다. Support function에는 다음이 포함됩니다.

  • CFPKT CAIF Packet: CAIF Protocol Packet 구현입니다. CAIF packet을 생성·파괴하고 content를 추가하며 protocol packet의 header와 trailer를 추가·추출하는 function을 제공합니다.

CAIF protocol 구현에는 다음이 포함됩니다.

  • CFCNFG CAIF Configuration layer: CAIF protocol stack을 구성하고 CAIF stack 위에 Link-Layer와 Driver interface를 추가하는 client interface를 제공합니다.
  • CFCTRL CAIF Control layer: enumeration과 channel setup 같은 control message를 encode·decode하고 request와 response message를 짝지어 줍니다.
  • CFSERVL General CAIF Service Layer: flow control과 remote shutdown request를 처리합니다.
  • CFVEI CAIF VEI layer: VEI(Virtual External Interface)의 CAIF AT Channel을 처리하며 VEI frame을 encode·decode합니다.
  • CFDGML CAIF Datagram layer: IP traffic을 위한 CAIF Datagram layer를 처리하고 Datagram frame을 encode·decode합니다.
  • CFMUX CAIF Mux layer: 여러 physical bearer와 VEI·Datagram 같은 여러 channel 사이를 multiplexing합니다. MUX는 기존 CAIF Channel과 Physical Instance를 추적하고 Channel-ID와 Physical-ID에 따라 적절한 instance를 선택합니다.
  • CFFRML CAIF Framing layer: frame length와 frame checksum을 포함한 framing을 처리합니다.
  • CFSERL CAIF Serial layer: frame을 올바른 길이의 CAIF frame으로 연결하거나 분할합니다.
Layered Architecture
====================

The CAIF protocol can be divided into two parts: Support functions and Protocol
Implementation. The support functions include:

      - CFPKT CAIF Packet. Implementation of CAIF Protocol Packet. The
        CAIF Packet has functions for creating, destroying and adding content
        and for adding/extracting header and trailers to protocol packets.

The CAIF Protocol implementation contains:

      - CFCNFG CAIF Configuration layer. Configures the CAIF Protocol
        Stack and provides a Client interface for adding Link-Layer and
        Driver interfaces on top of the CAIF Stack.

      - CFCTRL CAIF Control layer. Encodes and Decodes control messages
        such as enumeration and channel setup. Also matches request and
        response messages.

      - CFSERVL General CAIF Service Layer functionality; handles flow
        control and remote shutdown requests.

      - CFVEI CAIF VEI layer. Handles CAIF AT Channels on VEI (Virtual
        External Interface). This layer encodes/decodes VEI frames.

      - CFDGML CAIF Datagram layer. Handles CAIF Datagram layer (IP
        traffic), encodes/decodes Datagram frames.

      - CFMUX CAIF Mux layer. Handles multiplexing between multiple
        physical bearers and multiple channels such as VEI, Datagram, etc.
        The MUX keeps track of the existing CAIF Channels and
        Physical Instances and selects the appropriate instance based
        on Channel-Id and Physical-ID.

      - CFFRML CAIF Framing layer. Handles Framing i.e. Frame length
        and frame checksum.

      - CFSERL CAIF Serial layer. Handles concatenation/split of frames
        into CAIF Frames with correct length.

Layer 연결 구조와 호출 규칙

129-175

Configuration layer `CFCNFG` 아래에는 AT `CFVEIL`, Control `CFCTRL`, Datagram `CFDGML` service가 놓입니다. 이 service들은 하나의 MUX로 모이고, MUX 아래에서 physical path별 `CFFRML` framing layer와 선택적인 `CFSERL` serial layer로 갈라집니다.

이 layered approach에는 다음 규칙이 적용됩니다.

  • 모든 layer는 같은 structure인 `struct cflayer`를 embed합니다.
  • 어떤 layer도 다른 layer의 private data에 의존하지 않습니다.
  • Layer는 `layer->up`과 `layer->dn` pointer를 설정해 쌓습니다.
  • Data를 위로 보내려면 각 layer가 `layer->up->receive(layer->up, packet);`을 호출합니다.
  • Data를 아래로 보내려면 각 layer가 `layer->dn->transmit(layer->dn, packet);`을 호출합니다.
layer->up , layer->dn

layer->up->receive(layer->up, packet);

layer->dn->transmit(layer->dn, packet);
::

                    +---------+
                    | Config  |
                    | CFCNFG  |
                    +---------+
                         !
    +---------+            +---------+            +---------+
    |        AT    |            | Control |            | Datagram|
    | CFVEIL  |            | CFCTRL  |            | CFDGML  |
    +---------+            +---------+            +---------+
           \_____________!______________/
                         !
                    +---------+
                    |        MUX   |
                    |              |
                    +---------+
                    _____!_____
                   /               \
            +---------+            +---------+
            | CFFRML  |            | CFFRML  |
            | Framing |            | Framing |
            +---------+            +---------+
                 !                !
            +---------+            +---------+
            |              |            | Serial  |
            |              |            | CFSERL  |
            +---------+            +---------+


In this layered approach the following "rules" apply.

      - All layers embed the same structure "struct cflayer"
      - A layer does not depend on any other layer's private data.
      - Layers are stacked by setting the pointers::

                  layer->up , layer->dn

      -        In order to send data upwards, each layer should do::

                 layer->up->receive(layer->up, packet);

      - In order to send data downwards, each layer should do::

                 layer->dn->transmit(layer->dn, packet);