Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Bluetooth: ISO: add TX timestamping

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>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

authored by

Pauli Virtanen and committed by
Luiz Augusto von Dentz
d415ba28 134f4b39

+21 -4
+1
include/net/bluetooth/bluetooth.h
··· 156 156 #define BT_PKT_STATUS 16 157 157 158 158 #define BT_SCM_PKT_STATUS 0x03 159 + #define BT_SCM_ERROR 0x04 159 160 160 161 #define BT_ISO_QOS 17 161 162
+20 -4
net/bluetooth/iso.c
··· 518 518 return &iso_pi(sk)->qos; 519 519 } 520 520 521 - static int iso_send_frame(struct sock *sk, struct sk_buff *skb) 521 + static int iso_send_frame(struct sock *sk, struct sk_buff *skb, 522 + const struct sockcm_cookie *sockc) 522 523 { 523 524 struct iso_conn *conn = iso_pi(sk)->conn; 524 525 struct bt_iso_qos *qos = iso_sock_get_qos(sk); ··· 539 538 hdr->slen = cpu_to_le16(hci_iso_data_len_pack(len, 540 539 HCI_ISO_STATUS_VALID)); 541 540 542 - if (sk->sk_state == BT_CONNECTED) 541 + if (sk->sk_state == BT_CONNECTED) { 542 + hci_setup_tx_timestamp(skb, 1, sockc); 543 543 hci_send_iso(conn->hcon, skb); 544 - else 544 + } else { 545 545 len = -ENOTCONN; 546 + } 546 547 547 548 return len; 548 549 } ··· 1351 1348 { 1352 1349 struct sock *sk = sock->sk; 1353 1350 struct sk_buff *skb, **frag; 1351 + struct sockcm_cookie sockc; 1354 1352 size_t mtu; 1355 1353 int err; 1356 1354 ··· 1363 1359 1364 1360 if (msg->msg_flags & MSG_OOB) 1365 1361 return -EOPNOTSUPP; 1362 + 1363 + hci_sockcm_init(&sockc, sk); 1364 + 1365 + if (msg->msg_controllen) { 1366 + err = sock_cmsg_send(sk, msg, &sockc); 1367 + if (err) 1368 + return err; 1369 + } 1366 1370 1367 1371 lock_sock(sk); 1368 1372 ··· 1417 1405 lock_sock(sk); 1418 1406 1419 1407 if (sk->sk_state == BT_CONNECTED) 1420 - err = iso_send_frame(sk, skb); 1408 + err = iso_send_frame(sk, skb, &sockc); 1421 1409 else 1422 1410 err = -ENOTCONN; 1423 1411 ··· 1485 1473 int err = 0; 1486 1474 1487 1475 BT_DBG("sk %p", sk); 1476 + 1477 + if (unlikely(flags & MSG_ERRQUEUE)) 1478 + return sock_recv_errqueue(sk, msg, len, SOL_BLUETOOTH, 1479 + BT_SCM_ERROR); 1488 1480 1489 1481 if (test_and_clear_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags)) { 1490 1482 sock_hold(sk);