summaryrefslogtreecommitdiff
path: root/patches
diff options
context:
space:
mode:
Diffstat (limited to 'patches')
-rw-r--r--patches/attachment-0003.patch446
-rw-r--r--patches/attachment-0004.patch329
-rw-r--r--patches/attachment-0005.patch50
3 files changed, 825 insertions, 0 deletions
diff --git a/patches/attachment-0003.patch b/patches/attachment-0003.patch
new file mode 100644
index 00000000..35923a90
--- /dev/null
+++ b/patches/attachment-0003.patch
@@ -0,0 +1,446 @@
1>From 35f6f9c86c3dc66f2855b513e389a99bbcbb74c4 Mon Sep 17 00:00:00 2001
2From: Collin McMillan <cmc@nd.edu>
3Date: Mon, 4 Apr 2016 11:33:46 +0200
4Subject: [PATCH] QMI via MBIM
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9Signed-off-by: Bjørn Mork <bjorn@mork.no>
10---
11 build-aux/mbim-codegen/Message.py | 8 ++++----
12 build-aux/mbim-codegen/Struct.py | 8 ++++----
13 data/Makefile.am | 3 ++-
14 src/libmbim-glib/generated/Makefile.am | 18 +++++++++++++++---
15 src/libmbim-glib/libmbim-glib.h | 1 +
16 src/libmbim-glib/mbim-cid.c | 25 +++++++++++++++++++++----
17 src/libmbim-glib/mbim-cid.h | 12 ++++++++++++
18 src/libmbim-glib/mbim-message-private.h | 2 ++
19 src/libmbim-glib/mbim-message.c | 31 +++++++++++++++++++------------
20 src/libmbim-glib/mbim-uuid.c | 18 ++++++++++++++++--
21 src/libmbim-glib/mbim-uuid.h | 11 +++++++++++
22 11 files changed, 107 insertions(+), 30 deletions(-)
23
24diff --git a/build-aux/mbim-codegen/Message.py b/build-aux/mbim-codegen/Message.py
25index aa4e7b7..e66335d 100644
26--- a/build-aux/mbim-codegen/Message.py
27+++ b/build-aux/mbim-codegen/Message.py
28@@ -394,13 +394,13 @@ class Message:
29 inner_template += (' {\n')
30
31 if field['format'] == 'byte-array':
32- inner_template += (' _mbim_message_command_builder_append_byte_array (builder, FALSE, FALSE, ${field}, ${array_size});\n')
33+ inner_template += (' _mbim_message_command_builder_append_byte_array (builder, FALSE, FALSE, TRUE, ${field}, ${array_size});\n')
34 elif field['format'] == 'unsized-byte-array':
35- inner_template += (' _mbim_message_command_builder_append_byte_array (builder, FALSE, FALSE, ${field}, ${field}_size);\n')
36+ inner_template += (' _mbim_message_command_builder_append_byte_array (builder, FALSE, FALSE, FALSE, ${field}, ${field}_size);\n')
37 elif field['format'] == 'ref-byte-array':
38- inner_template += (' _mbim_message_command_builder_append_byte_array (builder, TRUE, TRUE, ${field}, ${field}_size);\n')
39+ inner_template += (' _mbim_message_command_builder_append_byte_array (builder, TRUE, TRUE, TRUE, ${field}, ${field}_size);\n')
40 elif field['format'] == 'ref-byte-array-no-offset':
41- inner_template += (' _mbim_message_command_builder_append_byte_array (builder, FALSE, TRUE, ${field}, ${field}_size);\n')
42+ inner_template += (' _mbim_message_command_builder_append_byte_array (builder, FALSE, TRUE, TRUE, ${field}, ${field}_size);\n')
43 elif field['format'] == 'uuid':
44 inner_template += (' _mbim_message_command_builder_append_uuid (builder, ${field});\n')
45 elif field['format'] == 'guint32':
46diff --git a/build-aux/mbim-codegen/Struct.py b/build-aux/mbim-codegen/Struct.py
47index 495e22f..8797f3a 100644
48--- a/build-aux/mbim-codegen/Struct.py
49+++ b/build-aux/mbim-codegen/Struct.py
50@@ -498,14 +498,14 @@ class Struct:
51 if field['format'] == 'uuid':
52 inner_template = (' _mbim_struct_builder_append_uuid (builder, &(value->${field}));\n')
53 elif field['format'] == 'byte-array':
54- inner_template = (' _mbim_struct_builder_append_byte_array (builder, FALSE, FALSE, value->${field}, ${array_size});\n')
55+ inner_template = (' _mbim_struct_builder_append_byte_array (builder, FALSE, FALSE, TRUE, value->${field}, ${array_size});\n')
56 elif field['format'] == 'unsized-byte-array':
57- inner_template = (' _mbim_struct_builder_append_byte_array (builder, FALSE, FALSE, value->${field}, value->${field}_size);\n')
58+ inner_template = (' _mbim_struct_builder_append_byte_array (builder, FALSE, FALSE, FALSE, value->${field}, value->${field}_size);\n')
59 elif field['format'] == 'ref-byte-array':
60 if 'array-size-field' in field:
61- inner_template = (' _mbim_struct_builder_append_byte_array (builder, TRUE, FALSE, value->${field}, value->${array_size_field});\n')
62+ inner_template = (' _mbim_struct_builder_append_byte_array (builder, TRUE, FALSE, TRUE, value->${field}, value->${array_size_field});\n')
63 else:
64- inner_template = (' _mbim_struct_builder_append_byte_array (builder, TRUE, TRUE, value->${field}, value->${field}_size);\n')
65+ inner_template = (' _mbim_struct_builder_append_byte_array (builder, TRUE, TRUE, TRUE, value->${field}, value->${field}_size);\n')
66 elif field['format'] == 'guint32':
67 inner_template = (' _mbim_struct_builder_append_guint32 (builder, value->${field});\n')
68 elif field['format'] == 'guint32-array':
69diff --git a/data/Makefile.am b/data/Makefile.am
70index 111e028..8c8891a 100644
71--- a/data/Makefile.am
72+++ b/data/Makefile.am
73@@ -10,4 +10,5 @@ EXTRA_DIST = \
74 mbim-service-dss.json \
75 mbim-service-ms-firmware-id.json \
76 mbim-service-ms-host-shutdown.json \
77- mbim-service-proxy-control.json
78+ mbim-service-proxy-control.json \
79+ mbim-service-qmi.json
80diff --git a/src/libmbim-glib/generated/Makefile.am b/src/libmbim-glib/generated/Makefile.am
81index ce81a71..c8b153a 100644
82--- a/src/libmbim-glib/generated/Makefile.am
83+++ b/src/libmbim-glib/generated/Makefile.am
84@@ -12,7 +12,8 @@ GENERATED_H = \
85 mbim-dss.h \
86 mbim-ms-firmware-id.h \
87 mbim-ms-host-shutdown.h \
88- mbim-proxy-control.h
89+ mbim-proxy-control.h \
90+ mbim-qmi.h
91
92 GENERATED_C = \
93 mbim-error-types.c \
94@@ -27,7 +28,8 @@ GENERATED_C = \
95 mbim-dss.c \
96 mbim-ms-firmware-id.c \
97 mbim-ms-host-shutdown.c \
98- mbim-proxy-control.c
99+ mbim-proxy-control.c \
100+ mbim-qmi.c
101
102 GENERATED_SECTIONS = \
103 mbim-basic-connect.sections \
104@@ -39,7 +41,8 @@ GENERATED_SECTIONS = \
105 mbim-dss.sections \
106 mbim-ms-firmware-id.sections \
107 mbim-ms-host-shutdown.sections \
108- mbim-proxy-control.sections
109+ mbim-proxy-control.sections \
110+ mbim-qmi.sections
111
112 # Error types
113 mbim-error-types.h: $(top_srcdir)/src/libmbim-glib/mbim-errors.h $(top_srcdir)/build-aux/templates/mbim-error-types-template.h
114@@ -170,6 +173,15 @@ mbim-proxy-control.h mbim-proxy-control.c mbim-proxy-control.sections: $(top_src
115 --input $(top_srcdir)/data/mbim-service-proxy-control.json \
116 --output mbim-proxy-control
117
118+# QMI-over-MBIM service
119+mbim-qmi.h mbim-qmi.c mbim-qmi.sections: $(top_srcdir)/data/mbim-service-qmi.json $(top_srcdir)/build-aux/mbim-codegen/*.py $(top_srcdir)/build-aux/mbim-codegen/mbim-codegen
120+ $(AM_V_GEN) \
121+ rm -f mbim-qmi.h && \
122+ rm -f mbim-qmi.c && \
123+ $(top_srcdir)/build-aux/mbim-codegen/mbim-codegen \
124+ --input $(top_srcdir)/data/mbim-service-qmi.json \
125+ --output mbim-qmi
126+
127 BUILT_SOURCES = $(GENERATED_H) $(GENERATED_C)
128
129 nodist_libmbim_glib_generated_la_SOURCES = \
130diff --git a/src/libmbim-glib/libmbim-glib.h b/src/libmbim-glib/libmbim-glib.h
131index b41122b..88d0be8 100644
132--- a/src/libmbim-glib/libmbim-glib.h
133+++ b/src/libmbim-glib/libmbim-glib.h
134@@ -48,6 +48,7 @@
135 #include "mbim-dss.h"
136 #include "mbim-ms-firmware-id.h"
137 #include "mbim-ms-host-shutdown.h"
138+#include "mbim-qmi.h"
139
140 /* backwards compatibility */
141 #include "mbim-compat.h"
142diff --git a/src/libmbim-glib/mbim-cid.c b/src/libmbim-glib/mbim-cid.c
143index 50dc4f1..cbfd81e 100644
144--- a/src/libmbim-glib/mbim-cid.c
145+++ b/src/libmbim-glib/mbim-cid.c
146@@ -38,6 +38,9 @@ typedef struct {
147 gboolean notify;
148 } CidConfig;
149
150+/* Note: MBIM_SERVICE_LAST from mbim-uuid.c should probably be visible
151+ * here somehow, since MBIM_SERVICE_QMI must be used in the error checks */
152+
153 /* Note: index of the array is CID-1 */
154 #define MBIM_CID_BASIC_CONNECT_LAST MBIM_CID_BASIC_CONNECT_MULTICARRIER_PROVIDERS
155 static const CidConfig cid_basic_connect_config [MBIM_CID_BASIC_CONNECT_LAST] = {
156@@ -132,6 +135,12 @@ static const CidConfig cid_proxy_control_config [MBIM_CID_PROXY_CONTROL_LAST] =
157 { TRUE, FALSE, FALSE }, /* MBIM_CID_PROXY_CONTROL_CONFIGURATION */
158 };
159
160+/* Note: index of the array is CID-1 */
161+#define MBIM_CID_QMI_LAST MBIM_CID_QMI_MSG
162+static const CidConfig cid_qmi_config [MBIM_CID_QMI_LAST] = {
163+ { TRUE, FALSE, FALSE }, /* MBIM_CID_QMI_MSG */
164+};
165+
166 /**
167 * mbim_cid_can_set:
168 * @service: a #MbimService.
169@@ -149,7 +158,7 @@ mbim_cid_can_set (MbimService service,
170 g_return_val_if_fail (cid > 0, FALSE);
171 /* Known service required */
172 g_return_val_if_fail (service > MBIM_SERVICE_INVALID, FALSE);
173- g_return_val_if_fail (service <= MBIM_SERVICE_PROXY_CONTROL, FALSE);
174+ g_return_val_if_fail (service <= MBIM_SERVICE_QMI, FALSE);
175
176 switch (service) {
177 case MBIM_SERVICE_BASIC_CONNECT:
178@@ -172,6 +181,8 @@ mbim_cid_can_set (MbimService service,
179 return cid_ms_host_shutdown_config[cid - 1].set;
180 case MBIM_SERVICE_PROXY_CONTROL:
181 return cid_proxy_control_config[cid - 1].set;
182+ case MBIM_SERVICE_QMI:
183+ return cid_qmi_config[cid - 1].set;
184 default:
185 g_assert_not_reached ();
186 return FALSE;
187@@ -195,7 +206,7 @@ mbim_cid_can_query (MbimService service,
188 g_return_val_if_fail (cid > 0, FALSE);
189 /* Known service required */
190 g_return_val_if_fail (service > MBIM_SERVICE_INVALID, FALSE);
191- g_return_val_if_fail (service <= MBIM_SERVICE_PROXY_CONTROL, FALSE);
192+ g_return_val_if_fail (service <= MBIM_SERVICE_QMI, FALSE);
193
194 switch (service) {
195 case MBIM_SERVICE_BASIC_CONNECT:
196@@ -218,6 +229,8 @@ mbim_cid_can_query (MbimService service,
197 return cid_ms_host_shutdown_config[cid - 1].query;
198 case MBIM_SERVICE_PROXY_CONTROL:
199 return cid_proxy_control_config[cid - 1].query;
200+ case MBIM_SERVICE_QMI:
201+ return cid_qmi_config[cid - 1].query;
202 default:
203 g_assert_not_reached ();
204 return FALSE;
205@@ -241,7 +254,7 @@ mbim_cid_can_notify (MbimService service,
206 g_return_val_if_fail (cid > 0, FALSE);
207 /* Known service required */
208 g_return_val_if_fail (service > MBIM_SERVICE_INVALID, FALSE);
209- g_return_val_if_fail (service <= MBIM_SERVICE_PROXY_CONTROL, FALSE);
210+ g_return_val_if_fail (service <= MBIM_SERVICE_QMI, FALSE);
211
212 switch (service) {
213 case MBIM_SERVICE_BASIC_CONNECT:
214@@ -264,6 +277,8 @@ mbim_cid_can_notify (MbimService service,
215 return cid_ms_host_shutdown_config[cid - 1].notify;
216 case MBIM_SERVICE_PROXY_CONTROL:
217 return cid_proxy_control_config[cid - 1].notify;
218+ case MBIM_SERVICE_QMI:
219+ return cid_qmi_config[cid - 1].notify;
220 default:
221 g_assert_not_reached ();
222 return FALSE;
223@@ -288,7 +303,7 @@ mbim_cid_get_printable (MbimService service,
224 g_return_val_if_fail (cid > 0, NULL);
225 /* Known service required */
226 g_return_val_if_fail (service > MBIM_SERVICE_INVALID, NULL);
227- g_return_val_if_fail (service <= MBIM_SERVICE_PROXY_CONTROL, NULL);
228+ g_return_val_if_fail (service <= MBIM_SERVICE_QMI, NULL);
229
230 switch (service) {
231 case MBIM_SERVICE_BASIC_CONNECT:
232@@ -311,6 +326,8 @@ mbim_cid_get_printable (MbimService service,
233 return mbim_cid_ms_host_shutdown_get_string (cid);
234 case MBIM_SERVICE_PROXY_CONTROL:
235 return mbim_cid_proxy_control_get_string (cid);
236+ case MBIM_SERVICE_QMI:
237+ return mbim_cid_qmi_get_string (cid);
238 default:
239 g_assert_not_reached ();
240 return FALSE;
241diff --git a/src/libmbim-glib/mbim-cid.h b/src/libmbim-glib/mbim-cid.h
242index 3315340..36930cd 100644
243--- a/src/libmbim-glib/mbim-cid.h
244+++ b/src/libmbim-glib/mbim-cid.h
245@@ -219,6 +219,18 @@ typedef enum {
246 MBIM_CID_PROXY_CONTROL_CONFIGURATION = 1
247 } MbimCidProxyControl;
248
249+/**
250+ * MbimCidQmi:
251+ * @MBIM_CID_QMI_UNKNOWN: Unknown command.
252+ * @MBIM_CID_QMI_MSG: Configuration.
253+ *
254+ * MBIM commands in the %MBIM_SERVICE_QMI service.
255+ */
256+typedef enum {
257+ MBIM_CID_QMI_UNKNOWN = 0,
258+ MBIM_CID_QMI_MSG = 1
259+} MbimCidQmi;
260+
261 /* Command helpers */
262
263 gboolean mbim_cid_can_set (MbimService service,
264diff --git a/src/libmbim-glib/mbim-message-private.h b/src/libmbim-glib/mbim-message-private.h
265index b5606e0..0459d00 100644
266--- a/src/libmbim-glib/mbim-message-private.h
267+++ b/src/libmbim-glib/mbim-message-private.h
268@@ -177,6 +177,7 @@ GByteArray *_mbim_struct_builder_complete (MbimStructBuilder
269 void _mbim_struct_builder_append_byte_array (MbimStructBuilder *builder,
270 gboolean with_offset,
271 gboolean with_length,
272+ gboolean permit_padding,
273 const guint8 *buffer,
274 guint32 buffer_len);
275 void _mbim_struct_builder_append_uuid (MbimStructBuilder *builder,
276@@ -225,6 +226,7 @@ MbimMessage *_mbim_message_command_builder_complete (M
277 void _mbim_message_command_builder_append_byte_array (MbimMessageCommandBuilder *builder,
278 gboolean with_offset,
279 gboolean with_length,
280+ gboolean permit_padding,
281 const guint8 *buffer,
282 guint32 buffer_len);
283 void _mbim_message_command_builder_append_uuid (MbimMessageCommandBuilder *builder,
284diff --git a/src/libmbim-glib/mbim-message.c b/src/libmbim-glib/mbim-message.c
285index b625ee5..7ab28f0 100644
286--- a/src/libmbim-glib/mbim-message.c
287+++ b/src/libmbim-glib/mbim-message.c
288@@ -492,6 +492,7 @@ void
289 _mbim_struct_builder_append_byte_array (MbimStructBuilder *builder,
290 gboolean with_offset,
291 gboolean with_length,
292+ gboolean permit_padding,
293 const guint8 *buffer,
294 guint32 buffer_len)
295 {
296@@ -501,12 +502,14 @@ _mbim_struct_builder_append_byte_array (MbimStructBuilder *builder,
297 */
298 if (!with_offset && !with_length) {
299 g_byte_array_append (builder->fixed_buffer, buffer, buffer_len);
300- while (buffer_len % 4 != 0) {
301- const guint8 padding = 0;
302-
303- g_byte_array_append (builder->fixed_buffer, &padding, 1);
304- buffer_len++;
305- }
306+ if(permit_padding) {
307+ while (buffer_len % 4 != 0) {
308+ const guint8 padding = 0;
309+
310+ g_byte_array_append (builder->fixed_buffer, &padding, 1);
311+ buffer_len++;
312+ }
313+ }
314 return;
315 }
316
317@@ -550,12 +553,15 @@ _mbim_struct_builder_append_byte_array (MbimStructBuilder *builder,
318 if (buffer_len) {
319 g_byte_array_append (builder->variable_buffer, (const guint8 *)buffer, (guint)buffer_len);
320
321- while (buffer_len % 4 != 0) {
322- const guint8 padding = 0;
323+ /* Note: adding zero padding causes trouble for QMI service */
324+ if(permit_padding) {
325+ while (buffer_len % 4 != 0) {
326+ const guint8 padding = 0;
327
328- g_byte_array_append (builder->variable_buffer, &padding, 1);
329- buffer_len++;
330- }
331+ g_byte_array_append (builder->variable_buffer, &padding, 1);
332+ buffer_len++;
333+ }
334+ }
335 }
336 }
337
338@@ -824,10 +830,11 @@ void
339 _mbim_message_command_builder_append_byte_array (MbimMessageCommandBuilder *builder,
340 gboolean with_offset,
341 gboolean with_length,
342+ gboolean permit_padding,
343 const guint8 *buffer,
344 guint32 buffer_len)
345 {
346- _mbim_struct_builder_append_byte_array (builder->contents_builder, with_offset, with_length, buffer, buffer_len);
347+ _mbim_struct_builder_append_byte_array (builder->contents_builder, with_offset, with_length, permit_padding, buffer, buffer_len);
348 }
349
350 void
351diff --git a/src/libmbim-glib/mbim-uuid.c b/src/libmbim-glib/mbim-uuid.c
352index 6497645..cdc9ba3 100644
353--- a/src/libmbim-glib/mbim-uuid.c
354+++ b/src/libmbim-glib/mbim-uuid.c
355@@ -38,7 +38,7 @@
356 * This section defines the data type for unique identifiers.
357 */
358
359-#define MBIM_SERVICE_LAST MBIM_SERVICE_PROXY_CONTROL
360+#define MBIM_SERVICE_LAST MBIM_SERVICE_QMI
361
362 /*****************************************************************************/
363
364@@ -229,6 +229,15 @@ static const MbimUuid uuid_proxy_control = {
365 .e = { 0xd7, 0x1d , 0xbe, 0xfb, 0xb3, 0x9b }
366 };
367
368+/* Note: this UUID is likely to work only for Sierra modems */
369+static const MbimUuid uuid_qmi = {
370+ .a = { 0xd1, 0xa3, 0x0b, 0xc2 },
371+ .b = { 0xf9, 0x7a },
372+ .c = { 0x6e, 0x43 },
373+ .d = { 0xbf, 0x65 },
374+ .e = { 0xc7, 0xe2 , 0x4f, 0xb0, 0xf0, 0xd3 }
375+};
376+
377 static GList *mbim_custom_service_list = NULL;
378
379 typedef struct {
380@@ -367,7 +376,7 @@ mbim_uuid_from_service (MbimService service)
381 GList *l;
382
383 g_return_val_if_fail (service >= MBIM_SERVICE_INVALID &&
384- (service <= MBIM_SERVICE_PROXY_CONTROL ||
385+ (service <= MBIM_SERVICE_LAST ||
386 mbim_service_id_is_custom (service)),
387 &uuid_invalid);
388
389@@ -394,6 +403,8 @@ mbim_uuid_from_service (MbimService service)
390 return &uuid_ms_host_shutdown;
391 case MBIM_SERVICE_PROXY_CONTROL:
392 return &uuid_proxy_control;
393+ case MBIM_SERVICE_QMI:
394+ return &uuid_qmi;
395 default:
396 for (l = mbim_custom_service_list; l != NULL; l = l->next) {
397 if (service == ((MbimCustomService *)l->data)->service_id)
398@@ -446,6 +457,9 @@ mbim_uuid_to_service (const MbimUuid *uuid)
399 if (mbim_uuid_cmp (uuid, &uuid_proxy_control))
400 return MBIM_SERVICE_PROXY_CONTROL;
401
402+ if (mbim_uuid_cmp (uuid, &uuid_qmi))
403+ return MBIM_SERVICE_QMI;
404+
405 for (l = mbim_custom_service_list; l != NULL; l = l->next) {
406 if (mbim_uuid_cmp (&((MbimCustomService *)l->data)->uuid, uuid))
407 return ((MbimCustomService *)l->data)->service_id;
408diff --git a/src/libmbim-glib/mbim-uuid.h b/src/libmbim-glib/mbim-uuid.h
409index 91def98..d42a256 100644
410--- a/src/libmbim-glib/mbim-uuid.h
411+++ b/src/libmbim-glib/mbim-uuid.h
412@@ -71,6 +71,7 @@ gboolean mbim_uuid_from_printable (const gchar *str,
413 * @MBIM_SERVICE_MS_FIRMWARE_ID: Microsoft Firmware ID service.
414 * @MBIM_SERVICE_MS_HOST_SHUTDOWN: Microsoft Host Shutdown service.
415 * @MBIM_SERVICE_PROXY_CONTROL: Proxy Control service.
416+ * @MBIM_SERVICE_QMI: QMI-over-MBIM service.
417 *
418 * Enumeration of the generic MBIM services.
419 */
420@@ -86,6 +87,7 @@ typedef enum {
421 MBIM_SERVICE_MS_FIRMWARE_ID = 8,
422 MBIM_SERVICE_MS_HOST_SHUTDOWN = 9,
423 MBIM_SERVICE_PROXY_CONTROL = 10,
424+ MBIM_SERVICE_QMI = 11
425 /* Note: update MBIM_SERVICE_LAST when a new value is added */
426 } MbimService;
427
428@@ -188,6 +190,15 @@ typedef enum {
429 */
430 #define MBIM_UUID_PROXY_CONTROL mbim_uuid_from_service (MBIM_SERVICE_PROXY_CONTROL)
431
432+/**
433+ * MBIM_UUID_QMI:
434+ *
435+ * Get the UUID of the %MBIM_SERVICE_QMI service.
436+ *
437+ * Returns: (transfer none): a #MbimUuid.
438+ */
439+#define MBIM_UUID_QMI mbim_uuid_from_service (MBIM_SERVICE_QMI)
440+
441 const gchar *mbim_service_lookup_name (guint service);
442
443 guint mbim_register_custom_service (const MbimUuid *uuid,
444--
4452.1.4
446
diff --git a/patches/attachment-0004.patch b/patches/attachment-0004.patch
new file mode 100644
index 00000000..b1110feb
--- /dev/null
+++ b/patches/attachment-0004.patch
@@ -0,0 +1,329 @@
1>From 4ffa5693bcaf283bc3c8ea7808226eb6e92aaaf5 Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Bj=C3=B8rn=20Mork?= <bjorn@mork.no>
3Date: Mon, 4 Apr 2016 14:44:01 +0200
4Subject: [PATCH 1/2] libqmi: support MBIM EXT_QMUX service
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9Signed-off-by: Bjørn Mork <bjorn@mork.no>
10---
11 configure.ac | 13 ++++
12 src/libqmi-glib/Makefile.am | 4 +-
13 src/libqmi-glib/qmi-device.c | 156 ++++++++++++++++++++++++++++++++++++++++++-
14 src/libqmi-glib/qmi-device.h | 4 +-
15 4 files changed, 172 insertions(+), 5 deletions(-)
16
17diff --git a/configure.ac b/configure.ac
18index 3e05993..fe6225e 100644
19--- a/configure.ac
20+++ b/configure.ac
21@@ -95,6 +95,18 @@ fi
22
23 AM_CONDITIONAL([QMI_USERNAME_ENABLED], [test "x$QMI_USERNAME_ENABLED" = "xyes"])
24
25+# MBIM QMUX service support
26+AC_ARG_ENABLE(mbim-qmux,
27+ AS_HELP_STRING([--enable-mbim-qmux], [support QMI over MBIM QMUX service]))
28+if test -n "$enable_mbim_qmux"; then
29+ PKG_CHECK_MODULES(MBIM, mbim-glib >= 1.13)
30+ MBIM_CFLAGS="$MBIM_CFLAGS -DMBIM_QMUX"
31+ AC_SUBST(MBIM_CFLAGS)
32+ AC_SUBST(MBIM_LIBS)
33+fi
34+
35+AM_CONDITIONAL(MBIM_QMUX, [test -n "$MBIM_CFLAGS"])
36+
37 # udev base directory
38 AC_ARG_WITH(udev-base-dir, AS_HELP_STRING([--with-udev-base-dir=DIR], [where udev base directory is]))
39 if test -n "$with_udev_base_dir" ; then
40@@ -146,4 +158,5 @@ echo "
41 udev base directory: ${UDEV_BASE_DIR}
42 Documentation: ${enable_gtk_doc}
43 QMI username: ${QMI_USERNAME_ENABLED} (${QMI_USERNAME})
44+ QMUX over MBIM: ${enable_mbim_qmux}
45 "
46diff --git a/src/libqmi-glib/Makefile.am b/src/libqmi-glib/Makefile.am
47index b24e3ae..6ff4e66 100644
48--- a/src/libqmi-glib/Makefile.am
49+++ b/src/libqmi-glib/Makefile.am
50@@ -5,6 +5,7 @@ lib_LTLIBRARIES = libqmi-glib.la
51
52 libqmi_glib_la_CPPFLAGS = \
53 $(GLIB_CFLAGS) \
54+ $(MBIM_CFLAGS) \
55 -I$(top_srcdir) \
56 -I$(top_builddir) \
57 -I$(top_srcdir)/src/libqmi-glib \
58@@ -39,7 +40,8 @@ libqmi_glib_la_SOURCES = \
59
60 libqmi_glib_la_LIBADD = \
61 ${top_builddir}/src/libqmi-glib/generated/libqmi-glib-generated.la \
62- $(GLIB_LIBS)
63+ $(GLIB_LIBS) \
64+ $(MBIM_LIBS)
65
66 libqmi_glib_la_LDFLAGS = \
67 -version-info $(QMI_GLIB_LT_CURRENT):$(QMI_GLIB_LT_REVISION):$(QMI_GLIB_LT_AGE)
68diff --git a/src/libqmi-glib/qmi-device.c b/src/libqmi-glib/qmi-device.c
69index c4abbbc..6c46bca 100644
70--- a/src/libqmi-glib/qmi-device.c
71+++ b/src/libqmi-glib/qmi-device.c
72@@ -32,6 +32,10 @@
73 #include <gio/gunixoutputstream.h>
74 #include <gio/gunixsocketaddress.h>
75
76+#ifdef MBIM_QMUX
77+#include <libmbim-glib.h>
78+#endif
79+
80 #include "qmi-device.h"
81 #include "qmi-message.h"
82 #include "qmi-ctl.h"
83@@ -92,6 +96,10 @@ struct _QmiDevicePrivate {
84 gchar *path_display;
85 gboolean no_file_check;
86 gchar *proxy_path;
87+ gboolean mbim_qmux;
88+#ifdef MBIM_QMUX
89+ MbimDevice *mbimdev;
90+#endif
91
92 /* WWAN interface */
93 gboolean no_wwan_check;
94@@ -1689,7 +1697,6 @@ input_ready_cb (GInputStream *istream,
95 self->priv->buffer = g_byte_array_sized_new (r);
96 g_byte_array_append (self->priv->buffer, buffer, r);
97
98- /* Try to parse input messages */
99 parse_response (self);
100
101 return TRUE;
102@@ -2134,6 +2141,56 @@ internal_proxy_open_ready (QmiClientCtl *client_ctl,
103 device_open_context_step (ctx);
104 }
105
106+#ifdef MBIM_QMUX
107+static void
108+mbim_device_open_ready (MbimDevice *dev,
109+ GAsyncResult *res,
110+ DeviceOpenContext *ctx)
111+{
112+ GError *error = NULL;
113+
114+ if (!mbim_device_open_finish (dev, res, &error)) {
115+ g_simple_async_result_take_error (ctx->result, error);
116+ device_open_context_complete_and_free (ctx);
117+ return;
118+ }
119+ g_debug ("[%s] MBIM device Open..",
120+ ctx->self->priv->path_display);
121+
122+ /* Go on */
123+ ctx->step++;
124+ device_open_context_step (ctx);
125+ return;
126+}
127+
128+static void
129+mbim_device_new_ready (GObject *source,
130+ GAsyncResult *res,
131+ DeviceOpenContext *ctx)
132+{
133+ MbimDeviceOpenFlags open_flags = MBIM_DEVICE_OPEN_FLAGS_NONE;
134+ GError *error = NULL;
135+ MbimDevice *device;
136+
137+ if (ctx->flags & QMI_DEVICE_OPEN_FLAGS_PROXY)
138+ open_flags |= MBIM_DEVICE_OPEN_FLAGS_PROXY;
139+ device = mbim_device_new_finish (res, &error);
140+ if (!device) {
141+ g_simple_async_result_take_error (ctx->result, error);
142+ device_open_context_complete_and_free (ctx);
143+ return;
144+ }
145+ ctx->self->priv->mbimdev = device;
146+
147+ mbim_device_open_full(device,
148+ open_flags,
149+ 30,
150+ ctx->cancellable,
151+ (GAsyncReadyCallback)mbim_device_open_ready,
152+ ctx);
153+}
154+#endif
155+
156 static void
157 create_iostream_ready (QmiDevice *self,
158 GAsyncResult *res,
159@@ -2166,6 +2223,20 @@ device_open_context_step (DeviceOpenContext *ctx)
160 /* Fall down */
161
162 case DEVICE_OPEN_CONTEXT_STEP_CREATE_IOSTREAM:
163+#ifdef MBIM_QMUX
164+ if (ctx->flags & QMI_DEVICE_OPEN_FLAGS_MBIM) {
165+ GFile *file;
166+
167+ ctx->self->priv->mbim_qmux = TRUE;
168+ file = g_file_new_for_path (ctx->self->priv->path);
169+ mbim_device_new (file,
170+ ctx->cancellable,
171+ (GAsyncReadyCallback)mbim_device_new_ready,
172+ ctx);
173+ g_object_unref (file);
174+ return;
175+ }
176+#endif
177 create_iostream (ctx->self,
178 !!(ctx->flags & QMI_DEVICE_OPEN_FLAGS_PROXY),
179 (GAsyncReadyCallback)create_iostream_ready,
180@@ -2174,7 +2245,8 @@ device_open_context_step (DeviceOpenContext *ctx)
181
182 case DEVICE_OPEN_CONTEXT_STEP_FLAGS_PROXY:
183 /* Initialize communication with proxy? */
184- if (ctx->flags & QMI_DEVICE_OPEN_FLAGS_PROXY) {
185+ if (ctx->flags & QMI_DEVICE_OPEN_FLAGS_PROXY &&
186+ !(ctx->flags & QMI_DEVICE_OPEN_FLAGS_MBIM)) {
187 QmiMessageCtlInternalProxyOpenInput *input;
188
189 input = qmi_message_ctl_internal_proxy_open_input_new ();
190@@ -2369,6 +2441,21 @@ destroy_iostream (QmiDevice *self,
191 return TRUE;
192 }
193
194+#ifdef MBIM_QMUX
195+static void
196+mbim_device_close_ready (MbimDevice *dev,
197+ GAsyncResult *res)
198+{
199+ GError *error = NULL;
200+
201+ if (!mbim_device_close_finish (dev, res, &error)) {
202+ g_printerr ("error: couldn't close device: %s", error->message);
203+ g_error_free (error);
204+ } else
205+ g_debug ("Device closed");
206+}
207+#endif
208+
209 /**
210 * qmi_device_close:
211 * @self: a #QmiDevice
212@@ -2386,6 +2473,15 @@ qmi_device_close (QmiDevice *self,
213 {
214 g_return_val_if_fail (QMI_IS_DEVICE (self), FALSE);
215
216+#ifdef MBIM_QMUX
217+ if (self->priv->mbim_qmux)
218+ mbim_device_close (self->priv->mbimdev,
219+ 15,
220+ NULL,
221+ (GAsyncReadyCallback) mbim_device_close_ready,
222+ NULL);
223+ else
224+#endif
225 if (!destroy_iostream (self, error)) {
226 g_prefix_error (error, "Cannot close QMI device: ");
227 return FALSE;
228@@ -2394,6 +2490,42 @@ qmi_device_close (QmiDevice *self,
229 return TRUE;
230 }
231
232+#ifdef MBIM_QMUX
233+static void
234+mbim_device_command_ready (MbimDevice *dev,
235+ GAsyncResult *res,
236+ QmiDevice *qmidev)
237+{
238+ MbimMessage *response;
239+ GError *error = NULL;
240+ const guint8 *buf;
241+ guint32 len;
242+
243+ response = mbim_device_command_finish (dev, res, &error);
244+ if (!response || !mbim_message_response_get_result (response, MBIM_MESSAGE_TYPE_COMMAND_DONE, &error)) {
245+ g_prefix_error (&error, "MBIM error: ");
246+ // transaction_complete_and_free (tr, NULL, error);
247+ g_error_free (error);
248+ mbim_message_unref (response);
249+ return;
250+ }
251+
252+ g_debug ("[%s] Received MBIM message\n", qmidev->priv->path_display);
253+
254+
255+ /* get the information buffer */
256+ buf = mbim_message_command_done_get_raw_information_buffer (response, &len);
257+ if (!G_UNLIKELY (qmidev->priv->buffer))
258+ qmidev->priv->buffer = g_byte_array_sized_new (len);
259+ g_byte_array_append (qmidev->priv->buffer, buf, len);
260+
261+ /* and parse it as QMI */
262+ parse_response(qmidev);
263+ mbim_message_unref (response);
264+ return;
265+}
266+#endif
267+
268 /*****************************************************************************/
269 /* Command */
270
271@@ -2462,7 +2594,7 @@ qmi_device_command (QmiDevice *self,
272 tr = transaction_new (self, message, cancellable, callback, user_data);
273
274 /* Device must be open */
275- if (!self->priv->istream || !self->priv->ostream) {
276+ if ((!self->priv->istream || !self->priv->ostream) && !self->priv->mbim_qmux) {
277 error = g_error_new (QMI_CORE_ERROR,
278 QMI_CORE_ERROR_WRONG_STATE,
279 "Device must be open to send commands");
280@@ -2531,6 +2663,24 @@ qmi_device_command (QmiDevice *self,
281 g_free (printable);
282 }
283
284+#ifdef MBIM_QMUX
285+ /* wrap QMUX in MBIM? */
286+ if (self->priv->mbim_qmux) {
287+ MbimMessage *mbim;
288+
289+ mbim = (mbim_message_qmi_msg_set_new (raw_message_len, raw_message, &error));
290+ mbim_device_command (self->priv->mbimdev,
291+ mbim,
292+ 30,
293+ NULL, /* cancellable */
294+ (GAsyncReadyCallback)mbim_device_command_ready,
295+ self);
296+ g_debug ("[%s] Message sent as MBIM\n", self->priv->path_display);
297+
298+ /* FIXME: check errors, set proper MBIM TID */
299+ return;
300+ }
301+#endif
302 if (!g_output_stream_write_all (self->priv->ostream,
303 raw_message,
304 raw_message_len,
305diff --git a/src/libqmi-glib/qmi-device.h b/src/libqmi-glib/qmi-device.h
306index 58651e1..957efac 100644
307--- a/src/libqmi-glib/qmi-device.h
308+++ b/src/libqmi-glib/qmi-device.h
309@@ -97,6 +97,7 @@ gboolean qmi_device_is_open (QmiDevice *self);
310 * @QMI_DEVICE_OPEN_FLAGS_NET_QOS_HEADER: set network port to transmit/receive QoS headers; mutually exclusive with @QMI_DEVICE_OPEN_FLAGS_NET_NO_QOS_HEADER
311 * @QMI_DEVICE_OPEN_FLAGS_NET_NO_QOS_HEADER: set network port to not transmit/receive QoS headers; mutually exclusive with @QMI_DEVICE_OPEN_FLAGS_NET_QOS_HEADER
312 * @QMI_DEVICE_OPEN_FLAGS_PROXY: Try to open the port through the 'qmi-proxy'.
313+ * @QMI_DEVICE_OPEN_FLAGS_MBIM: open an MBIM port with QMUX tunneling service
314 *
315 * Flags to specify which actions to be performed when the device is open.
316 */
317@@ -108,7 +109,8 @@ typedef enum {
318 QMI_DEVICE_OPEN_FLAGS_NET_RAW_IP = 1 << 3,
319 QMI_DEVICE_OPEN_FLAGS_NET_QOS_HEADER = 1 << 4,
320 QMI_DEVICE_OPEN_FLAGS_NET_NO_QOS_HEADER = 1 << 5,
321- QMI_DEVICE_OPEN_FLAGS_PROXY = 1 << 6
322+ QMI_DEVICE_OPEN_FLAGS_PROXY = 1 << 6,
323+ QMI_DEVICE_OPEN_FLAGS_MBIM = 1 << 7
324 } QmiDeviceOpenFlags;
325
326 void qmi_device_open (QmiDevice *self,
327--
3282.1.4
329
diff --git a/patches/attachment-0005.patch b/patches/attachment-0005.patch
new file mode 100644
index 00000000..ef455bce
--- /dev/null
+++ b/patches/attachment-0005.patch
@@ -0,0 +1,50 @@
1>From cfa1df1527d81bf8cf3deeaf9ce341cd6c2a954c Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Bj=C3=B8rn=20Mork?= <bjorn@mork.no>
3Date: Mon, 4 Apr 2016 14:47:01 +0200
4Subject: [PATCH 2/2] qmicli: support MBIM EXT_QMUX devices
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9Signed-off-by: Bjørn Mork <bjorn@mork.no>
10---
11 src/qmicli/qmicli.c | 9 ++++++++-
12 1 file changed, 8 insertions(+), 1 deletion(-)
13
14diff --git a/src/qmicli/qmicli.c b/src/qmicli/qmicli.c
15index 85c2faa..c591da2 100644
16--- a/src/qmicli/qmicli.c
17+++ b/src/qmicli/qmicli.c
18@@ -56,6 +56,7 @@ static gboolean device_open_version_info_flag;
19 static gboolean device_open_sync_flag;
20 static gchar *device_open_net_str;
21 static gboolean device_open_proxy_flag;
22+static gboolean device_open_mbim_flag;
23 static gchar *client_cid_str;
24 static gboolean client_no_release_cid_flag;
25 static gboolean verbose_flag;
26@@ -99,6 +100,10 @@ static GOptionEntry main_entries[] = {
27 "Request to use the 'qmi-proxy' proxy",
28 NULL
29 },
30+ { "device-open-mbim", 0, 0, G_OPTION_ARG_NONE, &device_open_mbim_flag,
31+ "Open an MBIM device with EXT_QMUX support",
32+ NULL
33+ },
34 { "device-open-net", 0, 0, G_OPTION_ARG_STRING, &device_open_net_str,
35 "Open device with specific link protocol and QoS flags",
36 "[net-802-3|net-raw-ip|net-qos-header|net-no-qos-header]"
37@@ -603,7 +608,9 @@ device_new_ready (GObject *unused,
38 open_flags |= QMI_DEVICE_OPEN_FLAGS_SYNC;
39 if (device_open_proxy_flag)
40 open_flags |= QMI_DEVICE_OPEN_FLAGS_PROXY;
41- if (device_open_net_str)
42+ if (device_open_mbim_flag)
43+ open_flags |= QMI_DEVICE_OPEN_FLAGS_MBIM;
44+ if (device_open_net_str)
45 if (!qmicli_read_net_open_flags_from_string (device_open_net_str, &open_flags))
46 exit (EXIT_FAILURE);
47
48--
492.1.4
50