2 * This file is provided under a dual BSD/LGPLv2 license. When using or
\r
3 * redistributing this file, you may do so under either license.
\r
5 * GNU LESSER GENERAL PUBLIC LICENSE
\r
7 * Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
\r
9 * This program is free software; you can redistribute it and/or modify
\r
10 * it under the terms of version 2.1 of the GNU Lesser General Public License
\r
11 * as published by the Free Software Foundation.
\r
13 * This program is distributed in the hope that it will be useful, but
\r
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
\r
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
\r
16 * Lesser General Public License for more details.
\r
18 * You should have received a copy of the GNU Lesser General Public License
\r
19 * along with this program; if not, write to the Free Software
\r
20 * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
\r
22 * Contact Information:
\r
28 * Copyright(c) 2010-2012 Intel Corporation. All rights reserved.
\r
29 * All rights reserved.
\r
31 * Redistribution and use in source and binary forms, with or without
\r
32 * modification, are permitted provided that the following conditions
\r
35 * * Redistributions of source code must retain the above copyright
\r
36 * notice, this list of conditions and the following disclaimer.
\r
37 * * Redistributions in binary form must reproduce the above copyright
\r
38 * notice, this list of conditions and the following disclaimer in
\r
39 * the documentation and/or other materials provided with the
\r
41 * * Neither the name of Intel Corporation nor the names of its
\r
42 * contributors may be used to endorse or promote products derived
\r
43 * from this software without specific prior written permission.
\r
45 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
\r
46 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
\r
47 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
\r
48 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
\r
49 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
\r
50 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
\r
51 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
\r
52 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
\r
53 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
\r
54 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
\r
55 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
60 #ifndef _RTE_KNI_COMMON_H_
61 #define _RTE_KNI_COMMON_H_
71 RTE_KNI_REQ_UNKNOWN = 0,
72 RTE_KNI_REQ_CHANGE_MTU,
73 RTE_KNI_REQ_CFG_NETWORK_IF,
78 * Structure for KNI request.
80 struct rte_kni_request {
81 uint32_t req_id; /**< Request id */
83 uint32_t new_mtu; /**< New MTU */
84 uint8_t if_up; /**< 1: interface up, 0: interface down */
86 int32_t result; /**< Result for processing request */
87 } __attribute__((__packed__));
90 * Fifo struct mapped in a shared memory. It describes a circular buffer FIFO
91 * Write and read should wrap arround. Fifo is empty when write == read
92 * Writing should never overwrite the read position
95 volatile unsigned write; /**< Next position to be written*/
96 volatile unsigned read; /**< Next position to be read */
97 unsigned len; /**< Circular buffer length */
98 unsigned elem_size; /**< Pointer size - for 32/64 bit OS */
99 void * volatile buffer[0]; /**< The buffer contains mbuf pointers */
103 * The kernel image of the rte_mbuf struct, with only the relevant fields.
104 * Padding is necessary to assure the offsets of these fields
106 struct rte_kni_mbuf {
110 uint16_t ol_flags; /**< Offload features. */
112 void *data; /**< Start address of data in segment buffer. */
113 uint16_t data_len; /**< Amount of data in segment buffer. */
115 uint16_t pkt_len; /**< Total pkt len: sum of all segment data_len. */
116 } __attribute__((__aligned__(64)));
119 * Struct used to create a KNI device. Passed to the kernel in IOCTL call
122 struct rte_kni_device_info
128 phys_addr_t alloc_phys;
129 phys_addr_t free_phys;
131 /* Used by Ethtool */
132 phys_addr_t req_phys;
133 phys_addr_t resp_phys;
134 phys_addr_t sync_phys;
139 phys_addr_t mbuf_phys;
142 uint16_t vendor_id; /**< Vendor ID or PCI_ANY_ID. */
143 uint16_t device_id; /**< Device ID or PCI_ANY_ID. */
144 uint8_t bus; /**< Device bus */
145 uint8_t devid; /**< Device ID */
146 uint8_t function; /**< Device function. */
152 #define KNI_DEVICE "kni"
154 #define RTE_KNI_IOCTL_TEST _IOWR(0, 1, int)
155 #define RTE_KNI_IOCTL_CREATE _IOWR(0, 2, struct rte_kni_device_info)
157 #endif /* _RTE_KNI_COMMON_H_ */