00e4bf2467fbf1b12fcd01089001c97e75bcf05b
[librecmc/librecmc.git] / package / network / utils / iw / patches / 010-dynack.patch
1
2
3 Add auto parameter to set distance command in order to enable ACK timeout
4 estimation algorithm (dynack). Dynack is automatically disabled setting valid
5 value for coverage class. Currently dynack is supported just by ath9k
6
7 This patch is based on "configure dynack through mac80211/cfg80211 stack"
8 patchset sent on linux-wireless
9
10 Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
11 ---
12  info.c    |  2 ++
13  nl80211.h | 12 ++++++++++++
14  phy.c     | 43 +++++++++++++++++++++++++------------------
15  3 files changed, 39 insertions(+), 18 deletions(-)
16
17 --- a/info.c
18 +++ b/info.c
19 @@ -551,6 +551,8 @@ broken_combination:
20                         printf("\tDevice supports scan flush.\n");
21                 if (features & NL80211_FEATURE_AP_SCAN)
22                         printf("\tDevice supports AP scan.\n");
23 +               if (features & NL80211_FEATURE_ACKTO_ESTIMATION)
24 +                       printf("\tDevice supports ACK timeout estimation.\n");
25         }
26  
27         if (tb_msg[NL80211_ATTR_TDLS_SUPPORT])
28 --- a/phy.c
29 +++ b/phy.c
30 @@ -362,39 +362,46 @@ static int handle_distance(struct nl8021
31                         int argc, char **argv,
32                         enum id_input id)
33  {
34 -       char *end;
35 -       unsigned int distance, coverage;
36 -
37         if (argc != 1)
38                 return 1;
39  
40         if (!*argv[0])
41                 return 1;
42  
43 -       distance = strtoul(argv[0], &end, 10);
44 +       if (strcmp("auto", argv[0]) == 0) {
45 +               NLA_PUT_FLAG(msg, NL80211_ATTR_WIPHY_DYN_ACK);
46 +       } else {
47 +               char *end;
48 +               unsigned int distance, coverage;
49  
50 -       if (*end)
51 -               return 1;
52 +               distance = strtoul(argv[0], &end, 10);
53  
54 -       /*
55 -        * Divide double the distance by the speed of light in m/usec (300) to
56 -        * get round-trip time in microseconds and then divide the result by
57 -        * three to get coverage class as specified in IEEE 802.11-2007 table
58 -        * 7-27. Values are rounded upwards.
59 -        */
60 -       coverage = (distance + 449) / 450;
61 -       if (coverage > 255)
62 -               return 1;
63 +               if (*end)
64 +                       return 1;
65 +
66 +               /*
67 +                * Divide double the distance by the speed of light
68 +                * in m/usec (300) to get round-trip time in microseconds
69 +                * and then divide the result by three to get coverage class
70 +                * as specified in IEEE 802.11-2007 table 7-27.
71 +                * Values are rounded upwards.
72 +                */
73 +               coverage = (distance + 449) / 450;
74 +               if (coverage > 255)
75 +                       return 1;
76  
77 -       NLA_PUT_U8(msg, NL80211_ATTR_WIPHY_COVERAGE_CLASS, coverage);
78 +               NLA_PUT_U8(msg, NL80211_ATTR_WIPHY_COVERAGE_CLASS, coverage);
79 +       }
80  
81         return 0;
82   nla_put_failure:
83         return -ENOBUFS;
84  }
85 -COMMAND(set, distance, "<distance>",
86 +COMMAND(set, distance, "<auto|distance>",
87         NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_distance,
88 -       "Set appropriate coverage class for given link distance in meters.\n"
89 +       "Enable ACK timeout estimation algorithm (dynack) or set appropriate\n"
90 +       "coverage class for given link distance in meters.\n"
91 +       "To disable dynack set valid value for coverage class.\n"
92         "Valid values: 0 - 114750");
93  
94  static int handle_txpower(struct nl80211_state *state,