Message ID | 1487148579-7243-15-git-send-email-yi.y.sun@linux.intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Wed, Feb 15, 2017 at 04:49:29PM +0800, Yi Sun wrote: [...] > > static void __init parse_psr_bool(char *s, char *value, char *feature, > diff --git a/xen/arch/x86/sysctl.c b/xen/arch/x86/sysctl.c > index e340baa..568bfe9 100644 > --- a/xen/arch/x86/sysctl.c > +++ b/xen/arch/x86/sysctl.c > @@ -181,9 +181,27 @@ long arch_do_sysctl( > ret = psr_get_info(sysctl->u.psr_cat_op.target, > PSR_CBM_TYPE_L3, data, 3); > > - sysctl->u.psr_cat_op.u.l3_info.cbm_len = data[CBM_LEN]; > - sysctl->u.psr_cat_op.u.l3_info.cos_max = data[COS_MAX]; > - sysctl->u.psr_cat_op.u.l3_info.flags = data[PSR_FLAG]; > + if ( !ret ) > + { > + sysctl->u.psr_cat_op.u.l3_info.cbm_len = data[CBM_LEN]; > + sysctl->u.psr_cat_op.u.l3_info.cos_max = data[COS_MAX]; > + sysctl->u.psr_cat_op.u.l3_info.flags = data[PSR_FLAG]; > + } else { > + /* > + * Check if CDP is enabled. > + * > + * Per spec, L3 CAT and CDP cannot co-exist. So, we need replace > + * output values to CDP's if it is enabled. > + */ > + ret = psr_get_info(sysctl->u.psr_cat_op.target, > + PSR_CBM_TYPE_L3_CODE, data, 3); Indentation. > + if ( !ret ) > + { > + sysctl->u.psr_cat_op.u.l3_info.cbm_len = data[CBM_LEN]; > + sysctl->u.psr_cat_op.u.l3_info.cos_max = data[COS_MAX]; > + sysctl->u.psr_cat_op.u.l3_info.flags = data[PSR_FLAG]; > + } > + } > > if ( !ret && __copy_field_to_guest(u_sysctl, sysctl, u.psr_cat_op) ) > ret = -EFAULT; > -- > 1.9.1 >
On Wed, Feb 15, 2017 at 04:49:29PM +0800, Yi Sun wrote: > This patch implements get HW info flow for CDP including L3 CDP callback > function. > > It also changes sysctl function to make it work for CDP. > > With this patch, 'psr-hwinfo' can work for L3 CDP. > > Signed-off-by: Yi Sun <yi.y.sun@linux.intel.com> > --- > xen/arch/x86/psr.c | 18 ++++++++++++++++++ > xen/arch/x86/sysctl.c | 24 +++++++++++++++++++++--- > 2 files changed, 39 insertions(+), 3 deletions(-) > > diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c > index 4c08779..72c9888 100644 > --- a/xen/arch/x86/psr.c > +++ b/xen/arch/x86/psr.c > @@ -270,6 +270,10 @@ static enum psr_feat_type psr_cbm_type_to_feat_type(enum cbm_type type) > case PSR_CBM_TYPE_L3: > feat_type = PSR_SOCKET_L3_CAT; > break; > + case PSR_CBM_TYPE_L3_DATA: > + case PSR_CBM_TYPE_L3_CODE: > + feat_type = PSR_SOCKET_L3_CDP; > + break; > default: > feat_type = PSR_SOCKET_UNKNOWN; > break; > @@ -528,8 +532,22 @@ static unsigned int l3_cdp_get_cos_max(const struct feat_node *feat) > return feat->info.l3_cdp_info.cos_max; > } > > +static bool l3_cdp_get_feat_info(const struct feat_node *feat, > + uint32_t data[], uint32_t array_len) > +{ > + if ( !data || 3 > array_len ) array_len != 3? > + return false; > + > + data[CBM_LEN] = feat->info.l3_cdp_info.cbm_len; > + data[COS_MAX] = feat->info.l3_cdp_info.cos_max; > + data[PSR_FLAG] |= XEN_SYSCTL_PSR_CAT_L3_CDP; > + > + return true; > +} > + > struct feat_ops l3_cdp_ops = { > .get_cos_max = l3_cdp_get_cos_max, > + .get_feat_info = l3_cdp_get_feat_info, > }; > > static void __init parse_psr_bool(char *s, char *value, char *feature, > diff --git a/xen/arch/x86/sysctl.c b/xen/arch/x86/sysctl.c > index e340baa..568bfe9 100644 > --- a/xen/arch/x86/sysctl.c > +++ b/xen/arch/x86/sysctl.c > @@ -181,9 +181,27 @@ long arch_do_sysctl( > ret = psr_get_info(sysctl->u.psr_cat_op.target, > PSR_CBM_TYPE_L3, data, 3); > > - sysctl->u.psr_cat_op.u.l3_info.cbm_len = data[CBM_LEN]; > - sysctl->u.psr_cat_op.u.l3_info.cos_max = data[COS_MAX]; > - sysctl->u.psr_cat_op.u.l3_info.flags = data[PSR_FLAG]; > + if ( !ret ) > + { > + sysctl->u.psr_cat_op.u.l3_info.cbm_len = data[CBM_LEN]; > + sysctl->u.psr_cat_op.u.l3_info.cos_max = data[COS_MAX]; > + sysctl->u.psr_cat_op.u.l3_info.flags = data[PSR_FLAG]; > + } else { Coding style, should be: } else { Roger.
diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c index 4c08779..72c9888 100644 --- a/xen/arch/x86/psr.c +++ b/xen/arch/x86/psr.c @@ -270,6 +270,10 @@ static enum psr_feat_type psr_cbm_type_to_feat_type(enum cbm_type type) case PSR_CBM_TYPE_L3: feat_type = PSR_SOCKET_L3_CAT; break; + case PSR_CBM_TYPE_L3_DATA: + case PSR_CBM_TYPE_L3_CODE: + feat_type = PSR_SOCKET_L3_CDP; + break; default: feat_type = PSR_SOCKET_UNKNOWN; break; @@ -528,8 +532,22 @@ static unsigned int l3_cdp_get_cos_max(const struct feat_node *feat) return feat->info.l3_cdp_info.cos_max; } +static bool l3_cdp_get_feat_info(const struct feat_node *feat, + uint32_t data[], uint32_t array_len) +{ + if ( !data || 3 > array_len ) + return false; + + data[CBM_LEN] = feat->info.l3_cdp_info.cbm_len; + data[COS_MAX] = feat->info.l3_cdp_info.cos_max; + data[PSR_FLAG] |= XEN_SYSCTL_PSR_CAT_L3_CDP; + + return true; +} + struct feat_ops l3_cdp_ops = { .get_cos_max = l3_cdp_get_cos_max, + .get_feat_info = l3_cdp_get_feat_info, }; static void __init parse_psr_bool(char *s, char *value, char *feature, diff --git a/xen/arch/x86/sysctl.c b/xen/arch/x86/sysctl.c index e340baa..568bfe9 100644 --- a/xen/arch/x86/sysctl.c +++ b/xen/arch/x86/sysctl.c @@ -181,9 +181,27 @@ long arch_do_sysctl( ret = psr_get_info(sysctl->u.psr_cat_op.target, PSR_CBM_TYPE_L3, data, 3); - sysctl->u.psr_cat_op.u.l3_info.cbm_len = data[CBM_LEN]; - sysctl->u.psr_cat_op.u.l3_info.cos_max = data[COS_MAX]; - sysctl->u.psr_cat_op.u.l3_info.flags = data[PSR_FLAG]; + if ( !ret ) + { + sysctl->u.psr_cat_op.u.l3_info.cbm_len = data[CBM_LEN]; + sysctl->u.psr_cat_op.u.l3_info.cos_max = data[COS_MAX]; + sysctl->u.psr_cat_op.u.l3_info.flags = data[PSR_FLAG]; + } else { + /* + * Check if CDP is enabled. + * + * Per spec, L3 CAT and CDP cannot co-exist. So, we need replace + * output values to CDP's if it is enabled. + */ + ret = psr_get_info(sysctl->u.psr_cat_op.target, + PSR_CBM_TYPE_L3_CODE, data, 3); + if ( !ret ) + { + sysctl->u.psr_cat_op.u.l3_info.cbm_len = data[CBM_LEN]; + sysctl->u.psr_cat_op.u.l3_info.cos_max = data[COS_MAX]; + sysctl->u.psr_cat_op.u.l3_info.flags = data[PSR_FLAG]; + } + } if ( !ret && __copy_field_to_guest(u_sysctl, sysctl, u.psr_cat_op) ) ret = -EFAULT;
This patch implements get HW info flow for CDP including L3 CDP callback function. It also changes sysctl function to make it work for CDP. With this patch, 'psr-hwinfo' can work for L3 CDP. Signed-off-by: Yi Sun <yi.y.sun@linux.intel.com> --- xen/arch/x86/psr.c | 18 ++++++++++++++++++ xen/arch/x86/sysctl.c | 24 +++++++++++++++++++++--- 2 files changed, 39 insertions(+), 3 deletions(-)