ethdev: insert Rx callback as head of list
[dpdk.git] / lib / librte_ether / rte_ethdev.h
index 1342b3a..c7983d3 100644 (file)
@@ -200,27 +200,9 @@ struct rte_eth_stats {
        /**< 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 __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 __rte_deprecated;
-       /**< Deprecated; Total number of RX packets matching a filter. */
-       uint64_t fdirmiss __rte_deprecated;
-       /**< Deprecated; Total number of RX packets not matching any filter. */
-       uint64_t tx_pause_xon __rte_deprecated;
-        /**< Deprecated; Total nb. of XON pause frame sent. */
-       uint64_t rx_pause_xon __rte_deprecated;
-       /**< Deprecated; Total nb. of XON pause frame received. */
-       uint64_t tx_pause_xoff __rte_deprecated;
-       /**< Deprecated; Total nb. of XOFF pause frame sent. */
-       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. */
        uint64_t q_opackets[RTE_ETHDEV_QUEUE_STAT_CNTRS];
@@ -231,14 +213,6 @@ struct rte_eth_stats {
        /**< Total number of successfully transmitted queue bytes. */
        uint64_t q_errors[RTE_ETHDEV_QUEUE_STAT_CNTRS];
        /**< Total number of queue packets received that are dropped. */
-       uint64_t ilbpackets;
-       /**< Total number of good packets received from loopback,VF Only */
-       uint64_t olbpackets;
-       /**< Total number of good packets transmitted to loopback,VF Only */
-       uint64_t ilbbytes;
-       /**< Total number of good bytes received from loopback,VF Only */
-       uint64_t olbbytes;
-       /**< Total number of good bytes transmitted to loopback,VF Only */
 };
 
 /**
@@ -259,6 +233,7 @@ struct rte_eth_stats {
 #define ETH_LINK_SPEED_40G      (1 << 11)  /**<  40 Gbps */
 #define ETH_LINK_SPEED_50G      (1 << 12)  /**<  50 Gbps */
 #define ETH_LINK_SPEED_56G      (1 << 13)  /**<  56 Gbps */
+#define ETH_LINK_SPEED_100G     (1 << 14)  /**< 100 Gbps */
 
 /**
  * Ethernet numeric link speeds in Mbps
@@ -275,12 +250,13 @@ struct rte_eth_stats {
 #define ETH_SPEED_NUM_40G      40000 /**<  40 Gbps */
 #define ETH_SPEED_NUM_50G      50000 /**<  50 Gbps */
 #define ETH_SPEED_NUM_56G      56000 /**<  56 Gbps */
+#define ETH_SPEED_NUM_100G    100000 /**< 100 Gbps */
 
 /**
  * A structure used to retrieve link-level information of an Ethernet port.
  */
 struct rte_eth_link {
-       uint16_t link_speed;        /**< ETH_SPEED_NUM_ */
+       uint32_t link_speed;        /**< ETH_SPEED_NUM_ */
        uint16_t link_duplex  : 1;  /**< ETH_LINK_[HALF/FULL]_DUPLEX */
        uint16_t link_autoneg : 1;  /**< ETH_LINK_SPEED_[AUTONEG/FIXED] */
        uint16_t link_status  : 1;  /**< ETH_LINK_[DOWN/UP] */
@@ -938,11 +914,22 @@ struct rte_eth_txq_info {
  * statistics that are not provided in the generic rte_eth_stats
  * structure.
  */
-struct rte_eth_xstats {
-       char name[RTE_ETH_XSTATS_NAME_SIZE];
+struct rte_eth_xstat {
+       uint64_t id;
        uint64_t value;
 };
 
+/**
+ * A name-key lookup element for extended statistics.
+ *
+ * This structure is used to map between names and ID numbers
+ * for extended ethernet statistics.
+ */
+struct rte_eth_xstat_name {
+       char name[RTE_ETH_XSTATS_NAME_SIZE];
+       uint64_t id;
+};
+
 #define ETH_DCB_NUM_TCS    8
 #define ETH_MAX_VMDQ_POOL  64
 
@@ -1072,12 +1059,16 @@ typedef void (*eth_stats_reset_t)(struct rte_eth_dev *dev);
 /**< @internal Reset global I/O statistics of an Ethernet device to 0. */
 
 typedef int (*eth_xstats_get_t)(struct rte_eth_dev *dev,
-       struct rte_eth_xstats *stats, unsigned n);
+       struct rte_eth_xstat *stats, unsigned n);
 /**< @internal Get extended stats of an Ethernet device. */
 
 typedef void (*eth_xstats_reset_t)(struct rte_eth_dev *dev);
 /**< @internal Reset extended stats of an Ethernet device. */
 
+typedef int (*eth_xstats_get_names_t)(struct rte_eth_dev *dev,
+       struct rte_eth_xstat_name *xstats_names, unsigned size);
+/**< @internal Get names of extended stats of an Ethernet device. */
+
 typedef int (*eth_queue_stats_mapping_set_t)(struct rte_eth_dev *dev,
                                             uint16_t queue_id,
                                             uint8_t stat_idx,
@@ -1425,6 +1416,8 @@ struct eth_dev_ops {
        eth_stats_reset_t          stats_reset;   /**< Reset generic device statistics. */
        eth_xstats_get_t           xstats_get;    /**< Get extended device statistics. */
        eth_xstats_reset_t         xstats_reset;  /**< Reset extended device statistics. */
+       eth_xstats_get_names_t     xstats_get_names;
+       /**< Get names of extended statistics. */
        eth_queue_stats_mapping_set_t queue_stats_mapping_set;
        /**< Configure per queue stat counter mapping. */
        eth_dev_infos_get_t        dev_infos_get; /**< Get device info. */
@@ -2276,6 +2269,29 @@ int rte_eth_stats_get(uint8_t port_id, struct rte_eth_stats *stats);
  */
 void rte_eth_stats_reset(uint8_t port_id);
 
+/**
+ * Retrieve names of extended statistics of an Ethernet device.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @param xstats_names
+ *  Block of memory to insert names into. Must be at least size in capacity.
+ *  If set to NULL, function returns required capacity.
+ * @param size
+ *  Capacity of xstats_names (number of names).
+ * @return
+ *   - positive value lower or equal to size: success. The return value
+ *     is the number of entries filled in the stats table.
+ *   - positive value higher than size: error, the given statistics table
+ *     is too small. The return value corresponds to the size that should
+ *     be given to succeed. The entries in the table are not valid and
+ *     shall not be used by the caller.
+ *   - negative value on error (invalid port id)
+ */
+int rte_eth_xstats_get_names(uint8_t port_id,
+               struct rte_eth_xstat_name *xstats_names,
+               unsigned size);
+
 /**
  * Retrieve extended statistics of an Ethernet device.
  *
@@ -2297,7 +2313,7 @@ void rte_eth_stats_reset(uint8_t port_id);
  *     shall not be used by the caller.
  *   - negative value on error (invalid port id)
  */
-int rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats,
+int rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstat *xstats,
                unsigned n);
 
 /**
@@ -2377,6 +2393,9 @@ void rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info);
  * @note
  *   Better to invoke this API after the device is already started or rx burst
  *   function is decided, to obtain correct supported ptypes.
+ * @note
+ *   if a given PMD does not report what ptypes it supports, then the supported
+ *   ptype count is reported as 0.
  * @param port_id
  *   The port identifier of the Ethernet device.
  * @param ptype_mask
@@ -2386,9 +2405,9 @@ void rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info);
  * @param num
  *  Size of the array pointed by param ptypes.
  * @return
- *   - (>0) Number of supported ptypes. If it exceeds param num, exceeding
- *          packet types will not be filled in the given array.
- *   - (0 or -ENOTSUP) if PMD does not fill the specified ptype.
+ *   - (>=0) Number of supported ptypes. If the number of types exceeds num,
+ *           only num entries will be filled into the ptypes array, but the full
+ *           count of supported ptypes will be returned.
  *   - (-ENODEV) if *port_id* invalid.
  */
 int rte_eth_dev_get_supported_ptypes(uint8_t port_id, uint32_t ptype_mask,
@@ -2704,7 +2723,8 @@ rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset)
  * on the output queue *queue_id* of the Ethernet device designated by its
  * *port_id*.
  * The *nb_pkts* parameter is the number of packets to send which are
- * supplied in the *tx_pkts* array of *rte_mbuf* structures.
+ * supplied in the *tx_pkts* array of *rte_mbuf* structures, each of them
+ * allocated from a pool created with rte_pktmbuf_pool_create().
  * The rte_eth_tx_burst() function loops, sending *nb_pkts* packets,
  * up to the number of transmit descriptors available in the TX ring of the
  * transmit queue.
@@ -3846,6 +3866,34 @@ int rte_eth_dev_get_dcb_info(uint8_t port_id,
 void *rte_eth_add_rx_callback(uint8_t port_id, uint16_t queue_id,
                rte_rx_callback_fn fn, void *user_param);
 
+/*
+* Add a callback that must be called first on packet RX on a given port
+* and queue.
+*
+* This API configures a first function to be called for each burst of
+* packets received on a given NIC port queue. The return value is a pointer
+* that can be used to later remove the callback using
+* rte_eth_remove_rx_callback().
+*
+* Multiple functions are called in the order that they are added.
+*
+* @param port_id
+*   The port identifier of the Ethernet device.
+* @param queue_id
+*   The queue on the Ethernet device on which the callback is to be added.
+* @param fn
+*   The callback function
+* @param user_param
+*   A generic pointer parameter which will be passed to each invocation of the
+*   callback function on this port and queue.
+*
+* @return
+*   NULL on error.
+*   On success, a pointer value which can later be used to remove the callback.
+*/
+void *rte_eth_add_first_rx_callback(uint8_t port_id, uint16_t queue_id,
+               rte_rx_callback_fn fn, void *user_param);
+
 /**
  * Add a callback to be called on packet TX on a given port and queue.
  *