From patchwork Mon May 20 19:17:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13668616 Received: from mail-oo1-f43.google.com (mail-oo1-f43.google.com [209.85.161.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B87BE1E86E for ; Mon, 20 May 2024 19:17:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716232647; cv=none; b=Douz+Mos3LHoQtcvJC7KPaF4cugIe4X5NFIyUes4wtSudfeqx5UFniGCsUQwuzlhU4KMVjmHRPfw4biWWcHfcQq6VcpzxuQulCgANmYZ6z7LwvgH0UnPY1slrBKToEMhy5KMLUVlZkdAXbq4jNGr+lHoAupfmTfBpYPAncVs7b0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716232647; c=relaxed/simple; bh=jSWy8CwGRiYv0cq3IziHCITid6IFbar7bE5oZO2b2lE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=OlMUoSTbUVVmcU6O0G0e/YdhyAwpu9CsWUj99L3D19+aKvSsppxy/eyk2B7fkn1WUG+Gc7PMKXekBAOYP7KYx8wftIo67NQoTvcLCQFciU4qdKzFywB/7fxnf++FnYhJrO04JYThydsOHuP3E0v3/g3RhHuFDOZ/UY25UlN0N3Y= 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=bsP2+jyu; arc=none smtp.client-ip=209.85.161.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bsP2+jyu" Received: by mail-oo1-f43.google.com with SMTP id 006d021491bc7-5b273b9f1deso1935437eaf.3 for ; Mon, 20 May 2024 12:17:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716232645; x=1716837445; 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=b8DChPbPrdhNPVlh3RSEx/qrZqFQLllrdztRLTZg6U8=; b=bsP2+jyu71Sz/h9+f00wPjOpYadXmBpZhPv1m5uavzIcqEwKqjzTnhL9pVviRFzgoX h5rh0SyqT/rRaCFxZ8ekqaTuPRAbMHNQZo+MKl+G9MxREoI4h71NWFN8wtLoCUcwdDtd z6wPoWYPqJrfvAeplaQYp8dcn7u1lSdg19BGeEYFRfCzunSCv48401WgAy8S+EdieAY3 nPxtCGR9o1mUxouZy46jubBdvolRca6XblU7EDjo98HrW6q1/rT8XpbqX1vJBYuJkfG0 GWL8QffxCcTShiJN8Sdo48NTyZ1HUACRCp4PycmvVW8RGu86DtI/QQRBNljynpf8DObu l7GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716232645; x=1716837445; 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=b8DChPbPrdhNPVlh3RSEx/qrZqFQLllrdztRLTZg6U8=; b=DBcO6ocV+gUKNOPIZMdRfmkuX9sc5XnUuL9sUHyAnO1U/RdQ28nwS8OCkFD2tVQY07 A3o9Tr5L4KKVrXiiFYWT2Pe+o7GrY5WOkdLaIdiVe20Xs4gPoIRYCQEzgVDtNBNTdgxn xilH1tz1lR4Ji9s5xugi2xcn5nmJYHC3SNsttEMgtr13SrvAK572RHwraDCHf3Qhvjr9 1k42tMQIakJ7Onzd9CUzEEkuMW98VZjZ7vj5zhu5+09tyJfW6Z/H4z9/30vtM/q2r7M9 1vgPImOuk0JPhmLVQxlDmHgboL0ggDk/jpBzGoffNuBkw7WVBUOnt3nwDwTH4aVey1bt 8fig== X-Gm-Message-State: AOJu0YxVLKDqT8pqu9+ZEvqBmDIvnX2jc6zAa2pS5/nVPt2IEA7qg4XV hs0vSMY5PP00rYqu0TRDZ/8TA/Iy3+4HmKvQ6SSMaTFhq2HprJoWSQNSow== X-Google-Smtp-Source: AGHT+IGGhcXSSmXbsG2CvBKrqrLWXiY52AQcz9zQ6KSXz2vfpQh1+4fX1c3GLk2fKhi7VztxNUM1sA== X-Received: by 2002:a05:6820:620:b0:5b5:3d56:5172 with SMTP id 006d021491bc7-5b53d566381mr1301154eaf.1.1716232644566; Mon, 20 May 2024 12:17:24 -0700 (PDT) Received: from localhost.localdomain (syn-070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-5b5390b9c54sm236387eaf.0.2024.05.20.12.17.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 12:17:24 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 1/6] gobi: add / use DeviceProtocol property Date: Mon, 20 May 2024 14:17:02 -0500 Message-ID: <20240520191722.184977-1-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Instead of using the kernel driver as a hint for whether qrtr or qmi is being used, introduce an explicit DeviceProtocol property that should be set by the detection logic to tell the driver whether to use qrtr or qmux. Split up QMI modem driver detection and setup logic inside udevng into setup_qmi_qrtr(), setup_qmi_qmux() and setup_qmi_netdev(). setup_qmi_netdev() takes care of setting up of common networking device properties, while setup_qmi_qrtr() and setup_qmi_qmux() setup QRTR and QMUX devices, respectively. While here, ensure that modem types are handled appropriately. QRTR is only available on embedded devices, while QMUX requires USB. --- plugins/gobi.c | 34 ++++++++++++++------- plugins/udevng.c | 78 +++++++++++++++++++++++++++++++----------------- 2 files changed, 75 insertions(+), 37 deletions(-) diff --git a/plugins/gobi.c b/plugins/gobi.c index 8bd2c4060446..d8b78ad6f5b0 100644 --- a/plugins/gobi.c +++ b/plugins/gobi.c @@ -72,6 +72,11 @@ #define GOBI_VOICE (1 << 9) #define GOBI_WDA (1 << 10) +enum qmi_protocol { + QMI_PROTOCOL_QMUX, + QMI_PROTOCOL_QRTR, +}; + struct gobi_data { struct qmi_device *device; struct qmi_service *dms; @@ -85,6 +90,7 @@ struct gobi_data { char main_net_name[IFNAMSIZ]; uint32_t max_aggregation_size; uint32_t set_powered_id; + enum qmi_protocol protocol; }; static void gobi_debug(const char *str, void *user_data) @@ -98,11 +104,22 @@ static int gobi_probe(struct ofono_modem *modem) { struct gobi_data *data; const char *kernel_driver; + const char *value; + enum qmi_protocol protocol; DBG("%p", modem); - data = l_new(struct gobi_data, 1); + value = ofono_modem_get_string(modem, "DeviceProtocol"); + if (l_streq0(value, "qrtr")) + protocol = QMI_PROTOCOL_QRTR; + else if (l_streq0(value, "qmux")) + protocol = QMI_PROTOCOL_QMUX; + else + return -EPROTO; + + data = l_new(struct gobi_data, 1); + data->protocol = protocol; kernel_driver = ofono_modem_get_string(modem, "KernelDriver"); DBG("kernel_driver: %s", kernel_driver); @@ -421,25 +438,22 @@ static void discover_cb(void *user_data) static int gobi_enable(struct ofono_modem *modem) { struct gobi_data *data = ofono_modem_get_data(modem); - const char *kernel_driver; + const char *device; int r; DBG("%p", modem); - kernel_driver = ofono_modem_get_string(modem, "KernelDriver"); - if (!kernel_driver) - return -EINVAL; - - if (!strcmp(kernel_driver, "qrtr")) + switch (data->protocol) { + case QMI_PROTOCOL_QRTR: data->device = qmi_device_new_qrtr(); - else { - const char *device; - + break; + case QMI_PROTOCOL_QMUX: device = ofono_modem_get_string(modem, "Device"); if (!device) return -EINVAL; data->device = qmi_device_new_qmux(device); + break; } if (!data->device) diff --git a/plugins/udevng.c b/plugins/udevng.c index fb694858aa6c..aa2a216d4247 100644 --- a/plugins/udevng.c +++ b/plugins/udevng.c @@ -197,20 +197,14 @@ static gboolean setup_hso(struct modem_info *modem) return TRUE; } -static int setup_qmi(struct modem_info *modem, const struct device_info *qmi, - const struct device_info *net) +static int setup_qmi_netdev(struct modem_info *modem, + const struct device_info *net) { const char *attr_value; uint32_t ifindex; int r; - DBG("qmi: %s net: %s kernel_driver: %s interface_number: %s", - qmi->devnode, net->devnode, net->kernel_driver, net->number); - - if (!qmi->kernel_driver) - return -EINVAL; - - if (!net->number && modem->type != MODEM_TYPE_EMBEDDED) + if (!net->kernel_driver) return -EINVAL; attr_value = udev_device_get_sysattr_value(net->udev_device, @@ -222,30 +216,60 @@ static int setup_qmi(struct modem_info *modem, const struct device_info *qmi, if (r < 0) return r; - ofono_modem_set_driver(modem->modem, "gobi"); - ofono_modem_set_string(modem->modem, "Device", qmi->devnode); ofono_modem_set_string(modem->modem, "KernelDriver", net->kernel_driver); ofono_modem_set_string(modem->modem, "NetworkInterface", net->devnode); - ofono_modem_set_string(modem->modem, "InterfaceNumber", net->number); ofono_modem_set_integer(modem->modem, "NetworkInterfaceIndex", ifindex); + return 0; +} + +static int setup_qmi_qmux(struct modem_info *modem, + const struct device_info *qmi, + const struct device_info *net) +{ + DBG("qmi: %s net: %s kernel_driver: %s interface_number: %s", + qmi->devnode, net->devnode, net->kernel_driver, net->number); + + if (modem->type != MODEM_TYPE_USB) + return -ENOTSUP; + + if (!net->number) + return -EINVAL; + + if (!qmi->kernel_driver) + return -EINVAL; + + ofono_modem_set_driver(modem->modem, "gobi"); + ofono_modem_set_string(modem->modem, "Device", qmi->devnode); + ofono_modem_set_string(modem->modem, "DeviceProtocol", "qmux"); + ofono_modem_set_string(modem->modem, "InterfaceNumber", net->number); + + ofono_modem_set_string(modem->modem, "Bus", "usb"); + + return setup_qmi_netdev(modem, net); +} + +static int setup_qmi_qrtr(struct modem_info *modem, + const struct device_info *net) +{ + DBG("net: %s kernel_driver: %s", net->devnode, net->kernel_driver); + switch (modem->type) { - case MODEM_TYPE_USB: - ofono_modem_set_string(modem->modem, "Bus", "usb"); - break; - case MODEM_TYPE_PCIE: - ofono_modem_set_string(modem->modem, "Bus", "pcie"); - break; case MODEM_TYPE_EMBEDDED: ofono_modem_set_string(modem->modem, "Bus", "embedded"); break; + case MODEM_TYPE_USB: case MODEM_TYPE_SERIAL: - break; + case MODEM_TYPE_PCIE: + return -ENOTSUP; } - return 0; + ofono_modem_set_driver(modem->modem, "gobi"); + ofono_modem_set_string(modem->modem, "DeviceProtocol", "qrtr"); + + return setup_qmi_netdev(modem, net); } static gboolean setup_gobi_qrtr_premux(struct modem_info *modem, @@ -310,7 +334,7 @@ static gboolean setup_gobi_qrtr(struct modem_info *modem) return FALSE; } - r = setup_qmi(modem, ipa_info, ipa_info); + r = setup_qmi_qrtr(modem, ipa_info); if (r < 0) return FALSE; @@ -367,7 +391,7 @@ static gboolean setup_gobi(struct modem_info *modem) DBG("qmi=%s net=%s mdm=%s gps=%s diag=%s", qmi->devnode, net->devnode, mdm, gps, diag); - if (setup_qmi(modem, qmi, net) < 0) + if (setup_qmi_qmux(modem, qmi, net) < 0) return FALSE; ofono_modem_set_string(modem->modem, "Modem", mdm); @@ -432,7 +456,7 @@ static gboolean setup_sierra(struct modem_info *modem) } if (qmi != NULL && net != NULL) { - if (setup_qmi(modem, qmi, net) < 0) + if (setup_qmi_qmux(modem, qmi, net) < 0) return FALSE; goto done; @@ -510,7 +534,7 @@ static gboolean setup_huawei(struct modem_info *modem) } if (qmi != NULL && net != NULL) { - if (setup_qmi(modem, qmi, net) < 0) + if (setup_qmi_qmux(modem, qmi, net) < 0) return FALSE; goto done; @@ -847,7 +871,7 @@ static gboolean setup_telitqmi(struct modem_info *modem) if (qmi == NULL || net == NULL) return FALSE; - if (setup_qmi(modem, qmi, net) < 0) + if (setup_qmi_qmux(modem, qmi, net) < 0) return FALSE; if (g_strcmp0(modem->model, "1070")) @@ -1161,7 +1185,7 @@ static gboolean setup_quectelqmi(struct modem_info *modem) DBG("gps=%s aux=%s", gps, aux); - if (setup_qmi(modem, qmi, net) < 0) + if (setup_qmi_qmux(modem, qmi, net) < 0) return FALSE; qmap_size = udev_device_get_sysattr_value(net->udev_device, @@ -1611,7 +1635,7 @@ static gboolean setup_sim7x00(struct modem_info *modem) if (qmi != NULL && net != NULL) { DBG("mdm=%s gps=%s diag=%s", mdm, gps, diag); - if (setup_qmi(modem, qmi, net) < 0) + if (setup_qmi_qmux(modem, qmi, net) < 0) return FALSE; ofono_modem_set_string(modem->modem, "Modem", mdm); From patchwork Mon May 20 19:17:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13668617 Received: from mail-oo1-f49.google.com (mail-oo1-f49.google.com [209.85.161.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 0663379EF for ; Mon, 20 May 2024 19:17:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716232648; cv=none; b=VKlUqm/wTdjZ3e2PvkeKbZzawzgCeZmdj+p/nOPNI8HTUJBqMnfD2jkApyKbvcTHL2i3OuXY9Vp9gwo3IX6tkqIvI6GN1TjaeL3cyCQZo0vJlgnMEMMBxkcO/BK9j6HjUGA2wNyJOvphZkMoJJ1BXPShhTGz1u5pPA8hiWUWqr4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716232648; c=relaxed/simple; bh=nLI/3ne0HcQ0M0BVvOTtmEUYyrUtzRR7TFWrOW7HqiU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fhQ7b5wV5Q/ZmCJ5JggXnmRtfKHcHo1fucbT6qrScs29v7+R1/uOMy6bUypviMkr6YwWhgbtD5Ztvxc7ESR8/IxTmxl5FSsMcO2OlzQu1FCQZ+QkHKKcuDQdhafsY95GIXyZ3O45L5RR+QusdZQ7u5NlGvqTxFueANuh2AH+nto= 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=QQ/P+X/z; arc=none smtp.client-ip=209.85.161.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="QQ/P+X/z" Received: by mail-oo1-f49.google.com with SMTP id 006d021491bc7-5b27d9fe710so1337351eaf.3 for ; Mon, 20 May 2024 12:17:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716232645; x=1716837445; 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=lA/q1f76VnCMyqUSqAslTbWfXLOcxzYPPzsEj3FbJJU=; b=QQ/P+X/zxUacujyHjezEkmUEG2q22im0xRcHYrrtgRl7tslTKlP54Jj9QuDVb2gsEM LIph4oyUjB4GXJk00/k5nUuhcYjWCtIVnBZY5ZaYw6P2Bdg9oa6GWNFj6WQYEFyUrsU4 f4yx7LHHDopSMEiB7m0f018QXd25g0JUA+X8aHpe1WrwGMob0gX/xfk9OcQOy0EEV6FW HaDVpILrN8y+5l8l/C7VZURMe+DUHYM84lbPEobsP+0Ey07IiFtQXFq+cHVV73SjbsDm Rw1+c35n7mi57m9nbgTlx8taA9uozPCIGBZoiWgU3DcZsLHUEix49xJEYl6brsIYxN3l kmRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716232645; x=1716837445; 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=lA/q1f76VnCMyqUSqAslTbWfXLOcxzYPPzsEj3FbJJU=; b=AB/g9h9LoxDyvhhzXOuF9E6vzR+QwohMUOfIMMJmOIeOOi/MswXI0Q1jJIgH/5GP1T VVYA0CNiYZvS2CRo4tZfheRN+PNCaeqA6ohx9n63tJ6JSONdwMFsxjWW0L25Rc+qtEOw WXdaJnEOTRiKdjHqYwBXT770ODBCExudKtFX/6OShW3shhgvWHQEwy43Y6TW/+yiz6hx /ZFKmllaPBAwbtdcmUX2CiIcjcv7La3wLNyNGrR8oglX7l21gRh+FQZBY4wzRyrnIVIY sZlRiGp7+/uwupwFj5oUsm9Awe8jBvtUlJeBCe/q6hsV+IQiuFjqxBW4X1TuyB70fq/K Xxtw== X-Gm-Message-State: AOJu0YzqeTRSWb+YfOveWVn/LrRJyGX+eaHmTzdCSauEgwNCy3xKmdCM 2yhrT/Y+EJz3VyXPiRWwbNdnB5lyq08bQNHMK1IL3QNOt98so+g3htpNJw== X-Google-Smtp-Source: AGHT+IEua2DoF4NeX7YE6yfpXapdW+QZV5r57YxnqZXnZnZ4R35tC83Vov3DOclwqcHoFTx6mnKHEw== X-Received: by 2002:a4a:55d2:0:b0:5b1:bf59:7ac0 with SMTP id 006d021491bc7-5b281a50b4amr31874099eaf.9.1716232645461; Mon, 20 May 2024 12:17:25 -0700 (PDT) Received: from localhost.localdomain (syn-070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-5b5390b9c54sm236387eaf.0.2024.05.20.12.17.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 12:17:24 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 2/6] gobi: Rename KernelDriver to NetworkInterfaceDriver Date: Mon, 20 May 2024 14:17:03 -0500 Message-ID: <20240520191722.184977-2-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240520191722.184977-1-denkenz@gmail.com> References: <20240520191722.184977-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The naming should now more accurately reflect what the driver string represents. --- plugins/gobi.c | 10 ++++++---- plugins/udevng.c | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/plugins/gobi.c b/plugins/gobi.c index d8b78ad6f5b0..5bb0b5ace0ca 100644 --- a/plugins/gobi.c +++ b/plugins/gobi.c @@ -103,9 +103,9 @@ static void gobi_debug(const char *str, void *user_data) static int gobi_probe(struct ofono_modem *modem) { struct gobi_data *data; - const char *kernel_driver; const char *value; enum qmi_protocol protocol; + const char *if_driver; DBG("%p", modem); @@ -118,12 +118,14 @@ static int gobi_probe(struct ofono_modem *modem) else return -EPROTO; + if_driver = ofono_modem_get_string(modem, + "NetworkInterfaceKernelDriver"); + DBG("netdev driver: %s", if_driver); + data = l_new(struct gobi_data, 1); data->protocol = protocol; - kernel_driver = ofono_modem_get_string(modem, "KernelDriver"); - DBG("kernel_driver: %s", kernel_driver); - if (!strcmp(kernel_driver, "qmi_wwan_q")) + if (!strcmp(if_driver, "qmi_wwan_q")) data->using_qmi_wwan_q = true; data->main_net_ifindex = diff --git a/plugins/udevng.c b/plugins/udevng.c index aa2a216d4247..c7db66238681 100644 --- a/plugins/udevng.c +++ b/plugins/udevng.c @@ -216,7 +216,7 @@ static int setup_qmi_netdev(struct modem_info *modem, if (r < 0) return r; - ofono_modem_set_string(modem->modem, "KernelDriver", + ofono_modem_set_string(modem->modem, "NetworkInterfaceKernelDriver", net->kernel_driver); ofono_modem_set_string(modem->modem, "NetworkInterface", net->devnode); ofono_modem_set_integer(modem->modem, "NetworkInterfaceIndex", From patchwork Mon May 20 19:17:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13668618 Received: from mail-oo1-f48.google.com (mail-oo1-f48.google.com [209.85.161.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 14F901E50B for ; Mon, 20 May 2024 19:17:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716232648; cv=none; b=llxjyN8878A3sjYnUt5NO00B4haLE0wf8fFoV7N1qBkp3pL/igCxD7WgxCLA8y8RjzYddR6GoG/BFmSI1h+IlwEQIN6RxYbdAOPcFQkidM8FslkjT/gYYdiQDZSdzAMILGFOjkRBE+p3DxFpurF86TSDznRhMkrZnk8qAb5/u2Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716232648; c=relaxed/simple; bh=Ni6GPyNMc4m96IJar6T6tiDgXMyaq9IfZM4JRv2nAhA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Rq2fVGLFHPcwAwuy1SdUbWz6xfuTC8R3paGlVMdB7JUJfGok5K/5WeAK7j7qLqCjWWy3h+tZfFsokxNTOyVq9LM5oN8/QWaufbeDqePcnmX+rMgmC7PHfALgqtTF6IL+Gb4Rj3mFUW1s7mE7DKmNDwhbtwZuDsc/hm3S2GIrLag= 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=Y/5befwU; arc=none smtp.client-ip=209.85.161.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="Y/5befwU" Received: by mail-oo1-f48.google.com with SMTP id 006d021491bc7-5aa1bf6cb40so3429911eaf.1 for ; Mon, 20 May 2024 12:17:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716232646; x=1716837446; 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=IiSbTm8aXaamR9RlNUw666aijxdt1fEiRyX+ox5bVt0=; b=Y/5befwU6KsiSiPKQhe6DXTmHKwTtaL5tQhlaKYo6kp3Mqh++7NvIdkP453NA6oQde VhNLksZCT0bUvMp2aqazmlBJAb1ATOwBXRM1+jGmA5NGdpRM0Ma+mlN3OsdqbUT77q7V L4d3dRoqd/VWLMFZurvITdomPS545LJ4zjcUkRC2a3VWTf+j54qGouf3j8ElS04t7E0/ r2dMcNCWEVzo107nfeLZqe9sIKKKNjQjd61ctDbI5692YAqFwccy5g0aZgs7v/ByJx54 IJX17AF9tKDb59PL67al8nhn2MjBjTsx39RxwxIW8hcl3j8wRwHWVaZLdjsvkoYKQXvh 8Ngw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716232646; x=1716837446; 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=IiSbTm8aXaamR9RlNUw666aijxdt1fEiRyX+ox5bVt0=; b=Qu+7WbmgB/0re8ziPsiR0LyAxtbuthA9vxdDlEbcQqx2t5K/KFtFRyoZZFB/T/LhOl EcGEwyBiDfP3pjgrTNGmm1A41EIGz98AfcsrtJYmF3eUEzd+9p3If//pQCdo37+PCcIZ 0QEfcfSvQ+6+LesJtp9UC0YopNDp09GveyIahLZ1LKupmFNDrjtaId8I8fZS8Ck/C9QO qgZVZCfXme5ZC1U4hD7e1MJwg1fl8Vnuv16r2KBMtRnxszWVlzv0ApMZynCMFAyZMY72 cVgUJM1ow6JZohXZJIGtEeD5H3ecTCcwT4qja0XaO4W0VT4oTYFj+cjtE7JUhhslsuHx 7nZg== X-Gm-Message-State: AOJu0Ywjt1Dp2ngxTyF/vqsQF3FKmMD5sDam5paD54DHmC/XcNhJt7Nf XpXerVX1r8aAXiidcPjPS8bgoab0Yrrer8VkZ7JiuTRmWIsqSd/2Wy0IJg== X-Google-Smtp-Source: AGHT+IGZeJuF9mwS57t9mVOXvvDjY8lGtN83L2XjzHKfX3RwhN8kNnK0ajnbHQy8hBSNNpD7mFTUuA== X-Received: by 2002:a4a:8553:0:b0:5b2:f1cb:1a3f with SMTP id 006d021491bc7-5b2f1cb1b21mr16274564eaf.7.1716232646099; Mon, 20 May 2024 12:17:26 -0700 (PDT) Received: from localhost.localdomain (syn-070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-5b5390b9c54sm236387eaf.0.2024.05.20.12.17.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 12:17:25 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 3/6] gobi: ensure required properties are provided Date: Mon, 20 May 2024 14:17:04 -0500 Message-ID: <20240520191722.184977-3-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240520191722.184977-1-denkenz@gmail.com> References: <20240520191722.184977-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Ensure that a minimum set of properties required to drive the modem are provided by the detection framework. Also, while here, document these properties. --- plugins/gobi.c | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/plugins/gobi.c b/plugins/gobi.c index 5bb0b5ace0ca..bb4560c43a06 100644 --- a/plugins/gobi.c +++ b/plugins/gobi.c @@ -100,12 +100,37 @@ static void gobi_debug(const char *str, void *user_data) ofono_info("%s%s", prefix, str); } +/* + * Probe the modem. The following modem properties are expected to be set + * in order to initialize the driver properly: + * + * DeviceProtocol + * Can be "qrtr" or "qmux", tells the driver which QMI encapsulation protocol + * is being used. + * + * NetworkInterface + * The string that contains the 'main' network device. This can be + * "rmnet_ipa" on SoC systems, or "wwan0" for upstream linux systems. + * + * NetworkInterfaceIndex + * The index of the main interface given by NetworkInterface + * + * NetworkInterfaceDriver + * The kernel driver that is being used by the main network device. Certain + * drivers such as 'qmi_wwan' or 'qmi_wwan_q' are treated specifically. + * + * Bus + * The bus of the modem. Values can be "usb", "embedded", or "pci" + */ static int gobi_probe(struct ofono_modem *modem) { struct gobi_data *data; const char *value; enum qmi_protocol protocol; const char *if_driver; + const char *ifname; + int ifindex; + const char *bus; DBG("%p", modem); @@ -120,7 +145,14 @@ static int gobi_probe(struct ofono_modem *modem) if_driver = ofono_modem_get_string(modem, "NetworkInterfaceKernelDriver"); - DBG("netdev driver: %s", if_driver); + ifname = ofono_modem_get_string(modem, "NetworkInterface"); + ifindex = ofono_modem_get_integer(modem, "NetworkInterfaceIndex"); + bus = ofono_modem_get_string(modem, "Bus"); + + DBG("net: %s[%s](%d) %s", ifname, if_driver, ifindex, bus); + + if (!if_driver || !ifname || !ifindex || !bus) + return -EPROTO; data = l_new(struct gobi_data, 1); data->protocol = protocol; @@ -133,8 +165,6 @@ static int gobi_probe(struct ofono_modem *modem) l_strlcpy(data->main_net_name, ofono_modem_get_string(modem, "NetworkInterface"), sizeof(data->main_net_name)); - DBG("net: %s (%d)", data->main_net_name, data->main_net_ifindex); - ofono_modem_set_data(modem, data); ofono_modem_set_capabilities(modem, OFONO_MODEM_CAPABILITY_LTE); From patchwork Mon May 20 19:17:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13668621 Received: from mail-oo1-f46.google.com (mail-oo1-f46.google.com [209.85.161.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 04F521E86E for ; Mon, 20 May 2024 19:17:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716232650; cv=none; b=BjNv2fYaSsb3gSEdbX9LCoRdCZ8hN7IV2qqBVSRCNchyydbuWC/bDHPxEmtvQ5g+Qpev2LpNHBYZl0NhWGBY6tameo3h9GEDB1ZTCnbabwsklmeTvA9bthMqefWGrWuwAjc/WGOytORH9wP6jCT4Ype4kCJOn6Wyynw/VydM6WU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716232650; c=relaxed/simple; bh=cMSQiU1K5XbNUNmUxsUE6vsXhRSN3VGF2kPAq2+mJB8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BxUBYxEdAmCahg9DFc0DfL3wM3qd3uv1i6l3cX4jKZJarz6xYGHPQ+dR8KAAQjSRMvXQMdUzgU6YnFMG47NOYopD5Dg1kDvTlV/6tfCaFts75D5y1cwmjbCYSn5cIjXJcBsrGpUEPIbs/vz0B7VLuTBHOdIQc9Zcx+3ZcxvFOQs= 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=j8sh1gHK; arc=none smtp.client-ip=209.85.161.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="j8sh1gHK" Received: by mail-oo1-f46.google.com with SMTP id 006d021491bc7-5b31f2c6e52so1176792eaf.2 for ; Mon, 20 May 2024 12:17:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716232647; x=1716837447; 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=8xnR6NHOaOLqaULXJww6HIqzaKX0gxy2gZJy7vrmW4g=; b=j8sh1gHKbdcrrNBLqt3k8ymae/Xk2Gj1eOPf/J9ARk4oSWZM6neh1VkvX64C18FjH3 hX0DvMBnykhBIXwiI/8cw2Jou0VlFMLYux/DR/hzF2MZfmdNiWwJNIwshOa4ndwRyFEP PKwveeFsAxhLEHOSli71vpmpxibnhYmL7VFrhN+d5w03fDctBFehnEHMm8wOTYHXiNQE QLT6HVyL7NimnXO1TdZT+lGpTmtdoR6wVOG5GKIZSsI/l4HJ0bmjfhf0cAJd9369fklY AIbDzWKjA6DZ//+lIgTOHuVPtKSc/M8ZhiTKnKk/L/caJQaD5SRiF5ohRAjCoY2nQnfE PXLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716232647; x=1716837447; 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=8xnR6NHOaOLqaULXJww6HIqzaKX0gxy2gZJy7vrmW4g=; b=kK+qCUC4ZcZpjDuGcWDkOD9Sks/XC+chpU9Hxe4yJCuoA2tqMqhT6A+MnP90TfHYe7 cFrJrT/fcHNJeozdiFmT7m7zxi6bp6XRQPyaaIEa/pASAE1uxpUzdwHyw0v4f8iN87UF 9Ev79PxTZvDTqbHyYi9vqM+Jn0bpfiJogaVhLdaTMejMBl0RTAOw/NlPvyU442kMHY++ 0NcITdO47yZ3umfPLEslpV6BX/pOSOKBNS7TXedRWaXlEDDyAb4RGvITXQH/BYdaieDL 2u4Fi7hbI0V0migKVECBVZQcG05VaTUWLBcH0QOg+evzFjT7wg/zGX5PZcjxe6MGUT6X 17kQ== X-Gm-Message-State: AOJu0YyhTh8z/qjss6SM7H8gJXxVuxow+42jp7YLA89LfwA7EtKkDmeP wDSnFC2ICS5fVvU8Dai1lKJ3mh3Pf1ozSWFHd5JKf/Hm1nyTzc1eFNbVAA== X-Google-Smtp-Source: AGHT+IGQqrG+GLXVrgGuPvy5Vn0XjKg1B8a1IzpBy9fsAk9NLGGsERZ3/gOQVZfbuLqDq/AIhfNa3Q== X-Received: by 2002:a4a:641:0:b0:5b2:72e5:c12d with SMTP id 006d021491bc7-5b281957032mr29657736eaf.5.1716232646659; Mon, 20 May 2024 12:17:26 -0700 (PDT) Received: from localhost.localdomain (syn-070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-5b5390b9c54sm236387eaf.0.2024.05.20.12.17.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 12:17:26 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 4/6] udevng: add and use get_ifname() for netdev nodes Date: Mon, 20 May 2024 14:17:05 -0500 Message-ID: <20240520191722.184977-4-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240520191722.184977-1-denkenz@gmail.com> References: <20240520191722.184977-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 For USB devices, 'devnode' member contains the path to the character device, typically under /dev. For example, /dev/cdc-wdm0. For network devices that are part of the USB composite device, 'devnode' was overloaded to contain the network interface. Unfortunately, this code path / logic was only active when add_device() was called with MODEM_TYPE_USB. For non-USB bus devices 'devnode' was always NULL. This led to NetworkInterface properties being set improperly: ofonod[4874]: plugins/gobi.c:gobi_probe() net: (null)[mhi_net](2) pcie ofonod[4874]: plugins/udevng.c:create_modem() could not register modem 'mhi' Fix this by introducing a new get_ifname() helper which will query the network device node information for the network interface name as follows: - Query ID_NET_NAME property. This is used on newer kernels. - Query INTERFACE property. This is used on newer and legacy kernels. - Fall back to sysname in case none of the above properties are present. --- plugins/udevng.c | 85 +++++++++++++++++++++++++++++------------------- 1 file changed, 51 insertions(+), 34 deletions(-) diff --git a/plugins/udevng.c b/plugins/udevng.c index c7db66238681..80a57434de78 100644 --- a/plugins/udevng.c +++ b/plugins/udevng.c @@ -78,6 +78,23 @@ struct serial_device_info { struct udev_device *dev; }; +static const char *get_ifname(const struct device_info *info) +{ + struct udev_device *udev_device = info->udev_device; + const char *net_name; + + net_name = udev_device_get_property_value(udev_device, "ID_NET_NAME"); + if (net_name) + return net_name; + + net_name = udev_device_get_property_value(udev_device, "INTERFACE"); + if (net_name) + return net_name; + + /* Fall back to using sysname (M: field in udevadm) */ + return udev_device_get_sysname(udev_device); +} + static gboolean setup_isi(struct modem_info *modem) { const char *node = NULL; @@ -96,7 +113,7 @@ static gboolean setup_isi(struct modem_info *modem) if (g_strcmp0(info->interface, "2/254/0") == 0) addr = 16; - node = info->devnode; + node = get_ifname(info); } } @@ -142,7 +159,7 @@ static gboolean setup_mbm(struct modem_info *modem) "gw") == TRUE || g_str_has_suffix(info->sysattr, "NetworkAdapter") == TRUE) { - network = info->devnode; + network = get_ifname(info); } } @@ -178,9 +195,12 @@ static gboolean setup_hso(struct modem_info *modem) app = info->devnode; else if (g_strcmp0(info->sysattr, "Modem") == 0) mdm = info->devnode; - else if (info->sysattr == NULL && - g_str_has_prefix(info->devnode, "hso") == TRUE) - net = info->devnode; + else if (!info->sysattr) { + const char *net_name = get_ifname(info); + + if (g_str_has_prefix(net_name, "hso")) + net = get_ifname(info); + } } if (ctl == NULL || app == NULL) @@ -218,7 +238,8 @@ static int setup_qmi_netdev(struct modem_info *modem, ofono_modem_set_string(modem->modem, "NetworkInterfaceKernelDriver", net->kernel_driver); - ofono_modem_set_string(modem->modem, "NetworkInterface", net->devnode); + ofono_modem_set_string(modem->modem, "NetworkInterface", + get_ifname(net)); ofono_modem_set_integer(modem->modem, "NetworkInterfaceIndex", ifindex); @@ -230,7 +251,8 @@ static int setup_qmi_qmux(struct modem_info *modem, const struct device_info *net) { DBG("qmi: %s net: %s kernel_driver: %s interface_number: %s", - qmi->devnode, net->devnode, net->kernel_driver, net->number); + qmi->devnode, get_ifname(net), + net->kernel_driver, net->number); if (modem->type != MODEM_TYPE_USB) return -ENOTSUP; @@ -254,7 +276,7 @@ static int setup_qmi_qmux(struct modem_info *modem, static int setup_qmi_qrtr(struct modem_info *modem, const struct device_info *net) { - DBG("net: %s kernel_driver: %s", net->devnode, net->kernel_driver); + DBG("net: %s kernel_driver: %s", get_ifname(net), net->kernel_driver); switch (modem->type) { case MODEM_TYPE_EMBEDDED: @@ -389,7 +411,7 @@ static gboolean setup_gobi(struct modem_info *modem) return FALSE; DBG("qmi=%s net=%s mdm=%s gps=%s diag=%s", - qmi->devnode, net->devnode, mdm, gps, diag); + qmi->devnode, get_ifname(net), mdm, gps, diag); if (setup_qmi_qmux(modem, qmi, net) < 0) return FALSE; @@ -465,10 +487,11 @@ static gboolean setup_sierra(struct modem_info *modem) if (mdm == NULL || net == NULL) return FALSE; - ofono_modem_set_string(modem->modem, "NetworkInterface", net->devnode); + ofono_modem_set_string(modem->modem, "NetworkInterface", + get_ifname(net)); done: DBG("modem=%s app=%s net=%s diag=%s qmi=%s", - mdm, app, net->devnode, diag, qmi->devnode); + mdm, app, get_ifname(net), diag, qmi->devnode); ofono_modem_set_string(modem->modem, "Modem", mdm); ofono_modem_set_string(modem->modem, "App", app); @@ -543,10 +566,11 @@ static gboolean setup_huawei(struct modem_info *modem) if (mdm == NULL || pcui == NULL) return FALSE; - ofono_modem_set_string(modem->modem, "NetworkInterface", net->devnode); + ofono_modem_set_string(modem->modem, "NetworkInterface", + get_ifname(net)); done: DBG("mdm=%s pcui=%s diag=%s qmi=%s net=%s", - mdm, pcui, diag, qmi->devnode, net->devnode); + mdm, pcui, diag, qmi->devnode, get_ifname(net)); ofono_modem_set_string(modem->modem, "Modem", mdm); ofono_modem_set_string(modem->modem, "Pcui", pcui); @@ -646,11 +670,11 @@ static gboolean setup_icera(struct modem_info *modem) mdm = info->devnode; } else if (g_strcmp0(info->interface, "2/6/0") == 0) { if (g_strcmp0(info->number, "05") == 0) - net = info->devnode; + net = get_ifname(info); else if (g_strcmp0(info->number, "06") == 0) - net = info->devnode; + net = get_ifname(info); else if (g_strcmp0(info->number, "07") == 0) - net = info->devnode; + net = get_ifname(info); } } @@ -823,7 +847,7 @@ static gboolean setup_telit(struct modem_info *modem) gps = info->devnode; } else if (info->sysattr && (g_str_has_suffix(info->sysattr, "CDC NCM") == TRUE)) { - net = info->devnode; + net = get_ifname(info); } } @@ -1022,7 +1046,7 @@ static gboolean setup_samsung(struct modem_info *modem) if (g_strcmp0(info->interface, "10/0/0") == 0) control = info->devnode; else if (g_strcmp0(info->interface, "255/0/0") == 0) - network = info->devnode; + network = get_ifname(info); } if (control == NULL && network == NULL) @@ -1249,7 +1273,7 @@ static gboolean setup_mbim(struct modem_info *modem) if (g_strcmp0(subsystem, "usbmisc") == 0) /* cdc-wdm */ ctl = info->devnode; else if (g_strcmp0(subsystem, "net") == 0) /* wwan */ - net = info->devnode; + net = get_ifname(info); else if (g_strcmp0(subsystem, "tty") == 0) { if (g_strcmp0(info->number, "02") == 0) atcmd = info->devnode; @@ -1407,7 +1431,7 @@ static gboolean setup_ublox(struct modem_info *modem) g_strcmp0(info->interface, "2/13/0") == 0 || g_strcmp0(info->interface, "10/0/0") == 0 || g_strcmp0(info->interface, "224/1/3") == 0) { - net = info->devnode; + net = get_ifname(info); } } @@ -1452,7 +1476,7 @@ static gboolean setup_gemalto(struct modem_info *modem) else if (g_strcmp0(info->number, "03") == 0) mdm = info->devnode; else if (g_strcmp0(subsystem, "net") == 0) - net = info->devnode; + net = get_ifname(info); else if (g_strcmp0(subsystem, "usbmisc") == 0) qmi = info->devnode; } @@ -1470,9 +1494,9 @@ static gboolean setup_gemalto(struct modem_info *modem) if (g_strcmp0(info->interface, "2/6/0") == 0) { if (g_strcmp0(subsystem, "net") == 0) { if (g_strcmp0(info->number, "0a") == 0) - net = info->devnode; + net = get_ifname(info); if (g_strcmp0(info->number, "0c") == 0) - net2 = info->devnode; + net2 = get_ifname(info); } } } @@ -1535,11 +1559,11 @@ static gboolean setup_xmm7xxx(struct modem_info *modem) } else if (g_strcmp0(subsystem, "net") == 0) { if (g_strcmp0(info->number, "06") == 0) - net = info->devnode; + net = get_ifname(info); if (g_strcmp0(info->number, "08") == 0) - net2 = info->devnode; + net2 = get_ifname(info); if (g_strcmp0(info->number, "0a") == 0) - net3 = info->devnode; + net3 = get_ifname(info); } } else { if (g_strcmp0(subsystem, "tty") == 0) { @@ -1548,7 +1572,7 @@ static gboolean setup_xmm7xxx(struct modem_info *modem) } else if (g_strcmp0(subsystem, "net") == 0) { if (g_strcmp0(info->number, "00") == 0) - net = info->devnode; + net = get_ifname(info); } } @@ -1992,13 +2016,6 @@ static void add_device(const char *modem_syspath, const char *modem_devname, if (modem->type == MODEM_TYPE_USB) { devnode = udev_device_get_devnode(device); - if (devnode == NULL) { - devnode = udev_device_get_property_value(device, - "INTERFACE"); - if (devnode == NULL) - return; - } - usb_interface = udev_device_get_parent_with_subsystem_devtype( device, "usb", "usb_interface"); From patchwork Mon May 20 19:17:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13668619 Received: from mail-oo1-f44.google.com (mail-oo1-f44.google.com [209.85.161.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C34B679EF for ; Mon, 20 May 2024 19:17:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716232650; cv=none; b=huiDJ3m71teF7Web8ZzzD5cuXxoqZHUFp3zMDQBKwQQT04BqxjbizWYKiy44NTA+6sXP8tnz4+TQ9/CxMj03d/uMI7yGqg0kywuRSeJBpaWrh6icTfTW6eGWcdVkDA8mIp+T6TWmmC7O+s2ktLUfKfojSnZ8uvjM6XyOS8wq8CI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716232650; c=relaxed/simple; bh=LddFCFknC033tln6KPG+wWcJeZa6RauF6VQ3lXar8C0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Un/T5bTL+glsn6OxvwIh0oye8SkaXVN1G1SVrQI1Yhp8QoeAvwBq+ITMscr1nliaVbwbXk33DsO2HBx5jkCeQt/8HZbEiW4DQKCUiBufJCE+/Q/SKd4RY5tNfUVTKgbr74t/vfJ+8OJs9dupvV/mf6bB51+/MG9HpmhZGmdHCM0= 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=QIV3jT5I; arc=none smtp.client-ip=209.85.161.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QIV3jT5I" Received: by mail-oo1-f44.google.com with SMTP id 006d021491bc7-5b2dec569e3so1944539eaf.2 for ; Mon, 20 May 2024 12:17:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716232648; x=1716837448; 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=e4+ZKE1V1KrAMn85U7hirtbrB3mX8NkrhC7SCNsCHPs=; b=QIV3jT5I0rmsnCYXtILX3hDL153kQHoKmTuHz3s4qzzdSlODSPUxCxmKaJbob23XS7 egmKC2udZ7X6LFx6ZrKC7y87lHcBid5j+HjRVlud/xLvgdJiDChluZ9MbZ4QUEo9eP2Z 6jgoks0CffiMx/uDBxhhP0yiYpTyyJDbPLsQ9h5ekisaq/dxtgtliqb7o0j5Alw6dpKF SZkfPNbbqi0PQBvbVa0DEFOfn5CPkjkRHyyTLvHHGPDgi/RYXWWoM4MtiOlb5HBn7Kub we+Frlii2IKQmpx1L7uZyoEGrdan2DcgeMYPVHPCvEpGjBNOy99V/1bKelfSrELBFAcd w0+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716232648; x=1716837448; 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=e4+ZKE1V1KrAMn85U7hirtbrB3mX8NkrhC7SCNsCHPs=; b=GSeVG0u66zuCSMl+ojeBjw51wZJAH9hBohneygL39A4rfgLxamEO91STOs9Bx2ryzV F+POdbTkuIDx3+qitOix3nI2FLrJv73EB6nY7FQVKtGLxToB3k1LExG1ZVHLNyEKnBGs Ce0ZefmJpEsQXSh1LTuxiODbPC+AChzpC54iSgZcgrAkX8IZ7KzjygfGYK6usZRrbAK+ Ro3RxyoiM2iiPC5fp+xqhwOmLArpsae54v+EgOQBOdNh1IcS02JpOpbkMRHNkEz1yQ7/ VeR1BQWO1snkVkilBnYXuLMwIs31KlG07wwUiJaKTkiKamf/Mnf6AACT/Km9cT1CXoZg NFJQ== X-Gm-Message-State: AOJu0YwhrP3rKWVvIXenTkLhT63EznHLmSOFL+5k0t+YOqqjtBrWaMe7 ce+Sc+2Ipw2ZvPCtihPKpHVMJgdGY6U/fTxS1FnnhRhFQtFiFLoAELkmRg== X-Google-Smtp-Source: AGHT+IF0pAGQJYtgNJQhoZq9p3zBLMsIJkGCHrX+jKWfS3qoULzDZdfLU+RIMC/3JNXJFYIzq0Xlyg== X-Received: by 2002:a05:6820:221a:b0:5b3:232a:5c0e with SMTP id 006d021491bc7-5b3232a5c17mr10438481eaf.4.1716232647590; Mon, 20 May 2024 12:17:27 -0700 (PDT) Received: from localhost.localdomain (syn-070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-5b5390b9c54sm236387eaf.0.2024.05.20.12.17.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 12:17:27 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 5/6] udevng: Add mhi subsystem detection Date: Mon, 20 May 2024 14:17:06 -0500 Message-ID: <20240520191722.184977-5-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240520191722.184977-1-denkenz@gmail.com> References: <20240520191722.184977-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 For now, only Qualcomm derived firmware devices that support QRTR + mhi_net are detected. --- plugins/udevng.c | 201 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 189 insertions(+), 12 deletions(-) diff --git a/plugins/udevng.c b/plugins/udevng.c index 80a57434de78..d3ce3d5b3f7c 100644 --- a/plugins/udevng.c +++ b/plugins/udevng.c @@ -44,6 +44,7 @@ enum modem_type { MODEM_TYPE_SERIAL, MODEM_TYPE_PCIE, MODEM_TYPE_EMBEDDED, + MODEM_TYPE_MHI, }; struct modem_info { @@ -282,6 +283,9 @@ static int setup_qmi_qrtr(struct modem_info *modem, case MODEM_TYPE_EMBEDDED: ofono_modem_set_string(modem->modem, "Bus", "embedded"); break; + case MODEM_TYPE_MHI: + ofono_modem_set_string(modem->modem, "Bus", "pcie"); + break; case MODEM_TYPE_USB: case MODEM_TYPE_SERIAL: case MODEM_TYPE_PCIE: @@ -1730,6 +1734,42 @@ static gboolean setup_sim76xx(struct modem_info *modem) return TRUE; } +static gboolean setup_mhi(struct modem_info *modem) +{ + const struct device_info *net = NULL; + const struct device_info *qrtr = NULL; + GSList *list; + int r; + + DBG("%s", modem->syspath); + + for (list = modem->devices; list; list = list->next) { + const struct device_info *info = list->data; + const char *subsystem = + udev_device_get_subsystem(info->udev_device); + + DBG("%s", udev_device_get_syspath(info->udev_device)); + + if (l_streq0(udev_device_get_property_value(info->udev_device, + "MODALIAS"), + "mhi:IPCR")) + qrtr = info; + else if (l_streq0(subsystem, "net")) + net = info; + } + + DBG("net: %p, qrtr: %p", net, qrtr); + + if (!net || !qrtr) + return FALSE; + + r = setup_qmi_qrtr(modem, net); + if (r < 0) + return FALSE; + + return TRUE; +} + static struct { const char *name; gboolean (*setup)(struct modem_info *modem); @@ -1772,6 +1812,7 @@ static struct { { "tc65", setup_tc65 }, { "ehs6", setup_ehs6 }, { "gobiqrtr", setup_gobi_qrtr }, + { "mhi", setup_mhi }, { } }; @@ -1823,6 +1864,7 @@ static void destroy_modem(gpointer data) case MODEM_TYPE_USB: case MODEM_TYPE_PCIE: case MODEM_TYPE_EMBEDDED: + case MODEM_TYPE_MHI: for (list = modem->devices; list; list = list->next) { struct device_info *info = list->data; @@ -1854,6 +1896,7 @@ static gboolean check_remove(gpointer key, gpointer value, gpointer user_data) switch (modem->type) { case MODEM_TYPE_USB: case MODEM_TYPE_PCIE: + case MODEM_TYPE_MHI: for (list = modem->devices; list; list = list->next) { struct device_info *info = list->data; const char *syspath = @@ -2315,11 +2358,137 @@ static void check_pci_device(struct udev_device *device) device, kernel_driver); } +static const struct { + const char *driver; + uint16_t vend; + uint16_t dev; + uint16_t subvend; + uint16_t subdev; +} wwan_driver_list[] = { + { "mhi", 0x17cb, 0x0308, }, + { } +}; + +static int parse_pci_id(const char *id, uint16_t *out_vend, uint16_t *out_dev) +{ + _auto_(l_strv_free) char **ids = l_strsplit(id, ':'); + int r; + + if (!ids || !ids[0] || !ids[1] || ids[2]) + return -EINVAL; + + r = l_safe_atox16(ids[0], out_vend); + if (r < 0) + return r; + + r = l_safe_atox16(ids[1], out_dev); + if (r < 0) + return r; + + return 0; +} + +static bool add_mhi_device(struct udev_device *device, + struct udev_device *parent) +{ + const char *syspath; + const char *kernel_driver; + const char *pci_id; + const char *pci_subid; + uint16_t vend, dev, subvend, subdev; + unsigned int i; + + /* Use syspath of the MHI device as the modem path */ + syspath = udev_device_get_syspath(parent); + if (!syspath) + return false; + + kernel_driver = udev_device_get_property_value(device, "ID_NET_DRIVER"); + if (!kernel_driver) + kernel_driver = udev_device_get_driver(device); + + /* vid / pid is on the parent of the MHI device */ + pci_id = udev_device_get_property_value(parent, "PCI_ID"); + pci_subid = udev_device_get_property_value(parent, "PCI_SUBSYS_ID"); + + if (!pci_id || !pci_subid) + return false; + + if (parse_pci_id(pci_id, &vend, &dev) < 0) + return false; + + if (parse_pci_id(pci_subid, &subvend, &subdev) < 0) + return false; + + for (i = 0; wwan_driver_list[i].driver; i++) { + if (wwan_driver_list[i].vend != vend) + continue; + + if (wwan_driver_list[i].dev != dev) + continue; + + if (wwan_driver_list[i].subvend && + wwan_driver_list[i].subvend != subvend) + continue; + + if (wwan_driver_list[i].subdev && + wwan_driver_list[i].subdev != subdev) + continue; + + add_device(syspath, NULL, wwan_driver_list[i].driver, + NULL, NULL, MODEM_TYPE_MHI, + device, kernel_driver); + return true; + } + + return false; +} + +static void check_wwan_device(struct udev_device *device) +{ + struct udev_device *parent; + + parent = udev_device_get_parent_with_subsystem_devtype(device, + "mhi", NULL); + if (!parent) + return; + + /* If this is an MHI device, find the MHI parent */ + parent = udev_device_get_parent(parent); + if (!parent) + return; + + add_mhi_device(device, parent); +} + +static void check_mhi_device(struct udev_device *device) +{ + struct udev_device *parent = + udev_device_get_parent_with_subsystem_devtype(device, + "pci", NULL); + + if (!parent) + return; + + add_mhi_device(device, parent); +} + static void check_net_device(struct udev_device *device) { char path[32]; const char *name; const char *iflink; + struct udev_device *parent; + + parent = udev_device_get_parent(device); + if (parent && l_streq0(udev_device_get_subsystem(parent), "mhi")) { + parent = udev_device_get_parent_with_subsystem_devtype(device, + "pci", NULL); + if (parent) + add_mhi_device(device, parent); + + return; + } name = udev_device_get_sysname(device); if (!l_str_has_prefix(name, "rmnet_")) @@ -2337,25 +2506,29 @@ static void check_net_device(struct udev_device *device) static void check_device(struct udev_device *device) { - const char *bus; + const char *subsystem = udev_device_get_subsystem(device); + const char *bus = udev_device_get_property_value(device, "ID_BUS"); - bus = udev_device_get_property_value(device, "ID_BUS"); - if (bus == NULL) { - bus = udev_device_get_subsystem(device); - if (bus == NULL) - return; + if (l_streq0(subsystem, "net")) { + /* Handle USB-connected network devices in check_usb_device */ + if (l_streq0(bus, "usb")) + check_usb_device(device); + else + check_net_device(device); + + return; } - if ((g_str_equal(bus, "usb") == TRUE) || - (g_str_equal(bus, "usbmisc") == TRUE)) + if (l_streq0(subsystem, "usb") || l_streq0(subsystem, "usbmisc")) check_usb_device(device); - else if (g_str_equal(bus, "pci") == TRUE) + else if (l_streq0(subsystem, "pci")) check_pci_device(device); - else if (g_str_equal(bus, "net") == TRUE) - check_net_device(device); + else if (l_streq0(subsystem, "wwan")) + check_wwan_device(device); + else if (l_streq0(subsystem, "mhi")) + check_mhi_device(device); else add_serial_device(device); - } static gboolean create_modem(gpointer key, gpointer value, gpointer user_data) @@ -2414,6 +2587,8 @@ static void enumerate_devices(struct udev *context) udev_enumerate_add_match_subsystem(enumerate, "net"); udev_enumerate_add_match_subsystem(enumerate, "hsi"); udev_enumerate_add_match_subsystem(enumerate, "pci"); + udev_enumerate_add_match_subsystem(enumerate, "wwan"); + udev_enumerate_add_match_subsystem(enumerate, "mhi"); udev_enumerate_scan_devices(enumerate); @@ -2539,6 +2714,8 @@ static int detect_init(void) "usbmisc", NULL); udev_monitor_filter_add_match_subsystem_devtype(udev_mon, "net", NULL); udev_monitor_filter_add_match_subsystem_devtype(udev_mon, "hsi", NULL); + udev_monitor_filter_add_match_subsystem_devtype(udev_mon, "wwan", NULL); + udev_monitor_filter_add_match_subsystem_devtype(udev_mon, "mhi", NULL); udev_monitor_filter_update(udev_mon); From patchwork Mon May 20 19:17:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13668620 Received: from mail-oo1-f48.google.com (mail-oo1-f48.google.com [209.85.161.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 476171E50B for ; Mon, 20 May 2024 19:17:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716232650; cv=none; b=iOJqLXH9NXZYhUxGzDgf5e1YfTs+nIywvdsKsVqhi/AkCeabCqF2Obh9dYMPQWiKLBBS4gnr3kcaKdUPm13yRJSWKKZ+nbVf0bSNEoavdiveSfQYsNytdI4MSeIQOxPj378K6xyysuYs/bP3Tpg2zrFHtTo5YXWp2liHxbjWpPM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716232650; c=relaxed/simple; bh=utKDdbHSkG+N6iILEJ0Z8fi+EUlATN/9a3nqOgAPScI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oVJU0gXckx8p4X2A3SKt/u8qx/UZd2F+FE8rgeaibCeYUrsio5N47y+ka+YzN2FkK6gNKq5w507wy0j5CKMNM/VGLi63m2EG6NdPfyas9kqYKcYQxUjXU4AcJsYsmIxYKgzjLJD6VpEKyzEpv/esrBJgF9RKKFto/fzWTSobJJA= 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=hLGPJ7Lp; arc=none smtp.client-ip=209.85.161.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="hLGPJ7Lp" Received: by mail-oo1-f48.google.com with SMTP id 006d021491bc7-5b2a66dce8fso2782778eaf.1 for ; Mon, 20 May 2024 12:17:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716232648; x=1716837448; 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=W951dU0+kqSN1FOecQgAXrca1UCpetMYC2XeXRjXzwY=; b=hLGPJ7LpZadvrqG/GIfKVH71WPMLwQ2OhuB9x0XHA+CLngm8BvHWjpaezNHdgjItKe fHxaEI4tcmJG3q5PDOR9vo9C+rhLmTlH1MMn07et3ly2rHPF/LBTpA+NP27Ti4ZwKN6G RX/NKAPN1bnNZacbt1LLTnGgNLP4HA7NAwd/2g9CMGh7lG9nHYldsSIDioULVLeQsTYk 9Zjd00OB+iiiW+wnCGjpga97hUiKwf4l3aN5xB4sMfneEKXe2uzJz1Znv1yd+nzebZSH UAr4ZrpCweNPc2vhDye95euH97lWawJtJo4OhXlB7jGEKt23bYsBwgcHVFUylNpvNwaq N+5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716232648; x=1716837448; 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=W951dU0+kqSN1FOecQgAXrca1UCpetMYC2XeXRjXzwY=; b=YlWHW69TiQt5nRCwmYAmlZjhL25HmjvrjyKliSUpko4IOhocPw0gNGsS+mqJNz1QY/ QICEubJmSdRFhjf/radYst3U+B3yO67h7ignHaqP/XzzsgCEMRiADccWhl5wpriiUHgX ToqoDRPo+cv+zVd37RKZbsxpSt+kvKK2CA89wpL0dbvRoL4mr0+Guv3GRBhl0r4Zp7av oiD7CJZzyMJkSfa/G4q7wOqg0EbgoRKOIQQFQWKc8m33bc1IbeFKOtTbdmQc0Vntfg1P Eq+uNLU3FjgQr1qFaxTuHUnoQMRqZ6f5eWRnbnPIkJk04uhM1VoCdP9VgTzYYVmLbYrp xcqA== X-Gm-Message-State: AOJu0YwvOsm2uDZ2o2VZNJK21Z88YS6+2xEEbYgQdpCBdVFocV9B6NeE QvjjFz5uhLXMwlQNF/iUuBZaEd2bUUdzN1N8b9tq3CDcrZ32krLPo9PX/Q== X-Google-Smtp-Source: AGHT+IE2Hv9bPc58NyYuZY4lcdVEIyD+nc2y0EDjkXN50w79nNatiMtkSRtne5qtYpv39f9PEWOXdQ== X-Received: by 2002:a05:6820:161f:b0:5b2:2b8:e419 with SMTP id 006d021491bc7-5b365c02154mr6584473eaf.0.1716232648386; Mon, 20 May 2024 12:17:28 -0700 (PDT) Received: from localhost.localdomain (syn-070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-5b5390b9c54sm236387eaf.0.2024.05.20.12.17.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 12:17:27 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 6/6] qmi: gprs-context: support bind_mux for pcie devices Date: Mon, 20 May 2024 14:17:07 -0500 Message-ID: <20240520191722.184977-6-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240520191722.184977-1-denkenz@gmail.com> References: <20240520191722.184977-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 PCIe based devices when invoking QMI_WDS_BIND_MUX_DATA_PORT command. While here, also refactor the handling of InterfaceNumber property and make it clear that is is only used for USB based devices. --- drivers/qmimodem/gprs-context.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/drivers/qmimodem/gprs-context.c b/drivers/qmimodem/gprs-context.c index 3a4f2f0717bc..6350d6584d8f 100644 --- a/drivers/qmimodem/gprs-context.c +++ b/drivers/qmimodem/gprs-context.c @@ -525,23 +525,29 @@ static void qmi_gprs_context_bind_mux(struct ofono_gprs_context *gc) goto error; } - interface_number = ofono_modem_get_string(modem, "InterfaceNumber"); - if (!interface_number && endpoint_info.endpoint_type != - QMI_DATA_ENDPOINT_TYPE_EMBEDDED) { - ofono_error("%s: Missing 'InterfaceNumber'", - ofono_modem_get_path(modem)); - goto error; - } else if (!interface_number) - u8 = 1; /* Default for embedded modems */ - else if (l_safe_atox8(interface_number, &u8) < 0) { - ofono_error("%s: Invalid InterfaceNumber", + switch (endpoint_info.endpoint_type) { + case QMI_DATA_ENDPOINT_TYPE_PCIE: + endpoint_info.interface_number = 0x04; /* Magic for PCIE */ + break; + case QMI_DATA_ENDPOINT_TYPE_EMBEDDED: + endpoint_info.interface_number = 0x01; + break; + case QMI_DATA_ENDPOINT_TYPE_HSUSB: + interface_number = ofono_modem_get_string(modem, + "InterfaceNumber"); + if (!l_safe_atox8(interface_number, &u8)) { + endpoint_info.interface_number = u8; + break; + } + + ofono_error("%s: Missing or invalid 'InterfaceNumber'", ofono_modem_get_path(modem)); + /* Fall through */ + default: goto error; } - endpoint_info.interface_number = u8; - - DBG("interface_number: %d", u8); + DBG("interface_number: %d", endpoint_info.interface_number); DBG("mux_id: %hhx", data->mux_id); param = qmi_param_new();