From: Kyle Manna <kyle@kylemanna.com>
To: linux-bluetooth@vger.kernel.org,
Marcel Holtmann <marcel@holtmann.org>,
Gustavo Padovan <gustavo@padovan.org>,
Johan Hedberg <johan.hedberg@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Kyle Manna <kyle@kylemanna.com>
Subject: [PATCH 2/2] bluetooth: Add l2cap sockopt for LE conn params
Date: Thu, 4 Jul 2013 16:25:03 -0700 [thread overview]
Message-ID: <1372980303-3007-3-git-send-email-kyle@kylemanna.com> (raw)
In-Reply-To: <1372980303-3007-1-git-send-email-kyle@kylemanna.com>
* Userspace can now specify connection parameters to override the
defaults prior to connecting to the device.
* The intention is that setsockopt() will be called before connect() is
called in userspace apps and BlueZ libraries.
* It is critical to set these parameters prior to connect() to avoid
issues with hardware that must arbitrate the antenna access between
Bluetooth LE and things like WiFi. Aggressive connect (and scan)
window and interval values result in significant WiFi degradation.
* Reduces the need to call the hci LE Connection Update Command to
override the "defaults" when the desired values are known ahead of
time.
* Add BT_LE_CONN_PARAM socket option.
Signed-off-by: Kyle Manna <kyle@kylemanna.com>
---
include/net/bluetooth/bluetooth.h | 2 ++
net/bluetooth/l2cap_sock.c | 23 +++++++++++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
index 10eb9b3..36e9242 100644
--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -82,6 +82,8 @@ struct bt_power {
#define BT_CHANNEL_POLICY 10
+#define BT_LE_CONN_PARAM 11
+
/* BR/EDR only (default policy)
* AMP controllers cannot be used.
* Channel move requests from the remote device are denied.
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 2c7917e..17b6e2b 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -454,6 +454,15 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname,
err = -EFAULT;
break;
+ case BT_LE_CONN_PARAM:
+
+ len = min_t(unsigned int, len,
+ sizeof(struct hci_cp_le_create_conn));
+ if (copy_to_user(optval, (char *) &chan->cp_le, len))
+ err = -EFAULT;
+
+ break;
+
default:
err = -ENOPROTOOPT;
break;
@@ -749,6 +758,20 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
break;
+ case BT_LE_CONN_PARAM:
+
+ if (sizeof(struct hci_cp_le_create_conn) != optlen) {
+ err = -EINVAL;
+ break;
+ }
+
+ if (copy_from_user((char *) &chan->cp_le, optval, optlen)) {
+ err = -EFAULT;
+ break;
+ }
+
+ break;
+
default:
err = -ENOPROTOOPT;
break;
--
1.8.1.2
prev parent reply other threads:[~2013-07-04 23:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-04 23:25 [PATCH 0/2] Add support fo BT LE Connection Parameters Kyle Manna
2013-07-04 23:25 ` [PATCH 1/2] bluetooth: Pass HCI LE connection parameters Kyle Manna
2013-07-04 23:25 ` Kyle Manna [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1372980303-3007-3-git-send-email-kyle@kylemanna.com \
--to=kyle@kylemanna.com \
--cc=davem@davemloft.net \
--cc=gustavo@padovan.org \
--cc=johan.hedberg@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcel@holtmann.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).