Lines Matching +full:use +full:- +full:ncsi
1 // SPDX-License-Identifier: GPL-2.0-or-later
14 #include <net/ncsi.h>
22 #include "ncsi-pkt.h"
23 #include "ncsi-netlink.h"
30 return !!(channel->modes[NCSI_MODE_LINK].data[2] & 0x1); in ncsi_channel_has_link()
43 if (nc->state == NCSI_CHANNEL_ACTIVE && in ncsi_channel_is_last()
53 struct ncsi_dev *nd = &ndp->ndev; in ncsi_report_link()
58 nd->state = ncsi_dev_state_functional; in ncsi_report_link()
60 nd->link_up = 0; in ncsi_report_link()
64 nd->link_up = 0; in ncsi_report_link()
67 spin_lock_irqsave(&nc->lock, flags); in ncsi_report_link()
69 if (!list_empty(&nc->link) || in ncsi_report_link()
70 nc->state != NCSI_CHANNEL_ACTIVE) { in ncsi_report_link()
71 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_report_link()
76 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_report_link()
77 nd->link_up = 1; in ncsi_report_link()
81 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_report_link()
86 nd->handler(nd); in ncsi_report_link()
92 struct ncsi_package *np = nc->package; in ncsi_channel_monitor()
93 struct ncsi_dev_priv *ndp = np->ndp; in ncsi_channel_monitor()
101 spin_lock_irqsave(&nc->lock, flags); in ncsi_channel_monitor()
102 state = nc->state; in ncsi_channel_monitor()
103 chained = !list_empty(&nc->link); in ncsi_channel_monitor()
104 enabled = nc->monitor.enabled; in ncsi_channel_monitor()
105 monitor_state = nc->monitor.state; in ncsi_channel_monitor()
106 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_channel_monitor()
116 netdev_warn(ndp->ndev.dev, in ncsi_channel_monitor()
117 "Bad NCSI monitor state channel %d 0x%x %s queue\n", in ncsi_channel_monitor()
118 nc->id, state, chained ? "on" : "off"); in ncsi_channel_monitor()
119 spin_lock_irqsave(&nc->lock, flags); in ncsi_channel_monitor()
120 nc->monitor.enabled = false; in ncsi_channel_monitor()
121 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_channel_monitor()
129 nca.package = np->id; in ncsi_channel_monitor()
130 nca.channel = nc->id; in ncsi_channel_monitor()
135 netdev_err(ndp->ndev.dev, "Error %d sending GLS\n", in ncsi_channel_monitor()
141 netdev_err(ndp->ndev.dev, "NCSI Channel %d timed out!\n", in ncsi_channel_monitor()
142 nc->id); in ncsi_channel_monitor()
144 ndp->flags |= NCSI_DEV_RESHUFFLE; in ncsi_channel_monitor()
146 ncm = &nc->modes[NCSI_MODE_LINK]; in ncsi_channel_monitor()
147 spin_lock_irqsave(&nc->lock, flags); in ncsi_channel_monitor()
148 nc->monitor.enabled = false; in ncsi_channel_monitor()
149 nc->state = NCSI_CHANNEL_INVISIBLE; in ncsi_channel_monitor()
150 ncm->data[2] &= ~0x1; in ncsi_channel_monitor()
151 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_channel_monitor()
153 spin_lock_irqsave(&ndp->lock, flags); in ncsi_channel_monitor()
154 nc->state = NCSI_CHANNEL_ACTIVE; in ncsi_channel_monitor()
155 list_add_tail_rcu(&nc->link, &ndp->channel_queue); in ncsi_channel_monitor()
156 spin_unlock_irqrestore(&ndp->lock, flags); in ncsi_channel_monitor()
161 spin_lock_irqsave(&nc->lock, flags); in ncsi_channel_monitor()
162 nc->monitor.state++; in ncsi_channel_monitor()
163 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_channel_monitor()
164 mod_timer(&nc->monitor.timer, jiffies + HZ); in ncsi_channel_monitor()
171 spin_lock_irqsave(&nc->lock, flags); in ncsi_start_channel_monitor()
172 WARN_ON_ONCE(nc->monitor.enabled); in ncsi_start_channel_monitor()
173 nc->monitor.enabled = true; in ncsi_start_channel_monitor()
174 nc->monitor.state = NCSI_CHANNEL_MONITOR_START; in ncsi_start_channel_monitor()
175 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_start_channel_monitor()
177 mod_timer(&nc->monitor.timer, jiffies + HZ); in ncsi_start_channel_monitor()
184 spin_lock_irqsave(&nc->lock, flags); in ncsi_stop_channel_monitor()
185 if (!nc->monitor.enabled) { in ncsi_stop_channel_monitor()
186 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_stop_channel_monitor()
189 nc->monitor.enabled = false; in ncsi_stop_channel_monitor()
190 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_stop_channel_monitor()
192 del_timer_sync(&nc->monitor.timer); in ncsi_stop_channel_monitor()
201 if (nc->id == id) in ncsi_find_channel()
218 nc->id = id; in ncsi_add_channel()
219 nc->package = np; in ncsi_add_channel()
220 nc->state = NCSI_CHANNEL_INACTIVE; in ncsi_add_channel()
221 nc->monitor.enabled = false; in ncsi_add_channel()
222 timer_setup(&nc->monitor.timer, ncsi_channel_monitor, 0); in ncsi_add_channel()
223 spin_lock_init(&nc->lock); in ncsi_add_channel()
224 INIT_LIST_HEAD(&nc->link); in ncsi_add_channel()
226 nc->caps[index].index = index; in ncsi_add_channel()
228 nc->modes[index].index = index; in ncsi_add_channel()
230 spin_lock_irqsave(&np->lock, flags); in ncsi_add_channel()
233 spin_unlock_irqrestore(&np->lock, flags); in ncsi_add_channel()
238 list_add_tail_rcu(&nc->node, &np->channels); in ncsi_add_channel()
239 np->channel_num++; in ncsi_add_channel()
240 spin_unlock_irqrestore(&np->lock, flags); in ncsi_add_channel()
247 struct ncsi_package *np = nc->package; in ncsi_remove_channel()
250 spin_lock_irqsave(&nc->lock, flags); in ncsi_remove_channel()
253 kfree(nc->mac_filter.addrs); in ncsi_remove_channel()
254 kfree(nc->vlan_filter.vids); in ncsi_remove_channel()
256 nc->state = NCSI_CHANNEL_INACTIVE; in ncsi_remove_channel()
257 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_remove_channel()
261 spin_lock_irqsave(&np->lock, flags); in ncsi_remove_channel()
262 list_del_rcu(&nc->node); in ncsi_remove_channel()
263 np->channel_num--; in ncsi_remove_channel()
264 spin_unlock_irqrestore(&np->lock, flags); in ncsi_remove_channel()
275 if (np->id == id) in ncsi_find_package()
292 np->id = id; in ncsi_add_package()
293 np->ndp = ndp; in ncsi_add_package()
294 spin_lock_init(&np->lock); in ncsi_add_package()
295 INIT_LIST_HEAD(&np->channels); in ncsi_add_package()
296 np->channel_whitelist = UINT_MAX; in ncsi_add_package()
298 spin_lock_irqsave(&ndp->lock, flags); in ncsi_add_package()
301 spin_unlock_irqrestore(&ndp->lock, flags); in ncsi_add_package()
306 list_add_tail_rcu(&np->node, &ndp->packages); in ncsi_add_package()
307 ndp->package_num++; in ncsi_add_package()
308 spin_unlock_irqrestore(&ndp->lock, flags); in ncsi_add_package()
315 struct ncsi_dev_priv *ndp = np->ndp; in ncsi_remove_package()
320 list_for_each_entry_safe(nc, tmp, &np->channels, node) in ncsi_remove_package()
324 spin_lock_irqsave(&ndp->lock, flags); in ncsi_remove_package()
325 list_del_rcu(&np->node); in ncsi_remove_package()
326 ndp->package_num--; in ncsi_remove_package()
327 spin_unlock_irqrestore(&ndp->lock, flags); in ncsi_remove_package()
349 /* For two consecutive NCSI commands, the packet IDs shouldn't
351 * the available IDs are allocated in round-robin fashion.
357 int i, limit = ARRAY_SIZE(ndp->requests); in ncsi_alloc_request()
361 spin_lock_irqsave(&ndp->lock, flags); in ncsi_alloc_request()
362 for (i = ndp->request_id; i < limit; i++) { in ncsi_alloc_request()
363 if (ndp->requests[i].used) in ncsi_alloc_request()
366 nr = &ndp->requests[i]; in ncsi_alloc_request()
367 nr->used = true; in ncsi_alloc_request()
368 nr->flags = req_flags; in ncsi_alloc_request()
369 ndp->request_id = i + 1; in ncsi_alloc_request()
374 for (i = NCSI_REQ_START_IDX; i < ndp->request_id; i++) { in ncsi_alloc_request()
375 if (ndp->requests[i].used) in ncsi_alloc_request()
378 nr = &ndp->requests[i]; in ncsi_alloc_request()
379 nr->used = true; in ncsi_alloc_request()
380 nr->flags = req_flags; in ncsi_alloc_request()
381 ndp->request_id = i + 1; in ncsi_alloc_request()
386 spin_unlock_irqrestore(&ndp->lock, flags); in ncsi_alloc_request()
392 struct ncsi_dev_priv *ndp = nr->ndp; in ncsi_free_request()
397 if (nr->enabled) { in ncsi_free_request()
398 nr->enabled = false; in ncsi_free_request()
399 del_timer_sync(&nr->timer); in ncsi_free_request()
402 spin_lock_irqsave(&ndp->lock, flags); in ncsi_free_request()
403 cmd = nr->cmd; in ncsi_free_request()
404 rsp = nr->rsp; in ncsi_free_request()
405 nr->cmd = NULL; in ncsi_free_request()
406 nr->rsp = NULL; in ncsi_free_request()
407 nr->used = false; in ncsi_free_request()
408 driven = !!(nr->flags & NCSI_REQ_FLAG_EVENT_DRIVEN); in ncsi_free_request()
409 spin_unlock_irqrestore(&ndp->lock, flags); in ncsi_free_request()
411 if (driven && cmd && --ndp->pending_req_num == 0) in ncsi_free_request()
412 schedule_work(&ndp->work); in ncsi_free_request()
424 if (ndp->ndev.dev == dev) in ncsi_find_dev()
425 return &ndp->ndev; in ncsi_find_dev()
434 struct ncsi_dev_priv *ndp = nr->ndp; in ncsi_request_timeout()
443 spin_lock_irqsave(&ndp->lock, flags); in ncsi_request_timeout()
444 nr->enabled = false; in ncsi_request_timeout()
445 if (nr->rsp || !nr->cmd) { in ncsi_request_timeout()
446 spin_unlock_irqrestore(&ndp->lock, flags); in ncsi_request_timeout()
449 spin_unlock_irqrestore(&ndp->lock, flags); in ncsi_request_timeout()
451 if (nr->flags == NCSI_REQ_FLAG_NETLINK_DRIVEN) { in ncsi_request_timeout()
452 if (nr->cmd) { in ncsi_request_timeout()
455 skb_network_header(nr->cmd); in ncsi_request_timeout()
457 cmd->cmd.common.channel, in ncsi_request_timeout()
469 struct ncsi_dev *nd = &ndp->ndev; in ncsi_suspend_channel()
476 np = ndp->active_package; in ncsi_suspend_channel()
477 nc = ndp->active_channel; in ncsi_suspend_channel()
480 switch (nd->state) { in ncsi_suspend_channel()
482 nd->state = ncsi_dev_state_suspend_select; in ncsi_suspend_channel()
485 ndp->pending_req_num = 1; in ncsi_suspend_channel()
488 nca.package = np->id; in ncsi_suspend_channel()
490 if (ndp->flags & NCSI_DEV_HWA) in ncsi_suspend_channel()
503 if (ndp->flags & NCSI_DEV_RESHUFFLE) in ncsi_suspend_channel()
504 nd->state = ncsi_dev_state_suspend_gls; in ncsi_suspend_channel()
506 nd->state = ncsi_dev_state_suspend_dcnt; in ncsi_suspend_channel()
513 ndp->pending_req_num = 1; in ncsi_suspend_channel()
516 nca.package = np->id; in ncsi_suspend_channel()
517 nca.channel = ndp->channel_probe_id; in ncsi_suspend_channel()
521 ndp->channel_probe_id++; in ncsi_suspend_channel()
523 if (ndp->channel_probe_id == ndp->channel_count) { in ncsi_suspend_channel()
524 ndp->channel_probe_id = 0; in ncsi_suspend_channel()
525 nd->state = ncsi_dev_state_suspend_dcnt; in ncsi_suspend_channel()
530 ndp->pending_req_num = 1; in ncsi_suspend_channel()
533 nca.package = np->id; in ncsi_suspend_channel()
534 nca.channel = nc->id; in ncsi_suspend_channel()
536 nd->state = ncsi_dev_state_suspend_dc; in ncsi_suspend_channel()
543 ndp->pending_req_num = 1; in ncsi_suspend_channel()
546 nca.package = np->id; in ncsi_suspend_channel()
547 nca.channel = nc->id; in ncsi_suspend_channel()
550 nd->state = ncsi_dev_state_suspend_deselect; in ncsi_suspend_channel()
559 if (tmp != nc && tmp->state == NCSI_CHANNEL_ACTIVE) { in ncsi_suspend_channel()
560 nd->state = ncsi_dev_state_suspend_done; in ncsi_suspend_channel()
566 ndp->pending_req_num = 1; in ncsi_suspend_channel()
569 nca.package = np->id; in ncsi_suspend_channel()
572 nd->state = ncsi_dev_state_suspend_done; in ncsi_suspend_channel()
579 spin_lock_irqsave(&nc->lock, flags); in ncsi_suspend_channel()
580 nc->state = NCSI_CHANNEL_INACTIVE; in ncsi_suspend_channel()
581 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_suspend_channel()
582 if (ndp->flags & NCSI_DEV_RESET) in ncsi_suspend_channel()
588 netdev_warn(nd->dev, "Wrong NCSI state 0x%x in suspend\n", in ncsi_suspend_channel()
589 nd->state); in ncsi_suspend_channel()
594 nd->state = ncsi_dev_state_functional; in ncsi_suspend_channel()
598 * "Set VLAN Filter - Disable" packet if found.
609 ncf = &nc->vlan_filter; in clear_one_vid()
610 bitmap = &ncf->bitmap; in clear_one_vid()
612 spin_lock_irqsave(&nc->lock, flags); in clear_one_vid()
613 index = find_first_bit(bitmap, ncf->n_vids); in clear_one_vid()
614 if (index >= ncf->n_vids) { in clear_one_vid()
615 spin_unlock_irqrestore(&nc->lock, flags); in clear_one_vid()
616 return -1; in clear_one_vid()
618 vid = ncf->vids[index]; in clear_one_vid()
621 ncf->vids[index] = 0; in clear_one_vid()
622 spin_unlock_irqrestore(&nc->lock, flags); in clear_one_vid()
624 nca->type = NCSI_PKT_CMD_SVF; in clear_one_vid()
625 nca->words[1] = vid; in clear_one_vid()
627 nca->bytes[6] = index + 1; in clear_one_vid()
628 nca->bytes[7] = 0x00; in clear_one_vid()
632 /* Find an outstanding VLAN tag and construct a "Set VLAN Filter - Enable"
645 if (list_empty(&ndp->vlan_vids)) in set_one_vid()
646 return -1; in set_one_vid()
648 ncf = &nc->vlan_filter; in set_one_vid()
649 bitmap = &ncf->bitmap; in set_one_vid()
651 spin_lock_irqsave(&nc->lock, flags); in set_one_vid()
654 list_for_each_entry_rcu(vlan, &ndp->vlan_vids, list) { in set_one_vid()
655 vid = vlan->vid; in set_one_vid()
656 for (i = 0; i < ncf->n_vids; i++) in set_one_vid()
657 if (ncf->vids[i] == vid) { in set_one_vid()
668 spin_unlock_irqrestore(&nc->lock, flags); in set_one_vid()
669 return -1; in set_one_vid()
672 index = find_first_zero_bit(bitmap, ncf->n_vids); in set_one_vid()
673 if (index < 0 || index >= ncf->n_vids) { in set_one_vid()
674 netdev_err(ndp->ndev.dev, in set_one_vid()
676 nc->id); in set_one_vid()
677 spin_unlock_irqrestore(&nc->lock, flags); in set_one_vid()
678 return -1; in set_one_vid()
681 ncf->vids[index] = vid; in set_one_vid()
683 spin_unlock_irqrestore(&nc->lock, flags); in set_one_vid()
685 nca->type = NCSI_PKT_CMD_SVF; in set_one_vid()
686 nca->words[1] = vid; in set_one_vid()
688 nca->bytes[6] = index + 1; in set_one_vid()
689 nca->bytes[7] = 0x01; in set_one_vid()
699 nca->payload = NCSI_OEM_INTEL_CMD_KEEP_PHY_LEN; in ncsi_oem_keep_phy_intel()
709 nca->data = data; in ncsi_oem_keep_phy_intel()
713 netdev_err(nca->ndp->ndev.dev, in ncsi_oem_keep_phy_intel()
714 "NCSI: Failed to transmit cmd 0x%x during configure\n", in ncsi_oem_keep_phy_intel()
715 nca->type); in ncsi_oem_keep_phy_intel()
719 /* NCSI OEM Command APIs */
725 nca->payload = NCSI_OEM_BCM_CMD_GMA_LEN; in ncsi_oem_gma_handler_bcm()
731 nca->data = data; in ncsi_oem_gma_handler_bcm()
735 netdev_err(nca->ndp->ndev.dev, in ncsi_oem_gma_handler_bcm()
736 "NCSI: Failed to transmit cmd 0x%x during configure\n", in ncsi_oem_gma_handler_bcm()
737 nca->type); in ncsi_oem_gma_handler_bcm()
749 nca->payload = NCSI_OEM_MLX_CMD_GMA_LEN; in ncsi_oem_gma_handler_mlx()
756 nca->data = u.data_u8; in ncsi_oem_gma_handler_mlx()
760 netdev_err(nca->ndp->ndev.dev, in ncsi_oem_gma_handler_mlx()
761 "NCSI: Failed to transmit cmd 0x%x during configure\n", in ncsi_oem_gma_handler_mlx()
762 nca->type); in ncsi_oem_gma_handler_mlx()
779 nca->ndp->ndev.dev->dev_addr, ETH_ALEN); in ncsi_oem_smaf_mlx()
783 nca->payload = NCSI_OEM_MLX_CMD_SMAF_LEN; in ncsi_oem_smaf_mlx()
784 nca->data = u.data_u8; in ncsi_oem_smaf_mlx()
788 netdev_err(nca->ndp->ndev.dev, in ncsi_oem_smaf_mlx()
789 "NCSI: Failed to transmit cmd 0x%x during probe\n", in ncsi_oem_smaf_mlx()
790 nca->type); in ncsi_oem_smaf_mlx()
799 nca->payload = NCSI_OEM_INTEL_CMD_GMA_LEN; in ncsi_oem_gma_handler_intel()
805 nca->data = data; in ncsi_oem_gma_handler_intel()
809 netdev_err(nca->ndp->ndev.dev, in ncsi_oem_gma_handler_intel()
810 "NCSI: Failed to transmit cmd 0x%x during configure\n", in ncsi_oem_gma_handler_intel()
811 nca->type); in ncsi_oem_gma_handler_intel()
832 if (nca->ndp->gma_flag == 1) in ncsi_gma_handler()
833 return -1; in ncsi_gma_handler()
845 netdev_err(nca->ndp->ndev.dev, in ncsi_gma_handler()
846 "NCSI: No GMA handler available for MFR-ID (0x%x)\n", in ncsi_gma_handler()
848 return -1; in ncsi_gma_handler()
851 /* Get Mac address from NCSI device */ in ncsi_gma_handler()
852 return nch->handler(nca); in ncsi_gma_handler()
867 if (!ndp->multi_package && np != nc->package) in ncsi_channel_is_tx()
870 ncm = &channel->modes[NCSI_MODE_TX_ENABLE]; in ncsi_channel_is_tx()
871 if (ncm->enable) in ncsi_channel_is_tx()
877 list_for_each_entry_rcu(channel, &ndp->channel_queue, link) { in ncsi_channel_is_tx()
878 np = channel->package; in ncsi_channel_is_tx()
879 if (np->preferred_channel && in ncsi_channel_is_tx()
880 ncsi_channel_has_link(np->preferred_channel)) { in ncsi_channel_is_tx()
881 return np->preferred_channel == nc; in ncsi_channel_is_tx()
889 list_for_each_entry_rcu(channel, &ndp->channel_queue, link) in ncsi_channel_is_tx()
897 /* Change the active Tx channel in a multi-channel setup */
908 if (!package->multi_channel && !ndp->multi_package) in ncsi_update_tx_channel()
909 netdev_warn(ndp->ndev.dev, in ncsi_update_tx_channel()
910 "NCSI: Trying to update Tx channel in single-channel mode\n"); in ncsi_update_tx_channel()
918 if (!ndp->multi_package && np != package) in ncsi_update_tx_channel()
922 if (nc->modes[NCSI_MODE_TX_ENABLE].enable) { in ncsi_update_tx_channel()
932 if (!ndp->multi_package && np != package) in ncsi_update_tx_channel()
934 if (!(ndp->package_whitelist & (0x1 << np->id))) in ncsi_update_tx_channel()
937 if (np->preferred_channel && in ncsi_update_tx_channel()
938 ncsi_channel_has_link(np->preferred_channel)) { in ncsi_update_tx_channel()
939 enable = np->preferred_channel; in ncsi_update_tx_channel()
944 if (!(np->channel_whitelist & 0x1 << nc->id)) in ncsi_update_tx_channel()
946 if (nc->state != NCSI_CHANNEL_ACTIVE) in ncsi_update_tx_channel()
956 return -1; in ncsi_update_tx_channel()
959 return -1; in ncsi_update_tx_channel()
962 nca.channel = disable->id; in ncsi_update_tx_channel()
963 nca.package = disable->package->id; in ncsi_update_tx_channel()
967 netdev_err(ndp->ndev.dev, in ncsi_update_tx_channel()
972 netdev_info(ndp->ndev.dev, "NCSI: channel %u enables Tx\n", enable->id); in ncsi_update_tx_channel()
974 nca.channel = enable->id; in ncsi_update_tx_channel()
975 nca.package = enable->package->id; in ncsi_update_tx_channel()
979 netdev_err(ndp->ndev.dev, in ncsi_update_tx_channel()
988 struct ncsi_package *np = ndp->active_package; in ncsi_configure_channel()
989 struct ncsi_channel *nc = ndp->active_channel; in ncsi_configure_channel()
991 struct ncsi_dev *nd = &ndp->ndev; in ncsi_configure_channel()
992 struct net_device *dev = nd->dev; in ncsi_configure_channel()
1000 switch (nd->state) { in ncsi_configure_channel()
1003 ndp->pending_req_num = 1; in ncsi_configure_channel()
1007 if (ndp->flags & NCSI_DEV_HWA) in ncsi_configure_channel()
1011 nca.package = np->id; in ncsi_configure_channel()
1015 netdev_err(ndp->ndev.dev, in ncsi_configure_channel()
1016 "NCSI: Failed to transmit CMD_SP\n"); in ncsi_configure_channel()
1020 nd->state = ncsi_dev_state_config_cis; in ncsi_configure_channel()
1023 ndp->pending_req_num = 1; in ncsi_configure_channel()
1027 nca.package = np->id; in ncsi_configure_channel()
1028 nca.channel = nc->id; in ncsi_configure_channel()
1031 netdev_err(ndp->ndev.dev, in ncsi_configure_channel()
1032 "NCSI: Failed to transmit CMD_CIS\n"); in ncsi_configure_channel()
1036 nd->state = IS_ENABLED(CONFIG_NCSI_OEM_CMD_GET_MAC) in ncsi_configure_channel()
1041 nd->state = ncsi_dev_state_config_clear_vids; in ncsi_configure_channel()
1043 nca.package = np->id; in ncsi_configure_channel()
1044 nca.channel = nc->id; in ncsi_configure_channel()
1045 ndp->pending_req_num = 1; in ncsi_configure_channel()
1046 if (nc->version.major >= 1 && nc->version.minor >= 2) { in ncsi_configure_channel()
1051 ret = ncsi_gma_handler(&nca, nc->version.mf_id); in ncsi_configure_channel()
1054 schedule_work(&ndp->work); in ncsi_configure_channel()
1067 ndp->pending_req_num = 1; in ncsi_configure_channel()
1069 nca.package = np->id; in ncsi_configure_channel()
1070 nca.channel = nc->id; in ncsi_configure_channel()
1073 if (nd->state == ncsi_dev_state_config_clear_vids) { in ncsi_configure_channel()
1076 nd->state = ncsi_dev_state_config_svf; in ncsi_configure_channel()
1077 schedule_work(&ndp->work); in ncsi_configure_channel()
1081 nd->state = ncsi_dev_state_config_clear_vids; in ncsi_configure_channel()
1083 } else if (nd->state == ncsi_dev_state_config_svf) { in ncsi_configure_channel()
1086 nd->state = ncsi_dev_state_config_ev; in ncsi_configure_channel()
1087 schedule_work(&ndp->work); in ncsi_configure_channel()
1091 nd->state = ncsi_dev_state_config_svf; in ncsi_configure_channel()
1093 } else if (nd->state == ncsi_dev_state_config_ev) { in ncsi_configure_channel()
1094 if (list_empty(&ndp->vlan_vids)) { in ncsi_configure_channel()
1100 nd->state = ncsi_dev_state_config_sma; in ncsi_configure_channel()
1101 } else if (nd->state == ncsi_dev_state_config_sma) { in ncsi_configure_channel()
1102 /* Use first entry in unicast filter table. Note that in ncsi_configure_channel()
1108 nca.bytes[index] = dev->dev_addr[index]; in ncsi_configure_channel()
1111 nd->state = ncsi_dev_state_config_ebf; in ncsi_configure_channel()
1112 } else if (nd->state == ncsi_dev_state_config_ebf) { in ncsi_configure_channel()
1114 nca.dwords[0] = nc->caps[NCSI_CAP_BC].cap; in ncsi_configure_channel()
1119 if (nc->caps[NCSI_CAP_GENERIC].cap & in ncsi_configure_channel()
1121 nd->state = ncsi_dev_state_config_dgmf; in ncsi_configure_channel()
1123 nd->state = ncsi_dev_state_config_ecnt; in ncsi_configure_channel()
1125 nd->state = ncsi_dev_state_config_ec; in ncsi_configure_channel()
1126 } else if (nd->state == ncsi_dev_state_config_dgmf) { in ncsi_configure_channel()
1129 nd->state = ncsi_dev_state_config_ecnt; in ncsi_configure_channel()
1131 nd->state = ncsi_dev_state_config_ec; in ncsi_configure_channel()
1132 } else if (nd->state == ncsi_dev_state_config_ecnt) { in ncsi_configure_channel()
1133 if (np->preferred_channel && in ncsi_configure_channel()
1134 nc != np->preferred_channel) in ncsi_configure_channel()
1135 netdev_info(ndp->ndev.dev, in ncsi_configure_channel()
1136 "NCSI: Tx failed over to channel %u\n", in ncsi_configure_channel()
1137 nc->id); in ncsi_configure_channel()
1139 nd->state = ncsi_dev_state_config_ec; in ncsi_configure_channel()
1140 } else if (nd->state == ncsi_dev_state_config_ec) { in ncsi_configure_channel()
1143 nd->state = ncsi_dev_state_config_ae; in ncsi_configure_channel()
1144 if (!(nc->caps[NCSI_CAP_AEN].cap & NCSI_CAP_AEN_MASK)) in ncsi_configure_channel()
1145 nd->state = ncsi_dev_state_config_gls; in ncsi_configure_channel()
1146 } else if (nd->state == ncsi_dev_state_config_ae) { in ncsi_configure_channel()
1149 nca.dwords[1] = nc->caps[NCSI_CAP_AEN].cap; in ncsi_configure_channel()
1150 nd->state = ncsi_dev_state_config_gls; in ncsi_configure_channel()
1151 } else if (nd->state == ncsi_dev_state_config_gls) { in ncsi_configure_channel()
1153 nd->state = ncsi_dev_state_config_done; in ncsi_configure_channel()
1158 netdev_err(ndp->ndev.dev, in ncsi_configure_channel()
1159 "NCSI: Failed to transmit CMD %x\n", in ncsi_configure_channel()
1165 netdev_dbg(ndp->ndev.dev, "NCSI: channel %u config done\n", in ncsi_configure_channel()
1166 nc->id); in ncsi_configure_channel()
1167 spin_lock_irqsave(&nc->lock, flags); in ncsi_configure_channel()
1168 nc->state = NCSI_CHANNEL_ACTIVE; in ncsi_configure_channel()
1170 if (ndp->flags & NCSI_DEV_RESET) { in ncsi_configure_channel()
1172 nc->reconfigure_needed = false; in ncsi_configure_channel()
1173 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_configure_channel()
1178 if (nc->reconfigure_needed) { in ncsi_configure_channel()
1180 * part-way during the config state - start the in ncsi_configure_channel()
1183 nc->reconfigure_needed = false; in ncsi_configure_channel()
1184 nc->state = NCSI_CHANNEL_INACTIVE; in ncsi_configure_channel()
1185 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_configure_channel()
1187 spin_lock_irqsave(&ndp->lock, flags); in ncsi_configure_channel()
1188 list_add_tail_rcu(&nc->link, &ndp->channel_queue); in ncsi_configure_channel()
1189 spin_unlock_irqrestore(&ndp->lock, flags); in ncsi_configure_channel()
1191 netdev_dbg(dev, "Dirty NCSI channel state reset\n"); in ncsi_configure_channel()
1196 if (nc->modes[NCSI_MODE_LINK].data[2] & 0x1) { in ncsi_configure_channel()
1200 netdev_dbg(ndp->ndev.dev, in ncsi_configure_channel()
1201 "NCSI: channel %u link down after config\n", in ncsi_configure_channel()
1202 nc->id); in ncsi_configure_channel()
1204 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_configure_channel()
1207 spin_lock_irqsave(&ndp->lock, flags); in ncsi_configure_channel()
1208 ndp->hot_channel = hot_nc; in ncsi_configure_channel()
1209 spin_unlock_irqrestore(&ndp->lock, flags); in ncsi_configure_channel()
1215 netdev_alert(dev, "Wrong NCSI state 0x%x in config\n", in ncsi_configure_channel()
1216 nd->state); in ncsi_configure_channel()
1233 spin_lock_irqsave(&ndp->lock, flags); in ncsi_choose_active_channel()
1234 hot_nc = ndp->hot_channel; in ncsi_choose_active_channel()
1235 spin_unlock_irqrestore(&ndp->lock, flags); in ncsi_choose_active_channel()
1245 if (!(ndp->package_whitelist & (0x1 << np->id))) in ncsi_choose_active_channel()
1248 if (!(np->channel_whitelist & (0x1 << nc->id))) in ncsi_choose_active_channel()
1251 spin_lock_irqsave(&nc->lock, cflags); in ncsi_choose_active_channel()
1253 if (!list_empty(&nc->link) || in ncsi_choose_active_channel()
1254 nc->state != NCSI_CHANNEL_INACTIVE) { in ncsi_choose_active_channel()
1255 spin_unlock_irqrestore(&nc->lock, cflags); in ncsi_choose_active_channel()
1265 ncm = &nc->modes[NCSI_MODE_LINK]; in ncsi_choose_active_channel()
1266 if (ncm->data[2] & 0x1) { in ncsi_choose_active_channel()
1275 if (with_link || np->multi_channel) { in ncsi_choose_active_channel()
1276 spin_lock_irqsave(&ndp->lock, flags); in ncsi_choose_active_channel()
1277 list_add_tail_rcu(&nc->link, in ncsi_choose_active_channel()
1278 &ndp->channel_queue); in ncsi_choose_active_channel()
1279 spin_unlock_irqrestore(&ndp->lock, flags); in ncsi_choose_active_channel()
1281 netdev_dbg(ndp->ndev.dev, in ncsi_choose_active_channel()
1282 "NCSI: Channel %u added to queue (link %s)\n", in ncsi_choose_active_channel()
1283 nc->id, in ncsi_choose_active_channel()
1284 ncm->data[2] & 0x1 ? "up" : "down"); in ncsi_choose_active_channel()
1287 spin_unlock_irqrestore(&nc->lock, cflags); in ncsi_choose_active_channel()
1289 if (with_link && !np->multi_channel) in ncsi_choose_active_channel()
1292 if (with_link && !ndp->multi_package) in ncsi_choose_active_channel()
1296 if (list_empty(&ndp->channel_queue) && found) { in ncsi_choose_active_channel()
1297 netdev_info(ndp->ndev.dev, in ncsi_choose_active_channel()
1298 "NCSI: No channel with link found, configuring channel %u\n", in ncsi_choose_active_channel()
1299 found->id); in ncsi_choose_active_channel()
1300 spin_lock_irqsave(&ndp->lock, flags); in ncsi_choose_active_channel()
1301 list_add_tail_rcu(&found->link, &ndp->channel_queue); in ncsi_choose_active_channel()
1302 spin_unlock_irqrestore(&ndp->lock, flags); in ncsi_choose_active_channel()
1304 netdev_warn(ndp->ndev.dev, in ncsi_choose_active_channel()
1305 "NCSI: No channel found to configure!\n"); in ncsi_choose_active_channel()
1307 return -ENODEV; in ncsi_choose_active_channel()
1327 cap = nc->caps[NCSI_CAP_GENERIC].cap; in ncsi_check_hwa()
1331 ndp->flags &= ~NCSI_DEV_HWA; in ncsi_check_hwa()
1338 ndp->flags |= NCSI_DEV_HWA; in ncsi_check_hwa()
1342 ndp->flags &= ~NCSI_DEV_HWA; in ncsi_check_hwa()
1348 struct ncsi_dev *nd = &ndp->ndev; in ncsi_probe_channel()
1356 switch (nd->state) { in ncsi_probe_channel()
1358 nd->state = ncsi_dev_state_probe_deselect; in ncsi_probe_channel()
1361 ndp->pending_req_num = 8; in ncsi_probe_channel()
1373 nd->state = ncsi_dev_state_probe_package; in ncsi_probe_channel()
1376 ndp->pending_req_num = 1; in ncsi_probe_channel()
1380 nca.package = ndp->package_probe_id; in ncsi_probe_channel()
1385 nd->state = ncsi_dev_state_probe_channel; in ncsi_probe_channel()
1388 ndp->active_package = ncsi_find_package(ndp, in ncsi_probe_channel()
1389 ndp->package_probe_id); in ncsi_probe_channel()
1390 if (!ndp->active_package) { in ncsi_probe_channel()
1392 nd->state = ncsi_dev_state_probe_dp; in ncsi_probe_channel()
1393 schedule_work(&ndp->work); in ncsi_probe_channel()
1396 nd->state = ncsi_dev_state_probe_cis; in ncsi_probe_channel()
1398 ndp->mlx_multi_host) in ncsi_probe_channel()
1399 nd->state = ncsi_dev_state_probe_mlx_gma; in ncsi_probe_channel()
1401 schedule_work(&ndp->work); in ncsi_probe_channel()
1404 ndp->pending_req_num = 1; in ncsi_probe_channel()
1407 nca.package = ndp->active_package->id; in ncsi_probe_channel()
1413 nd->state = ncsi_dev_state_probe_mlx_smaf; in ncsi_probe_channel()
1416 ndp->pending_req_num = 1; in ncsi_probe_channel()
1419 nca.package = ndp->active_package->id; in ncsi_probe_channel()
1425 nd->state = ncsi_dev_state_probe_cis; in ncsi_probe_channel()
1428 ndp->pending_req_num = 1; in ncsi_probe_channel()
1431 nca.package = ndp->active_package->id; in ncsi_probe_channel()
1437 nd->state = ncsi_dev_state_probe_gvi; in ncsi_probe_channel()
1443 np = ndp->active_package; in ncsi_probe_channel()
1444 ndp->pending_req_num = 1; in ncsi_probe_channel()
1447 if (nd->state == ncsi_dev_state_probe_cis) in ncsi_probe_channel()
1449 else if (nd->state == ncsi_dev_state_probe_gvi) in ncsi_probe_channel()
1451 else if (nd->state == ncsi_dev_state_probe_gc) in ncsi_probe_channel()
1456 nca.package = np->id; in ncsi_probe_channel()
1457 nca.channel = ndp->channel_probe_id; in ncsi_probe_channel()
1463 if (nd->state == ncsi_dev_state_probe_cis) { in ncsi_probe_channel()
1464 nd->state = ncsi_dev_state_probe_gvi; in ncsi_probe_channel()
1465 if (IS_ENABLED(CONFIG_NCSI_OEM_CMD_KEEP_PHY) && ndp->channel_probe_id == 0) in ncsi_probe_channel()
1466 nd->state = ncsi_dev_state_probe_keep_phy; in ncsi_probe_channel()
1467 } else if (nd->state == ncsi_dev_state_probe_gvi) { in ncsi_probe_channel()
1468 nd->state = ncsi_dev_state_probe_gc; in ncsi_probe_channel()
1469 } else if (nd->state == ncsi_dev_state_probe_gc) { in ncsi_probe_channel()
1470 nd->state = ncsi_dev_state_probe_gls; in ncsi_probe_channel()
1472 nd->state = ncsi_dev_state_probe_cis; in ncsi_probe_channel()
1473 ndp->channel_probe_id++; in ncsi_probe_channel()
1476 if (ndp->channel_probe_id == ndp->channel_count) { in ncsi_probe_channel()
1477 ndp->channel_probe_id = 0; in ncsi_probe_channel()
1478 nd->state = ncsi_dev_state_probe_dp; in ncsi_probe_channel()
1482 ndp->pending_req_num = 1; in ncsi_probe_channel()
1486 nca.package = ndp->package_probe_id; in ncsi_probe_channel()
1493 ndp->package_probe_id++; in ncsi_probe_channel()
1494 if (ndp->package_probe_id >= 8) { in ncsi_probe_channel()
1496 ndp->flags |= NCSI_DEV_PROBED; in ncsi_probe_channel()
1499 nd->state = ncsi_dev_state_probe_package; in ncsi_probe_channel()
1500 ndp->active_package = NULL; in ncsi_probe_channel()
1503 netdev_warn(nd->dev, "Wrong NCSI state 0x%0x in enumeration\n", in ncsi_probe_channel()
1504 nd->state); in ncsi_probe_channel()
1507 if (ndp->flags & NCSI_DEV_PROBED) { in ncsi_probe_channel()
1515 netdev_err(ndp->ndev.dev, in ncsi_probe_channel()
1516 "NCSI: Failed to transmit cmd 0x%x during probe\n", in ncsi_probe_channel()
1525 struct ncsi_dev *nd = &ndp->ndev; in ncsi_dev_work()
1527 switch (nd->state & ncsi_dev_state_major) { in ncsi_dev_work()
1538 netdev_warn(nd->dev, "Wrong NCSI state 0x%x in workqueue\n", in ncsi_dev_work()
1539 nd->state); in ncsi_dev_work()
1549 spin_lock_irqsave(&ndp->lock, flags); in ncsi_process_next_channel()
1550 nc = list_first_or_null_rcu(&ndp->channel_queue, in ncsi_process_next_channel()
1553 spin_unlock_irqrestore(&ndp->lock, flags); in ncsi_process_next_channel()
1557 list_del_init(&nc->link); in ncsi_process_next_channel()
1558 spin_unlock_irqrestore(&ndp->lock, flags); in ncsi_process_next_channel()
1560 spin_lock_irqsave(&nc->lock, flags); in ncsi_process_next_channel()
1561 old_state = nc->state; in ncsi_process_next_channel()
1562 nc->state = NCSI_CHANNEL_INVISIBLE; in ncsi_process_next_channel()
1563 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_process_next_channel()
1565 ndp->active_channel = nc; in ncsi_process_next_channel()
1566 ndp->active_package = nc->package; in ncsi_process_next_channel()
1570 ndp->ndev.state = ncsi_dev_state_config; in ncsi_process_next_channel()
1571 netdev_dbg(ndp->ndev.dev, "NCSI: configuring channel %u\n", in ncsi_process_next_channel()
1572 nc->id); in ncsi_process_next_channel()
1576 ndp->ndev.state = ncsi_dev_state_suspend; in ncsi_process_next_channel()
1577 netdev_dbg(ndp->ndev.dev, "NCSI: suspending channel %u\n", in ncsi_process_next_channel()
1578 nc->id); in ncsi_process_next_channel()
1582 netdev_err(ndp->ndev.dev, "Invalid state 0x%x on %d:%d\n", in ncsi_process_next_channel()
1583 old_state, nc->package->id, nc->id); in ncsi_process_next_channel()
1585 return -EINVAL; in ncsi_process_next_channel()
1591 ndp->active_channel = NULL; in ncsi_process_next_channel()
1592 ndp->active_package = NULL; in ncsi_process_next_channel()
1593 if (ndp->flags & NCSI_DEV_RESHUFFLE) { in ncsi_process_next_channel()
1594 ndp->flags &= ~NCSI_DEV_RESHUFFLE; in ncsi_process_next_channel()
1599 return -ENODEV; in ncsi_process_next_channel()
1604 struct ncsi_dev *nd = &ndp->ndev; in ncsi_kick_channels()
1612 spin_lock_irqsave(&nc->lock, flags); in ncsi_kick_channels()
1620 if (nc->state != NCSI_CHANNEL_ACTIVE) { in ncsi_kick_channels()
1621 if ((ndp->ndev.state & 0xff00) == in ncsi_kick_channels()
1623 !list_empty(&nc->link)) { in ncsi_kick_channels()
1624 netdev_dbg(nd->dev, in ncsi_kick_channels()
1625 "NCSI: channel %p marked dirty\n", in ncsi_kick_channels()
1627 nc->reconfigure_needed = true; in ncsi_kick_channels()
1629 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_kick_channels()
1633 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_kick_channels()
1636 spin_lock_irqsave(&nc->lock, flags); in ncsi_kick_channels()
1637 nc->state = NCSI_CHANNEL_INACTIVE; in ncsi_kick_channels()
1638 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_kick_channels()
1640 spin_lock_irqsave(&ndp->lock, flags); in ncsi_kick_channels()
1641 list_add_tail_rcu(&nc->link, &ndp->channel_queue); in ncsi_kick_channels()
1642 spin_unlock_irqrestore(&ndp->lock, flags); in ncsi_kick_channels()
1644 netdev_dbg(nd->dev, "NCSI: kicked channel %p\n", nc); in ncsi_kick_channels()
1665 netdev_warn(dev, "NCSI: No net_device?\n"); in ncsi_vlan_rx_add_vid()
1672 list_for_each_entry_rcu(vlan, &ndp->vlan_vids, list) { in ncsi_vlan_rx_add_vid()
1674 if (vlan->vid == vid) { in ncsi_vlan_rx_add_vid()
1675 netdev_dbg(dev, "NCSI: vid %u already registered\n", in ncsi_vlan_rx_add_vid()
1682 "tried to add vlan id %u but NCSI max already registered (%u)\n", in ncsi_vlan_rx_add_vid()
1684 return -ENOSPC; in ncsi_vlan_rx_add_vid()
1689 return -ENOMEM; in ncsi_vlan_rx_add_vid()
1691 vlan->proto = proto; in ncsi_vlan_rx_add_vid()
1692 vlan->vid = vid; in ncsi_vlan_rx_add_vid()
1693 list_add_rcu(&vlan->list, &ndp->vlan_vids); in ncsi_vlan_rx_add_vid()
1695 netdev_dbg(dev, "NCSI: Added new vid %u\n", vid); in ncsi_vlan_rx_add_vid()
1715 netdev_warn(dev, "NCSI: no net_device?\n"); in ncsi_vlan_rx_kill_vid()
1722 list_for_each_entry_safe(vlan, tmp, &ndp->vlan_vids, list) in ncsi_vlan_rx_kill_vid()
1723 if (vlan->vid == vid) { in ncsi_vlan_rx_kill_vid()
1724 netdev_dbg(dev, "NCSI: vid %u found, removing\n", vid); in ncsi_vlan_rx_kill_vid()
1725 list_del_rcu(&vlan->list); in ncsi_vlan_rx_kill_vid()
1731 netdev_err(dev, "NCSI: vid %u wasn't registered!\n", vid); in ncsi_vlan_rx_kill_vid()
1732 return -EINVAL; in ncsi_vlan_rx_kill_vid()
1756 /* Create NCSI device */ in ncsi_register_dev()
1761 nd = &ndp->ndev; in ncsi_register_dev()
1762 nd->state = ncsi_dev_state_registered; in ncsi_register_dev()
1763 nd->dev = dev; in ncsi_register_dev()
1764 nd->handler = handler; in ncsi_register_dev()
1765 ndp->pending_req_num = 0; in ncsi_register_dev()
1766 INIT_LIST_HEAD(&ndp->channel_queue); in ncsi_register_dev()
1767 INIT_LIST_HEAD(&ndp->vlan_vids); in ncsi_register_dev()
1768 INIT_WORK(&ndp->work, ncsi_dev_work); in ncsi_register_dev()
1769 ndp->package_whitelist = UINT_MAX; in ncsi_register_dev()
1771 /* Initialize private NCSI device */ in ncsi_register_dev()
1772 spin_lock_init(&ndp->lock); in ncsi_register_dev()
1773 INIT_LIST_HEAD(&ndp->packages); in ncsi_register_dev()
1774 ndp->request_id = NCSI_REQ_START_IDX; in ncsi_register_dev()
1775 for (i = 0; i < ARRAY_SIZE(ndp->requests); i++) { in ncsi_register_dev()
1776 ndp->requests[i].id = i; in ncsi_register_dev()
1777 ndp->requests[i].ndp = ndp; in ncsi_register_dev()
1778 timer_setup(&ndp->requests[i].timer, ncsi_request_timeout, 0); in ncsi_register_dev()
1780 ndp->channel_count = NCSI_RESERVED_CHANNEL; in ncsi_register_dev()
1783 list_add_tail_rcu(&ndp->node, &ncsi_dev_list); in ncsi_register_dev()
1786 /* Register NCSI packet Rx handler */ in ncsi_register_dev()
1787 ndp->ptype.type = cpu_to_be16(ETH_P_NCSI); in ncsi_register_dev()
1788 ndp->ptype.func = ncsi_rcv_rsp; in ncsi_register_dev()
1789 ndp->ptype.dev = dev; in ncsi_register_dev()
1790 dev_add_pack(&ndp->ptype); in ncsi_register_dev()
1792 pdev = to_platform_device(dev->dev.parent); in ncsi_register_dev()
1794 np = pdev->dev.of_node; in ncsi_register_dev()
1795 if (np && (of_property_read_bool(np, "mellanox,multi-host") || in ncsi_register_dev()
1796 of_property_read_bool(np, "mlx,multi-host"))) in ncsi_register_dev()
1797 ndp->mlx_multi_host = true; in ncsi_register_dev()
1808 if (nd->state != ncsi_dev_state_registered && in ncsi_start_dev()
1809 nd->state != ncsi_dev_state_functional) in ncsi_start_dev()
1810 return -ENOTTY; in ncsi_start_dev()
1812 if (!(ndp->flags & NCSI_DEV_PROBED)) { in ncsi_start_dev()
1813 ndp->package_probe_id = 0; in ncsi_start_dev()
1814 ndp->channel_probe_id = 0; in ncsi_start_dev()
1815 nd->state = ncsi_dev_state_probe; in ncsi_start_dev()
1816 schedule_work(&ndp->work); in ncsi_start_dev()
1841 spin_lock_irqsave(&nc->lock, flags); in ncsi_stop_dev()
1842 chained = !list_empty(&nc->link); in ncsi_stop_dev()
1843 old_state = nc->state; in ncsi_stop_dev()
1844 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_stop_dev()
1851 netdev_dbg(ndp->ndev.dev, "NCSI: Stopping device\n"); in ncsi_stop_dev()
1863 spin_lock_irqsave(&ndp->lock, flags); in ncsi_reset_dev()
1865 if (!(ndp->flags & NCSI_DEV_RESET)) { in ncsi_reset_dev()
1867 switch (nd->state & ncsi_dev_state_major) { in ncsi_reset_dev()
1870 /* Not even probed yet - do nothing */ in ncsi_reset_dev()
1871 spin_unlock_irqrestore(&ndp->lock, flags); in ncsi_reset_dev()
1879 ndp->flags |= NCSI_DEV_RESET; in ncsi_reset_dev()
1880 spin_unlock_irqrestore(&ndp->lock, flags); in ncsi_reset_dev()
1884 switch (nd->state) { in ncsi_reset_dev()
1892 spin_unlock_irqrestore(&ndp->lock, flags); in ncsi_reset_dev()
1897 if (!list_empty(&ndp->channel_queue)) { in ncsi_reset_dev()
1899 list_for_each_entry_safe(nc, tmp, &ndp->channel_queue, link) in ncsi_reset_dev()
1900 list_del_init(&nc->link); in ncsi_reset_dev()
1902 spin_unlock_irqrestore(&ndp->lock, flags); in ncsi_reset_dev()
1907 spin_lock_irqsave(&nc->lock, flags); in ncsi_reset_dev()
1909 if (nc->state == NCSI_CHANNEL_ACTIVE) { in ncsi_reset_dev()
1911 nc->state = NCSI_CHANNEL_INVISIBLE; in ncsi_reset_dev()
1912 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_reset_dev()
1917 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_reset_dev()
1925 spin_lock_irqsave(&ndp->lock, flags); in ncsi_reset_dev()
1926 ndp->flags &= ~NCSI_DEV_RESET; in ncsi_reset_dev()
1927 spin_unlock_irqrestore(&ndp->lock, flags); in ncsi_reset_dev()
1931 spin_lock_irqsave(&ndp->lock, flags); in ncsi_reset_dev()
1932 ndp->flags |= NCSI_DEV_RESET; in ncsi_reset_dev()
1933 ndp->active_channel = active; in ncsi_reset_dev()
1934 ndp->active_package = active->package; in ncsi_reset_dev()
1935 spin_unlock_irqrestore(&ndp->lock, flags); in ncsi_reset_dev()
1937 nd->state = ncsi_dev_state_suspend; in ncsi_reset_dev()
1938 schedule_work(&ndp->work); in ncsi_reset_dev()
1948 dev_remove_pack(&ndp->ptype); in ncsi_unregister_dev()
1950 list_for_each_entry_safe(np, tmp, &ndp->packages, node) in ncsi_unregister_dev()
1954 list_del_rcu(&ndp->node); in ncsi_unregister_dev()
1957 disable_work_sync(&ndp->work); in ncsi_unregister_dev()