1 /*******************************************************************************
3 Copyright (c) 2013-2015, Intel Corporation
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
9 1. Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer.
12 2. Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the distribution.
16 3. Neither the name of the Intel Corporation nor the names of its
17 contributors may be used to endorse or promote products derived from
18 this software without specific prior written permission.
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 POSSIBILITY OF SUCH DAMAGE.
32 ***************************************************************************/
34 #ifndef _FM10K_OSDEP_H_
35 #define _FM10K_OSDEP_H_
39 #include <rte_atomic.h>
40 #include <rte_byteorder.h>
41 #include <rte_cycles.h>
42 #include "../fm10k_logs.h"
44 /* TODO: this does not look like it should be used... */
45 #define ERROR_REPORT2(v1, v2, v3) do { } while (0)
47 #ifndef BOULDER_RAPIDS_HW
48 #define BOULDER_RAPIDS_HW
52 #define DEBUGFUNC(F) DEBUGOUT(F "\n");
53 #define DEBUGOUT(S, args...) PMD_DRV_LOG_RAW(DEBUG, S, ##args)
54 #define DEBUGOUT1(S, args...) DEBUGOUT(S, ##args)
55 #define DEBUGOUT2(S, args...) DEBUGOUT(S, ##args)
56 #define DEBUGOUT3(S, args...) DEBUGOUT(S, ##args)
57 #define DEBUGOUT6(S, args...) DEBUGOUT(S, ##args)
58 #define DEBUGOUT7(S, args...) DEBUGOUT(S, ##args)
90 /* offsets are WORD offsets, not BYTE offsets */
91 #define FM10K_WRITE_REG(hw, reg, val) \
92 ((((volatile uint32_t *)(hw)->hw_addr)[(reg)]) = ((uint32_t)(val)))
93 #define FM10K_READ_REG(hw, reg) \
94 (((volatile uint32_t *)(hw)->hw_addr)[(reg)])
95 #define FM10K_WRITE_FLUSH(a) FM10K_READ_REG(a, FM10K_CTRL)
97 #define FM10K_PCI_REG(reg) (*((volatile uint32_t *)(reg)))
99 #define FM10K_PCI_REG_WRITE(reg, value) do { \
100 FM10K_PCI_REG((reg)) = (value); \
103 /* not implemented */
104 #define FM10K_READ_PCI_WORD(hw, reg) 0
106 #define FM10K_WRITE_MBX(hw, reg, value) FM10K_WRITE_REG(hw, reg, value)
107 #define FM10K_READ_MBX(hw, reg) FM10K_READ_REG(hw, reg)
109 #define FM10K_LE16_TO_CPU rte_le_to_cpu_16
110 #define FM10K_LE32_TO_CPU rte_le_to_cpu_32
111 #define FM10K_CPU_TO_LE32 rte_cpu_to_le_32
112 #define FM10K_CPU_TO_LE16 rte_cpu_to_le_16
113 #define le16_to_cpu rte_le_to_cpu_16
115 #define FM10K_RMB rte_rmb
116 #define FM10K_WMB rte_wmb
118 #define usec_delay rte_delay_us
120 #define FM10K_REMOVED(hw_addr) (!(hw_addr))
122 #ifndef FM10K_IS_ZERO_ETHER_ADDR
123 /* make certain address is not 0 */
124 #define FM10K_IS_ZERO_ETHER_ADDR(addr) \
125 (!((addr)[0] | (addr)[1] | (addr)[2] | (addr)[3] | (addr)[4] | (addr)[5]))
128 #ifndef FM10K_IS_MULTICAST_ETHER_ADDR
129 #define FM10K_IS_MULTICAST_ETHER_ADDR(addr) ((addr)[0] & 0x1)
132 #ifndef FM10K_IS_VALID_ETHER_ADDR
133 /* make certain address is not multicast or 0 */
134 #define FM10K_IS_VALID_ETHER_ADDR(addr) \
135 (!FM10K_IS_MULTICAST_ETHER_ADDR(addr) && !FM10K_IS_ZERO_ETHER_ADDR(addr))
139 #define do_div(n, base) ({\
144 /* DPDK can't access IOMEM directly */
145 #ifndef FM10K_WRITE_SW_REG
146 #define FM10K_WRITE_SW_REG(v1, v2, v3) do { } while (0)
149 #ifndef fm10k_read_reg
150 #define fm10k_read_reg FM10K_READ_REG
153 #define FM10K_INTEL_VENDOR_ID 0x8086
154 #define FM10K_DMA_CTRL_MINMSS_SHIFT 9
155 #define FM10K_EICR_PCA_FAULT 0x00000001
156 #define FM10K_EICR_THI_FAULT 0x00000004
157 #define FM10K_EICR_FUM_FAULT 0x00000020
158 #define FM10K_EICR_SRAMERROR 0x00000400
159 #define FM10K_SRAM_IP 0x13003
160 #define FM10K_RXINT_TIMER_SHIFT 8
161 #define FM10K_TXINT_TIMER_SHIFT 8
162 #define FM10K_RXD_PKTTYPE_MASK 0x03F0
163 #define FM10K_RXD_PKTTYPE_SHIFT 4
165 enum fm10k_rdesc_pkt_type {
167 FM10K_PKTTYPE_OTHER = 0x00,
168 FM10K_PKTTYPE_IPV4 = 0x01,
169 FM10K_PKTTYPE_IPV4_EX = 0x02,
170 FM10K_PKTTYPE_IPV6 = 0x03,
171 FM10K_PKTTYPE_IPV6_EX = 0x04,
174 FM10K_PKTTYPE_TCP = 0x08,
175 FM10K_PKTTYPE_UDP = 0x10,
176 FM10K_PKTTYPE_GRE = 0x18,
177 FM10K_PKTTYPE_VXLAN = 0x20,
178 FM10K_PKTTYPE_NVGRE = 0x28,
179 FM10K_PKTTYPE_GENEVE = 0x30
182 #define FM10K_RXD_STATUS_IPCS 0x0008 /* Indicates IPv4 csum */
183 #define FM10K_RXD_STATUS_HBO 0x0400 /* header buffer overrun */
185 #define FM10K_TSO_MINMSS \
186 (FM10K_DMA_CTRL_MINMSS_64 >> FM10K_DMA_CTRL_MINMSS_SHIFT)
187 #define FM10K_TSO_MIN_HEADERLEN 54
188 #define FM10K_TSO_MAX_HEADERLEN 192
190 #endif /* _FM10K_OSDEP_H_ */