1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 23712b42dSKarsten Keil /* 33712b42dSKarsten Keil * see notice in l1oip.c 43712b42dSKarsten Keil */ 53712b42dSKarsten Keil 63712b42dSKarsten Keil /* debugging */ 73712b42dSKarsten Keil #define DEBUG_L1OIP_INIT 0x00010000 83712b42dSKarsten Keil #define DEBUG_L1OIP_SOCKET 0x00020000 93712b42dSKarsten Keil #define DEBUG_L1OIP_MGR 0x00040000 103712b42dSKarsten Keil #define DEBUG_L1OIP_MSG 0x00080000 113712b42dSKarsten Keil 123712b42dSKarsten Keil /* enable to disorder received bchannels by sequence 2143658798... */ 133712b42dSKarsten Keil /* 143712b42dSKarsten Keil #define REORDER_DEBUG 153712b42dSKarsten Keil */ 163712b42dSKarsten Keil 173712b42dSKarsten Keil /* frames */ 183712b42dSKarsten Keil #define L1OIP_MAX_LEN 2048 /* max packet size form l2 */ 193712b42dSKarsten Keil #define L1OIP_MAX_PERFRAME 1400 /* max data size in one frame */ 203712b42dSKarsten Keil 213712b42dSKarsten Keil 223712b42dSKarsten Keil /* timers */ 233712b42dSKarsten Keil #define L1OIP_KEEPALIVE 15 243712b42dSKarsten Keil #define L1OIP_TIMEOUT 65 253712b42dSKarsten Keil 263712b42dSKarsten Keil 273712b42dSKarsten Keil /* socket */ 283712b42dSKarsten Keil #define L1OIP_DEFAULTPORT 931 293712b42dSKarsten Keil 303712b42dSKarsten Keil 313712b42dSKarsten Keil /* channel structure */ 323712b42dSKarsten Keil struct l1oip_chan { 333712b42dSKarsten Keil struct dchannel *dch; 343712b42dSKarsten Keil struct bchannel *bch; 353712b42dSKarsten Keil u32 tx_counter; /* counts xmit bytes/packets */ 363712b42dSKarsten Keil u32 rx_counter; /* counts recv bytes/packets */ 373712b42dSKarsten Keil u32 codecstate; /* used by codec to save data */ 383712b42dSKarsten Keil #ifdef REORDER_DEBUG 393712b42dSKarsten Keil int disorder_flag; 403712b42dSKarsten Keil struct sk_buff *disorder_skb; 413712b42dSKarsten Keil u32 disorder_cnt; 423712b42dSKarsten Keil #endif 433712b42dSKarsten Keil }; 443712b42dSKarsten Keil 453712b42dSKarsten Keil 463712b42dSKarsten Keil /* card structure */ 473712b42dSKarsten Keil struct l1oip { 483712b42dSKarsten Keil struct list_head list; 493712b42dSKarsten Keil 503712b42dSKarsten Keil /* card */ 513712b42dSKarsten Keil int registered; /* if registered with mISDN */ 523712b42dSKarsten Keil char name[MISDN_MAX_IDLEN]; 533712b42dSKarsten Keil int idx; /* card index */ 543712b42dSKarsten Keil int pri; /* 1=pri, 0=bri */ 553712b42dSKarsten Keil int d_idx; /* current dchannel number */ 563712b42dSKarsten Keil int b_num; /* number of bchannels */ 573712b42dSKarsten Keil u32 id; /* id of connection */ 583712b42dSKarsten Keil int ondemand; /* if transmis. is on demand */ 593712b42dSKarsten Keil int bundle; /* bundle channels in one frm */ 603712b42dSKarsten Keil int codec; /* codec to use for transmis. */ 613712b42dSKarsten Keil int limit; /* limit number of bchannels */ 62*2568a7e0SDuoming Zhou bool shutdown; /* if card is released */ 633712b42dSKarsten Keil 643712b42dSKarsten Keil /* timer */ 653712b42dSKarsten Keil struct timer_list keep_tl; 663712b42dSKarsten Keil struct timer_list timeout_tl; 673712b42dSKarsten Keil int timeout_on; 683712b42dSKarsten Keil struct work_struct workq; 693712b42dSKarsten Keil 703712b42dSKarsten Keil /* socket */ 713712b42dSKarsten Keil struct socket *socket; /* if set, socket is created */ 723712b42dSKarsten Keil struct completion socket_complete;/* completion of sock thread */ 733712b42dSKarsten Keil struct task_struct *socket_thread; 743712b42dSKarsten Keil spinlock_t socket_lock; /* access sock outside thread */ 753712b42dSKarsten Keil u32 remoteip; /* if all set, ip is assigned */ 763712b42dSKarsten Keil u16 localport; /* must always be set */ 773712b42dSKarsten Keil u16 remoteport; /* must always be set */ 783712b42dSKarsten Keil struct sockaddr_in sin_local; /* local socket name */ 793712b42dSKarsten Keil struct sockaddr_in sin_remote; /* remote socket name */ 803712b42dSKarsten Keil struct msghdr sendmsg; /* ip message to send */ 818c90e11eSArnaldo Carvalho de Melo struct kvec sendiov; /* iov for message */ 823712b42dSKarsten Keil 833712b42dSKarsten Keil /* frame */ 843712b42dSKarsten Keil struct l1oip_chan chan[128]; /* channel instances */ 853712b42dSKarsten Keil }; 863712b42dSKarsten Keil 873712b42dSKarsten Keil extern int l1oip_law_to_4bit(u8 *data, int len, u8 *result, u32 *state); 883712b42dSKarsten Keil extern int l1oip_4bit_to_law(u8 *data, int len, u8 *result); 893712b42dSKarsten Keil extern int l1oip_alaw_to_ulaw(u8 *data, int len, u8 *result); 903712b42dSKarsten Keil extern int l1oip_ulaw_to_alaw(u8 *data, int len, u8 *result); 913712b42dSKarsten Keil extern void l1oip_4bit_free(void); 923712b42dSKarsten Keil extern int l1oip_4bit_alloc(int ulaw); 93