From nobody Wed Jan 18 16:25:07 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4NxrhN40jwz2yJd7; Wed, 18 Jan 2023 16:25:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NxrhN04Yhz3FXh; Wed, 18 Jan 2023 16:25:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674059108; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ObEUu1q3zMhOTTP5ZB4vVOK+mi/Wp/PmzrE440y/ZkM=; b=VXoYreCT8STFyFff3arTwUAj3ecEAUEUt4Wa9RkijQYyLJPppDTQIo1a0brYC99Kkxo2zl xS5pHK47rpvI5/LL4Zw9BYZR4FgqIMlF6a2sHj97h7sYB/2ir2R3EEY1bJM3Kb8WpRng/s a3NznXhZ+YgPLWxiKAeJ6Nf546+y1cyDTcnzwXUo6MI1vRvnEf3MBwEx7td3q0BvY+Sr4k HcRc8X4DHkUgWdvl50zw/b6/RYqHjqA38hnXgoJXZnN1B1eO6SUI3rfh1XndHWdXO+6nnP FAVV3/kMWHuGKRcuh8fyYRJDWsuTFL4ju9TUs+vCsn4z5vy5NnDX8wsJ7SXFGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674059108; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ObEUu1q3zMhOTTP5ZB4vVOK+mi/Wp/PmzrE440y/ZkM=; b=oIvzxuRKXpYs0PiAove+0QpnRE3/lZ8c5rojuagCCiIzqevo1CmjaDgmNo73f1ZJapjL9k QmdLYmBNdgPyMYXU6LNEX61oc88/mRUWr4TmUYfYrbTMSaSvvjPrRYr9LE3wh/xqc9kNwK J2twHq6PbL3U21YskGsLFKTh5Zczzf7BZHwyiZYicssdcLVZ+uuDX7PePl1M2rSh2PO6cv T+QWQ1qbvzKo55iPE6H66heO2Zgs8U8noR5oKao8/XmLoIZ1/nrW2VuYgoNEiZmAyer+uB AuNDaKMQCeQQKLrPV1Xmlg4+d94VVdvS4gAsQYdLwOO6bvjJ6UrsAGCCmXQiLg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674059108; a=rsa-sha256; cv=none; b=JIE3cdBk+5SVO3/V4Q8GRKU/srWmEqWnucc+WAYYb6wowHCRPRBVEsUPn3CO/UvJhRtH2p cZR7m4az3OMIY+4mWp1ccQ3JlYKcCN9/v29zvSWpvV9eSWSLr0v3vJHXAXV8SGgf2cNSjl mM7/WHaa5f8fQmtbiaYfOeXHgVdOrbB+gUFDVda7sW+mRZjns3nhZZFWC/PXJXU718w9Eg 1peRmD1yVoEjxPih30ofML83dtKHj0c3lQLfW6KycGtnmU0h5vKke/l4jQtXGSY81CKrqf Pty3OTPTtPkR1cauol0p4l/IsYMD17bK7oiDa85mVr08UsofFSocrK8Q3Nkj3Q== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4NxrhM4jgbzJ3f; Wed, 18 Jan 2023 16:25:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 30IGP7D8038362; Wed, 18 Jan 2023 16:25:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30IGP73A038361; Wed, 18 Jan 2023 16:25:07 GMT (envelope-from git) Date: Wed, 18 Jan 2023 16:25:07 GMT Message-Id: <202301181625.30IGP73A038361@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 649f21d4d7a8 - stable/13 - LinuxKPI: add (skeleton) functions to make drivers compile List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 649f21d4d7a838acfa36925c717ce99df33c9c9f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=649f21d4d7a838acfa36925c717ce99df33c9c9f commit 649f21d4d7a838acfa36925c717ce99df33c9c9f Author: Bjoern A. Zeeb AuthorDate: 2022-12-03 23:00:04 +0000 Commit: Bjoern A. Zeeb CommitDate: 2023-01-18 13:26:55 +0000 LinuxKPI: add (skeleton) functions to make drivers compile Add more functions to netdevice.h (netif_napi_add_tx() being the only one implemented) and add platform_device.h and netlink.h in order to make driver code compile. The skeleton functions are used only in very limited scope and not at all in our usage so far but add (invasive) #ifdef if removed. Add pr_debug() calls to each of them in order to log a TODO (if DEBUG compiled in) and someone should hit them in the future. Commented on by: hselasky (earlier version) Differential Revision: https://reviews.freebsd.org/D37599 (cherry picked from commit 75388b9ca5e566fb7cbd62a37cea1f66d8203fc6) --- .../linuxkpi/common/include/linux/netdevice.h | 132 +++++++++++++++++++++ .../common/include/linux/platform_device.h | 79 ++++++++++++ sys/compat/linuxkpi/common/include/net/netlink.h | 53 +++++++++ 3 files changed, 264 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/netdevice.h b/sys/compat/linuxkpi/common/include/linux/netdevice.h index fdfd650a55e5..8653b5df68bd 100644 --- a/sys/compat/linuxkpi/common/include/linux/netdevice.h +++ b/sys/compat/linuxkpi/common/include/linux/netdevice.h @@ -53,6 +53,7 @@ #include #include +#include #include #include #include @@ -134,6 +135,7 @@ struct net_device { /* Not properly typed as-of now. */ int flags, type; int name_assign_type, needed_headroom; + int threaded; void (*priv_destructor)(struct net_device *); @@ -266,6 +268,15 @@ void linuxkpi_napi_synchronize(struct napi_struct *); #define napi_synchronize(_n) \ linuxkpi_napi_synchronize(_n) + +static inline void +netif_napi_add_tx(struct net_device *dev, struct napi_struct *napi, + int(*napi_poll)(struct napi_struct *, int)) +{ + + netif_napi_add(dev, napi, napi_poll); +} + /* -------------------------------------------------------------------------- */ static inline void @@ -308,6 +319,126 @@ synchronize_net(void) synchronize_rcu(); } +static __inline void +netif_receive_skb_list(struct list_head *head) +{ + + pr_debug("%s: TODO\n", __func__); +} + +static __inline int +napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb) +{ + + pr_debug("%s: TODO\n", __func__); + return (-1); +} + +static __inline void +ether_setup(struct net_device *ndev) +{ + + pr_debug("%s: TODO\n", __func__); +} + +static __inline void +dev_net_set(struct net_device *dev, void *p) +{ + + pr_debug("%s: TODO\n", __func__); +} + +/* -------------------------------------------------------------------------- */ + +static __inline bool +netif_carrier_ok(struct net_device *ndev) +{ + pr_debug("%s: TODO\n", __func__); + return (false); +} + +static __inline void +netif_carrier_off(struct net_device *ndev) +{ + pr_debug("%s: TODO\n", __func__); +} + +static __inline void +netif_carrier_on(struct net_device *ndev) +{ + pr_debug("%s: TODO\n", __func__); +} + +/* -------------------------------------------------------------------------- */ + +static __inline bool +netif_queue_stopped(struct net_device *ndev) +{ + pr_debug("%s: TODO\n", __func__); + return (false); +} + +static __inline void +netif_stop_queue(struct net_device *ndev) +{ + pr_debug("%s: TODO\n", __func__); +} + +static __inline void +netif_wake_queue(struct net_device *ndev) +{ + pr_debug("%s: TODO\n", __func__); +} + +/* -------------------------------------------------------------------------- */ + +static __inline int +register_netdevice(struct net_device *ndev) +{ + + /* assert rtnl_locked? */ + pr_debug("%s: TODO\n", __func__); + return (0); +} + +static __inline int +register_netdev(struct net_device *ndev) +{ + int error; + + /* lock */ + error = register_netdevice(ndev); + /* unlock */ + pr_debug("%s: TODO\n", __func__); + return (error); +} + +static __inline void +unregister_netdev(struct net_device *ndev) +{ + pr_debug("%s: TODO\n", __func__); +} + +static __inline void +unregister_netdevice(struct net_device *ndev) +{ + pr_debug("%s: TODO\n", __func__); +} + +/* -------------------------------------------------------------------------- */ + +static __inline void +netif_rx(struct sk_buff *skb) +{ + pr_debug("%s: TODO\n", __func__); +} + +static __inline void +netif_rx_ni(struct sk_buff *skb) +{ + pr_debug("%s: TODO\n", __func__); +} + /* -------------------------------------------------------------------------- */ struct net_device *linuxkpi_alloc_netdev(size_t, const char *, uint32_t, @@ -331,5 +462,6 @@ netdev_priv(const struct net_device *ndev) #define rtnl_lock() do { } while(0) #define rtnl_unlock() do { } while(0) +#define rcu_dereference_rtnl(x) READ_ONCE(x) #endif /* _LINUXKPI_LINUX_NETDEVICE_H */ diff --git a/sys/compat/linuxkpi/common/include/linux/platform_device.h b/sys/compat/linuxkpi/common/include/linux/platform_device.h new file mode 100644 index 000000000000..f07b5aac967b --- /dev/null +++ b/sys/compat/linuxkpi/common/include/linux/platform_device.h @@ -0,0 +1,79 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2020-2022 Bjoern A. Zeeb + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _LINUXKPI_LINUX_PLATFORM_DEVICE_H +#define _LINUXKPI_LINUX_PLATFORM_DEVICE_H + +#include +#include + +struct platform_device { + struct device dev; +}; + +struct platform_driver { + int (*remove)(struct platform_device *); + struct device_driver driver; +}; + + +static __inline int +platform_driver_register(struct platform_driver *pdrv) +{ + + pr_debug("%s: TODO\n", __func__); + return (-ENXIO); +} + +static __inline void * +dev_get_platdata(struct device *dev) +{ + + pr_debug("%s: TODO\n", __func__); + return (NULL); +} + +static __inline int +platform_driver_probe(struct platform_driver *pdrv, + int(*pd_probe_f)(struct platform_device *)) +{ + + pr_debug("%s: TODO\n", __func__); + return (-ENODEV); +} + +static __inline void +platform_driver_unregister(struct platform_driver *pdrv) +{ + + pr_debug("%s: TODO\n", __func__); + return; +} + +#endif /* _LINUXKPI_LINUX_PLATFORM_DEVICE_H */ diff --git a/sys/compat/linuxkpi/common/include/net/netlink.h b/sys/compat/linuxkpi/common/include/net/netlink.h new file mode 100644 index 000000000000..ae250177d18b --- /dev/null +++ b/sys/compat/linuxkpi/common/include/net/netlink.h @@ -0,0 +1,53 @@ +/*- + * Copyright (c) 2020,2022 Bjoern A. Zeeb + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _LINUXKPI_NET_NETLINK_H +#define _LINUXKPI_NET_NETLINK_H + +#include + +struct nla_policy { +}; + +struct netlink_callback { + int args[8]; +}; + +static __inline int +nla_put(struct sk_buff *skb, int attr, size_t len, void *data) +{ + + pr_debug("%s: TODO -- now native?\n", __func__); + return (-ENXIO); +} + +static __inline int +nla_put_u16(struct sk_buff *skb, int attr, uint32_t val) +{ + + return (nla_put(skb, attr, sizeof(uint32_t), &val)); +} + +#endif /* _LINUXKPI_NET_NETLINK_H */