2 * QLogic qlcnic NIC Driver
3 * Copyright (c) 2009-2013 QLogic Corporation
5 * See LICENSE.qlcnic for copyright and licensing details.
8 #ifndef _QLCNIC_83XX_SRIOV_H_
9 #define _QLCNIC_83XX_SRIOV_H_
12 #include <linux/types.h>
13 #include <linux/pci.h>
15 extern const u32 qlcnic_83xx_reg_tbl
[];
16 extern const u32 qlcnic_83xx_ext_reg_tbl
[];
18 struct qlcnic_bc_payload
{
22 struct qlcnic_bc_hdr
{
23 #if defined(__LITTLE_ENDIAN)
34 #elif defined(__BIG_ENDIAN)
48 enum qlcnic_bc_commands
{
49 QLCNIC_BC_CMD_CHANNEL_INIT
= 0x0,
50 QLCNIC_BC_CMD_CHANNEL_TERM
= 0x1,
51 QLCNIC_BC_CMD_GET_ACL
= 0x2,
52 QLCNIC_BC_CMD_CFG_GUEST_VLAN
= 0x3,
55 #define QLCNIC_83XX_SRIOV_VF_MAX_MAC 2
58 struct qlcnic_trans_list
{
59 /* Lock for manipulating list */
61 struct list_head wait_list
;
65 enum qlcnic_trans_state
{
67 QLC_WAIT_FOR_CHANNEL_FREE
,
73 struct qlcnic_bc_trans
{
82 enum qlcnic_trans_state trans_state
;
83 struct list_head list
;
84 struct qlcnic_bc_hdr
*req_hdr
;
85 struct qlcnic_bc_hdr
*rsp_hdr
;
86 struct qlcnic_bc_payload
*req_pay
;
87 struct qlcnic_bc_payload
*rsp_pay
;
88 struct completion resp_cmpl
;
89 struct qlcnic_vf_info
*vf
;
92 enum qlcnic_vf_state
{
101 enum qlcnic_vlan_mode
{
102 QLC_NO_VLAN_MODE
= 0,
107 struct qlcnic_resources
{
108 u16 num_tx_mac_filters
;
109 u16 num_rx_ucast_mac_filters
;
110 u16 num_rx_mcast_mac_filters
;
117 u16 num_rx_buf_rings
;
118 u16 num_rx_status_rings
;
121 u32 num_lro_flows_supported
;
122 u16 max_local_ipv6_addrs
;
123 u16 max_remote_ipv6_addrs
;
126 struct qlcnic_vport
{
137 struct qlcnic_vf_info
{
144 struct completion ch_free_cmpl
;
145 struct work_struct trans_work
;
146 struct work_struct flr_work
;
147 /* It synchronizes commands sent from VF */
148 struct mutex send_cmd_lock
;
149 struct qlcnic_bc_trans
*send_cmd
;
150 struct qlcnic_bc_trans
*flr_trans
;
151 struct qlcnic_trans_list rcv_act
;
152 struct qlcnic_trans_list rcv_pend
;
153 struct qlcnic_adapter
*adapter
;
154 struct qlcnic_vport
*vp
;
155 spinlock_t vlan_list_lock
; /* Lock for VLAN list */
158 struct qlcnic_async_work_list
{
159 struct list_head list
;
160 struct work_struct work
;
162 struct qlcnic_cmd_args
*cmd
;
165 struct qlcnic_back_channel
{
167 struct workqueue_struct
*bc_trans_wq
;
168 struct workqueue_struct
*bc_async_wq
;
169 struct workqueue_struct
*bc_flr_wq
;
170 struct list_head async_list
;
173 struct qlcnic_sriov
{
178 u16 num_allowed_vlans
;
181 struct qlcnic_resources ff_max
;
182 struct qlcnic_back_channel bc
;
183 struct qlcnic_vf_info
*vf_info
;
186 int qlcnic_sriov_init(struct qlcnic_adapter
*, int);
187 void qlcnic_sriov_cleanup(struct qlcnic_adapter
*);
188 void __qlcnic_sriov_cleanup(struct qlcnic_adapter
*);
189 void qlcnic_sriov_vf_register_map(struct qlcnic_hardware_context
*);
190 int qlcnic_sriov_vf_init(struct qlcnic_adapter
*, int);
191 void qlcnic_sriov_vf_set_ops(struct qlcnic_adapter
*);
192 int qlcnic_sriov_func_to_index(struct qlcnic_adapter
*, u8
);
193 void qlcnic_sriov_handle_bc_event(struct qlcnic_adapter
*, u32
);
194 int qlcnic_sriov_cfg_bc_intr(struct qlcnic_adapter
*, u8
);
195 void qlcnic_sriov_cleanup_async_list(struct qlcnic_back_channel
*);
196 void qlcnic_sriov_cleanup_list(struct qlcnic_trans_list
*);
197 int __qlcnic_sriov_add_act_list(struct qlcnic_sriov
*, struct qlcnic_vf_info
*,
198 struct qlcnic_bc_trans
*);
199 int qlcnic_sriov_get_vf_vport_info(struct qlcnic_adapter
*,
200 struct qlcnic_info
*, u16
);
201 int qlcnic_sriov_cfg_vf_guest_vlan(struct qlcnic_adapter
*, u16
, u8
);
202 void qlcnic_sriov_free_vlans(struct qlcnic_adapter
*);
203 void qlcnic_sriov_alloc_vlans(struct qlcnic_adapter
*);
204 bool qlcnic_sriov_check_any_vlan(struct qlcnic_vf_info
*);
205 void qlcnic_sriov_del_vlan_id(struct qlcnic_sriov
*,
206 struct qlcnic_vf_info
*, u16
);
207 void qlcnic_sriov_add_vlan_id(struct qlcnic_sriov
*,
208 struct qlcnic_vf_info
*, u16
);
210 static inline bool qlcnic_sriov_enable_check(struct qlcnic_adapter
*adapter
)
212 return test_bit(__QLCNIC_SRIOV_ENABLE
, &adapter
->state
) ? true : false;
215 #ifdef CONFIG_QLCNIC_SRIOV
216 void qlcnic_sriov_pf_process_bc_cmd(struct qlcnic_adapter
*,
217 struct qlcnic_bc_trans
*,
218 struct qlcnic_cmd_args
*);
219 void qlcnic_sriov_pf_disable(struct qlcnic_adapter
*);
220 void qlcnic_sriov_pf_cleanup(struct qlcnic_adapter
*);
221 int qlcnic_pci_sriov_configure(struct pci_dev
*, int);
222 void qlcnic_pf_set_interface_id_create_rx_ctx(struct qlcnic_adapter
*, u32
*);
223 void qlcnic_pf_set_interface_id_create_tx_ctx(struct qlcnic_adapter
*, u32
*);
224 void qlcnic_pf_set_interface_id_del_rx_ctx(struct qlcnic_adapter
*, u32
*);
225 void qlcnic_pf_set_interface_id_del_tx_ctx(struct qlcnic_adapter
*, u32
*);
226 void qlcnic_pf_set_interface_id_promisc(struct qlcnic_adapter
*, u32
*);
227 void qlcnic_pf_set_interface_id_ipaddr(struct qlcnic_adapter
*, u32
*);
228 void qlcnic_pf_set_interface_id_macaddr(struct qlcnic_adapter
*, u32
*);
229 void qlcnic_sriov_pf_handle_flr(struct qlcnic_sriov
*, struct qlcnic_vf_info
*);
230 bool qlcnic_sriov_soft_flr_check(struct qlcnic_adapter
*,
231 struct qlcnic_bc_trans
*,
232 struct qlcnic_vf_info
*);
233 void qlcnic_sriov_pf_reset(struct qlcnic_adapter
*);
234 int qlcnic_sriov_pf_reinit(struct qlcnic_adapter
*);
235 int qlcnic_sriov_set_vf_mac(struct net_device
*, int, u8
*);
236 int qlcnic_sriov_set_vf_tx_rate(struct net_device
*, int, int, int);
237 int qlcnic_sriov_get_vf_config(struct net_device
*, int ,
238 struct ifla_vf_info
*);
239 int qlcnic_sriov_set_vf_vlan(struct net_device
*, int, u16
, u8
);
240 int qlcnic_sriov_set_vf_spoofchk(struct net_device
*, int, bool);
242 static inline void qlcnic_sriov_pf_disable(struct qlcnic_adapter
*adapter
) {}
243 static inline void qlcnic_sriov_pf_cleanup(struct qlcnic_adapter
*adapter
) {}
245 qlcnic_pf_set_interface_id_create_rx_ctx(struct qlcnic_adapter
*adapter
,
248 qlcnic_pf_set_interface_id_create_tx_ctx(struct qlcnic_adapter
*adapter
,
251 qlcnic_pf_set_interface_id_del_rx_ctx(struct qlcnic_adapter
*adapter
,
254 qlcnic_pf_set_interface_id_del_tx_ctx(struct qlcnic_adapter
*adapter
,
257 qlcnic_pf_set_interface_id_ipaddr(struct qlcnic_adapter
*adapter
, u32
*int_id
)
260 qlcnic_pf_set_interface_id_macaddr(struct qlcnic_adapter
*adapter
, u32
*int_id
)
263 qlcnic_pf_set_interface_id_promisc(struct qlcnic_adapter
*adapter
, u32
*int_id
)
265 static inline void qlcnic_sriov_pf_handle_flr(struct qlcnic_sriov
*sriov
,
266 struct qlcnic_vf_info
*vf
) {}
267 static inline bool qlcnic_sriov_soft_flr_check(struct qlcnic_adapter
*adapter
,
268 struct qlcnic_bc_trans
*trans
,
269 struct qlcnic_vf_info
*vf
)
271 static inline void qlcnic_sriov_pf_reset(struct qlcnic_adapter
*adapter
) {}
272 static inline int qlcnic_sriov_pf_reinit(struct qlcnic_adapter
*adapter
)