1 /* bnx2x_vfpf.h: Broadcom Everest network driver.
3 * Copyright (c) 2011-2013 Broadcom Corporation
5 * Unless you and Broadcom execute a separate written software license
6 * agreement governing use of this software, this software is licensed to you
7 * under the terms of the GNU General Public License version 2, available
8 * at http://www.gnu.org/licenses/old-licenses/gpl-2.0.html (the "GPL").
10 * Notwithstanding the above, under no circumstances may you combine this
11 * software in any way with any other Broadcom software provided under a
12 * license other than the GPL, without Broadcom's express prior written
15 * Maintained by: Eilon Greenstein <eilong@broadcom.com>
16 * Written by: Ariel Elior <ariele@broadcom.com>
21 #ifdef CONFIG_BNX2X_SRIOV
23 /* Common definitions for all HVs */
24 struct vf_pf_resc_request {
30 u8 num_mc_filters; /* No limit so superfluous */
34 u8 hw_sb_id; /* aka absolute igu id, used to ack the sb */
35 u8 sb_qid; /* used to update DHC for sb */
38 /* HW VF-PF channel definitions
41 #define TLV_BUFFER_SIZE 1024
42 #define PF_VF_BULLETIN_SIZE 512
44 #define VFPF_QUEUE_FLG_TPA 0x0001
45 #define VFPF_QUEUE_FLG_TPA_IPV6 0x0002
46 #define VFPF_QUEUE_FLG_TPA_GRO 0x0004
47 #define VFPF_QUEUE_FLG_CACHE_ALIGN 0x0008
48 #define VFPF_QUEUE_FLG_STATS 0x0010
49 #define VFPF_QUEUE_FLG_OV 0x0020
50 #define VFPF_QUEUE_FLG_VLAN 0x0040
51 #define VFPF_QUEUE_FLG_COS 0x0080
52 #define VFPF_QUEUE_FLG_HC 0x0100
53 #define VFPF_QUEUE_FLG_DHC 0x0200
55 #define VFPF_QUEUE_DROP_IP_CS_ERR (1 << 0)
56 #define VFPF_QUEUE_DROP_TCP_CS_ERR (1 << 1)
57 #define VFPF_QUEUE_DROP_TTL0 (1 << 2)
58 #define VFPF_QUEUE_DROP_UDP_CS_ERR (1 << 3)
60 #define VFPF_RX_MASK_ACCEPT_NONE 0x00000000
61 #define VFPF_RX_MASK_ACCEPT_MATCHED_UNICAST 0x00000001
62 #define VFPF_RX_MASK_ACCEPT_MATCHED_MULTICAST 0x00000002
63 #define VFPF_RX_MASK_ACCEPT_ALL_UNICAST 0x00000004
64 #define VFPF_RX_MASK_ACCEPT_ALL_MULTICAST 0x00000008
65 #define VFPF_RX_MASK_ACCEPT_BROADCAST 0x00000010
66 #define BULLETIN_CONTENT_SIZE (sizeof(struct pf_vf_bulletin_content))
67 #define BULLETIN_ATTEMPTS 5 /* crc failures before throwing towel */
68 #define BULLETIN_CRC_SEED 0
71 PFVF_STATUS_WAITING = 0,
74 PFVF_STATUS_NOT_SUPPORTED,
75 PFVF_STATUS_NO_RESOURCE
78 /* vf pf channel tlvs */
79 /* general tlv header (used for both vf->pf request and pf->vf response) */
85 /* header of first vf->pf tlv carries the offset used to calculate response
88 struct vfpf_first_tlv {
89 struct channel_tlv tl;
93 /* header of pf->vf tlvs, carries the status of handling the request */
95 struct channel_tlv tl;
100 /* response tlv used for most tlvs */
101 struct pfvf_general_resp_tlv {
105 /* used to terminate and pad a tlv list */
106 struct channel_list_end_tlv {
107 struct channel_tlv tl;
112 struct vfpf_acquire_tlv {
113 struct vfpf_first_tlv first_tlv;
115 struct vf_pf_vfdev_info {
116 /* the following fields are for debug purposes */
117 u8 vf_id; /* ME register value */
118 u8 vf_os; /* e.g. Linux, W2K8 */
122 struct vf_pf_resc_request resc_request;
124 aligned_u64 bulletin_addr;
127 /* simple operation request on queue */
128 struct vfpf_q_op_tlv {
129 struct vfpf_first_tlv first_tlv;
134 /* acquire response tlv - carries the allocated resources */
135 struct pfvf_acquire_resp_tlv {
137 struct pf_vf_pfdev_info {
140 #define PFVF_CAP_RSS 0x00000001
141 #define PFVF_CAP_DHC 0x00000002
142 #define PFVF_CAP_TPA 0x00000004
149 /* in case of status NO_RESOURCE in message hdr, pf will fill
150 * this struct with suggested amount of resources for next
153 #define PFVF_MAX_QUEUES_PER_VF 16
154 #define PFVF_MAX_SBS_PER_VF 16
155 struct hw_sb_info hw_sbs[PFVF_MAX_SBS_PER_VF];
156 u8 hw_qid[PFVF_MAX_QUEUES_PER_VF];
163 u8 permanent_mac_addr[ETH_ALEN];
164 u8 current_mac_addr[ETH_ALEN];
170 struct vfpf_init_tlv {
171 struct vfpf_first_tlv first_tlv;
172 aligned_u64 sb_addr[PFVF_MAX_SBS_PER_VF]; /* vf_sb based */
173 aligned_u64 spq_addr;
174 aligned_u64 stats_addr;
178 struct vfpf_setup_q_tlv {
179 struct vfpf_first_tlv first_tlv;
181 struct vf_pf_rxq_params {
182 /* physical addresses */
183 aligned_u64 rcq_addr;
184 aligned_u64 rcq_np_addr;
185 aligned_u64 rxq_addr;
186 aligned_u64 sge_addr;
189 u8 vf_sb; /* index in hw_sbs[] */
190 u8 sb_index; /* Index in the SB */
191 u16 hc_rate; /* desired interrupts per sec. */
192 /* valid iff VFPF_QUEUE_FLG_HC */
196 u16 flags; /* VFPF_QUEUE_FLG_X flags */
197 u16 stat_id; /* valid iff VFPF_QUEUE_FLG_STATS */
199 /* valid iff VFPF_QUEUE_FLG_TPA */
204 u8 drop_flags; /* VFPF_QUEUE_DROP_X, for Linux VMs
205 * all the flags are turned off
208 u8 cache_line_log; /* VFPF_QUEUE_FLG_CACHE_ALIGN */
212 struct vf_pf_txq_params {
213 /* physical addresses */
214 aligned_u64 txq_addr;
217 u8 vf_sb; /* index in hw_sbs[] */
218 u8 sb_index; /* Index in the SB */
219 u16 hc_rate; /* desired interrupts per sec. */
220 /* valid iff VFPF_QUEUE_FLG_HC */
221 u32 flags; /* VFPF_QUEUE_FLG_X flags */
222 u16 stat_id; /* valid iff VFPF_QUEUE_FLG_STATS */
223 u8 traffic_type; /* see in setup_context() */
227 u8 vf_qid; /* index in hw_qid[] */
229 #define VFPF_RXQ_VALID 0x01
230 #define VFPF_TXQ_VALID 0x02
234 /* Set Queue Filters */
235 struct vfpf_q_mac_vlan_filter {
237 #define VFPF_Q_FILTER_DEST_MAC_VALID 0x01
238 #define VFPF_Q_FILTER_VLAN_TAG_VALID 0x02
239 #define VFPF_Q_FILTER_SET_MAC 0x100 /* set/clear */
244 /* configure queue filters */
245 struct vfpf_set_q_filters_tlv {
246 struct vfpf_first_tlv first_tlv;
249 #define VFPF_SET_Q_FILTERS_MAC_VLAN_CHANGED 0x01
250 #define VFPF_SET_Q_FILTERS_MULTICAST_CHANGED 0x02
251 #define VFPF_SET_Q_FILTERS_RX_MASK_CHANGED 0x04
253 u8 vf_qid; /* index in hw_qid[] */
254 u8 n_mac_vlan_filters;
258 #define PFVF_MAX_MAC_FILTERS 16
259 #define PFVF_MAX_VLAN_FILTERS 16
260 #define PFVF_MAX_FILTERS (PFVF_MAX_MAC_FILTERS +\
261 PFVF_MAX_VLAN_FILTERS)
262 struct vfpf_q_mac_vlan_filter filters[PFVF_MAX_FILTERS];
264 #define PFVF_MAX_MULTICAST_PER_VF 32
265 u8 multicast[PFVF_MAX_MULTICAST_PER_VF][ETH_ALEN];
267 u32 rx_mask; /* see mask constants at the top of the file */
270 /* close VF (disable VF) */
271 struct vfpf_close_tlv {
272 struct vfpf_first_tlv first_tlv;
273 u16 vf_id; /* for debug */
277 /* release the VF's acquired resources */
278 struct vfpf_release_tlv {
279 struct vfpf_first_tlv first_tlv;
284 struct tlv_buffer_size {
285 u8 tlv_buffer[TLV_BUFFER_SIZE];
289 struct vfpf_first_tlv first_tlv;
290 struct vfpf_acquire_tlv acquire;
291 struct vfpf_init_tlv init;
292 struct vfpf_close_tlv close;
293 struct vfpf_q_op_tlv q_op;
294 struct vfpf_setup_q_tlv setup_q;
295 struct vfpf_set_q_filters_tlv set_q_filters;
296 struct vfpf_release_tlv release;
297 struct channel_list_end_tlv list_end;
298 struct tlv_buffer_size tlv_buf_size;
302 struct pfvf_general_resp_tlv general_resp;
303 struct pfvf_acquire_resp_tlv acquire_resp;
304 struct channel_list_end_tlv list_end;
305 struct tlv_buffer_size tlv_buf_size;
308 /* This is a structure which is allocated in the VF, which the PF may update
309 * when it deems it necessary to do so. The bulletin board is sampled
310 * periodically by the VF. A copy per VF is maintained in the PF (to prevent
311 * loss of data upon multiple updates (or the need for read modify write)).
313 struct pf_vf_bulletin_size {
314 u8 size[PF_VF_BULLETIN_SIZE];
317 struct pf_vf_bulletin_content {
318 u32 crc; /* crc of structure to ensure is not in
324 aligned_u64 valid_bitmap; /* bitmap indicating which fields
328 #define MAC_ADDR_VALID 0 /* alert the vf that a new mac address
329 * is available for it
331 #define VLAN_VALID 1 /* when set, the vf should not access
334 #define CHANNEL_DOWN 2 /* vfpf channel is disabled. VFs are not
335 * to attempt to send messages on the
336 * channel after this bit is set
345 union pf_vf_bulletin {
346 struct pf_vf_bulletin_content content;
347 struct pf_vf_bulletin_size size;
350 #define MAX_TLVS_IN_LIST 50
357 CHANNEL_TLV_SET_Q_FILTERS,
358 CHANNEL_TLV_TEARDOWN_Q,
361 CHANNEL_TLV_PF_RELEASE_VF,
362 CHANNEL_TLV_LIST_END,
364 CHANNEL_TLV_PF_SET_MAC,
365 CHANNEL_TLV_PF_SET_VLAN,
369 #endif /* CONFIG_BNX2X_SRIOV */
370 #endif /* VF_PF_IF_H */