1. Feb 20, 2024
  2. Feb 19, 2024
  3. Feb 18, 2024
  4. Feb 17, 2024
    • Ivan Vecera's avatar
      i40e: Remove VEB recursion · f09cbb6c
      Ivan Vecera authored
      
      
      The VEB (virtual embedded switch) as a switch element can be
      connected according datasheet though its uplink to:
      - Physical port
      - Port Virtualizer (not used directly by i40e driver but can
        be present in MFP mode where the physical port is shared
        between PFs)
      - No uplink (aka floating VEB)
      
      But VEB uplink cannot be connected to another VEB and any attempt
      to do so results in:
      
      "i40e 0000:02:00.0: couldn't add VEB, err -EIO aq_err I40E_AQ_RC_ENOENT"
      
      that indicates "the uplink SEID does not point to valid element".
      
      Remove this logic from the driver code this way:
      
      1) For debugfs only allow to build floating VEB (uplink_seid == 0)
         or main VEB (uplink_seid == mac_seid)
      2) Do not recurse in i40e_veb_link_event() as no VEB cannot have
         sub-VEBs
      3) Ditto for i40e_veb_rebuild() + simplify the function as we know
         that the VEB for rebuild can be only the main LAN VEB or some
         of the floating VEBs
      4) In i40e_rebuild() there is no need to check veb->uplink_seid
         as the possible ones are 0 and MAC SEID
      5) In i40e_vsi_release() do not take into account VEBs whose
         uplink is another VEB as this is not possible
      6) Remove veb_idx field from i40e_veb as a VEB cannot have
         sub-VEBs
      
      Tested using i40e debugfs interface:
      1) Initial state
      [root@cnb-03 net-next]# CMD="/sys/kernel/debug/i40e/0000:02:00.0/command"
      [root@cnb-03 net-next]# echo dump switch > $CMD
      [root@cnb-03 net-next]# dmesg -c
      [   98.440641] i40e 0000:02:00.0: header: 3 reported 3 total
      [   98.446053] i40e 0000:02:00.0: type=19 seid=392 uplink=160 downlink=16
      [   98.452593] i40e 0000:02:00.0: type=17 seid=160 uplink=2 downlink=0
      [   98.458856] i40e 0000:02:00.0: type=19 seid=390 uplink=160 downlink=16
      
      2) Add floating VEB
      [root@cnb-03 net-next]# echo add relay > $CMD
      [root@cnb-03 net-next]# dmesg -c
      [  122.745630] i40e 0000:02:00.0: added relay 162
      [root@cnb-03 net-next]# echo dump switch > $CMD
      [root@cnb-03 net-next]# dmesg -c
      [  136.650049] i40e 0000:02:00.0: header: 4 reported 4 total
      [  136.655466] i40e 0000:02:00.0: type=19 seid=392 uplink=160 downlink=16
      [  136.661994] i40e 0000:02:00.0: type=17 seid=160 uplink=2 downlink=0
      [  136.668264] i40e 0000:02:00.0: type=19 seid=390 uplink=160 downlink=16
      [  136.674787] i40e 0000:02:00.0: type=17 seid=162 uplink=0 downlink=0
      
      3) Add VMDQ2 VSI to this new VEB
      [root@cnb-03 net-next]# dmesg -c
      [  168.351763] i40e 0000:02:00.0: added VSI 394 to relay 162
      [  168.374652] enp2s0f0np0v0: NIC Link is Up, 40 Gbps Full Duplex, Flow Control: None
      [root@cnb-03 net-next]# echo dump switch > $CMD
      [root@cnb-03 net-next]# dmesg -c
      [  195.683204] i40e 0000:02:00.0: header: 5 reported 5 total
      [  195.688611] i40e 0000:02:00.0: type=19 seid=394 uplink=162 downlink=16
      [  195.695143] i40e 0000:02:00.0: type=17 seid=162 uplink=0 downlink=0
      [  195.701410] i40e 0000:02:00.0: type=19 seid=392 uplink=160 downlink=16
      [  195.707935] i40e 0000:02:00.0: type=17 seid=160 uplink=2 downlink=0
      [  195.714201] i40e 0000:02:00.0: type=19 seid=390 uplink=160 downlink=16
      
      4) Try to delete the VEB
      [root@cnb-03 net-next]# echo del relay 162 > $CMD
      [root@cnb-03 net-next]# dmesg -c
      [  239.260901] i40e 0000:02:00.0: deleting relay 162
      [  239.265621] i40e 0000:02:00.0: can't remove VEB 162 with 1 VSIs left
      
      5) Do PF reset and check switch status after rebuild
      [root@cnb-03 net-next]# echo pfr > $CMD
      [root@cnb-03 net-next]# echo dump switch > $CMD
      [root@cnb-03 net-next]# dmesg -c
      ...
      [  272.333655] i40e 0000:02:00.0: header: 5 reported 5 total
      [  272.339066] i40e 0000:02:00.0: type=19 seid=394 uplink=162 downlink=16
      [  272.345599] i40e 0000:02:00.0: type=17 seid=162 uplink=0 downlink=0
      [  272.351862] i40e 0000:02:00.0: type=19 seid=392 uplink=160 downlink=16
      [  272.358387] i40e 0000:02:00.0: type=17 seid=160 uplink=2 downlink=0
      [  272.364654] i40e 0000:02:00.0: type=19 seid=390 uplink=160 downlink=16
      
      6) Delete VSI and delete VEB
      [  297.199116] i40e 0000:02:00.0: deleting VSI 394
      [  299.807580] i40e 0000:02:00.0: deleting relay 162
      [  309.767905] i40e 0000:02:00.0: header: 3 reported 3 total
      [  309.773318] i40e 0000:02:00.0: type=19 seid=392 uplink=160 downlink=16
      [  309.779845] i40e 0000:02:00.0: type=17 seid=160 uplink=2 downlink=0
      [  309.786111] i40e 0000:02:00.0: type=19 seid=390 uplink=160 downlink=16
      
      Reviewed-by: default avatarWojciech Drewek <wojciech.drewek@intel.com>
      Signed-off-by: default avatarIvan Vecera <ivecera@redhat.com>
      Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel)
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      f09cbb6c
    • Ivan Vecera's avatar
      i40e: Fix broken support for floating VEBs · 08cdde31
      Ivan Vecera authored
      
      
      Although the i40e supports so-called floating VEB (VEB without
      an uplink connection to external network), this support is
      broken. This functionality is currently unused (except debugfs)
      but it will be used by subsequent series for switchdev mode
      slow-path. Fix this by following:
      
      1) Handle correctly floating VEB (VEB with uplink_seid == 0)
         in i40e_reconstitute_veb() and look for owner VSI and
         create it only for non-floating VEBs and also set bridge
         mode only for such VEBs as the floating ones are using
         always VEB mode.
      2) Handle correctly floating VEB in i40e_veb_release() and
         disallow its release when there are some VSIs. This is
         different from regular VEB that have owner VSI that is
         connected to VEB's uplink after VEB deletion by FW.
      3) Fix i40e_add_veb() to handle 'vsi' that is NULL for floating
         VEBs. For floating VEB use 0 for downlink SEID and 'true'
         for 'default_port' parameters as per datasheet.
      4) Fix 'add relay' command in i40e_dbg_command_write() to allow
         to create floating VEB by 'add relay 0 0' or 'add relay'
      
      Tested using debugfs:
      1) Initial state
      [root@host net-next]# echo dump switch > $CMD
      [root@host net-next]# dmesg -c
      [  173.701286] i40e 0000:02:00.0: header: 3 reported 3 total
      [  173.706701] i40e 0000:02:00.0: type=19 seid=392 uplink=160 downlink=16
      [  173.713241] i40e 0000:02:00.0: type=17 seid=160 uplink=2 downlink=0
      [  173.719507] i40e 0000:02:00.0: type=19 seid=390 uplink=160 downlink=16
      
      2) Add floating VEB
      [root@host net-next]# CMD="/sys/kernel/debug/i40e/0000:02:00.0/command"
      [root@host net-next]# echo add relay > $CMD
      [root@host net-next]# dmesg -c
      [  245.551720] i40e 0000:02:00.0: added relay 162
      [root@host net-next]# echo dump switch > $CMD
      [root@host net-next]# dmesg -c
      [  276.984371] i40e 0000:02:00.0: header: 4 reported 4 total
      [  276.989779] i40e 0000:02:00.0: type=19 seid=392 uplink=160 downlink=16
      [  276.996302] i40e 0000:02:00.0: type=17 seid=160 uplink=2 downlink=0
      [  277.002569] i40e 0000:02:00.0: type=19 seid=390 uplink=160 downlink=16
      [  277.009091] i40e 0000:02:00.0: type=17 seid=162 uplink=0 downlink=0
      
      3) Add VMDQ2 VSI to this new VEB
      [root@host net-next]# echo add vsi 162 > $CMD
      [root@host net-next]# dmesg -c
      [  332.314030] i40e 0000:02:00.0: added VSI 394 to relay 162
      [  332.337486] enp2s0f0np0v0: NIC Link is Up, 40 Gbps Full Duplex, Flow Control: None
      [root@host net-next]# echo dump switch > $CMD
      [root@host net-next]# dmesg -c
      [  387.284490] i40e 0000:02:00.0: header: 5 reported 5 total
      [  387.289904] i40e 0000:02:00.0: type=19 seid=394 uplink=162 downlink=16
      [  387.296446] i40e 0000:02:00.0: type=17 seid=162 uplink=0 downlink=0
      [  387.302708] i40e 0000:02:00.0: type=19 seid=392 uplink=160 downlink=16
      [  387.309234] i40e 0000:02:00.0: type=17 seid=160 uplink=2 downlink=0
      [  387.315500] i40e 0000:02:00.0: type=19 seid=390 uplink=160 downlink=16
      
      4) Try to delete the VEB
      [root@host net-next]# echo del relay 162 > $CMD
      [root@host net-next]# dmesg -c
      [  428.749297] i40e 0000:02:00.0: deleting relay 162
      [  428.754011] i40e 0000:02:00.0: can't remove VEB 162 with 1 VSIs left
      
      5) Do PF reset and check switch status after rebuild
      [root@host net-next]# echo pfr > $CMD
      [root@host net-next]# echo dump switch > $CMD
      [root@host net-next]# dmesg -c
      [  738.056172] i40e 0000:02:00.0: header: 5 reported 5 total
      [  738.061577] i40e 0000:02:00.0: type=19 seid=394 uplink=162 downlink=16
      [  738.068104] i40e 0000:02:00.0: type=17 seid=162 uplink=0 downlink=0
      [  738.074367] i40e 0000:02:00.0: type=19 seid=392 uplink=160 downlink=16
      [  738.080892] i40e 0000:02:00.0: type=17 seid=160 uplink=2 downlink=0
      [  738.087160] i40e 0000:02:00.0: type=19 seid=390 uplink=160 downlink=16
      
      6) Delete VSI and delete VEB
      [root@host net-next]# echo del vsi 394 > $CMD
      [root@host net-next]# echo del relay 162 > $CMD
      [root@host net-next]# echo dump switch > $CMD
      [root@host net-next]# dmesg -c
      [ 1233.081126] i40e 0000:02:00.0: deleting VSI 394
      [ 1239.345139] i40e 0000:02:00.0: deleting relay 162
      [ 1244.886920] i40e 0000:02:00.0: header: 3 reported 3 total
      [ 1244.892328] i40e 0000:02:00.0: type=19 seid=392 uplink=160 downlink=16
      [ 1244.898853] i40e 0000:02:00.0: type=17 seid=160 uplink=2 downlink=0
      [ 1244.905119] i40e 0000:02:00.0: type=19 seid=390 uplink=160 downlink=16
      
      Reviewed-by: default avatarWojciech Drewek <wojciech.drewek@intel.com>
      Signed-off-by: default avatarIvan Vecera <ivecera@redhat.com>
      Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel)
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      08cdde31
    • Ivan Vecera's avatar
      i40e: Add helpers to find VSI and VEB by SEID and use them · b7fac08d
      Ivan Vecera authored
      
      
      Add two helpers i40e_(veb|vsi)_get_by_seid() to find corresponding
      VEB or VSI by their SEID value and use these helpers to replace
      existing open-coded loops.
      
      Reviewed-by: default avatarWojciech Drewek <wojciech.drewek@intel.com>
      Signed-off-by: default avatarIvan Vecera <ivecera@redhat.com>
      Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel)
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      b7fac08d
    • Ivan Vecera's avatar
      i40e: Introduce and use macros for iterating VSIs and VEBs · b1f1b46f
      Ivan Vecera authored
      
      
      Introduce i40e_for_each_vsi() and i40e_for_each_veb() helper
      macros and use them to iterate relevant arrays.
      
      Replace pattern:
      for (i = 0; i < pf->num_alloc_vsi; i++)
      by:
      i40e_for_each_vsi(pf, i, vsi)
      
      and pattern:
      for (i = 0; i < I40E_MAX_VEB; i++)
      by
      i40e_for_each_veb(pf, i, veb)
      
      These macros also check if array item pf->vsi[i] or pf->veb[i]
      are not NULL and skip such items so we can remove redundant
      checks from loop bodies.
      
      Reviewed-by: default avatarWojciech Drewek <wojciech.drewek@intel.com>
      Signed-off-by: default avatarIvan Vecera <ivecera@redhat.com>
      Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel)
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      b1f1b46f
    • Ivan Vecera's avatar
      i40e: Use existing helper to find flow director VSI · 7e6cec7d
      Ivan Vecera authored
      
      
      Use existing i40e_find_vsi_by_type() to find a VSI
      associated with flow director.
      
      Reviewed-by: default avatarWojciech Drewek <wojciech.drewek@intel.com>
      Signed-off-by: default avatarIvan Vecera <ivecera@redhat.com>
      Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel)
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      7e6cec7d
  5. Feb 16, 2024