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)) 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) || !hc->timeout_on) { in l1oip_socket_parse()
605 hc->timeout_on = 1; in l1oip_socket_parse()
606 mod_timer(&hc->timeout_tl, jiffies + L1OIP_TIMEOUT * HZ); in l1oip_socket_parse()
608 hc->timeout_tl.expires = jiffies + L1OIP_TIMEOUT * HZ; in l1oip_socket_parse()
611 if ((hc->sin_remote.sin_addr.s_addr != sin->sin_addr.s_addr) in l1oip_socket_parse()
612 || (hc->sin_remote.sin_port != sin->sin_port)) { in l1oip_socket_parse()
616 ntohl(hc->sin_remote.sin_addr.s_addr), in l1oip_socket_parse()
618 ntohs(hc->sin_remote.sin_port), in l1oip_socket_parse()
620 hc->sin_remote.sin_addr.s_addr = sin->sin_addr.s_addr; in l1oip_socket_parse()
621 hc->sin_remote.sin_port = sin->sin_port; in l1oip_socket_parse()
632 struct l1oip *hc = (struct l1oip *)data; in l1oip_socket_thread() local
666 hc->sin_local.sin_family = AF_INET; in l1oip_socket_thread()
667 hc->sin_local.sin_addr.s_addr = INADDR_ANY; in l1oip_socket_thread()
668 hc->sin_local.sin_port = htons((unsigned short)hc->localport); in l1oip_socket_thread()
671 hc->sin_remote.sin_family = AF_INET; in l1oip_socket_thread()
672 hc->sin_remote.sin_addr.s_addr = htonl(hc->remoteip); in l1oip_socket_thread()
673 hc->sin_remote.sin_port = htons((unsigned short)hc->remoteport); in l1oip_socket_thread()
676 if (socket->ops->bind(socket, (struct sockaddr *)&hc->sin_local, in l1oip_socket_thread()
677 sizeof(hc->sin_local))) { in l1oip_socket_thread()
679 __func__, hc->localport); in l1oip_socket_thread()
692 hc->sendmsg.msg_name = &hc->sin_remote; in l1oip_socket_thread()
693 hc->sendmsg.msg_namelen = sizeof(hc->sin_remote); in l1oip_socket_thread()
694 hc->sendmsg.msg_control = NULL; in l1oip_socket_thread()
695 hc->sendmsg.msg_controllen = 0; in l1oip_socket_thread()
698 spin_lock(&hc->socket_lock); in l1oip_socket_thread()
699 hc->socket = socket; in l1oip_socket_thread()
700 spin_unlock(&hc->socket_lock); in l1oip_socket_thread()
710 l1oip_socket_parse(hc, &sin_rx, recvbuf, recvlen); in l1oip_socket_thread()
719 spin_lock(&hc->socket_lock); in l1oip_socket_thread()
721 while (!hc->socket) { in l1oip_socket_thread()
722 spin_unlock(&hc->socket_lock); in l1oip_socket_thread()
724 spin_lock(&hc->socket_lock); in l1oip_socket_thread()
726 hc->socket = NULL; in l1oip_socket_thread()
727 spin_unlock(&hc->socket_lock); in l1oip_socket_thread()
742 complete(&hc->socket_complete); in l1oip_socket_thread()
743 hc->socket_thread = NULL; /* show termination of thread */ in l1oip_socket_thread()
752 l1oip_socket_close(struct l1oip *hc) in l1oip_socket_close() argument
754 struct dchannel *dch = hc->chan[hc->d_idx].dch; in l1oip_socket_close()
757 if (hc->socket_thread) { in l1oip_socket_close()
761 send_sig(SIGTERM, hc->socket_thread, 0); in l1oip_socket_close()
762 wait_for_completion(&hc->socket_complete); in l1oip_socket_close()
777 l1oip_socket_open(struct l1oip *hc) in l1oip_socket_open() argument
780 l1oip_socket_close(hc); in l1oip_socket_open()
782 init_completion(&hc->socket_complete); in l1oip_socket_open()
785 hc->socket_thread = kthread_run(l1oip_socket_thread, hc, "l1oip_%s", in l1oip_socket_open()
786 hc->name); in l1oip_socket_open()
787 if (IS_ERR(hc->socket_thread)) { in l1oip_socket_open()
788 int err = PTR_ERR(hc->socket_thread); in l1oip_socket_open()
791 hc->socket_thread = NULL; in l1oip_socket_open()
792 sock_release(hc->socket); in l1oip_socket_open()
805 struct l1oip *hc = container_of(work, struct l1oip, workq); in l1oip_send_bh() local
812 l1oip_socket_send(hc, 0, hc->d_idx, 0, 0, NULL, 0); in l1oip_send_bh()
822 struct l1oip *hc = from_timer(hc, t, keep_tl); in l1oip_keepalive() local
824 schedule_work(&hc->workq); in l1oip_keepalive()
830 struct l1oip *hc = from_timer(hc, t, in l1oip_timeout() local
832 struct dchannel *dch = hc->chan[hc->d_idx].dch; in l1oip_timeout()
838 hc->timeout_on = 0; /* state that timer must be initialized next time */ in l1oip_timeout()
851 if (hc->ondemand) { in l1oip_timeout()
855 hc->sin_remote.sin_addr.s_addr = 0; in l1oip_timeout()
868 struct l1oip *hc = dch->hw; in handle_dmsg() local
895 l1oip_socket_send(hc, 0, dch->slot, 0, in handle_dmsg()
896 hc->chan[dch->slot].tx_counter++, p, ll); in handle_dmsg()
906 , __func__, dch->slot, hc->b_num + 1); in handle_dmsg()
917 hc->b_num + 1); in handle_dmsg()
934 struct l1oip *hc = dch->hw; in channel_dctrl() local
942 hc->remoteip = (u32)cq->p1; in channel_dctrl()
943 hc->remoteport = cq->p2 & 0xffff; in channel_dctrl()
944 hc->localport = cq->p2 >> 16; in channel_dctrl()
945 if (!hc->remoteport) in channel_dctrl()
946 hc->remoteport = hc->localport; in channel_dctrl()
950 l1oip_socket_open(hc); in channel_dctrl()
956 hc->remoteip = 0; in channel_dctrl()
957 l1oip_socket_open(hc); in channel_dctrl()
963 cq->p1 = hc->remoteip; in channel_dctrl()
964 cq->p2 = hc->remoteport | (hc->localport << 16); in channel_dctrl()
976 open_dchannel(struct l1oip *hc, struct dchannel *dch, struct channel_req *rq) in open_dchannel() argument
1003 open_bchannel(struct l1oip *hc, struct dchannel *dch, struct channel_req *rq) in open_bchannel() argument
1013 bch = hc->chan[ch].bch; in open_bchannel()
1033 struct l1oip *hc = dch->hw; in l1oip_dctrl() local
1046 if (hc->pri) { in l1oip_dctrl()
1050 err = open_dchannel(hc, dch, rq); in l1oip_dctrl()
1054 if (!hc->pri) { in l1oip_dctrl()
1058 err = open_dchannel(hc, dch, rq); in l1oip_dctrl()
1061 err = open_bchannel(hc, dch, rq); in l1oip_dctrl()
1087 struct l1oip *hc = bch->hw; in handle_bmsg() local
1111 hc->chan[bch->slot].tx_counter += l; in handle_bmsg()
1122 hc->chan[bch->slot].tx_counter += l; in handle_bmsg()
1137 l1oip_socket_send(hc, hc->codec, bch->slot, 0, in handle_bmsg()
1138 hc->chan[bch->slot].tx_counter, p, ll); in handle_bmsg()
1139 hc->chan[bch->slot].tx_counter += ll; in handle_bmsg()
1149 , __func__, bch->slot, hc->b_num + 1); in handle_bmsg()
1150 hc->chan[bch->slot].codecstate = 0; in handle_bmsg()
1159 hc->b_num + 1); in handle_bmsg()
1231 release_card(struct l1oip *hc) in release_card() argument
1235 if (timer_pending(&hc->keep_tl)) in release_card()
1236 del_timer(&hc->keep_tl); in release_card()
1238 if (timer_pending(&hc->timeout_tl)) in release_card()
1239 del_timer(&hc->timeout_tl); in release_card()
1241 cancel_work_sync(&hc->workq); in release_card()
1243 if (hc->socket_thread) in release_card()
1244 l1oip_socket_close(hc); in release_card()
1246 if (hc->registered && hc->chan[hc->d_idx].dch) in release_card()
1247 mISDN_unregister_device(&hc->chan[hc->d_idx].dch->dev); in release_card()
1249 if (hc->chan[ch].dch) { in release_card()
1250 mISDN_freedchannel(hc->chan[ch].dch); in release_card()
1251 kfree(hc->chan[ch].dch); in release_card()
1253 if (hc->chan[ch].bch) { in release_card()
1254 mISDN_freebchannel(hc->chan[ch].bch); in release_card()
1255 kfree(hc->chan[ch].bch); in release_card()
1257 dev_kfree_skb(hc->chan[ch].disorder_skb); in release_card()
1263 list_del(&hc->list); in release_card()
1266 kfree(hc); in release_card()
1272 struct l1oip *hc, *next; in l1oip_cleanup() local
1274 list_for_each_entry_safe(hc, next, &l1oip_ilist, list) in l1oip_cleanup()
1275 release_card(hc); in l1oip_cleanup()
1285 init_card(struct l1oip *hc, int pri, int bundle) in init_card() argument
1292 spin_lock_init(&hc->socket_lock); in init_card()
1293 hc->idx = l1oip_cnt; in init_card()
1294 hc->pri = pri; in init_card()
1295 hc->d_idx = pri ? 16 : 3; in init_card()
1296 hc->b_num = pri ? 30 : 2; in init_card()
1297 hc->bundle = bundle; in init_card()
1298 if (hc->pri) in init_card()
1299 sprintf(hc->name, "l1oip-e1.%d", l1oip_cnt + 1); in init_card()
1301 sprintf(hc->name, "l1oip-s0.%d", l1oip_cnt + 1); in init_card()
1314 hc->codec = codec[l1oip_cnt]; in init_card()
1317 __func__, hc->codec); in init_card()
1324 hc->id = id[l1oip_cnt]; in init_card()
1326 printk(KERN_DEBUG "%s: using id 0x%x\n", __func__, hc->id); in init_card()
1328 hc->ondemand = ondemand[l1oip_cnt]; in init_card()
1329 if (hc->ondemand && !hc->id) { in init_card()
1336 hc->b_num = limit[l1oip_cnt]; in init_card()
1337 if (!pri && hc->b_num > 2) { in init_card()
1342 if (pri && hc->b_num > 126) { in init_card()
1347 if (pri && hc->b_num > 30) { in init_card()
1351 "supported by application.\n", hc->limit); in init_card()
1354 hc->remoteip = ip[l1oip_cnt << 2] << 24 in init_card()
1358 hc->localport = port[l1oip_cnt]?:(L1OIP_DEFAULTPORT + l1oip_cnt); in init_card()
1360 hc->remoteport = remoteport[l1oip_cnt]; in init_card()
1362 hc->remoteport = hc->localport; in init_card()
1366 hc->localport, hc->remoteip >> 24, in init_card()
1367 (hc->remoteip >> 16) & 0xff, in init_card()
1368 (hc->remoteip >> 8) & 0xff, hc->remoteip & 0xff, in init_card()
1369 hc->remoteport, hc->ondemand); in init_card()
1376 dch->hw = hc; in init_card()
1385 dch->dev.nrbchan = hc->b_num; in init_card()
1386 dch->slot = hc->d_idx; in init_card()
1387 hc->chan[hc->d_idx].dch = dch; in init_card()
1402 bch->hw = hc; in init_card()
1407 hc->chan[i + ch].bch = bch; in init_card()
1411 ret = mISDN_register_device(&dch->dev, NULL, hc->name); in init_card()
1414 hc->registered = 1; in init_card()
1419 ret = l1oip_socket_open(hc); in init_card()
1423 timer_setup(&hc->keep_tl, l1oip_keepalive, 0); in init_card()
1424 hc->keep_tl.expires = jiffies + 2 * HZ; /* two seconds first time */ in init_card()
1425 add_timer(&hc->keep_tl); in init_card()
1427 timer_setup(&hc->timeout_tl, l1oip_timeout, 0); in init_card()
1428 hc->timeout_on = 0; /* state that we have timer off */ in init_card()
1437 struct l1oip *hc; in l1oip_init() local
1478 hc = kzalloc(sizeof(struct l1oip), GFP_ATOMIC); in l1oip_init()
1479 if (!hc) { in l1oip_init()
1484 INIT_WORK(&hc->workq, (void *)l1oip_send_bh); in l1oip_init()
1487 list_add_tail(&hc->list, &l1oip_ilist); in l1oip_init()
1490 ret = init_card(hc, pri, bundle); in l1oip_init()