Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | * |
| 3 | * Intel Ethernet Controller XL710 Family Linux Driver |
| 4 | * Copyright(c) 2013 Intel Corporation. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify it |
| 7 | * under the terms and conditions of the GNU General Public License, |
| 8 | * version 2, as published by the Free Software Foundation. |
| 9 | * |
| 10 | * This program is distributed in the hope it will be useful, but WITHOUT |
| 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 13 | * more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License along with |
| 16 | * this program; if not, write to the Free Software Foundation, Inc., |
| 17 | * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | * |
| 19 | * The full GNU General Public License is included in this distribution in |
| 20 | * the file called "COPYING". |
| 21 | * |
| 22 | * Contact Information: |
| 23 | * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> |
| 24 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
| 25 | * |
| 26 | ******************************************************************************/ |
| 27 | |
| 28 | #include "i40e_type.h" |
| 29 | #include "i40e_adminq.h" |
| 30 | #include "i40e_prototype.h" |
| 31 | #include "i40e_virtchnl.h" |
| 32 | |
| 33 | /** |
| 34 | * i40e_set_mac_type - Sets MAC type |
| 35 | * @hw: pointer to the HW structure |
| 36 | * |
| 37 | * This function sets the mac type of the adapter based on the |
| 38 | * vendor ID and device ID stored in the hw structure. |
| 39 | **/ |
| 40 | static i40e_status i40e_set_mac_type(struct i40e_hw *hw) |
| 41 | { |
| 42 | i40e_status status = 0; |
| 43 | |
| 44 | if (hw->vendor_id == PCI_VENDOR_ID_INTEL) { |
| 45 | switch (hw->device_id) { |
| 46 | case I40E_SFP_XL710_DEVICE_ID: |
| 47 | case I40E_SFP_X710_DEVICE_ID: |
| 48 | case I40E_QEMU_DEVICE_ID: |
| 49 | case I40E_KX_A_DEVICE_ID: |
| 50 | case I40E_KX_B_DEVICE_ID: |
| 51 | case I40E_KX_C_DEVICE_ID: |
| 52 | case I40E_KX_D_DEVICE_ID: |
| 53 | case I40E_QSFP_A_DEVICE_ID: |
| 54 | case I40E_QSFP_B_DEVICE_ID: |
| 55 | case I40E_QSFP_C_DEVICE_ID: |
| 56 | hw->mac.type = I40E_MAC_XL710; |
| 57 | break; |
| 58 | case I40E_VF_DEVICE_ID: |
| 59 | case I40E_VF_HV_DEVICE_ID: |
| 60 | hw->mac.type = I40E_MAC_VF; |
| 61 | break; |
| 62 | default: |
| 63 | hw->mac.type = I40E_MAC_GENERIC; |
| 64 | break; |
| 65 | } |
| 66 | } else { |
| 67 | status = I40E_ERR_DEVICE_NOT_SUPPORTED; |
| 68 | } |
| 69 | |
| 70 | hw_dbg(hw, "i40e_set_mac_type found mac: %d, returns: %d\n", |
| 71 | hw->mac.type, status); |
| 72 | return status; |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * i40e_debug_aq |
| 77 | * @hw: debug mask related to admin queue |
| 78 | * @cap: pointer to adminq command descriptor |
| 79 | * @buffer: pointer to command buffer |
| 80 | * |
| 81 | * Dumps debug log about adminq command with descriptor contents. |
| 82 | **/ |
| 83 | void i40e_debug_aq(struct i40e_hw *hw, enum i40e_debug_mask mask, void *desc, |
| 84 | void *buffer) |
| 85 | { |
| 86 | struct i40e_aq_desc *aq_desc = (struct i40e_aq_desc *)desc; |
| 87 | u8 *aq_buffer = (u8 *)buffer; |
| 88 | u32 data[4]; |
| 89 | u32 i = 0; |
| 90 | |
| 91 | if ((!(mask & hw->debug_mask)) || (desc == NULL)) |
| 92 | return; |
| 93 | |
| 94 | i40e_debug(hw, mask, |
| 95 | "AQ CMD: opcode 0x%04X, flags 0x%04X, datalen 0x%04X, retval 0x%04X\n", |
| 96 | aq_desc->opcode, aq_desc->flags, aq_desc->datalen, |
| 97 | aq_desc->retval); |
| 98 | i40e_debug(hw, mask, "\tcookie (h,l) 0x%08X 0x%08X\n", |
| 99 | aq_desc->cookie_high, aq_desc->cookie_low); |
| 100 | i40e_debug(hw, mask, "\tparam (0,1) 0x%08X 0x%08X\n", |
| 101 | aq_desc->params.internal.param0, |
| 102 | aq_desc->params.internal.param1); |
| 103 | i40e_debug(hw, mask, "\taddr (h,l) 0x%08X 0x%08X\n", |
| 104 | aq_desc->params.external.addr_high, |
| 105 | aq_desc->params.external.addr_low); |
| 106 | |
| 107 | if ((buffer != NULL) && (aq_desc->datalen != 0)) { |
| 108 | memset(data, 0, sizeof(data)); |
| 109 | i40e_debug(hw, mask, "AQ CMD Buffer:\n"); |
| 110 | for (i = 0; i < le16_to_cpu(aq_desc->datalen); i++) { |
| 111 | data[((i % 16) / 4)] |= |
| 112 | ((u32)aq_buffer[i]) << (8 * (i % 4)); |
| 113 | if ((i % 16) == 15) { |
| 114 | i40e_debug(hw, mask, |
| 115 | "\t0x%04X %08X %08X %08X %08X\n", |
| 116 | i - 15, data[0], data[1], data[2], |
| 117 | data[3]); |
| 118 | memset(data, 0, sizeof(data)); |
| 119 | } |
| 120 | } |
| 121 | if ((i % 16) != 0) |
| 122 | i40e_debug(hw, mask, "\t0x%04X %08X %08X %08X %08X\n", |
| 123 | i - (i % 16), data[0], data[1], data[2], |
| 124 | data[3]); |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | /** |
| 129 | * i40e_init_shared_code - Initialize the shared code |
| 130 | * @hw: pointer to hardware structure |
| 131 | * |
| 132 | * This assigns the MAC type and PHY code and inits the NVM. |
| 133 | * Does not touch the hardware. This function must be called prior to any |
| 134 | * other function in the shared code. The i40e_hw structure should be |
| 135 | * memset to 0 prior to calling this function. The following fields in |
| 136 | * hw structure should be filled in prior to calling this function: |
| 137 | * hw_addr, back, device_id, vendor_id, subsystem_device_id, |
| 138 | * subsystem_vendor_id, and revision_id |
| 139 | **/ |
| 140 | i40e_status i40e_init_shared_code(struct i40e_hw *hw) |
| 141 | { |
| 142 | i40e_status status = 0; |
| 143 | u32 reg; |
| 144 | |
| 145 | hw->phy.get_link_info = true; |
| 146 | |
| 147 | /* Determine port number */ |
| 148 | reg = rd32(hw, I40E_PFGEN_PORTNUM); |
| 149 | reg = ((reg & I40E_PFGEN_PORTNUM_PORT_NUM_MASK) >> |
| 150 | I40E_PFGEN_PORTNUM_PORT_NUM_SHIFT); |
| 151 | hw->port = (u8)reg; |
| 152 | |
| 153 | i40e_set_mac_type(hw); |
| 154 | |
| 155 | switch (hw->mac.type) { |
| 156 | case I40E_MAC_XL710: |
| 157 | break; |
| 158 | default: |
| 159 | return I40E_ERR_DEVICE_NOT_SUPPORTED; |
| 160 | break; |
| 161 | } |
| 162 | |
| 163 | status = i40e_init_nvm(hw); |
| 164 | return status; |
| 165 | } |
| 166 | |
| 167 | /** |
| 168 | * i40e_aq_mac_address_read - Retrieve the MAC addresses |
| 169 | * @hw: pointer to the hw struct |
| 170 | * @flags: a return indicator of what addresses were added to the addr store |
| 171 | * @addrs: the requestor's mac addr store |
| 172 | * @cmd_details: pointer to command details structure or NULL |
| 173 | **/ |
| 174 | static i40e_status i40e_aq_mac_address_read(struct i40e_hw *hw, |
| 175 | u16 *flags, |
| 176 | struct i40e_aqc_mac_address_read_data *addrs, |
| 177 | struct i40e_asq_cmd_details *cmd_details) |
| 178 | { |
| 179 | struct i40e_aq_desc desc; |
| 180 | struct i40e_aqc_mac_address_read *cmd_data = |
| 181 | (struct i40e_aqc_mac_address_read *)&desc.params.raw; |
| 182 | i40e_status status; |
| 183 | |
| 184 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_mac_address_read); |
| 185 | desc.flags |= cpu_to_le16(I40E_AQ_FLAG_BUF); |
| 186 | |
| 187 | status = i40e_asq_send_command(hw, &desc, addrs, |
| 188 | sizeof(*addrs), cmd_details); |
| 189 | *flags = le16_to_cpu(cmd_data->command_flags); |
| 190 | |
| 191 | return status; |
| 192 | } |
| 193 | |
| 194 | /** |
| 195 | * i40e_aq_mac_address_write - Change the MAC addresses |
| 196 | * @hw: pointer to the hw struct |
| 197 | * @flags: indicates which MAC to be written |
| 198 | * @mac_addr: address to write |
| 199 | * @cmd_details: pointer to command details structure or NULL |
| 200 | **/ |
| 201 | i40e_status i40e_aq_mac_address_write(struct i40e_hw *hw, |
| 202 | u16 flags, u8 *mac_addr, |
| 203 | struct i40e_asq_cmd_details *cmd_details) |
| 204 | { |
| 205 | struct i40e_aq_desc desc; |
| 206 | struct i40e_aqc_mac_address_write *cmd_data = |
| 207 | (struct i40e_aqc_mac_address_write *)&desc.params.raw; |
| 208 | i40e_status status; |
| 209 | |
| 210 | i40e_fill_default_direct_cmd_desc(&desc, |
| 211 | i40e_aqc_opc_mac_address_write); |
| 212 | cmd_data->command_flags = cpu_to_le16(flags); |
| 213 | memcpy(&cmd_data->mac_sal, &mac_addr[0], 4); |
| 214 | memcpy(&cmd_data->mac_sah, &mac_addr[4], 2); |
| 215 | |
| 216 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 217 | |
| 218 | return status; |
| 219 | } |
| 220 | |
| 221 | /** |
| 222 | * i40e_get_mac_addr - get MAC address |
| 223 | * @hw: pointer to the HW structure |
| 224 | * @mac_addr: pointer to MAC address |
| 225 | * |
| 226 | * Reads the adapter's MAC address from register |
| 227 | **/ |
| 228 | i40e_status i40e_get_mac_addr(struct i40e_hw *hw, u8 *mac_addr) |
| 229 | { |
| 230 | struct i40e_aqc_mac_address_read_data addrs; |
| 231 | i40e_status status; |
| 232 | u16 flags = 0; |
| 233 | |
| 234 | status = i40e_aq_mac_address_read(hw, &flags, &addrs, NULL); |
| 235 | |
| 236 | if (flags & I40E_AQC_LAN_ADDR_VALID) |
| 237 | memcpy(mac_addr, &addrs.pf_lan_mac, sizeof(addrs.pf_lan_mac)); |
| 238 | |
| 239 | return status; |
| 240 | } |
| 241 | |
| 242 | /** |
| 243 | * i40e_validate_mac_addr - Validate MAC address |
| 244 | * @mac_addr: pointer to MAC address |
| 245 | * |
| 246 | * Tests a MAC address to ensure it is a valid Individual Address |
| 247 | **/ |
| 248 | i40e_status i40e_validate_mac_addr(u8 *mac_addr) |
| 249 | { |
| 250 | i40e_status status = 0; |
| 251 | |
| 252 | /* Make sure it is not a multicast address */ |
| 253 | if (I40E_IS_MULTICAST(mac_addr)) { |
| 254 | hw_dbg(hw, "MAC address is multicast\n"); |
| 255 | status = I40E_ERR_INVALID_MAC_ADDR; |
| 256 | /* Not a broadcast address */ |
| 257 | } else if (I40E_IS_BROADCAST(mac_addr)) { |
| 258 | hw_dbg(hw, "MAC address is broadcast\n"); |
| 259 | status = I40E_ERR_INVALID_MAC_ADDR; |
| 260 | /* Reject the zero address */ |
| 261 | } else if (mac_addr[0] == 0 && mac_addr[1] == 0 && mac_addr[2] == 0 && |
| 262 | mac_addr[3] == 0 && mac_addr[4] == 0 && mac_addr[5] == 0) { |
| 263 | hw_dbg(hw, "MAC address is all zeros\n"); |
| 264 | status = I40E_ERR_INVALID_MAC_ADDR; |
| 265 | } |
| 266 | return status; |
| 267 | } |
| 268 | |
| 269 | /** |
Jesse Brandeburg | be405eb | 2013-11-20 10:02:50 +0000 | [diff] [blame] | 270 | * i40e_get_media_type - Gets media type |
| 271 | * @hw: pointer to the hardware structure |
| 272 | **/ |
| 273 | static enum i40e_media_type i40e_get_media_type(struct i40e_hw *hw) |
| 274 | { |
| 275 | enum i40e_media_type media; |
| 276 | |
| 277 | switch (hw->phy.link_info.phy_type) { |
| 278 | case I40E_PHY_TYPE_10GBASE_SR: |
| 279 | case I40E_PHY_TYPE_10GBASE_LR: |
| 280 | case I40E_PHY_TYPE_40GBASE_SR4: |
| 281 | case I40E_PHY_TYPE_40GBASE_LR4: |
| 282 | media = I40E_MEDIA_TYPE_FIBER; |
| 283 | break; |
| 284 | case I40E_PHY_TYPE_100BASE_TX: |
| 285 | case I40E_PHY_TYPE_1000BASE_T: |
| 286 | case I40E_PHY_TYPE_10GBASE_T: |
| 287 | media = I40E_MEDIA_TYPE_BASET; |
| 288 | break; |
| 289 | case I40E_PHY_TYPE_10GBASE_CR1_CU: |
| 290 | case I40E_PHY_TYPE_40GBASE_CR4_CU: |
| 291 | case I40E_PHY_TYPE_10GBASE_CR1: |
| 292 | case I40E_PHY_TYPE_40GBASE_CR4: |
| 293 | case I40E_PHY_TYPE_10GBASE_SFPP_CU: |
| 294 | media = I40E_MEDIA_TYPE_DA; |
| 295 | break; |
| 296 | case I40E_PHY_TYPE_1000BASE_KX: |
| 297 | case I40E_PHY_TYPE_10GBASE_KX4: |
| 298 | case I40E_PHY_TYPE_10GBASE_KR: |
| 299 | case I40E_PHY_TYPE_40GBASE_KR4: |
| 300 | media = I40E_MEDIA_TYPE_BACKPLANE; |
| 301 | break; |
| 302 | case I40E_PHY_TYPE_SGMII: |
| 303 | case I40E_PHY_TYPE_XAUI: |
| 304 | case I40E_PHY_TYPE_XFI: |
| 305 | case I40E_PHY_TYPE_XLAUI: |
| 306 | case I40E_PHY_TYPE_XLPPI: |
| 307 | default: |
| 308 | media = I40E_MEDIA_TYPE_UNKNOWN; |
| 309 | break; |
| 310 | } |
| 311 | |
| 312 | return media; |
| 313 | } |
| 314 | |
Jesse Brandeburg | 7134f9c | 2013-11-26 08:56:05 +0000 | [diff] [blame] | 315 | #define I40E_PF_RESET_WAIT_COUNT_A0 200 |
| 316 | #define I40E_PF_RESET_WAIT_COUNT 10 |
Jesse Brandeburg | be405eb | 2013-11-20 10:02:50 +0000 | [diff] [blame] | 317 | /** |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 318 | * i40e_pf_reset - Reset the PF |
| 319 | * @hw: pointer to the hardware structure |
| 320 | * |
| 321 | * Assuming someone else has triggered a global reset, |
| 322 | * assure the global reset is complete and then reset the PF |
| 323 | **/ |
| 324 | i40e_status i40e_pf_reset(struct i40e_hw *hw) |
| 325 | { |
Jesse Brandeburg | 7134f9c | 2013-11-26 08:56:05 +0000 | [diff] [blame] | 326 | u32 cnt = 0; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 327 | u32 reg = 0; |
| 328 | u32 grst_del; |
| 329 | |
| 330 | /* Poll for Global Reset steady state in case of recent GRST. |
| 331 | * The grst delay value is in 100ms units, and we'll wait a |
| 332 | * couple counts longer to be sure we don't just miss the end. |
| 333 | */ |
| 334 | grst_del = rd32(hw, I40E_GLGEN_RSTCTL) & I40E_GLGEN_RSTCTL_GRSTDEL_MASK |
| 335 | >> I40E_GLGEN_RSTCTL_GRSTDEL_SHIFT; |
Jesse Brandeburg | 7134f9c | 2013-11-26 08:56:05 +0000 | [diff] [blame] | 336 | for (cnt = 0; cnt < grst_del + 2; cnt++) { |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 337 | reg = rd32(hw, I40E_GLGEN_RSTAT); |
| 338 | if (!(reg & I40E_GLGEN_RSTAT_DEVSTATE_MASK)) |
| 339 | break; |
| 340 | msleep(100); |
| 341 | } |
| 342 | if (reg & I40E_GLGEN_RSTAT_DEVSTATE_MASK) { |
| 343 | hw_dbg(hw, "Global reset polling failed to complete.\n"); |
| 344 | return I40E_ERR_RESET_FAILED; |
| 345 | } |
| 346 | |
| 347 | /* Determine the PF number based on the PCI fn */ |
Christopher Pau | 71bd4b8 | 2013-11-16 10:00:33 +0000 | [diff] [blame] | 348 | reg = rd32(hw, I40E_GLPCI_CAPSUP); |
| 349 | if (reg & I40E_GLPCI_CAPSUP_ARI_EN_MASK) |
| 350 | hw->pf_id = (u8)((hw->bus.device << 3) | hw->bus.func); |
| 351 | else |
| 352 | hw->pf_id = (u8)hw->bus.func; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 353 | |
| 354 | /* If there was a Global Reset in progress when we got here, |
| 355 | * we don't need to do the PF Reset |
| 356 | */ |
Jesse Brandeburg | 7134f9c | 2013-11-26 08:56:05 +0000 | [diff] [blame] | 357 | if (!cnt) { |
| 358 | if (hw->revision_id == 0) |
| 359 | cnt = I40E_PF_RESET_WAIT_COUNT_A0; |
| 360 | else |
| 361 | cnt = I40E_PF_RESET_WAIT_COUNT; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 362 | reg = rd32(hw, I40E_PFGEN_CTRL); |
| 363 | wr32(hw, I40E_PFGEN_CTRL, |
| 364 | (reg | I40E_PFGEN_CTRL_PFSWR_MASK)); |
Jesse Brandeburg | 7134f9c | 2013-11-26 08:56:05 +0000 | [diff] [blame] | 365 | for (; cnt; cnt--) { |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 366 | reg = rd32(hw, I40E_PFGEN_CTRL); |
| 367 | if (!(reg & I40E_PFGEN_CTRL_PFSWR_MASK)) |
| 368 | break; |
| 369 | usleep_range(1000, 2000); |
| 370 | } |
| 371 | if (reg & I40E_PFGEN_CTRL_PFSWR_MASK) { |
| 372 | hw_dbg(hw, "PF reset polling failed to complete.\n"); |
| 373 | return I40E_ERR_RESET_FAILED; |
| 374 | } |
| 375 | } |
| 376 | |
| 377 | i40e_clear_pxe_mode(hw); |
| 378 | return 0; |
| 379 | } |
| 380 | |
| 381 | /** |
| 382 | * i40e_clear_pxe_mode - clear pxe operations mode |
| 383 | * @hw: pointer to the hw struct |
| 384 | * |
| 385 | * Make sure all PXE mode settings are cleared, including things |
| 386 | * like descriptor fetch/write-back mode. |
| 387 | **/ |
| 388 | void i40e_clear_pxe_mode(struct i40e_hw *hw) |
| 389 | { |
| 390 | u32 reg; |
| 391 | |
| 392 | /* Clear single descriptor fetch/write-back mode */ |
| 393 | reg = rd32(hw, I40E_GLLAN_RCTL_0); |
Jesse Brandeburg | 7134f9c | 2013-11-26 08:56:05 +0000 | [diff] [blame] | 394 | |
| 395 | if (hw->revision_id == 0) { |
| 396 | /* As a work around clear PXE_MODE instead of setting it */ |
| 397 | wr32(hw, I40E_GLLAN_RCTL_0, (reg & (~I40E_GLLAN_RCTL_0_PXE_MODE_MASK))); |
| 398 | } else { |
| 399 | wr32(hw, I40E_GLLAN_RCTL_0, (reg | I40E_GLLAN_RCTL_0_PXE_MODE_MASK)); |
| 400 | } |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 401 | } |
| 402 | |
| 403 | /** |
Jesse Brandeburg | 0556a9e | 2013-11-28 06:39:33 +0000 | [diff] [blame^] | 404 | * i40e_led_is_mine - helper to find matching led |
| 405 | * @hw: pointer to the hw struct |
| 406 | * @idx: index into GPIO registers |
| 407 | * |
| 408 | * returns: 0 if no match, otherwise the value of the GPIO_CTL register |
| 409 | */ |
| 410 | static u32 i40e_led_is_mine(struct i40e_hw *hw, int idx) |
| 411 | { |
| 412 | u32 gpio_val = 0; |
| 413 | u32 port; |
| 414 | |
| 415 | if (!hw->func_caps.led[idx]) |
| 416 | return 0; |
| 417 | |
| 418 | gpio_val = rd32(hw, I40E_GLGEN_GPIO_CTL(idx)); |
| 419 | port = (gpio_val & I40E_GLGEN_GPIO_CTL_PRT_NUM_MASK) >> |
| 420 | I40E_GLGEN_GPIO_CTL_PRT_NUM_SHIFT; |
| 421 | |
| 422 | /* if PRT_NUM_NA is 1 then this LED is not port specific, OR |
| 423 | * if it is not our port then ignore |
| 424 | */ |
| 425 | if ((gpio_val & I40E_GLGEN_GPIO_CTL_PRT_NUM_NA_MASK) || |
| 426 | (port != hw->port)) |
| 427 | return 0; |
| 428 | |
| 429 | return gpio_val; |
| 430 | } |
| 431 | |
| 432 | #define I40E_LED0 22 |
| 433 | #define I40E_LINK_ACTIVITY 0xC |
| 434 | |
| 435 | /** |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 436 | * i40e_led_get - return current on/off mode |
| 437 | * @hw: pointer to the hw struct |
| 438 | * |
| 439 | * The value returned is the 'mode' field as defined in the |
| 440 | * GPIO register definitions: 0x0 = off, 0xf = on, and other |
| 441 | * values are variations of possible behaviors relating to |
| 442 | * blink, link, and wire. |
| 443 | **/ |
| 444 | u32 i40e_led_get(struct i40e_hw *hw) |
| 445 | { |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 446 | u32 mode = 0; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 447 | int i; |
| 448 | |
Jesse Brandeburg | 0556a9e | 2013-11-28 06:39:33 +0000 | [diff] [blame^] | 449 | /* as per the documentation GPIO 22-29 are the LED |
| 450 | * GPIO pins named LED0..LED7 |
| 451 | */ |
| 452 | for (i = I40E_LED0; i <= I40E_GLGEN_GPIO_CTL_MAX_INDEX; i++) { |
| 453 | u32 gpio_val = i40e_led_is_mine(hw, i); |
| 454 | |
| 455 | if (!gpio_val) |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 456 | continue; |
| 457 | |
Jesse Brandeburg | 0556a9e | 2013-11-28 06:39:33 +0000 | [diff] [blame^] | 458 | mode = (gpio_val & I40E_GLGEN_GPIO_CTL_LED_MODE_MASK) >> |
| 459 | I40E_GLGEN_GPIO_CTL_LED_MODE_SHIFT; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 460 | break; |
| 461 | } |
| 462 | |
| 463 | return mode; |
| 464 | } |
| 465 | |
| 466 | /** |
| 467 | * i40e_led_set - set new on/off mode |
| 468 | * @hw: pointer to the hw struct |
Jesse Brandeburg | 0556a9e | 2013-11-28 06:39:33 +0000 | [diff] [blame^] | 469 | * @mode: 0=off, 0xf=on (else see manual for mode details) |
| 470 | * @blink: true if the LED should blink when on, false if steady |
| 471 | * |
| 472 | * if this function is used to turn on the blink it should |
| 473 | * be used to disable the blink when restoring the original state. |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 474 | **/ |
Jesse Brandeburg | 0556a9e | 2013-11-28 06:39:33 +0000 | [diff] [blame^] | 475 | void i40e_led_set(struct i40e_hw *hw, u32 mode, bool blink) |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 476 | { |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 477 | int i; |
| 478 | |
Jesse Brandeburg | 0556a9e | 2013-11-28 06:39:33 +0000 | [diff] [blame^] | 479 | if (mode & 0xfffffff0) |
| 480 | hw_dbg(hw, "invalid mode passed in %X\n", mode); |
| 481 | |
| 482 | /* as per the documentation GPIO 22-29 are the LED |
| 483 | * GPIO pins named LED0..LED7 |
| 484 | */ |
| 485 | for (i = I40E_LED0; i <= I40E_GLGEN_GPIO_CTL_MAX_INDEX; i++) { |
| 486 | u32 gpio_val = i40e_led_is_mine(hw, i); |
| 487 | |
| 488 | if (!gpio_val) |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 489 | continue; |
| 490 | |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 491 | gpio_val &= ~I40E_GLGEN_GPIO_CTL_LED_MODE_MASK; |
Jesse Brandeburg | 0556a9e | 2013-11-28 06:39:33 +0000 | [diff] [blame^] | 492 | /* this & is a bit of paranoia, but serves as a range check */ |
| 493 | gpio_val |= ((mode << I40E_GLGEN_GPIO_CTL_LED_MODE_SHIFT) & |
| 494 | I40E_GLGEN_GPIO_CTL_LED_MODE_MASK); |
| 495 | |
| 496 | if (mode == I40E_LINK_ACTIVITY) |
| 497 | blink = false; |
| 498 | |
| 499 | gpio_val |= (blink ? 1 : 0) << |
| 500 | I40E_GLGEN_GPIO_CTL_LED_BLINK_SHIFT; |
| 501 | |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 502 | wr32(hw, I40E_GLGEN_GPIO_CTL(i), gpio_val); |
Jesse Brandeburg | 0556a9e | 2013-11-28 06:39:33 +0000 | [diff] [blame^] | 503 | break; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 504 | } |
| 505 | } |
| 506 | |
| 507 | /* Admin command wrappers */ |
| 508 | /** |
| 509 | * i40e_aq_queue_shutdown |
| 510 | * @hw: pointer to the hw struct |
| 511 | * @unloading: is the driver unloading itself |
| 512 | * |
| 513 | * Tell the Firmware that we're shutting down the AdminQ and whether |
| 514 | * or not the driver is unloading as well. |
| 515 | **/ |
| 516 | i40e_status i40e_aq_queue_shutdown(struct i40e_hw *hw, |
| 517 | bool unloading) |
| 518 | { |
| 519 | struct i40e_aq_desc desc; |
| 520 | struct i40e_aqc_queue_shutdown *cmd = |
| 521 | (struct i40e_aqc_queue_shutdown *)&desc.params.raw; |
| 522 | i40e_status status; |
| 523 | |
| 524 | i40e_fill_default_direct_cmd_desc(&desc, |
| 525 | i40e_aqc_opc_queue_shutdown); |
| 526 | |
| 527 | if (unloading) |
| 528 | cmd->driver_unloading = cpu_to_le32(I40E_AQ_DRIVER_UNLOADING); |
| 529 | status = i40e_asq_send_command(hw, &desc, NULL, 0, NULL); |
| 530 | |
| 531 | return status; |
| 532 | } |
| 533 | |
| 534 | /** |
| 535 | * i40e_aq_set_link_restart_an |
| 536 | * @hw: pointer to the hw struct |
| 537 | * @cmd_details: pointer to command details structure or NULL |
| 538 | * |
| 539 | * Sets up the link and restarts the Auto-Negotiation over the link. |
| 540 | **/ |
| 541 | i40e_status i40e_aq_set_link_restart_an(struct i40e_hw *hw, |
| 542 | struct i40e_asq_cmd_details *cmd_details) |
| 543 | { |
| 544 | struct i40e_aq_desc desc; |
| 545 | struct i40e_aqc_set_link_restart_an *cmd = |
| 546 | (struct i40e_aqc_set_link_restart_an *)&desc.params.raw; |
| 547 | i40e_status status; |
| 548 | |
| 549 | i40e_fill_default_direct_cmd_desc(&desc, |
| 550 | i40e_aqc_opc_set_link_restart_an); |
| 551 | |
| 552 | cmd->command = I40E_AQ_PHY_RESTART_AN; |
| 553 | |
| 554 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 555 | |
| 556 | return status; |
| 557 | } |
| 558 | |
| 559 | /** |
| 560 | * i40e_aq_get_link_info |
| 561 | * @hw: pointer to the hw struct |
| 562 | * @enable_lse: enable/disable LinkStatusEvent reporting |
| 563 | * @link: pointer to link status structure - optional |
| 564 | * @cmd_details: pointer to command details structure or NULL |
| 565 | * |
| 566 | * Returns the link status of the adapter. |
| 567 | **/ |
| 568 | i40e_status i40e_aq_get_link_info(struct i40e_hw *hw, |
| 569 | bool enable_lse, struct i40e_link_status *link, |
| 570 | struct i40e_asq_cmd_details *cmd_details) |
| 571 | { |
| 572 | struct i40e_aq_desc desc; |
| 573 | struct i40e_aqc_get_link_status *resp = |
| 574 | (struct i40e_aqc_get_link_status *)&desc.params.raw; |
| 575 | struct i40e_link_status *hw_link_info = &hw->phy.link_info; |
| 576 | i40e_status status; |
| 577 | u16 command_flags; |
| 578 | |
| 579 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_get_link_status); |
| 580 | |
| 581 | if (enable_lse) |
| 582 | command_flags = I40E_AQ_LSE_ENABLE; |
| 583 | else |
| 584 | command_flags = I40E_AQ_LSE_DISABLE; |
| 585 | resp->command_flags = cpu_to_le16(command_flags); |
| 586 | |
| 587 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 588 | |
| 589 | if (status) |
| 590 | goto aq_get_link_info_exit; |
| 591 | |
| 592 | /* save off old link status information */ |
| 593 | memcpy(&hw->phy.link_info_old, hw_link_info, |
| 594 | sizeof(struct i40e_link_status)); |
| 595 | |
| 596 | /* update link status */ |
| 597 | hw_link_info->phy_type = (enum i40e_aq_phy_type)resp->phy_type; |
Jesse Brandeburg | be405eb | 2013-11-20 10:02:50 +0000 | [diff] [blame] | 598 | hw->phy.media_type = i40e_get_media_type(hw); |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 599 | hw_link_info->link_speed = (enum i40e_aq_link_speed)resp->link_speed; |
| 600 | hw_link_info->link_info = resp->link_info; |
| 601 | hw_link_info->an_info = resp->an_info; |
| 602 | hw_link_info->ext_info = resp->ext_info; |
Kamil Krawczyk | 639dc37 | 2013-11-20 10:03:07 +0000 | [diff] [blame] | 603 | hw_link_info->loopback = resp->loopback; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 604 | |
| 605 | if (resp->command_flags & cpu_to_le16(I40E_AQ_LSE_ENABLE)) |
| 606 | hw_link_info->lse_enable = true; |
| 607 | else |
| 608 | hw_link_info->lse_enable = false; |
| 609 | |
| 610 | /* save link status information */ |
| 611 | if (link) |
Jesse Brandeburg | d7595a2 | 2013-09-13 08:23:22 +0000 | [diff] [blame] | 612 | *link = *hw_link_info; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 613 | |
| 614 | /* flag cleared so helper functions don't call AQ again */ |
| 615 | hw->phy.get_link_info = false; |
| 616 | |
| 617 | aq_get_link_info_exit: |
| 618 | return status; |
| 619 | } |
| 620 | |
| 621 | /** |
| 622 | * i40e_aq_add_vsi |
| 623 | * @hw: pointer to the hw struct |
| 624 | * @vsi: pointer to a vsi context struct |
| 625 | * @cmd_details: pointer to command details structure or NULL |
| 626 | * |
| 627 | * Add a VSI context to the hardware. |
| 628 | **/ |
| 629 | i40e_status i40e_aq_add_vsi(struct i40e_hw *hw, |
| 630 | struct i40e_vsi_context *vsi_ctx, |
| 631 | struct i40e_asq_cmd_details *cmd_details) |
| 632 | { |
| 633 | struct i40e_aq_desc desc; |
| 634 | struct i40e_aqc_add_get_update_vsi *cmd = |
| 635 | (struct i40e_aqc_add_get_update_vsi *)&desc.params.raw; |
| 636 | struct i40e_aqc_add_get_update_vsi_completion *resp = |
| 637 | (struct i40e_aqc_add_get_update_vsi_completion *) |
| 638 | &desc.params.raw; |
| 639 | i40e_status status; |
| 640 | |
| 641 | i40e_fill_default_direct_cmd_desc(&desc, |
| 642 | i40e_aqc_opc_add_vsi); |
| 643 | |
| 644 | cmd->uplink_seid = cpu_to_le16(vsi_ctx->uplink_seid); |
| 645 | cmd->connection_type = vsi_ctx->connection_type; |
| 646 | cmd->vf_id = vsi_ctx->vf_num; |
| 647 | cmd->vsi_flags = cpu_to_le16(vsi_ctx->flags); |
| 648 | |
| 649 | desc.flags |= cpu_to_le16((u16)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD)); |
| 650 | if (sizeof(vsi_ctx->info) > I40E_AQ_LARGE_BUF) |
| 651 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB); |
| 652 | |
| 653 | status = i40e_asq_send_command(hw, &desc, &vsi_ctx->info, |
| 654 | sizeof(vsi_ctx->info), cmd_details); |
| 655 | |
| 656 | if (status) |
| 657 | goto aq_add_vsi_exit; |
| 658 | |
| 659 | vsi_ctx->seid = le16_to_cpu(resp->seid); |
| 660 | vsi_ctx->vsi_number = le16_to_cpu(resp->vsi_number); |
| 661 | vsi_ctx->vsis_allocated = le16_to_cpu(resp->vsi_used); |
| 662 | vsi_ctx->vsis_unallocated = le16_to_cpu(resp->vsi_free); |
| 663 | |
| 664 | aq_add_vsi_exit: |
| 665 | return status; |
| 666 | } |
| 667 | |
| 668 | /** |
| 669 | * i40e_aq_set_vsi_unicast_promiscuous |
| 670 | * @hw: pointer to the hw struct |
| 671 | * @seid: vsi number |
| 672 | * @set: set unicast promiscuous enable/disable |
| 673 | * @cmd_details: pointer to command details structure or NULL |
| 674 | **/ |
| 675 | i40e_status i40e_aq_set_vsi_unicast_promiscuous(struct i40e_hw *hw, |
| 676 | u16 seid, bool set, struct i40e_asq_cmd_details *cmd_details) |
| 677 | { |
| 678 | struct i40e_aq_desc desc; |
| 679 | struct i40e_aqc_set_vsi_promiscuous_modes *cmd = |
| 680 | (struct i40e_aqc_set_vsi_promiscuous_modes *)&desc.params.raw; |
| 681 | i40e_status status; |
| 682 | u16 flags = 0; |
| 683 | |
| 684 | i40e_fill_default_direct_cmd_desc(&desc, |
| 685 | i40e_aqc_opc_set_vsi_promiscuous_modes); |
| 686 | |
| 687 | if (set) |
| 688 | flags |= I40E_AQC_SET_VSI_PROMISC_UNICAST; |
| 689 | |
| 690 | cmd->promiscuous_flags = cpu_to_le16(flags); |
| 691 | |
| 692 | cmd->valid_flags = cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_UNICAST); |
| 693 | |
| 694 | cmd->seid = cpu_to_le16(seid); |
| 695 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 696 | |
| 697 | return status; |
| 698 | } |
| 699 | |
| 700 | /** |
| 701 | * i40e_aq_set_vsi_multicast_promiscuous |
| 702 | * @hw: pointer to the hw struct |
| 703 | * @seid: vsi number |
| 704 | * @set: set multicast promiscuous enable/disable |
| 705 | * @cmd_details: pointer to command details structure or NULL |
| 706 | **/ |
| 707 | i40e_status i40e_aq_set_vsi_multicast_promiscuous(struct i40e_hw *hw, |
| 708 | u16 seid, bool set, struct i40e_asq_cmd_details *cmd_details) |
| 709 | { |
| 710 | struct i40e_aq_desc desc; |
| 711 | struct i40e_aqc_set_vsi_promiscuous_modes *cmd = |
| 712 | (struct i40e_aqc_set_vsi_promiscuous_modes *)&desc.params.raw; |
| 713 | i40e_status status; |
| 714 | u16 flags = 0; |
| 715 | |
| 716 | i40e_fill_default_direct_cmd_desc(&desc, |
| 717 | i40e_aqc_opc_set_vsi_promiscuous_modes); |
| 718 | |
| 719 | if (set) |
| 720 | flags |= I40E_AQC_SET_VSI_PROMISC_MULTICAST; |
| 721 | |
| 722 | cmd->promiscuous_flags = cpu_to_le16(flags); |
| 723 | |
| 724 | cmd->valid_flags = cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_MULTICAST); |
| 725 | |
| 726 | cmd->seid = cpu_to_le16(seid); |
| 727 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 728 | |
| 729 | return status; |
| 730 | } |
| 731 | |
| 732 | /** |
| 733 | * i40e_aq_set_vsi_broadcast |
| 734 | * @hw: pointer to the hw struct |
| 735 | * @seid: vsi number |
| 736 | * @set_filter: true to set filter, false to clear filter |
| 737 | * @cmd_details: pointer to command details structure or NULL |
| 738 | * |
| 739 | * Set or clear the broadcast promiscuous flag (filter) for a given VSI. |
| 740 | **/ |
| 741 | i40e_status i40e_aq_set_vsi_broadcast(struct i40e_hw *hw, |
| 742 | u16 seid, bool set_filter, |
| 743 | struct i40e_asq_cmd_details *cmd_details) |
| 744 | { |
| 745 | struct i40e_aq_desc desc; |
| 746 | struct i40e_aqc_set_vsi_promiscuous_modes *cmd = |
| 747 | (struct i40e_aqc_set_vsi_promiscuous_modes *)&desc.params.raw; |
| 748 | i40e_status status; |
| 749 | |
| 750 | i40e_fill_default_direct_cmd_desc(&desc, |
| 751 | i40e_aqc_opc_set_vsi_promiscuous_modes); |
| 752 | |
| 753 | if (set_filter) |
| 754 | cmd->promiscuous_flags |
| 755 | |= cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_BROADCAST); |
| 756 | else |
| 757 | cmd->promiscuous_flags |
| 758 | &= cpu_to_le16(~I40E_AQC_SET_VSI_PROMISC_BROADCAST); |
| 759 | |
| 760 | cmd->valid_flags = cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_BROADCAST); |
| 761 | cmd->seid = cpu_to_le16(seid); |
| 762 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 763 | |
| 764 | return status; |
| 765 | } |
| 766 | |
| 767 | /** |
| 768 | * i40e_get_vsi_params - get VSI configuration info |
| 769 | * @hw: pointer to the hw struct |
| 770 | * @vsi: pointer to a vsi context struct |
| 771 | * @cmd_details: pointer to command details structure or NULL |
| 772 | **/ |
| 773 | i40e_status i40e_aq_get_vsi_params(struct i40e_hw *hw, |
| 774 | struct i40e_vsi_context *vsi_ctx, |
| 775 | struct i40e_asq_cmd_details *cmd_details) |
| 776 | { |
| 777 | struct i40e_aq_desc desc; |
| 778 | struct i40e_aqc_switch_seid *cmd = |
| 779 | (struct i40e_aqc_switch_seid *)&desc.params.raw; |
| 780 | struct i40e_aqc_add_get_update_vsi_completion *resp = |
| 781 | (struct i40e_aqc_add_get_update_vsi_completion *) |
| 782 | &desc.params.raw; |
| 783 | i40e_status status; |
| 784 | |
| 785 | i40e_fill_default_direct_cmd_desc(&desc, |
| 786 | i40e_aqc_opc_get_vsi_parameters); |
| 787 | |
| 788 | cmd->seid = cpu_to_le16(vsi_ctx->seid); |
| 789 | |
| 790 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF); |
| 791 | if (sizeof(vsi_ctx->info) > I40E_AQ_LARGE_BUF) |
| 792 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB); |
| 793 | |
| 794 | status = i40e_asq_send_command(hw, &desc, &vsi_ctx->info, |
| 795 | sizeof(vsi_ctx->info), NULL); |
| 796 | |
| 797 | if (status) |
| 798 | goto aq_get_vsi_params_exit; |
| 799 | |
| 800 | vsi_ctx->seid = le16_to_cpu(resp->seid); |
| 801 | vsi_ctx->vsi_number = le16_to_cpu(resp->vsi_number); |
| 802 | vsi_ctx->vsis_allocated = le16_to_cpu(resp->vsi_used); |
| 803 | vsi_ctx->vsis_unallocated = le16_to_cpu(resp->vsi_free); |
| 804 | |
| 805 | aq_get_vsi_params_exit: |
| 806 | return status; |
| 807 | } |
| 808 | |
| 809 | /** |
| 810 | * i40e_aq_update_vsi_params |
| 811 | * @hw: pointer to the hw struct |
| 812 | * @vsi: pointer to a vsi context struct |
| 813 | * @cmd_details: pointer to command details structure or NULL |
| 814 | * |
| 815 | * Update a VSI context. |
| 816 | **/ |
| 817 | i40e_status i40e_aq_update_vsi_params(struct i40e_hw *hw, |
| 818 | struct i40e_vsi_context *vsi_ctx, |
| 819 | struct i40e_asq_cmd_details *cmd_details) |
| 820 | { |
| 821 | struct i40e_aq_desc desc; |
| 822 | struct i40e_aqc_switch_seid *cmd = |
| 823 | (struct i40e_aqc_switch_seid *)&desc.params.raw; |
| 824 | i40e_status status; |
| 825 | |
| 826 | i40e_fill_default_direct_cmd_desc(&desc, |
| 827 | i40e_aqc_opc_update_vsi_parameters); |
| 828 | cmd->seid = cpu_to_le16(vsi_ctx->seid); |
| 829 | |
| 830 | desc.flags |= cpu_to_le16((u16)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD)); |
| 831 | if (sizeof(vsi_ctx->info) > I40E_AQ_LARGE_BUF) |
| 832 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB); |
| 833 | |
| 834 | status = i40e_asq_send_command(hw, &desc, &vsi_ctx->info, |
| 835 | sizeof(vsi_ctx->info), cmd_details); |
| 836 | |
| 837 | return status; |
| 838 | } |
| 839 | |
| 840 | /** |
| 841 | * i40e_aq_get_switch_config |
| 842 | * @hw: pointer to the hardware structure |
| 843 | * @buf: pointer to the result buffer |
| 844 | * @buf_size: length of input buffer |
| 845 | * @start_seid: seid to start for the report, 0 == beginning |
| 846 | * @cmd_details: pointer to command details structure or NULL |
| 847 | * |
| 848 | * Fill the buf with switch configuration returned from AdminQ command |
| 849 | **/ |
| 850 | i40e_status i40e_aq_get_switch_config(struct i40e_hw *hw, |
| 851 | struct i40e_aqc_get_switch_config_resp *buf, |
| 852 | u16 buf_size, u16 *start_seid, |
| 853 | struct i40e_asq_cmd_details *cmd_details) |
| 854 | { |
| 855 | struct i40e_aq_desc desc; |
| 856 | struct i40e_aqc_switch_seid *scfg = |
| 857 | (struct i40e_aqc_switch_seid *)&desc.params.raw; |
| 858 | i40e_status status; |
| 859 | |
| 860 | i40e_fill_default_direct_cmd_desc(&desc, |
| 861 | i40e_aqc_opc_get_switch_config); |
| 862 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF); |
| 863 | if (buf_size > I40E_AQ_LARGE_BUF) |
| 864 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB); |
| 865 | scfg->seid = cpu_to_le16(*start_seid); |
| 866 | |
| 867 | status = i40e_asq_send_command(hw, &desc, buf, buf_size, cmd_details); |
| 868 | *start_seid = le16_to_cpu(scfg->seid); |
| 869 | |
| 870 | return status; |
| 871 | } |
| 872 | |
| 873 | /** |
| 874 | * i40e_aq_get_firmware_version |
| 875 | * @hw: pointer to the hw struct |
| 876 | * @fw_major_version: firmware major version |
| 877 | * @fw_minor_version: firmware minor version |
| 878 | * @api_major_version: major queue version |
| 879 | * @api_minor_version: minor queue version |
| 880 | * @cmd_details: pointer to command details structure or NULL |
| 881 | * |
| 882 | * Get the firmware version from the admin queue commands |
| 883 | **/ |
| 884 | i40e_status i40e_aq_get_firmware_version(struct i40e_hw *hw, |
| 885 | u16 *fw_major_version, u16 *fw_minor_version, |
| 886 | u16 *api_major_version, u16 *api_minor_version, |
| 887 | struct i40e_asq_cmd_details *cmd_details) |
| 888 | { |
| 889 | struct i40e_aq_desc desc; |
| 890 | struct i40e_aqc_get_version *resp = |
| 891 | (struct i40e_aqc_get_version *)&desc.params.raw; |
| 892 | i40e_status status; |
| 893 | |
| 894 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_get_version); |
| 895 | |
| 896 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 897 | |
| 898 | if (!status) { |
| 899 | if (fw_major_version != NULL) |
| 900 | *fw_major_version = le16_to_cpu(resp->fw_major); |
| 901 | if (fw_minor_version != NULL) |
| 902 | *fw_minor_version = le16_to_cpu(resp->fw_minor); |
| 903 | if (api_major_version != NULL) |
| 904 | *api_major_version = le16_to_cpu(resp->api_major); |
| 905 | if (api_minor_version != NULL) |
| 906 | *api_minor_version = le16_to_cpu(resp->api_minor); |
| 907 | } |
| 908 | |
| 909 | return status; |
| 910 | } |
| 911 | |
| 912 | /** |
| 913 | * i40e_aq_send_driver_version |
| 914 | * @hw: pointer to the hw struct |
| 915 | * @event: driver event: driver ok, start or stop |
| 916 | * @dv: driver's major, minor version |
| 917 | * @cmd_details: pointer to command details structure or NULL |
| 918 | * |
| 919 | * Send the driver version to the firmware |
| 920 | **/ |
| 921 | i40e_status i40e_aq_send_driver_version(struct i40e_hw *hw, |
| 922 | struct i40e_driver_version *dv, |
| 923 | struct i40e_asq_cmd_details *cmd_details) |
| 924 | { |
| 925 | struct i40e_aq_desc desc; |
| 926 | struct i40e_aqc_driver_version *cmd = |
| 927 | (struct i40e_aqc_driver_version *)&desc.params.raw; |
| 928 | i40e_status status; |
| 929 | |
| 930 | if (dv == NULL) |
| 931 | return I40E_ERR_PARAM; |
| 932 | |
| 933 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_driver_version); |
| 934 | |
| 935 | desc.flags |= cpu_to_le16(I40E_AQ_FLAG_SI); |
| 936 | cmd->driver_major_ver = dv->major_version; |
| 937 | cmd->driver_minor_ver = dv->minor_version; |
| 938 | cmd->driver_build_ver = dv->build_version; |
| 939 | cmd->driver_subbuild_ver = dv->subbuild_version; |
| 940 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 941 | |
| 942 | return status; |
| 943 | } |
| 944 | |
| 945 | /** |
| 946 | * i40e_get_link_status - get status of the HW network link |
| 947 | * @hw: pointer to the hw struct |
| 948 | * |
| 949 | * Returns true if link is up, false if link is down. |
| 950 | * |
| 951 | * Side effect: LinkStatusEvent reporting becomes enabled |
| 952 | **/ |
| 953 | bool i40e_get_link_status(struct i40e_hw *hw) |
| 954 | { |
| 955 | i40e_status status = 0; |
| 956 | bool link_status = false; |
| 957 | |
| 958 | if (hw->phy.get_link_info) { |
| 959 | status = i40e_aq_get_link_info(hw, true, NULL, NULL); |
| 960 | |
| 961 | if (status) |
| 962 | goto i40e_get_link_status_exit; |
| 963 | } |
| 964 | |
| 965 | link_status = hw->phy.link_info.link_info & I40E_AQ_LINK_UP; |
| 966 | |
| 967 | i40e_get_link_status_exit: |
| 968 | return link_status; |
| 969 | } |
| 970 | |
| 971 | /** |
| 972 | * i40e_aq_add_veb - Insert a VEB between the VSI and the MAC |
| 973 | * @hw: pointer to the hw struct |
| 974 | * @uplink_seid: the MAC or other gizmo SEID |
| 975 | * @downlink_seid: the VSI SEID |
| 976 | * @enabled_tc: bitmap of TCs to be enabled |
| 977 | * @default_port: true for default port VSI, false for control port |
Kevin Scott | e1c51b95 | 2013-11-20 10:02:51 +0000 | [diff] [blame] | 978 | * @enable_l2_filtering: true to add L2 filter table rules to regular forwarding rules for cloud support |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 979 | * @veb_seid: pointer to where to put the resulting VEB SEID |
| 980 | * @cmd_details: pointer to command details structure or NULL |
| 981 | * |
| 982 | * This asks the FW to add a VEB between the uplink and downlink |
| 983 | * elements. If the uplink SEID is 0, this will be a floating VEB. |
| 984 | **/ |
| 985 | i40e_status i40e_aq_add_veb(struct i40e_hw *hw, u16 uplink_seid, |
| 986 | u16 downlink_seid, u8 enabled_tc, |
Kevin Scott | e1c51b95 | 2013-11-20 10:02:51 +0000 | [diff] [blame] | 987 | bool default_port, bool enable_l2_filtering, |
| 988 | u16 *veb_seid, |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 989 | struct i40e_asq_cmd_details *cmd_details) |
| 990 | { |
| 991 | struct i40e_aq_desc desc; |
| 992 | struct i40e_aqc_add_veb *cmd = |
| 993 | (struct i40e_aqc_add_veb *)&desc.params.raw; |
| 994 | struct i40e_aqc_add_veb_completion *resp = |
| 995 | (struct i40e_aqc_add_veb_completion *)&desc.params.raw; |
| 996 | i40e_status status; |
| 997 | u16 veb_flags = 0; |
| 998 | |
| 999 | /* SEIDs need to either both be set or both be 0 for floating VEB */ |
| 1000 | if (!!uplink_seid != !!downlink_seid) |
| 1001 | return I40E_ERR_PARAM; |
| 1002 | |
| 1003 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_add_veb); |
| 1004 | |
| 1005 | cmd->uplink_seid = cpu_to_le16(uplink_seid); |
| 1006 | cmd->downlink_seid = cpu_to_le16(downlink_seid); |
| 1007 | cmd->enable_tcs = enabled_tc; |
| 1008 | if (!uplink_seid) |
| 1009 | veb_flags |= I40E_AQC_ADD_VEB_FLOATING; |
| 1010 | if (default_port) |
| 1011 | veb_flags |= I40E_AQC_ADD_VEB_PORT_TYPE_DEFAULT; |
| 1012 | else |
| 1013 | veb_flags |= I40E_AQC_ADD_VEB_PORT_TYPE_DATA; |
Kevin Scott | e1c51b95 | 2013-11-20 10:02:51 +0000 | [diff] [blame] | 1014 | |
| 1015 | if (enable_l2_filtering) |
| 1016 | veb_flags |= I40E_AQC_ADD_VEB_ENABLE_L2_FILTER; |
| 1017 | |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1018 | cmd->veb_flags = cpu_to_le16(veb_flags); |
| 1019 | |
| 1020 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 1021 | |
| 1022 | if (!status && veb_seid) |
| 1023 | *veb_seid = le16_to_cpu(resp->veb_seid); |
| 1024 | |
| 1025 | return status; |
| 1026 | } |
| 1027 | |
| 1028 | /** |
| 1029 | * i40e_aq_get_veb_parameters - Retrieve VEB parameters |
| 1030 | * @hw: pointer to the hw struct |
| 1031 | * @veb_seid: the SEID of the VEB to query |
| 1032 | * @switch_id: the uplink switch id |
| 1033 | * @floating_veb: set to true if the VEB is floating |
| 1034 | * @statistic_index: index of the stats counter block for this VEB |
| 1035 | * @vebs_used: number of VEB's used by function |
| 1036 | * @vebs_unallocated: total VEB's not reserved by any function |
| 1037 | * @cmd_details: pointer to command details structure or NULL |
| 1038 | * |
| 1039 | * This retrieves the parameters for a particular VEB, specified by |
| 1040 | * uplink_seid, and returns them to the caller. |
| 1041 | **/ |
| 1042 | i40e_status i40e_aq_get_veb_parameters(struct i40e_hw *hw, |
| 1043 | u16 veb_seid, u16 *switch_id, |
| 1044 | bool *floating, u16 *statistic_index, |
| 1045 | u16 *vebs_used, u16 *vebs_free, |
| 1046 | struct i40e_asq_cmd_details *cmd_details) |
| 1047 | { |
| 1048 | struct i40e_aq_desc desc; |
| 1049 | struct i40e_aqc_get_veb_parameters_completion *cmd_resp = |
| 1050 | (struct i40e_aqc_get_veb_parameters_completion *) |
| 1051 | &desc.params.raw; |
| 1052 | i40e_status status; |
| 1053 | |
| 1054 | if (veb_seid == 0) |
| 1055 | return I40E_ERR_PARAM; |
| 1056 | |
| 1057 | i40e_fill_default_direct_cmd_desc(&desc, |
| 1058 | i40e_aqc_opc_get_veb_parameters); |
| 1059 | cmd_resp->seid = cpu_to_le16(veb_seid); |
| 1060 | |
| 1061 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 1062 | if (status) |
| 1063 | goto get_veb_exit; |
| 1064 | |
| 1065 | if (switch_id) |
| 1066 | *switch_id = le16_to_cpu(cmd_resp->switch_id); |
| 1067 | if (statistic_index) |
| 1068 | *statistic_index = le16_to_cpu(cmd_resp->statistic_index); |
| 1069 | if (vebs_used) |
| 1070 | *vebs_used = le16_to_cpu(cmd_resp->vebs_used); |
| 1071 | if (vebs_free) |
| 1072 | *vebs_free = le16_to_cpu(cmd_resp->vebs_free); |
| 1073 | if (floating) { |
| 1074 | u16 flags = le16_to_cpu(cmd_resp->veb_flags); |
| 1075 | if (flags & I40E_AQC_ADD_VEB_FLOATING) |
| 1076 | *floating = true; |
| 1077 | else |
| 1078 | *floating = false; |
| 1079 | } |
| 1080 | |
| 1081 | get_veb_exit: |
| 1082 | return status; |
| 1083 | } |
| 1084 | |
| 1085 | /** |
| 1086 | * i40e_aq_add_macvlan |
| 1087 | * @hw: pointer to the hw struct |
| 1088 | * @seid: VSI for the mac address |
| 1089 | * @mv_list: list of macvlans to be added |
| 1090 | * @count: length of the list |
| 1091 | * @cmd_details: pointer to command details structure or NULL |
| 1092 | * |
| 1093 | * Add MAC/VLAN addresses to the HW filtering |
| 1094 | **/ |
| 1095 | i40e_status i40e_aq_add_macvlan(struct i40e_hw *hw, u16 seid, |
| 1096 | struct i40e_aqc_add_macvlan_element_data *mv_list, |
| 1097 | u16 count, struct i40e_asq_cmd_details *cmd_details) |
| 1098 | { |
| 1099 | struct i40e_aq_desc desc; |
| 1100 | struct i40e_aqc_macvlan *cmd = |
| 1101 | (struct i40e_aqc_macvlan *)&desc.params.raw; |
| 1102 | i40e_status status; |
| 1103 | u16 buf_size; |
| 1104 | |
| 1105 | if (count == 0 || !mv_list || !hw) |
| 1106 | return I40E_ERR_PARAM; |
| 1107 | |
| 1108 | buf_size = count * sizeof(struct i40e_aqc_add_macvlan_element_data); |
| 1109 | |
| 1110 | /* prep the rest of the request */ |
| 1111 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_add_macvlan); |
| 1112 | cmd->num_addresses = cpu_to_le16(count); |
| 1113 | cmd->seid[0] = cpu_to_le16(I40E_AQC_MACVLAN_CMD_SEID_VALID | seid); |
| 1114 | cmd->seid[1] = 0; |
| 1115 | cmd->seid[2] = 0; |
| 1116 | |
| 1117 | desc.flags |= cpu_to_le16((u16)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD)); |
| 1118 | if (buf_size > I40E_AQ_LARGE_BUF) |
| 1119 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB); |
| 1120 | |
| 1121 | status = i40e_asq_send_command(hw, &desc, mv_list, buf_size, |
| 1122 | cmd_details); |
| 1123 | |
| 1124 | return status; |
| 1125 | } |
| 1126 | |
| 1127 | /** |
| 1128 | * i40e_aq_remove_macvlan |
| 1129 | * @hw: pointer to the hw struct |
| 1130 | * @seid: VSI for the mac address |
| 1131 | * @mv_list: list of macvlans to be removed |
| 1132 | * @count: length of the list |
| 1133 | * @cmd_details: pointer to command details structure or NULL |
| 1134 | * |
| 1135 | * Remove MAC/VLAN addresses from the HW filtering |
| 1136 | **/ |
| 1137 | i40e_status i40e_aq_remove_macvlan(struct i40e_hw *hw, u16 seid, |
| 1138 | struct i40e_aqc_remove_macvlan_element_data *mv_list, |
| 1139 | u16 count, struct i40e_asq_cmd_details *cmd_details) |
| 1140 | { |
| 1141 | struct i40e_aq_desc desc; |
| 1142 | struct i40e_aqc_macvlan *cmd = |
| 1143 | (struct i40e_aqc_macvlan *)&desc.params.raw; |
| 1144 | i40e_status status; |
| 1145 | u16 buf_size; |
| 1146 | |
| 1147 | if (count == 0 || !mv_list || !hw) |
| 1148 | return I40E_ERR_PARAM; |
| 1149 | |
| 1150 | buf_size = count * sizeof(struct i40e_aqc_remove_macvlan_element_data); |
| 1151 | |
| 1152 | /* prep the rest of the request */ |
| 1153 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_remove_macvlan); |
| 1154 | cmd->num_addresses = cpu_to_le16(count); |
| 1155 | cmd->seid[0] = cpu_to_le16(I40E_AQC_MACVLAN_CMD_SEID_VALID | seid); |
| 1156 | cmd->seid[1] = 0; |
| 1157 | cmd->seid[2] = 0; |
| 1158 | |
| 1159 | desc.flags |= cpu_to_le16((u16)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD)); |
| 1160 | if (buf_size > I40E_AQ_LARGE_BUF) |
| 1161 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB); |
| 1162 | |
| 1163 | status = i40e_asq_send_command(hw, &desc, mv_list, buf_size, |
| 1164 | cmd_details); |
| 1165 | |
| 1166 | return status; |
| 1167 | } |
| 1168 | |
| 1169 | /** |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1170 | * i40e_aq_send_msg_to_vf |
| 1171 | * @hw: pointer to the hardware structure |
| 1172 | * @vfid: vf id to send msg |
| 1173 | * @msg: pointer to the msg buffer |
| 1174 | * @msglen: msg length |
| 1175 | * @cmd_details: pointer to command details |
| 1176 | * |
| 1177 | * send msg to vf |
| 1178 | **/ |
| 1179 | i40e_status i40e_aq_send_msg_to_vf(struct i40e_hw *hw, u16 vfid, |
| 1180 | u32 v_opcode, u32 v_retval, u8 *msg, u16 msglen, |
| 1181 | struct i40e_asq_cmd_details *cmd_details) |
| 1182 | { |
| 1183 | struct i40e_aq_desc desc; |
| 1184 | struct i40e_aqc_pf_vf_message *cmd = |
| 1185 | (struct i40e_aqc_pf_vf_message *)&desc.params.raw; |
| 1186 | i40e_status status; |
| 1187 | |
| 1188 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_send_msg_to_vf); |
| 1189 | cmd->id = cpu_to_le32(vfid); |
| 1190 | desc.cookie_high = cpu_to_le32(v_opcode); |
| 1191 | desc.cookie_low = cpu_to_le32(v_retval); |
| 1192 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_SI); |
| 1193 | if (msglen) { |
| 1194 | desc.flags |= cpu_to_le16((u16)(I40E_AQ_FLAG_BUF | |
| 1195 | I40E_AQ_FLAG_RD)); |
| 1196 | if (msglen > I40E_AQ_LARGE_BUF) |
| 1197 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB); |
| 1198 | desc.datalen = cpu_to_le16(msglen); |
| 1199 | } |
| 1200 | status = i40e_asq_send_command(hw, &desc, msg, msglen, cmd_details); |
| 1201 | |
| 1202 | return status; |
| 1203 | } |
| 1204 | |
| 1205 | /** |
| 1206 | * i40e_aq_set_hmc_resource_profile |
| 1207 | * @hw: pointer to the hw struct |
| 1208 | * @profile: type of profile the HMC is to be set as |
| 1209 | * @pe_vf_enabled_count: the number of PE enabled VFs the system has |
| 1210 | * @cmd_details: pointer to command details structure or NULL |
| 1211 | * |
| 1212 | * set the HMC profile of the device. |
| 1213 | **/ |
| 1214 | i40e_status i40e_aq_set_hmc_resource_profile(struct i40e_hw *hw, |
| 1215 | enum i40e_aq_hmc_profile profile, |
| 1216 | u8 pe_vf_enabled_count, |
| 1217 | struct i40e_asq_cmd_details *cmd_details) |
| 1218 | { |
| 1219 | struct i40e_aq_desc desc; |
| 1220 | struct i40e_aq_get_set_hmc_resource_profile *cmd = |
| 1221 | (struct i40e_aq_get_set_hmc_resource_profile *)&desc.params.raw; |
| 1222 | i40e_status status; |
| 1223 | |
| 1224 | i40e_fill_default_direct_cmd_desc(&desc, |
| 1225 | i40e_aqc_opc_set_hmc_resource_profile); |
| 1226 | |
| 1227 | cmd->pm_profile = (u8)profile; |
| 1228 | cmd->pe_vf_enabled = pe_vf_enabled_count; |
| 1229 | |
| 1230 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 1231 | |
| 1232 | return status; |
| 1233 | } |
| 1234 | |
| 1235 | /** |
| 1236 | * i40e_aq_request_resource |
| 1237 | * @hw: pointer to the hw struct |
| 1238 | * @resource: resource id |
| 1239 | * @access: access type |
| 1240 | * @sdp_number: resource number |
| 1241 | * @timeout: the maximum time in ms that the driver may hold the resource |
| 1242 | * @cmd_details: pointer to command details structure or NULL |
| 1243 | * |
| 1244 | * requests common resource using the admin queue commands |
| 1245 | **/ |
| 1246 | i40e_status i40e_aq_request_resource(struct i40e_hw *hw, |
| 1247 | enum i40e_aq_resources_ids resource, |
| 1248 | enum i40e_aq_resource_access_type access, |
| 1249 | u8 sdp_number, u64 *timeout, |
| 1250 | struct i40e_asq_cmd_details *cmd_details) |
| 1251 | { |
| 1252 | struct i40e_aq_desc desc; |
| 1253 | struct i40e_aqc_request_resource *cmd_resp = |
| 1254 | (struct i40e_aqc_request_resource *)&desc.params.raw; |
| 1255 | i40e_status status; |
| 1256 | |
| 1257 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_request_resource); |
| 1258 | |
| 1259 | cmd_resp->resource_id = cpu_to_le16(resource); |
| 1260 | cmd_resp->access_type = cpu_to_le16(access); |
| 1261 | cmd_resp->resource_number = cpu_to_le32(sdp_number); |
| 1262 | |
| 1263 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 1264 | /* The completion specifies the maximum time in ms that the driver |
| 1265 | * may hold the resource in the Timeout field. |
| 1266 | * If the resource is held by someone else, the command completes with |
| 1267 | * busy return value and the timeout field indicates the maximum time |
| 1268 | * the current owner of the resource has to free it. |
| 1269 | */ |
| 1270 | if (!status || hw->aq.asq_last_status == I40E_AQ_RC_EBUSY) |
| 1271 | *timeout = le32_to_cpu(cmd_resp->timeout); |
| 1272 | |
| 1273 | return status; |
| 1274 | } |
| 1275 | |
| 1276 | /** |
| 1277 | * i40e_aq_release_resource |
| 1278 | * @hw: pointer to the hw struct |
| 1279 | * @resource: resource id |
| 1280 | * @sdp_number: resource number |
| 1281 | * @cmd_details: pointer to command details structure or NULL |
| 1282 | * |
| 1283 | * release common resource using the admin queue commands |
| 1284 | **/ |
| 1285 | i40e_status i40e_aq_release_resource(struct i40e_hw *hw, |
| 1286 | enum i40e_aq_resources_ids resource, |
| 1287 | u8 sdp_number, |
| 1288 | struct i40e_asq_cmd_details *cmd_details) |
| 1289 | { |
| 1290 | struct i40e_aq_desc desc; |
| 1291 | struct i40e_aqc_request_resource *cmd = |
| 1292 | (struct i40e_aqc_request_resource *)&desc.params.raw; |
| 1293 | i40e_status status; |
| 1294 | |
| 1295 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_release_resource); |
| 1296 | |
| 1297 | cmd->resource_id = cpu_to_le16(resource); |
| 1298 | cmd->resource_number = cpu_to_le32(sdp_number); |
| 1299 | |
| 1300 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 1301 | |
| 1302 | return status; |
| 1303 | } |
| 1304 | |
| 1305 | /** |
| 1306 | * i40e_aq_read_nvm |
| 1307 | * @hw: pointer to the hw struct |
| 1308 | * @module_pointer: module pointer location in words from the NVM beginning |
| 1309 | * @offset: byte offset from the module beginning |
| 1310 | * @length: length of the section to be read (in bytes from the offset) |
| 1311 | * @data: command buffer (size [bytes] = length) |
| 1312 | * @last_command: tells if this is the last command in a series |
| 1313 | * @cmd_details: pointer to command details structure or NULL |
| 1314 | * |
| 1315 | * Read the NVM using the admin queue commands |
| 1316 | **/ |
| 1317 | i40e_status i40e_aq_read_nvm(struct i40e_hw *hw, u8 module_pointer, |
| 1318 | u32 offset, u16 length, void *data, |
| 1319 | bool last_command, |
| 1320 | struct i40e_asq_cmd_details *cmd_details) |
| 1321 | { |
| 1322 | struct i40e_aq_desc desc; |
| 1323 | struct i40e_aqc_nvm_update *cmd = |
| 1324 | (struct i40e_aqc_nvm_update *)&desc.params.raw; |
| 1325 | i40e_status status; |
| 1326 | |
| 1327 | /* In offset the highest byte must be zeroed. */ |
| 1328 | if (offset & 0xFF000000) { |
| 1329 | status = I40E_ERR_PARAM; |
| 1330 | goto i40e_aq_read_nvm_exit; |
| 1331 | } |
| 1332 | |
| 1333 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_nvm_read); |
| 1334 | |
| 1335 | /* If this is the last command in a series, set the proper flag. */ |
| 1336 | if (last_command) |
| 1337 | cmd->command_flags |= I40E_AQ_NVM_LAST_CMD; |
| 1338 | cmd->module_pointer = module_pointer; |
| 1339 | cmd->offset = cpu_to_le32(offset); |
| 1340 | cmd->length = cpu_to_le16(length); |
| 1341 | |
| 1342 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF); |
| 1343 | if (length > I40E_AQ_LARGE_BUF) |
| 1344 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB); |
| 1345 | |
| 1346 | status = i40e_asq_send_command(hw, &desc, data, length, cmd_details); |
| 1347 | |
| 1348 | i40e_aq_read_nvm_exit: |
| 1349 | return status; |
| 1350 | } |
| 1351 | |
| 1352 | #define I40E_DEV_FUNC_CAP_SWITCH_MODE 0x01 |
| 1353 | #define I40E_DEV_FUNC_CAP_MGMT_MODE 0x02 |
| 1354 | #define I40E_DEV_FUNC_CAP_NPAR 0x03 |
| 1355 | #define I40E_DEV_FUNC_CAP_OS2BMC 0x04 |
| 1356 | #define I40E_DEV_FUNC_CAP_VALID_FUNC 0x05 |
| 1357 | #define I40E_DEV_FUNC_CAP_SRIOV_1_1 0x12 |
| 1358 | #define I40E_DEV_FUNC_CAP_VF 0x13 |
| 1359 | #define I40E_DEV_FUNC_CAP_VMDQ 0x14 |
| 1360 | #define I40E_DEV_FUNC_CAP_802_1_QBG 0x15 |
| 1361 | #define I40E_DEV_FUNC_CAP_802_1_QBH 0x16 |
| 1362 | #define I40E_DEV_FUNC_CAP_VSI 0x17 |
| 1363 | #define I40E_DEV_FUNC_CAP_DCB 0x18 |
| 1364 | #define I40E_DEV_FUNC_CAP_FCOE 0x21 |
| 1365 | #define I40E_DEV_FUNC_CAP_RSS 0x40 |
| 1366 | #define I40E_DEV_FUNC_CAP_RX_QUEUES 0x41 |
| 1367 | #define I40E_DEV_FUNC_CAP_TX_QUEUES 0x42 |
| 1368 | #define I40E_DEV_FUNC_CAP_MSIX 0x43 |
| 1369 | #define I40E_DEV_FUNC_CAP_MSIX_VF 0x44 |
| 1370 | #define I40E_DEV_FUNC_CAP_FLOW_DIRECTOR 0x45 |
| 1371 | #define I40E_DEV_FUNC_CAP_IEEE_1588 0x46 |
| 1372 | #define I40E_DEV_FUNC_CAP_MFP_MODE_1 0xF1 |
| 1373 | #define I40E_DEV_FUNC_CAP_CEM 0xF2 |
| 1374 | #define I40E_DEV_FUNC_CAP_IWARP 0x51 |
| 1375 | #define I40E_DEV_FUNC_CAP_LED 0x61 |
| 1376 | #define I40E_DEV_FUNC_CAP_SDP 0x62 |
| 1377 | #define I40E_DEV_FUNC_CAP_MDIO 0x63 |
| 1378 | |
| 1379 | /** |
| 1380 | * i40e_parse_discover_capabilities |
| 1381 | * @hw: pointer to the hw struct |
| 1382 | * @buff: pointer to a buffer containing device/function capability records |
| 1383 | * @cap_count: number of capability records in the list |
| 1384 | * @list_type_opc: type of capabilities list to parse |
| 1385 | * |
| 1386 | * Parse the device/function capabilities list. |
| 1387 | **/ |
| 1388 | static void i40e_parse_discover_capabilities(struct i40e_hw *hw, void *buff, |
| 1389 | u32 cap_count, |
| 1390 | enum i40e_admin_queue_opc list_type_opc) |
| 1391 | { |
| 1392 | struct i40e_aqc_list_capabilities_element_resp *cap; |
| 1393 | u32 number, logical_id, phys_id; |
| 1394 | struct i40e_hw_capabilities *p; |
| 1395 | u32 reg_val; |
| 1396 | u32 i = 0; |
| 1397 | u16 id; |
| 1398 | |
| 1399 | cap = (struct i40e_aqc_list_capabilities_element_resp *) buff; |
| 1400 | |
| 1401 | if (list_type_opc == i40e_aqc_opc_list_dev_capabilities) |
| 1402 | p = (struct i40e_hw_capabilities *)&hw->dev_caps; |
| 1403 | else if (list_type_opc == i40e_aqc_opc_list_func_capabilities) |
| 1404 | p = (struct i40e_hw_capabilities *)&hw->func_caps; |
| 1405 | else |
| 1406 | return; |
| 1407 | |
| 1408 | for (i = 0; i < cap_count; i++, cap++) { |
| 1409 | id = le16_to_cpu(cap->id); |
| 1410 | number = le32_to_cpu(cap->number); |
| 1411 | logical_id = le32_to_cpu(cap->logical_id); |
| 1412 | phys_id = le32_to_cpu(cap->phys_id); |
| 1413 | |
| 1414 | switch (id) { |
| 1415 | case I40E_DEV_FUNC_CAP_SWITCH_MODE: |
| 1416 | p->switch_mode = number; |
| 1417 | break; |
| 1418 | case I40E_DEV_FUNC_CAP_MGMT_MODE: |
| 1419 | p->management_mode = number; |
| 1420 | break; |
| 1421 | case I40E_DEV_FUNC_CAP_NPAR: |
| 1422 | p->npar_enable = number; |
| 1423 | break; |
| 1424 | case I40E_DEV_FUNC_CAP_OS2BMC: |
| 1425 | p->os2bmc = number; |
| 1426 | break; |
| 1427 | case I40E_DEV_FUNC_CAP_VALID_FUNC: |
| 1428 | p->valid_functions = number; |
| 1429 | break; |
| 1430 | case I40E_DEV_FUNC_CAP_SRIOV_1_1: |
| 1431 | if (number == 1) |
| 1432 | p->sr_iov_1_1 = true; |
| 1433 | break; |
| 1434 | case I40E_DEV_FUNC_CAP_VF: |
| 1435 | p->num_vfs = number; |
| 1436 | p->vf_base_id = logical_id; |
| 1437 | break; |
| 1438 | case I40E_DEV_FUNC_CAP_VMDQ: |
| 1439 | if (number == 1) |
| 1440 | p->vmdq = true; |
| 1441 | break; |
| 1442 | case I40E_DEV_FUNC_CAP_802_1_QBG: |
| 1443 | if (number == 1) |
| 1444 | p->evb_802_1_qbg = true; |
| 1445 | break; |
| 1446 | case I40E_DEV_FUNC_CAP_802_1_QBH: |
| 1447 | if (number == 1) |
| 1448 | p->evb_802_1_qbh = true; |
| 1449 | break; |
| 1450 | case I40E_DEV_FUNC_CAP_VSI: |
| 1451 | p->num_vsis = number; |
| 1452 | break; |
| 1453 | case I40E_DEV_FUNC_CAP_DCB: |
| 1454 | if (number == 1) { |
| 1455 | p->dcb = true; |
| 1456 | p->enabled_tcmap = logical_id; |
| 1457 | p->maxtc = phys_id; |
| 1458 | } |
| 1459 | break; |
| 1460 | case I40E_DEV_FUNC_CAP_FCOE: |
| 1461 | if (number == 1) |
| 1462 | p->fcoe = true; |
| 1463 | break; |
| 1464 | case I40E_DEV_FUNC_CAP_RSS: |
| 1465 | p->rss = true; |
| 1466 | reg_val = rd32(hw, I40E_PFQF_CTL_0); |
| 1467 | if (reg_val & I40E_PFQF_CTL_0_HASHLUTSIZE_MASK) |
| 1468 | p->rss_table_size = number; |
| 1469 | else |
| 1470 | p->rss_table_size = 128; |
| 1471 | p->rss_table_entry_width = logical_id; |
| 1472 | break; |
| 1473 | case I40E_DEV_FUNC_CAP_RX_QUEUES: |
| 1474 | p->num_rx_qp = number; |
| 1475 | p->base_queue = phys_id; |
| 1476 | break; |
| 1477 | case I40E_DEV_FUNC_CAP_TX_QUEUES: |
| 1478 | p->num_tx_qp = number; |
| 1479 | p->base_queue = phys_id; |
| 1480 | break; |
| 1481 | case I40E_DEV_FUNC_CAP_MSIX: |
| 1482 | p->num_msix_vectors = number; |
| 1483 | break; |
| 1484 | case I40E_DEV_FUNC_CAP_MSIX_VF: |
| 1485 | p->num_msix_vectors_vf = number; |
| 1486 | break; |
| 1487 | case I40E_DEV_FUNC_CAP_MFP_MODE_1: |
| 1488 | if (number == 1) |
| 1489 | p->mfp_mode_1 = true; |
| 1490 | break; |
| 1491 | case I40E_DEV_FUNC_CAP_CEM: |
| 1492 | if (number == 1) |
| 1493 | p->mgmt_cem = true; |
| 1494 | break; |
| 1495 | case I40E_DEV_FUNC_CAP_IWARP: |
| 1496 | if (number == 1) |
| 1497 | p->iwarp = true; |
| 1498 | break; |
| 1499 | case I40E_DEV_FUNC_CAP_LED: |
| 1500 | if (phys_id < I40E_HW_CAP_MAX_GPIO) |
| 1501 | p->led[phys_id] = true; |
| 1502 | break; |
| 1503 | case I40E_DEV_FUNC_CAP_SDP: |
| 1504 | if (phys_id < I40E_HW_CAP_MAX_GPIO) |
| 1505 | p->sdp[phys_id] = true; |
| 1506 | break; |
| 1507 | case I40E_DEV_FUNC_CAP_MDIO: |
| 1508 | if (number == 1) { |
| 1509 | p->mdio_port_num = phys_id; |
| 1510 | p->mdio_port_mode = logical_id; |
| 1511 | } |
| 1512 | break; |
| 1513 | case I40E_DEV_FUNC_CAP_IEEE_1588: |
| 1514 | if (number == 1) |
| 1515 | p->ieee_1588 = true; |
| 1516 | break; |
| 1517 | case I40E_DEV_FUNC_CAP_FLOW_DIRECTOR: |
| 1518 | p->fd = true; |
| 1519 | p->fd_filters_guaranteed = number; |
| 1520 | p->fd_filters_best_effort = logical_id; |
| 1521 | break; |
| 1522 | default: |
| 1523 | break; |
| 1524 | } |
| 1525 | } |
| 1526 | |
| 1527 | /* additional HW specific goodies that might |
| 1528 | * someday be HW version specific |
| 1529 | */ |
| 1530 | p->rx_buf_chain_len = I40E_MAX_CHAINED_RX_BUFFERS; |
| 1531 | } |
| 1532 | |
| 1533 | /** |
| 1534 | * i40e_aq_discover_capabilities |
| 1535 | * @hw: pointer to the hw struct |
| 1536 | * @buff: a virtual buffer to hold the capabilities |
| 1537 | * @buff_size: Size of the virtual buffer |
| 1538 | * @data_size: Size of the returned data, or buff size needed if AQ err==ENOMEM |
| 1539 | * @list_type_opc: capabilities type to discover - pass in the command opcode |
| 1540 | * @cmd_details: pointer to command details structure or NULL |
| 1541 | * |
| 1542 | * Get the device capabilities descriptions from the firmware |
| 1543 | **/ |
| 1544 | i40e_status i40e_aq_discover_capabilities(struct i40e_hw *hw, |
| 1545 | void *buff, u16 buff_size, u16 *data_size, |
| 1546 | enum i40e_admin_queue_opc list_type_opc, |
| 1547 | struct i40e_asq_cmd_details *cmd_details) |
| 1548 | { |
| 1549 | struct i40e_aqc_list_capabilites *cmd; |
| 1550 | i40e_status status = 0; |
| 1551 | struct i40e_aq_desc desc; |
| 1552 | |
| 1553 | cmd = (struct i40e_aqc_list_capabilites *)&desc.params.raw; |
| 1554 | |
| 1555 | if (list_type_opc != i40e_aqc_opc_list_func_capabilities && |
| 1556 | list_type_opc != i40e_aqc_opc_list_dev_capabilities) { |
| 1557 | status = I40E_ERR_PARAM; |
| 1558 | goto exit; |
| 1559 | } |
| 1560 | |
| 1561 | i40e_fill_default_direct_cmd_desc(&desc, list_type_opc); |
| 1562 | |
| 1563 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF); |
| 1564 | if (buff_size > I40E_AQ_LARGE_BUF) |
| 1565 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB); |
| 1566 | |
| 1567 | status = i40e_asq_send_command(hw, &desc, buff, buff_size, cmd_details); |
| 1568 | *data_size = le16_to_cpu(desc.datalen); |
| 1569 | |
| 1570 | if (status) |
| 1571 | goto exit; |
| 1572 | |
| 1573 | i40e_parse_discover_capabilities(hw, buff, le32_to_cpu(cmd->count), |
| 1574 | list_type_opc); |
| 1575 | |
| 1576 | exit: |
| 1577 | return status; |
| 1578 | } |
| 1579 | |
| 1580 | /** |
| 1581 | * i40e_aq_get_lldp_mib |
| 1582 | * @hw: pointer to the hw struct |
| 1583 | * @bridge_type: type of bridge requested |
| 1584 | * @mib_type: Local, Remote or both Local and Remote MIBs |
| 1585 | * @buff: pointer to a user supplied buffer to store the MIB block |
| 1586 | * @buff_size: size of the buffer (in bytes) |
| 1587 | * @local_len : length of the returned Local LLDP MIB |
| 1588 | * @remote_len: length of the returned Remote LLDP MIB |
| 1589 | * @cmd_details: pointer to command details structure or NULL |
| 1590 | * |
| 1591 | * Requests the complete LLDP MIB (entire packet). |
| 1592 | **/ |
| 1593 | i40e_status i40e_aq_get_lldp_mib(struct i40e_hw *hw, u8 bridge_type, |
| 1594 | u8 mib_type, void *buff, u16 buff_size, |
| 1595 | u16 *local_len, u16 *remote_len, |
| 1596 | struct i40e_asq_cmd_details *cmd_details) |
| 1597 | { |
| 1598 | struct i40e_aq_desc desc; |
| 1599 | struct i40e_aqc_lldp_get_mib *cmd = |
| 1600 | (struct i40e_aqc_lldp_get_mib *)&desc.params.raw; |
| 1601 | struct i40e_aqc_lldp_get_mib *resp = |
| 1602 | (struct i40e_aqc_lldp_get_mib *)&desc.params.raw; |
| 1603 | i40e_status status; |
| 1604 | |
| 1605 | if (buff_size == 0 || !buff) |
| 1606 | return I40E_ERR_PARAM; |
| 1607 | |
| 1608 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_lldp_get_mib); |
| 1609 | /* Indirect Command */ |
| 1610 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF); |
| 1611 | |
| 1612 | cmd->type = mib_type & I40E_AQ_LLDP_MIB_TYPE_MASK; |
| 1613 | cmd->type |= ((bridge_type << I40E_AQ_LLDP_BRIDGE_TYPE_SHIFT) & |
| 1614 | I40E_AQ_LLDP_BRIDGE_TYPE_MASK); |
| 1615 | |
| 1616 | desc.datalen = cpu_to_le16(buff_size); |
| 1617 | |
| 1618 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF); |
| 1619 | if (buff_size > I40E_AQ_LARGE_BUF) |
| 1620 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB); |
| 1621 | |
| 1622 | status = i40e_asq_send_command(hw, &desc, buff, buff_size, cmd_details); |
| 1623 | if (!status) { |
| 1624 | if (local_len != NULL) |
| 1625 | *local_len = le16_to_cpu(resp->local_len); |
| 1626 | if (remote_len != NULL) |
| 1627 | *remote_len = le16_to_cpu(resp->remote_len); |
| 1628 | } |
| 1629 | |
| 1630 | return status; |
| 1631 | } |
| 1632 | |
| 1633 | /** |
| 1634 | * i40e_aq_cfg_lldp_mib_change_event |
| 1635 | * @hw: pointer to the hw struct |
| 1636 | * @enable_update: Enable or Disable event posting |
| 1637 | * @cmd_details: pointer to command details structure or NULL |
| 1638 | * |
| 1639 | * Enable or Disable posting of an event on ARQ when LLDP MIB |
| 1640 | * associated with the interface changes |
| 1641 | **/ |
| 1642 | i40e_status i40e_aq_cfg_lldp_mib_change_event(struct i40e_hw *hw, |
| 1643 | bool enable_update, |
| 1644 | struct i40e_asq_cmd_details *cmd_details) |
| 1645 | { |
| 1646 | struct i40e_aq_desc desc; |
| 1647 | struct i40e_aqc_lldp_update_mib *cmd = |
| 1648 | (struct i40e_aqc_lldp_update_mib *)&desc.params.raw; |
| 1649 | i40e_status status; |
| 1650 | |
| 1651 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_lldp_update_mib); |
| 1652 | |
| 1653 | if (!enable_update) |
| 1654 | cmd->command |= I40E_AQ_LLDP_MIB_UPDATE_DISABLE; |
| 1655 | |
| 1656 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 1657 | |
| 1658 | return status; |
| 1659 | } |
| 1660 | |
| 1661 | /** |
| 1662 | * i40e_aq_stop_lldp |
| 1663 | * @hw: pointer to the hw struct |
| 1664 | * @shutdown_agent: True if LLDP Agent needs to be Shutdown |
| 1665 | * @cmd_details: pointer to command details structure or NULL |
| 1666 | * |
| 1667 | * Stop or Shutdown the embedded LLDP Agent |
| 1668 | **/ |
| 1669 | i40e_status i40e_aq_stop_lldp(struct i40e_hw *hw, bool shutdown_agent, |
| 1670 | struct i40e_asq_cmd_details *cmd_details) |
| 1671 | { |
| 1672 | struct i40e_aq_desc desc; |
| 1673 | struct i40e_aqc_lldp_stop *cmd = |
| 1674 | (struct i40e_aqc_lldp_stop *)&desc.params.raw; |
| 1675 | i40e_status status; |
| 1676 | |
| 1677 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_lldp_stop); |
| 1678 | |
| 1679 | if (shutdown_agent) |
| 1680 | cmd->command |= I40E_AQ_LLDP_AGENT_SHUTDOWN; |
| 1681 | |
| 1682 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 1683 | |
| 1684 | return status; |
| 1685 | } |
| 1686 | |
| 1687 | /** |
| 1688 | * i40e_aq_start_lldp |
| 1689 | * @hw: pointer to the hw struct |
| 1690 | * @cmd_details: pointer to command details structure or NULL |
| 1691 | * |
| 1692 | * Start the embedded LLDP Agent on all ports. |
| 1693 | **/ |
| 1694 | i40e_status i40e_aq_start_lldp(struct i40e_hw *hw, |
| 1695 | struct i40e_asq_cmd_details *cmd_details) |
| 1696 | { |
| 1697 | struct i40e_aq_desc desc; |
| 1698 | struct i40e_aqc_lldp_start *cmd = |
| 1699 | (struct i40e_aqc_lldp_start *)&desc.params.raw; |
| 1700 | i40e_status status; |
| 1701 | |
| 1702 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_lldp_start); |
| 1703 | |
| 1704 | cmd->command = I40E_AQ_LLDP_AGENT_START; |
| 1705 | |
| 1706 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 1707 | |
| 1708 | return status; |
| 1709 | } |
| 1710 | |
| 1711 | /** |
Jeff Kirsher | a1c9a9d | 2013-12-28 07:32:18 +0000 | [diff] [blame] | 1712 | * i40e_aq_add_udp_tunnel |
| 1713 | * @hw: pointer to the hw struct |
| 1714 | * @udp_port: the UDP port to add |
| 1715 | * @header_len: length of the tunneling header length in DWords |
| 1716 | * @protocol_index: protocol index type |
| 1717 | * @cmd_details: pointer to command details structure or NULL |
| 1718 | **/ |
| 1719 | i40e_status i40e_aq_add_udp_tunnel(struct i40e_hw *hw, |
| 1720 | u16 udp_port, u8 header_len, |
| 1721 | u8 protocol_index, u8 *filter_index, |
| 1722 | struct i40e_asq_cmd_details *cmd_details) |
| 1723 | { |
| 1724 | struct i40e_aq_desc desc; |
| 1725 | struct i40e_aqc_add_udp_tunnel *cmd = |
| 1726 | (struct i40e_aqc_add_udp_tunnel *)&desc.params.raw; |
| 1727 | struct i40e_aqc_del_udp_tunnel_completion *resp = |
| 1728 | (struct i40e_aqc_del_udp_tunnel_completion *)&desc.params.raw; |
| 1729 | i40e_status status; |
| 1730 | |
| 1731 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_add_udp_tunnel); |
| 1732 | |
| 1733 | cmd->udp_port = cpu_to_le16(udp_port); |
| 1734 | cmd->header_len = header_len; |
| 1735 | cmd->protocol_index = protocol_index; |
| 1736 | |
| 1737 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 1738 | |
| 1739 | if (!status) |
| 1740 | *filter_index = resp->index; |
| 1741 | |
| 1742 | return status; |
| 1743 | } |
| 1744 | |
| 1745 | /** |
| 1746 | * i40e_aq_del_udp_tunnel |
| 1747 | * @hw: pointer to the hw struct |
| 1748 | * @index: filter index |
| 1749 | * @cmd_details: pointer to command details structure or NULL |
| 1750 | **/ |
| 1751 | i40e_status i40e_aq_del_udp_tunnel(struct i40e_hw *hw, u8 index, |
| 1752 | struct i40e_asq_cmd_details *cmd_details) |
| 1753 | { |
| 1754 | struct i40e_aq_desc desc; |
| 1755 | struct i40e_aqc_remove_udp_tunnel *cmd = |
| 1756 | (struct i40e_aqc_remove_udp_tunnel *)&desc.params.raw; |
| 1757 | i40e_status status; |
| 1758 | |
| 1759 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_del_udp_tunnel); |
| 1760 | |
| 1761 | cmd->index = index; |
| 1762 | |
| 1763 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 1764 | |
| 1765 | return status; |
| 1766 | } |
| 1767 | |
| 1768 | /** |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1769 | * i40e_aq_delete_element - Delete switch element |
| 1770 | * @hw: pointer to the hw struct |
| 1771 | * @seid: the SEID to delete from the switch |
| 1772 | * @cmd_details: pointer to command details structure or NULL |
| 1773 | * |
| 1774 | * This deletes a switch element from the switch. |
| 1775 | **/ |
| 1776 | i40e_status i40e_aq_delete_element(struct i40e_hw *hw, u16 seid, |
| 1777 | struct i40e_asq_cmd_details *cmd_details) |
| 1778 | { |
| 1779 | struct i40e_aq_desc desc; |
| 1780 | struct i40e_aqc_switch_seid *cmd = |
| 1781 | (struct i40e_aqc_switch_seid *)&desc.params.raw; |
| 1782 | i40e_status status; |
| 1783 | |
| 1784 | if (seid == 0) |
| 1785 | return I40E_ERR_PARAM; |
| 1786 | |
| 1787 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_delete_element); |
| 1788 | |
| 1789 | cmd->seid = cpu_to_le16(seid); |
| 1790 | |
| 1791 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 1792 | |
| 1793 | return status; |
| 1794 | } |
| 1795 | |
| 1796 | /** |
| 1797 | * i40e_aq_tx_sched_cmd - generic Tx scheduler AQ command handler |
| 1798 | * @hw: pointer to the hw struct |
| 1799 | * @seid: seid for the physical port/switching component/vsi |
| 1800 | * @buff: Indirect buffer to hold data parameters and response |
| 1801 | * @buff_size: Indirect buffer size |
| 1802 | * @opcode: Tx scheduler AQ command opcode |
| 1803 | * @cmd_details: pointer to command details structure or NULL |
| 1804 | * |
| 1805 | * Generic command handler for Tx scheduler AQ commands |
| 1806 | **/ |
| 1807 | static i40e_status i40e_aq_tx_sched_cmd(struct i40e_hw *hw, u16 seid, |
| 1808 | void *buff, u16 buff_size, |
| 1809 | enum i40e_admin_queue_opc opcode, |
| 1810 | struct i40e_asq_cmd_details *cmd_details) |
| 1811 | { |
| 1812 | struct i40e_aq_desc desc; |
| 1813 | struct i40e_aqc_tx_sched_ind *cmd = |
| 1814 | (struct i40e_aqc_tx_sched_ind *)&desc.params.raw; |
| 1815 | i40e_status status; |
| 1816 | bool cmd_param_flag = false; |
| 1817 | |
| 1818 | switch (opcode) { |
| 1819 | case i40e_aqc_opc_configure_vsi_ets_sla_bw_limit: |
| 1820 | case i40e_aqc_opc_configure_vsi_tc_bw: |
| 1821 | case i40e_aqc_opc_enable_switching_comp_ets: |
| 1822 | case i40e_aqc_opc_modify_switching_comp_ets: |
| 1823 | case i40e_aqc_opc_disable_switching_comp_ets: |
| 1824 | case i40e_aqc_opc_configure_switching_comp_ets_bw_limit: |
| 1825 | case i40e_aqc_opc_configure_switching_comp_bw_config: |
| 1826 | cmd_param_flag = true; |
| 1827 | break; |
| 1828 | case i40e_aqc_opc_query_vsi_bw_config: |
| 1829 | case i40e_aqc_opc_query_vsi_ets_sla_config: |
| 1830 | case i40e_aqc_opc_query_switching_comp_ets_config: |
| 1831 | case i40e_aqc_opc_query_port_ets_config: |
| 1832 | case i40e_aqc_opc_query_switching_comp_bw_config: |
| 1833 | cmd_param_flag = false; |
| 1834 | break; |
| 1835 | default: |
| 1836 | return I40E_ERR_PARAM; |
| 1837 | } |
| 1838 | |
| 1839 | i40e_fill_default_direct_cmd_desc(&desc, opcode); |
| 1840 | |
| 1841 | /* Indirect command */ |
| 1842 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF); |
| 1843 | if (cmd_param_flag) |
| 1844 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_RD); |
| 1845 | if (buff_size > I40E_AQ_LARGE_BUF) |
| 1846 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB); |
| 1847 | |
| 1848 | desc.datalen = cpu_to_le16(buff_size); |
| 1849 | |
| 1850 | cmd->vsi_seid = cpu_to_le16(seid); |
| 1851 | |
| 1852 | status = i40e_asq_send_command(hw, &desc, buff, buff_size, cmd_details); |
| 1853 | |
| 1854 | return status; |
| 1855 | } |
| 1856 | |
| 1857 | /** |
| 1858 | * i40e_aq_config_vsi_tc_bw - Config VSI BW Allocation per TC |
| 1859 | * @hw: pointer to the hw struct |
| 1860 | * @seid: VSI seid |
| 1861 | * @bw_data: Buffer holding enabled TCs, relative TC BW limit/credits |
| 1862 | * @cmd_details: pointer to command details structure or NULL |
| 1863 | **/ |
| 1864 | i40e_status i40e_aq_config_vsi_tc_bw(struct i40e_hw *hw, |
| 1865 | u16 seid, |
| 1866 | struct i40e_aqc_configure_vsi_tc_bw_data *bw_data, |
| 1867 | struct i40e_asq_cmd_details *cmd_details) |
| 1868 | { |
| 1869 | return i40e_aq_tx_sched_cmd(hw, seid, (void *)bw_data, sizeof(*bw_data), |
| 1870 | i40e_aqc_opc_configure_vsi_tc_bw, |
| 1871 | cmd_details); |
| 1872 | } |
| 1873 | |
| 1874 | /** |
| 1875 | * i40e_aq_query_vsi_bw_config - Query VSI BW configuration |
| 1876 | * @hw: pointer to the hw struct |
| 1877 | * @seid: seid of the VSI |
| 1878 | * @bw_data: Buffer to hold VSI BW configuration |
| 1879 | * @cmd_details: pointer to command details structure or NULL |
| 1880 | **/ |
| 1881 | i40e_status i40e_aq_query_vsi_bw_config(struct i40e_hw *hw, |
| 1882 | u16 seid, |
| 1883 | struct i40e_aqc_query_vsi_bw_config_resp *bw_data, |
| 1884 | struct i40e_asq_cmd_details *cmd_details) |
| 1885 | { |
| 1886 | return i40e_aq_tx_sched_cmd(hw, seid, (void *)bw_data, sizeof(*bw_data), |
| 1887 | i40e_aqc_opc_query_vsi_bw_config, |
| 1888 | cmd_details); |
| 1889 | } |
| 1890 | |
| 1891 | /** |
| 1892 | * i40e_aq_query_vsi_ets_sla_config - Query VSI BW configuration per TC |
| 1893 | * @hw: pointer to the hw struct |
| 1894 | * @seid: seid of the VSI |
| 1895 | * @bw_data: Buffer to hold VSI BW configuration per TC |
| 1896 | * @cmd_details: pointer to command details structure or NULL |
| 1897 | **/ |
| 1898 | i40e_status i40e_aq_query_vsi_ets_sla_config(struct i40e_hw *hw, |
| 1899 | u16 seid, |
| 1900 | struct i40e_aqc_query_vsi_ets_sla_config_resp *bw_data, |
| 1901 | struct i40e_asq_cmd_details *cmd_details) |
| 1902 | { |
| 1903 | return i40e_aq_tx_sched_cmd(hw, seid, (void *)bw_data, sizeof(*bw_data), |
| 1904 | i40e_aqc_opc_query_vsi_ets_sla_config, |
| 1905 | cmd_details); |
| 1906 | } |
| 1907 | |
| 1908 | /** |
| 1909 | * i40e_aq_query_switch_comp_ets_config - Query Switch comp BW config per TC |
| 1910 | * @hw: pointer to the hw struct |
| 1911 | * @seid: seid of the switching component |
| 1912 | * @bw_data: Buffer to hold switching component's per TC BW config |
| 1913 | * @cmd_details: pointer to command details structure or NULL |
| 1914 | **/ |
| 1915 | i40e_status i40e_aq_query_switch_comp_ets_config(struct i40e_hw *hw, |
| 1916 | u16 seid, |
| 1917 | struct i40e_aqc_query_switching_comp_ets_config_resp *bw_data, |
| 1918 | struct i40e_asq_cmd_details *cmd_details) |
| 1919 | { |
| 1920 | return i40e_aq_tx_sched_cmd(hw, seid, (void *)bw_data, sizeof(*bw_data), |
| 1921 | i40e_aqc_opc_query_switching_comp_ets_config, |
| 1922 | cmd_details); |
| 1923 | } |
| 1924 | |
| 1925 | /** |
| 1926 | * i40e_aq_query_port_ets_config - Query Physical Port ETS configuration |
| 1927 | * @hw: pointer to the hw struct |
| 1928 | * @seid: seid of the VSI or switching component connected to Physical Port |
| 1929 | * @bw_data: Buffer to hold current ETS configuration for the Physical Port |
| 1930 | * @cmd_details: pointer to command details structure or NULL |
| 1931 | **/ |
| 1932 | i40e_status i40e_aq_query_port_ets_config(struct i40e_hw *hw, |
| 1933 | u16 seid, |
| 1934 | struct i40e_aqc_query_port_ets_config_resp *bw_data, |
| 1935 | struct i40e_asq_cmd_details *cmd_details) |
| 1936 | { |
| 1937 | return i40e_aq_tx_sched_cmd(hw, seid, (void *)bw_data, sizeof(*bw_data), |
| 1938 | i40e_aqc_opc_query_port_ets_config, |
| 1939 | cmd_details); |
| 1940 | } |
| 1941 | |
| 1942 | /** |
| 1943 | * i40e_aq_query_switch_comp_bw_config - Query Switch comp BW configuration |
| 1944 | * @hw: pointer to the hw struct |
| 1945 | * @seid: seid of the switching component |
| 1946 | * @bw_data: Buffer to hold switching component's BW configuration |
| 1947 | * @cmd_details: pointer to command details structure or NULL |
| 1948 | **/ |
| 1949 | i40e_status i40e_aq_query_switch_comp_bw_config(struct i40e_hw *hw, |
| 1950 | u16 seid, |
| 1951 | struct i40e_aqc_query_switching_comp_bw_config_resp *bw_data, |
| 1952 | struct i40e_asq_cmd_details *cmd_details) |
| 1953 | { |
| 1954 | return i40e_aq_tx_sched_cmd(hw, seid, (void *)bw_data, sizeof(*bw_data), |
| 1955 | i40e_aqc_opc_query_switching_comp_bw_config, |
| 1956 | cmd_details); |
| 1957 | } |
| 1958 | |
| 1959 | /** |
| 1960 | * i40e_validate_filter_settings |
| 1961 | * @hw: pointer to the hardware structure |
| 1962 | * @settings: Filter control settings |
| 1963 | * |
| 1964 | * Check and validate the filter control settings passed. |
| 1965 | * The function checks for the valid filter/context sizes being |
| 1966 | * passed for FCoE and PE. |
| 1967 | * |
| 1968 | * Returns 0 if the values passed are valid and within |
| 1969 | * range else returns an error. |
| 1970 | **/ |
| 1971 | static i40e_status i40e_validate_filter_settings(struct i40e_hw *hw, |
| 1972 | struct i40e_filter_control_settings *settings) |
| 1973 | { |
| 1974 | u32 fcoe_cntx_size, fcoe_filt_size; |
| 1975 | u32 pe_cntx_size, pe_filt_size; |
| 1976 | u32 fcoe_fmax, pe_fmax; |
| 1977 | u32 val; |
| 1978 | |
| 1979 | /* Validate FCoE settings passed */ |
| 1980 | switch (settings->fcoe_filt_num) { |
| 1981 | case I40E_HASH_FILTER_SIZE_1K: |
| 1982 | case I40E_HASH_FILTER_SIZE_2K: |
| 1983 | case I40E_HASH_FILTER_SIZE_4K: |
| 1984 | case I40E_HASH_FILTER_SIZE_8K: |
| 1985 | case I40E_HASH_FILTER_SIZE_16K: |
| 1986 | case I40E_HASH_FILTER_SIZE_32K: |
| 1987 | fcoe_filt_size = I40E_HASH_FILTER_BASE_SIZE; |
| 1988 | fcoe_filt_size <<= (u32)settings->fcoe_filt_num; |
| 1989 | break; |
| 1990 | default: |
| 1991 | return I40E_ERR_PARAM; |
| 1992 | } |
| 1993 | |
| 1994 | switch (settings->fcoe_cntx_num) { |
| 1995 | case I40E_DMA_CNTX_SIZE_512: |
| 1996 | case I40E_DMA_CNTX_SIZE_1K: |
| 1997 | case I40E_DMA_CNTX_SIZE_2K: |
| 1998 | case I40E_DMA_CNTX_SIZE_4K: |
| 1999 | fcoe_cntx_size = I40E_DMA_CNTX_BASE_SIZE; |
| 2000 | fcoe_cntx_size <<= (u32)settings->fcoe_cntx_num; |
| 2001 | break; |
| 2002 | default: |
| 2003 | return I40E_ERR_PARAM; |
| 2004 | } |
| 2005 | |
| 2006 | /* Validate PE settings passed */ |
| 2007 | switch (settings->pe_filt_num) { |
| 2008 | case I40E_HASH_FILTER_SIZE_1K: |
| 2009 | case I40E_HASH_FILTER_SIZE_2K: |
| 2010 | case I40E_HASH_FILTER_SIZE_4K: |
| 2011 | case I40E_HASH_FILTER_SIZE_8K: |
| 2012 | case I40E_HASH_FILTER_SIZE_16K: |
| 2013 | case I40E_HASH_FILTER_SIZE_32K: |
| 2014 | case I40E_HASH_FILTER_SIZE_64K: |
| 2015 | case I40E_HASH_FILTER_SIZE_128K: |
| 2016 | case I40E_HASH_FILTER_SIZE_256K: |
| 2017 | case I40E_HASH_FILTER_SIZE_512K: |
| 2018 | case I40E_HASH_FILTER_SIZE_1M: |
| 2019 | pe_filt_size = I40E_HASH_FILTER_BASE_SIZE; |
| 2020 | pe_filt_size <<= (u32)settings->pe_filt_num; |
| 2021 | break; |
| 2022 | default: |
| 2023 | return I40E_ERR_PARAM; |
| 2024 | } |
| 2025 | |
| 2026 | switch (settings->pe_cntx_num) { |
| 2027 | case I40E_DMA_CNTX_SIZE_512: |
| 2028 | case I40E_DMA_CNTX_SIZE_1K: |
| 2029 | case I40E_DMA_CNTX_SIZE_2K: |
| 2030 | case I40E_DMA_CNTX_SIZE_4K: |
| 2031 | case I40E_DMA_CNTX_SIZE_8K: |
| 2032 | case I40E_DMA_CNTX_SIZE_16K: |
| 2033 | case I40E_DMA_CNTX_SIZE_32K: |
| 2034 | case I40E_DMA_CNTX_SIZE_64K: |
| 2035 | case I40E_DMA_CNTX_SIZE_128K: |
| 2036 | case I40E_DMA_CNTX_SIZE_256K: |
| 2037 | pe_cntx_size = I40E_DMA_CNTX_BASE_SIZE; |
| 2038 | pe_cntx_size <<= (u32)settings->pe_cntx_num; |
| 2039 | break; |
| 2040 | default: |
| 2041 | return I40E_ERR_PARAM; |
| 2042 | } |
| 2043 | |
| 2044 | /* FCHSIZE + FCDSIZE should not be greater than PMFCOEFMAX */ |
| 2045 | val = rd32(hw, I40E_GLHMC_FCOEFMAX); |
| 2046 | fcoe_fmax = (val & I40E_GLHMC_FCOEFMAX_PMFCOEFMAX_MASK) |
| 2047 | >> I40E_GLHMC_FCOEFMAX_PMFCOEFMAX_SHIFT; |
| 2048 | if (fcoe_filt_size + fcoe_cntx_size > fcoe_fmax) |
| 2049 | return I40E_ERR_INVALID_SIZE; |
| 2050 | |
| 2051 | /* PEHSIZE + PEDSIZE should not be greater than PMPEXFMAX */ |
| 2052 | val = rd32(hw, I40E_GLHMC_PEXFMAX); |
| 2053 | pe_fmax = (val & I40E_GLHMC_PEXFMAX_PMPEXFMAX_MASK) |
| 2054 | >> I40E_GLHMC_PEXFMAX_PMPEXFMAX_SHIFT; |
| 2055 | if (pe_filt_size + pe_cntx_size > pe_fmax) |
| 2056 | return I40E_ERR_INVALID_SIZE; |
| 2057 | |
| 2058 | return 0; |
| 2059 | } |
| 2060 | |
| 2061 | /** |
| 2062 | * i40e_set_filter_control |
| 2063 | * @hw: pointer to the hardware structure |
| 2064 | * @settings: Filter control settings |
| 2065 | * |
| 2066 | * Set the Queue Filters for PE/FCoE and enable filters required |
| 2067 | * for a single PF. It is expected that these settings are programmed |
| 2068 | * at the driver initialization time. |
| 2069 | **/ |
| 2070 | i40e_status i40e_set_filter_control(struct i40e_hw *hw, |
| 2071 | struct i40e_filter_control_settings *settings) |
| 2072 | { |
| 2073 | i40e_status ret = 0; |
| 2074 | u32 hash_lut_size = 0; |
| 2075 | u32 val; |
| 2076 | |
| 2077 | if (!settings) |
| 2078 | return I40E_ERR_PARAM; |
| 2079 | |
| 2080 | /* Validate the input settings */ |
| 2081 | ret = i40e_validate_filter_settings(hw, settings); |
| 2082 | if (ret) |
| 2083 | return ret; |
| 2084 | |
| 2085 | /* Read the PF Queue Filter control register */ |
| 2086 | val = rd32(hw, I40E_PFQF_CTL_0); |
| 2087 | |
| 2088 | /* Program required PE hash buckets for the PF */ |
| 2089 | val &= ~I40E_PFQF_CTL_0_PEHSIZE_MASK; |
| 2090 | val |= ((u32)settings->pe_filt_num << I40E_PFQF_CTL_0_PEHSIZE_SHIFT) & |
| 2091 | I40E_PFQF_CTL_0_PEHSIZE_MASK; |
| 2092 | /* Program required PE contexts for the PF */ |
| 2093 | val &= ~I40E_PFQF_CTL_0_PEDSIZE_MASK; |
| 2094 | val |= ((u32)settings->pe_cntx_num << I40E_PFQF_CTL_0_PEDSIZE_SHIFT) & |
| 2095 | I40E_PFQF_CTL_0_PEDSIZE_MASK; |
| 2096 | |
| 2097 | /* Program required FCoE hash buckets for the PF */ |
| 2098 | val &= ~I40E_PFQF_CTL_0_PFFCHSIZE_MASK; |
| 2099 | val |= ((u32)settings->fcoe_filt_num << |
| 2100 | I40E_PFQF_CTL_0_PFFCHSIZE_SHIFT) & |
| 2101 | I40E_PFQF_CTL_0_PFFCHSIZE_MASK; |
| 2102 | /* Program required FCoE DDP contexts for the PF */ |
| 2103 | val &= ~I40E_PFQF_CTL_0_PFFCDSIZE_MASK; |
| 2104 | val |= ((u32)settings->fcoe_cntx_num << |
| 2105 | I40E_PFQF_CTL_0_PFFCDSIZE_SHIFT) & |
| 2106 | I40E_PFQF_CTL_0_PFFCDSIZE_MASK; |
| 2107 | |
| 2108 | /* Program Hash LUT size for the PF */ |
| 2109 | val &= ~I40E_PFQF_CTL_0_HASHLUTSIZE_MASK; |
| 2110 | if (settings->hash_lut_size == I40E_HASH_LUT_SIZE_512) |
| 2111 | hash_lut_size = 1; |
| 2112 | val |= (hash_lut_size << I40E_PFQF_CTL_0_HASHLUTSIZE_SHIFT) & |
| 2113 | I40E_PFQF_CTL_0_HASHLUTSIZE_MASK; |
| 2114 | |
| 2115 | /* Enable FDIR, Ethertype and MACVLAN filters for PF and VFs */ |
| 2116 | if (settings->enable_fdir) |
| 2117 | val |= I40E_PFQF_CTL_0_FD_ENA_MASK; |
| 2118 | if (settings->enable_ethtype) |
| 2119 | val |= I40E_PFQF_CTL_0_ETYPE_ENA_MASK; |
| 2120 | if (settings->enable_macvlan) |
| 2121 | val |= I40E_PFQF_CTL_0_MACVLAN_ENA_MASK; |
| 2122 | |
| 2123 | wr32(hw, I40E_PFQF_CTL_0, val); |
| 2124 | |
| 2125 | return 0; |
| 2126 | } |
Catherine Sullivan | d4dfb81 | 2013-11-28 06:39:21 +0000 | [diff] [blame] | 2127 | /** |
| 2128 | * i40e_set_pci_config_data - store PCI bus info |
| 2129 | * @hw: pointer to hardware structure |
| 2130 | * @link_status: the link status word from PCI config space |
| 2131 | * |
| 2132 | * Stores the PCI bus info (speed, width, type) within the i40e_hw structure |
| 2133 | **/ |
| 2134 | void i40e_set_pci_config_data(struct i40e_hw *hw, u16 link_status) |
| 2135 | { |
| 2136 | hw->bus.type = i40e_bus_type_pci_express; |
| 2137 | |
| 2138 | switch (link_status & PCI_EXP_LNKSTA_NLW) { |
| 2139 | case PCI_EXP_LNKSTA_NLW_X1: |
| 2140 | hw->bus.width = i40e_bus_width_pcie_x1; |
| 2141 | break; |
| 2142 | case PCI_EXP_LNKSTA_NLW_X2: |
| 2143 | hw->bus.width = i40e_bus_width_pcie_x2; |
| 2144 | break; |
| 2145 | case PCI_EXP_LNKSTA_NLW_X4: |
| 2146 | hw->bus.width = i40e_bus_width_pcie_x4; |
| 2147 | break; |
| 2148 | case PCI_EXP_LNKSTA_NLW_X8: |
| 2149 | hw->bus.width = i40e_bus_width_pcie_x8; |
| 2150 | break; |
| 2151 | default: |
| 2152 | hw->bus.width = i40e_bus_width_unknown; |
| 2153 | break; |
| 2154 | } |
| 2155 | |
| 2156 | switch (link_status & PCI_EXP_LNKSTA_CLS) { |
| 2157 | case PCI_EXP_LNKSTA_CLS_2_5GB: |
| 2158 | hw->bus.speed = i40e_bus_speed_2500; |
| 2159 | break; |
| 2160 | case PCI_EXP_LNKSTA_CLS_5_0GB: |
| 2161 | hw->bus.speed = i40e_bus_speed_5000; |
| 2162 | break; |
| 2163 | case PCI_EXP_LNKSTA_CLS_8_0GB: |
| 2164 | hw->bus.speed = i40e_bus_speed_8000; |
| 2165 | break; |
| 2166 | default: |
| 2167 | hw->bus.speed = i40e_bus_speed_unknown; |
| 2168 | break; |
| 2169 | } |
| 2170 | } |