blob: 2bf05a1b1313a698b2392dfcfe7516b2196e9311 [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001Introduction
2============
3
4QUALCOMM MSM Interface (QMI) defines the interface between MSM and
5attached Terminal Equipment (TE). RmNet interface is a new logical
6device in QMI framework for data services. RmNet in accordance with
7QMI architecture defines channels for control and data transfers and
8for example it uses Data I/O channel for IP data transfer and control
9I/O channel for QMI messaging (functionality similar to AT commands).
10RmNet may be used in place of legacy USB modem interface.
11
12Tethered networking is one of the function from MSM which can also be
13supported using QMI protocol. There are other standard protocols exists
14such as CDC-ECM and Windows proprietary RNDIS. On the host-side system,
15the gadget rmnet device looks like a ethernet adapter.
16
17Hardware description
18====================
19
20QMI is a messaging protocol to expose various functionalities of MSM
21and one of the functionality to be tethered networking which is being
22exposed over QMI using RmNet protocol. This usb gadget has one bulk-in,
23one bulk-out and one interrupt-in endpoint.
24
25Design:
26=======
27RmNet function driver design follows two approaches:
28
29Approach 1:
30-----------
31Single function driver is used to communicate with
32Modem(both for data and control). Most of the initial
33MSM targets are following this approach.
34
35The main disadvantage with this approach is there are
36multiple RmNet drivers for any change in DATA and Control
37Layer. There is no re-use in the code.
38
39Approach 2:
40-----------
41RmNet driver is divided into 3 components
42
431. USB:
44This component has the functionality to deal with composite layer.
45Allocates Interfaces, Endpoints, listens to connect/disconnect
46interrupts and gives connect/disconnect notifications to DATA and
47CONTROL modules.
48
492. Data:
50This component talks to modem to transfer IP data. Usually DATA
51and CONTROL go over same channel. However, to achieve higher
52data rates new transport channel for DATA may be used.
53
543. Control:
55This component talks to modem to transfer rmnet control data.
56
57Software description
58====================
59The RmNet suports following data and control transports:
60as follows:
61 1. SMD Interface
62 2. SDIO Interface
63 3. BAM Interface
64 4. SMD Control Interface
65
66SMD interface uses the Shared memory for the RmNet driver to communicate
67with the MSM modem processor.
68SDIO interface acts as a link for communication of RmNet driver with the
69MDM modem processor.
70
71USB INTERACTION:
72----------------
73
74The RmNet function driver binds with the USB using the struct usb_function.
75The function is added using the usb_function_add().
76Control Transfers: The RmNet handles two Class-specific control
77transfers: SEND_ENCAPSULATED_COMMAND and GET_ENCAPSULATED_RESPONSE.
78The asynchronous protocol QMI which consists of the QMI requests/responses
79is used for handling the transfers between the RmNet and the Host where the
80host sends a new QMI request before receiving the response for the current
81QMI request.
82
83Control & Data flow:
841. Host issues a SEND_ENCAPSULATED command to send a QMI request.
85SMD: If the SMD control channel has enough room to accomodate a QMI request,
86it is written into the SMD buffer. Otherwise, append/add that request to
87qmi_request queue. A tasklet is scheduled to drain all QMI requests in
88qmi_request queue.
89SDIO: Add each request in the qmi_request queue and is processed until
90the queue is empty.
91
922. Append/Add QMI response from modem to qmi_response queue.
93A notification on an interrupt end point is used to communicate the QMI
94response to host.
95
963. Host issues a GET_ENCAPSULATED command to retrieve the QMI response.
97The response from qmi_response queue will be sent to the host.
98
994. After the connection is fully established data can be sent to
100bulk-out endpoint and data can be received from bulk-in endpoint.
101
1025. Host can send QMI requests even after the connection is established.
103
104RmNet gadget driver is completely unaware of QMI/IP protocol. It just
105acts as a bridge between the modem and the PC.
106
107All the request/response queues in the driver can be accessed either
108from tasklet/workqueue or from interrupt context (either usb or smd/sdio
109interrupt handler). Hence a spinlock is used to protect all data/control req
110lists.
111
112
113SMD Interface:
114--------------
115
1161. Each QMI request/response can at most be 2048 bytes. Eight 2KB buffers
117are allocated using kmalloc for storing maximum of 8 requests/responses.
118
1192. Four 2KB buffers are allocated using kmalloc for data transfers on
120each bulk endpoint.
121
122Data structures:
123struct qmi_buf - Buffer to handle QMI requests & responses
124struct rmnet_smd_info - Control & Data SMD channel private data
125struct rmnet_dev - Endpoint and driver specific data
126
127Workqueues:
128rmnet_connect_work - Called on device connection.
129 Opens SMD channels; enables endpoints
130rmnet_disconnect_work - Called on device disconnection.
131 Closes SMD channels.
132
133Tasklets:
134rmnet_control_rx_tlet
135rmnet_control_tx_tlet - Control transfer data reception and transmission
136 handler
137
138rmnet_data_rx_tlet
139rmnet_data_tx_tlet - Data transfer data reception and transmission handler
140
141
142SMD control interface
143----------------------
144This function driver implements exchnage of control informtion with
145modem over SMD. Uses smd_read/write commands to read or write rmnet
146ctrl packets. Exposes a call back function to usb component to write
147control packet and at the same time call a call back usb component
148callback to send data to usb host.
149
150Data structures and Interfaces are very similar to control interfaces
151explained in "SMD Interface"
152
153BAM MUX interface
154------------------
155BAM Mux interface is very similar to SDIO MUX interface. However there
156are differences in the way BAM and SDIO operate but all of the details
157are masked by MUX Driver.
158
159Refer to the SDIO interfaces for more information on data structures
160
161SDIO Interface:
162---------------
163
1641. Each QMI request/response buffer is allocated depending on the size
165of data to be transmitted for the request/response.
166
1672. A 2KB network buffer is allocated for data transfer on bulk-out
168endpoint. The SDIO allocates the required buffer for data transfers
169on an bulk-in endpoint.
170
171Data structures:
172struct rmnet_sdio_qmi_buf - Buffer to handle QMI requests/responses.
173struct rmnet_dev - Endpoint and driver specific data
174
175Workqueues:
176rmnet_connect_work - Device connection handler. Opens SDIO
177 channels; enables and allocate buffer for
178 endpoints
179rmnet_disconnect_work - Device disconnection handler. Closes
180 SDIO channels; Frees allocated buffers.
181rmnet_control_rx_work - Control data reception handler.
182rmnet_data_rx_work - Network data reception handler.
183
184
185Two SMD/SDIO channels (control and data) are used as communication channels
186between Modem and Apps processor. The driver opens the SMD/SDIO channels
187on USB device connection. Data is either read from/written to the channels
188as one complete packet.
189
190SMD/SDIO provides a notification whenever the Modem processor completes
191read/write of a packet. Based on these SMD/SDIO notifications all the
192pending read/write requests will be handled. Tasklets(SMD)/Workqueues(SDIO)
193are used to get the requests done.
194
195There is another variant of rmnet driver called rmnet_smd_sdio which is used
196on some boards. This driver allows the transport (SMD/SDIO) to be chosen
197at runtime. This is required because either MDM processor or MODEM processor
198is only active at a time for data transfers. As SMD and SDIO interfaces
199are different, different endpoint completion handlers are used. This driver
200leverage the existing rmnet over smd and rmnet over sdio drivers. The control
201messages (QMI) always routed over SDIO. After the control messages exchange,
202user space will come to know about the available data transport (SMD/SDIO).
203User space notify the same to driver and the corresponding transport is
204activated. It is assumed that transport will not change while a USB cable
205is connected.
206
207Rmnet over SMD and rmnet over SDIO doesn't expose any of its interfaces to
208either kernelspace or userspace. But rmnet over smd/sdio expose a sysfs
209interface for userspace to notify the available transport to driver.
210
211The sysfs file can be found at
212/sys/class/usb_composite/rmnet_smd_sdio/transport
213
214The below command activates the SMD transport
215echo 0 > /sys/class/usb_composite/rmnet_smd_sdio/transport
216
217The below command activates the SDIO transport
218echo 1 > /sys/class/usb_composite/rmnet_smd_sdio/transport
219
220-EINVAL is returned if a write is attempted to transport when a USB cable
221is not connected.
222