summaryrefslogtreecommitdiffstatsabout
path: root/SylixOS
diff options
context:
space:
mode:
authorHanhui <hanhui@acoinfo.com>2020-06-24 17:20:41 (GMT)
committer Hanhui <hanhui@acoinfo.com>2020-06-24 17:20:41 (GMT)
commita56d55b6c36bf6fddc70ac6515d3a667a656d37a (patch)
tree467cd9b4a730447e4da69321a34011e2d5b2af91 /SylixOS
parent03763932d3665eab36ed5f4d6a80e4f9b52fe133 (diff)
downloadlibsylixos-a56d55b6c36bf6fddc70ac6515d3a667a656d37a.zip
libsylixos-a56d55b6c36bf6fddc70ac6515d3a667a656d37a.tar.gz
libsylixos-a56d55b6c36bf6fddc70ac6515d3a667a656d37a.tar.bz2
Improve PPPoS efficiency and add related configuration.
Diffstat (limited to 'SylixOS')
-rw-r--r--SylixOS/config/net/net_tools_cfg.h9
-rw-r--r--SylixOS/net/lwip/event/lwip_netevent.h1
-rw-r--r--SylixOS/net/lwip/lwip_config.h14
-rw-r--r--SylixOS/net/lwip/tools/ppp/lwip_ppp.c24
-rw-r--r--SylixOS/shell/ttinyShell/ttinyShellReadline.c10
-rw-r--r--SylixOS/system/device/ty/tyLib.c36
6 files changed, 78 insertions, 16 deletions
diff --git a/SylixOS/config/net/net_tools_cfg.h b/SylixOS/config/net/net_tools_cfg.h
index f6f0e18..14c474e 100644
--- a/SylixOS/config/net/net_tools_cfg.h
+++ b/SylixOS/config/net/net_tools_cfg.h
@@ -191,6 +191,15 @@
#define LW_CFG_NET_LOGINBL_EN 1 /* 网络登录黑名单服务 */
#define LW_CFG_NET_LOGINBL_MAX_NODE 1000 /* 黑名单存储最大个数 */
+/*********************************************************************************************************
+ PPP (拨号工具)
+* 依存关系: 1: 网络
+*********************************************************************************************************/
+
+#define LW_CFG_NET_PPP_TIMEOUT 6 /* 单次尝试超时时间 (s) */
+#define LW_CFG_NET_PPP_RETRANSMITS 8 /* 最大重试次数 */
+#define LW_CFG_NET_PPP_ECHOINTERVAL 10 /* Keepalive Echo 间隔时间 */
+
#endif /* __NET_TOOLS_CFG_H */
/*********************************************************************************************************
END
diff --git a/SylixOS/net/lwip/event/lwip_netevent.h b/SylixOS/net/lwip/event/lwip_netevent.h
index 695b1c2..064c0c9 100644
--- a/SylixOS/net/lwip/event/lwip_netevent.h
+++ b/SylixOS/net/lwip/event/lwip_netevent.h
@@ -73,6 +73,7 @@ extern "C" {
#define NET_EVENT_PPP_AUTH (NET_EVENT_PPP + 2) /* 进入用户认证 */
#define NET_EVENT_PPP_RUN (NET_EVENT_PPP + 3) /* 网络连通 */
#define NET_EVENT_PPP_DISCONN (NET_EVENT_PPP + 4) /* 进入连接中断 */
+#define NET_EVENT_PPP_TIMEOUT (NET_EVENT_PPP + 5) /* 连接超时 */
/*********************************************************************************************************
wireless 事件类型
diff --git a/SylixOS/net/lwip/lwip_config.h b/SylixOS/net/lwip/lwip_config.h
index e4cd249..8379387 100644
--- a/SylixOS/net/lwip/lwip_config.h
+++ b/SylixOS/net/lwip/lwip_config.h
@@ -650,7 +650,19 @@ extern INT __inetHostTableGetItem(CPCHAR pcHost, size_t stLen, PVOID pvAddr,
ppp timeouts
*********************************************************************************************************/
-#define LCP_ECHOINTERVAL 10 /* check lcp link per 10seconds*/
+#define FSM_DEFTIMEOUT LW_CFG_NET_PPP_TIMEOUT
+#define UPAP_DEFTIMEOUT LW_CFG_NET_PPP_TIMEOUT
+#define CHAP_DEFTIMEOUT LW_CFG_NET_PPP_TIMEOUT
+#define EAP_DEFREQTIME LW_CFG_NET_PPP_TIMEOUT
+#define EAP_DEFTIMEOUT LW_CFG_NET_PPP_TIMEOUT
+
+#define FSM_DEFMAXCONFREQS LW_CFG_NET_PPP_RETRANSMITS
+#define UPAP_DEFTRANSMITS LW_CFG_NET_PPP_RETRANSMITS
+#define CHAP_DEFTRANSMITS LW_CFG_NET_PPP_RETRANSMITS
+#define EAP_DEFALLOWREQ LW_CFG_NET_PPP_RETRANSMITS
+#define LCP_DEFLOOPBACKFAIL LW_CFG_NET_PPP_RETRANSMITS
+
+#define LCP_ECHOINTERVAL LW_CFG_NET_PPP_ECHOINTERVAL /* echo timer */
/*********************************************************************************************************
ppp api
diff --git a/SylixOS/net/lwip/tools/ppp/lwip_ppp.c b/SylixOS/net/lwip/tools/ppp/lwip_ppp.c
index 6db708d..ed9bc96 100644
--- a/SylixOS/net/lwip/tools/ppp/lwip_ppp.c
+++ b/SylixOS/net/lwip/tools/ppp/lwip_ppp.c
@@ -17,6 +17,9 @@
** 文件创建日期: 2014 年 01 月 08 日
**
** 描 述: lwip ppp 连接管理器.
+
+** BUG:
+2020.06.23 增大 PPPoS 接收缓冲.
*********************************************************************************************************/
#define __SYLIXOS_STDIO
#define __SYLIXOS_KERNEL
@@ -114,6 +117,7 @@ static VOID __pppLinkStatCb (ppp_pcb *pcb, INT iErrCode, PVOID pvCtx)
break;
case PPPERR_PEERDEAD:
+ netEventIfPppExt(ppp_netif(pcb), NET_EVENT_PPP_TIMEOUT);
printk(KERN_ERR "[PPP]PPPERR_PEERDEAD\n");
break;
@@ -217,15 +221,22 @@ static VOID __pppNotifyPhaseCb (ppp_pcb *pcb, u8_t ucPhase, PVOID pvCtx)
static VOID __pppOsThread (ppp_pcb *pcb)
{
PPP_CTX_PRIV *pctxp;
+ size_t stBufSz = PPPRBUF_SIZE >> 2; /* 接收缓冲 1/4 */
ssize_t sstRead;
- UCHAR ucBuffer[ETH_FRAME_LEN];
+ UCHAR ucStatic[ETH_FRAME_LEN];
+ PUCHAR pucBuffer;
- pctxp = (PPP_CTX_PRIV *)pcb->ctx_cb;
+ pctxp = (PPP_CTX_PRIV *)pcb->ctx_cb;
+ pucBuffer = (PUCHAR)__SHEAP_ALLOC(stBufSz);
+ if (!pucBuffer) {
+ pucBuffer = ucStatic;
+ stBufSz = sizeof(ucStatic);
+ }
for (;;) {
- sstRead = read(pctxp->CTXP_iFd, ucBuffer, sizeof(ucBuffer));
+ sstRead = read(pctxp->CTXP_iFd, pucBuffer, stBufSz);
if (sstRead > 0) {
- pppos_input(pcb, ucBuffer, (INT)sstRead);
+ pppos_input(pcb, pucBuffer, (INT)sstRead);
} else {
if (iosFdGetType(pctxp->CTXP_iFd, LW_NULL) < ERROR_NONE) {
@@ -247,9 +258,14 @@ static VOID __pppOsThread (ppp_pcb *pcb)
lib_free(pctxp->CTXP_cPass);
}
__SHEAP_FREE(pctxp);
+ if (pucBuffer != ucStatic) {
+ __SHEAP_FREE(pucBuffer);
+ }
break;
}
}
+
+ LW_THREAD_UNSAFE(); /* 退出安全模式 */
}
/*********************************************************************************************************
** 函数名称: __pppOsOutput
diff --git a/SylixOS/shell/ttinyShell/ttinyShellReadline.c b/SylixOS/shell/ttinyShell/ttinyShellReadline.c
index d2c7b43..2948347 100644
--- a/SylixOS/shell/ttinyShell/ttinyShellReadline.c
+++ b/SylixOS/shell/ttinyShell/ttinyShellReadline.c
@@ -197,7 +197,9 @@ VOID __tshellHistoryBackup (PLW_CLASS_TCB ptcbDel)
{
__PSHELL_HISTORY_CTX psihc = __TTINY_SHELL_GET_HIS(ptcbDel);
- psihc->SIHC_bNeedBackup = LW_TRUE;
+ if (psihc) {
+ psihc->SIHC_bNeedBackup = LW_TRUE;
+ }
}
/*********************************************************************************************************
** 函数名称: __tshellTtyInputHistorySave
@@ -217,6 +219,9 @@ static VOID __tshellHistorySave (__PSHELL_INPUT_CTX psicContext)
LW_TCB_GET_CUR_SAFE(ptcbCur);
psihc = __TTINY_SHELL_GET_HIS(ptcbCur);
+ if (psihc == LW_NULL) {
+ return;
+ }
pring = psihc->SIHC_pringHeader;
while (pring) { /* 循环查找是否与以前的相同 */
@@ -279,8 +284,7 @@ static BOOL __tshellHistoryGet (BOOL bNext, PVOID *ppvCookie, __PSHELL_INPUT_
LW_TCB_GET_CUR_SAFE(ptcbCur);
psihc = __TTINY_SHELL_GET_HIS(ptcbCur);
-
- if (psihc->SIHC_pringHeader == LW_NULL) { /* 没有历史记录 */
+ if (!psihc || psihc->SIHC_pringHeader == LW_NULL) { /* 没有历史记录 */
return (LW_FALSE);
}
diff --git a/SylixOS/system/device/ty/tyLib.c b/SylixOS/system/device/ty/tyLib.c
index 2a4a0d9..8c9395d 100644
--- a/SylixOS/system/device/ty/tyLib.c
+++ b/SylixOS/system/device/ty/tyLib.c
@@ -55,6 +55,7 @@
2014.12.08 修正 _TyIRd() 忘记释放 spinlock 错误.
2015.05.07 优化中断程序操作.
2015.12.04 修正 SMP 并发操作问题.
+2020.06.23 提高 RAW 模式效率.
*********************************************************************************************************/
#define __SYLIXOS_KERNEL
#include "../SylixOS/kernel/include/k_kernel.h"
@@ -384,6 +385,8 @@ static VOID _TyFlushWrt (TY_DEV_ID ptyDev)
rngFlush(ptyDev->TYDEV_vxringidWrBuf);
+ ptyDev->TYDEV_tydevwrstat.TYDEVWRSTAT_bCR = LW_FALSE;
+
LW_SPIN_UNLOCK_QUICK(&ptyDev->TYDEV_slLock, iregInterLevel); /* 解锁 spinlock 并打开中断 */
ptyDev->TYDEV_tydevwrstat.TYDEVWRSTAT_bFlushingWrtBuf = LW_FALSE;
@@ -1266,23 +1269,40 @@ INT _TyIRd (TY_DEV_ID ptyDev, CHAR cInchar)
REGISTER INT iFreeBytes;
- if (ptyDev->TYDEV_pfuncProtoHook) {
- if ((*ptyDev->TYDEV_pfuncProtoHook)(ptyDev->TYDEV_iProtoArg,
- cInchar)) { /* 有链接的协议时调用协议栈 */
- return (iStatus);
+ if (LW_UNLIKELY(ptyDev->TYDEV_pfuncProtoHook)) {
+ if (ptyDev->TYDEV_pfuncProtoHook(ptyDev->TYDEV_iProtoArg,
+ cInchar) == ERROR_NONE) { /* 有链接的协议时调用协议栈 */
+ return (ERROR_NONE);
}
}
- if (iOpt & OPT_7_BIT) { /* 仅接收 7 位数据 */
- cInchar &= 0x7f;
- }
-
LW_SPIN_LOCK_QUICK(&ptyDev->TYDEV_slLock, &iregInterLevel); /* 锁定 spinlock 并关闭中断 */
if (ptyDev->TYDEV_tydevrdstat.TYDEVRDSTAT_bFlushingRdBuf) { /* 输入缓冲区是否被 FLUSH */
LW_SPIN_UNLOCK_QUICK(&ptyDev->TYDEV_slLock, iregInterLevel); /* 解锁 spinlock 打开中断 */
return (PX_ERROR);
}
+
+ if (iOpt == OPT_RAW) { /* 原始模式加速操作 */
+ if (RNG_ELEM_PUT(ptyDev->TYDEV_vxringidRdBuf, cInchar, iNTemp) == 0) {
+ iStatus = PX_ERROR; /* 写入输入队列 */
+ }
+ if (rngNBytes(ptyDev->TYDEV_vxringidRdBuf) == 1) {
+ bReleaseTaskLevel = LW_TRUE; /* 激活等待任务 */
+ } else {
+ bReleaseTaskLevel = LW_FALSE;
+ }
+ LW_SPIN_UNLOCK_QUICK(&ptyDev->TYDEV_slLock, iregInterLevel); /* 解锁 spinlock 打开中断 */
+
+ if (bReleaseTaskLevel) {
+ API_SemaphoreBPost(ptyDev->TYDEV_hRdSyncSemB); /* 激活等待任务 */
+ SEL_WAKE_UP_ALL(&ptyDev->TYDEV_selwulList, SELREAD); /* select() 激活 */
+ }
+ return (iStatus);
+
+ } else if (iOpt & OPT_7_BIT) {
+ cInchar &= 0x7f; /* 仅接收 7 位数据 */
+ }
if ((cInchar == __TTY_CC(ptyDev, VINTR)) &&
(iOpt & OPT_ABORT) &&