1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (c) 2016 - 2018 Cavium Inc.
7 #ifndef __ECORE_SRIOV_H__
8 #define __ECORE_SRIOV_H__
10 #include "ecore_status.h"
11 #include "ecore_vfpf_if.h"
12 #include "ecore_iov_api.h"
13 #include "ecore_hsi_common.h"
16 #define ECORE_ETH_MAX_VF_NUM_VLAN_FILTERS \
17 (MAX_NUM_VFS_E4 * ECORE_ETH_VF_NUM_VLAN_FILTERS)
19 /* Represents a full message. Both the request filled by VF
20 * and the response filled by the PF. The VF needs one copy
21 * of this message, it fills the request part and sends it to
22 * the PF. The PF will copy the response to the response part for
23 * the VF to later read it. The PF needs to hold a message like this
24 * per VF, the request that is copied to the PF is placed in the
25 * request size, and the response is filled by the PF before sending
28 struct ecore_vf_mbx_msg
{
33 /* This mailbox is maintained per VF in its PF
34 * contains all information required for sending / receiving
37 struct ecore_iov_vf_mbx
{
38 union vfpf_tlvs
*req_virt
;
40 union pfvf_tlvs
*reply_virt
;
41 dma_addr_t reply_phys
;
43 /* Address in VF where a pending message is located */
44 dma_addr_t pending_req
;
46 /* Message from VF awaits handling */
51 #ifdef CONFIG_ECORE_SW_CHANNEL
52 struct ecore_iov_sw_mbx sw_mbx
;
59 struct vfpf_first_tlv first_tlv
; /* saved VF request header */
62 #define VF_MSG_INPROCESS 0x1 /* failsafe - the FW should prevent
63 * more then one pending msg
67 #define ECORE_IOV_LEGACY_QID_RX (0)
68 #define ECORE_IOV_LEGACY_QID_TX (1)
69 #define ECORE_IOV_QID_INVALID (0xFE)
71 struct ecore_vf_queue_cid
{
73 struct ecore_queue_cid
*p_cid
;
76 /* Describes a qzone associated with the VF */
77 struct ecore_vf_queue
{
78 /* Input from upper-layer, mapping relateive queue to queue-zone */
82 struct ecore_vf_queue_cid cids
[MAX_QUEUES_PER_QZONE
];
86 VF_FREE
= 0, /* VF ready to be acquired holds no resc */
87 VF_ACQUIRED
= 1, /* VF, acquired, but not initalized */
88 VF_ENABLED
= 2, /* VF, Enabled */
89 VF_RESET
= 3, /* VF, FLR'd, pending cleanup */
90 VF_STOPPED
= 4 /* VF, Stopped */
93 struct ecore_vf_vlan_shadow
{
98 struct ecore_vf_shadow_config
{
99 /* Shadow copy of all guest vlans */
100 struct ecore_vf_vlan_shadow vlans
[ECORE_ETH_VF_NUM_VLAN_FILTERS
+ 1];
102 /* Shadow copy of all configured MACs; Empty if forcing MACs */
103 u8 macs
[ECORE_ETH_VF_NUM_MAC_FILTERS
][ETH_ALEN
];
104 u8 inner_vlan_removal
;
107 /* PFs maintain an array of this structure, per VF */
108 struct ecore_vf_info
{
109 struct ecore_iov_vf_mbx vf_mbx
;
115 struct ecore_bulletin bulletin
;
116 dma_addr_t vf_bulletin
;
118 #ifdef CONFIG_ECORE_SW_CHANNEL
119 /* Determine whether PF communicate with VF using HW/SW channel */
123 /* PF saves a copy of the last VF acquire message */
124 struct vfpf_acquire_tlv acquire
;
134 #define ECORE_VF_ABS_ID(p_hwfn, p_vf) (ECORE_PATH_ID(p_hwfn) ? \
135 (p_vf)->abs_vf_id + MAX_NUM_VFS_BB : \
138 u8 vport_instance
; /* Number of active vports */
150 struct ecore_vf_queue vf_queues
[ECORE_MAX_VF_CHAINS_PER_PF
];
151 u16 igu_sbs
[ECORE_MAX_VF_CHAINS_PER_PF
];
153 /* TODO - Only windows is using it - should be removed */
157 struct ecore_public_vf_info p_vf_info
;
158 bool spoof_chk
; /* Current configured on HW */
159 bool req_spoofchk_val
; /* Requested value */
161 /* Stores the configuration requested by VF */
162 struct ecore_vf_shadow_config shadow_config
;
164 /* A bitfield using bulletin's valid-map bits, used to indicate
165 * which of the bulletin board features have been configured.
167 u64 configured_features
;
168 #define ECORE_IOV_CONFIGURED_FEATURES_MASK ((1 << MAC_ADDR_FORCED) | \
169 (1 << VLAN_ADDR_FORCED))
172 /* This structure is part of ecore_hwfn and used only for PFs that have sriov
173 * capability enabled.
175 struct ecore_pf_iov
{
176 struct ecore_vf_info vfs_array
[MAX_NUM_VFS_E4
];
177 u64 pending_flr
[ECORE_VF_ARRAY_LENGTH
];
180 /* This doesn't serve anything functionally, but it makes windows
181 * debugging of IOV related issues easier.
183 u64 active_vfs
[ECORE_VF_ARRAY_LENGTH
];
186 /* Allocate message address continuosuly and split to each VF */
187 void *mbx_msg_virt_addr
;
188 dma_addr_t mbx_msg_phys_addr
;
190 void *mbx_reply_virt_addr
;
191 dma_addr_t mbx_reply_phys_addr
;
194 dma_addr_t bulletins_phys
;
198 #ifdef CONFIG_ECORE_SRIOV
200 * @brief Read sriov related information and allocated resources
201 * reads from configuraiton space, shmem, etc.
205 * @return enum _ecore_status_t
207 enum _ecore_status_t
ecore_iov_hw_info(struct ecore_hwfn
*p_hwfn
);
210 * @brief ecore_add_tlv - place a given tlv on the tlv buffer at next offset
216 * @return pointer to the newly placed tlv
218 void *ecore_add_tlv(u8
**offset
, u16 type
, u16 length
);
221 * @brief list the types and lengths of the tlvs on the buffer
226 void ecore_dp_tlv_list(struct ecore_hwfn
*p_hwfn
,
230 * @brief ecore_iov_alloc - allocate sriov related resources
234 * @return enum _ecore_status_t
236 enum _ecore_status_t
ecore_iov_alloc(struct ecore_hwfn
*p_hwfn
);
239 * @brief ecore_iov_setup - setup sriov related resources
243 void ecore_iov_setup(struct ecore_hwfn
*p_hwfn
);
246 * @brief ecore_iov_free - free sriov related resources
250 void ecore_iov_free(struct ecore_hwfn
*p_hwfn
);
253 * @brief free sriov related memory that was allocated during hw_prepare
257 void ecore_iov_free_hw_info(struct ecore_dev
*p_dev
);
260 * @brief Mark structs of vfs that have been FLR-ed.
263 * @param disabled_vfs - bitmask of all VFs on path that were FLRed
265 * @return true iff one of the PF's vfs got FLRed. false otherwise.
267 bool ecore_iov_mark_vf_flr(struct ecore_hwfn
*p_hwfn
,
271 * @brief Search extended TLVs in request/reply buffer.
274 * @param p_tlvs_list - Pointer to tlvs list
275 * @param req_type - Type of TLV
277 * @return pointer to tlv type if found, otherwise returns NULL.
279 void *ecore_iov_search_list_tlvs(struct ecore_hwfn
*p_hwfn
,
280 void *p_tlvs_list
, u16 req_type
);
283 * @brief ecore_iov_get_vf_info - return the database of a
287 * @param relative_vf_id - relative id of the VF for which info
289 * @param b_enabled_only - false iff want to access even if vf is disabled
291 * @return struct ecore_vf_info*
293 struct ecore_vf_info
*ecore_iov_get_vf_info(struct ecore_hwfn
*p_hwfn
,
295 bool b_enabled_only
);
297 #endif /* __ECORE_SRIOV_H__ */