• Home
  • Raw
  • Download

Lines Matching refs:hc

276 l1oip_socket_send(struct l1oip *hc, u8 localcodec, u8 channel, u32 chanmask,  in l1oip_socket_send()  argument
290 if (time_before(hc->keep_tl.expires, jiffies + 5 * HZ)) in l1oip_socket_send()
291 mod_timer(&hc->keep_tl, jiffies + L1OIP_KEEPALIVE * HZ); in l1oip_socket_send()
293 hc->keep_tl.expires = jiffies + L1OIP_KEEPALIVE * HZ; in l1oip_socket_send()
299 if (!hc->sin_remote.sin_addr.s_addr || !hc->sin_remote.sin_port) { in l1oip_socket_send()
308 | (hc->pri ? 0x20 : 0x00) /* type */ in l1oip_socket_send()
309 | (hc->id ? 0x10 : 0x00) /* id */ in l1oip_socket_send()
311 if (hc->id) { in l1oip_socket_send()
312 *p++ = hc->id >> 24; /* id */ in l1oip_socket_send()
313 *p++ = hc->id >> 16; in l1oip_socket_send()
314 *p++ = hc->id >> 8; in l1oip_socket_send()
315 *p++ = hc->id; in l1oip_socket_send()
328 &hc->chan[channel].codecstate); in l1oip_socket_send()
335 spin_lock(&hc->socket_lock); in l1oip_socket_send()
336 if (!hc->socket) { in l1oip_socket_send()
337 spin_unlock(&hc->socket_lock); in l1oip_socket_send()
341 socket = hc->socket; in l1oip_socket_send()
342 hc->socket = NULL; in l1oip_socket_send()
343 spin_unlock(&hc->socket_lock); in l1oip_socket_send()
348 hc->sendiov.iov_base = frame; in l1oip_socket_send()
349 hc->sendiov.iov_len = len; in l1oip_socket_send()
350 len = kernel_sendmsg(socket, &hc->sendmsg, &hc->sendiov, 1, len); in l1oip_socket_send()
352 hc->socket = socket; /* no locking required */ in l1oip_socket_send()
362 l1oip_socket_recv(struct l1oip *hc, u8 remotecodec, u8 channel, u16 timebase, in l1oip_socket_recv() argument
387 dch = hc->chan[channel].dch; in l1oip_socket_recv()
388 bch = hc->chan[channel].bch; in l1oip_socket_recv()
419 rx_counter = hc->chan[channel].rx_counter; in l1oip_socket_recv()
437 hc->chan[channel].rx_counter = rx_counter; in l1oip_socket_recv()
440 if (hc->chan[channel].disorder_flag) { in l1oip_socket_recv()
443 skb = hc->chan[channel].disorder_skb; in l1oip_socket_recv()
444 hc->chan[channel].disorder_skb = nskb; in l1oip_socket_recv()
446 cnt = hc->chan[channel].disorder_cnt; in l1oip_socket_recv()
447 hc->chan[channel].disorder_cnt = rx_counter; in l1oip_socket_recv()
450 hc->chan[channel].disorder_flag ^= 1; in l1oip_socket_recv()
462 l1oip_socket_parse(struct l1oip *hc, struct sockaddr_in *sin, u8 *buf, int len) in l1oip_socket_parse() argument
470 struct dchannel *dch = hc->chan[hc->d_idx].dch; in l1oip_socket_parse()
491 if (((*buf) & 0x20) && !hc->pri) { in l1oip_socket_parse()
496 if (!((*buf) & 0x20) && hc->pri) { in l1oip_socket_parse()
517 if (!hc->id) { in l1oip_socket_parse()
533 if (packet_id != hc->id) { in l1oip_socket_parse()
536 __func__, packet_id, hc->id); in l1oip_socket_parse()
540 if (hc->id) { in l1oip_socket_parse()
613 l1oip_socket_recv(hc, remotecodec, channel, timebase, buf, mlen); in l1oip_socket_parse()
622 if (time_before(hc->timeout_tl.expires, jiffies + 5 * HZ) || !hc->timeout_on) { in l1oip_socket_parse()
623 hc->timeout_on = 1; in l1oip_socket_parse()
624 mod_timer(&hc->timeout_tl, jiffies + L1OIP_TIMEOUT * HZ); in l1oip_socket_parse()
626 hc->timeout_tl.expires = jiffies + L1OIP_TIMEOUT * HZ; in l1oip_socket_parse()
629 if ((hc->sin_remote.sin_addr.s_addr != sin->sin_addr.s_addr) in l1oip_socket_parse()
630 || (hc->sin_remote.sin_port != sin->sin_port)) { in l1oip_socket_parse()
634 ntohl(hc->sin_remote.sin_addr.s_addr), in l1oip_socket_parse()
636 ntohs(hc->sin_remote.sin_port), in l1oip_socket_parse()
638 hc->sin_remote.sin_addr.s_addr = sin->sin_addr.s_addr; in l1oip_socket_parse()
639 hc->sin_remote.sin_port = sin->sin_port; in l1oip_socket_parse()
650 struct l1oip *hc = (struct l1oip *)data; in l1oip_socket_thread() local
679 hc->sin_local.sin_family = AF_INET; in l1oip_socket_thread()
680 hc->sin_local.sin_addr.s_addr = INADDR_ANY; in l1oip_socket_thread()
681 hc->sin_local.sin_port = htons((unsigned short)hc->localport); in l1oip_socket_thread()
684 hc->sin_remote.sin_family = AF_INET; in l1oip_socket_thread()
685 hc->sin_remote.sin_addr.s_addr = htonl(hc->remoteip); in l1oip_socket_thread()
686 hc->sin_remote.sin_port = htons((unsigned short)hc->remoteport); in l1oip_socket_thread()
689 if (socket->ops->bind(socket, (struct sockaddr *)&hc->sin_local, in l1oip_socket_thread()
690 sizeof(hc->sin_local))) { in l1oip_socket_thread()
692 __func__, hc->localport); in l1oip_socket_thread()
711 hc->sendmsg.msg_name = &hc->sin_remote; in l1oip_socket_thread()
712 hc->sendmsg.msg_namelen = sizeof(hc->sin_remote); in l1oip_socket_thread()
713 hc->sendmsg.msg_control = NULL; in l1oip_socket_thread()
714 hc->sendmsg.msg_controllen = 0; in l1oip_socket_thread()
717 spin_lock(&hc->socket_lock); in l1oip_socket_thread()
718 hc->socket = socket; in l1oip_socket_thread()
719 spin_unlock(&hc->socket_lock); in l1oip_socket_thread()
733 l1oip_socket_parse(hc, &sin_rx, recvbuf, recvlen); in l1oip_socket_thread()
742 spin_lock(&hc->socket_lock); in l1oip_socket_thread()
744 while (!hc->socket) { in l1oip_socket_thread()
745 spin_unlock(&hc->socket_lock); in l1oip_socket_thread()
747 spin_lock(&hc->socket_lock); in l1oip_socket_thread()
749 hc->socket = NULL; in l1oip_socket_thread()
750 spin_unlock(&hc->socket_lock); in l1oip_socket_thread()
765 complete(&hc->socket_complete); in l1oip_socket_thread()
766 hc->socket_thread = NULL; /* show termination of thread */ in l1oip_socket_thread()
775 l1oip_socket_close(struct l1oip *hc) in l1oip_socket_close() argument
777 struct dchannel *dch = hc->chan[hc->d_idx].dch; in l1oip_socket_close()
780 if (hc->socket_thread) { in l1oip_socket_close()
784 send_sig(SIGTERM, hc->socket_thread, 0); in l1oip_socket_close()
785 wait_for_completion(&hc->socket_complete); in l1oip_socket_close()
800 l1oip_socket_open(struct l1oip *hc) in l1oip_socket_open() argument
803 l1oip_socket_close(hc); in l1oip_socket_open()
805 init_completion(&hc->socket_complete); in l1oip_socket_open()
808 hc->socket_thread = kthread_run(l1oip_socket_thread, hc, "l1oip_%s", in l1oip_socket_open()
809 hc->name); in l1oip_socket_open()
810 if (IS_ERR(hc->socket_thread)) { in l1oip_socket_open()
811 int err = PTR_ERR(hc->socket_thread); in l1oip_socket_open()
814 hc->socket_thread = NULL; in l1oip_socket_open()
815 sock_release(hc->socket); in l1oip_socket_open()
828 struct l1oip *hc = container_of(work, struct l1oip, workq); in l1oip_send_bh() local
835 l1oip_socket_send(hc, 0, hc->d_idx, 0, 0, NULL, 0); in l1oip_send_bh()
845 struct l1oip *hc = (struct l1oip *)data; in l1oip_keepalive() local
847 schedule_work(&hc->workq); in l1oip_keepalive()
853 struct l1oip *hc = (struct l1oip *)data; in l1oip_timeout() local
854 struct dchannel *dch = hc->chan[hc->d_idx].dch; in l1oip_timeout()
860 hc->timeout_on = 0; /* state that timer must be initialized next time */ in l1oip_timeout()
873 if (hc->ondemand) { in l1oip_timeout()
877 hc->sin_remote.sin_addr.s_addr = 0; in l1oip_timeout()
890 struct l1oip *hc = dch->hw; in handle_dmsg() local
913 l1oip_socket_send(hc, 0, dch->slot, 0, in handle_dmsg()
914 hc->chan[dch->slot].tx_counter++, p, ll); in handle_dmsg()
924 , __func__, dch->slot, hc->b_num + 1); in handle_dmsg()
935 hc->b_num + 1); in handle_dmsg()
952 struct l1oip *hc = dch->hw; in channel_dctrl() local
960 hc->remoteip = (u32)cq->p1; in channel_dctrl()
961 hc->remoteport = cq->p2 & 0xffff; in channel_dctrl()
962 hc->localport = cq->p2 >> 16; in channel_dctrl()
963 if (!hc->remoteport) in channel_dctrl()
964 hc->remoteport = hc->localport; in channel_dctrl()
968 l1oip_socket_open(hc); in channel_dctrl()
974 hc->remoteip = 0; in channel_dctrl()
975 l1oip_socket_open(hc); in channel_dctrl()
981 cq->p1 = hc->remoteip; in channel_dctrl()
982 cq->p2 = hc->remoteport | (hc->localport << 16); in channel_dctrl()
994 open_dchannel(struct l1oip *hc, struct dchannel *dch, struct channel_req *rq) in open_dchannel() argument
1021 open_bchannel(struct l1oip *hc, struct dchannel *dch, struct channel_req *rq) in open_bchannel() argument
1031 bch = hc->chan[ch].bch; in open_bchannel()
1051 struct l1oip *hc = dch->hw; in l1oip_dctrl() local
1064 if (hc->pri) { in l1oip_dctrl()
1068 err = open_dchannel(hc, dch, rq); in l1oip_dctrl()
1072 if (!hc->pri) { in l1oip_dctrl()
1076 err = open_dchannel(hc, dch, rq); in l1oip_dctrl()
1079 err = open_bchannel(hc, dch, rq); in l1oip_dctrl()
1105 struct l1oip *hc = bch->hw; in handle_bmsg() local
1129 hc->chan[bch->slot].tx_counter += l; in handle_bmsg()
1140 hc->chan[bch->slot].tx_counter += l; in handle_bmsg()
1151 l1oip_socket_send(hc, hc->codec, bch->slot, 0, in handle_bmsg()
1152 hc->chan[bch->slot].tx_counter, p, ll); in handle_bmsg()
1153 hc->chan[bch->slot].tx_counter += ll; in handle_bmsg()
1163 , __func__, bch->slot, hc->b_num + 1); in handle_bmsg()
1164 hc->chan[bch->slot].codecstate = 0; in handle_bmsg()
1173 hc->b_num + 1); in handle_bmsg()
1245 release_card(struct l1oip *hc) in release_card() argument
1249 if (timer_pending(&hc->keep_tl)) in release_card()
1250 del_timer(&hc->keep_tl); in release_card()
1252 if (timer_pending(&hc->timeout_tl)) in release_card()
1253 del_timer(&hc->timeout_tl); in release_card()
1255 cancel_work_sync(&hc->workq); in release_card()
1257 if (hc->socket_thread) in release_card()
1258 l1oip_socket_close(hc); in release_card()
1260 if (hc->registered && hc->chan[hc->d_idx].dch) in release_card()
1261 mISDN_unregister_device(&hc->chan[hc->d_idx].dch->dev); in release_card()
1263 if (hc->chan[ch].dch) { in release_card()
1264 mISDN_freedchannel(hc->chan[ch].dch); in release_card()
1265 kfree(hc->chan[ch].dch); in release_card()
1267 if (hc->chan[ch].bch) { in release_card()
1268 mISDN_freebchannel(hc->chan[ch].bch); in release_card()
1269 kfree(hc->chan[ch].bch); in release_card()
1271 if (hc->chan[ch].disorder_skb) in release_card()
1272 dev_kfree_skb(hc->chan[ch].disorder_skb); in release_card()
1278 list_del(&hc->list); in release_card()
1281 kfree(hc); in release_card()
1287 struct l1oip *hc, *next; in l1oip_cleanup() local
1289 list_for_each_entry_safe(hc, next, &l1oip_ilist, list) in l1oip_cleanup()
1290 release_card(hc); in l1oip_cleanup()
1300 init_card(struct l1oip *hc, int pri, int bundle) in init_card() argument
1307 spin_lock_init(&hc->socket_lock); in init_card()
1308 hc->idx = l1oip_cnt; in init_card()
1309 hc->pri = pri; in init_card()
1310 hc->d_idx = pri ? 16 : 3; in init_card()
1311 hc->b_num = pri ? 30 : 2; in init_card()
1312 hc->bundle = bundle; in init_card()
1313 if (hc->pri) in init_card()
1314 sprintf(hc->name, "l1oip-e1.%d", l1oip_cnt + 1); in init_card()
1316 sprintf(hc->name, "l1oip-s0.%d", l1oip_cnt + 1); in init_card()
1329 hc->codec = codec[l1oip_cnt]; in init_card()
1332 __func__, hc->codec); in init_card()
1339 hc->id = id[l1oip_cnt]; in init_card()
1341 printk(KERN_DEBUG "%s: using id 0x%x\n", __func__, hc->id); in init_card()
1343 hc->ondemand = ondemand[l1oip_cnt]; in init_card()
1344 if (hc->ondemand && !hc->id) { in init_card()
1351 hc->b_num = limit[l1oip_cnt]; in init_card()
1352 if (!pri && hc->b_num > 2) { in init_card()
1357 if (pri && hc->b_num > 126) { in init_card()
1362 if (pri && hc->b_num > 30) { in init_card()
1366 "supported by application.\n", hc->limit); in init_card()
1369 hc->remoteip = ip[l1oip_cnt << 2] << 24 in init_card()
1373 hc->localport = port[l1oip_cnt]?:(L1OIP_DEFAULTPORT + l1oip_cnt); in init_card()
1375 hc->remoteport = remoteport[l1oip_cnt]; in init_card()
1377 hc->remoteport = hc->localport; in init_card()
1381 hc->localport, hc->remoteip >> 24, in init_card()
1382 (hc->remoteip >> 16) & 0xff, in init_card()
1383 (hc->remoteip >> 8) & 0xff, hc->remoteip & 0xff, in init_card()
1384 hc->remoteport, hc->ondemand); in init_card()
1391 dch->hw = hc; in init_card()
1400 dch->dev.nrbchan = hc->b_num; in init_card()
1401 dch->slot = hc->d_idx; in init_card()
1402 hc->chan[hc->d_idx].dch = dch; in init_card()
1417 bch->hw = hc; in init_card()
1422 hc->chan[i + ch].bch = bch; in init_card()
1426 ret = mISDN_register_device(&dch->dev, NULL, hc->name); in init_card()
1429 hc->registered = 1; in init_card()
1434 ret = l1oip_socket_open(hc); in init_card()
1438 hc->keep_tl.function = (void *)l1oip_keepalive; in init_card()
1439 hc->keep_tl.data = (ulong)hc; in init_card()
1440 init_timer(&hc->keep_tl); in init_card()
1441 hc->keep_tl.expires = jiffies + 2 * HZ; /* two seconds first time */ in init_card()
1442 add_timer(&hc->keep_tl); in init_card()
1444 hc->timeout_tl.function = (void *)l1oip_timeout; in init_card()
1445 hc->timeout_tl.data = (ulong)hc; in init_card()
1446 init_timer(&hc->timeout_tl); in init_card()
1447 hc->timeout_on = 0; /* state that we have timer off */ in init_card()
1456 struct l1oip *hc; in l1oip_init() local
1500 hc = kzalloc(sizeof(struct l1oip), GFP_ATOMIC); in l1oip_init()
1501 if (!hc) { in l1oip_init()
1506 INIT_WORK(&hc->workq, (void *)l1oip_send_bh); in l1oip_init()
1509 list_add_tail(&hc->list, &l1oip_ilist); in l1oip_init()
1512 ret = init_card(hc, pri, bundle); in l1oip_init()