Lines Matching refs:hc

264 l1oip_socket_send(struct l1oip *hc, u8 localcodec, u8 channel, u32 chanmask,  in l1oip_socket_send()  argument
278 if (time_before(hc->keep_tl.expires, jiffies + 5 * HZ) && !hc->shutdown) in l1oip_socket_send()
279 mod_timer(&hc->keep_tl, jiffies + L1OIP_KEEPALIVE * HZ); in l1oip_socket_send()
281 hc->keep_tl.expires = jiffies + L1OIP_KEEPALIVE * HZ; in l1oip_socket_send()
287 if (!hc->sin_remote.sin_addr.s_addr || !hc->sin_remote.sin_port) { in l1oip_socket_send()
296 | (hc->pri ? 0x20 : 0x00) /* type */ in l1oip_socket_send()
297 | (hc->id ? 0x10 : 0x00) /* id */ in l1oip_socket_send()
299 if (hc->id) { in l1oip_socket_send()
300 *p++ = hc->id >> 24; /* id */ in l1oip_socket_send()
301 *p++ = hc->id >> 16; in l1oip_socket_send()
302 *p++ = hc->id >> 8; in l1oip_socket_send()
303 *p++ = hc->id; in l1oip_socket_send()
316 &hc->chan[channel].codecstate); in l1oip_socket_send()
323 spin_lock(&hc->socket_lock); in l1oip_socket_send()
324 if (!hc->socket) { in l1oip_socket_send()
325 spin_unlock(&hc->socket_lock); in l1oip_socket_send()
329 socket = hc->socket; in l1oip_socket_send()
330 hc->socket = NULL; in l1oip_socket_send()
331 spin_unlock(&hc->socket_lock); in l1oip_socket_send()
336 hc->sendiov.iov_base = frame; in l1oip_socket_send()
337 hc->sendiov.iov_len = len; in l1oip_socket_send()
338 len = kernel_sendmsg(socket, &hc->sendmsg, &hc->sendiov, 1, len); in l1oip_socket_send()
340 hc->socket = socket; /* no locking required */ in l1oip_socket_send()
350 l1oip_socket_recv(struct l1oip *hc, u8 remotecodec, u8 channel, u16 timebase, in l1oip_socket_recv() argument
375 dch = hc->chan[channel].dch; in l1oip_socket_recv()
376 bch = hc->chan[channel].bch; in l1oip_socket_recv()
407 rx_counter = hc->chan[channel].rx_counter; in l1oip_socket_recv()
425 hc->chan[channel].rx_counter = rx_counter; in l1oip_socket_recv()
428 if (hc->chan[channel].disorder_flag) { in l1oip_socket_recv()
429 swap(hc->chan[channel].disorder_skb, nskb); in l1oip_socket_recv()
430 swap(hc->chan[channel].disorder_cnt, rx_counter); in l1oip_socket_recv()
432 hc->chan[channel].disorder_flag ^= 1; in l1oip_socket_recv()
444 l1oip_socket_parse(struct l1oip *hc, struct sockaddr_in *sin, u8 *buf, int len) in l1oip_socket_parse() argument
452 struct dchannel *dch = hc->chan[hc->d_idx].dch; in l1oip_socket_parse()
473 if (((*buf) & 0x20) && !hc->pri) { in l1oip_socket_parse()
478 if (!((*buf) & 0x20) && hc->pri) { in l1oip_socket_parse()
499 if (!hc->id) { in l1oip_socket_parse()
515 if (packet_id != hc->id) { in l1oip_socket_parse()
518 __func__, packet_id, hc->id); in l1oip_socket_parse()
522 if (hc->id) { in l1oip_socket_parse()
595 l1oip_socket_recv(hc, remotecodec, channel, timebase, buf, mlen); in l1oip_socket_parse()
604 if ((time_before(hc->timeout_tl.expires, jiffies + 5 * HZ) || in l1oip_socket_parse()
605 !hc->timeout_on) && in l1oip_socket_parse()
606 !hc->shutdown) { in l1oip_socket_parse()
607 hc->timeout_on = 1; in l1oip_socket_parse()
608 mod_timer(&hc->timeout_tl, jiffies + L1OIP_TIMEOUT * HZ); in l1oip_socket_parse()
610 hc->timeout_tl.expires = jiffies + L1OIP_TIMEOUT * HZ; in l1oip_socket_parse()
613 if ((hc->sin_remote.sin_addr.s_addr != sin->sin_addr.s_addr) in l1oip_socket_parse()
614 || (hc->sin_remote.sin_port != sin->sin_port)) { in l1oip_socket_parse()
618 ntohl(hc->sin_remote.sin_addr.s_addr), in l1oip_socket_parse()
620 ntohs(hc->sin_remote.sin_port), in l1oip_socket_parse()
622 hc->sin_remote.sin_addr.s_addr = sin->sin_addr.s_addr; in l1oip_socket_parse()
623 hc->sin_remote.sin_port = sin->sin_port; in l1oip_socket_parse()
634 struct l1oip *hc = (struct l1oip *)data; in l1oip_socket_thread() local
668 hc->sin_local.sin_family = AF_INET; in l1oip_socket_thread()
669 hc->sin_local.sin_addr.s_addr = INADDR_ANY; in l1oip_socket_thread()
670 hc->sin_local.sin_port = htons((unsigned short)hc->localport); in l1oip_socket_thread()
673 hc->sin_remote.sin_family = AF_INET; in l1oip_socket_thread()
674 hc->sin_remote.sin_addr.s_addr = htonl(hc->remoteip); in l1oip_socket_thread()
675 hc->sin_remote.sin_port = htons((unsigned short)hc->remoteport); in l1oip_socket_thread()
678 if (socket->ops->bind(socket, (struct sockaddr *)&hc->sin_local, in l1oip_socket_thread()
679 sizeof(hc->sin_local))) { in l1oip_socket_thread()
681 __func__, hc->localport); in l1oip_socket_thread()
694 hc->sendmsg.msg_name = &hc->sin_remote; in l1oip_socket_thread()
695 hc->sendmsg.msg_namelen = sizeof(hc->sin_remote); in l1oip_socket_thread()
696 hc->sendmsg.msg_control = NULL; in l1oip_socket_thread()
697 hc->sendmsg.msg_controllen = 0; in l1oip_socket_thread()
700 spin_lock(&hc->socket_lock); in l1oip_socket_thread()
701 hc->socket = socket; in l1oip_socket_thread()
702 spin_unlock(&hc->socket_lock); in l1oip_socket_thread()
712 l1oip_socket_parse(hc, &sin_rx, recvbuf, recvlen); in l1oip_socket_thread()
721 spin_lock(&hc->socket_lock); in l1oip_socket_thread()
723 while (!hc->socket) { in l1oip_socket_thread()
724 spin_unlock(&hc->socket_lock); in l1oip_socket_thread()
726 spin_lock(&hc->socket_lock); in l1oip_socket_thread()
728 hc->socket = NULL; in l1oip_socket_thread()
729 spin_unlock(&hc->socket_lock); in l1oip_socket_thread()
744 complete(&hc->socket_complete); in l1oip_socket_thread()
745 hc->socket_thread = NULL; /* show termination of thread */ in l1oip_socket_thread()
754 l1oip_socket_close(struct l1oip *hc) in l1oip_socket_close() argument
756 struct dchannel *dch = hc->chan[hc->d_idx].dch; in l1oip_socket_close()
759 if (hc->socket_thread) { in l1oip_socket_close()
763 send_sig(SIGTERM, hc->socket_thread, 0); in l1oip_socket_close()
764 wait_for_completion(&hc->socket_complete); in l1oip_socket_close()
779 l1oip_socket_open(struct l1oip *hc) in l1oip_socket_open() argument
782 l1oip_socket_close(hc); in l1oip_socket_open()
784 init_completion(&hc->socket_complete); in l1oip_socket_open()
787 hc->socket_thread = kthread_run(l1oip_socket_thread, hc, "l1oip_%s", in l1oip_socket_open()
788 hc->name); in l1oip_socket_open()
789 if (IS_ERR(hc->socket_thread)) { in l1oip_socket_open()
790 int err = PTR_ERR(hc->socket_thread); in l1oip_socket_open()
793 hc->socket_thread = NULL; in l1oip_socket_open()
794 sock_release(hc->socket); in l1oip_socket_open()
807 struct l1oip *hc = container_of(work, struct l1oip, workq); in l1oip_send_bh() local
814 l1oip_socket_send(hc, 0, hc->d_idx, 0, 0, NULL, 0); in l1oip_send_bh()
824 struct l1oip *hc = from_timer(hc, t, keep_tl); in l1oip_keepalive() local
826 schedule_work(&hc->workq); in l1oip_keepalive()
832 struct l1oip *hc = from_timer(hc, t, in l1oip_timeout() local
834 struct dchannel *dch = hc->chan[hc->d_idx].dch; in l1oip_timeout()
840 hc->timeout_on = 0; /* state that timer must be initialized next time */ in l1oip_timeout()
853 if (hc->ondemand) { in l1oip_timeout()
857 hc->sin_remote.sin_addr.s_addr = 0; in l1oip_timeout()
870 struct l1oip *hc = dch->hw; in handle_dmsg() local
897 l1oip_socket_send(hc, 0, dch->slot, 0, in handle_dmsg()
898 hc->chan[dch->slot].tx_counter++, p, ll); in handle_dmsg()
908 , __func__, dch->slot, hc->b_num + 1); in handle_dmsg()
919 hc->b_num + 1); in handle_dmsg()
936 struct l1oip *hc = dch->hw; in channel_dctrl() local
944 hc->remoteip = (u32)cq->p1; in channel_dctrl()
945 hc->remoteport = cq->p2 & 0xffff; in channel_dctrl()
946 hc->localport = cq->p2 >> 16; in channel_dctrl()
947 if (!hc->remoteport) in channel_dctrl()
948 hc->remoteport = hc->localport; in channel_dctrl()
952 l1oip_socket_open(hc); in channel_dctrl()
958 hc->remoteip = 0; in channel_dctrl()
959 l1oip_socket_open(hc); in channel_dctrl()
965 cq->p1 = hc->remoteip; in channel_dctrl()
966 cq->p2 = hc->remoteport | (hc->localport << 16); in channel_dctrl()
978 open_dchannel(struct l1oip *hc, struct dchannel *dch, struct channel_req *rq) in open_dchannel() argument
1005 open_bchannel(struct l1oip *hc, struct dchannel *dch, struct channel_req *rq) in open_bchannel() argument
1015 bch = hc->chan[ch].bch; in open_bchannel()
1035 struct l1oip *hc = dch->hw; in l1oip_dctrl() local
1048 if (hc->pri) { in l1oip_dctrl()
1052 err = open_dchannel(hc, dch, rq); in l1oip_dctrl()
1056 if (!hc->pri) { in l1oip_dctrl()
1060 err = open_dchannel(hc, dch, rq); in l1oip_dctrl()
1063 err = open_bchannel(hc, dch, rq); in l1oip_dctrl()
1089 struct l1oip *hc = bch->hw; in handle_bmsg() local
1113 hc->chan[bch->slot].tx_counter += l; in handle_bmsg()
1124 hc->chan[bch->slot].tx_counter += l; in handle_bmsg()
1139 l1oip_socket_send(hc, hc->codec, bch->slot, 0, in handle_bmsg()
1140 hc->chan[bch->slot].tx_counter, p, ll); in handle_bmsg()
1141 hc->chan[bch->slot].tx_counter += ll; in handle_bmsg()
1151 , __func__, bch->slot, hc->b_num + 1); in handle_bmsg()
1152 hc->chan[bch->slot].codecstate = 0; in handle_bmsg()
1161 hc->b_num + 1); in handle_bmsg()
1233 release_card(struct l1oip *hc) in release_card() argument
1237 hc->shutdown = true; in release_card()
1239 del_timer_sync(&hc->keep_tl); in release_card()
1240 del_timer_sync(&hc->timeout_tl); in release_card()
1242 cancel_work_sync(&hc->workq); in release_card()
1244 if (hc->socket_thread) in release_card()
1245 l1oip_socket_close(hc); in release_card()
1247 if (hc->registered && hc->chan[hc->d_idx].dch) in release_card()
1248 mISDN_unregister_device(&hc->chan[hc->d_idx].dch->dev); in release_card()
1250 if (hc->chan[ch].dch) { in release_card()
1251 mISDN_freedchannel(hc->chan[ch].dch); in release_card()
1252 kfree(hc->chan[ch].dch); in release_card()
1254 if (hc->chan[ch].bch) { in release_card()
1255 mISDN_freebchannel(hc->chan[ch].bch); in release_card()
1256 kfree(hc->chan[ch].bch); in release_card()
1258 dev_kfree_skb(hc->chan[ch].disorder_skb); in release_card()
1264 list_del(&hc->list); in release_card()
1267 kfree(hc); in release_card()
1273 struct l1oip *hc, *next; in l1oip_cleanup() local
1275 list_for_each_entry_safe(hc, next, &l1oip_ilist, list) in l1oip_cleanup()
1276 release_card(hc); in l1oip_cleanup()
1286 init_card(struct l1oip *hc, int pri, int bundle) in init_card() argument
1293 spin_lock_init(&hc->socket_lock); in init_card()
1294 hc->idx = l1oip_cnt; in init_card()
1295 hc->pri = pri; in init_card()
1296 hc->d_idx = pri ? 16 : 3; in init_card()
1297 hc->b_num = pri ? 30 : 2; in init_card()
1298 hc->bundle = bundle; in init_card()
1299 if (hc->pri) in init_card()
1300 sprintf(hc->name, "l1oip-e1.%d", l1oip_cnt + 1); in init_card()
1302 sprintf(hc->name, "l1oip-s0.%d", l1oip_cnt + 1); in init_card()
1315 hc->codec = codec[l1oip_cnt]; in init_card()
1318 __func__, hc->codec); in init_card()
1325 hc->id = id[l1oip_cnt]; in init_card()
1327 printk(KERN_DEBUG "%s: using id 0x%x\n", __func__, hc->id); in init_card()
1329 hc->ondemand = ondemand[l1oip_cnt]; in init_card()
1330 if (hc->ondemand && !hc->id) { in init_card()
1337 hc->b_num = limit[l1oip_cnt]; in init_card()
1338 if (!pri && hc->b_num > 2) { in init_card()
1343 if (pri && hc->b_num > 126) { in init_card()
1348 if (pri && hc->b_num > 30) { in init_card()
1352 "supported by application.\n", hc->limit); in init_card()
1355 hc->remoteip = ip[l1oip_cnt << 2] << 24 in init_card()
1359 hc->localport = port[l1oip_cnt]?:(L1OIP_DEFAULTPORT + l1oip_cnt); in init_card()
1361 hc->remoteport = remoteport[l1oip_cnt]; in init_card()
1363 hc->remoteport = hc->localport; in init_card()
1367 hc->localport, hc->remoteip >> 24, in init_card()
1368 (hc->remoteip >> 16) & 0xff, in init_card()
1369 (hc->remoteip >> 8) & 0xff, hc->remoteip & 0xff, in init_card()
1370 hc->remoteport, hc->ondemand); in init_card()
1377 dch->hw = hc; in init_card()
1386 dch->dev.nrbchan = hc->b_num; in init_card()
1387 dch->slot = hc->d_idx; in init_card()
1388 hc->chan[hc->d_idx].dch = dch; in init_card()
1403 bch->hw = hc; in init_card()
1408 hc->chan[i + ch].bch = bch; in init_card()
1412 ret = mISDN_register_device(&dch->dev, NULL, hc->name); in init_card()
1415 hc->registered = 1; in init_card()
1420 ret = l1oip_socket_open(hc); in init_card()
1424 timer_setup(&hc->keep_tl, l1oip_keepalive, 0); in init_card()
1425 hc->keep_tl.expires = jiffies + 2 * HZ; /* two seconds first time */ in init_card()
1426 add_timer(&hc->keep_tl); in init_card()
1428 timer_setup(&hc->timeout_tl, l1oip_timeout, 0); in init_card()
1429 hc->timeout_on = 0; /* state that we have timer off */ in init_card()
1438 struct l1oip *hc; in l1oip_init() local
1479 hc = kzalloc(sizeof(struct l1oip), GFP_ATOMIC); in l1oip_init()
1480 if (!hc) { in l1oip_init()
1485 INIT_WORK(&hc->workq, (void *)l1oip_send_bh); in l1oip_init()
1488 list_add_tail(&hc->list, &l1oip_ilist); in l1oip_init()
1491 ret = init_card(hc, pri, bundle); in l1oip_init()