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