From patchwork Sat Apr 1 13:53:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi Sun X-Patchwork-Id: 9657943 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 E567860349 for ; Sat, 1 Apr 2017 13:56:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC241285C2 for ; Sat, 1 Apr 2017 13:56:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D0D2528616; Sat, 1 Apr 2017 13:56:02 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID 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 692CA285C2 for ; Sat, 1 Apr 2017 13:56:02 +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 1cuJU9-0006Gs-RO; Sat, 01 Apr 2017 13:54:33 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cuJU8-0006E9-6E for xen-devel@lists.xenproject.org; Sat, 01 Apr 2017 13:54:32 +0000 Received: from [85.158.137.68] by server-16.bemta-3.messagelabs.com id 1E/1B-06437-711BFD85; Sat, 01 Apr 2017 13:54:31 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrNLMWRWlGSWpSXmKPExsXS1tYhoiu28X6 EwdKfVhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bsM+dYCnZKVxx6Mpu1gbFNpIuRi4NF4BaT xNQ1bSwgjpDANEaJnY82MncxcnJICPBKHFk2g7WLkQPI9pd4v0gBJCwkUC/RvWoFI4jNJqAu8 fhrDxOILSKgJHFv1WQmkDnMAjuZJNad/g42R1jAWeL8s29gDSwCqhLvJvaxgdi8Ap4S356+YY PYJSdx8thkVhCbEyh+5cU+FohlHhKrJl1insDIt4CRYRWjRnFqUVlqka6hhV5SUWZ6RkluYma OrqGBsV5uanFxYnpqTmJSsV5yfu4mRmCg1DMwMO5g/H3a8xCjJAeTkijv9+J7EUJ8SfkplRmJ xRnxRaU5qcWHGGU4OJQkeBU23I8QEixKTU+tSMvMAYYsTFqCg0dJhPfYeqA0b3FBYm5xZjpE6 hSjopQ4bypInwBIIqM0D64NFieXGGWlhHkZGRgYhHgKUotyM0tQ5V8xinMwKgnzyoOM58nMK4 Gb/gpoMRPQYouvd0EWlyQipKQaGBdO1n0SfM7B5n3fjW7T9RdKHktXvBMuN5hbGi91OPlRgfx /P2fz1oV3+f+sXBltHhRywmLmhqi8yHUlT/6ttLjw88biuvuH39RqBOw4csAnse9Z3xcD16od zNWZFQ7py2wm/jzytf/g/kPbz9xcc3jhvMrEq/lrLrL48dswzxDwj/GMYNv7/KISS3FGoqEWc 1FxIgBqPIffjgIAAA== X-Env-Sender: yi.y.sun@linux.intel.com X-Msg-Ref: server-9.tower-31.messagelabs.com!1491054811!37933881!20 X-Originating-IP: [134.134.136.20] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTM0LjEzNC4xMzYuMjAgPT4gMzU1MzU4\n X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 55435 invoked from network); 1 Apr 2017 13:54:30 -0000 Received: from mga02.intel.com (HELO mga02.intel.com) (134.134.136.20) by server-9.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 1 Apr 2017 13:54:30 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1491054870; x=1522590870; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=CBYE9wzqngKj7SqyC4uhzldpWd+eZ0D0CZ3deWW0bMg=; b=nDPv+8ODFjPnL2wTJI1S+LRY+VC7r2qgusSGTG7crkrdevs2zw4b2Zxo uF1ZJ4Kn+iY5MWuuT8wHWJSHv77Qxg==; Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Apr 2017 06:54:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,258,1486454400"; d="scan'208";a="950545303" Received: from yisun1-ubuntu.bj.intel.com ([10.238.156.112]) by orsmga003.jf.intel.com with ESMTP; 01 Apr 2017 06:54:26 -0700 From: Yi Sun To: xen-devel@lists.xenproject.org Date: Sat, 1 Apr 2017 21:53:50 +0800 Message-Id: <1491054836-30488-20-git-send-email-yi.y.sun@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1491054836-30488-1-git-send-email-yi.y.sun@linux.intel.com> References: <1491054836-30488-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, he.chen@linux.intel.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 v10 19/25] 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 --- 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 | 4 ++++ xen/arch/x86/sysctl.c | 21 +++++++++++++++++++++ xen/include/public/sysctl.h | 1 + 3 files changed, 26 insertions(+) diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c index 6a9cd88..8114bed 100644 --- a/xen/arch/x86/psr.c +++ b/xen/arch/x86/psr.c @@ -257,6 +257,9 @@ static enum psr_feat_type psr_cbm_type_to_feat_type(enum cbm_type type) case PSR_CBM_TYPE_L3_CODE: feat_type = PSR_SOCKET_L3_CDP; break; + case PSR_CBM_TYPE_L2: + feat_type = PSR_SOCKET_L2_CAT; + break; default: ASSERT_UNREACHABLE(); } @@ -466,6 +469,7 @@ static struct feat_props l3_cdp_props = { /* L2 CAT ops */ static struct feat_props l2_cat_props = { .cos_num = 1, + .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..ba6b6a6 100644 --- a/xen/arch/x86/sysctl.c +++ b/xen/arch/x86/sysctl.c @@ -195,6 +195,27 @@ long arch_do_sysctl( break; } + case XEN_SYSCTL_PSR_CAT_get_l2_info: + { + uint32_t data[PSR_INFO_ARRAY_SIZE]; + + 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 00f5e77..1fe8fe4 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 */