Commit dd612fb9 authored by Alessandro Rubini's avatar Alessandro Rubini

add pfilter_verbose, selected by Kconfig (developer mode)

Also, this changes how to mac address is retrieved in patching pfilter
rules. I'd better use format_mac(get_mac) for the verbose message,
so get_mac is also the source for patching the rules.

register and get_mac/set_mac are guaranteed to be in-sync.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 22f24ec4
...@@ -30,6 +30,9 @@ config PLL_VERBOSE ...@@ -30,6 +30,9 @@ config PLL_VERBOSE
boolean boolean
default y if WR_SWITCH default y if WR_SWITCH
config PFILTER_VERBOSE
boolean
config WRC_VERBOSE config WRC_VERBOSE
boolean boolean
default y if WR_SWITCH default y if WR_SWITCH
...@@ -285,6 +288,12 @@ config PLL_VERBOSE ...@@ -285,6 +288,12 @@ config PLL_VERBOSE
The softpll is usually silent in WR node and verbose in WR The softpll is usually silent in WR node and verbose in WR
switch. You can enable pll messages in WR node for debugging. switch. You can enable pll messages in WR node for debugging.
config PFILTER_VERBOSE
depends on DEVELOPER
boolean "Verbose messages in packet filter setup"
help
A debug tool for people changing the packet filter rules
config WRC_VERBOSE config WRC_VERBOSE
depends on DEVELOPER depends on DEVELOPER
boolean "More verbose messages in wr core" boolean "More verbose messages in wr core"
......
...@@ -7,6 +7,7 @@ CONFIG_PRINT_BUFSIZE=128 ...@@ -7,6 +7,7 @@ CONFIG_PRINT_BUFSIZE=128
# CONFIG_PRINTF_XINT is not set # CONFIG_PRINTF_XINT is not set
CONFIG_RAMSIZE=131072 CONFIG_RAMSIZE=131072
CONFIG_PLL_VERBOSE=y CONFIG_PLL_VERBOSE=y
CONFIG_PFILTER_VERBOSE=y
CONFIG_WRC_VERBOSE=y CONFIG_WRC_VERBOSE=y
# CONFIG_WR_NODE_PCS16 is not set # CONFIG_WR_NODE_PCS16 is not set
CONFIG_STACKSIZE=2048 CONFIG_STACKSIZE=2048
......
...@@ -16,14 +16,13 @@ ...@@ -16,14 +16,13 @@
*/ */
#include <wrc.h> #include <wrc.h>
#include <shell.h>
#include <endpoint.h> #include <endpoint.h>
#include <hw/endpoint_regs.h> #include <hw/endpoint_regs.h>
extern uint32_t _binary_rules_pfilter_bin_start[]; extern uint32_t _binary_rules_pfilter_bin_start[];
extern uint32_t _binary_rules_pfilter_bin_end[]; extern uint32_t _binary_rules_pfilter_bin_end[];
#define pfilter_dbg(fmt, ...) /* nothing */
extern volatile struct EP_WB *EP; extern volatile struct EP_WB *EP;
static uint32_t swap32(uint32_t v) static uint32_t swap32(uint32_t v)
...@@ -42,6 +41,8 @@ void pfilter_init_default(void) ...@@ -42,6 +41,8 @@ void pfilter_init_default(void)
/* Use shorter names to avoid getting mad */ /* Use shorter names to avoid getting mad */
uint32_t *vini = _binary_rules_pfilter_bin_start; uint32_t *vini = _binary_rules_pfilter_bin_start;
uint32_t *vend = _binary_rules_pfilter_bin_end; uint32_t *vend = _binary_rules_pfilter_bin_end;
uint8_t mac[6];
char buf[20];
uint32_t m, *v; uint32_t m, *v;
uint64_t cmd_word; uint64_t cmd_word;
int i; int i;
...@@ -78,13 +79,17 @@ void pfilter_init_default(void) ...@@ -78,13 +79,17 @@ void pfilter_init_default(void)
} }
/* /*
* Patch the local MAC address in place, * Patch the local MAC address in place,
* in the first three instructions after NOP */ * in the first three instructions after NOP
*/
get_mac_addr(mac);
v[2] &= ~(0xffff << 13); v[2] &= ~(0xffff << 13);
v[4] &= ~(0xffff << 13); v[4] &= ~(0xffff << 13);
v[6] &= ~(0xffff << 13); v[6] &= ~(0xffff << 13);
v[2] |= ((EP->MACH >> 0) & 0xffff) << 13; v[2] |= ((mac[0] << 8) | mac[1]) << 13;
v[4] |= ((EP->MACL >> 16) & 0xffff) << 13; v[4] |= ((mac[2] << 8) | mac[3]) << 13;
v[6] |= ((EP->MACL >> 0) & 0xffff) << 13; v[6] |= ((mac[4] << 8) | mac[5]) << 13;
pfilter_verbose("fixing MAC adress in rule: use %s\n",
format_mac(buf, mac));
EP->PFCR0 = 0; // disable pfilter EP->PFCR0 = 0; // disable pfilter
...@@ -92,7 +97,9 @@ void pfilter_init_default(void) ...@@ -92,7 +97,9 @@ void pfilter_init_default(void)
uint32_t cr0, cr1; uint32_t cr0, cr1;
cmd_word = v[0] | ((uint64_t)v[1] << 32); cmd_word = v[0] | ((uint64_t)v[1] << 32);
pfilter_dbg("pos %02i: %x.%08x\n", i, (uint32_t)(cmd_word >> 32), (uint32_t)(cmd_word)); pfilter_verbose("pfilter rule %02i: %x.%08x\n", i,
(uint32_t)(cmd_word >> 32),
(uint32_t)(cmd_word));
cr1 = EP_PFCR1_MM_DATA_LSB_W(cmd_word & 0xfff); cr1 = EP_PFCR1_MM_DATA_LSB_W(cmd_word & 0xfff);
cr0 = EP_PFCR0_MM_ADDR_W(i) | EP_PFCR0_MM_DATA_MSB_W(cmd_word >> 12) | cr0 = EP_PFCR0_MM_ADDR_W(i) | EP_PFCR0_MM_DATA_MSB_W(cmd_word >> 12) |
......
...@@ -13,6 +13,12 @@ ...@@ -13,6 +13,12 @@
#define PLL_IS_VERBOSE 0 #define PLL_IS_VERBOSE 0
#endif #endif
#ifdef CONFIG_PFILTER_VERBOSE
#define PFILTER_IS_VERBOSE 1
#else
#define PFILTER_IS_VERBOSE 0
#endif
#ifdef CONFIG_WRC_VERBOSE #ifdef CONFIG_WRC_VERBOSE
#define WRC_IS_VERBOSE 1 #define WRC_IS_VERBOSE 1
#else #else
...@@ -22,6 +28,9 @@ ...@@ -22,6 +28,9 @@
#define pll_verbose(...) \ #define pll_verbose(...) \
({if (PLL_IS_VERBOSE) __debug_printf(__VA_ARGS__);}) ({if (PLL_IS_VERBOSE) __debug_printf(__VA_ARGS__);})
#define pfilter_verbose(...) \
({if (PFILTER_IS_VERBOSE) __debug_printf(__VA_ARGS__);})
#define wrc_verbose(...) \ #define wrc_verbose(...) \
({if (WRC_IS_VERBOSE) __debug_printf(__VA_ARGS__);}) ({if (WRC_IS_VERBOSE) __debug_printf(__VA_ARGS__);})
......
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