Commit | Line | Data |
---|---|---|
62683ab5 GR |
1 | /******************************************************************************* |
2 | * | |
3 | * Intel Ethernet Controller XL710 Family Linux Virtual Function Driver | |
ef8693eb | 4 | * Copyright(c) 2013 - 2014 Intel Corporation. |
62683ab5 GR |
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 | * | |
b831607d JB |
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/>. | |
17 | * | |
62683ab5 GR |
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 "i40evf.h" | |
28 | #include "i40e_prototype.h" | |
ed0e894d | 29 | #include "i40evf_client.h" |
62683ab5 GR |
30 | |
31 | /* busy wait delay in msec */ | |
32 | #define I40EVF_BUSY_WAIT_DELAY 10 | |
33 | #define I40EVF_BUSY_WAIT_COUNT 50 | |
34 | ||
35 | /** | |
36 | * i40evf_send_pf_msg | |
37 | * @adapter: adapter structure | |
38 | * @op: virtual channel opcode | |
39 | * @msg: pointer to message buffer | |
40 | * @len: message length | |
41 | * | |
42 | * Send message to PF and print status if failure. | |
43 | **/ | |
44 | static int i40evf_send_pf_msg(struct i40evf_adapter *adapter, | |
45 | enum i40e_virtchnl_ops op, u8 *msg, u16 len) | |
46 | { | |
47 | struct i40e_hw *hw = &adapter->hw; | |
48 | i40e_status err; | |
49 | ||
ef8693eb MW |
50 | if (adapter->flags & I40EVF_FLAG_PF_COMMS_FAILED) |
51 | return 0; /* nothing to see here, move along */ | |
52 | ||
62683ab5 GR |
53 | err = i40e_aq_send_msg_to_pf(hw, op, 0, msg, len, NULL); |
54 | if (err) | |
f1c7e72e SN |
55 | dev_err(&adapter->pdev->dev, "Unable to send opcode %d to PF, err %s, aq_err %s\n", |
56 | op, i40evf_stat_str(hw, err), | |
57 | i40evf_aq_str(hw, hw->aq.asq_last_status)); | |
62683ab5 GR |
58 | return err; |
59 | } | |
60 | ||
61 | /** | |
62 | * i40evf_send_api_ver | |
63 | * @adapter: adapter structure | |
64 | * | |
65 | * Send API version admin queue message to the PF. The reply is not checked | |
66 | * in this function. Returns 0 if the message was successfully | |
67 | * sent, or one of the I40E_ADMIN_QUEUE_ERROR_ statuses if not. | |
68 | **/ | |
69 | int i40evf_send_api_ver(struct i40evf_adapter *adapter) | |
70 | { | |
71 | struct i40e_virtchnl_version_info vvi; | |
72 | ||
73 | vvi.major = I40E_VIRTCHNL_VERSION_MAJOR; | |
74 | vvi.minor = I40E_VIRTCHNL_VERSION_MINOR; | |
75 | ||
76 | return i40evf_send_pf_msg(adapter, I40E_VIRTCHNL_OP_VERSION, (u8 *)&vvi, | |
77 | sizeof(vvi)); | |
78 | } | |
79 | ||
80 | /** | |
81 | * i40evf_verify_api_ver | |
82 | * @adapter: adapter structure | |
83 | * | |
84 | * Compare API versions with the PF. Must be called after admin queue is | |
6a8e93db MW |
85 | * initialized. Returns 0 if API versions match, -EIO if they do not, |
86 | * I40E_ERR_ADMIN_QUEUE_NO_WORK if the admin queue is empty, and any errors | |
87 | * from the firmware are propagated. | |
62683ab5 GR |
88 | **/ |
89 | int i40evf_verify_api_ver(struct i40evf_adapter *adapter) | |
90 | { | |
91 | struct i40e_virtchnl_version_info *pf_vvi; | |
92 | struct i40e_hw *hw = &adapter->hw; | |
93 | struct i40e_arq_event_info event; | |
f8d4db35 | 94 | enum i40e_virtchnl_ops op; |
62683ab5 GR |
95 | i40e_status err; |
96 | ||
1001dc37 MW |
97 | event.buf_len = I40EVF_MAX_AQ_BUF_SIZE; |
98 | event.msg_buf = kzalloc(event.buf_len, GFP_KERNEL); | |
62683ab5 GR |
99 | if (!event.msg_buf) { |
100 | err = -ENOMEM; | |
101 | goto out; | |
102 | } | |
103 | ||
f8d4db35 MW |
104 | while (1) { |
105 | err = i40evf_clean_arq_element(hw, &event, NULL); | |
106 | /* When the AQ is empty, i40evf_clean_arq_element will return | |
107 | * nonzero and this loop will terminate. | |
108 | */ | |
109 | if (err) | |
110 | goto out_alloc; | |
111 | op = | |
112 | (enum i40e_virtchnl_ops)le32_to_cpu(event.desc.cookie_high); | |
113 | if (op == I40E_VIRTCHNL_OP_VERSION) | |
114 | break; | |
115 | } | |
116 | ||
62683ab5 GR |
117 | |
118 | err = (i40e_status)le32_to_cpu(event.desc.cookie_low); | |
6a8e93db | 119 | if (err) |
62683ab5 | 120 | goto out_alloc; |
62683ab5 | 121 | |
f8d4db35 | 122 | if (op != I40E_VIRTCHNL_OP_VERSION) { |
6a8e93db | 123 | dev_info(&adapter->pdev->dev, "Invalid reply type %d from PF\n", |
f8d4db35 | 124 | op); |
62683ab5 GR |
125 | err = -EIO; |
126 | goto out_alloc; | |
127 | } | |
128 | ||
129 | pf_vvi = (struct i40e_virtchnl_version_info *)event.msg_buf; | |
ee1693e5 MW |
130 | adapter->pf_version = *pf_vvi; |
131 | ||
132 | if ((pf_vvi->major > I40E_VIRTCHNL_VERSION_MAJOR) || | |
133 | ((pf_vvi->major == I40E_VIRTCHNL_VERSION_MAJOR) && | |
134 | (pf_vvi->minor > I40E_VIRTCHNL_VERSION_MINOR))) | |
62683ab5 GR |
135 | err = -EIO; |
136 | ||
137 | out_alloc: | |
138 | kfree(event.msg_buf); | |
139 | out: | |
140 | return err; | |
141 | } | |
142 | ||
143 | /** | |
144 | * i40evf_send_vf_config_msg | |
145 | * @adapter: adapter structure | |
146 | * | |
147 | * Send VF configuration request admin queue message to the PF. The reply | |
148 | * is not checked in this function. Returns 0 if the message was | |
149 | * successfully sent, or one of the I40E_ADMIN_QUEUE_ERROR_ statuses if not. | |
150 | **/ | |
151 | int i40evf_send_vf_config_msg(struct i40evf_adapter *adapter) | |
152 | { | |
e6d038de MW |
153 | u32 caps; |
154 | ||
155 | adapter->current_op = I40E_VIRTCHNL_OP_GET_VF_RESOURCES; | |
156 | adapter->aq_required &= ~I40EVF_FLAG_AQ_GET_CONFIG; | |
157 | caps = I40E_VIRTCHNL_VF_OFFLOAD_L2 | | |
158 | I40E_VIRTCHNL_VF_OFFLOAD_RSS_AQ | | |
159 | I40E_VIRTCHNL_VF_OFFLOAD_RSS_REG | | |
1f012279 | 160 | I40E_VIRTCHNL_VF_OFFLOAD_VLAN | |
b9eacec3 ASJ |
161 | I40E_VIRTCHNL_VF_OFFLOAD_WB_ON_ITR | |
162 | I40E_VIRTCHNL_VF_OFFLOAD_RSS_PCTYPE_V2; | |
163 | ||
e6d038de MW |
164 | adapter->current_op = I40E_VIRTCHNL_OP_GET_VF_RESOURCES; |
165 | adapter->aq_required &= ~I40EVF_FLAG_AQ_GET_CONFIG; | |
166 | if (PF_IS_V11(adapter)) | |
167 | return i40evf_send_pf_msg(adapter, | |
168 | I40E_VIRTCHNL_OP_GET_VF_RESOURCES, | |
169 | (u8 *)&caps, sizeof(caps)); | |
170 | else | |
171 | return i40evf_send_pf_msg(adapter, | |
172 | I40E_VIRTCHNL_OP_GET_VF_RESOURCES, | |
173 | NULL, 0); | |
62683ab5 GR |
174 | } |
175 | ||
176 | /** | |
177 | * i40evf_get_vf_config | |
178 | * @hw: pointer to the hardware structure | |
179 | * @len: length of buffer | |
180 | * | |
181 | * Get VF configuration from PF and populate hw structure. Must be called after | |
182 | * admin queue is initialized. Busy waits until response is received from PF, | |
183 | * with maximum timeout. Response from PF is returned in the buffer for further | |
184 | * processing by the caller. | |
185 | **/ | |
186 | int i40evf_get_vf_config(struct i40evf_adapter *adapter) | |
187 | { | |
188 | struct i40e_hw *hw = &adapter->hw; | |
189 | struct i40e_arq_event_info event; | |
f8d4db35 | 190 | enum i40e_virtchnl_ops op; |
62683ab5 | 191 | i40e_status err; |
f8d4db35 | 192 | u16 len; |
62683ab5 GR |
193 | |
194 | len = sizeof(struct i40e_virtchnl_vf_resource) + | |
195 | I40E_MAX_VF_VSI * sizeof(struct i40e_virtchnl_vsi_resource); | |
1001dc37 MW |
196 | event.buf_len = len; |
197 | event.msg_buf = kzalloc(event.buf_len, GFP_KERNEL); | |
62683ab5 GR |
198 | if (!event.msg_buf) { |
199 | err = -ENOMEM; | |
200 | goto out; | |
201 | } | |
202 | ||
f8d4db35 | 203 | while (1) { |
f8d4db35 MW |
204 | /* When the AQ is empty, i40evf_clean_arq_element will return |
205 | * nonzero and this loop will terminate. | |
206 | */ | |
207 | err = i40evf_clean_arq_element(hw, &event, NULL); | |
208 | if (err) | |
209 | goto out_alloc; | |
210 | op = | |
211 | (enum i40e_virtchnl_ops)le32_to_cpu(event.desc.cookie_high); | |
212 | if (op == I40E_VIRTCHNL_OP_GET_VF_RESOURCES) | |
213 | break; | |
62683ab5 GR |
214 | } |
215 | ||
f8d4db35 | 216 | err = (i40e_status)le32_to_cpu(event.desc.cookie_low); |
1001dc37 | 217 | memcpy(adapter->vf_res, event.msg_buf, min(event.msg_len, len)); |
62683ab5 GR |
218 | |
219 | i40e_vf_parse_hw_config(hw, adapter->vf_res); | |
220 | out_alloc: | |
221 | kfree(event.msg_buf); | |
222 | out: | |
223 | return err; | |
224 | } | |
225 | ||
226 | /** | |
227 | * i40evf_configure_queues | |
228 | * @adapter: adapter structure | |
229 | * | |
230 | * Request that the PF set up our (previously allocated) queues. | |
231 | **/ | |
232 | void i40evf_configure_queues(struct i40evf_adapter *adapter) | |
233 | { | |
234 | struct i40e_virtchnl_vsi_queue_config_info *vqci; | |
235 | struct i40e_virtchnl_queue_pair_info *vqpi; | |
cc052927 | 236 | int pairs = adapter->num_active_queues; |
dab86afd | 237 | int i, len, max_frame = I40E_MAX_RXBUFFER; |
62683ab5 GR |
238 | |
239 | if (adapter->current_op != I40E_VIRTCHNL_OP_UNKNOWN) { | |
240 | /* bail because we already have a command pending */ | |
fb43201f SN |
241 | dev_err(&adapter->pdev->dev, "Cannot configure queues, command %d pending\n", |
242 | adapter->current_op); | |
62683ab5 GR |
243 | return; |
244 | } | |
245 | adapter->current_op = I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES; | |
246 | len = sizeof(struct i40e_virtchnl_vsi_queue_config_info) + | |
247 | (sizeof(struct i40e_virtchnl_queue_pair_info) * pairs); | |
a85088d8 | 248 | vqci = kzalloc(len, GFP_KERNEL); |
249c8b8d | 249 | if (!vqci) |
62683ab5 | 250 | return; |
249c8b8d | 251 | |
dab86afd AD |
252 | /* Limit maximum frame size when jumbo frames is not enabled */ |
253 | if (!(adapter->flags & I40EVF_FLAG_LEGACY_RX) && | |
254 | (adapter->netdev->mtu <= ETH_DATA_LEN)) | |
255 | max_frame = I40E_RXBUFFER_1536 - NET_IP_ALIGN; | |
256 | ||
62683ab5 GR |
257 | vqci->vsi_id = adapter->vsi_res->vsi_id; |
258 | vqci->num_queue_pairs = pairs; | |
259 | vqpi = vqci->qpair; | |
260 | /* Size check is not needed here - HW max is 16 queue pairs, and we | |
261 | * can fit info for 31 of them into the AQ buffer before it overflows. | |
262 | */ | |
263 | for (i = 0; i < pairs; i++) { | |
264 | vqpi->txq.vsi_id = vqci->vsi_id; | |
265 | vqpi->txq.queue_id = i; | |
0dd438d8 MW |
266 | vqpi->txq.ring_len = adapter->tx_rings[i].count; |
267 | vqpi->txq.dma_ring_addr = adapter->tx_rings[i].dma; | |
62683ab5 GR |
268 | vqpi->rxq.vsi_id = vqci->vsi_id; |
269 | vqpi->rxq.queue_id = i; | |
0dd438d8 MW |
270 | vqpi->rxq.ring_len = adapter->rx_rings[i].count; |
271 | vqpi->rxq.dma_ring_addr = adapter->rx_rings[i].dma; | |
dab86afd AD |
272 | vqpi->rxq.max_pkt_size = max_frame; |
273 | vqpi->rxq.databuffer_size = | |
274 | ALIGN(adapter->rx_rings[i].rx_buf_len, | |
275 | BIT_ULL(I40E_RXQ_CTX_DBUFF_SHIFT)); | |
62683ab5 GR |
276 | vqpi++; |
277 | } | |
278 | ||
fc86a970 | 279 | adapter->aq_required &= ~I40EVF_FLAG_AQ_CONFIGURE_QUEUES; |
62683ab5 GR |
280 | i40evf_send_pf_msg(adapter, I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES, |
281 | (u8 *)vqci, len); | |
282 | kfree(vqci); | |
62683ab5 GR |
283 | } |
284 | ||
285 | /** | |
286 | * i40evf_enable_queues | |
287 | * @adapter: adapter structure | |
288 | * | |
289 | * Request that the PF enable all of our queues. | |
290 | **/ | |
291 | void i40evf_enable_queues(struct i40evf_adapter *adapter) | |
292 | { | |
293 | struct i40e_virtchnl_queue_select vqs; | |
294 | ||
295 | if (adapter->current_op != I40E_VIRTCHNL_OP_UNKNOWN) { | |
296 | /* bail because we already have a command pending */ | |
fb43201f SN |
297 | dev_err(&adapter->pdev->dev, "Cannot enable queues, command %d pending\n", |
298 | adapter->current_op); | |
62683ab5 GR |
299 | return; |
300 | } | |
301 | adapter->current_op = I40E_VIRTCHNL_OP_ENABLE_QUEUES; | |
302 | vqs.vsi_id = adapter->vsi_res->vsi_id; | |
41a1d04b | 303 | vqs.tx_queues = BIT(adapter->num_active_queues) - 1; |
62683ab5 | 304 | vqs.rx_queues = vqs.tx_queues; |
62683ab5 | 305 | adapter->aq_required &= ~I40EVF_FLAG_AQ_ENABLE_QUEUES; |
fc86a970 MW |
306 | i40evf_send_pf_msg(adapter, I40E_VIRTCHNL_OP_ENABLE_QUEUES, |
307 | (u8 *)&vqs, sizeof(vqs)); | |
62683ab5 GR |
308 | } |
309 | ||
310 | /** | |
311 | * i40evf_disable_queues | |
312 | * @adapter: adapter structure | |
313 | * | |
314 | * Request that the PF disable all of our queues. | |
315 | **/ | |
316 | void i40evf_disable_queues(struct i40evf_adapter *adapter) | |
317 | { | |
318 | struct i40e_virtchnl_queue_select vqs; | |
319 | ||
320 | if (adapter->current_op != I40E_VIRTCHNL_OP_UNKNOWN) { | |
321 | /* bail because we already have a command pending */ | |
fb43201f SN |
322 | dev_err(&adapter->pdev->dev, "Cannot disable queues, command %d pending\n", |
323 | adapter->current_op); | |
62683ab5 GR |
324 | return; |
325 | } | |
326 | adapter->current_op = I40E_VIRTCHNL_OP_DISABLE_QUEUES; | |
327 | vqs.vsi_id = adapter->vsi_res->vsi_id; | |
41a1d04b | 328 | vqs.tx_queues = BIT(adapter->num_active_queues) - 1; |
62683ab5 | 329 | vqs.rx_queues = vqs.tx_queues; |
62683ab5 | 330 | adapter->aq_required &= ~I40EVF_FLAG_AQ_DISABLE_QUEUES; |
fc86a970 MW |
331 | i40evf_send_pf_msg(adapter, I40E_VIRTCHNL_OP_DISABLE_QUEUES, |
332 | (u8 *)&vqs, sizeof(vqs)); | |
62683ab5 GR |
333 | } |
334 | ||
335 | /** | |
336 | * i40evf_map_queues | |
337 | * @adapter: adapter structure | |
338 | * | |
339 | * Request that the PF map queues to interrupt vectors. Misc causes, including | |
340 | * admin queue, are always mapped to vector 0. | |
341 | **/ | |
342 | void i40evf_map_queues(struct i40evf_adapter *adapter) | |
343 | { | |
344 | struct i40e_virtchnl_irq_map_info *vimi; | |
345 | int v_idx, q_vectors, len; | |
346 | struct i40e_q_vector *q_vector; | |
347 | ||
348 | if (adapter->current_op != I40E_VIRTCHNL_OP_UNKNOWN) { | |
349 | /* bail because we already have a command pending */ | |
fb43201f SN |
350 | dev_err(&adapter->pdev->dev, "Cannot map queues to vectors, command %d pending\n", |
351 | adapter->current_op); | |
62683ab5 GR |
352 | return; |
353 | } | |
354 | adapter->current_op = I40E_VIRTCHNL_OP_CONFIG_IRQ_MAP; | |
355 | ||
356 | q_vectors = adapter->num_msix_vectors - NONQ_VECS; | |
357 | ||
358 | len = sizeof(struct i40e_virtchnl_irq_map_info) + | |
359 | (adapter->num_msix_vectors * | |
360 | sizeof(struct i40e_virtchnl_vector_map)); | |
a85088d8 | 361 | vimi = kzalloc(len, GFP_KERNEL); |
249c8b8d | 362 | if (!vimi) |
62683ab5 | 363 | return; |
62683ab5 GR |
364 | |
365 | vimi->num_vectors = adapter->num_msix_vectors; | |
366 | /* Queue vectors first */ | |
367 | for (v_idx = 0; v_idx < q_vectors; v_idx++) { | |
7d96ba1a | 368 | q_vector = adapter->q_vectors + v_idx; |
62683ab5 GR |
369 | vimi->vecmap[v_idx].vsi_id = adapter->vsi_res->vsi_id; |
370 | vimi->vecmap[v_idx].vector_id = v_idx + NONQ_VECS; | |
371 | vimi->vecmap[v_idx].txq_map = q_vector->ring_mask; | |
372 | vimi->vecmap[v_idx].rxq_map = q_vector->ring_mask; | |
373 | } | |
374 | /* Misc vector last - this is only for AdminQ messages */ | |
375 | vimi->vecmap[v_idx].vsi_id = adapter->vsi_res->vsi_id; | |
376 | vimi->vecmap[v_idx].vector_id = 0; | |
377 | vimi->vecmap[v_idx].txq_map = 0; | |
378 | vimi->vecmap[v_idx].rxq_map = 0; | |
379 | ||
fc86a970 | 380 | adapter->aq_required &= ~I40EVF_FLAG_AQ_MAP_VECTORS; |
62683ab5 GR |
381 | i40evf_send_pf_msg(adapter, I40E_VIRTCHNL_OP_CONFIG_IRQ_MAP, |
382 | (u8 *)vimi, len); | |
383 | kfree(vimi); | |
62683ab5 GR |
384 | } |
385 | ||
386 | /** | |
387 | * i40evf_add_ether_addrs | |
388 | * @adapter: adapter structure | |
389 | * @addrs: the MAC address filters to add (contiguous) | |
390 | * @count: number of filters | |
391 | * | |
392 | * Request that the PF add one or more addresses to our filters. | |
393 | **/ | |
394 | void i40evf_add_ether_addrs(struct i40evf_adapter *adapter) | |
395 | { | |
396 | struct i40e_virtchnl_ether_addr_list *veal; | |
397 | int len, i = 0, count = 0; | |
398 | struct i40evf_mac_filter *f; | |
1418c345 | 399 | bool more = false; |
62683ab5 GR |
400 | |
401 | if (adapter->current_op != I40E_VIRTCHNL_OP_UNKNOWN) { | |
402 | /* bail because we already have a command pending */ | |
fb43201f SN |
403 | dev_err(&adapter->pdev->dev, "Cannot add filters, command %d pending\n", |
404 | adapter->current_op); | |
62683ab5 GR |
405 | return; |
406 | } | |
407 | list_for_each_entry(f, &adapter->mac_filter_list, list) { | |
408 | if (f->add) | |
409 | count++; | |
410 | } | |
411 | if (!count) { | |
412 | adapter->aq_required &= ~I40EVF_FLAG_AQ_ADD_MAC_FILTER; | |
413 | return; | |
414 | } | |
415 | adapter->current_op = I40E_VIRTCHNL_OP_ADD_ETHER_ADDRESS; | |
416 | ||
417 | len = sizeof(struct i40e_virtchnl_ether_addr_list) + | |
418 | (count * sizeof(struct i40e_virtchnl_ether_addr)); | |
419 | if (len > I40EVF_MAX_AQ_BUF_SIZE) { | |
fb43201f | 420 | dev_warn(&adapter->pdev->dev, "Too many add MAC changes in one request\n"); |
62683ab5 GR |
421 | count = (I40EVF_MAX_AQ_BUF_SIZE - |
422 | sizeof(struct i40e_virtchnl_ether_addr_list)) / | |
423 | sizeof(struct i40e_virtchnl_ether_addr); | |
1418c345 MW |
424 | len = sizeof(struct i40e_virtchnl_ether_addr_list) + |
425 | (count * sizeof(struct i40e_virtchnl_ether_addr)); | |
426 | more = true; | |
62683ab5 GR |
427 | } |
428 | ||
a85088d8 | 429 | veal = kzalloc(len, GFP_KERNEL); |
249c8b8d | 430 | if (!veal) |
62683ab5 | 431 | return; |
249c8b8d | 432 | |
62683ab5 GR |
433 | veal->vsi_id = adapter->vsi_res->vsi_id; |
434 | veal->num_elements = count; | |
435 | list_for_each_entry(f, &adapter->mac_filter_list, list) { | |
436 | if (f->add) { | |
9a173901 | 437 | ether_addr_copy(veal->list[i].addr, f->macaddr); |
62683ab5 GR |
438 | i++; |
439 | f->add = false; | |
0e8d95f8 MW |
440 | if (i == count) |
441 | break; | |
62683ab5 GR |
442 | } |
443 | } | |
1418c345 MW |
444 | if (!more) |
445 | adapter->aq_required &= ~I40EVF_FLAG_AQ_ADD_MAC_FILTER; | |
62683ab5 GR |
446 | i40evf_send_pf_msg(adapter, I40E_VIRTCHNL_OP_ADD_ETHER_ADDRESS, |
447 | (u8 *)veal, len); | |
448 | kfree(veal); | |
62683ab5 GR |
449 | } |
450 | ||
451 | /** | |
452 | * i40evf_del_ether_addrs | |
453 | * @adapter: adapter structure | |
454 | * @addrs: the MAC address filters to remove (contiguous) | |
455 | * @count: number of filtes | |
456 | * | |
457 | * Request that the PF remove one or more addresses from our filters. | |
458 | **/ | |
459 | void i40evf_del_ether_addrs(struct i40evf_adapter *adapter) | |
460 | { | |
461 | struct i40e_virtchnl_ether_addr_list *veal; | |
462 | struct i40evf_mac_filter *f, *ftmp; | |
463 | int len, i = 0, count = 0; | |
1418c345 | 464 | bool more = false; |
62683ab5 GR |
465 | |
466 | if (adapter->current_op != I40E_VIRTCHNL_OP_UNKNOWN) { | |
467 | /* bail because we already have a command pending */ | |
fb43201f SN |
468 | dev_err(&adapter->pdev->dev, "Cannot remove filters, command %d pending\n", |
469 | adapter->current_op); | |
62683ab5 GR |
470 | return; |
471 | } | |
472 | list_for_each_entry(f, &adapter->mac_filter_list, list) { | |
473 | if (f->remove) | |
474 | count++; | |
475 | } | |
476 | if (!count) { | |
477 | adapter->aq_required &= ~I40EVF_FLAG_AQ_DEL_MAC_FILTER; | |
478 | return; | |
479 | } | |
480 | adapter->current_op = I40E_VIRTCHNL_OP_DEL_ETHER_ADDRESS; | |
481 | ||
482 | len = sizeof(struct i40e_virtchnl_ether_addr_list) + | |
483 | (count * sizeof(struct i40e_virtchnl_ether_addr)); | |
484 | if (len > I40EVF_MAX_AQ_BUF_SIZE) { | |
fb43201f | 485 | dev_warn(&adapter->pdev->dev, "Too many delete MAC changes in one request\n"); |
62683ab5 GR |
486 | count = (I40EVF_MAX_AQ_BUF_SIZE - |
487 | sizeof(struct i40e_virtchnl_ether_addr_list)) / | |
488 | sizeof(struct i40e_virtchnl_ether_addr); | |
1418c345 MW |
489 | len = sizeof(struct i40e_virtchnl_ether_addr_list) + |
490 | (count * sizeof(struct i40e_virtchnl_ether_addr)); | |
491 | more = true; | |
62683ab5 | 492 | } |
a85088d8 | 493 | veal = kzalloc(len, GFP_KERNEL); |
249c8b8d | 494 | if (!veal) |
62683ab5 | 495 | return; |
249c8b8d | 496 | |
62683ab5 GR |
497 | veal->vsi_id = adapter->vsi_res->vsi_id; |
498 | veal->num_elements = count; | |
499 | list_for_each_entry_safe(f, ftmp, &adapter->mac_filter_list, list) { | |
500 | if (f->remove) { | |
9a173901 | 501 | ether_addr_copy(veal->list[i].addr, f->macaddr); |
62683ab5 GR |
502 | i++; |
503 | list_del(&f->list); | |
504 | kfree(f); | |
0e8d95f8 MW |
505 | if (i == count) |
506 | break; | |
62683ab5 GR |
507 | } |
508 | } | |
1418c345 MW |
509 | if (!more) |
510 | adapter->aq_required &= ~I40EVF_FLAG_AQ_DEL_MAC_FILTER; | |
62683ab5 GR |
511 | i40evf_send_pf_msg(adapter, I40E_VIRTCHNL_OP_DEL_ETHER_ADDRESS, |
512 | (u8 *)veal, len); | |
513 | kfree(veal); | |
62683ab5 GR |
514 | } |
515 | ||
516 | /** | |
517 | * i40evf_add_vlans | |
518 | * @adapter: adapter structure | |
519 | * @vlans: the VLANs to add | |
520 | * @count: number of VLANs | |
521 | * | |
522 | * Request that the PF add one or more VLAN filters to our VSI. | |
523 | **/ | |
524 | void i40evf_add_vlans(struct i40evf_adapter *adapter) | |
525 | { | |
526 | struct i40e_virtchnl_vlan_filter_list *vvfl; | |
527 | int len, i = 0, count = 0; | |
528 | struct i40evf_vlan_filter *f; | |
1418c345 | 529 | bool more = false; |
62683ab5 GR |
530 | |
531 | if (adapter->current_op != I40E_VIRTCHNL_OP_UNKNOWN) { | |
532 | /* bail because we already have a command pending */ | |
fb43201f SN |
533 | dev_err(&adapter->pdev->dev, "Cannot add VLANs, command %d pending\n", |
534 | adapter->current_op); | |
62683ab5 GR |
535 | return; |
536 | } | |
537 | ||
538 | list_for_each_entry(f, &adapter->vlan_filter_list, list) { | |
539 | if (f->add) | |
540 | count++; | |
541 | } | |
542 | if (!count) { | |
543 | adapter->aq_required &= ~I40EVF_FLAG_AQ_ADD_VLAN_FILTER; | |
544 | return; | |
545 | } | |
546 | adapter->current_op = I40E_VIRTCHNL_OP_ADD_VLAN; | |
547 | ||
548 | len = sizeof(struct i40e_virtchnl_vlan_filter_list) + | |
549 | (count * sizeof(u16)); | |
550 | if (len > I40EVF_MAX_AQ_BUF_SIZE) { | |
fb43201f | 551 | dev_warn(&adapter->pdev->dev, "Too many add VLAN changes in one request\n"); |
62683ab5 GR |
552 | count = (I40EVF_MAX_AQ_BUF_SIZE - |
553 | sizeof(struct i40e_virtchnl_vlan_filter_list)) / | |
554 | sizeof(u16); | |
1418c345 MW |
555 | len = sizeof(struct i40e_virtchnl_vlan_filter_list) + |
556 | (count * sizeof(u16)); | |
557 | more = true; | |
62683ab5 | 558 | } |
a85088d8 | 559 | vvfl = kzalloc(len, GFP_KERNEL); |
249c8b8d | 560 | if (!vvfl) |
62683ab5 | 561 | return; |
249c8b8d | 562 | |
62683ab5 GR |
563 | vvfl->vsi_id = adapter->vsi_res->vsi_id; |
564 | vvfl->num_elements = count; | |
565 | list_for_each_entry(f, &adapter->vlan_filter_list, list) { | |
566 | if (f->add) { | |
567 | vvfl->vlan_id[i] = f->vlan; | |
568 | i++; | |
569 | f->add = false; | |
0e8d95f8 MW |
570 | if (i == count) |
571 | break; | |
62683ab5 GR |
572 | } |
573 | } | |
1418c345 MW |
574 | if (!more) |
575 | adapter->aq_required &= ~I40EVF_FLAG_AQ_ADD_VLAN_FILTER; | |
fc86a970 MW |
576 | i40evf_send_pf_msg(adapter, I40E_VIRTCHNL_OP_ADD_VLAN, (u8 *)vvfl, len); |
577 | kfree(vvfl); | |
62683ab5 GR |
578 | } |
579 | ||
580 | /** | |
581 | * i40evf_del_vlans | |
582 | * @adapter: adapter structure | |
583 | * @vlans: the VLANs to remove | |
584 | * @count: number of VLANs | |
585 | * | |
586 | * Request that the PF remove one or more VLAN filters from our VSI. | |
587 | **/ | |
588 | void i40evf_del_vlans(struct i40evf_adapter *adapter) | |
589 | { | |
590 | struct i40e_virtchnl_vlan_filter_list *vvfl; | |
591 | struct i40evf_vlan_filter *f, *ftmp; | |
592 | int len, i = 0, count = 0; | |
1418c345 | 593 | bool more = false; |
62683ab5 GR |
594 | |
595 | if (adapter->current_op != I40E_VIRTCHNL_OP_UNKNOWN) { | |
596 | /* bail because we already have a command pending */ | |
fb43201f SN |
597 | dev_err(&adapter->pdev->dev, "Cannot remove VLANs, command %d pending\n", |
598 | adapter->current_op); | |
62683ab5 GR |
599 | return; |
600 | } | |
601 | ||
602 | list_for_each_entry(f, &adapter->vlan_filter_list, list) { | |
603 | if (f->remove) | |
604 | count++; | |
605 | } | |
606 | if (!count) { | |
607 | adapter->aq_required &= ~I40EVF_FLAG_AQ_DEL_VLAN_FILTER; | |
608 | return; | |
609 | } | |
610 | adapter->current_op = I40E_VIRTCHNL_OP_DEL_VLAN; | |
611 | ||
612 | len = sizeof(struct i40e_virtchnl_vlan_filter_list) + | |
613 | (count * sizeof(u16)); | |
614 | if (len > I40EVF_MAX_AQ_BUF_SIZE) { | |
fb43201f | 615 | dev_warn(&adapter->pdev->dev, "Too many delete VLAN changes in one request\n"); |
62683ab5 GR |
616 | count = (I40EVF_MAX_AQ_BUF_SIZE - |
617 | sizeof(struct i40e_virtchnl_vlan_filter_list)) / | |
618 | sizeof(u16); | |
1418c345 MW |
619 | len = sizeof(struct i40e_virtchnl_vlan_filter_list) + |
620 | (count * sizeof(u16)); | |
621 | more = true; | |
62683ab5 | 622 | } |
a85088d8 | 623 | vvfl = kzalloc(len, GFP_KERNEL); |
249c8b8d | 624 | if (!vvfl) |
62683ab5 | 625 | return; |
249c8b8d | 626 | |
62683ab5 GR |
627 | vvfl->vsi_id = adapter->vsi_res->vsi_id; |
628 | vvfl->num_elements = count; | |
629 | list_for_each_entry_safe(f, ftmp, &adapter->vlan_filter_list, list) { | |
630 | if (f->remove) { | |
631 | vvfl->vlan_id[i] = f->vlan; | |
632 | i++; | |
633 | list_del(&f->list); | |
634 | kfree(f); | |
0e8d95f8 MW |
635 | if (i == count) |
636 | break; | |
62683ab5 GR |
637 | } |
638 | } | |
1418c345 MW |
639 | if (!more) |
640 | adapter->aq_required &= ~I40EVF_FLAG_AQ_DEL_VLAN_FILTER; | |
fc86a970 MW |
641 | i40evf_send_pf_msg(adapter, I40E_VIRTCHNL_OP_DEL_VLAN, (u8 *)vvfl, len); |
642 | kfree(vvfl); | |
62683ab5 GR |
643 | } |
644 | ||
645 | /** | |
646 | * i40evf_set_promiscuous | |
647 | * @adapter: adapter structure | |
648 | * @flags: bitmask to control unicast/multicast promiscuous. | |
649 | * | |
650 | * Request that the PF enable promiscuous mode for our VSI. | |
651 | **/ | |
652 | void i40evf_set_promiscuous(struct i40evf_adapter *adapter, int flags) | |
653 | { | |
654 | struct i40e_virtchnl_promisc_info vpi; | |
f42a5c74 | 655 | int promisc_all; |
62683ab5 GR |
656 | |
657 | if (adapter->current_op != I40E_VIRTCHNL_OP_UNKNOWN) { | |
658 | /* bail because we already have a command pending */ | |
fb43201f SN |
659 | dev_err(&adapter->pdev->dev, "Cannot set promiscuous mode, command %d pending\n", |
660 | adapter->current_op); | |
62683ab5 GR |
661 | return; |
662 | } | |
47d34839 | 663 | |
f42a5c74 ASJ |
664 | promisc_all = I40E_FLAG_VF_UNICAST_PROMISC | |
665 | I40E_FLAG_VF_MULTICAST_PROMISC; | |
666 | if ((flags & promisc_all) == promisc_all) { | |
47d34839 ASJ |
667 | adapter->flags |= I40EVF_FLAG_PROMISC_ON; |
668 | adapter->aq_required &= ~I40EVF_FLAG_AQ_REQUEST_PROMISC; | |
669 | dev_info(&adapter->pdev->dev, "Entering promiscuous mode\n"); | |
f42a5c74 ASJ |
670 | } |
671 | ||
672 | if (flags & I40E_FLAG_VF_MULTICAST_PROMISC) { | |
673 | adapter->flags |= I40EVF_FLAG_ALLMULTI_ON; | |
674 | adapter->aq_required &= ~I40EVF_FLAG_AQ_REQUEST_ALLMULTI; | |
675 | dev_info(&adapter->pdev->dev, "Entering multicast promiscuous mode\n"); | |
676 | } | |
677 | ||
678 | if (!flags) { | |
47d34839 ASJ |
679 | adapter->flags &= ~I40EVF_FLAG_PROMISC_ON; |
680 | adapter->aq_required &= ~I40EVF_FLAG_AQ_RELEASE_PROMISC; | |
681 | dev_info(&adapter->pdev->dev, "Leaving promiscuous mode\n"); | |
682 | } | |
683 | ||
62683ab5 GR |
684 | adapter->current_op = I40E_VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE; |
685 | vpi.vsi_id = adapter->vsi_res->vsi_id; | |
686 | vpi.flags = flags; | |
687 | i40evf_send_pf_msg(adapter, I40E_VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE, | |
688 | (u8 *)&vpi, sizeof(vpi)); | |
689 | } | |
690 | ||
691 | /** | |
692 | * i40evf_request_stats | |
693 | * @adapter: adapter structure | |
694 | * | |
695 | * Request VSI statistics from PF. | |
696 | **/ | |
697 | void i40evf_request_stats(struct i40evf_adapter *adapter) | |
698 | { | |
699 | struct i40e_virtchnl_queue_select vqs; | |
75a64435 | 700 | |
62683ab5 GR |
701 | if (adapter->current_op != I40E_VIRTCHNL_OP_UNKNOWN) { |
702 | /* no error message, this isn't crucial */ | |
703 | return; | |
704 | } | |
705 | adapter->current_op = I40E_VIRTCHNL_OP_GET_STATS; | |
706 | vqs.vsi_id = adapter->vsi_res->vsi_id; | |
707 | /* queue maps are ignored for this message - only the vsi is used */ | |
708 | if (i40evf_send_pf_msg(adapter, I40E_VIRTCHNL_OP_GET_STATS, | |
709 | (u8 *)&vqs, sizeof(vqs))) | |
710 | /* if the request failed, don't lock out others */ | |
711 | adapter->current_op = I40E_VIRTCHNL_OP_UNKNOWN; | |
712 | } | |
43a3d9ba MW |
713 | |
714 | /** | |
715 | * i40evf_get_hena | |
716 | * @adapter: adapter structure | |
717 | * | |
718 | * Request hash enable capabilities from PF | |
719 | **/ | |
720 | void i40evf_get_hena(struct i40evf_adapter *adapter) | |
721 | { | |
722 | if (adapter->current_op != I40E_VIRTCHNL_OP_UNKNOWN) { | |
723 | /* bail because we already have a command pending */ | |
724 | dev_err(&adapter->pdev->dev, "Cannot get RSS hash capabilities, command %d pending\n", | |
725 | adapter->current_op); | |
726 | return; | |
727 | } | |
728 | adapter->current_op = I40E_VIRTCHNL_OP_GET_RSS_HENA_CAPS; | |
729 | adapter->aq_required &= ~I40EVF_FLAG_AQ_GET_HENA; | |
730 | i40evf_send_pf_msg(adapter, I40E_VIRTCHNL_OP_GET_RSS_HENA_CAPS, | |
731 | NULL, 0); | |
732 | } | |
733 | ||
734 | /** | |
735 | * i40evf_set_hena | |
736 | * @adapter: adapter structure | |
737 | * | |
738 | * Request the PF to set our RSS hash capabilities | |
739 | **/ | |
740 | void i40evf_set_hena(struct i40evf_adapter *adapter) | |
741 | { | |
742 | struct i40e_virtchnl_rss_hena vrh; | |
743 | ||
744 | if (adapter->current_op != I40E_VIRTCHNL_OP_UNKNOWN) { | |
745 | /* bail because we already have a command pending */ | |
746 | dev_err(&adapter->pdev->dev, "Cannot set RSS hash enable, command %d pending\n", | |
747 | adapter->current_op); | |
748 | return; | |
749 | } | |
750 | vrh.hena = adapter->hena; | |
751 | adapter->current_op = I40E_VIRTCHNL_OP_SET_RSS_HENA; | |
752 | adapter->aq_required &= ~I40EVF_FLAG_AQ_SET_HENA; | |
753 | i40evf_send_pf_msg(adapter, I40E_VIRTCHNL_OP_SET_RSS_HENA, | |
754 | (u8 *)&vrh, sizeof(vrh)); | |
755 | } | |
756 | ||
757 | /** | |
758 | * i40evf_set_rss_key | |
759 | * @adapter: adapter structure | |
760 | * | |
761 | * Request the PF to set our RSS hash key | |
762 | **/ | |
763 | void i40evf_set_rss_key(struct i40evf_adapter *adapter) | |
764 | { | |
765 | struct i40e_virtchnl_rss_key *vrk; | |
766 | int len; | |
767 | ||
768 | if (adapter->current_op != I40E_VIRTCHNL_OP_UNKNOWN) { | |
769 | /* bail because we already have a command pending */ | |
770 | dev_err(&adapter->pdev->dev, "Cannot set RSS key, command %d pending\n", | |
771 | adapter->current_op); | |
772 | return; | |
773 | } | |
774 | len = sizeof(struct i40e_virtchnl_rss_key) + | |
775 | (adapter->rss_key_size * sizeof(u8)) - 1; | |
776 | vrk = kzalloc(len, GFP_KERNEL); | |
777 | if (!vrk) | |
778 | return; | |
779 | vrk->vsi_id = adapter->vsi.id; | |
780 | vrk->key_len = adapter->rss_key_size; | |
781 | memcpy(vrk->key, adapter->rss_key, adapter->rss_key_size); | |
782 | ||
783 | adapter->current_op = I40E_VIRTCHNL_OP_CONFIG_RSS_KEY; | |
784 | adapter->aq_required &= ~I40EVF_FLAG_AQ_SET_RSS_KEY; | |
785 | i40evf_send_pf_msg(adapter, I40E_VIRTCHNL_OP_CONFIG_RSS_KEY, | |
786 | (u8 *)vrk, len); | |
787 | kfree(vrk); | |
788 | } | |
789 | ||
790 | /** | |
791 | * i40evf_set_rss_lut | |
792 | * @adapter: adapter structure | |
793 | * | |
794 | * Request the PF to set our RSS lookup table | |
795 | **/ | |
796 | void i40evf_set_rss_lut(struct i40evf_adapter *adapter) | |
797 | { | |
798 | struct i40e_virtchnl_rss_lut *vrl; | |
799 | int len; | |
800 | ||
801 | if (adapter->current_op != I40E_VIRTCHNL_OP_UNKNOWN) { | |
802 | /* bail because we already have a command pending */ | |
803 | dev_err(&adapter->pdev->dev, "Cannot set RSS LUT, command %d pending\n", | |
804 | adapter->current_op); | |
805 | return; | |
806 | } | |
807 | len = sizeof(struct i40e_virtchnl_rss_lut) + | |
808 | (adapter->rss_lut_size * sizeof(u8)) - 1; | |
809 | vrl = kzalloc(len, GFP_KERNEL); | |
810 | if (!vrl) | |
811 | return; | |
812 | vrl->vsi_id = adapter->vsi.id; | |
813 | vrl->lut_entries = adapter->rss_lut_size; | |
814 | memcpy(vrl->lut, adapter->rss_lut, adapter->rss_lut_size); | |
815 | adapter->current_op = I40E_VIRTCHNL_OP_CONFIG_RSS_LUT; | |
816 | adapter->aq_required &= ~I40EVF_FLAG_AQ_SET_RSS_LUT; | |
817 | i40evf_send_pf_msg(adapter, I40E_VIRTCHNL_OP_CONFIG_RSS_LUT, | |
818 | (u8 *)vrl, len); | |
819 | kfree(vrl); | |
820 | } | |
821 | ||
fe458e50 MW |
822 | /** |
823 | * i40evf_print_link_message - print link up or down | |
824 | * @adapter: adapter structure | |
825 | * | |
826 | * Log a message telling the world of our wonderous link status | |
827 | */ | |
828 | static void i40evf_print_link_message(struct i40evf_adapter *adapter) | |
829 | { | |
830 | struct net_device *netdev = adapter->netdev; | |
831 | char *speed = "Unknown "; | |
832 | ||
833 | if (!adapter->link_up) { | |
834 | netdev_info(netdev, "NIC Link is Down\n"); | |
835 | return; | |
836 | } | |
837 | ||
838 | switch (adapter->link_speed) { | |
839 | case I40E_LINK_SPEED_40GB: | |
840 | speed = "40 G"; | |
841 | break; | |
3123237a CW |
842 | case I40E_LINK_SPEED_25GB: |
843 | speed = "25 G"; | |
844 | break; | |
fe458e50 MW |
845 | case I40E_LINK_SPEED_20GB: |
846 | speed = "20 G"; | |
847 | break; | |
848 | case I40E_LINK_SPEED_10GB: | |
849 | speed = "10 G"; | |
850 | break; | |
851 | case I40E_LINK_SPEED_1GB: | |
852 | speed = "1000 M"; | |
853 | break; | |
854 | case I40E_LINK_SPEED_100MB: | |
855 | speed = "100 M"; | |
856 | break; | |
857 | default: | |
858 | break; | |
859 | } | |
860 | ||
861 | netdev_info(netdev, "NIC Link is Up %sbps Full Duplex\n", speed); | |
862 | } | |
863 | ||
625777e3 MW |
864 | /** |
865 | * i40evf_request_reset | |
866 | * @adapter: adapter structure | |
867 | * | |
868 | * Request that the PF reset this VF. No response is expected. | |
869 | **/ | |
870 | void i40evf_request_reset(struct i40evf_adapter *adapter) | |
871 | { | |
872 | /* Don't check CURRENT_OP - this is always higher priority */ | |
873 | i40evf_send_pf_msg(adapter, I40E_VIRTCHNL_OP_RESET_VF, NULL, 0); | |
874 | adapter->current_op = I40E_VIRTCHNL_OP_UNKNOWN; | |
875 | } | |
62683ab5 GR |
876 | |
877 | /** | |
878 | * i40evf_virtchnl_completion | |
879 | * @adapter: adapter structure | |
880 | * @v_opcode: opcode sent by PF | |
881 | * @v_retval: retval sent by PF | |
882 | * @msg: message sent by PF | |
883 | * @msglen: message length | |
884 | * | |
885 | * Asynchronous completion function for admin queue messages. Rather than busy | |
886 | * wait, we fire off our requests and assume that no errors will be returned. | |
887 | * This function handles the reply messages. | |
888 | **/ | |
889 | void i40evf_virtchnl_completion(struct i40evf_adapter *adapter, | |
890 | enum i40e_virtchnl_ops v_opcode, | |
891 | i40e_status v_retval, | |
892 | u8 *msg, u16 msglen) | |
893 | { | |
894 | struct net_device *netdev = adapter->netdev; | |
895 | ||
896 | if (v_opcode == I40E_VIRTCHNL_OP_EVENT) { | |
897 | struct i40e_virtchnl_pf_event *vpe = | |
898 | (struct i40e_virtchnl_pf_event *)msg; | |
899 | switch (vpe->event) { | |
900 | case I40E_VIRTCHNL_EVENT_LINK_CHANGE: | |
fe458e50 MW |
901 | adapter->link_speed = |
902 | vpe->event_data.link_event.link_speed; | |
903 | if (adapter->link_up != | |
904 | vpe->event_data.link_event.link_status) { | |
905 | adapter->link_up = | |
906 | vpe->event_data.link_event.link_status; | |
3f341acc SS |
907 | if (adapter->link_up) { |
908 | netif_tx_start_all_queues(netdev); | |
909 | netif_carrier_on(netdev); | |
910 | } else { | |
911 | netif_tx_stop_all_queues(netdev); | |
912 | netif_carrier_off(netdev); | |
913 | } | |
fe458e50 | 914 | i40evf_print_link_message(adapter); |
62683ab5 GR |
915 | } |
916 | break; | |
917 | case I40E_VIRTCHNL_EVENT_RESET_IMPENDING: | |
ef8693eb MW |
918 | dev_info(&adapter->pdev->dev, "PF reset warning received\n"); |
919 | if (!(adapter->flags & I40EVF_FLAG_RESET_PENDING)) { | |
920 | adapter->flags |= I40EVF_FLAG_RESET_PENDING; | |
921 | dev_info(&adapter->pdev->dev, "Scheduling reset task\n"); | |
922 | schedule_work(&adapter->reset_task); | |
923 | } | |
62683ab5 GR |
924 | break; |
925 | default: | |
fb43201f SN |
926 | dev_err(&adapter->pdev->dev, "Unknown event %d from PF\n", |
927 | vpe->event); | |
62683ab5 | 928 | break; |
62683ab5 GR |
929 | } |
930 | return; | |
931 | } | |
62683ab5 | 932 | if (v_retval) { |
8d8f2295 MW |
933 | switch (v_opcode) { |
934 | case I40E_VIRTCHNL_OP_ADD_VLAN: | |
935 | dev_err(&adapter->pdev->dev, "Failed to add VLAN filter, error %s\n", | |
936 | i40evf_stat_str(&adapter->hw, v_retval)); | |
937 | break; | |
938 | case I40E_VIRTCHNL_OP_ADD_ETHER_ADDRESS: | |
939 | dev_err(&adapter->pdev->dev, "Failed to add MAC filter, error %s\n", | |
940 | i40evf_stat_str(&adapter->hw, v_retval)); | |
941 | break; | |
942 | case I40E_VIRTCHNL_OP_DEL_VLAN: | |
943 | dev_err(&adapter->pdev->dev, "Failed to delete VLAN filter, error %s\n", | |
944 | i40evf_stat_str(&adapter->hw, v_retval)); | |
945 | break; | |
946 | case I40E_VIRTCHNL_OP_DEL_ETHER_ADDRESS: | |
947 | dev_err(&adapter->pdev->dev, "Failed to delete MAC filter, error %s\n", | |
948 | i40evf_stat_str(&adapter->hw, v_retval)); | |
949 | break; | |
950 | default: | |
951 | dev_err(&adapter->pdev->dev, "PF returned error %d (%s) to our request %d\n", | |
952 | v_retval, | |
953 | i40evf_stat_str(&adapter->hw, v_retval), | |
954 | v_opcode); | |
955 | } | |
62683ab5 GR |
956 | } |
957 | switch (v_opcode) { | |
958 | case I40E_VIRTCHNL_OP_GET_STATS: { | |
959 | struct i40e_eth_stats *stats = | |
960 | (struct i40e_eth_stats *)msg; | |
961 | adapter->net_stats.rx_packets = stats->rx_unicast + | |
962 | stats->rx_multicast + | |
963 | stats->rx_broadcast; | |
964 | adapter->net_stats.tx_packets = stats->tx_unicast + | |
965 | stats->tx_multicast + | |
966 | stats->tx_broadcast; | |
967 | adapter->net_stats.rx_bytes = stats->rx_bytes; | |
968 | adapter->net_stats.tx_bytes = stats->tx_bytes; | |
62683ab5 | 969 | adapter->net_stats.tx_errors = stats->tx_errors; |
03da6f6a | 970 | adapter->net_stats.rx_dropped = stats->rx_discards; |
62683ab5 GR |
971 | adapter->net_stats.tx_dropped = stats->tx_discards; |
972 | adapter->current_stats = *stats; | |
973 | } | |
974 | break; | |
e6d038de MW |
975 | case I40E_VIRTCHNL_OP_GET_VF_RESOURCES: { |
976 | u16 len = sizeof(struct i40e_virtchnl_vf_resource) + | |
977 | I40E_MAX_VF_VSI * | |
978 | sizeof(struct i40e_virtchnl_vsi_resource); | |
979 | memcpy(adapter->vf_res, msg, min(msglen, len)); | |
980 | i40e_vf_parse_hw_config(&adapter->hw, adapter->vf_res); | |
8552d854 MW |
981 | /* restore current mac address */ |
982 | ether_addr_copy(adapter->hw.mac.addr, netdev->dev_addr); | |
e6d038de MW |
983 | i40evf_process_config(adapter); |
984 | } | |
985 | break; | |
62683ab5 | 986 | case I40E_VIRTCHNL_OP_ENABLE_QUEUES: |
62683ab5 GR |
987 | /* enable transmits */ |
988 | i40evf_irq_enable(adapter, true); | |
62683ab5 GR |
989 | break; |
990 | case I40E_VIRTCHNL_OP_DISABLE_QUEUES: | |
e284fc88 MW |
991 | i40evf_free_all_tx_resources(adapter); |
992 | i40evf_free_all_rx_resources(adapter); | |
209dc4da MW |
993 | if (adapter->state == __I40EVF_DOWN_PENDING) |
994 | adapter->state = __I40EVF_DOWN; | |
62683ab5 | 995 | break; |
ed636960 | 996 | case I40E_VIRTCHNL_OP_VERSION: |
62683ab5 | 997 | case I40E_VIRTCHNL_OP_CONFIG_IRQ_MAP: |
ed636960 MW |
998 | /* Don't display an error if we get these out of sequence. |
999 | * If the firmware needed to get kicked, we'll get these and | |
1000 | * it's no problem. | |
1001 | */ | |
1002 | if (v_opcode != adapter->current_op) | |
1003 | return; | |
62683ab5 | 1004 | break; |
ed0e894d MW |
1005 | case I40E_VIRTCHNL_OP_IWARP: |
1006 | /* Gobble zero-length replies from the PF. They indicate that | |
1007 | * a previous message was received OK, and the client doesn't | |
1008 | * care about that. | |
1009 | */ | |
1010 | if (msglen && CLIENT_ENABLED(adapter)) | |
1011 | i40evf_notify_client_message(&adapter->vsi, | |
1012 | msg, msglen); | |
1013 | break; | |
1014 | ||
e5f77f4a MW |
1015 | case I40E_VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP: |
1016 | adapter->client_pending &= | |
1017 | ~(BIT(I40E_VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP)); | |
1018 | break; | |
43a3d9ba MW |
1019 | case I40E_VIRTCHNL_OP_GET_RSS_HENA_CAPS: { |
1020 | struct i40e_virtchnl_rss_hena *vrh = | |
1021 | (struct i40e_virtchnl_rss_hena *)msg; | |
1022 | if (msglen == sizeof(*vrh)) | |
1023 | adapter->hena = vrh->hena; | |
1024 | else | |
1025 | dev_warn(&adapter->pdev->dev, | |
1026 | "Invalid message %d from PF\n", v_opcode); | |
1027 | } | |
1028 | break; | |
62683ab5 | 1029 | default: |
ed0e894d | 1030 | if (adapter->current_op && (v_opcode != adapter->current_op)) |
ed636960 MW |
1031 | dev_warn(&adapter->pdev->dev, "Expected response %d from PF, received %d\n", |
1032 | adapter->current_op, v_opcode); | |
62683ab5 GR |
1033 | break; |
1034 | } /* switch v_opcode */ | |
1035 | adapter->current_op = I40E_VIRTCHNL_OP_UNKNOWN; | |
1036 | } |