In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)05/31 Report--
This article will explain in detail how to achieve SylixOS network card driver optimization, the content of the article is of high quality, so the editor will share it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
1. Development environment
Operating system: SylixOS
Programming environment: RealEvo-IDE3.1
Hardware platform: AT9x25 development board
1. Technical realization
After the completion of the network card driver, which can achieve the basic sending and receiving functions, this article will briefly introduce how to optimize the sending function of the network card driver to improve the throughput and real-time performance.
1.1 Optimization of network card transmission throughput
The network card driver can improve the transmission throughput by means of zero copy. The enetCoreTx sending function is called in the driver to send Ethernet messages. This function takes two parameters, the netdev struct type pointer and the pbuf type pointer. EnetCoreTx copies what the pbuf points to to the DMA send buffer pointed to by the send descriptor. This copy has a certain impact on the send throughput.
Therefore, during optimization, the buffer address pointed to by the DMA descriptor can be changed to payload, a member of the pbuf structure, to the address that really needs to send the message. The specific implementation is shown in listing 21.
Program listing 21 Zero copy Optimization
If (usLen = = pstPbuf- > len) {if ((pstPbuf- > type! = PBUF_REF) & & (pstPbuf- > type! = PBUF_ROM)) {bCopy = LW_FALSE;}} if (! bCopy) {pbuf_ref (pstPbuf); pEnet- > pTxRing [ihead] .iTxBaddr = (UINT32) pstPbuf- > payload; API_CacheFlushPage (DATA_CACHE,pstPbuf- > payload, pstPbuf- > payload, LW_CFG_VMM_PAGE_SIZE) } else {pEnet- > pTxBaddr = (UINT32) pEnet- > NET_ pTxInfo.TXI _ pvDmaAddr; pbuf_copy_partial (pstPbuf, (PVOID) (pEnet- > pTxRing [iHead] .iTxBaddr), iTxBaddr, usLen, 0);}
The bCopy variable in the above code indicates whether a zero-copy operation is required.
When using zero-copy optimization, you need to be aware of the following:
1. Zero copy cannot be made when the pbuf type is REF or ROM.
2. When making zero copy, you need to call the API_CacheFlushPage function to clear cache. At the same time, the pbuf_ref function needs to be called to add 1 to the member ref value of pbuf.
3. After calling the pbuf_ref function, you need to manually free the zero-copy pbuf in the interrupt. The function pbuf_free is called when free. But because this operation is done in an interrupt, an error will be reported if the function is called directly in the interrupt service function. When you implement it, you can use the work queue to add the operations that need to release pbuf to the work queue.
2.2 Network card driver real-time transmission
When the network card driver sends, we need to judge whether the current descriptor can be used to send the message. The general operation is to wait through a while loop, and then send when there is a descriptor available. This will have a certain impact on real-time performance.
Here, semaphores can be used to optimize the transmission process, so as to optimize the real-time performance of network transmission.
First, create a counting semaphore when the network is initialized. The numeric value is the number of send descriptors currently set.
When you need to send, you need to call the API_SemaphoreCPend function to get the semaphore, and then you can do the following send operation.
Similarly, in the interrupt service function, if the interrupt is detected to be sent successfully, the API_SemaphoreCPost function needs to be called to release the semaphore.
The specific implementation is shown in listing 22 and listing 23.
Listing 22 gets the semaphore
# ifAT_TX_REALTIME > 0 API_SemaphoreCPend (pEnet- > NET_hTxRdyCnt,LW_OPTION_WAIT_INFINITE); # else
Listing 23 releases the semaphore
# ifAT_TX_REALTIME > 0 API_SemaphoreCPost (pEnet- > NET_hTxRdyCnt); # endif is here on how to optimize the SylixOS Nic driver. I hope the above content can be helpful to you and learn more. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.