From patchwork Sat Jul 1 07:01:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 1802205 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=daynix-com.20221208.gappssmtp.com header.i=@daynix-com.20221208.gappssmtp.com header.a=rsa-sha256 header.s=20221208 header.b=tmf+3ZX1; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QtNRk5r18z20ZV for ; Sat, 1 Jul 2023 17:02:42 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qFUcK-0007VX-SS; Sat, 01 Jul 2023 03:02:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qFUcJ-0007Uy-6Y for qemu-devel@nongnu.org; Sat, 01 Jul 2023 03:01:59 -0400 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qFUcG-0000jz-Vp for qemu-devel@nongnu.org; Sat, 01 Jul 2023 03:01:58 -0400 Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-5440e98616cso1587215a12.0 for ; Sat, 01 Jul 2023 00:01:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1688194915; x=1690786915; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uzSXskDD/v1lHw+o43R3dD1EMa38NVV+qos1D4KGb28=; b=tmf+3ZX1n4IsswZCdO5pgd83VKy2DfGPbjscSf4CvjggaqBVYZfyHeOEVBx0fw8P/s qw7+1k13xRcabwjeL+y3K7wm4KHDgk7f19T/rW0ZRzgSOo56jB62gh/lfQCw64Gmo26H hd5Oy6i9KhtHd86PLB8VtLXy/dtHdL1JPOG0He3nZAtJ3ok2ny58j6+HHDsctn41u6Dl 9XhGahPgUEtF+5N9E6CnFyfVdd8JBjgzY2tNbdn/nHWqjwLRa8pbRxrZFn/OGecvmAC8 E5A/1xszqXRg5X5vLDzbgT3AFAiJEq6xRrRwvE1v080YnnFKkFpEc6MGx4/ND6q5giw3 XgOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688194915; x=1690786915; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uzSXskDD/v1lHw+o43R3dD1EMa38NVV+qos1D4KGb28=; b=DyH2iRitzVeXfgh9ESD8mxcuhOBE9A04wNqR1bnM+94UcwdmozAQ1xfD237vGVcm9n BWlWzLciAxWaylO+nCjHwUmoeXwku6Eca0E2eDD0jr+We5/M/ADNel1reO7PEmi9ZhXl wWdxUCZabMekRG5dP7IXK8gJjJzP4guSrAWqlJZZlTEFr+kVT0Tz2TuMaLsXmF0tIvnM VN4OWOXddnlcTtvAnNReZYSNkSazYHAwl5wqDC7RR8EZk0zMJCa24HJLcE0cCti+u/md D4JeuVAN6pqLFzebOKJm59aFsWCgjqqAalpc3PzILiYHJSfh3PGt+8zlZqEC2+FPb4cE Xkng== X-Gm-Message-State: ABy/qLYXIoU4ym5hqOagtfw64ueeveKYsMnMQIdNfE1DKTzgbr5ewZfB 4SLeq6hFRakqeZz5B0XFDSroplvAtjrbUF17GeQ= X-Google-Smtp-Source: APBJJlEmVllYlwT+VxwsvPobpenmx898PoKEa9nQTpLzQKkppsAMMxBrilcjPRPGAswx8PAIcxPAPg== X-Received: by 2002:a17:902:e743:b0:1af:e302:123 with SMTP id p3-20020a170902e74300b001afe3020123mr8110555plf.3.1688194915460; Sat, 01 Jul 2023 00:01:55 -0700 (PDT) Received: from alarm.. ([157.82.204.253]) by smtp.gmail.com with ESMTPSA id jd4-20020a170903260400b001b1920cffdasm5592452plb.204.2023.07.01.00.01.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Jul 2023 00:01:55 -0700 (PDT) From: Akihiko Odaki To: Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Ani Sinha , "Michael S . Tsirkin" , Marcel Apfelbaum , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen , Akihiko Odaki Subject: [PATCH 1/4] docs: Fix next function numbers in SR/IOV documentation Date: Sat, 1 Jul 2023 16:01:19 +0900 Message-ID: <20230701070133.24877-2-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230701070133.24877-1-akihiko.odaki@daynix.com> References: <20230701070133.24877-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Received-SPF: none client-ip=2607:f8b0:4864:20::534; envelope-from=akihiko.odaki@daynix.com; helo=mail-pg1-x534.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The next function numbers are expected to form a linked list ending with 0. Fixes: 2503461691 ("pcie: Add some SR/IOV API documentation in docs/pcie_sriov.txt") Signed-off-by: Akihiko Odaki --- docs/pcie_sriov.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/pcie_sriov.txt b/docs/pcie_sriov.txt index 7eff7f2703..cc4232e49a 100644 --- a/docs/pcie_sriov.txt +++ b/docs/pcie_sriov.txt @@ -48,7 +48,7 @@ setting up a BAR for a VF. ... int ret = pcie_endpoint_cap_init(d, 0x70); ... - pcie_ari_init(d, 0x100, 1); + pcie_ari_init(d, 0x100, fun_offset); ... /* Add and initialize the SR/IOV capability */ @@ -76,9 +76,10 @@ setting up a BAR for a VF. pci_your_vf_dev_realize( ... ) { ... + uint16_t nextvfn = pcie_sriov_vf_number(dev) + 1; int ret = pcie_endpoint_cap_init(d, 0x60); ... - pcie_ari_init(d, 0x100, 1); + pcie_ari_init(d, 0x100, nextvfn < total_vfs ? fun_offset + nextvfn * stride : 0); ... memory_region_init(mr, ... ) pcie_sriov_vf_register_bar(d, bar_nr, mr); From patchwork Sat Jul 1 07:01:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 1802207 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=daynix-com.20221208.gappssmtp.com header.i=@daynix-com.20221208.gappssmtp.com header.a=rsa-sha256 header.s=20221208 header.b=iZY7kq6a; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QtNS1633Bz20ZV for ; Sat, 1 Jul 2023 17:02:57 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qFUcL-0007WC-UW; Sat, 01 Jul 2023 03:02:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qFUcL-0007Vf-26 for qemu-devel@nongnu.org; Sat, 01 Jul 2023 03:02:01 -0400 Received: from mail-il1-x131.google.com ([2607:f8b0:4864:20::131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qFUcJ-0000kR-KE for qemu-devel@nongnu.org; Sat, 01 Jul 2023 03:02:00 -0400 Received: by mail-il1-x131.google.com with SMTP id e9e14a558f8ab-34574014304so12596585ab.2 for ; Sat, 01 Jul 2023 00:01:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1688194918; x=1690786918; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Zsb2EYoYtxi+hLo7fouc8vYS/YOxaACOuCfNLuemkEQ=; b=iZY7kq6aeR/PgC7qI3f7TcEMIxZR2ybdEGv4MOhRUBV0XemoJnimyY3ogg9DfK9VRv GLPSVvh7AwEyvJqx7zZjsa2+298ennzbJoJzfQyKaciCUwMrjiKF4TNcpeRqCbnPyebk m8hTndB49lxkL60HEIUnF0kWgBGe1Y1LLNRyENJx2Yro4w6keU/UBlO5TllwFjhxQmz1 IApSs7Ms/w4kOVQLuKs09wEZmj7pXVZoauk08mFRLUVioUMgz8VCxW//ZW28ouZ0rn1w V02qzQLC67wpkIulB2bWPkX1HsxRFXX4PyQDVRy9DQs4gPTlv5DypC4ZPzY9ZDk8YUgt S4PQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688194918; x=1690786918; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Zsb2EYoYtxi+hLo7fouc8vYS/YOxaACOuCfNLuemkEQ=; b=UixAb9Cmde/rO5+6I7QCOkITRunP5v68tUxLhoW/STwQePu6wQj4hwW+sCa6+k98SI 64CoyOt9NhiPzn1WqXsRrn0biRIySD7f786uDGepZAsxX2AXLUAYNH1lRdQ25zx0yiKU bVEZgdMIthlLQ+b46pss9AZoMcjs0NHL5UqfifITHekO8UaLxowpM/15j56KThQNkiPF WysUd8n6ex0ZoR74ulJW6YYKMOTUoREm5D7jLbkD47uarCpMi2cSR9kzUzUZE73DoUt3 9IpSkYnjxFJZBpXLgvMMI1pohlpkOPVzvPhEUHg/KmFtdNfqjDHHwUEH0iQH2DdO4J9R a7aQ== X-Gm-Message-State: ABy/qLb5dp21sjXw1m7ptQvcgkUqF9VuOKw5OtQpObVyWSGf7MmzCPYQ U+Ur2ue98UGyHglyEUujlrOBC9VC0PJRkkHozN0= X-Google-Smtp-Source: APBJJlFlZ35B0rIZQzKfg3jTelGySVWGLopojw53KLoqCITw5ZsL2UZZX0SuJOz+DVy5uNgawZdFdg== X-Received: by 2002:a05:6e02:5d0:b0:345:b97e:6ba5 with SMTP id l16-20020a056e0205d000b00345b97e6ba5mr4380053ils.4.1688194918067; Sat, 01 Jul 2023 00:01:58 -0700 (PDT) Received: from alarm.. ([157.82.204.253]) by smtp.gmail.com with ESMTPSA id jd4-20020a170903260400b001b1920cffdasm5592452plb.204.2023.07.01.00.01.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Jul 2023 00:01:57 -0700 (PDT) From: Akihiko Odaki To: Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Ani Sinha , "Michael S . Tsirkin" , Marcel Apfelbaum , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen , Akihiko Odaki Subject: [PATCH 2/4] hw/nvme: Fix ARI next function numbers Date: Sat, 1 Jul 2023 16:01:20 +0900 Message-ID: <20230701070133.24877-3-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230701070133.24877-1-akihiko.odaki@daynix.com> References: <20230701070133.24877-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Received-SPF: none client-ip=2607:f8b0:4864:20::131; envelope-from=akihiko.odaki@daynix.com; helo=mail-il1-x131.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The next function numbers are expected to form a linked list ending with 0. Fixes: 44c2c09488 ("hw/nvme: Add support for SR-IOV") Signed-off-by: Akihiko Odaki --- hw/nvme/ctrl.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index fd917fcda1..12500dc80b 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -8088,7 +8088,12 @@ static bool nvme_init_pci(NvmeCtrl *n, PCIDevice *pci_dev, Error **errp) pcie_endpoint_cap_init(pci_dev, 0x80); pcie_cap_flr_init(pci_dev); if (n->params.sriov_max_vfs) { - pcie_ari_init(pci_dev, 0x100, 1); + uint16_t nextvfn = pci_is_vf(pci_dev) ? + pcie_sriov_vf_number(pci_dev) + 1 : 0; + uint16_t nextfn = nextvfn < n->params.sriov_max_vfs ? + NVME_VF_OFFSET + nextvfn * NVME_VF_STRIDE : 0; + + pcie_ari_init(pci_dev, 0x100, nextfn); } /* add one to max_ioqpairs to account for the admin queue pair */ From patchwork Sat Jul 1 07:01:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 1802208 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=daynix-com.20221208.gappssmtp.com header.i=@daynix-com.20221208.gappssmtp.com header.a=rsa-sha256 header.s=20221208 header.b=0QjaeIMV; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QtNSF0jd5z20ZV for ; Sat, 1 Jul 2023 17:03:09 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qFUcO-0007Xa-Of; Sat, 01 Jul 2023 03:02:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qFUcN-0007X3-Ae for qemu-devel@nongnu.org; Sat, 01 Jul 2023 03:02:03 -0400 Received: from mail-ot1-x329.google.com ([2607:f8b0:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qFUcL-0000l0-LI for qemu-devel@nongnu.org; Sat, 01 Jul 2023 03:02:03 -0400 Received: by mail-ot1-x329.google.com with SMTP id 46e09a7af769-6b7541d885cso2313089a34.3 for ; Sat, 01 Jul 2023 00:02:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1688194920; x=1690786920; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4RgH91GA1gaWvFQByNsH0yzA9IIim4f6UGgM6Gv3rCI=; b=0QjaeIMVAWgnc4u9M8lhJJHwlcaDLyD+iCct15Iz7nKtsynsFn+FKvnVVUud668Kfe gsvM3eULY+wE5PPpFHF0pz3Wl6BqPBvqFODZ3VWQT7vSbrM5W/GaghSGLhHSb+JHArss mN8KILguVREIT9MSabcuXxojNG78qkYfIWmgBdQrIWP/xPw80LhjsAegerCoYqTARKgx KnjE0IPnPyxI7tWo9JOCRM4k3ykHRANEr2/D2ODOpZrNSAg6i/SJaCRF4Sq3arko+fMe b4tKlpYWHTBQKtB5NPv6zgaOW8EfOQELyYWgnK/htpWko5kzZXeM+LiJNT1Zppp4YR+v lFhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688194920; x=1690786920; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4RgH91GA1gaWvFQByNsH0yzA9IIim4f6UGgM6Gv3rCI=; b=TwiWMHiikhYCnBXpqLG9oY/wKBeWiClUHBSIJDbO/MaG+tjY8Rv76L5HygLZQEYZAZ Nu/G1EyG748tfNoLg2PyQXqlzSJMG35iSRlLjOastbRLE5FM0QKS7LmMyy1BJrF1risx VDcUAZER7BZhKaeEDfsalfNIC7R3U19RK/QHdb9yI1wbS22EKDkMcsL7KJjJ5++PKwQK 1eXq2iJdpOYxk6AB4k6EmFtKx7gizdRz7PIvOP/SqnlqOq+JjO2YrTRo04sBfe71Ib/s k62bV0BhLlT8GBRZomF8A+U4hTTf0L3yMRhjVO+c8yXdskS0SwtBUYuLwclqCDwo9VVh KzMQ== X-Gm-Message-State: AC+VfDxZ7/mx3klWTUNZM4hYvz3/lm5VuPyxk4woHYdOeb0oObsWqpmc 4gIrt3MFUr/HdloVzjvCfY4lpM86lE/q9btZbi8= X-Google-Smtp-Source: ACHHUZ4XDsw5p0b9L3kABCaZFDbZ8/2Ed6cLnRs6NnotJ513K9paBSE5K9mUBLrjLGzWh9S/G1MZlQ== X-Received: by 2002:a05:6830:c4:b0:6b7:470c:931f with SMTP id x4-20020a05683000c400b006b7470c931fmr5682561oto.1.1688194920587; Sat, 01 Jul 2023 00:02:00 -0700 (PDT) Received: from alarm.. ([157.82.204.253]) by smtp.gmail.com with ESMTPSA id jd4-20020a170903260400b001b1920cffdasm5592452plb.204.2023.07.01.00.01.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Jul 2023 00:02:00 -0700 (PDT) From: Akihiko Odaki To: Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Ani Sinha , "Michael S . Tsirkin" , Marcel Apfelbaum , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen , Akihiko Odaki Subject: [PATCH 3/4] igb: Fix ARI next function numbers Date: Sat, 1 Jul 2023 16:01:21 +0900 Message-ID: <20230701070133.24877-4-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230701070133.24877-1-akihiko.odaki@daynix.com> References: <20230701070133.24877-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Received-SPF: none client-ip=2607:f8b0:4864:20::329; envelope-from=akihiko.odaki@daynix.com; helo=mail-ot1-x329.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The next function numbers are expected to form a linked list ending with 0. Fixes: 3a977deebe ("Intrdocue igb device emulation") Signed-off-by: Akihiko Odaki --- hw/net/igb_core.h | 3 +++ hw/net/igb.c | 4 +--- hw/net/igbvf.c | 5 ++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/hw/net/igb_core.h b/hw/net/igb_core.h index 9cbbfd516b..e1dab76995 100644 --- a/hw/net/igb_core.h +++ b/hw/net/igb_core.h @@ -49,6 +49,9 @@ #define IGB_NUM_QUEUES (16) #define IGB_NUM_VM_POOLS (8) +#define IGB_VF_OFFSET (0x80) +#define IGB_VF_STRIDE (2) + typedef struct IGBCore IGBCore; enum { PHY_R = BIT(0), diff --git a/hw/net/igb.c b/hw/net/igb.c index 1c989d7677..543ca0114a 100644 --- a/hw/net/igb.c +++ b/hw/net/igb.c @@ -81,8 +81,6 @@ struct IGBState { }; #define IGB_CAP_SRIOV_OFFSET (0x160) -#define IGB_VF_OFFSET (0x80) -#define IGB_VF_STRIDE (2) #define E1000E_MMIO_IDX 0 #define E1000E_FLASH_IDX 1 @@ -431,7 +429,7 @@ static void igb_pci_realize(PCIDevice *pci_dev, Error **errp) hw_error("Failed to initialize AER capability"); } - pcie_ari_init(pci_dev, 0x150, 1); + pcie_ari_init(pci_dev, 0x150, IGB_VF_OFFSET); pcie_sriov_pf_init(pci_dev, IGB_CAP_SRIOV_OFFSET, TYPE_IGBVF, IGB_82576_VF_DEV_ID, IGB_MAX_VF_FUNCTIONS, IGB_MAX_VF_FUNCTIONS, diff --git a/hw/net/igbvf.c b/hw/net/igbvf.c index 284ea61184..bf2f237ab5 100644 --- a/hw/net/igbvf.c +++ b/hw/net/igbvf.c @@ -240,6 +240,9 @@ static const MemoryRegionOps mmio_ops = { static void igbvf_pci_realize(PCIDevice *dev, Error **errp) { IgbVfState *s = IGBVF(dev); + uint16_t nextvfn = pcie_sriov_vf_number(dev) + 1; + uint16_t nextfn = nextvfn < IGB_MAX_VF_FUNCTIONS ? + IGB_VF_OFFSET + nextvfn * IGB_VF_STRIDE : 0; int ret; int i; @@ -270,7 +273,7 @@ static void igbvf_pci_realize(PCIDevice *dev, Error **errp) hw_error("Failed to initialize AER capability"); } - pcie_ari_init(dev, 0x150, 1); + pcie_ari_init(dev, 0x150, nextfn); } static void igbvf_pci_uninit(PCIDevice *dev) From patchwork Sat Jul 1 07:01:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 1802206 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=daynix-com.20221208.gappssmtp.com header.i=@daynix-com.20221208.gappssmtp.com header.a=rsa-sha256 header.s=20221208 header.b=0qP14O4/; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QtNRm67b3z20ZV for ; Sat, 1 Jul 2023 17:02:44 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qFUcR-0007b9-RK; Sat, 01 Jul 2023 03:02:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qFUcQ-0007ZQ-8l for qemu-devel@nongnu.org; Sat, 01 Jul 2023 03:02:06 -0400 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qFUcO-0000li-Od for qemu-devel@nongnu.org; Sat, 01 Jul 2023 03:02:05 -0400 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1b801e6ce85so16866125ad.1 for ; Sat, 01 Jul 2023 00:02:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1688194923; x=1690786923; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=S2mzoJtKETatATbk1+/Lk4f6WvlDPSXraYC64PqRpAQ=; b=0qP14O4/qof6fYZsfI8PXvNOjFolOAPo1Z5XU5N17C1TzKravC80JFzf+NmQBl+jwH jM3c/q3pF1LVkySB2USIK64Oa2Doga3Dbe/30qIj7ylYH+ufJkVIdzPtyc1Ya37rvzps k/Gf+qXlKUkaKMbBcYxDFrvrwBkuMef6O2/nARsDwilM5dGR2tVRkwOUIHkylX4SRASV hWUczWH1JiKCUOQPfy7tmzx3UA5fjsCn5B6rO6SaIjh90O7CVyd0BxfnXy5r7BT8H0on J6VmHgssADYwaIl8jZ9GhcWbhljZYPOR54aHj/zy3F1rQkOvpLPUj9K0zwMxst9TjJp6 dMtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688194923; x=1690786923; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=S2mzoJtKETatATbk1+/Lk4f6WvlDPSXraYC64PqRpAQ=; b=ZNJ6U4NEoYisxNgOMBqcotq3AUlUAtCYloLzv1lDtESiVgBuaj5UYZzFGZh4LlHMHB EnBgTyO7wF6hNQ9Qs13I+c5e6kZOCyFqwRLec6ftY5Vxwxj9ncg9dVVx2uWSra+kCcrp Zloethq7pIooDNd+eGhoJN/rB3O2vvMZjwpLYkx3cY6/qlF/NEyKPr69Kqnk7SwIxrrM Lc/s5/ExFXU3sfegCP4Z9GOlPjZNSDtkNqx7CcfMfJZwtCzVppIRmExvFueDyNUIkilt P0uMLx32R/upOvN8hGQqkFu8HJdU+45KJjtVziPP6JZwjkxA2B1DX3MOrGlAKm8Oscmo Wl6Q== X-Gm-Message-State: ABy/qLY1b1S1U0bc19mTmLCw7gJbSLffFHh83AdCkaEJqy6V6B8aR/dO o4c0j4Yhnu/xpTsY7ZI+kZnRqK07yrQkbdVMEEU= X-Google-Smtp-Source: APBJJlFNPvXGJgruhXipND3fFTGyw7GUw7v/Ke0TKlh7VaT2/WrnOA2z8IewwW2+SsMefhYqOY3llg== X-Received: by 2002:a17:902:d4ca:b0:1b8:656f:76e7 with SMTP id o10-20020a170902d4ca00b001b8656f76e7mr7173201plg.23.1688194923158; Sat, 01 Jul 2023 00:02:03 -0700 (PDT) Received: from alarm.. ([157.82.204.253]) by smtp.gmail.com with ESMTPSA id jd4-20020a170903260400b001b1920cffdasm5592452plb.204.2023.07.01.00.02.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Jul 2023 00:02:02 -0700 (PDT) From: Akihiko Odaki To: Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Ani Sinha , "Michael S . Tsirkin" , Marcel Apfelbaum , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen , Akihiko Odaki Subject: [PATCH 4/4] pci: Compare function number and ARI next function number Date: Sat, 1 Jul 2023 16:01:22 +0900 Message-ID: <20230701070133.24877-5-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230701070133.24877-1-akihiko.odaki@daynix.com> References: <20230701070133.24877-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Received-SPF: none client-ip=2607:f8b0:4864:20::62d; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x62d.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The function number must be lower than the next function number advertised with ARI. Signed-off-by: Akihiko Odaki --- hw/pci/pci.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index e2eb4c3b4a..568665ee42 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -2059,6 +2059,8 @@ static void pci_qdev_realize(DeviceState *qdev, Error **errp) Error *local_err = NULL; bool is_default_rom; uint16_t class_id; + uint16_t ari; + uint16_t nextfn; /* * capped by systemd (see: udev-builtin-net_id.c) @@ -2121,6 +2123,19 @@ static void pci_qdev_realize(DeviceState *qdev, Error **errp) } } + if (pci_is_express(pci_dev)) { + ari = pcie_find_capability(pci_dev, PCI_EXT_CAP_ID_ARI); + if (ari) { + nextfn = (pci_get_long(pci_dev->config + ari + PCI_ARI_CAP) >> 8) & 0xff; + if (nextfn && (pci_dev->devfn & 0xff) >= nextfn) { + error_setg(errp, "PCI: function number %u is not lower than ARI next function number %u", + pci_dev->devfn & 0xff, nextfn); + pci_qdev_unrealize(DEVICE(pci_dev)); + return; + } + } + } + if (pci_dev->failover_pair_id) { if (!pci_bus_is_express(pci_get_bus(pci_dev))) { error_setg(errp, "failover primary device must be on "