1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 2013 - 2018 Intel Corporation. */
4 #include <linux/list.h>
5 #include <linux/errno.h>
8 #include "i40e_prototype.h"
9 #include "i40e_client.h"
11 static const char i40e_client_interface_version_str[] = I40E_CLIENT_VERSION_STR;
12 static struct i40e_client *registered_client;
13 static LIST_HEAD(i40e_devices);
14 static DEFINE_MUTEX(i40e_device_mutex);
16 static int i40e_client_virtchnl_send(struct i40e_info *ldev,
17 struct i40e_client *client,
18 u32 vf_id, u8 *msg, u16 len);
20 static int i40e_client_setup_qvlist(struct i40e_info *ldev,
21 struct i40e_client *client,
22 struct i40e_qvlist_info *qvlist_info);
24 static void i40e_client_request_reset(struct i40e_info *ldev,
25 struct i40e_client *client,
28 static int i40e_client_update_vsi_ctxt(struct i40e_info *ldev,
29 struct i40e_client *client,
30 bool is_vf, u32 vf_id,
31 u32 flag, u32 valid_flag);
33 static struct i40e_ops i40e_lan_ops = {
34 .virtchnl_send = i40e_client_virtchnl_send,
35 .setup_qvlist = i40e_client_setup_qvlist,
36 .request_reset = i40e_client_request_reset,
37 .update_vsi_ctxt = i40e_client_update_vsi_ctxt,
41 * i40e_client_get_params - Get the params that can change at runtime
42 * @vsi: the VSI with the message
43 * @params: client param struct
47 int i40e_client_get_params(struct i40e_vsi *vsi, struct i40e_params *params)
49 struct i40e_dcbx_config *dcb_cfg = &vsi->back->hw.local_dcbx_config;
52 for (i = 0; i < I40E_MAX_USER_PRIORITY; i++) {
53 u8 tc = dcb_cfg->etscfg.prioritytable[i];
56 /* If TC is not enabled for VSI use TC0 for UP */
57 if (!(vsi->tc_config.enabled_tc & BIT(tc)))
60 qs_handle = le16_to_cpu(vsi->info.qs_handle[tc]);
61 params->qos.prio_qos[i].tc = tc;
62 params->qos.prio_qos[i].qs_handle = qs_handle;
63 if (qs_handle == I40E_AQ_VSI_QS_HANDLE_INVALID) {
64 dev_err(&vsi->back->pdev->dev, "Invalid queue set handle for TC = %d, vsi id = %d\n",
70 params->mtu = vsi->netdev->mtu;
75 * i40e_notify_client_of_vf_msg - call the client vf message callback
76 * @vsi: the VSI with the message
77 * @vf_id: the absolute VF id that sent the message
78 * @msg: message buffer
79 * @len: length of the message
81 * If there is a client to this VSI, call the client
84 i40e_notify_client_of_vf_msg(struct i40e_vsi *vsi, u32 vf_id, u8 *msg, u16 len)
86 struct i40e_pf *pf = vsi->back;
87 struct i40e_client_instance *cdev = pf->cinst;
89 if (!cdev || !cdev->client)
91 if (!cdev->client->ops || !cdev->client->ops->virtchnl_receive) {
92 dev_dbg(&pf->pdev->dev,
93 "Cannot locate client instance virtual channel receive routine\n");
96 if (!test_bit(__I40E_CLIENT_INSTANCE_OPENED, &cdev->state)) {
97 dev_dbg(&pf->pdev->dev, "Client is not open, abort virtchnl_receive\n");
100 cdev->client->ops->virtchnl_receive(&cdev->lan_info, cdev->client,
105 * i40e_notify_client_of_l2_param_changes - call the client notify callback
106 * @vsi: the VSI with l2 param changes
108 * If there is a client to this VSI, call the client
110 void i40e_notify_client_of_l2_param_changes(struct i40e_vsi *vsi)
112 struct i40e_pf *pf = vsi->back;
113 struct i40e_client_instance *cdev = pf->cinst;
114 struct i40e_params params;
116 if (!cdev || !cdev->client)
118 if (!cdev->client->ops || !cdev->client->ops->l2_param_change) {
119 dev_dbg(&vsi->back->pdev->dev,
120 "Cannot locate client instance l2_param_change routine\n");
123 if (!test_bit(__I40E_CLIENT_INSTANCE_OPENED, &cdev->state)) {
124 dev_dbg(&vsi->back->pdev->dev, "Client is not open, abort l2 param change\n");
127 memset(¶ms, 0, sizeof(params));
128 i40e_client_get_params(vsi, ¶ms);
129 memcpy(&cdev->lan_info.params, ¶ms, sizeof(struct i40e_params));
130 cdev->client->ops->l2_param_change(&cdev->lan_info, cdev->client,
135 * i40e_client_release_qvlist - release MSI-X vector mapping for client
136 * @ldev: pointer to L2 context.
139 static void i40e_client_release_qvlist(struct i40e_info *ldev)
141 struct i40e_qvlist_info *qvlist_info = ldev->qvlist_info;
144 if (!ldev->qvlist_info)
147 for (i = 0; i < qvlist_info->num_vectors; i++) {
148 struct i40e_pf *pf = ldev->pf;
149 struct i40e_qv_info *qv_info;
152 qv_info = &qvlist_info->qv_info[i];
155 reg_idx = I40E_PFINT_LNKLSTN(qv_info->v_idx - 1);
156 wr32(&pf->hw, reg_idx, I40E_PFINT_LNKLSTN_FIRSTQ_INDX_MASK);
158 kfree(ldev->qvlist_info);
159 ldev->qvlist_info = NULL;
163 * i40e_notify_client_of_netdev_close - call the client close callback
164 * @vsi: the VSI with netdev closed
165 * @reset: true when close called due to a reset pending
167 * If there is a client to this netdev, call the client with close
169 void i40e_notify_client_of_netdev_close(struct i40e_vsi *vsi, bool reset)
171 struct i40e_pf *pf = vsi->back;
172 struct i40e_client_instance *cdev = pf->cinst;
174 if (!cdev || !cdev->client)
176 if (!cdev->client->ops || !cdev->client->ops->close) {
177 dev_dbg(&vsi->back->pdev->dev,
178 "Cannot locate client instance close routine\n");
181 if (!test_bit(__I40E_CLIENT_INSTANCE_OPENED, &cdev->state)) {
182 dev_dbg(&pf->pdev->dev, "Client is not open, abort close\n");
185 cdev->client->ops->close(&cdev->lan_info, cdev->client, reset);
186 clear_bit(__I40E_CLIENT_INSTANCE_OPENED, &cdev->state);
187 i40e_client_release_qvlist(&cdev->lan_info);
191 * i40e_notify_client_of_vf_reset - call the client vf reset callback
192 * @pf: PF device pointer
193 * @vf_id: asolute id of VF being reset
195 * If there is a client attached to this PF, notify when a VF is reset
197 void i40e_notify_client_of_vf_reset(struct i40e_pf *pf, u32 vf_id)
199 struct i40e_client_instance *cdev = pf->cinst;
201 if (!cdev || !cdev->client)
203 if (!cdev->client->ops || !cdev->client->ops->vf_reset) {
204 dev_dbg(&pf->pdev->dev,
205 "Cannot locate client instance VF reset routine\n");
208 if (!test_bit(__I40E_CLIENT_INSTANCE_OPENED, &cdev->state)) {
209 dev_dbg(&pf->pdev->dev, "Client is not open, abort vf-reset\n");
212 cdev->client->ops->vf_reset(&cdev->lan_info, cdev->client, vf_id);
216 * i40e_notify_client_of_vf_enable - call the client vf notification callback
217 * @pf: PF device pointer
218 * @num_vfs: the number of VFs currently enabled, 0 for disable
220 * If there is a client attached to this PF, call its VF notification routine
222 void i40e_notify_client_of_vf_enable(struct i40e_pf *pf, u32 num_vfs)
224 struct i40e_client_instance *cdev = pf->cinst;
226 if (!cdev || !cdev->client)
228 if (!cdev->client->ops || !cdev->client->ops->vf_enable) {
229 dev_dbg(&pf->pdev->dev,
230 "Cannot locate client instance VF enable routine\n");
233 if (!test_bit(__I40E_CLIENT_INSTANCE_OPENED,
235 dev_dbg(&pf->pdev->dev, "Client is not open, abort vf-enable\n");
238 cdev->client->ops->vf_enable(&cdev->lan_info, cdev->client, num_vfs);
242 * i40e_vf_client_capable - ask the client if it likes the specified VF
243 * @pf: PF device pointer
244 * @vf_id: the VF in question
246 * If there is a client of the specified type attached to this PF, call
247 * its vf_capable routine
249 int i40e_vf_client_capable(struct i40e_pf *pf, u32 vf_id)
251 struct i40e_client_instance *cdev = pf->cinst;
254 if (!cdev || !cdev->client)
256 if (!cdev->client->ops || !cdev->client->ops->vf_capable) {
257 dev_dbg(&pf->pdev->dev,
258 "Cannot locate client instance VF capability routine\n");
261 if (!test_bit(__I40E_CLIENT_INSTANCE_OPENED, &cdev->state))
264 capable = cdev->client->ops->vf_capable(&cdev->lan_info,
271 void i40e_client_update_msix_info(struct i40e_pf *pf)
273 struct i40e_client_instance *cdev = pf->cinst;
275 if (!cdev || !cdev->client)
278 cdev->lan_info.msix_count = pf->num_iwarp_msix;
279 cdev->lan_info.msix_entries = &pf->msix_entries[pf->iwarp_base_vector];
283 * i40e_client_add_instance - add a client instance struct to the instance list
284 * @pf: pointer to the board struct
285 * @client: pointer to a client struct in the client list.
286 * @existing: if there was already an existing instance
289 static void i40e_client_add_instance(struct i40e_pf *pf)
291 struct i40e_client_instance *cdev = NULL;
292 struct netdev_hw_addr *mac = NULL;
293 struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi];
295 if (!registered_client || pf->cinst)
298 cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
302 cdev->lan_info.pf = (void *)pf;
303 cdev->lan_info.netdev = vsi->netdev;
304 cdev->lan_info.pcidev = pf->pdev;
305 cdev->lan_info.fid = pf->hw.pf_id;
306 cdev->lan_info.ftype = I40E_CLIENT_FTYPE_PF;
307 cdev->lan_info.hw_addr = pf->hw.hw_addr;
308 cdev->lan_info.ops = &i40e_lan_ops;
309 cdev->lan_info.version.major = I40E_CLIENT_VERSION_MAJOR;
310 cdev->lan_info.version.minor = I40E_CLIENT_VERSION_MINOR;
311 cdev->lan_info.version.build = I40E_CLIENT_VERSION_BUILD;
312 cdev->lan_info.fw_maj_ver = pf->hw.aq.fw_maj_ver;
313 cdev->lan_info.fw_min_ver = pf->hw.aq.fw_min_ver;
314 cdev->lan_info.fw_build = pf->hw.aq.fw_build;
315 set_bit(__I40E_CLIENT_INSTANCE_NONE, &cdev->state);
317 if (i40e_client_get_params(vsi, &cdev->lan_info.params)) {
323 mac = list_first_entry(&cdev->lan_info.netdev->dev_addrs.list,
324 struct netdev_hw_addr, list);
326 ether_addr_copy(cdev->lan_info.lanmac, mac->addr);
328 dev_err(&pf->pdev->dev, "MAC address list is empty!\n");
330 cdev->client = registered_client;
333 i40e_client_update_msix_info(pf);
337 * i40e_client_del_instance - removes a client instance from the list
338 * @pf: pointer to the board struct
342 void i40e_client_del_instance(struct i40e_pf *pf)
349 * i40e_client_subtask - client maintenance work
350 * @pf: board private structure
352 void i40e_client_subtask(struct i40e_pf *pf)
354 struct i40e_client *client = registered_client;
355 struct i40e_client_instance *cdev;
356 struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi];
359 if (!test_and_clear_bit(__I40E_CLIENT_SERVICE_REQUESTED, pf->state))
363 /* If we're down or resetting, just bail */
364 if (test_bit(__I40E_DOWN, pf->state) ||
365 test_bit(__I40E_CONFIG_BUSY, pf->state))
368 if (!client || !cdev)
371 /* Here we handle client opens. If the client is down, and
372 * the netdev is registered, then open the client.
374 if (!test_bit(__I40E_CLIENT_INSTANCE_OPENED, &cdev->state)) {
375 if (vsi->netdev_registered &&
376 client->ops && client->ops->open) {
377 set_bit(__I40E_CLIENT_INSTANCE_OPENED, &cdev->state);
378 ret = client->ops->open(&cdev->lan_info, client);
380 /* Remove failed client instance */
381 clear_bit(__I40E_CLIENT_INSTANCE_OPENED,
388 /* enable/disable PE TCP_ENA flag based on netdev down/up
390 if (test_bit(__I40E_VSI_DOWN, vsi->state))
391 i40e_client_update_vsi_ctxt(&cdev->lan_info, client,
393 I40E_CLIENT_VSI_FLAG_TCP_ENABLE);
395 i40e_client_update_vsi_ctxt(&cdev->lan_info, client,
397 I40E_CLIENT_VSI_FLAG_TCP_ENABLE,
398 I40E_CLIENT_VSI_FLAG_TCP_ENABLE);
402 * i40e_lan_add_device - add a lan device struct to the list of lan devices
403 * @pf: pointer to the board struct
405 * Returns 0 on success or none 0 on error
407 int i40e_lan_add_device(struct i40e_pf *pf)
409 struct i40e_device *ldev;
412 mutex_lock(&i40e_device_mutex);
413 list_for_each_entry(ldev, &i40e_devices, list) {
414 if (ldev->pf == pf) {
419 ldev = kzalloc(sizeof(*ldev), GFP_KERNEL);
425 INIT_LIST_HEAD(&ldev->list);
426 list_add(&ldev->list, &i40e_devices);
427 dev_info(&pf->pdev->dev, "Added LAN device PF%d bus=0x%02x dev=0x%02x func=0x%02x\n",
428 pf->hw.pf_id, pf->hw.bus.bus_id,
429 pf->hw.bus.device, pf->hw.bus.func);
431 /* If a client has already been registered, we need to add an instance
432 * of it to our new LAN device.
434 if (registered_client)
435 i40e_client_add_instance(pf);
437 /* Since in some cases register may have happened before a device gets
438 * added, we can schedule a subtask to go initiate the clients if
439 * they can be launched at probe time.
441 set_bit(__I40E_CLIENT_SERVICE_REQUESTED, pf->state);
442 i40e_service_event_schedule(pf);
445 mutex_unlock(&i40e_device_mutex);
450 * i40e_lan_del_device - removes a lan device from the device list
451 * @pf: pointer to the board struct
453 * Returns 0 on success or non-0 on error
455 int i40e_lan_del_device(struct i40e_pf *pf)
457 struct i40e_device *ldev, *tmp;
460 /* First, remove any client instance. */
461 i40e_client_del_instance(pf);
463 mutex_lock(&i40e_device_mutex);
464 list_for_each_entry_safe(ldev, tmp, &i40e_devices, list) {
465 if (ldev->pf == pf) {
466 dev_info(&pf->pdev->dev, "Deleted LAN device PF%d bus=0x%02x dev=0x%02x func=0x%02x\n",
467 pf->hw.pf_id, pf->hw.bus.bus_id,
468 pf->hw.bus.device, pf->hw.bus.func);
469 list_del(&ldev->list);
475 mutex_unlock(&i40e_device_mutex);
480 * i40e_client_release - release client specific resources
481 * @client: pointer to the registered client
484 static void i40e_client_release(struct i40e_client *client)
486 struct i40e_client_instance *cdev;
487 struct i40e_device *ldev;
490 mutex_lock(&i40e_device_mutex);
491 list_for_each_entry(ldev, &i40e_devices, list) {
497 while (test_and_set_bit(__I40E_SERVICE_SCHED,
499 usleep_range(500, 1000);
501 if (test_bit(__I40E_CLIENT_INSTANCE_OPENED, &cdev->state)) {
502 if (client->ops && client->ops->close)
503 client->ops->close(&cdev->lan_info, client,
505 i40e_client_release_qvlist(&cdev->lan_info);
506 clear_bit(__I40E_CLIENT_INSTANCE_OPENED, &cdev->state);
508 dev_warn(&pf->pdev->dev,
509 "Client %s instance for PF id %d closed\n",
510 client->name, pf->hw.pf_id);
512 /* delete the client instance */
513 i40e_client_del_instance(pf);
514 dev_info(&pf->pdev->dev, "Deleted client instance of Client %s\n",
516 clear_bit(__I40E_SERVICE_SCHED, pf->state);
518 mutex_unlock(&i40e_device_mutex);
522 * i40e_client_prepare - prepare client specific resources
523 * @client: pointer to the registered client
526 static void i40e_client_prepare(struct i40e_client *client)
528 struct i40e_device *ldev;
531 mutex_lock(&i40e_device_mutex);
532 list_for_each_entry(ldev, &i40e_devices, list) {
534 i40e_client_add_instance(pf);
535 /* Start the client subtask */
536 set_bit(__I40E_CLIENT_SERVICE_REQUESTED, pf->state);
537 i40e_service_event_schedule(pf);
539 mutex_unlock(&i40e_device_mutex);
543 * i40e_client_virtchnl_send - TBD
544 * @ldev: pointer to L2 context
545 * @client: Client pointer
546 * @vf_id: absolute VF identifier
547 * @msg: message buffer
548 * @len: length of message buffer
550 * Return 0 on success or < 0 on error
552 static int i40e_client_virtchnl_send(struct i40e_info *ldev,
553 struct i40e_client *client,
554 u32 vf_id, u8 *msg, u16 len)
556 struct i40e_pf *pf = ldev->pf;
557 struct i40e_hw *hw = &pf->hw;
560 err = i40e_aq_send_msg_to_vf(hw, vf_id, VIRTCHNL_OP_IWARP,
563 dev_err(&pf->pdev->dev, "Unable to send iWarp message to VF, error %d, aq status %d\n",
564 err, hw->aq.asq_last_status);
570 * i40e_client_setup_qvlist
571 * @ldev: pointer to L2 context.
572 * @client: Client pointer.
573 * @qvlist_info: queue and vector list
575 * Return 0 on success or < 0 on error
577 static int i40e_client_setup_qvlist(struct i40e_info *ldev,
578 struct i40e_client *client,
579 struct i40e_qvlist_info *qvlist_info)
581 struct i40e_pf *pf = ldev->pf;
582 struct i40e_hw *hw = &pf->hw;
583 struct i40e_qv_info *qv_info;
584 u32 v_idx, i, reg_idx, reg;
587 size = sizeof(struct i40e_qvlist_info) +
588 (sizeof(struct i40e_qv_info) * (qvlist_info->num_vectors - 1));
589 ldev->qvlist_info = kzalloc(size, GFP_KERNEL);
590 if (!ldev->qvlist_info)
592 ldev->qvlist_info->num_vectors = qvlist_info->num_vectors;
594 for (i = 0; i < qvlist_info->num_vectors; i++) {
595 qv_info = &qvlist_info->qv_info[i];
598 v_idx = qv_info->v_idx;
600 /* Validate vector id belongs to this client */
601 if ((v_idx >= (pf->iwarp_base_vector + pf->num_iwarp_msix)) ||
602 (v_idx < pf->iwarp_base_vector))
605 ldev->qvlist_info->qv_info[i] = *qv_info;
606 reg_idx = I40E_PFINT_LNKLSTN(v_idx - 1);
608 if (qv_info->ceq_idx == I40E_QUEUE_INVALID_IDX) {
609 /* Special case - No CEQ mapped on this vector */
610 wr32(hw, reg_idx, I40E_PFINT_LNKLSTN_FIRSTQ_INDX_MASK);
612 reg = (qv_info->ceq_idx &
613 I40E_PFINT_LNKLSTN_FIRSTQ_INDX_MASK) |
614 (I40E_QUEUE_TYPE_PE_CEQ <<
615 I40E_PFINT_LNKLSTN_FIRSTQ_TYPE_SHIFT);
616 wr32(hw, reg_idx, reg);
618 reg = (I40E_PFINT_CEQCTL_CAUSE_ENA_MASK |
619 (v_idx << I40E_PFINT_CEQCTL_MSIX_INDX_SHIFT) |
621 I40E_PFINT_CEQCTL_ITR_INDX_SHIFT) |
622 (I40E_QUEUE_END_OF_LIST <<
623 I40E_PFINT_CEQCTL_NEXTQ_INDX_SHIFT));
624 wr32(hw, I40E_PFINT_CEQCTL(qv_info->ceq_idx), reg);
626 if (qv_info->aeq_idx != I40E_QUEUE_INVALID_IDX) {
627 reg = (I40E_PFINT_AEQCTL_CAUSE_ENA_MASK |
628 (v_idx << I40E_PFINT_AEQCTL_MSIX_INDX_SHIFT) |
630 I40E_PFINT_AEQCTL_ITR_INDX_SHIFT));
632 wr32(hw, I40E_PFINT_AEQCTL, reg);
635 /* Mitigate sync problems with iwarp VF driver */
639 kfree(ldev->qvlist_info);
640 ldev->qvlist_info = NULL;
645 * i40e_client_request_reset
646 * @ldev: pointer to L2 context.
647 * @client: Client pointer.
648 * @reset_level: reset level
650 static void i40e_client_request_reset(struct i40e_info *ldev,
651 struct i40e_client *client,
654 struct i40e_pf *pf = ldev->pf;
656 switch (reset_level) {
657 case I40E_CLIENT_RESET_LEVEL_PF:
658 set_bit(__I40E_PF_RESET_REQUESTED, pf->state);
660 case I40E_CLIENT_RESET_LEVEL_CORE:
661 set_bit(__I40E_PF_RESET_REQUESTED, pf->state);
664 dev_warn(&pf->pdev->dev,
665 "Client for PF id %d requested an unsupported reset: %d.\n",
666 pf->hw.pf_id, reset_level);
670 i40e_service_event_schedule(pf);
674 * i40e_client_update_vsi_ctxt
675 * @ldev: pointer to L2 context.
676 * @client: Client pointer.
677 * @is_vf: if this for the VF
678 * @vf_id: if is_vf true this carries the vf_id
679 * @flag: Any device level setting that needs to be done for PE
680 * @valid_flag: Bits in this match up and enable changing of flag bits
682 * Return 0 on success or < 0 on error
684 static int i40e_client_update_vsi_ctxt(struct i40e_info *ldev,
685 struct i40e_client *client,
686 bool is_vf, u32 vf_id,
687 u32 flag, u32 valid_flag)
689 struct i40e_pf *pf = ldev->pf;
690 struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi];
691 struct i40e_vsi_context ctxt;
695 /* TODO: for now do not allow setting VF's VSI setting */
699 ctxt.seid = pf->main_vsi_seid;
700 ctxt.pf_num = pf->hw.pf_id;
701 err = i40e_aq_get_vsi_params(&pf->hw, &ctxt, NULL);
702 ctxt.flags = I40E_AQ_VSI_TYPE_PF;
704 dev_info(&pf->pdev->dev,
705 "couldn't get PF vsi config, err %s aq_err %s\n",
706 i40e_stat_str(&pf->hw, err),
708 pf->hw.aq.asq_last_status));
712 if ((valid_flag & I40E_CLIENT_VSI_FLAG_TCP_ENABLE) &&
713 (flag & I40E_CLIENT_VSI_FLAG_TCP_ENABLE)) {
714 ctxt.info.valid_sections =
715 cpu_to_le16(I40E_AQ_VSI_PROP_QUEUE_OPT_VALID);
716 ctxt.info.queueing_opt_flags |= I40E_AQ_VSI_QUE_OPT_TCP_ENA;
717 } else if ((valid_flag & I40E_CLIENT_VSI_FLAG_TCP_ENABLE) &&
718 !(flag & I40E_CLIENT_VSI_FLAG_TCP_ENABLE)) {
719 ctxt.info.valid_sections =
720 cpu_to_le16(I40E_AQ_VSI_PROP_QUEUE_OPT_VALID);
721 ctxt.info.queueing_opt_flags &= ~I40E_AQ_VSI_QUE_OPT_TCP_ENA;
724 dev_warn(&pf->pdev->dev,
725 "Client for PF id %d request an unsupported Config: %x.\n",
730 err = i40e_aq_update_vsi_params(&vsi->back->hw, &ctxt, NULL);
732 dev_info(&pf->pdev->dev,
733 "update VSI ctxt for PE failed, err %s aq_err %s\n",
734 i40e_stat_str(&pf->hw, err),
736 pf->hw.aq.asq_last_status));
743 * i40e_register_client - Register a i40e client driver with the L2 driver
744 * @client: pointer to the i40e_client struct
746 * Returns 0 on success or non-0 on error
748 int i40e_register_client(struct i40e_client *client)
757 if (strlen(client->name) == 0) {
758 pr_info("i40e: Failed to register client with no name\n");
763 if (registered_client) {
764 pr_info("i40e: Client %s has already been registered!\n",
770 if ((client->version.major != I40E_CLIENT_VERSION_MAJOR) ||
771 (client->version.minor != I40E_CLIENT_VERSION_MINOR)) {
772 pr_info("i40e: Failed to register client %s due to mismatched client interface version\n",
774 pr_info("Client is using version: %02d.%02d.%02d while LAN driver supports %s\n",
775 client->version.major, client->version.minor,
776 client->version.build,
777 i40e_client_interface_version_str);
782 registered_client = client;
784 i40e_client_prepare(client);
786 pr_info("i40e: Registered client %s\n", client->name);
790 EXPORT_SYMBOL(i40e_register_client);
793 * i40e_unregister_client - Unregister a i40e client driver with the L2 driver
794 * @client: pointer to the i40e_client struct
796 * Returns 0 on success or non-0 on error
798 int i40e_unregister_client(struct i40e_client *client)
802 if (registered_client != client) {
803 pr_info("i40e: Client %s has not been registered\n",
808 registered_client = NULL;
809 /* When a unregister request comes through we would have to send
810 * a close for each of the client instances that were opened.
811 * client_release function is called to handle this.
813 i40e_client_release(client);
815 pr_info("i40e: Unregistered client %s\n", client->name);
819 EXPORT_SYMBOL(i40e_unregister_client);