Skip to content

bf_switchd crashes with "Assertion mempool_obj_arr != NULL" when loading custom P4 program #119

@Vineet1101

Description

@Vineet1101

Issue Summary

I am trying to run a custom P4 program (main.p4) on p4-dpdk-target.
bf_switchd successfully starts system services and loads the config file, but then terminates with:

bf_switchd: switch_config.c:252: switch_p4_pipeline_config_init: Assertion `mempool_obj_arr != NULL' failed.
Aborted

Even though ports.json contains "mempool_name": "MEMPOOL0", the pipeline initialization fails.


Environment

Component Version / Details
OS Ubuntu 24.04 (VM on VirtualBox)
P4-DPDK-Target Latest build from GitHub (commit: )
SDE Install Dir /home/p4/sde/install
Python 3.12 (virtualenv)
DPDK Built automatically by p4-dpdk-target
Program PSA → simple_l2l3_lpm.p4

Steps Performed

1. Set environment variables

export SDE=/home/p4/sde
export SDE_INSTALL=/home/p4/sde/install
export LD_LIBRARY_PATH=$SDE_INSTALL/lib:$SDE_INSTALL/lib64:$SDE_INSTALL/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH
export PATH=$SDE_INSTALL/bin:$PATH

2. Launch bf_switchd

sudo -E PATH=$PATH LD_LIBRARY_PATH=$LD_LIBRARY_PATH \
    $SDE_INSTALL/bin/bf_switchd \
    --install-dir $SDE_INSTALL \
    --conf-file /home/p4/sde/p4-dpdk-target/examples/psa/simple_l2l3_lpm/switchd.config

3. bf_switchd output

rm: cannot remove '/tmp/iospec.io': No such file or directory
bf_switchd_lib_init_local: Fail to delete /tmp/iospec.io file
bf_switchd: system services initialized
bf_switchd: loading conf_file .../switchd.config...
bf_switchd: processing device configuration...
  Family: dpdk
bf_switchd: processing P4 configuration...
bf_switchd: switch_config.c:252: switch_p4_pipeline_config_init: Assertion `mempool_obj_arr != NULL' failed.
Aborted

Directory Structure

sde/
 ├── install/
 └── p4-dpdk-target/
      └── examples/psa/simple_l2l3_lpm/
           ├── simple_l2l3_lpm.p4
           ├── simple_l2l3_lpm.bfrt.json
           ├── simple_l2l3_lpm.spec
           ├── context.json
           ├── ports.json
           └── switchd.config

Config Files Used

switchd.config

{
    "chip_list": [
        {
            "id": "asic-0",
            "chip_family": "dpdk",
            "instance": 0
        }
    ],
    "instance": 0,
"mempool": [
    {
        "name": "MEMPOOL0",
        "buffer_size": 2048,
        "num_buffers": 16384
    }
],

"p4_devices": [
    {
        "device-id": 0,
        "eal-args": "dummy -n 4 -c 7",
        "p4_programs": [
            {
                "program-name": "simple_l2l3_lpm",
                "sai_default_init": false,
                "bfrt-config": "/home/p4/sde/p4-dpdk-target/examples/psa/simple_l2l3_lpm/simple_l2l3_lpm.bfrt.json",
                "port-config": "/home/p4/sde/p4-dpdk-target/examples/psa/simple_l2l3_lpm/ports.json",
                "p4_pipelines": [
                    {
                        "p4_pipeline_name": "pipe",
                        "context": "/home/p4/sde/p4-dpdk-target/examples/psa/simple_l2l3_lpm/context.json",
                        "config": "/home/p4/sde/p4-dpdk-target/examples/psa/simple_l2l3_lpm/simple_l2l3_lpm.spec",
                        "pipe_scope": [0],
                        "path": "/home/p4/sde/p4-dpdk-target/examples/psa/simple_l2l3_lpm"
                    }
                ]
            }
        ]
    }
]

}


ports.json

{
    "ports": [
        {
            "dev_port": 0,
            "port_name": "TAP0",
            "mempool_name": "MEMPOOL0",
            "pipe_name": "pipe",
            "port_dir": "default",
            "port_in_id": 0,
            "port_out_id": 0,
            "port_type": "tap",
            "tap_port_attributes": {
                "mtu": 1500
            }
        }
    ]
}

Question / Request

bf_switchd fails with:

Assertion `mempool_obj_arr != NULL' failed.

Even though:

  • mempool is defined in switchd.config

  • mempool_name: "MEMPOOL0" is defined in ports.json

  • config JSON and context JSON exist and are readable

Any guidance or an example for a minimal working PSA pipeline config for dpdk-target would be greatly appreciated.


@Dscano can you help with this once this programs work fine I have file to modify and add tables and then I can start writing the documentation

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions