From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: Pauli Virtanen <pav@iki.fi>, linux-bluetooth@vger.kernel.org
Cc: Pauli Virtanen <pav@iki.fi>,
Luiz Augusto von Dentz <luiz.dentz@gmail.com>,
netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org,
willemdebruijn.kernel@gmail.com
Subject: Re: [PATCH v5 3/5] Bluetooth: ISO: add TX timestamping
Date: Wed, 19 Mar 2025 10:49:11 -0400 [thread overview]
Message-ID: <67dad9672e000_5948294b6@willemb.c.googlers.com.notmuch> (raw)
In-Reply-To: <af69c75a4d38e42bb11b344defc96adc5f703357.1742324341.git.pav@iki.fi>
Pauli Virtanen wrote:
> Add BT_SCM_ERROR socket CMSG type.
>
> Support TX timestamping in ISO sockets.
>
> Support MSG_ERRQUEUE in ISO recvmsg.
>
> If a packet from sendmsg() is fragmented, only the first ACL fragment is
> timestamped.
>
> Signed-off-by: Pauli Virtanen <pav@iki.fi>
> ---
>
> Notes:
> v5:
> - use sockcm_init -> hci_sockcm_init
>
> include/net/bluetooth/bluetooth.h | 1 +
> net/bluetooth/iso.c | 24 ++++++++++++++++++++----
> 2 files changed, 21 insertions(+), 4 deletions(-)
>
> diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
> index 435250c72d56..bbefde319f95 100644
> --- a/include/net/bluetooth/bluetooth.h
> +++ b/include/net/bluetooth/bluetooth.h
> @@ -156,6 +156,7 @@ struct bt_voice {
> #define BT_PKT_STATUS 16
>
> #define BT_SCM_PKT_STATUS 0x03
> +#define BT_SCM_ERROR 0x04
>
> #define BT_ISO_QOS 17
>
> diff --git a/net/bluetooth/iso.c b/net/bluetooth/iso.c
> index 0cb52a3308ba..3501a991f1c6 100644
> --- a/net/bluetooth/iso.c
> +++ b/net/bluetooth/iso.c
> @@ -518,7 +518,8 @@ static struct bt_iso_qos *iso_sock_get_qos(struct sock *sk)
> return &iso_pi(sk)->qos;
> }
>
> -static int iso_send_frame(struct sock *sk, struct sk_buff *skb)
> +static int iso_send_frame(struct sock *sk, struct sk_buff *skb,
> + const struct sockcm_cookie *sockc)
> {
> struct iso_conn *conn = iso_pi(sk)->conn;
> struct bt_iso_qos *qos = iso_sock_get_qos(sk);
> @@ -538,10 +539,12 @@ static int iso_send_frame(struct sock *sk, struct sk_buff *skb)
> hdr->slen = cpu_to_le16(hci_iso_data_len_pack(len,
> HCI_ISO_STATUS_VALID));
>
> - if (sk->sk_state == BT_CONNECTED)
> + if (sk->sk_state == BT_CONNECTED) {
> + hci_setup_tx_timestamp(skb, 1, sockc);
> hci_send_iso(conn->hcon, skb);
> - else
> + } else {
> len = -ENOTCONN;
> + }
>
> return len;
> }
> @@ -1348,6 +1351,7 @@ static int iso_sock_sendmsg(struct socket *sock, struct msghdr *msg,
> {
> struct sock *sk = sock->sk;
> struct sk_buff *skb, **frag;
> + struct sockcm_cookie sockc;
> size_t mtu;
> int err;
>
> @@ -1360,6 +1364,14 @@ static int iso_sock_sendmsg(struct socket *sock, struct msghdr *msg,
> if (msg->msg_flags & MSG_OOB)
> return -EOPNOTSUPP;
>
> + hci_sockcm_init(&sockc, sk);
> +
> + if (msg->msg_controllen) {
> + err = sock_cmsg_send(sk, msg, &sockc);
> + if (err)
> + return err;
> + }
> +
Minor: do you want to return an error if the process set unexpected
sockc fields?
If allowing to set them now, but ignoring them, it will be harder to
support them later. As then it will result in a kernel behavioral
change for the same sendmsg() call.
Though I suppose that is already the case if all cmsg are ignored
currently. So fine to keep if you don't care.
next prev parent reply other threads:[~2025-03-19 14:49 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-18 19:06 [PATCH v5 0/5] net: Bluetooth: add TX timestamping for ISO/L2CAP/SCO Pauli Virtanen
2025-03-18 19:06 ` [PATCH v5 1/5] net-timestamp: COMPLETION timestamp on packet tx completion Pauli Virtanen
2025-03-19 0:13 ` Jason Xing
2025-03-19 14:37 ` Willem de Bruijn
2025-03-19 15:48 ` Paul Menzel
2025-03-20 14:43 ` Luiz Augusto von Dentz
2025-03-20 14:49 ` Willem de Bruijn
2025-03-20 17:12 ` Pauli Virtanen
2025-03-20 17:51 ` Jason Xing
2025-03-18 19:06 ` [PATCH v5 2/5] Bluetooth: add support for skb TX SND/COMPLETION timestamping Pauli Virtanen
2025-03-19 0:39 ` Jason Xing
2025-03-19 14:44 ` Willem de Bruijn
2025-03-19 17:43 ` Pauli Virtanen
2025-03-19 20:00 ` Willem de Bruijn
2025-03-19 21:30 ` Pauli Virtanen
2025-03-19 21:35 ` Willem de Bruijn
2025-03-19 21:16 ` Luiz Augusto von Dentz
2025-03-19 18:21 ` Pauli Virtanen
2025-03-20 0:25 ` Jason Xing
2025-03-18 19:06 ` [PATCH v5 3/5] Bluetooth: ISO: add TX timestamping Pauli Virtanen
2025-03-19 14:49 ` Willem de Bruijn [this message]
2025-03-18 19:06 ` [PATCH v5 4/5] Bluetooth: L2CAP: " Pauli Virtanen
2025-03-18 19:06 ` [PATCH v5 5/5] Bluetooth: SCO: " Pauli Virtanen
2025-03-20 16:10 ` [PATCH v5 0/5] net: Bluetooth: add TX timestamping for ISO/L2CAP/SCO patchwork-bot+bluetooth
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=67dad9672e000_5948294b6@willemb.c.googlers.com.notmuch \
--to=willemdebruijn.kernel@gmail.com \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pav@iki.fi \
/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