1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (c) 2015-2018 Atomic Rules LLC
10 static_assert(sizeof(union ark_tx_meta) == 8, "Unexpected struct size ark_tx_meta");
12 /* ************************************************************************* */
14 ark_ddm_verify(struct ark_ddm_t *ddm)
17 if (sizeof(struct ark_ddm_t) != ARK_DDM_EXPECTED_SIZE) {
18 ARK_PMD_LOG(ERR, "DDM structure looks incorrect %d vs %zd\n",
19 ARK_DDM_EXPECTED_SIZE, sizeof(struct ark_ddm_t));
23 hw_const = ddm->cfg.const0;
24 if (hw_const == ARK_DDM_CONST3)
27 if (hw_const == ARK_DDM_CONST1) {
29 "ARK: DDM module is version 1, "
30 "PMD expects version 2\n");
34 if (hw_const == ARK_DDM_CONST2) {
36 "ARK: DDM module is version 2, "
37 "PMD expects version 3\n");
41 "ARK: DDM module not found as expected 0x%08x\n",
47 ark_ddm_start(struct ark_ddm_t *ddm)
53 ark_ddm_stop(struct ark_ddm_t *ddm, const int wait)
58 while (wait && (ddm->cfg.stop_flushed & 0x01) == 0) {
68 ark_ddm_reset(struct ark_ddm_t *ddm)
72 /* reset only works if ddm has stopped properly. */
73 status = ark_ddm_stop(ddm, 1);
76 ARK_PMD_LOG(NOTICE, "%s stop failed doing forced reset\n",
85 ark_ddm_setup(struct ark_ddm_t *ddm, rte_iova_t cons_addr, uint32_t interval)
87 ddm->setup.cons_write_index_addr = cons_addr;
88 ddm->setup.write_index_interval = interval / 4; /* 4 ns period */
92 ark_ddm_stats_reset(struct ark_ddm_t *ddm)
94 ddm->cfg.tlp_stats_clear = 1;
98 ark_ddm_dump(struct ark_ddm_t *ddm, const char *msg)
100 ARK_PMD_LOG(DEBUG, "%s Stopped: %d\n", msg,
101 ark_ddm_is_stopped(ddm)
106 ark_ddm_dump_stats(struct ark_ddm_t *ddm, const char *msg)
108 struct ark_ddm_stats_t *stats = &ddm->stats;
110 ARK_PMD_LOG(INFO, "DDM Stats: %s"
111 ARK_SU64 ARK_SU64 ARK_SU64
113 "Bytes:", stats->tx_byte_count,
114 "Packets:", stats->tx_pkt_count,
115 "MBufs", stats->tx_mbuf_count);
119 ark_ddm_is_stopped(struct ark_ddm_t *ddm)
121 return (ddm->cfg.stop_flushed & 0x01) != 0;
125 ark_ddm_queue_byte_count(struct ark_ddm_t *ddm)
127 return ddm->queue_stats.byte_count;
131 ark_ddm_queue_pkt_count(struct ark_ddm_t *ddm)
133 return ddm->queue_stats.pkt_count;
137 ark_ddm_queue_reset_stats(struct ark_ddm_t *ddm)
139 ddm->queue_stats.byte_count = 1;