| 5006 | } |
| 5007 | |
| 5008 | static int bnxt_alloc_stats_mem(struct bnxt *bp) |
| 5009 | { |
| 5010 | struct rte_pci_device *pci_dev = bp->pdev; |
| 5011 | char mz_name[RTE_MEMZONE_NAMESIZE]; |
| 5012 | const struct rte_memzone *mz = NULL; |
| 5013 | uint32_t total_alloc_len; |
| 5014 | rte_iova_t mz_phys_addr; |
| 5015 | |
| 5016 | if (pci_dev->id.device_id == BROADCOM_DEV_ID_NS2) |
| 5017 | return 0; |
| 5018 | |
| 5019 | snprintf(mz_name, RTE_MEMZONE_NAMESIZE, |
| 5020 | "bnxt_" PCI_PRI_FMT "-%s", pci_dev->addr.domain, |
| 5021 | pci_dev->addr.bus, pci_dev->addr.devid, |
| 5022 | pci_dev->addr.function, "rx_port_stats"); |
| 5023 | mz_name[RTE_MEMZONE_NAMESIZE - 1] = 0; |
| 5024 | mz = rte_memzone_lookup(mz_name); |
| 5025 | total_alloc_len = |
| 5026 | RTE_CACHE_LINE_ROUNDUP(sizeof(struct rx_port_stats) + |
| 5027 | sizeof(struct rx_port_stats_ext) + 512); |
| 5028 | if (!mz) { |
| 5029 | mz = rte_memzone_reserve(mz_name, total_alloc_len, |
| 5030 | SOCKET_ID_ANY, |
| 5031 | RTE_MEMZONE_2MB | |
| 5032 | RTE_MEMZONE_SIZE_HINT_ONLY | |
| 5033 | RTE_MEMZONE_IOVA_CONTIG); |
| 5034 | if (mz == NULL) |
| 5035 | return -ENOMEM; |
| 5036 | } |
| 5037 | memset(mz->addr, 0, mz->len); |
| 5038 | mz_phys_addr = mz->iova; |
| 5039 | |
| 5040 | bp->rx_mem_zone = (const void *)mz; |
| 5041 | bp->hw_rx_port_stats = mz->addr; |
| 5042 | bp->hw_rx_port_stats_map = mz_phys_addr; |
| 5043 | |
| 5044 | snprintf(mz_name, RTE_MEMZONE_NAMESIZE, |
| 5045 | "bnxt_" PCI_PRI_FMT "-%s", pci_dev->addr.domain, |
| 5046 | pci_dev->addr.bus, pci_dev->addr.devid, |
| 5047 | pci_dev->addr.function, "tx_port_stats"); |
| 5048 | mz_name[RTE_MEMZONE_NAMESIZE - 1] = 0; |
| 5049 | mz = rte_memzone_lookup(mz_name); |
| 5050 | total_alloc_len = |
| 5051 | RTE_CACHE_LINE_ROUNDUP(sizeof(struct tx_port_stats) + |
| 5052 | sizeof(struct tx_port_stats_ext) + 512); |
| 5053 | if (!mz) { |
| 5054 | mz = rte_memzone_reserve(mz_name, |
| 5055 | total_alloc_len, |
| 5056 | SOCKET_ID_ANY, |
| 5057 | RTE_MEMZONE_2MB | |
| 5058 | RTE_MEMZONE_SIZE_HINT_ONLY | |
| 5059 | RTE_MEMZONE_IOVA_CONTIG); |
| 5060 | if (mz == NULL) |
| 5061 | return -ENOMEM; |
| 5062 | } |
| 5063 | memset(mz->addr, 0, mz->len); |
| 5064 | mz_phys_addr = mz->iova; |
| 5065 |
no test coverage detected