Alexander Duyck | 883a9cc | 2014-09-20 19:52:09 -0400 | [diff] [blame] | 1 | /* Intel Ethernet Switch Host Interface Driver |
Jeff Kirsher | de44519 | 2015-04-03 13:26:56 -0700 | [diff] [blame] | 2 | * Copyright(c) 2013 - 2015 Intel Corporation. |
Alexander Duyck | 883a9cc | 2014-09-20 19:52:09 -0400 | [diff] [blame] | 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify it |
| 5 | * under the terms and conditions of the GNU General Public License, |
| 6 | * version 2, as published by the Free Software Foundation. |
| 7 | * |
| 8 | * This program is distributed in the hope it will be useful, but WITHOUT |
| 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 11 | * more details. |
| 12 | * |
| 13 | * The full GNU General Public License is included in this distribution in |
| 14 | * the file called "COPYING". |
| 15 | * |
| 16 | * Contact Information: |
| 17 | * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> |
| 18 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
| 19 | */ |
| 20 | |
| 21 | #include "fm10k.h" |
| 22 | #include "fm10k_vf.h" |
| 23 | #include "fm10k_pf.h" |
| 24 | |
| 25 | static s32 fm10k_iov_msg_error(struct fm10k_hw *hw, u32 **results, |
| 26 | struct fm10k_mbx_info *mbx) |
| 27 | { |
| 28 | struct fm10k_vf_info *vf_info = (struct fm10k_vf_info *)mbx; |
| 29 | struct fm10k_intfc *interface = hw->back; |
| 30 | struct pci_dev *pdev = interface->pdev; |
| 31 | |
| 32 | dev_err(&pdev->dev, "Unknown message ID %u on VF %d\n", |
| 33 | **results & FM10K_TLV_ID_MASK, vf_info->vf_idx); |
| 34 | |
| 35 | return fm10k_tlv_msg_error(hw, results, mbx); |
| 36 | } |
| 37 | |
| 38 | static const struct fm10k_msg_data iov_mbx_data[] = { |
| 39 | FM10K_TLV_MSG_TEST_HANDLER(fm10k_tlv_msg_test), |
| 40 | FM10K_VF_MSG_MSIX_HANDLER(fm10k_iov_msg_msix_pf), |
| 41 | FM10K_VF_MSG_MAC_VLAN_HANDLER(fm10k_iov_msg_mac_vlan_pf), |
| 42 | FM10K_VF_MSG_LPORT_STATE_HANDLER(fm10k_iov_msg_lport_state_pf), |
| 43 | FM10K_TLV_MSG_ERROR_HANDLER(fm10k_iov_msg_error), |
| 44 | }; |
| 45 | |
| 46 | s32 fm10k_iov_event(struct fm10k_intfc *interface) |
| 47 | { |
| 48 | struct fm10k_hw *hw = &interface->hw; |
| 49 | struct fm10k_iov_data *iov_data; |
Jeff Kirsher | 9de15bd | 2015-04-10 17:20:17 -0700 | [diff] [blame^] | 50 | s64 vflre; |
Alexander Duyck | 883a9cc | 2014-09-20 19:52:09 -0400 | [diff] [blame] | 51 | int i; |
| 52 | |
| 53 | /* if there is no iov_data then there is no mailboxes to process */ |
| 54 | if (!ACCESS_ONCE(interface->iov_data)) |
| 55 | return 0; |
| 56 | |
| 57 | rcu_read_lock(); |
| 58 | |
| 59 | iov_data = interface->iov_data; |
| 60 | |
| 61 | /* check again now that we are in the RCU block */ |
| 62 | if (!iov_data) |
| 63 | goto read_unlock; |
| 64 | |
| 65 | if (!(fm10k_read_reg(hw, FM10K_EICR) & FM10K_EICR_VFLR)) |
Jeff Kirsher | 9de15bd | 2015-04-10 17:20:17 -0700 | [diff] [blame^] | 66 | goto read_unlock; |
Alexander Duyck | 883a9cc | 2014-09-20 19:52:09 -0400 | [diff] [blame] | 67 | |
| 68 | /* read VFLRE to determine if any VFs have been reset */ |
| 69 | do { |
| 70 | vflre = fm10k_read_reg(hw, FM10K_PFVFLRE(0)); |
| 71 | vflre <<= 32; |
| 72 | vflre |= fm10k_read_reg(hw, FM10K_PFVFLRE(1)); |
| 73 | vflre = (vflre << 32) | (vflre >> 32); |
| 74 | vflre |= fm10k_read_reg(hw, FM10K_PFVFLRE(0)); |
| 75 | |
| 76 | i = iov_data->num_vfs; |
| 77 | |
| 78 | for (vflre <<= 64 - i; vflre && i--; vflre += vflre) { |
| 79 | struct fm10k_vf_info *vf_info = &iov_data->vf_info[i]; |
| 80 | |
| 81 | if (vflre >= 0) |
| 82 | continue; |
| 83 | |
| 84 | hw->iov.ops.reset_resources(hw, vf_info); |
| 85 | vf_info->mbx.ops.connect(hw, &vf_info->mbx); |
| 86 | } |
| 87 | } while (i != iov_data->num_vfs); |
| 88 | |
Alexander Duyck | 883a9cc | 2014-09-20 19:52:09 -0400 | [diff] [blame] | 89 | read_unlock: |
| 90 | rcu_read_unlock(); |
| 91 | |
| 92 | return 0; |
| 93 | } |
| 94 | |
| 95 | s32 fm10k_iov_mbx(struct fm10k_intfc *interface) |
| 96 | { |
| 97 | struct fm10k_hw *hw = &interface->hw; |
| 98 | struct fm10k_iov_data *iov_data; |
| 99 | int i; |
| 100 | |
| 101 | /* if there is no iov_data then there is no mailboxes to process */ |
| 102 | if (!ACCESS_ONCE(interface->iov_data)) |
| 103 | return 0; |
| 104 | |
| 105 | rcu_read_lock(); |
| 106 | |
| 107 | iov_data = interface->iov_data; |
| 108 | |
| 109 | /* check again now that we are in the RCU block */ |
| 110 | if (!iov_data) |
| 111 | goto read_unlock; |
| 112 | |
| 113 | /* lock the mailbox for transmit and receive */ |
| 114 | fm10k_mbx_lock(interface); |
| 115 | |
| 116 | process_mbx: |
| 117 | for (i = iov_data->next_vf_mbx ? : iov_data->num_vfs; i--;) { |
| 118 | struct fm10k_vf_info *vf_info = &iov_data->vf_info[i]; |
| 119 | struct fm10k_mbx_info *mbx = &vf_info->mbx; |
| 120 | u16 glort = vf_info->glort; |
| 121 | |
| 122 | /* verify port mapping is valid, if not reset port */ |
| 123 | if (vf_info->vf_flags && !fm10k_glort_valid_pf(hw, glort)) |
| 124 | hw->iov.ops.reset_lport(hw, vf_info); |
| 125 | |
| 126 | /* reset VFs that have mailbox timed out */ |
| 127 | if (!mbx->timeout) { |
| 128 | hw->iov.ops.reset_resources(hw, vf_info); |
| 129 | mbx->ops.connect(hw, mbx); |
| 130 | } |
| 131 | |
Alexander Duyck | 883a9cc | 2014-09-20 19:52:09 -0400 | [diff] [blame] | 132 | /* guarantee we have free space in the SM mailbox */ |
| 133 | if (!hw->mbx.ops.tx_ready(&hw->mbx, FM10K_VFMBX_MSG_MTU)) |
| 134 | break; |
| 135 | |
| 136 | /* cleanup mailbox and process received messages */ |
| 137 | mbx->ops.process(hw, mbx); |
| 138 | } |
| 139 | |
| 140 | if (i >= 0) { |
| 141 | iov_data->next_vf_mbx = i + 1; |
| 142 | } else if (iov_data->next_vf_mbx) { |
| 143 | iov_data->next_vf_mbx = 0; |
| 144 | goto process_mbx; |
| 145 | } |
| 146 | |
| 147 | /* free the lock */ |
| 148 | fm10k_mbx_unlock(interface); |
| 149 | |
| 150 | read_unlock: |
| 151 | rcu_read_unlock(); |
| 152 | |
| 153 | return 0; |
| 154 | } |
| 155 | |
| 156 | void fm10k_iov_suspend(struct pci_dev *pdev) |
| 157 | { |
| 158 | struct fm10k_intfc *interface = pci_get_drvdata(pdev); |
| 159 | struct fm10k_iov_data *iov_data = interface->iov_data; |
| 160 | struct fm10k_hw *hw = &interface->hw; |
| 161 | int num_vfs, i; |
| 162 | |
| 163 | /* pull out num_vfs from iov_data */ |
| 164 | num_vfs = iov_data ? iov_data->num_vfs : 0; |
| 165 | |
| 166 | /* shut down queue mapping for VFs */ |
| 167 | fm10k_write_reg(hw, FM10K_DGLORTMAP(fm10k_dglort_vf_rss), |
| 168 | FM10K_DGLORTMAP_NONE); |
| 169 | |
| 170 | /* Stop any active VFs and reset their resources */ |
| 171 | for (i = 0; i < num_vfs; i++) { |
| 172 | struct fm10k_vf_info *vf_info = &iov_data->vf_info[i]; |
| 173 | |
| 174 | hw->iov.ops.reset_resources(hw, vf_info); |
| 175 | hw->iov.ops.reset_lport(hw, vf_info); |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | int fm10k_iov_resume(struct pci_dev *pdev) |
| 180 | { |
| 181 | struct fm10k_intfc *interface = pci_get_drvdata(pdev); |
| 182 | struct fm10k_iov_data *iov_data = interface->iov_data; |
| 183 | struct fm10k_dglort_cfg dglort = { 0 }; |
| 184 | struct fm10k_hw *hw = &interface->hw; |
| 185 | int num_vfs, i; |
| 186 | |
| 187 | /* pull out num_vfs from iov_data */ |
| 188 | num_vfs = iov_data ? iov_data->num_vfs : 0; |
| 189 | |
| 190 | /* return error if iov_data is not already populated */ |
| 191 | if (!iov_data) |
| 192 | return -ENOMEM; |
| 193 | |
| 194 | /* allocate hardware resources for the VFs */ |
| 195 | hw->iov.ops.assign_resources(hw, num_vfs, num_vfs); |
| 196 | |
| 197 | /* configure DGLORT mapping for RSS */ |
| 198 | dglort.glort = hw->mac.dglort_map & FM10K_DGLORTMAP_NONE; |
| 199 | dglort.idx = fm10k_dglort_vf_rss; |
| 200 | dglort.inner_rss = 1; |
| 201 | dglort.rss_l = fls(fm10k_queues_per_pool(hw) - 1); |
| 202 | dglort.queue_b = fm10k_vf_queue_index(hw, 0); |
| 203 | dglort.vsi_l = fls(hw->iov.total_vfs - 1); |
| 204 | dglort.vsi_b = 1; |
| 205 | |
| 206 | hw->mac.ops.configure_dglort_map(hw, &dglort); |
| 207 | |
| 208 | /* assign resources to the device */ |
| 209 | for (i = 0; i < num_vfs; i++) { |
| 210 | struct fm10k_vf_info *vf_info = &iov_data->vf_info[i]; |
| 211 | |
| 212 | /* allocate all but the last GLORT to the VFs */ |
| 213 | if (i == ((~hw->mac.dglort_map) >> FM10K_DGLORTMAP_MASK_SHIFT)) |
| 214 | break; |
| 215 | |
| 216 | /* assign GLORT to VF, and restrict it to multicast */ |
| 217 | hw->iov.ops.set_lport(hw, vf_info, i, |
| 218 | FM10K_VF_FLAG_MULTI_CAPABLE); |
| 219 | |
| 220 | /* assign our default vid to the VF following reset */ |
| 221 | vf_info->sw_vid = hw->mac.default_vid; |
| 222 | |
| 223 | /* mailbox is disconnected so we don't send a message */ |
| 224 | hw->iov.ops.assign_default_mac_vlan(hw, vf_info); |
| 225 | |
| 226 | /* now we are ready so we can connect */ |
| 227 | vf_info->mbx.ops.connect(hw, &vf_info->mbx); |
| 228 | } |
| 229 | |
| 230 | return 0; |
| 231 | } |
| 232 | |
| 233 | s32 fm10k_iov_update_pvid(struct fm10k_intfc *interface, u16 glort, u16 pvid) |
| 234 | { |
| 235 | struct fm10k_iov_data *iov_data = interface->iov_data; |
| 236 | struct fm10k_hw *hw = &interface->hw; |
| 237 | struct fm10k_vf_info *vf_info; |
| 238 | u16 vf_idx = (glort - hw->mac.dglort_map) & FM10K_DGLORTMAP_NONE; |
| 239 | |
| 240 | /* no IOV support, not our message to process */ |
| 241 | if (!iov_data) |
| 242 | return FM10K_ERR_PARAM; |
| 243 | |
| 244 | /* glort outside our range, not our message to process */ |
| 245 | if (vf_idx >= iov_data->num_vfs) |
| 246 | return FM10K_ERR_PARAM; |
| 247 | |
Matthew Vick | eca3204 | 2015-01-31 02:23:05 +0000 | [diff] [blame] | 248 | /* determine if an update has occurred and if so notify the VF */ |
Alexander Duyck | 883a9cc | 2014-09-20 19:52:09 -0400 | [diff] [blame] | 249 | vf_info = &iov_data->vf_info[vf_idx]; |
| 250 | if (vf_info->sw_vid != pvid) { |
| 251 | vf_info->sw_vid = pvid; |
| 252 | hw->iov.ops.assign_default_mac_vlan(hw, vf_info); |
| 253 | } |
| 254 | |
| 255 | return 0; |
| 256 | } |
| 257 | |
| 258 | static void fm10k_iov_free_data(struct pci_dev *pdev) |
| 259 | { |
| 260 | struct fm10k_intfc *interface = pci_get_drvdata(pdev); |
| 261 | |
| 262 | if (!interface->iov_data) |
| 263 | return; |
| 264 | |
| 265 | /* reclaim hardware resources */ |
| 266 | fm10k_iov_suspend(pdev); |
| 267 | |
| 268 | /* drop iov_data from interface */ |
| 269 | kfree_rcu(interface->iov_data, rcu); |
| 270 | interface->iov_data = NULL; |
| 271 | } |
| 272 | |
| 273 | static s32 fm10k_iov_alloc_data(struct pci_dev *pdev, int num_vfs) |
| 274 | { |
| 275 | struct fm10k_intfc *interface = pci_get_drvdata(pdev); |
| 276 | struct fm10k_iov_data *iov_data = interface->iov_data; |
| 277 | struct fm10k_hw *hw = &interface->hw; |
| 278 | size_t size; |
| 279 | int i, err; |
| 280 | |
| 281 | /* return error if iov_data is already populated */ |
| 282 | if (iov_data) |
| 283 | return -EBUSY; |
| 284 | |
| 285 | /* The PF should always be able to assign resources */ |
| 286 | if (!hw->iov.ops.assign_resources) |
| 287 | return -ENODEV; |
| 288 | |
| 289 | /* nothing to do if no VFs are requested */ |
| 290 | if (!num_vfs) |
| 291 | return 0; |
| 292 | |
| 293 | /* allocate memory for VF storage */ |
| 294 | size = offsetof(struct fm10k_iov_data, vf_info[num_vfs]); |
| 295 | iov_data = kzalloc(size, GFP_KERNEL); |
| 296 | if (!iov_data) |
| 297 | return -ENOMEM; |
| 298 | |
| 299 | /* record number of VFs */ |
| 300 | iov_data->num_vfs = num_vfs; |
| 301 | |
| 302 | /* loop through vf_info structures initializing each entry */ |
| 303 | for (i = 0; i < num_vfs; i++) { |
| 304 | struct fm10k_vf_info *vf_info = &iov_data->vf_info[i]; |
| 305 | |
| 306 | /* Record VF VSI value */ |
| 307 | vf_info->vsi = i + 1; |
| 308 | vf_info->vf_idx = i; |
| 309 | |
| 310 | /* initialize mailbox memory */ |
| 311 | err = fm10k_pfvf_mbx_init(hw, &vf_info->mbx, iov_mbx_data, i); |
| 312 | if (err) { |
| 313 | dev_err(&pdev->dev, |
| 314 | "Unable to initialize SR-IOV mailbox\n"); |
| 315 | kfree(iov_data); |
| 316 | return err; |
| 317 | } |
| 318 | } |
| 319 | |
| 320 | /* assign iov_data to interface */ |
| 321 | interface->iov_data = iov_data; |
| 322 | |
| 323 | /* allocate hardware resources for the VFs */ |
| 324 | fm10k_iov_resume(pdev); |
| 325 | |
| 326 | return 0; |
| 327 | } |
| 328 | |
| 329 | void fm10k_iov_disable(struct pci_dev *pdev) |
| 330 | { |
| 331 | if (pci_num_vf(pdev) && pci_vfs_assigned(pdev)) |
| 332 | dev_err(&pdev->dev, |
| 333 | "Cannot disable SR-IOV while VFs are assigned\n"); |
| 334 | else |
| 335 | pci_disable_sriov(pdev); |
| 336 | |
| 337 | fm10k_iov_free_data(pdev); |
| 338 | } |
| 339 | |
| 340 | static void fm10k_disable_aer_comp_abort(struct pci_dev *pdev) |
| 341 | { |
| 342 | u32 err_sev; |
| 343 | int pos; |
| 344 | |
| 345 | pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ERR); |
| 346 | if (!pos) |
| 347 | return; |
| 348 | |
| 349 | pci_read_config_dword(pdev, pos + PCI_ERR_UNCOR_SEVER, &err_sev); |
| 350 | err_sev &= ~PCI_ERR_UNC_COMP_ABORT; |
| 351 | pci_write_config_dword(pdev, pos + PCI_ERR_UNCOR_SEVER, err_sev); |
| 352 | } |
| 353 | |
| 354 | int fm10k_iov_configure(struct pci_dev *pdev, int num_vfs) |
| 355 | { |
| 356 | int current_vfs = pci_num_vf(pdev); |
| 357 | int err = 0; |
| 358 | |
| 359 | if (current_vfs && pci_vfs_assigned(pdev)) { |
| 360 | dev_err(&pdev->dev, |
| 361 | "Cannot modify SR-IOV while VFs are assigned\n"); |
| 362 | num_vfs = current_vfs; |
| 363 | } else { |
| 364 | pci_disable_sriov(pdev); |
| 365 | fm10k_iov_free_data(pdev); |
| 366 | } |
| 367 | |
| 368 | /* allocate resources for the VFs */ |
| 369 | err = fm10k_iov_alloc_data(pdev, num_vfs); |
| 370 | if (err) |
| 371 | return err; |
| 372 | |
| 373 | /* allocate VFs if not already allocated */ |
| 374 | if (num_vfs && (num_vfs != current_vfs)) { |
| 375 | /* Disable completer abort error reporting as |
| 376 | * the VFs can trigger this any time they read a queue |
| 377 | * that they don't own. |
| 378 | */ |
| 379 | fm10k_disable_aer_comp_abort(pdev); |
| 380 | |
| 381 | err = pci_enable_sriov(pdev, num_vfs); |
| 382 | if (err) { |
| 383 | dev_err(&pdev->dev, |
| 384 | "Enable PCI SR-IOV failed: %d\n", err); |
| 385 | return err; |
| 386 | } |
| 387 | } |
| 388 | |
| 389 | return num_vfs; |
| 390 | } |
| 391 | |
| 392 | int fm10k_ndo_set_vf_mac(struct net_device *netdev, int vf_idx, u8 *mac) |
| 393 | { |
| 394 | struct fm10k_intfc *interface = netdev_priv(netdev); |
| 395 | struct fm10k_iov_data *iov_data = interface->iov_data; |
| 396 | struct fm10k_hw *hw = &interface->hw; |
| 397 | struct fm10k_vf_info *vf_info; |
| 398 | |
| 399 | /* verify SR-IOV is active and that vf idx is valid */ |
| 400 | if (!iov_data || vf_idx >= iov_data->num_vfs) |
| 401 | return -EINVAL; |
| 402 | |
| 403 | /* verify MAC addr is valid */ |
| 404 | if (!is_zero_ether_addr(mac) && !is_valid_ether_addr(mac)) |
| 405 | return -EINVAL; |
| 406 | |
| 407 | /* record new MAC address */ |
| 408 | vf_info = &iov_data->vf_info[vf_idx]; |
| 409 | ether_addr_copy(vf_info->mac, mac); |
| 410 | |
| 411 | /* assigning the MAC will send a mailbox message so lock is needed */ |
| 412 | fm10k_mbx_lock(interface); |
| 413 | |
| 414 | /* assign MAC address to VF */ |
| 415 | hw->iov.ops.assign_default_mac_vlan(hw, vf_info); |
| 416 | |
| 417 | fm10k_mbx_unlock(interface); |
| 418 | |
| 419 | return 0; |
| 420 | } |
| 421 | |
| 422 | int fm10k_ndo_set_vf_vlan(struct net_device *netdev, int vf_idx, u16 vid, |
| 423 | u8 qos) |
| 424 | { |
| 425 | struct fm10k_intfc *interface = netdev_priv(netdev); |
| 426 | struct fm10k_iov_data *iov_data = interface->iov_data; |
| 427 | struct fm10k_hw *hw = &interface->hw; |
| 428 | struct fm10k_vf_info *vf_info; |
| 429 | |
| 430 | /* verify SR-IOV is active and that vf idx is valid */ |
| 431 | if (!iov_data || vf_idx >= iov_data->num_vfs) |
| 432 | return -EINVAL; |
| 433 | |
| 434 | /* QOS is unsupported and VLAN IDs accepted range 0-4094 */ |
| 435 | if (qos || (vid > (VLAN_VID_MASK - 1))) |
| 436 | return -EINVAL; |
| 437 | |
| 438 | vf_info = &iov_data->vf_info[vf_idx]; |
| 439 | |
| 440 | /* exit if there is nothing to do */ |
| 441 | if (vf_info->pf_vid == vid) |
| 442 | return 0; |
| 443 | |
| 444 | /* record default VLAN ID for VF */ |
| 445 | vf_info->pf_vid = vid; |
| 446 | |
| 447 | /* assigning the VLAN will send a mailbox message so lock is needed */ |
| 448 | fm10k_mbx_lock(interface); |
| 449 | |
| 450 | /* Clear the VLAN table for the VF */ |
| 451 | hw->mac.ops.update_vlan(hw, FM10K_VLAN_ALL, vf_info->vsi, false); |
| 452 | |
| 453 | /* Update VF assignment and trigger reset */ |
| 454 | hw->iov.ops.assign_default_mac_vlan(hw, vf_info); |
| 455 | |
| 456 | fm10k_mbx_unlock(interface); |
| 457 | |
| 458 | return 0; |
| 459 | } |
| 460 | |
Jeff Kirsher | de44519 | 2015-04-03 13:26:56 -0700 | [diff] [blame] | 461 | int fm10k_ndo_set_vf_bw(struct net_device *netdev, int vf_idx, |
| 462 | int __always_unused unused, int rate) |
Alexander Duyck | 883a9cc | 2014-09-20 19:52:09 -0400 | [diff] [blame] | 463 | { |
| 464 | struct fm10k_intfc *interface = netdev_priv(netdev); |
| 465 | struct fm10k_iov_data *iov_data = interface->iov_data; |
| 466 | struct fm10k_hw *hw = &interface->hw; |
| 467 | |
| 468 | /* verify SR-IOV is active and that vf idx is valid */ |
| 469 | if (!iov_data || vf_idx >= iov_data->num_vfs) |
| 470 | return -EINVAL; |
| 471 | |
| 472 | /* rate limit cannot be less than 10Mbs or greater than link speed */ |
| 473 | if (rate && ((rate < FM10K_VF_TC_MIN) || rate > FM10K_VF_TC_MAX)) |
| 474 | return -EINVAL; |
| 475 | |
| 476 | /* store values */ |
| 477 | iov_data->vf_info[vf_idx].rate = rate; |
| 478 | |
| 479 | /* update hardware configuration */ |
| 480 | hw->iov.ops.configure_tc(hw, vf_idx, rate); |
| 481 | |
| 482 | return 0; |
| 483 | } |
| 484 | |
| 485 | int fm10k_ndo_get_vf_config(struct net_device *netdev, |
| 486 | int vf_idx, struct ifla_vf_info *ivi) |
| 487 | { |
| 488 | struct fm10k_intfc *interface = netdev_priv(netdev); |
| 489 | struct fm10k_iov_data *iov_data = interface->iov_data; |
| 490 | struct fm10k_vf_info *vf_info; |
| 491 | |
| 492 | /* verify SR-IOV is active and that vf idx is valid */ |
| 493 | if (!iov_data || vf_idx >= iov_data->num_vfs) |
| 494 | return -EINVAL; |
| 495 | |
| 496 | vf_info = &iov_data->vf_info[vf_idx]; |
| 497 | |
| 498 | ivi->vf = vf_idx; |
| 499 | ivi->max_tx_rate = vf_info->rate; |
| 500 | ivi->min_tx_rate = 0; |
| 501 | ether_addr_copy(ivi->mac, vf_info->mac); |
| 502 | ivi->vlan = vf_info->pf_vid; |
| 503 | ivi->qos = 0; |
| 504 | |
| 505 | return 0; |
| 506 | } |