[Bluetooth] Allow disabling of credit based flow control

This patch adds the module parameter disable_cfc which can be used to
disable the credit based flow control. The credit based flow control
was introduced with the Bluetooth 1.1 specification and devices can
negotiate its support, but for testing purpose it is helpful to allow
disabling of it.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>

authored by Marcel Holtmann and committed by David S. Miller 7c2660b0 0139418c

+13 -5
+13 -5
net/bluetooth/rfcomm/core.c
··· 52 52 #define BT_DBG(D...) 53 53 #endif 54 54 55 - #define VERSION "1.7" 55 + #define VERSION "1.8" 56 56 57 + static int disable_cfc = 0; 57 58 static unsigned int l2cap_mtu = RFCOMM_MAX_L2CAP_MTU; 58 59 59 60 static struct task_struct *rfcomm_thread; ··· 534 533 s->sock = sock; 535 534 536 535 s->mtu = RFCOMM_DEFAULT_MTU; 537 - s->cfc = RFCOMM_CFC_UNKNOWN; 536 + s->cfc = disable_cfc ? RFCOMM_CFC_DISABLED : RFCOMM_CFC_UNKNOWN; 538 537 539 538 /* Do not increment module usage count for listening sessions. 540 539 * Otherwise we won't be able to unload the module. */ ··· 1223 1222 BT_DBG("dlc %p state %ld dlci %d mtu %d fc 0x%x credits %d", 1224 1223 d, d->state, d->dlci, pn->mtu, pn->flow_ctrl, pn->credits); 1225 1224 1226 - if (pn->flow_ctrl == 0xf0 || pn->flow_ctrl == 0xe0) { 1227 - d->cfc = s->cfc = RFCOMM_CFC_ENABLED; 1225 + if ((pn->flow_ctrl == 0xf0 && s->cfc != RFCOMM_CFC_DISABLED) || 1226 + pn->flow_ctrl == 0xe0) { 1227 + d->cfc = RFCOMM_CFC_ENABLED; 1228 1228 d->tx_credits = pn->credits; 1229 1229 } else { 1230 - d->cfc = s->cfc = RFCOMM_CFC_DISABLED; 1230 + d->cfc = RFCOMM_CFC_DISABLED; 1231 1231 set_bit(RFCOMM_TX_THROTTLED, &d->flags); 1232 1232 } 1233 + 1234 + if (s->cfc == RFCOMM_CFC_UNKNOWN) 1235 + s->cfc = d->cfc; 1233 1236 1234 1237 d->priority = pn->priority; 1235 1238 ··· 2077 2072 2078 2073 module_init(rfcomm_init); 2079 2074 module_exit(rfcomm_exit); 2075 + 2076 + module_param(disable_cfc, bool, 0644); 2077 + MODULE_PARM_DESC(disable_cfc, "Disable credit based flow control"); 2080 2078 2081 2079 module_param(l2cap_mtu, uint, 0644); 2082 2080 MODULE_PARM_DESC(l2cap_mtu, "Default MTU for the L2CAP connection");