From patchwork Mon Nov 15 09:41:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "K, Kiran" X-Patchwork-Id: 12619165 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28C8CC433F5 for ; Mon, 15 Nov 2021 09:35:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 050ED61A89 for ; Mon, 15 Nov 2021 09:35:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230432AbhKOJig (ORCPT ); Mon, 15 Nov 2021 04:38:36 -0500 Received: from mga11.intel.com ([192.55.52.93]:13725 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230162AbhKOJid (ORCPT ); Mon, 15 Nov 2021 04:38:33 -0500 X-IronPort-AV: E=McAfee;i="6200,9189,10168"; a="230870743" X-IronPort-AV: E=Sophos;i="5.87,236,1631602800"; d="scan'208";a="230870743" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2021 01:35:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,236,1631602800"; d="scan'208";a="734781772" Received: from intel-lenovo-legion-y540-15irh-pg0.iind.intel.com ([10.224.186.95]) by fmsmga006.fm.intel.com with ESMTP; 15 Nov 2021 01:35:35 -0800 From: Kiran K To: linux-bluetooth@vger.kernel.org Cc: ravishankar.srivatsa@intel.com, chethan.tumkur.narayan@intel.com, luiz.von.dentz@intel.com, Kiran K Subject: [PATCH v1 1/5] avdtp: Add a flag in struct avdtp to control a2dp offload Date: Mon, 15 Nov 2021 15:11:04 +0530 Message-Id: <20211115094108.24331-1-kiran.k@intel.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Define a flag in struct avdtp and set it based on the definition of env variable USE_OFFLOAD --- profiles/audio/avdtp.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c index d3dfbf96dda3..b6feac0ba4d5 100644 --- a/profiles/audio/avdtp.c +++ b/profiles/audio/avdtp.c @@ -409,6 +409,9 @@ struct avdtp { /* Attempt stream setup instead of disconnecting */ gboolean stream_setup; + + /* use offload for transport */ + gboolean use_offload; }; static GSList *state_callbacks = NULL; @@ -2425,6 +2428,7 @@ struct avdtp *avdtp_new(GIOChannel *chan, struct btd_device *device, struct queue *lseps) { struct avdtp *session; + char *use_offload; session = g_new0(struct avdtp, 1); @@ -2436,6 +2440,10 @@ struct avdtp *avdtp_new(GIOChannel *chan, struct btd_device *device, session->version = get_version(session); + use_offload = getenv("USE_OFFLOAD"); + if (use_offload && !strncmp(use_offload, "1", 1)) + session->use_offload = TRUE; + if (!chan) return session; From patchwork Mon Nov 15 09:41:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "K, Kiran" X-Patchwork-Id: 12619167 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8D57C433EF for ; Mon, 15 Nov 2021 09:35:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8E34961ABD for ; Mon, 15 Nov 2021 09:35:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230364AbhKOJij (ORCPT ); Mon, 15 Nov 2021 04:38:39 -0500 Received: from mga11.intel.com ([192.55.52.93]:13725 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230280AbhKOJie (ORCPT ); Mon, 15 Nov 2021 04:38:34 -0500 X-IronPort-AV: E=McAfee;i="6200,9189,10168"; a="230870747" X-IronPort-AV: E=Sophos;i="5.87,236,1631602800"; d="scan'208";a="230870747" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2021 01:35:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,236,1631602800"; d="scan'208";a="734781795" Received: from intel-lenovo-legion-y540-15irh-pg0.iind.intel.com ([10.224.186.95]) by fmsmga006.fm.intel.com with ESMTP; 15 Nov 2021 01:35:37 -0800 From: Kiran K To: linux-bluetooth@vger.kernel.org Cc: ravishankar.srivatsa@intel.com, chethan.tumkur.narayan@intel.com, luiz.von.dentz@intel.com, Kiran K Subject: [PATCH v1 2/5] avdtp: Add support for offload msft open command Date: Mon, 15 Nov 2021 15:11:05 +0530 Message-Id: <20211115094108.24331-2-kiran.k@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211115094108.24331-1-kiran.k@intel.com> References: <20211115094108.24331-1-kiran.k@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org In a2dp offload use case, controller needs to be sent MSFT avdtp command after opening media transport channel --- lib/bluetooth.h | 3 +++ profiles/audio/avdtp.c | 48 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/lib/bluetooth.h b/lib/bluetooth.h index 0fcf412c6c6b..59ef178a563a 100644 --- a/lib/bluetooth.h +++ b/lib/bluetooth.h @@ -158,6 +158,9 @@ struct bt_codecs { struct bt_codec codecs[]; } __attribute__((packed)); +#define BT_MSFT_OPEN 20 +#define BT_MSFT_CLOSE 23 + /* Connection and socket states */ enum { BT_CONNECTED = 1, /* Equal to TCP_ESTABLISHED to make net code happy */ diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c index b6feac0ba4d5..1cd4b4472b08 100644 --- a/profiles/audio/avdtp.c +++ b/profiles/audio/avdtp.c @@ -2352,6 +2352,47 @@ static uint16_t get_version(struct avdtp *session) return ver; } +static gboolean avdtp_offload_open(struct avdtp_stream *stream) +{ + int sock; + struct avdtp_service_capability *cap; + GSList *l; + + if (!stream->io) + return FALSE; + + sock = g_io_channel_unix_get_fd(stream->io); + + for (l = stream->caps; l ; l = g_slist_next(l)) { + cap = l->data; + + if (cap->category != AVDTP_MEDIA_CODEC) + continue; + break; + } + + if (setsockopt(sock, SOL_BLUETOOTH, BT_MSFT_OPEN, cap, + sizeof(*cap) + cap->length)) + return FALSE; + + return TRUE; +} + +static gboolean avdtp_offload_close(struct avdtp_stream *stream) +{ + int sock; + + if (!stream->io) + return FALSE; + + sock = g_io_channel_unix_get_fd(stream->io); + + if (setsockopt(sock, SOL_BLUETOOTH, BT_MSFT_CLOSE, 0, 0)) + return FALSE; + + return TRUE; +} + static void avdtp_connect_cb(GIOChannel *chan, GError *err, gpointer user_data) { struct avdtp *session = user_data; @@ -2385,6 +2426,13 @@ static void avdtp_connect_cb(GIOChannel *chan, GError *err, gpointer user_data) session->pending_open ? "transport" : "signaling", address); + if (session->pending_open && session->use_offload) { + if (!avdtp_offload_open(session->pending_open)) { + avdtp_offload_close(session->pending_open); + goto failed; + } + } + if (session->state == AVDTP_SESSION_STATE_CONNECTING) { DBG("AVDTP imtu=%u, omtu=%u", session->imtu, session->omtu); From patchwork Mon Nov 15 09:41:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "K, Kiran" X-Patchwork-Id: 12619169 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27578C4332F for ; Mon, 15 Nov 2021 09:35:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ED39C61A89 for ; Mon, 15 Nov 2021 09:35:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230316AbhKOJil (ORCPT ); Mon, 15 Nov 2021 04:38:41 -0500 Received: from mga11.intel.com ([192.55.52.93]:13725 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230414AbhKOJif (ORCPT ); Mon, 15 Nov 2021 04:38:35 -0500 X-IronPort-AV: E=McAfee;i="6200,9189,10168"; a="230870751" X-IronPort-AV: E=Sophos;i="5.87,236,1631602800"; d="scan'208";a="230870751" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2021 01:35:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,236,1631602800"; d="scan'208";a="734781808" Received: from intel-lenovo-legion-y540-15irh-pg0.iind.intel.com ([10.224.186.95]) by fmsmga006.fm.intel.com with ESMTP; 15 Nov 2021 01:35:39 -0800 From: Kiran K To: linux-bluetooth@vger.kernel.org Cc: ravishankar.srivatsa@intel.com, chethan.tumkur.narayan@intel.com, luiz.von.dentz@intel.com, Kiran K Subject: [PATCH v1 3/5] avdtp: Add support for offload msft start command Date: Mon, 15 Nov 2021 15:11:06 +0530 Message-Id: <20211115094108.24331-3-kiran.k@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211115094108.24331-1-kiran.k@intel.com> References: <20211115094108.24331-1-kiran.k@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Send MSFT avdtp start command to trigger a2dp offload streaming after sending remote AVDTP start command. --- lib/bluetooth.h | 1 + profiles/audio/avdtp.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/lib/bluetooth.h b/lib/bluetooth.h index 59ef178a563a..32a3b5f0c2b9 100644 --- a/lib/bluetooth.h +++ b/lib/bluetooth.h @@ -159,6 +159,7 @@ struct bt_codecs { } __attribute__((packed)); #define BT_MSFT_OPEN 20 +#define BT_MSFT_START 21 #define BT_MSFT_CLOSE 23 /* Connection and socket states */ diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c index 1cd4b4472b08..1ae96e3e8a07 100644 --- a/profiles/audio/avdtp.c +++ b/profiles/audio/avdtp.c @@ -2910,6 +2910,21 @@ static gboolean avdtp_open_resp(struct avdtp *session, struct avdtp_stream *stre return TRUE; } +static gboolean avdtp_offload_start(struct avdtp_stream *stream) +{ + int sock; + + if (!stream->io) + return FALSE; + + sock = g_io_channel_unix_get_fd(stream->io); + + if (setsockopt(sock, SOL_BLUETOOTH, BT_MSFT_START, 0, 0)) + return FALSE; + + return TRUE; +} + static gboolean avdtp_start_resp(struct avdtp *session, struct avdtp_stream *stream, struct seid_rej *resp, int size) @@ -2924,6 +2939,9 @@ static gboolean avdtp_start_resp(struct avdtp *session, if (sep->state != AVDTP_STATE_STREAMING) avdtp_sep_set_state(session, sep, AVDTP_STATE_STREAMING); + if (session->use_offload) + avdtp_offload_start(stream); + return TRUE; } From patchwork Mon Nov 15 09:41:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "K, Kiran" X-Patchwork-Id: 12619171 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 778F6C433F5 for ; Mon, 15 Nov 2021 09:35:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B8C961BFE for ; Mon, 15 Nov 2021 09:35:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230494AbhKOJim (ORCPT ); Mon, 15 Nov 2021 04:38:42 -0500 Received: from mga11.intel.com ([192.55.52.93]:13725 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230258AbhKOJih (ORCPT ); Mon, 15 Nov 2021 04:38:37 -0500 X-IronPort-AV: E=McAfee;i="6200,9189,10168"; a="230870760" X-IronPort-AV: E=Sophos;i="5.87,236,1631602800"; d="scan'208";a="230870760" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2021 01:35:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,236,1631602800"; d="scan'208";a="734781814" Received: from intel-lenovo-legion-y540-15irh-pg0.iind.intel.com ([10.224.186.95]) by fmsmga006.fm.intel.com with ESMTP; 15 Nov 2021 01:35:41 -0800 From: Kiran K To: linux-bluetooth@vger.kernel.org Cc: ravishankar.srivatsa@intel.com, chethan.tumkur.narayan@intel.com, luiz.von.dentz@intel.com, Kiran K Subject: [PATCH v1 4/5] avdtp: Add support for offload msft suspend command Date: Mon, 15 Nov 2021 15:11:07 +0530 Message-Id: <20211115094108.24331-4-kiran.k@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211115094108.24331-1-kiran.k@intel.com> References: <20211115094108.24331-1-kiran.k@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org In a2dp offload use case, send MSFT avdtp suspend command followed by remote AVDTP suspend command. --- lib/bluetooth.h | 1 + profiles/audio/avdtp.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/lib/bluetooth.h b/lib/bluetooth.h index 32a3b5f0c2b9..2bd253aeeed4 100644 --- a/lib/bluetooth.h +++ b/lib/bluetooth.h @@ -160,6 +160,7 @@ struct bt_codecs { #define BT_MSFT_OPEN 20 #define BT_MSFT_START 21 +#define BT_MSFT_SUSPEND 22 #define BT_MSFT_CLOSE 23 /* Connection and socket states */ diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c index 1ae96e3e8a07..d5e8c7856be3 100644 --- a/profiles/audio/avdtp.c +++ b/profiles/audio/avdtp.c @@ -2958,6 +2958,21 @@ static gboolean avdtp_close_resp(struct avdtp *session, return TRUE; } +static gboolean avdtp_offload_suspend(struct avdtp_stream *stream) +{ + int sock; + + if (!stream->io) + return FALSE; + + sock = g_io_channel_unix_get_fd(stream->io); + + if (setsockopt(sock, SOL_BLUETOOTH, BT_MSFT_SUSPEND, 0, 0)) + return FALSE; + + return TRUE; +} + static gboolean avdtp_suspend_resp(struct avdtp *session, struct avdtp_stream *stream, void *data, int size) @@ -2969,6 +2984,9 @@ static gboolean avdtp_suspend_resp(struct avdtp *session, if (sep->cfm && sep->cfm->suspend) sep->cfm->suspend(session, sep, stream, NULL, sep->user_data); + if (session->use_offload) + avdtp_offload_suspend(stream); + return TRUE; } From patchwork Mon Nov 15 09:41:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "K, Kiran" X-Patchwork-Id: 12619173 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54CD4C433EF for ; Mon, 15 Nov 2021 09:35:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2E8DD61A89 for ; Mon, 15 Nov 2021 09:35:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236431AbhKOJio (ORCPT ); Mon, 15 Nov 2021 04:38:44 -0500 Received: from mga11.intel.com ([192.55.52.93]:13725 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230426AbhKOJij (ORCPT ); Mon, 15 Nov 2021 04:38:39 -0500 X-IronPort-AV: E=McAfee;i="6200,9189,10168"; a="230870763" X-IronPort-AV: E=Sophos;i="5.87,236,1631602800"; d="scan'208";a="230870763" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2021 01:35:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,236,1631602800"; d="scan'208";a="734781819" Received: from intel-lenovo-legion-y540-15irh-pg0.iind.intel.com ([10.224.186.95]) by fmsmga006.fm.intel.com with ESMTP; 15 Nov 2021 01:35:43 -0800 From: Kiran K To: linux-bluetooth@vger.kernel.org Cc: ravishankar.srivatsa@intel.com, chethan.tumkur.narayan@intel.com, luiz.von.dentz@intel.com, Kiran K Subject: [PATCH v1 5/5] avdtp: Add support for offload msft close command Date: Mon, 15 Nov 2021 15:11:08 +0530 Message-Id: <20211115094108.24331-5-kiran.k@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211115094108.24331-1-kiran.k@intel.com> References: <20211115094108.24331-1-kiran.k@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org In a2dp offload use case, send MSFT avdtp close command followed by remote AVDTP close command. --- profiles/audio/avdtp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c index d5e8c7856be3..3ee5f30967f0 100644 --- a/profiles/audio/avdtp.c +++ b/profiles/audio/avdtp.c @@ -2953,6 +2953,9 @@ static gboolean avdtp_close_resp(struct avdtp *session, avdtp_sep_set_state(session, sep, AVDTP_STATE_CLOSING); + if (session->use_offload) + avdtp_offload_close(stream); + close_stream(stream); return TRUE;