Commit b4d9785c authored by David S. Miller's avatar David S. Miller

Merge branch 'Migrate-QRTR-Nameservice-to-Kernel'

Manivannan Sadhasivam says:

====================
Migrate QRTR Nameservice to Kernel

This patchset migrates the Qualcomm IPC Router (QRTR) Nameservice from userspace
to kernel under net/qrtr.

The userspace implementation of it can be found here:
https://github.com/andersson/qrtr/blob/master/src/ns.c

This change is required for enabling the WiFi functionality of some Qualcomm
WLAN devices using ATH11K without any dependency on a userspace daemon. Since
the QRTR NS is not usually packed in most of the distros, users need to clone,
build and install it to get the WiFi working. It will become a hassle when the
user doesn't have any other source of network connectivity.

The original userspace code is published under BSD3 license. For migrating it
to Linux kernel, I have adapted Dual BSD/GPL license.

This patchset has been verified on Dragonboard410c and Intel NUC with QCA6390
WLAN device.

Changes in v2:

* Sorted the local variables in reverse XMAS tree order
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents cd26d72d 31d6cbee
# SPDX-License-Identifier: GPL-2.0-only # SPDX-License-Identifier: GPL-2.0-only
obj-$(CONFIG_QRTR) := qrtr.o obj-$(CONFIG_QRTR) := qrtr.o ns.o
obj-$(CONFIG_QRTR_SMD) += qrtr-smd.o obj-$(CONFIG_QRTR_SMD) += qrtr-smd.o
qrtr-smd-y := smd.o qrtr-smd-y := smd.o
......
This diff is collapsed.
...@@ -7,9 +7,9 @@ ...@@ -7,9 +7,9 @@
#include <linux/netlink.h> #include <linux/netlink.h>
#include <linux/qrtr.h> #include <linux/qrtr.h>
#include <linux/termios.h> /* For TIOCINQ/OUTQ */ #include <linux/termios.h> /* For TIOCINQ/OUTQ */
#include <linux/numa.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/wait.h> #include <linux/wait.h>
#include <linux/workqueue.h>
#include <net/sock.h> #include <net/sock.h>
...@@ -96,7 +96,7 @@ static inline struct qrtr_sock *qrtr_sk(struct sock *sk) ...@@ -96,7 +96,7 @@ static inline struct qrtr_sock *qrtr_sk(struct sock *sk)
return container_of(sk, struct qrtr_sock, sk); return container_of(sk, struct qrtr_sock, sk);
} }
static unsigned int qrtr_local_nid = NUMA_NO_NODE; static unsigned int qrtr_local_nid = 1;
/* for node ids */ /* for node ids */
static RADIX_TREE(qrtr_nodes, GFP_ATOMIC); static RADIX_TREE(qrtr_nodes, GFP_ATOMIC);
...@@ -110,6 +110,8 @@ static DEFINE_MUTEX(qrtr_node_lock); ...@@ -110,6 +110,8 @@ static DEFINE_MUTEX(qrtr_node_lock);
static DEFINE_IDR(qrtr_ports); static DEFINE_IDR(qrtr_ports);
static DEFINE_MUTEX(qrtr_port_lock); static DEFINE_MUTEX(qrtr_port_lock);
static struct delayed_work qrtr_ns_work;
/** /**
* struct qrtr_node - endpoint node * struct qrtr_node - endpoint node
* @ep_lock: lock for endpoint management and callbacks * @ep_lock: lock for endpoint management and callbacks
...@@ -1241,38 +1243,6 @@ static int qrtr_create(struct net *net, struct socket *sock, ...@@ -1241,38 +1243,6 @@ static int qrtr_create(struct net *net, struct socket *sock,
return 0; return 0;
} }
static const struct nla_policy qrtr_policy[IFA_MAX + 1] = {
[IFA_LOCAL] = { .type = NLA_U32 },
};
static int qrtr_addr_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
struct netlink_ext_ack *extack)
{
struct nlattr *tb[IFA_MAX + 1];
struct ifaddrmsg *ifm;
int rc;
if (!netlink_capable(skb, CAP_NET_ADMIN))
return -EPERM;
if (!netlink_capable(skb, CAP_SYS_ADMIN))
return -EPERM;
ASSERT_RTNL();
rc = nlmsg_parse_deprecated(nlh, sizeof(*ifm), tb, IFA_MAX,
qrtr_policy, extack);
if (rc < 0)
return rc;
ifm = nlmsg_data(nlh);
if (!tb[IFA_LOCAL])
return -EINVAL;
qrtr_local_nid = nla_get_u32(tb[IFA_LOCAL]);
return 0;
}
static const struct net_proto_family qrtr_family = { static const struct net_proto_family qrtr_family = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.family = AF_QIPCRTR, .family = AF_QIPCRTR,
...@@ -1293,11 +1263,11 @@ static int __init qrtr_proto_init(void) ...@@ -1293,11 +1263,11 @@ static int __init qrtr_proto_init(void)
return rc; return rc;
} }
rc = rtnl_register_module(THIS_MODULE, PF_QIPCRTR, RTM_NEWADDR, qrtr_addr_doit, NULL, 0); /* FIXME: Currently, this 2s delay is required to catch the NEW_SERVER
if (rc) { * messages from routers. But the fix could be somewhere else.
sock_unregister(qrtr_family.family); */
proto_unregister(&qrtr_proto); INIT_DELAYED_WORK(&qrtr_ns_work, qrtr_ns_init);
} schedule_delayed_work(&qrtr_ns_work, msecs_to_jiffies(2000));
return rc; return rc;
} }
...@@ -1305,7 +1275,8 @@ postcore_initcall(qrtr_proto_init); ...@@ -1305,7 +1275,8 @@ postcore_initcall(qrtr_proto_init);
static void __exit qrtr_proto_fini(void) static void __exit qrtr_proto_fini(void)
{ {
rtnl_unregister(PF_QIPCRTR, RTM_NEWADDR); cancel_delayed_work_sync(&qrtr_ns_work);
qrtr_ns_remove();
sock_unregister(qrtr_family.family); sock_unregister(qrtr_family.family);
proto_unregister(&qrtr_proto); proto_unregister(&qrtr_proto);
} }
......
...@@ -29,4 +29,8 @@ void qrtr_endpoint_unregister(struct qrtr_endpoint *ep); ...@@ -29,4 +29,8 @@ void qrtr_endpoint_unregister(struct qrtr_endpoint *ep);
int qrtr_endpoint_post(struct qrtr_endpoint *ep, const void *data, size_t len); int qrtr_endpoint_post(struct qrtr_endpoint *ep, const void *data, size_t len);
void qrtr_ns_init(struct work_struct *work);
void qrtr_ns_remove(void);
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment