From patchwork Mon Mar 12 18:34:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey G X-Patchwork-Id: 10277015 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 04E5660211 for ; Mon, 12 Mar 2018 18:42:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E5C4A28B54 for ; Mon, 12 Mar 2018 18:42:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D952E28B8C; Mon, 12 Mar 2018 18:42:35 +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 6152A28B54 for ; Mon, 12 Mar 2018 18:42:35 +0000 (UTC) Received: from localhost ([::1]:33905 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evSP4-0000pD-JG for patchwork-qemu-devel@patchwork.kernel.org; Mon, 12 Mar 2018 14:42:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44821) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evSIv-000096-EG for qemu-devel@nongnu.org; Mon, 12 Mar 2018 14:36:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1evSIs-0005e2-BG for qemu-devel@nongnu.org; Mon, 12 Mar 2018 14:36:13 -0400 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:39811) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1evSIs-0005dj-2d for qemu-devel@nongnu.org; Mon, 12 Mar 2018 14:36:10 -0400 Received: by mail-pl0-x241.google.com with SMTP id s13-v6so9820984plq.6 for ; Mon, 12 Mar 2018 11:36:09 -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=amitkgLDcIsmxL29k4CN+YiqrmdME/+g7rpvxGvM5h0=; b=HXnaNKQNE5/6rlJbyQX+R1YAEt8nrPegxQWn/HrFYSBIStLBbbtlkqz7umxecWo2pB S5P6GvlY44dJNs2nImrSvN7mvjpcOF0tcITkXbK830BbNBMmkLIIdzyCBiF/ayfmjdAH E4xJM0iTNKDM3wlJ34BGvWamTgjYhMeNVinNBG6edag3kYQlbU3QMN5wv9ZZG7AiLJ/+ 5Sl0dEqOUGuloesksDsg1aravEYN/1pw7zEU6Z3odne47wrYbt81hUTmRHsYo0c2Gg+D PW/YXf3rPnMR8TQRzFylgXcjUROj8uYDzjHMh3/h0AzzNbrT8MspxdwfhmF/IZ/r8kq9 tPDA== 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=amitkgLDcIsmxL29k4CN+YiqrmdME/+g7rpvxGvM5h0=; b=kC5sT7KGH5/acZ3/wXCiC+g3D9E7naAlDuY+hR/hcaWoM47sV9Ry3wyxAs2HBsWDxO B7QmhXfCC3UBcabDUNzEJqgPeb1n14qCXOuFn1vSvEl3rIAb+fitvOvpGf5ZWilBSDlk pt46HISHOGdOn8TIRiQL6wA26K3G80MPRn3qgg9RGL3LyWCh+MPrlasrX9echweSfXFh 1DrMbXVYd/gFZWneuM99G1wExKqpa4zdFNi0PtTBaBvE8sLk4cXLzNLbAVHil7DfnPMl LaekGEF+TyGMPvF7EOOnz90LZ0T45uEZJwiC0Qvnfaku1YB9jjWR2QwORDndi4M3/zvA lP3A== X-Gm-Message-State: AElRT7HUhkG5Tc94nm9axBowf7aiVWNzzXzIJFanHdxrSLiw/z4Yy3PC 5421s7SFU69I0PZG7BrSpk0= X-Google-Smtp-Source: AG47ELu9bFWbf7yDtUJpp48Em3vxdxnTb2JCLCFsuB5PKH9fQBb8lI/AJcbAZAyKjrJ0vJWLmTwc3A== X-Received: by 2002:a17:902:4201:: with SMTP id g1-v6mr9191742pld.62.1520879769266; Mon, 12 Mar 2018 11:36:09 -0700 (PDT) Received: from localhost.localdomain ([217.150.73.25]) by smtp.gmail.com with ESMTPSA id w10sm14468666pgr.57.2018.03.12.11.36.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Mar 2018 11:36:08 -0700 (PDT) From: Alexey Gerasimenko To: xen-devel@lists.xenproject.org Date: Tue, 13 Mar 2018 04:34:10 +1000 Message-Id: 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:c01::241 Subject: [Qemu-devel] [RFC PATCH 25/30] xen/pt: add Vendor-specific 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 Vendor-specific PCIe Extended Capability description structure and corresponding sizing function. In this particular case the size of the Vendor capability is available in the VSEC Length field. Signed-off-by: Alexey Gerasimenko --- hw/xen/xen_pt_config_init.c | 77 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 75 insertions(+), 2 deletions(-) diff --git a/hw/xen/xen_pt_config_init.c b/hw/xen/xen_pt_config_init.c index 10f3b67d35..6e99b9ebd7 100644 --- a/hw/xen/xen_pt_config_init.c +++ b/hw/xen/xen_pt_config_init.c @@ -129,6 +129,18 @@ static uint32_t get_throughable_mask(const XenPCIPassthroughState *s, return throughable_mask & valid_mask; } +static void log_pcie_extended_cap(XenPCIPassthroughState *s, + const char *cap_name, + uint32_t base_offset, uint32_t size) +{ + if (size) { + XEN_PT_LOG(&s->dev, "Found PCIe Extended Capability: %s at 0x%04x, " + "size 0x%x bytes\n", cap_name, + (uint16_t) base_offset, size); + } +} + + /**************** * general register functions */ @@ -1684,6 +1696,44 @@ static int xen_pt_ext_cap_capid_reg_init(XenPCIPassthroughState *s, } +/* Vendor-specific Ext Capability Structure reg static information table */ +static XenPTRegInfo xen_pt_ext_cap_emu_reg_vendor[] = { + { + .offset = XEN_PCIE_CAP_ID, + .size = 2, + .init_val = 0x0000, + .ro_mask = 0xFFFF, + .emu_mask = 0xFFFF, + .init = xen_pt_ext_cap_capid_reg_init, + .u.w.read = xen_pt_word_reg_read, + .u.w.write = xen_pt_word_reg_write, + }, + { + .offset = XEN_PCIE_CAP_LIST_NEXT, + .size = 2, + .init_val = 0x0000, + .ro_mask = 0xFFFF, + .emu_mask = 0xFFFF, + .init = xen_pt_ext_cap_ptr_reg_init, + .u.w.read = xen_pt_word_reg_read, + .u.w.write = xen_pt_word_reg_write, + }, + { + .offset = PCI_VNDR_HEADER, + .size = 4, + .init_val = 0x00000000, + .ro_mask = 0xFFFFFFFF, + .emu_mask = 0x00000000, + .init = xen_pt_common_reg_init, + .u.dw.read = xen_pt_long_reg_read, + .u.dw.write = xen_pt_long_reg_write, + }, + { + .size = 0, + }, +}; + + /**************************** * Capabilities */ @@ -1708,6 +1758,23 @@ static int xen_pt_vendor_size_init(XenPCIPassthroughState *s, *size = sz; return ret; } + +static int xen_pt_ext_cap_vendor_size_init(XenPCIPassthroughState *s, + const XenPTRegGroupInfo *grp_reg, + uint32_t base_offset, + uint32_t *size) +{ + uint32_t vsec_hdr = 0; + int ret = xen_host_pci_get_long(&s->real_device, + base_offset + PCI_VNDR_HEADER, + &vsec_hdr); + + *size = PCI_VNDR_HEADER_LEN(vsec_hdr); + + log_pcie_extended_cap(s, "Vendor-specific", base_offset, *size); + + return ret; +} /* get PCI Express Capability Structure register group size */ static int xen_pt_pcie_size_init(XenPCIPassthroughState *s, const XenPTRegGroupInfo *grp_reg, @@ -1934,6 +2001,14 @@ static const XenPTRegGroupInfo xen_pt_emu_reg_grps[] = { .size_init = xen_pt_reg_grp_size_init, .emu_regs = xen_pt_emu_reg_igd_opregion, }, + /* Vendor-specific Extended Capability reg group */ + { + .grp_id = PCIE_EXT_CAP_ID(PCI_EXT_CAP_ID_VNDR), + .grp_type = XEN_PT_GRP_TYPE_EMU, + .grp_size = 0xFF, + .size_init = xen_pt_ext_cap_vendor_size_init, + .emu_regs = xen_pt_ext_cap_emu_reg_vendor, + }, { .grp_size = 0, }, @@ -2054,8 +2129,6 @@ out: return 0; } - - /************* * Main */