Lines Matching refs: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()
519 NCSI_FOR_EACH_CHANNEL(np, nc) { in ncsi_suspend_channel()
520 nca.channel = nc->id; in ncsi_suspend_channel()
532 nca.channel = nc->id; in ncsi_suspend_channel()
545 nca.channel = nc->id; in ncsi_suspend_channel()
557 if (tmp != nc && tmp->state == NCSI_CHANNEL_ACTIVE) { in ncsi_suspend_channel()
577 spin_lock_irqsave(&nc->lock, flags); in ncsi_suspend_channel()
578 nc->state = NCSI_CHANNEL_INACTIVE; in ncsi_suspend_channel()
579 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_suspend_channel()
598 static int clear_one_vid(struct ncsi_dev_priv *ndp, struct ncsi_channel *nc, in clear_one_vid() argument
607 ncf = &nc->vlan_filter; in clear_one_vid()
610 spin_lock_irqsave(&nc->lock, flags); in clear_one_vid()
613 spin_unlock_irqrestore(&nc->lock, flags); in clear_one_vid()
620 spin_unlock_irqrestore(&nc->lock, flags); in clear_one_vid()
633 static int set_one_vid(struct ncsi_dev_priv *ndp, struct ncsi_channel *nc, in set_one_vid() argument
646 ncf = &nc->vlan_filter; in set_one_vid()
649 spin_lock_irqsave(&nc->lock, flags); in set_one_vid()
666 spin_unlock_irqrestore(&nc->lock, flags); in set_one_vid()
674 nc->id); in set_one_vid()
675 spin_unlock_irqrestore(&nc->lock, flags); in set_one_vid()
681 spin_unlock_irqrestore(&nc->lock, flags); in set_one_vid()
863 struct ncsi_channel *nc) in ncsi_channel_is_tx() argument
873 if (!ndp->multi_package && np != nc->package) in ncsi_channel_is_tx()
887 return np->preferred_channel == nc; in ncsi_channel_is_tx()
892 if (ncsi_channel_has_link(nc)) in ncsi_channel_is_tx()
910 struct ncsi_channel *nc; in ncsi_update_tx_channel() local
927 NCSI_FOR_EACH_CHANNEL(np, nc) in ncsi_update_tx_channel()
928 if (nc->modes[NCSI_MODE_TX_ENABLE].enable) { in ncsi_update_tx_channel()
929 disable = nc; in ncsi_update_tx_channel()
949 NCSI_FOR_EACH_CHANNEL(np, nc) { in ncsi_update_tx_channel()
950 if (!(np->channel_whitelist & 0x1 << nc->id)) in ncsi_update_tx_channel()
952 if (nc->state != NCSI_CHANNEL_ACTIVE) in ncsi_update_tx_channel()
954 if (ncsi_channel_has_link(nc)) { in ncsi_update_tx_channel()
955 enable = nc; in ncsi_update_tx_channel()
995 struct ncsi_channel *nc = ndp->active_channel; in ncsi_configure_channel() local
1034 nca.channel = nc->id; in ncsi_configure_channel()
1051 nca.channel = nc->id; in ncsi_configure_channel()
1053 ret = ncsi_gma_handler(&nca, nc->version.mf_id); in ncsi_configure_channel()
1073 nca.channel = nc->id; in ncsi_configure_channel()
1077 ret = clear_one_vid(ndp, nc, &nca); in ncsi_configure_channel()
1087 ret = set_one_vid(ndp, nc, &nca); in ncsi_configure_channel()
1117 nca.dwords[0] = nc->caps[NCSI_CAP_BC].cap; in ncsi_configure_channel()
1122 if (nc->caps[NCSI_CAP_GENERIC].cap & in ncsi_configure_channel()
1125 else if (ncsi_channel_is_tx(ndp, nc)) in ncsi_configure_channel()
1131 if (ncsi_channel_is_tx(ndp, nc)) in ncsi_configure_channel()
1137 nc != np->preferred_channel) in ncsi_configure_channel()
1140 nc->id); in ncsi_configure_channel()
1147 if (!(nc->caps[NCSI_CAP_AEN].cap & NCSI_CAP_AEN_MASK)) in ncsi_configure_channel()
1152 nca.dwords[1] = nc->caps[NCSI_CAP_AEN].cap; in ncsi_configure_channel()
1169 nc->id); in ncsi_configure_channel()
1170 spin_lock_irqsave(&nc->lock, flags); in ncsi_configure_channel()
1171 nc->state = NCSI_CHANNEL_ACTIVE; in ncsi_configure_channel()
1175 nc->reconfigure_needed = false; in ncsi_configure_channel()
1176 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_configure_channel()
1181 if (nc->reconfigure_needed) { in ncsi_configure_channel()
1186 nc->reconfigure_needed = false; in ncsi_configure_channel()
1187 nc->state = NCSI_CHANNEL_INACTIVE; in ncsi_configure_channel()
1188 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_configure_channel()
1191 list_add_tail_rcu(&nc->link, &ndp->channel_queue); in ncsi_configure_channel()
1199 if (nc->modes[NCSI_MODE_LINK].data[2] & 0x1) { in ncsi_configure_channel()
1200 hot_nc = nc; in ncsi_configure_channel()
1205 nc->id); in ncsi_configure_channel()
1207 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_configure_channel()
1214 ncsi_start_channel_monitor(nc); in ncsi_configure_channel()
1230 struct ncsi_channel *nc, *found, *hot_nc; in ncsi_choose_active_channel() local
1250 NCSI_FOR_EACH_CHANNEL(np, nc) { in ncsi_choose_active_channel()
1251 if (!(np->channel_whitelist & (0x1 << nc->id))) in ncsi_choose_active_channel()
1254 spin_lock_irqsave(&nc->lock, cflags); in ncsi_choose_active_channel()
1256 if (!list_empty(&nc->link) || in ncsi_choose_active_channel()
1257 nc->state != NCSI_CHANNEL_INACTIVE) { in ncsi_choose_active_channel()
1258 spin_unlock_irqrestore(&nc->lock, cflags); in ncsi_choose_active_channel()
1263 found = nc; in ncsi_choose_active_channel()
1265 if (nc == hot_nc) in ncsi_choose_active_channel()
1266 found = nc; in ncsi_choose_active_channel()
1268 ncm = &nc->modes[NCSI_MODE_LINK]; in ncsi_choose_active_channel()
1270 found = nc; in ncsi_choose_active_channel()
1280 list_add_tail_rcu(&nc->link, in ncsi_choose_active_channel()
1286 nc->id, in ncsi_choose_active_channel()
1290 spin_unlock_irqrestore(&nc->lock, cflags); in ncsi_choose_active_channel()
1319 struct ncsi_channel *nc; in ncsi_check_hwa() local
1327 NCSI_FOR_EACH_CHANNEL(np, nc) { in ncsi_check_hwa()
1330 cap = nc->caps[NCSI_CAP_GENERIC].cap; in ncsi_check_hwa()
1353 struct ncsi_channel *nc; in ncsi_probe_channel() local
1479 NCSI_FOR_EACH_CHANNEL(np, nc) { in ncsi_probe_channel()
1480 nca.channel = nc->id; in ncsi_probe_channel()
1557 struct ncsi_channel *nc; in ncsi_process_next_channel() local
1562 nc = list_first_or_null_rcu(&ndp->channel_queue, in ncsi_process_next_channel()
1564 if (!nc) { in ncsi_process_next_channel()
1569 list_del_init(&nc->link); in ncsi_process_next_channel()
1572 spin_lock_irqsave(&nc->lock, flags); in ncsi_process_next_channel()
1573 old_state = nc->state; in ncsi_process_next_channel()
1574 nc->state = NCSI_CHANNEL_INVISIBLE; in ncsi_process_next_channel()
1575 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_process_next_channel()
1577 ndp->active_channel = nc; in ncsi_process_next_channel()
1578 ndp->active_package = nc->package; in ncsi_process_next_channel()
1584 nc->id); in ncsi_process_next_channel()
1590 nc->id); in ncsi_process_next_channel()
1595 old_state, nc->package->id, nc->id); in ncsi_process_next_channel()
1617 struct ncsi_channel *nc; in ncsi_kick_channels() local
1623 NCSI_FOR_EACH_CHANNEL(np, nc) { in ncsi_kick_channels()
1624 spin_lock_irqsave(&nc->lock, flags); in ncsi_kick_channels()
1632 if (nc->state != NCSI_CHANNEL_ACTIVE) { in ncsi_kick_channels()
1635 !list_empty(&nc->link)) { in ncsi_kick_channels()
1638 nc); in ncsi_kick_channels()
1639 nc->reconfigure_needed = true; in ncsi_kick_channels()
1641 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_kick_channels()
1645 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_kick_channels()
1647 ncsi_stop_channel_monitor(nc); in ncsi_kick_channels()
1648 spin_lock_irqsave(&nc->lock, flags); in ncsi_kick_channels()
1649 nc->state = NCSI_CHANNEL_INACTIVE; in ncsi_kick_channels()
1650 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_kick_channels()
1653 list_add_tail_rcu(&nc->link, &ndp->channel_queue); in ncsi_kick_channels()
1656 netdev_dbg(nd->dev, "NCSI: kicked channel %p\n", nc); in ncsi_kick_channels()
1838 struct ncsi_channel *nc; in ncsi_stop_dev() local
1848 NCSI_FOR_EACH_CHANNEL(np, nc) { in ncsi_stop_dev()
1849 ncsi_stop_channel_monitor(nc); in ncsi_stop_dev()
1851 spin_lock_irqsave(&nc->lock, flags); in ncsi_stop_dev()
1852 chained = !list_empty(&nc->link); in ncsi_stop_dev()
1853 old_state = nc->state; in ncsi_stop_dev()
1854 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_stop_dev()
1869 struct ncsi_channel *nc, *active, *tmp; in ncsi_reset_dev() local
1909 list_for_each_entry_safe(nc, tmp, &ndp->channel_queue, link) in ncsi_reset_dev()
1910 list_del_init(&nc->link); in ncsi_reset_dev()
1916 NCSI_FOR_EACH_CHANNEL(np, nc) { in ncsi_reset_dev()
1917 spin_lock_irqsave(&nc->lock, flags); in ncsi_reset_dev()
1919 if (nc->state == NCSI_CHANNEL_ACTIVE) { in ncsi_reset_dev()
1920 active = nc; in ncsi_reset_dev()
1921 nc->state = NCSI_CHANNEL_INVISIBLE; in ncsi_reset_dev()
1922 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_reset_dev()
1923 ncsi_stop_channel_monitor(nc); in ncsi_reset_dev()
1927 spin_unlock_irqrestore(&nc->lock, flags); in ncsi_reset_dev()