Commit 1a6fe614 authored by Maksim Krasnyanskiy's avatar Maksim Krasnyanskiy

[Bluetooth] RFCOMM must wait for MSC exchange to complete before sending data.

parent ca619c62
...@@ -186,10 +186,10 @@ struct rfcomm_dlc { ...@@ -186,10 +186,10 @@ struct rfcomm_dlc {
u8 dlci; u8 dlci;
u8 addr; u8 addr;
u8 priority; u8 priority;
uint mtu;
u8 v24_sig; u8 v24_sig;
u8 mscex;
uint mtu;
uint credits; uint credits;
uint rx_credits; uint rx_credits;
uint tx_credits; uint tx_credits;
...@@ -214,6 +214,11 @@ struct rfcomm_dlc { ...@@ -214,6 +214,11 @@ struct rfcomm_dlc {
#define RFCOMM_SCHED_TIMEO 3 #define RFCOMM_SCHED_TIMEO 3
#define RFCOMM_SCHED_WAKEUP 31 #define RFCOMM_SCHED_WAKEUP 31
/* MSC exchange flags */
#define RFCOMM_MSCEX_TX 1
#define RFCOMM_MSCEX_RX 2
#define RFCOMM_MSCEX_OK (RFCOMM_MSCEX_TX + RFCOMM_MSCEX_RX)
extern struct task_struct *rfcomm_thread; extern struct task_struct *rfcomm_thread;
extern unsigned long rfcomm_event; extern unsigned long rfcomm_event;
......
...@@ -203,6 +203,7 @@ static void rfcomm_dlc_clear_state(struct rfcomm_dlc *d) ...@@ -203,6 +203,7 @@ static void rfcomm_dlc_clear_state(struct rfcomm_dlc *d)
d->state = BT_OPEN; d->state = BT_OPEN;
d->flags = 0; d->flags = 0;
d->mscex = 0;
d->mtu = RFCOMM_DEFAULT_MTU; d->mtu = RFCOMM_DEFAULT_MTU;
d->v24_sig = RFCOMM_V24_RTC | RFCOMM_V24_RTR | RFCOMM_V24_DV; d->v24_sig = RFCOMM_V24_RTC | RFCOMM_V24_RTR | RFCOMM_V24_DV;
...@@ -1288,11 +1289,11 @@ static int rfcomm_recv_msc(struct rfcomm_session *s, int cr, struct sk_buff *skb ...@@ -1288,11 +1289,11 @@ static int rfcomm_recv_msc(struct rfcomm_session *s, int cr, struct sk_buff *skb
BT_DBG("dlci %d cr %d v24 0x%x", dlci, cr, msc->v24_sig); BT_DBG("dlci %d cr %d v24 0x%x", dlci, cr, msc->v24_sig);
if (!cr) d = rfcomm_dlc_get(s, dlci);
if (!d)
return 0; return 0;
d = rfcomm_dlc_get(s, dlci); if (cr) {
if (d) {
if (msc->v24_sig & RFCOMM_V24_FC && !d->credits) if (msc->v24_sig & RFCOMM_V24_FC && !d->credits)
set_bit(RFCOMM_TX_THROTTLED, &d->flags); set_bit(RFCOMM_TX_THROTTLED, &d->flags);
else else
...@@ -1304,7 +1305,11 @@ static int rfcomm_recv_msc(struct rfcomm_session *s, int cr, struct sk_buff *skb ...@@ -1304,7 +1305,11 @@ static int rfcomm_recv_msc(struct rfcomm_session *s, int cr, struct sk_buff *skb
rfcomm_dlc_unlock(d); rfcomm_dlc_unlock(d);
rfcomm_send_msc(s, 0, dlci, msc->v24_sig); rfcomm_send_msc(s, 0, dlci, msc->v24_sig);
}
d->mscex |= RFCOMM_MSCEX_RX;
} else
d->mscex |= RFCOMM_MSCEX_TX;
return 0; return 0;
} }
...@@ -1528,7 +1533,8 @@ static inline void rfcomm_process_dlcs(struct rfcomm_session *s) ...@@ -1528,7 +1533,8 @@ static inline void rfcomm_process_dlcs(struct rfcomm_session *s)
continue; continue;
} }
if (d->state == BT_CONNECTED || d->state == BT_DISCONN) if ((d->state == BT_CONNECTED || d->state == BT_DISCONN) &&
d->mscex == RFCOMM_MSCEX_OK)
rfcomm_process_tx(d); rfcomm_process_tx(d);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment