Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp4062112iog; Tue, 28 Jun 2022 08:15:06 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uZdqwSpGpxNrgtfdLO7OGGH0HD0qFvx1tMTEu8P56rbCiZhSUMMc2s1GzepuPwG7+1V0lk X-Received: by 2002:a05:6a00:b94:b0:525:930f:57ff with SMTP id g20-20020a056a000b9400b00525930f57ffmr5226689pfj.72.1656429305945; Tue, 28 Jun 2022 08:15:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656429305; cv=none; d=google.com; s=arc-20160816; b=VQYA9OnKG38qiou9OGxM9ZuC9pkj1FZEUm//+Ni4VQAWyOhSTmiuHXDnfRmbwyYAiB vkumZiMJuwXOjyndiYGctrNCmNxKFhJwTQ2lHfASQuFUoxyCEMg1gdefJJTkcEzL5+bh mxL7heiPCPSC8F1hY/2qslzIGU1ycPO5B9d3kuHbqjGXk/t0esuv5nnctQxwUtDWdhlT WBNDQJmaoQc6x88hasyEKh/xqBTfVvfOqls7ddRkqRQFsr3wXjVbA/7CQxLslOdQvp6U Dv2urjQPN97IT9cXiFY9E6yblu5AAtOpjutLJzxhjrlspBvD2bmQ4mRN3UI9t6v5RZJ0 LqHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=T7m/dJnwmWc1EQWY2Bp+JoHbPKGjwF+gEmVjmw4VlXI=; b=FKvMY+BAlvmnBbb62V4bEVvcBvrwna850Cpw9QSSrMrwXTqD3Jf+muUNwFMQCOrm6L V+fdVw/ULQuAPSCUVpjJn4F03XZQ0vW2f4j4xdJ51gy9nmX73UDNNzxaa2/tHuV7HOKU McM634oWns4lmR8cnaZUmqZjz8Kerjg9vbeJbAfzk9rxhyW3Q00fK9YW1Ga3fkxwE5/x d6JsNgstPurPB7ypJs/w7UTUjs6UkRcgcYd1ZVTwjiGnFGsY6u+zkV08r+pu+dYCRTDv +3tVlTlG4ViQ0Ev9S2nPzWm3lWzL597c7Y273DATWHk4J9JpBbgvlfy5JIyA8n9CtMNO Maqw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d6-20020a056a0024c600b0051be84abcc0si20391513pfv.87.2022.06.28.08.14.47; Tue, 28 Jun 2022 08:15:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345644AbiF1Oiy (ORCPT + 99 others); Tue, 28 Jun 2022 10:38:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231624AbiF1Oix (ORCPT ); Tue, 28 Jun 2022 10:38:53 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D429C2A268; Tue, 28 Jun 2022 07:38:52 -0700 (PDT) Received: from fraeml715-chm.china.huawei.com (unknown [172.18.147.207]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4LXRvF4bHKz686LW; Tue, 28 Jun 2022 22:34:49 +0800 (CST) Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by fraeml715-chm.china.huawei.com (10.206.15.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 28 Jun 2022 16:38:50 +0200 Received: from localhost (10.202.226.42) by lhreml710-chm.china.huawei.com (10.201.108.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 28 Jun 2022 15:38:49 +0100 Date: Tue, 28 Jun 2022 15:38:48 +0100 From: Jonathan Cameron To: CC: Dan Williams , Bjorn Helgaas , "Li, Ming" , Bjorn Helgaas , Lukas Wunner , Alison Schofield , Vishal Verma , "Dave Jiang" , Ben Widawsky , , , Subject: Re: [PATCH V12 3/9] PCI: Create PCIe library functions in support of DOE mailboxes. Message-ID: <20220628153848.00007818@Huawei.com> In-Reply-To: <20220628041527.742333-4-ira.weiny@intel.com> References: <20220628041527.742333-1-ira.weiny@intel.com> <20220628041527.742333-4-ira.weiny@intel.com> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.29; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.202.226.42] X-ClientProxiedBy: lhreml712-chm.china.huawei.com (10.201.108.63) To lhreml710-chm.china.huawei.com (10.201.108.61) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 27 Jun 2022 21:15:21 -0700 ira.weiny@intel.com wrote: > From: Jonathan Cameron > > Introduced in a PCIe r6.0, sec 6.30, DOE provides a config space based > mailbox with standard protocol discovery. Each mailbox is accessed > through a DOE Extended Capability. > > Each DOE mailbox must support the DOE discovery protocol in addition to > any number of additional protocols. > > Define core PCIe functionality to manage a single PCIe DOE mailbox at a > defined config space offset. Functionality includes iterating, > creating, query of supported protocol, and task submission. Destruction > of the mailboxes is device managed. > > If interrupts are desired, the interrupt number can be queried and > passed to the create function. Passing a negative value disables > interrupts for that mailbox. It is the caller's responsibility to ensure > enough interrupt vectors are allocated. > > Cc: "Li, Ming" > Cc: Bjorn Helgaas > Signed-off-by: Jonathan Cameron > Co-developed-by: Ira Weiny > Signed-off-by: Ira Weiny +static void *pci_doe_xa_entry(u16 vid, u8 prot) +{ + return (void *)(((unsigned long)vid << 16) | prot); +} ... > +static int pci_doe_cache_protocols(struct pci_doe_mb *doe_mb) > +{ > + u8 index = 0; > + u8 xa_idx = 0; > + > + do { > + int rc; > + u16 vid; > + u8 prot; > + > + rc = pci_doe_discovery(doe_mb, &index, &vid, &prot); > + if (rc) > + return rc; > + > + pci_dbg(doe_mb->pdev, > + "[%x] Found protocol %d vid: %x prot: %x\n", > + doe_mb->cap_offset, xa_idx, vid, prot); > + > + rc = xa_insert(&doe_mb->prots, xa_idx++, > + pci_doe_xa_entry(vid, prot), GFP_KERNEL); I'm not that familiar with xarray, but the docs suggest that you have to use xa_mk_value() to store an integer directly into it. > + if (rc) > + return -ENOMEM; > + } while (index); > + > + return 0; > +} > +