root/drivers/scsi/cxlflash/cxl_hw.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. cxlflash_psa_map
  2. cxlflash_psa_unmap
  3. cxlflash_process_element
  4. cxlflash_map_afu_irq
  5. cxlflash_unmap_afu_irq
  6. cxlflash_get_irq_objhndl
  7. cxlflash_start_context
  8. cxlflash_stop_context
  9. cxlflash_afu_reset
  10. cxlflash_set_master
  11. cxlflash_get_context
  12. cxlflash_dev_context_init
  13. cxlflash_release_context
  14. cxlflash_perst_reloads_same_image
  15. cxlflash_read_adapter_vpd
  16. cxlflash_allocate_afu_irqs
  17. cxlflash_free_afu_irqs
  18. cxlflash_create_afu
  19. cxlflash_destroy_afu
  20. cxlflash_get_fd
  21. cxlflash_fops_get_context
  22. cxlflash_start_work
  23. cxlflash_fd_mmap
  24. cxlflash_fd_release

   1 // SPDX-License-Identifier: GPL-2.0-or-later
   2 /*
   3  * CXL Flash Device Driver
   4  *
   5  * Written by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>, IBM Corporation
   6  *             Uma Krishnan <ukrishn@linux.vnet.ibm.com>, IBM Corporation
   7  *
   8  * Copyright (C) 2018 IBM Corporation
   9  */
  10 
  11 #include <misc/cxl.h>
  12 
  13 #include "backend.h"
  14 
  15 /*
  16  * The following routines map the cxlflash backend operations to existing CXL
  17  * kernel API function and are largely simple shims that provide an abstraction
  18  * for converting generic context and AFU cookies into cxl_context or cxl_afu
  19  * pointers.
  20  */
  21 
  22 static void __iomem *cxlflash_psa_map(void *ctx_cookie)
  23 {
  24         return cxl_psa_map(ctx_cookie);
  25 }
  26 
  27 static void cxlflash_psa_unmap(void __iomem *addr)
  28 {
  29         cxl_psa_unmap(addr);
  30 }
  31 
  32 static int cxlflash_process_element(void *ctx_cookie)
  33 {
  34         return cxl_process_element(ctx_cookie);
  35 }
  36 
  37 static int cxlflash_map_afu_irq(void *ctx_cookie, int num,
  38                                 irq_handler_t handler, void *cookie, char *name)
  39 {
  40         return cxl_map_afu_irq(ctx_cookie, num, handler, cookie, name);
  41 }
  42 
  43 static void cxlflash_unmap_afu_irq(void *ctx_cookie, int num, void *cookie)
  44 {
  45         cxl_unmap_afu_irq(ctx_cookie, num, cookie);
  46 }
  47 
  48 static u64 cxlflash_get_irq_objhndl(void *ctx_cookie, int irq)
  49 {
  50         /* Dummy fop for cxl */
  51         return 0;
  52 }
  53 
  54 static int cxlflash_start_context(void *ctx_cookie)
  55 {
  56         return cxl_start_context(ctx_cookie, 0, NULL);
  57 }
  58 
  59 static int cxlflash_stop_context(void *ctx_cookie)
  60 {
  61         return cxl_stop_context(ctx_cookie);
  62 }
  63 
  64 static int cxlflash_afu_reset(void *ctx_cookie)
  65 {
  66         return cxl_afu_reset(ctx_cookie);
  67 }
  68 
  69 static void cxlflash_set_master(void *ctx_cookie)
  70 {
  71         cxl_set_master(ctx_cookie);
  72 }
  73 
  74 static void *cxlflash_get_context(struct pci_dev *dev, void *afu_cookie)
  75 {
  76         return cxl_get_context(dev);
  77 }
  78 
  79 static void *cxlflash_dev_context_init(struct pci_dev *dev, void *afu_cookie)
  80 {
  81         return cxl_dev_context_init(dev);
  82 }
  83 
  84 static int cxlflash_release_context(void *ctx_cookie)
  85 {
  86         return cxl_release_context(ctx_cookie);
  87 }
  88 
  89 static void cxlflash_perst_reloads_same_image(void *afu_cookie, bool image)
  90 {
  91         cxl_perst_reloads_same_image(afu_cookie, image);
  92 }
  93 
  94 static ssize_t cxlflash_read_adapter_vpd(struct pci_dev *dev,
  95                                          void *buf, size_t count)
  96 {
  97         return cxl_read_adapter_vpd(dev, buf, count);
  98 }
  99 
 100 static int cxlflash_allocate_afu_irqs(void *ctx_cookie, int num)
 101 {
 102         return cxl_allocate_afu_irqs(ctx_cookie, num);
 103 }
 104 
 105 static void cxlflash_free_afu_irqs(void *ctx_cookie)
 106 {
 107         cxl_free_afu_irqs(ctx_cookie);
 108 }
 109 
 110 static void *cxlflash_create_afu(struct pci_dev *dev)
 111 {
 112         return cxl_pci_to_afu(dev);
 113 }
 114 
 115 static void cxlflash_destroy_afu(void *afu)
 116 {
 117         /* Dummy fop for cxl */
 118 }
 119 
 120 static struct file *cxlflash_get_fd(void *ctx_cookie,
 121                                     struct file_operations *fops, int *fd)
 122 {
 123         return cxl_get_fd(ctx_cookie, fops, fd);
 124 }
 125 
 126 static void *cxlflash_fops_get_context(struct file *file)
 127 {
 128         return cxl_fops_get_context(file);
 129 }
 130 
 131 static int cxlflash_start_work(void *ctx_cookie, u64 irqs)
 132 {
 133         struct cxl_ioctl_start_work work = { 0 };
 134 
 135         work.num_interrupts = irqs;
 136         work.flags = CXL_START_WORK_NUM_IRQS;
 137 
 138         return cxl_start_work(ctx_cookie, &work);
 139 }
 140 
 141 static int cxlflash_fd_mmap(struct file *file, struct vm_area_struct *vm)
 142 {
 143         return cxl_fd_mmap(file, vm);
 144 }
 145 
 146 static int cxlflash_fd_release(struct inode *inode, struct file *file)
 147 {
 148         return cxl_fd_release(inode, file);
 149 }
 150 
 151 const struct cxlflash_backend_ops cxlflash_cxl_ops = {
 152         .module                 = THIS_MODULE,
 153         .psa_map                = cxlflash_psa_map,
 154         .psa_unmap              = cxlflash_psa_unmap,
 155         .process_element        = cxlflash_process_element,
 156         .map_afu_irq            = cxlflash_map_afu_irq,
 157         .unmap_afu_irq          = cxlflash_unmap_afu_irq,
 158         .get_irq_objhndl        = cxlflash_get_irq_objhndl,
 159         .start_context          = cxlflash_start_context,
 160         .stop_context           = cxlflash_stop_context,
 161         .afu_reset              = cxlflash_afu_reset,
 162         .set_master             = cxlflash_set_master,
 163         .get_context            = cxlflash_get_context,
 164         .dev_context_init       = cxlflash_dev_context_init,
 165         .release_context        = cxlflash_release_context,
 166         .perst_reloads_same_image = cxlflash_perst_reloads_same_image,
 167         .read_adapter_vpd       = cxlflash_read_adapter_vpd,
 168         .allocate_afu_irqs      = cxlflash_allocate_afu_irqs,
 169         .free_afu_irqs          = cxlflash_free_afu_irqs,
 170         .create_afu             = cxlflash_create_afu,
 171         .destroy_afu            = cxlflash_destroy_afu,
 172         .get_fd                 = cxlflash_get_fd,
 173         .fops_get_context       = cxlflash_fops_get_context,
 174         .start_work             = cxlflash_start_work,
 175         .fd_mmap                = cxlflash_fd_mmap,
 176         .fd_release             = cxlflash_fd_release,
 177 };

/* [<][>][^][v][top][bottom][index][help] */