Merge branch 'mlx5-next' of git://git.kernel.org/pub/scm/linux/kernel/git/mellanox...
authorSaeed Mahameed <saeedm@nvidia.com>
Wed, 27 Oct 2021 19:45:37 +0000 (12:45 -0700)
committerSaeed Mahameed <saeedm@nvidia.com>
Thu, 28 Oct 2021 04:33:28 +0000 (21:33 -0700)
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
1  2 
drivers/infiniband/hw/mlx5/odp.c
drivers/net/ethernet/mellanox/mlx5/core/diag/fw_tracer.c
drivers/net/ethernet/mellanox/mlx5/core/en.h
drivers/net/ethernet/mellanox/mlx5/core/en_main.c
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h
include/linux/mlx5/device.h
include/linux/mlx5/driver.h
include/linux/mlx5/fs.h
include/linux/mlx5/mlx5_ifc.h

Simple merge
index 67453dd75b93cef95428592abcc02af238abd94c,7761daa25f631efc1465ee65bf1be5935ad85c90..f0ac6b0d9653577eec06b982cbb98e2b3e7253df
@@@ -642,25 -598,6 +642,25 @@@ struct mlx5e_rq_frags_info 
        u8 wqe_bulk;
  };
  
-       struct mlx5_core_mkey mkey;
 +struct mlx5e_shampo_hd {
++      u32 mkey;
 +      struct mlx5e_dma_info *info;
 +      struct page *last_page;
 +      u16 hd_per_wq;
 +      u16 hd_per_wqe;
 +      unsigned long *bitmap;
 +      u16 pi;
 +      u16 ci;
 +      __be32 key;
 +      u64 last_addr;
 +};
 +
 +struct mlx5e_hw_gro_data {
 +      struct sk_buff *skb;
 +      struct flow_keys fk;
 +      int second_ip_id;
 +};
 +
  struct mlx5e_rq {
        /* data path */
        union {
index 6f398f636f015761f663a051660d4b833782f96c,63076d0e8b63dcfacaeb9518ded0e79f67b8ac45..65571593ec5c1996bcf0f655ed45e6cf4bb94962
@@@ -272,10 -233,9 +272,9 @@@ static int mlx5e_rq_alloc_mpwqe_info(st
        return 0;
  }
  
 -static int mlx5e_create_umr_mkey(struct mlx5_core_dev *mdev,
 -                               u64 npages, u8 page_shift, u32 *umr_mkey,
 -                               dma_addr_t filler_addr)
 +static int mlx5e_create_umr_mtt_mkey(struct mlx5_core_dev *mdev,
-                                    u64 npages, u8 page_shift,
-                                    struct mlx5_core_mkey *umr_mkey,
++                                   u64 npages, u8 page_shift, u32 *umr_mkey,
 +                                   dma_addr_t filler_addr)
  {
        struct mlx5_mtt *mtt;
        int inlen;
        return err;
  }
  
-                                    struct mlx5_core_mkey *umr_mkey)
 +static int mlx5e_create_umr_klm_mkey(struct mlx5_core_dev *mdev,
 +                                   u64 nentries,
++                                   u32 *umr_mkey)
 +{
 +      int inlen;
 +      void *mkc;
 +      u32 *in;
 +      int err;
 +
 +      inlen = MLX5_ST_SZ_BYTES(create_mkey_in);
 +
 +      in = kvzalloc(inlen, GFP_KERNEL);
 +      if (!in)
 +              return -ENOMEM;
 +
 +      mkc = MLX5_ADDR_OF(create_mkey_in, in, memory_key_mkey_entry);
 +
 +      MLX5_SET(mkc, mkc, free, 1);
 +      MLX5_SET(mkc, mkc, umr_en, 1);
 +      MLX5_SET(mkc, mkc, lw, 1);
 +      MLX5_SET(mkc, mkc, lr, 1);
 +      MLX5_SET(mkc, mkc, access_mode_1_0, MLX5_MKC_ACCESS_MODE_KLMS);
 +      mlx5e_mkey_set_relaxed_ordering(mdev, mkc);
 +      MLX5_SET(mkc, mkc, qpn, 0xffffff);
 +      MLX5_SET(mkc, mkc, pd, mdev->mlx5e_res.hw_objs.pdn);
 +      MLX5_SET(mkc, mkc, translations_octword_size, nentries);
 +      MLX5_SET(mkc, mkc, length64, 1);
 +      err = mlx5_core_create_mkey(mdev, umr_mkey, in, inlen);
 +
 +      kvfree(in);
 +      return err;
 +}
 +
  static int mlx5e_create_rq_umr_mkey(struct mlx5_core_dev *mdev, struct mlx5e_rq *rq)
  {
        u64 num_mtts = MLX5E_REQUIRED_MTTS(mlx5_wq_ll_get_size(&rq->mpwqe.wq));
@@@ -489,65 -402,6 +488,65 @@@ static int mlx5e_init_rxq_rq(struct mlx
        return xdp_rxq_info_reg(&rq->xdp_rxq, rq->netdev, rq->ix, 0);
  }
  
-               cpu_to_be32(rq->mpwqe.shampo->mkey.key);
 +static int mlx5_rq_shampo_alloc(struct mlx5_core_dev *mdev,
 +                              struct mlx5e_params *params,
 +                              struct mlx5e_rq_param *rqp,
 +                              struct mlx5e_rq *rq,
 +                              u32 *pool_size,
 +                              int node)
 +{
 +      void *wqc = MLX5_ADDR_OF(rqc, rqp->rqc, wq);
 +      int wq_size;
 +      int err;
 +
 +      if (!test_bit(MLX5E_RQ_STATE_SHAMPO, &rq->state))
 +              return 0;
 +      err = mlx5e_rq_shampo_hd_alloc(rq, node);
 +      if (err)
 +              goto out;
 +      rq->mpwqe.shampo->hd_per_wq =
 +              mlx5e_shampo_hd_per_wq(mdev, params, rqp);
 +      err = mlx5e_create_rq_hd_umr_mkey(mdev, rq);
 +      if (err)
 +              goto err_shampo_hd;
 +      err = mlx5e_rq_shampo_hd_info_alloc(rq, node);
 +      if (err)
 +              goto err_shampo_info;
 +      rq->hw_gro_data = kvzalloc_node(sizeof(*rq->hw_gro_data), GFP_KERNEL, node);
 +      if (!rq->hw_gro_data) {
 +              err = -ENOMEM;
 +              goto err_hw_gro_data;
 +      }
 +      rq->mpwqe.shampo->key =
-       mlx5_core_destroy_mkey(mdev, &rq->mpwqe.shampo->mkey);
++              cpu_to_be32(rq->mpwqe.shampo->mkey);
 +      rq->mpwqe.shampo->hd_per_wqe =
 +              mlx5e_shampo_hd_per_wqe(mdev, params, rqp);
 +      wq_size = BIT(MLX5_GET(wq, wqc, log_wq_sz));
 +      *pool_size += (rq->mpwqe.shampo->hd_per_wqe * wq_size) /
 +                   MLX5E_SHAMPO_WQ_HEADER_PER_PAGE;
 +      return 0;
 +
 +err_hw_gro_data:
 +      mlx5e_rq_shampo_hd_info_free(rq);
 +err_shampo_info:
-       mlx5_core_destroy_mkey(rq->mdev, &rq->mpwqe.shampo->mkey);
++      mlx5_core_destroy_mkey(mdev, rq->mpwqe.shampo->mkey);
 +err_shampo_hd:
 +      mlx5e_rq_shampo_hd_free(rq);
 +out:
 +      return err;
 +}
 +
 +static void mlx5e_rq_free_shampo(struct mlx5e_rq *rq)
 +{
 +      if (!test_bit(MLX5E_RQ_STATE_SHAMPO, &rq->state))
 +              return;
 +
 +      kvfree(rq->hw_gro_data);
 +      mlx5e_rq_shampo_hd_info_free(rq);
++      mlx5_core_destroy_mkey(rq->mdev, rq->mpwqe.shampo->mkey);
 +      mlx5e_rq_shampo_hd_free(rq);
 +}
 +
  static int mlx5e_alloc_rq(struct mlx5e_params *params,
                          struct mlx5e_xsk_param *xsk,
                          struct mlx5e_rq_param *rqp,
@@@ -761,9 -606,8 +760,9 @@@ static void mlx5e_free_rq(struct mlx5e_
        switch (rq->wq_type) {
        case MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ:
                kvfree(rq->mpwqe.info);
-               mlx5_core_destroy_mkey(rq->mdev, &rq->umr_mkey);
+               mlx5_core_destroy_mkey(rq->mdev, rq->umr_mkey);
                mlx5e_free_mpwqe_rq_drop_page(rq);
 +              mlx5e_rq_free_shampo(rq);
                break;
        default: /* MLX5_WQ_TYPE_CYCLIC */
                kvfree(rq->wqe.frags);
@@@ -817,12 -661,6 +816,12 @@@ int mlx5e_create_rq(struct mlx5e_rq *rq
                                                MLX5_ADAPTER_PAGE_SHIFT);
        MLX5_SET64(wq, wq,  dbr_addr,           rq->wq_ctrl.db.dma);
  
-               MLX5_SET(wq, wq, headers_mkey, rq->mpwqe.shampo->mkey.key);
 +      if (test_bit(MLX5E_RQ_STATE_SHAMPO, &rq->state)) {
 +              MLX5_SET(wq, wq, log_headers_buffer_entry_num,
 +                       order_base_2(rq->mpwqe.shampo->hd_per_wq));
++              MLX5_SET(wq, wq, headers_mkey, rq->mpwqe.shampo->mkey);
 +      }
 +
        mlx5_fill_page_frag_array(&rq->wq_ctrl.buf,
                                  (__be64 *)MLX5_ADDR_OF(wq, wq, pas));
  
index fe979edd96dc6cd7cea127cca10c3bc3c300c3b6,29a6586ef28dc12848a4625e147b1f252c8cddab..f63c8ff3ef3f2d80864f2973df2351e40aa5249d
@@@ -501,157 -494,6 +501,157 @@@ static void mlx5e_post_rx_mpwqe(struct 
        mlx5_wq_ll_update_db_record(wq);
  }
  
-       u32 lkey = rq->mdev->mlx5e_res.hw_objs.mkey.key;
 +/* This function returns the size of the continuous free space inside a bitmap
 + * that starts from first and no longer than len including circular ones.
 + */
 +static int bitmap_find_window(unsigned long *bitmap, int len,
 +                            int bitmap_size, int first)
 +{
 +      int next_one, count;
 +
 +      next_one = find_next_bit(bitmap, bitmap_size, first);
 +      if (next_one == bitmap_size) {
 +              if (bitmap_size - first >= len)
 +                      return len;
 +              next_one = find_next_bit(bitmap, bitmap_size, 0);
 +              count = next_one + bitmap_size - first;
 +      } else {
 +              count = next_one - first;
 +      }
 +
 +      return min(len, count);
 +}
 +
 +static void build_klm_umr(struct mlx5e_icosq *sq, struct mlx5e_umr_wqe *umr_wqe,
 +                        __be32 key, u16 offset, u16 klm_len, u16 wqe_bbs)
 +{
 +      memset(umr_wqe, 0, offsetof(struct mlx5e_umr_wqe, inline_klms));
 +      umr_wqe->ctrl.opmod_idx_opcode =
 +              cpu_to_be32((sq->pc << MLX5_WQE_CTRL_WQE_INDEX_SHIFT) |
 +                           MLX5_OPCODE_UMR);
 +      umr_wqe->ctrl.umr_mkey = key;
 +      umr_wqe->ctrl.qpn_ds = cpu_to_be32((sq->sqn << MLX5_WQE_CTRL_QPN_SHIFT)
 +                                          | MLX5E_KLM_UMR_DS_CNT(klm_len));
 +      umr_wqe->uctrl.flags = MLX5_UMR_TRANSLATION_OFFSET_EN | MLX5_UMR_INLINE;
 +      umr_wqe->uctrl.xlt_offset = cpu_to_be16(offset);
 +      umr_wqe->uctrl.xlt_octowords = cpu_to_be16(klm_len);
 +      umr_wqe->uctrl.mkey_mask     = cpu_to_be64(MLX5_MKEY_MASK_FREE);
 +}
 +
 +static int mlx5e_build_shampo_hd_umr(struct mlx5e_rq *rq,
 +                                   struct mlx5e_icosq *sq,
 +                                   u16 klm_entries, u16 index)
 +{
 +      struct mlx5e_shampo_hd *shampo = rq->mpwqe.shampo;
 +      u16 entries, pi, i, header_offset, err, wqe_bbs, new_entries;
++      u32 lkey = rq->mdev->mlx5e_res.hw_objs.mkey;
 +      struct page *page = shampo->last_page;
 +      u64 addr = shampo->last_addr;
 +      struct mlx5e_dma_info *dma_info;
 +      struct mlx5e_umr_wqe *umr_wqe;
 +      int headroom;
 +
 +      headroom = rq->buff.headroom;
 +      new_entries = klm_entries - (shampo->pi & (MLX5_UMR_KLM_ALIGNMENT - 1));
 +      entries = ALIGN(klm_entries, MLX5_UMR_KLM_ALIGNMENT);
 +      wqe_bbs = MLX5E_KLM_UMR_WQEBBS(entries);
 +      pi = mlx5e_icosq_get_next_pi(sq, wqe_bbs);
 +      umr_wqe = mlx5_wq_cyc_get_wqe(&sq->wq, pi);
 +      build_klm_umr(sq, umr_wqe, shampo->key, index, entries, wqe_bbs);
 +
 +      for (i = 0; i < entries; i++, index++) {
 +              dma_info = &shampo->info[index];
 +              if (i >= klm_entries || (index < shampo->pi && shampo->pi - index <
 +                                       MLX5_UMR_KLM_ALIGNMENT))
 +                      goto update_klm;
 +              header_offset = (index & (MLX5E_SHAMPO_WQ_HEADER_PER_PAGE - 1)) <<
 +                      MLX5E_SHAMPO_LOG_MAX_HEADER_ENTRY_SIZE;
 +              if (!(header_offset & (PAGE_SIZE - 1))) {
 +                      err = mlx5e_page_alloc(rq, dma_info);
 +                      if (unlikely(err))
 +                              goto err_unmap;
 +                      addr = dma_info->addr;
 +                      page = dma_info->page;
 +              } else {
 +                      dma_info->addr = addr + header_offset;
 +                      dma_info->page = page;
 +              }
 +
 +update_klm:
 +              umr_wqe->inline_klms[i].bcount =
 +                      cpu_to_be32(MLX5E_RX_MAX_HEAD);
 +              umr_wqe->inline_klms[i].key    = cpu_to_be32(lkey);
 +              umr_wqe->inline_klms[i].va     =
 +                      cpu_to_be64(dma_info->addr + headroom);
 +      }
 +
 +      sq->db.wqe_info[pi] = (struct mlx5e_icosq_wqe_info) {
 +              .wqe_type       = MLX5E_ICOSQ_WQE_SHAMPO_HD_UMR,
 +              .num_wqebbs     = wqe_bbs,
 +              .shampo.len     = new_entries,
 +      };
 +
 +      shampo->pi = (shampo->pi + new_entries) & (shampo->hd_per_wq - 1);
 +      shampo->last_page = page;
 +      shampo->last_addr = addr;
 +      sq->pc += wqe_bbs;
 +      sq->doorbell_cseg = &umr_wqe->ctrl;
 +
 +      return 0;
 +
 +err_unmap:
 +      while (--i >= 0) {
 +              if (--index < 0)
 +                      index = shampo->hd_per_wq - 1;
 +              dma_info = &shampo->info[index];
 +              if (!(i & (MLX5E_SHAMPO_WQ_HEADER_PER_PAGE - 1))) {
 +                      dma_info->addr = ALIGN_DOWN(dma_info->addr, PAGE_SIZE);
 +                      mlx5e_page_release(rq, dma_info, true);
 +              }
 +      }
 +      rq->stats->buff_alloc_err++;
 +      return err;
 +}
 +
 +static int mlx5e_alloc_rx_hd_mpwqe(struct mlx5e_rq *rq)
 +{
 +      struct mlx5e_shampo_hd *shampo = rq->mpwqe.shampo;
 +      u16 klm_entries, num_wqe, index, entries_before;
 +      struct mlx5e_icosq *sq = rq->icosq;
 +      int i, err, max_klm_entries, len;
 +
 +      max_klm_entries = MLX5E_MAX_KLM_PER_WQE(rq->mdev);
 +      klm_entries = bitmap_find_window(shampo->bitmap,
 +                                       shampo->hd_per_wqe,
 +                                       shampo->hd_per_wq, shampo->pi);
 +      if (!klm_entries)
 +              return 0;
 +
 +      klm_entries += (shampo->pi & (MLX5_UMR_KLM_ALIGNMENT - 1));
 +      index = ALIGN_DOWN(shampo->pi, MLX5_UMR_KLM_ALIGNMENT);
 +      entries_before = shampo->hd_per_wq - index;
 +
 +      if (unlikely(entries_before < klm_entries))
 +              num_wqe = DIV_ROUND_UP(entries_before, max_klm_entries) +
 +                        DIV_ROUND_UP(klm_entries - entries_before, max_klm_entries);
 +      else
 +              num_wqe = DIV_ROUND_UP(klm_entries, max_klm_entries);
 +
 +      for (i = 0; i < num_wqe; i++) {
 +              len = (klm_entries > max_klm_entries) ? max_klm_entries :
 +                                                      klm_entries;
 +              if (unlikely(index + len > shampo->hd_per_wq))
 +                      len = shampo->hd_per_wq - index;
 +              err = mlx5e_build_shampo_hd_umr(rq, sq, len, index);
 +              if (unlikely(err))
 +                      return err;
 +              index = (index + len) & (rq->mpwqe.shampo->hd_per_wq - 1);
 +              klm_entries -= len;
 +      }
 +
 +      return 0;
 +}
 +
  static int mlx5e_alloc_rx_mpwqe(struct mlx5e_rq *rq, u16 ix)
  {
        struct mlx5e_mpw_info *wi = &rq->mpwqe.info[ix];
Simple merge
Simple merge
index 7a43fec63a35da223fa55775e85b510c2d7c64c9,f2c3da2006d9804dded53ed08378172fba51c103..a7e1155bc4da853a8376068771fd7f9db5306bde
@@@ -83,7 -83,8 +83,9 @@@ enum mlx5_flow_namespace_type 
        MLX5_FLOW_NAMESPACE_RDMA_RX,
        MLX5_FLOW_NAMESPACE_RDMA_RX_KERNEL,
        MLX5_FLOW_NAMESPACE_RDMA_TX,
 +      MLX5_FLOW_NAMESPACE_PORT_SEL,
+       MLX5_FLOW_NAMESPACE_RDMA_RX_COUNTERS,
+       MLX5_FLOW_NAMESPACE_RDMA_TX_COUNTERS,
  };
  
  enum {
Simple merge