Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5411643ybi; Tue, 4 Jun 2019 06:21:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqw1AimbQejDMvH85Ao+JD7SXfjfKFcXVRimcTcSw3bRit9N7KeBi5eHopSiCCS9PZT2nNYe X-Received: by 2002:a17:902:4c:: with SMTP id 70mr12246066pla.308.1559654479444; Tue, 04 Jun 2019 06:21:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559654479; cv=none; d=google.com; s=arc-20160816; b=DO5pXfyTx3kg7+vCtBGLCSm/gO2db0ADmI79Uv7Lkilp3xWQJsbEzCdNlP8pxS8UFl JS3CTcrBKVtZ5pfTk3htD5QCyDR6gjnujERH5pZ2AWFDd9ma0zvh8tjyAH0OGlXL2iOE 78L599q4svXsQHUvdPb27cJmwDnZMXX2WiYF+nxsUh5wKAiGql8KfeIyEWsyYPzrAdiB tkBqUMuta1oP78aSj5UgxXxc3S0nh2fY1A5be3fA/dseuzdT5zZXfLCsteF4AKD076kP 7EK0G19OuNO6Mw9a+baOCJjXovAlrwyxlomvTnXNnPi1kdWzzAgyjqeXr8yUcN2kXZcf BHEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=jqsa++lCvjyELh9SjLjw9ykSFWnOzndvoFRmjfRfvbM=; b=eiK2FODDnIa54Mxtqr5+QPVEGapxOm2/t5Rqyk1GSFvks9xWgcU/G9+GT/32eCL0+t OyxtdaHA1b7CWV/hECP2ftCBt23I2kVCXuMXMgLR/PgwlPEgFEzwv/JcMumDyIfr4igl Si/CUOV4dV6Az0qQ+nTbfzvhOx3DTkZN3x6Q9c2Z9hQuoRC8gUruqdFTSDX88OueKChY 56ot+0fhqUgrzJBTcKzw32o1OM4UnrLDQi8q9vKfChhcyOzxadWYCXlaOJ4AyUBA9H7j He7bDmGu4NVnIfjyRPiI4RVTUNzVX7ZPNeTyXseFJbjuVaW8cY3gtcEyLJVXg0iE+EKt GATA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=SJafN6MA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cg6si25457329plb.350.2019.06.04.06.21.01; Tue, 04 Jun 2019 06:21:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=SJafN6MA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727915AbfFDNTO (ORCPT + 99 others); Tue, 4 Jun 2019 09:19:14 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:50568 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727893AbfFDNTL (ORCPT ); Tue, 4 Jun 2019 09:19:11 -0400 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id x54DIVce082525; Tue, 4 Jun 2019 08:18:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1559654311; bh=jqsa++lCvjyELh9SjLjw9ykSFWnOzndvoFRmjfRfvbM=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=SJafN6MA92yKSz6dnMDxTTSbwugOvtBPxvXPk6dN9oGWrdM+bxvO9y+d+3fSZ2020 FjR8jknaD/OjckdHuenkfWAtz88nO3FnwFjWOjMOihJoROvPIjviRSeSN0KnSuHLPz /HYf2IOtakaVtsthLtvLltjaUW2Td3cPbKsUqTe8= Received: from DLEE104.ent.ti.com (dlee104.ent.ti.com [157.170.170.34]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x54DIVRw009609 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 4 Jun 2019 08:18:31 -0500 Received: from DLEE110.ent.ti.com (157.170.170.21) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Tue, 4 Jun 2019 08:18:30 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DLEE110.ent.ti.com (157.170.170.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Tue, 4 Jun 2019 08:18:30 -0500 Received: from a0393678ub.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id x54DGdGZ098972; Tue, 4 Jun 2019 08:18:25 -0500 From: Kishon Vijay Abraham I To: Tom Joseph , Bjorn Helgaas , Rob Herring , Mark Rutland , Lorenzo Pieralisi , Arnd Bergmann , Gustavo Pimentel CC: Greg Kroah-Hartman , Frank Rowand , Jingoo Han , , , , , , , Kishon Vijay Abraham I Subject: [RFC PATCH 19/30] PCI: endpoint: Add support to link a physical function to a virtual function Date: Tue, 4 Jun 2019 18:45:05 +0530 Message-ID: <20190604131516.13596-20-kishon@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190604131516.13596-1-kishon@ti.com> References: <20190604131516.13596-1-kishon@ti.com> MIME-Version: 1.0 Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org While the physical function has to be linked to endpoint controller, the virtual function has to be linked to a physical function. Add support to link a physical function to a virtual function in pci-ep-cfs. Signed-off-by: Kishon Vijay Abraham I --- drivers/pci/endpoint/pci-ep-cfs.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/pci/endpoint/pci-ep-cfs.c b/drivers/pci/endpoint/pci-ep-cfs.c index e7e8367eead1..c18ef626ada5 100644 --- a/drivers/pci/endpoint/pci-ep-cfs.c +++ b/drivers/pci/endpoint/pci-ep-cfs.c @@ -350,6 +350,28 @@ static struct configfs_attribute *pci_epf_attrs[] = { NULL, }; +static int pci_epf_vepf_link(struct config_item *epf_pf_item, + struct config_item *epf_vf_item) +{ + struct pci_epf_group *epf_vf_group = to_pci_epf_group(epf_vf_item); + struct pci_epf_group *epf_pf_group = to_pci_epf_group(epf_pf_item); + struct pci_epf *epf_pf = epf_pf_group->epf; + struct pci_epf *epf_vf = epf_vf_group->epf; + + return pci_epf_add_vepf(epf_pf, epf_vf); +} + +static void pci_epf_vepf_unlink(struct config_item *epf_pf_item, + struct config_item *epf_vf_item) +{ + struct pci_epf_group *epf_vf_group = to_pci_epf_group(epf_vf_item); + struct pci_epf_group *epf_pf_group = to_pci_epf_group(epf_pf_item); + struct pci_epf *epf_pf = epf_pf_group->epf; + struct pci_epf *epf_vf = epf_vf_group->epf; + + pci_epf_remove_vepf(epf_pf, epf_vf); +} + static void pci_epf_release(struct config_item *item) { struct pci_epf_group *epf_group = to_pci_epf_group(item); @@ -362,6 +384,8 @@ static void pci_epf_release(struct config_item *item) } static struct configfs_item_operations pci_epf_ops = { + .allow_link = pci_epf_vepf_link, + .drop_link = pci_epf_vepf_unlink, .release = pci_epf_release, }; -- 2.17.1