Skip to content

Commit 7b2dd80

Browse files
committed
Bluetooth: revert TX timestamping
JIRA: https://issues.redhat.com/browse/RHEL-93657 Upstream Status: RHEL-only The following upstream commits: 134f4b3 Bluetooth: add support for skb TX SND/COMPLETION timestamping d415ba2 Bluetooth: ISO: add TX timestamping 11770f4 Bluetooth: L2CAP: add TX timestamping bdbcd52 Bluetooth: SCO: add TX timestamping c174cd0 Bluetooth: increment TX timestamping tskey always for stream sockets 3908feb Bluetooth: L2CAP: copy RX timestamp to new fragments require commits that are not yet part of the Common Network Backport, and are not scheduled to be included until RHEL-9.8, so temporarily remove them so the Bluetooth rebase build can be completed in the RHEL-9.7 timeframe. reference: https://issues.redhat.com/browse/RHEL-101337 CNB98: net_tstamp: add SCM_TS_OPT_ID to provide OPT_ID in control message Note - These commits were reverted at the end rather than being omitted, since they impact the context of later commits in the rebase. Once RHEL-101337 is merged, this can be reverted. Signed-off-by: David Marlin <dmarlin@redhat.com>
1 parent f1d7f0c commit 7b2dd80

File tree

12 files changed

+17
-258
lines changed

12 files changed

+17
-258
lines changed

include/net/bluetooth/bluetooth.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ struct bt_voice {
156156
#define BT_PKT_STATUS 16
157157

158158
#define BT_SCM_PKT_STATUS 0x03
159-
#define BT_SCM_ERROR 0x04
160159

161160
#define BT_ISO_QOS 17
162161

include/net/bluetooth/hci_core.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -262,12 +262,6 @@ struct adv_info {
262262
struct delayed_work rpa_expired_cb;
263263
};
264264

265-
struct tx_queue {
266-
struct sk_buff_head queue;
267-
unsigned int extra;
268-
unsigned int tracked;
269-
};
270-
271265
#define HCI_MAX_ADV_INSTANCES 5
272266
#define HCI_DEFAULT_ADV_DURATION 2
273267

@@ -742,8 +736,6 @@ struct hci_conn {
742736
struct sk_buff_head data_q;
743737
struct list_head chan_list;
744738

745-
struct tx_queue tx_q;
746-
747739
struct delayed_work disc_work;
748740
struct delayed_work auto_accept_work;
749741
struct delayed_work idle_work;
@@ -1581,18 +1573,6 @@ void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active);
15811573
void hci_conn_failed(struct hci_conn *conn, u8 status);
15821574
u8 hci_conn_set_handle(struct hci_conn *conn, u16 handle);
15831575

1584-
void hci_conn_tx_queue(struct hci_conn *conn, struct sk_buff *skb);
1585-
void hci_conn_tx_dequeue(struct hci_conn *conn);
1586-
void hci_setup_tx_timestamp(struct sk_buff *skb, size_t key_offset,
1587-
const struct sockcm_cookie *sockc);
1588-
1589-
static inline void hci_sockcm_init(struct sockcm_cookie *sockc, struct sock *sk)
1590-
{
1591-
*sockc = (struct sockcm_cookie) {
1592-
.tsflags = READ_ONCE(sk->sk_tsflags),
1593-
};
1594-
}
1595-
15961576
/*
15971577
* hci_conn_get() and hci_conn_put() are used to control the life-time of an
15981578
* "hci_conn" object. They do not guarantee that the hci_conn object is running,

include/net/bluetooth/l2cap.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -955,8 +955,7 @@ void l2cap_chan_close(struct l2cap_chan *chan, int reason);
955955
int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid,
956956
bdaddr_t *dst, u8 dst_type, u16 timeout);
957957
int l2cap_chan_reconfigure(struct l2cap_chan *chan, __u16 mtu);
958-
int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len,
959-
const struct sockcm_cookie *sockc);
958+
int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len);
960959
void l2cap_chan_busy(struct l2cap_chan *chan, int busy);
961960
void l2cap_chan_rx_avail(struct l2cap_chan *chan, ssize_t rx_avail);
962961
int l2cap_chan_check_security(struct l2cap_chan *chan, bool initiator);

net/bluetooth/6lowpan.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ static int send_pkt(struct l2cap_chan *chan, struct sk_buff *skb,
443443
memset(&msg, 0, sizeof(msg));
444444
iov_iter_kvec(&msg.msg_iter, ITER_SOURCE, &iv, 1, skb->len);
445445

446-
err = l2cap_chan_send(chan, &msg, skb->len, NULL);
446+
err = l2cap_chan_send(chan, &msg, skb->len);
447447
if (err > 0) {
448448
netdev->stats.tx_bytes += err;
449449
netdev->stats.tx_packets++;

net/bluetooth/hci_conn.c

Lines changed: 0 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727

2828
#include <linux/export.h>
2929
#include <linux/debugfs.h>
30-
#include <linux/errqueue.h>
3130

3231
#include <net/bluetooth/bluetooth.h>
3332
#include <net/bluetooth/hci_core.h>
@@ -1003,7 +1002,6 @@ static struct hci_conn *__hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t
10031002
}
10041003

10051004
skb_queue_head_init(&conn->data_q);
1006-
skb_queue_head_init(&conn->tx_q.queue);
10071005

10081006
INIT_LIST_HEAD(&conn->chan_list);
10091007
INIT_LIST_HEAD(&conn->link_list);
@@ -1157,7 +1155,6 @@ void hci_conn_del(struct hci_conn *conn)
11571155
}
11581156

11591157
skb_queue_purge(&conn->data_q);
1160-
skb_queue_purge(&conn->tx_q.queue);
11611158

11621159
/* Remove the connection from the list and cleanup its remaining
11631160
* state. This is a separate function since for some cases like
@@ -2901,129 +2898,6 @@ int hci_abort_conn(struct hci_conn *conn, u8 reason)
29012898
return hci_cmd_sync_run_once(hdev, abort_conn_sync, conn, NULL);
29022899
}
29032900

2904-
void hci_setup_tx_timestamp(struct sk_buff *skb, size_t key_offset,
2905-
const struct sockcm_cookie *sockc)
2906-
{
2907-
struct sock *sk = skb ? skb->sk : NULL;
2908-
int key;
2909-
2910-
/* This shall be called on a single skb of those generated by user
2911-
* sendmsg(), and only when the sendmsg() does not return error to
2912-
* user. This is required for keeping the tskey that increments here in
2913-
* sync with possible sendmsg() counting by user.
2914-
*
2915-
* Stream sockets shall set key_offset to sendmsg() length in bytes
2916-
* and call with the last fragment, others to 1 and first fragment.
2917-
*/
2918-
2919-
if (!skb || !sockc || !sk || !key_offset)
2920-
return;
2921-
2922-
sock_tx_timestamp(sk, sockc, &skb_shinfo(skb)->tx_flags);
2923-
2924-
if (sk->sk_type == SOCK_STREAM)
2925-
key = atomic_add_return(key_offset, &sk->sk_tskey);
2926-
2927-
if (sockc->tsflags & SOF_TIMESTAMPING_OPT_ID &&
2928-
sockc->tsflags & SOF_TIMESTAMPING_TX_RECORD_MASK) {
2929-
if (sockc->tsflags & SOCKCM_FLAG_TS_OPT_ID) {
2930-
skb_shinfo(skb)->tskey = sockc->ts_opt_id;
2931-
} else {
2932-
if (sk->sk_type != SOCK_STREAM)
2933-
key = atomic_inc_return(&sk->sk_tskey);
2934-
skb_shinfo(skb)->tskey = key - 1;
2935-
}
2936-
}
2937-
}
2938-
2939-
void hci_conn_tx_queue(struct hci_conn *conn, struct sk_buff *skb)
2940-
{
2941-
struct tx_queue *comp = &conn->tx_q;
2942-
bool track = false;
2943-
2944-
/* Emit SND now, ie. just before sending to driver */
2945-
if (skb_shinfo(skb)->tx_flags & SKBTX_SW_TSTAMP)
2946-
__skb_tstamp_tx(skb, NULL, NULL, skb->sk, SCM_TSTAMP_SND);
2947-
2948-
/* COMPLETION tstamp is emitted for tracked skb later in Number of
2949-
* Completed Packets event. Available only for flow controlled cases.
2950-
*
2951-
* TODO: SCO support without flowctl (needs to be done in drivers)
2952-
*/
2953-
switch (conn->type) {
2954-
case ISO_LINK:
2955-
case ACL_LINK:
2956-
case LE_LINK:
2957-
break;
2958-
case SCO_LINK:
2959-
case ESCO_LINK:
2960-
if (!hci_dev_test_flag(conn->hdev, HCI_SCO_FLOWCTL))
2961-
return;
2962-
break;
2963-
default:
2964-
return;
2965-
}
2966-
2967-
if (skb->sk && (skb_shinfo(skb)->tx_flags & SKBTX_COMPLETION_TSTAMP))
2968-
track = true;
2969-
2970-
/* If nothing is tracked, just count extra skbs at the queue head */
2971-
if (!track && !comp->tracked) {
2972-
comp->extra++;
2973-
return;
2974-
}
2975-
2976-
if (track) {
2977-
skb = skb_clone_sk(skb);
2978-
if (!skb)
2979-
goto count_only;
2980-
2981-
comp->tracked++;
2982-
} else {
2983-
skb = skb_clone(skb, GFP_KERNEL);
2984-
if (!skb)
2985-
goto count_only;
2986-
}
2987-
2988-
skb_queue_tail(&comp->queue, skb);
2989-
return;
2990-
2991-
count_only:
2992-
/* Stop tracking skbs, and only count. This will not emit timestamps for
2993-
* the packets, but if we get here something is more seriously wrong.
2994-
*/
2995-
comp->tracked = 0;
2996-
comp->extra += skb_queue_len(&comp->queue) + 1;
2997-
skb_queue_purge(&comp->queue);
2998-
}
2999-
3000-
void hci_conn_tx_dequeue(struct hci_conn *conn)
3001-
{
3002-
struct tx_queue *comp = &conn->tx_q;
3003-
struct sk_buff *skb;
3004-
3005-
/* If there are tracked skbs, the counted extra go before dequeuing real
3006-
* skbs, to keep ordering. When nothing is tracked, the ordering doesn't
3007-
* matter so dequeue real skbs first to get rid of them ASAP.
3008-
*/
3009-
if (comp->extra && (comp->tracked || skb_queue_empty(&comp->queue))) {
3010-
comp->extra--;
3011-
return;
3012-
}
3013-
3014-
skb = skb_dequeue(&comp->queue);
3015-
if (!skb)
3016-
return;
3017-
3018-
if (skb->sk) {
3019-
comp->tracked--;
3020-
__skb_tstamp_tx(skb, NULL, NULL, skb->sk,
3021-
SCM_TSTAMP_COMPLETION);
3022-
}
3023-
3024-
kfree_skb(skb);
3025-
}
3026-
30272901
u8 *hci_conn_key_enc_size(struct hci_conn *conn)
30282902
{
30292903
if (conn->type == ACL_LINK) {

net/bluetooth/hci_core.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3041,13 +3041,6 @@ static int hci_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
30413041
return 0;
30423042
}
30433043

3044-
static int hci_send_conn_frame(struct hci_dev *hdev, struct hci_conn *conn,
3045-
struct sk_buff *skb)
3046-
{
3047-
hci_conn_tx_queue(conn, skb);
3048-
return hci_send_frame(hdev, skb);
3049-
}
3050-
30513044
/* Send HCI command */
30523045
int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen,
30533046
const void *param)
@@ -3594,7 +3587,7 @@ static void hci_sched_sco(struct hci_dev *hdev, __u8 type)
35943587
while (*cnt && (conn = hci_low_sent(hdev, type, &quote))) {
35953588
while (quote-- && (skb = skb_dequeue(&conn->data_q))) {
35963589
BT_DBG("skb %p len %d", skb, skb->len);
3597-
hci_send_conn_frame(hdev, conn, skb);
3590+
hci_send_frame(hdev, skb);
35983591

35993592
conn->sent++;
36003593
if (conn->sent == ~0)
@@ -3637,7 +3630,7 @@ static void hci_sched_acl_pkt(struct hci_dev *hdev)
36373630
hci_conn_enter_active_mode(chan->conn,
36383631
bt_cb(skb)->force_active);
36393632

3640-
hci_send_conn_frame(hdev, chan->conn, skb);
3633+
hci_send_frame(hdev, skb);
36413634
hdev->acl_last_tx = jiffies;
36423635

36433636
hdev->acl_cnt--;
@@ -3693,7 +3686,7 @@ static void hci_sched_le(struct hci_dev *hdev)
36933686

36943687
skb = skb_dequeue(&chan->data_q);
36953688

3696-
hci_send_conn_frame(hdev, chan->conn, skb);
3689+
hci_send_frame(hdev, skb);
36973690
hdev->le_last_tx = jiffies;
36983691

36993692
(*cnt)--;
@@ -3727,7 +3720,7 @@ static void hci_sched_iso(struct hci_dev *hdev)
37273720
while (*cnt && (conn = hci_low_sent(hdev, ISO_LINK, &quote))) {
37283721
while (quote-- && (skb = skb_dequeue(&conn->data_q))) {
37293722
BT_DBG("skb %p len %d", skb, skb->len);
3730-
hci_send_conn_frame(hdev, conn, skb);
3723+
hci_send_frame(hdev, skb);
37313724

37323725
conn->sent++;
37333726
if (conn->sent == ~0)

net/bluetooth/hci_event.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4426,7 +4426,6 @@ static void hci_num_comp_pkts_evt(struct hci_dev *hdev, void *data,
44264426
struct hci_comp_pkts_info *info = &ev->handles[i];
44274427
struct hci_conn *conn;
44284428
__u16 handle, count;
4429-
unsigned int i;
44304429

44314430
handle = __le16_to_cpu(info->handle);
44324431
count = __le16_to_cpu(info->count);
@@ -4437,9 +4436,6 @@ static void hci_num_comp_pkts_evt(struct hci_dev *hdev, void *data,
44374436

44384437
conn->sent -= count;
44394438

4440-
for (i = 0; i < count; ++i)
4441-
hci_conn_tx_dequeue(conn);
4442-
44434439
switch (conn->type) {
44444440
case ACL_LINK:
44454441
hdev->acl_cnt += count;

net/bluetooth/iso.c

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -518,8 +518,7 @@ static struct bt_iso_qos *iso_sock_get_qos(struct sock *sk)
518518
return &iso_pi(sk)->qos;
519519
}
520520

521-
static int iso_send_frame(struct sock *sk, struct sk_buff *skb,
522-
const struct sockcm_cookie *sockc)
521+
static int iso_send_frame(struct sock *sk, struct sk_buff *skb)
523522
{
524523
struct iso_conn *conn = iso_pi(sk)->conn;
525524
struct bt_iso_qos *qos = iso_sock_get_qos(sk);
@@ -539,12 +538,10 @@ static int iso_send_frame(struct sock *sk, struct sk_buff *skb,
539538
hdr->slen = cpu_to_le16(hci_iso_data_len_pack(len,
540539
HCI_ISO_STATUS_VALID));
541540

542-
if (sk->sk_state == BT_CONNECTED) {
543-
hci_setup_tx_timestamp(skb, 1, sockc);
541+
if (sk->sk_state == BT_CONNECTED)
544542
hci_send_iso(conn->hcon, skb);
545-
} else {
543+
else
546544
len = -ENOTCONN;
547-
}
548545

549546
return len;
550547
}
@@ -1351,7 +1348,6 @@ static int iso_sock_sendmsg(struct socket *sock, struct msghdr *msg,
13511348
{
13521349
struct sock *sk = sock->sk;
13531350
struct sk_buff *skb, **frag;
1354-
struct sockcm_cookie sockc;
13551351
size_t mtu;
13561352
int err;
13571353

@@ -1364,14 +1360,6 @@ static int iso_sock_sendmsg(struct socket *sock, struct msghdr *msg,
13641360
if (msg->msg_flags & MSG_OOB)
13651361
return -EOPNOTSUPP;
13661362

1367-
hci_sockcm_init(&sockc, sk);
1368-
1369-
if (msg->msg_controllen) {
1370-
err = sock_cmsg_send(sk, msg, &sockc);
1371-
if (err)
1372-
return err;
1373-
}
1374-
13751363
lock_sock(sk);
13761364

13771365
if (sk->sk_state != BT_CONNECTED) {
@@ -1417,7 +1405,7 @@ static int iso_sock_sendmsg(struct socket *sock, struct msghdr *msg,
14171405
lock_sock(sk);
14181406

14191407
if (sk->sk_state == BT_CONNECTED)
1420-
err = iso_send_frame(sk, skb, &sockc);
1408+
err = iso_send_frame(sk, skb);
14211409
else
14221410
err = -ENOTCONN;
14231411

@@ -1485,10 +1473,6 @@ static int iso_sock_recvmsg(struct socket *sock, struct msghdr *msg,
14851473

14861474
BT_DBG("sk %p", sk);
14871475

1488-
if (unlikely(flags & MSG_ERRQUEUE))
1489-
return sock_recv_errqueue(sk, msg, len, SOL_BLUETOOTH,
1490-
BT_SCM_ERROR);
1491-
14921476
if (test_and_clear_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags)) {
14931477
sock_hold(sk);
14941478
lock_sock(sk);

0 commit comments

Comments
 (0)