@@ -96,31 +96,33 @@ enum ovn_datapath_type {
9696 * form the stage's full name, e.g. S_SWITCH_IN_PORT_SEC_L2,
9797 * S_ROUTER_OUT_DELIVERY. */
9898enum ovn_stage {
99- #define PIPELINE_STAGES \
100- /* Logical switch ingress stages. */ \
101- PIPELINE_STAGE (SWITCH , IN , PORT_SEC_L2 , 0 , "ls_in_port_sec_l2 ") \
102- PIPELINE_STAGE (SWITCH , IN , PORT_SEC_IP , 1 , "ls_in_port_sec_ip ") \
103- PIPELINE_STAGE (SWITCH , IN , PORT_SEC_ND , 2 , "ls_in_port_sec_nd ") \
104- PIPELINE_STAGE (SWITCH , IN , PRE_ACL , 3 , "ls_in_pre_acl ") \
105- PIPELINE_STAGE (SWITCH , IN , PRE_LB , 4 , "ls_in_pre_lb ") \
106- PIPELINE_STAGE (SWITCH , IN , PRE_STATEFUL , 5 , "ls_in_pre_stateful ") \
107- PIPELINE_STAGE (SWITCH , IN , ACL , 6 , "ls_in_acl ") \
108- PIPELINE_STAGE (SWITCH , IN , LB , 7 , "ls_in_lb ") \
109- PIPELINE_STAGE (SWITCH , IN , STATEFUL , 8 , "ls_in_stateful ") \
110- PIPELINE_STAGE (SWITCH , IN , ARP_ND_RSP , 9 , "ls_in_arp_rsp ") \
111- PIPELINE_STAGE (SWITCH , IN , DHCP_OPTIONS , 10 , "ls_in_dhcp_options ") \
112- PIPELINE_STAGE (SWITCH , IN , DHCP_RESPONSE , 11 , "ls_in_dhcp_response ") \
113- PIPELINE_STAGE (SWITCH , IN , L2_LKUP , 12 , "ls_in_l2_lkup ") \
99+ #define PIPELINE_STAGES \
100+ /* Logical switch ingress stages. */ \
101+ PIPELINE_STAGE (SWITCH , IN , PORT_SEC_L2 , 0 , "ls_in_port_sec_l2 ") \
102+ PIPELINE_STAGE (SWITCH , IN , PORT_SEC_IP , 1 , "ls_in_port_sec_ip ") \
103+ PIPELINE_STAGE (SWITCH , IN , PORT_SEC_ND , 2 , "ls_in_port_sec_nd ") \
104+ PIPELINE_STAGE (SWITCH , IN , PRE_ACL , 3 , "ls_in_pre_acl ") \
105+ PIPELINE_STAGE (SWITCH , IN , PRE_LB , 4 , "ls_in_pre_lb ") \
106+ PIPELINE_STAGE (SWITCH , IN , PRE_STATEFUL , 5 , "ls_in_pre_stateful ") \
107+ PIPELINE_STAGE (SWITCH , IN , ACL , 6 , "ls_in_acl ") \
108+ PIPELINE_STAGE (SWITCH , IN , QOS_MARK , 7 , "ls_in_qos_mark ") \
109+ PIPELINE_STAGE (SWITCH , IN , LB , 8 , "ls_in_lb ") \
110+ PIPELINE_STAGE (SWITCH , IN , STATEFUL , 9 , "ls_in_stateful ") \
111+ PIPELINE_STAGE (SWITCH , IN , ARP_ND_RSP , 10 , "ls_in_arp_rsp ") \
112+ PIPELINE_STAGE (SWITCH , IN , DHCP_OPTIONS , 11 , "ls_in_dhcp_options ") \
113+ PIPELINE_STAGE (SWITCH , IN , DHCP_RESPONSE , 12 , "ls_in_dhcp_response ") \
114+ PIPELINE_STAGE (SWITCH , IN , L2_LKUP , 13 , "ls_in_l2_lkup ") \
114115 \
115116 /* Logical switch egress stages. */ \
116117 PIPELINE_STAGE (SWITCH , OUT , PRE_LB , 0 , "ls_out_pre_lb ") \
117118 PIPELINE_STAGE (SWITCH , OUT , PRE_ACL , 1 , "ls_out_pre_acl ") \
118119 PIPELINE_STAGE (SWITCH , OUT , PRE_STATEFUL , 2 , "ls_out_pre_stateful ") \
119120 PIPELINE_STAGE (SWITCH , OUT , LB , 3 , "ls_out_lb ") \
120121 PIPELINE_STAGE (SWITCH , OUT , ACL , 4 , "ls_out_acl ") \
121- PIPELINE_STAGE (SWITCH , OUT , STATEFUL , 5 , "ls_out_stateful ") \
122- PIPELINE_STAGE (SWITCH , OUT , PORT_SEC_IP , 6 , "ls_out_port_sec_ip ") \
123- PIPELINE_STAGE (SWITCH , OUT , PORT_SEC_L2 , 7 , "ls_out_port_sec_l2 ") \
122+ PIPELINE_STAGE (SWITCH , OUT , QOS_MARK , 5 , "ls_out_qos_mark ") \
123+ PIPELINE_STAGE (SWITCH , OUT , STATEFUL , 6 , "ls_out_stateful ") \
124+ PIPELINE_STAGE (SWITCH , OUT , PORT_SEC_IP , 7 , "ls_out_port_sec_ip ") \
125+ PIPELINE_STAGE (SWITCH , OUT , PORT_SEC_L2 , 8 , "ls_out_port_sec_l2 ") \
124126 \
125127 /* Logical router ingress stages. */ \
126128 PIPELINE_STAGE (ROUTER , IN , ADMISSION , 0 , "lr_in_admission ") \
@@ -2610,6 +2612,29 @@ build_acls(struct ovn_datapath *od, struct hmap *lflows)
26102612 }
26112613}
26122614
2615+ static void
2616+ build_qos (struct ovn_datapath * od , struct hmap * lflows ) {
2617+ ovn_lflow_add (lflows , od , S_SWITCH_IN_QOS_MARK , 0 , "1" , "next;" );
2618+ ovn_lflow_add (lflows , od , S_SWITCH_OUT_QOS_MARK , 0 , "1" , "next;" );
2619+
2620+ for (size_t i = 0 ; i < od -> nbs -> n_qos_rules ; i ++ ) {
2621+ struct nbrec_qos * qos = od -> nbs -> qos_rules [i ];
2622+ bool ingress = !strcmp (qos -> direction , "from-lport" ) ? true :false;
2623+ enum ovn_stage stage = ingress ? S_SWITCH_IN_QOS_MARK : S_SWITCH_OUT_QOS_MARK ;
2624+
2625+ if (!strcmp (qos -> key_action , "dscp" )) {
2626+ struct ds dscp_action = DS_EMPTY_INITIALIZER ;
2627+
2628+ ds_put_format (& dscp_action , "ip.dscp = %d; next;" ,
2629+ (uint8_t )qos -> value_action );
2630+ ovn_lflow_add (lflows , od , stage ,
2631+ qos -> priority ,
2632+ qos -> match , ds_cstr (& dscp_action ));
2633+ ds_destroy (& dscp_action );
2634+ }
2635+ }
2636+ }
2637+
26132638static void
26142639build_lb (struct ovn_datapath * od , struct hmap * lflows )
26152640{
@@ -2715,7 +2740,7 @@ build_lswitch_flows(struct hmap *datapaths, struct hmap *ports,
27152740 struct ds actions = DS_EMPTY_INITIALIZER ;
27162741
27172742 /* Build pre-ACL and ACL tables for both ingress and egress.
2718- * Ingress tables 3 and 4 . Egress tables 0 and 1 . */
2743+ * Ingress tables 3 through 9 . Egress tables 0 through 6 . */
27192744 struct ovn_datapath * od ;
27202745 HMAP_FOR_EACH (od , key_node , datapaths ) {
27212746 if (!od -> nbs ) {
@@ -2726,6 +2751,7 @@ build_lswitch_flows(struct hmap *datapaths, struct hmap *ports,
27262751 build_pre_lb (od , lflows );
27272752 build_pre_stateful (od , lflows );
27282753 build_acls (od , lflows );
2754+ build_qos (od , lflows );
27292755 build_lb (od , lflows );
27302756 build_stateful (od , lflows );
27312757 }
@@ -2797,7 +2823,7 @@ build_lswitch_flows(struct hmap *datapaths, struct hmap *ports,
27972823 ovn_lflow_add (lflows , od , S_SWITCH_IN_PORT_SEC_IP , 0 , "1" , "next;" );
27982824 }
27992825
2800- /* Ingress table 9 : ARP/ND responder, skip requests coming from localnet
2826+ /* Ingress table 10 : ARP/ND responder, skip requests coming from localnet
28012827 * ports. (priority 100). */
28022828 HMAP_FOR_EACH (op , key_node , ports ) {
28032829 if (!op -> nbsp ) {
@@ -2812,7 +2838,7 @@ build_lswitch_flows(struct hmap *datapaths, struct hmap *ports,
28122838 }
28132839 }
28142840
2815- /* Ingress table 9 : ARP/ND responder, reply for known IPs.
2841+ /* Ingress table 10 : ARP/ND responder, reply for known IPs.
28162842 * (priority 50). */
28172843 HMAP_FOR_EACH (op , key_node , ports ) {
28182844 if (!op -> nbsp ) {
@@ -2905,7 +2931,7 @@ build_lswitch_flows(struct hmap *datapaths, struct hmap *ports,
29052931 }
29062932 }
29072933
2908- /* Ingress table 9 : ARP/ND responder, by default goto next.
2934+ /* Ingress table 10 : ARP/ND responder, by default goto next.
29092935 * (priority 0)*/
29102936 HMAP_FOR_EACH (od , key_node , datapaths ) {
29112937 if (!od -> nbs ) {
@@ -2915,7 +2941,7 @@ build_lswitch_flows(struct hmap *datapaths, struct hmap *ports,
29152941 ovn_lflow_add (lflows , od , S_SWITCH_IN_ARP_ND_RSP , 0 , "1" , "next;" );
29162942 }
29172943
2918- /* Logical switch ingress table 10 and 11 : DHCP options and response
2944+ /* Logical switch ingress table 11 and 12 : DHCP options and response
29192945 * priority 100 flows. */
29202946 HMAP_FOR_EACH (op , key_node , ports ) {
29212947 if (!op -> nbsp ) {
@@ -2994,7 +3020,7 @@ build_lswitch_flows(struct hmap *datapaths, struct hmap *ports,
29943020 }
29953021 }
29963022
2997- /* Ingress table 10 and 11 : DHCP options and response, by default goto next.
3023+ /* Ingress table 11 and 12 : DHCP options and response, by default goto next.
29983024 * (priority 0). */
29993025
30003026 HMAP_FOR_EACH (od , key_node , datapaths ) {
@@ -3006,7 +3032,7 @@ build_lswitch_flows(struct hmap *datapaths, struct hmap *ports,
30063032 ovn_lflow_add (lflows , od , S_SWITCH_IN_DHCP_RESPONSE , 0 , "1" , "next;" );
30073033 }
30083034
3009- /* Ingress table 12 : Destination lookup, broadcast and multicast handling
3035+ /* Ingress table 13 : Destination lookup, broadcast and multicast handling
30103036 * (priority 100). */
30113037 HMAP_FOR_EACH (op , key_node , ports ) {
30123038 if (!op -> nbsp ) {
@@ -3026,7 +3052,7 @@ build_lswitch_flows(struct hmap *datapaths, struct hmap *ports,
30263052 "outport = \"" MC_FLOOD "\"; output;" );
30273053 }
30283054
3029- /* Ingress table 12 : Destination lookup, unicast handling (priority 50), */
3055+ /* Ingress table 13 : Destination lookup, unicast handling (priority 50), */
30303056 HMAP_FOR_EACH (op , key_node , ports ) {
30313057 if (!op -> nbsp ) {
30323058 continue ;
@@ -3073,7 +3099,7 @@ build_lswitch_flows(struct hmap *datapaths, struct hmap *ports,
30733099 }
30743100 }
30753101
3076- /* Ingress table 12 : Destination lookup for unknown MACs (priority 0). */
3102+ /* Ingress table 13 : Destination lookup for unknown MACs (priority 0). */
30773103 HMAP_FOR_EACH (od , key_node , datapaths ) {
30783104 if (!od -> nbs ) {
30793105 continue ;
0 commit comments