summaryrefslogtreecommitdiffstats
path: root/sys/compat
diff options
context:
space:
mode:
authorhselasky <hselasky@FreeBSD.org>2016-01-08 10:04:19 +0000
committerhselasky <hselasky@FreeBSD.org>2016-01-08 10:04:19 +0000
commitd1f61053c33f953ac5dfa5ed62f1b79965c662fb (patch)
treeb9bc3442819e3699cf586d3977afe2196a1fbe6a /sys/compat
parent3b77b5c8be948152c705ae667bce31c6cd5ed1bc (diff)
downloadFreeBSD-src-d1f61053c33f953ac5dfa5ed62f1b79965c662fb.zip
FreeBSD-src-d1f61053c33f953ac5dfa5ed62f1b79965c662fb.tar.gz
LinuxKPI style changes:
- Properly prefix internal functions with "linux_" instead of only a single underscore to avoid future namespace collisions. - Make some functions global instead of inline to ease debugging and to avoid unnecessary code duplication. - Remove no longer existing kthread_create() function's prototype. MFC after: 1 week Sponsored by: Mellanox Technologies
Diffstat (limited to 'sys/compat')
-rw-r--r--sys/compat/linuxkpi/common/include/linux/gfp.h8
-rw-r--r--sys/compat/linuxkpi/common/include/linux/interrupt.h23
-rw-r--r--sys/compat/linuxkpi/common/include/linux/kthread.h13
-rw-r--r--sys/compat/linuxkpi/common/include/linux/netdevice.h103
-rw-r--r--sys/compat/linuxkpi/common/src/linux_compat.c109
5 files changed, 130 insertions, 126 deletions
diff --git a/sys/compat/linuxkpi/common/include/linux/gfp.h b/sys/compat/linuxkpi/common/include/linux/gfp.h
index a82f30d..38a0222 100644
--- a/sys/compat/linuxkpi/common/include/linux/gfp.h
+++ b/sys/compat/linuxkpi/common/include/linux/gfp.h
@@ -66,15 +66,15 @@ page_address(struct page *page)
}
static inline unsigned long
-_get_page(gfp_t mask)
+linux_get_page(gfp_t mask)
{
return kmem_malloc(kmem_arena, PAGE_SIZE, mask);
}
-#define get_zeroed_page(mask) _get_page((mask) | M_ZERO)
-#define alloc_page(mask) virt_to_page(_get_page((mask)))
-#define __get_free_page(mask) _get_page((mask))
+#define get_zeroed_page(mask) linux_get_page((mask) | M_ZERO)
+#define alloc_page(mask) virt_to_page(linux_get_page((mask)))
+#define __get_free_page(mask) linux_get_page((mask))
static inline void
free_page(unsigned long page)
diff --git a/sys/compat/linuxkpi/common/include/linux/interrupt.h b/sys/compat/linuxkpi/common/include/linux/interrupt.h
index d33a3b0..dd943e3 100644
--- a/sys/compat/linuxkpi/common/include/linux/interrupt.h
+++ b/sys/compat/linuxkpi/common/include/linux/interrupt.h
@@ -54,24 +54,17 @@ struct irq_ent {
};
static inline int
-_irq_rid(struct device *dev, int irq)
+linux_irq_rid(struct device *dev, int irq)
{
if (irq == dev->irq)
return (0);
return irq - dev->msix + 1;
}
-static inline void
-_irq_handler(void *ent)
-{
- struct irq_ent *irqe;
-
- irqe = ent;
- irqe->handler(irqe->irq, irqe->arg);
-}
+extern void linux_irq_handler(void *);
static inline struct irq_ent *
-_irq_ent(struct device *dev, int irq)
+linux_irq_ent(struct device *dev, int irq)
{
struct irq_ent *irqe;
@@ -95,7 +88,7 @@ request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags,
dev = _pci_find_irq_dev(irq);
if (dev == NULL)
return -ENXIO;
- rid = _irq_rid(dev, irq);
+ rid = linux_irq_rid(dev, irq);
res = bus_alloc_resource_any(dev->bsddev, SYS_RES_IRQ, &rid,
flags | RF_ACTIVE);
if (res == NULL)
@@ -107,7 +100,7 @@ request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags,
irqe->handler = handler;
irqe->irq = irq;
error = bus_setup_intr(dev->bsddev, res, INTR_TYPE_NET | INTR_MPSAFE,
- NULL, _irq_handler, irqe, &irqe->tag);
+ NULL, linux_irq_handler, irqe, &irqe->tag);
if (error) {
bus_release_resource(dev->bsddev, SYS_RES_IRQ, rid, irqe->res);
kfree(irqe);
@@ -128,7 +121,7 @@ bind_irq_to_cpu(unsigned int irq, int cpu_id)
if (dev == NULL)
return (-ENOENT);
- irqe = _irq_ent(dev, irq);
+ irqe = linux_irq_ent(dev, irq);
if (irqe == NULL)
return (-ENOENT);
@@ -145,8 +138,8 @@ free_irq(unsigned int irq, void *device)
dev = _pci_find_irq_dev(irq);
if (dev == NULL)
return;
- rid = _irq_rid(dev, irq);
- irqe = _irq_ent(dev, irq);
+ rid = linux_irq_rid(dev, irq);
+ irqe = linux_irq_ent(dev, irq);
if (irqe == NULL)
return;
bus_teardown_intr(dev->bsddev, irqe->res, irqe->tag);
diff --git a/sys/compat/linuxkpi/common/include/linux/kthread.h b/sys/compat/linuxkpi/common/include/linux/kthread.h
index fa8e9ba..f85a3f4 100644
--- a/sys/compat/linuxkpi/common/include/linux/kthread.h
+++ b/sys/compat/linuxkpi/common/include/linux/kthread.h
@@ -42,7 +42,7 @@
#include <linux/sched.h>
static inline void
-_kthread_fn(void *arg)
+linux_kthread_fn(void *arg)
{
struct task_struct *task;
@@ -58,7 +58,7 @@ _kthread_fn(void *arg)
}
static inline struct task_struct *
-_kthread_create(int (*threadfn)(void *data), void *data)
+linux_kthread_create(int (*threadfn)(void *data), void *data)
{
struct task_struct *task;
@@ -69,17 +69,12 @@ _kthread_create(int (*threadfn)(void *data), void *data)
return (task);
}
-struct task_struct *kthread_create(int (*threadfn)(void *data),
- void *data,
- const char namefmt[], ...)
- __attribute__((format(printf, 3, 4)));
-
#define kthread_run(fn, data, fmt, ...) \
({ \
struct task_struct *_task; \
\
- _task = _kthread_create((fn), (data)); \
- if (kthread_add(_kthread_fn, _task, NULL, &_task->task_thread, \
+ _task = linux_kthread_create((fn), (data)); \
+ if (kthread_add(linux_kthread_fn, _task, NULL, &_task->task_thread, \
0, 0, fmt, ## __VA_ARGS__)) { \
kfree(_task); \
_task = NULL; \
diff --git a/sys/compat/linuxkpi/common/include/linux/netdevice.h b/sys/compat/linuxkpi/common/include/linux/netdevice.h
index 1b1f8bf..1d50ac1 100644
--- a/sys/compat/linuxkpi/common/include/linux/netdevice.h
+++ b/sys/compat/linuxkpi/common/include/linux/netdevice.h
@@ -2,7 +2,7 @@
* Copyright (c) 2010 Isilon Systems, Inc.
* Copyright (c) 2010 iX Systems, Inc.
* Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
+ * Copyright (c) 2013-2016 Mellanox Technologies, Ltd.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -69,103 +69,10 @@ netdev_priv(const struct net_device *dev)
return (dev->if_softc);
}
-static inline void
-_handle_ifnet_link_event(void *arg, struct ifnet *ifp, int linkstate)
-{
- struct notifier_block *nb;
-
- nb = arg;
- if (linkstate == LINK_STATE_UP)
- nb->notifier_call(nb, NETDEV_UP, ifp);
- else
- nb->notifier_call(nb, NETDEV_DOWN, ifp);
-}
-
-static inline void
-_handle_ifnet_arrival_event(void *arg, struct ifnet *ifp)
-{
- struct notifier_block *nb;
-
- nb = arg;
- nb->notifier_call(nb, NETDEV_REGISTER, ifp);
-}
-
-static inline void
-_handle_ifnet_departure_event(void *arg, struct ifnet *ifp)
-{
- struct notifier_block *nb;
-
- nb = arg;
- nb->notifier_call(nb, NETDEV_UNREGISTER, ifp);
-}
-
-static inline void
-_handle_iflladdr_event(void *arg, struct ifnet *ifp)
-{
- struct notifier_block *nb;
-
- nb = arg;
- nb->notifier_call(nb, NETDEV_CHANGEADDR, ifp);
-}
-
-static inline void
-_handle_ifaddr_event(void *arg, struct ifnet *ifp)
-{
- struct notifier_block *nb;
-
- nb = arg;
- nb->notifier_call(nb, NETDEV_CHANGEIFADDR, ifp);
-}
-
-static inline int
-register_netdevice_notifier(struct notifier_block *nb)
-{
-
- nb->tags[NETDEV_UP] = EVENTHANDLER_REGISTER(
- ifnet_link_event, _handle_ifnet_link_event, nb, 0);
- nb->tags[NETDEV_REGISTER] = EVENTHANDLER_REGISTER(
- ifnet_arrival_event, _handle_ifnet_arrival_event, nb, 0);
- nb->tags[NETDEV_UNREGISTER] = EVENTHANDLER_REGISTER(
- ifnet_departure_event, _handle_ifnet_departure_event, nb, 0);
- nb->tags[NETDEV_CHANGEADDR] = EVENTHANDLER_REGISTER(
- iflladdr_event, _handle_iflladdr_event, nb, 0);
-
- return (0);
-}
-
-static inline int
-register_inetaddr_notifier(struct notifier_block *nb)
-{
-
- nb->tags[NETDEV_CHANGEIFADDR] = EVENTHANDLER_REGISTER(
- ifaddr_event, _handle_ifaddr_event, nb, 0);
- return (0);
-}
-
-static inline int
-unregister_netdevice_notifier(struct notifier_block *nb)
-{
-
- EVENTHANDLER_DEREGISTER(ifnet_link_event, nb->tags[NETDEV_UP]);
- EVENTHANDLER_DEREGISTER(ifnet_arrival_event, nb->tags[NETDEV_REGISTER]);
- EVENTHANDLER_DEREGISTER(ifnet_departure_event,
- nb->tags[NETDEV_UNREGISTER]);
- EVENTHANDLER_DEREGISTER(iflladdr_event,
- nb->tags[NETDEV_CHANGEADDR]);
-
- return (0);
-}
-
-static inline int
-unregister_inetaddr_notifier(struct notifier_block *nb)
-{
-
- EVENTHANDLER_DEREGISTER(ifaddr_event,
- nb->tags[NETDEV_CHANGEIFADDR]);
-
- return (0);
-}
-
+int register_netdevice_notifier(struct notifier_block *);
+int register_inetaddr_notifier(struct notifier_block *);
+int unregister_netdevice_notifier(struct notifier_block *);
+int unregister_inetaddr_notifier(struct notifier_block *);
#define rtnl_lock()
#define rtnl_unlock()
diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c
index efda788..56080a4 100644
--- a/sys/compat/linuxkpi/common/src/linux_compat.c
+++ b/sys/compat/linuxkpi/common/src/linux_compat.c
@@ -66,6 +66,7 @@ __FBSDID("$FreeBSD$");
#include <linux/timer.h>
#include <linux/workqueue.h>
#include <linux/rcupdate.h>
+#include <linux/interrupt.h>
#include <vm/vm_pager.h>
@@ -1139,6 +1140,114 @@ const struct kobj_type linux_cdev_static_ktype = {
};
static void
+linux_handle_ifnet_link_event(void *arg, struct ifnet *ifp, int linkstate)
+{
+ struct notifier_block *nb;
+
+ nb = arg;
+ if (linkstate == LINK_STATE_UP)
+ nb->notifier_call(nb, NETDEV_UP, ifp);
+ else
+ nb->notifier_call(nb, NETDEV_DOWN, ifp);
+}
+
+static void
+linux_handle_ifnet_arrival_event(void *arg, struct ifnet *ifp)
+{
+ struct notifier_block *nb;
+
+ nb = arg;
+ nb->notifier_call(nb, NETDEV_REGISTER, ifp);
+}
+
+static void
+linux_handle_ifnet_departure_event(void *arg, struct ifnet *ifp)
+{
+ struct notifier_block *nb;
+
+ nb = arg;
+ nb->notifier_call(nb, NETDEV_UNREGISTER, ifp);
+}
+
+static void
+linux_handle_iflladdr_event(void *arg, struct ifnet *ifp)
+{
+ struct notifier_block *nb;
+
+ nb = arg;
+ nb->notifier_call(nb, NETDEV_CHANGEADDR, ifp);
+}
+
+static void
+linux_handle_ifaddr_event(void *arg, struct ifnet *ifp)
+{
+ struct notifier_block *nb;
+
+ nb = arg;
+ nb->notifier_call(nb, NETDEV_CHANGEIFADDR, ifp);
+}
+
+int
+register_netdevice_notifier(struct notifier_block *nb)
+{
+
+ nb->tags[NETDEV_UP] = EVENTHANDLER_REGISTER(
+ ifnet_link_event, linux_handle_ifnet_link_event, nb, 0);
+ nb->tags[NETDEV_REGISTER] = EVENTHANDLER_REGISTER(
+ ifnet_arrival_event, linux_handle_ifnet_arrival_event, nb, 0);
+ nb->tags[NETDEV_UNREGISTER] = EVENTHANDLER_REGISTER(
+ ifnet_departure_event, linux_handle_ifnet_departure_event, nb, 0);
+ nb->tags[NETDEV_CHANGEADDR] = EVENTHANDLER_REGISTER(
+ iflladdr_event, linux_handle_iflladdr_event, nb, 0);
+
+ return (0);
+}
+
+int
+register_inetaddr_notifier(struct notifier_block *nb)
+{
+
+ nb->tags[NETDEV_CHANGEIFADDR] = EVENTHANDLER_REGISTER(
+ ifaddr_event, linux_handle_ifaddr_event, nb, 0);
+ return (0);
+}
+
+int
+unregister_netdevice_notifier(struct notifier_block *nb)
+{
+
+ EVENTHANDLER_DEREGISTER(ifnet_link_event,
+ nb->tags[NETDEV_UP]);
+ EVENTHANDLER_DEREGISTER(ifnet_arrival_event,
+ nb->tags[NETDEV_REGISTER]);
+ EVENTHANDLER_DEREGISTER(ifnet_departure_event,
+ nb->tags[NETDEV_UNREGISTER]);
+ EVENTHANDLER_DEREGISTER(iflladdr_event,
+ nb->tags[NETDEV_CHANGEADDR]);
+
+ return (0);
+}
+
+int
+unregister_inetaddr_notifier(struct notifier_block *nb)
+{
+
+ EVENTHANDLER_DEREGISTER(ifaddr_event,
+ nb->tags[NETDEV_CHANGEIFADDR]);
+
+ return (0);
+}
+
+void
+linux_irq_handler(void *ent)
+{
+ struct irq_ent *irqe;
+
+ irqe = ent;
+ irqe->handler(irqe->irq, irqe->arg);
+}
+
+static void
linux_compat_init(void *arg)
{
struct sysctl_oid *rootoid;
OpenPOWER on IntegriCloud