From patchwork Fri Jan 8 20:29:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 59392 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp752285lbb; Fri, 8 Jan 2016 11:39:57 -0800 (PST) X-Received: by 10.55.72.70 with SMTP id v67mr145189901qka.47.1452281997863; Fri, 08 Jan 2016 11:39:57 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id c65si6554371qgc.16.2016.01.08.11.39.57; Fri, 08 Jan 2016 11:39:57 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 4BC2761CBC; Fri, 8 Jan 2016 19:39:57 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=XxB7YvmO; dkim-adsp=none (unprotected policy); dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 16C3461CC1; Fri, 8 Jan 2016 19:33:19 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id DE25261790; Fri, 8 Jan 2016 19:33:12 +0000 (UTC) Received: from mail-lf0-f45.google.com (mail-lf0-f45.google.com [209.85.215.45]) by lists.linaro.org (Postfix) with ESMTPS id 0B86861790 for ; Fri, 8 Jan 2016 19:31:42 +0000 (UTC) Received: by mail-lf0-f45.google.com with SMTP id d17so15374212lfb.1 for ; Fri, 08 Jan 2016 11:31:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=U1FPsDCSeEFkHFTgkOFYETB2BZE9Whlaivkvm/YnnkM=; b=XxB7YvmOcJZBSOurHTU2QiM6nn2rstNmUAfhZPFQusu4b1VGWsAzbLDQ8MgWQbKgu9 HROXVXXpWastVQYE79zTq8/WzCLEBuvwtMx+OILmR9cCtDYEkZilAMa0TleB/9bq/wzh 2VXL3pzZyNi0INoiIDWVQsnC7y5C2CzTeCK1s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=U1FPsDCSeEFkHFTgkOFYETB2BZE9Whlaivkvm/YnnkM=; b=XL1jtIdlqAqn603xmODsxbzymBGRW7Ns1uTDJ/c8zB/Z/svz+6+2wR93ejVJkVom2A iDqXzUTBXIq8nhgUEGwzWqfHjw4chvj+1EgzKEvMs5DU4PJT1MiE6FJeqUQsOPdDgUWc +/osS7AJ8Y10D0bttz3vakurQM1ofAECgFd+yP2o3nrAZmu4ch3VSdsXhZLhqVoF0u7y LCBNQsetcCIOrTtUUSOB3S87YAYxI//WEfn8gHsN/2KOxKcAKwLcUxKLQNoLOj9rrEDI F0iPAcE0xXsf/NYu0OLulgr3MMY/Vu1zj/ALkxBB/tI2rghBKdTlIHfK2K83aljA2r5A U3Xw== X-Gm-Message-State: ALoCoQk2A25JSy2x10rdI4orCkh6dI1P+dAFW54IQUyQCc3HV1QISuxJLpnJfPY7xx8DaovAEVR2Rdciq5bIUQFqPBC1tZMJwQ== X-Received: by 10.25.21.40 with SMTP id l40mr30820556lfi.123.1452281500952; Fri, 08 Jan 2016 11:31:40 -0800 (PST) Received: from erachmi-ericsson.ki.sw.ericsson.se (c-83-233-90-46.cust.bredband2.com. [83.233.90.46]) by smtp.gmail.com with ESMTPSA id l204sm2085534lfg.49.2016.01.08.11.31.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 08 Jan 2016 11:31:40 -0800 (PST) From: Christophe Milard To: anders.roxell@linaro.org, mike.holmes@linaro.org, stuart.haslam@linaro.org, maxim.uvarov@linaro.org, bill.fischofer@linaro.org, petri.savolainen@linaro.org, edavis@broadcom.com Date: Fri, 8 Jan 2016 21:29:50 +0100 Message-Id: <1452285014-60320-8-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1452285014-60320-1-git-send-email-christophe.milard@linaro.org> References: <1452285014-60320-1-git-send-email-christophe.milard@linaro.org> Cc: lng-odp@lists.linaro.org Subject: [lng-odp] [API-NEXT RFC 07/31] driver api: adding pci interface X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Note that the functions to init/release the pci device are not part of the interface as they are expected to be used by ODP (internaly) only. Signed-off-by: Christophe Milard --- include/odp/api/pci.h | 131 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/odp_driver.h | 1 + 2 files changed, 132 insertions(+) create mode 100644 include/odp/api/pci.h diff --git a/include/odp/api/pci.h b/include/odp/api/pci.h new file mode 100644 index 0000000..3fe36ce --- /dev/null +++ b/include/odp/api/pci.h @@ -0,0 +1,131 @@ +/* Copyright (c) 2015, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODP interface to PCI (for drivers) + */ + +#ifndef ODP_API_PCI_H_ +#define ODP_API_PCI_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** @defgroup odp_pci PCI + * @{ + */ + +/** + * @typedef odp_pci_dev_t + * An ODP PCI device. + */ + +/** + * get the vendor_id from a pci device + * + * @param dev the pci device as returned by odp_pci_init + * @returns the pci device vendor ID + */ +uint16_t odp_pci_get_vendor(odp_pci_dev_t pci_dev); +/** + * get the device_id from a pci device + * + * @param dev the pci device as returned by odp_pci_init + * @returns the pci device ID + */ +uint16_t odp_pci_get_device(odp_pci_dev_t pci_dev); +/** + * get the subsystem_vendor_id from a pci device + * + * @param dev the pci device as returned by odp_pci_init + * @returns the pci device subsystem vendor ID + */ +uint16_t odp_pci_get_subsystem_vendor(odp_pci_dev_t pci_dev); +/** + * get the subsystem_device_id from a pci device + * + * @param dev the pci device as returned by odp_pci_init + * @returns the pci device subsystem device ID + */ +uint16_t odp_pci_get_subsystem_device(odp_pci_dev_t pci_dev); +/** + * get the address of resource (BAR) + * + * @param dev the pci device as returned by odp_pci_init + * @param bar the resource region number (0-5) + * @returns the userspace virtual base address for that resource. + */ +void *odp_pci_get_resource_addr(odp_pci_dev_t pci_dev, int bar); +/** + * get the PCI address + * + * @param dev the pci device as returned by odp_pci_init + * @returns the PCI address, ::: + * as a string (e.g. "0000:23:00.0") + */ +char *odp_pci_get_addr_str(odp_pci_dev_t pci_dev); + +/** + * DMA map a (possibly fragmented) DMA region + * + * @param dev the pci device as returned by odp_pci_init + * @param region A DMA region descriptor + * + * @returns 0 on success or a negative value on error + */ +int odp_pci_map_dma_region(odp_pci_dev_t dev, odp_dma_map_t region); + +/** + * DMA unmap a (possibly fragmented) DMA region + * + * @param dev the pci device as returned by odp_pci_init + * @param region A DMA region descriptor + * + * @returns 0 on success or a negative value on error + */ +int odp_pci_unmap_dma_region(odp_pci_dev_t dev, odp_dma_map_t region); + +/** + * Read the PCI config area + * + * @param dev the pci device as returned by odp_pci_init + * @param buf where to write the read data + * @param len the number of bytes to read + * @param offs the offset where read should start + * + * @returns the number of read bytes + */ + +int odp_pci_read_config(odp_pci_dev_t dev, void *buf, size_t len, int offs); + +/** + * Write the PCI config area + * + * @param dev the pci device as returned by odp_pci_init + * @param buf where to take the data to be written + * @param len the number of bytes to written + * @param offs the offset where data should be written + * + * @returns the number of written bytes + */ + +int odp_pci_write_config(odp_pci_dev_t dev, const void *buf, + size_t len, int offs); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* ODP_API_PCI_H_ */ diff --git a/include/odp_driver.h b/include/odp_driver.h index b59f7df..6c1eded 100644 --- a/include/odp_driver.h +++ b/include/odp_driver.h @@ -22,6 +22,7 @@ extern "C" { #include #include #include +#include #include #include #include