Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | * |
| 3 | * Intel Ethernet Controller XL710 Family Linux Driver |
Shannon Nelson | 67be6eb | 2016-01-13 16:51:40 -0800 | [diff] [blame] | 4 | * Copyright(c) 2013 - 2016 Intel Corporation. |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 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 | * |
Greg Rose | dc641b7 | 2013-12-18 13:45:51 +0000 | [diff] [blame] | 15 | * You should have received a copy of the GNU General Public License along |
| 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 17 | * |
| 18 | * The full GNU General Public License is included in this distribution in |
| 19 | * the file called "COPYING". |
| 20 | * |
| 21 | * Contact Information: |
| 22 | * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> |
| 23 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
| 24 | * |
| 25 | ******************************************************************************/ |
| 26 | |
| 27 | #include "i40e_type.h" |
| 28 | #include "i40e_adminq.h" |
| 29 | #include "i40e_prototype.h" |
| 30 | #include "i40e_virtchnl.h" |
| 31 | |
| 32 | /** |
| 33 | * i40e_set_mac_type - Sets MAC type |
| 34 | * @hw: pointer to the HW structure |
| 35 | * |
| 36 | * This function sets the mac type of the adapter based on the |
| 37 | * vendor ID and device ID stored in the hw structure. |
| 38 | **/ |
| 39 | static i40e_status i40e_set_mac_type(struct i40e_hw *hw) |
| 40 | { |
| 41 | i40e_status status = 0; |
| 42 | |
| 43 | if (hw->vendor_id == PCI_VENDOR_ID_INTEL) { |
| 44 | switch (hw->device_id) { |
Shannon Nelson | ab60085 | 2014-01-17 15:36:39 -0800 | [diff] [blame] | 45 | case I40E_DEV_ID_SFP_XL710: |
Shannon Nelson | ab60085 | 2014-01-17 15:36:39 -0800 | [diff] [blame] | 46 | case I40E_DEV_ID_QEMU: |
Shannon Nelson | ab60085 | 2014-01-17 15:36:39 -0800 | [diff] [blame] | 47 | case I40E_DEV_ID_KX_B: |
| 48 | case I40E_DEV_ID_KX_C: |
Shannon Nelson | ab60085 | 2014-01-17 15:36:39 -0800 | [diff] [blame] | 49 | case I40E_DEV_ID_QSFP_A: |
| 50 | case I40E_DEV_ID_QSFP_B: |
| 51 | case I40E_DEV_ID_QSFP_C: |
Mitch Williams | 5960d33 | 2014-09-13 07:40:47 +0000 | [diff] [blame] | 52 | case I40E_DEV_ID_10G_BASE_T: |
Shannon Nelson | bc5166b9 | 2015-08-26 15:14:10 -0400 | [diff] [blame] | 53 | case I40E_DEV_ID_10G_BASE_T4: |
Jesse Brandeburg | ae24b40 | 2015-03-27 00:12:09 -0700 | [diff] [blame] | 54 | case I40E_DEV_ID_20G_KR2: |
Shannon Nelson | 48a3b51 | 2015-07-23 16:54:39 -0400 | [diff] [blame] | 55 | case I40E_DEV_ID_20G_KR2_A: |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 56 | hw->mac.type = I40E_MAC_XL710; |
| 57 | break; |
Anjali Singhai Jain | 35dae51 | 2015-12-22 14:25:03 -0800 | [diff] [blame] | 58 | case I40E_DEV_ID_KX_X722: |
| 59 | case I40E_DEV_ID_QSFP_X722: |
Anjali Singhai Jain | 87e6c1d | 2015-06-05 12:20:25 -0400 | [diff] [blame] | 60 | case I40E_DEV_ID_SFP_X722: |
| 61 | case I40E_DEV_ID_1G_BASE_T_X722: |
| 62 | case I40E_DEV_ID_10G_BASE_T_X722: |
Catherine Sullivan | d6bf58c | 2016-03-18 12:18:08 -0700 | [diff] [blame] | 63 | case I40E_DEV_ID_SFP_I_X722: |
Anjali Singhai Jain | 87e6c1d | 2015-06-05 12:20:25 -0400 | [diff] [blame] | 64 | hw->mac.type = I40E_MAC_X722; |
| 65 | break; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 66 | default: |
| 67 | hw->mac.type = I40E_MAC_GENERIC; |
| 68 | break; |
| 69 | } |
| 70 | } else { |
| 71 | status = I40E_ERR_DEVICE_NOT_SUPPORTED; |
| 72 | } |
| 73 | |
| 74 | hw_dbg(hw, "i40e_set_mac_type found mac: %d, returns: %d\n", |
| 75 | hw->mac.type, status); |
| 76 | return status; |
| 77 | } |
| 78 | |
| 79 | /** |
Shannon Nelson | f1c7e72 | 2015-06-04 16:24:01 -0400 | [diff] [blame] | 80 | * i40e_aq_str - convert AQ err code to a string |
| 81 | * @hw: pointer to the HW structure |
| 82 | * @aq_err: the AQ error code to convert |
| 83 | **/ |
Jingjing Wu | 4e68adfe | 2015-09-28 14:12:31 -0400 | [diff] [blame] | 84 | const char *i40e_aq_str(struct i40e_hw *hw, enum i40e_admin_queue_err aq_err) |
Shannon Nelson | f1c7e72 | 2015-06-04 16:24:01 -0400 | [diff] [blame] | 85 | { |
| 86 | switch (aq_err) { |
| 87 | case I40E_AQ_RC_OK: |
| 88 | return "OK"; |
| 89 | case I40E_AQ_RC_EPERM: |
| 90 | return "I40E_AQ_RC_EPERM"; |
| 91 | case I40E_AQ_RC_ENOENT: |
| 92 | return "I40E_AQ_RC_ENOENT"; |
| 93 | case I40E_AQ_RC_ESRCH: |
| 94 | return "I40E_AQ_RC_ESRCH"; |
| 95 | case I40E_AQ_RC_EINTR: |
| 96 | return "I40E_AQ_RC_EINTR"; |
| 97 | case I40E_AQ_RC_EIO: |
| 98 | return "I40E_AQ_RC_EIO"; |
| 99 | case I40E_AQ_RC_ENXIO: |
| 100 | return "I40E_AQ_RC_ENXIO"; |
| 101 | case I40E_AQ_RC_E2BIG: |
| 102 | return "I40E_AQ_RC_E2BIG"; |
| 103 | case I40E_AQ_RC_EAGAIN: |
| 104 | return "I40E_AQ_RC_EAGAIN"; |
| 105 | case I40E_AQ_RC_ENOMEM: |
| 106 | return "I40E_AQ_RC_ENOMEM"; |
| 107 | case I40E_AQ_RC_EACCES: |
| 108 | return "I40E_AQ_RC_EACCES"; |
| 109 | case I40E_AQ_RC_EFAULT: |
| 110 | return "I40E_AQ_RC_EFAULT"; |
| 111 | case I40E_AQ_RC_EBUSY: |
| 112 | return "I40E_AQ_RC_EBUSY"; |
| 113 | case I40E_AQ_RC_EEXIST: |
| 114 | return "I40E_AQ_RC_EEXIST"; |
| 115 | case I40E_AQ_RC_EINVAL: |
| 116 | return "I40E_AQ_RC_EINVAL"; |
| 117 | case I40E_AQ_RC_ENOTTY: |
| 118 | return "I40E_AQ_RC_ENOTTY"; |
| 119 | case I40E_AQ_RC_ENOSPC: |
| 120 | return "I40E_AQ_RC_ENOSPC"; |
| 121 | case I40E_AQ_RC_ENOSYS: |
| 122 | return "I40E_AQ_RC_ENOSYS"; |
| 123 | case I40E_AQ_RC_ERANGE: |
| 124 | return "I40E_AQ_RC_ERANGE"; |
| 125 | case I40E_AQ_RC_EFLUSHED: |
| 126 | return "I40E_AQ_RC_EFLUSHED"; |
| 127 | case I40E_AQ_RC_BAD_ADDR: |
| 128 | return "I40E_AQ_RC_BAD_ADDR"; |
| 129 | case I40E_AQ_RC_EMODE: |
| 130 | return "I40E_AQ_RC_EMODE"; |
| 131 | case I40E_AQ_RC_EFBIG: |
| 132 | return "I40E_AQ_RC_EFBIG"; |
| 133 | } |
| 134 | |
| 135 | snprintf(hw->err_str, sizeof(hw->err_str), "%d", aq_err); |
| 136 | return hw->err_str; |
| 137 | } |
| 138 | |
| 139 | /** |
| 140 | * i40e_stat_str - convert status err code to a string |
| 141 | * @hw: pointer to the HW structure |
| 142 | * @stat_err: the status error code to convert |
| 143 | **/ |
Jingjing Wu | 4e68adfe | 2015-09-28 14:12:31 -0400 | [diff] [blame] | 144 | const char *i40e_stat_str(struct i40e_hw *hw, i40e_status stat_err) |
Shannon Nelson | f1c7e72 | 2015-06-04 16:24:01 -0400 | [diff] [blame] | 145 | { |
| 146 | switch (stat_err) { |
| 147 | case 0: |
| 148 | return "OK"; |
| 149 | case I40E_ERR_NVM: |
| 150 | return "I40E_ERR_NVM"; |
| 151 | case I40E_ERR_NVM_CHECKSUM: |
| 152 | return "I40E_ERR_NVM_CHECKSUM"; |
| 153 | case I40E_ERR_PHY: |
| 154 | return "I40E_ERR_PHY"; |
| 155 | case I40E_ERR_CONFIG: |
| 156 | return "I40E_ERR_CONFIG"; |
| 157 | case I40E_ERR_PARAM: |
| 158 | return "I40E_ERR_PARAM"; |
| 159 | case I40E_ERR_MAC_TYPE: |
| 160 | return "I40E_ERR_MAC_TYPE"; |
| 161 | case I40E_ERR_UNKNOWN_PHY: |
| 162 | return "I40E_ERR_UNKNOWN_PHY"; |
| 163 | case I40E_ERR_LINK_SETUP: |
| 164 | return "I40E_ERR_LINK_SETUP"; |
| 165 | case I40E_ERR_ADAPTER_STOPPED: |
| 166 | return "I40E_ERR_ADAPTER_STOPPED"; |
| 167 | case I40E_ERR_INVALID_MAC_ADDR: |
| 168 | return "I40E_ERR_INVALID_MAC_ADDR"; |
| 169 | case I40E_ERR_DEVICE_NOT_SUPPORTED: |
| 170 | return "I40E_ERR_DEVICE_NOT_SUPPORTED"; |
| 171 | case I40E_ERR_MASTER_REQUESTS_PENDING: |
| 172 | return "I40E_ERR_MASTER_REQUESTS_PENDING"; |
| 173 | case I40E_ERR_INVALID_LINK_SETTINGS: |
| 174 | return "I40E_ERR_INVALID_LINK_SETTINGS"; |
| 175 | case I40E_ERR_AUTONEG_NOT_COMPLETE: |
| 176 | return "I40E_ERR_AUTONEG_NOT_COMPLETE"; |
| 177 | case I40E_ERR_RESET_FAILED: |
| 178 | return "I40E_ERR_RESET_FAILED"; |
| 179 | case I40E_ERR_SWFW_SYNC: |
| 180 | return "I40E_ERR_SWFW_SYNC"; |
| 181 | case I40E_ERR_NO_AVAILABLE_VSI: |
| 182 | return "I40E_ERR_NO_AVAILABLE_VSI"; |
| 183 | case I40E_ERR_NO_MEMORY: |
| 184 | return "I40E_ERR_NO_MEMORY"; |
| 185 | case I40E_ERR_BAD_PTR: |
| 186 | return "I40E_ERR_BAD_PTR"; |
| 187 | case I40E_ERR_RING_FULL: |
| 188 | return "I40E_ERR_RING_FULL"; |
| 189 | case I40E_ERR_INVALID_PD_ID: |
| 190 | return "I40E_ERR_INVALID_PD_ID"; |
| 191 | case I40E_ERR_INVALID_QP_ID: |
| 192 | return "I40E_ERR_INVALID_QP_ID"; |
| 193 | case I40E_ERR_INVALID_CQ_ID: |
| 194 | return "I40E_ERR_INVALID_CQ_ID"; |
| 195 | case I40E_ERR_INVALID_CEQ_ID: |
| 196 | return "I40E_ERR_INVALID_CEQ_ID"; |
| 197 | case I40E_ERR_INVALID_AEQ_ID: |
| 198 | return "I40E_ERR_INVALID_AEQ_ID"; |
| 199 | case I40E_ERR_INVALID_SIZE: |
| 200 | return "I40E_ERR_INVALID_SIZE"; |
| 201 | case I40E_ERR_INVALID_ARP_INDEX: |
| 202 | return "I40E_ERR_INVALID_ARP_INDEX"; |
| 203 | case I40E_ERR_INVALID_FPM_FUNC_ID: |
| 204 | return "I40E_ERR_INVALID_FPM_FUNC_ID"; |
| 205 | case I40E_ERR_QP_INVALID_MSG_SIZE: |
| 206 | return "I40E_ERR_QP_INVALID_MSG_SIZE"; |
| 207 | case I40E_ERR_QP_TOOMANY_WRS_POSTED: |
| 208 | return "I40E_ERR_QP_TOOMANY_WRS_POSTED"; |
| 209 | case I40E_ERR_INVALID_FRAG_COUNT: |
| 210 | return "I40E_ERR_INVALID_FRAG_COUNT"; |
| 211 | case I40E_ERR_QUEUE_EMPTY: |
| 212 | return "I40E_ERR_QUEUE_EMPTY"; |
| 213 | case I40E_ERR_INVALID_ALIGNMENT: |
| 214 | return "I40E_ERR_INVALID_ALIGNMENT"; |
| 215 | case I40E_ERR_FLUSHED_QUEUE: |
| 216 | return "I40E_ERR_FLUSHED_QUEUE"; |
| 217 | case I40E_ERR_INVALID_PUSH_PAGE_INDEX: |
| 218 | return "I40E_ERR_INVALID_PUSH_PAGE_INDEX"; |
| 219 | case I40E_ERR_INVALID_IMM_DATA_SIZE: |
| 220 | return "I40E_ERR_INVALID_IMM_DATA_SIZE"; |
| 221 | case I40E_ERR_TIMEOUT: |
| 222 | return "I40E_ERR_TIMEOUT"; |
| 223 | case I40E_ERR_OPCODE_MISMATCH: |
| 224 | return "I40E_ERR_OPCODE_MISMATCH"; |
| 225 | case I40E_ERR_CQP_COMPL_ERROR: |
| 226 | return "I40E_ERR_CQP_COMPL_ERROR"; |
| 227 | case I40E_ERR_INVALID_VF_ID: |
| 228 | return "I40E_ERR_INVALID_VF_ID"; |
| 229 | case I40E_ERR_INVALID_HMCFN_ID: |
| 230 | return "I40E_ERR_INVALID_HMCFN_ID"; |
| 231 | case I40E_ERR_BACKING_PAGE_ERROR: |
| 232 | return "I40E_ERR_BACKING_PAGE_ERROR"; |
| 233 | case I40E_ERR_NO_PBLCHUNKS_AVAILABLE: |
| 234 | return "I40E_ERR_NO_PBLCHUNKS_AVAILABLE"; |
| 235 | case I40E_ERR_INVALID_PBLE_INDEX: |
| 236 | return "I40E_ERR_INVALID_PBLE_INDEX"; |
| 237 | case I40E_ERR_INVALID_SD_INDEX: |
| 238 | return "I40E_ERR_INVALID_SD_INDEX"; |
| 239 | case I40E_ERR_INVALID_PAGE_DESC_INDEX: |
| 240 | return "I40E_ERR_INVALID_PAGE_DESC_INDEX"; |
| 241 | case I40E_ERR_INVALID_SD_TYPE: |
| 242 | return "I40E_ERR_INVALID_SD_TYPE"; |
| 243 | case I40E_ERR_MEMCPY_FAILED: |
| 244 | return "I40E_ERR_MEMCPY_FAILED"; |
| 245 | case I40E_ERR_INVALID_HMC_OBJ_INDEX: |
| 246 | return "I40E_ERR_INVALID_HMC_OBJ_INDEX"; |
| 247 | case I40E_ERR_INVALID_HMC_OBJ_COUNT: |
| 248 | return "I40E_ERR_INVALID_HMC_OBJ_COUNT"; |
| 249 | case I40E_ERR_INVALID_SRQ_ARM_LIMIT: |
| 250 | return "I40E_ERR_INVALID_SRQ_ARM_LIMIT"; |
| 251 | case I40E_ERR_SRQ_ENABLED: |
| 252 | return "I40E_ERR_SRQ_ENABLED"; |
| 253 | case I40E_ERR_ADMIN_QUEUE_ERROR: |
| 254 | return "I40E_ERR_ADMIN_QUEUE_ERROR"; |
| 255 | case I40E_ERR_ADMIN_QUEUE_TIMEOUT: |
| 256 | return "I40E_ERR_ADMIN_QUEUE_TIMEOUT"; |
| 257 | case I40E_ERR_BUF_TOO_SHORT: |
| 258 | return "I40E_ERR_BUF_TOO_SHORT"; |
| 259 | case I40E_ERR_ADMIN_QUEUE_FULL: |
| 260 | return "I40E_ERR_ADMIN_QUEUE_FULL"; |
| 261 | case I40E_ERR_ADMIN_QUEUE_NO_WORK: |
| 262 | return "I40E_ERR_ADMIN_QUEUE_NO_WORK"; |
| 263 | case I40E_ERR_BAD_IWARP_CQE: |
| 264 | return "I40E_ERR_BAD_IWARP_CQE"; |
| 265 | case I40E_ERR_NVM_BLANK_MODE: |
| 266 | return "I40E_ERR_NVM_BLANK_MODE"; |
| 267 | case I40E_ERR_NOT_IMPLEMENTED: |
| 268 | return "I40E_ERR_NOT_IMPLEMENTED"; |
| 269 | case I40E_ERR_PE_DOORBELL_NOT_ENABLED: |
| 270 | return "I40E_ERR_PE_DOORBELL_NOT_ENABLED"; |
| 271 | case I40E_ERR_DIAG_TEST_FAILED: |
| 272 | return "I40E_ERR_DIAG_TEST_FAILED"; |
| 273 | case I40E_ERR_NOT_READY: |
| 274 | return "I40E_ERR_NOT_READY"; |
| 275 | case I40E_NOT_SUPPORTED: |
| 276 | return "I40E_NOT_SUPPORTED"; |
| 277 | case I40E_ERR_FIRMWARE_API_VERSION: |
| 278 | return "I40E_ERR_FIRMWARE_API_VERSION"; |
| 279 | } |
| 280 | |
| 281 | snprintf(hw->err_str, sizeof(hw->err_str), "%d", stat_err); |
| 282 | return hw->err_str; |
| 283 | } |
| 284 | |
| 285 | /** |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 286 | * i40e_debug_aq |
| 287 | * @hw: debug mask related to admin queue |
Jeff Kirsher | 98d4438 | 2013-12-21 05:44:42 +0000 | [diff] [blame] | 288 | * @mask: debug mask |
| 289 | * @desc: pointer to admin queue descriptor |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 290 | * @buffer: pointer to command buffer |
Shannon Nelson | f905dd6 | 2014-07-10 07:58:20 +0000 | [diff] [blame] | 291 | * @buf_len: max length of buffer |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 292 | * |
| 293 | * Dumps debug log about adminq command with descriptor contents. |
| 294 | **/ |
| 295 | void i40e_debug_aq(struct i40e_hw *hw, enum i40e_debug_mask mask, void *desc, |
Shannon Nelson | f905dd6 | 2014-07-10 07:58:20 +0000 | [diff] [blame] | 296 | void *buffer, u16 buf_len) |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 297 | { |
| 298 | struct i40e_aq_desc *aq_desc = (struct i40e_aq_desc *)desc; |
Heinrich Schuchardt | cd95672 | 2016-05-17 22:41:33 +0200 | [diff] [blame] | 299 | u16 len; |
Shannon Nelson | 37a2973 | 2015-02-27 09:15:19 +0000 | [diff] [blame] | 300 | u8 *buf = (u8 *)buffer; |
| 301 | u16 i = 0; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 302 | |
| 303 | if ((!(mask & hw->debug_mask)) || (desc == NULL)) |
| 304 | return; |
| 305 | |
Heinrich Schuchardt | cd95672 | 2016-05-17 22:41:33 +0200 | [diff] [blame] | 306 | len = le16_to_cpu(aq_desc->datalen); |
| 307 | |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 308 | i40e_debug(hw, mask, |
| 309 | "AQ CMD: opcode 0x%04X, flags 0x%04X, datalen 0x%04X, retval 0x%04X\n", |
Paul M Stillwell Jr | f1abd7d | 2015-02-06 08:52:07 +0000 | [diff] [blame] | 310 | le16_to_cpu(aq_desc->opcode), |
| 311 | le16_to_cpu(aq_desc->flags), |
| 312 | le16_to_cpu(aq_desc->datalen), |
| 313 | le16_to_cpu(aq_desc->retval)); |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 314 | i40e_debug(hw, mask, "\tcookie (h,l) 0x%08X 0x%08X\n", |
Paul M Stillwell Jr | f1abd7d | 2015-02-06 08:52:07 +0000 | [diff] [blame] | 315 | le32_to_cpu(aq_desc->cookie_high), |
| 316 | le32_to_cpu(aq_desc->cookie_low)); |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 317 | i40e_debug(hw, mask, "\tparam (0,1) 0x%08X 0x%08X\n", |
Paul M Stillwell Jr | f1abd7d | 2015-02-06 08:52:07 +0000 | [diff] [blame] | 318 | le32_to_cpu(aq_desc->params.internal.param0), |
| 319 | le32_to_cpu(aq_desc->params.internal.param1)); |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 320 | i40e_debug(hw, mask, "\taddr (h,l) 0x%08X 0x%08X\n", |
Paul M Stillwell Jr | f1abd7d | 2015-02-06 08:52:07 +0000 | [diff] [blame] | 321 | le32_to_cpu(aq_desc->params.external.addr_high), |
| 322 | le32_to_cpu(aq_desc->params.external.addr_low)); |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 323 | |
| 324 | if ((buffer != NULL) && (aq_desc->datalen != 0)) { |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 325 | i40e_debug(hw, mask, "AQ CMD Buffer:\n"); |
Shannon Nelson | f905dd6 | 2014-07-10 07:58:20 +0000 | [diff] [blame] | 326 | if (buf_len < len) |
| 327 | len = buf_len; |
Shannon Nelson | 37a2973 | 2015-02-27 09:15:19 +0000 | [diff] [blame] | 328 | /* write the full 16-byte chunks */ |
| 329 | for (i = 0; i < (len - 16); i += 16) |
Andy Shevchenko | a3524e9 | 2015-10-02 12:18:16 +0300 | [diff] [blame] | 330 | i40e_debug(hw, mask, "\t0x%04X %16ph\n", i, buf + i); |
Shannon Nelson | 37a2973 | 2015-02-27 09:15:19 +0000 | [diff] [blame] | 331 | /* write whatever's left over without overrunning the buffer */ |
Andy Shevchenko | a3524e9 | 2015-10-02 12:18:16 +0300 | [diff] [blame] | 332 | if (i < len) |
| 333 | i40e_debug(hw, mask, "\t0x%04X %*ph\n", |
| 334 | i, len - i, buf + i); |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 335 | } |
| 336 | } |
| 337 | |
| 338 | /** |
Anjali Singhai Jain | e1860d8 | 2013-11-28 06:39:45 +0000 | [diff] [blame] | 339 | * i40e_check_asq_alive |
| 340 | * @hw: pointer to the hw struct |
| 341 | * |
| 342 | * Returns true if Queue is enabled else false. |
| 343 | **/ |
| 344 | bool i40e_check_asq_alive(struct i40e_hw *hw) |
| 345 | { |
Kevin Scott | 8b833b4 | 2014-04-09 05:58:54 +0000 | [diff] [blame] | 346 | if (hw->aq.asq.len) |
| 347 | return !!(rd32(hw, hw->aq.asq.len) & |
| 348 | I40E_PF_ATQLEN_ATQENABLE_MASK); |
| 349 | else |
| 350 | return false; |
Anjali Singhai Jain | e1860d8 | 2013-11-28 06:39:45 +0000 | [diff] [blame] | 351 | } |
| 352 | |
| 353 | /** |
| 354 | * i40e_aq_queue_shutdown |
| 355 | * @hw: pointer to the hw struct |
| 356 | * @unloading: is the driver unloading itself |
| 357 | * |
| 358 | * Tell the Firmware that we're shutting down the AdminQ and whether |
| 359 | * or not the driver is unloading as well. |
| 360 | **/ |
| 361 | i40e_status i40e_aq_queue_shutdown(struct i40e_hw *hw, |
| 362 | bool unloading) |
| 363 | { |
| 364 | struct i40e_aq_desc desc; |
| 365 | struct i40e_aqc_queue_shutdown *cmd = |
| 366 | (struct i40e_aqc_queue_shutdown *)&desc.params.raw; |
| 367 | i40e_status status; |
| 368 | |
| 369 | i40e_fill_default_direct_cmd_desc(&desc, |
| 370 | i40e_aqc_opc_queue_shutdown); |
| 371 | |
| 372 | if (unloading) |
| 373 | cmd->driver_unloading = cpu_to_le32(I40E_AQ_DRIVER_UNLOADING); |
| 374 | status = i40e_asq_send_command(hw, &desc, NULL, 0, NULL); |
| 375 | |
| 376 | return status; |
| 377 | } |
| 378 | |
Anjali Singhai Jain | e50c8d6 | 2015-06-05 12:20:27 -0400 | [diff] [blame] | 379 | /** |
| 380 | * i40e_aq_get_set_rss_lut |
| 381 | * @hw: pointer to the hardware structure |
| 382 | * @vsi_id: vsi fw index |
| 383 | * @pf_lut: for PF table set true, for VSI table set false |
| 384 | * @lut: pointer to the lut buffer provided by the caller |
| 385 | * @lut_size: size of the lut buffer |
| 386 | * @set: set true to set the table, false to get the table |
| 387 | * |
| 388 | * Internal function to get or set RSS look up table |
| 389 | **/ |
| 390 | static i40e_status i40e_aq_get_set_rss_lut(struct i40e_hw *hw, |
| 391 | u16 vsi_id, bool pf_lut, |
| 392 | u8 *lut, u16 lut_size, |
| 393 | bool set) |
| 394 | { |
| 395 | i40e_status status; |
| 396 | struct i40e_aq_desc desc; |
| 397 | struct i40e_aqc_get_set_rss_lut *cmd_resp = |
| 398 | (struct i40e_aqc_get_set_rss_lut *)&desc.params.raw; |
| 399 | |
| 400 | if (set) |
| 401 | i40e_fill_default_direct_cmd_desc(&desc, |
| 402 | i40e_aqc_opc_set_rss_lut); |
| 403 | else |
| 404 | i40e_fill_default_direct_cmd_desc(&desc, |
| 405 | i40e_aqc_opc_get_rss_lut); |
| 406 | |
| 407 | /* Indirect command */ |
| 408 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF); |
| 409 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_RD); |
| 410 | |
| 411 | cmd_resp->vsi_id = |
| 412 | cpu_to_le16((u16)((vsi_id << |
| 413 | I40E_AQC_SET_RSS_LUT_VSI_ID_SHIFT) & |
| 414 | I40E_AQC_SET_RSS_LUT_VSI_ID_MASK)); |
| 415 | cmd_resp->vsi_id |= cpu_to_le16((u16)I40E_AQC_SET_RSS_LUT_VSI_VALID); |
| 416 | |
| 417 | if (pf_lut) |
| 418 | cmd_resp->flags |= cpu_to_le16((u16) |
| 419 | ((I40E_AQC_SET_RSS_LUT_TABLE_TYPE_PF << |
| 420 | I40E_AQC_SET_RSS_LUT_TABLE_TYPE_SHIFT) & |
| 421 | I40E_AQC_SET_RSS_LUT_TABLE_TYPE_MASK)); |
| 422 | else |
| 423 | cmd_resp->flags |= cpu_to_le16((u16) |
| 424 | ((I40E_AQC_SET_RSS_LUT_TABLE_TYPE_VSI << |
| 425 | I40E_AQC_SET_RSS_LUT_TABLE_TYPE_SHIFT) & |
| 426 | I40E_AQC_SET_RSS_LUT_TABLE_TYPE_MASK)); |
| 427 | |
Anjali Singhai Jain | e50c8d6 | 2015-06-05 12:20:27 -0400 | [diff] [blame] | 428 | status = i40e_asq_send_command(hw, &desc, lut, lut_size, NULL); |
| 429 | |
| 430 | return status; |
| 431 | } |
| 432 | |
| 433 | /** |
| 434 | * i40e_aq_get_rss_lut |
| 435 | * @hw: pointer to the hardware structure |
| 436 | * @vsi_id: vsi fw index |
| 437 | * @pf_lut: for PF table set true, for VSI table set false |
| 438 | * @lut: pointer to the lut buffer provided by the caller |
| 439 | * @lut_size: size of the lut buffer |
| 440 | * |
| 441 | * get the RSS lookup table, PF or VSI type |
| 442 | **/ |
| 443 | i40e_status i40e_aq_get_rss_lut(struct i40e_hw *hw, u16 vsi_id, |
| 444 | bool pf_lut, u8 *lut, u16 lut_size) |
| 445 | { |
| 446 | return i40e_aq_get_set_rss_lut(hw, vsi_id, pf_lut, lut, lut_size, |
| 447 | false); |
| 448 | } |
| 449 | |
| 450 | /** |
| 451 | * i40e_aq_set_rss_lut |
| 452 | * @hw: pointer to the hardware structure |
| 453 | * @vsi_id: vsi fw index |
| 454 | * @pf_lut: for PF table set true, for VSI table set false |
| 455 | * @lut: pointer to the lut buffer provided by the caller |
| 456 | * @lut_size: size of the lut buffer |
| 457 | * |
| 458 | * set the RSS lookup table, PF or VSI type |
| 459 | **/ |
| 460 | i40e_status i40e_aq_set_rss_lut(struct i40e_hw *hw, u16 vsi_id, |
| 461 | bool pf_lut, u8 *lut, u16 lut_size) |
| 462 | { |
| 463 | return i40e_aq_get_set_rss_lut(hw, vsi_id, pf_lut, lut, lut_size, true); |
| 464 | } |
| 465 | |
| 466 | /** |
| 467 | * i40e_aq_get_set_rss_key |
| 468 | * @hw: pointer to the hw struct |
| 469 | * @vsi_id: vsi fw index |
| 470 | * @key: pointer to key info struct |
| 471 | * @set: set true to set the key, false to get the key |
| 472 | * |
| 473 | * get the RSS key per VSI |
| 474 | **/ |
| 475 | static i40e_status i40e_aq_get_set_rss_key(struct i40e_hw *hw, |
| 476 | u16 vsi_id, |
| 477 | struct i40e_aqc_get_set_rss_key_data *key, |
| 478 | bool set) |
| 479 | { |
| 480 | i40e_status status; |
| 481 | struct i40e_aq_desc desc; |
| 482 | struct i40e_aqc_get_set_rss_key *cmd_resp = |
| 483 | (struct i40e_aqc_get_set_rss_key *)&desc.params.raw; |
| 484 | u16 key_size = sizeof(struct i40e_aqc_get_set_rss_key_data); |
| 485 | |
| 486 | if (set) |
| 487 | i40e_fill_default_direct_cmd_desc(&desc, |
| 488 | i40e_aqc_opc_set_rss_key); |
| 489 | else |
| 490 | i40e_fill_default_direct_cmd_desc(&desc, |
| 491 | i40e_aqc_opc_get_rss_key); |
| 492 | |
| 493 | /* Indirect command */ |
| 494 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF); |
| 495 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_RD); |
| 496 | |
| 497 | cmd_resp->vsi_id = |
| 498 | cpu_to_le16((u16)((vsi_id << |
| 499 | I40E_AQC_SET_RSS_KEY_VSI_ID_SHIFT) & |
| 500 | I40E_AQC_SET_RSS_KEY_VSI_ID_MASK)); |
| 501 | cmd_resp->vsi_id |= cpu_to_le16((u16)I40E_AQC_SET_RSS_KEY_VSI_VALID); |
Anjali Singhai Jain | e50c8d6 | 2015-06-05 12:20:27 -0400 | [diff] [blame] | 502 | |
| 503 | status = i40e_asq_send_command(hw, &desc, key, key_size, NULL); |
| 504 | |
| 505 | return status; |
| 506 | } |
| 507 | |
| 508 | /** |
| 509 | * i40e_aq_get_rss_key |
| 510 | * @hw: pointer to the hw struct |
| 511 | * @vsi_id: vsi fw index |
| 512 | * @key: pointer to key info struct |
| 513 | * |
| 514 | **/ |
| 515 | i40e_status i40e_aq_get_rss_key(struct i40e_hw *hw, |
| 516 | u16 vsi_id, |
| 517 | struct i40e_aqc_get_set_rss_key_data *key) |
| 518 | { |
| 519 | return i40e_aq_get_set_rss_key(hw, vsi_id, key, false); |
| 520 | } |
| 521 | |
| 522 | /** |
| 523 | * i40e_aq_set_rss_key |
| 524 | * @hw: pointer to the hw struct |
| 525 | * @vsi_id: vsi fw index |
| 526 | * @key: pointer to key info struct |
| 527 | * |
| 528 | * set the RSS key per VSI |
| 529 | **/ |
| 530 | i40e_status i40e_aq_set_rss_key(struct i40e_hw *hw, |
| 531 | u16 vsi_id, |
| 532 | struct i40e_aqc_get_set_rss_key_data *key) |
| 533 | { |
| 534 | return i40e_aq_get_set_rss_key(hw, vsi_id, key, true); |
| 535 | } |
| 536 | |
Jesse Brandeburg | 206812b | 2014-02-12 01:45:33 +0000 | [diff] [blame] | 537 | /* The i40e_ptype_lookup table is used to convert from the 8-bit ptype in the |
| 538 | * hardware to a bit-field that can be used by SW to more easily determine the |
| 539 | * packet type. |
| 540 | * |
| 541 | * Macros are used to shorten the table lines and make this table human |
| 542 | * readable. |
| 543 | * |
| 544 | * We store the PTYPE in the top byte of the bit field - this is just so that |
| 545 | * we can check that the table doesn't have a row missing, as the index into |
| 546 | * the table should be the PTYPE. |
| 547 | * |
| 548 | * Typical work flow: |
| 549 | * |
| 550 | * IF NOT i40e_ptype_lookup[ptype].known |
| 551 | * THEN |
| 552 | * Packet is unknown |
| 553 | * ELSE IF i40e_ptype_lookup[ptype].outer_ip == I40E_RX_PTYPE_OUTER_IP |
| 554 | * Use the rest of the fields to look at the tunnels, inner protocols, etc |
| 555 | * ELSE |
| 556 | * Use the enum i40e_rx_l2_ptype to decode the packet type |
| 557 | * ENDIF |
| 558 | */ |
| 559 | |
| 560 | /* macro to make the table lines short */ |
| 561 | #define I40E_PTT(PTYPE, OUTER_IP, OUTER_IP_VER, OUTER_FRAG, T, TE, TEF, I, PL)\ |
| 562 | { PTYPE, \ |
| 563 | 1, \ |
| 564 | I40E_RX_PTYPE_OUTER_##OUTER_IP, \ |
| 565 | I40E_RX_PTYPE_OUTER_##OUTER_IP_VER, \ |
| 566 | I40E_RX_PTYPE_##OUTER_FRAG, \ |
| 567 | I40E_RX_PTYPE_TUNNEL_##T, \ |
| 568 | I40E_RX_PTYPE_TUNNEL_END_##TE, \ |
| 569 | I40E_RX_PTYPE_##TEF, \ |
| 570 | I40E_RX_PTYPE_INNER_PROT_##I, \ |
| 571 | I40E_RX_PTYPE_PAYLOAD_LAYER_##PL } |
| 572 | |
| 573 | #define I40E_PTT_UNUSED_ENTRY(PTYPE) \ |
| 574 | { PTYPE, 0, 0, 0, 0, 0, 0, 0, 0, 0 } |
| 575 | |
| 576 | /* shorter macros makes the table fit but are terse */ |
| 577 | #define I40E_RX_PTYPE_NOF I40E_RX_PTYPE_NOT_FRAG |
| 578 | #define I40E_RX_PTYPE_FRG I40E_RX_PTYPE_FRAG |
| 579 | #define I40E_RX_PTYPE_INNER_PROT_TS I40E_RX_PTYPE_INNER_PROT_TIMESYNC |
| 580 | |
| 581 | /* Lookup table mapping the HW PTYPE to the bit field for decoding */ |
| 582 | struct i40e_rx_ptype_decoded i40e_ptype_lookup[] = { |
| 583 | /* L2 Packet types */ |
| 584 | I40E_PTT_UNUSED_ENTRY(0), |
| 585 | I40E_PTT(1, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2), |
| 586 | I40E_PTT(2, L2, NONE, NOF, NONE, NONE, NOF, TS, PAY2), |
| 587 | I40E_PTT(3, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2), |
| 588 | I40E_PTT_UNUSED_ENTRY(4), |
| 589 | I40E_PTT_UNUSED_ENTRY(5), |
| 590 | I40E_PTT(6, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2), |
| 591 | I40E_PTT(7, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2), |
| 592 | I40E_PTT_UNUSED_ENTRY(8), |
| 593 | I40E_PTT_UNUSED_ENTRY(9), |
| 594 | I40E_PTT(10, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2), |
| 595 | I40E_PTT(11, L2, NONE, NOF, NONE, NONE, NOF, NONE, NONE), |
| 596 | I40E_PTT(12, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3), |
| 597 | I40E_PTT(13, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3), |
| 598 | I40E_PTT(14, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3), |
| 599 | I40E_PTT(15, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3), |
| 600 | I40E_PTT(16, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3), |
| 601 | I40E_PTT(17, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3), |
| 602 | I40E_PTT(18, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3), |
| 603 | I40E_PTT(19, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3), |
| 604 | I40E_PTT(20, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3), |
| 605 | I40E_PTT(21, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3), |
| 606 | |
| 607 | /* Non Tunneled IPv4 */ |
| 608 | I40E_PTT(22, IP, IPV4, FRG, NONE, NONE, NOF, NONE, PAY3), |
| 609 | I40E_PTT(23, IP, IPV4, NOF, NONE, NONE, NOF, NONE, PAY3), |
| 610 | I40E_PTT(24, IP, IPV4, NOF, NONE, NONE, NOF, UDP, PAY4), |
| 611 | I40E_PTT_UNUSED_ENTRY(25), |
| 612 | I40E_PTT(26, IP, IPV4, NOF, NONE, NONE, NOF, TCP, PAY4), |
| 613 | I40E_PTT(27, IP, IPV4, NOF, NONE, NONE, NOF, SCTP, PAY4), |
| 614 | I40E_PTT(28, IP, IPV4, NOF, NONE, NONE, NOF, ICMP, PAY4), |
| 615 | |
| 616 | /* IPv4 --> IPv4 */ |
| 617 | I40E_PTT(29, IP, IPV4, NOF, IP_IP, IPV4, FRG, NONE, PAY3), |
| 618 | I40E_PTT(30, IP, IPV4, NOF, IP_IP, IPV4, NOF, NONE, PAY3), |
| 619 | I40E_PTT(31, IP, IPV4, NOF, IP_IP, IPV4, NOF, UDP, PAY4), |
| 620 | I40E_PTT_UNUSED_ENTRY(32), |
| 621 | I40E_PTT(33, IP, IPV4, NOF, IP_IP, IPV4, NOF, TCP, PAY4), |
| 622 | I40E_PTT(34, IP, IPV4, NOF, IP_IP, IPV4, NOF, SCTP, PAY4), |
| 623 | I40E_PTT(35, IP, IPV4, NOF, IP_IP, IPV4, NOF, ICMP, PAY4), |
| 624 | |
| 625 | /* IPv4 --> IPv6 */ |
| 626 | I40E_PTT(36, IP, IPV4, NOF, IP_IP, IPV6, FRG, NONE, PAY3), |
| 627 | I40E_PTT(37, IP, IPV4, NOF, IP_IP, IPV6, NOF, NONE, PAY3), |
| 628 | I40E_PTT(38, IP, IPV4, NOF, IP_IP, IPV6, NOF, UDP, PAY4), |
| 629 | I40E_PTT_UNUSED_ENTRY(39), |
| 630 | I40E_PTT(40, IP, IPV4, NOF, IP_IP, IPV6, NOF, TCP, PAY4), |
| 631 | I40E_PTT(41, IP, IPV4, NOF, IP_IP, IPV6, NOF, SCTP, PAY4), |
| 632 | I40E_PTT(42, IP, IPV4, NOF, IP_IP, IPV6, NOF, ICMP, PAY4), |
| 633 | |
| 634 | /* IPv4 --> GRE/NAT */ |
| 635 | I40E_PTT(43, IP, IPV4, NOF, IP_GRENAT, NONE, NOF, NONE, PAY3), |
| 636 | |
| 637 | /* IPv4 --> GRE/NAT --> IPv4 */ |
| 638 | I40E_PTT(44, IP, IPV4, NOF, IP_GRENAT, IPV4, FRG, NONE, PAY3), |
| 639 | I40E_PTT(45, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, NONE, PAY3), |
| 640 | I40E_PTT(46, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, UDP, PAY4), |
| 641 | I40E_PTT_UNUSED_ENTRY(47), |
| 642 | I40E_PTT(48, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, TCP, PAY4), |
| 643 | I40E_PTT(49, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, SCTP, PAY4), |
| 644 | I40E_PTT(50, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, ICMP, PAY4), |
| 645 | |
| 646 | /* IPv4 --> GRE/NAT --> IPv6 */ |
| 647 | I40E_PTT(51, IP, IPV4, NOF, IP_GRENAT, IPV6, FRG, NONE, PAY3), |
| 648 | I40E_PTT(52, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, NONE, PAY3), |
| 649 | I40E_PTT(53, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, UDP, PAY4), |
| 650 | I40E_PTT_UNUSED_ENTRY(54), |
| 651 | I40E_PTT(55, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, TCP, PAY4), |
| 652 | I40E_PTT(56, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, SCTP, PAY4), |
| 653 | I40E_PTT(57, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, ICMP, PAY4), |
| 654 | |
| 655 | /* IPv4 --> GRE/NAT --> MAC */ |
| 656 | I40E_PTT(58, IP, IPV4, NOF, IP_GRENAT_MAC, NONE, NOF, NONE, PAY3), |
| 657 | |
| 658 | /* IPv4 --> GRE/NAT --> MAC --> IPv4 */ |
| 659 | I40E_PTT(59, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, FRG, NONE, PAY3), |
| 660 | I40E_PTT(60, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, NONE, PAY3), |
| 661 | I40E_PTT(61, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, UDP, PAY4), |
| 662 | I40E_PTT_UNUSED_ENTRY(62), |
| 663 | I40E_PTT(63, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, TCP, PAY4), |
| 664 | I40E_PTT(64, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, SCTP, PAY4), |
| 665 | I40E_PTT(65, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, ICMP, PAY4), |
| 666 | |
| 667 | /* IPv4 --> GRE/NAT -> MAC --> IPv6 */ |
| 668 | I40E_PTT(66, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, FRG, NONE, PAY3), |
| 669 | I40E_PTT(67, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, NONE, PAY3), |
| 670 | I40E_PTT(68, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, UDP, PAY4), |
| 671 | I40E_PTT_UNUSED_ENTRY(69), |
| 672 | I40E_PTT(70, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, TCP, PAY4), |
| 673 | I40E_PTT(71, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, SCTP, PAY4), |
| 674 | I40E_PTT(72, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, ICMP, PAY4), |
| 675 | |
| 676 | /* IPv4 --> GRE/NAT --> MAC/VLAN */ |
| 677 | I40E_PTT(73, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, NONE, NOF, NONE, PAY3), |
| 678 | |
| 679 | /* IPv4 ---> GRE/NAT -> MAC/VLAN --> IPv4 */ |
| 680 | I40E_PTT(74, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, FRG, NONE, PAY3), |
| 681 | I40E_PTT(75, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, NONE, PAY3), |
| 682 | I40E_PTT(76, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, UDP, PAY4), |
| 683 | I40E_PTT_UNUSED_ENTRY(77), |
| 684 | I40E_PTT(78, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, TCP, PAY4), |
| 685 | I40E_PTT(79, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, SCTP, PAY4), |
| 686 | I40E_PTT(80, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, ICMP, PAY4), |
| 687 | |
| 688 | /* IPv4 -> GRE/NAT -> MAC/VLAN --> IPv6 */ |
| 689 | I40E_PTT(81, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, FRG, NONE, PAY3), |
| 690 | I40E_PTT(82, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, NONE, PAY3), |
| 691 | I40E_PTT(83, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, UDP, PAY4), |
| 692 | I40E_PTT_UNUSED_ENTRY(84), |
| 693 | I40E_PTT(85, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, TCP, PAY4), |
| 694 | I40E_PTT(86, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, SCTP, PAY4), |
| 695 | I40E_PTT(87, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, ICMP, PAY4), |
| 696 | |
| 697 | /* Non Tunneled IPv6 */ |
| 698 | I40E_PTT(88, IP, IPV6, FRG, NONE, NONE, NOF, NONE, PAY3), |
| 699 | I40E_PTT(89, IP, IPV6, NOF, NONE, NONE, NOF, NONE, PAY3), |
Akeem G Abodunrin | 73df8c9 | 2016-05-03 15:13:16 -0700 | [diff] [blame] | 700 | I40E_PTT(90, IP, IPV6, NOF, NONE, NONE, NOF, UDP, PAY4), |
Jesse Brandeburg | 206812b | 2014-02-12 01:45:33 +0000 | [diff] [blame] | 701 | I40E_PTT_UNUSED_ENTRY(91), |
| 702 | I40E_PTT(92, IP, IPV6, NOF, NONE, NONE, NOF, TCP, PAY4), |
| 703 | I40E_PTT(93, IP, IPV6, NOF, NONE, NONE, NOF, SCTP, PAY4), |
| 704 | I40E_PTT(94, IP, IPV6, NOF, NONE, NONE, NOF, ICMP, PAY4), |
| 705 | |
| 706 | /* IPv6 --> IPv4 */ |
| 707 | I40E_PTT(95, IP, IPV6, NOF, IP_IP, IPV4, FRG, NONE, PAY3), |
| 708 | I40E_PTT(96, IP, IPV6, NOF, IP_IP, IPV4, NOF, NONE, PAY3), |
| 709 | I40E_PTT(97, IP, IPV6, NOF, IP_IP, IPV4, NOF, UDP, PAY4), |
| 710 | I40E_PTT_UNUSED_ENTRY(98), |
| 711 | I40E_PTT(99, IP, IPV6, NOF, IP_IP, IPV4, NOF, TCP, PAY4), |
| 712 | I40E_PTT(100, IP, IPV6, NOF, IP_IP, IPV4, NOF, SCTP, PAY4), |
| 713 | I40E_PTT(101, IP, IPV6, NOF, IP_IP, IPV4, NOF, ICMP, PAY4), |
| 714 | |
| 715 | /* IPv6 --> IPv6 */ |
| 716 | I40E_PTT(102, IP, IPV6, NOF, IP_IP, IPV6, FRG, NONE, PAY3), |
| 717 | I40E_PTT(103, IP, IPV6, NOF, IP_IP, IPV6, NOF, NONE, PAY3), |
| 718 | I40E_PTT(104, IP, IPV6, NOF, IP_IP, IPV6, NOF, UDP, PAY4), |
| 719 | I40E_PTT_UNUSED_ENTRY(105), |
| 720 | I40E_PTT(106, IP, IPV6, NOF, IP_IP, IPV6, NOF, TCP, PAY4), |
| 721 | I40E_PTT(107, IP, IPV6, NOF, IP_IP, IPV6, NOF, SCTP, PAY4), |
| 722 | I40E_PTT(108, IP, IPV6, NOF, IP_IP, IPV6, NOF, ICMP, PAY4), |
| 723 | |
| 724 | /* IPv6 --> GRE/NAT */ |
| 725 | I40E_PTT(109, IP, IPV6, NOF, IP_GRENAT, NONE, NOF, NONE, PAY3), |
| 726 | |
| 727 | /* IPv6 --> GRE/NAT -> IPv4 */ |
| 728 | I40E_PTT(110, IP, IPV6, NOF, IP_GRENAT, IPV4, FRG, NONE, PAY3), |
| 729 | I40E_PTT(111, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, NONE, PAY3), |
| 730 | I40E_PTT(112, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, UDP, PAY4), |
| 731 | I40E_PTT_UNUSED_ENTRY(113), |
| 732 | I40E_PTT(114, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, TCP, PAY4), |
| 733 | I40E_PTT(115, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, SCTP, PAY4), |
| 734 | I40E_PTT(116, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, ICMP, PAY4), |
| 735 | |
| 736 | /* IPv6 --> GRE/NAT -> IPv6 */ |
| 737 | I40E_PTT(117, IP, IPV6, NOF, IP_GRENAT, IPV6, FRG, NONE, PAY3), |
| 738 | I40E_PTT(118, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, NONE, PAY3), |
| 739 | I40E_PTT(119, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, UDP, PAY4), |
| 740 | I40E_PTT_UNUSED_ENTRY(120), |
| 741 | I40E_PTT(121, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, TCP, PAY4), |
| 742 | I40E_PTT(122, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, SCTP, PAY4), |
| 743 | I40E_PTT(123, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, ICMP, PAY4), |
| 744 | |
| 745 | /* IPv6 --> GRE/NAT -> MAC */ |
| 746 | I40E_PTT(124, IP, IPV6, NOF, IP_GRENAT_MAC, NONE, NOF, NONE, PAY3), |
| 747 | |
| 748 | /* IPv6 --> GRE/NAT -> MAC -> IPv4 */ |
| 749 | I40E_PTT(125, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, FRG, NONE, PAY3), |
| 750 | I40E_PTT(126, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, NONE, PAY3), |
| 751 | I40E_PTT(127, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, UDP, PAY4), |
| 752 | I40E_PTT_UNUSED_ENTRY(128), |
| 753 | I40E_PTT(129, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, TCP, PAY4), |
| 754 | I40E_PTT(130, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, SCTP, PAY4), |
| 755 | I40E_PTT(131, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, ICMP, PAY4), |
| 756 | |
| 757 | /* IPv6 --> GRE/NAT -> MAC -> IPv6 */ |
| 758 | I40E_PTT(132, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, FRG, NONE, PAY3), |
| 759 | I40E_PTT(133, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, NONE, PAY3), |
| 760 | I40E_PTT(134, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, UDP, PAY4), |
| 761 | I40E_PTT_UNUSED_ENTRY(135), |
| 762 | I40E_PTT(136, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, TCP, PAY4), |
| 763 | I40E_PTT(137, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, SCTP, PAY4), |
| 764 | I40E_PTT(138, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, ICMP, PAY4), |
| 765 | |
| 766 | /* IPv6 --> GRE/NAT -> MAC/VLAN */ |
| 767 | I40E_PTT(139, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, NONE, NOF, NONE, PAY3), |
| 768 | |
| 769 | /* IPv6 --> GRE/NAT -> MAC/VLAN --> IPv4 */ |
| 770 | I40E_PTT(140, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, FRG, NONE, PAY3), |
| 771 | I40E_PTT(141, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, NONE, PAY3), |
| 772 | I40E_PTT(142, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, UDP, PAY4), |
| 773 | I40E_PTT_UNUSED_ENTRY(143), |
| 774 | I40E_PTT(144, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, TCP, PAY4), |
| 775 | I40E_PTT(145, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, SCTP, PAY4), |
| 776 | I40E_PTT(146, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, ICMP, PAY4), |
| 777 | |
| 778 | /* IPv6 --> GRE/NAT -> MAC/VLAN --> IPv6 */ |
| 779 | I40E_PTT(147, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, FRG, NONE, PAY3), |
| 780 | I40E_PTT(148, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, NONE, PAY3), |
| 781 | I40E_PTT(149, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, UDP, PAY4), |
| 782 | I40E_PTT_UNUSED_ENTRY(150), |
| 783 | I40E_PTT(151, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, TCP, PAY4), |
| 784 | I40E_PTT(152, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, SCTP, PAY4), |
| 785 | I40E_PTT(153, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, ICMP, PAY4), |
| 786 | |
| 787 | /* unused entries */ |
| 788 | I40E_PTT_UNUSED_ENTRY(154), |
| 789 | I40E_PTT_UNUSED_ENTRY(155), |
| 790 | I40E_PTT_UNUSED_ENTRY(156), |
| 791 | I40E_PTT_UNUSED_ENTRY(157), |
| 792 | I40E_PTT_UNUSED_ENTRY(158), |
| 793 | I40E_PTT_UNUSED_ENTRY(159), |
| 794 | |
| 795 | I40E_PTT_UNUSED_ENTRY(160), |
| 796 | I40E_PTT_UNUSED_ENTRY(161), |
| 797 | I40E_PTT_UNUSED_ENTRY(162), |
| 798 | I40E_PTT_UNUSED_ENTRY(163), |
| 799 | I40E_PTT_UNUSED_ENTRY(164), |
| 800 | I40E_PTT_UNUSED_ENTRY(165), |
| 801 | I40E_PTT_UNUSED_ENTRY(166), |
| 802 | I40E_PTT_UNUSED_ENTRY(167), |
| 803 | I40E_PTT_UNUSED_ENTRY(168), |
| 804 | I40E_PTT_UNUSED_ENTRY(169), |
| 805 | |
| 806 | I40E_PTT_UNUSED_ENTRY(170), |
| 807 | I40E_PTT_UNUSED_ENTRY(171), |
| 808 | I40E_PTT_UNUSED_ENTRY(172), |
| 809 | I40E_PTT_UNUSED_ENTRY(173), |
| 810 | I40E_PTT_UNUSED_ENTRY(174), |
| 811 | I40E_PTT_UNUSED_ENTRY(175), |
| 812 | I40E_PTT_UNUSED_ENTRY(176), |
| 813 | I40E_PTT_UNUSED_ENTRY(177), |
| 814 | I40E_PTT_UNUSED_ENTRY(178), |
| 815 | I40E_PTT_UNUSED_ENTRY(179), |
| 816 | |
| 817 | I40E_PTT_UNUSED_ENTRY(180), |
| 818 | I40E_PTT_UNUSED_ENTRY(181), |
| 819 | I40E_PTT_UNUSED_ENTRY(182), |
| 820 | I40E_PTT_UNUSED_ENTRY(183), |
| 821 | I40E_PTT_UNUSED_ENTRY(184), |
| 822 | I40E_PTT_UNUSED_ENTRY(185), |
| 823 | I40E_PTT_UNUSED_ENTRY(186), |
| 824 | I40E_PTT_UNUSED_ENTRY(187), |
| 825 | I40E_PTT_UNUSED_ENTRY(188), |
| 826 | I40E_PTT_UNUSED_ENTRY(189), |
| 827 | |
| 828 | I40E_PTT_UNUSED_ENTRY(190), |
| 829 | I40E_PTT_UNUSED_ENTRY(191), |
| 830 | I40E_PTT_UNUSED_ENTRY(192), |
| 831 | I40E_PTT_UNUSED_ENTRY(193), |
| 832 | I40E_PTT_UNUSED_ENTRY(194), |
| 833 | I40E_PTT_UNUSED_ENTRY(195), |
| 834 | I40E_PTT_UNUSED_ENTRY(196), |
| 835 | I40E_PTT_UNUSED_ENTRY(197), |
| 836 | I40E_PTT_UNUSED_ENTRY(198), |
| 837 | I40E_PTT_UNUSED_ENTRY(199), |
| 838 | |
| 839 | I40E_PTT_UNUSED_ENTRY(200), |
| 840 | I40E_PTT_UNUSED_ENTRY(201), |
| 841 | I40E_PTT_UNUSED_ENTRY(202), |
| 842 | I40E_PTT_UNUSED_ENTRY(203), |
| 843 | I40E_PTT_UNUSED_ENTRY(204), |
| 844 | I40E_PTT_UNUSED_ENTRY(205), |
| 845 | I40E_PTT_UNUSED_ENTRY(206), |
| 846 | I40E_PTT_UNUSED_ENTRY(207), |
| 847 | I40E_PTT_UNUSED_ENTRY(208), |
| 848 | I40E_PTT_UNUSED_ENTRY(209), |
| 849 | |
| 850 | I40E_PTT_UNUSED_ENTRY(210), |
| 851 | I40E_PTT_UNUSED_ENTRY(211), |
| 852 | I40E_PTT_UNUSED_ENTRY(212), |
| 853 | I40E_PTT_UNUSED_ENTRY(213), |
| 854 | I40E_PTT_UNUSED_ENTRY(214), |
| 855 | I40E_PTT_UNUSED_ENTRY(215), |
| 856 | I40E_PTT_UNUSED_ENTRY(216), |
| 857 | I40E_PTT_UNUSED_ENTRY(217), |
| 858 | I40E_PTT_UNUSED_ENTRY(218), |
| 859 | I40E_PTT_UNUSED_ENTRY(219), |
| 860 | |
| 861 | I40E_PTT_UNUSED_ENTRY(220), |
| 862 | I40E_PTT_UNUSED_ENTRY(221), |
| 863 | I40E_PTT_UNUSED_ENTRY(222), |
| 864 | I40E_PTT_UNUSED_ENTRY(223), |
| 865 | I40E_PTT_UNUSED_ENTRY(224), |
| 866 | I40E_PTT_UNUSED_ENTRY(225), |
| 867 | I40E_PTT_UNUSED_ENTRY(226), |
| 868 | I40E_PTT_UNUSED_ENTRY(227), |
| 869 | I40E_PTT_UNUSED_ENTRY(228), |
| 870 | I40E_PTT_UNUSED_ENTRY(229), |
| 871 | |
| 872 | I40E_PTT_UNUSED_ENTRY(230), |
| 873 | I40E_PTT_UNUSED_ENTRY(231), |
| 874 | I40E_PTT_UNUSED_ENTRY(232), |
| 875 | I40E_PTT_UNUSED_ENTRY(233), |
| 876 | I40E_PTT_UNUSED_ENTRY(234), |
| 877 | I40E_PTT_UNUSED_ENTRY(235), |
| 878 | I40E_PTT_UNUSED_ENTRY(236), |
| 879 | I40E_PTT_UNUSED_ENTRY(237), |
| 880 | I40E_PTT_UNUSED_ENTRY(238), |
| 881 | I40E_PTT_UNUSED_ENTRY(239), |
| 882 | |
| 883 | I40E_PTT_UNUSED_ENTRY(240), |
| 884 | I40E_PTT_UNUSED_ENTRY(241), |
| 885 | I40E_PTT_UNUSED_ENTRY(242), |
| 886 | I40E_PTT_UNUSED_ENTRY(243), |
| 887 | I40E_PTT_UNUSED_ENTRY(244), |
| 888 | I40E_PTT_UNUSED_ENTRY(245), |
| 889 | I40E_PTT_UNUSED_ENTRY(246), |
| 890 | I40E_PTT_UNUSED_ENTRY(247), |
| 891 | I40E_PTT_UNUSED_ENTRY(248), |
| 892 | I40E_PTT_UNUSED_ENTRY(249), |
| 893 | |
| 894 | I40E_PTT_UNUSED_ENTRY(250), |
| 895 | I40E_PTT_UNUSED_ENTRY(251), |
| 896 | I40E_PTT_UNUSED_ENTRY(252), |
| 897 | I40E_PTT_UNUSED_ENTRY(253), |
| 898 | I40E_PTT_UNUSED_ENTRY(254), |
| 899 | I40E_PTT_UNUSED_ENTRY(255) |
| 900 | }; |
| 901 | |
Anjali Singhai Jain | e1860d8 | 2013-11-28 06:39:45 +0000 | [diff] [blame] | 902 | /** |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 903 | * i40e_init_shared_code - Initialize the shared code |
| 904 | * @hw: pointer to hardware structure |
| 905 | * |
| 906 | * This assigns the MAC type and PHY code and inits the NVM. |
| 907 | * Does not touch the hardware. This function must be called prior to any |
| 908 | * other function in the shared code. The i40e_hw structure should be |
| 909 | * memset to 0 prior to calling this function. The following fields in |
| 910 | * hw structure should be filled in prior to calling this function: |
| 911 | * hw_addr, back, device_id, vendor_id, subsystem_device_id, |
| 912 | * subsystem_vendor_id, and revision_id |
| 913 | **/ |
| 914 | i40e_status i40e_init_shared_code(struct i40e_hw *hw) |
| 915 | { |
| 916 | i40e_status status = 0; |
Shannon Nelson | 5fb11d7 | 2014-11-13 03:06:19 +0000 | [diff] [blame] | 917 | u32 port, ari, func_rid; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 918 | |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 919 | i40e_set_mac_type(hw); |
| 920 | |
| 921 | switch (hw->mac.type) { |
| 922 | case I40E_MAC_XL710: |
Anjali Singhai Jain | 87e6c1d | 2015-06-05 12:20:25 -0400 | [diff] [blame] | 923 | case I40E_MAC_X722: |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 924 | break; |
| 925 | default: |
| 926 | return I40E_ERR_DEVICE_NOT_SUPPORTED; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 927 | } |
| 928 | |
Shannon Nelson | af89d26c | 2013-12-11 08:17:14 +0000 | [diff] [blame] | 929 | hw->phy.get_link_info = true; |
| 930 | |
Shannon Nelson | 5fb11d7 | 2014-11-13 03:06:19 +0000 | [diff] [blame] | 931 | /* Determine port number and PF number*/ |
| 932 | port = (rd32(hw, I40E_PFGEN_PORTNUM) & I40E_PFGEN_PORTNUM_PORT_NUM_MASK) |
| 933 | >> I40E_PFGEN_PORTNUM_PORT_NUM_SHIFT; |
| 934 | hw->port = (u8)port; |
| 935 | ari = (rd32(hw, I40E_GLPCI_CAPSUP) & I40E_GLPCI_CAPSUP_ARI_EN_MASK) >> |
| 936 | I40E_GLPCI_CAPSUP_ARI_EN_SHIFT; |
| 937 | func_rid = rd32(hw, I40E_PF_FUNC_RID); |
| 938 | if (ari) |
| 939 | hw->pf_id = (u8)(func_rid & 0xff); |
Shannon Nelson | 5f9116a | 2013-12-11 08:17:13 +0000 | [diff] [blame] | 940 | else |
Shannon Nelson | 5fb11d7 | 2014-11-13 03:06:19 +0000 | [diff] [blame] | 941 | hw->pf_id = (u8)(func_rid & 0x7); |
Shannon Nelson | 5f9116a | 2013-12-11 08:17:13 +0000 | [diff] [blame] | 942 | |
Anjali Singhai | 07f89be | 2015-09-24 15:26:32 -0700 | [diff] [blame] | 943 | if (hw->mac.type == I40E_MAC_X722) |
| 944 | hw->flags |= I40E_HW_FLAG_AQ_SRCTL_ACCESS_ENABLE; |
| 945 | |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 946 | status = i40e_init_nvm(hw); |
| 947 | return status; |
| 948 | } |
| 949 | |
| 950 | /** |
| 951 | * i40e_aq_mac_address_read - Retrieve the MAC addresses |
| 952 | * @hw: pointer to the hw struct |
| 953 | * @flags: a return indicator of what addresses were added to the addr store |
| 954 | * @addrs: the requestor's mac addr store |
| 955 | * @cmd_details: pointer to command details structure or NULL |
| 956 | **/ |
| 957 | static i40e_status i40e_aq_mac_address_read(struct i40e_hw *hw, |
| 958 | u16 *flags, |
| 959 | struct i40e_aqc_mac_address_read_data *addrs, |
| 960 | struct i40e_asq_cmd_details *cmd_details) |
| 961 | { |
| 962 | struct i40e_aq_desc desc; |
| 963 | struct i40e_aqc_mac_address_read *cmd_data = |
| 964 | (struct i40e_aqc_mac_address_read *)&desc.params.raw; |
| 965 | i40e_status status; |
| 966 | |
| 967 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_mac_address_read); |
| 968 | desc.flags |= cpu_to_le16(I40E_AQ_FLAG_BUF); |
| 969 | |
| 970 | status = i40e_asq_send_command(hw, &desc, addrs, |
| 971 | sizeof(*addrs), cmd_details); |
| 972 | *flags = le16_to_cpu(cmd_data->command_flags); |
| 973 | |
| 974 | return status; |
| 975 | } |
| 976 | |
| 977 | /** |
| 978 | * i40e_aq_mac_address_write - Change the MAC addresses |
| 979 | * @hw: pointer to the hw struct |
| 980 | * @flags: indicates which MAC to be written |
| 981 | * @mac_addr: address to write |
| 982 | * @cmd_details: pointer to command details structure or NULL |
| 983 | **/ |
| 984 | i40e_status i40e_aq_mac_address_write(struct i40e_hw *hw, |
| 985 | u16 flags, u8 *mac_addr, |
| 986 | struct i40e_asq_cmd_details *cmd_details) |
| 987 | { |
| 988 | struct i40e_aq_desc desc; |
| 989 | struct i40e_aqc_mac_address_write *cmd_data = |
| 990 | (struct i40e_aqc_mac_address_write *)&desc.params.raw; |
| 991 | i40e_status status; |
| 992 | |
| 993 | i40e_fill_default_direct_cmd_desc(&desc, |
| 994 | i40e_aqc_opc_mac_address_write); |
| 995 | cmd_data->command_flags = cpu_to_le16(flags); |
Kamil Krawczyk | 55c29c3 | 2013-12-18 13:45:52 +0000 | [diff] [blame] | 996 | cmd_data->mac_sah = cpu_to_le16((u16)mac_addr[0] << 8 | mac_addr[1]); |
| 997 | cmd_data->mac_sal = cpu_to_le32(((u32)mac_addr[2] << 24) | |
| 998 | ((u32)mac_addr[3] << 16) | |
| 999 | ((u32)mac_addr[4] << 8) | |
| 1000 | mac_addr[5]); |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1001 | |
| 1002 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 1003 | |
| 1004 | return status; |
| 1005 | } |
| 1006 | |
| 1007 | /** |
| 1008 | * i40e_get_mac_addr - get MAC address |
| 1009 | * @hw: pointer to the HW structure |
| 1010 | * @mac_addr: pointer to MAC address |
| 1011 | * |
| 1012 | * Reads the adapter's MAC address from register |
| 1013 | **/ |
| 1014 | i40e_status i40e_get_mac_addr(struct i40e_hw *hw, u8 *mac_addr) |
| 1015 | { |
| 1016 | struct i40e_aqc_mac_address_read_data addrs; |
| 1017 | i40e_status status; |
| 1018 | u16 flags = 0; |
| 1019 | |
| 1020 | status = i40e_aq_mac_address_read(hw, &flags, &addrs, NULL); |
| 1021 | |
| 1022 | if (flags & I40E_AQC_LAN_ADDR_VALID) |
Jesse Brandeburg | 6995b36 | 2015-08-28 17:55:54 -0400 | [diff] [blame] | 1023 | ether_addr_copy(mac_addr, addrs.pf_lan_mac); |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1024 | |
| 1025 | return status; |
| 1026 | } |
| 1027 | |
| 1028 | /** |
Neerav Parikh | 1f224ad | 2014-02-12 01:45:31 +0000 | [diff] [blame] | 1029 | * i40e_get_port_mac_addr - get Port MAC address |
| 1030 | * @hw: pointer to the HW structure |
| 1031 | * @mac_addr: pointer to Port MAC address |
| 1032 | * |
| 1033 | * Reads the adapter's Port MAC address |
| 1034 | **/ |
| 1035 | i40e_status i40e_get_port_mac_addr(struct i40e_hw *hw, u8 *mac_addr) |
| 1036 | { |
| 1037 | struct i40e_aqc_mac_address_read_data addrs; |
| 1038 | i40e_status status; |
| 1039 | u16 flags = 0; |
| 1040 | |
| 1041 | status = i40e_aq_mac_address_read(hw, &flags, &addrs, NULL); |
| 1042 | if (status) |
| 1043 | return status; |
| 1044 | |
| 1045 | if (flags & I40E_AQC_PORT_ADDR_VALID) |
Jesse Brandeburg | 6995b36 | 2015-08-28 17:55:54 -0400 | [diff] [blame] | 1046 | ether_addr_copy(mac_addr, addrs.port_mac); |
Neerav Parikh | 1f224ad | 2014-02-12 01:45:31 +0000 | [diff] [blame] | 1047 | else |
| 1048 | status = I40E_ERR_INVALID_MAC_ADDR; |
| 1049 | |
| 1050 | return status; |
| 1051 | } |
| 1052 | |
| 1053 | /** |
Matt Jared | 351499ab | 2014-04-23 04:50:03 +0000 | [diff] [blame] | 1054 | * i40e_pre_tx_queue_cfg - pre tx queue configure |
| 1055 | * @hw: pointer to the HW structure |
Jeff Kirsher | b40c82e | 2015-02-27 09:18:34 +0000 | [diff] [blame] | 1056 | * @queue: target PF queue index |
Matt Jared | 351499ab | 2014-04-23 04:50:03 +0000 | [diff] [blame] | 1057 | * @enable: state change request |
| 1058 | * |
| 1059 | * Handles hw requirement to indicate intention to enable |
| 1060 | * or disable target queue. |
| 1061 | **/ |
| 1062 | void i40e_pre_tx_queue_cfg(struct i40e_hw *hw, u32 queue, bool enable) |
| 1063 | { |
Shannon Nelson | dfb699f | 2014-05-22 06:32:28 +0000 | [diff] [blame] | 1064 | u32 abs_queue_idx = hw->func_caps.base_queue + queue; |
Matt Jared | 351499ab | 2014-04-23 04:50:03 +0000 | [diff] [blame] | 1065 | u32 reg_block = 0; |
Shannon Nelson | dfb699f | 2014-05-22 06:32:28 +0000 | [diff] [blame] | 1066 | u32 reg_val; |
Matt Jared | 351499ab | 2014-04-23 04:50:03 +0000 | [diff] [blame] | 1067 | |
Christopher Pau | 24a768c | 2014-06-04 20:41:59 +0000 | [diff] [blame] | 1068 | if (abs_queue_idx >= 128) { |
Matt Jared | 351499ab | 2014-04-23 04:50:03 +0000 | [diff] [blame] | 1069 | reg_block = abs_queue_idx / 128; |
Christopher Pau | 24a768c | 2014-06-04 20:41:59 +0000 | [diff] [blame] | 1070 | abs_queue_idx %= 128; |
| 1071 | } |
Matt Jared | 351499ab | 2014-04-23 04:50:03 +0000 | [diff] [blame] | 1072 | |
| 1073 | reg_val = rd32(hw, I40E_GLLAN_TXPRE_QDIS(reg_block)); |
| 1074 | reg_val &= ~I40E_GLLAN_TXPRE_QDIS_QINDX_MASK; |
| 1075 | reg_val |= (abs_queue_idx << I40E_GLLAN_TXPRE_QDIS_QINDX_SHIFT); |
| 1076 | |
| 1077 | if (enable) |
| 1078 | reg_val |= I40E_GLLAN_TXPRE_QDIS_CLEAR_QDIS_MASK; |
| 1079 | else |
| 1080 | reg_val |= I40E_GLLAN_TXPRE_QDIS_SET_QDIS_MASK; |
| 1081 | |
| 1082 | wr32(hw, I40E_GLLAN_TXPRE_QDIS(reg_block), reg_val); |
| 1083 | } |
Vasu Dev | 38e0043 | 2014-08-01 13:27:03 -0700 | [diff] [blame] | 1084 | #ifdef I40E_FCOE |
| 1085 | |
| 1086 | /** |
| 1087 | * i40e_get_san_mac_addr - get SAN MAC address |
| 1088 | * @hw: pointer to the HW structure |
| 1089 | * @mac_addr: pointer to SAN MAC address |
| 1090 | * |
| 1091 | * Reads the adapter's SAN MAC address from NVM |
| 1092 | **/ |
| 1093 | i40e_status i40e_get_san_mac_addr(struct i40e_hw *hw, u8 *mac_addr) |
| 1094 | { |
| 1095 | struct i40e_aqc_mac_address_read_data addrs; |
| 1096 | i40e_status status; |
| 1097 | u16 flags = 0; |
| 1098 | |
| 1099 | status = i40e_aq_mac_address_read(hw, &flags, &addrs, NULL); |
| 1100 | if (status) |
| 1101 | return status; |
| 1102 | |
| 1103 | if (flags & I40E_AQC_SAN_ADDR_VALID) |
Jesse Brandeburg | 6995b36 | 2015-08-28 17:55:54 -0400 | [diff] [blame] | 1104 | ether_addr_copy(mac_addr, addrs.pf_san_mac); |
Vasu Dev | 38e0043 | 2014-08-01 13:27:03 -0700 | [diff] [blame] | 1105 | else |
| 1106 | status = I40E_ERR_INVALID_MAC_ADDR; |
| 1107 | |
| 1108 | return status; |
| 1109 | } |
| 1110 | #endif |
Matt Jared | 351499ab | 2014-04-23 04:50:03 +0000 | [diff] [blame] | 1111 | |
| 1112 | /** |
Kamil Krawczyk | 18f680c | 2014-12-11 07:06:31 +0000 | [diff] [blame] | 1113 | * i40e_read_pba_string - Reads part number string from EEPROM |
| 1114 | * @hw: pointer to hardware structure |
| 1115 | * @pba_num: stores the part number string from the EEPROM |
| 1116 | * @pba_num_size: part number string buffer length |
| 1117 | * |
| 1118 | * Reads the part number string from the EEPROM. |
| 1119 | **/ |
| 1120 | i40e_status i40e_read_pba_string(struct i40e_hw *hw, u8 *pba_num, |
| 1121 | u32 pba_num_size) |
| 1122 | { |
| 1123 | i40e_status status = 0; |
| 1124 | u16 pba_word = 0; |
| 1125 | u16 pba_size = 0; |
| 1126 | u16 pba_ptr = 0; |
| 1127 | u16 i = 0; |
| 1128 | |
| 1129 | status = i40e_read_nvm_word(hw, I40E_SR_PBA_FLAGS, &pba_word); |
| 1130 | if (status || (pba_word != 0xFAFA)) { |
| 1131 | hw_dbg(hw, "Failed to read PBA flags or flag is invalid.\n"); |
| 1132 | return status; |
| 1133 | } |
| 1134 | |
| 1135 | status = i40e_read_nvm_word(hw, I40E_SR_PBA_BLOCK_PTR, &pba_ptr); |
| 1136 | if (status) { |
| 1137 | hw_dbg(hw, "Failed to read PBA Block pointer.\n"); |
| 1138 | return status; |
| 1139 | } |
| 1140 | |
| 1141 | status = i40e_read_nvm_word(hw, pba_ptr, &pba_size); |
| 1142 | if (status) { |
| 1143 | hw_dbg(hw, "Failed to read PBA Block size.\n"); |
| 1144 | return status; |
| 1145 | } |
| 1146 | |
| 1147 | /* Subtract one to get PBA word count (PBA Size word is included in |
| 1148 | * total size) |
| 1149 | */ |
| 1150 | pba_size--; |
| 1151 | if (pba_num_size < (((u32)pba_size * 2) + 1)) { |
| 1152 | hw_dbg(hw, "Buffer to small for PBA data.\n"); |
| 1153 | return I40E_ERR_PARAM; |
| 1154 | } |
| 1155 | |
| 1156 | for (i = 0; i < pba_size; i++) { |
| 1157 | status = i40e_read_nvm_word(hw, (pba_ptr + 1) + i, &pba_word); |
| 1158 | if (status) { |
| 1159 | hw_dbg(hw, "Failed to read PBA Block word %d.\n", i); |
| 1160 | return status; |
| 1161 | } |
| 1162 | |
| 1163 | pba_num[(i * 2)] = (pba_word >> 8) & 0xFF; |
| 1164 | pba_num[(i * 2) + 1] = pba_word & 0xFF; |
| 1165 | } |
| 1166 | pba_num[(pba_size * 2)] = '\0'; |
| 1167 | |
| 1168 | return status; |
| 1169 | } |
| 1170 | |
| 1171 | /** |
Jesse Brandeburg | be405eb | 2013-11-20 10:02:50 +0000 | [diff] [blame] | 1172 | * i40e_get_media_type - Gets media type |
| 1173 | * @hw: pointer to the hardware structure |
| 1174 | **/ |
| 1175 | static enum i40e_media_type i40e_get_media_type(struct i40e_hw *hw) |
| 1176 | { |
| 1177 | enum i40e_media_type media; |
| 1178 | |
| 1179 | switch (hw->phy.link_info.phy_type) { |
| 1180 | case I40E_PHY_TYPE_10GBASE_SR: |
| 1181 | case I40E_PHY_TYPE_10GBASE_LR: |
Catherine Sullivan | 124ed15 | 2014-07-12 07:28:12 +0000 | [diff] [blame] | 1182 | case I40E_PHY_TYPE_1000BASE_SX: |
| 1183 | case I40E_PHY_TYPE_1000BASE_LX: |
Jesse Brandeburg | be405eb | 2013-11-20 10:02:50 +0000 | [diff] [blame] | 1184 | case I40E_PHY_TYPE_40GBASE_SR4: |
| 1185 | case I40E_PHY_TYPE_40GBASE_LR4: |
| 1186 | media = I40E_MEDIA_TYPE_FIBER; |
| 1187 | break; |
| 1188 | case I40E_PHY_TYPE_100BASE_TX: |
| 1189 | case I40E_PHY_TYPE_1000BASE_T: |
| 1190 | case I40E_PHY_TYPE_10GBASE_T: |
| 1191 | media = I40E_MEDIA_TYPE_BASET; |
| 1192 | break; |
| 1193 | case I40E_PHY_TYPE_10GBASE_CR1_CU: |
| 1194 | case I40E_PHY_TYPE_40GBASE_CR4_CU: |
| 1195 | case I40E_PHY_TYPE_10GBASE_CR1: |
| 1196 | case I40E_PHY_TYPE_40GBASE_CR4: |
| 1197 | case I40E_PHY_TYPE_10GBASE_SFPP_CU: |
Catherine Sullivan | 180204c | 2015-02-26 16:14:58 +0000 | [diff] [blame] | 1198 | case I40E_PHY_TYPE_40GBASE_AOC: |
| 1199 | case I40E_PHY_TYPE_10GBASE_AOC: |
Jesse Brandeburg | be405eb | 2013-11-20 10:02:50 +0000 | [diff] [blame] | 1200 | media = I40E_MEDIA_TYPE_DA; |
| 1201 | break; |
| 1202 | case I40E_PHY_TYPE_1000BASE_KX: |
| 1203 | case I40E_PHY_TYPE_10GBASE_KX4: |
| 1204 | case I40E_PHY_TYPE_10GBASE_KR: |
| 1205 | case I40E_PHY_TYPE_40GBASE_KR4: |
Jesse Brandeburg | ae24b40 | 2015-03-27 00:12:09 -0700 | [diff] [blame] | 1206 | case I40E_PHY_TYPE_20GBASE_KR2: |
Jesse Brandeburg | be405eb | 2013-11-20 10:02:50 +0000 | [diff] [blame] | 1207 | media = I40E_MEDIA_TYPE_BACKPLANE; |
| 1208 | break; |
| 1209 | case I40E_PHY_TYPE_SGMII: |
| 1210 | case I40E_PHY_TYPE_XAUI: |
| 1211 | case I40E_PHY_TYPE_XFI: |
| 1212 | case I40E_PHY_TYPE_XLAUI: |
| 1213 | case I40E_PHY_TYPE_XLPPI: |
| 1214 | default: |
| 1215 | media = I40E_MEDIA_TYPE_UNKNOWN; |
| 1216 | break; |
| 1217 | } |
| 1218 | |
| 1219 | return media; |
| 1220 | } |
| 1221 | |
Jesse Brandeburg | 7134f9c | 2013-11-26 08:56:05 +0000 | [diff] [blame] | 1222 | #define I40E_PF_RESET_WAIT_COUNT_A0 200 |
Akeem G Abodunrin | 8af580d | 2015-03-27 00:12:10 -0700 | [diff] [blame] | 1223 | #define I40E_PF_RESET_WAIT_COUNT 200 |
Jesse Brandeburg | be405eb | 2013-11-20 10:02:50 +0000 | [diff] [blame] | 1224 | /** |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1225 | * i40e_pf_reset - Reset the PF |
| 1226 | * @hw: pointer to the hardware structure |
| 1227 | * |
| 1228 | * Assuming someone else has triggered a global reset, |
| 1229 | * assure the global reset is complete and then reset the PF |
| 1230 | **/ |
| 1231 | i40e_status i40e_pf_reset(struct i40e_hw *hw) |
| 1232 | { |
Jesse Brandeburg | 7134f9c | 2013-11-26 08:56:05 +0000 | [diff] [blame] | 1233 | u32 cnt = 0; |
Shannon Nelson | 42794bd | 2013-12-11 08:17:10 +0000 | [diff] [blame] | 1234 | u32 cnt1 = 0; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1235 | u32 reg = 0; |
| 1236 | u32 grst_del; |
| 1237 | |
| 1238 | /* Poll for Global Reset steady state in case of recent GRST. |
| 1239 | * The grst delay value is in 100ms units, and we'll wait a |
| 1240 | * couple counts longer to be sure we don't just miss the end. |
| 1241 | */ |
Shannon Nelson | de78fc5 | 2015-02-21 06:41:47 +0000 | [diff] [blame] | 1242 | grst_del = (rd32(hw, I40E_GLGEN_RSTCTL) & |
| 1243 | I40E_GLGEN_RSTCTL_GRSTDEL_MASK) >> |
| 1244 | I40E_GLGEN_RSTCTL_GRSTDEL_SHIFT; |
Kevin Scott | 4d7cec0 | 2016-02-17 16:12:13 -0800 | [diff] [blame] | 1245 | |
| 1246 | /* It can take upto 15 secs for GRST steady state. |
| 1247 | * Bump it to 16 secs max to be safe. |
| 1248 | */ |
| 1249 | grst_del = grst_del * 20; |
| 1250 | |
| 1251 | for (cnt = 0; cnt < grst_del; cnt++) { |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1252 | reg = rd32(hw, I40E_GLGEN_RSTAT); |
| 1253 | if (!(reg & I40E_GLGEN_RSTAT_DEVSTATE_MASK)) |
| 1254 | break; |
| 1255 | msleep(100); |
| 1256 | } |
| 1257 | if (reg & I40E_GLGEN_RSTAT_DEVSTATE_MASK) { |
| 1258 | hw_dbg(hw, "Global reset polling failed to complete.\n"); |
| 1259 | return I40E_ERR_RESET_FAILED; |
| 1260 | } |
| 1261 | |
Shannon Nelson | 42794bd | 2013-12-11 08:17:10 +0000 | [diff] [blame] | 1262 | /* Now Wait for the FW to be ready */ |
| 1263 | for (cnt1 = 0; cnt1 < I40E_PF_RESET_WAIT_COUNT; cnt1++) { |
| 1264 | reg = rd32(hw, I40E_GLNVM_ULD); |
| 1265 | reg &= (I40E_GLNVM_ULD_CONF_CORE_DONE_MASK | |
| 1266 | I40E_GLNVM_ULD_CONF_GLOBAL_DONE_MASK); |
| 1267 | if (reg == (I40E_GLNVM_ULD_CONF_CORE_DONE_MASK | |
| 1268 | I40E_GLNVM_ULD_CONF_GLOBAL_DONE_MASK)) { |
| 1269 | hw_dbg(hw, "Core and Global modules ready %d\n", cnt1); |
| 1270 | break; |
| 1271 | } |
| 1272 | usleep_range(10000, 20000); |
| 1273 | } |
| 1274 | if (!(reg & (I40E_GLNVM_ULD_CONF_CORE_DONE_MASK | |
| 1275 | I40E_GLNVM_ULD_CONF_GLOBAL_DONE_MASK))) { |
| 1276 | hw_dbg(hw, "wait for FW Reset complete timedout\n"); |
| 1277 | hw_dbg(hw, "I40E_GLNVM_ULD = 0x%x\n", reg); |
| 1278 | return I40E_ERR_RESET_FAILED; |
| 1279 | } |
| 1280 | |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1281 | /* If there was a Global Reset in progress when we got here, |
| 1282 | * we don't need to do the PF Reset |
| 1283 | */ |
Jesse Brandeburg | 7134f9c | 2013-11-26 08:56:05 +0000 | [diff] [blame] | 1284 | if (!cnt) { |
| 1285 | if (hw->revision_id == 0) |
| 1286 | cnt = I40E_PF_RESET_WAIT_COUNT_A0; |
| 1287 | else |
| 1288 | cnt = I40E_PF_RESET_WAIT_COUNT; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1289 | reg = rd32(hw, I40E_PFGEN_CTRL); |
| 1290 | wr32(hw, I40E_PFGEN_CTRL, |
| 1291 | (reg | I40E_PFGEN_CTRL_PFSWR_MASK)); |
Jesse Brandeburg | 7134f9c | 2013-11-26 08:56:05 +0000 | [diff] [blame] | 1292 | for (; cnt; cnt--) { |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1293 | reg = rd32(hw, I40E_PFGEN_CTRL); |
| 1294 | if (!(reg & I40E_PFGEN_CTRL_PFSWR_MASK)) |
| 1295 | break; |
| 1296 | usleep_range(1000, 2000); |
| 1297 | } |
| 1298 | if (reg & I40E_PFGEN_CTRL_PFSWR_MASK) { |
| 1299 | hw_dbg(hw, "PF reset polling failed to complete.\n"); |
| 1300 | return I40E_ERR_RESET_FAILED; |
| 1301 | } |
| 1302 | } |
| 1303 | |
| 1304 | i40e_clear_pxe_mode(hw); |
Shannon Nelson | 922680b | 2013-12-18 05:29:17 +0000 | [diff] [blame] | 1305 | |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1306 | return 0; |
| 1307 | } |
| 1308 | |
| 1309 | /** |
Shannon Nelson | 838d41d | 2014-06-04 20:41:27 +0000 | [diff] [blame] | 1310 | * i40e_clear_hw - clear out any left over hw state |
| 1311 | * @hw: pointer to the hw struct |
| 1312 | * |
| 1313 | * Clear queues and interrupts, typically called at init time, |
| 1314 | * but after the capabilities have been found so we know how many |
| 1315 | * queues and msix vectors have been allocated. |
| 1316 | **/ |
| 1317 | void i40e_clear_hw(struct i40e_hw *hw) |
| 1318 | { |
| 1319 | u32 num_queues, base_queue; |
| 1320 | u32 num_pf_int; |
| 1321 | u32 num_vf_int; |
| 1322 | u32 num_vfs; |
| 1323 | u32 i, j; |
| 1324 | u32 val; |
| 1325 | u32 eol = 0x7ff; |
| 1326 | |
Jeff Kirsher | b40c82e | 2015-02-27 09:18:34 +0000 | [diff] [blame] | 1327 | /* get number of interrupts, queues, and VFs */ |
Shannon Nelson | 838d41d | 2014-06-04 20:41:27 +0000 | [diff] [blame] | 1328 | val = rd32(hw, I40E_GLPCI_CNF2); |
| 1329 | num_pf_int = (val & I40E_GLPCI_CNF2_MSI_X_PF_N_MASK) >> |
| 1330 | I40E_GLPCI_CNF2_MSI_X_PF_N_SHIFT; |
| 1331 | num_vf_int = (val & I40E_GLPCI_CNF2_MSI_X_VF_N_MASK) >> |
| 1332 | I40E_GLPCI_CNF2_MSI_X_VF_N_SHIFT; |
| 1333 | |
Shannon Nelson | 272cdaf2 | 2016-02-17 16:12:21 -0800 | [diff] [blame] | 1334 | val = rd32(hw, I40E_PFLAN_QALLOC); |
Shannon Nelson | 838d41d | 2014-06-04 20:41:27 +0000 | [diff] [blame] | 1335 | base_queue = (val & I40E_PFLAN_QALLOC_FIRSTQ_MASK) >> |
| 1336 | I40E_PFLAN_QALLOC_FIRSTQ_SHIFT; |
| 1337 | j = (val & I40E_PFLAN_QALLOC_LASTQ_MASK) >> |
| 1338 | I40E_PFLAN_QALLOC_LASTQ_SHIFT; |
| 1339 | if (val & I40E_PFLAN_QALLOC_VALID_MASK) |
| 1340 | num_queues = (j - base_queue) + 1; |
| 1341 | else |
| 1342 | num_queues = 0; |
| 1343 | |
| 1344 | val = rd32(hw, I40E_PF_VT_PFALLOC); |
| 1345 | i = (val & I40E_PF_VT_PFALLOC_FIRSTVF_MASK) >> |
| 1346 | I40E_PF_VT_PFALLOC_FIRSTVF_SHIFT; |
| 1347 | j = (val & I40E_PF_VT_PFALLOC_LASTVF_MASK) >> |
| 1348 | I40E_PF_VT_PFALLOC_LASTVF_SHIFT; |
| 1349 | if (val & I40E_PF_VT_PFALLOC_VALID_MASK) |
| 1350 | num_vfs = (j - i) + 1; |
| 1351 | else |
| 1352 | num_vfs = 0; |
| 1353 | |
| 1354 | /* stop all the interrupts */ |
| 1355 | wr32(hw, I40E_PFINT_ICR0_ENA, 0); |
| 1356 | val = 0x3 << I40E_PFINT_DYN_CTLN_ITR_INDX_SHIFT; |
| 1357 | for (i = 0; i < num_pf_int - 2; i++) |
| 1358 | wr32(hw, I40E_PFINT_DYN_CTLN(i), val); |
| 1359 | |
| 1360 | /* Set the FIRSTQ_INDX field to 0x7FF in PFINT_LNKLSTx */ |
| 1361 | val = eol << I40E_PFINT_LNKLST0_FIRSTQ_INDX_SHIFT; |
| 1362 | wr32(hw, I40E_PFINT_LNKLST0, val); |
| 1363 | for (i = 0; i < num_pf_int - 2; i++) |
| 1364 | wr32(hw, I40E_PFINT_LNKLSTN(i), val); |
| 1365 | val = eol << I40E_VPINT_LNKLST0_FIRSTQ_INDX_SHIFT; |
| 1366 | for (i = 0; i < num_vfs; i++) |
| 1367 | wr32(hw, I40E_VPINT_LNKLST0(i), val); |
| 1368 | for (i = 0; i < num_vf_int - 2; i++) |
| 1369 | wr32(hw, I40E_VPINT_LNKLSTN(i), val); |
| 1370 | |
| 1371 | /* warn the HW of the coming Tx disables */ |
| 1372 | for (i = 0; i < num_queues; i++) { |
| 1373 | u32 abs_queue_idx = base_queue + i; |
| 1374 | u32 reg_block = 0; |
| 1375 | |
| 1376 | if (abs_queue_idx >= 128) { |
| 1377 | reg_block = abs_queue_idx / 128; |
| 1378 | abs_queue_idx %= 128; |
| 1379 | } |
| 1380 | |
| 1381 | val = rd32(hw, I40E_GLLAN_TXPRE_QDIS(reg_block)); |
| 1382 | val &= ~I40E_GLLAN_TXPRE_QDIS_QINDX_MASK; |
| 1383 | val |= (abs_queue_idx << I40E_GLLAN_TXPRE_QDIS_QINDX_SHIFT); |
| 1384 | val |= I40E_GLLAN_TXPRE_QDIS_SET_QDIS_MASK; |
| 1385 | |
| 1386 | wr32(hw, I40E_GLLAN_TXPRE_QDIS(reg_block), val); |
| 1387 | } |
| 1388 | udelay(400); |
| 1389 | |
| 1390 | /* stop all the queues */ |
| 1391 | for (i = 0; i < num_queues; i++) { |
| 1392 | wr32(hw, I40E_QINT_TQCTL(i), 0); |
| 1393 | wr32(hw, I40E_QTX_ENA(i), 0); |
| 1394 | wr32(hw, I40E_QINT_RQCTL(i), 0); |
| 1395 | wr32(hw, I40E_QRX_ENA(i), 0); |
| 1396 | } |
| 1397 | |
| 1398 | /* short wait for all queue disables to settle */ |
| 1399 | udelay(50); |
| 1400 | } |
| 1401 | |
| 1402 | /** |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1403 | * i40e_clear_pxe_mode - clear pxe operations mode |
| 1404 | * @hw: pointer to the hw struct |
| 1405 | * |
| 1406 | * Make sure all PXE mode settings are cleared, including things |
| 1407 | * like descriptor fetch/write-back mode. |
| 1408 | **/ |
| 1409 | void i40e_clear_pxe_mode(struct i40e_hw *hw) |
| 1410 | { |
| 1411 | u32 reg; |
| 1412 | |
Shannon Nelson | c9b9b0a | 2014-04-09 05:59:05 +0000 | [diff] [blame] | 1413 | if (i40e_check_asq_alive(hw)) |
| 1414 | i40e_aq_clear_pxe_mode(hw, NULL); |
| 1415 | |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1416 | /* Clear single descriptor fetch/write-back mode */ |
| 1417 | reg = rd32(hw, I40E_GLLAN_RCTL_0); |
Jesse Brandeburg | 7134f9c | 2013-11-26 08:56:05 +0000 | [diff] [blame] | 1418 | |
| 1419 | if (hw->revision_id == 0) { |
| 1420 | /* As a work around clear PXE_MODE instead of setting it */ |
| 1421 | wr32(hw, I40E_GLLAN_RCTL_0, (reg & (~I40E_GLLAN_RCTL_0_PXE_MODE_MASK))); |
| 1422 | } else { |
| 1423 | wr32(hw, I40E_GLLAN_RCTL_0, (reg | I40E_GLLAN_RCTL_0_PXE_MODE_MASK)); |
| 1424 | } |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1425 | } |
| 1426 | |
| 1427 | /** |
Jesse Brandeburg | 0556a9e | 2013-11-28 06:39:33 +0000 | [diff] [blame] | 1428 | * i40e_led_is_mine - helper to find matching led |
| 1429 | * @hw: pointer to the hw struct |
| 1430 | * @idx: index into GPIO registers |
| 1431 | * |
| 1432 | * returns: 0 if no match, otherwise the value of the GPIO_CTL register |
| 1433 | */ |
| 1434 | static u32 i40e_led_is_mine(struct i40e_hw *hw, int idx) |
| 1435 | { |
| 1436 | u32 gpio_val = 0; |
| 1437 | u32 port; |
| 1438 | |
| 1439 | if (!hw->func_caps.led[idx]) |
| 1440 | return 0; |
| 1441 | |
| 1442 | gpio_val = rd32(hw, I40E_GLGEN_GPIO_CTL(idx)); |
| 1443 | port = (gpio_val & I40E_GLGEN_GPIO_CTL_PRT_NUM_MASK) >> |
| 1444 | I40E_GLGEN_GPIO_CTL_PRT_NUM_SHIFT; |
| 1445 | |
| 1446 | /* if PRT_NUM_NA is 1 then this LED is not port specific, OR |
| 1447 | * if it is not our port then ignore |
| 1448 | */ |
| 1449 | if ((gpio_val & I40E_GLGEN_GPIO_CTL_PRT_NUM_NA_MASK) || |
| 1450 | (port != hw->port)) |
| 1451 | return 0; |
| 1452 | |
| 1453 | return gpio_val; |
| 1454 | } |
| 1455 | |
Matt Jared | b84d5cd | 2015-02-26 16:11:30 +0000 | [diff] [blame] | 1456 | #define I40E_COMBINED_ACTIVITY 0xA |
| 1457 | #define I40E_FILTER_ACTIVITY 0xE |
Jesse Brandeburg | 0556a9e | 2013-11-28 06:39:33 +0000 | [diff] [blame] | 1458 | #define I40E_LINK_ACTIVITY 0xC |
Matt Jared | b84d5cd | 2015-02-26 16:11:30 +0000 | [diff] [blame] | 1459 | #define I40E_MAC_ACTIVITY 0xD |
| 1460 | #define I40E_LED0 22 |
Jesse Brandeburg | 0556a9e | 2013-11-28 06:39:33 +0000 | [diff] [blame] | 1461 | |
| 1462 | /** |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1463 | * i40e_led_get - return current on/off mode |
| 1464 | * @hw: pointer to the hw struct |
| 1465 | * |
| 1466 | * The value returned is the 'mode' field as defined in the |
| 1467 | * GPIO register definitions: 0x0 = off, 0xf = on, and other |
| 1468 | * values are variations of possible behaviors relating to |
| 1469 | * blink, link, and wire. |
| 1470 | **/ |
| 1471 | u32 i40e_led_get(struct i40e_hw *hw) |
| 1472 | { |
Matt Jared | b84d5cd | 2015-02-26 16:11:30 +0000 | [diff] [blame] | 1473 | u32 current_mode = 0; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1474 | u32 mode = 0; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1475 | int i; |
| 1476 | |
Jesse Brandeburg | 0556a9e | 2013-11-28 06:39:33 +0000 | [diff] [blame] | 1477 | /* as per the documentation GPIO 22-29 are the LED |
| 1478 | * GPIO pins named LED0..LED7 |
| 1479 | */ |
| 1480 | for (i = I40E_LED0; i <= I40E_GLGEN_GPIO_CTL_MAX_INDEX; i++) { |
| 1481 | u32 gpio_val = i40e_led_is_mine(hw, i); |
| 1482 | |
| 1483 | if (!gpio_val) |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1484 | continue; |
| 1485 | |
Matt Jared | b84d5cd | 2015-02-26 16:11:30 +0000 | [diff] [blame] | 1486 | /* ignore gpio LED src mode entries related to the activity |
| 1487 | * LEDs |
| 1488 | */ |
| 1489 | current_mode = ((gpio_val & I40E_GLGEN_GPIO_CTL_LED_MODE_MASK) |
| 1490 | >> I40E_GLGEN_GPIO_CTL_LED_MODE_SHIFT); |
| 1491 | switch (current_mode) { |
| 1492 | case I40E_COMBINED_ACTIVITY: |
| 1493 | case I40E_FILTER_ACTIVITY: |
| 1494 | case I40E_MAC_ACTIVITY: |
| 1495 | continue; |
| 1496 | default: |
| 1497 | break; |
| 1498 | } |
| 1499 | |
Jesse Brandeburg | 0556a9e | 2013-11-28 06:39:33 +0000 | [diff] [blame] | 1500 | mode = (gpio_val & I40E_GLGEN_GPIO_CTL_LED_MODE_MASK) >> |
| 1501 | I40E_GLGEN_GPIO_CTL_LED_MODE_SHIFT; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1502 | break; |
| 1503 | } |
| 1504 | |
| 1505 | return mode; |
| 1506 | } |
| 1507 | |
| 1508 | /** |
| 1509 | * i40e_led_set - set new on/off mode |
| 1510 | * @hw: pointer to the hw struct |
Jesse Brandeburg | 0556a9e | 2013-11-28 06:39:33 +0000 | [diff] [blame] | 1511 | * @mode: 0=off, 0xf=on (else see manual for mode details) |
| 1512 | * @blink: true if the LED should blink when on, false if steady |
| 1513 | * |
| 1514 | * if this function is used to turn on the blink it should |
| 1515 | * be used to disable the blink when restoring the original state. |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1516 | **/ |
Jesse Brandeburg | 0556a9e | 2013-11-28 06:39:33 +0000 | [diff] [blame] | 1517 | void i40e_led_set(struct i40e_hw *hw, u32 mode, bool blink) |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1518 | { |
Matt Jared | b84d5cd | 2015-02-26 16:11:30 +0000 | [diff] [blame] | 1519 | u32 current_mode = 0; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1520 | int i; |
| 1521 | |
Jesse Brandeburg | 0556a9e | 2013-11-28 06:39:33 +0000 | [diff] [blame] | 1522 | if (mode & 0xfffffff0) |
| 1523 | hw_dbg(hw, "invalid mode passed in %X\n", mode); |
| 1524 | |
| 1525 | /* as per the documentation GPIO 22-29 are the LED |
| 1526 | * GPIO pins named LED0..LED7 |
| 1527 | */ |
| 1528 | for (i = I40E_LED0; i <= I40E_GLGEN_GPIO_CTL_MAX_INDEX; i++) { |
| 1529 | u32 gpio_val = i40e_led_is_mine(hw, i); |
| 1530 | |
| 1531 | if (!gpio_val) |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1532 | continue; |
| 1533 | |
Matt Jared | b84d5cd | 2015-02-26 16:11:30 +0000 | [diff] [blame] | 1534 | /* ignore gpio LED src mode entries related to the activity |
| 1535 | * LEDs |
| 1536 | */ |
| 1537 | current_mode = ((gpio_val & I40E_GLGEN_GPIO_CTL_LED_MODE_MASK) |
| 1538 | >> I40E_GLGEN_GPIO_CTL_LED_MODE_SHIFT); |
| 1539 | switch (current_mode) { |
| 1540 | case I40E_COMBINED_ACTIVITY: |
| 1541 | case I40E_FILTER_ACTIVITY: |
| 1542 | case I40E_MAC_ACTIVITY: |
| 1543 | continue; |
| 1544 | default: |
| 1545 | break; |
| 1546 | } |
| 1547 | |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1548 | gpio_val &= ~I40E_GLGEN_GPIO_CTL_LED_MODE_MASK; |
Jesse Brandeburg | 0556a9e | 2013-11-28 06:39:33 +0000 | [diff] [blame] | 1549 | /* this & is a bit of paranoia, but serves as a range check */ |
| 1550 | gpio_val |= ((mode << I40E_GLGEN_GPIO_CTL_LED_MODE_SHIFT) & |
| 1551 | I40E_GLGEN_GPIO_CTL_LED_MODE_MASK); |
| 1552 | |
| 1553 | if (mode == I40E_LINK_ACTIVITY) |
| 1554 | blink = false; |
| 1555 | |
Matt Jared | 9be00d6 | 2015-01-24 09:58:28 +0000 | [diff] [blame] | 1556 | if (blink) |
Jesse Brandeburg | 41a1d04 | 2015-06-04 16:24:02 -0400 | [diff] [blame] | 1557 | gpio_val |= BIT(I40E_GLGEN_GPIO_CTL_LED_BLINK_SHIFT); |
Matt Jared | 9be00d6 | 2015-01-24 09:58:28 +0000 | [diff] [blame] | 1558 | else |
Jesse Brandeburg | 41a1d04 | 2015-06-04 16:24:02 -0400 | [diff] [blame] | 1559 | gpio_val &= ~BIT(I40E_GLGEN_GPIO_CTL_LED_BLINK_SHIFT); |
Jesse Brandeburg | 0556a9e | 2013-11-28 06:39:33 +0000 | [diff] [blame] | 1560 | |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1561 | wr32(hw, I40E_GLGEN_GPIO_CTL(i), gpio_val); |
Jesse Brandeburg | 0556a9e | 2013-11-28 06:39:33 +0000 | [diff] [blame] | 1562 | break; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1563 | } |
| 1564 | } |
| 1565 | |
| 1566 | /* Admin command wrappers */ |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1567 | |
| 1568 | /** |
Catherine Sullivan | 8109e12 | 2014-06-04 08:45:24 +0000 | [diff] [blame] | 1569 | * i40e_aq_get_phy_capabilities |
| 1570 | * @hw: pointer to the hw struct |
| 1571 | * @abilities: structure for PHY capabilities to be filled |
| 1572 | * @qualified_modules: report Qualified Modules |
| 1573 | * @report_init: report init capabilities (active are default) |
| 1574 | * @cmd_details: pointer to command details structure or NULL |
| 1575 | * |
| 1576 | * Returns the various PHY abilities supported on the Port. |
| 1577 | **/ |
| 1578 | i40e_status i40e_aq_get_phy_capabilities(struct i40e_hw *hw, |
| 1579 | bool qualified_modules, bool report_init, |
| 1580 | struct i40e_aq_get_phy_abilities_resp *abilities, |
| 1581 | struct i40e_asq_cmd_details *cmd_details) |
| 1582 | { |
| 1583 | struct i40e_aq_desc desc; |
| 1584 | i40e_status status; |
| 1585 | u16 abilities_size = sizeof(struct i40e_aq_get_phy_abilities_resp); |
| 1586 | |
| 1587 | if (!abilities) |
| 1588 | return I40E_ERR_PARAM; |
| 1589 | |
| 1590 | i40e_fill_default_direct_cmd_desc(&desc, |
| 1591 | i40e_aqc_opc_get_phy_abilities); |
| 1592 | |
| 1593 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF); |
| 1594 | if (abilities_size > I40E_AQ_LARGE_BUF) |
| 1595 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB); |
| 1596 | |
| 1597 | if (qualified_modules) |
| 1598 | desc.params.external.param0 |= |
| 1599 | cpu_to_le32(I40E_AQ_PHY_REPORT_QUALIFIED_MODULES); |
| 1600 | |
| 1601 | if (report_init) |
| 1602 | desc.params.external.param0 |= |
| 1603 | cpu_to_le32(I40E_AQ_PHY_REPORT_INITIAL_VALUES); |
| 1604 | |
| 1605 | status = i40e_asq_send_command(hw, &desc, abilities, abilities_size, |
| 1606 | cmd_details); |
| 1607 | |
| 1608 | if (hw->aq.asq_last_status == I40E_AQ_RC_EIO) |
| 1609 | status = I40E_ERR_UNKNOWN_PHY; |
| 1610 | |
Kevin Scott | 3ac67d7 | 2015-09-03 17:18:58 -0400 | [diff] [blame] | 1611 | if (report_init) |
| 1612 | hw->phy.phy_types = le32_to_cpu(abilities->phy_type); |
| 1613 | |
Catherine Sullivan | 8109e12 | 2014-06-04 08:45:24 +0000 | [diff] [blame] | 1614 | return status; |
| 1615 | } |
| 1616 | |
| 1617 | /** |
Catherine Sullivan | c56999f | 2014-06-04 08:45:26 +0000 | [diff] [blame] | 1618 | * i40e_aq_set_phy_config |
| 1619 | * @hw: pointer to the hw struct |
| 1620 | * @config: structure with PHY configuration to be set |
| 1621 | * @cmd_details: pointer to command details structure or NULL |
| 1622 | * |
| 1623 | * Set the various PHY configuration parameters |
| 1624 | * supported on the Port.One or more of the Set PHY config parameters may be |
| 1625 | * ignored in an MFP mode as the PF may not have the privilege to set some |
| 1626 | * of the PHY Config parameters. This status will be indicated by the |
| 1627 | * command response. |
| 1628 | **/ |
| 1629 | enum i40e_status_code i40e_aq_set_phy_config(struct i40e_hw *hw, |
| 1630 | struct i40e_aq_set_phy_config *config, |
| 1631 | struct i40e_asq_cmd_details *cmd_details) |
| 1632 | { |
| 1633 | struct i40e_aq_desc desc; |
| 1634 | struct i40e_aq_set_phy_config *cmd = |
| 1635 | (struct i40e_aq_set_phy_config *)&desc.params.raw; |
| 1636 | enum i40e_status_code status; |
| 1637 | |
| 1638 | if (!config) |
| 1639 | return I40E_ERR_PARAM; |
| 1640 | |
| 1641 | i40e_fill_default_direct_cmd_desc(&desc, |
| 1642 | i40e_aqc_opc_set_phy_config); |
| 1643 | |
| 1644 | *cmd = *config; |
| 1645 | |
| 1646 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 1647 | |
| 1648 | return status; |
| 1649 | } |
| 1650 | |
| 1651 | /** |
| 1652 | * i40e_set_fc |
| 1653 | * @hw: pointer to the hw struct |
| 1654 | * |
| 1655 | * Set the requested flow control mode using set_phy_config. |
| 1656 | **/ |
| 1657 | enum i40e_status_code i40e_set_fc(struct i40e_hw *hw, u8 *aq_failures, |
| 1658 | bool atomic_restart) |
| 1659 | { |
| 1660 | enum i40e_fc_mode fc_mode = hw->fc.requested_mode; |
| 1661 | struct i40e_aq_get_phy_abilities_resp abilities; |
| 1662 | struct i40e_aq_set_phy_config config; |
| 1663 | enum i40e_status_code status; |
| 1664 | u8 pause_mask = 0x0; |
| 1665 | |
| 1666 | *aq_failures = 0x0; |
| 1667 | |
| 1668 | switch (fc_mode) { |
| 1669 | case I40E_FC_FULL: |
| 1670 | pause_mask |= I40E_AQ_PHY_FLAG_PAUSE_TX; |
| 1671 | pause_mask |= I40E_AQ_PHY_FLAG_PAUSE_RX; |
| 1672 | break; |
| 1673 | case I40E_FC_RX_PAUSE: |
| 1674 | pause_mask |= I40E_AQ_PHY_FLAG_PAUSE_RX; |
| 1675 | break; |
| 1676 | case I40E_FC_TX_PAUSE: |
| 1677 | pause_mask |= I40E_AQ_PHY_FLAG_PAUSE_TX; |
| 1678 | break; |
| 1679 | default: |
| 1680 | break; |
| 1681 | } |
| 1682 | |
| 1683 | /* Get the current phy config */ |
| 1684 | status = i40e_aq_get_phy_capabilities(hw, false, false, &abilities, |
| 1685 | NULL); |
| 1686 | if (status) { |
| 1687 | *aq_failures |= I40E_SET_FC_AQ_FAIL_GET; |
| 1688 | return status; |
| 1689 | } |
| 1690 | |
| 1691 | memset(&config, 0, sizeof(struct i40e_aq_set_phy_config)); |
| 1692 | /* clear the old pause settings */ |
| 1693 | config.abilities = abilities.abilities & ~(I40E_AQ_PHY_FLAG_PAUSE_TX) & |
| 1694 | ~(I40E_AQ_PHY_FLAG_PAUSE_RX); |
| 1695 | /* set the new abilities */ |
| 1696 | config.abilities |= pause_mask; |
| 1697 | /* If the abilities have changed, then set the new config */ |
| 1698 | if (config.abilities != abilities.abilities) { |
| 1699 | /* Auto restart link so settings take effect */ |
| 1700 | if (atomic_restart) |
| 1701 | config.abilities |= I40E_AQ_PHY_ENABLE_ATOMIC_LINK; |
| 1702 | /* Copy over all the old settings */ |
| 1703 | config.phy_type = abilities.phy_type; |
| 1704 | config.link_speed = abilities.link_speed; |
| 1705 | config.eee_capability = abilities.eee_capability; |
| 1706 | config.eeer = abilities.eeer_val; |
| 1707 | config.low_power_ctrl = abilities.d3_lpan; |
| 1708 | status = i40e_aq_set_phy_config(hw, &config, NULL); |
| 1709 | |
| 1710 | if (status) |
| 1711 | *aq_failures |= I40E_SET_FC_AQ_FAIL_SET; |
| 1712 | } |
| 1713 | /* Update the link info */ |
Catherine Sullivan | 0a862b4 | 2015-08-31 19:54:53 -0400 | [diff] [blame] | 1714 | status = i40e_update_link_info(hw); |
Catherine Sullivan | c56999f | 2014-06-04 08:45:26 +0000 | [diff] [blame] | 1715 | if (status) { |
| 1716 | /* Wait a little bit (on 40G cards it sometimes takes a really |
| 1717 | * long time for link to come back from the atomic reset) |
| 1718 | * and try once more |
| 1719 | */ |
| 1720 | msleep(1000); |
Catherine Sullivan | 0a862b4 | 2015-08-31 19:54:53 -0400 | [diff] [blame] | 1721 | status = i40e_update_link_info(hw); |
Catherine Sullivan | c56999f | 2014-06-04 08:45:26 +0000 | [diff] [blame] | 1722 | } |
| 1723 | if (status) |
| 1724 | *aq_failures |= I40E_SET_FC_AQ_FAIL_UPDATE; |
| 1725 | |
| 1726 | return status; |
| 1727 | } |
| 1728 | |
| 1729 | /** |
Shannon Nelson | c9b9b0a | 2014-04-09 05:59:05 +0000 | [diff] [blame] | 1730 | * i40e_aq_clear_pxe_mode |
| 1731 | * @hw: pointer to the hw struct |
| 1732 | * @cmd_details: pointer to command details structure or NULL |
| 1733 | * |
| 1734 | * Tell the firmware that the driver is taking over from PXE |
| 1735 | **/ |
| 1736 | i40e_status i40e_aq_clear_pxe_mode(struct i40e_hw *hw, |
| 1737 | struct i40e_asq_cmd_details *cmd_details) |
| 1738 | { |
| 1739 | i40e_status status; |
| 1740 | struct i40e_aq_desc desc; |
| 1741 | struct i40e_aqc_clear_pxe *cmd = |
| 1742 | (struct i40e_aqc_clear_pxe *)&desc.params.raw; |
| 1743 | |
| 1744 | i40e_fill_default_direct_cmd_desc(&desc, |
| 1745 | i40e_aqc_opc_clear_pxe_mode); |
| 1746 | |
| 1747 | cmd->rx_cnt = 0x2; |
| 1748 | |
| 1749 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 1750 | |
| 1751 | wr32(hw, I40E_GLLAN_RCTL_0, 0x1); |
| 1752 | |
| 1753 | return status; |
| 1754 | } |
| 1755 | |
| 1756 | /** |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1757 | * i40e_aq_set_link_restart_an |
| 1758 | * @hw: pointer to the hw struct |
Catherine Sullivan | 1ac978a | 2014-06-04 01:23:20 +0000 | [diff] [blame] | 1759 | * @enable_link: if true: enable link, if false: disable link |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1760 | * @cmd_details: pointer to command details structure or NULL |
| 1761 | * |
| 1762 | * Sets up the link and restarts the Auto-Negotiation over the link. |
| 1763 | **/ |
| 1764 | i40e_status i40e_aq_set_link_restart_an(struct i40e_hw *hw, |
Catherine Sullivan | 1ac978a | 2014-06-04 01:23:20 +0000 | [diff] [blame] | 1765 | bool enable_link, |
| 1766 | struct i40e_asq_cmd_details *cmd_details) |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1767 | { |
| 1768 | struct i40e_aq_desc desc; |
| 1769 | struct i40e_aqc_set_link_restart_an *cmd = |
| 1770 | (struct i40e_aqc_set_link_restart_an *)&desc.params.raw; |
| 1771 | i40e_status status; |
| 1772 | |
| 1773 | i40e_fill_default_direct_cmd_desc(&desc, |
| 1774 | i40e_aqc_opc_set_link_restart_an); |
| 1775 | |
| 1776 | cmd->command = I40E_AQ_PHY_RESTART_AN; |
Catherine Sullivan | 1ac978a | 2014-06-04 01:23:20 +0000 | [diff] [blame] | 1777 | if (enable_link) |
| 1778 | cmd->command |= I40E_AQ_PHY_LINK_ENABLE; |
| 1779 | else |
| 1780 | cmd->command &= ~I40E_AQ_PHY_LINK_ENABLE; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1781 | |
| 1782 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 1783 | |
| 1784 | return status; |
| 1785 | } |
| 1786 | |
| 1787 | /** |
| 1788 | * i40e_aq_get_link_info |
| 1789 | * @hw: pointer to the hw struct |
| 1790 | * @enable_lse: enable/disable LinkStatusEvent reporting |
| 1791 | * @link: pointer to link status structure - optional |
| 1792 | * @cmd_details: pointer to command details structure or NULL |
| 1793 | * |
| 1794 | * Returns the link status of the adapter. |
| 1795 | **/ |
| 1796 | i40e_status i40e_aq_get_link_info(struct i40e_hw *hw, |
| 1797 | bool enable_lse, struct i40e_link_status *link, |
| 1798 | struct i40e_asq_cmd_details *cmd_details) |
| 1799 | { |
| 1800 | struct i40e_aq_desc desc; |
| 1801 | struct i40e_aqc_get_link_status *resp = |
| 1802 | (struct i40e_aqc_get_link_status *)&desc.params.raw; |
| 1803 | struct i40e_link_status *hw_link_info = &hw->phy.link_info; |
| 1804 | i40e_status status; |
Catherine Sullivan | c56999f | 2014-06-04 08:45:26 +0000 | [diff] [blame] | 1805 | bool tx_pause, rx_pause; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1806 | u16 command_flags; |
| 1807 | |
| 1808 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_get_link_status); |
| 1809 | |
| 1810 | if (enable_lse) |
| 1811 | command_flags = I40E_AQ_LSE_ENABLE; |
| 1812 | else |
| 1813 | command_flags = I40E_AQ_LSE_DISABLE; |
| 1814 | resp->command_flags = cpu_to_le16(command_flags); |
| 1815 | |
| 1816 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 1817 | |
| 1818 | if (status) |
| 1819 | goto aq_get_link_info_exit; |
| 1820 | |
| 1821 | /* save off old link status information */ |
Mitch Williams | c36bd4a7 | 2013-12-18 13:46:04 +0000 | [diff] [blame] | 1822 | hw->phy.link_info_old = *hw_link_info; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1823 | |
| 1824 | /* update link status */ |
| 1825 | 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] | 1826 | hw->phy.media_type = i40e_get_media_type(hw); |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1827 | hw_link_info->link_speed = (enum i40e_aq_link_speed)resp->link_speed; |
| 1828 | hw_link_info->link_info = resp->link_info; |
| 1829 | hw_link_info->an_info = resp->an_info; |
| 1830 | hw_link_info->ext_info = resp->ext_info; |
Kamil Krawczyk | 639dc37 | 2013-11-20 10:03:07 +0000 | [diff] [blame] | 1831 | hw_link_info->loopback = resp->loopback; |
Neerav Parikh | 6bb3f23 | 2014-04-01 07:11:56 +0000 | [diff] [blame] | 1832 | hw_link_info->max_frame_size = le16_to_cpu(resp->max_frame_size); |
| 1833 | hw_link_info->pacing = resp->config & I40E_AQ_CONFIG_PACING_MASK; |
| 1834 | |
Catherine Sullivan | c56999f | 2014-06-04 08:45:26 +0000 | [diff] [blame] | 1835 | /* update fc info */ |
| 1836 | tx_pause = !!(resp->an_info & I40E_AQ_LINK_PAUSE_TX); |
| 1837 | rx_pause = !!(resp->an_info & I40E_AQ_LINK_PAUSE_RX); |
| 1838 | if (tx_pause & rx_pause) |
| 1839 | hw->fc.current_mode = I40E_FC_FULL; |
| 1840 | else if (tx_pause) |
| 1841 | hw->fc.current_mode = I40E_FC_TX_PAUSE; |
| 1842 | else if (rx_pause) |
| 1843 | hw->fc.current_mode = I40E_FC_RX_PAUSE; |
| 1844 | else |
| 1845 | hw->fc.current_mode = I40E_FC_NONE; |
| 1846 | |
Neerav Parikh | 6bb3f23 | 2014-04-01 07:11:56 +0000 | [diff] [blame] | 1847 | if (resp->config & I40E_AQ_CONFIG_CRC_ENA) |
| 1848 | hw_link_info->crc_enable = true; |
| 1849 | else |
| 1850 | hw_link_info->crc_enable = false; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1851 | |
Filip Sadowski | 7ed3573 | 2016-09-14 16:24:33 -0700 | [diff] [blame] | 1852 | if (resp->command_flags & cpu_to_le16(I40E_AQ_LSE_IS_ENABLED)) |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1853 | hw_link_info->lse_enable = true; |
| 1854 | else |
| 1855 | hw_link_info->lse_enable = false; |
| 1856 | |
Catherine Sullivan | 088c4ee | 2015-02-26 16:14:12 +0000 | [diff] [blame] | 1857 | if ((hw->aq.fw_maj_ver < 4 || (hw->aq.fw_maj_ver == 4 && |
| 1858 | hw->aq.fw_min_ver < 40)) && hw_link_info->phy_type == 0xE) |
| 1859 | hw_link_info->phy_type = I40E_PHY_TYPE_10GBASE_SFPP_CU; |
| 1860 | |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1861 | /* save link status information */ |
| 1862 | if (link) |
Jesse Brandeburg | d7595a2 | 2013-09-13 08:23:22 +0000 | [diff] [blame] | 1863 | *link = *hw_link_info; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1864 | |
| 1865 | /* flag cleared so helper functions don't call AQ again */ |
| 1866 | hw->phy.get_link_info = false; |
| 1867 | |
| 1868 | aq_get_link_info_exit: |
| 1869 | return status; |
| 1870 | } |
| 1871 | |
| 1872 | /** |
Jesse Brandeburg | 7e2453f | 2014-09-13 07:40:41 +0000 | [diff] [blame] | 1873 | * i40e_aq_set_phy_int_mask |
| 1874 | * @hw: pointer to the hw struct |
| 1875 | * @mask: interrupt mask to be set |
| 1876 | * @cmd_details: pointer to command details structure or NULL |
| 1877 | * |
| 1878 | * Set link interrupt mask. |
| 1879 | **/ |
| 1880 | i40e_status i40e_aq_set_phy_int_mask(struct i40e_hw *hw, |
| 1881 | u16 mask, |
| 1882 | struct i40e_asq_cmd_details *cmd_details) |
| 1883 | { |
| 1884 | struct i40e_aq_desc desc; |
| 1885 | struct i40e_aqc_set_phy_int_mask *cmd = |
| 1886 | (struct i40e_aqc_set_phy_int_mask *)&desc.params.raw; |
| 1887 | i40e_status status; |
| 1888 | |
| 1889 | i40e_fill_default_direct_cmd_desc(&desc, |
| 1890 | i40e_aqc_opc_set_phy_int_mask); |
| 1891 | |
| 1892 | cmd->event_mask = cpu_to_le16(mask); |
| 1893 | |
| 1894 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 1895 | |
| 1896 | return status; |
| 1897 | } |
| 1898 | |
| 1899 | /** |
Carolyn Wyborny | 31b606d | 2016-02-17 16:12:12 -0800 | [diff] [blame] | 1900 | * i40e_aq_set_phy_debug |
| 1901 | * @hw: pointer to the hw struct |
| 1902 | * @cmd_flags: debug command flags |
| 1903 | * @cmd_details: pointer to command details structure or NULL |
| 1904 | * |
| 1905 | * Reset the external PHY. |
| 1906 | **/ |
Jesse Brandeburg | 6182902 | 2016-03-10 14:59:42 -0800 | [diff] [blame] | 1907 | i40e_status i40e_aq_set_phy_debug(struct i40e_hw *hw, u8 cmd_flags, |
| 1908 | struct i40e_asq_cmd_details *cmd_details) |
Carolyn Wyborny | 31b606d | 2016-02-17 16:12:12 -0800 | [diff] [blame] | 1909 | { |
| 1910 | struct i40e_aq_desc desc; |
| 1911 | struct i40e_aqc_set_phy_debug *cmd = |
| 1912 | (struct i40e_aqc_set_phy_debug *)&desc.params.raw; |
Jesse Brandeburg | 6182902 | 2016-03-10 14:59:42 -0800 | [diff] [blame] | 1913 | i40e_status status; |
Carolyn Wyborny | 31b606d | 2016-02-17 16:12:12 -0800 | [diff] [blame] | 1914 | |
| 1915 | i40e_fill_default_direct_cmd_desc(&desc, |
| 1916 | i40e_aqc_opc_set_phy_debug); |
| 1917 | |
| 1918 | cmd->command_flags = cmd_flags; |
| 1919 | |
| 1920 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 1921 | |
| 1922 | return status; |
| 1923 | } |
| 1924 | |
| 1925 | /** |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1926 | * i40e_aq_add_vsi |
| 1927 | * @hw: pointer to the hw struct |
Jeff Kirsher | 98d4438 | 2013-12-21 05:44:42 +0000 | [diff] [blame] | 1928 | * @vsi_ctx: pointer to a vsi context struct |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1929 | * @cmd_details: pointer to command details structure or NULL |
| 1930 | * |
| 1931 | * Add a VSI context to the hardware. |
| 1932 | **/ |
| 1933 | i40e_status i40e_aq_add_vsi(struct i40e_hw *hw, |
| 1934 | struct i40e_vsi_context *vsi_ctx, |
| 1935 | struct i40e_asq_cmd_details *cmd_details) |
| 1936 | { |
| 1937 | struct i40e_aq_desc desc; |
| 1938 | struct i40e_aqc_add_get_update_vsi *cmd = |
| 1939 | (struct i40e_aqc_add_get_update_vsi *)&desc.params.raw; |
| 1940 | struct i40e_aqc_add_get_update_vsi_completion *resp = |
| 1941 | (struct i40e_aqc_add_get_update_vsi_completion *) |
| 1942 | &desc.params.raw; |
| 1943 | i40e_status status; |
| 1944 | |
| 1945 | i40e_fill_default_direct_cmd_desc(&desc, |
| 1946 | i40e_aqc_opc_add_vsi); |
| 1947 | |
| 1948 | cmd->uplink_seid = cpu_to_le16(vsi_ctx->uplink_seid); |
| 1949 | cmd->connection_type = vsi_ctx->connection_type; |
| 1950 | cmd->vf_id = vsi_ctx->vf_num; |
| 1951 | cmd->vsi_flags = cpu_to_le16(vsi_ctx->flags); |
| 1952 | |
| 1953 | desc.flags |= cpu_to_le16((u16)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD)); |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1954 | |
| 1955 | status = i40e_asq_send_command(hw, &desc, &vsi_ctx->info, |
| 1956 | sizeof(vsi_ctx->info), cmd_details); |
| 1957 | |
| 1958 | if (status) |
| 1959 | goto aq_add_vsi_exit; |
| 1960 | |
| 1961 | vsi_ctx->seid = le16_to_cpu(resp->seid); |
| 1962 | vsi_ctx->vsi_number = le16_to_cpu(resp->vsi_number); |
| 1963 | vsi_ctx->vsis_allocated = le16_to_cpu(resp->vsi_used); |
| 1964 | vsi_ctx->vsis_unallocated = le16_to_cpu(resp->vsi_free); |
| 1965 | |
| 1966 | aq_add_vsi_exit: |
| 1967 | return status; |
| 1968 | } |
| 1969 | |
| 1970 | /** |
Mitch Williams | fb70fab | 2016-05-16 10:26:31 -0700 | [diff] [blame] | 1971 | * i40e_aq_set_default_vsi |
| 1972 | * @hw: pointer to the hw struct |
| 1973 | * @seid: vsi number |
| 1974 | * @cmd_details: pointer to command details structure or NULL |
| 1975 | **/ |
| 1976 | i40e_status i40e_aq_set_default_vsi(struct i40e_hw *hw, |
| 1977 | u16 seid, |
| 1978 | struct i40e_asq_cmd_details *cmd_details) |
| 1979 | { |
| 1980 | struct i40e_aq_desc desc; |
| 1981 | struct i40e_aqc_set_vsi_promiscuous_modes *cmd = |
| 1982 | (struct i40e_aqc_set_vsi_promiscuous_modes *) |
| 1983 | &desc.params.raw; |
| 1984 | i40e_status status; |
| 1985 | |
| 1986 | i40e_fill_default_direct_cmd_desc(&desc, |
| 1987 | i40e_aqc_opc_set_vsi_promiscuous_modes); |
| 1988 | |
| 1989 | cmd->promiscuous_flags = cpu_to_le16(I40E_AQC_SET_VSI_DEFAULT); |
| 1990 | cmd->valid_flags = cpu_to_le16(I40E_AQC_SET_VSI_DEFAULT); |
| 1991 | cmd->seid = cpu_to_le16(seid); |
| 1992 | |
| 1993 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 1994 | |
| 1995 | return status; |
| 1996 | } |
| 1997 | |
| 1998 | /** |
| 1999 | * i40e_aq_clear_default_vsi |
| 2000 | * @hw: pointer to the hw struct |
| 2001 | * @seid: vsi number |
| 2002 | * @cmd_details: pointer to command details structure or NULL |
| 2003 | **/ |
| 2004 | i40e_status i40e_aq_clear_default_vsi(struct i40e_hw *hw, |
| 2005 | u16 seid, |
| 2006 | struct i40e_asq_cmd_details *cmd_details) |
| 2007 | { |
| 2008 | struct i40e_aq_desc desc; |
| 2009 | struct i40e_aqc_set_vsi_promiscuous_modes *cmd = |
| 2010 | (struct i40e_aqc_set_vsi_promiscuous_modes *) |
| 2011 | &desc.params.raw; |
| 2012 | i40e_status status; |
| 2013 | |
| 2014 | i40e_fill_default_direct_cmd_desc(&desc, |
| 2015 | i40e_aqc_opc_set_vsi_promiscuous_modes); |
| 2016 | |
| 2017 | cmd->promiscuous_flags = cpu_to_le16(0); |
| 2018 | cmd->valid_flags = cpu_to_le16(I40E_AQC_SET_VSI_DEFAULT); |
| 2019 | cmd->seid = cpu_to_le16(seid); |
| 2020 | |
| 2021 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 2022 | |
| 2023 | return status; |
| 2024 | } |
| 2025 | |
| 2026 | /** |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2027 | * i40e_aq_set_vsi_unicast_promiscuous |
| 2028 | * @hw: pointer to the hw struct |
| 2029 | * @seid: vsi number |
| 2030 | * @set: set unicast promiscuous enable/disable |
| 2031 | * @cmd_details: pointer to command details structure or NULL |
Anjali Singhai Jain | b556989 | 2016-05-03 15:13:12 -0700 | [diff] [blame] | 2032 | * @rx_only_promisc: flag to decide if egress traffic gets mirrored in promisc |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2033 | **/ |
| 2034 | i40e_status i40e_aq_set_vsi_unicast_promiscuous(struct i40e_hw *hw, |
Mitch Williams | 885552a | 2013-12-21 05:44:41 +0000 | [diff] [blame] | 2035 | u16 seid, bool set, |
Anjali Singhai Jain | b556989 | 2016-05-03 15:13:12 -0700 | [diff] [blame] | 2036 | struct i40e_asq_cmd_details *cmd_details, |
| 2037 | bool rx_only_promisc) |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2038 | { |
| 2039 | struct i40e_aq_desc desc; |
| 2040 | struct i40e_aqc_set_vsi_promiscuous_modes *cmd = |
| 2041 | (struct i40e_aqc_set_vsi_promiscuous_modes *)&desc.params.raw; |
| 2042 | i40e_status status; |
| 2043 | u16 flags = 0; |
| 2044 | |
| 2045 | i40e_fill_default_direct_cmd_desc(&desc, |
| 2046 | i40e_aqc_opc_set_vsi_promiscuous_modes); |
| 2047 | |
Anjali Singhai Jain | 3b12008 | 2016-01-15 14:33:21 -0800 | [diff] [blame] | 2048 | if (set) { |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2049 | flags |= I40E_AQC_SET_VSI_PROMISC_UNICAST; |
Anjali Singhai Jain | b556989 | 2016-05-03 15:13:12 -0700 | [diff] [blame] | 2050 | if (rx_only_promisc && |
| 2051 | (((hw->aq.api_maj_ver == 1) && (hw->aq.api_min_ver >= 5)) || |
| 2052 | (hw->aq.api_maj_ver > 1))) |
Anjali Singhai Jain | 3b12008 | 2016-01-15 14:33:21 -0800 | [diff] [blame] | 2053 | flags |= I40E_AQC_SET_VSI_PROMISC_TX; |
| 2054 | } |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2055 | |
| 2056 | cmd->promiscuous_flags = cpu_to_le16(flags); |
| 2057 | |
| 2058 | cmd->valid_flags = cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_UNICAST); |
Anjali Singhai Jain | 3b12008 | 2016-01-15 14:33:21 -0800 | [diff] [blame] | 2059 | if (((hw->aq.api_maj_ver >= 1) && (hw->aq.api_min_ver >= 5)) || |
| 2060 | (hw->aq.api_maj_ver > 1)) |
| 2061 | cmd->valid_flags |= cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_TX); |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2062 | |
| 2063 | cmd->seid = cpu_to_le16(seid); |
| 2064 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 2065 | |
| 2066 | return status; |
| 2067 | } |
| 2068 | |
| 2069 | /** |
| 2070 | * i40e_aq_set_vsi_multicast_promiscuous |
| 2071 | * @hw: pointer to the hw struct |
| 2072 | * @seid: vsi number |
| 2073 | * @set: set multicast promiscuous enable/disable |
| 2074 | * @cmd_details: pointer to command details structure or NULL |
| 2075 | **/ |
| 2076 | i40e_status i40e_aq_set_vsi_multicast_promiscuous(struct i40e_hw *hw, |
| 2077 | u16 seid, bool set, struct i40e_asq_cmd_details *cmd_details) |
| 2078 | { |
| 2079 | struct i40e_aq_desc desc; |
| 2080 | struct i40e_aqc_set_vsi_promiscuous_modes *cmd = |
| 2081 | (struct i40e_aqc_set_vsi_promiscuous_modes *)&desc.params.raw; |
| 2082 | i40e_status status; |
| 2083 | u16 flags = 0; |
| 2084 | |
| 2085 | i40e_fill_default_direct_cmd_desc(&desc, |
| 2086 | i40e_aqc_opc_set_vsi_promiscuous_modes); |
| 2087 | |
| 2088 | if (set) |
| 2089 | flags |= I40E_AQC_SET_VSI_PROMISC_MULTICAST; |
| 2090 | |
| 2091 | cmd->promiscuous_flags = cpu_to_le16(flags); |
| 2092 | |
| 2093 | cmd->valid_flags = cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_MULTICAST); |
| 2094 | |
| 2095 | cmd->seid = cpu_to_le16(seid); |
| 2096 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 2097 | |
| 2098 | return status; |
| 2099 | } |
| 2100 | |
| 2101 | /** |
Greg Rose | 6c41a76 | 2016-04-12 08:30:50 -0700 | [diff] [blame] | 2102 | * i40e_aq_set_vsi_mc_promisc_on_vlan |
| 2103 | * @hw: pointer to the hw struct |
| 2104 | * @seid: vsi number |
| 2105 | * @enable: set MAC L2 layer unicast promiscuous enable/disable for a given VLAN |
| 2106 | * @vid: The VLAN tag filter - capture any multicast packet with this VLAN tag |
| 2107 | * @cmd_details: pointer to command details structure or NULL |
| 2108 | **/ |
| 2109 | enum i40e_status_code i40e_aq_set_vsi_mc_promisc_on_vlan(struct i40e_hw *hw, |
| 2110 | u16 seid, bool enable, |
| 2111 | u16 vid, |
| 2112 | struct i40e_asq_cmd_details *cmd_details) |
| 2113 | { |
| 2114 | struct i40e_aq_desc desc; |
| 2115 | struct i40e_aqc_set_vsi_promiscuous_modes *cmd = |
| 2116 | (struct i40e_aqc_set_vsi_promiscuous_modes *)&desc.params.raw; |
| 2117 | enum i40e_status_code status; |
| 2118 | u16 flags = 0; |
| 2119 | |
| 2120 | i40e_fill_default_direct_cmd_desc(&desc, |
| 2121 | i40e_aqc_opc_set_vsi_promiscuous_modes); |
| 2122 | |
| 2123 | if (enable) |
| 2124 | flags |= I40E_AQC_SET_VSI_PROMISC_MULTICAST; |
| 2125 | |
| 2126 | cmd->promiscuous_flags = cpu_to_le16(flags); |
| 2127 | cmd->valid_flags = cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_MULTICAST); |
| 2128 | cmd->seid = cpu_to_le16(seid); |
| 2129 | cmd->vlan_tag = cpu_to_le16(vid | I40E_AQC_SET_VSI_VLAN_VALID); |
| 2130 | |
| 2131 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 2132 | |
| 2133 | return status; |
| 2134 | } |
| 2135 | |
| 2136 | /** |
| 2137 | * i40e_aq_set_vsi_uc_promisc_on_vlan |
| 2138 | * @hw: pointer to the hw struct |
| 2139 | * @seid: vsi number |
| 2140 | * @enable: set MAC L2 layer unicast promiscuous enable/disable for a given VLAN |
| 2141 | * @vid: The VLAN tag filter - capture any unicast packet with this VLAN tag |
| 2142 | * @cmd_details: pointer to command details structure or NULL |
| 2143 | **/ |
| 2144 | enum i40e_status_code i40e_aq_set_vsi_uc_promisc_on_vlan(struct i40e_hw *hw, |
| 2145 | u16 seid, bool enable, |
| 2146 | u16 vid, |
| 2147 | struct i40e_asq_cmd_details *cmd_details) |
| 2148 | { |
| 2149 | struct i40e_aq_desc desc; |
| 2150 | struct i40e_aqc_set_vsi_promiscuous_modes *cmd = |
| 2151 | (struct i40e_aqc_set_vsi_promiscuous_modes *)&desc.params.raw; |
| 2152 | enum i40e_status_code status; |
| 2153 | u16 flags = 0; |
| 2154 | |
| 2155 | i40e_fill_default_direct_cmd_desc(&desc, |
| 2156 | i40e_aqc_opc_set_vsi_promiscuous_modes); |
| 2157 | |
| 2158 | if (enable) |
| 2159 | flags |= I40E_AQC_SET_VSI_PROMISC_UNICAST; |
| 2160 | |
| 2161 | cmd->promiscuous_flags = cpu_to_le16(flags); |
| 2162 | cmd->valid_flags = cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_UNICAST); |
| 2163 | cmd->seid = cpu_to_le16(seid); |
| 2164 | cmd->vlan_tag = cpu_to_le16(vid | I40E_AQC_SET_VSI_VLAN_VALID); |
| 2165 | |
| 2166 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 2167 | |
| 2168 | return status; |
| 2169 | } |
| 2170 | |
| 2171 | /** |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2172 | * i40e_aq_set_vsi_broadcast |
| 2173 | * @hw: pointer to the hw struct |
| 2174 | * @seid: vsi number |
| 2175 | * @set_filter: true to set filter, false to clear filter |
| 2176 | * @cmd_details: pointer to command details structure or NULL |
| 2177 | * |
| 2178 | * Set or clear the broadcast promiscuous flag (filter) for a given VSI. |
| 2179 | **/ |
| 2180 | i40e_status i40e_aq_set_vsi_broadcast(struct i40e_hw *hw, |
| 2181 | u16 seid, bool set_filter, |
| 2182 | struct i40e_asq_cmd_details *cmd_details) |
| 2183 | { |
| 2184 | struct i40e_aq_desc desc; |
| 2185 | struct i40e_aqc_set_vsi_promiscuous_modes *cmd = |
| 2186 | (struct i40e_aqc_set_vsi_promiscuous_modes *)&desc.params.raw; |
| 2187 | i40e_status status; |
| 2188 | |
| 2189 | i40e_fill_default_direct_cmd_desc(&desc, |
| 2190 | i40e_aqc_opc_set_vsi_promiscuous_modes); |
| 2191 | |
| 2192 | if (set_filter) |
| 2193 | cmd->promiscuous_flags |
| 2194 | |= cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_BROADCAST); |
| 2195 | else |
| 2196 | cmd->promiscuous_flags |
| 2197 | &= cpu_to_le16(~I40E_AQC_SET_VSI_PROMISC_BROADCAST); |
| 2198 | |
| 2199 | cmd->valid_flags = cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_BROADCAST); |
| 2200 | cmd->seid = cpu_to_le16(seid); |
| 2201 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 2202 | |
| 2203 | return status; |
| 2204 | } |
| 2205 | |
| 2206 | /** |
Kiran Patil | 7bd6875 | 2016-01-04 10:33:07 -0800 | [diff] [blame] | 2207 | * i40e_aq_set_vsi_vlan_promisc - control the VLAN promiscuous setting |
| 2208 | * @hw: pointer to the hw struct |
| 2209 | * @seid: vsi number |
| 2210 | * @enable: set MAC L2 layer unicast promiscuous enable/disable for a given VLAN |
| 2211 | * @cmd_details: pointer to command details structure or NULL |
| 2212 | **/ |
| 2213 | i40e_status i40e_aq_set_vsi_vlan_promisc(struct i40e_hw *hw, |
| 2214 | u16 seid, bool enable, |
| 2215 | struct i40e_asq_cmd_details *cmd_details) |
| 2216 | { |
| 2217 | struct i40e_aq_desc desc; |
| 2218 | struct i40e_aqc_set_vsi_promiscuous_modes *cmd = |
| 2219 | (struct i40e_aqc_set_vsi_promiscuous_modes *)&desc.params.raw; |
| 2220 | i40e_status status; |
| 2221 | u16 flags = 0; |
| 2222 | |
| 2223 | i40e_fill_default_direct_cmd_desc(&desc, |
| 2224 | i40e_aqc_opc_set_vsi_promiscuous_modes); |
| 2225 | if (enable) |
| 2226 | flags |= I40E_AQC_SET_VSI_PROMISC_VLAN; |
| 2227 | |
| 2228 | cmd->promiscuous_flags = cpu_to_le16(flags); |
| 2229 | cmd->valid_flags = cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_VLAN); |
| 2230 | cmd->seid = cpu_to_le16(seid); |
| 2231 | |
| 2232 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 2233 | |
| 2234 | return status; |
| 2235 | } |
| 2236 | |
| 2237 | /** |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2238 | * i40e_get_vsi_params - get VSI configuration info |
| 2239 | * @hw: pointer to the hw struct |
Jeff Kirsher | 98d4438 | 2013-12-21 05:44:42 +0000 | [diff] [blame] | 2240 | * @vsi_ctx: pointer to a vsi context struct |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2241 | * @cmd_details: pointer to command details structure or NULL |
| 2242 | **/ |
| 2243 | i40e_status i40e_aq_get_vsi_params(struct i40e_hw *hw, |
| 2244 | struct i40e_vsi_context *vsi_ctx, |
| 2245 | struct i40e_asq_cmd_details *cmd_details) |
| 2246 | { |
| 2247 | struct i40e_aq_desc desc; |
Shannon Nelson | f5ac857 | 2013-11-28 06:39:43 +0000 | [diff] [blame] | 2248 | struct i40e_aqc_add_get_update_vsi *cmd = |
| 2249 | (struct i40e_aqc_add_get_update_vsi *)&desc.params.raw; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2250 | struct i40e_aqc_add_get_update_vsi_completion *resp = |
| 2251 | (struct i40e_aqc_add_get_update_vsi_completion *) |
| 2252 | &desc.params.raw; |
| 2253 | i40e_status status; |
| 2254 | |
| 2255 | i40e_fill_default_direct_cmd_desc(&desc, |
| 2256 | i40e_aqc_opc_get_vsi_parameters); |
| 2257 | |
Shannon Nelson | f5ac857 | 2013-11-28 06:39:43 +0000 | [diff] [blame] | 2258 | cmd->uplink_seid = cpu_to_le16(vsi_ctx->seid); |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2259 | |
| 2260 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF); |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2261 | |
| 2262 | status = i40e_asq_send_command(hw, &desc, &vsi_ctx->info, |
| 2263 | sizeof(vsi_ctx->info), NULL); |
| 2264 | |
| 2265 | if (status) |
| 2266 | goto aq_get_vsi_params_exit; |
| 2267 | |
| 2268 | vsi_ctx->seid = le16_to_cpu(resp->seid); |
| 2269 | vsi_ctx->vsi_number = le16_to_cpu(resp->vsi_number); |
| 2270 | vsi_ctx->vsis_allocated = le16_to_cpu(resp->vsi_used); |
| 2271 | vsi_ctx->vsis_unallocated = le16_to_cpu(resp->vsi_free); |
| 2272 | |
| 2273 | aq_get_vsi_params_exit: |
| 2274 | return status; |
| 2275 | } |
| 2276 | |
| 2277 | /** |
| 2278 | * i40e_aq_update_vsi_params |
| 2279 | * @hw: pointer to the hw struct |
Jeff Kirsher | 98d4438 | 2013-12-21 05:44:42 +0000 | [diff] [blame] | 2280 | * @vsi_ctx: pointer to a vsi context struct |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2281 | * @cmd_details: pointer to command details structure or NULL |
| 2282 | * |
| 2283 | * Update a VSI context. |
| 2284 | **/ |
| 2285 | i40e_status i40e_aq_update_vsi_params(struct i40e_hw *hw, |
| 2286 | struct i40e_vsi_context *vsi_ctx, |
| 2287 | struct i40e_asq_cmd_details *cmd_details) |
| 2288 | { |
| 2289 | struct i40e_aq_desc desc; |
Shannon Nelson | f5ac857 | 2013-11-28 06:39:43 +0000 | [diff] [blame] | 2290 | struct i40e_aqc_add_get_update_vsi *cmd = |
| 2291 | (struct i40e_aqc_add_get_update_vsi *)&desc.params.raw; |
Kevin Scott | b6cacca | 2016-03-10 14:59:41 -0800 | [diff] [blame] | 2292 | struct i40e_aqc_add_get_update_vsi_completion *resp = |
| 2293 | (struct i40e_aqc_add_get_update_vsi_completion *) |
| 2294 | &desc.params.raw; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2295 | i40e_status status; |
| 2296 | |
| 2297 | i40e_fill_default_direct_cmd_desc(&desc, |
| 2298 | i40e_aqc_opc_update_vsi_parameters); |
Shannon Nelson | f5ac857 | 2013-11-28 06:39:43 +0000 | [diff] [blame] | 2299 | cmd->uplink_seid = cpu_to_le16(vsi_ctx->seid); |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2300 | |
| 2301 | desc.flags |= cpu_to_le16((u16)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD)); |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2302 | |
| 2303 | status = i40e_asq_send_command(hw, &desc, &vsi_ctx->info, |
| 2304 | sizeof(vsi_ctx->info), cmd_details); |
| 2305 | |
Kevin Scott | b6cacca | 2016-03-10 14:59:41 -0800 | [diff] [blame] | 2306 | vsi_ctx->vsis_allocated = le16_to_cpu(resp->vsi_used); |
| 2307 | vsi_ctx->vsis_unallocated = le16_to_cpu(resp->vsi_free); |
| 2308 | |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2309 | return status; |
| 2310 | } |
| 2311 | |
| 2312 | /** |
| 2313 | * i40e_aq_get_switch_config |
| 2314 | * @hw: pointer to the hardware structure |
| 2315 | * @buf: pointer to the result buffer |
| 2316 | * @buf_size: length of input buffer |
| 2317 | * @start_seid: seid to start for the report, 0 == beginning |
| 2318 | * @cmd_details: pointer to command details structure or NULL |
| 2319 | * |
| 2320 | * Fill the buf with switch configuration returned from AdminQ command |
| 2321 | **/ |
| 2322 | i40e_status i40e_aq_get_switch_config(struct i40e_hw *hw, |
| 2323 | struct i40e_aqc_get_switch_config_resp *buf, |
| 2324 | u16 buf_size, u16 *start_seid, |
| 2325 | struct i40e_asq_cmd_details *cmd_details) |
| 2326 | { |
| 2327 | struct i40e_aq_desc desc; |
| 2328 | struct i40e_aqc_switch_seid *scfg = |
| 2329 | (struct i40e_aqc_switch_seid *)&desc.params.raw; |
| 2330 | i40e_status status; |
| 2331 | |
| 2332 | i40e_fill_default_direct_cmd_desc(&desc, |
| 2333 | i40e_aqc_opc_get_switch_config); |
| 2334 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF); |
| 2335 | if (buf_size > I40E_AQ_LARGE_BUF) |
| 2336 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB); |
| 2337 | scfg->seid = cpu_to_le16(*start_seid); |
| 2338 | |
| 2339 | status = i40e_asq_send_command(hw, &desc, buf, buf_size, cmd_details); |
| 2340 | *start_seid = le16_to_cpu(scfg->seid); |
| 2341 | |
| 2342 | return status; |
| 2343 | } |
| 2344 | |
| 2345 | /** |
Shannon Nelson | f3d5849 | 2016-05-03 15:13:11 -0700 | [diff] [blame] | 2346 | * i40e_aq_set_switch_config |
| 2347 | * @hw: pointer to the hardware structure |
| 2348 | * @flags: bit flag values to set |
| 2349 | * @valid_flags: which bit flags to set |
| 2350 | * @cmd_details: pointer to command details structure or NULL |
| 2351 | * |
| 2352 | * Set switch configuration bits |
| 2353 | **/ |
| 2354 | enum i40e_status_code i40e_aq_set_switch_config(struct i40e_hw *hw, |
| 2355 | u16 flags, |
| 2356 | u16 valid_flags, |
| 2357 | struct i40e_asq_cmd_details *cmd_details) |
| 2358 | { |
| 2359 | struct i40e_aq_desc desc; |
| 2360 | struct i40e_aqc_set_switch_config *scfg = |
| 2361 | (struct i40e_aqc_set_switch_config *)&desc.params.raw; |
| 2362 | enum i40e_status_code status; |
| 2363 | |
| 2364 | i40e_fill_default_direct_cmd_desc(&desc, |
| 2365 | i40e_aqc_opc_set_switch_config); |
| 2366 | scfg->flags = cpu_to_le16(flags); |
| 2367 | scfg->valid_flags = cpu_to_le16(valid_flags); |
| 2368 | |
| 2369 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 2370 | |
| 2371 | return status; |
| 2372 | } |
| 2373 | |
| 2374 | /** |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2375 | * i40e_aq_get_firmware_version |
| 2376 | * @hw: pointer to the hw struct |
| 2377 | * @fw_major_version: firmware major version |
| 2378 | * @fw_minor_version: firmware minor version |
Shannon Nelson | 7edf810 | 2015-02-24 06:58:41 +0000 | [diff] [blame] | 2379 | * @fw_build: firmware build number |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2380 | * @api_major_version: major queue version |
| 2381 | * @api_minor_version: minor queue version |
| 2382 | * @cmd_details: pointer to command details structure or NULL |
| 2383 | * |
| 2384 | * Get the firmware version from the admin queue commands |
| 2385 | **/ |
| 2386 | i40e_status i40e_aq_get_firmware_version(struct i40e_hw *hw, |
| 2387 | u16 *fw_major_version, u16 *fw_minor_version, |
Shannon Nelson | 7edf810 | 2015-02-24 06:58:41 +0000 | [diff] [blame] | 2388 | u32 *fw_build, |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2389 | u16 *api_major_version, u16 *api_minor_version, |
| 2390 | struct i40e_asq_cmd_details *cmd_details) |
| 2391 | { |
| 2392 | struct i40e_aq_desc desc; |
| 2393 | struct i40e_aqc_get_version *resp = |
| 2394 | (struct i40e_aqc_get_version *)&desc.params.raw; |
| 2395 | i40e_status status; |
| 2396 | |
| 2397 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_get_version); |
| 2398 | |
| 2399 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 2400 | |
| 2401 | if (!status) { |
Shannon Nelson | 7edf810 | 2015-02-24 06:58:41 +0000 | [diff] [blame] | 2402 | if (fw_major_version) |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2403 | *fw_major_version = le16_to_cpu(resp->fw_major); |
Shannon Nelson | 7edf810 | 2015-02-24 06:58:41 +0000 | [diff] [blame] | 2404 | if (fw_minor_version) |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2405 | *fw_minor_version = le16_to_cpu(resp->fw_minor); |
Shannon Nelson | 7edf810 | 2015-02-24 06:58:41 +0000 | [diff] [blame] | 2406 | if (fw_build) |
| 2407 | *fw_build = le32_to_cpu(resp->fw_build); |
| 2408 | if (api_major_version) |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2409 | *api_major_version = le16_to_cpu(resp->api_major); |
Shannon Nelson | 7edf810 | 2015-02-24 06:58:41 +0000 | [diff] [blame] | 2410 | if (api_minor_version) |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2411 | *api_minor_version = le16_to_cpu(resp->api_minor); |
| 2412 | } |
| 2413 | |
| 2414 | return status; |
| 2415 | } |
| 2416 | |
| 2417 | /** |
| 2418 | * i40e_aq_send_driver_version |
| 2419 | * @hw: pointer to the hw struct |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2420 | * @dv: driver's major, minor version |
| 2421 | * @cmd_details: pointer to command details structure or NULL |
| 2422 | * |
| 2423 | * Send the driver version to the firmware |
| 2424 | **/ |
| 2425 | i40e_status i40e_aq_send_driver_version(struct i40e_hw *hw, |
| 2426 | struct i40e_driver_version *dv, |
| 2427 | struct i40e_asq_cmd_details *cmd_details) |
| 2428 | { |
| 2429 | struct i40e_aq_desc desc; |
| 2430 | struct i40e_aqc_driver_version *cmd = |
| 2431 | (struct i40e_aqc_driver_version *)&desc.params.raw; |
| 2432 | i40e_status status; |
Kevin Scott | 9d2f98e | 2014-04-01 07:11:52 +0000 | [diff] [blame] | 2433 | u16 len; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2434 | |
| 2435 | if (dv == NULL) |
| 2436 | return I40E_ERR_PARAM; |
| 2437 | |
| 2438 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_driver_version); |
| 2439 | |
Kevin Scott | 3b38cd1 | 2015-02-06 08:52:18 +0000 | [diff] [blame] | 2440 | desc.flags |= cpu_to_le16(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD); |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2441 | cmd->driver_major_ver = dv->major_version; |
| 2442 | cmd->driver_minor_ver = dv->minor_version; |
| 2443 | cmd->driver_build_ver = dv->build_version; |
| 2444 | cmd->driver_subbuild_ver = dv->subbuild_version; |
Shannon Nelson | d246601 | 2014-04-01 07:11:45 +0000 | [diff] [blame] | 2445 | |
| 2446 | len = 0; |
| 2447 | while (len < sizeof(dv->driver_string) && |
| 2448 | (dv->driver_string[len] < 0x80) && |
| 2449 | dv->driver_string[len]) |
| 2450 | len++; |
| 2451 | status = i40e_asq_send_command(hw, &desc, dv->driver_string, |
| 2452 | len, cmd_details); |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2453 | |
| 2454 | return status; |
| 2455 | } |
| 2456 | |
| 2457 | /** |
| 2458 | * i40e_get_link_status - get status of the HW network link |
| 2459 | * @hw: pointer to the hw struct |
Jesse Brandeburg | a72a5abc | 2015-08-26 15:14:19 -0400 | [diff] [blame] | 2460 | * @link_up: pointer to bool (true/false = linkup/linkdown) |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2461 | * |
Jesse Brandeburg | a72a5abc | 2015-08-26 15:14:19 -0400 | [diff] [blame] | 2462 | * Variable link_up true if link is up, false if link is down. |
| 2463 | * The variable link_up is invalid if returned value of status != 0 |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2464 | * |
| 2465 | * Side effect: LinkStatusEvent reporting becomes enabled |
| 2466 | **/ |
Jesse Brandeburg | a72a5abc | 2015-08-26 15:14:19 -0400 | [diff] [blame] | 2467 | i40e_status i40e_get_link_status(struct i40e_hw *hw, bool *link_up) |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2468 | { |
| 2469 | i40e_status status = 0; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2470 | |
| 2471 | if (hw->phy.get_link_info) { |
Catherine Sullivan | 0a862b4 | 2015-08-31 19:54:53 -0400 | [diff] [blame] | 2472 | status = i40e_update_link_info(hw); |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2473 | |
| 2474 | if (status) |
Jesse Brandeburg | a72a5abc | 2015-08-26 15:14:19 -0400 | [diff] [blame] | 2475 | i40e_debug(hw, I40E_DEBUG_LINK, "get link failed: status %d\n", |
| 2476 | status); |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2477 | } |
| 2478 | |
Jesse Brandeburg | a72a5abc | 2015-08-26 15:14:19 -0400 | [diff] [blame] | 2479 | *link_up = hw->phy.link_info.link_info & I40E_AQ_LINK_UP; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2480 | |
Jesse Brandeburg | a72a5abc | 2015-08-26 15:14:19 -0400 | [diff] [blame] | 2481 | return status; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2482 | } |
| 2483 | |
| 2484 | /** |
Catherine Sullivan | 0a862b4 | 2015-08-31 19:54:53 -0400 | [diff] [blame] | 2485 | * i40e_updatelink_status - update status of the HW network link |
| 2486 | * @hw: pointer to the hw struct |
| 2487 | **/ |
| 2488 | i40e_status i40e_update_link_info(struct i40e_hw *hw) |
| 2489 | { |
| 2490 | struct i40e_aq_get_phy_abilities_resp abilities; |
| 2491 | i40e_status status = 0; |
| 2492 | |
| 2493 | status = i40e_aq_get_link_info(hw, true, NULL, NULL); |
| 2494 | if (status) |
| 2495 | return status; |
| 2496 | |
Carolyn Wyborny | ab425cb | 2016-09-27 11:28:52 -0700 | [diff] [blame] | 2497 | /* extra checking needed to ensure link info to user is timely */ |
| 2498 | if ((hw->phy.link_info.link_info & I40E_AQ_MEDIA_AVAILABLE) && |
| 2499 | ((hw->phy.link_info.link_info & I40E_AQ_LINK_UP) || |
| 2500 | !(hw->phy.link_info_old.link_info & I40E_AQ_LINK_UP))) { |
Carolyn Wyborny | 8589af7 | 2015-09-28 14:16:56 -0400 | [diff] [blame] | 2501 | status = i40e_aq_get_phy_capabilities(hw, false, false, |
| 2502 | &abilities, NULL); |
| 2503 | if (status) |
| 2504 | return status; |
Catherine Sullivan | 0a862b4 | 2015-08-31 19:54:53 -0400 | [diff] [blame] | 2505 | |
Carolyn Wyborny | 8589af7 | 2015-09-28 14:16:56 -0400 | [diff] [blame] | 2506 | memcpy(hw->phy.link_info.module_type, &abilities.module_type, |
| 2507 | sizeof(hw->phy.link_info.module_type)); |
| 2508 | } |
Catherine Sullivan | 0a862b4 | 2015-08-31 19:54:53 -0400 | [diff] [blame] | 2509 | |
| 2510 | return status; |
| 2511 | } |
| 2512 | |
| 2513 | /** |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2514 | * i40e_aq_add_veb - Insert a VEB between the VSI and the MAC |
| 2515 | * @hw: pointer to the hw struct |
| 2516 | * @uplink_seid: the MAC or other gizmo SEID |
| 2517 | * @downlink_seid: the VSI SEID |
| 2518 | * @enabled_tc: bitmap of TCs to be enabled |
| 2519 | * @default_port: true for default port VSI, false for control port |
| 2520 | * @veb_seid: pointer to where to put the resulting VEB SEID |
Shannon Nelson | 8a187f4 | 2016-01-13 16:51:41 -0800 | [diff] [blame] | 2521 | * @enable_stats: true to turn on VEB stats |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2522 | * @cmd_details: pointer to command details structure or NULL |
| 2523 | * |
| 2524 | * This asks the FW to add a VEB between the uplink and downlink |
| 2525 | * elements. If the uplink SEID is 0, this will be a floating VEB. |
| 2526 | **/ |
| 2527 | i40e_status i40e_aq_add_veb(struct i40e_hw *hw, u16 uplink_seid, |
| 2528 | u16 downlink_seid, u8 enabled_tc, |
Shannon Nelson | 8a187f4 | 2016-01-13 16:51:41 -0800 | [diff] [blame] | 2529 | bool default_port, u16 *veb_seid, |
| 2530 | bool enable_stats, |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2531 | struct i40e_asq_cmd_details *cmd_details) |
| 2532 | { |
| 2533 | struct i40e_aq_desc desc; |
| 2534 | struct i40e_aqc_add_veb *cmd = |
| 2535 | (struct i40e_aqc_add_veb *)&desc.params.raw; |
| 2536 | struct i40e_aqc_add_veb_completion *resp = |
| 2537 | (struct i40e_aqc_add_veb_completion *)&desc.params.raw; |
| 2538 | i40e_status status; |
| 2539 | u16 veb_flags = 0; |
| 2540 | |
| 2541 | /* SEIDs need to either both be set or both be 0 for floating VEB */ |
| 2542 | if (!!uplink_seid != !!downlink_seid) |
| 2543 | return I40E_ERR_PARAM; |
| 2544 | |
| 2545 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_add_veb); |
| 2546 | |
| 2547 | cmd->uplink_seid = cpu_to_le16(uplink_seid); |
| 2548 | cmd->downlink_seid = cpu_to_le16(downlink_seid); |
| 2549 | cmd->enable_tcs = enabled_tc; |
| 2550 | if (!uplink_seid) |
| 2551 | veb_flags |= I40E_AQC_ADD_VEB_FLOATING; |
| 2552 | if (default_port) |
| 2553 | veb_flags |= I40E_AQC_ADD_VEB_PORT_TYPE_DEFAULT; |
| 2554 | else |
| 2555 | veb_flags |= I40E_AQC_ADD_VEB_PORT_TYPE_DATA; |
Kevin Scott | e1c51b95 | 2013-11-20 10:02:51 +0000 | [diff] [blame] | 2556 | |
Shannon Nelson | 8a187f4 | 2016-01-13 16:51:41 -0800 | [diff] [blame] | 2557 | /* reverse logic here: set the bitflag to disable the stats */ |
| 2558 | if (!enable_stats) |
| 2559 | veb_flags |= I40E_AQC_ADD_VEB_ENABLE_DISABLE_STATS; |
Kevin Scott | e1c51b95 | 2013-11-20 10:02:51 +0000 | [diff] [blame] | 2560 | |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2561 | cmd->veb_flags = cpu_to_le16(veb_flags); |
| 2562 | |
| 2563 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 2564 | |
| 2565 | if (!status && veb_seid) |
| 2566 | *veb_seid = le16_to_cpu(resp->veb_seid); |
| 2567 | |
| 2568 | return status; |
| 2569 | } |
| 2570 | |
| 2571 | /** |
| 2572 | * i40e_aq_get_veb_parameters - Retrieve VEB parameters |
| 2573 | * @hw: pointer to the hw struct |
| 2574 | * @veb_seid: the SEID of the VEB to query |
| 2575 | * @switch_id: the uplink switch id |
Jeff Kirsher | 98d4438 | 2013-12-21 05:44:42 +0000 | [diff] [blame] | 2576 | * @floating: set to true if the VEB is floating |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2577 | * @statistic_index: index of the stats counter block for this VEB |
| 2578 | * @vebs_used: number of VEB's used by function |
Jeff Kirsher | 98d4438 | 2013-12-21 05:44:42 +0000 | [diff] [blame] | 2579 | * @vebs_free: total VEB's not reserved by any function |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2580 | * @cmd_details: pointer to command details structure or NULL |
| 2581 | * |
| 2582 | * This retrieves the parameters for a particular VEB, specified by |
| 2583 | * uplink_seid, and returns them to the caller. |
| 2584 | **/ |
| 2585 | i40e_status i40e_aq_get_veb_parameters(struct i40e_hw *hw, |
| 2586 | u16 veb_seid, u16 *switch_id, |
| 2587 | bool *floating, u16 *statistic_index, |
| 2588 | u16 *vebs_used, u16 *vebs_free, |
| 2589 | struct i40e_asq_cmd_details *cmd_details) |
| 2590 | { |
| 2591 | struct i40e_aq_desc desc; |
| 2592 | struct i40e_aqc_get_veb_parameters_completion *cmd_resp = |
| 2593 | (struct i40e_aqc_get_veb_parameters_completion *) |
| 2594 | &desc.params.raw; |
| 2595 | i40e_status status; |
| 2596 | |
| 2597 | if (veb_seid == 0) |
| 2598 | return I40E_ERR_PARAM; |
| 2599 | |
| 2600 | i40e_fill_default_direct_cmd_desc(&desc, |
| 2601 | i40e_aqc_opc_get_veb_parameters); |
| 2602 | cmd_resp->seid = cpu_to_le16(veb_seid); |
| 2603 | |
| 2604 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 2605 | if (status) |
| 2606 | goto get_veb_exit; |
| 2607 | |
| 2608 | if (switch_id) |
| 2609 | *switch_id = le16_to_cpu(cmd_resp->switch_id); |
| 2610 | if (statistic_index) |
| 2611 | *statistic_index = le16_to_cpu(cmd_resp->statistic_index); |
| 2612 | if (vebs_used) |
| 2613 | *vebs_used = le16_to_cpu(cmd_resp->vebs_used); |
| 2614 | if (vebs_free) |
| 2615 | *vebs_free = le16_to_cpu(cmd_resp->vebs_free); |
| 2616 | if (floating) { |
| 2617 | u16 flags = le16_to_cpu(cmd_resp->veb_flags); |
Jesse Brandeburg | 6995b36 | 2015-08-28 17:55:54 -0400 | [diff] [blame] | 2618 | |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2619 | if (flags & I40E_AQC_ADD_VEB_FLOATING) |
| 2620 | *floating = true; |
| 2621 | else |
| 2622 | *floating = false; |
| 2623 | } |
| 2624 | |
| 2625 | get_veb_exit: |
| 2626 | return status; |
| 2627 | } |
| 2628 | |
| 2629 | /** |
| 2630 | * i40e_aq_add_macvlan |
| 2631 | * @hw: pointer to the hw struct |
| 2632 | * @seid: VSI for the mac address |
| 2633 | * @mv_list: list of macvlans to be added |
| 2634 | * @count: length of the list |
| 2635 | * @cmd_details: pointer to command details structure or NULL |
| 2636 | * |
| 2637 | * Add MAC/VLAN addresses to the HW filtering |
| 2638 | **/ |
| 2639 | i40e_status i40e_aq_add_macvlan(struct i40e_hw *hw, u16 seid, |
| 2640 | struct i40e_aqc_add_macvlan_element_data *mv_list, |
| 2641 | u16 count, struct i40e_asq_cmd_details *cmd_details) |
| 2642 | { |
| 2643 | struct i40e_aq_desc desc; |
| 2644 | struct i40e_aqc_macvlan *cmd = |
| 2645 | (struct i40e_aqc_macvlan *)&desc.params.raw; |
| 2646 | i40e_status status; |
| 2647 | u16 buf_size; |
Shannon Nelson | 67be6eb | 2016-01-13 16:51:40 -0800 | [diff] [blame] | 2648 | int i; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2649 | |
| 2650 | if (count == 0 || !mv_list || !hw) |
| 2651 | return I40E_ERR_PARAM; |
| 2652 | |
Shannon Nelson | 1efc80e | 2015-02-27 09:18:30 +0000 | [diff] [blame] | 2653 | buf_size = count * sizeof(*mv_list); |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2654 | |
| 2655 | /* prep the rest of the request */ |
| 2656 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_add_macvlan); |
| 2657 | cmd->num_addresses = cpu_to_le16(count); |
| 2658 | cmd->seid[0] = cpu_to_le16(I40E_AQC_MACVLAN_CMD_SEID_VALID | seid); |
| 2659 | cmd->seid[1] = 0; |
| 2660 | cmd->seid[2] = 0; |
| 2661 | |
Shannon Nelson | 67be6eb | 2016-01-13 16:51:40 -0800 | [diff] [blame] | 2662 | for (i = 0; i < count; i++) |
| 2663 | if (is_multicast_ether_addr(mv_list[i].mac_addr)) |
| 2664 | mv_list[i].flags |= |
| 2665 | cpu_to_le16(I40E_AQC_MACVLAN_ADD_USE_SHARED_MAC); |
| 2666 | |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2667 | desc.flags |= cpu_to_le16((u16)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD)); |
| 2668 | if (buf_size > I40E_AQ_LARGE_BUF) |
| 2669 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB); |
| 2670 | |
| 2671 | status = i40e_asq_send_command(hw, &desc, mv_list, buf_size, |
Shannon Nelson | 67be6eb | 2016-01-13 16:51:40 -0800 | [diff] [blame] | 2672 | cmd_details); |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2673 | |
| 2674 | return status; |
| 2675 | } |
| 2676 | |
| 2677 | /** |
| 2678 | * i40e_aq_remove_macvlan |
| 2679 | * @hw: pointer to the hw struct |
| 2680 | * @seid: VSI for the mac address |
| 2681 | * @mv_list: list of macvlans to be removed |
| 2682 | * @count: length of the list |
| 2683 | * @cmd_details: pointer to command details structure or NULL |
| 2684 | * |
| 2685 | * Remove MAC/VLAN addresses from the HW filtering |
| 2686 | **/ |
| 2687 | i40e_status i40e_aq_remove_macvlan(struct i40e_hw *hw, u16 seid, |
| 2688 | struct i40e_aqc_remove_macvlan_element_data *mv_list, |
| 2689 | u16 count, struct i40e_asq_cmd_details *cmd_details) |
| 2690 | { |
| 2691 | struct i40e_aq_desc desc; |
| 2692 | struct i40e_aqc_macvlan *cmd = |
| 2693 | (struct i40e_aqc_macvlan *)&desc.params.raw; |
| 2694 | i40e_status status; |
| 2695 | u16 buf_size; |
| 2696 | |
| 2697 | if (count == 0 || !mv_list || !hw) |
| 2698 | return I40E_ERR_PARAM; |
| 2699 | |
Shannon Nelson | 1efc80e | 2015-02-27 09:18:30 +0000 | [diff] [blame] | 2700 | buf_size = count * sizeof(*mv_list); |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2701 | |
| 2702 | /* prep the rest of the request */ |
| 2703 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_remove_macvlan); |
| 2704 | cmd->num_addresses = cpu_to_le16(count); |
| 2705 | cmd->seid[0] = cpu_to_le16(I40E_AQC_MACVLAN_CMD_SEID_VALID | seid); |
| 2706 | cmd->seid[1] = 0; |
| 2707 | cmd->seid[2] = 0; |
| 2708 | |
| 2709 | desc.flags |= cpu_to_le16((u16)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD)); |
| 2710 | if (buf_size > I40E_AQ_LARGE_BUF) |
| 2711 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB); |
| 2712 | |
| 2713 | status = i40e_asq_send_command(hw, &desc, mv_list, buf_size, |
| 2714 | cmd_details); |
| 2715 | |
| 2716 | return status; |
| 2717 | } |
| 2718 | |
| 2719 | /** |
Kiran Patil | 7bd6875 | 2016-01-04 10:33:07 -0800 | [diff] [blame] | 2720 | * i40e_mirrorrule_op - Internal helper function to add/delete mirror rule |
| 2721 | * @hw: pointer to the hw struct |
| 2722 | * @opcode: AQ opcode for add or delete mirror rule |
| 2723 | * @sw_seid: Switch SEID (to which rule refers) |
| 2724 | * @rule_type: Rule Type (ingress/egress/VLAN) |
| 2725 | * @id: Destination VSI SEID or Rule ID |
| 2726 | * @count: length of the list |
| 2727 | * @mr_list: list of mirrored VSI SEIDs or VLAN IDs |
| 2728 | * @cmd_details: pointer to command details structure or NULL |
| 2729 | * @rule_id: Rule ID returned from FW |
| 2730 | * @rule_used: Number of rules used in internal switch |
| 2731 | * @rule_free: Number of rules free in internal switch |
| 2732 | * |
| 2733 | * Add/Delete a mirror rule to a specific switch. Mirror rules are supported for |
| 2734 | * VEBs/VEPA elements only |
| 2735 | **/ |
| 2736 | static i40e_status i40e_mirrorrule_op(struct i40e_hw *hw, |
| 2737 | u16 opcode, u16 sw_seid, u16 rule_type, u16 id, |
| 2738 | u16 count, __le16 *mr_list, |
| 2739 | struct i40e_asq_cmd_details *cmd_details, |
| 2740 | u16 *rule_id, u16 *rules_used, u16 *rules_free) |
| 2741 | { |
| 2742 | struct i40e_aq_desc desc; |
| 2743 | struct i40e_aqc_add_delete_mirror_rule *cmd = |
| 2744 | (struct i40e_aqc_add_delete_mirror_rule *)&desc.params.raw; |
| 2745 | struct i40e_aqc_add_delete_mirror_rule_completion *resp = |
| 2746 | (struct i40e_aqc_add_delete_mirror_rule_completion *)&desc.params.raw; |
| 2747 | i40e_status status; |
| 2748 | u16 buf_size; |
| 2749 | |
| 2750 | buf_size = count * sizeof(*mr_list); |
| 2751 | |
| 2752 | /* prep the rest of the request */ |
| 2753 | i40e_fill_default_direct_cmd_desc(&desc, opcode); |
| 2754 | cmd->seid = cpu_to_le16(sw_seid); |
| 2755 | cmd->rule_type = cpu_to_le16(rule_type & |
| 2756 | I40E_AQC_MIRROR_RULE_TYPE_MASK); |
| 2757 | cmd->num_entries = cpu_to_le16(count); |
| 2758 | /* Dest VSI for add, rule_id for delete */ |
| 2759 | cmd->destination = cpu_to_le16(id); |
| 2760 | if (mr_list) { |
| 2761 | desc.flags |= cpu_to_le16((u16)(I40E_AQ_FLAG_BUF | |
| 2762 | I40E_AQ_FLAG_RD)); |
| 2763 | if (buf_size > I40E_AQ_LARGE_BUF) |
| 2764 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB); |
| 2765 | } |
| 2766 | |
| 2767 | status = i40e_asq_send_command(hw, &desc, mr_list, buf_size, |
| 2768 | cmd_details); |
| 2769 | if (!status || |
| 2770 | hw->aq.asq_last_status == I40E_AQ_RC_ENOSPC) { |
| 2771 | if (rule_id) |
| 2772 | *rule_id = le16_to_cpu(resp->rule_id); |
| 2773 | if (rules_used) |
| 2774 | *rules_used = le16_to_cpu(resp->mirror_rules_used); |
| 2775 | if (rules_free) |
| 2776 | *rules_free = le16_to_cpu(resp->mirror_rules_free); |
| 2777 | } |
| 2778 | return status; |
| 2779 | } |
| 2780 | |
| 2781 | /** |
| 2782 | * i40e_aq_add_mirrorrule - add a mirror rule |
| 2783 | * @hw: pointer to the hw struct |
| 2784 | * @sw_seid: Switch SEID (to which rule refers) |
| 2785 | * @rule_type: Rule Type (ingress/egress/VLAN) |
| 2786 | * @dest_vsi: SEID of VSI to which packets will be mirrored |
| 2787 | * @count: length of the list |
| 2788 | * @mr_list: list of mirrored VSI SEIDs or VLAN IDs |
| 2789 | * @cmd_details: pointer to command details structure or NULL |
| 2790 | * @rule_id: Rule ID returned from FW |
| 2791 | * @rule_used: Number of rules used in internal switch |
| 2792 | * @rule_free: Number of rules free in internal switch |
| 2793 | * |
| 2794 | * Add mirror rule. Mirror rules are supported for VEBs or VEPA elements only |
| 2795 | **/ |
| 2796 | i40e_status i40e_aq_add_mirrorrule(struct i40e_hw *hw, u16 sw_seid, |
| 2797 | u16 rule_type, u16 dest_vsi, u16 count, __le16 *mr_list, |
| 2798 | struct i40e_asq_cmd_details *cmd_details, |
| 2799 | u16 *rule_id, u16 *rules_used, u16 *rules_free) |
| 2800 | { |
| 2801 | if (!(rule_type == I40E_AQC_MIRROR_RULE_TYPE_ALL_INGRESS || |
| 2802 | rule_type == I40E_AQC_MIRROR_RULE_TYPE_ALL_EGRESS)) { |
| 2803 | if (count == 0 || !mr_list) |
| 2804 | return I40E_ERR_PARAM; |
| 2805 | } |
| 2806 | |
| 2807 | return i40e_mirrorrule_op(hw, i40e_aqc_opc_add_mirror_rule, sw_seid, |
| 2808 | rule_type, dest_vsi, count, mr_list, |
| 2809 | cmd_details, rule_id, rules_used, rules_free); |
| 2810 | } |
| 2811 | |
| 2812 | /** |
| 2813 | * i40e_aq_delete_mirrorrule - delete a mirror rule |
| 2814 | * @hw: pointer to the hw struct |
| 2815 | * @sw_seid: Switch SEID (to which rule refers) |
| 2816 | * @rule_type: Rule Type (ingress/egress/VLAN) |
| 2817 | * @count: length of the list |
| 2818 | * @rule_id: Rule ID that is returned in the receive desc as part of |
| 2819 | * add_mirrorrule. |
| 2820 | * @mr_list: list of mirrored VLAN IDs to be removed |
| 2821 | * @cmd_details: pointer to command details structure or NULL |
| 2822 | * @rule_used: Number of rules used in internal switch |
| 2823 | * @rule_free: Number of rules free in internal switch |
| 2824 | * |
| 2825 | * Delete a mirror rule. Mirror rules are supported for VEBs/VEPA elements only |
| 2826 | **/ |
| 2827 | i40e_status i40e_aq_delete_mirrorrule(struct i40e_hw *hw, u16 sw_seid, |
| 2828 | u16 rule_type, u16 rule_id, u16 count, __le16 *mr_list, |
| 2829 | struct i40e_asq_cmd_details *cmd_details, |
| 2830 | u16 *rules_used, u16 *rules_free) |
| 2831 | { |
| 2832 | /* Rule ID has to be valid except rule_type: INGRESS VLAN mirroring */ |
Greg Rose | db07727 | 2016-04-12 08:30:48 -0700 | [diff] [blame] | 2833 | if (rule_type == I40E_AQC_MIRROR_RULE_TYPE_VLAN) { |
Kiran Patil | 7bd6875 | 2016-01-04 10:33:07 -0800 | [diff] [blame] | 2834 | /* count and mr_list shall be valid for rule_type INGRESS VLAN |
| 2835 | * mirroring. For other rule_type, count and rule_type should |
| 2836 | * not matter. |
| 2837 | */ |
| 2838 | if (count == 0 || !mr_list) |
| 2839 | return I40E_ERR_PARAM; |
| 2840 | } |
| 2841 | |
| 2842 | return i40e_mirrorrule_op(hw, i40e_aqc_opc_delete_mirror_rule, sw_seid, |
| 2843 | rule_type, rule_id, count, mr_list, |
| 2844 | cmd_details, NULL, rules_used, rules_free); |
| 2845 | } |
| 2846 | |
| 2847 | /** |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2848 | * i40e_aq_send_msg_to_vf |
| 2849 | * @hw: pointer to the hardware structure |
Jeff Kirsher | b40c82e | 2015-02-27 09:18:34 +0000 | [diff] [blame] | 2850 | * @vfid: VF id to send msg |
Jeff Kirsher | 98d4438 | 2013-12-21 05:44:42 +0000 | [diff] [blame] | 2851 | * @v_opcode: opcodes for VF-PF communication |
| 2852 | * @v_retval: return error code |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2853 | * @msg: pointer to the msg buffer |
| 2854 | * @msglen: msg length |
| 2855 | * @cmd_details: pointer to command details |
| 2856 | * |
| 2857 | * send msg to vf |
| 2858 | **/ |
| 2859 | i40e_status i40e_aq_send_msg_to_vf(struct i40e_hw *hw, u16 vfid, |
| 2860 | u32 v_opcode, u32 v_retval, u8 *msg, u16 msglen, |
| 2861 | struct i40e_asq_cmd_details *cmd_details) |
| 2862 | { |
| 2863 | struct i40e_aq_desc desc; |
| 2864 | struct i40e_aqc_pf_vf_message *cmd = |
| 2865 | (struct i40e_aqc_pf_vf_message *)&desc.params.raw; |
| 2866 | i40e_status status; |
| 2867 | |
| 2868 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_send_msg_to_vf); |
| 2869 | cmd->id = cpu_to_le32(vfid); |
| 2870 | desc.cookie_high = cpu_to_le32(v_opcode); |
| 2871 | desc.cookie_low = cpu_to_le32(v_retval); |
| 2872 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_SI); |
| 2873 | if (msglen) { |
| 2874 | desc.flags |= cpu_to_le16((u16)(I40E_AQ_FLAG_BUF | |
| 2875 | I40E_AQ_FLAG_RD)); |
| 2876 | if (msglen > I40E_AQ_LARGE_BUF) |
| 2877 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB); |
| 2878 | desc.datalen = cpu_to_le16(msglen); |
| 2879 | } |
| 2880 | status = i40e_asq_send_command(hw, &desc, msg, msglen, cmd_details); |
| 2881 | |
| 2882 | return status; |
| 2883 | } |
| 2884 | |
| 2885 | /** |
Shannon Nelson | 9fee9db | 2014-12-11 07:06:30 +0000 | [diff] [blame] | 2886 | * i40e_aq_debug_read_register |
| 2887 | * @hw: pointer to the hw struct |
| 2888 | * @reg_addr: register address |
| 2889 | * @reg_val: register value |
| 2890 | * @cmd_details: pointer to command details structure or NULL |
| 2891 | * |
| 2892 | * Read the register using the admin queue commands |
| 2893 | **/ |
| 2894 | i40e_status i40e_aq_debug_read_register(struct i40e_hw *hw, |
Jesse Brandeburg | 7b115dd | 2015-02-27 09:15:23 +0000 | [diff] [blame] | 2895 | u32 reg_addr, u64 *reg_val, |
Shannon Nelson | 9fee9db | 2014-12-11 07:06:30 +0000 | [diff] [blame] | 2896 | struct i40e_asq_cmd_details *cmd_details) |
| 2897 | { |
| 2898 | struct i40e_aq_desc desc; |
| 2899 | struct i40e_aqc_debug_reg_read_write *cmd_resp = |
| 2900 | (struct i40e_aqc_debug_reg_read_write *)&desc.params.raw; |
| 2901 | i40e_status status; |
| 2902 | |
| 2903 | if (reg_val == NULL) |
| 2904 | return I40E_ERR_PARAM; |
| 2905 | |
Jesse Brandeburg | 7b115dd | 2015-02-27 09:15:23 +0000 | [diff] [blame] | 2906 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_debug_read_reg); |
Shannon Nelson | 9fee9db | 2014-12-11 07:06:30 +0000 | [diff] [blame] | 2907 | |
| 2908 | cmd_resp->address = cpu_to_le32(reg_addr); |
| 2909 | |
| 2910 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 2911 | |
| 2912 | if (!status) { |
Jesse Brandeburg | 7b115dd | 2015-02-27 09:15:23 +0000 | [diff] [blame] | 2913 | *reg_val = ((u64)le32_to_cpu(cmd_resp->value_high) << 32) | |
| 2914 | (u64)le32_to_cpu(cmd_resp->value_low); |
Shannon Nelson | 9fee9db | 2014-12-11 07:06:30 +0000 | [diff] [blame] | 2915 | } |
| 2916 | |
| 2917 | return status; |
| 2918 | } |
| 2919 | |
| 2920 | /** |
Shannon Nelson | 53db45c | 2014-08-01 13:27:05 -0700 | [diff] [blame] | 2921 | * i40e_aq_debug_write_register |
| 2922 | * @hw: pointer to the hw struct |
| 2923 | * @reg_addr: register address |
| 2924 | * @reg_val: register value |
| 2925 | * @cmd_details: pointer to command details structure or NULL |
| 2926 | * |
| 2927 | * Write to a register using the admin queue commands |
| 2928 | **/ |
| 2929 | i40e_status i40e_aq_debug_write_register(struct i40e_hw *hw, |
| 2930 | u32 reg_addr, u64 reg_val, |
| 2931 | struct i40e_asq_cmd_details *cmd_details) |
| 2932 | { |
| 2933 | struct i40e_aq_desc desc; |
| 2934 | struct i40e_aqc_debug_reg_read_write *cmd = |
| 2935 | (struct i40e_aqc_debug_reg_read_write *)&desc.params.raw; |
| 2936 | i40e_status status; |
| 2937 | |
| 2938 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_debug_write_reg); |
| 2939 | |
| 2940 | cmd->address = cpu_to_le32(reg_addr); |
| 2941 | cmd->value_high = cpu_to_le32((u32)(reg_val >> 32)); |
| 2942 | cmd->value_low = cpu_to_le32((u32)(reg_val & 0xFFFFFFFF)); |
| 2943 | |
| 2944 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 2945 | |
| 2946 | return status; |
| 2947 | } |
| 2948 | |
| 2949 | /** |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 2950 | * i40e_aq_request_resource |
| 2951 | * @hw: pointer to the hw struct |
| 2952 | * @resource: resource id |
| 2953 | * @access: access type |
| 2954 | * @sdp_number: resource number |
| 2955 | * @timeout: the maximum time in ms that the driver may hold the resource |
| 2956 | * @cmd_details: pointer to command details structure or NULL |
| 2957 | * |
| 2958 | * requests common resource using the admin queue commands |
| 2959 | **/ |
| 2960 | i40e_status i40e_aq_request_resource(struct i40e_hw *hw, |
| 2961 | enum i40e_aq_resources_ids resource, |
| 2962 | enum i40e_aq_resource_access_type access, |
| 2963 | u8 sdp_number, u64 *timeout, |
| 2964 | struct i40e_asq_cmd_details *cmd_details) |
| 2965 | { |
| 2966 | struct i40e_aq_desc desc; |
| 2967 | struct i40e_aqc_request_resource *cmd_resp = |
| 2968 | (struct i40e_aqc_request_resource *)&desc.params.raw; |
| 2969 | i40e_status status; |
| 2970 | |
| 2971 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_request_resource); |
| 2972 | |
| 2973 | cmd_resp->resource_id = cpu_to_le16(resource); |
| 2974 | cmd_resp->access_type = cpu_to_le16(access); |
| 2975 | cmd_resp->resource_number = cpu_to_le32(sdp_number); |
| 2976 | |
| 2977 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 2978 | /* The completion specifies the maximum time in ms that the driver |
| 2979 | * may hold the resource in the Timeout field. |
| 2980 | * If the resource is held by someone else, the command completes with |
| 2981 | * busy return value and the timeout field indicates the maximum time |
| 2982 | * the current owner of the resource has to free it. |
| 2983 | */ |
| 2984 | if (!status || hw->aq.asq_last_status == I40E_AQ_RC_EBUSY) |
| 2985 | *timeout = le32_to_cpu(cmd_resp->timeout); |
| 2986 | |
| 2987 | return status; |
| 2988 | } |
| 2989 | |
| 2990 | /** |
| 2991 | * i40e_aq_release_resource |
| 2992 | * @hw: pointer to the hw struct |
| 2993 | * @resource: resource id |
| 2994 | * @sdp_number: resource number |
| 2995 | * @cmd_details: pointer to command details structure or NULL |
| 2996 | * |
| 2997 | * release common resource using the admin queue commands |
| 2998 | **/ |
| 2999 | i40e_status i40e_aq_release_resource(struct i40e_hw *hw, |
| 3000 | enum i40e_aq_resources_ids resource, |
| 3001 | u8 sdp_number, |
| 3002 | struct i40e_asq_cmd_details *cmd_details) |
| 3003 | { |
| 3004 | struct i40e_aq_desc desc; |
| 3005 | struct i40e_aqc_request_resource *cmd = |
| 3006 | (struct i40e_aqc_request_resource *)&desc.params.raw; |
| 3007 | i40e_status status; |
| 3008 | |
| 3009 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_release_resource); |
| 3010 | |
| 3011 | cmd->resource_id = cpu_to_le16(resource); |
| 3012 | cmd->resource_number = cpu_to_le32(sdp_number); |
| 3013 | |
| 3014 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 3015 | |
| 3016 | return status; |
| 3017 | } |
| 3018 | |
| 3019 | /** |
| 3020 | * i40e_aq_read_nvm |
| 3021 | * @hw: pointer to the hw struct |
| 3022 | * @module_pointer: module pointer location in words from the NVM beginning |
| 3023 | * @offset: byte offset from the module beginning |
| 3024 | * @length: length of the section to be read (in bytes from the offset) |
| 3025 | * @data: command buffer (size [bytes] = length) |
| 3026 | * @last_command: tells if this is the last command in a series |
| 3027 | * @cmd_details: pointer to command details structure or NULL |
| 3028 | * |
| 3029 | * Read the NVM using the admin queue commands |
| 3030 | **/ |
| 3031 | i40e_status i40e_aq_read_nvm(struct i40e_hw *hw, u8 module_pointer, |
| 3032 | u32 offset, u16 length, void *data, |
| 3033 | bool last_command, |
| 3034 | struct i40e_asq_cmd_details *cmd_details) |
| 3035 | { |
| 3036 | struct i40e_aq_desc desc; |
| 3037 | struct i40e_aqc_nvm_update *cmd = |
| 3038 | (struct i40e_aqc_nvm_update *)&desc.params.raw; |
| 3039 | i40e_status status; |
| 3040 | |
| 3041 | /* In offset the highest byte must be zeroed. */ |
| 3042 | if (offset & 0xFF000000) { |
| 3043 | status = I40E_ERR_PARAM; |
| 3044 | goto i40e_aq_read_nvm_exit; |
| 3045 | } |
| 3046 | |
| 3047 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_nvm_read); |
| 3048 | |
| 3049 | /* If this is the last command in a series, set the proper flag. */ |
| 3050 | if (last_command) |
| 3051 | cmd->command_flags |= I40E_AQ_NVM_LAST_CMD; |
| 3052 | cmd->module_pointer = module_pointer; |
| 3053 | cmd->offset = cpu_to_le32(offset); |
| 3054 | cmd->length = cpu_to_le16(length); |
| 3055 | |
| 3056 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF); |
| 3057 | if (length > I40E_AQ_LARGE_BUF) |
| 3058 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB); |
| 3059 | |
| 3060 | status = i40e_asq_send_command(hw, &desc, data, length, cmd_details); |
| 3061 | |
| 3062 | i40e_aq_read_nvm_exit: |
| 3063 | return status; |
| 3064 | } |
| 3065 | |
Shannon Nelson | cd552cb | 2014-07-09 07:46:09 +0000 | [diff] [blame] | 3066 | /** |
| 3067 | * i40e_aq_erase_nvm |
| 3068 | * @hw: pointer to the hw struct |
| 3069 | * @module_pointer: module pointer location in words from the NVM beginning |
| 3070 | * @offset: offset in the module (expressed in 4 KB from module's beginning) |
| 3071 | * @length: length of the section to be erased (expressed in 4 KB) |
| 3072 | * @last_command: tells if this is the last command in a series |
| 3073 | * @cmd_details: pointer to command details structure or NULL |
| 3074 | * |
| 3075 | * Erase the NVM sector using the admin queue commands |
| 3076 | **/ |
| 3077 | i40e_status i40e_aq_erase_nvm(struct i40e_hw *hw, u8 module_pointer, |
| 3078 | u32 offset, u16 length, bool last_command, |
| 3079 | struct i40e_asq_cmd_details *cmd_details) |
| 3080 | { |
| 3081 | struct i40e_aq_desc desc; |
| 3082 | struct i40e_aqc_nvm_update *cmd = |
| 3083 | (struct i40e_aqc_nvm_update *)&desc.params.raw; |
| 3084 | i40e_status status; |
| 3085 | |
| 3086 | /* In offset the highest byte must be zeroed. */ |
| 3087 | if (offset & 0xFF000000) { |
| 3088 | status = I40E_ERR_PARAM; |
| 3089 | goto i40e_aq_erase_nvm_exit; |
| 3090 | } |
| 3091 | |
| 3092 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_nvm_erase); |
| 3093 | |
| 3094 | /* If this is the last command in a series, set the proper flag. */ |
| 3095 | if (last_command) |
| 3096 | cmd->command_flags |= I40E_AQ_NVM_LAST_CMD; |
| 3097 | cmd->module_pointer = module_pointer; |
| 3098 | cmd->offset = cpu_to_le32(offset); |
| 3099 | cmd->length = cpu_to_le16(length); |
| 3100 | |
| 3101 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 3102 | |
| 3103 | i40e_aq_erase_nvm_exit: |
| 3104 | return status; |
| 3105 | } |
| 3106 | |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3107 | /** |
| 3108 | * i40e_parse_discover_capabilities |
| 3109 | * @hw: pointer to the hw struct |
| 3110 | * @buff: pointer to a buffer containing device/function capability records |
| 3111 | * @cap_count: number of capability records in the list |
| 3112 | * @list_type_opc: type of capabilities list to parse |
| 3113 | * |
| 3114 | * Parse the device/function capabilities list. |
| 3115 | **/ |
| 3116 | static void i40e_parse_discover_capabilities(struct i40e_hw *hw, void *buff, |
| 3117 | u32 cap_count, |
| 3118 | enum i40e_admin_queue_opc list_type_opc) |
| 3119 | { |
| 3120 | struct i40e_aqc_list_capabilities_element_resp *cap; |
Shannon Nelson | 9fee9db | 2014-12-11 07:06:30 +0000 | [diff] [blame] | 3121 | u32 valid_functions, num_functions; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3122 | u32 number, logical_id, phys_id; |
| 3123 | struct i40e_hw_capabilities *p; |
Pawel Orlowski | c78b953 | 2015-04-22 19:34:06 -0400 | [diff] [blame] | 3124 | u8 major_rev; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3125 | u32 i = 0; |
| 3126 | u16 id; |
| 3127 | |
| 3128 | cap = (struct i40e_aqc_list_capabilities_element_resp *) buff; |
| 3129 | |
| 3130 | if (list_type_opc == i40e_aqc_opc_list_dev_capabilities) |
Joe Perches | b58f2f7 | 2014-03-25 04:30:32 +0000 | [diff] [blame] | 3131 | p = &hw->dev_caps; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3132 | else if (list_type_opc == i40e_aqc_opc_list_func_capabilities) |
Joe Perches | b58f2f7 | 2014-03-25 04:30:32 +0000 | [diff] [blame] | 3133 | p = &hw->func_caps; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3134 | else |
| 3135 | return; |
| 3136 | |
| 3137 | for (i = 0; i < cap_count; i++, cap++) { |
| 3138 | id = le16_to_cpu(cap->id); |
| 3139 | number = le32_to_cpu(cap->number); |
| 3140 | logical_id = le32_to_cpu(cap->logical_id); |
| 3141 | phys_id = le32_to_cpu(cap->phys_id); |
Pawel Orlowski | c78b953 | 2015-04-22 19:34:06 -0400 | [diff] [blame] | 3142 | major_rev = cap->major_rev; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3143 | |
| 3144 | switch (id) { |
Shannon Nelson | 406e734 | 2015-12-10 11:38:49 -0800 | [diff] [blame] | 3145 | case I40E_AQ_CAP_ID_SWITCH_MODE: |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3146 | p->switch_mode = number; |
| 3147 | break; |
Shannon Nelson | 406e734 | 2015-12-10 11:38:49 -0800 | [diff] [blame] | 3148 | case I40E_AQ_CAP_ID_MNG_MODE: |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3149 | p->management_mode = number; |
| 3150 | break; |
Shannon Nelson | 406e734 | 2015-12-10 11:38:49 -0800 | [diff] [blame] | 3151 | case I40E_AQ_CAP_ID_NPAR_ACTIVE: |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3152 | p->npar_enable = number; |
| 3153 | break; |
Shannon Nelson | 406e734 | 2015-12-10 11:38:49 -0800 | [diff] [blame] | 3154 | case I40E_AQ_CAP_ID_OS2BMC_CAP: |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3155 | p->os2bmc = number; |
| 3156 | break; |
Shannon Nelson | 406e734 | 2015-12-10 11:38:49 -0800 | [diff] [blame] | 3157 | case I40E_AQ_CAP_ID_FUNCTIONS_VALID: |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3158 | p->valid_functions = number; |
| 3159 | break; |
Shannon Nelson | 406e734 | 2015-12-10 11:38:49 -0800 | [diff] [blame] | 3160 | case I40E_AQ_CAP_ID_SRIOV: |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3161 | if (number == 1) |
| 3162 | p->sr_iov_1_1 = true; |
| 3163 | break; |
Shannon Nelson | 406e734 | 2015-12-10 11:38:49 -0800 | [diff] [blame] | 3164 | case I40E_AQ_CAP_ID_VF: |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3165 | p->num_vfs = number; |
| 3166 | p->vf_base_id = logical_id; |
| 3167 | break; |
Shannon Nelson | 406e734 | 2015-12-10 11:38:49 -0800 | [diff] [blame] | 3168 | case I40E_AQ_CAP_ID_VMDQ: |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3169 | if (number == 1) |
| 3170 | p->vmdq = true; |
| 3171 | break; |
Shannon Nelson | 406e734 | 2015-12-10 11:38:49 -0800 | [diff] [blame] | 3172 | case I40E_AQ_CAP_ID_8021QBG: |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3173 | if (number == 1) |
| 3174 | p->evb_802_1_qbg = true; |
| 3175 | break; |
Shannon Nelson | 406e734 | 2015-12-10 11:38:49 -0800 | [diff] [blame] | 3176 | case I40E_AQ_CAP_ID_8021QBR: |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3177 | if (number == 1) |
| 3178 | p->evb_802_1_qbh = true; |
| 3179 | break; |
Shannon Nelson | 406e734 | 2015-12-10 11:38:49 -0800 | [diff] [blame] | 3180 | case I40E_AQ_CAP_ID_VSI: |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3181 | p->num_vsis = number; |
| 3182 | break; |
Shannon Nelson | 406e734 | 2015-12-10 11:38:49 -0800 | [diff] [blame] | 3183 | case I40E_AQ_CAP_ID_DCB: |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3184 | if (number == 1) { |
| 3185 | p->dcb = true; |
| 3186 | p->enabled_tcmap = logical_id; |
| 3187 | p->maxtc = phys_id; |
| 3188 | } |
| 3189 | break; |
Shannon Nelson | 406e734 | 2015-12-10 11:38:49 -0800 | [diff] [blame] | 3190 | case I40E_AQ_CAP_ID_FCOE: |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3191 | if (number == 1) |
| 3192 | p->fcoe = true; |
| 3193 | break; |
Shannon Nelson | 406e734 | 2015-12-10 11:38:49 -0800 | [diff] [blame] | 3194 | case I40E_AQ_CAP_ID_ISCSI: |
Neerav Parikh | 63d7e5a | 2014-12-14 01:55:16 +0000 | [diff] [blame] | 3195 | if (number == 1) |
| 3196 | p->iscsi = true; |
| 3197 | break; |
Shannon Nelson | 406e734 | 2015-12-10 11:38:49 -0800 | [diff] [blame] | 3198 | case I40E_AQ_CAP_ID_RSS: |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3199 | p->rss = true; |
Carolyn Wyborny | e157ea3 | 2014-06-03 23:50:22 +0000 | [diff] [blame] | 3200 | p->rss_table_size = number; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3201 | p->rss_table_entry_width = logical_id; |
| 3202 | break; |
Shannon Nelson | 406e734 | 2015-12-10 11:38:49 -0800 | [diff] [blame] | 3203 | case I40E_AQ_CAP_ID_RXQ: |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3204 | p->num_rx_qp = number; |
| 3205 | p->base_queue = phys_id; |
| 3206 | break; |
Shannon Nelson | 406e734 | 2015-12-10 11:38:49 -0800 | [diff] [blame] | 3207 | case I40E_AQ_CAP_ID_TXQ: |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3208 | p->num_tx_qp = number; |
| 3209 | p->base_queue = phys_id; |
| 3210 | break; |
Shannon Nelson | 406e734 | 2015-12-10 11:38:49 -0800 | [diff] [blame] | 3211 | case I40E_AQ_CAP_ID_MSIX: |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3212 | p->num_msix_vectors = number; |
Deepthi Kavalur | 453e16e | 2016-04-01 03:56:01 -0700 | [diff] [blame] | 3213 | i40e_debug(hw, I40E_DEBUG_INIT, |
| 3214 | "HW Capability: MSIX vector count = %d\n", |
| 3215 | p->num_msix_vectors); |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3216 | break; |
Shannon Nelson | 406e734 | 2015-12-10 11:38:49 -0800 | [diff] [blame] | 3217 | case I40E_AQ_CAP_ID_VF_MSIX: |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3218 | p->num_msix_vectors_vf = number; |
| 3219 | break; |
Shannon Nelson | 406e734 | 2015-12-10 11:38:49 -0800 | [diff] [blame] | 3220 | case I40E_AQ_CAP_ID_FLEX10: |
Pawel Orlowski | c78b953 | 2015-04-22 19:34:06 -0400 | [diff] [blame] | 3221 | if (major_rev == 1) { |
| 3222 | if (number == 1) { |
| 3223 | p->flex10_enable = true; |
| 3224 | p->flex10_capable = true; |
| 3225 | } |
| 3226 | } else { |
| 3227 | /* Capability revision >= 2 */ |
| 3228 | if (number & 1) |
| 3229 | p->flex10_enable = true; |
| 3230 | if (number & 2) |
| 3231 | p->flex10_capable = true; |
| 3232 | } |
| 3233 | p->flex10_mode = logical_id; |
| 3234 | p->flex10_status = phys_id; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3235 | break; |
Shannon Nelson | 406e734 | 2015-12-10 11:38:49 -0800 | [diff] [blame] | 3236 | case I40E_AQ_CAP_ID_CEM: |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3237 | if (number == 1) |
| 3238 | p->mgmt_cem = true; |
| 3239 | break; |
Shannon Nelson | 406e734 | 2015-12-10 11:38:49 -0800 | [diff] [blame] | 3240 | case I40E_AQ_CAP_ID_IWARP: |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3241 | if (number == 1) |
| 3242 | p->iwarp = true; |
| 3243 | break; |
Shannon Nelson | 406e734 | 2015-12-10 11:38:49 -0800 | [diff] [blame] | 3244 | case I40E_AQ_CAP_ID_LED: |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3245 | if (phys_id < I40E_HW_CAP_MAX_GPIO) |
| 3246 | p->led[phys_id] = true; |
| 3247 | break; |
Shannon Nelson | 406e734 | 2015-12-10 11:38:49 -0800 | [diff] [blame] | 3248 | case I40E_AQ_CAP_ID_SDP: |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3249 | if (phys_id < I40E_HW_CAP_MAX_GPIO) |
| 3250 | p->sdp[phys_id] = true; |
| 3251 | break; |
Shannon Nelson | 406e734 | 2015-12-10 11:38:49 -0800 | [diff] [blame] | 3252 | case I40E_AQ_CAP_ID_MDIO: |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3253 | if (number == 1) { |
| 3254 | p->mdio_port_num = phys_id; |
| 3255 | p->mdio_port_mode = logical_id; |
| 3256 | } |
| 3257 | break; |
Shannon Nelson | 406e734 | 2015-12-10 11:38:49 -0800 | [diff] [blame] | 3258 | case I40E_AQ_CAP_ID_1588: |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3259 | if (number == 1) |
| 3260 | p->ieee_1588 = true; |
| 3261 | break; |
Shannon Nelson | 406e734 | 2015-12-10 11:38:49 -0800 | [diff] [blame] | 3262 | case I40E_AQ_CAP_ID_FLOW_DIRECTOR: |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3263 | p->fd = true; |
| 3264 | p->fd_filters_guaranteed = number; |
| 3265 | p->fd_filters_best_effort = logical_id; |
| 3266 | break; |
Shannon Nelson | 406e734 | 2015-12-10 11:38:49 -0800 | [diff] [blame] | 3267 | case I40E_AQ_CAP_ID_WSR_PROT: |
Kevin Scott | 73b2340 | 2015-04-07 19:45:38 -0400 | [diff] [blame] | 3268 | p->wr_csr_prot = (u64)number; |
| 3269 | p->wr_csr_prot |= (u64)logical_id << 32; |
| 3270 | break; |
Michal Kosiarz | 68a1c5a | 2016-04-12 08:30:46 -0700 | [diff] [blame] | 3271 | case I40E_AQ_CAP_ID_NVM_MGMT: |
| 3272 | if (number & I40E_NVM_MGMT_SEC_REV_DISABLED) |
| 3273 | p->sec_rev_disabled = true; |
| 3274 | if (number & I40E_NVM_MGMT_UPDATE_DISABLED) |
| 3275 | p->update_disabled = true; |
| 3276 | break; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3277 | default: |
| 3278 | break; |
| 3279 | } |
| 3280 | } |
| 3281 | |
Vasu Dev | f18ae10 | 2015-04-07 19:45:36 -0400 | [diff] [blame] | 3282 | if (p->fcoe) |
| 3283 | i40e_debug(hw, I40E_DEBUG_ALL, "device is FCoE capable\n"); |
| 3284 | |
Vasu Dev | 566bb85 | 2014-04-09 05:59:06 +0000 | [diff] [blame] | 3285 | /* Software override ensuring FCoE is disabled if npar or mfp |
| 3286 | * mode because it is not supported in these modes. |
| 3287 | */ |
Pawel Orlowski | c78b953 | 2015-04-22 19:34:06 -0400 | [diff] [blame] | 3288 | if (p->npar_enable || p->flex10_enable) |
Vasu Dev | 566bb85 | 2014-04-09 05:59:06 +0000 | [diff] [blame] | 3289 | p->fcoe = false; |
| 3290 | |
Shannon Nelson | 9fee9db | 2014-12-11 07:06:30 +0000 | [diff] [blame] | 3291 | /* count the enabled ports (aka the "not disabled" ports) */ |
| 3292 | hw->num_ports = 0; |
| 3293 | for (i = 0; i < 4; i++) { |
| 3294 | u32 port_cfg_reg = I40E_PRTGEN_CNF + (4 * i); |
| 3295 | u64 port_cfg = 0; |
| 3296 | |
| 3297 | /* use AQ read to get the physical register offset instead |
| 3298 | * of the port relative offset |
| 3299 | */ |
| 3300 | i40e_aq_debug_read_register(hw, port_cfg_reg, &port_cfg, NULL); |
| 3301 | if (!(port_cfg & I40E_PRTGEN_CNF_PORT_DIS_MASK)) |
| 3302 | hw->num_ports++; |
| 3303 | } |
| 3304 | |
| 3305 | valid_functions = p->valid_functions; |
| 3306 | num_functions = 0; |
| 3307 | while (valid_functions) { |
| 3308 | if (valid_functions & 1) |
| 3309 | num_functions++; |
| 3310 | valid_functions >>= 1; |
| 3311 | } |
| 3312 | |
| 3313 | /* partition id is 1-based, and functions are evenly spread |
| 3314 | * across the ports as partitions |
| 3315 | */ |
Michal Kosiarz | 999b315 | 2016-10-11 15:26:56 -0700 | [diff] [blame^] | 3316 | if (hw->num_ports != 0) { |
| 3317 | hw->partition_id = (hw->pf_id / hw->num_ports) + 1; |
| 3318 | hw->num_partitions = num_functions / hw->num_ports; |
| 3319 | } |
Shannon Nelson | 9fee9db | 2014-12-11 07:06:30 +0000 | [diff] [blame] | 3320 | |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3321 | /* additional HW specific goodies that might |
| 3322 | * someday be HW version specific |
| 3323 | */ |
| 3324 | p->rx_buf_chain_len = I40E_MAX_CHAINED_RX_BUFFERS; |
| 3325 | } |
| 3326 | |
| 3327 | /** |
| 3328 | * i40e_aq_discover_capabilities |
| 3329 | * @hw: pointer to the hw struct |
| 3330 | * @buff: a virtual buffer to hold the capabilities |
| 3331 | * @buff_size: Size of the virtual buffer |
| 3332 | * @data_size: Size of the returned data, or buff size needed if AQ err==ENOMEM |
| 3333 | * @list_type_opc: capabilities type to discover - pass in the command opcode |
| 3334 | * @cmd_details: pointer to command details structure or NULL |
| 3335 | * |
| 3336 | * Get the device capabilities descriptions from the firmware |
| 3337 | **/ |
| 3338 | i40e_status i40e_aq_discover_capabilities(struct i40e_hw *hw, |
| 3339 | void *buff, u16 buff_size, u16 *data_size, |
| 3340 | enum i40e_admin_queue_opc list_type_opc, |
| 3341 | struct i40e_asq_cmd_details *cmd_details) |
| 3342 | { |
| 3343 | struct i40e_aqc_list_capabilites *cmd; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3344 | struct i40e_aq_desc desc; |
Jesse Brandeburg | 8fb905b | 2014-01-17 15:36:33 -0800 | [diff] [blame] | 3345 | i40e_status status = 0; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3346 | |
| 3347 | cmd = (struct i40e_aqc_list_capabilites *)&desc.params.raw; |
| 3348 | |
| 3349 | if (list_type_opc != i40e_aqc_opc_list_func_capabilities && |
| 3350 | list_type_opc != i40e_aqc_opc_list_dev_capabilities) { |
| 3351 | status = I40E_ERR_PARAM; |
| 3352 | goto exit; |
| 3353 | } |
| 3354 | |
| 3355 | i40e_fill_default_direct_cmd_desc(&desc, list_type_opc); |
| 3356 | |
| 3357 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF); |
| 3358 | if (buff_size > I40E_AQ_LARGE_BUF) |
| 3359 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB); |
| 3360 | |
| 3361 | status = i40e_asq_send_command(hw, &desc, buff, buff_size, cmd_details); |
| 3362 | *data_size = le16_to_cpu(desc.datalen); |
| 3363 | |
| 3364 | if (status) |
| 3365 | goto exit; |
| 3366 | |
| 3367 | i40e_parse_discover_capabilities(hw, buff, le32_to_cpu(cmd->count), |
| 3368 | list_type_opc); |
| 3369 | |
| 3370 | exit: |
| 3371 | return status; |
| 3372 | } |
| 3373 | |
| 3374 | /** |
Shannon Nelson | cd552cb | 2014-07-09 07:46:09 +0000 | [diff] [blame] | 3375 | * i40e_aq_update_nvm |
| 3376 | * @hw: pointer to the hw struct |
| 3377 | * @module_pointer: module pointer location in words from the NVM beginning |
| 3378 | * @offset: byte offset from the module beginning |
| 3379 | * @length: length of the section to be written (in bytes from the offset) |
| 3380 | * @data: command buffer (size [bytes] = length) |
| 3381 | * @last_command: tells if this is the last command in a series |
| 3382 | * @cmd_details: pointer to command details structure or NULL |
| 3383 | * |
| 3384 | * Update the NVM using the admin queue commands |
| 3385 | **/ |
| 3386 | i40e_status i40e_aq_update_nvm(struct i40e_hw *hw, u8 module_pointer, |
| 3387 | u32 offset, u16 length, void *data, |
| 3388 | bool last_command, |
| 3389 | struct i40e_asq_cmd_details *cmd_details) |
| 3390 | { |
| 3391 | struct i40e_aq_desc desc; |
| 3392 | struct i40e_aqc_nvm_update *cmd = |
| 3393 | (struct i40e_aqc_nvm_update *)&desc.params.raw; |
| 3394 | i40e_status status; |
| 3395 | |
| 3396 | /* In offset the highest byte must be zeroed. */ |
| 3397 | if (offset & 0xFF000000) { |
| 3398 | status = I40E_ERR_PARAM; |
| 3399 | goto i40e_aq_update_nvm_exit; |
| 3400 | } |
| 3401 | |
| 3402 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_nvm_update); |
| 3403 | |
| 3404 | /* If this is the last command in a series, set the proper flag. */ |
| 3405 | if (last_command) |
| 3406 | cmd->command_flags |= I40E_AQ_NVM_LAST_CMD; |
| 3407 | cmd->module_pointer = module_pointer; |
| 3408 | cmd->offset = cpu_to_le32(offset); |
| 3409 | cmd->length = cpu_to_le16(length); |
| 3410 | |
| 3411 | desc.flags |= cpu_to_le16((u16)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD)); |
| 3412 | if (length > I40E_AQ_LARGE_BUF) |
| 3413 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB); |
| 3414 | |
| 3415 | status = i40e_asq_send_command(hw, &desc, data, length, cmd_details); |
| 3416 | |
| 3417 | i40e_aq_update_nvm_exit: |
| 3418 | return status; |
| 3419 | } |
| 3420 | |
| 3421 | /** |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3422 | * i40e_aq_get_lldp_mib |
| 3423 | * @hw: pointer to the hw struct |
| 3424 | * @bridge_type: type of bridge requested |
| 3425 | * @mib_type: Local, Remote or both Local and Remote MIBs |
| 3426 | * @buff: pointer to a user supplied buffer to store the MIB block |
| 3427 | * @buff_size: size of the buffer (in bytes) |
| 3428 | * @local_len : length of the returned Local LLDP MIB |
| 3429 | * @remote_len: length of the returned Remote LLDP MIB |
| 3430 | * @cmd_details: pointer to command details structure or NULL |
| 3431 | * |
| 3432 | * Requests the complete LLDP MIB (entire packet). |
| 3433 | **/ |
| 3434 | i40e_status i40e_aq_get_lldp_mib(struct i40e_hw *hw, u8 bridge_type, |
| 3435 | u8 mib_type, void *buff, u16 buff_size, |
| 3436 | u16 *local_len, u16 *remote_len, |
| 3437 | struct i40e_asq_cmd_details *cmd_details) |
| 3438 | { |
| 3439 | struct i40e_aq_desc desc; |
| 3440 | struct i40e_aqc_lldp_get_mib *cmd = |
| 3441 | (struct i40e_aqc_lldp_get_mib *)&desc.params.raw; |
| 3442 | struct i40e_aqc_lldp_get_mib *resp = |
| 3443 | (struct i40e_aqc_lldp_get_mib *)&desc.params.raw; |
| 3444 | i40e_status status; |
| 3445 | |
| 3446 | if (buff_size == 0 || !buff) |
| 3447 | return I40E_ERR_PARAM; |
| 3448 | |
| 3449 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_lldp_get_mib); |
| 3450 | /* Indirect Command */ |
| 3451 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF); |
| 3452 | |
| 3453 | cmd->type = mib_type & I40E_AQ_LLDP_MIB_TYPE_MASK; |
| 3454 | cmd->type |= ((bridge_type << I40E_AQ_LLDP_BRIDGE_TYPE_SHIFT) & |
| 3455 | I40E_AQ_LLDP_BRIDGE_TYPE_MASK); |
| 3456 | |
| 3457 | desc.datalen = cpu_to_le16(buff_size); |
| 3458 | |
| 3459 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF); |
| 3460 | if (buff_size > I40E_AQ_LARGE_BUF) |
| 3461 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB); |
| 3462 | |
| 3463 | status = i40e_asq_send_command(hw, &desc, buff, buff_size, cmd_details); |
| 3464 | if (!status) { |
| 3465 | if (local_len != NULL) |
| 3466 | *local_len = le16_to_cpu(resp->local_len); |
| 3467 | if (remote_len != NULL) |
| 3468 | *remote_len = le16_to_cpu(resp->remote_len); |
| 3469 | } |
| 3470 | |
| 3471 | return status; |
| 3472 | } |
| 3473 | |
| 3474 | /** |
| 3475 | * i40e_aq_cfg_lldp_mib_change_event |
| 3476 | * @hw: pointer to the hw struct |
| 3477 | * @enable_update: Enable or Disable event posting |
| 3478 | * @cmd_details: pointer to command details structure or NULL |
| 3479 | * |
| 3480 | * Enable or Disable posting of an event on ARQ when LLDP MIB |
| 3481 | * associated with the interface changes |
| 3482 | **/ |
| 3483 | i40e_status i40e_aq_cfg_lldp_mib_change_event(struct i40e_hw *hw, |
| 3484 | bool enable_update, |
| 3485 | struct i40e_asq_cmd_details *cmd_details) |
| 3486 | { |
| 3487 | struct i40e_aq_desc desc; |
| 3488 | struct i40e_aqc_lldp_update_mib *cmd = |
| 3489 | (struct i40e_aqc_lldp_update_mib *)&desc.params.raw; |
| 3490 | i40e_status status; |
| 3491 | |
| 3492 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_lldp_update_mib); |
| 3493 | |
| 3494 | if (!enable_update) |
| 3495 | cmd->command |= I40E_AQ_LLDP_MIB_UPDATE_DISABLE; |
| 3496 | |
| 3497 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 3498 | |
| 3499 | return status; |
| 3500 | } |
| 3501 | |
| 3502 | /** |
| 3503 | * i40e_aq_stop_lldp |
| 3504 | * @hw: pointer to the hw struct |
| 3505 | * @shutdown_agent: True if LLDP Agent needs to be Shutdown |
| 3506 | * @cmd_details: pointer to command details structure or NULL |
| 3507 | * |
| 3508 | * Stop or Shutdown the embedded LLDP Agent |
| 3509 | **/ |
| 3510 | i40e_status i40e_aq_stop_lldp(struct i40e_hw *hw, bool shutdown_agent, |
| 3511 | struct i40e_asq_cmd_details *cmd_details) |
| 3512 | { |
| 3513 | struct i40e_aq_desc desc; |
| 3514 | struct i40e_aqc_lldp_stop *cmd = |
| 3515 | (struct i40e_aqc_lldp_stop *)&desc.params.raw; |
| 3516 | i40e_status status; |
| 3517 | |
| 3518 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_lldp_stop); |
| 3519 | |
| 3520 | if (shutdown_agent) |
| 3521 | cmd->command |= I40E_AQ_LLDP_AGENT_SHUTDOWN; |
| 3522 | |
| 3523 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 3524 | |
| 3525 | return status; |
| 3526 | } |
| 3527 | |
| 3528 | /** |
| 3529 | * i40e_aq_start_lldp |
| 3530 | * @hw: pointer to the hw struct |
| 3531 | * @cmd_details: pointer to command details structure or NULL |
| 3532 | * |
| 3533 | * Start the embedded LLDP Agent on all ports. |
| 3534 | **/ |
| 3535 | i40e_status i40e_aq_start_lldp(struct i40e_hw *hw, |
| 3536 | struct i40e_asq_cmd_details *cmd_details) |
| 3537 | { |
| 3538 | struct i40e_aq_desc desc; |
| 3539 | struct i40e_aqc_lldp_start *cmd = |
| 3540 | (struct i40e_aqc_lldp_start *)&desc.params.raw; |
| 3541 | i40e_status status; |
| 3542 | |
| 3543 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_lldp_start); |
| 3544 | |
| 3545 | cmd->command = I40E_AQ_LLDP_AGENT_START; |
| 3546 | |
| 3547 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 3548 | |
| 3549 | return status; |
| 3550 | } |
| 3551 | |
| 3552 | /** |
Neerav Parikh | 9fa61dd | 2014-11-12 00:18:25 +0000 | [diff] [blame] | 3553 | * i40e_aq_get_cee_dcb_config |
| 3554 | * @hw: pointer to the hw struct |
| 3555 | * @buff: response buffer that stores CEE operational configuration |
| 3556 | * @buff_size: size of the buffer passed |
| 3557 | * @cmd_details: pointer to command details structure or NULL |
| 3558 | * |
| 3559 | * Get CEE DCBX mode operational configuration from firmware |
| 3560 | **/ |
| 3561 | i40e_status i40e_aq_get_cee_dcb_config(struct i40e_hw *hw, |
| 3562 | void *buff, u16 buff_size, |
| 3563 | struct i40e_asq_cmd_details *cmd_details) |
| 3564 | { |
| 3565 | struct i40e_aq_desc desc; |
| 3566 | i40e_status status; |
| 3567 | |
| 3568 | if (buff_size == 0 || !buff) |
| 3569 | return I40E_ERR_PARAM; |
| 3570 | |
| 3571 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_get_cee_dcb_cfg); |
| 3572 | |
| 3573 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF); |
| 3574 | status = i40e_asq_send_command(hw, &desc, (void *)buff, buff_size, |
| 3575 | cmd_details); |
| 3576 | |
| 3577 | return status; |
| 3578 | } |
| 3579 | |
| 3580 | /** |
Jeff Kirsher | a1c9a9d | 2013-12-28 07:32:18 +0000 | [diff] [blame] | 3581 | * i40e_aq_add_udp_tunnel |
| 3582 | * @hw: pointer to the hw struct |
| 3583 | * @udp_port: the UDP port to add |
| 3584 | * @header_len: length of the tunneling header length in DWords |
| 3585 | * @protocol_index: protocol index type |
Jeff Kirsher | 98d4438 | 2013-12-21 05:44:42 +0000 | [diff] [blame] | 3586 | * @filter_index: pointer to filter index |
Jeff Kirsher | a1c9a9d | 2013-12-28 07:32:18 +0000 | [diff] [blame] | 3587 | * @cmd_details: pointer to command details structure or NULL |
| 3588 | **/ |
| 3589 | i40e_status i40e_aq_add_udp_tunnel(struct i40e_hw *hw, |
Kevin Scott | f4f94b9 | 2014-04-05 07:46:10 +0000 | [diff] [blame] | 3590 | u16 udp_port, u8 protocol_index, |
| 3591 | u8 *filter_index, |
Jeff Kirsher | a1c9a9d | 2013-12-28 07:32:18 +0000 | [diff] [blame] | 3592 | struct i40e_asq_cmd_details *cmd_details) |
| 3593 | { |
| 3594 | struct i40e_aq_desc desc; |
| 3595 | struct i40e_aqc_add_udp_tunnel *cmd = |
| 3596 | (struct i40e_aqc_add_udp_tunnel *)&desc.params.raw; |
| 3597 | struct i40e_aqc_del_udp_tunnel_completion *resp = |
| 3598 | (struct i40e_aqc_del_udp_tunnel_completion *)&desc.params.raw; |
| 3599 | i40e_status status; |
| 3600 | |
| 3601 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_add_udp_tunnel); |
| 3602 | |
| 3603 | cmd->udp_port = cpu_to_le16(udp_port); |
Shannon Nelson | 981b754 | 2013-12-11 08:17:11 +0000 | [diff] [blame] | 3604 | cmd->protocol_type = protocol_index; |
Jeff Kirsher | a1c9a9d | 2013-12-28 07:32:18 +0000 | [diff] [blame] | 3605 | |
| 3606 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 3607 | |
Shannon Nelson | 65d1346 | 2015-02-21 06:45:28 +0000 | [diff] [blame] | 3608 | if (!status && filter_index) |
Jeff Kirsher | a1c9a9d | 2013-12-28 07:32:18 +0000 | [diff] [blame] | 3609 | *filter_index = resp->index; |
| 3610 | |
| 3611 | return status; |
| 3612 | } |
| 3613 | |
| 3614 | /** |
| 3615 | * i40e_aq_del_udp_tunnel |
| 3616 | * @hw: pointer to the hw struct |
| 3617 | * @index: filter index |
| 3618 | * @cmd_details: pointer to command details structure or NULL |
| 3619 | **/ |
| 3620 | i40e_status i40e_aq_del_udp_tunnel(struct i40e_hw *hw, u8 index, |
| 3621 | struct i40e_asq_cmd_details *cmd_details) |
| 3622 | { |
| 3623 | struct i40e_aq_desc desc; |
| 3624 | struct i40e_aqc_remove_udp_tunnel *cmd = |
| 3625 | (struct i40e_aqc_remove_udp_tunnel *)&desc.params.raw; |
| 3626 | i40e_status status; |
| 3627 | |
| 3628 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_del_udp_tunnel); |
| 3629 | |
| 3630 | cmd->index = index; |
| 3631 | |
| 3632 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 3633 | |
| 3634 | return status; |
| 3635 | } |
| 3636 | |
| 3637 | /** |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3638 | * i40e_aq_delete_element - Delete switch element |
| 3639 | * @hw: pointer to the hw struct |
| 3640 | * @seid: the SEID to delete from the switch |
| 3641 | * @cmd_details: pointer to command details structure or NULL |
| 3642 | * |
| 3643 | * This deletes a switch element from the switch. |
| 3644 | **/ |
| 3645 | i40e_status i40e_aq_delete_element(struct i40e_hw *hw, u16 seid, |
| 3646 | struct i40e_asq_cmd_details *cmd_details) |
| 3647 | { |
| 3648 | struct i40e_aq_desc desc; |
| 3649 | struct i40e_aqc_switch_seid *cmd = |
| 3650 | (struct i40e_aqc_switch_seid *)&desc.params.raw; |
| 3651 | i40e_status status; |
| 3652 | |
| 3653 | if (seid == 0) |
| 3654 | return I40E_ERR_PARAM; |
| 3655 | |
| 3656 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_delete_element); |
| 3657 | |
| 3658 | cmd->seid = cpu_to_le16(seid); |
| 3659 | |
| 3660 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 3661 | |
| 3662 | return status; |
| 3663 | } |
| 3664 | |
| 3665 | /** |
Neerav Parikh | afb3ff0 | 2014-01-17 15:36:36 -0800 | [diff] [blame] | 3666 | * i40e_aq_dcb_updated - DCB Updated Command |
| 3667 | * @hw: pointer to the hw struct |
| 3668 | * @cmd_details: pointer to command details structure or NULL |
| 3669 | * |
| 3670 | * EMP will return when the shared RPB settings have been |
| 3671 | * recomputed and modified. The retval field in the descriptor |
| 3672 | * will be set to 0 when RPB is modified. |
| 3673 | **/ |
| 3674 | i40e_status i40e_aq_dcb_updated(struct i40e_hw *hw, |
| 3675 | struct i40e_asq_cmd_details *cmd_details) |
| 3676 | { |
| 3677 | struct i40e_aq_desc desc; |
| 3678 | i40e_status status; |
| 3679 | |
| 3680 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_dcb_updated); |
| 3681 | |
| 3682 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 3683 | |
| 3684 | return status; |
| 3685 | } |
| 3686 | |
| 3687 | /** |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3688 | * i40e_aq_tx_sched_cmd - generic Tx scheduler AQ command handler |
| 3689 | * @hw: pointer to the hw struct |
| 3690 | * @seid: seid for the physical port/switching component/vsi |
| 3691 | * @buff: Indirect buffer to hold data parameters and response |
| 3692 | * @buff_size: Indirect buffer size |
| 3693 | * @opcode: Tx scheduler AQ command opcode |
| 3694 | * @cmd_details: pointer to command details structure or NULL |
| 3695 | * |
| 3696 | * Generic command handler for Tx scheduler AQ commands |
| 3697 | **/ |
| 3698 | static i40e_status i40e_aq_tx_sched_cmd(struct i40e_hw *hw, u16 seid, |
| 3699 | void *buff, u16 buff_size, |
| 3700 | enum i40e_admin_queue_opc opcode, |
| 3701 | struct i40e_asq_cmd_details *cmd_details) |
| 3702 | { |
| 3703 | struct i40e_aq_desc desc; |
| 3704 | struct i40e_aqc_tx_sched_ind *cmd = |
| 3705 | (struct i40e_aqc_tx_sched_ind *)&desc.params.raw; |
| 3706 | i40e_status status; |
| 3707 | bool cmd_param_flag = false; |
| 3708 | |
| 3709 | switch (opcode) { |
| 3710 | case i40e_aqc_opc_configure_vsi_ets_sla_bw_limit: |
| 3711 | case i40e_aqc_opc_configure_vsi_tc_bw: |
| 3712 | case i40e_aqc_opc_enable_switching_comp_ets: |
| 3713 | case i40e_aqc_opc_modify_switching_comp_ets: |
| 3714 | case i40e_aqc_opc_disable_switching_comp_ets: |
| 3715 | case i40e_aqc_opc_configure_switching_comp_ets_bw_limit: |
| 3716 | case i40e_aqc_opc_configure_switching_comp_bw_config: |
| 3717 | cmd_param_flag = true; |
| 3718 | break; |
| 3719 | case i40e_aqc_opc_query_vsi_bw_config: |
| 3720 | case i40e_aqc_opc_query_vsi_ets_sla_config: |
| 3721 | case i40e_aqc_opc_query_switching_comp_ets_config: |
| 3722 | case i40e_aqc_opc_query_port_ets_config: |
| 3723 | case i40e_aqc_opc_query_switching_comp_bw_config: |
| 3724 | cmd_param_flag = false; |
| 3725 | break; |
| 3726 | default: |
| 3727 | return I40E_ERR_PARAM; |
| 3728 | } |
| 3729 | |
| 3730 | i40e_fill_default_direct_cmd_desc(&desc, opcode); |
| 3731 | |
| 3732 | /* Indirect command */ |
| 3733 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF); |
| 3734 | if (cmd_param_flag) |
| 3735 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_RD); |
| 3736 | if (buff_size > I40E_AQ_LARGE_BUF) |
| 3737 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB); |
| 3738 | |
| 3739 | desc.datalen = cpu_to_le16(buff_size); |
| 3740 | |
| 3741 | cmd->vsi_seid = cpu_to_le16(seid); |
| 3742 | |
| 3743 | status = i40e_asq_send_command(hw, &desc, buff, buff_size, cmd_details); |
| 3744 | |
| 3745 | return status; |
| 3746 | } |
| 3747 | |
| 3748 | /** |
Mitch Williams | 6b19289 | 2014-03-06 09:02:29 +0000 | [diff] [blame] | 3749 | * i40e_aq_config_vsi_bw_limit - Configure VSI BW Limit |
| 3750 | * @hw: pointer to the hw struct |
| 3751 | * @seid: VSI seid |
| 3752 | * @credit: BW limit credits (0 = disabled) |
| 3753 | * @max_credit: Max BW limit credits |
| 3754 | * @cmd_details: pointer to command details structure or NULL |
| 3755 | **/ |
| 3756 | i40e_status i40e_aq_config_vsi_bw_limit(struct i40e_hw *hw, |
| 3757 | u16 seid, u16 credit, u8 max_credit, |
| 3758 | struct i40e_asq_cmd_details *cmd_details) |
| 3759 | { |
| 3760 | struct i40e_aq_desc desc; |
| 3761 | struct i40e_aqc_configure_vsi_bw_limit *cmd = |
| 3762 | (struct i40e_aqc_configure_vsi_bw_limit *)&desc.params.raw; |
| 3763 | i40e_status status; |
| 3764 | |
| 3765 | i40e_fill_default_direct_cmd_desc(&desc, |
| 3766 | i40e_aqc_opc_configure_vsi_bw_limit); |
| 3767 | |
| 3768 | cmd->vsi_seid = cpu_to_le16(seid); |
| 3769 | cmd->credit = cpu_to_le16(credit); |
| 3770 | cmd->max_credit = max_credit; |
| 3771 | |
| 3772 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 3773 | |
| 3774 | return status; |
| 3775 | } |
| 3776 | |
| 3777 | /** |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3778 | * i40e_aq_config_vsi_tc_bw - Config VSI BW Allocation per TC |
| 3779 | * @hw: pointer to the hw struct |
| 3780 | * @seid: VSI seid |
| 3781 | * @bw_data: Buffer holding enabled TCs, relative TC BW limit/credits |
| 3782 | * @cmd_details: pointer to command details structure or NULL |
| 3783 | **/ |
| 3784 | i40e_status i40e_aq_config_vsi_tc_bw(struct i40e_hw *hw, |
| 3785 | u16 seid, |
| 3786 | struct i40e_aqc_configure_vsi_tc_bw_data *bw_data, |
| 3787 | struct i40e_asq_cmd_details *cmd_details) |
| 3788 | { |
| 3789 | return i40e_aq_tx_sched_cmd(hw, seid, (void *)bw_data, sizeof(*bw_data), |
| 3790 | i40e_aqc_opc_configure_vsi_tc_bw, |
| 3791 | cmd_details); |
| 3792 | } |
| 3793 | |
| 3794 | /** |
Neerav Parikh | afb3ff0 | 2014-01-17 15:36:36 -0800 | [diff] [blame] | 3795 | * i40e_aq_config_switch_comp_ets - Enable/Disable/Modify ETS on the port |
| 3796 | * @hw: pointer to the hw struct |
| 3797 | * @seid: seid of the switching component connected to Physical Port |
| 3798 | * @ets_data: Buffer holding ETS parameters |
| 3799 | * @cmd_details: pointer to command details structure or NULL |
| 3800 | **/ |
| 3801 | i40e_status i40e_aq_config_switch_comp_ets(struct i40e_hw *hw, |
| 3802 | u16 seid, |
| 3803 | struct i40e_aqc_configure_switching_comp_ets_data *ets_data, |
| 3804 | enum i40e_admin_queue_opc opcode, |
| 3805 | struct i40e_asq_cmd_details *cmd_details) |
| 3806 | { |
| 3807 | return i40e_aq_tx_sched_cmd(hw, seid, (void *)ets_data, |
| 3808 | sizeof(*ets_data), opcode, cmd_details); |
| 3809 | } |
| 3810 | |
| 3811 | /** |
| 3812 | * i40e_aq_config_switch_comp_bw_config - Config Switch comp BW Alloc per TC |
| 3813 | * @hw: pointer to the hw struct |
| 3814 | * @seid: seid of the switching component |
| 3815 | * @bw_data: Buffer holding enabled TCs, relative/absolute TC BW limit/credits |
| 3816 | * @cmd_details: pointer to command details structure or NULL |
| 3817 | **/ |
| 3818 | i40e_status i40e_aq_config_switch_comp_bw_config(struct i40e_hw *hw, |
| 3819 | u16 seid, |
| 3820 | struct i40e_aqc_configure_switching_comp_bw_config_data *bw_data, |
| 3821 | struct i40e_asq_cmd_details *cmd_details) |
| 3822 | { |
| 3823 | return i40e_aq_tx_sched_cmd(hw, seid, (void *)bw_data, sizeof(*bw_data), |
| 3824 | i40e_aqc_opc_configure_switching_comp_bw_config, |
| 3825 | cmd_details); |
| 3826 | } |
| 3827 | |
| 3828 | /** |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3829 | * i40e_aq_query_vsi_bw_config - Query VSI BW configuration |
| 3830 | * @hw: pointer to the hw struct |
| 3831 | * @seid: seid of the VSI |
| 3832 | * @bw_data: Buffer to hold VSI BW configuration |
| 3833 | * @cmd_details: pointer to command details structure or NULL |
| 3834 | **/ |
| 3835 | i40e_status i40e_aq_query_vsi_bw_config(struct i40e_hw *hw, |
| 3836 | u16 seid, |
| 3837 | struct i40e_aqc_query_vsi_bw_config_resp *bw_data, |
| 3838 | struct i40e_asq_cmd_details *cmd_details) |
| 3839 | { |
| 3840 | return i40e_aq_tx_sched_cmd(hw, seid, (void *)bw_data, sizeof(*bw_data), |
| 3841 | i40e_aqc_opc_query_vsi_bw_config, |
| 3842 | cmd_details); |
| 3843 | } |
| 3844 | |
| 3845 | /** |
| 3846 | * i40e_aq_query_vsi_ets_sla_config - Query VSI BW configuration per TC |
| 3847 | * @hw: pointer to the hw struct |
| 3848 | * @seid: seid of the VSI |
| 3849 | * @bw_data: Buffer to hold VSI BW configuration per TC |
| 3850 | * @cmd_details: pointer to command details structure or NULL |
| 3851 | **/ |
| 3852 | i40e_status i40e_aq_query_vsi_ets_sla_config(struct i40e_hw *hw, |
| 3853 | u16 seid, |
| 3854 | struct i40e_aqc_query_vsi_ets_sla_config_resp *bw_data, |
| 3855 | struct i40e_asq_cmd_details *cmd_details) |
| 3856 | { |
| 3857 | return i40e_aq_tx_sched_cmd(hw, seid, (void *)bw_data, sizeof(*bw_data), |
| 3858 | i40e_aqc_opc_query_vsi_ets_sla_config, |
| 3859 | cmd_details); |
| 3860 | } |
| 3861 | |
| 3862 | /** |
| 3863 | * i40e_aq_query_switch_comp_ets_config - Query Switch comp BW config per TC |
| 3864 | * @hw: pointer to the hw struct |
| 3865 | * @seid: seid of the switching component |
| 3866 | * @bw_data: Buffer to hold switching component's per TC BW config |
| 3867 | * @cmd_details: pointer to command details structure or NULL |
| 3868 | **/ |
| 3869 | i40e_status i40e_aq_query_switch_comp_ets_config(struct i40e_hw *hw, |
| 3870 | u16 seid, |
| 3871 | struct i40e_aqc_query_switching_comp_ets_config_resp *bw_data, |
| 3872 | struct i40e_asq_cmd_details *cmd_details) |
| 3873 | { |
| 3874 | return i40e_aq_tx_sched_cmd(hw, seid, (void *)bw_data, sizeof(*bw_data), |
| 3875 | i40e_aqc_opc_query_switching_comp_ets_config, |
| 3876 | cmd_details); |
| 3877 | } |
| 3878 | |
| 3879 | /** |
| 3880 | * i40e_aq_query_port_ets_config - Query Physical Port ETS configuration |
| 3881 | * @hw: pointer to the hw struct |
| 3882 | * @seid: seid of the VSI or switching component connected to Physical Port |
| 3883 | * @bw_data: Buffer to hold current ETS configuration for the Physical Port |
| 3884 | * @cmd_details: pointer to command details structure or NULL |
| 3885 | **/ |
| 3886 | i40e_status i40e_aq_query_port_ets_config(struct i40e_hw *hw, |
| 3887 | u16 seid, |
| 3888 | struct i40e_aqc_query_port_ets_config_resp *bw_data, |
| 3889 | struct i40e_asq_cmd_details *cmd_details) |
| 3890 | { |
| 3891 | return i40e_aq_tx_sched_cmd(hw, seid, (void *)bw_data, sizeof(*bw_data), |
| 3892 | i40e_aqc_opc_query_port_ets_config, |
| 3893 | cmd_details); |
| 3894 | } |
| 3895 | |
| 3896 | /** |
| 3897 | * i40e_aq_query_switch_comp_bw_config - Query Switch comp BW configuration |
| 3898 | * @hw: pointer to the hw struct |
| 3899 | * @seid: seid of the switching component |
| 3900 | * @bw_data: Buffer to hold switching component's BW configuration |
| 3901 | * @cmd_details: pointer to command details structure or NULL |
| 3902 | **/ |
| 3903 | i40e_status i40e_aq_query_switch_comp_bw_config(struct i40e_hw *hw, |
| 3904 | u16 seid, |
| 3905 | struct i40e_aqc_query_switching_comp_bw_config_resp *bw_data, |
| 3906 | struct i40e_asq_cmd_details *cmd_details) |
| 3907 | { |
| 3908 | return i40e_aq_tx_sched_cmd(hw, seid, (void *)bw_data, sizeof(*bw_data), |
| 3909 | i40e_aqc_opc_query_switching_comp_bw_config, |
| 3910 | cmd_details); |
| 3911 | } |
| 3912 | |
| 3913 | /** |
| 3914 | * i40e_validate_filter_settings |
| 3915 | * @hw: pointer to the hardware structure |
| 3916 | * @settings: Filter control settings |
| 3917 | * |
| 3918 | * Check and validate the filter control settings passed. |
| 3919 | * The function checks for the valid filter/context sizes being |
| 3920 | * passed for FCoE and PE. |
| 3921 | * |
| 3922 | * Returns 0 if the values passed are valid and within |
| 3923 | * range else returns an error. |
| 3924 | **/ |
| 3925 | static i40e_status i40e_validate_filter_settings(struct i40e_hw *hw, |
| 3926 | struct i40e_filter_control_settings *settings) |
| 3927 | { |
| 3928 | u32 fcoe_cntx_size, fcoe_filt_size; |
| 3929 | u32 pe_cntx_size, pe_filt_size; |
Anjali Singhai Jain | 467d729 | 2014-05-10 04:49:02 +0000 | [diff] [blame] | 3930 | u32 fcoe_fmax; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 3931 | u32 val; |
| 3932 | |
| 3933 | /* Validate FCoE settings passed */ |
| 3934 | switch (settings->fcoe_filt_num) { |
| 3935 | case I40E_HASH_FILTER_SIZE_1K: |
| 3936 | case I40E_HASH_FILTER_SIZE_2K: |
| 3937 | case I40E_HASH_FILTER_SIZE_4K: |
| 3938 | case I40E_HASH_FILTER_SIZE_8K: |
| 3939 | case I40E_HASH_FILTER_SIZE_16K: |
| 3940 | case I40E_HASH_FILTER_SIZE_32K: |
| 3941 | fcoe_filt_size = I40E_HASH_FILTER_BASE_SIZE; |
| 3942 | fcoe_filt_size <<= (u32)settings->fcoe_filt_num; |
| 3943 | break; |
| 3944 | default: |
| 3945 | return I40E_ERR_PARAM; |
| 3946 | } |
| 3947 | |
| 3948 | switch (settings->fcoe_cntx_num) { |
| 3949 | case I40E_DMA_CNTX_SIZE_512: |
| 3950 | case I40E_DMA_CNTX_SIZE_1K: |
| 3951 | case I40E_DMA_CNTX_SIZE_2K: |
| 3952 | case I40E_DMA_CNTX_SIZE_4K: |
| 3953 | fcoe_cntx_size = I40E_DMA_CNTX_BASE_SIZE; |
| 3954 | fcoe_cntx_size <<= (u32)settings->fcoe_cntx_num; |
| 3955 | break; |
| 3956 | default: |
| 3957 | return I40E_ERR_PARAM; |
| 3958 | } |
| 3959 | |
| 3960 | /* Validate PE settings passed */ |
| 3961 | switch (settings->pe_filt_num) { |
| 3962 | case I40E_HASH_FILTER_SIZE_1K: |
| 3963 | case I40E_HASH_FILTER_SIZE_2K: |
| 3964 | case I40E_HASH_FILTER_SIZE_4K: |
| 3965 | case I40E_HASH_FILTER_SIZE_8K: |
| 3966 | case I40E_HASH_FILTER_SIZE_16K: |
| 3967 | case I40E_HASH_FILTER_SIZE_32K: |
| 3968 | case I40E_HASH_FILTER_SIZE_64K: |
| 3969 | case I40E_HASH_FILTER_SIZE_128K: |
| 3970 | case I40E_HASH_FILTER_SIZE_256K: |
| 3971 | case I40E_HASH_FILTER_SIZE_512K: |
| 3972 | case I40E_HASH_FILTER_SIZE_1M: |
| 3973 | pe_filt_size = I40E_HASH_FILTER_BASE_SIZE; |
| 3974 | pe_filt_size <<= (u32)settings->pe_filt_num; |
| 3975 | break; |
| 3976 | default: |
| 3977 | return I40E_ERR_PARAM; |
| 3978 | } |
| 3979 | |
| 3980 | switch (settings->pe_cntx_num) { |
| 3981 | case I40E_DMA_CNTX_SIZE_512: |
| 3982 | case I40E_DMA_CNTX_SIZE_1K: |
| 3983 | case I40E_DMA_CNTX_SIZE_2K: |
| 3984 | case I40E_DMA_CNTX_SIZE_4K: |
| 3985 | case I40E_DMA_CNTX_SIZE_8K: |
| 3986 | case I40E_DMA_CNTX_SIZE_16K: |
| 3987 | case I40E_DMA_CNTX_SIZE_32K: |
| 3988 | case I40E_DMA_CNTX_SIZE_64K: |
| 3989 | case I40E_DMA_CNTX_SIZE_128K: |
| 3990 | case I40E_DMA_CNTX_SIZE_256K: |
| 3991 | pe_cntx_size = I40E_DMA_CNTX_BASE_SIZE; |
| 3992 | pe_cntx_size <<= (u32)settings->pe_cntx_num; |
| 3993 | break; |
| 3994 | default: |
| 3995 | return I40E_ERR_PARAM; |
| 3996 | } |
| 3997 | |
| 3998 | /* FCHSIZE + FCDSIZE should not be greater than PMFCOEFMAX */ |
| 3999 | val = rd32(hw, I40E_GLHMC_FCOEFMAX); |
| 4000 | fcoe_fmax = (val & I40E_GLHMC_FCOEFMAX_PMFCOEFMAX_MASK) |
| 4001 | >> I40E_GLHMC_FCOEFMAX_PMFCOEFMAX_SHIFT; |
| 4002 | if (fcoe_filt_size + fcoe_cntx_size > fcoe_fmax) |
| 4003 | return I40E_ERR_INVALID_SIZE; |
| 4004 | |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 4005 | return 0; |
| 4006 | } |
| 4007 | |
| 4008 | /** |
| 4009 | * i40e_set_filter_control |
| 4010 | * @hw: pointer to the hardware structure |
| 4011 | * @settings: Filter control settings |
| 4012 | * |
| 4013 | * Set the Queue Filters for PE/FCoE and enable filters required |
| 4014 | * for a single PF. It is expected that these settings are programmed |
| 4015 | * at the driver initialization time. |
| 4016 | **/ |
| 4017 | i40e_status i40e_set_filter_control(struct i40e_hw *hw, |
| 4018 | struct i40e_filter_control_settings *settings) |
| 4019 | { |
| 4020 | i40e_status ret = 0; |
| 4021 | u32 hash_lut_size = 0; |
| 4022 | u32 val; |
| 4023 | |
| 4024 | if (!settings) |
| 4025 | return I40E_ERR_PARAM; |
| 4026 | |
| 4027 | /* Validate the input settings */ |
| 4028 | ret = i40e_validate_filter_settings(hw, settings); |
| 4029 | if (ret) |
| 4030 | return ret; |
| 4031 | |
| 4032 | /* Read the PF Queue Filter control register */ |
Shannon Nelson | f658137 | 2016-02-17 16:12:20 -0800 | [diff] [blame] | 4033 | val = i40e_read_rx_ctl(hw, I40E_PFQF_CTL_0); |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 4034 | |
| 4035 | /* Program required PE hash buckets for the PF */ |
| 4036 | val &= ~I40E_PFQF_CTL_0_PEHSIZE_MASK; |
| 4037 | val |= ((u32)settings->pe_filt_num << I40E_PFQF_CTL_0_PEHSIZE_SHIFT) & |
| 4038 | I40E_PFQF_CTL_0_PEHSIZE_MASK; |
| 4039 | /* Program required PE contexts for the PF */ |
| 4040 | val &= ~I40E_PFQF_CTL_0_PEDSIZE_MASK; |
| 4041 | val |= ((u32)settings->pe_cntx_num << I40E_PFQF_CTL_0_PEDSIZE_SHIFT) & |
| 4042 | I40E_PFQF_CTL_0_PEDSIZE_MASK; |
| 4043 | |
| 4044 | /* Program required FCoE hash buckets for the PF */ |
| 4045 | val &= ~I40E_PFQF_CTL_0_PFFCHSIZE_MASK; |
| 4046 | val |= ((u32)settings->fcoe_filt_num << |
| 4047 | I40E_PFQF_CTL_0_PFFCHSIZE_SHIFT) & |
| 4048 | I40E_PFQF_CTL_0_PFFCHSIZE_MASK; |
| 4049 | /* Program required FCoE DDP contexts for the PF */ |
| 4050 | val &= ~I40E_PFQF_CTL_0_PFFCDSIZE_MASK; |
| 4051 | val |= ((u32)settings->fcoe_cntx_num << |
| 4052 | I40E_PFQF_CTL_0_PFFCDSIZE_SHIFT) & |
| 4053 | I40E_PFQF_CTL_0_PFFCDSIZE_MASK; |
| 4054 | |
| 4055 | /* Program Hash LUT size for the PF */ |
| 4056 | val &= ~I40E_PFQF_CTL_0_HASHLUTSIZE_MASK; |
| 4057 | if (settings->hash_lut_size == I40E_HASH_LUT_SIZE_512) |
| 4058 | hash_lut_size = 1; |
| 4059 | val |= (hash_lut_size << I40E_PFQF_CTL_0_HASHLUTSIZE_SHIFT) & |
| 4060 | I40E_PFQF_CTL_0_HASHLUTSIZE_MASK; |
| 4061 | |
| 4062 | /* Enable FDIR, Ethertype and MACVLAN filters for PF and VFs */ |
| 4063 | if (settings->enable_fdir) |
| 4064 | val |= I40E_PFQF_CTL_0_FD_ENA_MASK; |
| 4065 | if (settings->enable_ethtype) |
| 4066 | val |= I40E_PFQF_CTL_0_ETYPE_ENA_MASK; |
| 4067 | if (settings->enable_macvlan) |
| 4068 | val |= I40E_PFQF_CTL_0_MACVLAN_ENA_MASK; |
| 4069 | |
Shannon Nelson | f658137 | 2016-02-17 16:12:20 -0800 | [diff] [blame] | 4070 | i40e_write_rx_ctl(hw, I40E_PFQF_CTL_0, val); |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 4071 | |
| 4072 | return 0; |
| 4073 | } |
Neerav Parikh | afb3ff0 | 2014-01-17 15:36:36 -0800 | [diff] [blame] | 4074 | |
| 4075 | /** |
| 4076 | * i40e_aq_add_rem_control_packet_filter - Add or Remove Control Packet Filter |
| 4077 | * @hw: pointer to the hw struct |
| 4078 | * @mac_addr: MAC address to use in the filter |
| 4079 | * @ethtype: Ethertype to use in the filter |
| 4080 | * @flags: Flags that needs to be applied to the filter |
| 4081 | * @vsi_seid: seid of the control VSI |
| 4082 | * @queue: VSI queue number to send the packet to |
| 4083 | * @is_add: Add control packet filter if True else remove |
| 4084 | * @stats: Structure to hold information on control filter counts |
| 4085 | * @cmd_details: pointer to command details structure or NULL |
| 4086 | * |
| 4087 | * This command will Add or Remove control packet filter for a control VSI. |
| 4088 | * In return it will update the total number of perfect filter count in |
| 4089 | * the stats member. |
| 4090 | **/ |
| 4091 | i40e_status i40e_aq_add_rem_control_packet_filter(struct i40e_hw *hw, |
| 4092 | u8 *mac_addr, u16 ethtype, u16 flags, |
| 4093 | u16 vsi_seid, u16 queue, bool is_add, |
| 4094 | struct i40e_control_filter_stats *stats, |
| 4095 | struct i40e_asq_cmd_details *cmd_details) |
| 4096 | { |
| 4097 | struct i40e_aq_desc desc; |
| 4098 | struct i40e_aqc_add_remove_control_packet_filter *cmd = |
| 4099 | (struct i40e_aqc_add_remove_control_packet_filter *) |
| 4100 | &desc.params.raw; |
| 4101 | struct i40e_aqc_add_remove_control_packet_filter_completion *resp = |
| 4102 | (struct i40e_aqc_add_remove_control_packet_filter_completion *) |
| 4103 | &desc.params.raw; |
| 4104 | i40e_status status; |
| 4105 | |
| 4106 | if (vsi_seid == 0) |
| 4107 | return I40E_ERR_PARAM; |
| 4108 | |
| 4109 | if (is_add) { |
| 4110 | i40e_fill_default_direct_cmd_desc(&desc, |
| 4111 | i40e_aqc_opc_add_control_packet_filter); |
| 4112 | cmd->queue = cpu_to_le16(queue); |
| 4113 | } else { |
| 4114 | i40e_fill_default_direct_cmd_desc(&desc, |
| 4115 | i40e_aqc_opc_remove_control_packet_filter); |
| 4116 | } |
| 4117 | |
| 4118 | if (mac_addr) |
Jesse Brandeburg | 6995b36 | 2015-08-28 17:55:54 -0400 | [diff] [blame] | 4119 | ether_addr_copy(cmd->mac, mac_addr); |
Neerav Parikh | afb3ff0 | 2014-01-17 15:36:36 -0800 | [diff] [blame] | 4120 | |
| 4121 | cmd->etype = cpu_to_le16(ethtype); |
| 4122 | cmd->flags = cpu_to_le16(flags); |
| 4123 | cmd->seid = cpu_to_le16(vsi_seid); |
| 4124 | |
| 4125 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 4126 | |
| 4127 | if (!status && stats) { |
| 4128 | stats->mac_etype_used = le16_to_cpu(resp->mac_etype_used); |
| 4129 | stats->etype_used = le16_to_cpu(resp->etype_used); |
| 4130 | stats->mac_etype_free = le16_to_cpu(resp->mac_etype_free); |
| 4131 | stats->etype_free = le16_to_cpu(resp->etype_free); |
| 4132 | } |
| 4133 | |
| 4134 | return status; |
| 4135 | } |
| 4136 | |
Catherine Sullivan | d4dfb81 | 2013-11-28 06:39:21 +0000 | [diff] [blame] | 4137 | /** |
Anjali Singhai Jain | e7358f5 | 2015-10-01 14:37:34 -0400 | [diff] [blame] | 4138 | * i40e_add_filter_to_drop_tx_flow_control_frames- filter to drop flow control |
| 4139 | * @hw: pointer to the hw struct |
| 4140 | * @seid: VSI seid to add ethertype filter from |
| 4141 | **/ |
| 4142 | #define I40E_FLOW_CONTROL_ETHTYPE 0x8808 |
| 4143 | void i40e_add_filter_to_drop_tx_flow_control_frames(struct i40e_hw *hw, |
| 4144 | u16 seid) |
| 4145 | { |
| 4146 | u16 flag = I40E_AQC_ADD_CONTROL_PACKET_FLAGS_IGNORE_MAC | |
| 4147 | I40E_AQC_ADD_CONTROL_PACKET_FLAGS_DROP | |
| 4148 | I40E_AQC_ADD_CONTROL_PACKET_FLAGS_TX; |
| 4149 | u16 ethtype = I40E_FLOW_CONTROL_ETHTYPE; |
| 4150 | i40e_status status; |
| 4151 | |
| 4152 | status = i40e_aq_add_rem_control_packet_filter(hw, NULL, ethtype, flag, |
| 4153 | seid, 0, true, NULL, |
| 4154 | NULL); |
| 4155 | if (status) |
| 4156 | hw_dbg(hw, "Ethtype Filter Add failed: Error pruning Tx flow control frames\n"); |
| 4157 | } |
| 4158 | |
| 4159 | /** |
Greg Rose | f4492db | 2015-02-06 08:52:12 +0000 | [diff] [blame] | 4160 | * i40e_aq_alternate_read |
| 4161 | * @hw: pointer to the hardware structure |
| 4162 | * @reg_addr0: address of first dword to be read |
| 4163 | * @reg_val0: pointer for data read from 'reg_addr0' |
| 4164 | * @reg_addr1: address of second dword to be read |
| 4165 | * @reg_val1: pointer for data read from 'reg_addr1' |
| 4166 | * |
| 4167 | * Read one or two dwords from alternate structure. Fields are indicated |
| 4168 | * by 'reg_addr0' and 'reg_addr1' register numbers. If 'reg_val1' pointer |
| 4169 | * is not passed then only register at 'reg_addr0' is read. |
| 4170 | * |
| 4171 | **/ |
Shannon Nelson | 37a2973 | 2015-02-27 09:15:19 +0000 | [diff] [blame] | 4172 | static i40e_status i40e_aq_alternate_read(struct i40e_hw *hw, |
| 4173 | u32 reg_addr0, u32 *reg_val0, |
| 4174 | u32 reg_addr1, u32 *reg_val1) |
Greg Rose | f4492db | 2015-02-06 08:52:12 +0000 | [diff] [blame] | 4175 | { |
| 4176 | struct i40e_aq_desc desc; |
| 4177 | struct i40e_aqc_alternate_write *cmd_resp = |
| 4178 | (struct i40e_aqc_alternate_write *)&desc.params.raw; |
| 4179 | i40e_status status; |
| 4180 | |
| 4181 | if (!reg_val0) |
| 4182 | return I40E_ERR_PARAM; |
| 4183 | |
| 4184 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_alternate_read); |
| 4185 | cmd_resp->address0 = cpu_to_le32(reg_addr0); |
| 4186 | cmd_resp->address1 = cpu_to_le32(reg_addr1); |
| 4187 | |
| 4188 | status = i40e_asq_send_command(hw, &desc, NULL, 0, NULL); |
| 4189 | |
| 4190 | if (!status) { |
| 4191 | *reg_val0 = le32_to_cpu(cmd_resp->data0); |
| 4192 | |
| 4193 | if (reg_val1) |
| 4194 | *reg_val1 = le32_to_cpu(cmd_resp->data1); |
| 4195 | } |
| 4196 | |
| 4197 | return status; |
| 4198 | } |
| 4199 | |
| 4200 | /** |
Neerav Parikh | 2fd75f3 | 2014-11-12 00:18:20 +0000 | [diff] [blame] | 4201 | * i40e_aq_resume_port_tx |
| 4202 | * @hw: pointer to the hardware structure |
| 4203 | * @cmd_details: pointer to command details structure or NULL |
| 4204 | * |
| 4205 | * Resume port's Tx traffic |
| 4206 | **/ |
| 4207 | i40e_status i40e_aq_resume_port_tx(struct i40e_hw *hw, |
| 4208 | struct i40e_asq_cmd_details *cmd_details) |
| 4209 | { |
| 4210 | struct i40e_aq_desc desc; |
| 4211 | i40e_status status; |
| 4212 | |
| 4213 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_resume_port_tx); |
| 4214 | |
| 4215 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 4216 | |
| 4217 | return status; |
| 4218 | } |
| 4219 | |
| 4220 | /** |
Catherine Sullivan | d4dfb81 | 2013-11-28 06:39:21 +0000 | [diff] [blame] | 4221 | * i40e_set_pci_config_data - store PCI bus info |
| 4222 | * @hw: pointer to hardware structure |
| 4223 | * @link_status: the link status word from PCI config space |
| 4224 | * |
| 4225 | * Stores the PCI bus info (speed, width, type) within the i40e_hw structure |
| 4226 | **/ |
| 4227 | void i40e_set_pci_config_data(struct i40e_hw *hw, u16 link_status) |
| 4228 | { |
| 4229 | hw->bus.type = i40e_bus_type_pci_express; |
| 4230 | |
| 4231 | switch (link_status & PCI_EXP_LNKSTA_NLW) { |
| 4232 | case PCI_EXP_LNKSTA_NLW_X1: |
| 4233 | hw->bus.width = i40e_bus_width_pcie_x1; |
| 4234 | break; |
| 4235 | case PCI_EXP_LNKSTA_NLW_X2: |
| 4236 | hw->bus.width = i40e_bus_width_pcie_x2; |
| 4237 | break; |
| 4238 | case PCI_EXP_LNKSTA_NLW_X4: |
| 4239 | hw->bus.width = i40e_bus_width_pcie_x4; |
| 4240 | break; |
| 4241 | case PCI_EXP_LNKSTA_NLW_X8: |
| 4242 | hw->bus.width = i40e_bus_width_pcie_x8; |
| 4243 | break; |
| 4244 | default: |
| 4245 | hw->bus.width = i40e_bus_width_unknown; |
| 4246 | break; |
| 4247 | } |
| 4248 | |
| 4249 | switch (link_status & PCI_EXP_LNKSTA_CLS) { |
| 4250 | case PCI_EXP_LNKSTA_CLS_2_5GB: |
| 4251 | hw->bus.speed = i40e_bus_speed_2500; |
| 4252 | break; |
| 4253 | case PCI_EXP_LNKSTA_CLS_5_0GB: |
| 4254 | hw->bus.speed = i40e_bus_speed_5000; |
| 4255 | break; |
| 4256 | case PCI_EXP_LNKSTA_CLS_8_0GB: |
| 4257 | hw->bus.speed = i40e_bus_speed_8000; |
| 4258 | break; |
| 4259 | default: |
| 4260 | hw->bus.speed = i40e_bus_speed_unknown; |
| 4261 | break; |
| 4262 | } |
| 4263 | } |
Greg Rose | f4492db | 2015-02-06 08:52:12 +0000 | [diff] [blame] | 4264 | |
| 4265 | /** |
Jesse Brandeburg | 3169c32 | 2015-04-07 19:45:37 -0400 | [diff] [blame] | 4266 | * i40e_aq_debug_dump |
| 4267 | * @hw: pointer to the hardware structure |
| 4268 | * @cluster_id: specific cluster to dump |
| 4269 | * @table_id: table id within cluster |
| 4270 | * @start_index: index of line in the block to read |
| 4271 | * @buff_size: dump buffer size |
| 4272 | * @buff: dump buffer |
| 4273 | * @ret_buff_size: actual buffer size returned |
| 4274 | * @ret_next_table: next block to read |
| 4275 | * @ret_next_index: next index to read |
| 4276 | * |
| 4277 | * Dump internal FW/HW data for debug purposes. |
| 4278 | * |
| 4279 | **/ |
| 4280 | i40e_status i40e_aq_debug_dump(struct i40e_hw *hw, u8 cluster_id, |
| 4281 | u8 table_id, u32 start_index, u16 buff_size, |
| 4282 | void *buff, u16 *ret_buff_size, |
| 4283 | u8 *ret_next_table, u32 *ret_next_index, |
| 4284 | struct i40e_asq_cmd_details *cmd_details) |
| 4285 | { |
| 4286 | struct i40e_aq_desc desc; |
| 4287 | struct i40e_aqc_debug_dump_internals *cmd = |
| 4288 | (struct i40e_aqc_debug_dump_internals *)&desc.params.raw; |
| 4289 | struct i40e_aqc_debug_dump_internals *resp = |
| 4290 | (struct i40e_aqc_debug_dump_internals *)&desc.params.raw; |
| 4291 | i40e_status status; |
| 4292 | |
| 4293 | if (buff_size == 0 || !buff) |
| 4294 | return I40E_ERR_PARAM; |
| 4295 | |
| 4296 | i40e_fill_default_direct_cmd_desc(&desc, |
| 4297 | i40e_aqc_opc_debug_dump_internals); |
| 4298 | /* Indirect Command */ |
| 4299 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF); |
| 4300 | if (buff_size > I40E_AQ_LARGE_BUF) |
| 4301 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB); |
| 4302 | |
| 4303 | cmd->cluster_id = cluster_id; |
| 4304 | cmd->table_id = table_id; |
| 4305 | cmd->idx = cpu_to_le32(start_index); |
| 4306 | |
| 4307 | desc.datalen = cpu_to_le16(buff_size); |
| 4308 | |
| 4309 | status = i40e_asq_send_command(hw, &desc, buff, buff_size, cmd_details); |
| 4310 | if (!status) { |
| 4311 | if (ret_buff_size) |
| 4312 | *ret_buff_size = le16_to_cpu(desc.datalen); |
| 4313 | if (ret_next_table) |
| 4314 | *ret_next_table = resp->table_id; |
| 4315 | if (ret_next_index) |
| 4316 | *ret_next_index = le32_to_cpu(resp->idx); |
| 4317 | } |
| 4318 | |
| 4319 | return status; |
| 4320 | } |
| 4321 | |
| 4322 | /** |
Greg Rose | f4492db | 2015-02-06 08:52:12 +0000 | [diff] [blame] | 4323 | * i40e_read_bw_from_alt_ram |
| 4324 | * @hw: pointer to the hardware structure |
| 4325 | * @max_bw: pointer for max_bw read |
| 4326 | * @min_bw: pointer for min_bw read |
| 4327 | * @min_valid: pointer for bool that is true if min_bw is a valid value |
| 4328 | * @max_valid: pointer for bool that is true if max_bw is a valid value |
| 4329 | * |
| 4330 | * Read bw from the alternate ram for the given pf |
| 4331 | **/ |
| 4332 | i40e_status i40e_read_bw_from_alt_ram(struct i40e_hw *hw, |
| 4333 | u32 *max_bw, u32 *min_bw, |
| 4334 | bool *min_valid, bool *max_valid) |
| 4335 | { |
| 4336 | i40e_status status; |
| 4337 | u32 max_bw_addr, min_bw_addr; |
| 4338 | |
| 4339 | /* Calculate the address of the min/max bw registers */ |
| 4340 | max_bw_addr = I40E_ALT_STRUCT_FIRST_PF_OFFSET + |
| 4341 | I40E_ALT_STRUCT_MAX_BW_OFFSET + |
| 4342 | (I40E_ALT_STRUCT_DWORDS_PER_PF * hw->pf_id); |
| 4343 | min_bw_addr = I40E_ALT_STRUCT_FIRST_PF_OFFSET + |
| 4344 | I40E_ALT_STRUCT_MIN_BW_OFFSET + |
| 4345 | (I40E_ALT_STRUCT_DWORDS_PER_PF * hw->pf_id); |
| 4346 | |
| 4347 | /* Read the bandwidths from alt ram */ |
| 4348 | status = i40e_aq_alternate_read(hw, max_bw_addr, max_bw, |
| 4349 | min_bw_addr, min_bw); |
| 4350 | |
| 4351 | if (*min_bw & I40E_ALT_BW_VALID_MASK) |
| 4352 | *min_valid = true; |
| 4353 | else |
| 4354 | *min_valid = false; |
| 4355 | |
| 4356 | if (*max_bw & I40E_ALT_BW_VALID_MASK) |
| 4357 | *max_valid = true; |
| 4358 | else |
| 4359 | *max_valid = false; |
| 4360 | |
| 4361 | return status; |
| 4362 | } |
| 4363 | |
| 4364 | /** |
| 4365 | * i40e_aq_configure_partition_bw |
| 4366 | * @hw: pointer to the hardware structure |
| 4367 | * @bw_data: Buffer holding valid pfs and bw limits |
| 4368 | * @cmd_details: pointer to command details |
| 4369 | * |
| 4370 | * Configure partitions guaranteed/max bw |
| 4371 | **/ |
| 4372 | i40e_status i40e_aq_configure_partition_bw(struct i40e_hw *hw, |
| 4373 | struct i40e_aqc_configure_partition_bw_data *bw_data, |
| 4374 | struct i40e_asq_cmd_details *cmd_details) |
| 4375 | { |
| 4376 | i40e_status status; |
| 4377 | struct i40e_aq_desc desc; |
| 4378 | u16 bwd_size = sizeof(*bw_data); |
| 4379 | |
| 4380 | i40e_fill_default_direct_cmd_desc(&desc, |
| 4381 | i40e_aqc_opc_configure_partition_bw); |
| 4382 | |
| 4383 | /* Indirect command */ |
| 4384 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF); |
| 4385 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_RD); |
| 4386 | |
| 4387 | if (bwd_size > I40E_AQ_LARGE_BUF) |
| 4388 | desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB); |
| 4389 | |
| 4390 | desc.datalen = cpu_to_le16(bwd_size); |
| 4391 | |
| 4392 | status = i40e_asq_send_command(hw, &desc, bw_data, bwd_size, |
| 4393 | cmd_details); |
| 4394 | |
| 4395 | return status; |
| 4396 | } |
Carolyn Wyborny | fd077cd | 2016-02-17 16:12:11 -0800 | [diff] [blame] | 4397 | |
| 4398 | /** |
| 4399 | * i40e_read_phy_register |
| 4400 | * @hw: pointer to the HW structure |
| 4401 | * @page: registers page number |
| 4402 | * @reg: register address in the page |
| 4403 | * @phy_adr: PHY address on MDIO interface |
| 4404 | * @value: PHY register value |
| 4405 | * |
| 4406 | * Reads specified PHY register value |
| 4407 | **/ |
| 4408 | i40e_status i40e_read_phy_register(struct i40e_hw *hw, |
| 4409 | u8 page, u16 reg, u8 phy_addr, |
| 4410 | u16 *value) |
| 4411 | { |
| 4412 | i40e_status status = I40E_ERR_TIMEOUT; |
| 4413 | u32 command = 0; |
| 4414 | u16 retry = 1000; |
| 4415 | u8 port_num = hw->func_caps.mdio_port_num; |
| 4416 | |
| 4417 | command = (reg << I40E_GLGEN_MSCA_MDIADD_SHIFT) | |
| 4418 | (page << I40E_GLGEN_MSCA_DEVADD_SHIFT) | |
| 4419 | (phy_addr << I40E_GLGEN_MSCA_PHYADD_SHIFT) | |
| 4420 | (I40E_MDIO_OPCODE_ADDRESS) | |
| 4421 | (I40E_MDIO_STCODE) | |
| 4422 | (I40E_GLGEN_MSCA_MDICMD_MASK) | |
| 4423 | (I40E_GLGEN_MSCA_MDIINPROGEN_MASK); |
| 4424 | wr32(hw, I40E_GLGEN_MSCA(port_num), command); |
| 4425 | do { |
| 4426 | command = rd32(hw, I40E_GLGEN_MSCA(port_num)); |
| 4427 | if (!(command & I40E_GLGEN_MSCA_MDICMD_MASK)) { |
| 4428 | status = 0; |
| 4429 | break; |
| 4430 | } |
| 4431 | usleep_range(10, 20); |
| 4432 | retry--; |
| 4433 | } while (retry); |
| 4434 | |
| 4435 | if (status) { |
| 4436 | i40e_debug(hw, I40E_DEBUG_PHY, |
| 4437 | "PHY: Can't write command to external PHY.\n"); |
| 4438 | goto phy_read_end; |
| 4439 | } |
| 4440 | |
| 4441 | command = (page << I40E_GLGEN_MSCA_DEVADD_SHIFT) | |
| 4442 | (phy_addr << I40E_GLGEN_MSCA_PHYADD_SHIFT) | |
| 4443 | (I40E_MDIO_OPCODE_READ) | |
| 4444 | (I40E_MDIO_STCODE) | |
| 4445 | (I40E_GLGEN_MSCA_MDICMD_MASK) | |
| 4446 | (I40E_GLGEN_MSCA_MDIINPROGEN_MASK); |
| 4447 | status = I40E_ERR_TIMEOUT; |
| 4448 | retry = 1000; |
| 4449 | wr32(hw, I40E_GLGEN_MSCA(port_num), command); |
| 4450 | do { |
| 4451 | command = rd32(hw, I40E_GLGEN_MSCA(port_num)); |
| 4452 | if (!(command & I40E_GLGEN_MSCA_MDICMD_MASK)) { |
| 4453 | status = 0; |
| 4454 | break; |
| 4455 | } |
| 4456 | usleep_range(10, 20); |
| 4457 | retry--; |
| 4458 | } while (retry); |
| 4459 | |
| 4460 | if (!status) { |
| 4461 | command = rd32(hw, I40E_GLGEN_MSRWD(port_num)); |
| 4462 | *value = (command & I40E_GLGEN_MSRWD_MDIRDDATA_MASK) >> |
| 4463 | I40E_GLGEN_MSRWD_MDIRDDATA_SHIFT; |
| 4464 | } else { |
| 4465 | i40e_debug(hw, I40E_DEBUG_PHY, |
| 4466 | "PHY: Can't read register value from external PHY.\n"); |
| 4467 | } |
| 4468 | |
| 4469 | phy_read_end: |
| 4470 | return status; |
| 4471 | } |
| 4472 | |
| 4473 | /** |
| 4474 | * i40e_write_phy_register |
| 4475 | * @hw: pointer to the HW structure |
| 4476 | * @page: registers page number |
| 4477 | * @reg: register address in the page |
| 4478 | * @phy_adr: PHY address on MDIO interface |
| 4479 | * @value: PHY register value |
| 4480 | * |
| 4481 | * Writes value to specified PHY register |
| 4482 | **/ |
| 4483 | i40e_status i40e_write_phy_register(struct i40e_hw *hw, |
| 4484 | u8 page, u16 reg, u8 phy_addr, |
| 4485 | u16 value) |
| 4486 | { |
| 4487 | i40e_status status = I40E_ERR_TIMEOUT; |
| 4488 | u32 command = 0; |
| 4489 | u16 retry = 1000; |
| 4490 | u8 port_num = hw->func_caps.mdio_port_num; |
| 4491 | |
| 4492 | command = (reg << I40E_GLGEN_MSCA_MDIADD_SHIFT) | |
| 4493 | (page << I40E_GLGEN_MSCA_DEVADD_SHIFT) | |
| 4494 | (phy_addr << I40E_GLGEN_MSCA_PHYADD_SHIFT) | |
| 4495 | (I40E_MDIO_OPCODE_ADDRESS) | |
| 4496 | (I40E_MDIO_STCODE) | |
| 4497 | (I40E_GLGEN_MSCA_MDICMD_MASK) | |
| 4498 | (I40E_GLGEN_MSCA_MDIINPROGEN_MASK); |
| 4499 | wr32(hw, I40E_GLGEN_MSCA(port_num), command); |
| 4500 | do { |
| 4501 | command = rd32(hw, I40E_GLGEN_MSCA(port_num)); |
| 4502 | if (!(command & I40E_GLGEN_MSCA_MDICMD_MASK)) { |
| 4503 | status = 0; |
| 4504 | break; |
| 4505 | } |
| 4506 | usleep_range(10, 20); |
| 4507 | retry--; |
| 4508 | } while (retry); |
| 4509 | if (status) { |
| 4510 | i40e_debug(hw, I40E_DEBUG_PHY, |
| 4511 | "PHY: Can't write command to external PHY.\n"); |
| 4512 | goto phy_write_end; |
| 4513 | } |
| 4514 | |
| 4515 | command = value << I40E_GLGEN_MSRWD_MDIWRDATA_SHIFT; |
| 4516 | wr32(hw, I40E_GLGEN_MSRWD(port_num), command); |
| 4517 | |
| 4518 | command = (page << I40E_GLGEN_MSCA_DEVADD_SHIFT) | |
| 4519 | (phy_addr << I40E_GLGEN_MSCA_PHYADD_SHIFT) | |
| 4520 | (I40E_MDIO_OPCODE_WRITE) | |
| 4521 | (I40E_MDIO_STCODE) | |
| 4522 | (I40E_GLGEN_MSCA_MDICMD_MASK) | |
| 4523 | (I40E_GLGEN_MSCA_MDIINPROGEN_MASK); |
| 4524 | status = I40E_ERR_TIMEOUT; |
| 4525 | retry = 1000; |
| 4526 | wr32(hw, I40E_GLGEN_MSCA(port_num), command); |
| 4527 | do { |
| 4528 | command = rd32(hw, I40E_GLGEN_MSCA(port_num)); |
| 4529 | if (!(command & I40E_GLGEN_MSCA_MDICMD_MASK)) { |
| 4530 | status = 0; |
| 4531 | break; |
| 4532 | } |
| 4533 | usleep_range(10, 20); |
| 4534 | retry--; |
| 4535 | } while (retry); |
| 4536 | |
| 4537 | phy_write_end: |
| 4538 | return status; |
| 4539 | } |
| 4540 | |
| 4541 | /** |
| 4542 | * i40e_get_phy_address |
| 4543 | * @hw: pointer to the HW structure |
| 4544 | * @dev_num: PHY port num that address we want |
| 4545 | * @phy_addr: Returned PHY address |
| 4546 | * |
| 4547 | * Gets PHY address for current port |
| 4548 | **/ |
| 4549 | u8 i40e_get_phy_address(struct i40e_hw *hw, u8 dev_num) |
| 4550 | { |
| 4551 | u8 port_num = hw->func_caps.mdio_port_num; |
| 4552 | u32 reg_val = rd32(hw, I40E_GLGEN_MDIO_I2C_SEL(port_num)); |
| 4553 | |
| 4554 | return (u8)(reg_val >> ((dev_num + 1) * 5)) & 0x1f; |
| 4555 | } |
| 4556 | |
| 4557 | /** |
| 4558 | * i40e_blink_phy_led |
| 4559 | * @hw: pointer to the HW structure |
| 4560 | * @time: time how long led will blinks in secs |
| 4561 | * @interval: gap between LED on and off in msecs |
| 4562 | * |
| 4563 | * Blinks PHY link LED |
| 4564 | **/ |
| 4565 | i40e_status i40e_blink_phy_link_led(struct i40e_hw *hw, |
| 4566 | u32 time, u32 interval) |
| 4567 | { |
| 4568 | i40e_status status = 0; |
| 4569 | u32 i; |
| 4570 | u16 led_ctl; |
| 4571 | u16 gpio_led_port; |
| 4572 | u16 led_reg; |
| 4573 | u16 led_addr = I40E_PHY_LED_PROV_REG_1; |
| 4574 | u8 phy_addr = 0; |
| 4575 | u8 port_num; |
| 4576 | |
| 4577 | i = rd32(hw, I40E_PFGEN_PORTNUM); |
| 4578 | port_num = (u8)(i & I40E_PFGEN_PORTNUM_PORT_NUM_MASK); |
| 4579 | phy_addr = i40e_get_phy_address(hw, port_num); |
| 4580 | |
| 4581 | for (gpio_led_port = 0; gpio_led_port < 3; gpio_led_port++, |
| 4582 | led_addr++) { |
| 4583 | status = i40e_read_phy_register(hw, I40E_PHY_COM_REG_PAGE, |
| 4584 | led_addr, phy_addr, &led_reg); |
| 4585 | if (status) |
| 4586 | goto phy_blinking_end; |
| 4587 | led_ctl = led_reg; |
| 4588 | if (led_reg & I40E_PHY_LED_LINK_MODE_MASK) { |
| 4589 | led_reg = 0; |
| 4590 | status = i40e_write_phy_register(hw, |
| 4591 | I40E_PHY_COM_REG_PAGE, |
| 4592 | led_addr, phy_addr, |
| 4593 | led_reg); |
| 4594 | if (status) |
| 4595 | goto phy_blinking_end; |
| 4596 | break; |
| 4597 | } |
| 4598 | } |
| 4599 | |
| 4600 | if (time > 0 && interval > 0) { |
| 4601 | for (i = 0; i < time * 1000; i += interval) { |
| 4602 | status = i40e_read_phy_register(hw, |
| 4603 | I40E_PHY_COM_REG_PAGE, |
| 4604 | led_addr, phy_addr, |
| 4605 | &led_reg); |
| 4606 | if (status) |
| 4607 | goto restore_config; |
| 4608 | if (led_reg & I40E_PHY_LED_MANUAL_ON) |
| 4609 | led_reg = 0; |
| 4610 | else |
| 4611 | led_reg = I40E_PHY_LED_MANUAL_ON; |
| 4612 | status = i40e_write_phy_register(hw, |
| 4613 | I40E_PHY_COM_REG_PAGE, |
| 4614 | led_addr, phy_addr, |
| 4615 | led_reg); |
| 4616 | if (status) |
| 4617 | goto restore_config; |
| 4618 | msleep(interval); |
| 4619 | } |
| 4620 | } |
| 4621 | |
| 4622 | restore_config: |
| 4623 | status = i40e_write_phy_register(hw, I40E_PHY_COM_REG_PAGE, led_addr, |
| 4624 | phy_addr, led_ctl); |
| 4625 | |
| 4626 | phy_blinking_end: |
| 4627 | return status; |
| 4628 | } |
| 4629 | |
| 4630 | /** |
| 4631 | * i40e_led_get_phy - return current on/off mode |
| 4632 | * @hw: pointer to the hw struct |
| 4633 | * @led_addr: address of led register to use |
| 4634 | * @val: original value of register to use |
| 4635 | * |
| 4636 | **/ |
| 4637 | i40e_status i40e_led_get_phy(struct i40e_hw *hw, u16 *led_addr, |
| 4638 | u16 *val) |
| 4639 | { |
| 4640 | i40e_status status = 0; |
| 4641 | u16 gpio_led_port; |
| 4642 | u8 phy_addr = 0; |
| 4643 | u16 reg_val; |
| 4644 | u16 temp_addr; |
| 4645 | u8 port_num; |
| 4646 | u32 i; |
| 4647 | |
| 4648 | temp_addr = I40E_PHY_LED_PROV_REG_1; |
| 4649 | i = rd32(hw, I40E_PFGEN_PORTNUM); |
| 4650 | port_num = (u8)(i & I40E_PFGEN_PORTNUM_PORT_NUM_MASK); |
| 4651 | phy_addr = i40e_get_phy_address(hw, port_num); |
| 4652 | |
| 4653 | for (gpio_led_port = 0; gpio_led_port < 3; gpio_led_port++, |
| 4654 | temp_addr++) { |
| 4655 | status = i40e_read_phy_register(hw, I40E_PHY_COM_REG_PAGE, |
| 4656 | temp_addr, phy_addr, ®_val); |
| 4657 | if (status) |
| 4658 | return status; |
| 4659 | *val = reg_val; |
| 4660 | if (reg_val & I40E_PHY_LED_LINK_MODE_MASK) { |
| 4661 | *led_addr = temp_addr; |
| 4662 | break; |
| 4663 | } |
| 4664 | } |
| 4665 | return status; |
| 4666 | } |
| 4667 | |
| 4668 | /** |
| 4669 | * i40e_led_set_phy |
| 4670 | * @hw: pointer to the HW structure |
| 4671 | * @on: true or false |
| 4672 | * @mode: original val plus bit for set or ignore |
| 4673 | * Set led's on or off when controlled by the PHY |
| 4674 | * |
| 4675 | **/ |
| 4676 | i40e_status i40e_led_set_phy(struct i40e_hw *hw, bool on, |
| 4677 | u16 led_addr, u32 mode) |
| 4678 | { |
| 4679 | i40e_status status = 0; |
| 4680 | u16 led_ctl = 0; |
| 4681 | u16 led_reg = 0; |
| 4682 | u8 phy_addr = 0; |
| 4683 | u8 port_num; |
| 4684 | u32 i; |
| 4685 | |
| 4686 | i = rd32(hw, I40E_PFGEN_PORTNUM); |
| 4687 | port_num = (u8)(i & I40E_PFGEN_PORTNUM_PORT_NUM_MASK); |
| 4688 | phy_addr = i40e_get_phy_address(hw, port_num); |
| 4689 | |
| 4690 | status = i40e_read_phy_register(hw, I40E_PHY_COM_REG_PAGE, led_addr, |
| 4691 | phy_addr, &led_reg); |
| 4692 | if (status) |
| 4693 | return status; |
| 4694 | led_ctl = led_reg; |
| 4695 | if (led_reg & I40E_PHY_LED_LINK_MODE_MASK) { |
| 4696 | led_reg = 0; |
| 4697 | status = i40e_write_phy_register(hw, I40E_PHY_COM_REG_PAGE, |
| 4698 | led_addr, phy_addr, led_reg); |
| 4699 | if (status) |
| 4700 | return status; |
| 4701 | } |
| 4702 | status = i40e_read_phy_register(hw, I40E_PHY_COM_REG_PAGE, |
| 4703 | led_addr, phy_addr, &led_reg); |
| 4704 | if (status) |
| 4705 | goto restore_config; |
| 4706 | if (on) |
| 4707 | led_reg = I40E_PHY_LED_MANUAL_ON; |
| 4708 | else |
| 4709 | led_reg = 0; |
| 4710 | status = i40e_write_phy_register(hw, I40E_PHY_COM_REG_PAGE, |
| 4711 | led_addr, phy_addr, led_reg); |
| 4712 | if (status) |
| 4713 | goto restore_config; |
| 4714 | if (mode & I40E_PHY_LED_MODE_ORIG) { |
| 4715 | led_ctl = (mode & I40E_PHY_LED_MODE_MASK); |
| 4716 | status = i40e_write_phy_register(hw, |
| 4717 | I40E_PHY_COM_REG_PAGE, |
| 4718 | led_addr, phy_addr, led_ctl); |
| 4719 | } |
| 4720 | return status; |
| 4721 | restore_config: |
| 4722 | status = i40e_write_phy_register(hw, I40E_PHY_COM_REG_PAGE, led_addr, |
| 4723 | phy_addr, led_ctl); |
| 4724 | return status; |
| 4725 | } |
Shannon Nelson | f658137 | 2016-02-17 16:12:20 -0800 | [diff] [blame] | 4726 | |
| 4727 | /** |
| 4728 | * i40e_aq_rx_ctl_read_register - use FW to read from an Rx control register |
| 4729 | * @hw: pointer to the hw struct |
| 4730 | * @reg_addr: register address |
| 4731 | * @reg_val: ptr to register value |
| 4732 | * @cmd_details: pointer to command details structure or NULL |
| 4733 | * |
| 4734 | * Use the firmware to read the Rx control register, |
| 4735 | * especially useful if the Rx unit is under heavy pressure |
| 4736 | **/ |
| 4737 | i40e_status i40e_aq_rx_ctl_read_register(struct i40e_hw *hw, |
| 4738 | u32 reg_addr, u32 *reg_val, |
| 4739 | struct i40e_asq_cmd_details *cmd_details) |
| 4740 | { |
| 4741 | struct i40e_aq_desc desc; |
| 4742 | struct i40e_aqc_rx_ctl_reg_read_write *cmd_resp = |
| 4743 | (struct i40e_aqc_rx_ctl_reg_read_write *)&desc.params.raw; |
| 4744 | i40e_status status; |
| 4745 | |
| 4746 | if (!reg_val) |
| 4747 | return I40E_ERR_PARAM; |
| 4748 | |
| 4749 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_rx_ctl_reg_read); |
| 4750 | |
| 4751 | cmd_resp->address = cpu_to_le32(reg_addr); |
| 4752 | |
| 4753 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 4754 | |
| 4755 | if (status == 0) |
| 4756 | *reg_val = le32_to_cpu(cmd_resp->value); |
| 4757 | |
| 4758 | return status; |
| 4759 | } |
| 4760 | |
| 4761 | /** |
| 4762 | * i40e_read_rx_ctl - read from an Rx control register |
| 4763 | * @hw: pointer to the hw struct |
| 4764 | * @reg_addr: register address |
| 4765 | **/ |
| 4766 | u32 i40e_read_rx_ctl(struct i40e_hw *hw, u32 reg_addr) |
| 4767 | { |
| 4768 | i40e_status status = 0; |
| 4769 | bool use_register; |
| 4770 | int retry = 5; |
| 4771 | u32 val = 0; |
| 4772 | |
| 4773 | use_register = (hw->aq.api_maj_ver == 1) && (hw->aq.api_min_ver < 5); |
| 4774 | if (!use_register) { |
| 4775 | do_retry: |
| 4776 | status = i40e_aq_rx_ctl_read_register(hw, reg_addr, &val, NULL); |
| 4777 | if (hw->aq.asq_last_status == I40E_AQ_RC_EAGAIN && retry) { |
| 4778 | usleep_range(1000, 2000); |
| 4779 | retry--; |
| 4780 | goto do_retry; |
| 4781 | } |
| 4782 | } |
| 4783 | |
| 4784 | /* if the AQ access failed, try the old-fashioned way */ |
| 4785 | if (status || use_register) |
| 4786 | val = rd32(hw, reg_addr); |
| 4787 | |
| 4788 | return val; |
| 4789 | } |
| 4790 | |
| 4791 | /** |
| 4792 | * i40e_aq_rx_ctl_write_register |
| 4793 | * @hw: pointer to the hw struct |
| 4794 | * @reg_addr: register address |
| 4795 | * @reg_val: register value |
| 4796 | * @cmd_details: pointer to command details structure or NULL |
| 4797 | * |
| 4798 | * Use the firmware to write to an Rx control register, |
| 4799 | * especially useful if the Rx unit is under heavy pressure |
| 4800 | **/ |
| 4801 | i40e_status i40e_aq_rx_ctl_write_register(struct i40e_hw *hw, |
| 4802 | u32 reg_addr, u32 reg_val, |
| 4803 | struct i40e_asq_cmd_details *cmd_details) |
| 4804 | { |
| 4805 | struct i40e_aq_desc desc; |
| 4806 | struct i40e_aqc_rx_ctl_reg_read_write *cmd = |
| 4807 | (struct i40e_aqc_rx_ctl_reg_read_write *)&desc.params.raw; |
| 4808 | i40e_status status; |
| 4809 | |
| 4810 | i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_rx_ctl_reg_write); |
| 4811 | |
| 4812 | cmd->address = cpu_to_le32(reg_addr); |
| 4813 | cmd->value = cpu_to_le32(reg_val); |
| 4814 | |
| 4815 | status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); |
| 4816 | |
| 4817 | return status; |
| 4818 | } |
| 4819 | |
| 4820 | /** |
| 4821 | * i40e_write_rx_ctl - write to an Rx control register |
| 4822 | * @hw: pointer to the hw struct |
| 4823 | * @reg_addr: register address |
| 4824 | * @reg_val: register value |
| 4825 | **/ |
| 4826 | void i40e_write_rx_ctl(struct i40e_hw *hw, u32 reg_addr, u32 reg_val) |
| 4827 | { |
| 4828 | i40e_status status = 0; |
| 4829 | bool use_register; |
| 4830 | int retry = 5; |
| 4831 | |
| 4832 | use_register = (hw->aq.api_maj_ver == 1) && (hw->aq.api_min_ver < 5); |
| 4833 | if (!use_register) { |
| 4834 | do_retry: |
| 4835 | status = i40e_aq_rx_ctl_write_register(hw, reg_addr, |
| 4836 | reg_val, NULL); |
| 4837 | if (hw->aq.asq_last_status == I40E_AQ_RC_EAGAIN && retry) { |
| 4838 | usleep_range(1000, 2000); |
| 4839 | retry--; |
| 4840 | goto do_retry; |
| 4841 | } |
| 4842 | } |
| 4843 | |
| 4844 | /* if the AQ access failed, try the old-fashioned way */ |
| 4845 | if (status || use_register) |
| 4846 | wr32(hw, reg_addr, reg_val); |
| 4847 | } |