From: Babu Shanmugam <bscha...@redhat.com> Replaced the earlier approach of setting the rate and burst parameters in the Interface table with Port tables's qos parameter (using the default queue). In this patch, 'linux-htb' is used as a fixed Qos type.
Also replaced the options for VMI Logical_Ports in NB db. policing_rate is replaced to to qos_max_rate and policing_burst is replaced to qos_burst. Signed-off-by: Babu Shanmugam <bscha...@redhat.com> --- ovn/controller/binding.c | 66 ++++++++++++++++++++++++++++++++++++++---------- ovn/ovn-nb.xml | 6 ++--- 2 files changed, 56 insertions(+), 16 deletions(-) diff --git a/ovn/controller/binding.c b/ovn/controller/binding.c index 32fcb85..6b6c40a 100644 --- a/ovn/controller/binding.c +++ b/ovn/controller/binding.c @@ -40,13 +40,17 @@ binding_register_ovs_idl(struct ovsdb_idl *ovs_idl) ovsdb_idl_add_table(ovs_idl, &ovsrec_table_port); ovsdb_idl_add_column(ovs_idl, &ovsrec_port_col_name); ovsdb_idl_add_column(ovs_idl, &ovsrec_port_col_interfaces); + ovsdb_idl_add_column(ovs_idl, &ovsrec_port_col_qos); ovsdb_idl_add_table(ovs_idl, &ovsrec_table_interface); ovsdb_idl_add_column(ovs_idl, &ovsrec_interface_col_name); ovsdb_idl_add_column(ovs_idl, &ovsrec_interface_col_external_ids); - ovsdb_idl_add_column(ovs_idl, &ovsrec_interface_col_ingress_policing_rate); - ovsdb_idl_add_column(ovs_idl, - &ovsrec_interface_col_ingress_policing_burst); + + ovsdb_idl_add_table(ovs_idl, &ovsrec_table_qos); + ovsdb_idl_add_column(ovs_idl, &ovsrec_qos_col_queues); + + ovsdb_idl_add_table(ovs_idl, &ovsrec_table_queue); + ovsdb_idl_add_column(ovs_idl, &ovsrec_queue_col_other_config); } static void @@ -71,7 +75,7 @@ get_local_iface_ids(const struct ovsrec_bridge *br_int, struct shash *lports) if (!iface_id) { continue; } - shash_add(lports, iface_id, iface_rec); + shash_add(lports, iface_id, port_rec); } } } @@ -136,14 +140,50 @@ add_local_datapath(struct hmap *local_datapaths, } static void -update_qos(const struct ovsrec_interface *iface_rec, +update_qos(struct ovsdb_idl_txn *txn, + const struct ovsrec_port *port_rec, const struct sbrec_port_binding *pb) { - int rate = smap_get_int(&pb->options, "policing_rate", 0); - int burst = smap_get_int(&pb->options, "policing_burst", 0); + int rate = smap_get_int(&pb->options, "qos_max_rate", 0); + int burst = smap_get_int(&pb->options, "qos_burst", 0); + struct smap other_config = SMAP_INITIALIZER(&other_config); + struct ovsrec_queue *default_queue; + bool is_empty_config; + + if (rate) { + smap_add_format(&other_config, "max-rate", "%d", rate); + } + if (burst) { + smap_add_format(&other_config, "burst", "%d", burst); + } - ovsrec_interface_set_ingress_policing_rate(iface_rec, MAX(0, rate)); - ovsrec_interface_set_ingress_policing_burst(iface_rec, MAX(0, burst)); + is_empty_config = smap_is_empty(&other_config); + if (port_rec->qos) { + if (is_empty_config) { + struct ovsrec_qos *qos = port_rec->qos; + struct ovsrec_queue *queue = qos->value_queues[0]; + ovsrec_port_set_qos(port_rec, NULL); + ovsrec_qos_delete(qos); + ovsrec_queue_delete(queue); + return; + } else { + default_queue = port_rec->qos->value_queues[0]; + } + } else { + if (is_empty_config) { + return; + } else { + int64_t key = 0; + struct ovsrec_qos *qos = ovsrec_qos_insert(txn); + + ovsrec_port_set_qos(port_rec, qos); + default_queue = ovsrec_queue_insert(txn); + ovsrec_qos_set_type(qos, "linux-htb"); + ovsrec_qos_set_queues(qos, &key, &default_queue, 1); + } + } + ovsrec_queue_set_other_config(default_queue, &other_config); + smap_destroy(&other_config); } void @@ -177,9 +217,9 @@ binding_run(struct controller_ctx *ctx, const struct ovsrec_bridge *br_int, * chassis and update the binding accordingly. This includes both * directly connected logical ports and children of those ports. */ SBREC_PORT_BINDING_FOR_EACH(binding_rec, ctx->ovnsb_idl) { - const struct ovsrec_interface *iface_rec + const struct ovsrec_port *port_rec = shash_find_and_delete(&lports, binding_rec->logical_port); - if (iface_rec + if (port_rec || (binding_rec->parent_port && binding_rec->parent_port[0] && sset_contains(&all_lports, binding_rec->parent_port))) { if (binding_rec->parent_port && binding_rec->parent_port[0]) { @@ -187,8 +227,8 @@ binding_run(struct controller_ctx *ctx, const struct ovsrec_bridge *br_int, sset_add(&all_lports, binding_rec->logical_port); } add_local_datapath(local_datapaths, binding_rec); - if (iface_rec && ctx->ovs_idl_txn) { - update_qos(iface_rec, binding_rec); + if (port_rec && ctx->ovs_idl_txn) { + update_qos(ctx->ovs_idl_txn, port_rec, binding_rec); } if (binding_rec->chassis == chassis_rec) { continue; diff --git a/ovn/ovn-nb.xml b/ovn/ovn-nb.xml index e65bc3a..8cca2ed 100644 --- a/ovn/ovn-nb.xml +++ b/ovn/ovn-nb.xml @@ -202,12 +202,12 @@ (empty string) </p> - <column name="options" key="policing_rate"> + <column name="options" key="qos_max_rate"> If set, indicates the maximum rate for data sent from this interface, - in kbps. Data exceeding this rate is dropped. + in kbps. The traffic will be shaped according to this limit. </column> - <column name="options" key="policing_burst"> + <column name="options" key="qos_burst"> If set, indicates the maximum burst size for data sent from this interface, in kb. </column> -- 2.5.0 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev