1. 06 4月, 2022 1 次提交
  2. 05 4月, 2022 2 次提交
    • A
      ice: Do not skip not enabled queues in ice_vc_dis_qs_msg · 05ef6813
      Anatolii Gerasymenko 提交于
      Disable check for queue being enabled in ice_vc_dis_qs_msg, because
      there could be a case when queues were created, but were not enabled.
      We still need to delete those queues.
      
      Normal workflow for VF looks like:
      Enable path:
      VIRTCHNL_OP_ADD_ETH_ADDR (opcode 10)
      VIRTCHNL_OP_CONFIG_VSI_QUEUES (opcode 6)
      VIRTCHNL_OP_ENABLE_QUEUES (opcode 8)
      
      Disable path:
      VIRTCHNL_OP_DISABLE_QUEUES (opcode 9)
      VIRTCHNL_OP_DEL_ETH_ADDR (opcode 11)
      
      The issue appears only in stress conditions when VF is enabled and
      disabled very fast.
      Eventually there will be a case, when queues are created by
      VIRTCHNL_OP_CONFIG_VSI_QUEUES, but are not enabled by
      VIRTCHNL_OP_ENABLE_QUEUES.
      In turn, these queues are not deleted by VIRTCHNL_OP_DISABLE_QUEUES,
      because there is a check whether queues are enabled in
      ice_vc_dis_qs_msg.
      
      When we bring up the VF again, we will see the "Failed to set LAN Tx queue
      context" error during VIRTCHNL_OP_CONFIG_VSI_QUEUES step. This
      happens because old 16 queues were not deleted and VF requests to create
      16 more, but ice_sched_get_free_qparent in ice_ena_vsi_txq would fail to
      find a parent node for first newly requested queue (because all nodes
      are allocated to 16 old queues).
      
      Testing Hints:
      
      Just enable and disable VF fast enough, so it would be disabled before
      reaching VIRTCHNL_OP_ENABLE_QUEUES.
      
      while true; do
              ip link set dev ens785f0v0 up
              sleep 0.065 # adjust delay value for you machine
              ip link set dev ens785f0v0 down
      done
      
      Fixes: 77ca27c4 ("ice: add support for virtchnl_queue_select.[tx|rx]_queues bitmap")
      Signed-off-by: NAnatolii Gerasymenko <anatolii.gerasymenko@intel.com>
      Tested-by: NKonrad Jankowski <konrad0.jankowski@intel.com>
      Signed-off-by: NAlice Michael <alice.michael@intel.com>
      Signed-off-by: NTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: NPaolo Abeni <pabeni@redhat.com>
      05ef6813
    • A
      ice: Set txq_teid to ICE_INVAL_TEID on ring creation · ccfee182
      Anatolii Gerasymenko 提交于
      When VF is freshly created, but not brought up, ring->txq_teid
      value is by default set to 0.
      But 0 is a valid TEID. On some platforms the Root Node of
      Tx scheduler has a TEID = 0. This can cause issues as shown below.
      
      The proper way is to set ring->txq_teid to ICE_INVAL_TEID (0xFFFFFFFF).
      
      Testing Hints:
      echo 1 > /sys/class/net/ens785f0/device/sriov_numvfs
      ip link set dev ens785f0v0 up
      ip link set dev ens785f0v0 down
      
      If we have freshly created VF and quickly turn it on and off, so there
      would be no time to reach VIRTCHNL_OP_CONFIG_VSI_QUEUES stage, then
      VIRTCHNL_OP_DISABLE_QUEUES stage will fail with error:
      [  639.531454] disable queue 89 failed 14
      [  639.532233] Failed to disable LAN Tx queues, error: ICE_ERR_AQ_ERROR
      [  639.533107] ice 0000:02:00.0: Failed to stop Tx ring 0 on VSI 5
      
      The reason for the fail is that we are trying to send AQ command to
      delete queue 89, which has never been created and receive an "invalid
      argument" error from firmware.
      
      As this queue has never been created, it's teid and ring->txq_teid
      have default value 0.
      ice_dis_vsi_txq has a check against non-existent queues:
      
      node = ice_sched_find_node_by_teid(pi->root, q_teids[i]);
      if (!node)
      	continue;
      
      But on some platforms the Root Node of Tx scheduler has a teid = 0.
      Hence, ice_sched_find_node_by_teid finds a node with teid = 0 (it is
      pi->root), and we go further to submit an erroneous request to firmware.
      
      Fixes: 37bb8390 ("ice: Move common functions out of ice_main.c part 7/7")
      Signed-off-by: NAnatolii Gerasymenko <anatolii.gerasymenko@intel.com>
      Reviewed-by: NMaciej Fijalkowski <maciej.fijalkowski@intel.com>
      Tested-by: NKonrad Jankowski <konrad0.jankowski@intel.com>
      Signed-off-by: NAlice Michael <alice.michael@intel.com>
      Signed-off-by: NTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: NPaolo Abeni <pabeni@redhat.com>
      ccfee182
  3. 01 4月, 2022 3 次提交
    • I
      ice: Fix broken IFF_ALLMULTI handling · 1273f895
      Ivan Vecera 提交于
      Handling of all-multicast flag and associated multicast promiscuous
      mode is broken in ice driver. When an user switches allmulticast
      flag on or off the driver checks whether any VLANs are configured
      over the interface (except default VLAN 0).
      
      If any extra VLANs are registered it enables multicast promiscuous
      mode for all these VLANs (including default VLAN 0) using
      ICE_SW_LKUP_PROMISC_VLAN look-up type. In this situation all
      multicast packets tagged with known VLAN ID or untagged are received
      and multicast packets tagged with unknown VLAN ID ignored.
      
      If no extra VLANs are registered (so only VLAN 0 exists) it enables
      multicast promiscuous mode for VLAN 0 and uses ICE_SW_LKUP_PROMISC
      look-up type. In this situation any multicast packets including
      tagged ones are received.
      
      The driver handles IFF_ALLMULTI in ice_vsi_sync_fltr() this way:
      
      ice_vsi_sync_fltr() {
        ...
        if (changed_flags & IFF_ALLMULTI) {
          if (netdev->flags & IFF_ALLMULTI) {
            if (vsi->num_vlans > 1)
              ice_set_promisc(..., ICE_MCAST_VLAN_PROMISC_BITS);
            else
              ice_set_promisc(..., ICE_MCAST_PROMISC_BITS);
          } else {
            if (vsi->num_vlans > 1)
              ice_clear_promisc(..., ICE_MCAST_VLAN_PROMISC_BITS);
            else
              ice_clear_promisc(..., ICE_MCAST_PROMISC_BITS);
          }
        }
        ...
      }
      
      The code above depends on value vsi->num_vlan that specifies number
      of VLANs configured over the interface (including VLAN 0) and
      this is problem because that value is modified in NDO callbacks
      ice_vlan_rx_add_vid() and ice_vlan_rx_kill_vid().
      
      Scenario 1:
      1. ip link set ens7f0 allmulticast on
      2. ip link add vlan10 link ens7f0 type vlan id 10
      3. ip link set ens7f0 allmulticast off
      4. ip link set ens7f0 allmulticast on
      
      [1] In this scenario IFF_ALLMULTI is enabled and the driver calls
          ice_set_promisc(..., ICE_MCAST_PROMISC_BITS) that installs
          multicast promisc rule with non-VLAN look-up type.
      [2] Then VLAN with ID 10 is added and vsi->num_vlan incremented to 2
      [3] Command switches IFF_ALLMULTI off and the driver calls
          ice_clear_promisc(..., ICE_MCAST_VLAN_PROMISC_BITS) but this
          call is effectively NOP because it looks for multicast promisc
          rules for VLAN 0 and VLAN 10 with VLAN look-up type but no such
          rules exist. So the all-multicast remains enabled silently
          in hardware.
      [4] Command tries to switch IFF_ALLMULTI on and the driver calls
          ice_clear_promisc(..., ICE_MCAST_PROMISC_BITS) but this call
          fails (-EEXIST) because non-VLAN multicast promisc rule already
          exists.
      
      Scenario 2:
      1. ip link add vlan10 link ens7f0 type vlan id 10
      2. ip link set ens7f0 allmulticast on
      3. ip link add vlan20 link ens7f0 type vlan id 20
      4. ip link del vlan10 ; ip link del vlan20
      5. ip link set ens7f0 allmulticast off
      
      [1] VLAN with ID 10 is added and vsi->num_vlan==2
      [2] Command switches IFF_ALLMULTI on and driver installs multicast
          promisc rules with VLAN look-up type for VLAN 0 and 10
      [3] VLAN with ID 20 is added and vsi->num_vlan==3 but no multicast
          promisc rules is added for this new VLAN so the interface does
          not receive MC packets from VLAN 20
      [4] Both VLANs are removed but multicast rule for VLAN 10 remains
          installed so interface receives multicast packets from VLAN 10
      [5] Command switches IFF_ALLMULTI off and because vsi->num_vlan is 1
          the driver tries to remove multicast promisc rule for VLAN 0
          with non-VLAN look-up that does not exist.
          All-multicast looks disabled from user point of view but it
          is partially enabled in HW (interface receives all multicast
          packets either untagged or tagged with VLAN ID 10)
      
      To resolve these issues the patch introduces these changes:
      1. Adds handling for IFF_ALLMULTI to ice_vlan_rx_add_vid() and
         ice_vlan_rx_kill_vid() callbacks. So when VLAN is added/removed
         and IFF_ALLMULTI is enabled an appropriate multicast promisc
         rule for that VLAN ID is added/removed.
      2. In ice_vlan_rx_add_vid() when first VLAN besides VLAN 0 is added
         so (vsi->num_vlan == 2) and IFF_ALLMULTI is enabled then look-up
         type for existing multicast promisc rule for VLAN 0 is updated
         to ICE_MCAST_VLAN_PROMISC_BITS.
      3. In ice_vlan_rx_kill_vid() when last VLAN besides VLAN 0 is removed
         so (vsi->num_vlan == 1) and IFF_ALLMULTI is enabled then look-up
         type for existing multicast promisc rule for VLAN 0 is updated
         to ICE_MCAST_PROMISC_BITS.
      4. Both ice_vlan_rx_{add,kill}_vid() have to run under ICE_CFG_BUSY
         bit protection to avoid races with ice_vsi_sync_fltr() that runs
         in ice_service_task() context.
      5. Bit ICE_VSI_VLAN_FLTR_CHANGED is use-less and can be removed.
      6. Error messages added to ice_fltr_*_vsi_promisc() helper functions
         to avoid them in their callers
      7. Small improvements to increase readability
      
      Fixes: 5eda8afd ("ice: Add support for PF/VF promiscuous mode")
      Signed-off-by: NIvan Vecera <ivecera@redhat.com>
      Reviewed-by: NJacob Keller <jacob.e.keller@intel.com>
      Signed-off-by: NAlice Michael <alice.michael@intel.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      1273f895
    • I
      ice: Fix MAC address setting · 2c0069f3
      Ivan Vecera 提交于
      Commit 2ccc1c1c ("ice: Remove excess error variables") merged
      the usage of 'status' and 'err' variables into single one in
      function ice_set_mac_address(). Unfortunately this causes
      a regression when call of ice_fltr_add_mac() returns -EEXIST because
      this return value does not indicate an error in this case but
      value of 'err' remains to be -EEXIST till the end of the function
      and is returned to caller.
      
      Prior mentioned commit this does not happen because return value of
      ice_fltr_add_mac() was stored to 'status' variable first and
      if it was -EEXIST then 'err' remains to be zero.
      
      Fix the problem by reset 'err' to zero when ice_fltr_add_mac()
      returns -EEXIST.
      
      Fixes: 2ccc1c1c ("ice: Remove excess error variables")
      Signed-off-by: NIvan Vecera <ivecera@redhat.com>
      Reviewed-by: NJacob Keller <jacob.e.keller@intel.com>
      Acked-by: NAlexander Lobakin <alexandr.lobakin@intel.com>
      Signed-off-by: NAlice Michael <alice.michael@intel.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      2c0069f3
    • I
      ice: Clear default forwarding VSI during VSI release · bd8c624c
      Ivan Vecera 提交于
      VSI is set as default forwarding one when promisc mode is set for
      PF interface, when PF is switched to switchdev mode or when VF
      driver asks to enable allmulticast or promisc mode for the VF
      interface (when vf-true-promisc-support priv flag is off).
      The third case is buggy because in that case VSI associated with
      VF remains as default one after VF removal.
      
      Reproducer:
      1. Create VF
         echo 1 > sys/class/net/ens7f0/device/sriov_numvfs
      2. Enable allmulticast or promisc mode on VF
         ip link set ens7f0v0 allmulticast on
         ip link set ens7f0v0 promisc on
      3. Delete VF
         echo 0 > sys/class/net/ens7f0/device/sriov_numvfs
      4. Try to enable promisc mode on PF
         ip link set ens7f0 promisc on
      
      Although it looks that promisc mode on PF is enabled the opposite
      is true because ice_vsi_sync_fltr() responsible for IFF_PROMISC
      handling first checks if any other VSI is set as default forwarding
      one and if so the function does not do anything. At this point
      it is not possible to enable promisc mode on PF without re-probe
      device.
      
      To resolve the issue this patch clear default forwarding VSI
      during ice_vsi_release() when the VSI to be released is the default
      one.
      
      Fixes: 01b5e89a ("ice: Add VF promiscuous support")
      Signed-off-by: NIvan Vecera <ivecera@redhat.com>
      Reviewed-by: NMichal Swiatkowski <michal.swiatkowski@linux.intel.com>
      Reviewed-by: NMaciej Fijalkowski <maciej.fijalkowski@intel.com>
      Signed-off-by: NAlice Michael <alice.michael@intel.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      bd8c624c
  4. 29 3月, 2022 3 次提交
  5. 24 3月, 2022 2 次提交
    • A
      ice: don't allow to run ice_send_event_to_aux() in atomic ctx · 5a315693
      Alexander Lobakin 提交于
      ice_send_event_to_aux() eventually descends to mutex_lock()
      (-> might_sched()), so it must not be called under non-task
      context. However, at least two fixes have happened already for the
      bug splats occurred due to this function being called from atomic
      context.
      To make the emergency landings softer, bail out early when executed
      in non-task context emitting a warn splat only once. This way we
      trade some events being potentially lost for system stability and
      avoid any related hangs and crashes.
      
      Fixes: 348048e7 ("ice: Implement iidc operations")
      Signed-off-by: NAlexander Lobakin <alexandr.lobakin@intel.com>
      Tested-by: NMichal Kubiak <michal.kubiak@intel.com>
      Reviewed-by: NMaciej Fijalkowski <maciej.fijalkowski@intel.com>
      Acked-by: NTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      5a315693
    • A
      ice: fix 'scheduling while atomic' on aux critical err interrupt · 32d53c0a
      Alexander Lobakin 提交于
      There's a kernel BUG splat on processing aux critical error
      interrupts in ice_misc_intr():
      
      [ 2100.917085] BUG: scheduling while atomic: swapper/15/0/0x00010000
      ...
      [ 2101.060770] Call Trace:
      [ 2101.063229]  <IRQ>
      [ 2101.065252]  dump_stack+0x41/0x60
      [ 2101.068587]  __schedule_bug.cold.100+0x4c/0x58
      [ 2101.073060]  __schedule+0x6a4/0x830
      [ 2101.076570]  schedule+0x35/0xa0
      [ 2101.079727]  schedule_preempt_disabled+0xa/0x10
      [ 2101.084284]  __mutex_lock.isra.7+0x310/0x420
      [ 2101.088580]  ? ice_misc_intr+0x201/0x2e0 [ice]
      [ 2101.093078]  ice_send_event_to_aux+0x25/0x70 [ice]
      [ 2101.097921]  ice_misc_intr+0x220/0x2e0 [ice]
      [ 2101.102232]  __handle_irq_event_percpu+0x40/0x180
      [ 2101.106965]  handle_irq_event_percpu+0x30/0x80
      [ 2101.111434]  handle_irq_event+0x36/0x53
      [ 2101.115292]  handle_edge_irq+0x82/0x190
      [ 2101.119148]  handle_irq+0x1c/0x30
      [ 2101.122480]  do_IRQ+0x49/0xd0
      [ 2101.125465]  common_interrupt+0xf/0xf
      [ 2101.129146]  </IRQ>
      ...
      
      As Andrew correctly mentioned previously[0], the following call
      ladder happens:
      
      ice_misc_intr() <- hardirq
        ice_send_event_to_aux()
          device_lock()
            mutex_lock()
              might_sleep()
                might_resched() <- oops
      
      Add a new PF state bit which indicates that an aux critical error
      occurred and serve it in ice_service_task() in process context.
      The new ice_pf::oicr_err_reg is read-write in both hardirq and
      process contexts, but only 3 bits of non-critical data probably
      aren't worth explicit synchronizing (and they're even in the same
      byte [31:24]).
      
      [0] https://lore.kernel.org/all/YeSRUVmrdmlUXHDn@lunn.ch
      
      Fixes: 348048e7 ("ice: Implement iidc operations")
      Signed-off-by: NAlexander Lobakin <alexandr.lobakin@intel.com>
      Tested-by: NMichal Kubiak <michal.kubiak@intel.com>
      Acked-by: NTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      32d53c0a
  6. 17 3月, 2022 3 次提交
    • J
      ice: add trace events for tx timestamps · 4c120218
      Jacob Keller 提交于
      We've previously run into many issues related to the latency of a Tx
      timestamp completion with the ice hardware. It can be difficult to
      determine the root cause of a slow Tx timestamp. To aid in this,
      introduce new trace events which capture timing data about when the
      driver reaches certain points while processing a transmit timestamp
      
       * ice_tx_tstamp_request: Trace when the stack initiates a new timestamp
         request.
      
       * ice_tx_tstamp_fw_req: Trace when the driver begins a read of the
         timestamp register in the work thread.
      
       * ice_tx_tstamp_fw_done: Trace when the driver finishes reading a
         timestamp register in the work thread.
      
       * ice_tx_tstamp_complete: Trace when the driver submits the skb back to
         the stack with a completed Tx timestamp.
      
      These trace events can be enabled using the standard trace event
      subsystem exposed by the ice driver. If they are disabled, they become
      no-ops with no run time cost.
      
      The following is a simple GNU AWK script which can highlight one
      potential way to use the trace events to capture latency data from the
      trace buffer about how long the driver takes to process a timestamp:
      
      -----
        BEGIN {
            PREC=256
        }
      
        # Detect requests
        /tx_tstamp_request/ {
            time=strtonum($4)
            skb=$7
      
            # Store the time of request for this skb
            requests[skb] = time
            printf("skb %s: idx %d at %.6f\n", skb, idx, time)
        }
      
        # Detect completions
        /tx_tstamp_complete/ {
            time=strtonum($4)
            skb=$7
            idx=$9
      
            if (skb in requests) {
                latency = (time - requests[skb]) * 1000
                printf("skb %s: %.3f to complete\n", skb, latency)
                if (latency > 4) {
                    printf(">>> HIGH LATENCY <<<\n")
                }
                printf("\n")
            } else {
                printf("!!! skb %s (idx %d) at %.6f\n", skb, idx, time)
            }
        }
      -----
      Signed-off-by: NJacob Keller <jacob.e.keller@intel.com>
      Tested-by: Gurucharan <gurucharanx.g@intel.com> (A Contingent worker at Intel)
      Signed-off-by: NTony Nguyen <anthony.l.nguyen@intel.com>
      4c120218
    • Y
      ice: fix return value check in ice_gnss.c · 2b1d0a24
      Yang Yingliang 提交于
      kthread_create_worker() and tty_alloc_driver() return ERR_PTR()
      and never return NULL. The NULL test in the return value check
      should be replaced with IS_ERR().
      
      Fixes: 43113ff7 ("ice: add TTY for GNSS module for E810T device")
      Reported-by: NHulk Robot <hulkci@huawei.com>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      Tested-by: Gurucharan <gurucharanx.g@intel.com> (A Contingent worker at Intel)
      Signed-off-by: NTony Nguyen <anthony.l.nguyen@intel.com>
      2b1d0a24
    • W
      ice: Fix inconsistent indenting in ice_switch · 2bcd5b9f
      Wojciech Drewek 提交于
      Fix the following warning as reported by smatch:
      
      smatch warnings:
      drivers/net/ethernet/intel/ice/ice_switch.c:5568 ice_find_dummy_packet() warn: inconsistent indenting
      
      Fixes: 9a225f81 ("ice: Support GTP-U and GTP-C offload in switchdev")
      Reported-by: Nkernel test robot <lkp@intel.com>
      Signed-off-by: NWojciech Drewek <wojciech.drewek@intel.com>
      Signed-off-by: NTony Nguyen <anthony.l.nguyen@intel.com>
      2bcd5b9f
  7. 16 3月, 2022 16 次提交
  8. 15 3月, 2022 10 次提交
    • J
      ice: use ice_is_vf_trusted helper function · 1261691d
      Jacob Keller 提交于
      The ice_vc_cfg_promiscuous_mode_msg function directly checks
      ICE_VIRTCHNL_VF_CAP_PRIVILEGE, instead of using the existing helper
      function ice_is_vf_trusted. Switch this to use the helper function so
      that all trusted checks are consistent. This aids in any potential
      future refactor by ensuring consistent code.
      Signed-off-by: NJacob Keller <jacob.e.keller@intel.com>
      Tested-by: NKonrad Jankowski <konrad0.jankowski@intel.com>
      Signed-off-by: NTony Nguyen <anthony.l.nguyen@intel.com>
      1261691d
    • J
      ice: log an error message when eswitch fails to configure · 2b369448
      Jacob Keller 提交于
      When ice_eswitch_configure fails, print an error message to make it more
      obvious why VF initialization did not succeed.
      Signed-off-by: NJacob Keller <jacob.e.keller@intel.com>
      Tested-by: NSandeep Penigalapati <sandeep.penigalapati@intel.com>
      Signed-off-by: NTony Nguyen <anthony.l.nguyen@intel.com>
      2b369448
    • J
      ice: cleanup error logging for ice_ena_vfs · 94ab2488
      Jacob Keller 提交于
      The ice_ena_vfs function and some of its sub-functions like
      ice_set_per_vf_res use a "if (<function>) { <print error> ; <exit> }"
      flow. This flow discards specialized errors reported by the called
      function.
      
      This style is generally not preferred as it makes tracing error sources
      more difficult. It also means we cannot log the actual error received
      properly.
      
      Refactor several calls in the ice_ena_vfs function that do this to catch
      the error in the 'ret' variable. Report this in the messages, and then
      return the more precise error value.
      
      Doing this reveals that ice_set_per_vf_res returns -EINVAL or -EIO in
      places where -ENOSPC makes more sense. Fix these calls up to return the
      more appropriate value.
      Signed-off-by: NJacob Keller <jacob.e.keller@intel.com>
      Tested-by: NKonrad Jankowski <konrad0.jankowski@intel.com>
      Signed-off-by: NTony Nguyen <anthony.l.nguyen@intel.com>
      94ab2488
    • J
      ice: move ice_set_vf_port_vlan near other .ndo ops · 346f7aa3
      Jacob Keller 提交于
      The ice_set_vf_port_vlan function is located in ice_sriov.c very far
      away from the other .ndo operations that it is similar to. Move this so
      that its located near the other .ndo operation definitions.
      Signed-off-by: NJacob Keller <jacob.e.keller@intel.com>
      Tested-by: NKonrad Jankowski <konrad0.jankowski@intel.com>
      Signed-off-by: NTony Nguyen <anthony.l.nguyen@intel.com>
      346f7aa3
    • J
      ice: refactor spoofchk control code in ice_sriov.c · a8ea6d86
      Jacob Keller 提交于
      The API to control the VSI spoof checking for a VF VSI has three
      functions: enable, disable, and set. The set function takes the VSI and
      the VF and decides whether to call enable or disable based on the
      vf->spoofchk field.
      
      In some flows, vf->spoofchk is not yet set, such as the function used to
      control the setting for a VF. (vf->spoofchk is only updated after a
      success).
      
      Simplify this API by refactoring ice_vf_set_spoofchk_cfg to be
      "ice_vsi_apply_spoofchk" which takes the boolean and allows all callers
      to avoid having to determine whether to call enable or disable
      themselves.
      
      This matches the expected callers better, and will prevent the need to
      export more than one function when this code must be called from another
      file.
      Signed-off-by: NJacob Keller <jacob.e.keller@intel.com>
      Tested-by: NKonrad Jankowski <konrad0.jankowski@intel.com>
      Signed-off-by: NTony Nguyen <anthony.l.nguyen@intel.com>
      a8ea6d86
    • J
      ice: rename ICE_MAX_VF_COUNT to avoid confusion · dc36796e
      Jacob Keller 提交于
      The ICE_MAX_VF_COUNT field is defined in ice_sriov.h. This count is true
      for SR-IOV but will not be true for all VF implementations, such as when
      the ice driver supports Scalable IOV.
      
      Rename this definition to clearly indicate ICE_MAX_SRIOV_VFS.
      Signed-off-by: NJacob Keller <jacob.e.keller@intel.com>
      Tested-by: NKonrad Jankowski <konrad0.jankowski@intel.com>
      Signed-off-by: NTony Nguyen <anthony.l.nguyen@intel.com>
      dc36796e
    • J
      ice: remove unused definitions from ice_sriov.h · 00a57e29
      Jacob Keller 提交于
      A few more macros exist in ice_sriov.h which are not used anywhere.
      These can be safely removed. Note that ICE_VIRTCHNL_VF_CAP_L2 capability
      is set but never checked anywhere in the driver. Thus it is also safe to
      remove.
      Signed-off-by: NJacob Keller <jacob.e.keller@intel.com>
      Tested-by: NKonrad Jankowski <konrad0.jankowski@intel.com>
      Signed-off-by: NTony Nguyen <anthony.l.nguyen@intel.com>
      00a57e29
    • J
      ice: convert vf->vc_ops to a const pointer · a7e11710
      Jacob Keller 提交于
      The vc_ops structure is used to allow different handlers for virtchnl
      commands when the driver is in representor mode. The current
      implementation uses a copy of the ops table in each VF, and modifies
      this copy dynamically.
      
      The usual practice in kernel code is to store the ops table in a
      constant structure and point to different versions. This has a number of
      advantages:
      
        1. Reduced memory usage. Each VF merely points to the correct table,
           so they're able to re-use the same constant lookup table in memory.
        2. Consistency. It becomes more difficult to accidentally update or
           edit only one op call. Instead, the code switches to the correct
           able by a single pointer write. In general this is atomic, either
           the pointer is updated or its not.
        3. Code Layout. The VF structure can store a pointer to the table
           without needing to have the full structure definition defined prior
           to the VF structure definition. This will aid in future refactoring
           of code by allowing the VF pointer to be kept in ice_vf_lib.h while
           the virtchnl ops table can be maintained in ice_virtchnl.h
      
      There is one major downside in the case of the vc_ops structure. Most of
      the operations in the table are the same between the two current
      implementations. This can appear to lead to duplication since each
      implementation must now fill in the complete table. It could make
      spotting the differences in the representor mode more challenging.
      Unfortunately, methods to make this less error prone either add
      complexity overhead (macros using CPP token concatenation) or don't work
      on all compilers we support (constant initializer from another constant
      structure).
      
      The cost of maintaining two structures does not out weigh the benefits
      of the constant table model.
      
      While we're making these changes, go ahead and rename the structure and
      implementations with "virtchnl" instead of "vc_vf_". This will more
      closely align with the planned file renaming, and avoid similar names when
      we later introduce a "vf ops" table for separating Scalable IOV and
      Single Root IOV implementations.
      
      Leave the accessor/assignment functions in order to avoid issues with
      compiling with options disabled. The interface makes it easier to handle
      when CONFIG_PCI_IOV is disabled in the kernel.
      Signed-off-by: NJacob Keller <jacob.e.keller@intel.com>
      Tested-by: NSandeep Penigalapati <sandeep.penigalapati@intel.com>
      Signed-off-by: NTony Nguyen <anthony.l.nguyen@intel.com>
      a7e11710
    • J
      ice: remove circular header dependencies on ice.h · 649c87c6
      Jacob Keller 提交于
      Several headers in the ice driver include ice.h even though they are
      themselves included by that header. The most notable of these is
      ice_common.h, but several other headers also do this.
      
      Such a recursive inclusion is problematic as it forces headers to be
      included in a strict order, otherwise compilation errors can result. The
      circular inclusions do not trigger an endless loop due to standard
      header inclusion guards, however other errors can occur.
      
      For example, ice_flow.h defines ice_rss_hash_cfg, which is used by
      ice_sriov.h as part of the definition of ice_vf_hash_ip_ctx.
      
      ice_flow.h includes ice_acl.h, which includes ice_common.h, and which
      finally includes ice.h. Since ice.h itself includes ice_sriov.h, this
      creates a circular dependency.
      
      The definition in ice_sriov.h requires things from ice_flow.h, but
      ice_flow.h itself will lead to trying to load ice_sriov.h as part of its
      process for expanding ice.h. The current code avoids this issue by
      having an implicit dependency without the include of ice_flow.h.
      
      If we were to fix that so that ice_sriov.h explicitly depends on
      ice_flow.h the following pattern would occur:
      
        ice_flow.h -> ice_acl.h -> ice_common.h -> ice.h -> ice_sriov.h
      
      At this point, during the expansion of, the header guard for ice_flow.h
      is already set, so when ice_sriov.h attempts to load the ice_flow.h
      header it is skipped. Then, we go on to begin including the rest of
      ice_sriov.h, including structure definitions which depend on
      ice_rss_hash_cfg. This produces a compiler warning because
      ice_rss_hash_cfg hasn't yet been included. Remember, we're just at the
      start of ice_flow.h!
      
      If the order of headers is incorrect (ice_flow.h is not implicitly
      loaded first in all files which include ice_sriov.h) then we get the
      same failure.
      
      Removing this recursive inclusion requires fixing a few cases where some
      headers depended on the header inclusions from ice.h. In addition, a few
      other changes are also required.
      
      Most notably, ice_hw_to_dev is implemented as a macro in ice_osdep.h,
      which is the likely reason that ice_common.h includes ice.h at all. This
      macro implementation requires the full definition of ice_pf in order to
      properly compile.
      
      Fix this by moving it to a function declared in ice_main.c, so that we
      do not require all files to depend on the layout of the ice_pf
      structure.
      
      Note that this change only fixes circular dependencies, but it does not
      fully resolve all implicit dependencies where one header may depend on
      the inclusion of another. I tried to fix as many of the implicit
      dependencies as I noticed, but fixing them all requires a somewhat
      tedious analysis of each header and attempting to compile it separately.
      Signed-off-by: NJacob Keller <jacob.e.keller@intel.com>
      Tested-by: Gurucharan G <gurucharanx.g@intel.com> (A Contingent worker at Intel)
      Signed-off-by: NTony Nguyen <anthony.l.nguyen@intel.com>
      649c87c6
    • J
      ice: rename ice_virtchnl_pf.c to ice_sriov.c · 0deb0bf7
      Jacob Keller 提交于
      The ice_virtchnl_pf.c and ice_virtchnl_pf.h files are where most of the
      code for implementing Single Root IOV virtualization resides. This code
      includes support for bringing up and tearing down VFs, hooks into the
      kernel SR-IOV netdev operations, and for handling virtchnl messages from
      VFs.
      
      In the future, we plan to support Scalable IOV in addition to Single
      Root IOV as an alternative virtualization scheme. This implementation
      will re-use some but not all of the code in ice_virtchnl_pf.c
      
      To prepare for this future, we want to refactor and split up the code in
      ice_virtchnl_pf.c into the following scheme:
      
       * ice_vf_lib.[ch]
      
         Basic VF structures and accessors. This is where scheme-independent
         code will reside.
      
       * ice_virtchnl.[ch]
      
         Virtchnl message handling. This is where the bulk of the logic for
         processing messages from VFs using the virtchnl messaging scheme will
         reside. This is separated from ice_vf_lib.c because it is distinct
         and has a bulk of the processing code.
      
       * ice_sriov.[ch]
      
         Single Root IOV implementation, including initialization and the
         routines for interacting with SR-IOV based netdev operations.
      
       * (future) ice_siov.[ch]
      
         Scalable IOV implementation.
      
      As a first step, lets assume that all of the code in
      ice_virtchnl_pf.[ch] is for Single Root IOV. Rename this file to
      ice_sriov.c and its header to ice_sriov.h
      
      Future changes will further split out the code in these files following
      the plan outlined here.
      Signed-off-by: NJacob Keller <jacob.e.keller@intel.com>
      Tested-by: NKonrad Jankowski <konrad0.jankowski@intel.com>
      Signed-off-by: NTony Nguyen <anthony.l.nguyen@intel.com>
      0deb0bf7