2 * Copyright 2008 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
21 #include "vnic_resource.h"
22 #include "vnic_devcmd.h"
25 * These defines avoid symbol clash between fnic and enic (Cisco 10G Eth
26 * Driver) when both are built with CONFIG options =y
28 #define vnic_dev_priv fnic_dev_priv
29 #define vnic_dev_get_res_count fnic_dev_get_res_count
30 #define vnic_dev_get_res fnic_dev_get_res
31 #define vnic_dev_desc_ring_size fnic_dev_desc_ring_siz
32 #define vnic_dev_clear_desc_ring fnic_dev_clear_desc_ring
33 #define vnic_dev_alloc_desc_ring fnic_dev_alloc_desc_ring
34 #define vnic_dev_free_desc_ring fnic_dev_free_desc_ring
35 #define vnic_dev_cmd fnic_dev_cmd
36 #define vnic_dev_fw_info fnic_dev_fw_info
37 #define vnic_dev_spec fnic_dev_spec
38 #define vnic_dev_stats_clear fnic_dev_stats_clear
39 #define vnic_dev_stats_dump fnic_dev_stats_dump
40 #define vnic_dev_hang_notify fnic_dev_hang_notify
41 #define vnic_dev_packet_filter fnic_dev_packet_filter
42 #define vnic_dev_add_addr fnic_dev_add_addr
43 #define vnic_dev_del_addr fnic_dev_del_addr
44 #define vnic_dev_mac_addr fnic_dev_mac_addr
45 #define vnic_dev_notify_set fnic_dev_notify_set
46 #define vnic_dev_notify_unset fnic_dev_notify_unset
47 #define vnic_dev_link_status fnic_dev_link_status
48 #define vnic_dev_port_speed fnic_dev_port_speed
49 #define vnic_dev_msg_lvl fnic_dev_msg_lvl
50 #define vnic_dev_mtu fnic_dev_mtu
51 #define vnic_dev_link_down_cnt fnic_dev_link_down_cnt
52 #define vnic_dev_close fnic_dev_close
53 #define vnic_dev_enable fnic_dev_enable
54 #define vnic_dev_disable fnic_dev_disable
55 #define vnic_dev_open fnic_dev_open
56 #define vnic_dev_open_done fnic_dev_open_done
57 #define vnic_dev_init fnic_dev_init
58 #define vnic_dev_soft_reset fnic_dev_soft_reset
59 #define vnic_dev_soft_reset_done fnic_dev_soft_reset_done
60 #define vnic_dev_set_intr_mode fnic_dev_set_intr_mode
61 #define vnic_dev_get_intr_mode fnic_dev_get_intr_mode
62 #define vnic_dev_unregister fnic_dev_unregister
63 #define vnic_dev_register fnic_dev_register
65 #ifndef VNIC_PADDR_TARGET
66 #define VNIC_PADDR_TARGET 0x0000000000000000ULL
70 static inline u64
readq(void __iomem
*reg
)
72 return ((u64
)readl(reg
+ 0x4UL
) << 32) | (u64
)readl(reg
);
75 static inline void writeq(u64 val
, void __iomem
*reg
)
77 writel(val
& 0xffffffff, reg
);
78 writel(val
>> 32, reg
+ 0x4UL
);
82 enum vnic_dev_intr_mode
{
83 VNIC_DEV_INTR_MODE_UNKNOWN
,
84 VNIC_DEV_INTR_MODE_INTX
,
85 VNIC_DEV_INTR_MODE_MSI
,
86 VNIC_DEV_INTR_MODE_MSIX
,
95 struct vnic_dev_ring
{
100 void *descs_unaligned
;
101 size_t size_unaligned
;
102 dma_addr_t base_addr_unaligned
;
103 unsigned int desc_size
;
104 unsigned int desc_count
;
105 unsigned int desc_avail
;
111 void *vnic_dev_priv(struct vnic_dev
*vdev
);
112 unsigned int vnic_dev_get_res_count(struct vnic_dev
*vdev
,
113 enum vnic_res_type type
);
114 void __iomem
*vnic_dev_get_res(struct vnic_dev
*vdev
, enum vnic_res_type type
,
116 unsigned int vnic_dev_desc_ring_size(struct vnic_dev_ring
*ring
,
117 unsigned int desc_count
,
118 unsigned int desc_size
);
119 void vnic_dev_clear_desc_ring(struct vnic_dev_ring
*ring
);
120 int vnic_dev_alloc_desc_ring(struct vnic_dev
*vdev
, struct vnic_dev_ring
*ring
,
121 unsigned int desc_count
, unsigned int desc_size
);
122 void vnic_dev_free_desc_ring(struct vnic_dev
*vdev
,
123 struct vnic_dev_ring
*ring
);
124 int vnic_dev_cmd(struct vnic_dev
*vdev
, enum vnic_devcmd_cmd cmd
,
125 u64
*a0
, u64
*a1
, int wait
);
126 int vnic_dev_fw_info(struct vnic_dev
*vdev
,
127 struct vnic_devcmd_fw_info
**fw_info
);
128 int vnic_dev_spec(struct vnic_dev
*vdev
, unsigned int offset
,
129 unsigned int size
, void *value
);
130 int vnic_dev_stats_clear(struct vnic_dev
*vdev
);
131 int vnic_dev_stats_dump(struct vnic_dev
*vdev
, struct vnic_stats
**stats
);
132 int vnic_dev_hang_notify(struct vnic_dev
*vdev
);
133 void vnic_dev_packet_filter(struct vnic_dev
*vdev
, int directed
, int multicast
,
134 int broadcast
, int promisc
, int allmulti
);
135 void vnic_dev_add_addr(struct vnic_dev
*vdev
, u8
*addr
);
136 void vnic_dev_del_addr(struct vnic_dev
*vdev
, u8
*addr
);
137 int vnic_dev_mac_addr(struct vnic_dev
*vdev
, u8
*mac_addr
);
138 int vnic_dev_notify_set(struct vnic_dev
*vdev
, u16 intr
);
139 void vnic_dev_notify_unset(struct vnic_dev
*vdev
);
140 int vnic_dev_link_status(struct vnic_dev
*vdev
);
141 u32
vnic_dev_port_speed(struct vnic_dev
*vdev
);
142 u32
vnic_dev_msg_lvl(struct vnic_dev
*vdev
);
143 u32
vnic_dev_mtu(struct vnic_dev
*vdev
);
144 u32
vnic_dev_link_down_cnt(struct vnic_dev
*vdev
);
145 int vnic_dev_close(struct vnic_dev
*vdev
);
146 int vnic_dev_enable(struct vnic_dev
*vdev
);
147 int vnic_dev_disable(struct vnic_dev
*vdev
);
148 int vnic_dev_open(struct vnic_dev
*vdev
, int arg
);
149 int vnic_dev_open_done(struct vnic_dev
*vdev
, int *done
);
150 int vnic_dev_init(struct vnic_dev
*vdev
, int arg
);
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 void vnic_dev_set_intr_mode(struct vnic_dev
*vdev
,
154 enum vnic_dev_intr_mode intr_mode
);
155 enum vnic_dev_intr_mode
vnic_dev_get_intr_mode(struct vnic_dev
*vdev
);
156 void vnic_dev_unregister(struct vnic_dev
*vdev
);
157 struct vnic_dev
*vnic_dev_register(struct vnic_dev
*vdev
,
158 void *priv
, struct pci_dev
*pdev
,
159 struct vnic_dev_bar
*bar
);
161 #endif /* _VNIC_DEV_H_ */