[openib-general] [PATCH 1/10] osm: QoS in OpenSM

Yevgeny Kliteynik kliteyn at dev.mellanox.co.il
Tue Jan 30 06:57:09 PST 2007


QoS policy file parser Yacc file

Signed-off-by: Yevgeny Kliteynik <kliteyn at dev.mellanox.co.il>
---
 osm/opensm/osm_qos_parser.y | 1653 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 1653 insertions(+), 0 deletions(-)

diff --git a/osm/opensm/osm_qos_parser.y b/osm/opensm/osm_qos_parser.y
new file mode 100644
index 0000000..379e8a1
--- /dev/null
+++ b/osm/opensm/osm_qos_parser.y
@@ -0,0 +1,1653 @@
+%{
+/*
+ * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ *    Grammar of OSM QoS parser.
+ *
+ * Environment:
+ *    Linux User Mode
+ *
+ * Author:
+ *    Yevgeny Kliteynik, Mellanox
+ */
+
+#include <opensm/osm_qos_parser.h>
+#include <opensm/osm_qos_parser_y.h>
+
+static void __osm_qos_parse_tree_init();
+
+static char * __osm_qos_parser_strip_white(char * str);
+
+static void __osm_qos_parser_str2uint64(uint64_t * p_val, char * str);
+
+static void __osm_qos_parser_port_group_start();
+static void __osm_qos_parser_port_group_end();
+
+static void __osm_qos_parser_sl2vl_scope_start();
+static void __osm_qos_parser_sl2vl_scope_end();
+
+static void __osm_qos_parser_vlarb_scope_start();
+static void __osm_qos_parser_vlarb_scope_end();
+
+static void __osm_qos_parser_qos_level_start();
+static void __osm_qos_parser_qos_level_end();
+
+static void __osm_qos_parser_match_rule_start();
+static void __osm_qos_parser_match_rule_end();
+
+extern char * yytext;
+extern void yyerror (char *s);
+extern int yylex (void);
+extern FILE * yyin;
+
+#define OSM_QOS_MAX_LINE_LEN 10000
+char str_buffer[OSM_QOS_MAX_LINE_LEN];
+#define RESET_BUFFER  str_buffer[0] = '\0'
+
+int column_num;
+int line_num;
+
+osm_qos_parse_tree_t   * p_qos_parse_tree = NULL;
+osm_qos_port_group_t   * p_current_port_group = NULL;
+osm_qos_sl2vl_scope_t  * p_current_sl2vl_scope = NULL;
+osm_qos_vlarb_scope_t  * p_current_vlarb_scope = NULL;
+osm_qos_level_t        * p_current_qos_level = NULL;
+osm_qos_match_rule_t   * p_current_qos_match_rule = NULL;
+
+osm_log_t * p_osm_log = NULL;
+
+/***************************************************/
+
+%}
+
+%token TK_HEX_NUMBER
+%token TK_DEC_NUMBER
+%token TK_WHITE
+%token TK_DASH
+%token TK_DOTDOT
+%token TK_COMMA
+%token TK_TEXT
+
+%token TK_XML_VERSION_START
+%token TK_XML_VERSION_END
+%token TK_QOS_POLICY_START
+%token TK_QOS_POLICY_END
+%token TK_PORT_GROUPS_START
+%token TK_PORT_GROUPS_END
+%token TK_PORT_GROUP_START
+%token TK_PORT_GROUP_END
+%token TK_NAME_START
+%token TK_NAME_END
+%token TK_USE_START
+%token TK_USE_END
+%token TK_PORT_GUID_START
+%token TK_PORT_GUID_END
+%token TK_PORT_NAME_START
+%token TK_PORT_NAME_END
+%token TK_PARTITION_START
+%token TK_PARTITION_END
+%token TK_NODE_TYPE_START
+%token TK_NODE_TYPE_END
+%token TK_QOS_SETUP_START
+%token TK_QOS_SETUP_END
+%token TK_SL2VL_TABLES_START
+%token TK_SL2VL_TABLES_END
+%token TK_SL2VL_SCOPE_START
+%token TK_SL2VL_SCOPE_END
+%token TK_GROUP_START
+%token TK_GROUP_END
+%token TK_FROM_START
+%token TK_FROM_END
+%token TK_TO_START
+%token TK_TO_END
+%token TK_SL2VL_TABLE_START
+%token TK_SL2VL_TABLE_END
+%token TK_ACROSS_START
+%token TK_ACROSS_END
+%token TK_ACROSS_FROM_START
+%token TK_ACROSS_FROM_END
+%token TK_ACROSS_TO_START
+%token TK_ACROSS_TO_END
+%token TK_VLARB_TABLES_START
+%token TK_VLARB_TABLES_END
+%token TK_VLARB_SCOPE_START
+%token TK_VLARB_SCOPE_END
+%token TK_VLARB_HIGH_START
+%token TK_VLARB_HIGH_END
+%token TK_VLARB_LOW_START
+%token TK_VLARB_LOW_END
+%token TK_VLARB_HIGH_LIMIT_START
+%token TK_VLARB_HIGH_LIMIT_END
+%token TK_QOS_LEVELS_START
+%token TK_QOS_LEVELS_END
+%token TK_QOS_LEVEL_START
+%token TK_QOS_LEVEL_END
+%token TK_SN_START
+%token TK_SN_END
+%token TK_SL_START
+%token TK_SL_END
+%token TK_CLASS_START
+%token TK_CLASS_END
+%token TK_MTU_LIMIT_START
+%token TK_MTU_LIMIT_END
+%token TK_RATE_LIMIT_START
+%token TK_RATE_LIMIT_END
+%token TK_PACKET_LIFE_START
+%token TK_PACKET_LIFE_END
+%token TK_PKEY_START
+%token TK_PKEY_END
+%token TK_QOS_MATCH_RULES_START
+%token TK_QOS_MATCH_RULES_END
+%token TK_QOS_MATCH_RULE_START
+%token TK_QOS_MATCH_RULE_END
+%token TK_QOS_LEVEL_SN_START
+%token TK_QOS_LEVEL_SN_END
+%token TK_SOURCE_START
+%token TK_SOURCE_END
+%token TK_DESTINATION_START
+%token TK_DESTINATION_END
+%token TK_SERVICE_START
+%token TK_SERVICE_END
+
+%start head
+
+%%
+
+head:               xml_version qos_policy
+                    ;
+
+xml_version:        /* empty */
+                    | TK_XML_VERSION_START any_text TK_XML_VERSION_END
+                    ;
+
+qos_policy:         /* empty */
+                    | qos_policy qos_policy_start qos_policy_entries qos_policy_end
+                    ;
+
+qos_policy_start:   TK_QOS_POLICY_START
+                    ;
+
+qos_policy_end:     TK_QOS_POLICY_END
+                    ;
+
+qos_policy_entries: /* empty */
+                    | qos_policy_entries qos_policy_entry
+                    ;
+
+qos_policy_entry:     port_groups
+                    | qos_setup
+                    | qos_levels
+                    | qos_match_rules
+                    ;
+
+    /*
+     * Parsing <port-groups> ... </port-groups>:
+     *
+     *     <port-groups>
+     *         <port-group>
+     *             <name>Storage</name>
+     *             <use>our SRP storage targets</use>
+     *             <port-guid>0x1000000000000001</port-guid>
+     *             <port-guid>0x1000000000000002</port-guid>
+     *         </port-group>
+     *         <port-group>
+     *             <name>Virtual Servers</name>
+     *             <use>node desc and IB port #</use>
+     *             <port-name>vs1/CA-1/P1</port-name>
+     *             <port-name>vs3/CA-1/P1</port-name>
+     *             <port-name>vs3/CA-2/P1</port-name>
+     *         </port-group>
+     *         <port-group>
+     *             <name>Partition 1</name>
+     *             <use>default settings</use>
+     *             <partition>Part1</partition>
+     *         </port-group>
+     *         <port-group>
+     *             <name>Routers</name>
+     *             <use>all routers</use>
+     *             <node-type>ROUTER</node-type>
+     *         </port-group>
+     *     </port-groups>
+     */
+
+port_groups:        port_groups_start port_group port_groups_end
+                    ;
+
+port_groups_start:  TK_PORT_GROUPS_START
+                    ;
+
+port_groups_end:    TK_PORT_GROUPS_END
+                    ;
+
+port_group:         single_port_group
+                    | port_group single_port_group
+                    ;
+
+single_port_group:  port_group_start port_group_entries port_group_end
+                    ;
+
+port_group_start:   TK_PORT_GROUP_START {
+                        __osm_qos_parser_port_group_start();
+                    }
+                    ;
+
+port_group_end:     TK_PORT_GROUP_END {
+                        __osm_qos_parser_port_group_end();
+                    }
+                    ;
+
+port_group_entries: /* empty */
+                    | port_group_entries port_group_entry
+                    ;
+
+port_group_entry:     name
+                    | use
+                    | port_guid
+                    | port_name
+                    | partition
+                    | node_type
+                    ;
+
+    /*
+     * Parsing <qos-setup> ... </qos-setup>:
+     *
+     *     <qos-setup>
+     *         <sl2vl-tables>
+     *             <sl2vl-scope>
+     *                 <group>Part1</group>
+     *                 <from>*</from>
+     *                 <to>*</to>
+     *                 <sl2vl-table>0,1,2,3,4,5,6,7,8,9,10,11,12,13,14</sl2vl-table>
+     *             </sl2vl-scope>
+     *             <sl2vl-scope>
+     *                 <across>Storage</across>
+     *                 <across-from>StorageXX</across-from>
+     *                 <across-to>StorageYY</across-to>
+     *                 <from>*</from>
+     *                 <to>1</to>
+     *                 <sl2vl-table>0,1,1,1,1,1,1,1,1,1,1,1,1,1,1</sl2vl-table>
+     *             </sl2vl-scope>
+     *         <sl2vl-tables>
+     *
+     *         <vlarb-tables>
+     *             <vlarb-scope>
+     *                 <group>Storage</group>
+     *                 <to>*</to>
+     *                 <vlarb-high>0:255,1:127,2:63,3:31,4:15,5:7,6:3,7:1</vlarb-high>
+     *                 <vlarb-low>8:255,9:127,10:63,11:31,12:15,13:7,14:3</vlarb-low>
+     *                 <vl-high-limit>10</vl-high-limit>
+     *             </vlarb-scope>
+     *         </vlarb-tables>
+     *    </qos-setup>
+     */
+
+qos_setup:          qos_setup_start qos_setup_items qos_setup_end
+                    ;
+
+qos_setup_start:    TK_QOS_SETUP_START
+                    ;
+
+qos_setup_end:      TK_QOS_SETUP_END
+                    ;
+
+qos_setup_items:    /* empty */
+                    | qos_setup_items sl2vl_tables
+                    | qos_setup_items vlarb_tables
+                    ;
+
+    /*
+     *         <sl2vl-tables>
+     *             <sl2vl-scope>
+     *                 ...
+     *             </sl2vl-scope>
+     *             ...
+     *         <sl2vl-tables>
+     */
+
+sl2vl_tables:       sl2vl_tables_start sl2vl_scope_items sl2vl_tables_end
+                    ;
+
+sl2vl_tables_start: TK_SL2VL_TABLES_START
+                    ;
+
+sl2vl_tables_end:   TK_SL2VL_TABLES_END
+                    ;
+
+sl2vl_scope_items:  /* empty */
+                    | sl2vl_scope_items sl2vl_scope
+                    ;
+
+sl2vl_scope:        sl2vl_scope_start sl2vl_scope_entries sl2vl_scope_end
+                    ;
+
+sl2vl_scope_start:  TK_SL2VL_SCOPE_START {
+                        __osm_qos_parser_sl2vl_scope_start();
+                    }
+                    ;
+
+sl2vl_scope_end:    TK_SL2VL_SCOPE_END {
+                        __osm_qos_parser_sl2vl_scope_end();
+                    }
+                    ;
+
+sl2vl_scope_entries:/* empty */
+                    | sl2vl_scope_entries sl2vl_scope_entry
+                    ;
+
+sl2vl_scope_entry:    group
+                    | across
+                    | across_from
+                    | across_to
+                    | from
+                    | to
+                    | sl2vl_table
+                    ;
+
+    /*
+     *         <vlarb-tables>
+     *             <vlarb-scope>
+     *                 ...
+     *             </vlarb-scope>
+     *             ...
+     *         </vlarb-tables>
+     */
+
+vlarb_tables:       vlarb_tables_start vlarb_scope_items vlarb_tables_end
+                    ;
+
+vlarb_tables_start: TK_VLARB_TABLES_START
+                    ;
+
+vlarb_tables_end:   TK_VLARB_TABLES_END
+                    ;
+
+vlarb_scope_items:  /* empty */
+                    | vlarb_scope_items vlarb_scope
+                    ;
+
+vlarb_scope:        vlarb_scope_start vlarb_scope_entries vlarb_scope_end
+                    ;
+
+vlarb_scope_start:  TK_VLARB_SCOPE_START {
+                        __osm_qos_parser_vlarb_scope_start();
+                    }
+                    ;
+
+vlarb_scope_end:    TK_VLARB_SCOPE_END {
+                        __osm_qos_parser_vlarb_scope_end();
+                    }
+                    ;
+
+vlarb_scope_entries:/* empty */
+                    | vlarb_scope_entries vlarb_scope_entry
+                    ;
+
+vlarb_scope_entry:    group
+                    | across
+                    | vlarb_high
+                    | vlarb_low
+                    | vlarb_high_limit
+                    ;
+
+    /*
+     * Parsing <qos-levels> ... </qos-levels>:
+     *
+     *     <qos-levels>
+     *         <qos-level>
+     *             <sn>1</sn>
+     *             <use>for the lowest priority comm</use>
+     *             <sl>16</sl>
+     *             <packet-life>5</packet-life>
+     *         </qos-level>
+     *         <qos-level>
+     *             <sn>2</sn>
+     *             <use>low latency best bandwidth</use>
+     *             <sl>0</sl>
+     *             <class>7</class>
+     *         </qos-level>
+     *         <qos-level>
+     *             <sn>3</sn>
+     *             <use>just an example</use>
+     *             <sl>0</sl>
+     *             <class>32</class>
+     *             <mtu-limit>1</mtl-limit>
+     *             <rate-limit>1</rate-limit>
+     *         </qos-level>
+     *     </qos-levels>
+     */
+
+qos_levels:         qos_levels_start qos_level_items qos_levels_end
+                    ;
+
+qos_levels_start:   TK_QOS_LEVELS_START
+                    ;
+
+qos_levels_end:     TK_QOS_LEVELS_END
+                    ;
+
+qos_level_items:    /* empty */
+                    | qos_level_items qos_level_start qos_level_entries qos_level_end
+                    ;
+
+qos_level_start:    TK_QOS_LEVEL_START {
+                        __osm_qos_parser_qos_level_start();
+                    }
+                    ;
+
+qos_level_end:      TK_QOS_LEVEL_END {
+                        __osm_qos_parser_qos_level_end();
+                    }
+                    ;
+
+qos_level_entries:  /* empty */
+                    | qos_level_entries qos_level_entry
+                    ;
+
+qos_level_entry:      sn
+                    | use
+                    | sl
+                    | mtu_limit
+                    | rate_limit
+                    | packet_life
+                    | pkey
+                    | qos_level_class
+                    ;
+
+    /*
+     * Parsing <qos-match-rules> ... </qos-match-rules>:
+     *
+     *
+     *    <qos-match-rules>
+     *        <qos-match-rule>
+     *            <sn>1</sn>
+     *            <use>low latency by class 7-9 or 11></use>
+     *            <class>7-9,11</class>
+     *        </qos-match-rule>
+     *        <qos-match-rule>
+     *            <sn>2</sn>
+     *            <use>Storage targets connection></use>
+     *            <destination>Storage</destination>
+     *            <service>22,4719</service>
+     *        </qos-match-rule>
+     *    </qos-match-rules>
+     */
+
+qos_match_rules:    qos_match_rules_start qos_match_rule_items qos_match_rules_end
+                    ;
+
+qos_match_rules_start: TK_QOS_MATCH_RULES_START
+                    ;
+
+qos_match_rules_end: TK_QOS_MATCH_RULES_END
+                    ;
+
+qos_match_rule_items: /* empty */
+                    | qos_match_rule_items qos_match_rule_start qos_match_rule_entries qos_match_rule_end
+                    ;
+
+qos_match_rule_start: TK_QOS_MATCH_RULE_START {
+                        __osm_qos_parser_match_rule_start();
+                    }
+                    ;
+
+qos_match_rule_end: TK_QOS_MATCH_RULE_END {
+                        __osm_qos_parser_match_rule_end();
+                    }
+                    ;
+
+qos_match_rule_entries: /* empty */
+                    | qos_match_rule_entries qos_match_rule_entry
+                    ;
+
+qos_match_rule_entry: use
+                    | match_rule_class
+                    | source
+                    | destination
+                    | service
+                    | qos_level_sn
+                    ;
+
+    /*
+     * values
+     */
+
+name:               name_start any_text TK_NAME_END {
+                        /* <name> of <port-group> - one instance */
+                        p_current_port_group->name = strdup(__osm_qos_parser_strip_white(str_buffer));
+                    }
+                    ;
+
+name_start:         TK_NAME_START {
+                        /* <name> of <port-group> - one instance */
+                        RESET_BUFFER;
+                        if (p_current_port_group->name)
+                        {
+                           yyerror("<port-group> has multiple <name> tags");
+                           return 1;
+                        }
+                    }
+                    ;
+
+use:                use_start any_text TK_USE_END {
+                        /* <use> of <port-group>,<qos-level>,<qos-match-rule> - one instance */
+                        if (p_current_port_group)
+                            p_current_port_group->use = strdup(__osm_qos_parser_strip_white(str_buffer));
+                        else if (p_current_qos_level)
+                            p_current_qos_level->use = strdup(__osm_qos_parser_strip_white(str_buffer));
+                        else if (p_current_qos_match_rule)
+                            p_current_qos_match_rule->use = strdup(__osm_qos_parser_strip_white(str_buffer));
+                        else
+                            CL_ASSERT(0);
+                    }
+                    ;
+
+use_start:          TK_USE_START {
+                        RESET_BUFFER;
+                        if (p_current_port_group)
+                        {
+                            /* <use> of <port-group> - one instance */
+                            if (p_current_port_group->use)
+                            {
+                                yyerror("<port-group> has multiple <use> tags");
+                                return 1;
+                            }
+                        }
+                        else if (p_current_qos_level)
+                        {
+                            /* <use> of <qos-level> - one instance */
+                            if (p_current_qos_level->use)
+                            {
+                                yyerror("<qos-level> has multiple <use> tags");
+                                return 1;
+                            }
+                        }
+                        else if (p_current_qos_match_rule)
+                        {
+                            /* <use> of <qos-match-rule> - one instance */
+                            if (p_current_qos_match_rule->use)
+                            {
+                                yyerror("<qos-match-rule> has multiple <use> tags");
+                                return 1;
+                            }
+                        }
+                        else
+                           CL_ASSERT(0);
+                    }
+                    ;
+
+port_name:          port_name_start any_text TK_PORT_NAME_END {
+                        /* <port-name> in <port-group> - any num of instances */
+                        osm_qos_string_vector_item_t * p_str_item =
+                            (osm_qos_string_vector_item_t *)malloc(sizeof(osm_qos_string_vector_item_t));
+
+                        p_str_item->str = strdup(__osm_qos_parser_strip_white(str_buffer));
+                        cl_ptr_vector_insert(&p_current_port_group->port_names,
+                                             p_str_item,
+                                             NULL);
+                    }
+                    ;
+
+port_name_start:    TK_PORT_NAME_START {
+                        /* <port-name> in <port-group> - any num of instances */
+                        CL_ASSERT(p_current_port_group);
+                        RESET_BUFFER;
+                    }
+                    ;
+
+port_guid:          port_guid_start hex_number TK_PORT_GUID_END {
+                        osm_qos_uint64_vector_item_t * p_uint64_item =
+                            (osm_qos_uint64_vector_item_t *)malloc(sizeof(osm_qos_uint64_vector_item_t));
+
+                        __osm_qos_parser_str2uint64(&p_uint64_item->value,
+                                                  __osm_qos_parser_strip_white(str_buffer));
+                        cl_ptr_vector_insert(&p_current_port_group->port_guids,
+                                             p_uint64_item,
+                                             NULL);
+                    }
+                    ;
+
+port_guid_start:    TK_PORT_GUID_START {
+                        /* <port-guid> in <port-group> - any num of instances */
+                        CL_ASSERT(p_current_port_group);
+                        RESET_BUFFER;
+                    }
+                    ;
+
+partition:          partition_start any_text TK_PARTITION_END {
+                        /* <partition> in <port-group> - any num of instances */
+                        osm_qos_string_vector_item_t * p_str_item =
+                            (osm_qos_string_vector_item_t *)malloc(sizeof(osm_qos_string_vector_item_t));
+
+                        p_str_item->str = strdup(__osm_qos_parser_strip_white(str_buffer));
+                        cl_ptr_vector_insert(&p_current_port_group->partitions,
+                                             p_str_item,
+                                             NULL);
+                    }
+                    ;
+
+partition_start:    TK_PARTITION_START {
+                        /* <partition> in <port-group> - any num of instances */
+                        CL_ASSERT(p_current_port_group);
+                        RESET_BUFFER;
+                    }
+                    ;
+
+node_type:          node_type_start any_text TK_NODE_TYPE_END {
+                        /* <node-type> in <port-group> - any num of instances */
+                        uint8_t tmp_node_type;
+                        char * clean_str = __osm_qos_parser_strip_white(str_buffer);
+
+                        if (strcasecmp(clean_str,OSM_QOS_NODE_TYPE_ROUTER) == 0)
+                            tmp_node_type = IB_NODE_TYPE_ROUTER;
+                        else if (strcasecmp(clean_str,OSM_QOS_NODE_TYPE_CA) == 0)
+                            tmp_node_type = IB_NODE_TYPE_CA;
+                        else if (strcasecmp(clean_str,OSM_QOS_NODE_TYPE_SWITCH) == 0)
+                            tmp_node_type = IB_NODE_TYPE_SWITCH;
+                        else
+                        {
+                            yyerror("wrong <node-type> value");
+                            return 1;
+                        }
+
+                        osm_qos_uint8_vector_item_t * p_uint8_item =
+                            (osm_qos_uint8_vector_item_t *)malloc(sizeof(osm_qos_uint8_vector_item_t));
+
+                        p_uint8_item->value = tmp_node_type;
+                        cl_ptr_vector_insert(&p_current_port_group->node_types,
+                                             p_uint8_item,
+                                             NULL);
+                    }
+                    ;
+
+node_type_start:    TK_NODE_TYPE_START {
+                        /* <node-type> in <port-group> - any num of instances */
+                        CL_ASSERT(p_current_port_group);
+                        RESET_BUFFER;
+                    }
+                    ;
+
+group:              group_start any_text TK_GROUP_END {
+                        /* <group> in <sl2vl-scope> and <vlarb-scope> - any num of instances.
+                           The <group> value refers to the <name> in <port-group> */
+                        osm_qos_string_vector_item_t * p_str_item =
+                            (osm_qos_string_vector_item_t *)malloc(sizeof(osm_qos_string_vector_item_t));
+
+                        p_str_item->str = strdup(__osm_qos_parser_strip_white(str_buffer));
+                        if (p_current_sl2vl_scope)
+                            cl_ptr_vector_insert(&p_current_sl2vl_scope->groups,
+                                                 p_str_item,
+                                                 NULL);
+                        else if (p_current_vlarb_scope)
+                            cl_ptr_vector_insert(&p_current_vlarb_scope->groups,
+                                                 p_str_item,
+                                                 NULL);
+                        else
+                            CL_ASSERT(0);
+                    }
+                    ;
+
+group_start:        TK_GROUP_START {
+                        /* <group> in <sl2vl-scope> and <vlarb-scope> - any num of instances.
+                           The <group> value refers to the <name> in <port-group> */
+                        RESET_BUFFER;
+                    }
+                    ;
+
+across:             across_start any_text TK_ACROSS_END {
+                        /* <across> in <sl2vl-scope> and <vlarb-scope> - any num of instances.
+                           The value refers to the <name> in <port-group> */
+                        osm_qos_string_vector_item_t * p_str_item =
+                            (osm_qos_string_vector_item_t *)malloc(sizeof(osm_qos_string_vector_item_t));
+                        p_str_item->str = strdup(__osm_qos_parser_strip_white(str_buffer));
+
+                        /* inserting this both to across_to and to across_from */
+                        if (p_current_sl2vl_scope) {
+                            cl_ptr_vector_insert(&p_current_sl2vl_scope->across_from,
+                                                 p_str_item,
+                                                 NULL);
+                            cl_ptr_vector_insert(&p_current_sl2vl_scope->across_to,
+                                                 p_str_item,
+                                                 NULL);
+                        }
+                        else if (p_current_vlarb_scope)
+                            cl_ptr_vector_insert(&p_current_vlarb_scope->across,
+                                                 p_str_item,
+                                                 NULL);
+                        else
+                            CL_ASSERT(0);
+                    }
+                    ;
+
+across_start:       TK_ACROSS_START {
+                        /* <across> in <sl2vl-scope> and <vlarb-scope> - any num of instances.
+                           The value refers to the <name> in <port-group> */
+                        RESET_BUFFER;
+                    }
+                    ;
+
+across_from:        across_from_start any_text TK_ACROSS_FROM_END {
+                        /* <across-from> in <sl2vl-scope> - any num of instances.
+                           The value refers to the <name> in <port-group> */
+                        osm_qos_string_vector_item_t * p_str_item =
+                            (osm_qos_string_vector_item_t *)malloc(sizeof(osm_qos_string_vector_item_t));
+
+                        p_str_item->str = strdup(__osm_qos_parser_strip_white(str_buffer));
+                        cl_ptr_vector_insert(&p_current_sl2vl_scope->across_from,
+                                             p_str_item,
+                                             NULL);
+                    }
+                    ;
+
+across_from_start:  TK_ACROSS_FROM_START {
+                        /* <across-from> in <sl2vl-scope> - any num of instances.
+                           The value refers to the <name> in <port-group> */
+                        CL_ASSERT(p_current_sl2vl_scope);
+                        RESET_BUFFER;
+                    }
+                    ;
+
+across_to:          across_to_start any_text TK_ACROSS_TO_END {
+                        /* <across-to> in <sl2vl-scope> - any num of instances.
+                           The value refers to the <name> in <port-group> */
+                        osm_qos_string_vector_item_t * p_str_item =
+                            (osm_qos_string_vector_item_t *)malloc(sizeof(osm_qos_string_vector_item_t));
+
+                        p_str_item->str = strdup(__osm_qos_parser_strip_white(str_buffer));
+                        cl_ptr_vector_insert(&p_current_sl2vl_scope->across_to,
+                                             p_str_item,
+                                             NULL);
+                    }
+                    ;
+
+across_to_start:    TK_ACROSS_TO_START {
+                        /* <across-to> in <sl2vl-scope> - any num of instances.
+                           The value refers to the <name> in <port-group> */
+                        CL_ASSERT(p_current_sl2vl_scope);
+                        RESET_BUFFER;
+                    }
+                    ;
+
+from:               from_start any_text TK_FROM_END {
+                        /* <from> in <sl2vl-scope> - any num of instances.
+                           The value refers to the <name> in <port-group> */
+                        osm_qos_string_vector_item_t * p_str_item =
+                            (osm_qos_string_vector_item_t *)malloc(sizeof(osm_qos_string_vector_item_t));
+
+                        p_str_item->str = strdup(__osm_qos_parser_strip_white(str_buffer));
+                        cl_ptr_vector_insert(&p_current_sl2vl_scope->from,
+                                             p_str_item,
+                                             NULL);
+                    }
+                    ;
+
+from_start:         TK_FROM_START {
+                        /* <from> in <sl2vl-scope> - any num of instances.
+                           The value refers to the <name> in <port-group> */
+                        CL_ASSERT(p_current_sl2vl_scope);
+                        RESET_BUFFER;
+                    }
+                    ;
+
+to:                 to_start any_text TK_TO_END {
+                        /* <to> in <sl2vl-scope> - any num of instances.
+                           The value refers to the <name> in <port-group> */
+                        osm_qos_string_vector_item_t * p_str_item =
+                            (osm_qos_string_vector_item_t *)malloc(sizeof(osm_qos_string_vector_item_t));
+
+                        p_str_item->str = strdup(__osm_qos_parser_strip_white(str_buffer));
+                        cl_ptr_vector_insert(&p_current_sl2vl_scope->to,
+                                             p_str_item,
+                                             NULL);
+                    }
+                    ;
+
+to_start:           TK_TO_START {
+                        /* <to> in <sl2vl-scope> - any num of instances.
+                           The value refers to the <name> in <port-group> */
+                        CL_ASSERT(p_current_sl2vl_scope);
+                        RESET_BUFFER;
+                    }
+                    ;
+
+sl2vl_table:        sl2vl_table_start whitespace
+                         any_number num_list_wo_whites any_number
+                              whitespace TK_SL2VL_TABLE_END {
+                        /* <sl2vl-table> in <sl2vl-scope> - one instance of 16 numbers */
+                        uint8_t counter = 0;
+                        uint8_t i;
+                        char * tok = NULL;
+                        char * tmp_str = __osm_qos_parser_strip_white(str_buffer);
+
+                        /* checking the syntax */
+                        for (i = 0; tmp_str[i] != '\0'; i++)
+                            if (tmp_str[i] == ',')
+                                counter ++;
+                        if (counter != 15)
+                        {
+                            yyerror("wrong number of values in <sl2vl-table> (should be 16)");
+                            return 1;
+                        }
+                        for (i = 1; tmp_str[i] != '\0'; i++)
+                            if ((tmp_str[i-1] == ',') && (tmp_str[i] == ','))
+                            {
+                                yyerror("wrong syntax in <sl2vl-table>");
+                                return 1;
+                            }
+
+                        /* tokenizing the line */
+                        i = 0;
+                        tok = strtok (tmp_str," ,");
+                        while (tok != NULL && i < 16)
+                        {
+                            p_current_sl2vl_scope->sl2vl_table[i++] = atoi(tok);
+                            tok = strtok (NULL, " ,");
+                        }
+                        if (tok != NULL)
+                        {
+                            yyerror("wrong syntax in <sl2vl-table>");
+                            return 1;
+                        }
+                    }
+                    ;
+
+sl2vl_table_start:  TK_SL2VL_TABLE_START {
+                        /* <sl2vl-table> in <sl2vl-scope> - one instance of 16 numbers */
+                        RESET_BUFFER;
+                    }
+                    ;
+
+sn:                 sn_start any_number TK_SN_END {
+                        /* <sn> in <qos-level> - one instance */
+                        p_current_qos_level->sn = atoi(__osm_qos_parser_strip_white(str_buffer));
+                        p_current_qos_level->sn_set = TRUE;
+                    }
+                    ;
+
+sn_start:           TK_SN_START {
+                        /* <sn> in <qos-level> - one instance */
+                        CL_ASSERT(p_current_qos_level);
+                        if (p_current_qos_level->sn_set)
+                        {
+                            yyerror("<qos-level> has multiple <sn> tags");
+                            return 1;
+                        }
+                        RESET_BUFFER;
+                    }
+                    ;
+
+sl:                 sl_start any_number TK_SL_END {
+                        /* <sl> in <qos-level> - one instance */
+                        p_current_qos_level->sl = atoi(__osm_qos_parser_strip_white(str_buffer));
+                        p_current_qos_level->sl_set = TRUE;
+                    }
+                    ;
+
+sl_start:           TK_SL_START {
+                        /* <sl> in <qos-level> - one instance */
+                        CL_ASSERT(p_current_qos_level);
+                        if (p_current_qos_level->sl_set)
+                        {
+                            yyerror("<qos-level> has multiple <sl> tags");
+                            return 1;
+                        }
+                        RESET_BUFFER;
+                    }
+                    ;
+
+mtu_limit:          mtu_limit_start any_number TK_MTU_LIMIT_END {
+                        /* <mtu-limit> in <qos-level> - one instance */
+                        p_current_qos_level->mtu_limit = atoi(__osm_qos_parser_strip_white(str_buffer));
+                        p_current_qos_level->mtu_limit_set = TRUE;
+                    }
+                    ;
+
+mtu_limit_start:    TK_MTU_LIMIT_START {
+                        /* <mtu-limit> in <qos-level> - one instance */
+                        CL_ASSERT(p_current_qos_level);
+                        if (p_current_qos_level->mtu_limit_set)
+                        {
+                            yyerror("<qos-level> has multiple <mtu-limit> tags");
+                            return 1;
+                        }
+                        RESET_BUFFER;
+                    }
+                    ;
+
+rate_limit:         rate_limit_start any_number TK_RATE_LIMIT_END {
+                        /* <rate-limit> in <qos-level> - one instance */
+                        p_current_qos_level->rate_limit = atoi(__osm_qos_parser_strip_white(str_buffer));
+                        p_current_qos_level->rate_limit_set = TRUE;
+                    }
+                    ;
+
+rate_limit_start:   TK_RATE_LIMIT_START {
+                        /* <rate-limit> in <qos-level> - one instance */
+                        CL_ASSERT(p_current_qos_level);
+                        if (p_current_qos_level->rate_limit_set)
+                        {
+                            yyerror("<qos-level> has multiple <rate-limit> tags");
+                            return 1;
+                        }
+                        RESET_BUFFER;
+                    }
+                    ;
+
+packet_life:        packet_life_start any_number TK_PACKET_LIFE_END {
+                        /* <packet-life> in <qos-level> - one instance */
+                        p_current_qos_level->pkt_life = atoi(__osm_qos_parser_strip_white(str_buffer));
+                        p_current_qos_level->pkt_life_set = TRUE;
+                    }
+                    ;
+
+packet_life_start:  TK_PACKET_LIFE_START {
+                        /* <packet-life> in <qos-level> - one instance */
+                        CL_ASSERT(p_current_qos_level);
+                        if (p_current_qos_level->pkt_life_set)
+                        {
+                            yyerror("<qos-level> has multiple <packet-life> tags");
+                            return 1;
+                        }
+                        RESET_BUFFER;
+                    }
+                    ;
+
+pkey:               pkey_start any_number TK_PKEY_END {
+                        /* <pkey> in <qos-level> - one instance */
+                        p_current_qos_level->pkey = atoi(__osm_qos_parser_strip_white(str_buffer));
+                    }
+                    ;
+
+pkey_start:         TK_PKEY_START {
+                        /* <pkey> in <qos-level> - one instance */
+                        CL_ASSERT(p_current_qos_level);
+                        RESET_BUFFER;
+                    }
+                    ;
+
+qos_level_class:    qos_level_class_start any_number TK_CLASS_END {
+                        /* <class> in <qos-level> - one instance of one number */
+                        p_current_qos_level->class = atoi(__osm_qos_parser_strip_white(str_buffer));
+                    }
+                    ;
+
+qos_level_class_start: TK_CLASS_START {
+                        /* <class> in <qos-level> - one instance of one number */
+                        CL_ASSERT(p_current_qos_level);
+                        RESET_BUFFER;
+                    }
+                    ;
+
+vlarb_high_limit:   vlarb_high_limit_start any_number TK_VLARB_HIGH_LIMIT_END {
+                        /* <vl-high-limit> in <vlarb-scope> - one instance of one number */
+                        p_current_vlarb_scope->vl_high_limit = atoi(__osm_qos_parser_strip_white(str_buffer));
+                    }
+                    ;
+
+vlarb_high_limit_start: TK_VLARB_HIGH_LIMIT_START {
+                        /* <vl-high-limit> in <vlarb-scope> - one instance of one number */
+                        CL_ASSERT(p_current_vlarb_scope);
+                        RESET_BUFFER;
+                    }
+                    ;
+
+vlarb_high:         vlarb_high_start whitespace
+                         any_number num_list_with_dotdot_wo_whites any_number
+                              whitespace TK_VLARB_HIGH_END {
+                        /* <vl-high> in <vlarb-scope> - list of pairs of numbers with ':' and ',' */
+                        uint8_t i;
+                        char * tok = NULL;
+                        char * tmp_str = __osm_qos_parser_strip_white(str_buffer);
+                        osm_qos_vlarb_hl_vector_item_t * p_hl_item = NULL;
+
+                        /* checking the syntax */
+                        for (i = 1; tmp_str[i] != '\0'; i++)
+                            if ( (tmp_str[i-1] == ',' || tmp_str[i-1] == ':') &&
+                                 (tmp_str[i]   == ',' || tmp_str[i]   == ':') )
+                            {
+                                yyerror("wrong syntax in <vl-high>");
+                                return 1;
+                            }
+
+                        /* tokenizing the line */
+                        i = 0;
+                        tok = strtok (tmp_str,":,");
+                        while (tok != NULL)
+                        {
+                            p_hl_item = (osm_qos_vlarb_hl_vector_item_t *)malloc(sizeof(osm_qos_vlarb_hl_vector_item_t));
+                            p_hl_item->sl = atoi(tok);
+                            tok = strtok (NULL, ":,");
+                            p_hl_item->credits = atoi(tok);
+                            tok = strtok (NULL, ":,");
+                            cl_ptr_vector_insert(&p_current_vlarb_scope->vlarb_highs,
+                                                 p_hl_item,
+                                                 NULL);
+                        }
+
+                    }
+                    ;
+
+vlarb_high_start:   TK_VLARB_HIGH_START {
+                        /* <vl-high> in <vlarb-scope> - list of pairs of numbers with ':' and ',' */
+                        CL_ASSERT(p_current_vlarb_scope);
+                        RESET_BUFFER;
+                    }
+                    ;
+
+vlarb_low:          vlarb_low_start whitespace
+                         any_number num_list_with_dotdot_wo_whites any_number
+                              whitespace TK_VLARB_LOW_END {
+                        /* <vl-low> in <vlarb-scope> - list of pairs of numbers with ':' and ',' */
+                        uint8_t i;
+                        char * tok = NULL;
+                        char * tmp_str = __osm_qos_parser_strip_white(str_buffer);
+                        osm_qos_vlarb_hl_vector_item_t * p_hl_item = NULL;
+
+                        /* checking the syntax */
+                        for (i = 1; tmp_str[i] != '\0'; i++)
+                            if ( (tmp_str[i-1] == ',' || tmp_str[i-1] == ':') &&
+                                 (tmp_str[i]   == ',' || tmp_str[i]   == ':') )
+                            {
+                                yyerror("wrong syntax in <vl-low>");
+                                return 1;
+                            }
+
+                        /* tokenizing the line */
+                        i = 0;
+                        tok = strtok (tmp_str,":,");
+                        while (tok != NULL)
+                        {
+                            p_hl_item = (osm_qos_vlarb_hl_vector_item_t *)malloc(sizeof(osm_qos_vlarb_hl_vector_item_t));
+                            p_hl_item->sl = atoi(tok);
+                            tok = strtok (NULL, ":,");
+                            p_hl_item->credits = atoi(tok);
+                            tok = strtok (NULL, ":,");
+                            cl_ptr_vector_insert(&p_current_vlarb_scope->vlarb_lows,
+                                                 p_hl_item,
+                                                 NULL);
+                        }
+
+                    }
+                    ;
+
+vlarb_low_start:    TK_VLARB_LOW_START {
+                        /* <vl-low> in <vlarb-scope> - list of pairs of numbers with ':' and ',' */
+                        CL_ASSERT(p_current_vlarb_scope);
+                        RESET_BUFFER;
+                    }
+                    ;
+
+source:             source_start any_text TK_SOURCE_END {
+                        /* <source> in <qos-match-rule> - text */
+                        p_current_qos_match_rule->source = strdup(__osm_qos_parser_strip_white(str_buffer));
+                    }
+                    ;
+
+source_start:       TK_SOURCE_START {
+                        /* <source> in <qos-match-rule> - text */
+                        CL_ASSERT(p_current_qos_match_rule);
+                        RESET_BUFFER;
+                    }
+                    ;
+
+destination:        destination_start any_text TK_DESTINATION_END {
+                        /* <destination> in <qos-match-rule> - text */
+                        p_current_qos_match_rule->destination = strdup(__osm_qos_parser_strip_white(str_buffer));
+                    }
+                    ;
+
+destination_start:  TK_DESTINATION_START {
+                        /* <destination> in <qos-match-rule> - text */
+                        CL_ASSERT(p_current_qos_match_rule);
+                        RESET_BUFFER;
+                    }
+                    ;
+
+match_rule_class:   match_rule_class_start whitespace
+                         any_number num_list_with_dash_wo_whites any_number
+                              whitespace TK_CLASS_END {
+                        /* <class> in <qos-match-rule> - "7-9,11" */
+                        uint16_t i;
+                        uint16_t j;
+                        uint16_t range_low;
+                        uint16_t range_high;
+                        char * dash_ptr = NULL;
+                        char * tok = NULL;
+                        char * tokens[10000] = {NULL};
+                        char * tmp_str = __osm_qos_parser_strip_white(str_buffer);
+                        osm_qos_uint16_vector_item_t * p_uint16_item = NULL;
+
+                        /* checking the syntax */
+                        for (i = 1; tmp_str[i] != '\0'; i++)
+                            if ( (tmp_str[i]   == ',' || tmp_str[i]   == '-') &&
+                                 (tmp_str[i-1] == ',' || tmp_str[i-1] == '-') )
+                            {
+                                yyerror("wrong syntax in <class>");
+                                return 1;
+                            }
+
+                        /* tokenizing the line with ',' being a delimiter */
+                        tok = strtok (tmp_str," ,");
+                        for (i = 0; tok != NULL; tok = strtok (NULL, " ,"))
+                            tokens[i++] = tok;
+
+                        for (i = 0; tokens[i] != NULL; i++)
+                        {
+                            dash_ptr = strstr(tokens[i],"-");
+                            if (dash_ptr != NULL)
+                            {
+                                /* this is number range: i-j */
+                                *dash_ptr = '\0';
+                                range_low = atoi(tokens[i]);
+                                *dash_ptr = '-';
+                                range_high = atoi(dash_ptr + 1);
+                                if (range_low > range_high)
+                                {
+                                    uint16_t tmp_num = range_low;
+                                    range_low = range_high;
+                                    range_high = tmp_num;
+                                }
+                                for (j = range_low; j <= range_high; j++)
+                                {
+                                    p_uint16_item = (osm_qos_uint16_vector_item_t *)
+                                                        malloc(sizeof(osm_qos_uint16_vector_item_t));
+                                    p_uint16_item->value = j;
+                                    cl_ptr_vector_insert(&p_current_qos_match_rule->classes,
+                                                         p_uint16_item,
+                                                         NULL);
+                                }
+                            }
+                            else
+                            {
+                                /* this is a single number */
+                                p_uint16_item = (osm_qos_uint16_vector_item_t *)
+                                                    malloc(sizeof(osm_qos_uint16_vector_item_t));
+                                p_uint16_item->value = atoi(tokens[i]);
+                                cl_ptr_vector_insert(&p_current_qos_match_rule->classes,
+                                                     p_uint16_item,
+                                                     NULL);
+                            }
+                        }
+                    }
+                    ;
+
+match_rule_class_start: TK_CLASS_START {
+                        CL_ASSERT(p_current_qos_match_rule);
+                        RESET_BUFFER;
+                    }
+                    ;
+
+service:            service_start whitespace
+                         any_number num_list_wo_whites any_number
+                              whitespace TK_SERVICE_END {
+                        /* <service> in <qos_match_rule> - list of ',' delimited numbers */
+                        uint32_t i;
+                        char * tok = NULL;
+                        char * tmp_str = __osm_qos_parser_strip_white(str_buffer);
+                        osm_qos_uint64_vector_item_t * p_uint64_item = NULL;
+
+                        /* checking the syntax */
+                        for (i = 1; tmp_str[i] != '\0'; i++)
+                            if ((tmp_str[i-1] == ',') && (tmp_str[i] == ','))
+                            {
+                                yyerror("wrong syntax in <service>");
+                                return 1;
+                            }
+
+                        /* tokenizing the line */
+                        tok = strtok (tmp_str," ,");
+                        while (tok != NULL)
+                        {
+                            p_uint64_item = (osm_qos_uint64_vector_item_t *)malloc(sizeof(osm_qos_uint64_vector_item_t));
+                            __osm_qos_parser_str2uint64(&p_uint64_item->value,tok);
+                            cl_ptr_vector_insert(&p_current_qos_match_rule->services,
+                                                 p_uint64_item,
+                                                 NULL);
+                            tok = strtok (NULL, " ,");
+                        }
+
+                    }
+                    ;
+
+service_start:      TK_SERVICE_START {
+                        /* <service> in <qos_match_rule> - list of ',' delimited numbers */
+                        CL_ASSERT(p_current_qos_match_rule);
+                        RESET_BUFFER;
+                    }
+                    ;
+
+qos_level_sn:       qos_level_sn_start any_number TK_QOS_LEVEL_SN_END {
+                        /* <qos-level-sn> in <qos-match-rule> - single number */
+                        p_current_qos_match_rule->qos_level_sn = atoi(__osm_qos_parser_strip_white(str_buffer));
+                    }
+                    ;
+
+qos_level_sn_start: TK_QOS_LEVEL_SN_START {
+                        /* <qos-level-sn> in <qos-match-rule> - single number */
+                        CL_ASSERT(p_current_qos_match_rule);
+                        RESET_BUFFER;
+                    }
+                    ;
+
+    /*
+     * Common part
+     */
+
+
+any_text:           /* empty */
+                    | any_text text
+                    ;
+
+text:                 pure_text
+                    | any_number
+                    ;
+
+pure_text:          TK_TEXT {
+                        strcat(str_buffer,$1);
+                        free($1);
+                    }
+                    | TK_WHITE {
+                        strcat(str_buffer,$1);
+                        free($1);
+                    }
+                    | TK_DASH {
+                        strcat(str_buffer,$1);
+                        free($1);
+                    }
+                    | TK_DOTDOT {
+                        strcat(str_buffer,$1);
+                        free($1);
+                    }
+                    | TK_COMMA {
+                        strcat(str_buffer,$1);
+                        free($1);
+                    }
+                    ;
+
+num_list_wo_whites:   whitespace
+                    | num_list_wo_whites whitespace
+                    | num_list_wo_whites dec_number
+                    | num_list_wo_whites hex_number
+                    | num_list_wo_whites comma
+                    ;
+
+num_list_with_dotdot_wo_whites:   whitespace
+                    | num_list_with_dotdot_wo_whites whitespace
+                    | num_list_with_dotdot_wo_whites dec_number
+                    | num_list_with_dotdot_wo_whites hex_number
+                    | num_list_with_dotdot_wo_whites comma
+                    | num_list_with_dotdot_wo_whites dotdot
+                    ;
+
+num_list_with_dash_wo_whites:   whitespace
+                    | num_list_with_dash_wo_whites whitespace
+                    | num_list_with_dash_wo_whites dec_number
+                    | num_list_with_dash_wo_whites hex_number
+                    | num_list_with_dash_wo_whites comma
+                    | num_list_with_dash_wo_whites dash
+                    ;
+
+comma:              TK_COMMA {
+                        strcat(str_buffer,$1);
+                        free($1);
+                    }
+                    ;
+
+dotdot:             TK_DOTDOT {
+                        strcat(str_buffer,$1);
+                        free($1);
+                    }
+                    ;
+
+dash:               TK_DASH {
+                        strcat(str_buffer,$1);
+                        free($1);
+                    }
+                    ;
+
+any_number:           dec_number
+                    | hex_number
+                    ;
+
+dec_number:         TK_DEC_NUMBER {
+                        strcat(str_buffer,$1);
+                        free($1);
+                    }
+                    ;
+
+hex_number:         TK_HEX_NUMBER {
+                        strcat(str_buffer,$1);
+                        free($1);
+                    }
+                    ;
+
+whitespace:         /* empty */
+                    | TK_WHITE {
+                        /* swallow whitespace */
+                        free($1);
+                    }
+                    ;
+
+%%
+
+/***************************************************
+ ***************************************************/
+
+int osm_qos_parse_policy_file(
+    IN  osm_log_t             * p_log,
+    IN  const char            * policy_file)
+{
+    int res = 0;
+    p_osm_log = p_log;
+
+    OSM_LOG_ENTER(p_osm_log, osm_qos_parse);
+
+    p_qos_parse_tree = NULL;
+    yyin = fopen (policy_file, "r");
+    if (!yyin)
+    {
+        osm_log(p_osm_log, OSM_LOG_ERROR,
+                "osm_qos_parse: ERR AC01: "
+                "Failed opening QoS policy file (%s)\n",
+                policy_file);
+        res = 1;
+        goto Exit;
+    }
+    column_num = 1;
+    line_num = 1;
+    __osm_qos_parse_tree_init();
+    str_buffer[0] = '\0';
+    
+    res = yyparse();
+    
+    if (res != 0)
+    {
+        osm_log(p_osm_log, OSM_LOG_ERROR,
+                "osm_qos_parse: ERR AC02: "
+                "Failed parsing QoS policy file (%s)\n",
+                policy_file);
+        p_qos_parse_tree = NULL;
+        res = 1;
+        goto Exit;
+    }
+
+  Exit:
+    if (yyin)
+        fclose(yyin);
+    OSM_LOG_EXIT(p_osm_log);
+    return res;
+}
+
+/***************************************************
+ ***************************************************/
+
+int yywrap()
+{
+    return(1);
+}
+
+/***************************************************
+ ***************************************************/
+
+void yyerror (char *s)
+{
+    OSM_LOG_ENTER(p_osm_log, yyerror);
+    osm_log(p_osm_log, OSM_LOG_ERROR,
+            "yyerror: ERR AC03: "
+            "Syntax error (line %d:%d): %s. "
+            "Last text read: \"%s\"\n",
+            line_num, column_num, s, __osm_qos_parser_strip_white(yytext));
+    OSM_LOG_EXIT(p_osm_log);
+}
+
+/***************************************************
+ ***************************************************/
+
+static char * __osm_qos_parser_strip_white(char * str)
+{
+   int i;
+   for (i = (strlen(str)-1); i >= 0; i--)
+   {
+      if (isspace(str[i]))
+          str[i] = '\0';
+      else
+         break;
+   }
+   for (i = 0; i < strlen(str); i++)
+   {
+      if (!isspace(str[i]))
+         break;
+   }
+   return &(str[i]);
+}
+
+/***************************************************
+ ***************************************************/
+
+static void __osm_qos_parser_str2uint64(uint64_t * p_val, char * str)
+{
+#if __WORDSIZE == 64
+   *p_val = strtoul(str, NULL, 0);
+#else
+   *p_val = strtoull(str, NULL, 0);
+#endif
+}
+
+/***************************************************
+ ***************************************************/
+
+static void __osm_qos_parse_tree_init()
+{
+   p_qos_parse_tree = (osm_qos_parse_tree_t *)
+                        malloc(sizeof(osm_qos_parse_tree_t));
+
+   memset(p_qos_parse_tree, 0, sizeof(osm_qos_parse_tree_t));
+
+   cl_ptr_vector_init(&p_qos_parse_tree->port_groups,
+                      0,  /* min size */
+                      4); /* grow size */
+   cl_ptr_vector_init(&p_qos_parse_tree->sl2vl_tables,
+                      0,  /* min size */
+                      4); /* grow size */
+   cl_ptr_vector_init(&p_qos_parse_tree->vlarb_tables,
+                      0,  /* min size */
+                      4); /* grow size */
+   cl_ptr_vector_init(&p_qos_parse_tree->qos_levels,
+                      0,  /* min size */
+                      4); /* grow size */
+   cl_ptr_vector_init(&p_qos_parse_tree->qos_match_rules,
+                      0,  /* min size */
+                      4); /* grow size */
+}
+
+/***************************************************
+ ***************************************************/
+
+static void __osm_qos_parser_port_group_start()
+{
+   p_current_port_group = (osm_qos_port_group_t *)
+                                malloc(sizeof(osm_qos_port_group_t));
+   memset(p_current_port_group, 0, sizeof(osm_qos_port_group_t));
+
+   cl_ptr_vector_init(&p_current_port_group->port_guids,
+                      0,  /* min size */
+                      4); /* grow size */
+   cl_ptr_vector_init(&p_current_port_group->port_names,
+                      0,  /* min size */
+                      4); /* grow size */
+   cl_ptr_vector_init(&p_current_port_group->partitions,
+                      0,  /* min size */
+                      4); /* grow size */
+   cl_ptr_vector_init(&p_current_port_group->node_types,
+                      0,  /* min size */
+                      4); /* grow size */
+}
+
+/***************************************************
+ ***************************************************/
+
+static void __osm_qos_parser_port_group_end()
+{
+   cl_ptr_vector_insert(&p_qos_parse_tree->port_groups,
+                        p_current_port_group,
+                        NULL);
+   p_current_port_group = NULL;
+}
+
+/***************************************************
+ ***************************************************/
+
+static void __osm_qos_parser_sl2vl_scope_start()
+{
+    p_current_sl2vl_scope = (osm_qos_sl2vl_scope_t *)
+                                malloc(sizeof(osm_qos_sl2vl_scope_t));
+    memset(p_current_sl2vl_scope, 0, sizeof(osm_qos_sl2vl_scope_t));
+
+    cl_ptr_vector_init(&p_current_sl2vl_scope->groups,
+                       0,  /* min size */
+                       4); /* grow size */
+    cl_ptr_vector_init(&p_current_sl2vl_scope->from,
+                       0,  /* min size */
+                       4); /* grow size */
+    cl_ptr_vector_init(&p_current_sl2vl_scope->to,
+                       0,  /* min size */
+                       4); /* grow size */
+    cl_ptr_vector_init(&p_current_sl2vl_scope->across_from,
+                       0,  /* min size */
+                       4); /* grow size */
+    cl_ptr_vector_init(&p_current_sl2vl_scope->across_to,
+                       0,  /* min size */
+                       4); /* grow size */
+}
+
+/***************************************************
+ ***************************************************/
+
+static void __osm_qos_parser_sl2vl_scope_end()
+{
+    cl_ptr_vector_insert(&p_qos_parse_tree->sl2vl_tables,
+                         p_current_sl2vl_scope,
+                         NULL);
+    p_current_sl2vl_scope = NULL;
+}
+
+/***************************************************
+ ***************************************************/
+
+static void __osm_qos_parser_vlarb_scope_start()
+{
+    p_current_vlarb_scope = (osm_qos_vlarb_scope_t *)
+                                malloc(sizeof(osm_qos_vlarb_scope_t));
+    memset(p_current_vlarb_scope, 0, sizeof(osm_qos_vlarb_scope_t));
+
+    cl_ptr_vector_init(&p_current_vlarb_scope->groups,
+                       0,  /* min size */
+                       4); /* grow size */
+    cl_ptr_vector_init(&p_current_vlarb_scope->across,
+                       0,  /* min size */
+                       4); /* grow size */
+    cl_ptr_vector_init(&p_current_vlarb_scope->vlarb_highs,
+                       0,  /* min size */
+                       4); /* grow size */
+    cl_ptr_vector_init(&p_current_vlarb_scope->vlarb_lows,
+                       0,  /* min size */
+                       4); /* grow size */
+}
+
+/***************************************************
+ ***************************************************/
+
+static void __osm_qos_parser_vlarb_scope_end()
+{
+    cl_ptr_vector_insert(&p_qos_parse_tree->vlarb_tables,
+                         p_current_vlarb_scope,
+                         NULL);
+    p_current_vlarb_scope = NULL;
+}
+
+
+/***************************************************
+ ***************************************************/
+
+static void __osm_qos_parser_qos_level_start()
+{
+   p_current_qos_level = (osm_qos_level_t *)
+                            malloc(sizeof(osm_qos_level_t));
+   memset(p_current_qos_level, 0, sizeof(osm_qos_level_t));
+}
+
+/***************************************************
+ ***************************************************/
+
+static void __osm_qos_parser_qos_level_end()
+{
+   cl_ptr_vector_insert(&p_qos_parse_tree->qos_levels,
+                        p_current_qos_level,
+                        NULL);
+   p_current_qos_level = NULL;
+}
+
+/***************************************************
+ ***************************************************/
+
+static void __osm_qos_parser_match_rule_start()
+{
+   p_current_qos_match_rule = (osm_qos_match_rule_t *)
+                                    malloc(sizeof(osm_qos_match_rule_t));
+   memset(p_current_qos_match_rule, 0, sizeof(osm_qos_match_rule_t));
+
+   cl_ptr_vector_init(&p_current_qos_match_rule->services,
+                      0,  /* min size */
+                      4); /* grow size */
+   cl_ptr_vector_init(&p_current_qos_match_rule->classes,
+                      0,  /* min size */
+                      4); /* grow size */
+}
+
+/***************************************************
+ ***************************************************/
+
+static void __osm_qos_parser_match_rule_end()
+{
+   cl_ptr_vector_insert(&p_qos_parse_tree->qos_match_rules,
+                        p_current_qos_match_rule,
+                        NULL);
+   p_current_qos_match_rule = NULL;
+}
+
+/***************************************************
+ ***************************************************/
+
-- 
1.4.4.1.GIT






More information about the general mailing list