Traffic shaping data access methods, control modules, network chips and devices
By using memory to store traffic shaping configuration data and token data in the network device chip, the problem of resource waste in the existing technology is solved, and efficient traffic shaping and resource saving are achieved.
Patent Information
- Application Number
- CN202410426270.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-10
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2044-04-10
AI Technical Summary
The resources used by traffic shaping logic in existing network equipment chips are too large, especially in multi-port and multi-queue designs, resulting in a waste of chip resources.
Memories are used to store the configuration data and token data of ports and queues respectively. Through specific data access methods and timing allocation schemes, the use of registers is reduced and resource utilization is improved.
It effectively solves the problem of resource waste, meets the traffic shaping accuracy requirements of multiple ports and queues, flexibly adjusts the jitter problem, and saves chip resources.
Smart Images

Figure CN118276780B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of network communication, and specifically relates to a traffic shaping data access method, a multi-port multi-queue traffic shaping control module, a network chip and a network device. Background Art
[0002] Traffic shaping is often used to adjust the bandwidth rate of ports and queues to limit the traffic and bursts flowing out of a connection in a network, so that messages are sent at a more uniform speed. Traffic shaping uses a token bucket to fill tokens into the token bucket regularly. When the tokens are used up but the filling time has not yet arrived, the sending of messages is suspended until the next token filling.
[0003] In the multi-port and multi-queue design of existing network chips, the traffic shaping logic of each port and queue is independent and does not affect each other. In order to limit the rate of multiple ports and queues at the same time, registers are often used to store configuration data and token calculation data. However, when the number of ports or queues increases, more chip resources will be used in this way. Summary of the invention
[0004] In view of this, the purpose of the present invention is to solve the problem of large resource usage of traffic shaping logic in existing network device chips.
[0005] To achieve the above-mentioned purpose, in a first aspect, the present invention provides a traffic shaping data access method, which is applied to a memory of a multi-port multi-queue traffic shaping control module in a network chip; wherein port shaping and queue shaping each use a pair of memories to store configuration data and token data respectively; in each pair of memories, the first memory stores configuration data and is connected to a first channel and a second channel, and the second memory stores token data and is connected to a third channel; the storage address depths of the configuration data and the token data are the same; the configuration data and the token data of each port and queue have corresponding storage addresses;
[0006] The method includes a configuration read operation, a configuration write operation, a bucket reduction read operation, a bucket reduction write operation, a bucket filling read operation, and a bucket filling write operation:
[0007] The configuration read operation is to read the corresponding configuration data in the first memory from the first channel according to the storage address;
[0008] The configuration write operation is to write the configuration data from the first channel to the corresponding storage address in the first memory;
[0009] The bucket filling read operation is to read the corresponding configuration data in the first memory from the second channel according to the storage address, and read the corresponding token data before the bucket filling calculation in the second memory from the third channel according to the storage address;
[0010] The bucket filling write operation is to write the token data calculated after the bucket filling from the third channel to the corresponding storage address in the second memory according to the storage address;
[0011] The bucket reduction read operation is to read the corresponding pre-bucket reduction token data in the second memory from the third channel according to the storage address;
[0012] The bucket reduction write operation is to write the token data after the bucket reduction calculation from the third channel to the corresponding storage address in the second memory.
[0013] In some embodiments of the present invention, when the first memory is a single-port memory, the bucket fill read operation needs to be executed in time-sharing with the configuration read operation and the configuration write operation; the second memory is a single-port memory, the bucket reduce read operation, the bucket reduce write operation, the bucket fill read operation and the bucket fill write operation need to be executed in time-sharing, and, when the bucket fill calculation is performed, the bucket fill read operation is performed first and then the bucket fill write operation is performed; when the bucket reduce calculation is performed, the bucket reduce read operation is performed first and then the bucket reduce write operation is performed.
[0014] In some embodiments of the present invention, the configuration data includes bucket depth and bucket filling rate.
[0015] In some embodiments of the present invention, the bucket depth is stored by storing a bucket depth factor cbs_mul and a bucket depth index cbs_exp representing the bucket depth CBS, where CBS=cbs_mul×2 cbs_exp .
[0016] In some embodiments of the present invention, the storage space of the bucket depth factor cbs_mul is 4 bits, and the storage space of the bucket depth index is 4 bits.
[0017] In some embodiments of the present invention, the bucket filling rate is stored by storing the bucket filling frequency F representing the bucket filling rate grty, the bucket filling granularity grty_mul and the bucket filling granularity fine-tuning value grty_delt, wherein grty=(F-1)×grty_mul+grty_delt.
[0018] In some embodiments of the present invention, the bucket filling frequency F is stored by storing the index value of the bucket filling frequency F.
[0019] In some embodiments of the present invention, the storage space of the index value of the bucket filling frequency F is 2 bits, the storage space of the bucket filling granularity grty_mul is 14 bits, and the storage space of the bucket filling granularity fine-tuning value grty_delt is 8 bits.
[0020] In some embodiments of the present invention, at least one bucket filling frequency F is preset, and each port and queue selects the bucket filling frequency F according to traffic shaping requirements.
[0021] In some embodiments of the present invention, four bucket filling frequencies F are preset.
[0022] In some embodiments of the present invention, the bucket filling frequency F can be 250, 50, 25, and 4.
[0023] In the second aspect, the present invention provides a multi-port multi-queue control module of a network chip, including a memory and a data access control module; wherein, port shaping and traffic shaping each use a pair of memories to store configuration data and token data respectively; in each pair of memories, the first memory stores configuration data and is connected to a first channel and a second channel, and the second memory stores token data and is connected to a third channel; the storage address depth of the configuration data and the token data is the same; the configuration data and token data of each port and queue have corresponding storage addresses; the data access control module uses the traffic shaping data access method to read the memory.
[0024] In some embodiments of the present invention, a token calculation unit is also included. The token calculation unit is used to complete bucket filling calculation and bucket reduction calculation. The token calculation unit is electrically connected to the first memory through the second channel and is electrically connected to the second storage module through the third channel.
[0025] In some embodiments of the present invention, the first memory and the second memory are single-port memories.
[0026] In some embodiments of the present invention, the first channel is a system bus of a network chip, and the second channel and the third channel are hardware logic lines connecting a bucket reduction and bucket filling calculation module of the network chip.
[0027] In a third aspect, the present invention provides a network chip, comprising the multi-port multi-queue control module.
[0028] In a fourth aspect, the present invention provides a network device, comprising the network chip.
[0029] In some embodiments of the present invention, the network device is an Ethernet switch.
[0030] The present invention has the following beneficial effects:
[0031] The present invention stores configuration data and token data in a memory respectively, and solves the problem of large register storage resources by changing the storage mode and realizing correct reading of configuration data and token data. Moreover, the present invention can provide multiple bucket filling formulas, which can not only meet the shaping accuracy requirements of all ports and queues, but also flexibly adjust the jitter problem and save resources. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 The figure is a schematic diagram of the structure of the memory of the multi-port multi-queue traffic shaping control module in one embodiment of the present invention.
[0033] Figure 2 This is a timing allocation scheme in one embodiment of the present invention.
[0034] Figure 3 This is another timing allocation scheme in an embodiment of the present invention.
[0035] Figure 4 It is a multi-port multi-queue control module of a network chip in one embodiment of the present invention.
[0036] Reference numerals
[0037] 100(100') First Memory
[0038] 200(200') Second memory
[0039] 300 First Channel
[0040] 400(400') Second channel
[0041] 500(500') Third channel
[0042] 600 Data Access Control Module
[0043] 700 Token Calculation Unit DETAILED DESCRIPTION
[0044] The following describes the embodiments of the present invention by specific examples, and those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict.
[0045] It should be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present invention, and thus the drawings only show components related to the present invention rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.
[0046] The present invention is used to control the quality of service (QoS) of a network, and specifically, to adjust the bandwidth rate of ports and queues of a network device by using traffic shaping. One of the existing solutions for traffic shaping is to use a token bucket mechanism in a network chip to control the rate of ports and queues. However, since the solution uses registers to implement the storage of configuration data and token calculation data, when the number of ports or queues increases, more chip resources are used. To solve this problem, a memory is used in the traffic shaping design to complete the traffic shaping token bucket configuration and data storage during the calculation process.
[0047] Example 1
[0048] This embodiment is used to explain in detail the traffic shaping data access method of the present invention.
[0049] When the number of bits used by the data exceeds a certain amount, the area occupied by the chip resources used by the register with the same number of bits is larger than that of the memory. The more bits there are, the more obvious the area advantage of the memory is. In addition, during multi-port multi-queue traffic shaping, after the egress scheduling takes effect, only one port will be scheduled at any time, and only one queue will be output under the port at that time. Therefore, the present invention uses a memory to complete the traffic shaping token bucket configuration and data storage during the calculation process.
[0050] The method of the present invention first separates the resources of the shaping chip according to the port and the queue, and then respectively places the resources of the port or the queue in two memories according to the configuration data and the token data, that is, the port shaping and the queue shaping each have two memories. The storage method is applied to the memory of the multi-port multi-queue traffic shaping control module in the network chip, such as Figure 1 As shown. Port shaping and queue shaping each use a pair of memories to store configuration data and token data respectively; in each pair of memories, the first memory 100 stores configuration data and is connected to the first channel 300 and the second channel 400, and the second memory 200 stores token data and is connected to the third channel 500; the storage address depth of the configuration data and the token data is the same; the configuration data and token data of each port and queue have corresponding storage addresses, such as Figure 1 As shown, address 1 corresponds to port 1 or queue 1, address 2 corresponds to port 2 or queue 2, ..., address n corresponds to port n or queue n.
[0051] In an actual network environment in the embodiment of the present invention, such as an Ethernet system, the number of queues is often 8 times the number of ports, and the memory allocated to the queues is generally much larger than the memory allocated to the ports.
[0052] Configuration data is usually set by the manufacturer or user from outside the chip according to the needs, and token data only needs to be accessed internally when filling and reducing buckets for traffic shaping. Therefore, the reading and writing of configuration data for configuration uses a different data channel from token data, and in order to ensure the correct access to the memory for both purposes, a design is made for each data operation required for traffic shaping.
[0053] The method includes a configuration read operation, a configuration write operation, a bucket reduction read operation, a bucket reduction write operation, a bucket filling read operation, and a bucket filling write operation. Specifically, Figure 1 As shown, the configuration read operation is to read the corresponding configuration data in the first memory 100 from the first channel 300 according to the storage address; the configuration write operation is to write the configuration data from the first channel 300 to the corresponding storage address in the first memory 100; the bucket read operation is to read the corresponding configuration data in the first memory 100 from the second channel 400 according to the storage address, and read the corresponding pre-bucket filling token data in the second memory 200 from the third channel 500 according to the storage address; the bucket write operation is to write the token data calculated after bucket filling from the third channel 500 to the corresponding storage address in the second memory 200 according to the storage address; the bucket read operation is to read the corresponding token data before bucket reduction calculation in the second memory 200 from the third channel 500 according to the storage address; the bucket write operation is to write the token data calculated after bucket reduction from the third channel 500 to the corresponding storage address in the second memory 200 resources.
[0054] In some specific embodiments of the present invention, in order to meet the access function and efficiency requirements and further reduce the occupation of chip resources, the first channel uses the system bus of the chip or module; the second channel and the third channel use the hardware logic line directly connected to the bucket filling and reducing calculation circuit in the network chip. Furthermore, for the first memory storing configuration data, the system bus can read and write to it, and the hardware logic can only read it; for the second memory storing the calculated token value, the hardware logic can read and write to it, but the system bus cannot perform any operation on it.
[0055] In some specific implementations of the present invention, a single-port memory with the same width and depth saves more resources, and the first memory and the second memory use single-port memories, which are generally RAM memories.
[0056] The present invention stores configuration data and token data in a memory respectively, and solves the problem of large register storage resources by changing the storage mode and realizing correct reading of configuration data and token data.
[0057] Example 2
[0058] In this embodiment, the first channel is a system bus, the second channel is a hardware logic line, and the memory is a single-port memory. This embodiment further describes in detail how to implement the traffic shaping data access method of the present invention based on a single-port memory.
[0059] A single-port memory can only perform read operations or write operations in one clock cycle. Therefore, when the method of the present invention is implemented using a single-port memory, it is necessary to allocate the timing of each read and write operation to meet the requirements of dynamically changing configuration data and correctly executing bucket filling and bucket reduction in actual traffic shaping application scenarios.
[0060] Since the traffic shaping of the port or queue needs to be independently controlled, the method of the present invention places the traffic shaping of the port or queue in two memories according to the configuration data and token data, respectively, and adopts a single-port memory. Therefore, when the first memory is a single-port memory, the configuration read operation and the configuration write operation performed on the first memory need to avoid conflicts with the bucket read operation, and the bucket read operation needs to be performed in time sharing with the configuration read operation and the configuration write operation; the second memory is a single-port memory, and the bucket read operation, the bucket write operation, the bucket read operation and the bucket write operation need to be performed in time sharing, and when the bucket is filled, the bucket read operation is performed first and then the bucket write operation; when the bucket is reduced, the bucket read operation is performed first and then the bucket write operation is performed.
[0061] Figure 2 A timing allocation scheme in this embodiment is provided. In this scheme, a processing cycle consisting of four processing time slots is set. In each processing cycle, the three read and write operations of the first memory RAM1 are allocated to three processing time slots, and the four read and write operations of the second memory RAM2 are allocated to four processing time slots. Since the clock cycles occupied by various read and write operations are different, each processing time slot occupies at least one clock cycle, and the clock cycles occupied by different processing time slots can be the same or different. Figure 2 As shown, specifically, the configuration write operation and the bucket reduction read operation are assigned to the first processing time slot for execution; the configuration read operation and the bucket reduction write operation are assigned to the second processing time slot for execution; the bucket filling write operation is assigned to the third processing time slot for execution; and the bucket filling write operation is assigned to the fourth processing time slot for execution. Figure 2 It can be seen that the fourth time slot is followed by the first time slot of the next processing cycle. The descriptions of the first processing time slot, the second processing time slot, etc. are for the convenience of description, not for limitation. Since the operations of the above timing allocation scheme are executed cyclically, multiple allocation schemes can be derived. For example, the processing cycle starts from the third time slot, the configuration write and the configuration read exchange time slots, or the configuration write or configuration read is allocated to the fourth time slot. These derived equivalent schemes can meet the requirements.
[0062] In addition, it should be noted that each read and write operation does not have to be performed in every processing cycle, and can be performed in different processing cycles according to configuration and calculation requirements. For processing cycles with read and write operations, in order to avoid conflicts between the seven operations, they are allocated in different time slots according to the above timing arrangement.
[0063] In this example, other timing allocation schemes may be used in the traffic shaping data access method of the present invention based on a single-port memory, and the method is not limited to one timing allocation scheme.
[0064] Figure 3 Another timing allocation scheme in this embodiment is given. In this scheme, the timing is allocated according to the clock cycles occupied by each read and write operation.
[0065] The configuration read operation includes the system bus reading the first memory to receive the read instruction ( Figure 3 The system bus reads the memory 1), executes the read instruction ( Figure 3 Memory 1 reads the returned data) and returns the corresponding data ( Figure 3 The configuration write operation includes executing the write instruction ( Figure 3 The system bus writes to the memory 1) in one step and is allocated one clock cycle.
[0066] Bucket reduction calculation and bucket filling calculation both adopt the sequential operation of read operation first and write operation later. Bucket reduction read operation includes receiving read instruction ( Figure 3 Read memory 2) when reducing the bucket in the operation, execute the read instruction ( Figure 3 The memory in the memory returns data twice) two operations, allocating two clock cycles, and the bucket write operation includes waiting for the calculation result ( Figure 3 Memory read returns data calculation) and result write ( Figure 3 The calculation data in the back memory is written back to the memory 2) two operations, which are allocated two clock cycles. The bucket read operation includes receiving the read instruction ( Figure 3 The bucket filling operation room reads memory 1 and reads memory 2), executes the read instruction ( Figure 3 The two operations of memory 1 and memory 2 read and return data in the bucket are allocated two clock cycles. The bucket write operation includes waiting for the calculation result ( Figure 3 The memory 1 read return data participates in the calculation and the memory 2 read return data calculation) and the result is written ( Figure 3 The two operations of writing the calculated data back to the memory 2) are allocated two clock cycles.
[0067] The present invention supports external configuration and internal token calculation needs at any time through timing allocation, and avoids conflicts among various operations, so that the present invention can be more flexibly adapted to various application scenarios.
[0068] Example 3
[0069] This embodiment is used to further explain in detail the configuration data storage and token data calculation in the traffic shaping data access method of the present invention.
[0070] Reasonable configuration of the configuration data and token data during the traffic shaping process can also further reduce the temporary chip resources. In this embodiment, the configuration data is at least the bucket depth and the bucket filling rate.
[0071] In some specific implementations of the present invention, the bucket depth is stored by storing a bucket depth factor cbs_mul and a bucket depth index cbs_exp representing the bucket depth CBS, wherein:
[0072] CBS=cbs_mul×2 cbs_exp .
[0073] The bucket depth can reduce the resources occupied by the storage bucket depth as much as possible through the above storage method, and can also use shift register calculation to reduce the resources occupied by the calculation circuit.
[0074] In some specific implementations of the present invention, the method of storing the bucket filling rate is to store the bucket filling frequency F representing the bucket filling rate grty, the bucket filling granularity grty_mul and the bucket filling granularity fine-tuning value grty_delt, wherein,
[0075] grty=(F-1)×grty_mul+grty_delt.
[0076] The method of storing the three key parameters of the bucket filling rate can, on the one hand, minimize the resources occupied by storing the bucket filling rate as much as possible, and on the other hand, correspond to the bucket filling rate and its bucket filling granularity and bucket filling granularity fine-tuning value through the bucket filling frequency.
[0077] At least one bucket filling frequency F is set. By setting multiple bucket filling frequencies, each port and queue selects the bucket filling frequency F according to the traffic shaping requirement.
[0078] This embodiment provides four formulas, namely, four bucket filling frequencies. Different formulas are selected according to traffic burst conditions to ensure that the buckets are filled as evenly as possible while supporting bursts.
[0079] The bucket filling rate is generally defined as the number of buckets filled per unit time. In this embodiment, the bucket filling rate is determined by the total number of bytes that need to be filled in the bucket within 1000 microseconds. Generally, the minimum shaping rate is 8kbps (kilobits per second), which means that 1 byte is filled in the bucket within 1000 microseconds. The step is also 8kbps, that is, the supported shaping rate is a multiple of 8kbps. When the shaping rate is known, the total number of bytes that need to be filled into the bucket within 1000 microseconds can be calculated by formula 1, which is as follows:
[0080] grty = rate * 0.001 / 8
[0081] Among them, grty represents the number of bytes filled into the bucket within 1000 microseconds, and rate represents the shaping rate in integer type.
[0082] In this embodiment, dynamic rate configuration change is supported. During a short period of configuration change, the rate will fluctuate, but then the rate will stabilize to the limited rate. For the first memory (RAM1) storing rate configuration data, the content stored in each address is shown in the following table.
[0083] [31:30] [29:16] [15:8] [7:4] [3:0] sel grty_mul grty_delt cbs_mul cbs_exp
[0084] Among them, cbs_mul represents the factor value of the bucket depth CBS, and cbs_exp represents the exponential value of the bucket depth CBS. Each occupies 4 bits for a total of 8 bits. According to the bucket depth calculation formula CBS = cbs_mul × 2 cbs_exp , the two generate discrete bucket depth CBS values. If the bucket depth CBS bit width is 15 bits and the maximum value is 32767, only 8 bits can be used to represent this bucket depth using this scheme. Moreover, a left shift shift register is used for calculation during calculation, that is, bucket depth CBS = cbs_mul << cbs_exp, and << represents left shift.
[0085] grty_mul represents the bucket filling granularity, grty_delt represents the bucket filling granularity fine-tuning value, and sel represents the index value of the bucket filling frequency F. This index value represents selecting the shaping rate in integer type corresponding to the bucket filling frequency F. Directly storing the bucket filling frequency will consume more chip resources. In actual application scenarios, traffic shaping generally only requires a limited number of traffic shaping rates to meet the requirements. Therefore, the index value is set according to the number of traffic shaping rates, and fewer bits are used to represent the traffic shaping rate or its corresponding bucket filling rate.
[0086] Four formulas are provided in this embodiment for users to select to generate bucket filling configurations. Specifically:
[0087] (1) If sel is 2'b00, it means that F takes the value of 250, and formula 2 is selected:
[0088] 249 * grty_mul + grty_delt = grty;
[0089] Formula 2 indicates that every 1000us will be divided into 250 bucket fillings, and the bucket will be filled once every 4us. The bucket filling rate grty is calculated according to Formula 1. grty_mul is the integer part of grty / 249, then grty_delt = grty-249*grty_mul. Assuming that the shaping is to 1000Mbps, it can be calculated that grty_mul = 500, grty_delt = 500, and 500 bytes are filled every 4us. This method has a high bucket filling frequency and is suitable for queues with relatively smooth traffic.
[0090] (2) If sel is 2'b01, it means that the value of F is 50, and formula 3 is selected:
[0091] 49*grty_mul+grty_delt=grty;
[0092] Formula 3 indicates that the bucket is filled 50 times within 1000us, once every 20us, and the bucket filling rate grty is calculated according to Formula 1, grty_mul is the integer part of grty / 49, and grty_delt = grty-49*grty_mul. This method is suitable for some queues with large traffic bursts.
[0093] (3) If sel is 2'b10, it means the value of F is 25, so select formula 4;
[0094] 24*grty_mul+grty_delt=grty;
[0095] Formula 4 indicates that the bucket is filled 25 times within 1000us, once every 50us, and the bucket filling rate grty is calculated according to Formula 1, grty_mul is the integer part of grty / 24, and grty_delt = grty-24*grty_mul. This method is suitable for queues with larger traffic bursts than Formula 3.
[0096] (4) If sel is 2'b11, it means that the value of F is 5, and formula 5 is selected:
[0097] 4*gryt_mul+grty_delt=grty;
[0098] Formula 5 indicates that the bucket is filled 5 times within 1000us, once every 200us, and the bucket filling rate grty is calculated according to Formula 1, grty_mul is the integer part of grty / 4, and grty_delt = grty-4*grty_mul. This formula is selected when the shaping rate is low.
[0099] (5) The purpose of setting the bucket filling granularity fine-tuning value grty_delt is to fine-tune the shaping rate according to the actual situation. Regardless of the formula, the value of grty_delt will only be filled once within 1000us. Therefore, you can increase or decrease grty_delt appropriately based on the actual calculated theoretical value to achieve the purpose of fine-tuning the rate. For example, if there is a frequency deviation in the clock, the rate will be slightly larger or smaller. In this case, you can slightly increase or decrease the value of grty_mul to achieve the required speed limit. If the value of grty_delt increases or decreases by 1, it means that the rate increases or decreases by 8kbps every 1 millisecond.
[0100] The upper and lower rate limits supported by the above four formulas are as follows:
[0101] Sel grty_mul grty_delt Rate Limit Rate lower limit 0 14‘d16383 8’d255 32.6Gbps 8kbps 1 14‘d16383 8’d255 6.4Gbps 8kbps 2 14‘d16383 8’d255 3.2Gbps 8kbps 3 14‘d16383 8’d255 526Mbps 8kbps
[0102] When the shaping rates are different, the values of cbs_mul and cbs_exp need to be determined according to the specific shaping rates to ensure that the bucket depth CBS can accommodate the value of the next bucket filling, and the traffic will not be reduced due to the bucket depth being too small.
[0103] If cbs_mul = 12 and cbs_exp = 10, then CBS = 12288*(12*2 10 ), that is, the maximum number of bytes in the bucket is 12288, and the value is kept at this value. If grty_mul is set to 15000, otherwise the bucket will be filled once, and the part exceeding 12288 will be discarded. This means that the traffic is reduced, and the final shaped traffic will be less than the theoretical value.
[0104] Therefore, the values of cbs_mul and cbs_exp should be set so that the bucket depth CBS they calculate is larger than the bucket filling granularity grty_mul and the bucket filling granularity fine-tuning value grty_delt.
[0105] In this embodiment, the calculated value of each port or queue token is placed in the second memory, with a bit width of 16 bits. For the second memory (RAM2) storing the calculated token data, the contents stored in each address are shown in the following table:
[0106] [15:0] token_count
[0107] token_count indicates the number of tokens currently remaining, in bytes. The highest bit is used as a sign bit. This memory can only be read and written by hardware logic, and cannot be accessed by the system bus. There are two reasons for hardware logic access, filling the bucket and reducing the bucket. Both operations require reading two memories at the same time first, and then writing back to memory 2 after calculation.
[0108] When the bucket needs to be filled, the formula used is determined by reading the sel signal in RAM1. If it is not the last bucket filling within 1000us, token_count = token_count + grty_mul, otherwise token_count = token_count + grty_delt, and the maximum token_count is the bucket depth CBS.
[0109] When the bucket needs to be reduced, token_count = token_count-pkt_lengt, where pkt_lengt represents the number of bytes (token number) used by the traffic, and token_count is at least 0.
[0110] Example 4
[0111] This embodiment is used to describe in detail the product implementation of the present invention applied to a network chip. Figure 4 As shown, a multi-port multi-queue control module of a network chip includes a memory and a data access control module 600; wherein, port shaping and traffic shaping each use a pair of memories to store configuration data and token data respectively; in each pair of memories, the first memory stores configuration data and is connected to the first channel and the second channel, and the second memory stores token data and is connected to the third channel; the storage address depth of the configuration data and the token data is the same; the configuration data and token data of each port and queue have corresponding storage addresses; the data access control module adopts the storage and traffic shaping data access method of the present invention to control the reading of the memory.
[0112] The network chip in this embodiment further includes a token calculation unit 700, which is used to complete bucket filling calculation and bucket reduction calculation. The token calculation unit 700 is electrically connected to the first memory 100 (100') through the second channel 400 (400'), and is electrically connected to the second storage module 200 (200') through the third channel 500 (500').
[0113] In this embodiment, the first memory and the second memory are single-port memories.
[0114] In this embodiment, the first channel is a system bus of a network chip, and the second channel and the third channel are hardware logic lines connecting the token calculation unit.
[0115] Example 5
[0116] This embodiment is used to explain in detail the implementation of the method of the present invention in a network chip product. This embodiment provides a network chip, including the multi-port multi-queue control module described in Embodiment 4.
[0117] Example 6
[0118] This embodiment is used to explain in detail the implementation of the method of the present invention on a network device product. This embodiment provides a network device, including the network chip described in Embodiment 5. In some embodiments of the present invention, the network device is an Ethernet switch.
[0119] The descriptions of the processes or structures corresponding to the above-mentioned figures have different emphases. For parts that are not described in detail in a certain process or structure, please refer to the relevant descriptions of other processes or structures.
[0120] The above embodiments are merely illustrative of the principles and effects of the present application and are not intended to limit the present application. Anyone familiar with the technology may modify or change the above embodiments without violating the spirit and scope of the present application. Therefore, all equivalent modifications or changes made by a person of ordinary skill in the art without departing from the spirit and technical ideas disclosed in the present application shall still be covered by the claims of the present application.
Claims
1. A traffic shaping data access method, characterized in that: The method is applied to a memory of a multi-port multi-queue traffic shaping control module in a network chip, wherein the memory does not include a register; wherein port shaping and queue shaping each use a pair of memories, wherein the pair of memories includes a first memory and a second memory; the first memory stores configuration data and is connected to a first channel and a second channel, wherein the configuration data is used for traffic shaping token bucket configuration, and the second memory stores token data and is connected to a third channel; the storage address depths of the configuration data and the token data are the same; the configuration data and the token data of each port have corresponding storage addresses, and the configuration data and the token data of each queue have corresponding storage addresses; The method includes a configuration read operation, a configuration write operation, a bucket reduction read operation, a bucket reduction write operation, a bucket filling read operation, and a bucket filling write operation; The configuration read operation is to read the corresponding configuration data in the first memory from the first channel according to the storage address; The configuration write operation is to write the configuration data from the first channel to the corresponding storage address in the first memory; The bucket filling read operation is to read the corresponding configuration data in the first memory from the second channel according to the storage address, and read the corresponding pre-bucket filling token data in the second memory from the third channel according to the storage address; The bucket filling write operation is to write the token data calculated after the bucket filling from the third channel to the corresponding storage address in the second memory according to the storage address; The bucket reduction read operation is to read the token data before the bucket reduction calculation corresponding to the second memory from the third channel according to the storage address; The bucket reduction write operation is to write the token data after the bucket reduction calculation from the third channel to the corresponding storage address in the second memory.
2. The traffic shaping data access method according to claim 1, characterized in that: When the first memory is a single-port memory, the bucket fill read operation needs to be executed in time-sharing with the configuration read operation and the configuration write operation; The second memory is a single-port memory. Bucket reduction read operation, bucket reduction write operation, bucket filling read operation and bucket filling write operation need to be executed in time sharing. In addition, when filling bucket calculation, the bucket filling read operation is performed first and then the bucket filling write operation is performed; when reducing bucket calculation, the bucket reduction read operation is performed first and then the bucket reduction write operation is performed.
3. The traffic shaping data access method according to claim 1, characterized in that: Configuration data includes bucket depth and bucket fill rate.
4. The traffic shaping data access method according to claim 3, characterized in that: The way to store the bucket depth is to store the bucket depth factor cbs_mul and the bucket depth index cbs_exp representing the bucket depth CBS, where CBS = cbs_mul × 2 cbs_exp .
5. The traffic shaping data access method according to claim 3, characterized in that: The way to store the bucket filling rate is to store the bucket filling frequency F representing the bucket filling rate grty, the bucket filling granularity grty_mul and the bucket filling granularity fine-tuning value grty_delt, wherein grty=(F-1)×grty_mul+grty_delt.
6. The traffic shaping data access method according to claim 5, characterized in that: At least one bucket filling frequency F is preset, and each port and queue selects the bucket filling frequency F according to traffic shaping requirements.
7. The traffic shaping data access method according to claim 5 or 6, characterized in that: The method of storing the bucket filling frequency F is to store the index value of the bucket filling frequency F.
8. A multi-port multi-queue control module for a network chip, characterized in that: It includes a memory and a data access control module, wherein the memory does not include a register; wherein, Port shaping and queue shaping each use a pair of memories, the pair of memories comprising a first memory and a second memory; the first memory stores configuration data and is connected to the first channel and the second channel, the configuration data is used for traffic shaping token bucket configuration, the second memory stores token data and is connected to the third channel; the storage address depth of the configuration data and the token data is the same; the configuration data and token data of each port have corresponding storage addresses, and the configuration data and token data of each queue have corresponding storage addresses; The data access control module uses the traffic shaping data access method as described in any one of claims 1-7 to control the reading of the memory.
9. A network chip, characterized in that It comprises the multi-port multi-queue control module as claimed in claim 8.
10. A network device, characterized in that Comprising the network chip as claimed in claim 9.
