Data Structures | |
struct | qsup_user_t |
QoS Sup related data for each user. More... | |
struct | qsup_level_t |
QoS Sup related data for each level. More... | |
Modules | |
QoS Supervisor Kernel Module | |
Mediates bandwidth requests made to the QoS Resource Reservation Kernel Module, enforcing system-level security policy and QoS behaviour configured through the use of level, group and user rules. | |
QoS Supervisor Library | |
Allows a privileged application to configure level, group and user rules governing security and guarantees policies enforced by the QoS Supervisor Kernel Module. | |
Files | |
file | qsup.c |
Implementation of the QoS Supervisor module. | |
Defines | |
#define | QSUP_COEFF_BITS 16 |
Number of binary decimal digits in qsup_coeff_t. | |
#define | QSUP_COEFF_ONE (1ul << QSUP_COEFF_BITS) |
This corresponds to a qsup_coeff_t of 1.0. | |
#define | coeff_apply(a, b) ((unsigned long) ul_mul_shr((__u32) (a), (__u32) (b), QSUP_COEFF_BITS) ) |
Scale (multiply) a bandwidth value by a coefficient. | |
#define | coeff_compute(a, b) ((unsigned long) ul_shl_div((__u32) (a), QSUP_COEFF_BITS, (__u32) (b)) ) |
Compute a coefficient value as the equivalent operation on reals: a/b. | |
#define | MAX_NUM_LEVELS 2 |
Typedefs | |
typedef long int | qsup_coeff_t |
Bandwidth coefficients are stored as fixed-point integers. | |
typedef struct qsup_user_t | qsup_user_t |
QoS Sup related data for each user. | |
typedef struct qsup_level_t | qsup_level_t |
QoS Sup related data for each level. | |
Functions | |
static void | qsup_lock_coeffs_read (unsigned long *p_flags) |
Global QSUP coefficients lock. | |
static void | qsup_unlock_coeffs_read (unsigned long flags) |
Unlock QSup coefficients for reading. | |
static void | qsup_lock_coeffs_write (unsigned long *p_flags) |
Lock QSup coefficients for writing. | |
static void | qsup_unlock_coeffs_write (unsigned long flags) |
Unlock QSup coefficients for writing. | |
static qos_bw_t | bw_min (qos_bw_t a, qos_bw_t b) |
qos_rv | qsup_add_level_rule (int level, qos_bw_t max_bw) |
Add a level rule to the QSUP. | |
qos_rv | qsup_add_group_constraints (int gid, qsup_constraints_t *constr) |
Add a group rule to the QSUP. | |
qos_rv | qsup_add_user_constraints (int uid, qsup_constraints_t *constr) |
Add a user rule to the QSUP. | |
qos_rv | qsup_init () |
Initialize the QSUP subsystem just after module load into the kernel. | |
qos_rv | qsup_cleanup () |
Cleanup the QSUP subsystem before unloading the module from kernel. | |
qsup_constraints_t * | qsup_find_constr (int uid, int gid) |
Find the constraints in force for the supplied uid/gid pair. | |
qsup_server_t * | qsup_find_server_by_id (int server_id) |
Return qsup_server_t structure for specified server_id, or zero if not found. | |
qos_rv | get_user_info (qsup_user_t **pp, int uid) |
Retrieve a qsup_user_t structure for the specified uid. | |
qos_bw_t | qsup_get_max_gua_bw (int uid, int gid) |
Returns the maximum guaranteed bandwidth for the specified user. | |
qos_rv | qsup_get_avail_gua_bw (int uid, int gid, qos_bw_t *p_avail_bw) |
Returns in *p_avail_bw the available guaranteed bw for the specified user. | |
qos_rv | qsup_get_avail_bw (int uid, int gid, qos_bw_t *p_avail_bw) |
Returns in *p_avail_bw the available bw for the specified user. | |
qos_rv | qsup_init_server (qsup_server_t *srv, int uid, int gid, qres_params_t *param) |
Initialize a new qsup_server_t structure. | |
qos_rv | qsup_create_server (qsup_server_t **pp, int uid, int gid, qres_params_t *param) |
Create a new qsup_server_t structure. | |
qos_rv | qsup_cleanup_server (qsup_server_t *srv) |
qos_rv | qsup_destroy_server (qsup_server_t *srv) |
Destroy a qsup_server_t and free associated resources. | |
qos_rv | qsup_set_required_bw (qsup_server_t *srv, qos_bw_t server_req) |
Sets the required bandwidth for the specified server. | |
qos_bw_t | qsup_get_required_bw (qsup_server_t *srv) |
Gets the required bandwidth for the specified server. | |
qos_bw_t | qsup_get_guaranteed_bw (qsup_server_t *srv) |
Gets the minimum granted bandwidth for the specified server. | |
void | qsup_dump (void) |
Dumps into the log system the QSUP server complete state. | |
qos_bw_t | qsup_get_approved_bw (qsup_server_t *srv) |
Returns the bandwidth approved for the specified server. | |
qos_rv | qsup_reserve_spare (qos_bw_t bw) |
Cannot reserve more than U_LUB as spare, and cannot change the reserved spare when servers are already active. | |
Variables | |
qsup_group_rule_t * | group_rules = 0 |
int | num_group_rules = 0 |
qsup_user_rule_t * | user_rules = 0 |
int | num_user_rules = 0 |
qos_bw_t | spare_bw = 0 |
static qsup_constraints_t | default_constraint |
qsup_server_t * | qsup_servers |
Head of global list of created qsup_servers. | |
int | next_server_id |
Id assigned to the next created qsup_server_t. | |
static qsup_user_t * | qsup_users |
User related data. | |
static qsup_level_t | qsup_levels [MAX_NUM_LEVELS] |
Level related data. | |
static qos_bw_t | tot_gua_bw = 0 |
Sum of guaranteed bandwidths of accepted servers. | |
static qos_bw_t | tot_used_gua_bw = 0 |
Sum of actually used guaranteed bw by all servers. |
#define coeff_apply | ( | a, | |||
b | ) | ((unsigned long) ul_mul_shr((__u32) (a), (__u32) (b), QSUP_COEFF_BITS) ) |
Scale (multiply) a bandwidth value by a coefficient.
Definition at line 51 of file qsup.c.
Referenced by qsup_dump(), and qsup_get_approved_bw().
#define coeff_compute | ( | a, | |||
b | ) | ((unsigned long) ul_shl_div((__u32) (a), QSUP_COEFF_BITS, (__u32) (b)) ) |
Compute a coefficient value as the equivalent operation on reals: a/b.
Definition at line 55 of file qsup.c.
Referenced by qsup_set_required_bw().
#define MAX_NUM_LEVELS 2 |
Definition at line 57 of file qsup.c.
Referenced by qsup_add_level_rule(), qsup_dump(), qsup_init(), and qsup_set_required_bw().
#define QSUP_COEFF_BITS 16 |
#define QSUP_COEFF_ONE (1ul << QSUP_COEFF_BITS) |
This corresponds to a qsup_coeff_t of 1.0.
Definition at line 47 of file qsup.c.
Referenced by get_user_info(), qsup_init(), and qsup_set_required_bw().
typedef long int qsup_coeff_t |
typedef struct qsup_level_t qsup_level_t |
QoS Sup related data for each level.
typedef struct qsup_user_t qsup_user_t |
QoS Sup related data for each user.
Definition at line 127 of file qsup.c.
Referenced by main(), qos_func_define(), qsup_add_level_rule(), qsup_set_required_bw(), and test().
qos_rv get_user_info | ( | qsup_user_t ** | pp, | |
int | uid | |||
) |
Retrieve a qsup_user_t structure for the specified uid.
If structure does not exist, create it and fill static parameters from the user and group rules.
Not found: create a new qsup_user_t
Add to head of qsup_users list
Fill in static data ?!?
Definition at line 259 of file qsup.c.
References qsup_user_t::next, QOS_E_NO_MEMORY, qos_malloc(), QOS_OK, QSUP_COEFF_ONE, qsup_user_t::uid, qsup_user_t::user_coeff, qsup_user_t::user_gua, qsup_user_t::user_req, and qsup_user_t::user_used_gua.
Referenced by qsup_get_avail_bw(), qsup_get_avail_gua_bw(), and qsup_init_server().
qos_rv qsup_add_group_constraints | ( | int | gid, | |
qsup_constraints_t * | constr | |||
) |
Add a group rule to the QSUP.
Definition at line 139 of file qsup.c.
References qsup_group_rule_t::constr, qsup_group_rule_t::gid, qsup_group_rule_t::next, num_group_rules, qos_create, QOS_E_NO_MEMORY, and QOS_OK.
Referenced by main(), and qsup_gw_ks().
Add a level rule to the QSUP.
Add a level max bw constraint to the identified level.
Definition at line 129 of file qsup.c.
Referenced by main(), and qsup_gw_ks().
qos_rv qsup_add_user_constraints | ( | int | uid, | |
qsup_constraints_t * | constr | |||
) |
Add a user rule to the QSUP.
Definition at line 153 of file qsup.c.
References qsup_user_rule_t::constr, qsup_user_rule_t::next, num_user_rules, QOS_E_NO_MEMORY, qos_malloc(), QOS_OK, and qsup_user_rule_t::uid.
Referenced by main().
qos_rv qsup_cleanup | ( | void | ) |
Cleanup the QSUP subsystem before unloading the module from kernel.
Definition at line 186 of file qsup.c.
Referenced by main(), qres_cleanup_module(), qsup_cleanup_ks(), and qsup_cleanup_module().
qos_rv qsup_cleanup_server | ( | qsup_server_t * | srv | ) |
Definition at line 405 of file qsup.c.
References qsup_server_t::gua_bw, qsup_server_t::next, prof_end, prof_func, prof_return, prof_vars, QOS_E_INCONSISTENT_STATE, QOS_E_INVALID_PARAM, QOS_OK, qsup_set_required_bw(), qsup_server_t::req_bw, and tot_gua_bw.
Referenced by qos_func_define(), and qsup_destroy_server().
qos_rv qsup_create_server | ( | qsup_server_t ** | p_srv, | |
int | uid, | |||
int | gid, | |||
qres_params_t * | param | |||
) |
Create a new qsup_server_t structure.
Definition at line 389 of file qsup.c.
References qos_create, QOS_E_NO_MEMORY, qos_free(), qos_log_err, QOS_OK, qos_strerror(), and qsup_init_server().
Referenced by main().
qos_rv qsup_destroy_server | ( | qsup_server_t * | srv | ) |
Destroy a qsup_server_t and free associated resources.
Definition at line 440 of file qsup.c.
References qos_free(), and qsup_cleanup_server().
Referenced by main().
void qsup_dump | ( | void | ) |
Dumps into the log system the QSUP server complete state.
Definition at line 554 of file qsup.c.
References bw2Q(), coeff_apply, qsup_server_t::level, MAX_NUM_LEVELS, qsup_server_t::next, qsup_user_t::next, qos_log_debug, QRES_TIME_FMT, qsup_get_approved_bw(), qsup_server_t::req_bw, qsup_server_t::server_id, srv, qsup_user_t::uid, and qsup_user_t::user_coeff.
Referenced by main(), and rres_read_qsup().
qsup_constraints_t* qsup_find_constr | ( | int | uid, | |
int | gid | |||
) |
Find the constraints in force for the supplied uid/gid pair.
Definition at line 226 of file qsup.c.
References qsup_group_rule_t::constr, qsup_user_rule_t::constr, qsup_group_rule_t::gid, qsup_group_rule_t::next, qsup_user_rule_t::next, and qsup_user_rule_t::uid.
Referenced by qsup_get_avail_bw(), qsup_get_avail_gua_bw(), qsup_get_max_gua_bw(), qsup_gw_ks(), and qsup_init_server().
qsup_server_t* qsup_find_server_by_id | ( | int | server_id | ) |
Return qsup_server_t structure for specified server_id, or zero if not found.
Definition at line 248 of file qsup.c.
References qsup_server_t::next, qsup_server_t::server_id, and srv.
qos_bw_t qsup_get_approved_bw | ( | qsup_server_t * | srv | ) |
Returns the bandwidth approved for the specified server.
Definition at line 577 of file qsup.c.
References coeff_apply, qsup_server_t::p_level_coeff, qsup_server_t::p_user_coeff, prof_func, prof_return, prof_vars, qsup_server_t::req_bw, and qsup_server_t::used_gua_bw.
Referenced by _qres_get_bandwidth(), main(), qos_func_define(), and qsup_dump().
Returns in *p_avail_bw the available bw for the specified user.
Definition at line 303 of file qsup.c.
References get_user_info(), qsup_constraints_t::max_bw, qos_chk_go_msg, QOS_OK, qsup_find_constr(), and qsup_user_t::user_req.
Returns in *p_avail_bw the available guaranteed bw for the specified user.
Definition at line 288 of file qsup.c.
References get_user_info(), qsup_constraints_t::max_min_bw, qos_chk_go_msg, QOS_OK, qsup_find_constr(), and qsup_user_t::user_gua.
Referenced by qsup_gw_ks().
qos_bw_t qsup_get_guaranteed_bw | ( | qsup_server_t * | srv | ) |
Gets the minimum granted bandwidth for the specified server.
Definition at line 550 of file qsup.c.
References qsup_server_t::gua_bw.
qos_bw_t qsup_get_max_gua_bw | ( | int | uid, | |
int | gid | |||
) |
Returns the maximum guaranteed bandwidth for the specified user.
Definition at line 282 of file qsup.c.
References qsup_constraints_t::max_min_bw, and qsup_find_constr().
qos_bw_t qsup_get_required_bw | ( | qsup_server_t * | srv | ) |
Gets the required bandwidth for the specified server.
Definition at line 546 of file qsup.c.
References qsup_server_t::req_bw.
qos_rv qsup_init | ( | void | ) |
Initialize the QSUP subsystem just after module load into the kernel.
Definition at line 167 of file qsup.c.
Referenced by check_open(), main(), and qsup_init_ks().
qos_rv qsup_init_server | ( | qsup_server_t * | srv, | |
int | uid, | |||
int | gid, | |||
qres_params_t * | param | |||
) |
Initialize a new qsup_server_t structure.
< Guaranteed minimum not used yet
Update sum of guaranteed bw to all servers
Definition at line 319 of file qsup.c.
References qres_params_t::flags, qsup_constraints_t::flags_mask, get_user_info(), qsup_server_t::gid, qsup_server_t::gua_bw, qsup_constraints_t::level, qsup_server_t::level, qsup_level_t::level_coeff, qsup_level_t::level_gua, qsup_level_t::level_max, qsup_level_t::level_req, qsup_level_t::level_sum, qsup_constraints_t::max_bw, qsup_server_t::max_level_bw, qsup_constraints_t::max_min_bw, qsup_server_t::max_user_bw, qsup_server_t::next, next_server_id, qres_params_t::P, qsup_server_t::p_level_coeff, qsup_server_t::p_level_gua, qsup_server_t::p_level_req, qsup_server_t::p_level_sum, qsup_server_t::p_user_coeff, qsup_server_t::p_user_gua, qsup_server_t::p_user_req, qres_params_t::Q_min, qos_chk_ok_ret, QOS_E_SYSTEM_OVERLOAD, QOS_E_UNAUTHORIZED, qos_log_debug, qos_log_err, QOS_OK, qsup_find_constr(), r2bw_ceil(), qsup_server_t::req_bw, qsup_server_t::server_id, spare_bw, tot_gua_bw, U_LUB, qsup_server_t::uid, qsup_server_t::used_gua_bw, qsup_user_t::user_coeff, qsup_user_t::user_gua, qsup_user_t::user_req, qsup_user_t::user_used_gua, qsup_constraints_t::weight, and qsup_server_t::weight.
Referenced by qos_func_define(), and qsup_create_server().
static void qsup_lock_coeffs_read | ( | unsigned long * | p_flags | ) | [inline, static] |
static void qsup_lock_coeffs_write | ( | unsigned long * | p_flags | ) | [inline, static] |
Cannot reserve more than U_LUB as spare, and cannot change the reserved spare when servers are already active.
Set the bandwidth that is considered as spare by the system for adaptive reservation purposes.
Set the spare bandwidth for admission control purposes.
Definition at line 594 of file qsup.c.
Referenced by main(), and qsup_gw_ks().
qos_rv qsup_set_required_bw | ( | qsup_server_t * | srv, | |
qos_bw_t | server_req | |||
) |
Sets the required bandwidth for the specified server.
Definition at line 447 of file qsup.c.
References bw_min(), coeff_compute, qsup_server_t::gua_bw, qsup_level_t::level_coeff, qsup_level_t::level_gua, qsup_level_t::level_max, qsup_level_t::level_req, qsup_level_t::level_sum, MAX_NUM_LEVELS, qsup_server_t::max_user_bw, qsup_server_t::p_level_gua, qsup_server_t::p_level_req, qsup_server_t::p_user_coeff, qsup_server_t::p_user_gua, qsup_server_t::p_user_req, prof_end, prof_func, prof_vars, QOS_BW_FMT, qos_log_debug, QOS_OK, QSUP_COEFF_ONE, qsup_server_t::req_bw, qsup_server_t::server_id, tot_used_gua_bw, U_LUB, and qsup_server_t::used_gua_bw.
Referenced by main(), qos_func_define(), and qsup_cleanup_server().
static void qsup_unlock_coeffs_read | ( | unsigned long | flags | ) | [inline, static] |
static void qsup_unlock_coeffs_write | ( | unsigned long | flags | ) | [inline, static] |
qsup_constraints_t default_constraint [static] |
int next_server_id |
Id assigned to the next created qsup_server_t.
Definition at line 71 of file qsup.c.
Referenced by qsup_init(), and qsup_init_server().
int num_group_rules = 0 |
Definition at line 33 of file qsup.c.
Referenced by qsup_add_group_constraints(), and qsup_init().
int num_user_rules = 0 |
Definition at line 36 of file qsup.c.
Referenced by qsup_add_user_constraints(), and qsup_init().
qsup_level_t qsup_levels[MAX_NUM_LEVELS] [static] |
qsup_user_t* qsup_users [static] |
Definition at line 38 of file qsup.c.
Referenced by main(), qsup_init_server(), and qsup_reserve_spare().
qos_bw_t tot_gua_bw = 0 [static] |
Sum of guaranteed bandwidths of accepted servers.
Definition at line 98 of file qsup.c.
Referenced by qsup_cleanup_server(), qsup_init(), and qsup_init_server().
qos_bw_t tot_used_gua_bw = 0 [static] |
Sum of actually used guaranteed bw by all servers.
Definition at line 100 of file qsup.c.
Referenced by qsup_init(), and qsup_set_required_bw().