📄 net.c
字号:
NET_DBG_RSRC_TH_LO_HYST_DFLT);
#endif
#endif
#if (NET_DBG_CFG_MON_TASK_EN == DEF_ENABLED)
(void)NetDbg_CfgMonTaskTime(NET_DBG_MON_TASK_TIME_DFLT_SEC);
#endif
#ifdef NET_CONN_MODULE_PRESENT
/* ------------- CFG CONN INIT DFLT VALS -------------- */
(void)NetConn_CfgAccessedTh(NET_CONN_ACCESSED_TH_DFLT);
#endif
#ifdef NET_ARP_MODULE_PRESENT
/* -------------- CFG ARP INIT DFLT VALS -------------- */
(void)NetARP_CfgCacheTimeout(NET_ARP_CACHE_TIMEOUT_DFLT_SEC);
(void)NetARP_CfgCacheAccessedTh(NET_ARP_CACHE_ACCESSED_TH_DFLT);
(void)NetARP_CfgReqMaxRetries(NET_ARP_REQ_RETRY_DFLT);
(void)NetARP_CfgReqTimeout(NET_ARP_REQ_RETRY_TIMEOUT_DFLT_SEC);
#endif
/* -------------- CFG IP INIT DFLT VALS --------------- */
(void)NetIP_CfgAddrThisHost((NET_IP_ADDR)NET_IP_ADDR_NONE,
(NET_IP_ADDR)NET_IP_ADDR_NONE);
(void)NetIP_CfgAddrDfltGateway((NET_IP_ADDR)NET_IP_ADDR_NONE);
(void)NetIP_CfgFragReasmTimeout(NET_IP_FRAG_REASM_TIMEOUT_DFLT_SEC);
/* ------------- CFG ICMP INIT DFLT VALS -------------- */
#if (NET_ICMP_CFG_TX_SRC_QUENCH_EN == DEF_ENABLED)
(void)NetICMP_CfgTxSrcQuenchTh(NET_ICMP_TX_SRC_QUENCH_TH_DFLT);
#endif
#ifdef NET_TCP_MODULE_PRESENT
/* -------------- CFG TCP INIT DFLT VALS -------------- */
/* #### NOT yet implemented (remove if unnecessary). */
#endif
#ifdef NET_SOCK_MODULE_PRESENT
/* ------------- CFG SOCK INIT DFLT VALS -------------- */
/* #### NOT yet implemented (remove if unnecessary). */
#endif
}
/*$PAGE*/
/*
*********************************************************************************************************
* Net_VersionGet()
*
* Description : Get network protocol suite software version.
*
* Argument(s) : none.
*
* Return(s) : Network protocol suite software version.
*
* Caller(s) : Application.
*
* This function is a network protocol suite application interface (API) function & MAY be
* called by application function(s).
*
* Note(s) : none.
*********************************************************************************************************
*/
CPU_INT16U Net_VersionGet (void)
{
CPU_INT16U ver;
ver = NET_VERSION;
return (ver);
}
/*$PAGE*/
/*
*********************************************************************************************************
* Net_RxPktIsAvail()
*
* Description : Determine if any network receive packet(s) are available.
*
* Argument(s) : rx_chk_nbr Number of consecutive times that network receive packet availability has
* been checked (see Note #2b1).
*
* Return(s) : DEF_YES, network receive packet(s) available (see Note #2a1).
*
* DEF_NO, network receive packet(s) NOT available (see Note #2a2).
*
* Caller(s) : NetTCP_TxConnTxQ().
*
* This function is an INTERNAL network protocol suite function & SHOULD NOT be called by
* application function(s).
*
* Note(s) : (1) To balance network receive versus transmit packet loads for certain network connection
* types (e.g. stream-type connections), network receive & transmit packets SHOULD be
* handled in an APPROXIMATELY balanced ratio.
*
* (a) Network task priorities & lock mechanisms partially maintain a balanced ratio
* between network receive versus transmit packet handling.
*
* However, the handling of network receive & transmit packets :
*
* (1) SHOULD be interleaved so that for every few packet(s) received & handled,
* several packet(s) should be transmitted; & vice versa.
*
* (2) SHOULD NOT exclusively handle receive nor transmit packets, even for a
* short period of time.
*
* (b) To implement network receive versus transmit load balancing :
*
* (1) The availability of network receive packets MUST be managed at the network
* interface layer :
*
* (A) Increment the number of available network receive packets queued for
* each network packet received.
*
* (B) Decrement the number of available network receive packets queued for
* each received packet handled.
*
* See also 'net.h NETWORK RECEIVE PACKET MACRO'S Note #1'.
*
* (2) (a) To approximate a balanced ratio of network receive versus transmit packets
* handled; the availability of network receive packets returned is conditionally
* based on the consecutive number of times the availability is checked :
*
* (1) If the number of available network receive packets queued ('Net_RxPktCtr')
* is greater than the consecutive number of times the availability is checked
* ('rx_chk_nbr'), then the actual availability of network receive packet is
* returned.
*
* (2) Otherwise, no available network receive packets is returned -- even if
* network receive packets ARE available.
*
* (b) (1) The number of consecutive times that the network receive availability
* is checked ('rx_chk_nbr') SHOULD correspond to the consecutive number
* of times that a network transmit suspends itself to check for & handle
* any network receive packet(s).
*
* (2) (A) To check actual network receive packet availability,
* call Net_RxPktIsAvail() with 'rx_chk_nbr' always set to 0.
*
* (B) To check network receive packet availability consecutively,
* call Net_RxPktIsAvail() with 'rx_chk_nbr' initially set to 0 &
* incremented by 1 for each consecutive call thereafter.
*********************************************************************************************************
*/
#if (NET_CFG_LOAD_BAL_EN == DEF_ENABLED)
CPU_BOOLEAN Net_RxPktIsAvail (NET_CTR rx_chk_nbr)
{
#if (CPU_CFG_CRITICAL_METHOD == CPU_CRITICAL_METHOD_STATUS_LOCAL)
CPU_SR cpu_sr;
#endif
CPU_BOOLEAN rx_pkt_avail;
CPU_CRITICAL_ENTER();
rx_pkt_avail = (Net_RxPktCtr > rx_chk_nbr) ? DEF_YES : DEF_NO;
CPU_CRITICAL_EXIT();
return (rx_pkt_avail);
}
#endif
/*$PAGE*/
/*
*********************************************************************************************************
* Net_TxSuspend()
*
* Description : Suspend network transmit.
*
* Argument(s) : none.
*
* Return(s) : none.
*
* Caller(s) : NetTCP_TxConnTxQ().
*
* This function is an INTERNAL network protocol suite function & MUST NOT be called by
* application function(s).
*
* Note(s) : (1) To balance network receive versus transmit packet loads for certain network connection
* types (e.g. stream-type connections), network receive & transmit packets SHOULD be
* handled in an APPROXIMATELY balanced ratio.
*
* (a) Network task priorities & lock mechanisms partially maintain a balanced ratio
* between network receive versus transmit packet handling.
*
* However, the handling of network receive & transmit packets :
*
* (1) SHOULD be interleaved so that for every few packet(s) received & handled,
* several packet(s) should be transmitted; & vice versa.
*
* (2) SHOULD NOT exclusively handle receive nor transmit packets, even for a
* short period of time.
*
* (b) To implement network receive versus transmit load balancing :
*
* (2) Certain network connections MUST periodically suspend network transmit(s)
* to handle network receive packet(s) :
*
* (A) Suspend network transmit(s) if network receive packets are available.
*
* (1) To approximate a balanced ratio of network receive versus transmit
* packets handled; the number of consecutive times that a network
* transmit suspends itself to check for & handle any network receive
* packet(s) SHOULD APPROXIMATELY correspond to the number of queued
* network receive packet(s) availabile.
*
* See also 'Net_RxPktIsAvail() Note #2'.
*
* (2) To protect connections from transmit corruption while suspended,
* ALL transmit operations for suspended connections MUST be blocked
* until the connection is no longer suspended.
*
* See also 'net.h NETWORK RECEIVE PACKET MACRO'S Note #1'.
*********************************************************************************************************
*/
#if (NET_CFG_LOAD_BAL_EN == DEF_ENABLED)
void Net_TxSuspend (void)
{
#if (CPU_CFG_CRITICAL_METHOD == CPU_CRITICAL_METHOD_STATUS_LOCAL)
CPU_SR cpu_sr;
#endif
CPU_CRITICAL_ENTER();
if (Net_TxSuspendCtr < NET_CTR_MAX) {
Net_TxSuspendCtr++; /* Inc net tx suspend ctr. */
}
CPU_CRITICAL_EXIT();
NetOS_TxSuspendWait(); /* Wait on net tx suspend signal (see Note #1b2A). */
CPU_CRITICAL_ENTER();
if (Net_TxSuspendCtr > 0) {
Net_TxSuspendCtr--; /* Dec net tx suspend ctr. */
}
CPU_CRITICAL_EXIT();
}
#endif
/*$PAGE*/
/*
*********************************************************************************************************
* Net_TxSuspendSignal()
*
* Description : Signal suspended network transmit(s).
*
* Argument(s) : none.
*
* Return(s) : none.
*
* Caller(s) : NetIF_Pkt_RxHandlerLoadBal().
*
* This function is an INTERNAL network protocol suite function & MUST NOT be called by
* application function(s).
*
* Note(s) : (1) To balance network receive versus transmit packet loads for certain network connection
* types (e.g. stream-type connections), network receive & transmit packets SHOULD be
* handled in an APPROXIMATELY balanced ratio.
*
* (a) Network task priorities & lock mechanisms partially maintain a balanced ratio
* between network receive versus transmit packet handling.
*
* However, the handling of network receive & transmit packets :
*
* (1) SHOULD be interleaved so that for every few packet(s) received & handled,
* several packet(s) should be transmitted; & vice versa.
*
* (2) SHOULD NOT exclusively handle receive nor transmit packets, even for a
* short period of time.
*
* (b) To implement network receive versus transmit load balancing :
*
* (2) Certain network connections MUST periodically suspend network transmit(s)
* to handle network receive packet(s) :
*
* (B) Signal or timeout network transmit suspend(s) to restart transmit(s).
*
* See also 'net.h NETWORK RECEIVE PACKET MACRO'S Note #1'.
*********************************************************************************************************
*/
#if (NET_CFG_LOAD_BAL_EN == DEF_ENABLED)
void Net_TxSuspendSignal (void)
{
#if (CPU_CFG_CRITICAL_METHOD == CPU_CRITICAL_METHOD_STATUS_LOCAL)
CPU_SR cpu_sr;
#endif
NET_CTR nbr_net_tx_suspend;
NET_CTR i;
CPU_CRITICAL_ENTER();
nbr_net_tx_suspend = Net_TxSuspendCtr;
CPU_CRITICAL_EXIT();
for (i = 0; i < nbr_net_tx_suspend; i++) {
NetOS_TxSuspendSignal(); /* Signal ALL suspended net tx's (see Note #1b2B). */
}
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -