Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp295703lqb; Thu, 14 Mar 2024 11:23:41 -0700 (PDT) X-Forwarded-Encrypted: i=4; AJvYcCWorKUCv5HuH+w4aWlfr5SgOk4t2n0ezDMOf5IFDiSDJq/wsm1oAve9GoviVAqi4GRATOc4R03Z7ZMvqNkyEFOLuZbD7bVTFUiBoH6V9A== X-Google-Smtp-Source: AGHT+IGFJGoQyop1uxizst2iJsTmcL9kq12RKKpHAeZe3tLxLBpkO39iau9+TpHSa5VOk28GtTlf X-Received: by 2002:a17:906:99d5:b0:a46:7b92:84c4 with SMTP id s21-20020a17090699d500b00a467b9284c4mr728362ejn.48.1710440621240; Thu, 14 Mar 2024 11:23:41 -0700 (PDT) ARC-Seal: i=3; a=rsa-sha256; t=1710440621; cv=pass; d=google.com; s=arc-20160816; b=jPUXU6qoL6dcSssqJQwVB1KwWlEC4FFr75J/Syns1RHHGhANsdPMWW+VO5bN1Gz3r6 dj0AzXynjp7pReCmJW9zAWTcMB7oS9yVVf/ypph8RpGKEjcgxVhmSnlBOYlUROP70MVf Wcsh0y9HQWLINexmYpGeVRoEra6nzb1GsLUbHBn2WslwvBHWk894XrB3eyfvI+YXfN1l XGZ4ELTjeTMNKNviBNNR0eoAJnYBMgiePSo1c+qvOidlgG3Ay+/fEhJwmbknN1qks2XH zGn5n5Lx+s3g1Gf0E4Xoo9EZRemlMDzFsMgxEuv9p5UVixAxJBYUx6b0UDUfnA78M3L0 cEUQ== ARC-Message-Signature: i=3; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=qqAbdeHgbf6SrAl4IQ4INi2J0n7FCiKQNKklcsCW2+I=; fh=ExGhjNQEFJgRqHmYATVc5UXZbS7abAmaHDitrfHKOuE=; b=a1Rl/A0iY+SDj2nPLSGUxPFBu1fhT/7mYuNvClkbjilR0BRhSMpmeIZuWP9BYLyoVR Ly8lrSzhVLFnDdbXfDXLrl/BKd/SyDYK5Ricw/e4Td7qk0yqP+OozucDzxQDfZ1fr0Co 4b1oFxkQvcnsSm9V1Tpk34eTANtnasC6y1qHmSummCDhsDyzsiFTK0tDKD5z5Wk+qN7l jyWLRQRvKO37yQym9fEYdctHivYgQetQ2I3rNqgBATxHUBYDhNvrd0MDYFWO/bKrJULM N0NjdDwSJrO5EpkwNIWjUo0Sqzd420lhE3m2srDjCmSq47TR6X/xzl81WwMBtcFQS5NV dPxA==; dara=google.com ARC-Authentication-Results: i=3; mx.google.com; dkim=pass header.i=@iki.fi header.s=meesny header.b=NyGoqq7x; arc=pass (i=2 spf=pass spfdomain=iki.fi dkim=pass dkdomain=iki.fi); spf=pass (google.com: domain of linux-bluetooth+bounces-2527-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-2527-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id mb16-20020a170906eb1000b00a453183f2edsi872808ejb.472.2024.03.14.11.23.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 11:23:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-2527-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@iki.fi header.s=meesny header.b=NyGoqq7x; arc=pass (i=2 spf=pass spfdomain=iki.fi dkim=pass dkdomain=iki.fi); spf=pass (google.com: domain of linux-bluetooth+bounces-2527-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-2527-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id F37341F214A8 for ; Thu, 14 Mar 2024 18:23:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B39C976EE8; Thu, 14 Mar 2024 18:21:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=iki.fi header.i=@iki.fi header.b="NyGoqq7x" X-Original-To: linux-bluetooth@vger.kernel.org Received: from meesny.iki.fi (meesny.iki.fi [195.140.195.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 64A4176EEC for ; Thu, 14 Mar 2024 18:20:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=195.140.195.201 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710440461; cv=pass; b=JAFQGRSz73YMwVqMjdknIsGkLMVUWQDyToiya7abKjqBfK8e76bl5wV3zUexHmznjhWDcFfO1NJ/C+gotib/wQyCQx4rq3A7wB98JEqidjVfr0P4PqTyh/vITxWqmhZJ3jKho6z6oE3faKVxVY/mum3mpSdd9nssuG4p1vLGCYk= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710440461; c=relaxed/simple; bh=upwLDxZeHoJ7y9p4wA1PGl0wvgGS07qfkAPnl5l4fTE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mvHAzZ17MYO5qnpeD9eLF5SnIuxi1iLAUbNVOqR3bOA7fGBFo2+j7chtd11EY47I+XLqRwMN4s3Lli2NSFAY91/wKVlo0tTKbMj5fAN3bJV6nebIK5U8ygqWIaNRJttsNOkT3V8F+P2Kem9qQx984rBOGIUZx4Lo3+X1X9vN3ec= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iki.fi; spf=pass smtp.mailfrom=iki.fi; dkim=pass (1024-bit key) header.d=iki.fi header.i=@iki.fi header.b=NyGoqq7x; arc=pass smtp.client-ip=195.140.195.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iki.fi Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=iki.fi Received: from monolith.lan (unknown [193.138.7.198]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: pav) by meesny.iki.fi (Postfix) with ESMTPSA id 4TwbKZ6xhlz1026; Thu, 14 Mar 2024 20:20:50 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1710440451; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qqAbdeHgbf6SrAl4IQ4INi2J0n7FCiKQNKklcsCW2+I=; b=NyGoqq7x1aqviyAGnMdQR2iCBrZkRli8h4IdgGgK9IUr9po5WKTj8zG/mjwlQgbHDC4ryU KewIC2nfNS/tNN99U0iOUnnDos9dhe4uStd64WQek/ct8hG+3UAHC44ULmiI7g6GIazsBN mhmwiM3sfyIlNHRM/3inZUL/HoaAfdw= ARC-Seal: i=1; s=meesny; d=iki.fi; t=1710440451; a=rsa-sha256; cv=none; b=BYRGPS8UdSwnE3JUoyqeNIgT5g7s2yDUgsRtQ8alDVJu4CHY3SsVSOW0Z5bnIlFgxny46E cy3EDo6qypMocaZgUAooe9DkcKLyKsRGdjExdJx4X3sOSMvTdwYYaAGgo0oEZxOnLl+yDl l9Ng3R9ZmNLMWz173BtSKkvtaeKFeKI= ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=pav smtp.mailfrom=pav@iki.fi ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1710440451; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qqAbdeHgbf6SrAl4IQ4INi2J0n7FCiKQNKklcsCW2+I=; b=dlm4e1Qvk8q8DWN+/v1lKNYh+24MsVM5bh81FqdzbHJwHQcmpe0KTrUiIP20ZQPIx4ORXi sYjj+X+ZJ7ne7VS4zpEtdrnovt2KbvC9C2f30A6sUGteikycCjNGflmDyy6NvqBkQusFCW H/wXdeTY/HadOf7/Fn0VVS7H4hp7bBU= From: Pauli Virtanen To: linux-bluetooth@vger.kernel.org Cc: Pauli Virtanen Subject: [PATCH v2 2/5] Bluetooth: ISO: add TX timestamping Date: Thu, 14 Mar 2024 20:20:18 +0200 Message-ID: <05534fa39b2e6106bda98e1835a84e49821d6f58.1710440392.git.pav@iki.fi> X-Mailer: git-send-email 2.44.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add BT_SCM_ERROR socket CMSG type. Support TX timestamping in ISO sockets. Support MSG_ERRQUEUE in ISO recvmsg. Signed-off-by: Pauli Virtanen --- 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 7ffa8c192c3f..9280e72093ee 100644 --- a/include/net/bluetooth/bluetooth.h +++ b/include/net/bluetooth/bluetooth.h @@ -155,6 +155,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 8af75d37b14c..a77ab9df7994 100644 --- a/net/bluetooth/iso.c +++ b/net/bluetooth/iso.c @@ -489,7 +489,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); @@ -509,10 +510,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_tx_timestamp(skb, sockc); hci_send_iso(conn->hcon, skb); - else + } else { len = -ENOTCONN; + } return len; } @@ -1266,6 +1269,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; @@ -1278,6 +1282,14 @@ static int iso_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; + } + lock_sock(sk); if (sk->sk_state != BT_CONNECTED) { @@ -1323,7 +1335,7 @@ static int iso_sock_sendmsg(struct socket *sock, struct msghdr *msg, lock_sock(sk); if (sk->sk_state == BT_CONNECTED) - err = iso_send_frame(sk, skb); + err = iso_send_frame(sk, skb, &sockc); else err = -ENOTCONN; @@ -1379,6 +1391,10 @@ static int iso_sock_recvmsg(struct socket *sock, struct msghdr *msg, BT_DBG("sk %p", sk); + if (unlikely(flags & MSG_ERRQUEUE)) + return sock_recv_errqueue(sk, msg, len, SOL_BLUETOOTH, + BT_SCM_ERROR); + if (test_and_clear_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags)) { lock_sock(sk); switch (sk->sk_state) { -- 2.44.0