Linux 4.16.11
[linux/fpc-iii.git] / drivers / net / ethernet / cisco / enic / vnic_dev.h
blob9d43d6bb9907ec323d9c1520720447bb7731c808
1 /*
2 * Copyright 2008-2010 Cisco Systems, Inc. All rights reserved.
3 * Copyright 2007 Nuova Systems, Inc. All rights reserved.
5 * This program is free software; you may redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License.
9 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
10 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
11 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
12 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
13 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
14 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
15 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
16 * SOFTWARE.
20 #ifndef _VNIC_DEV_H_
21 #define _VNIC_DEV_H_
23 #include "vnic_resource.h"
24 #include "vnic_devcmd.h"
26 #ifndef VNIC_PADDR_TARGET
27 #define VNIC_PADDR_TARGET 0x0000000000000000ULL
28 #endif
30 #ifndef readq
31 static inline u64 readq(void __iomem *reg)
33 return (((u64)readl(reg + 0x4UL) << 32) |
34 (u64)readl(reg));
37 static inline void writeq(u64 val, void __iomem *reg)
39 writel(val & 0xffffffff, reg);
40 writel(val >> 32, reg + 0x4UL);
42 #endif
44 #undef pr_fmt
45 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
47 enum vnic_dev_intr_mode {
48 VNIC_DEV_INTR_MODE_UNKNOWN,
49 VNIC_DEV_INTR_MODE_INTX,
50 VNIC_DEV_INTR_MODE_MSI,
51 VNIC_DEV_INTR_MODE_MSIX,
54 struct vnic_dev_bar {
55 void __iomem *vaddr;
56 dma_addr_t bus_addr;
57 unsigned long len;
60 struct vnic_dev_ring {
61 void *descs;
62 size_t size;
63 dma_addr_t base_addr;
64 size_t base_align;
65 void *descs_unaligned;
66 size_t size_unaligned;
67 dma_addr_t base_addr_unaligned;
68 unsigned int desc_size;
69 unsigned int desc_count;
70 unsigned int desc_avail;
73 enum vnic_proxy_type {
74 PROXY_NONE,
75 PROXY_BY_BDF,
76 PROXY_BY_INDEX,
79 struct vnic_res {
80 void __iomem *vaddr;
81 dma_addr_t bus_addr;
82 unsigned int count;
85 struct vnic_intr_coal_timer_info {
86 u32 mul;
87 u32 div;
88 u32 max_usec;
91 struct vnic_dev {
92 void *priv;
93 struct pci_dev *pdev;
94 struct vnic_res res[RES_TYPE_MAX];
95 enum vnic_dev_intr_mode intr_mode;
96 struct vnic_devcmd __iomem *devcmd;
97 struct vnic_devcmd_notify *notify;
98 struct vnic_devcmd_notify notify_copy;
99 dma_addr_t notify_pa;
100 u32 notify_sz;
101 dma_addr_t linkstatus_pa;
102 struct vnic_stats *stats;
103 dma_addr_t stats_pa;
104 struct vnic_devcmd_fw_info *fw_info;
105 dma_addr_t fw_info_pa;
106 enum vnic_proxy_type proxy;
107 u32 proxy_index;
108 u64 args[VNIC_DEVCMD_NARGS];
109 struct vnic_intr_coal_timer_info intr_coal_timer_info;
110 struct devcmd2_controller *devcmd2;
111 int (*devcmd_rtn)(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd,
112 int wait);
115 struct vnic_stats;
117 void *vnic_dev_priv(struct vnic_dev *vdev);
118 unsigned int vnic_dev_get_res_count(struct vnic_dev *vdev,
119 enum vnic_res_type type);
120 void __iomem *vnic_dev_get_res(struct vnic_dev *vdev, enum vnic_res_type type,
121 unsigned int index);
122 void vnic_dev_clear_desc_ring(struct vnic_dev_ring *ring);
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);
125 void vnic_dev_free_desc_ring(struct vnic_dev *vdev,
126 struct vnic_dev_ring *ring);
127 int vnic_dev_cmd(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd,
128 u64 *a0, u64 *a1, int wait);
129 void vnic_dev_cmd_proxy_by_index_start(struct vnic_dev *vdev, u16 index);
130 void vnic_dev_cmd_proxy_end(struct vnic_dev *vdev);
131 int vnic_dev_fw_info(struct vnic_dev *vdev,
132 struct vnic_devcmd_fw_info **fw_info);
133 int vnic_dev_spec(struct vnic_dev *vdev, unsigned int offset, unsigned int size,
134 void *value);
135 int vnic_dev_stats_dump(struct vnic_dev *vdev, struct vnic_stats **stats);
136 int vnic_dev_hang_notify(struct vnic_dev *vdev);
137 int vnic_dev_packet_filter(struct vnic_dev *vdev, int directed, int multicast,
138 int broadcast, int promisc, int allmulti);
139 int vnic_dev_add_addr(struct vnic_dev *vdev, const u8 *addr);
140 int vnic_dev_del_addr(struct vnic_dev *vdev, const u8 *addr);
141 int vnic_dev_get_mac_addr(struct vnic_dev *vdev, u8 *mac_addr);
142 int vnic_dev_notify_set(struct vnic_dev *vdev, u16 intr);
143 int vnic_dev_notify_unset(struct vnic_dev *vdev);
144 int vnic_dev_link_status(struct vnic_dev *vdev);
145 u32 vnic_dev_port_speed(struct vnic_dev *vdev);
146 u32 vnic_dev_msg_lvl(struct vnic_dev *vdev);
147 u32 vnic_dev_mtu(struct vnic_dev *vdev);
148 int vnic_dev_close(struct vnic_dev *vdev);
149 int vnic_dev_enable_wait(struct vnic_dev *vdev);
150 int vnic_dev_disable(struct vnic_dev *vdev);
151 int vnic_dev_open(struct vnic_dev *vdev, int arg);
152 int vnic_dev_open_done(struct vnic_dev *vdev, int *done);
153 int vnic_dev_init(struct vnic_dev *vdev, int arg);
154 int vnic_dev_deinit(struct vnic_dev *vdev);
155 void vnic_dev_intr_coal_timer_info_default(struct vnic_dev *vdev);
156 int vnic_dev_intr_coal_timer_info(struct vnic_dev *vdev);
157 int vnic_dev_hang_reset(struct vnic_dev *vdev, int arg);
158 int vnic_dev_soft_reset(struct vnic_dev *vdev, int arg);
159 int vnic_dev_hang_reset_done(struct vnic_dev *vdev, int *done);
160 int vnic_dev_soft_reset_done(struct vnic_dev *vdev, int *done);
161 void vnic_dev_set_intr_mode(struct vnic_dev *vdev,
162 enum vnic_dev_intr_mode intr_mode);
163 enum vnic_dev_intr_mode vnic_dev_get_intr_mode(struct vnic_dev *vdev);
164 u32 vnic_dev_intr_coal_timer_usec_to_hw(struct vnic_dev *vdev, u32 usec);
165 u32 vnic_dev_intr_coal_timer_hw_to_usec(struct vnic_dev *vdev, u32 hw_cycles);
166 u32 vnic_dev_get_intr_coal_timer_max(struct vnic_dev *vdev);
167 void vnic_dev_unregister(struct vnic_dev *vdev);
168 int vnic_dev_set_ig_vlan_rewrite_mode(struct vnic_dev *vdev,
169 u8 ig_vlan_rewrite_mode);
170 struct vnic_dev *vnic_dev_register(struct vnic_dev *vdev,
171 void *priv, struct pci_dev *pdev, struct vnic_dev_bar *bar,
172 unsigned int num_bars);
173 struct pci_dev *vnic_dev_get_pdev(struct vnic_dev *vdev);
174 int vnic_dev_init_prov2(struct vnic_dev *vdev, u8 *buf, u32 len);
175 int vnic_dev_enable2(struct vnic_dev *vdev, int active);
176 int vnic_dev_enable2_done(struct vnic_dev *vdev, int *status);
177 int vnic_dev_deinit_done(struct vnic_dev *vdev, int *status);
178 int vnic_dev_set_mac_addr(struct vnic_dev *vdev, u8 *mac_addr);
179 int vnic_dev_classifier(struct vnic_dev *vdev, u8 cmd, u16 *entry,
180 struct filter *data);
181 int vnic_devcmd_init(struct vnic_dev *vdev);
182 int vnic_dev_overlay_offload_ctrl(struct vnic_dev *vdev, u8 overlay, u8 config);
183 int vnic_dev_overlay_offload_cfg(struct vnic_dev *vdev, u8 overlay,
184 u16 vxlan_udp_port_number);
185 int vnic_dev_get_supported_feature_ver(struct vnic_dev *vdev, u8 feature,
186 u64 *supported_versions);
188 #endif /* _VNIC_DEV_H_ */