40 #define DEFAULT_UNIT 0
41 #define DEFAULT_VLAN 1
46 int index,
int *statId)
56 const int base_rate = (index + 1) * 50;
57 const int cir = base_rate * 8;
58 const int cbs = (base_rate + 200) * 8;
59 const int pir = (base_rate + 400) * 8;
60 const int pbs = (base_rate + 600) * 8;
114 (
" Policer %2d, Stat: %2d; CIR: %5d[%4d]; CBS: %5d[%4d]; PIR: %5d[%4d]; PBS: %5d[%4d]\n",
115 policer_id, *statId, cir, cir / 8, cbs, cbs / 8, pir, pir / 8, pbs, pbs / 8);
132 const int max_error = 50;
133 const int loop_count = 15;
135 int accumulated_error = 0;
137 for (loop = 0; loop < loop_count; loop++) {
143 printf(
"\nLoop: %d\n", loop);
144 for (idx = 0; idx < stat_count; idx++) {
152 const int64 expected_rate = (((idx + 1) * 50) + 400) * 1000;
153 const int64 rate = stat_value / delay;
156 ((rate - expected_rate) * 10000) / expected_rate;
158 printf(
"Rate: %d = %8llu bytes/sec [expected=%8llu, error=%lld]\n",
159 stat_list[idx], rate, expected_rate, rate_error);
160 accumulated_error += (rate_error < 0) ? -rate_error : rate_error;
164 accumulated_error /= (stat_count * (loop_count - 1));
165 if (accumulated_error > max_error) {
166 printf(
"FAIL: Per port avg error %d exceeds max of %d [LSB = 0.01%%]\n",
167 accumulated_error, max_error);
170 printf(
"PASS: Per port avg error: +/- %d [LSB = 0.01%%]\n", accumulated_error);
178 example_tx_pkt(
int unit,
int port)
184 0x01, 0x00, 0x5E, 0x00, 0x00, 0x01, 0x80, 0x80, 0x80, 0x71, 0x35, 0x42, 0x81, 0x00, 0x00, 0x01,
185 0x08, 0x00, 0x45, 0x00, 0x00, 0x5A, 0x00, 0x01, 0x00, 0x00, 0x40, 0x11, 0xD7, 0xE6, 0xC0, 0xA8,
186 0x01, 0x01, 0xE0, 0x01, 0x01, 0x01, 0x00, 0x07, 0x00, 0x07, 0x00, 0x46, 0x2C, 0xF6, 0x41, 0x6C,
187 0x6C, 0x20, 0x47, 0x6F, 0x6F, 0x64, 0x20, 0x54, 0x68, 0x69, 0x6E, 0x67, 0x73, 0x20, 0x43, 0x6F,
188 0x6D, 0x65, 0x20, 0x54, 0x6F, 0x20, 0x54, 0x68, 0x6F, 0x73, 0x65, 0x20, 0x57, 0x68, 0x6F, 0x20,
189 0x57, 0x61, 0x6E, 0x74, 0x20, 0x4C, 0x6F, 0x74, 0x73, 0x20, 0x4F, 0x66, 0x20, 0x47, 0x6F, 0x6F,
190 0x64, 0x20, 0x54, 0x68, 0x69, 0x6E, 0x67, 0x73, 0x00, 0x00, 0x00, 0x00
192 const int mypkt_SIZEOF =
sizeof(mypkt);
221 printf(
"Failed to create VLAN %d\n", vlan);
246 const int max_ports = 10;
247 const int storm_ports = 2;
256 int stat_ids[max_ports];
262 if (port_count == max_ports) {
265 port_list[port_count] =
port;
267 if (port_count >= storm_ports) {
281 if (port_count & 1) {
289 printf(
"Ingress Test Port: %d\n", port);
291 (unit, &group, port, next_vlan,
292 ingress_count, &stat_ids[ingress_count]));
293 ingress_list[ingress_count] =
port;
299 if (port_count != max_ports) {
300 printf(
"Not enough ethernet ports for test: %d\n", port_count);
303 printf(
"Send packet on storm port %d\n", port_list[0]);
320 int main(
int argc,
char *argv[])
329 printf(
"\r\nFailed to initialize the system. Error: %s\r\n",
337 printf(
"\r\nFailed to apply default config on ports, rc = %d (%s).\r\n",
342 printf(
"Adding ports to default vlan.\r\n");
345 printf(
"\r\nFailed to add default ports. Error: %s\r\n",
352 printf(
"\r\nFailed to test policer. Error: %s\r\n",