Yuval Mintz | 32a47e7 | 2016-05-11 16:36:12 +0300 | [diff] [blame] | 1 | /* QLogic qed NIC Driver |
Mintz, Yuval | e8f1cb5 | 2017-01-01 13:57:00 +0200 | [diff] [blame] | 2 | * Copyright (c) 2015-2017 QLogic Corporation |
Yuval Mintz | 32a47e7 | 2016-05-11 16:36:12 +0300 | [diff] [blame] | 3 | * |
Mintz, Yuval | e8f1cb5 | 2017-01-01 13:57:00 +0200 | [diff] [blame] | 4 | * This software is available to you under a choice of one of two |
| 5 | * licenses. You may choose to be licensed under the terms of the GNU |
| 6 | * General Public License (GPL) Version 2, available from the file |
| 7 | * COPYING in the main directory of this source tree, or the |
| 8 | * OpenIB.org BSD license below: |
| 9 | * |
| 10 | * Redistribution and use in source and binary forms, with or |
| 11 | * without modification, are permitted provided that the following |
| 12 | * conditions are met: |
| 13 | * |
| 14 | * - Redistributions of source code must retain the above |
| 15 | * copyright notice, this list of conditions and the following |
| 16 | * disclaimer. |
| 17 | * |
| 18 | * - Redistributions in binary form must reproduce the above |
| 19 | * copyright notice, this list of conditions and the following |
| 20 | * disclaimer in the documentation and /or other materials |
| 21 | * provided with the distribution. |
| 22 | * |
| 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 24 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 25 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 26 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
| 27 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
| 28 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 29 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 30 | * SOFTWARE. |
Yuval Mintz | 32a47e7 | 2016-05-11 16:36:12 +0300 | [diff] [blame] | 31 | */ |
| 32 | |
| 33 | #ifndef _QED_SRIOV_H |
| 34 | #define _QED_SRIOV_H |
| 35 | #include <linux/types.h> |
| 36 | #include "qed_vf.h" |
Yuval Mintz | 1cf2b1a | 2016-06-05 13:11:12 +0300 | [diff] [blame] | 37 | |
| 38 | #define QED_ETH_VF_NUM_MAC_FILTERS 1 |
| 39 | #define QED_ETH_VF_NUM_VLAN_FILTERS 2 |
Yuval Mintz | 32a47e7 | 2016-05-11 16:36:12 +0300 | [diff] [blame] | 40 | #define QED_VF_ARRAY_LENGTH (3) |
| 41 | |
Arnd Bergmann | 14b84e8 | 2016-06-01 15:29:13 +0200 | [diff] [blame] | 42 | #ifdef CONFIG_QED_SRIOV |
Yuval Mintz | 32a47e7 | 2016-05-11 16:36:12 +0300 | [diff] [blame] | 43 | #define IS_VF(cdev) ((cdev)->b_is_vf) |
| 44 | #define IS_PF(cdev) (!((cdev)->b_is_vf)) |
Yuval Mintz | 32a47e7 | 2016-05-11 16:36:12 +0300 | [diff] [blame] | 45 | #define IS_PF_SRIOV(p_hwfn) (!!((p_hwfn)->cdev->p_iov_info)) |
| 46 | #else |
Arnd Bergmann | 14b84e8 | 2016-06-01 15:29:13 +0200 | [diff] [blame] | 47 | #define IS_VF(cdev) (0) |
| 48 | #define IS_PF(cdev) (1) |
Yuval Mintz | 32a47e7 | 2016-05-11 16:36:12 +0300 | [diff] [blame] | 49 | #define IS_PF_SRIOV(p_hwfn) (0) |
| 50 | #endif |
| 51 | #define IS_PF_SRIOV_ALLOC(p_hwfn) (!!((p_hwfn)->pf_iov_info)) |
| 52 | |
Yuval Mintz | 1408cc1f | 2016-05-11 16:36:14 +0300 | [diff] [blame] | 53 | #define QED_MAX_VF_CHAINS_PER_PF 16 |
Yuval Mintz | 1408cc1f | 2016-05-11 16:36:14 +0300 | [diff] [blame] | 54 | |
Yuval Mintz | 08feecd | 2016-05-11 16:36:20 +0300 | [diff] [blame] | 55 | #define QED_ETH_MAX_VF_NUM_VLAN_FILTERS \ |
| 56 | (MAX_NUM_VFS * QED_ETH_VF_NUM_VLAN_FILTERS) |
| 57 | |
Yuval Mintz | dacd88d | 2016-05-11 16:36:16 +0300 | [diff] [blame] | 58 | enum qed_iov_vport_update_flag { |
| 59 | QED_IOV_VP_UPDATE_ACTIVATE, |
Yuval Mintz | 17b235c | 2016-05-11 16:36:18 +0300 | [diff] [blame] | 60 | QED_IOV_VP_UPDATE_VLAN_STRIP, |
| 61 | QED_IOV_VP_UPDATE_TX_SWITCH, |
Yuval Mintz | dacd88d | 2016-05-11 16:36:16 +0300 | [diff] [blame] | 62 | QED_IOV_VP_UPDATE_MCAST, |
| 63 | QED_IOV_VP_UPDATE_ACCEPT_PARAM, |
| 64 | QED_IOV_VP_UPDATE_RSS, |
Yuval Mintz | 17b235c | 2016-05-11 16:36:18 +0300 | [diff] [blame] | 65 | QED_IOV_VP_UPDATE_ACCEPT_ANY_VLAN, |
| 66 | QED_IOV_VP_UPDATE_SGE_TPA, |
Yuval Mintz | dacd88d | 2016-05-11 16:36:16 +0300 | [diff] [blame] | 67 | QED_IOV_VP_UPDATE_MAX, |
| 68 | }; |
| 69 | |
Yuval Mintz | 0b55e27 | 2016-05-11 16:36:15 +0300 | [diff] [blame] | 70 | struct qed_public_vf_info { |
| 71 | /* These copies will later be reflected in the bulletin board, |
| 72 | * but this copy should be newer. |
| 73 | */ |
Yuval Mintz | eff1696 | 2016-05-11 16:36:21 +0300 | [diff] [blame] | 74 | u8 forced_mac[ETH_ALEN]; |
Yuval Mintz | 08feecd | 2016-05-11 16:36:20 +0300 | [diff] [blame] | 75 | u16 forced_vlan; |
Yuval Mintz | 0b55e27 | 2016-05-11 16:36:15 +0300 | [diff] [blame] | 76 | u8 mac[ETH_ALEN]; |
Yuval Mintz | 733def6 | 2016-05-11 16:36:22 +0300 | [diff] [blame] | 77 | |
| 78 | /* IFLA_VF_LINK_STATE_<X> */ |
| 79 | int link_state; |
| 80 | |
| 81 | /* Currently configured Tx rate in MB/sec. 0 if unconfigured */ |
| 82 | int tx_rate; |
Mintz, Yuval | f990c82 | 2017-01-01 13:57:08 +0200 | [diff] [blame] | 83 | |
| 84 | /* Trusted VFs can configure promiscuous mode. |
| 85 | * Also store shadow promisc configuration if needed. |
| 86 | */ |
| 87 | bool is_trusted_configured; |
| 88 | bool is_trusted_request; |
| 89 | u8 rx_accept_mode; |
| 90 | u8 tx_accept_mode; |
Yuval Mintz | 0b55e27 | 2016-05-11 16:36:15 +0300 | [diff] [blame] | 91 | }; |
| 92 | |
Mintz, Yuval | 3da7a37 | 2016-11-29 16:47:06 +0200 | [diff] [blame] | 93 | struct qed_iov_vf_init_params { |
| 94 | u16 rel_vf_id; |
| 95 | |
| 96 | /* Number of requested Queues; Currently, don't support different |
| 97 | * number of Rx/Tx queues. |
| 98 | */ |
| 99 | |
| 100 | u16 num_queues; |
| 101 | |
| 102 | /* Allow the client to choose which qzones to use for Rx/Tx, |
| 103 | * and which queue_base to use for Tx queues on a per-queue basis. |
| 104 | * Notice values should be relative to the PF resources. |
| 105 | */ |
| 106 | u16 req_rx_queue[QED_MAX_VF_CHAINS_PER_PF]; |
| 107 | u16 req_tx_queue[QED_MAX_VF_CHAINS_PER_PF]; |
| 108 | }; |
| 109 | |
Yuval Mintz | 32a47e7 | 2016-05-11 16:36:12 +0300 | [diff] [blame] | 110 | /* This struct is part of qed_dev and contains data relevant to all hwfns; |
| 111 | * Initialized only if SR-IOV cpabability is exposed in PCIe config space. |
| 112 | */ |
| 113 | struct qed_hw_sriov_info { |
| 114 | int pos; /* capability position */ |
| 115 | int nres; /* number of resources */ |
| 116 | u32 cap; /* SR-IOV Capabilities */ |
| 117 | u16 ctrl; /* SR-IOV Control */ |
| 118 | u16 total_vfs; /* total VFs associated with the PF */ |
| 119 | u16 num_vfs; /* number of vfs that have been started */ |
| 120 | u16 initial_vfs; /* initial VFs associated with the PF */ |
| 121 | u16 nr_virtfn; /* number of VFs available */ |
| 122 | u16 offset; /* first VF Routing ID offset */ |
| 123 | u16 stride; /* following VF stride */ |
| 124 | u16 vf_device_id; /* VF device id */ |
| 125 | u32 pgsz; /* page size for BAR alignment */ |
| 126 | u8 link; /* Function Dependency Link */ |
| 127 | |
| 128 | u32 first_vf_in_pf; |
| 129 | }; |
| 130 | |
| 131 | /* This mailbox is maintained per VF in its PF contains all information |
| 132 | * required for sending / receiving a message. |
| 133 | */ |
| 134 | struct qed_iov_vf_mbx { |
| 135 | union vfpf_tlvs *req_virt; |
| 136 | dma_addr_t req_phys; |
| 137 | union pfvf_tlvs *reply_virt; |
| 138 | dma_addr_t reply_phys; |
Yuval Mintz | 37bff2b | 2016-05-11 16:36:13 +0300 | [diff] [blame] | 139 | |
| 140 | /* Address in VF where a pending message is located */ |
| 141 | dma_addr_t pending_req; |
| 142 | |
Mintz, Yuval | fd3c615 | 2017-02-27 11:06:32 +0200 | [diff] [blame] | 143 | /* Message from VF awaits handling */ |
| 144 | bool b_pending_msg; |
| 145 | |
Yuval Mintz | 37bff2b | 2016-05-11 16:36:13 +0300 | [diff] [blame] | 146 | u8 *offset; |
| 147 | |
| 148 | /* saved VF request header */ |
| 149 | struct vfpf_first_tlv first_tlv; |
Yuval Mintz | 32a47e7 | 2016-05-11 16:36:12 +0300 | [diff] [blame] | 150 | }; |
| 151 | |
Mintz, Yuval | bbe3f23 | 2017-06-04 13:31:03 +0300 | [diff] [blame] | 152 | #define QED_IOV_LEGACY_QID_RX (0) |
| 153 | #define QED_IOV_LEGACY_QID_TX (1) |
Mintz, Yuval | 08bc8f1 | 2017-06-04 13:31:06 +0300 | [diff] [blame] | 154 | #define QED_IOV_QID_INVALID (0xFE) |
Mintz, Yuval | bbe3f23 | 2017-06-04 13:31:03 +0300 | [diff] [blame] | 155 | |
Mintz, Yuval | 007bc37 | 2017-06-04 13:31:05 +0300 | [diff] [blame] | 156 | struct qed_vf_queue_cid { |
| 157 | bool b_is_tx; |
| 158 | struct qed_queue_cid *p_cid; |
| 159 | }; |
| 160 | |
| 161 | /* Describes a qzone associated with the VF */ |
| 162 | struct qed_vf_queue { |
Yuval Mintz | 1408cc1f | 2016-05-11 16:36:14 +0300 | [diff] [blame] | 163 | u16 fw_rx_qid; |
| 164 | u16 fw_tx_qid; |
Mintz, Yuval | 007bc37 | 2017-06-04 13:31:05 +0300 | [diff] [blame] | 165 | |
| 166 | struct qed_vf_queue_cid cids[MAX_QUEUES_PER_QZONE]; |
Yuval Mintz | 1408cc1f | 2016-05-11 16:36:14 +0300 | [diff] [blame] | 167 | }; |
| 168 | |
Yuval Mintz | 32a47e7 | 2016-05-11 16:36:12 +0300 | [diff] [blame] | 169 | enum vf_state { |
Yuval Mintz | 1408cc1f | 2016-05-11 16:36:14 +0300 | [diff] [blame] | 170 | VF_FREE = 0, /* VF ready to be acquired holds no resc */ |
| 171 | VF_ACQUIRED, /* VF, acquired, but not initalized */ |
Yuval Mintz | dacd88d | 2016-05-11 16:36:16 +0300 | [diff] [blame] | 172 | VF_ENABLED, /* VF, Enabled */ |
Yuval Mintz | 0b55e27 | 2016-05-11 16:36:15 +0300 | [diff] [blame] | 173 | VF_RESET, /* VF, FLR'd, pending cleanup */ |
Yuval Mintz | 32a47e7 | 2016-05-11 16:36:12 +0300 | [diff] [blame] | 174 | VF_STOPPED /* VF, Stopped */ |
| 175 | }; |
| 176 | |
Yuval Mintz | 08feecd | 2016-05-11 16:36:20 +0300 | [diff] [blame] | 177 | struct qed_vf_vlan_shadow { |
| 178 | bool used; |
| 179 | u16 vid; |
| 180 | }; |
| 181 | |
| 182 | struct qed_vf_shadow_config { |
| 183 | /* Shadow copy of all guest vlans */ |
| 184 | struct qed_vf_vlan_shadow vlans[QED_ETH_VF_NUM_VLAN_FILTERS + 1]; |
| 185 | |
Yuval Mintz | 8246d0b | 2016-06-05 13:11:15 +0300 | [diff] [blame] | 186 | /* Shadow copy of all configured MACs; Empty if forcing MACs */ |
| 187 | u8 macs[QED_ETH_VF_NUM_MAC_FILTERS][ETH_ALEN]; |
Yuval Mintz | 08feecd | 2016-05-11 16:36:20 +0300 | [diff] [blame] | 188 | u8 inner_vlan_removal; |
| 189 | }; |
| 190 | |
Yuval Mintz | 32a47e7 | 2016-05-11 16:36:12 +0300 | [diff] [blame] | 191 | /* PFs maintain an array of this structure, per VF */ |
| 192 | struct qed_vf_info { |
| 193 | struct qed_iov_vf_mbx vf_mbx; |
| 194 | enum vf_state state; |
| 195 | bool b_init; |
Yuval Mintz | 7eff82b | 2016-10-14 05:19:22 -0400 | [diff] [blame] | 196 | bool b_malicious; |
Yuval Mintz | 0b55e27 | 2016-05-11 16:36:15 +0300 | [diff] [blame] | 197 | u8 to_disable; |
Yuval Mintz | 32a47e7 | 2016-05-11 16:36:12 +0300 | [diff] [blame] | 198 | |
| 199 | struct qed_bulletin bulletin; |
| 200 | dma_addr_t vf_bulletin; |
| 201 | |
Yuval Mintz | 1fe614d | 2016-06-05 13:11:11 +0300 | [diff] [blame] | 202 | /* PF saves a copy of the last VF acquire message */ |
| 203 | struct vfpf_acquire_tlv acquire; |
| 204 | |
Yuval Mintz | 32a47e7 | 2016-05-11 16:36:12 +0300 | [diff] [blame] | 205 | u32 concrete_fid; |
| 206 | u16 opaque_fid; |
Yuval Mintz | dacd88d | 2016-05-11 16:36:16 +0300 | [diff] [blame] | 207 | u16 mtu; |
Yuval Mintz | 32a47e7 | 2016-05-11 16:36:12 +0300 | [diff] [blame] | 208 | |
| 209 | u8 vport_id; |
| 210 | u8 relative_vf_id; |
| 211 | u8 abs_vf_id; |
| 212 | #define QED_VF_ABS_ID(p_hwfn, p_vf) (QED_PATH_ID(p_hwfn) ? \ |
| 213 | (p_vf)->abs_vf_id + MAX_NUM_VFS_BB : \ |
| 214 | (p_vf)->abs_vf_id) |
Yuval Mintz | 1408cc1f | 2016-05-11 16:36:14 +0300 | [diff] [blame] | 215 | |
Yuval Mintz | dacd88d | 2016-05-11 16:36:16 +0300 | [diff] [blame] | 216 | u8 vport_instance; |
Yuval Mintz | 1408cc1f | 2016-05-11 16:36:14 +0300 | [diff] [blame] | 217 | u8 num_rxqs; |
| 218 | u8 num_txqs; |
| 219 | |
| 220 | u8 num_sbs; |
| 221 | |
| 222 | u8 num_mac_filters; |
| 223 | u8 num_vlan_filters; |
Mintz, Yuval | 007bc37 | 2017-06-04 13:31:05 +0300 | [diff] [blame] | 224 | |
| 225 | struct qed_vf_queue vf_queues[QED_MAX_VF_CHAINS_PER_PF]; |
Yuval Mintz | 1408cc1f | 2016-05-11 16:36:14 +0300 | [diff] [blame] | 226 | u16 igu_sbs[QED_MAX_VF_CHAINS_PER_PF]; |
Yuval Mintz | dacd88d | 2016-05-11 16:36:16 +0300 | [diff] [blame] | 227 | u8 num_active_rxqs; |
Yuval Mintz | 0b55e27 | 2016-05-11 16:36:15 +0300 | [diff] [blame] | 228 | struct qed_public_vf_info p_vf_info; |
Yuval Mintz | 6ddc760 | 2016-05-11 16:36:23 +0300 | [diff] [blame] | 229 | bool spoof_chk; |
| 230 | bool req_spoofchk_val; |
Yuval Mintz | 08feecd | 2016-05-11 16:36:20 +0300 | [diff] [blame] | 231 | |
| 232 | /* Stores the configuration requested by VF */ |
| 233 | struct qed_vf_shadow_config shadow_config; |
| 234 | |
| 235 | /* A bitfield using bulletin's valid-map bits, used to indicate |
| 236 | * which of the bulletin board features have been configured. |
| 237 | */ |
| 238 | u64 configured_features; |
| 239 | #define QED_IOV_CONFIGURED_FEATURES_MASK ((1 << MAC_ADDR_FORCED) | \ |
| 240 | (1 << VLAN_ADDR_FORCED)) |
Yuval Mintz | 32a47e7 | 2016-05-11 16:36:12 +0300 | [diff] [blame] | 241 | }; |
| 242 | |
| 243 | /* This structure is part of qed_hwfn and used only for PFs that have sriov |
| 244 | * capability enabled. |
| 245 | */ |
| 246 | struct qed_pf_iov { |
| 247 | struct qed_vf_info vfs_array[MAX_NUM_VFS]; |
Yuval Mintz | 32a47e7 | 2016-05-11 16:36:12 +0300 | [diff] [blame] | 248 | u64 pending_flr[QED_VF_ARRAY_LENGTH]; |
| 249 | |
| 250 | /* Allocate message address continuosuly and split to each VF */ |
| 251 | void *mbx_msg_virt_addr; |
| 252 | dma_addr_t mbx_msg_phys_addr; |
| 253 | u32 mbx_msg_size; |
| 254 | void *mbx_reply_virt_addr; |
| 255 | dma_addr_t mbx_reply_phys_addr; |
| 256 | u32 mbx_reply_size; |
| 257 | void *p_bulletins; |
| 258 | dma_addr_t bulletins_phys; |
| 259 | u32 bulletins_size; |
| 260 | }; |
| 261 | |
Yuval Mintz | 37bff2b | 2016-05-11 16:36:13 +0300 | [diff] [blame] | 262 | enum qed_iov_wq_flag { |
| 263 | QED_IOV_WQ_MSG_FLAG, |
| 264 | QED_IOV_WQ_SET_UNICAST_FILTER_FLAG, |
| 265 | QED_IOV_WQ_BULLETIN_UPDATE_FLAG, |
| 266 | QED_IOV_WQ_STOP_WQ_FLAG, |
| 267 | QED_IOV_WQ_FLR_FLAG, |
Mintz, Yuval | f990c82 | 2017-01-01 13:57:08 +0200 | [diff] [blame] | 268 | QED_IOV_WQ_TRUST_FLAG, |
Mintz, Yuval | 65ed2ff | 2017-02-20 22:43:39 +0200 | [diff] [blame] | 269 | QED_IOV_WQ_VF_FORCE_LINK_QUERY_FLAG, |
Yuval Mintz | 37bff2b | 2016-05-11 16:36:13 +0300 | [diff] [blame] | 270 | }; |
| 271 | |
Yuval Mintz | 32a47e7 | 2016-05-11 16:36:12 +0300 | [diff] [blame] | 272 | #ifdef CONFIG_QED_SRIOV |
| 273 | /** |
| 274 | * @brief - Given a VF index, return index of next [including that] active VF. |
| 275 | * |
| 276 | * @param p_hwfn |
| 277 | * @param rel_vf_id |
| 278 | * |
| 279 | * @return MAX_NUM_VFS in case no further active VFs, otherwise index. |
| 280 | */ |
| 281 | u16 qed_iov_get_next_active_vf(struct qed_hwfn *p_hwfn, u16 rel_vf_id); |
| 282 | |
Chopra, Manish | 97379f1 | 2017-04-24 10:00:48 -0700 | [diff] [blame] | 283 | void qed_iov_bulletin_set_udp_ports(struct qed_hwfn *p_hwfn, |
| 284 | int vfid, u16 vxlan_port, u16 geneve_port); |
| 285 | |
Yuval Mintz | 32a47e7 | 2016-05-11 16:36:12 +0300 | [diff] [blame] | 286 | /** |
| 287 | * @brief Read sriov related information and allocated resources |
| 288 | * reads from configuraiton space, shmem, etc. |
| 289 | * |
| 290 | * @param p_hwfn |
| 291 | * |
| 292 | * @return int |
| 293 | */ |
| 294 | int qed_iov_hw_info(struct qed_hwfn *p_hwfn); |
| 295 | |
| 296 | /** |
Yuval Mintz | 1408cc1f | 2016-05-11 16:36:14 +0300 | [diff] [blame] | 297 | * @brief qed_add_tlv - place a given tlv on the tlv buffer at next offset |
| 298 | * |
| 299 | * @param p_hwfn |
| 300 | * @param p_iov |
| 301 | * @param type |
| 302 | * @param length |
| 303 | * |
| 304 | * @return pointer to the newly placed tlv |
| 305 | */ |
| 306 | void *qed_add_tlv(struct qed_hwfn *p_hwfn, u8 **offset, u16 type, u16 length); |
| 307 | |
| 308 | /** |
| 309 | * @brief list the types and lengths of the tlvs on the buffer |
| 310 | * |
| 311 | * @param p_hwfn |
| 312 | * @param tlvs_list |
| 313 | */ |
| 314 | void qed_dp_tlv_list(struct qed_hwfn *p_hwfn, void *tlvs_list); |
| 315 | |
| 316 | /** |
Yuval Mintz | 32a47e7 | 2016-05-11 16:36:12 +0300 | [diff] [blame] | 317 | * @brief qed_iov_alloc - allocate sriov related resources |
| 318 | * |
| 319 | * @param p_hwfn |
| 320 | * |
| 321 | * @return int |
| 322 | */ |
| 323 | int qed_iov_alloc(struct qed_hwfn *p_hwfn); |
| 324 | |
| 325 | /** |
| 326 | * @brief qed_iov_setup - setup sriov related resources |
| 327 | * |
| 328 | * @param p_hwfn |
Yuval Mintz | 32a47e7 | 2016-05-11 16:36:12 +0300 | [diff] [blame] | 329 | */ |
Mintz, Yuval | 1ee240e | 2017-06-01 15:29:11 +0300 | [diff] [blame] | 330 | void qed_iov_setup(struct qed_hwfn *p_hwfn); |
Yuval Mintz | 32a47e7 | 2016-05-11 16:36:12 +0300 | [diff] [blame] | 331 | |
| 332 | /** |
| 333 | * @brief qed_iov_free - free sriov related resources |
| 334 | * |
| 335 | * @param p_hwfn |
| 336 | */ |
| 337 | void qed_iov_free(struct qed_hwfn *p_hwfn); |
| 338 | |
| 339 | /** |
| 340 | * @brief free sriov related memory that was allocated during hw_prepare |
| 341 | * |
| 342 | * @param cdev |
| 343 | */ |
| 344 | void qed_iov_free_hw_info(struct qed_dev *cdev); |
Yuval Mintz | 37bff2b | 2016-05-11 16:36:13 +0300 | [diff] [blame] | 345 | |
| 346 | /** |
| 347 | * @brief qed_sriov_eqe_event - handle async sriov event arrived on eqe. |
| 348 | * |
| 349 | * @param p_hwfn |
| 350 | * @param opcode |
| 351 | * @param echo |
| 352 | * @param data |
| 353 | */ |
| 354 | int qed_sriov_eqe_event(struct qed_hwfn *p_hwfn, |
| 355 | u8 opcode, __le16 echo, union event_ring_data *data); |
| 356 | |
Yuval Mintz | 0b55e27 | 2016-05-11 16:36:15 +0300 | [diff] [blame] | 357 | /** |
| 358 | * @brief Mark structs of vfs that have been FLR-ed. |
| 359 | * |
| 360 | * @param p_hwfn |
| 361 | * @param disabled_vfs - bitmask of all VFs on path that were FLRed |
| 362 | * |
Mintz, Yuval | cccf6f5 | 2017-03-19 13:08:18 +0200 | [diff] [blame] | 363 | * @return true iff one of the PF's vfs got FLRed. false otherwise. |
Yuval Mintz | 0b55e27 | 2016-05-11 16:36:15 +0300 | [diff] [blame] | 364 | */ |
Mintz, Yuval | cccf6f5 | 2017-03-19 13:08:18 +0200 | [diff] [blame] | 365 | bool qed_iov_mark_vf_flr(struct qed_hwfn *p_hwfn, u32 *disabled_vfs); |
Yuval Mintz | 0b55e27 | 2016-05-11 16:36:15 +0300 | [diff] [blame] | 366 | |
Yuval Mintz | dacd88d | 2016-05-11 16:36:16 +0300 | [diff] [blame] | 367 | /** |
| 368 | * @brief Search extended TLVs in request/reply buffer. |
| 369 | * |
| 370 | * @param p_hwfn |
| 371 | * @param p_tlvs_list - Pointer to tlvs list |
| 372 | * @param req_type - Type of TLV |
| 373 | * |
| 374 | * @return pointer to tlv type if found, otherwise returns NULL. |
| 375 | */ |
| 376 | void *qed_iov_search_list_tlvs(struct qed_hwfn *p_hwfn, |
| 377 | void *p_tlvs_list, u16 req_type); |
| 378 | |
Yuval Mintz | 37bff2b | 2016-05-11 16:36:13 +0300 | [diff] [blame] | 379 | void qed_iov_wq_stop(struct qed_dev *cdev, bool schedule_first); |
| 380 | int qed_iov_wq_start(struct qed_dev *cdev); |
| 381 | |
| 382 | void qed_schedule_iov(struct qed_hwfn *hwfn, enum qed_iov_wq_flag flag); |
Yuval Mintz | 1408cc1f | 2016-05-11 16:36:14 +0300 | [diff] [blame] | 383 | void qed_vf_start_iov_wq(struct qed_dev *cdev); |
Yuval Mintz | 0b55e27 | 2016-05-11 16:36:15 +0300 | [diff] [blame] | 384 | int qed_sriov_disable(struct qed_dev *cdev, bool pci_enabled); |
Yuval Mintz | 36558c3 | 2016-05-11 16:36:17 +0300 | [diff] [blame] | 385 | void qed_inform_vf_link_state(struct qed_hwfn *hwfn); |
Yuval Mintz | 32a47e7 | 2016-05-11 16:36:12 +0300 | [diff] [blame] | 386 | #else |
| 387 | static inline u16 qed_iov_get_next_active_vf(struct qed_hwfn *p_hwfn, |
| 388 | u16 rel_vf_id) |
| 389 | { |
| 390 | return MAX_NUM_VFS; |
| 391 | } |
| 392 | |
Chopra, Manish | 97379f1 | 2017-04-24 10:00:48 -0700 | [diff] [blame] | 393 | static inline void |
| 394 | qed_iov_bulletin_set_udp_ports(struct qed_hwfn *p_hwfn, int vfid, |
| 395 | u16 vxlan_port, u16 geneve_port) |
| 396 | { |
| 397 | } |
| 398 | |
Yuval Mintz | 32a47e7 | 2016-05-11 16:36:12 +0300 | [diff] [blame] | 399 | static inline int qed_iov_hw_info(struct qed_hwfn *p_hwfn) |
| 400 | { |
| 401 | return 0; |
| 402 | } |
| 403 | |
| 404 | static inline int qed_iov_alloc(struct qed_hwfn *p_hwfn) |
| 405 | { |
| 406 | return 0; |
| 407 | } |
| 408 | |
Mintz, Yuval | 1ee240e | 2017-06-01 15:29:11 +0300 | [diff] [blame] | 409 | static inline void qed_iov_setup(struct qed_hwfn *p_hwfn) |
Yuval Mintz | 32a47e7 | 2016-05-11 16:36:12 +0300 | [diff] [blame] | 410 | { |
| 411 | } |
| 412 | |
| 413 | static inline void qed_iov_free(struct qed_hwfn *p_hwfn) |
| 414 | { |
| 415 | } |
| 416 | |
| 417 | static inline void qed_iov_free_hw_info(struct qed_dev *cdev) |
| 418 | { |
| 419 | } |
Yuval Mintz | 37bff2b | 2016-05-11 16:36:13 +0300 | [diff] [blame] | 420 | |
| 421 | static inline int qed_sriov_eqe_event(struct qed_hwfn *p_hwfn, |
| 422 | u8 opcode, |
| 423 | __le16 echo, union event_ring_data *data) |
| 424 | { |
| 425 | return -EINVAL; |
| 426 | } |
| 427 | |
Mintz, Yuval | cccf6f5 | 2017-03-19 13:08:18 +0200 | [diff] [blame] | 428 | static inline bool qed_iov_mark_vf_flr(struct qed_hwfn *p_hwfn, |
| 429 | u32 *disabled_vfs) |
Yuval Mintz | 0b55e27 | 2016-05-11 16:36:15 +0300 | [diff] [blame] | 430 | { |
Mintz, Yuval | cccf6f5 | 2017-03-19 13:08:18 +0200 | [diff] [blame] | 431 | return false; |
Yuval Mintz | 0b55e27 | 2016-05-11 16:36:15 +0300 | [diff] [blame] | 432 | } |
| 433 | |
Yuval Mintz | 37bff2b | 2016-05-11 16:36:13 +0300 | [diff] [blame] | 434 | static inline void qed_iov_wq_stop(struct qed_dev *cdev, bool schedule_first) |
| 435 | { |
| 436 | } |
| 437 | |
| 438 | static inline int qed_iov_wq_start(struct qed_dev *cdev) |
| 439 | { |
| 440 | return 0; |
| 441 | } |
| 442 | |
| 443 | static inline void qed_schedule_iov(struct qed_hwfn *hwfn, |
| 444 | enum qed_iov_wq_flag flag) |
| 445 | { |
| 446 | } |
Yuval Mintz | 1408cc1f | 2016-05-11 16:36:14 +0300 | [diff] [blame] | 447 | |
| 448 | static inline void qed_vf_start_iov_wq(struct qed_dev *cdev) |
| 449 | { |
| 450 | } |
Yuval Mintz | 0b55e27 | 2016-05-11 16:36:15 +0300 | [diff] [blame] | 451 | |
| 452 | static inline int qed_sriov_disable(struct qed_dev *cdev, bool pci_enabled) |
| 453 | { |
| 454 | return 0; |
| 455 | } |
Yuval Mintz | 36558c3 | 2016-05-11 16:36:17 +0300 | [diff] [blame] | 456 | |
| 457 | static inline void qed_inform_vf_link_state(struct qed_hwfn *hwfn) |
| 458 | { |
| 459 | } |
Yuval Mintz | 32a47e7 | 2016-05-11 16:36:12 +0300 | [diff] [blame] | 460 | #endif |
| 461 | |
| 462 | #define qed_for_each_vf(_p_hwfn, _i) \ |
| 463 | for (_i = qed_iov_get_next_active_vf(_p_hwfn, 0); \ |
| 464 | _i < MAX_NUM_VFS; \ |
| 465 | _i = qed_iov_get_next_active_vf(_p_hwfn, _i + 1)) |
| 466 | |
| 467 | #endif |