Skip to content

Commit bdbcd52

Browse files
pvVudentz
authored andcommitted
Bluetooth: SCO: add TX timestamping
Support TX timestamping in SCO sockets. Not available for hdevs without SCO_FLOWCTL. Support MSG_ERRQUEUE in SCO recvmsg. Signed-off-by: Pauli Virtanen <pav@iki.fi> Reviewed-by: Willem de Bruijn <willemb@google.com> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
1 parent 11770f4 commit bdbcd52

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

net/bluetooth/sco.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,8 @@ static int sco_connect(struct sock *sk)
378378
return err;
379379
}
380380

381-
static int sco_send_frame(struct sock *sk, struct sk_buff *skb)
381+
static int sco_send_frame(struct sock *sk, struct sk_buff *skb,
382+
const struct sockcm_cookie *sockc)
382383
{
383384
struct sco_conn *conn = sco_pi(sk)->conn;
384385
int len = skb->len;
@@ -389,6 +390,7 @@ static int sco_send_frame(struct sock *sk, struct sk_buff *skb)
389390

390391
BT_DBG("sk %p len %d", sk, len);
391392

393+
hci_setup_tx_timestamp(skb, 1, sockc);
392394
hci_send_sco(conn->hcon, skb);
393395

394396
return len;
@@ -784,6 +786,7 @@ static int sco_sock_sendmsg(struct socket *sock, struct msghdr *msg,
784786
{
785787
struct sock *sk = sock->sk;
786788
struct sk_buff *skb;
789+
struct sockcm_cookie sockc;
787790
int err;
788791

789792
BT_DBG("sock %p, sk %p", sock, sk);
@@ -795,14 +798,22 @@ static int sco_sock_sendmsg(struct socket *sock, struct msghdr *msg,
795798
if (msg->msg_flags & MSG_OOB)
796799
return -EOPNOTSUPP;
797800

801+
hci_sockcm_init(&sockc, sk);
802+
803+
if (msg->msg_controllen) {
804+
err = sock_cmsg_send(sk, msg, &sockc);
805+
if (err)
806+
return err;
807+
}
808+
798809
skb = bt_skb_sendmsg(sk, msg, len, len, 0, 0);
799810
if (IS_ERR(skb))
800811
return PTR_ERR(skb);
801812

802813
lock_sock(sk);
803814

804815
if (sk->sk_state == BT_CONNECTED)
805-
err = sco_send_frame(sk, skb);
816+
err = sco_send_frame(sk, skb, &sockc);
806817
else
807818
err = -ENOTCONN;
808819

@@ -868,6 +879,10 @@ static int sco_sock_recvmsg(struct socket *sock, struct msghdr *msg,
868879
struct sock *sk = sock->sk;
869880
struct sco_pinfo *pi = sco_pi(sk);
870881

882+
if (unlikely(flags & MSG_ERRQUEUE))
883+
return sock_recv_errqueue(sk, msg, len, SOL_BLUETOOTH,
884+
BT_SCM_ERROR);
885+
871886
lock_sock(sk);
872887

873888
if (sk->sk_state == BT_CONNECT2 &&

0 commit comments

Comments
 (0)