• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/drivers/char/

Lines Matching defs:gsm

107 	struct gsm_mux *gsm;
161 * to the gsm mux array. For now we don't free DLCI objects that
197 void (*receive)(struct gsm_mux *gsm, u8 ch);
198 void (*error)(struct gsm_mux *gsm, u8 ch, u8 flag);
533 static void gsm_send(struct gsm_mux *gsm, int addr, int cr, int control)
539 switch (gsm->encoding) {
566 gsm->output(gsm, cbuf, len);
572 * @gsm: our GSM mux
579 static inline void gsm_response(struct gsm_mux *gsm, int addr, int control)
581 gsm_send(gsm, addr, 0, control);
586 * @gsm: our GSM mux
593 static inline void gsm_command(struct gsm_mux *gsm, int addr, int control)
595 gsm_send(gsm, addr, 1, control);
604 * @gsm: GSM mux
614 static struct gsm_msg *gsm_data_alloc(struct gsm_mux *gsm, u8 addr, int len,
630 static void gsm_data_kick(struct gsm_mux *gsm)
632 struct gsm_msg *msg = gsm->tx_head;
636 if (gsm->constipated)
639 while (gsm->tx_head != NULL) {
640 msg = gsm->tx_head;
641 if (gsm->encoding != 0) {
642 gsm->txframe[0] = GSM1_SOF;
644 gsm->txframe + 1, msg->len);
645 gsm->txframe[len + 1] = GSM1_SOF;
648 gsm->txframe[0] = GSM0_SOF;
649 memcpy(gsm->txframe + 1 , msg->data, msg->len);
650 gsm->txframe[msg->len + 1] = GSM0_SOF;
656 hex_packet(gsm->txframe, len);
659 if (gsm->output(gsm, gsm->txframe + skip_sof,
662 gsm->tx_head = msg->next;
663 if (gsm->tx_head == NULL)
664 gsm->tx_tail = NULL;
665 gsm->tx_bytes -= msg->len;
680 * the gsm tx lock.
685 struct gsm_mux *gsm = dlci->gsm;
690 if (gsm->encoding == 0) {
700 if (gsm->initiator)
710 gsm_print_packet("Q> ", msg->addr, gsm->initiator, msg->ctrl,
719 if (gsm->tx_tail)
720 gsm->tx_tail->next = msg;
722 gsm->tx_head = msg;
723 gsm->tx_tail = msg;
724 gsm->tx_bytes += msg->len;
725 gsm_data_kick(gsm);
735 * the gsm tx lock and dlci lock.
741 spin_lock_irqsave(&dlci->gsm->tx_lock, flags);
743 spin_unlock_irqrestore(&dlci->gsm->tx_lock, flags);
748 * @gsm: mux
758 static int gsm_dlci_data_output(struct gsm_mux *gsm, struct gsm_dlci *dlci)
770 if (len > gsm->mtu)
771 len = gsm->mtu;
775 msg = gsm_data_alloc(gsm, dlci->addr, size, gsm->ftype);
796 * @gsm: mux
806 static int gsm_dlci_data_output_framed(struct gsm_mux *gsm,
829 if (len > gsm->mtu) {
836 len = gsm->mtu;
841 msg = gsm_data_alloc(gsm, dlci->addr, size, gsm->ftype);
860 static void gsm_dlci_data_sweep(struct gsm_mux *gsm)
869 if (gsm->tx_bytes > TX_THRESH_HI)
871 dlci = gsm->dlci[i];
877 len = gsm_dlci_data_output(gsm, dlci);
879 len = gsm_dlci_data_output_framed(gsm, dlci);
901 spin_lock_irqsave(&dlci->gsm->tx_lock, flags);
903 if (dlci->gsm->tx_bytes == 0)
904 gsm_dlci_data_output(dlci->gsm, dlci);
905 else if (dlci->gsm->tx_bytes < TX_THRESH_LO)
906 gsm_dlci_data_sweep(dlci->gsm);
907 spin_unlock_irqrestore(&dlci->gsm->tx_lock, flags);
917 * @gsm: gsm channel
925 static void gsm_control_reply(struct gsm_mux *gsm, int cmd, u8 *data,
929 msg = gsm_data_alloc(gsm, 0, dlen + 2, gsm->ftype);
935 gsm_data_queue(gsm->dlci[0], msg);
985 * @gsm: GSM channel
995 static void gsm_control_modem(struct gsm_mux *gsm, u8 *data, int clen)
1016 if (addr == 0 || addr >= NUM_DLCI || gsm->dlci[addr] == NULL)
1018 dlci = gsm->dlci[addr];
1031 gsm_control_reply(gsm, CMD_MSC, data, clen);
1036 * @gsm: GSM channel
1045 static void gsm_control_rls(struct gsm_mux *gsm, u8 *data, int clen)
1064 if (addr == 0 || addr >= NUM_DLCI || gsm->dlci[addr] == NULL)
1071 tty = tty_port_tty_get(&gsm->dlci[addr]->port);
1083 gsm_control_reply(gsm, CMD_RLS, data, clen);
1090 * @gsm: our GSM mux
1100 static void gsm_control_message(struct gsm_mux *gsm, unsigned int command,
1106 struct gsm_dlci *dlci = gsm->dlci[0];
1110 gsm->dead = 1;
1117 gsm_control_reply(gsm, CMD_TEST, data, clen);
1121 gsm->constipated = 1;
1122 gsm_control_reply(gsm, CMD_FCON, NULL, 0);
1126 gsm->constipated = 0;
1127 gsm_control_reply(gsm, CMD_FCOFF, NULL, 0);
1129 gsm_data_kick(gsm);
1133 gsm_control_modem(gsm, data, clen);
1137 gsm_control_rls(gsm, data, clen);
1141 gsm_control_reply(gsm, CMD_PSC, NULL, 0);
1150 gsm_control_reply(gsm, CMD_NSC, buf, 1);
1157 * @gsm: our GSM mux
1168 static void gsm_control_response(struct gsm_mux *gsm, unsigned int command,
1174 spin_lock_irqsave(&gsm->control_lock, flags);
1176 ctrl = gsm->pending_cmd;
1181 del_timer(&gsm->t2_timer);
1182 gsm->pending_cmd = NULL;
1187 wake_up(&gsm->event);
1189 spin_unlock_irqrestore(&gsm->control_lock, flags);
1194 * @gsm: gsm mux
1200 static void gsm_control_transmit(struct gsm_mux *gsm, struct gsm_control *ctrl)
1202 struct gsm_msg *msg = gsm_data_alloc(gsm, 0, ctrl->len + 1,
1203 gsm->ftype|PF);
1208 gsm_data_queue(gsm->dlci[0], msg);
1213 * @data: pointer to our gsm object
1219 * gsm->pending_cmd will be NULL and we just let the timer expire.
1224 struct gsm_mux *gsm = (struct gsm_mux *)data;
1227 spin_lock_irqsave(&gsm->control_lock, flags);
1228 ctrl = gsm->pending_cmd;
1230 gsm->cretries--;
1231 if (gsm->cretries == 0) {
1232 gsm->pending_cmd = NULL;
1235 spin_unlock_irqrestore(&gsm->control_lock, flags);
1236 wake_up(&gsm->event);
1239 gsm_control_transmit(gsm, ctrl);
1240 mod_timer(&gsm->t2_timer, jiffies + gsm->t2 * HZ / 100);
1242 spin_unlock_irqrestore(&gsm->control_lock, flags);
1247 * @gsm: the GSM channel
1257 static struct gsm_control *gsm_control_send(struct gsm_mux *gsm,
1266 wait_event(gsm->event, gsm->pending_cmd == NULL);
1267 spin_lock_irqsave(&gsm->control_lock, flags);
1268 if (gsm->pending_cmd != NULL) {
1269 spin_unlock_irqrestore(&gsm->control_lock, flags);
1275 gsm->pending_cmd = ctrl;
1276 gsm->cretries = gsm->n2;
1277 mod_timer(&gsm->t2_timer, jiffies + gsm->t2 * HZ / 100);
1278 gsm_control_transmit(gsm, ctrl);
1279 spin_unlock_irqrestore(&gsm->control_lock, flags);
1285 * @gsm: GSM mux
1293 static int gsm_control_wait(struct gsm_mux *gsm, struct gsm_control *control)
1296 wait_event(gsm->event, control->done == 1);
1333 dlci->gsm->dead = 1;
1334 wake_up(&dlci->gsm->event);
1355 wake_up(&dlci->gsm->event);
1372 struct gsm_mux *gsm = dlci->gsm;
1378 gsm_command(dlci->gsm, dlci->addr, SABM|PF);
1379 mod_timer(&dlci->t1, jiffies + gsm->t1 * HZ / 100);
1386 gsm_command(dlci->gsm, dlci->addr, DISC|PF);
1387 mod_timer(&dlci->t1, jiffies + gsm->t1 * HZ / 100);
1406 struct gsm_mux *gsm = dlci->gsm;
1409 dlci->retries = gsm->n2;
1411 gsm_command(dlci->gsm, dlci->addr, SABM|PF);
1412 mod_timer(&dlci->t1, jiffies + gsm->t1 * HZ / 100);
1428 struct gsm_mux *gsm = dlci->gsm;
1431 dlci->retries = gsm->n2;
1433 gsm_command(dlci->gsm, dlci->addr, DISC|PF);
1434 mod_timer(&dlci->t1, jiffies + gsm->t1 * HZ / 100);
1509 gsm_control_message(dlci->gsm, command,
1512 gsm_control_response(dlci->gsm, command,
1524 static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
1542 dlci->gsm = gsm;
1544 dlci->adaption = gsm->adaption;
1550 gsm->dlci[addr] = dlci;
1572 dlci->gsm->dlci[dlci->addr] = NULL;
1584 * @gsm: pointer to our gsm mux
1592 static void gsm_queue(struct gsm_mux *gsm)
1600 if ((gsm->control & ~PF) == UI)
1601 gsm->fcs = gsm_fcs_add_block(gsm->fcs, gsm->buf, gsm->len);
1602 if (gsm->fcs != GOOD_FCS) {
1603 gsm->bad_fcs++;
1605 printk("BAD FCS %02x\n", gsm->fcs);
1608 address = gsm->address >> 1;
1612 cr = gsm->address & 1; /* C/R bit */
1614 gsm_print_packet("<--", address, cr, gsm->control, gsm->buf, gsm->len);
1616 cr ^= 1 - gsm->initiator; /* Flip so 1 always means command */
1617 dlci = gsm->dlci[address];
1619 switch (gsm->control) {
1624 dlci = gsm_dlci_alloc(gsm, address);
1628 gsm_response(gsm, address, DM);
1630 gsm_response(gsm, address, UA);
1638 gsm_response(gsm, address, DM);
1642 gsm_response(gsm, address, UA);
1671 gsm_command(gsm, address, DM|PF);
1674 dlci->data(dlci, gsm->buf, gsm->len);
1681 gsm->malformed++;
1688 * @gsm: gsm data for this ldisc instance
1691 * Receive bytes in gsm mode 0
1694 static void gsm0_receive(struct gsm_mux *gsm, unsigned char c)
1696 switch (gsm->state) {
1699 gsm->state = GSM_ADDRESS;
1700 gsm->address = 0;
1701 gsm->len = 0;
1702 gsm->fcs = INIT_FCS;
1706 gsm->fcs = gsm_fcs_add(gsm->fcs, c);
1707 if (gsm_read_ea(&gsm->address, c))
1708 gsm->state = GSM_CONTROL;
1711 gsm->fcs = gsm_fcs_add(gsm->fcs, c);
1712 gsm->control = c;
1713 gsm->state = GSM_LEN;
1716 gsm->fcs = gsm_fcs_add(gsm->fcs, c);
1717 if (gsm_read_ea(&gsm->len, c)) {
1718 if (gsm->len > gsm->mru) {
1719 gsm->bad_size++;
1720 gsm->state = GSM_SEARCH;
1723 gsm->count = 0;
1724 gsm->state = GSM_DATA;
1728 gsm->buf[gsm->count++] = c;
1729 if (gsm->count == gsm->len)
1730 gsm->state = GSM_FCS;
1733 gsm->fcs = c;
1734 gsm_queue(gsm);
1736 gsm->state = GSM_SEARCH;
1743 * @gsm: gsm data for this ldisc instance
1749 static void gsm1_receive(struct gsm_mux *gsm, unsigned char c)
1754 if (gsm->state == GSM_DATA && gsm->count) {
1756 gsm->count--;
1757 gsm->fcs = gsm_fcs_add(gsm->fcs, gsm->buf[gsm->count]);
1758 gsm->len = gsm->count;
1759 gsm_queue(gsm);
1760 gsm->state = GSM_START;
1764 if (gsm->state != GSM_START) {
1765 gsm->malformed++;
1766 gsm->state = GSM_START;
1774 gsm->escape = 1;
1779 if (gsm->state == GSM_SEARCH)
1782 if (gsm->escape) {
1784 gsm->escape = 0;
1786 switch (gsm->state) {
1788 gsm->address = 0;
1789 gsm->state = GSM_ADDRESS;
1790 gsm->fcs = INIT_FCS;
1793 gsm->fcs = gsm_fcs_add(gsm->fcs, c);
1794 if (gsm_read_ea(&gsm->address, c))
1795 gsm->state = GSM_CONTROL;
1798 gsm->fcs = gsm_fcs_add(gsm->fcs, c);
1799 gsm->control = c;
1800 gsm->count = 0;
1801 gsm->state = GSM_DATA;
1804 if (gsm->count > gsm->mru ) { /* Allow one for the FCS */
1805 gsm->state = GSM_OVERRUN;
1806 gsm->bad_size++;
1808 gsm->buf[gsm->count++] = c;
1816 static void gsm_error(struct gsm_mux *gsm,
1819 gsm->state = GSM_SEARCH;
1820 gsm->io_error++;
1825 * @gsm: our mux
1832 void gsm_cleanup_mux(struct gsm_mux *gsm)
1835 struct gsm_dlci *dlci = gsm->dlci[0];
1838 gsm->dead = 1;
1842 if (gsm_mux[i] == gsm) {
1850 del_timer_sync(&gsm->t2_timer);
1855 wait_event_interruptible(gsm->event,
1860 if (gsm->dlci[i])
1861 gsm_dlci_free(gsm->dlci[i]);
1863 for (txq = gsm->tx_head; txq != NULL; txq = gsm->tx_head) {
1864 gsm->tx_head = txq->next;
1867 gsm->tx_tail = NULL;
1873 * @gsm: our mux
1880 int gsm_activate_mux(struct gsm_mux *gsm)
1885 init_timer(&gsm->t2_timer);
1886 gsm->t2_timer.function = gsm_control_retransmit;
1887 gsm->t2_timer.data = (unsigned long)gsm;
1888 init_waitqueue_head(&gsm->event);
1889 spin_lock_init(&gsm->control_lock);
1890 spin_lock_init(&gsm->tx_lock);
1892 if (gsm->encoding == 0)
1893 gsm->receive = gsm0_receive;
1895 gsm->receive = gsm1_receive;
1896 gsm->error = gsm_error;
1901 gsm_mux[i] = gsm;
1909 dlci = gsm_dlci_alloc(gsm, 0);
1912 gsm->dead = 0; /* Tty opens are now permissible */
1924 void gsm_free_mux(struct gsm_mux *gsm)
1926 kfree(gsm->txframe);
1927 kfree(gsm->buf);
1928 kfree(gsm);
1940 struct gsm_mux *gsm = kzalloc(sizeof(struct gsm_mux), GFP_KERNEL);
1941 if (gsm == NULL)
1943 gsm->buf = kmalloc(MAX_MRU + 1, GFP_KERNEL);
1944 if (gsm->buf == NULL) {
1945 kfree(gsm);
1948 gsm->txframe = kmalloc(2 * MAX_MRU + 2, GFP_KERNEL);
1949 if (gsm->txframe == NULL) {
1950 kfree(gsm->buf);
1951 kfree(gsm);
1954 spin_lock_init(&gsm->lock);
1956 gsm->t1 = T1;
1957 gsm->t2 = T2;
1958 gsm->n2 = N2;
1959 gsm->ftype = UIH;
1960 gsm->initiator = 0;
1961 gsm->adaption = 1;
1962 gsm->encoding = 1;
1963 gsm->mru = 64; /* Default to encoding 1 so these should be 64 */
1964 gsm->mtu = 64;
1965 gsm->dead = 1; /* Avoid early tty opens */
1967 return gsm;
1976 * @gsm: our mux
1984 static int gsmld_output(struct gsm_mux *gsm, u8 *data, int len)
1986 if (tty_write_room(gsm->tty) < len) {
1987 set_bit(TTY_DO_WRITE_WAKEUP, &gsm->tty->flags);
1994 gsm->tty->ops->write(gsm->tty, data, len);
2001 * @gsm: our mux
2008 static int gsmld_attach_gsm(struct tty_struct *tty, struct gsm_mux *gsm)
2012 gsm->tty = tty_kref_get(tty);
2013 gsm->output = gsmld_output;
2014 ret = gsm_activate_mux(gsm);
2016 tty_kref_put(gsm->tty);
2024 * @gsm: mux
2029 static void gsmld_detach_gsm(struct tty_struct *tty, struct gsm_mux *gsm)
2031 WARN_ON(tty != gsm->tty);
2032 gsm_cleanup_mux(gsm);
2033 tty_kref_put(gsm->tty);
2034 gsm->tty = NULL;
2040 struct gsm_mux *gsm = tty->disc_data;
2056 gsm->receive(gsm, *dp);
2062 gsm->error(gsm, *dp, flags);
2081 * Locking: gsm lock
2114 struct gsm_mux *gsm = tty->disc_data;
2116 gsmld_detach_gsm(tty, gsm);
2120 gsm_free_mux(gsm);
2135 struct gsm_mux *gsm;
2141 gsm = gsm_alloc_mux();
2142 if (gsm == NULL)
2145 tty->disc_data = gsm;
2149 gsm->encoding = 1;
2150 return gsmld_attach_gsm(tty, gsm);
2164 struct gsm_mux *gsm = tty->disc_data;
2169 gsm_data_kick(gsm);
2170 if (gsm->tx_bytes < TX_THRESH_LO) {
2171 spin_lock_irqsave(&gsm->tx_lock, flags);
2172 gsm_dlci_data_sweep(gsm);
2173 spin_unlock_irqrestore(&gsm->tx_lock, flags);
2240 struct gsm_mux *gsm = tty->disc_data;
2248 if (gsm->dead)
2253 static int gsmld_config(struct tty_struct *tty, struct gsm_mux *gsm,
2278 if (c->t1 != 0 && c->t1 != gsm->t1)
2280 if (c->t2 != 0 && c->t2 != gsm->t2)
2282 if (c->encapsulation != gsm->encoding)
2284 if (c->adaption != gsm->adaption)
2287 if (c->initiator != gsm->initiator)
2289 if (c->mru != gsm->mru)
2291 if (c->mtu != gsm->mtu)
2300 gsm_dlci_begin_close(gsm->dlci[0]);
2302 wait_event_interruptible(gsm->event,
2303 gsm->dlci[0]->state == DLCI_CLOSED);
2308 gsm_cleanup_mux(gsm);
2310 gsm->initiator = c->initiator;
2311 gsm->mru = c->mru;
2312 gsm->encoding = c->encapsulation;
2313 gsm->adaption = c->adaption;
2316 gsm->ftype = UIH;
2318 gsm->ftype = UI;
2321 gsm->t1 = c->t1;
2323 gsm->t2 = c->t2;
2326 gsm_activate_mux(gsm);
2327 if (gsm->initiator && need_close)
2328 gsm_dlci_begin_open(gsm->dlci[0]);
2336 struct gsm_mux *gsm = tty->disc_data;
2341 c.adaption = gsm->adaption;
2342 c.encapsulation = gsm->encoding;
2343 c.initiator = gsm->initiator;
2344 c.t1 = gsm->t1;
2345 c.t2 = gsm->t2;
2347 c.n2 = gsm->n2;
2348 if (gsm->ftype == UIH)
2352 printk("Ftype %d i %d\n", gsm->ftype, c.i);
2353 c.mru = gsm->mru;
2354 c.mtu = gsm->mtu;
2362 return gsmld_config(tty, gsm, &c);
2406 ctrl = gsm_control_send(dlci->gsm, CMD_MSC, modembits, len + 1);
2409 return gsm_control_wait(dlci->gsm, ctrl);
2445 struct gsm_mux *gsm;
2459 gsm = gsm_mux[mux];
2460 if (gsm->dead)
2462 dlci = gsm->dlci[line];
2464 dlci = gsm_dlci_alloc(gsm, line);