• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * QLogic qlcnic NIC Driver
3  * Copyright (c) 2009-2013 QLogic Corporation
4  *
5  * See LICENSE.qlcnic for copyright and licensing details.
6  */
7 
8 #ifndef _QLCNIC_83XX_SRIOV_H_
9 #define _QLCNIC_83XX_SRIOV_H_
10 
11 #include "qlcnic.h"
12 #include <linux/types.h>
13 #include <linux/pci.h>
14 
15 extern const u32 qlcnic_83xx_reg_tbl[];
16 extern const u32 qlcnic_83xx_ext_reg_tbl[];
17 
18 struct qlcnic_bc_payload {
19 	u64 payload[126];
20 };
21 
22 struct qlcnic_bc_hdr {
23 #if defined(__LITTLE_ENDIAN)
24 	u8	version;
25 	u8	msg_type:4;
26 	u8	rsvd1:3;
27 	u8	op_type:1;
28 	u8	num_cmds;
29 	u8	num_frags;
30 	u8	frag_num;
31 	u8	cmd_op;
32 	u16	seq_id;
33 	u64	rsvd3;
34 #elif defined(__BIG_ENDIAN)
35 	u8	num_frags;
36 	u8	num_cmds;
37 	u8	op_type:1;
38 	u8	rsvd1:3;
39 	u8	msg_type:4;
40 	u8	version;
41 	u16	seq_id;
42 	u8	cmd_op;
43 	u8	frag_num;
44 	u64	rsvd3;
45 #endif
46 };
47 
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,
53 };
54 
55 #define QLC_BC_CMD 1
56 
57 struct qlcnic_trans_list {
58 	/* Lock for manipulating list */
59 	spinlock_t		lock;
60 	struct list_head	wait_list;
61 	int			count;
62 };
63 
64 enum qlcnic_trans_state {
65 	QLC_INIT = 0,
66 	QLC_WAIT_FOR_CHANNEL_FREE,
67 	QLC_WAIT_FOR_RESP,
68 	QLC_ABORT,
69 	QLC_END,
70 };
71 
72 struct qlcnic_bc_trans {
73 	u8				func_id;
74 	u8				active;
75 	u8				curr_rsp_frag;
76 	u8				curr_req_frag;
77 	u16				cmd_id;
78 	u16				req_pay_size;
79 	u16				rsp_pay_size;
80 	u32				trans_id;
81 	enum qlcnic_trans_state		trans_state;
82 	struct list_head		list;
83 	struct qlcnic_bc_hdr		*req_hdr;
84 	struct qlcnic_bc_hdr		*rsp_hdr;
85 	struct qlcnic_bc_payload	*req_pay;
86 	struct qlcnic_bc_payload	*rsp_pay;
87 	struct completion		resp_cmpl;
88 	struct qlcnic_vf_info		*vf;
89 };
90 
91 enum qlcnic_vf_state {
92 	QLC_BC_VF_SEND = 0,
93 	QLC_BC_VF_RECV,
94 	QLC_BC_VF_CHANNEL,
95 	QLC_BC_VF_STATE,
96 	QLC_BC_VF_FLR,
97 	QLC_BC_VF_SOFT_FLR,
98 };
99 
100 enum qlcnic_vlan_mode {
101 	QLC_NO_VLAN_MODE = 0,
102 	QLC_PVID_MODE,
103 	QLC_GUEST_VLAN_MODE,
104 };
105 
106 struct qlcnic_resources {
107 	u16 num_tx_mac_filters;
108 	u16 num_rx_ucast_mac_filters;
109 	u16 num_rx_mcast_mac_filters;
110 
111 	u16 num_txvlan_keys;
112 
113 	u16 num_rx_queues;
114 	u16 num_tx_queues;
115 
116 	u16 num_rx_buf_rings;
117 	u16 num_rx_status_rings;
118 
119 	u16 num_destip;
120 	u32 num_lro_flows_supported;
121 	u16 max_local_ipv6_addrs;
122 	u16 max_remote_ipv6_addrs;
123 };
124 
125 struct qlcnic_vport {
126 	u16			handle;
127 	u16			max_tx_bw;
128 	u16			min_tx_bw;
129 	u8			vlan_mode;
130 	u16			vlan;
131 	u8			qos;
132 	u8			mac[6];
133 };
134 
135 struct qlcnic_vf_info {
136 	u8				pci_func;
137 	u16				rx_ctx_id;
138 	u16				tx_ctx_id;
139 	unsigned long			state;
140 	struct completion		ch_free_cmpl;
141 	struct work_struct		trans_work;
142 	struct work_struct		flr_work;
143 	/* It synchronizes commands sent from VF */
144 	struct mutex			send_cmd_lock;
145 	struct qlcnic_bc_trans		*send_cmd;
146 	struct qlcnic_bc_trans		*flr_trans;
147 	struct qlcnic_trans_list	rcv_act;
148 	struct qlcnic_trans_list	rcv_pend;
149 	struct qlcnic_adapter		*adapter;
150 	struct qlcnic_vport		*vp;
151 };
152 
153 struct qlcnic_async_work_list {
154 	struct list_head	list;
155 	struct work_struct	work;
156 	void			*ptr;
157 };
158 
159 struct qlcnic_back_channel {
160 	u16			trans_counter;
161 	struct workqueue_struct *bc_trans_wq;
162 	struct workqueue_struct *bc_async_wq;
163 	struct workqueue_struct *bc_flr_wq;
164 	struct list_head	async_list;
165 };
166 
167 struct qlcnic_sriov {
168 	u16				vp_handle;
169 	u8				num_vfs;
170 	u8				any_vlan;
171 	u8				vlan_mode;
172 	u16				num_allowed_vlans;
173 	u16				*allowed_vlans;
174 	u16				vlan;
175 	struct qlcnic_resources		ff_max;
176 	struct qlcnic_back_channel	bc;
177 	struct qlcnic_vf_info		*vf_info;
178 };
179 
180 int qlcnic_sriov_init(struct qlcnic_adapter *, int);
181 void qlcnic_sriov_cleanup(struct qlcnic_adapter *);
182 void __qlcnic_sriov_cleanup(struct qlcnic_adapter *);
183 void qlcnic_sriov_vf_register_map(struct qlcnic_hardware_context *);
184 int qlcnic_sriov_vf_init(struct qlcnic_adapter *, int);
185 void qlcnic_sriov_vf_set_ops(struct qlcnic_adapter *);
186 int qlcnic_sriov_func_to_index(struct qlcnic_adapter *, u8);
187 int qlcnic_sriov_channel_cfg_cmd(struct qlcnic_adapter *, u8);
188 void qlcnic_sriov_handle_bc_event(struct qlcnic_adapter *, u32);
189 int qlcnic_sriov_cfg_bc_intr(struct qlcnic_adapter *, u8);
190 void qlcnic_sriov_cleanup_async_list(struct qlcnic_back_channel *);
191 void qlcnic_sriov_cleanup_list(struct qlcnic_trans_list *);
192 int __qlcnic_sriov_add_act_list(struct qlcnic_sriov *, struct qlcnic_vf_info *,
193 				struct qlcnic_bc_trans *);
194 int qlcnic_sriov_get_vf_vport_info(struct qlcnic_adapter *,
195 				   struct qlcnic_info *, u16);
196 int qlcnic_sriov_cfg_vf_guest_vlan(struct qlcnic_adapter *, u16, u8);
197 
qlcnic_sriov_enable_check(struct qlcnic_adapter * adapter)198 static inline bool qlcnic_sriov_enable_check(struct qlcnic_adapter *adapter)
199 {
200 	return test_bit(__QLCNIC_SRIOV_ENABLE, &adapter->state) ? true : false;
201 }
202 
203 #ifdef CONFIG_QLCNIC_SRIOV
204 void qlcnic_sriov_pf_process_bc_cmd(struct qlcnic_adapter *,
205 				    struct qlcnic_bc_trans *,
206 				    struct qlcnic_cmd_args *);
207 void qlcnic_sriov_pf_disable(struct qlcnic_adapter *);
208 void qlcnic_sriov_pf_cleanup(struct qlcnic_adapter *);
209 int qlcnic_pci_sriov_configure(struct pci_dev *, int);
210 void qlcnic_pf_set_interface_id_create_rx_ctx(struct qlcnic_adapter *, u32 *);
211 void qlcnic_pf_set_interface_id_create_tx_ctx(struct qlcnic_adapter *, u32 *);
212 void qlcnic_pf_set_interface_id_del_rx_ctx(struct qlcnic_adapter *, u32 *);
213 void qlcnic_pf_set_interface_id_del_tx_ctx(struct qlcnic_adapter *, u32 *);
214 void qlcnic_pf_set_interface_id_promisc(struct qlcnic_adapter *, u32 *);
215 void qlcnic_pf_set_interface_id_ipaddr(struct qlcnic_adapter *, u32 *);
216 void qlcnic_pf_set_interface_id_macaddr(struct qlcnic_adapter *, u32 *);
217 void qlcnic_sriov_pf_handle_flr(struct qlcnic_sriov *, struct qlcnic_vf_info *);
218 bool qlcnic_sriov_soft_flr_check(struct qlcnic_adapter *,
219 				 struct qlcnic_bc_trans *,
220 				 struct qlcnic_vf_info *);
221 void qlcnic_sriov_pf_reset(struct qlcnic_adapter *);
222 int qlcnic_sriov_pf_reinit(struct qlcnic_adapter *);
223 int qlcnic_sriov_set_vf_mac(struct net_device *, int, u8 *);
224 int qlcnic_sriov_set_vf_tx_rate(struct net_device *, int, int);
225 int qlcnic_sriov_get_vf_config(struct net_device *, int ,
226 			       struct ifla_vf_info *);
227 int qlcnic_sriov_set_vf_vlan(struct net_device *, int, u16, u8);
228 #else
qlcnic_sriov_pf_disable(struct qlcnic_adapter * adapter)229 static inline void qlcnic_sriov_pf_disable(struct qlcnic_adapter *adapter) {}
qlcnic_sriov_pf_cleanup(struct qlcnic_adapter * adapter)230 static inline void qlcnic_sriov_pf_cleanup(struct qlcnic_adapter *adapter) {}
231 static inline void
qlcnic_pf_set_interface_id_create_rx_ctx(struct qlcnic_adapter * adapter,u32 * int_id)232 qlcnic_pf_set_interface_id_create_rx_ctx(struct qlcnic_adapter *adapter,
233 					 u32 *int_id) {}
234 static inline void
qlcnic_pf_set_interface_id_create_tx_ctx(struct qlcnic_adapter * adapter,u32 * int_id)235 qlcnic_pf_set_interface_id_create_tx_ctx(struct qlcnic_adapter *adapter,
236 					 u32 *int_id) {}
237 static inline void
qlcnic_pf_set_interface_id_del_rx_ctx(struct qlcnic_adapter * adapter,u32 * int_id)238 qlcnic_pf_set_interface_id_del_rx_ctx(struct qlcnic_adapter *adapter,
239 				      u32 *int_id) {}
240 static inline void
qlcnic_pf_set_interface_id_del_tx_ctx(struct qlcnic_adapter * adapter,u32 * int_id)241 qlcnic_pf_set_interface_id_del_tx_ctx(struct qlcnic_adapter *adapter,
242 				      u32 *int_id) {}
243 static inline void
qlcnic_pf_set_interface_id_ipaddr(struct qlcnic_adapter * adapter,u32 * int_id)244 qlcnic_pf_set_interface_id_ipaddr(struct qlcnic_adapter *adapter, u32 *int_id)
245 {}
246 static inline void
qlcnic_pf_set_interface_id_macaddr(struct qlcnic_adapter * adapter,u32 * int_id)247 qlcnic_pf_set_interface_id_macaddr(struct qlcnic_adapter *adapter, u32 *int_id)
248 {}
249 static inline void
qlcnic_pf_set_interface_id_promisc(struct qlcnic_adapter * adapter,u32 * int_id)250 qlcnic_pf_set_interface_id_promisc(struct qlcnic_adapter *adapter, u32 *int_id)
251 {}
qlcnic_sriov_pf_handle_flr(struct qlcnic_sriov * sriov,struct qlcnic_vf_info * vf)252 static inline void qlcnic_sriov_pf_handle_flr(struct qlcnic_sriov *sriov,
253 					      struct qlcnic_vf_info *vf) {}
qlcnic_sriov_soft_flr_check(struct qlcnic_adapter * adapter,struct qlcnic_bc_trans * trans,struct qlcnic_vf_info * vf)254 static inline bool qlcnic_sriov_soft_flr_check(struct qlcnic_adapter *adapter,
255 					       struct qlcnic_bc_trans *trans,
256 					       struct qlcnic_vf_info *vf)
257 { return false; }
qlcnic_sriov_pf_reset(struct qlcnic_adapter * adapter)258 static inline void qlcnic_sriov_pf_reset(struct qlcnic_adapter *adapter) {}
qlcnic_sriov_pf_reinit(struct qlcnic_adapter * adapter)259 static inline int qlcnic_sriov_pf_reinit(struct qlcnic_adapter *adapter)
260 { return 0; }
261 #endif
262 
263 #endif
264