Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Bluetooth: Fix using PHYs bitfields as PHY value

This renames the PHY fields in bt_iso_io_qos to PHYs (plural) since it
represents a bitfield where multiple PHYs can be set and make the same
change also to HCI_OP_LE_SET_CIG_PARAMS since both c_phy and p_phy
fields are bitfields.

This also fixes the assumption that hci_evt_le_cis_established PHYs
fields are compatible with bt_iso_io_qos, they are not, the fields in
hci_evt_le_cis_established represent just a single PHY value so they
need to be converted to bitfield when set in bt_iso_io_qos.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

+52 -36
+4 -4
include/net/bluetooth/bluetooth.h
··· 182 182 __u32 interval; 183 183 __u16 latency; 184 184 __u16 sdu; 185 - __u8 phy; 185 + __u8 phys; 186 186 __u8 rtn; 187 187 }; 188 188 ··· 221 221 }; 222 222 }; 223 223 224 - #define BT_ISO_PHY_1M 0x01 225 - #define BT_ISO_PHY_2M 0x02 226 - #define BT_ISO_PHY_CODED 0x04 224 + #define BT_ISO_PHY_1M BIT(0) 225 + #define BT_ISO_PHY_2M BIT(1) 226 + #define BT_ISO_PHY_CODED BIT(2) 227 227 #define BT_ISO_PHY_ANY (BT_ISO_PHY_1M | BT_ISO_PHY_2M | \ 228 228 BT_ISO_PHY_CODED) 229 229
+3 -3
include/net/bluetooth/hci.h
··· 1891 1891 __u8 all_phys; 1892 1892 __u8 tx_phys; 1893 1893 __u8 rx_phys; 1894 - __le16 phy_opts; 1894 + __le16 phy_opts; 1895 1895 } __packed; 1896 1896 1897 1897 #define HCI_OP_LE_SET_EXT_SCAN_PARAMS 0x2041 ··· 2147 2147 __u8 cis_id; 2148 2148 __le16 c_sdu; 2149 2149 __le16 p_sdu; 2150 - __u8 c_phy; 2151 - __u8 p_phy; 2150 + __u8 c_phys; 2151 + __u8 p_phys; 2152 2152 __u8 c_rtn; 2153 2153 __u8 p_rtn; 2154 2154 } __packed;
+18 -17
net/bluetooth/hci_conn.c
··· 1825 1825 cp.bis.sdu = cpu_to_le16(qos->bcast.out.sdu); 1826 1826 cp.bis.latency = cpu_to_le16(qos->bcast.out.latency); 1827 1827 cp.bis.rtn = qos->bcast.out.rtn; 1828 - cp.bis.phy = qos->bcast.out.phy; 1828 + cp.bis.phy = qos->bcast.out.phys; 1829 1829 cp.bis.packing = qos->bcast.packing; 1830 1830 cp.bis.framing = qos->bcast.framing; 1831 1831 cp.bis.encryption = qos->bcast.encryption; ··· 1875 1875 cis->cis_id = cis_id; 1876 1876 cis->c_sdu = cpu_to_le16(conn->iso_qos.ucast.out.sdu); 1877 1877 cis->p_sdu = cpu_to_le16(conn->iso_qos.ucast.in.sdu); 1878 - cis->c_phy = qos->ucast.out.phy ? qos->ucast.out.phy : 1879 - qos->ucast.in.phy; 1880 - cis->p_phy = qos->ucast.in.phy ? qos->ucast.in.phy : 1881 - qos->ucast.out.phy; 1878 + cis->c_phys = qos->ucast.out.phys ? qos->ucast.out.phys : 1879 + qos->ucast.in.phys; 1880 + cis->p_phys = qos->ucast.in.phys ? qos->ucast.in.phys : 1881 + qos->ucast.out.phys; 1882 1882 cis->c_rtn = qos->ucast.out.rtn; 1883 1883 cis->p_rtn = qos->ucast.in.rtn; 1884 1884 } ··· 1980 1980 return cis; 1981 1981 1982 1982 /* Update LINK PHYs according to QoS preference */ 1983 - cis->le_tx_phy = qos->ucast.out.phy; 1984 - cis->le_rx_phy = qos->ucast.in.phy; 1983 + cis->le_tx_phy = qos->ucast.out.phys; 1984 + cis->le_rx_phy = qos->ucast.in.phys; 1985 1985 1986 1986 /* If output interval is not set use the input interval as it cannot be 1987 1987 * 0x000000. ··· 2096 2096 } 2097 2097 2098 2098 static void hci_iso_qos_setup(struct hci_dev *hdev, struct hci_conn *conn, 2099 - struct bt_iso_io_qos *qos, __u8 phy) 2099 + struct bt_iso_io_qos *qos, __u8 phys) 2100 2100 { 2101 2101 /* Only set MTU if PHY is enabled */ 2102 - if (!qos->sdu && qos->phy) 2102 + if (!qos->sdu && qos->phys) 2103 2103 qos->sdu = conn->mtu; 2104 2104 2105 2105 /* Use the same PHY as ACL if set to any */ 2106 - if (qos->phy == BT_ISO_PHY_ANY) 2107 - qos->phy = phy; 2106 + if (qos->phys == BT_ISO_PHY_ANY) 2107 + qos->phys = phys; 2108 2108 2109 2109 /* Use LE ACL connection interval if not set */ 2110 2110 if (!qos->interval) ··· 2124 2124 u32 flags = 0; 2125 2125 int err; 2126 2126 2127 - if (qos->bcast.out.phy == 0x02) 2127 + if (qos->bcast.out.phys == BIT(1)) 2128 2128 flags |= MGMT_ADV_FLAG_SEC_2M; 2129 2129 2130 2130 /* Align intervals */ ··· 2233 2233 return conn; 2234 2234 2235 2235 /* Update LINK PHYs according to QoS preference */ 2236 - conn->le_tx_phy = qos->bcast.out.phy; 2237 - conn->le_tx_phy = qos->bcast.out.phy; 2236 + conn->le_tx_def_phys = qos->bcast.out.phys; 2238 2237 2239 2238 /* Add Basic Announcement into Peridic Adv Data if BASE is set */ 2240 2239 if (base_len && base) { ··· 2242 2243 } 2243 2244 2244 2245 hci_iso_qos_setup(hdev, conn, &qos->bcast.out, 2245 - conn->le_tx_phy ? conn->le_tx_phy : 2246 + conn->le_tx_def_phys ? conn->le_tx_def_phys : 2246 2247 hdev->le_tx_def_phys); 2247 2248 2248 2249 conn->iso_qos = *qos; ··· 2362 2363 return le; 2363 2364 2364 2365 hci_iso_qos_setup(hdev, le, &qos->ucast.out, 2365 - le->le_tx_phy ? le->le_tx_phy : hdev->le_tx_def_phys); 2366 + le->le_tx_def_phys ? le->le_tx_def_phys : 2367 + hdev->le_tx_def_phys); 2366 2368 hci_iso_qos_setup(hdev, le, &qos->ucast.in, 2367 - le->le_rx_phy ? le->le_rx_phy : hdev->le_rx_def_phys); 2369 + le->le_rx_def_phys ? le->le_rx_def_phys : 2370 + hdev->le_rx_def_phys); 2368 2371 2369 2372 cis = hci_bind_cis(hdev, dst, dst_type, qos, timeout); 2370 2373 if (IS_ERR(cis)) {
+19 -4
net/bluetooth/hci_event.c
··· 6867 6867 hci_dev_unlock(hdev); 6868 6868 } 6869 6869 6870 + /* Convert LE PHY to QoS PHYs */ 6871 + static u8 le_phy_qos(u8 phy) 6872 + { 6873 + switch (phy) { 6874 + case 0x01: 6875 + return HCI_LE_SET_PHY_1M; 6876 + case 0x02: 6877 + return HCI_LE_SET_PHY_2M; 6878 + case 0x03: 6879 + return HCI_LE_SET_PHY_CODED; 6880 + } 6881 + 6882 + return 0; 6883 + } 6884 + 6870 6885 static void hci_le_cis_established_evt(struct hci_dev *hdev, void *data, 6871 6886 struct sk_buff *skb) 6872 6887 { ··· 6943 6928 1000); 6944 6929 qos->ucast.in.sdu = ev->c_bn ? le16_to_cpu(ev->c_mtu) : 0; 6945 6930 qos->ucast.out.sdu = ev->p_bn ? le16_to_cpu(ev->p_mtu) : 0; 6946 - qos->ucast.in.phy = ev->c_phy; 6947 - qos->ucast.out.phy = ev->p_phy; 6931 + qos->ucast.in.phys = le_phy_qos(ev->c_phy); 6932 + qos->ucast.out.phys = le_phy_qos(ev->p_phy); 6948 6933 break; 6949 6934 case HCI_ROLE_MASTER: 6950 6935 qos->ucast.in.interval = p_sdu_interval; ··· 6958 6943 1000); 6959 6944 qos->ucast.out.sdu = ev->c_bn ? le16_to_cpu(ev->c_mtu) : 0; 6960 6945 qos->ucast.in.sdu = ev->p_bn ? le16_to_cpu(ev->p_mtu) : 0; 6961 - qos->ucast.out.phy = ev->c_phy; 6962 - qos->ucast.in.phy = ev->p_phy; 6946 + qos->ucast.out.phys = le_phy_qos(ev->c_phy); 6947 + qos->ucast.in.phys = le_phy_qos(ev->p_phy); 6963 6948 break; 6964 6949 } 6965 6950
+3 -3
net/bluetooth/hci_sync.c
··· 2948 2948 if (conn) { 2949 2949 struct bt_iso_qos *qos = &conn->iso_qos; 2950 2950 2951 - if (qos->bcast.in.phy & BT_ISO_PHY_1M || 2952 - qos->bcast.in.phy & BT_ISO_PHY_2M) { 2951 + if (qos->bcast.in.phys & BT_ISO_PHY_1M || 2952 + qos->bcast.in.phys & BT_ISO_PHY_2M) { 2953 2953 cp->scanning_phys |= LE_SCAN_PHY_1M; 2954 2954 hci_le_scan_phy_params(phy, type, 2955 2955 interval, ··· 2958 2958 phy++; 2959 2959 } 2960 2960 2961 - if (qos->bcast.in.phy & BT_ISO_PHY_CODED) { 2961 + if (qos->bcast.in.phys & BT_ISO_PHY_CODED) { 2962 2962 cp->scanning_phys |= LE_SCAN_PHY_CODED; 2963 2963 hci_le_scan_phy_params(phy, type, 2964 2964 interval * 3,
+5 -5
net/bluetooth/iso.c
··· 361 361 } 362 362 363 363 /* Fail if out PHYs are marked as disabled */ 364 - if (!iso_pi(sk)->qos.bcast.out.phy) { 364 + if (!iso_pi(sk)->qos.bcast.out.phys) { 365 365 err = -EINVAL; 366 366 goto unlock; 367 367 } ··· 458 458 } 459 459 460 460 /* Fail if either PHYs are marked as disabled */ 461 - if (!iso_pi(sk)->qos.ucast.in.phy && !iso_pi(sk)->qos.ucast.out.phy) { 461 + if (!iso_pi(sk)->qos.ucast.in.phys && !iso_pi(sk)->qos.ucast.out.phys) { 462 462 err = -EINVAL; 463 463 goto unlock; 464 464 } ··· 894 894 .interval = 10000u, \ 895 895 .latency = 10u, \ 896 896 .sdu = 40u, \ 897 - .phy = BT_ISO_PHY_2M, \ 897 + .phys = BT_ISO_PHY_2M, \ 898 898 .rtn = 2u, \ 899 899 } 900 900 ··· 1661 1661 static bool check_io_qos(struct bt_iso_io_qos *qos) 1662 1662 { 1663 1663 /* If no PHY is enable SDU must be 0 */ 1664 - if (!qos->phy && qos->sdu) 1664 + if (!qos->phys && qos->sdu) 1665 1665 return false; 1666 1666 1667 1667 if (qos->interval && (qos->interval < 0xff || qos->interval > 0xfffff)) ··· 1670 1670 if (qos->latency && (qos->latency < 0x05 || qos->latency > 0xfa0)) 1671 1671 return false; 1672 1672 1673 - if (qos->phy > BT_ISO_PHY_ANY) 1673 + if (qos->phys > BT_ISO_PHY_ANY) 1674 1674 return false; 1675 1675 1676 1676 return true;