Commit 571277e3 authored by Maksim Krasnyanskiy's avatar Maksim Krasnyanskiy

Consistent naming for Bluetooth HCI events, commands and parameters.

Cleanup unused HCI stuff.
Optimize HCI receive path.
parent 26872595
This diff is collapsed.
......@@ -51,7 +51,7 @@ struct inquiry_cache {
struct inquiry_entry *list;
};
struct conn_hash {
struct hci_conn_hash {
struct list_head list;
spinlock_t lock;
unsigned int num;
......@@ -102,7 +102,7 @@ struct hci_dev {
__u32 req_result;
struct inquiry_cache inq_cache;
struct conn_hash conn_hash;
struct hci_conn_hash conn_hash;
struct hci_dev_stats stat;
......@@ -189,44 +189,34 @@ enum {
HCI_CONN_ENCRYPT_PEND
};
#define hci_conn_lock(c) spin_lock(&c->lock)
#define hci_conn_unlock(c) spin_unlock(&c->lock)
#define hci_conn_lock_bh(c) spin_lock_bh(&c->lock)
#define hci_conn_unlock_bh(c) spin_unlock_bh(&c->lock)
#define conn_hash_lock(d) spin_lock(&d->conn_hash->lock)
#define conn_hash_unlock(d) spin_unlock(&d->conn_hash->lock)
#define conn_hash_lock_bh(d) spin_lock_bh(&d->conn_hash->lock)
#define conn_hash_unlock_bh(d) spin_unlock_bh(&d->conn_hash->lock)
static inline void conn_hash_init(struct hci_dev *hdev)
static inline void hci_conn_hash_init(struct hci_dev *hdev)
{
struct conn_hash *h = &hdev->conn_hash;
struct hci_conn_hash *h = &hdev->conn_hash;
INIT_LIST_HEAD(&h->list);
spin_lock_init(&h->lock);
h->num = 0;
}
static inline void conn_hash_add(struct hci_dev *hdev, struct hci_conn *c)
static inline void hci_conn_hash_add(struct hci_dev *hdev, struct hci_conn *c)
{
struct conn_hash *h = &hdev->conn_hash;
struct hci_conn_hash *h = &hdev->conn_hash;
list_add(&c->list, &h->list);
h->num++;
}
static inline void conn_hash_del(struct hci_dev *hdev, struct hci_conn *c)
static inline void hci_conn_hash_del(struct hci_dev *hdev, struct hci_conn *c)
{
struct conn_hash *h = &hdev->conn_hash;
struct hci_conn_hash *h = &hdev->conn_hash;
list_del(&c->list);
h->num--;
}
static inline struct hci_conn *conn_hash_lookup_handle(struct hci_dev *hdev,
static inline struct hci_conn *hci_conn_hash_lookup_handle(struct hci_dev *hdev,
__u16 handle)
{
register struct conn_hash *h = &hdev->conn_hash;
register struct list_head *p;
register struct hci_conn *c;
struct hci_conn_hash *h = &hdev->conn_hash;
struct list_head *p;
struct hci_conn *c;
list_for_each(p, &h->list) {
c = list_entry(p, struct hci_conn, list);
......@@ -236,12 +226,12 @@ static inline struct hci_conn *conn_hash_lookup_handle(struct hci_dev *hdev,
return NULL;
}
static inline struct hci_conn *conn_hash_lookup_ba(struct hci_dev *hdev,
static inline struct hci_conn *hci_conn_hash_lookup_ba(struct hci_dev *hdev,
__u8 type, bdaddr_t *ba)
{
register struct conn_hash *h = &hdev->conn_hash;
register struct list_head *p;
register struct hci_conn *c;
struct hci_conn_hash *h = &hdev->conn_hash;
struct list_head *p;
struct hci_conn *c;
list_for_each(p, &h->list) {
c = list_entry(p, struct hci_conn, list);
......@@ -285,6 +275,22 @@ static inline void hci_conn_put(struct hci_conn *conn)
hci_conn_set_timer(conn, HCI_DISCONN_TIMEOUT);
}
/* ----- HCI tasks ----- */
static inline void hci_sched_cmd(struct hci_dev *hdev)
{
tasklet_schedule(&hdev->cmd_task);
}
static inline void hci_sched_rx(struct hci_dev *hdev)
{
tasklet_schedule(&hdev->rx_task);
}
static inline void hci_sched_tx(struct hci_dev *hdev)
{
tasklet_schedule(&hdev->tx_task);
}
/* ----- HCI Devices ----- */
static inline void hci_dev_put(struct hci_dev *d)
{
......@@ -315,29 +321,34 @@ int hci_get_conn_list(unsigned long arg);
int hci_get_conn_info(struct hci_dev *hdev, unsigned long arg);
int hci_inquiry(unsigned long arg);
int hci_recv_frame(struct sk_buff *skb);
void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb);
/* ----- LMP capabilities ----- */
#define lmp_rswitch_capable(dev) (dev->features[0] & LMP_RSWITCH)
#define lmp_encrypt_capable(dev) (dev->features[0] & LMP_ENCRYPT)
/* ----- HCI tasks ----- */
static inline void hci_sched_cmd(struct hci_dev *hdev)
/* Receive frame from HCI drivers */
static inline int hci_recv_frame(struct sk_buff *skb)
{
tasklet_schedule(&hdev->cmd_task);
}
struct hci_dev *hdev = (struct hci_dev *) skb->dev;
if (!hdev || (!test_bit(HCI_UP, &hdev->flags)
&& !test_bit(HCI_INIT, &hdev->flags))) {
kfree_skb(skb);
return -ENXIO;
}
static inline void hci_sched_rx(struct hci_dev *hdev)
{
tasklet_schedule(&hdev->rx_task);
}
/* Incomming skb */
bt_cb(skb)->incoming = 1;
static inline void hci_sched_tx(struct hci_dev *hdev)
{
tasklet_schedule(&hdev->tx_task);
/* Time stamp */
do_gettimeofday(&skb->stamp);
/* Queue frame for rx task */
skb_queue_tail(&hdev->rx_q, skb);
hci_sched_rx(hdev);
return 0;
}
/* ----- LMP capabilities ----- */
#define lmp_rswitch_capable(dev) (dev->features[0] & LMP_RSWITCH)
#define lmp_encrypt_capable(dev) (dev->features[0] & LMP_ENCRYPT)
/* ----- HCI protocols ----- */
struct hci_proto {
char *name;
......
......@@ -61,7 +61,7 @@ void hci_acl_connect(struct hci_conn *conn)
{
struct hci_dev *hdev = conn->hdev;
struct inquiry_entry *ie;
struct create_conn_cp cp;
struct hci_cp_create_conn cp;
BT_DBG("%p", conn);
......@@ -90,7 +90,7 @@ void hci_acl_connect(struct hci_conn *conn)
void hci_acl_disconn(struct hci_conn *conn, __u8 reason)
{
struct disconnect_cp cp;
struct hci_cp_disconnect cp;
BT_DBG("%p", conn);
......@@ -104,7 +104,7 @@ void hci_acl_disconn(struct hci_conn *conn, __u8 reason)
void hci_add_sco(struct hci_conn *conn, __u16 handle)
{
struct hci_dev *hdev = conn->hdev;
struct add_sco_cp cp;
struct hci_cp_add_sco cp;
BT_DBG("%p", conn);
......@@ -166,7 +166,7 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst)
hci_dev_hold(hdev);
tasklet_disable(&hdev->tx_task);
conn_hash_add(hdev, conn);
hci_conn_hash_add(hdev, conn);
tasklet_enable(&hdev->tx_task);
return conn;
......@@ -196,7 +196,7 @@ int hci_conn_del(struct hci_conn *conn)
}
tasklet_disable(&hdev->tx_task);
conn_hash_del(hdev, conn);
hci_conn_hash_del(hdev, conn);
tasklet_enable(&hdev->tx_task);
skb_queue_purge(&conn->data_q);
......@@ -255,7 +255,7 @@ struct hci_conn * hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst)
BT_DBG("%s dst %s", hdev->name, batostr(dst));
if (!(acl = conn_hash_lookup_ba(hdev, ACL_LINK, dst))) {
if (!(acl = hci_conn_hash_lookup_ba(hdev, ACL_LINK, dst))) {
if (!(acl = hci_conn_add(hdev, ACL_LINK, dst)))
return NULL;
}
......@@ -268,7 +268,7 @@ struct hci_conn * hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst)
if (type == SCO_LINK) {
struct hci_conn *sco;
if (!(sco = conn_hash_lookup_ba(hdev, SCO_LINK, dst))) {
if (!(sco = hci_conn_hash_lookup_ba(hdev, SCO_LINK, dst))) {
if (!(sco = hci_conn_add(hdev, SCO_LINK, dst))) {
hci_conn_put(acl);
return NULL;
......@@ -298,7 +298,7 @@ int hci_conn_auth(struct hci_conn *conn)
return 1;
if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->pend)) {
struct auth_requested_cp cp;
struct hci_cp_auth_requested cp;
cp.handle = __cpu_to_le16(conn->handle);
hci_send_cmd(conn->hdev, OGF_LINK_CTL, OCF_AUTH_REQUESTED, sizeof(cp), &cp);
}
......@@ -317,7 +317,7 @@ int hci_conn_encrypt(struct hci_conn *conn)
return 0;
if (hci_conn_auth(conn)) {
struct set_conn_encrypt_cp cp;
struct hci_cp_set_conn_encrypt cp;
cp.handle = __cpu_to_le16(conn->handle);
cp.encrypt = 1;
hci_send_cmd(conn->hdev, OGF_LINK_CTL, OCF_SET_CONN_ENCRYPT, sizeof(cp), &cp);
......@@ -328,7 +328,7 @@ int hci_conn_encrypt(struct hci_conn *conn)
/* Drop all connection on the device */
void hci_conn_hash_flush(struct hci_dev *hdev)
{
struct conn_hash *h = &hdev->conn_hash;
struct hci_conn_hash *h = &hdev->conn_hash;
struct list_head *p;
BT_DBG("hdev %s", hdev->name);
......@@ -411,7 +411,7 @@ int hci_get_conn_info(struct hci_dev *hdev, unsigned long arg)
return -EFAULT;
hci_dev_lock_bh(hdev);
conn = conn_hash_lookup_ba(hdev, req.type, &req.bdaddr);
conn = hci_conn_hash_lookup_ba(hdev, req.type, &req.bdaddr);
if (conn) {
bacpy(&ci.bdaddr, &conn->dst);
ci.handle = conn->handle;
......
......@@ -145,7 +145,8 @@ void hci_req_cancel(struct hci_dev *hdev, int err)
}
/* Execute request and wait for completion. */
static int __hci_request(struct hci_dev *hdev, void (*req)(struct hci_dev *hdev, unsigned long opt), unsigned long opt, __u32 timeout)
static int __hci_request(struct hci_dev *hdev, void (*req)(struct hci_dev *hdev, unsigned long opt),
unsigned long opt, __u32 timeout)
{
DECLARE_WAITQUEUE(wait, current);
int err = 0;
......@@ -188,7 +189,7 @@ static int __hci_request(struct hci_dev *hdev, void (*req)(struct hci_dev *hdev,
}
static inline int hci_request(struct hci_dev *hdev, void (*req)(struct hci_dev *hdev, unsigned long opt),
unsigned long opt, __u32 timeout)
unsigned long opt, __u32 timeout)
{
int ret;
......@@ -225,7 +226,7 @@ static void hci_init_req(struct hci_dev *hdev, unsigned long opt)
#if 0
/* Host buffer size */
{
struct host_buffer_size_cp cp;
struct hci_cp_host_buffer_size cp;
cp.acl_mtu = __cpu_to_le16(HCI_MAX_ACL_SIZE);
cp.sco_mtu = HCI_MAX_SCO_SIZE;
cp.acl_max_pkt = __cpu_to_le16(0xffff);
......@@ -241,8 +242,8 @@ static void hci_init_req(struct hci_dev *hdev, unsigned long opt)
/* Clear Event Filters */
{
struct set_event_flt_cp cp;
cp.flt_type = FLT_CLEAR_ALL;
struct hci_cp_set_event_flt cp;
cp.flt_type = HCI_FLT_CLEAR_ALL;
hci_send_cmd(hdev, OGF_HOST_CTL, OCF_SET_EVENT_FLT, sizeof(cp), &cp);
}
......@@ -377,7 +378,7 @@ int inquiry_cache_dump(struct hci_dev *hdev, int num, __u8 *buf)
static void hci_inq_req(struct hci_dev *hdev, unsigned long opt)
{
struct hci_inquiry_req *ir = (struct hci_inquiry_req *) opt;
struct inquiry_cp cp;
struct hci_cp_inquiry cp;
BT_DBG("%s", hdev->name);
......@@ -781,7 +782,6 @@ int hci_get_dev_info(unsigned long arg)
return err;
}
/* ---- Interface to HCI drivers ---- */
/* Register HCI device */
......@@ -828,7 +828,7 @@ int hci_register_dev(struct hci_dev *hdev)
inquiry_cache_init(hdev);
conn_hash_init(hdev);
hci_conn_hash_init(hdev);
memset(&hdev->stat, 0, sizeof(struct hci_dev_stats));
......@@ -880,31 +880,6 @@ int hci_resume_dev(struct hci_dev *hdev)
return 0;
}
/* Receive frame from HCI drivers */
int hci_recv_frame(struct sk_buff *skb)
{
struct hci_dev *hdev = (struct hci_dev *) skb->dev;
if (!hdev || (!test_bit(HCI_UP, &hdev->flags) &&
!test_bit(HCI_INIT, &hdev->flags)) ) {
kfree_skb(skb);
return -1;
}
BT_DBG("%s type %d len %d", hdev->name, skb->pkt_type, skb->len);
/* Incomming skb */
bt_cb(skb)->incoming = 1;
/* Time stamp */
do_gettimeofday(&skb->stamp);
/* Queue frame for rx task */
skb_queue_tail(&hdev->rx_q, skb);
hci_sched_rx(hdev);
return 0;
}
/* ---- Interface to upper protocols ---- */
/* Register/Unregister protocols.
......@@ -1025,7 +1000,7 @@ int hci_send_cmd(struct hci_dev *hdev, __u16 ogf, __u16 ocf, __u32 plen, void *p
}
hdr = (struct hci_command_hdr *) skb_put(skb, HCI_COMMAND_HDR_SIZE);
hdr->opcode = __cpu_to_le16(cmd_opcode_pack(ogf, ocf));
hdr->opcode = __cpu_to_le16(hci_opcode_pack(ogf, ocf));
hdr->plen = plen;
if (plen)
......@@ -1051,7 +1026,7 @@ void *hci_sent_cmd_data(struct hci_dev *hdev, __u16 ogf, __u16 ocf)
hdr = (void *) hdev->sent_cmd->data;
if (hdr->opcode != __cpu_to_le16(cmd_opcode_pack(ogf, ocf)))
if (hdr->opcode != __cpu_to_le16(hci_opcode_pack(ogf, ocf)))
return NULL;
BT_DBG("%s ogf 0x%x ocf 0x%x", hdev->name, ogf, ocf);
......@@ -1066,7 +1041,7 @@ static void hci_add_acl_hdr(struct sk_buff *skb, __u16 handle, __u16 flags)
int len = skb->len;
hdr = (struct hci_acl_hdr *) skb_push(skb, HCI_ACL_HDR_SIZE);
hdr->handle = __cpu_to_le16(acl_handle_pack(handle, flags));
hdr->handle = __cpu_to_le16(hci_handle_pack(handle, flags));
hdr->dlen = __cpu_to_le16(len);
skb->h.raw = (void *) hdr;
......@@ -1148,7 +1123,7 @@ int hci_send_sco(struct hci_conn *conn, struct sk_buff *skb)
/* HCI Connection scheduler */
static inline struct hci_conn *hci_low_sent(struct hci_dev *hdev, __u8 type, int *quote)
{
struct conn_hash *h = &hdev->conn_hash;
struct hci_conn_hash *h = &hdev->conn_hash;
struct hci_conn *conn = NULL;
int num = 0, min = ~0;
struct list_head *p;
......@@ -1183,7 +1158,7 @@ static inline struct hci_conn *hci_low_sent(struct hci_dev *hdev, __u8 type, int
static inline void hci_acl_tx_to(struct hci_dev *hdev)
{
struct conn_hash *h = &hdev->conn_hash;
struct hci_conn_hash *h = &hdev->conn_hash;
struct list_head *p;
struct hci_conn *c;
......@@ -1280,15 +1255,15 @@ static inline void hci_acldata_packet(struct hci_dev *hdev, struct sk_buff *skb)
skb_pull(skb, HCI_ACL_HDR_SIZE);
handle = __le16_to_cpu(hdr->handle);
flags = acl_flags(handle);
handle = acl_handle(handle);
flags = hci_flags(handle);
handle = hci_handle(handle);
BT_DBG("%s len %d handle 0x%x flags 0x%x", hdev->name, skb->len, handle, flags);
hdev->stat.acl_rx++;
hci_dev_lock(hdev);
conn = conn_hash_lookup_handle(hdev, handle);
conn = hci_conn_hash_lookup_handle(hdev, handle);
hci_dev_unlock(hdev);
if (conn) {
......@@ -1323,7 +1298,7 @@ static inline void hci_scodata_packet(struct hci_dev *hdev, struct sk_buff *skb)
hdev->stat.sco_rx++;
hci_dev_lock(hdev);
conn = conn_hash_lookup_handle(hdev, handle);
conn = hci_conn_hash_lookup_handle(hdev, handle);
hci_dev_unlock(hdev);
if (conn) {
......
This diff is collapsed.
......@@ -114,9 +114,9 @@ void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb)
if (!test_bit(evt, flt->event_mask))
continue;
if (flt->opcode && ((evt == EVT_CMD_COMPLETE &&
if (flt->opcode && ((evt == HCI_EV_CMD_COMPLETE &&
flt->opcode != *(__u16 *)(skb->data + 3)) ||
(evt == EVT_CMD_STATUS &&
(evt == HCI_EV_CMD_STATUS &&
flt->opcode != *(__u16 *)(skb->data + 4))))
continue;
}
......@@ -394,8 +394,8 @@ static int hci_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct msgh
if (skb->pkt_type == HCI_COMMAND_PKT) {
u16 opcode = __le16_to_cpu(*(__u16 *)skb->data);
u16 ogf = cmd_opcode_ogf(opcode) - 1;
u16 ocf = cmd_opcode_ocf(opcode) & HCI_FLT_OCF_BITS;
u16 ogf = hci_opcode_ogf(opcode) - 1;
u16 ocf = hci_opcode_ocf(opcode) & HCI_FLT_OCF_BITS;
if (ogf > HCI_SFLT_MAX_OGF ||
!test_bit(ocf, hci_sec_filter.ocf_mask[ogf]))
......@@ -584,14 +584,14 @@ static int hci_sock_create(struct socket *sock, int protocol)
static int hci_sock_dev_event(struct notifier_block *this, unsigned long event, void *ptr)
{
struct hci_dev *hdev = (struct hci_dev *) ptr;
struct evt_si_device ev;
struct hci_ev_si_device ev;
BT_DBG("hdev %s event %ld", hdev->name, event);
/* Send event to sockets */
ev.event = event;
ev.dev_id = hdev->id;
hci_si_event(NULL, EVT_SI_DEVICE, sizeof(ev), &ev);
hci_si_event(NULL, HCI_EV_SI_DEVICE, sizeof(ev), &ev);
if (event == HCI_DEV_UNREG) {
struct sock *sk;
......
......@@ -56,7 +56,6 @@ EXPORT_SYMBOL(hci_dev_get);
EXPORT_SYMBOL(hci_conn_auth);
EXPORT_SYMBOL(hci_conn_encrypt);
EXPORT_SYMBOL(hci_recv_frame);
EXPORT_SYMBOL(hci_send_acl);
EXPORT_SYMBOL(hci_send_sco);
EXPORT_SYMBOL(hci_send_raw);
......
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