1. 30 Aug, 2021 12 commits
    • David S. Miller's avatar
      Merge branch 'bnxt_en-fw-messages' · 49f9df5b
      David S. Miller authored
      Michael Chan says:
      
      ====================
      bnxt_en: Implement new driver APIs to send FW messages
      
      The current driver APIs to send messages to the firmware allow only one
      outstanding message in flight.  There is only one buffer for the firmware
      response for each firmware channel.  To send a firmware message, all
      callers must take a mutex and it is released after the firmware response
      has been read.  This scheme does not allow multiple firmware messages
      in flight.  Firmware may take a long time to respond to some messages
      (e.g. NVRAM related ones) and this causes the mutex to be held for
      a long time, blocking other callers.
      
      This patchset intoduces the new driver APIs to address the above
      shortcomings.  The new APIs are compatible with new and old firmware.
      But the new deferred firmware response mechanism will require newer
      firmware in order to allow multiple outstanding firmware commands.
      
      All callers are updated to use the new APIs.
      
      v2: Patch 4 and patch 9 updated to fix issues reported by test robot
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      49f9df5b
    • Edwin Peer's avatar
      bnxt_en: support multiple HWRM commands in flight · 68f684e2
      Edwin Peer authored
      Add infrastructure to maintain a pending list of HWRM commands awaiting
      completion and reduce the scope of the hwrm_cmd_lock mutex so that it
      protects only the request mailbox. The mailbox is free to use for one
      or more concurrent commands after receiving deferred response events.
      
      For uniformity and completeness, use the same pending list for
      collecting completions for commands that respond via a completion ring.
      These commands are only used for freeing rings and for IRQ test and
      we only support one such command in flight.
      
      Note deferred responses are also only supported on the main channel.
      The secondary channel (KONG) does not support deferred responses.
      Signed-off-by: default avatarEdwin Peer <edwin.peer@broadcom.com>
      Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      68f684e2
    • Edwin Peer's avatar
      bnxt_en: remove legacy HWRM interface · b34695a8
      Edwin Peer authored
      There are no longer any callers relying on the old API.
      Signed-off-by: default avatarEdwin Peer <edwin.peer@broadcom.com>
      Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      b34695a8
    • Edwin Peer's avatar
      bnxt_en: update all firmware calls to use the new APIs · bbf33d1d
      Edwin Peer authored
      The conversion follows this general pattern for most of the calls:
      
      1. The input message is changed from a stack variable initialized
      using bnxt_hwrm_cmd_hdr_init() to a pointer allocated and intialized
      using hwrm_req_init().
      
      2. If we don't need to read the firmware response, the hwrm_send_message()
      call is replaced with hwrm_req_send().
      
      3. If we need to read the firmware response, the mutex lock is replaced
      by hwrm_req_hold() to hold the response.  When the response is read, the
      mutex unlock is replaced by hwrm_req_drop().
      
      If additional DMA buffers are needed for firmware response data, the
      hwrm_req_dma_slice() is used instead of calling dma_alloc_coherent().
      
      Some minor refactoring is also done while doing these conversions.
      
      v2: Fix unintialized variable warnings in __bnxt_hwrm_get_tx_rings()
      and bnxt_approve_mac()
      Signed-off-by: default avatarEdwin Peer <edwin.peer@broadcom.com>
      Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      bbf33d1d
    • Edwin Peer's avatar
      bnxt_en: use link_lock instead of hwrm_cmd_lock to protect link_info · 3c10ed49
      Edwin Peer authored
      We currently use the hwrm_cmd_lock to serialize the update of the
      firmware's link status response data and the copying of link status data
      to the VF.  This won't work when we update the firmware message APIs, so
      we use the link_lock mutex instead.  All link_info data should be
      updated under the link_lock mutex.  Also add link_lock to functions that
      touch link_info in __bnxt_open_nic() and bnxt_probe_phy(). The locking
      is probably not strictly necessary during probe, but it's more consistent.
      Signed-off-by: default avatarEdwin Peer <edwin.peer@broadcom.com>
      Reviewed-by: default avatarMichael Chan <michael.chan@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      3c10ed49
    • Edwin Peer's avatar
      bnxt_en: add support for HWRM request slices · 21380817
      Edwin Peer authored
      Slices are a mechanism for suballocating DMA mapped regions from the
      request buffer. Such regions can be used for indirect command data
      instead of creating new mappings with dma_alloc_coherent().
      
      The advantage of using a slice is that the lifetime of the slice is
      bound to the request and will be automatically unmapped when the
      request is consumed.
      
      A single external region is also supported. This allows for regions
      that will not fit inside the spare request buffer space such that
      the same API can be used consistently even for larger mappings.
      Signed-off-by: default avatarEdwin Peer <edwin.peer@broadcom.com>
      Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      21380817
    • Edwin Peer's avatar
      bnxt_en: add HWRM request assignment API · ecddc29d
      Edwin Peer authored
      hwrm_req_replace() provides an assignment like operation to replace a
      managed HWRM request object with data from a pre-built source. This is
      useful for handling request data provided by higher layer HWRM clients.
      Signed-off-by: default avatarEdwin Peer <edwin.peer@broadcom.com>
      Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      ecddc29d
    • Edwin Peer's avatar
      bnxt_en: discard out of sequence HWRM responses · 02b9aa10
      Edwin Peer authored
      During firmware crash recovery, it is possible for firmware to respond
      to stale HWRM commands that have already timed out. Because response
      buffers may be reused, any out of sequence responses need to be ignored
      and only the matching seq_id should be accepted.
      
      Also, READ_ONCE should be used for the reads from the DMA buffer to
      ensure that the necessary loads are scheduled.
      Reviewed-by: default avatarScott Branden <scott.branden@broadcom.com>
      Signed-off-by: default avatarEdwin Peer <edwin.peer@broadcom.com>
      Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      02b9aa10
    • Edwin Peer's avatar
      bnxt_en: introduce new firmware message API based on DMA pools · f9ff5782
      Edwin Peer authored
      This change constitutes a major step towards supporting multiple
      firmware commands in flight by maintaining a separate response buffer
      for the duration of each request. These firmware commands are also
      known as Hardware Resource Manager (HWRM) commands.  Using separate
      response buffers requires an API change in order for callers to be
      able to free the buffer when done.
      
      It is impossible to keep the existing APIs unchanged.  The existing
      usage for a simple HWRM message request such as the following:
      
              struct input req = {0};
              bnxt_hwrm_cmd_hdr_init(bp, &req, REQ_TYPE, -1, -1);
              rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
              if (rc)
                      /* error */
      
      changes to:
      
               struct input *req;
               rc = hwrm_req_init(bp, req, REQ_TYPE);
               if (rc)
                       /* error */
               rc = hwrm_req_send(bp, req); /* consumes req */
               if (rc)
                       /* error */
      
      The key changes are:
      
      1. The req is no longer allocated on the stack.
      2. The caller must call hwrm_req_init() to allocate a req buffer and
         check for a valid buffer.
      3. The req buffer is automatically released when hwrm_req_send() returns.
      4. If the caller wants to check the firmware response, the caller must
         call hwrm_req_hold() to take ownership of the response buffer and
         release it afterwards using hwrm_req_drop().  The caller is no longer
         required to explicitly hold the hwrm_cmd_lock mutex to read the
         response.
      5. Because the firmware commands and responses all have different sizes,
         some safeguards are added to the code.
      
      This patch maintains legacy API compatibiltiy, implementing the old
      API in terms of the new.  The follow-on patches will convert all
      callers to use the new APIs.
      
      v2: Fix redefined writeq with parisc .config
          Fix "cast from pointer to integer of different size" warning in
      hwrm_calc_sentinel()
      Signed-off-by: default avatarEdwin Peer <edwin.peer@broadcom.com>
      Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      f9ff5782
    • Edwin Peer's avatar
      bnxt_en: move HWRM API implementation into separate file · 3c8c20db
      Edwin Peer authored
      Move all firmware messaging functions and definitions to new
      bnxt_hwrm.[ch].  The follow-on patches will make major modifications
      to these APIs.
      Signed-off-by: default avatarEdwin Peer <edwin.peer@broadcom.com>
      Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      3c8c20db
    • Edwin Peer's avatar
      bnxt_en: Refactor the HWRM_VER_GET firmware calls · 7b370ad7
      Edwin Peer authored
      Refactor the code so that __bnxt_hwrm_ver_get() does not call
      bnxt_hwrm_do_send_msg() directly.  The new APIs will not expose this
      internal call.  Add a new bnxt_hwrm_poll() to poll the HWRM_VER_GET
      firmware call silently.  The other bnxt_hwrm_ver_get() function will
      send the HWRM_VER_GET message directly with error logs enabled.
      Signed-off-by: default avatarEdwin Peer <edwin.peer@broadcom.com>
      Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      7b370ad7
    • Edwin Peer's avatar
      bnxt_en: remove DMA mapping for KONG response · 6c172d59
      Edwin Peer authored
      The additional response buffer serves no useful purpose. There can
      be only one firmware command in flight due to the hwrm_cmd_lock mutex,
      which is taken for the entire duration of any command completion,
      KONG or otherwise. It is thus safe to share a single DMA buffer.
      
      Removing the code associated with the additional mapping will simplify
      matters in the next patch, which allocates response buffers from DMA
      pools on a per request basis.
      Signed-off-by: default avatarEdwin Peer <edwin.peer@broadcom.com>
      Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      6c172d59
  2. 29 Aug, 2021 28 commits