blob: 2719a057b2112975b5c81cea2ba2bd530c9b2121 [file] [log] [blame]
Greg Rose62683ab2013-12-21 06:13:01 +00001/*******************************************************************************
2 *
3 * Intel Ethernet Controller XL710 Family Linux Virtual Function Driver
Mitch Williamsef8693e2014-02-13 03:48:53 -08004 * Copyright(c) 2013 - 2014 Intel Corporation.
Greg Rose62683ab2013-12-21 06:13:01 +00005 *
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 *
Jesse Brandeburgb8316072014-04-05 07:46:11 +000015 * 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 *
Greg Rose62683ab2013-12-21 06:13:01 +000018 * 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"
Mitch Williamsed0e8942017-01-24 10:23:59 -080029#include "i40evf_client.h"
Greg Rose62683ab2013-12-21 06:13:01 +000030
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 **/
44static int i40evf_send_pf_msg(struct i40evf_adapter *adapter,
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -070045 enum virtchnl_ops op, u8 *msg, u16 len)
Greg Rose62683ab2013-12-21 06:13:01 +000046{
47 struct i40e_hw *hw = &adapter->hw;
48 i40e_status err;
49
Mitch Williamsef8693e2014-02-13 03:48:53 -080050 if (adapter->flags & I40EVF_FLAG_PF_COMMS_FAILED)
51 return 0; /* nothing to see here, move along */
52
Greg Rose62683ab2013-12-21 06:13:01 +000053 err = i40e_aq_send_msg_to_pf(hw, op, 0, msg, len, NULL);
54 if (err)
Mitch Williams905770f2017-07-14 09:27:01 -040055 dev_dbg(&adapter->pdev->dev, "Unable to send opcode %d to PF, err %s, aq_err %s\n",
Shannon Nelsonf1c7e722015-06-04 16:24:01 -040056 op, i40evf_stat_str(hw, err),
57 i40evf_aq_str(hw, hw->aq.asq_last_status));
Greg Rose62683ab2013-12-21 06:13:01 +000058 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 **/
69int i40evf_send_api_ver(struct i40evf_adapter *adapter)
70{
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -070071 struct virtchnl_version_info vvi;
Greg Rose62683ab2013-12-21 06:13:01 +000072
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -070073 vvi.major = VIRTCHNL_VERSION_MAJOR;
74 vvi.minor = VIRTCHNL_VERSION_MINOR;
Greg Rose62683ab2013-12-21 06:13:01 +000075
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -070076 return i40evf_send_pf_msg(adapter, VIRTCHNL_OP_VERSION, (u8 *)&vvi,
Greg Rose62683ab2013-12-21 06:13:01 +000077 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
Mitch Williams6a8e93d2014-06-05 00:09:17 +000085 * 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.
Greg Rose62683ab2013-12-21 06:13:01 +000088 **/
89int i40evf_verify_api_ver(struct i40evf_adapter *adapter)
90{
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -070091 struct virtchnl_version_info *pf_vvi;
Greg Rose62683ab2013-12-21 06:13:01 +000092 struct i40e_hw *hw = &adapter->hw;
93 struct i40e_arq_event_info event;
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -070094 enum virtchnl_ops op;
Greg Rose62683ab2013-12-21 06:13:01 +000095 i40e_status err;
96
Mitch Williams1001dc32014-11-11 20:02:19 +000097 event.buf_len = I40EVF_MAX_AQ_BUF_SIZE;
98 event.msg_buf = kzalloc(event.buf_len, GFP_KERNEL);
Greg Rose62683ab2013-12-21 06:13:01 +000099 if (!event.msg_buf) {
100 err = -ENOMEM;
101 goto out;
102 }
103
Mitch Williamsf8d4db32014-10-25 03:24:33 +0000104 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 =
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700112 (enum virtchnl_ops)le32_to_cpu(event.desc.cookie_high);
113 if (op == VIRTCHNL_OP_VERSION)
Mitch Williamsf8d4db32014-10-25 03:24:33 +0000114 break;
115 }
116
Greg Rose62683ab2013-12-21 06:13:01 +0000117
118 err = (i40e_status)le32_to_cpu(event.desc.cookie_low);
Mitch Williams6a8e93d2014-06-05 00:09:17 +0000119 if (err)
Greg Rose62683ab2013-12-21 06:13:01 +0000120 goto out_alloc;
Greg Rose62683ab2013-12-21 06:13:01 +0000121
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700122 if (op != VIRTCHNL_OP_VERSION) {
Mitch Williams6a8e93d2014-06-05 00:09:17 +0000123 dev_info(&adapter->pdev->dev, "Invalid reply type %d from PF\n",
Mitch Williamsf8d4db32014-10-25 03:24:33 +0000124 op);
Greg Rose62683ab2013-12-21 06:13:01 +0000125 err = -EIO;
126 goto out_alloc;
127 }
128
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700129 pf_vvi = (struct virtchnl_version_info *)event.msg_buf;
Mitch Williamsee1693e2015-06-04 16:23:59 -0400130 adapter->pf_version = *pf_vvi;
131
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700132 if ((pf_vvi->major > VIRTCHNL_VERSION_MAJOR) ||
133 ((pf_vvi->major == VIRTCHNL_VERSION_MAJOR) &&
134 (pf_vvi->minor > VIRTCHNL_VERSION_MINOR)))
Greg Rose62683ab2013-12-21 06:13:01 +0000135 err = -EIO;
136
137out_alloc:
138 kfree(event.msg_buf);
139out:
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 **/
151int i40evf_send_vf_config_msg(struct i40evf_adapter *adapter)
152{
Mitch Williamse6d038d2015-06-04 16:23:58 -0400153 u32 caps;
154
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700155 caps = VIRTCHNL_VF_OFFLOAD_L2 |
156 VIRTCHNL_VF_OFFLOAD_RSS_PF |
157 VIRTCHNL_VF_OFFLOAD_RSS_AQ |
158 VIRTCHNL_VF_OFFLOAD_RSS_REG |
159 VIRTCHNL_VF_OFFLOAD_VLAN |
160 VIRTCHNL_VF_OFFLOAD_WB_ON_ITR |
161 VIRTCHNL_VF_OFFLOAD_RSS_PCTYPE_V2 |
162 VIRTCHNL_VF_OFFLOAD_ENCAP |
Alan Brady5b36e8d2017-08-22 06:57:50 -0400163 VIRTCHNL_VF_OFFLOAD_ENCAP_CSUM |
164 VIRTCHNL_VF_OFFLOAD_REQ_QUEUES;
Anjali Singhai Jainb9eacec2015-11-19 11:34:22 -0800165
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700166 adapter->current_op = VIRTCHNL_OP_GET_VF_RESOURCES;
Mitch Williamse6d038d2015-06-04 16:23:58 -0400167 adapter->aq_required &= ~I40EVF_FLAG_AQ_GET_CONFIG;
168 if (PF_IS_V11(adapter))
169 return i40evf_send_pf_msg(adapter,
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700170 VIRTCHNL_OP_GET_VF_RESOURCES,
Mitch Williamse6d038d2015-06-04 16:23:58 -0400171 (u8 *)&caps, sizeof(caps));
172 else
173 return i40evf_send_pf_msg(adapter,
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700174 VIRTCHNL_OP_GET_VF_RESOURCES,
Mitch Williamse6d038d2015-06-04 16:23:58 -0400175 NULL, 0);
Greg Rose62683ab2013-12-21 06:13:01 +0000176}
177
178/**
179 * i40evf_get_vf_config
180 * @hw: pointer to the hardware structure
181 * @len: length of buffer
182 *
183 * Get VF configuration from PF and populate hw structure. Must be called after
184 * admin queue is initialized. Busy waits until response is received from PF,
185 * with maximum timeout. Response from PF is returned in the buffer for further
186 * processing by the caller.
187 **/
188int i40evf_get_vf_config(struct i40evf_adapter *adapter)
189{
190 struct i40e_hw *hw = &adapter->hw;
191 struct i40e_arq_event_info event;
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700192 enum virtchnl_ops op;
Greg Rose62683ab2013-12-21 06:13:01 +0000193 i40e_status err;
Mitch Williamsf8d4db32014-10-25 03:24:33 +0000194 u16 len;
Greg Rose62683ab2013-12-21 06:13:01 +0000195
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700196 len = sizeof(struct virtchnl_vf_resource) +
197 I40E_MAX_VF_VSI * sizeof(struct virtchnl_vsi_resource);
Mitch Williams1001dc32014-11-11 20:02:19 +0000198 event.buf_len = len;
199 event.msg_buf = kzalloc(event.buf_len, GFP_KERNEL);
Greg Rose62683ab2013-12-21 06:13:01 +0000200 if (!event.msg_buf) {
201 err = -ENOMEM;
202 goto out;
203 }
204
Mitch Williamsf8d4db32014-10-25 03:24:33 +0000205 while (1) {
Mitch Williamsf8d4db32014-10-25 03:24:33 +0000206 /* When the AQ is empty, i40evf_clean_arq_element will return
207 * nonzero and this loop will terminate.
208 */
209 err = i40evf_clean_arq_element(hw, &event, NULL);
210 if (err)
211 goto out_alloc;
212 op =
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700213 (enum virtchnl_ops)le32_to_cpu(event.desc.cookie_high);
214 if (op == VIRTCHNL_OP_GET_VF_RESOURCES)
Mitch Williamsf8d4db32014-10-25 03:24:33 +0000215 break;
216 }
Greg Rose62683ab2013-12-21 06:13:01 +0000217
218 err = (i40e_status)le32_to_cpu(event.desc.cookie_low);
Mitch Williams1001dc32014-11-11 20:02:19 +0000219 memcpy(adapter->vf_res, event.msg_buf, min(event.msg_len, len));
Greg Rose62683ab2013-12-21 06:13:01 +0000220
221 i40e_vf_parse_hw_config(hw, adapter->vf_res);
222out_alloc:
223 kfree(event.msg_buf);
224out:
225 return err;
226}
227
228/**
229 * i40evf_configure_queues
230 * @adapter: adapter structure
231 *
232 * Request that the PF set up our (previously allocated) queues.
233 **/
234void i40evf_configure_queues(struct i40evf_adapter *adapter)
235{
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700236 struct virtchnl_vsi_queue_config_info *vqci;
237 struct virtchnl_queue_pair_info *vqpi;
Mitch Williamscc052922014-10-25 03:24:34 +0000238 int pairs = adapter->num_active_queues;
Alexander Duyckdab86af2017-03-14 10:15:27 -0700239 int i, len, max_frame = I40E_MAX_RXBUFFER;
Greg Rose62683ab2013-12-21 06:13:01 +0000240
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700241 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
Greg Rose62683ab2013-12-21 06:13:01 +0000242 /* bail because we already have a command pending */
Shannon Nelsonfb43201f2015-08-26 15:14:17 -0400243 dev_err(&adapter->pdev->dev, "Cannot configure queues, command %d pending\n",
244 adapter->current_op);
Greg Rose62683ab2013-12-21 06:13:01 +0000245 return;
246 }
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700247 adapter->current_op = VIRTCHNL_OP_CONFIG_VSI_QUEUES;
248 len = sizeof(struct virtchnl_vsi_queue_config_info) +
249 (sizeof(struct virtchnl_queue_pair_info) * pairs);
Mitch Williamsa85088d2015-11-06 15:26:04 -0800250 vqci = kzalloc(len, GFP_KERNEL);
Mitch Williams249c8b82014-05-10 04:49:04 +0000251 if (!vqci)
Greg Rose62683ab2013-12-21 06:13:01 +0000252 return;
Mitch Williams249c8b82014-05-10 04:49:04 +0000253
Alexander Duyckdab86af2017-03-14 10:15:27 -0700254 /* Limit maximum frame size when jumbo frames is not enabled */
255 if (!(adapter->flags & I40EVF_FLAG_LEGACY_RX) &&
256 (adapter->netdev->mtu <= ETH_DATA_LEN))
257 max_frame = I40E_RXBUFFER_1536 - NET_IP_ALIGN;
258
Greg Rose62683ab2013-12-21 06:13:01 +0000259 vqci->vsi_id = adapter->vsi_res->vsi_id;
260 vqci->num_queue_pairs = pairs;
261 vqpi = vqci->qpair;
262 /* Size check is not needed here - HW max is 16 queue pairs, and we
263 * can fit info for 31 of them into the AQ buffer before it overflows.
264 */
265 for (i = 0; i < pairs; i++) {
266 vqpi->txq.vsi_id = vqci->vsi_id;
267 vqpi->txq.queue_id = i;
Mitch Williams0dd438d2015-10-26 19:44:40 -0400268 vqpi->txq.ring_len = adapter->tx_rings[i].count;
269 vqpi->txq.dma_ring_addr = adapter->tx_rings[i].dma;
Greg Rose62683ab2013-12-21 06:13:01 +0000270 vqpi->rxq.vsi_id = vqci->vsi_id;
271 vqpi->rxq.queue_id = i;
Mitch Williams0dd438d2015-10-26 19:44:40 -0400272 vqpi->rxq.ring_len = adapter->rx_rings[i].count;
273 vqpi->rxq.dma_ring_addr = adapter->rx_rings[i].dma;
Alexander Duyckdab86af2017-03-14 10:15:27 -0700274 vqpi->rxq.max_pkt_size = max_frame;
275 vqpi->rxq.databuffer_size =
276 ALIGN(adapter->rx_rings[i].rx_buf_len,
277 BIT_ULL(I40E_RXQ_CTX_DBUFF_SHIFT));
Greg Rose62683ab2013-12-21 06:13:01 +0000278 vqpi++;
279 }
280
Mitch Williamsfc86a972014-06-04 20:41:38 +0000281 adapter->aq_required &= ~I40EVF_FLAG_AQ_CONFIGURE_QUEUES;
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700282 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_CONFIG_VSI_QUEUES,
Greg Rose62683ab2013-12-21 06:13:01 +0000283 (u8 *)vqci, len);
284 kfree(vqci);
Greg Rose62683ab2013-12-21 06:13:01 +0000285}
286
287/**
288 * i40evf_enable_queues
289 * @adapter: adapter structure
290 *
291 * Request that the PF enable all of our queues.
292 **/
293void i40evf_enable_queues(struct i40evf_adapter *adapter)
294{
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700295 struct virtchnl_queue_select vqs;
Greg Rose62683ab2013-12-21 06:13:01 +0000296
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700297 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
Greg Rose62683ab2013-12-21 06:13:01 +0000298 /* bail because we already have a command pending */
Shannon Nelsonfb43201f2015-08-26 15:14:17 -0400299 dev_err(&adapter->pdev->dev, "Cannot enable queues, command %d pending\n",
300 adapter->current_op);
Greg Rose62683ab2013-12-21 06:13:01 +0000301 return;
302 }
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700303 adapter->current_op = VIRTCHNL_OP_ENABLE_QUEUES;
Greg Rose62683ab2013-12-21 06:13:01 +0000304 vqs.vsi_id = adapter->vsi_res->vsi_id;
Jesse Brandeburg41a1d042015-06-04 16:24:02 -0400305 vqs.tx_queues = BIT(adapter->num_active_queues) - 1;
Greg Rose62683ab2013-12-21 06:13:01 +0000306 vqs.rx_queues = vqs.tx_queues;
Greg Rose62683ab2013-12-21 06:13:01 +0000307 adapter->aq_required &= ~I40EVF_FLAG_AQ_ENABLE_QUEUES;
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700308 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_ENABLE_QUEUES,
Mitch Williamsfc86a972014-06-04 20:41:38 +0000309 (u8 *)&vqs, sizeof(vqs));
Greg Rose62683ab2013-12-21 06:13:01 +0000310}
311
312/**
313 * i40evf_disable_queues
314 * @adapter: adapter structure
315 *
316 * Request that the PF disable all of our queues.
317 **/
318void i40evf_disable_queues(struct i40evf_adapter *adapter)
319{
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700320 struct virtchnl_queue_select vqs;
Greg Rose62683ab2013-12-21 06:13:01 +0000321
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700322 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
Greg Rose62683ab2013-12-21 06:13:01 +0000323 /* bail because we already have a command pending */
Shannon Nelsonfb43201f2015-08-26 15:14:17 -0400324 dev_err(&adapter->pdev->dev, "Cannot disable queues, command %d pending\n",
325 adapter->current_op);
Greg Rose62683ab2013-12-21 06:13:01 +0000326 return;
327 }
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700328 adapter->current_op = VIRTCHNL_OP_DISABLE_QUEUES;
Greg Rose62683ab2013-12-21 06:13:01 +0000329 vqs.vsi_id = adapter->vsi_res->vsi_id;
Jesse Brandeburg41a1d042015-06-04 16:24:02 -0400330 vqs.tx_queues = BIT(adapter->num_active_queues) - 1;
Greg Rose62683ab2013-12-21 06:13:01 +0000331 vqs.rx_queues = vqs.tx_queues;
Greg Rose62683ab2013-12-21 06:13:01 +0000332 adapter->aq_required &= ~I40EVF_FLAG_AQ_DISABLE_QUEUES;
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700333 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_DISABLE_QUEUES,
Mitch Williamsfc86a972014-06-04 20:41:38 +0000334 (u8 *)&vqs, sizeof(vqs));
Greg Rose62683ab2013-12-21 06:13:01 +0000335}
336
337/**
338 * i40evf_map_queues
339 * @adapter: adapter structure
340 *
341 * Request that the PF map queues to interrupt vectors. Misc causes, including
342 * admin queue, are always mapped to vector 0.
343 **/
344void i40evf_map_queues(struct i40evf_adapter *adapter)
345{
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700346 struct virtchnl_irq_map_info *vimi;
Greg Rose62683ab2013-12-21 06:13:01 +0000347 int v_idx, q_vectors, len;
348 struct i40e_q_vector *q_vector;
349
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700350 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
Greg Rose62683ab2013-12-21 06:13:01 +0000351 /* bail because we already have a command pending */
Shannon Nelsonfb43201f2015-08-26 15:14:17 -0400352 dev_err(&adapter->pdev->dev, "Cannot map queues to vectors, command %d pending\n",
353 adapter->current_op);
Greg Rose62683ab2013-12-21 06:13:01 +0000354 return;
355 }
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700356 adapter->current_op = VIRTCHNL_OP_CONFIG_IRQ_MAP;
Greg Rose62683ab2013-12-21 06:13:01 +0000357
358 q_vectors = adapter->num_msix_vectors - NONQ_VECS;
359
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700360 len = sizeof(struct virtchnl_irq_map_info) +
Greg Rose62683ab2013-12-21 06:13:01 +0000361 (adapter->num_msix_vectors *
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700362 sizeof(struct virtchnl_vector_map));
Mitch Williamsa85088d2015-11-06 15:26:04 -0800363 vimi = kzalloc(len, GFP_KERNEL);
Mitch Williams249c8b82014-05-10 04:49:04 +0000364 if (!vimi)
Greg Rose62683ab2013-12-21 06:13:01 +0000365 return;
Greg Rose62683ab2013-12-21 06:13:01 +0000366
367 vimi->num_vectors = adapter->num_msix_vectors;
368 /* Queue vectors first */
369 for (v_idx = 0; v_idx < q_vectors; v_idx++) {
Mitch Williams7d96ba12015-10-26 19:44:39 -0400370 q_vector = adapter->q_vectors + v_idx;
Greg Rose62683ab2013-12-21 06:13:01 +0000371 vimi->vecmap[v_idx].vsi_id = adapter->vsi_res->vsi_id;
372 vimi->vecmap[v_idx].vector_id = v_idx + NONQ_VECS;
373 vimi->vecmap[v_idx].txq_map = q_vector->ring_mask;
374 vimi->vecmap[v_idx].rxq_map = q_vector->ring_mask;
375 }
376 /* Misc vector last - this is only for AdminQ messages */
377 vimi->vecmap[v_idx].vsi_id = adapter->vsi_res->vsi_id;
378 vimi->vecmap[v_idx].vector_id = 0;
379 vimi->vecmap[v_idx].txq_map = 0;
380 vimi->vecmap[v_idx].rxq_map = 0;
381
Mitch Williamsfc86a972014-06-04 20:41:38 +0000382 adapter->aq_required &= ~I40EVF_FLAG_AQ_MAP_VECTORS;
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700383 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_CONFIG_IRQ_MAP,
Greg Rose62683ab2013-12-21 06:13:01 +0000384 (u8 *)vimi, len);
385 kfree(vimi);
Greg Rose62683ab2013-12-21 06:13:01 +0000386}
387
388/**
Alan Brady5b36e8d2017-08-22 06:57:50 -0400389 * i40evf_request_queues
390 * @adapter: adapter structure
391 * @num: number of requested queues
392 *
393 * We get a default number of queues from the PF. This enables us to request a
394 * different number. Returns 0 on success, negative on failure
395 **/
396int i40evf_request_queues(struct i40evf_adapter *adapter, int num)
397{
398 struct virtchnl_vf_res_request vfres;
399
400 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
401 /* bail because we already have a command pending */
402 dev_err(&adapter->pdev->dev, "Cannot request queues, command %d pending\n",
403 adapter->current_op);
404 return -EBUSY;
405 }
406
407 vfres.num_queue_pairs = num;
408
409 adapter->current_op = VIRTCHNL_OP_REQUEST_QUEUES;
Alan Brady17a94222017-10-11 14:49:43 -0700410 adapter->flags |= I40EVF_FLAG_REINIT_ITR_NEEDED;
Alan Brady5b36e8d2017-08-22 06:57:50 -0400411 return i40evf_send_pf_msg(adapter, VIRTCHNL_OP_REQUEST_QUEUES,
412 (u8 *)&vfres, sizeof(vfres));
413}
414
415/**
Greg Rose62683ab2013-12-21 06:13:01 +0000416 * i40evf_add_ether_addrs
417 * @adapter: adapter structure
418 * @addrs: the MAC address filters to add (contiguous)
419 * @count: number of filters
420 *
421 * Request that the PF add one or more addresses to our filters.
422 **/
423void i40evf_add_ether_addrs(struct i40evf_adapter *adapter)
424{
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700425 struct virtchnl_ether_addr_list *veal;
Greg Rose62683ab2013-12-21 06:13:01 +0000426 int len, i = 0, count = 0;
427 struct i40evf_mac_filter *f;
Mitch Williams1418c342015-10-21 19:47:12 -0400428 bool more = false;
Greg Rose62683ab2013-12-21 06:13:01 +0000429
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700430 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
Greg Rose62683ab2013-12-21 06:13:01 +0000431 /* bail because we already have a command pending */
Shannon Nelsonfb43201f2015-08-26 15:14:17 -0400432 dev_err(&adapter->pdev->dev, "Cannot add filters, command %d pending\n",
433 adapter->current_op);
Greg Rose62683ab2013-12-21 06:13:01 +0000434 return;
435 }
Jacob Keller504398f2017-10-27 11:06:50 -0400436
437 spin_lock_bh(&adapter->mac_vlan_list_lock);
438
Greg Rose62683ab2013-12-21 06:13:01 +0000439 list_for_each_entry(f, &adapter->mac_filter_list, list) {
440 if (f->add)
441 count++;
442 }
443 if (!count) {
444 adapter->aq_required &= ~I40EVF_FLAG_AQ_ADD_MAC_FILTER;
Jacob Keller504398f2017-10-27 11:06:50 -0400445 spin_unlock_bh(&adapter->mac_vlan_list_lock);
Greg Rose62683ab2013-12-21 06:13:01 +0000446 return;
447 }
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700448 adapter->current_op = VIRTCHNL_OP_ADD_ETH_ADDR;
Greg Rose62683ab2013-12-21 06:13:01 +0000449
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700450 len = sizeof(struct virtchnl_ether_addr_list) +
451 (count * sizeof(struct virtchnl_ether_addr));
Greg Rose62683ab2013-12-21 06:13:01 +0000452 if (len > I40EVF_MAX_AQ_BUF_SIZE) {
Shannon Nelsonfb43201f2015-08-26 15:14:17 -0400453 dev_warn(&adapter->pdev->dev, "Too many add MAC changes in one request\n");
Greg Rose62683ab2013-12-21 06:13:01 +0000454 count = (I40EVF_MAX_AQ_BUF_SIZE -
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700455 sizeof(struct virtchnl_ether_addr_list)) /
456 sizeof(struct virtchnl_ether_addr);
457 len = sizeof(struct virtchnl_ether_addr_list) +
458 (count * sizeof(struct virtchnl_ether_addr));
Mitch Williams1418c342015-10-21 19:47:12 -0400459 more = true;
Greg Rose62683ab2013-12-21 06:13:01 +0000460 }
461
Mitch Williamsa85088d2015-11-06 15:26:04 -0800462 veal = kzalloc(len, GFP_KERNEL);
Jacob Keller504398f2017-10-27 11:06:50 -0400463 if (!veal) {
464 spin_unlock_bh(&adapter->mac_vlan_list_lock);
Greg Rose62683ab2013-12-21 06:13:01 +0000465 return;
Jacob Keller504398f2017-10-27 11:06:50 -0400466 }
Mitch Williams249c8b82014-05-10 04:49:04 +0000467
Greg Rose62683ab2013-12-21 06:13:01 +0000468 veal->vsi_id = adapter->vsi_res->vsi_id;
469 veal->num_elements = count;
470 list_for_each_entry(f, &adapter->mac_filter_list, list) {
471 if (f->add) {
Greg Rose9a173902014-05-22 06:32:02 +0000472 ether_addr_copy(veal->list[i].addr, f->macaddr);
Greg Rose62683ab2013-12-21 06:13:01 +0000473 i++;
474 f->add = false;
Mitch Williams0e8d95f892016-05-16 10:26:36 -0700475 if (i == count)
476 break;
Greg Rose62683ab2013-12-21 06:13:01 +0000477 }
478 }
Mitch Williams1418c342015-10-21 19:47:12 -0400479 if (!more)
480 adapter->aq_required &= ~I40EVF_FLAG_AQ_ADD_MAC_FILTER;
Jacob Keller504398f2017-10-27 11:06:50 -0400481
482 spin_unlock_bh(&adapter->mac_vlan_list_lock);
483
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700484 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_ADD_ETH_ADDR,
Greg Rose62683ab2013-12-21 06:13:01 +0000485 (u8 *)veal, len);
486 kfree(veal);
Greg Rose62683ab2013-12-21 06:13:01 +0000487}
488
489/**
490 * i40evf_del_ether_addrs
491 * @adapter: adapter structure
492 * @addrs: the MAC address filters to remove (contiguous)
493 * @count: number of filtes
494 *
495 * Request that the PF remove one or more addresses from our filters.
496 **/
497void i40evf_del_ether_addrs(struct i40evf_adapter *adapter)
498{
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700499 struct virtchnl_ether_addr_list *veal;
Greg Rose62683ab2013-12-21 06:13:01 +0000500 struct i40evf_mac_filter *f, *ftmp;
501 int len, i = 0, count = 0;
Mitch Williams1418c342015-10-21 19:47:12 -0400502 bool more = false;
Greg Rose62683ab2013-12-21 06:13:01 +0000503
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700504 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
Greg Rose62683ab2013-12-21 06:13:01 +0000505 /* bail because we already have a command pending */
Shannon Nelsonfb43201f2015-08-26 15:14:17 -0400506 dev_err(&adapter->pdev->dev, "Cannot remove filters, command %d pending\n",
507 adapter->current_op);
Greg Rose62683ab2013-12-21 06:13:01 +0000508 return;
509 }
Jacob Keller504398f2017-10-27 11:06:50 -0400510
511 spin_lock_bh(&adapter->mac_vlan_list_lock);
512
Greg Rose62683ab2013-12-21 06:13:01 +0000513 list_for_each_entry(f, &adapter->mac_filter_list, list) {
514 if (f->remove)
515 count++;
516 }
517 if (!count) {
518 adapter->aq_required &= ~I40EVF_FLAG_AQ_DEL_MAC_FILTER;
Jacob Keller504398f2017-10-27 11:06:50 -0400519 spin_unlock_bh(&adapter->mac_vlan_list_lock);
Greg Rose62683ab2013-12-21 06:13:01 +0000520 return;
521 }
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700522 adapter->current_op = VIRTCHNL_OP_DEL_ETH_ADDR;
Greg Rose62683ab2013-12-21 06:13:01 +0000523
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700524 len = sizeof(struct virtchnl_ether_addr_list) +
525 (count * sizeof(struct virtchnl_ether_addr));
Greg Rose62683ab2013-12-21 06:13:01 +0000526 if (len > I40EVF_MAX_AQ_BUF_SIZE) {
Shannon Nelsonfb43201f2015-08-26 15:14:17 -0400527 dev_warn(&adapter->pdev->dev, "Too many delete MAC changes in one request\n");
Greg Rose62683ab2013-12-21 06:13:01 +0000528 count = (I40EVF_MAX_AQ_BUF_SIZE -
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700529 sizeof(struct virtchnl_ether_addr_list)) /
530 sizeof(struct virtchnl_ether_addr);
531 len = sizeof(struct virtchnl_ether_addr_list) +
532 (count * sizeof(struct virtchnl_ether_addr));
Mitch Williams1418c342015-10-21 19:47:12 -0400533 more = true;
Greg Rose62683ab2013-12-21 06:13:01 +0000534 }
Mitch Williamsa85088d2015-11-06 15:26:04 -0800535 veal = kzalloc(len, GFP_KERNEL);
Jacob Keller504398f2017-10-27 11:06:50 -0400536 if (!veal) {
537 spin_unlock_bh(&adapter->mac_vlan_list_lock);
Greg Rose62683ab2013-12-21 06:13:01 +0000538 return;
Jacob Keller504398f2017-10-27 11:06:50 -0400539 }
Mitch Williams249c8b82014-05-10 04:49:04 +0000540
Greg Rose62683ab2013-12-21 06:13:01 +0000541 veal->vsi_id = adapter->vsi_res->vsi_id;
542 veal->num_elements = count;
543 list_for_each_entry_safe(f, ftmp, &adapter->mac_filter_list, list) {
544 if (f->remove) {
Greg Rose9a173902014-05-22 06:32:02 +0000545 ether_addr_copy(veal->list[i].addr, f->macaddr);
Greg Rose62683ab2013-12-21 06:13:01 +0000546 i++;
547 list_del(&f->list);
548 kfree(f);
Mitch Williams0e8d95f892016-05-16 10:26:36 -0700549 if (i == count)
550 break;
Greg Rose62683ab2013-12-21 06:13:01 +0000551 }
552 }
Mitch Williams1418c342015-10-21 19:47:12 -0400553 if (!more)
554 adapter->aq_required &= ~I40EVF_FLAG_AQ_DEL_MAC_FILTER;
Jacob Keller504398f2017-10-27 11:06:50 -0400555
556 spin_unlock_bh(&adapter->mac_vlan_list_lock);
557
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700558 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_DEL_ETH_ADDR,
Greg Rose62683ab2013-12-21 06:13:01 +0000559 (u8 *)veal, len);
560 kfree(veal);
Greg Rose62683ab2013-12-21 06:13:01 +0000561}
562
563/**
564 * i40evf_add_vlans
565 * @adapter: adapter structure
566 * @vlans: the VLANs to add
567 * @count: number of VLANs
568 *
569 * Request that the PF add one or more VLAN filters to our VSI.
570 **/
571void i40evf_add_vlans(struct i40evf_adapter *adapter)
572{
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700573 struct virtchnl_vlan_filter_list *vvfl;
Greg Rose62683ab2013-12-21 06:13:01 +0000574 int len, i = 0, count = 0;
575 struct i40evf_vlan_filter *f;
Mitch Williams1418c342015-10-21 19:47:12 -0400576 bool more = false;
Greg Rose62683ab2013-12-21 06:13:01 +0000577
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700578 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
Greg Rose62683ab2013-12-21 06:13:01 +0000579 /* bail because we already have a command pending */
Shannon Nelsonfb43201f2015-08-26 15:14:17 -0400580 dev_err(&adapter->pdev->dev, "Cannot add VLANs, command %d pending\n",
581 adapter->current_op);
Greg Rose62683ab2013-12-21 06:13:01 +0000582 return;
583 }
584
Jacob Keller504398f2017-10-27 11:06:50 -0400585 spin_lock_bh(&adapter->mac_vlan_list_lock);
586
Greg Rose62683ab2013-12-21 06:13:01 +0000587 list_for_each_entry(f, &adapter->vlan_filter_list, list) {
588 if (f->add)
589 count++;
590 }
591 if (!count) {
592 adapter->aq_required &= ~I40EVF_FLAG_AQ_ADD_VLAN_FILTER;
Jacob Keller504398f2017-10-27 11:06:50 -0400593 spin_unlock_bh(&adapter->mac_vlan_list_lock);
Greg Rose62683ab2013-12-21 06:13:01 +0000594 return;
595 }
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700596 adapter->current_op = VIRTCHNL_OP_ADD_VLAN;
Greg Rose62683ab2013-12-21 06:13:01 +0000597
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700598 len = sizeof(struct virtchnl_vlan_filter_list) +
Greg Rose62683ab2013-12-21 06:13:01 +0000599 (count * sizeof(u16));
600 if (len > I40EVF_MAX_AQ_BUF_SIZE) {
Shannon Nelsonfb43201f2015-08-26 15:14:17 -0400601 dev_warn(&adapter->pdev->dev, "Too many add VLAN changes in one request\n");
Greg Rose62683ab2013-12-21 06:13:01 +0000602 count = (I40EVF_MAX_AQ_BUF_SIZE -
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700603 sizeof(struct virtchnl_vlan_filter_list)) /
Greg Rose62683ab2013-12-21 06:13:01 +0000604 sizeof(u16);
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700605 len = sizeof(struct virtchnl_vlan_filter_list) +
Mitch Williams1418c342015-10-21 19:47:12 -0400606 (count * sizeof(u16));
607 more = true;
Greg Rose62683ab2013-12-21 06:13:01 +0000608 }
Mitch Williamsa85088d2015-11-06 15:26:04 -0800609 vvfl = kzalloc(len, GFP_KERNEL);
Jacob Keller504398f2017-10-27 11:06:50 -0400610 if (!vvfl) {
611 spin_unlock_bh(&adapter->mac_vlan_list_lock);
Greg Rose62683ab2013-12-21 06:13:01 +0000612 return;
Jacob Keller504398f2017-10-27 11:06:50 -0400613 }
Mitch Williams249c8b82014-05-10 04:49:04 +0000614
Greg Rose62683ab2013-12-21 06:13:01 +0000615 vvfl->vsi_id = adapter->vsi_res->vsi_id;
616 vvfl->num_elements = count;
617 list_for_each_entry(f, &adapter->vlan_filter_list, list) {
618 if (f->add) {
619 vvfl->vlan_id[i] = f->vlan;
620 i++;
621 f->add = false;
Mitch Williams0e8d95f892016-05-16 10:26:36 -0700622 if (i == count)
623 break;
Greg Rose62683ab2013-12-21 06:13:01 +0000624 }
625 }
Mitch Williams1418c342015-10-21 19:47:12 -0400626 if (!more)
627 adapter->aq_required &= ~I40EVF_FLAG_AQ_ADD_VLAN_FILTER;
Jacob Keller504398f2017-10-27 11:06:50 -0400628
629 spin_unlock_bh(&adapter->mac_vlan_list_lock);
630
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700631 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_ADD_VLAN, (u8 *)vvfl, len);
Mitch Williamsfc86a972014-06-04 20:41:38 +0000632 kfree(vvfl);
Greg Rose62683ab2013-12-21 06:13:01 +0000633}
634
635/**
636 * i40evf_del_vlans
637 * @adapter: adapter structure
638 * @vlans: the VLANs to remove
639 * @count: number of VLANs
640 *
641 * Request that the PF remove one or more VLAN filters from our VSI.
642 **/
643void i40evf_del_vlans(struct i40evf_adapter *adapter)
644{
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700645 struct virtchnl_vlan_filter_list *vvfl;
Greg Rose62683ab2013-12-21 06:13:01 +0000646 struct i40evf_vlan_filter *f, *ftmp;
647 int len, i = 0, count = 0;
Mitch Williams1418c342015-10-21 19:47:12 -0400648 bool more = false;
Greg Rose62683ab2013-12-21 06:13:01 +0000649
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700650 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
Greg Rose62683ab2013-12-21 06:13:01 +0000651 /* bail because we already have a command pending */
Shannon Nelsonfb43201f2015-08-26 15:14:17 -0400652 dev_err(&adapter->pdev->dev, "Cannot remove VLANs, command %d pending\n",
653 adapter->current_op);
Greg Rose62683ab2013-12-21 06:13:01 +0000654 return;
655 }
656
Jacob Keller504398f2017-10-27 11:06:50 -0400657 spin_lock_bh(&adapter->mac_vlan_list_lock);
658
Greg Rose62683ab2013-12-21 06:13:01 +0000659 list_for_each_entry(f, &adapter->vlan_filter_list, list) {
660 if (f->remove)
661 count++;
662 }
663 if (!count) {
664 adapter->aq_required &= ~I40EVF_FLAG_AQ_DEL_VLAN_FILTER;
Jacob Keller504398f2017-10-27 11:06:50 -0400665 spin_unlock_bh(&adapter->mac_vlan_list_lock);
Greg Rose62683ab2013-12-21 06:13:01 +0000666 return;
667 }
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700668 adapter->current_op = VIRTCHNL_OP_DEL_VLAN;
Greg Rose62683ab2013-12-21 06:13:01 +0000669
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700670 len = sizeof(struct virtchnl_vlan_filter_list) +
Greg Rose62683ab2013-12-21 06:13:01 +0000671 (count * sizeof(u16));
672 if (len > I40EVF_MAX_AQ_BUF_SIZE) {
Shannon Nelsonfb43201f2015-08-26 15:14:17 -0400673 dev_warn(&adapter->pdev->dev, "Too many delete VLAN changes in one request\n");
Greg Rose62683ab2013-12-21 06:13:01 +0000674 count = (I40EVF_MAX_AQ_BUF_SIZE -
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700675 sizeof(struct virtchnl_vlan_filter_list)) /
Greg Rose62683ab2013-12-21 06:13:01 +0000676 sizeof(u16);
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700677 len = sizeof(struct virtchnl_vlan_filter_list) +
Mitch Williams1418c342015-10-21 19:47:12 -0400678 (count * sizeof(u16));
679 more = true;
Greg Rose62683ab2013-12-21 06:13:01 +0000680 }
Mitch Williamsa85088d2015-11-06 15:26:04 -0800681 vvfl = kzalloc(len, GFP_KERNEL);
Jacob Keller504398f2017-10-27 11:06:50 -0400682 if (!vvfl) {
683 spin_unlock_bh(&adapter->mac_vlan_list_lock);
Greg Rose62683ab2013-12-21 06:13:01 +0000684 return;
Jacob Keller504398f2017-10-27 11:06:50 -0400685 }
Mitch Williams249c8b82014-05-10 04:49:04 +0000686
Greg Rose62683ab2013-12-21 06:13:01 +0000687 vvfl->vsi_id = adapter->vsi_res->vsi_id;
688 vvfl->num_elements = count;
689 list_for_each_entry_safe(f, ftmp, &adapter->vlan_filter_list, list) {
690 if (f->remove) {
691 vvfl->vlan_id[i] = f->vlan;
692 i++;
693 list_del(&f->list);
694 kfree(f);
Mitch Williams0e8d95f892016-05-16 10:26:36 -0700695 if (i == count)
696 break;
Greg Rose62683ab2013-12-21 06:13:01 +0000697 }
698 }
Mitch Williams1418c342015-10-21 19:47:12 -0400699 if (!more)
700 adapter->aq_required &= ~I40EVF_FLAG_AQ_DEL_VLAN_FILTER;
Jacob Keller504398f2017-10-27 11:06:50 -0400701
702 spin_unlock_bh(&adapter->mac_vlan_list_lock);
703
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700704 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_DEL_VLAN, (u8 *)vvfl, len);
Mitch Williamsfc86a972014-06-04 20:41:38 +0000705 kfree(vvfl);
Greg Rose62683ab2013-12-21 06:13:01 +0000706}
707
708/**
709 * i40evf_set_promiscuous
710 * @adapter: adapter structure
711 * @flags: bitmask to control unicast/multicast promiscuous.
712 *
713 * Request that the PF enable promiscuous mode for our VSI.
714 **/
715void i40evf_set_promiscuous(struct i40evf_adapter *adapter, int flags)
716{
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700717 struct virtchnl_promisc_info vpi;
Anjali Singhai Jainf42a5c72016-05-03 15:13:10 -0700718 int promisc_all;
Greg Rose62683ab2013-12-21 06:13:01 +0000719
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700720 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
Greg Rose62683ab2013-12-21 06:13:01 +0000721 /* bail because we already have a command pending */
Shannon Nelsonfb43201f2015-08-26 15:14:17 -0400722 dev_err(&adapter->pdev->dev, "Cannot set promiscuous mode, command %d pending\n",
723 adapter->current_op);
Greg Rose62683ab2013-12-21 06:13:01 +0000724 return;
725 }
Anjali Singhai Jain47d34832016-04-12 08:30:52 -0700726
Jesse Brandeburgff3f4cc2017-05-11 11:23:16 -0700727 promisc_all = FLAG_VF_UNICAST_PROMISC |
728 FLAG_VF_MULTICAST_PROMISC;
Anjali Singhai Jainf42a5c72016-05-03 15:13:10 -0700729 if ((flags & promisc_all) == promisc_all) {
Anjali Singhai Jain47d34832016-04-12 08:30:52 -0700730 adapter->flags |= I40EVF_FLAG_PROMISC_ON;
731 adapter->aq_required &= ~I40EVF_FLAG_AQ_REQUEST_PROMISC;
732 dev_info(&adapter->pdev->dev, "Entering promiscuous mode\n");
Anjali Singhai Jainf42a5c72016-05-03 15:13:10 -0700733 }
734
Jesse Brandeburgff3f4cc2017-05-11 11:23:16 -0700735 if (flags & FLAG_VF_MULTICAST_PROMISC) {
Anjali Singhai Jainf42a5c72016-05-03 15:13:10 -0700736 adapter->flags |= I40EVF_FLAG_ALLMULTI_ON;
737 adapter->aq_required &= ~I40EVF_FLAG_AQ_REQUEST_ALLMULTI;
738 dev_info(&adapter->pdev->dev, "Entering multicast promiscuous mode\n");
739 }
740
741 if (!flags) {
Anjali Singhai Jain47d34832016-04-12 08:30:52 -0700742 adapter->flags &= ~I40EVF_FLAG_PROMISC_ON;
743 adapter->aq_required &= ~I40EVF_FLAG_AQ_RELEASE_PROMISC;
744 dev_info(&adapter->pdev->dev, "Leaving promiscuous mode\n");
745 }
746
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700747 adapter->current_op = VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE;
Greg Rose62683ab2013-12-21 06:13:01 +0000748 vpi.vsi_id = adapter->vsi_res->vsi_id;
749 vpi.flags = flags;
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700750 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE,
Greg Rose62683ab2013-12-21 06:13:01 +0000751 (u8 *)&vpi, sizeof(vpi));
752}
753
754/**
755 * i40evf_request_stats
756 * @adapter: adapter structure
757 *
758 * Request VSI statistics from PF.
759 **/
760void i40evf_request_stats(struct i40evf_adapter *adapter)
761{
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700762 struct virtchnl_queue_select vqs;
Mitch Williams75a64432014-11-11 20:02:42 +0000763
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700764 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
Greg Rose62683ab2013-12-21 06:13:01 +0000765 /* no error message, this isn't crucial */
766 return;
767 }
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700768 adapter->current_op = VIRTCHNL_OP_GET_STATS;
Greg Rose62683ab2013-12-21 06:13:01 +0000769 vqs.vsi_id = adapter->vsi_res->vsi_id;
770 /* queue maps are ignored for this message - only the vsi is used */
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700771 if (i40evf_send_pf_msg(adapter, VIRTCHNL_OP_GET_STATS,
Greg Rose62683ab2013-12-21 06:13:01 +0000772 (u8 *)&vqs, sizeof(vqs)))
773 /* if the request failed, don't lock out others */
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700774 adapter->current_op = VIRTCHNL_OP_UNKNOWN;
Greg Rose62683ab2013-12-21 06:13:01 +0000775}
Mitch Williams43a3d9b2016-04-12 08:30:44 -0700776
777/**
778 * i40evf_get_hena
779 * @adapter: adapter structure
780 *
781 * Request hash enable capabilities from PF
782 **/
783void i40evf_get_hena(struct i40evf_adapter *adapter)
784{
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700785 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
Mitch Williams43a3d9b2016-04-12 08:30:44 -0700786 /* bail because we already have a command pending */
787 dev_err(&adapter->pdev->dev, "Cannot get RSS hash capabilities, command %d pending\n",
788 adapter->current_op);
789 return;
790 }
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700791 adapter->current_op = VIRTCHNL_OP_GET_RSS_HENA_CAPS;
Mitch Williams43a3d9b2016-04-12 08:30:44 -0700792 adapter->aq_required &= ~I40EVF_FLAG_AQ_GET_HENA;
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700793 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_GET_RSS_HENA_CAPS,
Mitch Williams43a3d9b2016-04-12 08:30:44 -0700794 NULL, 0);
795}
796
797/**
798 * i40evf_set_hena
799 * @adapter: adapter structure
800 *
801 * Request the PF to set our RSS hash capabilities
802 **/
803void i40evf_set_hena(struct i40evf_adapter *adapter)
804{
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700805 struct virtchnl_rss_hena vrh;
Mitch Williams43a3d9b2016-04-12 08:30:44 -0700806
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700807 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
Mitch Williams43a3d9b2016-04-12 08:30:44 -0700808 /* bail because we already have a command pending */
809 dev_err(&adapter->pdev->dev, "Cannot set RSS hash enable, command %d pending\n",
810 adapter->current_op);
811 return;
812 }
813 vrh.hena = adapter->hena;
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700814 adapter->current_op = VIRTCHNL_OP_SET_RSS_HENA;
Mitch Williams43a3d9b2016-04-12 08:30:44 -0700815 adapter->aq_required &= ~I40EVF_FLAG_AQ_SET_HENA;
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700816 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_SET_RSS_HENA,
Mitch Williams43a3d9b2016-04-12 08:30:44 -0700817 (u8 *)&vrh, sizeof(vrh));
818}
819
820/**
821 * i40evf_set_rss_key
822 * @adapter: adapter structure
823 *
824 * Request the PF to set our RSS hash key
825 **/
826void i40evf_set_rss_key(struct i40evf_adapter *adapter)
827{
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700828 struct virtchnl_rss_key *vrk;
Mitch Williams43a3d9b2016-04-12 08:30:44 -0700829 int len;
830
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700831 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
Mitch Williams43a3d9b2016-04-12 08:30:44 -0700832 /* bail because we already have a command pending */
833 dev_err(&adapter->pdev->dev, "Cannot set RSS key, command %d pending\n",
834 adapter->current_op);
835 return;
836 }
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700837 len = sizeof(struct virtchnl_rss_key) +
Mitch Williams43a3d9b2016-04-12 08:30:44 -0700838 (adapter->rss_key_size * sizeof(u8)) - 1;
839 vrk = kzalloc(len, GFP_KERNEL);
840 if (!vrk)
841 return;
842 vrk->vsi_id = adapter->vsi.id;
843 vrk->key_len = adapter->rss_key_size;
844 memcpy(vrk->key, adapter->rss_key, adapter->rss_key_size);
845
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700846 adapter->current_op = VIRTCHNL_OP_CONFIG_RSS_KEY;
Mitch Williams43a3d9b2016-04-12 08:30:44 -0700847 adapter->aq_required &= ~I40EVF_FLAG_AQ_SET_RSS_KEY;
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700848 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_CONFIG_RSS_KEY,
Mitch Williams43a3d9b2016-04-12 08:30:44 -0700849 (u8 *)vrk, len);
850 kfree(vrk);
851}
852
853/**
854 * i40evf_set_rss_lut
855 * @adapter: adapter structure
856 *
857 * Request the PF to set our RSS lookup table
858 **/
859void i40evf_set_rss_lut(struct i40evf_adapter *adapter)
860{
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700861 struct virtchnl_rss_lut *vrl;
Mitch Williams43a3d9b2016-04-12 08:30:44 -0700862 int len;
863
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700864 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
Mitch Williams43a3d9b2016-04-12 08:30:44 -0700865 /* bail because we already have a command pending */
866 dev_err(&adapter->pdev->dev, "Cannot set RSS LUT, command %d pending\n",
867 adapter->current_op);
868 return;
869 }
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700870 len = sizeof(struct virtchnl_rss_lut) +
Mitch Williams43a3d9b2016-04-12 08:30:44 -0700871 (adapter->rss_lut_size * sizeof(u8)) - 1;
872 vrl = kzalloc(len, GFP_KERNEL);
873 if (!vrl)
874 return;
875 vrl->vsi_id = adapter->vsi.id;
876 vrl->lut_entries = adapter->rss_lut_size;
877 memcpy(vrl->lut, adapter->rss_lut, adapter->rss_lut_size);
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700878 adapter->current_op = VIRTCHNL_OP_CONFIG_RSS_LUT;
Mitch Williams43a3d9b2016-04-12 08:30:44 -0700879 adapter->aq_required &= ~I40EVF_FLAG_AQ_SET_RSS_LUT;
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700880 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_CONFIG_RSS_LUT,
Mitch Williams43a3d9b2016-04-12 08:30:44 -0700881 (u8 *)vrl, len);
882 kfree(vrl);
883}
884
Mitch Williams625777e2014-02-20 19:29:05 -0800885/**
Mariusz Stachura87743702017-07-17 22:09:45 -0700886 * i40evf_enable_vlan_stripping
887 * @adapter: adapter structure
888 *
889 * Request VLAN header stripping to be enabled
890 **/
891void i40evf_enable_vlan_stripping(struct i40evf_adapter *adapter)
892{
893 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
894 /* bail because we already have a command pending */
895 dev_err(&adapter->pdev->dev, "Cannot enable stripping, command %d pending\n",
896 adapter->current_op);
897 return;
898 }
899 adapter->current_op = VIRTCHNL_OP_ENABLE_VLAN_STRIPPING;
900 adapter->aq_required &= ~I40EVF_FLAG_AQ_ENABLE_VLAN_STRIPPING;
901 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_ENABLE_VLAN_STRIPPING,
902 NULL, 0);
903}
904
905/**
906 * i40evf_disable_vlan_stripping
907 * @adapter: adapter structure
908 *
909 * Request VLAN header stripping to be disabled
910 **/
911void i40evf_disable_vlan_stripping(struct i40evf_adapter *adapter)
912{
913 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
914 /* bail because we already have a command pending */
915 dev_err(&adapter->pdev->dev, "Cannot disable stripping, command %d pending\n",
916 adapter->current_op);
917 return;
918 }
919 adapter->current_op = VIRTCHNL_OP_DISABLE_VLAN_STRIPPING;
920 adapter->aq_required &= ~I40EVF_FLAG_AQ_DISABLE_VLAN_STRIPPING;
921 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_DISABLE_VLAN_STRIPPING,
922 NULL, 0);
923}
924
925/**
Mitch Williamsfe458e52016-08-04 11:37:02 -0700926 * i40evf_print_link_message - print link up or down
927 * @adapter: adapter structure
928 *
929 * Log a message telling the world of our wonderous link status
930 */
931static void i40evf_print_link_message(struct i40evf_adapter *adapter)
932{
933 struct net_device *netdev = adapter->netdev;
934 char *speed = "Unknown ";
935
936 if (!adapter->link_up) {
937 netdev_info(netdev, "NIC Link is Down\n");
938 return;
939 }
940
941 switch (adapter->link_speed) {
942 case I40E_LINK_SPEED_40GB:
943 speed = "40 G";
944 break;
Carolyn Wyborny31232372016-11-21 13:03:48 -0800945 case I40E_LINK_SPEED_25GB:
946 speed = "25 G";
947 break;
Mitch Williamsfe458e52016-08-04 11:37:02 -0700948 case I40E_LINK_SPEED_20GB:
949 speed = "20 G";
950 break;
951 case I40E_LINK_SPEED_10GB:
952 speed = "10 G";
953 break;
954 case I40E_LINK_SPEED_1GB:
955 speed = "1000 M";
956 break;
957 case I40E_LINK_SPEED_100MB:
958 speed = "100 M";
959 break;
960 default:
961 break;
962 }
963
964 netdev_info(netdev, "NIC Link is Up %sbps Full Duplex\n", speed);
965}
966
967/**
Mitch Williams625777e2014-02-20 19:29:05 -0800968 * i40evf_request_reset
969 * @adapter: adapter structure
970 *
971 * Request that the PF reset this VF. No response is expected.
972 **/
973void i40evf_request_reset(struct i40evf_adapter *adapter)
974{
975 /* Don't check CURRENT_OP - this is always higher priority */
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700976 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_RESET_VF, NULL, 0);
977 adapter->current_op = VIRTCHNL_OP_UNKNOWN;
Mitch Williams625777e2014-02-20 19:29:05 -0800978}
Greg Rose62683ab2013-12-21 06:13:01 +0000979
980/**
981 * i40evf_virtchnl_completion
982 * @adapter: adapter structure
983 * @v_opcode: opcode sent by PF
984 * @v_retval: retval sent by PF
985 * @msg: message sent by PF
986 * @msglen: message length
987 *
988 * Asynchronous completion function for admin queue messages. Rather than busy
989 * wait, we fire off our requests and assume that no errors will be returned.
990 * This function handles the reply messages.
991 **/
992void i40evf_virtchnl_completion(struct i40evf_adapter *adapter,
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700993 enum virtchnl_ops v_opcode,
Greg Rose62683ab2013-12-21 06:13:01 +0000994 i40e_status v_retval,
995 u8 *msg, u16 msglen)
996{
997 struct net_device *netdev = adapter->netdev;
998
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700999 if (v_opcode == VIRTCHNL_OP_EVENT) {
1000 struct virtchnl_pf_event *vpe =
1001 (struct virtchnl_pf_event *)msg;
Greg Rose62683ab2013-12-21 06:13:01 +00001002 switch (vpe->event) {
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -07001003 case VIRTCHNL_EVENT_LINK_CHANGE:
Mitch Williamsfe458e52016-08-04 11:37:02 -07001004 adapter->link_speed =
1005 vpe->event_data.link_event.link_speed;
1006 if (adapter->link_up !=
1007 vpe->event_data.link_event.link_status) {
1008 adapter->link_up =
1009 vpe->event_data.link_event.link_status;
Sridhar Samudrala3f341ac2016-09-01 22:27:27 +02001010 if (adapter->link_up) {
1011 netif_tx_start_all_queues(netdev);
1012 netif_carrier_on(netdev);
1013 } else {
1014 netif_tx_stop_all_queues(netdev);
1015 netif_carrier_off(netdev);
1016 }
Mitch Williamsfe458e52016-08-04 11:37:02 -07001017 i40evf_print_link_message(adapter);
Greg Rose62683ab2013-12-21 06:13:01 +00001018 }
1019 break;
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -07001020 case VIRTCHNL_EVENT_RESET_IMPENDING:
Mitch Williamsef8693e2014-02-13 03:48:53 -08001021 dev_info(&adapter->pdev->dev, "PF reset warning received\n");
1022 if (!(adapter->flags & I40EVF_FLAG_RESET_PENDING)) {
1023 adapter->flags |= I40EVF_FLAG_RESET_PENDING;
1024 dev_info(&adapter->pdev->dev, "Scheduling reset task\n");
1025 schedule_work(&adapter->reset_task);
1026 }
Greg Rose62683ab2013-12-21 06:13:01 +00001027 break;
1028 default:
Shannon Nelsonfb43201f2015-08-26 15:14:17 -04001029 dev_err(&adapter->pdev->dev, "Unknown event %d from PF\n",
1030 vpe->event);
Greg Rose62683ab2013-12-21 06:13:01 +00001031 break;
Greg Rose62683ab2013-12-21 06:13:01 +00001032 }
1033 return;
1034 }
Greg Rose62683ab2013-12-21 06:13:01 +00001035 if (v_retval) {
Mitch Williams8d8f2292015-10-21 19:47:11 -04001036 switch (v_opcode) {
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -07001037 case VIRTCHNL_OP_ADD_VLAN:
Mitch Williams8d8f2292015-10-21 19:47:11 -04001038 dev_err(&adapter->pdev->dev, "Failed to add VLAN filter, error %s\n",
1039 i40evf_stat_str(&adapter->hw, v_retval));
1040 break;
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -07001041 case VIRTCHNL_OP_ADD_ETH_ADDR:
Mitch Williams8d8f2292015-10-21 19:47:11 -04001042 dev_err(&adapter->pdev->dev, "Failed to add MAC filter, error %s\n",
1043 i40evf_stat_str(&adapter->hw, v_retval));
1044 break;
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -07001045 case VIRTCHNL_OP_DEL_VLAN:
Mitch Williams8d8f2292015-10-21 19:47:11 -04001046 dev_err(&adapter->pdev->dev, "Failed to delete VLAN filter, error %s\n",
1047 i40evf_stat_str(&adapter->hw, v_retval));
1048 break;
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -07001049 case VIRTCHNL_OP_DEL_ETH_ADDR:
Mitch Williams8d8f2292015-10-21 19:47:11 -04001050 dev_err(&adapter->pdev->dev, "Failed to delete MAC filter, error %s\n",
1051 i40evf_stat_str(&adapter->hw, v_retval));
1052 break;
1053 default:
1054 dev_err(&adapter->pdev->dev, "PF returned error %d (%s) to our request %d\n",
1055 v_retval,
1056 i40evf_stat_str(&adapter->hw, v_retval),
1057 v_opcode);
1058 }
Greg Rose62683ab2013-12-21 06:13:01 +00001059 }
1060 switch (v_opcode) {
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -07001061 case VIRTCHNL_OP_GET_STATS: {
Greg Rose62683ab2013-12-21 06:13:01 +00001062 struct i40e_eth_stats *stats =
1063 (struct i40e_eth_stats *)msg;
Tobias Klauser4a0a3ab2017-04-06 08:46:28 +02001064 netdev->stats.rx_packets = stats->rx_unicast +
1065 stats->rx_multicast +
1066 stats->rx_broadcast;
1067 netdev->stats.tx_packets = stats->tx_unicast +
1068 stats->tx_multicast +
1069 stats->tx_broadcast;
1070 netdev->stats.rx_bytes = stats->rx_bytes;
1071 netdev->stats.tx_bytes = stats->tx_bytes;
1072 netdev->stats.tx_errors = stats->tx_errors;
1073 netdev->stats.rx_dropped = stats->rx_discards;
1074 netdev->stats.tx_dropped = stats->tx_discards;
Greg Rose62683ab2013-12-21 06:13:01 +00001075 adapter->current_stats = *stats;
1076 }
1077 break;
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -07001078 case VIRTCHNL_OP_GET_VF_RESOURCES: {
1079 u16 len = sizeof(struct virtchnl_vf_resource) +
Mitch Williamse6d038d2015-06-04 16:23:58 -04001080 I40E_MAX_VF_VSI *
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -07001081 sizeof(struct virtchnl_vsi_resource);
Mitch Williamse6d038d2015-06-04 16:23:58 -04001082 memcpy(adapter->vf_res, msg, min(msglen, len));
1083 i40e_vf_parse_hw_config(&adapter->hw, adapter->vf_res);
Mitch Williams8552d852015-08-31 19:54:51 -04001084 /* restore current mac address */
1085 ether_addr_copy(adapter->hw.mac.addr, netdev->dev_addr);
Mitch Williamse6d038d2015-06-04 16:23:58 -04001086 i40evf_process_config(adapter);
1087 }
1088 break;
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -07001089 case VIRTCHNL_OP_ENABLE_QUEUES:
Greg Rose62683ab2013-12-21 06:13:01 +00001090 /* enable transmits */
1091 i40evf_irq_enable(adapter, true);
Greg Rose62683ab2013-12-21 06:13:01 +00001092 break;
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -07001093 case VIRTCHNL_OP_DISABLE_QUEUES:
Mitch Williamse284fc82015-03-27 00:12:09 -07001094 i40evf_free_all_tx_resources(adapter);
1095 i40evf_free_all_rx_resources(adapter);
Sudheer Mogilappagarife2647a2017-06-23 04:24:44 -04001096 if (adapter->state == __I40EVF_DOWN_PENDING) {
Mitch Williams209dc4d2015-12-09 15:50:27 -08001097 adapter->state = __I40EVF_DOWN;
Sudheer Mogilappagarife2647a2017-06-23 04:24:44 -04001098 wake_up(&adapter->down_waitqueue);
1099 }
Greg Rose62683ab2013-12-21 06:13:01 +00001100 break;
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -07001101 case VIRTCHNL_OP_VERSION:
1102 case VIRTCHNL_OP_CONFIG_IRQ_MAP:
Mitch Williamsed636962015-04-07 19:45:32 -04001103 /* Don't display an error if we get these out of sequence.
1104 * If the firmware needed to get kicked, we'll get these and
1105 * it's no problem.
1106 */
1107 if (v_opcode != adapter->current_op)
1108 return;
Greg Rose62683ab2013-12-21 06:13:01 +00001109 break;
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -07001110 case VIRTCHNL_OP_IWARP:
Mitch Williamsed0e8942017-01-24 10:23:59 -08001111 /* Gobble zero-length replies from the PF. They indicate that
1112 * a previous message was received OK, and the client doesn't
1113 * care about that.
1114 */
1115 if (msglen && CLIENT_ENABLED(adapter))
1116 i40evf_notify_client_message(&adapter->vsi,
1117 msg, msglen);
1118 break;
1119
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -07001120 case VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP:
Mitch Williamse5f77f42017-02-09 23:35:18 -08001121 adapter->client_pending &=
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -07001122 ~(BIT(VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP));
Mitch Williamse5f77f42017-02-09 23:35:18 -08001123 break;
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -07001124 case VIRTCHNL_OP_GET_RSS_HENA_CAPS: {
Jesse Brandeburgf0adc6e2017-05-11 11:23:15 -07001125 struct virtchnl_rss_hena *vrh = (struct virtchnl_rss_hena *)msg;
Mitch Williams43a3d9b2016-04-12 08:30:44 -07001126 if (msglen == sizeof(*vrh))
1127 adapter->hena = vrh->hena;
1128 else
1129 dev_warn(&adapter->pdev->dev,
1130 "Invalid message %d from PF\n", v_opcode);
1131 }
1132 break;
Alan Brady5b36e8d2017-08-22 06:57:50 -04001133 case VIRTCHNL_OP_REQUEST_QUEUES: {
1134 struct virtchnl_vf_res_request *vfres =
1135 (struct virtchnl_vf_res_request *)msg;
Alan Brady17a94222017-10-11 14:49:43 -07001136 if (vfres->num_queue_pairs != adapter->num_req_queues) {
Alan Brady5b36e8d2017-08-22 06:57:50 -04001137 dev_info(&adapter->pdev->dev,
1138 "Requested %d queues, PF can support %d\n",
1139 adapter->num_req_queues,
1140 vfres->num_queue_pairs);
1141 adapter->num_req_queues = 0;
Alan Brady17a94222017-10-11 14:49:43 -07001142 adapter->flags &= ~I40EVF_FLAG_REINIT_ITR_NEEDED;
Alan Brady5b36e8d2017-08-22 06:57:50 -04001143 }
1144 }
1145 break;
Greg Rose62683ab2013-12-21 06:13:01 +00001146 default:
Mitch Williamsed0e8942017-01-24 10:23:59 -08001147 if (adapter->current_op && (v_opcode != adapter->current_op))
Mitch Williamsed636962015-04-07 19:45:32 -04001148 dev_warn(&adapter->pdev->dev, "Expected response %d from PF, received %d\n",
1149 adapter->current_op, v_opcode);
Greg Rose62683ab2013-12-21 06:13:01 +00001150 break;
1151 } /* switch v_opcode */
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -07001152 adapter->current_op = VIRTCHNL_OP_UNKNOWN;
Greg Rose62683ab2013-12-21 06:13:01 +00001153}