1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (c) 2015-2018 Atomic Rules LLC
10 static_assert(sizeof(struct ark_rx_meta) == 32, "Unexpected struct size ark_rx_meta");
13 ark_udm_verify(struct ark_udm_t *udm)
15 if (sizeof(struct ark_udm_t) != ARK_UDM_EXPECT_SIZE) {
17 "ARK: UDM structure looks incorrect %d vs %zd\n",
18 ARK_UDM_EXPECT_SIZE, sizeof(struct ark_udm_t));
22 if (udm->setup.const0 != ARK_UDM_CONST) {
24 "ARK: UDM module not found as expected 0x%08x\n",
32 ark_udm_stop(struct ark_udm_t *udm, const int wait)
38 while (wait && (udm->cfg.stop_flushed & 0x01) == 0) {
48 ark_udm_reset(struct ark_udm_t *udm)
52 status = ark_udm_stop(udm, 1);
54 ARK_PMD_LOG(NOTICE, "%s stop failed doing forced reset\n",
59 status = ark_udm_stop(udm, 0);
60 ARK_PMD_LOG(INFO, "%s stop status %d post failure"
61 " and forced reset\n",
71 ark_udm_start(struct ark_udm_t *udm)
77 ark_udm_stats_reset(struct ark_udm_t *udm)
79 udm->pcibp.pci_clear = 1;
80 udm->tlp_ps.tlp_clear = 1;
84 ark_udm_configure(struct ark_udm_t *udm,
87 uint32_t write_interval_ns)
89 /* headroom and data room are in DWords in the UDM */
90 udm->cfg.dataroom = dataroom / 4;
91 udm->cfg.headroom = headroom / 4;
94 udm->rt_cfg.write_interval = write_interval_ns / 4;
98 ark_udm_write_addr(struct ark_udm_t *udm, rte_iova_t addr)
100 udm->rt_cfg.hw_prod_addr = addr;
104 ark_udm_is_flushed(struct ark_udm_t *udm)
106 return (udm->cfg.stop_flushed & 0x01) != 0;
110 ark_udm_dropped(struct ark_udm_t *udm)
112 return udm->qstats.q_pkt_drop;
116 ark_udm_bytes(struct ark_udm_t *udm)
118 return udm->qstats.q_byte_count;
122 ark_udm_packets(struct ark_udm_t *udm)
124 return udm->qstats.q_ff_packet_count;
128 ark_udm_dump_stats(struct ark_udm_t *udm, const char *msg)
130 ARK_PMD_LOG(INFO, "UDM Stats: %s"
131 ARK_SU64 ARK_SU64 ARK_SU64 ARK_SU64 ARK_SU64 "\n",
133 "Pkts Received", udm->stats.rx_packet_count,
134 "Pkts Finalized", udm->stats.rx_sent_packets,
135 "Pkts Dropped", udm->tlp.pkt_drop,
136 "Bytes Count", udm->stats.rx_byte_count,
137 "MBuf Count", udm->stats.rx_mbuf_count);
141 ark_udm_dump_queue_stats(struct ark_udm_t *udm, const char *msg, uint16_t qid)
143 ARK_PMD_LOG(INFO, "UDM Queue %3u Stats: %s"
148 "Pkts Received", udm->qstats.q_packet_count,
149 "Pkts Finalized", udm->qstats.q_ff_packet_count,
150 "Pkts Dropped", udm->qstats.q_pkt_drop,
151 "Bytes Count", udm->qstats.q_byte_count,
152 "MBuf Count", udm->qstats.q_mbuf_count);
156 ark_udm_dump(struct ark_udm_t *udm, const char *msg)
158 ARK_PMD_LOG(DEBUG, "UDM Dump: %s Stopped: %d\n", msg,
159 udm->cfg.stop_flushed);
163 ark_udm_dump_setup(struct ark_udm_t *udm, uint16_t q_id)
165 ARK_PMD_LOG(DEBUG, "UDM Setup Q: %u"
166 ARK_SU64X ARK_SU32 "\n",
168 "hw_prod_addr", udm->rt_cfg.hw_prod_addr,
169 "prod_idx", udm->rt_cfg.prod_idx);
173 ark_udm_dump_perf(struct ark_udm_t *udm, const char *msg)
175 struct ark_udm_pcibp_t *bp = &udm->pcibp;
177 ARK_PMD_LOG(INFO, "UDM Performance %s"
178 ARK_SU32 ARK_SU32 ARK_SU32 ARK_SU32 ARK_SU32 ARK_SU32
181 "PCI Empty", bp->pci_empty,
182 "PCI Q1", bp->pci_q1,
183 "PCI Q2", bp->pci_q2,
184 "PCI Q3", bp->pci_q3,
185 "PCI Q4", bp->pci_q4,
186 "PCI Full", bp->pci_full);
190 ark_udm_queue_stats_reset(struct ark_udm_t *udm)
192 udm->qstats.q_byte_count = 1;
196 ark_udm_queue_enable(struct ark_udm_t *udm, int enable)
198 udm->qstats.q_enable = enable ? 1 : 0;