From patchwork Fri Jul 27 14:47:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Reza Arbab X-Patchwork-Id: 950222 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41cX0q0Jczz9ryl for ; Sat, 28 Jul 2018 00:49:15 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41cX0p5F3pzF0x8 for ; Sat, 28 Jul 2018 00:49:14 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=linux.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=arbab@linux.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41cWzC3H5hzF0h9 for ; Sat, 28 Jul 2018 00:47:51 +1000 (AEST) Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w6REiSVW018015 for ; Fri, 27 Jul 2018 10:47:49 -0400 Received: from e16.ny.us.ibm.com (e16.ny.us.ibm.com [129.33.205.206]) by mx0a-001b2d01.pphosted.com with ESMTP id 2kg3qucw51-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 27 Jul 2018 10:47:48 -0400 Received: from localhost by e16.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 27 Jul 2018 10:47:47 -0400 Received: from b01cxnp23033.gho.pok.ibm.com (9.57.198.28) by e16.ny.us.ibm.com (146.89.104.203) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 27 Jul 2018 10:47:44 -0400 Received: from b01ledav001.gho.pok.ibm.com (b01ledav001.gho.pok.ibm.com [9.57.199.106]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w6RElhhp5505528 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 27 Jul 2018 14:47:43 GMT Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E527E28060; Fri, 27 Jul 2018 10:46:46 -0400 (EDT) Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CA6582805A; Fri, 27 Jul 2018 10:46:46 -0400 (EDT) Received: from arbab-laptop.localdomain (unknown [9.53.92.213]) by b01ledav001.gho.pok.ibm.com (Postfix) with ESMTP; Fri, 27 Jul 2018 10:46:46 -0400 (EDT) Received: by arbab-laptop.localdomain (Postfix, from userid 152845) id 9E7ED460502; Fri, 27 Jul 2018 09:47:42 -0500 (CDT) From: Reza Arbab To: skiboot@lists.ozlabs.org Date: Fri, 27 Jul 2018 09:47:38 -0500 X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1532702862-22751-1-git-send-email-arbab@linux.ibm.com> References: <1532702862-22751-1-git-send-email-arbab@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18072714-0072-0000-0000-00000386A941 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009438; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01066904; UDB=6.00548185; IPR=6.00844770; MB=3.00022354; MTD=3.00000008; XFM=3.00000015; UTC=2018-07-27 14:47:46 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18072714-0073-0000-0000-000048DD330E Message-Id: <1532702862-22751-3-git-send-email-arbab@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-07-27_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=918 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1807270152 Subject: [Skiboot] [PATCH 2/6] pci: Add pci_next_phb() X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alistair Popple MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Add an iterator to walk over every PHB. Signed-off-by: Alistair Popple Signed-off-by: Reza Arbab Reviewed-by: Alistair Popple --- core/pci.c | 12 ++++++++++++ include/pci.h | 1 + 2 files changed, 13 insertions(+) diff --git a/core/pci.c b/core/pci.c index 6ba6eda..4faf88e 100644 --- a/core/pci.c +++ b/core/pci.c @@ -1104,6 +1104,18 @@ struct phb *pci_get_phb(uint64_t phb_id) return phbs[phb_id]; } +/* Iterator to walk over every PHB */ +struct phb *pci_next_phb(struct phb *last) +{ + uint64_t phb_id = last ? last->opal_id + 1 : 0; + + for (; phb_id < ARRAY_SIZE(phbs); phb_id++) + if (phbs[phb_id]) + return phbs[phb_id]; + + return NULL; +} + static const char *pci_class_name(uint32_t class_code) { uint8_t class = class_code >> 16; diff --git a/include/pci.h b/include/pci.h index c6aa664..19fe9c0 100644 --- a/include/pci.h +++ b/include/pci.h @@ -481,6 +481,7 @@ extern struct pci_cfg_reg_filter *pci_add_cfg_reg_filter(struct pci_device *pd, extern int64_t pci_register_phb(struct phb *phb, int opal_id); extern int64_t pci_unregister_phb(struct phb *phb); extern struct phb *pci_get_phb(uint64_t phb_id); +extern struct phb *pci_next_phb(struct phb *last); static inline struct phb *__pci_next_phb_idx(uint64_t *phb_id) { struct phb *phb = NULL;