mic_virtio.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Intel MIC Platform Software Stack (MPSS)
  3. *
  4. * Copyright(c) 2013 Intel Corporation.
  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. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * General Public License for more details.
  14. *
  15. * The full GNU General Public License is included in this distribution in
  16. * the file called "COPYING".
  17. *
  18. * Disclaimer: The codes contained in these modules may be specific to
  19. * the Intel Software Development Platform codenamed: Knights Ferry, and
  20. * the Intel product codenamed: Knights Corner, and are not backward
  21. * compatible with other Intel products. Additionally, Intel will NOT
  22. * support the codes or instruction set in future products.
  23. *
  24. * Intel MIC Card driver.
  25. *
  26. */
  27. #ifndef __MIC_CARD_VIRTIO_H
  28. #define __MIC_CARD_VIRTIO_H
  29. #include <linux/mic_common.h>
  30. #include "mic_device.h"
  31. /*
  32. * 64 bit I/O access
  33. */
  34. #ifndef ioread64
  35. #define ioread64 readq
  36. #endif
  37. #ifndef iowrite64
  38. #define iowrite64 writeq
  39. #endif
  40. static inline unsigned mic_desc_size(struct mic_device_desc __iomem *desc)
  41. {
  42. return sizeof(*desc)
  43. + ioread8(&desc->num_vq) * sizeof(struct mic_vqconfig)
  44. + ioread8(&desc->feature_len) * 2
  45. + ioread8(&desc->config_len);
  46. }
  47. static inline struct mic_vqconfig __iomem *
  48. mic_vq_config(struct mic_device_desc __iomem *desc)
  49. {
  50. return (struct mic_vqconfig __iomem *)(desc + 1);
  51. }
  52. static inline __u8 __iomem *
  53. mic_vq_features(struct mic_device_desc __iomem *desc)
  54. {
  55. return (__u8 __iomem *)(mic_vq_config(desc) + ioread8(&desc->num_vq));
  56. }
  57. static inline __u8 __iomem *
  58. mic_vq_configspace(struct mic_device_desc __iomem *desc)
  59. {
  60. return mic_vq_features(desc) + ioread8(&desc->feature_len) * 2;
  61. }
  62. static inline unsigned mic_total_desc_size(struct mic_device_desc __iomem *desc)
  63. {
  64. return mic_aligned_desc_size(desc) + sizeof(struct mic_device_ctrl);
  65. }
  66. int mic_devices_init(struct mic_driver *mdrv);
  67. void mic_devices_uninit(struct mic_driver *mdrv);
  68. #endif