| 748 | } |
| 749 | |
| 750 | int |
| 751 | ionic_rx_qcq_alloc(struct ionic_lif *lif, uint32_t socket_id, uint32_t index, |
| 752 | uint16_t nrxq_descs, struct rte_mempool *mb_pool, |
| 753 | struct ionic_rx_qcq **rxq_out) |
| 754 | { |
| 755 | struct ionic_rx_qcq *rxq; |
| 756 | uint16_t flags = 0, seg_size, hdr_seg_size, max_segs, max_segs_fw = 1; |
| 757 | uint32_t max_mtu; |
| 758 | int err; |
| 759 | |
| 760 | if (lif->state & IONIC_LIF_F_Q_IN_CMB) |
| 761 | flags |= IONIC_QCQ_F_CMB; |
| 762 | |
| 763 | seg_size = rte_pktmbuf_data_room_size(mb_pool); |
| 764 | |
| 765 | /* The first mbuf needs to leave headroom */ |
| 766 | hdr_seg_size = seg_size - RTE_PKTMBUF_HEADROOM; |
| 767 | |
| 768 | max_mtu = rte_le_to_cpu_32(lif->adapter->ident.lif.eth.max_mtu); |
| 769 | |
| 770 | /* If mbufs are too small to hold received packets, enable SG */ |
| 771 | if (max_mtu > hdr_seg_size) { |
| 772 | IONIC_PRINT(NOTICE, "Enabling RX_OFFLOAD_SCATTER"); |
| 773 | lif->eth_dev->data->dev_conf.rxmode.offloads |= |
| 774 | RTE_ETH_RX_OFFLOAD_SCATTER; |
| 775 | ionic_lif_configure_rx_sg_offload(lif); |
| 776 | } |
| 777 | |
| 778 | if (lif->features & IONIC_ETH_HW_RX_SG) { |
| 779 | flags |= IONIC_QCQ_F_SG; |
| 780 | max_segs_fw = IONIC_RX_MAX_SG_ELEMS + 1; |
| 781 | } |
| 782 | |
| 783 | /* |
| 784 | * Calculate how many fragment pointers might be stored in queue. |
| 785 | * This is the worst-case number, so that there's enough room in |
| 786 | * the info array. |
| 787 | */ |
| 788 | max_segs = 1 + (max_mtu + RTE_PKTMBUF_HEADROOM - 1) / seg_size; |
| 789 | |
| 790 | IONIC_PRINT(DEBUG, "rxq %u max_mtu %u seg_size %u max_segs %u", |
| 791 | index, max_mtu, seg_size, max_segs); |
| 792 | if (max_segs > max_segs_fw) { |
| 793 | IONIC_PRINT(ERR, "Rx mbuf size insufficient (%d > %d avail)", |
| 794 | max_segs, max_segs_fw); |
| 795 | return -EINVAL; |
| 796 | } |
| 797 | |
| 798 | err = ionic_qcq_alloc(lif, |
| 799 | IONIC_QTYPE_RXQ, |
| 800 | sizeof(struct ionic_rx_qcq), |
| 801 | socket_id, |
| 802 | index, |
| 803 | "rx", |
| 804 | flags, |
| 805 | nrxq_descs, |
| 806 | max_segs, |
| 807 | sizeof(struct ionic_rxq_desc), |
no test coverage detected