X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_ether%2Frte_ethdev.h;h=c7983d3c8c20209550502d11aa15edd6eecde9e8;hb=c8231c63ddcb;hp=bf3519d85c43c583ac2145cd75993846d0766437;hpb=c49b2bad6a028fa53b09699c6cae10143e6f3a3e;p=dpdk.git diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index bf3519d85c..c7983d3c8c 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -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,37 +213,62 @@ 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 */ }; +/** + * Device supported speeds bitmap flags + */ +#define ETH_LINK_SPEED_AUTONEG (0 << 0) /**< Autonegotiate (all speeds) */ +#define ETH_LINK_SPEED_FIXED (1 << 0) /**< Disable autoneg (fixed speed) */ +#define ETH_LINK_SPEED_10M_HD (1 << 1) /**< 10 Mbps half-duplex */ +#define ETH_LINK_SPEED_10M (1 << 2) /**< 10 Mbps full-duplex */ +#define ETH_LINK_SPEED_100M_HD (1 << 3) /**< 100 Mbps half-duplex */ +#define ETH_LINK_SPEED_100M (1 << 4) /**< 100 Mbps full-duplex */ +#define ETH_LINK_SPEED_1G (1 << 5) /**< 1 Gbps */ +#define ETH_LINK_SPEED_2_5G (1 << 6) /**< 2.5 Gbps */ +#define ETH_LINK_SPEED_5G (1 << 7) /**< 5 Gbps */ +#define ETH_LINK_SPEED_10G (1 << 8) /**< 10 Gbps */ +#define ETH_LINK_SPEED_20G (1 << 9) /**< 20 Gbps */ +#define ETH_LINK_SPEED_25G (1 << 10) /**< 25 Gbps */ +#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 + */ +#define ETH_SPEED_NUM_NONE 0 /**< Not defined */ +#define ETH_SPEED_NUM_10M 10 /**< 10 Mbps */ +#define ETH_SPEED_NUM_100M 100 /**< 100 Mbps */ +#define ETH_SPEED_NUM_1G 1000 /**< 1 Gbps */ +#define ETH_SPEED_NUM_2_5G 2500 /**< 2.5 Gbps */ +#define ETH_SPEED_NUM_5G 5000 /**< 5 Gbps */ +#define ETH_SPEED_NUM_10G 10000 /**< 10 Gbps */ +#define ETH_SPEED_NUM_20G 20000 /**< 20 Gbps */ +#define ETH_SPEED_NUM_25G 25000 /**< 25 Gbps */ +#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_LINK_SPEED_[10, 100, 1000, 10000] */ - uint16_t link_duplex; /**< ETH_LINK_[HALF_DUPLEX, FULL_DUPLEX] */ - uint8_t link_status : 1; /**< 1 -> link up, 0 -> link down */ -}__attribute__((aligned(8))); /**< aligned for atomic64 read/write */ + 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] */ +} __attribute__((aligned(8))); /**< aligned for atomic64 read/write */ -#define ETH_LINK_SPEED_AUTONEG 0 /**< Auto-negotiate link speed. */ -#define ETH_LINK_SPEED_10 10 /**< 10 megabits/second. */ -#define ETH_LINK_SPEED_100 100 /**< 100 megabits/second. */ -#define ETH_LINK_SPEED_1000 1000 /**< 1 gigabits/second. */ -#define ETH_LINK_SPEED_10000 10000 /**< 10 gigabits/second. */ -#define ETH_LINK_SPEED_10G 10000 /**< alias of 10 gigabits/second. */ -#define ETH_LINK_SPEED_20G 20000 /**< 20 gigabits/second. */ -#define ETH_LINK_SPEED_40G 40000 /**< 40 gigabits/second. */ - -#define ETH_LINK_AUTONEG_DUPLEX 0 /**< Auto-negotiate duplex. */ -#define ETH_LINK_HALF_DUPLEX 1 /**< Half-duplex connection. */ -#define ETH_LINK_FULL_DUPLEX 2 /**< Full-duplex connection. */ +/* Utility constants */ +#define ETH_LINK_HALF_DUPLEX 0 /**< Half-duplex connection. */ +#define ETH_LINK_FULL_DUPLEX 1 /**< Full-duplex connection. */ +#define ETH_LINK_DOWN 0 /**< Link is down. */ +#define ETH_LINK_UP 1 /**< Link is up. */ +#define ETH_LINK_FIXED 0 /**< No autonegotiation. */ +#define ETH_LINK_AUTONEG 1 /**< Autonegotiated. */ /** * A structure used to configure the ring threshold registers of an RX/TX @@ -749,10 +756,14 @@ 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. */ struct rte_eth_udp_tunnel { - uint16_t udp_port; - uint8_t prot_type; + uint16_t udp_port; /**< UDP port used for the tunnel. */ + uint8_t prot_type; /**< Tunnel type. Defined in rte_eth_tunnel_type. */ }; /** @@ -771,10 +782,13 @@ struct rte_intr_conf { * configuration settings may be needed. */ struct rte_eth_conf { - uint16_t link_speed; - /**< ETH_LINK_SPEED_10[0|00|000], or 0 for autonegotation */ - uint16_t link_duplex; - /**< ETH_LINK_[HALF_DUPLEX|FULL_DUPLEX], or 0 for autonegotation */ + uint32_t link_speeds; /**< bitmap of ETH_LINK_SPEED_XXX of speeds to be + used. ETH_LINK_SPEED_FIXED disables link + autonegotiation, and a unique speed shall be + set. Otherwise, the bitmap defines the set of + speeds to be advertised. If the special value + ETH_LINK_SPEED_AUTONEG (0) is used, all speeds + supported are advertised. */ struct rte_eth_rxmode rxmode; /**< Port RX configuration. */ struct rte_eth_txmode txmode; /**< Port TX configuration. */ uint32_t lpbk_mode; /**< Loopback operation mode. By default the value @@ -821,6 +835,7 @@ struct rte_eth_conf { #define DEV_RX_OFFLOAD_TCP_CKSUM 0x00000008 #define DEV_RX_OFFLOAD_TCP_LRO 0x00000010 #define DEV_RX_OFFLOAD_QINQ_STRIP 0x00000020 +#define DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM 0x00000040 /** * TX offload capabilities of a device. @@ -835,6 +850,9 @@ struct rte_eth_conf { #define DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM 0x00000080 /**< Used for tunneling packet. */ #define DEV_TX_OFFLOAD_QINQ_INSERT 0x00000100 +/** + * Ethernet device information + */ struct rte_eth_dev_info { struct rte_pci_device *pci_dev; /**< Device PCI information. */ const char *driver_name; /**< Device Driver name. */ @@ -863,6 +881,7 @@ struct rte_eth_dev_info { 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 */ + uint32_t speed_capa; /**< Supported speeds bitmap (ETH_LINK_SPEED_). */ }; /** @@ -895,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 @@ -1029,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, @@ -1045,6 +1079,9 @@ typedef void (*eth_dev_infos_get_t)(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info); /**< @internal Get specific informations of an Ethernet device. */ +typedef const uint32_t *(*eth_dev_supported_ptypes_get_t)(struct rte_eth_dev *dev); +/**< @internal Get supported ptypes of an Ethernet device. */ + typedef int (*eth_queue_start_t)(struct rte_eth_dev *dev, uint16_t queue_id); /**< @internal Start rx and tx of a queue of an Ethernet device. */ @@ -1228,13 +1265,13 @@ typedef int (*eth_mirror_rule_reset_t)(struct rte_eth_dev *dev, uint8_t rule_id); /**< @internal Remove a traffic mirroring rule on an Ethernet device */ -typedef int (*eth_udp_tunnel_add_t)(struct rte_eth_dev *dev, - struct rte_eth_udp_tunnel *tunnel_udp); -/**< @internal Add tunneling UDP info */ +typedef int (*eth_udp_tunnel_port_add_t)(struct rte_eth_dev *dev, + struct rte_eth_udp_tunnel *tunnel_udp); +/**< @internal Add tunneling UDP port */ -typedef int (*eth_udp_tunnel_del_t)(struct rte_eth_dev *dev, - struct rte_eth_udp_tunnel *tunnel_udp); -/**< @internal Delete tunneling UDP info */ +typedef int (*eth_udp_tunnel_port_del_t)(struct rte_eth_dev *dev, + struct rte_eth_udp_tunnel *tunnel_udp); +/**< @internal Delete tunneling UDP port */ typedef int (*eth_set_mc_addr_list_t)(struct rte_eth_dev *dev, struct ether_addr *mc_addr_set, @@ -1379,9 +1416,13 @@ 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. */ + eth_dev_supported_ptypes_get_t dev_supported_ptypes_get; + /**< Get packet types supported and identified by device*/ mtu_set_t mtu_set; /**< Set MTU. */ vlan_filter_set_t vlan_filter_set; /**< Filter VLAN Setup. */ vlan_tpid_set_t vlan_tpid_set; /**< Outer VLAN TPID Setup. */ @@ -1418,8 +1459,10 @@ struct eth_dev_ops { eth_set_vf_rx_t set_vf_rx; /**< enable/disable a VF receive */ eth_set_vf_tx_t set_vf_tx; /**< enable/disable a VF transmit */ eth_set_vf_vlan_filter_t set_vf_vlan_filter; /**< Set VF VLAN filter */ - eth_udp_tunnel_add_t udp_tunnel_add; - eth_udp_tunnel_del_t udp_tunnel_del; + /** Add UDP tunnel port. */ + eth_udp_tunnel_port_add_t udp_tunnel_port_add; + /** Del UDP tunnel port. */ + eth_udp_tunnel_port_del_t udp_tunnel_port_del; eth_set_queue_rate_limit_t set_queue_rate_limit; /**< Set queue rate limit */ eth_set_vf_rate_limit_t set_vf_rate_limit; /**< Set VF rate limit */ /** Update redirection table. */ @@ -1655,6 +1698,8 @@ struct rte_eth_dev_data { #define RTE_ETH_DEV_DETACHABLE 0x0001 /** Device supports link state interrupt */ #define RTE_ETH_DEV_INTR_LSC 0x0002 +/** Device is a bonded slave */ +#define RTE_ETH_DEV_BONDED_SLAVE 0x0004 /** * @internal @@ -1825,6 +1870,19 @@ struct eth_driver { */ void rte_eth_driver_register(struct eth_driver *eth_drv); +/** + * Convert a numerical speed in Mbps to a bitmap flag that can be used in + * the bitmap link_speeds of the struct rte_eth_conf + * + * @param speed + * Numerical speed value in Mbps + * @param duplex + * ETH_LINK_[HALF/FULL]_DUPLEX (only for 10/100M speeds) + * @return + * 0 if the speed cannot be mapped + */ +uint32_t rte_eth_speed_bitflag(uint32_t speed, int duplex); + /** * Configure an Ethernet device. * This function must be invoked first before any other function in the @@ -2211,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. * @@ -2232,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); /** @@ -2306,6 +2387,32 @@ void rte_eth_macaddr_get(uint8_t port_id, struct ether_addr *mac_addr); */ void rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info); +/** + * Retrieve the supported packet types of an Ethernet device. + * + * @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 + * A hint of what kind of packet type which the caller is interested in. + * @param ptypes + * An array pointer to store adequent packet types, allocated by caller. + * @param num + * Size of the array pointed by param ptypes. + * @return + * - (>=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, + uint32_t *ptypes, int num); + /** * Retrieve the MTU of an Ethernet device. * @@ -2616,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. @@ -2908,6 +3016,10 @@ rte_eth_tx_buffer_count_callback(struct rte_mbuf **pkts, uint16_t unsent, enum rte_eth_event_type { RTE_ETH_EVENT_UNKNOWN, /**< unknown event type */ RTE_ETH_EVENT_INTR_LSC, /**< lsc interrupt event */ + RTE_ETH_EVENT_QUEUE_STATE, + /**< queue state event (enabled/disabled) */ + RTE_ETH_EVENT_INTR_RESET, + /**< reset interrupt event, sent to VF on PF reset */ RTE_ETH_EVENT_MAX /**< max value of this enum */ }; @@ -3634,8 +3746,11 @@ rte_eth_dev_rss_hash_conf_get(uint8_t port_id, struct rte_eth_rss_conf *rss_conf); /** - * Add UDP tunneling port of an Ethernet device for filtering a specific - * tunneling packet by UDP port number. + * 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 sepcific UDP port. * * @param port_id * The port identifier of the Ethernet device. @@ -3648,11 +3763,16 @@ rte_eth_dev_rss_hash_conf_get(uint8_t port_id, * - (-ENOTSUP) if hardware doesn't support tunnel type. */ int -rte_eth_dev_udp_tunnel_add(uint8_t port_id, - struct rte_eth_udp_tunnel *tunnel_udp); +rte_eth_dev_udp_tunnel_port_add(uint8_t port_id, + struct rte_eth_udp_tunnel *tunnel_udp); /** - * Detete UDP tunneling port configuration of Ethernet device + * 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 sepcific UDP port. * * @param port_id * The port identifier of the Ethernet device. @@ -3665,8 +3785,8 @@ rte_eth_dev_udp_tunnel_add(uint8_t port_id, * - (-ENOTSUP) if hardware doesn't support tunnel type. */ int -rte_eth_dev_udp_tunnel_delete(uint8_t port_id, - struct rte_eth_udp_tunnel *tunnel_udp); +rte_eth_dev_udp_tunnel_port_delete(uint8_t port_id, + struct rte_eth_udp_tunnel *tunnel_udp); /** * Check whether the filter type is supported on an Ethernet device. @@ -3746,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. *