Hi Vladimir,
I’ve a committed a new version of switchdctl.py that you can grab here. This version has the capability:
- to run one single p4 program on all pipes (pipe_scope [0,1,2,3] default)
- to run multiple p4 program on dual or quad pipes
- pipe_scope [0],pipe_scope [1]
- pipe_scope [0],pipe_scope [1],pipe_scope [2],pipe_scope [3]
To use it:
- single program on all pipes
p4@UMU-Stordis-bf2556x-1t-P4:~/tmp/rare/bfrt_python$ ./switchdctl.py --single --p4-program bf_router
single pipe output:
SDE=/home/p4/BF/bf-sde-9.3.0
switchdctl.py running on NPU (single pipe mode)
GRPC_ADDRESS: localhost:50052
P4_BASE: /home/p4/BF/bf-sde-9.3.0/install/share/tofinopd/
P4_NAME_LIST: ['bf_router']
DEVICE_ID: 0
CLIENT_ID: 0
PROFILE_NAME: pipe
Binding client[0] to device[0]@localhost:50052 with MASTER role
Subscribe attempt #1
Subscribe response received 0
Setting config for: bf_router
p4_base = /home/p4/BF/bf-sde-9.3.0/install/share/tofinopd/
Sending VERIFY, VERIFY_AND_WARM_INIT_BEGIN and WARM_INIT_END
WARM_INIT_FINISHED received
Config sent for ['bf_router'] !
Tearing down gracefully grpc session with localhost:50052
- 2 p4 program on dual pipes
./switchdctl.py --multi dual --p4-p0 bf_router_a --p4-p1 bf_router_b
dual pipe output:
SDE=/home/p4/BF/bf-sde-9.3.0
switchdctl.py running on NPU (dual pipe mode)
GRPC_ADDRESS: localhost:50052
P4_BASE: /home/p4/BF/bf-sde-9.3.0/install/share/tofinopd/
P4_NAME_LIST: ['bf_router_a', 'bf_router_b']
DEVICE_ID: 0
CLIENT_ID: 0
PROFILE_NAME: pipe
Binding client[0] to device[0]@localhost:50052 with MASTER role
Subscribe attempt #1
Subscribe response received 0
Setting config for: bf_router_a
Setting config for: bf_router_b
Sending VERIFY, VERIFY_AND_WARM_INIT_BEGIN and WARM_INIT_END
WARM_INIT_FINISHED received
Config sent for ['bf_router_a', 'bf_router_b'] !
Tearing down gracefully grpc session with localhost:50052
If by any chance you could test this script on a quad pipe TOFINO switch, I would be grateful.
However, this does not correct my bf_shell problem. I must miss something in my python 2/3 environment …
(I’m using genuine ubuntu 18.04 / debian 10 install and p4studio_build.py script …) It seems something related to python environment … which environment OS are you using ?
bfshell> bfrt_python
cwd : /home/p4
Devices found : [0]
We've found 2 p4 programs for device 0:
bf_router_a
bf_router_b
Creating tree for dev 0 and program bf_router_a
> /home/p4/BF/bf-sde-9.3.0/install/lib/python3.4/bfrtcli.py(1022)_set_dynamic_method()
-> setattr(self, method_name, types.MethodType(d[method_name], self))
(Pdb) exit
Traceback (most recent call last):
File "/home/p4/BF/bf-sde-9.3.0/install/lib/python3.4/bfrtcli.py", line 1905, in start_bfrt
sts = load_bfrt(dev_id_list)
File "/home/p4/BF/bf-sde-9.3.0/install/lib/python3.4/bfrtcli.py", line 1870, in load_bfrt
sts = populate_bfrt(dev_id_list)
File "/home/p4/BF/bf-sde-9.3.0/install/lib/python3.4/bfrtcli.py", line 1820, in populate_bfrt
make_deep_tree(p4_name, bf_rt_info, dev_node, cintf)
File "/home/p4/BF/bf-sde-9.3.0/install/lib/python3.4/bfrtcli.py", line 1759, in make_deep_tree
BFLeaf(name=prefs[-1], c_tbl=tbl_obj, cintf=cintf, parent_node=parent_node)
File "/home/p4/BF/bf-sde-9.3.0/install/lib/python3.4/bfrtcli.py", line 573, in __init__
self._init_table_methods()
File "/home/p4/BF/bf-sde-9.3.0/install/lib/python3.4/bfrtcli.py", line 986, in _init_table_methods
self._create_get(key_fields)
File "/home/p4/BF/bf-sde-9.3.0/install/lib/python3.4/bfrtcli.py", line 1459, in _create_get
bf_rt cli python call failed
get_method = self._set_dynamic_method(code, method_name)
File "/home/p4/BF/bf-sde-9.3.0/install/lib/python3.4/bfrtcli.py", line 1022, in _set_dynamic_method
setattr(self, method_name, types.MethodType(d[method_name], self))
File "/home/p4/BF/bf-sde-9.3.0/install/lib/python3.4/bfrtcli.py", line 1022, in _set_dynamic_method
setattr(self, method_name, types.MethodType(d[method_name], self))
File "/home/p4/BF/bf-sde-9.3.0/install/lib/python3.4/bdb.py", line 48, in trace_dispatch
return self.dispatch_line(frame)
File "/home/p4/BF/bf-sde-9.3.0/install/lib/python3.4/bdb.py", line 67, in dispatch_line
if self.quitting: raise BdbQuit
bdb.BdbQuit
bfrt_cli_cmd:198 could not initialize bf_rt for the cli. err: 1