39 #define DEFAULT_UNIT 0
40 #define DEFAULT_VLAN 1
41 #define MAX_DIGITS_IN_CHOICE 5
44 "Syntax: example_rx_packet_cpu \n\r"
46 "Paramaters: None. \n\r"
48 "Example: The following command is used to demonstrate receiving a \n\r"
49 " packet to CPU. \n\r"
50 " example_rx_packet_cpu \n\r"
52 "Usage Guidelines: None. \n\r";
69 int len,
unsigned char *user_header,
72 unsigned char pph_type;
73 unsigned int pph_offset;
74 unsigned int lb_ext_offset = 0;
75 unsigned char eei_ext_present;
76 unsigned char lrn_ext_present;
77 unsigned char fhei_size;
85 *offset += lb_ext_offset;
98 pph_type = (pkt[5] & 0x06) >> 1;
110 eei_ext_present = (pkt[*offset+0] & 0x80) >> 7;
117 lrn_ext_present = (pkt[*offset+0] & 0x40) >> 6;
124 fhei_size = (pkt[*offset+0] & 0x30) >> 4;
154 *offset += pph_offset;
174 unsigned int offset = 0;
176 unsigned char user_header[8];
179 printf(
"Packet received with pkt->rx_port:%hhu pkt->src_port:%hhu\n",
181 printf(
"Packet received with pkt->pkt_len : %d pkt->tot_len : %d cos: %d\n",
186 for(i = 0; i < pkt->
tot_len; i++)
193 printf(
"%02hhx", data[i]);
198 memset (&pkt_l, 0x00,
sizeof(pkt_l));
204 memcpy (&pkt_l, pkt,
sizeof(pkt_l));
211 printf(
"Packet after stripping the device specific header\n");
214 for(i = 0; i < pkt->
tot_len; i++)
221 printf(
"%02hhx", data[i]);
260 printf(
"Failed to register packet receive callback for unit %d,"
269 printf(
"opennsl_rx_start() failed on unit %d with rv %d (%s).\r\n",
284 int main(
int argc,
char *argv[])
293 if(strcmp(argv[0],
"gdb") == 0)
298 if((argc != (index + 1)) || ((argc > (index + 1)) && (strcmp(argv[index + 1],
"--help") == 0)))
305 printf(
"Initializing the system.\r\n");
310 printf(
"\r\nFailed to initialize the system. Error %s\r\n",
318 printf(
"\r\nFailed to apply default config on ports, rv = %d (%s).\r\n",
323 printf(
"Adding ports to default VLAN.\r\n");
327 printf(
"\r\nFailed to add default ports. rv: %s\r\n",
opennsl_errmsg(rv));
334 printf(
"Failed to get port configuration. Error %s\n",
opennsl_errmsg(rv));
340 printf(
"Failed to add ports to VLAN. Error %s\n",
opennsl_errmsg(rv));
343 printf(
"CPU port is added to default VLAN.\r\n");
348 printf(
"\r\nFailed to setup system for packet reception. rv: %s\r\n",
355 printf(
"\r\nUser menu: Select one of the following options\r\n");
356 printf(
"1. Display OpenNSL version\n");
357 #ifdef INCLUDE_DIAG_SHELL
358 printf(
"9. Launch diagnostic shell\n");
360 printf(
"0. Quit the application\n");
364 printf(
"Invalid option entered. Please re-enter.\n");
375 #ifdef INCLUDE_DIAG_SHELL
378 opennsl_driver_shell();
385 printf(
"Exiting the application.\n");