Skip to content

Commit

Permalink
qos: add support for port minimum bandwidth guarantee
Browse files Browse the repository at this point in the history
Reported-At: https://bugzilla.redhat.com/show_bug.cgi?id=2060310
Signed-off-by: Ihar Hrachyshka <ihrachys@redhat.com>
Acked-by: Ales Musil <amusil@redhat.com>
Signed-off-by: Mark Michelson <mmichels@redhat.com>
(cherry picked from commit dbf12e5)
Signed-off-by: Numan Siddique <numans@ovn.org>
  • Loading branch information
booxter authored and numansiddique committed Aug 2, 2022
1 parent 3554c5a commit a27f077
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
OVN v22.03.2 - xx xxx xxxx
--------------------------
- Support (LSP.options:qos_min_rate) to guarantee minimal bandwidth available
for a logical port.

OVN v22.03.1 - 03 Jun 2022
--------------------------
Expand Down
13 changes: 10 additions & 3 deletions controller/binding.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ VLOG_DEFINE_THIS_MODULE(binding);
struct qos_queue {
struct hmap_node node;
uint32_t queue_id;
uint32_t min_rate;
uint32_t max_rate;
uint32_t burst;
};
Expand Down Expand Up @@ -88,17 +89,19 @@ static void update_lport_tracking(const struct sbrec_port_binding *pb,
static void
get_qos_params(const struct sbrec_port_binding *pb, struct hmap *queue_map)
{
uint32_t min_rate = smap_get_int(&pb->options, "qos_min_rate", 0);
uint32_t max_rate = smap_get_int(&pb->options, "qos_max_rate", 0);
uint32_t burst = smap_get_int(&pb->options, "qos_burst", 0);
uint32_t queue_id = smap_get_int(&pb->options, "qdisc_queue_id", 0);

if ((!max_rate && !burst) || !queue_id) {
if ((!min_rate && !max_rate && !burst) || !queue_id) {
/* Qos is not configured for this port. */
return;
}

struct qos_queue *node = xzalloc(sizeof *node);
hmap_insert(queue_map, &node->node, hash_int(queue_id, 0));
node->min_rate = min_rate;
node->max_rate = max_rate;
node->burst = burst;
node->queue_id = queue_id;
Expand Down Expand Up @@ -238,9 +241,12 @@ setup_qos(const char *egress_iface, struct hmap *queue_map)
HMAP_FOR_EACH_WITH_HASH (sb_info, node, hash_int(queue_id, 0),
queue_map) {
is_queue_needed = true;
if (sb_info->max_rate ==
if (sb_info->min_rate ==
smap_get_int(&queue_details, "min-rate", 0)
&& sb_info->max_rate ==
smap_get_int(&queue_details, "max-rate", 0)
&& sb_info->burst == smap_get_int(&queue_details, "burst", 0)) {
&& sb_info->burst ==
smap_get_int(&queue_details, "burst", 0)) {
/* This queue is consistent. */
hmap_insert(&consistent_queues, &sb_info->node,
hash_int(queue_id, 0));
Expand All @@ -265,6 +271,7 @@ setup_qos(const char *egress_iface, struct hmap *queue_map)
}

smap_clear(&queue_details);
smap_add_format(&queue_details, "min-rate", "%d", sb_info->min_rate);
smap_add_format(&queue_details, "max-rate", "%d", sb_info->max_rate);
smap_add_format(&queue_details, "burst", "%d", sb_info->burst);
error = netdev_set_queue(netdev_phy, sb_info->queue_id,
Expand Down
5 changes: 5 additions & 0 deletions ovn-nb.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,11 @@
<ref table="Interface" db="Open_vSwitch"/> table.
</column>

<column name="options" key="qos_min_rate">
If set, indicates the minimum guaranteed rate available for data sent
from this interface, in bit/s.
</column>

<column name="options" key="qos_max_rate">
If set, indicates the maximum rate for data sent from this interface,
in bit/s. The traffic will be shaped according to this limit.
Expand Down
5 changes: 5 additions & 0 deletions ovn-sb.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3270,6 +3270,11 @@ tcp.flags = RST;
<ref table="Interface" db="Open_vSwitch"/> table.
</column>

<column name="options" key="qos_min_rate">
If set, indicates the minimum guaranteed rate available for data sent
from this interface, in bit/s.
</column>

<column name="options" key="qos_max_rate">
If set, indicates the maximum rate for data sent from this interface,
in bit/s. The traffic will be shaped according to this limit.
Expand Down
4 changes: 3 additions & 1 deletion tests/system-ovn.at
Original file line number Diff line number Diff line change
Expand Up @@ -6345,13 +6345,15 @@ ovn-nbctl lsp-add sw0 public \
-- lsp-set-type public localnet \
-- lsp-set-options public network_name=phynet

AT_CHECK([ovn-nbctl set Logical_Switch_Port public options:qos_min_rate=200000])
AT_CHECK([ovn-nbctl set Logical_Switch_Port public options:qos_max_rate=300000])
AT_CHECK([ovn-nbctl set Logical_Switch_Port public options:qos_burst=3000000])
AT_CHECK([ovs-vsctl set interface ovs-public external-ids:ovn-egress-iface=true])
OVS_WAIT_UNTIL([tc qdisc show | grep -q 'htb 1: dev ovs-public'])
OVS_WAIT_UNTIL([tc class show dev ovs-public | \
grep -q 'class htb .* ceil 300Kbit burst 375000b cburst 375000b'])
grep -q 'class htb .* rate 200Kbit ceil 300Kbit burst 375000b cburst 375000b'])

AT_CHECK([ovn-nbctl remove Logical_Switch_Port public options qos_min_rate=200000])
AT_CHECK([ovn-nbctl remove Logical_Switch_Port public options qos_max_rate=300000])
AT_CHECK([ovn-nbctl remove Logical_Switch_Port public options qos_burst=3000000])
OVS_WAIT_UNTIL([test "$(tc qdisc show | grep 'htb 1: dev ovs-public')" = ""])
Expand Down

0 comments on commit a27f077

Please sign in to comment.