1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (c) 2015-2018 Atomic Rules LLC
10 /* ************************************************************************* */
12 ark_ddm_verify(struct ark_ddm_t *ddm)
15 if (sizeof(struct ark_ddm_t) != ARK_DDM_EXPECTED_SIZE) {
16 PMD_DRV_LOG(ERR, "ARK: DDM structure looks incorrect %d vs %zd\n",
17 ARK_DDM_EXPECTED_SIZE, sizeof(struct ark_ddm_t));
21 hw_const = ddm->cfg.const0;
22 if (hw_const == ARK_DDM_CONST1) {
24 "ARK: DDM module is version 1, "
25 "PMD expects version 2\n");
27 } else if (hw_const != ARK_DDM_CONST2) {
29 "ARK: DDM module not found as expected 0x%08x\n",
37 ark_ddm_start(struct ark_ddm_t *ddm)
43 ark_ddm_stop(struct ark_ddm_t *ddm, const int wait)
48 while (wait && (ddm->cfg.stop_flushed & 0x01) == 0) {
58 ark_ddm_reset(struct ark_ddm_t *ddm)
62 /* reset only works if ddm has stopped properly. */
63 status = ark_ddm_stop(ddm, 1);
66 PMD_DEBUG_LOG(INFO, "%s stop failed doing forced reset\n",
75 ark_ddm_setup(struct ark_ddm_t *ddm, rte_iova_t cons_addr, uint32_t interval)
77 ddm->setup.cons_write_index_addr = cons_addr;
78 ddm->setup.write_index_interval = interval / 4; /* 4 ns period */
82 ark_ddm_stats_reset(struct ark_ddm_t *ddm)
84 ddm->cfg.tlp_stats_clear = 1;
88 ark_ddm_dump(struct ark_ddm_t *ddm, const char *msg)
90 PMD_FUNC_LOG(DEBUG, "%s Stopped: %d\n", msg,
91 ark_ddm_is_stopped(ddm)
96 ark_ddm_dump_stats(struct ark_ddm_t *ddm, const char *msg)
98 struct ark_ddm_stats_t *stats = &ddm->stats;
100 PMD_STATS_LOG(INFO, "DDM Stats: %s"
101 ARK_SU64 ARK_SU64 ARK_SU64
103 "Bytes:", stats->tx_byte_count,
104 "Packets:", stats->tx_pkt_count,
105 "MBufs", stats->tx_mbuf_count);
109 ark_ddm_is_stopped(struct ark_ddm_t *ddm)
111 return (ddm->cfg.stop_flushed & 0x01) != 0;
115 ark_ddm_queue_byte_count(struct ark_ddm_t *ddm)
117 return ddm->queue_stats.byte_count;
121 ark_ddm_queue_pkt_count(struct ark_ddm_t *ddm)
123 return ddm->queue_stats.pkt_count;
127 ark_ddm_queue_reset_stats(struct ark_ddm_t *ddm)
129 ddm->queue_stats.byte_count = 1;