38 #define DEFAULT_UNIT 0
39 #define DEFAULT_VLAN 1
40 #define MAX_COUNTERS 30
41 #define MAX_DIGITS_IN_CHOICE 5
44 "Syntax: example_stat \n\r"
46 "Paramaters: None \n\r"
48 "Example: The following command is used to see the statistics of a port\n\r"
51 "Usage Guidelines: This program request the user to enter the port \n\r"
52 " number interactively \n\r";
62 int main(
int argc,
char *argv[])
105 if((argc != 1) || ((argc > 1) && (strcmp(argv[1],
"--help") == 0))) {
111 printf(
"Initializing the system.\r\n");
115 printf(
"\r\nFailed to initialize the system, rc = %d (%s).\r\n",
123 printf(
"\r\nFailed to apply default config on ports, rc = %d (%s).\r\n",
128 printf(
"Adding ports to default vlan.\r\n");
131 printf(
"\r\nFailed to add default ports, rc = %d (%s).\r\n",
136 printf(
"Initializing the stat module.\r\n");
140 printf(
"\r\nFailed to initialise stat module, rc = %d (%s).\r\n",
147 printf(
"\nUser Menu: Select one of the following options\n");
148 printf(
"1. Display statistics of a port.\n");
149 printf(
"2. Clear statistics of a port.\n");
150 #ifdef INCLUDE_DIAG_SHELL
151 printf(
"9. Launch diagnostic shell\n");
153 printf(
"0. Quit the application.\n");
157 printf(
"Invalid option entered. Please re-enter.\n");
164 printf(
"\r\nEnter the port number.\r\n");
167 printf(
"Invalid option entered. Please re-enter.\n");
172 printf(
"\r\nFailed to sync the state of port, rc = %d (%s).\r\n",
180 for (i=0; i < nstat; i++) {
186 printf(
"\r\nFailed to get the port stats, rc = %d (%s).\r\n",
191 printf(
"Count of Ingress Unicast packets ....... %llu\n", val[0]);
192 printf(
"Count of Ingress Non-unicast packets....... %llu\n", val[1]);
193 printf(
"Count of Ingress Discard packets ....... %llu\n", val[2]);
194 printf(
"Count of Ingress Error packets ....... %llu\n", val[3]);
195 printf(
"Count of Ingress Multicast packets ....... %llu\n", val[4]);
196 printf(
"Count of Ingress Broadcast packets ....... %llu\n", val[5]);
197 printf(
"Count of Received 64 octets ....... %llu\n", val[6]);
198 printf(
"Count of Received 65-127 octets ....... %llu\n", val[7]);
199 printf(
"Count of Received 128-255 octets ....... %llu\n", val[8]);
200 printf(
"Count of Received 256-511 octets ....... %llu\n", val[9]);
201 printf(
"Count of Received 512-1023 octets ....... %llu\n", val[10]);
202 printf(
"Count of Received 1024-1518 octets ....... %llu\n", val[11]);
203 printf(
"Count of Received 1519-2047 octets ....... %llu\n", val[12]);
204 printf(
"Count of Received 2048-4095 octets ....... %llu\n", val[13]);
205 printf(
"Count of Received 4096-9216 octets ....... %llu\n", val[14]);
206 printf(
"Count of Egress Unicast packets ....... %llu\n", val[15]);
207 printf(
"Count of Egress Non-unicast packets ....... %llu\n", val[16]);
208 printf(
"Count of Egress Discards packets ....... %llu\n", val[17]);
209 printf(
"Count of Egress Error packets ....... %llu\n", val[18]);
210 printf(
"Count of Egress Multicast packets ....... %llu\n", val[19]);
211 printf(
"Count of Egress Broadcast packets ....... %llu\n", val[20]);
212 printf(
"Count of Transmitted 64 octets ....... %llu\n", val[21]);
213 printf(
"Count of Transmitted 65-127 octets ....... %llu\n", val[22]);
214 printf(
"Count of Transmitted 128-255 octets ....... %llu\n", val[23]);
215 printf(
"Count of Transmitted 256-511 octets ....... %llu\n", val[24]);
216 printf(
"Count of Transmitted 512-1023 octet ....... %llu\n", val[25]);
217 printf(
"Count of Transmitted 1024-1518 octets ..... %llu\n", val[26]);
218 printf(
"Count of Transmitted 1519-2047 octets ..... %llu\n", val[27]);
219 printf(
"Count of Transmitted 2048-4095 octets ..... %llu\n", val[28]);
225 printf(
"\r\nEnter the port number.\r\n");
228 printf(
"Invalid option entered. Please re-enter.\n");
233 printf(
"\r\nFailed to clear the port stats, rc = %d (%s).\r\n",
238 printf(
"\r\nPort %d stats cleared\r\n", port);
242 #ifdef INCLUDE_DIAG_SHELL
245 opennsl_driver_shell();
252 printf(
"Exiting the application.\n");