diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2005-08-09 23:30:28 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2005-08-29 18:55:13 -0400 |
commit | 0d48d93947dd9ea21c5cdc76a8581b06a4a39281 (patch) | |
tree | 96a1cbfe83a02e27fed3d30f1ac9f2fe05c17506 /net/bluetooth | |
parent | 2eb25a6c34504254760e67172f7518d6bfdd7676 (diff) |
[Bluetooth]: Move packet type into the SKB control buffer
This patch moves the usage of packet type into the SKB control
buffer. After this patch it is now possible to shrink the sk_buff
structure and redefine its pkt_type.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/bluetooth')
-rw-r--r-- | net/bluetooth/hci_core.c | 16 | ||||
-rw-r--r-- | net/bluetooth/hci_event.c | 2 | ||||
-rw-r--r-- | net/bluetooth/hci_sock.c | 18 |
3 files changed, 19 insertions, 17 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index ffa26c10bfe8..4f9e11b533a3 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c | |||
@@ -191,7 +191,7 @@ static void hci_init_req(struct hci_dev *hdev, unsigned long opt) | |||
191 | 191 | ||
192 | /* Special commands */ | 192 | /* Special commands */ |
193 | while ((skb = skb_dequeue(&hdev->driver_init))) { | 193 | while ((skb = skb_dequeue(&hdev->driver_init))) { |
194 | skb->pkt_type = HCI_COMMAND_PKT; | 194 | bt_cb(skb)->pkt_type = HCI_COMMAND_PKT; |
195 | skb->dev = (void *) hdev; | 195 | skb->dev = (void *) hdev; |
196 | skb_queue_tail(&hdev->cmd_q, skb); | 196 | skb_queue_tail(&hdev->cmd_q, skb); |
197 | hci_sched_cmd(hdev); | 197 | hci_sched_cmd(hdev); |
@@ -995,7 +995,7 @@ static int hci_send_frame(struct sk_buff *skb) | |||
995 | return -ENODEV; | 995 | return -ENODEV; |
996 | } | 996 | } |
997 | 997 | ||
998 | BT_DBG("%s type %d len %d", hdev->name, skb->pkt_type, skb->len); | 998 | BT_DBG("%s type %d len %d", hdev->name, bt_cb(skb)->pkt_type, skb->len); |
999 | 999 | ||
1000 | if (atomic_read(&hdev->promisc)) { | 1000 | if (atomic_read(&hdev->promisc)) { |
1001 | /* Time stamp */ | 1001 | /* Time stamp */ |
@@ -1034,7 +1034,7 @@ int hci_send_cmd(struct hci_dev *hdev, __u16 ogf, __u16 ocf, __u32 plen, void *p | |||
1034 | 1034 | ||
1035 | BT_DBG("skb len %d", skb->len); | 1035 | BT_DBG("skb len %d", skb->len); |
1036 | 1036 | ||
1037 | skb->pkt_type = HCI_COMMAND_PKT; | 1037 | bt_cb(skb)->pkt_type = HCI_COMMAND_PKT; |
1038 | skb->dev = (void *) hdev; | 1038 | skb->dev = (void *) hdev; |
1039 | skb_queue_tail(&hdev->cmd_q, skb); | 1039 | skb_queue_tail(&hdev->cmd_q, skb); |
1040 | hci_sched_cmd(hdev); | 1040 | hci_sched_cmd(hdev); |
@@ -1081,7 +1081,7 @@ int hci_send_acl(struct hci_conn *conn, struct sk_buff *skb, __u16 flags) | |||
1081 | BT_DBG("%s conn %p flags 0x%x", hdev->name, conn, flags); | 1081 | BT_DBG("%s conn %p flags 0x%x", hdev->name, conn, flags); |
1082 | 1082 | ||
1083 | skb->dev = (void *) hdev; | 1083 | skb->dev = (void *) hdev; |
1084 | skb->pkt_type = HCI_ACLDATA_PKT; | 1084 | bt_cb(skb)->pkt_type = HCI_ACLDATA_PKT; |
1085 | hci_add_acl_hdr(skb, conn->handle, flags | ACL_START); | 1085 | hci_add_acl_hdr(skb, conn->handle, flags | ACL_START); |
1086 | 1086 | ||
1087 | if (!(list = skb_shinfo(skb)->frag_list)) { | 1087 | if (!(list = skb_shinfo(skb)->frag_list)) { |
@@ -1103,7 +1103,7 @@ int hci_send_acl(struct hci_conn *conn, struct sk_buff *skb, __u16 flags) | |||
1103 | skb = list; list = list->next; | 1103 | skb = list; list = list->next; |
1104 | 1104 | ||
1105 | skb->dev = (void *) hdev; | 1105 | skb->dev = (void *) hdev; |
1106 | skb->pkt_type = HCI_ACLDATA_PKT; | 1106 | bt_cb(skb)->pkt_type = HCI_ACLDATA_PKT; |
1107 | hci_add_acl_hdr(skb, conn->handle, flags | ACL_CONT); | 1107 | hci_add_acl_hdr(skb, conn->handle, flags | ACL_CONT); |
1108 | 1108 | ||
1109 | BT_DBG("%s frag %p len %d", hdev->name, skb, skb->len); | 1109 | BT_DBG("%s frag %p len %d", hdev->name, skb, skb->len); |
@@ -1139,7 +1139,7 @@ int hci_send_sco(struct hci_conn *conn, struct sk_buff *skb) | |||
1139 | memcpy(skb->h.raw, &hdr, HCI_SCO_HDR_SIZE); | 1139 | memcpy(skb->h.raw, &hdr, HCI_SCO_HDR_SIZE); |
1140 | 1140 | ||
1141 | skb->dev = (void *) hdev; | 1141 | skb->dev = (void *) hdev; |
1142 | skb->pkt_type = HCI_SCODATA_PKT; | 1142 | bt_cb(skb)->pkt_type = HCI_SCODATA_PKT; |
1143 | skb_queue_tail(&conn->data_q, skb); | 1143 | skb_queue_tail(&conn->data_q, skb); |
1144 | hci_sched_tx(hdev); | 1144 | hci_sched_tx(hdev); |
1145 | return 0; | 1145 | return 0; |
@@ -1369,7 +1369,7 @@ void hci_rx_task(unsigned long arg) | |||
1369 | 1369 | ||
1370 | if (test_bit(HCI_INIT, &hdev->flags)) { | 1370 | if (test_bit(HCI_INIT, &hdev->flags)) { |
1371 | /* Don't process data packets in this states. */ | 1371 | /* Don't process data packets in this states. */ |
1372 | switch (skb->pkt_type) { | 1372 | switch (bt_cb(skb)->pkt_type) { |
1373 | case HCI_ACLDATA_PKT: | 1373 | case HCI_ACLDATA_PKT: |
1374 | case HCI_SCODATA_PKT: | 1374 | case HCI_SCODATA_PKT: |
1375 | kfree_skb(skb); | 1375 | kfree_skb(skb); |
@@ -1378,7 +1378,7 @@ void hci_rx_task(unsigned long arg) | |||
1378 | } | 1378 | } |
1379 | 1379 | ||
1380 | /* Process frame */ | 1380 | /* Process frame */ |
1381 | switch (skb->pkt_type) { | 1381 | switch (bt_cb(skb)->pkt_type) { |
1382 | case HCI_EVENT_PKT: | 1382 | case HCI_EVENT_PKT: |
1383 | hci_event_packet(hdev, skb); | 1383 | hci_event_packet(hdev, skb); |
1384 | break; | 1384 | break; |
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index a004284c4d98..40b219560bb1 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c | |||
@@ -1089,7 +1089,7 @@ void hci_si_event(struct hci_dev *hdev, int type, int dlen, void *data) | |||
1089 | bt_cb(skb)->incoming = 1; | 1089 | bt_cb(skb)->incoming = 1; |
1090 | do_gettimeofday(&skb->stamp); | 1090 | do_gettimeofday(&skb->stamp); |
1091 | 1091 | ||
1092 | skb->pkt_type = HCI_EVENT_PKT; | 1092 | bt_cb(skb)->pkt_type = HCI_EVENT_PKT; |
1093 | skb->dev = (void *) hdev; | 1093 | skb->dev = (void *) hdev; |
1094 | hci_send_to_sock(hdev, skb); | 1094 | hci_send_to_sock(hdev, skb); |
1095 | kfree_skb(skb); | 1095 | kfree_skb(skb); |
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c index ebdcce5e7ca0..eed9090d77f1 100644 --- a/net/bluetooth/hci_sock.c +++ b/net/bluetooth/hci_sock.c | |||
@@ -110,11 +110,11 @@ void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb) | |||
110 | /* Apply filter */ | 110 | /* Apply filter */ |
111 | flt = &hci_pi(sk)->filter; | 111 | flt = &hci_pi(sk)->filter; |
112 | 112 | ||
113 | if (!test_bit((skb->pkt_type == HCI_VENDOR_PKT) ? | 113 | if (!test_bit((bt_cb(skb)->pkt_type == HCI_VENDOR_PKT) ? |
114 | 0 : (skb->pkt_type & HCI_FLT_TYPE_BITS), &flt->type_mask)) | 114 | 0 : (bt_cb(skb)->pkt_type & HCI_FLT_TYPE_BITS), &flt->type_mask)) |
115 | continue; | 115 | continue; |
116 | 116 | ||
117 | if (skb->pkt_type == HCI_EVENT_PKT) { | 117 | if (bt_cb(skb)->pkt_type == HCI_EVENT_PKT) { |
118 | register int evt = (*(__u8 *)skb->data & HCI_FLT_EVENT_BITS); | 118 | register int evt = (*(__u8 *)skb->data & HCI_FLT_EVENT_BITS); |
119 | 119 | ||
120 | if (!hci_test_bit(evt, &flt->event_mask)) | 120 | if (!hci_test_bit(evt, &flt->event_mask)) |
@@ -131,7 +131,7 @@ void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb) | |||
131 | continue; | 131 | continue; |
132 | 132 | ||
133 | /* Put type byte before the data */ | 133 | /* Put type byte before the data */ |
134 | memcpy(skb_push(nskb, 1), &nskb->pkt_type, 1); | 134 | memcpy(skb_push(nskb, 1), &bt_cb(nskb)->pkt_type, 1); |
135 | 135 | ||
136 | if (sock_queue_rcv_skb(sk, nskb)) | 136 | if (sock_queue_rcv_skb(sk, nskb)) |
137 | kfree_skb(nskb); | 137 | kfree_skb(nskb); |
@@ -327,8 +327,10 @@ static inline void hci_sock_cmsg(struct sock *sk, struct msghdr *msg, struct sk_ | |||
327 | { | 327 | { |
328 | __u32 mask = hci_pi(sk)->cmsg_mask; | 328 | __u32 mask = hci_pi(sk)->cmsg_mask; |
329 | 329 | ||
330 | if (mask & HCI_CMSG_DIR) | 330 | if (mask & HCI_CMSG_DIR) { |
331 | put_cmsg(msg, SOL_HCI, HCI_CMSG_DIR, sizeof(int), &bt_cb(skb)->incoming); | 331 | int incoming = bt_cb(skb)->incoming; |
332 | put_cmsg(msg, SOL_HCI, HCI_CMSG_DIR, sizeof(incoming), &incoming); | ||
333 | } | ||
332 | 334 | ||
333 | if (mask & HCI_CMSG_TSTAMP) | 335 | if (mask & HCI_CMSG_TSTAMP) |
334 | put_cmsg(msg, SOL_HCI, HCI_CMSG_TSTAMP, sizeof(skb->stamp), &skb->stamp); | 336 | put_cmsg(msg, SOL_HCI, HCI_CMSG_TSTAMP, sizeof(skb->stamp), &skb->stamp); |
@@ -405,11 +407,11 @@ static int hci_sock_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
405 | goto drop; | 407 | goto drop; |
406 | } | 408 | } |
407 | 409 | ||
408 | skb->pkt_type = *((unsigned char *) skb->data); | 410 | bt_cb(skb)->pkt_type = *((unsigned char *) skb->data); |
409 | skb_pull(skb, 1); | 411 | skb_pull(skb, 1); |
410 | skb->dev = (void *) hdev; | 412 | skb->dev = (void *) hdev; |
411 | 413 | ||
412 | if (skb->pkt_type == HCI_COMMAND_PKT) { | 414 | if (bt_cb(skb)->pkt_type == HCI_COMMAND_PKT) { |
413 | u16 opcode = __le16_to_cpu(get_unaligned((u16 *)skb->data)); | 415 | u16 opcode = __le16_to_cpu(get_unaligned((u16 *)skb->data)); |
414 | u16 ogf = hci_opcode_ogf(opcode); | 416 | u16 ogf = hci_opcode_ogf(opcode); |
415 | u16 ocf = hci_opcode_ocf(opcode); | 417 | u16 ocf = hci_opcode_ocf(opcode); |