diff options
author | Mat Martineau <mathewm@codeaurora.org> | 2012-10-23 18:24:20 -0400 |
---|---|---|
committer | Gustavo Padovan <gustavo.padovan@collabora.co.uk> | 2012-10-23 22:25:42 -0400 |
commit | 36c86c8566cec67924ae6f372d9066cc9e92ad0e (patch) | |
tree | 7a5414c85edd8ceb8c78fa13ef660171e0db2c67 /net/bluetooth | |
parent | b99e13ade709274104f5c2b8a26dc7d2953fc58e (diff) |
Bluetooth: Configure appropriate timeouts for AMP controllers
The L2CAP spec recommends specific retransmit and monitor timeouts for
ERTM channels that are on AMP controllers. These timeouts are
calculated from the AMP controller's best effort flush timeout.
BR/EDR controllers use the default retransmit and monitor timeouts.
Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Diffstat (limited to 'net/bluetooth')
-rw-r--r-- | net/bluetooth/l2cap_core.c | 47 |
1 files changed, 41 insertions, 6 deletions
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 4eb3ca84de2f..6662ee34e754 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c | |||
@@ -2967,6 +2967,44 @@ static inline bool __l2cap_efs_supported(struct l2cap_chan *chan) | |||
2967 | return enable_hs && chan->conn->feat_mask & L2CAP_FEAT_EXT_FLOW; | 2967 | return enable_hs && chan->conn->feat_mask & L2CAP_FEAT_EXT_FLOW; |
2968 | } | 2968 | } |
2969 | 2969 | ||
2970 | static void __l2cap_set_ertm_timeouts(struct l2cap_chan *chan, | ||
2971 | struct l2cap_conf_rfc *rfc) | ||
2972 | { | ||
2973 | if (chan->local_amp_id && chan->hs_hcon) { | ||
2974 | u64 ertm_to = chan->hs_hcon->hdev->amp_be_flush_to; | ||
2975 | |||
2976 | /* Class 1 devices have must have ERTM timeouts | ||
2977 | * exceeding the Link Supervision Timeout. The | ||
2978 | * default Link Supervision Timeout for AMP | ||
2979 | * controllers is 10 seconds. | ||
2980 | * | ||
2981 | * Class 1 devices use 0xffffffff for their | ||
2982 | * best-effort flush timeout, so the clamping logic | ||
2983 | * will result in a timeout that meets the above | ||
2984 | * requirement. ERTM timeouts are 16-bit values, so | ||
2985 | * the maximum timeout is 65.535 seconds. | ||
2986 | */ | ||
2987 | |||
2988 | /* Convert timeout to milliseconds and round */ | ||
2989 | ertm_to = DIV_ROUND_UP_ULL(ertm_to, 1000); | ||
2990 | |||
2991 | /* This is the recommended formula for class 2 devices | ||
2992 | * that start ERTM timers when packets are sent to the | ||
2993 | * controller. | ||
2994 | */ | ||
2995 | ertm_to = 3 * ertm_to + 500; | ||
2996 | |||
2997 | if (ertm_to > 0xffff) | ||
2998 | ertm_to = 0xffff; | ||
2999 | |||
3000 | rfc->retrans_timeout = cpu_to_le16((u16) ertm_to); | ||
3001 | rfc->monitor_timeout = rfc->retrans_timeout; | ||
3002 | } else { | ||
3003 | rfc->retrans_timeout = __constant_cpu_to_le16(L2CAP_DEFAULT_RETRANS_TO); | ||
3004 | rfc->monitor_timeout = __constant_cpu_to_le16(L2CAP_DEFAULT_MONITOR_TO); | ||
3005 | } | ||
3006 | } | ||
3007 | |||
2970 | static inline void l2cap_txwin_setup(struct l2cap_chan *chan) | 3008 | static inline void l2cap_txwin_setup(struct l2cap_chan *chan) |
2971 | { | 3009 | { |
2972 | if (chan->tx_win > L2CAP_DEFAULT_TX_WINDOW && | 3010 | if (chan->tx_win > L2CAP_DEFAULT_TX_WINDOW && |
@@ -3033,8 +3071,8 @@ done: | |||
3033 | case L2CAP_MODE_ERTM: | 3071 | case L2CAP_MODE_ERTM: |
3034 | rfc.mode = L2CAP_MODE_ERTM; | 3072 | rfc.mode = L2CAP_MODE_ERTM; |
3035 | rfc.max_transmit = chan->max_tx; | 3073 | rfc.max_transmit = chan->max_tx; |
3036 | rfc.retrans_timeout = 0; | 3074 | |
3037 | rfc.monitor_timeout = 0; | 3075 | __l2cap_set_ertm_timeouts(chan, &rfc); |
3038 | 3076 | ||
3039 | size = min_t(u16, L2CAP_DEFAULT_MAX_PDU_SIZE, chan->conn->mtu - | 3077 | size = min_t(u16, L2CAP_DEFAULT_MAX_PDU_SIZE, chan->conn->mtu - |
3040 | L2CAP_EXT_HDR_SIZE - L2CAP_SDULEN_SIZE - | 3078 | L2CAP_EXT_HDR_SIZE - L2CAP_SDULEN_SIZE - |
@@ -3262,10 +3300,7 @@ done: | |||
3262 | rfc.max_pdu_size = cpu_to_le16(size); | 3300 | rfc.max_pdu_size = cpu_to_le16(size); |
3263 | chan->remote_mps = size; | 3301 | chan->remote_mps = size; |
3264 | 3302 | ||
3265 | rfc.retrans_timeout = | 3303 | __l2cap_set_ertm_timeouts(chan, &rfc); |
3266 | __constant_cpu_to_le16(L2CAP_DEFAULT_RETRANS_TO); | ||
3267 | rfc.monitor_timeout = | ||
3268 | __constant_cpu_to_le16(L2CAP_DEFAULT_MONITOR_TO); | ||
3269 | 3304 | ||
3270 | set_bit(CONF_MODE_DONE, &chan->conf_state); | 3305 | set_bit(CONF_MODE_DONE, &chan->conf_state); |
3271 | 3306 | ||