xen: allow determining DOM0 at runtime
[dpdk.git] / lib / librte_ether / rte_ethdev.h
index 8a8c82b..5b51fe6 100644 (file)
@@ -195,27 +195,29 @@ struct rte_eth_stats {
        uint64_t ibytes;    /**< Total number of successfully received bytes. */
        uint64_t obytes;    /**< Total number of successfully transmitted bytes. */
        uint64_t imissed;
-       /**< Deprecated; Total of RX missed packets (e.g full FIFO). */
-       uint64_t ibadcrc;
+       /**< Total of RX packets dropped by the HW,
+        * because there are no available mbufs (i.e. RX queues are full).
+        */
+       uint64_t ibadcrc __rte_deprecated;
        /**< Deprecated; Total of RX packets with CRC error. */
-       uint64_t ibadlen;
+       uint64_t ibadlen __rte_deprecated;
        /**< Deprecated; Total of RX packets with bad length. */
        uint64_t ierrors;   /**< Total number of erroneous received packets. */
        uint64_t oerrors;   /**< Total number of failed transmitted packets. */
        uint64_t imcasts;
        /**< Deprecated; Total number of multicast received packets. */
        uint64_t rx_nombuf; /**< Total number of RX mbuf allocation failures. */
-       uint64_t fdirmatch;
+       uint64_t fdirmatch __rte_deprecated;
        /**< Deprecated; Total number of RX packets matching a filter. */
-       uint64_t fdirmiss;
+       uint64_t fdirmiss __rte_deprecated;
        /**< Deprecated; Total number of RX packets not matching any filter. */
-       uint64_t tx_pause_xon;
+       uint64_t tx_pause_xon __rte_deprecated;
         /**< Deprecated; Total nb. of XON pause frame sent. */
-       uint64_t rx_pause_xon;
+       uint64_t rx_pause_xon __rte_deprecated;
        /**< Deprecated; Total nb. of XON pause frame received. */
-       uint64_t tx_pause_xoff;
+       uint64_t tx_pause_xoff __rte_deprecated;
        /**< Deprecated; Total nb. of XOFF pause frame sent. */
-       uint64_t rx_pause_xoff;
+       uint64_t rx_pause_xoff __rte_deprecated;
        /**< Deprecated; Total nb. of XOFF pause frame received. */
        uint64_t q_ipackets[RTE_ETHDEV_QUEUE_STAT_CNTRS];
        /**< Total number of queue RX packets. */
@@ -543,20 +545,20 @@ enum rte_eth_nb_pools {
 /* This structure may be extended in future. */
 struct rte_eth_dcb_rx_conf {
        enum rte_eth_nb_tcs nb_tcs; /**< Possible DCB TCs, 4 or 8 TCs */
-       uint8_t dcb_queue[ETH_DCB_NUM_USER_PRIORITIES];
-       /**< Possible DCB queue,4 or 8. */
+       /** Traffic class each UP mapped to. */
+       uint8_t dcb_tc[ETH_DCB_NUM_USER_PRIORITIES];
 };
 
 struct rte_eth_vmdq_dcb_tx_conf {
        enum rte_eth_nb_pools nb_queue_pools; /**< With DCB, 16 or 32 pools. */
-       uint8_t dcb_queue[ETH_DCB_NUM_USER_PRIORITIES];
-       /**< Possible DCB queue,4 or 8. */
+       /** Traffic class each UP mapped to. */
+       uint8_t dcb_tc[ETH_DCB_NUM_USER_PRIORITIES];
 };
 
 struct rte_eth_dcb_tx_conf {
        enum rte_eth_nb_tcs nb_tcs; /**< Possible DCB TCs, 4 or 8 TCs. */
-       uint8_t dcb_queue[ETH_DCB_NUM_USER_PRIORITIES];
-       /**< Possible DCB queue,4 or 8. */
+       /** Traffic class each UP mapped to. */
+       uint8_t dcb_tc[ETH_DCB_NUM_USER_PRIORITIES];
 };
 
 struct rte_eth_vmdq_tx_conf {
@@ -583,7 +585,7 @@ struct rte_eth_vmdq_dcb_conf {
                uint16_t vlan_id; /**< The vlan id of the received frame */
                uint64_t pools;   /**< Bitmask of pools for packet rx */
        } pool_map[ETH_VMDQ_MAX_VLAN_FILTERS]; /**< VMDq vlan pool maps. */
-       uint8_t dcb_queue[ETH_DCB_NUM_USER_PRIORITIES];
+       uint8_t dcb_tc[ETH_DCB_NUM_USER_PRIORITIES];
        /**< Selects a queue in a pool */
 };
 
@@ -652,6 +654,15 @@ struct rte_eth_txconf {
        uint8_t tx_deferred_start; /**< Do not start queue with rte_eth_dev_start(). */
 };
 
+/**
+ * A structure contains information about HW descriptor ring limitations.
+ */
+struct rte_eth_desc_lim {
+       uint16_t nb_max;   /**< Max allowed number of descriptors. */
+       uint16_t nb_min;   /**< Min allowed number of descriptors. */
+       uint16_t nb_align; /**< Number of descriptors should be aligned to. */
+};
+
 /**
  * This enum indicates the flow control mode
  */
@@ -837,8 +848,30 @@ struct rte_eth_dev_info {
        uint16_t vmdq_queue_base; /**< First queue ID for VMDQ pools. */
        uint16_t vmdq_queue_num;  /**< Queue number for VMDQ pools. */
        uint16_t vmdq_pool_base;  /**< First ID of VMDQ pools. */
+       struct rte_eth_desc_lim rx_desc_lim;  /**< RX descriptors limits */
+       struct rte_eth_desc_lim tx_desc_lim;  /**< TX descriptors limits */
 };
 
+/**
+ * Ethernet device RX queue information structure.
+ * Used to retieve information about configured queue.
+ */
+struct rte_eth_rxq_info {
+       struct rte_mempool *mp;     /**< mempool used by that queue. */
+       struct rte_eth_rxconf conf; /**< queue config parameters. */
+       uint8_t scattered_rx;       /**< scattered packets RX supported. */
+       uint16_t nb_desc;           /**< configured number of RXDs. */
+} __rte_cache_aligned;
+
+/**
+ * Ethernet device TX queue information structure.
+ * Used to retieve information about configured queue.
+ */
+struct rte_eth_txq_info {
+       struct rte_eth_txconf conf; /**< queue config parameters. */
+       uint16_t nb_desc;           /**< configured number of TXDs. */
+} __rte_cache_aligned;
+
 /** Maximum name length for extended statistics counters */
 #define RTE_ETH_XSTATS_NAME_SIZE 64
 
@@ -854,6 +887,44 @@ struct rte_eth_xstats {
        uint64_t value;
 };
 
+#define ETH_DCB_NUM_TCS    8
+#define ETH_MAX_VMDQ_POOL  64
+
+/**
+ * A structure used to get the information of queue and
+ * TC mapping on both TX and RX paths.
+ */
+struct rte_eth_dcb_tc_queue_mapping {
+       /** rx queues assigned to tc per Pool */
+       struct {
+               uint8_t base;
+               uint8_t nb_queue;
+       } tc_rxq[ETH_MAX_VMDQ_POOL][ETH_DCB_NUM_TCS];
+       /** rx queues assigned to tc per Pool */
+       struct {
+               uint8_t base;
+               uint8_t nb_queue;
+       } tc_txq[ETH_MAX_VMDQ_POOL][ETH_DCB_NUM_TCS];
+};
+
+/**
+ * A structure used to get the information of DCB.
+ * It includes TC UP mapping and queue TC mapping.
+ */
+struct rte_eth_dcb_info {
+       uint8_t nb_tcs;        /**< number of TCs */
+       uint8_t prio_tc[ETH_DCB_NUM_USER_PRIORITIES]; /**< Priority to tc */
+       uint8_t tc_bws[ETH_DCB_NUM_TCS]; /**< TX BW percentage for each TC */
+       /** rx queues assigned to tc */
+       struct rte_eth_dcb_tc_queue_mapping tc_queue;
+};
+
+/**
+ * RX/TX queue states
+ */
+#define RTE_ETH_QUEUE_STATE_STOPPED 0
+#define RTE_ETH_QUEUE_STATE_STARTED 1
+
 struct rte_eth_dev;
 
 struct rte_eth_dev_callback;
@@ -965,6 +1036,12 @@ typedef uint32_t (*eth_rx_queue_count_t)(struct rte_eth_dev *dev,
 typedef int (*eth_rx_descriptor_done_t)(void *rxq, uint16_t offset);
 /**< @internal Check DD bit of specific RX descriptor */
 
+typedef void (*eth_rxq_info_get_t)(struct rte_eth_dev *dev,
+       uint16_t rx_queue_id, struct rte_eth_rxq_info *qinfo);
+
+typedef void (*eth_txq_info_get_t)(struct rte_eth_dev *dev,
+       uint16_t tx_queue_id, struct rte_eth_txq_info *qinfo);
+
 typedef int (*mtu_set_t)(struct rte_eth_dev *dev, uint16_t mtu);
 /**< @internal Set MTU. */
 
@@ -1207,6 +1284,10 @@ typedef int (*eth_filter_ctrl_t)(struct rte_eth_dev *dev,
                                 void *arg);
 /**< @internal Take operations to assigned filter type on an Ethernet device */
 
+typedef int (*eth_get_dcb_info)(struct rte_eth_dev *dev,
+                                struct rte_eth_dcb_info *dcb_info);
+/**< @internal Get dcb information on an Ethernet device */
+
 /**
  * @internal A structure containing the functions exported by an Ethernet driver.
  */
@@ -1301,9 +1382,13 @@ struct eth_dev_ops {
        rss_hash_update_t rss_hash_update;
        /** Get current RSS hash configuration. */
        rss_hash_conf_get_t rss_hash_conf_get;
-       eth_filter_ctrl_t              filter_ctrl;          /**< common filter control*/
+       eth_filter_ctrl_t              filter_ctrl;
+       /**< common filter control. */
        eth_set_mc_addr_list_t set_mc_addr_list; /**< set list of mcast addrs */
-
+       eth_rxq_info_get_t rxq_info_get;
+       /**< retrieve RX queue information. */
+       eth_txq_info_get_t txq_info_get;
+       /**< retrieve TX queue information. */
        /** Turn IEEE1588/802.1AS timestamping on. */
        eth_timesync_enable_t timesync_enable;
        /** Turn IEEE1588/802.1AS timestamping off. */
@@ -1312,6 +1397,9 @@ struct eth_dev_ops {
        eth_timesync_read_rx_timestamp_t timesync_read_rx_timestamp;
        /** Read the IEEE1588/802.1AS TX timestamp. */
        eth_timesync_read_tx_timestamp_t timesync_read_tx_timestamp;
+
+       /** Get DCB information */
+       eth_get_dcb_info get_dcb_info;
 };
 
 /**
@@ -1471,8 +1559,21 @@ struct rte_eth_dev_data {
                all_multicast : 1, /**< RX all multicast mode ON(1) / OFF(0). */
                dev_started : 1,   /**< Device state: STARTED(1) / STOPPED(0). */
                lro         : 1;   /**< RX LRO is ON(1) / OFF(0) */
+       uint8_t rx_queue_state[RTE_MAX_QUEUES_PER_PORT];
+       /** Queues state: STARTED(1) / STOPPED(0) */
+       uint8_t tx_queue_state[RTE_MAX_QUEUES_PER_PORT];
+       /** Queues state: STARTED(1) / STOPPED(0) */
+       uint32_t dev_flags; /**< Capabilities */
+       enum rte_kernel_driver kdrv;    /**< Kernel driver passthrough */
+       int numa_node;  /**< NUMA node connection */
+       const char *drv_name;   /**< Driver name */
 };
 
+/** Device supports hotplug detach */
+#define RTE_ETH_DEV_DETACHABLE   0x0001
+/** Device supports link state interrupt */
+#define RTE_ETH_DEV_INTR_LSC     0x0002
+
 /**
  * @internal
  * The pool of *rte_eth_dev* structures. The size of the pool
@@ -3021,7 +3122,7 @@ int rte_eth_mirror_rule_reset(uint8_t port_id,
  * @param queue_idx
  *   The queue id.
  * @param tx_rate
- *   The tx rate allocated from the total link speed for this queue.
+ *   The tx rate in Mbps. Allocated from the total port link speed.
  * @return
  *   - (0) if successful.
  *   - (-ENOTSUP) if hardware doesn't support this feature.
@@ -3320,6 +3421,21 @@ int rte_eth_dev_filter_supported(uint8_t port_id, enum rte_filter_type filter_ty
 int rte_eth_dev_filter_ctrl(uint8_t port_id, enum rte_filter_type filter_type,
                        enum rte_filter_op filter_op, void *arg);
 
+/**
+ * Get DCB information on an Ethernet device.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @param dcb_info
+ *   dcb information.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENODEV) if port identifier is invalid.
+ *   - (-ENOTSUP) if hardware doesn't support.
+ */
+int rte_eth_dev_get_dcb_info(uint8_t port_id,
+                            struct rte_eth_dcb_info *dcb_info);
+
 /**
  * Add a callback to be called on packet RX on a given port and queue.
  *
@@ -3441,6 +3557,46 @@ int rte_eth_remove_tx_callback(uint8_t port_id, uint16_t queue_id,
                struct rte_eth_rxtx_callback *user_cb);
 
 /**
+ * Retrieve information about given port's RX queue.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @param queue_id
+ *   The RX queue on the Ethernet device for which information
+ *   will be retrieved.
+ * @param qinfo
+ *   A pointer to a structure of type *rte_eth_rxq_info_info* to be filled with
+ *   the information of the Ethernet device.
+ *
+ * @return
+ *   - 0: Success
+ *   - -ENOTSUP: routine is not supported by the device PMD.
+ *   - -EINVAL:  The port_id or the queue_id is out of range.
+ */
+int rte_eth_rx_queue_info_get(uint8_t port_id, uint16_t queue_id,
+       struct rte_eth_rxq_info *qinfo);
+
+/**
+ * Retrieve information about given port's TX queue.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @param queue_id
+ *   The TX queue on the Ethernet device for which information
+ *   will be retrieved.
+ * @param qinfo
+ *   A pointer to a structure of type *rte_eth_txq_info_info* to be filled with
+ *   the information of the Ethernet device.
+ *
+ * @return
+ *   - 0: Success
+ *   - -ENOTSUP: routine is not supported by the device PMD.
+ *   - -EINVAL:  The port_id or the queue_id is out of range.
+ */
+int rte_eth_tx_queue_info_get(uint8_t port_id, uint16_t queue_id,
+       struct rte_eth_txq_info *qinfo);
+
+/*
  * Retrieve number of available registers for access
  *
  * @param port_id
@@ -3598,6 +3754,44 @@ extern int rte_eth_timesync_read_rx_timestamp(uint8_t port_id,
 extern int rte_eth_timesync_read_tx_timestamp(uint8_t port_id,
                                              struct timespec *timestamp);
 
+/**
+ * Copy pci device info to the Ethernet device data.
+ *
+ * @param eth_dev
+ * The *eth_dev* pointer is the address of the *rte_eth_dev* structure.
+ * @param pci_dev
+ * The *pci_dev* pointer is the address of the *rte_pci_device* structure.
+ *
+ * @return
+ *   - 0 on success, negative on error
+ */
+extern void rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, struct rte_pci_device *pci_dev);
+
+
+/**
+ * Create memzone for HW rings.
+ * malloc can't be used as the physical address is needed.
+ * If the memzone is already created, then this function returns a ptr
+ * to the old one.
+ *
+ * @param eth_dev
+ *   The *eth_dev* pointer is the address of the *rte_eth_dev* structure
+ * @param name
+ *   The name of the memory zone
+ * @param queue_id
+ *   The index of the queue to add to name
+ * @param size
+ *   The sizeof of the memory area
+ * @param align
+ *   Alignment for resulting memzone. Must be a power of 2.
+ * @param socket_id
+ *   The *socket_id* argument is the socket identifier in case of NUMA.
+ */
+const struct rte_memzone *
+rte_eth_dma_zone_reserve(const struct rte_eth_dev *eth_dev, const char *name,
+                        uint16_t queue_id, size_t size,
+                        unsigned align, int socket_id);
+
 #ifdef __cplusplus
 }
 #endif