2 * Copyright (c) 2004-2007 Voltaire, Inc. All rights reserved.
3 * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
4 * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
6 * This software is available to you under a choice of one of two
7 * licenses. You may choose to be licensed under the terms of the GNU
8 * General Public License (GPL) Version 2, available from the file
9 * COPYING in the main directory of this source tree, or the
10 * OpenIB.org BSD license below:
12 * Redistribution and use in source and binary forms, with or
13 * without modification, are permitted provided that the following
16 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
20 * - Redistributions in binary form must reproduce the above
21 * copyright notice, this list of conditions and the following
22 * disclaimer in the documentation and/or other materials
23 * provided with the distribution.
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
38 * Declaration of OSM QoS Policy data types and functions.
41 * Yevgeny Kliteynik, Mellanox
44 #ifndef OSM_QOS_POLICY_H
45 #define OSM_QOS_POLICY_H
47 #include <iba/ib_types.h>
48 #include <complib/cl_list.h>
49 #include <opensm/st.h>
50 #include <opensm/osm_port.h>
51 #include <opensm/osm_partition.h>
53 #define YYSTYPE char *
54 #define OSM_QOS_POLICY_MAX_PORTS_ON_SWITCH 128
55 #define OSM_QOS_POLICY_DEFAULT_LEVEL_NAME "default"
57 #define OSM_QOS_POLICY_ULP_SDP_SERVICE_ID 0x0000000000010000ULL
58 #define OSM_QOS_POLICY_ULP_RDS_SERVICE_ID 0x0000000001060000ULL
59 #define OSM_QOS_POLICY_ULP_RDS_PORT 0x48CA
60 #define OSM_QOS_POLICY_ULP_ISER_SERVICE_ID 0x0000000001060000ULL
61 #define OSM_QOS_POLICY_ULP_ISER_PORT 0x0CBC
63 #define OSM_QOS_POLICY_NODE_TYPE_CA (((uint8_t)1)<<IB_NODE_TYPE_CA)
64 #define OSM_QOS_POLICY_NODE_TYPE_SWITCH (((uint8_t)1)<<IB_NODE_TYPE_SWITCH)
65 #define OSM_QOS_POLICY_NODE_TYPE_ROUTER (((uint8_t)1)<<IB_NODE_TYPE_ROUTER)
67 /***************************************************/
69 typedef struct osm_qos_port {
70 cl_map_item_t map_item;
71 osm_physp_t * p_physp;
74 typedef struct osm_qos_port_group {
75 char *name; /* single string (this port group name) */
76 char *use; /* single string (description) */
77 uint8_t node_types; /* node types bitmask */
79 } osm_qos_port_group_t;
81 /***************************************************/
83 typedef struct osm_qos_vlarb_scope {
84 cl_list_t group_list; /* list of group names (strings) */
85 cl_list_t across_list; /* list of 'across' group names (strings) */
86 cl_list_t vlarb_high_list; /* list of num pairs (n:m,...), 32-bit values */
87 cl_list_t vlarb_low_list; /* list of num pairs (n:m,...), 32-bit values */
88 uint32_t vl_high_limit; /* single integer */
89 boolean_t vl_high_limit_set;
90 } osm_qos_vlarb_scope_t;
92 /***************************************************/
94 typedef struct osm_qos_sl2vl_scope {
95 cl_list_t group_list; /* list of strings (port group names) */
96 boolean_t from[OSM_QOS_POLICY_MAX_PORTS_ON_SWITCH];
97 boolean_t to[OSM_QOS_POLICY_MAX_PORTS_ON_SWITCH];
98 cl_list_t across_from_list; /* list of strings (port group names) */
99 cl_list_t across_to_list; /* list of strings (port group names) */
100 uint8_t sl2vl_table[16]; /* array of sl2vl values */
101 boolean_t sl2vl_table_set;
102 } osm_qos_sl2vl_scope_t;
104 /***************************************************/
106 typedef struct osm_qos_level {
112 boolean_t mtu_limit_set;
114 boolean_t rate_limit_set;
116 boolean_t pkt_life_set;
117 uint64_t **path_bits_range_arr; /* array of bit ranges (real values are 32bits) */
118 unsigned path_bits_range_len; /* num of bit ranges in the array */
119 uint64_t **pkey_range_arr; /* array of PKey ranges (real values are 16bits) */
120 unsigned pkey_range_len;
124 /***************************************************/
126 typedef struct osm_qos_match_rule {
128 cl_list_t source_list; /* list of strings */
129 cl_list_t source_group_list; /* list of pointers to relevant port-group */
130 cl_list_t destination_list; /* list of strings */
131 cl_list_t destination_group_list; /* list of pointers to relevant port-group */
132 char *qos_level_name;
133 osm_qos_level_t *p_qos_level;
134 uint64_t **service_id_range_arr; /* array of SID ranges (64-bit values) */
135 unsigned service_id_range_len;
136 uint64_t **qos_class_range_arr; /* array of QoS Class ranges (real values are 16bits) */
137 unsigned qos_class_range_len;
138 uint64_t **pkey_range_arr; /* array of PKey ranges (real values are 16bits) */
139 unsigned pkey_range_len;
140 } osm_qos_match_rule_t;
142 /***************************************************/
144 typedef struct osm_qos_policy {
145 cl_list_t port_groups; /* list of osm_qos_port_group_t */
146 cl_list_t sl2vl_tables; /* list of osm_qos_sl2vl_scope_t */
147 cl_list_t vlarb_tables; /* list of osm_qos_vlarb_scope_t */
148 cl_list_t qos_levels; /* list of osm_qos_level_t */
149 cl_list_t qos_match_rules; /* list of osm_qos_match_rule_t */
150 osm_qos_level_t *p_default_qos_level; /* default QoS level */
151 osm_subn_t *p_subn; /* osm subnet object */
152 st_table * p_node_hash; /* node by name hash */
155 /***************************************************/
157 osm_qos_port_t *osm_qos_policy_port_create(osm_physp_t * p_physp);
158 osm_qos_port_group_t * osm_qos_policy_port_group_create();
159 void osm_qos_policy_port_group_destroy(osm_qos_port_group_t * p_port_group);
161 osm_qos_vlarb_scope_t * osm_qos_policy_vlarb_scope_create();
162 void osm_qos_policy_vlarb_scope_destroy(osm_qos_vlarb_scope_t * p_vlarb_scope);
164 osm_qos_sl2vl_scope_t * osm_qos_policy_sl2vl_scope_create();
165 void osm_qos_policy_sl2vl_scope_destroy(osm_qos_sl2vl_scope_t * p_sl2vl_scope);
167 osm_qos_level_t * osm_qos_policy_qos_level_create();
168 void osm_qos_policy_qos_level_destroy(osm_qos_level_t * p_qos_level);
170 boolean_t osm_qos_level_has_pkey(IN const osm_qos_level_t * p_qos_level,
173 ib_net16_t osm_qos_level_get_shared_pkey(IN const osm_qos_level_t * p_qos_level,
174 IN const osm_physp_t * p_src_physp,
175 IN const osm_physp_t * p_dest_physp);
177 osm_qos_match_rule_t * osm_qos_policy_match_rule_create();
178 void osm_qos_policy_match_rule_destroy(osm_qos_match_rule_t * p_match_rule);
180 osm_qos_policy_t * osm_qos_policy_create(osm_subn_t * p_subn);
181 void osm_qos_policy_destroy(osm_qos_policy_t * p_qos_policy);
182 int osm_qos_policy_validate(osm_qos_policy_t * p_qos_policy, osm_log_t * p_log);
184 osm_qos_level_t * osm_qos_policy_get_qos_level_by_pr(
185 IN const osm_qos_policy_t * p_qos_policy,
186 IN const ib_path_rec_t * p_pr,
187 IN const osm_physp_t * p_src_physp,
188 IN const osm_physp_t * p_dest_physp,
189 IN ib_net64_t comp_mask);
191 osm_qos_level_t * osm_qos_policy_get_qos_level_by_mpr(
192 IN const osm_qos_policy_t * p_qos_policy,
193 IN const ib_multipath_rec_t * p_mpr,
194 IN const osm_physp_t * p_src_physp,
195 IN const osm_physp_t * p_dest_physp,
196 IN ib_net64_t comp_mask);
198 /***************************************************/
200 int osm_qos_parse_policy_file(IN osm_subn_t * const p_subn);
202 /***************************************************/
204 #endif /* ifndef OSM_QOS_POLICY_H */