Skip to content

Commit f1a94f2

Browse files
authored
[feature] OpenWrt: added support for Wifi6/802.11ax #199
Closes #199
1 parent ca737e3 commit f1a94f2

4 files changed

Lines changed: 164 additions & 9 deletions

File tree

docs/source/backends/openwrt.rst

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,13 +1350,13 @@ Radio object extensions
13501350
In addition to the default *NetJSON Radio object options*, the ``OpenWrt`` backend
13511351
also requires setting the following additional options for each radio in the list:
13521352

1353-
+--------------+---------+-----------------------------------------------+
1354-
| key name | type | allowed values |
1355-
+==============+=========+===============================================+
1356-
| ``driver`` | string | mac80211, atheros, ath5k, ath9k, broadcom |
1357-
+--------------+---------+-----------------------------------------------+
1358-
| ``protocol`` | string | 802.11a, 802.11b, 802.11g, 802.11n, 802.11ac |
1359-
+--------------+---------+-----------------------------------------------+
1353+
+--------------+---------+---------------------------------------------------------+
1354+
| key name | type | allowed values |
1355+
+==============+=========+=========================================================+
1356+
| ``driver`` | string | mac80211, atheros, ath5k, ath9k, broadcom |
1357+
+--------------+---------+---------------------------------------------------------+
1358+
| ``protocol`` | string | 802.11a, 802.11b, 802.11g, 802.11n, 802.11ac, 802.11ax |
1359+
+--------------+---------+---------------------------------------------------------+
13601360

13611361
Radio example
13621362
~~~~~~~~~~~~~
@@ -1417,7 +1417,7 @@ Automatic channel selection example
14171417
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14181418

14191419
If you need to use the "automatic channel selection" feature of OpenWRT, you must set
1420-
the channel to ``0`` and, unless you are using neither **802.11n** nor **802.11ac**,
1420+
the channel to ``0`` and, unless you are using neither **802.11n** nor **802.11ac** nor **802.11ax**,
14211421
you must set the ``hwmode`` property to tell OpenWRT which band to use
14221422
(11g for 2.4 Ghz, 11a for 5 GHz).
14231423

@@ -1498,6 +1498,38 @@ UCI output::
14981498
option phy 'phy0'
14991499
option type 'mac80211'
15001500

1501+
802.11ax example
1502+
~~~~~~~~~~~~~~~~
1503+
1504+
In the following example we show how to configure an *802.11ax* capable radio:
1505+
1506+
.. code-block:: python
1507+
1508+
{
1509+
"radios": [
1510+
{
1511+
"name": "radio0",
1512+
"phy": "phy0",
1513+
"driver": "mac80211",
1514+
"protocol": "802.11ax",
1515+
"channel": 36,
1516+
"channel_width": 80,
1517+
}
1518+
]
1519+
}
1520+
1521+
UCI output::
1522+
1523+
package wireless
1524+
1525+
config wifi-device 'radio0'
1526+
option channel '36'
1527+
option htmode 'HE80'
1528+
option hwmode '11a'
1529+
option phy 'phy0'
1530+
option type 'mac80211'
1531+
1532+
15011533
Static Routes
15021534
-------------
15031535

netjsonconfig/backends/openwrt/converters/radios.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ def __intermediate_htmode(self, radio):
6666
return 'HT{0}'.format(channel_width)
6767
elif protocol == '802.11ac':
6868
return 'VHT{0}'.format(channel_width)
69+
elif protocol == '802.11ax':
70+
return 'HE{0}'.format(channel_width)
6971
# disables n
7072
return 'NONE'
7173

@@ -98,6 +100,8 @@ def __netjson_protocol(self, radio):
98100
return '802.11n'
99101
elif htmode.startswith('VHT'):
100102
return '802.11ac'
103+
elif htmode.startswith('HE'):
104+
return '802.11ax'
101105
return '802.{0}'.format(hwmode)
102106

103107
def __netjson_channel(self, radio):
@@ -118,7 +122,7 @@ def __netjson_channel_width(self, radio):
118122
htmode = radio.pop('htmode')
119123
if htmode == 'NONE':
120124
return 20
121-
channel_width = htmode.replace('VHT', '').replace('HT', '')
125+
channel_width = htmode.replace('VHT', '').replace('HT', '').replace('HE', '')
122126
# we need to override htmode
123127
if '+' in channel_width or '-' in channel_width:
124128
radio['htmode'] = htmode

netjsonconfig/schema.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,9 @@
744744
"radio_ac_channel_width": {
745745
"properties": {"channel_width": {"enum": [20, 40, 80, 160]}}
746746
},
747+
"radio_ax_channel_width": {
748+
"properties": {"channel_width": {"enum": [20, 40, 80, 160]}}
749+
},
747750
"radio_80211bg_settings": {
748751
"title": "802.11b/g (2.4 GHz legacy)",
749752
"allOf": [
@@ -798,6 +801,34 @@
798801
{"$ref": "#/definitions/radio_ac_channel_width"},
799802
],
800803
},
804+
"radio_80211ax_2ghz_settings": {
805+
"title": "802.11AX (2.4 GHz AX)",
806+
"allOf": [
807+
{
808+
"properties": {
809+
"protocol": {"enum": ["802.11ax"]},
810+
"hwmode": {"enum": ["11g"]},
811+
}
812+
},
813+
{"$ref": "#/definitions/base_radio_settings"},
814+
{"$ref": "#/definitions/radio_2ghz_channels"},
815+
{"$ref": "#/definitions/radio_ax_channel_width"},
816+
],
817+
},
818+
"radio_80211ax_5ghz_settings": {
819+
"title": "802.11ax (5 GHz AX)",
820+
"allOf": [
821+
{
822+
"properties": {
823+
"protocol": {"enum": ["802.11ax"]},
824+
"hwmode": {"enum": ["11a"]},
825+
}
826+
},
827+
{"$ref": "#/definitions/base_radio_settings"},
828+
{"$ref": "#/definitions/radio_5ghz_channels"},
829+
{"$ref": "#/definitions/radio_ax_channel_width"},
830+
],
831+
},
801832
},
802833
"properties": {
803834
"general": {
@@ -856,6 +887,8 @@
856887
{"$ref": "#/definitions/radio_80211an_settings"},
857888
{"$ref": "#/definitions/radio_80211ac_2ghz_settings"},
858889
{"$ref": "#/definitions/radio_80211ac_5ghz_settings"},
890+
{"$ref": "#/definitions/radio_80211ax_2ghz_settings"},
891+
{"$ref": "#/definitions/radio_80211ax_5ghz_settings"},
859892
{"$ref": "#/definitions/radio_80211bg_settings"},
860893
{"$ref": "#/definitions/radio_80211a_settings"},
861894
],

tests/openwrt/test_radio.py

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,92 @@ def test_auto_80211ac_5ghz_channel(self):
530530
)
531531
self.assertEqual(o.render(), expected)
532532

533+
def test_parse_auto_80211ax_5ghz_channel(self):
534+
native = self._tabs(
535+
"""package wireless
536+
537+
config wifi-device 'radio0'
538+
option channel 'auto'
539+
option htmode 'HE20'
540+
option hwmode '11a'
541+
option phy 'phy0'
542+
option type 'mac80211'
543+
"""
544+
)
545+
expected = {
546+
"radios": [
547+
{
548+
"name": "radio0",
549+
"phy": "phy0",
550+
"driver": "mac80211",
551+
"protocol": "802.11ax",
552+
"channel": 0,
553+
"channel_width": 20,
554+
"hwmode": "11a",
555+
}
556+
]
557+
}
558+
o = OpenWrt(native=native)
559+
self.assertEqual(o.config, expected)
560+
561+
def test_auto_80211ax_2ghz_channel(self):
562+
o = OpenWrt(
563+
{
564+
"radios": [
565+
{
566+
"name": "radio0",
567+
"phy": "phy0",
568+
"driver": "mac80211",
569+
"protocol": "802.11ax",
570+
"channel": 0,
571+
"channel_width": 80,
572+
"hwmode": "11g",
573+
}
574+
]
575+
}
576+
)
577+
expected = self._tabs(
578+
"""package wireless
579+
580+
config wifi-device 'radio0'
581+
option channel 'auto'
582+
option htmode 'HE80'
583+
option hwmode '11g'
584+
option phy 'phy0'
585+
option type 'mac80211'
586+
"""
587+
)
588+
self.assertEqual(o.render(), expected)
589+
590+
def test_auto_80211ax_5ghz_channel(self):
591+
o = OpenWrt(
592+
{
593+
"radios": [
594+
{
595+
"name": "radio0",
596+
"phy": "phy0",
597+
"driver": "mac80211",
598+
"protocol": "802.11ax",
599+
"channel": 0,
600+
"channel_width": 160,
601+
"hwmode": "11a",
602+
}
603+
]
604+
}
605+
)
606+
expected = self._tabs(
607+
"""package wireless
608+
609+
config wifi-device 'radio0'
610+
option channel 'auto'
611+
option htmode 'HE160'
612+
option hwmode '11a'
613+
option phy 'phy0'
614+
option type 'mac80211'
615+
"""
616+
)
617+
self.assertEqual(o.render(), expected)
618+
533619
def test_auto_80211g_channel(self):
534620
o = OpenWrt(
535621
{

0 commit comments

Comments
 (0)