Configure the Rx with optional split. */
| 2806 | |
| 2807 | /* Configure the Rx with optional split. */ |
| 2808 | int |
| 2809 | rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, |
| 2810 | uint16_t nb_rx_desc, unsigned int socket_id, |
| 2811 | struct rte_eth_rxconf *rx_conf, struct rte_mempool *mp) |
| 2812 | { |
| 2813 | union rte_eth_rxseg rx_useg[MAX_SEGS_BUFFER_SPLIT] = {}; |
| 2814 | struct rte_mempool *rx_mempool[MAX_MEMPOOL] = {}; |
| 2815 | struct rte_mempool *mpx; |
| 2816 | unsigned int i, mp_n; |
| 2817 | uint32_t prev_hdrs = 0; |
| 2818 | int ret; |
| 2819 | |
| 2820 | |
| 2821 | if ((rx_pkt_nb_segs > 1) && |
| 2822 | (rx_conf->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT)) { |
| 2823 | /* multi-segment configuration */ |
| 2824 | for (i = 0; i < rx_pkt_nb_segs; i++) { |
| 2825 | struct rte_eth_rxseg_split *rx_seg = &rx_useg[i].split; |
| 2826 | /* |
| 2827 | * Use last valid pool for the segments with number |
| 2828 | * exceeding the pool index. |
| 2829 | */ |
| 2830 | mp_n = (i >= mbuf_data_size_n) ? mbuf_data_size_n - 1 : i; |
| 2831 | mpx = mbuf_pool_find(socket_id, mp_n); |
| 2832 | /* Handle zero as mbuf data buffer size. */ |
| 2833 | rx_seg->offset = i < rx_pkt_nb_offs ? |
| 2834 | rx_pkt_seg_offsets[i] : 0; |
| 2835 | rx_seg->mp = mpx ? mpx : mp; |
| 2836 | if (rx_pkt_hdr_protos[i] != 0 && rx_pkt_seg_lengths[i] == 0) { |
| 2837 | rx_seg->proto_hdr = rx_pkt_hdr_protos[i] & ~prev_hdrs; |
| 2838 | prev_hdrs |= rx_seg->proto_hdr; |
| 2839 | } else { |
| 2840 | rx_seg->length = rx_pkt_seg_lengths[i] ? |
| 2841 | rx_pkt_seg_lengths[i] : |
| 2842 | mbuf_data_size[mp_n]; |
| 2843 | } |
| 2844 | } |
| 2845 | rx_conf->rx_nseg = rx_pkt_nb_segs; |
| 2846 | rx_conf->rx_seg = rx_useg; |
| 2847 | rx_conf->rx_mempools = NULL; |
| 2848 | rx_conf->rx_nmempool = 0; |
| 2849 | ret = rte_eth_rx_queue_setup(port_id, rx_queue_id, nb_rx_desc, |
| 2850 | socket_id, rx_conf, NULL); |
| 2851 | rx_conf->rx_seg = NULL; |
| 2852 | rx_conf->rx_nseg = 0; |
| 2853 | } else if (multi_rx_mempool == 1) { |
| 2854 | /* multi-pool configuration */ |
| 2855 | struct rte_eth_dev_info dev_info; |
| 2856 | |
| 2857 | if (mbuf_data_size_n <= 1) { |
| 2858 | fprintf(stderr, "Invalid number of mempools %u\n", |
| 2859 | mbuf_data_size_n); |
| 2860 | return -EINVAL; |
| 2861 | } |
| 2862 | ret = rte_eth_dev_info_get(port_id, &dev_info); |
| 2863 | if (ret != 0) |
| 2864 | return ret; |
| 2865 | if (dev_info.max_rx_mempools == 0) { |
no test coverage detected