svn commit: r324527 - in stable/10/sys/ofed: drivers/infiniband/core include/linux

Hans Petter Selasky hselasky at FreeBSD.org
Wed Oct 11 10:57:01 UTC 2017


Author: hselasky
Date: Wed Oct 11 10:56:59 2017
New Revision: 324527
URL: https://svnweb.freebsd.org/changeset/base/324527

Log:
  MFC r315404:
  Add basic support for VIMAGE to the LinuxKPI and ibcore.
  
  Support is implemented by mapping Linux's "struct net" into FreeBSD's
  "struct vnet". Currently only vnet0 is supported by ibcore.
  
  Sponsored by:		Mellanox Technologies

Modified:
  stable/10/sys/ofed/drivers/infiniband/core/addr.c
  stable/10/sys/ofed/include/linux/inetdevice.h
  stable/10/sys/ofed/include/linux/linux_compat.c
  stable/10/sys/ofed/include/linux/netdevice.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/ofed/drivers/infiniband/core/addr.c
==============================================================================
--- stable/10/sys/ofed/drivers/infiniband/core/addr.c	Wed Oct 11 10:36:40 2017	(r324526)
+++ stable/10/sys/ofed/drivers/infiniband/core/addr.c	Wed Oct 11 10:56:59 2017	(r324527)
@@ -172,7 +172,9 @@ int rdma_translate_ip(struct sockaddr *addr, struct rd
 			sin6 = (struct sockaddr_in6 *)addr;
 			port = sin6->sin6_port;
 			sin6->sin6_port = 0;
+			CURVNET_SET_QUIET(&init_net);
 			ifa = ifa_ifwithaddr(addr);
+			CURVNET_RESTORE();
 			sin6->sin6_port = port;
 			if (ifa == NULL) {
 				ret = -ENODEV;
@@ -339,7 +341,7 @@ static int addr6_resolve(struct sockaddr_in6 *src_in,
 #else
 #include <netinet/if_ether.h>
 
-static int addr_resolve(struct sockaddr *src_in,
+static int addr_resolve_sub(struct sockaddr *src_in,
 			struct sockaddr *dst_in,
 			struct rdma_dev_addr *addr)
 {
@@ -487,6 +489,18 @@ mcast:
 	return -error;
 }
 
+static int addr_resolve(struct sockaddr *src_in,
+			struct sockaddr *dst_in,
+			struct rdma_dev_addr *addr)
+{
+	int error;
+
+	CURVNET_SET_QUIET(&init_net);
+	error = addr_resolve_sub(src_in, dst_in, addr);
+	CURVNET_RESTORE();
+
+	return (error);
+}
 #endif
 
 static void process_req(struct work_struct *work)

Modified: stable/10/sys/ofed/include/linux/inetdevice.h
==============================================================================
--- stable/10/sys/ofed/include/linux/inetdevice.h	Wed Oct 11 10:36:40 2017	(r324526)
+++ stable/10/sys/ofed/include/linux/inetdevice.h	Wed Oct 11 10:56:59 2017	(r324527)
@@ -34,23 +34,25 @@
 #include <linux/netdevice.h>
 
 static inline struct net_device *
-ip_dev_find(struct net *net, uint32_t addr)
+ip_dev_find(struct vnet *vnet, uint32_t addr)
 {
 	struct sockaddr_in sin;
 	struct ifaddr *ifa;
 	struct ifnet *ifp;
 
-	ifp = NULL;
 	memset(&sin, 0, sizeof(sin));
 	sin.sin_addr.s_addr = addr;
-	sin.sin_port = 0;
 	sin.sin_len = sizeof(sin);
 	sin.sin_family = AF_INET;
+	CURVNET_SET_QUIET(vnet);
 	ifa = ifa_ifwithaddr((struct sockaddr *)&sin);
+	CURVNET_RESTORE();
 	if (ifa) {
 		ifp = ifa->ifa_ifp;
 		if_ref(ifp);
 		ifa_free(ifa);
+	} else {
+		ifp = NULL;
 	}
 	return (ifp);
 }

Modified: stable/10/sys/ofed/include/linux/linux_compat.c
==============================================================================
--- stable/10/sys/ofed/include/linux/linux_compat.c	Wed Oct 11 10:36:40 2017	(r324526)
+++ stable/10/sys/ofed/include/linux/linux_compat.c	Wed Oct 11 10:56:59 2017	(r324527)
@@ -80,7 +80,6 @@ struct device linux_rootdev;
 struct class miscclass;
 struct list_head pci_drivers;
 struct list_head pci_devices;
-struct net init_net;
 spinlock_t pci_lock;
 
 unsigned long linux_timer_hz_mask;

Modified: stable/10/sys/ofed/include/linux/netdevice.h
==============================================================================
--- stable/10/sys/ofed/include/linux/netdevice.h	Wed Oct 11 10:36:40 2017	(r324526)
+++ stable/10/sys/ofed/include/linux/netdevice.h	Wed Oct 11 10:56:59 2017	(r324527)
@@ -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-2017 Mellanox Technologies, Ltd.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -38,24 +38,40 @@
 #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>
 
-struct net {
-};
+#ifdef VIMAGE
+#define	init_net *vnet0
+#else
+#define	init_net *((struct vnet *)0)
+#endif
 
-extern struct net init_net;
-
 #define	MAX_ADDR_LEN		20
 
 #define	net_device	ifnet
 
-#define	dev_get_by_index(n, idx)	ifnet_byindex_ref((idx))
-#define	dev_hold(d)	if_ref((d))
-#define	dev_put(d)	if_rele((d))
+static inline struct ifnet *
+dev_get_by_index(struct vnet *vnet, int if_index)
+{
+	struct ifnet *retval;
+
+	CURVNET_SET(vnet);
+	retval = ifnet_byindex_ref(if_index);
+	CURVNET_RESTORE();
+
+	return (retval);
+}
+
+#define	dev_hold(d)	if_ref(d)
+#define	dev_put(d)	if_rele(d)
+#define	dev_net(d)	((d)->if_vnet)
+
+#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)


More information about the svn-src-all mailing list