Re: [PATCH v3 3/3] Bluetooth: Add BT_MODE socket option

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Luiz,

> This adds BT_MODE socket option which can be used to set L2CAP modes,
> including modes only supported over LE which were not supported using
> the L2CAP_OPTIONS.
> 
> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@xxxxxxxxx>
> ---
> include/net/bluetooth/bluetooth.h | 11 ++++
> net/bluetooth/l2cap_sock.c        | 96 +++++++++++++++++++++++++++++++
> 2 files changed, 107 insertions(+)
> 
> diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
> index 1576353a2773..34191e34bfdc 100644
> --- a/include/net/bluetooth/bluetooth.h
> +++ b/include/net/bluetooth/bluetooth.h
> @@ -139,6 +139,17 @@ struct bt_voice {
> #define BT_PHY_LE_CODED_TX	0x00002000
> #define BT_PHY_LE_CODED_RX	0x00004000
> 
> +#define BT_MODE			15
> +
> +#define BT_MODE_BASIC		0x00
> +#define BT_MODE_RETRANS		0x01
> +#define BT_MODE_FLOWCTL		0x02
> +#define BT_MODE_ERTM		0x03
> +#define BT_MODE_STREAMING	0x04
> +#define BT_MODE_EXT_FLOWCTL	0x05
> +
> +#define BT_MODE_LE_FLOWCTL	0x80
> +

what I would do is just this:

	BASIC		0x00
	ERTM		0x01
	STREAMING	0x02
	LE_FLOWCTL	0x03
	EXT_FLOWCTL	0x04

Trying to cling onto some old L2CAP definition from the 2.1 days is not helpful. I would really make a clean cut here.

This way we can also cleanly check the available modes per selected socket and have either setsockopt or connect fail appropriately.

> __printf(1, 2)
> void bt_info(const char *fmt, ...);
> __printf(1, 2)
> diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
> index 117ba20ea194..f2bb376c699f 100644
> --- a/net/bluetooth/l2cap_sock.c
> +++ b/net/bluetooth/l2cap_sock.c
> @@ -500,6 +500,25 @@ static int l2cap_sock_getsockopt_old(struct socket *sock, int optname,
> 	return err;
> }
> 
> +static u8 l2cap_get_mode(struct l2cap_chan *chan)
> +{
> +	switch (chan->mode) {
> +	case L2CAP_MODE_BASIC:
> +	case L2CAP_MODE_RETRANS:
> +	case L2CAP_MODE_FLOWCTL:
> +	case L2CAP_MODE_ERTM:
> +	case L2CAP_MODE_STREAMING:
> +		/* Mode above are the same on both old and new sockopt */
> +		return chan->mode;
> +	case L2CAP_MODE_LE_FLOWCTL:
> +		return BT_MODE_FLOWCTL;
> +	case L2CAP_MODE_EXT_FLOWCTL:
> +		return BT_MODE_EXT_FLOWCTL;
> +	}
> +
> +	return chan->mode;
> +}
> +

Don’t bother with this. Keep the old socket and new socket independent code. I also want to add Kconfig option later that will allow us to disable the old socket options once we have SOL_L2CAP requirement eradicated.

Regards

Marcel




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux