diff mbox series

[v2,04/11] gobi: Limit number of premultiplexed contexts to 4

Message ID 20240711164654.1688558-4-denkenz@gmail.com (mailing list archive)
State Not Applicable
Headers show
Series [v2,01/11] udevng: Remove gps from setup_gobi | expand

Commit Message

Denis Kenzior July 11, 2024, 4:46 p.m. UTC
4 was chosen somewhat arbitrarily, but it is the maximum that the
qmi_wwan_q driver can support out of the box.  The only limit is the
number of clients under QMI.  Two WDS clients are typically required for
each active context, one for IPv4 and one for IPv6.  The total number of
clients cannot exceed 255 (uint8).
---
 plugins/gobi.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

Comments

Denis Kenzior July 11, 2024, 4:50 p.m. UTC | #1
On 7/11/24 11:46 AM, Denis Kenzior wrote:
> 4 was chosen somewhat arbitrarily, but it is the maximum that the
> qmi_wwan_q driver can support out of the box.  The only limit is the
> number of clients under QMI.  Two WDS clients are typically required for
> each active context, one for IPv4 and one for IPv6.  The total number of
> clients cannot exceed 255 (uint8).
> ---
>   plugins/gobi.c | 19 +++++++++++++++----
>   1 file changed, 15 insertions(+), 4 deletions(-)
> 

This set should be ignored.  Sorry for the noise.
diff mbox series

Patch

diff --git a/plugins/gobi.c b/plugins/gobi.c
index 88e4c7fc4887..b6df849de47e 100644
--- a/plugins/gobi.c
+++ b/plugins/gobi.c
@@ -55,6 +55,8 @@ 
 #define GOBI_VOICE	(1 << 6)
 #define GOBI_WDA	(1 << 7)
 
+#define MAX_CONTEXTS 4
+
 struct service_request {
 	struct qmi_service **member;
 	uint32_t service_type;
@@ -75,6 +77,7 @@  struct gobi_data {
 	int num_service_requests;
 	unsigned long features;
 	unsigned int discover_attempts;
+	uint8_t n_premux;
 	uint8_t oper_mode;
 	int main_net_ifindex;
 	char main_net_name[IFNAMSIZ];
@@ -124,6 +127,7 @@  static int gobi_probe(struct ofono_modem *modem)
 	const char *ifname;
 	int ifindex;
 	const char *bus;
+	int n_premux;
 
 	DBG("%p", modem);
 
@@ -132,10 +136,11 @@  static int gobi_probe(struct ofono_modem *modem)
 	ifname = ofono_modem_get_string(modem, "NetworkInterface");
 	ifindex = ofono_modem_get_integer(modem, "NetworkInterfaceIndex");
 	bus = ofono_modem_get_string(modem, "Bus");
+	n_premux = ofono_modem_get_integer(modem, "NumPremuxInterfaces");
 
 	DBG("net: %s[%s](%d) %s", ifname, if_driver, ifindex, bus);
 
-	if (!if_driver || !ifname || !ifindex || !bus)
+	if (!if_driver || !ifname || !ifindex || !bus || n_premux < 0)
 		return -EPROTO;
 
 	data = l_new(struct gobi_data, 1);
@@ -145,6 +150,13 @@  static int gobi_probe(struct ofono_modem *modem)
 	else if (!strcmp(if_driver, "qmi_wwan"))
 		data->using_qmi_wwan = true;
 
+	if (n_premux > MAX_CONTEXTS) {
+		l_warn("NumPremuxInterfaces > %d, limiting to %d",
+				MAX_CONTEXTS, MAX_CONTEXTS);
+		n_premux = MAX_CONTEXTS;
+	}
+
+	data->n_premux = n_premux;
 	data->main_net_ifindex =
 		ofono_modem_get_integer(modem, "NetworkInterfaceIndex");
 	l_strlcpy(data->main_net_name,
@@ -753,7 +765,6 @@  static void gobi_pre_sim(struct ofono_modem *modem)
 static void gobi_setup_gprs(struct ofono_modem *modem)
 {
 	struct gobi_data *data = ofono_modem_get_data(modem);
-	int n_premux = ofono_modem_get_integer(modem, "NumPremuxInterfaces");
 	struct ofono_gprs *gprs;
 	struct ofono_gprs_context *gc;
 	const char *interface;
@@ -770,7 +781,7 @@  static void gobi_setup_gprs(struct ofono_modem *modem)
 	}
 
 	/* Simple case of 802.3 interface, no QMAP */
-	if (n_premux == 0) {
+	if (data->n_premux == 0) {
 		interface = ofono_modem_get_string(modem, "NetworkInterface");
 
 		gc = ofono_gprs_context_create(modem, 0, "qmimodem", -1,
@@ -793,7 +804,7 @@  static void gobi_setup_gprs(struct ofono_modem *modem)
 		ofono_modem_get_integer(modem, "MaxAggregationSize");
 	DBG("max_aggregation_size: %u", data->max_aggregation_size);
 
-	for (i = 0; i < n_premux; i++) {
+	for (i = 0; i < data->n_premux; i++) {
 		int mux_id;
 
 		sprintf(buf, "PremuxInterface%dMuxId", i + 1);