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
MFC after:	13 days
Reviewed by:	hselasky, kib
Differential Revision: https://reviews.freebsd.org/D30461
This commit is contained in:
Bjoern A. Zeeb 2021-05-26 12:27:26 +00:00
parent 3bca93e042
commit c35034b338
7 changed files with 23 additions and 67 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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>

View File

@ -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>

View File

@ -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;

View File

@ -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 */

View File

@ -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>