From patchwork Wed Mar 18 21:51:19 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: 197267 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=-6.8 required=3.0 tests=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, 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 C7641C4332D for ; Wed, 18 Mar 2020 21:51:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 881822076C for ; Wed, 18 Mar 2020 21:51:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="tKu6ResE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727070AbgCRVv2 (ORCPT ); Wed, 18 Mar 2020 17:51:28 -0400 Received: from mail-pf1-f182.google.com ([209.85.210.182]:42923 "EHLO mail-pf1-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726776AbgCRVv2 (ORCPT ); Wed, 18 Mar 2020 17:51:28 -0400 Received: by mail-pf1-f182.google.com with SMTP id x2so194969pfn.9 for ; Wed, 18 Mar 2020 14:51:27 -0700 (PDT) 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=MPfZ6Ur90/9wCSGmoi9z3v0hkVuFY/fVXq73vDSGlUE=; b=tKu6ResEkrxWegWROAp/ZLoohDnRUUNx3g2fdEXjRfwTlr9TTe9hQkYJKJW6F+Ygdh GVtZyIHHKgTHasL26gXlRmNeG/zadwwJPiuIuk5jjgYf6E0E2wSbfsImodxXwW/wXS7+ CtWhx27+oRTBGKLjJwCw2VNHI600NBJxeu7wlRsC/Avqi9fN15SlfQqrzl++PQJWxwkt ZO5/jqmX1/60FmU1W3aU9S8jO5PqT7shzzb2Dx61cpv0JWm4x3O9X2JnC5/Rpon3nP5E LSIA9S1yM8uAamexU9hAe+z0YEzSLJOYIjIMDxUA+Em3pFooEDEORDPxgrOUbxng+wfY qdvA== 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=MPfZ6Ur90/9wCSGmoi9z3v0hkVuFY/fVXq73vDSGlUE=; b=ZN388xwUP4/XmPyKKQqL15VhSfynq6Mp/jECK2xfoxvI7zQ0zKb6191Ee2yt5t85cl HM77XswRhRHPisFMOJAxRrqAEPxx/9cUxPfO+tR3/4aPYP4fCr7f++zPaUji6C74MtsR wkZAjtXmVdIg586ZJfZU+pFle0fQHi3f/2UdRk5CA3eT1LVIplnP0iT3jpMsGftPsJGA YrVQ8dFv/2RbF0RkfomHgFYgbrjGj3RozrKWp+0ylanrHXFYqNI91GsiK1JR6QPjDmmp moCxhH3gtos7+QuylZdht4Ycd53Dv0aZplhsaqP+nxjxZ2h+s/OV9Zok4Q6Sy0+Aqx6S yiSw== X-Gm-Message-State: ANhLgQ0XmHDvhfCbZojdudNRxPXPaRX01MdhhtUE5Rk0OzCX1KCIN6Do gzhFN85OJwg3D7loLm/LlTFPo1Gs X-Google-Smtp-Source: ADFU+vtkYY/DwSP3hwTZLiuzC5Nq8nHkBolU2YfyCdL63s5XKP0DEsGf4Ld0SMfx6ozuEVEv+wS6eg== X-Received: by 2002:a62:15d3:: with SMTP id 202mr386765pfv.231.1584568286123; Wed, 18 Mar 2020 14:51:26 -0700 (PDT) Received: from localhost.localdomain (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id r13sm83709pgf.1.2020.03.18.14.51.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Mar 2020 14:51:25 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH v3 1/6] lib: Add definitions for Enhanced Credits Based Mode Date: Wed, 18 Mar 2020 14:51:19 -0700 Message-Id: <20200318215124.21880-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.21.1 MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz --- lib/bluetooth.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/bluetooth.h b/lib/bluetooth.h index d14217eac..121010c63 100644 --- a/lib/bluetooth.h +++ b/lib/bluetooth.h @@ -141,6 +141,15 @@ struct bt_voice { #define BT_PHY_LE_CODED_TX 0x00002000 #define BT_PHY_LE_CODED_RX 0x00004000 +#define BT_MODE 15 + +#define BT_MODE_BASIC 0x00 +#define BT_MODE_RETRANS 0x01 +#define BT_MODE_FLOWCTL 0x02 +#define BT_MODE_ERTM 0x03 +#define BT_MODE_STREAMING 0x04 +#define BT_MODE_EXT_FLOWCTL 0x05 + /* Connection and socket states */ enum { BT_CONNECTED = 1, /* Equal to TCP_ESTABLISHED to make net code happy */ From patchwork Wed Mar 18 21:51:21 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: 197266 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=-6.8 required=3.0 tests=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, 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 7F877C43332 for ; Wed, 18 Mar 2020 21:51:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 530D42076C for ; Wed, 18 Mar 2020 21:51:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Zt8SA79V" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727113AbgCRVva (ORCPT ); Wed, 18 Mar 2020 17:51:30 -0400 Received: from mail-pj1-f65.google.com ([209.85.216.65]:50426 "EHLO mail-pj1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726930AbgCRVv3 (ORCPT ); Wed, 18 Mar 2020 17:51:29 -0400 Received: by mail-pj1-f65.google.com with SMTP id v13so32083pjb.0 for ; Wed, 18 Mar 2020 14:51:28 -0700 (PDT) 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=IBv8hQNbmpTa0AIoocboT1khiHc/5SGjGyL7viltjm4=; b=Zt8SA79VXMfVqmZWlveNoE4Of4buWhfNqcJKJREajFthUEnZlIWiOzPSNs3HnfCl5F jslFsIQAiF5T0fiRT6jxNWy3wNs9Q1GncYj4MWIBoZjA0K/+cnvUevj/8MSJggMvPXXV RrKU2sT0nWy4c/H3Cn3CItwG4EqbfgeGeIh8E5jmie1Giveo+PAxVSFefDtjNj098aZT d3v6TDezKVXkUxOSFc+hdWCY57MrGhKWO1gUnvqsCbaP7G/H92w7YUeWABzRjcjtsJYv hVQYili67Kc6+lM7y5D+6xfZCJLtl/RIX9w7B0J9GdtDvJJ480mLjfBuyvkMIvHJBPd+ J+Gw== 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=IBv8hQNbmpTa0AIoocboT1khiHc/5SGjGyL7viltjm4=; b=r/ymk1AyyIWem/Nj7eCEf8Knk0iC7+Rz1BWkyjSpqV+GciihhOg4zsOXrClzXBxnSD xz7El22mlMHt22ZZSas00VvJagi3GP8K3L7PFqTk/0eN8JwBzUGAp8/NrGnMNTKnu2lO gO/sohkPUmGvPD4LedhhuD/uRELsAs0VQzMLO9o1ztYIp/zBLcp2ENLBBrMZZMZUU2co zO2gDFK5r5aBh611gGGRUwG5kSCTjjz25daXpFzhvrNLQ2fl4XRM4RpesDCGr1h90y60 OUBnzYPSs2qGTTr0xcFlwPrTFRhVAmcGL5s22MNWnywRhceKmOq84Jl/eT0saazpSM9C j9LQ== X-Gm-Message-State: ANhLgQ02/QCypSa3pQngBk+gqrMXB4n2s6w4pRLcF/jP1OYjbc5eR+UR NtEDzSGo2N6K8yW/UQsp8pg4mSfd X-Google-Smtp-Source: ADFU+vsgMQ4/V8917NndWUnDqZeR9Ownb/Tn8+ng5m57YPJO9wZG5z2EzFQ7SA/5fJsOSOUwww/FOA== X-Received: by 2002:a17:90a:37c6:: with SMTP id v64mr313925pjb.20.1584568287933; Wed, 18 Mar 2020 14:51:27 -0700 (PDT) Received: from localhost.localdomain (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id r13sm83709pgf.1.2020.03.18.14.51.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Mar 2020 14:51:27 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH v3 3/6] l2test: Add support for BT_MODE_EXT_FLOWCTL Date: Wed, 18 Mar 2020 14:51:21 -0700 Message-Id: <20200318215124.21880-3-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200318215124.21880-1-luiz.dentz@gmail.com> References: <20200318215124.21880-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This enables using l2test to connect or listen with BT_MODE_EXT_FLOWCTL. --- tools/l2test.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/tools/l2test.c b/tools/l2test.c index 8c6e08646..0d846ed93 100644 --- a/tools/l2test.c +++ b/tools/l2test.c @@ -143,13 +143,14 @@ struct lookup_table { }; static struct lookup_table l2cap_modes[] = { - { "basic", L2CAP_MODE_BASIC }, + { "basic", BT_MODE_BASIC }, /* Not implemented - { "flowctl", L2CAP_MODE_FLOWCTL }, - { "retrans", L2CAP_MODE_RETRANS }, + { "flowctl", BT_MODE_FLOWCTL }, + { "retrans", BT_MODE_RETRANS }, */ - { "ertm", L2CAP_MODE_ERTM }, - { "streaming", L2CAP_MODE_STREAMING }, + { "ertm", BT_MODE_ERTM }, + { "streaming", BT_MODE_STREAMING }, + { "ext-flowctl",BT_MODE_EXT_FLOWCTL }, { 0 } }; @@ -283,7 +284,7 @@ static int getopts(int sk, struct l2cap_options *opts, bool connected) memset(opts, 0, sizeof(*opts)); - if (bdaddr_type == BDADDR_BREDR) { + if (bdaddr_type == BDADDR_BREDR || rfcmode) { optlen = sizeof(*opts); return getsockopt(sk, SOL_L2CAP, L2CAP_OPTIONS, opts, &optlen); } @@ -303,6 +304,13 @@ static int setopts(int sk, struct l2cap_options *opts) return setsockopt(sk, SOL_L2CAP, L2CAP_OPTIONS, opts, sizeof(*opts)); + if (opts->mode) { + if (setsockopt(sk, SOL_BLUETOOTH, BT_MODE, &opts->mode, + sizeof(opts->mode)) < 0) { + return -errno; + } + } + return setsockopt(sk, SOL_BLUETOOTH, BT_RCVMTU, &opts->imtu, sizeof(opts->imtu)); } From patchwork Wed Mar 18 21:51:24 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: 197265 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=-6.8 required=3.0 tests=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, 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 20C08C4332B for ; Wed, 18 Mar 2020 21:51:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E6DF92076C for ; Wed, 18 Mar 2020 21:51:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="j2py525b" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727177AbgCRVvc (ORCPT ); Wed, 18 Mar 2020 17:51:32 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:37067 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727132AbgCRVvc (ORCPT ); Wed, 18 Mar 2020 17:51:32 -0400 Received: by mail-pl1-f193.google.com with SMTP id f16so94130plj.4 for ; Wed, 18 Mar 2020 14:51:32 -0700 (PDT) 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=Lg7nkN4mkSlGzt343AERUU8DxSDQ1y02ISUsPdPcwHY=; b=j2py525b4u7qXtRQcjGH8PvWFOuhkN+Hl3qf1SXXsNkQUK4hbJ2R8ZvFb1Dv2wNElO qvTZsBnOKCoQaGhsP15ewYhn/2GUKOy2hjpouDXA66UcmlGX5w5Ue05CMB1lN3OWiahf oqy21uXtJ07sefy4vgVqdXwn5xdmfcWXW2uy30EkviEhT4BPqDQGkhoJ4lohNzOJn0OI oj/5v8fOSiP7zOW4+wDwJVwSzOhyBrrFiRGYjjvRKtZKaldQKlPyVKAtujblw3SLVgIo pbEBOIBuNP1eUS+kkHI+zCnA8yigJZtsp6QDlAPxnStbqLyskjISQPC8xVowohsqUleW l5CQ== 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=Lg7nkN4mkSlGzt343AERUU8DxSDQ1y02ISUsPdPcwHY=; b=iunVRrUiUxYslQaTEbEUggwDCLdAKVHIK8pXqnPEi22iuybDMwNKi7HKAosGTNUYiZ 5s4iPCtlY8JRkvzo+FBfO+NJqvjYCQ5mF0WE/4w+HafYDpgdDcif9YEOKUI70YF24Wjd Tj1gOo4Gn/ikmjfGgu8MTKhCJ+QNzeoQd3W5BhY8jInA58Psg6g0XwzxBmm7d65njNma g8qK499fWZvv3GIrP2sPpyaEANi2G19bTAKmXssHSflAhVEmuxbG0D9QNORcqbY9Q4lj Oa+MG6pT4saqsWuDFORU/ThwiPMVDehZi/1bU3847e2+H7YbEg6+LN22RqNi3a5U05Wg UUzg== X-Gm-Message-State: ANhLgQ1tycqW+aP95CerUrryim6nIOYWQmvxsXM5fGiHVBF0l+55gihL jwS25777baCHaJySMrPQqnOlcM4F X-Google-Smtp-Source: ADFU+vsKmUfJuGdbVN+B8ZoIfX0ODLQtOylzl6B4/rJiRIXJThJV26W3PUO5+2izMTOiX4aDc4dbdg== X-Received: by 2002:a17:90a:a891:: with SMTP id h17mr274498pjq.182.1584568291096; Wed, 18 Mar 2020 14:51:31 -0700 (PDT) Received: from localhost.localdomain (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id r13sm83709pgf.1.2020.03.18.14.51.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Mar 2020 14:51:30 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH v3 6/6] gatt: Enable connecting to EATT channel using Ext-Flowctl mode Date: Wed, 18 Mar 2020 14:51:24 -0700 Message-Id: <20200318215124.21880-6-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200318215124.21880-1-luiz.dentz@gmail.com> References: <20200318215124.21880-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This makes use of BT_IO_MODE_EXT_FLOWCTL to connect to EATT channels. --- src/gatt-client.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/src/gatt-client.c b/src/gatt-client.c index 20efb7ae9..a9bfc2802 100644 --- a/src/gatt-client.c +++ b/src/gatt-client.c @@ -2182,9 +2182,13 @@ static void eatt_connect(struct btd_gatt_client *client) ba2str(device_get_address(dev), addr); - DBG("Connection attempt to: %s", addr); - for (i = bt_att_get_channels(att); i < main_opts.gatt_channels; i++) { + int defer_timeout = i + 1 < main_opts.gatt_channels ? 1 : 0; + + DBG("Connection attempt to: %s defer %s", addr, + defer_timeout ? "true" : "false"); + + /* Attempt to connect using the Ext-Flowctl */ io = bt_io_connect(eatt_connect_cb, client, NULL, &gerr, BT_IO_OPT_SOURCE_BDADDR, btd_adapter_get_address(adapter), @@ -2194,15 +2198,35 @@ static void eatt_connect(struct btd_gatt_client *client) device_get_address(dev), BT_IO_OPT_DEST_TYPE, device_get_le_address_type(dev), + BT_IO_OPT_MODE, BT_IO_MODE_EXT_FLOWCTL, BT_IO_OPT_PSM, BT_ATT_EATT_PSM, BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_LOW, BT_IO_OPT_MTU, main_opts.gatt_mtu, + BT_IO_OPT_DEFER_TIMEOUT, defer_timeout, BT_IO_OPT_INVALID); if (!io) { - error("EATT bt_io_connect(%s): %s", addr, - gerr->message); g_error_free(gerr); - return; + gerr = NULL; + /* Fallback to legacy LE Mode */ + io = bt_io_connect(eatt_connect_cb, client, NULL, &gerr, + BT_IO_OPT_SOURCE_BDADDR, + btd_adapter_get_address(adapter), + BT_IO_OPT_SOURCE_TYPE, + btd_adapter_get_address_type(adapter), + BT_IO_OPT_DEST_BDADDR, + device_get_address(dev), + BT_IO_OPT_DEST_TYPE, + device_get_le_address_type(dev), + BT_IO_OPT_PSM, BT_ATT_EATT_PSM, + BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_LOW, + BT_IO_OPT_MTU, main_opts.gatt_mtu, + BT_IO_OPT_INVALID); + if (!io) { + error("EATT bt_io_connect(%s): %s", addr, + gerr->message); + g_error_free(gerr); + return; + } } g_io_channel_unref(io);