add wda commands for setting/getting wireless data mode
authorFelix Fietkau <nbd@openwrt.org>
Tue, 25 Nov 2014 20:22:16 +0000 (21:22 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Tue, 25 Nov 2014 20:22:16 +0000 (21:22 +0100)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
CMakeLists.txt
commands-wda.c [new file with mode: 0644]
commands-wda.h [new file with mode: 0644]
commands.c
commands.h
dev.c
main.c
qmi-enums-wda.h [new file with mode: 0644]
qmi-message.h
uqmi.h

index fcfd772a4e96581a02da8f8806f33c7fc5c7157d..3f676525473e48fff5bd5e8fe8cf365b3899c680 100644 (file)
@@ -20,7 +20,7 @@ ENDIF()
 
 SET(service_headers)
 SET(service_sources)
-FOREACH(service ctl dms nas pds wds wms)
+FOREACH(service ctl dms nas pds wds wms wda)
        ADD_CUSTOM_COMMAND(
                OUTPUT qmi-message-${service}.h
                COMMAND ./data/gen-header.pl ${service}_ ./data/qmi-service-${service}.json > qmi-message-${service}.h
diff --git a/commands-wda.c b/commands-wda.c
new file mode 100644 (file)
index 0000000..0ca32b4
--- /dev/null
@@ -0,0 +1,58 @@
+#include <stdlib.h>
+
+#include "qmi-message.h"
+
+static const struct {
+       const char *name;
+       QmiWdaLinkLayerProtocol val;
+} link_modes[] = {
+       { "802.3", QMI_WDA_LINK_LAYER_PROTOCOL_802_3 },
+       { "raw-ip", QMI_WDA_LINK_LAYER_PROTOCOL_RAW_IP },
+};
+
+#define cmd_wda_set_data_format_cb no_cb
+
+static enum qmi_cmd_result
+cmd_wda_set_data_format_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg)
+{
+       struct qmi_wda_set_data_format_request data_req = {};
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(link_modes); i++) {
+               if (strcasecmp(link_modes[i].name, arg) != 0)
+                       continue;
+
+               qmi_set(&data_req, link_layer_protocol, link_modes[i].val);
+               qmi_set_wda_set_data_format_request(msg, &data_req);
+               return QMI_CMD_REQUEST;
+       }
+
+       uqmi_add_error("Invalid auth mode (valid: 802.3, raw-ip)");
+       return QMI_CMD_EXIT;
+}
+
+static void
+cmd_wda_get_data_format_cb(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg)
+{
+       struct qmi_wda_get_data_format_response res;
+       const char *name = "unknown";
+       int i;
+
+       qmi_parse_wda_get_data_format_response(msg, &res);
+       for (i = 0; i < ARRAY_SIZE(link_modes); i++) {
+               if (link_modes[i].val != res.data.link_layer_protocol)
+                       continue;
+
+               name = link_modes[i].name;
+               break;
+       }
+
+       blobmsg_add_string(&status, NULL, name);
+}
+
+static enum qmi_cmd_result
+cmd_wda_get_data_format_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg)
+{
+       qmi_set_wda_get_data_format_request(msg);
+       return QMI_CMD_REQUEST;
+}
diff --git a/commands-wda.h b/commands-wda.h
new file mode 100644 (file)
index 0000000..e51452c
--- /dev/null
@@ -0,0 +1,9 @@
+#define __uqmi_wda_commands \
+       __uqmi_command(wda_set_data_format, wda-set-data-format, required, QMI_SERVICE_WDA), \
+       __uqmi_command(wda_get_data_format, wda-get-data-format, no, QMI_SERVICE_WDA)
+
+
+#define wda_helptext \
+               "  --wda-set-data-format <type>:     Set data format (type: 802.3|raw-ip)\n" \
+               "  --wda-get-data-format:            Get data format\n" \
+
index 198b6abacd1c0637d4cd9ce1b81c20d370f5a1e5..c87714dee5c5833232eab492bda46116b723b469 100644 (file)
@@ -139,6 +139,7 @@ cmd_ctl_set_data_format_prepare(struct qmi_dev *qmi, struct qmi_request *req, st
 #include "commands-dms.c"
 #include "commands-nas.c"
 #include "commands-wms.c"
+#include "commands-wda.c"
 
 #define __uqmi_command(_name, _optname, _arg, _type) \
        [__UQMI_COMMAND_##_name] = { \
index 9d492e712aab039897d924a32a51d6051465703c..312e897f8d158e98fb3c828f5efc3e8bc34cb26b 100644 (file)
@@ -6,6 +6,7 @@
 #include "commands-dms.h"
 #include "commands-nas.h"
 #include "commands-wms.h"
+#include "commands-wda.h"
 
 enum qmi_cmd_result {
        QMI_CMD_DONE,
@@ -38,7 +39,8 @@ struct uqmi_cmd {
        __uqmi_wds_commands, \
        __uqmi_dms_commands, \
        __uqmi_nas_commands, \
-       __uqmi_wms_commands
+       __uqmi_wms_commands, \
+       __uqmi_wda_commands
 
 #define __uqmi_command(_name, _optname, _arg, _option) __UQMI_COMMAND_##_name
 enum uqmi_command {
diff --git a/dev.c b/dev.c
index 4e48179356c70a70fa2bb3dee7e1e4b15a8c77fb..a586157a996649c70df16bd86bfdce04fb1f2dbb 100644 (file)
--- a/dev.c
+++ b/dev.c
@@ -342,6 +342,7 @@ QmiService qmi_service_get_by_name(const char *str)
                { "pds", QMI_SERVICE_PDS },
                { "wds", QMI_SERVICE_WDS },
                { "wms", QMI_SERVICE_WMS },
+               { "wda", QMI_SERVICE_WDA },
        };
        int i;
 
diff --git a/main.c b/main.c
index 6ba746e029d017cd665196cca2f0a5cb4671eba7..4154defb2f9eaf2e4d13a4e65d0b25617eba7aac 100644 (file)
--- a/main.c
+++ b/main.c
@@ -47,6 +47,7 @@ static int usage(const char *progname)
                dms_helptext
                nas_helptext
                wms_helptext
+               wda_helptext
                "\n", progname);
        return 1;
 }
diff --git a/qmi-enums-wda.h b/qmi-enums-wda.h
new file mode 100644 (file)
index 0000000..b45bae0
--- /dev/null
@@ -0,0 +1,68 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * libqmi-glib -- GLib/GIO based library to control QMI devices
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA.
+ *
+ * Copyright (C) 2014 Aleksander Morgado <aleksander@aleksander.es>
+ */
+
+#ifndef _LIBQMI_GLIB_QMI_ENUMS_WDA_H_
+#define _LIBQMI_GLIB_QMI_ENUMS_WDA_H_
+
+/**
+ * SECTION: qmi-enums-wda
+ * @title: WDA enumerations and flags
+ *
+ * This section defines enumerations and flags used in the WDA service
+ * interface.
+ */
+
+/**
+ * QmiWdaLinkLayerProtocol:
+ * @QMI_WDA_LINK_LAYER_PROTOCOL_UNKNOWN: Unknown.
+ * @QMI_WDA_LINK_LAYER_PROTOCOL_802_3: 802.3 ethernet mode.
+ * @QMI_WDA_LINK_LAYER_PROTOCOL_RAW_IP: Raw IP mode.
+ *
+ * Link layer protocol.
+ */
+typedef enum {
+    QMI_WDA_LINK_LAYER_PROTOCOL_UNKNOWN = 0x00,
+    QMI_WDA_LINK_LAYER_PROTOCOL_802_3   = 0x01,
+    QMI_WDA_LINK_LAYER_PROTOCOL_RAW_IP  = 0x02,
+} QmiWdaLinkLayerProtocol;
+
+/**
+ * QmiWdaDataAggregationProtocol:
+ * @QMI_WDA_DATA_AGGREGATION_PROTOCOL_DISABLED: Disabled.
+ * @QMI_WDA_DATA_AGGREGATION_PROTOCOL_TLP: TLP enabled.
+ * @QMI_WDA_DATA_AGGREGATION_PROTOCOL_QC_NCM: QC NCM enabled.
+ * @QMI_WDA_DATA_AGGREGATION_PROTOCOL_MBIM: MBIM enabled.
+ * @QMI_WDA_DATA_AGGREGATION_PROTOCOL_RNDIS: RNDIS enabled.
+ * @QMI_WDA_DATA_AGGREGATION_PROTOCOL_QMAP: QMAP enabled.
+ *
+ * Data aggregation protocol in uplink or downlink.
+ */
+typedef enum {
+    QMI_WDA_DATA_AGGREGATION_PROTOCOL_DISABLED = 0x00,
+    QMI_WDA_DATA_AGGREGATION_PROTOCOL_TLP      = 0x01,
+    QMI_WDA_DATA_AGGREGATION_PROTOCOL_QC_NCM   = 0x02,
+    QMI_WDA_DATA_AGGREGATION_PROTOCOL_MBIM     = 0x03,
+    QMI_WDA_DATA_AGGREGATION_PROTOCOL_RNDIS    = 0x04,
+    QMI_WDA_DATA_AGGREGATION_PROTOCOL_QMAP     = 0x05,
+} QmiWdaDataAggregationProtocol;
+
+#endif /* _LIBQMI_GLIB_QMI_ENUMS_WDA_H_ */
index 4ba8e5cc543c7617f934a97d92f45077bc3488ed..d63ee82958f7ef2b420df641ff4f774a930a51d2 100644 (file)
@@ -27,6 +27,9 @@
 #include "qmi-enums-wms.h"
 #include "qmi-message-wms.h"
 
+#include "qmi-enums-wda.h"
+#include "qmi-message-wda.h"
+
 #define qmi_set(_data, _field, _val) \
        do { \
                (_data)->set._field = 1; \
diff --git a/uqmi.h b/uqmi.h
index de212fcd8da195b59ea1eff925a92f469f375147..ea2a140f8ac6fda31764ff40910fb7a808b7bdf0 100644 (file)
--- a/uqmi.h
+++ b/uqmi.h
@@ -34,7 +34,8 @@ static inline void dump_packet(const char *prefix, void *ptr, int len)
     __qmi_service(QMI_SERVICE_RMTFS), \
     __qmi_service(QMI_SERVICE_CAT), \
     __qmi_service(QMI_SERVICE_RMS), \
-    __qmi_service(QMI_SERVICE_OMA)
+    __qmi_service(QMI_SERVICE_OMA), \
+    __qmi_service(QMI_SERVICE_WDA)
 
 #define __qmi_service(_n) __##_n
 enum {