Buffer settings

A buffer configuration includes:

  • Buffer pool size: The maximum memory a certain kind of traffic can occupy.
  • Buffer profile: Typically, most ports can share the same buffer configuration. You can create a buffer profile to attach that configuration to a port.
  • Buffer PG: The profile for each ingress priority.
  • Buffer queue: The profile for each egress queue.

The buffer configuration is stored in the BUFFER_POOL, BUFFER_PROFILE and BUFFER_PG tables. These tables are described in detail below.

Buffer Calculation Model

A traditional model, all buffer-related configurations must be configured manually in CONFIG_DB.

BUFFER_POOL Table

The BUFFER_POOL table defines the buffer pools for lossless/lossy and ingress/egress. It contains the following fields:

  • size: The size of the buffer pool.
  • type: Egress or ingress.
  • mode: Static or dynamic.
  • xoff: The size of the shared headroom pool, available for ingress_lossless_pool only.

There are four predefined buffer pools:

  • egress_lossless_pool
  • egress_lossy_pool
  • ingress_lossless_pool
  • ingress_lossy_pool

The size of egress_lossless_pool is always the maximum available memory whereas the the size of all the other pools is the quantity of the accumulative per
port/PG/queue reserved buffer size subtracted from the maximum available buffer size.

A default buffer configuration is pronanoded for both top of rack and leaf router topologies:

  • For a top of rack sonic, SONiC assumes a buffer configuration in sonic-buildimage/denanoce/netberg/<platform>/<sku>/buffers_defaults_t0.j2.
  • For a leaf router, SONiC assumes a buffer configuration in sonic-buildimage/denanoce/netberg/<platform>/<sku>/buffers_defaults_t1.j2.
  • All ports run at the highest speed.

This table is referenced by the BUFFER_PROFILE table.

BUFFER_PROFILE Table

The BUFFER_PROFILE table defines the buffer profiles. It contains the following fields:

  • pool: The buffer pool object defined in the BUFFER_POOL table.
  • xon and xoff*: The xon and xoff thresholds.
  • size: The headroom size.
  • dynamic_th: representing the proportion of currently available memory in the pool the PG or queue can occupy. It is calculated as: alpha = 2 ^ dynamic_th; proportion = alpha / (1 + alpha)

The table usually contains the following pre-defined profiles:

  • egress_lossless_profile
  • egress_lossy_profile
  • ingress_lossless_profile
  • ingress_lossy_profile

When the sonic is running in the traditional model, it has profiles for lossless traffic that get generated dynamically by querying pg_profile_lookup.ini with cable
length and speed as the key. The xoff threshold of lossless traffic is determined by the port’s cable length, speed and port MTU. The xoff threshold calculation uses
the configured port speed and cable length, and the maximum MTU (9100) regardless of the configured value.

This table is referenced by the physical ports (BUFFER_PG) table.

BUFFER_PG Table

The BUFFER_PG table defines the mapping from port/priority to the buffer profile. It pronanodes the ability to designate a buffer profile for traffic coming from a certain priority
group of a port. Typically, priorities 3 and 4 are used for lossless traffic, and other priorities are used for lossy traffic.

When the sonic is running in the traditional model, it is updated automatically when the port’s speed is updated. If the cable length has been configured, priorities 3 and 4 are
always generated for lossless traffic. A new profile is generated accordingly and referenced by the port in BUFFER_PG table when the port’s speed is updated. When the port’s cable
or MTU is updated, no update is made in the BUFFER_PG table.

The BUFFER_PG table can also be modified manually by creating a JSON file and then running sonic-cfggen -j qos_test_cfg.json –write-to-db.

BUFFER_QUEUE Table

The BUFFER_QUEUE table defines the mapping from a port orr queue to egress to the buffer profile. It pronanodes the ability to designate a buffer profile for traffic going
through a certain queue of a port. Typically, queue 3 and 4 are used for lossless traffic and others for lossy traffic.

The BUFFER_QUEUE table can be modified manually by creating a JSON file and then running config qos reload.

CABLE_LENGTH Table

THe CABLE_LENGTH table defines the length of the cables connected to the ports of the sonic.

Only 5m, 40m and 300m cable length values are supported. When updating the cable length of a port, the BUFFER_PG is not updated.

Configure a Buffer in the Traditional Model

You need to manually configure all buffer-related configurations in CONFIG_DB.

Create a New Buffer Pool

Typically, there is no need to create a new buffer pool. However, if a new one is required, complete the following steps:

  1. Create a JSON file called qos_test_buffer_pool.json that contains the buffer pool definition:
    admin@sonic:~$ sudo nano qos_test_buffer_pool.json
    {
      "BUFFER_POOL": {
        "egress_lossless_pool": {
        "mode": "dynamic",
        "size": "16777152",
        "type": "egress"
        }
      }
    }
  2. Apply the JSON file:
    admin@sonic:~$ sudo sonic-cfggen -j qos_test_buffer_pool.json --write-to-db

Update the BUFFER_PG Table

The lossless priority group of a port in BUFFER_PG table is updated automatically when the port’s speed is updated. For example, when Ethernet0’s speed is updated,
the entry Ethernet0|3-4 in BUFFER_PG is updated automatically.

To update the BUFFER_PG table:

  1. Create a JSON file called qos_test_buffer_pg.json. The JSON array should contain the definition of the new buffer profile; if you decide to reuse a profile that
    already exists, you don’t need to specify it again. It should also contain the definition of the new port or priority group to buffer profile map.

    admin@sonic:~$ sudo nano qos_test_buffer_pg.json
    {
      "BUFFER_PROFILE": {
         "ingress_lossy_test_profile": {
         "dynamic_th": "3",
         "pool": "[BUFFER_POOL|ingress_lossy_pool]",
         "size": "0"
         },
      },
      "BUFFER_PG": {
         "Ethernet0|0": {
         "profile": "[BUFFER_PROFILE|ingress_lossy_test_profile]"
         }
      }
    }
  2. Shut down interface Ethernet0.
    admin@sonic:~$ sudo config interface shutdown Ethernet0
  3. Apply the JSON file:
    admin@sonic:~$ sonic-cfggen -j qos_test_buffer_pg.json --write-to-db
  4. Start up the interface.
    admin@sonic:~$ sudo config interface startup Ethernet0

Update the BUFFER_PROFILE Table

Due to some restrictions in SONiC, you cannot update a buffer profile on the fly if it is already in use by a port/priority group pair. If you must change a buffer
profile, you need to define a new buffer profile and modify the BUFFER_PG entry by pointing to the new buffer profile. See the prenanoous section for instructions.

Update the CABLE_LENGTH Table

To update the CABLE_LENGTH table:

  1. Create a JSON file called qos_test_cable_length.json that contains the new cable length of a port:
    admin@sonic:~$ sudo nano qos_test_cable_length.json
    {
      "CABLE_LENGTH":{
        "AZURE":{
          "Ethernet0": "5m"
        }
      }
    }
  2. Since the BUFFER_PG table is not updated automatically after you update the cable length, you need to manually save and reload the configuration.
    admin@sonic:~$ sudo config save -y
    admin@sonic:~$ sudo config reload -y

Display the BUFFER_POOL and BUFFER_PROFILE

To display BUFFER_POOL and BUFFER_PROFILE tables, run:

admin@sonic:~$ mmuconfig -l
Pool: ingress_l1ossless_pool
----  --------
mode  dynamic
size  34056960
type  ingress
xoff  4185600
----  --------
Pool: lossy_pool
----  --------
mode  dynamic
size  14595840
type  egress
xoff  0
----  --------
Profile: ingress_lossy_profile
---------  ------------------------
pool       [BUFFER_POOL|lossy_pool]
size       0
static_th  23001600
---------  ------------------------
Profile: ingress_lossless_profile
----------  -----------------------------------
dynamic_th  1
pool        [BUFFER_POOL|ingress_lossless_pool]
size        1518
xoff        38816
xon_offset  13440
----------  -----------------------------------
Profile: pg_lossless_100000_40m_profile
----------  -----------------------------------
pool        [BUFFER_POOL|ingress_lossless_pool]
xon         0
xon_offset  13440
xoff        38816
size        1518
dynamic_th  1
----------  -----------------------------------
Profile: egress_lossy_profile
----------  ------------------------
dynamic_th  2
pool        [BUFFER_POOL|lossy_pool]
size        1518
----------  ------------------------
Profile: egress_lossless_profile
---------  -----------------------------------
pool       [BUFFER_POOL|ingress_lossless_pool]
size       0
static_th  23001600
---------  -----------------------------------

Update Buffers and QoS Configuration Using Templates

Buffers and QoS configuration can be rendered from templates. If you are going to update the configuration of the entire sonic in batch mode, follow the steps below:

  1. Modify the templates:
    • For buffer configuration, modify the /usr/share/sonic/templates/buffers_config.j2 file.
    • For QoS configuration, modify the /usr/share/sonic/templates/qos_config.j2 file.
  2. Reload the QoS configuration and the sonic:
    admin@sonic:~$ sudo config qos reload -y
NEWS

Latest news