Commit 8accf456 authored by Miguel Jimenez Lopez's avatar Miguel Jimenez Lopez Committed by Grzegorz Daniluk

dev/ep_pfilter: Updated filter rules for wr-nic (with etherbone) project.

	- Added the NIC_PFILTER configuration option in Kconfig to decide which filter rules will be used.
	- Updated the dev/ep_pfilter.c file by using the CONFIG_NIC_PFILTER macro. This is done because packet filter does
	not work correctly if we write all rules in the CONFIG_ETHERBONE section.
	- We do not use the DROP instruction because all other packets go to NIC core.

Notes:

	- The filter rules to the wr-nic do not have the DROP instruction because all traffic
	does not go to the LM32/Etherbone is re-direct to the NIC by default.

	- The NIC_PFILTER configuration option depends on ETHERBONE one.

	- Magic number of Etherbone packets is not checked due to the number of rules. (The packet filter is not able to classify correctly)
parent a5d3db16
......@@ -55,7 +55,15 @@ config CMD_CONFIG
reports the current configuration. This adds half a kilobyte
to the binary size (100b for the code plus the .config file).
config NIC_PFILTER
depends on ETHERBONE
bool "Add packet filter rules for wr-nic"
help
When using wr-nic, the host must receive frames that are not
ptp nor etherbone ones. This adds the needed filter rules
to that effect. Such rules are not needed when no Etherbone
is there, because in that case all non-ptp frames reach the
host.
#
# This is a set of configuration options that should not be changed by
......
......@@ -9,8 +9,7 @@ CONFIG_PPSI=y
CONFIG_UART=y
CONFIG_W1=y
CONFIG_ETHERBONE=y
CONFIG_WRNIC=y
CONFIG_NIC_PFILTER=y
# CONFIG_CMD_CONFIG is not set
#
......
......@@ -239,42 +239,30 @@ void pfilter_init_default()
#ifdef CONFIG_ETHERBONE
#ifdef CONFIG_WRNIC
pfilter_logic3(10, 3, OR, 0, AND, 4); /* r10 = IP(unicast) */
pfilter_logic3(11, 1, OR, 3, AND, 4); /* r11 = IP(unicast+broadcast) */
pfilter_logic3(14, 1, AND, 6, OR, 5); /* r14 = ARP(broadcast) or PTPv2 */
pfilter_logic3(15, 10, AND, 7, OR, 14); /* r15 = ICMP/IP(unicast) or ARP(broadcast) or PTPv2 */
/* Ethernet = 14 bytes, IPv4 = 20 bytes, offset to dport: 2 = 36/2 = 18 */
pfilter_cmp(18, 0x0044, 0xffff, MOV, 14); /* r14 = 1 when dport = BOOTPC */
pfilter_logic3(14, 14, AND, 8, AND, 11); /* r14 = BOOTP/UDP/IP(unicast|broadcast) */
pfilter_logic2(15, 14, OR, 15); /* r15 = BOOTP/UDP/IP(unicast|broadcast) or ICMP/IP(unicast) or ARP(broadcast) or PTPv2 */
pfilter_logic3(10, 3, OR, 0, AND, 4); /* r10 = IP(unicast) */
pfilter_logic3(11, 1, OR, 3, AND, 4); /* r11 = IP(unicast+broadcast) */
pfilter_logic3(14, 1, AND, 6, OR, 5); /* r14 = ARP(broadcast) or PTPv2 */
pfilter_logic3(15, 10, AND, 7, OR, 14); /* r15 = ICMP/IP(unicast) or ARP(broadcast) or PTPv2 */
/* Ethernet = 14 bytes, IPv4 = 20 bytes, offset to dport: 2 = 36/2 = 18 */
pfilter_cmp(18, 0x0044, 0xffff, MOV, 14); /* r14 = 1 when dport = BOOTPC */
#ifdef CONFIG_NIC_PFILTER
pfilter_cmp(18,0xebd0,0xffff,MOV,6); /* r6 = 1 when dport = ETHERBONE */
pfilter_logic3(14, 14, AND, 8, AND, 11); /* r14 = BOOTP/UDP/IP(unicast|broadcast) */
pfilter_logic2(15,14, OR, 15); /* r15 = BOOTP/UDP/IP(unicast|broadcast) or ICMP/IP(unicast) or ARP(broadcast) or PTPv2 */
pfilter_cmp(21,0x4e6f,0xffff,MOV,9); /* r9 = 1 when magic number = ETHERBONE */
pfilter_logic2(6,6,AND,9);
//pfilter_cmp(21,0x4e6f,0xffff,MOV,9); /* r9 = 1 when magic number = ETHERBONE */
//pfilter_logic2(6,6,AND,9);
pfilter_logic2(R_CLASS(0), 15, MOV, 0); /* class 0: ICMP/IP(unicast) or ARP(broadcast) or PTPv2 => PTP LM32 core */
pfilter_logic2(R_CLASS(5), 6, OR, 0); /* class 5: Etherbone packet => Etherbone Core */
pfilter_logic3(R_CLASS(7), 15, OR, 6, NOT, 0); /* class 7: All other packets (no drop) => NIC Core */
pfilter_logic3(R_CLASS(7), 15, OR, 6, NOT, 0); /* class 7: Rest => NIC Core */
#else
pfilter_logic3(10, 3, OR, 0, AND, 4); /* r10 = IP(unicast) */
pfilter_logic3(11, 1, OR, 3, AND, 4); /* r11 = IP(unicast+broadcast) */
pfilter_logic3(14, 1, AND, 6, OR, 5); /* r14 = ARP(broadcast) or PTPv2 */
pfilter_logic3(15, 10, AND, 7, OR, 14); /* r15 = ICMP/IP(unicast) or ARP(broadcast) or PTPv2 */
/* Ethernet = 14 bytes, IPv4 = 20 bytes, offset to dport: 2 = 36/2 = 18 */
pfilter_cmp(18, 0x0044, 0xffff, MOV, 14); /* r14 = 1 when dport = BOOTPC */
pfilter_logic3(14, 14, AND, 8, AND, 11); /* r14 = BOOTP/UDP/IP(unicast|broadcast) */
pfilter_logic2(15, 14, OR, 15); /* r15 = BOOTP/UDP/IP(unicast|broadcast) or ICMP/IP(unicast) or ARP(broadcast) or PTPv2 */
pfilter_logic3(20, 11, AND, 8, OR, 15); /* r16 = Something we accept */
pfilter_logic3(R_DROP, 20, OR, 9, NOT, 0); /* None match? drop */
......@@ -284,7 +272,7 @@ void pfilter_init_default()
pfilter_logic2(R_CLASS(0), 15, MOV, 0); /* class 0: ICMP/IP(unicast) or ARP(broadcast) or PTPv2 => PTP LM32 core */
#endif
#else
pfilter_logic3(10, 3, OR, 2, AND, 5); /* r10 = PTP (multicast or unicast) */
pfilter_logic2(11, 1, AND, 9); /* r11 = streamer broadcast */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment