62 "Syntax: example_policer \n\r"
64 "Paramaters: None. \n\r"
66 "Example: The following command is used to create a policer and attach \n\r"
67 " it to a field processor rule matching traffic with \n\r"
68 " destination MAC = MAC_DA. \n\r"
69 " It also provides an option to display the number of packets \n\r"
70 " redirected to destination port. \n\r"
72 " example_policer \n\r"
74 "Usage Guidelines: None. \n\r";
76 #define DEFAULT_UNIT 0
77 #define DEFAULT_VLAN 1
78 #define MAC_DA {0x00, 0x00, 0x00, 0x00, 0x00, 0x01}
80 #define MAC_MASK {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
99 printf(
"Error in opennsl_info_get, rv=%d\n", rv);
115 printf(
"Error in opennsl_policer_create no. 1, rv=%d\n",rv);
129 int group_priority = 6;
147 printf(
"Error in opennsl_field_group_create_mode_id. rv=%d \n",rv);
158 printf(
"Error in opennsl_field_group_action_set. rv=%d \n",rv);
165 printf(
"Error in opennsl_field_entry_create. rv=%d\n",rv);
172 printf(
"Error in opennsl_field_qualify_DstMac. rv=%d\n",rv);
182 printf(
"Error in opennsl_field_stat_create. rv=%d \n", rv);
189 printf(
"Error in opennsl_field_entry_stat_attach with ent %d. rv=%d\n", ent, rv);
197 printf(
"\r\nFailed to create the meter. Error: %s\r\n",
205 printf(
"Error in opennsl_field_entry_policer_attach with policer_id %d. rv=%d \n",
policer_id, rv);
212 printf(
"Error in opennsl_field_group_install. rv=%d \n", rv);
218 l2addr.
port = out_port;
222 printf(
"Error, opennsl_l2_addr_add with vid 1. rv=%d \n", rv);
236 printf(
"Error, opennsl_port_vlan_priority_map_set with prio 4. rv=%d \n", rv);
249 printf(
"Error, opennsl_port_vlan_priority_map_set with prio 1. rv=%d \n", rv);
257 printf(
"Error, opennsl_cosq_discard_set. rv=%d \n", rv);
271 int main(
int argc,
char *argv[])
279 if((argc != 1) || ((argc > 1) && (strcmp(argv[1],
"--help") == 0)))
289 printf(
"\r\nFailed to initialize the system. Error: %s\r\n",
298 printf(
"\r\nFailed to apply default config on ports, rc = %d (%s).\r\n",
303 printf(
"Adding ports to default vlan.\r\n");
307 printf(
"\r\nFailed to add default ports. Error: %s\r\n",
312 printf(
"\r\nUser menu: Select one of the following options\r\n");
313 printf(
"1. Apply policer to the traffic\n");
314 printf(
"2. Retrieve statistics of the policer\n");
315 #ifdef INCLUDE_DIAG_SHELL
316 printf(
"9. Launch diagnostic shell\n");
318 printf(
"0. Quit the application.\r\n");
322 printf(
"Invalid option entered. Please re-enter.\n");
329 printf(
"Enter the input port number(belonging to core-0):\n");
332 printf(
"Invalid value entered. Please re-enter.\n");
336 printf(
"Enter the output port number(belonging to core-0):\n");
339 printf(
"Invalid value entered. Please re-enter.\n");
347 printf(
"\r\nFailed to create the policer. Error: %s\r\n",
358 printf(
"Failed to get the accepted packets statistics, "
362 printf(
"Number of packets accepted: %lld (0x%0x)\n", val, val);
367 printf(
"Failed to get the dropped packets statistics, "
371 printf(
"Number of packets dropped: %lld (0x%0x)\n", val, val);
375 #ifdef INCLUDE_DIAG_SHELL
378 opennsl_driver_shell();
385 printf(
"Exiting the application.\n");