From ba48484dac9d39f37eeeb96ad77649e5791ce289 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Tue, 25 Nov 2014 21:22:16 +0100 Subject: [PATCH] add wda commands for setting/getting wireless data mode Signed-off-by: Felix Fietkau --- CMakeLists.txt | 2 +- commands-wda.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++ commands-wda.h | 9 ++++++++ commands.c | 1 + commands.h | 4 +++- dev.c | 1 + main.c | 1 + qmi-enums-wda.h | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ qmi-message.h | 3 +++ uqmi.h | 3 ++- 10 files changed, 147 insertions(+), 3 deletions(-) create mode 100644 commands-wda.c create mode 100644 commands-wda.h create mode 100644 qmi-enums-wda.h diff --git a/CMakeLists.txt b/CMakeLists.txt index fcfd772..3f67652 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 index 0000000..0ca32b4 --- /dev/null +++ b/commands-wda.c @@ -0,0 +1,58 @@ +#include + +#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 index 0000000..e51452c --- /dev/null +++ b/commands-wda.h @@ -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 : Set data format (type: 802.3|raw-ip)\n" \ + " --wda-get-data-format: Get data format\n" \ + diff --git a/commands.c b/commands.c index 198b6ab..c87714d 100644 --- a/commands.c +++ b/commands.c @@ -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] = { \ diff --git a/commands.h b/commands.h index 9d492e7..312e897 100644 --- a/commands.h +++ b/commands.h @@ -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 4e48179..a586157 100644 --- 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 6ba746e..4154def 100644 --- 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 index 0000000..b45bae0 --- /dev/null +++ b/qmi-enums-wda.h @@ -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 + */ + +#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_ */ diff --git a/qmi-message.h b/qmi-message.h index 4ba8e5c..d63ee82 100644 --- a/qmi-message.h +++ b/qmi-message.h @@ -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 de212fc..ea2a140 100644 --- 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 { -- 2.11.0