@@ -724,6 +724,17 @@ def get_vif_port_by_id(self, port_id):
724
724
LOG .info ("Port %(port_id)s not present in bridge %(br_name)s" ,
725
725
{'port_id' : port_id , 'br_name' : self .br_name })
726
726
727
+ def get_bridge_patch_ports_ofports (self ):
728
+ ports = self .ovsdb .db_find (
729
+ 'Interface' , ('type' , '=' , 'patch' ),
730
+ columns = ['name' , 'ofport' ]).execute ()
731
+ patch_ports = []
732
+ for port in ports :
733
+ if self .br_name != self .get_bridge_for_iface (port ['name' ]):
734
+ continue
735
+ patch_ports .append (port ['ofport' ])
736
+ return patch_ports
737
+
727
738
def delete_ports (self , all_ports = False ):
728
739
if all_ports :
729
740
port_names = self .get_port_name_list ()
@@ -800,6 +811,23 @@ def _update_bw_limit_profile_dpdk(self, txn, port_name, qos_uuid,
800
811
other_config = other_config ))
801
812
return qos_uuid
802
813
814
+ def set_queue_for_ingress_bandwidth_limit (self ):
815
+ # reg3 is used to memoize if queue was set or not. If it is first visit
816
+ # to table 0 for a packet (i.e. reg3 == 0), set queue and memoize (i.e.
817
+ # load 1 to reg3), then goto table 0 again. The packet will be handled
818
+ # as usual when the second visit to table 0.
819
+ # For min bw reg4 is used for the same purpose. In case if there we
820
+ # would need one of those registries for something else in the future
821
+ # we can try to use same reg4 for both OF rules, this one and the one
822
+ # which sets pkt_mark for minimum bandwidth and play with bitmask
823
+ self .add_flow (
824
+ table = constants .LOCAL_SWITCHING ,
825
+ reg3 = 0 ,
826
+ priority = 200 ,
827
+ actions = ("set_queue:%s,load:1->NXM_NX_REG3[0],"
828
+ "resubmit(,%s)" % (QOS_DEFAULT_QUEUE ,
829
+ constants .LOCAL_SWITCHING )))
830
+
803
831
def _update_ingress_bw_limit_for_port (
804
832
self , port_name , max_kbps , max_burst_kbps ):
805
833
queue_id = self ._update_queue (
@@ -926,7 +954,7 @@ def get_egress_min_bw_for_port(self, port_id):
926
954
min_bps = queue ['other_config' ].get ('min-rate' )
927
955
return int (int (min_bps ) / 1000 ) if min_bps else None
928
956
929
- def _set_queue_for_minimum_bandwidth (self , queue_num ):
957
+ def _set_pkt_mark_for_minimum_bandwidth (self , queue_num ):
930
958
# reg4 is used to memoize if queue was set or not. If it is first visit
931
959
# to table 0 for a packet (i.e. reg4 == 0), set queue and memoize (i.e.
932
960
# load 1 to reg4), then goto table 0 again. The packet will be handled
@@ -936,10 +964,26 @@ def _set_queue_for_minimum_bandwidth(self, queue_num):
936
964
in_port = queue_num ,
937
965
reg4 = 0 ,
938
966
priority = 200 ,
939
- actions = ("set_queue :%s,load:1->NXM_NX_REG4[0],"
967
+ actions = ("set_field :%s->pkt_mark ,load:1->NXM_NX_REG4[0],"
940
968
"resubmit(,%s)" % (queue_num , constants .LOCAL_SWITCHING )))
941
969
942
- def _unset_queue_for_minimum_bandwidth (self , queue_num ):
970
+ def set_queue_for_minimum_bandwidth (self , queue_num ):
971
+ # reg4 is used to memoize if queue was set or not. If it is first visit
972
+ # to table 0 for a packet (i.e. reg4 == 0), set queue and memoize (i.e.
973
+ # load 1 to reg4), then goto table 0 again. The packet will be handled
974
+ # as usual when the second visit to table 0.
975
+ patch_ports = self .get_bridge_patch_ports_ofports ()
976
+ for patch_port in patch_ports :
977
+ self .add_flow (
978
+ table = 0 ,
979
+ in_port = patch_port ,
980
+ pkt_mark = queue_num ,
981
+ reg4 = 0 ,
982
+ priority = 200 ,
983
+ actions = ("set_queue:%s,load:1->NXM_NX_REG4[0],"
984
+ "resubmit(,0)" % queue_num ))
985
+
986
+ def _unset_pkt_mark_for_minimum_bandwidth (self , queue_num ):
943
987
self .delete_flows (
944
988
table = constants .LOCAL_SWITCHING ,
945
989
in_port = queue_num ,
@@ -964,26 +1008,31 @@ def update_minimum_bandwidth_queue(self, port_id, egress_port_names,
964
1008
qos_id = qos_id , queues = qos_queues )
965
1009
for egress_port_name in egress_port_names :
966
1010
self ._set_port_qos (egress_port_name , qos_id = qos_id )
967
- self ._set_queue_for_minimum_bandwidth (queue_num )
1011
+ self ._set_pkt_mark_for_minimum_bandwidth (queue_num )
968
1012
return qos_id
969
1013
970
1014
def delete_minimum_bandwidth_queue (self , port_id ):
971
1015
queue = self ._find_queue (port_id )
972
1016
if not queue :
973
1017
return
974
1018
queue_num = int (queue ['external_ids' ]['queue-num' ])
975
- self ._unset_queue_for_minimum_bandwidth (queue_num )
1019
+ self ._unset_pkt_mark_for_minimum_bandwidth (queue_num )
976
1020
qos_id , qos_queues = self ._find_qos (
977
1021
self ._min_bw_qos_id ,
978
1022
qos_constants .RULE_TYPE_MINIMUM_BANDWIDTH )
979
1023
if not qos_queues :
980
1024
return
981
1025
if queue_num in qos_queues .keys ():
982
1026
qos_queues .pop (queue_num )
983
- self ._update_qos (
984
- self ._min_bw_qos_id ,
985
- qos_constants .RULE_TYPE_MINIMUM_BANDWIDTH ,
986
- qos_id = qos_id , queues = qos_queues )
1027
+ if qos_queues :
1028
+ self ._update_qos (
1029
+ self ._min_bw_qos_id ,
1030
+ qos_constants .RULE_TYPE_MINIMUM_BANDWIDTH ,
1031
+ qos_id = qos_id , queues = qos_queues )
1032
+ self .ovsdb .db_clear ('Port' , port_id , 'qos' ).execute (
1033
+ check_error = False )
1034
+ if not qos_queues :
1035
+ self ._delete_qos (qos_id )
987
1036
self ._delete_queue (
988
1037
queue ['_uuid' ], qos_constants .RULE_TYPE_MINIMUM_BANDWIDTH )
989
1038
0 commit comments