Lines Matching full:nc
37 struct ncsi_channel *nc; in ncsi_channel_is_last() local
40 NCSI_FOR_EACH_CHANNEL(np, nc) { in ncsi_channel_is_last()
41 if (nc == channel) in ncsi_channel_is_last()
43 if (nc->state == NCSI_CHANNEL_ACTIVE && in ncsi_channel_is_last()
44 ncsi_channel_has_link(nc)) in ncsi_channel_is_last()
55 struct ncsi_channel *nc; in ncsi_report_link() local
66 NCSI_FOR_EACH_CHANNEL(np, nc) { 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()
75 if (ncsi_channel_has_link(nc)) { in ncsi_report_link()
76 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_report_link()
81 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_report_link()
91 struct ncsi_channel *nc = from_timer(nc, t, monitor.timer); in ncsi_channel_monitor() local
92 struct ncsi_package *np = nc->package; 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()
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()
130 nca.channel = nc->id; in ncsi_channel_monitor()
142 nc->id); 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()
151 spin_unlock_irqrestore(&nc->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()
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()
167 void ncsi_start_channel_monitor(struct ncsi_channel *nc) in ncsi_start_channel_monitor() argument
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()
180 void ncsi_stop_channel_monitor(struct ncsi_channel *nc) in ncsi_stop_channel_monitor() argument
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()
198 struct ncsi_channel *nc; in ncsi_find_channel() local
200 NCSI_FOR_EACH_CHANNEL(np, nc) { in ncsi_find_channel()
201 if (nc->id == id) in ncsi_find_channel()
202 return nc; in ncsi_find_channel()
210 struct ncsi_channel *nc, *tmp; in ncsi_add_channel() local
214 nc = kzalloc(sizeof(*nc), GFP_ATOMIC); in ncsi_add_channel()
215 if (!nc) in ncsi_add_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()
234 kfree(nc); in ncsi_add_channel()
238 list_add_tail_rcu(&nc->node, &np->channels); in ncsi_add_channel()
242 return nc; in ncsi_add_channel()
245 static void ncsi_remove_channel(struct ncsi_channel *nc) in ncsi_remove_channel() argument
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()
258 ncsi_stop_channel_monitor(nc); in ncsi_remove_channel()
262 list_del_rcu(&nc->node); in ncsi_remove_channel()
266 kfree(nc); in ncsi_remove_channel()
316 struct ncsi_channel *nc, *tmp; in ncsi_remove_package() local
320 list_for_each_entry_safe(nc, tmp, &np->channels, node) in ncsi_remove_package()
321 ncsi_remove_channel(nc); in ncsi_remove_package()
335 struct ncsi_channel **nc) in ncsi_find_package_and_channel() argument
345 if (nc) in ncsi_find_package_and_channel()
346 *nc = c; in ncsi_find_package_and_channel()
437 struct ncsi_channel *nc; in ncsi_request_timeout() local
458 &np, &nc); in ncsi_request_timeout()
459 ncsi_send_netlink_timeout(nr, np, nc); in ncsi_request_timeout()
471 struct ncsi_channel *nc, *tmp; in ncsi_suspend_channel() local
477 nc = ndp->active_channel; in ncsi_suspend_channel()
534 nca.channel = nc->id; in ncsi_suspend_channel()
547 nca.channel = nc->id; in ncsi_suspend_channel()
559 if (tmp != nc && tmp->state == NCSI_CHANNEL_ACTIVE) { 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()
600 static int clear_one_vid(struct ncsi_dev_priv *ndp, struct ncsi_channel *nc, in clear_one_vid() argument
609 ncf = &nc->vlan_filter; in clear_one_vid()
612 spin_lock_irqsave(&nc->lock, flags); in clear_one_vid()
615 spin_unlock_irqrestore(&nc->lock, flags); in clear_one_vid()
622 spin_unlock_irqrestore(&nc->lock, flags); in clear_one_vid()
635 static int set_one_vid(struct ncsi_dev_priv *ndp, struct ncsi_channel *nc, in set_one_vid() argument
648 ncf = &nc->vlan_filter; in set_one_vid()
651 spin_lock_irqsave(&nc->lock, flags); in set_one_vid()
668 spin_unlock_irqrestore(&nc->lock, flags); in set_one_vid()
676 nc->id); in set_one_vid()
677 spin_unlock_irqrestore(&nc->lock, flags); in set_one_vid()
683 spin_unlock_irqrestore(&nc->lock, flags); in set_one_vid()
857 struct ncsi_channel *nc) in ncsi_channel_is_tx() argument
867 if (!ndp->multi_package && np != nc->package) in ncsi_channel_is_tx()
881 return np->preferred_channel == nc; in ncsi_channel_is_tx()
886 if (ncsi_channel_has_link(nc)) in ncsi_channel_is_tx()
904 struct ncsi_channel *nc; in ncsi_update_tx_channel() local
921 NCSI_FOR_EACH_CHANNEL(np, nc) in ncsi_update_tx_channel()
922 if (nc->modes[NCSI_MODE_TX_ENABLE].enable) { in ncsi_update_tx_channel()
923 disable = nc; in ncsi_update_tx_channel()
943 NCSI_FOR_EACH_CHANNEL(np, nc) { 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()
948 if (ncsi_channel_has_link(nc)) { in ncsi_update_tx_channel()
949 enable = nc; in ncsi_update_tx_channel()
989 struct ncsi_channel *nc = ndp->active_channel; in ncsi_configure_channel() local
1028 nca.channel = nc->id; in ncsi_configure_channel()
1044 nca.channel = nc->id; 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()
1082 nca.channel = nc->id; in ncsi_configure_channel()
1086 ret = clear_one_vid(ndp, nc, &nca); in ncsi_configure_channel()
1096 ret = set_one_vid(ndp, nc, &nca); in ncsi_configure_channel()
1126 nca.dwords[0] = nc->caps[NCSI_CAP_BC].cap; in ncsi_configure_channel()
1131 if (nc->caps[NCSI_CAP_GENERIC].cap & in ncsi_configure_channel()
1134 else if (ncsi_channel_is_tx(ndp, nc)) in ncsi_configure_channel()
1140 if (ncsi_channel_is_tx(ndp, nc)) in ncsi_configure_channel()
1146 nc != np->preferred_channel) in ncsi_configure_channel()
1149 nc->id); in ncsi_configure_channel()
1156 if (!(nc->caps[NCSI_CAP_AEN].cap & NCSI_CAP_AEN_MASK)) in ncsi_configure_channel()
1161 nca.dwords[1] = nc->caps[NCSI_CAP_AEN].cap; in ncsi_configure_channel()
1178 nc->id); in ncsi_configure_channel()
1179 spin_lock_irqsave(&nc->lock, flags); in ncsi_configure_channel()
1180 nc->state = NCSI_CHANNEL_ACTIVE; in ncsi_configure_channel()
1184 nc->reconfigure_needed = false; in ncsi_configure_channel()
1185 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_configure_channel()
1190 if (nc->reconfigure_needed) { in ncsi_configure_channel()
1195 nc->reconfigure_needed = false; in ncsi_configure_channel()
1196 nc->state = NCSI_CHANNEL_INACTIVE; in ncsi_configure_channel()
1197 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_configure_channel()
1200 list_add_tail_rcu(&nc->link, &ndp->channel_queue); in ncsi_configure_channel()
1208 if (nc->modes[NCSI_MODE_LINK].data[2] & 0x1) { in ncsi_configure_channel()
1209 hot_nc = nc; in ncsi_configure_channel()
1214 nc->id); in ncsi_configure_channel()
1216 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_configure_channel()
1223 ncsi_start_channel_monitor(nc); in ncsi_configure_channel()
1239 struct ncsi_channel *nc, *found, *hot_nc; in ncsi_choose_active_channel() local
1259 NCSI_FOR_EACH_CHANNEL(np, nc) { in ncsi_choose_active_channel()
1260 if (!(np->channel_whitelist & (0x1 << nc->id))) in ncsi_choose_active_channel()
1263 spin_lock_irqsave(&nc->lock, cflags); in ncsi_choose_active_channel()
1265 if (!list_empty(&nc->link) || in ncsi_choose_active_channel()
1266 nc->state != NCSI_CHANNEL_INACTIVE) { in ncsi_choose_active_channel()
1267 spin_unlock_irqrestore(&nc->lock, cflags); in ncsi_choose_active_channel()
1272 found = nc; in ncsi_choose_active_channel()
1274 if (nc == hot_nc) in ncsi_choose_active_channel()
1275 found = nc; in ncsi_choose_active_channel()
1277 ncm = &nc->modes[NCSI_MODE_LINK]; in ncsi_choose_active_channel()
1279 found = nc; in ncsi_choose_active_channel()
1289 list_add_tail_rcu(&nc->link, in ncsi_choose_active_channel()
1295 nc->id, in ncsi_choose_active_channel()
1299 spin_unlock_irqrestore(&nc->lock, cflags); in ncsi_choose_active_channel()
1328 struct ncsi_channel *nc; in ncsi_check_hwa() local
1336 NCSI_FOR_EACH_CHANNEL(np, nc) { in ncsi_check_hwa()
1339 cap = nc->caps[NCSI_CAP_GENERIC].cap; in ncsi_check_hwa()
1558 struct ncsi_channel *nc; in ncsi_process_next_channel() local
1563 nc = list_first_or_null_rcu(&ndp->channel_queue, in ncsi_process_next_channel()
1565 if (!nc) { in ncsi_process_next_channel()
1570 list_del_init(&nc->link); in ncsi_process_next_channel()
1573 spin_lock_irqsave(&nc->lock, flags); in ncsi_process_next_channel()
1574 old_state = nc->state; in ncsi_process_next_channel()
1575 nc->state = NCSI_CHANNEL_INVISIBLE; in ncsi_process_next_channel()
1576 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_process_next_channel()
1578 ndp->active_channel = nc; in ncsi_process_next_channel()
1579 ndp->active_package = nc->package; in ncsi_process_next_channel()
1585 nc->id); in ncsi_process_next_channel()
1591 nc->id); in ncsi_process_next_channel()
1596 old_state, nc->package->id, nc->id); in ncsi_process_next_channel()
1618 struct ncsi_channel *nc; in ncsi_kick_channels() local
1624 NCSI_FOR_EACH_CHANNEL(np, nc) { in ncsi_kick_channels()
1625 spin_lock_irqsave(&nc->lock, flags); in ncsi_kick_channels()
1633 if (nc->state != NCSI_CHANNEL_ACTIVE) { in ncsi_kick_channels()
1636 !list_empty(&nc->link)) { in ncsi_kick_channels()
1639 nc); in ncsi_kick_channels()
1640 nc->reconfigure_needed = true; in ncsi_kick_channels()
1642 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_kick_channels()
1646 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_kick_channels()
1648 ncsi_stop_channel_monitor(nc); in ncsi_kick_channels()
1649 spin_lock_irqsave(&nc->lock, flags); in ncsi_kick_channels()
1650 nc->state = NCSI_CHANNEL_INACTIVE; in ncsi_kick_channels()
1651 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_kick_channels()
1654 list_add_tail_rcu(&nc->link, &ndp->channel_queue); in ncsi_kick_channels()
1657 netdev_dbg(nd->dev, "NCSI: kicked channel %p\n", nc); in ncsi_kick_channels()
1841 struct ncsi_channel *nc; in ncsi_stop_dev() local
1851 NCSI_FOR_EACH_CHANNEL(np, nc) { in ncsi_stop_dev()
1852 ncsi_stop_channel_monitor(nc); in ncsi_stop_dev()
1854 spin_lock_irqsave(&nc->lock, flags); in ncsi_stop_dev()
1855 chained = !list_empty(&nc->link); in ncsi_stop_dev()
1856 old_state = nc->state; in ncsi_stop_dev()
1857 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_stop_dev()
1872 struct ncsi_channel *nc, *active, *tmp; in ncsi_reset_dev() local
1912 list_for_each_entry_safe(nc, tmp, &ndp->channel_queue, link) in ncsi_reset_dev()
1913 list_del_init(&nc->link); in ncsi_reset_dev()
1919 NCSI_FOR_EACH_CHANNEL(np, nc) { in ncsi_reset_dev()
1920 spin_lock_irqsave(&nc->lock, flags); in ncsi_reset_dev()
1922 if (nc->state == NCSI_CHANNEL_ACTIVE) { in ncsi_reset_dev()
1923 active = nc; in ncsi_reset_dev()
1924 nc->state = NCSI_CHANNEL_INVISIBLE; in ncsi_reset_dev()
1925 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_reset_dev()
1926 ncsi_stop_channel_monitor(nc); in ncsi_reset_dev()
1930 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_reset_dev()