From patchwork Tue Jul 9 22:50:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13728604 Received: from mail-il1-f182.google.com (mail-il1-f182.google.com [209.85.166.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B7954155316 for ; Tue, 9 Jul 2024 22:50:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720565451; cv=none; b=VuJlSwwJc/4v1YiWIKxGLc6+aNu8jdoZW/7uIE1b1/ZUYZw+JpCLYrgs260KW9kg1Z889L9z4uFW/Enh4c47FS0Y7hW9oWaL9+3NYJAnYwWm7WTkHcup10lNXjlGqsYKZZfcVkC2m0gMnZ+fTc78Wu5UNzx7x7neQphglFXOn+s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720565451; c=relaxed/simple; bh=v0v7zU7SfV5hf7UJ7ywGy/Wso6ZtVANjHh6GDJxnbp8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=MzX4qqfcxkALBR2MV0uF5NdqHV5eK2gGKGnKaCwe47/g6vxTB/0q1OArjnhSrG55U9rAWM4rlht8v7A2Z6MI9WRvY6lZ1aYpRivPt8XEV9P5k+i0gDSeZlIl+K4MqSer4etrPYgPPkdMTjBHhELuZ6PQi7e7moNIHZrSSfGrWxo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=EgwgTFt0; arc=none smtp.client-ip=209.85.166.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EgwgTFt0" Received: by mail-il1-f182.google.com with SMTP id e9e14a558f8ab-38b1ce72526so3889555ab.0 for ; Tue, 09 Jul 2024 15:50:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720565449; x=1721170249; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=iiE7/RanaIDCqOfIBMI4yOLghOxvZGR+2aVfftt5bCU=; b=EgwgTFt0zh9g4P9nCyIkIq9b2gcsBafUZ9I18DTHVDi9ZDDHfNsw95ArdzCZxFN722 xbjasvhWpXU2bHnBVNQ9YG63b3ALavEOoz80m1geulbfYi8HdmrJhFbiJgXUS3lsChz1 KM/+vWPSEriBHBeXeBeeGJVZ0ZsaV3EKz7PKh9AaKzBbXlzL63P/FqeuCNZ2rT3F+JGx EEjEpU3P8CsCcdNo4S91AbbO6pN0XxmsPIr2fS6iXjw9bBjoGlltxHfgWB6y66L6SfCU d7uU2zuo38BDOBwX4jPPeo6xn5h0VwmTq3ic2y71QwzPCg/sQso57jWi2oiVAbvgQmG7 lbgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720565449; x=1721170249; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=iiE7/RanaIDCqOfIBMI4yOLghOxvZGR+2aVfftt5bCU=; b=QnG7iGFjg6kDE5AZMfhIWN8d//350cIBQ3ffvAGgU2DFDl832FItkSVup+Y7SaS2ic istrgwALJb0rPNgKdFSZSA9GP42kje5ov0p6JaW3QR37TaE11sjJFU4yoIMT/6zle9ud blZuKvssGweQvf3C5yaWzp9BY4P/wNixWKJrc+oeJu0hmf4Us1daeTmdrWug6LiwVnVN RPbNfoINRv60lZs9D4RLtR6lMLMU5WZAx5+ygmsCZqF+b/mqUJEZyy48/Jp9LyOmI35n hmKtokF02HdLRgw++wy5cLU3Q4ctt4TnSuE2v0edeocmBv+nXYzLdK/atCEWXDS6TdpF PWKg== X-Gm-Message-State: AOJu0Ywf2BLEGSeidKp8OJYCWj4iQw1MbNfwn8yezVHZkDBG7Ehfppbv ZR6PZlqoEOOaMepdqAVh/L+GKX07q9PnokQ5CguQE8CWmURIOFFEMboTCQ== X-Google-Smtp-Source: AGHT+IEdJaa4e0PFunwwn9ZmFGQtoB1VbJWHjFCTDO8EVjyS9aJOlRME3Ga4vd5AIzhsPz0sxVnxjA== X-Received: by 2002:a05:6e02:1547:b0:374:6e8f:c760 with SMTP id e9e14a558f8ab-38a59d923dcmr44136545ab.20.1720565448658; Tue, 09 Jul 2024 15:50:48 -0700 (PDT) Received: from localhost.localdomain ([2605:a601:ad99:2e00:e9ed:d1b6:6b3c:b7f3]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-38a49075808sm6300075ab.15.2024.07.09.15.50.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jul 2024 15:50:48 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 01/11] gobi: Limit number of premultiplexed contexts to 4 Date: Tue, 9 Jul 2024 17:50:20 -0500 Message-ID: <20240709225047.1427626-1-denkenz@gmail.com> X-Mailer: git-send-email 2.45.2 Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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(-) 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); From patchwork Tue Jul 9 22:50:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13728605 Received: from mail-il1-f181.google.com (mail-il1-f181.google.com [209.85.166.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 632CB156F43 for ; Tue, 9 Jul 2024 22:50:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720565451; cv=none; b=kT+Mm91zDbrfuUugrAQbDj6WYPQWvrgVlAi5699vfiH9sW3ghBgJaNomcO6L3gdVEFitMJO8lCX51I2pdVmRsIXj+qodFDuNFYlqFEPzxcJnmpFqF9pDTSw39i/sF+QrLx2XktbrgPylF2hqyXhh0Jwhmm2gqu6KSslW05kHhx0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720565451; c=relaxed/simple; bh=VBJdnq/Br6eI4igqVnMW/sTXg0Gzz2fZ4MEiET6TZ3E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jeHJHD+G7traFByiiauIOc6YN8+hWo5SQM8c+PYsEWxLJxcIFJEJZxEiHvsMasl570pC0288iJoLbI9YqkqD61mmd8x5Bys41oVFrBiWjhUAvdfm9UzxnP9MoTw8LEMDHhZNbM3nlwQIA4nwai2NBpfOFvO+Z14ZSB3p/kJPfPc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Ysg/Bb75; arc=none smtp.client-ip=209.85.166.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ysg/Bb75" Received: by mail-il1-f181.google.com with SMTP id e9e14a558f8ab-38713b03039so13881305ab.0 for ; Tue, 09 Jul 2024 15:50:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720565449; x=1721170249; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4hFYFd2wxJVjFo1RYvq8oVkHVsdRhr45mMwFvFgqeFg=; b=Ysg/Bb75i7gHbbDYZeOZGxRjgBBn192/Zst6i6S+BC0MRfwWNF0kjiMVve76q/Kn3n Hrix+AkZS03omLc/71DYd5sECo4M03adlqi5JGHXJdlDI7omyFneInA5e8AA/CMKpBdr gZP2OBGhoflgf74uMNfwNGfAuXLhvnMW9UWSoOMPFw82paQ8eEa1MGH8R+TFtK3zFdRf qdCYifOZ2DEFfzziatN378GfADXg8/NQruflILfrqoKQFnyIKeSJoyHICvlwu3e6GT+3 Pr+fwTYiVvtEvVy7s0VS+B2T2eun44tBcIs6f7wTz+uuZqSD4UCzVU31ZZrjbZyN4WKQ 7eTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720565449; x=1721170249; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4hFYFd2wxJVjFo1RYvq8oVkHVsdRhr45mMwFvFgqeFg=; b=IqNO3OsGa7VsBHRZaRQOIDfm0lXqRN0Tc2eZj3SWBn6PWS/HzKpK4/r3F8g9lbQR5v kxrCAqK02F1X4lEFIDZfMx6VUzy5qkRKhIlYfSUuRgZ+Z1OPJr0gC/qQVn/52zYtquPD Qey1qhzJ+9qViu9AwlpYJrkmMUvLICMNZp1aapaqLQ6EEdgQt6bQfu5Ff7Y0oYq6yEmu MToBqTVQ4cOzRpjmUgsygILQmNL5CodiM9X4cqzf121ok+3pRDbpTxv1AGZMyRVe2GnE HoV7cFWHBcqg3FM6tEzXL4Wi9HxV36Efo2hZhj7IeAA458AXFT+7PAjQUccxLo3pKsOZ EgYw== X-Gm-Message-State: AOJu0YzBMyhkdJcCv2BYSN+Oxwbv0e1DtPNhvy6F/qw94L49lreK4xtd n6uaw0SSqZjUmhd+E38sVG+hWsowa3YVcvlT/9/NmZn2gwxdqDb8GT70YA== X-Google-Smtp-Source: AGHT+IGVgrUF4Gpwac8QFHSYWjq4FMg9T3G0oyFazk8xM4KXuP4b3HdxCN8c2nys3llQ8xylW24eqg== X-Received: by 2002:a05:6e02:180a:b0:374:ac3a:e32c with SMTP id e9e14a558f8ab-38a57bce18cmr43555215ab.16.1720565449350; Tue, 09 Jul 2024 15:50:49 -0700 (PDT) Received: from localhost.localdomain ([2605:a601:ad99:2e00:e9ed:d1b6:6b3c:b7f3]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-38a49075808sm6300075ab.15.2024.07.09.15.50.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jul 2024 15:50:49 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 02/11] gobi: Request dedicated WDS services for contexts Date: Tue, 9 Jul 2024 17:50:21 -0500 Message-ID: <20240709225047.1427626-2-denkenz@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240709225047.1427626-1-denkenz@gmail.com> References: <20240709225047.1427626-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Each context the modem supports (up to MAX_CONTEXTS) will require two dedicated WDS services. One will manage the IPv4 configuration, the other will manage IPv6 configuration. --- plugins/gobi.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/plugins/gobi.c b/plugins/gobi.c index b6df849de47e..76e1e133860d 100644 --- a/plugins/gobi.c +++ b/plugins/gobi.c @@ -72,7 +72,11 @@ struct gobi_data { struct qmi_service *voice; struct qmi_service *pds; struct qmi_service *uim; - struct service_request service_requests[16]; + struct { + struct qmi_service *wds_ipv4; + struct qmi_service *wds_ipv6; + } context_services[MAX_CONTEXTS]; + struct service_request service_requests[8 + MAX_CONTEXTS * 2]; int cur_service_request; int num_service_requests; unsigned long features; @@ -170,6 +174,8 @@ static int gobi_probe(struct ofono_modem *modem) static void cleanup_services(struct gobi_data *data) { + int i; + qmi_service_free(data->dms); data->dms = NULL; @@ -193,6 +199,13 @@ static void cleanup_services(struct gobi_data *data) qmi_service_free(data->uim); data->uim = NULL; + + for (i = 0; i < MAX_CONTEXTS; i++) { + qmi_service_free(data->context_services[i].wds_ipv4); + qmi_service_free(data->context_services[i].wds_ipv6); + } + + memset(&data->context_services, 0, sizeof(data->context_services)); } static void gobi_remove(struct ofono_modem *modem) @@ -489,6 +502,7 @@ static void discover_cb(void *user_data) struct gobi_data *data = ofono_modem_get_data(modem); uint16_t major; uint16_t minor; + int i; DBG(""); @@ -538,6 +552,13 @@ static void discover_cb(void *user_data) if (data->features & GOBI_UIM) add_service_request(data, &data->uim, QMI_SERVICE_UIM); + for (i = 0; i < (data->n_premux ? data->n_premux : 1); i++) { + add_service_request(data, &data->context_services[i].wds_ipv4, + QMI_SERVICE_WDS); + add_service_request(data, &data->context_services[i].wds_ipv6, + QMI_SERVICE_WDS); + } + if (qmi_qmux_device_create_client(data->device, QMI_SERVICE_DMS, request_service_cb, modem, NULL) > 0) return; From patchwork Tue Jul 9 22:50:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13728606 Received: from mail-il1-f170.google.com (mail-il1-f170.google.com [209.85.166.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1665413211E for ; Tue, 9 Jul 2024 22:50:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720565452; cv=none; b=bneJrMVrVW0vqo3Iwu1AkXoUgdOFmg/cgCeoGHcg5I4xdCZyjxFhp9rqVaNzn/0rMeBysPV/TcchDx2FcFwLM+pWxEpVthZPmOnex+CbHfgolT64z9KJNMdALTQVzYawGD0g6X9Eg12p9Cpj//j2tkNnNqIU2KXk1RdztJI0WBw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720565452; c=relaxed/simple; bh=vZemnAQx6lt/5RW9tkn97Ir7UgxKrTvGJK9H4hhc7BI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=h0P8aC0zY203T7zluTTlZOKs0UXkQhqAJX3KPAHJw9BefHMaNhjXjOv3gigaxu+dyBbn+xGktH/E3TjcZI4bOqQ3PI6m1hBRI8c96CXMUKOmW+VbR5P6yi61sqtj2OVL7MvZm9ppMS00aEO9zjEUguuSyqOkkfRyhkNih26P/Lw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Bjp1UGqU; arc=none smtp.client-ip=209.85.166.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Bjp1UGqU" Received: by mail-il1-f170.google.com with SMTP id e9e14a558f8ab-376069031c7so22011395ab.0 for ; Tue, 09 Jul 2024 15:50:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720565450; x=1721170250; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=q2iBWS2+3c3Faezm++4qy17LkbyRGNJqin8EvtAlyAE=; b=Bjp1UGqUYgn9Jg5elfFx2oxXmXv4geBEVZ147NJHbfcfQ1CuzO8AvlpppLheLy0DXP 802KlpJFIsM3KJfNy9IBTZmXmTfQe3bgizYIdKxqMz7TMrNss1kBHNc+u03PqoxgEAx7 jHppdZ4rHgUs4CEAT1wZjh0JdmPVcUX1xoEc04uk8sINKppyyuG5Qrs8g/h+iSt1YRzl FS8J2pccguVMFNVg1nqU5+6mQbNciVr89lqx6qSxTl4MtZi/ER/h7Yvhk8XOWBF4guc7 pb5p6Z4l83CNLX69vl+cfqsAoXiVwAnNk9VY9jathccTQPlpHMFgMLqlv8oU3Ol3HYUo 5uSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720565450; x=1721170250; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=q2iBWS2+3c3Faezm++4qy17LkbyRGNJqin8EvtAlyAE=; b=MA568qRyP94SLrCT1jOASPSYcG6KzeXhQXDAZKcB+M/n/yhii5qmztodkqO+vOvXvu KFgKPjy8/vllVavhDbQyMaNSaRumL/2pbfkOLVE/gwLNb06LhHZDeeNdjT+v+wILCHDD BIdVkbIUw1A1r9iQiF4DzrYOhVFiuP9KRvoIiDNPa0rFJlxvchNE0QZAUyshwvKrb12y KkdveL86NAGRguV2HTGoDILnD+GvDc8UC2Jvj6ahFgtar4Wm1lC4lytFqCVsSQ3ehQpw /5FsoYFjy0N871Yv7y7UuZrxKfUB2q9MOeMY3YTICYeznALiMp2q6HDdQI/QVwwCymMx Ajdg== X-Gm-Message-State: AOJu0Yy9YyTs9lxZVxhORlwSfBmreV0xxI/SszAwk4z94j0DSkFSsEnT tp4j8LA6t9OkuoDKEtU/f0fzsvPEvaIy4Yc9qfExRHxGNMPFymoY8Caj9A== X-Google-Smtp-Source: AGHT+IHsIBNANi4jLX1xRKnPuARhauLuxbPo4aNhFO6tpdQJiGFENtZxxg3CmAYE9ngKoOjr+tL3CA== X-Received: by 2002:a05:6e02:18cd:b0:379:4564:1228 with SMTP id e9e14a558f8ab-38a598b3998mr41022825ab.30.1720565449960; Tue, 09 Jul 2024 15:50:49 -0700 (PDT) Received: from localhost.localdomain ([2605:a601:ad99:2e00:e9ed:d1b6:6b3c:b7f3]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-38a49075808sm6300075ab.15.2024.07.09.15.50.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jul 2024 15:50:49 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 03/11] qmi: Enable _auto_ use for some classes Date: Tue, 9 Jul 2024 17:50:22 -0500 Message-ID: <20240709225047.1427626-3-denkenz@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240709225047.1427626-1-denkenz@gmail.com> References: <20240709225047.1427626-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This enables ell _auto_ keyword use with qmi_service_free and qmi_param_free. --- drivers/qmimodem/qmi.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/qmimodem/qmi.h b/drivers/qmimodem/qmi.h index 0e48313ebb64..69698ee049c6 100644 --- a/drivers/qmimodem/qmi.h +++ b/drivers/qmimodem/qmi.h @@ -5,6 +5,8 @@ * SPDX-License-Identifier: GPL-2.0-only */ +#include + #include #include @@ -110,6 +112,8 @@ struct qmi_param; struct qmi_param *qmi_param_new(void); void qmi_param_free(struct qmi_param *param); +DEFINE_CLEANUP_FUNC(qmi_param_free) + bool qmi_param_append(struct qmi_param *param, uint8_t type, uint16_t length, const void *data); bool qmi_param_append_uint8(struct qmi_param *param, uint8_t type, @@ -146,6 +150,8 @@ int qmi_error_to_ofono_cme(int qmi_error); struct qmi_service *qmi_service_clone(struct qmi_service *service); void qmi_service_free(struct qmi_service *service); +DEFINE_CLEANUP_FUNC(qmi_service_free) + const char *qmi_service_get_identifier(struct qmi_service *service); bool qmi_service_get_version(struct qmi_service *service, uint8_t *out_version); From patchwork Tue Jul 9 22:50:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13728607 Received: from mail-il1-f177.google.com (mail-il1-f177.google.com [209.85.166.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9113E155316 for ; Tue, 9 Jul 2024 22:50:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720565452; cv=none; b=q7V1IsYmShcKC+9jWDVuOlJ5huZUZfrdybaNINCwbZ2fkxHAowQEke7Wx136lH/lhb36/8cej2YZx7G7cqjon8mu/VMD8kFqM5lkAhcEkuyfBTrkv2jMhR352T4/rLU+djJBRFT0jF4R6CJ/dTGxlXrjpoEwaq061L4PdpNKN9Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720565452; c=relaxed/simple; bh=dffnGkI17qSPW3b25IONLAlEAPrFwVApJ4+yj4idVS4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pZRnHU+WFXff7JUY/P+CEcm00pJb95kkCfFOWctuIrmSoXRoeOwlUDzJAfLsG86mCCbqGgfYSUWGJMMq7wFevn9JPxHYKDDo1ZGmNbnc+7w6yW8QVgoU2YibL7KzZwmkt4DJJR7mszWEoWH0y+NHzCjc9tbls40M9GJMVmQfQnk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=G9x8F7yc; arc=none smtp.client-ip=209.85.166.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="G9x8F7yc" Received: by mail-il1-f177.google.com with SMTP id e9e14a558f8ab-381f24d6bc4so22519375ab.2 for ; Tue, 09 Jul 2024 15:50:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720565450; x=1721170250; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9c2JHjrV2CQ00glYH/m2D0yKTwf7Wgj38pYLIWfkVyo=; b=G9x8F7ycki5MHLROpz9fwWhoo46tv3kI3J8dRrqinvY6ROoj7Kj5JS+t1MGvY3ZzFg U2CgrR+8s5T6PHz4VCl/CPRtiLfs/7a7KCaods9WjJ8CEy88nB5nd0XqMnhi76nfhnL9 p72WDKJ+e3JCnnuCWirqMhMRwsbEuXyiG1/uWj3MYyp9JJhQLzG8849FQ6+I5+Vo17y+ +RgVtK2UeHrHVKV7qygGdT0kBK6g0TKVrPlK89I3DhxjKFnXIgMz8LdWfo0bSODG/11h Mfo67zskee4Nu4JQSdQyy/duTD6OPzpuAsEY7wqAnpgs5zfUx2RhqtXwMpCYewST3BwL aAfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720565450; x=1721170250; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9c2JHjrV2CQ00glYH/m2D0yKTwf7Wgj38pYLIWfkVyo=; b=T/0XjkX14/pxt/TTWibFxmCg0CxmsROT/pnsxzmBD6oED6aylyW02AUqNsgReSzRm4 laI5NAisVpzPVB3eahHez8GpLUbMSyfgB3aaGpastT1eENa/mrye34Sv5jQCV6rND3t8 BmgvwbGqWzxGWo3+FCjp7AHPKyUhpWmnD8SP4kcY2OQO+EDMR6ZEzzG1D1IW17Lcs6Mj 87MEKim2ifqcfkIzZQqM6sLWmTUXNf32wBL3gl70chGx9qcc+vzhChnD7E+Wlw6uZNgq uMC5gm78xhq5DPgh+tK9MgKEX7opzGIEZS4mwtQO6hpdtmqE92iGk2IbI0GKmBs1gCie 6Lcw== X-Gm-Message-State: AOJu0Yzn8iWqv6V5DSEn6F69y3nHG6QUlMRy54lzCZdX2Nz6SACuHDOW MSBjpJ+zNMY8jWW1PM0pI+wJ+kh1Y3HBQeTRMcb8hSKBpfxbXnMpMRNMxA== X-Google-Smtp-Source: AGHT+IHcswGz9Mo4UlK2856+Dn+oxy93+XQ5ngEXIzbgAsDNrRZ+4OunTXpmNv6UzNsH17ssQTE/8w== X-Received: by 2002:a05:6e02:164c:b0:376:2202:a84f with SMTP id e9e14a558f8ab-38a577e8dc9mr49908445ab.15.1720565450545; Tue, 09 Jul 2024 15:50:50 -0700 (PDT) Received: from localhost.localdomain ([2605:a601:ad99:2e00:e9ed:d1b6:6b3c:b7f3]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-38a49075808sm6300075ab.15.2024.07.09.15.50.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jul 2024 15:50:50 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 04/11] qmi: gprs-context: Declare qmi_service objects using _auto_ Date: Tue, 9 Jul 2024 17:50:23 -0500 Message-ID: <20240709225047.1427626-4-denkenz@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240709225047.1427626-1-denkenz@gmail.com> References: <20240709225047.1427626-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This simplifies the error paths slightly. --- drivers/qmimodem/gprs-context.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/qmimodem/gprs-context.c b/drivers/qmimodem/gprs-context.c index 3c18476142ea..7d13889bf603 100644 --- a/drivers/qmimodem/gprs-context.c +++ b/drivers/qmimodem/gprs-context.c @@ -554,7 +554,8 @@ static int qmi_gprs_context_probev(struct ofono_gprs_context *gc, unsigned int vendor, va_list args) { int mux_id = va_arg(args, int); - struct qmi_service *wds = va_arg(args, struct qmi_service *); + _auto_(qmi_service_free) struct qmi_service *wds = + va_arg(args, struct qmi_service *); struct gprs_context_data *data; DBG(""); @@ -562,14 +563,12 @@ static int qmi_gprs_context_probev(struct ofono_gprs_context *gc, if (mux_id != -1) { int r = qmi_gprs_context_bind_mux(gc, wds, mux_id); - if (r < 0) { - qmi_service_free(wds); + if (r < 0) return r; - } } data = l_new(struct gprs_context_data, 1); - data->wds = wds; + data->wds = l_steal_ptr(wds); data->mux_id = mux_id; qmi_service_register(data->wds, QMI_WDS_PACKET_SERVICE_STATUS, From patchwork Tue Jul 9 22:50:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13728608 Received: from mail-il1-f182.google.com (mail-il1-f182.google.com [209.85.166.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 362B4156F43 for ; Tue, 9 Jul 2024 22:50:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720565453; cv=none; b=GdqNU9o4XCCyWqkubYWCZLmrsMEEXIVn3sKR3j2qSoAN/bQgnw2oRxD5Qe3oWuFioc43N26yIX+uyLlH1+jQ9GnD3VmV+7crhQ85xy7DQJ8+CZFCQ+phhrf/O6SNc1AoJv7nucj84zDAxwNb0Ti/VQ576UEBFVKDYS/oZqQ/JSc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720565453; c=relaxed/simple; bh=iZlHt/A2O6grO/X1yTE1vnMtETKWcpgDowWu9LQLCbc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bCTkTKLLcvJa8LAnBN5uXi2QDVlOscSpw3cmeMArKYZDScOJts2KZDCvgEMnBkzlH47DzzSCGx2+K42YaCd29cwD7+Uy5pTmRO13NDf6i3ZzNqf4IijYS6pMdm+w6G4BzSXilr1XDMFBe4UcKUYAy/UQbsByRzexUEYwrdUgxSI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=g/5KIstG; arc=none smtp.client-ip=209.85.166.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="g/5KIstG" Received: by mail-il1-f182.google.com with SMTP id e9e14a558f8ab-3839d74a2abso20108395ab.1 for ; Tue, 09 Jul 2024 15:50:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720565451; x=1721170251; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xxcAHt31rhaZUfXbtRdoehzVhraF5OL1R/CyD/8mu7M=; b=g/5KIstGv7JDORlTPWpwIh08Lv/8Yw1daAuSrDFOURhL8ONNhWuoWht2bmur1sCYSv ZbbSts0lB6yvM963jl8iUdWav6gsXROg/X1MBhB41R/GUyh89J5Cdedlk1pI4egsfrCW /B+crwmQkUSvaPFO4yOEUZoy3MiBLRY2yK2HSRja1I40K9tXKaSBohiIWiN9DE+by4mA B3jPEkBKTbe24kwq9PUy3vjyeIJY2TbI1rMZqfP+l135WX0iVCTWCsdsVsYsg1Gd/hTe EExlTa3Qog+TybvFdFXlGerGc3TIlfgnsJn48XT3nHEViddX/x6/0otH0o8pHmP33Ss1 zvqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720565451; x=1721170251; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xxcAHt31rhaZUfXbtRdoehzVhraF5OL1R/CyD/8mu7M=; b=JU52oMGimEp0p9iKhy3AbpZ3Gbnh56Cai2anMipqOrxeZtbThUoRf/stoIk6DPgWFA OfDPXuyFceReQLfb/bB7rtZTGsTjmz3ZnTMI3PkcCTMfkN/Vw+tIziNMU8GF0QlZIcYf 24fAh0aa/z5RRCTbPebUj//Su//E7XiUgYFy+bUL/7CKozYUN/SEpAy7C2+Rno7bCGXP 1X0nrx09de91GwmFELnVFpf14AobYipDaP3zR20PSKIE9MbvYQqZRvwvGxnZdNdaREoQ mmZtYpzH9ZYaxSvr5bQuJ8MMLt9pam03TLnbl74wpX3FNvWlJzl7/hlSUbkXWyJdMf6s IugQ== X-Gm-Message-State: AOJu0YxgEmLa6XsvgEdO9MPsxakUG5mzdRkAFXfQCRPBA9VFEp+dl6Nc Oec30CB5QMfsKyqHgmFJaGRS97DAsL5ni4guxY2THk6QVxPnnxvSnE7pDA== X-Google-Smtp-Source: AGHT+IFrf3x4S2PlePnzUsVgHQ6mpEcmOjeelNzDbl9zoqjAgLYIjJvKgZClflVm4TNjVkh3gHub8Q== X-Received: by 2002:a05:6e02:1d0f:b0:377:1611:1b49 with SMTP id e9e14a558f8ab-38a59d923e7mr40520755ab.25.1720565451216; Tue, 09 Jul 2024 15:50:51 -0700 (PDT) Received: from localhost.localdomain ([2605:a601:ad99:2e00:e9ed:d1b6:6b3c:b7f3]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-38a49075808sm6300075ab.15.2024.07.09.15.50.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jul 2024 15:50:50 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 05/11] qmi: Pass two dedicated WDS services to gprs-context Date: Tue, 9 Jul 2024 17:50:24 -0500 Message-ID: <20240709225047.1427626-5-denkenz@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240709225047.1427626-1-denkenz@gmail.com> References: <20240709225047.1427626-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 gprs-context driver will not take two qmi_service objects, each with a dedicated WDS service. This will allow gprs-context to support dual stack (ipv4 + ipv6) contexts (in future commits). For now, the behavior is left unchanged with the second qmi_service being destroyed. --- drivers/qmimodem/gprs-context.c | 8 +++++--- plugins/gobi.c | 11 +++++++++-- plugins/qrtrqmi.c | 7 +++++-- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/drivers/qmimodem/gprs-context.c b/drivers/qmimodem/gprs-context.c index 7d13889bf603..5582a8052c0b 100644 --- a/drivers/qmimodem/gprs-context.c +++ b/drivers/qmimodem/gprs-context.c @@ -554,21 +554,23 @@ static int qmi_gprs_context_probev(struct ofono_gprs_context *gc, unsigned int vendor, va_list args) { int mux_id = va_arg(args, int); - _auto_(qmi_service_free) struct qmi_service *wds = + _auto_(qmi_service_free) struct qmi_service *ipv4 = + va_arg(args, struct qmi_service *); + _auto_(qmi_service_free) struct qmi_service *ipv6 = va_arg(args, struct qmi_service *); struct gprs_context_data *data; DBG(""); if (mux_id != -1) { - int r = qmi_gprs_context_bind_mux(gc, wds, mux_id); + int r = qmi_gprs_context_bind_mux(gc, ipv4, mux_id); if (r < 0) return r; } data = l_new(struct gprs_context_data, 1); - data->wds = l_steal_ptr(wds); + data->wds = l_steal_ptr(ipv4); data->mux_id = mux_id; qmi_service_register(data->wds, QMI_WDS_PACKET_SERVICE_STATUS, diff --git a/plugins/gobi.c b/plugins/gobi.c index 76e1e133860d..cb20824cc424 100644 --- a/plugins/gobi.c +++ b/plugins/gobi.c @@ -803,10 +803,14 @@ static void gobi_setup_gprs(struct ofono_modem *modem) /* Simple case of 802.3 interface, no QMAP */ if (data->n_premux == 0) { + struct qmi_service *ipv4 = data->context_services[0].wds_ipv4; + struct qmi_service *ipv6 = data->context_services[0].wds_ipv6; + interface = ofono_modem_get_string(modem, "NetworkInterface"); gc = ofono_gprs_context_create(modem, 0, "qmimodem", -1, - qmi_service_clone(data->wds)); + qmi_service_clone(ipv4), + qmi_service_clone(ipv6)); if (!gc) { ofono_warn("Unable to create gprs-context for: %s", ofono_modem_get_path(modem)); @@ -826,13 +830,16 @@ static void gobi_setup_gprs(struct ofono_modem *modem) DBG("max_aggregation_size: %u", data->max_aggregation_size); for (i = 0; i < data->n_premux; i++) { + struct qmi_service *ipv4 = data->context_services[i].wds_ipv4; + struct qmi_service *ipv6 = data->context_services[i].wds_ipv6; int mux_id; sprintf(buf, "PremuxInterface%dMuxId", i + 1); mux_id = ofono_modem_get_integer(modem, buf); gc = ofono_gprs_context_create(modem, 0, "qmimodem", mux_id, - qmi_service_clone(data->wds)); + qmi_service_clone(ipv4), + qmi_service_clone(ipv6)); if (!gc) { ofono_warn("gprs-context creation failed for [%d] %s", diff --git a/plugins/qrtrqmi.c b/plugins/qrtrqmi.c index b64ab355a2e8..21103371046a 100644 --- a/plugins/qrtrqmi.c +++ b/plugins/qrtrqmi.c @@ -324,10 +324,13 @@ static int setup_gprs_context(uint8_t mux_id, const char *interface, struct ofono_modem *modem = ofono_gprs_get_modem(gprs); struct qrtrqmi_data *data = ofono_modem_get_data(modem); struct qmi_qrtr_node *node = data->node; + struct qmi_service *ipv4 = qmi_qrtr_node_get_dedicated_service(node, + QMI_SERVICE_WDS); + struct qmi_service *ipv6 = qmi_qrtr_node_get_dedicated_service(node, + QMI_SERVICE_WDS); struct ofono_gprs_context *gc; - gc = ofono_gprs_context_create(modem, 0, "qmimodem", mux_id, - qmi_qrtr_node_get_service(node, QMI_SERVICE_WDS)); + gc = ofono_gprs_context_create(modem, 0, "qmimodem", mux_id, ipv4, ipv6); if (!gc) { ofono_warn("Unable to create gprs-context for: %s, %s[%u]", ofono_modem_get_path(modem), interface, mux_id); From patchwork Tue Jul 9 22:50:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13728609 Received: from mail-il1-f178.google.com (mail-il1-f178.google.com [209.85.166.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D48A013211E for ; Tue, 9 Jul 2024 22:50:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720565454; cv=none; b=kjdV3z8dDZEn5C41nP41CE20TbS6s5iit2HJImj7Xfj4CWI2v4nK4thN+6oCNC4Qwbr6KE1u12/3AmTxJbG/Q0oCBQMeyBoYUFsT6QjnX36DBz8JSWQ3qJM5WfFjEdbgq4gBUhP0iFo7yzFE2xueUK+h8VLsfjIi2g11IjgJ/Dg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720565454; c=relaxed/simple; bh=0UKrj6psPpqKrHfsfXGzVkrlHHzbsnYn0x2SxeReDmI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r/Dnd9pu7QYD2nol7ah08GkBPHj1VP9FPD49+EE3+X+U2pOBJWB9keFThU8b1SzNpSvSTzEH/oPRfzjiALXyNuv3ZCfUrOIlHn84OtL0o6d6OsTu/190TvSi02w6N8ypk6RSbMiw/JVDR9DnZ9EN7CIC7lUrUr++6DAGnXxGd7E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=BQzvmZzJ; arc=none smtp.client-ip=209.85.166.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BQzvmZzJ" Received: by mail-il1-f178.google.com with SMTP id e9e14a558f8ab-375e96f5fddso22001745ab.1 for ; Tue, 09 Jul 2024 15:50:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720565452; x=1721170252; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rs8F02vWqEf3iOs19nUa1+NSb0ZJzw+ofar/3zu1nbw=; b=BQzvmZzJSq7EuvljSLuwpKdkeMYAGmtx+TDOc9ylDNSlo2q6rgQFrRPSf9Mxw46WS/ vwIHAGhXF5LRaGBiUVJJC3RZWtgVNxwxZtQ1Hleb6zvvRA8LqQNdWCA6DwbIgiygT/qZ GIpBvZ6OGigBmOc3gmsJDzoneBsJo0uft2XMBk8/OnrNRO4p25dgJlZL9/xpY58Mv0OF eBrXBPSe/PyqAg+o9YkFNU2zcnxubGX9QtGYn07meb/Iy6kuVW8xh2oS8KfLiWO7cM7g ehYAKdStp29IrdvKXxWMaS8vB2gYS3w3zq0djtA0/q+RFRubRVkO1/NOicCt4FbEKhq3 /YYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720565452; x=1721170252; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rs8F02vWqEf3iOs19nUa1+NSb0ZJzw+ofar/3zu1nbw=; b=fcLh6gq+yxDuSXSPJRAFCQtNJqvdqPVPOR63NWXcEZMTNo/kRvg/rJxcs5dud8wllF 75HLAkXJRQMTJTyV2eEBKlX9UL3oPsMnKgBkLDMb/Q0vUG31m/teRnPJs7txpvr/ptwj QAjK1+abZMrc/wx0gW8nqBa1GZAhvMzs4GC4CZI0q2pkcEC5YBUOHvqvG94rwSFyDOSu MhFIN0GYVqyetGCg+YHhgSVtKSEWLHo1pB1IKkQ+6gpbfu40RSQcMQS+PE/SJ8DNICm8 CjZJNcCh7eDiXyFbxaL9sovWcgYmMKoMiNMPlRgaTVvHodza1QlaNNR7W8k9BV1Ptxba l4mA== X-Gm-Message-State: AOJu0YzYUmFQdnaOl0CNB8f+a/O/uZnea+WIkp1njDRc3zc6fPoBRQbU Uf0EFFrETs27SsxEL1XvN5uLjQTMztOwjAiIOrrgJ2wugBEYDbxs5GkArw== X-Google-Smtp-Source: AGHT+IGYuPU7B4STNut8rJKLR1X8UAMZsqIDPCnqUoAOB9egdFLZykxYHQk1WyQd863W2jrx7Rew1A== X-Received: by 2002:a05:6e02:1568:b0:380:c1e5:5fd6 with SMTP id e9e14a558f8ab-38a578e3116mr46135275ab.13.1720565451798; Tue, 09 Jul 2024 15:50:51 -0700 (PDT) Received: from localhost.localdomain ([2605:a601:ad99:2e00:e9ed:d1b6:6b3c:b7f3]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-38a49075808sm6300075ab.15.2024.07.09.15.50.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jul 2024 15:50:51 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 06/11] qmi: gprs-context: Remove parsing of unused TLVs Date: Tue, 9 Jul 2024 17:50:25 -0500 Message-ID: <20240709225047.1427626-6-denkenz@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240709225047.1427626-1-denkenz@gmail.com> References: <20240709225047.1427626-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The information from these TLVs is currently unused and only printed to debug output. Same can be accomplished using an external sniffer. Remove this code until the information in these TLVs is needed for something. --- drivers/qmimodem/gprs-context.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/drivers/qmimodem/gprs-context.c b/drivers/qmimodem/gprs-context.c index 5582a8052c0b..f29f10720710 100644 --- a/drivers/qmimodem/gprs-context.c +++ b/drivers/qmimodem/gprs-context.c @@ -173,29 +173,17 @@ static void get_settings_ipv4(struct ofono_gprs_context *gc, static void get_settings_cb(struct qmi_result *result, void *user_data) { - static const uint8_t RESULT_PDP_TYPE = 0x11; /* uint8 */ - static const uint8_t RESULT_APN = 0x14; /* string */ static const uint8_t RESULT_IP_FAMILY = 0x2b; /* uint8 */ struct cb_data *cbd = user_data; ofono_gprs_context_cb_t cb = cbd->cb; struct ofono_gprs_context *gc = cbd->user; - uint8_t pdp_type, ip_family; - char *apn; + uint8_t ip_family; DBG(""); if (qmi_result_set_error(result, NULL)) goto done; - apn = qmi_result_get_string(result, RESULT_APN); - if (apn) { - DBG("APN: %s", apn); - l_free(apn); - } - - if (qmi_result_get_uint8(result, RESULT_PDP_TYPE, &pdp_type)) - DBG("PDP type %d", pdp_type); - if (!qmi_result_get_uint8(result, RESULT_IP_FAMILY, &ip_family)) { ofono_error("No IP family in results"); goto done; From patchwork Tue Jul 9 22:50:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13728610 Received: from mail-il1-f179.google.com (mail-il1-f179.google.com [209.85.166.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 663F0155316 for ; Tue, 9 Jul 2024 22:50:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720565454; cv=none; b=aZM1Tjd3LCVCvP7Se331IyrCN4CKSOR6vG1i5rqAmHD/slq2/ub5Pmn7Bn9UdTzrV2bxmxZi1xN9Ofjt95I+Dqqc+phPdKX4Eh0O6ewk5fkQu7pCxPpsDWk8e26phRM4CMJIXd1xOYIHQFaW5Y4kdzWkO0AW0lqlGgnE4m4jOFY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720565454; c=relaxed/simple; bh=vO4r9cGq68fYR+sL1wt5HYkj6S6KPSzAJWZb1HayTkY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oI4IRoBwTjrDTn9Y/UeRXrCaQnBi4EfowNiabcx2prnr9diedtsTlnIo+B40b1HsQEqtsVklt+/dsHwI9WQbkw4TD3G4iD3LjXR6iKVSr3CLUexjF8/OY4OlMGicWX8I23QPE0gDU+cn9qrO0H97BGUBrcxP274LsIK7ZiaRJRM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ZpgOaplI; arc=none smtp.client-ip=209.85.166.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZpgOaplI" Received: by mail-il1-f179.google.com with SMTP id e9e14a558f8ab-376208fbe7bso22537185ab.3 for ; Tue, 09 Jul 2024 15:50:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720565452; x=1721170252; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hhDPhgBnW28NGD1DexG3TdcWj7WvUa/k14wm4z0A/Pg=; b=ZpgOaplIAOuP+ykEp6LRh4aGb7Ktou0Ae5SW+SbFOHulMZJajEC7YoM0xl7UDXXza4 6F3kP5ejdpkFgyu8UwGO5TrJvz66G/cF/hHXwI2qK1mhUccCj8kQyCvxo7cB8KWdK/4b Tv74eXeMSRhPA/xqJU5cL8jGf3K/M0we5w1/nGbhhLaJb9o4vPHGPZX/NENu+I929cpC lBjC2TzVyaXJzbPE1+mm6BbL4DVB7RbbbDOtgMz2tcmPpmXgC56cm/JHPGn7SbxSmQg3 7C8vRYDLz9WZl6hZVlGTfrnV8vJnP5TN/U0N1+Md3jajq15AUvi0mx7ir4kOYNNg3uhi TDhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720565452; x=1721170252; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hhDPhgBnW28NGD1DexG3TdcWj7WvUa/k14wm4z0A/Pg=; b=k4pso+EyqBveWFPtptQGXJBM6at/znKdeaPq8RpnHTOW8KK4eA7Ww6rbDq1Q3IFz2P JkuObMKZOcjtLADjRt+7MN/j+Wv6ytVWJ3CjCMHyBiAgGV+vnllE2yOzhJuFvLpLGCsz 7Gi04qIcdVGZ97kWTi4/04TgZcHzfGhwEzLgUgcvZaBdFsBAb87tE/vTmncjyc+bK+N3 UlpsTFMU99cWCA9vellY7UJRg9eULESj2WlqvKTZCheECct4FRsenHpjSPIpP4XC8BXy mzjfxfa9AOLJNDT3Zuph8WZT0wEWgHeuyqH+8gxM8tFCz6KOZekCQ4F8ZI0HlZhTCTlj vyOQ== X-Gm-Message-State: AOJu0Ywezxl5wZRUfA0uOdcHzuTpeRuhgno36dk43R0VGGkGn2CWXBQ4 hAqyQCWDQY0jy9OcgEufAHDOmbAD2INldw9n0LAQsMdbdF2nX+gURuUYzw== X-Google-Smtp-Source: AGHT+IG6b0NNJsHHQi0Ci8mGrOGqksWYIdFdSn0w2rnur4nwGZB/evKX/Lh25zwk1VXg24z5TNk5lg== X-Received: by 2002:a05:6e02:1c49:b0:374:b07f:6dbf with SMTP id e9e14a558f8ab-38a570f889bmr42611535ab.1.1720565452529; Tue, 09 Jul 2024 15:50:52 -0700 (PDT) Received: from localhost.localdomain ([2605:a601:ad99:2e00:e9ed:d1b6:6b3c:b7f3]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-38a49075808sm6300075ab.15.2024.07.09.15.50.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jul 2024 15:50:52 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 07/11] qmi: gprs-context: Treat IP family TLV as mandatory Date: Tue, 9 Jul 2024 17:50:26 -0500 Message-ID: <20240709225047.1427626-7-denkenz@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240709225047.1427626-1-denkenz@gmail.com> References: <20240709225047.1427626-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Also, while here, coalesce two debugging statements into one. --- drivers/qmimodem/gprs-context.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/qmimodem/gprs-context.c b/drivers/qmimodem/gprs-context.c index f29f10720710..203a320a42af 100644 --- a/drivers/qmimodem/gprs-context.c +++ b/drivers/qmimodem/gprs-context.c @@ -46,10 +46,10 @@ static void pkt_status_notify(struct qmi_result *result, void *user_data) if (!status) return; - DBG("conn status %d", status->status); + if (!qmi_result_get_uint8(result, RESULT_IP_FAMILY, &ip_family)) + return; - if (qmi_result_get_uint8(result, RESULT_IP_FAMILY, &ip_family)) - DBG("ip family %d", ip_family); + DBG("conn status %d ip family %d", status->status, ip_family); switch (status->status) { case QMI_WDS_CONNECTION_STATUS_DISCONNECTED: From patchwork Tue Jul 9 22:50:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13728611 Received: from mail-il1-f179.google.com (mail-il1-f179.google.com [209.85.166.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03D13156F43 for ; Tue, 9 Jul 2024 22:50:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720565455; cv=none; b=ULeaRV3HAuwoLZ8SpSi+GfuPf8VfQPlcg3jqqJqeV13NbQap3bDtzV/kLcThrgq839p+v6LZaTCz/buLX9VnMqMYClv7+spSiWbsl3ranNkHbFypFLzhCoMwkoIGzk1I1myLivdxdedQzspz9SIVoA+bNCCrSFgR4gaieC4RVKc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720565455; c=relaxed/simple; bh=MuAW1WprFYauDCz4XMr9Kc3S07e6qhYMoW7Cy3L/pD0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=P1YqqOzYRgHZ3l1n2QGDFMtej6vwoeHmQXNoxXZ2bFkSei/OzZ41r59KcE99f9triqZk/VauX4abyJn855agc+JzI2yTze89+wVwwQSLjaFFMfQOfIk4DHFG0laa4EZbI9/bRo3BQSGPYEmww+aALBhRKaJsyyRscniOaMrwp5w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Ii0hmNiu; arc=none smtp.client-ip=209.85.166.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ii0hmNiu" Received: by mail-il1-f179.google.com with SMTP id e9e14a558f8ab-375858224adso21990835ab.0 for ; Tue, 09 Jul 2024 15:50:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720565453; x=1721170253; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Q7ZNcA2G06tng7crsSBn2P2yEzjO2BBEK4gyu2rEWUE=; b=Ii0hmNiuswcXN3a5d7QRKNUSBz9d1jCxnBXYxinXYC/puHxDCSUQR8PizpK+tJt6PK DEz+uyzM1Unevz6/z6GHNWDdRHsla0e5OKtinSxfektmHjLY7a7LzNd5Cv6gseDMKvoj 5emUnWurg275tBu3hm233ecNISuJhgJPDJSsSZWMUI+dOYShQbX8R5o1VJlkz/YCDvMv 6kX2nK+yrwUc2k/SewPHqq+ObX1p80BpyzAU2OvMMqCJ46l3jAB25WS1dh9FKfJZ7XNy ZbGUkfxw+/4NaycYTStcOqQ+kHeHsmhvHltWD4g0GuNxvmJIvP2qZr4o2aD8I+G4HFzJ 7dcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720565453; x=1721170253; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Q7ZNcA2G06tng7crsSBn2P2yEzjO2BBEK4gyu2rEWUE=; b=aEuul9oKbNOw6ZSu8McoVb+6Un0OM5NCEUKKIUTsM/wHos9EDRiYUFkanS7cCEi8q0 jgsTsxupj1K5Wyk5ggpRRXg7q1RnRjNc8E0yaJvtbQNrHDXZWmdl0UVYd9YNEHW6X3kK WWawbSLghdTalzBAgGb5wVe4CPOIxJR/Nxc1UnpZpPt9YeMBoSQfCMJUr2MfG5zAMsJu a23O6DQK3NWEbpEWnQQGqgahYh7FB9IZ0nwBW+Xlv3I4jJRtqarLIdnAyKg+UDlx5gdZ XNrSCDxx5OPHyFb58J4DNUxRPPsb0hmZQtqXdBAW1/VWkAZXgyWNDNVH3CPTMPzSM5zm 9g6A== X-Gm-Message-State: AOJu0YzT0bkp6ODARc8zAxGPoQ31jZKtlZHmZHv5GZPkh1QM+scDd0c6 O4e04T+poUXx4rxXEQ5uQsf8xBtvAi9W4cpea/Zs4b7+HIAnT93HI1vfNA== X-Google-Smtp-Source: AGHT+IE0nrdga+iJ2KqvRYbhrsT561ktkHRTK4kwjbtczZ5/UJAU6aCfpByqu1hqch9NhgivK4HcAA== X-Received: by 2002:a92:c54f:0:b0:375:c240:e7a6 with SMTP id e9e14a558f8ab-38a5a0798b7mr40247165ab.24.1720565453092; Tue, 09 Jul 2024 15:50:53 -0700 (PDT) Received: from localhost.localdomain ([2605:a601:ad99:2e00:e9ed:d1b6:6b3c:b7f3]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-38a49075808sm6300075ab.15.2024.07.09.15.50.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jul 2024 15:50:52 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 08/11] qmi: gprs-context: Set up WDS service for IPv6 Date: Tue, 9 Jul 2024 17:50:27 -0500 Message-ID: <20240709225047.1427626-8-denkenz@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240709225047.1427626-1-denkenz@gmail.com> References: <20240709225047.1427626-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Track and take ownership of the passed in WDS service meant for IPv6 connectivity. The WDS service should be bound to a particular endpoint / mux_id and register to the same indication types as the other WDS service being utilized. Additionally, WDS services are created with IPv4 as the default family preference. To support dual-stack bearers, the WDS service managing IPv6 requires 'Set IP Family Preference' command to be issued with the IPv6 family preference set. --- drivers/qmimodem/gprs-context.c | 51 ++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/drivers/qmimodem/gprs-context.c b/drivers/qmimodem/gprs-context.c index 203a320a42af..131358aa112b 100644 --- a/drivers/qmimodem/gprs-context.c +++ b/drivers/qmimodem/gprs-context.c @@ -22,6 +22,7 @@ struct gprs_context_data { struct qmi_service *wds; + struct qmi_service *ipv6; unsigned int active_context; uint32_t pkt_handle; uint8_t mux_id; @@ -454,6 +455,37 @@ static void qmi_gprs_context_detach_shutdown(struct ofono_gprs_context *gc, qmi_deactivate_primary(gc, cid, NULL, NULL); } +static void set_ip_family_preference_cb(struct qmi_result *result, + void *user_data) +{ + struct ofono_gprs_context *gc = user_data; + uint16_t error; + + if (!qmi_result_set_error(result, &error)) + error = 0; + + DBG("%u", error); + + if (error) + ofono_gprs_context_remove(gc); +} + +static int set_ip_family_preference(struct ofono_gprs_context *gc, + struct qmi_service *wds, + uint8_t family) +{ + static const uint8_t PARAM_IP_FAMILY_PREFERENCE = 0x1; + struct qmi_param *param = + qmi_param_new_uint8(PARAM_IP_FAMILY_PREFERENCE, family); + + if (qmi_service_send(wds, QMI_WDS_SET_IP_FAMILY, param, + set_ip_family_preference_cb, gc, NULL) > 0) + return 0; + + qmi_param_free(param); + return -EIO; +} + static void bind_mux_data_port_cb(struct qmi_result *result, void *user_data) { struct ofono_gprs_context *gc = user_data; @@ -547,22 +579,38 @@ static int qmi_gprs_context_probev(struct ofono_gprs_context *gc, _auto_(qmi_service_free) struct qmi_service *ipv6 = va_arg(args, struct qmi_service *); struct gprs_context_data *data; + int r; DBG(""); if (mux_id != -1) { - int r = qmi_gprs_context_bind_mux(gc, ipv4, mux_id); + r = qmi_gprs_context_bind_mux(gc, ipv4, mux_id); + if (r < 0) + return r; + r = qmi_gprs_context_bind_mux(gc, ipv6, mux_id); if (r < 0) return r; } + /* + * Default family preference for new WDS services is IPv4. For the + * service used for IPv6 contexts, issue a SET_IP_FAMILY_PREFERENCE + * command + */ + r = set_ip_family_preference(gc, ipv6, QMI_WDS_IP_FAMILY_IPV6); + if (r < 0) + return r; + data = l_new(struct gprs_context_data, 1); data->wds = l_steal_ptr(ipv4); + data->ipv6 = l_steal_ptr(ipv6); data->mux_id = mux_id; qmi_service_register(data->wds, QMI_WDS_PACKET_SERVICE_STATUS, pkt_status_notify, gc, NULL); + qmi_service_register(data->ipv6, QMI_WDS_PACKET_SERVICE_STATUS, + pkt_status_notify, gc, NULL); ofono_gprs_context_set_data(gc, data); @@ -578,6 +626,7 @@ static void qmi_gprs_context_remove(struct ofono_gprs_context *gc) ofono_gprs_context_set_data(gc, NULL); qmi_service_free(data->wds); + qmi_service_free(data->ipv6); l_free(data); } From patchwork Tue Jul 9 22:50:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13728612 Received: from mail-il1-f174.google.com (mail-il1-f174.google.com [209.85.166.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B37AD13211E for ; Tue, 9 Jul 2024 22:50:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720565456; cv=none; b=IQkyOzynFtp/cDrT2QruR/T+6uGnYeIOH2s7lCeHaSMLDJcOwuEY/L/Yq6HuTpyYj/H7c1qc2Kuzmj3nJsl2VAKyDgpaZ/DqKol2E+svR0FvQj6Qb+nNQC9GffDEFfBOlJd7w7st/3wMzhRniW0DL47psf29S/YPLtv4aDBcFzU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720565456; c=relaxed/simple; bh=IuBlJJsXS+fQxsCxX258mYz3TrGUIyNcIpmnOIVhlRw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Gyk5NOb7iVxdFgUB5crAXOUhT3nZry6jabwpPevCzkt5FvH2Llz1m6S12ybIGwTxXCBfFQ2ayP/QATINnWQC4t8NedAsV7I5digk4JPzEsLgI0Fvc+WA8FB4mF5kvddGW4xbdbLRLocD+5m3XpvzG6q5gb3XAjs4h46gKnnJ3Tk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Ti3tH8F8; arc=none smtp.client-ip=209.85.166.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ti3tH8F8" Received: by mail-il1-f174.google.com with SMTP id e9e14a558f8ab-381f24d6bc4so22519555ab.2 for ; Tue, 09 Jul 2024 15:50:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720565454; x=1721170254; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=csL85o3myY6lvAWFhlBSZg97exrpwR77AOGyo4FZMC8=; b=Ti3tH8F8vSGHh/zfnFOPHDLtjPB/Lxjpk7ASiPO1BPXfbskvah1EhqulvqA+ZODPQY 33pfDyLfIaFyMhwyeTqYHoFeQWvhm0/VmEwDNqURDWym2Ws2NOIVeJ5i2Wvb3L0oCvkX 8yhRfyxW/u19jna+peGOGNZxWRZnkQBm/A2hlIy1qvhFaTbgVg7L8A2QXbkQnVmOjmgr 2QbbFfDv0E6JrwsdClgYK4wS705VOoGcKzaF2REKrRvG2Cqlw2D8l0wcDtQBoIf5WHQx yDe9TQ/UMWCoQIu85hP6Dn5JA/5dXhOoG3xfxe/AN+MbcUvmffoC58GYjNjn4XcmsL5c 80Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720565454; x=1721170254; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=csL85o3myY6lvAWFhlBSZg97exrpwR77AOGyo4FZMC8=; b=GDJWDxJpXLNP6kXvRG6Gqu22Oz7SY7DIeoDKjfsWp/Jw+gZIbSnBEaxi9+2SISVl3G HNsKzsrqWJWjoWfmtuI3kHIl809Pailepx36BF8F2wv0Fsfu8j3ZN+waT4tzlhS3g0gG k+tImnZAg5wgNbhq97W0dF9Y9xN4ny/Sz6qs8QtwnjQIz4+450bDBkihtLdL4AnLb5ix cPwt2/ybd6zLVt2gwdpXQ2cwrFMpNOLY8y1PIUHrRd6tInsuhqS830XMRhNHs4recidy cd+gQlTlm7JmBj0WsR5AgD8FqAZIs75YVvUddjuhrahyFa3DXEezv85AY+oB8CfigZGZ BlVQ== X-Gm-Message-State: AOJu0YyhSm8oXaPcjfoSMeCopxWJTw9tnP0xWbFs2ZiSaflcRfD4+eBJ G2kV95H03YmqACeh8v+H+90EGPp77n81MrkoMdHOqKQ6Bqiq0uWkMf/evg== X-Google-Smtp-Source: AGHT+IHzpL+l5lKnRmvfTPJq/IAeocbyRyMNBWjPedCxrhlVTQwqYnDZJ20IoR5bj2OJ/V6QWfkngQ== X-Received: by 2002:a05:6e02:b26:b0:382:db50:6ebd with SMTP id e9e14a558f8ab-38a5910a09bmr43495875ab.27.1720565453693; Tue, 09 Jul 2024 15:50:53 -0700 (PDT) Received: from localhost.localdomain ([2605:a601:ad99:2e00:e9ed:d1b6:6b3c:b7f3]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-38a49075808sm6300075ab.15.2024.07.09.15.50.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jul 2024 15:50:53 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 09/11] qmi: gprs-context: refactor detach_shutdown path Date: Tue, 9 Jul 2024 17:50:28 -0500 Message-ID: <20240709225047.1427626-9-denkenz@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240709225047.1427626-1-denkenz@gmail.com> References: <20240709225047.1427626-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Since there will now be up to two WDS clients used (Dual stack contexts), the detach_shutdown path needs to send a Stop Network command on any client with an ongoing packet connection. Implement this by keeping track of WDS clients used for ipv4 and ipv6 families respectively and their respective packet handles. Rename member 'wds' to 'ipv4', it is used as-is for currently existing code paths. Similarly, rename pkt_handle to packet_handle_ipv4. Note that the dedicated WDS client associated with the 'ipv6' qmi_service handle is effectively not used as of this commit. This is because packet_handle_ipv6 is never set. IPv6-only context activations will continue using 'ipv4' and 'packet_handle_ipv4'. This will be addressed in follow-on commits. --- drivers/qmimodem/gprs-context.c | 114 ++++++++++++++++++++++++++------ 1 file changed, 95 insertions(+), 19 deletions(-) diff --git a/drivers/qmimodem/gprs-context.c b/drivers/qmimodem/gprs-context.c index 131358aa112b..bdbf50efd721 100644 --- a/drivers/qmimodem/gprs-context.c +++ b/drivers/qmimodem/gprs-context.c @@ -21,13 +21,26 @@ #include "util.h" struct gprs_context_data { - struct qmi_service *wds; + struct qmi_service *ipv4; struct qmi_service *ipv6; unsigned int active_context; - uint32_t pkt_handle; + uint32_t packet_handle_ipv4; + uint32_t packet_handle_ipv6; uint8_t mux_id; }; +static void check_all_deactivated(struct ofono_gprs_context *gc) +{ + struct gprs_context_data *data = ofono_gprs_context_get_data(gc); + + if (data->packet_handle_ipv4 || data->packet_handle_ipv6) + return; + + /* All families have been disconnected */ + ofono_gprs_context_deactivated(gc, data->active_context); + data->active_context = 0; +} + static void pkt_status_notify(struct qmi_result *result, void *user_data) { static const uint8_t RESULT_CONN_STATUS = 0x01; @@ -54,12 +67,11 @@ static void pkt_status_notify(struct qmi_result *result, void *user_data) switch (status->status) { case QMI_WDS_CONNECTION_STATUS_DISCONNECTED: - if (data->pkt_handle) { - /* The context has been disconnected by the network */ - ofono_gprs_context_deactivated(gc, data->active_context); - data->pkt_handle = 0; - data->active_context = 0; + if (data->packet_handle_ipv4) { + data->packet_handle_ipv4 = 0; + check_all_deactivated(gc); } + break; } } @@ -227,7 +239,7 @@ static void start_net_cb(struct qmi_result *result, void *user_data) DBG("packet handle %d", handle); - data->pkt_handle = handle; + data->packet_handle_ipv4 = handle; /* * Explicitly request certain information to be provided. The requested @@ -243,7 +255,7 @@ static void start_net_cb(struct qmi_result *result, void *user_data) param = qmi_param_new_uint32(PARAM_REQUESTED_SETTINGS, requested_settings); - if (qmi_service_send(data->wds, QMI_WDS_GET_CURRENT_SETTINGS, param, + if (qmi_service_send(data->ipv4, QMI_WDS_GET_CURRENT_SETTINGS, param, get_settings_cb, cbd, cb_data_unref) > 0) { cb_data_ref(cbd); return; @@ -292,7 +304,7 @@ static void get_lte_attach_param_cb(struct qmi_result *result, void *user_data) param = qmi_param_new_uint8(QMI_WDS_PARAM_IP_FAMILY, ip_family); - if (qmi_service_send(data->wds, QMI_WDS_START_NETWORK, param, + if (qmi_service_send(data->ipv4, QMI_WDS_START_NETWORK, param, start_net_cb, cbd, cb_data_unref) > 0) { cb_data_ref(cbd); return; @@ -322,7 +334,7 @@ static void qmi_gprs_read_settings(struct ofono_gprs_context* gc, DBG("cid %u", cid); - if (qmi_service_send(data->wds, QMI_WDS_GET_LTE_ATTACH_PARAMETERS, + if (qmi_service_send(data->ipv4, QMI_WDS_GET_LTE_ATTACH_PARAMETERS, NULL, get_lte_attach_param_cb, cbd, cb_data_unref) > 0) { data->active_context = cid; @@ -381,7 +393,7 @@ static void qmi_activate_primary(struct ofono_gprs_context *gc, qmi_param_append(param, QMI_WDS_PARAM_PASSWORD, strlen(ctx->password), ctx->password); - if (qmi_service_send(data->wds, QMI_WDS_START_NETWORK, param, + if (qmi_service_send(data->ipv4, QMI_WDS_START_NETWORK, param, start_net_cb, cbd, cb_data_unref) > 0) return; @@ -395,6 +407,24 @@ error: l_free(cbd); } +static uint32_t send_stop_net(struct qmi_service *wds, uint32_t packet_handle, + qmi_service_result_func_t func, + void *user_data, qmi_destroy_func_t destroy) +{ + static const uint8_t PARAM_PACKET_HANDLE = 0x01; + struct qmi_param *param = qmi_param_new_uint32(PARAM_PACKET_HANDLE, + packet_handle); + uint32_t id; + + id = qmi_service_send(wds, QMI_WDS_STOP_NETWORK, param, + func, user_data, destroy); + + if (!id) + qmi_param_free(param); + + return id; +} + static void stop_net_cb(struct qmi_result *result, void *user_data) { struct cb_data *cbd = user_data; @@ -410,7 +440,7 @@ static void stop_net_cb(struct qmi_result *result, void *user_data) return; } - data->pkt_handle = 0; + data->packet_handle_ipv4 = 0; if (cb) CALLBACK_WITH_SUCCESS(cb, cbd->data); @@ -433,9 +463,10 @@ static void qmi_deactivate_primary(struct ofono_gprs_context *gc, cbd->user = gc; - param = qmi_param_new_uint32(PARAM_PACKET_HANDLE, data->pkt_handle); + param = qmi_param_new_uint32(PARAM_PACKET_HANDLE, + data->packet_handle_ipv4); - if (qmi_service_send(data->wds, QMI_WDS_STOP_NETWORK, param, + if (qmi_service_send(data->ipv4, QMI_WDS_STOP_NETWORK, param, stop_net_cb, cbd, l_free) > 0) return; @@ -447,12 +478,57 @@ static void qmi_deactivate_primary(struct ofono_gprs_context *gc, l_free(cbd); } +static void stop_net_detach_ipv4_cb(struct qmi_result *result, void *user_data) +{ + struct ofono_gprs_context *gc = user_data; + struct gprs_context_data *data = ofono_gprs_context_get_data(gc); + uint16_t error; + + if (!qmi_result_set_error(result, &error)) + error = 0; + + DBG("error: %u", error); + + data->packet_handle_ipv4 = 0; + check_all_deactivated(gc); +} + +static void stop_net_detach_ipv6_cb(struct qmi_result *result, void *user_data) +{ + struct ofono_gprs_context *gc = user_data; + struct gprs_context_data *data = ofono_gprs_context_get_data(gc); + uint16_t error; + + if (!qmi_result_set_error(result, &error)) + error = 0; + + DBG("error: %u", error); + + data->packet_handle_ipv6 = 0; + check_all_deactivated(gc); +} + static void qmi_gprs_context_detach_shutdown(struct ofono_gprs_context *gc, unsigned int cid) { + struct gprs_context_data *data = ofono_gprs_context_get_data(gc); + DBG(""); - qmi_deactivate_primary(gc, cid, NULL, NULL); + if (data->packet_handle_ipv6 && + !send_stop_net(data->ipv6, data->packet_handle_ipv6, + stop_net_detach_ipv6_cb, gc, NULL)) + data->packet_handle_ipv6 = 0; + + if (data->packet_handle_ipv4 && + !send_stop_net(data->ipv4, data->packet_handle_ipv4, + stop_net_detach_ipv4_cb, gc, NULL)) + data->packet_handle_ipv4 = 0; + + if (data->packet_handle_ipv4 || data->packet_handle_ipv6) + return; + + data->active_context = 0; } static void set_ip_family_preference_cb(struct qmi_result *result, @@ -603,11 +679,11 @@ static int qmi_gprs_context_probev(struct ofono_gprs_context *gc, return r; data = l_new(struct gprs_context_data, 1); - data->wds = l_steal_ptr(ipv4); + data->ipv4 = l_steal_ptr(ipv4); data->ipv6 = l_steal_ptr(ipv6); data->mux_id = mux_id; - qmi_service_register(data->wds, QMI_WDS_PACKET_SERVICE_STATUS, + qmi_service_register(data->ipv4, QMI_WDS_PACKET_SERVICE_STATUS, pkt_status_notify, gc, NULL); qmi_service_register(data->ipv6, QMI_WDS_PACKET_SERVICE_STATUS, pkt_status_notify, gc, NULL); @@ -625,7 +701,7 @@ static void qmi_gprs_context_remove(struct ofono_gprs_context *gc) ofono_gprs_context_set_data(gc, NULL); - qmi_service_free(data->wds); + qmi_service_free(data->ipv4); qmi_service_free(data->ipv6); l_free(data); } From patchwork Tue Jul 9 22:50:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13728613 Received: from mail-il1-f179.google.com (mail-il1-f179.google.com [209.85.166.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5719C155316 for ; Tue, 9 Jul 2024 22:50:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720565456; cv=none; b=Y1aMjzzqW3fT+eOzaLzGTPRc2g9s2IUuper6LcKbSzYLI6PXXC4A/8dTiswZtT/RqvVZncyac7VepaLy2ZDDsQ1XFdlGh0b2s1/quw0Qs0eIBKIYreYkmrP6OYraMvNEM2z0KLlvmDDxz2ZrAXiUKQg/v47vuuZJ3TFFVyGaqAM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720565456; c=relaxed/simple; bh=M1CZJ0aXZNjebQFQsNPbO1erLdOs4SmRG3aTUst4auk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VuWVbk2DGAvuDLwG8Im+Kfh+ynaVtsMsUuVlzSDGfeaGRtt69NP5AHdeR0Zpx7kToneirKOXUv/k1s8n5M6PS9EMe/UPrcoOZR3E5WbNxficx+VMgTEtJBYO8rBWZlDEJlia75ytyadtYQJ8q6KMryj0cQrZWzT0G2dzR1unYF0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=BfZbV/d1; arc=none smtp.client-ip=209.85.166.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BfZbV/d1" Received: by mail-il1-f179.google.com with SMTP id e9e14a558f8ab-380bfd7cdbfso27739105ab.1 for ; Tue, 09 Jul 2024 15:50:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720565454; x=1721170254; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oVv7hzeLCRW8dJ44zfujNBcMlJ4v82ih1I28IPMtpko=; b=BfZbV/d19Fq7mwyLAo2vywq1oOP4hBszBDkakkCuR0/8jcozeI8zzoQQpum6IILOdY YdX/PdRPTW7fXD+hr/K9uHAfYjmbfW8eBxw0CsyyLfFqt09cq6YK917sLvULOoUY+fKs icJvoTvLRb2akwuyOYrjv+UbZR94BE5IEddfN/c/G+ytY1kK5H2ev/w2iNhmBZceh4TR fQRfm7sKvKJUyeHMjEYq+18Io8Z16uF2INISeAW2T86YVBNd8BX5O0gf4tNWXDR9Ig4P KPpA5cSbFQkTYGBNuDqSDmyevtcdDoyiCTFSw5DXlSiGpbqQyu6JliHO7lswH0ddZTkd 3Y/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720565454; x=1721170254; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oVv7hzeLCRW8dJ44zfujNBcMlJ4v82ih1I28IPMtpko=; b=Gsp4HOTqDj/LGhZaOpSGVYuVcExzKhX0wseFJ/e3dX0dBJJbPDuumNMzdCN45zbvWB Uhlz5ZN4Sg+7yarPBVMR7noYtKPknmapDOCtIsa7iauBSxLFQURRzoltjp8hfSOTJ1Ph p3wmlWe/qdLOA3L1GQLmt2UH8E9JXhuON/8eVJAhZFNq9hsmlMZbm0XZJVApWYpWXhQJ y9Si+1gsJ61eFbAjElInOp4UvwLXnWBlQTzUIruyWSci01qR5VnRhLZzTbPYurYoIR35 ZRMtGW4e0nsBVQWKcsikrKNRdXdIkTrCzpE3C9isKvYF/RWuu39LIktGIVV03GRm4LkL q1tA== X-Gm-Message-State: AOJu0YwGmEPoG1GGJJjd/alqwv7I4yI/pD18N5XGNxtczjBY4op8f6xd 1W3PqXufW5+WueEinDHEF2cng9cCaRfNoVJDuzli34QUqimGa9sqHM/y9Q== X-Google-Smtp-Source: AGHT+IFOVrr0VKlfzifh6XxhKS5QDc5lfkbUHQLCoufNcj+7SA5CWYbDEIj3qS4TKaS1rQiSZJU/ng== X-Received: by 2002:a05:6e02:1805:b0:375:e1fc:aea2 with SMTP id e9e14a558f8ab-38a596cad07mr43303065ab.31.1720565454388; Tue, 09 Jul 2024 15:50:54 -0700 (PDT) Received: from localhost.localdomain ([2605:a601:ad99:2e00:e9ed:d1b6:6b3c:b7f3]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-38a49075808sm6300075ab.15.2024.07.09.15.50.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jul 2024 15:50:54 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 10/11] qmi: gprs-context: refactor deactivate_primary Date: Tue, 9 Jul 2024 17:50:29 -0500 Message-ID: <20240709225047.1427626-10-denkenz@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240709225047.1427626-1-denkenz@gmail.com> References: <20240709225047.1427626-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 When multiple WDS clients are used (Dual stack contexts), the deactivate_primary path needs to send Stop Network command on any client with an ongoing packet connection. The following strategy is now used: 1. If no packet connections are ongoing on either IPv4 or IPV6 WDS client, callback with an error 2. If IPv6 WDS client is used, attempt to stop that first, otherwise, proceed to step 4. 3. If IPv6 WDS client is the only client used, report the success / failure of this operation. Otherwise, proceed to step 4. 4. Try to send a Stop Network request to the IPv4 WDS client. If this step fails, callback with an error. --- drivers/qmimodem/gprs-context.c | 84 ++++++++++++++++++++++++--------- 1 file changed, 62 insertions(+), 22 deletions(-) diff --git a/drivers/qmimodem/gprs-context.c b/drivers/qmimodem/gprs-context.c index bdbf50efd721..f05f10a277fd 100644 --- a/drivers/qmimodem/gprs-context.c +++ b/drivers/qmimodem/gprs-context.c @@ -425,57 +425,97 @@ static uint32_t send_stop_net(struct qmi_service *wds, uint32_t packet_handle, return id; } -static void stop_net_cb(struct qmi_result *result, void *user_data) +static void stop_net_ipv4_cb(struct qmi_result *result, void *user_data) { struct cb_data *cbd = user_data; ofono_gprs_context_cb_t cb = cbd->cb; struct ofono_gprs_context *gc = cbd->user; struct gprs_context_data *data = ofono_gprs_context_get_data(gc); + uint16_t error; - DBG(""); + if (!qmi_result_set_error(result, &error)) + error = 0; - if (qmi_result_set_error(result, NULL)) { - if (cb) - CALLBACK_WITH_FAILURE(cb, cbd->data); - return; - } + DBG("error: %u", error); data->packet_handle_ipv4 = 0; + data->active_context = 0; - if (cb) - CALLBACK_WITH_SUCCESS(cb, cbd->data); + if (error) + CALLBACK_WITH_FAILURE(cb, cbd->data); else - ofono_gprs_context_deactivated(gc, data->active_context); + CALLBACK_WITH_SUCCESS(cb, cbd->data); +} - data->active_context = 0; +static void stop_net_ipv6_cb(struct qmi_result *result, void *user_data) +{ + struct cb_data *cbd = user_data; + ofono_gprs_context_cb_t cb = cbd->cb; + struct ofono_gprs_context *gc = cbd->user; + struct gprs_context_data *data = ofono_gprs_context_get_data(gc); + uint16_t error; + + if (!qmi_result_set_error(result, &error)) + error = 0; + + DBG("error: %u", error); + + data->packet_handle_ipv6 = 0; + + if (data->packet_handle_ipv4) { + if (send_stop_net(data->ipv4, data->packet_handle_ipv4, + stop_net_ipv4_cb, + cb_data_ref(cbd), cb_data_unref)) + return; + + cb_data_unref(cbd); + data->active_context = 0; + data->packet_handle_ipv4 = 0; + goto error; + } else + data->active_context = 0; + + if (!error) { + CALLBACK_WITH_SUCCESS(cb, cbd->data); + return; + } +error: + CALLBACK_WITH_FAILURE(cb, cbd->data); } static void qmi_deactivate_primary(struct ofono_gprs_context *gc, unsigned int cid, ofono_gprs_context_cb_t cb, void *user_data) { - static const uint8_t PARAM_PACKET_HANDLE = 0x01; struct gprs_context_data *data = ofono_gprs_context_get_data(gc); - struct cb_data *cbd = cb_data_new(cb, user_data); - struct qmi_param *param; + struct cb_data *cbd; + uint32_t id; DBG("cid %u", cid); + if (!data->packet_handle_ipv4 && !data->packet_handle_ipv6) + goto error; + + cbd = cb_data_new(cb, user_data); cbd->user = gc; - param = qmi_param_new_uint32(PARAM_PACKET_HANDLE, - data->packet_handle_ipv4); + if (data->packet_handle_ipv6) + id = send_stop_net(data->ipv6, data->packet_handle_ipv6, + stop_net_ipv6_cb, cbd, cb_data_unref); + else + id = send_stop_net(data->ipv4, data->packet_handle_ipv4, + stop_net_ipv4_cb, cbd, cb_data_unref); - if (qmi_service_send(data->ipv4, QMI_WDS_STOP_NETWORK, param, - stop_net_cb, cbd, l_free) > 0) + if (id) return; - qmi_param_free(param); - - if (cb) - CALLBACK_WITH_FAILURE(cb, user_data); + data->packet_handle_ipv6 = 0; + data->packet_handle_ipv4 = 0; + data->active_context = 0; l_free(cbd); +error: + CALLBACK_WITH_FAILURE(cb, user_data); } static void stop_net_detach_ipv4_cb(struct qmi_result *result, void *user_data) From patchwork Tue Jul 9 22:50:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13728614 Received: from mail-il1-f182.google.com (mail-il1-f182.google.com [209.85.166.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 034B814D439 for ; Tue, 9 Jul 2024 22:50:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720565457; cv=none; b=iE/wREZwtDiHV56DmSt1grPv+14MJIz5hT2trsOGob+up9Xr6EdNRXI5g+LBnL3LuGMoJMosgGcURwx0dVH5Prb8mNAJwMVa2xSneV1NhOiEKPqwlFIu3RTJOHeWNrxQC7+9en2/lg0xBeZqKj34RvcSk3jSG6qCbUdzP4JLZl0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720565457; c=relaxed/simple; bh=K5VIJjRcsyDyp8z7p9dkucsEe/Yt0allgMJ+oCLRrAw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CDchZXNRvRAwSiO3DVRO4aovl4ZlM7tnpedysMUBTBDwzeWz1/ILy7lblKaPY3Kg7GDUUGvbWr6VYQxIEuJl2YefH558asyHPEQBa7PdKIf0DHReLkUwlcHvDxKnahKpfPk5WXw/iNG5cUsZ9zOcE6+ym5wVIlQNgQWsIzcYiws= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=F+G8qT7L; arc=none smtp.client-ip=209.85.166.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="F+G8qT7L" Received: by mail-il1-f182.google.com with SMTP id e9e14a558f8ab-389ccd2f0abso8032965ab.2 for ; Tue, 09 Jul 2024 15:50:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720565455; x=1721170255; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YRHXUrwuSLVSLb+HJJDmp1GdLHzvQfwHZ0Kpu9OPzC8=; b=F+G8qT7LxZvC2WOLP/+8rUDrwHIwjsrp5bnpsSu1cJZGbCeUDeTngmXAS/DxSEgb4d +xSbPwe0FZjd5ltZJJm11WqSCgio0/e9YackazkjpU+pGHvOWiLj1g6aYZgNwcfThhJO BHJHYkJOEhx64XarcbYfOA9dqSLk/rjw5ziuim2wze8twqcRk5zWE16FAKG2/uw5Ffn7 oEssp3tWw842tUQKZK7FdQe3clu9JbTxlUIs3lbZasUvpT9zZjlnBkfLqF/rCrpqTdnJ LHUEFkPfKp3t2U7xNX6YZ7WwTLSZE6EGozZEUfnICLOK/m9A9m88Xo3KcKKo18EzeF4R Yvsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720565455; x=1721170255; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YRHXUrwuSLVSLb+HJJDmp1GdLHzvQfwHZ0Kpu9OPzC8=; b=B86NiXg6uTCfcTeVp3QutTrfmjsirtm1MNh4o0HoT+sAuyhF34Rm71EDEdrckyVXgO FXOsZIax2A9P5IvR/hV7SzGZgoge2sltvPymMvL7bpdhfEMntpCA1LDb4/gRizPjmJUY qKU37DlAihJcFqUnx6UO130/B4Nw7Rn0kxoTcI77IvHse4A7K83Wv4xv7u/+vZRpZouw 7lr0hq3eLapOGn04ycztmK5MrtJCijqiNgfC9l/PXPNY5G1Y2T+TglAnaRn215sEZfya zHmaHwTHUjcUh9E8f50P2BxuA/nBLPqXLVEnAFwVqqHjh6onSNd1duYPC5QuVDoX4mgc /Log== X-Gm-Message-State: AOJu0YwrpUhz+RiGBUjfm58H/MnZmo33r22l37hYV32sLZRciDo+uH5v 9H/oY0ICqgndJBK9kQyuT5UYh5knFHa1fnzSlsgxXPblVQHDcIMLkKgJUQ== X-Google-Smtp-Source: AGHT+IHZ6zsXFYugpFG0FLXl63iBvFxz1VYuQ/tiwK/P/CISiWFX9lehlr3nQoIFslYwBn4cdJ+w3g== X-Received: by 2002:a92:cdab:0:b0:380:fd76:3d9e with SMTP id e9e14a558f8ab-38a5a45d088mr49547305ab.22.1720565454995; Tue, 09 Jul 2024 15:50:54 -0700 (PDT) Received: from localhost.localdomain ([2605:a601:ad99:2e00:e9ed:d1b6:6b3c:b7f3]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-38a49075808sm6300075ab.15.2024.07.09.15.50.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jul 2024 15:50:54 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 11/11] qmi: gprs-context: Dual-Stack context activation support Date: Tue, 9 Jul 2024 17:50:30 -0500 Message-ID: <20240709225047.1427626-11-denkenz@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240709225047.1427626-1-denkenz@gmail.com> References: <20240709225047.1427626-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Support dual-stack contexts by utilizing two WDS services, one for each family type. For IPv4 only contexts, the WDS service 'ipv4' is used. For IPv6 only contexts, the WDS service 'ipv6' is used. For dual stack contexts, both WDS services are used simultaneously. When a default bearer (using read_settings) or primary context is activated (using activate_primary), the Start Network command is issued on one or both of the WDS services. Once the Start Network command succeeds, the returned packet handle is stored in 'packet_handle_ipv4' or 'packet_handle_ipv6', depending on the selected IP family. Subsequently Get Current Settings command is issued and settings are read from the QMI response and applied to the context. Success is signaled to the core if at least one Start Network command succeeded. Otherwise, an error is signaled. --- drivers/qmimodem/gprs-context.c | 364 ++++++++++++++++++++------------ 1 file changed, 228 insertions(+), 136 deletions(-) diff --git a/drivers/qmimodem/gprs-context.c b/drivers/qmimodem/gprs-context.c index f05f10a277fd..fa6c5fa1c85e 100644 --- a/drivers/qmimodem/gprs-context.c +++ b/drivers/qmimodem/gprs-context.c @@ -26,6 +26,8 @@ struct gprs_context_data { unsigned int active_context; uint32_t packet_handle_ipv4; uint32_t packet_handle_ipv6; + uint32_t start_network_ipv4_id; + uint32_t start_network_ipv6_id; uint8_t mux_id; }; @@ -67,23 +69,49 @@ static void pkt_status_notify(struct qmi_result *result, void *user_data) switch (status->status) { case QMI_WDS_CONNECTION_STATUS_DISCONNECTED: - if (data->packet_handle_ipv4) { + if (ip_family == QMI_WDS_IP_FAMILY_IPV4 && + data->packet_handle_ipv4) { data->packet_handle_ipv4 = 0; check_all_deactivated(gc); } + if (ip_family == QMI_WDS_IP_FAMILY_IPV6 && + data->packet_handle_ipv6) { + data->packet_handle_ipv6 = 0; + check_all_deactivated(gc); + } + break; } } -static void get_settings_ipv6(struct ofono_gprs_context *gc, - struct qmi_result *result) +static void check_all_activated(struct gprs_context_data *data, + ofono_gprs_context_cb_t cb, + void *user_data) +{ + if (data->start_network_ipv4_id || data->start_network_ipv6_id) + return; + + if (!data->packet_handle_ipv4 && !data->packet_handle_ipv6) { + data->active_context = 0; + CALLBACK_WITH_FAILURE(cb, user_data); + return; + } + + CALLBACK_WITH_SUCCESS(cb, user_data); +} + +static void get_settings_ipv6_cb(struct qmi_result *result, void *user_data) { static const uint8_t RESULT_IP_ADDRESS = 0x25; static const uint8_t RESULT_GATEWAY = 0x26; static const uint8_t RESULT_PRIMARY_DNS = 0x27; static const uint8_t RESULT_SECONDARY_DNS = 0x28; static const uint8_t RESULT_MTU = 0x29; + struct cb_data *cbd = user_data; + struct ofono_gprs_context *gc = cbd->user; + struct gprs_context_data *data = ofono_gprs_context_get_data(gc); + uint16_t error; const char *dns[3] = { NULL, NULL, NULL }; char dns1str[INET6_ADDRSTRLEN]; char dns2str[INET6_ADDRSTRLEN]; @@ -92,6 +120,13 @@ static void get_settings_ipv6(struct ofono_gprs_context *gc, uint16_t len; uint32_t mtu; + data->start_network_ipv6_id = 0; + + if (qmi_result_set_error(result, &error)) { + DBG("error: %u", error); + goto done; + } + tlv = qmi_result_get(result, RESULT_IP_ADDRESS, &len); if (tlv && len == sizeof(struct in6_addr) + 1) { const struct in6_addr *ip = tlv; @@ -131,22 +166,35 @@ static void get_settings_ipv6(struct ofono_gprs_context *gc, if (qmi_result_get_uint32(result, RESULT_MTU, &mtu)) DBG("MTU: %u", mtu); + +done: + check_all_activated(data, cbd->cb, cbd->data); } -static void get_settings_ipv4(struct ofono_gprs_context *gc, - struct qmi_result *result) +static void get_settings_ipv4_cb(struct qmi_result *result, void *user_data) { static const uint8_t RESULT_PRIMARY_DNS = 0x15; static const uint8_t RESULT_SECONDARY_DNS = 0x16; static const uint8_t RESULT_IP_ADDRESS = 0x1e; static const uint8_t RESULT_GATEWAY = 0x20; static const uint8_t RESULT_GATEWAY_NETMASK = 0x21; + struct cb_data *cbd = user_data; + struct ofono_gprs_context *gc = cbd->user; + struct gprs_context_data *data = ofono_gprs_context_get_data(gc); + uint16_t error; uint32_t ip_addr; struct in_addr addr; char* straddr; const char *dns[3] = { NULL, NULL, NULL }; char dns_buf[2][INET_ADDRSTRLEN]; + data->start_network_ipv4_id = 0; + + if (qmi_result_set_error(result, &error)) { + DBG("error: %u", error); + goto done; + } + if (qmi_result_get_uint32(result, RESULT_IP_ADDRESS, &ip_addr)) { addr.s_addr = htonl(ip_addr); straddr = inet_ntoa(addr); @@ -182,65 +230,20 @@ static void get_settings_ipv4(struct ofono_gprs_context *gc, if (dns[0]) ofono_gprs_context_set_ipv4_dns_servers(gc, dns); -} - -static void get_settings_cb(struct qmi_result *result, void *user_data) -{ - static const uint8_t RESULT_IP_FAMILY = 0x2b; /* uint8 */ - struct cb_data *cbd = user_data; - ofono_gprs_context_cb_t cb = cbd->cb; - struct ofono_gprs_context *gc = cbd->user; - uint8_t ip_family; - - DBG(""); - - if (qmi_result_set_error(result, NULL)) - goto done; - - if (!qmi_result_get_uint8(result, RESULT_IP_FAMILY, &ip_family)) { - ofono_error("No IP family in results"); - goto done; - } - - switch (ip_family) { - case QMI_WDS_IP_FAMILY_IPV4: - get_settings_ipv4(gc, result); - break; - case QMI_WDS_IP_FAMILY_IPV6: - get_settings_ipv6(gc, result); - break; - default: - break; - } done: - CALLBACK_WITH_SUCCESS(cb, cbd->data); + check_all_activated(data, cbd->cb, cbd->data); } -static void start_net_cb(struct qmi_result *result, void *user_data) +static uint32_t send_get_current_settings(struct qmi_service *wds, + qmi_service_result_func_t func, + void *user_data, + qmi_destroy_func_t destroy) { - static const uint8_t RESULT_PACKET_HANDLE = 0x01; static const uint8_t PARAM_REQUESTED_SETTINGS = 0x10; - struct cb_data *cbd = user_data; - ofono_gprs_context_cb_t cb = cbd->cb; - struct ofono_gprs_context *gc = cbd->user; - struct gprs_context_data *data = ofono_gprs_context_get_data(gc); - uint32_t handle; uint32_t requested_settings = 0; struct qmi_param *param; - - DBG(""); - - if (qmi_result_set_error(result, NULL)) - goto error; - - if (!qmi_result_get_uint32(result, RESULT_PACKET_HANDLE, &handle)) - goto error; - - DBG("packet handle %d", handle); - - data->packet_handle_ipv4 = handle; - + uint32_t id; /* * Explicitly request certain information to be provided. The requested * settings is a bit field, with each bit representing whether the @@ -254,18 +257,149 @@ static void start_net_cb(struct qmi_result *result, void *user_data) L_BITS_SET(&requested_settings, 2, 3, 4, 5, 6, 7, 8, 9, 13, 14, 15, 17); param = qmi_param_new_uint32(PARAM_REQUESTED_SETTINGS, requested_settings); + id = qmi_service_send(wds, QMI_WDS_GET_CURRENT_SETTINGS, param, + func, user_data, destroy); + + if (!id) + qmi_param_free(param); + + return id; +} + +static void start_network_common_cb(int family, struct qmi_result *result, + struct cb_data *cbd, + struct qmi_service *wds, + qmi_service_result_func_t func, + uint32_t *packet_handle, + uint32_t *family_start_id) +{ + static const uint8_t RESULT_PACKET_HANDLE = 0x01; + struct ofono_gprs_context *gc = cbd->user; + struct gprs_context_data *data = ofono_gprs_context_get_data(gc); + uint16_t error; + + *family_start_id = 0; - if (qmi_service_send(data->ipv4, QMI_WDS_GET_CURRENT_SETTINGS, param, - get_settings_cb, cbd, cb_data_unref) > 0) { - cb_data_ref(cbd); + if (!qmi_result_set_error(result, &error)) + error = 0; + + DBG("family: %d, error: %u", family, error); + + if (error) + goto error; + + if (!qmi_result_get_uint32(result, RESULT_PACKET_HANDLE, packet_handle)) + goto error; + + *family_start_id = + send_get_current_settings(wds, func, + cb_data_ref(cbd), cb_data_unref); + if (*family_start_id) return; + + *packet_handle = 0; + cb_data_unref(cbd); +error: + check_all_activated(data, cbd->cb, cbd->data); +} + +static void start_network_ipv4_cb(struct qmi_result *result, void *user_data) +{ + struct cb_data *cbd = user_data; + struct ofono_gprs_context *gc = cbd->user; + struct gprs_context_data *data = ofono_gprs_context_get_data(gc); + + start_network_common_cb(4, result, user_data, + data->ipv4, get_settings_ipv4_cb, + &data->packet_handle_ipv4, + &data->start_network_ipv4_id); +} + +static void start_network_ipv6_cb(struct qmi_result *result, void *user_data) +{ + struct cb_data *cbd = user_data; + struct ofono_gprs_context *gc = cbd->user; + struct gprs_context_data *data = ofono_gprs_context_get_data(gc); + + start_network_common_cb(6, result, user_data, + data->ipv6, get_settings_ipv6_cb, + &data->packet_handle_ipv6, + &data->start_network_ipv6_id); +} + +static struct qmi_param *param_from_context(uint8_t ip_family, + const struct ofono_gprs_primary_context *ctx) +{ + struct qmi_param *param = qmi_param_new(); + uint8_t auth; + + qmi_param_append_uint8(param, QMI_WDS_PARAM_IP_FAMILY, ip_family); + + if (!ctx) + goto done; + + qmi_param_append(param, QMI_WDS_PARAM_APN, + strlen(ctx->apn), ctx->apn); + + auth = qmi_wds_auth_from_ofono(ctx->auth_method); + qmi_param_append_uint8(param, QMI_WDS_PARAM_AUTHENTICATION_PREFERENCE, + auth); + + if (auth && ctx->username[0] != '\0') + qmi_param_append(param, QMI_WDS_PARAM_USERNAME, + strlen(ctx->username), ctx->username); + + if (auth && ctx->password[0] != '\0') + qmi_param_append(param, QMI_WDS_PARAM_PASSWORD, + strlen(ctx->password), ctx->password); +done: + return param; +} + +static int start_network(uint8_t iptype, struct gprs_context_data *data, + const struct ofono_gprs_primary_context *ctx, + struct cb_data *cbd) +{ + struct qmi_param *param; + + if (!L_IN_SET(iptype, QMI_WDS_IP_SUPPORT_IPV4, QMI_WDS_IP_SUPPORT_IPV6, + QMI_WDS_IP_SUPPORT_IPV4V6)) + return -EINVAL; + + if (iptype == QMI_WDS_IP_SUPPORT_IPV4 || + iptype == QMI_WDS_IP_SUPPORT_IPV4V6) { + param = param_from_context(QMI_WDS_IP_FAMILY_IPV4, ctx); + + data->start_network_ipv4_id = + qmi_service_send(data->ipv4, QMI_WDS_START_NETWORK, + param, start_network_ipv4_cb, + cb_data_ref(cbd), cb_data_unref); + + if (!data->start_network_ipv4_id) { + cb_data_unref(cbd); + qmi_param_free(param); + } } - qmi_param_free(param); + if (iptype == QMI_WDS_IP_SUPPORT_IPV6 || + iptype == QMI_WDS_IP_SUPPORT_IPV4V6) { + param = param_from_context(QMI_WDS_IP_FAMILY_IPV6, ctx); -error: - data->active_context = 0; - CALLBACK_WITH_FAILURE(cb, cbd->data); + data->start_network_ipv6_id = + qmi_service_send(data->ipv6, QMI_WDS_START_NETWORK, + param, start_network_ipv6_cb, + cb_data_ref(cbd), cb_data_unref); + + if (!data->start_network_ipv6_id) { + cb_data_unref(cbd); + qmi_param_free(param); + } + } + + if (data->start_network_ipv4_id || data->start_network_ipv6_id) + return 0; + + return -EIO; } static void get_lte_attach_param_cb(struct qmi_result *result, void *user_data) @@ -277,40 +411,20 @@ static void get_lte_attach_param_cb(struct qmi_result *result, void *user_data) struct gprs_context_data *data = ofono_gprs_context_get_data(gc); uint16_t error; uint8_t iptype; - struct qmi_param *param; - uint8_t ip_family; - DBG(""); + if (!qmi_result_set_error(result, &error)) + error = 0; - if (qmi_result_set_error(result, &error)) - goto error; + DBG("error: %u", error); - if (!qmi_result_get_uint8(result, RESULT_IP_SUPPORT_TYPE, &iptype)) + if (error) goto error; - switch (iptype) { - case QMI_WDS_IP_SUPPORT_IPV4: - ip_family = QMI_WDS_IP_FAMILY_IPV4; - break; - case QMI_WDS_IP_SUPPORT_IPV6: - ip_family = QMI_WDS_IP_FAMILY_IPV6; - break; - case QMI_WDS_IP_SUPPORT_IPV4V6: - ip_family = QMI_WDS_IP_FAMILY_IPV4; - break; - default: + if (!qmi_result_get_uint8(result, RESULT_IP_SUPPORT_TYPE, &iptype)) goto error; - } - - param = qmi_param_new_uint8(QMI_WDS_PARAM_IP_FAMILY, ip_family); - if (qmi_service_send(data->ipv4, QMI_WDS_START_NETWORK, param, - start_net_cb, cbd, cb_data_unref) > 0) { - cb_data_ref(cbd); + if (!start_network(iptype, data, NULL, cbd)) return; - } - - qmi_param_free(param); error: data->active_context = 0; @@ -320,7 +434,7 @@ error: /* * This function gets called for "automatic" contexts, those which are * not activated via activate_primary. For these, we will still need - * to call start_net in order to get the packet handle for the context. + * to call start_network in order to get the packet handle for the context. * The process for automatic contexts is essentially identical to that * for others. */ @@ -334,14 +448,15 @@ static void qmi_gprs_read_settings(struct ofono_gprs_context* gc, DBG("cid %u", cid); + data->active_context = cid; + cbd->user = gc; + if (qmi_service_send(data->ipv4, QMI_WDS_GET_LTE_ATTACH_PARAMETERS, NULL, get_lte_attach_param_cb, cbd, - cb_data_unref) > 0) { - data->active_context = cid; - cbd->user = gc; + cb_data_unref) > 0) return; - } + data->active_context = 0; CALLBACK_WITH_FAILURE(cb, cbd->data); l_free(cbd); } @@ -351,60 +466,37 @@ static void qmi_activate_primary(struct ofono_gprs_context *gc, ofono_gprs_context_cb_t cb, void *user_data) { struct gprs_context_data *data = ofono_gprs_context_get_data(gc); - struct cb_data *cbd = cb_data_new(cb, user_data); - struct qmi_param *param; - uint8_t ip_family; - uint8_t auth; + enum ofono_gprs_proto proto = ctx->proto; + struct cb_data *cbd; + int ip_type; + int r; DBG("cid %u", ctx->cid); - cbd->user = gc; - - data->active_context = ctx->cid; - - switch (ctx->proto) { - case OFONO_GPRS_PROTO_IP: - ip_family = QMI_WDS_IP_FAMILY_IPV4; - break; - case OFONO_GPRS_PROTO_IPV6: - ip_family = QMI_WDS_IP_FAMILY_IPV6; - break; - default: + if (!L_IN_SET(proto, OFONO_GPRS_PROTO_IP, OFONO_GPRS_PROTO_IPV6, + OFONO_GPRS_PROTO_IPV4V6)) goto error; - } - param = qmi_param_new(); - - qmi_param_append(param, QMI_WDS_PARAM_APN, - strlen(ctx->apn), ctx->apn); - - qmi_param_append_uint8(param, QMI_WDS_PARAM_IP_FAMILY, ip_family); - - auth = qmi_wds_auth_from_ofono(ctx->auth_method); + ip_type = qmi_wds_pdp_type_from_ofono(ctx->proto); + if (ip_type < 0) + goto error; - qmi_param_append_uint8(param, QMI_WDS_PARAM_AUTHENTICATION_PREFERENCE, - auth); + if (qmi_wds_auth_from_ofono(ctx->auth_method) < 0) + goto error; - if (auth && ctx->username[0] != '\0') - qmi_param_append(param, QMI_WDS_PARAM_USERNAME, - strlen(ctx->username), ctx->username); + data->active_context = ctx->cid; + cbd = cb_data_new(cb, user_data); + cbd->user = gc; - if (auth && ctx->password[0] != '\0') - qmi_param_append(param, QMI_WDS_PARAM_PASSWORD, - strlen(ctx->password), ctx->password); + r = start_network(ip_type, data, ctx, cbd); + cb_data_unref(cbd); - if (qmi_service_send(data->ipv4, QMI_WDS_START_NETWORK, param, - start_net_cb, cbd, cb_data_unref) > 0) + if (!r) return; - qmi_param_free(param); - -error: data->active_context = 0; - - CALLBACK_WITH_FAILURE(cb, cbd->data); - - l_free(cbd); +error: + CALLBACK_WITH_FAILURE(cb, user_data); } static uint32_t send_stop_net(struct qmi_service *wds, uint32_t packet_handle,