mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-25 00:50:54 +07:00
Bluetooth: Refactor HCI request variables into own struct
In order to shrink the size of bt_skb_cb, this patch moves the HCI request related variables into their own req_ctrl struct. Additionall the L2CAP and HCI request structs are placed inside the same union since they will never be used at the same time for the same skb. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
This commit is contained in:
parent
a4368ff3ed
commit
db6e3e8d01
@ -278,16 +278,22 @@ struct hci_dev;
|
|||||||
|
|
||||||
typedef void (*hci_req_complete_t)(struct hci_dev *hdev, u8 status, u16 opcode);
|
typedef void (*hci_req_complete_t)(struct hci_dev *hdev, u8 status, u16 opcode);
|
||||||
|
|
||||||
|
struct req_ctrl {
|
||||||
|
bool start;
|
||||||
|
u8 event;
|
||||||
|
hci_req_complete_t complete;
|
||||||
|
};
|
||||||
|
|
||||||
struct bt_skb_cb {
|
struct bt_skb_cb {
|
||||||
__u8 pkt_type;
|
__u8 pkt_type;
|
||||||
__u8 force_active;
|
__u8 force_active;
|
||||||
__u16 opcode;
|
__u16 opcode;
|
||||||
__u16 expect;
|
__u16 expect;
|
||||||
__u8 incoming:1;
|
__u8 incoming:1;
|
||||||
__u8 req_start:1;
|
union {
|
||||||
u8 req_event;
|
struct l2cap_ctrl l2cap;
|
||||||
hci_req_complete_t req_complete;
|
struct req_ctrl req;
|
||||||
struct l2cap_ctrl l2cap;
|
};
|
||||||
};
|
};
|
||||||
#define bt_cb(skb) ((struct bt_skb_cb *)((skb)->cb))
|
#define bt_cb(skb) ((struct bt_skb_cb *)((skb)->cb))
|
||||||
|
|
||||||
|
@ -3585,7 +3585,7 @@ int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen,
|
|||||||
/* Stand-alone HCI commands must be flagged as
|
/* Stand-alone HCI commands must be flagged as
|
||||||
* single-command requests.
|
* single-command requests.
|
||||||
*/
|
*/
|
||||||
bt_cb(skb)->req_start = 1;
|
bt_cb(skb)->req.start = true;
|
||||||
|
|
||||||
skb_queue_tail(&hdev->cmd_q, skb);
|
skb_queue_tail(&hdev->cmd_q, skb);
|
||||||
queue_work(hdev->workqueue, &hdev->cmd_work);
|
queue_work(hdev->workqueue, &hdev->cmd_work);
|
||||||
@ -4263,7 +4263,7 @@ static bool hci_req_is_complete(struct hci_dev *hdev)
|
|||||||
if (!skb)
|
if (!skb)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return bt_cb(skb)->req_start;
|
return bt_cb(skb)->req.start;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hci_resend_last(struct hci_dev *hdev)
|
static void hci_resend_last(struct hci_dev *hdev)
|
||||||
@ -4323,14 +4323,14 @@ void hci_req_cmd_complete(struct hci_dev *hdev, u16 opcode, u8 status)
|
|||||||
* command queue (hdev->cmd_q).
|
* command queue (hdev->cmd_q).
|
||||||
*/
|
*/
|
||||||
if (hdev->sent_cmd) {
|
if (hdev->sent_cmd) {
|
||||||
req_complete = bt_cb(hdev->sent_cmd)->req_complete;
|
req_complete = bt_cb(hdev->sent_cmd)->req.complete;
|
||||||
|
|
||||||
if (req_complete) {
|
if (req_complete) {
|
||||||
/* We must set the complete callback to NULL to
|
/* We must set the complete callback to NULL to
|
||||||
* avoid calling the callback more than once if
|
* avoid calling the callback more than once if
|
||||||
* this function gets called again.
|
* this function gets called again.
|
||||||
*/
|
*/
|
||||||
bt_cb(hdev->sent_cmd)->req_complete = NULL;
|
bt_cb(hdev->sent_cmd)->req.complete = NULL;
|
||||||
|
|
||||||
goto call_complete;
|
goto call_complete;
|
||||||
}
|
}
|
||||||
@ -4339,12 +4339,12 @@ void hci_req_cmd_complete(struct hci_dev *hdev, u16 opcode, u8 status)
|
|||||||
/* Remove all pending commands belonging to this request */
|
/* Remove all pending commands belonging to this request */
|
||||||
spin_lock_irqsave(&hdev->cmd_q.lock, flags);
|
spin_lock_irqsave(&hdev->cmd_q.lock, flags);
|
||||||
while ((skb = __skb_dequeue(&hdev->cmd_q))) {
|
while ((skb = __skb_dequeue(&hdev->cmd_q))) {
|
||||||
if (bt_cb(skb)->req_start) {
|
if (bt_cb(skb)->req.start) {
|
||||||
__skb_queue_head(&hdev->cmd_q, skb);
|
__skb_queue_head(&hdev->cmd_q, skb);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
req_complete = bt_cb(skb)->req_complete;
|
req_complete = bt_cb(skb)->req.complete;
|
||||||
kfree_skb(skb);
|
kfree_skb(skb);
|
||||||
}
|
}
|
||||||
spin_unlock_irqrestore(&hdev->cmd_q.lock, flags);
|
spin_unlock_irqrestore(&hdev->cmd_q.lock, flags);
|
||||||
|
@ -3125,7 +3125,7 @@ static void hci_cmd_status_evt(struct hci_dev *hdev, struct sk_buff *skb)
|
|||||||
atomic_set(&hdev->cmd_cnt, 1);
|
atomic_set(&hdev->cmd_cnt, 1);
|
||||||
|
|
||||||
if (ev->status ||
|
if (ev->status ||
|
||||||
(hdev->sent_cmd && !bt_cb(hdev->sent_cmd)->req_event))
|
(hdev->sent_cmd && !bt_cb(hdev->sent_cmd)->req.event))
|
||||||
hci_req_cmd_complete(hdev, opcode, ev->status);
|
hci_req_cmd_complete(hdev, opcode, ev->status);
|
||||||
|
|
||||||
if (atomic_read(&hdev->cmd_cnt) && !skb_queue_empty(&hdev->cmd_q))
|
if (atomic_read(&hdev->cmd_cnt) && !skb_queue_empty(&hdev->cmd_q))
|
||||||
@ -5049,7 +5049,7 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb)
|
|||||||
|
|
||||||
skb_pull(skb, HCI_EVENT_HDR_SIZE);
|
skb_pull(skb, HCI_EVENT_HDR_SIZE);
|
||||||
|
|
||||||
if (hdev->sent_cmd && bt_cb(hdev->sent_cmd)->req_event == event) {
|
if (hdev->sent_cmd && bt_cb(hdev->sent_cmd)->req.event == event) {
|
||||||
struct hci_command_hdr *cmd_hdr = (void *) hdev->sent_cmd->data;
|
struct hci_command_hdr *cmd_hdr = (void *) hdev->sent_cmd->data;
|
||||||
u16 opcode = __le16_to_cpu(cmd_hdr->opcode);
|
u16 opcode = __le16_to_cpu(cmd_hdr->opcode);
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ int hci_req_run(struct hci_request *req, hci_req_complete_t complete)
|
|||||||
return -ENODATA;
|
return -ENODATA;
|
||||||
|
|
||||||
skb = skb_peek_tail(&req->cmd_q);
|
skb = skb_peek_tail(&req->cmd_q);
|
||||||
bt_cb(skb)->req_complete = complete;
|
bt_cb(skb)->req.complete = complete;
|
||||||
|
|
||||||
spin_lock_irqsave(&hdev->cmd_q.lock, flags);
|
spin_lock_irqsave(&hdev->cmd_q.lock, flags);
|
||||||
skb_queue_splice_tail(&req->cmd_q, &hdev->cmd_q);
|
skb_queue_splice_tail(&req->cmd_q, &hdev->cmd_q);
|
||||||
@ -116,9 +116,9 @@ void hci_req_add_ev(struct hci_request *req, u16 opcode, u32 plen,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (skb_queue_empty(&req->cmd_q))
|
if (skb_queue_empty(&req->cmd_q))
|
||||||
bt_cb(skb)->req_start = 1;
|
bt_cb(skb)->req.start = true;
|
||||||
|
|
||||||
bt_cb(skb)->req_event = event;
|
bt_cb(skb)->req.event = event;
|
||||||
|
|
||||||
skb_queue_tail(&req->cmd_q, skb);
|
skb_queue_tail(&req->cmd_q, skb);
|
||||||
}
|
}
|
||||||
|
@ -1164,7 +1164,7 @@ static int hci_sock_sendmsg(struct socket *sock, struct msghdr *msg,
|
|||||||
/* Stand-alone HCI commands must be flagged as
|
/* Stand-alone HCI commands must be flagged as
|
||||||
* single-command requests.
|
* single-command requests.
|
||||||
*/
|
*/
|
||||||
bt_cb(skb)->req_start = 1;
|
bt_cb(skb)->req.start = true;
|
||||||
|
|
||||||
skb_queue_tail(&hdev->cmd_q, skb);
|
skb_queue_tail(&hdev->cmd_q, skb);
|
||||||
queue_work(hdev->workqueue, &hdev->cmd_work);
|
queue_work(hdev->workqueue, &hdev->cmd_work);
|
||||||
|
Loading…
Reference in New Issue
Block a user