From owner-svn-src-stable-11@freebsd.org Wed Oct 11 10:36:41 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E79C4E27FFB; Wed, 11 Oct 2017 10:36:41 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A8CD93A41; Wed, 11 Oct 2017 10:36:41 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9BAae4e020306; Wed, 11 Oct 2017 10:36:40 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9BAae64020302; Wed, 11 Oct 2017 10:36:40 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201710111036.v9BAae64020302@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Wed, 11 Oct 2017 10:36:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324526 - in stable/11/sys: compat/linuxkpi/common/include/linux compat/linuxkpi/common/src ofed/drivers/infiniband/core X-SVN-Group: stable-11 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: in stable/11/sys: compat/linuxkpi/common/include/linux compat/linuxkpi/common/src ofed/drivers/infiniband/core X-SVN-Commit-Revision: 324526 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Oct 2017 10:36:42 -0000 Author: hselasky Date: Wed Oct 11 10:36:40 2017 New Revision: 324526 URL: https://svnweb.freebsd.org/changeset/base/324526 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/11/sys/compat/linuxkpi/common/include/linux/inetdevice.h stable/11/sys/compat/linuxkpi/common/include/linux/netdevice.h stable/11/sys/compat/linuxkpi/common/src/linux_compat.c stable/11/sys/ofed/drivers/infiniband/core/addr.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/compat/linuxkpi/common/include/linux/inetdevice.h ============================================================================== --- stable/11/sys/compat/linuxkpi/common/include/linux/inetdevice.h Wed Oct 11 10:20:53 2017 (r324525) +++ stable/11/sys/compat/linuxkpi/common/include/linux/inetdevice.h Wed Oct 11 10:36:40 2017 (r324526) @@ -34,23 +34,25 @@ #include 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/11/sys/compat/linuxkpi/common/include/linux/netdevice.h ============================================================================== --- stable/11/sys/compat/linuxkpi/common/include/linux/netdevice.h Wed Oct 11 10:20:53 2017 (r324525) +++ stable/11/sys/compat/linuxkpi/common/include/linux/netdevice.h Wed Oct 11 10:36:40 2017 (r324526) @@ -2,7 +2,7 @@ * Copyright (c) 2010 Isilon Systems, Inc. * Copyright (c) 2010 iX Systems, Inc. * Copyright (c) 2010 Panasas, Inc. - * Copyright (c) 2013-2016 Mellanox Technologies, Ltd. + * Copyright (c) 2013-2017 Mellanox Technologies, Ltd. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -40,25 +40,38 @@ #include #include +#include #include #include #include #include #include -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)) -#define dev_net(d) (&init_net) +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)) Modified: stable/11/sys/compat/linuxkpi/common/src/linux_compat.c ============================================================================== --- stable/11/sys/compat/linuxkpi/common/src/linux_compat.c Wed Oct 11 10:20:53 2017 (r324525) +++ stable/11/sys/compat/linuxkpi/common/src/linux_compat.c Wed Oct 11 10:36:40 2017 (r324526) @@ -94,7 +94,6 @@ struct device linux_root_device; struct class linux_class_misc; struct list_head pci_drivers; struct list_head pci_devices; -struct net init_net; spinlock_t pci_lock; struct sx linux_global_rcu_lock; Modified: stable/11/sys/ofed/drivers/infiniband/core/addr.c ============================================================================== --- stable/11/sys/ofed/drivers/infiniband/core/addr.c Wed Oct 11 10:20:53 2017 (r324525) +++ stable/11/sys/ofed/drivers/infiniband/core/addr.c Wed Oct 11 10:36:40 2017 (r324526) @@ -161,7 +161,9 @@ int rdma_translate_ip(struct sockaddr *addr, struct rd scope_id = sin6->sin6_scope_id; if (IN6_IS_SCOPE_LINKLOCAL(&sin6->sin6_addr)) SCOPE_ID_CACHE(scope_id, sin6); + CURVNET_SET_QUIET(&init_net); ifa = ifa_ifwithaddr(addr); + CURVNET_RESTORE(); sin6->sin6_port = port; if (IN6_IS_SCOPE_LINKLOCAL(&sin6->sin6_addr)) SCOPE_ID_RESTORE(scope_id, sin6); @@ -231,6 +233,9 @@ static int addr_resolve(struct sockaddr *src_in, int bcast; int is_gw = 0; int error = 0; + + CURVNET_SET_QUIET(&init_net); + /* * Determine whether the address is unicast, multicast, or broadcast * and whether the source interface is valid. @@ -271,7 +276,9 @@ static int addr_resolve(struct sockaddr *src_in, * up first and verify that it is a local * interface: */ + CURVNET_SET_QUIET(&init_net); ifa = ifa_ifwithaddr(src_in); + CURVNET_RESTORE(); sin->sin_port = port; if (ifa == NULL) { error = ENETUNREACH; @@ -312,7 +319,9 @@ static int addr_resolve(struct sockaddr *src_in, * up first and verify that it is a local * interface: */ + CURVNET_SET_QUIET(&init_net); ifa = ifa_ifwithaddr(src_in); + CURVNET_RESTORE(); sin6->sin6_port = port; if (ifa == NULL) { error = ENETUNREACH; @@ -426,6 +435,8 @@ done: #endif if (error == EWOULDBLOCK) error = ENODATA; + + CURVNET_RESTORE(); return -error; }