From patchwork Mon Dec 21 23:01:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 11985365 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D20EC433E0 for ; Mon, 21 Dec 2020 23:02:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 637C2229CA for ; Mon, 21 Dec 2020 23:02:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726139AbgLUXCY (ORCPT ); Mon, 21 Dec 2020 18:02:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725844AbgLUXCY (ORCPT ); Mon, 21 Dec 2020 18:02:24 -0500 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08549C0613D3 for ; Mon, 21 Dec 2020 15:01:44 -0800 (PST) Received: by mail-pj1-x1032.google.com with SMTP id b5so292294pjl.0 for ; Mon, 21 Dec 2020 15:01:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=+D78R+KUxlxs8S2JpfeUAyag+Ph+68TNR9WVVh4II7k=; b=dGqVhadeuKjDYEfja+R5Urvt9MjBu2Y/uW4K28v9aJdwDRucfKSYXRG/BNpTIdmKMt pjxSNMbcdWck1RxeN4UNtdcxm2xPtdisvistIUZzVcVEOmaYi2d8rgAP+92kP/1Ekxq/ aU2mEE2saPdacN09xE64HLBS6XHt+sXWsFPCjiGw1QdEevQE60Rg1UBjreqM+VrvXJkj lliCyNNsdhmaOj2RqCGcmX7PrPfObfykpxRSmWxFbz4/c4qr44dP36t1nHJPb7Nmc2Vw rJYxatboNTbDe/lvGMgLqn8HkRDiIeji7SWQF5topwGOuhIBOAS7RSOdJ0AYx8ev/Dls /Jhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=+D78R+KUxlxs8S2JpfeUAyag+Ph+68TNR9WVVh4II7k=; b=YJ1XWR64RjIoZ6Y+v0HTDt6tOC3t4F3enSMSSiju2M8trYHO6THX5y9EB5v0xGKNV9 QL4ugqjJdgFftSdXVwrDBwMYVHCaih6XIo5HPpGNSDc8I+QXM1q4RW59daZ1ALRQ7ZgM Jdvw0ez/yRHPhIzaV3jyg0x5UmIp/FsTJyk05VQMDXhaI7EccPj1SBIB9skEVHibeMAF vAze7WJ+PgJZCt/EnTqGe5VT27WN9UCVa0ZXgEXHmbxNGIO8qsDllR0FVySEVidQTU3j 4UOqOh7LdC7RjN644F1iS8JRZbih1KseP3NCALv4grJi/zOVZCyC2qzAo0c7LHmYz0xK RPTg== X-Gm-Message-State: AOAM533Mc3vcbFuGMSsD+DPVWA8wqXAN5LudONr4BqVKmVsZ3/krDJrU /En+dSzTn8G1zgwiExMBUwaj3gU2wJg= X-Google-Smtp-Source: ABdhPJzVpwoY9BTAsgbEW428cH8aQQOHoYmOZSJqpx8vR+3kh5WKa5f5QZ6tRgspC+VysHSw9ILRcA== X-Received: by 2002:a17:902:b116:b029:dc:c93:1d6b with SMTP id q22-20020a170902b116b02900dc0c931d6bmr741588plr.22.1608591702665; Mon, 21 Dec 2020 15:01:42 -0800 (PST) Received: from localhost.localdomain (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id a19sm17131855pfi.130.2020.12.21.15.01.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Dec 2020 15:01:41 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 1/4] lib: Add definitions for ISO socket Date: Mon, 21 Dec 2020 15:01:37 -0800 Message-Id: <20201221230140.2100824-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz --- lib/bluetooth.h | 24 ++++++++++++++++++++++++ lib/iso.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 lib/iso.h diff --git a/lib/bluetooth.h b/lib/bluetooth.h index 9ab033ec4..0d4557377 100644 --- a/lib/bluetooth.h +++ b/lib/bluetooth.h @@ -37,6 +37,7 @@ extern "C" { #define BTPROTO_CMTP 5 #define BTPROTO_HIDP 6 #define BTPROTO_AVDTP 7 +#define BTPROTO_ISO 8 #define SOL_HCI 0 #define SOL_L2CAP 6 @@ -140,6 +141,29 @@ struct bt_voice { #define BT_SCM_PKT_STATUS 0x03 +#define BT_ISO_QOS 17 + +#define BT_ISO_QOS_CIG_UNSET 0xff +#define BT_ISO_QOS_CIS_UNSET 0xff + +struct bt_iso_io_qos { + uint32_t interval; + uint16_t latency; + uint16_t sdu; + uint8_t phy; + uint8_t rtn; +}; + +struct bt_iso_qos { + uint8_t cig; + uint8_t cis; + uint8_t sca; + uint8_t packing; + uint8_t framing; + struct bt_iso_io_qos in; + struct bt_iso_io_qos out; +}; + /* Connection and socket states */ enum { BT_CONNECTED = 1, /* Equal to TCP_ESTABLISHED to make net code happy */ diff --git a/lib/iso.h b/lib/iso.h new file mode 100644 index 000000000..2d427b417 --- /dev/null +++ b/lib/iso.h @@ -0,0 +1,45 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2019 Intel Corporation. + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef __ISO_H +#define __ISO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* ISO defaults */ +#define ISO_DEFAULT_MTU 251 + +/* ISO socket address */ +struct sockaddr_iso { + sa_family_t iso_family; + bdaddr_t iso_bdaddr; + uint8_t iso_bdaddr_type; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* __ISO_H */ From patchwork Mon Dec 21 23:01:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 11985367 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,UNWANTED_LANGUAGE_BODY,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F8DBC433E6 for ; Mon, 21 Dec 2020 23:02:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2824F229CA for ; Mon, 21 Dec 2020 23:02:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726150AbgLUXCZ (ORCPT ); Mon, 21 Dec 2020 18:02:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725844AbgLUXCZ (ORCPT ); Mon, 21 Dec 2020 18:02:25 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2EA1C0613D6 for ; Mon, 21 Dec 2020 15:01:44 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id b5so292318pjl.0 for ; Mon, 21 Dec 2020 15:01:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=BfmpI0KTCdyAGKzQ+8ywEXg/zOYwXP89HRvv3RjC2NI=; b=fNe4fADUYN2jOmZwBEfAKQG9RspkLXAeLFEj67xZF4ASOJmEdE5BSuQ0lBAxheoHhk ohljTSXvEzblFs3tnrAP5a7bqaSb7CJuV1AVvtZp/wvp8ils1Ndo8GujymjM/+CMz9X7 f76bATOTGGGucEBKZ9tjJlIEdWy4DxJG16Ij7kXQAgQa1xRAdIG4qvvADhno8OJNg04j vcQ3XYpJS8wKKCDsgnMDIZu+ga934/MbcboL7xCJRjFkCoqOxxNwL8c0cKaEBgJlohvi v+WXk5sMJ0bCQ2vjqfb4Mh+s/wXHXMDC/h/d2xIKtybu1evjETKau2i3PJAuFiFv6QjR 9kGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BfmpI0KTCdyAGKzQ+8ywEXg/zOYwXP89HRvv3RjC2NI=; b=g8YWw24pImqvv7qGXpBIPPm5ieWbwLAn5YImuUgpp0X/5I26Wf2Vsv0VjfI+E600P1 NWNowAEdkXYcToCc92KmhmOC3BSapxPWPPOF5IoHeX7c6GzCLVutWVe3YUfTvhIn5xUG J+0iP6NpZ58IEWR0ZNxSZrsWUwd5/0lIg74erc2hrQG0fsuejpYVhsZEEFOAbiZBgola FnmUscb6l/zeQqtbvoMYfCtaF/ZqvbRubAB/g1HzVZU3H38ZxhD5TPuB+HSP7yX689wJ /0pMFPRcg8K/+DLHL0Tiq3hdnqqx9JBmmEu++UwCcQYWjZDz+rIBQYWW0vRsAq59hBmO 5KlQ== X-Gm-Message-State: AOAM533NQJt1fV082sc7ozMgSfxpm7js6vHDn16w7gqJSR7hSdTpqqf8 BV4mbjzw/ZOQa0fWDprCB61zFdgnq8A= X-Google-Smtp-Source: ABdhPJwSWTOKXT8i5lezOcxc1RYv8BW/5BMc9G5KGUX0l/9mQ5UjclLNgK96LqAtYpsr78Z/4fKI5g== X-Received: by 2002:a17:902:ff12:b029:db:d7b7:c99d with SMTP id f18-20020a170902ff12b02900dbd7b7c99dmr18290154plj.14.1608591703471; Mon, 21 Dec 2020 15:01:43 -0800 (PST) Received: from localhost.localdomain (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id a19sm17131855pfi.130.2020.12.21.15.01.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Dec 2020 15:01:42 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 2/4] tools: Add isotest tool Date: Mon, 21 Dec 2020 15:01:38 -0800 Message-Id: <20201221230140.2100824-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201221230140.2100824-1-luiz.dentz@gmail.com> References: <20201221230140.2100824-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This adds isotest tool which can be used to test ISO sockets. --- Makefile.tools | 5 +- tools/isotest.c | 845 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 849 insertions(+), 1 deletion(-) create mode 100644 tools/isotest.c diff --git a/Makefile.tools b/Makefile.tools index d5fdf2d89..c1eb2778a 100644 --- a/Makefile.tools +++ b/Makefile.tools @@ -191,7 +191,8 @@ noinst_PROGRAMS += tools/bdaddr tools/avinfo tools/avtest \ tools/eddystone tools/ibeacon \ tools/btgatt-client tools/btgatt-server \ tools/test-runner tools/check-selftest \ - tools/gatt-service profiles/iap/iapd + tools/gatt-service profiles/iap/iapd \ + tools/isotest tools_bdaddr_SOURCES = tools/bdaddr.c src/oui.h src/oui.c tools_bdaddr_LDADD = lib/libbluetooth-internal.la $(UDEV_LIBS) @@ -291,6 +292,8 @@ tools_gatt_service_LDADD = $(GLIB_LIBS) $(DBUS_LIBS) gdbus/libgdbus-internal.la profiles_iap_iapd_SOURCES = profiles/iap/main.c profiles_iap_iapd_LDADD = gdbus/libgdbus-internal.la $(GLIB_LIBS) $(DBUS_LIBS) +tools_isotest_LDADD = lib/libbluetooth-internal.la + dist_man_MANS += tools/rctest.1 tools/l2ping.1 tools/btattach.1 EXTRA_DIST += tools/bdaddr.1 diff --git a/tools/isotest.c b/tools/isotest.c new file mode 100644 index 000000000..6abe2fd8a --- /dev/null +++ b/tools/isotest.c @@ -0,0 +1,845 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2020 Intel Corporation. + * + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "lib/bluetooth.h" +#include "lib/hci.h" +#include "lib/hci_lib.h" +#include "lib/iso.h" + +#include "src/shared/util.h" + +/* Test modes */ +enum { + SEND, + RECV, + RECONNECT, + MULTY, + DUMP, + CONNECT +}; + +static unsigned char *buf; + +/* Default data size */ +static long data_size = 251; + +static bdaddr_t bdaddr; +static int bdaddr_type = BDADDR_LE_PUBLIC; + +static int defer_setup = 0; + +struct bt_iso_qos *iso_qos = NULL; +static bool inout; + +struct lookup_table { + const char *name; + int flag; +}; + +static struct lookup_table bdaddr_types[] = { + { "le_public", BDADDR_LE_PUBLIC }, + { "le_random", BDADDR_LE_RANDOM }, + { NULL, 0 }, +}; + +static int get_lookup_flag(struct lookup_table *table, char *name) +{ + int i; + + for (i = 0; table[i].name; i++) + if (!strcasecmp(table[i].name, name)) + return table[i].flag; + + return -1; +} + +static void print_lookup_values(struct lookup_table *table, char *header) +{ + int i; + + printf("%s\n", header); + + for (i = 0; table[i].name; i++) + printf("\t%s\n", table[i].name); +} + +static float tv2fl(struct timeval tv) +{ + return (float)tv.tv_sec + (float)(tv.tv_usec/1000000.0); +} + +static int do_connect(char *peer) +{ + struct sockaddr_iso addr; + struct bt_iso_qos qos; + socklen_t len; + int sk; + + /* Create socket */ + sk = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_ISO); + if (sk < 0) { + syslog(LOG_ERR, "Can't create socket: %s (%d)", + strerror(errno), errno); + return -1; + } + + /* Bind to local address */ + memset(&addr, 0, sizeof(addr)); + addr.iso_family = AF_BLUETOOTH; + bacpy(&addr.iso_bdaddr, &bdaddr); + addr.iso_bdaddr_type = bdaddr_type; + + if (bind(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) { + syslog(LOG_ERR, "Can't bind socket: %s (%d)", + strerror(errno), errno); + goto error; + } + + /* Set QoS if available */ + if (iso_qos) { + if (!inout) { + iso_qos->in.phy = 0x00; + iso_qos->in.sdu = 0; + } + + if (setsockopt(sk, SOL_BLUETOOTH, BT_ISO_QOS, iso_qos, + sizeof(*iso_qos)) < 0) { + syslog(LOG_ERR, "Can't set QoS socket option: " + "%s (%d)", strerror(errno), errno); + } + } + + /* Enable deferred setup */ + if (defer_setup && setsockopt(sk, SOL_BLUETOOTH, BT_DEFER_SETUP, + &defer_setup, sizeof(defer_setup)) < 0) { + syslog(LOG_ERR, "Can't enable deferred setup : %s (%d)", + strerror(errno), errno); + goto error; + } + + /* Connect to remote device */ + memset(&addr, 0, sizeof(addr)); + addr.iso_family = AF_BLUETOOTH; + str2ba(peer, &addr.iso_bdaddr); + addr.iso_bdaddr_type = bdaddr_type; + + syslog(LOG_INFO, "Connecting %s ...", peer); + + if (connect(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) { + syslog(LOG_ERR, "Can't connect: %s (%d)", + strerror(errno), errno); + goto error; + } + + /* Read Out QOS */ + memset(&qos, 0, sizeof(qos)); + len = sizeof(qos); + + if (getsockopt(sk, SOL_BLUETOOTH, BT_ISO_QOS, &qos, &len) < 0) { + syslog(LOG_ERR, "Can't get QoS socket option: %s (%d)", + strerror(errno), errno); + goto error; + } + + syslog(LOG_INFO, "Connected [%s]", peer); + syslog(LOG_INFO, "QoS [CIG 0x%02x CIS 0x%02x Packing 0x%02x " + "Framing 0x%02x]", qos.cig, qos.cis, qos.packing, qos.framing); + syslog(LOG_INFO, "Input QoS [Interval %u us Latency %u " + "ms SDU %u PHY 0x%02x RTN %u]", qos.in.interval, + qos.in.latency, qos.in.sdu, qos.in.phy, qos.in.rtn); + syslog(LOG_INFO, "Output QoS [Interval %u us Latency %u " + "ms SDU %u PHY 0x%02x RTN %u]", qos.out.interval, + qos.out.latency, qos.out.sdu, qos.out.phy, qos.out.rtn); + + return sk; + +error: + close(sk); + return -1; +} + +static void do_listen(char *filename, void (*handler)(int fd, int sk)) +{ + struct sockaddr_iso addr; + socklen_t optlen; + int sk, nsk, fd = -1; + char ba[18]; + + if (filename) { + fd = open(filename, O_WRONLY | O_CREAT | O_APPEND, 0644); + if (fd < 0) { + syslog(LOG_ERR, "Can't open file %s: %s\n", + filename, strerror(errno)); + exit(1); + } + } + + /* Create socket */ + sk = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_ISO); + if (sk < 0) { + syslog(LOG_ERR, "Can't create socket: %s (%d)", + strerror(errno), errno); + if (fd >= 0) + close(fd); + exit(1); + } + + /* Bind to local address */ + memset(&addr, 0, sizeof(addr)); + addr.iso_family = AF_BLUETOOTH; + bacpy(&addr.iso_bdaddr, &bdaddr); + addr.iso_bdaddr_type = bdaddr_type; + + if (bind(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) { + syslog(LOG_ERR, "Can't bind socket: %s (%d)", + strerror(errno), errno); + goto error; + } + + /* Enable deferred setup */ + if (defer_setup && setsockopt(sk, SOL_BLUETOOTH, BT_DEFER_SETUP, + &defer_setup, sizeof(defer_setup)) < 0) { + syslog(LOG_ERR, "Can't enable deferred setup : %s (%d)", + strerror(errno), errno); + goto error; + } + + /* Listen for connections */ + if (listen(sk, 10)) { + syslog(LOG_ERR,"Can not listen on the socket: %s (%d)", + strerror(errno), errno); + goto error; + } + + syslog(LOG_INFO,"Waiting for connection ..."); + + while (1) { + memset(&addr, 0, sizeof(addr)); + optlen = sizeof(addr); + + nsk = accept(sk, (struct sockaddr *) &addr, &optlen); + if (nsk < 0) { + syslog(LOG_ERR,"Accept failed: %s (%d)", + strerror(errno), errno); + goto error; + } + if (fork()) { + /* Parent */ + close(nsk); + continue; + } + /* Child */ + close(sk); + + ba2str(&addr.iso_bdaddr, ba); + syslog(LOG_INFO, "Connect from %s", ba); + + /* Handle deferred setup */ + if (defer_setup) { + syslog(LOG_INFO, "Waiting for %d seconds", + abs(defer_setup) - 1); + sleep(abs(defer_setup) - 1); + + if (defer_setup < 0) { + close(nsk); + exit(1); + } + } + + handler(fd, nsk); + + syslog(LOG_INFO, "Disconnect"); + exit(0); + } + +error: + if (fd >= 0) + close(fd); + close(sk); + exit(1); +} + +static void dump_mode(int fd, int sk) +{ + int len; + + if (defer_setup) { + len = read(sk, buf, data_size); + if (len < 0) + syslog(LOG_ERR, "Initial read error: %s (%d)", + strerror(errno), errno); + else + syslog(LOG_INFO, "Initial bytes %d", len); + } + + syslog(LOG_INFO,"Receiving ..."); + while ((len = read(sk, buf, data_size)) > 0) { + if (fd >= 0) { + len = write(fd, buf, len); + if (len < 0) { + syslog(LOG_ERR, "Write failed: %s (%d)", + strerror(errno), errno); + return; + } + } else + syslog(LOG_INFO, "Received %d bytes", len); + } +} + +static void recv_mode(int fd, int sk) +{ + struct timeval tv_beg,tv_end,tv_diff; + long total; + int len; + + if (defer_setup) { + len = read(sk, buf, data_size); + if (len < 0) + syslog(LOG_ERR, "Initial read error: %s (%d)", + strerror(errno), errno); + else + syslog(LOG_INFO, "Initial bytes %d", len); + } + + syslog(LOG_INFO, "Receiving ..."); + + while (1) { + gettimeofday(&tv_beg, NULL); + total = 0; + while (total < data_size) { + int r; + + r = recv(sk, buf, data_size, 0); + if (r <= 0) { + if (r < 0) + syslog(LOG_ERR, "Read failed: %s (%d)", + strerror(errno), errno); + if (errno != ENOTCONN) + return; + r = 0; + } + + if (fd >= 0) { + r = write(fd, buf, r); + if (r < 0) { + syslog(LOG_ERR, "Write failed: %s (%d)", + strerror(errno), errno); + return; + } + } + + total += r; + } + gettimeofday(&tv_end, NULL); + + timersub(&tv_end, &tv_beg, &tv_diff); + + syslog(LOG_INFO,"%ld bytes in %.2f sec speed %.2f kb/s", total, + tv2fl(tv_diff), + (float)(total * 8 / tv2fl(tv_diff)) / 1024.0); + } +} + +static int open_file(const char *filename) +{ + int fd = -1; + + syslog(LOG_INFO,"Opening %s ...", filename); + + fd = open(filename, O_RDONLY); + if (fd <= 0) { + syslog(LOG_ERR, "Can't open file %s: %s\n", + filename, strerror(errno)); + } + + return fd; +} + +static void send_mode(char *filename, char *peer, int i) +{ + struct bt_iso_qos qos; + socklen_t len; + uint32_t seq; + int sk, fd = -1; + + if (filename) { + char altername[PATH_MAX]; + struct stat st; + int err; + + snprintf(altername, PATH_MAX, "%s.%u", filename, i); + + err = stat(altername, &st); + if (!err) + fd = open_file(altername); + + if (fd <= 0) + fd = open_file(filename); + } + + sk = do_connect(peer); + if (sk < 0) { + syslog(LOG_ERR, "Can't connect to the server: %s (%d)", + strerror(errno), errno); + exit(1); + } + + if (defer_setup) { + syslog(LOG_INFO, "Waiting for %d seconds", + abs(defer_setup) - 1); + sleep(abs(defer_setup) - 1); + } + + syslog(LOG_INFO,"Sending ..."); + + /* Read QoS */ + memset(&qos, 0, sizeof(qos)); + len = sizeof(qos); + if (getsockopt(sk, SOL_BLUETOOTH, BT_ISO_QOS, &qos, &len) < 0) { + syslog(LOG_ERR, "Can't get Output QoS socket option: %s (%d)", + strerror(errno), errno); + qos.out.sdu = ISO_DEFAULT_MTU; + } + + for (i = 6; i < qos.out.sdu; i++) + buf[i] = 0x7f; + + seq = 0; + while (1) { + if (fd >= 0) { + ssize_t ret; + + ret = read(fd, buf, qos.out.sdu); + if (ret <= 0) { + if (ret < 0) + syslog(LOG_ERR, "read failed: %s (%d)", + strerror(errno), errno); + close(fd); + break; + } + } + + seq++; + + if (send(sk, buf, qos.out.sdu, 0) <= 0) { + syslog(LOG_ERR, "Send failed: %s (%d)", + strerror(errno), errno); + exit(1); + } + + usleep(qos.out.interval); + } +} + +static void reconnect_mode(char *peer) +{ + while (1) { + int sk; + + sk = do_connect(peer); + if (sk < 0) { + syslog(LOG_ERR, "Can't connect to the server: %s (%d)", + strerror(errno), errno); + exit(1); + } + + close(sk); + + sleep(5); + } +} + +static void multy_connect_mode(char *peer) +{ + while (1) { + int i, sk; + + for (i = 0; i < 10; i++){ + if (fork()) + continue; + + /* Child */ + sk = do_connect(peer); + if (sk < 0) { + syslog(LOG_ERR, "Can't connect to the server: " + "%s (%d)", strerror(errno), errno); + } + close(sk); + exit(0); + } + + sleep(19); + } +} + +#define QOS_IO(_interval, _latency, _sdu, _phy, _rtn) \ +{ \ + .interval = _interval, \ + .latency = _latency, \ + .sdu = _sdu, \ + .phy = _phy, \ + .rtn = _rtn, \ +} + +#define QOS(_interval, _latency, _sdu, _phy, _rtn) \ +{ \ + .cig = BT_ISO_QOS_CIG_UNSET, \ + .cis = BT_ISO_QOS_CIS_UNSET, \ + .sca = 0x07, \ + .packing = 0x00, \ + .framing = 0x00, \ + .out = QOS_IO(_interval, _latency, _sdu, _phy, _rtn), \ +} + +#define QOS_PRESET(_name, _inout, _interval, _latency, _sdu, _phy, _rtn) \ +{ \ + .name = _name, \ + .inout = _inout, \ + .qos = QOS(_interval, _latency, _sdu, _phy, _rtn), \ +} + +static struct qos_preset { + const char *name; + bool inout; + struct bt_iso_qos qos; +} presets[] = { + /* QoS Configuration settings for low latency audio data */ + QOS_PRESET("8_1_1", true, 7500, 8, 26, 0x02, 2), + QOS_PRESET("8_2_1", true, 10000, 10, 30, 0x02, 2), + QOS_PRESET("16_1_1", true, 7500, 8, 30, 0x02, 2), + QOS_PRESET("16_2_1", true, 10000, 10, 40, 0x02, 2), + QOS_PRESET("24_1_1", true, 7500, 8, 45, 0x02, 2), + QOS_PRESET("24_2_1", true, 10000, 10, 60, 0x02, 2), + QOS_PRESET("32_1_1", true, 7500, 8, 60, 0x02, 2), + QOS_PRESET("32_2_1", true, 10000, 10, 80, 0x02, 2), + QOS_PRESET("44_1_1", false, 8163, 24, 98, 0x02, 5), + QOS_PRESET("44_2_1", false, 10884, 31, 130, 0x02, 5), + QOS_PRESET("48_1_1", false, 7500, 15, 75, 0x02, 5), + QOS_PRESET("48_2_1", false, 10000, 20, 100, 0x02, 5), + QOS_PRESET("48_3_1", false, 7500, 15, 90, 0x02, 5), + QOS_PRESET("48_4_1", false, 10000, 20, 120, 0x02, 5), + QOS_PRESET("48_5_1", false, 7500, 15, 117, 0x02, 5), + QOS_PRESET("44_6_1", false, 10000, 20, 155, 0x02, 5), + /* QoS Configuration settings for high reliability audio data */ + QOS_PRESET("8_1_2", true, 7500, 45, 26, 0x02, 41), + QOS_PRESET("8_2_2", true, 10000, 60, 30, 0x02, 53), + QOS_PRESET("16_1_2", true, 7500, 45, 30, 0x02, 41), + QOS_PRESET("16_2_2", true, 10000, 60, 40, 0x02, 47), + QOS_PRESET("24_1_2", true, 7500, 45, 45, 0x02, 35), + QOS_PRESET("24_2_2", true, 10000, 60, 60, 0x02, 41), + QOS_PRESET("32_1_2", true, 7500, 45, 60, 0x02, 29), + QOS_PRESET("32_2_1", true, 10000, 60, 80, 0x02, 35), + QOS_PRESET("44_1_2", false, 8163, 54, 98, 0x02, 23), + QOS_PRESET("44_2_2", false, 10884, 71, 130, 0x02, 23), + QOS_PRESET("48_1_2", false, 7500, 45, 75, 0x02, 23), + QOS_PRESET("48_2_2", false, 10000, 60, 100, 0x02, 23), + QOS_PRESET("48_3_2", false, 7500, 45, 90, 0x02, 23), + QOS_PRESET("48_4_2", false, 10000, 60, 120, 0x02, 23), + QOS_PRESET("48_5_2", false, 7500, 45, 117, 0x02, 23), + QOS_PRESET("44_6_2", false, 10000, 60, 155, 0x02, 23), +}; + +#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) + +static void usage(void) +{ + printf("isotest - ISO testing\n" + "Usage:\n"); + printf("\tisotest [options] [bdaddr] [bdaddr1]...\n"); + printf("Modes:\n" + "\t-d, --dump [filename] dump (server)\n" + "\t-c, --reconnect reconnect (client)\n" + "\t-m, --multiple multiple connects (client)\n" + "\t-r, --receive [filename] receive (server)\n" + "\t-s, --send [filename,...] connect and send (client)\n" + "\t-n, --silent connect and be silent (client)\n" + "Options:\n" + "\t[-b, --bytes ]\n" + "\t[-i, --device ]\n" + "\t[-h, --help]\n" + "\t[-W, --defer ] enable deferred setup\n" + "\t[-M, --mtu ]\n" + "\t[-S, --sca ]\n" + "\t[-P, --packing ]\n" + "\t[-F, --framing ]\n" + "\t[-I, --interval ]\n" + "\t[-L, --latency ]\n" + "\t[-Y, --phy ]\n" + "\t[-R, --rtn ]\n" + "\t[-B, --preset ]\n" + "\t[-G, --CIG ]\n" + "\t[-V, --type ] address type (help for list)\n"); +} + +static const struct option main_options[] = { + { "dump", optional_argument, NULL, 'd'}, + { "reconnect", no_argument, NULL, 'c'}, + { "multiple", no_argument, NULL, 'm'}, + { "receive", optional_argument, NULL, 'r'}, + { "send", optional_argument, NULL, 's'}, + { "silent", no_argument, NULL, 'n'}, + { "bytes", required_argument, NULL, 'b'}, + { "device", required_argument, NULL, 'i'}, + { "help", no_argument, NULL, 'h'}, + { "defer", required_argument, NULL, 'W'}, + { "mtu", required_argument, NULL, 'M'}, + { "sca", required_argument, NULL, 'S'}, + { "packing", required_argument, NULL, 'P'}, + { "framing", required_argument, NULL, 'F'}, + { "interval", required_argument, NULL, 'I'}, + { "latency", required_argument, NULL, 'L'}, + { "phy", required_argument, NULL, 'Y'}, + { "rtn", required_argument, NULL, 'R'}, + { "preset", required_argument, NULL, 'B'}, + { "CIG", required_argument, NULL, 'G'}, + { "type", required_argument, NULL, 'V'}, + {} +}; + +int main(int argc ,char *argv[]) +{ + struct sigaction sa; + int sk, mode = RECV; + char *filename = NULL; + unsigned int i; + + iso_qos = malloc(sizeof(*iso_qos)); + /* Default to 16_2_1 */ + *iso_qos = presets[3].qos; + inout = true; + + while (1) { + int opt; + + opt = getopt_long(argc, argv, + "d::cmr::s::nb:i:hV:W:M:S:P:F:I:L:Y:R:B:G:", + main_options, NULL); + if (opt < 0) + break; + + + switch(opt) { + case 'r': + mode = RECV; + if (optarg) + filename = strdup(optarg); + break; + + case 's': + mode = SEND; + if (optarg) + filename = strdup(optarg); + break; + + case 'd': + mode = DUMP; + if (optarg) + filename = strdup(optarg); + break; + + case 'c': + mode = RECONNECT; + break; + + case 'm': + mode = MULTY; + break; + + case 'n': + mode = CONNECT; + break; + + case 'b': + data_size = atoi(optarg); + break; + + case 'i': + if (!strncasecmp(optarg, "hci", 3)) + hci_devba(atoi(optarg + 3), &bdaddr); + else + str2ba(optarg, &bdaddr); + break; + + case 'V': + bdaddr_type = get_lookup_flag(bdaddr_types, optarg); + + if (bdaddr_type == -1) { + print_lookup_values(bdaddr_types, + "List Address types:"); + exit(1); + } + + break; + + case 'W': + defer_setup = atoi(optarg); + break; + + case 'M': + iso_qos->out.sdu = atoi(optarg); + + break; + + case 'S': + iso_qos->sca = atoi(optarg); + + break; + + + case 'P': + iso_qos->packing = atoi(optarg); + + break; + + case 'F': + iso_qos->framing = atoi(optarg); + + break; + + case 'I': + iso_qos->out.interval = atoi(optarg); + + break; + + case 'L': + iso_qos->out.latency = atoi(optarg); + + break; + + case 'Y': + iso_qos->out.phy = atoi(optarg); + + break; + + case 'R': + iso_qos->out.rtn = atoi(optarg); + + break; + + case 'B': + for (i = 0; i < ARRAY_SIZE(presets); i++) { + if (!strcmp(presets[i].name, optarg)) { + *iso_qos = presets[i].qos; + inout = presets[i].inout; + break; + } + } + + break; + + case 'G': + iso_qos->cig = atoi(optarg); + + break; + + /* Fallthrough */ + default: + usage(); + exit(1); + } + } + + if (inout) + iso_qos->in = iso_qos->out; + + buf = malloc(data_size); + if (!buf) { + perror("Can't allocate data buffer"); + exit(1); + } + + memset(&sa, 0, sizeof(sa)); + sa.sa_handler = SIG_IGN; + sa.sa_flags = SA_NOCLDSTOP; + sigaction(SIGCHLD, &sa, NULL); + + openlog("isotest", LOG_PERROR | LOG_PID, LOG_LOCAL0); + + if (!(argc - optind)) { + switch (mode) { + case RECV: + do_listen(filename, recv_mode); + goto done; + + case DUMP: + do_listen(filename, dump_mode); + goto done; + default: + usage(); + exit(1); + } + } + + argc -= optind; + + for (i = 0; i < (unsigned int) argc; i++) { + pid_t pid; + + pid = fork(); + if (pid < 0) { + perror("Failed to fork new process"); + return -1; + } + + if (!pid) + continue; + + switch (mode) { + case SEND: + send_mode(filename, argv[optind + i], i); + if (strchr(filename, ',')) + filename = strchr(filename, ',') + 1; + break; + + case RECONNECT: + reconnect_mode(argv[optind + i]); + break; + + case MULTY: + multy_connect_mode(argv[optind + i]); + break; + + case CONNECT: + sk = do_connect(argv[optind + i]); + if (sk < 0) + exit(1); + dump_mode(-1, sk); + break; + } + + break; + } + +done: + syslog(LOG_INFO, "Exit"); + + closelog(); + + return 0; +} From patchwork Mon Dec 21 23:01:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 11985371 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38D61C433E9 for ; Mon, 21 Dec 2020 23:02:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DF331229CA for ; Mon, 21 Dec 2020 23:02:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726173AbgLUXC0 (ORCPT ); Mon, 21 Dec 2020 18:02:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725844AbgLUXCZ (ORCPT ); Mon, 21 Dec 2020 18:02:25 -0500 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71DEDC061793 for ; Mon, 21 Dec 2020 15:01:45 -0800 (PST) Received: by mail-pf1-x42a.google.com with SMTP id t8so7324498pfg.8 for ; Mon, 21 Dec 2020 15:01:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=PojkuspmGgPTIK6m0xM4qDTdyWDV9/yDV529q/7JJYI=; b=HZcJzBNOKAwvM8pjgYO5/yN+808iGqTkvphx3vxvB++muQporhjgtuBNao7EwiAcIe nQ2h6YeTcYYIsEI0+9EYL4SqLc+8JhhfUh2kGXwTX4brAWQPC1+yaa1OKoMxnydjWVoh bVkJzEzEP/jx3OuEeuWWTuhBG982zIsOE7GwZWDxRiqZbr+y+CFrOCy712y1THQ2Ooe3 Pb90iAJWiwMIXGMvWIKnXwS03MEpldW9NXLn7HBFLYZH4TswQy2iLtDdV0NmlK9YGdj+ DGWhLCALyHe/CIAWIVFTrTmOiRqcJaS0Q9XCSdMncUvYg1qdoQgS3v2vl2zJ2bRAzwh8 /d8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PojkuspmGgPTIK6m0xM4qDTdyWDV9/yDV529q/7JJYI=; b=J8AZ8vEj9YvJYBgFYKC1VCS2m1mOZgsJdcUnx6aqs4qEqLG6Ki/hWrB2WKcAM57k47 dq19P6eqf0NesnoHfpupib4UjhQm845ans0G6KL6yd+7MC9WmD6AtCzvyynoQazVZhAP vXRSzZ27QxZLdR1W25e5ipNeLdLbsmQk0898LB3oFuAANV1gmEDrmfXorCIskNyU7Mjs Yul2wtGqC/nVwjtXp1Va3Mt/VSEM6Je42CSNgmlM01vIp/waAH/kbXsspkp6nj2HgUnW igh6CNsN3xDPtMbXMFN0/ZKXhUz4BaadC8pSqzcxr2EBOme3FtSQfvGjq5QceyWAQzDy DAFg== X-Gm-Message-State: AOAM53316KaDWUvj7AbQrPN2fAmnHnxGfspZrlAHR2jgbei3H+Dumsza nK1CE9wu6qOhgKFDn+eTXE9z2AQahtc= X-Google-Smtp-Source: ABdhPJypwNZ7lprhKqHV959CFhblmkDHWOAuDQiEWvnZhXigBVUQJT0lJ15xBS+0NnWBFfSLj6cd+A== X-Received: by 2002:a63:2902:: with SMTP id p2mr17133338pgp.274.1608591704417; Mon, 21 Dec 2020 15:01:44 -0800 (PST) Received: from localhost.localdomain (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id a19sm17131855pfi.130.2020.12.21.15.01.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Dec 2020 15:01:43 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 3/4] btio: Add support for ISO sockets Date: Mon, 21 Dec 2020 15:01:39 -0800 Message-Id: <20201221230140.2100824-3-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201221230140.2100824-1-luiz.dentz@gmail.com> References: <20201221230140.2100824-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This adds support to create objects that map to ISO sockets. --- btio/btio.c | 164 +++++++++++++++++++++++++++++++++++++++++++++++ btio/btio.h | 4 +- tools/btiotest.c | 110 +++++++++++++++++++++++++++++++ 3 files changed, 277 insertions(+), 1 deletion(-) diff --git a/btio/btio.c b/btio/btio.c index 8230212b4..38356ff00 100644 --- a/btio/btio.c +++ b/btio/btio.c @@ -27,6 +27,7 @@ #include "lib/l2cap.h" #include "lib/rfcomm.h" #include "lib/sco.h" +#include "lib/iso.h" #include "btio.h" @@ -44,6 +45,7 @@ typedef enum { BT_IO_L2CAP, BT_IO_RFCOMM, BT_IO_SCO, + BT_IO_ISO, BT_IO_INVALID, } BtIOType; @@ -66,6 +68,7 @@ struct set_opts { int flushable; uint32_t priority; uint16_t voice; + struct bt_iso_qos qos; }; struct connect { @@ -763,6 +766,25 @@ static int sco_bind(int sock, const bdaddr_t *src, GError **err) return 0; } +static int iso_bind(int sock, const bdaddr_t *src, uint8_t src_type, + GError **err) +{ + struct sockaddr_iso addr; + + memset(&addr, 0, sizeof(addr)); + addr.iso_family = AF_BLUETOOTH; + bacpy(&addr.iso_bdaddr, src); + addr.iso_bdaddr_type = src_type; + + if (bind(sock, (struct sockaddr *) &addr, sizeof(addr)) < 0) { + int error = -errno; + ERROR_FAILED(err, "sco_bind", errno); + return error; + } + + return 0; +} + static int sco_connect(int sock, const bdaddr_t *dst) { struct sockaddr_sco addr; @@ -779,6 +801,23 @@ static int sco_connect(int sock, const bdaddr_t *dst) return 0; } +static int iso_connect(int sock, const bdaddr_t *dst, uint8_t dst_type) +{ + struct sockaddr_iso addr; + int err; + + memset(&addr, 0, sizeof(addr)); + addr.iso_family = AF_BLUETOOTH; + bacpy(&addr.iso_bdaddr, dst); + addr.iso_bdaddr_type = dst_type; + + err = connect(sock, (struct sockaddr *) &addr, sizeof(addr)); + if (err < 0 && !(errno == EAGAIN || errno == EINPROGRESS)) + return -errno; + + return 0; +} + static gboolean sco_set(int sock, uint16_t mtu, uint16_t voice, GError **err) { struct sco_options sco_opt; @@ -817,6 +856,17 @@ voice: return TRUE; } +static gboolean iso_set(int sock, struct bt_iso_qos *qos, GError **err) +{ + if (setsockopt(sock, SOL_BLUETOOTH, BT_ISO_QOS, qos, + sizeof(*qos)) < 0) { + ERROR_FAILED(err, "setsockopt(BT_ISO_QOS)", errno); + return FALSE; + } + + return TRUE; +} + static gboolean parse_set_opts(struct set_opts *opts, GError **err, BtIOOption opt1, va_list args) { @@ -894,6 +944,8 @@ static gboolean parse_set_opts(struct set_opts *opts, GError **err, break; case BT_IO_OPT_MODE: opts->mode = va_arg(args, int); + if (opts->mode == BT_IO_MODE_ISO) + opts->type = BT_IO_ISO; break; case BT_IO_OPT_FLUSHABLE: opts->flushable = va_arg(args, gboolean); @@ -904,6 +956,9 @@ static gboolean parse_set_opts(struct set_opts *opts, GError **err, case BT_IO_OPT_VOICE: opts->voice = va_arg(args, int); break; + case BT_IO_OPT_QOS: + opts->qos = *va_arg(args, struct bt_iso_qos *); + break; case BT_IO_OPT_INVALID: case BT_IO_OPT_KEY_SIZE: case BT_IO_OPT_SOURCE_CHANNEL: @@ -1227,6 +1282,7 @@ parse_opts: case BT_IO_OPT_DEST_CHANNEL: case BT_IO_OPT_MTU: case BT_IO_OPT_VOICE: + case BT_IO_OPT_QOS: default: g_set_error(err, BT_IO_ERROR, EINVAL, "Unknown option %d", opt); @@ -1380,6 +1436,7 @@ static gboolean rfcomm_get(int sock, GError **err, BtIOOption opt1, case BT_IO_OPT_FLUSHABLE: case BT_IO_OPT_PRIORITY: case BT_IO_OPT_VOICE: + case BT_IO_OPT_QOS: case BT_IO_OPT_INVALID: default: g_set_error(err, BT_IO_ERROR, EINVAL, @@ -1489,6 +1546,95 @@ static gboolean sco_get(int sock, GError **err, BtIOOption opt1, va_list args) case BT_IO_OPT_FLUSHABLE: case BT_IO_OPT_PRIORITY: case BT_IO_OPT_VOICE: + case BT_IO_OPT_QOS: + case BT_IO_OPT_INVALID: + default: + g_set_error(err, BT_IO_ERROR, EINVAL, + "Unknown option %d", opt); + return FALSE; + } + + opt = va_arg(args, int); + } + + return TRUE; +} + +static gboolean iso_get(int sock, GError **err, BtIOOption opt1, va_list args) +{ + BtIOOption opt = opt1; + struct sockaddr_iso src, dst; + struct bt_iso_qos qos; + socklen_t len; + uint32_t phy; + + len = sizeof(qos); + memset(&qos, 0, len); + if (getsockopt(sock, SOL_BLUETOOTH, BT_ISO_QOS, &qos, &len) < 0) { + ERROR_FAILED(err, "getsockopt(BT_ISO_QOS)", errno); + return FALSE; + } + + if (!get_src(sock, &src, sizeof(src), err)) + return FALSE; + + if (!get_dst(sock, &dst, sizeof(dst), err)) + return FALSE; + + while (opt != BT_IO_OPT_INVALID) { + switch (opt) { + case BT_IO_OPT_SOURCE: + ba2str(&src.iso_bdaddr, va_arg(args, char *)); + break; + case BT_IO_OPT_SOURCE_BDADDR: + bacpy(va_arg(args, bdaddr_t *), &src.iso_bdaddr); + break; + case BT_IO_OPT_SOURCE_TYPE: + *(va_arg(args, uint8_t *)) = src.iso_bdaddr_type; + break; + case BT_IO_OPT_DEST: + ba2str(&dst.iso_bdaddr, va_arg(args, char *)); + break; + case BT_IO_OPT_DEST_BDADDR: + bacpy(va_arg(args, bdaddr_t *), &dst.iso_bdaddr); + break; + case BT_IO_OPT_DEST_TYPE: + *(va_arg(args, uint8_t *)) = dst.iso_bdaddr_type; + break; + case BT_IO_OPT_MTU: + *(va_arg(args, uint16_t *)) = qos.out.sdu; + break; + case BT_IO_OPT_IMTU: + *(va_arg(args, uint16_t *)) = qos.in.sdu; + break; + case BT_IO_OPT_OMTU: + *(va_arg(args, uint16_t *)) = qos.out.sdu; + break; + case BT_IO_OPT_PHY: + if (get_phy(sock, &phy) < 0) { + ERROR_FAILED(err, "get_phy", errno); + return FALSE; + } + *(va_arg(args, uint32_t *)) = phy; + break; + case BT_IO_OPT_QOS: + *(va_arg(args, struct bt_iso_qos *)) = qos; + break; + case BT_IO_OPT_HANDLE: + case BT_IO_OPT_CLASS: + case BT_IO_OPT_DEFER_TIMEOUT: + case BT_IO_OPT_SEC_LEVEL: + case BT_IO_OPT_KEY_SIZE: + case BT_IO_OPT_CHANNEL: + case BT_IO_OPT_SOURCE_CHANNEL: + case BT_IO_OPT_DEST_CHANNEL: + case BT_IO_OPT_PSM: + case BT_IO_OPT_CID: + case BT_IO_OPT_MASTER: + case BT_IO_OPT_MODE: + case BT_IO_OPT_FLUSHABLE: + case BT_IO_OPT_PRIORITY: + case BT_IO_OPT_VOICE: case BT_IO_OPT_INVALID: default: g_set_error(err, BT_IO_ERROR, EINVAL, @@ -1516,6 +1662,8 @@ static gboolean get_valist(GIOChannel *io, BtIOType type, GError **err, return rfcomm_get(sock, err, opt1, args); case BT_IO_SCO: return sco_get(sock, err, opt1, args); + case BT_IO_ISO: + return iso_get(sock, err, opt1, args); case BT_IO_INVALID: default: g_set_error(err, BT_IO_ERROR, EINVAL, @@ -1584,6 +1732,8 @@ gboolean bt_io_set(GIOChannel *io, GError **err, BtIOOption opt1, ...) return rfcomm_set(sock, opts.sec_level, opts.master, err); case BT_IO_SCO: return sco_set(sock, opts.mtu, opts.voice, err); + case BT_IO_ISO: + return iso_set(sock, &opts.qos, err); case BT_IO_INVALID: default: g_set_error(err, BT_IO_ERROR, EINVAL, @@ -1655,6 +1805,17 @@ static GIOChannel *create_io(gboolean server, struct set_opts *opts, if (!sco_set(sock, opts->mtu, opts->voice, err)) goto failed; break; + case BT_IO_ISO: + sock = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_ISO); + if (sock < 0) { + ERROR_FAILED(err, "socket(SEQPACKET, ISO)", errno); + return NULL; + } + if (iso_bind(sock, &opts->src, opts->src_type, err) < 0) + goto failed; + if (!iso_set(sock, &opts->qos, err)) + goto failed; + break; case BT_IO_INVALID: default: g_set_error(err, BT_IO_ERROR, EINVAL, @@ -1719,6 +1880,9 @@ GIOChannel *bt_io_connect(BtIOConnect connect, gpointer user_data, case BT_IO_SCO: err = sco_connect(sock, &opts.dst); break; + case BT_IO_ISO: + err = iso_connect(sock, &opts.dst, opts.dst_type); + break; case BT_IO_INVALID: default: g_set_error(gerr, BT_IO_ERROR, EINVAL, diff --git a/btio/btio.h b/btio/btio.h index f0259cf1d..7d0acbb17 100644 --- a/btio/btio.h +++ b/btio/btio.h @@ -44,6 +44,7 @@ typedef enum { BT_IO_OPT_PRIORITY, BT_IO_OPT_VOICE, BT_IO_OPT_PHY, + BT_IO_OPT_QOS, } BtIOOption; typedef enum { @@ -58,7 +59,8 @@ typedef enum { BT_IO_MODE_ERTM, BT_IO_MODE_STREAMING, BT_IO_MODE_LE_FLOWCTL, - BT_IO_MODE_EXT_FLOWCTL + BT_IO_MODE_EXT_FLOWCTL, + BT_IO_MODE_ISO } BtIOMode; typedef void (*BtIOConfirm)(GIOChannel *io, gpointer user_data); diff --git a/tools/btiotest.c b/tools/btiotest.c index cb8cc3534..c5def5044 100644 --- a/tools/btiotest.c +++ b/tools/btiotest.c @@ -29,6 +29,25 @@ #define DEFAULT_ACCEPT_TIMEOUT 2 static int opt_update_sec = 0; +#define DEFAULT_IO_QOS \ +{ \ + .interval = 10000, \ + .latency = 10, \ + .sdu = 40, \ + .phy = 0x02, \ + .rtn = 2, \ +} + +struct bt_iso_qos qos = { + .cig = BT_ISO_QOS_CIG_UNSET, + .cis = BT_ISO_QOS_CIG_UNSET, + .sca = 0x07, + .packing = 0x00, + .framing = 0x00, + .in = DEFAULT_IO_QOS, + .out = DEFAULT_IO_QOS, +}; + struct io_data { guint ref; GIOChannel *io; @@ -36,6 +55,8 @@ struct io_data { int disconn; int accept; int voice; + struct bt_iso_qos *in_qos; + struct bt_iso_qos *out_qos; }; static void io_data_unref(struct io_data *data) @@ -67,6 +88,8 @@ static struct io_data *io_data_new(GIOChannel *io, int reject, int disconn, data->reject = reject; data->disconn = disconn; data->accept = accept; + data->in_qos = &qos; + data->out_qos = &qos; return io_data_ref(data); } @@ -530,9 +553,86 @@ static void sco_listen(const char *src, gboolean defer, int reject, g_io_channel_unref(sco_srv); } +static void iso_connect(const char *src, const char *dst, int disconn) +{ + struct io_data *data; + GError *err = NULL; + + printf("Connecting ISO to %s\n", dst); + + data = io_data_new(NULL, -1, disconn, -1); + + if (src) + data->io = bt_io_connect(connect_cb, data, + (GDestroyNotify) io_data_unref, + &err, + BT_IO_OPT_SOURCE, src, + BT_IO_OPT_DEST, dst, + BT_IO_OPT_MODE, BT_IO_MODE_ISO, + BT_IO_OPT_INVALID); + else + data->io = bt_io_connect(connect_cb, data, + (GDestroyNotify) io_data_unref, + &err, + BT_IO_OPT_DEST, dst, + BT_IO_OPT_MODE, BT_IO_MODE_ISO, + BT_IO_OPT_INVALID); + + if (!data->io) { + printf("Connecting to %s failed: %s\n", dst, err->message); + g_error_free(err); + exit(EXIT_FAILURE); + } +} + +static void iso_listen(const char *src, gboolean defer, int reject, + int disconn, int accept) +{ + struct io_data *data; + BtIOConnect conn; + BtIOConfirm cfm; + GIOChannel *iso_srv; + GError *err = NULL; + + printf("Listening for ISO connections\n"); + + if (defer) { + conn = NULL; + cfm = confirm_cb; + } else { + conn = connect_cb; + cfm = NULL; + } + + data = io_data_new(NULL, reject, disconn, accept); + + if (src) + iso_srv = bt_io_listen(conn, cfm, data, + (GDestroyNotify) io_data_unref, + &err, + BT_IO_OPT_SOURCE, src, + BT_IO_OPT_MODE, BT_IO_MODE_ISO, + BT_IO_OPT_INVALID); + else + iso_srv = bt_io_listen(conn, cfm, data, + (GDestroyNotify) io_data_unref, + &err, + BT_IO_OPT_MODE, BT_IO_MODE_ISO, + BT_IO_OPT_INVALID); + + if (!iso_srv) { + printf("Listening failed: %s\n", err->message); + g_error_free(err); + exit(EXIT_FAILURE); + } + + g_io_channel_unref(iso_srv); +} + static int opt_channel = -1; static int opt_psm = 0; static gboolean opt_sco = FALSE; +static gboolean opt_iso = FALSE; static gboolean opt_defer = FALSE; static gint opt_voice = 0; static char *opt_dev = NULL; @@ -559,6 +659,8 @@ static GOptionEntry options[] = { "(0 BR/EDR 1 LE Public 2 LE Random" }, { "sco", 's', 0, G_OPTION_ARG_NONE, &opt_sco, "Use SCO" }, + { "iso", 'o', 0, G_OPTION_ARG_NONE, &opt_iso, + "Use ISO" }, { "defer", 'd', 0, G_OPTION_ARG_NONE, &opt_defer, "Use DEFER_SETUP for incoming connections" }, { "voice", 'V', 0, G_OPTION_ARG_INT, &opt_voice, @@ -635,6 +737,14 @@ int main(int argc, char *argv[]) opt_disconn, opt_accept, opt_voice); } + if (opt_iso) { + if (argc > 1) + iso_connect(opt_dev, argv[1], opt_disconn); + else + iso_listen(opt_dev, opt_defer, opt_reject, + opt_disconn, opt_accept); + } + signal(SIGTERM, sig_term); signal(SIGINT, sig_term); From patchwork Mon Dec 21 23:01:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 11985369 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,UNWANTED_LANGUAGE_BODY,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C16DC433DB for ; Mon, 21 Dec 2020 23:02:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C435F229CA for ; Mon, 21 Dec 2020 23:02:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726190AbgLUXC1 (ORCPT ); Mon, 21 Dec 2020 18:02:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725844AbgLUXC0 (ORCPT ); Mon, 21 Dec 2020 18:02:26 -0500 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75B1AC061282 for ; Mon, 21 Dec 2020 15:01:46 -0800 (PST) Received: by mail-pj1-x1030.google.com with SMTP id hk16so281414pjb.4 for ; Mon, 21 Dec 2020 15:01:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=4yQg4d5X0FSp9G4mFgxKNiWVZGapNvYVbxzM4ahZ9pg=; b=rPVVaLaFm3jgOGGvFZslofdFkjXHlzUE2R9fUA9q0tXWhZ1XuI/4WmojxrLza2EA9c UCqjOSWCR9Bl8UQmDLMvQGR8YrHocBeOmpvDjwQMKtTqrLlCup3apAVxLblXu4l0yCsc 7r4g6PR6vfIJ0wTbYTtEn7WF/jO/B0F2a/QYC0UiZDbVswvy6WRRlpOWyLtExUzhjTul +w3mOllwg3GgV0vBIWaz7VhE88xH+BpU4+D4NkACl6zIRfLV/QwpMK7cn1OJhQfBlB0V KdpQ5smSC8p2vejB1UeyCZcW9RF/NBc1sjAE61d7TXwA+rNA0lVs+o4sJAYcFffja+zm hZPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4yQg4d5X0FSp9G4mFgxKNiWVZGapNvYVbxzM4ahZ9pg=; b=GthfKaaFDGD5D2/M+XIdi65Ih3g5Ta6NGs/VJ6CeyM88dN0v9nSzx4PW4cAZJwvocn 0vIruRLr4SfCysKCN4wgz6Yliyhub1d4e3SmqMAKzoCLeL5folyDPS/zu0fU5eE7u3Rp uaKmslaZ2N+OME5/+BLrhJHuBSuVGgLHyDiZMVQ8D+YnDo/JSx4Jmn2beQdRzQeXaANv E/KfiK4K4/jYAExIwS1Ej7bToBkb7I1HxCbDeteKk2VeLC0rwV2JvVPb0IKy5RoOpgt+ pcxJM41VFoSmNeDNs7omHrDrFmBdeA5kdCA7XMCbypKtFE1iOtw9dHC21vlDNrIQQH6l BdNw== X-Gm-Message-State: AOAM530Wm0EaHyPlc1v67aH6bA9K7spsj7vRtWw83ZYFZupTm0muBomc jcP/rf2WUG8gaBHbEXKC9DUAFeQrpag= X-Google-Smtp-Source: ABdhPJy5AzX+oxcdFGx7ufdel2DtYh+nsDv/ejRXE/jM5wtsAlTeWQogvSp+VK4kS0BxygleJNXJKQ== X-Received: by 2002:a17:902:b717:b029:dc:3e69:6dd5 with SMTP id d23-20020a170902b717b02900dc3e696dd5mr6454117pls.70.1608591705358; Mon, 21 Dec 2020 15:01:45 -0800 (PST) Received: from localhost.localdomain (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id a19sm17131855pfi.130.2020.12.21.15.01.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Dec 2020 15:01:44 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 4/4] tools: Add iso-tester Date: Mon, 21 Dec 2020 15:01:40 -0800 Message-Id: <20201221230140.2100824-4-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201221230140.2100824-1-luiz.dentz@gmail.com> References: <20201221230140.2100824-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This adds iso-tester which tests BTPROTO_ISO socket: Basic Framework - Success Basic ISO Socket - Success Basic ISO Get Socket Option - Success Basic ISO Set Socket Option - Success ISO QoS 8_1_1 - Success ISO QoS 8_2_1 - Success ISO QoS 16_1_1 - Success ISO QoS 16_2_1 - Success ISO QoS 24_1_1 - Success ISO QoS 24_2_1 - Success ISO QoS 32_1_1 - Success ISO QoS 32_2_1 - Success ISO QoS 44_1_1 - Success ISO QoS 44_2_1 - Success ISO QoS 48_1_1 - Success ISO QoS 48_2_1 - Success ISO QoS 48_3_1 - Success ISO QoS 48_4_1 - Success ISO QoS 48_5_1 - Success ISO QoS 48_6_1 - Success ISO QoS 8_1_2 - Success ISO QoS 8_2_2 - Success ISO QoS 16_1_2 - Success ISO QoS 16_2_2 - Success ISO QoS 24_1_2 - Success ISO QoS 24_2_2 - Success ISO QoS 32_1_2 - Success ISO QoS 32_2_2 - Success ISO QoS 44_1_2 - Success ISO QoS 44_2_2 - Success ISO QoS 48_1_2 - Success ISO QoS 48_2_2 - Success ISO QoS 48_3_2 - Success ISO QoS 48_4_2 - Success ISO QoS 48_5_2 - Success ISO QoS 48_6_2 - Success ISO Connect2 - Success --- Makefile.tools | 10 +- tools/iso-tester.c | 998 ++++++++++++++++++++++++++++++++++++++++++++ tools/test-runner.c | 5 +- 3 files changed, 1010 insertions(+), 3 deletions(-) create mode 100644 tools/iso-tester.c diff --git a/Makefile.tools b/Makefile.tools index c1eb2778a..6dfbc9808 100644 --- a/Makefile.tools +++ b/Makefile.tools @@ -73,7 +73,7 @@ noinst_PROGRAMS += emulator/btvirt emulator/b1ee emulator/hfp \ tools/l2cap-tester tools/sco-tester \ tools/smp-tester tools/hci-tester \ tools/rfcomm-tester tools/bnep-tester \ - tools/userchan-tester + tools/userchan-tester tools/iso-tester emulator_btvirt_SOURCES = emulator/main.c monitor/bt.h \ emulator/serial.h emulator/serial.c \ @@ -173,6 +173,14 @@ tools_userchan_tester_SOURCES = tools/userchan-tester.c monitor/bt.h \ emulator/smp.c tools_userchan_tester_LDADD = lib/libbluetooth-internal.la \ src/libshared-glib.la $(GLIB_LIBS) + +tools_iso_tester_SOURCES = tools/iso-tester.c monitor/bt.h \ + emulator/hciemu.h emulator/hciemu.c \ + emulator/btdev.h emulator/btdev.c \ + emulator/bthost.h emulator/bthost.c \ + emulator/smp.c +tools_iso_tester_LDADD = lib/libbluetooth-internal.la \ + src/libshared-glib.la $(GLIB_LIBS) endif if TOOLS diff --git a/tools/iso-tester.c b/tools/iso-tester.c new file mode 100644 index 000000000..d722ea516 --- /dev/null +++ b/tools/iso-tester.c @@ -0,0 +1,998 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2020 Intel Corporation. All rights reserved. + * + * + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include + +#include + +#include "lib/bluetooth.h" +#include "lib/iso.h" +#include "lib/mgmt.h" + +#include "monitor/bt.h" +#include "emulator/bthost.h" +#include "emulator/hciemu.h" + +#include "src/shared/tester.h" +#include "src/shared/mgmt.h" +#include "src/shared/util.h" + +#define QOS_IO(_interval, _latency, _sdu, _phy, _rtn) \ +{ \ + .interval = _interval, \ + .latency = _latency, \ + .sdu = _sdu, \ + .phy = _phy, \ + .rtn = _rtn, \ +} + +#define QOS_FULL(_in, _out) \ +{ \ + .cig = BT_ISO_QOS_CIG_UNSET, \ + .cis = BT_ISO_QOS_CIS_UNSET, \ + .sca = 0x07, \ + .packing = 0x00, \ + .framing = 0x00, \ + .in = _in, \ + .out = _out, \ +} + +#define QOS(_interval, _latency, _sdu, _phy, _rtn) \ + QOS_FULL(QOS_IO(_interval, _latency, _sdu, _phy, _rtn), \ + QOS_IO(_interval, _latency, _sdu, _phy, _rtn)) + +#define QOS_OUT(_interval, _latency, _sdu, _phy, _rtn) \ + QOS_FULL({}, QOS_IO(_interval, _latency, _sdu, _phy, _rtn)) + +/* QoS Configuration settings for low latency audio data */ +#define QOS_8_1_1 QOS(7500, 8, 26, 0x02, 2) +#define QOS_8_2_1 QOS(10000, 10, 30, 0x02, 2) +#define QOS_16_1_1 QOS(7500, 8, 30, 0x02, 2) +#define QOS_16_2_1 QOS(10000, 10, 40, 0x02, 2) +#define QOS_24_1_1 QOS(7500, 8, 45, 0x02, 2) +#define QOS_24_2_1 QOS(10000, 10, 60, 0x02, 2) +#define QOS_32_1_1 QOS(7500, 8, 60, 0x02, 2) +#define QOS_32_2_1 QOS(10000, 10, 80, 0x02, 2) +#define QOS_44_1_1 QOS_OUT(8163, 24, 98, 0x02, 5) +#define QOS_44_2_1 QOS_OUT(10884, 31, 130, 0x02, 5) +#define QOS_48_1_1 QOS_OUT(7500, 15, 75, 0x02, 5) +#define QOS_48_2_1 QOS_OUT(10000, 20, 100, 0x02, 5) +#define QOS_48_3_1 QOS_OUT(7500, 15, 90, 0x02, 5) +#define QOS_48_4_1 QOS_OUT(10000, 20, 120, 0x02, 5) +#define QOS_48_5_1 QOS_OUT(7500, 15, 117, 0x02, 5) +#define QOS_48_6_1 QOS_OUT(10000, 20, 155, 0x02, 5) +/* QoS Configuration settings for high reliability audio data */ +#define QOS_8_1_2 QOS(7500, 45, 26, 0x02, 41) +#define QOS_8_2_2 QOS(10000, 60, 30, 0x02, 53) +#define QOS_16_1_2 QOS(7500, 45, 30, 0x02, 41) +#define QOS_16_2_2 QOS(10000, 60, 40, 0x02, 47) +#define QOS_24_1_2 QOS(7500, 45, 45, 0x02, 35) +#define QOS_24_2_2 QOS(10000, 60, 60, 0x02, 41) +#define QOS_32_1_2 QOS(7500, 45, 60, 0x02, 29) +#define QOS_32_2_2 QOS(10000, 60, 80, 0x02, 35) +#define QOS_44_1_2 QOS_OUT(8163, 54, 98, 0x02, 23) +#define QOS_44_2_2 QOS_OUT(10884, 71, 130, 0x02, 23) +#define QOS_48_1_2 QOS_OUT(7500, 45, 75, 0x02, 23) +#define QOS_48_2_2 QOS_OUT(10000, 60, 100, 0x02, 23) +#define QOS_48_3_2 QOS_OUT(7500, 45, 90, 0x02, 23) +#define QOS_48_4_2 QOS_OUT(10000, 60, 120, 0x02, 23) +#define QOS_48_5_2 QOS_OUT(7500, 45, 117, 0x02, 23) +#define QOS_48_6_2 QOS_OUT(10000, 60, 155, 0x02, 23) + +struct test_data { + const void *test_data; + struct mgmt *mgmt; + uint16_t mgmt_index; + struct hciemu *hciemu; + enum hciemu_type hciemu_type; + unsigned int io_id[2]; + uint8_t client_num; + int step; +}; + +struct iso_client_data { + struct bt_iso_qos qos; + int expect_err; +}; + +static void mgmt_debug(const char *str, void *user_data) +{ + const char *prefix = user_data; + + tester_print("%s%s", prefix, str); +} + +static void read_info_callback(uint8_t status, uint16_t length, + const void *param, void *user_data) +{ + struct test_data *data = tester_get_data(); + const struct mgmt_rp_read_info *rp = param; + char addr[18]; + uint16_t manufacturer; + uint32_t supported_settings, current_settings; + + tester_print("Read Info callback"); + tester_print(" Status: 0x%02x", status); + + if (status || !param) { + tester_pre_setup_failed(); + return; + } + + ba2str(&rp->bdaddr, addr); + manufacturer = btohs(rp->manufacturer); + supported_settings = btohl(rp->supported_settings); + current_settings = btohl(rp->current_settings); + + tester_print(" Address: %s", addr); + tester_print(" Version: 0x%02x", rp->version); + tester_print(" Manufacturer: 0x%04x", manufacturer); + tester_print(" Supported settings: 0x%08x", supported_settings); + tester_print(" Current settings: 0x%08x", current_settings); + tester_print(" Class: 0x%02x%02x%02x", + rp->dev_class[2], rp->dev_class[1], rp->dev_class[0]); + tester_print(" Name: %s", rp->name); + tester_print(" Short name: %s", rp->short_name); + + if (strcmp(hciemu_get_address(data->hciemu), addr)) { + tester_pre_setup_failed(); + return; + } + + tester_pre_setup_complete(); +} + +static void index_added_callback(uint16_t index, uint16_t length, + const void *param, void *user_data) +{ + struct test_data *data = tester_get_data(); + + tester_print("Index Added callback"); + tester_print(" Index: 0x%04x", index); + + data->mgmt_index = index; + + mgmt_send(data->mgmt, MGMT_OP_READ_INFO, data->mgmt_index, 0, NULL, + read_info_callback, NULL, NULL); +} + +static void index_removed_callback(uint16_t index, uint16_t length, + const void *param, void *user_data) +{ + struct test_data *data = tester_get_data(); + + tester_print("Index Removed callback"); + tester_print(" Index: 0x%04x", index); + + if (index != data->mgmt_index) + return; + + mgmt_unregister_index(data->mgmt, data->mgmt_index); + + mgmt_unref(data->mgmt); + data->mgmt = NULL; + + tester_post_teardown_complete(); +} + +static void hciemu_debug(const char *str, void *user_data) +{ + const char *prefix = user_data; + + tester_print("%s%s", prefix, str); +} + +static void read_index_list_callback(uint8_t status, uint16_t length, + const void *param, void *user_data) +{ + struct test_data *data = tester_get_data(); + + tester_print("Read Index List callback"); + tester_print(" Status: 0x%02x", status); + + if (status || !param) { + tester_pre_setup_failed(); + return; + } + + mgmt_register(data->mgmt, MGMT_EV_INDEX_ADDED, MGMT_INDEX_NONE, + index_added_callback, NULL, NULL); + + mgmt_register(data->mgmt, MGMT_EV_INDEX_REMOVED, MGMT_INDEX_NONE, + index_removed_callback, NULL, NULL); + + data->hciemu = hciemu_new_num(HCIEMU_TYPE_BREDRLE52, data->client_num); + if (!data->hciemu) { + tester_warn("Failed to setup HCI emulation"); + tester_pre_setup_failed(); + return; + } + + if (tester_use_debug()) + hciemu_set_debug(data->hciemu, hciemu_debug, "hciemu: ", NULL); + + tester_print("New hciemu instance created"); +} + +static void test_pre_setup(const void *test_data) +{ + struct test_data *data = tester_get_data(); + + data->mgmt = mgmt_new_default(); + if (!data->mgmt) { + tester_warn("Failed to setup management interface"); + tester_pre_setup_failed(); + return; + } + + if (tester_use_debug()) + mgmt_set_debug(data->mgmt, mgmt_debug, "mgmt: ", NULL); + + mgmt_send(data->mgmt, MGMT_OP_READ_INDEX_LIST, MGMT_INDEX_NONE, 0, NULL, + read_index_list_callback, NULL, NULL); +} + +static void test_post_teardown(const void *test_data) +{ + struct test_data *data = tester_get_data(); + + hciemu_unref(data->hciemu); + data->hciemu = NULL; +} + +static void test_data_free(void *test_data) +{ + struct test_data *data = test_data; + + if (data->io_id[0] > 0) + g_source_remove(data->io_id[0]); + + if (data->io_id[1] > 0) + g_source_remove(data->io_id[1]); + + free(data); +} + +#define test_iso_full(name, data, setup, func, num) \ + do { \ + struct test_data *user; \ + user = new0(struct test_data, 1); \ + if (!user) \ + break; \ + user->hciemu_type = HCIEMU_TYPE_BREDRLE; \ + user->test_data = data; \ + user->client_num = num; \ + tester_add_full(name, data, \ + test_pre_setup, setup, func, NULL, \ + test_post_teardown, 2, user, test_data_free); \ + } while (0) + +#define test_iso(name, data, setup, func) \ + test_iso_full(name, data, setup, func, 1) + +#define test_iso2(name, data, setup, func) \ + test_iso_full(name, data, setup, func, 2) + +static const struct iso_client_data connect_8_1_1 = { + .qos = QOS_8_1_1, + .expect_err = 0 +}; + +static const struct iso_client_data connect_8_2_1 = { + .qos = QOS_8_2_1, + .expect_err = 0 +}; + +static const struct iso_client_data connect_16_1_1 = { + .qos = QOS_16_1_1, + .expect_err = 0 +}; + +static const struct iso_client_data connect_16_2_1 = { + .qos = QOS_16_2_1, + .expect_err = 0 +}; + +static const struct iso_client_data connect_24_1_1 = { + .qos = QOS_24_1_1, + .expect_err = 0 +}; + +static const struct iso_client_data connect_24_2_1 = { + .qos = QOS_24_2_1, + .expect_err = 0 +}; + +static const struct iso_client_data connect_32_1_1 = { + .qos = QOS_32_1_1, + .expect_err = 0 +}; + +static const struct iso_client_data connect_32_2_1 = { + .qos = QOS_32_2_1, + .expect_err = 0 +}; + +static const struct iso_client_data connect_44_1_1 = { + .qos = QOS_44_1_1, + .expect_err = 0 +}; + +static const struct iso_client_data connect_44_2_1 = { + .qos = QOS_44_2_1, + .expect_err = 0 +}; + +static const struct iso_client_data connect_48_1_1 = { + .qos = QOS_48_1_1, + .expect_err = 0 +}; + +static const struct iso_client_data connect_48_2_1 = { + .qos = QOS_48_2_1, + .expect_err = 0 +}; + +static const struct iso_client_data connect_48_3_1 = { + .qos = QOS_48_3_1, + .expect_err = 0 +}; + +static const struct iso_client_data connect_48_4_1 = { + .qos = QOS_48_4_1, + .expect_err = 0 +}; + +static const struct iso_client_data connect_48_5_1 = { + .qos = QOS_48_5_1, + .expect_err = 0 +}; + +static const struct iso_client_data connect_48_6_1 = { + .qos = QOS_48_6_1, + .expect_err = 0 +}; + +static const struct iso_client_data connect_8_1_2 = { + .qos = QOS_8_1_2, + .expect_err = 0 +}; + +static const struct iso_client_data connect_8_2_2 = { + .qos = QOS_8_2_2, + .expect_err = 0 +}; + +static const struct iso_client_data connect_16_1_2 = { + .qos = QOS_16_1_2, + .expect_err = 0 +}; + +static const struct iso_client_data connect_16_2_2 = { + .qos = QOS_16_2_2, + .expect_err = 0 +}; + +static const struct iso_client_data connect_24_1_2 = { + .qos = QOS_24_1_2, + .expect_err = 0 +}; + +static const struct iso_client_data connect_24_2_2 = { + .qos = QOS_24_2_2, + .expect_err = 0 +}; + +static const struct iso_client_data connect_32_1_2 = { + .qos = QOS_32_1_2, + .expect_err = 0 +}; + +static const struct iso_client_data connect_32_2_2 = { + .qos = QOS_32_2_2, + .expect_err = 0 +}; + +static const struct iso_client_data connect_44_1_2 = { + .qos = QOS_44_1_2, + .expect_err = 0 +}; + +static const struct iso_client_data connect_44_2_2 = { + .qos = QOS_44_2_2, + .expect_err = 0 +}; + +static const struct iso_client_data connect_48_1_2 = { + .qos = QOS_48_1_2, + .expect_err = 0 +}; + +static const struct iso_client_data connect_48_2_2 = { + .qos = QOS_48_2_2, + .expect_err = 0 +}; + +static const struct iso_client_data connect_48_3_2 = { + .qos = QOS_48_3_2, + .expect_err = 0 +}; + +static const struct iso_client_data connect_48_4_2 = { + .qos = QOS_48_4_2, + .expect_err = 0 +}; + +static const struct iso_client_data connect_48_5_2 = { + .qos = QOS_48_5_2, + .expect_err = 0 +}; + +static const struct iso_client_data connect_48_6_2 = { + .qos = QOS_48_6_2, + .expect_err = 0 +}; + +static void client_connectable_complete(uint16_t opcode, uint8_t status, + const void *param, uint8_t len, + void *user_data) +{ + struct test_data *data = user_data; + static uint8_t client_num; + + if (opcode != BT_HCI_CMD_LE_SET_EXT_ADV_ENABLE) + return; + + tester_print("Client %u set connectable status 0x%02x", client_num, + status); + + client_num++; + + if (status) + tester_setup_failed(); + else if (data->client_num == client_num) { + tester_setup_complete(); + client_num = 0; + } +} + +static void setup_powered_callback(uint8_t status, uint16_t length, + const void *param, void *user_data) +{ + struct test_data *data = tester_get_data(); + uint8_t i; + + if (status != MGMT_STATUS_SUCCESS) { + tester_setup_failed(); + return; + } + + tester_print("Controller powered on"); + + for (i = 0; i < data->client_num; i++) { + struct hciemu_client *client; + struct bthost *host; + + client = hciemu_get_client(data->hciemu, i); + host = hciemu_client_host(client); + bthost_set_cmd_complete_cb(host, client_connectable_complete, + data); + bthost_set_ext_adv_enable(host, 0x01); + } +} + +static void setup_powered(const void *test_data) +{ + struct test_data *data = tester_get_data(); + unsigned char param[] = { 0x01 }; + + tester_print("Powering on controller"); + + mgmt_send(data->mgmt, MGMT_OP_SET_CONNECTABLE, data->mgmt_index, + sizeof(param), param, + NULL, NULL, NULL); + + mgmt_send(data->mgmt, MGMT_OP_SET_SSP, data->mgmt_index, + sizeof(param), param, NULL, NULL, NULL); + + mgmt_send(data->mgmt, MGMT_OP_SET_LE, data->mgmt_index, + sizeof(param), param, NULL, NULL, NULL); + + mgmt_send(data->mgmt, MGMT_OP_SET_POWERED, data->mgmt_index, + sizeof(param), param, + setup_powered_callback, NULL, NULL); +} + +static void test_framework(const void *test_data) +{ + tester_test_passed(); +} + +static void test_socket(const void *test_data) +{ + int sk; + + sk = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_ISO); + if (sk < 0) { + tester_warn("Can't create socket: %s (%d)", strerror(errno), + errno); + tester_test_abort(); + return; + } + + close(sk); + + tester_test_passed(); +} + +static void test_getsockopt(const void *test_data) +{ + int sk, err; + socklen_t len; + struct bt_iso_qos qos; + + sk = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_ISO); + if (sk < 0) { + tester_warn("Can't create socket: %s (%d)", strerror(errno), + errno); + tester_test_abort(); + return; + } + + len = sizeof(qos); + memset(&qos, 0, len); + + err = getsockopt(sk, SOL_BLUETOOTH, BT_ISO_QOS, &qos, &len); + if (err < 0) { + tester_warn("Can't get socket option : %s (%d)", + strerror(errno), errno); + tester_test_failed(); + goto end; + } + + tester_test_passed(); + +end: + close(sk); +} + +static void test_setsockopt(const void *test_data) +{ + int sk, err; + socklen_t len; + struct bt_iso_qos qos = QOS_16_1_2; + + sk = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_ISO); + if (sk < 0) { + tester_warn("Can't create socket: %s (%d)", strerror(errno), + errno); + tester_test_abort(); + goto end; + } + + err = setsockopt(sk, SOL_BLUETOOTH, BT_ISO_QOS, &qos, sizeof(qos)); + if (err < 0) { + tester_warn("Can't set socket option : %s (%d)", + strerror(errno), errno); + tester_test_failed(); + goto end; + } + + len = sizeof(qos); + memset(&qos, 0, len); + + err = getsockopt(sk, SOL_BLUETOOTH, BT_ISO_QOS, &qos, &len); + if (err < 0) { + tester_warn("Can't get socket option : %s (%d)", + strerror(errno), errno); + tester_test_failed(); + goto end; + } + + tester_test_passed(); + +end: + close(sk); +} + +static int create_iso_sock(struct test_data *data) +{ + const uint8_t *master_bdaddr; + struct sockaddr_iso addr; + int sk, err; + + sk = socket(PF_BLUETOOTH, SOCK_SEQPACKET | SOCK_NONBLOCK, BTPROTO_ISO); + if (sk < 0) { + err = -errno; + tester_warn("Can't create socket: %s (%d)", strerror(errno), + errno); + return -EPROTONOSUPPORT; + } + + master_bdaddr = hciemu_get_master_bdaddr(data->hciemu); + if (!master_bdaddr) { + tester_warn("No master bdaddr"); + return -ENODEV; + } + + memset(&addr, 0, sizeof(addr)); + addr.iso_family = AF_BLUETOOTH; + bacpy(&addr.iso_bdaddr, (void *) master_bdaddr); + addr.iso_bdaddr_type = BDADDR_LE_PUBLIC; + + if (bind(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) { + err = -errno; + tester_warn("Can't bind socket: %s (%d)", strerror(errno), + errno); + close(sk); + return err; + } + + return sk; +} + +static int connect_iso_sock(struct test_data *data, uint8_t num, int sk) +{ + const struct iso_client_data *isodata = data->test_data; + struct hciemu_client *client; + const uint8_t *client_bdaddr; + struct sockaddr_iso addr; + char str[18]; + int err; + + client = hciemu_get_client(data->hciemu, num); + if (!client) { + tester_warn("No client"); + return -ENODEV; + } + + client_bdaddr = hciemu_client_bdaddr(client); + if (!client_bdaddr) { + tester_warn("No client bdaddr"); + return -ENODEV; + } + + err = setsockopt(sk, SOL_BLUETOOTH, BT_ISO_QOS, &isodata->qos, + sizeof(isodata->qos)); + if (err < 0) { + tester_warn("Can't set socket option : %s (%d)", + strerror(errno), errno); + tester_test_failed(); + return -EINVAL; + } + + memset(&addr, 0, sizeof(addr)); + addr.iso_family = AF_BLUETOOTH; + bacpy(&addr.iso_bdaddr, (void *) client_bdaddr); + addr.iso_bdaddr_type = BDADDR_LE_PUBLIC; + + ba2str(&addr.iso_bdaddr, str); + + tester_print("Connecting to %s...", str); + + err = connect(sk, (struct sockaddr *) &addr, sizeof(addr)); + if (err < 0 && !(errno == EAGAIN || errno == EINPROGRESS)) { + err = -errno; + tester_warn("Can't connect socket: %s (%d)", strerror(errno), + errno); + return err; + } + + return 0; +} + +static bool check_io_qos(const struct bt_iso_io_qos *io1, + const struct bt_iso_io_qos *io2) +{ + if (io1->interval != io2->interval) { + tester_warn("Unexpected IO interval: %u != %u", + io1->interval, io2->interval); + return false; + } + + if (io1->latency != io2->latency) { + tester_warn("Unexpected IO latency: %u != %u", + io1->latency, io2->latency); + return false; + } + + if (io1->sdu != io2->sdu) { + tester_warn("Unexpected IO SDU: %u != %u", io1->sdu, io2->sdu); + return false; + } + + if (io2->phy && io1->phy != io2->phy) { + tester_warn("Unexpected IO PHY: 0x%02x != 0x%02x", + io1->phy, io2->phy); + return false; + } + + if (io1->rtn != io2->rtn) { + tester_warn("Unexpected IO RTN: %u != %u", io1->rtn, io2->rtn); + return false; + } + + return true; +} + +static bool check_qos(const struct bt_iso_qos *qos1, + const struct bt_iso_qos *qos2) +{ + if (qos1->packing != qos2->packing) { + tester_warn("Unexpected QoS packing: 0x%02x != 0x%02x", + qos1->packing, qos2->packing); + return false; + } + + if (qos1->framing != qos2->framing) { + tester_warn("Unexpected QoS framing: 0x%02x != 0x%02x", + qos1->framing, qos2->framing); + return false; + } + + if (!check_io_qos(&qos1->in, &qos2->in)) { + tester_warn("Unexpected Input QoS"); + return false; + } + + if (!check_io_qos(&qos1->out, &qos2->out)) { + tester_warn("Unexpected Output QoS"); + return false; + } + + return true; +} + +static gboolean iso_connect(GIOChannel *io, GIOCondition cond, + gpointer user_data) +{ + struct test_data *data = tester_get_data(); + const struct iso_client_data *isodata = data->test_data; + int err, sk_err, sk; + socklen_t len; + struct bt_iso_qos qos; + + data->io_id[0] = 0; + + sk = g_io_channel_unix_get_fd(io); + + len = sizeof(qos); + memset(&qos, 0, len); + + err = getsockopt(sk, SOL_BLUETOOTH, BT_ISO_QOS, &qos, &len); + if (err < 0) { + tester_warn("Can't get socket option : %s (%d)", + strerror(errno), errno); + tester_test_failed(); + return FALSE; + } + + if (!check_qos(&qos, &isodata->qos)) { + tester_warn("Unexpected QoS parameter"); + tester_test_failed(); + return FALSE; + } + + len = sizeof(sk_err); + + if (getsockopt(sk, SOL_SOCKET, SO_ERROR, &sk_err, &len) < 0) + err = -errno; + else + err = -sk_err; + + if (err < 0) + tester_warn("Connect failed: %s (%d)", strerror(-err), -err); + else + tester_print("Successfully connected"); + + if (-err != isodata->expect_err) + tester_test_failed(); + else { + data->step--; + if (data->step) + tester_print("Step %u", data->step); + else + tester_test_passed(); + } + + return FALSE; +} + +static gboolean iso_connect_cb(GIOChannel *io, GIOCondition cond, + gpointer user_data) +{ + struct test_data *data = tester_get_data(); + + data->io_id[0] = 0; + + return iso_connect(io, cond, user_data); +} + +static gboolean iso_connect2_cb(GIOChannel *io, GIOCondition cond, + gpointer user_data) +{ + struct test_data *data = tester_get_data(); + + data->io_id[1] = 0; + + return iso_connect(io, cond, user_data); +} + +static void setup_connect(struct test_data *data, uint8_t num, GIOFunc func) +{ + GIOChannel *io; + int sk; + + sk = create_iso_sock(data); + if (sk < 0) { + if (sk == -EPROTONOSUPPORT) + tester_test_abort(); + else + tester_test_failed(); + return; + } + + if (connect_iso_sock(data, num, sk) < 0) { + close(sk); + tester_test_failed(); + return; + } + + io = g_io_channel_unix_new(sk); + g_io_channel_set_close_on_unref(io, TRUE); + + data->io_id[num] = g_io_add_watch(io, G_IO_OUT, func, NULL); + + g_io_channel_unref(io); + + tester_print("Connect in progress"); + + data->step++; +} + +static void test_connect(const void *test_data) +{ + struct test_data *data = tester_get_data(); + + setup_connect(data, 0, iso_connect_cb); +} + +static void test_connect2(const void *test_data) +{ + struct test_data *data = tester_get_data(); + + setup_connect(data, 0, iso_connect_cb); + setup_connect(data, 1, iso_connect2_cb); +} + +int main(int argc, char *argv[]) +{ + tester_init(&argc, &argv); + + test_iso("Basic Framework - Success", NULL, setup_powered, + test_framework); + + test_iso("Basic ISO Socket - Success", NULL, setup_powered, + test_socket); + + test_iso("Basic ISO Get Socket Option - Success", NULL, setup_powered, + test_getsockopt); + + test_iso("Basic ISO Set Socket Option - Success", NULL, setup_powered, + test_setsockopt); + + test_iso("ISO QoS 8_1_1 - Success", &connect_8_1_1, setup_powered, + test_connect); + + test_iso("ISO QoS 8_2_1 - Success", &connect_8_2_1, setup_powered, + test_connect); + + test_iso("ISO QoS 16_1_1 - Success", &connect_16_1_1, setup_powered, + test_connect); + + test_iso("ISO QoS 16_2_1 - Success", &connect_16_2_1, setup_powered, + test_connect); + + test_iso("ISO QoS 24_1_1 - Success", &connect_24_1_1, setup_powered, + test_connect); + + test_iso("ISO QoS 24_2_1 - Success", &connect_24_2_1, setup_powered, + test_connect); + + test_iso("ISO QoS 32_1_1 - Success", &connect_32_1_1, setup_powered, + test_connect); + + test_iso("ISO QoS 32_2_1 - Success", &connect_32_2_1, setup_powered, + test_connect); + + test_iso("ISO QoS 44_1_1 - Success", &connect_44_1_1, setup_powered, + test_connect); + + test_iso("ISO QoS 44_2_1 - Success", &connect_44_2_1, setup_powered, + test_connect); + + test_iso("ISO QoS 48_1_1 - Success", &connect_48_1_1, setup_powered, + test_connect); + + test_iso("ISO QoS 48_2_1 - Success", &connect_48_2_1, setup_powered, + test_connect); + + test_iso("ISO QoS 48_3_1 - Success", &connect_48_3_1, setup_powered, + test_connect); + + test_iso("ISO QoS 48_4_1 - Success", &connect_48_4_1, setup_powered, + test_connect); + + test_iso("ISO QoS 48_5_1 - Success", &connect_48_5_1, setup_powered, + test_connect); + + test_iso("ISO QoS 48_6_1 - Success", &connect_48_6_1, setup_powered, + test_connect); + + test_iso("ISO QoS 8_1_2 - Success", &connect_8_1_2, setup_powered, + test_connect); + + test_iso("ISO QoS 8_2_2 - Success", &connect_8_2_2, setup_powered, + test_connect); + + test_iso("ISO QoS 16_1_2 - Success", &connect_16_1_2, setup_powered, + test_connect); + + test_iso("ISO QoS 16_2_2 - Success", &connect_16_2_2, setup_powered, + test_connect); + + test_iso("ISO QoS 24_1_2 - Success", &connect_24_1_2, setup_powered, + test_connect); + + test_iso("ISO QoS 24_2_2 - Success", &connect_24_2_2, setup_powered, + test_connect); + + test_iso("ISO QoS 32_1_2 - Success", &connect_32_1_2, setup_powered, + test_connect); + + test_iso("ISO QoS 32_2_2 - Success", &connect_32_2_2, setup_powered, + test_connect); + + test_iso("ISO QoS 44_1_2 - Success", &connect_44_1_2, setup_powered, + test_connect); + + test_iso("ISO QoS 44_2_2 - Success", &connect_44_2_2, setup_powered, + test_connect); + + test_iso("ISO QoS 48_1_2 - Success", &connect_48_1_2, setup_powered, + test_connect); + + test_iso("ISO QoS 48_2_2 - Success", &connect_48_2_2, setup_powered, + test_connect); + + test_iso("ISO QoS 48_3_2 - Success", &connect_48_3_2, setup_powered, + test_connect); + + test_iso("ISO QoS 48_4_2 - Success", &connect_48_4_2, setup_powered, + test_connect); + + test_iso("ISO QoS 48_5_2 - Success", &connect_48_5_2, setup_powered, + test_connect); + + test_iso("ISO QoS 48_6_2 - Success", &connect_48_6_2, setup_powered, + test_connect); + + test_iso2("ISO Connect2 - Success", &connect_16_2_1, setup_powered, + test_connect2); + + return tester_run(); +} diff --git a/tools/test-runner.c b/tools/test-runner.c index a17ec594a..c27f7549e 100644 --- a/tools/test-runner.c +++ b/tools/test-runner.c @@ -188,7 +188,6 @@ static char *const qemu_argv[] = { "-machine", "type=q35,accel=kvm:tcg", "-m", "192M", "-nographic", - "-vga", "none", "-net", "none", "-no-acpi", "-no-hpet", @@ -245,7 +244,7 @@ static void start_qemu(void) snprintf(cmdline, sizeof(cmdline), "console=ttyS0,115200n8 earlyprintk=serial " "rootfstype=9p " - "rootflags=trans=virtio,version=9p2000.L " + "rootflags=trans=virtio,version=9p2000.u " "acpi=off pci=noacpi noapic quiet ro init=%s " "TESTHOME=%s TESTDBUS=%u TESTMONITOR=%u " "TESTDEVS=%d TESTAUTO=%u TESTARGS=\'%s\'", @@ -523,6 +522,7 @@ static const char *test_table[] = { "l2cap-tester", "rfcomm-tester", "sco-tester", + "iso-tester", "bnep-tester", "check-selftest", "tools/mgmt-tester", @@ -530,6 +530,7 @@ static const char *test_table[] = { "tools/l2cap-tester", "tools/rfcomm-tester", "tools/sco-tester", + "tools/iso-tester", "tools/bnep-tester", "tools/check-selftest", NULL