00001
00002 qos_rv qres_setup_qsup_for_rres(server_t *rres, qsup_server_t *qsup);
00003
00011 typedef struct qres_ext_data {
00012 void *data[QRES_SLOT_NUMBER];
00013 } qres_ext_data_t;
00014
00016 qos_rv qres_attach_to_ext_data(qres_ext_data_t * ext_data, qres_slot_t s, void *data);
00017
00018
00019
00020
00021
00026 typedef enum {
00027 QRES_SLOT_QSUP,
00028 QRES_SLOT_QMGR,
00029 QRES_SLOT_RFU,
00030 QRES_SLOT_NUMBER
00031 } qres_slot_t;
00032
00037 qos_rv qres_attach_data_to_rres(server_t *rres, qres_slot_t s, void *data);
00038
00043 qos_rv qres_attach_data_to_task(struct task_struct *tsk, qres_slot_t s, void *data);
00044
00050 qos_rv qres_retrieve_from_rres(server_t *rres, int s, void **data);
00051
00052 static inline qos_rv qres_retrieve_from_task(struct task_struct *tsk, int s, void **data) {
00053 server_t *rres = rres_find_by_task(tsk);
00054 if (rres == 0)
00055 return QOS_E_INCONSISTENT_STATE;
00056 return qres_retrieve_from_rres(rres, s, data);
00057 }
00058
00060 qos_rv qres_setup_qsup_for_rres(server_t *rres, qsup_server_t *qsup) {
00061 int i;
00063 qres_ext_data_t *ext_data = qos_malloc(sizeof(qres_ext_data_t));
00064 if (ext_data == 0) {
00065 qos_log_err("Couldn't allocate memory for ext_data");
00066 return QOS_E_NO_MEMORY;
00067 }
00068
00069 for (i=0; i<QRES_SLOT_NUMBER; i++)
00070 ext_data->data[i] = 0;
00071
00073 rres_set_ext_data(rres, ext_data);
00074
00076 qres_attach_to_ext_data(ext_data, QRES_SLOT_QSUP, qsup);
00077
00078 return QOS_OK;
00079 }
00080
00081 qos_rv qres_attach_to_ext_data(qres_ext_data_t * ext_data, qres_slot_t s, void *data) {
00082 if (ext_data == 0) {
00083 qos_log_err("No ext_data set in rres server, yet");
00084 return QOS_E_INTERNAL_ERROR;
00085 }
00086 if ((s < 0) || (s >= QRES_SLOT_NUMBER)) {
00087 qos_log_err("Index out of range");
00088 return QOS_E_INVALID_PARAM;
00089 }
00090 ext_data->data[s] = data;
00091 return QOS_OK;
00092 }
00093
00094 qos_rv qres_attach_data_to_rres(server_t *rres, qres_slot_t s, void *data) {
00095 return qres_attach_to_ext_data(rres_get_ext_data(rres), s, data);
00096 }
00097
00098 qos_rv qres_attach_data_to_task(struct task_struct *tsk, qres_slot_t s, void *data) {
00099 server_t *rres = rres_find_by_task(tsk);
00100 if (rres == 0)
00101 return QOS_E_INCONSISTENT_STATE;
00102 if (s == QRES_SLOT_QSUP)
00103 return QOS_E_INVALID_PARAM;
00104 return qres_attach_data_to_rres(rres, s, data);
00105 }
00106
00107 qos_rv qres_retrieve_from_rres(server_t *rres, int s, void **data) {
00108 qres_ext_data_t * ext_data;
00109 if (rres == 0) {
00110 qos_log_err("NULL rres pointer");
00111 return QOS_E_INTERNAL_ERROR;
00112 }
00113 ext_data = rres_get_ext_data(rres);
00114 if (ext_data == 0) {
00115 qos_log_err("No ext_data set in rres module");
00116 return QOS_E_INTERNAL_ERROR;
00117 }
00118 if ((s < 0) || (s >= QRES_SLOT_NUMBER)) {
00119 qos_log_err("Index out of range");
00120 return QOS_E_INVALID_PARAM;
00121 }
00122 *data = ext_data->data[s];
00123 return QOS_OK;
00124 }
00125
00126 EXPORT_SYMBOL_GPL(qres_attach_data_to_rres);
00127 EXPORT_SYMBOL_GPL(qres_attach_data_to_task);
00128 EXPORT_SYMBOL_GPL(qres_retrieve_from_rres);