42c42,43 < * Date Created: 2/11/2009 --- > * History: > * 2/11/2009 Creation by Ken Wong 53a55,57 > #define PKT_COUNT 0 // plugin counters > #define ERR_COUNT 4 > 74c78 < // volatile __declspec(shared gp_reg) int sharedNextBlock; --- > //X volatile __declspec(shared gp_reg) int sharedNextBlock; 77a82,88 > __declspec(shared gp_reg) int go; > > #define NX 64 > volatile __declspec(shared sram) unsigned int xdata[NX]; // extra data > volatile __declspec(shared sram) unsigned int nxdata; // #xdata valid > volatile __declspec(shared sram) unsigned int nxget; > 83a95,126 > // record extra data (usually debugging data) > // > static __forceinline void > helper_set_xdata( unsigned int x ) { > if( nxdata < NX ) { > xdata[nxdata] = x; > ++nxdata; > } > } > > // output control msg with xdata[] > // <<<<< > void > helper_sram_outmsg_xdata( __declspec(local_mem) char *outmsgstr ) { > __declspec(sram) char SPACE[2] = " "; > __declspec(sram) char sram_msg_buf[28]; > __declspec(sram) char sram_tmpstr[16]; > __declspec(gp_reg) int i; > > if( nxget >= nxdata ) return; > > sram_msg_buf[0] = '\0'; > for( i=0; i<2; i++ ) { > if( nxget >= nxdata ) break; > if( i > 0 ) strcat_sram( sram_msg_buf, SPACE ); > helper_ultoa_sram( xdata[nxget], sram_tmpstr, 16 ); > strcat_sram( sram_msg_buf, sram_tmpstr ); > ++nxget; > } > memcpy_lmem_sram( outmsgstr, sram_msg_buf, 28 ); > } > 105,111c148,154 < if( strcmp(str, "PLUGIN0") == 0 ) return PACKET_IN_RING_0; < else if( strcmp(str, "PLUGIN1") == 0 ) return PACKET_IN_RING_1; < else if( strcmp(str, "PLUGIN2") == 0 ) return PACKET_IN_RING_2; < else if( strcmp(str, "PLUGIN3") == 0 ) return PACKET_IN_RING_3; < else if( strcmp(str, "PLUGIN4") == 0 ) return PACKET_IN_RING_4; < else if( strcmp(str, "MUX") == 0 ) return MUX; < else if( strcmp(str, "DROP") == 0 ) return DROP; --- > if( strncmp(str, "PLUGIN0", 7) == 0 ) return PACKET_IN_RING_0; > else if( strncmp(str, "PLUGIN1", 7) == 0 ) return PACKET_IN_RING_1; > else if( strncmp(str, "PLUGIN2", 7) == 0 ) return PACKET_IN_RING_2; > else if( strncmp(str, "PLUGIN3", 7) == 0 ) return PACKET_IN_RING_3; > else if( strncmp(str, "PLUGIN4", 7) == 0 ) return PACKET_IN_RING_4; > else if( strncmp(str, "MUX", 3) == 0 ) return MUX; > else if( strncmp(str, "DROP", 4) == 0 ) return DROP; 126,130c169 < // Note: < // The calls to helper_sram_dbgmsg_str_1ul() are commented out < // because they caused the compile to run out of local memory. < // < void --- > int 135,139c174,177 < || (ring_out.plugin_qm_data_out.buf_handle_lo24 == 0) ) < helper_sram_dbgmsg_3ul( < ring_out.plugin_qm_data_out.out_port, < ring_out.plugin_qm_data_out.qid, < ring_out.plugin_qm_data_out.buf_handle_lo24 ); --- > || (ring_out.plugin_qm_data_out.buf_handle_lo24 == 0) ) { > return -1; > } > return 0; 155,158c193,196 < char dbgmsg[10] = "got pkt "; < char dbgmsg2[16] = "dlNextBlock= "; < char dbgmsg3[16] = "BAD set_meta= "; < unsigned int rc; --- > char dbgmsg[10] = "got pkt "; > char dbgmsg2[16] = "dlNextBlock= "; > char dbgmsg3[16] = "BAD set_meta= "; > int rc; 161,163c199 < if( debug_on ) { < helper_sram_dbgmsg_str_1ul( dbgmsg, npkts ); < } --- > if( debug_on ) helper_sram_dbgmsg_str_1ul( dbgmsg, npkts ); 165c201 < onl_api_plugin_cntr_inc(pluginId, 0); // Incr global plugin cntr 0 --- > onl_api_plugin_cntr_inc(pluginId, PKT_COUNT); 169,171c205 < if( debug_on ) { < helper_sram_dbgmsg_str_1ul( dbgmsg2, dlNextBlock ); < } --- > if( debug_on ) helper_sram_dbgmsg_str_1ul( dbgmsg2, dlNextBlock ); 174,175c208,210 < if( rc != 0 ) { < helper_sram_dbgmsg_str_1ul( dbgmsg3, dlNextBlock ); --- > if( rc != 0 ) { // bad dlNextBlock > helper_sram_dbgmsg_str_1ul( dbgmsg3, dlNextBlock ); > onl_api_plugin_cntr_inc(pluginId, ERR_COUNT); 176a212,224 > > if( (go > 0) && (go < 20) ) { > ++go; > helper_set_xdata( ring_out.i[0] ); > helper_set_xdata( ring_out.i[1] ); > helper_set_xdata( ring_out.i[2] ); > > // helper_sram_dbgmsg_3ul( ring_out.plugin_qm_data_out.out_port, > // ring_out.plugin_qm_data_out.qid, > // ring_out.plugin_qm_data_out.buf_handle_lo24 ); > > } > 207c255 < __declspec(sram) char vers[4] = "1.7"; --- > __declspec(sram) char vers[4] = "1.6"; 215a264,265 > char GO[8] = "go"; > char GET_xdata[8] = "=xdata"; 250c300,303 < helper_plugin_cntr_zero( 0 ); --- > nxget = 0; > nxdata = 0; > helper_plugin_cntr_zero( PKT_COUNT ); > helper_plugin_cntr_zero( ERR_COUNT ); 254a308,312 > } else if( strncmp_sram(sram_inmsgstr, GO, 2) == 0 ) { > if( go > 0 ) go = 0; > else go = 1; > } else if( strncmp_sram(sram_inmsgstr, GET_xdata, 8) == 0 ) { > helper_sram_outmsg_xdata( outmsgstr ); 300a359,361 > go = 0; > nxdata = 0; nxget = 0; > 302c363,364 < helper_plugin_cntr_zero( 0 ); --- > helper_plugin_cntr_zero( PKT_COUNT ); > helper_plugin_cntr_zero( ERR_COUNT ); 317a380,382 > // >>> NOTE: I don't use this function in this plugin since I use > // helper_set_meta_default() in handle_pkt_user() > // 377,379c442 < dlNextBlock = sharedNextBlock; < < if( debug_on ) { --- > //XXX if( debug_on ) { 388,389c451,460 < if( dlNextBlock == QM ) helper_check_meta( ); < } --- > if( dlNextBlock == QM ) { > if( helper_check_meta( ) != 0 ) { > helper_sram_dbgmsg_3ul( > ring_out.plugin_qm_data_out.out_port, > ring_out.plugin_qm_data_out.qid, > ring_out.plugin_qm_data_out.buf_handle_lo24 ); > onl_api_plugin_cntr_inc(pluginId, ERR_COUNT); > } > } > //XXX }