mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-08-30 14:52:51 +08:00
Add initial IGMP handling via ASIC
This commit is contained in:
@@ -10,7 +10,7 @@ SUBDIRSCLEAN=$(addsuffix clean,$(SUBDIRS))
|
|||||||
|
|
||||||
all: $(SUBDIRS) rtlplayground.bin
|
all: $(SUBDIRS) rtlplayground.bin
|
||||||
|
|
||||||
SRCS = rtlplayground.c rtl837x_flash.c rtl837x_phy.c rtl837x_port.c cmd_parser.c html_data.c
|
SRCS = rtlplayground.c rtl837x_flash.c rtl837x_phy.c rtl837x_port.c cmd_parser.c html_data.c rtl837x_igmp.c
|
||||||
OBJS = ${SRCS:.c=.rel}
|
OBJS = ${SRCS:.c=.rel}
|
||||||
OBJS += uip/timer.rel uip/uip-fw.rel uip/uip-neighbor.rel uip/uip-split.rel uip/uip.rel uip/uip_arp.rel uip/uiplib.rel httpd/httpd.rel httpd/page_impl.rel
|
OBJS += uip/timer.rel uip/uip-fw.rel uip/uip-neighbor.rel uip/uip-split.rel uip/uip.rel uip/uip_arp.rel uip/uiplib.rel httpd/httpd.rel httpd/page_impl.rel
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* This is a driver implementation for the IGMP features for the RTL827x platform
|
||||||
|
* This code is in the Public Domain
|
||||||
|
*/
|
||||||
|
|
||||||
|
// #define REGDBG
|
||||||
|
// #define DEBUG
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "rtl837x_common.h"
|
||||||
|
#include "rtl837x_sfr.h"
|
||||||
|
#include "rtl837x_regs.h"
|
||||||
|
#include "rtl837x_igmp.h"
|
||||||
|
|
||||||
|
extern __xdata uint8_t minPort;
|
||||||
|
extern __xdata uint8_t maxPort;
|
||||||
|
extern __xdata uint8_t nSFPPorts;
|
||||||
|
extern __xdata uint8_t cpuPort;
|
||||||
|
extern __xdata uint8_t isRTL8373;
|
||||||
|
|
||||||
|
void igmp_setup(void) __banked
|
||||||
|
{
|
||||||
|
uint8_t i;
|
||||||
|
|
||||||
|
// For now, forward all unkown MC pkts (2 bits per port. 00: flood via floodmask, 01: drop, 10: trap, 11: to rport)
|
||||||
|
REG_SET(RTL837X_MC_LOOKUPMISS_ACTIONS, 0x00000000); //0x4f78
|
||||||
|
// Define ports where unknown MC addresses are flooded to:
|
||||||
|
if (isRTL8373) {
|
||||||
|
REG_SET(RTL837X_MC_FLOODMASK, PMASK_9); // R5368-000001f8
|
||||||
|
} else {
|
||||||
|
REG_SET(RTL837X_MC_FLOODMASK, PMASK_6);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enable lookup of IPv4 MC addresses in table
|
||||||
|
reg_bit_set(RTL837X_L2_CTRL, 3); // 0x5350
|
||||||
|
|
||||||
|
// Configure per-port IGMP configuration, bits 0-10 enable MC protocol snooping,
|
||||||
|
// bits 16-24 configure max MC group used by that port. For now all protocols are flooded (01)
|
||||||
|
for (i = minPort; i <= maxPort; i++)
|
||||||
|
REG_SET(RTL837X_IGMP_PORT_CFG + (i << 2), 0x00ff7c15);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void igmp_enable(void) __banked
|
||||||
|
{
|
||||||
|
uint8_t i;
|
||||||
|
|
||||||
|
REG_SET(0x50bc, 00010007); // Trap control?
|
||||||
|
|
||||||
|
// Drop unknown MC messages
|
||||||
|
REG_SET(RTL837X_MC_LOOKUPMISS_ACTIONS, 0x00015540); //0x4f78
|
||||||
|
|
||||||
|
// Configure per-port IGMP configuration, bits 0-10 enable MC protocol snooping,
|
||||||
|
// bits 16-24 configure max MC group used by that port. Trap to CPU (10)
|
||||||
|
for (i = minPort; i <= maxPort; i++)
|
||||||
|
REG_SET(RTL837X_IGMP_PORT_CFG + (i << 2), 0x00ff7c2a); // 0x00ff7000: Handling by ASIC (00)
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
#ifndef _RTL837X_IGMP_H_
|
||||||
|
#define _RTL837X_IGMP_H_
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
void igmp_setup(void) __banked;
|
||||||
|
void igmp_enable(void) __banked;
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -143,6 +143,7 @@
|
|||||||
*/
|
*/
|
||||||
#define RTL837X_MC_LOOKUPMISS_ACTIONS 0x4f78
|
#define RTL837X_MC_LOOKUPMISS_ACTIONS 0x4f78
|
||||||
#define RTL837X_IGMP_PORT_CFG 0x52a0
|
#define RTL837X_IGMP_PORT_CFG 0x52a0
|
||||||
|
#define RTL837X_MC_FLOODMASK 0x5368
|
||||||
|
|
||||||
|
|
||||||
#ifdef REGDBG
|
#ifdef REGDBG
|
||||||
|
|||||||
Reference in New Issue
Block a user