Lines Matching refs:mgr
72 struct manager *mgr = fi->userdata; in da_debug() local
84 printk(KERN_DEBUG "mgr(%d): %pV\n", mgr->ch.st->dev->id, &vaf); in da_debug()
92 struct manager *mgr = fi->userdata; in da_activate() local
95 mISDN_FsmDelTimer(&mgr->datimer, 1); in da_activate()
108 struct manager *mgr = fi->userdata; in da_deactivate() local
112 read_lock_irqsave(&mgr->lock, flags); in da_deactivate()
113 list_for_each_entry(l2, &mgr->layer2, list) { in da_deactivate()
116 read_unlock_irqrestore(&mgr->lock, flags); in da_deactivate()
120 read_unlock_irqrestore(&mgr->lock, flags); in da_deactivate()
122 if (!test_bit(OPTION_L1_HOLD, &mgr->options)) { in da_deactivate()
123 mISDN_FsmAddTimer(&mgr->datimer, DATIMER_VAL, EV_DATIMER, in da_deactivate()
132 struct manager *mgr = fi->userdata; in da_ui() local
135 if (!test_bit(OPTION_L1_HOLD, &mgr->options)) { in da_ui()
136 mISDN_FsmDelTimer(&mgr->datimer, 2); in da_ui()
137 mISDN_FsmAddTimer(&mgr->datimer, DATIMER_VAL, EV_DATIMER, in da_ui()
145 struct manager *mgr = fi->userdata; in da_timer() local
150 read_lock_irqsave(&mgr->lock, flags); in da_timer()
151 list_for_each_entry(l2, &mgr->layer2, list) { in da_timer()
154 read_unlock_irqrestore(&mgr->lock, flags); in da_timer()
159 read_unlock_irqrestore(&mgr->lock, flags); in da_timer()
162 _queue_data(&mgr->ch, PH_DEACTIVATE_REQ, MISDN_ID_ANY, 0, NULL, in da_timer()
242 get_free_id(struct manager *mgr) in get_free_id() argument
248 list_for_each_entry(l2, &mgr->layer2, list) { in get_free_id()
266 get_free_tei(struct manager *mgr) in get_free_tei() argument
272 list_for_each_entry(l2, &mgr->layer2, list) { in get_free_tei()
293 teiup_create(struct manager *mgr, u_int prim, int len, void *arg) in teiup_create() argument
304 hh->id = (mgr->ch.nr << 16) | mgr->ch.addr; in teiup_create()
307 err = mgr->up->send(mgr->up, skb); in teiup_create()
315 new_id(struct manager *mgr) in new_id() argument
319 id = mgr->nextid++; in new_id()
321 mgr->nextid = 1; in new_id()
329 do_send(struct manager *mgr) in do_send() argument
331 if (!test_bit(MGR_PH_ACTIVE, &mgr->options)) in do_send()
334 if (!test_and_set_bit(MGR_PH_NOTREADY, &mgr->options)) { in do_send()
335 struct sk_buff *skb = skb_dequeue(&mgr->sendq); in do_send()
338 test_and_clear_bit(MGR_PH_NOTREADY, &mgr->options); in do_send()
341 mgr->lastid = mISDN_HEAD_ID(skb); in do_send()
342 mISDN_FsmEvent(&mgr->deact, EV_UI, NULL); in do_send()
343 if (mgr->ch.recv(mgr->ch.peer, skb)) { in do_send()
345 test_and_clear_bit(MGR_PH_NOTREADY, &mgr->options); in do_send()
346 mgr->lastid = MISDN_ID_NONE; in do_send()
352 do_ack(struct manager *mgr, u_int id) in do_ack() argument
354 if (test_bit(MGR_PH_NOTREADY, &mgr->options)) { in do_ack()
355 if (id == mgr->lastid) { in do_ack()
356 if (test_bit(MGR_PH_ACTIVE, &mgr->options)) { in do_ack()
359 skb = skb_dequeue(&mgr->sendq); in do_ack()
361 mgr->lastid = mISDN_HEAD_ID(skb); in do_ack()
362 if (!mgr->ch.recv(mgr->ch.peer, skb)) in do_ack()
367 mgr->lastid = MISDN_ID_NONE; in do_ack()
368 test_and_clear_bit(MGR_PH_NOTREADY, &mgr->options); in do_ack()
374 mgr_send_down(struct manager *mgr, struct sk_buff *skb) in mgr_send_down() argument
376 skb_queue_tail(&mgr->sendq, skb); in mgr_send_down()
377 if (!test_bit(MGR_PH_ACTIVE, &mgr->options)) { in mgr_send_down()
378 _queue_data(&mgr->ch, PH_ACTIVATE_REQ, MISDN_ID_ANY, 0, in mgr_send_down()
381 do_send(mgr); in mgr_send_down()
386 dl_unit_data(struct manager *mgr, struct sk_buff *skb) in dl_unit_data() argument
388 if (!test_bit(MGR_OPT_NETWORK, &mgr->options)) /* only net send UI */ in dl_unit_data()
390 if (!test_bit(MGR_PH_ACTIVE, &mgr->options)) in dl_unit_data()
391 _queue_data(&mgr->ch, PH_ACTIVATE_REQ, MISDN_ID_ANY, 0, in dl_unit_data()
398 mISDN_HEAD_ID(skb) = new_id(mgr); in dl_unit_data()
399 skb_queue_tail(&mgr->sendq, skb); in dl_unit_data()
400 do_send(mgr); in dl_unit_data()
414 findtei(struct manager *mgr, int tei) in findtei() argument
419 read_lock_irqsave(&mgr->lock, flags); in findtei()
420 list_for_each_entry(l2, &mgr->layer2, list) { in findtei()
427 read_unlock_irqrestore(&mgr->lock, flags); in findtei()
432 put_tei_msg(struct manager *mgr, u_char m_id, unsigned int ri, int tei) in put_tei_msg() argument
438 if (test_bit(MGR_OPT_NETWORK, &mgr->options)) in put_tei_msg()
447 skb = _alloc_mISDN_skb(PH_DATA_REQ, new_id(mgr), 8, bp, GFP_ATOMIC); in put_tei_msg()
452 mgr_send_down(mgr, skb); in put_tei_msg()
470 put_tei_msg(tm->mgr, ID_REQUEST, tm->ri, GROUP_TEI); in tei_id_request()
491 l2 = findtei(tm->mgr, tei); in tei_id_assign()
520 l2 = findtei(tm->mgr, tei); in tei_id_test_dup()
560 put_tei_msg(tm->mgr, ID_CHK_RES, random_ri(), tm->l2->tei); in tei_id_chk_req()
590 put_tei_msg(tm->mgr, ID_VERIFY, 0, tm->l2->tei); in tei_id_verify()
606 put_tei_msg(tm->mgr, ID_REQUEST, tm->ri, GROUP_TEI); in tei_id_req_tout()
625 put_tei_msg(tm->mgr, ID_VERIFY, 0, tm->l2->tei); in tei_id_ver_tout()
653 put_tei_msg(l2->tm->mgr, ID_REMOVE, 0, l2->tei); in tei_l2remove()
675 put_tei_msg(tm->mgr, ID_ASSIGNED, tm->ri, tm->l2->tei); in tei_assign_req()
688 put_tei_msg(tm->mgr, ID_CHK_REQ, 0, tm->l2->tei); in tei_id_chk_req_net()
741 put_tei_msg(tm->mgr, ID_CHK_REQ, 0, tm->l2->tei); in tei_id_ver_tout_net()
782 create_new_tei(struct manager *mgr, int tei, int sapi) in create_new_tei() argument
790 if (!mgr->up) in create_new_tei()
794 if (mgr->ch.st->dev->Dprotocols & ((1 << ISDN_P_TE_E1) | in create_new_tei()
801 l2 = create_l2(mgr->up, ISDN_P_LAPD_NT, opt, tei, sapi); in create_new_tei()
812 l2->tm->mgr = mgr; in create_new_tei()
821 write_lock_irqsave(&mgr->lock, flags); in create_new_tei()
822 id = get_free_id(mgr); in create_new_tei()
823 list_add_tail(&l2->list, &mgr->layer2); in create_new_tei()
824 write_unlock_irqrestore(&mgr->lock, flags); in create_new_tei()
831 __add_layer2(&l2->ch, mgr->ch.st); in create_new_tei()
832 l2->ch.recv = mgr->ch.recv; in create_new_tei()
833 l2->ch.peer = mgr->ch.peer; in create_new_tei()
836 rq.adr.dev = mgr->ch.st->dev->id; in create_new_tei()
837 id = mgr->ch.st->own.ctrl(&mgr->ch.st->own, OPEN_CHANNEL, &rq); in create_new_tei()
848 new_tei_req(struct manager *mgr, u_char *dp) in new_tei_req() argument
855 if (!mgr->up) in new_tei_req()
862 tei = get_free_tei(mgr); in new_tei_req()
867 l2 = create_new_tei(mgr, tei, CTRL_SAPI); in new_tei_req()
874 put_tei_msg(mgr, ID_DENIED, ri, GROUP_TEI); in new_tei_req()
878 ph_data_ind(struct manager *mgr, struct sk_buff *skb) in ph_data_ind() argument
908 if (!test_bit(MGR_OPT_NETWORK, &mgr->options)) in ph_data_ind()
915 if (test_bit(MGR_OPT_NETWORK, &mgr->options)) in ph_data_ind()
923 new_tei_req(mgr, &skb->data[4]); in ph_data_ind()
926 list_for_each_entry_safe(l2, nl2, &mgr->layer2, list) { in ph_data_ind()
947 if (test_bit(MGR_OPT_NETWORK, &tm->mgr->options)) in l2_tei()
949 if (test_bit(MGR_OPT_USER, &tm->mgr->options)) in l2_tei()
953 if (test_bit(MGR_OPT_NETWORK, &tm->mgr->options)) in l2_tei()
954 mISDN_FsmEvent(&tm->mgr->deact, EV_ACTIVATE, NULL); in l2_tei()
957 if (test_bit(MGR_OPT_NETWORK, &tm->mgr->options)) in l2_tei()
958 mISDN_FsmEvent(&tm->mgr->deact, EV_DEACTIVATE, NULL); in l2_tei()
961 if (test_bit(MGR_OPT_NETWORK, &tm->mgr->options)) in l2_tei()
962 mISDN_FsmEvent(&tm->mgr->deact, EV_UI, NULL); in l2_tei()
975 write_lock_irqsave(&tm->mgr->lock, flags); in TEIrelease()
977 write_unlock_irqrestore(&tm->mgr->lock, flags); in TEIrelease()
983 create_teimgr(struct manager *mgr, struct channel_req *crq) in create_teimgr() argument
993 __func__, dev_name(&mgr->ch.st->dev->dev), in create_teimgr()
1002 if (test_bit(MGR_OPT_NETWORK, &mgr->options)) { in create_teimgr()
1007 if (mgr->up) { in create_teimgr()
1013 } else if (test_bit(MGR_OPT_USER, &mgr->options)) { in create_teimgr()
1020 test_and_set_bit(MGR_OPT_NETWORK, &mgr->options); in create_teimgr()
1022 test_and_set_bit(MGR_OPT_USER, &mgr->options); in create_teimgr()
1025 if (mgr->ch.st->dev->Dprotocols in create_teimgr()
1029 mgr->up = crq->ch; in create_teimgr()
1031 teiup_create(mgr, DL_INFORMATION_IND, sizeof(id), &id); in create_teimgr()
1032 if (test_bit(MGR_PH_ACTIVE, &mgr->options)) in create_teimgr()
1033 teiup_create(mgr, PH_ACTIVATE_IND, 0, NULL); in create_teimgr()
1035 if (!list_empty(&mgr->layer2)) { in create_teimgr()
1036 read_lock_irqsave(&mgr->lock, flags); in create_teimgr()
1037 list_for_each_entry(l2, &mgr->layer2, list) { in create_teimgr()
1038 l2->up = mgr->up; in create_teimgr()
1041 read_unlock_irqrestore(&mgr->lock, flags); in create_teimgr()
1055 l2->tm->mgr = mgr; in create_teimgr()
1078 write_lock_irqsave(&mgr->lock, flags); in create_teimgr()
1079 id = get_free_id(mgr); in create_teimgr()
1080 list_add_tail(&l2->list, &mgr->layer2); in create_teimgr()
1081 write_unlock_irqrestore(&mgr->lock, flags); in create_teimgr()
1087 id = mgr->ch.st->own.ctrl(&mgr->ch.st->own, OPEN_CHANNEL, in create_teimgr()
1098 struct manager *mgr; in mgr_send() local
1102 mgr = container_of(ch, struct manager, ch); in mgr_send()
1108 mISDN_FsmEvent(&mgr->deact, EV_UI, NULL); in mgr_send()
1109 ret = ph_data_ind(mgr, skb); in mgr_send()
1112 do_ack(mgr, hh->id); in mgr_send()
1116 test_and_set_bit(MGR_PH_ACTIVE, &mgr->options); in mgr_send()
1117 if (mgr->up) in mgr_send()
1118 teiup_create(mgr, PH_ACTIVATE_IND, 0, NULL); in mgr_send()
1119 mISDN_FsmEvent(&mgr->deact, EV_ACTIVATE_IND, NULL); in mgr_send()
1120 do_send(mgr); in mgr_send()
1124 test_and_clear_bit(MGR_PH_ACTIVE, &mgr->options); in mgr_send()
1125 if (mgr->up) in mgr_send()
1126 teiup_create(mgr, PH_DEACTIVATE_IND, 0, NULL); in mgr_send()
1127 mISDN_FsmEvent(&mgr->deact, EV_DEACTIVATE_IND, NULL); in mgr_send()
1131 return dl_unit_data(mgr, skb); in mgr_send()
1139 free_teimanager(struct manager *mgr) in free_teimanager() argument
1143 test_and_clear_bit(OPTION_L1_HOLD, &mgr->options); in free_teimanager()
1144 if (test_bit(MGR_OPT_NETWORK, &mgr->options)) { in free_teimanager()
1146 mgr->up = NULL; in free_teimanager()
1147 if (test_bit(OPTION_L2_CLEANUP, &mgr->options)) { in free_teimanager()
1148 list_for_each_entry_safe(l2, nl2, &mgr->layer2, list) { in free_teimanager()
1149 put_tei_msg(mgr, ID_REMOVE, 0, l2->tei); in free_teimanager()
1150 mutex_lock(&mgr->ch.st->lmutex); in free_teimanager()
1152 mutex_unlock(&mgr->ch.st->lmutex); in free_teimanager()
1155 test_and_clear_bit(MGR_OPT_NETWORK, &mgr->options); in free_teimanager()
1157 list_for_each_entry_safe(l2, nl2, &mgr->layer2, list) { in free_teimanager()
1162 if (test_bit(MGR_OPT_USER, &mgr->options)) { in free_teimanager()
1163 if (list_empty(&mgr->layer2)) in free_teimanager()
1164 test_and_clear_bit(MGR_OPT_USER, &mgr->options); in free_teimanager()
1166 mgr->ch.st->dev->D.ctrl(&mgr->ch.st->dev->D, CLOSE_CHANNEL, NULL); in free_teimanager()
1171 ctrl_teimanager(struct manager *mgr, void *arg) in ctrl_teimanager() argument
1179 test_and_set_bit(OPTION_L2_CLEANUP, &mgr->options); in ctrl_teimanager()
1181 test_and_clear_bit(OPTION_L2_CLEANUP, &mgr->options); in ctrl_teimanager()
1185 test_and_set_bit(OPTION_L1_HOLD, &mgr->options); in ctrl_teimanager()
1187 test_and_clear_bit(OPTION_L1_HOLD, &mgr->options); in ctrl_teimanager()
1197 check_data(struct manager *mgr, struct sk_buff *skb) in check_data() argument
1206 if (test_bit(MGR_OPT_USER, &mgr->options)) in check_data()
1226 l2 = create_new_tei(mgr, tei, sapi); in check_data()
1240 struct manager *mgr; in delete_teimanager() local
1243 mgr = container_of(ch, struct manager, ch); in delete_teimanager()
1245 list_for_each_entry_safe(l2, nl2, &mgr->layer2, list) { in delete_teimanager()
1246 mutex_lock(&mgr->ch.st->lmutex); in delete_teimanager()
1248 mutex_unlock(&mgr->ch.st->lmutex); in delete_teimanager()
1251 list_del(&mgr->ch.list); in delete_teimanager()
1252 list_del(&mgr->bcast.list); in delete_teimanager()
1253 skb_queue_purge(&mgr->sendq); in delete_teimanager()
1254 kfree(mgr); in delete_teimanager()
1260 struct manager *mgr; in mgr_ctrl() local
1263 mgr = container_of(ch, struct manager, ch); in mgr_ctrl()
1268 ret = create_teimgr(mgr, arg); in mgr_ctrl()
1271 ret = free_teimanager(mgr); in mgr_ctrl()
1274 ret = ctrl_teimanager(mgr, arg); in mgr_ctrl()
1277 ret = check_data(mgr, arg); in mgr_ctrl()
1286 struct manager *mgr = container_of(ch, struct manager, bcast); in mgr_bcast() local
1293 read_lock_irqsave(&mgr->lock, flags); in mgr_bcast()
1294 list_for_each_entry(l2, &mgr->layer2, list) { in mgr_bcast()
1297 if (list_is_last(&l2->list, &mgr->layer2)) { in mgr_bcast()
1330 read_unlock_irqrestore(&mgr->lock, flags); in mgr_bcast()
1346 struct manager *mgr; in create_teimanager() local
1348 mgr = kzalloc(sizeof(struct manager), GFP_KERNEL); in create_teimanager()
1349 if (!mgr) in create_teimanager()
1351 INIT_LIST_HEAD(&mgr->layer2); in create_teimanager()
1352 rwlock_init(&mgr->lock); in create_teimanager()
1353 skb_queue_head_init(&mgr->sendq); in create_teimanager()
1354 mgr->nextid = 1; in create_teimanager()
1355 mgr->lastid = MISDN_ID_NONE; in create_teimanager()
1356 mgr->ch.send = mgr_send; in create_teimanager()
1357 mgr->ch.ctrl = mgr_ctrl; in create_teimanager()
1358 mgr->ch.st = dev->D.st; in create_teimanager()
1359 set_channel_address(&mgr->ch, TEI_SAPI, GROUP_TEI); in create_teimanager()
1360 add_layer2(&mgr->ch, dev->D.st); in create_teimanager()
1361 mgr->bcast.send = mgr_bcast; in create_teimanager()
1362 mgr->bcast.ctrl = mgr_bcast_ctrl; in create_teimanager()
1363 mgr->bcast.st = dev->D.st; in create_teimanager()
1364 set_channel_address(&mgr->bcast, 0, GROUP_TEI); in create_teimanager()
1365 add_layer2(&mgr->bcast, dev->D.st); in create_teimanager()
1366 mgr->deact.debug = *debug & DEBUG_MANAGER; in create_teimanager()
1367 mgr->deact.userdata = mgr; in create_teimanager()
1368 mgr->deact.printdebug = da_debug; in create_teimanager()
1369 mgr->deact.fsm = &deactfsm; in create_teimanager()
1370 mgr->deact.state = ST_L1_DEACT; in create_teimanager()
1371 mISDN_FsmInitTimer(&mgr->deact, &mgr->datimer); in create_teimanager()
1372 dev->teimgr = &mgr->ch; in create_teimanager()