diff mbox series

[3/6] gobi: ensure required properties are provided

Message ID 20240520191722.184977-3-denkenz@gmail.com (mailing list archive)
State Accepted
Commit b3ff67d78830d372e657173fb393379308c38e12
Headers show
Series [1/6] gobi: add / use DeviceProtocol property | expand

Commit Message

Denis Kenzior May 20, 2024, 7:17 p.m. UTC
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 mbox series

Patch

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);