From patchwork Thu Jul 11 16:49: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: 13730877 Received: from mail-ot1-f52.google.com (mail-ot1-f52.google.com [209.85.210.52]) (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 61D9284047 for ; Thu, 11 Jul 2024 16:49:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720716580; cv=none; b=NSFqmWCR+UXF5hOiBCOVsGo6Bc2LAbkNWPJk4lmGeBqxCtmJKIORE0jJJkyQSRO86c6YZRvzXITqYFI/azcGSwsyhFTrChNHhEaK+5i2fYC/ygl0RGfF2Iir0DnJv6NDhPPZugUcCXaAh3StSzQUpsUpYWkFiz7dD+EVCh0FY/g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720716580; c=relaxed/simple; bh=v0v7zU7SfV5hf7UJ7ywGy/Wso6ZtVANjHh6GDJxnbp8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Dvt+p890QzgmbYB9cX4R7AzIepxOzGgiIrG6jP6grGY+AXo5NtXB6Td4EWKQ8z0HgDLVME/orLjiz+WH49hooBOoMkfFukYDnl8gdEohgC41lcEba9Z+/IcnjWmdzBYvz2RgiBy8+7J/VekwJZ9XE0l5PFb4IHsNjtV/86pGl48= 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=fPtnxgPC; arc=none smtp.client-ip=209.85.210.52 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="fPtnxgPC" Received: by mail-ot1-f52.google.com with SMTP id 46e09a7af769-7036815bde7so607443a34.3 for ; Thu, 11 Jul 2024 09:49:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720716578; x=1721321378; 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=fPtnxgPCOfuTueprG0ev4npsSOl/CdJ+S2ZPeRRAGWPkoGWmgzIl05fEGphuL4oGY7 QcNoPaKoZOdqv+g/j58IVZ0V0vUF7VM1spXX34OAAgohg1D9RSDJLqA0muMNEXZc0ylD VbVDpL4AyQUA2Gyyo/gJ/YxjyRt3uAqzn+6DGU0Qw2yLBGzPXIHcodMc8HYHdr4GUQ9Y 4OqLNJXb0j1Y7au2/Dir6v1v4Auj3qD8uzhPo6UATS95hrhTT8HDR1qVic2LIkrUO8Y9 HEfG2RpD3s3PtAFsCWjn7poat0A7Colw7JeT9Ncm0XJC5wZejhH24K9P429kZyAdIEgN 28Og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720716578; x=1721321378; 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=XNh00aOSdA8pmjLIyI69gyzND6K84WVa7r/PBfAqmqodxP3oZg5lxytO39IJ+uLN3K 68T9CATMw7eJyznrSDvJ0KJkqb8rggjZjIM1JGz15vT014JeP8/urtEgYB3qe76mCk0d f/BWUZ3Ez4ijgtO7cGf0p5/LT/bLIdYJ1BmLDcwyWw8a92rkNzuzSkImfP17Kg3UdNEd Kgw5p8SiYdv82vhs7jEhxxFCyFHBr7bmTzebbVsKGcgzdiLKl6f2KsbfUWzZgUIihElt /ub2LMJ3Gli+WWTIXeju7OZWXuO147rXXEF/Eyw6ssbhTJajmI/ZTkHEILgIY7BaNLEv kJGw== X-Gm-Message-State: AOJu0YxhMgGltUsxO6pInYAedrlkCNfCQtqVMm6zFBNyjyrgQ4srRKaS NqY93TepqPh27r9msgSqZRYE4oAyoF8+8ejjzjXyXILkr3FEPMnzws1ZjQ== X-Google-Smtp-Source: AGHT+IEB/jtCj3jy9DC2bxqZl+7npsNUq+8sosMWXe5BL0NgHrbkCcyaHjZln62i3XgP15XPxTDbAQ== X-Received: by 2002:a05:6830:4d1:b0:704:470d:638a with SMTP id 46e09a7af769-704470d68abmr8375938a34.3.1720716578107; Thu, 11 Jul 2024 09:49:38 -0700 (PDT) Received: from localhost.localdomain ([2605:a601:ad99:2e00:e9ed:d1b6:6b3c:b7f3]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-70378d3adecsm1027524a34.3.2024.07.11.09.49.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jul 2024 09:49:37 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 01/11] gobi: Limit number of premultiplexed contexts to 4 Date: Thu, 11 Jul 2024 11:49:23 -0500 Message-ID: <20240711164936.1688973-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 Thu Jul 11 16:49: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: 13730878 Received: from mail-oi1-f175.google.com (mail-oi1-f175.google.com [209.85.167.175]) (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 E6B5D16D4C5 for ; Thu, 11 Jul 2024 16:49:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720716581; cv=none; b=sEH/e7DPB+tuu52SyXm2pjtgj6MM/5ZuZBbLCrrrBsJgIWiAxoXatq5CowPNC7LSsz4kuqMcO+vOyo4AQ/UWWH7l+0WhjgxkmJ18k5sciLs7fPboaLS0FtsREN7CvoLCQIgDC43ABwhYuw1ySmF3KAP+pIDR0gsQlBTAqadcrwk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720716581; c=relaxed/simple; bh=VBJdnq/Br6eI4igqVnMW/sTXg0Gzz2fZ4MEiET6TZ3E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=j7bq7ik8ptdKdQ7O7p3CQGR7f+fGO2U6nLuTqEI0WIe+6MudBG5ehA7XUjrt7T5GnOe1qfcnw7VViCX/wN8sGxQ65YgxwfiKCocUKN5thSKycqdVHCwZCVrK0/hQfJ6GKfOIG38mPmehMTFyST6GVSUHFJKz/EKSY/Ijl9bGgrk= 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=bGVAA1FJ; arc=none smtp.client-ip=209.85.167.175 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="bGVAA1FJ" Received: by mail-oi1-f175.google.com with SMTP id 5614622812f47-3d6301e7279so663818b6e.3 for ; Thu, 11 Jul 2024 09:49:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720716579; x=1721321379; 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=bGVAA1FJLtxPCcGZn6LxYG2uma7zSEB+zaHMJqP6e6ReA9HdoUHhgO/GYMPDvWlvZv X80efDFhQZ6pT0ldGBShj8b6APnzHwbbGHnZH8vJCPcVBlch2ZG0BEpD+AJbYoakanYY IochK/HO519grJ6EUY88BSMI+brc9udYwSp+GoXd3VSdQ97YWl1Mv1UNm0S8EnSfTYh3 uFqv3frk50/ytZMgeZ6jaxx8afolwsgjjtLmGeULs2mGbbdrk+x8pqDhdrDDTRGDwHyk I4a8h6jUB3S4fPzFSeTDKO1S0eNQUKtR5NmZA4fKchVR2Y6r/nr5RT0ZqM97LYwZpxpy isog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720716579; x=1721321379; 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=sQMU5xmO2ytZNYnVTs1znvvfWig8L3GV+MyOuCU2AjU5c/wBbZN4AThpOLTFs6CQn4 xExWKnGg11XHa/vp81bKFKzyh0xjRBOXtSIvzhONz1AIimilrOUA9DbgTB6KgWS9LYml CsIvalVaCZKVCmD8KSvWxr2CbcltOYlZ5Lw9udCidJEKVkXlME/V1FxfsukimUV1mYeR iaEfN5QG0laufUVWn57C5F2a7QMsmMiKHlbEuqGLYzNRkdrpfJ2yFpjik7jinar3exHG kPUkWIaeUV/0DClzMAcQUEPYtskSwadijYnUyNSYNGf/Sq4GwiEJ+vF7l+2imRbiPd8X agWQ== X-Gm-Message-State: AOJu0Yy2Yj7UmkHWSi4/5szBua6iuPU5a8kc0tQEtlWXxpF24Ym1DFR5 U58GmHcXlftLQXMEwYsx62hwIdFSZhH8grnoQckPxm8AukHgPnhk/f+T0Q== X-Google-Smtp-Source: AGHT+IH9SOmj30iQS2+G1mKXRX9E2alPoyXb7JMttf32CbpdxGi63N+6R6odA/8p6lssyzwJHyF9Qg== X-Received: by 2002:a05:6808:170a:b0:3d2:17c2:8301 with SMTP id 5614622812f47-3d93c039304mr10247140b6e.30.1720716578825; Thu, 11 Jul 2024 09:49:38 -0700 (PDT) Received: from localhost.localdomain ([2605:a601:ad99:2e00:e9ed:d1b6:6b3c:b7f3]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-70378d3adecsm1027524a34.3.2024.07.11.09.49.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jul 2024 09:49:38 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 02/11] gobi: Request dedicated WDS services for contexts Date: Thu, 11 Jul 2024 11:49:24 -0500 Message-ID: <20240711164936.1688973-2-denkenz@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240711164936.1688973-1-denkenz@gmail.com> References: <20240711164936.1688973-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 Thu Jul 11 16:49: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: 13730879 Received: from mail-ot1-f50.google.com (mail-ot1-f50.google.com [209.85.210.50]) (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 72B1C16D4C6 for ; Thu, 11 Jul 2024 16:49:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720716581; cv=none; b=d9jLY0UnjCXrjAuf1h2/k7te9KyZ5KpxHiiRVtYVgH5KKZN4+7Tz99M+AzrGpd0V35ySCMNb4yZegOELBgdklic4/SMeEryt1+ftppTwKXTqxVMmLl+LqLBzbjJCnKmbutPNFwRw74yUg7WmY/eBQzDu7UXLPU8qYYTyDob4/pc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720716581; c=relaxed/simple; bh=vZemnAQx6lt/5RW9tkn97Ir7UgxKrTvGJK9H4hhc7BI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XnbRWzCCGM4kBaCWTUcri2gJ3YORT9QktrMv7D7nro4PeLeaia6vIXJ7IQU/1cL6H0/bmkFfbzrsTAw6pt//izaT1vBWlC28fSbZEAoxLtSwsR/cjwx0V2juTGzXMpflirE+2sbx87N1FZa4NiHTAEvowx38Hs3s0YVdU3CC3Lk= 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=UPiF7IlY; arc=none smtp.client-ip=209.85.210.50 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="UPiF7IlY" Received: by mail-ot1-f50.google.com with SMTP id 46e09a7af769-7037a208ff5so645605a34.0 for ; Thu, 11 Jul 2024 09:49:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720716579; x=1721321379; 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=UPiF7IlYUqFz+nRbAUJIHlkEhemf90phLJ9A5uLd/C44FbNwYmR/OQ7kLT1I6wkL3G LXJ3y2TrRe8Sjxiua6GkhZRWWGx7Us2UVwEnenmybJDlp+fgbqUPrFACeF+Mbg1k4Wu7 wMuDjeejGYcNTbojj+J/7PhR1JNrWlsZPugLdzZz1JvDF6u51EkPmgoXbPsjD824TAq3 5V1lqIVLVwyoP2WXw4JfKFopFjx2GEYpXbdeSEsOFAFWcXGSKOA4NsOygxSqZxYBaK7h QfMF0IKe6VFMcbvO+i7KsRbjTOimg1/aexKiT//elJvTAH8sQRQV41DMpm+BPH3fyuwV 6Tqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720716579; x=1721321379; 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=ao0laEs4C5hyaysBhuA6xUtMK/IcpwGzbOvt5IghT2lJpIQ/U9AczbBS9EeXkAGcZD vOBxRzZecc/X8Zamqa9m0JoUkms46mZkqo5Sktjvcsc3CVGhn1t49vApNa/peaW1qaQ4 IWE9io/46KhG2uTWdOU6crvvTc2d3eHmUIw9VQ5oDs2I2j/eMg/ySUBKPfMv0nBniOkI IEmaF1Qb7kxuvzyhkttkfKhfLJcLKR15QinW9DKSxYwt3vkxukEWCnOd1NTo4T8pml6B vbABky12NnCUS342GHSP6xRAkrYoBA0n6O2fR3Wa2py/NfSuTa6wITMP4cqj+frRspoK zX+w== X-Gm-Message-State: AOJu0Yyq7igkGkwocE5UL8QdZPtr21XMljuEovbdp0WNF9Yq2c84inDi AdAwiIewtJzp07zmHQDUYLw6eKykejo33Y/oraVPsvA6JJJeSjfJ6F5+6Q== X-Google-Smtp-Source: AGHT+IHxFQDeIqEPRC13tOZ66Id4O5RiFer7MZipKo6HH5S6fSdFN5lMLgscxLC4QsIco2p/Aoqrvw== X-Received: by 2002:a05:6830:9:b0:703:6dcc:f1db with SMTP id 46e09a7af769-70375b4a2f0mr8880163a34.37.1720716579465; Thu, 11 Jul 2024 09:49:39 -0700 (PDT) Received: from localhost.localdomain ([2605:a601:ad99:2e00:e9ed:d1b6:6b3c:b7f3]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-70378d3adecsm1027524a34.3.2024.07.11.09.49.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jul 2024 09:49:39 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 03/11] qmi: Enable _auto_ use for some classes Date: Thu, 11 Jul 2024 11:49:25 -0500 Message-ID: <20240711164936.1688973-3-denkenz@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240711164936.1688973-1-denkenz@gmail.com> References: <20240711164936.1688973-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 Thu Jul 11 16:49: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: 13730880 Received: from mail-ot1-f47.google.com (mail-ot1-f47.google.com [209.85.210.47]) (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 5CAAA84047 for ; Thu, 11 Jul 2024 16:49:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720716582; cv=none; b=EH3X4VCAlNBCQqnbdm3EYk+iXQ4wglNWG3oFz+euOcYE3h2ey4mvLuQbsW6jXOCE/QZtmeq8J0FLo8qTIqP+j+g/pt3rZI7N42FvzXjPJIg3nrBjw374VVCDyXbTFUXxZ4OMtPM+r45Q6byo44xymZMe0NLDSa686mspZ32TAnw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720716582; c=relaxed/simple; bh=dffnGkI17qSPW3b25IONLAlEAPrFwVApJ4+yj4idVS4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=un7nr8W2ax8P8hF+s+pf70iP+WNBSBO+XQO3uJ8EGSehGlTGZQN70hTswyfUhNA+m3Ed82d9VN1yOmAqGvRuzWeCInh9Lwd9VHMBAiIcpEYfSGoNX1trSo680ak4EMDYfdu4sFT9tkdKR5TxgkF4Ei9Qt7DoPZh05xvS0EnFOpQ= 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=UPqCvXOS; arc=none smtp.client-ip=209.85.210.47 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="UPqCvXOS" Received: by mail-ot1-f47.google.com with SMTP id 46e09a7af769-7037c464792so576750a34.2 for ; Thu, 11 Jul 2024 09:49:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720716580; x=1721321380; 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=UPqCvXOSsPhYswIux1oLGh+lLYo3NgEze5fre1DlW1F9rPeE6AYPQWGlKnkBL18VkB In5sNahvk1rEqhRNMy4dJwP+y5N9wK45nzTP3+yNLf8/w54EcX8w3ysrbWfZqyjbSg1z IAXcNtV+l5QXoi2vIYSTjJEcYrJyynm9QdDcabD+QdqkV6nGxJMQ3G/5mTcVtb7qUbvv 5X+fITkafp+OKNj5Ujvz06NVp+JZ8PlqcuFfI5oHW9gOVthWaGLrB1zeZeosna8D0wZy S37QMn+I0HjTngmo/awgUl9dx4RpJghnBkf/wXA2OY5RKXyPadxnOwLVLGqn3y+XUqmi a1dA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720716580; x=1721321380; 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=DmNz/kSGNlI+fbgwca1j2FWd2dMMa6XfQNqoX1G6Fz/YFKP0vsUiVMZwSDDfbO3hOV kv/GzKLsky1qmZ6EFrT2Tz56B9eX+zywGWkbZP/cMw8jUwChm8ABqQJQz4hZIn05HSTb t2UrX09gH/6Lk1jdq53h9qcgaETevE1j90LPvBhoiZ6HbcSnoMs/gG6mjIOVQlpOAPQW XIWE6D411uz1pZtgv/nf+8XZYqpLV4aBa8LmCYgYAjJH5D/ZPOWLUOqnFgkP3RQ4VZz3 YH/uI4vErhp1vcqHBXekDetV79yXWICwkRb3KHT7OlS9ayqg3mTw7NnHQ8ddJk363NE4 tghA== X-Gm-Message-State: AOJu0YzEfdbWO+QWP+b0/pyPQgwyfJtzfBS2bcxoUbLXTqaRoYqepU+J 2L5M9tCNuee6NzuEf5GHsYc0uruxh6C2BKglnR2ur8wd5+dBYOuUTH+bFg== X-Google-Smtp-Source: AGHT+IFurVprWC5fejLAzTXu27/QhOQ9AV9WvbeE6de3L4h3Mplcd4GShQpzWwgBhMqijPGxSvI/gQ== X-Received: by 2002:a05:6830:22ed:b0:704:4995:3733 with SMTP id 46e09a7af769-704499539f5mr6191313a34.31.1720716580368; Thu, 11 Jul 2024 09:49:40 -0700 (PDT) Received: from localhost.localdomain ([2605:a601:ad99:2e00:e9ed:d1b6:6b3c:b7f3]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-70378d3adecsm1027524a34.3.2024.07.11.09.49.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jul 2024 09:49:39 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 04/11] qmi: gprs-context: Declare qmi_service objects using _auto_ Date: Thu, 11 Jul 2024 11:49:26 -0500 Message-ID: <20240711164936.1688973-4-denkenz@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240711164936.1688973-1-denkenz@gmail.com> References: <20240711164936.1688973-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 Thu Jul 11 16:49: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: 13730881 Received: from mail-ot1-f44.google.com (mail-ot1-f44.google.com [209.85.210.44]) (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 7D8BA16D4C6 for ; Thu, 11 Jul 2024 16:49:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720716584; cv=none; b=hF2+jOKscn8nTRd24PHMXiXnyG9seGcHGxCaB/fDCVn8R1sZQNr69xFhsVCK5ySf4eqFAQaIwfd3W34+KIEHrm1NMWXcBOTo9cBLz9MXf94ACw9PXXcFhrblsMql33YBSNmj7GRY5otUXTkkHTrmr+CJy8iBG1is/U1ZE4FUiiU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720716584; c=relaxed/simple; bh=iZlHt/A2O6grO/X1yTE1vnMtETKWcpgDowWu9LQLCbc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DWNKNA1uQY+Qb3alznml8boPfaK1Kix8SNT0Y/oMaa6StZ3MFR8A1aMv4CJKoYmU7TyCTs55tPk2FXNj4xqGeh049+8gf7ULxblDgHrtSOSC5qvgtzmsY29wYwSaa9Qj1RUb5wF2bRZnMutm/tiLWdrKsycUjuvor1jqgAM3AQg= 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=axhbxdW4; arc=none smtp.client-ip=209.85.210.44 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="axhbxdW4" Received: by mail-ot1-f44.google.com with SMTP id 46e09a7af769-7035d5eec5aso511434a34.1 for ; Thu, 11 Jul 2024 09:49:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720716581; x=1721321381; 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=axhbxdW4HVLxhdxA/+fx7pi1YlWf9cgrj3sBRkz66AqsOIbWlDqBFkGxwfKoVcUHcA BcJ7acqP8BogyrOBJhKHoR4m/hNwspqUAJxZ1vvsx6LUwQYCD8pww+YPRpLzJuH1dGWt eIUJfff56KxRnweI6N6AuhqOBmNwJidrPS36LSULNYvIPwTdpHFadDkIBDA6S0Ewgo2B 7Q3BO/jRHPZtEfeGL+PfFKtVJz09k1ugvwS3vggffFfPjw2EXBJy6jt5MHQeGhSKBcPD 6RqVZxIgrQs7IRda5vESZuBQBgEonYwqBVoKgtv5ZylF+cu92JBiYYDuKXOuVq0u8BB7 8n5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720716581; x=1721321381; 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=mNnwbZuL5/S2KCh82wSWBBci6kGBn6F8LgdgYSLQpE2T1GSZsqWG8J5Osw0bTWWJbJ VXnFsKJCxFIYaK8KnwygDbkESFSC24tFAHdpNAtwqvq6327NkJkVewNSDKFsgwxNOUvk 1OW/YAhlaXa+yKkEtEaqft5GCE01iX8Lt6nMD9ZR+FnnOzE5A2L/jwXLknIRX5RRo7MR sjAHLdPxxyyagWJ0fTF1PHajlf4MgwuWUD8qfYTskpifOJRmTN5RKoporEx2MgHeVlkB s7fcEdSq5xJjTwCbjvnkg15KymcbQqcsZ4A7JuRHkWYErcXAPIHvvfRYMZQzo+fqhL75 kADg== X-Gm-Message-State: AOJu0Yz5huJtG3CBfj/4nMQL4QudHq+OF85exxs6eecIIQTQeL42xb+I 49hoi0Xc2bJ348X4OPF/uOGamfVcjhM7Vp4UPmvzuqy3WnvE5cxAquSmXg== X-Google-Smtp-Source: AGHT+IG8EJEXi2hsXqDVygasiBQyIm6VFpqHpDb9rFvdzq+61QsR/WF4Qfw27bQoO1ZJ2ZR5dHTWuA== X-Received: by 2002:a9d:480a:0:b0:703:7871:c71e with SMTP id 46e09a7af769-7037871ce5amr9027743a34.1.1720716581370; Thu, 11 Jul 2024 09:49:41 -0700 (PDT) Received: from localhost.localdomain ([2605:a601:ad99:2e00:e9ed:d1b6:6b3c:b7f3]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-70378d3adecsm1027524a34.3.2024.07.11.09.49.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jul 2024 09:49:41 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 05/11] qmi: Pass two dedicated WDS services to gprs-context Date: Thu, 11 Jul 2024 11:49:27 -0500 Message-ID: <20240711164936.1688973-5-denkenz@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240711164936.1688973-1-denkenz@gmail.com> References: <20240711164936.1688973-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 Thu Jul 11 16:49: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: 13730882 Received: from mail-oa1-f52.google.com (mail-oa1-f52.google.com [209.85.160.52]) (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 F22B084047 for ; Thu, 11 Jul 2024 16:49:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720716584; cv=none; b=sM1Dn/ye5x3q4X2oWIlbrQl4eWCEfVq19BsNK1ZpqZX1z9AFhREPv1uk3r0HV/aPqKKbE8QKerDpxg+5QkA/H9fFjYbZ0eH14d4+XNQ1cqa+W7cZ/APUfwSH9kYpgUHXTuudVCf0kxBQy2Gj4q7X9xT89JnIHqGY4oXyc3N2PbM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720716584; c=relaxed/simple; bh=0UKrj6psPpqKrHfsfXGzVkrlHHzbsnYn0x2SxeReDmI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sCChShkAD2BDiSMzdn6Vnu3flBcDmR4gFm7ej1y3wF9Bk266DnDy0VXzlx31ltc5XwXUEmvfmtj0BTM5isdAhRSZC/ABNqLybhHgx2wSqQNBqeXzIoiPQAgbjNxrOdEyc9LATChW3VgCRZK2fW41bmH3tpSvfSBd2X5n8Lq7b/c= 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=Ay1v3Yu0; arc=none smtp.client-ip=209.85.160.52 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="Ay1v3Yu0" Received: by mail-oa1-f52.google.com with SMTP id 586e51a60fabf-25e43dda1edso665682fac.0 for ; Thu, 11 Jul 2024 09:49:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720716582; x=1721321382; 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=Ay1v3Yu0WkP8WP+mHz5TeOcgKnl9BNnl8/nf4PBB2ksfpGNVK124PTlWaPDCbeVPRX +kQiEoY5qOSucoqZ70Jf741ZzlBs1uakou+hUNmlNHTXTb4iRtCj9ej694QZE1EMV2RO z9RAPZsCfUA+GK956pX/Pbhca+8jBV6jte69GaZvlcrJWYjlBcsbrTu5KVH1exL80z5F M30eWKx+gy4FQc3Qmbd3pQaMgwVD5euE3SXOTOHE3bq7GSjm19nrvUBVfX2X3w5sTJ8C ItpsBFmHhET1+iO9NAYfXQWVxdVMOytRbWGcBOqj7gGlthTrj9lgTgzi2NB68UnKO9Wa Izpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720716582; x=1721321382; 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=kwcTK3BM9rQbkaN5Yp+XXXdnpsp88NmG5CyBf0mtvyvhnejH3dYwMSd/IyfVzfeOrE ZiIU61tN2eGZvf3hq2uzIKBmEyU+qajDOzLwwCUxLS863VzyrZjcp6H4sF0TsY7/R7xn oh40ViUOHOuFSTTizTOkbYYGz6N56wJ/EZx2HsR/Jo4QgFFMCtMV3B7JIQx+aX94WbJ4 Q2JDZifyDZmRPoMHXJ1+O76vx0JtGPcZH6nKEslTvWZ9aNrfLMhm2Oirb43ahOHD4lVY 4p3To0JtU1SOXBMIl0xjaN4lNzelkaqYFLFQTVEHIj4radrWIfoXvXO3ZaWDxvBkPMzf jqgw== X-Gm-Message-State: AOJu0Yy77ACkx3t11RKGVi5chGlhF6rg9F6SZiHd1XdgRB5bVNGuTrvb AhkIWWmYDT6gPDCPYgws8qFyWrbKmQgHDf0BQii2Frrf4jgVjAWl/gSI5A== X-Google-Smtp-Source: AGHT+IFbrrLUcae+jjyUBCN7ZNeSV+KLzJ/i7ki6KOBHTsMlkQt00aYrke+6Gcq2GLXHA8U79Alo0Q== X-Received: by 2002:a05:6870:8a21:b0:25b:5032:25c4 with SMTP id 586e51a60fabf-25eaec92ce9mr7440827fac.54.1720716581929; Thu, 11 Jul 2024 09:49:41 -0700 (PDT) Received: from localhost.localdomain ([2605:a601:ad99:2e00:e9ed:d1b6:6b3c:b7f3]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-70378d3adecsm1027524a34.3.2024.07.11.09.49.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jul 2024 09:49:41 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 06/11] qmi: gprs-context: Remove parsing of unused TLVs Date: Thu, 11 Jul 2024 11:49:28 -0500 Message-ID: <20240711164936.1688973-6-denkenz@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240711164936.1688973-1-denkenz@gmail.com> References: <20240711164936.1688973-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 Thu Jul 11 16:49: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: 13730883 Received: from mail-ot1-f52.google.com (mail-ot1-f52.google.com [209.85.210.52]) (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 BB5DB16D4D2 for ; Thu, 11 Jul 2024 16:49:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720716585; cv=none; b=cKRvAai9QIufHDG2unth34oCHSiznOcgPEn9RGeQNYQEnVQ+9rgExU2Cxot+72Go5Uq5kP5hqHPggj/vnYl7fD+LCRm0UbTL9Cc4wK3iEZkMDVIULt9DI7kxjO0+MR0N2BTRtY5+jGzsuVOzNFBYzbn61697splHhZplmDPH3A8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720716585; c=relaxed/simple; bh=vO4r9cGq68fYR+sL1wt5HYkj6S6KPSzAJWZb1HayTkY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kahcMhfX2cRuFOr033JiaiyQQhGba9SBlwN4ogJEVuhuqonvOuhwlxB3Xx/PzjfxDeE0qOabSMDrNj1B5IV+bwZP1NZ+amVs+ZyWC0ifoaR4hdYF0dQr6tL57AMOWyr8muJpL3qZ7U+qBs2xqrlTuOMI6eBNpA4Rfi4UknTBues= 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=Kdiy6E9O; arc=none smtp.client-ip=209.85.210.52 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="Kdiy6E9O" Received: by mail-ot1-f52.google.com with SMTP id 46e09a7af769-708b273b437so363514a34.0 for ; Thu, 11 Jul 2024 09:49:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720716583; x=1721321383; 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=Kdiy6E9OYsa+6GaIrkzGiMrxIXnSfsc4+uLHYIdbxEEN0b2urE2MIULQkCTl2+/egD EnBFjPr5nGHaPf/QUKj5wJ6feWjX5qT+DbVXpkppFr36YeS6LOG6BSQ4BsbsCO0rkqKV 8r+d/4a/7zclT7CMFv75kD6TvxysAulXzSNgx+XWvZT394oflYstQZsstuhG+CL5YVMT 5MpWETjo7zo0RSd41Wq3Nm1Jjc5SiY/zxpUGjkGN4VKJsuNllTNda6RTmwl+/Tjp8WIe od1fo632YHvpUuHEC+B/mJY93gEt/h5aoivFddr1L4dSHbAbZ+wPsixXQsb2Om/YJgNJ uobA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720716583; x=1721321383; 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=eoUja702mb94bSomuysUJoprYG+/t+/tv31+l1i/t8mkVtDm+8A66a4vptPUdYMFjQ rfG8s9YRTJfknRrbDcluFt/ajJgrV0y34KTZvKVhOeTCbQiqC+u8fAy6zDD0a3hTL5Gn VeDJ6G52iEc7lT2m5D9KSBSjJ9LSsd+9fxYKNKpsHnXRrG1d/hyG6iXaxUUDDJ4SDqAW KdVKRnvXW/LoAulaVD1RQxSrexTWVtBX6Rm4TWB/MIEUduR/wd9Sm5Rak73wtFTV7Bvt IA5yr+xhq186xi4Gat1AU2f1YdQetI/NIL0HT9gDu0vxN9RdQGUg1JoHC/76RQ8Nt4AW b5dw== X-Gm-Message-State: AOJu0YwtjFChvY8xRAqlgubmtVyM6tCQGKdSyybQYN77HuLhrlnaXnwl 5CMhZ+Mi0c8xwR/QLn7c+ILHJjF/VoYEisSveXCxcJQEw7g8b9UjYmo/gQ== X-Google-Smtp-Source: AGHT+IHNeDn4XqNSZW769bnq8W0PMMwxajShI3pOmq0pqyNIdUVa3TwO4dYNNgfaZTf2lklUIdLwOw== X-Received: by 2002:a9d:68c2:0:b0:703:651b:382f with SMTP id 46e09a7af769-70375a05a7bmr9162654a34.3.1720716582668; Thu, 11 Jul 2024 09:49:42 -0700 (PDT) Received: from localhost.localdomain ([2605:a601:ad99:2e00:e9ed:d1b6:6b3c:b7f3]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-70378d3adecsm1027524a34.3.2024.07.11.09.49.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jul 2024 09:49:42 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 07/11] qmi: gprs-context: Treat IP family TLV as mandatory Date: Thu, 11 Jul 2024 11:49:29 -0500 Message-ID: <20240711164936.1688973-7-denkenz@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240711164936.1688973-1-denkenz@gmail.com> References: <20240711164936.1688973-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 Thu Jul 11 16:49: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: 13730884 Received: from mail-ot1-f43.google.com (mail-ot1-f43.google.com [209.85.210.43]) (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 662BB16D4DF for ; Thu, 11 Jul 2024 16:49:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720716585; cv=none; b=fX5kAzbkK4tmQ1cTuMmP8Nax/zx7fYrefkixdxAXh61GjJRWZp5PpuETSdd1Ywm77N9SZv0YhNNswrJ6LMVcRj4zon/o98dWidh0+Cpn3MIHZHAdGUU8ZH0LOBTw5/KFTG4/dluhqeRZImVcrXIaky5MAP7w2LxQyRSzni51LCk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720716585; c=relaxed/simple; bh=kDr1xsnUxUtjM3I9IlmL9vxIjJLhnalxNLEmIJVSIYk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=evLQ5BNksQkNud1IuW19TtkW8ExadHYlus/IBhyONCaDBYklQLSHN4/k/vnDSin28vCCldGVrxbGVr/MforQXRssewRTPjYiWsyPaCodi8R9+ltBgDdwksQdBCEOgCmbekYTQRIkODUsmIEexsOz6r02EC3uaA+ntCV6J5HS+w0= 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=B9Kn3EAI; arc=none smtp.client-ip=209.85.210.43 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="B9Kn3EAI" Received: by mail-ot1-f43.google.com with SMTP id 46e09a7af769-70388567d24so626197a34.0 for ; Thu, 11 Jul 2024 09:49:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720716583; x=1721321383; 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=ulFCqB4rLETVs0UZnS7S1sOnvERefdoHgf1++l0WEJM=; b=B9Kn3EAIrlBR/Jm9f/ji/GE5O2K9VydI8Zy3K18VgJnvPGteEarV/D9u87GLodwGm2 PWhqzladh2QbzRCGpa32vQAr/9YKnrjyF9NE6tIURcA8jdLAlFzY/e8vGsRNlCyG5lap rzgcfDMol0GB+Y0JwNVVDSzDMezRORj7jIQ3oxc/0oG25j/Ge9rRJfspQPlcAzajlRwt 47Cl6AQNHNzVYYiVImI6UFmYq5N5jLV1L6i+6iEnwehsIK75BFRgpiCB2a3CXrGsbfuG 48thXlXxAiZn8Ab9YKKujsqPKRZfVqdjgCzLIBIqR4O53TcuK9U965C/yyx6deDl4TRO 6J9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720716583; x=1721321383; 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=ulFCqB4rLETVs0UZnS7S1sOnvERefdoHgf1++l0WEJM=; b=PbfR+0jvI0cWpP19JRAkzPUWtCAzcLkkUAECyi9aS5c58ytT9BDM+dqK3clH3aiF7V UHhpYmtg8nEu/RuS6dCGgfd/VZIREUgkbYDAKm/RFtDU2peGqVQuSK+b4PBvJFpTqHfJ 4wTnYYiXadUQrnxKZf+mgrN2WDmJjuz9rcI0ZBcql6Rb4HsDBj1pkhJQQ0DB7fRsJZ4Y Dll15mwpjB/XEFL2o9bi5L+XP0mMv8/JmkrLALiOdN5yGCw1ZGjaziFAg4AU679QU5UI BkShIpsRS5dHzM36tDwOCSB8wleTpZ68uUT1PeQzqkFItQgwF6b9NFKFp+J/kGg+upIy qI1g== X-Gm-Message-State: AOJu0YxuJHwb2q7Tp7XLqWsrXfLy7qCetFHpI7RgBPAwOzD4rRIiUHGu ECVKLwRJP5G59OIYOIN4OZW0tGwUM6exwkS9rc+iRsyQBOuPt2078GfCiA== X-Google-Smtp-Source: AGHT+IEoOtmHk4spjTpbCvqHnhbvC8AZz9pD+DNXCs2qTO0eTymnOrGT4n6nCzTgAkVluuszTxZUPw== X-Received: by 2002:a05:6830:1e99:b0:703:6847:3ab8 with SMTP id 46e09a7af769-70375a45ca7mr9959994a34.25.1720716583374; Thu, 11 Jul 2024 09:49:43 -0700 (PDT) Received: from localhost.localdomain ([2605:a601:ad99:2e00:e9ed:d1b6:6b3c:b7f3]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-70378d3adecsm1027524a34.3.2024.07.11.09.49.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jul 2024 09:49:43 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 08/11] qmi: gprs-context: Set up WDS service for IPv6 Date: Thu, 11 Jul 2024 11:49:30 -0500 Message-ID: <20240711164936.1688973-8-denkenz@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240711164936.1688973-1-denkenz@gmail.com> References: <20240711164936.1688973-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..456f46ead6d5 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 = 0x01; + 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 Thu Jul 11 16:49:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13730885 Received: from mail-oa1-f43.google.com (mail-oa1-f43.google.com [209.85.160.43]) (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 145E684047 for ; Thu, 11 Jul 2024 16:49:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720716586; cv=none; b=nMMfxzc3JnCj9BxOCPQMxpluptgJJOYLCTrpwHiaMMMYUaVAkYNmkZZz8cDzQ9VMZSY1bvP3rEh+A4P45e1/ckwW6jEvQ3c6A+Zy8vak1blEVtdAvKyr8mB3c7eZEGU61a+ShxYjEZdaDzcFJd7+f9H2HrIN6Tc9KpHkTsTz33Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720716586; c=relaxed/simple; bh=EkaKgzvy8UfudnBrM3RgzjSrk5inute2DpB+yAyFOb0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cd5cz8dM0wWeMCvGYaSkydEM28DQIk3zJBTb+6cFy/3TNkvgY/Nhu7CnIG+Hs5yJsHT/+4+mJO+A8pfmgCqEBnve2v5cpzH5SeK3uSV+umAEr9H9htcDDOGN/1zBZhxSpb8IYbNXvKlhB9AU6xLXd7sEwNDL3GWGJYzCregTB84= 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=JDrUgv1S; arc=none smtp.client-ip=209.85.160.43 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="JDrUgv1S" Received: by mail-oa1-f43.google.com with SMTP id 586e51a60fabf-25e2cc76becso485770fac.3 for ; Thu, 11 Jul 2024 09:49:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720716584; x=1721321384; 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=hBzY8p7iQZzTuiydz8/WuUiXtoZIqPdsquhxIPtDQjA=; b=JDrUgv1SZsB105c6PD9UnEtJZlv03P7ZfoeGnvIWLawX6c9QjKvVcfqJuwih3ivM+S AtVI5Ma67sAt9qz4ayMmKb3zbSiV/lPC1WODN56P5UxOZvRWZ1WaoYKAxj21VuLEJ95o 2oJ6qCw4b/7SGEvorLv6y3oKKM/dT2EeyqxF0qtN35k6UJe7LC8OF7N5fltHidk8NZzv E8CxadmSz2unbxFvljiNlbxY3VBUXjXt62Rwm8XrfQ6x6dq/ky6VHKcLVaZMGzfqA+Ep GKhLPQCyUoK7AsHFei+YnzxfFOzTO4IfldIF5CCsJVn6byhPsrOxmQQr+bawuu/wWRk4 nZtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720716584; x=1721321384; 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=hBzY8p7iQZzTuiydz8/WuUiXtoZIqPdsquhxIPtDQjA=; b=whHmfDJv+g1wWXN5hJG5boq4gWDSAzVOf8o1bE3vAiV+dk5k8fc/KcpOvhvWfZoVfL Ws44RyNXiqeA0z9L1JNWZg2A0T3Ar9YjuLpbkNjlxEgX1Mb3PmG6FQXjrydeHztG4W5R Xr4OrGr+z/UywGE8Q6jhwKUFEQjt2uxS4VagXyFeYK/hFAZmqEx5jr6KHIcfjh6vFqbt UKv1MPyyzX2oLrcVhAIDCu6tDvxngea7z7dlmK0bICkbzVkdSAq/8OXkXedHqaggHLxP Up+8xzEK4R2DCdE3PHDmrOL8tA8ST2KTaS03Tb6y6S8/4Z74WnOFkVj/BF/AeflvKZjY XXNQ== X-Gm-Message-State: AOJu0YywxsW/QMh++1MNyJX3liEl8X4qGlrTfC6DAF5fy/FJiT16u0jZ 3yqY6aKemkgZZRmv6KVQ9bLQIrR0yaJ8KfECaO/VCHXJD8gzaNVWUZioHA== X-Google-Smtp-Source: AGHT+IGb6uzVrcGH8xQk0yiuumW0nOonTn3UpotqaC6Boi/1AxkjK0O/J0AUg2XVm84it3Z6WLE0ng== X-Received: by 2002:a05:6870:b296:b0:254:bd24:de85 with SMTP id 586e51a60fabf-25eae7b619cmr7354561fac.16.1720716584030; Thu, 11 Jul 2024 09:49:44 -0700 (PDT) Received: from localhost.localdomain ([2605:a601:ad99:2e00:e9ed:d1b6:6b3c:b7f3]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-70378d3adecsm1027524a34.3.2024.07.11.09.49.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jul 2024 09:49:43 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 09/11] qmi: gprs-context: refactor detach_shutdown path Date: Thu, 11 Jul 2024 11:49:31 -0500 Message-ID: <20240711164936.1688973-9-denkenz@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240711164936.1688973-1-denkenz@gmail.com> References: <20240711164936.1688973-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 456f46ead6d5..f4846f0299e7 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 Thu Jul 11 16:49:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13730886 Received: from mail-ot1-f53.google.com (mail-ot1-f53.google.com [209.85.210.53]) (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 D096B16D4D2 for ; Thu, 11 Jul 2024 16:49:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720716587; cv=none; b=A/+cU68wBe8EGDFzwDWlgXgvXSJdi2+Cl9AmH1/8zYcd45jfnG0MRcdrwIno6qFT0VEDY0I+whOp0JczTLQlnbgxVK7+eqmTPljrieXo9Q/PJxIcihF3LcSbeO2u5PmfEdVxU2SbAdKFOMWAoQuR8ehbGgkLzUzK1qo7K+4XkTY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720716587; c=relaxed/simple; bh=8cfODcoWXNYMcLJsfnko6IIDlPtXTjFSOie4w2z76kE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RUB9+tot7zXYPEx0e74qs0U80DJkzlYZLp77/dfozy+eZiVS7UUh0gK8GYys2aPEqOPF+UbSNsks2QyO1/CwaZDPd7qh/raPHYExTr/5HqaryV/jzxAZ5yvkbEZdrVZPDpWzAh9HottemF/m4vHmQruXmhmXfNrtOmQ9+U8UXlw= 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=QipnrTe2; arc=none smtp.client-ip=209.85.210.53 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="QipnrTe2" Received: by mail-ot1-f53.google.com with SMTP id 46e09a7af769-70445bb3811so588663a34.1 for ; Thu, 11 Jul 2024 09:49:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720716585; x=1721321385; 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=2IdoR3kSiJsDqnQFMOJF3gYwYZqDTB3crIPGt/XI2os=; b=QipnrTe2mZ9tgn6f5c5mVXJPz5wAIMrNEBuS70KBjHFYnXFMG/K0Cm+HjEhPHkdFhU nHsqKIdHRC2QbAJnv881bSD7ljOjqE5dYBkNL4QKPM5oRzmGxTBS02kFuScN6rF/ZHNg ISV0o4ZGuoOd3f9z9ImDf+iqPkQKxTYF+ijDR4MWgK+yQjJ508qyroyaVcj1HfCjmFOq LeyvFvAH2u4iE1vHrnOX2Abn1Q390KfVf2KTAhGBhTNDdaZshfbhSsViUH9pMFWq+kZN YRC19Sk2AkEqGT1Yh0/8UTxmXfX2vQBwDNPqQ/IgOd9Jt/LEQ/PQDSgZQlploj/vxhLb 02dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720716585; x=1721321385; 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=2IdoR3kSiJsDqnQFMOJF3gYwYZqDTB3crIPGt/XI2os=; b=Y/SXdatH771/XXBBKKFCpIe4YxvaDudnEyRWvV44hVPRSdJbQgAX7oELKiH997oH7o JS9bcUtuDUlnP0Qx53wmcndiE9loSx2I/rP0g1VYJ8dk1tSaFrunk5ZZmkeRg3l4qcYY 2idPwkrV6WJFusK47SSfz9Gcibo9yBeDsp+tvmiMFcgC8tjeFYVMN4lAjQcxPxvFYrDh UFQnVfD5LU9SnIuIC67h0Ds1sfwvdDhoX+91bYLlc7xEfhb/Sjp7XOnXw2YLPkwPxzy3 dSCxj2DoYZ7qWfkWiA0PyJCK2cDzkFheMFBxiGMXYevOQj+9ISguxcnr9isHLcK0nStx qBHA== X-Gm-Message-State: AOJu0YwbGnYH2sV0xx5YUfhGsN1ms0oL3/8aZbBaiuf2z2JMIwjGhSij thz8fJqvQ8CTtQZ0WcFJHO2Sfm+AOUIozzkvgJoZP9g1ja8zAN98tSLg5A== X-Google-Smtp-Source: AGHT+IHgNMcrhKNx8tiUbhT3i9w43bmlXOsOUBwWyIoOCvpIZaCilMAsqnajevNtaqyDRO+PhRe6yw== X-Received: by 2002:a05:6830:1553:b0:703:5dc9:7295 with SMTP id 46e09a7af769-70375a1245dmr9907783a34.17.1720716584758; Thu, 11 Jul 2024 09:49:44 -0700 (PDT) Received: from localhost.localdomain ([2605:a601:ad99:2e00:e9ed:d1b6:6b3c:b7f3]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-70378d3adecsm1027524a34.3.2024.07.11.09.49.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jul 2024 09:49:44 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 10/11] qmi: gprs-context: refactor deactivate_primary Date: Thu, 11 Jul 2024 11:49:32 -0500 Message-ID: <20240711164936.1688973-10-denkenz@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240711164936.1688973-1-denkenz@gmail.com> References: <20240711164936.1688973-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 f4846f0299e7..6061de0a483d 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 Thu Jul 11 16:49:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13730887 Received: from mail-oi1-f171.google.com (mail-oi1-f171.google.com [209.85.167.171]) (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 95D5E16D4DF for ; Thu, 11 Jul 2024 16:49:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720716588; cv=none; b=tff2Hdh0fWXKQjP6d3lH4h2OsVh5JL2ZG3wYuuyMlEhBSzlO+hpb7kHCWa8iuBml5EJv6FLvgVyb3TSnmR/vFZtrLcUwGhcU5EvAXA9oR6Bmphg6uf99f1QJDPrACf0QqsnQUNh92qfQ/mTuFMtA5iREAKcQBPYP7zMIM7JUODM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720716588; c=relaxed/simple; bh=df43SoDfw6AYWnDD9dDCrCpJ77gJAH8rr/24mcl08A8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Oi4ZDxTCiGX1BY4FujjyDgKxIy5Mj5CcMdUdtwIjqRAl1SiWEjvwUhPWXae6BFDaHRZ21ogiAFIxTWEBjcLMgJCwNMhF349enhYWPlBhkSwVXPyqI6flW8pm9Q4cusfUB70djqQj/kA0fZs/ohh5C2XZNP/cYjpPvh/Jf8XuJkA= 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=CLqWUA09; arc=none smtp.client-ip=209.85.167.171 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="CLqWUA09" Received: by mail-oi1-f171.google.com with SMTP id 5614622812f47-3d6301e7279so663887b6e.3 for ; Thu, 11 Jul 2024 09:49:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720716586; x=1721321386; 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=n7y5oDOtmsbXllu5bhw8YrwObtC5/6CUGeA3EBR4tHM=; b=CLqWUA09YPi+aQ9RKp2YKxhIGjQIUVYaDC9W7+uZ8RjVXVnD0iohrldsUEDfVUG4XN 8/ol+eXQyIDoFKBC35TL+N9BxjO4eWylhdGp/CTQDXzBolOmJq3fixsFmTGe2+0ZZAfo gw6Imq/GYModN0i3EvQgGb7bZHjcEAIyGGsSBrKE3B60gaV/UJRCkOmHrQILiSHgi+4X eXmoYDPJ9f1i2QzHzlscSE4iHIQmsfpIsAE33GBBlOywZSqT9dTTRogQrmPKBB4PjRn8 rxtIUMZ/r4m1AFe6gOhWL+zsr8IsCLTDcpm0XMNcqLRh4gC8KgO37Tu+ZZjM5U7vmqKt X3iA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720716586; x=1721321386; 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=n7y5oDOtmsbXllu5bhw8YrwObtC5/6CUGeA3EBR4tHM=; b=DTUXBrV/XY7+0MtZnc5DaV86H5vgiLl72VQlAhq3cqoZI6Ld/7XF3c/xCD2U598uay HfuwtbFcupKAWh5U32MP0TZVwzvMRB1aKy9/ga93SkIGmMf3haelAd+Ar8b5Faykf1DD mWeuvKxdlt34ZOnVWaANLP6pQHWGhVz0BGHLOKsuQSUdlgHBusNHRVxa7iZdV77oCTO7 mz0TwvXSCF3Ri/Dj8qTdoBFgLvLFBOSuGRv4PdO62vHssfPenZppPHUO8g1s35KtCvdF tjgAfHT/TQSVwRoNl5+LzL9JNxcEkdJjIIqGKgkXChjFCv/KbBzs0X4sPD8SfiPhF9n3 LjyQ== X-Gm-Message-State: AOJu0YxVq0vMQKEYQBio5nwrkATLd8Hv7i2JcQSI8TuBWK1cfGfSCQNm fKM866KO2DrBAzG6FBQAvgOd3VF+jYhy4rH7DSOB0dYjLg2uLAJjDuarpQ== X-Google-Smtp-Source: AGHT+IEo2K7/3tp9ZoVq1FZbr8FP2XwNEmJpumSYBFocaXOhN5TZtukwjhcgRG/67+ZTpa/AFT2OUQ== X-Received: by 2002:a05:6808:10c5:b0:3d5:6728:74ae with SMTP id 5614622812f47-3d93c0cb369mr10672264b6e.56.1720716585557; Thu, 11 Jul 2024 09:49:45 -0700 (PDT) Received: from localhost.localdomain ([2605:a601:ad99:2e00:e9ed:d1b6:6b3c:b7f3]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-70378d3adecsm1027524a34.3.2024.07.11.09.49.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jul 2024 09:49:45 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 11/11] qmi: gprs-context: Dual-Stack context activation support Date: Thu, 11 Jul 2024 11:49:33 -0500 Message-ID: <20240711164936.1688973-11-denkenz@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240711164936.1688973-1-denkenz@gmail.com> References: <20240711164936.1688973-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 6061de0a483d..89d68d154ed8 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,