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);
855 struct ncsi_channel *nc)
865 if (!ndp->multi_package && np != nc->package)
879 return np->preferred_channel == nc;
884 if (ncsi_channel_has_link(nc))
902 struct ncsi_channel *nc;
919 NCSI_FOR_EACH_CHANNEL(np, nc)
920 if (nc->modes[NCSI_MODE_TX_ENABLE].enable) {
921 disable = nc;
941 NCSI_FOR_EACH_CHANNEL(np, nc) {
942 if (!(np->channel_whitelist & 0x1 << nc->id))
944 if (nc->state != NCSI_CHANNEL_ACTIVE)
946 if (ncsi_channel_has_link(nc)) {
947 enable = nc;
987 struct ncsi_channel *nc = ndp->active_channel;
1026 nca.channel = nc->id;
1042 nca.channel = nc->id;
1044 if (nc->version.major >= 1 && nc->version.minor >= 2) {
1049 ret = ncsi_gma_handler(&nca, nc->version.mf_id);
1068 nca.channel = nc->id;
1072 ret = clear_one_vid(ndp, nc, &nca);
1082 ret = set_one_vid(ndp, nc, &nca);
1112 nca.dwords[0] = nc->caps[NCSI_CAP_BC].cap;
1117 if (nc->caps[NCSI_CAP_GENERIC].cap &
1120 else if (ncsi_channel_is_tx(ndp, nc))
1126 if (ncsi_channel_is_tx(ndp, nc))
1132 nc != np->preferred_channel)
1135 nc->id);
1142 if (!(nc->caps[NCSI_CAP_AEN].cap & NCSI_CAP_AEN_MASK))
1147 nca.dwords[1] = nc->caps[NCSI_CAP_AEN].cap;
1164 nc->id);
1165 spin_lock_irqsave(&nc->lock, flags);
1166 nc->state = NCSI_CHANNEL_ACTIVE;
1170 nc->reconfigure_needed = false;
1171 spin_unlock_irqrestore(&nc->lock, flags);
1176 if (nc->reconfigure_needed) {
1181 nc->reconfigure_needed = false;
1182 nc->state = NCSI_CHANNEL_INACTIVE;
1183 spin_unlock_irqrestore(&nc->lock, flags);
1186 list_add_tail_rcu(&nc->link, &ndp->channel_queue);
1194 if (nc->modes[NCSI_MODE_LINK].data[2] & 0x1) {
1195 hot_nc = nc;
1200 nc->id);
1202 spin_unlock_irqrestore(&nc->lock, flags);
1209 ncsi_start_channel_monitor(nc);
1225 struct ncsi_channel *nc, *found, *hot_nc;
1245 NCSI_FOR_EACH_CHANNEL(np, nc) {
1246 if (!(np->channel_whitelist & (0x1 << nc->id)))
1249 spin_lock_irqsave(&nc->lock, cflags);
1251 if (!list_empty(&nc->link) ||
1252 nc->state != NCSI_CHANNEL_INACTIVE) {
1253 spin_unlock_irqrestore(&nc->lock, cflags);
1258 found = nc;
1260 if (nc == hot_nc)
1261 found = nc;
1263 ncm = &nc->modes[NCSI_MODE_LINK];
1265 found = nc;
1275 list_add_tail_rcu(&nc->link,
1281 nc->id,
1285 spin_unlock_irqrestore(&nc->lock, cflags);
1314 struct ncsi_channel *nc;
1322 NCSI_FOR_EACH_CHANNEL(np, nc) {
1325 cap = nc->caps[NCSI_CAP_GENERIC].cap;
1348 struct ncsi_channel *nc;
1470 NCSI_FOR_EACH_CHANNEL(np, nc) {
1471 nca.channel = nc->id;
1548 struct ncsi_channel *nc;
1553 nc = list_first_or_null_rcu(&ndp->channel_queue,
1555 if (!nc) {
1560 list_del_init(&nc->link);
1563 spin_lock_irqsave(&nc->lock, flags);
1564 old_state = nc->state;
1565 nc->state = NCSI_CHANNEL_INVISIBLE;
1566 spin_unlock_irqrestore(&nc->lock, flags);
1568 ndp->active_channel = nc;
1569 ndp->active_package = nc->package;
1575 nc->id);
1581 nc->id);
1586 old_state, nc->package->id, nc->id);
1608 struct ncsi_channel *nc;
1614 NCSI_FOR_EACH_CHANNEL(np, nc) {
1615 spin_lock_irqsave(&nc->lock, flags);
1623 if (nc->state != NCSI_CHANNEL_ACTIVE) {
1626 !list_empty(&nc->link)) {
1629 nc);
1630 nc->reconfigure_needed = true;
1632 spin_unlock_irqrestore(&nc->lock, flags);
1636 spin_unlock_irqrestore(&nc->lock, flags);
1638 ncsi_stop_channel_monitor(nc);
1639 spin_lock_irqsave(&nc->lock, flags);
1640 nc->state = NCSI_CHANNEL_INACTIVE;
1641 spin_unlock_irqrestore(&nc->lock, flags);
1644 list_add_tail_rcu(&nc->link, &ndp->channel_queue);
1647 netdev_dbg(nd->dev, "NCSI: kicked channel %p\n", nc);
1829 struct ncsi_channel *nc;
1839 NCSI_FOR_EACH_CHANNEL(np, nc) {
1840 ncsi_stop_channel_monitor(nc);
1842 spin_lock_irqsave(&nc->lock, flags);
1843 chained = !list_empty(&nc->link);
1844 old_state = nc->state;
1845 spin_unlock_irqrestore(&nc->lock, flags);
1860 struct ncsi_channel *nc, *active, *tmp;
1900 list_for_each_entry_safe(nc, tmp, &ndp->channel_queue, link)
1901 list_del_init(&nc->link);
1907 NCSI_FOR_EACH_CHANNEL(np, nc) {
1908 spin_lock_irqsave(&nc->lock, flags);
1910 if (nc->state == NCSI_CHANNEL_ACTIVE) {
1911 active = nc;
1912 nc->state = NCSI_CHANNEL_INVISIBLE;
1913 spin_unlock_irqrestore(&nc->lock, flags);
1914 ncsi_stop_channel_monitor(nc);
1918 spin_unlock_irqrestore(&nc->lock, flags);