The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/irdma/irdma_pble.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * SPDX-License-Identifier: GPL-2.0 or Linux-OpenIB
    3  *
    4  * Copyright (c) 2015 - 2021 Intel Corporation
    5  *
    6  * This software is available to you under a choice of one of two
    7  * licenses.  You may choose to be licensed under the terms of the GNU
    8  * General Public License (GPL) Version 2, available from the file
    9  * COPYING in the main directory of this source tree, or the
   10  * OpenFabrics.org BSD license below:
   11  *
   12  *   Redistribution and use in source and binary forms, with or
   13  *   without modification, are permitted provided that the following
   14  *   conditions are met:
   15  *
   16  *    - Redistributions of source code must retain the above
   17  *      copyright notice, this list of conditions and the following
   18  *      disclaimer.
   19  *
   20  *    - Redistributions in binary form must reproduce the above
   21  *      copyright notice, this list of conditions and the following
   22  *      disclaimer in the documentation and/or other materials
   23  *      provided with the distribution.
   24  *
   25  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
   26  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
   27  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
   28  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
   29  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
   30  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
   31  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
   32  * SOFTWARE.
   33  */
   34 /*$FreeBSD$*/
   35 
   36 #ifndef IRDMA_PBLE_H
   37 #define IRDMA_PBLE_H
   38 
   39 #define PBLE_SHIFT              6
   40 #define PBLE_PER_PAGE           512
   41 #define HMC_PAGED_BP_SHIFT      12
   42 #define PBLE_512_SHIFT          9
   43 #define PBLE_INVALID_IDX        0xffffffff
   44 
   45 enum irdma_pble_level {
   46         PBLE_LEVEL_0 = 0,
   47         PBLE_LEVEL_1 = 1,
   48         PBLE_LEVEL_2 = 2,
   49 };
   50 
   51 enum irdma_alloc_type {
   52         PBLE_NO_ALLOC     = 0,
   53         PBLE_SD_CONTIGOUS = 1,
   54         PBLE_SD_PAGED     = 2,
   55 };
   56 
   57 struct irdma_chunk;
   58 
   59 struct irdma_pble_chunkinfo {
   60         struct irdma_chunk *pchunk;
   61         u64 bit_idx;
   62         u64 bits_used;
   63 };
   64 
   65 struct irdma_pble_info {
   66         u64 *addr;
   67         u32 idx;
   68         u32 cnt;
   69         struct irdma_pble_chunkinfo chunkinfo;
   70 };
   71 
   72 struct irdma_pble_level2 {
   73         struct irdma_pble_info root;
   74         struct irdma_pble_info *leaf;
   75         struct irdma_virt_mem leafmem;
   76         u32 leaf_cnt;
   77 };
   78 
   79 struct irdma_pble_alloc {
   80         u32 total_cnt;
   81         enum irdma_pble_level level;
   82         union {
   83                 struct irdma_pble_info level1;
   84                 struct irdma_pble_level2 level2;
   85         };
   86 };
   87 
   88 struct sd_pd_idx {
   89         u32 sd_idx;
   90         u32 pd_idx;
   91         u32 rel_pd_idx;
   92 };
   93 
   94 struct irdma_add_page_info {
   95         struct irdma_chunk *chunk;
   96         struct irdma_hmc_sd_entry *sd_entry;
   97         struct irdma_hmc_info *hmc_info;
   98         struct sd_pd_idx idx;
   99         u32 pages;
  100 };
  101 
  102 struct irdma_chunk {
  103         struct list_head list;
  104         struct irdma_dma_info dmainfo;
  105         void *bitmapbuf;
  106 
  107         u32 sizeofbitmap;
  108         u64 size;
  109         void *vaddr;
  110         u64 fpm_addr;
  111         u32 pg_cnt;
  112         enum irdma_alloc_type type;
  113         struct irdma_sc_dev *dev;
  114         struct irdma_virt_mem bitmapmem;
  115         struct irdma_virt_mem chunkmem;
  116 };
  117 
  118 struct irdma_pble_prm {
  119         struct list_head clist;
  120         spinlock_t prm_lock; /* protect prm bitmap */
  121         u64 total_pble_alloc;
  122         u64 free_pble_cnt;
  123         u8 pble_shift;
  124 };
  125 
  126 struct irdma_hmc_pble_rsrc {
  127         u32 unallocated_pble;
  128         struct mutex pble_mutex_lock; /* protect PBLE resource */
  129         struct irdma_sc_dev *dev;
  130         u64 fpm_base_addr;
  131         u64 next_fpm_addr;
  132         struct irdma_pble_prm pinfo;
  133         u64 allocdpbles;
  134         u64 freedpbles;
  135         u32 stats_direct_sds;
  136         u32 stats_paged_sds;
  137         u64 stats_alloc_ok;
  138         u64 stats_alloc_fail;
  139         u64 stats_alloc_freed;
  140         u64 stats_lvl1;
  141         u64 stats_lvl2;
  142 };
  143 
  144 void irdma_destroy_pble_prm(struct irdma_hmc_pble_rsrc *pble_rsrc);
  145 int irdma_hmc_init_pble(struct irdma_sc_dev *dev,
  146                         struct irdma_hmc_pble_rsrc *pble_rsrc);
  147 void irdma_free_pble(struct irdma_hmc_pble_rsrc *pble_rsrc,
  148                      struct irdma_pble_alloc *palloc);
  149 int irdma_get_pble(struct irdma_hmc_pble_rsrc *pble_rsrc,
  150                    struct irdma_pble_alloc *palloc, u32 pble_cnt,
  151                    bool level1_only);
  152 int irdma_prm_add_pble_mem(struct irdma_pble_prm *pprm,
  153                            struct irdma_chunk *pchunk);
  154 int irdma_prm_get_pbles(struct irdma_pble_prm *pprm,
  155                         struct irdma_pble_chunkinfo *chunkinfo, u64 mem_size,
  156                         u64 **vaddr, u64 *fpm_addr);
  157 void irdma_prm_return_pbles(struct irdma_pble_prm *pprm,
  158                             struct irdma_pble_chunkinfo *chunkinfo);
  159 void irdma_pble_acquire_lock(struct irdma_hmc_pble_rsrc *pble_rsrc,
  160                              unsigned long *flags);
  161 void irdma_pble_release_lock(struct irdma_hmc_pble_rsrc *pble_rsrc,
  162                              unsigned long *flags);
  163 void irdma_pble_free_paged_mem(struct irdma_chunk *chunk);
  164 int irdma_pble_get_paged_mem(struct irdma_chunk *chunk, u32 pg_cnt);
  165 void irdma_prm_rem_bitmapmem(struct irdma_hw *hw, struct irdma_chunk *chunk);
  166 #endif /* IRDMA_PBLE_H */

Cache object: a9e3d6055baea505266fc0d1f3b10be6


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.