Basically the only change to the second bit of code is to remove a lot of the conditional assembly and to change the filter result routine a bit.
mii_filter.xc:102: error: case not terminated with a break or return
Code: Select all
while (1)
{
select
{
#pragma xta endpoint "rx_packet"
case (int ifnum=0; ifnum<NUM_ETHERNET_PORTS; ifnum++) c[ifnum] :> buf :
{
if (buf)
{
int length = mii_packet_get_length(buf);
#if ETHERNET_RX_CRC_ERROR_CHECK
unsigned poly = 0xEDB88320;
unsigned crc = mii_packet_get_crc(buf);
int endbytes;
int tail;
tail = mii_packet_get_data(buf,((length & 0xFFFFFFFC)/4)+1);
endbytes = (length & 3);
switch (endbytes)
{
case 0:
break;
case 1:
tail = crc8shr(crc, tail, poly);
break;
case 2:
tail = crc8shr(crc, tail, poly);
tail = crc8shr(crc, tail, poly);
break;
case 3:
tail = crc8shr(crc, tail, poly);
tail = crc8shr(crc, tail, poly);
tail = crc8shr(crc, tail, poly);
break;
}
#endif
mii_packet_set_src_port(buf,ifnum);
if (length < 60)
{
#if ETHERNET_COUNT_PACKETS
ethernet_filtered_by_length++;
#endif
mii_packet_set_filter_result(buf, 0);
mii_packet_set_stage(buf,1);
}
#if ETHERNET_RX_CRC_ERROR_CHECK
else if (~crc)
{
#if ETHERNET_COUNT_PACKETS
ethernet_filtered_by_bad_crc++;
#endif
mii_packet_set_filter_result(buf, 0);
mii_packet_set_stage(buf,1);
}
#endif
else
{
int broadcast = is_broadcast(buf);
int unicast = compare_mac(buf,mac);
int res=0;
#if (NUM_ETHERNET_PORTS > 1) && !defined(DISABLE_ETHERNET_PORT_FORWARDING)
if (!unicast) {
res |= MII_FILTER_FORWARD_TO_OTHER_PORTS;
}
#endif
#ifdef MAC_PROMISCUOUS
if (1) {
#else
if (broadcast || unicast) {
#endif
int filter_result = mac_custom_filter_coerce(buf);
#if ETHERNET_COUNT_PACKETS
if (filter_result == 0) ethernet_filtered_by_user_filter++;
#endif
res |= filter_result;
} else {
#if ETHERNET_COUNT_PACKETS
ethernet_filtered_by_address++;
#endif
}
mii_packet_set_filter_result(buf, res);
mii_packet_set_stage(buf, 1);
}
}
break;
} // end if (buf)
} // end case()
} // end select
} // end while (1)
Code: Select all
while (1)
{
select
{
#pragma xta endpoint "rx_packet"
case (int ifnum=0; ifnum<NUM_ETHERNET_PORTS; ifnum++) c[ifnum] :> buf :
{
if (buf)
{
int length = mii_packet_get_length(buf);
unsigned poly = 0xEDB88320;
unsigned crc = mii_packet_get_crc(buf);
int endbytes;
int tail;
tail = mii_packet_get_data(buf,((length & 0xFFFFFFFC)/4)+1);
endbytes = (length & 3);
switch (endbytes)
{
case 0:
break;
case 1:
tail = crc8shr(crc, tail, poly);
break;
case 2:
tail = crc8shr(crc, tail, poly);
tail = crc8shr(crc, tail, poly);
break;
case 3:
tail = crc8shr(crc, tail, poly);
tail = crc8shr(crc, tail, poly);
tail = crc8shr(crc, tail, poly);
break;
}
mii_packet_set_src_port(buf,ifnum);
if (length < 60)
{
ethernet_filtered_by_length++;
mii_packet_set_filter_result(buf, 0);
mii_packet_set_stage(buf,1);
}
else if (~crc)
{
ethernet_filtered_by_bad_crc++;
mii_packet_set_filter_result(buf, 0);
mii_packet_set_stage(buf,1);
}
else
{
filter_result = 0;
broadcast = check_for_broadcast(buf);
our_address = compare_own_mac(buf,own_mac);
xmos_address = compare_xmos_mac(buf,xmos_mac);
if (broadcast || our_address)
{
filter_result = mac_custom_filter_coerce(buf);
if (filter_result == 0) ethernet_filtered_by_user_filter++;
}
if (broadcast || (xmos_address && !our_address))
{
filter_result |= REPEAT_PACKET_TO_OTHER_PORTS;
}
if (!(broadcast || xmos_address))
{
ethernet_filtered_by_address++;
}
mii_packet_set_filter_result(buf, filter_result);
mii_packet_set_stage(buf, 1);
}
break;
} // end if (buf)
} // end case()
// break;
} // end select
} // end while (1)
}