From owner-svn-src-all@freebsd.org Tue Apr 28 16:00:35 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 801AB2BDCFA; Tue, 28 Apr 2020 16:00:35 +0000 (UTC) (envelope-from takawata@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49BRFH2xhcz3QG8; Tue, 28 Apr 2020 16:00:35 +0000 (UTC) (envelope-from takawata@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 602D526A4C; Tue, 28 Apr 2020 16:00:35 +0000 (UTC) (envelope-from takawata@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 03SG0ZJm007226; Tue, 28 Apr 2020 16:00:35 GMT (envelope-from takawata@FreeBSD.org) Received: (from takawata@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 03SG0YJQ007221; Tue, 28 Apr 2020 16:00:34 GMT (envelope-from takawata@FreeBSD.org) Message-Id: <202004281600.03SG0YJQ007221@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: takawata set sender to takawata@FreeBSD.org using -f From: Takanori Watanabe Date: Tue, 28 Apr 2020 16:00:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r360440 - in head: sys/netgraph/bluetooth/include usr.sbin/bluetooth/hccontrol X-SVN-Group: head X-SVN-Commit-Author: takawata X-SVN-Commit-Paths: in head: sys/netgraph/bluetooth/include usr.sbin/bluetooth/hccontrol X-SVN-Commit-Revision: 360440 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Apr 2020 16:00:35 -0000 Author: takawata Date: Tue Apr 28 16:00:34 2020 New Revision: 360440 URL: https://svnweb.freebsd.org/changeset/base/360440 Log: Add le_read_buffer_size command and manpage. It supports both v1 and v2 command. PR:245964 Submitted by: Marc Veldman Modified: head/sys/netgraph/bluetooth/include/ng_hci.h head/usr.sbin/bluetooth/hccontrol/hccontrol.8 head/usr.sbin/bluetooth/hccontrol/le.c Modified: head/sys/netgraph/bluetooth/include/ng_hci.h ============================================================================== --- head/sys/netgraph/bluetooth/include/ng_hci.h Tue Apr 28 15:44:39 2020 (r360439) +++ head/sys/netgraph/bluetooth/include/ng_hci.h Tue Apr 28 16:00:34 2020 (r360440) @@ -1672,6 +1672,15 @@ typedef struct { u_int16_t connection_handle; }__attribute__ ((packed)) ng_hci_le_long_term_key_request_negative_reply_rp; +#define NG_HCI_OCF_LE_READ_BUFFER_SIZE_V2 0x0060 +/*No command parameter */ +typedef struct { + u_int8_t status; + u_int16_t hc_le_data_packet_length; + u_int8_t hc_total_num_le_data_packets; + u_int16_t hc_iso_data_packet_length; + u_int8_t hc_total_num_iso_data_packets; +} __attribute__ ((packed)) ng_hci_le_read_buffer_size_rp_v2; #define NG_HCI_OCF_LE_READ_SUPPORTED_STATES 0x001c /*No command parameter*/ Modified: head/usr.sbin/bluetooth/hccontrol/hccontrol.8 ============================================================================== --- head/usr.sbin/bluetooth/hccontrol/hccontrol.8 Tue Apr 28 15:44:39 2020 (r360439) +++ head/usr.sbin/bluetooth/hccontrol/hccontrol.8 Tue Apr 28 16:00:34 2020 (r360440) @@ -25,7 +25,7 @@ .\" $Id: hccontrol.8,v 1.6 2003/08/06 21:26:38 max Exp $ .\" $FreeBSD$ .\" -.Dd April 24, 2020 +.Dd April 27, 2020 .Dt HCCONTROL 8 .Os .Sh NAME @@ -154,6 +154,7 @@ are: .It Cm LE_Set_Scan_Parameters .It Cm LE_Set_Scan_Enable .It Cm LE_Read_Supported_States +.It Cm LE_Read_Buffer_Size .El .Pp The currently supported node commands in Modified: head/usr.sbin/bluetooth/hccontrol/le.c ============================================================================== --- head/usr.sbin/bluetooth/hccontrol/le.c Tue Apr 28 15:44:39 2020 (r360439) +++ head/usr.sbin/bluetooth/hccontrol/le.c Tue Apr 28 16:00:34 2020 (r360440) @@ -554,7 +554,65 @@ le_set_advertising_data(int s, int argc, char *argv[]) return (OK); } +static int +le_read_buffer_size(int s, int argc, char *argv[]) +{ + union { + ng_hci_le_read_buffer_size_rp v1; + ng_hci_le_read_buffer_size_rp_v2 v2; + } rp; + int n, ch; + uint8_t v; + uint16_t cmd; + + optreset = 1; + optind = 0; + + /* Default to version 1*/ + v = 1; + cmd = NG_HCI_OCF_LE_READ_BUFFER_SIZE; + + while ((ch = getopt(argc, argv , "v:")) != -1) { + switch(ch) { + case 'v': + v = (uint8_t)strtol(optarg, NULL, 16); + if (v == 2) + cmd = NG_HCI_OCF_LE_READ_BUFFER_SIZE_V2; + else if (v > 2) + return (USAGE); + break; + default: + v = 1; + } + } + + n = sizeof(rp); + if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LE, cmd), + (void *)&rp, &n) == ERROR) + return (ERROR); + + if (rp.v1.status != 0x00) { + fprintf(stdout, "Status: %s [%#02x]\n", + hci_status2str(rp.v1.status), rp.v1.status); + return (FAILED); + } + + fprintf(stdout, "ACL data packet length: %d\n", + rp.v1.hc_le_data_packet_length); + fprintf(stdout, "Number of ACL data packets: %d\n", + rp.v1.hc_total_num_le_data_packets); + + if (v == 2) { + fprintf(stdout, "ISO data packet length: %d\n", + rp.v2.hc_iso_data_packet_length); + fprintf(stdout, "Number of ISO data packets: %d\n", + rp.v2.hc_total_num_iso_data_packets); + } + + return (OK); +} + struct hci_command le_commands[] = { { "le_enable", @@ -620,5 +678,11 @@ struct hci_command le_commands[] = { "le_set_advertising_data -n $name -f $flag -u $uuid16,$uuid16 \n" "set LE device advertising packed data", &le_set_advertising_data + }, + { + "le_read_buffer_size", + "le_read_buffer_size [-v 1|2]\n" + "Read the maximum size of ACL and ISO data packets", + &le_read_buffer_size }, };