diff options
author | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2011-11-01 04:58:57 -0400 |
---|---|---|
committer | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-11-07 14:24:47 -0500 |
commit | 5e59b791c3561e2fbb4aee17df3505ad25c16b7a (patch) | |
tree | 9c071f96562e42c91f572502c5302d06f1012cc8 | |
parent | 8035ded466049ca2fe8c04564a0fa00f222abe3f (diff) |
Bluetooth: set skbuffer priority based on L2CAP socket priority
This uses SO_PRIORITY to set the skbuffer priority field
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
-rw-r--r-- | include/net/bluetooth/hci_core.h | 3 | ||||
-rw-r--r-- | include/net/bluetooth/l2cap.h | 3 | ||||
-rw-r--r-- | net/bluetooth/l2cap_core.c | 27 | ||||
-rw-r--r-- | net/bluetooth/l2cap_sock.c | 2 |
4 files changed, 26 insertions, 9 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 967e18f72a38..9285a650949c 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h | |||
@@ -32,6 +32,9 @@ | |||
32 | #define HCI_PROTO_L2CAP 0 | 32 | #define HCI_PROTO_L2CAP 0 |
33 | #define HCI_PROTO_SCO 1 | 33 | #define HCI_PROTO_SCO 1 |
34 | 34 | ||
35 | /* HCI priority */ | ||
36 | #define HCI_PRIO_MAX 7 | ||
37 | |||
35 | /* HCI Core structures */ | 38 | /* HCI Core structures */ |
36 | struct inquiry_data { | 39 | struct inquiry_data { |
37 | bdaddr_t bdaddr; | 40 | bdaddr_t bdaddr; |
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 38a561581169..c10bf1db0abb 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h | |||
@@ -747,7 +747,8 @@ struct l2cap_chan *l2cap_chan_create(struct sock *sk); | |||
747 | void l2cap_chan_close(struct l2cap_chan *chan, int reason); | 747 | void l2cap_chan_close(struct l2cap_chan *chan, int reason); |
748 | void l2cap_chan_destroy(struct l2cap_chan *chan); | 748 | void l2cap_chan_destroy(struct l2cap_chan *chan); |
749 | int l2cap_chan_connect(struct l2cap_chan *chan); | 749 | int l2cap_chan_connect(struct l2cap_chan *chan); |
750 | int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len); | 750 | int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len, |
751 | u32 priority); | ||
751 | void l2cap_chan_busy(struct l2cap_chan *chan, int busy); | 752 | void l2cap_chan_busy(struct l2cap_chan *chan, int busy); |
752 | 753 | ||
753 | #endif /* __L2CAP_H */ | 754 | #endif /* __L2CAP_H */ |
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 76210cd6d3ea..ac2c41ada0fe 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c | |||
@@ -564,6 +564,7 @@ static void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, | |||
564 | flags = ACL_START; | 564 | flags = ACL_START; |
565 | 565 | ||
566 | bt_cb(skb)->force_active = BT_POWER_FORCE_ACTIVE_ON; | 566 | bt_cb(skb)->force_active = BT_POWER_FORCE_ACTIVE_ON; |
567 | skb->priority = HCI_PRIO_MAX; | ||
567 | 568 | ||
568 | hci_send_acl(conn->hcon, skb, flags); | 569 | hci_send_acl(conn->hcon, skb, flags); |
569 | } | 570 | } |
@@ -1265,7 +1266,8 @@ static void l2cap_do_send(struct l2cap_chan *chan, struct sk_buff *skb) | |||
1265 | struct hci_conn *hcon = chan->conn->hcon; | 1266 | struct hci_conn *hcon = chan->conn->hcon; |
1266 | u16 flags; | 1267 | u16 flags; |
1267 | 1268 | ||
1268 | BT_DBG("chan %p, skb %p len %d", chan, skb, skb->len); | 1269 | BT_DBG("chan %p, skb %p len %d priority %u", chan, skb, skb->len, |
1270 | skb->priority); | ||
1269 | 1271 | ||
1270 | if (!test_bit(FLAG_FLUSHABLE, &chan->flags) && | 1272 | if (!test_bit(FLAG_FLUSHABLE, &chan->flags) && |
1271 | lmp_no_flush_capable(hcon->hdev)) | 1273 | lmp_no_flush_capable(hcon->hdev)) |
@@ -1483,6 +1485,8 @@ static inline int l2cap_skbuff_fromiovec(struct sock *sk, struct msghdr *msg, in | |||
1483 | if (memcpy_fromiovec(skb_put(*frag, count), msg->msg_iov, count)) | 1485 | if (memcpy_fromiovec(skb_put(*frag, count), msg->msg_iov, count)) |
1484 | return -EFAULT; | 1486 | return -EFAULT; |
1485 | 1487 | ||
1488 | (*frag)->priority = skb->priority; | ||
1489 | |||
1486 | sent += count; | 1490 | sent += count; |
1487 | len -= count; | 1491 | len -= count; |
1488 | 1492 | ||
@@ -1492,7 +1496,9 @@ static inline int l2cap_skbuff_fromiovec(struct sock *sk, struct msghdr *msg, in | |||
1492 | return sent; | 1496 | return sent; |
1493 | } | 1497 | } |
1494 | 1498 | ||
1495 | static struct sk_buff *l2cap_create_connless_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len) | 1499 | static struct sk_buff *l2cap_create_connless_pdu(struct l2cap_chan *chan, |
1500 | struct msghdr *msg, size_t len, | ||
1501 | u32 priority) | ||
1496 | { | 1502 | { |
1497 | struct sock *sk = chan->sk; | 1503 | struct sock *sk = chan->sk; |
1498 | struct l2cap_conn *conn = chan->conn; | 1504 | struct l2cap_conn *conn = chan->conn; |
@@ -1500,7 +1506,7 @@ static struct sk_buff *l2cap_create_connless_pdu(struct l2cap_chan *chan, struct | |||
1500 | int err, count, hlen = L2CAP_HDR_SIZE + L2CAP_PSMLEN_SIZE; | 1506 | int err, count, hlen = L2CAP_HDR_SIZE + L2CAP_PSMLEN_SIZE; |
1501 | struct l2cap_hdr *lh; | 1507 | struct l2cap_hdr *lh; |
1502 | 1508 | ||
1503 | BT_DBG("sk %p len %d", sk, (int)len); | 1509 | BT_DBG("sk %p len %d priority %u", sk, (int)len, priority); |
1504 | 1510 | ||
1505 | count = min_t(unsigned int, (conn->mtu - hlen), len); | 1511 | count = min_t(unsigned int, (conn->mtu - hlen), len); |
1506 | skb = bt_skb_send_alloc(sk, count + hlen, | 1512 | skb = bt_skb_send_alloc(sk, count + hlen, |
@@ -1508,6 +1514,8 @@ static struct sk_buff *l2cap_create_connless_pdu(struct l2cap_chan *chan, struct | |||
1508 | if (!skb) | 1514 | if (!skb) |
1509 | return ERR_PTR(err); | 1515 | return ERR_PTR(err); |
1510 | 1516 | ||
1517 | skb->priority = priority; | ||
1518 | |||
1511 | /* Create L2CAP header */ | 1519 | /* Create L2CAP header */ |
1512 | lh = (struct l2cap_hdr *) skb_put(skb, L2CAP_HDR_SIZE); | 1520 | lh = (struct l2cap_hdr *) skb_put(skb, L2CAP_HDR_SIZE); |
1513 | lh->cid = cpu_to_le16(chan->dcid); | 1521 | lh->cid = cpu_to_le16(chan->dcid); |
@@ -1522,7 +1530,9 @@ static struct sk_buff *l2cap_create_connless_pdu(struct l2cap_chan *chan, struct | |||
1522 | return skb; | 1530 | return skb; |
1523 | } | 1531 | } |
1524 | 1532 | ||
1525 | static struct sk_buff *l2cap_create_basic_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len) | 1533 | static struct sk_buff *l2cap_create_basic_pdu(struct l2cap_chan *chan, |
1534 | struct msghdr *msg, size_t len, | ||
1535 | u32 priority) | ||
1526 | { | 1536 | { |
1527 | struct sock *sk = chan->sk; | 1537 | struct sock *sk = chan->sk; |
1528 | struct l2cap_conn *conn = chan->conn; | 1538 | struct l2cap_conn *conn = chan->conn; |
@@ -1538,6 +1548,8 @@ static struct sk_buff *l2cap_create_basic_pdu(struct l2cap_chan *chan, struct ms | |||
1538 | if (!skb) | 1548 | if (!skb) |
1539 | return ERR_PTR(err); | 1549 | return ERR_PTR(err); |
1540 | 1550 | ||
1551 | skb->priority = priority; | ||
1552 | |||
1541 | /* Create L2CAP header */ | 1553 | /* Create L2CAP header */ |
1542 | lh = (struct l2cap_hdr *) skb_put(skb, L2CAP_HDR_SIZE); | 1554 | lh = (struct l2cap_hdr *) skb_put(skb, L2CAP_HDR_SIZE); |
1543 | lh->cid = cpu_to_le16(chan->dcid); | 1555 | lh->cid = cpu_to_le16(chan->dcid); |
@@ -1651,7 +1663,8 @@ static int l2cap_sar_segment_sdu(struct l2cap_chan *chan, struct msghdr *msg, si | |||
1651 | return size; | 1663 | return size; |
1652 | } | 1664 | } |
1653 | 1665 | ||
1654 | int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len) | 1666 | int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len, |
1667 | u32 priority) | ||
1655 | { | 1668 | { |
1656 | struct sk_buff *skb; | 1669 | struct sk_buff *skb; |
1657 | u32 control; | 1670 | u32 control; |
@@ -1659,7 +1672,7 @@ int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len) | |||
1659 | 1672 | ||
1660 | /* Connectionless channel */ | 1673 | /* Connectionless channel */ |
1661 | if (chan->chan_type == L2CAP_CHAN_CONN_LESS) { | 1674 | if (chan->chan_type == L2CAP_CHAN_CONN_LESS) { |
1662 | skb = l2cap_create_connless_pdu(chan, msg, len); | 1675 | skb = l2cap_create_connless_pdu(chan, msg, len, priority); |
1663 | if (IS_ERR(skb)) | 1676 | if (IS_ERR(skb)) |
1664 | return PTR_ERR(skb); | 1677 | return PTR_ERR(skb); |
1665 | 1678 | ||
@@ -1674,7 +1687,7 @@ int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len) | |||
1674 | return -EMSGSIZE; | 1687 | return -EMSGSIZE; |
1675 | 1688 | ||
1676 | /* Create a basic PDU */ | 1689 | /* Create a basic PDU */ |
1677 | skb = l2cap_create_basic_pdu(chan, msg, len); | 1690 | skb = l2cap_create_basic_pdu(chan, msg, len, priority); |
1678 | if (IS_ERR(skb)) | 1691 | if (IS_ERR(skb)) |
1679 | return PTR_ERR(skb); | 1692 | return PTR_ERR(skb); |
1680 | 1693 | ||
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index 836d12e66a38..646aefc4f1d7 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c | |||
@@ -721,7 +721,7 @@ static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct ms | |||
721 | return -ENOTCONN; | 721 | return -ENOTCONN; |
722 | } | 722 | } |
723 | 723 | ||
724 | err = l2cap_chan_send(chan, msg, len); | 724 | err = l2cap_chan_send(chan, msg, len, sk->sk_priority); |
725 | 725 | ||
726 | release_sock(sk); | 726 | release_sock(sk); |
727 | return err; | 727 | return err; |