diff options
Diffstat (limited to 'net/bluetooth/rfcomm/core.c')
-rw-r--r-- | net/bluetooth/rfcomm/core.c | 65 |
1 files changed, 40 insertions, 25 deletions
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c index 4e32e18211f..8743f369ed3 100644 --- a/net/bluetooth/rfcomm/core.c +++ b/net/bluetooth/rfcomm/core.c | |||
@@ -65,7 +65,8 @@ static DEFINE_MUTEX(rfcomm_mutex); | |||
65 | 65 | ||
66 | static LIST_HEAD(session_list); | 66 | static LIST_HEAD(session_list); |
67 | 67 | ||
68 | static int rfcomm_send_frame(struct rfcomm_session *s, u8 *data, int len); | 68 | static int rfcomm_send_frame(struct rfcomm_session *s, u8 *data, int len, |
69 | u32 priority); | ||
69 | static int rfcomm_send_sabm(struct rfcomm_session *s, u8 dlci); | 70 | static int rfcomm_send_sabm(struct rfcomm_session *s, u8 dlci); |
70 | static int rfcomm_send_disc(struct rfcomm_session *s, u8 dlci); | 71 | static int rfcomm_send_disc(struct rfcomm_session *s, u8 dlci); |
71 | static int rfcomm_queue_disc(struct rfcomm_dlc *d); | 72 | static int rfcomm_queue_disc(struct rfcomm_dlc *d); |
@@ -377,13 +378,11 @@ static void rfcomm_dlc_unlink(struct rfcomm_dlc *d) | |||
377 | static struct rfcomm_dlc *rfcomm_dlc_get(struct rfcomm_session *s, u8 dlci) | 378 | static struct rfcomm_dlc *rfcomm_dlc_get(struct rfcomm_session *s, u8 dlci) |
378 | { | 379 | { |
379 | struct rfcomm_dlc *d; | 380 | struct rfcomm_dlc *d; |
380 | struct list_head *p; | ||
381 | 381 | ||
382 | list_for_each(p, &s->dlcs) { | 382 | list_for_each_entry(d, &s->dlcs, list) |
383 | d = list_entry(p, struct rfcomm_dlc, list); | ||
384 | if (d->dlci == dlci) | 383 | if (d->dlci == dlci) |
385 | return d; | 384 | return d; |
386 | } | 385 | |
387 | return NULL; | 386 | return NULL; |
388 | } | 387 | } |
389 | 388 | ||
@@ -749,19 +748,34 @@ void rfcomm_session_getaddr(struct rfcomm_session *s, bdaddr_t *src, bdaddr_t *d | |||
749 | } | 748 | } |
750 | 749 | ||
751 | /* ---- RFCOMM frame sending ---- */ | 750 | /* ---- RFCOMM frame sending ---- */ |
752 | static int rfcomm_send_frame(struct rfcomm_session *s, u8 *data, int len) | 751 | static int rfcomm_send_frame(struct rfcomm_session *s, u8 *data, int len, |
752 | u32 priority) | ||
753 | { | 753 | { |
754 | struct socket *sock = s->sock; | 754 | struct socket *sock = s->sock; |
755 | struct sock *sk = sock->sk; | ||
755 | struct kvec iv = { data, len }; | 756 | struct kvec iv = { data, len }; |
756 | struct msghdr msg; | 757 | struct msghdr msg; |
757 | 758 | ||
758 | BT_DBG("session %p len %d", s, len); | 759 | BT_DBG("session %p len %d priority %u", s, len, priority); |
760 | |||
761 | if (sk->sk_priority != priority) { | ||
762 | lock_sock(sk); | ||
763 | sk->sk_priority = priority; | ||
764 | release_sock(sk); | ||
765 | } | ||
759 | 766 | ||
760 | memset(&msg, 0, sizeof(msg)); | 767 | memset(&msg, 0, sizeof(msg)); |
761 | 768 | ||
762 | return kernel_sendmsg(sock, &msg, &iv, 1, len); | 769 | return kernel_sendmsg(sock, &msg, &iv, 1, len); |
763 | } | 770 | } |
764 | 771 | ||
772 | static int rfcomm_send_cmd(struct rfcomm_session *s, struct rfcomm_cmd *cmd) | ||
773 | { | ||
774 | BT_DBG("%p cmd %u", s, cmd->ctrl); | ||
775 | |||
776 | return rfcomm_send_frame(s, (void *) cmd, sizeof(*cmd), HCI_PRIO_MAX); | ||
777 | } | ||
778 | |||
765 | static int rfcomm_send_sabm(struct rfcomm_session *s, u8 dlci) | 779 | static int rfcomm_send_sabm(struct rfcomm_session *s, u8 dlci) |
766 | { | 780 | { |
767 | struct rfcomm_cmd cmd; | 781 | struct rfcomm_cmd cmd; |
@@ -773,7 +787,7 @@ static int rfcomm_send_sabm(struct rfcomm_session *s, u8 dlci) | |||
773 | cmd.len = __len8(0); | 787 | cmd.len = __len8(0); |
774 | cmd.fcs = __fcs2((u8 *) &cmd); | 788 | cmd.fcs = __fcs2((u8 *) &cmd); |
775 | 789 | ||
776 | return rfcomm_send_frame(s, (void *) &cmd, sizeof(cmd)); | 790 | return rfcomm_send_cmd(s, &cmd); |
777 | } | 791 | } |
778 | 792 | ||
779 | static int rfcomm_send_ua(struct rfcomm_session *s, u8 dlci) | 793 | static int rfcomm_send_ua(struct rfcomm_session *s, u8 dlci) |
@@ -787,7 +801,7 @@ static int rfcomm_send_ua(struct rfcomm_session *s, u8 dlci) | |||
787 | cmd.len = __len8(0); | 801 | cmd.len = __len8(0); |
788 | cmd.fcs = __fcs2((u8 *) &cmd); | 802 | cmd.fcs = __fcs2((u8 *) &cmd); |
789 | 803 | ||
790 | return rfcomm_send_frame(s, (void *) &cmd, sizeof(cmd)); | 804 | return rfcomm_send_cmd(s, &cmd); |
791 | } | 805 | } |
792 | 806 | ||
793 | static int rfcomm_send_disc(struct rfcomm_session *s, u8 dlci) | 807 | static int rfcomm_send_disc(struct rfcomm_session *s, u8 dlci) |
@@ -801,7 +815,7 @@ static int rfcomm_send_disc(struct rfcomm_session *s, u8 dlci) | |||
801 | cmd.len = __len8(0); | 815 | cmd.len = __len8(0); |
802 | cmd.fcs = __fcs2((u8 *) &cmd); | 816 | cmd.fcs = __fcs2((u8 *) &cmd); |
803 | 817 | ||
804 | return rfcomm_send_frame(s, (void *) &cmd, sizeof(cmd)); | 818 | return rfcomm_send_cmd(s, &cmd); |
805 | } | 819 | } |
806 | 820 | ||
807 | static int rfcomm_queue_disc(struct rfcomm_dlc *d) | 821 | static int rfcomm_queue_disc(struct rfcomm_dlc *d) |
@@ -815,6 +829,8 @@ static int rfcomm_queue_disc(struct rfcomm_dlc *d) | |||
815 | if (!skb) | 829 | if (!skb) |
816 | return -ENOMEM; | 830 | return -ENOMEM; |
817 | 831 | ||
832 | skb->priority = HCI_PRIO_MAX; | ||
833 | |||
818 | cmd = (void *) __skb_put(skb, sizeof(*cmd)); | 834 | cmd = (void *) __skb_put(skb, sizeof(*cmd)); |
819 | cmd->addr = d->addr; | 835 | cmd->addr = d->addr; |
820 | cmd->ctrl = __ctrl(RFCOMM_DISC, 1); | 836 | cmd->ctrl = __ctrl(RFCOMM_DISC, 1); |
@@ -837,7 +853,7 @@ static int rfcomm_send_dm(struct rfcomm_session *s, u8 dlci) | |||
837 | cmd.len = __len8(0); | 853 | cmd.len = __len8(0); |
838 | cmd.fcs = __fcs2((u8 *) &cmd); | 854 | cmd.fcs = __fcs2((u8 *) &cmd); |
839 | 855 | ||
840 | return rfcomm_send_frame(s, (void *) &cmd, sizeof(cmd)); | 856 | return rfcomm_send_cmd(s, &cmd); |
841 | } | 857 | } |
842 | 858 | ||
843 | static int rfcomm_send_nsc(struct rfcomm_session *s, int cr, u8 type) | 859 | static int rfcomm_send_nsc(struct rfcomm_session *s, int cr, u8 type) |
@@ -862,7 +878,7 @@ static int rfcomm_send_nsc(struct rfcomm_session *s, int cr, u8 type) | |||
862 | 878 | ||
863 | *ptr = __fcs(buf); ptr++; | 879 | *ptr = __fcs(buf); ptr++; |
864 | 880 | ||
865 | return rfcomm_send_frame(s, buf, ptr - buf); | 881 | return rfcomm_send_frame(s, buf, ptr - buf, HCI_PRIO_MAX); |
866 | } | 882 | } |
867 | 883 | ||
868 | static int rfcomm_send_pn(struct rfcomm_session *s, int cr, struct rfcomm_dlc *d) | 884 | static int rfcomm_send_pn(struct rfcomm_session *s, int cr, struct rfcomm_dlc *d) |
@@ -904,7 +920,7 @@ static int rfcomm_send_pn(struct rfcomm_session *s, int cr, struct rfcomm_dlc *d | |||
904 | 920 | ||
905 | *ptr = __fcs(buf); ptr++; | 921 | *ptr = __fcs(buf); ptr++; |
906 | 922 | ||
907 | return rfcomm_send_frame(s, buf, ptr - buf); | 923 | return rfcomm_send_frame(s, buf, ptr - buf, HCI_PRIO_MAX); |
908 | } | 924 | } |
909 | 925 | ||
910 | int rfcomm_send_rpn(struct rfcomm_session *s, int cr, u8 dlci, | 926 | int rfcomm_send_rpn(struct rfcomm_session *s, int cr, u8 dlci, |
@@ -942,7 +958,7 @@ int rfcomm_send_rpn(struct rfcomm_session *s, int cr, u8 dlci, | |||
942 | 958 | ||
943 | *ptr = __fcs(buf); ptr++; | 959 | *ptr = __fcs(buf); ptr++; |
944 | 960 | ||
945 | return rfcomm_send_frame(s, buf, ptr - buf); | 961 | return rfcomm_send_frame(s, buf, ptr - buf, HCI_PRIO_MAX); |
946 | } | 962 | } |
947 | 963 | ||
948 | static int rfcomm_send_rls(struct rfcomm_session *s, int cr, u8 dlci, u8 status) | 964 | static int rfcomm_send_rls(struct rfcomm_session *s, int cr, u8 dlci, u8 status) |
@@ -969,7 +985,7 @@ static int rfcomm_send_rls(struct rfcomm_session *s, int cr, u8 dlci, u8 status) | |||
969 | 985 | ||
970 | *ptr = __fcs(buf); ptr++; | 986 | *ptr = __fcs(buf); ptr++; |
971 | 987 | ||
972 | return rfcomm_send_frame(s, buf, ptr - buf); | 988 | return rfcomm_send_frame(s, buf, ptr - buf, HCI_PRIO_MAX); |
973 | } | 989 | } |
974 | 990 | ||
975 | static int rfcomm_send_msc(struct rfcomm_session *s, int cr, u8 dlci, u8 v24_sig) | 991 | static int rfcomm_send_msc(struct rfcomm_session *s, int cr, u8 dlci, u8 v24_sig) |
@@ -996,7 +1012,7 @@ static int rfcomm_send_msc(struct rfcomm_session *s, int cr, u8 dlci, u8 v24_sig | |||
996 | 1012 | ||
997 | *ptr = __fcs(buf); ptr++; | 1013 | *ptr = __fcs(buf); ptr++; |
998 | 1014 | ||
999 | return rfcomm_send_frame(s, buf, ptr - buf); | 1015 | return rfcomm_send_frame(s, buf, ptr - buf, HCI_PRIO_MAX); |
1000 | } | 1016 | } |
1001 | 1017 | ||
1002 | static int rfcomm_send_fcoff(struct rfcomm_session *s, int cr) | 1018 | static int rfcomm_send_fcoff(struct rfcomm_session *s, int cr) |
@@ -1018,7 +1034,7 @@ static int rfcomm_send_fcoff(struct rfcomm_session *s, int cr) | |||
1018 | 1034 | ||
1019 | *ptr = __fcs(buf); ptr++; | 1035 | *ptr = __fcs(buf); ptr++; |
1020 | 1036 | ||
1021 | return rfcomm_send_frame(s, buf, ptr - buf); | 1037 | return rfcomm_send_frame(s, buf, ptr - buf, HCI_PRIO_MAX); |
1022 | } | 1038 | } |
1023 | 1039 | ||
1024 | static int rfcomm_send_fcon(struct rfcomm_session *s, int cr) | 1040 | static int rfcomm_send_fcon(struct rfcomm_session *s, int cr) |
@@ -1040,7 +1056,7 @@ static int rfcomm_send_fcon(struct rfcomm_session *s, int cr) | |||
1040 | 1056 | ||
1041 | *ptr = __fcs(buf); ptr++; | 1057 | *ptr = __fcs(buf); ptr++; |
1042 | 1058 | ||
1043 | return rfcomm_send_frame(s, buf, ptr - buf); | 1059 | return rfcomm_send_frame(s, buf, ptr - buf, HCI_PRIO_MAX); |
1044 | } | 1060 | } |
1045 | 1061 | ||
1046 | static int rfcomm_send_test(struct rfcomm_session *s, int cr, u8 *pattern, int len) | 1062 | static int rfcomm_send_test(struct rfcomm_session *s, int cr, u8 *pattern, int len) |
@@ -1091,7 +1107,7 @@ static int rfcomm_send_credits(struct rfcomm_session *s, u8 addr, u8 credits) | |||
1091 | 1107 | ||
1092 | *ptr = __fcs(buf); ptr++; | 1108 | *ptr = __fcs(buf); ptr++; |
1093 | 1109 | ||
1094 | return rfcomm_send_frame(s, buf, ptr - buf); | 1110 | return rfcomm_send_frame(s, buf, ptr - buf, HCI_PRIO_MAX); |
1095 | } | 1111 | } |
1096 | 1112 | ||
1097 | static void rfcomm_make_uih(struct sk_buff *skb, u8 addr) | 1113 | static void rfcomm_make_uih(struct sk_buff *skb, u8 addr) |
@@ -1769,7 +1785,8 @@ static inline int rfcomm_process_tx(struct rfcomm_dlc *d) | |||
1769 | return skb_queue_len(&d->tx_queue); | 1785 | return skb_queue_len(&d->tx_queue); |
1770 | 1786 | ||
1771 | while (d->tx_credits && (skb = skb_dequeue(&d->tx_queue))) { | 1787 | while (d->tx_credits && (skb = skb_dequeue(&d->tx_queue))) { |
1772 | err = rfcomm_send_frame(d->session, skb->data, skb->len); | 1788 | err = rfcomm_send_frame(d->session, skb->data, skb->len, |
1789 | skb->priority); | ||
1773 | if (err < 0) { | 1790 | if (err < 0) { |
1774 | skb_queue_head(&d->tx_queue, skb); | 1791 | skb_queue_head(&d->tx_queue, skb); |
1775 | break; | 1792 | break; |
@@ -2120,15 +2137,13 @@ static struct hci_cb rfcomm_cb = { | |||
2120 | static int rfcomm_dlc_debugfs_show(struct seq_file *f, void *x) | 2137 | static int rfcomm_dlc_debugfs_show(struct seq_file *f, void *x) |
2121 | { | 2138 | { |
2122 | struct rfcomm_session *s; | 2139 | struct rfcomm_session *s; |
2123 | struct list_head *pp, *p; | ||
2124 | 2140 | ||
2125 | rfcomm_lock(); | 2141 | rfcomm_lock(); |
2126 | 2142 | ||
2127 | list_for_each(p, &session_list) { | 2143 | list_for_each_entry(s, &session_list, list) { |
2128 | s = list_entry(p, struct rfcomm_session, list); | 2144 | struct rfcomm_dlc *d; |
2129 | list_for_each(pp, &s->dlcs) { | 2145 | list_for_each_entry(d, &s->dlcs, list) { |
2130 | struct sock *sk = s->sock->sk; | 2146 | struct sock *sk = s->sock->sk; |
2131 | struct rfcomm_dlc *d = list_entry(pp, struct rfcomm_dlc, list); | ||
2132 | 2147 | ||
2133 | seq_printf(f, "%s %s %ld %d %d %d %d\n", | 2148 | seq_printf(f, "%s %s %ld %d %d %d %d\n", |
2134 | batostr(&bt_sk(sk)->src), | 2149 | batostr(&bt_sk(sk)->src), |