Skip to content

Commit

Permalink
Bluetooth: SCO: add TX timestamping
Browse files Browse the repository at this point in the history
Support TX timestamping in SCO sockets.

Support MSG_ERRQUEUE in SCO recvmsg.

Signed-off-by: Pauli Virtanen <[email protected]>
Signed-off-by: Luiz Augusto von Dentz <[email protected]>
  • Loading branch information
pv authored and Vudentz committed Apr 1, 2024
1 parent e22f35e commit b7adccd
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions net/bluetooth/sco.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,8 @@ static int sco_connect(struct sock *sk)
return err;
}

static int sco_send_frame(struct sock *sk, struct sk_buff *skb)
static int sco_send_frame(struct sock *sk, struct sk_buff *skb,
const struct sockcm_cookie *sockc)
{
struct sco_conn *conn = sco_pi(sk)->conn;
int len = skb->len;
Expand All @@ -316,6 +317,7 @@ static int sco_send_frame(struct sock *sk, struct sk_buff *skb)

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

hci_tx_timestamp(skb, sockc);
hci_send_sco(conn->hcon, skb);

return len;
Expand Down Expand Up @@ -720,6 +722,7 @@ static int sco_sock_sendmsg(struct socket *sock, struct msghdr *msg,
{
struct sock *sk = sock->sk;
struct sk_buff *skb;
struct sockcm_cookie sockc;
int err;

BT_DBG("sock %p, sk %p", sock, sk);
Expand All @@ -731,14 +734,22 @@ static int sco_sock_sendmsg(struct socket *sock, struct msghdr *msg,
if (msg->msg_flags & MSG_OOB)
return -EOPNOTSUPP;

sockcm_init(&sockc, sk);

if (msg->msg_controllen) {
err = sock_cmsg_send(sk, msg, &sockc);
if (err)
return err;
}

skb = bt_skb_sendmsg(sk, msg, len, len, 0, 0);
if (IS_ERR(skb))
return PTR_ERR(skb);

lock_sock(sk);

if (sk->sk_state == BT_CONNECTED)
err = sco_send_frame(sk, skb);
err = sco_send_frame(sk, skb, &sockc);
else
err = -ENOTCONN;

Expand Down Expand Up @@ -804,6 +815,10 @@ static int sco_sock_recvmsg(struct socket *sock, struct msghdr *msg,
struct sock *sk = sock->sk;
struct sco_pinfo *pi = sco_pi(sk);

if (unlikely(flags & MSG_ERRQUEUE))
return sock_recv_errqueue(sk, msg, len, SOL_BLUETOOTH,
BT_SCM_ERROR);

lock_sock(sk);

if (sk->sk_state == BT_CONNECT2 &&
Expand Down

0 comments on commit b7adccd

Please sign in to comment.