Lines Matching refs:nc
37 struct ncsi_channel *nc;
40 NCSI_FOR_EACH_CHANNEL(np, nc) {
41 if (nc == channel)
43 if (nc->state == NCSI_CHANNEL_ACTIVE &&
44 ncsi_channel_has_link(nc))
55 struct ncsi_channel *nc;
66 NCSI_FOR_EACH_CHANNEL(np, nc) {
67 spin_lock_irqsave(&nc->lock, flags);
69 if (!list_empty(&nc->link) ||
70 nc->state != NCSI_CHANNEL_ACTIVE) {
71 spin_unlock_irqrestore(&nc->lock, flags);
75 if (ncsi_channel_has_link(nc)) {
76 spin_unlock_irqrestore(&nc->lock, flags);
81 spin_unlock_irqrestore(&nc->lock, flags);
91 struct ncsi_channel *nc = from_timer(nc, t, monitor.timer);
92 struct ncsi_package *np = nc->package;
101 spin_lock_irqsave(&nc->lock, flags);
102 state = nc->state;
103 chained = !list_empty(&nc->link);
104 enabled = nc->monitor.enabled;
105 monitor_state = nc->monitor.state;
106 spin_unlock_irqrestore(&nc->lock, flags);
118 nc->id, state, chained ? "on" : "off");
119 spin_lock_irqsave(&nc->lock, flags);
120 nc->monitor.enabled = false;
121 spin_unlock_irqrestore(&nc->lock, flags);
130 nca.channel = nc->id;
142 nc->id);
146 ncm = &nc->modes[NCSI_MODE_LINK];
147 spin_lock_irqsave(&nc->lock, flags);
148 nc->monitor.enabled = false;
149 nc->state = NCSI_CHANNEL_INVISIBLE;
151 spin_unlock_irqrestore(&nc->lock, flags);
154 nc->state = NCSI_CHANNEL_ACTIVE;
155 list_add_tail_rcu(&nc->link, &ndp->channel_queue);
161 spin_lock_irqsave(&nc->lock, flags);
162 nc->monitor.state++;
163 spin_unlock_irqrestore(&nc->lock, flags);
164 mod_timer(&nc->monitor.timer, jiffies + HZ);
167 void ncsi_start_channel_monitor(struct ncsi_channel *nc)
171 spin_lock_irqsave(&nc->lock, flags);
172 WARN_ON_ONCE(nc->monitor.enabled);
173 nc->monitor.enabled = true;
174 nc->monitor.state = NCSI_CHANNEL_MONITOR_START;
175 spin_unlock_irqrestore(&nc->lock, flags);
177 mod_timer(&nc->monitor.timer, jiffies + HZ);
180 void ncsi_stop_channel_monitor(struct ncsi_channel *nc)
184 spin_lock_irqsave(&nc->lock, flags);
185 if (!nc->monitor.enabled) {
186 spin_unlock_irqrestore(&nc->lock, flags);
189 nc->monitor.enabled = false;
190 spin_unlock_irqrestore(&nc->lock, flags);
192 del_timer_sync(&nc->monitor.timer);
198 struct ncsi_channel *nc;
200 NCSI_FOR_EACH_CHANNEL(np, nc) {
201 if (nc->id == id)
202 return nc;
210 struct ncsi_channel *nc, *tmp;
214 nc = kzalloc(sizeof(*nc), GFP_ATOMIC);
215 if (!nc)
218 nc->id = id;
219 nc->package = np;
220 nc->state = NCSI_CHANNEL_INACTIVE;
221 nc->monitor.enabled = false;
222 timer_setup(&nc->monitor.timer, ncsi_channel_monitor, 0);
223 spin_lock_init(&nc->lock);
224 INIT_LIST_HEAD(&nc->link);
226 nc->caps[index].index = index;
228 nc->modes[index].index = index;
234 kfree(nc);
238 list_add_tail_rcu(&nc->node, &np->channels);
242 return nc;
245 static void ncsi_remove_channel(struct ncsi_channel *nc)
247 struct ncsi_package *np = nc->package;
250 spin_lock_irqsave(&nc->lock, flags);
253 kfree(nc->mac_filter.addrs);
254 kfree(nc->vlan_filter.vids);
256 nc->state = NCSI_CHANNEL_INACTIVE;
257 spin_unlock_irqrestore(&nc->lock, flags);
258 ncsi_stop_channel_monitor(nc);
262 list_del_rcu(&nc->node);
266 kfree(nc);
316 struct ncsi_channel *nc, *tmp;
320 list_for_each_entry_safe(nc, tmp, &np->channels, node)
321 ncsi_remove_channel(nc);
335 struct ncsi_channel **nc)
345 if (nc)
346 *nc = c;
437 struct ncsi_channel *nc;
458 &np, &nc);
459 ncsi_send_netlink_timeout(nr, np, nc);
471 struct ncsi_channel *nc, *tmp;
477 nc = ndp->active_channel;
519 NCSI_FOR_EACH_CHANNEL(np, nc) {
520 nca.channel = nc->id;
532 nca.channel = nc->id;
545 nca.channel = nc->id;
557 if (tmp != nc && tmp->state == NCSI_CHANNEL_ACTIVE) {
577 spin_lock_irqsave(&nc->lock, flags);
578 nc->state = NCSI_CHANNEL_INACTIVE;
579 spin_unlock_irqrestore(&nc->lock, flags);
598 static int clear_one_vid(struct ncsi_dev_priv *ndp, struct ncsi_channel *nc,
607 ncf = &nc->vlan_filter;
610 spin_lock_irqsave(&nc->lock, flags);
613 spin_unlock_irqrestore(&nc->lock, flags);
620 spin_unlock_irqrestore(&nc->lock, flags);
633 static int set_one_vid(struct ncsi_dev_priv *ndp, struct ncsi_channel *nc,
646 ncf = &nc->vlan_filter;
649 spin_lock_irqsave(&nc->lock, flags);
666 spin_unlock_irqrestore(&nc->lock, flags);
674 nc->id);
675 spin_unlock_irqrestore(&nc->lock, flags);
681 spin_unlock_irqrestore(&nc->lock, flags);
811 struct ncsi_channel *nc)
821 if (!ndp->multi_package && np != nc->package)
835 return np->preferred_channel == nc;
840 if (ncsi_channel_has_link(nc))
858 struct ncsi_channel *nc;
875 NCSI_FOR_EACH_CHANNEL(np, nc)
876 if (nc->modes[NCSI_MODE_TX_ENABLE].enable) {
877 disable = nc;
897 NCSI_FOR_EACH_CHANNEL(np, nc) {
898 if (!(np->channel_whitelist & 0x1 << nc->id))
900 if (nc->state != NCSI_CHANNEL_ACTIVE)
902 if (ncsi_channel_has_link(nc)) {
903 enable = nc;
943 struct ncsi_channel *nc = ndp->active_channel;
982 nca.channel = nc->id;
999 nca.channel = nc->id;
1001 ret = ncsi_gma_handler(&nca, nc->version.mf_id);
1021 nca.channel = nc->id;
1025 ret = clear_one_vid(ndp, nc, &nca);
1035 ret = set_one_vid(ndp, nc, &nca);
1065 nca.dwords[0] = nc->caps[NCSI_CAP_BC].cap;
1070 if (nc->caps[NCSI_CAP_GENERIC].cap &
1073 else if (ncsi_channel_is_tx(ndp, nc))
1079 if (ncsi_channel_is_tx(ndp, nc))
1085 nc != np->preferred_channel)
1088 nc->id);
1095 if (!(nc->caps[NCSI_CAP_AEN].cap & NCSI_CAP_AEN_MASK))
1100 nca.dwords[1] = nc->caps[NCSI_CAP_AEN].cap;
1117 nc->id);
1118 spin_lock_irqsave(&nc->lock, flags);
1119 nc->state = NCSI_CHANNEL_ACTIVE;
1123 nc->reconfigure_needed = false;
1124 spin_unlock_irqrestore(&nc->lock, flags);
1129 if (nc->reconfigure_needed) {
1134 nc->reconfigure_needed = false;
1135 nc->state = NCSI_CHANNEL_INACTIVE;
1136 spin_unlock_irqrestore(&nc->lock, flags);
1139 list_add_tail_rcu(&nc->link, &ndp->channel_queue);
1147 if (nc->modes[NCSI_MODE_LINK].data[2] & 0x1) {
1148 hot_nc = nc;
1153 nc->id);
1155 spin_unlock_irqrestore(&nc->lock, flags);
1162 ncsi_start_channel_monitor(nc);
1178 struct ncsi_channel *nc, *found, *hot_nc;
1198 NCSI_FOR_EACH_CHANNEL(np, nc) {
1199 if (!(np->channel_whitelist & (0x1 << nc->id)))
1202 spin_lock_irqsave(&nc->lock, cflags);
1204 if (!list_empty(&nc->link) ||
1205 nc->state != NCSI_CHANNEL_INACTIVE) {
1206 spin_unlock_irqrestore(&nc->lock, cflags);
1211 found = nc;
1213 if (nc == hot_nc)
1214 found = nc;
1216 ncm = &nc->modes[NCSI_MODE_LINK];
1218 found = nc;
1228 list_add_tail_rcu(&nc->link,
1234 nc->id,
1238 spin_unlock_irqrestore(&nc->lock, cflags);
1267 struct ncsi_channel *nc;
1275 NCSI_FOR_EACH_CHANNEL(np, nc) {
1278 cap = nc->caps[NCSI_CAP_GENERIC].cap;
1301 struct ncsi_channel *nc;
1411 NCSI_FOR_EACH_CHANNEL(np, nc) {
1412 nca.channel = nc->id;
1489 struct ncsi_channel *nc;
1494 nc = list_first_or_null_rcu(&ndp->channel_queue,
1496 if (!nc) {
1501 list_del_init(&nc->link);
1504 spin_lock_irqsave(&nc->lock, flags);
1505 old_state = nc->state;
1506 nc->state = NCSI_CHANNEL_INVISIBLE;
1507 spin_unlock_irqrestore(&nc->lock, flags);
1509 ndp->active_channel = nc;
1510 ndp->active_package = nc->package;
1516 nc->id);
1522 nc->id);
1527 old_state, nc->package->id, nc->id);
1549 struct ncsi_channel *nc;
1555 NCSI_FOR_EACH_CHANNEL(np, nc) {
1556 spin_lock_irqsave(&nc->lock, flags);
1564 if (nc->state != NCSI_CHANNEL_ACTIVE) {
1567 !list_empty(&nc->link)) {
1570 nc);
1571 nc->reconfigure_needed = true;
1573 spin_unlock_irqrestore(&nc->lock, flags);
1577 spin_unlock_irqrestore(&nc->lock, flags);
1579 ncsi_stop_channel_monitor(nc);
1580 spin_lock_irqsave(&nc->lock, flags);
1581 nc->state = NCSI_CHANNEL_INACTIVE;
1582 spin_unlock_irqrestore(&nc->lock, flags);
1585 list_add_tail_rcu(&nc->link, &ndp->channel_queue);
1588 netdev_dbg(nd->dev, "NCSI: kicked channel %p\n", nc);
1769 struct ncsi_channel *nc;
1779 NCSI_FOR_EACH_CHANNEL(np, nc) {
1780 ncsi_stop_channel_monitor(nc);
1782 spin_lock_irqsave(&nc->lock, flags);
1783 chained = !list_empty(&nc->link);
1784 old_state = nc->state;
1785 spin_unlock_irqrestore(&nc->lock, flags);
1800 struct ncsi_channel *nc, *active, *tmp;
1840 list_for_each_entry_safe(nc, tmp, &ndp->channel_queue, link)
1841 list_del_init(&nc->link);
1847 NCSI_FOR_EACH_CHANNEL(np, nc) {
1848 spin_lock_irqsave(&nc->lock, flags);
1850 if (nc->state == NCSI_CHANNEL_ACTIVE) {
1851 active = nc;
1852 nc->state = NCSI_CHANNEL_INVISIBLE;
1853 spin_unlock_irqrestore(&nc->lock, flags);
1854 ncsi_stop_channel_monitor(nc);
1858 spin_unlock_irqrestore(&nc->lock, flags);