X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_ethdev%2Frte_ethdev.h;h=ec95f9b19412de96a337496c3b29f73f5eddc0e1;hb=eb5902504a1349f40530117b9c33dc352835ea20;hp=42803e3f1a80ed6783c39d59fe1e3da63cd5c98b;hpb=0109a56e73c8a21abd45ac99f0112fbf59c75fb3;p=dpdk.git diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h index 42803e3f1a..ec95f9b194 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -80,10 +80,12 @@ * rte_eth_dev_stop()/rte_eth_dev_start(). The following configuration will * be retained: * + * - MTU * - flow control settings - * - receive mode configuration (promiscuous mode, hardware checksum mode, - * RSS/VMDQ settings etc.) + * - receive mode configuration (promiscuous mode, all-multicast mode, + * hardware checksum mode, RSS/VMDQ settings etc.) * - VLAN filtering configuration + * - default MAC address * - MAC addresses supplied to MAC address array * - flow director filtering mode (but not filtering rules) * - NIC queue statistics mappings @@ -156,7 +158,6 @@ extern "C" { #include #include "rte_ether.h" -#include "rte_eth_ctrl.h" #include "rte_dev_info.h" extern int rte_eth_dev_logtype; @@ -166,6 +167,73 @@ extern int rte_eth_dev_logtype; struct rte_mbuf; +/** + * Initializes a device iterator. + * + * This iterator allows accessing a list of devices matching some devargs. + * + * @param iter + * Device iterator handle initialized by the function. + * The fields bus_str and cls_str might be dynamically allocated, + * and could be freed by calling rte_eth_iterator_cleanup(). + * + * @param devargs + * Device description string. + * + * @return + * 0 on successful initialization, negative otherwise. + */ +int rte_eth_iterator_init(struct rte_dev_iterator *iter, const char *devargs); + +/** + * Iterates on devices with devargs filter. + * The ownership is not checked. + * + * The next port id is returned, and the iterator is updated. + * + * @param iter + * Device iterator handle initialized by rte_eth_iterator_init(). + * Some fields bus_str and cls_str might be freed when no more port is found, + * by calling rte_eth_iterator_cleanup(). + * + * @return + * A port id if found, RTE_MAX_ETHPORTS otherwise. + */ +uint16_t rte_eth_iterator_next(struct rte_dev_iterator *iter); + +/** + * Free some allocated fields of the iterator. + * + * This function is automatically called by rte_eth_iterator_next() + * on the last iteration (i.e. when no more matching port is found). + * + * It is safe to call this function twice; it will do nothing more. + * + * @param iter + * Device iterator handle initialized by rte_eth_iterator_init(). + * The fields bus_str and cls_str are freed if needed. + */ +void rte_eth_iterator_cleanup(struct rte_dev_iterator *iter); + +/** + * Macro to iterate over all ethdev ports matching some devargs. + * + * If a break is done before the end of the loop, + * the function rte_eth_iterator_cleanup() must be called. + * + * @param id + * Iterated port id of type uint16_t. + * @param devargs + * Device parameters input as string of type char*. + * @param iter + * Iterator handle of type struct rte_dev_iterator, used internally. + */ +#define RTE_ETH_FOREACH_MATCHING_DEV(id, devargs, iter) \ + for (rte_eth_iterator_init(iter, devargs), \ + id = rte_eth_iterator_next(iter); \ + id != RTE_MAX_ETHPORTS; \ + id = rte_eth_iterator_next(iter)) + /** * A structure used to retrieve statistics for an Ethernet port. * Not all statistics fields in struct rte_eth_stats are supported @@ -326,7 +394,7 @@ enum rte_eth_tx_mq_mode { struct rte_eth_rxmode { /** The multi-queue packet distribution mode to be used, e.g. RSS. */ enum rte_eth_rx_mq_mode mq_mode; - uint32_t max_rx_pkt_len; /**< Only used if jumbo_frame enabled. */ + 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. @@ -334,33 +402,6 @@ struct rte_eth_rxmode { * 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. */ - hw_vlan_strip : 1, /**< VLAN strip enable. */ - hw_vlan_extend : 1, /**< Extended VLAN enable. */ - 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 */ - hw_timestamp : 1, /**< Enable HW timestamp */ - security : 1, /**< Enable rte_security offloads */ - /** - * 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; }; /** @@ -406,8 +447,44 @@ struct rte_eth_rss_conf { }; /* - * The RSS offload types are defined based on flow types which are defined - * in rte_eth_ctrl.h. Different NIC hardwares may support different RSS offload + * A packet can be identified by hardware as different flow types. Different + * NIC hardware may support different flow types. + * Basically, the NIC hardware identifies the flow type as deep protocol as + * possible, and exclusively. For example, if a packet is identified as + * 'RTE_ETH_FLOW_NONFRAG_IPV4_TCP', it will not be any of other flow types, + * though it is an actual IPV4 packet. + * Note that the flow types are used to define RSS offload types. + */ +#define RTE_ETH_FLOW_UNKNOWN 0 +#define RTE_ETH_FLOW_RAW 1 +#define RTE_ETH_FLOW_IPV4 2 +#define RTE_ETH_FLOW_FRAG_IPV4 3 +#define RTE_ETH_FLOW_NONFRAG_IPV4_TCP 4 +#define RTE_ETH_FLOW_NONFRAG_IPV4_UDP 5 +#define RTE_ETH_FLOW_NONFRAG_IPV4_SCTP 6 +#define RTE_ETH_FLOW_NONFRAG_IPV4_OTHER 7 +#define RTE_ETH_FLOW_IPV6 8 +#define RTE_ETH_FLOW_FRAG_IPV6 9 +#define RTE_ETH_FLOW_NONFRAG_IPV6_TCP 10 +#define RTE_ETH_FLOW_NONFRAG_IPV6_UDP 11 +#define RTE_ETH_FLOW_NONFRAG_IPV6_SCTP 12 +#define RTE_ETH_FLOW_NONFRAG_IPV6_OTHER 13 +#define RTE_ETH_FLOW_L2_PAYLOAD 14 +#define RTE_ETH_FLOW_IPV6_EX 15 +#define RTE_ETH_FLOW_IPV6_TCP_EX 16 +#define RTE_ETH_FLOW_IPV6_UDP_EX 17 +#define RTE_ETH_FLOW_PORT 18 + /**< Consider device port number as a flow differentiator */ +#define RTE_ETH_FLOW_VXLAN 19 /**< VXLAN protocol based flow */ +#define RTE_ETH_FLOW_GENEVE 20 /**< GENEVE protocol based flow */ +#define RTE_ETH_FLOW_NVGRE 21 /**< NVGRE protocol based flow */ +#define RTE_ETH_FLOW_VXLAN_GPE 22 /**< VXLAN-GPE protocol based flow */ +#define RTE_ETH_FLOW_GTPU 23 /**< GTPU protocol based flow */ +#define RTE_ETH_FLOW_MAX 24 + +/* + * The RSS offload types are defined based on flow types. + * Different NIC hardware may support different RSS offload * types. The supported flow types or RSS offload types can be queried by * rte_eth_dev_info_get(). */ @@ -431,6 +508,7 @@ struct rte_eth_rss_conf { #define ETH_RSS_VXLAN (1ULL << RTE_ETH_FLOW_VXLAN) #define ETH_RSS_GENEVE (1ULL << RTE_ETH_FLOW_GENEVE) #define ETH_RSS_NVGRE (1ULL << RTE_ETH_FLOW_NVGRE) +#define ETH_RSS_GTPU (1ULL << RTE_ETH_FLOW_GTPU) #define ETH_RSS_IP ( \ ETH_RSS_IPV4 | \ @@ -508,11 +586,13 @@ struct rte_eth_rss_conf { #define ETH_VLAN_STRIP_OFFLOAD 0x0001 /**< VLAN Strip On/Off */ #define ETH_VLAN_FILTER_OFFLOAD 0x0002 /**< VLAN Filter On/Off */ #define ETH_VLAN_EXTEND_OFFLOAD 0x0004 /**< VLAN Extend On/Off */ +#define ETH_QINQ_STRIP_OFFLOAD 0x0008 /**< QINQ Strip On/Off */ /* Definitions used for mask VLAN setting */ #define ETH_VLAN_STRIP_MASK 0x0001 /**< VLAN Strip setting mask */ #define ETH_VLAN_FILTER_MASK 0x0002 /**< VLAN Filter setting mask*/ #define ETH_VLAN_EXTEND_MASK 0x0004 /**< VLAN Extend setting mask*/ +#define ETH_QINQ_STRIP_MASK 0x0008 /**< QINQ Strip setting mask */ #define ETH_VLAN_ID_MAX 0x0FFF /**< VLAN ID is in lower 12 bits*/ /* Definitions used for receive MAC address */ @@ -707,28 +787,6 @@ struct rte_eth_rxconf { uint64_t offloads; }; -#define ETH_TXQ_FLAGS_NOMULTSEGS 0x0001 /**< nb_segs=1 for all mbufs */ -#define ETH_TXQ_FLAGS_NOREFCOUNT 0x0002 /**< refcnt can be ignored */ -#define ETH_TXQ_FLAGS_NOMULTMEMP 0x0004 /**< all bufs come from same mempool */ -#define ETH_TXQ_FLAGS_NOVLANOFFL 0x0100 /**< disable VLAN offload */ -#define ETH_TXQ_FLAGS_NOXSUMSCTP 0x0200 /**< disable SCTP checksum offload */ -#define ETH_TXQ_FLAGS_NOXSUMUDP 0x0400 /**< disable UDP checksum offload */ -#define ETH_TXQ_FLAGS_NOXSUMTCP 0x0800 /**< disable TCP checksum offload */ -#define ETH_TXQ_FLAGS_NOOFFLOADS \ - (ETH_TXQ_FLAGS_NOVLANOFFL | ETH_TXQ_FLAGS_NOXSUMSCTP | \ - ETH_TXQ_FLAGS_NOXSUMUDP | ETH_TXQ_FLAGS_NOXSUMTCP) -#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. */ @@ -738,7 +796,6 @@ struct rte_eth_txconf { uint16_t tx_free_thresh; /**< Start freeing TX buffers if there are less free descriptors than this value. */ - 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. @@ -815,6 +872,24 @@ struct rte_eth_pfc_conf { uint8_t priority; /**< VLAN User Priority. */ }; +/** + * Tunneled type. + */ +enum rte_eth_tunnel_type { + RTE_TUNNEL_TYPE_NONE = 0, + RTE_TUNNEL_TYPE_VXLAN, + RTE_TUNNEL_TYPE_GENEVE, + RTE_TUNNEL_TYPE_TEREDO, + RTE_TUNNEL_TYPE_NVGRE, + RTE_TUNNEL_TYPE_IP_IN_GRE, + RTE_L2_TUNNEL_TYPE_E_TAG, + RTE_TUNNEL_TYPE_VXLAN_GPE, + RTE_TUNNEL_TYPE_MAX, +}; + +/* Deprecated API file for rte_eth_dev_filter_* functions */ +#include "rte_eth_ctrl.h" + /** * Memory space that can be configured to store Flow Director filters * in the board memory. @@ -838,7 +913,7 @@ enum rte_fdir_status_mode { * A structure used to configure the Flow Director (FDIR) feature * of an Ethernet port. * - * If mode is RTE_FDIR_DISABLE, the pballoc value is ignored. + * If mode is RTE_FDIR_MODE_NONE, the pballoc value is ignored. */ struct rte_fdir_conf { enum rte_fdir_mode mode; /**< Flow Director mode. */ @@ -915,16 +990,10 @@ struct rte_eth_conf { /** Currently,Priority Flow Control(PFC) are supported,if DCB with PFC is needed,and the variable must be set ETH_DCB_PFC_SUPPORT. */ uint32_t dcb_capability_en; - struct rte_fdir_conf fdir_conf; /**< FDIR configuration. */ + struct rte_fdir_conf fdir_conf; /**< FDIR configuration. DEPRECATED */ struct rte_intr_conf intr_conf; /**< Interrupt mode configuration. */ }; -/** - * A structure used to retrieve the contextual information of - * an Ethernet device, such as the controlling driver of the device, - * its PCI context, etc... - */ - /** * RX offload capabilities of a device. */ @@ -940,22 +1009,20 @@ struct rte_eth_conf { #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_TIMESTAMP 0x00004000 #define DEV_RX_OFFLOAD_SECURITY 0x00008000 - -/** - * Invalid to set both DEV_RX_OFFLOAD_CRC_STRIP and DEV_RX_OFFLOAD_KEEP_CRC - * No DEV_RX_OFFLOAD_CRC_STRIP flag means keep CRC - */ #define DEV_RX_OFFLOAD_KEEP_CRC 0x00010000 +#define DEV_RX_OFFLOAD_SCTP_CKSUM 0x00020000 +#define DEV_RX_OFFLOAD_OUTER_UDP_CKSUM 0x00040000 + #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) + DEV_RX_OFFLOAD_VLAN_EXTEND | \ + DEV_RX_OFFLOAD_QINQ_STRIP) /* * If new Rx offload capabilities are defined, they also must be @@ -1003,6 +1070,13 @@ struct rte_eth_conf { * for tunnel TSO. */ #define DEV_TX_OFFLOAD_IP_TNL_TSO 0x00080000 +/** Device supports outer UDP checksum */ +#define DEV_TX_OFFLOAD_OUTER_UDP_CKSUM 0x00100000 +/** + * Device supports match on metadata Tx offload.. + * Application must set PKT_TX_METADATA and mbuf metadata field. + */ +#define DEV_TX_OFFLOAD_MATCH_METADATA 0x00200000 #define RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP 0x00000001 /**< Device supports Rx queue setup after device started*/ @@ -1014,8 +1088,6 @@ struct rte_eth_conf { * mentioned in rte_tx_offload_names in rte_ethdev.c file. */ -struct rte_pci_device; - /* * Fallback default preferred Rx/Tx port parameters. * These are used if an application requests default parameters @@ -1062,11 +1134,19 @@ struct rte_eth_switch_info { /** * Ethernet device information */ + +/** + * A structure used to retrieve the contextual information of + * an Ethernet device, such as the controlling driver of the + * device, etc... + */ struct rte_eth_dev_info { struct rte_device *device; /** Generic device information */ const char *driver_name; /**< Device Driver name. */ unsigned int if_index; /**< Index to bound host interface, or 0 if none. Use if_indextoname() to translate into an interface name. */ + uint16_t min_mtu; /**< Minimum MTU allowed */ + uint16_t max_mtu; /**< Maximum MTU allowed */ const uint32_t *dev_flags; /**< Device flags */ uint32_t min_rx_bufsize; /**< Minimum size of RX buffer. */ uint32_t max_rx_pktlen; /**< Maximum configurable length of RX pkt. */ @@ -1116,7 +1196,7 @@ struct rte_eth_dev_info { /** * Ethernet device RX queue information structure. - * Used to retieve information about configured queue. + * Used to retrieve information about configured queue. */ struct rte_eth_rxq_info { struct rte_mempool *mp; /**< mempool used by that queue. */ @@ -1134,6 +1214,35 @@ struct rte_eth_txq_info { uint16_t nb_desc; /**< configured number of TXDs. */ } __rte_cache_min_aligned; +/** + * Burst mode types, values can be ORed to define the burst mode of a driver. + */ +enum rte_eth_burst_mode_option { + RTE_ETH_BURST_SCALAR = (1 << 0), + RTE_ETH_BURST_VECTOR = (1 << 1), + + /**< bits[15:2] are reserved for each vector type */ + RTE_ETH_BURST_ALTIVEC = (1 << 2), + RTE_ETH_BURST_NEON = (1 << 3), + RTE_ETH_BURST_SSE = (1 << 4), + RTE_ETH_BURST_AVX2 = (1 << 5), + RTE_ETH_BURST_AVX512 = (1 << 6), + + RTE_ETH_BURST_SCATTERED = (1 << 16), /**< Support scattered packets */ + RTE_ETH_BURST_BULK_ALLOC = (1 << 17), /**< Support mbuf bulk alloc */ + RTE_ETH_BURST_SIMPLE = (1 << 18), + + RTE_ETH_BURST_PER_QUEUE = (1 << 19), /**< Support per queue burst */ +}; + +/** + * Ethernet device RX/TX queue packet burst mode information structure. + * Used to retrieve information about packet burst mode setting. + */ +struct rte_eth_burst_mode { + uint64_t options; +}; + /** Maximum name length for extended statistics counters */ #define RTE_ETH_XSTATS_NAME_SIZE 64 @@ -1287,8 +1396,6 @@ enum rte_eth_dev_state { RTE_ETH_DEV_UNUSED = 0, /** Device is attached when allocated in probing. */ RTE_ETH_DEV_ATTACHED, - /** The deferred state is useless and replaced by ownership. */ - RTE_ETH_DEV_DEFERRED, /** Device is in removed state when plug-out is detected. */ RTE_ETH_DEV_REMOVED, }; @@ -1312,6 +1419,11 @@ struct rte_eth_dev_owner { char name[RTE_ETH_MAX_OWNER_NAME_LEN]; /**< The owner name. */ }; +/** + * Port is released (i.e. totally freed and data erased) on close. + * Temporary flag for PMD migration to new rte_eth_dev_close() behaviour. + */ +#define RTE_ETH_DEV_CLOSE_REMOVE 0x0001 /** Device supports link state interrupt */ #define RTE_ETH_DEV_INTR_LSC 0x0002 /** Device is a bonded slave */ @@ -1320,6 +1432,8 @@ struct rte_eth_dev_owner { #define RTE_ETH_DEV_INTR_RMV 0x0008 /** Device is port representor */ #define RTE_ETH_DEV_REPRESENTOR 0x0010 +/** Device does not support MAC change after started */ +#define RTE_ETH_DEV_NOLIVE_MAC_ADDR 0x0020 /** * Iterates over valid ethdev ports owned by a specific owner. @@ -1359,6 +1473,71 @@ uint16_t rte_eth_find_next(uint16_t port_id); #define RTE_ETH_FOREACH_DEV(p) \ RTE_ETH_FOREACH_DEV_OWNED_BY(p, RTE_ETH_DEV_NO_OWNER) +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Iterates over ethdev ports of a specified device. + * + * @param port_id_start + * The id of the next possible valid port. + * @param parent + * The generic device behind the ports to iterate. + * @return + * Next port id of the device, possibly port_id_start, + * RTE_MAX_ETHPORTS if there is none. + */ +__rte_experimental +uint16_t +rte_eth_find_next_of(uint16_t port_id_start, + const struct rte_device *parent); + +/** + * Macro to iterate over all ethdev ports of a specified device. + * + * @param port_id + * The id of the matching port being iterated. + * @param parent + * The rte_device pointer matching the iterated ports. + */ +#define RTE_ETH_FOREACH_DEV_OF(port_id, parent) \ + for (port_id = rte_eth_find_next_of(0, parent); \ + port_id < RTE_MAX_ETHPORTS; \ + port_id = rte_eth_find_next_of(port_id + 1, parent)) + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Iterates over sibling ethdev ports (i.e. sharing the same rte_device). + * + * @param port_id_start + * The id of the next possible valid sibling port. + * @param ref_port_id + * The id of a reference port to compare rte_device with. + * @return + * Next sibling port id, possibly port_id_start or ref_port_id itself, + * RTE_MAX_ETHPORTS if there is none. + */ +__rte_experimental +uint16_t +rte_eth_find_next_sibling(uint16_t port_id_start, + uint16_t ref_port_id); + +/** + * Macro to iterate over all ethdev ports sharing the same rte_device + * as the specified port. + * Note: the specified reference port is part of the loop iterations. + * + * @param port_id + * The id of the matching port being iterated. + * @param ref_port_id + * The id of the port being compared. + */ +#define RTE_ETH_FOREACH_DEV_SIBLING(port_id, ref_port_id) \ + for (port_id = rte_eth_find_next_sibling(0, ref_port_id); \ + port_id < RTE_MAX_ETHPORTS; \ + port_id = rte_eth_find_next_sibling(port_id + 1, ref_port_id)) /** * @warning @@ -1373,7 +1552,8 @@ uint16_t rte_eth_find_next(uint16_t port_id); * @return * Negative errno value on error, 0 on success. */ -int __rte_experimental rte_eth_dev_owner_new(uint64_t *owner_id); +__rte_experimental +int rte_eth_dev_owner_new(uint64_t *owner_id); /** * @warning @@ -1388,7 +1568,8 @@ int __rte_experimental rte_eth_dev_owner_new(uint64_t *owner_id); * @return * Negative errno value on error, 0 on success. */ -int __rte_experimental rte_eth_dev_owner_set(const uint16_t port_id, +__rte_experimental +int rte_eth_dev_owner_set(const uint16_t port_id, const struct rte_eth_dev_owner *owner); /** @@ -1404,7 +1585,8 @@ int __rte_experimental rte_eth_dev_owner_set(const uint16_t port_id, * @return * 0 on success, negative errno value on error. */ -int __rte_experimental rte_eth_dev_owner_unset(const uint16_t port_id, +__rte_experimental +int rte_eth_dev_owner_unset(const uint16_t port_id, const uint64_t owner_id); /** @@ -1415,8 +1597,11 @@ int __rte_experimental rte_eth_dev_owner_unset(const uint16_t port_id, * * @param owner_id * The owner identifier. + * @return + * 0 on success, negative errno value on error. */ -void __rte_experimental rte_eth_dev_owner_delete(const uint64_t owner_id); +__rte_experimental +int rte_eth_dev_owner_delete(const uint64_t owner_id); /** * @warning @@ -1431,7 +1616,8 @@ void __rte_experimental rte_eth_dev_owner_delete(const uint64_t owner_id); * @return * 0 on success, negative errno value on error.. */ -int __rte_experimental rte_eth_dev_owner_get(const uint16_t port_id, +__rte_experimental +int rte_eth_dev_owner_get(const uint16_t port_id, struct rte_eth_dev_owner *owner); /** @@ -1469,36 +1655,7 @@ uint16_t rte_eth_dev_count_avail(void); * @return * The total count of Ethernet devices. */ -uint16_t __rte_experimental rte_eth_dev_count_total(void); - -/** - * Attach a new Ethernet device specified by arguments. - * - * @param devargs - * A pointer to a strings array describing the new device - * to be attached. The strings should be a pci address like - * '0000:01:00.0' or virtual device name like 'net_pcap0'. - * @param port_id - * A pointer to a port identifier actually attached. - * @return - * 0 on success and port_id is filled, negative on error - */ -int rte_eth_dev_attach(const char *devargs, uint16_t *port_id); - -/** - * Detach a Ethernet device specified by port identifier. - * This function must be called when the device is in the - * closed state. - * - * @param port_id - * The port identifier of the device to detach. - * @param devname - * 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 - */ -int rte_eth_dev_detach(uint16_t port_id, char *devname); +uint16_t rte_eth_dev_count_total(void); /** * Convert a numerical speed in Mbps to a bitmap flag that can be used in @@ -1514,9 +1671,6 @@ int rte_eth_dev_detach(uint16_t port_id, char *devname); uint32_t rte_eth_speed_bitflag(uint32_t speed, int duplex); /** - * @warning - * @b EXPERIMENTAL: this API may change without prior notice - * * Get DEV_RX_OFFLOAD_* flag name. * * @param offload @@ -1524,12 +1678,9 @@ uint32_t rte_eth_speed_bitflag(uint32_t speed, int duplex); * @return * Offload name or 'UNKNOWN' if the flag cannot be recognised. */ -const char * __rte_experimental rte_eth_dev_rx_offload_name(uint64_t offload); +const char *rte_eth_dev_rx_offload_name(uint64_t offload); /** - * @warning - * @b EXPERIMENTAL: this API may change without prior notice - * * Get DEV_TX_OFFLOAD_* flag name. * * @param offload @@ -1537,7 +1688,7 @@ const char * __rte_experimental rte_eth_dev_rx_offload_name(uint64_t offload); * @return * Offload name or 'UNKNOWN' if the flag cannot be recognised. */ -const char * __rte_experimental rte_eth_dev_tx_offload_name(uint64_t offload); +const char *rte_eth_dev_tx_offload_name(uint64_t offload); /** * Configure an Ethernet device. @@ -1562,12 +1713,14 @@ const char * __rte_experimental rte_eth_dev_tx_offload_name(uint64_t offload); * Applications should set the ignore_bitfield_offloads bit on *rxmode* * structure and use offloads field to set per-port offloads instead. * - Any offloading set in eth_conf->[rt]xmode.offloads must be within - * the [rt]x_offload_capa returned from rte_eth_dev_infos_get(). + * the [rt]x_offload_capa returned from rte_eth_dev_info_get(). * Any type of device supported offloading set in the input argument * eth_conf->[rt]xmode.offloads to rte_eth_dev_configure() is enabled - * on all queues and it can't be disabled in rte_eth_[rt]x_queue_setup(). - * - the Receive Side Scaling (RSS) configuration when using multiple RX - * queues per port. + * on all queues and it can't be disabled in rte_eth_[rt]x_queue_setup() + * - the Receive Side Scaling (RSS) configuration when using multiple RX + * queues per port. Any RSS hash function set in eth_conf->rss_conf.rss_hf + * must be within the flow_type_rss_offloads provided by drivers via + * rte_eth_dev_info_get() API. * * Embedding all configuration information in a single data structure * is the more flexible method that allows the addition of new features @@ -1590,7 +1743,8 @@ int rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_queue, * @return * 1 when the Ethernet device is removed, otherwise 0. */ -int __rte_experimental +__rte_experimental +int rte_eth_dev_is_removed(uint16_t port_id); /** @@ -1635,9 +1789,9 @@ rte_eth_dev_is_removed(uint16_t port_id); * @return * - 0: Success, receive queue correctly set up. * - -EIO: if device is removed. - * - -EINVAL: The size of network buffers which can be allocated from the - * memory pool does not fit the various buffer sizes allowed by the - * device controller. + * - -EINVAL: The memory pool pointer is null or the size of network buffers + * which can be allocated from this memory pool does not fit the various + * buffer sizes allowed by the device controller. * - -ENOMEM: Unable to allocate the receive ring descriptors or to * allocate network memory buffers from the memory pool when * initializing receive descriptors. @@ -1680,12 +1834,6 @@ int rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, * The *tx_rs_thresh* value should be less or equal then * *tx_free_thresh* value, and both of them should be less then * *nb_tx_desc* - 3. - * - 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. * If an offloading set in tx_conf->offloads * hasn't been set in the input argument eth_conf->txmode.offloads @@ -1804,6 +1952,10 @@ int rte_eth_dev_tx_queue_stop(uint16_t port_id, uint16_t tx_queue_id); * The device start step is the last one and consists of setting the configured * offload features and in starting the transmit and the receive units of the * device. + * + * Device RTE_ETH_DEV_NOLIVE_MAC_ADDR flag causes MAC address to be set before + * PMD port start callback function is invoked. + * * On success, all basic functions exported by the Ethernet API (link status, * receive/transmit, and so on) can be invoked. * @@ -1851,8 +2003,8 @@ int rte_eth_dev_set_link_down(uint16_t port_id); /** * Close a stopped Ethernet device. The device cannot be restarted! - * The function frees all resources except for needed by the - * closed state. To free these resources, call rte_eth_dev_detach(). + * The function frees all port resources if the driver supports + * the flag RTE_ETH_DEV_CLOSE_REMOVE. * * @param port_id * The port identifier of the Ethernet device. @@ -1903,16 +2055,26 @@ int rte_eth_dev_reset(uint16_t port_id); * * @param port_id * The port identifier of the Ethernet device. + * @return + * - (0) if successful. + * - (-ENOTSUP) if support for promiscuous_enable() does not exist + * for the device. + * - (-ENODEV) if *port_id* invalid. */ -void rte_eth_promiscuous_enable(uint16_t port_id); +int rte_eth_promiscuous_enable(uint16_t port_id); /** * Disable receipt in promiscuous mode for an Ethernet device. * * @param port_id * The port identifier of the Ethernet device. + * @return + * - (0) if successful. + * - (-ENOTSUP) if support for promiscuous_disable() does not exist + * for the device. + * - (-ENODEV) if *port_id* invalid. */ -void rte_eth_promiscuous_disable(uint16_t port_id); +int rte_eth_promiscuous_disable(uint16_t port_id); /** * Return the value of promiscuous mode for an Ethernet device. @@ -1931,16 +2093,26 @@ int rte_eth_promiscuous_get(uint16_t port_id); * * @param port_id * The port identifier of the Ethernet device. + * @return + * - (0) if successful. + * - (-ENOTSUP) if support for allmulticast_enable() does not exist + * for the device. + * - (-ENODEV) if *port_id* invalid. */ -void rte_eth_allmulticast_enable(uint16_t port_id); +int rte_eth_allmulticast_enable(uint16_t port_id); /** * Disable the receipt of all multicast frames by an Ethernet device. * * @param port_id * The port identifier of the Ethernet device. + * @return + * - (0) if successful. + * - (-ENOTSUP) if support for allmulticast_disable() does not exist + * for the device. + * - (-ENODEV) if *port_id* invalid. */ -void rte_eth_allmulticast_disable(uint16_t port_id); +int rte_eth_allmulticast_disable(uint16_t port_id); /** * Return the value of allmulticast mode for an Ethernet device. @@ -1964,8 +2136,12 @@ int rte_eth_allmulticast_get(uint16_t port_id); * @param link * A pointer to an *rte_eth_link* structure to be filled with * the status, the speed and the mode of the Ethernet device link. + * @return + * - (0) if successful. + * - (-ENOTSUP) if the function is not supported in PMD driver. + * - (-ENODEV) if *port_id* invalid. */ -void rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link); +int rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link); /** * Retrieve the status (ON/OFF), the speed (in Mbps) and the mode (HALF-DUPLEX @@ -1977,8 +2153,12 @@ void rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link); * @param link * A pointer to an *rte_eth_link* structure to be filled with * the status, the speed and the mode of the Ethernet device link. + * @return + * - (0) if successful. + * - (-ENOTSUP) if the function is not supported in PMD driver. + * - (-ENODEV) if *port_id* invalid. */ -void rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *link); +int rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *link); /** * Retrieve the general I/O statistics of an Ethernet device. @@ -2008,6 +2188,7 @@ int rte_eth_stats_get(uint16_t port_id, struct rte_eth_stats *stats); * - (0) if device notified to reset stats. * - (-ENOTSUP) if hardware doesn't support. * - (-ENODEV) if *port_id* invalid. + * - (<0): Error code of the driver stats reset function. */ int rte_eth_stats_reset(uint16_t port_id); @@ -2112,7 +2293,7 @@ rte_eth_xstats_get_names_by_id(uint16_t port_id, * A pointer to an ids array passed by application. This tells which * statistics values function should retrieve. This parameter * can be set to NULL if size is 0. In this case function will retrieve - * all avalible statistics. + * all available statistics. * @param values * A pointer to a table to be filled with device statistics values. * @param size @@ -2155,8 +2336,14 @@ int rte_eth_xstats_get_id_by_name(uint16_t port_id, const char *xstat_name, * * @param port_id * The port identifier of the Ethernet device. + * @return + * - (0) if device notified to reset extended stats. + * - (-ENOTSUP) if pmd doesn't support both + * extended stats and basic stats reset. + * - (-ENODEV) if *port_id* invalid. + * - (<0): Error code of the driver xstats reset function. */ -void rte_eth_xstats_reset(uint16_t port_id); +int rte_eth_xstats_reset(uint16_t port_id); /** * Set a mapping for the specified transmit queue to the specified per-queue @@ -2171,7 +2358,7 @@ void rte_eth_xstats_reset(uint16_t port_id); * @param stat_idx * The per-queue packet statistics functionality number that the transmit * queue is to be assigned. - * The value must be in the range [0, RTE_MAX_ETHPORT_QUEUE_STATS_MAPS - 1]. + * The value must be in the range [0, RTE_ETHDEV_QUEUE_STAT_CNTRS - 1]. * @return * Zero if successful. Non-zero otherwise. */ @@ -2191,7 +2378,7 @@ int rte_eth_dev_set_tx_queue_stats_mapping(uint16_t port_id, * @param stat_idx * The per-queue packet statistics functionality number that the receive * queue is to be assigned. - * The value must be in the range [0, RTE_MAX_ETHPORT_QUEUE_STATS_MAPS - 1]. + * The value must be in the range [0, RTE_ETHDEV_QUEUE_STAT_CNTRS - 1]. * @return * Zero if successful. Non-zero otherwise. */ @@ -2207,19 +2394,55 @@ int rte_eth_dev_set_rx_queue_stats_mapping(uint16_t port_id, * @param mac_addr * A pointer to a structure of type *ether_addr* to be filled with * the Ethernet address of the Ethernet device. + * @return + * - (0) if successful + * - (-ENODEV) if *port_id* invalid. */ -void rte_eth_macaddr_get(uint16_t port_id, struct ether_addr *mac_addr); +int rte_eth_macaddr_get(uint16_t port_id, struct rte_ether_addr *mac_addr); /** * Retrieve the contextual information of an Ethernet device. * + * As part of this function, a number of of fields in dev_info will be + * initialized as follows: + * + * rx_desc_lim = lim + * tx_desc_lim = lim + * + * Where lim is defined within the rte_eth_dev_info_get as + * + * const struct rte_eth_desc_lim lim = { + * .nb_max = UINT16_MAX, + * .nb_min = 0, + * .nb_align = 1, + * .nb_seg_max = UINT16_MAX, + * .nb_mtu_seg_max = UINT16_MAX, + * }; + * + * device = dev->device + * min_mtu = RTE_ETHER_MIN_MTU + * max_mtu = UINT16_MAX + * + * The following fields will be populated if support for dev_infos_get() + * exists for the device and the rte_eth_dev 'dev' has been populated + * successfully with a call to it: + * + * driver_name = dev->device->driver->name + * nb_rx_queues = dev->data->nb_rx_queues + * nb_tx_queues = dev->data->nb_tx_queues + * dev_flags = &dev->data->dev_flags + * * @param port_id * The port identifier of the Ethernet device. * @param dev_info * A pointer to a structure of type *rte_eth_dev_info* to be filled with * the contextual information of the Ethernet device. + * @return + * - (0) if successful. + * - (-ENOTSUP) if support for dev_infos_get() does not exist for the device. + * - (-ENODEV) if *port_id* invalid. */ -void rte_eth_dev_info_get(uint16_t port_id, struct rte_eth_dev_info *dev_info); +int rte_eth_dev_info_get(uint16_t port_id, struct rte_eth_dev_info *dev_info); /** * Retrieve the firmware version of a device. @@ -2309,7 +2532,9 @@ int rte_eth_dev_get_mtu(uint16_t port_id, uint16_t *mtu); * - (-ENOTSUP) if operation is not supported. * - (-ENODEV) if *port_id* invalid. * - (-EIO) if device is removed. - * - (-EINVAL) if *mtu* invalid. + * - (-EINVAL) if *mtu* invalid, validation of mtu can occur within + * rte_eth_dev_set_mtu if dev_infos_get is supported by the device or + * when the mtu is set using dev->dev_ops->mtu_set. * - (-EBUSY) if operation is not allowed when the port is running */ int rte_eth_dev_set_mtu(uint16_t port_id, uint16_t mtu); @@ -2327,7 +2552,7 @@ int rte_eth_dev_set_mtu(uint16_t port_id, uint16_t mtu); * Otherwise, disable VLAN filtering of VLAN packets tagged with *vlan_id*. * @return * - (0) if successful. - * - (-ENOSUP) if hardware-assisted VLAN filtering not configured. + * - (-ENOTSUP) if hardware-assisted VLAN filtering not configured. * - (-ENODEV) if *port_id* invalid. * - (-EIO) if device is removed. * - (-ENOSYS) if VLAN filtering on *port_id* disabled. @@ -2350,7 +2575,7 @@ int rte_eth_dev_vlan_filter(uint16_t port_id, uint16_t vlan_id, int on); * If 0, Disable VLAN Stripping of the receive queue of the Ethernet port. * @return * - (0) if successful. - * - (-ENOSUP) if hardware-assisted VLAN stripping not configured. + * - (-ENOTSUP) if hardware-assisted VLAN stripping not configured. * - (-ENODEV) if *port_id* invalid. * - (-EINVAL) if *rx_queue_id* invalid. */ @@ -2370,7 +2595,7 @@ int rte_eth_dev_set_vlan_strip_on_queue(uint16_t port_id, uint16_t rx_queue_id, * The Tag Protocol ID * @return * - (0) if successful. - * - (-ENOSUP) if hardware-assisted VLAN TPID setup is not supported. + * - (-ENOTSUP) if hardware-assisted VLAN TPID setup is not supported. * - (-ENODEV) if *port_id* invalid. * - (-EIO) if device is removed. */ @@ -2393,9 +2618,10 @@ int rte_eth_dev_set_vlan_ether_type(uint16_t port_id, * ETH_VLAN_STRIP_OFFLOAD * ETH_VLAN_FILTER_OFFLOAD * ETH_VLAN_EXTEND_OFFLOAD + * ETH_QINQ_STRIP_OFFLOAD * @return * - (0) if successful. - * - (-ENOSUP) if hardware-assisted VLAN filtering not configured. + * - (-ENOTSUP) if hardware-assisted VLAN filtering not configured. * - (-ENODEV) if *port_id* invalid. * - (-EIO) if device is removed. */ @@ -2411,6 +2637,7 @@ int rte_eth_dev_set_vlan_offload(uint16_t port_id, int offload_mask); * ETH_VLAN_STRIP_OFFLOAD * ETH_VLAN_FILTER_OFFLOAD * ETH_VLAN_EXTEND_OFFLOAD + * ETH_QINQ_STRIP_OFFLOAD * - (-ENODEV) if *port_id* invalid. */ int rte_eth_dev_get_vlan_offload(uint16_t port_id); @@ -2553,7 +2780,7 @@ rte_eth_tx_buffer_count_callback(struct rte_mbuf **pkts, uint16_t unsent, /** * Request the driver to free mbufs currently cached by the driver. The * driver will only free the mbuf if it is no longer in use. It is the - * application's responsibity to ensure rte_eth_tx_buffer_flush(..) is + * application's responsibility to ensure rte_eth_tx_buffer_flush(..) is * called if needed. * * @param port_id @@ -2772,6 +2999,27 @@ int rte_eth_dev_rx_intr_ctl(uint16_t port_id, int epfd, int op, void *data); int rte_eth_dev_rx_intr_ctl_q(uint16_t port_id, uint16_t queue_id, int epfd, int op, void *data); +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Get interrupt fd per Rx queue. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param queue_id + * The index of the receive queue from which to retrieve input packets. + * The value must be in the range [0, nb_rx_queue - 1] previously supplied + * to rte_eth_dev_configure(). + * @return + * - (>=0) the interrupt fd associated to the requested Rx queue if + * successful. + * - (-1) on error. + */ +__rte_experimental +int +rte_eth_dev_rx_intr_ctl_q_get_fd(uint16_t port_id, uint16_t queue_id); + /** * Turn on the LED on the Ethernet device. * This function turns on the LED on the Ethernet device. @@ -2872,7 +3120,7 @@ int rte_eth_dev_priority_flow_ctrl_set(uint16_t port_id, * - (-ENOSPC) if no more MAC addresses can be added. * - (-EINVAL) if MAC address is invalid. */ -int rte_eth_dev_mac_addr_add(uint16_t port_id, struct ether_addr *mac_addr, +int rte_eth_dev_mac_addr_add(uint16_t port_id, struct rte_ether_addr *mac_addr, uint32_t pool); /** @@ -2888,7 +3136,8 @@ int rte_eth_dev_mac_addr_add(uint16_t port_id, struct ether_addr *mac_addr, * - (-ENODEV) if *port* invalid. * - (-EADDRINUSE) if attempting to remove the default MAC address */ -int rte_eth_dev_mac_addr_remove(uint16_t port_id, struct ether_addr *mac_addr); +int rte_eth_dev_mac_addr_remove(uint16_t port_id, + struct rte_ether_addr *mac_addr); /** * Set the default MAC address. @@ -2904,7 +3153,7 @@ int rte_eth_dev_mac_addr_remove(uint16_t port_id, struct ether_addr *mac_addr); * - (-EINVAL) if MAC address is invalid. */ int rte_eth_dev_default_mac_addr_set(uint16_t port_id, - struct ether_addr *mac_addr); + struct rte_ether_addr *mac_addr); /** * Update Redirection Table(RETA) of Receive Side Scaling of Ethernet device. @@ -2932,7 +3181,8 @@ int rte_eth_dev_rss_reta_update(uint16_t port_id, * @param port_id * The port identifier of the Ethernet device. * @param reta_conf - * RETA to query. + * RETA to query. For each requested reta entry, corresponding bit + * in mask must be set. * @param reta_size * Redirection table size. The table size can be queried by * rte_eth_dev_info_get(). @@ -2965,7 +3215,7 @@ int rte_eth_dev_rss_reta_query(uint16_t port_id, * - (-EIO) if device is removed. * - (-EINVAL) if bad parameter. */ -int rte_eth_dev_uc_hash_table_set(uint16_t port_id, struct ether_addr *addr, +int rte_eth_dev_uc_hash_table_set(uint16_t port_id, struct rte_ether_addr *addr, uint8_t on); /** @@ -3145,6 +3395,7 @@ rte_eth_dev_udp_tunnel_port_delete(uint16_t port_id, * - (-ENODEV) if *port_id* invalid. * - (-EIO) if device is removed. */ +__rte_deprecated int rte_eth_dev_filter_supported(uint16_t port_id, enum rte_filter_type filter_type); @@ -3167,6 +3418,7 @@ int rte_eth_dev_filter_supported(uint16_t port_id, * - (-EIO) if device is removed. * - others depends on the specific operations implementation. */ +__rte_deprecated int rte_eth_dev_filter_ctrl(uint16_t port_id, enum rte_filter_type filter_type, enum rte_filter_op filter_op, void *arg); @@ -3379,6 +3631,62 @@ int rte_eth_rx_queue_info_get(uint16_t port_id, uint16_t queue_id, int rte_eth_tx_queue_info_get(uint16_t port_id, uint16_t queue_id, struct rte_eth_txq_info *qinfo); +/** + * Retrieve information about the Rx packet burst mode. + * + * @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 mode + * A pointer to a structure of type *rte_eth_burst_mode* to be filled + * with the information of the packet burst mode. + * + * @return + * - 0: Success + * - -ENOTSUP: routine is not supported by the device PMD. + * - -EINVAL: The port_id or the queue_id is out of range. + */ +__rte_experimental +int rte_eth_rx_burst_mode_get(uint16_t port_id, uint16_t queue_id, + struct rte_eth_burst_mode *mode); + +/** + * Retrieve information about the Tx packet burst mode. + * + * @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 mode + * A pointer to a structure of type *rte_eth_burst_mode* to be filled + * with the information of the packet burst mode. + * + * @return + * - 0: Success + * - -ENOTSUP: routine is not supported by the device PMD. + * - -EINVAL: The port_id or the queue_id is out of range. + */ +__rte_experimental +int rte_eth_tx_burst_mode_get(uint16_t port_id, uint16_t queue_id, + struct rte_eth_burst_mode *mode); + +/** + * Retrieve name about burst mode option. + * + * @param option + * The burst mode option of type *rte_eth_burst_mode_option*. + * + * @return + * - "": Not found + * - "xxx": name of the mode option. + */ +__rte_experimental +const char * +rte_eth_burst_mode_option_name(uint64_t option); + /** * Retrieve device registers and register attributes (number of registers and * register size) @@ -3463,7 +3771,8 @@ int rte_eth_dev_set_eeprom(uint16_t port_id, struct rte_dev_eeprom_info *info); * - (-EIO) if device is removed. * - others depends on the specific operations implementation. */ -int __rte_experimental +__rte_experimental +int rte_eth_dev_get_module_info(uint16_t port_id, struct rte_eth_dev_module_info *modinfo); @@ -3485,7 +3794,8 @@ rte_eth_dev_get_module_info(uint16_t port_id, * - (-EIO) if device is removed. * - others depends on the specific operations implementation. */ -int __rte_experimental +__rte_experimental +int rte_eth_dev_get_module_eeprom(uint16_t port_id, struct rte_dev_eeprom_info *info); @@ -3508,7 +3818,7 @@ rte_eth_dev_get_module_eeprom(uint16_t port_id, * - (-ENOSPC) if *port_id* has not enough multicast filtering resources. */ int rte_eth_dev_set_mc_addr_list(uint16_t port_id, - struct ether_addr *mc_addr_set, + struct rte_ether_addr *mc_addr_set, uint32_t nb_mc_addr); /** @@ -3633,6 +3943,54 @@ int rte_eth_timesync_read_time(uint16_t port_id, struct timespec *time); */ int rte_eth_timesync_write_time(uint16_t port_id, const struct timespec *time); +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Read the current clock counter of an Ethernet device + * + * This returns the current raw clock value of an Ethernet device. It is + * a raw amount of ticks, with no given time reference. + * The value returned here is from the same clock than the one + * filling timestamp field of Rx packets when using hardware timestamp + * offload. Therefore it can be used to compute a precise conversion of + * the device clock to the real time. + * + * E.g, a simple heuristic to derivate the frequency would be: + * uint64_t start, end; + * rte_eth_read_clock(port, start); + * rte_delay_ms(100); + * rte_eth_read_clock(port, end); + * double freq = (end - start) * 10; + * + * Compute a common reference with: + * uint64_t base_time_sec = current_time(); + * uint64_t base_clock; + * rte_eth_read_clock(port, base_clock); + * + * Then, convert the raw mbuf timestamp with: + * base_time_sec + (double)(mbuf->timestamp - base_clock) / freq; + * + * This simple example will not provide a very good accuracy. One must + * at least measure multiple times the frequency and do a regression. + * To avoid deviation from the system time, the common reference can + * be repeated from time to time. The integer division can also be + * converted by a multiplication and a shift for better performance. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param clock + * Pointer to the uint64_t that holds the raw clock value. + * + * @return + * - 0: Success. + * - -ENODEV: The port ID is invalid. + * - -ENOTSUP: The function is not supported by the Ethernet driver. + */ +__rte_experimental +int +rte_eth_read_clock(uint16_t port_id, uint64_t *clock); + /** * Config l2 tunnel ether type of an Ethernet device for filtering specific * tunnel packets by ether type. @@ -3683,11 +4041,11 @@ rte_eth_dev_l2_tunnel_offload_set(uint16_t port_id, uint8_t en); /** -* Get the port id from pci address or device name -* Example: -* - PCIe, 0000:2:00.0 -* - SoC, fsl-gmac0 -* - vdev, net_pcap0 +* Get the port id from device name. The device name should be specified +* as below: +* - PCIe address (Domain:Bus:Device.Function), for example- 0000:2:00.0 +* - SoC device name, for example- fsl-gmac0 +* - vdev dpdk name, for example- net_[pcap0|null0|tap0] * * @param name * pci address or name of the device @@ -3701,11 +4059,10 @@ int rte_eth_dev_get_port_by_name(const char *name, uint16_t *port_id); /** -* Get the device name from port id -* Example: -* - PCIe Bus:Domain:Function, 0000:02:00.0 -* - SoC device name, fsl-gmac0 -* - vdev dpdk name, net_[pcap0|null0|tun0|tap0] +* Get the device name from port id. The device name is specified as below: +* - PCIe address (Domain:Bus:Device.Function), for example- 0000:02:00.0 +* - SoC device name, for example- fsl-gmac0 +* - vdev dpdk name, for example- net_[pcap0|null0|tun0|tap0] * * @param port_id * Port identifier of the device. @@ -4097,7 +4454,7 @@ static inline int rte_eth_tx_descriptor_status(uint16_t port_id, * * If the PMD is DEV_TX_OFFLOAD_MT_LOCKFREE capable, multiple threads can * invoke this function concurrently on the same tx queue without SW lock. - * @see rte_eth_dev_info_get, struct rte_eth_txconf::txq_flags + * @see rte_eth_dev_info_get, struct rte_eth_txconf::offloads * * @see rte_eth_tx_prepare to perform some prior checks or adjustments * for offloads. @@ -4151,9 +4508,6 @@ rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id, } /** - * @warning - * @b EXPERIMENTAL: this API may change without prior notice - * * Process a burst of output packets on a transmit queue of an Ethernet device. * * The rte_eth_tx_prepare() function is invoked to prepare output packets to be @@ -4201,8 +4555,8 @@ rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id, * The number of packets correct and ready to be sent. The return value can be * less than the value of the *tx_pkts* parameter when some packet doesn't * meet devices requirements with rte_errno set appropriately: - * - -EINVAL: offload flags are not correctly set - * - -ENOTSUP: the offload feature is not supported by the hardware + * - EINVAL: offload flags are not correctly set + * - ENOTSUP: the offload feature is not supported by the hardware * */ @@ -4217,7 +4571,7 @@ rte_eth_tx_prepare(uint16_t port_id, uint16_t queue_id, #ifdef RTE_LIBRTE_ETHDEV_DEBUG if (!rte_eth_dev_is_valid_port(port_id)) { RTE_ETHDEV_LOG(ERR, "Invalid TX port_id=%u\n", port_id); - rte_errno = -EINVAL; + rte_errno = EINVAL; return 0; } #endif @@ -4227,7 +4581,7 @@ rte_eth_tx_prepare(uint16_t port_id, uint16_t queue_id, #ifdef RTE_LIBRTE_ETHDEV_DEBUG if (queue_id >= dev->data->nb_tx_queues) { RTE_ETHDEV_LOG(ERR, "Invalid TX queue_id=%u\n", queue_id); - rte_errno = -EINVAL; + rte_errno = EINVAL; return 0; } #endif