[openib-general] [PATCH 3/6] osm: QoS parser grammar (Yacc) file

Yevgeny Kliteynik kliteyn at dev.mellanox.co.il
Wed Jan 17 07:12:42 PST 2007


Hi Hal.

This patch is QoS parser grammar (Yacc) file

Signed-off-by: Yevgeny Kliteynik <kliteyn at dev.mellanox.co.il>
---
 osm/opensm/osm_qos_parser.y | 1822 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 1822 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..ba1e374
--- /dev/null
+++ b/osm/opensm/osm_qos_parser.y
@@ -0,0 +1,1822 @@
+%{
+/*
+ * 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_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/HCA-1/P1</port-name>
+     *             <port-name>vs3/HCA-1/P1</port-name>
+     *             <port-name>vs3/HCA-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>
+     *         </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
+                    | qos_level_class
+                    | mtu_limit
+                    | rate_limit
+                    ;
+
+    /*
+     * 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>
+     *            <match-level>1</match-level>
+     *        </qos-match-rule>
+     *        <qos-match-rule>
+     *            <sn>2</sn>
+     *            <use>Storage targets connection></use>
+     *            <destination>Storage</destination>
+     *            <service>22,4719</service>
+     *            <match-level>3</match-level>
+     *        </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_uint32_vector_item_t * p_uint32_item =
+                            (osm_qos_uint32_vector_item_t *)malloc(sizeof(osm_qos_uint32_vector_item_t));
+
+                        p_uint32_item->value = tmp_node_type;
+                        cl_ptr_vector_insert(&p_current_port_group->node_types,
+                                             p_uint32_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));
+                    }
+                    ;
+
+sn_start:           TK_SN_START {
+                        /* <sn> in <qos-level> - one instance */
+                        CL_ASSERT(p_current_qos_level);
+                        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));
+                    }
+                    ;
+
+sl_start:           TK_SL_START {
+                        /* <sl> in <qos-level> - one instance */
+                        CL_ASSERT(p_current_qos_level);
+                        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));
+                    }
+                    ;
+
+mtu_limit_start:    TK_MTU_LIMIT_START {
+                        /* <mtu-limit> in <qos-level> - one instance */
+                        CL_ASSERT(p_current_qos_level);
+                        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));
+                    }
+                    ;
+
+rate_limit_start:   TK_RATE_LIMIT_START {
+                        /* <rate-limit> 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" */
+                        uint32_t i;
+                        uint32_t j;
+                        uint32_t range_low;
+                        uint32_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_uint32_vector_item_t * p_uint32_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)
+                                {
+                                    uint32_t tmp_num = range_low;
+                                    range_low = range_high;
+                                    range_high = tmp_num;
+                                }
+                                for (j = range_low; j <= range_high; j++)
+                                {
+                                    p_uint32_item = (osm_qos_uint32_vector_item_t *)
+                                                        malloc(sizeof(osm_qos_uint32_vector_item_t));
+                                    p_uint32_item->value = j;
+                                    cl_ptr_vector_insert(&p_current_qos_match_rule->classes,
+                                                         p_uint32_item,
+                                                         NULL);
+                                }
+                            }
+                            else
+                            {
+                                /* this is a single number */
+                                p_uint32_item = (osm_qos_uint32_vector_item_t *)
+                                                    malloc(sizeof(osm_qos_uint32_vector_item_t));
+                                p_uint32_item->value = atoi(tokens[i]);
+                                cl_ptr_vector_insert(&p_current_qos_match_rule->classes,
+                                                     p_uint32_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_uint32_vector_item_t * p_uint32_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_uint32_item = (osm_qos_uint32_vector_item_t *)malloc(sizeof(osm_qos_uint32_vector_item_t));
+                            p_uint32_item->value = atoi(tok);
+                            cl_ptr_vector_insert(&p_current_qos_match_rule->services,
+                                                 p_uint32_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 */
+
+                        osm_qos_uint32_vector_item_t * p_uint32_item =
+                            (osm_qos_uint32_vector_item_t *)malloc(sizeof(osm_qos_uint32_vector_item_t));
+
+                        p_uint32_item->value = atoi(__osm_qos_parser_strip_white(str_buffer));
+                        cl_ptr_vector_insert(&p_current_qos_match_rule->qos_level_sns,
+                                             p_uint32_item,
+                                             NULL);
+                    }
+                    ;
+
+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,
+    OUT osm_qos_parse_tree_t ** pp_qos_parse_tree)
+{
+    int res = 0;
+    p_osm_log = p_log;
+
+    //~ OSM_LOG_ENTER(p_osm_log, osm_qos_parse);
+
+    *pp_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);
+        printf( "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)
+    {
+        *pp_qos_parse_tree = p_qos_parse_tree;
+    }
+    else
+    {
+        //~ osm_log(p_osm_log, OSM_LOG_ERROR,
+                //~ "osm_qos_parse: ERR AC02: "
+                //~ "Failed parsing QoS policy file (%s)\n",
+                //~ policy_file);
+        printf( "osm_qos_parse: ERR AC02: "
+                "Failed parsing QoS policy file (%s)\n",
+                policy_file);
+        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));
+    printf( "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->qos_level_sns,
+                      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;
+}
+
+/***************************************************
+ ***************************************************/
+
+/* free all the memory occupied by the parse tree data structure */
+void osm_qos_parser_destroy_parse_tree(
+    IN  osm_qos_parse_tree_t * p_qos_parse_tree)
+{
+    uint32_t i;
+    uint32_t j;
+
+    osm_qos_port_group_t   * p_port_group = NULL;
+    osm_qos_sl2vl_scope_t  * p_sl2vl_scope = NULL;
+    osm_qos_vlarb_scope_t  * p_vlarb_scope = NULL;
+    osm_qos_level_t        * p_qos_level = NULL;
+    osm_qos_match_rule_t   * p_qos_match_rule = NULL;
+
+    osm_qos_string_vector_item_t   * p_str_vector_item = NULL;
+    osm_qos_uint64_vector_item_t   * p_uint64_vector_item = NULL;
+    osm_qos_uint32_vector_item_t   * p_uint32_vector_item = NULL;
+    osm_qos_vlarb_hl_vector_item_t * p_vlarb_hl_vector_item = NULL;
+
+    for (i = 0; i < cl_ptr_vector_get_size(&p_qos_parse_tree->port_groups); i++)
+    {
+        cl_ptr_vector_at(&p_qos_parse_tree->port_groups, i, (void **)&p_port_group);
+
+        if (p_port_group->name)
+            free(p_port_group->name);
+        if (p_port_group->use)
+            free(p_port_group->use);
+
+        for (j = 0; j < cl_ptr_vector_get_size(&p_port_group->port_guids); j++)
+        {
+            cl_ptr_vector_at(&p_port_group->port_guids, j, (void **)&p_uint64_vector_item);
+            free(p_uint64_vector_item);
+        }
+        cl_ptr_vector_destroy(&p_port_group->port_guids);
+
+        for (j = 0; j < cl_ptr_vector_get_size(&p_port_group->port_names); j++)
+        {
+            cl_ptr_vector_at(&p_port_group->port_names, j, (void **)&p_str_vector_item);
+            if (p_str_vector_item->str)
+                free(p_str_vector_item->str);
+            free(p_str_vector_item);
+        }
+        cl_ptr_vector_destroy(&p_port_group->port_names);
+
+        for (j = 0; j < cl_ptr_vector_get_size(&p_port_group->partitions); j++)
+        {
+            cl_ptr_vector_at(&p_port_group->partitions, j, (void **)&p_str_vector_item);
+            if (p_str_vector_item->str)
+                free(p_str_vector_item->str);
+            free(p_str_vector_item);
+        }
+        cl_ptr_vector_destroy(&p_port_group->partitions);
+
+        for (j = 0; j < cl_ptr_vector_get_size(&p_port_group->node_types); j++)
+        {
+            cl_ptr_vector_at(&p_port_group->node_types, j, (void **)&p_uint32_vector_item);
+            free(p_uint32_vector_item);
+        }
+        cl_ptr_vector_destroy(&p_port_group->node_types);
+        
+        free(p_port_group);
+    }
+    cl_ptr_vector_destroy(&p_qos_parse_tree->port_groups);
+
+    for (i = 0; i < cl_ptr_vector_get_size(&p_qos_parse_tree->sl2vl_tables); i++)
+    {
+        cl_ptr_vector_at(&p_qos_parse_tree->sl2vl_tables, i, (void **)&p_sl2vl_scope);
+
+        for (j = 0; j < cl_ptr_vector_get_size(&p_sl2vl_scope->groups); j++)
+        {
+            cl_ptr_vector_at(&p_sl2vl_scope->groups, j, (void **)&p_str_vector_item);
+            if (p_str_vector_item->str)
+                free(p_str_vector_item->str);
+            free(p_str_vector_item);
+        }
+        cl_ptr_vector_destroy(&p_sl2vl_scope->groups);
+
+        for (j = 0; j < cl_ptr_vector_get_size(&p_sl2vl_scope->from); j++)
+        {
+            cl_ptr_vector_at(&p_sl2vl_scope->from, j, (void **)&p_str_vector_item);
+            if (p_str_vector_item->str)
+                free(p_str_vector_item->str);
+            free(p_str_vector_item);
+        }
+        cl_ptr_vector_destroy(&p_sl2vl_scope->from);
+
+        for (j = 0; j < cl_ptr_vector_get_size(&p_sl2vl_scope->to); j++)
+        {
+            cl_ptr_vector_at(&p_sl2vl_scope->to, j, (void **)&p_str_vector_item);
+            if (p_str_vector_item->str)
+                free(p_str_vector_item->str);
+            free(p_str_vector_item);
+        }
+        cl_ptr_vector_destroy(&p_sl2vl_scope->to);
+
+        for (j = 0; j < cl_ptr_vector_get_size(&p_sl2vl_scope->across_from); j++)
+        {
+            cl_ptr_vector_at(&p_sl2vl_scope->across_from, j, (void **)&p_str_vector_item);
+            if (p_str_vector_item->str)
+                free(p_str_vector_item->str);
+            free(p_str_vector_item);
+        }
+        cl_ptr_vector_destroy(&p_sl2vl_scope->across_from);
+
+        for (j = 0; j < cl_ptr_vector_get_size(&p_sl2vl_scope->across_to); j++)
+        {
+            cl_ptr_vector_at(&p_sl2vl_scope->across_to, j, (void **)&p_str_vector_item);
+            if (p_str_vector_item->str)
+                free(p_str_vector_item->str);
+            free(p_str_vector_item);
+        }
+        cl_ptr_vector_destroy(&p_sl2vl_scope->across_to);
+
+        free(p_sl2vl_scope);
+    }
+    cl_ptr_vector_destroy(&p_qos_parse_tree->sl2vl_tables);
+
+    for (i = 0; i < cl_ptr_vector_get_size(&p_qos_parse_tree->vlarb_tables); i++)
+    {
+        cl_ptr_vector_at(&p_qos_parse_tree->vlarb_tables, i, (void **)&p_vlarb_scope);
+
+        for (j = 0; j < cl_ptr_vector_get_size(&p_vlarb_scope->groups); j++)
+        {
+            cl_ptr_vector_at(&p_vlarb_scope->groups, j, (void **)&p_str_vector_item);
+            if (p_str_vector_item->str)
+                free(p_str_vector_item->str);
+            free(p_str_vector_item);
+        }
+        cl_ptr_vector_destroy(&p_vlarb_scope->groups);
+
+        for (j = 0; j < cl_ptr_vector_get_size(&p_vlarb_scope->across); j++)
+        {
+            cl_ptr_vector_at(&p_vlarb_scope->across, j, (void **)&p_str_vector_item);
+            if (p_str_vector_item->str)
+                free(p_str_vector_item->str);
+            free(p_str_vector_item);
+        }
+        cl_ptr_vector_destroy(&p_vlarb_scope->across);
+
+        for (j = 0; j < cl_ptr_vector_get_size(&p_vlarb_scope->vlarb_highs); j++)
+        {
+            cl_ptr_vector_at(&p_vlarb_scope->vlarb_highs, j, (void **)&p_vlarb_hl_vector_item);
+            free(p_vlarb_hl_vector_item);
+        }
+        cl_ptr_vector_destroy(&p_vlarb_scope->vlarb_highs);
+
+        for (j = 0; j < cl_ptr_vector_get_size(&p_vlarb_scope->vlarb_lows); j++)
+        {
+            cl_ptr_vector_at(&p_vlarb_scope->vlarb_lows, j, (void **)&p_vlarb_hl_vector_item);
+            free(p_vlarb_hl_vector_item);
+        }
+        cl_ptr_vector_destroy(&p_vlarb_scope->vlarb_lows);
+
+        free(p_vlarb_scope);
+    }
+    cl_ptr_vector_destroy(&p_qos_parse_tree->vlarb_tables);
+
+    for (i = 0; i < cl_ptr_vector_get_size(&p_qos_parse_tree->qos_levels); i++)
+    {
+        cl_ptr_vector_at(&p_qos_parse_tree->qos_levels, i, (void **)&p_qos_level);
+        if (p_qos_level->use)
+            free(p_qos_level->use);
+        free(p_qos_level);
+    }
+    cl_ptr_vector_destroy(&p_qos_parse_tree->qos_levels);
+
+    for (i = 0; i < cl_ptr_vector_get_size(&p_qos_parse_tree->qos_match_rules); i++)
+    {
+        cl_ptr_vector_at(&p_qos_parse_tree->qos_match_rules, i, (void **)&p_qos_match_rule);
+
+        if (p_qos_match_rule->use)
+            free(p_qos_match_rule->use);
+        if (p_qos_match_rule->source)
+            free(p_qos_match_rule->source);
+        if (p_qos_match_rule->destination)
+            free(p_qos_match_rule->destination);
+
+        for (j = 0; j < cl_ptr_vector_get_size(&p_qos_match_rule->services); j++)
+        {
+            cl_ptr_vector_at(&p_qos_match_rule->services, j, (void **)&p_uint32_vector_item);
+            free(p_uint32_vector_item);
+        }
+        cl_ptr_vector_destroy(&p_qos_match_rule->services);
+
+        for (j = 0; j < cl_ptr_vector_get_size(&p_qos_match_rule->qos_level_sns); j++)
+        {
+            cl_ptr_vector_at(&p_qos_match_rule->qos_level_sns, j, (void **)&p_uint32_vector_item);
+            free(p_uint32_vector_item);
+        }
+        cl_ptr_vector_destroy(&p_qos_match_rule->qos_level_sns);
+
+        for (j = 0; j < cl_ptr_vector_get_size(&p_qos_match_rule->classes); j++)
+        {
+            cl_ptr_vector_at(&p_qos_match_rule->classes, j, (void **)&p_uint32_vector_item);
+            free(p_uint32_vector_item);
+        }
+        cl_ptr_vector_destroy(&p_qos_match_rule->classes);
+
+        free(p_qos_match_rule);
+    }
+    cl_ptr_vector_destroy(&p_qos_parse_tree->qos_match_rules);
+
+    free(p_qos_parse_tree);
+}
+
+/***************************************************
+ ***************************************************/
-- 
1.4.4.1.GIT





More information about the general mailing list