diff options
Diffstat (limited to 'net/dccp/ccids')
-rw-r--r-- | net/dccp/ccids/ccid3.c | 290 |
1 files changed, 176 insertions, 114 deletions
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c index 9866dc175258..225c53013172 100644 --- a/net/dccp/ccids/ccid3.c +++ b/net/dccp/ccids/ccid3.c | |||
@@ -142,14 +142,16 @@ static const char *ccid3_tx_state_name(enum ccid3_hc_tx_states state) | |||
142 | } | 142 | } |
143 | #endif | 143 | #endif |
144 | 144 | ||
145 | static inline void ccid3_hc_tx_set_state(struct sock *sk, enum ccid3_hc_tx_states state) | 145 | static inline void ccid3_hc_tx_set_state(struct sock *sk, |
146 | enum ccid3_hc_tx_states state) | ||
146 | { | 147 | { |
147 | struct dccp_sock *dp = dccp_sk(sk); | 148 | struct dccp_sock *dp = dccp_sk(sk); |
148 | struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; | 149 | struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; |
149 | enum ccid3_hc_tx_states oldstate = hctx->ccid3hctx_state; | 150 | enum ccid3_hc_tx_states oldstate = hctx->ccid3hctx_state; |
150 | 151 | ||
151 | ccid3_pr_debug("%s(%p) %-8.8s -> %s\n", | 152 | ccid3_pr_debug("%s(%p) %-8.8s -> %s\n", |
152 | dccp_role(sk), sk, ccid3_tx_state_name(oldstate), ccid3_tx_state_name(state)); | 153 | dccp_role(sk), sk, ccid3_tx_state_name(oldstate), |
154 | ccid3_tx_state_name(state)); | ||
153 | WARN_ON(state == oldstate); | 155 | WARN_ON(state == oldstate); |
154 | hctx->ccid3hctx_state = state; | 156 | hctx->ccid3hctx_state = state; |
155 | } | 157 | } |
@@ -785,7 +787,8 @@ static inline void ccid3_calc_new_t_ipi(struct ccid3_hc_tx_sock *hctx) | |||
785 | /* Calculate new delta by delta = min(t_ipi / 2, t_gran / 2) */ | 787 | /* Calculate new delta by delta = min(t_ipi / 2, t_gran / 2) */ |
786 | static inline void ccid3_calc_new_delta(struct ccid3_hc_tx_sock *hctx) | 788 | static inline void ccid3_calc_new_delta(struct ccid3_hc_tx_sock *hctx) |
787 | { | 789 | { |
788 | hctx->ccid3hctx_delta = min_t(u32, hctx->ccid3hctx_t_ipi / 2, TFRC_OPSYS_HALF_TIME_GRAN); | 790 | hctx->ccid3hctx_delta = min_t(u32, hctx->ccid3hctx_t_ipi / 2, |
791 | TFRC_OPSYS_HALF_TIME_GRAN); | ||
789 | 792 | ||
790 | } | 793 | } |
791 | 794 | ||
@@ -804,20 +807,25 @@ static void ccid3_hc_tx_update_x(struct sock *sk) | |||
804 | struct dccp_sock *dp = dccp_sk(sk); | 807 | struct dccp_sock *dp = dccp_sk(sk); |
805 | struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; | 808 | struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; |
806 | 809 | ||
807 | if (hctx->ccid3hctx_p >= TFRC_SMALLEST_P) { /* to avoid large error in calcX */ | 810 | /* To avoid large error in calcX */ |
811 | if (hctx->ccid3hctx_p >= TFRC_SMALLEST_P) { | ||
808 | hctx->ccid3hctx_x_calc = ccid3_calc_x(hctx->ccid3hctx_s, | 812 | hctx->ccid3hctx_x_calc = ccid3_calc_x(hctx->ccid3hctx_s, |
809 | hctx->ccid3hctx_rtt, | 813 | hctx->ccid3hctx_rtt, |
810 | hctx->ccid3hctx_p); | 814 | hctx->ccid3hctx_p); |
811 | hctx->ccid3hctx_x = max_t(u32, min_t(u32, hctx->ccid3hctx_x_calc, 2 * hctx->ccid3hctx_x_recv), | 815 | hctx->ccid3hctx_x = max_t(u32, min_t(u32, hctx->ccid3hctx_x_calc, |
812 | hctx->ccid3hctx_s / TFRC_MAX_BACK_OFF_TIME); | 816 | 2 * hctx->ccid3hctx_x_recv), |
817 | (hctx->ccid3hctx_s / | ||
818 | TFRC_MAX_BACK_OFF_TIME)); | ||
813 | } else if (now_delta(hctx->ccid3hctx_t_ld) >= hctx->ccid3hctx_rtt) { | 819 | } else if (now_delta(hctx->ccid3hctx_t_ld) >= hctx->ccid3hctx_rtt) { |
814 | u32 rtt = hctx->ccid3hctx_rtt; | 820 | u32 rtt = hctx->ccid3hctx_rtt; |
815 | if (rtt < 10) { | 821 | if (rtt < 10) { |
816 | rtt = 10; | 822 | rtt = 10; |
817 | } /* avoid divide by zero below */ | 823 | } /* avoid divide by zero below */ |
818 | 824 | ||
819 | hctx->ccid3hctx_x = max_t(u32, min_t(u32, 2 * hctx->ccid3hctx_x_recv, 2 * hctx->ccid3hctx_x), | 825 | hctx->ccid3hctx_x = max_t(u32, min_t(u32, 2 * hctx->ccid3hctx_x_recv, |
820 | (hctx->ccid3hctx_s * 100000) / (rtt / 10)); | 826 | 2 * hctx->ccid3hctx_x), |
827 | ((hctx->ccid3hctx_s * 100000) / | ||
828 | (rtt / 10))); | ||
821 | /* Using 100000 and 10 to avoid 32 bit overflow for jumbo frames */ | 829 | /* Using 100000 and 10 to avoid 32 bit overflow for jumbo frames */ |
822 | do_gettimeofday(&hctx->ccid3hctx_t_ld); | 830 | do_gettimeofday(&hctx->ccid3hctx_t_ld); |
823 | } | 831 | } |
@@ -840,7 +848,8 @@ static void ccid3_hc_tx_no_feedback_timer(unsigned long data) | |||
840 | if (sock_owned_by_user(sk)) { | 848 | if (sock_owned_by_user(sk)) { |
841 | /* Try again later. */ | 849 | /* Try again later. */ |
842 | /* XXX: set some sensible MIB */ | 850 | /* XXX: set some sensible MIB */ |
843 | sk_reset_timer(sk, &hctx->ccid3hctx_no_feedback_timer, jiffies + HZ / 5); | 851 | sk_reset_timer(sk, &hctx->ccid3hctx_no_feedback_timer, |
852 | jiffies + HZ / 5); | ||
844 | goto out; | 853 | goto out; |
845 | } | 854 | } |
846 | 855 | ||
@@ -858,27 +867,38 @@ static void ccid3_hc_tx_no_feedback_timer(unsigned long data) | |||
858 | case TFRC_SSTATE_NO_FBACK: | 867 | case TFRC_SSTATE_NO_FBACK: |
859 | /* Halve send rate */ | 868 | /* Halve send rate */ |
860 | hctx->ccid3hctx_x /= 2; | 869 | hctx->ccid3hctx_x /= 2; |
861 | if (hctx->ccid3hctx_x < (hctx->ccid3hctx_s / TFRC_MAX_BACK_OFF_TIME)) | 870 | if (hctx->ccid3hctx_x < |
862 | hctx->ccid3hctx_x = hctx->ccid3hctx_s / TFRC_MAX_BACK_OFF_TIME; | 871 | (hctx->ccid3hctx_s / TFRC_MAX_BACK_OFF_TIME)) |
872 | hctx->ccid3hctx_x = (hctx->ccid3hctx_s / | ||
873 | TFRC_MAX_BACK_OFF_TIME); | ||
863 | 874 | ||
864 | ccid3_pr_debug("%s, sk=%p, state=%s, updated tx rate to %d bytes/s\n", | 875 | ccid3_pr_debug("%s, sk=%p, state=%s, updated tx rate to %d " |
865 | dccp_role(sk), sk, ccid3_tx_state_name(hctx->ccid3hctx_state), | 876 | "bytes/s\n", |
877 | dccp_role(sk), sk, | ||
878 | ccid3_tx_state_name(hctx->ccid3hctx_state), | ||
866 | hctx->ccid3hctx_x); | 879 | hctx->ccid3hctx_x); |
867 | next_tmout = max_t(u32, 2 * (hctx->ccid3hctx_s * 100000) | 880 | next_tmout = max_t(u32, 2 * (hctx->ccid3hctx_s * 100000) / (hctx->ccid3hctx_x / 10), |
868 | / (hctx->ccid3hctx_x / 10), TFRC_INITIAL_TIMEOUT); | 881 | TFRC_INITIAL_TIMEOUT); |
869 | /* do above maths with 100000 and 10 to prevent overflow on 32 bit */ | 882 | /* do above maths with 100000 and 10 to prevent overflow on 32 bit */ |
870 | /* FIXME - not sure above calculation is correct. See section 5 of CCID3 11 | 883 | /* |
871 | * should adjust tx_t_ipi and double that to achieve it really */ | 884 | * FIXME - not sure above calculation is correct. See section |
885 | * 5 of CCID3 11 should adjust tx_t_ipi and double that to | ||
886 | * achieve it really | ||
887 | */ | ||
872 | break; | 888 | break; |
873 | case TFRC_SSTATE_FBACK: | 889 | case TFRC_SSTATE_FBACK: |
874 | /* Check if IDLE since last timeout and recv rate is less than 4 packets per RTT */ | 890 | /* |
891 | * Check if IDLE since last timeout and recv rate is less than | ||
892 | * 4 packets per RTT | ||
893 | */ | ||
875 | rtt = hctx->ccid3hctx_rtt; | 894 | rtt = hctx->ccid3hctx_rtt; |
876 | if (rtt < 10) | 895 | if (rtt < 10) |
877 | rtt = 10; | 896 | rtt = 10; |
878 | /* stop divide by zero below */ | 897 | /* stop divide by zero below */ |
879 | if (!hctx->ccid3hctx_idle || (hctx->ccid3hctx_x_recv >= | 898 | if (!hctx->ccid3hctx_idle || |
880 | 4 * (hctx->ccid3hctx_s * 100000) / (rtt / 10))) { | 899 | (hctx->ccid3hctx_x_recv >= 4 * (hctx->ccid3hctx_s * 100000) / (rtt / 10))) { |
881 | ccid3_pr_debug("%s, sk=%p, state=%s, not idle\n", dccp_role(sk), sk, | 900 | ccid3_pr_debug("%s, sk=%p, state=%s, not idle\n", |
901 | dccp_role(sk), sk, | ||
882 | ccid3_tx_state_name(hctx->ccid3hctx_state)); | 902 | ccid3_tx_state_name(hctx->ccid3hctx_state)); |
883 | /* Halve sending rate */ | 903 | /* Halve sending rate */ |
884 | 904 | ||
@@ -887,7 +907,8 @@ static void ccid3_hc_tx_no_feedback_timer(unsigned long data) | |||
887 | * Else | 907 | * Else |
888 | * X_recv = X_calc / 4; | 908 | * X_recv = X_calc / 4; |
889 | */ | 909 | */ |
890 | BUG_ON(hctx->ccid3hctx_p >= TFRC_SMALLEST_P && hctx->ccid3hctx_x_calc == 0); | 910 | BUG_ON(hctx->ccid3hctx_p >= TFRC_SMALLEST_P && |
911 | hctx->ccid3hctx_x_calc == 0); | ||
891 | 912 | ||
892 | /* check also if p is zero -> x_calc is infinity? */ | 913 | /* check also if p is zero -> x_calc is infinity? */ |
893 | if (hctx->ccid3hctx_p < TFRC_SMALLEST_P || | 914 | if (hctx->ccid3hctx_p < TFRC_SMALLEST_P || |
@@ -916,7 +937,7 @@ static void ccid3_hc_tx_no_feedback_timer(unsigned long data) | |||
916 | } | 937 | } |
917 | 938 | ||
918 | sk_reset_timer(sk, &hctx->ccid3hctx_no_feedback_timer, | 939 | sk_reset_timer(sk, &hctx->ccid3hctx_no_feedback_timer, |
919 | jiffies + max_t(u32, 1, usecs_to_jiffies(next_tmout))); | 940 | jiffies + max_t(u32, 1, usecs_to_jiffies(next_tmout))); |
920 | hctx->ccid3hctx_idle = 1; | 941 | hctx->ccid3hctx_idle = 1; |
921 | out: | 942 | out: |
922 | bh_unlock_sock(sk); | 943 | bh_unlock_sock(sk); |
@@ -933,24 +954,27 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, | |||
933 | long delay; | 954 | long delay; |
934 | int rc = -ENOTCONN; | 955 | int rc = -ENOTCONN; |
935 | 956 | ||
936 | // ccid3_pr_debug("%s, sk=%p, skb=%p, len=%d\n", dccp_role(sk), sk, skb, len); | 957 | /* Check if pure ACK or Terminating*/ |
958 | |||
937 | /* | 959 | /* |
938 | * check if pure ACK or Terminating */ | 960 | * XXX: We only call this function for DATA and DATAACK, on, these |
939 | /* XXX: We only call this function for DATA and DATAACK, on, these packets can have | 961 | * packets can have zero length, but why the comment about "pure ACK"? |
940 | * zero length, but why the comment about "pure ACK"? | ||
941 | */ | 962 | */ |
942 | if (hctx == NULL || len == 0 || hctx->ccid3hctx_state == TFRC_SSTATE_TERM) | 963 | if (hctx == NULL || len == 0 || |
964 | hctx->ccid3hctx_state == TFRC_SSTATE_TERM) | ||
943 | goto out; | 965 | goto out; |
944 | 966 | ||
945 | /* See if last packet allocated was not sent */ | 967 | /* See if last packet allocated was not sent */ |
946 | new_packet = dccp_tx_hist_head(&hctx->ccid3hctx_hist); | 968 | new_packet = dccp_tx_hist_head(&hctx->ccid3hctx_hist); |
947 | if (new_packet == NULL || new_packet->dccphtx_sent) { | 969 | if (new_packet == NULL || new_packet->dccphtx_sent) { |
948 | new_packet = dccp_tx_hist_entry_new(ccid3_tx_hist, SLAB_ATOMIC); | 970 | new_packet = dccp_tx_hist_entry_new(ccid3_tx_hist, |
971 | SLAB_ATOMIC); | ||
949 | 972 | ||
950 | rc = -ENOBUFS; | 973 | rc = -ENOBUFS; |
951 | if (new_packet == NULL) { | 974 | if (new_packet == NULL) { |
952 | ccid3_pr_debug("%s, sk=%p, not enough mem to add " | 975 | ccid3_pr_debug("%s, sk=%p, not enough mem to add " |
953 | "to history, send refused\n", dccp_role(sk), sk); | 976 | "to history, send refused\n", |
977 | dccp_role(sk), sk); | ||
954 | goto out; | 978 | goto out; |
955 | } | 979 | } |
956 | 980 | ||
@@ -961,12 +985,13 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, | |||
961 | 985 | ||
962 | switch (hctx->ccid3hctx_state) { | 986 | switch (hctx->ccid3hctx_state) { |
963 | case TFRC_SSTATE_NO_SENT: | 987 | case TFRC_SSTATE_NO_SENT: |
964 | ccid3_pr_debug("%s, sk=%p, first packet(%llu)\n", dccp_role(sk), sk, | 988 | ccid3_pr_debug("%s, sk=%p, first packet(%llu)\n", |
965 | dp->dccps_gss); | 989 | dccp_role(sk), sk, dp->dccps_gss); |
966 | 990 | ||
967 | hctx->ccid3hctx_no_feedback_timer.function = ccid3_hc_tx_no_feedback_timer; | 991 | hctx->ccid3hctx_no_feedback_timer.function = ccid3_hc_tx_no_feedback_timer; |
968 | hctx->ccid3hctx_no_feedback_timer.data = (unsigned long)sk; | 992 | hctx->ccid3hctx_no_feedback_timer.data = (unsigned long)sk; |
969 | sk_reset_timer(sk, &hctx->ccid3hctx_no_feedback_timer, jiffies + usecs_to_jiffies(TFRC_INITIAL_TIMEOUT)); | 993 | sk_reset_timer(sk, &hctx->ccid3hctx_no_feedback_timer, |
994 | jiffies + usecs_to_jiffies(TFRC_INITIAL_TIMEOUT)); | ||
970 | hctx->ccid3hctx_last_win_count = 0; | 995 | hctx->ccid3hctx_last_win_count = 0; |
971 | hctx->ccid3hctx_t_last_win_count = now; | 996 | hctx->ccid3hctx_t_last_win_count = now; |
972 | ccid3_hc_tx_set_state(sk, TFRC_SSTATE_NO_FBACK); | 997 | ccid3_hc_tx_set_state(sk, TFRC_SSTATE_NO_FBACK); |
@@ -981,7 +1006,7 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, | |||
981 | break; | 1006 | break; |
982 | case TFRC_SSTATE_NO_FBACK: | 1007 | case TFRC_SSTATE_NO_FBACK: |
983 | case TFRC_SSTATE_FBACK: | 1008 | case TFRC_SSTATE_FBACK: |
984 | delay = (now_delta(hctx->ccid3hctx_t_nom) - hctx->ccid3hctx_delta); | 1009 | delay = now_delta(hctx->ccid3hctx_t_nom) - hctx->ccid3hctx_delta; |
985 | ccid3_pr_debug("send_packet delay=%ld\n", delay); | 1010 | ccid3_pr_debug("send_packet delay=%ld\n", delay); |
986 | delay /= -1000; | 1011 | delay /= -1000; |
987 | /* divide by -1000 is to convert to ms and get sign right */ | 1012 | /* divide by -1000 is to convert to ms and get sign right */ |
@@ -1027,41 +1052,35 @@ static void ccid3_hc_tx_packet_sent(struct sock *sk, int more, int len) | |||
1027 | 1052 | ||
1028 | packet = dccp_tx_hist_head(&hctx->ccid3hctx_hist); | 1053 | packet = dccp_tx_hist_head(&hctx->ccid3hctx_hist); |
1029 | if (packet == NULL) { | 1054 | if (packet == NULL) { |
1030 | printk(KERN_CRIT "%s: packet doesn't exists in history!\n", __FUNCTION__); | 1055 | printk(KERN_CRIT "%s: packet doesn't exists in " |
1056 | "history!\n", __FUNCTION__); | ||
1031 | return; | 1057 | return; |
1032 | } | 1058 | } |
1033 | if (packet->dccphtx_sent) { | 1059 | if (packet->dccphtx_sent) { |
1034 | printk(KERN_CRIT "%s: no unsent packet in history!\n", __FUNCTION__); | 1060 | printk(KERN_CRIT "%s: no unsent packet in history!\n", |
1061 | __FUNCTION__); | ||
1035 | return; | 1062 | return; |
1036 | } | 1063 | } |
1037 | packet->dccphtx_tstamp = now; | 1064 | packet->dccphtx_tstamp = now; |
1038 | packet->dccphtx_seqno = dp->dccps_gss; | 1065 | packet->dccphtx_seqno = dp->dccps_gss; |
1039 | #if 0 | ||
1040 | ccid3_pr_debug("%s, sk=%p, seqno=%llu inserted!\n", | ||
1041 | dccp_role(sk), sk, packet->dccphtx_seqno); | ||
1042 | #endif | ||
1043 | /* | 1066 | /* |
1044 | * Check if win_count have changed */ | 1067 | * Check if win_count have changed |
1045 | /* COMPLIANCE_BEGIN | 1068 | * Algorithm in "8.1. Window Counter Valuer" in |
1046 | * Algorithm in "8.1. Window Counter Valuer" in draft-ietf-dccp-ccid3-11.txt | 1069 | * draft-ietf-dccp-ccid3-11.txt |
1047 | */ | 1070 | */ |
1048 | quarter_rtt = now_delta(hctx->ccid3hctx_t_last_win_count) / (hctx->ccid3hctx_rtt / 4); | 1071 | quarter_rtt = now_delta(hctx->ccid3hctx_t_last_win_count) / |
1072 | (hctx->ccid3hctx_rtt / 4); | ||
1049 | if (quarter_rtt > 0) { | 1073 | if (quarter_rtt > 0) { |
1050 | hctx->ccid3hctx_t_last_win_count = now; | 1074 | hctx->ccid3hctx_t_last_win_count = now; |
1051 | hctx->ccid3hctx_last_win_count = (hctx->ccid3hctx_last_win_count + | 1075 | hctx->ccid3hctx_last_win_count = (hctx->ccid3hctx_last_win_count + |
1052 | min_t(unsigned long, quarter_rtt, 5)) % 16; | 1076 | min_t(unsigned long, quarter_rtt, 5)) % 16; |
1053 | ccid3_pr_debug("%s, sk=%p, window changed from %u to %u!\n", | 1077 | ccid3_pr_debug("%s, sk=%p, window changed from " |
1078 | "%u to %u!\n", | ||
1054 | dccp_role(sk), sk, | 1079 | dccp_role(sk), sk, |
1055 | packet->dccphtx_ccval, | 1080 | packet->dccphtx_ccval, |
1056 | hctx->ccid3hctx_last_win_count); | 1081 | hctx->ccid3hctx_last_win_count); |
1057 | } | 1082 | } |
1058 | /* COMPLIANCE_END */ | 1083 | |
1059 | #if 0 | ||
1060 | ccid3_pr_debug("%s, sk=%p, packet sent (%llu,%u)\n", | ||
1061 | dccp_role(sk), sk, | ||
1062 | packet->dccphtx_seqno, | ||
1063 | packet->dccphtx_ccval); | ||
1064 | #endif | ||
1065 | hctx->ccid3hctx_idle = 0; | 1084 | hctx->ccid3hctx_idle = 0; |
1066 | packet->dccphtx_rtt = hctx->ccid3hctx_rtt; | 1085 | packet->dccphtx_rtt = hctx->ccid3hctx_rtt; |
1067 | packet->dccphtx_sent = 1; | 1086 | packet->dccphtx_sent = 1; |
@@ -1073,7 +1092,8 @@ static void ccid3_hc_tx_packet_sent(struct sock *sk, int more, int len) | |||
1073 | case TFRC_SSTATE_NO_SENT: | 1092 | case TFRC_SSTATE_NO_SENT: |
1074 | /* if first wasn't pure ack */ | 1093 | /* if first wasn't pure ack */ |
1075 | if (len != 0) | 1094 | if (len != 0) |
1076 | printk(KERN_CRIT "%s: %s, First packet sent is noted as a data packet\n", | 1095 | printk(KERN_CRIT "%s: %s, First packet sent is noted " |
1096 | "as a data packet\n", | ||
1077 | __FUNCTION__, dccp_role(sk)); | 1097 | __FUNCTION__, dccp_role(sk)); |
1078 | return; | 1098 | return; |
1079 | case TFRC_SSTATE_NO_FBACK: | 1099 | case TFRC_SSTATE_NO_FBACK: |
@@ -1105,16 +1125,13 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
1105 | u32 pinv; | 1125 | u32 pinv; |
1106 | u32 x_recv; | 1126 | u32 x_recv; |
1107 | u32 r_sample; | 1127 | u32 r_sample; |
1108 | #if 0 | 1128 | |
1109 | ccid3_pr_debug("%s, sk=%p(%s), skb=%p(%s)\n", | ||
1110 | dccp_role(sk), sk, dccp_state_name(sk->sk_state), | ||
1111 | skb, dccp_packet_name(DCCP_SKB_CB(skb)->dccpd_type)); | ||
1112 | #endif | ||
1113 | if (hctx == NULL) | 1129 | if (hctx == NULL) |
1114 | return; | 1130 | return; |
1115 | 1131 | ||
1116 | if (hctx->ccid3hctx_state == TFRC_SSTATE_TERM) { | 1132 | if (hctx->ccid3hctx_state == TFRC_SSTATE_TERM) { |
1117 | ccid3_pr_debug("%s, sk=%p, received a packet when terminating!\n", dccp_role(sk), sk); | 1133 | ccid3_pr_debug("%s, sk=%p, received a packet when " |
1134 | "terminating!\n", dccp_role(sk), sk); | ||
1118 | return; | 1135 | return; |
1119 | } | 1136 | } |
1120 | 1137 | ||
@@ -1141,8 +1158,10 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
1141 | packet = dccp_tx_hist_find_entry(&hctx->ccid3hctx_hist, | 1158 | packet = dccp_tx_hist_find_entry(&hctx->ccid3hctx_hist, |
1142 | DCCP_SKB_CB(skb)->dccpd_ack_seq); | 1159 | DCCP_SKB_CB(skb)->dccpd_ack_seq); |
1143 | if (packet == NULL) { | 1160 | if (packet == NULL) { |
1144 | ccid3_pr_debug("%s, sk=%p, seqno %llu(%s) does't exist in history!\n", | 1161 | ccid3_pr_debug("%s, sk=%p, seqno %llu(%s) does't " |
1145 | dccp_role(sk), sk, DCCP_SKB_CB(skb)->dccpd_ack_seq, | 1162 | "exist in history!\n", |
1163 | dccp_role(sk), sk, | ||
1164 | DCCP_SKB_CB(skb)->dccpd_ack_seq, | ||
1146 | dccp_packet_name(DCCP_SKB_CB(skb)->dccpd_type)); | 1165 | dccp_packet_name(DCCP_SKB_CB(skb)->dccpd_type)); |
1147 | return; | 1166 | return; |
1148 | } | 1167 | } |
@@ -1164,7 +1183,8 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
1164 | ccid3_hc_tx_set_state(sk, TFRC_SSTATE_FBACK); | 1183 | ccid3_hc_tx_set_state(sk, TFRC_SSTATE_FBACK); |
1165 | hctx->ccid3hctx_rtt = r_sample; | 1184 | hctx->ccid3hctx_rtt = r_sample; |
1166 | } else | 1185 | } else |
1167 | hctx->ccid3hctx_rtt = (hctx->ccid3hctx_rtt * 9) / 10 + r_sample / 10; | 1186 | hctx->ccid3hctx_rtt = (hctx->ccid3hctx_rtt * 9) / 10 + |
1187 | r_sample / 10; | ||
1168 | 1188 | ||
1169 | /* | 1189 | /* |
1170 | * XXX: this is to avoid a division by zero in ccid3_hc_tx_packet_sent | 1190 | * XXX: this is to avoid a division by zero in ccid3_hc_tx_packet_sent |
@@ -1173,17 +1193,16 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
1173 | if (hctx->ccid3hctx_rtt < 4) | 1193 | if (hctx->ccid3hctx_rtt < 4) |
1174 | hctx->ccid3hctx_rtt = 4; | 1194 | hctx->ccid3hctx_rtt = 4; |
1175 | 1195 | ||
1176 | ccid3_pr_debug("%s, sk=%p, New RTT estimate=%uus, r_sample=%us\n", | 1196 | ccid3_pr_debug("%s, sk=%p, New RTT estimate=%uus, " |
1177 | dccp_role(sk), sk, | 1197 | "r_sample=%us\n", dccp_role(sk), sk, |
1178 | hctx->ccid3hctx_rtt, | 1198 | hctx->ccid3hctx_rtt, r_sample); |
1179 | r_sample); | ||
1180 | 1199 | ||
1181 | /* Update timeout interval */ | 1200 | /* Update timeout interval */ |
1182 | hctx->ccid3hctx_t_rto = max_t(u32, 4 * hctx->ccid3hctx_rtt, | 1201 | hctx->ccid3hctx_t_rto = max_t(u32, 4 * hctx->ccid3hctx_rtt, |
1183 | USEC_PER_SEC); | 1202 | USEC_PER_SEC); |
1184 | 1203 | ||
1185 | /* Update receive rate */ | 1204 | /* Update receive rate */ |
1186 | hctx->ccid3hctx_x_recv = x_recv; /* x_recv in bytes per second */ | 1205 | hctx->ccid3hctx_x_recv = x_recv;/* X_recv in bytes per sec */ |
1187 | 1206 | ||
1188 | /* Update loss event rate */ | 1207 | /* Update loss event rate */ |
1189 | if (pinv == ~0 || pinv == 0) | 1208 | if (pinv == ~0 || pinv == 0) |
@@ -1193,7 +1212,8 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
1193 | 1212 | ||
1194 | if (hctx->ccid3hctx_p < TFRC_SMALLEST_P) { | 1213 | if (hctx->ccid3hctx_p < TFRC_SMALLEST_P) { |
1195 | hctx->ccid3hctx_p = TFRC_SMALLEST_P; | 1214 | hctx->ccid3hctx_p = TFRC_SMALLEST_P; |
1196 | ccid3_pr_debug("%s, sk=%p, Smallest p used!\n", dccp_role(sk), sk); | 1215 | ccid3_pr_debug("%s, sk=%p, Smallest p used!\n", |
1216 | dccp_role(sk), sk); | ||
1197 | } | 1217 | } |
1198 | } | 1218 | } |
1199 | 1219 | ||
@@ -1220,22 +1240,27 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
1220 | &hctx->ccid3hctx_hist, packet); | 1240 | &hctx->ccid3hctx_hist, packet); |
1221 | 1241 | ||
1222 | if (hctx->ccid3hctx_x < 10) { | 1242 | if (hctx->ccid3hctx_x < 10) { |
1223 | ccid3_pr_debug("ccid3_hc_tx_packet_recv hctx->ccid3hctx_x < 10\n"); | 1243 | ccid3_pr_debug("ccid3_hc_tx_packet_recv hctx_x < 10\n"); |
1224 | hctx->ccid3hctx_x = 10; | 1244 | hctx->ccid3hctx_x = 10; |
1225 | } | 1245 | } |
1226 | /* to prevent divide by zero below */ | 1246 | /* to prevent divide by zero below */ |
1227 | 1247 | ||
1228 | /* Schedule no feedback timer to expire in max(4 * R, 2 * s / X) */ | 1248 | /* |
1249 | * Schedule no feedback timer to expire in | ||
1250 | * max(4 * R, 2 * s / X) | ||
1251 | */ | ||
1229 | next_tmout = max(hctx->ccid3hctx_t_rto, | 1252 | next_tmout = max(hctx->ccid3hctx_t_rto, |
1230 | (2 * (hctx->ccid3hctx_s * 100000) / | 1253 | (2 * (hctx->ccid3hctx_s * 100000) / |
1231 | (hctx->ccid3hctx_x / 10))); | 1254 | (hctx->ccid3hctx_x / 10))); |
1232 | /* maths with 100000 and 10 is to prevent overflow with 32 bit */ | 1255 | /* maths with 100000 and 10 is to prevent overflow with 32 bit */ |
1233 | 1256 | ||
1234 | ccid3_pr_debug("%s, sk=%p, Scheduled no feedback timer to expire in %lu jiffies (%luus)\n", | 1257 | ccid3_pr_debug("%s, sk=%p, Scheduled no feedback timer to " |
1235 | dccp_role(sk), sk, usecs_to_jiffies(next_tmout), next_tmout); | 1258 | "expire in %lu jiffies (%luus)\n", |
1259 | dccp_role(sk), sk, | ||
1260 | usecs_to_jiffies(next_tmout), next_tmout); | ||
1236 | 1261 | ||
1237 | sk_reset_timer(sk, &hctx->ccid3hctx_no_feedback_timer, | 1262 | sk_reset_timer(sk, &hctx->ccid3hctx_no_feedback_timer, |
1238 | jiffies + max_t(u32,1,usecs_to_jiffies(next_tmout))); | 1263 | jiffies + max_t(u32, 1, usecs_to_jiffies(next_tmout))); |
1239 | 1264 | ||
1240 | /* set idle flag */ | 1265 | /* set idle flag */ |
1241 | hctx->ccid3hctx_idle = 1; | 1266 | hctx->ccid3hctx_idle = 1; |
@@ -1253,14 +1278,16 @@ static void ccid3_hc_tx_insert_options(struct sock *sk, struct sk_buff *skb) | |||
1253 | const struct dccp_sock *dp = dccp_sk(sk); | 1278 | const struct dccp_sock *dp = dccp_sk(sk); |
1254 | struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; | 1279 | struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; |
1255 | 1280 | ||
1256 | if (hctx == NULL || !(sk->sk_state == DCCP_OPEN || sk->sk_state == DCCP_PARTOPEN)) | 1281 | if (hctx == NULL || !(sk->sk_state == DCCP_OPEN || |
1282 | sk->sk_state == DCCP_PARTOPEN)) | ||
1257 | return; | 1283 | return; |
1258 | 1284 | ||
1259 | DCCP_SKB_CB(skb)->dccpd_ccval = hctx->ccid3hctx_last_win_count; | 1285 | DCCP_SKB_CB(skb)->dccpd_ccval = hctx->ccid3hctx_last_win_count; |
1260 | } | 1286 | } |
1261 | 1287 | ||
1262 | static int ccid3_hc_tx_parse_options(struct sock *sk, unsigned char option, | 1288 | static int ccid3_hc_tx_parse_options(struct sock *sk, unsigned char option, |
1263 | unsigned char len, u16 idx, unsigned char *value) | 1289 | unsigned char len, u16 idx, |
1290 | unsigned char *value) | ||
1264 | { | 1291 | { |
1265 | int rc = 0; | 1292 | int rc = 0; |
1266 | struct dccp_sock *dp = dccp_sk(sk); | 1293 | struct dccp_sock *dp = dccp_sk(sk); |
@@ -1283,7 +1310,8 @@ static int ccid3_hc_tx_parse_options(struct sock *sk, unsigned char option, | |||
1283 | switch (option) { | 1310 | switch (option) { |
1284 | case TFRC_OPT_LOSS_EVENT_RATE: | 1311 | case TFRC_OPT_LOSS_EVENT_RATE: |
1285 | if (len != 4) { | 1312 | if (len != 4) { |
1286 | ccid3_pr_debug("%s, sk=%p, invalid len for TFRC_OPT_LOSS_EVENT_RATE\n", | 1313 | ccid3_pr_debug("%s, sk=%p, invalid len for " |
1314 | "TFRC_OPT_LOSS_EVENT_RATE\n", | ||
1287 | dccp_role(sk), sk); | 1315 | dccp_role(sk), sk); |
1288 | rc = -EINVAL; | 1316 | rc = -EINVAL; |
1289 | } else { | 1317 | } else { |
@@ -1303,7 +1331,8 @@ static int ccid3_hc_tx_parse_options(struct sock *sk, unsigned char option, | |||
1303 | break; | 1331 | break; |
1304 | case TFRC_OPT_RECEIVE_RATE: | 1332 | case TFRC_OPT_RECEIVE_RATE: |
1305 | if (len != 4) { | 1333 | if (len != 4) { |
1306 | ccid3_pr_debug("%s, sk=%p, invalid len for TFRC_OPT_RECEIVE_RATE\n", | 1334 | ccid3_pr_debug("%s, sk=%p, invalid len for " |
1335 | "TFRC_OPT_RECEIVE_RATE\n", | ||
1307 | dccp_role(sk), sk); | 1336 | dccp_role(sk), sk); |
1308 | rc = -EINVAL; | 1337 | rc = -EINVAL; |
1309 | } else { | 1338 | } else { |
@@ -1325,7 +1354,8 @@ static int ccid3_hc_tx_init(struct sock *sk) | |||
1325 | 1354 | ||
1326 | ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); | 1355 | ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); |
1327 | 1356 | ||
1328 | hctx = dp->dccps_hc_tx_ccid_private = kmalloc(sizeof(*hctx), gfp_any()); | 1357 | hctx = dp->dccps_hc_tx_ccid_private = kmalloc(sizeof(*hctx), |
1358 | gfp_any()); | ||
1329 | if (hctx == NULL) | 1359 | if (hctx == NULL) |
1330 | return -ENOMEM; | 1360 | return -ENOMEM; |
1331 | 1361 | ||
@@ -1337,8 +1367,10 @@ static int ccid3_hc_tx_init(struct sock *sk) | |||
1337 | else | 1367 | else |
1338 | hctx->ccid3hctx_s = TFRC_STD_PACKET_SIZE; | 1368 | hctx->ccid3hctx_s = TFRC_STD_PACKET_SIZE; |
1339 | 1369 | ||
1340 | hctx->ccid3hctx_x = hctx->ccid3hctx_s; /* set transmission rate to 1 packet per second */ | 1370 | /* Set transmission rate to 1 packet per second */ |
1341 | hctx->ccid3hctx_rtt = 4; /* See ccid3_hc_tx_packet_sent win_count calculatation */ | 1371 | hctx->ccid3hctx_x = hctx->ccid3hctx_s; |
1372 | /* See ccid3_hc_tx_packet_sent win_count calculatation */ | ||
1373 | hctx->ccid3hctx_rtt = 4; | ||
1342 | hctx->ccid3hctx_t_rto = USEC_PER_SEC; | 1374 | hctx->ccid3hctx_t_rto = USEC_PER_SEC; |
1343 | hctx->ccid3hctx_state = TFRC_SSTATE_NO_SENT; | 1375 | hctx->ccid3hctx_state = TFRC_SSTATE_NO_SENT; |
1344 | INIT_LIST_HEAD(&hctx->ccid3hctx_hist); | 1376 | INIT_LIST_HEAD(&hctx->ccid3hctx_hist); |
@@ -1389,14 +1421,16 @@ static const char *ccid3_rx_state_name(enum ccid3_hc_rx_states state) | |||
1389 | } | 1421 | } |
1390 | #endif | 1422 | #endif |
1391 | 1423 | ||
1392 | static inline void ccid3_hc_rx_set_state(struct sock *sk, enum ccid3_hc_rx_states state) | 1424 | static inline void ccid3_hc_rx_set_state(struct sock *sk, |
1425 | enum ccid3_hc_rx_states state) | ||
1393 | { | 1426 | { |
1394 | struct dccp_sock *dp = dccp_sk(sk); | 1427 | struct dccp_sock *dp = dccp_sk(sk); |
1395 | struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; | 1428 | struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; |
1396 | enum ccid3_hc_rx_states oldstate = hcrx->ccid3hcrx_state; | 1429 | enum ccid3_hc_rx_states oldstate = hcrx->ccid3hcrx_state; |
1397 | 1430 | ||
1398 | ccid3_pr_debug("%s(%p) %-8.8s -> %s\n", | 1431 | ccid3_pr_debug("%s(%p) %-8.8s -> %s\n", |
1399 | dccp_role(sk), sk, ccid3_rx_state_name(oldstate), ccid3_rx_state_name(state)); | 1432 | dccp_role(sk), sk, ccid3_rx_state_name(oldstate), |
1433 | ccid3_rx_state_name(state)); | ||
1400 | WARN_ON(state == oldstate); | 1434 | WARN_ON(state == oldstate); |
1401 | hcrx->ccid3hcrx_state = state; | 1435 | hcrx->ccid3hcrx_state = state; |
1402 | } | 1436 | } |
@@ -1434,9 +1468,12 @@ static int ccid3_hc_rx_add_hist(struct sock *sk, | |||
1434 | num_later++; | 1468 | num_later++; |
1435 | 1469 | ||
1436 | if (num_later == TFRC_RECV_NUM_LATE_LOSS) { | 1470 | if (num_later == TFRC_RECV_NUM_LATE_LOSS) { |
1437 | dccp_rx_hist_entry_delete(ccid3_rx_hist, packet); | 1471 | dccp_rx_hist_entry_delete(ccid3_rx_hist, |
1438 | ccid3_pr_debug("%s, sk=%p, packet(%llu) already lost!\n", | 1472 | packet); |
1439 | dccp_role(sk), sk, seqno); | 1473 | ccid3_pr_debug("%s, sk=%p, packet" |
1474 | "(%llu) already lost!\n", | ||
1475 | dccp_role(sk), sk, | ||
1476 | seqno); | ||
1440 | return 1; | 1477 | return 1; |
1441 | } | 1478 | } |
1442 | } | 1479 | } |
@@ -1444,12 +1481,18 @@ static int ccid3_hc_rx_add_hist(struct sock *sk, | |||
1444 | if (num_later < TFRC_RECV_NUM_LATE_LOSS) | 1481 | if (num_later < TFRC_RECV_NUM_LATE_LOSS) |
1445 | dccp_rx_hist_add_entry(&hcrx->ccid3hcrx_hist, | 1482 | dccp_rx_hist_add_entry(&hcrx->ccid3hcrx_hist, |
1446 | packet); | 1483 | packet); |
1447 | /* FIXME: else what? should we destroy the packet like above? */ | 1484 | /* |
1485 | * FIXME: else what? should we destroy the packet | ||
1486 | * like above? | ||
1487 | */ | ||
1448 | } | 1488 | } |
1449 | } | 1489 | } |
1450 | 1490 | ||
1451 | trim_history: | 1491 | trim_history: |
1452 | /* Trim history (remove all packets after the NUM_LATE_LOSS + 1 data packets) */ | 1492 | /* |
1493 | * Trim history (remove all packets after the NUM_LATE_LOSS + 1 | ||
1494 | * data packets) | ||
1495 | */ | ||
1453 | num_later = TFRC_RECV_NUM_LATE_LOSS + 1; | 1496 | num_later = TFRC_RECV_NUM_LATE_LOSS + 1; |
1454 | 1497 | ||
1455 | if (!list_empty(&hcrx->ccid3hcrx_loss_interval_hist)) { | 1498 | if (!list_empty(&hcrx->ccid3hcrx_loss_interval_hist)) { |
@@ -1489,15 +1532,18 @@ trim_history: | |||
1489 | if (tmp < 0) | 1532 | if (tmp < 0) |
1490 | tmp += TFRC_WIN_COUNT_LIMIT; | 1533 | tmp += TFRC_WIN_COUNT_LIMIT; |
1491 | if (tmp > TFRC_WIN_COUNT_PER_RTT + 1) { | 1534 | if (tmp > TFRC_WIN_COUNT_PER_RTT + 1) { |
1492 | /* we have found a packet older than one rtt | 1535 | /* |
1493 | * remove the rest */ | 1536 | * We have found a packet older |
1537 | * than one rtt remove the rest | ||
1538 | */ | ||
1494 | step = 3; | 1539 | step = 3; |
1495 | } else /* OK, find next data packet */ | 1540 | } else /* OK, find next data packet */ |
1496 | num_later = 1; | 1541 | num_later = 1; |
1497 | break; | 1542 | break; |
1498 | case 3: | 1543 | case 3: |
1499 | list_del_init(&entry->dccphrx_node); | 1544 | list_del_init(&entry->dccphrx_node); |
1500 | dccp_rx_hist_entry_delete(ccid3_rx_hist, entry); | 1545 | dccp_rx_hist_entry_delete(ccid3_rx_hist, |
1546 | entry); | ||
1501 | break; | 1547 | break; |
1502 | } | 1548 | } |
1503 | } else if (dccp_rx_hist_entry_data_packet(entry)) | 1549 | } else if (dccp_rx_hist_entry_data_packet(entry)) |
@@ -1564,7 +1610,8 @@ static void ccid3_hc_rx_insert_options(struct sock *sk, struct sk_buff *skb) | |||
1564 | u32 x_recv, pinv; | 1610 | u32 x_recv, pinv; |
1565 | struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; | 1611 | struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; |
1566 | 1612 | ||
1567 | if (hcrx == NULL || !(sk->sk_state == DCCP_OPEN || sk->sk_state == DCCP_PARTOPEN)) | 1613 | if (hcrx == NULL || !(sk->sk_state == DCCP_OPEN || |
1614 | sk->sk_state == DCCP_PARTOPEN)) | ||
1568 | return; | 1615 | return; |
1569 | 1616 | ||
1570 | DCCP_SKB_CB(skb)->dccpd_ccval = hcrx->ccid3hcrx_last_counter; | 1617 | DCCP_SKB_CB(skb)->dccpd_ccval = hcrx->ccid3hcrx_last_counter; |
@@ -1658,13 +1705,15 @@ static u32 ccid3_hc_rx_calc_first_li(struct sock *sk) | |||
1658 | } | 1705 | } |
1659 | 1706 | ||
1660 | if (step == 0) { | 1707 | if (step == 0) { |
1661 | printk(KERN_CRIT "%s: %s, sk=%p, packet history contains no data packets!\n", | 1708 | printk(KERN_CRIT "%s: %s, sk=%p, packet history contains no " |
1709 | "data packets!\n", | ||
1662 | __FUNCTION__, dccp_role(sk), sk); | 1710 | __FUNCTION__, dccp_role(sk), sk); |
1663 | return ~0; | 1711 | return ~0; |
1664 | } | 1712 | } |
1665 | 1713 | ||
1666 | if (interval == 0) { | 1714 | if (interval == 0) { |
1667 | ccid3_pr_debug("%s, sk=%p, Could not find a win_count interval > 0. Defaulting to 1\n", | 1715 | ccid3_pr_debug("%s, sk=%p, Could not find a win_count " |
1716 | "interval > 0. Defaulting to 1\n", | ||
1668 | dccp_role(sk), sk); | 1717 | dccp_role(sk), sk); |
1669 | interval = 1; | 1718 | interval = 1; |
1670 | } | 1719 | } |
@@ -1688,8 +1737,8 @@ found: | |||
1688 | fval = (hcrx->ccid3hcrx_s * 100000) / tmp2; | 1737 | fval = (hcrx->ccid3hcrx_s * 100000) / tmp2; |
1689 | /* do not alter order above or you will get overflow on 32 bit */ | 1738 | /* do not alter order above or you will get overflow on 32 bit */ |
1690 | p = calcx_reverse_lookup(fval); | 1739 | p = calcx_reverse_lookup(fval); |
1691 | ccid3_pr_debug("%s, sk=%p, receive rate=%u bytes/s, implied loss rate=%u\n",\ | 1740 | ccid3_pr_debug("%s, sk=%p, receive rate=%u bytes/s, implied " |
1692 | dccp_role(sk), sk, x_recv, p); | 1741 | "loss rate=%u\n", dccp_role(sk), sk, x_recv, p); |
1693 | 1742 | ||
1694 | if (p == 0) | 1743 | if (p == 0) |
1695 | return ~0; | 1744 | return ~0; |
@@ -1704,25 +1753,31 @@ static void ccid3_hc_rx_update_li(struct sock *sk, u64 seq_loss, u8 win_loss) | |||
1704 | struct ccid3_loss_interval_hist_entry *li_entry; | 1753 | struct ccid3_loss_interval_hist_entry *li_entry; |
1705 | 1754 | ||
1706 | if (seq_loss != DCCP_MAX_SEQNO + 1) { | 1755 | if (seq_loss != DCCP_MAX_SEQNO + 1) { |
1707 | ccid3_pr_debug("%s, sk=%p, seq_loss=%llu, win_loss=%u, packet loss detected\n", | 1756 | ccid3_pr_debug("%s, sk=%p, seq_loss=%llu, win_loss=%u, " |
1757 | "packet loss detected\n", | ||
1708 | dccp_role(sk), sk, seq_loss, win_loss); | 1758 | dccp_role(sk), sk, seq_loss, win_loss); |
1709 | 1759 | ||
1710 | if (list_empty(&hcrx->ccid3hcrx_loss_interval_hist)) { | 1760 | if (list_empty(&hcrx->ccid3hcrx_loss_interval_hist)) { |
1711 | struct ccid3_loss_interval_hist_entry *li_tail = NULL; | 1761 | struct ccid3_loss_interval_hist_entry *li_tail = NULL; |
1712 | int i; | 1762 | int i; |
1713 | 1763 | ||
1714 | ccid3_pr_debug("%s, sk=%p, first loss event detected, creating history\n", dccp_role(sk), sk); | 1764 | ccid3_pr_debug("%s, sk=%p, first loss event detected, " |
1765 | "creating history\n", | ||
1766 | dccp_role(sk), sk); | ||
1715 | for (i = 0; i <= TFRC_RECV_IVAL_F_LENGTH; ++i) { | 1767 | for (i = 0; i <= TFRC_RECV_IVAL_F_LENGTH; ++i) { |
1716 | li_entry = ccid3_loss_interval_hist_entry_new(SLAB_ATOMIC); | 1768 | li_entry = ccid3_loss_interval_hist_entry_new(SLAB_ATOMIC); |
1717 | if (li_entry == NULL) { | 1769 | if (li_entry == NULL) { |
1718 | ccid3_loss_interval_history_delete(&hcrx->ccid3hcrx_loss_interval_hist); | 1770 | ccid3_loss_interval_history_delete(&hcrx->ccid3hcrx_loss_interval_hist); |
1719 | ccid3_pr_debug("%s, sk=%p, not enough mem for creating history\n", | 1771 | ccid3_pr_debug("%s, sk=%p, not enough " |
1772 | "mem for creating " | ||
1773 | "history\n", | ||
1720 | dccp_role(sk), sk); | 1774 | dccp_role(sk), sk); |
1721 | return; | 1775 | return; |
1722 | } | 1776 | } |
1723 | if (li_tail == NULL) | 1777 | if (li_tail == NULL) |
1724 | li_tail = li_entry; | 1778 | li_tail = li_entry; |
1725 | list_add(&li_entry->ccid3lih_node, &hcrx->ccid3hcrx_loss_interval_hist); | 1779 | list_add(&li_entry->ccid3lih_node, |
1780 | &hcrx->ccid3hcrx_loss_interval_hist); | ||
1726 | } | 1781 | } |
1727 | 1782 | ||
1728 | li_entry->ccid3lih_seqno = seq_loss; | 1783 | li_entry->ccid3lih_seqno = seq_loss; |
@@ -1772,11 +1827,13 @@ static void ccid3_hc_rx_detect_loss(struct sock *sk) | |||
1772 | if (list_empty(&hcrx->ccid3hcrx_loss_interval_hist)) { | 1827 | if (list_empty(&hcrx->ccid3hcrx_loss_interval_hist)) { |
1773 | /* no loss event have occured yet */ | 1828 | /* no loss event have occured yet */ |
1774 | ccid3_pr_debug("%s, sk=%p, TODO: find a lost data " | 1829 | ccid3_pr_debug("%s, sk=%p, TODO: find a lost data " |
1775 | "packet by comparing to initial seqno\n", | 1830 | "packet by comparing to initial " |
1831 | "seqno\n", | ||
1776 | dccp_role(sk), sk); | 1832 | dccp_role(sk), sk); |
1777 | goto out_update_li; | 1833 | goto out_update_li; |
1778 | } else { | 1834 | } else { |
1779 | pr_info("%s: %s, sk=%p, ERROR! Less than 4 data packets in history", | 1835 | pr_info("%s: %s, sk=%p, ERROR! Less than 4 data " |
1836 | "packets in history", | ||
1780 | __FUNCTION__, dccp_role(sk), sk); | 1837 | __FUNCTION__, dccp_role(sk), sk); |
1781 | return; | 1838 | return; |
1782 | } | 1839 | } |
@@ -1831,7 +1888,9 @@ static u32 ccid3_hc_rx_calc_i_mean(struct sock *sk) | |||
1831 | u32 i_tot1 = 0; | 1888 | u32 i_tot1 = 0; |
1832 | u32 w_tot = 0; | 1889 | u32 w_tot = 0; |
1833 | 1890 | ||
1834 | list_for_each_entry_safe(li_entry, li_next, &hcrx->ccid3hcrx_loss_interval_hist, ccid3lih_node) { | 1891 | list_for_each_entry_safe(li_entry, li_next, |
1892 | &hcrx->ccid3hcrx_loss_interval_hist, | ||
1893 | ccid3lih_node) { | ||
1835 | if (i < TFRC_RECV_IVAL_F_LENGTH) { | 1894 | if (i < TFRC_RECV_IVAL_F_LENGTH) { |
1836 | i_tot0 += li_entry->ccid3lih_interval * ccid3_hc_rx_w[i]; | 1895 | i_tot0 += li_entry->ccid3lih_interval * ccid3_hc_rx_w[i]; |
1837 | w_tot += ccid3_hc_rx_w[i]; | 1896 | w_tot += ccid3_hc_rx_w[i]; |
@@ -1845,7 +1904,8 @@ static u32 ccid3_hc_rx_calc_i_mean(struct sock *sk) | |||
1845 | } | 1904 | } |
1846 | 1905 | ||
1847 | if (i != TFRC_RECV_IVAL_F_LENGTH) { | 1906 | if (i != TFRC_RECV_IVAL_F_LENGTH) { |
1848 | pr_info("%s: %s, sk=%p, ERROR! Missing entry in interval history!\n", | 1907 | pr_info("%s: %s, sk=%p, ERROR! Missing entry in " |
1908 | "interval history!\n", | ||
1849 | __FUNCTION__, dccp_role(sk), sk); | 1909 | __FUNCTION__, dccp_role(sk), sk); |
1850 | return 0; | 1910 | return 0; |
1851 | } | 1911 | } |
@@ -1870,11 +1930,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
1870 | u8 win_count; | 1930 | u8 win_count; |
1871 | u32 p_prev; | 1931 | u32 p_prev; |
1872 | int ins; | 1932 | int ins; |
1873 | #if 0 | 1933 | |
1874 | ccid3_pr_debug("%s, sk=%p(%s), skb=%p(%s)\n", | ||
1875 | dccp_role(sk), sk, dccp_state_name(sk->sk_state), | ||
1876 | skb, dccp_packet_name(DCCP_SKB_CB(skb)->dccpd_type)); | ||
1877 | #endif | ||
1878 | if (hcrx == NULL) | 1934 | if (hcrx == NULL) |
1879 | return; | 1935 | return; |
1880 | 1936 | ||
@@ -1913,7 +1969,8 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
1913 | packet = dccp_rx_hist_entry_new(ccid3_rx_hist, opt_recv->dccpor_ndp, | 1969 | packet = dccp_rx_hist_entry_new(ccid3_rx_hist, opt_recv->dccpor_ndp, |
1914 | skb, SLAB_ATOMIC); | 1970 | skb, SLAB_ATOMIC); |
1915 | if (packet == NULL) { | 1971 | if (packet == NULL) { |
1916 | ccid3_pr_debug("%s, sk=%p, Not enough mem to add rx packet to history (consider it lost)!", | 1972 | ccid3_pr_debug("%s, sk=%p, Not enough mem to add rx packet " |
1973 | "to history (consider it lost)!", | ||
1917 | dccp_role(sk), sk); | 1974 | dccp_role(sk), sk); |
1918 | return; | 1975 | return; |
1919 | } | 1976 | } |
@@ -1927,13 +1984,16 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
1927 | 1984 | ||
1928 | switch (hcrx->ccid3hcrx_state) { | 1985 | switch (hcrx->ccid3hcrx_state) { |
1929 | case TFRC_RSTATE_NO_DATA: | 1986 | case TFRC_RSTATE_NO_DATA: |
1930 | ccid3_pr_debug("%s, sk=%p(%s), skb=%p, sending initial feedback\n", | 1987 | ccid3_pr_debug("%s, sk=%p(%s), skb=%p, sending initial " |
1931 | dccp_role(sk), sk, dccp_state_name(sk->sk_state), skb); | 1988 | "feedback\n", |
1989 | dccp_role(sk), sk, | ||
1990 | dccp_state_name(sk->sk_state), skb); | ||
1932 | ccid3_hc_rx_send_feedback(sk); | 1991 | ccid3_hc_rx_send_feedback(sk); |
1933 | ccid3_hc_rx_set_state(sk, TFRC_RSTATE_DATA); | 1992 | ccid3_hc_rx_set_state(sk, TFRC_RSTATE_DATA); |
1934 | return; | 1993 | return; |
1935 | case TFRC_RSTATE_DATA: | 1994 | case TFRC_RSTATE_DATA: |
1936 | hcrx->ccid3hcrx_bytes_recv += skb->len - dccp_hdr(skb)->dccph_doff * 4; | 1995 | hcrx->ccid3hcrx_bytes_recv += skb->len - |
1996 | dccp_hdr(skb)->dccph_doff * 4; | ||
1937 | if (ins == 0) { | 1997 | if (ins == 0) { |
1938 | if (now_delta(hcrx->ccid3hcrx_tstamp_last_ack) >= | 1998 | if (now_delta(hcrx->ccid3hcrx_tstamp_last_ack) >= |
1939 | hcrx->ccid3hcrx_rtt) { | 1999 | hcrx->ccid3hcrx_rtt) { |
@@ -1975,7 +2035,8 @@ static int ccid3_hc_rx_init(struct sock *sk) | |||
1975 | 2035 | ||
1976 | ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); | 2036 | ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); |
1977 | 2037 | ||
1978 | hcrx = dp->dccps_hc_rx_ccid_private = kmalloc(sizeof(*hcrx), gfp_any()); | 2038 | hcrx = dp->dccps_hc_rx_ccid_private = kmalloc(sizeof(*hcrx), |
2039 | gfp_any()); | ||
1979 | if (hcrx == NULL) | 2040 | if (hcrx == NULL) |
1980 | return -ENOMEM; | 2041 | return -ENOMEM; |
1981 | 2042 | ||
@@ -2135,7 +2196,8 @@ static __exit void ccid3_module_exit(void) | |||
2135 | } | 2196 | } |
2136 | module_exit(ccid3_module_exit); | 2197 | module_exit(ccid3_module_exit); |
2137 | 2198 | ||
2138 | MODULE_AUTHOR("Ian McDonald <iam4@cs.waikato.ac.nz> & Arnaldo Carvalho de Melo <acme@ghostprotocols.net>"); | 2199 | MODULE_AUTHOR("Ian McDonald <iam4@cs.waikato.ac.nz>, " |
2200 | "Arnaldo Carvalho de Melo <acme@ghostprotocols.net>"); | ||
2139 | MODULE_DESCRIPTION("DCCP TFRC CCID3 CCID"); | 2201 | MODULE_DESCRIPTION("DCCP TFRC CCID3 CCID"); |
2140 | MODULE_LICENSE("GPL"); | 2202 | MODULE_LICENSE("GPL"); |
2141 | MODULE_ALIAS("net-dccp-ccid-3"); | 2203 | MODULE_ALIAS("net-dccp-ccid-3"); |