diff mbox series

[1/8] rmnet: Add skeleton

Message ID 20241115220053.49613-1-denkenz@gmail.com (mailing list archive)
State Superseded
Headers show
Series [1/8] rmnet: Add skeleton | expand

Commit Message

Denis Kenzior Nov. 15, 2024, 10 p.m. UTC
Add skeleton of the RMNet interface management module.  Implement the
basic API structure and register the module with oFono core.
---
 Makefile.am |  2 ++
 src/rmnet.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/rmnet.h | 25 +++++++++++++++++++++++
 3 files changed, 86 insertions(+)
 create mode 100644 src/rmnet.c
 create mode 100644 src/rmnet.h

Comments

Marcel Holtmann Nov. 16, 2024, 6:07 p.m. UTC | #1
Hi Denis,

> Add skeleton of the RMNet interface management module.  Implement the
> basic API structure and register the module with oFono core.
> ---
> Makefile.am |  2 ++
> src/rmnet.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> src/rmnet.h | 25 +++++++++++++++++++++++
> 3 files changed, 86 insertions(+)
> create mode 100644 src/rmnet.c
> create mode 100644 src/rmnet.h
> 
> diff --git a/Makefile.am b/Makefile.am
> index d379201d362b..d107dc410fd2 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -353,6 +353,8 @@ builtin_sources += plugins/u8500.c
> endif
> 
> if QMIMODEM
> +builtin_sources += src/rmnet.h src/rmnet.c
> +
> qmi_sources = drivers/qmimodem/qmi.h drivers/qmimodem/qmi.c \
> drivers/qmimodem/ctl.h \
> drivers/qmimodem/dms.h \

does this make really sense? Putting this into drivers/qmimodem/rmnet.c is not possible?

We might actually need a generic abstraction for del_interface / add_interface and allow for drivers to register their implementation for it, but that is a different story.

Regards

Marcel
Denis Kenzior Nov. 18, 2024, 4:38 a.m. UTC | #2
Hi Marcel,

 >
> does this make really sense? Putting this into drivers/qmimodem/rmnet.c is not possible?
> 

I switched most of the atom drivers to use the OFONO_ATOM_DRIVER_BUILTIN macro. 
The drivers that performed static initialization during 'plugin_init' using 
OFONO_PLUGIN_DEFINE went *poof*, including qmimodem.  Only individual atom 
drivers remain.  There is one straggler, namely drivers/stemodem/stemodem.c. 
That one does something somewhat similar in drivers/stemodem/caif_rtnl.c.

Similarly, for modem drivers, OFONO_MODEM_DRIVER_BUILTIN was introduced.  This 
leaves only a few users of OFONO_PLUGIN_DEFINE.  Longer term I'd like to get rid 
of the whole plugin concept.  However, it still leaves the open question of what 
to do with code that requires plugin_init / plugin_exit style static 
initialization.  Easiest way is to convert such users to core modules, like I do 
with rmnet here, but I'm open to suggestions.

> We might actually need a generic abstraction for del_interface / add_interface and allow for drivers to register their implementation for it, but that is a different story.

Yes, true.  This will surely come up with MBIM.

On another note, I was thinking of eventually moving transport implementations 
into src/ or transport/ to allow easier mixing, e.g. running QMI over MBIM, or 
AT commands over QMI, etc.

Regards,
-Denis
diff mbox series

Patch

diff --git a/Makefile.am b/Makefile.am
index d379201d362b..d107dc410fd2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -353,6 +353,8 @@  builtin_sources += plugins/u8500.c
 endif
 
 if QMIMODEM
+builtin_sources += src/rmnet.h src/rmnet.c
+
 qmi_sources = drivers/qmimodem/qmi.h drivers/qmimodem/qmi.c \
 					drivers/qmimodem/ctl.h \
 					drivers/qmimodem/dms.h \
diff --git a/src/rmnet.c b/src/rmnet.c
new file mode 100644
index 000000000000..58f841a49a59
--- /dev/null
+++ b/src/rmnet.c
@@ -0,0 +1,59 @@ 
+/*
+ *  oFono - Open Source Telephony
+ *  Copyright (C) 2024  Cruise, LLC
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stddef.h>
+#include <errno.h>
+#include <unistd.h>
+#include <linux/rtnetlink.h>
+#include <net/if.h>
+
+#include <ell/ell.h>
+
+#include "ofono.h"
+#include "rmnet.h"
+
+static struct l_netlink *rtnl;
+
+int rmnet_get_interfaces(uint32_t parent_ifindex, unsigned int n_interfaces,
+				rmnet_new_interfaces_func_t cb,
+				void *user_data, rmnet_destroy_func_t destroy)
+{
+	return -ENOTSUP;
+}
+
+int rmnet_del_interfaces(unsigned int n_interfaces,
+					const struct rmnet_ifinfo *interfaces)
+{
+	return -ENOTSUP;
+}
+
+int rmnet_cancel(int id)
+{
+	return -ENOTSUP;
+}
+
+static int rmnet_init(void)
+{
+	DBG("");
+
+	rtnl = l_netlink_new(NETLINK_ROUTE);
+	if (!rtnl)
+		return -EIO;
+
+	return 0;
+}
+
+static void rmnet_exit(void)
+{
+	l_netlink_destroy(rtnl);
+}
+
+OFONO_MODULE(rmnet, rmnet_init, rmnet_exit)
diff --git a/src/rmnet.h b/src/rmnet.h
new file mode 100644
index 000000000000..dc416e0d5d51
--- /dev/null
+++ b/src/rmnet.h
@@ -0,0 +1,25 @@ 
+/*
+ *  oFono - Open Source Telephony
+ *  Copyright (C) 2024  Cruise, LLC
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+struct rmnet_ifinfo {
+	uint32_t ifindex;
+	uint16_t mux_id;
+	char ifname[IF_NAMESIZE];
+};
+
+typedef void (*rmnet_new_interfaces_func_t)(int error,
+					unsigned int n_interfaces,
+					const struct rmnet_ifinfo *interfaces,
+					void *user_data);
+typedef void (*rmnet_destroy_func_t)(void *user_data);
+
+int rmnet_get_interfaces(uint32_t parent_ifindex, unsigned int n_interfaces,
+				rmnet_new_interfaces_func_t cb,
+				void *user_data, rmnet_destroy_func_t destroy);
+int rmnet_del_interfaces(unsigned int n_interfaces,
+					const struct rmnet_ifinfo *interfaces);
+int rmnet_cancel(int id);