Lines Matching defs:dlci
112 struct gsm_dlci *dlci;
186 void (*data)(struct gsm_dlci *dlci, const u8 *data, int len);
187 void (*prev_data)(struct gsm_dlci *dlci, const u8 *data, int len);
304 struct gsm_dlci *dlci[NUM_DLCI];
452 static void gsm_dlci_close(struct gsm_dlci *dlci);
454 static int gsm_modem_update(struct gsm_dlci *dlci, u8 brk);
534 * @dlci: DLCI to encode from
540 static u8 gsm_encode_modem(const struct gsm_dlci *dlci)
544 if (dlci->throttled)
546 if (dlci->modem_tx & TIOCM_DTR)
548 if (dlci->modem_tx & TIOCM_RTS)
550 if (dlci->modem_tx & TIOCM_RI)
552 if (dlci->modem_tx & TIOCM_CD || dlci->gsm->initiator)
555 if (dlci->modem_tx & TIOCM_OUT1)
557 if (dlci->modem_tx & TIOCM_OUT2)
583 * @dlci: DLCI to encode from
589 static int gsm_encode_params(const struct gsm_dlci *dlci,
592 const struct gsm_mux *gsm = dlci->gsm;
595 switch (dlci->ftype) {
603 pr_debug("unsupported frame type %d\n", dlci->ftype);
607 switch (dlci->adaption) {
615 pr_debug("unsupported adaption %d\n", dlci->adaption);
619 params->d_bits = FIELD_PREP(PN_D_FIELD_DLCI, dlci->addr);
623 params->p_bits = FIELD_PREP(PN_P_FIELD_PRIO, dlci->prio);
625 params->n_bits = cpu_to_le16(FIELD_PREP(PN_N_FIELD_N1, dlci->mtu));
627 params->k_bits = FIELD_PREP(PN_K_FIELD_K, dlci->k);
847 * @dlci: clear for this DLCI
851 static void gsm_dlci_clear_queues(struct gsm_mux *gsm, struct gsm_dlci *dlci)
854 int addr = dlci->addr;
858 spin_lock_irqsave(&dlci->lock, flags);
859 kfifo_reset(&dlci->fifo);
860 spin_unlock_irqrestore(&dlci->lock, flags);
1016 struct gsm_dlci *dlci;
1051 dlci = gsm->dlci[msg->addr];
1053 if (dlci->state != DLCI_OPEN) {
1083 * @dlci: DLCI sending the data
1091 static void __gsm_data_queue(struct gsm_dlci *dlci, struct gsm_msg *msg)
1093 struct gsm_mux *gsm = dlci->gsm;
1147 * @dlci: DLCI sending the data
1152 * the gsm tx lock and dlci lock.
1155 static void gsm_data_queue(struct gsm_dlci *dlci, struct gsm_msg *msg)
1158 spin_lock_irqsave(&dlci->gsm->tx_lock, flags);
1159 __gsm_data_queue(dlci, msg);
1160 spin_unlock_irqrestore(&dlci->gsm->tx_lock, flags);
1166 * @dlci: the DLCI to pull data from
1175 static int gsm_dlci_data_output(struct gsm_mux *gsm, struct gsm_dlci *dlci)
1182 h = ((dlci->adaption == 1) ? 0 : 1);
1184 len = kfifo_len(&dlci->fifo);
1189 if ((len + h) > dlci->mtu)
1190 len = dlci->mtu - h;
1194 msg = gsm_data_alloc(gsm, dlci->addr, size, dlci->ftype);
1198 switch (dlci->adaption) {
1204 *dp++ = (gsm_encode_modem(dlci) << 1) | EA;
1208 dlci->adaption);
1212 WARN_ON(len != kfifo_out_locked(&dlci->fifo, dp, len,
1213 &dlci->lock));
1216 tty_port_tty_wakeup(&dlci->port);
1218 __gsm_data_queue(dlci, msg);
1226 * @dlci: the DLCI to pull data from
1236 struct gsm_dlci *dlci)
1245 if (dlci->adaption == 4)
1248 /* dlci->skb is locked by tx_lock */
1249 if (dlci->skb == NULL) {
1250 dlci->skb = skb_dequeue_tail(&dlci->skb_list);
1251 if (dlci->skb == NULL)
1255 len = dlci->skb->len + overhead;
1258 if (len > dlci->mtu) {
1259 if (dlci->adaption == 3) {
1261 dev_kfree_skb_any(dlci->skb);
1262 dlci->skb = NULL;
1265 len = dlci->mtu;
1270 msg = gsm_data_alloc(gsm, dlci->addr, size, dlci->ftype);
1272 skb_queue_tail(&dlci->skb_list, dlci->skb);
1273 dlci->skb = NULL;
1278 if (dlci->adaption == 4) { /* Interruptible framed (Packetised Data) */
1283 memcpy(dp, dlci->skb->data, len);
1284 skb_pull(dlci->skb, len);
1285 __gsm_data_queue(dlci, msg);
1287 dev_kfree_skb_any(dlci->skb);
1288 dlci->skb = NULL;
1296 * @dlci: the DLCI to pull modem status from
1305 static int gsm_dlci_modem_output(struct gsm_mux *gsm, struct gsm_dlci *dlci,
1313 switch (dlci->adaption) {
1323 dlci->adaption);
1327 msg = gsm_data_alloc(gsm, dlci->addr, size, dlci->ftype);
1333 switch (dlci->adaption) {
1338 *dp++ = (gsm_encode_modem(dlci) << 1) | EA;
1340 *dp++ = gsm_encode_modem(dlci) << 1;
1349 __gsm_data_queue(dlci, msg);
1371 struct gsm_dlci *dlci;
1375 dlci = gsm->dlci[i];
1377 if (!dlci || dlci->constipated)
1380 if (dlci->state != DLCI_OPEN)
1383 if (dlci->adaption < 3 && !dlci->net)
1384 len = gsm_dlci_data_output(gsm, dlci);
1386 len = gsm_dlci_data_output_framed(gsm, dlci);
1407 * @dlci: DLCI to kick
1414 static void gsm_dlci_data_kick(struct gsm_dlci *dlci)
1419 if (dlci->constipated)
1422 spin_lock_irqsave(&dlci->gsm->tx_lock, flags);
1424 sweep = (dlci->gsm->tx_bytes < TX_THRESH_LO);
1425 if (dlci->gsm->tx_bytes == 0) {
1426 if (dlci->net)
1427 gsm_dlci_data_output_framed(dlci->gsm, dlci);
1429 gsm_dlci_data_output(dlci->gsm, dlci);
1432 gsm_dlci_data_sweep(dlci->gsm);
1433 spin_unlock_irqrestore(&dlci->gsm->tx_lock, flags);
1454 struct gsm_dlci *dlci = gsm->dlci[0];
1456 msg = gsm_data_alloc(gsm, 0, dlen + 2, dlci->ftype);
1463 gsm_data_queue(dlci, msg);
1482 struct gsm_dlci *dlci = gsm->dlci[0];
1484 msg = gsm_data_alloc(gsm, 0, dlen + 2, dlci->ftype);
1490 gsm_data_queue(dlci, msg);
1496 * @dlci: DLCI to affect
1504 static void gsm_process_modem(struct tty_struct *tty, struct gsm_dlci *dlci,
1525 if (fc && !dlci->constipated) {
1527 dlci->constipated = true;
1528 } else if (!fc && dlci->constipated) {
1529 dlci->constipated = false;
1530 gsm_dlci_data_kick(dlci);
1545 if ((mlines & TIOCM_CD) == 0 && (dlci->modem_rx & TIOCM_CD))
1550 tty_insert_flip_char(&dlci->port, 0, TTY_BREAK);
1551 dlci->modem_rx = mlines;
1552 wake_up_interruptible(&dlci->gsm->event);
1569 struct gsm_dlci *dlci = gsm->dlci[addr];
1604 if (adaption != dlci->adaption) {
1610 if (prio != dlci->prio) {
1616 if (n1 > gsm->mru || n1 > dlci->mtu) {
1626 dlci->mtu = n1;
1627 if (ftype != dlci->ftype) {
1632 if (ftype != UI && ftype != UIH && k > dlci->k) {
1637 dlci->k = k;
1646 dlci->adaption = adaption;
1649 dlci->mtu = gsm->mru;
1652 dlci->mtu = MAX_MTU;
1654 dlci->mtu = n1;
1656 dlci->prio = prio;
1657 dlci->ftype = ftype;
1658 dlci->k = k;
1682 struct gsm_dlci *dlci;
1694 if (addr == 0 || addr >= NUM_DLCI || gsm->dlci[addr] == NULL)
1696 dlci = gsm->dlci[addr];
1710 tty = tty_port_tty_get(&dlci->port);
1711 gsm_process_modem(tty, dlci, modem, cl);
1734 struct gsm_dlci *dlci;
1745 if (addr == 0 || addr >= NUM_DLCI || !gsm->dlci[addr]) {
1749 dlci = gsm->dlci[addr];
1752 if ((!cr && dlci->state == DLCI_OPENING) || dlci->state == DLCI_OPEN) {
1763 gsm_dlci_close(dlci);
1769 if (gsm_encode_params(dlci, &pn_reply) == 0)
1774 } else if (dlci->state == DLCI_CONFIGURE) {
1776 dlci->state = DLCI_OPENING;
1777 gsm_command(gsm, dlci->addr, SABM|PF);
1778 mod_timer(&dlci->t1, jiffies + gsm->t1 * HZ / 100);
1816 if (addr == 0 || addr >= NUM_DLCI || gsm->dlci[addr] == NULL)
1823 port = &gsm->dlci[addr]->port;
1837 static void gsm_dlci_begin_close(struct gsm_dlci *dlci);
1858 struct gsm_dlci *dlci = gsm->dlci[0];
1860 if (dlci) {
1861 dlci->dead = true;
1863 gsm_dlci_begin_close(dlci);
1930 struct gsm_dlci *dlci;
1936 dlci = gsm->dlci[0];
1954 if (dlci && !dlci->dead)
1980 if (gsm->dlci[0])
1981 gsm_dlci_begin_close(gsm->dlci[0]);
1983 } else if (gsm->keep_alive && gsm->dlci[0] && !gsm->dlci[0]->dead) {
2034 if (gsm->cretries == 0 || !gsm->dlci[0] || gsm->dlci[0]->dead) {
2082 if (gsm->dlci[0]->mode == DLCI_MODE_ADM)
2123 * @dlci: DLCI that closed
2129 static void gsm_dlci_close(struct gsm_dlci *dlci)
2131 del_timer(&dlci->t1);
2133 pr_debug("DLCI %d goes closed.\n", dlci->addr);
2134 dlci->state = DLCI_CLOSED;
2136 dlci->constipated = true;
2137 if (dlci->addr != 0) {
2138 tty_port_tty_hangup(&dlci->port, false);
2139 gsm_dlci_clear_queues(dlci->gsm, dlci);
2141 tty_port_set_initialized(&dlci->port, false);
2142 wake_up_interruptible(&dlci->port.open_wait);
2144 del_timer(&dlci->gsm->ka_timer);
2145 dlci->gsm->dead = true;
2149 gsm_dlci_data_kick(dlci);
2150 wake_up_all(&dlci->gsm->event);
2155 * @dlci: DLCI that opened
2160 static void gsm_dlci_open(struct gsm_dlci *dlci)
2162 struct gsm_mux *gsm = dlci->gsm;
2166 del_timer(&dlci->t1);
2168 dlci->state = DLCI_OPEN;
2169 dlci->constipated = false;
2171 pr_debug("DLCI %d goes open.\n", dlci->addr);
2173 if (dlci->addr) {
2174 gsm_modem_update(dlci, 0);
2182 gsm_dlci_data_kick(dlci);
2183 wake_up(&dlci->gsm->event);
2188 * @dlci: DLCI to open
2193 static int gsm_dlci_negotiate(struct gsm_dlci *dlci)
2195 struct gsm_mux *gsm = dlci->gsm;
2199 ret = gsm_encode_params(dlci, ¶ms);
2222 * Some control dlci can stay in ADM mode with other dlci working just
2223 * fine. In that case we can just keep the control dlci open after the
2229 struct gsm_dlci *dlci = from_timer(dlci, t, t1);
2230 struct gsm_mux *gsm = dlci->gsm;
2232 switch (dlci->state) {
2234 if (dlci->retries && gsm_dlci_negotiate(dlci) == 0) {
2235 dlci->retries--;
2236 mod_timer(&dlci->t1, jiffies + gsm->t1 * HZ / 100);
2239 gsm_dlci_begin_close(dlci); /* prevent half open link */
2243 if (dlci->retries) {
2244 dlci->retries--;
2245 gsm_command(dlci->gsm, dlci->addr, SABM|PF);
2246 mod_timer(&dlci->t1, jiffies + gsm->t1 * HZ / 100);
2247 } else if (!dlci->addr && gsm->control == (DM | PF)) {
2250 dlci->addr);
2251 dlci->mode = DLCI_MODE_ADM;
2252 gsm_dlci_open(dlci);
2255 gsm_dlci_begin_close(dlci); /* prevent half open link */
2260 if (dlci->retries) {
2261 dlci->retries--;
2262 gsm_command(dlci->gsm, dlci->addr, DISC|PF);
2263 mod_timer(&dlci->t1, jiffies + gsm->t1 * HZ / 100);
2265 gsm_dlci_close(dlci);
2268 pr_debug("%s: unhandled state: %d\n", __func__, dlci->state);
2275 * @dlci: DLCI to open
2284 static void gsm_dlci_begin_open(struct gsm_dlci *dlci)
2286 struct gsm_mux *gsm = dlci ? dlci->gsm : NULL;
2292 if (dlci->addr != 0) {
2293 if (gsm->adaption != 1 || gsm->adaption != dlci->adaption)
2295 if (dlci->prio != (roundup(dlci->addr + 1, 8) - 1))
2297 if (gsm->ftype != dlci->ftype)
2301 switch (dlci->state) {
2305 dlci->retries = gsm->n2;
2307 dlci->state = DLCI_OPENING;
2308 gsm_command(gsm, dlci->addr, SABM|PF);
2311 dlci->state = DLCI_CONFIGURE;
2312 if (gsm_dlci_negotiate(dlci) != 0) {
2313 gsm_dlci_close(dlci);
2317 mod_timer(&dlci->t1, jiffies + gsm->t1 * HZ / 100);
2326 * @dlci: DLCI to open
2331 static void gsm_dlci_set_opening(struct gsm_dlci *dlci)
2333 switch (dlci->state) {
2337 dlci->state = DLCI_OPENING;
2346 * @dlci: DLCI to configure
2350 static void gsm_dlci_set_wait_config(struct gsm_dlci *dlci)
2352 switch (dlci->state) {
2355 dlci->state = DLCI_WAITING_CONFIG;
2364 * @dlci: DLCI to open
2373 static void gsm_dlci_begin_close(struct gsm_dlci *dlci)
2375 struct gsm_mux *gsm = dlci->gsm;
2376 if (dlci->state == DLCI_CLOSED || dlci->state == DLCI_CLOSING)
2378 dlci->retries = gsm->n2;
2379 dlci->state = DLCI_CLOSING;
2380 gsm_command(dlci->gsm, dlci->addr, DISC|PF);
2381 mod_timer(&dlci->t1, jiffies + gsm->t1 * HZ / 100);
2387 * @dlci: channel
2396 static void gsm_dlci_data(struct gsm_dlci *dlci, const u8 *data, int clen)
2399 struct tty_port *port = &dlci->port;
2406 switch (dlci->adaption) {
2418 gsm_process_modem(tty, dlci, modem, len);
2435 * @dlci: channel
2445 static void gsm_dlci_command(struct gsm_dlci *dlci, const u8 *data, int len)
2464 dlci->gsm->malformed++;
2469 gsm_control_message(dlci->gsm, command, data, clen);
2471 gsm_control_response(dlci->gsm, command, data, clen);
2500 * @dlci: source DLCI
2503 static void gsm_dlci_copy_config_values(struct gsm_dlci *dlci, struct gsm_dlci_config *dc)
2506 dc->channel = (u32)dlci->addr;
2507 dc->adaption = (u32)dlci->adaption;
2508 dc->mtu = (u32)dlci->mtu;
2509 dc->priority = (u32)dlci->prio;
2510 if (dlci->ftype == UIH)
2514 dc->k = (u32)dlci->k;
2519 * @dlci: DLCI to configure
2523 static int gsm_dlci_config(struct gsm_dlci *dlci, struct gsm_dlci_config *dc, int open)
2538 if (!dlci)
2540 gsm = dlci->gsm;
2560 if (dc->adaption != dlci->adaption)
2562 if (dc->mtu != dlci->mtu)
2564 if (dc->i != dlci->ftype)
2567 if (dc->priority != dlci->prio)
2574 if (dlci->state == DLCI_WAITING_CONFIG) {
2584 gsm_dlci_begin_close(dlci);
2585 wait_event_interruptible(gsm->event, dlci->state == DLCI_CLOSED);
2592 dlci->adaption = (int)dc->adaption;
2595 dlci->mtu = (unsigned int)dc->mtu;
2597 dlci->mtu = gsm->mtu;
2600 dlci->prio = (u8)dc->priority;
2602 dlci->prio = roundup(dlci->addr + 1, 8) - 1;
2605 dlci->ftype = UIH;
2607 dlci->ftype = UI;
2610 dlci->k = (u8)dc->k;
2612 dlci->k = gsm->k;
2616 gsm_dlci_begin_open(dlci);
2618 gsm_dlci_set_opening(dlci);
2640 struct gsm_dlci *dlci = kzalloc(sizeof(struct gsm_dlci), GFP_ATOMIC);
2641 if (dlci == NULL)
2643 spin_lock_init(&dlci->lock);
2644 mutex_init(&dlci->mutex);
2645 if (kfifo_alloc(&dlci->fifo, TX_SIZE, GFP_KERNEL) < 0) {
2646 kfree(dlci);
2650 skb_queue_head_init(&dlci->skb_list);
2651 timer_setup(&dlci->t1, gsm_dlci_t1, 0);
2652 tty_port_init(&dlci->port);
2653 dlci->port.ops = &gsm_port_ops;
2654 dlci->gsm = gsm;
2655 dlci->addr = addr;
2656 dlci->adaption = gsm->adaption;
2657 dlci->mtu = gsm->mtu;
2659 dlci->prio = 0;
2661 dlci->prio = roundup(addr + 1, 8) - 1;
2662 dlci->ftype = gsm->ftype;
2663 dlci->k = gsm->k;
2664 dlci->state = DLCI_CLOSED;
2666 dlci->data = gsm_dlci_data;
2668 dlci->constipated = true;
2670 dlci->data = gsm_dlci_command;
2672 gsm->dlci[addr] = dlci;
2673 return dlci;
2686 struct gsm_dlci *dlci = container_of(port, struct gsm_dlci, port);
2688 timer_shutdown_sync(&dlci->t1);
2689 dlci->gsm->dlci[dlci->addr] = NULL;
2690 kfifo_free(&dlci->fifo);
2691 while ((dlci->skb = skb_dequeue(&dlci->skb_list)))
2692 dev_kfree_skb(dlci->skb);
2693 kfree(dlci);
2696 static inline void dlci_get(struct gsm_dlci *dlci)
2698 tty_port_get(&dlci->port);
2701 static inline void dlci_put(struct gsm_dlci *dlci)
2703 tty_port_put(&dlci->port);
2706 static void gsm_destroy_network(struct gsm_dlci *dlci);
2710 * @dlci: DLCI to destroy
2717 static void gsm_dlci_release(struct gsm_dlci *dlci)
2719 struct tty_struct *tty = tty_port_tty_get(&dlci->port);
2721 mutex_lock(&dlci->mutex);
2722 gsm_destroy_network(dlci);
2723 mutex_unlock(&dlci->mutex);
2732 tty_port_tty_set(&dlci->port, NULL);
2735 dlci->state = DLCI_CLOSED;
2736 dlci_put(dlci);
2755 struct gsm_dlci *dlci;
2774 dlci = gsm->dlci[address];
2782 if (dlci == NULL)
2783 dlci = gsm_dlci_alloc(gsm, address);
2784 if (dlci == NULL) {
2788 if (dlci->dead)
2792 gsm_dlci_open(dlci);
2798 if (dlci == NULL || dlci->state == DLCI_CLOSED) {
2804 gsm_dlci_close(dlci);
2807 if (cr == 0 || dlci == NULL)
2809 switch (dlci->state) {
2811 gsm_dlci_close(dlci);
2814 gsm_dlci_open(dlci);
2818 dlci->state);
2826 if (dlci == NULL)
2828 gsm_dlci_close(dlci);
2834 if (dlci == NULL || dlci->state != DLCI_OPEN) {
2838 dlci->data(dlci, gsm->buf, gsm->len);
3071 struct gsm_dlci *dlci;
3077 dlci = gsm->dlci[0];
3078 if (dlci) {
3079 if (disc && dlci->state != DLCI_CLOSED) {
3080 gsm_dlci_begin_close(dlci);
3081 wait_event(gsm->event, dlci->state == DLCI_CLOSED);
3083 dlci->dead = true;
3100 if (gsm->dlci[i])
3101 gsm_dlci_release(gsm->dlci[i]);
3124 struct gsm_dlci *dlci;
3127 dlci = gsm_dlci_alloc(gsm, 0);
3128 if (dlci == NULL)
3385 gsm_dlci_begin_open(gsm->dlci[0]);
3436 gsm_dlci_begin_open(gsm->dlci[0]);
3470 if (!gsm || !gsm->dlci[0] || gsm->dlci[0]->dead)
3500 if (gsm->dlci[i])
3501 tty_port_tty_wakeup(&gsm->dlci[i]->port);
3773 struct gsm_dlci *dlci;
3803 dlci = gsm->dlci[addr];
3804 if (!dlci) {
3805 dlci = gsm_dlci_alloc(gsm, addr);
3806 if (!dlci)
3809 gsm_dlci_copy_config_values(dlci, &dc);
3819 dlci = gsm->dlci[addr];
3820 if (!dlci) {
3821 dlci = gsm_dlci_alloc(gsm, addr);
3822 if (!dlci)
3825 return gsm_dlci_config(dlci, &dc, 0);
3849 static void dlci_net_free(struct gsm_dlci *dlci)
3851 if (!dlci->net) {
3855 dlci->adaption = dlci->prev_adaption;
3856 dlci->data = dlci->prev_data;
3857 free_netdev(dlci->net);
3858 dlci->net = NULL;
3863 struct gsm_dlci *dlci;
3866 dlci = mux_net->dlci;
3868 if (dlci->net) {
3869 unregister_netdev(dlci->net);
3870 dlci_net_free(dlci);
3888 struct gsm_dlci *dlci = mux_net->dlci;
3891 skb_queue_head(&dlci->skb_list, skb);
3894 gsm_dlci_data_kick(dlci);
3911 static void gsm_mux_rx_netchar(struct gsm_dlci *dlci,
3914 struct net_device *net = dlci->net;
3962 /* caller holds the dlci mutex */
3963 static void gsm_destroy_network(struct gsm_dlci *dlci)
3968 if (!dlci->net)
3970 mux_net = netdev_priv(dlci->net);
3975 /* caller holds the dlci mutex */
3976 static int gsm_create_network(struct gsm_dlci *dlci, struct gsm_netconfig *nc)
3987 if (dlci->adaption > 2)
4007 net->mtu = dlci->mtu;
4009 net->max_mtu = dlci->mtu;
4011 mux_net->dlci = dlci;
4015 /* reconfigure dlci for network */
4016 dlci->prev_adaption = dlci->adaption;
4017 dlci->prev_data = dlci->data;
4018 dlci->adaption = nc->adaption;
4019 dlci->data = gsm_mux_rx_netchar;
4020 dlci->net = net;
4026 dlci_net_free(dlci);
4054 * @dlci: channel
4061 static void gsm_modem_upd_via_data(struct gsm_dlci *dlci, u8 brk)
4063 struct gsm_mux *gsm = dlci->gsm;
4066 if (dlci->state != DLCI_OPEN || dlci->adaption != 2)
4070 gsm_dlci_modem_output(gsm, dlci, brk);
4076 * @dlci: channel
4080 static int gsm_modem_upd_via_msc(struct gsm_dlci *dlci, u8 brk)
4086 if (dlci->gsm->encoding != GSM_BASIC_OPT)
4089 modembits[0] = (dlci->addr << 2) | 2 | EA; /* DLCI, Valid, EA */
4091 modembits[1] = (gsm_encode_modem(dlci) << 1) | EA;
4093 modembits[1] = gsm_encode_modem(dlci) << 1;
4097 ctrl = gsm_control_send(dlci->gsm, CMD_MSC, modembits, len);
4100 return gsm_control_wait(dlci->gsm, ctrl);
4105 * @dlci: channel
4109 static int gsm_modem_update(struct gsm_dlci *dlci, u8 brk)
4111 if (dlci->gsm->dead)
4113 if (dlci->adaption == 2) {
4115 gsm_modem_upd_via_data(dlci, brk);
4117 } else if (dlci->gsm->encoding == GSM_BASIC_OPT) {
4119 return gsm_modem_upd_via_msc(dlci, brk);
4128 * @dlci: channel
4137 static int gsm_wait_modem_change(struct gsm_dlci *dlci, u32 mask)
4139 struct gsm_mux *gsm = dlci->gsm;
4140 u32 old = dlci->modem_rx;
4144 dlci->state != DLCI_OPEN ||
4145 (old ^ dlci->modem_rx) & mask);
4148 if (dlci->state != DLCI_OPEN)
4155 struct gsm_dlci *dlci = container_of(port, struct gsm_dlci, port);
4156 struct gsm_mux *gsm = dlci->gsm;
4159 if (dlci->state != DLCI_OPEN)
4169 gsm->dlci[0]->mode == DLCI_MODE_ADM && !dlci->modem_rx)
4172 return dlci->modem_rx & TIOCM_CD;
4177 struct gsm_dlci *dlci = container_of(port, struct gsm_dlci, port);
4178 unsigned int modem_tx = dlci->modem_tx;
4183 if (modem_tx != dlci->modem_tx) {
4184 dlci->modem_tx = modem_tx;
4185 gsm_modem_update(dlci, 0);
4198 struct gsm_dlci *dlci;
4221 if (gsm->dlci[0] && gsm->dlci[0]->state != DLCI_OPEN) {
4225 dlci = gsm->dlci[line];
4226 if (dlci == NULL) {
4228 dlci = gsm_dlci_alloc(gsm, line);
4230 if (dlci == NULL) {
4234 ret = tty_port_install(&dlci->port, driver, tty);
4237 dlci_put(dlci);
4242 dlci_get(dlci);
4243 dlci_get(gsm->dlci[0]);
4245 tty->driver_data = dlci;
4253 struct gsm_dlci *dlci = tty->driver_data;
4254 struct tty_port *port = &dlci->port;
4259 dlci->modem_rx = 0;
4264 if (!dlci->gsm->wait_config) {
4266 if (dlci->gsm->initiator)
4267 gsm_dlci_begin_open(dlci);
4269 gsm_dlci_set_opening(dlci);
4271 gsm_dlci_set_wait_config(dlci);
4279 struct gsm_dlci *dlci = tty->driver_data;
4281 if (dlci == NULL)
4283 if (dlci->state == DLCI_CLOSED)
4285 mutex_lock(&dlci->mutex);
4286 gsm_destroy_network(dlci);
4287 mutex_unlock(&dlci->mutex);
4288 if (tty_port_close_start(&dlci->port, tty, filp) == 0)
4290 gsm_dlci_begin_close(dlci);
4291 if (tty_port_initialized(&dlci->port) && C_HUPCL(tty))
4292 tty_port_lower_dtr_rts(&dlci->port);
4293 tty_port_close_end(&dlci->port, tty);
4294 tty_port_tty_set(&dlci->port, NULL);
4300 struct gsm_dlci *dlci = tty->driver_data;
4301 if (dlci->state == DLCI_CLOSED)
4303 tty_port_hangup(&dlci->port);
4304 gsm_dlci_begin_close(dlci);
4310 struct gsm_dlci *dlci = tty->driver_data;
4311 if (dlci->state == DLCI_CLOSED)
4314 sent = kfifo_in_locked(&dlci->fifo, buf, len, &dlci->lock);
4316 gsm_dlci_data_kick(dlci);
4322 struct gsm_dlci *dlci = tty->driver_data;
4323 if (dlci->state == DLCI_CLOSED)
4325 return kfifo_avail(&dlci->fifo);
4330 struct gsm_dlci *dlci = tty->driver_data;
4331 if (dlci->state == DLCI_CLOSED)
4333 return kfifo_len(&dlci->fifo);
4338 struct gsm_dlci *dlci = tty->driver_data;
4341 if (dlci->state == DLCI_CLOSED)
4347 spin_lock_irqsave(&dlci->lock, flags);
4348 kfifo_reset(&dlci->fifo);
4349 spin_unlock_irqrestore(&dlci->lock, flags);
4362 struct gsm_dlci *dlci = tty->driver_data;
4363 if (dlci->state == DLCI_CLOSED)
4365 return dlci->modem_rx;
4371 struct gsm_dlci *dlci = tty->driver_data;
4372 unsigned int modem_tx = dlci->modem_tx;
4374 if (dlci->state == DLCI_CLOSED)
4379 if (modem_tx != dlci->modem_tx) {
4380 dlci->modem_tx = modem_tx;
4381 return gsm_modem_update(dlci, 0);
4390 struct gsm_dlci *dlci = tty->driver_data;
4395 if (dlci->state == DLCI_CLOSED)
4403 mutex_lock(&dlci->mutex);
4404 index = gsm_create_network(dlci, &nc);
4405 mutex_unlock(&dlci->mutex);
4412 mutex_lock(&dlci->mutex);
4413 gsm_destroy_network(dlci);
4414 mutex_unlock(&dlci->mutex);
4419 if (dc.channel != dlci->addr)
4421 gsm_dlci_copy_config_values(dlci, &dc);
4430 if (dc.channel != 0 && dc.channel != dlci->addr)
4432 return gsm_dlci_config(dlci, &dc, 1);
4434 return gsm_wait_modem_change(dlci, (u32)arg);
4443 struct gsm_dlci *dlci = tty->driver_data;
4444 if (dlci->state == DLCI_CLOSED)
4456 struct gsm_dlci *dlci = tty->driver_data;
4457 if (dlci->state == DLCI_CLOSED)
4460 dlci->modem_tx &= ~TIOCM_RTS;
4461 dlci->throttled = true;
4463 gsm_modem_update(dlci, 0);
4468 struct gsm_dlci *dlci = tty->driver_data;
4469 if (dlci->state == DLCI_CLOSED)
4472 dlci->modem_tx |= TIOCM_RTS;
4473 dlci->throttled = false;
4475 gsm_modem_update(dlci, 0);
4480 struct gsm_dlci *dlci = tty->driver_data;
4482 if (dlci->state == DLCI_CLOSED)
4493 return gsm_modem_update(dlci, encode);
4498 struct gsm_dlci *dlci = tty->driver_data;
4499 struct gsm_mux *gsm = dlci->gsm;
4501 dlci_put(dlci);
4502 dlci_put(gsm->dlci[0]);