vnic_dev.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * Copyright 2014 Cisco Systems, Inc. All rights reserved.
  3. *
  4. * This program is free software; you may redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; version 2 of the License.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  9. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  10. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  11. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  12. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  13. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  14. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  15. * SOFTWARE.
  16. */
  17. #ifndef _VNIC_DEV_H_
  18. #define _VNIC_DEV_H_
  19. #include "vnic_resource.h"
  20. #include "vnic_devcmd.h"
  21. #ifndef VNIC_PADDR_TARGET
  22. #define VNIC_PADDR_TARGET 0x0000000000000000ULL
  23. #endif
  24. #ifndef readq
  25. static inline u64 readq(void __iomem *reg)
  26. {
  27. return ((u64)readl(reg + 0x4UL) << 32) | (u64)readl(reg);
  28. }
  29. static inline void writeq(u64 val, void __iomem *reg)
  30. {
  31. writel(lower_32_bits(val), reg);
  32. writel(upper_32_bits(val), reg + 0x4UL);
  33. }
  34. #endif
  35. enum vnic_dev_intr_mode {
  36. VNIC_DEV_INTR_MODE_UNKNOWN,
  37. VNIC_DEV_INTR_MODE_INTX,
  38. VNIC_DEV_INTR_MODE_MSI,
  39. VNIC_DEV_INTR_MODE_MSIX,
  40. };
  41. struct vnic_dev_bar {
  42. void __iomem *vaddr;
  43. dma_addr_t bus_addr;
  44. unsigned long len;
  45. };
  46. struct vnic_dev_ring {
  47. void *descs;
  48. size_t size;
  49. dma_addr_t base_addr;
  50. size_t base_align;
  51. void *descs_unaligned;
  52. size_t size_unaligned;
  53. dma_addr_t base_addr_unaligned;
  54. unsigned int desc_size;
  55. unsigned int desc_count;
  56. unsigned int desc_avail;
  57. };
  58. struct vnic_dev;
  59. struct vnic_stats;
  60. void *svnic_dev_priv(struct vnic_dev *vdev);
  61. unsigned int svnic_dev_get_res_count(struct vnic_dev *vdev,
  62. enum vnic_res_type type);
  63. void __iomem *svnic_dev_get_res(struct vnic_dev *vdev, enum vnic_res_type type,
  64. unsigned int index);
  65. unsigned int svnic_dev_desc_ring_size(struct vnic_dev_ring *ring,
  66. unsigned int desc_count,
  67. unsigned int desc_size);
  68. void svnic_dev_clear_desc_ring(struct vnic_dev_ring *ring);
  69. int svnic_dev_alloc_desc_ring(struct vnic_dev *vdev, struct vnic_dev_ring *ring,
  70. unsigned int desc_count, unsigned int desc_size);
  71. void svnic_dev_free_desc_ring(struct vnic_dev *vdev,
  72. struct vnic_dev_ring *ring);
  73. int svnic_dev_cmd(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd,
  74. u64 *a0, u64 *a1, int wait);
  75. int svnic_dev_fw_info(struct vnic_dev *vdev,
  76. struct vnic_devcmd_fw_info **fw_info);
  77. int svnic_dev_spec(struct vnic_dev *vdev, unsigned int offset,
  78. unsigned int size, void *value);
  79. int svnic_dev_stats_clear(struct vnic_dev *vdev);
  80. int svnic_dev_stats_dump(struct vnic_dev *vdev, struct vnic_stats **stats);
  81. int svnic_dev_notify_set(struct vnic_dev *vdev, u16 intr);
  82. void svnic_dev_notify_unset(struct vnic_dev *vdev);
  83. int svnic_dev_link_status(struct vnic_dev *vdev);
  84. u32 svnic_dev_link_down_cnt(struct vnic_dev *vdev);
  85. int svnic_dev_close(struct vnic_dev *vdev);
  86. int svnic_dev_enable_wait(struct vnic_dev *vdev);
  87. int svnic_dev_disable(struct vnic_dev *vdev);
  88. int svnic_dev_open(struct vnic_dev *vdev, int arg);
  89. int svnic_dev_open_done(struct vnic_dev *vdev, int *done);
  90. int svnic_dev_init(struct vnic_dev *vdev, int arg);
  91. struct vnic_dev *svnic_dev_alloc_discover(struct vnic_dev *vdev,
  92. void *priv, struct pci_dev *pdev,
  93. struct vnic_dev_bar *bar,
  94. unsigned int num_bars);
  95. void svnic_dev_set_intr_mode(struct vnic_dev *vdev,
  96. enum vnic_dev_intr_mode intr_mode);
  97. enum vnic_dev_intr_mode svnic_dev_get_intr_mode(struct vnic_dev *vdev);
  98. void svnic_dev_unregister(struct vnic_dev *vdev);
  99. int svnic_dev_cmd_init(struct vnic_dev *vdev, int fallback);
  100. #endif /* _VNIC_DEV_H_ */