hinic_hw_io.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * Huawei HiNIC PCI Express Linux driver
  3. * Copyright(c) 2017 Huawei Technologies Co., Ltd
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms and conditions of the GNU General Public License,
  7. * version 2, as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  12. * for more details.
  13. *
  14. */
  15. #ifndef HINIC_HW_IO_H
  16. #define HINIC_HW_IO_H
  17. #include <linux/types.h>
  18. #include <linux/pci.h>
  19. #include <linux/semaphore.h>
  20. #include <linux/sizes.h>
  21. #include "hinic_hw_if.h"
  22. #include "hinic_hw_eqs.h"
  23. #include "hinic_hw_wq.h"
  24. #include "hinic_hw_cmdq.h"
  25. #include "hinic_hw_qp.h"
  26. #define HINIC_DB_PAGE_SIZE SZ_4K
  27. #define HINIC_DB_SIZE SZ_4M
  28. #define HINIC_DB_MAX_AREAS (HINIC_DB_SIZE / HINIC_DB_PAGE_SIZE)
  29. enum hinic_db_type {
  30. HINIC_DB_CMDQ_TYPE,
  31. HINIC_DB_SQ_TYPE,
  32. };
  33. enum hinic_io_path {
  34. HINIC_CTRL_PATH,
  35. HINIC_DATA_PATH,
  36. };
  37. struct hinic_free_db_area {
  38. int db_idx[HINIC_DB_MAX_AREAS];
  39. int alloc_pos;
  40. int return_pos;
  41. int num_free;
  42. /* Lock for getting db area */
  43. struct semaphore idx_lock;
  44. };
  45. struct hinic_func_to_io {
  46. struct hinic_hwif *hwif;
  47. struct hinic_ceqs ceqs;
  48. struct hinic_wqs wqs;
  49. struct hinic_wq *sq_wq;
  50. struct hinic_wq *rq_wq;
  51. struct hinic_qp *qps;
  52. u16 max_qps;
  53. void __iomem **sq_db;
  54. void __iomem *db_base;
  55. void *ci_addr_base;
  56. dma_addr_t ci_dma_base;
  57. struct hinic_free_db_area free_db_area;
  58. void __iomem *cmdq_db_area[HINIC_MAX_CMDQ_TYPES];
  59. struct hinic_cmdqs cmdqs;
  60. };
  61. int hinic_io_create_qps(struct hinic_func_to_io *func_to_io,
  62. u16 base_qpn, int num_qps,
  63. struct msix_entry *sq_msix_entries,
  64. struct msix_entry *rq_msix_entries);
  65. void hinic_io_destroy_qps(struct hinic_func_to_io *func_to_io,
  66. int num_qps);
  67. int hinic_io_init(struct hinic_func_to_io *func_to_io,
  68. struct hinic_hwif *hwif, u16 max_qps, int num_ceqs,
  69. struct msix_entry *ceq_msix_entries);
  70. void hinic_io_free(struct hinic_func_to_io *func_to_io);
  71. #endif