blob: edfa28e5d42b53369bb7c6d8dac91787effab8d0 [file] [log] [blame]
developer42c7a432024-07-12 14:39:29 +08001From b29da202bdcbdc75cd75db37175261fb22d1e13b Mon Sep 17 00:00:00 2001
2From: Johannes Berg <johannes.berg@intel.com>
3Date: Fri, 17 May 2024 12:12:10 +0200
developer05f3b2b2024-08-19 19:17:34 +08004Subject: [PATCH 02/13] iw: add puncturing support
developer42c7a432024-07-12 14:39:29 +08005
6Parse and pass the puncturing bitmap to the kernel in any
7chandef (except S1G), the kernel will check validity.
8
9Reviewed-by: Miriam Rachel Korenblit <miriam.rachel.korenblit@intel.com>
10Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11---
12 iw.h | 7 ++++---
13 util.c | 15 ++++++++++++++-
14 2 files changed, 18 insertions(+), 4 deletions(-)
15
16diff --git a/iw.h b/iw.h
17index 82eee7c..f416d6d 100644
18--- a/iw.h
19+++ b/iw.h
20@@ -106,6 +106,7 @@ struct chandef {
21 unsigned int center_freq1;
22 unsigned int center_freq1_offset;
23 unsigned int center_freq2;
24+ unsigned int punctured;
25 };
26
27 #define ARRAY_SIZE(ar) (sizeof(ar)/sizeof(ar[0]))
28@@ -210,8 +211,8 @@ unsigned char *parse_hex(char *hex, size_t *outlen);
29
30 int parse_keys(struct nl_msg *msg, char **argv[], int *argc);
31
32-#define _PARSE_FREQ_ARGS_OPT1 "<freq> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz|160MHz|320MHz]"
33-#define _PARSE_FREQ_ARGS_OPT2 "<control freq> [5|10|20|40|80|80+80|160|320] [<center1_freq> [<center2_freq>]]"
34+#define _PARSE_FREQ_ARGS_OPT1 "<freq> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz|160MHz|320MHz] [punct <bitmap>]"
35+#define _PARSE_FREQ_ARGS_OPT2 "<control freq> [5|10|20|40|80|80+80|160|320] [<center1_freq> [<center2_freq>]] [punct <bitmap>]"
36 #define PARSE_FREQ_ARGS(pfx, sfx) \
37 pfx _PARSE_FREQ_ARGS_OPT1 sfx "\n" \
38 pfx _PARSE_FREQ_ARGS_OPT2 sfx
39@@ -221,7 +222,7 @@ int parse_keys(struct nl_msg *msg, char **argv[], int *argc);
40 pfx _PARSE_FREQ_KHZ_ARGS_OPT1 sfx "\n" \
41 pfx _PARSE_FREQ_KHZ_ARGS_OPT2 sfx
42 #define PARSE_CHAN_ARGS(pfx) \
43- pfx "<channel> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz|160MHz|320MHz]"
44+ pfx "<channel> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz|160MHz|320MHz] [punct <bitmap>]"
45 int parse_freqchan(struct chandef *chandef, bool chan, int argc, char **argv,
46 int *parsed, bool freq_in_khz);
47 enum nl80211_chan_width str_to_bw(const char *str);
48diff --git a/util.c b/util.c
49index f358317..e43d590 100644
50--- a/util.c
51+++ b/util.c
52@@ -735,13 +735,23 @@ int parse_freqchan(struct chandef *chandef, bool chan, int argc, char **argv,
53 goto out;
54 }
55
56- /* This was a only a channel definition, nothing further may follow. */
57+ /* This was a only a channel definition, only puncturing may follow */
58 if (chan)
59 goto out;
60
61 res = parse_freqs(chandef, argc - 1, argv + 1, &_parsed, freq_in_khz);
62
63 out:
64+ if (!freq_in_khz && argc > _parsed && strcmp(argv[_parsed], "punct") == 0) {
65+ _parsed++;
66+ if (argc <= _parsed)
67+ return 1;
68+ chandef->punctured = strtoul(argv[_parsed], &end, 10);
69+ if (*end)
70+ return 1;
71+ _parsed++;
72+ }
73+
74 /* Error out if parsed is NULL. */
75 if (!parsed && _parsed != argc)
76 return 1;
77@@ -800,6 +810,9 @@ int put_chandef(struct nl_msg *msg, struct chandef *chandef)
78 NL80211_ATTR_CENTER_FREQ2,
79 chandef->center_freq2);
80
81+ if (chandef->punctured)
82+ NLA_PUT_U32(msg, NL80211_ATTR_PUNCT_BITMAP, chandef->punctured);
83+
84 return 0;
85
86 nla_put_failure:
87--
882.18.0
89