ethdev: add mbuf fast free Tx offload
[dpdk.git] / lib / librte_ether / rte_ethdev.h
index 0e99090..78de045 100644 (file)
@@ -348,7 +348,18 @@ struct rte_eth_rxmode {
        enum rte_eth_rx_mq_mode mq_mode;
        uint32_t max_rx_pkt_len;  /**< Only used if jumbo_frame enabled. */
        uint16_t split_hdr_size;  /**< hdr buf size (header_split enabled).*/
+       /**
+        * Per-port Rx offloads to be set using DEV_RX_OFFLOAD_* flags.
+        * Only offloads set on rx_offload_capa field on rte_eth_dev_info
+        * structure are allowed to be set.
+        */
+       uint64_t offloads;
        __extension__
+       /**
+        * Below bitfield API is obsolete. Application should
+        * enable per-port offloads using the offload field
+        * above.
+        */
        uint16_t header_split : 1, /**< Header Split enable. */
                hw_ip_checksum   : 1, /**< IP/UDP/TCP checksum offload enable. */
                hw_vlan_filter   : 1, /**< VLAN filter enable. */
@@ -357,7 +368,17 @@ struct rte_eth_rxmode {
                jumbo_frame      : 1, /**< Jumbo Frame Receipt enable. */
                hw_strip_crc     : 1, /**< Enable CRC stripping by hardware. */
                enable_scatter   : 1, /**< Enable scatter packets rx handler */
-               enable_lro       : 1; /**< Enable LRO */
+               enable_lro       : 1, /**< Enable LRO */
+               /**
+                * When set the offload bitfield should be ignored.
+                * Instead per-port Rx offloads should be set on offloads
+                * field above.
+                * Per-queue offloads shuold be set on rte_eth_rxq_conf
+                * structure.
+                * This bit is temporary till rxmode bitfield offloads API will
+                * be deprecated.
+                */
+               ignore_offload_bitfield : 1;
 };
 
 /**
@@ -671,6 +692,12 @@ struct rte_eth_vmdq_rx_conf {
  */
 struct rte_eth_txmode {
        enum rte_eth_tx_mq_mode mq_mode; /**< TX multi-queues mode. */
+       /**
+        * Per-port Tx offloads to be set using DEV_TX_OFFLOAD_* flags.
+        * Only offloads set on tx_offload_capa field on rte_eth_dev_info
+        * structure are allowed to be set.
+        */
+       uint64_t offloads;
 
        /* For i40e specifically */
        uint16_t pvid;
@@ -691,6 +718,12 @@ struct rte_eth_rxconf {
        uint16_t rx_free_thresh; /**< Drives the freeing of RX descriptors. */
        uint8_t rx_drop_en; /**< Drop packets if no descriptors are available. */
        uint8_t rx_deferred_start; /**< Do not start queue with rte_eth_dev_start(). */
+       /**
+        * Per-queue Rx offloads to be set using DEV_RX_OFFLOAD_* flags.
+        * Only offloads set on rx_queue_offload_capa or rx_offload_capa
+        * fields on rte_eth_dev_info structure are allowed to be set.
+        */
+       uint64_t offloads;
 };
 
 #define ETH_TXQ_FLAGS_NOMULTSEGS 0x0001 /**< nb_segs=1 for all mbufs */
@@ -706,6 +739,15 @@ struct rte_eth_rxconf {
 #define ETH_TXQ_FLAGS_NOXSUMS \
                (ETH_TXQ_FLAGS_NOXSUMSCTP | ETH_TXQ_FLAGS_NOXSUMUDP | \
                 ETH_TXQ_FLAGS_NOXSUMTCP)
+/**
+ * When set the txq_flags should be ignored,
+ * instead per-queue Tx offloads will be set on offloads field
+ * located on rte_eth_txq_conf struct.
+ * This flag is temporary till the rte_eth_txq_conf.txq_flags
+ * API will be deprecated.
+ */
+#define ETH_TXQ_FLAGS_IGNORE   0x8000
+
 /**
  * A structure used to configure a TX ring of an Ethernet port.
  */
@@ -717,6 +759,12 @@ struct rte_eth_txconf {
 
        uint32_t txq_flags; /**< Set flags for the Tx queue */
        uint8_t tx_deferred_start; /**< Do not start queue with rte_eth_dev_start(). */
+       /**
+        * Per-queue Tx offloads to be set  using DEV_TX_OFFLOAD_* flags.
+        * Only offloads set on tx_queue_offload_capa or tx_offload_capa
+        * fields on rte_eth_dev_info structure are allowed to be set.
+        */
+       uint64_t offloads;
 };
 
 /**
@@ -907,6 +955,18 @@ struct rte_eth_conf {
 #define DEV_RX_OFFLOAD_QINQ_STRIP  0x00000020
 #define DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM 0x00000040
 #define DEV_RX_OFFLOAD_MACSEC_STRIP     0x00000080
+#define DEV_RX_OFFLOAD_HEADER_SPLIT    0x00000100
+#define DEV_RX_OFFLOAD_VLAN_FILTER     0x00000200
+#define DEV_RX_OFFLOAD_VLAN_EXTEND     0x00000400
+#define DEV_RX_OFFLOAD_JUMBO_FRAME     0x00000800
+#define DEV_RX_OFFLOAD_CRC_STRIP       0x00001000
+#define DEV_RX_OFFLOAD_SCATTER         0x00002000
+#define DEV_RX_OFFLOAD_CHECKSUM (DEV_RX_OFFLOAD_IPV4_CKSUM | \
+                                DEV_RX_OFFLOAD_UDP_CKSUM | \
+                                DEV_RX_OFFLOAD_TCP_CKSUM)
+#define DEV_RX_OFFLOAD_VLAN (DEV_RX_OFFLOAD_VLAN_STRIP | \
+                            DEV_RX_OFFLOAD_VLAN_FILTER | \
+                            DEV_RX_OFFLOAD_VLAN_EXTEND)
 
 /**
  * TX offload capabilities of a device.
@@ -929,6 +989,13 @@ struct rte_eth_conf {
 /**< Multiple threads can invoke rte_eth_tx_burst() concurrently on the same
  * tx queue without SW lock.
  */
+#define DEV_TX_OFFLOAD_MULTI_SEGS      0x00008000
+/**< Device supports multi segment send. */
+#define DEV_TX_OFFLOAD_MBUF_FAST_FREE  0x00010000
+/**< Device supports optimization for fast release of mbufs.
+ *   When set application must guarantee that per-queue all mbufs comes from
+ *   the same mempool and has refcnt = 1.
+ */
 
 struct rte_pci_device;
 
@@ -949,8 +1016,14 @@ struct rte_eth_dev_info {
        /** Maximum number of hash MAC addresses for MTA and UTA. */
        uint16_t max_vfs; /**< Maximum number of VFs. */
        uint16_t max_vmdq_pools; /**< Maximum number of VMDq pools. */
-       uint32_t rx_offload_capa; /**< Device RX offload capabilities. */
-       uint32_t tx_offload_capa; /**< Device TX offload capabilities. */
+       uint64_t rx_offload_capa;
+       /**< Device per port RX offload capabilities. */
+       uint64_t tx_offload_capa;
+       /**< Device per port TX offload capabilities. */
+       uint64_t rx_queue_offload_capa;
+       /**< Device per queue RX offload capabilities. */
+       uint64_t tx_queue_offload_capa;
+       /**< Device per queue TX offload capabilities. */
        uint16_t reta_size;
        /**< Device redirection table size, the total number of entries. */
        uint8_t hash_key_size; /**< Hash key size in bytes */
@@ -1115,6 +1188,9 @@ typedef int  (*eth_dev_set_link_down_t)(struct rte_eth_dev *dev);
 typedef void (*eth_dev_close_t)(struct rte_eth_dev *dev);
 /**< @internal Function used to close a configured Ethernet device. */
 
+typedef int (*eth_dev_reset_t)(struct rte_eth_dev *dev);
+/** <@internal Function used to reset a configured Ethernet device. */
+
 typedef void (*eth_promiscuous_enable_t)(struct rte_eth_dev *dev);
 /**< @internal Function used to enable the RX promiscuous mode of an Ethernet device. */
 
@@ -1435,6 +1511,7 @@ struct eth_dev_ops {
        eth_dev_set_link_up_t      dev_set_link_up;   /**< Device link up. */
        eth_dev_set_link_down_t    dev_set_link_down; /**< Device link down. */
        eth_dev_close_t            dev_close;     /**< Close device. */
+       eth_dev_reset_t            dev_reset;     /**< Reset device. */
        eth_link_update_t          link_update;   /**< Get device link state. */
 
        eth_promiscuous_enable_t   promiscuous_enable; /**< Promiscuous ON. */
@@ -1831,7 +1908,8 @@ int rte_eth_dev_attach(const char *devargs, uint8_t *port_id);
  * @param port_id
  *   The port identifier of the device to detach.
  * @param devname
- *  A pointer to a device name actually detached.
+ *   A pointer to a buffer that will be filled with the device name.
+ *   This buffer must be at least RTE_DEV_NAME_MAX_LEN long.
  * @return
  *  0 on success and devname is filled, negative on error
  */
@@ -1869,6 +1947,9 @@ uint32_t rte_eth_speed_bitflag(uint32_t speed, int duplex);
  *        each statically configurable offload hardware feature provided by
  *        Ethernet devices, such as IP checksum or VLAN tag stripping for
  *        example.
+ *        The Rx offload bitfield API is obsolete and will be deprecated.
+ *        Applications should set the ignore_bitfield_offloads bit on *rxmode*
+ *        structure and use offloads field to set per-port offloads instead.
  *     - the Receive Side Scaling (RSS) configuration when using multiple RX
  *         queues per port.
  *
@@ -1922,6 +2003,8 @@ void _rte_eth_dev_reset(struct rte_eth_dev *dev);
  *   The *rx_conf* structure contains an *rx_thresh* structure with the values
  *   of the Prefetch, Host, and Write-Back threshold registers of the receive
  *   ring.
+ *   In addition it contains the hardware offloads features to activate using
+ *   the DEV_RX_OFFLOAD_* flags.
  * @param mb_pool
  *   The pointer to the memory pool from which to allocate *rte_mbuf* network
  *   memory buffers to populate each descriptor of the receive ring.
@@ -1975,6 +2058,11 @@ int rte_eth_rx_queue_setup(uint8_t port_id, uint16_t rx_queue_id,
  *   - The *txq_flags* member contains flags to pass to the TX queue setup
  *     function to configure the behavior of the TX queue. This should be set
  *     to 0 if no special configuration is required.
+ *     This API is obsolete and will be deprecated. Applications
+ *     should set it to ETH_TXQ_FLAGS_IGNORE and use
+ *     the offloads field below.
+ *   - The *offloads* member contains Tx offloads to be enabled.
+ *     Offloads which are not set cannot be used on the datapath.
  *
  *     Note that setting *tx_free_thresh* or *tx_rs_thresh* value to 0 forces
  *     the transmit function to use default values.
@@ -2139,6 +2227,36 @@ int rte_eth_dev_set_link_down(uint8_t port_id);
  */
 void rte_eth_dev_close(uint8_t port_id);
 
+/**
+ * Reset a Ethernet device and keep its port id.
+ *
+ * When a port has to be reset passively, the DPDK application can invoke
+ * this function. For example when a PF is reset, all its VFs should also
+ * be reset. Normally a DPDK application can invoke this function when
+ * RTE_ETH_EVENT_INTR_RESET event is detected, but can also use it to start
+ * a port reset in other circumstances.
+ *
+ * When this function is called, it first stops the port and then calls the
+ * PMD specific dev_uninit( ) and dev_init( ) to return the port to initial
+ * state, in which no Tx and Rx queues are setup, as if the port has been
+ * reset and not started. The port keeps the port id it had before the
+ * function call.
+ *
+ * After calling rte_eth_dev_reset( ), the application should use
+ * rte_eth_dev_configure( ), rte_eth_rx_queue_setup( ),
+ * rte_eth_tx_queue_setup( ), and rte_eth_dev_start( )
+ * to reconfigure the device as appropriate.
+ *
+ * Note: To avoid unexpected behavior, the application should stop calling
+ * Tx and Rx functions before calling rte_eth_dev_reset( ). For thread
+ * safety, all these controlling functions should be called from the same
+ * thread.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ */
+int rte_eth_dev_reset(uint8_t port_id);
+
 /**
  * Enable receipt in promiscuous mode for an Ethernet device.
  *