WO2016101485A1 - Method and device for writing tcam entries - Google Patents

Method and device for writing tcam entries Download PDF

Info

Publication number
WO2016101485A1
WO2016101485A1 PCT/CN2015/078209 CN2015078209W WO2016101485A1 WO 2016101485 A1 WO2016101485 A1 WO 2016101485A1 CN 2015078209 W CN2015078209 W CN 2015078209W WO 2016101485 A1 WO2016101485 A1 WO 2016101485A1
Authority
WO
WIPO (PCT)
Prior art keywords
tcam
data block
predetermined data
writing
entry
Prior art date
Application number
PCT/CN2015/078209
Other languages
French (fr)
Chinese (zh)
Inventor
姜海明
朱延灵
Original Assignee
中兴通讯股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2016101485A1 publication Critical patent/WO2016101485A1/en

Links

Images

Classifications

    • GPHYSICS
    • G11INFORMATION STORAGE
    • G11CSTATIC STORES
    • G11C15/00Digital stores in which information comprising one or more characteristic parts is written into the store and in which information is read-out by searching for one or more of these characteristic parts, i.e. associative or content-addressed stores
    • G11C15/04Digital stores in which information comprising one or more characteristic parts is written into the store and in which information is read-out by searching for one or more of these characteristic parts, i.e. associative or content-addressed stores using semiconductor elements

Definitions

  • This paper relates to the field of communications, and in particular to a method and apparatus for writing TCAM entries.
  • ASIC Application Specific Integrated Circuit
  • NP Network Processor
  • SRAM Static Random Access Memory
  • TCAM Ternary Content Addressable Memory
  • SDRAM Synchronous Dynamic Random Memory
  • the TCAM update method is a single update, and the rate is very slow.
  • an access control list (ACL) is used to configure an ACL to contain 2K entries. 2K TCAM entries are sent one by one, and each is sent to the TCAM.
  • ACL access control list
  • the disadvantage of this method is that each TCAM entry is written to the TCAM hardware and requires full CPU intervention. The hardware is written byte by byte under the control of the CPU, and the completion of the write hardware requires the CPU to know that the update is completed by hardware interrupt or CPU polling, so that one can start writing one. If the user configures the ACL to include 30K entries, it takes a long time to write all the TCAMs, which may reach ten or even tens of seconds.
  • the present invention provides a method and apparatus for writing a TCAM entry to solve the problem that the TCAM entry is written to the TCAM one by one in the related art, and the write rate is low.
  • a method of writing a TCAM entry comprising: writing a predetermined data block to a first in first out FIFO buffer of a TCAM interface by direct memory access DMA, wherein the predetermined data block includes a plurality of TCAM entries; The plurality of TCAM entries are written to the TCAM.
  • the method before writing the predetermined data block to the FIFO buffer of the TCAM interface by direct memory access DMA, the method further comprises: acquiring the predetermined data block.
  • acquiring the predetermined data block comprises: converting, by the central processing unit, the TCAM data into a TCAM entry; writing the converted TCAM entry into the buffer space to obtain the predetermined data block.
  • writing the converted TCAM entry into the buffer space to obtain the predetermined data block comprises: determining whether the written TCAM entry is the last TCAM entry converted according to the TCAM data; If not, the next TCAM entry obtained by the conversion is continuously written into the buffer space; if the determination result is yes, the formed by the plurality of TCAM entries written is obtained from the cache space.
  • the predetermined data block is described.
  • writing the predetermined data block to the FIFO buffer of the TCAM interface by using the direct memory access DMA includes: determining the predetermined data block according to the physical address of the predetermined data block, the FIFO cache address, and the data block size. Write to the FIFO buffer.
  • An apparatus for writing a TCAM entry comprising: a first write module configured to: write a predetermined data block into a first in first out FIFO buffer of a TCAM interface by direct memory access DMA, wherein the predetermined data block includes a TCAM entry; a second write module configured to: write the plurality of TCAM entries in the FIFO buffer to the TCAM.
  • the device further includes: an obtaining module, configured to: acquire the predetermined data block.
  • the obtaining module includes: a converting unit, configured to: the central processing unit CPU converts the TCAM data into a TCAM entry; and the writing unit is configured to: write the converted TCAM entry into the buffer space, to obtain the Predetermine the data block.
  • the writing unit includes: determining a secondary unit, configured to: determine whether the written TCAM entry is the last TCAM entry converted according to the TCAM data; and the first write secondary unit is set to: If the result of the determination is no, the next TCAM entry obtained by the conversion is continuously written into the buffer space; the second write secondary unit is set as: In the case of the cache space, the predetermined data block formed by the plurality of TCAM entries written is acquired.
  • the first writing module is configured to: write the predetermined data block into the FIFO buffer according to a physical address, a FIFO buffer address, and a data block size of the predetermined data block.
  • the TCAM solves the problem in the related art that when the TCAM entries are written one by one, the CPU needs to be fully intervened, the write rate is low, and the CPU resource overhead is large, and the TCAM entries are written in batches, and the TCAM entries are written. effectiveness.
  • FIG. 1 is a flow chart of a method of writing a TCAM entry in accordance with an embodiment of the present invention
  • FIG. 2 is a flow chart of another method of writing a TCAM entry in accordance with an embodiment of the present invention.
  • FIG. 3 is a block diagram showing the structure of a device for writing a TCAM entry according to an embodiment of the present invention
  • FIG. 4 is a block diagram showing another structure of a device for writing a TCAM entry according to an embodiment of the present invention.
  • FIG. 5 is a structural block diagram of an acquisition module 40 for writing a TCAM entry device according to an embodiment of the present invention
  • FIG. 6 is a block diagram showing the structure of a write unit 402 for writing a TCAM entry device according to an embodiment of the present invention
  • FIG. 7 is a schematic diagram of a connection relationship of a CPU, an NP, a TCAM, and a DMA for writing a TCAM entry according to an embodiment of the present invention
  • FIG. 8 is a flow chart of a method of writing a TCAM entry in accordance with a preferred embodiment of the present invention.
  • FIG. 1 is a flowchart according to an embodiment of the present invention. As shown in FIG. 1, the process may include the following steps:
  • Step S100 writing a predetermined data block to the FIFO buffer of the TCAM interface by direct memory access DMA, wherein the predetermined data block includes a plurality of TCAM entries;
  • Step S102 writing the plurality of TCAM entries in the FIFO buffer to the TCAM.
  • the network chip TCAM interface usually has a FIFO buffer inside, and writes TCAM entries in the FIFO buffer to the TCAM through the physical bus between the network chip and the external TCAM.
  • a plurality of TCAM entries cached by the DMA are used to write the TCAM adaptation module FIFO buffer of the network chip at one time, and the DMA controller can quickly access the internal module of the network chip and the characteristics of less CPU resource overhead, and the related technology is solved.
  • the CPU needs full intervention, the write rate is low, and the CPU resource overhead is large, and the TCAM entries are written in batches, and the efficiency of writing TCAM entries is improved.
  • FIG. 2 is a flowchart according to an embodiment of the present invention. As shown in FIG. 2, the process may include the following steps:
  • Step S200 acquiring a predetermined data block
  • Step S202 writing a predetermined data block to the FIFO buffer of the TCAM interface by direct memory access DMA, wherein the predetermined data block includes a plurality of TCAM entries;
  • Step S204 writing the plurality of TCAM entries in the FIFO buffer to the TCAM.
  • obtaining the predetermined data block may include: converting, by the central processing unit, the TCAM data into a TCAM entry; writing the converted TCAM entry into a buffer space (ie, a memory) to obtain the predetermined data block.
  • the CPU control layer converts the service data related to the upper layer service (for example, ACL, flow mirroring, and the like) into a TCAM entry according to the TCAM storage format, where the TCAM entry is used for the packet lookup table of the upper layer service traffic forwarding.
  • the converted TCAM entry is written to the cache space.
  • the size of the cache space can be adjusted according to the number of TCAM entries.
  • writing the converted TCAM entry into the buffer space to obtain the predetermined data block may include: determining whether the written TCAM entry is the last TCAM entry converted according to the TCAM data; If the result is no, continue to convert the resulting The next TCAM entry is written to the cache space; if the result of the determination is YES, the predetermined data block formed by the written plurality of TCAM entries is acquired from the cache space.
  • the CPU control plane writes multiple TCAM entries one by one to the DMA. In order to save time and improve efficiency, it is necessary to write all the TCAM entries into the memory, and then start the TCAM interface that writes the TCAM entries from the memory to the network chip. FIFO buffer. If the multiple TCAM entries are not all written to the DMA, the CPU control plane will continue to write the remaining TCAM entries to memory until all are written to the memory.
  • the ACL Access Control List
  • the user configures an ACL to contain 2000 entries. Up to 2000 TCAM entries are written to the memory. The cache space of the memory stops acquiring multiple TCAM entries of the ACL. 2000 entries have all been written to the DMA cache space.
  • the writing of the predetermined data block to the FIFO buffer of the TCAM interface by direct memory access DMA may further include: determining, according to the physical address of the predetermined data block, the FIFO cache address, and the data. A block size that writes the predetermined block of data to the FIFO buffer.
  • the network chip configures the DMA controller to write the TCAM entry from the memory into the FIFO buffer of the TCAM interface of the network chip through the CPU interface of the network chip.
  • the network chip turns on the DMA transfer to write the TCMA entry into the FIFO buffer, needs to specify the physical address of the predetermined data block, the FIFO cache address, and the data block size, writes the predetermined data block to the FIFO buffer, and then writes the data to the TCAM through the physical bus. hardware.
  • the DMA controller of the network chip is used to write a plurality of TCAM entries in the DMA buffer to the FIFO buffer of the TCAM interface of the network chip in batches, and the DMA controller can quickly access the characteristics of the internal modules of the network chip.
  • TCAM entries can be quickly written to the hardware, increasing the efficiency of writing TCAM entries and reducing CPU usage.
  • FIG. 3 is a structural block diagram of an apparatus for writing a TCAM entry according to an embodiment of the present invention. As shown in FIG. 3, the apparatus may include:
  • the first write module 30 is configured to: write a predetermined data block into the FIFO FIFO buffer of the TCAM interface by direct memory access DMA, wherein the predetermined data block includes a plurality of TCAM entries; and the second write module 32 Connected to the first write module 30, set to: FIFO in the buffer The plurality of TCAM entries are written to the TCAM.
  • FIG. 4 is a structural block diagram of another apparatus for writing a TCAM entry according to an embodiment of the present invention. As shown in FIG. 4, the apparatus may include:
  • the obtaining module 40 is configured to: acquire the predetermined data block; the first writing module 42 is connected to the obtaining module 40, and is configured to: write the predetermined data block into the first-in first-out FIFO buffer of the TCAM interface by direct memory access DMA
  • the predetermined data block includes a plurality of TCAM entries; the second write module 44 is coupled to the first write module 42 and configured to write the plurality of TCAM entries in the FIFO buffer to the TCAM.
  • the obtaining module 40 may further include: a converting unit 401 configured to: convert the TCAM data into a TCAM entry; and the writing unit 402 is connected to the converting unit 401, and is configured to: convert the obtained A TCAM entry is written to the cache space to obtain the predetermined data block.
  • a converting unit 401 configured to: convert the TCAM data into a TCAM entry
  • the writing unit 402 is connected to the converting unit 401, and is configured to: convert the obtained A TCAM entry is written to the cache space to obtain the predetermined data block.
  • the writing unit 402 may further include: a determining sub-unit 4021, configured to: determine whether the written TCAM entry is the last TCAM entry converted according to the TCAM data; the first write The sub-unit 4022 is connected to the judging sub-unit 4021, and is configured to: continue to write the converted next TCAM entry into the buffer space if the determination result is no; the second write sub-unit 4023 is connected to The first write subunit 4022 is configured to: when the determination result is YES, acquire the predetermined data block formed by the written plurality of TCAM entries from the cache space.
  • a determining sub-unit 4021 configured to: determine whether the written TCAM entry is the last TCAM entry converted according to the TCAM data
  • the first write The sub-unit 4022 is connected to the judging sub-unit 4021, and is configured to: continue to write the converted next TCAM entry into the buffer space if the determination result is no
  • the second write sub-unit 4023 is connected to The first write subunit 4022 is configured to: when the determination result is
  • the first write module 30 and the first write module 42 may be further configured to: according to the physical address of the predetermined data block, the FIFO cache address, and the data block size. A predetermined data block is written to the FIFO buffer.
  • a plurality of TCAM entries are written into the buffer space by the CPU, and the network chip writes a plurality of TCAM entries in the memory into the FIFO buffer in the network chip in batches through the DMA controller, and then passes through the physical bus.
  • Writing TCAM entries to the external TCAM solves the problem that the TCAM entries are written to the TCAM one by one, and the write rate is low, which enables batch writing of TCAM entries, improves the efficiency of writing TCAM entries, and reduces CPU consumption.
  • first write module 30, the second write module 32, and the first mentioned above The writing module 42 and the second writing module 44, or the functions and functions of the first writing sub-unit 4022 and the second writing sub-unit 4023 are the same or similar, they may be the same module, or may be different. Module.
  • FIG. 7 is a schematic diagram of a connection relationship of a CPU, an NP, and a TCAM for writing a TCAM entry according to an embodiment of the present invention, and FIG. 7 is as follows:
  • the central processing unit CPU 70 is connected to the network processor NP through the data bus PCI-E, and is configured to convert the related data of the upper layer service message into a TCAM entry according to the TCAM storage format, and in the DDR3 SDRAM (Double Data Rate 3 Synchronous Dynamic) Random Access Memory (eight times data rate synchronous dynamic random access memory) applies for cache space.
  • DDR3 SDRAM Double Data Rate 3 Synchronous Dynamic Random Access Memory
  • DDR3 SDRAM 72 connected to CPU 70, is set to: cache multiple TCAM entries.
  • An NP (Network Processer) 74 is connected to the TCAM 76.
  • the NP 74 internally includes a CPU interface 741 and a TCAM interface 742.
  • the TCAM interface 742 has a first in first out FIFO buffer.
  • the CPU interface 741 has a DMA controller inside, and the NP can access the DDR3 SDRAM 72 through the DMA controller to enable DMA transfer, and the entire block of data can be transmitted without intervention by the CPU.
  • the DMA can support fast access to NP internal modules.
  • the data stored in the DDR3 SDRAM 72 is written to the FIFO buffer. Each transfer requires specifying the physical address of the data source, the address of the destination NP internal block, and the block size, and then turning on DMA transfer, which allows quick access to the NP internal block.
  • TCAM 76 interconnected with NP 74 via the Interlaken bus.
  • FIG. 8 is a flowchart according to an embodiment of the present invention. As shown in FIG. 8, the process includes the following steps:
  • Step S800 the CPU control plane applies for a cache space
  • the CPU control requests a contiguous physical memory for the DDR3 SDRAM to be used as the buffer space.
  • the cache space is used to cache the TCAM entries assembled by the CPU control plane, and can accept the network chip DMA controller or the DMA memory.
  • the size of the cache space is related to the upper layer service. For example, the fourth generation Internet Protocol Version 4 (IPV4) IPV4 ACL, the user configures an ACL instance, up to 32K TCAM entries, and each TCAM entry is wide. The degree is 20 bytes, and the size of the cache space can be defined as 32K*20 bytes.
  • Step S802 the CPU control plane assembles the TCAM entry
  • the CPU control plane converts the service-related data sent by the upper-layer application into the data format of the TCAM write table, that is, the TCAM entry, including the TCAM entry physical address and the write table data, according to the TCAM data format.
  • Step S804 writing a TCAM entry into the buffer space
  • the TCAM entries assembled in step S802 are written one by one into the DMA buffer, that is, the DDR3 SDRAM buffer space requested by the CPU in step S800.
  • Step S806 determining whether the TCAM entry is the last one
  • the CPU thread maintains a global variable N and records the current cache space address.
  • N starts at 0 and corresponds to the Nth entry in the cache.
  • the global variable N N+1.
  • the 32K entry is the last TCAM entry.
  • the process jumps to step S802 to continue assembling the next TCAM entry and buffering it into the N+1th cache address in the cache space.
  • Step S808 writing a TCAM entry in the cache space to the FIFO buffer
  • the network chip turns on DMA transfer, and by configuring the DMA controller, the data is written into the FIFO buffer in the TCAM interface of the NP through the CPU interface of the NP.
  • the CPU interface of the NP usually has a DMA controller, which can perform the whole block data transmission without the intervention of the CPU.
  • the DMA can support fast access to NP internal modules. Each transfer requires specifying the physical address of the data source, the address of the destination NP internal module, and the data block size.
  • the DMA transfer is enabled, which allows quick access to the NP internal modules, including the TCAM interface in the NP and the FIFO buffer in the TCAM interface.
  • Step S810 writing a TCAM entry in the FIFO buffer to the TCAM.
  • the NP writes the TCAM entry in the FIFO buffer to the TCAM hardware via the Interlaken bus between the NP and the external TCAM.
  • TCAM entries are written one by one in an update manner, each time a TCAM entry is transmitted At the same time, it is necessary to participate in controlling the data movement, the CPU resource overhead is large, and the TCAM entry is updated slowly.
  • the method provided by the embodiment of the invention can quickly access the internal module of the network chip and the characteristic of low CPU resource consumption by using the DMA controller, and write the cached plurality of TCAM entries into the TCAM of the NP in batches through the NP controller of the NP.
  • the adapter module FIFO buffer enables fast writing of TCAM entries to the TCAM, reducing CPU usage.
  • the embodiment of the present invention provides a novel TCAM batch write table fast update method, which applies a cache space to the memory by the CPU, and caches multiple TCAM entries sent by the upper layer service until the last TCAM entry. After the completion of the delivery, the write operation is triggered; in the case of a small amount of CPU intervention, the network chip can use the DMA controller to write TCAM entries in batches, enabling fast writing of TCAM entries and reducing CPU usage.
  • the method and device for writing TCAM entries provided in this paper have fast TCAM entries and low CPU usage, and have great promotion and application value.
  • all or part of the steps of the above embodiments may also be implemented by using an integrated circuit. These steps may be separately fabricated into individual integrated circuit modules, or multiple modules or steps may be fabricated into a single integrated circuit module. achieve.
  • the devices/function modules/functional units in the above embodiments may be implemented by a general-purpose computing device, which may be centralized on a single computing device or distributed over a network of multiple computing devices.
  • the device/function module/functional unit in the above embodiment When the device/function module/functional unit in the above embodiment is implemented in the form of a software function module and sold or used as a stand-alone product, it can be stored in a computer readable storage medium.
  • the above mentioned computer readable storage medium may be a read only memory, a magnetic disk or an optical disk or the like.
  • This document uses a FIFO buffer for writing a predetermined data block to a TCAM interface by DMA, wherein the predetermined data block includes a plurality of TCAM entries; writing the plurality of TCAM entries in the FIFO buffer to the TCAM to solve
  • the CPU needs to intervene in a whole process, the write rate is low, and the CPU resource overhead is large, and the TCAM entry is written in batches, and the efficiency of writing the TCAM entry is improved.

Abstract

A method and device for writing TCAM entries. The method comprises: writing a predetermined data block into a first in first out (FIFO) buffer of a TCAM interface by means of direct memory access (DMA), the predetermined data block comprising multiple TCAM entries; and writing the TCAM entries in the FIFO buffer into a TCAM.

Description

一种写入TCAM条目的方法及装置Method and device for writing TCAM entries 技术领域Technical field
本文涉及通信领域,尤其涉及一种写入TCAM条目的方法及装置。This paper relates to the field of communications, and in particular to a method and apparatus for writing TCAM entries.
背景技术Background technique
现今网络发展速度惊人,网络流量的增长及新业务的出现,需要网络设备具有线速和灵活的处理能力。目前网络芯片包括专用集成电路(Application Specific Integrated Circuit,简称为ASIC)和网络处理器(Network Processor,简称为NP)两大类。网络处理器凭借其高速处理及灵活的可编程性,已成为当今网络中数据处理的有效解决方案。网络处理器中有多种不同的存储器,如静态随机存储器(Static Random Access Memory,简称为SRAM)、三态内容寻址存储器(Ternary Content Addressable Memory,简称为TCAM)、同步动态随机存储器(Synchronous Dynamic Random Access Memory,简称为SDRAM)等,这些存储器存放着各种业务表项,如端口表、MAC表、路由表等。Today's network development is amazing, network traffic growth and the emergence of new services require network equipment to have wire-speed and flexible processing capabilities. Currently, the network chip includes two types: Application Specific Integrated Circuit (ASIC) and Network Processor (NP). With its high-speed processing and flexible programmability, network processors have become an effective solution for data processing in today's networks. There are many different memories in the network processor, such as Static Random Access Memory (SRAM), Ternary Content Addressable Memory (TCAM), Synchronous Dynamic Random Memory (Synchronous Dynamic). Random Access Memory (SDRAM), etc., these memories store various business items, such as port tables, MAC tables, routing tables, and so on.
相关技术中,TCAM更新方法是单条更新,速率很慢。以访问控制列表(Access Control List,简称为ACL)为例,用户配置一个ACL包含2K个条目,2K个TCAM条目是一条一条下发,每条下发都写入TCAM。这种方法缺点是每一条TCAM条目写入TCAM硬件,需要CPU全程干预。在CPU控制下逐字节地写硬件,而且在写硬件完成需要通过硬件中断或者CPU轮询方式让CPU获知更新完成,这样才能开始写下一条。如果用户配置ACL包含30K条目情况下,全部写入TCAM需要很长时间,可能达到十几秒钟甚至几十秒。In the related art, the TCAM update method is a single update, and the rate is very slow. For example, an access control list (ACL) is used to configure an ACL to contain 2K entries. 2K TCAM entries are sent one by one, and each is sent to the TCAM. The disadvantage of this method is that each TCAM entry is written to the TCAM hardware and requires full CPU intervention. The hardware is written byte by byte under the control of the CPU, and the completion of the write hardware requires the CPU to know that the update is completed by hardware interrupt or CPU polling, so that one can start writing one. If the user configures the ACL to include 30K entries, it takes a long time to write all the TCAMs, which may reach ten or even tens of seconds.
发明内容Summary of the invention
本文提供了一种写入TCAM条目的方法及装置,以解决相关技术中TCAM条目是逐条写入TCAM,写入速率较低的问题。 The present invention provides a method and apparatus for writing a TCAM entry to solve the problem that the TCAM entry is written to the TCAM one by one in the related art, and the write rate is low.
一种写入TCAM条目的方法,包括:通过直接内存存取DMA将预定数据块写入TCAM接口的先进先出FIFO缓存,其中,所述预定数据块包括多条TCAM条目;将FIFO缓存中的所述多条TCAM条目写入TCAM。A method of writing a TCAM entry, comprising: writing a predetermined data block to a first in first out FIFO buffer of a TCAM interface by direct memory access DMA, wherein the predetermined data block includes a plurality of TCAM entries; The plurality of TCAM entries are written to the TCAM.
可选地,在通过直接内存存取DMA将预定数据块写入TCAM接口的FIFO缓存之前,所述方法还包括:获取所述预定数据块。Optionally, before writing the predetermined data block to the FIFO buffer of the TCAM interface by direct memory access DMA, the method further comprises: acquiring the predetermined data block.
可选地,获取所述预定数据块包括:中央处理器CPU将TCAM数据转换为TCAM条目;将转换得到的TCAM条目写入缓存空间,以得到所述预定数据块。Optionally, acquiring the predetermined data block comprises: converting, by the central processing unit, the TCAM data into a TCAM entry; writing the converted TCAM entry into the buffer space to obtain the predetermined data block.
可选地,将转换得到的TCAM条目写入所述缓存空间,以得到所述预定数据块包括:判断写入的TCAM条目是否是根据所述TCAM数据转换得到的最后一条TCAM条目;在判断结果为否的情况下,继续将转换得到的下一条TCAM条目写入所述缓存空间;在判断结果为是的情况下,从所述缓存空间获取由写入的所述多条TCAM条目形成的所述预定数据块。Optionally, writing the converted TCAM entry into the buffer space to obtain the predetermined data block comprises: determining whether the written TCAM entry is the last TCAM entry converted according to the TCAM data; If not, the next TCAM entry obtained by the conversion is continuously written into the buffer space; if the determination result is yes, the formed by the plurality of TCAM entries written is obtained from the cache space. The predetermined data block is described.
可选地,通过直接内存存取DMA将预定数据块写入TCAM接口的先进先出FIFO缓存包括:根据所述预定数据块的物理地址、FIFO缓存地址以及数据块大小,将所述预定数据块写入所述FIFO缓存。Optionally, writing the predetermined data block to the FIFO buffer of the TCAM interface by using the direct memory access DMA includes: determining the predetermined data block according to the physical address of the predetermined data block, the FIFO cache address, and the data block size. Write to the FIFO buffer.
一种写入TCAM条目的装置,包括:第一写入模块,设置为:通过直接内存存取DMA将预定数据块写入TCAM接口的先进先出FIFO缓存,其中,所述预定数据块包括多条TCAM条目;第二写入模块,设置为:将FIFO缓存中的所述多条TCAM条目写入所述TCAM。An apparatus for writing a TCAM entry, comprising: a first write module configured to: write a predetermined data block into a first in first out FIFO buffer of a TCAM interface by direct memory access DMA, wherein the predetermined data block includes a TCAM entry; a second write module configured to: write the plurality of TCAM entries in the FIFO buffer to the TCAM.
可选地,所述装置还包括:获取模块,设置为:获取所述预定数据块。Optionally, the device further includes: an obtaining module, configured to: acquire the predetermined data block.
可选地,所述获取模块包括:转换单元,设置为:中央处理器CPU将TCAM数据转换为TCAM条目;写入单元,设置为:将转换得到的TCAM条目写入缓存空间,以得到所述预定数据块。Optionally, the obtaining module includes: a converting unit, configured to: the central processing unit CPU converts the TCAM data into a TCAM entry; and the writing unit is configured to: write the converted TCAM entry into the buffer space, to obtain the Predetermine the data block.
可选地,所述写入单元包括:判断次单元,设置为:判断写入的TCAM条目是否是根据所述TCAM数据转换得到的最后一条TCAM条目;第一写入次单元,设置为:在判断结果为否的情况下,继续将转换得到的下一条TCAM条目写入所述缓存空间;第二写入次单元,设置为:在判断结果为是 的情况下,从所述缓存空间获取由写入的所述多条TCAM条目形成的所述预定数据块。Optionally, the writing unit includes: determining a secondary unit, configured to: determine whether the written TCAM entry is the last TCAM entry converted according to the TCAM data; and the first write secondary unit is set to: If the result of the determination is no, the next TCAM entry obtained by the conversion is continuously written into the buffer space; the second write secondary unit is set as: In the case of the cache space, the predetermined data block formed by the plurality of TCAM entries written is acquired.
可选地,所述第一写入模块是设置为:根据所述预定数据块的物理地址、FIFO缓存地址以及数据块大小,将所述预定数据块写入所述FIFO缓存。Optionally, the first writing module is configured to: write the predetermined data block into the FIFO buffer according to a physical address, a FIFO buffer address, and a data block size of the predetermined data block.
本文采用通过直接内存存取DMA将预定数据块写入TCAM接口的先进先出FIFO缓存,其中,所述预定数据块包括多条TCAM条目;将FIFO缓存中的所述多条TCAM条目写入所述TCAM,解决了相关技术中,在逐条写入TCAM条目时,需要CPU全程干预,写入速率较低、CPU资源开销大的问题,实现了批量写入TCAM条目,提高了写入TCAM条目的效率。A FIFO buffer for writing a predetermined block of data to a TCAM interface by direct memory access DMA, wherein the predetermined block of data includes a plurality of TCAM entries; writing the plurality of TCAM entries in the FIFO buffer The TCAM solves the problem in the related art that when the TCAM entries are written one by one, the CPU needs to be fully intervened, the write rate is low, and the CPU resource overhead is large, and the TCAM entries are written in batches, and the TCAM entries are written. effectiveness.
附图概述BRIEF abstract
图1是根据本发明实施例的一种写入TCAM条目的方法的流程图;1 is a flow chart of a method of writing a TCAM entry in accordance with an embodiment of the present invention;
图2是根据本发明实施例的另一种写入TCAM条目的方法的流程图;2 is a flow chart of another method of writing a TCAM entry in accordance with an embodiment of the present invention;
图3是根据本发明实施例的一种写入TCAM条目装置的结构框图;3 is a block diagram showing the structure of a device for writing a TCAM entry according to an embodiment of the present invention;
图4是根据本发明实施例的另一种写入TCAM条目装置的结构框图;4 is a block diagram showing another structure of a device for writing a TCAM entry according to an embodiment of the present invention;
图5是根据本发明实施例的一种写入TCAM条目装置的获取模块40的结构框图;FIG. 5 is a structural block diagram of an acquisition module 40 for writing a TCAM entry device according to an embodiment of the present invention;
图6是根据本发明实施例的一种写入TCAM条目装置的写入单元402的结构框图;6 is a block diagram showing the structure of a write unit 402 for writing a TCAM entry device according to an embodiment of the present invention;
图7是根据本发明实施例的一种用于写入TCAM条目的CPU、NP、TCAM、DMA的连接关系示意图;7 is a schematic diagram of a connection relationship of a CPU, an NP, a TCAM, and a DMA for writing a TCAM entry according to an embodiment of the present invention;
图8是根据本发明优选实施例的一种写入TCAM条目的方法的流程图。8 is a flow chart of a method of writing a TCAM entry in accordance with a preferred embodiment of the present invention.
本发明的实施方式Embodiments of the invention
下文中将参考附图对本发明的实施例进行说明。需要说明的是,在不冲突的情况下,本文中的实施例及实施例中的特征可以相互组合。 Embodiments of the present invention will be described hereinafter with reference to the accompanying drawings. It should be noted that, in the case of no conflict, the embodiments in the embodiments and the features in the embodiments may be combined with each other.
在发明本实施例中提供了一种写入TCAM条目的方法,图1是根据本发明实施例的流程图,如图1所示,该流程可以包括如下步骤:In the embodiment of the present invention, a method for writing a TCAM entry is provided. FIG. 1 is a flowchart according to an embodiment of the present invention. As shown in FIG. 1, the process may include the following steps:
步骤S100,通过直接内存存取DMA将预定数据块写入TCAM接口的先进先出FIFO缓存,其中,所述预定数据块包括多条TCAM条目;Step S100, writing a predetermined data block to the FIFO buffer of the TCAM interface by direct memory access DMA, wherein the predetermined data block includes a plurality of TCAM entries;
步骤S102,将FIFO缓存中的所述多条TCAM条目写入TCAM。网络芯片TCAM接口内部通常有FIFO缓存,将FIFO缓存中的多条TCAM条目通过网络芯片与外部TCAM之间的物理总线将TCAM条目写入TCAM。Step S102, writing the plurality of TCAM entries in the FIFO buffer to the TCAM. The network chip TCAM interface usually has a FIFO buffer inside, and writes TCAM entries in the FIFO buffer to the TCAM through the physical bus between the network chip and the external TCAM.
本实施例通过DMA缓存的多条TCAM条目,一次性写入网络芯片的TCAM适配模块FIFO缓存,利用DMA控制器可以快速访问网络芯片内部模块及其CPU资源开销少的特性,解决了相关技术中,在逐条写入TCAM条目时,需要CPU全程干预,写入速率较低、CPU资源开销大的问题,实现了批量写入TCAM条目,提高了写入TCAM条目的效率。In this embodiment, a plurality of TCAM entries cached by the DMA are used to write the TCAM adaptation module FIFO buffer of the network chip at one time, and the DMA controller can quickly access the internal module of the network chip and the characteristics of less CPU resource overhead, and the related technology is solved. In the case of writing TCAM entries one by one, the CPU needs full intervention, the write rate is low, and the CPU resource overhead is large, and the TCAM entries are written in batches, and the efficiency of writing TCAM entries is improved.
在本发明实施例中还提供了一种写入TCAM条目的方法,图2是根据本发明实施例的流程图,如图2所示,该流程可以包括如下步骤:A method for writing a TCAM entry is also provided in the embodiment of the present invention. FIG. 2 is a flowchart according to an embodiment of the present invention. As shown in FIG. 2, the process may include the following steps:
步骤S200,获取预定数据块;Step S200, acquiring a predetermined data block;
步骤S202,通过直接内存存取DMA将预定数据块写入TCAM接口的先进先出FIFO缓存,其中,所述预定数据块包括多条TCAM条目;Step S202, writing a predetermined data block to the FIFO buffer of the TCAM interface by direct memory access DMA, wherein the predetermined data block includes a plurality of TCAM entries;
步骤S204,将FIFO缓存中的所述多条TCAM条目写入TCAM。Step S204, writing the plurality of TCAM entries in the FIFO buffer to the TCAM.
可选地,获取所述预定数据块可以包括:中央处理器CPU将TCAM数据转换为TCAM条目;将转换得到的TCAM条目写入缓存空间(即内存),以得到所述预定数据块。Optionally, obtaining the predetermined data block may include: converting, by the central processing unit, the TCAM data into a TCAM entry; writing the converted TCAM entry into a buffer space (ie, a memory) to obtain the predetermined data block.
CPU控制层面将与上层业务(例如ACL、流镜像等)相关的业务数据按照TCAM存储格式转换成TCAM条目,其中,TCAM条目用于上层业务流量转发的报文查表。将转换得到的TCAM条目写入所述缓存空间。缓存空间的大小可以根据TCAM条目的数量进行相应的调节。The CPU control layer converts the service data related to the upper layer service (for example, ACL, flow mirroring, and the like) into a TCAM entry according to the TCAM storage format, where the TCAM entry is used for the packet lookup table of the upper layer service traffic forwarding. The converted TCAM entry is written to the cache space. The size of the cache space can be adjusted according to the number of TCAM entries.
可选地,将转换得到的TCAM条目写入所述缓存空间,以得到所述预定数据块可以包括:判断写入的TCAM条目是否是根据所述TCAM数据转换得到的最后一条TCAM条目;在判断结果为否的情况下,继续将转换得到的 下一条TCAM条目写入所述缓存空间;在判断结果为是的情况下,从所述缓存空间获取由写入的所述多条TCAM条目形成的所述预定数据块。Optionally, writing the converted TCAM entry into the buffer space to obtain the predetermined data block may include: determining whether the written TCAM entry is the last TCAM entry converted according to the TCAM data; If the result is no, continue to convert the resulting The next TCAM entry is written to the cache space; if the result of the determination is YES, the predetermined data block formed by the written plurality of TCAM entries is acquired from the cache space.
目前每一个上层业务报文的相关数据转换成多条TCAM条目。CPU控制面将多条TCAM条目逐条写入DMA,为了考虑节约时间和提高效率,需要将该多条TCAM条目全部写入内存,才会启动将TCAM条目从内存中写入网络芯片的TCAM接口的FIFO缓存。如果该多条TCAM条目没有全部写入DMA,CPU控制面会继续将剩下的TCAM条目写入内存,直至全部写入内存为止。以ACL(Access Control List)为例,用户配置一个ACL包含2000个条目,直至2000条TCAM条目全部写入内存,该内存的缓存空间才会停止获取所述ACL的多条TCAM条目,确定ACL的2000个条目已经全部写入了DMA缓存空间。Currently, the relevant data of each upper layer service message is converted into multiple TCAM entries. The CPU control plane writes multiple TCAM entries one by one to the DMA. In order to save time and improve efficiency, it is necessary to write all the TCAM entries into the memory, and then start the TCAM interface that writes the TCAM entries from the memory to the network chip. FIFO buffer. If the multiple TCAM entries are not all written to the DMA, the CPU control plane will continue to write the remaining TCAM entries to memory until all are written to the memory. The ACL (Access Control List) is used as an example. The user configures an ACL to contain 2000 entries. Up to 2000 TCAM entries are written to the memory. The cache space of the memory stops acquiring multiple TCAM entries of the ACL. 2000 entries have all been written to the DMA cache space.
在以上实施例或者可选实施方式中,通过直接内存存取DMA将预定数据块写入TCAM接口的先进先出FIFO缓存还可以包括:根据所述预定数据块的物理地址、FIFO缓存地址以及数据块大小,将所述预定数据块写入所述FIFO缓存。In the above embodiment or the optional implementation, the writing of the predetermined data block to the FIFO buffer of the TCAM interface by direct memory access DMA may further include: determining, according to the physical address of the predetermined data block, the FIFO cache address, and the data. A block size that writes the predetermined block of data to the FIFO buffer.
上层应用的TCAM条目写入内存完成后,网络芯片配置DMA控制器,通过网络芯片的CPU接口将TCAM条目从内存中写入网络芯片的TCAM接口的FIFO缓存中。网络芯片开启DMA传输将TCMA条目写入FIFO缓存,需要指明预定数据块的物理地址、FIFO缓存地址以及数据块大小,将预定数据块写入所述FIFO缓存,继而通过物理总线将数据写入TCAM硬件。在本实施方式中,利用网络芯片的DMA控制器,将DMA缓存中的多条TCAM条目,批量写入网络芯片的TCAM接口的FIFO缓存,利用DMA控制器可以快速访问网络芯片内部模块的特性,可以快速将TCAM条目写入硬件,提高了写入TCAM条目的效率,并且减少占用CPU资源。After the upper application TCAM entry is written to the memory, the network chip configures the DMA controller to write the TCAM entry from the memory into the FIFO buffer of the TCAM interface of the network chip through the CPU interface of the network chip. The network chip turns on the DMA transfer to write the TCMA entry into the FIFO buffer, needs to specify the physical address of the predetermined data block, the FIFO cache address, and the data block size, writes the predetermined data block to the FIFO buffer, and then writes the data to the TCAM through the physical bus. hardware. In the embodiment, the DMA controller of the network chip is used to write a plurality of TCAM entries in the DMA buffer to the FIFO buffer of the TCAM interface of the network chip in batches, and the DMA controller can quickly access the characteristics of the internal modules of the network chip. TCAM entries can be quickly written to the hardware, increasing the efficiency of writing TCAM entries and reducing CPU usage.
图3是根据本发明实施例的一种写入TCAM条目的装置的结构框图,如图3所示,该装置可以包括:FIG. 3 is a structural block diagram of an apparatus for writing a TCAM entry according to an embodiment of the present invention. As shown in FIG. 3, the apparatus may include:
第一写入模块30,设置为:通过直接内存存取DMA将预定数据块写入TCAM接口的先进先出FIFO缓存,其中,所述预定数据块包括多条TCAM条目;第二写入模块32,连接至第一写入模块30,设置为:将FIFO缓存中 的所述多条TCAM条目写入TCAM。The first write module 30 is configured to: write a predetermined data block into the FIFO FIFO buffer of the TCAM interface by direct memory access DMA, wherein the predetermined data block includes a plurality of TCAM entries; and the second write module 32 Connected to the first write module 30, set to: FIFO in the buffer The plurality of TCAM entries are written to the TCAM.
图4是根据本发明实施例的另一种写入TCAM条目的装置的结构框图,如图4所示,该装置可以包括:FIG. 4 is a structural block diagram of another apparatus for writing a TCAM entry according to an embodiment of the present invention. As shown in FIG. 4, the apparatus may include:
获取模块40,设置为:获取所述预定数据块;第一写入模块42,连接至获取模块40,设置为:通过直接内存存取DMA将预定数据块写入TCAM接口的先进先出FIFO缓存,其中,所述预定数据块包括多条TCAM条目;第二写入模块44,连接至第一写入模块42,设置为:将FIFO缓存中的所述多条TCAM条目写入TCAM。The obtaining module 40 is configured to: acquire the predetermined data block; the first writing module 42 is connected to the obtaining module 40, and is configured to: write the predetermined data block into the first-in first-out FIFO buffer of the TCAM interface by direct memory access DMA The predetermined data block includes a plurality of TCAM entries; the second write module 44 is coupled to the first write module 42 and configured to write the plurality of TCAM entries in the FIFO buffer to the TCAM.
可选地,如图5所示,获取模块40还可以包括:转换单元401,设置为:将TCAM数据转换为TCAM条目;写入单元402,连接至转换单元401,设置为:将转换得到的TCAM条目写入所述缓存空间,以得到所述预定数据块。Optionally, as shown in FIG. 5, the obtaining module 40 may further include: a converting unit 401 configured to: convert the TCAM data into a TCAM entry; and the writing unit 402 is connected to the converting unit 401, and is configured to: convert the obtained A TCAM entry is written to the cache space to obtain the predetermined data block.
可选地,如图6所示,写入单元402还可以包括:判断次单元4021,设置为:判断写入的TCAM条目是否是根据所述TCAM数据转换得到的最后一条TCAM条目;第一写入次单元4022,连接至判断次单元4021,设置为:在判断结果为否的情况下,继续将转换得到的下一条TCAM条目写入所述缓存空间;第二写入次单元4023,连接至第一写入次单元4022,设置为:在判断结果为是的情况下,从所述缓存空间获取由写入的所述多条TCAM条目形成的所述预定数据块。Optionally, as shown in FIG. 6, the writing unit 402 may further include: a determining sub-unit 4021, configured to: determine whether the written TCAM entry is the last TCAM entry converted according to the TCAM data; the first write The sub-unit 4022 is connected to the judging sub-unit 4021, and is configured to: continue to write the converted next TCAM entry into the buffer space if the determination result is no; the second write sub-unit 4023 is connected to The first write subunit 4022 is configured to: when the determination result is YES, acquire the predetermined data block formed by the written plurality of TCAM entries from the cache space.
在以上实施例或者实施方式中,所述第一写入模块30、第一写入模块42还可以设置为:根据所述预定数据块的物理地址、FIFO缓存地址以及数据块大小,将所述预定数据块写入所述FIFO缓存。In the above embodiment or implementation, the first write module 30 and the first write module 42 may be further configured to: according to the physical address of the predetermined data block, the FIFO cache address, and the data block size. A predetermined data block is written to the FIFO buffer.
通过本发明实施例提供的装置,通过CPU将多条TCAM条目写入缓存空间,网络芯片通过DMA控制器将内存中的多条TCAM条目批量地写入网络芯片中的FIFO缓存,继而通过物理总线将TCAM条目写入外部TCAM,解决了TCAM条目是逐条写入TCAM,写入速率较低的问题,实现了批量写入TCAM条目,提高了写入TCAM条目的效率,并且减少占用CPU资源。Through the device provided by the embodiment of the present invention, a plurality of TCAM entries are written into the buffer space by the CPU, and the network chip writes a plurality of TCAM entries in the memory into the FIFO buffer in the network chip in batches through the DMA controller, and then passes through the physical bus. Writing TCAM entries to the external TCAM solves the problem that the TCAM entries are written to the TCAM one by one, and the write rate is low, which enables batch writing of TCAM entries, improves the efficiency of writing TCAM entries, and reduces CPU consumption.
需要说明的是,以上提及的第一写入模块30、第二写入模块32、第一 写入模块42以及第二写入模块44,或者,第一写入次单元4022和第二写入次单元4023发挥的功能和作用是相同或相似,它们可以是同一个模块,也可以不同的模块。It should be noted that the first write module 30, the second write module 32, and the first mentioned above The writing module 42 and the second writing module 44, or the functions and functions of the first writing sub-unit 4022 and the second writing sub-unit 4023 are the same or similar, they may be the same module, or may be different. Module.
图7是根据本发明实施例的一种用于写入TCAM条目的CPU、NP、TCAM、的连接关系示意图,图7所示:FIG. 7 is a schematic diagram of a connection relationship of a CPU, an NP, and a TCAM for writing a TCAM entry according to an embodiment of the present invention, and FIG. 7 is as follows:
中央处理器CPU 70,通过数据总线PCI-E连接至网络处理器NP,设置为:将上层业务报文的相关数据按照TCAM存储格式转换为TCAM条目,以及在DDR3 SDRAM(Double Data Rate 3 Synchronous Dynamic Random Access Memory,即八倍资料率同步动态随机存取内存)申请缓存空间。The central processing unit CPU 70 is connected to the network processor NP through the data bus PCI-E, and is configured to convert the related data of the upper layer service message into a TCAM entry according to the TCAM storage format, and in the DDR3 SDRAM (Double Data Rate 3 Synchronous Dynamic) Random Access Memory (eight times data rate synchronous dynamic random access memory) applies for cache space.
DDR3 SDRAM 72,连接至CPU 70,设置为:缓存多条TCAM条目。 DDR3 SDRAM 72, connected to CPU 70, is set to: cache multiple TCAM entries.
NP(Network Processer,即网络处理器)74,连接至TCAM 76。NP 74内部包含CPU接口741和TCAM接口742。其中,TCAM接口742内部有先进先出FIFO缓存。CPU接口741内部有DMA控制器,NP可以通过DMA控制器访问DDR3 SDRAM 72,开启DMA传输,可以在CPU不干预的情况下进行整块的数据传输。DMA可以支持快速的NP内部模块的访问。将DDR3 SDRAM 72存储的数据写入FIFO缓存。每次传输需要指定数据源的物理地址,目的NP内部模块的地址,以及数据块大小,然后开启DMA传输,这样可以快速的访问NP内部模块。An NP (Network Processer) 74 is connected to the TCAM 76. The NP 74 internally includes a CPU interface 741 and a TCAM interface 742. Among them, the TCAM interface 742 has a first in first out FIFO buffer. The CPU interface 741 has a DMA controller inside, and the NP can access the DDR3 SDRAM 72 through the DMA controller to enable DMA transfer, and the entire block of data can be transmitted without intervention by the CPU. The DMA can support fast access to NP internal modules. The data stored in the DDR3 SDRAM 72 is written to the FIFO buffer. Each transfer requires specifying the physical address of the data source, the address of the destination NP internal block, and the block size, and then turning on DMA transfer, which allows quick access to the NP internal block.
TCAM 76,通过Interlaken总线与NP 74互联。 TCAM 76, interconnected with NP 74 via the Interlaken bus.
在本发明实施例中提供了一种写入TCAM条目的方法,图8是根据本发明实施例的流程图,如图8所示,该流程包括如下步骤:In the embodiment of the present invention, a method for writing a TCAM entry is provided. FIG. 8 is a flowchart according to an embodiment of the present invention. As shown in FIG. 8, the process includes the following steps:
步骤S800,CPU控制面申请缓存空间;Step S800, the CPU control plane applies for a cache space;
CPU控制面向DDR3 SDRAM申请一块地址连续的物理内存用作缓存空间。该缓存空间用于缓存CPU控制面组装的TCAM条目,可以接受网络芯片DMA控制器,也可以成为DMA内存。该缓存空间的大小与上层业务相关,比如第四代互联网协议(Internet Protocol Version 4,简称为IPV4)IPV4 ACL,用户配置一个ACL实例,最多32K TCAM条目,每条TCAM条目宽 度为20字节,则缓存空间大小可以定义为32K*20字节。The CPU control requests a contiguous physical memory for the DDR3 SDRAM to be used as the buffer space. The cache space is used to cache the TCAM entries assembled by the CPU control plane, and can accept the network chip DMA controller or the DMA memory. The size of the cache space is related to the upper layer service. For example, the fourth generation Internet Protocol Version 4 (IPV4) IPV4 ACL, the user configures an ACL instance, up to 32K TCAM entries, and each TCAM entry is wide. The degree is 20 bytes, and the size of the cache space can be defined as 32K*20 bytes.
步骤S802,CPU控制面组装TCAM条目;Step S802, the CPU control plane assembles the TCAM entry;
CPU控制面按照TCAM数据格式将上层应用下发的业务相关数据转换成TCAM写表的数据格式即TCAM条目,包括TCAM条目物理地址和写表数据。The CPU control plane converts the service-related data sent by the upper-layer application into the data format of the TCAM write table, that is, the TCAM entry, including the TCAM entry physical address and the write table data, according to the TCAM data format.
步骤S804,将TCAM条目写入缓存空间;Step S804, writing a TCAM entry into the buffer space;
将步骤S802组装好的TCAM条目逐条写入步骤S800中CPU申请的DMA缓存即DDR3 SDRAM缓存空间中。The TCAM entries assembled in step S802 are written one by one into the DMA buffer, that is, the DDR3 SDRAM buffer space requested by the CPU in step S800.
步骤S806,判断TCAM条目是否为最后一条;Step S806, determining whether the TCAM entry is the last one;
CPU线程维护一个全局变量N,记录当前的缓存空间地址,N从0开始,对应缓存中第N个条目。缓存空间中每写入一条TCAM条目,全局变量N=N+1。以上述提及的ACL实例,第32K条目即是最后一条TCAM条目。在写入缓存空间中的TCAM条目不是最后一条TCAM条目的情况下,跳到步骤S802,继续组装下一条TCAM条目,并缓存到缓存空间中第N+1的缓存地址中。The CPU thread maintains a global variable N and records the current cache space address. N starts at 0 and corresponds to the Nth entry in the cache. Each time a TCAM entry is written in the cache space, the global variable N=N+1. With the ACL example mentioned above, the 32K entry is the last TCAM entry. In the case where the TCAM entry in the write buffer space is not the last TCAM entry, the process jumps to step S802 to continue assembling the next TCAM entry and buffering it into the N+1th cache address in the cache space.
步骤S808,将缓存空间中的TCAM条目写入FIFO缓存;Step S808, writing a TCAM entry in the cache space to the FIFO buffer;
在写入缓存空间中的TCAM条目是最后一条TCAM条目的情况下,即认为CPU控制面写入缓存空间中TCAM条目已全部写完。网络芯片开启DMA传输,通过配置DMA控制器,通过NP的CPU接口将数据写入NP的TCAM接口中的FIFO缓存中。NP的CPU接口通常有DMA控制器,可以在CPU不干预的情况下进行整块的数据传输。DMA可以支持快速的NP内部模块的访问。每次传输需要指定数据源的物理地址、目的NP内部模块的地址、以及数据块大小,开启DMA传输,这样可以快速的访问NP内部模块,包括NP中的TCAM接口以及TCAM接口中的FIFO缓存。In the case where the TCAM entry in the write buffer space is the last TCAM entry, it is considered that the TCAM entry in the CPU control plane write cache space has all been written. The network chip turns on DMA transfer, and by configuring the DMA controller, the data is written into the FIFO buffer in the TCAM interface of the NP through the CPU interface of the NP. The CPU interface of the NP usually has a DMA controller, which can perform the whole block data transmission without the intervention of the CPU. The DMA can support fast access to NP internal modules. Each transfer requires specifying the physical address of the data source, the address of the destination NP internal module, and the data block size. The DMA transfer is enabled, which allows quick access to the NP internal modules, including the TCAM interface in the NP and the FIFO buffer in the TCAM interface.
步骤S810,将FIFO缓存中的TCAM条目写入TCAM。Step S810, writing a TCAM entry in the FIFO buffer to the TCAM.
NP通过NP与外部TCAM之间的Interlaken总线将FIFO缓存中的TCAM条目写入TCAM硬件。The NP writes the TCAM entry in the FIFO buffer to the TCAM hardware via the Interlaken bus between the NP and the external TCAM.
相关技术的TCAM条目逐条写入的更新方式,在每次传输TCAM条目 时,都需要参与控制数据搬移,CPU资源开销大,而且TCAM条目更新缓慢。本发明实施例提供的方法,利用DMA控制器可以快速访问网络芯片内部模块及其CPU资源开销少的特性,通过NP的DMA控制器,将缓存的多条TCAM条目,批量地写入NP的TCAM适配模块FIFO缓存,实现了快速地将TCAM条目写入TCAM,减少占用CPU资源。Related art TCAM entries are written one by one in an update manner, each time a TCAM entry is transmitted At the same time, it is necessary to participate in controlling the data movement, the CPU resource overhead is large, and the TCAM entry is updated slowly. The method provided by the embodiment of the invention can quickly access the internal module of the network chip and the characteristic of low CPU resource consumption by using the DMA controller, and write the cached plurality of TCAM entries into the TCAM of the NP in batches through the NP controller of the NP. The adapter module FIFO buffer enables fast writing of TCAM entries to the TCAM, reducing CPU usage.
综上所述,本发明实施例提出了一种新颖的TCAM批量写表快速更新方法,通过CPU向存储器申请一块缓存空间,将上层业务下发的多条TCAM条目缓存起来,直到最后一条TCAM条目下发完毕,才触发写入操作;在CPU很小限度干预的情况下,网络芯片利用DMA控制器可以批量写入TCAM条目,实现了快速写入TCAM条目,减少占用CPU资源。本文提供的写入TCAM条目的方法及装置,写入TCAM条目快、CPU占用率低,具有极大的推广和应用价值。In summary, the embodiment of the present invention provides a novel TCAM batch write table fast update method, which applies a cache space to the memory by the CPU, and caches multiple TCAM entries sent by the upper layer service until the last TCAM entry. After the completion of the delivery, the write operation is triggered; in the case of a small amount of CPU intervention, the network chip can use the DMA controller to write TCAM entries in batches, enabling fast writing of TCAM entries and reducing CPU usage. The method and device for writing TCAM entries provided in this paper have fast TCAM entries and low CPU usage, and have great promotion and application value.
本领域普通技术人员可以理解上述实施例的全部或部分步骤可以使用计算机程序流程来实现,所述计算机程序可以存储于一计算机可读存储介质中,所述计算机程序在相应的硬件平台上(如系统、设备、装置、器件等)执行,在执行时,包括方法实施例的步骤之一或其组合。One of ordinary skill in the art will appreciate that all or a portion of the steps of the above-described embodiments can be implemented using a computer program flow, which can be stored in a computer readable storage medium, such as on a corresponding hardware platform (eg, The system, device, device, device, etc. are executed, and when executed, include one or a combination of the steps of the method embodiments.
可选地,上述实施例的全部或部分步骤也可以使用集成电路来实现,这些步骤可以被分别制作成一个个集成电路模块,或者将它们中的多个模块或步骤制作成单个集成电路模块来实现。Alternatively, all or part of the steps of the above embodiments may also be implemented by using an integrated circuit. These steps may be separately fabricated into individual integrated circuit modules, or multiple modules or steps may be fabricated into a single integrated circuit module. achieve.
上述实施例中的装置/功能模块/功能单元可以采用通用的计算装置来实现,它们可以集中在单个的计算装置上,也可以分布在多个计算装置所组成的网络上。The devices/function modules/functional units in the above embodiments may be implemented by a general-purpose computing device, which may be centralized on a single computing device or distributed over a network of multiple computing devices.
上述实施例中的装置/功能模块/功能单元以软件功能模块的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。上述提到的计算机可读取存储介质可以是只读存储器,磁盘或光盘等。When the device/function module/functional unit in the above embodiment is implemented in the form of a software function module and sold or used as a stand-alone product, it can be stored in a computer readable storage medium. The above mentioned computer readable storage medium may be a read only memory, a magnetic disk or an optical disk or the like.
工业实用性 Industrial applicability
本文采用通过DMA将预定数据块写入TCAM接口的先进先出FIFO缓存,其中,所述预定数据块包括多条TCAM条目;将FIFO缓存中的所述多条TCAM条目写入所述TCAM,解决了相关技术中,在逐条写入TCAM条目时,需要CPU全程干预,写入速率较低、CPU资源开销大的问题,实现了批量写入TCAM条目,提高了写入TCAM条目的效率。 This document uses a FIFO buffer for writing a predetermined data block to a TCAM interface by DMA, wherein the predetermined data block includes a plurality of TCAM entries; writing the plurality of TCAM entries in the FIFO buffer to the TCAM to solve In the related art, when the TCAM entry is written one by one, the CPU needs to intervene in a whole process, the write rate is low, and the CPU resource overhead is large, and the TCAM entry is written in batches, and the efficiency of writing the TCAM entry is improved.

Claims (11)

  1. 一种写入三态内容寻址存储器TCAM条目的方法,包括:A method of writing a tri-state content addressed memory TCAM entry, comprising:
    通过直接内存存取DMA将预定数据块写入TCAM接口的先进先出FIFO缓存,其中,所述预定数据块包括多条TCAM条目;Writing a predetermined data block to the first in first out FIFO buffer of the TCAM interface by direct memory access DMA, wherein the predetermined data block includes a plurality of TCAM entries;
    将FIFO缓存中的所述多条TCAM条目写入TCAM。The plurality of TCAM entries in the FIFO buffer are written to the TCAM.
  2. 根据权利要求1所述的方法,在通过直接内存存取DMA将预定数据块写入TCAM接口的FIFO缓存之前,所述方法还包括:The method of claim 1, before the predetermined data block is written to the FIFO buffer of the TCAM interface by direct memory access DMA, the method further comprising:
    获取所述预定数据块。Obtaining the predetermined data block.
  3. 根据权利要求2所述的方法,其中,获取所述预定数据块包括:The method of claim 2 wherein obtaining the predetermined block of data comprises:
    中央处理器CPU将TCAM数据转换为TCAM条目;The central processing unit CPU converts the TCAM data into a TCAM entry;
    将转换得到的TCAM条目写入缓存空间,以得到所述预定数据块。The converted TCAM entry is written to the cache space to obtain the predetermined data block.
  4. 根据权利要求3所述的方法,其中,将转换得到的TCAM条目写入缓存空间,以得到所述预定数据块包括:The method of claim 3, wherein writing the converted TCAM entry to the cache space to obtain the predetermined data block comprises:
    判断写入的TCAM条目是否是根据所述TCAM数据转换得到的最后一条TCAM条目;Determining whether the written TCAM entry is the last TCAM entry converted according to the TCAM data;
    在判断结果为否的情况下,继续将转换得到的下一条TCAM条目写入所述缓存空间;If the judgment result is no, the next TCAM entry obtained by the conversion is continuously written into the buffer space;
    在判断结果为是的情况下,从所述缓存空间获取由写入的所述多条TCAM条目形成的所述预定数据块。In the case where the determination result is YES, the predetermined data block formed by the written plurality of TCAM entries is acquired from the buffer space.
  5. 根据权利要求1至4中任一项所述的方法,其中,通过直接内存存取DMA将预定数据块写入TCAM接口的先进先出FIFO缓存包括:The method according to any one of claims 1 to 4, wherein the writing of the predetermined data block to the FIFO interface of the TCAM interface by direct memory access DMA comprises:
    根据所述预定数据块的物理地址、FIFO缓存地址以及数据块大小,将所述预定数据块写入所述FIFO缓存。The predetermined data block is written to the FIFO buffer according to a physical address of the predetermined data block, a FIFO cache address, and a data block size.
  6. 一种写入TCAM条目的装置,包括:A device for writing TCAM entries, including:
    第一写入模块,设置为:通过直接内存存取DMA将预定数据块写入 TCAM接口的先进先出FIFO缓存,其中,所述预定数据块包括多条TCAM条目;The first write module is configured to: write a predetermined data block by direct memory access DMA a first in first out FIFO buffer of the TCAM interface, wherein the predetermined data block includes a plurality of TCAM entries;
    第二写入模块,设置为:将FIFO缓存中的所述多条TCAM条目写入所述TCAM。The second write module is configured to: write the plurality of TCAM entries in the FIFO buffer to the TCAM.
  7. 根据权利要求6所述的装置,还包括:The apparatus of claim 6 further comprising:
    获取模块,设置为:获取所述预定数据块。The obtaining module is configured to: acquire the predetermined data block.
  8. 根据权利要求7所述的装置,其中,所述获取模块包括:The apparatus of claim 7, wherein the obtaining module comprises:
    转换单元,设置为:将TCAM数据转换为TCAM条目;a conversion unit, configured to: convert TCAM data into a TCAM entry;
    写入单元,设置为:将转换得到的TCAM条目写入缓存空间,以得到所述预定数据块。The writing unit is configured to: write the converted TCAM entry into the buffer space to obtain the predetermined data block.
  9. 根据权利要求8所述的装置,其中,所述写入单元包括:The apparatus of claim 8 wherein said writing unit comprises:
    判断次单元,设置为:判断写入的TCAM条目是否是根据所述TCAM数据转换得到的最后一条TCAM条目;Determining the secondary unit, configured to: determine whether the written TCAM entry is the last TCAM entry converted according to the TCAM data;
    第一写入次单元,设置为:在判断结果为否的情况下,继续将转换得到的下一条TCAM条目写入所述缓存空间;The first write secondary unit is configured to: continue to convert the converted next TCAM entry into the buffer space if the determination result is negative;
    第二写入次单元,设置为:在判断结果为是的情况下,从所述缓存空间获取由写入的所述多条TCAM条目形成的所述预定数据块。The second write secondary unit is configured to: obtain, when the determination result is YES, the predetermined data block formed by the written plurality of TCAM entries from the cache space.
  10. 根据权利要求6至9中任一项所述的装置,其中,所述第一写入模块是设置为:The apparatus according to any one of claims 6 to 9, wherein the first writing module is configured to:
    根据所述预定数据块的物理地址、FIFO缓存地址以及数据块大小,将所述预定数据块写入所述FIFO缓存。The predetermined data block is written to the FIFO buffer according to a physical address of the predetermined data block, a FIFO cache address, and a data block size.
  11. 一种计算机可读存储介质,存储有计算机可执行指令,所述计算机可执行指令用于执行权利要求1-5任一项的方法。 A computer readable storage medium storing computer executable instructions for performing the method of any of claims 1-5.
PCT/CN2015/078209 2014-12-26 2015-05-04 Method and device for writing tcam entries WO2016101485A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201410836285.2A CN105786733B (en) 2014-12-26 2014-12-26 Method and device for writing TCAM (ternary content addressable memory) entries
CN201410836285.2 2014-12-26

Publications (1)

Publication Number Publication Date
WO2016101485A1 true WO2016101485A1 (en) 2016-06-30

Family

ID=56149078

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/078209 WO2016101485A1 (en) 2014-12-26 2015-05-04 Method and device for writing tcam entries

Country Status (2)

Country Link
CN (1) CN105786733B (en)
WO (1) WO2016101485A1 (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10032500B2 (en) * 2016-10-07 2018-07-24 Tc Lab, Inc. Memory disturb recovery scheme for cross-point memory arrays
CN108363638A (en) * 2018-02-06 2018-08-03 盛科网络(苏州)有限公司 The error correction method and system of TCAM memory in a kind of chip
CN112291212B (en) * 2020-10-16 2023-02-28 北京锐安科技有限公司 Static rule management method and device, electronic equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101364947A (en) * 2008-09-08 2009-02-11 中兴通讯股份有限公司 Rule matching method and system for control list access
CN101616099A (en) * 2009-08-03 2009-12-30 杭州华三通信技术有限公司 Hardware forwarding table refreshing method and device and routing device
CN101866357A (en) * 2010-06-11 2010-10-20 福建星网锐捷网络有限公司 Method and device for updating items of three-state content addressing memory
US20130290622A1 (en) * 2012-04-27 2013-10-31 Suddha Sekhar Dey Tcam action updates

Family Cites Families (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP3289661B2 (en) * 1997-11-07 2002-06-10 日本電気株式会社 Cache memory system
CN100495373C (en) * 2003-12-05 2009-06-03 联发科技股份有限公司 Virtual first-in first-out direct storage accessing device
US7411957B2 (en) * 2004-03-26 2008-08-12 Cisco Technology, Inc. Hardware filtering support for denial-of-service attacks
CN100440184C (en) * 2007-04-26 2008-12-03 北京中星微电子有限公司 DMA controller and transmit method capable of simultaneously carrying out read-write operation
CN100464318C (en) * 2007-04-27 2009-02-25 北京中星微电子有限公司 DMA controller and transmission method of implementing high efficient DMA transmission
CN101650698B (en) * 2009-08-28 2011-11-16 曙光信息产业(北京)有限公司 Method for realizing direct memory access
CN102073592B (en) * 2009-11-19 2012-12-05 中兴通讯股份有限公司 Quick read-write method and device for flash memory
DE112011102487T5 (en) * 2010-07-27 2013-05-29 International Business Machines Corporation Assignment of logical to physical addresses in semiconductor memory units having memory systems
CN102662888A (en) * 2012-03-20 2012-09-12 大连梯耐德网络技术有限公司 System for controlling multi-user parallel operation of TCAM, and control method thereof
CN103023782B (en) * 2012-11-22 2016-05-04 北京星网锐捷网络技术有限公司 A kind of method and device of accessing three-state content addressing memory

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101364947A (en) * 2008-09-08 2009-02-11 中兴通讯股份有限公司 Rule matching method and system for control list access
CN101616099A (en) * 2009-08-03 2009-12-30 杭州华三通信技术有限公司 Hardware forwarding table refreshing method and device and routing device
CN101866357A (en) * 2010-06-11 2010-10-20 福建星网锐捷网络有限公司 Method and device for updating items of three-state content addressing memory
US20130290622A1 (en) * 2012-04-27 2013-10-31 Suddha Sekhar Dey Tcam action updates

Also Published As

Publication number Publication date
CN105786733A (en) 2016-07-20
CN105786733B (en) 2020-08-07

Similar Documents

Publication Publication Date Title
US11461263B2 (en) Disaggregated memory server
US10193831B2 (en) Device and method for packet processing with memories having different latencies
US11489791B2 (en) Virtual switch scaling for networking applications
US8880632B1 (en) Method and apparatus for performing multiple DMA channel based network quality of service
US9866479B2 (en) Technologies for concurrency of cuckoo hashing flow lookup
US8972630B1 (en) Transactional memory that supports a put with low priority ring command
US9411775B2 (en) iWARP send with immediate data operations
US8868672B2 (en) Server node interconnect devices and methods
US9037810B2 (en) Pre-fetching of data packets
US10268612B1 (en) Hardware controller supporting memory page migration
US9678866B1 (en) Transactional memory that supports put and get ring commands
US20130318280A1 (en) Offloading of computation for rack level servers and corresponding methods and systems
WO2015078219A1 (en) Information caching method and apparatus, and communication device
WO2017148292A1 (en) Cascade plate, and system and method for ssd remote sharing access
US10248315B2 (en) Devices and methods for interconnecting server nodes
US20140143519A1 (en) Store operation with conditional push
US20170048320A1 (en) Distributed gather/scatter operations across a network of memory nodes
WO2016101485A1 (en) Method and device for writing tcam entries
US10601723B2 (en) Bandwidth matched scheduler
US9411400B1 (en) Methods and systems for advertsing available credit at memory of network device ports based on temperature
US9342313B2 (en) Transactional memory that supports a get from one of a set of rings command
US9137167B2 (en) Host ethernet adapter frame forwarding
US10445267B2 (en) Direct memory access (DMA) unit with address alignment
US10255213B1 (en) Adapter device for large address spaces
WO2024001310A1 (en) Data processing device and method

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 15871561

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 15871561

Country of ref document: EP

Kind code of ref document: A1