From patchwork Thu Nov 21 15:29: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: 13882094 Received: from mail-oa1-f53.google.com (mail-oa1-f53.google.com [209.85.160.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 BD2A71369B4 for ; Thu, 21 Nov 2024 15:29:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732202994; cv=none; b=ltB38FXqQ7h5O16bltTf80EE6bAztlymuB9QwTRwJIOldgSFmoC5FheRtRHyN5mLb4umn5EPtLS+qmbysd4YMcEXsYtKZ+4BZ2ppwAmwF/fsZCIPJ25zjEVaGHwk6SbhgCQGsvagwUR8N6wLDN7v3tSFAhtFGxy+ZHIUgxQ3M/k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732202994; c=relaxed/simple; bh=cOXjnlud4QKvzsTQ4OznMq8o9Vx9AcDQ5rCN6r1aqhE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=DVXwS7BjotusIZsv2q12sQan45UorP20/E2YXurMcx/cELQx9aUnSbK//pB2U1V0ZddBE49wvtbEAmaDAMubYmCSC/tS2mqMRd6Z4Qn4unw4Fqe39qSRcxOm875i1M5F7bGXOqXJgfNaDoi48a3GVSpN17roT+3T7WlPyhz8zr0= 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=lzcrJep2; arc=none smtp.client-ip=209.85.160.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="lzcrJep2" Received: by mail-oa1-f53.google.com with SMTP id 586e51a60fabf-2965e10da1bso573367fac.0 for ; Thu, 21 Nov 2024 07:29:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732202992; x=1732807792; 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=5UGQrXToXTTTC19kbDwKCetW1cXwDHGKCfCEl17ztIg=; b=lzcrJep2yKgt+qLW2vuavMX7lbYfxbHj2J9XKtJX0gupN/WaZ3aTM78QhoJRazUeGG GDqWcdmaT2LlaG6P7ai+VDcplFzzhkUeSQlpD60pJcMgb524GLX0TEcpDDvav8ehpKVU cMQmeVWW9pRdq+dBdf/O9euGmNekZMb0Ybw+PcmmjnNlQQ81UEpJV5fxgjQPJenEQHEZ hY86pd2iYkSdjHgQEEBCMf+IBaW9X6EmMDEuSoKFCu5YNXOgeEsLnh4NTC2jUAkoqYc4 BjPQ3oNJXxgHy9Ca5SH+RLonSdx8nXCl2GLA8OkeJAYTwtkCC3nLWBtq/y+vqGJJP7o3 Jbvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732202992; x=1732807792; 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=5UGQrXToXTTTC19kbDwKCetW1cXwDHGKCfCEl17ztIg=; b=qaHBkwbaqz1LVL28CvNxwwWb5bO+rDdOcCsHztiJrOUYh6igJPZMitKCPDVBVcb63R i2QpwA7jXFTpoVGqtnAPrvQ15ywMH4zjJshFzdbuBIdD3uzd3RL2VxTBTzYcH92Qrxvl +1bT2U6k4RZ5GWV+SVIeRpTnm7Ll0ZiQ5H2f+iI7qam5MwNpkKSjGYEwWM+z7beFsr0u 5C3KZbJxztVc6uBo2O2gTfVcQY/tHF8MD2lL0hcBliQrVoRVDvWi3Zg8ti38yyG0rjm5 dhJfrA8M0d+JkumRHLGzvWDn4C8ICHzTnExEICVM+dGSGLlUTtSKBZ3KOjvsZrYRN2Ct 1pHQ== X-Gm-Message-State: AOJu0YzJcyu4r8igqr7TGkZLbJrhXwnI+U/sftlt+9BXXAKgySODHnj1 u9htrVF1vIN4c/2snnynuk6TiGksrzxZC+xdpqT7ZogR59fK01zjNSpF8w== X-Gm-Gg: ASbGncvXYhUzYmV7ir3NJkf5rU32JzuCmBXaL88VG4lui1OvQ9mVAwIMsL5+azKlv8J Ae9d4dgF8pEZ4qDpTPCvN6hGjdRLzC7OJ5yukgZ6tp0Ip7N8XtDBEMBukRAEP3566gQjcjnp+F/ 8Il/Xo02fQymc0mZ8IFcE8evjJ17XbZEoo/baMVF+XxVW3mrXXdPKygvx94JD6kasPNjWqqSBJn ZJyKWkvHUPQQ4qExY+OwXEguPLi5JlKQejHhd8elIS81RNFPzb8jJtOGn9/vAa+diPDXHXbrveG QZGd3k7I0SpXxIn48NWPG3ZG X-Google-Smtp-Source: AGHT+IGwgMguNYjE5M0s0oI2WpvmCV8hvmtqnOj9ZpWRKyHsQYc40O8DXvMfIseqwcumqyjfzw81dQ== X-Received: by 2002:a05:6870:b507:b0:296:80aa:a9b7 with SMTP id 586e51a60fabf-296d9bf04f9mr7114432fac.21.1732202991661; Thu, 21 Nov 2024 07:29:51 -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 586e51a60fabf-29651ac5ff9sm4856831fac.42.2024.11.21.07.29.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Nov 2024 07:29:51 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 01/10] qmi: wda: Add qmi_wda_set_data_format utility Date: Thu, 21 Nov 2024 09:29:29 -0600 Message-ID: <20241121152949.56962-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 This utility function builds a WDA Set Data Format message and sends it to the desired wda service handle. --- Makefile.am | 1 + drivers/qmimodem/common.h | 5 ++++ drivers/qmimodem/gprs-context.c | 6 ++-- drivers/qmimodem/wda.c | 51 +++++++++++++++++++++++++++++++++ drivers/qmimodem/wda.h | 23 +++++++++++++++ 5 files changed, 82 insertions(+), 4 deletions(-) create mode 100644 drivers/qmimodem/wda.c diff --git a/Makefile.am b/Makefile.am index d107dc410fd2..2d198f52a4a0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -366,6 +366,7 @@ qmi_sources = drivers/qmimodem/qmi.h drivers/qmimodem/qmi.c \ drivers/qmimodem/pds.h \ drivers/qmimodem/common.h \ drivers/qmimodem/wda.h \ + drivers/qmimodem/wda.c \ drivers/qmimodem/wds.c \ drivers/qmimodem/voice.h diff --git a/drivers/qmimodem/common.h b/drivers/qmimodem/common.h index b0788285b5e7..1610f1da9e45 100644 --- a/drivers/qmimodem/common.h +++ b/drivers/qmimodem/common.h @@ -76,3 +76,8 @@ #define QMI_LTE_BAND_MASK_EUTRA_41 0x0000010000000000 #define QMI_LTE_BAND_MASK_EUTRA_42 0x0000020000000000 #define QMI_LTE_BAND_MASK_EUTRA_43 0x0000040000000000 + +struct qmi_endpoint_info { + uint32_t endpoint_type; + uint32_t interface_number; +} __attribute__((packed)); diff --git a/drivers/qmimodem/gprs-context.c b/drivers/qmimodem/gprs-context.c index 89d68d154ed8..a8ac3cb18c80 100644 --- a/drivers/qmimodem/gprs-context.c +++ b/drivers/qmimodem/gprs-context.c @@ -17,6 +17,7 @@ #include #include "qmi.h" +#include "common.h" #include "wds.h" #include "util.h" @@ -715,10 +716,7 @@ static int qmi_gprs_context_bind_mux(struct ofono_gprs_context *gc, struct qmi_param *param; const char *interface_number; const char *bus; - struct { - uint32_t endpoint_type; - uint32_t interface_number; - } __attribute__((packed)) endpoint_info; + struct qmi_endpoint_info endpoint_info; uint8_t u8; bus = ofono_modem_get_string(modem, "Bus"); diff --git a/drivers/qmimodem/wda.c b/drivers/qmimodem/wda.c new file mode 100644 index 000000000000..cf32aa094d69 --- /dev/null +++ b/drivers/qmimodem/wda.c @@ -0,0 +1,51 @@ +/* + * oFono - Open Source Telephony + * Copyright (C) 2024 Cruise, LLC + * + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#include +#include + +#include + +#include "src/common.h" + +#include "qmi.h" +#include "common.h" +#include "wda.h" + +uint16_t qmi_wda_set_data_format(struct qmi_service *wda, + const struct qmi_endpoint_info *endpoint_info, + const struct qmi_wda_data_format *format, + qmi_service_result_func_t func, + void *user_data, qmi_destroy_func_t destroy) +{ + static const uint8_t PARAM_LL_PROTO = 0x11; + static const uint8_t PARAM_UL_AGGREGATION_PROTOCOL = 0x12; + static const uint8_t PARAM_DL_AGGREGATION_PROTOCOL = 0x13; + static const uint8_t PARAM_DL_MAX_DATAGRAMS = 0x15; + static const uint8_t PARAM_DL_MAX_SIZE = 0x16; + static const uint8_t PARAM_EP_INFO = 0x17; + struct qmi_param *param = qmi_param_new(); + uint32_t req_id; + + qmi_param_append_uint32(param, PARAM_LL_PROTO, format->ll_protocol); + qmi_param_append_uint32(param, PARAM_UL_AGGREGATION_PROTOCOL, + format->ul_aggregation_protocol); + qmi_param_append_uint32(param, PARAM_DL_AGGREGATION_PROTOCOL, + format->dl_aggregation_protocol); + qmi_param_append_uint32(param, PARAM_DL_MAX_DATAGRAMS, + format->dl_max_datagrams); + qmi_param_append_uint32(param, PARAM_DL_MAX_SIZE, format->dl_max_size); + qmi_param_append(param, PARAM_EP_INFO, + sizeof(*endpoint_info), endpoint_info); + + req_id = qmi_service_send(wda, QMI_WDA_SET_DATA_FORMAT, + param, func, user_data, destroy); + if (!req_id) + qmi_param_free(param); + + return req_id; +} diff --git a/drivers/qmimodem/wda.h b/drivers/qmimodem/wda.h index fd1e1f63ab1e..4facc0cb6677 100644 --- a/drivers/qmimodem/wda.h +++ b/drivers/qmimodem/wda.h @@ -5,6 +5,8 @@ * SPDX-License-Identifier: GPL-2.0-only */ +struct qmi_endpoint_info; + #define QMI_WDA_SET_DATA_FORMAT 32 /* Set data format */ #define QMI_WDA_GET_DATA_FORMAT 33 /* Get data format */ @@ -16,3 +18,24 @@ enum qmi_wda_data_link_protocol { QMI_WDA_DATA_LINK_PROTOCOL_802_3 = 0x01, QMI_WDA_DATA_LINK_PROTOCOL_RAW_IP = 0x02, }; + +enum qmi_wda_aggregation_protocol { + QMI_WDA_AGGREGATION_PROTOCOL_DISABLED = 0x00, + QMI_WDA_AGGREGATION_PROTOCOL_QMAP = 0x05, + QMI_WDA_AGGREGATION_PROTOCOL_QMAPV4 = 0x08, + QMI_WDA_AGGREGATION_PROTOCOL_QMAPV5 = 0x09, +}; + +struct qmi_wda_data_format { + uint32_t ll_protocol; + uint32_t ul_aggregation_protocol; + uint32_t dl_aggregation_protocol; + uint32_t dl_max_datagrams; + uint32_t dl_max_size; +}; + +uint16_t qmi_wda_set_data_format(struct qmi_service *wda, + const struct qmi_endpoint_info *endpoint_info, + const struct qmi_wda_data_format *format, + qmi_service_result_func_t func, + void *user_data, qmi_destroy_func_t destroy); From patchwork Thu Nov 21 15:29: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: 13882095 Received: from mail-oa1-f49.google.com (mail-oa1-f49.google.com [209.85.160.49]) (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 D012B19D080 for ; Thu, 21 Nov 2024 15:29:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732202995; cv=none; b=dJwqj0yipdtMCL4TR4BykwnnS8hpLnEV1VmAvbcZ6AbD4SUUogRNn5Xn77T84+ueMauYrp5zauevprNqTZa52lCKgb1bJT83ogGjlPZwR8dJYN01KwmqnWRHuTGCaBEa6LroJ0oEo87PJTjUQxTOl/AbCDlo/CHsODyZs78yHOI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732202995; c=relaxed/simple; bh=03kej0DJIYKoyJcnjc3zcbawUpT3XMl36zMCabZEu9Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NADGiUcm/JsBTkYXbVple2ldb21p0h6EksSUtFdvBIFNe6MAPRlNcyZAukTmiE5/uyPVLOaKHZvVJTUVyHrgnjl8Zm3WlDgs5jyIWMqxfxxFyD9cX731vT/b1Ao/HZ73WHriNbg3MJxHRyeEct+mY2r/dw5XENy3EFsgbeheQ8U= 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=nFg9ugax; arc=none smtp.client-ip=209.85.160.49 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="nFg9ugax" Received: by mail-oa1-f49.google.com with SMTP id 586e51a60fabf-27d0e994ae3so521859fac.3 for ; Thu, 21 Nov 2024 07:29:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732202993; x=1732807793; 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=4D9yGc+TQp7y7oE5+UbznEG/33kXPLILwm5UOL6H50M=; b=nFg9ugaxRA6uEsjqawj76NKAQPT+ahq5jzwk/2hem62vtZ31fZ5HKnIYweaGYuDYv/ fVvT/37K2dBgRXk4AYyZSJ/VjSCpCwGK/QX14QS1XhqyRYIKeH/wodHLS10sYK8dcABS rQ4m9Ni//1ajRC/GHjHtbJs4QHtbvy1AP8vQV5g34lH+aiWxcApoWBR7CGOG8NYt2k/d NxekGd2zdrOT/7IQwO5s3D58fV+hYPcJE58LKZJhgpwXDI+QST6oHVeI9fs6Hv3UkhgT ZwzmTyEGroIiQ+YgqbVpD7cttU/RjYiuENaUSOh1K2CQGs6egu48b1g6SnGg/Ax7X0aw cDiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732202993; x=1732807793; 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=4D9yGc+TQp7y7oE5+UbznEG/33kXPLILwm5UOL6H50M=; b=hFStiROsENGD2ds7n1Q+iEXlUVy2Ut1VnlywBD7oPMD1sPsIynL0QiTn2cbxj/zGd9 ZBCuwRoqVionLxgv9rp0Mqd9FRRwXuGLCnpelieh3Amv6YVeNBaMAAYH5jBzEvAzGWoC EzHmWc7zx3l6UHxu2ynIfJyqXGVcAVVf3ze72AACqxZGeKcuP4rCWyBwTtNw1kQNfAa/ AaZ9LefGEo+5JgFbOTL/sKkSCNbJmwMy13IN2hN0I85nM1iank8/PVJV7jIi8v8gA/LA 4BAFPCLd4xDn0h98d5cgBv/tnVcIhqr+P/qjtmijflyStQq1eMAOFUfUvRVcmEu14GvO H0ag== X-Gm-Message-State: AOJu0YwcPbVlra9Kqp87ek/lTrZ2Bne/sIrXklSt+1FKbXwT7yjz7Ggq JlCISztJkOMeGx3FDdeMcQyuKNJOts/gOfC6kttWsvy4xAdNpaXZGQ8BVw== X-Gm-Gg: ASbGnctMZ9oVruI6wbsw90hqHaHR4X1G3/Mbkd/54xuFWtVDMgOiFnr3DhWIM69sFqI OzRpz+AyO22iDLhH0/Ab8wajstuK0mNVhZrmaFVcYhmp+jMAAjaym3jsm7GYkkbXc9wfsHsfVd5 21l13RByBhnR+mdKbzYuBFRxdxgjRylTfHIkOOjWjoKMiclKYIJstVnqxoxsu9OI8ECa5VZGlcH IJnkhl8cu+rU+RLsUVyFGj+gFgIYlgEjrPaQwaQVlrlLCkpHzWX2zE3o9JIJT2L8955Vz68HYCF nzj1SJvjhjDOhasR9CU/D4lC X-Google-Smtp-Source: AGHT+IFacn/FwXnCEfcp5JzsL41ZtM4Ao8KZZyx+0Wca5ciuYiA3OkBicFepfnNhBtYWgeV+PTTGhg== X-Received: by 2002:a05:6870:d10e:b0:25e:d90:fe70 with SMTP id 586e51a60fabf-296d9f25222mr6747192fac.43.1732202992652; Thu, 21 Nov 2024 07:29:52 -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 586e51a60fabf-29651ac5ff9sm4856831fac.42.2024.11.21.07.29.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Nov 2024 07:29:52 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 02/10] qmi: wda: Add qmi_wda_parse_data_format utility Date: Thu, 21 Nov 2024 09:29:30 -0600 Message-ID: <20241121152949.56962-2-denkenz@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241121152949.56962-1-denkenz@gmail.com> References: <20241121152949.56962-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This utility function parses the response from WDA Set Data Format result message, and from the WDA Get Data Format result message. --- drivers/qmimodem/wda.c | 36 ++++++++++++++++++++++++++++++++++++ drivers/qmimodem/wda.h | 2 ++ 2 files changed, 38 insertions(+) diff --git a/drivers/qmimodem/wda.c b/drivers/qmimodem/wda.c index cf32aa094d69..0ba8914312da 100644 --- a/drivers/qmimodem/wda.c +++ b/drivers/qmimodem/wda.c @@ -16,6 +16,42 @@ #include "common.h" #include "wda.h" +int qmi_wda_parse_data_format(struct qmi_result *result, + struct qmi_wda_data_format *out_format) +{ + static const uint8_t RESULT_LL_PROTO = 0x11; + static const uint8_t RESULT_UL_AGGREGATION_PROTOCOL = 0x12; + static const uint8_t RESULT_DL_AGGREGATION_PROTOCOL = 0x13; + static const uint8_t RESULT_DL_MAX_DATAGRAMS = 0x15; + static const uint8_t RESULT_DL_MAX_SIZE = 0x16; + struct qmi_wda_data_format format; + + if (!qmi_result_get_uint32(result, RESULT_LL_PROTO, + &format.ll_protocol)) + return -ENOENT; + + if (!qmi_result_get_uint32(result, RESULT_UL_AGGREGATION_PROTOCOL, + &format.ul_aggregation_protocol)) + return -ENOENT; + + if (!qmi_result_get_uint32(result, RESULT_DL_AGGREGATION_PROTOCOL, + &format.dl_aggregation_protocol)) + return -ENOENT; + + if (!qmi_result_get_uint32(result, RESULT_DL_MAX_DATAGRAMS, + &format.dl_max_datagrams)) + return -ENOENT; + + if (!qmi_result_get_uint32(result, RESULT_DL_MAX_SIZE, + &format.dl_max_size)) + return -ENOENT; + + if (out_format) + memcpy(out_format, &format, sizeof(struct qmi_wda_data_format)); + + return 0; +} + uint16_t qmi_wda_set_data_format(struct qmi_service *wda, const struct qmi_endpoint_info *endpoint_info, const struct qmi_wda_data_format *format, diff --git a/drivers/qmimodem/wda.h b/drivers/qmimodem/wda.h index 4facc0cb6677..608c04947d6a 100644 --- a/drivers/qmimodem/wda.h +++ b/drivers/qmimodem/wda.h @@ -34,6 +34,8 @@ struct qmi_wda_data_format { uint32_t dl_max_size; }; +int qmi_wda_parse_data_format(struct qmi_result *result, + struct qmi_wda_data_format *out_format); uint16_t qmi_wda_set_data_format(struct qmi_service *wda, const struct qmi_endpoint_info *endpoint_info, const struct qmi_wda_data_format *format, From patchwork Thu Nov 21 15:29: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: 13882096 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 B62561369B4 for ; Thu, 21 Nov 2024 15:29:54 +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=1732202996; cv=none; b=eLTh5AFlaiOIwPbz2oH+dE1zi0K/e1Sa4W2tqJFnDp0MbANRjEzr0HogQEFOWXLlag/fX+jgnvVQs55QzY99f+lyCl5ej6lPIq5BAJcRpq9+Q5ZoED3Z5oPCo47c+vkI4QEuIfnJuMqb7RV1zLeSms9W3fgjn3fWDtvS9QgVJG0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732202996; c=relaxed/simple; bh=xregUDOpLXmogpkaDnz5Rcr5Qh6XR4lIzMjwLez0j6k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c1Gi0wEjtuhRLXAtwDgZuZMBVymggjwVNOkKGvfgtePr/IClogUirkjjSvBNt+RJgjHnY1I/WNGlPlA8vc1dRgcKKDiCnTSbIYp3J2mkuv+DPlD7qAUBn+DWDG8oPYYZBcjHiWKsG/RfO+jfsIALEtGLvxmofbx7U66IxsZLdT4= 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=K0tec7il; 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="K0tec7il" Received: by mail-oa1-f52.google.com with SMTP id 586e51a60fabf-296c184ed6bso642165fac.0 for ; Thu, 21 Nov 2024 07:29:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732202993; x=1732807793; 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=80CTRyuEUF3ZQoRGp6bgbgOH1IDCwiiaGWfqq1ywHNc=; b=K0tec7il7GlIfQJ93lyp/q45G6srGotETebmQWbFJddu7tSIdAomPA0eJxoiwJ9j2H YchvL5HHLtDfmMMAyHTYbxMKJ1wENUWSrbv7JHoa68oFpInSFQECgyJX2nydrEZuCHYm TsaGvey/qiYNt1OOfpnQIzvMeGoafQ0Idd3GUW1ElYNeS2XXM/6pMpotVKtSlbvgey2L XYZHrKuWQ937Cny9Vw0N+bxwFNkXhS+U6czsdb1GSqMHB78wg2qY+yN9BXBbvXBFQCvM GMln8+SincSsmbWJitDk4A0RAgCOqTnlhIorgNpxnlvfYsU0l0PG9eZHMb9aa8gLj2N3 qlMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732202993; x=1732807793; 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=80CTRyuEUF3ZQoRGp6bgbgOH1IDCwiiaGWfqq1ywHNc=; b=H9Y3EtDv8M+jVXCLOceWEGP4GPIQSQNKzsV144fqo8W14e7w4f0MVq5ziB1VjUsZlZ fLsU3VH6rlJ7XOKq1GOvmx1q+iLfn9bF5KunjiUELpLm+c8DfmYh/eZ207MzQyT4T1nh GOYVXM2NA4+TjoBi0tg/1C2RbkMFMYOuRKmpyxEObf1qlxiK46IvOOiD5dh2RgCBRnqN v4O4X5IeGoKJ44U2AFZNXTe+tsZqxiVBh+JAPEiZf53miFFdNjD7s/yGsp3F/w//2fSX 1kxvzncPsKCLTaJ0p6CatxmEzNTxuldXAlRk5oTPsxve5OyhI5/J+fPdB5i0gIdRx9KX 61sA== X-Gm-Message-State: AOJu0YxFXisSBcgKjJ7QZMHhkiQ57N7Jz1rjugOmxTig6o7SeSICu4Z0 FbMmEG7rsaXMxJBaoEY+9G5vGxid5Nl5EdRxF/dW5FLLq/MYoLEn+nNC8g== X-Gm-Gg: ASbGncvVVrW7SfdVJ7pZD8xElc3q5PuFCxXbHBP/dQrDWKR10nlwNhAoNNOMtG8S5wY PCO0EZQFXT9LZ79cBaHR9Yq8kZHWAFjsO4VWHZ44biitOHn0k27gxxY1colf/pFrFT3az6wVk8O +4ioiN8Dny5T2aagJkkQUjGlF1Y5mNp8LDEt/D1RTcXr7m5e+e5CNRZmwU6XX5weit2gXKsAm6u Jo6CWek7S8fIwOd8P4TRuFPMaGvhnkPBvGDCtTCA89H9y5wkNrNv8qAUTV7AcTCD28eiYkn9ek6 RjrjRvhdSdtm//yn2BbQ/t41 X-Google-Smtp-Source: AGHT+IGk62XZmdItay4SDXYKWfR277dMbuXdVxnlVhzkR36YRM0ELzVRRmmdGjK5oxxzDZXm2Xki6Q== X-Received: by 2002:a05:6871:5287:b0:296:a7bf:b503 with SMTP id 586e51a60fabf-296d9ae0a64mr7392417fac.7.1732202993554; Thu, 21 Nov 2024 07:29:53 -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 586e51a60fabf-29651ac5ff9sm4856831fac.42.2024.11.21.07.29.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Nov 2024 07:29:53 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 03/10] gobi: Explicitly set 802.3 data format Date: Thu, 21 Nov 2024 09:29:31 -0600 Message-ID: <20241121152949.56962-3-denkenz@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241121152949.56962-1-denkenz@gmail.com> References: <20241121152949.56962-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The current logic relies on querying the current data format, and setting the qmi_wwan parameters accordingly. Unfortunately, the logic does not take data aggregation settings into account and can get confused if the modem is using such settings. Fix this by explicitly setting the WDA data format to 802.3. While here, add some preparatory logic to support other data modes easily. This will be used in the future to support multiple contexts using RMNet + QMAP. --- plugins/gobi.c | 191 ++++++++++++++++++++++++++++--------------------- 1 file changed, 108 insertions(+), 83 deletions(-) diff --git a/plugins/gobi.c b/plugins/gobi.c index 54b64acb7871..4af3f3846694 100644 --- a/plugins/gobi.c +++ b/plugins/gobi.c @@ -45,6 +45,7 @@ #include #include #include +#include #define GOBI_DMS (1 << 0) #define GOBI_NAS (1 << 1) @@ -57,6 +58,13 @@ #define MAX_CONTEXTS 4 +#define QMI_WWAN_RAW_IP "/sys/class/net/%s/qmi/raw_ip" + +enum wda_data_format { + WDA_DATA_FORMAT_UNKNOWN = 0, + WDA_DATA_FORMAT_802_3, /* Last, most compatible legacy fallback */ +}; + struct service_request { struct qmi_service **member; uint32_t service_type; @@ -88,6 +96,7 @@ struct gobi_data { uint8_t interface_number; uint32_t max_aggregation_size; uint32_t set_powered_id; + enum wda_data_format data_format; bool using_mux : 1; }; @@ -105,6 +114,28 @@ static void gobi_io_debug(const char *str, void *user_data) ofono_debug("%s%s", prefix, str); } +static bool wda_get_data_format(struct gobi_data *data, + struct qmi_wda_data_format *out_format) +{ + if (data->data_format == WDA_DATA_FORMAT_UNKNOWN || + data->data_format > WDA_DATA_FORMAT_802_3) + return false; + + memset(out_format, 0, sizeof(struct qmi_wda_data_format)); + + if (data->data_format == WDA_DATA_FORMAT_802_3) { + out_format->ll_protocol = QMI_WDA_DATA_LINK_PROTOCOL_802_3; + return true; + } + + return false; +} + +static int qmi_wwan_set_raw_ip(const char *interface, char value) +{ + return l_sysctl_set_char(value, QMI_WWAN_RAW_IP, interface); +} + /* * Probe the modem. The following modem properties are expected to be set * in order to initialize the driver properly: @@ -159,11 +190,8 @@ static int gobi_probe(struct ofono_modem *modem) return -EINVAL; data = l_new(struct gobi_data, 1); - data->main_net_ifindex = - ofono_modem_get_integer(modem, "NetworkInterfaceIndex"); - l_strlcpy(data->main_net_name, - ofono_modem_get_string(modem, "NetworkInterface"), - sizeof(data->main_net_name)); + data->main_net_ifindex = ifindex; + l_strlcpy(data->main_net_name, ifname, sizeof(data->main_net_name)); data->interface_number = interface_number; ofono_modem_set_data(modem, data); @@ -252,6 +280,7 @@ static void __shutdown_device(struct ofono_modem *modem) data->cur_service_request = 0; data->num_service_requests = 0; data->features = 0; + data->data_format = WDA_DATA_FORMAT_UNKNOWN; qmi_qmux_device_free(data->device); data->device = NULL; @@ -376,126 +405,113 @@ error: shutdown_device(modem); } -static void setup_qmi_wwan(const char *interface, uint32_t llproto) -{ - char raw_ip; - char new_raw_ip; - - if (l_sysctl_get_char(&raw_ip, "/sys/class/net/%s/qmi/raw_ip", - interface) < 0) { - DBG("Couldn't query raw_ip setting"); - return; - } - - if (raw_ip != 'Y' && raw_ip != 'N') { - DBG("Unexpected value: %c", raw_ip); - return; - } - - switch (llproto) { - case QMI_WDA_DATA_LINK_PROTOCOL_802_3: - new_raw_ip = 'N'; - break; - case QMI_WDA_DATA_LINK_PROTOCOL_RAW_IP: - new_raw_ip = 'Y'; - break; - default: - DBG("Unknown WDA Link Protocol"); - return; - } - - DBG("raw_ip: %c, want: %c", raw_ip, new_raw_ip); - - if (raw_ip == new_raw_ip) - return; - - if (l_sysctl_set_char(new_raw_ip, "/sys/class/net/%s/qmi/raw_ip", - interface) < 0) - DBG("Fail to set raw_ip to %c", new_raw_ip); -} - -static void get_data_format_cb(struct qmi_result *result, void *user_data) +static void request_service_cb(struct qmi_service *service, void *user_data) { struct ofono_modem *modem = user_data; struct gobi_data *data = ofono_modem_get_data(modem); - uint32_t llproto; + struct service_request *req = + &data->service_requests[data->cur_service_request]; DBG(""); - if (qmi_result_set_error(result, NULL)) - goto done; + if (!service) + goto error; - if (!qmi_result_get_uint32(result, QMI_WDA_LL_PROTOCOL, &llproto)) - goto done; + *req->member = service; - setup_qmi_wwan(data->main_net_name, llproto); + data->cur_service_request += 1; + if (data->cur_service_request == data->num_service_requests) { + DBG("All services requested, query DMS Capabilities"); -done: - if (qmi_service_send(data->dms, QMI_DMS_GET_CAPS, NULL, + if (qmi_service_send(data->dms, QMI_DMS_GET_CAPS, NULL, get_caps_cb, modem, NULL) > 0) + return; + + goto error; + } + + req = &data->service_requests[data->cur_service_request]; + DBG("Requesting: %u", req->service_type); + + if (qmi_qmux_device_create_client(data->device, req->service_type, + request_service_cb, modem, NULL)) return; +error: shutdown_device(modem); } -static void create_wda_cb(struct qmi_service *service, void *user_data) +static void set_data_format_cb(struct qmi_result *result, void *user_data) { struct ofono_modem *modem = user_data; struct gobi_data *data = ofono_modem_get_data(modem); + struct qmi_endpoint_info endpoint_info = { + .endpoint_type = QMI_DATA_ENDPOINT_TYPE_HSUSB, + .interface_number = data->interface_number, + }; + struct qmi_wda_data_format format; DBG(""); - if (!service) { - DBG("Failed to request WDA service, continue initialization"); + if (!qmi_result_set_error(result, NULL)) + goto done; + + if (data->data_format == WDA_DATA_FORMAT_802_3) goto error; - } - data->wda = service; + DBG("Trying next data format"); + data->data_format += 1; - if (qmi_service_send(data->wda, QMI_WDA_GET_DATA_FORMAT, NULL, - get_data_format_cb, modem, NULL) > 0) - return; + if (!wda_get_data_format(data, &format)) + goto error; -error: - if (qmi_service_send(data->dms, QMI_DMS_GET_CAPS, NULL, - get_caps_cb, modem, NULL) > 0) + if (qmi_wda_set_data_format(data->wda, &endpoint_info, &format, + set_data_format_cb, modem, NULL) > 0) return; + goto error; + +done: + DBG("Set Data Format succeeded, proceeding to create services"); + + if (qmi_qmux_device_create_client(data->device, QMI_SERVICE_DMS, + request_service_cb, modem, NULL) > 0) + return; +error: shutdown_device(modem); } -static void request_service_cb(struct qmi_service *service, void *user_data) +static void create_wda_cb(struct qmi_service *service, void *user_data) { struct ofono_modem *modem = user_data; struct gobi_data *data = ofono_modem_get_data(modem); - struct service_request *req = - &data->service_requests[data->cur_service_request]; + struct qmi_endpoint_info endpoint_info = { + .endpoint_type = QMI_DATA_ENDPOINT_TYPE_HSUSB, + .interface_number = data->interface_number, + }; + struct qmi_wda_data_format format; DBG(""); - if (!service) - goto error; - - *req->member = service; - - data->cur_service_request += 1; - if (data->cur_service_request == data->num_service_requests) { - DBG("All services requested, proceeding to create WDA"); + if (!service) { + DBG("Failed to request WDA service, assume 802.3"); - if (qmi_qmux_device_create_client(data->device, QMI_SERVICE_WDA, - create_wda_cb, modem, NULL)) + if (qmi_qmux_device_create_client(data->device, QMI_SERVICE_DMS, + request_service_cb, modem, NULL) > 0) return; goto error; } - req = &data->service_requests[data->cur_service_request]; - DBG("Requesting: %u", req->service_type); + data->wda = service; + data->data_format = WDA_DATA_FORMAT_UNKNOWN + 1; - if (qmi_qmux_device_create_client(data->device, req->service_type, - request_service_cb, modem, NULL)) - return; + if (!wda_get_data_format(data, &format)) + goto error; + if (qmi_wda_set_data_format(data->wda, &endpoint_info, &format, + set_data_format_cb, modem, NULL) > 0) + return; error: shutdown_device(modem); } @@ -563,9 +579,10 @@ static void discover_cb(void *user_data) QMI_SERVICE_WDS); } - if (qmi_qmux_device_create_client(data->device, QMI_SERVICE_DMS, - request_service_cb, modem, NULL) > 0) + if (qmi_qmux_device_create_client(data->device, QMI_SERVICE_WDA, + create_wda_cb, modem, NULL)) return; + error: shutdown_device(modem); } @@ -585,6 +602,14 @@ static void init_powered_down_cb(int error, uint16_t type, if (error) goto error; + DBG("Setting QMI_WWAN to 802.3 mode"); + + r = qmi_wwan_set_raw_ip(data->main_net_name, 'N'); + if (r < 0) { + ofono_warn("Unable to reset raw_ip"); + goto error; + } + r = qmi_qmux_device_discover(data->device, discover_cb, modem, NULL); if (!r) return; From patchwork Thu Nov 21 15:29: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: 13882097 Received: from mail-oa1-f45.google.com (mail-oa1-f45.google.com [209.85.160.45]) (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 7A3C119D080 for ; Thu, 21 Nov 2024 15:29:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732202997; cv=none; b=e94zhktljX+QdWbUmYHtFq9LALVi+4kzrKk/ydK8mRWBntyJBrDxyoB6YzQC+doCPQSLAMJwUMah7de4rnMfwK0OfagIJQ2WeChfJboTbL+BXbiIJ6j7S3Y/wQp7VzkVCP2csZqyDGDPwIA0aic9H8mnnt2ypl+7lW6R4W8Jk50= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732202997; c=relaxed/simple; bh=goXx78K2KumYVXCBKxzF4raCV0W0ReQPQ98vi51FmHw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GrLL1gQzeGLZxHqfz88gjq+45zPcWlhuocOuAxzEJmuSTRbzH8ayzvnj9NsNHuySUFgm6nLC5tv0NA8aCKw5PGnsRUWriZyGjIcaE0W99/9KH28NkPNEAnPBnEFAAo5AzMUFggKfg8y2/x+Qdc6uhIUQt4FCmmX8P9KnG5eTy0Y= 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=lnSEEsXM; arc=none smtp.client-ip=209.85.160.45 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="lnSEEsXM" Received: by mail-oa1-f45.google.com with SMTP id 586e51a60fabf-296b0d2271aso668946fac.0 for ; Thu, 21 Nov 2024 07:29:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732202994; x=1732807794; 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=3ej4MTVy6vT9sqHMDE1EKLAEae+qaoh0XppUwehHJDo=; b=lnSEEsXMtckDtiukJFBDFPj4RLK966jdO/mHO7NtL/xIiXcpzBwe3L9znfxAYOlM24 nw2ckY2+T4nZDvxIaF9PEZWoKmasu0J1VAKl04roSsuWTkaknEGNiSktoUZiMhS/XW2p Q4miD66CDnNALPFU0/T4K+bQXC05778iJ9kM2s8O3HphulE1qjW5Wlzkpn1S6n8ISisy zuKSWUjr4983Z1p1Ly2y7A1JbaTp/OPGuFgT178lbPlw0IAuMo+JM0I2Iu0bVMifYLY8 ew8NmH825JxT/W/fbL+59uqhsUyP/NQ0+XYUnlrVVfEDSoLxDSL0pEm075c90H2+5sKE 2KrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732202994; x=1732807794; 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=3ej4MTVy6vT9sqHMDE1EKLAEae+qaoh0XppUwehHJDo=; b=L2HRoMRIJ8ol1UaHgAbOw/VGvkf3hznxJ1I7S/l1ZqaqGHwCPIJpU5hnIx4EBbOJ71 OMb94I46aQQ24mBXl3lIts3edesPOdhihjuJMG5ZH6MVqCPS3xtZNfKzaB4vT/vaMPSv UOSMCnYpyxqBIc/yVHD1VY1UYiP6GoPjID9sPAjfBjiY1xbbABp9meQxBL3X9tVxbLuQ RZddtQfemGernnWNoAi+YxT/wYU6JHcGtlgOK2SVFVbN4F+naJ4lhJriwnjUPRtR/u/W yzmciFEHRULPcq0qw+ox0CEOSUmqiRUHyd7x17LURxYgltPpvO/3/Wgbf0+E5bp2sUnM BZZw== X-Gm-Message-State: AOJu0Yy7fSgdKQILRX8L7/rKENnOucl1Xf1oWUkj8QXNg7zCSHsmaOVO /RTzhrmofHQXlOCzNpkNN8eFH7Z2dP+6i5ivzALob2/clgHPLx65/HMa7w== X-Gm-Gg: ASbGncu72ImQnCSn4Er8XuS1bSD0BXNt4Gns7QxvNfHOUSd4/VzfE7Oy1gyJZEs4ATQ m74v8V8DA/95nRfMzU00qXOONBwayidNpYBmChRTchBdnL8DzXfZn/brLdI508Hw0OfCL40iIQV qouiXUpcreJQ6zgEzGud1FZg/ByOILibwX6clW4fcead1LibssNq4Jv5AZnr9dm6uOKe2AA7OP6 Pi5q5wsj+zaE4nf7gaGmeof+cgWxUMxF97sFQPPl//K5loTFpJHuY39JsiVGQoGW9jc0lSvGMsn bHT1wSUku9O92gHnAtAcy2u4 X-Google-Smtp-Source: AGHT+IERwkBaGURGRYJhFBNUMxx21M/p0h6CiS1W0CgVKK09G4srv7w4ABIPKor4FaMpbLQeLO8ahw== X-Received: by 2002:a05:6871:d205:b0:288:6d7e:2e19 with SMTP id 586e51a60fabf-296d9b57fcfmr7518199fac.10.1732202994423; Thu, 21 Nov 2024 07:29:54 -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 586e51a60fabf-29651ac5ff9sm4856831fac.42.2024.11.21.07.29.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Nov 2024 07:29:54 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 04/10] gobi: Detect qmi_wwan pass_through support Date: Thu, 21 Nov 2024 09:29:32 -0600 Message-ID: <20241121152949.56962-4-denkenz@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241121152949.56962-1-denkenz@gmail.com> References: <20241121152949.56962-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Detect the presence of 'pass_through' sysfs entry and record it in a flag for future reference. pass_through mode is used when QMI_WWAN and rmnet interfaces are used in a multiplexed fashion. --- plugins/gobi.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/plugins/gobi.c b/plugins/gobi.c index 4af3f3846694..87b54ae05f17 100644 --- a/plugins/gobi.c +++ b/plugins/gobi.c @@ -15,6 +15,7 @@ #include #include #include +#include #define OFONO_API_SUBJECT_TO_CHANGE #include @@ -59,6 +60,7 @@ #define MAX_CONTEXTS 4 #define QMI_WWAN_RAW_IP "/sys/class/net/%s/qmi/raw_ip" +#define QMI_WWAN_PASS_THROUGH "/sys/class/net/%s/qmi/pass_through" enum wda_data_format { WDA_DATA_FORMAT_UNKNOWN = 0, @@ -98,6 +100,7 @@ struct gobi_data { uint32_t set_powered_id; enum wda_data_format data_format; bool using_mux : 1; + bool no_pass_through : 1; }; static void gobi_debug(const char *str, void *user_data) @@ -136,6 +139,11 @@ static int qmi_wwan_set_raw_ip(const char *interface, char value) return l_sysctl_set_char(value, QMI_WWAN_RAW_IP, interface); } +static int qmi_wwan_set_pass_through(const char *interface, char value) +{ + return l_sysctl_set_char(value, QMI_WWAN_PASS_THROUGH, interface); +} + /* * Probe the modem. The following modem properties are expected to be set * in order to initialize the driver properly: @@ -165,6 +173,9 @@ static int gobi_probe(struct ofono_modem *modem) uint8_t interface_number; int ifindex; const char *bus; + struct stat st; + _auto_(l_free) char *pass_through = NULL; + bool no_pass_through = false; DBG("%p", modem); @@ -189,10 +200,19 @@ static int gobi_probe(struct ofono_modem *modem) &interface_number) < 0) return -EINVAL; + pass_through = l_strdup_printf(QMI_WWAN_PASS_THROUGH, ifname); + if (stat(pass_through, &st) == -1) { + if (errno == ENOENT) + no_pass_through = true; + else + return -errno; + } + data = l_new(struct gobi_data, 1); data->main_net_ifindex = ifindex; l_strlcpy(data->main_net_name, ifname, sizeof(data->main_net_name)); data->interface_number = interface_number; + data->no_pass_through = no_pass_through; ofono_modem_set_data(modem, data); ofono_modem_set_capabilities(modem, OFONO_MODEM_CAPABILITY_LTE); @@ -504,7 +524,11 @@ static void create_wda_cb(struct qmi_service *service, void *user_data) } data->wda = service; - data->data_format = WDA_DATA_FORMAT_UNKNOWN + 1; + + if (data->no_pass_through) + data->data_format = WDA_DATA_FORMAT_802_3; + else + data->data_format = WDA_DATA_FORMAT_UNKNOWN + 1; if (!wda_get_data_format(data, &format)) goto error; @@ -604,6 +628,15 @@ static void init_powered_down_cb(int error, uint16_t type, DBG("Setting QMI_WWAN to 802.3 mode"); + /* Must set pass_through first, before toggling raw_ip */ + if (!data->no_pass_through) { + r = qmi_wwan_set_pass_through(data->main_net_name, 'N'); + if (r < 0) { + ofono_warn("Unable to reset pass_through"); + goto error; + } + } + r = qmi_wwan_set_raw_ip(data->main_net_name, 'N'); if (r < 0) { ofono_warn("Unable to reset raw_ip"); From patchwork Thu Nov 21 15:29: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: 13882098 Received: from mail-oa1-f49.google.com (mail-oa1-f49.google.com [209.85.160.49]) (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 852581DBB0C for ; Thu, 21 Nov 2024 15:29:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732202997; cv=none; b=hlJSxOWIwXbOTizUdRS6tFmBCBgoDVs+CSJHn2V+/cd4XWn8RzLx0AYrrebG/5oxW3VxBHbSLHvzOZ48VhV33VVxhiMB6/lvYheSAwFhgtZE25ONyIeuO95J0PALt5WijIc0Ao3OsLaCbVFNNdyiskSezYJz+xg17s/vBQ3JPbo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732202997; c=relaxed/simple; bh=K/mO8DXP5l66w9IrVuOZrcyki+7Ahgg27q3qLOsqCfo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qhRm5DkjPcJsonKPfS9/jps1wyTDVaDE9vvgF8bQUBqhlStyKmEdsTh0pJqMXKclpdbY37UV/iTUodrNlmaI5BdyMpUvJ9YvUXp2Pgd7Xhjzao2/tCuP7+TZWYEgTSGYEzyuNfPfIEUwfOk975rqJn3TF+vGWC2U4yXOHIGKGAU= 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=YBNHAQHy; arc=none smtp.client-ip=209.85.160.49 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="YBNHAQHy" Received: by mail-oa1-f49.google.com with SMTP id 586e51a60fabf-2969dc28d9eso685887fac.0 for ; Thu, 21 Nov 2024 07:29:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732202995; x=1732807795; 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=7pBvuTpliBIseJXNzlVg2WXf6PYRSRuFYxUuc4uQx1Q=; b=YBNHAQHy9crDuRJqNcdK9Buychn2IjQrH5uTg+gpEHAkGkQ61XtpQxx/RIk/fosJ26 D3vaJ4chtIeSbzH9BEdtBvL/PEMeO4M8CcBcyKTOZrBqko9Hl9MUGVlLeEPj3smbrME5 qyx7sSFnUNwOWXiT/maE9zhJpDeEXMzCxNdKltwEgAK3p9dS2dTkU64iNdY6/zz420Ap xwGatO6fxEKcKym/XxdANYmj60aV8hRODk82jB60JwOQ5A0StY2JBnC008m9yxdYYo50 9DsS1JlFYOKdl0aSFPwn35yCSpT09JayRGLY2gkdVeCmASBCkZAkEybATyg9fhiEAP+R n6Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732202995; x=1732807795; 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=7pBvuTpliBIseJXNzlVg2WXf6PYRSRuFYxUuc4uQx1Q=; b=TUfucRYDlejO+kzDL2SIjZANyxLA0Fo/dY1K5X6FBy+gbL1svvUV6itSubu5NY1jCq JXw9J4u938+lJqq0vQp61kKxON1phqm0mtOJLTPv4psYd5ietfQLYdPxdqw7oxJgrbhb kMhwMy93nDMRovzuRfcKQJGCv47Qm84HrOwtjLf6nxn7KulijwTrvGH4nlwcaLkgOmad b2BrYHdlwnJx7SGkRAlaQVWwM2rtW0x7O9Dmsd6GYQWlBmLiWA0gEOKVFBFov6TlsNsW JS/UVlzf8TtOmjek/wBp62wd1s/1RM8W64Krhoe5TPO6wXMaLjozTCmr+x/493DQriNN uIfQ== X-Gm-Message-State: AOJu0Yyt5Bmnvibgj/u8lJyEqLGXt09f4o73sFfc/ceGsMVwDl9uPeOF sfgFh0QOAV6yD5olCKZiYU5TgGLeCXuW6r1e3URxvXP4a1LhAtQwqRnwgQ== X-Gm-Gg: ASbGncsJm6WLucsvhAjhA3rhJSCteNzUTPLQAG658h0WIUfCkBNVgndzHdQO0nsY4EG +V2r2w3JD0T0+8DavLO7TAa7tRZrp55ym5RoGHLzSK1t0jXkf4D6XdfcrDVzcZjStvSlF+wne30 vOPsyVLZ1raOtbE3NEXT+CCNc4vQLcL4RW08oSmBsOWMkHa2qeWaMRU1YprZ/dSvWlqhD83oRtJ JYEVTBwHvoeX3j3vlWo4GfQJdQKr/ie9KkoriWkRFl5f0V8Hw8h9k6gL3/ypFU5N/3L9xEh7osK zrDQahI29cTBcixm2jCtu/UK X-Google-Smtp-Source: AGHT+IEynh2Ov6JLBeAfScZOpBE60flhTfs6mN9FcJ8Z6Ny87D5x0ly5mJN/OWsRv+h70h3hH0I6FA== X-Received: by 2002:a05:6870:b4a3:b0:287:32f7:ef42 with SMTP id 586e51a60fabf-296d9ae3365mr7611883fac.16.1732202995310; Thu, 21 Nov 2024 07:29:55 -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 586e51a60fabf-29651ac5ff9sm4856831fac.42.2024.11.21.07.29.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Nov 2024 07:29:54 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 05/10] gobi: ensure Set Data Format changes were applied Date: Thu, 21 Nov 2024 09:29:33 -0600 Message-ID: <20241121152949.56962-5-denkenz@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241121152949.56962-1-denkenz@gmail.com> References: <20241121152949.56962-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Some firmware accept Set Data Format command, but do not actually honor it. For example Quectel RM502Q happily accepts being set to 802.3 link-layer protocol, but doesn't actually change it. Try to detect this case and handle it appropriately. --- plugins/gobi.c | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/plugins/gobi.c b/plugins/gobi.c index 87b54ae05f17..321a2ae0bca7 100644 --- a/plugins/gobi.c +++ b/plugins/gobi.c @@ -461,6 +461,33 @@ error: shutdown_device(modem); } +/* + * Some firmware accepts the Set Data Format command successfully, but doesn't + * change anything. Try to detect and warn if that happens + */ +static int compare_data_format(struct gobi_data *data, struct qmi_result *result) +{ + struct qmi_wda_data_format expected; + struct qmi_wda_data_format actual; + int r; + + if (!wda_get_data_format(data, &expected)) + return -EPROTO; + + r = qmi_wda_parse_data_format(result, &actual); + if (r < 0) + return -EBADMSG; + + if (expected.ll_protocol != actual.ll_protocol || + expected.ul_aggregation_protocol != + actual.ul_aggregation_protocol || + expected.dl_aggregation_protocol != + actual.dl_aggregation_protocol) + return -EBADE; + + return 0; +} + static void set_data_format_cb(struct qmi_result *result, void *user_data) { struct ofono_modem *modem = user_data; @@ -473,8 +500,12 @@ static void set_data_format_cb(struct qmi_result *result, void *user_data) DBG(""); - if (!qmi_result_set_error(result, NULL)) - goto done; + if (!qmi_result_set_error(result, NULL)) { + if (!compare_data_format(data, result)) + goto done; + + ofono_error("Setting Data Format had no effect"); + } if (data->data_format == WDA_DATA_FORMAT_802_3) goto error; From patchwork Thu Nov 21 15:29:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13882100 Received: from mail-oa1-f51.google.com (mail-oa1-f51.google.com [209.85.160.51]) (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 26D2D1DACB8 for ; Thu, 21 Nov 2024 15:29:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732202999; cv=none; b=YAV9NaOv800DKaaeIxWmwk7QOznOPTtE3Z2EOwORcpCv1WayTSp3vz9GBsflvRxb/FFMSAU3Oy/qpRxE659ArIEzfYqCJlJZN41Nndh8MJKPKM6gUEOGQB+oizehaZOjNgv620hztktiPyiBZ4S7ny7M31nZm3s4usuOi0I3McQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732202999; c=relaxed/simple; bh=jY/wHj5U3dVQgXSkp/y0W5yZpsZ/+GfYTXyDcNS6tLo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VCSWSslQTHGWIyAWnxL+wpjHXT69mAp/6W2m0VK9osuQL8tkkIPoyI17MaO1tiJXk+Ie6tEEN5NNahFfk4H04HTznjYCQVnfcdJBdWIkczD6BF98nG8kRZUUpr6dQH3+rYMgmSZHbwhJH15oAmxQBNDIUBMUrJof/jNDIUmsIH0= 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=fD1zhy95; arc=none smtp.client-ip=209.85.160.51 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="fD1zhy95" Received: by mail-oa1-f51.google.com with SMTP id 586e51a60fabf-29678315c06so577679fac.1 for ; Thu, 21 Nov 2024 07:29:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732202996; x=1732807796; 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=PHLrc/XyOgHIIittARvCLdeNYWmDnYH7A/qXwEn8zdE=; b=fD1zhy95zW3CWBluxcPJnLvWW7PYOdFQzoEbxOl9z9wllbpJjo2EH/XU9atDM3iK86 2qj8yyKkHaA51QRdRftbf3/GB1fUcu0RNDMb7GOVmo/FAOLLBgFBy1OAeBcRmKBJBPty +eqP7wPtq1uJb8VEU6DEO1U4W7DLzvtXuVTdYBLlfXgwkJ9Jh0XLmcMx1nX5SEjTx4tl 5w24VHX3IafXaSqwlzYcyvGnYfqM3/jp2PdNzDNUWyhxmVL+FhZPBnWcJE3V8Ni+8uNz 5wR4LcBUT6QmXX6l09s8pVCw/gXGiPfayHLRbGESftE2MAqatQjskt8440KnxUY0d9y6 quZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732202996; x=1732807796; 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=PHLrc/XyOgHIIittARvCLdeNYWmDnYH7A/qXwEn8zdE=; b=b5XTi6Erw5mbDkAgeTBvQBvungMFalLi+yPEexyWMbKZv/QcMR3roz72zNiU0syPwT v+ryV7FZlf3h6JRKg0jExUNfrMA/A+AfNMe5F0SfKi2QBVD4BhRdE/mEnnDAIDdTzqrz j0IOB4b0KH4zucII2GGYr4Fq06HaD4iOYNxhZ9cqwvpo+K/iUtRvDqevuxWTSnQqA76L i4DjAvXSVVX8mId5rqBoF7fAI/ZdByA04rXC52tHvXw2Fq64EHJeZA+mwSlzjsOMiqnE MYRzGlhqZpzfmDt+RdpgLU1DVdfDm7MVxuyTNZWZx/eUKap9aiSTkbn9WOB7N49K/mbr oeug== X-Gm-Message-State: AOJu0YwJja1fT6DaEhp4iqYS46z825fOpDfGzhc4MucL/OdyCZED/rOO 8PZdqbLsbYr9TEuBSz86CZiuIs1mF1TvcF/eW0i0eh5nJ2B/qOd9FR7ZbA== X-Gm-Gg: ASbGncsf57mUJUD2IiTfcXZP4T3u79EHsKd4j3liZn1xJNwf/fJv0V+dm/GgHe1qkKT WeVcj+dSASoT6dvaEuFQIfW6cUGqairIbqfdNAqJ8Fy6NeJL+14Uoqcxix80qRsHDNBkr//5yDt 6cbNvy4htapui0ikBzCeOKehHCWFEmU0yEFLklYElOB01OQ9TOgqrz9kjLayrR6PQDsb7mCrwsN LMl1u1SZyj0UzjNyjv5qqwqyLoZ9zAXyF8pHWBR0xNecasFMipgSS8vgOdKTHunrBEXkQxeYyhb OAo3Sg+QJnHRQQUye8m47XyV X-Google-Smtp-Source: AGHT+IFklczpuOIse/YOq83/gmoQFgWlwKeO/hRg0Fh8xhkbdcVFDzTXDzBn1pKiyHLCp6PUemX6qw== X-Received: by 2002:a05:6871:e7c5:b0:270:64ed:c125 with SMTP id 586e51a60fabf-296d9b84f56mr8041515fac.16.1732202996085; Thu, 21 Nov 2024 07:29:56 -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 586e51a60fabf-29651ac5ff9sm4856831fac.42.2024.11.21.07.29.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Nov 2024 07:29:55 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 06/10] gobi: Set MTU when initializing QMI_WWAN Date: Thu, 21 Nov 2024 09:29:34 -0600 Message-ID: <20241121152949.56962-6-denkenz@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241121152949.56962-1-denkenz@gmail.com> References: <20241121152949.56962-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 MTU on cellular networks is generally smaller than the default 1500 MTU used by ethernet. Most network providers recommend a particular setting, typically around ~1430 bytes. The recommended MTU should also be provided by the network when the context is activated. On AT command modems, the setting can be read using +CGDCONTRDP. oFono does not currently manage MTU settings; setup a conservative 1400 byte MTU to bootstrap. --- plugins/gobi.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 57 insertions(+), 3 deletions(-) diff --git a/plugins/gobi.c b/plugins/gobi.c index 321a2ae0bca7..cb53ec582385 100644 --- a/plugins/gobi.c +++ b/plugins/gobi.c @@ -58,6 +58,7 @@ #define GOBI_WDA (1 << 7) #define MAX_CONTEXTS 4 +#define DEFAULT_MTU 1400 #define QMI_WWAN_RAW_IP "/sys/class/net/%s/qmi/raw_ip" #define QMI_WWAN_PASS_THROUGH "/sys/class/net/%s/qmi/pass_through" @@ -98,6 +99,7 @@ struct gobi_data { uint8_t interface_number; uint32_t max_aggregation_size; uint32_t set_powered_id; + uint32_t set_mtu_id; enum wda_data_format data_format; bool using_mux : 1; bool no_pass_through : 1; @@ -134,6 +136,24 @@ static bool wda_get_data_format(struct gobi_data *data, return false; } +static int wda_data_format_to_mtu(enum wda_data_format format, uint32_t *out_mtu) +{ + uint32_t mtu; + + switch (format) { + case WDA_DATA_FORMAT_802_3: + mtu = DEFAULT_MTU; + break; + default: + return -ENOTSUP; + } + + if (out_mtu) + *out_mtu = mtu; + + return 0; +} + static int qmi_wwan_set_raw_ip(const char *interface, char value) { return l_sysctl_set_char(value, QMI_WWAN_RAW_IP, interface); @@ -269,6 +289,11 @@ static void gobi_remove(struct ofono_modem *modem) data->set_powered_id = 0; } + if (data->set_mtu_id) { + l_netlink_cancel(l_rtnl_get(), data->set_mtu_id); + data->set_mtu_id = 0; + } + cleanup_services(data); qmi_qmux_device_free(data->device); @@ -461,6 +486,29 @@ error: shutdown_device(modem); } +static void enable_set_mtu_cb(int error, uint16_t type, + const void *msg, uint32_t len, + void *user_data) +{ + struct ofono_modem *modem = user_data; + struct gobi_data *data = ofono_modem_get_data(modem); + + DBG("error: %d", error); + + data->set_mtu_id = 0; + + if (error) + goto error; + + DBG("Requesting services"); + + if (qmi_qmux_device_create_client(data->device, QMI_SERVICE_DMS, + request_service_cb, modem, NULL) > 0) + return; +error: + shutdown_device(modem); +} + /* * Some firmware accepts the Set Data Format command successfully, but doesn't * change anything. Try to detect and warn if that happens @@ -497,6 +545,7 @@ static void set_data_format_cb(struct qmi_result *result, void *user_data) .interface_number = data->interface_number, }; struct qmi_wda_data_format format; + uint32_t mtu; DBG(""); @@ -523,10 +572,15 @@ static void set_data_format_cb(struct qmi_result *result, void *user_data) goto error; done: - DBG("Set Data Format succeeded, proceeding to create services"); + DBG("Set Data Format succeeded, try to set MTU..."); - if (qmi_qmux_device_create_client(data->device, QMI_SERVICE_DMS, - request_service_cb, modem, NULL) > 0) + if (L_WARN_ON(wda_data_format_to_mtu(data->data_format, &mtu) < 0)) + goto error; + + data->set_mtu_id = l_rtnl_link_set_mtu(l_rtnl_get(), + data->main_net_ifindex, mtu, + enable_set_mtu_cb, modem, NULL); + if (data->set_mtu_id) return; error: shutdown_device(modem); From patchwork Thu Nov 21 15:29:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13882099 Received: from mail-oa1-f46.google.com (mail-oa1-f46.google.com [209.85.160.46]) (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 297E51DBB0C for ; Thu, 21 Nov 2024 15:29:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732202999; cv=none; b=bkT5zjQcgXooXF3lRRgJRC3gVUs5RgmdelFq6sojZ9rtiGiBu9d+HzL//CMe6Pul2dwkFTYI0zsBY7q9O9lMk3O+17OVkATwmmdefPaVytl2jXlhzxIM+JyOH8d4EX3DacMyw2JBUo40BrkdIUoiMBlKD469B07OyjmDFsfkG3Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732202999; c=relaxed/simple; bh=jHJtBN7tkMY4JC//mjCTgudJ0dOjinrjj4fP8n7TlJs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=U2xkEJeR6m3lTk5F9TgXzP4L7IcsA+9d1L2Gi5qbCm9hnkk9U8fYSKI0jCdaJlfOaKylEqhcp4kQ9PIOk9oktiaCkH9HVw339PgpkHrbSapsluY8efip6OlRqaZ02sHsYW9q55Pq2TJscfOuQULj8aGB+z4uo9EYfnLse6UUVMc= 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=CjZA2duF; arc=none smtp.client-ip=209.85.160.46 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="CjZA2duF" Received: by mail-oa1-f46.google.com with SMTP id 586e51a60fabf-295d27f9fc9so824560fac.0 for ; Thu, 21 Nov 2024 07:29:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732202997; x=1732807797; 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=2Ep1rTPQ/w023Pu6vGt8sVkI4wCxQQ4L5eMNM+GvPrY=; b=CjZA2duFHma2vCDn/pHA60PGbBX/hkHbnO9AYsVhJaowbr6a1cyDI5j34tYha0zg/J n4pSteSuqGFbu4mvfKOxqUPPgW3puqLlJw4GLuX/wh1Kk2hFlUGqlS3Gs+8BMFd5b6Gj 0+/hIQRcCSjmn8QJu95j8MId40Lngbv813RWuVhhh4NJAVHih0HnbBNWLkBY+kjJ2D/P yk8EzEQJVfHNTNCLtIM4XiAZ08pWrYM2pXJ4WAQ6uzJrgutGwtwe/x0MrokAt00FLmdb 2/t9kSGBGKG+0D8MkdgngFLLh5FuqTBDXO2SdXrSw2/wsQBeDwkrbEEohihNytByVuPi TvNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732202997; x=1732807797; 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=2Ep1rTPQ/w023Pu6vGt8sVkI4wCxQQ4L5eMNM+GvPrY=; b=Z12FYmzkdhnq0PTqedRVrr5iyyOYieAe/WbJ3J/8zhR3P7yb7ChB9H5Q/ysYHcLsEY L/ubLyjbyrh8gSVeoiiExbAzaOHFFizh82ebuFjGbZpBfYqEKwwnKuhVAiGWy8SnS+Tb 1y4PKtnG5J/WPR2L9BySvuRJtA1jFpd0pt4cj3J89Tx9MqGy3mQ8eMkIpRUd8wjTBuOS UUxnWdgLXWV5A/sE2SPMY+UnWSxE3UkZWBx7xqK/oCfmr+egPBBF5yaK0zL0IWMzjIlG o7x6u2Lv0YD2jKy2E7NBhzmutIoxAAwoVxtoDP8ymbMFbdRJ6CGxBIrpTYoRSHaH6M44 vbKA== X-Gm-Message-State: AOJu0YzKoKmh3uKBH1WxJiU0IWUjk1FSm7CNTaLwj42cfGEojPqptvkV vNkQX5BBqrz1ptiD4PDtzfp0TA/RupQoW2FjhKyjP8EHhKLdqbAkBk2kgw== X-Gm-Gg: ASbGnctEdc1o2nzUjG32oc9ooM3yK3Pu2GwDxtAD/lB32L/HZaFX6Fnr4b4qOl2SOa4 AFUj4W6f3BTUIkvxd0U+FsFdKA2RJksyTkVzkxzJ5/ZcuS0t5q80HfzBE6BnCNBrkxXUAwVp06F Rt6LflfQCYyEZRVQ+9Sp14q+d5j3lnke8BjnYq46C2GuSvj8Cw6VQPOXRxZZy/JJ5NYck1ZN6lT G5a6wZ/2w1a0WAwtaRlpGCikwfLp4bsU7SFTIW5fuzrpAatB5j2pE2zdE+C6KOoI+26WJpbse5D c243iArK/QcOKADDLiLrK8cY X-Google-Smtp-Source: AGHT+IE7i5iIZeMPlcPj1WNn3wXnn+u9v2l1YHWoABkDTqhUZC3z5wtVmy0yEAyaiJ6rIXvP0JZNDA== X-Received: by 2002:a05:6870:2b09:b0:296:88d2:6428 with SMTP id 586e51a60fabf-296d9b972c2mr7788649fac.16.1732202996978; Thu, 21 Nov 2024 07:29:56 -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 586e51a60fabf-29651ac5ff9sm4856831fac.42.2024.11.21.07.29.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Nov 2024 07:29:56 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 07/10] gobi: Support RAW_IP configuration Date: Thu, 21 Nov 2024 09:29:35 -0600 Message-ID: <20241121152949.56962-7-denkenz@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241121152949.56962-1-denkenz@gmail.com> References: <20241121152949.56962-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Most newer QMI modem firmware only support RAW_IP based configurations. This is a more efficient data path since 802.3 headers do not need to be emulated. Support this data format by configuring the 'raw_ip' setting on QMI_WWAN accordingly. --- plugins/gobi.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/plugins/gobi.c b/plugins/gobi.c index cb53ec582385..111ddd3464fe 100644 --- a/plugins/gobi.c +++ b/plugins/gobi.c @@ -65,6 +65,7 @@ enum wda_data_format { WDA_DATA_FORMAT_UNKNOWN = 0, + WDA_DATA_FORMAT_RAW_IP, WDA_DATA_FORMAT_802_3, /* Last, most compatible legacy fallback */ }; @@ -133,7 +134,10 @@ static bool wda_get_data_format(struct gobi_data *data, return true; } - return false; + /* For everything except 802.3, use RAW_IP */ + out_format->ll_protocol = QMI_WDA_DATA_LINK_PROTOCOL_RAW_IP; + + return true; } static int wda_data_format_to_mtu(enum wda_data_format format, uint32_t *out_mtu) @@ -142,6 +146,7 @@ static int wda_data_format_to_mtu(enum wda_data_format format, uint32_t *out_mtu switch (format) { case WDA_DATA_FORMAT_802_3: + case WDA_DATA_FORMAT_RAW_IP: mtu = DEFAULT_MTU; break; default: @@ -500,6 +505,15 @@ static void enable_set_mtu_cb(int error, uint16_t type, if (error) goto error; + if (data->data_format == WDA_DATA_FORMAT_RAW_IP) { + DBG("Setting QMI WWAN to raw_ip"); + + if (qmi_wwan_set_raw_ip(data->main_net_name, 'Y') < 0) { + ofono_warn("Unable to set raw_ip"); + goto error; + } + } + DBG("Requesting services"); if (qmi_qmux_device_create_client(data->device, QMI_SERVICE_DMS, From patchwork Thu Nov 21 15:29:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13882101 Received: from mail-oa1-f48.google.com (mail-oa1-f48.google.com [209.85.160.48]) (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 2989B1DBB13 for ; Thu, 21 Nov 2024 15:29:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732203000; cv=none; b=jthNd0dhrgsk5ob2SXutMfzKxKqm461UMZWLY0fGnXkl+1EXHsqSGUcjIggH8avLSiOHJBKBa2Clt+recmqGal6Hz2H0K+mimyP1D6G9BDs70jPAITPIhNgNeLIgi8PifOsxNLEuaeM3EXT2DPn3FarXrTEijgaLmIauxJnntCk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732203000; c=relaxed/simple; bh=mPD0504gBx1l+cPecc6GnM39mSnPgmSFttPXqr1A7CU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AaxLUdFzgTAQVObHpmSFSWdO9mBNlDiK4TIQSxCpdVcQG8cOfaIPuoYhtB2VQzxdhlyINWACX9YRcREvo2oIwE7oclSGnZJzrI7qv1p5R4kgW0/1yopVZBsaTYSwbwiQtK4vZbXCEJ9n/BrPpLugPgx0OoX34aJv9Rq/EX8lhLI= 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=c25+HXx6; arc=none smtp.client-ip=209.85.160.48 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="c25+HXx6" Received: by mail-oa1-f48.google.com with SMTP id 586e51a60fabf-296b567bc30so354780fac.2 for ; Thu, 21 Nov 2024 07:29:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732202998; x=1732807798; 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=L++HG8+vyI9/naIo65G0NsZ7CozBCIgZRKJU3NHzqK4=; b=c25+HXx6FiwVGOUpUf8Nemkyh74jUa2JSiyaVB2BcG9a4YeSXFJmjjCxffUoqf4Pqx YU/J1hgpe9g99Ye8mLkXmv0e4VxZWO2jXC8rylPynHrRoK/K5T2L7oT+ecqFGRV7/ec4 9Z0V/0n8oIW/2o7Rc/sxJEnzfUwZ77l0XUmnLASSa6iUrx186iMTg63E4qon3zwGJa20 vDDKv+ujxg14nka4nrcPy0k4TpEx9clMU8e2C2WsvUwPUTMz1ieDCd3hZ6NTr/53ZcvK VbFgKedE3YER0VKB+xtNyYbSHXIpxOhBaXpiXpJIUmb8L3GnB5Jz9YE42PkIT/Zuii75 84vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732202998; x=1732807798; 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=L++HG8+vyI9/naIo65G0NsZ7CozBCIgZRKJU3NHzqK4=; b=QewL9e+mccB+QsYmVckeYlOB2YHjbacszRigR69hEms1E+3WlhgVMoBxHMoNDiwKWc PcyeRe/3AgIQcMlZFab/TPiAtioSxHwFutMs8ziguqH4e0GcX+ijYP4bRWrIW0pl7SkR wQbPzIF7STXBS4UFHlX0KeL46azB8RonQkBz/NPUi/Hi1ZG7qU74aVvkJ0MljsoNivxW lWExLYLAsoUlWxaRiDoXp/Ez3wJ1gS7Bos7wuasyXhVmHIRBNxDs1Vv3EUodPc2wDNP5 qXlUGZpxun97rd+/lfy/o9gxnDDanG7LtjZStg/R7eFrNH6KkEaX3+zsiAmMzbwpDb3M XZHA== X-Gm-Message-State: AOJu0YxZFPXiKJHr8TONVDqr1waC1OE3xa62FI0GUdBJaXz/aPAu6Ux1 g+2PTAwHZUjdoxRLgXDekT15+Cs24Q+X9sJ0xQoxrwp6EdOaGxjwDZGUeA== X-Gm-Gg: ASbGncv8Ttzj3Vdjsce0++jvgB7X/kTIfuc15NC3XlAo/Jpv6lS5LCLT6L/7T9TMRFi nuQiB3AVNZ+jQb86XoVzKUewDVPYUc3uCEAJQJGkgp4KFFk7VWzRPpmsFXbpcZM6oodk2r1p+pI zAJEKwiW1+Bx9JH1A5YIhfE9GMlI/rKWUZJ5zrTWWYbYenI1oab1VVYS6Er2ntkJiTqavZ4vbHx I4RAcbXT6cFVni5kaqQRJ8EaWaRD2NTIAcLLWETF+Bs2Z82xMoHUsKiPR+HBrqKA2FvLx0DnB0M QfKbgFeaVJaTqZZ5DIZZRcEU X-Google-Smtp-Source: AGHT+IFpu4Hme5Wb6G5cC7+J4tdtd6SYpAeILqdDcgOmFSb7b2Eh47zFcKyJkM5gdveGCkJt6kopMw== X-Received: by 2002:a05:6870:5b0b:b0:296:de5e:569b with SMTP id 586e51a60fabf-296de5e58demr5491765fac.18.1732202997962; Thu, 21 Nov 2024 07:29:57 -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 586e51a60fabf-29651ac5ff9sm4856831fac.42.2024.11.21.07.29.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Nov 2024 07:29:57 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 08/10] gobi: Add support for multiple active contexts Date: Thu, 21 Nov 2024 09:29:36 -0600 Message-ID: <20241121152949.56962-8-denkenz@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241121152949.56962-1-denkenz@gmail.com> References: <20241121152949.56962-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add support for multiple contexts based on qmi_wwan 'passthrough' + rmnet combination. This is a newer and more flexible approach compared to the legacy qmi_wwan 'add_mux' / 'del_mux' design. Multiple contexts are enabled as follows: - If the device supports passthrough, attempt to set the modem to use QMAPv5 for both downlink and uplink aggregation. - If successful, request rmnet module to create multiple rmnet network interfaces to use for each context / PDN that will be simultaneously active - Request WDS service handles for each rmnet device created With the above setup, the main network interface MTU is changed to 16384, which is the maximum supported by the current qmi_wwan driver. Note that modems might be capable of larger aggregation sizes, particularly for the download direction. However, such sizes will exceed the maximum URB (corresponding to the MTU) which qmi_wwan supports. --- plugins/gobi.c | 140 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 113 insertions(+), 27 deletions(-) diff --git a/plugins/gobi.c b/plugins/gobi.c index 111ddd3464fe..027aa91d6ade 100644 --- a/plugins/gobi.c +++ b/plugins/gobi.c @@ -47,6 +47,7 @@ #include #include #include +#include "src/rmnet.h" #define GOBI_DMS (1 << 0) #define GOBI_NAS (1 << 1) @@ -59,12 +60,15 @@ #define MAX_CONTEXTS 4 #define DEFAULT_MTU 1400 +#define RMNET_MAX_MTU 16384 +#define DEFAULT_DL_DATAGRAMS 32 #define QMI_WWAN_RAW_IP "/sys/class/net/%s/qmi/raw_ip" #define QMI_WWAN_PASS_THROUGH "/sys/class/net/%s/qmi/pass_through" enum wda_data_format { WDA_DATA_FORMAT_UNKNOWN = 0, + WDA_DATA_FORMAT_RMNET_QMAP5, WDA_DATA_FORMAT_RAW_IP, WDA_DATA_FORMAT_802_3, /* Last, most compatible legacy fallback */ }; @@ -88,12 +92,14 @@ struct gobi_data { struct qmi_service *wds_ipv4; struct qmi_service *wds_ipv6; } context_services[MAX_CONTEXTS]; + struct rmnet_ifinfo rmnet_interfaces[MAX_CONTEXTS]; + uint8_t n_premux; + int rmnet_id; struct service_request service_requests[8 + MAX_CONTEXTS * 2]; int cur_service_request; 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]; @@ -102,7 +108,6 @@ struct gobi_data { uint32_t set_powered_id; uint32_t set_mtu_id; enum wda_data_format data_format; - bool using_mux : 1; bool no_pass_through : 1; }; @@ -137,6 +142,19 @@ static bool wda_get_data_format(struct gobi_data *data, /* For everything except 802.3, use RAW_IP */ out_format->ll_protocol = QMI_WDA_DATA_LINK_PROTOCOL_RAW_IP; + if (data->data_format == WDA_DATA_FORMAT_RAW_IP) + goto done; + + out_format->dl_max_datagrams = DEFAULT_DL_DATAGRAMS; + out_format->dl_max_size = data->max_aggregation_size; + + if (data->data_format == WDA_DATA_FORMAT_RMNET_QMAP5) { + out_format->ul_aggregation_protocol = + QMI_WDA_AGGREGATION_PROTOCOL_QMAPV5; + out_format->dl_aggregation_protocol = + QMI_WDA_AGGREGATION_PROTOCOL_QMAPV5; + } +done: return true; } @@ -149,6 +167,9 @@ static int wda_data_format_to_mtu(enum wda_data_format format, uint32_t *out_mtu case WDA_DATA_FORMAT_RAW_IP: mtu = DEFAULT_MTU; break; + case WDA_DATA_FORMAT_RMNET_QMAP5: + mtu = RMNET_MAX_MTU; + break; default: return -ENOTSUP; } @@ -238,6 +259,8 @@ static int gobi_probe(struct ofono_modem *modem) l_strlcpy(data->main_net_name, ifname, sizeof(data->main_net_name)); data->interface_number = interface_number; data->no_pass_through = no_pass_through; + /* See drivers/net/ethernet/qualcomm/rmnet/rmnet_private.h */ + data->max_aggregation_size = 16384; ofono_modem_set_data(modem, data); ofono_modem_set_capabilities(modem, OFONO_MODEM_CAPABILITY_LTE); @@ -299,6 +322,11 @@ static void gobi_remove(struct ofono_modem *modem) data->set_mtu_id = 0; } + if (data->rmnet_id) { + rmnet_cancel(data->rmnet_id); + data->rmnet_id = 0; + } + cleanup_services(data); qmi_qmux_device_free(data->device); @@ -354,6 +382,14 @@ static void shutdown_device(struct ofono_modem *modem) cleanup_services(data); + if (!l_memeqzero(data->rmnet_interfaces, + sizeof(data->rmnet_interfaces))) { + rmnet_del_interfaces(data->n_premux, data->rmnet_interfaces); + data->n_premux = 0; + memset(data->rmnet_interfaces, 0, + sizeof(data->rmnet_interfaces)); + } + if (qmi_qmux_device_shutdown(data->device, shutdown_cb, modem, NULL) < 0) shutdown_cb(modem); } @@ -491,6 +527,55 @@ error: shutdown_device(modem); } +static uint32_t start_service_requests(struct ofono_modem *modem) +{ + struct gobi_data *data = ofono_modem_get_data(modem); + unsigned int i; + + DBG(""); + + 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); + } + + return qmi_qmux_device_create_client(data->device, QMI_SERVICE_DMS, + request_service_cb, modem, NULL); +} + +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 gobi_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; + + if (start_service_requests(modem) > 0) + return; +error: + shutdown_device(modem); +} + static void enable_set_mtu_cb(int error, uint16_t type, const void *msg, uint32_t len, void *user_data) @@ -505,7 +590,7 @@ static void enable_set_mtu_cb(int error, uint16_t type, if (error) goto error; - if (data->data_format == WDA_DATA_FORMAT_RAW_IP) { + if (data->data_format != WDA_DATA_FORMAT_802_3) { DBG("Setting QMI WWAN to raw_ip"); if (qmi_wwan_set_raw_ip(data->main_net_name, 'Y') < 0) { @@ -514,10 +599,26 @@ static void enable_set_mtu_cb(int error, uint16_t type, } } - DBG("Requesting services"); + if (L_IN_SET(data->data_format, WDA_DATA_FORMAT_RMNET_QMAP5)) { + DBG("Setting QMI WWAN to pass_through"); + + if (qmi_wwan_set_pass_through(data->main_net_name, 'Y') < 0) { + ofono_error("Unable to set pass_through"); + goto error; + } + + data->rmnet_id = rmnet_get_interfaces(data->main_net_ifindex, + MAX_CONTEXTS, + rmnet_get_interfaces_cb, + modem, NULL); + if (data->rmnet_id > 0) + return; - if (qmi_qmux_device_create_client(data->device, QMI_SERVICE_DMS, - request_service_cb, modem, NULL) > 0) + ofono_error("Unable to request RMNet interfaces"); + goto error; + } + + if (start_service_requests(modem) > 0) return; error: shutdown_device(modem); @@ -645,7 +746,6 @@ 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(""); @@ -695,13 +795,6 @@ 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_WDA, create_wda_cb, modem, NULL)) return; @@ -910,7 +1003,7 @@ static void gobi_set_online(struct ofono_modem *modem, ofono_bool_t online, l_netlink_command_func_t powered_cb; DBG("%p %s using_mux: %s", modem, online ? "online" : "offline", - data->using_mux ? "yes" : "no"); + data->n_premux ? "yes" : "no"); cbd->user = data; @@ -919,7 +1012,7 @@ static void gobi_set_online(struct ofono_modem *modem, ofono_bool_t online, else powered_cb = powered_down_cb; - if (!data->using_mux) { + if (!data->n_premux) { powered_cb(0, 0, NULL, 0, cbd); cb_data_unref(cbd); return; @@ -1000,14 +1093,10 @@ static void gobi_setup_gprs(struct ofono_modem *modem) 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; - const char *interface; - char buf[256]; - int mux_id; - - sprintf(buf, "PremuxInterface%dMuxId", i + 1); - mux_id = ofono_modem_get_integer(modem, buf); + struct rmnet_ifinfo *ifinfo = data->rmnet_interfaces + i; - gc = ofono_gprs_context_create(modem, 0, "qmimodem", mux_id, + gc = ofono_gprs_context_create(modem, 0, "qmimodem", + ifinfo->mux_id, qmi_service_clone(ipv4), qmi_service_clone(ipv6)); @@ -1017,11 +1106,8 @@ static void gobi_setup_gprs(struct ofono_modem *modem) continue; } - sprintf(buf, "PremuxInterface%d", i + 1); - interface = ofono_modem_get_string(modem, buf); - ofono_gprs_add_context(gprs, gc); - ofono_gprs_context_set_interface(gc, interface); + ofono_gprs_context_set_interface(gc, ifinfo->ifname); } } From patchwork Thu Nov 21 15:29:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13882102 Received: from mail-oa1-f50.google.com (mail-oa1-f50.google.com [209.85.160.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 088EC1DBB0C for ; Thu, 21 Nov 2024 15:29:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732203001; cv=none; b=YRfeEj9XhPzWGb4yj34AzO0083CJqmgholYekNO+oNpP2q4IWSh7lJczToi1TAQoQ/GumtQsG95avcJ0UsVTThxjIcBqf+Ro35c8pracH1hBmZTdtq1yGXG606nSLF86IrPLc0pIQhTztRM1OaZexbFhOFX1LFA5NXRzwPvbHXs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732203001; c=relaxed/simple; bh=+56cwjOCGqAJQ6m6XG5yU9SuwexjNDh8KBphcx+vT6o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EB552rSJNKBNfToqeH+Cw7splhm5cqnb7hozM5HN5szdZxhwngXgBxVhGZajD5iUPjiH0idO6rurlorUnlXJMzBnl63Bg0e4qDWLYfP3oS26uR+gmNWCXG+9r+5FcLqZ2m5UOL83VBz6W9OZd0YFWiZxcg8raqHcdiB75DoeIH0= 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=Byt1Q8Zj; arc=none smtp.client-ip=209.85.160.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="Byt1Q8Zj" Received: by mail-oa1-f50.google.com with SMTP id 586e51a60fabf-2965e65ce89so692420fac.3 for ; Thu, 21 Nov 2024 07:29:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732202999; x=1732807799; 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=5WAvHTKoCbo/9lNNRfkJ6qV4t0tbUTtEBytA+LmA3UQ=; b=Byt1Q8ZjLBCTGcqVRQWkvR8ZHVUU/wn3rmt8Y7tqvAtGqF0wZuM/rHfdTd1iUqMlKk yxjHt7YJCZi53dhV1H2pgnVp39PNJNy/TLQ6DyvlwrGfKDxxOAmOZQinRRTPYz6NGy3E HtbNsuX+ovEqq6SdTTK3xlIdyDGZjGOCbJrm/3khGZrMtpsogZxvPeCIhIOG1HsS8HS3 rac4M2l8jZLI2duVk0KlJtqssh4UJOpbfJcZTRu0xQebsxILOD6kk3bMECXW9QW5/WBE irduLm1FsL8RPLmEAybh+B9Gd3jyrFbdaUvXaP6v+8yDRizxW0nVzzmJj8LB+WPZp5HM zEAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732202999; x=1732807799; 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=5WAvHTKoCbo/9lNNRfkJ6qV4t0tbUTtEBytA+LmA3UQ=; b=VcFPuC4j+r1ORBidKWqTd5T0lLtnxfv/GzXV57nZajR1zKEE+fl1WpxDT/voTZdG3K kO19BT7CAjVNc/S6lXbfvupddwN99UYqezr1sXZYevKUSkW08Ntjkcx8zNHsoM4zKtay aC7IY7T+cCyszyP0FgUVJSwFW53EMwC7iNqby4Jq+xCMG5yuDXBaSGNETTQcDXlX6whF kiSHxNSm3b5HpURteht6CrWlhOsMPTO/BqI5EWxLmwh1um1SB/x2N4wDZBRLUkw7jZgg /kJchgr17ZLfF70ZgpCA3UhFjioG+aDbxwPwebm9M55ovauP437dwdtwD1XADOICy5/j jpfg== X-Gm-Message-State: AOJu0Yyb9BszV0xtWKL7TTmwjVu974obKqKlRvnwxbQL1FbOLju7SWMy hAT/lPOsvavqZahb2IRmZQExgZGoP2T0dE7HXWYW33NnKXouw15wnglCJQ== X-Gm-Gg: ASbGncvfQNGEtnbpULrxai6noxaMtN/CWNVIvls/wYI5Hdq7Inlt4io1ddKaVITxUbv ZNXPFLRrhcQk+19Vj/iY7Xyw0ne87gymlDlqVR/GTryTEPaDsCb8vL3qzabdJFvqLMCFbr+JHBh R2ZYq7sqg8kvsLRkryPuqyv9D4iU3WvPsVP+tF2D5P22boTVjMAMrWCIdTxXLjDtaCkw6NxZyIN wNNSVc2/S8cUyWVwBHSs+4XlSSH7VarJZqcyiDUc4FJU86X7jT/y2coHq0LvLAwCESQ4xoYPgZv /UX9znbI4bB7qLaSTSrTp3X8 X-Google-Smtp-Source: AGHT+IGZTskXidZLEMM+sVPDkQxTnsrwVeWw/3WIXAqL1cBQdV/y+I/OLmta2I3FOWgmyfHpPwMKmA== X-Received: by 2002:a05:6871:3429:b0:296:e365:d169 with SMTP id 586e51a60fabf-296e366292dmr6027227fac.8.1732202999032; Thu, 21 Nov 2024 07:29:59 -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 586e51a60fabf-29651ac5ff9sm4856831fac.42.2024.11.21.07.29.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Nov 2024 07:29:58 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 09/10] qmimodem: wds: Add qmi_wds_ip_support_from_ofono Date: Thu, 21 Nov 2024 09:29:37 -0600 Message-ID: <20241121152949.56962-9-denkenz@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241121152949.56962-1-denkenz@gmail.com> References: <20241121152949.56962-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This is used to convert from ofono context type enumeration to QMI IP support enumeration reported by Get LTE Attach Parameters. --- drivers/qmimodem/wds.c | 14 ++++++++++++++ drivers/qmimodem/wds.h | 1 + 2 files changed, 15 insertions(+) diff --git a/drivers/qmimodem/wds.c b/drivers/qmimodem/wds.c index ced0c5e5308d..07c96d4fdc58 100644 --- a/drivers/qmimodem/wds.c +++ b/drivers/qmimodem/wds.c @@ -43,6 +43,20 @@ int qmi_wds_pdp_type_from_ofono(enum ofono_gprs_proto proto) return -ENOENT; } +int qmi_wds_ip_support_from_ofono(enum ofono_gprs_proto proto) +{ + switch (proto) { + case OFONO_GPRS_PROTO_IP: + return QMI_WDS_IP_SUPPORT_IPV4; + case OFONO_GPRS_PROTO_IPV6: + return QMI_WDS_IP_SUPPORT_IPV6; + case OFONO_GPRS_PROTO_IPV4V6: + return QMI_WDS_IP_SUPPORT_IPV4V6; + } + + return -ENOENT; +} + int qmi_wds_parse_data_system_status(const void *dss, uint16_t len) { const size_t network_info_size = sizeof(uint8_t) + 2 * sizeof(uint32_t); diff --git a/drivers/qmimodem/wds.h b/drivers/qmimodem/wds.h index 64a18aa6d86e..9343d1f83665 100644 --- a/drivers/qmimodem/wds.h +++ b/drivers/qmimodem/wds.h @@ -155,6 +155,7 @@ enum qmi_wds_command { int qmi_wds_auth_from_ofono(enum ofono_gprs_auth_method method); int qmi_wds_pdp_type_from_ofono(enum ofono_gprs_proto proto); +int qmi_wds_ip_support_from_ofono(enum ofono_gprs_proto proto); int qmi_wds_parse_data_system_status(const void *dss, uint16_t len); int qmi_wds_parse_extended_data_bearer_technology(const void *edbt, From patchwork Thu Nov 21 15:29:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13882103 Received: from mail-oo1-f45.google.com (mail-oo1-f45.google.com [209.85.161.45]) (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 35ED81DD877 for ; Thu, 21 Nov 2024 15:30:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732203002; cv=none; b=YxMQqEhD3nva4HP2PIV/wN+YychY7+Lrc83CUA7G9KDuYs3ZUtXYYILc4MKSGvrdFUAXZD+WPrQwMjnIH1ZUwRgQMUAW6cCamD8qeVgnIzanE8j5aDTIy4QlFQYUscCqRCv1nymdiB46HEk9dPNh/igG0X9LyCHHHjRjLprhUxQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732203002; c=relaxed/simple; bh=s4UdHlpFD1B8aAjSAqtdehl4ctIJUuMcNGL0wizdxH4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XINhr5Jm1cAZWrEcwNnZDMld33f65dNurA9fsuR6eYERbPCIA/p18Sx62jR5M0vvWvwisZvsgwid2OVh+AmBNrwR4acnK0xlh+FwE+dgRSCfozt8rRZ4OlDLfbWv6eC0cLv5BHeKtESPx0kjnhPHCyhsMuZEHfonPIry0SEn4Ds= 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=Z5ElRX6k; arc=none smtp.client-ip=209.85.161.45 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="Z5ElRX6k" Received: by mail-oo1-f45.google.com with SMTP id 006d021491bc7-5ee9dbf1b47so1054956eaf.1 for ; Thu, 21 Nov 2024 07:30:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732203000; x=1732807800; 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=vhssKegXs0dkBlkAs2LAwYuMWY72qVTAcjM7gFFYhEI=; b=Z5ElRX6kndW3M6CNqSb3XsWMv1fz+dVs1mAgdjKEbThulxLRS7ZchF8GxfiktsiFAX XneVixD1bHs2MVM3FWBoUJ+IQ2nZ6yjpgfrImfffqDf8+I0zQGDj7uTRl3AifmHq5oCn WiSrwHOd1Y1ek7w4CdO/JlVQGFXco2twzGR+xA4vHvrZ0DgJbo/HrHHPdOM9DD/Olowh lzzghZbup3GtqjJN1o+GfWpVoT2/e6jDkXjjwSyyjVkbrGUFypi6ZpOtNw2fvOUIx/s7 H28uqntJdEFHdkQTgU4FtoTfxR8Zyt4q/ZtELDnh8Boqazi2vKSbRXTmYUZAYirGGOIw XjYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732203000; x=1732807800; 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=vhssKegXs0dkBlkAs2LAwYuMWY72qVTAcjM7gFFYhEI=; b=xSkBbu906l+67UvYlacRU5xDQJ8JNIytxdvgPbd2qvXQvX1OmNupzlA/RQUvHCPmOj 4hCADV1AUfff9momQhlHq7TDxdDC8371HdeF77X9s7toDBIF4nZQ6AIAnbT/3uCnjqdK YRA28TViPF2CnvgXhgys/NVFDR6cBvGtAE4C57MYn4lCd0wCYnLH/edMONfv1UJeGxVK YmNzgWlX9MkZwZ8MMImHkV+8ifzo3jkiJ1ZuDjMBO/hc/fNLPXZjajWoehHRm1UmHywN ry6eFh2TLfhZHGp0w0CQ5X0QtAcahbZcVLjZXpA9ljXsbc3vsTG5G93wwbbs8HshDvFA vrcQ== X-Gm-Message-State: AOJu0Yw7uerNspzjhKj598SRBnXwnfXFiltFZPDjgRd2Yds9Uf8ebInq HG+iAI+6B39wuXCwslMaiHvN+JPFvHrz/xNh5xWV77/BwSp0YcClSrjx5Q== X-Gm-Gg: ASbGnctu0eoYnNDnwTenJ9h6gi5z06xxSyiyAE5GyIrPX4fP7197jopmev/dlUnYwms PvvkUDGxQBMRQ6v1AyG/YT2hGJiJwdZ56Lk9ehxABfu9AluoVQSD6UnzWBoA82F9XjycizfNMe6 GxvOCWPKSZd9EbBi6fzsSqYUxckkrbS/Z4J81fP95yxucfqIkx3aFLkcigbhRTxFxygt9ZYjHRC GvdgOT+4EDR91OmkEGyphT7VDJMp821T3yO1SQvwhm/q3umTQZkExi2Smn6CzKtYBPB4cf3q+IT GVBQxp6Geh57YzMhFg/aMxAL X-Google-Smtp-Source: AGHT+IHrWkCGFcN1TM6B9SLxta+uyW7ZSPCp8fCq/pbTtA7L0nXy1dVUbnfaIOnqqa4MGEc1Y4TvYw== X-Received: by 2002:a05:6870:7d19:b0:297:c05:1b56 with SMTP id 586e51a60fabf-2970c06ccb6mr1125072fac.13.1732202999914; Thu, 21 Nov 2024 07:29:59 -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 586e51a60fabf-29651ac5ff9sm4856831fac.42.2024.11.21.07.29.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Nov 2024 07:29:59 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 10/10] qmimodem: gprs-context: Fix non-default bearer activation Date: Thu, 21 Nov 2024 09:29:38 -0600 Message-ID: <20241121152949.56962-10-denkenz@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241121152949.56962-1-denkenz@gmail.com> References: <20241121152949.56962-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 start_network() expects a QMI IP_SUPPORT enumeration, which is obtained from WDS Get LTE Attach Parameters response. However, activate_primary() was converting the context type to a QMI PDP Type enumeration, which was subtly different. This broke non-default context activation for dual-stack contexts. Fixes: 3ee784aa9d9c ("qmi: gprs-context: Dual-Stack context activation support") --- drivers/qmimodem/gprs-context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/qmimodem/gprs-context.c b/drivers/qmimodem/gprs-context.c index a8ac3cb18c80..484cc7d8ddb9 100644 --- a/drivers/qmimodem/gprs-context.c +++ b/drivers/qmimodem/gprs-context.c @@ -478,7 +478,7 @@ static void qmi_activate_primary(struct ofono_gprs_context *gc, OFONO_GPRS_PROTO_IPV4V6)) goto error; - ip_type = qmi_wds_pdp_type_from_ofono(ctx->proto); + ip_type = qmi_wds_ip_support_from_ofono(ctx->proto); if (ip_type < 0) goto error;