From patchwork Thu Jul 6 01:53:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi Sun X-Patchwork-Id: 9827433 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6C234602BD for ; Thu, 6 Jul 2017 02:09:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5BB3C285C9 for ; Thu, 6 Jul 2017 02:09:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4FCBE285C7; Thu, 6 Jul 2017 02:09:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DE0F1285C7 for ; Thu, 6 Jul 2017 02:09:11 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dSwCX-0001Cd-OK; Thu, 06 Jul 2017 02:07:29 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dSwCW-0001AE-KB for xen-devel@lists.xenproject.org; Thu, 06 Jul 2017 02:07:28 +0000 Received: from [193.109.254.147] by server-11.bemta-6.messagelabs.com id F4/D2-03612-06B9D595; Thu, 06 Jul 2017 02:07:28 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrJLMWRWlGSWpSXmKPExsXS1tYhrxs7Ozb SYOdrDovvWyYzOTB6HP5whSWAMYo1My8pvyKBNWPS22amgib5ij/7QhoYd4p1MXJyCAlUSszv /sYEYksI8EocWTaDtYuRA8gOkPg+3aqLkQuopIFRomHBazaQGjYBdYnHX3vA6kUElCTurZrMB FLELDCfSeL1+QfMIAlhAWeJWw2vwBpYBFQlDm96wAhi8wp4SrQtX8gGsUxO4uSxyawgNidQ/M jVZnaIgzwkNra/ZprAyLuAkWEVo0ZxalFZapGuoaVeUlFmekZJbmJmjq6hgZlebmpxcWJ6ak5 iUrFecn7uJkZgMDAAwQ7GH8sCDjFKcjApifL+0Y+NFOJLyk+pzEgszogvKs1JLT7EKMPBoSTB qzMLKCdYlJqeWpGWmQMMS5i0BAePkgjvamGgNG9xQWJucWY6ROoUoy7Hqwn/vzEJseTl56VKi fPag8wQACnKKM2DGwGLkUuMslLCvIxARwnxFKQW5WaWoMq/YhTnYFQS5g0GmcKTmVcCt+kV0B FMQEcoNsaAHFGSiJCSamC0nea7Rj+oxz9n9rqnDcobP9rua5U56/iysbjMdQdDs/3ROEmTnSf 0pfYLnrHeKy6181Jzq0buCQaDHRXBpYFfDhn3SfU9/L3M55uFncXE9vhtajvSjd4e3nemadM+ 5wcXX2WtK7gctPkdg8jJb1/uz/R9s8lDOKBILOjR28r6rKWplhdMJ8cqsRRnJBpqMRcVJwIAa qcrTowCAAA= X-Env-Sender: yi.y.sun@linux.intel.com X-Msg-Ref: server-3.tower-27.messagelabs.com!1499306837!105490986!4 X-Originating-IP: [134.134.136.31] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 34701 invoked from network); 6 Jul 2017 02:07:24 -0000 Received: from mga06.intel.com (HELO mga06.intel.com) (134.134.136.31) by server-3.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 6 Jul 2017 02:07:24 -0000 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP; 05 Jul 2017 19:07:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.40,314,1496127600"; d="scan'208"; a="1191048166" Received: from vmmmba-s2600wft.bj.intel.com ([10.240.193.80]) by fmsmga002.fm.intel.com with ESMTP; 05 Jul 2017 19:07:21 -0700 From: Yi Sun To: xen-devel@lists.xenproject.org Date: Thu, 6 Jul 2017 09:53:10 +0800 Message-Id: <1499305996-19029-18-git-send-email-yi.y.sun@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1499305996-19029-1-git-send-email-yi.y.sun@linux.intel.com> References: <1499305996-19029-1-git-send-email-yi.y.sun@linux.intel.com> Cc: kevin.tian@intel.com, wei.liu2@citrix.com, andrew.cooper3@citrix.com, dario.faggioli@citrix.com, ian.jackson@eu.citrix.com, Yi Sun , mengxu@cis.upenn.edu, jbeulich@suse.com, chao.p.peng@linux.intel.com, roger.pau@citrix.com Subject: [Xen-devel] [PATCH v13 17/23] x86: L2 CAT: implement get hw info flow. X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP This patch implements L2 CAT get HW info flow and interface in sysctl. Signed-off-by: Yi Sun Reviewed-by: Jan Beulich --- v10: - modify macro name according to previous patch change. (suggested by Jan Beulich) - modify commit message. v9: - reuse 'cat_get_feat_info' for L2 CAT to reduce redundant codes. (suggested by Roger Pau) - modify sysctl implementation of L2 CAT to input data[3] to use 'cat_get_feat_info'. (suggested by Roger Pau) - modify macros names to newly defined ones. (suggested by Jan Beulich) - remove 'l2_info' to reuse 'l3_info'. (suggested by Jan Beulich) - modify macro name according to previous patch change. (suggested by Jan Beulich) v5: - rename 'dat[]' to 'data[]' (suggested by Jan Beulich) - remove type check in callback function. (suggested by Jan Beulich) v4: - create this patch because of codes architecture change. (suggested by Jan Beulich) --- xen/arch/x86/psr.c | 5 +++++ xen/arch/x86/sysctl.c | 23 +++++++++++++++++++++-- xen/include/public/sysctl.h | 1 + 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c index 81c9454..610a55c 100644 --- a/xen/arch/x86/psr.c +++ b/xen/arch/x86/psr.c @@ -240,6 +240,10 @@ static enum psr_feat_type psr_cbm_type_to_feat_type(enum cbm_type type) feat_type = FEAT_TYPE_L3_CDP; break; + case PSR_CBM_TYPE_L2: + feat_type = FEAT_TYPE_L2_CAT; + break; + default: ASSERT_UNREACHABLE(); } @@ -407,6 +411,7 @@ static const struct feat_props l2_cat_props = { .cos_num = 1, .type[0] = PSR_CBM_TYPE_L2, .alt_type = PSR_CBM_TYPE_UNKNOWN, + .get_feat_info = cat_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 c23270d..5e91755 100644 --- a/xen/arch/x86/sysctl.c +++ b/xen/arch/x86/sysctl.c @@ -174,10 +174,10 @@ long arch_do_sysctl( case XEN_SYSCTL_psr_cat_op: switch ( sysctl->u.psr_cat_op.cmd ) { - case XEN_SYSCTL_PSR_CAT_get_l3_info: - { uint32_t data[PSR_INFO_ARRAY_SIZE]; + case XEN_SYSCTL_PSR_CAT_get_l3_info: + { ret = psr_get_info(sysctl->u.psr_cat_op.target, PSR_CBM_TYPE_L3, data, ARRAY_SIZE(data)); if ( ret ) @@ -195,6 +195,25 @@ long arch_do_sysctl( break; } + case XEN_SYSCTL_PSR_CAT_get_l2_info: + { + ret = psr_get_info(sysctl->u.psr_cat_op.target, + PSR_CBM_TYPE_L2, data, ARRAY_SIZE(data)); + if ( ret ) + break; + + sysctl->u.psr_cat_op.u.l3_info.cos_max = + data[PSR_INFO_IDX_COS_MAX]; + sysctl->u.psr_cat_op.u.l3_info.cbm_len = + data[PSR_INFO_IDX_CAT_CBM_LEN]; + sysctl->u.psr_cat_op.u.l3_info.flags = + data[PSR_INFO_IDX_CAT_FLAG]; + + if ( !ret && __copy_field_to_guest(u_sysctl, sysctl, u.psr_cat_op) ) + ret = -EFAULT; + break; + } + default: ret = -EOPNOTSUPP; break; diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h index ee76a66..4c76d3a 100644 --- a/xen/include/public/sysctl.h +++ b/xen/include/public/sysctl.h @@ -744,6 +744,7 @@ typedef struct xen_sysctl_pcitopoinfo xen_sysctl_pcitopoinfo_t; DEFINE_XEN_GUEST_HANDLE(xen_sysctl_pcitopoinfo_t); #define XEN_SYSCTL_PSR_CAT_get_l3_info 0 +#define XEN_SYSCTL_PSR_CAT_get_l2_info 1 struct xen_sysctl_psr_cat_op { uint32_t cmd; /* IN: XEN_SYSCTL_PSR_CAT_* */ uint32_t target; /* IN */