1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2008-2017 Cisco Systems, Inc. All rights reserved.
3 * Copyright 2007 Nuova Systems, Inc. All rights reserved.
10 #include <rte_bus_pci.h>
12 #include "enic_compat.h"
13 #include "vnic_resource.h"
14 #include "vnic_devcmd.h"
16 #ifndef VNIC_PADDR_TARGET
17 #define VNIC_PADDR_TARGET 0x0000000000000000ULL
21 static inline u64 readq(void __iomem *reg)
23 return ((u64)readl((char *)reg + 0x4UL) << 32) |
27 static inline void writeq(u64 val, void __iomem *reg)
29 writel(val & 0xffffffff, reg);
30 writel((u32)(val >> 32), (char *)reg + 0x4UL);
35 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
37 enum vnic_dev_intr_mode {
38 VNIC_DEV_INTR_MODE_UNKNOWN,
39 VNIC_DEV_INTR_MODE_INTX,
40 VNIC_DEV_INTR_MODE_MSI,
41 VNIC_DEV_INTR_MODE_MSIX,
50 struct vnic_dev_ring {
55 void *descs_unaligned;
56 size_t size_unaligned;
57 dma_addr_t base_addr_unaligned;
58 unsigned int desc_size;
59 unsigned int desc_count;
60 unsigned int desc_avail;
63 struct vnic_dev_iomap_info {
72 void *vnic_dev_priv(struct vnic_dev *vdev);
73 unsigned int vnic_dev_get_res_count(struct vnic_dev *vdev,
74 enum vnic_res_type type);
75 void vnic_register_cbacks(struct vnic_dev *vdev,
76 void *(*alloc_consistent)(void *priv, size_t size,
77 dma_addr_t *dma_handle, u8 *name),
78 void (*free_consistent)(void *priv,
79 size_t size, void *vaddr,
80 dma_addr_t dma_handle));
81 void __iomem *vnic_dev_get_res(struct vnic_dev *vdev, enum vnic_res_type type,
83 dma_addr_t vnic_dev_get_res_bus_addr(struct vnic_dev *vdev,
84 enum vnic_res_type type, unsigned int index);
85 uint8_t vnic_dev_get_res_bar(struct vnic_dev *vdev,
86 enum vnic_res_type type);
87 uint32_t vnic_dev_get_res_offset(struct vnic_dev *vdev,
88 enum vnic_res_type type, unsigned int index);
89 unsigned long vnic_dev_get_res_type_len(struct vnic_dev *vdev,
90 enum vnic_res_type type);
91 unsigned int vnic_dev_desc_ring_size(struct vnic_dev_ring *ring,
92 unsigned int desc_count, unsigned int desc_size);
93 void vnic_dev_clear_desc_ring(struct vnic_dev_ring *ring);
94 int vnic_dev_alloc_desc_ring(struct vnic_dev *vdev, struct vnic_dev_ring *ring,
95 unsigned int desc_count, unsigned int desc_size, unsigned int socket_id,
97 void vnic_dev_free_desc_ring(struct vnic_dev *vdev,
98 struct vnic_dev_ring *ring);
99 int vnic_dev_cmd(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd,
100 u64 *a0, u64 *a1, int wait);
101 int vnic_dev_cmd_args(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd,
102 u64 *args, int nargs, int wait);
103 void vnic_dev_cmd_proxy_by_index_start(struct vnic_dev *vdev, u16 index);
104 void vnic_dev_cmd_proxy_by_bdf_start(struct vnic_dev *vdev, u16 bdf);
105 void vnic_dev_cmd_proxy_end(struct vnic_dev *vdev);
106 int vnic_dev_fw_info(struct vnic_dev *vdev,
107 struct vnic_devcmd_fw_info **fw_info);
108 int vnic_dev_capable_adv_filters(struct vnic_dev *vdev);
109 int vnic_dev_capable(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd);
110 int vnic_dev_capable_filter_mode(struct vnic_dev *vdev, u32 *mode,
112 int vnic_dev_asic_info(struct vnic_dev *vdev, u16 *asic_type, u16 *asic_rev);
113 int vnic_dev_spec(struct vnic_dev *vdev, unsigned int offset, size_t size,
115 int vnic_dev_stats_clear(struct vnic_dev *vdev);
116 int vnic_dev_stats_dump(struct vnic_dev *vdev, struct vnic_stats **stats);
117 int vnic_dev_hang_notify(struct vnic_dev *vdev);
118 int vnic_dev_packet_filter(struct vnic_dev *vdev, int directed, int multicast,
119 int broadcast, int promisc, int allmulti);
120 int vnic_dev_packet_filter_all(struct vnic_dev *vdev, int directed,
121 int multicast, int broadcast, int promisc, int allmulti);
122 int vnic_dev_add_addr(struct vnic_dev *vdev, u8 *addr);
123 int vnic_dev_del_addr(struct vnic_dev *vdev, u8 *addr);
124 int vnic_dev_get_mac_addr(struct vnic_dev *vdev, u8 *mac_addr);
125 int vnic_dev_raise_intr(struct vnic_dev *vdev, u16 intr);
126 int vnic_dev_notify_set(struct vnic_dev *vdev, u16 intr);
127 void vnic_dev_set_reset_flag(struct vnic_dev *vdev, int state);
128 int vnic_dev_notify_unset(struct vnic_dev *vdev);
129 int vnic_dev_notify_setcmd(struct vnic_dev *vdev,
130 void *notify_addr, dma_addr_t notify_pa, u16 intr);
131 int vnic_dev_notify_unsetcmd(struct vnic_dev *vdev);
132 int vnic_dev_link_status(struct vnic_dev *vdev);
133 u32 vnic_dev_port_speed(struct vnic_dev *vdev);
134 u32 vnic_dev_msg_lvl(struct vnic_dev *vdev);
135 u32 vnic_dev_mtu(struct vnic_dev *vdev);
136 u32 vnic_dev_link_down_cnt(struct vnic_dev *vdev);
137 u32 vnic_dev_notify_status(struct vnic_dev *vdev);
138 u32 vnic_dev_uif(struct vnic_dev *vdev);
139 int vnic_dev_close(struct vnic_dev *vdev);
140 int vnic_dev_enable(struct vnic_dev *vdev);
141 int vnic_dev_enable_wait(struct vnic_dev *vdev);
142 int vnic_dev_disable(struct vnic_dev *vdev);
143 int vnic_dev_open(struct vnic_dev *vdev, int arg);
144 int vnic_dev_open_done(struct vnic_dev *vdev, int *done);
145 int vnic_dev_init(struct vnic_dev *vdev, int arg);
146 int vnic_dev_init_done(struct vnic_dev *vdev, int *done, int *err);
147 int vnic_dev_init_prov(struct vnic_dev *vdev, u8 *buf, u32 len);
148 int vnic_dev_deinit(struct vnic_dev *vdev);
149 void vnic_dev_intr_coal_timer_info_default(struct vnic_dev *vdev);
150 int vnic_dev_intr_coal_timer_info(struct vnic_dev *vdev);
151 int vnic_dev_soft_reset(struct vnic_dev *vdev, int arg);
152 int vnic_dev_soft_reset_done(struct vnic_dev *vdev, int *done);
153 int vnic_dev_hang_reset(struct vnic_dev *vdev, int arg);
154 int vnic_dev_hang_reset_done(struct vnic_dev *vdev, int *done);
155 void vnic_dev_set_intr_mode(struct vnic_dev *vdev,
156 enum vnic_dev_intr_mode intr_mode);
157 enum vnic_dev_intr_mode vnic_dev_get_intr_mode(struct vnic_dev *vdev);
158 u32 vnic_dev_intr_coal_timer_usec_to_hw(struct vnic_dev *vdev, u32 usec);
159 u32 vnic_dev_intr_coal_timer_hw_to_usec(struct vnic_dev *vdev, u32 hw_cycles);
160 u32 vnic_dev_get_intr_coal_timer_max(struct vnic_dev *vdev);
161 void vnic_dev_unregister(struct vnic_dev *vdev);
162 int vnic_dev_set_ig_vlan_rewrite_mode(struct vnic_dev *vdev,
163 u8 ig_vlan_rewrite_mode);
164 struct vnic_dev *vnic_dev_register(struct vnic_dev *vdev,
165 void *priv, struct rte_pci_device *pdev, struct vnic_dev_bar *bar,
166 unsigned int num_bars);
167 struct rte_pci_device *vnic_dev_get_pdev(struct vnic_dev *vdev);
168 int vnic_dev_cmd_init(struct vnic_dev *vdev, int fallback);
169 int vnic_dev_get_size(void);
170 int vnic_dev_int13(struct vnic_dev *vdev, u64 arg, u32 op);
171 int vnic_dev_perbi(struct vnic_dev *vdev, u64 arg, u32 op);
172 u32 vnic_dev_perbi_rebuild_cnt(struct vnic_dev *vdev);
173 int vnic_dev_init_prov2(struct vnic_dev *vdev, u8 *buf, u32 len);
174 int vnic_dev_enable2(struct vnic_dev *vdev, int active);
175 int vnic_dev_enable2_done(struct vnic_dev *vdev, int *status);
176 int vnic_dev_deinit_done(struct vnic_dev *vdev, int *status);
177 int vnic_dev_set_mac_addr(struct vnic_dev *vdev, u8 *mac_addr);
178 int vnic_dev_classifier(struct vnic_dev *vdev, u8 cmd, u16 *entry,
179 struct filter_v2 *data, struct filter_action_v2 *action_v2);
181 int vnic_dev_overlay_offload_enable_disable(struct vnic_dev *vdev,
182 u8 overlay, u8 config);
183 int vnic_dev_overlay_offload_cfg(struct vnic_dev *vdev, u8 overlay,
184 u16 vxlan_udp_port_number);
186 #endif /* _VNIC_DEV_H_ */