[PATCH 01/10] qmi: wda: Add qmi_wda_set_data_format utility

Denis Kenzior <[email protected]>
Newsgroups dev.linux.lists.ofono
Message-ID <[email protected]>
This utility function builds a WDA Set Data Format message and sends it
to the desired wda service handle.
---
 Makefile.am                     |  1 +
 drivers/qmimodem/common.h       |  5 ++++
 drivers/qmimodem/gprs-context.c |  6 ++--
 drivers/qmimodem/wda.c          | 51 +++++++++++++++++++++++++++++++++
 drivers/qmimodem/wda.h          | 23 +++++++++++++++
 5 files changed, 82 insertions(+), 4 deletions(-)
 create mode 100644 drivers/qmimodem/wda.c

diff --git a/Makefile.am b/Makefile.am
index d107dc410fd2..2d198f52a4a0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -366,6 +366,7 @@ qmi_sources = drivers/qmimodem/qmi.h drivers/qmimodem/qmi.c \
 					drivers/qmimodem/pds.h \
 					drivers/qmimodem/common.h \
 					drivers/qmimodem/wda.h \
+					drivers/qmimodem/wda.c \
 					drivers/qmimodem/wds.c \
 					drivers/qmimodem/voice.h
 
diff --git a/drivers/qmimodem/common.h b/drivers/qmimodem/common.h
index b0788285b5e7..1610f1da9e45 100644
--- a/drivers/qmimodem/common.h
+++ b/drivers/qmimodem/common.h
@@ -76,3 +76,8 @@
 #define QMI_LTE_BAND_MASK_EUTRA_41	0x0000010000000000
 #define QMI_LTE_BAND_MASK_EUTRA_42	0x0000020000000000
 #define QMI_LTE_BAND_MASK_EUTRA_43	0x0000040000000000
+
+struct qmi_endpoint_info {
+	uint32_t endpoint_type;
+	uint32_t interface_number;
+} __attribute__((packed));
diff --git a/drivers/qmimodem/gprs-context.c b/drivers/qmimodem/gprs-context.c
index 89d68d154ed8..a8ac3cb18c80 100644
--- a/drivers/qmimodem/gprs-context.c
+++ b/drivers/qmimodem/gprs-context.c
@@ -17,6 +17,7 @@
 #include <ofono/gprs-context.h>
 
 #include "qmi.h"
+#include "common.h"
 #include "wds.h"
 #include "util.h"
 
@@ -715,10 +716,7 @@ static int qmi_gprs_context_bind_mux(struct ofono_gprs_context *gc,
 	struct qmi_param *param;
 	const char *interface_number;
 	const char *bus;
-	struct {
-		uint32_t endpoint_type;
-		uint32_t interface_number;
-	} __attribute__((packed)) endpoint_info;
+	struct qmi_endpoint_info endpoint_info;
 	uint8_t u8;
 
 	bus = ofono_modem_get_string(modem, "Bus");
diff --git a/drivers/qmimodem/wda.c b/drivers/qmimodem/wda.c
new file mode 100644
index 000000000000..cf32aa094d69
--- /dev/null
+++ b/drivers/qmimodem/wda.c
@@ -0,0 +1,51 @@
+/*
+ * oFono - Open Source Telephony
+ * Copyright (C) 2024  Cruise, LLC
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#include <stdint.h>
+#include <stddef.h>
+
+#include <ell/ell.h>
+
+#include "src/common.h"
+
+#include "qmi.h"
+#include "common.h"
+#include "wda.h"
+
+uint16_t qmi_wda_set_data_format(struct qmi_service *wda,
+				const struct qmi_endpoint_info *endpoint_info,
+				const struct qmi_wda_data_format *format,
+				qmi_service_result_func_t func,
+				void *user_data, qmi_destroy_func_t destroy)
+{
+	static const uint8_t PARAM_LL_PROTO = 0x11;
+	static const uint8_t PARAM_UL_AGGREGATION_PROTOCOL = 0x12;
+	static const uint8_t PARAM_DL_AGGREGATION_PROTOCOL = 0x13;
+	static const uint8_t PARAM_DL_MAX_DATAGRAMS = 0x15;
+	static const uint8_t PARAM_DL_MAX_SIZE = 0x16;
+	static const uint8_t PARAM_EP_INFO = 0x17;
+	struct qmi_param *param = qmi_param_new();
+	uint32_t req_id;
+
+	qmi_param_append_uint32(param, PARAM_LL_PROTO, format->ll_protocol);
+	qmi_param_append_uint32(param, PARAM_UL_AGGREGATION_PROTOCOL,
+					format->ul_aggregation_protocol);
+	qmi_param_append_uint32(param, PARAM_DL_AGGREGATION_PROTOCOL,
+					format->dl_aggregation_protocol);
+	qmi_param_append_uint32(param, PARAM_DL_MAX_DATAGRAMS,
+					format->dl_max_datagrams);
+	qmi_param_append_uint32(param, PARAM_DL_MAX_SIZE, format->dl_max_size);
+	qmi_param_append(param, PARAM_EP_INFO,
+				sizeof(*endpoint_info), endpoint_info);
+
+	req_id = qmi_service_send(wda, QMI_WDA_SET_DATA_FORMAT,
+					param, func, user_data, destroy);
+	if (!req_id)
+		qmi_param_free(param);
+
+	return req_id;
+}
diff --git a/drivers/qmimodem/wda.h b/drivers/qmimodem/wda.h
index fd1e1f63ab1e..4facc0cb6677 100644
--- a/drivers/qmimodem/wda.h
+++ b/drivers/qmimodem/wda.h
@@ -5,6 +5,8 @@
  * SPDX-License-Identifier: GPL-2.0-only
  */
 
+struct qmi_endpoint_info;
+
 #define QMI_WDA_SET_DATA_FORMAT	32	/* Set data format */
 #define QMI_WDA_GET_DATA_FORMAT	33	/* Get data format */
 
@@ -16,3 +18,24 @@ enum qmi_wda_data_link_protocol {
 	QMI_WDA_DATA_LINK_PROTOCOL_802_3 =			0x01,
 	QMI_WDA_DATA_LINK_PROTOCOL_RAW_IP =			0x02,
 };
+
+enum qmi_wda_aggregation_protocol {
+	QMI_WDA_AGGREGATION_PROTOCOL_DISABLED =			0x00,
+	QMI_WDA_AGGREGATION_PROTOCOL_QMAP =			0x05,
+	QMI_WDA_AGGREGATION_PROTOCOL_QMAPV4 =			0x08,
+	QMI_WDA_AGGREGATION_PROTOCOL_QMAPV5 =			0x09,
+};
+
+struct qmi_wda_data_format {
+	uint32_t ll_protocol;
+	uint32_t ul_aggregation_protocol;
+	uint32_t dl_aggregation_protocol;
+	uint32_t dl_max_datagrams;
+	uint32_t dl_max_size;
+};
+
+uint16_t qmi_wda_set_data_format(struct qmi_service *wda,
+				const struct qmi_endpoint_info *endpoint_info,
+				const struct qmi_wda_data_format *format,
+				qmi_service_result_func_t func,
+				void *user_data, qmi_destroy_func_t destroy);
-- 
2.47.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.