1/*-
2 *   This file is provided under a dual BSD/LGPLv2 license.  When using or
3 *   redistributing this file, you may do so under either license.
4 *
5 *   GNU LESSER GENERAL PUBLIC LICENSE
6 *
7 *   Copyright(c) 2007-2014 Intel Corporation. All rights reserved.
8 *
9 *   This program is free software; you can redistribute it and/or modify
10 *   it under the terms of version 2.1 of the GNU Lesser General Public License
11 *   as published by the Free Software Foundation.
12 *
13 *   This program is distributed in the hope that it will be useful, but
14 *   WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 *   Lesser General Public License for more details.
17 *
18 *   You should have received a copy of the GNU Lesser General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 *   Contact Information:
23 *   Intel Corporation
24 *
25 *
26 *   BSD LICENSE
27 *
28 *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
29 *   All rights reserved.
30 *
31 *   Redistribution and use in source and binary forms, with or without
32 *   modification, are permitted provided that the following conditions
33 *   are met:
34 *
35 *   * Redistributions of source code must retain the above copyright
36 *     notice, this list of conditions and the following disclaimer.
37 *   * Redistributions in binary form must reproduce the above copyright
38 *     notice, this list of conditions and the following disclaimer in
39 *     the documentation and/or other materials provided with the
40 *     distribution.
41 *   * Neither the name of Intel Corporation nor the names of its
42 *     contributors may be used to endorse or promote products derived
43 *     from this software without specific prior written permission.
44 *
45 *    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
46 *    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
47 *    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
48 *    A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
49 *    OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
50 *    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
51 *    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
52 *    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
53 *    THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
54 *    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
55 *    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
56 *
57 */
58
59#ifndef _RTE_DOM0_COMMON_H_
60#define _RTE_DOM0_COMMON_H_
61
62#ifdef __KERNEL__
63#include <linux/if.h>
64#endif
65
66#define DOM0_NAME_MAX   256
67#define DOM0_MM_DEV   "/dev/dom0_mm"
68
69#define DOM0_CONTIG_NUM_ORDER       9       /**< order of 2M */
70#define DOM0_NUM_MEMSEG             512     /**< Maximum nb. of memory segment. */
71#define DOM0_MEMBLOCK_SIZE          0x200000 /**< size of memory block(2M). */
72#define DOM0_CONFIG_MEMSIZE         4096     /**< Maximum config memory size(4G). */
73#define DOM0_NUM_MEMBLOCK (DOM0_CONFIG_MEMSIZE / 2) /**< Maximum nb. of 2M memory block. */
74
75#define RTE_DOM0_IOCTL_PREPARE_MEMSEG    _IOWR(0, 1 , struct memory_info)
76#define RTE_DOM0_IOCTL_ATTACH_TO_MEMSEG  _IOWR(0, 2 , char *)
77#define RTE_DOM0_IOCTL_GET_NUM_MEMSEG    _IOWR(0, 3, int)
78#define RTE_DOM0_IOCTL_GET_MEMSEG_INFO   _IOWR(0, 4, void *)
79
80/**
81 * A structure used to store memory information.
82 */
83struct memory_info {
84	char name[DOM0_NAME_MAX];
85	uint64_t size;
86};
87
88/**
89 * A structure used to store memory segment information.
90 */
91struct memseg_info {
92	uint32_t idx;
93	uint64_t pfn;
94	uint64_t size;
95	uint64_t mfn[DOM0_NUM_MEMBLOCK];
96};
97
98/**
99 * A structure used to store memory block information.
100 */
101struct memblock_info {
102	uint8_t exchange_flag;
103	uint8_t used;
104	uint64_t vir_addr;
105	uint64_t pfn;
106	uint64_t mfn;
107};
108#endif /* _RTE_DOM0_COMMON_H_ */
109