1
2
3
4
5
6
7
8#include <errno.h>
9#include <log.h>
10#include <time.h>
11#include <linux/delay.h>
12
13#include <mach/cvmx-regs.h>
14#include <mach/cvmx-csr.h>
15#include <mach/cvmx-bootmem.h>
16#include <mach/octeon-model.h>
17#include <mach/cvmx-fuse.h>
18#include <mach/octeon-feature.h>
19#include <mach/cvmx-qlm.h>
20#include <mach/octeon_qlm.h>
21#include <mach/cvmx-pcie.h>
22#include <mach/cvmx-coremask.h>
23#include <mach/cvmx-range.h>
24#include <mach/cvmx-global-resources.h>
25
26#include <mach/cvmx-agl-defs.h>
27#include <mach/cvmx-bgxx-defs.h>
28#include <mach/cvmx-ciu-defs.h>
29#include <mach/cvmx-gmxx-defs.h>
30#include <mach/cvmx-gserx-defs.h>
31#include <mach/cvmx-ilk-defs.h>
32#include <mach/cvmx-ipd-defs.h>
33#include <mach/cvmx-pcsx-defs.h>
34#include <mach/cvmx-pcsxx-defs.h>
35#include <mach/cvmx-pki-defs.h>
36#include <mach/cvmx-pko-defs.h>
37#include <mach/cvmx-xcv-defs.h>
38
39#include <mach/cvmx-hwpko.h>
40#include <mach/cvmx-ilk.h>
41#include <mach/cvmx-ipd.h>
42#include <mach/cvmx-pki.h>
43#include <mach/cvmx-pko3.h>
44#include <mach/cvmx-pko3-queue.h>
45#include <mach/cvmx-pko3-resources.h>
46
47#include <mach/cvmx-helper.h>
48#include <mach/cvmx-helper-board.h>
49#include <mach/cvmx-helper-cfg.h>
50
51#include <mach/cvmx-helper-bgx.h>
52#include <mach/cvmx-helper-cfg.h>
53#include <mach/cvmx-helper-util.h>
54#include <mach/cvmx-helper-pki.h>
55
56static s64 pko_fpa_config_pool = -1;
57static u64 pko_fpa_config_size = 1024;
58
59
60
61
62
63
64
65
66void (*cvmx_override_pko_queue_priority)(int ipd_port,
67 uint8_t *priorities) = NULL;
68
69int64_t cvmx_fpa_get_pko_pool(void)
70{
71 return pko_fpa_config_pool;
72}
73
74
75
76
77u64 cvmx_fpa_get_pko_pool_block_size(void)
78{
79 return pko_fpa_config_size;
80}
81
82
83
84
85static int cvmx_helper_pko_pool_init(void)
86{
87 u8 pool;
88 unsigned int buf_count;
89 unsigned int pkt_buf_count;
90 int rc;
91
92
93 pool = cvmx_fpa_get_pko_pool();
94
95
96 if (cvmx_fpa_get_block_size(pool) > 0) {
97#ifdef DEBUG
98 debug("WARNING: %s: pool %d already initialized\n", __func__,
99 pool);
100#endif
101
102 return pool;
103 }
104
105
106 pkt_buf_count = cvmx_fpa_get_packet_pool_buffer_count();
107 buf_count = CVMX_PKO_MAX_OUTPUT_QUEUES + (pkt_buf_count * 3) / 8;
108
109
110 rc = __cvmx_helper_initialize_fpa_pool(pool,
111 cvmx_fpa_get_pko_pool_block_size(),
112 buf_count, "PKO Cmd-bufs");
113
114 if (rc < 0)
115 debug("%s: ERROR: in PKO buffer pool\n", __func__);
116
117 pool = rc;
118 return pool;
119}
120
121
122
123
124
125int cvmx_helper_pko_init(void)
126{
127 int rc;
128
129 rc = cvmx_helper_pko_pool_init();
130 if (rc < 0)
131 return rc;
132
133 __cvmx_helper_init_port_config_data(0);
134
135 cvmx_pko_hw_init(cvmx_fpa_get_pko_pool(),
136 cvmx_fpa_get_pko_pool_block_size());
137 return 0;
138}
139
140
141
142
143
144
145
146
147
148
149
150
151
152int __cvmx_helper_interface_setup_pko(int interface)
153{
154
155
156
157
158
159
160
161
162
163
164
165
166
167 u8 priorities[16] = { [0 ... 15] = 8 };
168
169
170
171
172
173
174 int num_ports = cvmx_helper_ports_on_interface(interface);
175
176 while (num_ports--) {
177 int ipd_port;
178
179 if (!cvmx_helper_is_port_valid(interface, num_ports))
180 continue;
181
182 ipd_port = cvmx_helper_get_ipd_port(interface, num_ports);
183
184
185
186
187 if (cvmx_override_pko_queue_priority)
188 cvmx_override_pko_queue_priority(ipd_port, priorities);
189
190 cvmx_pko_config_port(ipd_port,
191 cvmx_pko_get_base_queue(ipd_port),
192 cvmx_pko_get_num_queues(ipd_port),
193 priorities);
194 ipd_port++;
195 }
196 return 0;
197
198
199
200
201
202
203}
204