1328653Shselasky/*-
2328653Shselasky * Copyright (c) 2017 Mellanox Technologies, Ltd.
3328653Shselasky * All rights reserved.
4328653Shselasky *
5328653Shselasky * Redistribution and use in source and binary forms, with or without
6328653Shselasky * modification, are permitted provided that the following conditions
7328653Shselasky * are met:
8328653Shselasky * 1. Redistributions of source code must retain the above copyright
9328653Shselasky *    notice unmodified, this list of conditions, and the following
10328653Shselasky *    disclaimer.
11328653Shselasky * 2. Redistributions in binary form must reproduce the above copyright
12328653Shselasky *    notice, this list of conditions and the following disclaimer in the
13328653Shselasky *    documentation and/or other materials provided with the distribution.
14328653Shselasky *
15328653Shselasky * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16328653Shselasky * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17328653Shselasky * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18328653Shselasky * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19328653Shselasky * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20328653Shselasky * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21328653Shselasky * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22328653Shselasky * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23328653Shselasky * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24328653Shselasky * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25328653Shselasky *
26328653Shselasky * $FreeBSD: stable/11/sys/compat/linuxkpi/common/include/linux/pfn_t.h 328653 2018-02-01 13:01:44Z hselasky $
27328653Shselasky */
28328653Shselasky
29328653Shselasky#ifndef _LINUX_PFN_T_H_
30328653Shselasky#define	_LINUX_PFN_T_H_
31328653Shselasky
32328653Shselasky#include <linux/mm.h>
33328653Shselasky
34328653ShselaskyCTASSERT(PAGE_SHIFT > 4);
35328653Shselasky
36328653Shselasky#define	PFN_FLAGS_MASK (((u64)(PAGE_SIZE - 1)) << (64 - PAGE_SHIFT))
37328653Shselasky#define	PFN_SG_CHAIN (1ULL << (64 - 1))
38328653Shselasky#define	PFN_SG_LAST (1ULL << (64 - 2))
39328653Shselasky#define	PFN_DEV (1ULL << (64 - 3))
40328653Shselasky#define	PFN_MAP (1ULL << (64 - 4))
41328653Shselasky
42328653Shselaskystatic inline pfn_t
43328653Shselasky__pfn_to_pfn_t(unsigned long pfn, u64 flags)
44328653Shselasky{
45328653Shselasky	pfn_t pfn_t = { pfn | (flags & PFN_FLAGS_MASK) };
46328653Shselasky
47328653Shselasky	return (pfn_t);
48328653Shselasky}
49328653Shselasky
50328653Shselaskystatic inline pfn_t
51328653Shselaskypfn_to_pfn_t(unsigned long pfn)
52328653Shselasky{
53328653Shselasky	return (__pfn_to_pfn_t (pfn, 0));
54328653Shselasky}
55328653Shselasky
56328653Shselasky#endif					/* _LINUX_PFN_T_H_ */
57