1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (c) 2015-2018 Atomic Rules LLC
10 #include <rte_memory.h>
12 /* The UDM or Upstream Data Mover is an internal Arkville hardware
13 * module for moving packet from the RX packet streams to host memory.
14 * This module is *not* intended for end-user manipulation, hence
15 * there is minimal documentation.
18 /* Meta data structure apssed from FPGA, must match layout in FPGA */
28 * UDM hardware structures
29 * These are overlay structures to a memory mapped FPGA device. These
30 * structs will never be instantiated in ram memory
33 #define ARK_RX_WRITE_TIME_NS 2500
34 #define ARK_UDM_SETUP 0
35 #define ARK_UDM_CONST 0xbACECACE
36 struct ark_udm_setup_t {
39 volatile uint32_t cycle_count;
43 #define ARK_UDM_CFG 0x010
44 struct ark_udm_cfg_t {
45 volatile uint32_t stop_flushed; /* RO */
46 volatile uint32_t command;
57 #define ARK_UDM_STATS 0x020
58 struct ark_udm_stats_t {
59 volatile uint64_t rx_byte_count;
60 volatile uint64_t rx_packet_count;
61 volatile uint64_t rx_mbuf_count;
62 volatile uint64_t rx_sent_packets;
65 #define ARK_UDM_PQ 0x040
66 struct ark_udm_queue_stats_t {
67 volatile uint64_t q_byte_count;
68 volatile uint64_t q_packet_count; /* includes drops */
69 volatile uint64_t q_mbuf_count;
70 volatile uint64_t q_ff_packet_count;
71 volatile uint64_t q_pkt_drop;
75 #define ARK_UDM_TLP 0x0070
76 struct ark_udm_tlp_t {
77 volatile uint64_t pkt_drop; /* global */
78 volatile uint32_t tlp_q1;
79 volatile uint32_t tlp_q2;
80 volatile uint32_t tlp_q3;
81 volatile uint32_t tlp_q4;
82 volatile uint32_t tlp_full;
85 #define ARK_UDM_PCIBP 0x00a0
86 struct ark_udm_pcibp_t {
87 volatile uint32_t pci_clear;
88 volatile uint32_t pci_empty;
89 volatile uint32_t pci_q1;
90 volatile uint32_t pci_q2;
91 volatile uint32_t pci_q3;
92 volatile uint32_t pci_q4;
93 volatile uint32_t pci_full;
96 #define ARK_UDM_TLP_PS 0x00bc
97 struct ark_udm_tlp_ps_t {
98 volatile uint32_t tlp_clear;
99 volatile uint32_t tlp_ps_min;
100 volatile uint32_t tlp_ps_max;
101 volatile uint32_t tlp_full_ps_min;
102 volatile uint32_t tlp_full_ps_max;
103 volatile uint32_t tlp_dw_ps_min;
104 volatile uint32_t tlp_dw_ps_max;
105 volatile uint32_t tlp_pldw_ps_min;
106 volatile uint32_t tlp_pldw_ps_max;
109 #define ARK_UDM_RT_CFG 0x00e0
110 struct ark_udm_rt_cfg_t {
111 rte_iova_t hw_prod_addr;
112 uint32_t write_interval; /* 4ns cycles */
113 volatile uint32_t prod_idx; /* RO */
116 /* Consolidated structure */
117 #define ARK_UDM_EXPECT_SIZE (0x00fc + 4)
118 #define ARK_UDM_QOFFSET ARK_UDM_EXPECT_SIZE
120 struct ark_udm_setup_t setup;
121 struct ark_udm_cfg_t cfg;
122 struct ark_udm_stats_t stats;
123 struct ark_udm_queue_stats_t qstats;
124 uint8_t reserved1[(ARK_UDM_TLP - ARK_UDM_PQ) -
125 sizeof(struct ark_udm_queue_stats_t)];
126 struct ark_udm_tlp_t tlp;
127 uint8_t reserved2[(ARK_UDM_PCIBP - ARK_UDM_TLP) -
128 sizeof(struct ark_udm_tlp_t)];
129 struct ark_udm_pcibp_t pcibp;
130 struct ark_udm_tlp_ps_t tlp_ps;
131 struct ark_udm_rt_cfg_t rt_cfg;
132 int8_t reserved3[(ARK_UDM_EXPECT_SIZE - ARK_UDM_RT_CFG) -
133 sizeof(struct ark_udm_rt_cfg_t)];
137 int ark_udm_verify(struct ark_udm_t *udm);
138 int ark_udm_stop(struct ark_udm_t *udm, int wait);
139 void ark_udm_start(struct ark_udm_t *udm);
140 int ark_udm_reset(struct ark_udm_t *udm);
141 void ark_udm_configure(struct ark_udm_t *udm,
144 uint32_t write_interval_ns);
145 void ark_udm_write_addr(struct ark_udm_t *udm, rte_iova_t addr);
146 void ark_udm_stats_reset(struct ark_udm_t *udm);
147 void ark_udm_dump_stats(struct ark_udm_t *udm, const char *msg);
148 void ark_udm_dump_queue_stats(struct ark_udm_t *udm, const char *msg,
150 void ark_udm_dump(struct ark_udm_t *udm, const char *msg);
151 void ark_udm_dump_perf(struct ark_udm_t *udm, const char *msg);
152 void ark_udm_dump_setup(struct ark_udm_t *udm, uint16_t q_id);
153 int ark_udm_is_flushed(struct ark_udm_t *udm);
156 uint64_t ark_udm_dropped(struct ark_udm_t *udm);
157 uint64_t ark_udm_bytes(struct ark_udm_t *udm);
158 uint64_t ark_udm_packets(struct ark_udm_t *udm);
160 void ark_udm_queue_stats_reset(struct ark_udm_t *udm);
161 void ark_udm_queue_enable(struct ark_udm_t *udm, int enable);