Date: Sun, 18 Jul 2021 00:36:38 GMT From: "Bjoern A. Zeeb" <bz@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: ddecc06c9940 - stable/13 - LinuxKPI/OFED/mlx4: cleanup netdevice.h some more Message-ID: <202107180036.16I0acqE049384@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=ddecc06c9940e1e9b14278c22f605655263a693f commit ddecc06c9940e1e9b14278c22f605655263a693f Author: Bjoern A. Zeeb <bz@FreeBSD.org> AuthorDate: 2021-05-26 12:27:26 +0000 Commit: Bjoern A. Zeeb <bz@FreeBSD.org> CommitDate: 2021-07-18 00:35:02 +0000 LinuxKPI/OFED/mlx4: cleanup netdevice.h some more This removes all unused bits from linux/netdevice.h and migrates two inline functions into the mlx4 and ofed code respectively. This gets the mlx4/ofed (struct ifnet) specific bits down to 7 lines in netdevice.h. Sponsored by: The FreeBSD Foundation Reviewed by: hselasky, kib Differential Revision: https://reviews.freebsd.org/D30461 (cherry picked from commit c35034b338eb4de6fb42fd855865bce21c81a225) --- .../linuxkpi/common/include/linux/netdevice.h | 64 ---------------------- sys/dev/mlx4/mlx4_en/en.h | 6 ++ sys/ofed/drivers/infiniband/core/ib_addr.c | 1 - sys/ofed/drivers/infiniband/core/ib_cma.c | 1 - sys/ofed/include/rdma/ib_addr.h | 2 +- sys/ofed/include/rdma/ib_addr_freebsd.h | 15 +++++ sys/ofed/include/rdma/ib_sa.h | 1 + 7 files changed, 23 insertions(+), 67 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/netdevice.h b/sys/compat/linuxkpi/common/include/linux/netdevice.h index 9ec76d9b90ef..07c111cc4fc9 100644 --- a/sys/compat/linuxkpi/common/include/linux/netdevice.h +++ b/sys/compat/linuxkpi/common/include/linux/netdevice.h @@ -40,10 +40,6 @@ #include <net/if_var.h> #include <net/if_dl.h> -#include <linux/list.h> -#include <linux/completion.h> -#include <linux/device.h> -#include <linux/workqueue.h> #include <linux/net.h> #include <linux/notifier.h> @@ -57,21 +53,6 @@ #define net_device ifnet -static inline struct ifnet * -dev_get_by_index(struct vnet *vnet, int if_index) -{ - struct epoch_tracker et; - struct ifnet *retval; - - NET_EPOCH_ENTER(et); - CURVNET_SET(vnet); - retval = ifnet_byindex_ref(if_index); - CURVNET_RESTORE(); - NET_EPOCH_EXIT(et); - - return (retval); -} - #define dev_hold(d) if_ref(d) #define dev_put(d) if_rele(d) #define dev_net(d) ((d)->if_vnet) @@ -79,56 +60,11 @@ dev_get_by_index(struct vnet *vnet, int if_index) #define net_eq(a,b) ((a) == (b)) #define netif_running(dev) !!((dev)->if_drv_flags & IFF_DRV_RUNNING) -#define netif_oper_up(dev) !!((dev)->if_flags & IFF_UP) #define netif_carrier_ok(dev) ((dev)->if_link_state == LINK_STATE_UP) -static inline void * -netdev_priv(const struct net_device *dev) -{ - return (dev->if_softc); -} - #define rtnl_lock() #define rtnl_unlock() -static inline int -dev_mc_delete(struct net_device *dev, void *addr, int alen, int all) -{ - struct sockaddr_dl sdl; - - if (alen > sizeof(sdl.sdl_data)) - return (-EINVAL); - memset(&sdl, 0, sizeof(sdl)); - sdl.sdl_len = sizeof(sdl); - sdl.sdl_family = AF_LINK; - sdl.sdl_alen = alen; - memcpy(&sdl.sdl_data, addr, alen); - - return -if_delmulti(dev, (struct sockaddr *)&sdl); -} - -static inline int -dev_mc_del(struct net_device *dev, void *addr) -{ - return (dev_mc_delete(dev, addr, 6, 0)); -} - -static inline int -dev_mc_add(struct net_device *dev, void *addr, int alen, int newonly) -{ - struct sockaddr_dl sdl; - - if (alen > sizeof(sdl.sdl_data)) - return (-EINVAL); - memset(&sdl, 0, sizeof(sdl)); - sdl.sdl_len = sizeof(sdl); - sdl.sdl_family = AF_LINK; - sdl.sdl_alen = alen; - memcpy(&sdl.sdl_data, addr, alen); - - return -if_addmulti(dev, (struct sockaddr *)&sdl, NULL); -} - /* According to linux::ipoib_main.c. */ struct netdev_notifier_info { struct net_device *dev; diff --git a/sys/dev/mlx4/mlx4_en/en.h b/sys/dev/mlx4/mlx4_en/en.h index e7a02f02c8b7..e63027bc9dc0 100644 --- a/sys/dev/mlx4/mlx4_en/en.h +++ b/sys/dev/mlx4/mlx4_en/en.h @@ -654,6 +654,12 @@ struct mlx4_mac_entry { u64 reg_id; }; +static inline void * +netdev_priv(const struct net_device *dev) +{ + return (dev->if_softc); +} + static inline struct mlx4_cqe *mlx4_en_get_cqe(u8 *buf, int idx, int cqe_sz) { return (struct mlx4_cqe *)(buf + idx * cqe_sz); diff --git a/sys/ofed/drivers/infiniband/core/ib_addr.c b/sys/ofed/drivers/infiniband/core/ib_addr.c index f8c1cb180af8..ef5e264577e0 100644 --- a/sys/ofed/drivers/infiniband/core/ib_addr.c +++ b/sys/ofed/drivers/infiniband/core/ib_addr.c @@ -46,7 +46,6 @@ __FBSDID("$FreeBSD$"); #include <net/route/nhop.h> #include <net/netevent.h> #include <rdma/ib_addr.h> -#include <rdma/ib_addr_freebsd.h> #include <rdma/ib.h> #include <netinet/in_fib.h> diff --git a/sys/ofed/drivers/infiniband/core/ib_cma.c b/sys/ofed/drivers/infiniband/core/ib_cma.c index 717d7c70e9de..7c03841d51d7 100644 --- a/sys/ofed/drivers/infiniband/core/ib_cma.c +++ b/sys/ofed/drivers/infiniband/core/ib_cma.c @@ -65,7 +65,6 @@ __FBSDID("$FreeBSD$"); #include <rdma/rdma_sdp.h> #include <rdma/ib.h> #include <rdma/ib_addr.h> -#include <rdma/ib_addr_freebsd.h> #include <rdma/ib_cache.h> #include <rdma/ib_cm.h> #include <rdma/ib_sa.h> diff --git a/sys/ofed/include/rdma/ib_addr.h b/sys/ofed/include/rdma/ib_addr.h index 052fc636f617..535e6c2b3b14 100644 --- a/sys/ofed/include/rdma/ib_addr.h +++ b/sys/ofed/include/rdma/ib_addr.h @@ -49,7 +49,7 @@ #include <net/ip.h> #include <rdma/ib_verbs.h> #include <rdma/ib_pack.h> -#include <net/ipv6.h> +#include <rdma/ib_addr_freebsd.h> struct rdma_addr_client { atomic_t refcount; diff --git a/sys/ofed/include/rdma/ib_addr_freebsd.h b/sys/ofed/include/rdma/ib_addr_freebsd.h index 5ce5f2f8a5ed..79b7231875ec 100644 --- a/sys/ofed/include/rdma/ib_addr_freebsd.h +++ b/sys/ofed/include/rdma/ib_addr_freebsd.h @@ -92,4 +92,19 @@ ip6_ifp_find(struct vnet *vnet, struct in6_addr addr, uint16_t scope_id) } #endif +static inline struct ifnet * +dev_get_by_index(struct vnet *vnet, int if_index) +{ + struct epoch_tracker et; + struct ifnet *retval; + + NET_EPOCH_ENTER(et); + CURVNET_SET(vnet); + retval = ifnet_byindex_ref(if_index); + CURVNET_RESTORE(); + NET_EPOCH_EXIT(et); + + return (retval); +} + #endif /* _RDMA_IB_ADDR_FREEBSD_H */ diff --git a/sys/ofed/include/rdma/ib_sa.h b/sys/ofed/include/rdma/ib_sa.h index 28e9a7887cab..beea96a02e1a 100644 --- a/sys/ofed/include/rdma/ib_sa.h +++ b/sys/ofed/include/rdma/ib_sa.h @@ -43,6 +43,7 @@ #include <linux/compiler.h> #include <linux/netdevice.h> +#include <rdma/ib_addr_freebsd.h> #include <rdma/ib_verbs.h> #include <rdma/ib_mad.h>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202107180036.16I0acqE049384>