00001 #include "qres_config.h"
00002 #define QOS_DEBUG_LEVEL QSUP_MOD_DEBUG_LEVEL
00003 #include <linux/aquosa/qos_debug.h>
00004
00005 #ifdef PROF_QSUP_MOD
00006 # define QOS_PROFILE
00007 #endif
00008 #include <linux/aquosa/qos_prof.h>
00009
00010 #include "qsup_gw_ks.h"
00011 #include "qsup.h"
00012 #include <linux/aquosa/kal_sched.h>
00013 #include <linux/aquosa/qos_memory.h>
00014 #include <linux/aquosa/rres_interface.h>
00015
00016 #include <linux/kernel.h>
00017 #include <linux/version.h>
00018 #include <linux/module.h>
00019 #include <asm/uaccess.h>
00020 #include <linux/sched.h>
00021
00022 #define QSUP_DEFAULT_SRV_MAX_BW r2bw(45000, 50000)
00023 #define QSUP_DEFAULT_SRV_MAX_MIN_BW r2bw(40000, 50000)
00024
00025 qos_rv qsup_init_ks(void) {
00026 qos_log_debug("Starting function");
00027
00028 qos_chk_ok_ret(qsup_init());
00029
00030 qos_log_debug("Ending function");
00031 return QOS_OK;
00032 }
00033
00034 qos_rv qsup_cleanup_ks(void) {
00035 return qsup_cleanup();
00036 }
00037
00048 qos_rv qsup_gw_ks(qsup_op_t op, void __user *up_iparams, unsigned long size) {
00049 qsup_iparams_t iparams;
00050 qos_rv err = QOS_OK;
00051 kal_irq_state flags;
00052
00053 qos_log_debug("Starting qsup_gw_ks()");
00054
00055 if (size != sizeof(qsup_iparams_t)) {
00056 qos_log_err("Wrong size");
00057 return QOS_E_INTERNAL_ERROR;
00058 }
00059
00060 if (copy_from_user(&iparams, up_iparams, sizeof(qsup_iparams_t)))
00061 return QOS_E_INVALID_PARAM;
00062
00063 kal_spin_lock_irqsave(rres_get_spinlock(), &flags);
00064
00065 if (! qsup_authorize_op(&iparams)) {
00066 kal_spin_unlock_irqrestore(rres_get_spinlock(), &flags);
00067 return QOS_E_UNAUTHORIZED;
00068 }
00069
00070 switch (op) {
00071 case QSUP_OP_ADD_LEVEL_RULE:
00072 err = qsup_add_level_rule(iparams.u.level_rule.level_id, iparams.u.level_rule.max_level_bw);
00073 break;
00074 case QSUP_OP_ADD_GROUP_RULE:
00075 err = qsup_add_group_constraints(iparams.u.group_rule.gid,
00076 &iparams.u.group_rule.constr);
00077 break;
00078 case QSUP_OP_ADD_USER_RULE:
00079 err = qsup_add_group_constraints(iparams.u.user_rule.uid,
00080 &iparams.u.user_rule.constr);
00081 case QSUP_OP_FIND_CONSTR:
00082 iparams.u.found_rule.constr =
00083 *(qsup_find_constr(iparams.u.found_rule.uid, iparams.u.found_rule.gid));
00084 kal_spin_unlock_irqrestore(rres_get_spinlock(), &flags);
00085 if (copy_to_user(up_iparams, &iparams, sizeof(qsup_iparams_t)))
00086 err = QOS_E_INTERNAL_ERROR;
00087 return err;
00088 break;
00089 case QSUP_OP_GET_AVAIL_GUA_BW:
00090 err = qsup_get_avail_gua_bw(iparams.u.avail.uid, iparams.u.avail.gid,
00091 &iparams.u.avail.avail_gua_bw);
00092 if (err == QOS_OK) {
00093 kal_spin_unlock_irqrestore(rres_get_spinlock(), &flags);
00094 if (copy_to_user(up_iparams, &iparams, sizeof(qsup_iparams_t)))
00095 err = QOS_E_INTERNAL_ERROR;
00096 return err;
00097 }
00098 break;
00099 case QSUP_OP_RESERVE_SPARE:
00100 err = qsup_reserve_spare(iparams.u.spare_bw);
00101 break;
00102 default:
00103 qos_log_err("Unhandled operation code");
00104 err = QOS_E_INTERNAL_ERROR;
00105 }
00106
00107 kal_spin_unlock_irqrestore(rres_get_spinlock(), &flags);
00108 return err;
00109 }