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