From patchwork Tue Nov 26 21:26:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13886374 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 76B301DF274 for ; Tue, 26 Nov 2024 21:27:07 +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=1732656428; cv=none; b=GmxcR9XgvK5tI8IkZI+H8BTp1NuRHjod011rTnyW0Y/RxXJR62SSGpTYKZhVF99gWyct2MNiJglZ3CeNkN1CqDFlYRi/GrGd2LwNaXRbwOM4e6nBq40HBdGmWqS/gV2FbBuUaB0YBeigX5lMECDLykRAXghNk2ZMDTDcNHfjufw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732656428; c=relaxed/simple; bh=ueKfNAB0UPPS79VSnZQMs81BzvVgtXsNHuPCaigc/gY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=UaZYydbheWYPqioY4/rd6g9LHkO5y2FHric2dQAE/KsLVSWhtk8uRR96R8sWRIqnsfds5goxU6uR4N/PdgQfPUfdGDFyO1Jte4LPbBakwjqOWYYW5/LMvlC8U7KBD38RqhwALuEq/E4Iy5W/WN31tNTBNhO3OKPVJvagfWWNHFk= 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=W9w5Omu6; 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="W9w5Omu6" Received: by mail-oi1-f171.google.com with SMTP id 5614622812f47-3ea48624a2aso1451523b6e.2 for ; Tue, 26 Nov 2024 13:27:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732656426; x=1733261226; 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=qjoH1IgYA6E/twIawgveTEBf+PsTyraRvZNOlYoF4S0=; b=W9w5Omu6ft3+mexlnb5dTqA1eQs55WJmhNtQefdYZ0FZF0Fy5ZF57rGYf2KnN8GAcW /vrLnliy7gRw8MEG0fFl+TAkzOpR3t/NGPyG171ijvKZbstPOwmooxBTxJUaCU/Y6e3/ NiOFNyyVle9KUR2OgHeynQQAA800JEwrDf4lWH5uh2h1eOQS5KYherJZqLIHZf6mTeon 78Np5gKLPArMtyqioNSZYSMJ7PxxI/brMaQfdB+ugXuOSNUqWVMNm5osEQdvsKNbQN38 l35GIYkc2Z4o3yiPp4PP0Dqx9Tr9kuPmgHO4vhpkubqqZgh3QA0WPBwkmjwKDayl1ODp d3sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732656426; x=1733261226; 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=qjoH1IgYA6E/twIawgveTEBf+PsTyraRvZNOlYoF4S0=; b=K/X92p4DPG7if6l7s9iFuWtmb0cu4W6HXNpcNvYp4c0MDVDQKjEDY4GsLugW98eRGc EMdTEoNC3oNpogVDkuXReSM/5pC9soJtR/Q/YLeWemVDyxV9xfriWQAd5CzUOR++c9wm JmcBapVHmNy4Oy+94T6dx1/xZqcqi6KFx+/L97FkP6uFBt4SP4Uhrp14OcnAZYUdWRZ6 +70m5UgVAZ4b/IM8717oqElndX8dUFhtR1IyquSjVaG9Q93KHMoDLrNcU61M6v5FzkXE GJ5QgaY1OJStX7oWBjQ4046gcY9qIn9PHUk2iJ3CPpRkER3i+Tl4jCFL8ahUdEgLE1Yz VRsg== X-Gm-Message-State: AOJu0YwUCe3VAmHxTRLKfiiuqzvId99OusJwVt7Sw7XjCVge6Qlzktip kwqVtuSTbRTPXymSZgCcEv+6zLdIW62IhNOA2c0siWR8pamXe590FrIH8g== X-Gm-Gg: ASbGncuWUVHkSBSjOklwEMP/MnXda0ldPavzOWPtJ7DchQvxk7wNyKSjqAfhkyNF1Zq JCdbGEoQc66OSiZxSLebnn62JpR91nZApKCatmiFwC8EF9qxrelzBYIcso5gFouKam7bQlmkFlP uEMv4viS9m61D+muabXsJSjiokukPoDLU4fLKGfTHMcjHXIs/sTg/4wvkAcZgS/PA7fBD3eUnt0 87/hHmrtwzoQBpuy2dZU4FQ4nAIHUj87DN6aWGnS+7rq5KWDClf1bvpuRnLdmIY9mNpPmE+RAOl NALuowi0xoPlQeSNsY2VlPMp X-Google-Smtp-Source: AGHT+IEW8saouhYvX9igLeHwMr4nDWTsXEi3sIlxJC02Lup28r7zs3AAbc/nMJJvss4ArMLpLZM8Jw== X-Received: by 2002:a05:6808:2115:b0:3e7:bcb1:f5c4 with SMTP id 5614622812f47-3ea6db63b26mr939279b6e.4.1732656425948; Tue, 26 Nov 2024 13:27:05 -0800 (PST) Received: from localhost.localdomain (syn-070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3e914e835e2sm3177531b6e.13.2024.11.26.13.27.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Nov 2024 13:27:05 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 1/4] provision: Add 311 270 MCC/MNC as Verizon Date: Tue, 26 Nov 2024 15:26:15 -0600 Message-ID: <20241126212703.196003-1-denkenz@gmail.com> X-Mailer: git-send-email 2.47.0 Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- data/provision.json | 1 + 1 file changed, 1 insertion(+) diff --git a/data/provision.json b/data/provision.json index 434bfd8d8f7b..50319cf33a51 100644 --- a/data/provision.json +++ b/data/provision.json @@ -14266,6 +14266,7 @@ "310010", "310011", "310012", + "311270", "311480", "311481", "311482", From patchwork Tue Nov 26 21:26:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13886375 Received: from mail-oi1-f179.google.com (mail-oi1-f179.google.com [209.85.167.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 E7A861DFD86 for ; Tue, 26 Nov 2024 21:27:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732656429; cv=none; b=ibLyF/WClWY4O4FI6/dRu2X6kVao+JmpTU3foVXuZhqD0EbOdCbCHEdPqdC61rhSut9/Ll1CVJw3Je0cWG2o8y6rsO9yjv8sKQviV0qPx1FgftC6+cCUocuVfBqwUMUGt1mo9lqqsNq6KQN1ypkI4ES82Gwec9gLAjxZn5yUYgY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732656429; c=relaxed/simple; bh=qPkMt1RJA1voyJmcc0GQrDlEJHEFPDA7zHHrJS2cbsE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Yd4Ka9eEFPtqinhaBzJYX4i4H5J0bQ87+LjikbzVNnAAESLbwo8fPakzWuEiGq2WkAJ5XgBOBzGpyf9LgBzS8nb/R0/92Mv4dZrxUKjvuApZanb9TMpWIBqrEqzFDhP/OQeVIFXNld1dyL/Wj+KBIhcLP2YhL7IvC9i+w8xHO4c= 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=MsrHXqPV; arc=none smtp.client-ip=209.85.167.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="MsrHXqPV" Received: by mail-oi1-f179.google.com with SMTP id 5614622812f47-3ea696c4dcaso491564b6e.2 for ; Tue, 26 Nov 2024 13:27:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732656427; x=1733261227; 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=JJVR/mMXmTf/tNKq4xATVtT4pHSGBMlppg7bWXf8cRk=; b=MsrHXqPVQv+YR8K7PGhjLSMiz1TKdvwv/LaAjf9+qAAcJUwyFF8BkEXXv5MTgTjmmX J+b+yXx1Q5P1nbpm8Kwp9qI0PyeKgEuo0RxIKDSWJi/RvlkJQkvy9NYsvBbILhheiGG6 y0OvexNDjQCMQtANqWDHvljzMMnNGC+pUHEWZhtBhztWBr6jzHX01rV2yjfi0lxesJ4v RuA6Pa1plFCkW3zrC2fbAH8Y4M9XzLLxOcuY7MyCrClvCK7OwGU38eOBhvFZswk5lwpl QqQhzwZeXOPMhjj4mz3kFMo8dysvTT7e/YAk6R5VmX0PL67a9E0j0S22m/AccSdvppeR DOyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732656427; x=1733261227; 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=JJVR/mMXmTf/tNKq4xATVtT4pHSGBMlppg7bWXf8cRk=; b=qTKeQTjAZfbxcjgLNdgA2hCvzX/NJgLFKCZJDdGWSVRjBMoudTOzvFbCELUajBHdMx 2QFpf6fDlBlyCje6i/5VTmWxdz+XfJev5ZI1IUFlOz4aHCzX3kiUKABBKhRySP4zILhu JM9hi+bLRk1ZBuQm42M+knLL29RP40AuVRc/H78zyZqx6PViD+pQGxhihy/5tdhiJISb yr8YWTgwDLWAcQaPUcejaW7EPrtQTzJre5UjDDvqS1Mq7XPWeJRtrHEIrZT0KR4CkzrV 4cDXPB7AjK0bcf5ai7s1yQFYm2GkpYMecwyQ99PnyJA9K0cLeTy6+CwHnsni8/j8rDmn ISCA== X-Gm-Message-State: AOJu0YzxsJJgJCrSh+6s48DiAFP+0pvofvfb3zne00Jm9kBnPdZ1NotV aU77VvSB60NBS3jMUjeQR6I3m9swZ9j5TtQCC9YTuhC3G1EtfsUeL5Svww== X-Gm-Gg: ASbGncuAQcCd1F2csggf5crzmBN3cMzK2nuFGNp47iem4UPaHsJozwmvbzD4gMZSzK+ bVSZmcklwkGcNiJQNmPanzqyrpeTRxHwnGglUBd7r7Y3CFdHXkS7/xF3WBLAww+QlmtlP5ZY8g2 Lq5JDcAIudUuQJQKJdWNC99UuGaAzVZcAMrJ7C0GALumwwZdRbjrD/lmyNZ/0/uEDdVumiuiol6 5LzpVyeJlEUyiX+s+ubTurdQtK1LbKwlZ1rokMT/CO6dDSbaMeIqyPCrbnoqyguhKHoO+15mJw6 BsTQfvzboWCr8mrt66W6oKyT X-Google-Smtp-Source: AGHT+IGJX6UcK605KpV909XkBY+3BP3q/NePEVvVGdM2tHEzNAGLzV37YvS8WiCVjAbv3RUE1dz7bA== X-Received: by 2002:a05:6808:1383:b0:3ea:525c:46f8 with SMTP id 5614622812f47-3ea6dc286f1mr1006399b6e.22.1732656426967; Tue, 26 Nov 2024 13:27:06 -0800 (PST) Received: from localhost.localdomain (syn-070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3e914e835e2sm3177531b6e.13.2024.11.26.13.27.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Nov 2024 13:27:06 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 2/4] rmnet: Default created interfaces to MTU of 1400 Date: Tue, 26 Nov 2024 15:26:16 -0600 Message-ID: <20241126212703.196003-2-denkenz@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241126212703.196003-1-denkenz@gmail.com> References: <20241126212703.196003-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 By default the network interface is being created with 16380 byte MTU, which is excessive for cellular links. Typically, cellular links use a maximum MTU of around 1430. Set the MTU to something more reasonable by default. Unfortunately, the kernel does not support setting the MTU value in the original NEWLINK message. It must be set separately in a different transaction. Add support for this and make sure that cancellation logic still works. --- src/rmnet.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 68 insertions(+), 9 deletions(-) diff --git a/src/rmnet.c b/src/rmnet.c index 83110c33a980..2c000fc33c3c 100644 --- a/src/rmnet.c +++ b/src/rmnet.c @@ -25,6 +25,7 @@ #define RMNET_TYPE "rmnet" #define MAX_MUX_IDS 254U +#define DEFAULT_MTU 1400U struct rmnet_request { uint32_t parent_ifindex; @@ -195,19 +196,16 @@ next_request: rmnet_start_next_request(); } -static void rmnet_new_link_cb(int error, uint16_t type, const void *data, +static void rmnet_set_mtu_cb(int error, uint16_t type, const void *data, uint32_t len, void *user_data) { struct rmnet_request *req = l_queue_peek_head(request_q); - DBG("NEWLINK %u (%u/%u) complete, error: %d", - req->netlink_id, req->current + 1, req->n_interfaces, error); + DBG("%u (%u/%u) complete, error: %d", + req->netlink_id, req->current, req->n_interfaces, error); req->netlink_id = 0; - if (!error) - req->current += 1; - if (error || req->canceled) { __rmnet_cancel_request(); req->n_interfaces = 0; @@ -229,6 +227,49 @@ next_request: rmnet_start_next_request(); } +static void rmnet_new_link_cb(int error, uint16_t type, const void *data, + uint32_t len, void *user_data) +{ + struct rmnet_request *req = l_queue_peek_head(request_q); + uint32_t ifindex = req->infos[req->current].ifindex; + + DBG("NEWLINK %u (%u/%u) complete, error: %d", + req->netlink_id, req->current + 1, req->n_interfaces, error); + + req->netlink_id = 0; + + if (!error) + req->current += 1; + + if (error || req->canceled) + goto error; + + /* + * Unfortunately the kernel does not take IFLA_MTU into account + * when creating new RMNet links, so this must be done as a separate + * step. Hopefully this is fixed one day + */ + error = -EIO; + req->netlink_id = l_rtnl_link_set_mtu(rtnl, ifindex, DEFAULT_MTU, + rmnet_set_mtu_cb, NULL, NULL); + if (req->netlink_id) { + DBG("Set MTU: interface: %u/%u, request: %u", + req->current, req->n_interfaces, req->netlink_id); + return; + } +error: + __rmnet_cancel_request(); + req->n_interfaces = 0; + l_queue_pop_head(request_q); + + if (req->new_cb) + req->new_cb(error, req->n_interfaces, + req->n_interfaces ? req->infos : NULL, + req->user_data); + + rmnet_request_free(req); +} + static void rmnet_start_next_request(void) { struct rmnet_request *req = l_queue_peek_head(request_q); @@ -429,6 +470,7 @@ static int rmnet_parse_link(const void *data, uint32_t len, bool have_linkinfo = false; const char *ifname = NULL; uint16_t ifnamelen = 0; + uint32_t mtu = 0; uint16_t rta_type; uint16_t rta_len; const void *rta_data; @@ -450,10 +492,16 @@ static int rmnet_parse_link(const void *data, uint32_t len, have_linkinfo = true; break; + case IFLA_MTU: + if (rta_len != sizeof(uint32_t)) + return -EBADMSG; + + mtu = l_get_u32(rta_data); + break; } } - if (!have_linkinfo || !ifname || !ifnamelen) + if (!have_linkinfo || !ifname || !ifnamelen || !mtu) return -ENOENT; r = rmnet_parse_info_data(&linkinfo, out_mux_id); @@ -466,6 +514,8 @@ static int rmnet_parse_link(const void *data, uint32_t len, if (out_ifindex) *out_ifindex = ifa->ifa_index; + l_info("MTU: %u", mtu); + return 0; } @@ -530,14 +580,23 @@ static void update_new_link_ifindex(uint16_t mux_id, { struct rmnet_request *req; struct rmnet_ifinfo *info; + unsigned int i; req = l_queue_peek_head(request_q); if (!req || req->request_type != RTM_NEWLINK) return; - info = req->infos + req->current; - if (info->mux_id == mux_id && !strcmp(info->ifname, ifname)) + for (i = 0; i < req->n_interfaces; i++) { + info = req->infos + i; + + if (info->mux_id != mux_id) + continue; + + if (strcmp(info->ifname, ifname)) + continue; + info->ifindex = ifindex; + } } static void rmnet_link_notification(uint16_t type, const void *data, From patchwork Tue Nov 26 21:26:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13886376 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 10FCE1DFD8E for ; Tue, 26 Nov 2024 21:27:08 +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=1732656430; cv=none; b=PhGuTdrjFhKLEOCqOsRwuk0oZAQC/js/4PkgDhmqgrjMO/6lKPJr+Ow/A3P5rxwj9jSxug86cwngUYcTFM05OT0nIEQ+mmA9xrMqO3BdYxJD3zS9OjJq80VH9K8qhgdqM8RRnV2o2FJCsfuRCWFw7CKteA45fxqgGDvhX9hWvz8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732656430; c=relaxed/simple; bh=yRW9Zupoa5zATuTqIJwYsbSSWygLnHE81YSrGfZVW2U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hR1PfjiYZ1jEiagntC53WkO/BfeyBNVam5AdLS2asNHgENYjQbhourhpXi+/SppuqpldCulMyJOghFKIsRg2GLIQgutRlxKua4Ylxe6qDZFqrBJbJe6m6qjPsE6XBxhvKkxoKMzGNqSJ/NMDm74TTPTeR0TuxExjBwGq2rXuWfw= 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=EOtj4WtN; 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="EOtj4WtN" Received: by mail-oi1-f175.google.com with SMTP id 5614622812f47-3ea52520327so1145718b6e.1 for ; Tue, 26 Nov 2024 13:27:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732656428; x=1733261228; 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=ciq0TS0HGbSLegbXe1gmUm7Bhj1zByC+oR6oyWVuqQM=; b=EOtj4WtNaaS23nyrmS/92CqRIFL/FTP1AAVivJ8GxEbBcunnXbDXCV1UXOtlYThRff hhZ/EV5H7IwbeHO4F5P9tuKGeFhkzEMs352AXOyslGsSE41wh+HKHsc15s9Bpfngzt5D tp3X6CJYeE/iocdbM0DEBIqEQYbj2d56J/YNT/1YXCNFKilzZM8WPCf574cZg6R+aUpt Q8Qx+yCLKrg11Btq8+ajyCB+aVPQWbzRRae/hbKVyxaTolX373p/pPprG9Uh3rDEfaRu 7J/t7MEEaR5skIEGYlr+9PCDAX/qkAci4RMi5uHywyUMUG0lxcbPm1S6/DaJ8JUNbnEA PYlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732656428; x=1733261228; 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=ciq0TS0HGbSLegbXe1gmUm7Bhj1zByC+oR6oyWVuqQM=; b=Pcr04AOBpCtxJ1w3R1awdzc8xN8HTzXSkB8boDhd4WpVJ8e2VMXorSQFcOB20TOvnX j0l5ZZYu8LC9+7xWFTmfWUNOJUZ+qtjtbJt85+5pLkB+/sKjYCr0qkv7nme69noq9I7l SxWmApDUkbpmIsL6EFmh9ZP0cQV59NdFH5f5RSjvIeHbJ8QuDof6JN8g6s2pzkqSTJKh o1UW+c2V2/f1fUHvTpTQWmu2MJldZgW9WQ6+Xnxyd23wfwKuPFIwC5dfvtNF6CG7xQ2i VHXf8NUKZdJo/5wQnIn1dqBQztf1lQiuzQfh2tuk75dFJojZcjEW0KaoBuUCBc9xSw9S LKFA== X-Gm-Message-State: AOJu0YxLcq95guF8c4XQ5ORRoPSOtJIOspW8h06EavwMsZDr98jtf0Te etMRCKt5qBrCtXh6vZKDda+df45On9x1kUKUvZaqZGZ/Plt6SkVYwBhQbw== X-Gm-Gg: ASbGnct+mrU1srubLSehy367Gzy/fMmDoncaHyHgnmYaUeChIqdvI5yidoN0Mq7kefy WYyN4BO/QQ11FDa4FqqYDWYUhJYLqcCyj7qe62ETlpWr5C9WsrT4TDDkTZM1lWxBxjfootabwl0 Y5HMponda2ylyaoJXqFD6t9bNigL7IEJcDE5wOkJ5ov29Z27iLkQeAGBPwzDDIYhG5ZcX2gGFvR HsviS+DBhukRprt4FPFQy5rMFC2VT1xsVYlabBpnVk2lY6rrd50q9gVDWJhF5e5svtTKKUUXiSI 6IDQn9I8r7ibckIyGYOfCKEf X-Google-Smtp-Source: AGHT+IFejsQCh1Iqos8SE6q0f56iDN2b5bXilc6VgFgIHNjAT1cNtZUCHU//3Z2VPTeomfsqlxtSoA== X-Received: by 2002:a05:6808:1a02:b0:3ea:367e:db44 with SMTP id 5614622812f47-3ea6db6d67cmr946570b6e.3.1732656427985; Tue, 26 Nov 2024 13:27:07 -0800 (PST) Received: from localhost.localdomain (syn-070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3e914e835e2sm3177531b6e.13.2024.11.26.13.27.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Nov 2024 13:27:07 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 3/4] qrtrqmi: Add multiple bearer support Date: Tue, 26 Nov 2024 15:26:17 -0600 Message-ID: <20241126212703.196003-3-denkenz@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241126212703.196003-1-denkenz@gmail.com> References: <20241126212703.196003-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Use the new rmnet module to request multiple rmnet interfaces that will sit on top of the main mhi_net interface (typically mhi_hwipX). These interfaces can then be used to support multiple simultaneous active contexts. --- plugins/qrtrqmi.c | 145 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 122 insertions(+), 23 deletions(-) diff --git a/plugins/qrtrqmi.c b/plugins/qrtrqmi.c index 21103371046a..8bfbb11d167e 100644 --- a/plugins/qrtrqmi.c +++ b/plugins/qrtrqmi.c @@ -42,13 +42,25 @@ #include #include +#include #include +#include +#include "src/rmnet.h" + +#define MAX_CONTEXTS 4 +#define DEFAULT_DL_DATAGRAMS 32 +#define DEFAULT_DL_AGGREGATION_SIZE 32768 +#define DEFAULT_UL_AGGREGATION_SIZE 16384 struct qrtrqmi_data { struct qmi_qrtr_node *node; struct qmi_service *dms; + struct qmi_service *wda; int main_net_ifindex; char main_net_name[IFNAMSIZ]; + struct rmnet_ifinfo rmnet_interfaces[MAX_CONTEXTS]; + uint8_t n_premux; + int rmnet_id; bool have_voice : 1; }; @@ -120,6 +132,8 @@ static void qrtrqmi_deinit(struct qrtrqmi_data *data) { qmi_service_free(data->dms); data->dms = NULL; + qmi_service_free(data->wda); + data->wda = NULL; qmi_qrtr_node_free(data->node); data->node = NULL; } @@ -132,10 +146,105 @@ static void qrtrqmi_remove(struct ofono_modem *modem) ofono_modem_set_data(modem, NULL); + if (data->rmnet_id) { + rmnet_cancel(data->rmnet_id); + data->rmnet_id = 0; + } + qrtrqmi_deinit(data); l_free(data); } +static void rmnet_get_interfaces_cb(int error, unsigned int n_interfaces, + const struct rmnet_ifinfo *interfaces, + void *user_data) +{ + struct ofono_modem *modem = user_data; + struct qrtrqmi_data *data = ofono_modem_get_data(modem); + unsigned int i; + + DBG("error: %d, n_interfaces: %u", error, n_interfaces); + data->rmnet_id = 0; + + if (error) + goto error; + + DBG("RMNet interfaces created:"); + for (i = 0; i < n_interfaces; i++) + DBG("\t%s[%d], mux_id: %u", + interfaces[i].ifname, interfaces[i].ifindex, + interfaces[i].mux_id); + + memcpy(data->rmnet_interfaces, interfaces, + sizeof(struct rmnet_ifinfo) * n_interfaces); + data->n_premux = n_interfaces; + ofono_modem_set_powered(modem, TRUE); + return; +error: + qrtrqmi_deinit(data); + ofono_modem_set_powered(modem, FALSE); +} + +static void set_data_format_cb(struct qmi_result *result, void *user_data) +{ + struct ofono_modem *modem = user_data; + struct qrtrqmi_data *data = ofono_modem_get_data(modem); + struct qmi_wda_data_format format; + int r; + + DBG(""); + + if (qmi_result_set_error(result, NULL)) + goto error; + + r = qmi_wda_parse_data_format(result, &format); + if (r < 0) + goto error; + + DBG("DL Aggregation Size: %u", format.dl_max_size); + DBG("DL Max Datagrams: %u", format.dl_max_datagrams); + DBG("DL Aggregation Protocol: %u", format.dl_aggregation_protocol); + DBG("UL Aggregation Protocol: %u", format.ul_aggregation_protocol); + + data->rmnet_id = rmnet_get_interfaces(data->main_net_ifindex, + MAX_CONTEXTS, + rmnet_get_interfaces_cb, + modem, NULL); + if (data->rmnet_id > 0) + return; + + ofono_error("Unable to request RMNet interfaces"); +error: + qrtrqmi_deinit(data); + ofono_modem_set_powered(modem, FALSE); +} + +static void setup_data_format(struct ofono_modem *modem) +{ + struct qrtrqmi_data *data = ofono_modem_get_data(modem); + struct qmi_endpoint_info endpoint_info = { + .endpoint_type = QMI_DATA_ENDPOINT_TYPE_PCIE, + .interface_number = 0x04, + }; + struct qmi_wda_data_format format = { + .ll_protocol = QMI_WDA_DATA_LINK_PROTOCOL_RAW_IP, + .dl_aggregation_protocol = QMI_WDA_AGGREGATION_PROTOCOL_QMAPV5, + .ul_aggregation_protocol = QMI_WDA_AGGREGATION_PROTOCOL_QMAPV5, + .dl_max_datagrams = DEFAULT_DL_DATAGRAMS, + .dl_max_size = DEFAULT_DL_AGGREGATION_SIZE, + }; + + DBG("%p", modem); + + data->wda = qmi_qrtr_node_get_service(data->node, QMI_SERVICE_WDA); + if (qmi_wda_set_data_format(data->wda, &endpoint_info, &format, + set_data_format_cb, modem, NULL) > 0) + return; + + qrtrqmi_deinit(data); + ofono_modem_set_powered(modem, FALSE); +} + static void power_reset_cb(struct qmi_result *result, void *user_data) { struct ofono_modem *modem = user_data; @@ -148,7 +257,7 @@ static void power_reset_cb(struct qmi_result *result, void *user_data) return; } - ofono_modem_set_powered(modem, TRUE); + setup_data_format(modem); } static void get_oper_mode_cb(struct qmi_result *result, void *user_data) @@ -177,7 +286,7 @@ static void get_oper_mode_cb(struct qmi_result *result, void *user_data) break; default: - ofono_modem_set_powered(modem, TRUE); + setup_data_format(modem); return; } @@ -196,6 +305,7 @@ static void lookup_done(void *user_data) if (!qmi_qrtr_node_has_service(node, QMI_SERVICE_DMS) || !qmi_qrtr_node_has_service(node, QMI_SERVICE_UIM) || !qmi_qrtr_node_has_service(node, QMI_SERVICE_WDS) || + !qmi_qrtr_node_has_service(node, QMI_SERVICE_WDA) || !qmi_qrtr_node_has_service(node, QMI_SERVICE_NAS)) goto error; @@ -236,10 +346,15 @@ static int qrtrqmi_enable(struct ofono_modem *modem) static void power_disable_cb(struct qmi_result *result, void *user_data) { struct ofono_modem *modem = user_data; + struct qrtrqmi_data *data = ofono_modem_get_data(modem); DBG(""); - qrtrqmi_deinit(ofono_modem_get_data(modem)); + rmnet_del_interfaces(data->n_premux, data->rmnet_interfaces); + data->n_premux = 0; + memset(data->rmnet_interfaces, 0, sizeof(data->rmnet_interfaces)); + + qrtrqmi_deinit(data); ofono_modem_set_powered(modem, FALSE); } @@ -346,11 +461,8 @@ static void setup_gprs(struct ofono_modem *modem) { struct qrtrqmi_data *data = ofono_modem_get_data(modem); struct qmi_qrtr_node *node = data->node; - int n_premux = ofono_modem_get_integer(modem, "NumPremuxInterfaces"); struct ofono_gprs *gprs; - const char *interface; - char buf[256]; - int i; + unsigned int i; gprs = ofono_gprs_create(modem, 0, "qmimodem", qmi_qrtr_node_get_service(node, QMI_SERVICE_WDS), @@ -361,23 +473,10 @@ static void setup_gprs(struct ofono_modem *modem) return; } - /* Upstream driver default, single interface, single context */ - if (!n_premux) { - interface = ofono_modem_get_string(modem, "NetworkInterface"); - setup_gprs_context(0, interface, gprs); - return; - } - - for (i = 0; i < n_premux; i++) { - int mux_id; - - sprintf(buf, "PremuxInterface%dMuxId", i + 1); - mux_id = ofono_modem_get_integer(modem, buf); - - sprintf(buf, "PremuxInterface%d", i + 1); - interface = ofono_modem_get_string(modem, buf); + for (i = 0; i < data->n_premux; i++) { + struct rmnet_ifinfo *ifinfo = data->rmnet_interfaces + i; - setup_gprs_context(mux_id, interface, gprs); + setup_gprs_context(ifinfo->mux_id, ifinfo->ifname, gprs); } } From patchwork Tue Nov 26 21:26:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13886377 Received: from mail-oi1-f173.google.com (mail-oi1-f173.google.com [209.85.167.173]) (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 F12191DFD86 for ; Tue, 26 Nov 2024 21:27:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732656431; cv=none; b=NYu3iLnljMYpqoJ1sFguyyWlQboJaSYUc7ery/bb8rHhYViLIuvTvTn+QkR9hHMysxxyUL7E7QLigms3AGSonxUfKYNhGHLXqbAPc5sReEJLHHaLrrdWZHEbw1d4tW5lIhYMn2m4oyhjq7GZIYif6Q39EQPl1PicGC7Fdx183xI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732656431; c=relaxed/simple; bh=Wj4RkngDgqWGj1rgQElelYBFGQvWldiYCQxTcDu67i4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=b6NMmWrK+ZSM/sCXBsMAVB9ibZOwxwojFtDSPn4J0eYXuiwj5lyY3gDQsnGtZsTVVWjjKyrRkx9EmjcAsehtbL4j4WK5pRQYQDIh5o2gU1bVvgwLxrC5mXynUzBZFR3Ok+p8wx8DVyIsmBHeKmdPi/CO8C3SNTqZAVSOryg40q0= 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=nQD32jQW; arc=none smtp.client-ip=209.85.167.173 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="nQD32jQW" Received: by mail-oi1-f173.google.com with SMTP id 5614622812f47-3ea48624a2aso1451539b6e.2 for ; Tue, 26 Nov 2024 13:27:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732656429; x=1733261229; 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=dl7rFJByg1zjg1Y4HfDHhdriiWZ1Y7dMfChV3DmufY8=; b=nQD32jQWdX4y+69RqwIss4+RbtK9vHHXv4oZZemPNPR70QjQ5Z60D9x8nuZmg6i2BE 6lKrnumHs7d+I7vxBNDrWeXitrWJemBfIwhgtlqG6U1UeDckFRIxeimZnEWX2fMxwKRu Q7wYIQZuEGo34gj8CS2z5VKVBLEg1inbX64sWwKWVVoETOKO8ryfqswGVAyW+D1DcCIC fvlqNm9un9xwe06VvPF7VngbnSUG5LCr2QapJmqyDy1vlJUo5nGgQIeCfK1ZerLIm+2O sI1VnSPA0C6X3kISbSksq9sDa8IUPpNmcLHyxRoaFWqEo1GfHfoimoB9TkOdSs471mrH 4ncA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732656429; x=1733261229; 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=dl7rFJByg1zjg1Y4HfDHhdriiWZ1Y7dMfChV3DmufY8=; b=FNJk7SxqtPWtFWVUhRdzkgdoh8T88hej8SqKU5wP2lK69dzpLEMmPesDR4M4eDDVGz tuzB5Bra5XTG925ioiV0BoBtbG8H+m7i4/5gsnMOvpgONtc1ubNWhMjvukoHfmPhoST/ +3VEfpMEFcEGH2YGw8F7NVfKyhlgMw/tLCZy/Gypmg2S+zyVEDFbxju98ZLfFOYr3OM5 zYJj43/aJPco73GQSzQKG7oFzv0UHL6af1ubJXcB9wrrAmfUS40kXrGCrgHsat5ageT8 OKQaPpEmuHUDpraWffkcQRHuTYHLWC/8nf4Nj/Uq/mmmpbDLluQHDWBVNCB+nmUm6srX WqVQ== X-Gm-Message-State: AOJu0Yz6B1zZJa6QymFHNvQMcawruPQxfzXZ6ajUlxz+YXu8a8oHUurP KjlR5KkOFSTRUOEJu13LT7TNZKB4qApgbdoNKUHzl0QFrujMIYsXGvkuEA== X-Gm-Gg: ASbGncs6NslylDBOQADZCq2bNWT9G3DhBXFswwL26gZVwc79bJcNwM15aMZmECGp8CN eDqRF6+og7eARgOowxDA0ESTYTxGUjoM8kVScHgm285xTRBgg7y70Lnl5/K9HwyOVVOZXxyWhFp TKEQyFcGCUWFInTPnbJ85nIiWsIE8a8SFjiIUyI+gdazOx6V5LGH8eh0F+dw6wCO1xaoljLLl9r iOZJSnQKUZ7eGxWZXQatLHtTzkoHSNsdBpKkQZ/GERJotVVF012wwHYhXyzxKtbBqLQ6Smn0SAy aiPk9AKo1TYBWscjDdNm7NCm X-Google-Smtp-Source: AGHT+IG/yAisp9KsHAuDDQFqtTtTHEX0dJXtiWyyoSfFewZOEjRQJG89ydGsRM4CnpKNC5VBndnNcA== X-Received: by 2002:a05:6808:d53:b0:3e6:580e:f12c with SMTP id 5614622812f47-3ea6dbc3f00mr967031b6e.10.1732656429004; Tue, 26 Nov 2024 13:27:09 -0800 (PST) Received: from localhost.localdomain (syn-070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3e914e835e2sm3177531b6e.13.2024.11.26.13.27.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Nov 2024 13:27:08 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 4/4] qrtrqmi: Manage main netdev as part of .set_online Date: Tue, 26 Nov 2024 15:26:18 -0600 Message-ID: <20241126212703.196003-4-denkenz@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241126212703.196003-1-denkenz@gmail.com> References: <20241126212703.196003-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The mhi_hwipX interface is created with IFF_UP not set. It must be set IFF_UP when the modem is brought into online state, otherwise packets will not flow properly. Similarly, when bring the modem into offline state, bring down the main network device for consistency. --- plugins/qrtrqmi.c | 73 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 65 insertions(+), 8 deletions(-) diff --git a/plugins/qrtrqmi.c b/plugins/qrtrqmi.c index 8bfbb11d167e..7065419c34f7 100644 --- a/plugins/qrtrqmi.c +++ b/plugins/qrtrqmi.c @@ -61,6 +61,7 @@ struct qrtrqmi_data { struct rmnet_ifinfo rmnet_interfaces[MAX_CONTEXTS]; uint8_t n_premux; int rmnet_id; + uint32_t set_powered_id; bool have_voice : 1; }; @@ -152,6 +153,12 @@ static void qrtrqmi_remove(struct ofono_modem *modem) } qrtrqmi_deinit(data); + + if (data->set_powered_id) { + l_netlink_cancel(l_rtnl_get(), data->set_powered_id); + data->set_powered_id = 0; + } + l_free(data); } @@ -390,25 +397,75 @@ static void set_online_cb(struct qmi_result *result, void *user_data) CALLBACK_WITH_SUCCESS(cb, cbd->data); } -static void qrtrqmi_set_online(struct ofono_modem *modem, ofono_bool_t online, - ofono_modem_online_cb_t cb, void *user_data) +static void powered_common_cb(int error, bool online, struct cb_data *cbd) { - struct qrtrqmi_data *data = ofono_modem_get_data(modem); - struct cb_data *cbd = cb_data_new(cb, user_data); + struct qrtrqmi_data *data = cbd->user; struct qmi_param *param; + ofono_modem_online_cb_t cb = cbd->cb; - DBG("%p %s", modem, online ? "online" : "offline"); + data->set_powered_id = 0; + + if (error) + goto error; param = qmi_param_new_uint8(QMI_DMS_PARAM_OPER_MODE, online ? QMI_DMS_OPER_MODE_ONLINE : QMI_DMS_OPER_MODE_LOW_POWER); - if (qmi_service_send(data->dms, QMI_DMS_SET_OPER_MODE, param, - set_online_cb, cbd, l_free) > 0) + if (qmi_service_send(data->dms, QMI_DMS_SET_OPER_MODE, + param, set_online_cb, + cb_data_ref(cbd), cb_data_unref) > 0) return; qmi_param_free(param); - l_free(cbd); + cb_data_unref(cbd); +error: + CALLBACK_WITH_FAILURE(cb, cbd->data); +} + +static void powered_up_cb(int error, uint16_t type, const void *msg, + uint32_t len, void *user_data) +{ + struct cb_data *cbd = user_data; + + DBG("error: %d: %s", error, strerror(-error)); + powered_common_cb(error, true, cbd); +} + +static void powered_down_cb(int error, uint16_t type, const void *msg, + uint32_t len, void *user_data) +{ + struct cb_data *cbd = user_data; + + DBG("error: %d: %s", error, strerror(-error)); + powered_common_cb(error, false, cbd); +} + +static void qrtrqmi_set_online(struct ofono_modem *modem, ofono_bool_t online, + ofono_modem_online_cb_t cb, void *user_data) +{ + struct qrtrqmi_data *data = ofono_modem_get_data(modem); + struct l_netlink *rtnl = l_rtnl_get(); + struct cb_data *cbd = cb_data_new(cb, user_data); + l_netlink_command_func_t powered_cb; + + DBG("%p %s", modem, online ? "online" : "offline"); + + cbd->user = data; + + if (online) + powered_cb = powered_up_cb; + else + powered_cb = powered_down_cb; + + data->set_powered_id = l_rtnl_set_powered(rtnl, data->main_net_ifindex, + online, powered_cb, + cbd, cb_data_unref); + if (data->set_powered_id) + return; + + cb_data_unref(cbd); + CALLBACK_WITH_FAILURE(cb, user_data); } static void qrtrqmi_pre_sim(struct ofono_modem *modem)