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.
39 /* ************************************************************************* */
41 ark_ddm_verify(struct ark_ddm_t *ddm)
43 if (sizeof(struct ark_ddm_t) != ARK_DDM_EXPECTED_SIZE) {
44 PMD_DRV_LOG(ERR, "ARK: DDM structure looks incorrect %d vs %zd\n",
45 ARK_DDM_EXPECTED_SIZE, sizeof(struct ark_ddm_t));
49 if (ddm->cfg.const0 != ARK_DDM_CONST) {
50 PMD_DRV_LOG(ERR, "ARK: DDM module not found as expected 0x%08x\n",
58 ark_ddm_start(struct ark_ddm_t *ddm)
64 ark_ddm_stop(struct ark_ddm_t *ddm, const int wait)
69 while (wait && (ddm->cfg.stop_flushed & 0x01) == 0) {
79 ark_ddm_reset(struct ark_ddm_t *ddm)
83 /* reset only works if ddm has stopped properly. */
84 status = ark_ddm_stop(ddm, 1);
87 PMD_DEBUG_LOG(INFO, "%s stop failed doing forced reset\n",
96 ark_ddm_setup(struct ark_ddm_t *ddm, phys_addr_t cons_addr, uint32_t interval)
98 ddm->setup.cons_write_index_addr = cons_addr;
99 ddm->setup.write_index_interval = interval / 4; /* 4 ns period */
103 ark_ddm_stats_reset(struct ark_ddm_t *ddm)
105 ddm->cfg.tlp_stats_clear = 1;
109 ark_ddm_dump(struct ark_ddm_t *ddm, const char *msg)
111 PMD_FUNC_LOG(DEBUG, "%s Stopped: %d\n", msg,
112 ark_ddm_is_stopped(ddm)
117 ark_ddm_dump_stats(struct ark_ddm_t *ddm, const char *msg)
119 struct ark_ddm_stats_t *stats = &ddm->stats;
121 PMD_STATS_LOG(INFO, "DDM Stats: %s"
122 ARK_SU64 ARK_SU64 ARK_SU64
124 "Bytes:", stats->tx_byte_count,
125 "Packets:", stats->tx_pkt_count,
126 "MBufs", stats->tx_mbuf_count);
130 ark_ddm_is_stopped(struct ark_ddm_t *ddm)
132 return (ddm->cfg.stop_flushed & 0x01) != 0;
136 ark_ddm_queue_byte_count(struct ark_ddm_t *ddm)
138 return ddm->queue_stats.byte_count;
142 ark_ddm_queue_pkt_count(struct ark_ddm_t *ddm)
144 return ddm->queue_stats.pkt_count;
148 ark_ddm_queue_reset_stats(struct ark_ddm_t *ddm)
150 ddm->queue_stats.byte_count = 1;