doc: add Meson coding style to contributors guide
[dpdk.git] / lib / librte_ethdev / rte_ethdev.h
index 69fc973..3b773b6 100644 (file)
@@ -20,7 +20,7 @@
  * - The driver-oriented Ethernet API that exports functions allowing
  *   an Ethernet Poll Mode Driver (PMD) to allocate an Ethernet device instance,
  *   create memzone for HW rings and process registered callbacks, and so on.
- *   PMDs should include rte_ethdev_driver.h instead of this header.
+ *   PMDs should include ethdev_driver.h instead of this header.
  *
  * By default, all the functions of the Ethernet Device API exported by a PMD
  * are lock-free functions which assume to not be invoked in parallel on
@@ -148,6 +148,12 @@ extern "C" {
 /* Use this macro to check if LRO API is supported */
 #define RTE_ETHDEV_HAS_LRO_SUPPORT
 
+/* Alias RTE_LIBRTE_ETHDEV_DEBUG for backward compatibility. */
+#ifdef RTE_LIBRTE_ETHDEV_DEBUG
+#define RTE_ETHDEV_DEBUG_RX
+#define RTE_ETHDEV_DEBUG_TX
+#endif
+
 #include <rte_compat.h>
 #include <rte_log.h>
 #include <rte_interrupts.h>
@@ -157,6 +163,7 @@ extern "C" {
 #include <rte_common.h>
 #include <rte_config.h>
 #include <rte_ether.h>
+#include <rte_power_intrinsics.h>
 
 #include "rte_ethdev_trace_fp.h"
 #include "rte_dev_info.h"
@@ -240,6 +247,9 @@ void rte_eth_iterator_cleanup(struct rte_dev_iterator *iter);
  * Not all statistics fields in struct rte_eth_stats are supported
  * by any type of network interface card (NIC). If any statistics
  * field is not supported, its value is 0.
+ * All byte-related statistics do not include Ethernet FCS regardless
+ * of whether these bytes have been delivered to the application
+ * (see DEV_RX_OFFLOAD_KEEP_CRC).
  */
 struct rte_eth_stats {
        uint64_t ipackets;  /**< Total number of successfully received packets. */
@@ -525,6 +535,8 @@ struct rte_eth_rss_conf {
 #define ETH_RSS_L2TPV3             (1ULL << 29)
 #define ETH_RSS_PFCP               (1ULL << 30)
 #define ETH_RSS_PPPOE             (1ULL << 31)
+#define ETH_RSS_ECPRI             (1ULL << 32)
+#define ETH_RSS_MPLS              (1ULL << 33)
 
 /*
  * We use the following macros to combine with above ETH_RSS_* for
@@ -756,7 +768,8 @@ rte_eth_rss_hf_refine(uint64_t rss_hf)
        ETH_RSS_PORT  | \
        ETH_RSS_VXLAN | \
        ETH_RSS_GENEVE | \
-       ETH_RSS_NVGRE)
+       ETH_RSS_NVGRE | \
+       ETH_RSS_MPLS)
 
 /*
  * Definitions used for redirection table entry size.
@@ -1207,7 +1220,8 @@ struct rte_eth_pfc_conf {
 };
 
 /**
- * Tunneled type.
+ * Tunnel type for device-specific classifier configuration.
+ * @see rte_eth_udp_tunnel
  */
 enum rte_eth_tunnel_type {
        RTE_TUNNEL_TYPE_NONE = 0,
@@ -1218,6 +1232,7 @@ enum rte_eth_tunnel_type {
        RTE_TUNNEL_TYPE_IP_IN_GRE,
        RTE_L2_TUNNEL_TYPE_E_TAG,
        RTE_TUNNEL_TYPE_VXLAN_GPE,
+       RTE_TUNNEL_TYPE_ECPRI,
        RTE_TUNNEL_TYPE_MAX,
 };
 
@@ -1262,14 +1277,16 @@ struct rte_fdir_conf {
 
 /**
  * UDP tunneling configuration.
- * Used to config the UDP port for a type of tunnel.
- * NICs need the UDP port to identify the tunnel type.
- * Normally a type of tunnel has a default UDP port, this structure can be used
- * in case if the users want to change or support more UDP port.
+ *
+ * Used to configure the classifier of a device,
+ * associating an UDP port with a type of tunnel.
+ *
+ * Some NICs may need such configuration to properly parse a tunnel
+ * with any standard or custom UDP port.
  */
 struct rte_eth_udp_tunnel {
        uint16_t udp_port; /**< UDP port used for the tunnel. */
-       uint8_t prot_type; /**< Tunnel type. Defined in rte_eth_tunnel_type. */
+       uint8_t prot_type; /**< Tunnel type. @see rte_eth_tunnel_type */
 };
 
 /**
@@ -1495,6 +1512,16 @@ struct rte_eth_rxseg_capa {
  * Ethernet device information
  */
 
+/**
+ * Ethernet device representor port type.
+ */
+enum rte_eth_representor_type {
+       RTE_ETH_REPRESENTOR_NONE, /**< not a representor. */
+       RTE_ETH_REPRESENTOR_VF,   /**< representor of Virtual Function. */
+       RTE_ETH_REPRESENTOR_SF,   /**< representor of Sub Function. */
+       RTE_ETH_REPRESENTOR_PF,   /**< representor of Physical Function. */
+};
+
 /**
  * A structure used to retrieve the contextual information of
  * an Ethernet device, such as the controlling driver of the
@@ -3860,7 +3887,7 @@ int rte_eth_dev_rss_reta_update(uint16_t port_id,
                                struct rte_eth_rss_reta_entry64 *reta_conf,
                                uint16_t reta_size);
 
- /**
+/**
  * Query Redirection Table(RETA) of Receive Side Scaling of Ethernet device.
  *
  * @param port_id
@@ -3882,7 +3909,7 @@ int rte_eth_dev_rss_reta_query(uint16_t port_id,
                               struct rte_eth_rss_reta_entry64 *reta_conf,
                               uint16_t reta_size);
 
- /**
+/**
  * Updates unicast hash table for receiving packet with the given destination
  * MAC address, and the packet is routed to all VFs for which the RX mode is
  * accept packets that match the unicast hash table.
@@ -3904,7 +3931,7 @@ int rte_eth_dev_rss_reta_query(uint16_t port_id,
 int rte_eth_dev_uc_hash_table_set(uint16_t port_id, struct rte_ether_addr *addr,
                                  uint8_t on);
 
- /**
+/**
  * Updates all unicast hash bitmaps for receiving packet with any Unicast
  * Ethernet MAC addresses,the packet is routed to all VFs for which the RX
  * mode is accept packets that match the unicast hash table.
@@ -3987,7 +4014,7 @@ int rte_eth_mirror_rule_reset(uint16_t port_id,
 int rte_eth_set_queue_rate_limit(uint16_t port_id, uint16_t queue_idx,
                        uint16_t tx_rate);
 
- /**
+/**
  * Configuration of Receive Side Scaling hash computation of Ethernet device.
  *
  * @param port_id
@@ -4004,7 +4031,7 @@ int rte_eth_set_queue_rate_limit(uint16_t port_id, uint16_t queue_idx,
 int rte_eth_dev_rss_hash_update(uint16_t port_id,
                                struct rte_eth_rss_conf *rss_conf);
 
- /**
+/**
  * Retrieve current configuration of Receive Side Scaling hash computation
  * of Ethernet device.
  *
@@ -4022,12 +4049,18 @@ int
 rte_eth_dev_rss_hash_conf_get(uint16_t port_id,
                              struct rte_eth_rss_conf *rss_conf);
 
- /**
- * Add UDP tunneling port for a specific type of tunnel.
- * The packets with this UDP port will be identified as this type of tunnel.
- * Before enabling any offloading function for a tunnel, users can call this API
- * to change or add more UDP port for the tunnel. So the offloading function
- * can take effect on the packets with the specific UDP port.
+/**
+ * Add UDP tunneling port for a type of tunnel.
+ *
+ * Some NICs may require such configuration to properly parse a tunnel
+ * with any standard or custom UDP port.
+ * The packets with this UDP port will be parsed for this type of tunnel.
+ * The device parser will also check the rest of the tunnel headers
+ * before classifying the packet.
+ *
+ * With some devices, this API will affect packet classification, i.e.:
+ *     - mbuf.packet_type reported on Rx
+ *     - rte_flow rules with tunnel items
  *
  * @param port_id
  *   The port identifier of the Ethernet device.
@@ -4044,13 +4077,13 @@ int
 rte_eth_dev_udp_tunnel_port_add(uint16_t port_id,
                                struct rte_eth_udp_tunnel *tunnel_udp);
 
- /**
- * Delete UDP tunneling port a specific type of tunnel.
- * The packets with this UDP port will not be identified as this type of tunnel
- * any more.
- * Before enabling any offloading function for a tunnel, users can call this API
- * to delete a UDP port for the tunnel. So the offloading function will not take
- * effect on the packets with the specific UDP port.
+/**
+ * Delete UDP tunneling port for a type of tunnel.
+ *
+ * The packets with this UDP port will not be classified as this type of tunnel
+ * anymore if the device use such mapping for tunnel packet classification.
+ *
+ * @see rte_eth_dev_udp_tunnel_port_add
  *
  * @param port_id
  *   The port identifier of the Ethernet device.
@@ -4333,6 +4366,30 @@ __rte_experimental
 int rte_eth_tx_burst_mode_get(uint16_t port_id, uint16_t queue_id,
        struct rte_eth_burst_mode *mode);
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice.
+ *
+ * Retrieve the monitor condition for a given receive 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 pmc
+ *   The pointer to power-optimized monitoring condition structure.
+ *
+ * @return
+ *   - 0: Success.
+ *   -ENOTSUP: Operation not supported.
+ *   -EINVAL: Invalid parameters.
+ *   -ENODEV: Invalid port ID.
+ */
+__rte_experimental
+int rte_eth_get_monitor_addr(uint16_t port_id, uint16_t queue_id,
+               struct rte_power_monitor_cond *pmc);
+
 /**
  * Retrieve device registers and register attributes (number of registers and
  * register size)
@@ -4346,6 +4403,7 @@ int rte_eth_tx_burst_mode_get(uint16_t port_id, uint16_t queue_id,
  * @return
  *   - (0) if successful.
  *   - (-ENOTSUP) if hardware doesn't support.
+ *   - (-EINVAL) if bad parameter.
  *   - (-ENODEV) if *port_id* invalid.
  *   - (-EIO) if device is removed.
  *   - others depends on the specific operations implementation.
@@ -4377,6 +4435,7 @@ int rte_eth_dev_get_eeprom_length(uint16_t port_id);
  * @return
  *   - (0) if successful.
  *   - (-ENOTSUP) if hardware doesn't support.
+ *   - (-EINVAL) if bad parameter.
  *   - (-ENODEV) if *port_id* invalid.
  *   - (-EIO) if device is removed.
  *   - others depends on the specific operations implementation.
@@ -4395,6 +4454,7 @@ int rte_eth_dev_get_eeprom(uint16_t port_id, struct rte_dev_eeprom_info *info);
  *   - (0) if successful.
  *   - (-ENOTSUP) if hardware doesn't support.
  *   - (-ENODEV) if *port_id* invalid.
+ *   - (-EINVAL) if bad parameter.
  *   - (-EIO) if device is removed.
  *   - others depends on the specific operations implementation.
  */
@@ -4414,6 +4474,7 @@ int rte_eth_dev_set_eeprom(uint16_t port_id, struct rte_dev_eeprom_info *info);
  *   - (0) if successful.
  *   - (-ENOTSUP) if hardware doesn't support.
  *   - (-ENODEV) if *port_id* invalid.
+ *   - (-EINVAL) if bad parameter.
  *   - (-EIO) if device is removed.
  *   - others depends on the specific operations implementation.
  */
@@ -4436,6 +4497,7 @@ rte_eth_dev_get_module_info(uint16_t port_id,
  * @return
  *   - (0) if successful.
  *   - (-ENOTSUP) if hardware doesn't support.
+ *   - (-EINVAL) if bad parameter.
  *   - (-ENODEV) if *port_id* invalid.
  *   - (-EIO) if device is removed.
  *   - others depends on the specific operations implementation.
@@ -4740,6 +4802,60 @@ __rte_experimental
 int rte_eth_dev_hairpin_capability_get(uint16_t port_id,
                                       struct rte_eth_hairpin_cap *cap);
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice.
+ *
+ * ethernet device representor ID range entry
+ */
+struct rte_eth_representor_range {
+       enum rte_eth_representor_type type; /**< Representor type */
+       int controller; /**< Controller index */
+       int pf; /**< Physical function index */
+       __extension__
+       union {
+               int vf; /**< VF start index */
+               int sf; /**< SF start index */
+       };
+       uint32_t id_base; /**< Representor ID start index */
+       uint32_t id_end;  /**< Representor ID end index */
+       char name[RTE_DEV_NAME_MAX_LEN]; /**< Representor name */
+};
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice.
+ *
+ * Ethernet device representor information
+ */
+struct rte_eth_representor_info {
+       uint16_t controller; /**< Controller ID of caller device. */
+       uint16_t pf; /**< Physical function ID of caller device. */
+       struct rte_eth_representor_range ranges[];/**< Representor ID range. */
+};
+
+/**
+ * Retrieve the representor info of the device.
+ *
+ * Get device representor info to be able to calculate a unique
+ * representor ID. @see rte_eth_representor_id_get helper.
+ *
+ * @param port_id
+ *   The port identifier of the device.
+ * @param info
+ *   A pointer to a representor info structure.
+ *   NULL to return number of range entries and allocate memory
+ *   for next call to store detail.
+ * @return
+ *   - (-ENOTSUP) if operation is not supported.
+ *   - (-ENODEV) if *port_id* invalid.
+ *   - (-EIO) if device is removed.
+ *   - (>=0) number of representor range entries supported by device.
+ */
+__rte_experimental
+int rte_eth_representor_info_get(uint16_t port_id,
+                                struct rte_eth_representor_info *info);
+
 #include <rte_ethdev_core.h>
 
 /**
@@ -4836,7 +4952,7 @@ rte_eth_rx_burst(uint16_t port_id, uint16_t queue_id,
        struct rte_eth_dev *dev = &rte_eth_devices[port_id];
        uint16_t nb_rx;
 
-#ifdef RTE_LIBRTE_ETHDEV_DEBUG
+#ifdef RTE_ETHDEV_DEBUG_RX
        RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
        RTE_FUNC_PTR_OR_ERR_RET(*dev->rx_pkt_burst, 0);
 
@@ -4970,11 +5086,11 @@ rte_eth_rx_descriptor_status(uint16_t port_id, uint16_t queue_id,
        struct rte_eth_dev *dev;
        void *rxq;
 
-#ifdef RTE_LIBRTE_ETHDEV_DEBUG
+#ifdef RTE_ETHDEV_DEBUG_RX
        RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 #endif
        dev = &rte_eth_devices[port_id];
-#ifdef RTE_LIBRTE_ETHDEV_DEBUG
+#ifdef RTE_ETHDEV_DEBUG_RX
        if (queue_id >= dev->data->nb_rx_queues)
                return -ENODEV;
 #endif
@@ -5027,11 +5143,11 @@ static inline int rte_eth_tx_descriptor_status(uint16_t port_id,
        struct rte_eth_dev *dev;
        void *txq;
 
-#ifdef RTE_LIBRTE_ETHDEV_DEBUG
+#ifdef RTE_ETHDEV_DEBUG_TX
        RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 #endif
        dev = &rte_eth_devices[port_id];
-#ifdef RTE_LIBRTE_ETHDEV_DEBUG
+#ifdef RTE_ETHDEV_DEBUG_TX
        if (queue_id >= dev->data->nb_tx_queues)
                return -ENODEV;
 #endif
@@ -5113,7 +5229,7 @@ rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id,
 {
        struct rte_eth_dev *dev = &rte_eth_devices[port_id];
 
-#ifdef RTE_LIBRTE_ETHDEV_DEBUG
+#ifdef RTE_ETHDEV_DEBUG_TX
        RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
        RTE_FUNC_PTR_OR_ERR_RET(*dev->tx_pkt_burst, 0);
 
@@ -5211,7 +5327,7 @@ rte_eth_tx_prepare(uint16_t port_id, uint16_t queue_id,
 {
        struct rte_eth_dev *dev;
 
-#ifdef RTE_LIBRTE_ETHDEV_DEBUG
+#ifdef RTE_ETHDEV_DEBUG_TX
        if (!rte_eth_dev_is_valid_port(port_id)) {
                RTE_ETHDEV_LOG(ERR, "Invalid TX port_id=%u\n", port_id);
                rte_errno = ENODEV;
@@ -5221,7 +5337,7 @@ rte_eth_tx_prepare(uint16_t port_id, uint16_t queue_id,
 
        dev = &rte_eth_devices[port_id];
 
-#ifdef RTE_LIBRTE_ETHDEV_DEBUG
+#ifdef RTE_ETHDEV_DEBUG_TX
        if (queue_id >= dev->data->nb_tx_queues) {
                RTE_ETHDEV_LOG(ERR, "Invalid TX queue_id=%u\n", queue_id);
                rte_errno = EINVAL;