net/bnxt: fix mbuf flags for PTP packets
[dpdk.git] / lib / librte_pci / rte_pci.h
index ea0897c..f89c7db 100644 (file)
@@ -1,35 +1,6 @@
-/*-
- *   BSD LICENSE
- *
- *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
- *   Copyright 2013-2014 6WIND S.A.
- *   All rights reserved.
- *
- *   Redistribution and use in source and binary forms, with or without
- *   modification, are permitted provided that the following conditions
- *   are met:
- *
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above copyright
- *       notice, this list of conditions and the following disclaimer in
- *       the documentation and/or other materials provided with the
- *       distribution.
- *     * Neither the name of Intel Corporation nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2015 Intel Corporation.
+ * Copyright 2013-2014 6WIND S.A.
  */
 
 #ifndef _RTE_PCI_H_
@@ -46,18 +17,47 @@ extern "C" {
 #endif
 
 #include <stdio.h>
-#include <stdlib.h>
 #include <limits.h>
-#include <errno.h>
 #include <sys/queue.h>
-#include <stdint.h>
 #include <inttypes.h>
+#include <sys/types.h>
 
-#include <rte_debug.h>
-#include <rte_interrupts.h>
+/*
+ * Conventional PCI and PCI-X Mode 1 devices have 256 bytes of
+ * configuration space.  PCI-X Mode 2 and PCIe devices have 4096 bytes of
+ * configuration space.
+ */
+#define RTE_PCI_CFG_SPACE_SIZE         256
+#define RTE_PCI_CFG_SPACE_EXP_SIZE     4096
+
+#define RTE_PCI_VENDOR_ID      0x00    /* 16 bits */
+#define RTE_PCI_DEVICE_ID      0x02    /* 16 bits */
+
+/* PCI Express capability registers */
+#define RTE_PCI_EXP_DEVCTL     8       /* Device Control */
+
+/* Extended Capabilities (PCI-X 2.0 and Express) */
+#define RTE_PCI_EXT_CAP_ID(header)     (header & 0x0000ffff)
+#define RTE_PCI_EXT_CAP_NEXT(header)   ((header >> 20) & 0xffc)
+
+#define RTE_PCI_EXT_CAP_ID_ERR         0x01    /* Advanced Error Reporting */
+#define RTE_PCI_EXT_CAP_ID_DSN         0x03    /* Device Serial Number */
+#define RTE_PCI_EXT_CAP_ID_SRIOV       0x10    /* SR-IOV*/
+
+/* Single Root I/O Virtualization */
+#define RTE_PCI_SRIOV_CAP              0x04    /* SR-IOV Capabilities */
+#define RTE_PCI_SRIOV_CTRL             0x08    /* SR-IOV Control */
+#define RTE_PCI_SRIOV_INITIAL_VF       0x0c    /* Initial VFs */
+#define RTE_PCI_SRIOV_TOTAL_VF         0x0e    /* Total VFs */
+#define RTE_PCI_SRIOV_NUM_VF           0x10    /* Number of VFs */
+#define RTE_PCI_SRIOV_FUNC_LINK                0x12    /* Function Dependency Link */
+#define RTE_PCI_SRIOV_VF_OFFSET                0x14    /* First VF Offset */
+#define RTE_PCI_SRIOV_VF_STRIDE                0x16    /* Following VF Stride */
+#define RTE_PCI_SRIOV_VF_DID           0x1a    /* VF Device ID */
+#define RTE_PCI_SRIOV_SUP_PGSIZE       0x1c    /* Supported Page Sizes */
 
 /** Formatting string for PCI device identifier: Ex: 0000:00:01.0 */
-#define PCI_PRI_FMT "%.4" PRIx16 ":%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8
+#define PCI_PRI_FMT "%.4" PRIx32 ":%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8
 #define PCI_PRI_STR_SIZE sizeof("XXXXXXXX:XX:XX.X")
 
 /** Short formatting string, without domain, for PCI device: Ex: 00:01.0 */
@@ -99,74 +99,6 @@ struct rte_pci_addr {
 #define RTE_CLASS_ANY_ID (0xffffff)
 
 /**
- * A structure describing a PCI mapping.
- */
-struct pci_map {
-       void *addr;
-       char *path;
-       uint64_t offset;
-       uint64_t size;
-       uint64_t phaddr;
-};
-
-struct pci_msix_table {
-       int bar_index;
-       uint32_t offset;
-       uint32_t size;
-};
-
-/**
- * A structure describing a mapped PCI resource.
- * For multi-process we need to reproduce all PCI mappings in secondary
- * processes, so save them in a tailq.
- */
-struct mapped_pci_resource {
-       TAILQ_ENTRY(mapped_pci_resource) next;
-
-       struct rte_pci_addr pci_addr;
-       char path[PATH_MAX];
-       int nb_maps;
-       struct pci_map maps[PCI_MAX_RESOURCE];
-       struct pci_msix_table msix_table;
-};
-
-
-/** mapped pci device list */
-TAILQ_HEAD(mapped_pci_res_list, mapped_pci_resource);
-
-/**
- * @deprecated
- * Utility function to produce a PCI Bus-Device-Function value
- * given a string representation. Assumes that the BDF is provided without
- * a domain prefix (i.e. domain returned is always 0)
- *
- * @param input
- *     The input string to be parsed. Should have the format XX:XX.X
- * @param dev_addr
- *     The PCI Bus-Device-Function address to be returned.
- *     Domain will always be returned as 0
- * @return
- *  0 on success, negative on error.
- */
-int eal_parse_pci_BDF(const char *input, struct rte_pci_addr *dev_addr);
-
-/**
- * @deprecated
- * Utility function to produce a PCI Bus-Device-Function value
- * given a string representation. Assumes that the BDF is provided including
- * a domain prefix.
- *
- * @param input
- *     The input string to be parsed. Should have the format XXXX:XX:XX.X
- * @param dev_addr
- *     The PCI Bus-Device-Function address to be returned
- * @return
- *  0 on success, negative on error.
- */
-int eal_parse_pci_DomBDF(const char *input, struct rte_pci_addr *dev_addr);
-
-/**
- * @deprecated
  * Utility function to write a pci device name, this device name can later be
  * used to retrieve the corresponding rte_pci_addr using eal_parse_pci_*
  * BDF helpers.
@@ -179,39 +111,8 @@ int eal_parse_pci_DomBDF(const char *input, struct rte_pci_addr *dev_addr);
  *     The output buffer size
  */
 void rte_pci_device_name(const struct rte_pci_addr *addr,
-                        char *output, size_t size);
-
-/**
- * Utility function to write a pci device name, this device name can later be
- * used to retrieve the corresponding rte_pci_addr using eal_parse_pci_*
- * BDF helpers.
- *
- * @param addr
- *     The PCI Bus-Device-Function address
- * @param output
- *     The output buffer string
- * @param size
- *     The output buffer size
- */
-void pci_device_name(const struct rte_pci_addr *addr,
                     char *output, size_t size);
 
-/**
- * @deprecated
- * Utility function to compare two PCI device addresses.
- *
- * @param addr
- *     The PCI Bus-Device-Function address to compare
- * @param addr2
- *     The PCI Bus-Device-Function address to compare
- * @return
- *     0 on equal PCI address.
- *     Positive on addr is greater than addr2.
- *     Negative on addr is less than addr2, or error.
- */
-int rte_eal_compare_pci_addr(const struct rte_pci_addr *addr,
-                            const struct rte_pci_addr *addr2);
-
 /**
  * Utility function to compare two PCI device addresses.
  *
@@ -224,8 +125,8 @@ int rte_eal_compare_pci_addr(const struct rte_pci_addr *addr,
  *     Positive on addr is greater than addr2.
  *     Negative on addr is less than addr2, or error.
  */
-int pci_addr_cmp(const struct rte_pci_addr *addr,
-                const struct rte_pci_addr *addr2);
+int rte_pci_addr_cmp(const struct rte_pci_addr *addr,
+                    const struct rte_pci_addr *addr2);
 
 
 /**
@@ -240,37 +141,7 @@ int pci_addr_cmp(const struct rte_pci_addr *addr,
  *     0 on success
  *     <0 otherwise
  */
-int pci_addr_parse(const char *str, struct rte_pci_addr *addr);
-
-/**
- * Map a particular resource from a file.
- *
- * @param requested_addr
- *      The starting address for the new mapping range.
- * @param fd
- *      The file descriptor.
- * @param offset
- *      The offset for the mapping range.
- * @param size
- *      The size for the mapping range.
- * @param additional_flags
- *      The additional flags for the mapping range.
- * @return
- *   - On success, the function returns a pointer to the mapped area.
- *   - On error, the value MAP_FAILED is returned.
- */
-void *pci_map_resource(void *requested_addr, int fd, off_t offset,
-               size_t size, int additional_flags);
-
-/**
- * Unmap a particular resource.
- *
- * @param requested_addr
- *      The address for the unmapping range.
- * @param size
- *      The size for the unmapping range.
- */
-void pci_unmap_resource(void *requested_addr, size_t size);
+int rte_pci_addr_parse(const char *str, struct rte_pci_addr *addr);
 
 #ifdef __cplusplus
 }