From patchwork Mon Mar 12 18:34:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey G X-Patchwork-Id: 10277041 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 CAB74602C2 for ; Mon, 12 Mar 2018 18:50:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B8AE0286FD for ; Mon, 12 Mar 2018 18:50:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD7A528B0A; Mon, 12 Mar 2018 18:50:18 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 55B27286FD for ; Mon, 12 Mar 2018 18:50:18 +0000 (UTC) Received: from localhost ([::1]:33966 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evSWX-0007Wu-HS for patchwork-qemu-devel@patchwork.kernel.org; Mon, 12 Mar 2018 14:50:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44898) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evSJ0-0000FY-Os for qemu-devel@nongnu.org; Mon, 12 Mar 2018 14:36:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1evSIz-0005hg-Op for qemu-devel@nongnu.org; Mon, 12 Mar 2018 14:36:18 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:45600) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1evSIz-0005hL-JX for qemu-devel@nongnu.org; Mon, 12 Mar 2018 14:36:17 -0400 Received: by mail-pf0-x244.google.com with SMTP id h19so4724566pfd.12 for ; Mon, 12 Mar 2018 11:36:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=H8I3qiPoe4mXtqCA4VoJP/F5xj30F1aCh8Yw9lYfGwQ=; b=P6CH+arFa1VypuqTUAtQLSQ+bYI4cz1FYzGmfepOkYprHvAx7Xd+cpxRjzjyYIkwFO xSTTu8xm3I4TU9iyjsVy3K3/mAH7Rjbovy0kB9jCQqWkLPVUxtWVB8jOeAJKDTGK4hJV QesJgPXC8LHB/AOm4AHQ8x6c4x0XJ/lCLP+RhkF0k0tYt9FoKMCXrnp3uO82ErtePnA7 Q4OZ9QDMysl2tkJXndSD1vXx0WsMQc8LFtrYJopXu8FTVd5BqNZiVXiBbFkpb+wAeCyx aZBi+EfTfnDcqgUSoHij2Pf+RsttfhtDisfmXBqN+tZpZFxOAu7QiROmGMpNVLHWxv/d RBPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=H8I3qiPoe4mXtqCA4VoJP/F5xj30F1aCh8Yw9lYfGwQ=; b=t3vPqC8RkVBh2euYr7GcewV4E6++TW6KfYbq9SfikMk0snJ7PMcPYGyXWM0JPvWKe/ X7aoSm2mI664Ot8fK02L+hCkiA4xPL4hcFde6YTmOObuxn0ZlcnZnVrP5CQgH0e241V2 0biAlHJ98lWBpJsgm/MHywb012O3kvHvDavrpBuKv+dzYd4UNJW6zC1hmSYPxysbonH8 qb8lS3Vg3BvcFV9M3o2Yrw0ZqEKQB4kGNd2nPqucl1HBvT881yF1ykPkm3AaR7bKb6Te UPk4g7pixH884rTgKoOEiq/emGoZnccWGpO7QH4vqLEuk05CZA+KpGO5X6Ptkx10+NNw rA6g== X-Gm-Message-State: AElRT7Huto+aWCdi4Uq3wmD5T2f2f1DnwpSNyVVqDNP7c0PJ6lX8Q1kh UGXczibzj/m8pxjyntgd8hc= X-Google-Smtp-Source: AG47ELvkLOOm5coDdEY0pMPmw9w7mCR3MvUuEQ/cnonIXqnRcB9Qct9gjKPEmISAP8/jajYUXI9qQw== X-Received: by 10.98.153.157 with SMTP id t29mr8963850pfk.201.1520879776795; Mon, 12 Mar 2018 11:36:16 -0700 (PDT) Received: from localhost.localdomain ([217.150.73.25]) by smtp.gmail.com with ESMTPSA id w10sm14468666pgr.57.2018.03.12.11.36.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Mar 2018 11:36:16 -0700 (PDT) From: Alexey Gerasimenko To: xen-devel@lists.xenproject.org Date: Tue, 13 Mar 2018 04:34:12 +1000 Message-Id: <43e8c571a05afdd8b44ad43d7f178672399660d5.1520867956.git.x1917x@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::244 Subject: [Qemu-devel] [RFC PATCH 27/30] xen/pt: add AER PCIe Extended Capability descriptor and sizing X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anthony Perard , Stefano Stabellini , Alexey Gerasimenko , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The patch provides Advanced Error Reporting PCIe Extended Capability description structure and corresponding capability sizing function. Signed-off-by: Alexey Gerasimenko --- hw/xen/xen_pt_config_init.c | 72 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/hw/xen/xen_pt_config_init.c b/hw/xen/xen_pt_config_init.c index 42296c08cc..98aae3daca 100644 --- a/hw/xen/xen_pt_config_init.c +++ b/hw/xen/xen_pt_config_init.c @@ -1924,6 +1924,70 @@ static int xen_pt_msix_size_init(XenPCIPassthroughState *s, return 0; } +/* get Advanced Error Reporting Extended Capability register group size */ +#define PCI_ERR_CAP_TLP_PREFIX_LOG (1U << 11) +#define PCI_DEVCAP2_END_END_TLP_PREFIX (1U << 21) +static int xen_pt_ext_cap_aer_size_init(XenPCIPassthroughState *s, + const XenPTRegGroupInfo *grp_reg, + uint32_t base_offset, + uint32_t *size) +{ + uint8_t dev_type = get_pcie_device_type(s); + uint32_t aer_caps = 0; + uint32_t sz = 0; + int pcie_cap_pos; + uint32_t devcaps2; + int ret = 0; + + pcie_cap_pos = xen_host_pci_find_next_cap(&s->real_device, 0, + PCI_CAP_ID_EXP); + if (!pcie_cap_pos) { + XEN_PT_ERR(&s->dev, + "Cannot find a required PCI Express Capability\n"); + return -1; + } + + if (get_pcie_capability_version(s) > 1) { + ret = xen_host_pci_get_long(&s->real_device, + pcie_cap_pos + PCI_EXP_DEVCAP2, + &devcaps2); + if (ret) { + XEN_PT_ERR(&s->dev, "Error while reading Device " + "Capabilities 2 Register \n"); + return -1; + } + } + + if (devcaps2 & PCI_DEVCAP2_END_END_TLP_PREFIX) { + ret = xen_host_pci_get_long(&s->real_device, + base_offset + PCI_ERR_CAP, + &aer_caps); + if (ret) { + XEN_PT_ERR(&s->dev, + "Error while reading AER Extended Capability\n"); + return -1; + } + + if (aer_caps & PCI_ERR_CAP_TLP_PREFIX_LOG) { + sz = 0x48; + } + } + + if (!sz) { + if (dev_type == PCI_EXP_TYPE_ROOT_PORT || + dev_type == PCI_EXP_TYPE_RC_EC) { + sz = 0x38; + } else { + sz = 0x2C; + } + } + + *size = sz; + + log_pcie_extended_cap(s, "AER", base_offset, *size); + return ret; +} + static const XenPTRegGroupInfo xen_pt_emu_reg_grps[] = { /* Header Type0 reg group */ @@ -2192,6 +2256,14 @@ static const XenPTRegGroupInfo xen_pt_emu_reg_grps[] = { .size_init = xen_pt_reg_grp_size_init, .emu_regs = xen_pt_ext_cap_emu_reg_dummy, }, + /* Advanced Error Reporting Extended Capability reg group */ + { + .grp_id = PCIE_EXT_CAP_ID(PCI_EXT_CAP_ID_ERR), + .grp_type = XEN_PT_GRP_TYPE_EMU, + .grp_size = 0xFF, + .size_init = xen_pt_ext_cap_aer_size_init, + .emu_regs = xen_pt_ext_cap_emu_reg_dummy, + }, { .grp_size = 0, },