QMI: add uqmi tool with all depends
[tomato.git] / release / src / router / uqmi / uqmi.h
blob5cd3bff06e9ae18eccbf89f4d356e75c351f58ae
1 /*
2 * uqmi -- tiny QMI support implementation
4 * Copyright (C) 2014-2015 Felix Fietkau <nbd@openwrt.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301 USA.
22 #ifndef __UQMI_H
23 #define __UQMI_H
25 #include <stdbool.h>
27 #include <libubox/uloop.h>
28 #include <libubox/ustream.h>
30 #include "qmi-message.h"
32 #ifdef DEBUG_PACKET
33 void dump_packet(const char *prefix, void *ptr, int len);
34 #else
35 static inline void dump_packet(const char *prefix, void *ptr, int len)
38 #endif
40 #define __qmi_services \
41 __qmi_service(QMI_SERVICE_WDS), \
42 __qmi_service(QMI_SERVICE_DMS), \
43 __qmi_service(QMI_SERVICE_NAS), \
44 __qmi_service(QMI_SERVICE_QOS), \
45 __qmi_service(QMI_SERVICE_WMS), \
46 __qmi_service(QMI_SERVICE_PDS), \
47 __qmi_service(QMI_SERVICE_AUTH), \
48 __qmi_service(QMI_SERVICE_AT), \
49 __qmi_service(QMI_SERVICE_VOICE), \
50 __qmi_service(QMI_SERVICE_CAT2), \
51 __qmi_service(QMI_SERVICE_UIM), \
52 __qmi_service(QMI_SERVICE_PBM), \
53 __qmi_service(QMI_SERVICE_LOC), \
54 __qmi_service(QMI_SERVICE_SAR), \
55 __qmi_service(QMI_SERVICE_RMTFS), \
56 __qmi_service(QMI_SERVICE_CAT), \
57 __qmi_service(QMI_SERVICE_RMS), \
58 __qmi_service(QMI_SERVICE_OMA), \
59 __qmi_service(QMI_SERVICE_WDA)
61 #define __qmi_service(_n) __##_n
62 enum {
63 __qmi_services,
64 __QMI_SERVICE_LAST
66 #undef __qmi_service
68 struct qmi_dev;
69 struct qmi_request;
70 struct qmi_msg;
72 typedef void (*request_cb)(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg);
74 struct qmi_dev {
75 struct ustream_fd sf;
77 struct list_head req;
79 struct {
80 bool connected;
81 uint8_t client_id;
82 uint16_t tid;
83 } service_data[__QMI_SERVICE_LAST];
85 uint32_t service_connected;
86 uint32_t service_keep_cid;
87 uint32_t service_release_cid;
89 uint8_t ctl_tid;
92 struct qmi_request {
93 struct list_head list;
95 request_cb cb;
97 bool *complete;
98 bool pending;
99 bool no_error_cb;
100 uint8_t service;
101 uint16_t tid;
102 int ret;
105 extern bool cancel_all_requests;
106 int qmi_device_open(struct qmi_dev *qmi, const char *path);
107 void qmi_device_close(struct qmi_dev *qmi);
109 int qmi_request_start(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, request_cb cb);
110 void qmi_request_cancel(struct qmi_dev *qmi, struct qmi_request *req);
111 int qmi_request_wait(struct qmi_dev *qmi, struct qmi_request *req);
113 static inline bool qmi_request_pending(struct qmi_request *req)
115 return req->pending;
118 int qmi_service_connect(struct qmi_dev *qmi, QmiService svc, int client_id);
119 int qmi_service_get_client_id(struct qmi_dev *qmi, QmiService svc);
120 int qmi_service_release_client_id(struct qmi_dev *qmi, QmiService svc);
121 QmiService qmi_service_get_by_name(const char *str);
122 const char *qmi_get_error_str(int code);
124 #endif