Lines Matching refs:d
56 static int rfcomm_queue_disc(struct rfcomm_dlc *d);
58 static int rfcomm_send_pn(struct rfcomm_session *s, int cr, struct rfcomm_dlc *d);
208 static int rfcomm_check_security(struct rfcomm_dlc *d) in rfcomm_check_security() argument
210 struct sock *sk = d->session->sock->sk; in rfcomm_check_security()
215 switch (d->sec_level) { in rfcomm_check_security()
228 return hci_conn_security(conn->hcon, d->sec_level, auth_type, in rfcomm_check_security()
229 d->out); in rfcomm_check_security()
259 struct rfcomm_dlc *d = from_timer(d, t, timer); in rfcomm_dlc_timeout() local
261 BT_DBG("dlc %p state %ld", d, d->state); in rfcomm_dlc_timeout()
263 set_bit(RFCOMM_TIMED_OUT, &d->flags); in rfcomm_dlc_timeout()
264 rfcomm_dlc_put(d); in rfcomm_dlc_timeout()
268 static void rfcomm_dlc_set_timer(struct rfcomm_dlc *d, long timeout) in rfcomm_dlc_set_timer() argument
270 BT_DBG("dlc %p state %ld timeout %ld", d, d->state, timeout); in rfcomm_dlc_set_timer()
272 if (!mod_timer(&d->timer, jiffies + timeout)) in rfcomm_dlc_set_timer()
273 rfcomm_dlc_hold(d); in rfcomm_dlc_set_timer()
276 static void rfcomm_dlc_clear_timer(struct rfcomm_dlc *d) in rfcomm_dlc_clear_timer() argument
278 BT_DBG("dlc %p state %ld", d, d->state); in rfcomm_dlc_clear_timer()
280 if (del_timer(&d->timer)) in rfcomm_dlc_clear_timer()
281 rfcomm_dlc_put(d); in rfcomm_dlc_clear_timer()
284 static void rfcomm_dlc_clear_state(struct rfcomm_dlc *d) in rfcomm_dlc_clear_state() argument
286 BT_DBG("%p", d); in rfcomm_dlc_clear_state()
288 d->state = BT_OPEN; in rfcomm_dlc_clear_state()
289 d->flags = 0; in rfcomm_dlc_clear_state()
290 d->mscex = 0; in rfcomm_dlc_clear_state()
291 d->sec_level = BT_SECURITY_LOW; in rfcomm_dlc_clear_state()
292 d->mtu = RFCOMM_DEFAULT_MTU; in rfcomm_dlc_clear_state()
293 d->v24_sig = RFCOMM_V24_RTC | RFCOMM_V24_RTR | RFCOMM_V24_DV; in rfcomm_dlc_clear_state()
295 d->cfc = RFCOMM_CFC_DISABLED; in rfcomm_dlc_clear_state()
296 d->rx_credits = RFCOMM_DEFAULT_CREDITS; in rfcomm_dlc_clear_state()
301 struct rfcomm_dlc *d = kzalloc(sizeof(*d), prio); in rfcomm_dlc_alloc() local
303 if (!d) in rfcomm_dlc_alloc()
306 timer_setup(&d->timer, rfcomm_dlc_timeout, 0); in rfcomm_dlc_alloc()
308 skb_queue_head_init(&d->tx_queue); in rfcomm_dlc_alloc()
309 mutex_init(&d->lock); in rfcomm_dlc_alloc()
310 refcount_set(&d->refcnt, 1); in rfcomm_dlc_alloc()
312 rfcomm_dlc_clear_state(d); in rfcomm_dlc_alloc()
314 BT_DBG("%p", d); in rfcomm_dlc_alloc()
316 return d; in rfcomm_dlc_alloc()
319 void rfcomm_dlc_free(struct rfcomm_dlc *d) in rfcomm_dlc_free() argument
321 BT_DBG("%p", d); in rfcomm_dlc_free()
323 skb_queue_purge(&d->tx_queue); in rfcomm_dlc_free()
324 kfree(d); in rfcomm_dlc_free()
327 static void rfcomm_dlc_link(struct rfcomm_session *s, struct rfcomm_dlc *d) in rfcomm_dlc_link() argument
329 BT_DBG("dlc %p session %p", d, s); in rfcomm_dlc_link()
332 rfcomm_dlc_hold(d); in rfcomm_dlc_link()
333 list_add(&d->list, &s->dlcs); in rfcomm_dlc_link()
334 d->session = s; in rfcomm_dlc_link()
337 static void rfcomm_dlc_unlink(struct rfcomm_dlc *d) in rfcomm_dlc_unlink() argument
339 struct rfcomm_session *s = d->session; in rfcomm_dlc_unlink()
341 BT_DBG("dlc %p refcnt %d session %p", d, refcount_read(&d->refcnt), s); in rfcomm_dlc_unlink()
343 list_del(&d->list); in rfcomm_dlc_unlink()
344 d->session = NULL; in rfcomm_dlc_unlink()
345 rfcomm_dlc_put(d); in rfcomm_dlc_unlink()
353 struct rfcomm_dlc *d; in rfcomm_dlc_get() local
355 list_for_each_entry(d, &s->dlcs, list) in rfcomm_dlc_get()
356 if (d->dlci == dlci) in rfcomm_dlc_get()
357 return d; in rfcomm_dlc_get()
367 static int __rfcomm_dlc_open(struct rfcomm_dlc *d, bdaddr_t *src, bdaddr_t *dst, u8 channel) in __rfcomm_dlc_open() argument
374 d, d->state, src, dst, channel); in __rfcomm_dlc_open()
379 if (d->state != BT_OPEN && d->state != BT_CLOSED) in __rfcomm_dlc_open()
384 s = rfcomm_session_create(src, dst, d->sec_level, &err); in __rfcomm_dlc_open()
395 rfcomm_dlc_clear_state(d); in __rfcomm_dlc_open()
397 d->dlci = dlci; in __rfcomm_dlc_open()
398 d->addr = __addr(s->initiator, dlci); in __rfcomm_dlc_open()
399 d->priority = 7; in __rfcomm_dlc_open()
401 d->state = BT_CONFIG; in __rfcomm_dlc_open()
402 rfcomm_dlc_link(s, d); in __rfcomm_dlc_open()
404 d->out = 1; in __rfcomm_dlc_open()
406 d->mtu = s->mtu; in __rfcomm_dlc_open()
407 d->cfc = (s->cfc == RFCOMM_CFC_UNKNOWN) ? 0 : s->cfc; in __rfcomm_dlc_open()
410 if (rfcomm_check_security(d)) in __rfcomm_dlc_open()
411 rfcomm_send_pn(s, 1, d); in __rfcomm_dlc_open()
413 set_bit(RFCOMM_AUTH_PENDING, &d->flags); in __rfcomm_dlc_open()
416 rfcomm_dlc_set_timer(d, RFCOMM_CONN_TIMEOUT); in __rfcomm_dlc_open()
421 int rfcomm_dlc_open(struct rfcomm_dlc *d, bdaddr_t *src, bdaddr_t *dst, u8 channel) in rfcomm_dlc_open() argument
427 r = __rfcomm_dlc_open(d, src, dst, channel); in rfcomm_dlc_open()
433 static void __rfcomm_dlc_disconn(struct rfcomm_dlc *d) in __rfcomm_dlc_disconn() argument
435 struct rfcomm_session *s = d->session; in __rfcomm_dlc_disconn()
437 d->state = BT_DISCONN; in __rfcomm_dlc_disconn()
438 if (skb_queue_empty(&d->tx_queue)) { in __rfcomm_dlc_disconn()
439 rfcomm_send_disc(s, d->dlci); in __rfcomm_dlc_disconn()
440 rfcomm_dlc_set_timer(d, RFCOMM_DISC_TIMEOUT); in __rfcomm_dlc_disconn()
442 rfcomm_queue_disc(d); in __rfcomm_dlc_disconn()
443 rfcomm_dlc_set_timer(d, RFCOMM_DISC_TIMEOUT * 2); in __rfcomm_dlc_disconn()
447 static int __rfcomm_dlc_close(struct rfcomm_dlc *d, int err) in __rfcomm_dlc_close() argument
449 struct rfcomm_session *s = d->session; in __rfcomm_dlc_close()
454 d, d->state, d->dlci, err, s); in __rfcomm_dlc_close()
456 switch (d->state) { in __rfcomm_dlc_close()
461 if (test_and_clear_bit(RFCOMM_DEFER_SETUP, &d->flags)) { in __rfcomm_dlc_close()
462 set_bit(RFCOMM_AUTH_REJECT, &d->flags); in __rfcomm_dlc_close()
468 switch (d->state) { in __rfcomm_dlc_close()
471 __rfcomm_dlc_disconn(d); in __rfcomm_dlc_close()
476 __rfcomm_dlc_disconn(d); in __rfcomm_dlc_close()
485 rfcomm_dlc_clear_timer(d); in __rfcomm_dlc_close()
487 rfcomm_dlc_lock(d); in __rfcomm_dlc_close()
488 d->state = BT_CLOSED; in __rfcomm_dlc_close()
489 d->state_change(d, err); in __rfcomm_dlc_close()
490 rfcomm_dlc_unlock(d); in __rfcomm_dlc_close()
492 skb_queue_purge(&d->tx_queue); in __rfcomm_dlc_close()
493 rfcomm_dlc_unlink(d); in __rfcomm_dlc_close()
499 int rfcomm_dlc_close(struct rfcomm_dlc *d, int err) in rfcomm_dlc_close() argument
505 BT_DBG("dlc %p state %ld dlci %d err %d", d, d->state, d->dlci, err); in rfcomm_dlc_close()
509 s = d->session; in rfcomm_dlc_close()
519 if (d_list == d) { in rfcomm_dlc_close()
520 r = __rfcomm_dlc_close(d, err); in rfcomm_dlc_close()
552 static int rfcomm_dlc_send_frag(struct rfcomm_dlc *d, struct sk_buff *frag) in rfcomm_dlc_send_frag() argument
556 BT_DBG("dlc %p mtu %d len %d", d, d->mtu, len); in rfcomm_dlc_send_frag()
558 if (len > d->mtu) in rfcomm_dlc_send_frag()
561 rfcomm_make_uih(frag, d->addr); in rfcomm_dlc_send_frag()
562 __skb_queue_tail(&d->tx_queue, frag); in rfcomm_dlc_send_frag()
567 int rfcomm_dlc_send(struct rfcomm_dlc *d, struct sk_buff *skb) in rfcomm_dlc_send() argument
573 if (d->state != BT_CONNECTED) in rfcomm_dlc_send()
580 spin_lock_irqsave(&d->tx_queue.lock, flags); in rfcomm_dlc_send()
582 len = rfcomm_dlc_send_frag(d, skb); in rfcomm_dlc_send()
591 ret = rfcomm_dlc_send_frag(d, frag); in rfcomm_dlc_send()
601 spin_unlock_irqrestore(&d->tx_queue.lock, flags); in rfcomm_dlc_send()
603 if (len > 0 && !test_bit(RFCOMM_TX_THROTTLED, &d->flags)) in rfcomm_dlc_send()
608 void rfcomm_dlc_send_noerror(struct rfcomm_dlc *d, struct sk_buff *skb) in rfcomm_dlc_send_noerror() argument
612 BT_DBG("dlc %p mtu %d len %d", d, d->mtu, len); in rfcomm_dlc_send_noerror()
614 rfcomm_make_uih(skb, d->addr); in rfcomm_dlc_send_noerror()
615 skb_queue_tail(&d->tx_queue, skb); in rfcomm_dlc_send_noerror()
617 if (d->state == BT_CONNECTED && in rfcomm_dlc_send_noerror()
618 !test_bit(RFCOMM_TX_THROTTLED, &d->flags)) in rfcomm_dlc_send_noerror()
622 void __rfcomm_dlc_throttle(struct rfcomm_dlc *d) in __rfcomm_dlc_throttle() argument
624 BT_DBG("dlc %p state %ld", d, d->state); in __rfcomm_dlc_throttle()
626 if (!d->cfc) { in __rfcomm_dlc_throttle()
627 d->v24_sig |= RFCOMM_V24_FC; in __rfcomm_dlc_throttle()
628 set_bit(RFCOMM_MSC_PENDING, &d->flags); in __rfcomm_dlc_throttle()
633 void __rfcomm_dlc_unthrottle(struct rfcomm_dlc *d) in __rfcomm_dlc_unthrottle() argument
635 BT_DBG("dlc %p state %ld", d, d->state); in __rfcomm_dlc_unthrottle()
637 if (!d->cfc) { in __rfcomm_dlc_unthrottle()
638 d->v24_sig &= ~RFCOMM_V24_FC; in __rfcomm_dlc_unthrottle()
639 set_bit(RFCOMM_MSC_PENDING, &d->flags); in __rfcomm_dlc_unthrottle()
649 int rfcomm_dlc_set_modem_status(struct rfcomm_dlc *d, u8 v24_sig) in rfcomm_dlc_set_modem_status() argument
652 d, d->state, v24_sig); in rfcomm_dlc_set_modem_status()
654 if (test_bit(RFCOMM_RX_THROTTLED, &d->flags)) in rfcomm_dlc_set_modem_status()
659 d->v24_sig = v24_sig; in rfcomm_dlc_set_modem_status()
661 if (!test_and_set_bit(RFCOMM_MSC_PENDING, &d->flags)) in rfcomm_dlc_set_modem_status()
667 int rfcomm_dlc_get_modem_status(struct rfcomm_dlc *d, u8 *v24_sig) in rfcomm_dlc_get_modem_status() argument
670 d, d->state, d->v24_sig); in rfcomm_dlc_get_modem_status()
672 *v24_sig = d->v24_sig; in rfcomm_dlc_get_modem_status()
743 struct rfcomm_dlc *d, *n; in rfcomm_session_close() local
750 list_for_each_entry_safe(d, n, &s->dlcs, list) { in rfcomm_session_close()
751 d->state = BT_CLOSED; in rfcomm_session_close()
752 __rfcomm_dlc_close(d, err); in rfcomm_session_close()
889 static int rfcomm_queue_disc(struct rfcomm_dlc *d) in rfcomm_queue_disc() argument
894 BT_DBG("dlc %p dlci %d", d, d->dlci); in rfcomm_queue_disc()
901 cmd->addr = d->addr; in rfcomm_queue_disc()
906 skb_queue_tail(&d->tx_queue, skb); in rfcomm_queue_disc()
950 static int rfcomm_send_pn(struct rfcomm_session *s, int cr, struct rfcomm_dlc *d) in rfcomm_send_pn() argument
957 BT_DBG("%p cr %d dlci %d mtu %d", s, cr, d->dlci, d->mtu); in rfcomm_send_pn()
969 pn->dlci = d->dlci; in rfcomm_send_pn()
970 pn->priority = d->priority; in rfcomm_send_pn()
985 pn->mtu = cpu_to_le16(d->mtu); in rfcomm_send_pn()
1206 struct rfcomm_dlc *d = rfcomm_dlc_get(s, dlci); in rfcomm_recv_ua() local
1207 if (!d) { in rfcomm_recv_ua()
1212 switch (d->state) { in rfcomm_recv_ua()
1214 rfcomm_dlc_clear_timer(d); in rfcomm_recv_ua()
1216 rfcomm_dlc_lock(d); in rfcomm_recv_ua()
1217 d->state = BT_CONNECTED; in rfcomm_recv_ua()
1218 d->state_change(d, 0); in rfcomm_recv_ua()
1219 rfcomm_dlc_unlock(d); in rfcomm_recv_ua()
1221 rfcomm_send_msc(s, 1, dlci, d->v24_sig); in rfcomm_recv_ua()
1225 d->state = BT_CLOSED; in rfcomm_recv_ua()
1226 __rfcomm_dlc_close(d, 0); in rfcomm_recv_ua()
1260 struct rfcomm_dlc *d = rfcomm_dlc_get(s, dlci); in rfcomm_recv_dm() local
1261 if (d) { in rfcomm_recv_dm()
1262 if (d->state == BT_CONNECT || d->state == BT_CONFIG) in rfcomm_recv_dm()
1267 d->state = BT_CLOSED; in rfcomm_recv_dm()
1268 __rfcomm_dlc_close(d, err); in rfcomm_recv_dm()
1289 struct rfcomm_dlc *d = rfcomm_dlc_get(s, dlci); in rfcomm_recv_disc() local
1290 if (d) { in rfcomm_recv_disc()
1293 if (d->state == BT_CONNECT || d->state == BT_CONFIG) in rfcomm_recv_disc()
1298 d->state = BT_CLOSED; in rfcomm_recv_disc()
1299 __rfcomm_dlc_close(d, err); in rfcomm_recv_disc()
1316 void rfcomm_dlc_accept(struct rfcomm_dlc *d) in rfcomm_dlc_accept() argument
1318 struct sock *sk = d->session->sock->sk; in rfcomm_dlc_accept()
1321 BT_DBG("dlc %p", d); in rfcomm_dlc_accept()
1323 rfcomm_send_ua(d->session, d->dlci); in rfcomm_dlc_accept()
1325 rfcomm_dlc_clear_timer(d); in rfcomm_dlc_accept()
1327 rfcomm_dlc_lock(d); in rfcomm_dlc_accept()
1328 d->state = BT_CONNECTED; in rfcomm_dlc_accept()
1329 d->state_change(d, 0); in rfcomm_dlc_accept()
1330 rfcomm_dlc_unlock(d); in rfcomm_dlc_accept()
1332 if (d->role_switch) in rfcomm_dlc_accept()
1335 rfcomm_send_msc(d->session, 1, d->dlci, d->v24_sig); in rfcomm_dlc_accept()
1338 static void rfcomm_check_accept(struct rfcomm_dlc *d) in rfcomm_check_accept() argument
1340 if (rfcomm_check_security(d)) { in rfcomm_check_accept()
1341 if (d->defer_setup) { in rfcomm_check_accept()
1342 set_bit(RFCOMM_DEFER_SETUP, &d->flags); in rfcomm_check_accept()
1343 rfcomm_dlc_set_timer(d, RFCOMM_AUTH_TIMEOUT); in rfcomm_check_accept()
1345 rfcomm_dlc_lock(d); in rfcomm_check_accept()
1346 d->state = BT_CONNECT2; in rfcomm_check_accept()
1347 d->state_change(d, 0); in rfcomm_check_accept()
1348 rfcomm_dlc_unlock(d); in rfcomm_check_accept()
1350 rfcomm_dlc_accept(d); in rfcomm_check_accept()
1352 set_bit(RFCOMM_AUTH_PENDING, &d->flags); in rfcomm_check_accept()
1353 rfcomm_dlc_set_timer(d, RFCOMM_AUTH_TIMEOUT); in rfcomm_check_accept()
1359 struct rfcomm_dlc *d; in rfcomm_recv_sabm() local
1375 d = rfcomm_dlc_get(s, dlci); in rfcomm_recv_sabm()
1376 if (d) { in rfcomm_recv_sabm()
1377 if (d->state == BT_OPEN) { in rfcomm_recv_sabm()
1379 rfcomm_check_accept(d); in rfcomm_recv_sabm()
1386 if (rfcomm_connect_ind(s, channel, &d)) { in rfcomm_recv_sabm()
1387 d->dlci = dlci; in rfcomm_recv_sabm()
1388 d->addr = __addr(s->initiator, dlci); in rfcomm_recv_sabm()
1389 rfcomm_dlc_link(s, d); in rfcomm_recv_sabm()
1391 rfcomm_check_accept(d); in rfcomm_recv_sabm()
1399 static int rfcomm_apply_pn(struct rfcomm_dlc *d, int cr, struct rfcomm_pn *pn) in rfcomm_apply_pn() argument
1401 struct rfcomm_session *s = d->session; in rfcomm_apply_pn()
1404 d, d->state, d->dlci, pn->mtu, pn->flow_ctrl, pn->credits); in rfcomm_apply_pn()
1408 d->cfc = RFCOMM_CFC_ENABLED; in rfcomm_apply_pn()
1409 d->tx_credits = pn->credits; in rfcomm_apply_pn()
1411 d->cfc = RFCOMM_CFC_DISABLED; in rfcomm_apply_pn()
1412 set_bit(RFCOMM_TX_THROTTLED, &d->flags); in rfcomm_apply_pn()
1416 s->cfc = d->cfc; in rfcomm_apply_pn()
1418 d->priority = pn->priority; in rfcomm_apply_pn()
1420 d->mtu = __le16_to_cpu(pn->mtu); in rfcomm_apply_pn()
1422 if (cr && d->mtu > s->mtu) in rfcomm_apply_pn()
1423 d->mtu = s->mtu; in rfcomm_apply_pn()
1431 struct rfcomm_dlc *d; in rfcomm_recv_pn() local
1439 d = rfcomm_dlc_get(s, dlci); in rfcomm_recv_pn()
1440 if (d) { in rfcomm_recv_pn()
1443 rfcomm_apply_pn(d, cr, pn); in rfcomm_recv_pn()
1444 rfcomm_send_pn(s, 0, d); in rfcomm_recv_pn()
1447 switch (d->state) { in rfcomm_recv_pn()
1449 rfcomm_apply_pn(d, cr, pn); in rfcomm_recv_pn()
1451 d->state = BT_CONNECT; in rfcomm_recv_pn()
1452 rfcomm_send_sabm(s, d->dlci); in rfcomm_recv_pn()
1464 if (rfcomm_connect_ind(s, channel, &d)) { in rfcomm_recv_pn()
1465 d->dlci = dlci; in rfcomm_recv_pn()
1466 d->addr = __addr(s->initiator, dlci); in rfcomm_recv_pn()
1467 rfcomm_dlc_link(s, d); in rfcomm_recv_pn()
1469 rfcomm_apply_pn(d, cr, pn); in rfcomm_recv_pn()
1471 d->state = BT_OPEN; in rfcomm_recv_pn()
1472 rfcomm_send_pn(s, 0, d); in rfcomm_recv_pn()
1608 struct rfcomm_dlc *d; in rfcomm_recv_msc() local
1613 d = rfcomm_dlc_get(s, dlci); in rfcomm_recv_msc()
1614 if (!d) in rfcomm_recv_msc()
1618 if (msc->v24_sig & RFCOMM_V24_FC && !d->cfc) in rfcomm_recv_msc()
1619 set_bit(RFCOMM_TX_THROTTLED, &d->flags); in rfcomm_recv_msc()
1621 clear_bit(RFCOMM_TX_THROTTLED, &d->flags); in rfcomm_recv_msc()
1623 rfcomm_dlc_lock(d); in rfcomm_recv_msc()
1625 d->remote_v24_sig = msc->v24_sig; in rfcomm_recv_msc()
1627 if (d->modem_status) in rfcomm_recv_msc()
1628 d->modem_status(d, msc->v24_sig); in rfcomm_recv_msc()
1630 rfcomm_dlc_unlock(d); in rfcomm_recv_msc()
1634 d->mscex |= RFCOMM_MSCEX_RX; in rfcomm_recv_msc()
1636 d->mscex |= RFCOMM_MSCEX_TX; in rfcomm_recv_msc()
1703 struct rfcomm_dlc *d; in rfcomm_recv_data() local
1707 d = rfcomm_dlc_get(s, dlci); in rfcomm_recv_data()
1708 if (!d) { in rfcomm_recv_data()
1713 if (pf && d->cfc) { in rfcomm_recv_data()
1716 d->tx_credits += credits; in rfcomm_recv_data()
1717 if (d->tx_credits) in rfcomm_recv_data()
1718 clear_bit(RFCOMM_TX_THROTTLED, &d->flags); in rfcomm_recv_data()
1721 if (skb->len && d->state == BT_CONNECTED) { in rfcomm_recv_data()
1722 rfcomm_dlc_lock(d); in rfcomm_recv_data()
1723 d->rx_credits--; in rfcomm_recv_data()
1724 d->data_ready(d, skb); in rfcomm_recv_data()
1725 rfcomm_dlc_unlock(d); in rfcomm_recv_data()
1804 struct rfcomm_dlc *d, *n; in rfcomm_process_connect() local
1808 list_for_each_entry_safe(d, n, &s->dlcs, list) { in rfcomm_process_connect()
1809 if (d->state == BT_CONFIG) { in rfcomm_process_connect()
1810 d->mtu = s->mtu; in rfcomm_process_connect()
1811 if (rfcomm_check_security(d)) { in rfcomm_process_connect()
1812 rfcomm_send_pn(s, 1, d); in rfcomm_process_connect()
1814 set_bit(RFCOMM_AUTH_PENDING, &d->flags); in rfcomm_process_connect()
1815 rfcomm_dlc_set_timer(d, RFCOMM_AUTH_TIMEOUT); in rfcomm_process_connect()
1824 static int rfcomm_process_tx(struct rfcomm_dlc *d) in rfcomm_process_tx() argument
1830 d, d->state, d->cfc, d->rx_credits, d->tx_credits); in rfcomm_process_tx()
1833 if (test_and_clear_bit(RFCOMM_MSC_PENDING, &d->flags)) in rfcomm_process_tx()
1834 rfcomm_send_msc(d->session, 1, d->dlci, d->v24_sig); in rfcomm_process_tx()
1836 if (d->cfc) { in rfcomm_process_tx()
1839 if (!test_bit(RFCOMM_RX_THROTTLED, &d->flags) && in rfcomm_process_tx()
1840 d->rx_credits <= (d->cfc >> 2)) { in rfcomm_process_tx()
1841 rfcomm_send_credits(d->session, d->addr, d->cfc - d->rx_credits); in rfcomm_process_tx()
1842 d->rx_credits = d->cfc; in rfcomm_process_tx()
1847 d->tx_credits = 5; in rfcomm_process_tx()
1850 if (test_bit(RFCOMM_TX_THROTTLED, &d->flags)) in rfcomm_process_tx()
1851 return skb_queue_len(&d->tx_queue); in rfcomm_process_tx()
1853 while (d->tx_credits && (skb = skb_dequeue(&d->tx_queue))) { in rfcomm_process_tx()
1854 err = rfcomm_send_frame(d->session, skb->data, skb->len); in rfcomm_process_tx()
1856 skb_queue_head(&d->tx_queue, skb); in rfcomm_process_tx()
1860 d->tx_credits--; in rfcomm_process_tx()
1863 if (d->cfc && !d->tx_credits) { in rfcomm_process_tx()
1866 set_bit(RFCOMM_TX_THROTTLED, &d->flags); in rfcomm_process_tx()
1869 return skb_queue_len(&d->tx_queue); in rfcomm_process_tx()
1874 struct rfcomm_dlc *d, *n; in rfcomm_process_dlcs() local
1878 list_for_each_entry_safe(d, n, &s->dlcs, list) { in rfcomm_process_dlcs()
1879 if (test_bit(RFCOMM_TIMED_OUT, &d->flags)) { in rfcomm_process_dlcs()
1880 __rfcomm_dlc_close(d, ETIMEDOUT); in rfcomm_process_dlcs()
1884 if (test_bit(RFCOMM_ENC_DROP, &d->flags)) { in rfcomm_process_dlcs()
1885 __rfcomm_dlc_close(d, ECONNREFUSED); in rfcomm_process_dlcs()
1889 if (test_and_clear_bit(RFCOMM_AUTH_ACCEPT, &d->flags)) { in rfcomm_process_dlcs()
1890 rfcomm_dlc_clear_timer(d); in rfcomm_process_dlcs()
1891 if (d->out) { in rfcomm_process_dlcs()
1892 rfcomm_send_pn(s, 1, d); in rfcomm_process_dlcs()
1893 rfcomm_dlc_set_timer(d, RFCOMM_CONN_TIMEOUT); in rfcomm_process_dlcs()
1895 if (d->defer_setup) { in rfcomm_process_dlcs()
1896 set_bit(RFCOMM_DEFER_SETUP, &d->flags); in rfcomm_process_dlcs()
1897 rfcomm_dlc_set_timer(d, RFCOMM_AUTH_TIMEOUT); in rfcomm_process_dlcs()
1899 rfcomm_dlc_lock(d); in rfcomm_process_dlcs()
1900 d->state = BT_CONNECT2; in rfcomm_process_dlcs()
1901 d->state_change(d, 0); in rfcomm_process_dlcs()
1902 rfcomm_dlc_unlock(d); in rfcomm_process_dlcs()
1904 rfcomm_dlc_accept(d); in rfcomm_process_dlcs()
1907 } else if (test_and_clear_bit(RFCOMM_AUTH_REJECT, &d->flags)) { in rfcomm_process_dlcs()
1908 rfcomm_dlc_clear_timer(d); in rfcomm_process_dlcs()
1909 if (!d->out) in rfcomm_process_dlcs()
1910 rfcomm_send_dm(s, d->dlci); in rfcomm_process_dlcs()
1912 d->state = BT_CLOSED; in rfcomm_process_dlcs()
1913 __rfcomm_dlc_close(d, ECONNREFUSED); in rfcomm_process_dlcs()
1917 if (test_bit(RFCOMM_SEC_PENDING, &d->flags)) in rfcomm_process_dlcs()
1923 if ((d->state == BT_CONNECTED || d->state == BT_DISCONN) && in rfcomm_process_dlcs()
1924 d->mscex == RFCOMM_MSCEX_OK) in rfcomm_process_dlcs()
1925 rfcomm_process_tx(d); in rfcomm_process_dlcs()
2136 struct rfcomm_dlc *d, *n; in rfcomm_security_cfm() local
2144 list_for_each_entry_safe(d, n, &s->dlcs, list) { in rfcomm_security_cfm()
2145 if (test_and_clear_bit(RFCOMM_SEC_PENDING, &d->flags)) { in rfcomm_security_cfm()
2146 rfcomm_dlc_clear_timer(d); in rfcomm_security_cfm()
2148 set_bit(RFCOMM_ENC_DROP, &d->flags); in rfcomm_security_cfm()
2153 if (d->state == BT_CONNECTED && !status && encrypt == 0x00) { in rfcomm_security_cfm()
2154 if (d->sec_level == BT_SECURITY_MEDIUM) { in rfcomm_security_cfm()
2155 set_bit(RFCOMM_SEC_PENDING, &d->flags); in rfcomm_security_cfm()
2156 rfcomm_dlc_set_timer(d, RFCOMM_AUTH_TIMEOUT); in rfcomm_security_cfm()
2158 } else if (d->sec_level == BT_SECURITY_HIGH || in rfcomm_security_cfm()
2159 d->sec_level == BT_SECURITY_FIPS) { in rfcomm_security_cfm()
2160 set_bit(RFCOMM_ENC_DROP, &d->flags); in rfcomm_security_cfm()
2165 if (!test_and_clear_bit(RFCOMM_AUTH_PENDING, &d->flags)) in rfcomm_security_cfm()
2168 if (!status && hci_conn_check_secure(conn, d->sec_level)) in rfcomm_security_cfm()
2169 set_bit(RFCOMM_AUTH_ACCEPT, &d->flags); in rfcomm_security_cfm()
2171 set_bit(RFCOMM_AUTH_REJECT, &d->flags); in rfcomm_security_cfm()
2190 struct rfcomm_dlc *d; in rfcomm_dlc_debugfs_show() local
2191 list_for_each_entry(d, &s->dlcs, list) { in rfcomm_dlc_debugfs_show()
2194 d->state, d->dlci, d->mtu, in rfcomm_dlc_debugfs_show()
2195 d->rx_credits, d->tx_credits); in rfcomm_dlc_debugfs_show()