2024-04-07 15:18:55

by Pauli Virtanen

[permalink] [raw]
Subject: [PATCH BlueZ 0/5] Add BT_POLL_ERRQUEUE experimental feature and tests

Add BT_POLL_ERRQUEUE mgmt experimental feature, and tests for the
corresponding socket option.

Pauli Virtanen (5):
lib: add BT_POLL_ERRQUEUE socket option
adapter: add support for setting POLL_ERRQUEUE experimental feature
mgmt-tester: update for Poll Errqueue experimental fature
iso-tester: add test for BT_POLL_ERRQUEUE
shared/util: add uuid for Poll Errqueue experimental feature

lib/bluetooth.h | 2 +
src/adapter.c | 72 +++++++++++++++++++++++--
src/adapter.h | 1 +
src/main.c | 1 +
src/main.conf | 1 +
src/shared/util.c | 2 +
tools/iso-tester.c | 124 +++++++++++++++++++++++++++++++++++++++++++-
tools/mgmt-tester.c | 6 ++-
tools/tester.h | 3 ++
9 files changed, 206 insertions(+), 6 deletions(-)

--
2.44.0



2024-04-07 15:19:01

by Pauli Virtanen

[permalink] [raw]
Subject: [PATCH BlueZ 1/5] lib: add BT_POLL_ERRQUEUE socket option

Add new (experimental) socket option.
---
lib/bluetooth.h | 2 ++
1 file changed, 2 insertions(+)

diff --git a/lib/bluetooth.h b/lib/bluetooth.h
index a4ed65d0b..073ed875d 100644
--- a/lib/bluetooth.h
+++ b/lib/bluetooth.h
@@ -240,6 +240,8 @@ enum {

#define BT_ISO_BASE 20

+#define BT_POLL_ERRQUEUE 21
+
/* Byte order conversions */
#if __BYTE_ORDER == __LITTLE_ENDIAN
#define htobs(d) (d)
--
2.44.0


2024-04-07 15:19:04

by Pauli Virtanen

[permalink] [raw]
Subject: [PATCH BlueZ 4/5] iso-tester: add test for BT_POLL_ERRQUEUE

Also test BT_POLL_ERRQUEUE is experimental feature.

Add test:

ISO Send - TX No Poll Timestamping
---
tools/iso-tester.c | 124 ++++++++++++++++++++++++++++++++++++++++++++-
tools/tester.h | 3 ++
2 files changed, 125 insertions(+), 2 deletions(-)

diff --git a/tools/iso-tester.c b/tools/iso-tester.c
index c29fedd1d..046606068 100644
--- a/tools/iso-tester.c
+++ b/tools/iso-tester.c
@@ -470,7 +470,7 @@ struct test_data {
uint16_t handle;
uint16_t acl_handle;
struct queue *io_queue;
- unsigned int io_id[3];
+ unsigned int io_id[4];
uint8_t client_num;
int step;
bool reconnect;
@@ -513,6 +513,9 @@ struct iso_client_data {
* Used for testing TX timestamping OPT_ID.
*/
unsigned int repeat_send;
+
+ /* Disable BT_POLL_ERRQUEUE before enabling TX timestamping */
+ bool no_poll_errqueue;
};

typedef bool (*iso_defer_accept_t)(struct test_data *data, GIOChannel *io);
@@ -648,6 +651,18 @@ static const uint8_t reset_iso_socket_param[] = {
0x00, /* Action - disable */
};

+static const uint8_t set_poll_errqueue_param[] = {
+ 0x33, 0x57, 0x7b, 0xb4, 0x21, 0xc0, 0xc1, 0x8b, /* UUID */
+ 0x79, 0x46, 0x9f, 0xb6, 0x4c, 0x8c, 0x51, 0x69,
+ 0x01, /* Action - enable */
+};
+
+static const uint8_t reset_poll_errqueue_param[] = {
+ 0x33, 0x57, 0x7b, 0xb4, 0x21, 0xc0, 0xc1, 0x8b, /* UUID */
+ 0x79, 0x46, 0x9f, 0xb6, 0x4c, 0x8c, 0x51, 0x69,
+ 0x00, /* Action - disable */
+};
+
static void set_iso_socket_callback(uint8_t status, uint16_t length,
const void *param, void *user_data)
{
@@ -659,9 +674,21 @@ static void set_iso_socket_callback(uint8_t status, uint16_t length,
tester_print("ISO socket feature is enabled");
}

+static void set_poll_errqueue_callback(uint8_t status, uint16_t length,
+ const void *param, void *user_data)
+{
+ if (status != MGMT_STATUS_SUCCESS) {
+ tester_print("Poll Errqueue feature could not be enabled");
+ return;
+ }
+
+ tester_print("Poll Errqueue feature is enabled");
+}
+
static void test_pre_setup(const void *test_data)
{
struct test_data *data = tester_get_data();
+ const struct iso_client_data *isodata = test_data;

data->mgmt = mgmt_new_default();
if (!data->mgmt) {
@@ -677,6 +704,13 @@ static void test_pre_setup(const void *test_data)
sizeof(set_iso_socket_param), set_iso_socket_param,
set_iso_socket_callback, NULL, NULL);

+ if (isodata && isodata->no_poll_errqueue) {
+ mgmt_send(data->mgmt, MGMT_OP_SET_EXP_FEATURE, MGMT_INDEX_NONE,
+ sizeof(set_poll_errqueue_param),
+ set_poll_errqueue_param,
+ set_poll_errqueue_callback, NULL, NULL);
+ }
+
mgmt_send(data->mgmt, MGMT_OP_READ_INDEX_LIST, MGMT_INDEX_NONE, 0, NULL,
read_index_list_callback, NULL, NULL);
}
@@ -684,11 +718,19 @@ static void test_pre_setup(const void *test_data)
static void test_post_teardown(const void *test_data)
{
struct test_data *data = tester_get_data();
+ const struct iso_client_data *isodata = test_data;

mgmt_send(data->mgmt, MGMT_OP_SET_EXP_FEATURE, MGMT_INDEX_NONE,
sizeof(reset_iso_socket_param), reset_iso_socket_param,
NULL, NULL, NULL);

+ if (isodata && isodata->no_poll_errqueue) {
+ mgmt_send(data->mgmt, MGMT_OP_SET_EXP_FEATURE, MGMT_INDEX_NONE,
+ sizeof(reset_poll_errqueue_param),
+ reset_poll_errqueue_param,
+ NULL, NULL, NULL);
+ }
+
hciemu_unref(data->hciemu);
data->hciemu = NULL;
}
@@ -1044,6 +1086,16 @@ static const struct iso_client_data connect_send_tx_cmsg_timestamping = {
.cmsg_timestamping = true,
};

+static const struct iso_client_data connect_send_tx_no_poll_timestamping = {
+ .qos = QOS_16_2_1,
+ .expect_err = 0,
+ .send = &send_16_2_1,
+ .so_timestamping = (SOF_TIMESTAMPING_SOFTWARE |
+ SOF_TIMESTAMPING_TX_SOFTWARE),
+ .repeat_send = 1,
+ .no_poll_errqueue = true,
+};
+
static const struct iso_client_data listen_16_2_1_recv = {
.qos = QOS_16_2_1,
.expect_err = 0,
@@ -2162,6 +2214,37 @@ static gboolean iso_recv_errqueue(GIOChannel *io, GIOCondition cond,
return FALSE;
}

+static gboolean iso_fail_errqueue(GIOChannel *io, GIOCondition cond,
+ gpointer user_data)
+{
+ struct test_data *data = user_data;
+
+ tester_warn("Unexpected POLLERR");
+ tester_test_failed();
+
+ data->io_id[3] = 0;
+ return FALSE;
+}
+
+static gboolean iso_timer_errqueue(gpointer user_data)
+{
+ struct test_data *data = user_data;
+ GIOChannel *io;
+ gboolean ret;
+
+ io = queue_peek_head(data->io_queue);
+ g_assert(io);
+
+ ret = iso_recv_errqueue(io, G_IO_IN, data);
+ if (!ret) {
+ if (data->io_id[3])
+ g_source_remove(data->io_id[3]);
+ data->io_id[3] = 0;
+ }
+
+ return ret;
+}
+
static void iso_tx_timestamping(struct test_data *data, GIOChannel *io)
{
const struct iso_client_data *isodata = data->test_data;
@@ -2182,7 +2265,39 @@ static void iso_tx_timestamping(struct test_data *data, GIOChannel *io)

sk = g_io_channel_unix_get_fd(io);

- data->io_id[2] = g_io_add_watch(io, G_IO_ERR, iso_recv_errqueue, data);
+ if (isodata->no_poll_errqueue) {
+ uint32_t flag = 0;
+
+ err = setsockopt(sk, SOL_BLUETOOTH, BT_POLL_ERRQUEUE,
+ &flag, sizeof(flag));
+ if (err < 0) {
+ tester_warn("setsockopt BT_POLL_ERRQUEUE: %s (%d)",
+ strerror(errno), errno);
+ tester_test_failed();
+ return;
+ }
+
+ if (!data->io_queue)
+ data->io_queue = queue_new();
+ queue_push_head(data->io_queue, g_io_channel_ref(io));
+
+ data->io_id[2] = g_timeout_add(100, iso_timer_errqueue, data);
+ data->io_id[3] = g_io_add_watch(io, G_IO_ERR, iso_fail_errqueue,
+ data);
+ } else {
+ uint32_t flag = 1;
+
+ err = setsockopt(sk, SOL_BLUETOOTH, BT_POLL_ERRQUEUE,
+ &flag, sizeof(flag));
+ if (err >= 0) {
+ tester_warn("BT_POLL_ERRQUEUE available");
+ tester_test_failed();
+ return;
+ }
+
+ data->io_id[2] = g_io_add_watch(io, G_IO_ERR, iso_recv_errqueue,
+ data);
+ }

if (isodata->cmsg_timestamping)
so &= ~SOF_TIMESTAMPING_TX_RECORD_MASK;
@@ -3407,6 +3522,11 @@ int main(int argc, char *argv[])
&connect_send_tx_cmsg_timestamping, setup_powered,
test_connect);

+ /* Test TX timestamping and disabling POLLERR wakeup */
+ test_iso("ISO Send - TX No Poll Timestamping",
+ &connect_send_tx_no_poll_timestamping, setup_powered,
+ test_connect);
+
test_iso("ISO Receive - Success", &listen_16_2_1_recv, setup_powered,
test_listen);

diff --git a/tools/tester.h b/tools/tester.h
index 617de842e..b6de084a4 100644
--- a/tools/tester.h
+++ b/tools/tester.h
@@ -89,6 +89,9 @@ static inline int tx_tstamp_recv(struct tx_tstamp_data *data, int sk, int len)

ret = recvmsg(sk, &msg, MSG_ERRQUEUE);
if (ret < 0) {
+ if (ret == EAGAIN || ret == EWOULDBLOCK)
+ return data->count - data->pos;
+
tester_warn("Failed to read from errqueue: %s (%d)",
strerror(errno), errno);
return -EINVAL;
--
2.44.0


2024-04-07 15:19:07

by Pauli Virtanen

[permalink] [raw]
Subject: [PATCH BlueZ 2/5] adapter: add support for setting POLL_ERRQUEUE experimental feature

Add support for setting an experimental feature UUID which enables the
use of the BT_POLL_ERRQUEUE socket option.

Change adapter initialization to read and set also INDEX_NONE features.
This may set them multiple times, but this is harmless and it is simpler
to use the same framework.
---
src/adapter.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++---
src/adapter.h | 1 +
src/main.c | 1 +
src/main.conf | 1 +
4 files changed, 72 insertions(+), 3 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index 017e60233..1a9e28bed 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -148,6 +148,13 @@ static const struct mgmt_exp_uuid iso_socket_uuid = {
.str = "6fbaf188-05e0-496a-9885-d6ddfdb4e03e"
};

+/* 69518c4c-b69f-4679-8bc1-c021b47b5733 */
+static const struct mgmt_exp_uuid poll_errqueue_uuid = {
+ .val = { 0x33, 0x57, 0x7b, 0xb4, 0x21, 0xc0, 0xc1, 0x8b,
+ 0x79, 0x46, 0x9f, 0xb6, 0x4c, 0x8c, 0x51, 0x69 },
+ .str = "69518c4c-b69f-4679-8bc1-c021b47b5733"
+};
+
static DBusConnection *dbus_conn = NULL;

static uint32_t kernel_features = 0;
@@ -10027,6 +10034,44 @@ static void iso_socket_func(struct btd_adapter *adapter, uint8_t action)
btd_error(adapter->dev_id, "Failed to set ISO Socket");
}

+static void poll_errqueue_complete(uint8_t status, uint16_t len,
+ const void *param, void *user_data)
+{
+ struct exp_pending *pending = user_data;
+ struct btd_adapter *adapter = pending->adapter;
+ uint8_t action;
+
+ if (status != 0) {
+ error("Set Poll Errqueue failed with status 0x%02x (%s)",
+ status, mgmt_errstr(status));
+ return;
+ }
+
+ action = btd_kernel_experimental_enabled(poll_errqueue_uuid.str);
+
+ DBG("Poll Errqueue successfully %s", action ? "set" : "reset");
+
+ if (action)
+ queue_push_tail(adapter->exps,
+ (void *)poll_errqueue_uuid.val);
+}
+
+static void poll_errqueue_func(struct btd_adapter *adapter, uint8_t action)
+{
+ struct mgmt_cp_set_exp_feature cp;
+
+ memset(&cp, 0, sizeof(cp));
+ memcpy(cp.uuid, poll_errqueue_uuid.val, 16);
+ cp.action = action;
+
+ if (exp_mgmt_send(adapter, MGMT_OP_SET_EXP_FEATURE,
+ MGMT_INDEX_NONE, sizeof(cp), &cp,
+ poll_errqueue_complete))
+ return;
+
+ btd_error(adapter->dev_id, "Failed to set Poll Errqueue");
+}
+
static const struct exp_feat {
uint32_t flag;
const struct mgmt_exp_uuid *uuid;
@@ -10041,6 +10086,8 @@ static const struct exp_feat {
EXP_FEAT(EXP_FEAT_CODEC_OFFLOAD, &codec_offload_uuid,
codec_offload_func),
EXP_FEAT(EXP_FEAT_ISO_SOCKET, &iso_socket_uuid, iso_socket_func),
+ EXP_FEAT(EXP_FEAT_POLL_ERRQUEUE, &poll_errqueue_uuid,
+ poll_errqueue_func),
};

static void read_exp_features_complete(uint8_t status, uint16_t length,
@@ -10052,8 +10099,6 @@ static void read_exp_features_complete(uint8_t status, uint16_t length,
size_t feature_count = 0;
size_t i = 0;

- DBG("index %u status 0x%02x", adapter->dev_id, status);
-
if (status != MGMT_STATUS_SUCCESS) {
btd_error(adapter->dev_id,
"Failed to read exp features info: %s (0x%02x)",
@@ -10105,10 +10150,31 @@ static void read_exp_features_complete(uint8_t status, uint16_t length,
}
}

+static void read_exp_features_adapter_complete(uint8_t status, uint16_t length,
+ const void *param, void *user_data)
+{
+ struct exp_pending *pending = user_data;
+ struct btd_adapter *adapter = pending->adapter;
+
+ DBG("index %u status 0x%02x", adapter->dev_id, status);
+ return read_exp_features_complete(status, length, param, user_data);
+}
+
+static void read_exp_features_none_complete(uint8_t status, uint16_t length,
+ const void *param, void *user_data)
+{
+ DBG("index NONE status 0x%02x", status);
+ return read_exp_features_complete(status, length, param, user_data);
+}
+
static void read_exp_features(struct btd_adapter *adapter)
{
if (exp_mgmt_send(adapter, MGMT_OP_READ_EXP_FEATURES_INFO,
- adapter->dev_id, 0, NULL, read_exp_features_complete))
+ adapter->dev_id, 0, NULL,
+ read_exp_features_adapter_complete) &&
+ exp_mgmt_send(adapter, MGMT_OP_READ_EXP_FEATURES_INFO,
+ MGMT_INDEX_NONE, 0, NULL,
+ read_exp_features_none_complete))
return;

btd_error(adapter->dev_id, "Failed to read exp features info");
diff --git a/src/adapter.h b/src/adapter.h
index ca96c1f65..2ca045539 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -268,6 +268,7 @@ enum experimental_features {
EXP_FEAT_RPA_RESOLUTION = 1 << 3,
EXP_FEAT_CODEC_OFFLOAD = 1 << 4,
EXP_FEAT_ISO_SOCKET = 1 << 5,
+ EXP_FEAT_POLL_ERRQUEUE = 1 << 6,
};

bool btd_adapter_has_exp_feature(struct btd_adapter *adapter, uint32_t feature);
diff --git a/src/main.c b/src/main.c
index f774670e4..78831ad02 100644
--- a/src/main.c
+++ b/src/main.c
@@ -707,6 +707,7 @@ static const char *valid_uuids[] = {
"330859bc-7506-492d-9370-9a6f0614037f",
"a6695ace-ee7f-4fb9-881a-5fac66c629af",
"6fbaf188-05e0-496a-9885-d6ddfdb4e03e",
+ "69518c4c-b69f-4679-8bc1-c021b47b5733",
"*"
};

diff --git a/src/main.conf b/src/main.conf
index 815f1c0f8..49864b5c3 100644
--- a/src/main.conf
+++ b/src/main.conf
@@ -136,6 +136,7 @@
# 330859bc-7506-492d-9370-9a6f0614037f (BlueZ Experimental Bluetooth Quality Report)
# a6695ace-ee7f-4fb9-881a-5fac66c629af (BlueZ Experimental Offload Codecs)
# 6fbaf188-05e0-496a-9885-d6ddfdb4e03e (BlueZ Experimental ISO socket)
+# 69518c4c-b69f-4679-8bc1-c021b47b5733 (BlueZ Experimental Poll Errqueue)
# Defaults to false.
#KernelExperimental = false

--
2.44.0


2024-04-07 15:19:07

by Pauli Virtanen

[permalink] [raw]
Subject: [PATCH BlueZ 3/5] mgmt-tester: update for Poll Errqueue experimental fature

Update Read Exp Feature - Success (Index None) for new experimental
feature Poll Errqueue.
---
tools/mgmt-tester.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c
index 8a4fbc2eb..81636200e 100644
--- a/tools/mgmt-tester.c
+++ b/tools/mgmt-tester.c
@@ -9985,7 +9985,7 @@ static const struct generic_data read_exp_feat_success = {


static const uint8_t read_exp_feat_param_success_index_none[] = {
- 0x02, 0x00, /* Feature Count */
+ 0x03, 0x00, /* Feature Count */
0x1c, 0xda, 0x47, 0x1c, 0x48, 0x6c, /* UUID - Debug */
0x01, 0xab, 0x9f, 0x46, 0xec, 0xb9,
0x30, 0x25, 0x99, 0xd4,
@@ -9994,6 +9994,10 @@ static const uint8_t read_exp_feat_param_success_index_none[] = {
0x85, 0x98, 0x6a, 0x49, 0xe0, 0x05,
0x88, 0xf1, 0xba, 0x6f,
0x00, 0x00, 0x00, 0x00, /* Flags */
+ 0x33, 0x57, 0x7b, 0xb4, 0x21, 0xc0, /* UUID - Poll Errqueue */
+ 0xc1, 0x8b, 0x79, 0x46, 0x9f, 0xb6,
+ 0x4c, 0x8c, 0x51, 0x69,
+ 0x00, 0x00, 0x00, 0x00, /* Flags */
};

static const struct generic_data read_exp_feat_success_index_none = {
--
2.44.0


2024-04-07 15:19:09

by Pauli Virtanen

[permalink] [raw]
Subject: [PATCH BlueZ 5/5] shared/util: add uuid for Poll Errqueue experimental feature

Add UUID for Poll Errqueue experimental feature to bt_uuidstr_to_str().
---
src/shared/util.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/src/shared/util.c b/src/shared/util.c
index 0e71fda02..ee59b94a0 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -1653,6 +1653,8 @@ static const struct {
{ "a6695ace-ee7f-4fb9-881a-5fac66c629af", "BlueZ Offload Codecs"},
{ "6fbaf188-05e0-496a-9885-d6ddfdb4e03e",
"BlueZ Experimental ISO Socket"},
+ { "69518c4c-b69f-4679-8bc1-c021b47b5733",
+ "BlueZ Experimental Poll Errqueue"},
{ }
};

--
2.44.0


2024-04-07 18:53:33

by bluez.test.bot

[permalink] [raw]
Subject: RE: Add BT_POLL_ERRQUEUE experimental feature and tests

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=842181

---Test result---

Test Summary:
CheckPatch PASS 2.39 seconds
GitLint PASS 1.59 seconds
BuildEll PASS 24.74 seconds
BluezMake PASS 1745.40 seconds
MakeCheck PASS 16.42 seconds
MakeDistcheck PASS 179.83 seconds
CheckValgrind PASS 249.66 seconds
CheckSmatch PASS 357.23 seconds
bluezmakeextell PASS 121.04 seconds
IncrementalBuild PASS 8023.76 seconds
ScanBuild PASS 1012.32 seconds



---
Regards,
Linux Bluetooth

2024-04-08 07:33:47

by Pauli Virtanen

[permalink] [raw]
Subject: Re: [PATCH BlueZ 4/5] iso-tester: add test for BT_POLL_ERRQUEUE



7. huhtikuuta 2024 18.18.37 GMT+03:00 Pauli Virtanen <[email protected]> kirjoitti:
>Also test BT_POLL_ERRQUEUE is experimental feature.
>
>Add test:
>
>ISO Send - TX No Poll Timestamping
>---
> tools/iso-tester.c | 124 ++++++++++++++++++++++++++++++++++++++++++++-
> tools/tester.h | 3 ++
> 2 files changed, 125 insertions(+), 2 deletions(-)
>
>diff --git a/tools/iso-tester.c b/tools/iso-tester.c
>index c29fedd1d..046606068 100644
>--- a/tools/iso-tester.c
>+++ b/tools/iso-tester.c
>@@ -470,7 +470,7 @@ struct test_data {
> uint16_t handle;
> uint16_t acl_handle;
> struct queue *io_queue;
>- unsigned int io_id[3];
>+ unsigned int io_id[4];
> uint8_t client_num;
> int step;
> bool reconnect;
>@@ -513,6 +513,9 @@ struct iso_client_data {
> * Used for testing TX timestamping OPT_ID.
> */
> unsigned int repeat_send;
>+
>+ /* Disable BT_POLL_ERRQUEUE before enabling TX timestamping */
>+ bool no_poll_errqueue;
> };
>
> typedef bool (*iso_defer_accept_t)(struct test_data *data, GIOChannel *io);
>@@ -648,6 +651,18 @@ static const uint8_t reset_iso_socket_param[] = {
> 0x00, /* Action - disable */
> };
>
>+static const uint8_t set_poll_errqueue_param[] = {
>+ 0x33, 0x57, 0x7b, 0xb4, 0x21, 0xc0, 0xc1, 0x8b, /* UUID */
>+ 0x79, 0x46, 0x9f, 0xb6, 0x4c, 0x8c, 0x51, 0x69,
>+ 0x01, /* Action - enable */
>+};
>+
>+static const uint8_t reset_poll_errqueue_param[] = {
>+ 0x33, 0x57, 0x7b, 0xb4, 0x21, 0xc0, 0xc1, 0x8b, /* UUID */
>+ 0x79, 0x46, 0x9f, 0xb6, 0x4c, 0x8c, 0x51, 0x69,
>+ 0x00, /* Action - disable */
>+};
>+
> static void set_iso_socket_callback(uint8_t status, uint16_t length,
> const void *param, void *user_data)
> {
>@@ -659,9 +674,21 @@ static void set_iso_socket_callback(uint8_t status, uint16_t length,
> tester_print("ISO socket feature is enabled");
> }
>
>+static void set_poll_errqueue_callback(uint8_t status, uint16_t length,
>+ const void *param, void *user_data)
>+{
>+ if (status != MGMT_STATUS_SUCCESS) {
>+ tester_print("Poll Errqueue feature could not be enabled");
>+ return;
>+ }
>+
>+ tester_print("Poll Errqueue feature is enabled");
>+}
>+
> static void test_pre_setup(const void *test_data)
> {
> struct test_data *data = tester_get_data();
>+ const struct iso_client_data *isodata = test_data;
>
> data->mgmt = mgmt_new_default();
> if (!data->mgmt) {
>@@ -677,6 +704,13 @@ static void test_pre_setup(const void *test_data)
> sizeof(set_iso_socket_param), set_iso_socket_param,
> set_iso_socket_callback, NULL, NULL);
>
>+ if (isodata && isodata->no_poll_errqueue) {
>+ mgmt_send(data->mgmt, MGMT_OP_SET_EXP_FEATURE, MGMT_INDEX_NONE,
>+ sizeof(set_poll_errqueue_param),
>+ set_poll_errqueue_param,
>+ set_poll_errqueue_callback, NULL, NULL);
>+ }
>+
> mgmt_send(data->mgmt, MGMT_OP_READ_INDEX_LIST, MGMT_INDEX_NONE, 0, NULL,
> read_index_list_callback, NULL, NULL);
> }
>@@ -684,11 +718,19 @@ static void test_pre_setup(const void *test_data)
> static void test_post_teardown(const void *test_data)
> {
> struct test_data *data = tester_get_data();
>+ const struct iso_client_data *isodata = test_data;
>
> mgmt_send(data->mgmt, MGMT_OP_SET_EXP_FEATURE, MGMT_INDEX_NONE,
> sizeof(reset_iso_socket_param), reset_iso_socket_param,
> NULL, NULL, NULL);
>
>+ if (isodata && isodata->no_poll_errqueue) {
>+ mgmt_send(data->mgmt, MGMT_OP_SET_EXP_FEATURE, MGMT_INDEX_NONE,
>+ sizeof(reset_poll_errqueue_param),
>+ reset_poll_errqueue_param,
>+ NULL, NULL, NULL);
>+ }
>+
> hciemu_unref(data->hciemu);
> data->hciemu = NULL;
> }
>@@ -1044,6 +1086,16 @@ static const struct iso_client_data connect_send_tx_cmsg_timestamping = {
> .cmsg_timestamping = true,
> };
>
>+static const struct iso_client_data connect_send_tx_no_poll_timestamping = {
>+ .qos = QOS_16_2_1,
>+ .expect_err = 0,
>+ .send = &send_16_2_1,
>+ .so_timestamping = (SOF_TIMESTAMPING_SOFTWARE |
>+ SOF_TIMESTAMPING_TX_SOFTWARE),
>+ .repeat_send = 1,
>+ .no_poll_errqueue = true,
>+};
>+
> static const struct iso_client_data listen_16_2_1_recv = {
> .qos = QOS_16_2_1,
> .expect_err = 0,
>@@ -2162,6 +2214,37 @@ static gboolean iso_recv_errqueue(GIOChannel *io, GIOCondition cond,
> return FALSE;
> }
>
>+static gboolean iso_fail_errqueue(GIOChannel *io, GIOCondition cond,
>+ gpointer user_data)
>+{
>+ struct test_data *data = user_data;
>+
>+ tester_warn("Unexpected POLLERR");
>+ tester_test_failed();
>+
>+ data->io_id[3] = 0;
>+ return FALSE;
>+}
>+
>+static gboolean iso_timer_errqueue(gpointer user_data)
>+{
>+ struct test_data *data = user_data;
>+ GIOChannel *io;
>+ gboolean ret;
>+
>+ io = queue_peek_head(data->io_queue);
>+ g_assert(io);
>+
>+ ret = iso_recv_errqueue(io, G_IO_IN, data);
>+ if (!ret) {
>+ if (data->io_id[3])
>+ g_source_remove(data->io_id[3]);
>+ data->io_id[3] = 0;
>+ }
>+
>+ return ret;
>+}
>+
> static void iso_tx_timestamping(struct test_data *data, GIOChannel *io)
> {
> const struct iso_client_data *isodata = data->test_data;
>@@ -2182,7 +2265,39 @@ static void iso_tx_timestamping(struct test_data *data, GIOChannel *io)
>
> sk = g_io_channel_unix_get_fd(io);
>
>- data->io_id[2] = g_io_add_watch(io, G_IO_ERR, iso_recv_errqueue, data);
>+ if (isodata->no_poll_errqueue) {
>+ uint32_t flag = 0;
>+
>+ err = setsockopt(sk, SOL_BLUETOOTH, BT_POLL_ERRQUEUE,
>+ &flag, sizeof(flag));
>+ if (err < 0) {
>+ tester_warn("setsockopt BT_POLL_ERRQUEUE: %s (%d)",
>+ strerror(errno), errno);
>+ tester_test_failed();
>+ return;
>+ }
>+
>+ if (!data->io_queue)
>+ data->io_queue = queue_new();
>+ queue_push_head(data->io_queue, g_io_channel_ref(io));
>+
>+ data->io_id[2] = g_timeout_add(100, iso_timer_errqueue, data);
>+ data->io_id[3] = g_io_add_watch(io, G_IO_ERR, iso_fail_errqueue,
>+ data);
>+ } else {
>+ uint32_t flag = 1;
>+
>+ err = setsockopt(sk, SOL_BLUETOOTH, BT_POLL_ERRQUEUE,
>+ &flag, sizeof(flag));
>+ if (err >= 0) {
>+ tester_warn("BT_POLL_ERRQUEUE available");
>+ tester_test_failed();
>+ return;
>+ }
>+
>+ data->io_id[2] = g_io_add_watch(io, G_IO_ERR, iso_recv_errqueue,
>+ data);
>+ }
>
> if (isodata->cmsg_timestamping)
> so &= ~SOF_TIMESTAMPING_TX_RECORD_MASK;
>@@ -3407,6 +3522,11 @@ int main(int argc, char *argv[])
> &connect_send_tx_cmsg_timestamping, setup_powered,
> test_connect);
>
>+ /* Test TX timestamping and disabling POLLERR wakeup */
>+ test_iso("ISO Send - TX No Poll Timestamping",
>+ &connect_send_tx_no_poll_timestamping, setup_powered,
>+ test_connect);
>+
> test_iso("ISO Receive - Success", &listen_16_2_1_recv, setup_powered,
> test_listen);
>
>diff --git a/tools/tester.h b/tools/tester.h
>index 617de842e..b6de084a4 100644
>--- a/tools/tester.h
>+++ b/tools/tester.h
>@@ -89,6 +89,9 @@ static inline int tx_tstamp_recv(struct tx_tstamp_data *data, int sk, int len)
>
> ret = recvmsg(sk, &msg, MSG_ERRQUEUE);
> if (ret < 0) {
>+ if (ret == EAGAIN || ret == EWOULDBLOCK)

This should have been errno, not ret.

-> v2

>+ return data->count - data->pos;
>+
> tester_warn("Failed to read from errqueue: %s (%d)",
> strerror(errno), errno);
> return -EINVAL;

2024-04-10 16:40:47

by patchwork-bot+bluetooth

[permalink] [raw]
Subject: Re: [PATCH BlueZ 0/5] Add BT_POLL_ERRQUEUE experimental feature and tests

Hello:

This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <[email protected]>:

On Sun, 7 Apr 2024 18:18:33 +0300 you wrote:
> Add BT_POLL_ERRQUEUE mgmt experimental feature, and tests for the
> corresponding socket option.
>
> Pauli Virtanen (5):
> lib: add BT_POLL_ERRQUEUE socket option
> adapter: add support for setting POLL_ERRQUEUE experimental feature
> mgmt-tester: update for Poll Errqueue experimental fature
> iso-tester: add test for BT_POLL_ERRQUEUE
> shared/util: add uuid for Poll Errqueue experimental feature
>
> [...]

Here is the summary with links:
- [BlueZ,1/5] lib: add BT_POLL_ERRQUEUE socket option
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=138e97020d5f
- [BlueZ,2/5] adapter: add support for setting POLL_ERRQUEUE experimental feature
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=e1c178f96a07
- [BlueZ,3/5] mgmt-tester: update for Poll Errqueue experimental fature
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=c777c55ab662
- [BlueZ,4/5] iso-tester: add test for BT_POLL_ERRQUEUE
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=141f66411ca4
- [BlueZ,5/5] shared/util: add uuid for Poll Errqueue experimental feature
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=fe71fa3dfe26

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html