Back to home page

OSCL-LXR

 
 

    


0001 #!/bin/bash
0002 # SPDX-License-Identifier: GPL-2.0
0003 
0004 # Test for physical ports resource. The test splits each splittable port
0005 # to its width and checks that eventually the number of physical ports equals
0006 # the maximum number of physical ports.
0007 
0008 PORT_NUM_NETIFS=0
0009 
0010 declare -a unsplit
0011 
0012 port_setup_prepare()
0013 {
0014         :
0015 }
0016 
0017 port_cleanup()
0018 {
0019         pre_cleanup
0020 
0021         for port in "${unsplit[@]}"; do
0022                 devlink port unsplit $port
0023                 check_err $? "Did not unsplit $netdev"
0024         done
0025         unsplit=()
0026 }
0027 
0028 split_all_ports()
0029 {
0030         local should_fail=$1; shift
0031 
0032         # Loop over the splittable netdevs and create tuples of netdev along
0033         # with its width. For example:
0034         # '$netdev1 $count1 $netdev2 $count2...', when:
0035         # $netdev1-2 are splittable netdevs in the device, and
0036         # $count1-2 are the netdevs width respectively.
0037         while read netdev count <<<$(
0038                 devlink -j port show |
0039                 jq -r '.[][] | select(.splittable==true) | "\(.netdev) \(.lanes)"'
0040                 )
0041                 [[ ! -z $netdev ]]
0042         do
0043                 devlink port split $netdev count $count
0044                 check_err $? "Did not split $netdev into $count"
0045                 unsplit+=( "${netdev}s0" )
0046         done
0047 }
0048 
0049 port_test()
0050 {
0051         local max_ports=$1; shift
0052         local should_fail=$1; shift
0053 
0054         split_all_ports $should_fail
0055 
0056         occ=$(devlink -j resource show $DEVLINK_DEV \
0057               | jq '.[][][] | select(.name=="physical_ports") |.["occ"]')
0058 
0059         [[ $occ -eq $max_ports ]]
0060         check_err_fail $should_fail $? "Attempt to create $max_ports ports (actual result $occ)"
0061 
0062 }