linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: Marcel Holtmann <marcel@holtmann.org>
Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>
Subject: Re: [PATCH v3 3/3] Bluetooth: Add BT_MODE socket option
Date: Mon, 23 Mar 2020 11:39:14 -0700	[thread overview]
Message-ID: <CABBYNZLndyg9DzTUohx-DZ0y09OscbdFLNm+LMWfv+6L9XwdZw@mail.gmail.com> (raw)
In-Reply-To: <70260AFD-45C1-4A28-B7B1-021F65E38A5C@holtmann.org>

Hi Marcel.

On Mon, Mar 23, 2020 at 10:42 AM Marcel Holtmann <marcel@holtmann.org> wrote:
>
> 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@intel.com>
> >>> ---
> >>> 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.
> >
> > Just to confirm, that means we will not going to support the old
> > flowctl and retransmit modes from BR/EDR with BT_MODE?
>
> we currently don’t support these two modes, nor are there any specs that require it.

Right, it seems we didn't validate these modes in L2CAP_OPTION though,
I left that unchanged in the last set.

> >> 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.
> >
> > The reason I had the defines intermixed was that application would be
> > able to use the old sockopt to set it and then use BT_MODE to read it,
> > in which case I may need to store the actual socket mode separately
> > from the chan->mode and then perhaps fail if application attempt to
> > read it with BT_MODE if was not set using it.
>
> If someone used L2CAP_OTIONS, then just lets fail BT_MODE read and write.

Right, Ive made it fail with lastest change, I can probably have a
flag to make it exclusively thogh with one or another, I will send an
update shortly.

> Regards
>
> Marcel
>


-- 
Luiz Augusto von Dentz

      reply	other threads:[~2020-03-23 18:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-18 21:50 [PATCH v3 0/3] Enable use of L2CAP_MODE_EXT_FLOWCTL Luiz Augusto von Dentz
2020-03-18 21:50 ` [PATCH v3 1/3] Bluetooth: L2CAP: Add get_peer_pid callback Luiz Augusto von Dentz
2020-03-18 21:50 ` [PATCH v3 2/3] Bluetooth: L2CAP: Use DEFER_SETUP to group ECRED connections Luiz Augusto von Dentz
2020-03-18 21:50 ` [PATCH v3 3/3] Bluetooth: Add BT_MODE socket option Luiz Augusto von Dentz
2020-03-20  0:58   ` Marcel Holtmann
2020-03-20 17:44     ` Luiz Augusto von Dentz
2020-03-23 17:42       ` Marcel Holtmann
2020-03-23 18:39         ` Luiz Augusto von Dentz [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CABBYNZLndyg9DzTUohx-DZ0y09OscbdFLNm+LMWfv+6L9XwdZw@mail.gmail.com \
    --to=luiz.dentz@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=marcel@holtmann.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).