00001 #ifndef __QOS_TYPES_H__
00002 #define __QOS_TYPES_H__
00003
00004 #include "qos_ul.h"
00005 #include <linux/aquosa/rres_config.h>
00006
00007 #ifdef QOS_KS
00008 # include <linux/types.h>
00009 #else
00010 # include <sys/types.h>
00011 #endif
00012
00013
00014
00015
00017 typedef long qres_time_t;
00019 typedef long long qres_atime_t;
00020
00021 #define QRES_TIME_FMT "%ld"
00022 #define QRES_ATIME_FMT "%lld"
00024 static inline struct timespec qres_time_to_timespec(qres_time_t time) {
00025 struct timespec dummy_ts;
00026 dummy_ts.tv_sec = time / 1000000;
00027 dummy_ts.tv_nsec = (time % 1000000) * 1000;
00028 return dummy_ts;
00029 }
00030
00031 static inline qres_time_t qres_timespec_to_time(struct timespec ts) {
00032 return (qres_time_t)
00033 ts.tv_sec * 1000000 + (qres_time_t) ts.tv_nsec / 1000;
00034 }
00035
00036 typedef int qres_sid_t;
00037 #define QRES_SID_FMT "%d"
00039 #define QRES_SID_NULL ((qres_sid_t)0)
00048 typedef int qos_bool_t;
00049
00061 typedef pid_t tid_t;
00062
00069 typedef unsigned long int qos_bw_t;
00070
00072 #define QOS_BW_FMT "%lu"
00073
00079 #define QOS_BW_BITS 24
00080
00084 #define MAX_BW (1ul << QOS_BW_BITS)
00085
00089 #define U_LUB r2bw_c(RRES_U_LUB, 100)
00090
00091 #ifndef QOS_KS
00092
00096 static inline qos_bw_t d2bw(double b) {
00097 return (qos_bw_t) (b * (double) MAX_BW);
00098 }
00099
00101 #define md2bw(b) ((qos_bw_t) (b * (double) MAX_BW))
00102
00107 static inline double bw2d(qos_bw_t b) {
00108 return ((double) (b)) / ((double) MAX_BW);
00109 }
00110 #endif
00111
00115 static inline qos_bw_t r2bw(qres_time_t Q, qres_time_t P) {
00116 return ul_shl_div((unsigned long) Q, QOS_BW_BITS, (unsigned long) P);
00117 }
00118
00122 static inline qos_bw_t r2bw_ceil(qres_time_t Q, qres_time_t P) {
00123 return ul_shl_ceil((unsigned long) Q, QOS_BW_BITS, (unsigned long) P);
00124 }
00125
00126 static inline unsigned long div_by_bw(unsigned long num, qos_bw_t bw) {
00127 return ul_shl_div(num, QOS_BW_BITS, bw);
00128 }
00129
00130 static inline unsigned long mul_by_bw(unsigned long value, qos_bw_t bw) {
00131 return ul_mul_shr(value, bw, QOS_BW_BITS);
00132 }
00133
00138 #define r2bw_c(Q, P) ((qos_bw_t) ((((unsigned long long) (Q)) << QOS_BW_BITS) / (P)))
00139
00140 #include "qos_debug.h"
00141
00145 static inline qres_time_t bw2Q(qos_bw_t bw, qres_time_t P) {
00146
00147
00148
00149
00150
00151 return ul_mul_shr(bw, P, QOS_BW_BITS);
00152 }
00153
00155 #define QRES_DEF_P 100000
00156
00162 #define QOS_F_DEFAULT 0x00000001
00163
00170 #define QOS_F_SOFT 0x00000002
00171 #define QOS_F_NOMULTI 0x00000004
00172 #define QOS_F_PERSISTENT 0x00000008
00174 #endif