diff options
| author | Roman Yeryomin <roman@advem.lv> | 2013-05-17 20:40:24 +0300 |
|---|---|---|
| committer | Roman Yeryomin <roman@advem.lv> | 2013-05-17 20:40:24 +0300 |
| commit | e6d87036412b952cb083eff2dc716aee97a771f2 (patch) | |
| tree | 273dd3daaa85553832d3cc6d48276229dc7fbe09 /target/linux/realtek/files/drivers/net/rtl819x/rtl865x_proc_debug.c | |
| parent | a18fec42221baa52fff4c5ffd45ec8f32e3add36 (diff) | |
Move to rsdk 3.2.4. Compiles cleanly.
Signed-off-by: Roman Yeryomin <roman@advem.lv>
Diffstat (limited to 'target/linux/realtek/files/drivers/net/rtl819x/rtl865x_proc_debug.c')
| -rw-r--r-- | target/linux/realtek/files/drivers/net/rtl819x/rtl865x_proc_debug.c | 2720 |
1 files changed, 1835 insertions, 885 deletions
diff --git a/target/linux/realtek/files/drivers/net/rtl819x/rtl865x_proc_debug.c b/target/linux/realtek/files/drivers/net/rtl819x/rtl865x_proc_debug.c index 15d2531d5..210c9df59 100644 --- a/target/linux/realtek/files/drivers/net/rtl819x/rtl865x_proc_debug.c +++ b/target/linux/realtek/files/drivers/net/rtl819x/rtl865x_proc_debug.c @@ -1,10 +1,10 @@ /* -* Copyright c Realtek Semiconductor Corporation, 2008 -* All rights reserved. -* +* Copyright c Realtek Semiconductor Corporation, 2008 +* All rights reserved. +* * Program : just for driver debug -* Abstract : -* Author : Hyking Liu (Hyking_liu@realsil.com.tw) +* Abstract : +* Author : Hyking Liu (Hyking_liu@realsil.com.tw) * ------------------------------------------------------- */ #include <net/rtl/rtl_types.h> @@ -31,11 +31,11 @@ #include "AsicDriver/rtl865x_asicBasic.h" #include "AsicDriver/rtl865x_asicCom.h" -#include "AsicDriver/rtl865x_asicL2.h" +#include "AsicDriver/rtl865x_asicL2.h" #ifdef CONFIG_RTL_LAYERED_ASIC_DRIVER_L3 #include "AsicDriver/rtl865x_asicL3.h" #endif -#if defined(CONFIG_RTL_LAYERED_ASIC_DRIVER_L4) && defined(CONFIG_RTL_8198) +#if defined(CONFIG_RTL_LAYERED_DRIVER_L4) && (defined(CONFIG_RTL_8198) ||defined(CONFIG_RTL_8196CT) ||defined(CONFIG_RTL_819XDT)) #include "AsicDriver/rtl865x_asicL4.h" #endif @@ -57,7 +57,14 @@ #include <net/rtl/rtl_nic.h> #endif +#if defined(CONFIG_RTL_PROC_DEBUG) +extern unsigned int rx_noBuffer_cnt; +extern unsigned int tx_ringFull_cnt; +#endif + + static struct proc_dir_entry *rtl865x_proc_dir; +#ifdef CONFIG_RTL_PROC_DEBUG //proc debug flag static struct proc_dir_entry *vlan_entry,*netif_entry,*l2_entry, *arp_entry, *nexthop_entry,*l3_entry,*ip_entry,*pppoe_entry,*napt_entry, *acl_entry,*storm_control, @@ -65,32 +72,121 @@ static struct proc_dir_entry *vlan_entry,*netif_entry,*l2_entry, *arp_entry, *advRt_entry, #endif #if defined(RTL_DEBUG_NIC_SKB_BUFFER) - *nic_skb_buff, + *nic_skb_buff, #endif #ifdef CONFIG_RTL_LAYERED_DRIVER - *acl_chains_entry, + *acl_chains_entry, #endif #if defined(CONFIG_RTL_HW_QOS_SUPPORT) - *qos_rule_entry, + *qos_rule_entry, #endif - *rxRing_entry, *txRing_entry, *mbuf_entry, - *hs_entry, *pvid_entry, *mirrorPort_entry, - *mem_entry, *diagnostic_entry, -#if defined(CONFIG_RTL_LAYERED_DRIVER_L4) && defined(CONFIG_RTL_8198) - *sw_napt_entry, + *rxRing_entry, *txRing_entry, *mbuf_entry, + *hs_entry, *pvid_entry, *mirrorPort_entry, + +#if defined(CONFIG_RTL_LAYERED_DRIVER_L4) && (defined(CONFIG_RTL_8198) ||defined(CONFIG_RTL_8196CT) ||defined(CONFIG_RTL_819XDT)) + *sw_napt_entry, #endif - *port_bandwidth_entry, *queue_bandwidth_entry, - *port_status_entry, *priority_decision_entry,*hwMCast_entry, -#if defined (CONFIG_RTL_HARDWARE_MULTICAST) + *port_bandwidth_entry, *queue_bandwidth_entry, + *priority_decision_entry, + + *port_priority_entry, *dscp_priority_entry, + +#if defined (CONFIG_RTL_HARDWARE_MULTICAST) *swMCast_entry, -#endif +#endif #if defined (CONFIG_RTL_ENABLE_RATELIMIT_TABLE) *rateLimit_entry, #endif - *asicCnt_entry,*phyReg_entry; +*hwMCast_entry,*stats_debug_entry; +#endif + +#if defined(CONFIG_RTL_PROC_DEBUG)||defined(CONFIG_RTL_DEBUG_TOOL) + +static struct proc_dir_entry *mmd_entry, *mem_entry, *diagnostic_entry, + *asicCnt_entry,*phyReg_entry,*port_status_entry,*mac_entry,*fc_threshold_entry; +#define PROC_READ_RETURN_VALUE 0 +extern int32 mmd_read(uint32 phyId, uint32 devId, uint32 regId, uint32 *rData); +extern int32 mmd_write(uint32 phyId, uint32 devId, uint32 regId, uint32 wData); + +#endif + +#if defined CONFIG_RTL_DEBUG_TOOL //debug tool flag +#ifndef CONFIG_RTL_PROC_DEBUG + //#ifndef RTK_X86_CLE//RTK-CNSD2-NickWu-20061222: for x86 compile + /*cfliu: This function is only for debugging. Should not be used in production code...*/ + + void memDump (void *start, uint32 size, int8 * strHeader) + { + int32 row, column, index, index2, max; + uint32 buffer[5]; + uint8 *buf, *line, ascii[17]; + int8 empty = ' '; + + if(!start ||(size==0)) + return; + line = (uint8*)start; + + /* + 16 bytes per line + */ + if (strHeader) + rtlglue_printf ("%s", strHeader); + column = size % 16; + row = (size / 16) + 1; + for (index = 0; index < row; index++, line += 16) + { +#ifdef RTL865X_TEST + buf = (uint8*)line; +#else + /* for un-alignment access */ + buffer[0] = ntohl( READ_MEM32( (((uint32)line)&~3)+ 0 ) ); + buffer[1] = ntohl( READ_MEM32( (((uint32)line)&~3)+ 4 ) ); + buffer[2] = ntohl( READ_MEM32( (((uint32)line)&~3)+ 8 ) ); + buffer[3] = ntohl( READ_MEM32( (((uint32)line)&~3)+12 ) ); + buffer[4] = ntohl( READ_MEM32( (((uint32)line)&~3)+16 ) ); + buf = ((uint8*)buffer) + (((uint32)line)&3); +#endif + + memset (ascii, 0, 17); + + max = (index == row - 1) ? column : 16; + if ( max==0 ) break; /* If we need not dump this line, break it. */ + + rtlglue_printf ("\n%08x: ", (memaddr) line); + + //Hex + for (index2 = 0; index2 < max; index2++) + { + if (index2 == 8) + rtlglue_printf (" "); + rtlglue_printf ("%02X", (uint8) buf[index2]); + ascii[index2] = ((uint8) buf[index2] < 32) ? empty : buf[index2]; + if ((index2+1)%4==0) + rtlglue_printf (" "); + } + + if (max != 16) + { + if (max < 8) + rtlglue_printf (" "); + for (index2 = 16 - max; index2 > 0; index2--) + rtlglue_printf (" "); + } + + //ASCII + rtlglue_printf (" %s", ascii); + } + rtlglue_printf ("\n"); + return; + } +#endif +#endif + +#ifdef CONFIG_RTL_PROC_DEBUG static uint32 queue_bandwidth_record_portmask = 0; + #if defined (CONFIG_RTL_HARDWARE_MULTICAST) int32 rtl_dumpSwMulticastInfo(void); #endif @@ -98,20 +194,16 @@ int32 rtl_dumpSwMulticastInfo(void); static struct proc_dir_entry *eventMgr_entry; #endif -#if defined (CONFIG_RTL_IGMP_SNOOPING) +#if defined (CONFIG_RTL_IGMP_SNOOPING) static struct proc_dir_entry *igmp_entry; #endif /*#if defined(CONFIG_RTL_ETH_PRIV_SKB_DEBUG)*/ static struct proc_dir_entry *prive_skb_debug_entry; /*#endif*/ - -#define PROC_READ_RETURN_VALUE 0 - extern int32 rtl865x_sw_napt_proc_read( char *page, char **start, off_t off, int count, int *eof, void *data ); extern int32 rtl865x_sw_napt_proc_write( struct file *filp, const char *buff,unsigned long len, void *data ); - #ifdef CONFIG_RTL_LAYERED_DRIVER #ifdef CONFIG_RTL_LAYERED_DRIVER_L2 static struct proc_dir_entry *sw_l2_entry; @@ -130,14 +222,14 @@ extern int32 rtl865x_perf_proc_write(struct file *file, const char *buffer, unsi int vlan_show(void) { int i, j; - + for ( i = 0; i < RTL865XC_VLAN_NUMBER; i++ ) { rtl865x_tblAsicDrv_vlanParam_t vlan; if ( rtl8651_getAsicVlan( i, &vlan ) == FAILED ) continue; - + printk(" VID[%d] ", i); printk("\n\tmember ports:"); @@ -147,7 +239,7 @@ int vlan_show(void) printk( "%d ", j); } - printk("\n\tUntag member ports:"); + printk("\n\tUntag member ports:"); for( j = 0; j < RTL8651_PORT_NUMBER + rtl8651_totalExtPortNum; j++ ) { @@ -171,15 +263,19 @@ static int32 vlan_single_show(struct seq_file *s, void *v) { int i, j; - - for ( i = 0; i < RTL865XC_VLAN_NUMBER; i++ ) + + for ( i = 0; i < RTL865XC_VLANTBL_SIZE; i++ ) { rtl865x_tblAsicDrv_vlanParam_t vlan; if ( rtl8651_getAsicVlan( i, &vlan ) == FAILED ) continue; - + +#if defined(CONFIG_RTL_819XD) || defined(CONFIG_RTL_8196E) + seq_printf(s, " idx [%d] VID[%d] ", i, vlan.vid); +#else seq_printf(s, " VID[%d] ", i); +#endif seq_printf(s, "\n\tmember ports:"); for( j = 0; j < RTL8651_PORT_NUMBER + rtl8651_totalExtPortNum; j++ ) @@ -188,7 +284,7 @@ static int32 vlan_single_show(struct seq_file *s, void *v) seq_printf(s,"%d ", j); } - seq_printf(s,"\n\tUntag member ports:"); + seq_printf(s,"\n\tUntag member ports:"); for( j = 0; j < RTL8651_PORT_NUMBER + rtl8651_totalExtPortNum; j++ ) { @@ -199,7 +295,7 @@ static int32 vlan_single_show(struct seq_file *s, void *v) seq_printf(s,"\n\tFID:\t%d\n",vlan.fid); } - } + } return 0; } @@ -209,36 +305,40 @@ extern int switch_iram(uint32 addr); #endif static int32 vlan_write( struct file *filp, const char *buff,unsigned long len, void *data ) { - char tmpbuf[32]; + char tmpbuf[256]; + if(len>32) + { + goto errout; + } if (buff && !copy_from_user(tmpbuf, buff, len)) { - tmpbuf[len -1] = '\0'; + tmpbuf[len -1] = '\0'; if(tmpbuf[0] == '1') { #ifdef CONFIG_RTL_LAYERED_DRIVER_ACL - rtl865x_AclRule_t rule; - - memset(&rule,0,sizeof(rtl865x_AclRule_t)); + rtl865x_AclRule_t rule; + + memset(&rule,0,sizeof(rtl865x_AclRule_t)); rule.actionType_ = RTL865X_ACL_PRIORITY; rule.ruleType_ = RTL865X_ACL_IP; rule.dstIpAddrLB_ = 0xc0a801fe; rule.dstIpAddrUB_ = 0xc0a801fe; rule.priority_ = 6; rule.pktOpApp_ = RTL865X_ACL_ALL_LAYER; - - rtl865x_add_acl(&rule, RTL_DRV_LAN_NETIF_NAME, RTL865X_ACL_SYSTEM_USED); + + rtl865x_add_acl(&rule, RTL_DRV_LAN_NETIF_NAME, RTL865X_ACL_SYSTEM_USED); #endif } #if defined(CONFIG_RTL_DYNAMIC_IRAM_MAPPING_FOR_WAPI) else if(tmpbuf[0] =='2') - { + { switch_iram(0); - + } else if(tmpbuf[0] == '3') - { - switch_iram(1); + { + switch_iram(1); } #endif else @@ -253,7 +353,7 @@ static int32 vlan_write( struct file *filp, const char *buff,unsigned long len, { goto errout; } - printk("cmd %s\n", cmd_addr); + rtlglue_printf("cmd %s\n", cmd_addr); if (!memcmp(cmd_addr, "dump", 4)) { tokptr = strsep(&strptr," "); @@ -263,39 +363,94 @@ static int32 vlan_write( struct file *filp, const char *buff,unsigned long len, } vid = simple_strtol(tokptr, NULL, 0); - printk("Vlan info:\n"); + rtlglue_printf("Vlan info:\n"); { rtl865x_tblAsicDrv_vlanParam_t vlan; int j; if ( rtl8651_getAsicVlan( vid, &vlan ) == FAILED ) return len; - - printk(" VID[%d] ", vid); - printk("\n\tmember ports:"); + + rtlglue_printf(" VID[%d] ", vid); + rtlglue_printf("\n\tmember ports:"); for( j = 0; j < RTL8651_PORT_NUMBER + rtl8651_totalExtPortNum; j++ ) { if ( vlan.memberPortMask & ( 1 << j ) ) - printk("%d ", j); + rtlglue_printf("%d ", j); } - printk("\n\tUntag member ports:"); + rtlglue_printf("\n\tUntag member ports:"); for( j = 0; j < RTL8651_PORT_NUMBER + rtl8651_totalExtPortNum; j++ ) { if( vlan.untagPortMask & ( 1 << j ) ) - printk("%d ", j); + rtlglue_printf("%d ", j); } - printk("\n\tFID:\t%d\n",vlan.fid); + rtlglue_printf("\n\tFID:\t%d\n",vlan.fid); + } + } + else if ( (!memcmp(cmd_addr, "add", 3)) || + (!memcmp(cmd_addr, "Add", 3)) || + (!memcmp(cmd_addr, "ADD", 3)) ) + { + + uint32 vid=0; + uint32 portMask=0; + uint32 taggedPortMask=0; + tokptr = strsep(&strptr," "); + if (tokptr==NULL) + { + goto errout; + } + + vid=simple_strtol(tokptr, NULL, 0); + + tokptr = strsep(&strptr," "); + if (tokptr==NULL) + { + goto errout; + } + + portMask=simple_strtol(tokptr, NULL, 0); + + tokptr = strsep(&strptr," "); + if (tokptr==NULL) + { + goto errout; + } + + taggedPortMask= simple_strtol(tokptr, NULL, 0); + + rtl865x_addVlan(vid); + rtl865x_addVlanPortMember(vid & 4095,portMask & 0x13F); + rtl865x_setVlanPortTag(vid,taggedPortMask,1); + rtl865x_setVlanFilterDatabase(vid,0); + + + } + else if ( (!memcmp(cmd_addr, "del", 3)) || + (!memcmp(cmd_addr, "Del", 3)) || + (!memcmp(cmd_addr, "DEL", 3)) ) + { + uint32 vid=0; + tokptr = strsep(&strptr," "); + if (tokptr==NULL) + { + goto errout; } + + vid=simple_strtol(tokptr, NULL, 0); + + rtl865x_delVlan(vid); + } return len; errout: - printk("vlan operation only support \"dump\" as the first parameter\n"); - printk("dump format: \"dump vid\"\n"); + rtlglue_printf("vlan operation only support \"dump\" as the first parameter\n"); + rtlglue_printf("dump format: \"dump vid\"\n"); } } return len; @@ -315,7 +470,7 @@ static ssize_t vlan_single_write(struct file * file, const char __user * userbuf struct file_operations vlan_single_seq_file_operations = { .open = vlan_single_open, - .write =vlan_single_write, + .write =vlan_single_write, .read = seq_read, .llseek = seq_lseek, .release = single_release, @@ -346,7 +501,7 @@ static int32 netif_read( char *page, char **start, off_t off, int count, int *eo if ( intf.valid ) { mac = (uint8 *)&intf.macAddr.octet[0]; - len += sprintf(page+len,"[%d] VID[%d] %x:%x:%x:%x:%x:%x", + len += sprintf(page+len,"[%d] VID[%d] %x:%x:%x:%x:%x:%x", i, intf.vid, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); len += sprintf(page+len," Routing %s \n", intf.enableRoute==TRUE? "enabled": "disabled" ); @@ -380,7 +535,9 @@ static int32 netif_read( char *page, char **start, off_t off, int count, int *eo len += sprintf(page+len,"ACL %d-%d, ", intf.outAclStart, intf.outAclEnd); len += sprintf(page+len, "\n %d MAC Addresses, MTU %d Bytes\n", intf.macAddrNumber, intf.mtu); - + #if defined(CONFIG_RTL_819XD) || defined(CONFIG_RTL_8196E) + rtl8651_findAsicVlanIndexByVid(&intf.vid); + #endif rtl8651_getAsicVlan( intf.vid, &vlan ); len += sprintf(page+len,"\n Untag member ports:"); @@ -397,7 +554,7 @@ static int32 netif_read( char *page, char **start, off_t off, int count, int *eo if ( vlan.memberPortMask & ( 1 << j ) ) len += sprintf(page+len, "%d ", j); } - + len += sprintf(page+len, "\n Port state("); for ( j = 0; j < RTL8651_PORT_NUMBER + rtl8651_totalExtPortNum; j++ ) @@ -435,8 +592,8 @@ static int32 netif_write( struct file *filp, const char *buff,unsigned long len, static int32 acl_read( char *page, char **start, off_t off, int count, int *eof, void *data ) { int len; - int8 *actionT[] = { "permit", "redirect to ether", "drop", "to cpu", "legacy drop", - "drop for log", "mirror", "redirect to pppoe", "default redirect", "mirror keep match", + int8 *actionT[] = { "permit", "redirect to ether", "drop", "to cpu", "legacy drop", + "drop for log", "mirror", "redirect to pppoe", "default redirect", "mirror keep match", "drop rate exceed pps", "log rate exceed pps", "drop rate exceed bps", "log rate exceed bps","priority " }; #ifdef CONFIG_RTL_LAYERED_DRIVER @@ -451,9 +608,9 @@ static int32 acl_read( char *page, char **start, off_t off, int count, int *eof, int8 outRule; - + len = sprintf(page, "%s\n", "ASIC ACL Table:"); - for(vid=0; vid<8; vid++ ) + for(vid=0; vid<8; vid++ ) { /* Read VLAN Table */ if (rtl8651_getAsicNetInterface(vid, &asic_intf) == FAILED) @@ -476,7 +633,7 @@ static int32 acl_read( char *page, char **start, off_t off, int count, int *eof, { if ( _rtl865x_getAclFromAsic(acl_start, &asic_acl) == FAILED) rtlglue_printf("=============%s(%d): get asic acl rule error!\n",__FUNCTION__, __LINE__); - + switch(asic_acl.ruleType_) { case RTL865X_ACL_MAC: @@ -488,7 +645,7 @@ static int32 acl_read( char *page, char **start, off_t off, int count, int *eof, asic_acl.dstMacMask_.octet[0], asic_acl.dstMacMask_.octet[1], asic_acl.dstMacMask_.octet[2], asic_acl.dstMacMask_.octet[3], asic_acl.dstMacMask_.octet[4], asic_acl.dstMacMask_.octet[5] ); - + len += sprintf(page+len, "\tSMAC: %x:%x:%x:%x:%x:%x SMACM: %x:%x:%x:%x:%x:%x\n", asic_acl.srcMac_.octet[0], asic_acl.srcMac_.octet[1], asic_acl.srcMac_.octet[2], asic_acl.srcMac_.octet[3], asic_acl.srcMac_.octet[4], asic_acl.srcMac_.octet[5], @@ -512,14 +669,14 @@ static int32 acl_read( char *page, char **start, off_t off, int count, int *eof, len += sprintf(page+len, "\tTos: %x TosM: %x ipProto: %x ipProtoM: %x ipFlag: %x ipFlagM: %x\n", asic_acl.tos_, asic_acl.tosMask_, asic_acl.ipProto_, asic_acl.ipProtoMask_, asic_acl.ipFlag_, asic_acl.ipFlagMask_ ); - + len += sprintf(page+len, "\t<FOP:%x> <FOM:%x> <http:%x> <httpM:%x> <IdentSdip:%x> <IdentSdipM:%x> \n", asic_acl.ipFOP_, asic_acl.ipFOM_, asic_acl.ipHttpFilter_, asic_acl.ipHttpFilterM_, asic_acl.ipIdentSrcDstIp_, asic_acl.ipIdentSrcDstIpM_ ); - len += sprintf(page+len, "\t<DF:%x> <MF:%x>\n", asic_acl.ipDF_, asic_acl.ipMF_); + len += sprintf(page+len, "\t<DF:%x> <MF:%x>\n", asic_acl.ipDF_, asic_acl.ipMF_); break; - + case RTL865X_ACL_IP_RANGE: len += sprintf(page+len, " [%d] rule type: %s rule action: %s\n", acl_start, "IP Range", actionT[asic_acl.actionType_]); len += sprintf(page+len, "\tdipU: %d.%d.%d.%d dipL: %d.%d.%d.%d\n", (asic_acl.dstIpAddr_>>24), @@ -539,8 +696,8 @@ static int32 acl_read( char *page, char **start, off_t off, int count, int *eof, asic_acl.ipFOP_, asic_acl.ipFOM_, asic_acl.ipHttpFilter_, asic_acl.ipHttpFilterM_, asic_acl.ipIdentSrcDstIp_, asic_acl.ipIdentSrcDstIpM_ ); - len += sprintf(page+len, "\t<DF:%x> <MF:%x>\n", asic_acl.ipDF_, asic_acl.ipMF_); - break; + len += sprintf(page+len, "\t<DF:%x> <MF:%x>\n", asic_acl.ipDF_, asic_acl.ipMF_); + break; case RTL865X_ACL_ICMP: len += sprintf(page+len, " [%d] rule type: %s rule action: %s\n", acl_start, "ICMP", actionT[asic_acl.actionType_]); len += sprintf(page+len, "\tdip: %d.%d.%d.%d dipM: %d.%d.%d.%d\n", (asic_acl.dstIpAddr_>>24), @@ -554,7 +711,7 @@ static int32 acl_read( char *page, char **start, off_t off, int count, int *eof, ((asic_acl.srcIpAddrMask_&0x0000ff00)>>8), (asic_acl.srcIpAddrMask_&0xff) ); len += sprintf(page+len, "\tTos: %x TosM: %x type: %x typeM: %x code: %x codeM: %x\n", - asic_acl.tos_, asic_acl.tosMask_, asic_acl.icmpType_, asic_acl.icmpTypeMask_, + asic_acl.tos_, asic_acl.tosMask_, asic_acl.icmpType_, asic_acl.icmpTypeMask_, asic_acl.icmpCode_, asic_acl.icmpCodeMask_); break; case RTL865X_ACL_ICMP_IPRANGE: @@ -570,7 +727,7 @@ static int32 acl_read( char *page, char **start, off_t off, int count, int *eof, ((asic_acl.srcIpAddrMask_&0x0000ff00)>>8), (asic_acl.srcIpAddrMask_&0xff) ); len += sprintf(page+len, "\tTos: %x TosM: %x type: %x typeM: %x code: %x codeM: %x\n", - asic_acl.tos_, asic_acl.tosMask_, asic_acl.icmpType_, asic_acl.icmpTypeMask_, + asic_acl.tos_, asic_acl.tosMask_, asic_acl.icmpType_, asic_acl.icmpTypeMask_, asic_acl.icmpCode_, asic_acl.icmpCodeMask_); break; case RTL865X_ACL_IGMP: @@ -667,7 +824,7 @@ static int32 acl_read( char *page, char **start, off_t off, int count, int *eof, asic_acl.tos_, asic_acl.tosMask_, asic_acl.udpSrcPortLB_, asic_acl.udpSrcPortUB_, asic_acl.udpDstPortLB_, asic_acl.udpDstPortUB_ ); - break; + break; case RTL865X_ACL_UDP_IPRANGE: len += sprintf(page+len, " [%d] rule type: %s rule action: %s\n", acl_start, "UDP IP RANGE", actionT[asic_acl.actionType_]); len += sprintf(page+len, "\tdipU: %d.%d.%d.%d dipL: %d.%d.%d.%d\n", (asic_acl.dstIpAddr_>>24), @@ -684,13 +841,13 @@ static int32 acl_read( char *page, char **start, off_t off, int count, int *eof, asic_acl.tos_, asic_acl.tosMask_, asic_acl.udpSrcPortLB_, asic_acl.udpSrcPortUB_, asic_acl.udpDstPortLB_, asic_acl.udpDstPortUB_ ); - break; + break; + - case RTL865X_ACL_SRCFILTER: len += sprintf(page+len, " [%d] rule type: %s rule action: %s\n", acl_start, "Source Filter", actionT[asic_acl.actionType_]); - len += sprintf(page+len, "\tSMAC: %x:%x:%x:%x:%x:%x SMACM: %x:%x:%x:%x:%x:%x\n", - asic_acl.srcFilterMac_.octet[0], asic_acl.srcFilterMac_.octet[1], asic_acl.srcFilterMac_.octet[2], + len += sprintf(page+len, "\tSMAC: %x:%x:%x:%x:%x:%x SMACM: %x:%x:%x:%x:%x:%x\n", + asic_acl.srcFilterMac_.octet[0], asic_acl.srcFilterMac_.octet[1], asic_acl.srcFilterMac_.octet[2], asic_acl.srcFilterMac_.octet[3], asic_acl.srcFilterMac_.octet[4], asic_acl.srcFilterMac_.octet[5], asic_acl.srcFilterMacMask_.octet[0], asic_acl.srcFilterMacMask_.octet[1], asic_acl.srcFilterMacMask_.octet[2], asic_acl.srcFilterMacMask_.octet[3], asic_acl.srcFilterMacMask_.octet[4], asic_acl.srcFilterMacMask_.octet[5] @@ -710,8 +867,8 @@ static int32 acl_read( char *page, char **start, off_t off, int count, int *eof, case RTL865X_ACL_SRCFILTER_IPRANGE: len += sprintf(page+len, " [%d] rule type: %s rule action: %s\n", acl_start, "Source Filter(IP RANGE)", actionT[asic_acl.actionType_]); - len += sprintf(page+len, "\tSMAC: %x:%x:%x:%x:%x:%x SMACM: %x:%x:%x:%x:%x:%x\n", - asic_acl.srcFilterMac_.octet[0], asic_acl.srcFilterMac_.octet[1], asic_acl.srcFilterMac_.octet[2], + len += sprintf(page+len, "\tSMAC: %x:%x:%x:%x:%x:%x SMACM: %x:%x:%x:%x:%x:%x\n", + asic_acl.srcFilterMac_.octet[0], asic_acl.srcFilterMac_.octet[1], asic_acl.srcFilterMac_.octet[2], asic_acl.srcFilterMac_.octet[3], asic_acl.srcFilterMac_.octet[4], asic_acl.srcFilterMac_.octet[5], asic_acl.srcFilterMacMask_.octet[0], asic_acl.srcFilterMacMask_.octet[1], asic_acl.srcFilterMacMask_.octet[2], asic_acl.srcFilterMacMask_.octet[3], asic_acl.srcFilterMacMask_.octet[4], asic_acl.srcFilterMacMask_.octet[5] @@ -731,15 +888,15 @@ static int32 acl_read( char *page, char **start, off_t off, int count, int *eof, case RTL865X_ACL_DSTFILTER: len += sprintf(page+len, " [%d] rule type: %s rule action: %s\n", acl_start, "Deatination Filter", actionT[asic_acl.actionType_]); - len += sprintf(page+len, "\tDMAC: %x:%x:%x:%x:%x:%x DMACM: %x:%x:%x:%x:%x:%x\n", - asic_acl.dstFilterMac_.octet[0], asic_acl.dstFilterMac_.octet[1], asic_acl.dstFilterMac_.octet[2], + len += sprintf(page+len, "\tDMAC: %x:%x:%x:%x:%x:%x DMACM: %x:%x:%x:%x:%x:%x\n", + asic_acl.dstFilterMac_.octet[0], asic_acl.dstFilterMac_.octet[1], asic_acl.dstFilterMac_.octet[2], asic_acl.dstFilterMac_.octet[3], asic_acl.dstFilterMac_.octet[4], asic_acl.dstFilterMac_.octet[5], asic_acl.dstFilterMacMask_.octet[0], asic_acl.dstFilterMacMask_.octet[1], asic_acl.dstFilterMacMask_.octet[2], asic_acl.dstFilterMacMask_.octet[3], asic_acl.dstFilterMacMask_.octet[4], asic_acl.dstFilterMacMask_.octet[5] ); len += sprintf(page+len, "\tdvidx: %d dvidxM: %x ProtoType: %x dportL: %d dportU: %d\n", - asic_acl.dstFilterVlanIdx_, asic_acl.dstFilterVlanIdxMask_, - (asic_acl.dstFilterIgnoreL3L4_==TRUE? 2: (asic_acl.dstFilterIgnoreL4_ == 1? 1: 0)), + asic_acl.dstFilterVlanIdx_, asic_acl.dstFilterVlanIdxMask_, + (asic_acl.dstFilterIgnoreL3L4_==TRUE? 2: (asic_acl.dstFilterIgnoreL4_ == 1? 1: 0)), asic_acl.dstFilterPortLowerBound_, asic_acl.dstFilterPortUpperBound_ ); len += sprintf(page+len, "\tdip: %d.%d.%d.%d dipM: %d.%d.%d.%d\n", (asic_acl.dstFilterIpAddr_>>24), @@ -751,15 +908,15 @@ static int32 acl_read( char *page, char **start, off_t off, int count, int *eof, break; case RTL865X_ACL_DSTFILTER_IPRANGE: len += sprintf(page+len, " [%d] rule type: %s rule action: %s\n", acl_start, "Deatination Filter(IP Range)", actionT[asic_acl.actionType_]); - len += sprintf(page+len, "\tDMAC: %x:%x:%x:%x:%x:%x DMACM: %x:%x:%x:%x:%x:%x\n", - asic_acl.dstFilterMac_.octet[0], asic_acl.dstFilterMac_.octet[1], asic_acl.dstFilterMac_.octet[2], + len += sprintf(page+len, "\tDMAC: %x:%x:%x:%x:%x:%x DMACM: %x:%x:%x:%x:%x:%x\n", + asic_acl.dstFilterMac_.octet[0], asic_acl.dstFilterMac_.octet[1], asic_acl.dstFilterMac_.octet[2], asic_acl.dstFilterMac_.octet[3], asic_acl.dstFilterMac_.octet[4], asic_acl.dstFilterMac_.octet[5], asic_acl.dstFilterMacMask_.octet[0], asic_acl.dstFilterMacMask_.octet[1], asic_acl.dstFilterMacMask_.octet[2], asic_acl.dstFilterMacMask_.octet[3], asic_acl.dstFilterMacMask_.octet[4], asic_acl.dstFilterMacMask_.octet[5] ); len += sprintf(page+len, "\tdvidx: %d dvidxM: %x ProtoType: %x dportL: %d dportU: %d\n", - asic_acl.dstFilterVlanIdx_, asic_acl.dstFilterVlanIdxMask_, - (asic_acl.dstFilterIgnoreL3L4_==TRUE? 2: (asic_acl.dstFilterIgnoreL4_ == 1? 1: 0)), + asic_acl.dstFilterVlanIdx_, asic_acl.dstFilterVlanIdxMask_, + (asic_acl.dstFilterIgnoreL3L4_==TRUE? 2: (asic_acl.dstFilterIgnoreL4_ == 1? 1: 0)), asic_acl.dstFilterPortLowerBound_, asic_acl.dstFilterPortUpperBound_ ); len += sprintf(page+len, "\tdipU: %d.%d.%d.%d dipL: %d.%d.%d.%d\n", (asic_acl.dstFilterIpAddr_>>24), @@ -777,7 +934,7 @@ static int32 acl_read( char *page, char **start, off_t off, int count, int *eof, /* Action type */ - switch (asic_acl.actionType_) + switch (asic_acl.actionType_) { case RTL865X_ACL_PERMIT: @@ -792,10 +949,10 @@ static int32 acl_read( char *page, char **start, off_t off, int count, int *eof, len += sprintf(page+len, "\tnetifIdx: %d pppoeIdx: %d l2Idx:%d ", asic_acl.netifIdx_, asic_acl.pppoeIdx_, asic_acl.L2Idx_); break; - case RTL865X_ACL_PRIORITY: + case RTL865X_ACL_PRIORITY: len += sprintf(page+len, "\tprioirty: %d ", asic_acl.priority_) ; break; - + case RTL865X_ACL_DEFAULT_REDIRECT: len += sprintf(page+len,"\tnextHop:%d ", asic_acl.nexthopIdx_); break; @@ -806,19 +963,19 @@ static int32 acl_read( char *page, char **start, off_t off, int count, int *eof, case RTL865X_ACL_LOG_RATE_EXCEED_BPS: len += sprintf(page+len, "\tratelimitIdx: %d ", asic_acl.ratelimtIdx_); break; - default: + default: ; - + } len += sprintf(page+len, "pktOpApp: %d\n", asic_acl.pktOpApp_); - + } #else - for( ; acl_start<=acl_end; acl_start++) + for( ; acl_start<=acl_end; acl_start++) { if (rtl8651_getAsicAclRule(acl_start, &asic_acl) == FAILED) rtlglue_printf("=============%s(%d): get asic acl rule error!\n",__FUNCTION__, __LINE__); - + switch(asic_acl.ruleType_) { case RTL8651_ACL_MAC: @@ -830,7 +987,7 @@ static int32 acl_read( char *page, char **start, off_t off, int count, int *eof, asic_acl.dstMacMask_.octet[0], asic_acl.dstMacMask_.octet[1], asic_acl.dstMacMask_.octet[2], asic_acl.dstMacMask_.octet[3], asic_acl.dstMacMask_.octet[4], asic_acl.dstMacMask_.octet[5] ); - + len += sprintf(page+len, "\tSMAC: %x:%x:%x:%x:%x:%x SMACM: %x:%x:%x:%x:%x:%x\n", asic_acl.srcMac_.octet[0], asic_acl.srcMac_.octet[1], asic_acl.srcMac_.octet[2], asic_acl.srcMac_.octet[3], asic_acl.srcMac_.octet[4], asic_acl.srcMac_.octet[5], @@ -854,14 +1011,14 @@ static int32 acl_read( char *page, char **start, off_t off, int count, int *eof, len += sprintf(page+len, "\tTos: %x TosM: %x ipProto: %x ipProtoM: %x ipFlag: %x ipFlagM: %x\n", asic_acl.tos_, asic_acl.tosMask_, asic_acl.ipProto_, asic_acl.ipProtoMask_, asic_acl.ipFlag_, asic_acl.ipFlagMask_ ); - + len += sprintf(page+len, "\t<FOP:%x> <FOM:%x> <http:%x> <httpM:%x> <IdentSdip:%x> <IdentSdipM:%x> \n", asic_acl.ipFOP_, asic_acl.ipFOM_, asic_acl.ipHttpFilter_, asic_acl.ipHttpFilterM_, asic_acl.ipIdentSrcDstIp_, asic_acl.ipIdentSrcDstIpM_ ); - len += sprintf(page+len, "\t<DF:%x> <MF:%x>\n", asic_acl.ipDF_, asic_acl.ipMF_); + len += sprintf(page+len, "\t<DF:%x> <MF:%x>\n", asic_acl.ipDF_, asic_acl.ipMF_); break; - + case RTL8652_ACL_IP_RANGE: len += sprintf(page+len, " [%d] rule type: %s rule action: %s\n", acl_start, "IP Range", actionT[asic_acl.actionType_]); len += sprintf(page+len, "\tdipU: %d.%d.%d.%d dipL: %d.%d.%d.%d\n", (asic_acl.dstIpAddr_>>24), @@ -881,8 +1038,8 @@ static int32 acl_read( char *page, char **start, off_t off, int count, int *eof, asic_acl.ipFOP_, asic_acl.ipFOM_, asic_acl.ipHttpFilter_, asic_acl.ipHttpFilterM_, asic_acl.ipIdentSrcDstIp_, asic_acl.ipIdentSrcDstIpM_ ); - len += sprintf(page+len, "\t<DF:%x> <MF:%x>\n", asic_acl.ipDF_, asic_acl.ipMF_); - break; + len += sprintf(page+len, "\t<DF:%x> <MF:%x>\n", asic_acl.ipDF_, asic_acl.ipMF_); + break; case RTL8651_ACL_ICMP: len += sprintf(page+len, " [%d] rule type: %s rule action: %s\n", acl_start, "ICMP", actionT[asic_acl.actionType_]); len += sprintf(page+len, "\tdip: %d.%d.%d.%d dipM: %d.%d.%d.%d\n", (asic_acl.dstIpAddr_>>24), @@ -896,7 +1053,7 @@ static int32 acl_read( char *page, char **start, off_t off, int count, int *eof, ((asic_acl.srcIpAddrMask_&0x0000ff00)>>8), (asic_acl.srcIpAddrMask_&0xff) ); len += sprintf(page+len, "\tTos: %x TosM: %x type: %x typeM: %x code: %x codeM: %x\n", - asic_acl.tos_, asic_acl.tosMask_, asic_acl.icmpType_, asic_acl.icmpTypeMask_, + asic_acl.tos_, asic_acl.tosMask_, asic_acl.icmpType_, asic_acl.icmpTypeMask_, asic_acl.icmpCode_, asic_acl.icmpCodeMask_); break; case RTL8652_ACL_ICMP_IPRANGE: @@ -912,7 +1069,7 @@ static int32 acl_read( char *page, char **start, off_t off, int count, int *eof, ((asic_acl.srcIpAddrMask_&0x0000ff00)>>8), (asic_acl.srcIpAddrMask_&0xff) ); len += sprintf(page+len, "\tTos: %x TosM: %x type: %x typeM: %x code: %x codeM: %x\n", - asic_acl.tos_, asic_acl.tosMask_, asic_acl.icmpType_, asic_acl.icmpTypeMask_, + asic_acl.tos_, asic_acl.tosMask_, asic_acl.icmpType_, asic_acl.icmpTypeMask_, asic_acl.icmpCode_, asic_acl.icmpCodeMask_); break; case RTL8651_ACL_IGMP: @@ -1009,7 +1166,7 @@ static int32 acl_read( char *page, char **start, off_t off, int count, int *eof, asic_acl.tos_, asic_acl.tosMask_, asic_acl.udpSrcPortLB_, asic_acl.udpSrcPortUB_, asic_acl.udpDstPortLB_, asic_acl.udpDstPortUB_ ); - break; + break; case RTL8652_ACL_UDP_IPRANGE: len += sprintf(page+len, " [%d] rule type: %s rule action: %s\n", acl_start, "UDP IP RANGE", actionT[asic_acl.actionType_]); len += sprintf(page+len, "\tdipU: %d.%d.%d.%d dipL: %d.%d.%d.%d\n", (asic_acl.dstIpAddr_>>24), @@ -1026,7 +1183,7 @@ static int32 acl_read( char *page, char **start, off_t off, int count, int *eof, asic_acl.tos_, asic_acl.tosMask_, asic_acl.udpSrcPortLB_, asic_acl.udpSrcPortUB_, asic_acl.udpDstPortLB_, asic_acl.udpDstPortUB_ ); - break; + break; case RTL8651_ACL_IFSEL: len += sprintf(page+len, " [%d] rule type: %s rule action: %s\n", acl_start, "UDP", actionT[asic_acl.actionType_]); @@ -1034,8 +1191,8 @@ static int32 acl_read( char *page, char **start, off_t off, int count, int *eof, break; case RTL8651_ACL_SRCFILTER: len += sprintf(page+len, " [%d] rule type: %s rule action: %s\n", acl_start, "Source Filter", actionT[asic_acl.actionType_]); - len += sprintf(page+len, "\tSMAC: %x:%x:%x:%x:%x:%x SMACM: %x:%x:%x:%x:%x:%x\n", - asic_acl.srcFilterMac_.octet[0], asic_acl.srcFilterMac_.octet[1], asic_acl.srcFilterMac_.octet[2], + len += sprintf(page+len, "\tSMAC: %x:%x:%x:%x:%x:%x SMACM: %x:%x:%x:%x:%x:%x\n", + asic_acl.srcFilterMac_.octet[0], asic_acl.srcFilterMac_.octet[1], asic_acl.srcFilterMac_.octet[2], asic_acl.srcFilterMac_.octet[3], asic_acl.srcFilterMac_.octet[4], asic_acl.srcFilterMac_.octet[5], asic_acl.srcFilterMacMask_.octet[0], asic_acl.srcFilterMacMask_.octet[1], asic_acl.srcFilterMacMask_.octet[2], asic_acl.srcFilterMacMask_.octet[3], asic_acl.srcFilterMacMask_.octet[4], asic_acl.srcFilterMacMask_.octet[5] @@ -1055,8 +1212,8 @@ static int32 acl_read( char *page, char **start, off_t off, int count, int *eof, case RTL8652_ACL_SRCFILTER_IPRANGE: len += sprintf(page+len, " [%d] rule type: %s rule action: %s\n", acl_start, "Source Filter(IP RANGE)", actionT[asic_acl.actionType_]); - len += sprintf(page+len, "\tSMAC: %x:%x:%x:%x:%x:%x SMACM: %x:%x:%x:%x:%x:%x\n", - asic_acl.srcFilterMac_.octet[0], asic_acl.srcFilterMac_.octet[1], asic_acl.srcFilterMac_.octet[2], + len += sprintf(page+len, "\tSMAC: %x:%x:%x:%x:%x:%x SMACM: %x:%x:%x:%x:%x:%x\n", + asic_acl.srcFilterMac_.octet[0], asic_acl.srcFilterMac_.octet[1], asic_acl.srcFilterMac_.octet[2], asic_acl.srcFilterMac_.octet[3], asic_acl.srcFilterMac_.octet[4], asic_acl.srcFilterMac_.octet[5], asic_acl.srcFilterMacMask_.octet[0], asic_acl.srcFilterMacMask_.octet[1], asic_acl.srcFilterMacMask_.octet[2], asic_acl.srcFilterMacMask_.octet[3], asic_acl.srcFilterMacMask_.octet[4], asic_acl.srcFilterMacMask_.octet[5] @@ -1076,15 +1233,15 @@ static int32 acl_read( char *page, char **start, off_t off, int count, int *eof, case RTL8651_ACL_DSTFILTER: len += sprintf(page+len, " [%d] rule type: %s rule action: %s\n", acl_start, "Deatination Filter", actionT[asic_acl.actionType_]); - len += sprintf(page+len, "\tDMAC: %x:%x:%x:%x:%x:%x DMACM: %x:%x:%x:%x:%x:%x\n", - asic_acl.dstFilterMac_.octet[0], asic_acl.dstFilterMac_.octet[1], asic_acl.dstFilterMac_.octet[2], + len += sprintf(page+len, "\tDMAC: %x:%x:%x:%x:%x:%x DMACM: %x:%x:%x:%x:%x:%x\n", + asic_acl.dstFilterMac_.octet[0], asic_acl.dstFilterMac_.octet[1], asic_acl.dstFilterMac_.octet[2], asic_acl.dstFilterMac_.octet[3], asic_acl.dstFilterMac_.octet[4], asic_acl.dstFilterMac_.octet[5], asic_acl.dstFilterMacMask_.octet[0], asic_acl.dstFilterMacMask_.octet[1], asic_acl.dstFilterMacMask_.octet[2], asic_acl.dstFilterMacMask_.octet[3], asic_acl.dstFilterMacMask_.octet[4], asic_acl.dstFilterMacMask_.octet[5] ); len += sprintf(page+len, "\tdvidx: %d dvidxM: %x ProtoType: %x dportL: %d dportU: %d\n", - asic_acl.dstFilterVlanIdx_, asic_acl.dstFilterVlanIdxMask_, - (asic_acl.dstFilterIgnoreL3L4_==TRUE? 2: (asic_acl.dstFilterIgnoreL4_ == 1? 1: 0)), + asic_acl.dstFilterVlanIdx_, asic_acl.dstFilterVlanIdxMask_, + (asic_acl.dstFilterIgnoreL3L4_==TRUE? 2: (asic_acl.dstFilterIgnoreL4_ == 1? 1: 0)), asic_acl.dstFilterPortLowerBound_, asic_acl.dstFilterPortUpperBound_ ); len += sprintf(page+len, "\tdip: %d.%d.%d.%d dipM: %d.%d.%d.%d\n", (asic_acl.dstFilterIpAddr_>>24), @@ -1096,15 +1253,15 @@ static int32 acl_read( char *page, char **start, off_t off, int count, int *eof, break; case RTL8652_ACL_DSTFILTER_IPRANGE: len += sprintf(page+len, " [%d] rule type: %s rule action: %s\n", acl_start, "Deatination Filter(IP Range)", actionT[asic_acl.actionType_]); - len += sprintf(page+len, "\tDMAC: %x:%x:%x:%x:%x:%x DMACM: %x:%x:%x:%x:%x:%x\n", - asic_acl.dstFilterMac_.octet[0], asic_acl.dstFilterMac_.octet[1], asic_acl.dstFilterMac_.octet[2], + len += sprintf(page+len, "\tDMAC: %x:%x:%x:%x:%x:%x DMACM: %x:%x:%x:%x:%x:%x\n", + asic_acl.dstFilterMac_.octet[0], asic_acl.dstFilterMac_.octet[1], asic_acl.dstFilterMac_.octet[2], asic_acl.dstFilterMac_.octet[3], asic_acl.dstFilterMac_.octet[4], asic_acl.dstFilterMac_.octet[5], asic_acl.dstFilterMacMask_.octet[0], asic_acl.dstFilterMacMask_.octet[1], asic_acl.dstFilterMacMask_.octet[2], asic_acl.dstFilterMacMask_.octet[3], asic_acl.dstFilterMacMask_.octet[4], asic_acl.dstFilterMacMask_.octet[5] ); len += sprintf(page+len, "\tdvidx: %d dvidxM: %x ProtoType: %x dportL: %d dportU: %d\n", - asic_acl.dstFilterVlanIdx_, asic_acl.dstFilterVlanIdxMask_, - (asic_acl.dstFilterIgnoreL3L4_==TRUE? 2: (asic_acl.dstFilterIgnoreL4_ == 1? 1: 0)), + asic_acl.dstFilterVlanIdx_, asic_acl.dstFilterVlanIdxMask_, + (asic_acl.dstFilterIgnoreL3L4_==TRUE? 2: (asic_acl.dstFilterIgnoreL4_ == 1? 1: 0)), asic_acl.dstFilterPortLowerBound_, asic_acl.dstFilterPortUpperBound_ ); len += sprintf(page+len, "\tdipU: %d.%d.%d.%d dipL: %d.%d.%d.%d\n", (asic_acl.dstFilterIpAddr_>>24), @@ -1122,7 +1279,7 @@ static int32 acl_read( char *page, char **start, off_t off, int count, int *eof, /* Action type */ - switch (asic_acl.actionType_) + switch (asic_acl.actionType_) { case RTL8651_ACL_PERMIT: /* 0x00 */ @@ -1151,17 +1308,17 @@ static int32 acl_read( char *page, char **start, off_t off, int count, int *eof, case RTL8651_ACL_LOG_RATE_EXCEED_BPS: /* 0x0d */ len += sprintf(page+len, "\trlIdx: %d ", asic_acl.rlIndex); break; - default: + default: ; - + } len += sprintf(page+len, "pktOpApp: %d\n", asic_acl.pktOpApp); - + } #endif - if (outRule == FALSE) + if (outRule == FALSE) { acl_start = asic_intf.outAclStart; acl_end = asic_intf.outAclEnd; outRule = TRUE; @@ -1186,11 +1343,11 @@ static int32 acl_write( struct file *filp, const char *buff,unsigned long len, v #if RTL_LAYERED_DRIVER_DEBUG char tmpbuf[32]; int32 testNo; - - if (buff && !copy_from_user(tmpbuf, buff, len)) + + if (buff && !copy_from_user(tmpbuf, buff, len)) { tmpbuf[len] = '\0'; - testNo = tmpbuf[0]-'0'; + testNo = tmpbuf[0]-'0'; rtl865x_acl_test(testNo); } #endif @@ -1207,14 +1364,18 @@ static int32 advRt_read( char *page, char **start, off_t off, int count, int *eo return len; } -static int32 advRt_write( struct file *filp, const char *buff,unsigned long len, void *data ) +static int32 advRt_write( struct file *filp, const char *buff,unsigned long len, void *data ) { char tmpbuf[32]; rtl_advRoute_entry_t rule; int retval; + if(len>32) + { + goto errout; + } if (buff && !copy_from_user(tmpbuf, buff, len)) { - tmpbuf[len -1] = '\0'; + tmpbuf[len -1] = '\0'; if(tmpbuf[0] == '1') { //add rule @@ -1232,7 +1393,7 @@ static int32 advRt_write( struct file *filp, const char *buff,unsigned long len, rule.advrt_dstIpAddrEnd_ = 0xffffffff; retval = rtl_add_advRt_entry(&rule); - printk("===%s(%d),retval(%d)\n",__FUNCTION__,__LINE__,retval); + rtlglue_printf("===%s(%d),retval(%d)\n",__FUNCTION__,__LINE__,retval); //add rule memset(&rule,0,sizeof(rtl_advRoute_entry_t)); @@ -1249,7 +1410,7 @@ static int32 advRt_write( struct file *filp, const char *buff,unsigned long len, rule.advrt_dstIpAddrEnd_ = 0xffffffff; retval = rtl_add_advRt_entry(&rule); - printk("===%s(%d),retval(%d)\n",__FUNCTION__,__LINE__,retval); + rtlglue_printf("===%s(%d),retval(%d)\n",__FUNCTION__,__LINE__,retval); } else if(tmpbuf[0] == '2') { @@ -1267,7 +1428,7 @@ static int32 advRt_write( struct file *filp, const char *buff,unsigned long len, rule.advrt_dstIpAddrEnd_ = 0xffffffff; retval = rtl_del_advRt_entry(&rule); - printk("===%s(%d),retval(%d)\n",__FUNCTION__,__LINE__,retval); + rtlglue_printf("===%s(%d),retval(%d)\n",__FUNCTION__,__LINE__,retval); } else { @@ -1285,17 +1446,22 @@ static int32 advRt_write( struct file *filp, const char *buff,unsigned long len, rule.advrt_dstIpAddrEnd_ = 0xffffffff; retval = rtl_del_advRt_entry(&rule); - printk("===%s(%d),retval(%d)\n",__FUNCTION__,__LINE__,retval); + rtlglue_printf("===%s(%d),retval(%d)\n",__FUNCTION__,__LINE__,retval); } } + else + { +errout: + rtlglue_printf("error input\n"); + } return len; } #endif int acl_show(struct seq_file *s, void *v) { - int8 *actionT[] = { "permit", "redirect to ether", "drop", "to cpu", "legacy drop", - "drop for log", "mirror", "redirect to pppoe", "default redirect", "mirror keep match", + int8 *actionT[] = { "permit", "redirect to ether", "drop", "to cpu", "legacy drop", + "drop for log", "mirror", "redirect to pppoe", "default redirect", "mirror keep match", "drop rate exceed pps", "log rate exceed pps", "drop rate exceed bps", "log rate exceed bps","priority " }; #ifdef CONFIG_RTL_LAYERED_DRIVER @@ -1308,13 +1474,13 @@ int acl_show(struct seq_file *s, void *v) uint16 vid; int8 outRule; -#if defined (CONFIG_RTL_LOCAL_PUBLIC) || defined(CONFIG_RTL_MULTIPLE_WAN) +#if defined (CONFIG_RTL_LOCAL_PUBLIC) || defined(CONFIG_RTL_MULTIPLE_WAN) || defined(CONFIG_RTL_HW_VLAN_SUPPORT) unsigned char defInAclStart, defInAclEnd,defOutAclStart,defOutAclEnd; #endif - + seq_printf(s, "%s\n", "ASIC ACL Table:"); - for(vid=0; vid<8; vid++ ) + for(vid=0; vid<8; vid++ ) { /* Read VLAN Table */ if (rtl8651_getAsicNetInterface(vid, &asic_intf) == FAILED) @@ -1337,7 +1503,7 @@ int acl_show(struct seq_file *s, void *v) { if ( _rtl865x_getAclFromAsic(acl_start, &asic_acl) == FAILED) rtlglue_printf("=============%s(%d): get asic acl rule error!\n",__FUNCTION__, __LINE__); - + switch(asic_acl.ruleType_) { case RTL865X_ACL_MAC: @@ -1349,7 +1515,7 @@ int acl_show(struct seq_file *s, void *v) asic_acl.dstMacMask_.octet[0], asic_acl.dstMacMask_.octet[1], asic_acl.dstMacMask_.octet[2], asic_acl.dstMacMask_.octet[3], asic_acl.dstMacMask_.octet[4], asic_acl.dstMacMask_.octet[5] ); - + seq_printf(s, "\tSMAC: %x:%x:%x:%x:%x:%x SMACM: %x:%x:%x:%x:%x:%x\n", asic_acl.srcMac_.octet[0], asic_acl.srcMac_.octet[1], asic_acl.srcMac_.octet[2], asic_acl.srcMac_.octet[3], asic_acl.srcMac_.octet[4], asic_acl.srcMac_.octet[5], @@ -1373,14 +1539,14 @@ int acl_show(struct seq_file *s, void *v) seq_printf(s, "\tTos: %x TosM: %x ipProto: %x ipProtoM: %x ipFlag: %x ipFlagM: %x\n", asic_acl.tos_, asic_acl.tosMask_, asic_acl.ipProto_, asic_acl.ipProtoMask_, asic_acl.ipFlag_, asic_acl.ipFlagMask_ ); - + seq_printf(s, "\t<FOP:%x> <FOM:%x> <http:%x> <httpM:%x> <IdentSdip:%x> <IdentSdipM:%x> \n", asic_acl.ipFOP_, asic_acl.ipFOM_, asic_acl.ipHttpFilter_, asic_acl.ipHttpFilterM_, asic_acl.ipIdentSrcDstIp_, asic_acl.ipIdentSrcDstIpM_ ); - seq_printf(s, "\t<DF:%x> <MF:%x>\n", asic_acl.ipDF_, asic_acl.ipMF_); + seq_printf(s, "\t<DF:%x> <MF:%x>\n", asic_acl.ipDF_, asic_acl.ipMF_); break; - + case RTL865X_ACL_IP_RANGE: seq_printf(s, " [%d] rule type: %s rule action: %s\n", acl_start, "IP Range", actionT[asic_acl.actionType_]); seq_printf(s, "\tdipU: %d.%d.%d.%d dipL: %d.%d.%d.%d\n", (asic_acl.dstIpAddr_>>24), @@ -1400,8 +1566,8 @@ int acl_show(struct seq_file *s, void *v) asic_acl.ipFOP_, asic_acl.ipFOM_, asic_acl.ipHttpFilter_, asic_acl.ipHttpFilterM_, asic_acl.ipIdentSrcDstIp_, asic_acl.ipIdentSrcDstIpM_ ); - seq_printf(s, "\t<DF:%x> <MF:%x>\n", asic_acl.ipDF_, asic_acl.ipMF_); - break; + seq_printf(s, "\t<DF:%x> <MF:%x>\n", asic_acl.ipDF_, asic_acl.ipMF_); + break; case RTL865X_ACL_ICMP: seq_printf(s, " [%d] rule type: %s rule action: %s\n", acl_start, "ICMP", actionT[asic_acl.actionType_]); seq_printf(s, "\tdip: %d.%d.%d.%d dipM: %d.%d.%d.%d\n", (asic_acl.dstIpAddr_>>24), @@ -1415,7 +1581,7 @@ int acl_show(struct seq_file *s, void *v) ((asic_acl.srcIpAddrMask_&0x0000ff00)>>8), (asic_acl.srcIpAddrMask_&0xff) ); seq_printf(s, "\tTos: %x TosM: %x type: %x typeM: %x code: %x codeM: %x\n", - asic_acl.tos_, asic_acl.tosMask_, asic_acl.icmpType_, asic_acl.icmpTypeMask_, + asic_acl.tos_, asic_acl.tosMask_, asic_acl.icmpType_, asic_acl.icmpTypeMask_, asic_acl.icmpCode_, asic_acl.icmpCodeMask_); break; case RTL865X_ACL_ICMP_IPRANGE: @@ -1431,7 +1597,7 @@ int acl_show(struct seq_file *s, void *v) ((asic_acl.srcIpAddrMask_&0x0000ff00)>>8), (asic_acl.srcIpAddrMask_&0xff) ); seq_printf(s, "\tTos: %x TosM: %x type: %x typeM: %x code: %x codeM: %x\n", - asic_acl.tos_, asic_acl.tosMask_, asic_acl.icmpType_, asic_acl.icmpTypeMask_, + asic_acl.tos_, asic_acl.tosMask_, asic_acl.icmpType_, asic_acl.icmpTypeMask_, asic_acl.icmpCode_, asic_acl.icmpCodeMask_); break; case RTL865X_ACL_IGMP: @@ -1528,7 +1694,7 @@ int acl_show(struct seq_file *s, void *v) asic_acl.tos_, asic_acl.tosMask_, asic_acl.udpSrcPortLB_, asic_acl.udpSrcPortUB_, asic_acl.udpDstPortLB_, asic_acl.udpDstPortUB_ ); - break; + break; case RTL865X_ACL_UDP_IPRANGE: seq_printf(s, " [%d] rule type: %s rule action: %s\n", acl_start, "UDP IP RANGE", actionT[asic_acl.actionType_]); seq_printf(s, "\tdipU: %d.%d.%d.%d dipL: %d.%d.%d.%d\n", (asic_acl.dstIpAddr_>>24), @@ -1545,13 +1711,13 @@ int acl_show(struct seq_file *s, void *v) asic_acl.tos_, asic_acl.tosMask_, asic_acl.udpSrcPortLB_, asic_acl.udpSrcPortUB_, asic_acl.udpDstPortLB_, asic_acl.udpDstPortUB_ ); - break; + break; + - case RTL865X_ACL_SRCFILTER: seq_printf(s, " [%d] rule type: %s rule action: %s\n", acl_start, "Source Filter", actionT[asic_acl.actionType_]); - seq_printf(s, "\tSMAC: %x:%x:%x:%x:%x:%x SMACM: %x:%x:%x:%x:%x:%x\n", - asic_acl.srcFilterMac_.octet[0], asic_acl.srcFilterMac_.octet[1], asic_acl.srcFilterMac_.octet[2], + seq_printf(s, "\tSMAC: %x:%x:%x:%x:%x:%x SMACM: %x:%x:%x:%x:%x:%x\n", + asic_acl.srcFilterMac_.octet[0], asic_acl.srcFilterMac_.octet[1], asic_acl.srcFilterMac_.octet[2], asic_acl.srcFilterMac_.octet[3], asic_acl.srcFilterMac_.octet[4], asic_acl.srcFilterMac_.octet[5], asic_acl.srcFilterMacMask_.octet[0], asic_acl.srcFilterMacMask_.octet[1], asic_acl.srcFilterMacMask_.octet[2], asic_acl.srcFilterMacMask_.octet[3], asic_acl.srcFilterMacMask_.octet[4], asic_acl.srcFilterMacMask_.octet[5] @@ -1571,8 +1737,8 @@ int acl_show(struct seq_file *s, void *v) case RTL865X_ACL_SRCFILTER_IPRANGE: seq_printf(s, " [%d] rule type: %s rule action: %s\n", acl_start, "Source Filter(IP RANGE)", actionT[asic_acl.actionType_]); - seq_printf(s, "\tSMAC: %x:%x:%x:%x:%x:%x SMACM: %x:%x:%x:%x:%x:%x\n", - asic_acl.srcFilterMac_.octet[0], asic_acl.srcFilterMac_.octet[1], asic_acl.srcFilterMac_.octet[2], + seq_printf(s, "\tSMAC: %x:%x:%x:%x:%x:%x SMACM: %x:%x:%x:%x:%x:%x\n", + asic_acl.srcFilterMac_.octet[0], asic_acl.srcFilterMac_.octet[1], asic_acl.srcFilterMac_.octet[2], asic_acl.srcFilterMac_.octet[3], asic_acl.srcFilterMac_.octet[4], asic_acl.srcFilterMac_.octet[5], asic_acl.srcFilterMacMask_.octet[0], asic_acl.srcFilterMacMask_.octet[1], asic_acl.srcFilterMacMask_.octet[2], asic_acl.srcFilterMacMask_.octet[3], asic_acl.srcFilterMacMask_.octet[4], asic_acl.srcFilterMacMask_.octet[5] @@ -1592,15 +1758,15 @@ int acl_show(struct seq_file *s, void *v) case RTL865X_ACL_DSTFILTER: seq_printf(s, " [%d] rule type: %s rule action: %s\n", acl_start, "Deatination Filter", actionT[asic_acl.actionType_]); - seq_printf(s, "\tDMAC: %x:%x:%x:%x:%x:%x DMACM: %x:%x:%x:%x:%x:%x\n", - asic_acl.dstFilterMac_.octet[0], asic_acl.dstFilterMac_.octet[1], asic_acl.dstFilterMac_.octet[2], + seq_printf(s, "\tDMAC: %x:%x:%x:%x:%x:%x DMACM: %x:%x:%x:%x:%x:%x\n", + asic_acl.dstFilterMac_.octet[0], asic_acl.dstFilterMac_.octet[1], asic_acl.dstFilterMac_.octet[2], asic_acl.dstFilterMac_.octet[3], asic_acl.dstFilterMac_.octet[4], asic_acl.dstFilterMac_.octet[5], asic_acl.dstFilterMacMask_.octet[0], asic_acl.dstFilterMacMask_.octet[1], asic_acl.dstFilterMacMask_.octet[2], asic_acl.dstFilterMacMask_.octet[3], asic_acl.dstFilterMacMask_.octet[4], asic_acl.dstFilterMacMask_.octet[5] ); seq_printf(s, "\tdvidx: %d dvidxM: %x ProtoType: %x dportL: %d dportU: %d\n", - asic_acl.dstFilterVlanIdx_, asic_acl.dstFilterVlanIdxMask_, - (asic_acl.dstFilterIgnoreL3L4_==TRUE? 2: (asic_acl.dstFilterIgnoreL4_ == 1? 1: 0)), + asic_acl.dstFilterVlanIdx_, asic_acl.dstFilterVlanIdxMask_, + (asic_acl.dstFilterIgnoreL3L4_==TRUE? 2: (asic_acl.dstFilterIgnoreL4_ == 1? 1: 0)), asic_acl.dstFilterPortLowerBound_, asic_acl.dstFilterPortUpperBound_ ); seq_printf(s, "\tdip: %d.%d.%d.%d dipM: %d.%d.%d.%d\n", (asic_acl.dstFilterIpAddr_>>24), @@ -1612,15 +1778,15 @@ int acl_show(struct seq_file *s, void *v) break; case RTL865X_ACL_DSTFILTER_IPRANGE: seq_printf(s, " [%d] rule type: %s rule action: %s\n", acl_start, "Deatination Filter(IP Range)", actionT[asic_acl.actionType_]); - seq_printf(s, "\tDMAC: %x:%x:%x:%x:%x:%x DMACM: %x:%x:%x:%x:%x:%x\n", - asic_acl.dstFilterMac_.octet[0], asic_acl.dstFilterMac_.octet[1], asic_acl.dstFilterMac_.octet[2], + seq_printf(s, "\tDMAC: %x:%x:%x:%x:%x:%x DMACM: %x:%x:%x:%x:%x:%x\n", + asic_acl.dstFilterMac_.octet[0], asic_acl.dstFilterMac_.octet[1], asic_acl.dstFilterMac_.octet[2], asic_acl.dstFilterMac_.octet[3], asic_acl.dstFilterMac_.octet[4], asic_acl.dstFilterMac_.octet[5], asic_acl.dstFilterMacMask_.octet[0], asic_acl.dstFilterMacMask_.octet[1], asic_acl.dstFilterMacMask_.octet[2], asic_acl.dstFilterMacMask_.octet[3], asic_acl.dstFilterMacMask_.octet[4], asic_acl.dstFilterMacMask_.octet[5] ); seq_printf(s, "\tdvidx: %d dvidxM: %x ProtoType: %x dportL: %d dportU: %d\n", - asic_acl.dstFilterVlanIdx_, asic_acl.dstFilterVlanIdxMask_, - (asic_acl.dstFilterIgnoreL3L4_==TRUE? 2: (asic_acl.dstFilterIgnoreL4_ == 1? 1: 0)), + asic_acl.dstFilterVlanIdx_, asic_acl.dstFilterVlanIdxMask_, + (asic_acl.dstFilterIgnoreL3L4_==TRUE? 2: (asic_acl.dstFilterIgnoreL4_ == 1? 1: 0)), asic_acl.dstFilterPortLowerBound_, asic_acl.dstFilterPortUpperBound_ ); seq_printf(s, "\tdipU: %d.%d.%d.%d dipL: %d.%d.%d.%d\n", (asic_acl.dstFilterIpAddr_>>24), @@ -1638,7 +1804,7 @@ int acl_show(struct seq_file *s, void *v) /* Action type */ - switch (asic_acl.actionType_) + switch (asic_acl.actionType_) { case RTL865X_ACL_PERMIT: @@ -1653,10 +1819,10 @@ int acl_show(struct seq_file *s, void *v) seq_printf(s, "\tnetifIdx: %d pppoeIdx: %d l2Idx:%d ", asic_acl.netifIdx_, asic_acl.pppoeIdx_, asic_acl.L2Idx_); break; - case RTL865X_ACL_PRIORITY: + case RTL865X_ACL_PRIORITY: seq_printf(s, "\tprioirty: %d ", asic_acl.priority_) ; break; - + case RTL865X_ACL_DEFAULT_REDIRECT: seq_printf(s,"\tnextHop:%d ", asic_acl.nexthopIdx_); break; @@ -1667,19 +1833,19 @@ int acl_show(struct seq_file *s, void *v) case RTL865X_ACL_LOG_RATE_EXCEED_BPS: seq_printf(s, "\tratelimitIdx: %d ", asic_acl.ratelimtIdx_); break; - default: + default: ; - + } seq_printf(s, "pktOpApp: %d\n", asic_acl.pktOpApp_); - + } #else - for( ; acl_start<=acl_end; acl_start++) + for( ; acl_start<=acl_end; acl_start++) { if (rtl8651_getAsicAclRule(acl_start, &asic_acl) == FAILED) rtlglue_printf("=============%s(%d): get asic acl rule error!\n",__FUNCTION__, __LINE__); - + switch(asic_acl.ruleType_) { case RTL8651_ACL_MAC: @@ -1691,7 +1857,7 @@ int acl_show(struct seq_file *s, void *v) asic_acl.dstMacMask_.octet[0], asic_acl.dstMacMask_.octet[1], asic_acl.dstMacMask_.octet[2], asic_acl.dstMacMask_.octet[3], asic_acl.dstMacMask_.octet[4], asic_acl.dstMacMask_.octet[5] ); - + seq_printf(s, "\tSMAC: %x:%x:%x:%x:%x:%x SMACM: %x:%x:%x:%x:%x:%x\n", asic_acl.srcMac_.octet[0], asic_acl.srcMac_.octet[1], asic_acl.srcMac_.octet[2], asic_acl.srcMac_.octet[3], asic_acl.srcMac_.octet[4], asic_acl.srcMac_.octet[5], @@ -1715,14 +1881,14 @@ int acl_show(struct seq_file *s, void *v) seq_printf(s, "\tTos: %x TosM: %x ipProto: %x ipProtoM: %x ipFlag: %x ipFlagM: %x\n", asic_acl.tos_, asic_acl.tosMask_, asic_acl.ipProto_, asic_acl.ipProtoMask_, asic_acl.ipFlag_, asic_acl.ipFlagMask_ ); - + seq_printf(s, "\t<FOP:%x> <FOM:%x> <http:%x> <httpM:%x> <IdentSdip:%x> <IdentSdipM:%x> \n", asic_acl.ipFOP_, asic_acl.ipFOM_, asic_acl.ipHttpFilter_, asic_acl.ipHttpFilterM_, asic_acl.ipIdentSrcDstIp_, asic_acl.ipIdentSrcDstIpM_ ); - seq_printf(s, "\t<DF:%x> <MF:%x>\n", asic_acl.ipDF_, asic_acl.ipMF_); + seq_printf(s, "\t<DF:%x> <MF:%x>\n", asic_acl.ipDF_, asic_acl.ipMF_); break; - + case RTL8652_ACL_IP_RANGE: seq_printf(s, " [%d] rule type: %s rule action: %s\n", acl_start, "IP Range", actionT[asic_acl.actionType_]); seq_printf(s, "\tdipU: %d.%d.%d.%d dipL: %d.%d.%d.%d\n", (asic_acl.dstIpAddr_>>24), @@ -1742,8 +1908,8 @@ int acl_show(struct seq_file *s, void *v) asic_acl.ipFOP_, asic_acl.ipFOM_, asic_acl.ipHttpFilter_, asic_acl.ipHttpFilterM_, asic_acl.ipIdentSrcDstIp_, asic_acl.ipIdentSrcDstIpM_ ); - seq_printf(s, "\t<DF:%x> <MF:%x>\n", asic_acl.ipDF_, asic_acl.ipMF_); - break; + seq_printf(s, "\t<DF:%x> <MF:%x>\n", asic_acl.ipDF_, asic_acl.ipMF_); + break; case RTL8651_ACL_ICMP: seq_printf(s, " [%d] rule type: %s rule action: %s\n", acl_start, "ICMP", actionT[asic_acl.actionType_]); seq_printf(s, "\tdip: %d.%d.%d.%d dipM: %d.%d.%d.%d\n", (asic_acl.dstIpAddr_>>24), @@ -1757,7 +1923,7 @@ int acl_show(struct seq_file *s, void *v) ((asic_acl.srcIpAddrMask_&0x0000ff00)>>8), (asic_acl.srcIpAddrMask_&0xff) ); seq_printf(s, "\tTos: %x TosM: %x type: %x typeM: %x code: %x codeM: %x\n", - asic_acl.tos_, asic_acl.tosMask_, asic_acl.icmpType_, asic_acl.icmpTypeMask_, + asic_acl.tos_, asic_acl.tosMask_, asic_acl.icmpType_, asic_acl.icmpTypeMask_, asic_acl.icmpCode_, asic_acl.icmpCodeMask_); break; case RTL8652_ACL_ICMP_IPRANGE: @@ -1773,7 +1939,7 @@ int acl_show(struct seq_file *s, void *v) ((asic_acl.srcIpAddrMask_&0x0000ff00)>>8), (asic_acl.srcIpAddrMask_&0xff) ); seq_printf(s, "\tTos: %x TosM: %x type: %x typeM: %x code: %x codeM: %x\n", - asic_acl.tos_, asic_acl.tosMask_, asic_acl.icmpType_, asic_acl.icmpTypeMask_, + asic_acl.tos_, asic_acl.tosMask_, asic_acl.icmpType_, asic_acl.icmpTypeMask_, asic_acl.icmpCode_, asic_acl.icmpCodeMask_); break; case RTL8651_ACL_IGMP: @@ -1870,7 +2036,7 @@ int acl_show(struct seq_file *s, void *v) asic_acl.tos_, asic_acl.tosMask_, asic_acl.udpSrcPortLB_, asic_acl.udpSrcPortUB_, asic_acl.udpDstPortLB_, asic_acl.udpDstPortUB_ ); - break; + break; case RTL8652_ACL_UDP_IPRANGE: seq_printf(s, " [%d] rule type: %s rule action: %s\n", acl_start, "UDP IP RANGE", actionT[asic_acl.actionType_]); seq_printf(s, "\tdipU: %d.%d.%d.%d dipL: %d.%d.%d.%d\n", (asic_acl.dstIpAddr_>>24), @@ -1887,7 +2053,7 @@ int acl_show(struct seq_file *s, void *v) asic_acl.tos_, asic_acl.tosMask_, asic_acl.udpSrcPortLB_, asic_acl.udpSrcPortUB_, asic_acl.udpDstPortLB_, asic_acl.udpDstPortUB_ ); - break; + break; case RTL8651_ACL_IFSEL: seq_printf(s, " [%d] rule type: %s rule action: %s\n", acl_start, "UDP", actionT[asic_acl.actionType_]); @@ -1895,8 +2061,8 @@ int acl_show(struct seq_file *s, void *v) break; case RTL8651_ACL_SRCFILTER: seq_printf(s, " [%d] rule type: %s rule action: %s\n", acl_start, "Source Filter", actionT[asic_acl.actionType_]); - seq_printf(s, "\tSMAC: %x:%x:%x:%x:%x:%x SMACM: %x:%x:%x:%x:%x:%x\n", - asic_acl.srcFilterMac_.octet[0], asic_acl.srcFilterMac_.octet[1], asic_acl.srcFilterMac_.octet[2], + seq_printf(s, "\tSMAC: %x:%x:%x:%x:%x:%x SMACM: %x:%x:%x:%x:%x:%x\n", + asic_acl.srcFilterMac_.octet[0], asic_acl.srcFilterMac_.octet[1], asic_acl.srcFilterMac_.octet[2], asic_acl.srcFilterMac_.octet[3], asic_acl.srcFilterMac_.octet[4], asic_acl.srcFilterMac_.octet[5], asic_acl.srcFilterMacMask_.octet[0], asic_acl.srcFilterMacMask_.octet[1], asic_acl.srcFilterMacMask_.octet[2], asic_acl.srcFilterMacMask_.octet[3], asic_acl.srcFilterMacMask_.octet[4], asic_acl.srcFilterMacMask_.octet[5] @@ -1916,8 +2082,8 @@ int acl_show(struct seq_file *s, void *v) case RTL8652_ACL_SRCFILTER_IPRANGE: seq_printf(s, " [%d] rule type: %s rule action: %s\n", acl_start, "Source Filter(IP RANGE)", actionT[asic_acl.actionType_]); - seq_printf(s, "\tSMAC: %x:%x:%x:%x:%x:%x SMACM: %x:%x:%x:%x:%x:%x\n", - asic_acl.srcFilterMac_.octet[0], asic_acl.srcFilterMac_.octet[1], asic_acl.srcFilterMac_.octet[2], + seq_printf(s, "\tSMAC: %x:%x:%x:%x:%x:%x SMACM: %x:%x:%x:%x:%x:%x\n", + asic_acl.srcFilterMac_.octet[0], asic_acl.srcFilterMac_.octet[1], asic_acl.srcFilterMac_.octet[2], asic_acl.srcFilterMac_.octet[3], asic_acl.srcFilterMac_.octet[4], asic_acl.srcFilterMac_.octet[5], asic_acl.srcFilterMacMask_.octet[0], asic_acl.srcFilterMacMask_.octet[1], asic_acl.srcFilterMacMask_.octet[2], asic_acl.srcFilterMacMask_.octet[3], asic_acl.srcFilterMacMask_.octet[4], asic_acl.srcFilterMacMask_.octet[5] @@ -1937,15 +2103,15 @@ int acl_show(struct seq_file *s, void *v) case RTL8651_ACL_DSTFILTER: seq_printf(s, " [%d] rule type: %s rule action: %s\n", acl_start, "Deatination Filter", actionT[asic_acl.actionType_]); - seq_printf(s, "\tDMAC: %x:%x:%x:%x:%x:%x DMACM: %x:%x:%x:%x:%x:%x\n", - asic_acl.dstFilterMac_.octet[0], asic_acl.dstFilterMac_.octet[1], asic_acl.dstFilterMac_.octet[2], + seq_printf(s, "\tDMAC: %x:%x:%x:%x:%x:%x DMACM: %x:%x:%x:%x:%x:%x\n", + asic_acl.dstFilterMac_.octet[0], asic_acl.dstFilterMac_.octet[1], asic_acl.dstFilterMac_.octet[2], asic_acl.dstFilterMac_.octet[3], asic_acl.dstFilterMac_.octet[4], asic_acl.dstFilterMac_.octet[5], asic_acl.dstFilterMacMask_.octet[0], asic_acl.dstFilterMacMask_.octet[1], asic_acl.dstFilterMacMask_.octet[2], asic_acl.dstFilterMacMask_.octet[3], asic_acl.dstFilterMacMask_.octet[4], asic_acl.dstFilterMacMask_.octet[5] ); seq_printf(s, "\tdvidx: %d dvidxM: %x ProtoType: %x dportL: %d dportU: %d\n", - asic_acl.dstFilterVlanIdx_, asic_acl.dstFilterVlanIdxMask_, - (asic_acl.dstFilterIgnoreL3L4_==TRUE? 2: (asic_acl.dstFilterIgnoreL4_ == 1? 1: 0)), + asic_acl.dstFilterVlanIdx_, asic_acl.dstFilterVlanIdxMask_, + (asic_acl.dstFilterIgnoreL3L4_==TRUE? 2: (asic_acl.dstFilterIgnoreL4_ == 1? 1: 0)), asic_acl.dstFilterPortLowerBound_, asic_acl.dstFilterPortUpperBound_ ); seq_printf(s, "\tdip: %d.%d.%d.%d dipM: %d.%d.%d.%d\n", (asic_acl.dstFilterIpAddr_>>24), @@ -1957,15 +2123,15 @@ int acl_show(struct seq_file *s, void *v) break; case RTL8652_ACL_DSTFILTER_IPRANGE: seq_printf(s, " [%d] rule type: %s rule action: %s\n", acl_start, "Deatination Filter(IP Range)", actionT[asic_acl.actionType_]); - seq_printf(s, "\tDMAC: %x:%x:%x:%x:%x:%x DMACM: %x:%x:%x:%x:%x:%x\n", - asic_acl.dstFilterMac_.octet[0], asic_acl.dstFilterMac_.octet[1], asic_acl.dstFilterMac_.octet[2], + seq_printf(s, "\tDMAC: %x:%x:%x:%x:%x:%x DMACM: %x:%x:%x:%x:%x:%x\n", + asic_acl.dstFilterMac_.octet[0], asic_acl.dstFilterMac_.octet[1], asic_acl.dstFilterMac_.octet[2], asic_acl.dstFilterMac_.octet[3], asic_acl.dstFilterMac_.octet[4], asic_acl.dstFilterMac_.octet[5], asic_acl.dstFilterMacMask_.octet[0], asic_acl.dstFilterMacMask_.octet[1], asic_acl.dstFilterMacMask_.octet[2], asic_acl.dstFilterMacMask_.octet[3], asic_acl.dstFilterMacMask_.octet[4], asic_acl.dstFilterMacMask_.octet[5] ); seq_printf(s, "\tdvidx: %d dvidxM: %x ProtoType: %x dportL: %d dportU: %d\n", - asic_acl.dstFilterVlanIdx_, asic_acl.dstFilterVlanIdxMask_, - (asic_acl.dstFilterIgnoreL3L4_==TRUE? 2: (asic_acl.dstFilterIgnoreL4_ == 1? 1: 0)), + asic_acl.dstFilterVlanIdx_, asic_acl.dstFilterVlanIdxMask_, + (asic_acl.dstFilterIgnoreL3L4_==TRUE? 2: (asic_acl.dstFilterIgnoreL4_ == 1? 1: 0)), asic_acl.dstFilterPortLowerBound_, asic_acl.dstFilterPortUpperBound_ ); seq_printf(s, "\tdipU: %d.%d.%d.%d dipL: %d.%d.%d.%d\n", (asic_acl.dstFilterIpAddr_>>24), @@ -1983,7 +2149,7 @@ int acl_show(struct seq_file *s, void *v) /* Action type */ - switch (asic_acl.actionType_) + switch (asic_acl.actionType_) { case RTL8651_ACL_PERMIT: /* 0x00 */ @@ -2012,17 +2178,17 @@ int acl_show(struct seq_file *s, void *v) case RTL8651_ACL_LOG_RATE_EXCEED_BPS: /* 0x0d */ seq_printf(s, "\trlIdx: %d ", asic_acl.rlIndex); break; - default: + default: ; - + } seq_printf(s, "pktOpApp: %d\n", asic_acl.pktOpApp); - + } #endif - if (outRule == FALSE) + if (outRule == FALSE) { acl_start = asic_intf.outAclStart; acl_end = asic_intf.outAclEnd; outRule = TRUE; @@ -2030,11 +2196,11 @@ int acl_show(struct seq_file *s, void *v) } } -#if defined (CONFIG_RTL_LOCAL_PUBLIC) ||defined(CONFIG_RTL_MULTIPLE_WAN) +#if defined (CONFIG_RTL_LOCAL_PUBLIC) ||defined(CONFIG_RTL_MULTIPLE_WAN) || defined(CONFIG_RTL_HW_VLAN_SUPPORT) { outRule = FALSE; - rtl865x_getDefACLForNetDecisionMiss(&defInAclStart, &defInAclEnd,&defOutAclStart,&defOutAclEnd); + rtl865x_getDefACLForNetDecisionMiss(&defInAclStart, &defInAclEnd,&defOutAclStart,&defOutAclEnd); acl_start = defInAclStart; acl_end = defInAclEnd; seq_printf(s, "\nacl_start(%d), acl_end(%d)", acl_start, acl_end); again_forOutAcl: @@ -2047,7 +2213,7 @@ again_forOutAcl: { if ( _rtl865x_getAclFromAsic(acl_start, &asic_acl) == FAILED) rtlglue_printf("=============%s(%d): get asic acl rule error!\n",__FUNCTION__, __LINE__); - + switch(asic_acl.ruleType_) { case RTL865X_ACL_MAC: @@ -2059,7 +2225,7 @@ again_forOutAcl: asic_acl.dstMacMask_.octet[0], asic_acl.dstMacMask_.octet[1], asic_acl.dstMacMask_.octet[2], asic_acl.dstMacMask_.octet[3], asic_acl.dstMacMask_.octet[4], asic_acl.dstMacMask_.octet[5] ); - + seq_printf(s, "\tSMAC: %x:%x:%x:%x:%x:%x SMACM: %x:%x:%x:%x:%x:%x\n", asic_acl.srcMac_.octet[0], asic_acl.srcMac_.octet[1], asic_acl.srcMac_.octet[2], asic_acl.srcMac_.octet[3], asic_acl.srcMac_.octet[4], asic_acl.srcMac_.octet[5], @@ -2083,14 +2249,14 @@ again_forOutAcl: seq_printf(s, "\tTos: %x TosM: %x ipProto: %x ipProtoM: %x ipFlag: %x ipFlagM: %x\n", asic_acl.tos_, asic_acl.tosMask_, asic_acl.ipProto_, asic_acl.ipProtoMask_, asic_acl.ipFlag_, asic_acl.ipFlagMask_ ); - + seq_printf(s, "\t<FOP:%x> <FOM:%x> <http:%x> <httpM:%x> <IdentSdip:%x> <IdentSdipM:%x> \n", asic_acl.ipFOP_, asic_acl.ipFOM_, asic_acl.ipHttpFilter_, asic_acl.ipHttpFilterM_, asic_acl.ipIdentSrcDstIp_, asic_acl.ipIdentSrcDstIpM_ ); - seq_printf(s, "\t<DF:%x> <MF:%x>\n", asic_acl.ipDF_, asic_acl.ipMF_); + seq_printf(s, "\t<DF:%x> <MF:%x>\n", asic_acl.ipDF_, asic_acl.ipMF_); break; - + case RTL865X_ACL_IP_RANGE: seq_printf(s, " [%d] rule type: %s rule action: %s\n", acl_start, "IP Range", actionT[asic_acl.actionType_]); seq_printf(s, "\tdipU: %d.%d.%d.%d dipL: %d.%d.%d.%d\n", (asic_acl.dstIpAddr_>>24), @@ -2110,8 +2276,8 @@ again_forOutAcl: asic_acl.ipFOP_, asic_acl.ipFOM_, asic_acl.ipHttpFilter_, asic_acl.ipHttpFilterM_, asic_acl.ipIdentSrcDstIp_, asic_acl.ipIdentSrcDstIpM_ ); - seq_printf(s, "\t<DF:%x> <MF:%x>\n", asic_acl.ipDF_, asic_acl.ipMF_); - break; + seq_printf(s, "\t<DF:%x> <MF:%x>\n", asic_acl.ipDF_, asic_acl.ipMF_); + break; case RTL865X_ACL_ICMP: seq_printf(s, " [%d] rule type: %s rule action: %s\n", acl_start, "ICMP", actionT[asic_acl.actionType_]); seq_printf(s, "\tdip: %d.%d.%d.%d dipM: %d.%d.%d.%d\n", (asic_acl.dstIpAddr_>>24), @@ -2125,7 +2291,7 @@ again_forOutAcl: ((asic_acl.srcIpAddrMask_&0x0000ff00)>>8), (asic_acl.srcIpAddrMask_&0xff) ); seq_printf(s, "\tTos: %x TosM: %x type: %x typeM: %x code: %x codeM: %x\n", - asic_acl.tos_, asic_acl.tosMask_, asic_acl.icmpType_, asic_acl.icmpTypeMask_, + asic_acl.tos_, asic_acl.tosMask_, asic_acl.icmpType_, asic_acl.icmpTypeMask_, asic_acl.icmpCode_, asic_acl.icmpCodeMask_); break; case RTL865X_ACL_ICMP_IPRANGE: @@ -2141,7 +2307,7 @@ again_forOutAcl: ((asic_acl.srcIpAddrMask_&0x0000ff00)>>8), (asic_acl.srcIpAddrMask_&0xff) ); seq_printf(s, "\tTos: %x TosM: %x type: %x typeM: %x code: %x codeM: %x\n", - asic_acl.tos_, asic_acl.tosMask_, asic_acl.icmpType_, asic_acl.icmpTypeMask_, + asic_acl.tos_, asic_acl.tosMask_, asic_acl.icmpType_, asic_acl.icmpTypeMask_, asic_acl.icmpCode_, asic_acl.icmpCodeMask_); break; case RTL865X_ACL_IGMP: @@ -2238,7 +2404,7 @@ again_forOutAcl: asic_acl.tos_, asic_acl.tosMask_, asic_acl.udpSrcPortLB_, asic_acl.udpSrcPortUB_, asic_acl.udpDstPortLB_, asic_acl.udpDstPortUB_ ); - break; + break; case RTL865X_ACL_UDP_IPRANGE: seq_printf(s, " [%d] rule type: %s rule action: %s\n", acl_start, "UDP IP RANGE", actionT[asic_acl.actionType_]); seq_printf(s, "\tdipU: %d.%d.%d.%d dipL: %d.%d.%d.%d\n", (asic_acl.dstIpAddr_>>24), @@ -2255,13 +2421,13 @@ again_forOutAcl: asic_acl.tos_, asic_acl.tosMask_, asic_acl.udpSrcPortLB_, asic_acl.udpSrcPortUB_, asic_acl.udpDstPortLB_, asic_acl.udpDstPortUB_ ); - break; + break; + - case RTL865X_ACL_SRCFILTER: seq_printf(s, " [%d] rule type: %s rule action: %s\n", acl_start, "Source Filter", actionT[asic_acl.actionType_]); - seq_printf(s, "\tSMAC: %x:%x:%x:%x:%x:%x SMACM: %x:%x:%x:%x:%x:%x\n", - asic_acl.srcFilterMac_.octet[0], asic_acl.srcFilterMac_.octet[1], asic_acl.srcFilterMac_.octet[2], + seq_printf(s, "\tSMAC: %x:%x:%x:%x:%x:%x SMACM: %x:%x:%x:%x:%x:%x\n", + asic_acl.srcFilterMac_.octet[0], asic_acl.srcFilterMac_.octet[1], asic_acl.srcFilterMac_.octet[2], asic_acl.srcFilterMac_.octet[3], asic_acl.srcFilterMac_.octet[4], asic_acl.srcFilterMac_.octet[5], asic_acl.srcFilterMacMask_.octet[0], asic_acl.srcFilterMacMask_.octet[1], asic_acl.srcFilterMacMask_.octet[2], asic_acl.srcFilterMacMask_.octet[3], asic_acl.srcFilterMacMask_.octet[4], asic_acl.srcFilterMacMask_.octet[5] @@ -2281,8 +2447,8 @@ again_forOutAcl: case RTL865X_ACL_SRCFILTER_IPRANGE: seq_printf(s, " [%d] rule type: %s rule action: %s\n", acl_start, "Source Filter(IP RANGE)", actionT[asic_acl.actionType_]); - seq_printf(s, "\tSMAC: %x:%x:%x:%x:%x:%x SMACM: %x:%x:%x:%x:%x:%x\n", - asic_acl.srcFilterMac_.octet[0], asic_acl.srcFilterMac_.octet[1], asic_acl.srcFilterMac_.octet[2], + seq_printf(s, "\tSMAC: %x:%x:%x:%x:%x:%x SMACM: %x:%x:%x:%x:%x:%x\n", + asic_acl.srcFilterMac_.octet[0], asic_acl.srcFilterMac_.octet[1], asic_acl.srcFilterMac_.octet[2], asic_acl.srcFilterMac_.octet[3], asic_acl.srcFilterMac_.octet[4], asic_acl.srcFilterMac_.octet[5], asic_acl.srcFilterMacMask_.octet[0], asic_acl.srcFilterMacMask_.octet[1], asic_acl.srcFilterMacMask_.octet[2], asic_acl.srcFilterMacMask_.octet[3], asic_acl.srcFilterMacMask_.octet[4], asic_acl.srcFilterMacMask_.octet[5] @@ -2302,15 +2468,15 @@ again_forOutAcl: case RTL865X_ACL_DSTFILTER: seq_printf(s, " [%d] rule type: %s rule action: %s\n", acl_start, "Deatination Filter", actionT[asic_acl.actionType_]); - seq_printf(s, "\tDMAC: %x:%x:%x:%x:%x:%x DMACM: %x:%x:%x:%x:%x:%x\n", - asic_acl.dstFilterMac_.octet[0], asic_acl.dstFilterMac_.octet[1], asic_acl.dstFilterMac_.octet[2], + seq_printf(s, "\tDMAC: %x:%x:%x:%x:%x:%x DMACM: %x:%x:%x:%x:%x:%x\n", + asic_acl.dstFilterMac_.octet[0], asic_acl.dstFilterMac_.octet[1], asic_acl.dstFilterMac_.octet[2], asic_acl.dstFilterMac_.octet[3], asic_acl.dstFilterMac_.octet[4], asic_acl.dstFilterMac_.octet[5], asic_acl.dstFilterMacMask_.octet[0], asic_acl.dstFilterMacMask_.octet[1], asic_acl.dstFilterMacMask_.octet[2], asic_acl.dstFilterMacMask_.octet[3], asic_acl.dstFilterMacMask_.octet[4], asic_acl.dstFilterMacMask_.octet[5] ); seq_printf(s, "\tdvidx: %d dvidxM: %x ProtoType: %x dportL: %d dportU: %d\n", - asic_acl.dstFilterVlanIdx_, asic_acl.dstFilterVlanIdxMask_, - (asic_acl.dstFilterIgnoreL3L4_==TRUE? 2: (asic_acl.dstFilterIgnoreL4_ == 1? 1: 0)), + asic_acl.dstFilterVlanIdx_, asic_acl.dstFilterVlanIdxMask_, + (asic_acl.dstFilterIgnoreL3L4_==TRUE? 2: (asic_acl.dstFilterIgnoreL4_ == 1? 1: 0)), asic_acl.dstFilterPortLowerBound_, asic_acl.dstFilterPortUpperBound_ ); seq_printf(s, "\tdip: %d.%d.%d.%d dipM: %d.%d.%d.%d\n", (asic_acl.dstFilterIpAddr_>>24), @@ -2322,15 +2488,15 @@ again_forOutAcl: break; case RTL865X_ACL_DSTFILTER_IPRANGE: seq_printf(s, " [%d] rule type: %s rule action: %s\n", acl_start, "Deatination Filter(IP Range)", actionT[asic_acl.actionType_]); - seq_printf(s, "\tDMAC: %x:%x:%x:%x:%x:%x DMACM: %x:%x:%x:%x:%x:%x\n", - asic_acl.dstFilterMac_.octet[0], asic_acl.dstFilterMac_.octet[1], asic_acl.dstFilterMac_.octet[2], + seq_printf(s, "\tDMAC: %x:%x:%x:%x:%x:%x DMACM: %x:%x:%x:%x:%x:%x\n", + asic_acl.dstFilterMac_.octet[0], asic_acl.dstFilterMac_.octet[1], asic_acl.dstFilterMac_.octet[2], asic_acl.dstFilterMac_.octet[3], asic_acl.dstFilterMac_.octet[4], asic_acl.dstFilterMac_.octet[5], asic_acl.dstFilterMacMask_.octet[0], asic_acl.dstFilterMacMask_.octet[1], asic_acl.dstFilterMacMask_.octet[2], asic_acl.dstFilterMacMask_.octet[3], asic_acl.dstFilterMacMask_.octet[4], asic_acl.dstFilterMacMask_.octet[5] ); seq_printf(s, "\tdvidx: %d dvidxM: %x ProtoType: %x dportL: %d dportU: %d\n", - asic_acl.dstFilterVlanIdx_, asic_acl.dstFilterVlanIdxMask_, - (asic_acl.dstFilterIgnoreL3L4_==TRUE? 2: (asic_acl.dstFilterIgnoreL4_ == 1? 1: 0)), + asic_acl.dstFilterVlanIdx_, asic_acl.dstFilterVlanIdxMask_, + (asic_acl.dstFilterIgnoreL3L4_==TRUE? 2: (asic_acl.dstFilterIgnoreL4_ == 1? 1: 0)), asic_acl.dstFilterPortLowerBound_, asic_acl.dstFilterPortUpperBound_ ); seq_printf(s, "\tdipU: %d.%d.%d.%d dipL: %d.%d.%d.%d\n", (asic_acl.dstFilterIpAddr_>>24), @@ -2348,7 +2514,7 @@ again_forOutAcl: /* Action type */ - switch (asic_acl.actionType_) + switch (asic_acl.actionType_) { case RTL865X_ACL_PERMIT: @@ -2363,10 +2529,10 @@ again_forOutAcl: seq_printf(s, "\tnetifIdx: %d pppoeIdx: %d l2Idx:%d ", asic_acl.netifIdx_, asic_acl.pppoeIdx_, asic_acl.L2Idx_); break; - case RTL865X_ACL_PRIORITY: + case RTL865X_ACL_PRIORITY: seq_printf(s, "\tprioirty: %d ", asic_acl.priority_) ; break; - + case RTL865X_ACL_DEFAULT_REDIRECT: seq_printf(s,"\tnextHop:%d ", asic_acl.nexthopIdx_); break; @@ -2377,15 +2543,15 @@ again_forOutAcl: case RTL865X_ACL_LOG_RATE_EXCEED_BPS: seq_printf(s, "\tratelimitIdx: %d ", asic_acl.ratelimtIdx_); break; - default: + default: ; - + } seq_printf(s, "pktOpApp: %d\n", asic_acl.pktOpApp_); - + } - if (outRule == FALSE) + if (outRule == FALSE) { acl_start = defOutAclStart; acl_end = defOutAclEnd; outRule = TRUE; @@ -2408,6 +2574,7 @@ struct file_operations acl_single_seq_file_operations = { .release = single_release, }; +#if defined(CONFIG_RTL_IGMP_SNOOPING) extern int igmp_show(struct seq_file *s, void *v); extern int igmp_write(struct file *file, const char __user *buffer, size_t count, loff_t *data); int igmp_single_open(struct inode *inode, struct file *file) @@ -2422,6 +2589,7 @@ struct file_operations igmp_single_seq_file_operations = { .llseek = seq_lseek, .release = single_release, }; +#endif #ifdef CONFIG_RTL_LAYERED_DRIVER int aclChains_show(struct seq_file *s, void *v) @@ -2468,7 +2636,7 @@ struct file_operations qosRule_single_seq_file_operations = { static int32 hs_read( char *page, char **start, off_t off, int count, int *eof, void *data ) { - int len; + int len; hsb_param_t *hsb_r, dummy_hsb_r; hsa_param_t *hsa_r, dummy_hsa_r; ipaddr_t addr; @@ -2479,48 +2647,48 @@ static int32 hs_read( char *page, char **start, off_t off, int count, int *eof, hsa_r = &dummy_hsa_r; memset((void*)hsb_r,0,sizeof(hsb_r)); memset((void*)hsa_r,0,sizeof(hsa_r)); - + virtualMacGetHsb( hsb_r ); { len += sprintf(page+len,"HSB("); len += sprintf(page+len,"\ttype:%d",hsb_r->type); - + len += sprintf(page+len,"\tspa:%d",hsb_r->spa); len += sprintf(page+len,"\tlen:%d",hsb_r->len); len += sprintf(page+len,"\tvid :%d\n",hsb_r->vid); len += sprintf(page+len,"\tpppoe:%d",hsb_r->pppoeif); - + /* Protocol contents */ len += sprintf(page+len,"\ttagif:%d\tpppoeId:%d",hsb_r->tagif,hsb_r->pppoeid); len += sprintf(page+len,"\tethrtype:0x%04x\n",hsb_r->ethtype); len += sprintf(page+len,"\tllc_other:%d\tsnap:%d\n",hsb_r->llcothr,hsb_r->snap); len += sprintf(page+len,"\tda:%02x-%02x-%02x-%02x-%02x-%02x",hsb_r->da[0],hsb_r->da[1],hsb_r->da[2],hsb_r->da[3],hsb_r->da[4],hsb_r->da[5]); len += sprintf(page+len,"\tsa:%02x-%02x-%02x-%02x-%02x-%02x\n",hsb_r->sa[0],hsb_r->sa[1],hsb_r->sa[2],hsb_r->sa[3],hsb_r->sa[4],hsb_r->sa[5]); - + addr = ntohl( hsb_r->sip); inet_ntoa_r(addr, addr_s); len += sprintf(page+len,"\tsip:%s(hex:%08x) ",addr_s,hsb_r->sip); len += sprintf(page+len,"\tsprt:%d (hex:%x)\n ",(int)hsb_r->sprt,hsb_r->sprt); addr = ntohl(hsb_r->dip); inet_ntoa_r(addr, addr_s); - len += sprintf(page+len,"\tdip:%s(hex:%08x) ",addr_s,hsb_r->dip);; + len += sprintf(page+len,"\tdip:%s(hex:%08x) ",addr_s,hsb_r->dip);; len += sprintf(page+len,"\tdprt:%d(hex:%08x)\n",hsb_r->dprt,hsb_r->dprt); - + len += sprintf(page+len,"\tipptl:%d,",(int)hsb_r->ipptl); len += sprintf(page+len,"\tipflg:%d,",hsb_r->ipfg); len += sprintf(page+len,"\tiptos:%d,",hsb_r->iptos); len += sprintf(page+len,"\ttcpflg:%d\n",hsb_r->tcpfg); - + len += sprintf(page+len,"\tdirtx:%d,",hsb_r->dirtx); len += sprintf(page+len,"\tprtnmat:%d",hsb_r->patmatch); - + len += sprintf(page+len,"\tudp_nocs:%d",hsb_r->udpnocs); len += sprintf(page+len,"\tttlst:0x%x\n",hsb_r->ttlst); - + len += sprintf(page+len,"\thp:%d",hsb_r->hiprior); len += sprintf(page+len,"\tl3csok:%d\tl4csok:%d\tipfragif:%d\n",hsb_r->l3csok,hsb_r->l4csok,hsb_r->ipfo0_n); - + len += sprintf(page+len,"\textspa:%d",hsb_r->extspa); len += sprintf(page+len,"\turlmch:%d\n)\n",hsb_r->urlmch); } @@ -2532,7 +2700,7 @@ static int32 hs_read( char *page, char **start, off_t off, int count, int *eof, addr =ntohl( hsa_r->trip); inet_ntoa_r(addr, addr_s); - len += sprintf(page+len,"\ttrip:%s(hex:%08x)",addr_s,hsa_r->trip); + len += sprintf(page+len,"\ttrip:%s(hex:%08x)",addr_s,hsa_r->trip); len += sprintf(page+len,"\tprt:%d\tipmcast:%d\n",hsa_r->port,hsa_r->ipmcastr); len += sprintf(page+len,"\tl3cs:%d",hsa_r->l3csdt); len += sprintf(page+len,"\tl4cs:%d",hsa_r->l4csdt); @@ -2566,7 +2734,7 @@ static int32 hs_read( char *page, char **start, off_t off, int count, int *eof, len += sprintf(page+len,"\tdpext:0x%x\thwfwrd:%d\n",hsa_r->dpext,hsa_r->hwfwrd); len += sprintf(page+len,"\tspcp:%d",hsa_r->spcp); len += sprintf(page+len,"\tpriority:%d",hsa_r->priority); - + len += sprintf(page+len,"\tdp:0x%x\n",hsa_r->dp); len += sprintf(page+len,")\n"); } @@ -2694,9 +2862,53 @@ static int32 pvid_read( char *page, char **start, off_t off, int count, int *eof static int32 pvid_write( struct file *filp, const char *buff,unsigned long len, void *data ) { - return SUCCESS; + char tmpbuf[256]; + char *strptr; + char *tokptr; + uint32 port=0; + uint32 pvid=0; + if (buff && !copy_from_user(tmpbuf, buff, len)) + { + strptr = tmpbuf; + + tokptr = strsep(&strptr," "); + if (tokptr==NULL) + { + goto errout; + } + + port=simple_strtol(tokptr, NULL, 0); + + if(port>(RTL8651_PORT_NUMBER+rtl8651_totalExtPortNum)) + { + goto errout; + } + + tokptr = strsep(&strptr," "); + if (tokptr==NULL) + { + goto errout; + } + + pvid=simple_strtol(tokptr, NULL, 0); + + if(pvid>4096) + { + goto errout; + } + + rtl8651_setAsicPvid( port, pvid); + + return len; + errout: + rtlglue_printf("wrong format\n"); + + } + + return len; } + static int32 mirrorPort_read( char *page, char **start, off_t off, int count, int *eof, void *data ) { uint32 mirrorRx, mirrorTx, mirrorPort; @@ -2727,6 +2939,10 @@ static int32 mirrorPort_write( struct file *filp, const char *buff,unsigned long uint32 rx_mask,tx_mask,port_mask; char *strptr, *cmd_addr; char *tokptr; + if(len>64) + { + goto errout; + } if (buff && !copy_from_user(tmpbuf, buff, len)) { tmpbuf[len] = '\0'; @@ -2736,7 +2952,7 @@ static int32 mirrorPort_write( struct file *filp, const char *buff,unsigned long { goto errout; } - printk("cmd %s\n", cmd_addr); + rtlglue_printf("cmd %s\n", cmd_addr); tokptr = strsep(&strptr," "); if (tokptr==NULL) { @@ -2753,81 +2969,15 @@ static int32 mirrorPort_write( struct file *filp, const char *buff,unsigned long goto errout; } tx_mask = simple_strtol(tokptr,NULL,0); - + tokptr = strsep(&strptr," "); if (tokptr==NULL) { goto errout; } port_mask = simple_strtol(tokptr, NULL, 0); - printk("mirror rx port mask(0x%x) tx port mask(0x%x), mirror port mask(0x%x)\n",rx_mask,tx_mask,port_mask); + rtlglue_printf("mirror rx port mask(0x%x) tx port mask(0x%x), mirror port mask(0x%x)\n",rx_mask,tx_mask,port_mask); rtl8651_setAsicPortMirror(rx_mask,tx_mask,port_mask); - } - else - { - goto errout; - } - } - else - { -errout: - printk("Mirror port configuration only support \"mirror\"as the first parameter\n"); - printk("mirror: \"mirror rx_portmask tx_portmask mirror_portmask\"\n"); - } - - return len; -} - - -static int32 proc_mem_read( char *page, char **start, off_t off, int count, int *eof, void *data ) -{ - return PROC_READ_RETURN_VALUE; -} - -static int32 proc_mem_write( struct file *filp, const char *buff,unsigned long len, void *data ) -{ - char tmpbuf[64]; - uint32 *mem_addr, mem_data, mem_len; - char *strptr, *cmd_addr; - char *tokptr; - - if (buff && !copy_from_user(tmpbuf, buff, len)) { - tmpbuf[len] = '\0'; - strptr=tmpbuf; - cmd_addr = strsep(&strptr," "); - if (cmd_addr==NULL) - { - goto errout; - } - printk("cmd %s\n", cmd_addr); - tokptr = strsep(&strptr," "); - if (tokptr==NULL) - { - goto errout; - } - - if (!memcmp(cmd_addr, "read", 4)) - { - mem_addr=(uint32*)simple_strtol(tokptr, NULL, 0); - tokptr = strsep(&strptr," "); - if (tokptr==NULL) - { - goto errout; - } - mem_len=simple_strtol(tokptr, NULL, 0); - memDump(mem_addr, mem_len, ""); - } - else if (!memcmp(cmd_addr, "write", 5)) - { - mem_addr=(uint32*)simple_strtol(tokptr, NULL, 0); - tokptr = strsep(&strptr," "); - if (tokptr==NULL) - { - goto errout; - } - mem_data=simple_strtol(tokptr, NULL, 0); - WRITE_MEM32(mem_addr, mem_data); - printk("Write memory 0x%p dat 0x%x: 0x%x\n", mem_addr, mem_data, READ_MEM32(mem_addr)); } else { @@ -2837,9 +2987,8 @@ static int32 proc_mem_write( struct file *filp, const char *buff,unsigned long l else { errout: - printk("Memory operation only support \"read\" and \"write\" as the first parameter\n"); - printk("Read format: \"read mem_addr length\"\n"); - printk("Write format: \"write mem_addr mem_data\"\n"); + rtlglue_printf("Mirror port configuration only support \"mirror\"as the first parameter\n"); + rtlglue_printf("mirror: \"mirror rx_portmask tx_portmask mirror_portmask\"\n"); } return len; @@ -2851,7 +3000,7 @@ static int32 l2_read( char *page, char **start, off_t off, int count, int *eof, int len; rtl865x_tblAsicDrv_l2Param_t asic_l2; uint32 row, col, port, m=0; - + len = sprintf(page, "%s\n", "ASIC L2 Table:"); for(row=0x0; row<RTL8651_L2TBL_ROW; row++) { @@ -2862,14 +3011,14 @@ static int32 l2_read( char *page, char **start, off_t off, int count, int *eof, { continue; } - + if (asic_l2.isStatic && asic_l2.ageSec==0 && asic_l2.cpu && asic_l2.memberPortMask == 0 &&asic_l2.auth==0) { continue; } - len += sprintf(page + len, "%4d.[%3d,%d] %02x:%02x:%02x:%02x:%02x:%02x FID:%x mbr(",m, row, col, - asic_l2.macAddr.octet[0], asic_l2.macAddr.octet[1], asic_l2.macAddr.octet[2], + len += sprintf(page + len, "%4d.[%3d,%d] %02x:%02x:%02x:%02x:%02x:%02x FID:%x mbr(",m, row, col, + asic_l2.macAddr.octet[0], asic_l2.macAddr.octet[1], asic_l2.macAddr.octet[2], asic_l2.macAddr.octet[3], asic_l2.macAddr.octet[4], asic_l2.macAddr.octet[5],asic_l2.fid ); @@ -2894,7 +3043,7 @@ static int32 l2_read( char *page, char **start, off_t off, int count, int *eof, { len += sprintf(page + len,"AUTH:0"); } - + len += sprintf(page + len,"\n"); } } @@ -2916,62 +3065,64 @@ static int32 rtl865x_proc_hw_mcast_read( char *page, char **start, off_t off, in int len=0; rtl865x_tblAsicDrv_multiCastParam_t asic; uint32 entry; - + #if 1 - printk("%s\n", "ASIC Multicast Table:"); - for(entry=0; entry<RTL8651_MULTICASTTBL_SIZE; entry++) + rtlglue_printf("%s\n", "ASIC Multicast Table:"); + for(entry=0; entry<RTL8651_MULTICASTTBL_SIZE; entry++) { if (rtl8651_getAsicIpMulticastTable(entry, &asic) != SUCCESS) { - printk("\t[%d] (INVALID)dip(%d.%d.%d.%d) sip(%d.%d.%d.%d) mbr(0x%x)\n", entry, - asic.dip>>24, (asic.dip&0x00ff0000)>>16, (asic.dip&0x0000ff00)>>8, (asic.dip&0xff), + #if 0 + rtlglue_printf("\t[%d] (INVALID)dip(%d.%d.%d.%d) sip(%d.%d.%d.%d) mbr(0x%x)\n", entry, + asic.dip>>24, (asic.dip&0x00ff0000)>>16, (asic.dip&0x0000ff00)>>8, (asic.dip&0xff), asic.sip>>24, (asic.sip&0x00ff0000)>>16, (asic.sip&0x0000ff00)>>8, (asic.sip&0xff), asic.mbr); - printk("\t svid:%d, spa:%d, extIP:%d, age:%d, cpu:%d\n", asic.svid, asic.port, asic.extIdx, + rtlglue_printf("\t svid:%d, spa:%d, extIP:%d, age:%d, cpu:%d\n", asic.svid, asic.port, asic.extIdx, asic.age, asic.cpu); + #endif continue; } else { - printk("\t[%d] (OK)dip(%d.%d.%d.%d) sip(%d.%d.%d.%d) mbr(0x%x)\n", entry, - asic.dip>>24, (asic.dip&0x00ff0000)>>16, (asic.dip&0x0000ff00)>>8, (asic.dip&0xff), + rtlglue_printf("\t[%d] (OK)dip(%d.%d.%d.%d) sip(%d.%d.%d.%d) mbr(0x%x)\n", entry, + asic.dip>>24, (asic.dip&0x00ff0000)>>16, (asic.dip&0x0000ff00)>>8, (asic.dip&0xff), asic.sip>>24, (asic.sip&0x00ff0000)>>16, (asic.sip&0x0000ff00)>>8, (asic.sip&0xff), asic.mbr); - printk("\t svid:%d, spa:%d, extIP:%d, age:%d, cpu:%d\n", asic.svid, asic.port, asic.extIdx, + rtlglue_printf("\t svid:%d, spa:%d, extIP:%d, age:%d, cpu:%d\n", asic.svid, asic.port, asic.extIdx, asic.age, asic.cpu); } } - printk("\n\t TotalOpCnt:AddMcastOpCnt:%d\tDelMcastOpCnt:%d\tForceAddMcastOpCnt:%d\t \n", _rtl865x_getAddMcastOpCnt(),_rtl865x_getDelMcastOpCnt(),_rtl865x_getForceAddMcastOpCnt()); + rtlglue_printf("\n\t TotalOpCnt:AddMcastOpCnt:%d\tDelMcastOpCnt:%d\tForceAddMcastOpCnt:%d\t \n", _rtl865x_getAddMcastOpCnt(),_rtl865x_getDelMcastOpCnt(),_rtl865x_getForceAddMcastOpCnt()); #else len = sprintf(page, "%s\n", "ASIC Multicast Table:"); - for(entry=0; entry<RTL8651_MULTICASTTBL_SIZE; entry++) + for(entry=0; entry<RTL8651_MULTICASTTBL_SIZE; entry++) { if (rtl8651_getAsicIpMulticastTable(entry, &asic) != SUCCESS) { len +=sprintf(page+len,"\t[%d] (Invalid Entry)\n", entry); continue; } len += sprintf(page+len, "\t[%d] dip(%d.%d.%d.%d) sip(%d.%d.%d.%d) mbr(%x)\n", entry, - asic.dip>>24, (asic.dip&0x00ff0000)>>16, (asic.dip&0x0000ff00)>>8, (asic.dip&0xff), + asic.dip>>24, (asic.dip&0x00ff0000)>>16, (asic.dip&0x0000ff00)>>8, (asic.dip&0xff), asic.sip>>24, (asic.sip&0x00ff0000)>>16, (asic.sip&0x0000ff00)>>8, (asic.sip&0xff), asic.mbr); len +=sprintf(page+len,"\t svid:%d, spa:%d, extIP:%d, age:%d, cpu:%d\n", asic.svid, asic.port, asic.extIdx, asic.age, asic.cpu); } #endif - - if (len <= off+count) + + if (len <= off+count) { *eof = 1; } - + *start = page + off; len -= off; - + if (len>count) { len = count; } - + if (len<0) { len = 0; @@ -2986,19 +3137,23 @@ static int32 rtl865x_proc_hw_mcast_write( struct file *filp, const char *buff,un char *strptr; char *tokptr; char *dotPtr; - rtl865xc_tblAsic_ipMulticastTable_t entry; + rtl865xc_tblAsic_ipMulticastTable_t entry; int16 age; uint32 idx; uint32 sip,dip; uint32 srcPort,svid,mbr; int32 i; - + if(len>512) + { + goto errout; + } + if (buff && !copy_from_user(tmpbuf, buff, len)) { bzero(&entry, sizeof(entry)); tmpbuf[len] = '\0'; - + strptr=tmpbuf; /*valid*/ @@ -3008,7 +3163,7 @@ static int32 rtl865x_proc_hw_mcast_write( struct file *filp, const char *buff,un goto errout; } entry.valid = simple_strtol(tokptr, NULL, 0); - + /*destination ip*/ tokptr = strsep(&strptr," "); if (tokptr==NULL) @@ -3026,17 +3181,17 @@ static int32 rtl865x_proc_hw_mcast_write( struct file *filp, const char *buff,un } dip=(dip<<8)|simple_strtol(dotPtr, NULL, 0); } - + entry.destIPAddrLsbs= dip & 0xfffffff; - - + + /*source ip*/ tokptr = strsep(&strptr," "); if (tokptr==NULL) { goto errout; } - + sip=0; for(i=0;i<4;i++) { @@ -3047,10 +3202,10 @@ static int32 rtl865x_proc_hw_mcast_write( struct file *filp, const char *buff,un } sip=(sip<<8)|simple_strtol(dotPtr, NULL, 0); } - + entry.srcIPAddr=sip; - - + + /*mbr*/ tokptr = strsep(&strptr," "); if (tokptr==NULL) @@ -3059,7 +3214,7 @@ static int32 rtl865x_proc_hw_mcast_write( struct file *filp, const char *buff,un } mbr= simple_strtol(tokptr, NULL, 0); entry.portList = mbr & (RTL8651_PHYSICALPORTMASK); -#if defined (CONFIG_RTL8196C_REVISION_B) || defined (CONFIG_RTL8198_REVISION_B) +#if defined (CONFIG_RTL8196C_REVISION_B) || defined (CONFIG_RTL8198_REVISION_B) || defined(CONFIG_RTL_819XD) || defined(CONFIG_RTL_8196E) #else entry.extPortList = mbr >> RTL8651_PORT_NUMBER; #endif @@ -3071,7 +3226,7 @@ static int32 rtl865x_proc_hw_mcast_write( struct file *filp, const char *buff,un goto errout; } svid= simple_strtol(tokptr, NULL, 0); -#if defined (CONFIG_RTL8196C_REVISION_B) || defined (CONFIG_RTL8198_REVISION_B) +#if defined (CONFIG_RTL8196C_REVISION_B) || defined (CONFIG_RTL8198_REVISION_B) || defined(CONFIG_RTL_819XD) || defined(CONFIG_RTL_8196E) #else entry.srcVidH = ((svid)>>4) &0xff; entry.srcVidL = (svid)&0xf; @@ -3082,19 +3237,19 @@ static int32 rtl865x_proc_hw_mcast_write( struct file *filp, const char *buff,un if (tokptr==NULL) { goto errout; - } + } srcPort= simple_strtol(tokptr, NULL, 0); -#if defined (CONFIG_RTL8196C_REVISION_B) || defined (CONFIG_RTL8198_REVISION_B) +#if defined (CONFIG_RTL8196C_REVISION_B) || defined (CONFIG_RTL8198_REVISION_B) || defined(CONFIG_RTL_819XD) || defined(CONFIG_RTL_8196E) #else - if (srcPort>= RTL8651_PORT_NUMBER) + if (srcPort>= RTL8651_PORT_NUMBER) { /* extension port */ entry.srcPortExt = 1; entry.srcPort = (srcPort-RTL8651_PORT_NUMBER); } - else + else { entry.srcPortExt = 0; entry.srcPort = srcPort; @@ -3107,7 +3262,7 @@ static int32 rtl865x_proc_hw_mcast_write( struct file *filp, const char *buff,un goto errout; } entry.extIPIndex = simple_strtol(tokptr, NULL, 0); - + /*age*/ tokptr = strsep(&strptr," "); if (tokptr==NULL) @@ -3115,8 +3270,8 @@ static int32 rtl865x_proc_hw_mcast_write( struct file *filp, const char *buff,un goto errout; } age=simple_strtol(tokptr, NULL, 0); - - + + entry.ageTime = 0; while ( age > 0 ) { @@ -3135,13 +3290,13 @@ static int32 rtl865x_proc_hw_mcast_write( struct file *filp, const char *buff,un idx = rtl8651_ipMulticastTableIndex(sip,dip); _rtl8651_forceAddAsicEntry(TYPE_MULTICAST_TABLE, idx, &entry); - - + + } else { errout: - printk("error input\n"); + rtlglue_printf("error input\n"); } return len; @@ -3150,15 +3305,15 @@ errout: static int32 rtl865x_proc_sw_mcast_read( char *page, char **start, off_t off, int count, int *eof, void *data ) { int len=0; - + rtl_dumpSwMulticastInfo(); - + return len; } static int32 rtl865x_proc_sw_mcast_write( struct file *filp, const char *buff,unsigned long len, void *data ) { - + return len; } #endif @@ -3170,18 +3325,18 @@ static int32 arp_read( char *page, char **start, off_t off, int count, int *eof, rtl865x_tblAsicDrv_routingParam_t asic_l3; rtl865x_tblAsicDrv_arpParam_t asic_arp; rtl865x_tblAsicDrv_l2Param_t asic_l2; - + uint32 i, j, port; ipaddr_t ipAddr; int8 ipBuf[sizeof"255.255.255.255"]; - + len = sprintf(page, "%s\n", "ASIC Arp Table:\n"); - for(i=0; i<RTL8651_ARPTBL_SIZE; i++) + for(i=0; i<RTL8651_ARPTBL_SIZE; i++) { if (rtl8651_getAsicArp(i, &asic_arp) == FAILED) continue; - for(j=0; j<RTL8651_ROUTINGTBL_SIZE; j++) + for(j=0; j<RTL8651_ROUTINGTBL_SIZE; j++) { if (rtl8651_getAsicRouting(j, &asic_l3) == FAILED || asic_l3.process!= 0x02 /*RT_ARP*/) continue; @@ -3193,7 +3348,7 @@ static int32 arp_read( char *page, char **start, off_t off, int count, int *eof, inet_ntoa_r(ipAddr, ipBuf); len += sprintf(page + len,"%-16s [%3d,%d] ", ipBuf, asic_arp.nextHopRow, asic_arp.nextHopColumn); } - else + else { inet_ntoa_r(ipAddr, ipBuf); len += sprintf(page + len,"%-16s %02x-%02x-%02x-%02x-%02x-%02x (", ipBuf, asic_l2.macAddr.octet[0], asic_l2.macAddr.octet[1], asic_l2.macAddr.octet[2], asic_l2.macAddr.octet[3], asic_l2.macAddr.octet[4], asic_l2.macAddr.octet[5]); @@ -3202,7 +3357,7 @@ static int32 arp_read( char *page, char **start, off_t off, int count, int *eof, len += sprintf(page + len,"%d ", port); else len += sprintf(page + len," "); - } + } len += sprintf(page + len,") %us", asic_l2.ageSec); } continue; @@ -3213,7 +3368,7 @@ static int32 arp_read( char *page, char **start, off_t off, int count, int *eof, } - return len; + return len; } static int32 arp_write( struct file *filp, const char *buff,unsigned long len, void *data ) @@ -3223,7 +3378,7 @@ static int32 arp_write( struct file *filp, const char *buff,unsigned long len, v static int32 nexthop_read( char *page, char **start, off_t off, int count, int *eof, void *data ) { - int len; + int len; rtl865x_tblAsicDrv_nextHopParam_t asic_nxthop; uint32 idx, refcnt, rt_flag; @@ -3234,7 +3389,7 @@ static int32 nexthop_read( char *page, char **start, off_t off, int count, int * if (rtl8651_getAsicNextHopTable(idx, &asic_nxthop) == FAILED) continue; len += sprintf(page + len," [%d] type(%s) IPIdx(%d) dstVid(%d) pppoeIdx(%d) nextHop(%d) rf(%d) rt(%d)\n", idx, - (asic_nxthop.isPppoe==TRUE? "pppoe": "ethernet"), asic_nxthop.extIntIpIdx, + (asic_nxthop.isPppoe==TRUE? "pppoe": "ethernet"), asic_nxthop.extIntIpIdx, asic_nxthop.dvid, asic_nxthop.pppoeIdx, (asic_nxthop.nextHopRow<<2)+asic_nxthop.nextHopColumn, refcnt, rt_flag); } @@ -3248,7 +3403,7 @@ static int32 nexthop_write( struct file *filp, const char *buff,unsigned long le static int32 l3_read( char *page, char **start, off_t off, int count, int *eof, void *data ) { - int len; + int len; rtl865x_tblAsicDrv_routingParam_t asic_l3; int8 *str[] = { "PPPoE", "L2", "ARP", " ", "CPU", "NxtHop", "DROP", " " }; int8 *strNetType[] = { "WAN", "DMZ", "LAN", "RLAN"}; @@ -3269,15 +3424,15 @@ static int32 l3_read( char *page, char **start, off_t off, int count, int *eof, mask--; netIdx = asic_l3.internal<<1|asic_l3.DMZFlag; len += sprintf(page + len,"\t[%d] %d.%d.%d.%d/%d process(%s) %s \n", idx, (asic_l3.ipAddr>>24), - ((asic_l3.ipAddr&0x00ff0000)>>16), ((asic_l3.ipAddr&0x0000ff00)>>8), (asic_l3.ipAddr&0xff), + ((asic_l3.ipAddr&0x00ff0000)>>16), ((asic_l3.ipAddr&0x0000ff00)>>8), (asic_l3.ipAddr&0xff), mask, str[asic_l3.process],strNetType[netIdx]); - - switch(asic_l3.process) + + switch(asic_l3.process) { case 0x00: /* PPPoE */ len += sprintf(page + len,"\t dvidx(%d) pppidx(%d) nxthop(%d)\n", asic_l3.vidx, asic_l3.pppoeIdx, (asic_l3.nextHopRow<<2)+asic_l3.nextHopColumn); break; - + case 0x01: /* L2 */ len += sprintf(page + len," dvidx(%d) nexthop(%d)\n", asic_l3.vidx, (asic_l3.nextHopRow<<2)+asic_l3.nextHopColumn); break; @@ -3304,7 +3459,7 @@ static int32 l3_read( char *page, char **start, off_t off, int count, int *eof, case 0x07: /* Reserved */ /* pass through */ - default: + default: ; } } @@ -3336,7 +3491,7 @@ static int32 ip_read( char *page, char **start, off_t off, int count, int *eof, continue; } inet_ntoa_r(asic_ip.intIpAddr, intIpBuf); - inet_ntoa_r(asic_ip.extIpAddr,extIpBuf); + inet_ntoa_r(asic_ip.extIpAddr,extIpBuf); len += sprintf(page + len," [%d] intip(%-14s) extip(%-14s) type(%s) nhIdx(%d)\n", i, intIpBuf,extIpBuf, (asic_ip.localPublic==TRUE? "LP" : (asic_ip.nat==TRUE ? "NAT" : "NAPT")), asic_ip.nhIndex); @@ -3352,12 +3507,12 @@ static int32 ip_write( struct file *filp, const char *buff,unsigned long len, vo static int32 pppoe_read( char *page, char **start, off_t off, int count, int *eof, void *data ) { - int len; + int len; rtl865x_tblAsicDrv_pppoeParam_t asic_pppoe; int32 i; len = sprintf(page, "%s\n", "ASIC PPPOE Table:\n"); - for(i=0; i<RTL8651_PPPOETBL_SIZE; i++) + for(i=0; i<RTL8651_PPPOETBL_SIZE; i++) { if (rtl8651_getAsicPppoe(i, &asic_pppoe) == FAILED) continue; @@ -3373,10 +3528,10 @@ static int32 pppoe_write( struct file *filp, const char *buff,unsigned long len, #endif -#if defined(CONFIG_RTL_LAYERED_DRIVER_L4) && defined(CONFIG_RTL_8198) +#if defined(CONFIG_RTL_LAYERED_DRIVER_L4) && (defined(CONFIG_RTL_8198) ||defined(CONFIG_RTL_8196CT) ||defined(CONFIG_RTL_819XDT)) int32 napt_show(struct seq_file *s, void *v) { - int len; + int len; rtl865x_tblAsicDrv_naptTcpUdpParam_t asic_tcpudp; uint32 idx, entry=0; @@ -3391,18 +3546,18 @@ int32 napt_show(struct seq_file *s, void *v) idx, asic_tcpudp.insideLocalIpAddr>>24, (asic_tcpudp.insideLocalIpAddr&0x00ff0000) >> 16, (asic_tcpudp.insideLocalIpAddr&0x0000ff00)>>8, asic_tcpudp.insideLocalIpAddr&0x000000ff, - asic_tcpudp.insideLocalPort, + asic_tcpudp.insideLocalPort, asic_tcpudp.isValid, asic_tcpudp.isDedicated, asic_tcpudp.isCollision, asic_tcpudp.isCollision2, asic_tcpudp.isStatic, asic_tcpudp.isTcp ); len += seq_printf(s, " age(%d) offset(%d) tcpflag(%d) SelEIdx(%d) SelIPIdx(%d) priValid:%d pri(%d)\n", - asic_tcpudp.ageSec, asic_tcpudp.offset<<10, asic_tcpudp.tcpFlag, + asic_tcpudp.ageSec, asic_tcpudp.offset<<10, asic_tcpudp.tcpFlag, asic_tcpudp.selEIdx, asic_tcpudp.selExtIPIdx,asic_tcpudp.priValid,asic_tcpudp.priority ); entry++; } } - len += seq_printf(s, "Total entry: %d\n", entry); - + len += seq_printf(s, "Total entry: %d\n", entry); + return 0; } @@ -3419,7 +3574,7 @@ struct file_operations napt_single_seq_file_operations = { }; #endif -#if defined(CONFIG_RTL_LAYERED_DRIVER_L4) && defined(CONFIG_RTL_8198) +#if defined(CONFIG_RTL_LAYERED_DRIVER_L4) && (defined(CONFIG_RTL_8198) ||defined(CONFIG_RTL_8196CT) ||defined(CONFIG_RTL_819XDT)) extern int32 rtl865x_sw_napt_seq_read(struct seq_file *s, void *v); extern int32 rtl865x_sw_napt_seq_write( struct file *filp, const char *buff,unsigned long len, loff_t *off ); @@ -3443,89 +3598,13 @@ struct file_operations sw_napt_single_seq_file_operations = { }; #endif - -static int32 diagnostic_read( char *page, char **start, off_t off, int count, int *eof, void *data ) -{ - int len; - uint32 regData, regData1; - int port, regIdx; - uint32 mask, offset; - - len = sprintf(page, "Diagnostic Register Info:\n"); - - regData = READ_MEM32(GDSR0); - len += sprintf(page + len, "MaxUsedDescriptor: %d CurUsed Descriptor: %d\n", - (regData&MaxUsedDsc_MASK)>>MaxUsedDsc_OFFSET, - (regData&USEDDSC_MASK)>>USEDDSC_OFFSET); - len += sprintf(page+len, "DescRunOut: %s TotalDescFC: %s ShareBufFC: %s\n", - (regData&DSCRUNOUT)?"YES":"NO", (regData&TotalDscFctrl_Flag)?"YES":"NO", (regData&SharedBufFCON_Flag)?"YES":"NO"); - - for(regIdx = 0; regIdx<2; regIdx++) - { - regData = READ_MEM32(PCSR0+(regIdx<<2)); - - for(port=0; port<4; port++) - { - switch(port) - { - case 0: - mask = P0OQCgst_MASK; - offset = P0OQCgst_OFFSET; - break; - case 1: - mask = P1OQCgst_MASK; - offset = P1OQCgst_OFFSET; - break; - case 2: - mask = P2OQCgst_MASK; - offset = P2OQCgst_OFFSET; - break; - default: - mask = P3OQCgst_MASK; - offset = P3OQCgst_OFFSET; - break; - } - regData1 = (regData&mask)>>offset; - if (regData1==0) - len += sprintf(page+len, "Port%d not congestion\n", port+(regIdx<<2)); - else - { - len += sprintf(page+len, "Port%d queue congestion mask 0x%x\n", port+(regIdx<<2), regData1); - } - } - } - - for(port=0;port<=CPU;port++) - { - len += sprintf(page+len, "Port%d each queue used descriptor: Queue[0~5]: [ ", port); - for(regIdx=0; regIdx<3; regIdx++) - { - regData = READ_MEM32(P0_DCR0+(port<<4)+(regIdx<<2)); - len += sprintf(page+len, "%d %d ", - ((regData&Pn_EQDSCR_MASK)>>Pn_EVEN_OQDSCR_OFFSET), - ((regData&Pn_OQDSCR_MASK)>>Pn_ODD_OQDSCR_OFFSET)); - } - - regData = READ_MEM32(P0_DCR3+(port<<4)); - len += sprintf(page+len, "] Input queue [%d]\n", - ((regData&Pn_EQDSCR_MASK)>>Pn_EVEN_OQDSCR_OFFSET)); - } - - return len; -} - -static int32 diagnostic_write( struct file *filp, const char *buff,unsigned long len, void *data ) -{ - return len; -} - static int32 port_bandwidth_read( char *page, char **start, off_t off, int count, int *eof, void *data ) { int len; uint32 regData; uint32 data0, data1; int port; - + len = sprintf(page, "Dump Port Bandwidth Info:\n"); for(port=0;port<=CPU;port++) @@ -3539,12 +3618,12 @@ static int32 port_bandwidth_read( char *page, char **start, off_t off, int count { data0 = (regData&IBWC_EVENPORT_MASK)>>IBWC_EVENPORT_OFFSET; } - + regData = READ_MEM32(WFQRCRP0+((port*3)<<2)); data1 = (regData&APR_MASK)>>APR_OFFSET; data0++; - + if (data0) { if (data0<64) @@ -3560,7 +3639,7 @@ static int32 port_bandwidth_read( char *page, char **start, off_t off, int count if(data1!=(APR_MASK>>APR_OFFSET)) { data1++; - + if (data1<16) len += sprintf(page+len, "Engress:[%dKbps]\n", (data1<<16)/1000); else @@ -3570,7 +3649,7 @@ static int32 port_bandwidth_read( char *page, char **start, off_t off, int count else len += sprintf(page+len, "Egress:FullSpeed\n"); } - + return len; } @@ -3579,6 +3658,134 @@ static int32 port_bandwidth_write( struct file *filp, const char *buff,unsigned return len; } +static int32 port_priority_read( char *page, char **start, off_t off, int count, int *eof, void *data ) +{ + + extern int32 rtl8651_getAsicPortPriority( enum PORTID , enum PRIORITYVALUE*); + + + int len; + int port; + int priority; + len = sprintf(page, "Dump Port Priority Info:\n"); + for(port=0;port<=CPU;port++) + { + rtl8651_getAsicPortPriority(port,(enum PRIORITYVALUE*)&priority); + len += sprintf(page+len, "Port %d Priority %d\n",port,priority); + } + return len; +} +static int32 port_priority_write( struct file *filp, const char *buff,unsigned long len, void *data ) +{ + extern int32 rtl8651_setAsicPortPriority(enum PORTID, enum PRIORITYVALUE); + char tmpbuf[16], *tokptr, *strptr; + int port; + int priority; + int i; + memset(tmpbuf, 0, 16); + + if (buff && !copy_from_user(tmpbuf, buff, len)) { + + tmpbuf[len] = '\0'; + strptr = tmpbuf; + tokptr = strsep(&strptr," "); + if (tokptr==NULL || *tokptr=='\0') + { + goto errout; + } + + port = (uint32)simple_strtol(tokptr, NULL, 0); + + if(port == -1) + { + printk("Reset all port priority ro 0 \n"); + for(i=0; i<= CPU; i++) + rtl8651_setAsicPortPriority( i,0); + return len; + } + + tokptr = strsep(&strptr," "); + if (tokptr==NULL || *tokptr=='\0') + { + goto errout; + } + priority = (uint32)simple_strtol(tokptr, NULL, 0); + priority &=0x7; + + rtl8651_setAsicPortPriority( port,(enum PRIORITYVALUE)priority); + printk("set port %d priority %d\n",port,priority); + return len; + + } + +errout: + printk("Input error: port(0-5) priority (0-7)\n"); + printk("-1 to reset all port priority to 0\n"); + return len; +} + +static int32 dscp_priority_read( char *page, char **start, off_t off, int count, int *eof, void *data ) +{ + int len; + int dscp; + int priority; + extern int32 rtl8651_getAsicDscpPriority( uint32 , enum PRIORITYVALUE*); + len = sprintf(page, "Dump DSCP Priority Info:\n"); + for(dscp = 0;dscp < 64;dscp ++) + { + rtl8651_getAsicDscpPriority(dscp,(enum PRIORITYVALUE*)&priority); + if (priority) + len += sprintf(page+len, "DSCP %d Priority %d\n",dscp,priority); + } + return len; +} +static int32 dscp_priority_write( struct file *filp, const char *buff,unsigned long len, void *data ) +{ + + extern int32 rtl8651_setAsicDscpPriority( uint32 , enum PRIORITYVALUE); + extern int32 rtl8651_reset_dscp_priority(void); + char tmpbuf[16], *tokptr, *strptr; + int dscp; + int priority; + memset(tmpbuf, 0, 16); + + if (buff && !copy_from_user(tmpbuf, buff, len)) { + + tmpbuf[len] = '\0'; + strptr = tmpbuf; + tokptr = strsep(&strptr," "); + if (tokptr==NULL || *tokptr=='\0') + { + goto errout; + } + dscp = (uint32)simple_strtol(tokptr, NULL, 0); + if(dscp == -1) + { + rtl8651_reset_dscp_priority(); + printk("Reset all dscp priority ro 0 \n"); + return len; + } + + dscp &= 0x3f; + tokptr = strsep(&strptr," "); + if (tokptr==NULL || *tokptr=='\0') + { + goto errout; + } + priority = (uint32)simple_strtol(tokptr, NULL, 0); + priority &=0x7; + + rtl8651_setAsicDscpPriority( dscp,(enum PRIORITYVALUE)priority); + printk("set dscp %d priority %d\n", dscp, priority); + return len; + + } + +errout: + printk("Input error: dscp(0-63) priority (0-7)\n"); + printk("-1 to reset all dscp priority to 0\n"); + return len; +} static int32 queue_bandwidth_read( char *page, char **start, off_t off, int count, int *eof, void *data ) { int len; @@ -3597,7 +3804,7 @@ static int32 queue_bandwidth_read( char *page, char **start, off_t off, int coun { if ((queue_bandwidth_record_portmask&(1<<port))==0) continue; - + regData = READ_MEM32(QNUMCR); data0 = (regData>>(port*3))&7; len += sprintf(page+len, "Port%d Queue number: %d\n", port, data0); @@ -3615,7 +3822,7 @@ static int32 queue_bandwidth_read( char *page, char **start, off_t off, int coun { len += sprintf(page+len, "Type: WFQ [weight:%d]\n", data1+1); } - + regData = READ_MEM32(P0Q0RGCR+(queue<<2)+((port*6)<<2)); data1 = (regData&L1_MASK)>>L1_OFFSET; @@ -3641,10 +3848,10 @@ static int32 queue_bandwidth_read( char *page, char **start, off_t off, int coun } else len += sprintf(page+len, "Egress: avgRate & peakRateFullSpeed\n"); - - } + + } } - + return len; } @@ -3652,9 +3859,13 @@ static int32 queue_bandwidth_write( struct file *filp, const char *buff,unsigned { char tmpbuf[16], *tokptr, *strptr; int port; + if(len>16) + { + goto errout; + } memset(tmpbuf, 0, 16); - + if (buff && !copy_from_user(tmpbuf, buff, len)) { tmpbuf[len] = '\0'; strptr = tmpbuf; @@ -3665,36 +3876,484 @@ static int32 queue_bandwidth_write( struct file *filp, const char *buff,unsigned } queue_bandwidth_record_portmask=(uint32)simple_strtol(tokptr, NULL, 0); - printk("Dump info of: "); + rtlglue_printf("Dump info of: "); for(port=PHY0;port<=CPU;port++) { if ((1<<port)&queue_bandwidth_record_portmask) - printk("port%d ", port); + rtlglue_printf("port%d ", port); + } + rtlglue_printf("\n"); + } + else + { +errout: + rtlglue_printf("error input\n"); + } + + return len; +} + + + +static int32 priority_decision_read( char *page, char **start, off_t off, int count, int *eof, void *data ) +{ + int len; + uint32 regData; + int queue; + + len = sprintf(page, "Dump Priority Infor:\n"); + + regData = READ_MEM32(QIDDPCR); + + len += sprintf(page+len, "NAPT[%d] ACL[%d] DSCP[%d] 8021Q[%d] PortBase[%d]\n", + (regData & NAPT_PRI_MASK) >> NAPT_PRI_OFFSET, + (regData & ACL_PRI_MASK) >> ACL_PRI_OFFSET, + (regData & DSCP_PRI_MASK) >> DSCP_PRI_OFFSET, + (regData & BP8021Q_PRI_MASK) >> BP8021Q_PRI_OFFSET, + (regData & PBP_PRI_MASK) >> PBP_PRI_OFFSET); + + for(queue=0;queue<RTL8651_OUTPUTQUEUE_SIZE;queue++) + { + regData = READ_MEM32(UPTCMCR0+(queue<<2)); + len += sprintf(page+len, "Queue number %d:\n", (queue+1)); + len += sprintf(page+len, "Piority[0~7] Mapping to Queue[ %d %d %d %d %d %d %d %d ]\n", + regData&0x7, (regData>>3)&0x7, (regData>>6)&0x7, (regData>>9)&0x7, + (regData>>12)&0x7, (regData>>15)&0x7, (regData>>18)&0x7, (regData>>21)&0x7); + } + + return len; +} + +static int32 priority_decision_write( struct file *filp, const char *buff,unsigned long len, void *data ) +{ + return len; +} + +#if defined (CONFIG_RTL_ENABLE_RATELIMIT_TABLE) +static int32 rate_limit_read( char *page, char **start, off_t off, int count, int *eof, void *data ) +{ + int len; + rtl865x_tblAsicDrv_rateLimitParam_t asic_rl; + uint32 entry; + + len = sprintf(page, "Dump rate limit table:\n"); + for(entry=0; entry<RTL8651_RATELIMITTBL_SIZE; entry++) { + if (rtl8651_getAsicRateLimitTable(entry, &asic_rl) == SUCCESS) { + len += sprintf(page+len, " [%d] Token(%u) MaxToken(%u) remainTime Unit(%u) \n\trefillTimeUnit(%u) refillToken(%u)\n", + entry, asic_rl.token, asic_rl.maxToken, asic_rl.t_remainUnit, asic_rl.t_intervalUnit, asic_rl.refill_number); + } + else len += sprintf(page+len, " [%d] Invalid entry\n", entry); + } + len += sprintf(page+len, "\n"); + + return len; +} + +static int32 rate_limit_write( struct file *filp, const char *buff,unsigned long len, void *data ) +{ + return len; +} +#endif + +#if defined(CONFIG_RTL_ETH_PRIV_SKB_DEBUG) +static int32 rtl819x_proc_priveSkbDebug_read( char *page, char **start, off_t off, int count, int *eof, void *data ) +{ + return PROC_READ_RETURN_VALUE; +} + +static int32 rtl819x_proc_priveSkbDebug_write( struct file *filp, const char *buff,unsigned long len, void *data ) +{ + char tmpbuf[32]; + + if(len>32) + { + goto errout; + } + if (buff && !copy_from_user(tmpbuf, buff, len)) + { + tmpbuf[len -1] = '\0'; + if(tmpbuf[0] == '1') + { + unsigned long flags; + int cpu_queue_cnt,rxRing_cnt,txRing_cnt,wlan_txRing_cnt,wlan_txRing_cnt1, mbuf_pending_cnt; + int rx_queue_cnt,poll_cnt; + + rtlglue_printf("nic buf cnt(%d)\n",MAX_ETH_SKB_NUM); + + local_irq_save(flags); + mbuf_pending_cnt = get_mbuf_pending_times(); + cpu_queue_cnt = get_cpu_completion_queue_num(); + rxRing_cnt = get_nic_rxRing_buf(); + txRing_cnt = get_nic_txRing_buf(); + wlan_txRing_cnt = get_nic_buf_in_wireless_tx("wlan0"); + wlan_txRing_cnt1 = get_nic_buf_in_wireless_tx("wlan1"); + rx_queue_cnt = get_buf_in_rx_skb_queue(); + poll_cnt = get_buf_in_poll(); + local_irq_restore(flags); + + rtlglue_printf("cpu completion cnt(%d)\nnic rxring cnt(%d)\nnic txring cnt(%d)\nwlan0 txring(%d)\nwlan1 txring(%d)\nrx_queue_cnt(%d)\npoll_cnt(%d)\ntotal(%d)\nmbuf_pending_cnt(%d)\n",cpu_queue_cnt, + rxRing_cnt,txRing_cnt,wlan_txRing_cnt,wlan_txRing_cnt1, rx_queue_cnt,poll_cnt, + cpu_queue_cnt+rxRing_cnt+txRing_cnt+wlan_txRing_cnt+wlan_txRing_cnt1+rx_queue_cnt+poll_cnt, mbuf_pending_cnt); + } + else if (tmpbuf[0] == '2') + { + dump_wlan_dz_queue_num("wlan0"); + dump_wlan_dz_queue_num("wlan1"); + } + else + { + + } + } + else + { +errout: + rtlglue_printf("error input\n"); + } + return len; +} +#else +static int32 rtl819x_proc_priveSkbDebug_read( char *page, char **start, off_t off, int count, int *eof, void *data ) +{ + return PROC_READ_RETURN_VALUE; +} + +static int32 rtl819x_proc_priveSkbDebug_write( struct file *filp, const char *buff,unsigned long len, void *data ) +{ + char tmpbuf[32]; + if(len>32) + { + goto errout; + } + if (buff && !copy_from_user(tmpbuf, buff, len)) { + tmpbuf[len -1] = '\0'; + if(tmpbuf[0] == '1') { + rtl_dumpIndexs(); + } + } + else + { +errout: + rtlglue_printf("error input\n"); + } + + return len; +} +#endif + +static int32 storm_read( char *page, char **start, off_t off, int count, int *eof, void *data ) +{ + int len; + uint32 regData; + uint32 port; + uint32 totalExtPortNum=3; + len = sprintf(page, "Dump storm control info:\n"); + + regData = READ_MEM32(BSCR); + len += sprintf(page+len, "rate(%d)\n",regData*100/30360); + + for ( port = 0; port < RTL8651_PORT_NUMBER + totalExtPortNum; port++ ) + { + regData = READ_MEM32(PCRP0+port*4); + len+= sprintf(page+len,"port%d, %s BCSC, %s BC, %s MC\n", port,regData&ENBCSC?"enable":"disable",regData&BCSC_ENBROADCAST?"enable":"disable", + regData&BCSC_ENMULTICAST?"enable":"disable"); + } + + if (len <= off+count) + *eof = 1; + + *start = page + off; + len -= off; + + if (len>count) + len = count; + + if (len<0) len = 0; + + return len; +} + +static int32 storm_write(struct file *file, const char *buffer, + unsigned long count, void *data) +{ + uint32 tmpBuf[32]; + uint32 stormCtrlType=0x3;//mc & bc + uint32 enableStormCtrl=FALSE; + uint32 percentage=0; + uint32 uintVal; + if(count>32) + { + goto errout; + } + + if (buffer && !copy_from_user(tmpBuf, buffer, count)) + { + tmpBuf[count-1]=0; + uintVal=simple_strtoul((char *)tmpBuf, NULL, 0); + rtlglue_printf("%s(%d) uintval(%u) \n",__FUNCTION__,__LINE__,uintVal);//Added for test + if(uintVal>100) + { + enableStormCtrl=FALSE; + percentage=0; + } + else + { + enableStormCtrl=TRUE; + percentage=uintVal; + } + //printk("%s(%d),enableStormCtrl=%d,percentage=%d\n",__FUNCTION__,__LINE__, + // enableStormCtrl,percentage);//Added for test + rtl865x_setStormControl(stormCtrlType,enableStormCtrl,percentage); + return count; + } + else + { +errout: + rtlglue_printf("error input\n"); + } + return -EFAULT; +} + +static int32 stats_debug_entry_read( char *page, char **start, off_t off, int count, int *eof, void *data ) + { + int len; + + len = sprintf(page, " Debug Statistics Info:\n"); + len += sprintf(page+len," rx_noBuffer_cnt: %d\n",rx_noBuffer_cnt); + len += sprintf(page+len," tx_ringFull_cnt: %d\n",tx_ringFull_cnt); + return len; + + } +/*echo clear > /proc/rtl865x/stats to clear the count of tx&rx no buffer count*/ +static int32 stats_debug_entry_write(struct file *file, const char *buffer, + unsigned long len, void *data) + +{ + char tmpBuf[32]; + char *strptr; + char *cmd_addr; + if(len>32) + { + goto errout; + } + if (buffer && !copy_from_user(tmpBuf, buffer, len)) { + tmpBuf[len-1] = '\0'; + strptr=tmpBuf; + cmd_addr = strsep(&strptr," "); + if (cmd_addr==NULL) + { + goto errout; + } + + if(strncmp(cmd_addr, "clear",5) == 0) + { + rx_noBuffer_cnt=0; + tx_ringFull_cnt=0; + } + + } + else + { +errout: + rtlglue_printf("error input\n"); + } + return len; +} + +#endif + +#if defined(CONFIG_RTL_PROC_DEBUG)||defined(CONFIG_RTL_DEBUG_TOOL) +//the following proc default established +static int32 diagnostic_read( char *page, char **start, off_t off, int count, int *eof, void *data ) +{ + int len; + uint32 regData, regData1; + int port, regIdx; + uint32 mask, offset; + + len = sprintf(page, "Diagnostic Register Info:\n"); + + regData = READ_MEM32(GDSR0); + len += sprintf(page + len, "MaxUsedDescriptor: %d CurUsed Descriptor: %d\n", + (regData&MaxUsedDsc_MASK)>>MaxUsedDsc_OFFSET, + (regData&USEDDSC_MASK)>>USEDDSC_OFFSET); + len += sprintf(page+len, "DescRunOut: %s TotalDescFC: %s ShareBufFC: %s\n", + (regData&DSCRUNOUT)?"YES":"NO", (regData&TotalDscFctrl_Flag)?"YES":"NO", (regData&SharedBufFCON_Flag)?"YES":"NO"); + + for(regIdx = 0; regIdx<2; regIdx++) + { + regData = READ_MEM32(PCSR0+(regIdx<<2)); + + for(port=0; port<4; port++) + { + switch(port) + { + case 0: + mask = P0OQCgst_MASK; + offset = P0OQCgst_OFFSET; + break; + case 1: + mask = P1OQCgst_MASK; + offset = P1OQCgst_OFFSET; + break; + case 2: + mask = P2OQCgst_MASK; + offset = P2OQCgst_OFFSET; + break; + default: + mask = P3OQCgst_MASK; + offset = P3OQCgst_OFFSET; + break; + } + regData1 = (regData&mask)>>offset; + if (regData1==0) + len += sprintf(page+len, "Port%d not congestion\n", port+(regIdx<<2)); + else + { + len += sprintf(page+len, "Port%d queue congestion mask 0x%x\n", port+(regIdx<<2), regData1); + } + } + } + + for(port=0;port<=CPU;port++) + { + len += sprintf(page+len, "Port%d each queue used descriptor: Queue[0~5]: [ ", port); + for(regIdx=0; regIdx<3; regIdx++) + { + regData = READ_MEM32(P0_DCR0+(port<<4)+(regIdx<<2)); + len += sprintf(page+len, "%d %d ", + ((regData&Pn_EQDSCR_MASK)>>Pn_EVEN_OQDSCR_OFFSET), + ((regData&Pn_OQDSCR_MASK)>>Pn_ODD_OQDSCR_OFFSET)); + } + + regData = READ_MEM32(P0_DCR3+(port<<4)); + len += sprintf(page+len, "] Input queue [%d]\n", + ((regData&Pn_EQDSCR_MASK)>>Pn_EVEN_OQDSCR_OFFSET)); + } + + return len; +} + +static int32 diagnostic_write( struct file *filp, const char *buff,unsigned long len, void *data ) +{ + return len; +} + + +static int32 proc_mem_read( char *page, char **start, off_t off, int count, int *eof, void *data ) +{ + return PROC_READ_RETURN_VALUE; +} + +static int32 proc_mem_write( struct file *filp, const char *buff,unsigned long len, void *data ) +{ + char tmpbuf[64]; + uint32 *mem_addr, mem_data, mem_len; + char *strptr, *cmd_addr; + char *tokptr; + + if(len>64) + { + goto errout; + } + if (buff && !copy_from_user(tmpbuf, buff, len)) { + tmpbuf[len] = '\0'; + strptr=tmpbuf; + cmd_addr = strsep(&strptr," "); + if (cmd_addr==NULL) + { + goto errout; + } + rtlglue_printf("cmd %s\n", cmd_addr); + tokptr = strsep(&strptr," "); + if (tokptr==NULL) + { + goto errout; + } + + if (!memcmp(cmd_addr, "read", 4)) + { + mem_addr=(uint32*)simple_strtol(tokptr, NULL, 0); + tokptr = strsep(&strptr," "); + if (tokptr==NULL) + { + goto errout; + } + mem_len=simple_strtol(tokptr, NULL, 0); + memDump(mem_addr, mem_len, ""); + } + else if (!memcmp(cmd_addr, "write", 5)) + { + mem_addr=(uint32*)simple_strtol(tokptr, NULL, 0); + tokptr = strsep(&strptr," "); + if (tokptr==NULL) + { + goto errout; + } + mem_data=simple_strtol(tokptr, NULL, 0); + WRITE_MEM32(mem_addr, mem_data); + rtlglue_printf("Write memory 0x%p dat 0x%x: 0x%x\n", mem_addr, mem_data, READ_MEM32(mem_addr)); + } + else + { + goto errout; } - printk("\n"); + } + else + { +errout: + rtlglue_printf("Memory operation only support \"read\" and \"write\" as the first parameter\n"); + rtlglue_printf("Read format: \"read mem_addr length\"\n"); + rtlglue_printf("Write format: \"write mem_addr mem_data\"\n"); } return len; } + + static int32 port_status_read( char *page, char **start, off_t off, int count, int *eof, void *data ) { int len; uint32 regData; uint32 data0; int port; + uint32 regData_PCR; len = sprintf(page, "Dump Port Status:\n"); for(port=PHY0;port<=CPU;port++) { regData = READ_MEM32(PSRP0+((port)<<2)); + regData_PCR = READ_MEM32(PCRP0+((port)<<2)); + if (port==CPU) len += sprintf(page+len, "CPUPort "); else len += sprintf(page+len, "Port%d ", port); - data0 = regData & PortStatusLinkUp; + data0 = regData_PCR & EnForceMode; + if(data0) + { + len += sprintf(page+len, "Enforce Mode "); + data0 = regData_PCR & PollLinkStatus; + if (data0) + len += sprintf(page+len, " | polling LinkUp"); + else + { + len += sprintf(page+len, " | disable Auto-Negotiation\n\n"); + } + } + else + { + len += sprintf(page+len, "Force Mode disable\n"); + } + data0 = (regData & (PortEEEStatus_MASK))>>PortEEEStatus_OFFSET; + len += sprintf(page+len,"EEE Status %0x\n",data0); + + regData = READ_MEM32(PSRP0+((port)<<2)); + data0 = regData & PortStatusLinkUp; + if (data0) len += sprintf(page+len, "LinkUp | "); else @@ -3715,7 +4374,7 @@ static int32 port_status_read( char *page, char **start, off_t off, int count, i (data0==PortStatusLinkSpeed1000M?"1G": (data0==PortStatusLinkSpeed10M?"10M":"Unkown"))); } - + return len; } @@ -3737,6 +4396,10 @@ static int32 port_status_write( struct file *filp, const char *buff,unsigned lon #define SPEED100M 1 #define SPEED1000M 2 + if(len>64) + { + goto errout; + } if (buff && !copy_from_user(tmpbuf, buff, len)) { tmpbuf[len-1] = '\0'; strptr=tmpbuf; @@ -3759,7 +4422,7 @@ static int32 port_status_write( struct file *filp, const char *buff,unsigned lon { goto errout; } - + if(strcmp(tokptr,"10_half") == 0) type = HALF_DUPLEX_10M; else if(strcmp(tokptr,"100_half") == 0) @@ -3821,7 +4484,7 @@ static int32 port_status_write( struct file *filp, const char *buff,unsigned lon forceDuplex=TRUE; advCapability=(1<<DUPLEX_100M); break; - } + } case DUPLEX_1000M: { forceMode=TRUE; @@ -3831,32 +4494,32 @@ static int32 port_status_write( struct file *filp, const char *buff,unsigned lon advCapability=(1<<DUPLEX_1000M); break; } - default: + default: { forceMode=FALSE; forceLink=TRUE; /*all capality*/ - advCapability=(1<<PORT_AUTO); + advCapability=(1<<PORT_AUTO); } } - - + + for(port = 0; port < CPU; port++) { if((1<<port) & port_mask) { rtl865xC_setAsicEthernetForceModeRegs(port, forceMode, forceLink, forceLinkSpeed, forceDuplex); - + /*Set PHY Register*/ rtl8651_setAsicEthernetPHYSpeed(port,forceLinkSpeed); rtl8651_setAsicEthernetPHYDuplex(port,forceDuplex); rtl8651_setAsicEthernetPHYAutoNeg(port,forceMode?FALSE:TRUE); rtl8651_setAsicEthernetPHYAdvCapality(port,advCapability); - rtl8651_restartAsicEthernetPHYNway(port); + rtl8651_restartAsicEthernetPHYNway(port); } } - - } + + } else { goto errout; @@ -3865,138 +4528,20 @@ static int32 port_status_write( struct file *filp, const char *buff,unsigned lon else { errout: - printk("port status only support \"port\" as the first parameter\n"); - printk("format: \"port port_mask 10_half/100_half/10_full/100_full/1000_full/auto\"\n"); - } - return len; -} - - -static int32 priority_decision_read( char *page, char **start, off_t off, int count, int *eof, void *data ) -{ - int len; - uint32 regData; - int queue; - - len = sprintf(page, "Dump Priority Infor:\n"); - - regData = READ_MEM32(QIDDPCR); - - len += sprintf(page+len, "NAPT[%d] ACL[%d] DSCP[%d] 8021Q[%d] PortBase[%d]\n", - (regData & NAPT_PRI_MASK) >> NAPT_PRI_OFFSET, - (regData & ACL_PRI_MASK) >> ACL_PRI_OFFSET, - (regData & DSCP_PRI_MASK) >> DSCP_PRI_OFFSET, - (regData & BP8021Q_PRI_MASK) >> BP8021Q_PRI_OFFSET, - (regData & PBP_PRI_MASK) >> PBP_PRI_OFFSET); - - for(queue=0;queue<RTL8651_OUTPUTQUEUE_SIZE;queue++) - { - regData = READ_MEM32(UPTCMCR0+(queue<<2)); - len += sprintf(page+len, "Queue number %d:\n", (queue+1)); - len += sprintf(page+len, "Piority[0~7] Mapping to Queue[ %d %d %d %d %d %d %d %d ]\n", - regData&0x7, (regData>>3)&0x7, (regData>>6)&0x7, (regData>>9)&0x7, - (regData>>12)&0x7, (regData>>15)&0x7, (regData>>18)&0x7, (regData>>21)&0x7); + rtlglue_printf("port status only support \"port\" as the first parameter\n"); + rtlglue_printf("format: \"port port_mask 10_half/100_half/10_full/100_full/1000_full/auto\"\n"); } - - return len; -} - -static int32 priority_decision_write( struct file *filp, const char *buff,unsigned long len, void *data ) -{ return len; } -#if defined (CONFIG_RTL_ENABLE_RATELIMIT_TABLE) -static int32 rate_limit_read( char *page, char **start, off_t off, int count, int *eof, void *data ) -{ - int len; - rtl865x_tblAsicDrv_rateLimitParam_t asic_rl; - uint32 entry; - len = sprintf(page, "Dump rate limit table:\n"); - for(entry=0; entry<RTL8651_RATELIMITTBL_SIZE; entry++) { - if (rtl8651_getAsicRateLimitTable(entry, &asic_rl) == SUCCESS) { - len += sprintf(page+len, " [%d] Token(%u) MaxToken(%u) remainTime Unit(%u) \n\trefillTimeUnit(%u) refillToken(%u)\n", - entry, asic_rl.token, asic_rl.maxToken, asic_rl.t_remainUnit, asic_rl.t_intervalUnit, asic_rl.refill_number); - } - else len += sprintf(page+len, " [%d] Invalid entry\n", entry); - } - len += sprintf(page+len, "\n"); - - return len; -} - -static int32 rate_limit_write( struct file *filp, const char *buff,unsigned long len, void *data ) -{ - return len; -} -#endif - -#if defined(CONFIG_RTL_ETH_PRIV_SKB_DEBUG) -static int32 rtl819x_proc_priveSkbDebug_read( char *page, char **start, off_t off, int count, int *eof, void *data ) -{ - return PROC_READ_RETURN_VALUE; -} - -static int32 rtl819x_proc_priveSkbDebug_write( struct file *filp, const char *buff,unsigned long len, void *data ) -{ - char tmpbuf[32]; - if (buff && !copy_from_user(tmpbuf, buff, len)) - { - tmpbuf[len -1] = '\0'; - if(tmpbuf[0] == '1') - { - unsigned long flags; - int cpu_queue_cnt,rxRing_cnt,txRing_cnt,wlan_txRing_cnt,wlan_txRing_cnt1, mbuf_pending_cnt; - int rx_queue_cnt,poll_cnt; - - printk("=======nic buf cnt(%d)\n",MAX_ETH_SKB_NUM); - - local_irq_save(flags); - mbuf_pending_cnt = get_mbuf_pending_times(); - cpu_queue_cnt = get_cpu_completion_queue_num(); - rxRing_cnt = get_nic_rxRing_buf(); - txRing_cnt = get_nic_txRing_buf(); - wlan_txRing_cnt = get_nic_buf_in_wireless_tx("wlan0"); - wlan_txRing_cnt1 = get_nic_buf_in_wireless_tx("wlan1"); - rx_queue_cnt = get_buf_in_rx_skb_queue(); - poll_cnt = get_buf_in_poll(); - local_irq_restore(flags); - - printk("cpu completion cnt(%d)\nnic rxring cnt(%d)\nnic txring cnt(%d)\nwlan0 txring(%d)\nwlan1 txring(%d)\nrx_queue_cnt(%d)\npoll_cnt(%d)\ntotal(%d)\nmbuf_pending_cnt(%d)\n",cpu_queue_cnt, - rxRing_cnt,txRing_cnt,wlan_txRing_cnt,wlan_txRing_cnt1, rx_queue_cnt,poll_cnt, - cpu_queue_cnt+rxRing_cnt+txRing_cnt+wlan_txRing_cnt+wlan_txRing_cnt1+rx_queue_cnt+poll_cnt, mbuf_pending_cnt); - } - } - - return len; -} -#else -static int32 rtl819x_proc_priveSkbDebug_read( char *page, char **start, off_t off, int count, int *eof, void *data ) -{ - return PROC_READ_RETURN_VALUE; -} - -static int32 rtl819x_proc_priveSkbDebug_write( struct file *filp, const char *buff,unsigned long len, void *data ) -{ - char tmpbuf[32]; - if (buff && !copy_from_user(tmpbuf, buff, len)) { - tmpbuf[len -1] = '\0'; - if(tmpbuf[0] == '1') { - rtl_dumpIndexs(); - } - } - - return len; -} -#endif static int32 rtl865x_proc_mibCounter_read( char *page, char **start, off_t off, int count, int *eof, void *data ) { int len=0; - + rtl865xC_dumpAsicDiagCounter(); - + return len; } @@ -4007,23 +4552,28 @@ static int32 rtl865x_proc_mibCounter_write( struct file *filp, const char *buff, char *strptr; char *cmdptr; uint32 portNum=0xFFFFFFFF; + + if(len>512) + { + goto errout; + } if (buff && !copy_from_user(tmpbuf, buff, len)) { tmpbuf[len] = '\0'; - + strptr=tmpbuf; if(strlen(strptr)==0) { goto errout; } - + cmdptr = strsep(&strptr," "); if (cmdptr==NULL) { goto errout; } - + /*parse command*/ if(strncmp(cmdptr, "clear",5) == 0) { @@ -4036,71 +4586,71 @@ static int32 rtl865x_proc_mibCounter_write( struct file *filp, const char *buff, { goto errout; } - + if(strncmp(cmdptr, "port",4) != 0) { goto errout; } - + cmdptr = strsep(&strptr," "); if (cmdptr==NULL) { goto errout; } portNum = simple_strtol(cmdptr, NULL, 0); - - + + if((portNum>=0) && (portNum<=RTL8651_PORT_NUMBER)) { - extern int32 rtl8651_returnAsicCounter(uint32 offset); + extern uint32 rtl8651_returnAsicCounter(uint32 offset); extern uint64 rtl865xC_returnAsicCounter64(uint32 offset); uint32 addrOffset_fromP0 = portNum * MIB_ADDROFFSETBYPORT; - + if ( portNum == RTL8651_PORT_NUMBER ) - printk("<CPU port (extension port included)>\n"); + rtlglue_printf("<CPU port (extension port included)>\n"); else - printk("<Port: %d>\n", portNum); - - printk("Rx counters\n"); - printk(" Rcv %llu bytes, Drop %u pkts, CRCAlignErr %u, FragErr %u, JabberErr %u\n", - rtl865xC_returnAsicCounter64( OFFSET_IFINOCTETS_P0 + addrOffset_fromP0 ), - rtl8651_returnAsicCounter( OFFSET_DOT1DTPPORTINDISCARDS_P0 + addrOffset_fromP0 ), - rtl8651_returnAsicCounter( OFFSET_DOT3STATSFCSERRORS_P0 + addrOffset_fromP0 ), - rtl8651_returnAsicCounter( OFFSET_ETHERSTATSFRAGMEMTS_P0 + addrOffset_fromP0 ), + rtlglue_printf("<Port: %d>\n", portNum); + + rtlglue_printf("Rx counters\n"); + rtlglue_printf(" Rcv %llu bytes, Drop %u pkts, CRCAlignErr %u, FragErr %u, JabberErr %u\n", + rtl865xC_returnAsicCounter64( OFFSET_IFINOCTETS_P0 + addrOffset_fromP0 ), + rtl8651_returnAsicCounter( OFFSET_DOT1DTPPORTINDISCARDS_P0 + addrOffset_fromP0 ), + rtl8651_returnAsicCounter( OFFSET_DOT3STATSFCSERRORS_P0 + addrOffset_fromP0 ), + rtl8651_returnAsicCounter( OFFSET_ETHERSTATSFRAGMEMTS_P0 + addrOffset_fromP0 ), rtl8651_returnAsicCounter( OFFSET_ETHERSTATSJABBERS_P0 + addrOffset_fromP0 )); - printk(" Unicast %u pkts, Multicast %u pkts, Broadcast %u pkts\n", - rtl8651_returnAsicCounter( OFFSET_IFINUCASTPKTS_P0 + addrOffset_fromP0 ), - rtl8651_returnAsicCounter( OFFSET_ETHERSTATSMULTICASTPKTS_P0 + addrOffset_fromP0 ), + rtlglue_printf(" Unicast %u pkts, Multicast %u pkts, Broadcast %u pkts\n", + rtl8651_returnAsicCounter( OFFSET_IFINUCASTPKTS_P0 + addrOffset_fromP0 ), + rtl8651_returnAsicCounter( OFFSET_ETHERSTATSMULTICASTPKTS_P0 + addrOffset_fromP0 ), rtl8651_returnAsicCounter( OFFSET_ETHERSTATSBROADCASTPKTS_P0 + addrOffset_fromP0 )); - printk(" < 64: %u pkts, 64: %u pkts, 65 -127: %u pkts, 128 -255: %u pkts\n", - rtl8651_returnAsicCounter( OFFSET_ETHERSTATSUNDERSIZEPKTS_P0 + addrOffset_fromP0 ), - rtl8651_returnAsicCounter( OFFSET_ETHERSTATSPKTS64OCTETS_P0 + addrOffset_fromP0 ), - rtl8651_returnAsicCounter( OFFSET_ETHERSTATSPKTS65TO127OCTETS_P0 + addrOffset_fromP0 ), + rtlglue_printf(" < 64: %u pkts, 64: %u pkts, 65 -127: %u pkts, 128 -255: %u pkts\n", + rtl8651_returnAsicCounter( OFFSET_ETHERSTATSUNDERSIZEPKTS_P0 + addrOffset_fromP0 ), + rtl8651_returnAsicCounter( OFFSET_ETHERSTATSPKTS64OCTETS_P0 + addrOffset_fromP0 ), + rtl8651_returnAsicCounter( OFFSET_ETHERSTATSPKTS65TO127OCTETS_P0 + addrOffset_fromP0 ), rtl8651_returnAsicCounter( OFFSET_ETHERSTATSPKTS128TO255OCTETS_P0 + addrOffset_fromP0 )); - printk(" 256 - 511: %u pkts, 512 - 1023: %u pkts, 1024 - 1518: %u pkts\n", - rtl8651_returnAsicCounter( OFFSET_ETHERSTATSPKTS256TO511OCTETS_P0 + addrOffset_fromP0 ), - rtl8651_returnAsicCounter( OFFSET_ETHERSTATSPKTS512TO1023OCTETS_P0 + addrOffset_fromP0), + rtlglue_printf(" 256 - 511: %u pkts, 512 - 1023: %u pkts, 1024 - 1518: %u pkts\n", + rtl8651_returnAsicCounter( OFFSET_ETHERSTATSPKTS256TO511OCTETS_P0 + addrOffset_fromP0 ), + rtl8651_returnAsicCounter( OFFSET_ETHERSTATSPKTS512TO1023OCTETS_P0 + addrOffset_fromP0), rtl8651_returnAsicCounter( OFFSET_ETHERSTATSPKTS1024TO1518OCTETS_P0 + addrOffset_fromP0 ) ); - printk(" oversize: %u pkts, Control unknown %u pkts, Pause %u pkts\n", + rtlglue_printf(" oversize: %u pkts, Control unknown %u pkts, Pause %u pkts\n", rtl8651_returnAsicCounter( OFFSET_ETHERSTATSOVERSIZEPKTS_P0 + addrOffset_fromP0 ), - rtl8651_returnAsicCounter( OFFSET_DOT3CONTROLINUNKNOWNOPCODES_P0 + addrOffset_fromP0 ), + rtl8651_returnAsicCounter( OFFSET_DOT3CONTROLINUNKNOWNOPCODES_P0 + addrOffset_fromP0 ), rtl8651_returnAsicCounter( OFFSET_DOT3INPAUSEFRAMES_P0 + addrOffset_fromP0 )); - - printk("Output counters\n"); - printk(" Snd %llu bytes, Unicast %u pkts, Multicast %u pkts\n", - rtl865xC_returnAsicCounter64( OFFSET_IFOUTOCTETS_P0 + addrOffset_fromP0 ), + + rtlglue_printf("Output counters\n"); + rtlglue_printf(" Snd %llu bytes, Unicast %u pkts, Multicast %u pkts\n", + rtl865xC_returnAsicCounter64( OFFSET_IFOUTOCTETS_P0 + addrOffset_fromP0 ), rtl8651_returnAsicCounter( OFFSET_IFOUTUCASTPKTS_P0 + addrOffset_fromP0 ), rtl8651_returnAsicCounter( OFFSET_IFOUTMULTICASTPKTS_P0 + addrOffset_fromP0 )); - printk(" Broadcast %u pkts, Late collision %u, Deferred transmission %u \n", + rtlglue_printf(" Broadcast %u pkts, Late collision %u, Deferred transmission %u \n", rtl8651_returnAsicCounter( OFFSET_IFOUTBROADCASTPKTS_P0 + addrOffset_fromP0 ), - rtl8651_returnAsicCounter( OFFSET_DOT3STATSLATECOLLISIONS_P0 + addrOffset_fromP0 ), + rtl8651_returnAsicCounter( OFFSET_DOT3STATSLATECOLLISIONS_P0 + addrOffset_fromP0 ), rtl8651_returnAsicCounter( OFFSET_DOT3STATSDEFERREDTRANSMISSIONS_P0 + addrOffset_fromP0 )); - printk(" Collisions %u Single collision %u Multiple collision %u pause %u\n", - rtl8651_returnAsicCounter( OFFSET_ETHERSTATSCOLLISIONS_P0 + addrOffset_fromP0 ), - rtl8651_returnAsicCounter( OFFSET_DOT3STATSSINGLECOLLISIONFRAMES_P0 + addrOffset_fromP0 ), - rtl8651_returnAsicCounter( OFFSET_DOT3STATSMULTIPLECOLLISIONFRAMES_P0 + addrOffset_fromP0 ), + rtlglue_printf(" Collisions %u Single collision %u Multiple collision %u pause %u\n", + rtl8651_returnAsicCounter( OFFSET_ETHERSTATSCOLLISIONS_P0 + addrOffset_fromP0 ), + rtl8651_returnAsicCounter( OFFSET_DOT3STATSSINGLECOLLISIONFRAMES_P0 + addrOffset_fromP0 ), + rtl8651_returnAsicCounter( OFFSET_DOT3STATSMULTIPLECOLLISIONFRAMES_P0 + addrOffset_fromP0 ), rtl8651_returnAsicCounter( OFFSET_DOT3OUTPAUSEFRAMES_P0 + addrOffset_fromP0 )); - + } else { @@ -4111,23 +4661,144 @@ static int32 rtl865x_proc_mibCounter_write( struct file *filp, const char *buff, { goto errout; } - + } else { errout: - printk("error input\n"); + rtlglue_printf("error input\n"); } return len; } + static int32 proc_phyReg_read( char *page, char **start, off_t off, int count, int *eof, void *data ) { return PROC_READ_RETURN_VALUE; } -#ifdef CONFIG_RTL_8198 +static int32 proc_mmd_read( char *page, char **start, off_t off, int count, int *eof, void *data ) +{ + return PROC_READ_RETURN_VALUE; +} + +/* + echo read phy_id device_id reg_addr > /proc/rtl865x/mmd + echo write phy_id device_id reg_addr data_for_write > /proc/rtl865x/mmd + */ +static int32 proc_mmd_write( struct file *filp, const char *buff,unsigned long len, void *data ) +{ + char tmpbuf[64]; + uint32 phyId, regId, regData, devId, dataReadBack; + char *strptr, *cmd_addr; + char *tokptr; + int32 ret; + + if(len>64) + { + goto errout; + } + if (buff && !copy_from_user(tmpbuf, buff, len)) { + tmpbuf[len] = '\0'; + strptr=tmpbuf; + cmd_addr = strsep(&strptr," "); + if (cmd_addr==NULL) + { + goto errout; + } + + if (!memcmp(cmd_addr, "read", 4)) + { + tokptr = strsep(&strptr," "); + if (tokptr==NULL) + { + goto errout; + } + phyId=simple_strtol(tokptr, NULL, 0); + + tokptr = strsep(&strptr," "); + if (tokptr==NULL) + { + goto errout; + } + devId=simple_strtol(tokptr, NULL, 0); + + tokptr = strsep(&strptr," "); + if (tokptr==NULL) + { + goto errout; + } + regId=simple_strtol(tokptr, NULL, 0); + + ret = mmd_read(phyId, devId, regId, ®Data); + + if(ret==SUCCESS) + { + rtlglue_printf("read phyId(%d), devId(%d), regId(%d), regData:0x%x\n", phyId,devId, regId, regData); + } + else + { + rtlglue_printf("error input!\n"); + } + } + else if (!memcmp(cmd_addr, "write", 5)) + { + tokptr = strsep(&strptr," "); + if (tokptr==NULL) + { + goto errout; + } + phyId=simple_strtol(tokptr, NULL, 0); + + tokptr = strsep(&strptr," "); + if (tokptr==NULL) + { + goto errout; + } + devId=simple_strtol(tokptr, NULL, 0); + + tokptr = strsep(&strptr," "); + if (tokptr==NULL) + { + goto errout; + } + regId=simple_strtol(tokptr, NULL, 0); + + tokptr = strsep(&strptr," "); + if (tokptr==NULL) + { + goto errout; + } + regData=simple_strtol(tokptr, NULL, 0); + + mmd_write(phyId, devId, regId, regData); + + /* confirm result */ + rtl8651_setAsicEthernetPHYReg( phyId, 13, (devId | 0x4000)); + ret=rtl8651_getAsicEthernetPHYReg(phyId, 14, &dataReadBack); + + if(ret==SUCCESS) + { + rtlglue_printf("extWrite phyId(%d), devId(%d), regId(%d), regData:0x%x, regData(read back):0x%x\n", + phyId, devId, regId, regData, dataReadBack); + } + else + { + rtlglue_printf("error input!\n"); + } + } + } + else + { +errout: + rtlglue_printf("error input!\n"); + } + + return len; +} + +#if defined(CONFIG_RTL_8198) || defined(CONFIG_RTL_819XD) || defined(CONFIG_RTL_8196E) void getPhyByPortPage(int port, int page) { uint32 regData; @@ -4136,7 +4807,7 @@ void getPhyByPortPage(int port, int page) //change page num //rtl8651_setAsicEthernetPHYReg(port, 31, page); if (page>=31) - { + { rtl8651_setAsicEthernetPHYReg( port, 31, 7 ); rtl8651_setAsicEthernetPHYReg( port, 30, page ); } @@ -4144,15 +4815,15 @@ void getPhyByPortPage(int port, int page) { rtl8651_setAsicEthernetPHYReg( port, 31, page ); } - + for(reg=0;reg<32;reg++) { - rtl8651_getAsicEthernetPHYReg( port, reg, ®Data); - printk("port:%d,page:%d,regId:%d,regData:0x%x\n",port,page,reg,regData); + rtl8651_getAsicEthernetPHYReg( port, reg, ®Data); + rtlglue_printf("port:%d,page:%d,regId:%d,regData:0x%x\n",port,page,reg,regData); } //if(page!=3) //{ - printk("------------------------------------------\n"); + rtlglue_printf("------------------------------------------\n"); //} //change back to page 0 @@ -4160,8 +4831,8 @@ void getPhyByPortPage(int port, int page) } -static const int _8198_phy_page[] = { 0, 1, 2, 3, 4, 5, 6, 32, - 33, 34, 35, 36, 40, 44, 45, 46, +static const int _8198_phy_page[] = { 0, 1, 2, 3, 4, 5, 6, 32, + 33, 34, 35, 36, 40, 44, 45, 46, 64, 65, 66, 69, 70, 80, 81, 161 }; #endif @@ -4175,6 +4846,10 @@ static int32 proc_phyReg_write( struct file *filp, const char *buff,unsigned lon int32 ret; int i, j; + if(len>64) + { + goto errout; + } if (buff && !copy_from_user(tmpbuf, buff, len)) { tmpbuf[len] = '\0'; strptr=tmpbuf; @@ -4183,7 +4858,7 @@ static int32 proc_phyReg_write( struct file *filp, const char *buff,unsigned lon { goto errout; } - + if (!memcmp(cmd_addr, "read", 4)) { tokptr = strsep(&strptr," "); @@ -4192,22 +4867,22 @@ static int32 proc_phyReg_write( struct file *filp, const char *buff,unsigned lon goto errout; } phyId=simple_strtol(tokptr, NULL, 0); - + tokptr = strsep(&strptr," "); if (tokptr==NULL) { goto errout; } regId=simple_strtol(tokptr, NULL, 0); - - ret=rtl8651_getAsicEthernetPHYReg(phyId, regId, ®Data); + + ret=rtl8651_getAsicEthernetPHYReg(phyId, regId, ®Data); if(ret==SUCCESS) { - printk("read phyId(%d), regId(%d),regData:0x%x\n", phyId, regId, regData); + rtlglue_printf("read phyId(%d), regId(%d),regData:0x%x\n", phyId, regId, regData); } else { - printk("error input!\n"); + rtlglue_printf("error input!\n"); } } else if (!memcmp(cmd_addr, "write", 5)) @@ -4218,7 +4893,7 @@ static int32 proc_phyReg_write( struct file *filp, const char *buff,unsigned lon goto errout; } phyId=simple_strtol(tokptr, NULL, 0); - + tokptr = strsep(&strptr," "); if (tokptr==NULL) { @@ -4232,15 +4907,15 @@ static int32 proc_phyReg_write( struct file *filp, const char *buff,unsigned lon goto errout; } regData=simple_strtol(tokptr, NULL, 0); - + ret=rtl8651_setAsicEthernetPHYReg(phyId, regId, regData); if(ret==SUCCESS) { - printk("Write phyId(%d), regId(%d), regData:0x%x\n", phyId, regId, regData); + rtlglue_printf("Write phyId(%d), regId(%d), regData:0x%x\n", phyId, regId, regData); } else { - printk("error input!\n"); + rtlglue_printf("error input!\n"); } } #ifdef CONFIG_8198_PORT5_RGMII @@ -4252,15 +4927,15 @@ static int32 proc_phyReg_write( struct file *filp, const char *buff,unsigned lon goto errout; } regId=simple_strtol(tokptr, NULL, 16); - ret = rtl8370_getAsicReg(regId, ®Data); - + ret = rtl8370_getAsicReg(regId, ®Data); + if(ret==0) { - printk("rtl8370_getAsicReg: reg= %x, data= %x\n", regId, regData); + rtlglue_printf("rtl8370_getAsicReg: reg= %x, data= %x\n", regId, regData); } else { - printk("get fail %d\n", ret); + rtlglue_printf("get fail %d\n", ret); } } else if (!memcmp(cmd_addr, "8370write", 9)) @@ -4271,23 +4946,23 @@ static int32 proc_phyReg_write( struct file *filp, const char *buff,unsigned lon goto errout; } regId=simple_strtol(tokptr, NULL, 16); - + tokptr = strsep(&strptr," "); if (tokptr==NULL) { goto errout; } regData=simple_strtol(tokptr, NULL, 16); - + ret = rtl8370_setAsicReg(regId, regData); if(ret==0) { - printk("rtl8370_setAsicReg: reg= %x, data= %x\n", regId, regData); + rtlglue_printf("rtl8370_setAsicReg: reg= %x, data= %x\n", regId, regData); } else { - printk("set fail %d\n", ret); + rtlglue_printf("set fail %d\n", ret); } } #endif @@ -4306,7 +4981,7 @@ static int32 proc_phyReg_write( struct file *filp, const char *buff,unsigned lon goto errout; } pageId=simple_strtol(tokptr, NULL, 0); - + tokptr = strsep(&strptr," "); if (tokptr==NULL) { @@ -4316,7 +4991,7 @@ static int32 proc_phyReg_write( struct file *filp, const char *buff,unsigned lon //switch page if (pageId>=31) - { + { rtl8651_setAsicEthernetPHYReg( phyId, 31, 7 ); rtl8651_setAsicEthernetPHYReg( phyId, 30, pageId ); } @@ -4324,21 +4999,21 @@ static int32 proc_phyReg_write( struct file *filp, const char *buff,unsigned lon { rtl8651_setAsicEthernetPHYReg( phyId, 31, pageId ); } - + ret=rtl8651_getAsicEthernetPHYReg(phyId, regId, ®Data); - + if(ret==SUCCESS) { - printk("extRead phyId(%d), pageId(%d), regId(%d), regData:0x%x\n", phyId,pageId, regId, regData); + rtlglue_printf("extRead phyId(%d), pageId(%d), regId(%d), regData:0x%x\n", phyId,pageId, regId, regData); } else { - printk("error input!\n"); + rtlglue_printf("error input!\n"); } //change back to page 0 rtl8651_setAsicEthernetPHYReg(phyId, 31, 0); - + } else if (!memcmp(cmd_addr, "extWrite", 8)) { @@ -4355,7 +5030,7 @@ static int32 proc_phyReg_write( struct file *filp, const char *buff,unsigned lon goto errout; } pageId=simple_strtol(tokptr, NULL, 0); - + tokptr = strsep(&strptr," "); if (tokptr==NULL) { @@ -4372,7 +5047,7 @@ static int32 proc_phyReg_write( struct file *filp, const char *buff,unsigned lon //switch page if (pageId>=31) - { + { rtl8651_setAsicEthernetPHYReg( phyId, 31, 7 ); rtl8651_setAsicEthernetPHYReg( phyId, 30, pageId ); } @@ -4380,29 +5055,29 @@ static int32 proc_phyReg_write( struct file *filp, const char *buff,unsigned lon { rtl8651_setAsicEthernetPHYReg( phyId, 31, pageId ); } - + ret=rtl8651_setAsicEthernetPHYReg(phyId, regId, regData); - + if(ret==SUCCESS) { - printk("extWrite phyId(%d), pageId(%d), regId(%d), regData:0x%x\n", phyId, pageId, regId, regData); + rtlglue_printf("extWrite phyId(%d), pageId(%d), regId(%d), regData:0x%x\n", phyId, pageId, regId, regData); } else { - printk("error input!\n"); + rtlglue_printf("error input!\n"); } - + //change back to page 0 rtl8651_setAsicEthernetPHYReg(phyId, 31, 0); } else if (!memcmp(cmd_addr, "snr", 3)) { uint32 sum; - for (i=0;i<5;i++) + for (i=0;i<5;i++) { - if (REG32(PSRP0 + (i * 4)) & PortStatusLinkUp) + if (REG32(PSRP0 + (i * 4)) & PortStatusLinkUp) { - for (j=0, sum=0;j<10;j++) + for (j=0, sum=0;j<10;j++) { rtl8651_getAsicEthernetPHYReg(i, 29, ®Data); sum += regData; @@ -4411,11 +5086,11 @@ static int32 proc_phyReg_write( struct file *filp, const char *buff,unsigned lon sum /= 10; //db = -(10 * log(sum/262144)); //printk(" port %d SNR = %d dB\n", i, db); - printk(" port %d SUM = %d\n", i, sum); + rtlglue_printf(" port %d SUM = %d\n", i, sum); } - else + else { - printk(" port %d is link down\n", i); + rtlglue_printf(" port %d is link down\n", i); } } } @@ -4427,8 +5102,8 @@ static int32 proc_phyReg_write( struct file *filp, const char *buff,unsigned lon #endif for (port=0; port<5; port++) { - printk("==========================================\n"); - + rtlglue_printf("==========================================\n"); + #ifdef CONFIG_RTL_8196C for(page=0;page<4;page++) { @@ -4436,114 +5111,281 @@ static int32 proc_phyReg_write( struct file *filp, const char *buff,unsigned lon rtl8651_setAsicEthernetPHYReg(port, 31, page); for(reg=0;reg<32;reg++) { - rtl8651_getAsicEthernetPHYReg( port, reg, ®Data); - printk("port:%d,page:%d,regId:%d,regData:0x%x\n",port,page,reg,regData); + rtl8651_getAsicEthernetPHYReg( port, reg, ®Data); + rtlglue_printf("port:%d,page:%d,regId:%d,regData:0x%x\n",port,page,reg,regData); } if(page!=3) { - printk("------------------------------------------\n"); + rtlglue_printf("------------------------------------------\n"); } //change back to page 0 rtl8651_setAsicEthernetPHYReg(port, 31, 0 ); } -#elif defined(CONFIG_RTL_8198) - //set pageNum {0 1 2 3 4 5 6 32 33 34 35 36 40 44 45 46 64 65 66 69 70 80 81 161} +#elif defined(CONFIG_RTL_8198) || defined(CONFIG_RTL_819XD) || defined(CONFIG_RTL_8196E) + //set pageNum {0 1 2 3 4 5 6 32 33 34 35 36 40 44 45 46 64 65 66 69 70 80 81 161} for (i=0; i<24; i++) getPhyByPortPage(port, _8198_phy_page[i]); -#endif +#endif } } } else { errout: - printk("error input!\n"); + rtlglue_printf("error input!\n"); } return len; } - -static int32 storm_read( char *page, char **start, off_t off, int count, int *eof, void *data ) +//MACCR porc-------------------------------------------------------------------------------------------- +static int32 mac_config_read( char *page, char **start, off_t off, int count, int *eof, void *data ) { int len; uint32 regData; - uint32 port; - uint32 totalExtPortNum=3; - len = sprintf(page, "Dump storm control info:\n"); - - regData = READ_MEM32(BSCR); - len += sprintf(page+len, "rate(%d)\n",regData*100/30360); + uint32 data0; + + len = sprintf(page, "MAC Configuration Register Info:\n"); + regData = READ_MEM32(MACCR); + + data0 = regData & IPG_SEL; + len += sprintf(page+len, "IfgSel: "); + if (data0) + len += sprintf(page+len, "internal counter =352\n"); + else + len += sprintf(page+len, "internal counter =480\n"); + + data0 = regData & INFINITE_PAUSE_FRAMES ; + len += sprintf(page+len, "INFINITE_PAUSE_FRAMES: "); + if (data0) + len += sprintf(page+len, "Infinite pause frame count\n"); + else + len += sprintf(page+len, "Maximum of 128 consecutive pause frames\n"); - for ( port = 0; port < RTL8651_PORT_NUMBER + totalExtPortNum; port++ ) - { - regData = READ_MEM32(PCRP0+port*4); - len+= sprintf(page+len,"port%d, %s BCSC, %s BC, %s MC\n", port,regData&ENBCSC?"enable":"disable",regData&BCSC_ENBROADCAST?"enable":"disable", - regData&BCSC_ENMULTICAST?"enable":"disable"); - } + data0= regData & LONG_TXE; + len += sprintf(page+len, "LONG_TXE: "); + if (data0) + len += sprintf(page+len, "Carrier-based backpressure\n"); + else + len += sprintf(page+len, "Collision-based backpressure\n"); - if (len <= off+count) - *eof = 1; + data0= regData & EN_48_DROP; + len += sprintf(page+len, "EN_48_DROP: "); + if (data0) + len += sprintf(page+len, "Enabled\n"); + else + len += sprintf(page+len, "Disabled\n"); + + data0= (regData & SELIPG_MASK)>>SELIPG_OFFSET; + len += sprintf(page+len, "SELIPG: "); + if(data0==0x00) + len += sprintf(page+len, "7 byte-time\n"); + else if(data0==0x01) + len += sprintf(page+len, "8 byte-time\n"); + else if(data0==0x10) + len += sprintf(page+len, "10 byte-time\n"); + else + len += sprintf(page+len, "12 byte-time\n"); + + data0= (regData & CF_SYSCLK_SEL_MASK)>>CF_SYSCLK_SEL_OFFSET; + len += sprintf(page+len, "CF_SYSCLK_SEL: "); + if(data0==0x00) + len += sprintf(page+len, "50MHz\n"); + else if(data0==0x01) + len += sprintf(page+len, "100MHz\n"); + else + len += sprintf(page+len, "reserved status\n"); - *start = page + off; - len -= off; + data0= (regData & CF_FCDSC_MASK)>>CF_FCDSC_OFFSET; + len += sprintf(page+len, "CF_FCDSC: %d pages\n",data0); - if (len>count) - len = count; + data0= (regData & CF_RXIPG_MASK); + len += sprintf(page+len, "CF_RXIPG: %d pkts\n",data0); + + return len; - if (len<0) len = 0; +} - return len; +static int32 mac_config_write(struct file *filp, const char *buff,unsigned long len, void *data ) +{ + return len; } -static int32 storm_write(struct file *file, const char *buffer, - unsigned long count, void *data) +//FC threshold-------------------------------------------------------------------------- +static int32 fc_threshold_read( char *page, char **start, off_t off, int count, int *eof, void *data ) { - uint32 tmpBuf[32]; - uint32 stormCtrlType=0x3;//mc & bc - uint32 enableStormCtrl=FALSE; - uint32 percentage=0; - uint32 uintVal; - if (buffer && !copy_from_user(tmpBuf, buffer, count)) + int len; + uint32 regData; + uint32 data0; + int port; + int group=3; + len = sprintf(page, "Dump FC threshold Information:\n"); + + //SBFCR0 + regData = READ_MEM32(SBFCR0); + data0 = regData & S_DSC_RUNOUT_MASK; + len += sprintf(page+len, "S_DSC_RUNOUT:%d\n",data0); + //SBFCR1 + regData = READ_MEM32(SBFCR1); + data0 = (regData & SDC_FCOFF_MASK)>>SDC_FCOFF_OFFSET; + len += sprintf(page+len, "SDC_FCOFF:%d, ",data0); + data0 = (regData & SDC_FCON_MASK)>>SDC_FCON_OFFSET; + len += sprintf(page+len, "SDC_FCON:%d\n",data0); + //SBFCR2 + regData = READ_MEM32(SBFCR2); + data0 = (regData & S_Max_SBuf_FCOFF_MASK)>>S_Max_SBuf_FCOFF_OFFSET; + len += sprintf(page+len, "S_MaxSBuf_FCON:%d, ",data0); + data0 = (regData & S_Max_SBuf_FCON_MASK)>>S_Max_SBuf_FCON_OFFSET; + len += sprintf(page+len, "S_MaxSBuf_FCOFF:%d\n",data0); + //FCCR0,FCCR1 + regData = READ_MEM32(FCCR0); + data0 =(regData & Q_P0_EN_FC_MASK)>>(Q_P0_EN_FC_OFFSET); + len += sprintf(page+len, "Q_P0_EN_FC:%0x, ",data0); + data0 =(regData & Q_P1_EN_FC_MASK)>>(Q_P1_EN_FC_OFFSET); + len += sprintf(page+len, "Q_P1_EN_FC:%0x, ",data0); + data0 =(regData & Q_P2_EN_FC_MASK)>>(Q_P2_EN_FC_OFFSET); + len += sprintf(page+len, "Q_P2_EN_FC:%0x\n",data0); + data0 =(regData & Q_P3_EN_FC_MASK)>>(Q_P3_EN_FC_OFFSET); + len += sprintf(page+len, "Q_P3_EN_FC:%0x, ",data0); + regData = READ_MEM32(FCCR1); + data0 =(regData & Q_P4_EN_FC_MASK)>>(Q_P4_EN_FC_OFFSET); + len += sprintf(page+len, "Q_P4_EN_FC:%0x, ",data0); + regData = READ_MEM32(FCCR0); + data0 =(regData & Q_P5_EN_FC_MASK)>>(Q_P5_EN_FC_OFFSET); + len += sprintf(page+len, "Q_P5_EN_FC:%0x\n",data0); + //PQPLGR + regData = READ_MEM32(PQPLGR); + data0 =regData & QLEN_GAP_MASK; + len += sprintf(page+len, "QLEN_GAP:%d\n",data0); + //QRR + regData = READ_MEM32(QRR); + data0 =regData & QRST; + len += sprintf(page+len, "QRST:%d\n",data0); + //IQFCTCR + regData = READ_MEM32(IQFCTCR); + data0 =(regData & IQ_DSC_FCON_MASK)>>IQ_DSC_FCON_OFFSET; + len += sprintf(page+len, "IQ_DSC_FCON:%d, ",data0); + data0 =(regData & IQ_DSC_FCOFF_MASK)>>IQ_DSC_FCOFF_OFFSET; + len += sprintf(page+len, "IQ_DSC_FCOFF:%d\n",data0); + //QNUMCR + regData = READ_MEM32(QNUMCR); + len += sprintf(page+len,"The number of output queue for port(0~6) :\n"); + data0=(regData & P0QNum_MASK )>>(P0QNum_OFFSET); + len += sprintf(page+len, "P0QNum%d, ",data0); + data0=(regData & P1QNum_MASK )>>(P1QNum_OFFSET); + len += sprintf(page+len, "P1QNum%d, ",data0); + data0=(regData & P2QNum_MASK )>>(P2QNum_OFFSET); + len += sprintf(page+len, "P2QNum%d, ",data0); + data0=(regData & P3QNum_MASK )>>(P3QNum_OFFSET); + len += sprintf(page+len, "P3QNum%d, ",data0); + data0=(regData & P4QNum_MASK )>>(P4QNum_OFFSET); + len += sprintf(page+len, "P4QNum%d, ",data0); + data0=(regData & P5QNum_MASK )>>(P5QNum_OFFSET); + len += sprintf(page+len, "P5QNum%d, ",data0); + data0=(regData & P6QNum_MASK )>>(P6QNum_OFFSET); + len += sprintf(page+len, "P6QNum%d\n",data0); + //per port + for(port=PHY0;port<=CPU;port++) { - tmpBuf[count-1]=0; - uintVal=simple_strtoul((char *)tmpBuf, NULL, 0); - printk("%s(%d) uintval(%u) \n",__FUNCTION__,__LINE__,uintVal);//Added for test - if(uintVal>100) - { - enableStormCtrl=FALSE; - percentage=0; - } + if (port==CPU) + len += sprintf(page+len, "\nCPUPort\n"); else - { - enableStormCtrl=TRUE; - percentage=uintVal; + len += sprintf(page+len, "\nPort%d\n", port); + + regData = READ_MEM32(PBFCR0+((port)<<2)); + data0 = (regData & P_MaxDSC_FCOFF_MASK)>>P_MaxDSC_FCOFF_OFFSET; + len += sprintf(page+len, " P_MaxDSC_FCOFF:%d, ",data0); + data0 = (regData & P_MaxDSC_FCON_MASK)>>P_MaxDSC_FCON_OFFSET; + len += sprintf(page+len, "P_MaxDSC_FCON:%d\n",data0); + //if(port<CPU) + { + for (group=GR0;group<=GR2;group++) + { + len += sprintf(page+len, " Port%dGroup%d\n",port,group); + /* QDBFCRP0G0,QDBFCRP0G1,QDBFCRP0G2 + * QDBFCRP1G0,QDBFCRP1G1,QDBFCRP1G2 + * QDBFCRP2G0,QDBFCRP2G1,QDBFCRP2G2 + * QDBFCRP3G0,QDBFCRP3G1,QDBFCRP3G2 + * QDBFCRP4G0,QDBFCRP4G1,QDBFCRP4G2 + * QDBFCRP5G0,QDBFCRP5G1,QDBFCRP5G2 + * - Queue-Descriptor=Based Flow Control Threshold for Port 0 Group 0 */ + regData =READ_MEM32(QDBFCRP0G0+((port)<<2)+((group)<<2)); + //len+=sprintf(page+len,"address:%0x",(QDBFCRP0G0+((port)<<2)+((group)<<2))); + data0 = (regData & QG_DSC_FCOFF_MASK)>>QG_DSC_FCOFF_OFFSET; + len += sprintf(page+len, " QG_DSC_FCOFF:%d, ",data0); + data0 = (regData & QG_DSC_FCON_MASK)>>QG_DSC_FCON_OFFSET; + len += sprintf(page+len, "QG_DSC_FCON:%d, ",data0); + + /* QPKTFCRP0G0,QPKTFCRP0G1,QPKTFCRP0G2 + * QPKTFCRP1G0,QPKTFCRP1G1,QPKTFCRP1G2 + * QPKTFCRP2G0,QPKTFCRP2G1,QPKTFCRP2G2 + * QPKTFCRP3G0,QPKTFCRP3G1,QPKTFCRP3G2 + * QPKTFCRP4G0,QPKTFCRP4G1,QPKTFCRP4G2 + * QPKTFCRP5G0,QPKTFCRP5G1,QPKTFCRP5G2 + - Queue-Packet-Based Flow Control Register for Port 0 Group 0 */ + regData =READ_MEM32(QPKTFCRP0G0+((port)<<2)+((group)<<2)); + //len+=sprintf(page+len,"address:%0x",(QPKTFCRP0G0+((port)<<2)+((group)<<2))); + data0 = (regData & QG_QLEN_FCOFF_MASK)>>QG_QLEN_FCOFF_OFFSET; + len += sprintf(page+len, "QG_QLEN_FCOFF:%d, ",data0); + data0 = (regData & QG_QLEN_FCON_MASK)>>QG_QLEN_FCON_OFFSET; + len += sprintf(page+len, "QG_QLEN_FCON:%d\n",data0); + + } } - //printk("%s(%d),enableStormCtrl=%d,percentage=%d\n",__FUNCTION__,__LINE__, - // enableStormCtrl,percentage);//Added for test - rtl865x_setStormControl(stormCtrlType,enableStormCtrl,percentage); - return count; } - return -EFAULT; + + return len; +} + +static int32 fc_threshold_write(struct file *filp, const char *buff,unsigned long len, void *data ) +{ + return len; } +#endif + + int32 rtl865x_proc_debug_init(void) { int32 retval; + +#if defined(CONFIG_RTL_LOG_DEBUG) + extern void log_print_proc_init(void); + log_print_proc_init(); +#endif rtl865x_proc_dir = proc_mkdir(RTL865X_PROC_DIR_NAME,NULL); if(rtl865x_proc_dir) { + #ifdef CONFIG_RTL_PROC_DEBUG + /*stats*/ + { + stats_debug_entry = create_proc_entry("stats",0,rtl865x_proc_dir); + if(stats_debug_entry != NULL) + { + stats_debug_entry->read_proc = stats_debug_entry_read; + stats_debug_entry->write_proc= stats_debug_entry_write; + + retval = SUCCESS; + } + else + { + rtlglue_printf("can't create proc entry for stats"); + retval = FAILED; + goto out; + } + } + /*vlan*/ { vlan_entry = create_proc_entry("vlan",0,rtl865x_proc_dir); if(vlan_entry != NULL) { //vlan_entry->read_proc = vlan_read; - //vlan_entry->write_proc= vlan_write; + //vlan_entry->write_proc= vlan_write; vlan_entry->proc_fops = &vlan_single_seq_file_operations; - retval = SUCCESS; + retval = SUCCESS; } else { @@ -4561,7 +5403,7 @@ int32 rtl865x_proc_debug_init(void) netif_entry->read_proc = netif_read; netif_entry->write_proc= netif_write; - retval = SUCCESS; + retval = SUCCESS; } else { @@ -4582,7 +5424,7 @@ int32 rtl865x_proc_debug_init(void) */ acl_entry->proc_fops = &acl_single_seq_file_operations; - retval = SUCCESS; + retval = SUCCESS; } else { @@ -4599,7 +5441,7 @@ int32 rtl865x_proc_debug_init(void) advRt_entry->read_proc = advRt_read; advRt_entry->write_proc= advRt_write; //advRt_entry->owner = THIS_MODULE; - retval = SUCCESS; + retval = SUCCESS; } else { @@ -4631,10 +5473,10 @@ int32 rtl865x_proc_debug_init(void) { acl_chains_entry = create_proc_entry("soft_aclChains",0,rtl865x_proc_dir); if(acl_chains_entry != NULL) - { + { acl_chains_entry->proc_fops = &aclChains_single_seq_file_operations; - retval = SUCCESS; + retval = SUCCESS; } else { @@ -4657,7 +5499,7 @@ int32 rtl865x_proc_debug_init(void) */ qos_rule_entry->proc_fops = &qosRule_single_seq_file_operations; - retval = SUCCESS; + retval = SUCCESS; } else { @@ -4675,7 +5517,7 @@ int32 rtl865x_proc_debug_init(void) hs_entry->read_proc = hs_read; hs_entry->write_proc= hs_write; - retval = SUCCESS; + retval = SUCCESS; } else { @@ -4695,7 +5537,7 @@ int32 rtl865x_proc_debug_init(void) } else { - printk("can't create nic_mbuf entry for hs"); + rtlglue_printf("can't create nic_mbuf entry for hs"); retval = FAILED; goto out; } @@ -4708,7 +5550,7 @@ int32 rtl865x_proc_debug_init(void) { rxRing_entry->proc_fops = &rxRing_single_seq_file_operations; - retval = SUCCESS; + retval = SUCCESS; } else { @@ -4725,7 +5567,7 @@ int32 rtl865x_proc_debug_init(void) { txRing_entry->proc_fops = &txRing_single_seq_file_operations; - retval = SUCCESS; + retval = SUCCESS; } else { @@ -4742,16 +5584,16 @@ int32 rtl865x_proc_debug_init(void) { mbuf_entry->proc_fops = &mbuf_single_seq_file_operations; - retval = SUCCESS; + retval = SUCCESS; } else { - rtlglue_printf("can't create mbuf entry for hs"); + rtlglue_printf("can't create mbuf entry for mbufRing"); retval = FAILED; goto out; } } - + /*pvid*/ { pvid_entry = create_proc_entry("pvid",0,rtl865x_proc_dir); @@ -4760,7 +5602,7 @@ int32 rtl865x_proc_debug_init(void) pvid_entry->read_proc = pvid_read; pvid_entry->write_proc= pvid_write; - retval = SUCCESS; + retval = SUCCESS; } else { @@ -4778,7 +5620,7 @@ int32 rtl865x_proc_debug_init(void) mirrorPort_entry->read_proc = mirrorPort_read; mirrorPort_entry->write_proc= mirrorPort_write; - retval = SUCCESS; + retval = SUCCESS; } else { @@ -4788,24 +5630,6 @@ int32 rtl865x_proc_debug_init(void) } } - /*memory*/ - { - mem_entry = create_proc_entry("memory",0,rtl865x_proc_dir); - if(mem_entry != NULL) - { - mem_entry->read_proc = proc_mem_read; - mem_entry->write_proc= proc_mem_write; - - retval = SUCCESS; - } - else - { - rtlglue_printf("can't create proc entry for memory"); - retval = FAILED; - goto out; - } - } - /*l2*/ { l2_entry = create_proc_entry("l2", 0, rtl865x_proc_dir); @@ -4823,8 +5647,8 @@ int32 rtl865x_proc_debug_init(void) goto out; } } - -#if defined (CONFIG_RTL_HARDWARE_MULTICAST) + +#if defined (CONFIG_RTL_HARDWARE_MULTICAST) hwMCast_entry=create_proc_entry("hwMCast", 0, rtl865x_proc_dir); if(hwMCast_entry != NULL) { @@ -4832,7 +5656,7 @@ int32 rtl865x_proc_debug_init(void) hwMCast_entry->write_proc = rtl865x_proc_hw_mcast_write; retval = SUCCESS; } - + swMCast_entry=create_proc_entry("swMCast", 0, rtl865x_proc_dir); if(swMCast_entry != NULL) { @@ -4840,7 +5664,7 @@ int32 rtl865x_proc_debug_init(void) swMCast_entry->write_proc = rtl865x_proc_sw_mcast_write; retval = SUCCESS; } -#endif +#endif #ifdef CONFIG_RTL_LAYERED_DRIVER_L3 @@ -4861,7 +5685,7 @@ int32 rtl865x_proc_debug_init(void) goto out; } } - + /*nextHop*/ { nexthop_entry= create_proc_entry("nexthop", 0, rtl865x_proc_dir); @@ -4935,7 +5759,7 @@ int32 rtl865x_proc_debug_init(void) } #endif -#if defined(CONFIG_RTL_LAYERED_DRIVER_L4) && defined(CONFIG_RTL_8198) +#if defined(CONFIG_RTL_LAYERED_DRIVER_L4) && (defined(CONFIG_RTL_8198) ||defined(CONFIG_RTL_8196CT) ||defined(CONFIG_RTL_819XDT)) /*napt*/ { napt_entry= create_proc_entry("napt", 0, rtl865x_proc_dir); @@ -4957,9 +5781,8 @@ int32 rtl865x_proc_debug_init(void) goto out; } } - + /*software napt*/ -#if defined(CONFIG_RTL_LAYERED_DRIVER_L4) && defined(CONFIG_RTL_8198) { sw_napt_entry= create_proc_entry("sw_napt", 0, rtl865x_proc_dir); if(sw_napt_entry != NULL) @@ -4981,8 +5804,6 @@ int32 rtl865x_proc_debug_init(void) } #endif -#endif - #ifdef CONFIG_RTL_LAYERED_DRIVER_L2 /*software l2*/ { @@ -5021,24 +5842,6 @@ int32 rtl865x_proc_debug_init(void) } } #endif - /*diagnostic*/ - { - diagnostic_entry= create_proc_entry("diagnostic", 0, rtl865x_proc_dir); - if(diagnostic_entry != NULL) - { - diagnostic_entry->read_proc = diagnostic_read; - diagnostic_entry->write_proc = diagnostic_write; - - retval = SUCCESS; - } - else - { - rtlglue_printf("can't create proc entry for diagnostic"); - retval = FAILED; - goto out; - } - } - /*port_bandwidth*/ { port_bandwidth_entry= create_proc_entry("port_bandwidth", 0, rtl865x_proc_dir); @@ -5056,62 +5859,58 @@ int32 rtl865x_proc_debug_init(void) goto out; } } - - /*queue_bandwidth*/ + /*port_priority*/ { - queue_bandwidth_entry= create_proc_entry("queue_bandwidth", 0, rtl865x_proc_dir); - if(queue_bandwidth_entry != NULL) + port_priority_entry= create_proc_entry("port_priority", 0, rtl865x_proc_dir); + if(port_priority_entry != NULL) { - queue_bandwidth_entry->read_proc = queue_bandwidth_read; - queue_bandwidth_entry->write_proc = queue_bandwidth_write; + port_priority_entry->read_proc = port_priority_read; + port_priority_entry->write_proc = port_priority_write; retval = SUCCESS; } else { - rtlglue_printf("can't create proc entry for queue_bandwidth"); + rtlglue_printf("can't create proc entry for port_priority"); retval = FAILED; goto out; } } - - /*port_status*/ + /*dscp_priority*/ { - port_status_entry= create_proc_entry("port_status", 0, rtl865x_proc_dir); - if(port_status_entry != NULL) + dscp_priority_entry= create_proc_entry("dscp_priority", 0, rtl865x_proc_dir); + if(dscp_priority_entry != NULL) { - port_status_entry->read_proc = port_status_read; - port_status_entry->write_proc = port_status_write; + dscp_priority_entry->read_proc = dscp_priority_read; + dscp_priority_entry->write_proc = dscp_priority_write; retval = SUCCESS; } else { - rtlglue_printf("can't create proc entry for port_status"); + rtlglue_printf("can't create proc entry for dscp_priority"); retval = FAILED; goto out; } } - - /*phy*/ + /*queue_bandwidth*/ { - phyReg_entry= create_proc_entry("phyReg", 0, rtl865x_proc_dir); - if(phyReg_entry != NULL) + queue_bandwidth_entry= create_proc_entry("queue_bandwidth", 0, rtl865x_proc_dir); + if(queue_bandwidth_entry != NULL) { - phyReg_entry->read_proc = proc_phyReg_read; - phyReg_entry->write_proc = proc_phyReg_write; + queue_bandwidth_entry->read_proc = queue_bandwidth_read; + queue_bandwidth_entry->write_proc = queue_bandwidth_write; retval = SUCCESS; } else { - rtlglue_printf("can't create proc entry for phyTeg"); + rtlglue_printf("can't create proc entry for queue_bandwidth"); retval = FAILED; goto out; } } - - /*priority_decision*/ + /*priority_decision*/ { priority_decision_entry= create_proc_entry("priority_decision", 0, rtl865x_proc_dir); if(priority_decision_entry != NULL) @@ -5156,15 +5955,6 @@ int32 rtl865x_proc_debug_init(void) retval = SUCCESS; } #endif - - - asicCnt_entry=create_proc_entry("asicCounter", 0, rtl865x_proc_dir); - if(asicCnt_entry != NULL) - { - asicCnt_entry->read_proc = rtl865x_proc_mibCounter_read; - asicCnt_entry->write_proc = rtl865x_proc_mibCounter_write; - retval = SUCCESS; - } #if defined CONFIG_RTL_IGMP_SNOOPING igmp_entry=create_proc_entry("igmp", 0, rtl865x_proc_dir); @@ -5188,7 +5978,143 @@ int32 rtl865x_proc_debug_init(void) prive_skb_debug_entry->write_proc = rtl819x_proc_priveSkbDebug_write; retval = SUCCESS; } - /* #endif */ + #endif + +#if defined(CONFIG_RTL_PROC_DEBUG)||defined(CONFIG_RTL_DEBUG_TOOL) + /*memory*/ + { + mem_entry = create_proc_entry("memory",0,rtl865x_proc_dir); + if(mem_entry != NULL) + { + mem_entry->read_proc = proc_mem_read; + mem_entry->write_proc= proc_mem_write; + + retval = SUCCESS; + } + else + { + rtlglue_printf("can't create proc entry for memory"); + retval = FAILED; + goto out; + } + } + /*diagnostic*/ + { + diagnostic_entry= create_proc_entry("diagnostic", 0, rtl865x_proc_dir); + if(diagnostic_entry != NULL) + { + diagnostic_entry->read_proc = diagnostic_read; + diagnostic_entry->write_proc = diagnostic_write; + + retval = SUCCESS; + } + else + { + rtlglue_printf("can't create proc entry for diagnostic"); + retval = FAILED; + goto out; + } + } + /*port_status*/ + { + port_status_entry= create_proc_entry("port_status", 0, rtl865x_proc_dir); + if(port_status_entry != NULL) + { + port_status_entry->read_proc = port_status_read; + port_status_entry->write_proc = port_status_write; + + retval = SUCCESS; + } + else + { + rtlglue_printf("can't create proc entry for port_status"); + retval = FAILED; + goto out; + } + } + + /*phy*/ + { + phyReg_entry= create_proc_entry("phyReg", 0, rtl865x_proc_dir); + if(phyReg_entry != NULL) + { + phyReg_entry->read_proc = proc_phyReg_read; + phyReg_entry->write_proc = proc_phyReg_write; + + retval = SUCCESS; + } + else + { + rtlglue_printf("can't create proc entry for phyTeg"); + retval = FAILED; + goto out; + } + } + /*asicCnt*/ + { + asicCnt_entry=create_proc_entry("asicCounter", 0, rtl865x_proc_dir); + if(asicCnt_entry != NULL) + { + asicCnt_entry->read_proc = rtl865x_proc_mibCounter_read; + asicCnt_entry->write_proc = rtl865x_proc_mibCounter_write; + retval = SUCCESS; + } + } + + /* indirect access for special phy register */ + { + mmd_entry= create_proc_entry("mmd", 0, rtl865x_proc_dir); + if(mmd_entry != NULL) + { + mmd_entry->read_proc = proc_mmd_read; + mmd_entry->write_proc = proc_mmd_write; + + retval = SUCCESS; + } + else + { + rtlglue_printf("can't create proc entry for mmd"); + retval = FAILED; + goto out; + } + } + + /*maccr*/ + { + mac_entry=create_proc_entry("mac", 0, rtl865x_proc_dir); + if(mac_entry != NULL) + { + mac_entry->read_proc = mac_config_read; + mac_entry->write_proc = mac_config_write; + retval = SUCCESS; + } + else + { + rtlglue_printf("can't create proc entry for mac"); + retval = FAILED; + goto out; + } + + } + /*FC threshold*/ + { + fc_threshold_entry=create_proc_entry("fc_threshold", 0, rtl865x_proc_dir); + if(fc_threshold_entry != NULL) + { + fc_threshold_entry->read_proc = fc_threshold_read; + fc_threshold_entry->write_proc = fc_threshold_write; + retval = SUCCESS; + } + else + { + rtlglue_printf("can't create proc entry for fc_threshold"); + retval = FAILED; + goto out; + } + + } +#endif + } else { @@ -5197,15 +6123,22 @@ int32 rtl865x_proc_debug_init(void) out: if(retval == FAILED) rtl865x_proc_debug_cleanup(); - - return retval; - + + return retval; + } int32 rtl865x_proc_debug_cleanup(void) { if(rtl865x_proc_dir) { +#ifdef CONFIG_RTL_PROC_DEBUG + + if(stats_debug_entry) + { + remove_proc_entry("stats",rtl865x_proc_dir); + stats_debug_entry = NULL; + } if(vlan_entry) { remove_proc_entry("vlan",rtl865x_proc_dir); @@ -5281,12 +6214,7 @@ int32 rtl865x_proc_debug_cleanup(void) l2_entry = NULL; } - if(mem_entry) - { - remove_proc_entry("memory", mem_entry); - mem_entry = NULL; - } - + if(arp_entry) { remove_proc_entry("arp", rtl865x_proc_dir); @@ -5321,12 +6249,6 @@ int32 rtl865x_proc_debug_cleanup(void) { remove_proc_entry("napt", rtl865x_proc_dir); } - - if (diagnostic_entry) - { - remove_proc_entry("diagnostic", rtl865x_proc_dir); - } - if (port_bandwidth_entry) { remove_proc_entry("port_bandwidth", rtl865x_proc_dir); @@ -5336,21 +6258,11 @@ int32 rtl865x_proc_debug_cleanup(void) { remove_proc_entry("queue_bandwidth", rtl865x_proc_dir); } - - if (port_status_entry) - { - remove_proc_entry("port_status", rtl865x_proc_dir); - } - - if (phyReg_entry) - { - remove_proc_entry("phyReg", rtl865x_proc_dir); - } if (priority_decision_entry) { remove_proc_entry("priority_decision", rtl865x_proc_dir); } -#if defined(CONFIG_RTL_LAYERED_DRIVER_L4) && defined(CONFIG_RTL_8198) +#if defined(CONFIG_RTL_LAYERED_DRIVER_L4) && defined(CONFIG_RTL_8198)||defined(CONFIG_RTL_8196CT) || defined(CONFIG_RTL_819XDT) if(sw_napt_entry) { remove_proc_entry("sw_napt", rtl865x_proc_dir); @@ -5382,18 +6294,14 @@ int32 rtl865x_proc_debug_cleanup(void) { remove_proc_entry("hwMCast", rtl865x_proc_dir); } - + #if defined (CONFIG_RTL_HARDWARE_MULTICAST) if(swMCast_entry != NULL) { remove_proc_entry("swMCast", rtl865x_proc_dir); } #endif - if(asicCnt_entry != NULL) - { - remove_proc_entry("asicCounter", rtl865x_proc_dir); - } - + #if defined (CONFIG_RTL_IGMP_SNOOPING) if(igmp_entry!=NULL) { @@ -5414,13 +6322,55 @@ int32 rtl865x_proc_debug_cleanup(void) remove_proc_entry("priveSkbDebug", rtl865x_proc_dir); } /*#endif*/ +#endif + +#if defined(CONFIG_RTL_PROC_DEBUG)||defined(CONFIG_RTL_DEBUG_TOOL) + if(mem_entry) + { + remove_proc_entry("memory", mem_entry); + mem_entry = NULL; + } + if (diagnostic_entry) + { + remove_proc_entry("diagnostic", rtl865x_proc_dir); + } + if (port_status_entry) + { + remove_proc_entry("port_status", rtl865x_proc_dir); + } + if (phyReg_entry) + { + remove_proc_entry("phyReg", rtl865x_proc_dir); + } + + if (mmd_entry) + { + remove_proc_entry("mmd", rtl865x_proc_dir); + } + if(asicCnt_entry != NULL) + { + remove_proc_entry("asicCounter", rtl865x_proc_dir); + } + if(mac_entry != NULL) + { + remove_proc_entry("mac",rtl865x_proc_dir); + } + + if(fc_threshold_entry != NULL) + { + remove_proc_entry("fc_threshold", rtl865x_proc_dir); + } + +#endif + + remove_proc_entry(RTL865X_PROC_DIR_NAME, NULL); rtl865x_proc_dir = NULL; - + } - return SUCCESS; + return SUCCESS; } |
