All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yi Sun <yi.y.sun@linux.intel.com>
To: xen-devel@lists.xenproject.org
Cc: wei.liu2@citrix.com, he.chen@linux.intel.com,
	andrew.cooper3@citrix.com, ian.jackson@eu.citrix.com,
	Yi Sun <yi.y.sun@linux.intel.com>,
	jbeulich@suse.com, chao.p.peng@linux.intel.com
Subject: [RFC 03/16] x86: change 'cbm_type' to 'psr_val_type' to make it general.
Date: Tue, 10 Jan 2017 15:42:22 +0800	[thread overview]
Message-ID: <1484034155-4521-4-git-send-email-yi.y.sun@linux.intel.com> (raw)
In-Reply-To: <1484034155-4521-1-git-send-email-yi.y.sun@linux.intel.com>

This patch changes 'cbm_type' to 'psr_val_type' to make it general.
Then, we can reuse this for every psr allocation feature.

Signed-off-by: Yi Sun <yi.y.sun@linux.intel.com>
---
 xen/arch/x86/domctl.c     | 16 +++++-----
 xen/arch/x86/psr.c        | 80 +++++++++++++++++++++++------------------------
 xen/arch/x86/sysctl.c     |  6 ++--
 xen/include/asm-x86/psr.h | 16 +++++-----
 4 files changed, 59 insertions(+), 59 deletions(-)

diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
index 3b6534b..1f83ab2 100644
--- a/xen/arch/x86/domctl.c
+++ b/xen/arch/x86/domctl.c
@@ -1372,52 +1372,52 @@ long arch_do_domctl(
         case XEN_DOMCTL_PSR_CAT_OP_SET_L3_CBM:
             ret = psr_set_val(d, domctl->u.psr_alloc_op.target,
                               domctl->u.psr_alloc_op.data,
-                              PSR_CBM_TYPE_L3);
+                              PSR_VAL_TYPE_L3);
             break;
 
         case XEN_DOMCTL_PSR_CAT_OP_SET_L3_CODE:
             ret = psr_set_val(d, domctl->u.psr_alloc_op.target,
                               domctl->u.psr_alloc_op.data,
-                              PSR_CBM_TYPE_L3_CODE);
+                              PSR_VAL_TYPE_L3_CODE);
             break;
 
         case XEN_DOMCTL_PSR_CAT_OP_SET_L3_DATA:
             ret = psr_set_val(d, domctl->u.psr_alloc_op.target,
                               domctl->u.psr_alloc_op.data,
-                              PSR_CBM_TYPE_L3_DATA);
+                              PSR_VAL_TYPE_L3_DATA);
             break;
 
         case XEN_DOMCTL_PSR_CAT_OP_SET_L2_CBM:
             ret = psr_set_val(d, domctl->u.psr_alloc_op.target,
                               domctl->u.psr_alloc_op.data,
-                              PSR_CBM_TYPE_L2);
+                              PSR_VAL_TYPE_L2);
             break;
 
         case XEN_DOMCTL_PSR_CAT_OP_GET_L3_CBM:
             ret = psr_get_val(d, domctl->u.psr_alloc_op.target,
                               &domctl->u.psr_alloc_op.data,
-                              PSR_CBM_TYPE_L3);
+                              PSR_VAL_TYPE_L3);
             copyback = 1;
             break;
 
         case XEN_DOMCTL_PSR_CAT_OP_GET_L3_CODE:
             ret = psr_get_val(d, domctl->u.psr_alloc_op.target,
                               &domctl->u.psr_alloc_op.data,
-                              PSR_CBM_TYPE_L3_CODE);
+                              PSR_VAL_TYPE_L3_CODE);
             copyback = 1;
             break;
 
         case XEN_DOMCTL_PSR_CAT_OP_GET_L3_DATA:
             ret = psr_get_val(d, domctl->u.psr_alloc_op.target,
                               &domctl->u.psr_alloc_op.data,
-                              PSR_CBM_TYPE_L3_DATA);
+                              PSR_VAL_TYPE_L3_DATA);
             copyback = 1;
             break;
 
         case XEN_DOMCTL_PSR_CAT_OP_GET_L2_CBM:
             ret = psr_get_val(d, domctl->u.psr_alloc_op.target,
                               &domctl->u.psr_alloc_op.data,
-                              PSR_CBM_TYPE_L2);
+                              PSR_VAL_TYPE_L2);
             copyback = 1;
             break;
 
diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c
index ed1ec2f..2c69cc0 100644
--- a/xen/arch/x86/psr.c
+++ b/xen/arch/x86/psr.c
@@ -118,11 +118,11 @@ struct feat_ops {
     /* get_max_cos_max is used to get feature's cos_max. */
     unsigned int (*get_max_cos_max)(const struct feat_node *feat);
     /* get_feat_info is used to get feature HW info. */
-    bool (*get_feat_info)(const struct feat_node *feat, enum cbm_type type,
+    bool (*get_feat_info)(const struct feat_node *feat, enum psr_val_type type,
                           uint32_t dat[], uint32_t array_len);
     /* get_val is used to get feature COS register value. */
     bool (*get_val)(const struct feat_node *feat, unsigned int cos,
-                   enum cbm_type type, uint64_t *val);
+                   enum psr_val_type type, uint64_t *val);
     /*
      * get_cos_num is used to get the COS registers amount used by the
      * feature for one setting, e.g. CDP uses 2 COSs but CAT uses 1.
@@ -150,14 +150,14 @@ struct feat_ops {
     int (*set_new_val)(uint64_t val[],
                        const struct feat_node *feat,
                        unsigned int old_cos,
-                       enum cbm_type type,
+                       enum psr_val_type type,
                        uint64_t m);
     /*
      * get_cos_max_from_type is used to get the cos_max value of the feature
      * according to input type.
      */
     unsigned int (*get_cos_max_from_type)(const struct feat_node *feat,
-                                          enum cbm_type type);
+                                          enum psr_val_type type);
     /*
      * compare_val is used in set value process to compare if the
      * input value array can match all the features' COS registers values
@@ -350,10 +350,10 @@ static unsigned int l3_cat_get_max_cos_max(const struct feat_node *feat)
 }
 
 static bool l3_cat_get_feat_info(const struct feat_node *feat,
-                                 enum cbm_type type,
+                                 enum psr_val_type type,
                                  uint32_t dat[], uint32_t array_len)
 {
-    if ( !dat || 3 > array_len || type != PSR_CBM_TYPE_L3 )
+    if ( !dat || 3 > array_len || type != PSR_VAL_TYPE_L3 )
         return false;
 
     dat[CBM_LEN] = feat->info.l3_cat_info.cbm_len;
@@ -364,9 +364,9 @@ static bool l3_cat_get_feat_info(const struct feat_node *feat,
 }
 
 static bool l3_cat_get_val(const struct feat_node *feat, unsigned int cos,
-                           enum cbm_type type, uint64_t *val)
+                           enum psr_val_type type, uint64_t *val)
 {
-    if ( type != PSR_CBM_TYPE_L3 )
+    if ( type != PSR_VAL_TYPE_L3 )
         return false;
 
     if ( cos > feat->info.l3_cat_info.cos_max )
@@ -401,10 +401,10 @@ static int l3_cat_get_old_val(uint64_t val[],
 static int l3_cat_set_new_val(uint64_t val[],
                               const struct feat_node *feat,
                               unsigned int old_cos,
-                              enum cbm_type type,
+                              enum psr_val_type type,
                               uint64_t m)
 {
-    if ( type != PSR_CBM_TYPE_L3 )
+    if ( type != PSR_VAL_TYPE_L3 )
         /* L3 CAT uses one COS. Skip it. */
         return 1;
 
@@ -418,9 +418,9 @@ static int l3_cat_set_new_val(uint64_t val[],
 }
 
 static unsigned int l3_cat_get_cos_max_from_type(const struct feat_node *feat,
-                                                 enum cbm_type type)
+                                                 enum psr_val_type type)
 {
-    if ( type != PSR_CBM_TYPE_L3 )
+    if ( type != PSR_VAL_TYPE_L3 )
         return 0;
 
     return feat->info.l3_cat_info.cos_max;
@@ -557,11 +557,11 @@ static unsigned int l3_cdp_get_max_cos_max(const struct feat_node *feat)
 }
 
 static bool l3_cdp_get_feat_info(const struct feat_node *feat,
-                                 enum cbm_type type,
+                                 enum psr_val_type type,
                                  uint32_t dat[], uint32_t array_len)
 {
     if ( !dat || 3 > array_len ||
-         ( type != PSR_CBM_TYPE_L3_DATA && type != PSR_CBM_TYPE_L3_CODE) )
+         ( type != PSR_VAL_TYPE_L3_DATA && type != PSR_VAL_TYPE_L3_CODE) )
         return false;
 
     dat[CBM_LEN] = feat->info.l3_cdp_info.cbm_len;
@@ -572,16 +572,16 @@ static bool l3_cdp_get_feat_info(const struct feat_node *feat,
 }
 
 static bool l3_cdp_get_val(const struct feat_node *feat, unsigned int cos,
-                           enum cbm_type type, uint64_t *val)
+                           enum psr_val_type type, uint64_t *val)
 {
-    if ( type != PSR_CBM_TYPE_L3_DATA && type != PSR_CBM_TYPE_L3_CODE )
+    if ( type != PSR_VAL_TYPE_L3_DATA && type != PSR_VAL_TYPE_L3_CODE )
         return false;
 
     if ( cos > feat->info.l3_cdp_info.cos_max )
         /* Use default value. */
         cos = 0;
 
-    if ( type == PSR_CBM_TYPE_L3_DATA )
+    if ( type == PSR_VAL_TYPE_L3_DATA )
         *val = get_cdp_data(feat, cos);
     else
         *val = get_cdp_code(feat, cos);
@@ -614,17 +614,17 @@ static int l3_cdp_get_old_val(uint64_t val[],
 static int l3_cdp_set_new_val(uint64_t val[],
                               const struct feat_node *feat,
                               unsigned int old_cos,
-                              enum cbm_type type,
+                              enum psr_val_type type,
                               uint64_t m)
 {
-    if ( type != PSR_CBM_TYPE_L3_DATA && type != PSR_CBM_TYPE_L3_CODE )
+    if ( type != PSR_VAL_TYPE_L3_DATA && type != PSR_VAL_TYPE_L3_CODE )
         /* CDP uses two COSs. Skip them outside. */
         return 2;
 
     if ( !psr_check_cbm(feat->info.l3_cdp_info.cbm_len, m) )
         return -EINVAL;
 
-    if ( type == PSR_CBM_TYPE_L3_DATA )
+    if ( type == PSR_VAL_TYPE_L3_DATA )
         val[0] = m;
     else
         val[1] = m;
@@ -634,9 +634,9 @@ static int l3_cdp_set_new_val(uint64_t val[],
 }
 
 static unsigned int l3_cdp_get_cos_max_from_type(const struct feat_node *feat,
-                                                 enum cbm_type type)
+                                                 enum psr_val_type type)
 {
-    if ( type != PSR_CBM_TYPE_L3_DATA && type != PSR_CBM_TYPE_L3_CODE )
+    if ( type != PSR_VAL_TYPE_L3_DATA && type != PSR_VAL_TYPE_L3_CODE )
         return 0;
 
     return feat->info.l3_cdp_info.cos_max;
@@ -775,10 +775,10 @@ static unsigned int l2_cat_get_max_cos_max(const struct feat_node *feat)
 }
 
 static bool l2_cat_get_feat_info(const struct feat_node *feat,
-                                 enum cbm_type type,
+                                 enum psr_val_type type,
                                  uint32_t dat[], uint32_t array_len)
 {
-    if ( !dat || 2 > array_len || type != PSR_CBM_TYPE_L2 )
+    if ( !dat || 2 > array_len || type != PSR_VAL_TYPE_L2 )
         return false;
 
     dat[CBM_LEN] = feat->info.l2_cat_info.cbm_len;
@@ -788,9 +788,9 @@ static bool l2_cat_get_feat_info(const struct feat_node *feat,
 }
 
 static bool l2_cat_get_val(const struct feat_node *feat, unsigned int cos,
-                          enum cbm_type type, uint64_t *val)
+                          enum psr_val_type type, uint64_t *val)
 {
-    if ( type != PSR_CBM_TYPE_L2 )
+    if ( type != PSR_VAL_TYPE_L2 )
          return false;
 
     if ( cos > feat->info.l2_cat_info.cos_max )
@@ -824,10 +824,10 @@ static int l2_cat_get_old_val(uint64_t val[],
 static int l2_cat_set_new_val(uint64_t val[],
                               const struct feat_node *feat,
                               unsigned int old_cos,
-                              enum cbm_type type,
+                              enum psr_val_type type,
                               uint64_t m)
 {
-    if ( type != PSR_CBM_TYPE_L2 )
+    if ( type != PSR_VAL_TYPE_L2 )
         return 1;
 
     if ( !psr_check_cbm(feat->info.l2_cat_info.cbm_len, m) )
@@ -840,9 +840,9 @@ static int l2_cat_set_new_val(uint64_t val[],
 }
 
 static unsigned int l2_cat_get_cos_max_from_type(const struct feat_node *feat,
-                                                 enum cbm_type type)
+                                                 enum psr_val_type type)
 {
-    if ( type != PSR_CBM_TYPE_L2 )
+    if ( type != PSR_VAL_TYPE_L2 )
         return 0;
 
     return feat->info.l2_cat_info.cos_max;
@@ -1134,7 +1134,7 @@ static struct psr_socket_info *get_socket_info(unsigned int socket)
     return socket_info + socket;
 }
 
-int psr_get_info(unsigned int socket, enum cbm_type type,
+int psr_get_info(unsigned int socket, enum psr_val_type type,
                  uint32_t dat[], uint32_t array_len)
 {
     struct psr_socket_info *info = get_socket_info(socket);
@@ -1151,7 +1151,7 @@ int psr_get_info(unsigned int socket, enum cbm_type type,
 }
 
 int psr_get_val(struct domain *d, unsigned int socket,
-                uint64_t *val, enum cbm_type type)
+                uint64_t *val, enum psr_val_type type)
 {
     const struct psr_socket_info *info = get_socket_info(socket);
     unsigned int cos = d->arch.psr_cos_ids[socket];
@@ -1187,7 +1187,7 @@ static int get_old_set_new(uint64_t *val,
                            uint32_t array_len,
                            const struct psr_socket_info *info,
                            unsigned int old_cos,
-                           enum cbm_type type,
+                           enum psr_val_type type,
                            uint64_t m)
 {
     const struct feat_node *feat_tmp;
@@ -1226,7 +1226,7 @@ static int get_old_set_new(uint64_t *val,
 }
 
 static int find_cos(const uint64_t *val, uint32_t array_len,
-                    enum cbm_type type,
+                    enum psr_val_type type,
                     const struct psr_socket_info *info)
 {
     unsigned int cos;
@@ -1309,7 +1309,7 @@ static bool exceeds_cos_max(const uint64_t *val,
 static int alloc_new_cos(const struct psr_socket_info *info,
                          const uint64_t *val, uint32_t array_len,
                          unsigned int old_cos,
-                         enum cbm_type type)
+                         enum psr_val_type type)
 {
     unsigned int cos;
     unsigned int cos_max = 0;
@@ -1419,7 +1419,7 @@ static int write_psr_msr(unsigned int socket, unsigned int cos,
 }
 
 int psr_set_val(struct domain *d, unsigned int socket,
-                uint64_t val, enum cbm_type type)
+                uint64_t val, enum psr_val_type type)
 {
     unsigned int old_cos;
     int cos, ret;
@@ -1434,14 +1434,14 @@ int psr_set_val(struct domain *d, unsigned int socket,
 
     /* Judge if feature is enabled. */
     switch ( type ) {
-    case PSR_CBM_TYPE_L3:
+    case PSR_VAL_TYPE_L3:
         flag = PSR_SOCKET_L3_CAT;
         break;
-    case PSR_CBM_TYPE_L3_DATA:
-    case PSR_CBM_TYPE_L3_CODE:
+    case PSR_VAL_TYPE_L3_DATA:
+    case PSR_VAL_TYPE_L3_CODE:
         flag = PSR_SOCKET_L3_CDP;
         break;
-    case PSR_CBM_TYPE_L2:
+    case PSR_VAL_TYPE_L2:
         flag = PSR_SOCKET_L2_CAT;
         break;
     default:
diff --git a/xen/arch/x86/sysctl.c b/xen/arch/x86/sysctl.c
index cff56bb..739909b 100644
--- a/xen/arch/x86/sysctl.c
+++ b/xen/arch/x86/sysctl.c
@@ -179,7 +179,7 @@ long arch_do_sysctl(
         {
             uint32_t dat[3];
             ret = psr_get_info(sysctl->u.psr_alloc_op.target,
-                               PSR_CBM_TYPE_L3, dat, 3);
+                               PSR_VAL_TYPE_L3, dat, 3);
 
             if ( !ret )
             {
@@ -194,7 +194,7 @@ long arch_do_sysctl(
                  * output values to CDP's if it is enabled.
                  */
                 ret = psr_get_info(sysctl->u.psr_alloc_op.target,
-                               PSR_CBM_TYPE_L3_CODE, dat, 3);
+                               PSR_VAL_TYPE_L3_CODE, dat, 3);
                 if ( !ret )
                 {
                     sysctl->u.psr_alloc_op.u.l3_info.cbm_len = dat[CBM_LEN];
@@ -211,7 +211,7 @@ long arch_do_sysctl(
         {
             uint32_t dat[2];
             ret = psr_get_info(sysctl->u.psr_alloc_op.target,
-                               PSR_CBM_TYPE_L2, dat, 2);
+                               PSR_VAL_TYPE_L2, dat, 2);
             if ( ret )
                 break;
 
diff --git a/xen/include/asm-x86/psr.h b/xen/include/asm-x86/psr.h
index ee65fe5..4d52918 100644
--- a/xen/include/asm-x86/psr.h
+++ b/xen/include/asm-x86/psr.h
@@ -52,11 +52,11 @@ struct psr_cmt {
     struct psr_cmt_l3 l3;
 };
 
-enum cbm_type {
-    PSR_CBM_TYPE_L3,
-    PSR_CBM_TYPE_L3_CODE,
-    PSR_CBM_TYPE_L3_DATA,
-    PSR_CBM_TYPE_L2,
+enum psr_val_type {
+    PSR_VAL_TYPE_L3,
+    PSR_VAL_TYPE_L3_CODE,
+    PSR_VAL_TYPE_L3_DATA,
+    PSR_VAL_TYPE_L2,
 };
 
 extern struct psr_cmt *psr_cmt;
@@ -70,12 +70,12 @@ int psr_alloc_rmid(struct domain *d);
 void psr_free_rmid(struct domain *d);
 void psr_ctxt_switch_to(struct domain *d);
 
-int psr_get_info(unsigned int socket, enum cbm_type type,
+int psr_get_info(unsigned int socket, enum psr_val_type type,
                  uint32_t dat[], uint32_t array_len);
 int psr_get_val(struct domain *d, unsigned int socket,
-                uint64_t *val, enum cbm_type type);
+                uint64_t *val, enum psr_val_type type);
 int psr_set_val(struct domain *d, unsigned int socket,
-                uint64_t val, enum cbm_type type);
+                uint64_t val, enum psr_val_type type);
 
 int psr_domain_init(struct domain *d);
 void psr_domain_free(struct domain *d);
-- 
1.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2017-01-10  7:43 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-10  7:42 [RFC 00/16] Enable Memory Bandwidth Allocation in Xen Yi Sun
2017-01-10  7:42 ` [RFC 01/16] docs: create Memory Bandwidth Allocation (MBA) feature document Yi Sun
2017-02-23 20:46   ` Meng Xu
2017-02-24  5:07     ` Yi Sun
2017-02-24 15:53       ` Meng Xu
2017-02-27  4:39         ` Yi Sun
2017-01-10  7:42 ` [RFC 02/16] Rename sysctl/domctl interface and xsm policy to make them general Yi Sun
2017-01-10  7:42 ` Yi Sun [this message]
2017-01-10  7:42 ` [RFC 04/16] x86: implement data structure of MBA Yi Sun
2017-01-10  7:42 ` [RFC 05/16] x86: parse config parameters for MBA Yi Sun
2017-01-10  7:42 ` [RFC 06/16] x86: implement init flow " Yi Sun
2017-01-10  7:42 ` [RFC 07/16] x86: implement get hw info " Yi Sun
2017-01-10  7:42 ` [RFC 08/16] x86: implement get value " Yi Sun
2017-01-10  7:42 ` [RFC 09/16] x86: implement set " Yi Sun
2017-01-10  7:42 ` [RFC 10/16] tools: refactor codes to make get hw info interface be general Yi Sun
2017-01-10  7:42 ` [RFC 11/16] tools: refactor codes to make get val be more general Yi Sun
2017-01-10  7:42 ` [RFC 12/16] tools: refactor codes to make set " Yi Sun
2017-01-10  7:42 ` [RFC 13/16] tools: implemet get hw info flow for MBA Yi Sun
2017-01-10  7:42 ` [RFC 14/16] tools: implemet get value " Yi Sun
2017-01-10  7:42 ` [RFC 15/16] tools: implemet set " Yi Sun
2017-01-10  7:42 ` [RFC 16/16] docs: add MBA description in docs Yi Sun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1484034155-4521-4-git-send-email-yi.y.sun@linux.intel.com \
    --to=yi.y.sun@linux.intel.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=chao.p.peng@linux.intel.com \
    --cc=he.chen@linux.intel.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.