otx_cptvf.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /* SPDX-License-Identifier: GPL-2.0
  2. * Marvell OcteonTX CPT driver
  3. *
  4. * Copyright (C) 2019 Marvell International Ltd.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #ifndef __OTX_CPTVF_H
  11. #define __OTX_CPTVF_H
  12. #include <linux/list.h>
  13. #include <linux/interrupt.h>
  14. #include <linux/device.h>
  15. #include "otx_cpt_common.h"
  16. #include "otx_cptvf_reqmgr.h"
  17. /* Flags to indicate the features supported */
  18. #define OTX_CPT_FLAG_DEVICE_READY BIT(1)
  19. #define otx_cpt_device_ready(cpt) ((cpt)->flags & OTX_CPT_FLAG_DEVICE_READY)
  20. /* Default command queue length */
  21. #define OTX_CPT_CMD_QLEN (4*2046)
  22. #define OTX_CPT_CMD_QCHUNK_SIZE 1023
  23. #define OTX_CPT_NUM_QS_PER_VF 1
  24. struct otx_cpt_cmd_chunk {
  25. u8 *head;
  26. dma_addr_t dma_addr;
  27. u32 size; /* Chunk size, max OTX_CPT_INST_CHUNK_MAX_SIZE */
  28. struct list_head nextchunk;
  29. };
  30. struct otx_cpt_cmd_queue {
  31. u32 idx; /* Command queue host write idx */
  32. u32 num_chunks; /* Number of command chunks */
  33. struct otx_cpt_cmd_chunk *qhead;/*
  34. * Command queue head, instructions
  35. * are inserted here
  36. */
  37. struct otx_cpt_cmd_chunk *base;
  38. struct list_head chead;
  39. };
  40. struct otx_cpt_cmd_qinfo {
  41. u32 qchunksize; /* Command queue chunk size */
  42. struct otx_cpt_cmd_queue queue[OTX_CPT_NUM_QS_PER_VF];
  43. };
  44. struct otx_cpt_pending_qinfo {
  45. u32 num_queues; /* Number of queues supported */
  46. struct otx_cpt_pending_queue queue[OTX_CPT_NUM_QS_PER_VF];
  47. };
  48. #define for_each_pending_queue(qinfo, q, i) \
  49. for (i = 0, q = &qinfo->queue[i]; i < qinfo->num_queues; i++, \
  50. q = &qinfo->queue[i])
  51. struct otx_cptvf_wqe {
  52. struct tasklet_struct twork;
  53. struct otx_cptvf *cptvf;
  54. };
  55. struct otx_cptvf_wqe_info {
  56. struct otx_cptvf_wqe vq_wqe[OTX_CPT_NUM_QS_PER_VF];
  57. };
  58. struct otx_cptvf {
  59. u16 flags; /* Flags to hold device status bits */
  60. u8 vfid; /* Device Index 0...OTX_CPT_MAX_VF_NUM */
  61. u8 num_vfs; /* Number of enabled VFs */
  62. u8 vftype; /* VF type of SE_TYPE(2) or AE_TYPE(1) */
  63. u8 vfgrp; /* VF group (0 - 8) */
  64. u8 node; /* Operating node: Bits (46:44) in BAR0 address */
  65. u8 priority; /*
  66. * VF priority ring: 1-High proirity round
  67. * robin ring;0-Low priority round robin ring;
  68. */
  69. struct pci_dev *pdev; /* Pci device handle */
  70. void __iomem *reg_base; /* Register start address */
  71. void *wqe_info; /* BH worker info */
  72. /* MSI-X */
  73. cpumask_var_t affinity_mask[OTX_CPT_VF_MSIX_VECTORS];
  74. /* Command and Pending queues */
  75. u32 qsize;
  76. u32 num_queues;
  77. struct otx_cpt_cmd_qinfo cqinfo; /* Command queue information */
  78. struct otx_cpt_pending_qinfo pqinfo; /* Pending queue information */
  79. /* VF-PF mailbox communication */
  80. bool pf_acked;
  81. bool pf_nacked;
  82. };
  83. int otx_cptvf_send_vf_up(struct otx_cptvf *cptvf);
  84. int otx_cptvf_send_vf_down(struct otx_cptvf *cptvf);
  85. int otx_cptvf_send_vf_to_grp_msg(struct otx_cptvf *cptvf, int group);
  86. int otx_cptvf_send_vf_priority_msg(struct otx_cptvf *cptvf);
  87. int otx_cptvf_send_vq_size_msg(struct otx_cptvf *cptvf);
  88. int otx_cptvf_check_pf_ready(struct otx_cptvf *cptvf);
  89. void otx_cptvf_handle_mbox_intr(struct otx_cptvf *cptvf);
  90. void otx_cptvf_write_vq_doorbell(struct otx_cptvf *cptvf, u32 val);
  91. #endif /* __OTX_CPTVF_H */