1219820Sjeff/*
2219820Sjeff * Copyright (c) 2004-2007 Voltaire, Inc. All rights reserved.
3219820Sjeff * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
4219820Sjeff * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
5219820Sjeff *
6219820Sjeff * This software is available to you under a choice of one of two
7219820Sjeff * licenses.  You may choose to be licensed under the terms of the GNU
8219820Sjeff * General Public License (GPL) Version 2, available from the file
9219820Sjeff * COPYING in the main directory of this source tree, or the
10219820Sjeff * OpenIB.org BSD license below:
11219820Sjeff *
12219820Sjeff *     Redistribution and use in source and binary forms, with or
13219820Sjeff *     without modification, are permitted provided that the following
14219820Sjeff *     conditions are met:
15219820Sjeff *
16219820Sjeff *      - Redistributions of source code must retain the above
17219820Sjeff *        copyright notice, this list of conditions and the following
18219820Sjeff *        disclaimer.
19219820Sjeff *
20219820Sjeff *      - Redistributions in binary form must reproduce the above
21219820Sjeff *        copyright notice, this list of conditions and the following
22219820Sjeff *        disclaimer in the documentation and/or other materials
23219820Sjeff *        provided with the distribution.
24219820Sjeff *
25219820Sjeff * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26219820Sjeff * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27219820Sjeff * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28219820Sjeff * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29219820Sjeff * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30219820Sjeff * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31219820Sjeff * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32219820Sjeff * SOFTWARE.
33219820Sjeff *
34219820Sjeff */
35219820Sjeff
36219820Sjeff/*
37219820Sjeff * Abstract:
38219820Sjeff *    Declaration of OSM QoS Policy data types and functions.
39219820Sjeff *
40219820Sjeff * Author:
41219820Sjeff *    Yevgeny Kliteynik, Mellanox
42219820Sjeff */
43219820Sjeff
44219820Sjeff#ifndef OSM_QOS_POLICY_H
45219820Sjeff#define OSM_QOS_POLICY_H
46219820Sjeff
47219820Sjeff#include <iba/ib_types.h>
48219820Sjeff#include <complib/cl_list.h>
49219820Sjeff#include <opensm/st.h>
50219820Sjeff#include <opensm/osm_port.h>
51219820Sjeff#include <opensm/osm_partition.h>
52219820Sjeff
53219820Sjeff#define YYSTYPE char *
54219820Sjeff#define OSM_QOS_POLICY_MAX_PORTS_ON_SWITCH  128
55219820Sjeff#define OSM_QOS_POLICY_DEFAULT_LEVEL_NAME   "default"
56219820Sjeff
57219820Sjeff#define OSM_QOS_POLICY_ULP_SDP_SERVICE_ID   0x0000000000010000ULL
58219820Sjeff#define OSM_QOS_POLICY_ULP_RDS_SERVICE_ID   0x0000000001060000ULL
59219820Sjeff#define OSM_QOS_POLICY_ULP_RDS_PORT         0x48CA
60219820Sjeff#define OSM_QOS_POLICY_ULP_ISER_SERVICE_ID  0x0000000001060000ULL
61219820Sjeff#define OSM_QOS_POLICY_ULP_ISER_PORT        0x0CBC
62219820Sjeff
63219820Sjeff#define OSM_QOS_POLICY_NODE_TYPE_CA        (((uint8_t)1)<<IB_NODE_TYPE_CA)
64219820Sjeff#define OSM_QOS_POLICY_NODE_TYPE_SWITCH    (((uint8_t)1)<<IB_NODE_TYPE_SWITCH)
65219820Sjeff#define OSM_QOS_POLICY_NODE_TYPE_ROUTER    (((uint8_t)1)<<IB_NODE_TYPE_ROUTER)
66219820Sjeff
67219820Sjeff/***************************************************/
68219820Sjeff
69219820Sjefftypedef struct osm_qos_port {
70219820Sjeff	cl_map_item_t map_item;
71219820Sjeff	osm_physp_t * p_physp;
72219820Sjeff} osm_qos_port_t;
73219820Sjeff
74219820Sjefftypedef struct osm_qos_port_group {
75219820Sjeff	char *name;			/* single string (this port group name) */
76219820Sjeff	char *use;			/* single string (description) */
77219820Sjeff	uint8_t node_types;		/* node types bitmask */
78219820Sjeff	cl_qmap_t port_map;
79219820Sjeff} osm_qos_port_group_t;
80219820Sjeff
81219820Sjeff/***************************************************/
82219820Sjeff
83219820Sjefftypedef struct osm_qos_vlarb_scope {
84219820Sjeff	cl_list_t group_list;		/* list of group names (strings) */
85219820Sjeff	cl_list_t across_list;		/* list of 'across' group names (strings) */
86219820Sjeff	cl_list_t vlarb_high_list;	/* list of num pairs (n:m,...), 32-bit values */
87219820Sjeff	cl_list_t vlarb_low_list;	/* list of num pairs (n:m,...), 32-bit values */
88219820Sjeff	uint32_t vl_high_limit;		/* single integer */
89219820Sjeff	boolean_t vl_high_limit_set;
90219820Sjeff} osm_qos_vlarb_scope_t;
91219820Sjeff
92219820Sjeff/***************************************************/
93219820Sjeff
94219820Sjefftypedef struct osm_qos_sl2vl_scope {
95219820Sjeff	cl_list_t group_list;		/* list of strings (port group names) */
96219820Sjeff	boolean_t from[OSM_QOS_POLICY_MAX_PORTS_ON_SWITCH];
97219820Sjeff	boolean_t to[OSM_QOS_POLICY_MAX_PORTS_ON_SWITCH];
98219820Sjeff	cl_list_t across_from_list;	/* list of strings (port group names) */
99219820Sjeff	cl_list_t across_to_list;	/* list of strings (port group names) */
100219820Sjeff	uint8_t sl2vl_table[16];	/* array of sl2vl values */
101219820Sjeff	boolean_t sl2vl_table_set;
102219820Sjeff} osm_qos_sl2vl_scope_t;
103219820Sjeff
104219820Sjeff/***************************************************/
105219820Sjeff
106219820Sjefftypedef struct osm_qos_level {
107219820Sjeff	char *use;
108219820Sjeff	char *name;
109219820Sjeff	uint8_t sl;
110219820Sjeff	boolean_t sl_set;
111219820Sjeff	uint8_t mtu_limit;
112219820Sjeff	boolean_t mtu_limit_set;
113219820Sjeff	uint8_t rate_limit;
114219820Sjeff	boolean_t rate_limit_set;
115219820Sjeff	uint8_t pkt_life;
116219820Sjeff	boolean_t pkt_life_set;
117219820Sjeff	uint64_t **path_bits_range_arr;	/* array of bit ranges (real values are 32bits) */
118219820Sjeff	unsigned path_bits_range_len;	/* num of bit ranges in the array */
119219820Sjeff	uint64_t **pkey_range_arr;	/* array of PKey ranges (real values are 16bits) */
120219820Sjeff	unsigned pkey_range_len;
121219820Sjeff} osm_qos_level_t;
122219820Sjeff
123219820Sjeff
124219820Sjeff/***************************************************/
125219820Sjeff
126219820Sjefftypedef struct osm_qos_match_rule {
127219820Sjeff	char *use;
128219820Sjeff	cl_list_t source_list;			/* list of strings */
129219820Sjeff	cl_list_t source_group_list;		/* list of pointers to relevant port-group */
130219820Sjeff	cl_list_t destination_list;		/* list of strings */
131219820Sjeff	cl_list_t destination_group_list;	/* list of pointers to relevant port-group */
132219820Sjeff	char *qos_level_name;
133219820Sjeff	osm_qos_level_t *p_qos_level;
134219820Sjeff	uint64_t **service_id_range_arr;	/* array of SID ranges (64-bit values) */
135219820Sjeff	unsigned service_id_range_len;
136219820Sjeff	uint64_t **qos_class_range_arr;		/* array of QoS Class ranges (real values are 16bits) */
137219820Sjeff	unsigned qos_class_range_len;
138219820Sjeff	uint64_t **pkey_range_arr;		/* array of PKey ranges (real values are 16bits) */
139219820Sjeff	unsigned pkey_range_len;
140219820Sjeff} osm_qos_match_rule_t;
141219820Sjeff
142219820Sjeff/***************************************************/
143219820Sjeff
144219820Sjefftypedef struct osm_qos_policy {
145219820Sjeff	cl_list_t port_groups;			/* list of osm_qos_port_group_t */
146219820Sjeff	cl_list_t sl2vl_tables;			/* list of osm_qos_sl2vl_scope_t */
147219820Sjeff	cl_list_t vlarb_tables;			/* list of osm_qos_vlarb_scope_t */
148219820Sjeff	cl_list_t qos_levels;			/* list of osm_qos_level_t */
149219820Sjeff	cl_list_t qos_match_rules;		/* list of osm_qos_match_rule_t */
150219820Sjeff	osm_qos_level_t *p_default_qos_level;	/* default QoS level */
151219820Sjeff	osm_subn_t *p_subn;			/* osm subnet object */
152219820Sjeff	st_table * p_node_hash;			/* node by name hash */
153219820Sjeff} osm_qos_policy_t;
154219820Sjeff
155219820Sjeff/***************************************************/
156219820Sjeff
157219820Sjeffosm_qos_port_t *osm_qos_policy_port_create(osm_physp_t * p_physp);
158219820Sjeffosm_qos_port_group_t * osm_qos_policy_port_group_create();
159219820Sjeffvoid osm_qos_policy_port_group_destroy(osm_qos_port_group_t * p_port_group);
160219820Sjeff
161219820Sjeffosm_qos_vlarb_scope_t * osm_qos_policy_vlarb_scope_create();
162219820Sjeffvoid osm_qos_policy_vlarb_scope_destroy(osm_qos_vlarb_scope_t * p_vlarb_scope);
163219820Sjeff
164219820Sjeffosm_qos_sl2vl_scope_t * osm_qos_policy_sl2vl_scope_create();
165219820Sjeffvoid osm_qos_policy_sl2vl_scope_destroy(osm_qos_sl2vl_scope_t * p_sl2vl_scope);
166219820Sjeff
167219820Sjeffosm_qos_level_t * osm_qos_policy_qos_level_create();
168219820Sjeffvoid osm_qos_policy_qos_level_destroy(osm_qos_level_t * p_qos_level);
169219820Sjeff
170219820Sjeffboolean_t osm_qos_level_has_pkey(IN const osm_qos_level_t * p_qos_level,
171219820Sjeff				 IN ib_net16_t pkey);
172219820Sjeff
173219820Sjeffib_net16_t osm_qos_level_get_shared_pkey(IN const osm_qos_level_t * p_qos_level,
174219820Sjeff					 IN const osm_physp_t * p_src_physp,
175219820Sjeff					 IN const osm_physp_t * p_dest_physp);
176219820Sjeff
177219820Sjeffosm_qos_match_rule_t * osm_qos_policy_match_rule_create();
178219820Sjeffvoid osm_qos_policy_match_rule_destroy(osm_qos_match_rule_t * p_match_rule);
179219820Sjeff
180219820Sjeffosm_qos_policy_t * osm_qos_policy_create(osm_subn_t * p_subn);
181219820Sjeffvoid osm_qos_policy_destroy(osm_qos_policy_t * p_qos_policy);
182219820Sjeffint osm_qos_policy_validate(osm_qos_policy_t * p_qos_policy, osm_log_t * p_log);
183219820Sjeff
184219820Sjeffosm_qos_level_t * osm_qos_policy_get_qos_level_by_pr(
185219820Sjeff	IN const osm_qos_policy_t * p_qos_policy,
186219820Sjeff	IN const ib_path_rec_t * p_pr,
187219820Sjeff	IN const osm_physp_t * p_src_physp,
188219820Sjeff	IN const osm_physp_t * p_dest_physp,
189219820Sjeff	IN ib_net64_t comp_mask);
190219820Sjeff
191219820Sjeffosm_qos_level_t * osm_qos_policy_get_qos_level_by_mpr(
192219820Sjeff	IN const osm_qos_policy_t * p_qos_policy,
193219820Sjeff	IN const ib_multipath_rec_t * p_mpr,
194219820Sjeff	IN const osm_physp_t * p_src_physp,
195219820Sjeff	IN const osm_physp_t * p_dest_physp,
196219820Sjeff	IN ib_net64_t comp_mask);
197219820Sjeff
198219820Sjeff/***************************************************/
199219820Sjeff
200219820Sjeffint osm_qos_parse_policy_file(IN osm_subn_t * const p_subn);
201219820Sjeff
202219820Sjeff/***************************************************/
203219820Sjeff
204219820Sjeff#endif				/* ifndef OSM_QOS_POLICY_H */
205