blob: 82e6b115be87c17381093aff780cd43e4b0926bf [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;
Alexander Duyckd4942d52017-12-29 08:51:20 -0500347 struct virtchnl_vector_map *vecmap;
Greg Rose62683ab2013-12-21 06:13:01 +0000348 int v_idx, q_vectors, len;
349 struct i40e_q_vector *q_vector;
350
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700351 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
Greg Rose62683ab2013-12-21 06:13:01 +0000352 /* bail because we already have a command pending */
Shannon Nelsonfb43201f2015-08-26 15:14:17 -0400353 dev_err(&adapter->pdev->dev, "Cannot map queues to vectors, command %d pending\n",
354 adapter->current_op);
Greg Rose62683ab2013-12-21 06:13:01 +0000355 return;
356 }
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700357 adapter->current_op = VIRTCHNL_OP_CONFIG_IRQ_MAP;
Greg Rose62683ab2013-12-21 06:13:01 +0000358
359 q_vectors = adapter->num_msix_vectors - NONQ_VECS;
360
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700361 len = sizeof(struct virtchnl_irq_map_info) +
Greg Rose62683ab2013-12-21 06:13:01 +0000362 (adapter->num_msix_vectors *
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700363 sizeof(struct virtchnl_vector_map));
Mitch Williamsa85088d2015-11-06 15:26:04 -0800364 vimi = kzalloc(len, GFP_KERNEL);
Mitch Williams249c8b82014-05-10 04:49:04 +0000365 if (!vimi)
Greg Rose62683ab2013-12-21 06:13:01 +0000366 return;
Greg Rose62683ab2013-12-21 06:13:01 +0000367
368 vimi->num_vectors = adapter->num_msix_vectors;
369 /* Queue vectors first */
370 for (v_idx = 0; v_idx < q_vectors; v_idx++) {
Alexander Duyckd4942d52017-12-29 08:51:20 -0500371 q_vector = &adapter->q_vectors[v_idx];
372 vecmap = &vimi->vecmap[v_idx];
373
374 vecmap->vsi_id = adapter->vsi_res->vsi_id;
375 vecmap->vector_id = v_idx + NONQ_VECS;
376 vecmap->txq_map = q_vector->ring_mask;
377 vecmap->rxq_map = q_vector->ring_mask;
378 vecmap->rxitr_idx = I40E_RX_ITR;
379 vecmap->txitr_idx = I40E_TX_ITR;
Greg Rose62683ab2013-12-21 06:13:01 +0000380 }
381 /* Misc vector last - this is only for AdminQ messages */
Alexander Duyckd4942d52017-12-29 08:51:20 -0500382 vecmap = &vimi->vecmap[v_idx];
383 vecmap->vsi_id = adapter->vsi_res->vsi_id;
384 vecmap->vector_id = 0;
385 vecmap->txq_map = 0;
386 vecmap->rxq_map = 0;
Greg Rose62683ab2013-12-21 06:13:01 +0000387
Mitch Williamsfc86a972014-06-04 20:41:38 +0000388 adapter->aq_required &= ~I40EVF_FLAG_AQ_MAP_VECTORS;
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700389 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_CONFIG_IRQ_MAP,
Greg Rose62683ab2013-12-21 06:13:01 +0000390 (u8 *)vimi, len);
391 kfree(vimi);
Greg Rose62683ab2013-12-21 06:13:01 +0000392}
393
394/**
Alan Brady5b36e8d2017-08-22 06:57:50 -0400395 * i40evf_request_queues
396 * @adapter: adapter structure
397 * @num: number of requested queues
398 *
399 * We get a default number of queues from the PF. This enables us to request a
400 * different number. Returns 0 on success, negative on failure
401 **/
402int i40evf_request_queues(struct i40evf_adapter *adapter, int num)
403{
404 struct virtchnl_vf_res_request vfres;
405
406 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
407 /* bail because we already have a command pending */
408 dev_err(&adapter->pdev->dev, "Cannot request queues, command %d pending\n",
409 adapter->current_op);
410 return -EBUSY;
411 }
412
413 vfres.num_queue_pairs = num;
414
415 adapter->current_op = VIRTCHNL_OP_REQUEST_QUEUES;
Alan Brady17a94222017-10-11 14:49:43 -0700416 adapter->flags |= I40EVF_FLAG_REINIT_ITR_NEEDED;
Alan Brady5b36e8d2017-08-22 06:57:50 -0400417 return i40evf_send_pf_msg(adapter, VIRTCHNL_OP_REQUEST_QUEUES,
418 (u8 *)&vfres, sizeof(vfres));
419}
420
421/**
Greg Rose62683ab2013-12-21 06:13:01 +0000422 * i40evf_add_ether_addrs
423 * @adapter: adapter structure
424 * @addrs: the MAC address filters to add (contiguous)
425 * @count: number of filters
426 *
427 * Request that the PF add one or more addresses to our filters.
428 **/
429void i40evf_add_ether_addrs(struct i40evf_adapter *adapter)
430{
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700431 struct virtchnl_ether_addr_list *veal;
Greg Rose62683ab2013-12-21 06:13:01 +0000432 int len, i = 0, count = 0;
433 struct i40evf_mac_filter *f;
Mitch Williams1418c342015-10-21 19:47:12 -0400434 bool more = false;
Greg Rose62683ab2013-12-21 06:13:01 +0000435
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700436 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
Greg Rose62683ab2013-12-21 06:13:01 +0000437 /* bail because we already have a command pending */
Shannon Nelsonfb43201f2015-08-26 15:14:17 -0400438 dev_err(&adapter->pdev->dev, "Cannot add filters, command %d pending\n",
439 adapter->current_op);
Greg Rose62683ab2013-12-21 06:13:01 +0000440 return;
441 }
Jacob Keller504398f2017-10-27 11:06:50 -0400442
443 spin_lock_bh(&adapter->mac_vlan_list_lock);
444
Greg Rose62683ab2013-12-21 06:13:01 +0000445 list_for_each_entry(f, &adapter->mac_filter_list, list) {
446 if (f->add)
447 count++;
448 }
449 if (!count) {
450 adapter->aq_required &= ~I40EVF_FLAG_AQ_ADD_MAC_FILTER;
Jacob Keller504398f2017-10-27 11:06:50 -0400451 spin_unlock_bh(&adapter->mac_vlan_list_lock);
Greg Rose62683ab2013-12-21 06:13:01 +0000452 return;
453 }
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700454 adapter->current_op = VIRTCHNL_OP_ADD_ETH_ADDR;
Greg Rose62683ab2013-12-21 06:13:01 +0000455
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700456 len = sizeof(struct virtchnl_ether_addr_list) +
457 (count * sizeof(struct virtchnl_ether_addr));
Greg Rose62683ab2013-12-21 06:13:01 +0000458 if (len > I40EVF_MAX_AQ_BUF_SIZE) {
Shannon Nelsonfb43201f2015-08-26 15:14:17 -0400459 dev_warn(&adapter->pdev->dev, "Too many add MAC changes in one request\n");
Greg Rose62683ab2013-12-21 06:13:01 +0000460 count = (I40EVF_MAX_AQ_BUF_SIZE -
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700461 sizeof(struct virtchnl_ether_addr_list)) /
462 sizeof(struct virtchnl_ether_addr);
463 len = sizeof(struct virtchnl_ether_addr_list) +
464 (count * sizeof(struct virtchnl_ether_addr));
Mitch Williams1418c342015-10-21 19:47:12 -0400465 more = true;
Greg Rose62683ab2013-12-21 06:13:01 +0000466 }
467
Wei Yongjun03f431b2018-01-12 02:27:13 +0000468 veal = kzalloc(len, GFP_ATOMIC);
Jacob Keller504398f2017-10-27 11:06:50 -0400469 if (!veal) {
470 spin_unlock_bh(&adapter->mac_vlan_list_lock);
Greg Rose62683ab2013-12-21 06:13:01 +0000471 return;
Jacob Keller504398f2017-10-27 11:06:50 -0400472 }
Mitch Williams249c8b82014-05-10 04:49:04 +0000473
Greg Rose62683ab2013-12-21 06:13:01 +0000474 veal->vsi_id = adapter->vsi_res->vsi_id;
475 veal->num_elements = count;
476 list_for_each_entry(f, &adapter->mac_filter_list, list) {
477 if (f->add) {
Greg Rose9a173902014-05-22 06:32:02 +0000478 ether_addr_copy(veal->list[i].addr, f->macaddr);
Greg Rose62683ab2013-12-21 06:13:01 +0000479 i++;
480 f->add = false;
Mitch Williams0e8d95f892016-05-16 10:26:36 -0700481 if (i == count)
482 break;
Greg Rose62683ab2013-12-21 06:13:01 +0000483 }
484 }
Mitch Williams1418c342015-10-21 19:47:12 -0400485 if (!more)
486 adapter->aq_required &= ~I40EVF_FLAG_AQ_ADD_MAC_FILTER;
Jacob Keller504398f2017-10-27 11:06:50 -0400487
488 spin_unlock_bh(&adapter->mac_vlan_list_lock);
489
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700490 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_ADD_ETH_ADDR,
Greg Rose62683ab2013-12-21 06:13:01 +0000491 (u8 *)veal, len);
492 kfree(veal);
Greg Rose62683ab2013-12-21 06:13:01 +0000493}
494
495/**
496 * i40evf_del_ether_addrs
497 * @adapter: adapter structure
498 * @addrs: the MAC address filters to remove (contiguous)
499 * @count: number of filtes
500 *
501 * Request that the PF remove one or more addresses from our filters.
502 **/
503void i40evf_del_ether_addrs(struct i40evf_adapter *adapter)
504{
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700505 struct virtchnl_ether_addr_list *veal;
Greg Rose62683ab2013-12-21 06:13:01 +0000506 struct i40evf_mac_filter *f, *ftmp;
507 int len, i = 0, count = 0;
Mitch Williams1418c342015-10-21 19:47:12 -0400508 bool more = false;
Greg Rose62683ab2013-12-21 06:13:01 +0000509
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700510 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
Greg Rose62683ab2013-12-21 06:13:01 +0000511 /* bail because we already have a command pending */
Shannon Nelsonfb43201f2015-08-26 15:14:17 -0400512 dev_err(&adapter->pdev->dev, "Cannot remove filters, command %d pending\n",
513 adapter->current_op);
Greg Rose62683ab2013-12-21 06:13:01 +0000514 return;
515 }
Jacob Keller504398f2017-10-27 11:06:50 -0400516
517 spin_lock_bh(&adapter->mac_vlan_list_lock);
518
Greg Rose62683ab2013-12-21 06:13:01 +0000519 list_for_each_entry(f, &adapter->mac_filter_list, list) {
520 if (f->remove)
521 count++;
522 }
523 if (!count) {
524 adapter->aq_required &= ~I40EVF_FLAG_AQ_DEL_MAC_FILTER;
Jacob Keller504398f2017-10-27 11:06:50 -0400525 spin_unlock_bh(&adapter->mac_vlan_list_lock);
Greg Rose62683ab2013-12-21 06:13:01 +0000526 return;
527 }
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700528 adapter->current_op = VIRTCHNL_OP_DEL_ETH_ADDR;
Greg Rose62683ab2013-12-21 06:13:01 +0000529
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700530 len = sizeof(struct virtchnl_ether_addr_list) +
531 (count * sizeof(struct virtchnl_ether_addr));
Greg Rose62683ab2013-12-21 06:13:01 +0000532 if (len > I40EVF_MAX_AQ_BUF_SIZE) {
Shannon Nelsonfb43201f2015-08-26 15:14:17 -0400533 dev_warn(&adapter->pdev->dev, "Too many delete MAC changes in one request\n");
Greg Rose62683ab2013-12-21 06:13:01 +0000534 count = (I40EVF_MAX_AQ_BUF_SIZE -
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700535 sizeof(struct virtchnl_ether_addr_list)) /
536 sizeof(struct virtchnl_ether_addr);
537 len = sizeof(struct virtchnl_ether_addr_list) +
538 (count * sizeof(struct virtchnl_ether_addr));
Mitch Williams1418c342015-10-21 19:47:12 -0400539 more = true;
Greg Rose62683ab2013-12-21 06:13:01 +0000540 }
Wei Yongjun03f431b2018-01-12 02:27:13 +0000541 veal = kzalloc(len, GFP_ATOMIC);
Jacob Keller504398f2017-10-27 11:06:50 -0400542 if (!veal) {
543 spin_unlock_bh(&adapter->mac_vlan_list_lock);
Greg Rose62683ab2013-12-21 06:13:01 +0000544 return;
Jacob Keller504398f2017-10-27 11:06:50 -0400545 }
Mitch Williams249c8b82014-05-10 04:49:04 +0000546
Greg Rose62683ab2013-12-21 06:13:01 +0000547 veal->vsi_id = adapter->vsi_res->vsi_id;
548 veal->num_elements = count;
549 list_for_each_entry_safe(f, ftmp, &adapter->mac_filter_list, list) {
550 if (f->remove) {
Greg Rose9a173902014-05-22 06:32:02 +0000551 ether_addr_copy(veal->list[i].addr, f->macaddr);
Greg Rose62683ab2013-12-21 06:13:01 +0000552 i++;
553 list_del(&f->list);
554 kfree(f);
Mitch Williams0e8d95f892016-05-16 10:26:36 -0700555 if (i == count)
556 break;
Greg Rose62683ab2013-12-21 06:13:01 +0000557 }
558 }
Mitch Williams1418c342015-10-21 19:47:12 -0400559 if (!more)
560 adapter->aq_required &= ~I40EVF_FLAG_AQ_DEL_MAC_FILTER;
Jacob Keller504398f2017-10-27 11:06:50 -0400561
562 spin_unlock_bh(&adapter->mac_vlan_list_lock);
563
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700564 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_DEL_ETH_ADDR,
Greg Rose62683ab2013-12-21 06:13:01 +0000565 (u8 *)veal, len);
566 kfree(veal);
Greg Rose62683ab2013-12-21 06:13:01 +0000567}
568
569/**
570 * i40evf_add_vlans
571 * @adapter: adapter structure
572 * @vlans: the VLANs to add
573 * @count: number of VLANs
574 *
575 * Request that the PF add one or more VLAN filters to our VSI.
576 **/
577void i40evf_add_vlans(struct i40evf_adapter *adapter)
578{
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700579 struct virtchnl_vlan_filter_list *vvfl;
Greg Rose62683ab2013-12-21 06:13:01 +0000580 int len, i = 0, count = 0;
581 struct i40evf_vlan_filter *f;
Mitch Williams1418c342015-10-21 19:47:12 -0400582 bool more = false;
Greg Rose62683ab2013-12-21 06:13:01 +0000583
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700584 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
Greg Rose62683ab2013-12-21 06:13:01 +0000585 /* bail because we already have a command pending */
Shannon Nelsonfb43201f2015-08-26 15:14:17 -0400586 dev_err(&adapter->pdev->dev, "Cannot add VLANs, command %d pending\n",
587 adapter->current_op);
Greg Rose62683ab2013-12-21 06:13:01 +0000588 return;
589 }
590
Jacob Keller504398f2017-10-27 11:06:50 -0400591 spin_lock_bh(&adapter->mac_vlan_list_lock);
592
Greg Rose62683ab2013-12-21 06:13:01 +0000593 list_for_each_entry(f, &adapter->vlan_filter_list, list) {
594 if (f->add)
595 count++;
596 }
597 if (!count) {
598 adapter->aq_required &= ~I40EVF_FLAG_AQ_ADD_VLAN_FILTER;
Jacob Keller504398f2017-10-27 11:06:50 -0400599 spin_unlock_bh(&adapter->mac_vlan_list_lock);
Greg Rose62683ab2013-12-21 06:13:01 +0000600 return;
601 }
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700602 adapter->current_op = VIRTCHNL_OP_ADD_VLAN;
Greg Rose62683ab2013-12-21 06:13:01 +0000603
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700604 len = sizeof(struct virtchnl_vlan_filter_list) +
Greg Rose62683ab2013-12-21 06:13:01 +0000605 (count * sizeof(u16));
606 if (len > I40EVF_MAX_AQ_BUF_SIZE) {
Shannon Nelsonfb43201f2015-08-26 15:14:17 -0400607 dev_warn(&adapter->pdev->dev, "Too many add VLAN changes in one request\n");
Greg Rose62683ab2013-12-21 06:13:01 +0000608 count = (I40EVF_MAX_AQ_BUF_SIZE -
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700609 sizeof(struct virtchnl_vlan_filter_list)) /
Greg Rose62683ab2013-12-21 06:13:01 +0000610 sizeof(u16);
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700611 len = sizeof(struct virtchnl_vlan_filter_list) +
Mitch Williams1418c342015-10-21 19:47:12 -0400612 (count * sizeof(u16));
613 more = true;
Greg Rose62683ab2013-12-21 06:13:01 +0000614 }
Wei Yongjun03f431b2018-01-12 02:27:13 +0000615 vvfl = kzalloc(len, GFP_ATOMIC);
Jacob Keller504398f2017-10-27 11:06:50 -0400616 if (!vvfl) {
617 spin_unlock_bh(&adapter->mac_vlan_list_lock);
Greg Rose62683ab2013-12-21 06:13:01 +0000618 return;
Jacob Keller504398f2017-10-27 11:06:50 -0400619 }
Mitch Williams249c8b82014-05-10 04:49:04 +0000620
Greg Rose62683ab2013-12-21 06:13:01 +0000621 vvfl->vsi_id = adapter->vsi_res->vsi_id;
622 vvfl->num_elements = count;
623 list_for_each_entry(f, &adapter->vlan_filter_list, list) {
624 if (f->add) {
625 vvfl->vlan_id[i] = f->vlan;
626 i++;
627 f->add = false;
Mitch Williams0e8d95f892016-05-16 10:26:36 -0700628 if (i == count)
629 break;
Greg Rose62683ab2013-12-21 06:13:01 +0000630 }
631 }
Mitch Williams1418c342015-10-21 19:47:12 -0400632 if (!more)
633 adapter->aq_required &= ~I40EVF_FLAG_AQ_ADD_VLAN_FILTER;
Jacob Keller504398f2017-10-27 11:06:50 -0400634
635 spin_unlock_bh(&adapter->mac_vlan_list_lock);
636
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700637 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_ADD_VLAN, (u8 *)vvfl, len);
Mitch Williamsfc86a972014-06-04 20:41:38 +0000638 kfree(vvfl);
Greg Rose62683ab2013-12-21 06:13:01 +0000639}
640
641/**
642 * i40evf_del_vlans
643 * @adapter: adapter structure
644 * @vlans: the VLANs to remove
645 * @count: number of VLANs
646 *
647 * Request that the PF remove one or more VLAN filters from our VSI.
648 **/
649void i40evf_del_vlans(struct i40evf_adapter *adapter)
650{
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700651 struct virtchnl_vlan_filter_list *vvfl;
Greg Rose62683ab2013-12-21 06:13:01 +0000652 struct i40evf_vlan_filter *f, *ftmp;
653 int len, i = 0, count = 0;
Mitch Williams1418c342015-10-21 19:47:12 -0400654 bool more = false;
Greg Rose62683ab2013-12-21 06:13:01 +0000655
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700656 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
Greg Rose62683ab2013-12-21 06:13:01 +0000657 /* bail because we already have a command pending */
Shannon Nelsonfb43201f2015-08-26 15:14:17 -0400658 dev_err(&adapter->pdev->dev, "Cannot remove VLANs, command %d pending\n",
659 adapter->current_op);
Greg Rose62683ab2013-12-21 06:13:01 +0000660 return;
661 }
662
Jacob Keller504398f2017-10-27 11:06:50 -0400663 spin_lock_bh(&adapter->mac_vlan_list_lock);
664
Greg Rose62683ab2013-12-21 06:13:01 +0000665 list_for_each_entry(f, &adapter->vlan_filter_list, list) {
666 if (f->remove)
667 count++;
668 }
669 if (!count) {
670 adapter->aq_required &= ~I40EVF_FLAG_AQ_DEL_VLAN_FILTER;
Jacob Keller504398f2017-10-27 11:06:50 -0400671 spin_unlock_bh(&adapter->mac_vlan_list_lock);
Greg Rose62683ab2013-12-21 06:13:01 +0000672 return;
673 }
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700674 adapter->current_op = VIRTCHNL_OP_DEL_VLAN;
Greg Rose62683ab2013-12-21 06:13:01 +0000675
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700676 len = sizeof(struct virtchnl_vlan_filter_list) +
Greg Rose62683ab2013-12-21 06:13:01 +0000677 (count * sizeof(u16));
678 if (len > I40EVF_MAX_AQ_BUF_SIZE) {
Shannon Nelsonfb43201f2015-08-26 15:14:17 -0400679 dev_warn(&adapter->pdev->dev, "Too many delete VLAN changes in one request\n");
Greg Rose62683ab2013-12-21 06:13:01 +0000680 count = (I40EVF_MAX_AQ_BUF_SIZE -
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700681 sizeof(struct virtchnl_vlan_filter_list)) /
Greg Rose62683ab2013-12-21 06:13:01 +0000682 sizeof(u16);
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700683 len = sizeof(struct virtchnl_vlan_filter_list) +
Mitch Williams1418c342015-10-21 19:47:12 -0400684 (count * sizeof(u16));
685 more = true;
Greg Rose62683ab2013-12-21 06:13:01 +0000686 }
Wei Yongjun03f431b2018-01-12 02:27:13 +0000687 vvfl = kzalloc(len, GFP_ATOMIC);
Jacob Keller504398f2017-10-27 11:06:50 -0400688 if (!vvfl) {
689 spin_unlock_bh(&adapter->mac_vlan_list_lock);
Greg Rose62683ab2013-12-21 06:13:01 +0000690 return;
Jacob Keller504398f2017-10-27 11:06:50 -0400691 }
Mitch Williams249c8b82014-05-10 04:49:04 +0000692
Greg Rose62683ab2013-12-21 06:13:01 +0000693 vvfl->vsi_id = adapter->vsi_res->vsi_id;
694 vvfl->num_elements = count;
695 list_for_each_entry_safe(f, ftmp, &adapter->vlan_filter_list, list) {
696 if (f->remove) {
697 vvfl->vlan_id[i] = f->vlan;
698 i++;
699 list_del(&f->list);
700 kfree(f);
Mitch Williams0e8d95f892016-05-16 10:26:36 -0700701 if (i == count)
702 break;
Greg Rose62683ab2013-12-21 06:13:01 +0000703 }
704 }
Mitch Williams1418c342015-10-21 19:47:12 -0400705 if (!more)
706 adapter->aq_required &= ~I40EVF_FLAG_AQ_DEL_VLAN_FILTER;
Jacob Keller504398f2017-10-27 11:06:50 -0400707
708 spin_unlock_bh(&adapter->mac_vlan_list_lock);
709
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700710 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_DEL_VLAN, (u8 *)vvfl, len);
Mitch Williamsfc86a972014-06-04 20:41:38 +0000711 kfree(vvfl);
Greg Rose62683ab2013-12-21 06:13:01 +0000712}
713
714/**
715 * i40evf_set_promiscuous
716 * @adapter: adapter structure
717 * @flags: bitmask to control unicast/multicast promiscuous.
718 *
719 * Request that the PF enable promiscuous mode for our VSI.
720 **/
721void i40evf_set_promiscuous(struct i40evf_adapter *adapter, int flags)
722{
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700723 struct virtchnl_promisc_info vpi;
Anjali Singhai Jainf42a5c72016-05-03 15:13:10 -0700724 int promisc_all;
Greg Rose62683ab2013-12-21 06:13:01 +0000725
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700726 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
Greg Rose62683ab2013-12-21 06:13:01 +0000727 /* bail because we already have a command pending */
Shannon Nelsonfb43201f2015-08-26 15:14:17 -0400728 dev_err(&adapter->pdev->dev, "Cannot set promiscuous mode, command %d pending\n",
729 adapter->current_op);
Greg Rose62683ab2013-12-21 06:13:01 +0000730 return;
731 }
Anjali Singhai Jain47d34832016-04-12 08:30:52 -0700732
Jesse Brandeburgff3f4cc2017-05-11 11:23:16 -0700733 promisc_all = FLAG_VF_UNICAST_PROMISC |
734 FLAG_VF_MULTICAST_PROMISC;
Anjali Singhai Jainf42a5c72016-05-03 15:13:10 -0700735 if ((flags & promisc_all) == promisc_all) {
Anjali Singhai Jain47d34832016-04-12 08:30:52 -0700736 adapter->flags |= I40EVF_FLAG_PROMISC_ON;
737 adapter->aq_required &= ~I40EVF_FLAG_AQ_REQUEST_PROMISC;
738 dev_info(&adapter->pdev->dev, "Entering promiscuous mode\n");
Anjali Singhai Jainf42a5c72016-05-03 15:13:10 -0700739 }
740
Jesse Brandeburgff3f4cc2017-05-11 11:23:16 -0700741 if (flags & FLAG_VF_MULTICAST_PROMISC) {
Anjali Singhai Jainf42a5c72016-05-03 15:13:10 -0700742 adapter->flags |= I40EVF_FLAG_ALLMULTI_ON;
743 adapter->aq_required &= ~I40EVF_FLAG_AQ_REQUEST_ALLMULTI;
744 dev_info(&adapter->pdev->dev, "Entering multicast promiscuous mode\n");
745 }
746
747 if (!flags) {
Alexander Duyckf23735a2017-11-14 07:00:45 -0500748 adapter->flags &= ~(I40EVF_FLAG_PROMISC_ON |
749 I40EVF_FLAG_ALLMULTI_ON);
750 adapter->aq_required &= ~(I40EVF_FLAG_AQ_RELEASE_PROMISC |
751 I40EVF_FLAG_AQ_RELEASE_ALLMULTI);
Anjali Singhai Jain47d34832016-04-12 08:30:52 -0700752 dev_info(&adapter->pdev->dev, "Leaving promiscuous mode\n");
753 }
754
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700755 adapter->current_op = VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE;
Greg Rose62683ab2013-12-21 06:13:01 +0000756 vpi.vsi_id = adapter->vsi_res->vsi_id;
757 vpi.flags = flags;
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700758 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE,
Greg Rose62683ab2013-12-21 06:13:01 +0000759 (u8 *)&vpi, sizeof(vpi));
760}
761
762/**
763 * i40evf_request_stats
764 * @adapter: adapter structure
765 *
766 * Request VSI statistics from PF.
767 **/
768void i40evf_request_stats(struct i40evf_adapter *adapter)
769{
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700770 struct virtchnl_queue_select vqs;
Mitch Williams75a64432014-11-11 20:02:42 +0000771
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700772 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
Greg Rose62683ab2013-12-21 06:13:01 +0000773 /* no error message, this isn't crucial */
774 return;
775 }
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700776 adapter->current_op = VIRTCHNL_OP_GET_STATS;
Greg Rose62683ab2013-12-21 06:13:01 +0000777 vqs.vsi_id = adapter->vsi_res->vsi_id;
778 /* queue maps are ignored for this message - only the vsi is used */
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700779 if (i40evf_send_pf_msg(adapter, VIRTCHNL_OP_GET_STATS,
Greg Rose62683ab2013-12-21 06:13:01 +0000780 (u8 *)&vqs, sizeof(vqs)))
781 /* if the request failed, don't lock out others */
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700782 adapter->current_op = VIRTCHNL_OP_UNKNOWN;
Greg Rose62683ab2013-12-21 06:13:01 +0000783}
Mitch Williams43a3d9b2016-04-12 08:30:44 -0700784
785/**
786 * i40evf_get_hena
787 * @adapter: adapter structure
788 *
789 * Request hash enable capabilities from PF
790 **/
791void i40evf_get_hena(struct i40evf_adapter *adapter)
792{
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700793 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
Mitch Williams43a3d9b2016-04-12 08:30:44 -0700794 /* bail because we already have a command pending */
795 dev_err(&adapter->pdev->dev, "Cannot get RSS hash capabilities, command %d pending\n",
796 adapter->current_op);
797 return;
798 }
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700799 adapter->current_op = VIRTCHNL_OP_GET_RSS_HENA_CAPS;
Mitch Williams43a3d9b2016-04-12 08:30:44 -0700800 adapter->aq_required &= ~I40EVF_FLAG_AQ_GET_HENA;
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700801 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_GET_RSS_HENA_CAPS,
Mitch Williams43a3d9b2016-04-12 08:30:44 -0700802 NULL, 0);
803}
804
805/**
806 * i40evf_set_hena
807 * @adapter: adapter structure
808 *
809 * Request the PF to set our RSS hash capabilities
810 **/
811void i40evf_set_hena(struct i40evf_adapter *adapter)
812{
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700813 struct virtchnl_rss_hena vrh;
Mitch Williams43a3d9b2016-04-12 08:30:44 -0700814
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700815 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
Mitch Williams43a3d9b2016-04-12 08:30:44 -0700816 /* bail because we already have a command pending */
817 dev_err(&adapter->pdev->dev, "Cannot set RSS hash enable, command %d pending\n",
818 adapter->current_op);
819 return;
820 }
821 vrh.hena = adapter->hena;
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700822 adapter->current_op = VIRTCHNL_OP_SET_RSS_HENA;
Mitch Williams43a3d9b2016-04-12 08:30:44 -0700823 adapter->aq_required &= ~I40EVF_FLAG_AQ_SET_HENA;
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700824 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_SET_RSS_HENA,
Mitch Williams43a3d9b2016-04-12 08:30:44 -0700825 (u8 *)&vrh, sizeof(vrh));
826}
827
828/**
829 * i40evf_set_rss_key
830 * @adapter: adapter structure
831 *
832 * Request the PF to set our RSS hash key
833 **/
834void i40evf_set_rss_key(struct i40evf_adapter *adapter)
835{
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700836 struct virtchnl_rss_key *vrk;
Mitch Williams43a3d9b2016-04-12 08:30:44 -0700837 int len;
838
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700839 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
Mitch Williams43a3d9b2016-04-12 08:30:44 -0700840 /* bail because we already have a command pending */
841 dev_err(&adapter->pdev->dev, "Cannot set RSS key, command %d pending\n",
842 adapter->current_op);
843 return;
844 }
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700845 len = sizeof(struct virtchnl_rss_key) +
Mitch Williams43a3d9b2016-04-12 08:30:44 -0700846 (adapter->rss_key_size * sizeof(u8)) - 1;
847 vrk = kzalloc(len, GFP_KERNEL);
848 if (!vrk)
849 return;
850 vrk->vsi_id = adapter->vsi.id;
851 vrk->key_len = adapter->rss_key_size;
852 memcpy(vrk->key, adapter->rss_key, adapter->rss_key_size);
853
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700854 adapter->current_op = VIRTCHNL_OP_CONFIG_RSS_KEY;
Mitch Williams43a3d9b2016-04-12 08:30:44 -0700855 adapter->aq_required &= ~I40EVF_FLAG_AQ_SET_RSS_KEY;
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700856 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_CONFIG_RSS_KEY,
Mitch Williams43a3d9b2016-04-12 08:30:44 -0700857 (u8 *)vrk, len);
858 kfree(vrk);
859}
860
861/**
862 * i40evf_set_rss_lut
863 * @adapter: adapter structure
864 *
865 * Request the PF to set our RSS lookup table
866 **/
867void i40evf_set_rss_lut(struct i40evf_adapter *adapter)
868{
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700869 struct virtchnl_rss_lut *vrl;
Mitch Williams43a3d9b2016-04-12 08:30:44 -0700870 int len;
871
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700872 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
Mitch Williams43a3d9b2016-04-12 08:30:44 -0700873 /* bail because we already have a command pending */
874 dev_err(&adapter->pdev->dev, "Cannot set RSS LUT, command %d pending\n",
875 adapter->current_op);
876 return;
877 }
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700878 len = sizeof(struct virtchnl_rss_lut) +
Mitch Williams43a3d9b2016-04-12 08:30:44 -0700879 (adapter->rss_lut_size * sizeof(u8)) - 1;
880 vrl = kzalloc(len, GFP_KERNEL);
881 if (!vrl)
882 return;
883 vrl->vsi_id = adapter->vsi.id;
884 vrl->lut_entries = adapter->rss_lut_size;
885 memcpy(vrl->lut, adapter->rss_lut, adapter->rss_lut_size);
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700886 adapter->current_op = VIRTCHNL_OP_CONFIG_RSS_LUT;
Mitch Williams43a3d9b2016-04-12 08:30:44 -0700887 adapter->aq_required &= ~I40EVF_FLAG_AQ_SET_RSS_LUT;
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700888 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_CONFIG_RSS_LUT,
Mitch Williams43a3d9b2016-04-12 08:30:44 -0700889 (u8 *)vrl, len);
890 kfree(vrl);
891}
892
Mitch Williams625777e2014-02-20 19:29:05 -0800893/**
Mariusz Stachura87743702017-07-17 22:09:45 -0700894 * i40evf_enable_vlan_stripping
895 * @adapter: adapter structure
896 *
897 * Request VLAN header stripping to be enabled
898 **/
899void i40evf_enable_vlan_stripping(struct i40evf_adapter *adapter)
900{
901 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
902 /* bail because we already have a command pending */
903 dev_err(&adapter->pdev->dev, "Cannot enable stripping, command %d pending\n",
904 adapter->current_op);
905 return;
906 }
907 adapter->current_op = VIRTCHNL_OP_ENABLE_VLAN_STRIPPING;
908 adapter->aq_required &= ~I40EVF_FLAG_AQ_ENABLE_VLAN_STRIPPING;
909 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_ENABLE_VLAN_STRIPPING,
910 NULL, 0);
911}
912
913/**
914 * i40evf_disable_vlan_stripping
915 * @adapter: adapter structure
916 *
917 * Request VLAN header stripping to be disabled
918 **/
919void i40evf_disable_vlan_stripping(struct i40evf_adapter *adapter)
920{
921 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
922 /* bail because we already have a command pending */
923 dev_err(&adapter->pdev->dev, "Cannot disable stripping, command %d pending\n",
924 adapter->current_op);
925 return;
926 }
927 adapter->current_op = VIRTCHNL_OP_DISABLE_VLAN_STRIPPING;
928 adapter->aq_required &= ~I40EVF_FLAG_AQ_DISABLE_VLAN_STRIPPING;
929 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_DISABLE_VLAN_STRIPPING,
930 NULL, 0);
931}
932
933/**
Mitch Williamsfe458e52016-08-04 11:37:02 -0700934 * i40evf_print_link_message - print link up or down
935 * @adapter: adapter structure
936 *
937 * Log a message telling the world of our wonderous link status
938 */
939static void i40evf_print_link_message(struct i40evf_adapter *adapter)
940{
941 struct net_device *netdev = adapter->netdev;
942 char *speed = "Unknown ";
943
944 if (!adapter->link_up) {
945 netdev_info(netdev, "NIC Link is Down\n");
946 return;
947 }
948
949 switch (adapter->link_speed) {
950 case I40E_LINK_SPEED_40GB:
951 speed = "40 G";
952 break;
Carolyn Wyborny31232372016-11-21 13:03:48 -0800953 case I40E_LINK_SPEED_25GB:
954 speed = "25 G";
955 break;
Mitch Williamsfe458e52016-08-04 11:37:02 -0700956 case I40E_LINK_SPEED_20GB:
957 speed = "20 G";
958 break;
959 case I40E_LINK_SPEED_10GB:
960 speed = "10 G";
961 break;
962 case I40E_LINK_SPEED_1GB:
963 speed = "1000 M";
964 break;
965 case I40E_LINK_SPEED_100MB:
966 speed = "100 M";
967 break;
968 default:
969 break;
970 }
971
972 netdev_info(netdev, "NIC Link is Up %sbps Full Duplex\n", speed);
973}
974
975/**
Mitch Williams625777e2014-02-20 19:29:05 -0800976 * i40evf_request_reset
977 * @adapter: adapter structure
978 *
979 * Request that the PF reset this VF. No response is expected.
980 **/
981void i40evf_request_reset(struct i40evf_adapter *adapter)
982{
983 /* Don't check CURRENT_OP - this is always higher priority */
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -0700984 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_RESET_VF, NULL, 0);
985 adapter->current_op = VIRTCHNL_OP_UNKNOWN;
Mitch Williams625777e2014-02-20 19:29:05 -0800986}
Greg Rose62683ab2013-12-21 06:13:01 +0000987
988/**
989 * i40evf_virtchnl_completion
990 * @adapter: adapter structure
991 * @v_opcode: opcode sent by PF
992 * @v_retval: retval sent by PF
993 * @msg: message sent by PF
994 * @msglen: message length
995 *
996 * Asynchronous completion function for admin queue messages. Rather than busy
997 * wait, we fire off our requests and assume that no errors will be returned.
998 * This function handles the reply messages.
999 **/
1000void i40evf_virtchnl_completion(struct i40evf_adapter *adapter,
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -07001001 enum virtchnl_ops v_opcode,
Greg Rose62683ab2013-12-21 06:13:01 +00001002 i40e_status v_retval,
1003 u8 *msg, u16 msglen)
1004{
1005 struct net_device *netdev = adapter->netdev;
1006
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -07001007 if (v_opcode == VIRTCHNL_OP_EVENT) {
1008 struct virtchnl_pf_event *vpe =
1009 (struct virtchnl_pf_event *)msg;
Alan Bradye0346f92018-01-05 04:55:21 -05001010 bool link_up = vpe->event_data.link_event.link_status;
Greg Rose62683ab2013-12-21 06:13:01 +00001011 switch (vpe->event) {
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -07001012 case VIRTCHNL_EVENT_LINK_CHANGE:
Mitch Williamsfe458e52016-08-04 11:37:02 -07001013 adapter->link_speed =
1014 vpe->event_data.link_event.link_speed;
Alan Bradye0346f92018-01-05 04:55:21 -05001015
1016 /* we've already got the right link status, bail */
1017 if (adapter->link_up == link_up)
1018 break;
1019
1020 /* If we get link up message and start queues before
1021 * our queues are configured it will trigger a TX hang.
1022 * In that case, just ignore the link status message,
1023 * we'll get another one after we enable queues and
1024 * actually prepared to send traffic.
1025 */
1026 if (link_up && adapter->state != __I40EVF_RUNNING)
1027 break;
1028
1029 adapter->link_up = link_up;
1030 if (link_up) {
1031 netif_tx_start_all_queues(netdev);
1032 netif_carrier_on(netdev);
1033 } else {
1034 netif_tx_stop_all_queues(netdev);
1035 netif_carrier_off(netdev);
Greg Rose62683ab2013-12-21 06:13:01 +00001036 }
Alan Bradye0346f92018-01-05 04:55:21 -05001037 i40evf_print_link_message(adapter);
Greg Rose62683ab2013-12-21 06:13:01 +00001038 break;
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -07001039 case VIRTCHNL_EVENT_RESET_IMPENDING:
Mitch Williamsef8693e2014-02-13 03:48:53 -08001040 dev_info(&adapter->pdev->dev, "PF reset warning received\n");
1041 if (!(adapter->flags & I40EVF_FLAG_RESET_PENDING)) {
1042 adapter->flags |= I40EVF_FLAG_RESET_PENDING;
1043 dev_info(&adapter->pdev->dev, "Scheduling reset task\n");
1044 schedule_work(&adapter->reset_task);
1045 }
Greg Rose62683ab2013-12-21 06:13:01 +00001046 break;
1047 default:
Shannon Nelsonfb43201f2015-08-26 15:14:17 -04001048 dev_err(&adapter->pdev->dev, "Unknown event %d from PF\n",
1049 vpe->event);
Greg Rose62683ab2013-12-21 06:13:01 +00001050 break;
Greg Rose62683ab2013-12-21 06:13:01 +00001051 }
1052 return;
1053 }
Greg Rose62683ab2013-12-21 06:13:01 +00001054 if (v_retval) {
Mitch Williams8d8f2292015-10-21 19:47:11 -04001055 switch (v_opcode) {
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -07001056 case VIRTCHNL_OP_ADD_VLAN:
Mitch Williams8d8f2292015-10-21 19:47:11 -04001057 dev_err(&adapter->pdev->dev, "Failed to add VLAN filter, error %s\n",
1058 i40evf_stat_str(&adapter->hw, v_retval));
1059 break;
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -07001060 case VIRTCHNL_OP_ADD_ETH_ADDR:
Mitch Williams8d8f2292015-10-21 19:47:11 -04001061 dev_err(&adapter->pdev->dev, "Failed to add MAC filter, error %s\n",
1062 i40evf_stat_str(&adapter->hw, v_retval));
1063 break;
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -07001064 case VIRTCHNL_OP_DEL_VLAN:
Mitch Williams8d8f2292015-10-21 19:47:11 -04001065 dev_err(&adapter->pdev->dev, "Failed to delete VLAN filter, error %s\n",
1066 i40evf_stat_str(&adapter->hw, v_retval));
1067 break;
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -07001068 case VIRTCHNL_OP_DEL_ETH_ADDR:
Mitch Williams8d8f2292015-10-21 19:47:11 -04001069 dev_err(&adapter->pdev->dev, "Failed to delete MAC filter, error %s\n",
1070 i40evf_stat_str(&adapter->hw, v_retval));
1071 break;
1072 default:
1073 dev_err(&adapter->pdev->dev, "PF returned error %d (%s) to our request %d\n",
1074 v_retval,
1075 i40evf_stat_str(&adapter->hw, v_retval),
1076 v_opcode);
1077 }
Greg Rose62683ab2013-12-21 06:13:01 +00001078 }
1079 switch (v_opcode) {
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -07001080 case VIRTCHNL_OP_GET_STATS: {
Greg Rose62683ab2013-12-21 06:13:01 +00001081 struct i40e_eth_stats *stats =
1082 (struct i40e_eth_stats *)msg;
Tobias Klauser4a0a3ab2017-04-06 08:46:28 +02001083 netdev->stats.rx_packets = stats->rx_unicast +
1084 stats->rx_multicast +
1085 stats->rx_broadcast;
1086 netdev->stats.tx_packets = stats->tx_unicast +
1087 stats->tx_multicast +
1088 stats->tx_broadcast;
1089 netdev->stats.rx_bytes = stats->rx_bytes;
1090 netdev->stats.tx_bytes = stats->tx_bytes;
1091 netdev->stats.tx_errors = stats->tx_errors;
1092 netdev->stats.rx_dropped = stats->rx_discards;
1093 netdev->stats.tx_dropped = stats->tx_discards;
Greg Rose62683ab2013-12-21 06:13:01 +00001094 adapter->current_stats = *stats;
1095 }
1096 break;
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -07001097 case VIRTCHNL_OP_GET_VF_RESOURCES: {
1098 u16 len = sizeof(struct virtchnl_vf_resource) +
Mitch Williamse6d038d2015-06-04 16:23:58 -04001099 I40E_MAX_VF_VSI *
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -07001100 sizeof(struct virtchnl_vsi_resource);
Mitch Williamse6d038d2015-06-04 16:23:58 -04001101 memcpy(adapter->vf_res, msg, min(msglen, len));
1102 i40e_vf_parse_hw_config(&adapter->hw, adapter->vf_res);
Mitch Williams8552d852015-08-31 19:54:51 -04001103 /* restore current mac address */
1104 ether_addr_copy(adapter->hw.mac.addr, netdev->dev_addr);
Mitch Williamse6d038d2015-06-04 16:23:58 -04001105 i40evf_process_config(adapter);
1106 }
1107 break;
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -07001108 case VIRTCHNL_OP_ENABLE_QUEUES:
Greg Rose62683ab2013-12-21 06:13:01 +00001109 /* enable transmits */
1110 i40evf_irq_enable(adapter, true);
Greg Rose62683ab2013-12-21 06:13:01 +00001111 break;
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -07001112 case VIRTCHNL_OP_DISABLE_QUEUES:
Mitch Williamse284fc82015-03-27 00:12:09 -07001113 i40evf_free_all_tx_resources(adapter);
1114 i40evf_free_all_rx_resources(adapter);
Sudheer Mogilappagarife2647a2017-06-23 04:24:44 -04001115 if (adapter->state == __I40EVF_DOWN_PENDING) {
Mitch Williams209dc4d2015-12-09 15:50:27 -08001116 adapter->state = __I40EVF_DOWN;
Sudheer Mogilappagarife2647a2017-06-23 04:24:44 -04001117 wake_up(&adapter->down_waitqueue);
1118 }
Greg Rose62683ab2013-12-21 06:13:01 +00001119 break;
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -07001120 case VIRTCHNL_OP_VERSION:
1121 case VIRTCHNL_OP_CONFIG_IRQ_MAP:
Mitch Williamsed636962015-04-07 19:45:32 -04001122 /* Don't display an error if we get these out of sequence.
1123 * If the firmware needed to get kicked, we'll get these and
1124 * it's no problem.
1125 */
1126 if (v_opcode != adapter->current_op)
1127 return;
Greg Rose62683ab2013-12-21 06:13:01 +00001128 break;
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -07001129 case VIRTCHNL_OP_IWARP:
Mitch Williamsed0e8942017-01-24 10:23:59 -08001130 /* Gobble zero-length replies from the PF. They indicate that
1131 * a previous message was received OK, and the client doesn't
1132 * care about that.
1133 */
1134 if (msglen && CLIENT_ENABLED(adapter))
1135 i40evf_notify_client_message(&adapter->vsi,
1136 msg, msglen);
1137 break;
1138
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -07001139 case VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP:
Mitch Williamse5f77f42017-02-09 23:35:18 -08001140 adapter->client_pending &=
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -07001141 ~(BIT(VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP));
Mitch Williamse5f77f42017-02-09 23:35:18 -08001142 break;
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -07001143 case VIRTCHNL_OP_GET_RSS_HENA_CAPS: {
Jesse Brandeburgf0adc6e2017-05-11 11:23:15 -07001144 struct virtchnl_rss_hena *vrh = (struct virtchnl_rss_hena *)msg;
Mitch Williams43a3d9b2016-04-12 08:30:44 -07001145 if (msglen == sizeof(*vrh))
1146 adapter->hena = vrh->hena;
1147 else
1148 dev_warn(&adapter->pdev->dev,
1149 "Invalid message %d from PF\n", v_opcode);
1150 }
1151 break;
Alan Brady5b36e8d2017-08-22 06:57:50 -04001152 case VIRTCHNL_OP_REQUEST_QUEUES: {
1153 struct virtchnl_vf_res_request *vfres =
1154 (struct virtchnl_vf_res_request *)msg;
Alan Brady17a94222017-10-11 14:49:43 -07001155 if (vfres->num_queue_pairs != adapter->num_req_queues) {
Alan Brady5b36e8d2017-08-22 06:57:50 -04001156 dev_info(&adapter->pdev->dev,
1157 "Requested %d queues, PF can support %d\n",
1158 adapter->num_req_queues,
1159 vfres->num_queue_pairs);
1160 adapter->num_req_queues = 0;
Alan Brady17a94222017-10-11 14:49:43 -07001161 adapter->flags &= ~I40EVF_FLAG_REINIT_ITR_NEEDED;
Alan Brady5b36e8d2017-08-22 06:57:50 -04001162 }
1163 }
1164 break;
Greg Rose62683ab2013-12-21 06:13:01 +00001165 default:
Mitch Williamsed0e8942017-01-24 10:23:59 -08001166 if (adapter->current_op && (v_opcode != adapter->current_op))
Mitch Williamsed636962015-04-07 19:45:32 -04001167 dev_warn(&adapter->pdev->dev, "Expected response %d from PF, received %d\n",
1168 adapter->current_op, v_opcode);
Greg Rose62683ab2013-12-21 06:13:01 +00001169 break;
1170 } /* switch v_opcode */
Jesse Brandeburg310a2ad2017-05-11 11:23:11 -07001171 adapter->current_op = VIRTCHNL_OP_UNKNOWN;
Greg Rose62683ab2013-12-21 06:13:01 +00001172}