1 /****************************************************************************
2  * (C) 2006 - Emmanuel Ackaouy - XenSource Inc.
3  ****************************************************************************
4  *
5  *        File: xc_csched.c
6  *      Author: Emmanuel Ackaouy
7  *
8  * Description: XC Interface to the credit scheduler
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation;
13  * version 2.1 of the License.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with this library; If not, see <http://www.gnu.org/licenses/>.
22  */
23 
24 #include "xc_private.h"
25 
26 int
xc_sched_credit2_domain_set(xc_interface * xch,uint32_t domid,struct xen_domctl_sched_credit2 * sdom)27 xc_sched_credit2_domain_set(
28     xc_interface *xch,
29     uint32_t domid,
30     struct xen_domctl_sched_credit2 *sdom)
31 {
32     DECLARE_DOMCTL;
33 
34     domctl.cmd = XEN_DOMCTL_scheduler_op;
35     domctl.domain = domid;
36     domctl.u.scheduler_op.sched_id = XEN_SCHEDULER_CREDIT2;
37     domctl.u.scheduler_op.cmd = XEN_DOMCTL_SCHEDOP_putinfo;
38     domctl.u.scheduler_op.u.credit2 = *sdom;
39 
40     if ( do_domctl(xch, &domctl) )
41         return -1;
42 
43     return 0;
44 }
45 
46 int
xc_sched_credit2_domain_get(xc_interface * xch,uint32_t domid,struct xen_domctl_sched_credit2 * sdom)47 xc_sched_credit2_domain_get(
48     xc_interface *xch,
49     uint32_t domid,
50     struct xen_domctl_sched_credit2 *sdom)
51 {
52     DECLARE_DOMCTL;
53 
54     domctl.cmd = XEN_DOMCTL_scheduler_op;
55     domctl.domain = domid;
56     domctl.u.scheduler_op.sched_id = XEN_SCHEDULER_CREDIT2;
57     domctl.u.scheduler_op.cmd = XEN_DOMCTL_SCHEDOP_getinfo;
58 
59     if ( do_domctl(xch, &domctl) )
60         return -1;
61 
62     *sdom = domctl.u.scheduler_op.u.credit2;
63 
64     return 0;
65 }
66 
67 int
xc_sched_credit2_params_set(xc_interface * xch,uint32_t cpupool_id,struct xen_sysctl_credit2_schedule * schedule)68 xc_sched_credit2_params_set(
69     xc_interface *xch,
70     uint32_t cpupool_id,
71     struct xen_sysctl_credit2_schedule *schedule)
72 {
73     DECLARE_SYSCTL;
74 
75     sysctl.cmd = XEN_SYSCTL_scheduler_op;
76     sysctl.u.scheduler_op.cpupool_id = cpupool_id;
77     sysctl.u.scheduler_op.sched_id = XEN_SCHEDULER_CREDIT2;
78     sysctl.u.scheduler_op.cmd = XEN_SYSCTL_SCHEDOP_putinfo;
79 
80     sysctl.u.scheduler_op.u.sched_credit2 = *schedule;
81 
82     if ( do_sysctl(xch, &sysctl) )
83         return -1;
84 
85     *schedule = sysctl.u.scheduler_op.u.sched_credit2;
86 
87     return 0;
88 }
89 
90 int
xc_sched_credit2_params_get(xc_interface * xch,uint32_t cpupool_id,struct xen_sysctl_credit2_schedule * schedule)91 xc_sched_credit2_params_get(
92     xc_interface *xch,
93     uint32_t cpupool_id,
94     struct xen_sysctl_credit2_schedule *schedule)
95 {
96     DECLARE_SYSCTL;
97 
98     sysctl.cmd = XEN_SYSCTL_scheduler_op;
99     sysctl.u.scheduler_op.cpupool_id = cpupool_id;
100     sysctl.u.scheduler_op.sched_id = XEN_SCHEDULER_CREDIT2;
101     sysctl.u.scheduler_op.cmd = XEN_SYSCTL_SCHEDOP_getinfo;
102 
103     if ( do_sysctl(xch, &sysctl) )
104         return -1;
105 
106     *schedule = sysctl.u.scheduler_op.u.sched_credit2;
107 
108     return 0;
109 }
110