summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--trafgen_lexer.l4
-rw-r--r--trafgen_parser.y40
2 files changed, 42 insertions, 2 deletions
diff --git a/trafgen_lexer.l b/trafgen_lexer.l
index 324a171..025fbfe 100644
--- a/trafgen_lexer.l
+++ b/trafgen_lexer.l
@@ -118,8 +118,9 @@ ip6_addr (({a_hex}?:)?({a_hex}?:)?({a_hex}?:)?({a_hex}?:)?({a_hex}?:)?({a_hex}?:
"etype" { return K_ETYPE; }
"type" { return K_TYPE; }
- /* IEEE 802.3X PAUSE */
+ /* PFC/IEEE 802.3X PAUSE */
"time" { return K_TIME; }
+"pri"|"prio" { return K_PRIO; }
/* VLAN (802.1Q & 802.1ad) */
"tpid" { return K_TPID; }
@@ -196,6 +197,7 @@ ip6_addr (({a_hex}?:)?({a_hex}?:)?({a_hex}?:)?({a_hex}?:)?({a_hex}?:)?({a_hex}?:
"eth" { return K_ETH; }
"pause" { return K_PAUSE; }
+"pfc" { return K_PFC; }
"vlan" { return K_VLAN; }
"mpls" { return K_MPLS; }
"arp" { return K_ARP; }
diff --git a/trafgen_parser.y b/trafgen_parser.y
index 6526756..8ebf464 100644
--- a/trafgen_parser.y
+++ b/trafgen_parser.y
@@ -461,7 +461,7 @@ static void proto_field_expr_eval(void)
%token K_CPU K_CSUMIP K_CSUMUDP K_CSUMTCP K_CSUMUDP6 K_CSUMTCP6 K_CONST8 K_CONST16 K_CONST32 K_CONST64
%token K_DADDR K_SADDR K_ETYPE K_TYPE
-%token K_TIME
+%token K_TIME K_PRIO
%token K_OPER K_SHA K_SPA K_THA K_TPA K_REQUEST K_REPLY K_PTYPE K_HTYPE
%token K_PROT K_TTL K_DSCP K_ECN K_TOS K_LEN K_ID K_FLAGS K_FRAG K_IHL K_VER K_CSUM K_DF K_MF
%token K_FLOW K_NEXT_HDR K_HOP_LIMIT
@@ -475,6 +475,7 @@ static void proto_field_expr_eval(void)
%token K_ETH
%token K_PAUSE
+%token K_PFC
%token K_VLAN K_MPLS
%token K_ARP
%token K_IP4 K_IP6
@@ -702,6 +703,7 @@ ddec
proto
: eth_proto { }
| pause_proto { }
+ | pfc_proto { }
| vlan_proto { }
| mpls_proto { }
| arp_proto { }
@@ -806,6 +808,42 @@ pause_expr
{ proto_field_expr_eval(); }
;
+pfc_proto
+ : pfc '(' pfc_param_list ')' { }
+ ;
+
+pfc
+ : K_PFC { proto_add(PROTO_PFC); }
+ ;
+
+pfc_param_list
+ : { }
+ | pfc_expr { }
+ | pfc_expr delimiter pfc_param_list { }
+ ;
+
+pfc_field
+ : K_CODE { proto_field_set(PFC_OPCODE); }
+ | K_PRIO { proto_field_set(PFC_PRIO); }
+ | K_PRIO '(' number ')'
+ { if ($3 > 7) {
+ yyerror("pfc: Invalid prio(index) parameter");
+ panic("pfc: prio(0)..prio(7) is allowed only\n");
+ }
+ proto_field_set(PFC_PRIO_0 + $3); }
+ | K_TIME '(' number ')'
+ { if ($3 > 7) {
+ yyerror("pfc: Invalid time(index) parameter");
+ panic("pfc: time(0)..time(7) is allowed only\n");
+ }
+ proto_field_set(PFC_TIME_0 + $3); }
+ ;
+
+pfc_expr
+ : pfc_field skip_white '=' skip_white field_expr
+ { proto_field_expr_eval(); }
+ ;
+
vlan_proto
: vlan '(' vlan_param_list ')' { }
;