2 * Copyright 2008-2010 Cisco Systems, Inc. All rights reserved.
3 * Copyright 2007 Nuova Systems, Inc. All rights reserved.
5 * Copyright (c) 2014, Cisco Systems, Inc.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
38 #include "enic_compat.h"
40 #include "vnic_resource.h"
41 #include "vnic_devcmd.h"
43 #ifndef VNIC_PADDR_TARGET
44 #define VNIC_PADDR_TARGET 0x0000000000000000ULL
48 static inline u64 readq(void __iomem *reg)
50 return ((u64)readl((char *)reg + 0x4UL) << 32) |
54 static inline void writeq(u64 val, void __iomem *reg)
56 writel(val & 0xffffffff, reg);
57 writel((u32)(val >> 32), (char *)reg + 0x4UL);
62 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
64 enum vnic_dev_intr_mode {
65 VNIC_DEV_INTR_MODE_UNKNOWN,
66 VNIC_DEV_INTR_MODE_INTX,
67 VNIC_DEV_INTR_MODE_MSI,
68 VNIC_DEV_INTR_MODE_MSIX,
77 struct vnic_dev_ring {
82 void *descs_unaligned;
83 size_t size_unaligned;
84 dma_addr_t base_addr_unaligned;
85 unsigned int desc_size;
86 unsigned int desc_count;
87 unsigned int desc_avail;
90 struct vnic_dev_iomap_info {
99 void *vnic_dev_priv(struct vnic_dev *vdev);
100 unsigned int vnic_dev_get_res_count(struct vnic_dev *vdev,
101 enum vnic_res_type type);
102 void vnic_register_cbacks(struct vnic_dev *vdev,
103 void *(*alloc_consistent)(void *priv, size_t size,
104 dma_addr_t *dma_handle, u8 *name),
105 void (*free_consistent)(void *priv,
106 size_t size, void *vaddr,
107 dma_addr_t dma_handle));
108 void __iomem *vnic_dev_get_res(struct vnic_dev *vdev, enum vnic_res_type type,
110 dma_addr_t vnic_dev_get_res_bus_addr(struct vnic_dev *vdev,
111 enum vnic_res_type type, unsigned int index);
112 uint8_t vnic_dev_get_res_bar(struct vnic_dev *vdev,
113 enum vnic_res_type type);
114 uint32_t vnic_dev_get_res_offset(struct vnic_dev *vdev,
115 enum vnic_res_type type, unsigned int index);
116 unsigned long vnic_dev_get_res_type_len(struct vnic_dev *vdev,
117 enum vnic_res_type type);
118 unsigned int vnic_dev_desc_ring_size(struct vnic_dev_ring *ring,
119 unsigned int desc_count, unsigned int desc_size);
120 void vnic_dev_clear_desc_ring(struct vnic_dev_ring *ring);
121 void vnic_set_hdr_split_size(struct vnic_dev *vdev, u16 size);
122 u16 vnic_get_hdr_split_size(struct vnic_dev *vdev);
123 int vnic_dev_alloc_desc_ring(struct vnic_dev *vdev, struct vnic_dev_ring *ring,
124 unsigned int desc_count, unsigned int desc_size, unsigned int socket_id,
126 void vnic_dev_free_desc_ring(struct vnic_dev *vdev,
127 struct vnic_dev_ring *ring);
128 int vnic_dev_cmd(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd,
129 u64 *a0, u64 *a1, int wait);
130 int vnic_dev_cmd_args(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd,
131 u64 *args, int nargs, int wait);
132 void vnic_dev_cmd_proxy_by_index_start(struct vnic_dev *vdev, u16 index);
133 void vnic_dev_cmd_proxy_by_bdf_start(struct vnic_dev *vdev, u16 bdf);
134 void vnic_dev_cmd_proxy_end(struct vnic_dev *vdev);
135 int vnic_dev_fw_info(struct vnic_dev *vdev,
136 struct vnic_devcmd_fw_info **fw_info);
137 int vnic_dev_capable_adv_filters(struct vnic_dev *vdev);
138 int vnic_dev_asic_info(struct vnic_dev *vdev, u16 *asic_type, u16 *asic_rev);
139 int vnic_dev_spec(struct vnic_dev *vdev, unsigned int offset, size_t size,
141 int vnic_dev_stats_clear(struct vnic_dev *vdev);
142 int vnic_dev_stats_dump(struct vnic_dev *vdev, struct vnic_stats **stats);
143 int vnic_dev_hang_notify(struct vnic_dev *vdev);
144 int vnic_dev_packet_filter(struct vnic_dev *vdev, int directed, int multicast,
145 int broadcast, int promisc, int allmulti);
146 int vnic_dev_packet_filter_all(struct vnic_dev *vdev, int directed,
147 int multicast, int broadcast, int promisc, int allmulti);
148 int vnic_dev_add_addr(struct vnic_dev *vdev, u8 *addr);
149 int vnic_dev_del_addr(struct vnic_dev *vdev, u8 *addr);
150 int vnic_dev_get_mac_addr(struct vnic_dev *vdev, u8 *mac_addr);
151 int vnic_dev_raise_intr(struct vnic_dev *vdev, u16 intr);
152 int vnic_dev_notify_set(struct vnic_dev *vdev, u16 intr);
153 void vnic_dev_set_reset_flag(struct vnic_dev *vdev, int state);
154 int vnic_dev_notify_unset(struct vnic_dev *vdev);
155 int vnic_dev_notify_setcmd(struct vnic_dev *vdev,
156 void *notify_addr, dma_addr_t notify_pa, u16 intr);
157 int vnic_dev_notify_unsetcmd(struct vnic_dev *vdev);
158 int vnic_dev_link_status(struct vnic_dev *vdev);
159 u32 vnic_dev_port_speed(struct vnic_dev *vdev);
160 u32 vnic_dev_msg_lvl(struct vnic_dev *vdev);
161 u32 vnic_dev_mtu(struct vnic_dev *vdev);
162 u32 vnic_dev_link_down_cnt(struct vnic_dev *vdev);
163 u32 vnic_dev_notify_status(struct vnic_dev *vdev);
164 u32 vnic_dev_uif(struct vnic_dev *vdev);
165 int vnic_dev_close(struct vnic_dev *vdev);
166 int vnic_dev_enable(struct vnic_dev *vdev);
167 int vnic_dev_enable_wait(struct vnic_dev *vdev);
168 int vnic_dev_disable(struct vnic_dev *vdev);
169 int vnic_dev_open(struct vnic_dev *vdev, int arg);
170 int vnic_dev_open_done(struct vnic_dev *vdev, int *done);
171 int vnic_dev_init(struct vnic_dev *vdev, int arg);
172 int vnic_dev_init_done(struct vnic_dev *vdev, int *done, int *err);
173 int vnic_dev_init_prov(struct vnic_dev *vdev, u8 *buf, u32 len);
174 int vnic_dev_deinit(struct vnic_dev *vdev);
175 void vnic_dev_intr_coal_timer_info_default(struct vnic_dev *vdev);
176 int vnic_dev_intr_coal_timer_info(struct vnic_dev *vdev);
177 int vnic_dev_soft_reset(struct vnic_dev *vdev, int arg);
178 int vnic_dev_soft_reset_done(struct vnic_dev *vdev, int *done);
179 int vnic_dev_hang_reset(struct vnic_dev *vdev, int arg);
180 int vnic_dev_hang_reset_done(struct vnic_dev *vdev, int *done);
181 void vnic_dev_set_intr_mode(struct vnic_dev *vdev,
182 enum vnic_dev_intr_mode intr_mode);
183 enum vnic_dev_intr_mode vnic_dev_get_intr_mode(struct vnic_dev *vdev);
184 u32 vnic_dev_intr_coal_timer_usec_to_hw(struct vnic_dev *vdev, u32 usec);
185 u32 vnic_dev_intr_coal_timer_hw_to_usec(struct vnic_dev *vdev, u32 hw_cycles);
186 u32 vnic_dev_get_intr_coal_timer_max(struct vnic_dev *vdev);
187 void vnic_dev_unregister(struct vnic_dev *vdev);
188 int vnic_dev_set_ig_vlan_rewrite_mode(struct vnic_dev *vdev,
189 u8 ig_vlan_rewrite_mode);
190 struct vnic_dev *vnic_dev_register(struct vnic_dev *vdev,
191 void *priv, struct rte_pci_device *pdev, struct vnic_dev_bar *bar,
192 unsigned int num_bars);
193 struct rte_pci_device *vnic_dev_get_pdev(struct vnic_dev *vdev);
194 int vnic_dev_cmd_init(struct vnic_dev *vdev, int fallback);
195 int vnic_dev_get_size(void);
196 int vnic_dev_int13(struct vnic_dev *vdev, u64 arg, u32 op);
197 int vnic_dev_perbi(struct vnic_dev *vdev, u64 arg, u32 op);
198 u32 vnic_dev_perbi_rebuild_cnt(struct vnic_dev *vdev);
199 int vnic_dev_init_prov2(struct vnic_dev *vdev, u8 *buf, u32 len);
200 int vnic_dev_enable2(struct vnic_dev *vdev, int active);
201 int vnic_dev_enable2_done(struct vnic_dev *vdev, int *status);
202 int vnic_dev_deinit_done(struct vnic_dev *vdev, int *status);
203 int vnic_dev_set_mac_addr(struct vnic_dev *vdev, u8 *mac_addr);
204 int vnic_dev_classifier(struct vnic_dev *vdev, u8 cmd, u16 *entry,
205 struct filter_v2 *data);
207 int vnic_dev_overlay_offload_enable_disable(struct vnic_dev *vdev,
208 u8 overlay, u8 config);
209 int vnic_dev_overlay_offload_cfg(struct vnic_dev *vdev, u8 overlay,
210 u16 vxlan_udp_port_number);
212 #endif /* _VNIC_DEV_H_ */