add idpf pmd enhancement features
cover add idpf pmd enhancement features
This patchset add several enhancement features of idpf pmd. Including the following:
- add hw statistics, support stats/xstats ops
- add rss configure/show ops
- add event handle: link status
- add scattered data path for single queue
This patchset is based on the refactor idpf PMD code:
http://patches.dpdk.org/project/dpdk/list/?submitter=410&q=&delegate=&archive=&series=&state=*
http://patches.dpdk.org/project/dpdk/list/?submitter=2083&q=&delegate=&archive=&series=&state=*
Mingxia Liu (7):
common/idpf: add hw statistics
common/idpf: add RSS set/get ops
common/idpf: support single q scatter RX datapath common/idpf: add rss_offload hash in singleq rx common/idpf: add alarm to support handle vchnl message common/idpf: add xstats ops
common/idpf: update mbuf_alloc_failed multi-thread process
drivers/common/idpf/idpf_common_device.c | 17 + drivers/common/idpf/idpf_common_device.h | 11 +- drivers/common/idpf/idpf_common_rxtx.c | 158 ++++- drivers/common/idpf/idpf_common_rxtx.h | 5 +- drivers/common/idpf/idpf_common_rxtx_avx512.c | 12 +- drivers/common/idpf/idpf_common_virtchnl.c | 157 ++++- drivers/common/idpf/idpf_common_virtchnl.h | 18 +- drivers/common/idpf/version.map | 9 + drivers/net/idpf/idpf_ethdev.c | 639 +++++++++++++++++- drivers/net/idpf/idpf_ethdev.h | 7 +- drivers/net/idpf/idpf_rxtx.c | 26 +- drivers/net/idpf/idpf_rxtx.h | 2 + 12 files changed, 1029 insertions(+), 32 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/7 common/idpf: add hw statistics
This patch add hardware packets/bytes statistics.
--- drivers/common/idpf/idpf_common_device.c | 17 +++++ drivers/common/idpf/idpf_common_device.h | 5 +- drivers/common/idpf/idpf_common_virtchnl.c | 27 +++++++ drivers/common/idpf/idpf_common_virtchnl.h | 3 + drivers/common/idpf/version.map | 2 + drivers/net/idpf/idpf_ethdev.c | 87 ++++++++++++++++++++++ 6 files changed, 140 insertions(+), 1 deletion(-)
drivers/common/idpf/idpf_common_device.c +17 -0
@@ -672,4 +672,21 @@ idpf_create_vport_info_init(struct idpf_vport *vport,return 0 ; } +void +idpf_update_stats (struct virtchnl2_vport_stats *oes,struct virtchnl2_vport_stats *nes) +{ + nes->rx_bytes = nes->rx_bytes - oes->rx_bytes; + nes->rx_unicast = nes->rx_unicast - oes->rx_unicast; + nes->rx_multicast = nes->rx_multicast - oes->rx_multicast; + nes->rx_broadcast = nes->rx_broadcast - oes->rx_broadcast; + nes->rx_errors = nes->rx_errors - oes->rx_errors; + nes->rx_discards = nes->rx_discards - oes->rx_discards; + nes->tx_bytes = nes->tx_bytes - oes->tx_bytes; + nes->tx_unicast = nes->tx_unicast - oes->tx_unicast; + nes->tx_multicast = nes->tx_multicast - oes->tx_multicast; + nes->tx_broadcast = nes->tx_broadcast - oes->tx_broadcast; + nes->tx_errors = nes->tx_errors - oes->tx_errors; + nes->tx_discards = nes->tx_discards - oes->tx_discards; +} +RTE_LOG_REGISTER_SUFFIX (idpf_common_logtype, common,NOTICE );
drivers/common/idpf/idpf_common_device.h +4 -1
@@ -112,6 +112,8 @@ struct idpf_vport {bool tx_vec_allowed;bool rx_use_avx512;bool tx_use_avx512; + +struct virtchnl2_vport_stats eth_stats_offset; };/* Message type read in virtual channel from PF */
@@ -188,5 +190,6 @@ int idpf_config_irq_unmap(struct idpf_vport *vport, uint16_t nb_rx_queues);__rte_internal int idpf_create_vport_info_init(struct idpf_vport *vport,struct virtchnl2_create_vport *vport_info); - +__rte_internal +void idpf_update_stats(struct virtchnl2_vport_stats *oes, struct virtchnl2_vport_stats *nes);#endif /* _IDPF_COMMON_DEVICE_H_ */
drivers/common/idpf/idpf_common_virtchnl.c +27 -0
@@ -217,6 +217,7 @@ idpf_execute_vc_cmd(struct idpf_adapter *adapter, struct idpf_cmd_info *args)case VIRTCHNL2_OP_UNMAP_QUEUE_VECTOR :case VIRTCHNL2_OP_ALLOC_VECTORS :case VIRTCHNL2_OP_DEALLOC_VECTORS : +case VIRTCHNL2_OP_GET_STATS :/* for init virtchnl ops, need to poll the response */ err =idpf_read_one_msg (adapter, args->ops, args->out_size, args->out_buffer);clear_cmd (adapter);
@@ -806,6 +807,32 @@ idpf_vc_query_ptype_info(struct idpf_adapter *adapter)return err; } +int +idpf_query_stats (struct idpf_vport *vport, +struct virtchnl2_vport_stats **pstats) +{ +struct idpf_adapter *adapter = vport->adapter; +struct virtchnl2_vport_stats vport_stats; +struct idpf_cmd_info args; +int err; + + vport_stats.vport_id = vport->vport_id; + args.ops =VIRTCHNL2_OP_GET_STATS ; + args.in_args = (u8 *)&vport_stats; + args.in_args_size =sizeof (vport_stats); + args.out_buffer = adapter->mbx_resp; + args.out_size =IDPF_DFLT_MBX_BUF_SIZE ; + + err =idpf_execute_vc_cmd (adapter, &args); +if (err) { +DRV_LOG (ERR ,"Failed to execute command of VIRTCHNL2_OP_GET_STATS" ); + *pstats =NULL ; +return err; + } + *pstats = (struct virtchnl2_vport_stats *)args.out_buffer; +return 0 ; +} +#define IDPF_RX_BUF_STRIDE 64int idpf_vc_config_rxq (struct idpf_vport *vport,struct idpf_rx_queue *rxq)
drivers/common/idpf/idpf_common_virtchnl.h +3 -0
@@ -38,4 +38,7 @@ __rte_internalint idpf_vc_config_rxq (struct idpf_vport *vport,struct idpf_rx_queue *rxq);__rte_internal int idpf_vc_config_txq(struct idpf_vport *vport, struct idpf_tx_queue *txq); +__rte_internal +int idpf_query_stats(struct idpf_vport *vport, +struct virtchnl2_vport_stats **pstats);#endif /* _IDPF_COMMON_VIRTCHNL_H_ */
drivers/common/idpf/version.map +2 -0
@@ -50,6 +50,8 @@ INTERNAL { idpf_splitq_recv_pkts_avx512; idpf_singleq_xmit_pkts_avx512; idpf_splitq_xmit_pkts_avx512; + idpf_update_stats; + idpf_query_stats; local: *; };
drivers/net/idpf/idpf_ethdev.c +87 -0
105 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 2/7 common/idpf: add RSS set/get ops
In reply to Mingxia LiuAdd support for these device ops:
- rss_reta_update
- rss_reta_query
- rss_hash_update
- rss_hash_conf_get
--- drivers/common/idpf/idpf_common_device.h | 1 + drivers/common/idpf/idpf_common_virtchnl.c | 119 ++++++++ drivers/common/idpf/idpf_common_virtchnl.h | 15 +- drivers/common/idpf/version.map | 6 + drivers/net/idpf/idpf_ethdev.c | 303 +++++++++++++++++++++ drivers/net/idpf/idpf_ethdev.h | 5 +- 6 files changed, 445 insertions(+), 4 deletions(-)
drivers/common/idpf/idpf_common_device.h +1 -0
@@ -95,6 +95,7 @@ struct idpf_vport {uint32_t *rss_lut;uint8_t *rss_key;uint64_t rss_hf; +uint64_t last_general_rss_hf;/* MSIX info*/ struct virtchnl2_queue_vector *qv_map;/* queue vector mapping */
drivers/common/idpf/idpf_common_virtchnl.c +119 -0
143 lines not on this page · raw message
drivers/common/idpf/idpf_common_virtchnl.h +12 -3
@@ -13,9 +13,6 @@ int idpf_vc_get_caps(struct idpf_adapter *adapter);int idpf_vc_create_vport (struct idpf_vport *vport,struct virtchnl2_create_vport *vport_info);int idpf_vc_destroy_vport (struct idpf_vport *vport); -int idpf_vc_set_rss_key (struct idpf_vport *vport); -int idpf_vc_set_rss_lut (struct idpf_vport *vport); -int idpf_vc_set_rss_hash (struct idpf_vport *vport);int idpf_vc_config_irq_map_unmap (struct idpf_vport *vport,uint16_t nb_rxq,bool map);int idpf_vc_query_ptype_info (struct idpf_adapter *adapter);
@@ -41,4 +38,16 @@ int idpf_vc_config_txq(struct idpf_vport *vport, struct idpf_tx_queue *txq);__rte_internal int idpf_query_stats(struct idpf_vport *vport,struct virtchnl2_vport_stats **pstats); +__rte_internal +int idpf_vc_set_rss_key(struct idpf_vport *vport); +__rte_internal +int idpf_vc_get_rss_key(struct idpf_vport *vport); +__rte_internal +int idpf_vc_set_rss_lut(struct idpf_vport *vport); +__rte_internal +int idpf_vc_get_rss_lut(struct idpf_vport *vport); +__rte_internal +int idpf_vc_set_rss_hash(struct idpf_vport *vport); +__rte_internal +int idpf_vc_get_rss_hash(struct idpf_vport *vport);#endif /* _IDPF_COMMON_VIRTCHNL_H_ */
drivers/common/idpf/version.map +6 -0
@@ -52,6 +52,12 @@ INTERNAL { idpf_splitq_xmit_pkts_avx512; idpf_update_stats; idpf_query_stats; + idpf_vc_set_rss_key; + idpf_vc_get_rss_key; + idpf_vc_set_rss_lut; + idpf_vc_get_rss_lut; + idpf_vc_set_rss_hash; + idpf_vc_get_rss_hash; local: *; };
drivers/net/idpf/idpf_ethdev.c +303 -0
333 lines not on this page · raw message
drivers/net/idpf/idpf_ethdev.h +4 -1
@@ -47,7 +47,10 @@ RTE_ETH_RSS_NONFRAG_IPV6_TCP | \ RTE_ETH_RSS_NONFRAG_IPV6_UDP | \ RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \ - RTE_ETH_RSS_NONFRAG_IPV6_OTHER) + RTE_ETH_RSS_NONFRAG_IPV6_OTHER | \ + RTE_ETH_RSS_L2_PAYLOAD) + +#define IDPF_RSS_KEY_LEN 52#define IDPF_ADAPTER_NAME_LEN (PCI_PRI_STR_SIZE + 1)
Signature · 1 line
2.25.1
PATCH 3/7 common/idpf: support single q scatter RX datapath
In reply to Mingxia LiuThis patch add single q recv scatter rx function.
--- drivers/common/idpf/idpf_common_rxtx.c | 134 +++++++++++++++++++++++++ drivers/common/idpf/idpf_common_rxtx.h | 3 + drivers/common/idpf/version.map | 1 + drivers/net/idpf/idpf_ethdev.c | 3 +- drivers/net/idpf/idpf_rxtx.c | 26 ++++- drivers/net/idpf/idpf_rxtx.h | 2 + 6 files changed, 166 insertions(+), 3 deletions(-)
drivers/common/idpf/idpf_common_rxtx.c +134 -0
@@ -1144,6 +1144,140 @@ idpf_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,return nb_rx; } +uint16_t +idpf_singleq_recv_scatter_pkts (void *rx_queue,struct rte_mbuf **rx_pkts, +uint16_t nb_pkts) +{ +struct idpf_rx_queue *rxq = rx_queue; +volatile union virtchnl2_rx_desc *rx_ring = rxq->rx_ring; +volatile union virtchnl2_rx_desc *rxdp; +union virtchnl2_rx_desc rxd; +struct idpf_adapter *ad; +struct rte_mbuf *first_seg = rxq->pkt_first_seg; +struct rte_mbuf *last_seg = rxq->pkt_last_seg; +struct rte_mbuf *rxm; +struct rte_mbuf *nmb; +struct rte_eth_dev *dev; +const uint32_t *ptype_tbl = rxq->adapter->ptype_tbl; +uint16_t nb_hold =0 , nb_rx =0 ; +uint16_t rx_id = rxq->rx_tail; +uint16_t rx_packet_len; +uint16_t rx_status0; +uint64_t pkt_flags; +uint64_t dma_addr; +uint64_t ts_ns; + + ad = rxq->adapter; + +if (unlikely (!rxq) ||unlikely (!rxq->q_started)) +return nb_rx; + +while (nb_rx < nb_pkts) { + rxdp = &rx_ring[rx_id]; + rx_status0 =rte_le_to_cpu_16 (rxdp->flex_nic_wb.status_error0); + +/* Check the DD bit first */ +if (!(rx_status0 & (1 <<VIRTCHNL2_RX_FLEX_DESC_STATUS0_DD_S ))) +break ; + + nmb =rte_mbuf_raw_alloc (rxq->mp); +if (unlikely (!nmb)) { + rxq->rx_stats.mbuf_alloc_failed++; +RX_LOG (DEBUG ,"RX mbuf alloc failed port_id=%u " +"queue_id=%u" , rxq->port_id, rxq->queue_id); +break ; + } + + rxd = *rxdp; + + nb_hold++; + rxm = rxq->sw_ring[rx_id]; + rxq->sw_ring[rx_id] = nmb; + rx_id++; +if (unlikely (rx_id == rxq->nb_rx_desc)) + rx_id =0 ; + +/* Prefetch next mbuf */ +rte_prefetch0 (rxq->sw_ring[rx_id]); + +/* When next RX descriptor is on a cache line boundary, +* prefetch the next 4 RX descriptors and next 8 pointers +* to mbufs. +*/ +if ((rx_id &0x3 ) ==0 ) { +rte_prefetch0 (&rx_ring[rx_id]); +rte_prefetch0 (rxq->sw_ring[rx_id]); + } + dma_addr = +rte_cpu_to_le_64 (rte_mbuf_data_iova_default (nmb)); + rxdp->read.hdr_addr =0 ; + rxdp->read.pkt_addr = dma_addr; + rx_packet_len = (rte_cpu_to_le_16 (rxd.flex_nic_wb.pkt_len) & +VIRTCHNL2_RX_FLEX_DESC_PKT_LEN_M ); + rxm->data_len = rx_packet_len; + rxm->data_off =RTE_PKTMBUF_HEADROOM ; + +/** +* If this is the first buffer of the received packet, set the +* pointer to the first mbuf of the packet and initialize its +* context. Otherwise, update the total length and the number +* of segments of the current scattered packet, and update the +* pointer to the last mbuf of the current packet. +*/ +if (!first_seg) { + first_seg = rxm; + first_seg->nb_segs =1 ; + first_seg->pkt_len = rx_packet_len; + }else { + first_seg->pkt_len = + (uint16_t )(first_seg->pkt_len + + rx_packet_len); + first_seg->nb_segs++; + last_seg->next = rxm; + } + +if (!(rx_status0 & (1 <<VIRTCHNL2_RX_FLEX_DESC_STATUS0_EOF_S ))) { + last_seg = rxm; +continue ; + } + + rxm->next =NULL ; + + first_seg->port = rxq->port_id; + first_seg->ol_flags =0 ; + pkt_flags =idpf_rxd_to_pkt_flags (rx_status0); + first_seg->packet_type = + ptype_tbl[(uint8_t )(rte_cpu_to_le_16 (rxd.flex_nic_wb.ptype_flex_flags0) & +VIRTCHNL2_RX_FLEX_DESC_PTYPE_M )]; + +if (idpf_timestamp_dynflag >0 && + (rxq->offloads &IDPF_RX_OFFLOAD_TIMESTAMP ) !=0 ) { +/* timestamp */ + ts_ns =idpf_tstamp_convert_32b_64b (ad, + rxq->hw_register_set, +rte_le_to_cpu_32 (rxd.flex_nic_wb.flex_ts.ts_high)); + rxq->hw_register_set =0 ; + *RTE_MBUF_DYNFIELD (rxm, + idpf_timestamp_dynfield_offset, + rte_mbuf_timestamp_t *) = ts_ns; + first_seg->ol_flags |= idpf_timestamp_dynflag; + } + + first_seg->ol_flags |= pkt_flags; +rte_prefetch0 (RTE_PTR_ADD (first_seg->buf_addr, + first_seg->data_off)); + rx_pkts[nb_rx++] = first_seg; + first_seg =NULL ; + } + rxq->rx_tail = rx_id; + rxq->pkt_first_seg = first_seg; + rxq->pkt_last_seg = last_seg; + +idpf_update_rx_tail (rxq, nb_hold, rx_id); + +return nb_rx; +} +static inline int idpf_xmit_cleanup (struct idpf_tx_queue *txq) {
drivers/common/idpf/idpf_common_rxtx.h +3 -0
@@ -260,6 +260,9 @@ __rte_internaluint16_t idpf_splitq_recv_pkts (void *rx_queue,struct rte_mbuf **rx_pkts,uint16_t nb_pkts);__rte_internal +uint16_t idpf_singleq_recv_scatter_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, +uint16_t nb_pkts); +__rte_internal uint16_t idpf_splitq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,uint16_t nb_pkts); __rte_internal
drivers/common/idpf/version.map +1 -0
@@ -41,6 +41,7 @@ INTERNAL { idpf_splitq_recv_pkts; idpf_splitq_xmit_pkts; idpf_singleq_recv_pkts; + idpf_singleq_recv_scatter_pkts; idpf_singleq_xmit_pkts; idpf_prep_pkts; idpf_singleq_rx_vec_setup;
drivers/net/idpf/idpf_ethdev.c +2 -1
@@ -119,7 +119,8 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)RTE_ETH_RX_OFFLOAD_UDP_CKSUM |RTE_ETH_RX_OFFLOAD_TCP_CKSUM |RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM | -RTE_ETH_RX_OFFLOAD_TIMESTAMP ; +RTE_ETH_RX_OFFLOAD_TIMESTAMP | +RTE_ETH_RX_OFFLOAD_SCATTER ; dev_info->tx_offload_capa = RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
drivers/net/idpf/idpf_rxtx.c +24 -2
@@ -506,6 +506,8 @@ int idpf_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id) {struct idpf_rx_queue *rxq; +uint16_t max_pkt_len; +uint32_t frame_size;int err;if (rx_queue_id >= dev->data->nb_rx_queues)
@@ -519,6 +521,17 @@ idpf_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id)return -EINVAL ; } + frame_size = dev->data->mtu +IDPF_ETH_OVERHEAD ; + + max_pkt_len = +RTE_MIN ((uint32_t )IDPF_SUPPORT_CHAIN_NUM * rxq->rx_buf_len, + frame_size); + + rxq->max_pkt_len = max_pkt_len; +if ((dev->data->dev_conf.rxmode.offloads &RTE_ETH_RX_OFFLOAD_SCATTER ) || + frame_size > rxq->rx_buf_len) + dev->data->scattered_rx =1 ; + err =idpf_register_ts_mbuf (rxq);if (err !=0 ) { PMD_DRV_LOG(ERR, "fail to regidter timestamp mbuf %u",
@@ -804,13 +817,22 @@ idpf_set_rx_function(struct rte_eth_dev *dev) #endif /* CC_AVX512_SUPPORT */ } +if (dev->data->scattered_rx) { + dev->rx_pkt_burst = idpf_singleq_recv_scatter_pkts; +return ; + } dev->rx_pkt_burst = idpf_singleq_recv_pkts; }#else -if (vport->rxq_model ==VIRTCHNL2_QUEUE_MODEL_SPLIT ) +if (vport->rxq_model ==VIRTCHNL2_QUEUE_MODEL_SPLIT ) { dev->rx_pkt_burst = idpf_splitq_recv_pkts; -else + }else { +if (dev->data->scattered_rx) { + dev->rx_pkt_burst = idpf_singleq_recv_scatter_pkts; +return ; + } dev->rx_pkt_burst = idpf_singleq_recv_pkts; + }#endif /* RTE_ARCH_X86 */ }
drivers/net/idpf/idpf_rxtx.h +2 -0
@@ -23,6 +23,8 @@#define IDPF_DEFAULT_TX_RS_THRESH 32#define IDPF_DEFAULT_TX_FREE_THRESH 32 +#define IDPF_SUPPORT_CHAIN_NUM 5 + int idpf_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, uint16_t nb_desc, unsigned int socket_id, const struct rte_eth_rxconf *rx_conf,
Signature · 1 line
2.25.1
PATCH 4/7 common/idpf: add rss_offload hash in singleq rx
In reply to Mingxia LiuThis patch add rss valid flag and hash value parsing of rx descriptor.
--- drivers/common/idpf/idpf_common_rxtx.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/common/idpf/idpf_common_rxtx.c +16 -0
@@ -1028,6 +1028,20 @@ idpf_update_rx_tail(struct idpf_rx_queue *rxq, uint16_t nb_hold, rxq->nb_rx_hold = nb_hold; } +static inline void +idpf_singleq_rx_rss_offload (struct rte_mbuf *mb, +volatile struct virtchnl2_rx_flex_desc_nic *rx_desc, +uint64_t *pkt_flags) +{ +uint16_t rx_status0 =rte_le_to_cpu_16 (rx_desc->status_error0); + +if (rx_status0 &RTE_BIT32 (VIRTCHNL2_RX_FLEX_DESC_STATUS0_RSS_VALID_S )) { + *pkt_flags |=RTE_MBUF_F_RX_RSS_HASH ; + mb->hash.rss =rte_le_to_cpu_32 (rx_desc->rss_hash); + } + +} +uint16_t idpf_singleq_recv_pkts (void *rx_queue,struct rte_mbuf **rx_pkts,uint16_t nb_pkts)
@@ -1116,6 +1130,7 @@ idpf_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, rxm->port = rxq->port_id; rxm->ol_flags =0 ; pkt_flags =idpf_rxd_to_pkt_flags (rx_status0); +idpf_singleq_rx_rss_offload (rxm, &rxd.flex_nic_wb, &pkt_flags); rxm->packet_type = ptype_tbl[(uint8_t )(rte_cpu_to_le_16 (rxd.flex_nic_wb.ptype_flex_flags0) &VIRTCHNL2_RX_FLEX_DESC_PTYPE_M )];
@@ -1246,6 +1261,7 @@ idpf_singleq_recv_scatter_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, first_seg->port = rxq->port_id; first_seg->ol_flags =0 ; pkt_flags =idpf_rxd_to_pkt_flags (rx_status0); +idpf_singleq_rx_rss_offload (first_seg, &rxd.flex_nic_wb, &pkt_flags); first_seg->packet_type = ptype_tbl[(uint8_t )(rte_cpu_to_le_16 (rxd.flex_nic_wb.ptype_flex_flags0) &VIRTCHNL2_RX_FLEX_DESC_PTYPE_M )];
Signature · 1 line
2.25.1
PATCH 5/7 common/idpf: add alarm to support handle vchnl message
In reply to Mingxia LiuHandle virtual channel message.
Refine link status update.
--- drivers/common/idpf/idpf_common_device.h | 5 + drivers/common/idpf/idpf_common_virtchnl.c | 19 --- drivers/net/idpf/idpf_ethdev.c | 165 ++++++++++++++++++++- drivers/net/idpf/idpf_ethdev.h | 2 + 4 files changed, 171 insertions(+), 20 deletions(-)
drivers/common/idpf/idpf_common_device.h +5 -0
@@ -115,6 +115,11 @@ struct idpf_vport {bool tx_use_avx512;struct virtchnl2_vport_stats eth_stats_offset; + +void *dev; +/* Event from ipf */ +bool link_up; +uint32_t link_speed; };/* Message type read in virtual channel from PF */
drivers/common/idpf/idpf_common_virtchnl.c +0 -19
@@ -202,25 +202,6 @@ idpf_execute_vc_cmd(struct idpf_adapter *adapter, struct idpf_cmd_info *args)switch (args->ops) {case VIRTCHNL_OP_VERSION :case VIRTCHNL2_OP_GET_CAPS : -case VIRTCHNL2_OP_CREATE_VPORT : -case VIRTCHNL2_OP_DESTROY_VPORT : -case VIRTCHNL2_OP_SET_RSS_KEY : -case VIRTCHNL2_OP_SET_RSS_LUT : -case VIRTCHNL2_OP_SET_RSS_HASH : -case VIRTCHNL2_OP_CONFIG_RX_QUEUES : -case VIRTCHNL2_OP_CONFIG_TX_QUEUES : -case VIRTCHNL2_OP_ENABLE_QUEUES : -case VIRTCHNL2_OP_DISABLE_QUEUES : -case VIRTCHNL2_OP_ENABLE_VPORT : -case VIRTCHNL2_OP_DISABLE_VPORT : -case VIRTCHNL2_OP_MAP_QUEUE_VECTOR : -case VIRTCHNL2_OP_UNMAP_QUEUE_VECTOR : -case VIRTCHNL2_OP_ALLOC_VECTORS : -case VIRTCHNL2_OP_DEALLOC_VECTORS : -case VIRTCHNL2_OP_GET_STATS : -case VIRTCHNL2_OP_GET_RSS_KEY : -case VIRTCHNL2_OP_GET_RSS_HASH : -case VIRTCHNL2_OP_GET_RSS_LUT :/* for init virtchnl ops, need to poll the response */ err =idpf_read_one_msg (adapter, args->ops, args->out_size, args->out_buffer);clear_cmd (adapter);
drivers/net/idpf/idpf_ethdev.c +164 -1
206 lines not on this page · raw message
drivers/net/idpf/idpf_ethdev.h +2 -0
@@ -54,6 +54,8 @@#define IDPF_ADAPTER_NAME_LEN (PCI_PRI_STR_SIZE + 1) +#define IDPF_ALARM_INTERVAL 50000/* us */ +struct idpf_vport_param {struct idpf_adapter_ext *adapter;uint16_t devarg_id;/* arg id from user */
Signature · 1 line
2.25.1
PATCH 6/7 common/idpf: add xstats ops
In reply to Mingxia LiuAdd support for these device ops:
-idpf_dev_xstats_get
-idpf_dev_xstats_get_names
-idpf_dev_xstats_reset
--- drivers/net/idpf/idpf_ethdev.c | 80 ++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+)
drivers/net/idpf/idpf_ethdev.c +80 -0
@@ -80,6 +80,30 @@ static const uint64_t idpf_ipv6_rss = RTE_ETH_RSS_NONFRAG_IPV6_UDP |RTE_ETH_RSS_NONFRAG_IPV6_OTHER |RTE_ETH_RSS_FRAG_IPV6 ; +struct rte_idpf_xstats_name_off { +char name[RTE_ETH_XSTATS_NAME_SIZE ]; +unsigned int offset; +}; + +static const struct rte_idpf_xstats_name_off rte_idpf_stats_strings[] = { + {"rx_bytes" , offsetof(struct virtchnl2_vport_stats , rx_bytes)}, + {"rx_unicast_packets" , offsetof(struct virtchnl2_vport_stats , rx_unicast)}, + {"rx_multicast_packets" , offsetof(struct virtchnl2_vport_stats , rx_multicast)}, + {"rx_broadcast_packets" , offsetof(struct virtchnl2_vport_stats , rx_broadcast)}, + {"rx_dropped_packets" , offsetof(struct virtchnl2_vport_stats , rx_discards)}, + {"rx_errors" , offsetof(struct virtchnl2_vport_stats , rx_errors)}, + {"rx_unknown_protocol_packets" , offsetof(struct virtchnl2_vport_stats , + rx_unknown_protocol)}, + {"tx_bytes" , offsetof(struct virtchnl2_vport_stats , tx_bytes)}, + {"tx_unicast_packets" , offsetof(struct virtchnl2_vport_stats , tx_unicast)}, + {"tx_multicast_packets" , offsetof(struct virtchnl2_vport_stats , tx_multicast)}, + {"tx_broadcast_packets" , offsetof(struct virtchnl2_vport_stats , tx_broadcast)}, + {"tx_dropped_packets" , offsetof(struct virtchnl2_vport_stats , tx_discards)}, + {"tx_error_packets" , offsetof(struct virtchnl2_vport_stats , tx_errors)}}; + +#define IDPF_NB_XSTATS (sizeof(rte_idpf_stats_strings) / \ + sizeof(rte_idpf_stats_strings[0])) +static int idpf_dev_link_update (struct rte_eth_dev *dev, __rte_unused int wait_to_complete)
@@ -303,6 +327,59 @@ idpf_dev_stats_reset(struct rte_eth_dev *dev)return 0 ; } +static int idpf_dev_xstats_reset (struct rte_eth_dev *dev) +{ +idpf_dev_stats_reset (dev); +return 0 ; +} + +static int idpf_dev_xstats_get (struct rte_eth_dev *dev, +struct rte_eth_xstat *xstats,unsigned int n) +{ +struct idpf_vport *vport = + (struct idpf_vport *)dev->data->dev_private; +struct virtchnl2_vport_stats *pstats =NULL ; +unsigned int i; +int ret; + +if (n <IDPF_NB_XSTATS ) +return IDPF_NB_XSTATS ; + +if (!xstats) +return 0 ; + + ret =idpf_query_stats (vport, &pstats); +if (ret) { +PMD_DRV_LOG (ERR ,"Get statistics failed" ); +return 0 ; + } + +idpf_update_stats (&vport->eth_stats_offset, pstats); + +/* loop over xstats array and values from pstats */ +for (i =0 ; i <IDPF_NB_XSTATS ; i++) { + xstats[i].id = i; + xstats[i].value = *(uint64_t *)(((char *)pstats) + + rte_idpf_stats_strings[i].offset); + } +return IDPF_NB_XSTATS ; +} + +static int idpf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, +struct rte_eth_xstat_name *xstats_names, + __rte_unused unsigned int limit) +{ +unsigned int i; + +if (xstats_names) +for (i =0 ; i <IDPF_NB_XSTATS ; i++) { +snprintf (xstats_names[i].name, +sizeof (xstats_names[i].name), +"%s" , rte_idpf_stats_strings[i].name); + } +return IDPF_NB_XSTATS ; +} +static int idpf_config_rss_hf (struct idpf_vport *vport,uint64_t rss_hf) {uint64_t hena =0 , valid_rss_hf =0 ;
@@ -1149,6 +1226,9 @@ static const struct eth_dev_ops idpf_eth_dev_ops = { .reta_query = idpf_rss_reta_query, .rss_hash_update = idpf_rss_hash_update, .rss_hash_conf_get = idpf_rss_hash_conf_get, + .xstats_get = idpf_dev_xstats_get, + .xstats_get_names = idpf_dev_xstats_get_names, + .xstats_reset = idpf_dev_xstats_reset, }; static uint16_t
Signature · 1 line
2.25.1
PATCH 7/7 common/idpf: update mbuf_alloc_failed multi-thread process
In reply to Mingxia LiuAs the variable mbuf_alloc_failed is operated by more than thread, change it to type rte_atomic64_t and operated by rte_atomic64_xx() function, this will avoid multithreading issue.
--- drivers/common/idpf/idpf_common_rxtx.c | 10 ++++++---- drivers/common/idpf/idpf_common_rxtx.h | 2 +- drivers/common/idpf/idpf_common_rxtx_avx512.c | 12 ++++++++---- drivers/net/idpf/idpf_ethdev.c | 5 +++-- 4 files changed, 18 insertions(+), 11 deletions(-)
drivers/common/idpf/idpf_common_rxtx.c +6 -4
@@ -592,7 +592,8 @@ idpf_split_rx_bufq_refill(struct idpf_rx_queue *rx_bufq) next_avail =0 ; rx_bufq->nb_rx_hold -= delta; }else { - rx_bufq->rx_stats.mbuf_alloc_failed += nb_desc - next_avail; +rte_atomic64_add (&(rx_bufq->rx_stats.mbuf_alloc_failed), + nb_desc - next_avail);RX_LOG (DEBUG ,"RX mbuf alloc failed port_id=%u queue_id=%u" , rx_bufq->port_id, rx_bufq->queue_id);return ;
@@ -611,7 +612,8 @@ idpf_split_rx_bufq_refill(struct idpf_rx_queue *rx_bufq) next_avail += nb_refill; rx_bufq->nb_rx_hold -= nb_refill; }else { - rx_bufq->rx_stats.mbuf_alloc_failed += nb_desc - next_avail; +rte_atomic64_add (&(rx_bufq->rx_stats.mbuf_alloc_failed), + nb_desc - next_avail);RX_LOG (DEBUG ,"RX mbuf alloc failed port_id=%u queue_id=%u" , rx_bufq->port_id, rx_bufq->queue_id); }
@@ -1088,7 +1090,7 @@ idpf_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, nmb =rte_mbuf_raw_alloc (rxq->mp);if (unlikely (nmb ==NULL )) { - rxq->rx_stats.mbuf_alloc_failed++; +rte_atomic64_inc (&(rxq->rx_stats.mbuf_alloc_failed));RX_LOG (DEBUG ,"RX mbuf alloc failed port_id=%u " "queue_id=%u" , rxq->port_id, rxq->queue_id);break ;
@@ -1197,7 +1199,7 @@ idpf_singleq_recv_scatter_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, nmb =rte_mbuf_raw_alloc (rxq->mp);if (unlikely (!nmb)) { - rxq->rx_stats.mbuf_alloc_failed++; +rte_atomic64_inc (&(rxq->rx_stats.mbuf_alloc_failed));RX_LOG (DEBUG ,"RX mbuf alloc failed port_id=%u " "queue_id=%u" , rxq->port_id, rxq->queue_id);break ;
drivers/common/idpf/idpf_common_rxtx.h +1 -1
@@ -91,7 +91,7 @@#define PF_GLTSYN_SHTIME_H_5 (PF_TIMESYNC_BAR4_BASE + 0x13C)struct idpf_rx_stats { -uint64_t mbuf_alloc_failed; +rte_atomic64_t mbuf_alloc_failed; };struct idpf_rx_queue {
drivers/common/idpf/idpf_common_rxtx_avx512.c +8 -4
@@ -38,7 +38,8 @@ idpf_singleq_rearm_common(struct idpf_rx_queue *rxq) dma_addr0); } } - rxq->rx_stats.mbuf_alloc_failed +=IDPF_RXQ_REARM_THRESH ; +rte_atomic64_add (&(rxq->rx_stats.mbuf_alloc_failed), +IDPF_RXQ_REARM_THRESH );return ; }struct rte_mbuf *mb0, *mb1, *mb2, *mb3;
@@ -167,7 +168,8 @@ idpf_singleq_rearm(struct idpf_rx_queue *rxq) dma_addr0); } } - rxq->rx_stats.mbuf_alloc_failed +=IDPF_RXQ_REARM_THRESH ; +rte_atomic64_add (&(rxq->rx_stats.mbuf_alloc_failed), +IDPF_RXQ_REARM_THRESH );return ; } }
@@ -562,7 +564,8 @@ idpf_splitq_rearm_common(struct idpf_rx_queue *rx_bufq) dma_addr0); } } - rx_bufq->rx_stats.mbuf_alloc_failed +=IDPF_RXQ_REARM_THRESH ; +rte_atomic64_add (&(rx_bufq->rx_stats.mbuf_alloc_failed), +IDPF_RXQ_REARM_THRESH );return ; }
@@ -635,7 +638,8 @@ idpf_splitq_rearm(struct idpf_rx_queue *rx_bufq) dma_addr0); } } - rx_bufq->rx_stats.mbuf_alloc_failed +=IDPF_RXQ_REARM_THRESH ; +rte_atomic64_add (&(rx_bufq->rx_stats.mbuf_alloc_failed), +IDPF_RXQ_REARM_THRESH );return ; } }
drivers/net/idpf/idpf_ethdev.c +3 -2
@@ -256,7 +256,8 @@ idpf_get_mbuf_alloc_failed_stats(struct rte_eth_dev *dev)for (i =0 ; i < dev->data->nb_rx_queues; i++) { rxq = dev->data->rx_queues[i]; - mbuf_alloc_failed += rxq->rx_stats.mbuf_alloc_failed; + mbuf_alloc_failed += +rte_atomic64_read (&(rxq->rx_stats.mbuf_alloc_failed)); }return mbuf_alloc_failed;
@@ -303,7 +304,7 @@ idpf_reset_mbuf_alloc_failed_stats(struct rte_eth_dev *dev)for (i =0 ; i < dev->data->nb_rx_queues; i++) { rxq = dev->data->rx_queues[i]; - rxq->rx_stats.mbuf_alloc_failed =0 ; +rte_atomic64_set (&(rxq->rx_stats.mbuf_alloc_failed),0 ); } }
Signature · 1 line
2.25.1
cover add idpf pmd enhancement features
In reply to Mingxia LiuThis patchset add several enhancement features of idpf pmd. Including the following:
- add hw statistics, support stats/xstats ops
- add rss configure/show ops
- add event handle: link status
- add scattered data path for single queue
This patchset is based on the refactor idpf PMD code:
http://patches.dpdk.org/project/dpdk/cover/[email protected]/
http://patches.dpdk.org/project/dpdk/cover/[email protected]/
http://patches.dpdk.org/project/dpdk/cover/[email protected]/
v2 changes:
- Fix rss lut config issue.
Mingxia Liu (6):
common/idpf: add hw statistics
common/idpf: add RSS set/get ops
common/idpf: support single q scatter RX datapath common/idpf: add rss_offload hash in singleq rx common/idpf: add alarm to support handle vchnl message common/idpf: add xstats ops
drivers/common/idpf/idpf_common_device.c | 17 + drivers/common/idpf/idpf_common_device.h | 11 +- drivers/common/idpf/idpf_common_rxtx.c | 150 +++++ drivers/common/idpf/idpf_common_rxtx.h | 3 + drivers/common/idpf/idpf_common_virtchnl.c | 157 ++++- drivers/common/idpf/idpf_common_virtchnl.h | 18 +- drivers/common/idpf/version.map | 9 + drivers/net/idpf/idpf_ethdev.c | 638 ++++++++++++++++++++- drivers/net/idpf/idpf_ethdev.h | 7 +- drivers/net/idpf/idpf_rxtx.c | 26 +- drivers/net/idpf/idpf_rxtx.h | 2 + 11 files changed, 1014 insertions(+), 24 deletions(-)
Signature · 1 line
2.25.1
PATCH v2 1/6 common/idpf: add hw statistics
This patch add hardware packets/bytes statistics.
--- drivers/common/idpf/idpf_common_device.c | 17 +++++ drivers/common/idpf/idpf_common_device.h | 5 +- drivers/common/idpf/idpf_common_virtchnl.c | 27 +++++++ drivers/common/idpf/idpf_common_virtchnl.h | 3 + drivers/common/idpf/version.map | 2 + drivers/net/idpf/idpf_ethdev.c | 87 ++++++++++++++++++++++ 6 files changed, 140 insertions(+), 1 deletion(-)
drivers/common/idpf/idpf_common_device.c +17 -0
@@ -661,4 +661,21 @@ idpf_create_vport_info_init(struct idpf_vport *vport,return 0 ; } +void +idpf_update_stats (struct virtchnl2_vport_stats *oes,struct virtchnl2_vport_stats *nes) +{ + nes->rx_bytes = nes->rx_bytes - oes->rx_bytes; + nes->rx_unicast = nes->rx_unicast - oes->rx_unicast; + nes->rx_multicast = nes->rx_multicast - oes->rx_multicast; + nes->rx_broadcast = nes->rx_broadcast - oes->rx_broadcast; + nes->rx_errors = nes->rx_errors - oes->rx_errors; + nes->rx_discards = nes->rx_discards - oes->rx_discards; + nes->tx_bytes = nes->tx_bytes - oes->tx_bytes; + nes->tx_unicast = nes->tx_unicast - oes->tx_unicast; + nes->tx_multicast = nes->tx_multicast - oes->tx_multicast; + nes->tx_broadcast = nes->tx_broadcast - oes->tx_broadcast; + nes->tx_errors = nes->tx_errors - oes->tx_errors; + nes->tx_discards = nes->tx_discards - oes->tx_discards; +} +RTE_LOG_REGISTER_SUFFIX (idpf_common_logtype, common,NOTICE );
drivers/common/idpf/idpf_common_device.h +4 -1
@@ -112,6 +112,8 @@ struct idpf_vport {bool tx_vec_allowed;bool rx_use_avx512;bool tx_use_avx512; + +struct virtchnl2_vport_stats eth_stats_offset; };/* Message type read in virtual channel from PF */
@@ -188,5 +190,6 @@ int idpf_config_irq_unmap(struct idpf_vport *vport, uint16_t nb_rx_queues);__rte_internal int idpf_create_vport_info_init(struct idpf_vport *vport,struct virtchnl2_create_vport *vport_info); - +__rte_internal +void idpf_update_stats(struct virtchnl2_vport_stats *oes, struct virtchnl2_vport_stats *nes);#endif /* _IDPF_COMMON_DEVICE_H_ */
drivers/common/idpf/idpf_common_virtchnl.c +27 -0
@@ -217,6 +217,7 @@ idpf_execute_vc_cmd(struct idpf_adapter *adapter, struct idpf_cmd_info *args)case VIRTCHNL2_OP_UNMAP_QUEUE_VECTOR :case VIRTCHNL2_OP_ALLOC_VECTORS :case VIRTCHNL2_OP_DEALLOC_VECTORS : +case VIRTCHNL2_OP_GET_STATS :/* for init virtchnl ops, need to poll the response */ err =idpf_read_one_msg (adapter, args->ops, args->out_size, args->out_buffer);clear_cmd (adapter);
@@ -806,6 +807,32 @@ idpf_vc_query_ptype_info(struct idpf_adapter *adapter)return err; } +int +idpf_query_stats (struct idpf_vport *vport, +struct virtchnl2_vport_stats **pstats) +{ +struct idpf_adapter *adapter = vport->adapter; +struct virtchnl2_vport_stats vport_stats; +struct idpf_cmd_info args; +int err; + + vport_stats.vport_id = vport->vport_id; + args.ops =VIRTCHNL2_OP_GET_STATS ; + args.in_args = (u8 *)&vport_stats; + args.in_args_size =sizeof (vport_stats); + args.out_buffer = adapter->mbx_resp; + args.out_size =IDPF_DFLT_MBX_BUF_SIZE ; + + err =idpf_execute_vc_cmd (adapter, &args); +if (err) { +DRV_LOG (ERR ,"Failed to execute command of VIRTCHNL2_OP_GET_STATS" ); + *pstats =NULL ; +return err; + } + *pstats = (struct virtchnl2_vport_stats *)args.out_buffer; +return 0 ; +} +#define IDPF_RX_BUF_STRIDE 64int idpf_vc_config_rxq (struct idpf_vport *vport,struct idpf_rx_queue *rxq)
drivers/common/idpf/idpf_common_virtchnl.h +3 -0
@@ -38,4 +38,7 @@ __rte_internalint idpf_vc_config_rxq (struct idpf_vport *vport,struct idpf_rx_queue *rxq);__rte_internal int idpf_vc_config_txq(struct idpf_vport *vport, struct idpf_tx_queue *txq); +__rte_internal +int idpf_query_stats(struct idpf_vport *vport, +struct virtchnl2_vport_stats **pstats);#endif /* _IDPF_COMMON_VIRTCHNL_H_ */
drivers/common/idpf/version.map +2 -0
@@ -50,6 +50,8 @@ INTERNAL { idpf_splitq_recv_pkts_avx512; idpf_singleq_xmit_pkts_avx512; idpf_splitq_xmit_pkts_avx512; + idpf_update_stats; + idpf_query_stats; local: *; };
drivers/net/idpf/idpf_ethdev.c +87 -0
105 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v2 2/6 common/idpf: add RSS set/get ops
In reply to Mingxia LiuAdd support for these device ops:
- rss_reta_update
- rss_reta_query
- rss_hash_update
- rss_hash_conf_get
--- drivers/common/idpf/idpf_common_device.h | 1 + drivers/common/idpf/idpf_common_virtchnl.c | 119 ++++++++ drivers/common/idpf/idpf_common_virtchnl.h | 15 +- drivers/common/idpf/version.map | 6 + drivers/net/idpf/idpf_ethdev.c | 303 +++++++++++++++++++++ drivers/net/idpf/idpf_ethdev.h | 5 +- 6 files changed, 445 insertions(+), 4 deletions(-)
drivers/common/idpf/idpf_common_device.h +1 -0
@@ -95,6 +95,7 @@ struct idpf_vport {uint32_t *rss_lut;uint8_t *rss_key;uint64_t rss_hf; +uint64_t last_general_rss_hf;/* MSIX info*/ struct virtchnl2_queue_vector *qv_map;/* queue vector mapping */
drivers/common/idpf/idpf_common_virtchnl.c +119 -0
143 lines not on this page · raw message
drivers/common/idpf/idpf_common_virtchnl.h +12 -3
@@ -13,9 +13,6 @@ int idpf_vc_get_caps(struct idpf_adapter *adapter);int idpf_vc_create_vport (struct idpf_vport *vport,struct virtchnl2_create_vport *vport_info);int idpf_vc_destroy_vport (struct idpf_vport *vport); -int idpf_vc_set_rss_key (struct idpf_vport *vport); -int idpf_vc_set_rss_lut (struct idpf_vport *vport); -int idpf_vc_set_rss_hash (struct idpf_vport *vport);int idpf_vc_config_irq_map_unmap (struct idpf_vport *vport,uint16_t nb_rxq,bool map);int idpf_vc_query_ptype_info (struct idpf_adapter *adapter);
@@ -41,4 +38,16 @@ int idpf_vc_config_txq(struct idpf_vport *vport, struct idpf_tx_queue *txq);__rte_internal int idpf_query_stats(struct idpf_vport *vport,struct virtchnl2_vport_stats **pstats); +__rte_internal +int idpf_vc_set_rss_key(struct idpf_vport *vport); +__rte_internal +int idpf_vc_get_rss_key(struct idpf_vport *vport); +__rte_internal +int idpf_vc_set_rss_lut(struct idpf_vport *vport); +__rte_internal +int idpf_vc_get_rss_lut(struct idpf_vport *vport); +__rte_internal +int idpf_vc_set_rss_hash(struct idpf_vport *vport); +__rte_internal +int idpf_vc_get_rss_hash(struct idpf_vport *vport);#endif /* _IDPF_COMMON_VIRTCHNL_H_ */
drivers/common/idpf/version.map +6 -0
@@ -52,6 +52,12 @@ INTERNAL { idpf_splitq_xmit_pkts_avx512; idpf_update_stats; idpf_query_stats; + idpf_vc_set_rss_key; + idpf_vc_get_rss_key; + idpf_vc_set_rss_lut; + idpf_vc_get_rss_lut; + idpf_vc_set_rss_hash; + idpf_vc_get_rss_hash; local: *; };
drivers/net/idpf/idpf_ethdev.c +303 -0
333 lines not on this page · raw message
drivers/net/idpf/idpf_ethdev.h +4 -1
@@ -48,7 +48,10 @@ RTE_ETH_RSS_NONFRAG_IPV6_TCP | \ RTE_ETH_RSS_NONFRAG_IPV6_UDP | \ RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \ - RTE_ETH_RSS_NONFRAG_IPV6_OTHER) + RTE_ETH_RSS_NONFRAG_IPV6_OTHER | \ + RTE_ETH_RSS_L2_PAYLOAD) + +#define IDPF_RSS_KEY_LEN 52#define IDPF_ADAPTER_NAME_LEN (PCI_PRI_STR_SIZE + 1)
Signature · 1 line
2.25.1
PATCH v2 3/6 common/idpf: support single q scatter RX datapath
In reply to Mingxia LiuThis patch add single q recv scatter rx function.
--- drivers/common/idpf/idpf_common_rxtx.c | 134 +++++++++++++++++++++++++ drivers/common/idpf/idpf_common_rxtx.h | 3 + drivers/common/idpf/version.map | 1 + drivers/net/idpf/idpf_ethdev.c | 3 +- drivers/net/idpf/idpf_rxtx.c | 26 ++++- drivers/net/idpf/idpf_rxtx.h | 2 + 6 files changed, 166 insertions(+), 3 deletions(-)
drivers/common/idpf/idpf_common_rxtx.c +134 -0
@@ -1146,6 +1146,140 @@ idpf_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,return nb_rx; } +uint16_t +idpf_singleq_recv_scatter_pkts (void *rx_queue,struct rte_mbuf **rx_pkts, +uint16_t nb_pkts) +{ +struct idpf_rx_queue *rxq = rx_queue; +volatile union virtchnl2_rx_desc *rx_ring = rxq->rx_ring; +volatile union virtchnl2_rx_desc *rxdp; +union virtchnl2_rx_desc rxd; +struct idpf_adapter *ad; +struct rte_mbuf *first_seg = rxq->pkt_first_seg; +struct rte_mbuf *last_seg = rxq->pkt_last_seg; +struct rte_mbuf *rxm; +struct rte_mbuf *nmb; +struct rte_eth_dev *dev; +const uint32_t *ptype_tbl = rxq->adapter->ptype_tbl; +uint16_t nb_hold =0 , nb_rx =0 ; +uint16_t rx_id = rxq->rx_tail; +uint16_t rx_packet_len; +uint16_t rx_status0; +uint64_t pkt_flags; +uint64_t dma_addr; +uint64_t ts_ns; + + ad = rxq->adapter; + +if (unlikely (!rxq) ||unlikely (!rxq->q_started)) +return nb_rx; + +while (nb_rx < nb_pkts) { + rxdp = &rx_ring[rx_id]; + rx_status0 =rte_le_to_cpu_16 (rxdp->flex_nic_wb.status_error0); + +/* Check the DD bit first */ +if (!(rx_status0 & (1 <<VIRTCHNL2_RX_FLEX_DESC_STATUS0_DD_S ))) +break ; + + nmb =rte_mbuf_raw_alloc (rxq->mp); +if (unlikely (!nmb)) { +rte_atomic64_inc (&(rxq->rx_stats.mbuf_alloc_failed)); +RX_LOG (DEBUG ,"RX mbuf alloc failed port_id=%u " +"queue_id=%u" , rxq->port_id, rxq->queue_id); +break ; + } + + rxd = *rxdp; + + nb_hold++; + rxm = rxq->sw_ring[rx_id]; + rxq->sw_ring[rx_id] = nmb; + rx_id++; +if (unlikely (rx_id == rxq->nb_rx_desc)) + rx_id =0 ; + +/* Prefetch next mbuf */ +rte_prefetch0 (rxq->sw_ring[rx_id]); + +/* When next RX descriptor is on a cache line boundary, +* prefetch the next 4 RX descriptors and next 8 pointers +* to mbufs. +*/ +if ((rx_id &0x3 ) ==0 ) { +rte_prefetch0 (&rx_ring[rx_id]); +rte_prefetch0 (rxq->sw_ring[rx_id]); + } + dma_addr = +rte_cpu_to_le_64 (rte_mbuf_data_iova_default (nmb)); + rxdp->read.hdr_addr =0 ; + rxdp->read.pkt_addr = dma_addr; + rx_packet_len = (rte_cpu_to_le_16 (rxd.flex_nic_wb.pkt_len) & +VIRTCHNL2_RX_FLEX_DESC_PKT_LEN_M ); + rxm->data_len = rx_packet_len; + rxm->data_off =RTE_PKTMBUF_HEADROOM ; + +/** +* If this is the first buffer of the received packet, set the +* pointer to the first mbuf of the packet and initialize its +* context. Otherwise, update the total length and the number +* of segments of the current scattered packet, and update the +* pointer to the last mbuf of the current packet. +*/ +if (!first_seg) { + first_seg = rxm; + first_seg->nb_segs =1 ; + first_seg->pkt_len = rx_packet_len; + }else { + first_seg->pkt_len = + (uint16_t )(first_seg->pkt_len + + rx_packet_len); + first_seg->nb_segs++; + last_seg->next = rxm; + } + +if (!(rx_status0 & (1 <<VIRTCHNL2_RX_FLEX_DESC_STATUS0_EOF_S ))) { + last_seg = rxm; +continue ; + } + + rxm->next =NULL ; + + first_seg->port = rxq->port_id; + first_seg->ol_flags =0 ; + pkt_flags =idpf_rxd_to_pkt_flags (rx_status0); + first_seg->packet_type = + ptype_tbl[(uint8_t )(rte_cpu_to_le_16 (rxd.flex_nic_wb.ptype_flex_flags0) & +VIRTCHNL2_RX_FLEX_DESC_PTYPE_M )]; + +if (idpf_timestamp_dynflag >0 && + (rxq->offloads &IDPF_RX_OFFLOAD_TIMESTAMP ) !=0 ) { +/* timestamp */ + ts_ns =idpf_tstamp_convert_32b_64b (ad, + rxq->hw_register_set, +rte_le_to_cpu_32 (rxd.flex_nic_wb.flex_ts.ts_high)); + rxq->hw_register_set =0 ; + *RTE_MBUF_DYNFIELD (rxm, + idpf_timestamp_dynfield_offset, + rte_mbuf_timestamp_t *) = ts_ns; + first_seg->ol_flags |= idpf_timestamp_dynflag; + } + + first_seg->ol_flags |= pkt_flags; +rte_prefetch0 (RTE_PTR_ADD (first_seg->buf_addr, + first_seg->data_off)); + rx_pkts[nb_rx++] = first_seg; + first_seg =NULL ; + } + rxq->rx_tail = rx_id; + rxq->pkt_first_seg = first_seg; + rxq->pkt_last_seg = last_seg; + +idpf_update_rx_tail (rxq, nb_hold, rx_id); + +return nb_rx; +} +static inline int idpf_xmit_cleanup (struct idpf_tx_queue *txq) {
drivers/common/idpf/idpf_common_rxtx.h +3 -0
@@ -260,6 +260,9 @@ __rte_internaluint16_t idpf_splitq_recv_pkts (void *rx_queue,struct rte_mbuf **rx_pkts,uint16_t nb_pkts);__rte_internal +uint16_t idpf_singleq_recv_scatter_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, +uint16_t nb_pkts); +__rte_internal uint16_t idpf_splitq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,uint16_t nb_pkts); __rte_internal
drivers/common/idpf/version.map +1 -0
@@ -41,6 +41,7 @@ INTERNAL { idpf_splitq_recv_pkts; idpf_splitq_xmit_pkts; idpf_singleq_recv_pkts; + idpf_singleq_recv_scatter_pkts; idpf_singleq_xmit_pkts; idpf_prep_pkts; idpf_singleq_rx_vec_setup;
drivers/net/idpf/idpf_ethdev.c +2 -1
@@ -119,7 +119,8 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)RTE_ETH_RX_OFFLOAD_UDP_CKSUM |RTE_ETH_RX_OFFLOAD_TCP_CKSUM |RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM | -RTE_ETH_RX_OFFLOAD_TIMESTAMP ; +RTE_ETH_RX_OFFLOAD_TIMESTAMP | +RTE_ETH_RX_OFFLOAD_SCATTER ; dev_info->tx_offload_capa = RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
drivers/net/idpf/idpf_rxtx.c +24 -2
@@ -503,6 +503,8 @@ int idpf_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id) {struct idpf_rx_queue *rxq; +uint16_t max_pkt_len; +uint32_t frame_size;int err;if (rx_queue_id >= dev->data->nb_rx_queues)
@@ -516,6 +518,17 @@ idpf_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id)return -EINVAL ; } + frame_size = dev->data->mtu +IDPF_ETH_OVERHEAD ; + + max_pkt_len = +RTE_MIN ((uint32_t )IDPF_SUPPORT_CHAIN_NUM * rxq->rx_buf_len, + frame_size); + + rxq->max_pkt_len = max_pkt_len; +if ((dev->data->dev_conf.rxmode.offloads &RTE_ETH_RX_OFFLOAD_SCATTER ) || + frame_size > rxq->rx_buf_len) + dev->data->scattered_rx =1 ; + err =idpf_register_ts_mbuf (rxq);if (err !=0 ) { PMD_DRV_LOG(ERR, "fail to regidter timestamp mbuf %u",
@@ -801,13 +814,22 @@ idpf_set_rx_function(struct rte_eth_dev *dev) #endif /* CC_AVX512_SUPPORT */ } +if (dev->data->scattered_rx) { + dev->rx_pkt_burst = idpf_singleq_recv_scatter_pkts; +return ; + } dev->rx_pkt_burst = idpf_singleq_recv_pkts; }#else -if (vport->rxq_model ==VIRTCHNL2_QUEUE_MODEL_SPLIT ) +if (vport->rxq_model ==VIRTCHNL2_QUEUE_MODEL_SPLIT ) { dev->rx_pkt_burst = idpf_splitq_recv_pkts; -else + }else { +if (dev->data->scattered_rx) { + dev->rx_pkt_burst = idpf_singleq_recv_scatter_pkts; +return ; + } dev->rx_pkt_burst = idpf_singleq_recv_pkts; + }#endif /* RTE_ARCH_X86 */ }
drivers/net/idpf/idpf_rxtx.h +2 -0
@@ -23,6 +23,8 @@#define IDPF_DEFAULT_TX_RS_THRESH 32#define IDPF_DEFAULT_TX_FREE_THRESH 32 +#define IDPF_SUPPORT_CHAIN_NUM 5 + int idpf_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, uint16_t nb_desc, unsigned int socket_id, const struct rte_eth_rxconf *rx_conf,
Signature · 1 line
2.25.1
PATCH v2 4/6 common/idpf: add rss_offload hash in singleq rx
In reply to Mingxia LiuThis patch add rss valid flag and hash value parsing of rx descriptor.
--- drivers/common/idpf/idpf_common_rxtx.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/common/idpf/idpf_common_rxtx.c +16 -0
@@ -1030,6 +1030,20 @@ idpf_update_rx_tail(struct idpf_rx_queue *rxq, uint16_t nb_hold, rxq->nb_rx_hold = nb_hold; } +static inline void +idpf_singleq_rx_rss_offload (struct rte_mbuf *mb, +volatile struct virtchnl2_rx_flex_desc_nic *rx_desc, +uint64_t *pkt_flags) +{ +uint16_t rx_status0 =rte_le_to_cpu_16 (rx_desc->status_error0); + +if (rx_status0 &RTE_BIT32 (VIRTCHNL2_RX_FLEX_DESC_STATUS0_RSS_VALID_S )) { + *pkt_flags |=RTE_MBUF_F_RX_RSS_HASH ; + mb->hash.rss =rte_le_to_cpu_32 (rx_desc->rss_hash); + } + +} +uint16_t idpf_singleq_recv_pkts (void *rx_queue,struct rte_mbuf **rx_pkts,uint16_t nb_pkts)
@@ -1118,6 +1132,7 @@ idpf_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, rxm->port = rxq->port_id; rxm->ol_flags =0 ; pkt_flags =idpf_rxd_to_pkt_flags (rx_status0); +idpf_singleq_rx_rss_offload (rxm, &rxd.flex_nic_wb, &pkt_flags); rxm->packet_type = ptype_tbl[(uint8_t )(rte_cpu_to_le_16 (rxd.flex_nic_wb.ptype_flex_flags0) &VIRTCHNL2_RX_FLEX_DESC_PTYPE_M )];
@@ -1248,6 +1263,7 @@ idpf_singleq_recv_scatter_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, first_seg->port = rxq->port_id; first_seg->ol_flags =0 ; pkt_flags =idpf_rxd_to_pkt_flags (rx_status0); +idpf_singleq_rx_rss_offload (first_seg, &rxd.flex_nic_wb, &pkt_flags); first_seg->packet_type = ptype_tbl[(uint8_t )(rte_cpu_to_le_16 (rxd.flex_nic_wb.ptype_flex_flags0) &VIRTCHNL2_RX_FLEX_DESC_PTYPE_M )];
Signature · 1 line
2.25.1
PATCH v2 5/6 common/idpf: add alarm to support handle vchnl message
In reply to Mingxia LiuHandle virtual channel message.
Refine link status update.
--- drivers/common/idpf/idpf_common_device.h | 5 + drivers/common/idpf/idpf_common_virtchnl.c | 19 --- drivers/net/idpf/idpf_ethdev.c | 165 ++++++++++++++++++++- drivers/net/idpf/idpf_ethdev.h | 2 + 4 files changed, 171 insertions(+), 20 deletions(-)
drivers/common/idpf/idpf_common_device.h +5 -0
@@ -115,6 +115,11 @@ struct idpf_vport {bool tx_use_avx512;struct virtchnl2_vport_stats eth_stats_offset; + +void *dev; +/* Event from ipf */ +bool link_up; +uint32_t link_speed; };/* Message type read in virtual channel from PF */
drivers/common/idpf/idpf_common_virtchnl.c +0 -19
@@ -202,25 +202,6 @@ idpf_execute_vc_cmd(struct idpf_adapter *adapter, struct idpf_cmd_info *args)switch (args->ops) {case VIRTCHNL_OP_VERSION :case VIRTCHNL2_OP_GET_CAPS : -case VIRTCHNL2_OP_CREATE_VPORT : -case VIRTCHNL2_OP_DESTROY_VPORT : -case VIRTCHNL2_OP_SET_RSS_KEY : -case VIRTCHNL2_OP_SET_RSS_LUT : -case VIRTCHNL2_OP_SET_RSS_HASH : -case VIRTCHNL2_OP_CONFIG_RX_QUEUES : -case VIRTCHNL2_OP_CONFIG_TX_QUEUES : -case VIRTCHNL2_OP_ENABLE_QUEUES : -case VIRTCHNL2_OP_DISABLE_QUEUES : -case VIRTCHNL2_OP_ENABLE_VPORT : -case VIRTCHNL2_OP_DISABLE_VPORT : -case VIRTCHNL2_OP_MAP_QUEUE_VECTOR : -case VIRTCHNL2_OP_UNMAP_QUEUE_VECTOR : -case VIRTCHNL2_OP_ALLOC_VECTORS : -case VIRTCHNL2_OP_DEALLOC_VECTORS : -case VIRTCHNL2_OP_GET_STATS : -case VIRTCHNL2_OP_GET_RSS_KEY : -case VIRTCHNL2_OP_GET_RSS_HASH : -case VIRTCHNL2_OP_GET_RSS_LUT :/* for init virtchnl ops, need to poll the response */ err =idpf_read_one_msg (adapter, args->ops, args->out_size, args->out_buffer);clear_cmd (adapter);
drivers/net/idpf/idpf_ethdev.c +164 -1
206 lines not on this page · raw message
drivers/net/idpf/idpf_ethdev.h +2 -0
@@ -55,6 +55,8 @@#define IDPF_ADAPTER_NAME_LEN (PCI_PRI_STR_SIZE + 1) +#define IDPF_ALARM_INTERVAL 50000/* us */ +struct idpf_vport_param {struct idpf_adapter_ext *adapter;uint16_t devarg_id;/* arg id from user */
Signature · 1 line
2.25.1
PATCH v2 6/6 common/idpf: add xstats ops
In reply to Mingxia LiuAdd support for these device ops:
-idpf_dev_xstats_get
-idpf_dev_xstats_get_names
-idpf_dev_xstats_reset
--- drivers/net/idpf/idpf_ethdev.c | 80 ++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+)
drivers/net/idpf/idpf_ethdev.c +80 -0
@@ -80,6 +80,30 @@ static const uint64_t idpf_ipv6_rss = RTE_ETH_RSS_NONFRAG_IPV6_UDP |RTE_ETH_RSS_NONFRAG_IPV6_OTHER |RTE_ETH_RSS_FRAG_IPV6 ; +struct rte_idpf_xstats_name_off { +char name[RTE_ETH_XSTATS_NAME_SIZE ]; +unsigned int offset; +}; + +static const struct rte_idpf_xstats_name_off rte_idpf_stats_strings[] = { + {"rx_bytes" , offsetof(struct virtchnl2_vport_stats , rx_bytes)}, + {"rx_unicast_packets" , offsetof(struct virtchnl2_vport_stats , rx_unicast)}, + {"rx_multicast_packets" , offsetof(struct virtchnl2_vport_stats , rx_multicast)}, + {"rx_broadcast_packets" , offsetof(struct virtchnl2_vport_stats , rx_broadcast)}, + {"rx_dropped_packets" , offsetof(struct virtchnl2_vport_stats , rx_discards)}, + {"rx_errors" , offsetof(struct virtchnl2_vport_stats , rx_errors)}, + {"rx_unknown_protocol_packets" , offsetof(struct virtchnl2_vport_stats , + rx_unknown_protocol)}, + {"tx_bytes" , offsetof(struct virtchnl2_vport_stats , tx_bytes)}, + {"tx_unicast_packets" , offsetof(struct virtchnl2_vport_stats , tx_unicast)}, + {"tx_multicast_packets" , offsetof(struct virtchnl2_vport_stats , tx_multicast)}, + {"tx_broadcast_packets" , offsetof(struct virtchnl2_vport_stats , tx_broadcast)}, + {"tx_dropped_packets" , offsetof(struct virtchnl2_vport_stats , tx_discards)}, + {"tx_error_packets" , offsetof(struct virtchnl2_vport_stats , tx_errors)}}; + +#define IDPF_NB_XSTATS (sizeof(rte_idpf_stats_strings) / \ + sizeof(rte_idpf_stats_strings[0])) +static int idpf_dev_link_update (struct rte_eth_dev *dev, __rte_unused int wait_to_complete)
@@ -312,6 +336,59 @@ idpf_dev_stats_reset(struct rte_eth_dev *dev)return 0 ; } +static int idpf_dev_xstats_reset (struct rte_eth_dev *dev) +{ +idpf_dev_stats_reset (dev); +return 0 ; +} + +static int idpf_dev_xstats_get (struct rte_eth_dev *dev, +struct rte_eth_xstat *xstats,unsigned int n) +{ +struct idpf_vport *vport = + (struct idpf_vport *)dev->data->dev_private; +struct virtchnl2_vport_stats *pstats =NULL ; +unsigned int i; +int ret; + +if (n <IDPF_NB_XSTATS ) +return IDPF_NB_XSTATS ; + +if (!xstats) +return 0 ; + + ret =idpf_query_stats (vport, &pstats); +if (ret) { +PMD_DRV_LOG (ERR ,"Get statistics failed" ); +return 0 ; + } + +idpf_update_stats (&vport->eth_stats_offset, pstats); + +/* loop over xstats array and values from pstats */ +for (i =0 ; i <IDPF_NB_XSTATS ; i++) { + xstats[i].id = i; + xstats[i].value = *(uint64_t *)(((char *)pstats) + + rte_idpf_stats_strings[i].offset); + } +return IDPF_NB_XSTATS ; +} + +static int idpf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, +struct rte_eth_xstat_name *xstats_names, + __rte_unused unsigned int limit) +{ +unsigned int i; + +if (xstats_names) +for (i =0 ; i <IDPF_NB_XSTATS ; i++) { +snprintf (xstats_names[i].name, +sizeof (xstats_names[i].name), +"%s" , rte_idpf_stats_strings[i].name); + } +return IDPF_NB_XSTATS ; +} +static int idpf_config_rss_hf (struct idpf_vport *vport,uint64_t rss_hf) {uint64_t hena =0 , valid_rss_hf =0 ;
@@ -1158,6 +1235,9 @@ static const struct eth_dev_ops idpf_eth_dev_ops = { .reta_query = idpf_rss_reta_query, .rss_hash_update = idpf_rss_hash_update, .rss_hash_conf_get = idpf_rss_hash_conf_get, + .xstats_get = idpf_dev_xstats_get, + .xstats_get_names = idpf_dev_xstats_get_names, + .xstats_reset = idpf_dev_xstats_reset, }; static uint16_t
Signature · 1 line
2.25.1
v3 cover add idpf pmd enhancement features
In reply to Mingxia LiuThis patchset add several enhancement features of idpf pmd. Including the following:
- add hw statistics, support stats/xstats ops
- add rss configure/show ops
- add event handle: link status
- add scattered data path for single queue
This patchset is based on the refactor idpf PMD code:
http://patches.dpdk.org/project/dpdk/cover/[email protected]/
http://patches.dpdk.org/project/dpdk/cover/[email protected]/
http://patches.dpdk.org/project/dpdk/cover/[email protected]/
v2 changes:
- Fix rss lut config issue.
v2 changes:
- rebase to the new baseline.
Mingxia Liu (6):
common/idpf: add hw statistics
common/idpf: add RSS set/get ops
common/idpf: support single q scatter RX datapath common/idpf: add rss_offload hash in singleq rx common/idpf: add alarm to support handle vchnl message common/idpf: add xstats ops
drivers/common/idpf/idpf_common_device.c | 17 + drivers/common/idpf/idpf_common_device.h | 11 +- drivers/common/idpf/idpf_common_rxtx.c | 150 +++++ drivers/common/idpf/idpf_common_rxtx.h | 3 + drivers/common/idpf/idpf_common_virtchnl.c | 157 ++++- drivers/common/idpf/idpf_common_virtchnl.h | 9 + drivers/common/idpf/version.map | 6 + drivers/net/idpf/idpf_ethdev.c | 638 ++++++++++++++++++++- drivers/net/idpf/idpf_ethdev.h | 5 +- drivers/net/idpf/idpf_rxtx.c | 26 +- drivers/net/idpf/idpf_rxtx.h | 2 + 11 files changed, 1003 insertions(+), 21 deletions(-)
Signature · 1 line
2.25.1
PATCH v3 1/6 common/idpf: add hw statistics
This patch add hardware packets/bytes statistics.
--- drivers/common/idpf/idpf_common_device.c | 17 +++++ drivers/common/idpf/idpf_common_device.h | 5 +- drivers/common/idpf/idpf_common_virtchnl.c | 27 +++++++ drivers/common/idpf/idpf_common_virtchnl.h | 3 + drivers/common/idpf/version.map | 2 + drivers/net/idpf/idpf_ethdev.c | 87 ++++++++++++++++++++++ 6 files changed, 140 insertions(+), 1 deletion(-)
drivers/common/idpf/idpf_common_device.c +17 -0
@@ -648,4 +648,21 @@ idpf_create_vport_info_init(struct idpf_vport *vport,return 0 ; } +void +idpf_update_stats (struct virtchnl2_vport_stats *oes,struct virtchnl2_vport_stats *nes) +{ + nes->rx_bytes = nes->rx_bytes - oes->rx_bytes; + nes->rx_unicast = nes->rx_unicast - oes->rx_unicast; + nes->rx_multicast = nes->rx_multicast - oes->rx_multicast; + nes->rx_broadcast = nes->rx_broadcast - oes->rx_broadcast; + nes->rx_errors = nes->rx_errors - oes->rx_errors; + nes->rx_discards = nes->rx_discards - oes->rx_discards; + nes->tx_bytes = nes->tx_bytes - oes->tx_bytes; + nes->tx_unicast = nes->tx_unicast - oes->tx_unicast; + nes->tx_multicast = nes->tx_multicast - oes->tx_multicast; + nes->tx_broadcast = nes->tx_broadcast - oes->tx_broadcast; + nes->tx_errors = nes->tx_errors - oes->tx_errors; + nes->tx_discards = nes->tx_discards - oes->tx_discards; +} +RTE_LOG_REGISTER_SUFFIX (idpf_common_logtype, common,NOTICE );
drivers/common/idpf/idpf_common_device.h +4 -1
@@ -115,6 +115,8 @@ struct idpf_vport {bool tx_vec_allowed;bool rx_use_avx512;bool tx_use_avx512; + +struct virtchnl2_vport_stats eth_stats_offset; };/* Message type read in virtual channel from PF */
@@ -191,5 +193,6 @@ int idpf_config_irq_unmap(struct idpf_vport *vport, uint16_t nb_rx_queues);__rte_internal int idpf_create_vport_info_init(struct idpf_vport *vport,struct virtchnl2_create_vport *vport_info); - +__rte_internal +void idpf_update_stats(struct virtchnl2_vport_stats *oes, struct virtchnl2_vport_stats *nes);#endif /* _IDPF_COMMON_DEVICE_H_ */
drivers/common/idpf/idpf_common_virtchnl.c +27 -0
@@ -217,6 +217,7 @@ idpf_execute_vc_cmd(struct idpf_adapter *adapter, struct idpf_cmd_info *args)case VIRTCHNL2_OP_UNMAP_QUEUE_VECTOR :case VIRTCHNL2_OP_ALLOC_VECTORS :case VIRTCHNL2_OP_DEALLOC_VECTORS : +case VIRTCHNL2_OP_GET_STATS :/* for init virtchnl ops, need to poll the response */ err =idpf_read_one_msg (adapter, args->ops, args->out_size, args->out_buffer);clear_cmd (adapter);
@@ -806,6 +807,32 @@ idpf_vc_query_ptype_info(struct idpf_adapter *adapter)return err; } +int +idpf_query_stats (struct idpf_vport *vport, +struct virtchnl2_vport_stats **pstats) +{ +struct idpf_adapter *adapter = vport->adapter; +struct virtchnl2_vport_stats vport_stats; +struct idpf_cmd_info args; +int err; + + vport_stats.vport_id = vport->vport_id; + args.ops =VIRTCHNL2_OP_GET_STATS ; + args.in_args = (u8 *)&vport_stats; + args.in_args_size =sizeof (vport_stats); + args.out_buffer = adapter->mbx_resp; + args.out_size =IDPF_DFLT_MBX_BUF_SIZE ; + + err =idpf_execute_vc_cmd (adapter, &args); +if (err) { +DRV_LOG (ERR ,"Failed to execute command of VIRTCHNL2_OP_GET_STATS" ); + *pstats =NULL ; +return err; + } + *pstats = (struct virtchnl2_vport_stats *)args.out_buffer; +return 0 ; +} +#define IDPF_RX_BUF_STRIDE 64int idpf_vc_config_rxq (struct idpf_vport *vport,struct idpf_rx_queue *rxq)
drivers/common/idpf/idpf_common_virtchnl.h +3 -0
@@ -49,4 +49,7 @@ __rte_internalint idpf_vc_config_rxq (struct idpf_vport *vport,struct idpf_rx_queue *rxq);__rte_internal int idpf_vc_config_txq(struct idpf_vport *vport, struct idpf_tx_queue *txq); +__rte_internal +int idpf_query_stats(struct idpf_vport *vport, +struct virtchnl2_vport_stats **pstats);#endif /* _IDPF_COMMON_VIRTCHNL_H_ */
drivers/common/idpf/version.map +2 -0
@@ -44,6 +44,8 @@ INTERNAL { idpf_splitq_xmit_pkts_avx512; idpf_switch_queue; idpf_tx_queue_release; + idpf_update_stats; + idpf_query_stats; idpf_vc_alloc_vectors; idpf_vc_check_api_version; idpf_vc_config_irq_map_unmap;
drivers/net/idpf/idpf_ethdev.c +87 -0
105 lines not on this page · raw message
Signature · 1 line
2.25.1
RE: [PATCH v3 1/6] common/idpf: add hw statistics
drivers/net/idpf/idpf_ethdev.c idpf_dev_start(struct rte_eth_dev *dev) · line 412
Quoted 7 lines
drivers/net/idpf/idpf_ethdev.c +3
-0@@ -327,6 +407,11 @@ idpf_dev_start(struct rte_eth_dev *dev) goto err_vport; } +if (idpf_dev_stats_reset (dev)) { +PMD_DRV_LOG (ERR ,"Failed to reset stats" ); + goto err_vport;
If stats reset fails, will block the start process and roll back? I think print ERR may be enough.
Quoted 16 lines
drivers/net/idpf/idpf_ethdev.c +4
-1+ } + vport->stopped =0 ;return 0 ;@@ -606,6 +691,8 @@ static const struct eth_dev_ops idpf_eth_dev_ops = { .tx_queue_release = idpf_dev_tx_queue_release, .mtu_set = idpf_dev_mtu_set, .dev_supported_ptypes_get = idpf_dev_supported_ptypes_get, + .stats_get = idpf_dev_stats_get, + .stats_reset = idpf_dev_stats_reset, }; static uint16_t --2.25.1
RE: [PATCH v3 1/6] common/idpf: add hw statistics
Quoted 13 lines
-----Original Message-----
From: Wu, Jingjing <[email protected]>
Sent: Wednesday, February 1, 2023 4:49 PM
To: Liu, Mingxia <[email protected]>; [email protected]
Cc: Xing, Beilei <[email protected]>
Subject: RE: [PATCH v3 1/6] common/idpf: add hw statisticsQuoted 4 lines
drivers/net/idpf/idpf_ethdev.c +0
-0@@ -327,6 +407,11 @@ idpf_dev_start(struct rte_eth_dev *dev) goto err_vport; }
Quoted 7 lines
drivers/net/idpf/idpf_ethdev.c idpf_dev_start(struct rte_eth_dev *dev) · line 412
Quoted 3 lines
drivers/net/idpf/idpf_ethdev.c +3
-0+if (idpf_dev_stats_reset (dev)) { +PMD_DRV_LOG (ERR ,"Failed to reset stats" ); + goto err_vport;If stats reset fails, will block the start process and roll back? I think print ERR may be enough.
[Liu, Mingxia] Good idea, I'll delete the error process of rolling back.
Quoted 17 lines
drivers/net/idpf/idpf_ethdev.c static const struct eth_dev_ops idpf_eth_dev_ops
Quoted 6 lines
drivers/net/idpf/idpf_ethdev.c +2
-0+ } + vport->stopped =0 ;return 0 ;@@ -606,6 +691,8 @@ static const struct eth_dev_ops idpf_eth_dev_ops= {
Quoted 10 lines
drivers/net/idpf/idpf_ethdev.c +2
-1.tx_queue_release = idpf_dev_tx_queue_release, .mtu_set = idpf_dev_mtu_set, .dev_supported_ptypes_get = idpf_dev_supported_ptypes_get, + .stats_get = idpf_dev_stats_get, + .stats_reset = idpf_dev_stats_reset, }; static uint16_t --2.25.1
PATCH v3 2/6 common/idpf: add RSS set/get ops
In reply to Mingxia LiuAdd support for these device ops:
- rss_reta_update
- rss_reta_query
- rss_hash_update
- rss_hash_conf_get
--- drivers/common/idpf/idpf_common_device.h | 1 + drivers/common/idpf/idpf_common_virtchnl.c | 119 ++++++++ drivers/common/idpf/idpf_common_virtchnl.h | 6 + drivers/common/idpf/version.map | 3 + drivers/net/idpf/idpf_ethdev.c | 303 +++++++++++++++++++++ drivers/net/idpf/idpf_ethdev.h | 3 +- 6 files changed, 434 insertions(+), 1 deletion(-)
drivers/common/idpf/idpf_common_device.h +1 -0
@@ -98,6 +98,7 @@ struct idpf_vport {uint32_t *rss_lut;uint8_t *rss_key;uint64_t rss_hf; +uint64_t last_general_rss_hf;/* MSIX info*/ struct virtchnl2_queue_vector *qv_map;/* queue vector mapping */
drivers/common/idpf/idpf_common_virtchnl.c +119 -0
143 lines not on this page · raw message
drivers/common/idpf/idpf_common_virtchnl.h +6 -0
@@ -52,4 +52,10 @@ int idpf_vc_config_txq(struct idpf_vport *vport, struct idpf_tx_queue *txq);__rte_internal int idpf_query_stats(struct idpf_vport *vport,struct virtchnl2_vport_stats **pstats); +__rte_internal +int idpf_vc_get_rss_key(struct idpf_vport *vport); +__rte_internal +int idpf_vc_get_rss_lut(struct idpf_vport *vport); +__rte_internal +int idpf_vc_get_rss_hash(struct idpf_vport *vport);#endif /* _IDPF_COMMON_VIRTCHNL_H_ */
drivers/common/idpf/version.map +3 -0
@@ -63,6 +63,9 @@ INTERNAL { idpf_vc_set_rss_lut; idpf_vport_deinit; idpf_vport_init; + idpf_vc_get_rss_key; + idpf_vc_get_rss_lut; + idpf_vc_get_rss_hash; local: *; };
drivers/net/idpf/idpf_ethdev.c +303 -0
333 lines not on this page · raw message
drivers/net/idpf/idpf_ethdev.h +2 -1
@@ -48,7 +48,8 @@RTE_ETH_RSS_NONFRAG_IPV6_TCP | \RTE_ETH_RSS_NONFRAG_IPV6_UDP | \RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \ - RTE_ETH_RSS_NONFRAG_IPV6_OTHER) +RTE_ETH_RSS_NONFRAG_IPV6_OTHER | \ + RTE_ETH_RSS_L2_PAYLOAD) #define IDPF_ADAPTER_NAME_LEN (PCI_PRI_STR_SIZE + 1)
Signature · 1 line
2.25.1
RE: [PATCH v3 2/6] common/idpf: add RSS set/get ops
drivers/net/idpf/idpf_ethdev.c idpf_dev_stats_reset(struct rte_eth_dev *dev) · line 278
Quoted 3 lines
drivers/net/idpf/idpf_ethdev.c +3
-0+static int idpf_config_rss_hf (struct idpf_vport *vport,uint64_t rss_hf) +{ +uint64_t hena =0 , valid_rss_hf =0 ;
According to the coding style, only the last variable on a line should be initialized.
Quoted 30 lines
drivers/net/idpf/idpf_ethdev.c +30
-0+int ret =0 ; +uint16_t i; + +/** +* RTE_ETH_RSS_IPV4 and RTE_ETH_RSS_IPV6 can be considered as 2 +* generalizations of all other IPv4 and IPv6 RSS types. +*/ +if (rss_hf &RTE_ETH_RSS_IPV4 ) + rss_hf |= idpf_ipv4_rss; + +if (rss_hf &RTE_ETH_RSS_IPV6 ) + rss_hf |= idpf_ipv6_rss; + +for (i =0 ; i <RTE_DIM (idpf_map_hena_rss); i++) { +uint64_t bit =BIT_ULL (i); + +if (idpf_map_hena_rss[i] & rss_hf) { + valid_rss_hf |= idpf_map_hena_rss[i]; + hena |= bit; + } + } + + vport->rss_hf = hena; + + ret =idpf_vc_set_rss_hash (vport); +if (ret !=0 ) { +PMD_DRV_LOG (WARNING , +"fail to set RSS offload types, ret: %d" , ret); +return ret; + }
drivers/net/idpf/idpf_ethdev.c idpf_dev_stats_reset(struct rte_eth_dev *dev) · line 318
Quoted 10 lines
drivers/net/idpf/idpf_ethdev.c +10
-0+ +if (valid_rss_hf & idpf_ipv4_rss) + valid_rss_hf |= rss_hf &RTE_ETH_RSS_IPV4 ; + +if (valid_rss_hf & idpf_ipv6_rss) + valid_rss_hf |= rss_hf &RTE_ETH_RSS_IPV6 ; + +if (rss_hf & ~valid_rss_hf) +PMD_DRV_LOG (WARNING ,"Unsupported rss_hf 0x%" PRIx64, + rss_hf & ~valid_rss_hf);
It makes me a bit confused, valid_rss_hf is would be the sub of rss_hf according above assignment. Would it be possible to go here? And if it is possible, why not set valid_rss_hf before calling vc command?
Quoted 37 lines
drivers/net/idpf/idpf_ethdev.c +30
-0+ vport->last_general_rss_hf = valid_rss_hf; + +return ret; +} +static int idpf_init_rss (struct idpf_vport *vport) {@@ -256,6 +357,204 @@ idpf_init_rss(struct idpf_vport *vport)return ret; } +static int +idpf_rss_reta_update (struct rte_eth_dev *dev, +struct rte_eth_rss_reta_entry64 *reta_conf, +uint16_t reta_size) +{ +struct idpf_vport *vport = dev->data->dev_private; +struct idpf_adapter *adapter = vport->adapter; +uint16_t idx, shift; +uint32_t *lut; +int ret =0 ; +uint16_t i; + +if (adapter->caps.rss_caps ==0 || dev->data->nb_rx_queues ==0 ) { +PMD_DRV_LOG (DEBUG ,"RSS is not supported" ); +return -ENOTSUP ; + } + +if (reta_size != vport->rss_lut_size) { +PMD_DRV_LOG (ERR ,"The size of hash lookup table configured " +"(%d) doesn't match the number of hardware can " +"support (%d)" , + reta_size, vport->rss_lut_size); +return -EINVAL ; + } +
drivers/net/idpf/idpf_ethdev.c idpf_init_rss(struct idpf_vport *vport) · line 394
Quoted 10 lines
drivers/net/idpf/idpf_ethdev.c +10
-0+/* It MUST use the current LUT size to get the RSS lookup table, +* otherwise if will fail with -100 error code. +*/ + lut =rte_zmalloc (NULL , reta_size *sizeof (uint32_t ),0 ); +if (!lut) { +PMD_DRV_LOG (ERR ,"No memory can be allocated" ); +return -ENOMEM ; + } +/* store the old lut table temporarily */ +rte_memcpy (lut, vport->rss_lut, reta_size *sizeof (uint32_t ));
Stored the vport->rss_lut to lut? But you overwrite the lut below?
Quoted 20 lines
drivers/net/idpf/idpf_ethdev.c +20
-0+ +for (i =0 ; i < reta_size; i++) { + idx = i /RTE_ETH_RETA_GROUP_SIZE ; + shift = i %RTE_ETH_RETA_GROUP_SIZE ; +if (reta_conf[idx].mask & (1ULL << shift)) + lut[i] = reta_conf[idx].reta[shift]; + } + +rte_memcpy (vport->rss_lut, lut, reta_size *sizeof (uint32_t )); +/* send virtchnl ops to configure RSS */ + ret =idpf_vc_set_rss_lut (vport); +if (ret) { +PMD_INIT_LOG (ERR ,"Failed to configure RSS lut" ); + goto out; + } +out: +rte_free (lut); + +return ret; +}
RE: [PATCH v3 2/6] common/idpf: add RSS set/get ops
Quoted 6 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+static int idpf_config_rss_hf(struct idpf_vport *vport, uint64_t +rss_hf) { + uint64_t hena = 0, valid_rss_hf = 0;According to the coding style, only the last variable on a line should be initialized.
[Liu, Mingxia] Ok, thank, I'll check if the same issue exist otherwhere.
Quoted 18 lines
Quoted 7 lines
drivers/net/idpf/idpf_ethdev.c +7
-0+ vport->rss_hf = hena; + + ret =idpf_vc_set_rss_hash (vport); +if (ret !=0 ) { +PMD_DRV_LOG (WARNING , +"fail to set RSS offload types, ret: %d" , ret); +return ret;drivers/net/idpf/idpf_ethdev.c idpf_dev_stats_reset(struct rte_eth_dev *dev)
Quoted 10 lines
drivers/net/idpf/idpf_ethdev.c +10
-0+ } + +if (valid_rss_hf & idpf_ipv4_rss) + valid_rss_hf |= rss_hf &RTE_ETH_RSS_IPV4 ; + +if (valid_rss_hf & idpf_ipv6_rss) + valid_rss_hf |= rss_hf &RTE_ETH_RSS_IPV6 ; + +if (rss_hf & ~valid_rss_hf) + PMD_DRV_LOG(WARNING, "Unsupported rss_hf 0x%"PRIx64,
Quoted 5 lines
drivers/net/idpf/idpf_ethdev.c idpf_dev_stats_reset(struct rte_eth_dev *dev) · line 318
Quoted 1 line
drivers/net/idpf/idpf_ethdev.c +1
-0+ rss_hf & ~valid_rss_hf);It makes me a bit confused,
valid_rss_hfis would be the sub ofrss_hfaccording above assignment. Would it be possible to go here? And if it is possible, why not setvalid_rss_hfbefore calling vc command?
[Liu, Mingxia] According to cmd_config_rss_parsed(), when the rss_hf set is not belong to flow_type_rss_offloads, it will be delete by &flow_type_rss_offloads. What's more, in rte_eth_dev_rss_hash_update(), it will check again if rss_hf set is belong to flow_type_rss_offloads, if not, will return error. So when entering function idpf_config_rss_hf, it wouldn't be possible that (rss_hf & ~valid_rss_hf) != 0.
Better to delete this piece of code.
For the second question, why not set valid_rss_hf before calling vc command?
Because if we set rss_hf to RTE_ETH_RSS_IPV4, then the rss hf value on idpf side mapping to RTE_ETH_RSS_NONFRAG_IPV4_UDP | RTE_ETH_RSS_NONFRAG_IPV4_TCP | RTE_ETH_RSS_NONFRAG_IPV4_SCTP |RTE_ETH_RSS_NONFRAG_IPV4_OTHER |RTE_ETH_RSS_FRAG_IPV4 is been set. But there is no rss hf value on idpf side mapping to RTE_ETH_RSS_IPV4.
When we get rss_hf from vc, it won't tell us if RTE_ETH_RSS_IPV4 have ever been configured.
So dpdk software should record if RTE_ETH_RSS_IPV4 have ever been set by valid_rss_hf |= rss_hf & RTE_ETH_RSS_IPV4, and return to user when needed.
RTE_ETH_RSS_IPV6 is similar.
Quoted 12 lines
drivers/net/idpf/idpf_ethdev.c idpf_init_rss(struct idpf_vport *vport) · line 394
Quoted 10 lines
drivers/net/idpf/idpf_ethdev.c +10
-0+/* It MUST use the current LUT size to get the RSS lookup table, +* otherwise if will fail with -100 error code. +*/ + lut =rte_zmalloc (NULL , reta_size *sizeof (uint32_t ),0 ); +if (!lut) { +PMD_DRV_LOG (ERR ,"No memory can be allocated" ); +return -ENOMEM ; + } +/* store the old lut table temporarily */ +rte_memcpy (lut, vport->rss_lut, reta_size *sizeof (uint32_t ));Stored the
vport->rss_lutto lut? But you overwrite the lut below?
[Liu, Mingxia] Because lut include all redirection table, but we may want to update only several value of redirection table, so we first stored the original lut, and update the required table entries.
Quoted 91 lines
-----Original Message-----
From: Wu, Jingjing <[email protected]>
Sent: Thursday, February 2, 2023 11:28 AM
To: Liu, Mingxia <[email protected]>; [email protected]
Cc: Xing, Beilei <[email protected]>
Subject: RE: [PATCH v3 2/6] common/idpf: add RSS set/get opsReview
Quoted 3 lines
(quoted diff) +3
-0+static int idpf_config_rss_hf(struct idpf_vport *vport, uint64_t +rss_hf) { + uint64_t hena = 0, valid_rss_hf = 0;According to the coding style, only the last variable on a line should be initialized.
Quoted 29 lines
drivers/net/idpf/idpf_ethdev.c +29
-0+int ret =0 ; +uint16_t i; + +/** +* RTE_ETH_RSS_IPV4 and RTE_ETH_RSS_IPV6 can be considered as 2 +* generalizations of all other IPv4 and IPv6 RSS types. +*/ +if (rss_hf &RTE_ETH_RSS_IPV4 ) + rss_hf |= idpf_ipv4_rss; + +if (rss_hf &RTE_ETH_RSS_IPV6 ) + rss_hf |= idpf_ipv6_rss; + +for (i =0 ; i <RTE_DIM (idpf_map_hena_rss); i++) { +uint64_t bit =BIT_ULL (i); + +if (idpf_map_hena_rss[i] & rss_hf) { + valid_rss_hf |= idpf_map_hena_rss[i]; + hena |= bit; + } + } + + vport->rss_hf = hena; + + ret =idpf_vc_set_rss_hash (vport); +if (ret !=0 ) { +PMD_DRV_LOG (WARNING , +"fail to set RSS offload types, ret: %d" , ret); +return ret;drivers/net/idpf/idpf_ethdev.c idpf_dev_stats_reset(struct rte_eth_dev *dev)
Quoted 10 lines
drivers/net/idpf/idpf_ethdev.c +10
-0+ } + +if (valid_rss_hf & idpf_ipv4_rss) + valid_rss_hf |= rss_hf &RTE_ETH_RSS_IPV4 ; + +if (valid_rss_hf & idpf_ipv6_rss) + valid_rss_hf |= rss_hf &RTE_ETH_RSS_IPV6 ; + +if (rss_hf & ~valid_rss_hf) + PMD_DRV_LOG(WARNING, "Unsupported rss_hf 0x%"PRIx64,
drivers/net/idpf/idpf_ethdev.c idpf_dev_stats_reset(struct rte_eth_dev *dev) · line 318
Quoted 1 line
drivers/net/idpf/idpf_ethdev.c +1
-0+ rss_hf & ~valid_rss_hf);It makes me a bit confused,
valid_rss_hfis would be the sub ofrss_hfaccording above assignment. Would it be possible to go here? And if it is possible, why not setvalid_rss_hfbefore calling vc command?Quoted 20 lines
drivers/net/idpf/idpf_ethdev.c +5
-0+ vport->last_general_rss_hf = valid_rss_hf; + +return ret; +} +static int idpf_init_rss(struct idpf_vport *vport) { @@ -256,6 +357,204 @@
idpf_init_rss(struct idpf_vport *vport)drivers/net/idpf/idpf_ethdev.c +9
-0return ret; } +static int +idpf_rss_reta_update (struct rte_eth_dev *dev, +struct rte_eth_rss_reta_entry64 *reta_conf, +uint16_t reta_size) +{ +struct idpf_vport *vport = dev->data->dev_private; +struct idpf_adapter *adapter = vport->adapter; +uint16_t idx, shift; +uint32_t *lut;drivers/net/idpf/idpf_ethdev.c idpf_init_rss(struct idpf_vport *vport)
Quoted 10 lines
drivers/net/idpf/idpf_ethdev.c +10
-0+int ret =0 ; +uint16_t i; + +if (adapter->caps.rss_caps ==0 || dev->data->nb_rx_queues ==0 ) { +PMD_DRV_LOG (DEBUG ,"RSS is not supported" ); +return -ENOTSUP ; + } + +if (reta_size != vport->rss_lut_size) { + PMD_DRV_LOG(ERR, "The size of hash lookup tableconfigured "
Review
Quoted 1 line
(quoted diff) +1
-0+ "(%d) doesn't match the number ofhardware can "
Quoted 17 lines
Quoted 5 lines
drivers/net/idpf/idpf_ethdev.c +5
-0+"support (%d)" , + reta_size, vport->rss_lut_size); +return -EINVAL ; + } +drivers/net/idpf/idpf_ethdev.c idpf_init_rss(struct idpf_vport *vport) · line 394
Quoted 10 lines
drivers/net/idpf/idpf_ethdev.c +10
-0+/* It MUST use the current LUT size to get the RSS lookup table, +* otherwise if will fail with -100 error code. +*/ + lut =rte_zmalloc (NULL , reta_size *sizeof (uint32_t ),0 ); +if (!lut) { +PMD_DRV_LOG (ERR ,"No memory can be allocated" ); +return -ENOMEM ; + } +/* store the old lut table temporarily */ +rte_memcpy (lut, vport->rss_lut, reta_size *sizeof (uint32_t ));Stored the
vport->rss_lutto lut? But you overwrite the lut below?
[Liu, Mingxia] Because lut include all redirection table, but we may want to update only several value of redirection table, so we first stored the original lut, and update the required table entries.
Quoted 20 lines
Quoted 20 lines
drivers/net/idpf/idpf_ethdev.c +20
-0+ +for (i =0 ; i < reta_size; i++) { + idx = i /RTE_ETH_RETA_GROUP_SIZE ; + shift = i %RTE_ETH_RETA_GROUP_SIZE ; +if (reta_conf[idx].mask & (1ULL << shift)) + lut[i] = reta_conf[idx].reta[shift]; + } + +rte_memcpy (vport->rss_lut, lut, reta_size *sizeof (uint32_t )); +/* send virtchnl ops to configure RSS */ + ret =idpf_vc_set_rss_lut (vport); +if (ret) { +PMD_INIT_LOG (ERR ,"Failed to configure RSS lut" ); + goto out; + } +out: +rte_free (lut); + +return ret; +}
PATCH v3 3/6 common/idpf: support single q scatter RX datapath
In reply to Mingxia LiuThis patch add single q recv scatter rx function.
--- drivers/common/idpf/idpf_common_rxtx.c | 134 +++++++++++++++++++++++++ drivers/common/idpf/idpf_common_rxtx.h | 3 + drivers/common/idpf/version.map | 1 + drivers/net/idpf/idpf_ethdev.c | 3 +- drivers/net/idpf/idpf_rxtx.c | 26 ++++- drivers/net/idpf/idpf_rxtx.h | 2 + 6 files changed, 166 insertions(+), 3 deletions(-)
drivers/common/idpf/idpf_common_rxtx.c +134 -0
@@ -1146,6 +1146,140 @@ idpf_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,return nb_rx; } +uint16_t +idpf_singleq_recv_scatter_pkts (void *rx_queue,struct rte_mbuf **rx_pkts, +uint16_t nb_pkts) +{ +struct idpf_rx_queue *rxq = rx_queue; +volatile union virtchnl2_rx_desc *rx_ring = rxq->rx_ring; +volatile union virtchnl2_rx_desc *rxdp; +union virtchnl2_rx_desc rxd; +struct idpf_adapter *ad; +struct rte_mbuf *first_seg = rxq->pkt_first_seg; +struct rte_mbuf *last_seg = rxq->pkt_last_seg; +struct rte_mbuf *rxm; +struct rte_mbuf *nmb; +struct rte_eth_dev *dev; +const uint32_t *ptype_tbl = rxq->adapter->ptype_tbl; +uint16_t nb_hold =0 , nb_rx =0 ; +uint16_t rx_id = rxq->rx_tail; +uint16_t rx_packet_len; +uint16_t rx_status0; +uint64_t pkt_flags; +uint64_t dma_addr; +uint64_t ts_ns; + + ad = rxq->adapter; + +if (unlikely (!rxq) ||unlikely (!rxq->q_started)) +return nb_rx; + +while (nb_rx < nb_pkts) { + rxdp = &rx_ring[rx_id]; + rx_status0 =rte_le_to_cpu_16 (rxdp->flex_nic_wb.status_error0); + +/* Check the DD bit first */ +if (!(rx_status0 & (1 <<VIRTCHNL2_RX_FLEX_DESC_STATUS0_DD_S ))) +break ; + + nmb =rte_mbuf_raw_alloc (rxq->mp); +if (unlikely (!nmb)) { +rte_atomic64_inc (&(rxq->rx_stats.mbuf_alloc_failed)); +RX_LOG (DEBUG ,"RX mbuf alloc failed port_id=%u " +"queue_id=%u" , rxq->port_id, rxq->queue_id); +break ; + } + + rxd = *rxdp; + + nb_hold++; + rxm = rxq->sw_ring[rx_id]; + rxq->sw_ring[rx_id] = nmb; + rx_id++; +if (unlikely (rx_id == rxq->nb_rx_desc)) + rx_id =0 ; + +/* Prefetch next mbuf */ +rte_prefetch0 (rxq->sw_ring[rx_id]); + +/* When next RX descriptor is on a cache line boundary, +* prefetch the next 4 RX descriptors and next 8 pointers +* to mbufs. +*/ +if ((rx_id &0x3 ) ==0 ) { +rte_prefetch0 (&rx_ring[rx_id]); +rte_prefetch0 (rxq->sw_ring[rx_id]); + } + dma_addr = +rte_cpu_to_le_64 (rte_mbuf_data_iova_default (nmb)); + rxdp->read.hdr_addr =0 ; + rxdp->read.pkt_addr = dma_addr; + rx_packet_len = (rte_cpu_to_le_16 (rxd.flex_nic_wb.pkt_len) & +VIRTCHNL2_RX_FLEX_DESC_PKT_LEN_M ); + rxm->data_len = rx_packet_len; + rxm->data_off =RTE_PKTMBUF_HEADROOM ; + +/** +* If this is the first buffer of the received packet, set the +* pointer to the first mbuf of the packet and initialize its +* context. Otherwise, update the total length and the number +* of segments of the current scattered packet, and update the +* pointer to the last mbuf of the current packet. +*/ +if (!first_seg) { + first_seg = rxm; + first_seg->nb_segs =1 ; + first_seg->pkt_len = rx_packet_len; + }else { + first_seg->pkt_len = + (uint16_t )(first_seg->pkt_len + + rx_packet_len); + first_seg->nb_segs++; + last_seg->next = rxm; + } + +if (!(rx_status0 & (1 <<VIRTCHNL2_RX_FLEX_DESC_STATUS0_EOF_S ))) { + last_seg = rxm; +continue ; + } + + rxm->next =NULL ; + + first_seg->port = rxq->port_id; + first_seg->ol_flags =0 ; + pkt_flags =idpf_rxd_to_pkt_flags (rx_status0); + first_seg->packet_type = + ptype_tbl[(uint8_t )(rte_cpu_to_le_16 (rxd.flex_nic_wb.ptype_flex_flags0) & +VIRTCHNL2_RX_FLEX_DESC_PTYPE_M )]; + +if (idpf_timestamp_dynflag >0 && + (rxq->offloads &IDPF_RX_OFFLOAD_TIMESTAMP ) !=0 ) { +/* timestamp */ + ts_ns =idpf_tstamp_convert_32b_64b (ad, + rxq->hw_register_set, +rte_le_to_cpu_32 (rxd.flex_nic_wb.flex_ts.ts_high)); + rxq->hw_register_set =0 ; + *RTE_MBUF_DYNFIELD (rxm, + idpf_timestamp_dynfield_offset, + rte_mbuf_timestamp_t *) = ts_ns; + first_seg->ol_flags |= idpf_timestamp_dynflag; + } + + first_seg->ol_flags |= pkt_flags; +rte_prefetch0 (RTE_PTR_ADD (first_seg->buf_addr, + first_seg->data_off)); + rx_pkts[nb_rx++] = first_seg; + first_seg =NULL ; + } + rxq->rx_tail = rx_id; + rxq->pkt_first_seg = first_seg; + rxq->pkt_last_seg = last_seg; + +idpf_update_rx_tail (rxq, nb_hold, rx_id); + +return nb_rx; +} +static inline int idpf_xmit_cleanup (struct idpf_tx_queue *txq) {
drivers/common/idpf/idpf_common_rxtx.h +3 -0
@@ -260,6 +260,9 @@ __rte_internaluint16_t idpf_splitq_recv_pkts (void *rx_queue,struct rte_mbuf **rx_pkts,uint16_t nb_pkts);__rte_internal +uint16_t idpf_singleq_recv_scatter_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, +uint16_t nb_pkts); +__rte_internal uint16_t idpf_splitq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,uint16_t nb_pkts); __rte_internal
drivers/common/idpf/version.map +1 -0
@@ -32,6 +32,7 @@ INTERNAL { idpf_reset_split_tx_descq; idpf_rx_queue_release; idpf_singleq_recv_pkts; + idpf_singleq_recv_scatter_pkts; idpf_singleq_recv_pkts_avx512; idpf_singleq_rx_vec_setup; idpf_splitq_rx_vec_setup;
drivers/net/idpf/idpf_ethdev.c +2 -1
@@ -119,7 +119,8 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)RTE_ETH_RX_OFFLOAD_UDP_CKSUM |RTE_ETH_RX_OFFLOAD_TCP_CKSUM |RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM | -RTE_ETH_RX_OFFLOAD_TIMESTAMP ; +RTE_ETH_RX_OFFLOAD_TIMESTAMP | +RTE_ETH_RX_OFFLOAD_SCATTER ; dev_info->tx_offload_capa = RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
drivers/net/idpf/idpf_rxtx.c +24 -2
@@ -503,6 +503,8 @@ int idpf_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id) {struct idpf_rx_queue *rxq; +uint16_t max_pkt_len; +uint32_t frame_size;int err;if (rx_queue_id >= dev->data->nb_rx_queues)
@@ -516,6 +518,17 @@ idpf_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id)return -EINVAL ; } + frame_size = dev->data->mtu +IDPF_ETH_OVERHEAD ; + + max_pkt_len = +RTE_MIN ((uint32_t )IDPF_SUPPORT_CHAIN_NUM * rxq->rx_buf_len, + frame_size); + + rxq->max_pkt_len = max_pkt_len; +if ((dev->data->dev_conf.rxmode.offloads &RTE_ETH_RX_OFFLOAD_SCATTER ) || + frame_size > rxq->rx_buf_len) + dev->data->scattered_rx =1 ; + err =idpf_register_ts_mbuf (rxq);if (err !=0 ) { PMD_DRV_LOG(ERR, "fail to regidter timestamp mbuf %u",
@@ -801,13 +814,22 @@ idpf_set_rx_function(struct rte_eth_dev *dev) #endif /* CC_AVX512_SUPPORT */ } +if (dev->data->scattered_rx) { + dev->rx_pkt_burst = idpf_singleq_recv_scatter_pkts; +return ; + } dev->rx_pkt_burst = idpf_singleq_recv_pkts; }#else -if (vport->rxq_model ==VIRTCHNL2_QUEUE_MODEL_SPLIT ) +if (vport->rxq_model ==VIRTCHNL2_QUEUE_MODEL_SPLIT ) { dev->rx_pkt_burst = idpf_splitq_recv_pkts; -else + }else { +if (dev->data->scattered_rx) { + dev->rx_pkt_burst = idpf_singleq_recv_scatter_pkts; +return ; + } dev->rx_pkt_burst = idpf_singleq_recv_pkts; + }#endif /* RTE_ARCH_X86 */ }
drivers/net/idpf/idpf_rxtx.h +2 -0
@@ -23,6 +23,8 @@#define IDPF_DEFAULT_TX_RS_THRESH 32#define IDPF_DEFAULT_TX_FREE_THRESH 32 +#define IDPF_SUPPORT_CHAIN_NUM 5 + int idpf_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, uint16_t nb_desc, unsigned int socket_id, const struct rte_eth_rxconf *rx_conf,
Signature · 1 line
2.25.1
RE: [PATCH v3 3/6] common/idpf: support single q scatter RX datapath
Quoted 7 lines
drivers/common/idpf/idpf_common_rxtx.c +6
-0+uint16_t +idpf_singleq_recv_scatter_pkts (void *rx_queue,struct rte_mbuf **rx_pkts, +uint16_t nb_pkts) +{ +struct idpf_rx_queue *rxq = rx_queue; +volatile union virtchnl2_rx_desc *rx_ring = rxq->rx_ring;
drivers/common/idpf/idpf_common_rxtx.c idpf_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, · line 1164
Quoted 10 lines
drivers/common/idpf/idpf_common_rxtx.c +10
-0+volatile union virtchnl2_rx_desc *rxdp; +union virtchnl2_rx_desc rxd; +struct idpf_adapter *ad; +struct rte_mbuf *first_seg = rxq->pkt_first_seg; +struct rte_mbuf *last_seg = rxq->pkt_last_seg; +struct rte_mbuf *rxm; +struct rte_mbuf *nmb; +struct rte_eth_dev *dev; +const uint32_t *ptype_tbl = rxq->adapter->ptype_tbl; +uint16_t nb_hold =0 , nb_rx =0 ;
According to the coding style, only the last variable on a line should be initialized.
Quoted 7 lines
drivers/common/idpf/idpf_common_rxtx.c +7
-0+uint16_t rx_id = rxq->rx_tail; +uint16_t rx_packet_len; +uint16_t rx_status0; +uint64_t pkt_flags; +uint64_t dma_addr; +uint64_t ts_ns; +
RE: [PATCH v3 3/6] common/idpf: support single q scatter RX datapath
Quoted 15 lines
-----Original Message-----
From: Wu, Jingjing <[email protected]>
Sent: Thursday, February 2, 2023 11:46 AM
To: Liu, Mingxia <[email protected]>; [email protected]
Cc: Xing, Beilei <[email protected]>; Wu, Wenjun1 <[email protected]>
Subject: RE: [PATCH v3 3/6] common/idpf: support single q scatter RX datapathReview
Quoted 3 lines
(quoted diff) +2
-0+uint16_t +idpf_singleq_recv_scatter_pkts(void *rx_queue, struct rte_mbuf**rx_pkts,
Quoted 17 lines
Quoted 4 lines
drivers/common/idpf/idpf_common_rxtx.c +4
-0+ uint16_t nb_pkts) +{ +struct idpf_rx_queue *rxq = rx_queue; +volatile union virtchnl2_rx_desc *rx_ring = rxq->rx_ring;drivers/common/idpf/idpf_common_rxtx.c idpf_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, · line 1164
Quoted 10 lines
drivers/common/idpf/idpf_common_rxtx.c +10
-0+volatile union virtchnl2_rx_desc *rxdp; +union virtchnl2_rx_desc rxd; +struct idpf_adapter *ad; +struct rte_mbuf *first_seg = rxq->pkt_first_seg; +struct rte_mbuf *last_seg = rxq->pkt_last_seg; +struct rte_mbuf *rxm; +struct rte_mbuf *nmb; +struct rte_eth_dev *dev; +const uint32_t *ptype_tbl = rxq->adapter->ptype_tbl; +uint16_t nb_hold =0 , nb_rx =0 ;According to the coding style, only the last variable on a line should be initialized.
[Liu, Mingxia] Ok, thank, I'll check if the same issue exist otherwhere.
Quoted 7 lines
Quoted 7 lines
drivers/common/idpf/idpf_common_rxtx.c +7
-0+uint16_t rx_id = rxq->rx_tail; +uint16_t rx_packet_len; +uint16_t rx_status0; +uint64_t pkt_flags; +uint64_t dma_addr; +uint64_t ts_ns; +
PATCH v3 4/6 common/idpf: add rss_offload hash in singleq rx
In reply to Mingxia LiuThis patch add rss valid flag and hash value parsing of rx descriptor.
--- drivers/common/idpf/idpf_common_rxtx.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/common/idpf/idpf_common_rxtx.c +16 -0
@@ -1030,6 +1030,20 @@ idpf_update_rx_tail(struct idpf_rx_queue *rxq, uint16_t nb_hold, rxq->nb_rx_hold = nb_hold; } +static inline void +idpf_singleq_rx_rss_offload (struct rte_mbuf *mb, +volatile struct virtchnl2_rx_flex_desc_nic *rx_desc, +uint64_t *pkt_flags) +{ +uint16_t rx_status0 =rte_le_to_cpu_16 (rx_desc->status_error0); + +if (rx_status0 &RTE_BIT32 (VIRTCHNL2_RX_FLEX_DESC_STATUS0_RSS_VALID_S )) { + *pkt_flags |=RTE_MBUF_F_RX_RSS_HASH ; + mb->hash.rss =rte_le_to_cpu_32 (rx_desc->rss_hash); + } + +} +uint16_t idpf_singleq_recv_pkts (void *rx_queue,struct rte_mbuf **rx_pkts,uint16_t nb_pkts)
@@ -1118,6 +1132,7 @@ idpf_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, rxm->port = rxq->port_id; rxm->ol_flags =0 ; pkt_flags =idpf_rxd_to_pkt_flags (rx_status0); +idpf_singleq_rx_rss_offload (rxm, &rxd.flex_nic_wb, &pkt_flags); rxm->packet_type = ptype_tbl[(uint8_t )(rte_cpu_to_le_16 (rxd.flex_nic_wb.ptype_flex_flags0) &VIRTCHNL2_RX_FLEX_DESC_PTYPE_M )];
@@ -1248,6 +1263,7 @@ idpf_singleq_recv_scatter_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, first_seg->port = rxq->port_id; first_seg->ol_flags =0 ; pkt_flags =idpf_rxd_to_pkt_flags (rx_status0); +idpf_singleq_rx_rss_offload (first_seg, &rxd.flex_nic_wb, &pkt_flags); first_seg->packet_type = ptype_tbl[(uint8_t )(rte_cpu_to_le_16 (rxd.flex_nic_wb.ptype_flex_flags0) &VIRTCHNL2_RX_FLEX_DESC_PTYPE_M )];
Signature · 1 line
2.25.1
PATCH v3 5/6 common/idpf: add alarm to support handle vchnl message
In reply to Mingxia LiuHandle virtual channel message.
Refine link status update.
--- drivers/common/idpf/idpf_common_device.h | 5 + drivers/common/idpf/idpf_common_virtchnl.c | 19 --- drivers/net/idpf/idpf_ethdev.c | 165 ++++++++++++++++++++- drivers/net/idpf/idpf_ethdev.h | 2 + 4 files changed, 171 insertions(+), 20 deletions(-)
drivers/common/idpf/idpf_common_device.h +5 -0
@@ -118,6 +118,11 @@ struct idpf_vport {bool tx_use_avx512;struct virtchnl2_vport_stats eth_stats_offset; + +void *dev; +/* Event from ipf */ +bool link_up; +uint32_t link_speed; };/* Message type read in virtual channel from PF */
drivers/common/idpf/idpf_common_virtchnl.c +0 -19
@@ -202,25 +202,6 @@ idpf_execute_vc_cmd(struct idpf_adapter *adapter, struct idpf_cmd_info *args)switch (args->ops) {case VIRTCHNL_OP_VERSION :case VIRTCHNL2_OP_GET_CAPS : -case VIRTCHNL2_OP_CREATE_VPORT : -case VIRTCHNL2_OP_DESTROY_VPORT : -case VIRTCHNL2_OP_SET_RSS_KEY : -case VIRTCHNL2_OP_SET_RSS_LUT : -case VIRTCHNL2_OP_SET_RSS_HASH : -case VIRTCHNL2_OP_CONFIG_RX_QUEUES : -case VIRTCHNL2_OP_CONFIG_TX_QUEUES : -case VIRTCHNL2_OP_ENABLE_QUEUES : -case VIRTCHNL2_OP_DISABLE_QUEUES : -case VIRTCHNL2_OP_ENABLE_VPORT : -case VIRTCHNL2_OP_DISABLE_VPORT : -case VIRTCHNL2_OP_MAP_QUEUE_VECTOR : -case VIRTCHNL2_OP_UNMAP_QUEUE_VECTOR : -case VIRTCHNL2_OP_ALLOC_VECTORS : -case VIRTCHNL2_OP_DEALLOC_VECTORS : -case VIRTCHNL2_OP_GET_STATS : -case VIRTCHNL2_OP_GET_RSS_KEY : -case VIRTCHNL2_OP_GET_RSS_HASH : -case VIRTCHNL2_OP_GET_RSS_LUT :/* for init virtchnl ops, need to poll the response */ err =idpf_read_one_msg (adapter, args->ops, args->out_size, args->out_buffer);clear_cmd (adapter);
drivers/net/idpf/idpf_ethdev.c +164 -1
206 lines not on this page · raw message
drivers/net/idpf/idpf_ethdev.h +2 -0
@@ -53,6 +53,8 @@#define IDPF_ADAPTER_NAME_LEN (PCI_PRI_STR_SIZE + 1) +#define IDPF_ALARM_INTERVAL 50000/* us */ +struct idpf_vport_param {struct idpf_adapter_ext *adapter;uint16_t devarg_id;/* arg id from user */
Signature · 1 line
2.25.1
RE: [PATCH v3 5/6] common/idpf: add alarm to support handle vchnl message
Quoted 40 lines
drivers/net/idpf/idpf_ethdev.c +31
-1@@ -83,12 +84,49 @@ static int idpf_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete) { + struct idpf_vport *vport = dev->data->dev_private;struct rte_eth_link new_link;memset (&new_link,0 ,sizeof (new_link)); - new_link.link_speed =RTE_ETH_SPEED_NUM_NONE ; +switch (vport->link_speed) { +case 10 : + new_link.link_speed =RTE_ETH_SPEED_NUM_10M ; +break ; +case 100 : + new_link.link_speed =RTE_ETH_SPEED_NUM_100M ; +break ; +case 1000 : + new_link.link_speed =RTE_ETH_SPEED_NUM_1G ; +break ; +case 10000 : + new_link.link_speed =RTE_ETH_SPEED_NUM_10G ; +break ; +case 20000 : + new_link.link_speed =RTE_ETH_SPEED_NUM_20G ; +break ; +case 25000 : + new_link.link_speed =RTE_ETH_SPEED_NUM_25G ; +break ; +case 40000 : + new_link.link_speed =RTE_ETH_SPEED_NUM_40G ; +break ; +case 50000 : + new_link.link_speed =RTE_ETH_SPEED_NUM_50G ; +break ; +case 100000 : + new_link.link_speed =RTE_ETH_SPEED_NUM_100G ; +break ; +case 200000 : + new_link.link_speed =RTE_ETH_SPEED_NUM_200G ;
drivers/net/idpf/idpf_ethdev.c static int · line 131
Quoted 10 lines
drivers/net/idpf/idpf_ethdev.c +7
-0+break ; +default : + new_link.link_speed =RTE_ETH_SPEED_NUM_NONE ; + } + new_link.link_duplex =RTE_ETH_LINK_FULL_DUPLEX ; + new_link.link_status = vport->link_up ?RTE_ETH_LINK_UP : +RTE_ETH_LINK_DOWN ; new_link.link_autoneg = !(dev->data->dev_conf.link_speeds &RTE_ETH_LINK_SPEED_FIXED );
Better to use RTE_ETH_LINK_[AUTONEG/FIXED] instead.
Quoted 28 lines
(quoted diff) +0
-0@@ -927,6 +965,127 @@ idpf_parse_devargs(struct rte_pci_device *pci_dev, struct
idpf_adapter_ext*adapdrivers/net/idpf/idpf_ethdev.c +22
-0return ret; } +static struct idpf_vport * +idpf_find_vport (struct idpf_adapter_ext *adapter,uint32_t vport_id) +{ +struct idpf_vport *vport =NULL ; +int i; + +for (i =0 ; i < adapter->cur_vport_nb; i++) { + vport = adapter->vports[i]; +if (vport->vport_id != vport_id) +continue ; +else +return vport; + } + +return vport; +} + +static void +idpf_handle_event_msg (struct idpf_vport *vport,uint8_t *msg,uint16_t msglen) +{ +struct virtchnl2_event *vc_event = (struct virtchnl2_event *)msg; +struct rte_eth_dev *dev = (struct rte_eth_dev *)vport->dev;
drivers/net/idpf/idpf_ethdev.c idpf_parse_devargs(struct rte_pci_device *pci_dev, struct idpf_adapter_ext *adap · line 999
Quoted 10 lines
drivers/net/idpf/idpf_ethdev.c +10
-0+ +if (msglen <sizeof (struct virtchnl2_event )) { +PMD_DRV_LOG (ERR ,"Error event" ); +return ; + } + +switch (vc_event->event) { +case VIRTCHNL2_EVENT_LINK_CHANGE : +PMD_DRV_LOG (DEBUG ,"VIRTCHNL2_EVENT_LINK_CHANGE" ); + vport->link_up = vc_event->link_status;
Any conversion between bool and uint8?
RE: [PATCH v3 5/6] common/idpf: add alarm to support handle vchnl message
Quoted 52 lines
-----Original Message-----
From: Wu, Jingjing <[email protected]>
Sent: Thursday, February 2, 2023 12:24 PM
To: Liu, Mingxia <[email protected]>; [email protected]
Cc: Xing, Beilei <[email protected]>
Subject: RE: [PATCH v3 5/6] common/idpf: add alarm to support handle vchnl messageQuoted 42 lines
drivers/net/idpf/idpf_ethdev.c +34
-1@@ -83,12 +84,49 @@ static int idpf_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete) { + struct idpf_vport *vport = dev->data->dev_private;struct rte_eth_link new_link;memset (&new_link,0 ,sizeof (new_link)); - new_link.link_speed =RTE_ETH_SPEED_NUM_NONE ; +switch (vport->link_speed) { +case 10 : + new_link.link_speed =RTE_ETH_SPEED_NUM_10M ; +break ; +case 100 : + new_link.link_speed =RTE_ETH_SPEED_NUM_100M ; +break ; +case 1000 : + new_link.link_speed =RTE_ETH_SPEED_NUM_1G ; +break ; +case 10000 : + new_link.link_speed =RTE_ETH_SPEED_NUM_10G ; +break ; +case 20000 : + new_link.link_speed =RTE_ETH_SPEED_NUM_20G ; +break ; +case 25000 : + new_link.link_speed =RTE_ETH_SPEED_NUM_25G ; +break ; +case 40000 : + new_link.link_speed =RTE_ETH_SPEED_NUM_40G ; +break ; +case 50000 : + new_link.link_speed =RTE_ETH_SPEED_NUM_50G ; +break ; +case 100000 : + new_link.link_speed =RTE_ETH_SPEED_NUM_100G ; +break ; +case 200000 : + new_link.link_speed =RTE_ETH_SPEED_NUM_200G ; +break ; +default : + new_link.link_speed =RTE_ETH_SPEED_NUM_NONE ;
Quoted 9 lines
drivers/net/idpf/idpf_ethdev.c static int · line 131
Quoted 7 lines
drivers/net/idpf/idpf_ethdev.c +4
-0+ } + new_link.link_duplex =RTE_ETH_LINK_FULL_DUPLEX ; + new_link.link_status = vport->link_up ?RTE_ETH_LINK_UP : +RTE_ETH_LINK_DOWN ; new_link.link_autoneg = !(dev->data->dev_conf.link_speeds &RTE_ETH_LINK_SPEED_FIXED );Better to use RTE_ETH_LINK_[AUTONEG/FIXED] instead.
[Liu, Mingxia] According to the comment description of struct rte_eth_conf, RTE_ETH_LINK_SPEED_FIXED is better. struct rte_eth_conf {uint32_t link_speeds; /**< bitmap of RTE_ETH_LINK_SPEED_XXX of speeds to be
used. RTE_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 RTE_ETH_LINK_SPEED_AUTONEG (0) is used, all speeds
supported are advertised. */
Quoted 38 lines
Quoted 27 lines
drivers/net/idpf/idpf_ethdev.c +21
-0@@ -927,6 +965,127 @@ idpf_parse_devargs(struct rte_pci_device *pci_dev, struct idpf_adapter_ext *adapreturn ret; } +static struct idpf_vport * +idpf_find_vport (struct idpf_adapter_ext *adapter,uint32_t vport_id) +{ +struct idpf_vport *vport =NULL ; +int i; + +for (i =0 ; i < adapter->cur_vport_nb; i++) { + vport = adapter->vports[i]; +if (vport->vport_id != vport_id) +continue ; +else +return vport; + } + +return vport; +} + +static void +idpf_handle_event_msg (struct idpf_vport *vport,uint8_t *msg, +uint16_t msglen) { +struct virtchnl2_event *vc_event = (struct virtchnl2_event *)msg;drivers/net/idpf/idpf_ethdev.c idpf_parse_devargs(struct rte_pci_device · line 999
Quoted 10 lines
drivers/net/idpf/idpf_ethdev.c +10
-0+struct rte_eth_dev *dev = (struct rte_eth_dev *)vport->dev; + +if (msglen <sizeof (struct virtchnl2_event )) { +PMD_DRV_LOG (ERR ,"Error event" ); +return ; + } + +switch (vc_event->event) { +case VIRTCHNL2_EVENT_LINK_CHANGE : + PMD_DRV_LOG(DEBUG,"
VIRTCHNL2_EVENT_LINK_CHANGE");
Quoted 3 lines
drivers/net/idpf/idpf_ethdev.c idpf_parse_devargs(struct rte_pci_device *pci_dev, struct idpf_adapter_ext *adap · line 999
Quoted 1 line
drivers/net/idpf/idpf_ethdev.c +1
-0+ vport->link_up = vc_event->link_status;Any conversion between bool and uint8?
[Liu, Mingxia] Ok, thanks, I 'll use !! to convert uint8 to bool.
RE: [PATCH v3 5/6] common/idpf: add alarm to support handle vchnl message
Quoted 8 lines
Quoted 8 lines
drivers/net/idpf/idpf_ethdev.c static int · line 131
Quoted 6 lines
drivers/net/idpf/idpf_ethdev.c +3
-0+ new_link.link_duplex =RTE_ETH_LINK_FULL_DUPLEX ; + new_link.link_status = vport->link_up ?RTE_ETH_LINK_UP : +RTE_ETH_LINK_DOWN ; new_link.link_autoneg = !(dev->data->dev_conf.link_speeds &RTE_ETH_LINK_SPEED_FIXED );Better to use RTE_ETH_LINK_[AUTONEG/FIXED] instead.
Quoted 11 lines
[Liu, Mingxia] According to the comment description of struct
rte_eth_conf,RTE_ETH_LINK_SPEED_FIXEDis better.
structrte_eth_conf{uint32_tlink_speeds; /**< bitmap ofRTE_ETH_LINK_SPEED_XXXof speeds to be
used.RTE_ETH_LINK_SPEED_FIXEDdisables link autonegotiation, and a unique speed shall be set. Otherwise, the bitmap defines the set of speeds to be advertised. If the special valueRTE_ETH_LINK_SPEED_AUTONEG(0) is used, all speeds supported are advertised. */
I am talking about link_autoneg but not link_speeds
PATCH v3 6/6 common/idpf: add xstats ops
In reply to Mingxia LiuAdd support for these device ops:
-idpf_dev_xstats_get
-idpf_dev_xstats_get_names
-idpf_dev_xstats_reset
--- drivers/net/idpf/idpf_ethdev.c | 80 ++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+)
drivers/net/idpf/idpf_ethdev.c +80 -0
@@ -80,6 +80,30 @@ static const uint64_t idpf_ipv6_rss = RTE_ETH_RSS_NONFRAG_IPV6_UDP |RTE_ETH_RSS_NONFRAG_IPV6_OTHER |RTE_ETH_RSS_FRAG_IPV6 ; +struct rte_idpf_xstats_name_off { +char name[RTE_ETH_XSTATS_NAME_SIZE ]; +unsigned int offset; +}; + +static const struct rte_idpf_xstats_name_off rte_idpf_stats_strings[] = { + {"rx_bytes" , offsetof(struct virtchnl2_vport_stats , rx_bytes)}, + {"rx_unicast_packets" , offsetof(struct virtchnl2_vport_stats , rx_unicast)}, + {"rx_multicast_packets" , offsetof(struct virtchnl2_vport_stats , rx_multicast)}, + {"rx_broadcast_packets" , offsetof(struct virtchnl2_vport_stats , rx_broadcast)}, + {"rx_dropped_packets" , offsetof(struct virtchnl2_vport_stats , rx_discards)}, + {"rx_errors" , offsetof(struct virtchnl2_vport_stats , rx_errors)}, + {"rx_unknown_protocol_packets" , offsetof(struct virtchnl2_vport_stats , + rx_unknown_protocol)}, + {"tx_bytes" , offsetof(struct virtchnl2_vport_stats , tx_bytes)}, + {"tx_unicast_packets" , offsetof(struct virtchnl2_vport_stats , tx_unicast)}, + {"tx_multicast_packets" , offsetof(struct virtchnl2_vport_stats , tx_multicast)}, + {"tx_broadcast_packets" , offsetof(struct virtchnl2_vport_stats , tx_broadcast)}, + {"tx_dropped_packets" , offsetof(struct virtchnl2_vport_stats , tx_discards)}, + {"tx_error_packets" , offsetof(struct virtchnl2_vport_stats , tx_errors)}}; + +#define IDPF_NB_XSTATS (sizeof(rte_idpf_stats_strings) / \ + sizeof(rte_idpf_stats_strings[0])) +static int idpf_dev_link_update (struct rte_eth_dev *dev, __rte_unused int wait_to_complete)
@@ -312,6 +336,59 @@ idpf_dev_stats_reset(struct rte_eth_dev *dev)return 0 ; } +static int idpf_dev_xstats_reset (struct rte_eth_dev *dev) +{ +idpf_dev_stats_reset (dev); +return 0 ; +} + +static int idpf_dev_xstats_get (struct rte_eth_dev *dev, +struct rte_eth_xstat *xstats,unsigned int n) +{ +struct idpf_vport *vport = + (struct idpf_vport *)dev->data->dev_private; +struct virtchnl2_vport_stats *pstats =NULL ; +unsigned int i; +int ret; + +if (n <IDPF_NB_XSTATS ) +return IDPF_NB_XSTATS ; + +if (!xstats) +return 0 ; + + ret =idpf_query_stats (vport, &pstats); +if (ret) { +PMD_DRV_LOG (ERR ,"Get statistics failed" ); +return 0 ; + } + +idpf_update_stats (&vport->eth_stats_offset, pstats); + +/* loop over xstats array and values from pstats */ +for (i =0 ; i <IDPF_NB_XSTATS ; i++) { + xstats[i].id = i; + xstats[i].value = *(uint64_t *)(((char *)pstats) + + rte_idpf_stats_strings[i].offset); + } +return IDPF_NB_XSTATS ; +} + +static int idpf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, +struct rte_eth_xstat_name *xstats_names, + __rte_unused unsigned int limit) +{ +unsigned int i; + +if (xstats_names) +for (i =0 ; i <IDPF_NB_XSTATS ; i++) { +snprintf (xstats_names[i].name, +sizeof (xstats_names[i].name), +"%s" , rte_idpf_stats_strings[i].name); + } +return IDPF_NB_XSTATS ; +} +static int idpf_config_rss_hf (struct idpf_vport *vport,uint64_t rss_hf) {uint64_t hena =0 , valid_rss_hf =0 ;
@@ -1158,6 +1235,9 @@ static const struct eth_dev_ops idpf_eth_dev_ops = { .reta_query = idpf_rss_reta_query, .rss_hash_update = idpf_rss_hash_update, .rss_hash_conf_get = idpf_rss_hash_conf_get, + .xstats_get = idpf_dev_xstats_get, + .xstats_get_names = idpf_dev_xstats_get_names, + .xstats_reset = idpf_dev_xstats_reset, }; static uint16_t
Signature · 1 line
2.25.1
v4 cover add idpf pmd enhancement features
In reply to Mingxia LiuThis patchset add several enhancement features of idpf pmd. Including the following:
- add hw statistics, support stats/xstats ops
- add rss configure/show ops
- add event handle: link status
- add scattered data path for single queue
This patchset is based on the refactor idpf PMD code:
http://patches.dpdk.org/project/dpdk/patch/[email protected]/
v2 changes:
- Fix rss lut config issue.
v3 changes:
- rebase to the new baseline.
v4 changes:
- rebase to the new baseline.
- optimize some code
- give "not supported" tips when user want to config rss hash type
- if stats reset fails at initialization time, don't rollback, just print ERROR info.
Mingxia Liu (6):
common/idpf: add hw statistics
common/idpf: add RSS set/get ops
common/idpf: support single q scatter RX datapath common/idpf: add rss_offload hash in singleq rx common/idpf: add alarm to support handle vchnl message common/idpf: add xstats ops
drivers/common/idpf/idpf_common_device.c | 17 + drivers/common/idpf/idpf_common_device.h | 10 + drivers/common/idpf/idpf_common_rxtx.c | 151 +++++ drivers/common/idpf/idpf_common_rxtx.h | 3 + drivers/common/idpf/idpf_common_virtchnl.c | 171 +++++- drivers/common/idpf/idpf_common_virtchnl.h | 15 + drivers/common/idpf/version.map | 8 + drivers/net/idpf/idpf_ethdev.c | 606 ++++++++++++++++++++- drivers/net/idpf/idpf_ethdev.h | 5 +- drivers/net/idpf/idpf_rxtx.c | 28 + drivers/net/idpf/idpf_rxtx.h | 2 + 11 files changed, 996 insertions(+), 20 deletions(-)
Signature · 1 line
2.25.1
PATCH v4 1/6 common/idpf: add hw statistics
This patch add hardware packets/bytes statistics.
--- drivers/common/idpf/idpf_common_device.c | 17 +++++ drivers/common/idpf/idpf_common_device.h | 4 + drivers/common/idpf/idpf_common_virtchnl.c | 27 +++++++ drivers/common/idpf/idpf_common_virtchnl.h | 3 + drivers/common/idpf/version.map | 2 + drivers/net/idpf/idpf_ethdev.c | 86 ++++++++++++++++++++++ 6 files changed, 139 insertions(+)
drivers/common/idpf/idpf_common_device.c +17 -0
@@ -652,4 +652,21 @@ idpf_vport_info_init(struct idpf_vport *vport,return 0 ; } +void +idpf_vport_stats_update (struct virtchnl2_vport_stats *oes,struct virtchnl2_vport_stats *nes) +{ + nes->rx_bytes = nes->rx_bytes - oes->rx_bytes; + nes->rx_unicast = nes->rx_unicast - oes->rx_unicast; + nes->rx_multicast = nes->rx_multicast - oes->rx_multicast; + nes->rx_broadcast = nes->rx_broadcast - oes->rx_broadcast; + nes->rx_errors = nes->rx_errors - oes->rx_errors; + nes->rx_discards = nes->rx_discards - oes->rx_discards; + nes->tx_bytes = nes->tx_bytes - oes->tx_bytes; + nes->tx_unicast = nes->tx_unicast - oes->tx_unicast; + nes->tx_multicast = nes->tx_multicast - oes->tx_multicast; + nes->tx_broadcast = nes->tx_broadcast - oes->tx_broadcast; + nes->tx_errors = nes->tx_errors - oes->tx_errors; + nes->tx_discards = nes->tx_discards - oes->tx_discards; +} +RTE_LOG_REGISTER_SUFFIX (idpf_common_logtype, common,NOTICE );
drivers/common/idpf/idpf_common_device.h +4 -0
@@ -115,6 +115,8 @@ struct idpf_vport {bool tx_vec_allowed;bool rx_use_avx512;bool tx_use_avx512; + +struct virtchnl2_vport_stats eth_stats_offset; };/* Message type read in virtual channel from PF */
@@ -191,5 +193,7 @@ int idpf_vport_irq_unmap_config(struct idpf_vport *vport, uint16_t nb_rx_queues)__rte_internal int idpf_vport_info_init(struct idpf_vport *vport,struct virtchnl2_create_vport *vport_info); +__rte_internal +void idpf_vport_stats_update(struct virtchnl2_vport_stats *oes, struct virtchnl2_vport_stats *nes);#endif /* _IDPF_COMMON_DEVICE_H_ */
drivers/common/idpf/idpf_common_virtchnl.c +27 -0
@@ -217,6 +217,7 @@ idpf_vc_cmd_execute(struct idpf_adapter *adapter, struct idpf_cmd_info *args)case VIRTCHNL2_OP_UNMAP_QUEUE_VECTOR :case VIRTCHNL2_OP_ALLOC_VECTORS :case VIRTCHNL2_OP_DEALLOC_VECTORS : +case VIRTCHNL2_OP_GET_STATS :/* for init virtchnl ops, need to poll the response */ err =idpf_vc_one_msg_read (adapter, args->ops, args->out_size, args->out_buffer);clear_cmd (adapter);
@@ -806,6 +807,32 @@ idpf_vc_ptype_info_query(struct idpf_adapter *adapter)return err; } +int +idpf_vc_stats_query (struct idpf_vport *vport, +struct virtchnl2_vport_stats **pstats) +{ +struct idpf_adapter *adapter = vport->adapter; +struct virtchnl2_vport_stats vport_stats; +struct idpf_cmd_info args; +int err; + + vport_stats.vport_id = vport->vport_id; + args.ops =VIRTCHNL2_OP_GET_STATS ; + args.in_args = (u8 *)&vport_stats; + args.in_args_size =sizeof (vport_stats); + args.out_buffer = adapter->mbx_resp; + args.out_size =IDPF_DFLT_MBX_BUF_SIZE ; + + err =idpf_vc_cmd_execute (adapter, &args); +if (err) { +DRV_LOG (ERR ,"Failed to execute command of VIRTCHNL2_OP_GET_STATS" ); + *pstats =NULL ; +return err; + } + *pstats = (struct virtchnl2_vport_stats *)args.out_buffer; +return 0 ; +} +#define IDPF_RX_BUF_STRIDE 64int idpf_vc_rxq_config (struct idpf_vport *vport,struct idpf_rx_queue *rxq)
drivers/common/idpf/idpf_common_virtchnl.h +3 -0
@@ -49,4 +49,7 @@ __rte_internalint idpf_vc_rxq_config (struct idpf_vport *vport,struct idpf_rx_queue *rxq);__rte_internal int idpf_vc_txq_config(struct idpf_vport *vport, struct idpf_tx_queue *txq); +__rte_internal +int idpf_vc_stats_query(struct idpf_vport *vport, +struct virtchnl2_vport_stats **pstats);#endif /* _IDPF_COMMON_VIRTCHNL_H_ */
drivers/common/idpf/version.map +2 -0
@@ -46,6 +46,7 @@ INTERNAL { idpf_vc_rss_key_set; idpf_vc_rss_lut_set; idpf_vc_rxq_config; + idpf_vc_stats_query; idpf_vc_txq_config; idpf_vc_vectors_alloc; idpf_vc_vectors_dealloc;
@@ -59,6 +60,7 @@ INTERNAL { idpf_vport_irq_map_config; idpf_vport_irq_unmap_config; idpf_vport_rss_config; + idpf_vport_stats_update; local: *; };
drivers/net/idpf/idpf_ethdev.c +86 -0
104 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v4 2/6 common/idpf: add RSS set/get ops
In reply to Mingxia LiuAdd support for these device ops:
- rss_reta_update
- rss_reta_query
- rss_hash_update
- rss_hash_conf_get
--- drivers/common/idpf/idpf_common_device.h | 1 + drivers/common/idpf/idpf_common_virtchnl.c | 119 +++++++++ drivers/common/idpf/idpf_common_virtchnl.h | 6 + drivers/common/idpf/version.map | 3 + drivers/net/idpf/idpf_ethdev.c | 268 +++++++++++++++++++++ drivers/net/idpf/idpf_ethdev.h | 3 +- 6 files changed, 399 insertions(+), 1 deletion(-)
drivers/common/idpf/idpf_common_device.h +1 -0
@@ -98,6 +98,7 @@ struct idpf_vport {uint32_t *rss_lut;uint8_t *rss_key;uint64_t rss_hf; +uint64_t last_general_rss_hf;/* MSIX info*/ struct virtchnl2_queue_vector *qv_map;/* queue vector mapping */
drivers/common/idpf/idpf_common_virtchnl.c +119 -0
137 lines not on this page · raw message
drivers/common/idpf/idpf_common_virtchnl.h +6 -0
@@ -52,4 +52,10 @@ int idpf_vc_txq_config(struct idpf_vport *vport, struct idpf_tx_queue *txq);__rte_internal int idpf_vc_stats_query(struct idpf_vport *vport,struct virtchnl2_vport_stats **pstats); +__rte_internal +int idpf_vc_rss_key_get(struct idpf_vport *vport); +__rte_internal +int idpf_vc_rss_lut_get(struct idpf_vport *vport); +__rte_internal +int idpf_vc_rss_hash_get(struct idpf_vport *vport);#endif /* _IDPF_COMMON_VIRTCHNL_H_ */
drivers/common/idpf/version.map +3 -0
@@ -42,8 +42,11 @@ INTERNAL { idpf_vc_ptype_info_query; idpf_vc_queue_switch; idpf_vc_queues_ena_dis; + idpf_vc_rss_hash_get; idpf_vc_rss_hash_set; + idpf_vc_rss_key_get; idpf_vc_rss_key_set; + idpf_vc_rss_lut_get; idpf_vc_rss_lut_set; idpf_vc_rxq_config; idpf_vc_stats_query;
drivers/net/idpf/idpf_ethdev.c +268 -0
298 lines not on this page · raw message
drivers/net/idpf/idpf_ethdev.h +2 -1
@@ -48,7 +48,8 @@RTE_ETH_RSS_NONFRAG_IPV6_TCP | \RTE_ETH_RSS_NONFRAG_IPV6_UDP | \RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \ - RTE_ETH_RSS_NONFRAG_IPV6_OTHER) +RTE_ETH_RSS_NONFRAG_IPV6_OTHER | \ + RTE_ETH_RSS_L2_PAYLOAD) #define IDPF_ADAPTER_NAME_LEN (PCI_PRI_STR_SIZE + 1)
Signature · 1 line
2.25.1
PATCH v4 3/6 common/idpf: support single q scatter RX datapath
In reply to Mingxia LiuThis patch add single q recv scatter rx function.
--- drivers/common/idpf/idpf_common_rxtx.c | 135 +++++++++++++++++++++++++ drivers/common/idpf/idpf_common_rxtx.h | 3 + drivers/common/idpf/version.map | 1 + drivers/net/idpf/idpf_ethdev.c | 3 +- drivers/net/idpf/idpf_rxtx.c | 28 +++++ drivers/net/idpf/idpf_rxtx.h | 2 + 6 files changed, 171 insertions(+), 1 deletion(-)
drivers/common/idpf/idpf_common_rxtx.c +135 -0
@@ -1146,6 +1146,141 @@ idpf_dp_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,return nb_rx; } +uint16_t +idpf_dp_singleq_recv_scatter_pkts (void *rx_queue,struct rte_mbuf **rx_pkts, +uint16_t nb_pkts) +{ +struct idpf_rx_queue *rxq = rx_queue; +volatile union virtchnl2_rx_desc *rx_ring = rxq->rx_ring; +volatile union virtchnl2_rx_desc *rxdp; +union virtchnl2_rx_desc rxd; +struct idpf_adapter *ad; +struct rte_mbuf *first_seg = rxq->pkt_first_seg; +struct rte_mbuf *last_seg = rxq->pkt_last_seg; +struct rte_mbuf *rxm; +struct rte_mbuf *nmb; +struct rte_eth_dev *dev; +const uint32_t *ptype_tbl = rxq->adapter->ptype_tbl; +uint16_t rx_id = rxq->rx_tail; +uint16_t rx_packet_len; +uint16_t nb_hold =0 ; +uint16_t rx_status0; +uint16_t nb_rx =0 ; +uint64_t pkt_flags; +uint64_t dma_addr; +uint64_t ts_ns; + + ad = rxq->adapter; + +if (unlikely (!rxq) ||unlikely (!rxq->q_started)) +return nb_rx; + +while (nb_rx < nb_pkts) { + rxdp = &rx_ring[rx_id]; + rx_status0 =rte_le_to_cpu_16 (rxdp->flex_nic_wb.status_error0); + +/* Check the DD bit first */ +if (!(rx_status0 & (1 <<VIRTCHNL2_RX_FLEX_DESC_STATUS0_DD_S ))) +break ; + + nmb =rte_mbuf_raw_alloc (rxq->mp); +if (unlikely (!nmb)) { +__atomic_fetch_add (&rxq->rx_stats.mbuf_alloc_failed,1 , __ATOMIC_RELAXED); +RX_LOG (DEBUG ,"RX mbuf alloc failed port_id=%u " +"queue_id=%u" , rxq->port_id, rxq->queue_id); +break ; + } + + rxd = *rxdp; + + nb_hold++; + rxm = rxq->sw_ring[rx_id]; + rxq->sw_ring[rx_id] = nmb; + rx_id++; +if (unlikely (rx_id == rxq->nb_rx_desc)) + rx_id =0 ; + +/* Prefetch next mbuf */ +rte_prefetch0 (rxq->sw_ring[rx_id]); + +/* When next RX descriptor is on a cache line boundary, +* prefetch the next 4 RX descriptors and next 8 pointers +* to mbufs. +*/ +if ((rx_id &0x3 ) ==0 ) { +rte_prefetch0 (&rx_ring[rx_id]); +rte_prefetch0 (rxq->sw_ring[rx_id]); + } + dma_addr = +rte_cpu_to_le_64 (rte_mbuf_data_iova_default (nmb)); + rxdp->read.hdr_addr =0 ; + rxdp->read.pkt_addr = dma_addr; + rx_packet_len = (rte_cpu_to_le_16 (rxd.flex_nic_wb.pkt_len) & +VIRTCHNL2_RX_FLEX_DESC_PKT_LEN_M ); + rxm->data_len = rx_packet_len; + rxm->data_off =RTE_PKTMBUF_HEADROOM ; + +/** +* If this is the first buffer of the received packet, set the +* pointer to the first mbuf of the packet and initialize its +* context. Otherwise, update the total length and the number +* of segments of the current scattered packet, and update the +* pointer to the last mbuf of the current packet. +*/ +if (!first_seg) { + first_seg = rxm; + first_seg->nb_segs =1 ; + first_seg->pkt_len = rx_packet_len; + }else { + first_seg->pkt_len = + (uint16_t )(first_seg->pkt_len + + rx_packet_len); + first_seg->nb_segs++; + last_seg->next = rxm; + } + +if (!(rx_status0 & (1 <<VIRTCHNL2_RX_FLEX_DESC_STATUS0_EOF_S ))) { + last_seg = rxm; +continue ; + } + + rxm->next =NULL ; + + first_seg->port = rxq->port_id; + first_seg->ol_flags =0 ; + pkt_flags =idpf_rxd_to_pkt_flags (rx_status0); + first_seg->packet_type = + ptype_tbl[(uint8_t )(rte_cpu_to_le_16 (rxd.flex_nic_wb.ptype_flex_flags0) & +VIRTCHNL2_RX_FLEX_DESC_PTYPE_M )]; + +if (idpf_timestamp_dynflag >0 && + (rxq->offloads &IDPF_RX_OFFLOAD_TIMESTAMP ) !=0 ) { +/* timestamp */ + ts_ns =idpf_tstamp_convert_32b_64b (ad, + rxq->hw_register_set, +rte_le_to_cpu_32 (rxd.flex_nic_wb.flex_ts.ts_high)); + rxq->hw_register_set =0 ; + *RTE_MBUF_DYNFIELD (rxm, + idpf_timestamp_dynfield_offset, + rte_mbuf_timestamp_t *) = ts_ns; + first_seg->ol_flags |= idpf_timestamp_dynflag; + } + + first_seg->ol_flags |= pkt_flags; +rte_prefetch0 (RTE_PTR_ADD (first_seg->buf_addr, + first_seg->data_off)); + rx_pkts[nb_rx++] = first_seg; + first_seg =NULL ; + } + rxq->rx_tail = rx_id; + rxq->pkt_first_seg = first_seg; + rxq->pkt_last_seg = last_seg; + +idpf_update_rx_tail (rxq, nb_hold, rx_id); + +return nb_rx; +} +static inline int idpf_xmit_cleanup (struct idpf_tx_queue *txq) {
drivers/common/idpf/idpf_common_rxtx.h +3 -0
@@ -293,5 +293,8 @@ uint16_t idpf_dp_singleq_xmit_pkts_avx512(void *tx_queue,__rte_internal uint16_t idpf_dp_splitq_xmit_pkts_avx512(void *tx_queue, struct rte_mbuf **tx_pkts,uint16_t nb_pkts); +__rte_internal +uint16_t idpf_dp_singleq_recv_scatter_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, +uint16_t nb_pkts);#endif /* _IDPF_COMMON_RXTX_H_ */
drivers/common/idpf/version.map +1 -0
@@ -7,6 +7,7 @@ INTERNAL { idpf_dp_prep_pkts; idpf_dp_singleq_recv_pkts; idpf_dp_singleq_recv_pkts_avx512; + idpf_dp_singleq_recv_scatter_pkts; idpf_dp_singleq_xmit_pkts; idpf_dp_singleq_xmit_pkts_avx512; idpf_dp_splitq_recv_pkts;
drivers/net/idpf/idpf_ethdev.c +2 -1
@@ -119,7 +119,8 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)RTE_ETH_RX_OFFLOAD_UDP_CKSUM |RTE_ETH_RX_OFFLOAD_TCP_CKSUM |RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM | -RTE_ETH_RX_OFFLOAD_TIMESTAMP ; +RTE_ETH_RX_OFFLOAD_TIMESTAMP | +RTE_ETH_RX_OFFLOAD_SCATTER ; dev_info->tx_offload_capa = RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
drivers/net/idpf/idpf_rxtx.c +28 -0
@@ -503,6 +503,8 @@ int idpf_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id) {struct idpf_rx_queue *rxq; +uint16_t max_pkt_len; +uint32_t frame_size;int err;if (rx_queue_id >= dev->data->nb_rx_queues)
@@ -516,6 +518,17 @@ idpf_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id)return -EINVAL ; } + frame_size = dev->data->mtu +IDPF_ETH_OVERHEAD ; + + max_pkt_len = +RTE_MIN ((uint32_t )IDPF_SUPPORT_CHAIN_NUM * rxq->rx_buf_len, + frame_size); + + rxq->max_pkt_len = max_pkt_len; +if ((dev->data->dev_conf.rxmode.offloads &RTE_ETH_RX_OFFLOAD_SCATTER ) || + frame_size > rxq->rx_buf_len) + dev->data->scattered_rx =1 ; + err =idpf_qc_ts_mbuf_register (rxq);if (err !=0 ) { PMD_DRV_LOG(ERR, "fail to residter timestamp mbuf %u",
@@ -807,6 +820,14 @@ idpf_set_rx_function(struct rte_eth_dev *dev) }#endif /* CC_AVX512_SUPPORT */ } + +if (dev->data->scattered_rx) { +PMD_DRV_LOG (NOTICE , +"Using Single Scalar Scatterd Rx (port %d)." , + dev->data->port_id); + dev->rx_pkt_burst = idpf_dp_singleq_recv_scatter_pkts; +return ; + }PMD_DRV_LOG (NOTICE ,"Using Single Scalar Rx (port %d)." , dev->data->port_id);
@@ -819,6 +840,13 @@ idpf_set_rx_function(struct rte_eth_dev *dev) dev->data->port_id); dev->rx_pkt_burst = idpf_dp_splitq_recv_pkts; }else { +if (dev->data->scattered_rx) { +PMD_DRV_LOG (NOTICE , +"Using Single Scalar Scatterd Rx (port %d)." , + dev->data->port_id); + dev->rx_pkt_burst = idpf_dp_singleq_recv_scatter_pkts; +return ; + }PMD_DRV_LOG (NOTICE ,"Using Single Scalar Rx (port %d)." , dev->data->port_id);
drivers/net/idpf/idpf_rxtx.h +2 -0
@@ -23,6 +23,8 @@#define IDPF_DEFAULT_TX_RS_THRESH 32#define IDPF_DEFAULT_TX_FREE_THRESH 32 +#define IDPF_SUPPORT_CHAIN_NUM 5 + int idpf_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, uint16_t nb_desc, unsigned int socket_id, const struct rte_eth_rxconf *rx_conf,
Signature · 1 line
2.25.1
PATCH v4 4/6 common/idpf: add rss_offload hash in singleq rx
In reply to Mingxia LiuThis patch add rss valid flag and hash value parsing of rx descriptor.
--- drivers/common/idpf/idpf_common_rxtx.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/common/idpf/idpf_common_rxtx.c +16 -0
@@ -1030,6 +1030,20 @@ idpf_update_rx_tail(struct idpf_rx_queue *rxq, uint16_t nb_hold, rxq->nb_rx_hold = nb_hold; } +static inline void +idpf_singleq_rx_rss_offload (struct rte_mbuf *mb, +volatile struct virtchnl2_rx_flex_desc_nic *rx_desc, +uint64_t *pkt_flags) +{ +uint16_t rx_status0 =rte_le_to_cpu_16 (rx_desc->status_error0); + +if (rx_status0 &RTE_BIT32 (VIRTCHNL2_RX_FLEX_DESC_STATUS0_RSS_VALID_S )) { + *pkt_flags |=RTE_MBUF_F_RX_RSS_HASH ; + mb->hash.rss =rte_le_to_cpu_32 (rx_desc->rss_hash); + } + +} +uint16_t idpf_dp_singleq_recv_pkts (void *rx_queue,struct rte_mbuf **rx_pkts,uint16_t nb_pkts)
@@ -1118,6 +1132,7 @@ idpf_dp_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, rxm->port = rxq->port_id; rxm->ol_flags =0 ; pkt_flags =idpf_rxd_to_pkt_flags (rx_status0); +idpf_singleq_rx_rss_offload (rxm, &rxd.flex_nic_wb, &pkt_flags); rxm->packet_type = ptype_tbl[(uint8_t )(rte_cpu_to_le_16 (rxd.flex_nic_wb.ptype_flex_flags0) &VIRTCHNL2_RX_FLEX_DESC_PTYPE_M )];
@@ -1249,6 +1264,7 @@ idpf_dp_singleq_recv_scatter_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, first_seg->port = rxq->port_id; first_seg->ol_flags =0 ; pkt_flags =idpf_rxd_to_pkt_flags (rx_status0); +idpf_singleq_rx_rss_offload (first_seg, &rxd.flex_nic_wb, &pkt_flags); first_seg->packet_type = ptype_tbl[(uint8_t )(rte_cpu_to_le_16 (rxd.flex_nic_wb.ptype_flex_flags0) &VIRTCHNL2_RX_FLEX_DESC_PTYPE_M )];
Signature · 1 line
2.25.1
PATCH v4 5/6 common/idpf: add alarm to support handle vchnl message
In reply to Mingxia LiuHandle virtual channel message.
Refine link status update.
--- drivers/common/idpf/idpf_common_device.h | 5 + drivers/common/idpf/idpf_common_virtchnl.c | 33 ++-- drivers/common/idpf/idpf_common_virtchnl.h | 6 + drivers/common/idpf/version.map | 2 + drivers/net/idpf/idpf_ethdev.c | 169 ++++++++++++++++++++- drivers/net/idpf/idpf_ethdev.h | 2 + 6 files changed, 195 insertions(+), 22 deletions(-)
drivers/common/idpf/idpf_common_device.h +5 -0
@@ -118,6 +118,11 @@ struct idpf_vport {bool tx_use_avx512;struct virtchnl2_vport_stats eth_stats_offset; + +void *dev; +/* Event from ipf */ +bool link_up; +uint32_t link_speed; };/* Message type read in virtual channel from PF */
drivers/common/idpf/idpf_common_virtchnl.c +14 -19
@@ -202,25 +202,6 @@ idpf_vc_cmd_execute(struct idpf_adapter *adapter, struct idpf_cmd_info *args)switch (args->ops) {case VIRTCHNL_OP_VERSION :case VIRTCHNL2_OP_GET_CAPS : -case VIRTCHNL2_OP_CREATE_VPORT : -case VIRTCHNL2_OP_DESTROY_VPORT : -case VIRTCHNL2_OP_SET_RSS_KEY : -case VIRTCHNL2_OP_SET_RSS_LUT : -case VIRTCHNL2_OP_SET_RSS_HASH : -case VIRTCHNL2_OP_CONFIG_RX_QUEUES : -case VIRTCHNL2_OP_CONFIG_TX_QUEUES : -case VIRTCHNL2_OP_ENABLE_QUEUES : -case VIRTCHNL2_OP_DISABLE_QUEUES : -case VIRTCHNL2_OP_ENABLE_VPORT : -case VIRTCHNL2_OP_DISABLE_VPORT : -case VIRTCHNL2_OP_MAP_QUEUE_VECTOR : -case VIRTCHNL2_OP_UNMAP_QUEUE_VECTOR : -case VIRTCHNL2_OP_ALLOC_VECTORS : -case VIRTCHNL2_OP_DEALLOC_VECTORS : -case VIRTCHNL2_OP_GET_STATS : -case VIRTCHNL2_OP_GET_RSS_KEY : -case VIRTCHNL2_OP_GET_RSS_HASH : -case VIRTCHNL2_OP_GET_RSS_LUT :/* for init virtchnl ops, need to poll the response */ err =idpf_vc_one_msg_read (adapter, args->ops, args->out_size, args->out_buffer);clear_cmd (adapter);
@@ -1111,3 +1092,17 @@ idpf_vc_txq_config(struct idpf_vport *vport, struct idpf_tx_queue *txq)return err; } + +int +idpf_vc_ctlq_recv (struct idpf_ctlq_info *cq,u16 *num_q_msg, +struct idpf_ctlq_msg *q_msg) +{ +return idpf_ctlq_recv (cq, num_q_msg, q_msg); +} + +int +idpf_vc_ctlq_post_rx_buffs (struct idpf_hw *hw,struct idpf_ctlq_info *cq, +u16 *buff_count,struct idpf_dma_mem **buffs) +{ +return idpf_ctlq_post_rx_buffs (hw, cq, buff_count, buffs); +}
drivers/common/idpf/idpf_common_virtchnl.h +6 -0
@@ -58,4 +58,10 @@ __rte_internalint idpf_vc_rss_lut_get (struct idpf_vport *vport);__rte_internal int idpf_vc_rss_hash_get(struct idpf_vport *vport); +__rte_internal +int idpf_vc_ctlq_recv(struct idpf_ctlq_info *cq, u16 *num_q_msg, +struct idpf_ctlq_msg *q_msg); +__rte_internal +int idpf_vc_ctlq_post_rx_buffs(struct idpf_hw *hw, struct idpf_ctlq_info *cq, +u16 *buff_count,struct idpf_dma_mem **buffs);#endif /* _IDPF_COMMON_VIRTCHNL_H_ */
drivers/common/idpf/version.map +2 -0
@@ -38,6 +38,8 @@ INTERNAL { idpf_vc_api_version_check; idpf_vc_caps_get; idpf_vc_cmd_execute; + idpf_vc_ctlq_post_rx_buffs; + idpf_vc_ctlq_recv; idpf_vc_irq_map_unmap_config; idpf_vc_one_msg_read; idpf_vc_ptype_info_query;
drivers/net/idpf/idpf_ethdev.c +166 -3
210 lines not on this page · raw message
drivers/net/idpf/idpf_ethdev.h +2 -0
@@ -53,6 +53,8 @@#define IDPF_ADAPTER_NAME_LEN (PCI_PRI_STR_SIZE + 1) +#define IDPF_ALARM_INTERVAL 50000/* us */ +struct idpf_vport_param {struct idpf_adapter_ext *adapter;uint16_t devarg_id;/* arg id from user */
Signature · 1 line
2.25.1
PATCH v4 6/6 common/idpf: add xstats ops
In reply to Mingxia LiuAdd support for these device ops:
-idpf_dev_xstats_get
-idpf_dev_xstats_get_names
-idpf_dev_xstats_reset
--- drivers/net/idpf/idpf_ethdev.c | 80 ++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+)
drivers/net/idpf/idpf_ethdev.c +80 -0
@@ -80,6 +80,30 @@ static const uint64_t idpf_ipv6_rss = RTE_ETH_RSS_NONFRAG_IPV6_UDP |RTE_ETH_RSS_NONFRAG_IPV6_OTHER |RTE_ETH_RSS_FRAG_IPV6 ; +struct rte_idpf_xstats_name_off { +char name[RTE_ETH_XSTATS_NAME_SIZE ]; +unsigned int offset; +}; + +static const struct rte_idpf_xstats_name_off rte_idpf_stats_strings[] = { + {"rx_bytes" , offsetof(struct virtchnl2_vport_stats , rx_bytes)}, + {"rx_unicast_packets" , offsetof(struct virtchnl2_vport_stats , rx_unicast)}, + {"rx_multicast_packets" , offsetof(struct virtchnl2_vport_stats , rx_multicast)}, + {"rx_broadcast_packets" , offsetof(struct virtchnl2_vport_stats , rx_broadcast)}, + {"rx_dropped_packets" , offsetof(struct virtchnl2_vport_stats , rx_discards)}, + {"rx_errors" , offsetof(struct virtchnl2_vport_stats , rx_errors)}, + {"rx_unknown_protocol_packets" , offsetof(struct virtchnl2_vport_stats , + rx_unknown_protocol)}, + {"tx_bytes" , offsetof(struct virtchnl2_vport_stats , tx_bytes)}, + {"tx_unicast_packets" , offsetof(struct virtchnl2_vport_stats , tx_unicast)}, + {"tx_multicast_packets" , offsetof(struct virtchnl2_vport_stats , tx_multicast)}, + {"tx_broadcast_packets" , offsetof(struct virtchnl2_vport_stats , tx_broadcast)}, + {"tx_dropped_packets" , offsetof(struct virtchnl2_vport_stats , tx_discards)}, + {"tx_error_packets" , offsetof(struct virtchnl2_vport_stats , tx_errors)}}; + +#define IDPF_NB_XSTATS (sizeof(rte_idpf_stats_strings) / \ + sizeof(rte_idpf_stats_strings[0])) +static int idpf_dev_link_update (struct rte_eth_dev *dev, __rte_unused int wait_to_complete)
@@ -313,6 +337,59 @@ idpf_dev_stats_reset(struct rte_eth_dev *dev)return 0 ; } +static int idpf_dev_xstats_reset (struct rte_eth_dev *dev) +{ +idpf_dev_stats_reset (dev); +return 0 ; +} + +static int idpf_dev_xstats_get (struct rte_eth_dev *dev, +struct rte_eth_xstat *xstats,unsigned int n) +{ +struct idpf_vport *vport = + (struct idpf_vport *)dev->data->dev_private; +struct virtchnl2_vport_stats *pstats =NULL ; +unsigned int i; +int ret; + +if (n <IDPF_NB_XSTATS ) +return IDPF_NB_XSTATS ; + +if (!xstats) +return 0 ; + + ret =idpf_vc_stats_query (vport, &pstats); +if (ret) { +PMD_DRV_LOG (ERR ,"Get statistics failed" ); +return 0 ; + } + +idpf_vport_stats_update (&vport->eth_stats_offset, pstats); + +/* loop over xstats array and values from pstats */ +for (i =0 ; i <IDPF_NB_XSTATS ; i++) { + xstats[i].id = i; + xstats[i].value = *(uint64_t *)(((char *)pstats) + + rte_idpf_stats_strings[i].offset); + } +return IDPF_NB_XSTATS ; +} + +static int idpf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, +struct rte_eth_xstat_name *xstats_names, + __rte_unused unsigned int limit) +{ +unsigned int i; + +if (xstats_names) +for (i =0 ; i <IDPF_NB_XSTATS ; i++) { +snprintf (xstats_names[i].name, +sizeof (xstats_names[i].name), +"%s" , rte_idpf_stats_strings[i].name); + } +return IDPF_NB_XSTATS ; +} +static int idpf_config_rss_hf (struct idpf_vport *vport,uint64_t rss_hf) {uint64_t hena =0 ;
@@ -1122,6 +1199,9 @@ static const struct eth_dev_ops idpf_eth_dev_ops = { .reta_query = idpf_rss_reta_query, .rss_hash_update = idpf_rss_hash_update, .rss_hash_conf_get = idpf_rss_hash_conf_get, + .xstats_get = idpf_dev_xstats_get, + .xstats_get_names = idpf_dev_xstats_get_names, + .xstats_reset = idpf_dev_xstats_reset, }; static uint16_t
Signature · 1 line
2.25.1
v4 cover add idpf pmd enhancement features
In reply to Mingxia LiuThis patchset add several enhancement features of idpf pmd. Including the following:
- add hw statistics, support stats/xstats ops
- add rss configure/show ops
- add event handle: link status
- add scattered data path for single queue
This patchset is based on the refactor idpf PMD code:
http://patches.dpdk.org/project/dpdk/patch/[email protected]/
v2 changes:
- Fix rss lut config issue.
v3 changes:
- rebase to the new baseline.
v4 changes:
- rebase to the new baseline.
- optimize some code
- give "not supported" tips when user want to config rss hash type
- if stats reset fails at initialization time, don't rollback, just print ERROR info.
v5 changes:
- fix some spelling error
Mingxia Liu (6):
common/idpf: add hw statistics
common/idpf: add RSS set/get ops
common/idpf: support single q scatter RX datapath common/idpf: add rss_offload hash in singleq rx common/idpf: add alarm to support handle vchnl message common/idpf: add xstats ops
drivers/common/idpf/idpf_common_device.c | 17 + drivers/common/idpf/idpf_common_device.h | 10 + drivers/common/idpf/idpf_common_rxtx.c | 151 +++++ drivers/common/idpf/idpf_common_rxtx.h | 3 + drivers/common/idpf/idpf_common_virtchnl.c | 171 +++++- drivers/common/idpf/idpf_common_virtchnl.h | 15 + drivers/common/idpf/version.map | 8 + drivers/net/idpf/idpf_ethdev.c | 606 ++++++++++++++++++++- drivers/net/idpf/idpf_ethdev.h | 5 +- drivers/net/idpf/idpf_rxtx.c | 28 + drivers/net/idpf/idpf_rxtx.h | 2 + 11 files changed, 996 insertions(+), 20 deletions(-)
Signature · 1 line
2.25.1
PATCH v5 1/6 common/idpf: add hw statistics
This patch add hardware packets/bytes statistics.
--- drivers/common/idpf/idpf_common_device.c | 17 +++++ drivers/common/idpf/idpf_common_device.h | 4 + drivers/common/idpf/idpf_common_virtchnl.c | 27 +++++++ drivers/common/idpf/idpf_common_virtchnl.h | 3 + drivers/common/idpf/version.map | 2 + drivers/net/idpf/idpf_ethdev.c | 86 ++++++++++++++++++++++ 6 files changed, 139 insertions(+)
drivers/common/idpf/idpf_common_device.c +17 -0
@@ -652,4 +652,21 @@ idpf_vport_info_init(struct idpf_vport *vport,return 0 ; } +void +idpf_vport_stats_update (struct virtchnl2_vport_stats *oes,struct virtchnl2_vport_stats *nes) +{ + nes->rx_bytes = nes->rx_bytes - oes->rx_bytes; + nes->rx_unicast = nes->rx_unicast - oes->rx_unicast; + nes->rx_multicast = nes->rx_multicast - oes->rx_multicast; + nes->rx_broadcast = nes->rx_broadcast - oes->rx_broadcast; + nes->rx_errors = nes->rx_errors - oes->rx_errors; + nes->rx_discards = nes->rx_discards - oes->rx_discards; + nes->tx_bytes = nes->tx_bytes - oes->tx_bytes; + nes->tx_unicast = nes->tx_unicast - oes->tx_unicast; + nes->tx_multicast = nes->tx_multicast - oes->tx_multicast; + nes->tx_broadcast = nes->tx_broadcast - oes->tx_broadcast; + nes->tx_errors = nes->tx_errors - oes->tx_errors; + nes->tx_discards = nes->tx_discards - oes->tx_discards; +} +RTE_LOG_REGISTER_SUFFIX (idpf_common_logtype, common,NOTICE );
drivers/common/idpf/idpf_common_device.h +4 -0
@@ -115,6 +115,8 @@ struct idpf_vport {bool tx_vec_allowed;bool rx_use_avx512;bool tx_use_avx512; + +struct virtchnl2_vport_stats eth_stats_offset; };/* Message type read in virtual channel from PF */
@@ -191,5 +193,7 @@ int idpf_vport_irq_unmap_config(struct idpf_vport *vport, uint16_t nb_rx_queues)__rte_internal int idpf_vport_info_init(struct idpf_vport *vport,struct virtchnl2_create_vport *vport_info); +__rte_internal +void idpf_vport_stats_update(struct virtchnl2_vport_stats *oes, struct virtchnl2_vport_stats *nes);#endif /* _IDPF_COMMON_DEVICE_H_ */
drivers/common/idpf/idpf_common_virtchnl.c +27 -0
@@ -217,6 +217,7 @@ idpf_vc_cmd_execute(struct idpf_adapter *adapter, struct idpf_cmd_info *args)case VIRTCHNL2_OP_UNMAP_QUEUE_VECTOR :case VIRTCHNL2_OP_ALLOC_VECTORS :case VIRTCHNL2_OP_DEALLOC_VECTORS : +case VIRTCHNL2_OP_GET_STATS :/* for init virtchnl ops, need to poll the response */ err =idpf_vc_one_msg_read (adapter, args->ops, args->out_size, args->out_buffer);clear_cmd (adapter);
@@ -806,6 +807,32 @@ idpf_vc_ptype_info_query(struct idpf_adapter *adapter)return err; } +int +idpf_vc_stats_query (struct idpf_vport *vport, +struct virtchnl2_vport_stats **pstats) +{ +struct idpf_adapter *adapter = vport->adapter; +struct virtchnl2_vport_stats vport_stats; +struct idpf_cmd_info args; +int err; + + vport_stats.vport_id = vport->vport_id; + args.ops =VIRTCHNL2_OP_GET_STATS ; + args.in_args = (u8 *)&vport_stats; + args.in_args_size =sizeof (vport_stats); + args.out_buffer = adapter->mbx_resp; + args.out_size =IDPF_DFLT_MBX_BUF_SIZE ; + + err =idpf_vc_cmd_execute (adapter, &args); +if (err) { +DRV_LOG (ERR ,"Failed to execute command of VIRTCHNL2_OP_GET_STATS" ); + *pstats =NULL ; +return err; + } + *pstats = (struct virtchnl2_vport_stats *)args.out_buffer; +return 0 ; +} +#define IDPF_RX_BUF_STRIDE 64int idpf_vc_rxq_config (struct idpf_vport *vport,struct idpf_rx_queue *rxq)
drivers/common/idpf/idpf_common_virtchnl.h +3 -0
@@ -49,4 +49,7 @@ __rte_internalint idpf_vc_rxq_config (struct idpf_vport *vport,struct idpf_rx_queue *rxq);__rte_internal int idpf_vc_txq_config(struct idpf_vport *vport, struct idpf_tx_queue *txq); +__rte_internal +int idpf_vc_stats_query(struct idpf_vport *vport, +struct virtchnl2_vport_stats **pstats);#endif /* _IDPF_COMMON_VIRTCHNL_H_ */
drivers/common/idpf/version.map +2 -0
@@ -46,6 +46,7 @@ INTERNAL { idpf_vc_rss_key_set; idpf_vc_rss_lut_set; idpf_vc_rxq_config; + idpf_vc_stats_query; idpf_vc_txq_config; idpf_vc_vectors_alloc; idpf_vc_vectors_dealloc;
@@ -59,6 +60,7 @@ INTERNAL { idpf_vport_irq_map_config; idpf_vport_irq_unmap_config; idpf_vport_rss_config; + idpf_vport_stats_update; local: *; };
drivers/net/idpf/idpf_ethdev.c +86 -0
104 lines not on this page · raw message
Signature · 1 line
2.25.1
v6 cover add idpf pmd enhancement features
This patchset add several enhancement features of idpf pmd. Including the following:
- add hw statistics, support stats/xstats ops
- add rss configure/show ops
- add event handle: link status
- add scattered data path for single queue
This patchset is based on the refactor idpf PMD code:
http://patches.dpdk.org/project/dpdk/patch/[email protected]/
v2 changes:
- Fix rss lut config issue.
v3 changes:
- rebase to the new baseline.
v4 changes:
- rebase to the new baseline.
- optimize some code
- give "not supported" tips when user want to config rss hash type
- if stats reset fails at initialization time, don't rollback, just print ERROR info.
v5 changes:
- fix some spelling error
v6 changes:
- add cover-letter
Mingxia Liu (6):
common/idpf: add hw statistics
common/idpf: add RSS set/get ops
common/idpf: support single q scatter RX datapath common/idpf: add rss_offload hash in singleq rx common/idpf: add alarm to support handle vchnl message common/idpf: add xstats ops
drivers/common/idpf/idpf_common_device.c | 17 + drivers/common/idpf/idpf_common_device.h | 10 + drivers/common/idpf/idpf_common_rxtx.c | 151 +++++ drivers/common/idpf/idpf_common_rxtx.h | 3 + drivers/common/idpf/idpf_common_virtchnl.c | 171 +++++- drivers/common/idpf/idpf_common_virtchnl.h | 15 + drivers/common/idpf/version.map | 8 + drivers/net/idpf/idpf_ethdev.c | 606 ++++++++++++++++++++- drivers/net/idpf/idpf_ethdev.h | 5 +- drivers/net/idpf/idpf_rxtx.c | 28 + drivers/net/idpf/idpf_rxtx.h | 2 + 11 files changed, 996 insertions(+), 20 deletions(-)
Signature · 1 line
2.25.1
PATCH v6 1/6 common/idpf: add hw statistics
This patch add hardware packets/bytes statistics.
--- drivers/common/idpf/idpf_common_device.c | 17 +++++ drivers/common/idpf/idpf_common_device.h | 4 + drivers/common/idpf/idpf_common_virtchnl.c | 27 +++++++ drivers/common/idpf/idpf_common_virtchnl.h | 3 + drivers/common/idpf/version.map | 2 + drivers/net/idpf/idpf_ethdev.c | 86 ++++++++++++++++++++++ 6 files changed, 139 insertions(+)
drivers/common/idpf/idpf_common_device.c +17 -0
@@ -652,4 +652,21 @@ idpf_vport_info_init(struct idpf_vport *vport,return 0 ; } +void +idpf_vport_stats_update (struct virtchnl2_vport_stats *oes,struct virtchnl2_vport_stats *nes) +{ + nes->rx_bytes = nes->rx_bytes - oes->rx_bytes; + nes->rx_unicast = nes->rx_unicast - oes->rx_unicast; + nes->rx_multicast = nes->rx_multicast - oes->rx_multicast; + nes->rx_broadcast = nes->rx_broadcast - oes->rx_broadcast; + nes->rx_errors = nes->rx_errors - oes->rx_errors; + nes->rx_discards = nes->rx_discards - oes->rx_discards; + nes->tx_bytes = nes->tx_bytes - oes->tx_bytes; + nes->tx_unicast = nes->tx_unicast - oes->tx_unicast; + nes->tx_multicast = nes->tx_multicast - oes->tx_multicast; + nes->tx_broadcast = nes->tx_broadcast - oes->tx_broadcast; + nes->tx_errors = nes->tx_errors - oes->tx_errors; + nes->tx_discards = nes->tx_discards - oes->tx_discards; +} +RTE_LOG_REGISTER_SUFFIX (idpf_common_logtype, common,NOTICE );
drivers/common/idpf/idpf_common_device.h +4 -0
@@ -115,6 +115,8 @@ struct idpf_vport {bool tx_vec_allowed;bool rx_use_avx512;bool tx_use_avx512; + +struct virtchnl2_vport_stats eth_stats_offset; };/* Message type read in virtual channel from PF */
@@ -191,5 +193,7 @@ int idpf_vport_irq_unmap_config(struct idpf_vport *vport, uint16_t nb_rx_queues)__rte_internal int idpf_vport_info_init(struct idpf_vport *vport,struct virtchnl2_create_vport *vport_info); +__rte_internal +void idpf_vport_stats_update(struct virtchnl2_vport_stats *oes, struct virtchnl2_vport_stats *nes);#endif /* _IDPF_COMMON_DEVICE_H_ */
drivers/common/idpf/idpf_common_virtchnl.c +27 -0
@@ -217,6 +217,7 @@ idpf_vc_cmd_execute(struct idpf_adapter *adapter, struct idpf_cmd_info *args)case VIRTCHNL2_OP_UNMAP_QUEUE_VECTOR :case VIRTCHNL2_OP_ALLOC_VECTORS :case VIRTCHNL2_OP_DEALLOC_VECTORS : +case VIRTCHNL2_OP_GET_STATS :/* for init virtchnl ops, need to poll the response */ err =idpf_vc_one_msg_read (adapter, args->ops, args->out_size, args->out_buffer);clear_cmd (adapter);
@@ -806,6 +807,32 @@ idpf_vc_ptype_info_query(struct idpf_adapter *adapter)return err; } +int +idpf_vc_stats_query (struct idpf_vport *vport, +struct virtchnl2_vport_stats **pstats) +{ +struct idpf_adapter *adapter = vport->adapter; +struct virtchnl2_vport_stats vport_stats; +struct idpf_cmd_info args; +int err; + + vport_stats.vport_id = vport->vport_id; + args.ops =VIRTCHNL2_OP_GET_STATS ; + args.in_args = (u8 *)&vport_stats; + args.in_args_size =sizeof (vport_stats); + args.out_buffer = adapter->mbx_resp; + args.out_size =IDPF_DFLT_MBX_BUF_SIZE ; + + err =idpf_vc_cmd_execute (adapter, &args); +if (err) { +DRV_LOG (ERR ,"Failed to execute command of VIRTCHNL2_OP_GET_STATS" ); + *pstats =NULL ; +return err; + } + *pstats = (struct virtchnl2_vport_stats *)args.out_buffer; +return 0 ; +} +#define IDPF_RX_BUF_STRIDE 64int idpf_vc_rxq_config (struct idpf_vport *vport,struct idpf_rx_queue *rxq)
drivers/common/idpf/idpf_common_virtchnl.h +3 -0
@@ -49,4 +49,7 @@ __rte_internalint idpf_vc_rxq_config (struct idpf_vport *vport,struct idpf_rx_queue *rxq);__rte_internal int idpf_vc_txq_config(struct idpf_vport *vport, struct idpf_tx_queue *txq); +__rte_internal +int idpf_vc_stats_query(struct idpf_vport *vport, +struct virtchnl2_vport_stats **pstats);#endif /* _IDPF_COMMON_VIRTCHNL_H_ */
drivers/common/idpf/version.map +2 -0
@@ -46,6 +46,7 @@ INTERNAL { idpf_vc_rss_key_set; idpf_vc_rss_lut_set; idpf_vc_rxq_config; + idpf_vc_stats_query; idpf_vc_txq_config; idpf_vc_vectors_alloc; idpf_vc_vectors_dealloc;
@@ -59,6 +60,7 @@ INTERNAL { idpf_vport_irq_map_config; idpf_vport_irq_unmap_config; idpf_vport_rss_config; + idpf_vport_stats_update; local: *; };
drivers/net/idpf/idpf_ethdev.c +86 -0
104 lines not on this page · raw message
Signature · 1 line
2.25.1
RE: [PATCH v6 1/6] common/idpf: add hw statistics
Quoted 9 lines
-----Original Message-----
From: Liu, Mingxia <[email protected]>
Sent: Tuesday, February 7, 2023 6:17 PM
To: [email protected]; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>
Cc: Liu, Mingxia <[email protected]>
Subject: [PATCH v6 1/6] common/idpf: add hw statistics
Suggest to use ./devtools/check-git-log.sh to fix any title warning if possible Also the main purpose of this patch is to support stats_get /stats_reset API, the prefix is more reasonable to be "net/idpf" but not "common/idpf.
Please fix other patches if any similar issue.
Quoted 261 lines
This patch add hardware packets/bytes statistics.
Signed-off-by Mingxia Liu <[email protected]>--- drivers/common/idpf/idpf_common_device.c | 17 +++++ drivers/common/idpf/idpf_common_device.h | 4 + drivers/common/idpf/idpf_common_virtchnl.c | 27 +++++++ drivers/common/idpf/idpf_common_virtchnl.h | 3 + drivers/common/idpf/version.map | 2 + drivers/net/idpf/idpf_ethdev.c | 86 ++++++++++++++++++++++ 6 files changed, 139 insertions(+)drivers/common/idpf/idpf_common_device.c +16
-1@@ -652,4 +652,21 @@ idpf_vport_info_init(struct idpf_vport *vport,return 0 ; } +void +idpf_vport_stats_update (struct virtchnl2_vport_stats *oes,struct +virtchnl2_vport_stats *nes) { + nes->rx_bytes = nes->rx_bytes - oes->rx_bytes; + nes->rx_unicast = nes->rx_unicast - oes->rx_unicast; + nes->rx_multicast = nes->rx_multicast - oes->rx_multicast; + nes->rx_broadcast = nes->rx_broadcast - oes->rx_broadcast; + nes->rx_errors = nes->rx_errors - oes->rx_errors; + nes->rx_discards = nes->rx_discards - oes->rx_discards; + nes->tx_bytes = nes->tx_bytes - oes->tx_bytes; + nes->tx_unicast = nes->tx_unicast - oes->tx_unicast; + nes->tx_multicast = nes->tx_multicast - oes->tx_multicast; + nes->tx_broadcast = nes->tx_broadcast - oes->tx_broadcast; + nes->tx_errors = nes->tx_errors - oes->tx_errors; + nes->tx_discards = nes->tx_discards - oes->tx_discards; } +RTE_LOG_REGISTER_SUFFIX (idpf_common_logtype, common,NOTICE ); diff --git a/drivers/common/idpf/idpf_common_device.h
b/drivers/common/idpf/idpf_common_device.h
index545117df79..1d8e7d405a100644drivers/common/idpf/idpf_common_device.h +2
-0@@ -115,6 +115,8 @@ struct idpf_vport {bool tx_vec_allowed;bool rx_use_avx512;bool tx_use_avx512; + +struct virtchnl2_vport_stats eth_stats_offset; }; /* Message type read in virtual channel from PF */ @@ -191,5 +193,7 @@int
idpf_vport_irq_unmap_config(struct idpf_vport *vport, uint16_t nb_rx_queues)__rte_internalint idpf_vport_info_init(structidpf_vport*vport,drivers/common/idpf/idpf_common_device.h +3
-0struct virtchnl2_create_vport *vport_info); +__rte_internal +void idpf_vport_stats_update(struct virtchnl2_vport_stats *oes, struct +virtchnl2_vport_stats *nes);#endif /* _IDPF_COMMON_DEVICE_H_ */ drivers/common/idpf/idpf_common_virtchnl.c +1
-0@@ -217,6 +217,7 @@ idpf_vc_cmd_execute(struct idpf_adapter *adapter, struct idpf_cmd_info *args)case VIRTCHNL2_OP_UNMAP_QUEUE_VECTOR :case VIRTCHNL2_OP_ALLOC_VECTORS :case VIRTCHNL2_OP_DEALLOC_VECTORS : +case VIRTCHNL2_OP_GET_STATS :/* for init virtchnl ops, need to poll the response */ err = idpf_vc_one_msg_read(adapter, args->ops, args-Quoted 1 line
out_size,args->out_buffer);drivers/common/idpf/idpf_common_virtchnl.c +25
-1clear_cmd (adapter);@@ -806,6 +807,32 @@ idpf_vc_ptype_info_query(struct idpf_adapter *adapter)return err; } +int +idpf_vc_stats_query (struct idpf_vport *vport, +struct virtchnl2_vport_stats **pstats) { +struct idpf_adapter *adapter = vport->adapter; +struct virtchnl2_vport_stats vport_stats; +struct idpf_cmd_info args; +int err; + + vport_stats.vport_id = vport->vport_id; + args.ops =VIRTCHNL2_OP_GET_STATS ; + args.in_args = (u8 *)&vport_stats; + args.in_args_size =sizeof (vport_stats); + args.out_buffer = adapter->mbx_resp; + args.out_size =IDPF_DFLT_MBX_BUF_SIZE ; + + err =idpf_vc_cmd_execute (adapter, &args); +if (err) { +DRV_LOG (ERR ,"Failed to execute command of VIRTCHNL2_OP_GET_STATS"); + *pstats =NULL ; +return err; + } + *pstats = (struct virtchnl2_vport_stats *)args.out_buffer; +return 0 ; +} +#define IDPF_RX_BUF_STRIDE 64 int idpf_vc_rxq_config(struct idpf_vport *vport, struct idpf_rx_queue *rxq) diff - -git a/drivers/common/idpf/idpf_common_virtchnl.h
b/drivers/common/idpf/idpf_common_virtchnl.h
indexc105f02836..6b94fd5b8f100644drivers/common/idpf/idpf_common_virtchnl.h +0
-0@@ -49,4 +49,7 @@ __rte_internalint idpf_vc_rxq_config (struct idpf_vport *vport,struct idpf_rx_queue *rxq);
__rte_internalintidpf_vc_txq_config(struct idpf_vport *vport, struct idpf_tx_queue *txq);drivers/common/idpf/idpf_common_virtchnl.h +3
-0+__rte_internal +int idpf_vc_stats_query(struct idpf_vport *vport, +struct virtchnl2_vport_stats **pstats);#endif /* _IDPF_COMMON_VIRTCHNL_H_ */ (quoted diff) +0
-0b/drivers/common/idpf/version.map index
8b33130bd6..e6a02828ba100644drivers/common/idpf/version.map +2
-0@@ -46,6 +46,7 @@ INTERNAL { idpf_vc_rss_key_set; idpf_vc_rss_lut_set; idpf_vc_rxq_config; + idpf_vc_stats_query; idpf_vc_txq_config; idpf_vc_vectors_alloc; idpf_vc_vectors_dealloc;@@ -59,6 +60,7 @@ INTERNAL { idpf_vport_irq_map_config; idpf_vport_irq_unmap_config; idpf_vport_rss_config; + idpf_vport_stats_update; local: *; };drivers/net/idpf/idpf_ethdev.c +26
-0@@ -140,6 +140,87 @@ idpf_dev_supported_ptypes_get(struct rte_eth_dev *dev __rte_unused)return ptypes; } +static uint64_t +idpf_get_mbuf_alloc_failed_stats (struct rte_eth_dev *dev) { +uint64_t mbuf_alloc_failed =0 ; +struct idpf_rx_queue *rxq; +int i =0 ; + +for (i =0 ; i < dev->data->nb_rx_queues; i++) { + rxq = dev->data->rx_queues[i]; + mbuf_alloc_failed +=__atomic_load_n (&rxq- >rx_stats.mbuf_alloc_failed, + __ATOMIC_RELAXED); + } + +return mbuf_alloc_failed; +} + +static int +idpf_dev_stats_get (struct rte_eth_dev *dev,struct rte_eth_stats +*stats) { +struct idpf_vport *vport = + (struct idpf_vport *)dev->data->dev_private; +struct virtchnl2_vport_stats *pstats =NULL ; +int ret; + + ret =idpf_vc_stats_query (vport, &pstats); +if (ret ==0 ) { + uint8_t crc_stats_len = (dev->data-Quoted 1 line
dev_conf.rxmode.offloads &
drivers/net/idpf/idpf_ethdev.c +1
-0+ RTE_ETH_RX_OFFLOAD_KEEP_CRC) ?0 :
drivers/net/idpf/idpf_ethdev.c +6
-0+RTE_ETHER_CRC_LEN ; + +idpf_vport_stats_update (&vport->eth_stats_offset, pstats); + stats->ipackets = pstats->rx_unicast + pstats->rx_multicast + + pstats->rx_broadcast - pstats->rx_discards; + stats->opackets = pstats->tx_broadcast + pstats-Quoted 1 line
tx_multicast+drivers/net/idpf/idpf_ethdev.c +8
-0+ pstats->tx_unicast; + stats->imissed = pstats->rx_discards; + stats->oerrors = pstats->tx_errors + pstats->tx_discards; + stats->ibytes = pstats->rx_bytes; + stats->ibytes -= stats->ipackets * crc_stats_len; + stats->obytes = pstats->tx_bytes; + + dev->data->rx_mbuf_alloc_failed =
idpf_get_mbuf_alloc_failed_stats(dev);drivers/net/idpf/idpf_ethdev.c +15
-0+ stats->rx_nombuf = dev->data->rx_mbuf_alloc_failed; + }else { +PMD_DRV_LOG (ERR ,"Get statistics failed" ); + } +return ret; +} + +static void +idpf_reset_mbuf_alloc_failed_stats (struct rte_eth_dev *dev) { +struct idpf_rx_queue *rxq; +int i; + +for (i =0 ; i < dev->data->nb_rx_queues; i++) { + rxq = dev->data->rx_queues[i]; + __atomic_store_n(&rxq->rx_stats.mbuf_alloc_failed, 0,
__ATOMIC_RELAXED);drivers/net/idpf/idpf_ethdev.c +22
-0+ } +} + +static int +idpf_dev_stats_reset (struct rte_eth_dev *dev) { +struct idpf_vport *vport = + (struct idpf_vport *)dev->data->dev_private; +struct virtchnl2_vport_stats *pstats =NULL ; +int ret; + + ret =idpf_vc_stats_query (vport, &pstats); +if (ret !=0 ) +return ret; + +/* set stats offset base on current values */ + vport->eth_stats_offset = *pstats; + +idpf_reset_mbuf_alloc_failed_stats (dev); + +return 0 ; +} +static int idpf_init_rss(struct idpf_vport *vport) { @@ -327,6 +408,9 @@
idpf_dev_start(struct rte_eth_dev *dev)drivers/net/idpf/idpf_ethdev.c +5
-1goto err_vport; } +if (idpf_dev_stats_reset (dev)) +PMD_DRV_LOG (ERR ,"Failed to reset stats" ); + vport->stopped =0 ;return 0 ;@@ -606,6 +690,8 @@ static const struct eth_dev_ops idpf_eth_dev_ops = { .tx_queue_release = idpf_dev_tx_queue_release, .mtu_set = idpf_dev_mtu_set, .dev_supported_ptypes_get = idpf_dev_supported_ptypes_get, + .stats_get = idpf_dev_stats_get, + .stats_reset = idpf_dev_stats_reset, }; static uint16_t --2.25.1
RE: [PATCH v6 1/6] common/idpf: add hw statistics
Thanks, will update module name.
And there is no warning when checked by ./devtools/check-git-log.sh.
Quoted 288 lines
-----Original Message-----
From: Zhang, Qi Z <[email protected]>
Sent: Wednesday, February 8, 2023 10:00 AM
To: Liu, Mingxia <[email protected]>; [email protected]; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>
Subject: RE: [PATCH v6 1/6] common/idpf: add hw statisticsQuoted 7 lines
-----Original Message-----
From: Liu, Mingxia <[email protected]>
Sent: Tuesday, February 7, 2023 6:17 PM
To: [email protected]; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>
Cc: Liu, Mingxia <[email protected]>
Subject: [PATCH v6 1/6] common/idpf: add hw statisticsSuggest to use
./devtools/check-git-log.shto fix any title warning if possible Also the main purpose of this patch is to supportstats_get/stats_reset API, the prefix is more reasonable to be "net/idpf" but not "common/idpf.Please fix other patches if any similar issue.
Quoted 29 lines
This patch add hardware packets/bytes statistics.
Signed-off-by Mingxia Liu <[email protected]>--- drivers/common/idpf/idpf_common_device.c | 17 +++++ drivers/common/idpf/idpf_common_device.h | 4 + drivers/common/idpf/idpf_common_virtchnl.c | 27 +++++++ drivers/common/idpf/idpf_common_virtchnl.h | 3 + drivers/common/idpf/version.map | 2 + drivers/net/idpf/idpf_ethdev.c | 86 ++++++++++++++++++++++ 6 files changed, 139 insertions(+)drivers/common/idpf/idpf_common_device.c +7
-0@@ -652,4 +652,21 @@ idpf_vport_info_init(struct idpf_vport *vport,return 0 ; } +void +idpf_vport_stats_update (struct virtchnl2_vport_stats *oes,struct +virtchnl2_vport_stats *nes) { + nes->rx_bytes = nes->rx_bytes - oes->rx_bytes; + nes->rx_unicast = nes->rx_unicast - oes->rx_unicast; + nes->rx_multicast = nes->rx_multicast - oes->rx_multicast; + nes->rx_broadcast = nes->rx_broadcast - oes->rx_broadcast;drivers/common/idpf/idpf_common_device.c idpf_vport_info_init(struct idpf_vport *vport, · line 671
Quoted 10 lines
drivers/common/idpf/idpf_common_device.c +9
-0+ nes->rx_errors = nes->rx_errors - oes->rx_errors; + nes->rx_discards = nes->rx_discards - oes->rx_discards; + nes->tx_bytes = nes->tx_bytes - oes->tx_bytes; + nes->tx_unicast = nes->tx_unicast - oes->tx_unicast; + nes->tx_multicast = nes->tx_multicast - oes->tx_multicast; + nes->tx_broadcast = nes->tx_broadcast - oes->tx_broadcast; + nes->tx_errors = nes->tx_errors - oes->tx_errors; + nes->tx_discards = nes->tx_discards - oes->tx_discards; } +RTE_LOG_REGISTER_SUFFIX (idpf_common_logtype, common,NOTICE );diff
drivers/common/idpf/idpf_common_virtchnl.c idpf_vc_cmd_execute(struct idpf_adapter
Quoted 29 lines
--git
a/drivers/common/idpf/idpf_common_device.hb/drivers/common/idpf/idpf_common_device.hindex545117df79..1d8e7d405a100644drivers/common/idpf/idpf_common_device.h +2
-0@@ -115,6 +115,8 @@ struct idpf_vport {bool tx_vec_allowed;bool rx_use_avx512;bool tx_use_avx512; + +struct virtchnl2_vport_stats eth_stats_offset; }; /* Message type read in virtual channel from PF */ @@ -191,5 +193,7@@ int
idpf_vport_irq_unmap_config(struct idpf_vport *vport, uint16_t nb_rx_queues)__rte_internalint idpf_vport_info_init(structidpf_vport*vport,drivers/common/idpf/idpf_common_device.h +3
-0struct virtchnl2_create_vport *vport_info); +__rte_internal +void idpf_vport_stats_update(struct virtchnl2_vport_stats *oes, +struct virtchnl2_vport_stats *nes);#endif /* _IDPF_COMMON_DEVICE_H_ */ drivers/common/idpf/idpf_common_virtchnl.c +0
-0@@ -217,6 +217,7 @@ idpf_vc_cmd_execute(struct idpf_adapter*adapter,
drivers/net/idpf/idpf_ethdev.c idpf_dev_supported_ptypes_get(struct
Quoted 82 lines
drivers/common/idpf/idpf_common_virtchnl.c +1
-0struct idpf_cmd_info *args)case VIRTCHNL2_OP_UNMAP_QUEUE_VECTOR :case VIRTCHNL2_OP_ALLOC_VECTORS :case VIRTCHNL2_OP_DEALLOC_VECTORS : +case VIRTCHNL2_OP_GET_STATS :/* for init virtchnl ops, need to poll the response */ err = idpf_vc_one_msg_read(adapter, args->ops, args-Quoted 1 line
out_size,args->out_buffer);drivers/common/idpf/idpf_common_virtchnl.c +25
-0clear_cmd (adapter);@@ -806,6 +807,32 @@ idpf_vc_ptype_info_query(struct idpf_adapter *adapter)return err; } +int +idpf_vc_stats_query (struct idpf_vport *vport, +struct virtchnl2_vport_stats **pstats) { +struct idpf_adapter *adapter = vport->adapter; +struct virtchnl2_vport_stats vport_stats; +struct idpf_cmd_info args; +int err; + + vport_stats.vport_id = vport->vport_id; + args.ops =VIRTCHNL2_OP_GET_STATS ; + args.in_args = (u8 *)&vport_stats; + args.in_args_size =sizeof (vport_stats); + args.out_buffer = adapter->mbx_resp; + args.out_size =IDPF_DFLT_MBX_BUF_SIZE ; + + err =idpf_vc_cmd_execute (adapter, &args); +if (err) { +DRV_LOG (ERR ,"Failed to execute command of VIRTCHNL2_OP_GET_STATS"); + *pstats =NULL ; +return err; + } + *pstats = (struct virtchnl2_vport_stats *)args.out_buffer; +return 0 ; +} +#define IDPF_RX_BUF_STRIDE 64int idpf_vc_rxq_config(struct idpf_vport *vport, struct idpf_rx_queue*rxq) diff - -git
a/drivers/common/idpf/idpf_common_virtchnl.hb/drivers/common/idpf/idpf_common_virtchnl.h
indexc105f02836..6b94fd5b8f100644drivers/common/idpf/idpf_common_virtchnl.h +3
-0@@ -49,4 +49,7 @@ __rte_internalint idpf_vc_rxq_config (struct idpf_vport *vport,struct idpf_rx_queue *rxq); __rte_internal int idpf_vc_txq_config(struct idpf_vport *vport,struct idpf_tx_queue *txq); +__rte_internal +int idpf_vc_stats_query(struct idpf_vport *vport, +struct virtchnl2_vport_stats **pstats); #endif /* _IDPF_COMMON_VIRTCHNL_H_ */ diff --gita/drivers/common/idpf/version.map b/drivers/common/idpf/version.map index
8b33130bd6..e6a02828ba
100644drivers/common/idpf/version.map +2
-0@@ -46,6 +46,7 @@ INTERNAL { idpf_vc_rss_key_set; idpf_vc_rss_lut_set; idpf_vc_rxq_config; + idpf_vc_stats_query; idpf_vc_txq_config; idpf_vc_vectors_alloc; idpf_vc_vectors_dealloc;@@ -59,6 +60,7 @@ INTERNAL { idpf_vport_irq_map_config; idpf_vport_irq_unmap_config; idpf_vport_rss_config; + idpf_vport_stats_update; local: *; };(quoted diff) +0
-0
b/drivers/net/idpf/idpf_ethdev.cindex33f5e90743..02ddb0330a100644drivers/net/idpf/idpf_ethdev.c +0
-0@@ -140,6 +140,87 @@ idpf_dev_supported_ptypes_get(struct
rte_eth_devdrivers/net/idpf/idpf_ethdev.c static const struct eth_dev_ops idpf_eth_dev_ops
Quoted 101 lines
drivers/net/idpf/idpf_ethdev.c +26
-0*dev __rte_unused)return ptypes; } +static uint64_t +idpf_get_mbuf_alloc_failed_stats (struct rte_eth_dev *dev) { +uint64_t mbuf_alloc_failed =0 ; +struct idpf_rx_queue *rxq; +int i =0 ; + +for (i =0 ; i < dev->data->nb_rx_queues; i++) { + rxq = dev->data->rx_queues[i]; + mbuf_alloc_failed +=__atomic_load_n (&rxq- >rx_stats.mbuf_alloc_failed, + __ATOMIC_RELAXED); + } + +return mbuf_alloc_failed; +} + +static int +idpf_dev_stats_get (struct rte_eth_dev *dev,struct rte_eth_stats +*stats) { +struct idpf_vport *vport = + (struct idpf_vport *)dev->data->dev_private; +struct virtchnl2_vport_stats *pstats =NULL ; +int ret; + + ret =idpf_vc_stats_query (vport, &pstats); +if (ret ==0 ) { + uint8_t crc_stats_len = (dev->data-Quoted 1 line
dev_conf.rxmode.offloads &
drivers/net/idpf/idpf_ethdev.c +1
-0+ RTE_ETH_RX_OFFLOAD_KEEP_CRC) ?0 :
drivers/net/idpf/idpf_ethdev.c +6
-0+RTE_ETHER_CRC_LEN ; + +idpf_vport_stats_update (&vport->eth_stats_offset, pstats); + stats->ipackets = pstats->rx_unicast + pstats->rx_multicast + + pstats->rx_broadcast - pstats->rx_discards; + stats->opackets = pstats->tx_broadcast + pstats-Quoted 1 line
tx_multicast+drivers/net/idpf/idpf_ethdev.c +8
-0+ pstats->tx_unicast; + stats->imissed = pstats->rx_discards; + stats->oerrors = pstats->tx_errors + pstats->tx_discards; + stats->ibytes = pstats->rx_bytes; + stats->ibytes -= stats->ipackets * crc_stats_len; + stats->obytes = pstats->tx_bytes; + + dev->data->rx_mbuf_alloc_failed =
idpf_get_mbuf_alloc_failed_stats(dev);drivers/net/idpf/idpf_ethdev.c +15
-0+ stats->rx_nombuf = dev->data->rx_mbuf_alloc_failed; + }else { +PMD_DRV_LOG (ERR ,"Get statistics failed" ); + } +return ret; +} + +static void +idpf_reset_mbuf_alloc_failed_stats (struct rte_eth_dev *dev) { +struct idpf_rx_queue *rxq; +int i; + +for (i =0 ; i < dev->data->nb_rx_queues; i++) { + rxq = dev->data->rx_queues[i]; + __atomic_store_n(&rxq->rx_stats.mbuf_alloc_failed, 0,
__ATOMIC_RELAXED);drivers/net/idpf/idpf_ethdev.c +22
-0+ } +} + +static int +idpf_dev_stats_reset (struct rte_eth_dev *dev) { +struct idpf_vport *vport = + (struct idpf_vport *)dev->data->dev_private; +struct virtchnl2_vport_stats *pstats =NULL ; +int ret; + + ret =idpf_vc_stats_query (vport, &pstats); +if (ret !=0 ) +return ret; + +/* set stats offset base on current values */ + vport->eth_stats_offset = *pstats; + +idpf_reset_mbuf_alloc_failed_stats (dev); + +return 0 ; +} +static int idpf_init_rss(struct idpf_vport *vport) { @@ -327,6 +408,9 @@
idpf_dev_start(struct rte_eth_dev *dev)drivers/net/idpf/idpf_ethdev.c +3
-0goto err_vport; } +if (idpf_dev_stats_reset (dev)) +PMD_DRV_LOG (ERR ,"Failed to reset stats" ); + vport->stopped =0 ;return 0 ;@@ -606,6 +690,8 @@ static const struct eth_dev_ops idpf_eth_dev_ops= {
Quoted 10 lines
drivers/net/idpf/idpf_ethdev.c +2
-1.tx_queue_release = idpf_dev_tx_queue_release, .mtu_set = idpf_dev_mtu_set, .dev_supported_ptypes_get = idpf_dev_supported_ptypes_get, + .stats_get = idpf_dev_stats_get, + .stats_reset = idpf_dev_stats_reset, }; static uint16_t --2.25.1
PATCH v6 2/6 common/idpf: add RSS set/get ops
In reply to Mingxia LiuAdd support for these device ops:
- rss_reta_update
- rss_reta_query
- rss_hash_update
- rss_hash_conf_get
--- drivers/common/idpf/idpf_common_device.h | 1 + drivers/common/idpf/idpf_common_virtchnl.c | 119 +++++++++ drivers/common/idpf/idpf_common_virtchnl.h | 6 + drivers/common/idpf/version.map | 3 + drivers/net/idpf/idpf_ethdev.c | 268 +++++++++++++++++++++ drivers/net/idpf/idpf_ethdev.h | 3 +- 6 files changed, 399 insertions(+), 1 deletion(-)
drivers/common/idpf/idpf_common_device.h +1 -0
@@ -98,6 +98,7 @@ struct idpf_vport {uint32_t *rss_lut;uint8_t *rss_key;uint64_t rss_hf; +uint64_t last_general_rss_hf;/* MSIX info*/ struct virtchnl2_queue_vector *qv_map;/* queue vector mapping */
drivers/common/idpf/idpf_common_virtchnl.c +119 -0
137 lines not on this page · raw message
drivers/common/idpf/idpf_common_virtchnl.h +6 -0
@@ -52,4 +52,10 @@ int idpf_vc_txq_config(struct idpf_vport *vport, struct idpf_tx_queue *txq);__rte_internal int idpf_vc_stats_query(struct idpf_vport *vport,struct virtchnl2_vport_stats **pstats); +__rte_internal +int idpf_vc_rss_key_get(struct idpf_vport *vport); +__rte_internal +int idpf_vc_rss_lut_get(struct idpf_vport *vport); +__rte_internal +int idpf_vc_rss_hash_get(struct idpf_vport *vport);#endif /* _IDPF_COMMON_VIRTCHNL_H_ */
drivers/common/idpf/version.map +3 -0
@@ -42,8 +42,11 @@ INTERNAL { idpf_vc_ptype_info_query; idpf_vc_queue_switch; idpf_vc_queues_ena_dis; + idpf_vc_rss_hash_get; idpf_vc_rss_hash_set; + idpf_vc_rss_key_get; idpf_vc_rss_key_set; + idpf_vc_rss_lut_get; idpf_vc_rss_lut_set; idpf_vc_rxq_config; idpf_vc_stats_query;
drivers/net/idpf/idpf_ethdev.c +268 -0
298 lines not on this page · raw message
drivers/net/idpf/idpf_ethdev.h +2 -1
@@ -48,7 +48,8 @@RTE_ETH_RSS_NONFRAG_IPV6_TCP | \RTE_ETH_RSS_NONFRAG_IPV6_UDP | \RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \ - RTE_ETH_RSS_NONFRAG_IPV6_OTHER) +RTE_ETH_RSS_NONFRAG_IPV6_OTHER | \ + RTE_ETH_RSS_L2_PAYLOAD) #define IDPF_ADAPTER_NAME_LEN (PCI_PRI_STR_SIZE + 1)
Signature · 1 line
2.25.1
PATCH v6 3/6 common/idpf: support single q scatter RX datapath
In reply to Mingxia LiuThis patch add single q recv scatter rx function.
--- drivers/common/idpf/idpf_common_rxtx.c | 135 +++++++++++++++++++++++++ drivers/common/idpf/idpf_common_rxtx.h | 3 + drivers/common/idpf/version.map | 1 + drivers/net/idpf/idpf_ethdev.c | 3 +- drivers/net/idpf/idpf_rxtx.c | 28 +++++ drivers/net/idpf/idpf_rxtx.h | 2 + 6 files changed, 171 insertions(+), 1 deletion(-)
drivers/common/idpf/idpf_common_rxtx.c +135 -0
@@ -1146,6 +1146,141 @@ idpf_dp_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,return nb_rx; } +uint16_t +idpf_dp_singleq_recv_scatter_pkts (void *rx_queue,struct rte_mbuf **rx_pkts, +uint16_t nb_pkts) +{ +struct idpf_rx_queue *rxq = rx_queue; +volatile union virtchnl2_rx_desc *rx_ring = rxq->rx_ring; +volatile union virtchnl2_rx_desc *rxdp; +union virtchnl2_rx_desc rxd; +struct idpf_adapter *ad; +struct rte_mbuf *first_seg = rxq->pkt_first_seg; +struct rte_mbuf *last_seg = rxq->pkt_last_seg; +struct rte_mbuf *rxm; +struct rte_mbuf *nmb; +struct rte_eth_dev *dev; +const uint32_t *ptype_tbl = rxq->adapter->ptype_tbl; +uint16_t rx_id = rxq->rx_tail; +uint16_t rx_packet_len; +uint16_t nb_hold =0 ; +uint16_t rx_status0; +uint16_t nb_rx =0 ; +uint64_t pkt_flags; +uint64_t dma_addr; +uint64_t ts_ns; + + ad = rxq->adapter; + +if (unlikely (!rxq) ||unlikely (!rxq->q_started)) +return nb_rx; + +while (nb_rx < nb_pkts) { + rxdp = &rx_ring[rx_id]; + rx_status0 =rte_le_to_cpu_16 (rxdp->flex_nic_wb.status_error0); + +/* Check the DD bit first */ +if (!(rx_status0 & (1 <<VIRTCHNL2_RX_FLEX_DESC_STATUS0_DD_S ))) +break ; + + nmb =rte_mbuf_raw_alloc (rxq->mp); +if (unlikely (!nmb)) { +__atomic_fetch_add (&rxq->rx_stats.mbuf_alloc_failed,1 , __ATOMIC_RELAXED); +RX_LOG (DEBUG ,"RX mbuf alloc failed port_id=%u " +"queue_id=%u" , rxq->port_id, rxq->queue_id); +break ; + } + + rxd = *rxdp; + + nb_hold++; + rxm = rxq->sw_ring[rx_id]; + rxq->sw_ring[rx_id] = nmb; + rx_id++; +if (unlikely (rx_id == rxq->nb_rx_desc)) + rx_id =0 ; + +/* Prefetch next mbuf */ +rte_prefetch0 (rxq->sw_ring[rx_id]); + +/* When next RX descriptor is on a cache line boundary, +* prefetch the next 4 RX descriptors and next 8 pointers +* to mbufs. +*/ +if ((rx_id &0x3 ) ==0 ) { +rte_prefetch0 (&rx_ring[rx_id]); +rte_prefetch0 (rxq->sw_ring[rx_id]); + } + dma_addr = +rte_cpu_to_le_64 (rte_mbuf_data_iova_default (nmb)); + rxdp->read.hdr_addr =0 ; + rxdp->read.pkt_addr = dma_addr; + rx_packet_len = (rte_cpu_to_le_16 (rxd.flex_nic_wb.pkt_len) & +VIRTCHNL2_RX_FLEX_DESC_PKT_LEN_M ); + rxm->data_len = rx_packet_len; + rxm->data_off =RTE_PKTMBUF_HEADROOM ; + +/** +* If this is the first buffer of the received packet, set the +* pointer to the first mbuf of the packet and initialize its +* context. Otherwise, update the total length and the number +* of segments of the current scattered packet, and update the +* pointer to the last mbuf of the current packet. +*/ +if (!first_seg) { + first_seg = rxm; + first_seg->nb_segs =1 ; + first_seg->pkt_len = rx_packet_len; + }else { + first_seg->pkt_len = + (uint16_t )(first_seg->pkt_len + + rx_packet_len); + first_seg->nb_segs++; + last_seg->next = rxm; + } + +if (!(rx_status0 & (1 <<VIRTCHNL2_RX_FLEX_DESC_STATUS0_EOF_S ))) { + last_seg = rxm; +continue ; + } + + rxm->next =NULL ; + + first_seg->port = rxq->port_id; + first_seg->ol_flags =0 ; + pkt_flags =idpf_rxd_to_pkt_flags (rx_status0); + first_seg->packet_type = + ptype_tbl[(uint8_t )(rte_cpu_to_le_16 (rxd.flex_nic_wb.ptype_flex_flags0) & +VIRTCHNL2_RX_FLEX_DESC_PTYPE_M )]; + +if (idpf_timestamp_dynflag >0 && + (rxq->offloads &IDPF_RX_OFFLOAD_TIMESTAMP ) !=0 ) { +/* timestamp */ + ts_ns =idpf_tstamp_convert_32b_64b (ad, + rxq->hw_register_set, +rte_le_to_cpu_32 (rxd.flex_nic_wb.flex_ts.ts_high)); + rxq->hw_register_set =0 ; + *RTE_MBUF_DYNFIELD (rxm, + idpf_timestamp_dynfield_offset, + rte_mbuf_timestamp_t *) = ts_ns; + first_seg->ol_flags |= idpf_timestamp_dynflag; + } + + first_seg->ol_flags |= pkt_flags; +rte_prefetch0 (RTE_PTR_ADD (first_seg->buf_addr, + first_seg->data_off)); + rx_pkts[nb_rx++] = first_seg; + first_seg =NULL ; + } + rxq->rx_tail = rx_id; + rxq->pkt_first_seg = first_seg; + rxq->pkt_last_seg = last_seg; + +idpf_update_rx_tail (rxq, nb_hold, rx_id); + +return nb_rx; +} +static inline int idpf_xmit_cleanup (struct idpf_tx_queue *txq) {
drivers/common/idpf/idpf_common_rxtx.h +3 -0
@@ -293,5 +293,8 @@ uint16_t idpf_dp_singleq_xmit_pkts_avx512(void *tx_queue,__rte_internal uint16_t idpf_dp_splitq_xmit_pkts_avx512(void *tx_queue, struct rte_mbuf **tx_pkts,uint16_t nb_pkts); +__rte_internal +uint16_t idpf_dp_singleq_recv_scatter_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, +uint16_t nb_pkts);#endif /* _IDPF_COMMON_RXTX_H_ */
drivers/common/idpf/version.map +1 -0
@@ -7,6 +7,7 @@ INTERNAL { idpf_dp_prep_pkts; idpf_dp_singleq_recv_pkts; idpf_dp_singleq_recv_pkts_avx512; + idpf_dp_singleq_recv_scatter_pkts; idpf_dp_singleq_xmit_pkts; idpf_dp_singleq_xmit_pkts_avx512; idpf_dp_splitq_recv_pkts;
drivers/net/idpf/idpf_ethdev.c +2 -1
@@ -119,7 +119,8 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)RTE_ETH_RX_OFFLOAD_UDP_CKSUM |RTE_ETH_RX_OFFLOAD_TCP_CKSUM |RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM | -RTE_ETH_RX_OFFLOAD_TIMESTAMP ; +RTE_ETH_RX_OFFLOAD_TIMESTAMP | +RTE_ETH_RX_OFFLOAD_SCATTER ; dev_info->tx_offload_capa = RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
drivers/net/idpf/idpf_rxtx.c +28 -0
@@ -503,6 +503,8 @@ int idpf_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id) {struct idpf_rx_queue *rxq; +uint16_t max_pkt_len; +uint32_t frame_size;int err;if (rx_queue_id >= dev->data->nb_rx_queues)
@@ -516,6 +518,17 @@ idpf_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id)return -EINVAL ; } + frame_size = dev->data->mtu +IDPF_ETH_OVERHEAD ; + + max_pkt_len = +RTE_MIN ((uint32_t )IDPF_SUPPORT_CHAIN_NUM * rxq->rx_buf_len, + frame_size); + + rxq->max_pkt_len = max_pkt_len; +if ((dev->data->dev_conf.rxmode.offloads &RTE_ETH_RX_OFFLOAD_SCATTER ) || + frame_size > rxq->rx_buf_len) + dev->data->scattered_rx =1 ; + err =idpf_qc_ts_mbuf_register (rxq);if (err !=0 ) { PMD_DRV_LOG(ERR, "fail to residter timestamp mbuf %u",
@@ -807,6 +820,14 @@ idpf_set_rx_function(struct rte_eth_dev *dev) }#endif /* CC_AVX512_SUPPORT */ } + +if (dev->data->scattered_rx) { +PMD_DRV_LOG (NOTICE , +"Using Single Scalar Scatterd Rx (port %d)." , + dev->data->port_id); + dev->rx_pkt_burst = idpf_dp_singleq_recv_scatter_pkts; +return ; + }PMD_DRV_LOG (NOTICE ,"Using Single Scalar Rx (port %d)." , dev->data->port_id);
@@ -819,6 +840,13 @@ idpf_set_rx_function(struct rte_eth_dev *dev) dev->data->port_id); dev->rx_pkt_burst = idpf_dp_splitq_recv_pkts; }else { +if (dev->data->scattered_rx) { +PMD_DRV_LOG (NOTICE , +"Using Single Scalar Scatterd Rx (port %d)." , + dev->data->port_id); + dev->rx_pkt_burst = idpf_dp_singleq_recv_scatter_pkts; +return ; + }PMD_DRV_LOG (NOTICE ,"Using Single Scalar Rx (port %d)." , dev->data->port_id);
drivers/net/idpf/idpf_rxtx.h +2 -0
@@ -23,6 +23,8 @@#define IDPF_DEFAULT_TX_RS_THRESH 32#define IDPF_DEFAULT_TX_FREE_THRESH 32 +#define IDPF_SUPPORT_CHAIN_NUM 5 + int idpf_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, uint16_t nb_desc, unsigned int socket_id, const struct rte_eth_rxconf *rx_conf,
Signature · 1 line
2.25.1
PATCH v6 4/6 common/idpf: add rss_offload hash in singleq rx
In reply to Mingxia LiuThis patch add rss valid flag and hash value parsing of rx descriptor.
--- drivers/common/idpf/idpf_common_rxtx.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/common/idpf/idpf_common_rxtx.c +16 -0
@@ -1030,6 +1030,20 @@ idpf_update_rx_tail(struct idpf_rx_queue *rxq, uint16_t nb_hold, rxq->nb_rx_hold = nb_hold; } +static inline void +idpf_singleq_rx_rss_offload (struct rte_mbuf *mb, +volatile struct virtchnl2_rx_flex_desc_nic *rx_desc, +uint64_t *pkt_flags) +{ +uint16_t rx_status0 =rte_le_to_cpu_16 (rx_desc->status_error0); + +if (rx_status0 &RTE_BIT32 (VIRTCHNL2_RX_FLEX_DESC_STATUS0_RSS_VALID_S )) { + *pkt_flags |=RTE_MBUF_F_RX_RSS_HASH ; + mb->hash.rss =rte_le_to_cpu_32 (rx_desc->rss_hash); + } + +} +uint16_t idpf_dp_singleq_recv_pkts (void *rx_queue,struct rte_mbuf **rx_pkts,uint16_t nb_pkts)
@@ -1118,6 +1132,7 @@ idpf_dp_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, rxm->port = rxq->port_id; rxm->ol_flags =0 ; pkt_flags =idpf_rxd_to_pkt_flags (rx_status0); +idpf_singleq_rx_rss_offload (rxm, &rxd.flex_nic_wb, &pkt_flags); rxm->packet_type = ptype_tbl[(uint8_t )(rte_cpu_to_le_16 (rxd.flex_nic_wb.ptype_flex_flags0) &VIRTCHNL2_RX_FLEX_DESC_PTYPE_M )];
@@ -1249,6 +1264,7 @@ idpf_dp_singleq_recv_scatter_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, first_seg->port = rxq->port_id; first_seg->ol_flags =0 ; pkt_flags =idpf_rxd_to_pkt_flags (rx_status0); +idpf_singleq_rx_rss_offload (first_seg, &rxd.flex_nic_wb, &pkt_flags); first_seg->packet_type = ptype_tbl[(uint8_t )(rte_cpu_to_le_16 (rxd.flex_nic_wb.ptype_flex_flags0) &VIRTCHNL2_RX_FLEX_DESC_PTYPE_M )];
Signature · 1 line
2.25.1
PATCH v6 5/6 common/idpf: add alarm to support handle vchnl message
In reply to Mingxia LiuHandle virtual channel message.
Refine link status update.
--- drivers/common/idpf/idpf_common_device.h | 5 + drivers/common/idpf/idpf_common_virtchnl.c | 33 ++-- drivers/common/idpf/idpf_common_virtchnl.h | 6 + drivers/common/idpf/version.map | 2 + drivers/net/idpf/idpf_ethdev.c | 169 ++++++++++++++++++++- drivers/net/idpf/idpf_ethdev.h | 2 + 6 files changed, 195 insertions(+), 22 deletions(-)
drivers/common/idpf/idpf_common_device.h +5 -0
@@ -118,6 +118,11 @@ struct idpf_vport {bool tx_use_avx512;struct virtchnl2_vport_stats eth_stats_offset; + +void *dev; +/* Event from ipf */ +bool link_up; +uint32_t link_speed; };/* Message type read in virtual channel from PF */
drivers/common/idpf/idpf_common_virtchnl.c +14 -19
@@ -202,25 +202,6 @@ idpf_vc_cmd_execute(struct idpf_adapter *adapter, struct idpf_cmd_info *args)switch (args->ops) {case VIRTCHNL_OP_VERSION :case VIRTCHNL2_OP_GET_CAPS : -case VIRTCHNL2_OP_CREATE_VPORT : -case VIRTCHNL2_OP_DESTROY_VPORT : -case VIRTCHNL2_OP_SET_RSS_KEY : -case VIRTCHNL2_OP_SET_RSS_LUT : -case VIRTCHNL2_OP_SET_RSS_HASH : -case VIRTCHNL2_OP_CONFIG_RX_QUEUES : -case VIRTCHNL2_OP_CONFIG_TX_QUEUES : -case VIRTCHNL2_OP_ENABLE_QUEUES : -case VIRTCHNL2_OP_DISABLE_QUEUES : -case VIRTCHNL2_OP_ENABLE_VPORT : -case VIRTCHNL2_OP_DISABLE_VPORT : -case VIRTCHNL2_OP_MAP_QUEUE_VECTOR : -case VIRTCHNL2_OP_UNMAP_QUEUE_VECTOR : -case VIRTCHNL2_OP_ALLOC_VECTORS : -case VIRTCHNL2_OP_DEALLOC_VECTORS : -case VIRTCHNL2_OP_GET_STATS : -case VIRTCHNL2_OP_GET_RSS_KEY : -case VIRTCHNL2_OP_GET_RSS_HASH : -case VIRTCHNL2_OP_GET_RSS_LUT :/* for init virtchnl ops, need to poll the response */ err =idpf_vc_one_msg_read (adapter, args->ops, args->out_size, args->out_buffer);clear_cmd (adapter);
@@ -1111,3 +1092,17 @@ idpf_vc_txq_config(struct idpf_vport *vport, struct idpf_tx_queue *txq)return err; } + +int +idpf_vc_ctlq_recv (struct idpf_ctlq_info *cq,u16 *num_q_msg, +struct idpf_ctlq_msg *q_msg) +{ +return idpf_ctlq_recv (cq, num_q_msg, q_msg); +} + +int +idpf_vc_ctlq_post_rx_buffs (struct idpf_hw *hw,struct idpf_ctlq_info *cq, +u16 *buff_count,struct idpf_dma_mem **buffs) +{ +return idpf_ctlq_post_rx_buffs (hw, cq, buff_count, buffs); +}
drivers/common/idpf/idpf_common_virtchnl.h +6 -0
@@ -58,4 +58,10 @@ __rte_internalint idpf_vc_rss_lut_get (struct idpf_vport *vport);__rte_internal int idpf_vc_rss_hash_get(struct idpf_vport *vport); +__rte_internal +int idpf_vc_ctlq_recv(struct idpf_ctlq_info *cq, u16 *num_q_msg, +struct idpf_ctlq_msg *q_msg); +__rte_internal +int idpf_vc_ctlq_post_rx_buffs(struct idpf_hw *hw, struct idpf_ctlq_info *cq, +u16 *buff_count,struct idpf_dma_mem **buffs);#endif /* _IDPF_COMMON_VIRTCHNL_H_ */
drivers/common/idpf/version.map +2 -0
@@ -38,6 +38,8 @@ INTERNAL { idpf_vc_api_version_check; idpf_vc_caps_get; idpf_vc_cmd_execute; + idpf_vc_ctlq_post_rx_buffs; + idpf_vc_ctlq_recv; idpf_vc_irq_map_unmap_config; idpf_vc_one_msg_read; idpf_vc_ptype_info_query;
drivers/net/idpf/idpf_ethdev.c +166 -3
210 lines not on this page · raw message
drivers/net/idpf/idpf_ethdev.h +2 -0
@@ -53,6 +53,8 @@#define IDPF_ADAPTER_NAME_LEN (PCI_PRI_STR_SIZE + 1) +#define IDPF_ALARM_INTERVAL 50000/* us */ +struct idpf_vport_param {struct idpf_adapter_ext *adapter;uint16_t devarg_id;/* arg id from user */
Signature · 1 line
2.25.1
PATCH v6 6/6 common/idpf: add xstats ops
In reply to Mingxia LiuAdd support for these device ops:
-idpf_dev_xstats_get
-idpf_dev_xstats_get_names
-idpf_dev_xstats_reset
--- drivers/net/idpf/idpf_ethdev.c | 80 ++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+)
drivers/net/idpf/idpf_ethdev.c +80 -0
@@ -80,6 +80,30 @@ static const uint64_t idpf_ipv6_rss = RTE_ETH_RSS_NONFRAG_IPV6_UDP |RTE_ETH_RSS_NONFRAG_IPV6_OTHER |RTE_ETH_RSS_FRAG_IPV6 ; +struct rte_idpf_xstats_name_off { +char name[RTE_ETH_XSTATS_NAME_SIZE ]; +unsigned int offset; +}; + +static const struct rte_idpf_xstats_name_off rte_idpf_stats_strings[] = { + {"rx_bytes" , offsetof(struct virtchnl2_vport_stats , rx_bytes)}, + {"rx_unicast_packets" , offsetof(struct virtchnl2_vport_stats , rx_unicast)}, + {"rx_multicast_packets" , offsetof(struct virtchnl2_vport_stats , rx_multicast)}, + {"rx_broadcast_packets" , offsetof(struct virtchnl2_vport_stats , rx_broadcast)}, + {"rx_dropped_packets" , offsetof(struct virtchnl2_vport_stats , rx_discards)}, + {"rx_errors" , offsetof(struct virtchnl2_vport_stats , rx_errors)}, + {"rx_unknown_protocol_packets" , offsetof(struct virtchnl2_vport_stats , + rx_unknown_protocol)}, + {"tx_bytes" , offsetof(struct virtchnl2_vport_stats , tx_bytes)}, + {"tx_unicast_packets" , offsetof(struct virtchnl2_vport_stats , tx_unicast)}, + {"tx_multicast_packets" , offsetof(struct virtchnl2_vport_stats , tx_multicast)}, + {"tx_broadcast_packets" , offsetof(struct virtchnl2_vport_stats , tx_broadcast)}, + {"tx_dropped_packets" , offsetof(struct virtchnl2_vport_stats , tx_discards)}, + {"tx_error_packets" , offsetof(struct virtchnl2_vport_stats , tx_errors)}}; + +#define IDPF_NB_XSTATS (sizeof(rte_idpf_stats_strings) / \ + sizeof(rte_idpf_stats_strings[0])) +static int idpf_dev_link_update (struct rte_eth_dev *dev, __rte_unused int wait_to_complete)
@@ -313,6 +337,59 @@ idpf_dev_stats_reset(struct rte_eth_dev *dev)return 0 ; } +static int idpf_dev_xstats_reset (struct rte_eth_dev *dev) +{ +idpf_dev_stats_reset (dev); +return 0 ; +} + +static int idpf_dev_xstats_get (struct rte_eth_dev *dev, +struct rte_eth_xstat *xstats,unsigned int n) +{ +struct idpf_vport *vport = + (struct idpf_vport *)dev->data->dev_private; +struct virtchnl2_vport_stats *pstats =NULL ; +unsigned int i; +int ret; + +if (n <IDPF_NB_XSTATS ) +return IDPF_NB_XSTATS ; + +if (!xstats) +return 0 ; + + ret =idpf_vc_stats_query (vport, &pstats); +if (ret) { +PMD_DRV_LOG (ERR ,"Get statistics failed" ); +return 0 ; + } + +idpf_vport_stats_update (&vport->eth_stats_offset, pstats); + +/* loop over xstats array and values from pstats */ +for (i =0 ; i <IDPF_NB_XSTATS ; i++) { + xstats[i].id = i; + xstats[i].value = *(uint64_t *)(((char *)pstats) + + rte_idpf_stats_strings[i].offset); + } +return IDPF_NB_XSTATS ; +} + +static int idpf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, +struct rte_eth_xstat_name *xstats_names, + __rte_unused unsigned int limit) +{ +unsigned int i; + +if (xstats_names) +for (i =0 ; i <IDPF_NB_XSTATS ; i++) { +snprintf (xstats_names[i].name, +sizeof (xstats_names[i].name), +"%s" , rte_idpf_stats_strings[i].name); + } +return IDPF_NB_XSTATS ; +} +static int idpf_config_rss_hf (struct idpf_vport *vport,uint64_t rss_hf) {uint64_t hena =0 ;
@@ -1122,6 +1199,9 @@ static const struct eth_dev_ops idpf_eth_dev_ops = { .reta_query = idpf_rss_reta_query, .rss_hash_update = idpf_rss_hash_update, .rss_hash_conf_get = idpf_rss_hash_conf_get, + .xstats_get = idpf_dev_xstats_get, + .xstats_get_names = idpf_dev_xstats_get_names, + .xstats_reset = idpf_dev_xstats_reset, }; static uint16_t
Signature · 1 line
2.25.1
Quoted 21 lines
-----Original Message-----
From: Liu, Mingxia <[email protected]>
Sent: Tuesday, February 7, 2023 6:17 PM
To: [email protected]; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>
Cc: Liu, Mingxia <[email protected]>
Subject: [PATCH v6 0/6] add idpf pmd enhancement featuresThis patchset add several enhancement features of idpf pmd. Including the following:
- add hw statistics, support stats/xstats ops
- add rss configure/show ops
- add event handle: link status
- add scattered data path for single queueThis patchset is based on the refactor idpf PMD code:
http://patches.dpdk.org/project/dpdk/patch/20230207084549.2225214-2-
[email protected]/
Quoted 15 lines
v2 changes:
- Fix rss lut config issue.
v3 changes:
- rebase to the new baseline.
v4 changes:
- rebase to the new baseline.
- optimize some code
- give "not supported" tips when user want to config rss hash type
- if stats reset fails at initialization time, don't rollback, just print ERROR info.
v5 changes:
- fix some spelling error
v6 changes:
- add cover-letter
v7 cover add idpf pmd enhancement features
In reply to Mingxia LiuThis patchset add several enhancement features of idpf pmd. Including the following:
- add hw statistics, support stats/xstats ops
- add rss configure/show ops
- add event handle: link status
- add scattered data path for single queue
v2 changes:
- Fix rss lut config issue.
v3 changes:
- rebase to the new baseline.
v4 changes:
- rebase to the new baseline.
- optimize some code
- give "not supported" tips when user want to config rss hash type
- if stats reset fails at initialization time, don't rollback, just print ERROR info.
v5 changes:
- fix some spelling error
v6 changes:
- add cover-letter
v7 changes:
- change commit msg module from "common/idpf" to "net/idpf"
Mingxia Liu (6):
net/idpf: add hw statistics
net/idpf: add RSS set/get ops
net/idpf: support single q scatter RX datapath net/idpf: add rss_offload hash in singleq rx net/idpf: add alarm to support handle vchnl message net/idpf: add xstats ops
drivers/common/idpf/idpf_common_device.c | 17 + drivers/common/idpf/idpf_common_device.h | 10 + drivers/common/idpf/idpf_common_rxtx.c | 151 +++++ drivers/common/idpf/idpf_common_rxtx.h | 3 + drivers/common/idpf/idpf_common_virtchnl.c | 171 +++++- drivers/common/idpf/idpf_common_virtchnl.h | 15 + drivers/common/idpf/version.map | 8 + drivers/net/idpf/idpf_ethdev.c | 606 ++++++++++++++++++++- drivers/net/idpf/idpf_ethdev.h | 5 +- drivers/net/idpf/idpf_rxtx.c | 28 + drivers/net/idpf/idpf_rxtx.h | 2 + 11 files changed, 996 insertions(+), 20 deletions(-)
Signature · 1 line
2.25.1
PATCH v7 1/6 net/idpf: add hw statistics
This patch add hardware packets/bytes statistics.
--- drivers/common/idpf/idpf_common_device.c | 17 +++++ drivers/common/idpf/idpf_common_device.h | 4 + drivers/common/idpf/idpf_common_virtchnl.c | 27 +++++++ drivers/common/idpf/idpf_common_virtchnl.h | 3 + drivers/common/idpf/version.map | 2 + drivers/net/idpf/idpf_ethdev.c | 86 ++++++++++++++++++++++ 6 files changed, 139 insertions(+)
drivers/common/idpf/idpf_common_device.c +17 -0
@@ -652,4 +652,21 @@ idpf_vport_info_init(struct idpf_vport *vport,return 0 ; } +void +idpf_vport_stats_update (struct virtchnl2_vport_stats *oes,struct virtchnl2_vport_stats *nes) +{ + nes->rx_bytes = nes->rx_bytes - oes->rx_bytes; + nes->rx_unicast = nes->rx_unicast - oes->rx_unicast; + nes->rx_multicast = nes->rx_multicast - oes->rx_multicast; + nes->rx_broadcast = nes->rx_broadcast - oes->rx_broadcast; + nes->rx_errors = nes->rx_errors - oes->rx_errors; + nes->rx_discards = nes->rx_discards - oes->rx_discards; + nes->tx_bytes = nes->tx_bytes - oes->tx_bytes; + nes->tx_unicast = nes->tx_unicast - oes->tx_unicast; + nes->tx_multicast = nes->tx_multicast - oes->tx_multicast; + nes->tx_broadcast = nes->tx_broadcast - oes->tx_broadcast; + nes->tx_errors = nes->tx_errors - oes->tx_errors; + nes->tx_discards = nes->tx_discards - oes->tx_discards; +} +RTE_LOG_REGISTER_SUFFIX (idpf_common_logtype, common,NOTICE );
drivers/common/idpf/idpf_common_device.h +4 -0
@@ -115,6 +115,8 @@ struct idpf_vport {bool tx_vec_allowed;bool rx_use_avx512;bool tx_use_avx512; + +struct virtchnl2_vport_stats eth_stats_offset; };/* Message type read in virtual channel from PF */
@@ -191,5 +193,7 @@ int idpf_vport_irq_unmap_config(struct idpf_vport *vport, uint16_t nb_rx_queues)__rte_internal int idpf_vport_info_init(struct idpf_vport *vport,struct virtchnl2_create_vport *vport_info); +__rte_internal +void idpf_vport_stats_update(struct virtchnl2_vport_stats *oes, struct virtchnl2_vport_stats *nes);#endif /* _IDPF_COMMON_DEVICE_H_ */
drivers/common/idpf/idpf_common_virtchnl.c +27 -0
@@ -217,6 +217,7 @@ idpf_vc_cmd_execute(struct idpf_adapter *adapter, struct idpf_cmd_info *args)case VIRTCHNL2_OP_UNMAP_QUEUE_VECTOR :case VIRTCHNL2_OP_ALLOC_VECTORS :case VIRTCHNL2_OP_DEALLOC_VECTORS : +case VIRTCHNL2_OP_GET_STATS :/* for init virtchnl ops, need to poll the response */ err =idpf_vc_one_msg_read (adapter, args->ops, args->out_size, args->out_buffer);clear_cmd (adapter);
@@ -806,6 +807,32 @@ idpf_vc_ptype_info_query(struct idpf_adapter *adapter)return err; } +int +idpf_vc_stats_query (struct idpf_vport *vport, +struct virtchnl2_vport_stats **pstats) +{ +struct idpf_adapter *adapter = vport->adapter; +struct virtchnl2_vport_stats vport_stats; +struct idpf_cmd_info args; +int err; + + vport_stats.vport_id = vport->vport_id; + args.ops =VIRTCHNL2_OP_GET_STATS ; + args.in_args = (u8 *)&vport_stats; + args.in_args_size =sizeof (vport_stats); + args.out_buffer = adapter->mbx_resp; + args.out_size =IDPF_DFLT_MBX_BUF_SIZE ; + + err =idpf_vc_cmd_execute (adapter, &args); +if (err) { +DRV_LOG (ERR ,"Failed to execute command of VIRTCHNL2_OP_GET_STATS" ); + *pstats =NULL ; +return err; + } + *pstats = (struct virtchnl2_vport_stats *)args.out_buffer; +return 0 ; +} +#define IDPF_RX_BUF_STRIDE 64int idpf_vc_rxq_config (struct idpf_vport *vport,struct idpf_rx_queue *rxq)
drivers/common/idpf/idpf_common_virtchnl.h +3 -0
@@ -49,4 +49,7 @@ __rte_internalint idpf_vc_rxq_config (struct idpf_vport *vport,struct idpf_rx_queue *rxq);__rte_internal int idpf_vc_txq_config(struct idpf_vport *vport, struct idpf_tx_queue *txq); +__rte_internal +int idpf_vc_stats_query(struct idpf_vport *vport, +struct virtchnl2_vport_stats **pstats);#endif /* _IDPF_COMMON_VIRTCHNL_H_ */
drivers/common/idpf/version.map +2 -0
@@ -46,6 +46,7 @@ INTERNAL { idpf_vc_rss_key_set; idpf_vc_rss_lut_set; idpf_vc_rxq_config; + idpf_vc_stats_query; idpf_vc_txq_config; idpf_vc_vectors_alloc; idpf_vc_vectors_dealloc;
@@ -59,6 +60,7 @@ INTERNAL { idpf_vport_irq_map_config; idpf_vport_irq_unmap_config; idpf_vport_rss_config; + idpf_vport_stats_update; local: *; };
drivers/net/idpf/idpf_ethdev.c +86 -0
104 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v7 2/6 net/idpf: add RSS set/get ops
In reply to Mingxia LiuAdd support for these device ops:
- rss_reta_update
- rss_reta_query
- rss_hash_update
- rss_hash_conf_get
--- drivers/common/idpf/idpf_common_device.h | 1 + drivers/common/idpf/idpf_common_virtchnl.c | 119 +++++++++ drivers/common/idpf/idpf_common_virtchnl.h | 6 + drivers/common/idpf/version.map | 3 + drivers/net/idpf/idpf_ethdev.c | 268 +++++++++++++++++++++ drivers/net/idpf/idpf_ethdev.h | 3 +- 6 files changed, 399 insertions(+), 1 deletion(-)
drivers/common/idpf/idpf_common_device.h +1 -0
@@ -98,6 +98,7 @@ struct idpf_vport {uint32_t *rss_lut;uint8_t *rss_key;uint64_t rss_hf; +uint64_t last_general_rss_hf;/* MSIX info*/ struct virtchnl2_queue_vector *qv_map;/* queue vector mapping */
drivers/common/idpf/idpf_common_virtchnl.c +119 -0
137 lines not on this page · raw message
drivers/common/idpf/idpf_common_virtchnl.h +6 -0
@@ -52,4 +52,10 @@ int idpf_vc_txq_config(struct idpf_vport *vport, struct idpf_tx_queue *txq);__rte_internal int idpf_vc_stats_query(struct idpf_vport *vport,struct virtchnl2_vport_stats **pstats); +__rte_internal +int idpf_vc_rss_key_get(struct idpf_vport *vport); +__rte_internal +int idpf_vc_rss_lut_get(struct idpf_vport *vport); +__rte_internal +int idpf_vc_rss_hash_get(struct idpf_vport *vport);#endif /* _IDPF_COMMON_VIRTCHNL_H_ */
drivers/common/idpf/version.map +3 -0
@@ -42,8 +42,11 @@ INTERNAL { idpf_vc_ptype_info_query; idpf_vc_queue_switch; idpf_vc_queues_ena_dis; + idpf_vc_rss_hash_get; idpf_vc_rss_hash_set; + idpf_vc_rss_key_get; idpf_vc_rss_key_set; + idpf_vc_rss_lut_get; idpf_vc_rss_lut_set; idpf_vc_rxq_config; idpf_vc_stats_query;
drivers/net/idpf/idpf_ethdev.c +268 -0
298 lines not on this page · raw message
drivers/net/idpf/idpf_ethdev.h +2 -1
@@ -48,7 +48,8 @@RTE_ETH_RSS_NONFRAG_IPV6_TCP | \RTE_ETH_RSS_NONFRAG_IPV6_UDP | \RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \ - RTE_ETH_RSS_NONFRAG_IPV6_OTHER) +RTE_ETH_RSS_NONFRAG_IPV6_OTHER | \ + RTE_ETH_RSS_L2_PAYLOAD) #define IDPF_ADAPTER_NAME_LEN (PCI_PRI_STR_SIZE + 1)
Signature · 1 line
2.25.1
PATCH v7 3/6 net/idpf: support single q scatter RX datapath
In reply to Mingxia LiuThis patch add single q recv scatter rx function.
--- drivers/common/idpf/idpf_common_rxtx.c | 135 +++++++++++++++++++++++++ drivers/common/idpf/idpf_common_rxtx.h | 3 + drivers/common/idpf/version.map | 1 + drivers/net/idpf/idpf_ethdev.c | 3 +- drivers/net/idpf/idpf_rxtx.c | 28 +++++ drivers/net/idpf/idpf_rxtx.h | 2 + 6 files changed, 171 insertions(+), 1 deletion(-)
drivers/common/idpf/idpf_common_rxtx.c +135 -0
@@ -1146,6 +1146,141 @@ idpf_dp_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,return nb_rx; } +uint16_t +idpf_dp_singleq_recv_scatter_pkts (void *rx_queue,struct rte_mbuf **rx_pkts, +uint16_t nb_pkts) +{ +struct idpf_rx_queue *rxq = rx_queue; +volatile union virtchnl2_rx_desc *rx_ring = rxq->rx_ring; +volatile union virtchnl2_rx_desc *rxdp; +union virtchnl2_rx_desc rxd; +struct idpf_adapter *ad; +struct rte_mbuf *first_seg = rxq->pkt_first_seg; +struct rte_mbuf *last_seg = rxq->pkt_last_seg; +struct rte_mbuf *rxm; +struct rte_mbuf *nmb; +struct rte_eth_dev *dev; +const uint32_t *ptype_tbl = rxq->adapter->ptype_tbl; +uint16_t rx_id = rxq->rx_tail; +uint16_t rx_packet_len; +uint16_t nb_hold =0 ; +uint16_t rx_status0; +uint16_t nb_rx =0 ; +uint64_t pkt_flags; +uint64_t dma_addr; +uint64_t ts_ns; + + ad = rxq->adapter; + +if (unlikely (!rxq) ||unlikely (!rxq->q_started)) +return nb_rx; + +while (nb_rx < nb_pkts) { + rxdp = &rx_ring[rx_id]; + rx_status0 =rte_le_to_cpu_16 (rxdp->flex_nic_wb.status_error0); + +/* Check the DD bit first */ +if (!(rx_status0 & (1 <<VIRTCHNL2_RX_FLEX_DESC_STATUS0_DD_S ))) +break ; + + nmb =rte_mbuf_raw_alloc (rxq->mp); +if (unlikely (!nmb)) { +__atomic_fetch_add (&rxq->rx_stats.mbuf_alloc_failed,1 , __ATOMIC_RELAXED); +RX_LOG (DEBUG ,"RX mbuf alloc failed port_id=%u " +"queue_id=%u" , rxq->port_id, rxq->queue_id); +break ; + } + + rxd = *rxdp; + + nb_hold++; + rxm = rxq->sw_ring[rx_id]; + rxq->sw_ring[rx_id] = nmb; + rx_id++; +if (unlikely (rx_id == rxq->nb_rx_desc)) + rx_id =0 ; + +/* Prefetch next mbuf */ +rte_prefetch0 (rxq->sw_ring[rx_id]); + +/* When next RX descriptor is on a cache line boundary, +* prefetch the next 4 RX descriptors and next 8 pointers +* to mbufs. +*/ +if ((rx_id &0x3 ) ==0 ) { +rte_prefetch0 (&rx_ring[rx_id]); +rte_prefetch0 (rxq->sw_ring[rx_id]); + } + dma_addr = +rte_cpu_to_le_64 (rte_mbuf_data_iova_default (nmb)); + rxdp->read.hdr_addr =0 ; + rxdp->read.pkt_addr = dma_addr; + rx_packet_len = (rte_cpu_to_le_16 (rxd.flex_nic_wb.pkt_len) & +VIRTCHNL2_RX_FLEX_DESC_PKT_LEN_M ); + rxm->data_len = rx_packet_len; + rxm->data_off =RTE_PKTMBUF_HEADROOM ; + +/** +* If this is the first buffer of the received packet, set the +* pointer to the first mbuf of the packet and initialize its +* context. Otherwise, update the total length and the number +* of segments of the current scattered packet, and update the +* pointer to the last mbuf of the current packet. +*/ +if (!first_seg) { + first_seg = rxm; + first_seg->nb_segs =1 ; + first_seg->pkt_len = rx_packet_len; + }else { + first_seg->pkt_len = + (uint16_t )(first_seg->pkt_len + + rx_packet_len); + first_seg->nb_segs++; + last_seg->next = rxm; + } + +if (!(rx_status0 & (1 <<VIRTCHNL2_RX_FLEX_DESC_STATUS0_EOF_S ))) { + last_seg = rxm; +continue ; + } + + rxm->next =NULL ; + + first_seg->port = rxq->port_id; + first_seg->ol_flags =0 ; + pkt_flags =idpf_rxd_to_pkt_flags (rx_status0); + first_seg->packet_type = + ptype_tbl[(uint8_t )(rte_cpu_to_le_16 (rxd.flex_nic_wb.ptype_flex_flags0) & +VIRTCHNL2_RX_FLEX_DESC_PTYPE_M )]; + +if (idpf_timestamp_dynflag >0 && + (rxq->offloads &IDPF_RX_OFFLOAD_TIMESTAMP ) !=0 ) { +/* timestamp */ + ts_ns =idpf_tstamp_convert_32b_64b (ad, + rxq->hw_register_set, +rte_le_to_cpu_32 (rxd.flex_nic_wb.flex_ts.ts_high)); + rxq->hw_register_set =0 ; + *RTE_MBUF_DYNFIELD (rxm, + idpf_timestamp_dynfield_offset, + rte_mbuf_timestamp_t *) = ts_ns; + first_seg->ol_flags |= idpf_timestamp_dynflag; + } + + first_seg->ol_flags |= pkt_flags; +rte_prefetch0 (RTE_PTR_ADD (first_seg->buf_addr, + first_seg->data_off)); + rx_pkts[nb_rx++] = first_seg; + first_seg =NULL ; + } + rxq->rx_tail = rx_id; + rxq->pkt_first_seg = first_seg; + rxq->pkt_last_seg = last_seg; + +idpf_update_rx_tail (rxq, nb_hold, rx_id); + +return nb_rx; +} +static inline int idpf_xmit_cleanup (struct idpf_tx_queue *txq) {
drivers/common/idpf/idpf_common_rxtx.h +3 -0
@@ -293,5 +293,8 @@ uint16_t idpf_dp_singleq_xmit_pkts_avx512(void *tx_queue,__rte_internal uint16_t idpf_dp_splitq_xmit_pkts_avx512(void *tx_queue, struct rte_mbuf **tx_pkts,uint16_t nb_pkts); +__rte_internal +uint16_t idpf_dp_singleq_recv_scatter_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, +uint16_t nb_pkts);#endif /* _IDPF_COMMON_RXTX_H_ */
drivers/common/idpf/version.map +1 -0
@@ -7,6 +7,7 @@ INTERNAL { idpf_dp_prep_pkts; idpf_dp_singleq_recv_pkts; idpf_dp_singleq_recv_pkts_avx512; + idpf_dp_singleq_recv_scatter_pkts; idpf_dp_singleq_xmit_pkts; idpf_dp_singleq_xmit_pkts_avx512; idpf_dp_splitq_recv_pkts;
drivers/net/idpf/idpf_ethdev.c +2 -1
@@ -119,7 +119,8 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)RTE_ETH_RX_OFFLOAD_UDP_CKSUM |RTE_ETH_RX_OFFLOAD_TCP_CKSUM |RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM | -RTE_ETH_RX_OFFLOAD_TIMESTAMP ; +RTE_ETH_RX_OFFLOAD_TIMESTAMP | +RTE_ETH_RX_OFFLOAD_SCATTER ; dev_info->tx_offload_capa = RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
drivers/net/idpf/idpf_rxtx.c +28 -0
@@ -503,6 +503,8 @@ int idpf_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id) {struct idpf_rx_queue *rxq; +uint16_t max_pkt_len; +uint32_t frame_size;int err;if (rx_queue_id >= dev->data->nb_rx_queues)
@@ -516,6 +518,17 @@ idpf_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id)return -EINVAL ; } + frame_size = dev->data->mtu +IDPF_ETH_OVERHEAD ; + + max_pkt_len = +RTE_MIN ((uint32_t )IDPF_SUPPORT_CHAIN_NUM * rxq->rx_buf_len, + frame_size); + + rxq->max_pkt_len = max_pkt_len; +if ((dev->data->dev_conf.rxmode.offloads &RTE_ETH_RX_OFFLOAD_SCATTER ) || + frame_size > rxq->rx_buf_len) + dev->data->scattered_rx =1 ; + err =idpf_qc_ts_mbuf_register (rxq);if (err !=0 ) { PMD_DRV_LOG(ERR, "fail to residter timestamp mbuf %u",
@@ -807,6 +820,14 @@ idpf_set_rx_function(struct rte_eth_dev *dev) }#endif /* CC_AVX512_SUPPORT */ } + +if (dev->data->scattered_rx) { +PMD_DRV_LOG (NOTICE , +"Using Single Scalar Scatterd Rx (port %d)." , + dev->data->port_id); + dev->rx_pkt_burst = idpf_dp_singleq_recv_scatter_pkts; +return ; + }PMD_DRV_LOG (NOTICE ,"Using Single Scalar Rx (port %d)." , dev->data->port_id);
@@ -819,6 +840,13 @@ idpf_set_rx_function(struct rte_eth_dev *dev) dev->data->port_id); dev->rx_pkt_burst = idpf_dp_splitq_recv_pkts; }else { +if (dev->data->scattered_rx) { +PMD_DRV_LOG (NOTICE , +"Using Single Scalar Scatterd Rx (port %d)." , + dev->data->port_id); + dev->rx_pkt_burst = idpf_dp_singleq_recv_scatter_pkts; +return ; + }PMD_DRV_LOG (NOTICE ,"Using Single Scalar Rx (port %d)." , dev->data->port_id);
drivers/net/idpf/idpf_rxtx.h +2 -0
@@ -23,6 +23,8 @@#define IDPF_DEFAULT_TX_RS_THRESH 32#define IDPF_DEFAULT_TX_FREE_THRESH 32 +#define IDPF_SUPPORT_CHAIN_NUM 5 + int idpf_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, uint16_t nb_desc, unsigned int socket_id, const struct rte_eth_rxconf *rx_conf,
Signature · 1 line
2.25.1
PATCH v7 4/6 net/idpf: add rss_offload hash in singleq rx
In reply to Mingxia LiuThis patch add rss valid flag and hash value parsing of rx descriptor.
--- drivers/common/idpf/idpf_common_rxtx.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/common/idpf/idpf_common_rxtx.c +16 -0
@@ -1030,6 +1030,20 @@ idpf_update_rx_tail(struct idpf_rx_queue *rxq, uint16_t nb_hold, rxq->nb_rx_hold = nb_hold; } +static inline void +idpf_singleq_rx_rss_offload (struct rte_mbuf *mb, +volatile struct virtchnl2_rx_flex_desc_nic *rx_desc, +uint64_t *pkt_flags) +{ +uint16_t rx_status0 =rte_le_to_cpu_16 (rx_desc->status_error0); + +if (rx_status0 &RTE_BIT32 (VIRTCHNL2_RX_FLEX_DESC_STATUS0_RSS_VALID_S )) { + *pkt_flags |=RTE_MBUF_F_RX_RSS_HASH ; + mb->hash.rss =rte_le_to_cpu_32 (rx_desc->rss_hash); + } + +} +uint16_t idpf_dp_singleq_recv_pkts (void *rx_queue,struct rte_mbuf **rx_pkts,uint16_t nb_pkts)
@@ -1118,6 +1132,7 @@ idpf_dp_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, rxm->port = rxq->port_id; rxm->ol_flags =0 ; pkt_flags =idpf_rxd_to_pkt_flags (rx_status0); +idpf_singleq_rx_rss_offload (rxm, &rxd.flex_nic_wb, &pkt_flags); rxm->packet_type = ptype_tbl[(uint8_t )(rte_cpu_to_le_16 (rxd.flex_nic_wb.ptype_flex_flags0) &VIRTCHNL2_RX_FLEX_DESC_PTYPE_M )];
@@ -1249,6 +1264,7 @@ idpf_dp_singleq_recv_scatter_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, first_seg->port = rxq->port_id; first_seg->ol_flags =0 ; pkt_flags =idpf_rxd_to_pkt_flags (rx_status0); +idpf_singleq_rx_rss_offload (first_seg, &rxd.flex_nic_wb, &pkt_flags); first_seg->packet_type = ptype_tbl[(uint8_t )(rte_cpu_to_le_16 (rxd.flex_nic_wb.ptype_flex_flags0) &VIRTCHNL2_RX_FLEX_DESC_PTYPE_M )];
Signature · 1 line
2.25.1
PATCH v7 5/6 net/idpf: add alarm to support handle vchnl message
In reply to Mingxia LiuHandle virtual channel message.
Refine link status update.
--- drivers/common/idpf/idpf_common_device.h | 5 + drivers/common/idpf/idpf_common_virtchnl.c | 33 ++-- drivers/common/idpf/idpf_common_virtchnl.h | 6 + drivers/common/idpf/version.map | 2 + drivers/net/idpf/idpf_ethdev.c | 169 ++++++++++++++++++++- drivers/net/idpf/idpf_ethdev.h | 2 + 6 files changed, 195 insertions(+), 22 deletions(-)
drivers/common/idpf/idpf_common_device.h +5 -0
@@ -118,6 +118,11 @@ struct idpf_vport {bool tx_use_avx512;struct virtchnl2_vport_stats eth_stats_offset; + +void *dev; +/* Event from ipf */ +bool link_up; +uint32_t link_speed; };/* Message type read in virtual channel from PF */
drivers/common/idpf/idpf_common_virtchnl.c +14 -19
@@ -202,25 +202,6 @@ idpf_vc_cmd_execute(struct idpf_adapter *adapter, struct idpf_cmd_info *args)switch (args->ops) {case VIRTCHNL_OP_VERSION :case VIRTCHNL2_OP_GET_CAPS : -case VIRTCHNL2_OP_CREATE_VPORT : -case VIRTCHNL2_OP_DESTROY_VPORT : -case VIRTCHNL2_OP_SET_RSS_KEY : -case VIRTCHNL2_OP_SET_RSS_LUT : -case VIRTCHNL2_OP_SET_RSS_HASH : -case VIRTCHNL2_OP_CONFIG_RX_QUEUES : -case VIRTCHNL2_OP_CONFIG_TX_QUEUES : -case VIRTCHNL2_OP_ENABLE_QUEUES : -case VIRTCHNL2_OP_DISABLE_QUEUES : -case VIRTCHNL2_OP_ENABLE_VPORT : -case VIRTCHNL2_OP_DISABLE_VPORT : -case VIRTCHNL2_OP_MAP_QUEUE_VECTOR : -case VIRTCHNL2_OP_UNMAP_QUEUE_VECTOR : -case VIRTCHNL2_OP_ALLOC_VECTORS : -case VIRTCHNL2_OP_DEALLOC_VECTORS : -case VIRTCHNL2_OP_GET_STATS : -case VIRTCHNL2_OP_GET_RSS_KEY : -case VIRTCHNL2_OP_GET_RSS_HASH : -case VIRTCHNL2_OP_GET_RSS_LUT :/* for init virtchnl ops, need to poll the response */ err =idpf_vc_one_msg_read (adapter, args->ops, args->out_size, args->out_buffer);clear_cmd (adapter);
@@ -1111,3 +1092,17 @@ idpf_vc_txq_config(struct idpf_vport *vport, struct idpf_tx_queue *txq)return err; } + +int +idpf_vc_ctlq_recv (struct idpf_ctlq_info *cq,u16 *num_q_msg, +struct idpf_ctlq_msg *q_msg) +{ +return idpf_ctlq_recv (cq, num_q_msg, q_msg); +} + +int +idpf_vc_ctlq_post_rx_buffs (struct idpf_hw *hw,struct idpf_ctlq_info *cq, +u16 *buff_count,struct idpf_dma_mem **buffs) +{ +return idpf_ctlq_post_rx_buffs (hw, cq, buff_count, buffs); +}
drivers/common/idpf/idpf_common_virtchnl.h +6 -0
@@ -58,4 +58,10 @@ __rte_internalint idpf_vc_rss_lut_get (struct idpf_vport *vport);__rte_internal int idpf_vc_rss_hash_get(struct idpf_vport *vport); +__rte_internal +int idpf_vc_ctlq_recv(struct idpf_ctlq_info *cq, u16 *num_q_msg, +struct idpf_ctlq_msg *q_msg); +__rte_internal +int idpf_vc_ctlq_post_rx_buffs(struct idpf_hw *hw, struct idpf_ctlq_info *cq, +u16 *buff_count,struct idpf_dma_mem **buffs);#endif /* _IDPF_COMMON_VIRTCHNL_H_ */
drivers/common/idpf/version.map +2 -0
@@ -38,6 +38,8 @@ INTERNAL { idpf_vc_api_version_check; idpf_vc_caps_get; idpf_vc_cmd_execute; + idpf_vc_ctlq_post_rx_buffs; + idpf_vc_ctlq_recv; idpf_vc_irq_map_unmap_config; idpf_vc_one_msg_read; idpf_vc_ptype_info_query;
drivers/net/idpf/idpf_ethdev.c +166 -3
210 lines not on this page · raw message
drivers/net/idpf/idpf_ethdev.h +2 -0
@@ -53,6 +53,8 @@#define IDPF_ADAPTER_NAME_LEN (PCI_PRI_STR_SIZE + 1) +#define IDPF_ALARM_INTERVAL 50000/* us */ +struct idpf_vport_param {struct idpf_adapter_ext *adapter;uint16_t devarg_id;/* arg id from user */
Signature · 1 line
2.25.1
PATCH v7 6/6 net/idpf: add xstats ops
In reply to Mingxia LiuAdd support for these device ops:
-idpf_dev_xstats_get
-idpf_dev_xstats_get_names
-idpf_dev_xstats_reset
--- drivers/net/idpf/idpf_ethdev.c | 80 ++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+)
drivers/net/idpf/idpf_ethdev.c +80 -0
@@ -80,6 +80,30 @@ static const uint64_t idpf_ipv6_rss = RTE_ETH_RSS_NONFRAG_IPV6_UDP |RTE_ETH_RSS_NONFRAG_IPV6_OTHER |RTE_ETH_RSS_FRAG_IPV6 ; +struct rte_idpf_xstats_name_off { +char name[RTE_ETH_XSTATS_NAME_SIZE ]; +unsigned int offset; +}; + +static const struct rte_idpf_xstats_name_off rte_idpf_stats_strings[] = { + {"rx_bytes" , offsetof(struct virtchnl2_vport_stats , rx_bytes)}, + {"rx_unicast_packets" , offsetof(struct virtchnl2_vport_stats , rx_unicast)}, + {"rx_multicast_packets" , offsetof(struct virtchnl2_vport_stats , rx_multicast)}, + {"rx_broadcast_packets" , offsetof(struct virtchnl2_vport_stats , rx_broadcast)}, + {"rx_dropped_packets" , offsetof(struct virtchnl2_vport_stats , rx_discards)}, + {"rx_errors" , offsetof(struct virtchnl2_vport_stats , rx_errors)}, + {"rx_unknown_protocol_packets" , offsetof(struct virtchnl2_vport_stats , + rx_unknown_protocol)}, + {"tx_bytes" , offsetof(struct virtchnl2_vport_stats , tx_bytes)}, + {"tx_unicast_packets" , offsetof(struct virtchnl2_vport_stats , tx_unicast)}, + {"tx_multicast_packets" , offsetof(struct virtchnl2_vport_stats , tx_multicast)}, + {"tx_broadcast_packets" , offsetof(struct virtchnl2_vport_stats , tx_broadcast)}, + {"tx_dropped_packets" , offsetof(struct virtchnl2_vport_stats , tx_discards)}, + {"tx_error_packets" , offsetof(struct virtchnl2_vport_stats , tx_errors)}}; + +#define IDPF_NB_XSTATS (sizeof(rte_idpf_stats_strings) / \ + sizeof(rte_idpf_stats_strings[0])) +static int idpf_dev_link_update (struct rte_eth_dev *dev, __rte_unused int wait_to_complete)
@@ -313,6 +337,59 @@ idpf_dev_stats_reset(struct rte_eth_dev *dev)return 0 ; } +static int idpf_dev_xstats_reset (struct rte_eth_dev *dev) +{ +idpf_dev_stats_reset (dev); +return 0 ; +} + +static int idpf_dev_xstats_get (struct rte_eth_dev *dev, +struct rte_eth_xstat *xstats,unsigned int n) +{ +struct idpf_vport *vport = + (struct idpf_vport *)dev->data->dev_private; +struct virtchnl2_vport_stats *pstats =NULL ; +unsigned int i; +int ret; + +if (n <IDPF_NB_XSTATS ) +return IDPF_NB_XSTATS ; + +if (!xstats) +return 0 ; + + ret =idpf_vc_stats_query (vport, &pstats); +if (ret) { +PMD_DRV_LOG (ERR ,"Get statistics failed" ); +return 0 ; + } + +idpf_vport_stats_update (&vport->eth_stats_offset, pstats); + +/* loop over xstats array and values from pstats */ +for (i =0 ; i <IDPF_NB_XSTATS ; i++) { + xstats[i].id = i; + xstats[i].value = *(uint64_t *)(((char *)pstats) + + rte_idpf_stats_strings[i].offset); + } +return IDPF_NB_XSTATS ; +} + +static int idpf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, +struct rte_eth_xstat_name *xstats_names, + __rte_unused unsigned int limit) +{ +unsigned int i; + +if (xstats_names) +for (i =0 ; i <IDPF_NB_XSTATS ; i++) { +snprintf (xstats_names[i].name, +sizeof (xstats_names[i].name), +"%s" , rte_idpf_stats_strings[i].name); + } +return IDPF_NB_XSTATS ; +} +static int idpf_config_rss_hf (struct idpf_vport *vport,uint64_t rss_hf) {uint64_t hena =0 ;
@@ -1122,6 +1199,9 @@ static const struct eth_dev_ops idpf_eth_dev_ops = { .reta_query = idpf_rss_reta_query, .rss_hash_update = idpf_rss_hash_update, .rss_hash_conf_get = idpf_rss_hash_conf_get, + .xstats_get = idpf_dev_xstats_get, + .xstats_get_names = idpf_dev_xstats_get_names, + .xstats_reset = idpf_dev_xstats_reset, }; static uint16_t
Signature · 1 line
2.25.1
Zhang, Qi Z
AppliedQuoted 35 lines
-----Original Message-----
From: Mingxia Liu <[email protected]>
Sent: Wednesday, February 8, 2023 3:34 PM
To: [email protected]
Cc: Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Liu, Mingxia <[email protected]>
Subject: [PATCH v7 0/6] add idpf pmd enhancement featuresThis patchset add several enhancement features of idpf pmd. Including the following:
- add hw statistics, support stats/xstats ops
- add rss configure/show ops
- add event handle: link status
- add scattered data path for single queuev2 changes:
- Fix rss lut config issue.
v3 changes:
- rebase to the new baseline.
v4 changes:
- rebase to the new baseline.
- optimize some code
- give "not supported" tips when user want to config rss hash type
- if stats reset fails at initialization time, don't rollback, just print ERROR info.
v5 changes:
- fix some spelling error
v6 changes:
- add cover-letter
v7 changes:
- change commit msg module from "common/idpf" to "net/idpf"
Quoted 2 lines
Mingxia Liu (6):
net/idpf: add hw statistics
s/hw/HW
Quoted 2 lines
net/idpf: add RSS set/get ops
net/idpf: support single q scatter RX datapath
s/single q/singleq
s/RX/Rx
Quoted 1 line
net/idpf: add
rss_offloadhash in singleq rx
/rx/Rx
Quoted 16 lines
net/idpf: add alarm to support handle vchnl message net/idpf: add xstats ops
drivers/common/idpf/idpf_common_device.c | 17 + drivers/common/idpf/idpf_common_device.h | 10 + drivers/common/idpf/idpf_common_rxtx.c | 151 +++++ drivers/common/idpf/idpf_common_rxtx.h | 3 + drivers/common/idpf/idpf_common_virtchnl.c | 171 +++++- drivers/common/idpf/idpf_common_virtchnl.h | 15 + drivers/common/idpf/version.map | 8 + drivers/net/idpf/idpf_ethdev.c | 606 ++++++++++++++++++++- drivers/net/idpf/idpf_ethdev.h | 5 +- drivers/net/idpf/idpf_rxtx.c | 28 + drivers/net/idpf/idpf_rxtx.h | 2 + 11 files changed, 996 insertions(+), 20 deletions(-)
Quoted 2 lines
--
2.25.1
Added Reviewed-by: [email protected]<[email protected]> from v6
Applied to dpdk-next-net-intel with couple commit log check-git-log fix as above comments
Thanks
Qi
PATCH v5 2/6 common/idpf: add RSS set/get ops
In reply to Mingxia LiuAdd support for these device ops:
- rss_reta_update
- rss_reta_query
- rss_hash_update
- rss_hash_conf_get
--- drivers/common/idpf/idpf_common_device.h | 1 + drivers/common/idpf/idpf_common_virtchnl.c | 119 +++++++++ drivers/common/idpf/idpf_common_virtchnl.h | 6 + drivers/common/idpf/version.map | 3 + drivers/net/idpf/idpf_ethdev.c | 268 +++++++++++++++++++++ drivers/net/idpf/idpf_ethdev.h | 3 +- 6 files changed, 399 insertions(+), 1 deletion(-)
drivers/common/idpf/idpf_common_device.h +1 -0
@@ -98,6 +98,7 @@ struct idpf_vport {uint32_t *rss_lut;uint8_t *rss_key;uint64_t rss_hf; +uint64_t last_general_rss_hf;/* MSIX info*/ struct virtchnl2_queue_vector *qv_map;/* queue vector mapping */
drivers/common/idpf/idpf_common_virtchnl.c +119 -0
137 lines not on this page · raw message
drivers/common/idpf/idpf_common_virtchnl.h +6 -0
@@ -52,4 +52,10 @@ int idpf_vc_txq_config(struct idpf_vport *vport, struct idpf_tx_queue *txq);__rte_internal int idpf_vc_stats_query(struct idpf_vport *vport,struct virtchnl2_vport_stats **pstats); +__rte_internal +int idpf_vc_rss_key_get(struct idpf_vport *vport); +__rte_internal +int idpf_vc_rss_lut_get(struct idpf_vport *vport); +__rte_internal +int idpf_vc_rss_hash_get(struct idpf_vport *vport);#endif /* _IDPF_COMMON_VIRTCHNL_H_ */
drivers/common/idpf/version.map +3 -0
@@ -42,8 +42,11 @@ INTERNAL { idpf_vc_ptype_info_query; idpf_vc_queue_switch; idpf_vc_queues_ena_dis; + idpf_vc_rss_hash_get; idpf_vc_rss_hash_set; + idpf_vc_rss_key_get; idpf_vc_rss_key_set; + idpf_vc_rss_lut_get; idpf_vc_rss_lut_set; idpf_vc_rxq_config; idpf_vc_stats_query;
drivers/net/idpf/idpf_ethdev.c +268 -0
298 lines not on this page · raw message
drivers/net/idpf/idpf_ethdev.h +2 -1
@@ -48,7 +48,8 @@RTE_ETH_RSS_NONFRAG_IPV6_TCP | \RTE_ETH_RSS_NONFRAG_IPV6_UDP | \RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \ - RTE_ETH_RSS_NONFRAG_IPV6_OTHER) +RTE_ETH_RSS_NONFRAG_IPV6_OTHER | \ + RTE_ETH_RSS_L2_PAYLOAD) #define IDPF_ADAPTER_NAME_LEN (PCI_PRI_STR_SIZE + 1)
Signature · 1 line
2.25.1
PATCH v5 3/6 common/idpf: support single q scatter RX datapath
In reply to Mingxia LiuThis patch add single q recv scatter rx function.
--- drivers/common/idpf/idpf_common_rxtx.c | 135 +++++++++++++++++++++++++ drivers/common/idpf/idpf_common_rxtx.h | 3 + drivers/common/idpf/version.map | 1 + drivers/net/idpf/idpf_ethdev.c | 3 +- drivers/net/idpf/idpf_rxtx.c | 28 +++++ drivers/net/idpf/idpf_rxtx.h | 2 + 6 files changed, 171 insertions(+), 1 deletion(-)
drivers/common/idpf/idpf_common_rxtx.c +135 -0
@@ -1146,6 +1146,141 @@ idpf_dp_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,return nb_rx; } +uint16_t +idpf_dp_singleq_recv_scatter_pkts (void *rx_queue,struct rte_mbuf **rx_pkts, +uint16_t nb_pkts) +{ +struct idpf_rx_queue *rxq = rx_queue; +volatile union virtchnl2_rx_desc *rx_ring = rxq->rx_ring; +volatile union virtchnl2_rx_desc *rxdp; +union virtchnl2_rx_desc rxd; +struct idpf_adapter *ad; +struct rte_mbuf *first_seg = rxq->pkt_first_seg; +struct rte_mbuf *last_seg = rxq->pkt_last_seg; +struct rte_mbuf *rxm; +struct rte_mbuf *nmb; +struct rte_eth_dev *dev; +const uint32_t *ptype_tbl = rxq->adapter->ptype_tbl; +uint16_t rx_id = rxq->rx_tail; +uint16_t rx_packet_len; +uint16_t nb_hold =0 ; +uint16_t rx_status0; +uint16_t nb_rx =0 ; +uint64_t pkt_flags; +uint64_t dma_addr; +uint64_t ts_ns; + + ad = rxq->adapter; + +if (unlikely (!rxq) ||unlikely (!rxq->q_started)) +return nb_rx; + +while (nb_rx < nb_pkts) { + rxdp = &rx_ring[rx_id]; + rx_status0 =rte_le_to_cpu_16 (rxdp->flex_nic_wb.status_error0); + +/* Check the DD bit first */ +if (!(rx_status0 & (1 <<VIRTCHNL2_RX_FLEX_DESC_STATUS0_DD_S ))) +break ; + + nmb =rte_mbuf_raw_alloc (rxq->mp); +if (unlikely (!nmb)) { +__atomic_fetch_add (&rxq->rx_stats.mbuf_alloc_failed,1 , __ATOMIC_RELAXED); +RX_LOG (DEBUG ,"RX mbuf alloc failed port_id=%u " +"queue_id=%u" , rxq->port_id, rxq->queue_id); +break ; + } + + rxd = *rxdp; + + nb_hold++; + rxm = rxq->sw_ring[rx_id]; + rxq->sw_ring[rx_id] = nmb; + rx_id++; +if (unlikely (rx_id == rxq->nb_rx_desc)) + rx_id =0 ; + +/* Prefetch next mbuf */ +rte_prefetch0 (rxq->sw_ring[rx_id]); + +/* When next RX descriptor is on a cache line boundary, +* prefetch the next 4 RX descriptors and next 8 pointers +* to mbufs. +*/ +if ((rx_id &0x3 ) ==0 ) { +rte_prefetch0 (&rx_ring[rx_id]); +rte_prefetch0 (rxq->sw_ring[rx_id]); + } + dma_addr = +rte_cpu_to_le_64 (rte_mbuf_data_iova_default (nmb)); + rxdp->read.hdr_addr =0 ; + rxdp->read.pkt_addr = dma_addr; + rx_packet_len = (rte_cpu_to_le_16 (rxd.flex_nic_wb.pkt_len) & +VIRTCHNL2_RX_FLEX_DESC_PKT_LEN_M ); + rxm->data_len = rx_packet_len; + rxm->data_off =RTE_PKTMBUF_HEADROOM ; + +/** +* If this is the first buffer of the received packet, set the +* pointer to the first mbuf of the packet and initialize its +* context. Otherwise, update the total length and the number +* of segments of the current scattered packet, and update the +* pointer to the last mbuf of the current packet. +*/ +if (!first_seg) { + first_seg = rxm; + first_seg->nb_segs =1 ; + first_seg->pkt_len = rx_packet_len; + }else { + first_seg->pkt_len = + (uint16_t )(first_seg->pkt_len + + rx_packet_len); + first_seg->nb_segs++; + last_seg->next = rxm; + } + +if (!(rx_status0 & (1 <<VIRTCHNL2_RX_FLEX_DESC_STATUS0_EOF_S ))) { + last_seg = rxm; +continue ; + } + + rxm->next =NULL ; + + first_seg->port = rxq->port_id; + first_seg->ol_flags =0 ; + pkt_flags =idpf_rxd_to_pkt_flags (rx_status0); + first_seg->packet_type = + ptype_tbl[(uint8_t )(rte_cpu_to_le_16 (rxd.flex_nic_wb.ptype_flex_flags0) & +VIRTCHNL2_RX_FLEX_DESC_PTYPE_M )]; + +if (idpf_timestamp_dynflag >0 && + (rxq->offloads &IDPF_RX_OFFLOAD_TIMESTAMP ) !=0 ) { +/* timestamp */ + ts_ns =idpf_tstamp_convert_32b_64b (ad, + rxq->hw_register_set, +rte_le_to_cpu_32 (rxd.flex_nic_wb.flex_ts.ts_high)); + rxq->hw_register_set =0 ; + *RTE_MBUF_DYNFIELD (rxm, + idpf_timestamp_dynfield_offset, + rte_mbuf_timestamp_t *) = ts_ns; + first_seg->ol_flags |= idpf_timestamp_dynflag; + } + + first_seg->ol_flags |= pkt_flags; +rte_prefetch0 (RTE_PTR_ADD (first_seg->buf_addr, + first_seg->data_off)); + rx_pkts[nb_rx++] = first_seg; + first_seg =NULL ; + } + rxq->rx_tail = rx_id; + rxq->pkt_first_seg = first_seg; + rxq->pkt_last_seg = last_seg; + +idpf_update_rx_tail (rxq, nb_hold, rx_id); + +return nb_rx; +} +static inline int idpf_xmit_cleanup (struct idpf_tx_queue *txq) {
drivers/common/idpf/idpf_common_rxtx.h +3 -0
@@ -293,5 +293,8 @@ uint16_t idpf_dp_singleq_xmit_pkts_avx512(void *tx_queue,__rte_internal uint16_t idpf_dp_splitq_xmit_pkts_avx512(void *tx_queue, struct rte_mbuf **tx_pkts,uint16_t nb_pkts); +__rte_internal +uint16_t idpf_dp_singleq_recv_scatter_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, +uint16_t nb_pkts);#endif /* _IDPF_COMMON_RXTX_H_ */
drivers/common/idpf/version.map +1 -0
@@ -7,6 +7,7 @@ INTERNAL { idpf_dp_prep_pkts; idpf_dp_singleq_recv_pkts; idpf_dp_singleq_recv_pkts_avx512; + idpf_dp_singleq_recv_scatter_pkts; idpf_dp_singleq_xmit_pkts; idpf_dp_singleq_xmit_pkts_avx512; idpf_dp_splitq_recv_pkts;
drivers/net/idpf/idpf_ethdev.c +2 -1
@@ -119,7 +119,8 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)RTE_ETH_RX_OFFLOAD_UDP_CKSUM |RTE_ETH_RX_OFFLOAD_TCP_CKSUM |RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM | -RTE_ETH_RX_OFFLOAD_TIMESTAMP ; +RTE_ETH_RX_OFFLOAD_TIMESTAMP | +RTE_ETH_RX_OFFLOAD_SCATTER ; dev_info->tx_offload_capa = RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
drivers/net/idpf/idpf_rxtx.c +28 -0
@@ -503,6 +503,8 @@ int idpf_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id) {struct idpf_rx_queue *rxq; +uint16_t max_pkt_len; +uint32_t frame_size;int err;if (rx_queue_id >= dev->data->nb_rx_queues)
@@ -516,6 +518,17 @@ idpf_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id)return -EINVAL ; } + frame_size = dev->data->mtu +IDPF_ETH_OVERHEAD ; + + max_pkt_len = +RTE_MIN ((uint32_t )IDPF_SUPPORT_CHAIN_NUM * rxq->rx_buf_len, + frame_size); + + rxq->max_pkt_len = max_pkt_len; +if ((dev->data->dev_conf.rxmode.offloads &RTE_ETH_RX_OFFLOAD_SCATTER ) || + frame_size > rxq->rx_buf_len) + dev->data->scattered_rx =1 ; + err =idpf_qc_ts_mbuf_register (rxq);if (err !=0 ) { PMD_DRV_LOG(ERR, "fail to residter timestamp mbuf %u",
@@ -807,6 +820,14 @@ idpf_set_rx_function(struct rte_eth_dev *dev) }#endif /* CC_AVX512_SUPPORT */ } + +if (dev->data->scattered_rx) { +PMD_DRV_LOG (NOTICE , +"Using Single Scalar Scatterd Rx (port %d)." , + dev->data->port_id); + dev->rx_pkt_burst = idpf_dp_singleq_recv_scatter_pkts; +return ; + }PMD_DRV_LOG (NOTICE ,"Using Single Scalar Rx (port %d)." , dev->data->port_id);
@@ -819,6 +840,13 @@ idpf_set_rx_function(struct rte_eth_dev *dev) dev->data->port_id); dev->rx_pkt_burst = idpf_dp_splitq_recv_pkts; }else { +if (dev->data->scattered_rx) { +PMD_DRV_LOG (NOTICE , +"Using Single Scalar Scatterd Rx (port %d)." , + dev->data->port_id); + dev->rx_pkt_burst = idpf_dp_singleq_recv_scatter_pkts; +return ; + }PMD_DRV_LOG (NOTICE ,"Using Single Scalar Rx (port %d)." , dev->data->port_id);
drivers/net/idpf/idpf_rxtx.h +2 -0
@@ -23,6 +23,8 @@#define IDPF_DEFAULT_TX_RS_THRESH 32#define IDPF_DEFAULT_TX_FREE_THRESH 32 +#define IDPF_SUPPORT_CHAIN_NUM 5 + int idpf_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, uint16_t nb_desc, unsigned int socket_id, const struct rte_eth_rxconf *rx_conf,
Signature · 1 line
2.25.1
PATCH v5 4/6 common/idpf: add rss_offload hash in singleq rx
In reply to Mingxia LiuThis patch add rss valid flag and hash value parsing of rx descriptor.
--- drivers/common/idpf/idpf_common_rxtx.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/common/idpf/idpf_common_rxtx.c +16 -0
@@ -1030,6 +1030,20 @@ idpf_update_rx_tail(struct idpf_rx_queue *rxq, uint16_t nb_hold, rxq->nb_rx_hold = nb_hold; } +static inline void +idpf_singleq_rx_rss_offload (struct rte_mbuf *mb, +volatile struct virtchnl2_rx_flex_desc_nic *rx_desc, +uint64_t *pkt_flags) +{ +uint16_t rx_status0 =rte_le_to_cpu_16 (rx_desc->status_error0); + +if (rx_status0 &RTE_BIT32 (VIRTCHNL2_RX_FLEX_DESC_STATUS0_RSS_VALID_S )) { + *pkt_flags |=RTE_MBUF_F_RX_RSS_HASH ; + mb->hash.rss =rte_le_to_cpu_32 (rx_desc->rss_hash); + } + +} +uint16_t idpf_dp_singleq_recv_pkts (void *rx_queue,struct rte_mbuf **rx_pkts,uint16_t nb_pkts)
@@ -1118,6 +1132,7 @@ idpf_dp_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, rxm->port = rxq->port_id; rxm->ol_flags =0 ; pkt_flags =idpf_rxd_to_pkt_flags (rx_status0); +idpf_singleq_rx_rss_offload (rxm, &rxd.flex_nic_wb, &pkt_flags); rxm->packet_type = ptype_tbl[(uint8_t )(rte_cpu_to_le_16 (rxd.flex_nic_wb.ptype_flex_flags0) &VIRTCHNL2_RX_FLEX_DESC_PTYPE_M )];
@@ -1249,6 +1264,7 @@ idpf_dp_singleq_recv_scatter_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, first_seg->port = rxq->port_id; first_seg->ol_flags =0 ; pkt_flags =idpf_rxd_to_pkt_flags (rx_status0); +idpf_singleq_rx_rss_offload (first_seg, &rxd.flex_nic_wb, &pkt_flags); first_seg->packet_type = ptype_tbl[(uint8_t )(rte_cpu_to_le_16 (rxd.flex_nic_wb.ptype_flex_flags0) &VIRTCHNL2_RX_FLEX_DESC_PTYPE_M )];
Signature · 1 line
2.25.1
PATCH v5 5/6 common/idpf: add alarm to support handle vchnl message
In reply to Mingxia LiuHandle virtual channel message.
Refine link status update.
--- drivers/common/idpf/idpf_common_device.h | 5 + drivers/common/idpf/idpf_common_virtchnl.c | 33 ++-- drivers/common/idpf/idpf_common_virtchnl.h | 6 + drivers/common/idpf/version.map | 2 + drivers/net/idpf/idpf_ethdev.c | 169 ++++++++++++++++++++- drivers/net/idpf/idpf_ethdev.h | 2 + 6 files changed, 195 insertions(+), 22 deletions(-)
drivers/common/idpf/idpf_common_device.h +5 -0
@@ -118,6 +118,11 @@ struct idpf_vport {bool tx_use_avx512;struct virtchnl2_vport_stats eth_stats_offset; + +void *dev; +/* Event from ipf */ +bool link_up; +uint32_t link_speed; };/* Message type read in virtual channel from PF */
drivers/common/idpf/idpf_common_virtchnl.c +14 -19
@@ -202,25 +202,6 @@ idpf_vc_cmd_execute(struct idpf_adapter *adapter, struct idpf_cmd_info *args)switch (args->ops) {case VIRTCHNL_OP_VERSION :case VIRTCHNL2_OP_GET_CAPS : -case VIRTCHNL2_OP_CREATE_VPORT : -case VIRTCHNL2_OP_DESTROY_VPORT : -case VIRTCHNL2_OP_SET_RSS_KEY : -case VIRTCHNL2_OP_SET_RSS_LUT : -case VIRTCHNL2_OP_SET_RSS_HASH : -case VIRTCHNL2_OP_CONFIG_RX_QUEUES : -case VIRTCHNL2_OP_CONFIG_TX_QUEUES : -case VIRTCHNL2_OP_ENABLE_QUEUES : -case VIRTCHNL2_OP_DISABLE_QUEUES : -case VIRTCHNL2_OP_ENABLE_VPORT : -case VIRTCHNL2_OP_DISABLE_VPORT : -case VIRTCHNL2_OP_MAP_QUEUE_VECTOR : -case VIRTCHNL2_OP_UNMAP_QUEUE_VECTOR : -case VIRTCHNL2_OP_ALLOC_VECTORS : -case VIRTCHNL2_OP_DEALLOC_VECTORS : -case VIRTCHNL2_OP_GET_STATS : -case VIRTCHNL2_OP_GET_RSS_KEY : -case VIRTCHNL2_OP_GET_RSS_HASH : -case VIRTCHNL2_OP_GET_RSS_LUT :/* for init virtchnl ops, need to poll the response */ err =idpf_vc_one_msg_read (adapter, args->ops, args->out_size, args->out_buffer);clear_cmd (adapter);
@@ -1111,3 +1092,17 @@ idpf_vc_txq_config(struct idpf_vport *vport, struct idpf_tx_queue *txq)return err; } + +int +idpf_vc_ctlq_recv (struct idpf_ctlq_info *cq,u16 *num_q_msg, +struct idpf_ctlq_msg *q_msg) +{ +return idpf_ctlq_recv (cq, num_q_msg, q_msg); +} + +int +idpf_vc_ctlq_post_rx_buffs (struct idpf_hw *hw,struct idpf_ctlq_info *cq, +u16 *buff_count,struct idpf_dma_mem **buffs) +{ +return idpf_ctlq_post_rx_buffs (hw, cq, buff_count, buffs); +}
drivers/common/idpf/idpf_common_virtchnl.h +6 -0
@@ -58,4 +58,10 @@ __rte_internalint idpf_vc_rss_lut_get (struct idpf_vport *vport);__rte_internal int idpf_vc_rss_hash_get(struct idpf_vport *vport); +__rte_internal +int idpf_vc_ctlq_recv(struct idpf_ctlq_info *cq, u16 *num_q_msg, +struct idpf_ctlq_msg *q_msg); +__rte_internal +int idpf_vc_ctlq_post_rx_buffs(struct idpf_hw *hw, struct idpf_ctlq_info *cq, +u16 *buff_count,struct idpf_dma_mem **buffs);#endif /* _IDPF_COMMON_VIRTCHNL_H_ */
drivers/common/idpf/version.map +2 -0
@@ -38,6 +38,8 @@ INTERNAL { idpf_vc_api_version_check; idpf_vc_caps_get; idpf_vc_cmd_execute; + idpf_vc_ctlq_post_rx_buffs; + idpf_vc_ctlq_recv; idpf_vc_irq_map_unmap_config; idpf_vc_one_msg_read; idpf_vc_ptype_info_query;
drivers/net/idpf/idpf_ethdev.c +166 -3
210 lines not on this page · raw message
drivers/net/idpf/idpf_ethdev.h +2 -0
@@ -53,6 +53,8 @@#define IDPF_ADAPTER_NAME_LEN (PCI_PRI_STR_SIZE + 1) +#define IDPF_ALARM_INTERVAL 50000/* us */ +struct idpf_vport_param {struct idpf_adapter_ext *adapter;uint16_t devarg_id;/* arg id from user */
Signature · 1 line
2.25.1
PATCH v5 6/6 common/idpf: add xstats ops
In reply to Mingxia LiuAdd support for these device ops:
-idpf_dev_xstats_get
-idpf_dev_xstats_get_names
-idpf_dev_xstats_reset
--- drivers/net/idpf/idpf_ethdev.c | 80 ++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+)
drivers/net/idpf/idpf_ethdev.c +80 -0
@@ -80,6 +80,30 @@ static const uint64_t idpf_ipv6_rss = RTE_ETH_RSS_NONFRAG_IPV6_UDP |RTE_ETH_RSS_NONFRAG_IPV6_OTHER |RTE_ETH_RSS_FRAG_IPV6 ; +struct rte_idpf_xstats_name_off { +char name[RTE_ETH_XSTATS_NAME_SIZE ]; +unsigned int offset; +}; + +static const struct rte_idpf_xstats_name_off rte_idpf_stats_strings[] = { + {"rx_bytes" , offsetof(struct virtchnl2_vport_stats , rx_bytes)}, + {"rx_unicast_packets" , offsetof(struct virtchnl2_vport_stats , rx_unicast)}, + {"rx_multicast_packets" , offsetof(struct virtchnl2_vport_stats , rx_multicast)}, + {"rx_broadcast_packets" , offsetof(struct virtchnl2_vport_stats , rx_broadcast)}, + {"rx_dropped_packets" , offsetof(struct virtchnl2_vport_stats , rx_discards)}, + {"rx_errors" , offsetof(struct virtchnl2_vport_stats , rx_errors)}, + {"rx_unknown_protocol_packets" , offsetof(struct virtchnl2_vport_stats , + rx_unknown_protocol)}, + {"tx_bytes" , offsetof(struct virtchnl2_vport_stats , tx_bytes)}, + {"tx_unicast_packets" , offsetof(struct virtchnl2_vport_stats , tx_unicast)}, + {"tx_multicast_packets" , offsetof(struct virtchnl2_vport_stats , tx_multicast)}, + {"tx_broadcast_packets" , offsetof(struct virtchnl2_vport_stats , tx_broadcast)}, + {"tx_dropped_packets" , offsetof(struct virtchnl2_vport_stats , tx_discards)}, + {"tx_error_packets" , offsetof(struct virtchnl2_vport_stats , tx_errors)}}; + +#define IDPF_NB_XSTATS (sizeof(rte_idpf_stats_strings) / \ + sizeof(rte_idpf_stats_strings[0])) +static int idpf_dev_link_update (struct rte_eth_dev *dev, __rte_unused int wait_to_complete)
@@ -313,6 +337,59 @@ idpf_dev_stats_reset(struct rte_eth_dev *dev)return 0 ; } +static int idpf_dev_xstats_reset (struct rte_eth_dev *dev) +{ +idpf_dev_stats_reset (dev); +return 0 ; +} + +static int idpf_dev_xstats_get (struct rte_eth_dev *dev, +struct rte_eth_xstat *xstats,unsigned int n) +{ +struct idpf_vport *vport = + (struct idpf_vport *)dev->data->dev_private; +struct virtchnl2_vport_stats *pstats =NULL ; +unsigned int i; +int ret; + +if (n <IDPF_NB_XSTATS ) +return IDPF_NB_XSTATS ; + +if (!xstats) +return 0 ; + + ret =idpf_vc_stats_query (vport, &pstats); +if (ret) { +PMD_DRV_LOG (ERR ,"Get statistics failed" ); +return 0 ; + } + +idpf_vport_stats_update (&vport->eth_stats_offset, pstats); + +/* loop over xstats array and values from pstats */ +for (i =0 ; i <IDPF_NB_XSTATS ; i++) { + xstats[i].id = i; + xstats[i].value = *(uint64_t *)(((char *)pstats) + + rte_idpf_stats_strings[i].offset); + } +return IDPF_NB_XSTATS ; +} + +static int idpf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, +struct rte_eth_xstat_name *xstats_names, + __rte_unused unsigned int limit) +{ +unsigned int i; + +if (xstats_names) +for (i =0 ; i <IDPF_NB_XSTATS ; i++) { +snprintf (xstats_names[i].name, +sizeof (xstats_names[i].name), +"%s" , rte_idpf_stats_strings[i].name); + } +return IDPF_NB_XSTATS ; +} +static int idpf_config_rss_hf (struct idpf_vport *vport,uint64_t rss_hf) {uint64_t hena =0 ;
@@ -1122,6 +1199,9 @@ static const struct eth_dev_ops idpf_eth_dev_ops = { .reta_query = idpf_rss_reta_query, .rss_hash_update = idpf_rss_hash_update, .rss_hash_conf_get = idpf_rss_hash_conf_get, + .xstats_get = idpf_dev_xstats_get, + .xstats_get_names = idpf_dev_xstats_get_names, + .xstats_reset = idpf_dev_xstats_reset, }; static uint16_t
Signature · 1 line
2.25.1