-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: John Crispin <[email protected]>
- Loading branch information
Showing
11 changed files
with
524 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
{% | ||
|
||
let wmm = state?.globals?.wireless_multimedia; | ||
|
||
if (!length(wmm)) | ||
return; | ||
|
||
let class = { | ||
"CS1": 8, | ||
"CS2": 16, | ||
"CS3": 24, | ||
"CS4": 32, | ||
"CS5": 40, | ||
"CS6": 48, | ||
"CS7": 56, | ||
"AF11": 10, | ||
"AF12": 12, | ||
"AF13": 14, | ||
"AF21": 18, | ||
"AF22": 20, | ||
"AF23": 22, | ||
"AF31": 26, | ||
"AF32": 28, | ||
"AF33": 30, | ||
"AF41": 34, | ||
"AF42": 36, | ||
"AF43": 38, | ||
"EF": 46, | ||
"DF": 0, | ||
}; | ||
|
||
let profiles = { | ||
"enterprise": { | ||
"UP0": [ "DF"], | ||
"UP1": [ "CS1" ], | ||
"UP2": [ "AF11", "AF12", "AF13" ], | ||
"UP3": [ "CS2", "AF21", "AF22", "AF23" ], | ||
"UP4": [ "CS3", "AF31", "AF32", "AF33" ], | ||
"UP5": [ "CS5", "AF41", "AF42", "AF43" ], | ||
"UP6": [ "CS4", "EF" ], | ||
"UP7": [ "CS6" ] | ||
} | ||
}; | ||
|
||
function qos_map() { | ||
let up_map = []; | ||
|
||
if (wmm.profile) | ||
wmm = profiles[wmm.profile]; | ||
|
||
for (let prio = 0; prio < 8; prio++) { | ||
let up = wmm["UP" + prio]; | ||
let len = length(up); | ||
|
||
if (length(up) < 2) | ||
continue; | ||
|
||
for (let idx = 1; idx < len; idx++) { | ||
push(up_map, class[up[idx]]); | ||
push(up_map, prio); | ||
} | ||
} | ||
|
||
for (let prio = 0; prio < 8; prio++) { | ||
let up = wmm["UP" + prio]; | ||
|
||
if (length(up)) | ||
push(up_map, class[up[0]]); | ||
else | ||
push(up_map, 255); | ||
push(up_map, 255); | ||
} | ||
let qos_map = join(",", up_map); | ||
|
||
return qos_map; | ||
} | ||
%} | ||
set wireless.{{ section }}.iw_qos_map_set={{ s(qos_map()) }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,46 @@ | ||
{% | ||
if (!quality_of_service) | ||
quality_of_service = {}; | ||
let egress = ethernet.lookup_by_select_ports([quality_of_service.select_port]); | ||
let egress = ethernet.lookup_by_select_ports(quality_of_service.select_ports); | ||
let enable = length(egress); | ||
services.set_enabled("sqm", enable); | ||
services.set_enabled("qosify", enable); | ||
if (!enable) | ||
return; | ||
|
||
if (!quality_of_service.upload_rate || !quality_of_service.download_rate) { | ||
quality_of_service.download_rate = 0; | ||
quality_of_service.upload_rate = 0; | ||
} | ||
|
||
function get_speed(dev, speed) { | ||
if (!speed) | ||
speed = ethernet.get_speed(dev); | ||
return speed * 1000; | ||
return speed; | ||
} | ||
|
||
function get_proto(proto) { | ||
if (proto == "any") | ||
return [ "udp", "tcp" ]; | ||
return [ proto ]; | ||
} | ||
|
||
function dscp_map(dscp) { | ||
let map = { "CS1": 8, "CS2": 16, "CS3": 24, "CS4": 32, "CS5": 40, "CS6": 48, "CS7": 56 }; | ||
return map[dscp] ? map[dscp] : 0; | ||
function get_range(port) { | ||
if (port.range_end) | ||
return sprintf("-%d", port.range_end) | ||
} | ||
|
||
let fs = require("fs"); | ||
let file = fs.open("/tmp/qosify.conf", "w"); | ||
for (let class in quality_of_service.classifier) { | ||
if (!length(class.ports)) | ||
continue; | ||
for (let port in class.ports) | ||
for (let proto in get_proto(port.protocol)) | ||
file.write(sprintf("%s:%d%s %s%s\n", proto, port.port, | ||
port.range_end ? sprintf("-%d", port.range_end) : "", | ||
port.reclassify ? "" : "+", class.dscp)); | ||
} | ||
file.close(); | ||
%} | ||
|
||
{% for (let dev in egress): %} | ||
set sqm.{{ dev }}=queue | ||
set sqm.@queue[-1].interface={{ s(dev) }} | ||
set sqm.@queue[-1].download='{{ get_speed(dev, quality_of_service.upload_rate) }}' | ||
set sqm.@queue[-1].upload='{{ get_speed(dev, quality_of_service.download_rate) }}' | ||
set sqm.@queue[-1].auto_rate='{{ quality_of_service.download_rate ? 0 : 1 }}' | ||
set sqm.@queue[-1].enabled='1' | ||
set sqm.@queue[-1].verbosity='5' | ||
set sqm.@queue[-1].qdisc_advanced='1' | ||
set sqm.@queue[-1].egress_ecn='NOECN' | ||
set sqm.@queue[-1].squash_dscp='0' | ||
set sqm.@queue[-1].squash_ingress='0' | ||
set sqm.@queue[-1].ingress_ecn='ECN' | ||
set sqm.@queue[-1].debug_logging='1' | ||
set sqm.@queue[-1].qdisc='fq_codel' | ||
set sqm.@queue[-1].script='layer_cake.qos' | ||
set sqm.@queue[-1].linklayer='ethernet' | ||
set sqm.@queue[-1].overhead='44' | ||
set sqm.@queue[-1].eqdisc_opts='diffserv4 no-split-gso' | ||
set sqm.@queue[-1].iqdisc_opts='diffserv4 no-split-gso' | ||
{% endfor %} | ||
|
||
{% for (let class in quality_of_service.classifier): %} | ||
{% if (!length(class.ports) && !length(class.dns)) continue; %} | ||
{% let dscp = dscp_map(class.dscp); %} | ||
add sqm classifier | ||
set sqm.@classifier[-1].dscp={{ dscp }} | ||
{% for (let fqdn in class.dns): %} | ||
add_list sqm.@classifier[-1].dns={{ s(fqdn) }} | ||
{% endfor %} | ||
{% for (let port in class.ports): %} | ||
{% if (!port.protocol || !port.port) continue; %} | ||
add_list sqm.@classifier[-1].ports='{{ port.protocol }}:{{ port.port }}{{ port.range_end ? ":" + port.range_end : "" }}' | ||
{% endfor %} | ||
set qosify.{{ dev }}=device | ||
set qosify.{{ dev }}.name={{ s(dev) }} | ||
set qosify.{{ dev }}.bandwidth_up='{{ get_speed(dev, quality_of_service.bandwidth_up) }}mbit' | ||
set qosify.{{ dev }}.bandwidth_down='{{ get_speed(dev, quality_of_service.bandwidth_down) }}mbit' | ||
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
description: | ||
Define a default profile that shall be used for the WMM behaviour of all SSIDs on | ||
the device. | ||
type: string | ||
enum: | ||
- enterprise |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
type: array | ||
items: | ||
type: string | ||
enum: | ||
- CS1 | ||
- CS2 | ||
- CS3 | ||
- CS4 | ||
- CS5 | ||
- CS6 | ||
- AF11 | ||
- AF12 | ||
- AF13 | ||
- AF21 | ||
- AF22 | ||
- AF23 | ||
- AF31 | ||
- AF32 | ||
- AF33 | ||
- AF41 | ||
- AF42 | ||
- AF43 | ||
- DF | ||
- EF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
description: | ||
Define the default WMM behaviour of all SSIDs on the device. Each access | ||
category can be assigned a default class selector that gets used for packet | ||
matching. | ||
type: object | ||
properties: | ||
UP0: | ||
$ref: 'https://ucentral.io/schema/v1/globals/wireless-multimedia/class-selector/' | ||
UP1: | ||
$ref: 'https://ucentral.io/schema/v1/globals/wireless-multimedia/class-selector/' | ||
UP2: | ||
$ref: 'https://ucentral.io/schema/v1/globals/wireless-multimedia/class-selector/' | ||
UP3: | ||
$ref: 'https://ucentral.io/schema/v1/globals/wireless-multimedia/class-selector/' | ||
UP4: | ||
$ref: 'https://ucentral.io/schema/v1/globals/wireless-multimedia/class-selector/' | ||
UP5: | ||
$ref: 'https://ucentral.io/schema/v1/globals/wireless-multimedia/class-selector/' | ||
UP6: | ||
$ref: 'https://ucentral.io/schema/v1/globals/wireless-multimedia/class-selector/' | ||
UP7: | ||
$ref: 'https://ucentral.io/schema/v1/globals/wireless-multimedia/class-selector/' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.