Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 57666c13 authored by Anantha Krishnan's avatar Anantha Krishnan Committed by Rupesh Tatiya
Browse files

bluetooth: Configure DUT as MASTER for outgoing connection requests



Request MASTER ONLY role while establishing connection with remote
devices. Post ACL establishment, update link policy by disabling
role switch. This would prevent remote devices from requesting
for role switch post ACL creation and will allow the DUT to be
in MASTER role always. This is done to satisy BTC requirements
for achieving better WLAN throughput and performance.

Change-Id: If3187d0e8359d70ffb12e63e397b621a7c1a6031
Signed-off-by: default avatarAnantha Krishnan <ananthk@codeaurora.org>
Signed-off-by: default avatarRupesh Tatiya <rtatiya@codeaurora.org>
parent 53d2912c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -730,6 +730,7 @@ int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type,
		      bool initiator);
int hci_conn_change_link_key(struct hci_conn *conn);
int hci_conn_switch_role(struct hci_conn *conn, __u8 role);
int hci_cfg_link_policy(struct hci_conn *conn);

void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active);

+20 −0
Original line number Diff line number Diff line
@@ -98,6 +98,8 @@ static void hci_acl_create_connection(struct hci_conn *conn)
	}

	cp.pkt_type = cpu_to_le16(conn->pkt_type);
	/* Allow DUT to be MASTER for allow outgoing connection requests */
	hdev->link_mode |= HCI_LM_MASTER;
	if (lmp_rswitch_capable(hdev) && !(hdev->link_mode & HCI_LM_MASTER))
		cp.role_switch = 0x01;
	else
@@ -1113,6 +1115,24 @@ int hci_conn_switch_role(struct hci_conn *conn, __u8 role)
}
EXPORT_SYMBOL(hci_conn_switch_role);

/* Change ACL link policy */
int hci_cfg_link_policy(struct hci_conn *conn)
{
	struct hci_cp_write_link_policy lp;

	if (conn == NULL) {
		BT_ERR("%s: NO HCI Connection handle available!", __func__);
		return -ENODEV;
	}
	BT_INFO("%s: Disabling role switch on the ACL handle %d",
		__func__, conn->handle);
	lp.handle = conn->handle;
	lp.policy = HCI_LP_HOLD|HCI_LP_SNIFF|HCI_LP_PARK;
	hci_send_cmd(conn->hdev, HCI_OP_WRITE_LINK_POLICY, sizeof(lp), &lp);
	return 0;
}
EXPORT_SYMBOL(hci_cfg_link_policy);

/* Enter active mode */
void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active)
{
+2 −2
Original line number Diff line number Diff line
@@ -2867,7 +2867,7 @@ int hci_dev_cmd(unsigned int cmd, void __user *arg)

	case HCISETLINKMODE:
		hdev->link_mode = ((__u16) dr.dev_opt) &
					(HCI_LM_MASTER | HCI_LM_ACCEPT);
					(HCI_LM_MASTER);
		break;

	case HCISETPTYPE:
@@ -3986,7 +3986,7 @@ struct hci_dev *hci_alloc_dev(void)

	hdev->pkt_type  = (HCI_DM1 | HCI_DH1 | HCI_HV1);
	hdev->esco_type = (ESCO_HV1);
	hdev->link_mode = (HCI_LM_ACCEPT);
	hdev->link_mode = (HCI_LM_MASTER); /* Allow DUT to be in MASTER role */
	hdev->num_iac = 0x01;		/* One IAC support is mandatory */
	hdev->io_capability = 0x03;	/* No Input No Output */
	hdev->manufacturer = 0xffff;	/* Default to internal use */
+3 −0
Original line number Diff line number Diff line
@@ -2088,6 +2088,9 @@ static void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
			hci_send_cmd(hdev, HCI_OP_CHANGE_CONN_PTYPE, sizeof(cp),
				     &cp);
		}

		/* Change the ACL LINK POLICY to disable role switch */
		hci_cfg_link_policy(conn);
	} else {
		conn->state = BT_CLOSED;
		if (conn->type == ACL_LINK)