4 * Copyright (c) 2015-2017 Atomic Rules LLC
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of copyright holder nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 ark_udm_verify(struct ark_udm_t *udm)
42 if (sizeof(struct ark_udm_t) != ARK_UDM_EXPECT_SIZE) {
44 "ARK: UDM structure looks incorrect %d vs %zd\n",
45 ARK_UDM_EXPECT_SIZE, sizeof(struct ark_udm_t));
49 if (udm->setup.const0 != ARK_UDM_CONST) {
51 "ARK: UDM module not found as expected 0x%08x\n",
59 ark_udm_stop(struct ark_udm_t *udm, const int wait)
65 while (wait && (udm->cfg.stop_flushed & 0x01) == 0) {
75 ark_udm_reset(struct ark_udm_t *udm)
79 status = ark_udm_stop(udm, 1);
81 PMD_DEBUG_LOG(INFO, "%s stop failed doing forced reset\n",
86 status = ark_udm_stop(udm, 0);
87 PMD_DEBUG_LOG(INFO, "%s stop status %d post failure"
88 " and forced reset\n",
98 ark_udm_start(struct ark_udm_t *udm)
100 udm->cfg.command = 1;
104 ark_udm_stats_reset(struct ark_udm_t *udm)
106 udm->pcibp.pci_clear = 1;
107 udm->tlp_ps.tlp_clear = 1;
111 ark_udm_configure(struct ark_udm_t *udm,
114 uint32_t write_interval_ns)
116 /* headroom and data room are in DWords in the UDM */
117 udm->cfg.dataroom = dataroom / 4;
118 udm->cfg.headroom = headroom / 4;
121 udm->rt_cfg.write_interval = write_interval_ns / 4;
125 ark_udm_write_addr(struct ark_udm_t *udm, phys_addr_t addr)
127 udm->rt_cfg.hw_prod_addr = addr;
131 ark_udm_is_flushed(struct ark_udm_t *udm)
133 return (udm->cfg.stop_flushed & 0x01) != 0;
137 ark_udm_dropped(struct ark_udm_t *udm)
139 return udm->qstats.q_pkt_drop;
143 ark_udm_bytes(struct ark_udm_t *udm)
145 return udm->qstats.q_byte_count;
149 ark_udm_packets(struct ark_udm_t *udm)
151 return udm->qstats.q_ff_packet_count;
155 ark_udm_dump_stats(struct ark_udm_t *udm, const char *msg)
157 PMD_STATS_LOG(INFO, "UDM Stats: %s"
158 ARK_SU64 ARK_SU64 ARK_SU64 ARK_SU64 ARK_SU64 "\n",
160 "Pkts Received", udm->stats.rx_packet_count,
161 "Pkts Finalized", udm->stats.rx_sent_packets,
162 "Pkts Dropped", udm->tlp.pkt_drop,
163 "Bytes Count", udm->stats.rx_byte_count,
164 "MBuf Count", udm->stats.rx_mbuf_count);
168 ark_udm_dump_queue_stats(struct ark_udm_t *udm, const char *msg, uint16_t qid)
170 PMD_STATS_LOG(INFO, "UDM Queue %3u Stats: %s"
175 "Pkts Received", udm->qstats.q_packet_count,
176 "Pkts Finalized", udm->qstats.q_ff_packet_count,
177 "Pkts Dropped", udm->qstats.q_pkt_drop,
178 "Bytes Count", udm->qstats.q_byte_count,
179 "MBuf Count", udm->qstats.q_mbuf_count);
183 ark_udm_dump(struct ark_udm_t *udm, const char *msg)
185 PMD_DEBUG_LOG(DEBUG, "UDM Dump: %s Stopped: %d\n", msg,
186 udm->cfg.stop_flushed);
190 ark_udm_dump_setup(struct ark_udm_t *udm, uint16_t q_id)
192 PMD_DEBUG_LOG(DEBUG, "UDM Setup Q: %u"
193 ARK_SU64X ARK_SU32 "\n",
195 "hw_prod_addr", udm->rt_cfg.hw_prod_addr,
196 "prod_idx", udm->rt_cfg.prod_idx);
200 ark_udm_dump_perf(struct ark_udm_t *udm, const char *msg)
202 struct ark_udm_pcibp_t *bp = &udm->pcibp;
204 PMD_STATS_LOG(INFO, "UDM Performance %s"
205 ARK_SU32 ARK_SU32 ARK_SU32 ARK_SU32 ARK_SU32 ARK_SU32
208 "PCI Empty", bp->pci_empty,
209 "PCI Q1", bp->pci_q1,
210 "PCI Q2", bp->pci_q2,
211 "PCI Q3", bp->pci_q3,
212 "PCI Q4", bp->pci_q4,
213 "PCI Full", bp->pci_full);
217 ark_udm_queue_stats_reset(struct ark_udm_t *udm)
219 udm->qstats.q_byte_count = 1;
223 ark_udm_queue_enable(struct ark_udm_t *udm, int enable)
225 udm->qstats.q_enable = enable ? 1 : 0;