* Allocates a completion ring with vmem and stats optionally also allocating * a TX and/or RX ring. Passing NULL as tx_ring_info and/or rx_ring_info * to not allocate them. * * Order in the allocation is: * stats - Always non-zero length * cp vmem - Always zero-length, supported for the bnxt_ring abstraction * tx vmem - Only non-zero length if tx_ring_info is not NULL * rx vmem - Only non
| 95 | * rx bd ring - Only non-zero length if rx_ring_info is not NULL |
| 96 | */ |
| 97 | int bnxt_alloc_rings(struct bnxt *bp, unsigned int socket_id, uint16_t qidx, |
| 98 | struct bnxt_tx_queue *txq, |
| 99 | struct bnxt_rx_queue *rxq, |
| 100 | struct bnxt_cp_ring_info *cp_ring_info, |
| 101 | struct bnxt_cp_ring_info *nq_ring_info, |
| 102 | const char *suffix) |
| 103 | { |
| 104 | struct bnxt_ring *cp_ring = cp_ring_info->cp_ring_struct; |
| 105 | struct bnxt_rx_ring_info *rx_ring_info = rxq ? rxq->rx_ring : NULL; |
| 106 | struct bnxt_tx_ring_info *tx_ring_info = txq ? txq->tx_ring : NULL; |
| 107 | uint64_t rx_offloads = bp->eth_dev->data->dev_conf.rxmode.offloads; |
| 108 | int ag_ring_start, ag_bitmap_start, tpa_info_start; |
| 109 | int ag_vmem_start, cp_ring_start, nq_ring_start; |
| 110 | int total_alloc_len, rx_ring_start, rx_ring_len; |
| 111 | struct rte_pci_device *pdev = bp->pdev; |
| 112 | struct bnxt_ring *tx_ring, *rx_ring; |
| 113 | const struct rte_memzone *mz = NULL; |
| 114 | char mz_name[RTE_MEMZONE_NAMESIZE]; |
| 115 | rte_iova_t mz_phys_addr; |
| 116 | int ag_bitmap_len = 0; |
| 117 | int tpa_info_len = 0; |
| 118 | int ag_vmem_len = 0; |
| 119 | int ag_ring_len = 0; |
| 120 | |
| 121 | int stats_len = (tx_ring_info || rx_ring_info) ? |
| 122 | RTE_CACHE_LINE_ROUNDUP(sizeof(struct hwrm_stat_ctx_query_output) - |
| 123 | sizeof (struct hwrm_resp_hdr)) : 0; |
| 124 | stats_len = RTE_ALIGN(stats_len, 128); |
| 125 | |
| 126 | int cp_vmem_start = stats_len; |
| 127 | int cp_vmem_len = RTE_CACHE_LINE_ROUNDUP(cp_ring->vmem_size); |
| 128 | cp_vmem_len = RTE_ALIGN(cp_vmem_len, 128); |
| 129 | |
| 130 | int nq_vmem_len = nq_ring_info ? |
| 131 | RTE_CACHE_LINE_ROUNDUP(cp_ring->vmem_size) : 0; |
| 132 | nq_vmem_len = RTE_ALIGN(nq_vmem_len, 128); |
| 133 | |
| 134 | int nq_vmem_start = cp_vmem_start + cp_vmem_len; |
| 135 | |
| 136 | int tx_vmem_start = nq_vmem_start + nq_vmem_len; |
| 137 | int tx_vmem_len = |
| 138 | tx_ring_info ? RTE_CACHE_LINE_ROUNDUP(tx_ring_info-> |
| 139 | tx_ring_struct->vmem_size) : 0; |
| 140 | tx_vmem_len = RTE_ALIGN(tx_vmem_len, 128); |
| 141 | |
| 142 | int rx_vmem_start = tx_vmem_start + tx_vmem_len; |
| 143 | int rx_vmem_len = rx_ring_info ? |
| 144 | RTE_CACHE_LINE_ROUNDUP(rx_ring_info-> |
| 145 | rx_ring_struct->vmem_size) : 0; |
| 146 | rx_vmem_len = RTE_ALIGN(rx_vmem_len, 128); |
| 147 | |
| 148 | ag_vmem_start = rx_vmem_start + rx_vmem_len; |
| 149 | if (bnxt_need_agg_ring(bp->eth_dev)) |
| 150 | ag_vmem_len = rx_ring_info && rx_ring_info->ag_ring_struct ? |
| 151 | RTE_CACHE_LINE_ROUNDUP(rx_ring_info->ag_ring_struct->vmem_size) : 0; |
| 152 | |
| 153 | cp_ring_start = ag_vmem_start + ag_vmem_len; |
| 154 | cp_ring_start = RTE_ALIGN(cp_ring_start, 4096); |
no test coverage detected