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
23 #include "vnic_resource.h"
24 #include "vnic_devcmd.h"
26 #ifndef VNIC_PADDR_TARGET
27 #define VNIC_PADDR_TARGET 0x0000000000000000ULL
31 static inline u64 readq(void __iomem *reg)
33 return (((u64)readl(reg + 0x4UL) << 32) |
37 static inline void writeq(u64 val, void __iomem *reg)
39 writel(val & 0xffffffff, reg);
40 writel(val >> 32, reg + 0x4UL);
45 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
47 enum vnic_dev_hw_version {
48 VNIC_DEV_HW_VER_UNKNOWN,
53 enum vnic_dev_intr_mode {
54 VNIC_DEV_INTR_MODE_UNKNOWN,
55 VNIC_DEV_INTR_MODE_INTX,
56 VNIC_DEV_INTR_MODE_MSI,
57 VNIC_DEV_INTR_MODE_MSIX,
66 struct vnic_dev_ring {
71 void *descs_unaligned;
72 size_t size_unaligned;
73 dma_addr_t base_addr_unaligned;
74 unsigned int desc_size;
75 unsigned int desc_count;
76 unsigned int desc_avail;
82 void *vnic_dev_priv(struct vnic_dev *vdev);
83 unsigned int vnic_dev_get_res_count(struct vnic_dev *vdev,
84 enum vnic_res_type type);
85 void __iomem *vnic_dev_get_res(struct vnic_dev *vdev, enum vnic_res_type type,
87 dma_addr_t vnic_dev_get_res_bus_addr(struct vnic_dev *vdev,
88 enum vnic_res_type type, unsigned int index);
89 unsigned int vnic_dev_desc_ring_size(struct vnic_dev_ring *ring,
90 unsigned int desc_count, unsigned int desc_size);
91 void vnic_dev_clear_desc_ring(struct vnic_dev_ring *ring);
92 int vnic_dev_alloc_desc_ring(struct vnic_dev *vdev, struct vnic_dev_ring *ring,
93 unsigned int desc_count, unsigned int desc_size);
94 void vnic_dev_free_desc_ring(struct vnic_dev *vdev,
95 struct vnic_dev_ring *ring);
96 int vnic_dev_cmd(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd,
97 u64 *a0, u64 *a1, int wait);
98 void vnic_dev_cmd_proxy_by_bdf_start(struct vnic_dev *vdev, u16 bdf);
99 void vnic_dev_cmd_proxy_end(struct vnic_dev *vdev);
100 int vnic_dev_fw_info(struct vnic_dev *vdev,
101 struct vnic_devcmd_fw_info **fw_info);
102 int vnic_dev_hw_version(struct vnic_dev *vdev,
103 enum vnic_dev_hw_version *hw_ver);
104 int vnic_dev_spec(struct vnic_dev *vdev, unsigned int offset, unsigned int size,
106 int vnic_dev_stats_clear(struct vnic_dev *vdev);
107 int vnic_dev_stats_dump(struct vnic_dev *vdev, struct vnic_stats **stats);
108 int vnic_dev_hang_notify(struct vnic_dev *vdev);
109 int vnic_dev_packet_filter(struct vnic_dev *vdev, int directed, int multicast,
110 int broadcast, int promisc, int allmulti);
111 int vnic_dev_packet_filter_all(struct vnic_dev *vdev, int directed,
112 int multicast, int broadcast, int promisc, int allmulti);
113 int vnic_dev_add_addr(struct vnic_dev *vdev, u8 *addr);
114 int vnic_dev_del_addr(struct vnic_dev *vdev, u8 *addr);
115 int vnic_dev_mac_addr(struct vnic_dev *vdev, u8 *mac_addr);
116 int vnic_dev_raise_intr(struct vnic_dev *vdev, u16 intr);
117 int vnic_dev_notify_setcmd(struct vnic_dev *vdev,
118 void *notify_addr, dma_addr_t notify_pa, u16 intr);
119 int vnic_dev_notify_set(struct vnic_dev *vdev, u16 intr);
120 int vnic_dev_notify_unsetcmd(struct vnic_dev *vdev);
121 int vnic_dev_notify_unset(struct vnic_dev *vdev);
122 int vnic_dev_link_status(struct vnic_dev *vdev);
123 u32 vnic_dev_port_speed(struct vnic_dev *vdev);
124 u32 vnic_dev_msg_lvl(struct vnic_dev *vdev);
125 u32 vnic_dev_mtu(struct vnic_dev *vdev);
126 u32 vnic_dev_link_down_cnt(struct vnic_dev *vdev);
127 u32 vnic_dev_notify_status(struct vnic_dev *vdev);
128 u32 vnic_dev_uif(struct vnic_dev *vdev);
129 int vnic_dev_close(struct vnic_dev *vdev);
130 int vnic_dev_enable(struct vnic_dev *vdev);
131 int vnic_dev_enable_wait(struct vnic_dev *vdev);
132 int vnic_dev_disable(struct vnic_dev *vdev);
133 int vnic_dev_open(struct vnic_dev *vdev, int arg);
134 int vnic_dev_open_done(struct vnic_dev *vdev, int *done);
135 int vnic_dev_init(struct vnic_dev *vdev, int arg);
136 int vnic_dev_init_done(struct vnic_dev *vdev, int *done, int *err);
137 int vnic_dev_init_prov(struct vnic_dev *vdev, u8 *buf, u32 len);
138 int vnic_dev_deinit(struct vnic_dev *vdev);
139 int vnic_dev_soft_reset(struct vnic_dev *vdev, int arg);
140 int vnic_dev_soft_reset_done(struct vnic_dev *vdev, int *done);
141 int vnic_dev_hang_reset(struct vnic_dev *vdev, int arg);
142 int vnic_dev_hang_reset_done(struct vnic_dev *vdev, int *done);
143 void vnic_dev_set_intr_mode(struct vnic_dev *vdev,
144 enum vnic_dev_intr_mode intr_mode);
145 enum vnic_dev_intr_mode vnic_dev_get_intr_mode(struct vnic_dev *vdev);
146 void vnic_dev_unregister(struct vnic_dev *vdev);
147 int vnic_dev_set_ig_vlan_rewrite_mode(struct vnic_dev *vdev,
148 u8 ig_vlan_rewrite_mode);
149 struct vnic_dev *vnic_dev_register(struct vnic_dev *vdev,
150 void *priv, struct pci_dev *pdev, struct vnic_dev_bar *bar,
151 unsigned int num_bars);
153 #endif /* _VNIC_DEV_H_ */