1 /*******************************************************************************
3 * Intel Ethernet Controller XL710 Family Linux Driver
4 * Copyright(c) 2013 - 2015 Intel Corporation.
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.
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
15 * You should have received a copy of the GNU General Public License along
16 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 * The full GNU General Public License is included in this distribution in
19 * the file called "COPYING".
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
25 ******************************************************************************/
27 #include <linux/list.h>
28 #include <linux/errno.h>
31 #include "i40e_prototype.h"
32 #include "i40e_client.h"
34 static const char i40e_client_interface_version_str[] = I40E_CLIENT_VERSION_STR;
36 static LIST_HEAD(i40e_devices);
37 static DEFINE_MUTEX(i40e_device_mutex);
39 static LIST_HEAD(i40e_clients);
40 static DEFINE_MUTEX(i40e_client_mutex);
42 static LIST_HEAD(i40e_client_instances);
43 static DEFINE_MUTEX(i40e_client_instance_mutex);
45 static int i40e_client_virtchnl_send(struct i40e_info *ldev,
46 struct i40e_client *client,
47 u32 vf_id, u8 *msg, u16 len);
49 static int i40e_client_setup_qvlist(struct i40e_info *ldev,
50 struct i40e_client *client,
51 struct i40e_qvlist_info *qvlist_info);
53 static void i40e_client_request_reset(struct i40e_info *ldev,
54 struct i40e_client *client,
57 static int i40e_client_update_vsi_ctxt(struct i40e_info *ldev,
58 struct i40e_client *client,
59 bool is_vf, u32 vf_id,
60 u32 flag, u32 valid_flag);
62 static struct i40e_ops i40e_lan_ops = {
63 .virtchnl_send = i40e_client_virtchnl_send,
64 .setup_qvlist = i40e_client_setup_qvlist,
65 .request_reset = i40e_client_request_reset,
66 .update_vsi_ctxt = i40e_client_update_vsi_ctxt,
70 * i40e_client_type_to_vsi_type - convert client type to vsi type
71 * @client_type: the i40e_client type
73 * returns the related vsi type value
76 enum i40e_vsi_type i40e_client_type_to_vsi_type(enum i40e_client_type type)
79 case I40E_CLIENT_IWARP:
80 return I40E_VSI_IWARP;
82 case I40E_CLIENT_VMDQ2:
83 return I40E_VSI_VMDQ2;
86 pr_err("i40e: Client type unknown\n");
87 return I40E_VSI_TYPE_UNKNOWN;
92 * i40e_client_get_params - Get the params that can change at runtime
93 * @vsi: the VSI with the message
94 * @param: clinet param struct
98 int i40e_client_get_params(struct i40e_vsi *vsi, struct i40e_params *params)
100 struct i40e_dcbx_config *dcb_cfg = &vsi->back->hw.local_dcbx_config;
103 for (i = 0; i < I40E_MAX_USER_PRIORITY; i++) {
104 u8 tc = dcb_cfg->etscfg.prioritytable[i];
107 /* If TC is not enabled for VSI use TC0 for UP */
108 if (!(vsi->tc_config.enabled_tc & BIT(tc)))
111 qs_handle = le16_to_cpu(vsi->info.qs_handle[tc]);
112 params->qos.prio_qos[i].tc = tc;
113 params->qos.prio_qos[i].qs_handle = qs_handle;
114 if (qs_handle == I40E_AQ_VSI_QS_HANDLE_INVALID) {
115 dev_err(&vsi->back->pdev->dev, "Invalid queue set handle for TC = %d, vsi id = %d\n",
121 params->mtu = vsi->netdev->mtu;
126 * i40e_notify_client_of_vf_msg - call the client vf message callback
127 * @vsi: the VSI with the message
128 * @vf_id: the absolute VF id that sent the message
129 * @msg: message buffer
130 * @len: length of the message
132 * If there is a client to this VSI, call the client
135 i40e_notify_client_of_vf_msg(struct i40e_vsi *vsi, u32 vf_id, u8 *msg, u16 len)
137 struct i40e_client_instance *cdev;
141 mutex_lock(&i40e_client_instance_mutex);
142 list_for_each_entry(cdev, &i40e_client_instances, list) {
143 if (cdev->lan_info.pf == vsi->back) {
145 !cdev->client->ops ||
146 !cdev->client->ops->virtchnl_receive) {
147 dev_dbg(&vsi->back->pdev->dev,
148 "Cannot locate client instance virtual channel receive routine\n");
151 if (!test_bit(__I40E_CLIENT_INSTANCE_OPENED,
153 dev_dbg(&vsi->back->pdev->dev, "Client is not open, abort virtchnl_receive\n");
156 cdev->client->ops->virtchnl_receive(&cdev->lan_info,
161 mutex_unlock(&i40e_client_instance_mutex);
165 * i40e_notify_client_of_l2_param_changes - call the client notify callback
166 * @vsi: the VSI with l2 param changes
168 * If there is a client to this VSI, call the client
170 void i40e_notify_client_of_l2_param_changes(struct i40e_vsi *vsi)
172 struct i40e_client_instance *cdev;
173 struct i40e_params params;
177 mutex_lock(&i40e_client_instance_mutex);
178 list_for_each_entry(cdev, &i40e_client_instances, list) {
179 if (cdev->lan_info.pf == vsi->back) {
181 !cdev->client->ops ||
182 !cdev->client->ops->l2_param_change) {
183 dev_dbg(&vsi->back->pdev->dev,
184 "Cannot locate client instance l2_param_change routine\n");
187 memset(¶ms, 0, sizeof(params));
188 i40e_client_get_params(vsi, ¶ms);
189 if (!test_bit(__I40E_CLIENT_INSTANCE_OPENED,
191 dev_dbg(&vsi->back->pdev->dev, "Client is not open, abort l2 param change\n");
194 cdev->lan_info.params = params;
195 cdev->client->ops->l2_param_change(&cdev->lan_info,
200 mutex_unlock(&i40e_client_instance_mutex);
204 * i40e_client_release_qvlist
205 * @ldev: pointer to L2 context.
208 static void i40e_client_release_qvlist(struct i40e_info *ldev)
210 struct i40e_qvlist_info *qvlist_info = ldev->qvlist_info;
213 if (!ldev->qvlist_info)
216 for (i = 0; i < qvlist_info->num_vectors; i++) {
217 struct i40e_pf *pf = ldev->pf;
218 struct i40e_qv_info *qv_info;
221 qv_info = &qvlist_info->qv_info[i];
224 reg_idx = I40E_PFINT_LNKLSTN(qv_info->v_idx - 1);
225 wr32(&pf->hw, reg_idx, I40E_PFINT_LNKLSTN_FIRSTQ_INDX_MASK);
227 kfree(ldev->qvlist_info);
228 ldev->qvlist_info = NULL;
232 * i40e_notify_client_of_netdev_close - call the client close callback
233 * @vsi: the VSI with netdev closed
234 * @reset: true when close called due to a reset pending
236 * If there is a client to this netdev, call the client with close
238 void i40e_notify_client_of_netdev_close(struct i40e_vsi *vsi, bool reset)
240 struct i40e_client_instance *cdev;
244 mutex_lock(&i40e_client_instance_mutex);
245 list_for_each_entry(cdev, &i40e_client_instances, list) {
246 if (cdev->lan_info.netdev == vsi->netdev) {
248 !cdev->client->ops || !cdev->client->ops->close) {
249 dev_dbg(&vsi->back->pdev->dev,
250 "Cannot locate client instance close routine\n");
253 cdev->client->ops->close(&cdev->lan_info, cdev->client,
255 clear_bit(__I40E_CLIENT_INSTANCE_OPENED, &cdev->state);
256 i40e_client_release_qvlist(&cdev->lan_info);
259 mutex_unlock(&i40e_client_instance_mutex);
263 * i40e_notify_client_of_vf_reset - call the client vf reset callback
264 * @pf: PF device pointer
265 * @vf_id: asolute id of VF being reset
267 * If there is a client attached to this PF, notify when a VF is reset
269 void i40e_notify_client_of_vf_reset(struct i40e_pf *pf, u32 vf_id)
271 struct i40e_client_instance *cdev;
275 mutex_lock(&i40e_client_instance_mutex);
276 list_for_each_entry(cdev, &i40e_client_instances, list) {
277 if (cdev->lan_info.pf == pf) {
279 !cdev->client->ops ||
280 !cdev->client->ops->vf_reset) {
281 dev_dbg(&pf->pdev->dev,
282 "Cannot locate client instance VF reset routine\n");
285 if (!test_bit(__I40E_CLIENT_INSTANCE_OPENED,
287 dev_dbg(&pf->pdev->dev, "Client is not open, abort vf-reset\n");
290 cdev->client->ops->vf_reset(&cdev->lan_info,
291 cdev->client, vf_id);
294 mutex_unlock(&i40e_client_instance_mutex);
298 * i40e_notify_client_of_vf_enable - call the client vf notification callback
299 * @pf: PF device pointer
300 * @num_vfs: the number of VFs currently enabled, 0 for disable
302 * If there is a client attached to this PF, call its VF notification routine
304 void i40e_notify_client_of_vf_enable(struct i40e_pf *pf, u32 num_vfs)
306 struct i40e_client_instance *cdev;
310 mutex_lock(&i40e_client_instance_mutex);
311 list_for_each_entry(cdev, &i40e_client_instances, list) {
312 if (cdev->lan_info.pf == pf) {
314 !cdev->client->ops ||
315 !cdev->client->ops->vf_enable) {
316 dev_dbg(&pf->pdev->dev,
317 "Cannot locate client instance VF enable routine\n");
320 if (!test_bit(__I40E_CLIENT_INSTANCE_OPENED,
322 dev_dbg(&pf->pdev->dev, "Client is not open, abort vf-enable\n");
325 cdev->client->ops->vf_enable(&cdev->lan_info,
326 cdev->client, num_vfs);
329 mutex_unlock(&i40e_client_instance_mutex);
333 * i40e_vf_client_capable - ask the client if it likes the specified VF
334 * @pf: PF device pointer
335 * @vf_id: the VF in question
337 * If there is a client of the specified type attached to this PF, call
338 * its vf_capable routine
340 int i40e_vf_client_capable(struct i40e_pf *pf, u32 vf_id,
341 enum i40e_client_type type)
343 struct i40e_client_instance *cdev;
348 mutex_lock(&i40e_client_instance_mutex);
349 list_for_each_entry(cdev, &i40e_client_instances, list) {
350 if (cdev->lan_info.pf == pf) {
352 !cdev->client->ops ||
353 !cdev->client->ops->vf_capable ||
354 !(cdev->client->type == type)) {
355 dev_dbg(&pf->pdev->dev,
356 "Cannot locate client instance VF capability routine\n");
359 if (!test_bit(__I40E_CLIENT_INSTANCE_OPENED,
361 dev_dbg(&pf->pdev->dev, "Client is not open, abort vf-capable\n");
364 capable = cdev->client->ops->vf_capable(&cdev->lan_info,
370 mutex_unlock(&i40e_client_instance_mutex);
375 * i40e_client_add_instance - add a client instance struct to the instance list
376 * @pf: pointer to the board struct
377 * @client: pointer to a client struct in the client list.
378 * @existing: if there was already an existing instance
380 * Returns cdev ptr on success or if already exists, NULL on failure
383 struct i40e_client_instance *i40e_client_add_instance(struct i40e_pf *pf,
384 struct i40e_client *client,
387 struct i40e_client_instance *cdev;
388 struct netdev_hw_addr *mac = NULL;
389 struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi];
391 mutex_lock(&i40e_client_instance_mutex);
392 list_for_each_entry(cdev, &i40e_client_instances, list) {
393 if ((cdev->lan_info.pf == pf) && (cdev->client == client)) {
398 cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
402 cdev->lan_info.pf = (void *)pf;
403 cdev->lan_info.netdev = vsi->netdev;
404 cdev->lan_info.pcidev = pf->pdev;
405 cdev->lan_info.fid = pf->hw.pf_id;
406 cdev->lan_info.ftype = I40E_CLIENT_FTYPE_PF;
407 cdev->lan_info.hw_addr = pf->hw.hw_addr;
408 cdev->lan_info.ops = &i40e_lan_ops;
409 cdev->lan_info.version.major = I40E_CLIENT_VERSION_MAJOR;
410 cdev->lan_info.version.minor = I40E_CLIENT_VERSION_MINOR;
411 cdev->lan_info.version.build = I40E_CLIENT_VERSION_BUILD;
412 cdev->lan_info.fw_maj_ver = pf->hw.aq.fw_maj_ver;
413 cdev->lan_info.fw_min_ver = pf->hw.aq.fw_min_ver;
414 cdev->lan_info.fw_build = pf->hw.aq.fw_build;
415 set_bit(__I40E_CLIENT_INSTANCE_NONE, &cdev->state);
417 if (i40e_client_get_params(vsi, &cdev->lan_info.params)) {
423 cdev->lan_info.msix_count = pf->num_iwarp_msix;
424 cdev->lan_info.msix_entries = &pf->msix_entries[pf->iwarp_base_vector];
426 mac = list_first_entry(&cdev->lan_info.netdev->dev_addrs.list,
427 struct netdev_hw_addr, list);
429 ether_addr_copy(cdev->lan_info.lanmac, mac->addr);
431 dev_err(&pf->pdev->dev, "MAC address list is empty!\n");
433 cdev->client = client;
434 INIT_LIST_HEAD(&cdev->list);
435 list_add(&cdev->list, &i40e_client_instances);
437 mutex_unlock(&i40e_client_instance_mutex);
442 * i40e_client_del_instance - removes a client instance from the list
443 * @pf: pointer to the board struct
445 * Returns 0 on success or non-0 on error
448 int i40e_client_del_instance(struct i40e_pf *pf, struct i40e_client *client)
450 struct i40e_client_instance *cdev, *tmp;
453 mutex_lock(&i40e_client_instance_mutex);
454 list_for_each_entry_safe(cdev, tmp, &i40e_client_instances, list) {
455 if ((cdev->lan_info.pf != pf) || (cdev->client != client))
458 dev_info(&pf->pdev->dev, "Deleted instance of Client %s, of dev %d bus=0x%02x func=0x%02x)\n",
459 client->name, pf->hw.pf_id,
460 pf->hw.bus.device, pf->hw.bus.func);
461 list_del(&cdev->list);
466 mutex_unlock(&i40e_client_instance_mutex);
471 * i40e_client_subtask - client maintenance work
472 * @pf: board private structure
474 void i40e_client_subtask(struct i40e_pf *pf)
476 struct i40e_client_instance *cdev;
477 struct i40e_client *client;
478 bool existing = false;
481 if (!(pf->flags & I40E_FLAG_SERVICE_CLIENT_REQUESTED))
483 pf->flags &= ~I40E_FLAG_SERVICE_CLIENT_REQUESTED;
485 /* If we're down or resetting, just bail */
486 if (test_bit(__I40E_DOWN, &pf->state) ||
487 test_bit(__I40E_CONFIG_BUSY, &pf->state))
490 /* Check client state and instantiate client if client registered */
491 mutex_lock(&i40e_client_mutex);
492 list_for_each_entry(client, &i40e_clients, list) {
493 /* first check client is registered */
494 if (!test_bit(__I40E_CLIENT_REGISTERED, &client->state))
497 /* Do we also need the LAN VSI to be up, to create instance */
498 if (!(client->flags & I40E_CLIENT_FLAGS_LAUNCH_ON_PROBE)) {
499 /* check if L2 VSI is up, if not we are not ready */
500 if (test_bit(__I40E_DOWN, &pf->vsi[pf->lan_vsi]->state))
503 dev_warn(&pf->pdev->dev, "This client %s is being instantiated at probe\n",
507 /* Add the client instance to the instance list */
508 cdev = i40e_client_add_instance(pf, client, &existing);
513 dev_info(&pf->pdev->dev, "Added instance of Client %s to PF%d bus=0x%02x dev=0x%02x func=0x%02x\n",
514 client->name, pf->hw.pf_id,
515 pf->hw.bus.bus_id, pf->hw.bus.device,
519 mutex_lock(&i40e_client_instance_mutex);
520 if (!test_bit(__I40E_CLIENT_INSTANCE_OPENED,
522 /* Send an Open request to the client */
523 if (client->ops && client->ops->open)
524 ret = client->ops->open(&cdev->lan_info,
527 set_bit(__I40E_CLIENT_INSTANCE_OPENED,
530 /* remove client instance */
531 i40e_client_del_instance(pf, client);
534 mutex_unlock(&i40e_client_instance_mutex);
536 mutex_unlock(&i40e_client_mutex);
540 * i40e_lan_add_device - add a lan device struct to the list of lan devices
541 * @pf: pointer to the board struct
543 * Returns 0 on success or none 0 on error
545 int i40e_lan_add_device(struct i40e_pf *pf)
547 struct i40e_device *ldev;
550 mutex_lock(&i40e_device_mutex);
551 list_for_each_entry(ldev, &i40e_devices, list) {
552 if (ldev->pf == pf) {
557 ldev = kzalloc(sizeof(*ldev), GFP_KERNEL);
563 INIT_LIST_HEAD(&ldev->list);
564 list_add(&ldev->list, &i40e_devices);
565 dev_info(&pf->pdev->dev, "Added LAN device PF%d bus=0x%02x dev=0x%02x func=0x%02x\n",
566 pf->hw.pf_id, pf->hw.bus.bus_id,
567 pf->hw.bus.device, pf->hw.bus.func);
569 /* Since in some cases register may have happened before a device gets
570 * added, we can schedule a subtask to go initiate the clients if
571 * they can be launched at probe time.
573 pf->flags |= I40E_FLAG_SERVICE_CLIENT_REQUESTED;
574 i40e_service_event_schedule(pf);
577 mutex_unlock(&i40e_device_mutex);
582 * i40e_lan_del_device - removes a lan device from the device list
583 * @pf: pointer to the board struct
585 * Returns 0 on success or non-0 on error
587 int i40e_lan_del_device(struct i40e_pf *pf)
589 struct i40e_device *ldev, *tmp;
592 mutex_lock(&i40e_device_mutex);
593 list_for_each_entry_safe(ldev, tmp, &i40e_devices, list) {
594 if (ldev->pf == pf) {
595 dev_info(&pf->pdev->dev, "Deleted LAN device PF%d bus=0x%02x dev=0x%02x func=0x%02x\n",
596 pf->hw.pf_id, pf->hw.bus.bus_id,
597 pf->hw.bus.device, pf->hw.bus.func);
598 list_del(&ldev->list);
605 mutex_unlock(&i40e_device_mutex);
610 * i40e_client_release - release client specific resources
611 * @client: pointer to the registered client
613 * Return 0 on success or < 0 on error
615 static int i40e_client_release(struct i40e_client *client)
617 struct i40e_client_instance *cdev, *tmp;
621 LIST_HEAD(cdevs_tmp);
623 mutex_lock(&i40e_client_instance_mutex);
624 list_for_each_entry_safe(cdev, tmp, &i40e_client_instances, list) {
625 if (strncmp(cdev->client->name, client->name,
626 I40E_CLIENT_STR_LENGTH))
628 pf = (struct i40e_pf *)cdev->lan_info.pf;
629 if (test_bit(__I40E_CLIENT_INSTANCE_OPENED, &cdev->state)) {
630 if (client->ops && client->ops->close)
631 client->ops->close(&cdev->lan_info, client,
633 i40e_client_release_qvlist(&cdev->lan_info);
634 clear_bit(__I40E_CLIENT_INSTANCE_OPENED, &cdev->state);
636 dev_warn(&pf->pdev->dev,
637 "Client %s instance for PF id %d closed\n",
638 client->name, pf->hw.pf_id);
640 /* delete the client instance from the list */
641 list_move(&cdev->list, &cdevs_tmp);
642 dev_info(&pf->pdev->dev, "Deleted client instance of Client %s\n",
645 mutex_unlock(&i40e_client_instance_mutex);
647 /* free the client device and release its vsi */
648 list_for_each_entry_safe(cdev, tmp, &cdevs_tmp, list) {
655 * i40e_client_prepare - prepare client specific resources
656 * @client: pointer to the registered client
659 static void i40e_client_prepare(struct i40e_client *client)
661 struct i40e_device *ldev;
664 mutex_lock(&i40e_device_mutex);
665 list_for_each_entry(ldev, &i40e_devices, list) {
667 /* Start the client subtask */
668 pf->flags |= I40E_FLAG_SERVICE_CLIENT_REQUESTED;
669 i40e_service_event_schedule(pf);
671 mutex_unlock(&i40e_device_mutex);
675 * i40e_client_virtchnl_send - TBD
676 * @ldev: pointer to L2 context
677 * @client: Client pointer
678 * @vf_id: absolute VF identifier
679 * @msg: message buffer
680 * @len: length of message buffer
682 * Return 0 on success or < 0 on error
684 static int i40e_client_virtchnl_send(struct i40e_info *ldev,
685 struct i40e_client *client,
686 u32 vf_id, u8 *msg, u16 len)
688 struct i40e_pf *pf = ldev->pf;
689 struct i40e_hw *hw = &pf->hw;
692 err = i40e_aq_send_msg_to_vf(hw, vf_id, I40E_VIRTCHNL_OP_IWARP,
695 dev_err(&pf->pdev->dev, "Unable to send iWarp message to VF, error %d, aq status %d\n",
696 err, hw->aq.asq_last_status);
702 * i40e_client_setup_qvlist
703 * @ldev: pointer to L2 context.
704 * @client: Client pointer.
705 * @qv_info: queue and vector list
707 * Return 0 on success or < 0 on error
709 static int i40e_client_setup_qvlist(struct i40e_info *ldev,
710 struct i40e_client *client,
711 struct i40e_qvlist_info *qvlist_info)
713 struct i40e_pf *pf = ldev->pf;
714 struct i40e_hw *hw = &pf->hw;
715 struct i40e_qv_info *qv_info;
716 u32 v_idx, i, reg_idx, reg;
719 size = sizeof(struct i40e_qvlist_info) +
720 (sizeof(struct i40e_qv_info) * (qvlist_info->num_vectors - 1));
721 ldev->qvlist_info = kzalloc(size, GFP_KERNEL);
722 ldev->qvlist_info->num_vectors = qvlist_info->num_vectors;
724 for (i = 0; i < qvlist_info->num_vectors; i++) {
725 qv_info = &qvlist_info->qv_info[i];
728 v_idx = qv_info->v_idx;
730 /* Validate vector id belongs to this client */
731 if ((v_idx >= (pf->iwarp_base_vector + pf->num_iwarp_msix)) ||
732 (v_idx < pf->iwarp_base_vector))
735 ldev->qvlist_info->qv_info[i] = *qv_info;
736 reg_idx = I40E_PFINT_LNKLSTN(v_idx - 1);
738 if (qv_info->ceq_idx == I40E_QUEUE_INVALID_IDX) {
739 /* Special case - No CEQ mapped on this vector */
740 wr32(hw, reg_idx, I40E_PFINT_LNKLSTN_FIRSTQ_INDX_MASK);
742 reg = (qv_info->ceq_idx &
743 I40E_PFINT_LNKLSTN_FIRSTQ_INDX_MASK) |
744 (I40E_QUEUE_TYPE_PE_CEQ <<
745 I40E_PFINT_LNKLSTN_FIRSTQ_TYPE_SHIFT);
746 wr32(hw, reg_idx, reg);
748 reg = (I40E_PFINT_CEQCTL_CAUSE_ENA_MASK |
749 (v_idx << I40E_PFINT_CEQCTL_MSIX_INDX_SHIFT) |
751 I40E_PFINT_CEQCTL_ITR_INDX_SHIFT) |
752 (I40E_QUEUE_END_OF_LIST <<
753 I40E_PFINT_CEQCTL_NEXTQ_INDX_SHIFT));
754 wr32(hw, I40E_PFINT_CEQCTL(qv_info->ceq_idx), reg);
756 if (qv_info->aeq_idx != I40E_QUEUE_INVALID_IDX) {
757 reg = (I40E_PFINT_AEQCTL_CAUSE_ENA_MASK |
758 (v_idx << I40E_PFINT_AEQCTL_MSIX_INDX_SHIFT) |
760 I40E_PFINT_AEQCTL_ITR_INDX_SHIFT));
762 wr32(hw, I40E_PFINT_AEQCTL, reg);
765 /* Mitigate sync problems with iwarp VF driver */
769 kfree(ldev->qvlist_info);
770 ldev->qvlist_info = NULL;
775 * i40e_client_request_reset
776 * @ldev: pointer to L2 context.
777 * @client: Client pointer.
778 * @level: reset level
780 static void i40e_client_request_reset(struct i40e_info *ldev,
781 struct i40e_client *client,
784 struct i40e_pf *pf = ldev->pf;
786 switch (reset_level) {
787 case I40E_CLIENT_RESET_LEVEL_PF:
788 set_bit(__I40E_PF_RESET_REQUESTED, &pf->state);
790 case I40E_CLIENT_RESET_LEVEL_CORE:
791 set_bit(__I40E_PF_RESET_REQUESTED, &pf->state);
794 dev_warn(&pf->pdev->dev,
795 "Client %s instance for PF id %d request an unsupported reset: %d.\n",
796 client->name, pf->hw.pf_id, reset_level);
800 i40e_service_event_schedule(pf);
804 * i40e_client_update_vsi_ctxt
805 * @ldev: pointer to L2 context.
806 * @client: Client pointer.
807 * @is_vf: if this for the VF
808 * @vf_id: if is_vf true this carries the vf_id
809 * @flag: Any device level setting that needs to be done for PE
810 * @valid_flag: Bits in this match up and enable changing of flag bits
812 * Return 0 on success or < 0 on error
814 static int i40e_client_update_vsi_ctxt(struct i40e_info *ldev,
815 struct i40e_client *client,
816 bool is_vf, u32 vf_id,
817 u32 flag, u32 valid_flag)
819 struct i40e_pf *pf = ldev->pf;
820 struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi];
821 struct i40e_vsi_context ctxt;
825 /* TODO: for now do not allow setting VF's VSI setting */
829 ctxt.seid = pf->main_vsi_seid;
830 ctxt.pf_num = pf->hw.pf_id;
831 err = i40e_aq_get_vsi_params(&pf->hw, &ctxt, NULL);
832 ctxt.flags = I40E_AQ_VSI_TYPE_PF;
834 dev_info(&pf->pdev->dev,
835 "couldn't get PF vsi config, err %s aq_err %s\n",
836 i40e_stat_str(&pf->hw, err),
838 pf->hw.aq.asq_last_status));
842 if ((valid_flag & I40E_CLIENT_VSI_FLAG_TCP_PACKET_ENABLE) &&
843 (flag & I40E_CLIENT_VSI_FLAG_TCP_PACKET_ENABLE)) {
844 ctxt.info.valid_sections =
845 cpu_to_le16(I40E_AQ_VSI_PROP_QUEUE_OPT_VALID);
846 ctxt.info.queueing_opt_flags |= I40E_AQ_VSI_QUE_OPT_TCP_ENA;
847 } else if ((valid_flag & I40E_CLIENT_VSI_FLAG_TCP_PACKET_ENABLE) &&
848 !(flag & I40E_CLIENT_VSI_FLAG_TCP_PACKET_ENABLE)) {
849 ctxt.info.valid_sections =
850 cpu_to_le16(I40E_AQ_VSI_PROP_QUEUE_OPT_VALID);
851 ctxt.info.queueing_opt_flags &= ~I40E_AQ_VSI_QUE_OPT_TCP_ENA;
854 dev_warn(&pf->pdev->dev,
855 "Client %s instance for PF id %d request an unsupported Config: %x.\n",
856 client->name, pf->hw.pf_id, flag);
860 err = i40e_aq_update_vsi_params(&vsi->back->hw, &ctxt, NULL);
862 dev_info(&pf->pdev->dev,
863 "update VSI ctxt for PE failed, err %s aq_err %s\n",
864 i40e_stat_str(&pf->hw, err),
866 pf->hw.aq.asq_last_status));
873 * i40e_register_client - Register a i40e client driver with the L2 driver
874 * @client: pointer to the i40e_client struct
876 * Returns 0 on success or non-0 on error
878 int i40e_register_client(struct i40e_client *client)
881 enum i40e_vsi_type vsi_type;
888 if (strlen(client->name) == 0) {
889 pr_info("i40e: Failed to register client with no name\n");
894 mutex_lock(&i40e_client_mutex);
895 if (i40e_client_is_registered(client)) {
896 pr_info("i40e: Client %s has already been registered!\n",
898 mutex_unlock(&i40e_client_mutex);
903 if ((client->version.major != I40E_CLIENT_VERSION_MAJOR) ||
904 (client->version.minor != I40E_CLIENT_VERSION_MINOR)) {
905 pr_info("i40e: Failed to register client %s due to mismatched client interface version\n",
907 pr_info("Client is using version: %02d.%02d.%02d while LAN driver supports %s\n",
908 client->version.major, client->version.minor,
909 client->version.build,
910 i40e_client_interface_version_str);
911 mutex_unlock(&i40e_client_mutex);
916 vsi_type = i40e_client_type_to_vsi_type(client->type);
917 if (vsi_type == I40E_VSI_TYPE_UNKNOWN) {
918 pr_info("i40e: Failed to register client %s due to unknown client type %d\n",
919 client->name, client->type);
920 mutex_unlock(&i40e_client_mutex);
924 list_add(&client->list, &i40e_clients);
925 set_bit(__I40E_CLIENT_REGISTERED, &client->state);
926 mutex_unlock(&i40e_client_mutex);
928 i40e_client_prepare(client);
930 pr_info("i40e: Registered client %s\n", client->name);
934 EXPORT_SYMBOL(i40e_register_client);
937 * i40e_unregister_client - Unregister a i40e client driver with the L2 driver
938 * @client: pointer to the i40e_client struct
940 * Returns 0 on success or non-0 on error
942 int i40e_unregister_client(struct i40e_client *client)
946 /* When a unregister request comes through we would have to send
947 * a close for each of the client instances that were opened.
948 * client_release function is called to handle this.
950 mutex_lock(&i40e_client_mutex);
951 if (!client || i40e_client_release(client)) {
956 /* TODO: check if device is in reset, or if that matters? */
957 if (!i40e_client_is_registered(client)) {
958 pr_info("i40e: Client %s has not been registered\n",
963 clear_bit(__I40E_CLIENT_REGISTERED, &client->state);
964 list_del(&client->list);
965 pr_info("i40e: Unregistered client %s with return code %d\n",
968 mutex_unlock(&i40e_client_mutex);
971 EXPORT_SYMBOL(i40e_unregister_client);