Commit 782de66e authored by Marcel Holtmann's avatar Marcel Holtmann

[Bluetooth] Improve connection hash handling

The connection hash counts the ACL and SCO links together at the moment
and this is not a useful behaviour. Separate the counters and put the
calling of the notifier before the TX tasklet is enabled.
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 3fdd2088
......@@ -53,7 +53,8 @@ struct inquiry_cache {
struct hci_conn_hash {
struct list_head list;
spinlock_t lock;
unsigned int num;
unsigned int acl_num;
unsigned int sco_num;
};
struct hci_dev {
......@@ -209,21 +210,28 @@ static inline void hci_conn_hash_init(struct hci_dev *hdev)
struct hci_conn_hash *h = &hdev->conn_hash;
INIT_LIST_HEAD(&h->list);
spin_lock_init(&h->lock);
h->num = 0;
h->acl_num = 0;
h->sco_num = 0;
}
static inline void hci_conn_hash_add(struct hci_dev *hdev, struct hci_conn *c)
{
struct hci_conn_hash *h = &hdev->conn_hash;
list_add(&c->list, &h->list);
h->num++;
if (c->type == ACL_LINK)
h->acl_num++;
else
h->sco_num++;
}
static inline void hci_conn_hash_del(struct hci_dev *hdev, struct hci_conn *c)
{
struct hci_conn_hash *h = &hdev->conn_hash;
list_del(&c->list);
h->num--;
if (c->type == ACL_LINK)
h->acl_num++;
else
h->sco_num--;
}
static inline struct hci_conn *hci_conn_hash_lookup_handle(struct hci_dev *hdev,
......
......@@ -163,12 +163,13 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst)
hci_dev_hold(hdev);
tasklet_disable(&hdev->tx_task);
hci_conn_hash_add(hdev, conn);
tasklet_enable(&hdev->tx_task);
hci_conn_hash_add(hdev, conn);
if (hdev->notify)
hdev->notify(hdev, HCI_NOTIFY_CONN_ADD);
tasklet_enable(&hdev->tx_task);
return conn;
}
......@@ -195,11 +196,12 @@ int hci_conn_del(struct hci_conn *conn)
hdev->acl_cnt += conn->sent;
}
tasklet_disable(&hdev->tx_task);
hci_conn_hash_del(hdev, conn);
if (hdev->notify)
hdev->notify(hdev, HCI_NOTIFY_CONN_DEL);
tasklet_disable(&hdev->tx_task);
hci_conn_hash_del(hdev, conn);
tasklet_enable(&hdev->tx_task);
skb_queue_purge(&conn->data_q);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment