X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fhns3%2Fhns3_rxtx.h;h=8f5ae5cf11afe65ee11d5bf2b81590255355bb8e;hb=3a1aca384d3ac628dec8830714826e323f509dec;hp=ba1b01742b0cbe631ef196dedc3b196bb63cec07;hpb=952ebacce4f2bc97e4399ce0ca4a36149dde43fe;p=dpdk.git diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h index ba1b01742b..8f5ae5cf11 100644 --- a/drivers/net/hns3/hns3_rxtx.h +++ b/drivers/net/hns3/hns3_rxtx.h @@ -5,6 +5,9 @@ #ifndef _HNS3_RXTX_H_ #define _HNS3_RXTX_H_ +#include +#include + #define HNS3_MIN_RING_DESC 64 #define HNS3_MAX_RING_DESC 32768 #define HNS3_DEFAULT_RING_DESC 1024 @@ -263,6 +266,24 @@ struct hns3_entry { struct rte_mbuf *mbuf; }; +struct hns3_rx_basic_stats { + uint64_t packets; + uint64_t bytes; + uint64_t errors; +}; + +struct hns3_rx_dfx_stats { + uint64_t l3_csum_errors; + uint64_t l4_csum_errors; + uint64_t ol3_csum_errors; + uint64_t ol4_csum_errors; +}; + +struct hns3_rx_bd_errors_stats { + uint64_t l2_errors; + uint64_t pkt_len_errors; +}; + struct hns3_rx_queue { void *io_base; volatile void *io_head_reg; @@ -309,12 +330,11 @@ struct hns3_rx_queue { bool pvid_sw_discard_en; bool enabled; /* indicate if Rx queue has been enabled */ - uint64_t l2_errors; - uint64_t pkt_len_errors; - uint64_t l3_csum_errors; - uint64_t l4_csum_errors; - uint64_t ol3_csum_errors; - uint64_t ol4_csum_errors; + struct hns3_rx_basic_stats basic_stats; + /* DFX statistics that driver does not need to discard packets */ + struct hns3_rx_dfx_stats dfx_stats; + /* Error statistics that driver needs to discard packets */ + struct hns3_rx_bd_errors_stats err_stats; struct rte_mbuf *bulk_mbuf[HNS3_BULK_ALLOC_MBUF_NUM]; uint16_t bulk_mbuf_num; @@ -325,6 +345,62 @@ struct hns3_rx_queue { struct rte_mbuf fake_mbuf; /* fake mbuf used with vector rx */ }; +struct hns3_tx_basic_stats { + uint64_t packets; + uint64_t bytes; +}; + +/* + * The following items are used for the abnormal errors statistics in + * the Tx datapath. When upper level application calls the + * rte_eth_tx_burst API function to send multiple packets at a time with + * burst mode based on hns3 network engine, there are some abnormal + * conditions that cause the driver to fail to operate the hardware to + * send packets correctly. + * Note: When using burst mode to call the rte_eth_tx_burst API function + * to send multiple packets at a time. When the first abnormal error is + * detected, add one to the relevant error statistics item, and then + * exit the loop of sending multiple packets of the function. That is to + * say, even if there are multiple packets in which abnormal errors may + * be detected in the burst, the relevant error statistics in the driver + * will only be increased by one. + * The detail description of the Tx abnormal errors statistic items as + * below: + * - over_length_pkt_cnt + * Total number of greater than HNS3_MAX_FRAME_LEN the driver + * supported. + * + * - exceed_limit_bd_pkt_cnt + * Total number of exceeding the hardware limited bd which process + * a packet needed bd numbers. + * + * - exceed_limit_bd_reassem_fail + * Total number of exceeding the hardware limited bd fail which + * process a packet needed bd numbers and reassemble fail. + * + * - unsupported_tunnel_pkt_cnt + * Total number of unsupported tunnel packet. The unsupported tunnel + * type: vxlan_gpe, gtp, ipip and MPLSINUDP, MPLSINUDP is a packet + * with MPLS-in-UDP RFC 7510 header. + * + * - queue_full_cnt + * Total count which the available bd numbers in current bd queue is + * less than the bd numbers with the pkt process needed. + * + * - pkt_padding_fail_cnt + * Total count which the packet length is less than minimum packet + * length(struct hns3_tx_queue::min_tx_pkt_len) supported by + * hardware in Tx direction and fail to be appended with 0. + */ +struct hns3_tx_dfx_stats { + uint64_t over_length_pkt_cnt; + uint64_t exceed_limit_bd_pkt_cnt; + uint64_t exceed_limit_bd_reassem_fail; + uint64_t unsupported_tunnel_pkt_cnt; + uint64_t queue_full_cnt; + uint64_t pkt_padding_fail_cnt; +}; + struct hns3_tx_queue { void *io_base; volatile void *io_tail_reg; @@ -408,54 +484,8 @@ struct hns3_tx_queue { bool pvid_sw_shift_en; bool enabled; /* indicate if Tx queue has been enabled */ - /* - * The following items are used for the abnormal errors statistics in - * the Tx datapath. When upper level application calls the - * rte_eth_tx_burst API function to send multiple packets at a time with - * burst mode based on hns3 network engine, there are some abnormal - * conditions that cause the driver to fail to operate the hardware to - * send packets correctly. - * Note: When using burst mode to call the rte_eth_tx_burst API function - * to send multiple packets at a time. When the first abnormal error is - * detected, add one to the relevant error statistics item, and then - * exit the loop of sending multiple packets of the function. That is to - * say, even if there are multiple packets in which abnormal errors may - * be detected in the burst, the relevant error statistics in the driver - * will only be increased by one. - * The detail description of the Tx abnormal errors statistic items as - * below: - * - over_length_pkt_cnt - * Total number of greater than HNS3_MAX_FRAME_LEN the driver - * supported. - * - * - exceed_limit_bd_pkt_cnt - * Total number of exceeding the hardware limited bd which process - * a packet needed bd numbers. - * - * - exceed_limit_bd_reassem_fail - * Total number of exceeding the hardware limited bd fail which - * process a packet needed bd numbers and reassemble fail. - * - * - unsupported_tunnel_pkt_cnt - * Total number of unsupported tunnel packet. The unsupported tunnel - * type: vxlan_gpe, gtp, ipip and MPLSINUDP, MPLSINUDP is a packet - * with MPLS-in-UDP RFC 7510 header. - * - * - queue_full_cnt - * Total count which the available bd numbers in current bd queue is - * less than the bd numbers with the pkt process needed. - * - * - pkt_padding_fail_cnt - * Total count which the packet length is less than minimum packet - * length(struct hns3_tx_queue::min_tx_pkt_len) supported by - * hardware in Tx direction and fail to be appended with 0. - */ - uint64_t over_length_pkt_cnt; - uint64_t exceed_limit_bd_pkt_cnt; - uint64_t exceed_limit_bd_reassem_fail; - uint64_t unsupported_tunnel_pkt_cnt; - uint64_t queue_full_cnt; - uint64_t pkt_padding_fail_cnt; + struct hns3_tx_basic_stats basic_stats; + struct hns3_tx_dfx_stats dfx_stats; }; #define HNS3_GET_TX_QUEUE_PEND_BD_NUM(txq) \ @@ -470,14 +500,10 @@ struct hns3_queue_info { }; #define HNS3_TX_CKSUM_OFFLOAD_MASK ( \ - PKT_TX_OUTER_IPV6 | \ - PKT_TX_OUTER_IPV4 | \ PKT_TX_OUTER_IP_CKSUM | \ - PKT_TX_IPV6 | \ - PKT_TX_IPV4 | \ PKT_TX_IP_CKSUM | \ - PKT_TX_L4_MASK | \ - PKT_TX_TUNNEL_MASK) + PKT_TX_TCP_SEG | \ + PKT_TX_L4_MASK) enum hns3_cksum_status { HNS3_CKSUM_NONE = 0, @@ -512,9 +538,9 @@ hns3_handle_bdinfo(struct hns3_rx_queue *rxq, struct rte_mbuf *rxm, if (unlikely((l234_info & L2E_TRUNC_ERR_FLAG) || rxm->pkt_len == 0)) { if (l234_info & BIT(HNS3_RXD_L2E_B)) - rxq->l2_errors++; + rxq->err_stats.l2_errors++; else - rxq->pkt_len_errors++; + rxq->err_stats.pkt_len_errors++; return -EINVAL; } @@ -526,24 +552,24 @@ hns3_handle_bdinfo(struct hns3_rx_queue *rxq, struct rte_mbuf *rxm, if (unlikely(l234_info & BIT(HNS3_RXD_L3E_B))) { rxm->ol_flags |= PKT_RX_IP_CKSUM_BAD; - rxq->l3_csum_errors++; + rxq->dfx_stats.l3_csum_errors++; tmp |= HNS3_L3_CKSUM_ERR; } if (unlikely(l234_info & BIT(HNS3_RXD_L4E_B))) { rxm->ol_flags |= PKT_RX_L4_CKSUM_BAD; - rxq->l4_csum_errors++; + rxq->dfx_stats.l4_csum_errors++; tmp |= HNS3_L4_CKSUM_ERR; } if (unlikely(l234_info & BIT(HNS3_RXD_OL3E_B))) { - rxq->ol3_csum_errors++; + rxq->dfx_stats.ol3_csum_errors++; tmp |= HNS3_OUTER_L3_CKSUM_ERR; } if (unlikely(l234_info & BIT(HNS3_RXD_OL4E_B))) { rxm->ol_flags |= PKT_RX_OUTER_L4_CKSUM_BAD; - rxq->ol4_csum_errors++; + rxq->dfx_stats.ol4_csum_errors++; tmp |= HNS3_OUTER_L4_CKSUM_ERR; } } @@ -580,14 +606,14 @@ static inline uint32_t hns3_rx_calc_ptype(struct hns3_rx_queue *rxq, const uint32_t l234_info, const uint32_t ol_info) { - const struct hns3_ptype_table *const ptype_tbl = rxq->ptype_tbl; + const struct hns3_ptype_table * const ptype_tbl = rxq->ptype_tbl; uint32_t l2id, l3id, l4id; - uint32_t ol3id, ol4id; + uint32_t ol3id, ol4id, ol2id; ol4id = hns3_get_field(ol_info, HNS3_RXD_OL4ID_M, HNS3_RXD_OL4ID_S); ol3id = hns3_get_field(ol_info, HNS3_RXD_OL3ID_M, HNS3_RXD_OL3ID_S); - l2id = hns3_get_field(l234_info, HNS3_RXD_STRP_TAGP_M, - HNS3_RXD_STRP_TAGP_S); + ol2id = hns3_get_field(ol_info, HNS3_RXD_OVLAN_M, HNS3_RXD_OVLAN_S); + l2id = hns3_get_field(l234_info, HNS3_RXD_VLAN_M, HNS3_RXD_VLAN_S); l3id = hns3_get_field(l234_info, HNS3_RXD_L3ID_M, HNS3_RXD_L3ID_S); l4id = hns3_get_field(l234_info, HNS3_RXD_L4ID_M, HNS3_RXD_L4ID_S); @@ -595,9 +621,10 @@ hns3_rx_calc_ptype(struct hns3_rx_queue *rxq, const uint32_t l234_info, return ptype_tbl->inner_l2table[l2id] | ptype_tbl->inner_l3table[l3id] | ptype_tbl->inner_l4table[l4id] | - ptype_tbl->ol3table[ol3id] | ptype_tbl->ol4table[ol4id]; + ptype_tbl->ol3table[ol3id] | + ptype_tbl->ol4table[ol4id] | ptype_tbl->ol2table[ol2id]; else - return ptype_tbl->l2table[l2id] | ptype_tbl->l3table[l3id] | + return ptype_tbl->l2l3table[l2id][l3id] | ptype_tbl->l4table[l4id]; } @@ -620,6 +647,7 @@ int hns3_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc, struct rte_mempool *mp); int hns3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc, unsigned int socket, const struct rte_eth_txconf *conf); +uint32_t hns3_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id); int hns3_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id); int hns3_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id); int hns3_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id); @@ -644,12 +672,15 @@ uint16_t hns3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts); uint16_t hns3_xmit_pkts_vec(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts); +uint16_t hns3_xmit_pkts_vec_sve(void *tx_queue, struct rte_mbuf **tx_pkts, + uint16_t nb_pkts); int hns3_tx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id, struct rte_eth_burst_mode *mode); const uint32_t *hns3_dev_supported_ptypes_get(struct rte_eth_dev *dev); void hns3_init_rx_ptype_tble(struct rte_eth_dev *dev); void hns3_set_rxtx_function(struct rte_eth_dev *eth_dev); +uint32_t hns3_get_tqp_intr_reg_offset(uint16_t tqp_intr_id); void hns3_set_queue_intr_gl(struct hns3_hw *hw, uint16_t queue_id, uint8_t gl_idx, uint16_t gl_value); void hns3_set_queue_intr_rl(struct hns3_hw *hw, uint16_t queue_id, @@ -674,5 +705,6 @@ uint32_t hns3_get_tqp_reg_offset(uint16_t idx); int hns3_start_all_txqs(struct rte_eth_dev *dev); int hns3_start_all_rxqs(struct rte_eth_dev *dev); void hns3_stop_all_txqs(struct rte_eth_dev *dev); +void hns3_restore_tqp_enable_state(struct hns3_hw *hw); #endif /* _HNS3_RXTX_H_ */