You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mlx_utils.h 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #ifndef MLXUTILS_INCLUDE_PUBLIC_MLXUTILS_H_
  2. #define MLXUTILS_INCLUDE_PUBLIC_MLXUTILS_H_
  3. /*
  4. * Copyright (C) 2015 Mellanox Technologies Ltd.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation; either version 2 of the
  9. * License, or any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  19. * 02110-1301, USA.
  20. */
  21. FILE_LICENCE ( GPL2_OR_LATER );
  22. #include "mlx_logging.h"
  23. #include "mlx_types.h"
  24. #define IN
  25. #define OUT
  26. typedef mlx_uint16 mlx_pci_gw_space;
  27. typedef struct{
  28. mlx_uint32 pci_cmd_offset;
  29. mlx_pci_gw_space space;
  30. } __attribute__ (( packed )) mlx_pci_gw;
  31. typedef struct {
  32. mlx_boolean icmd_opened;
  33. mlx_boolean took_semaphore;
  34. mlx_uint32 max_cmd_size;
  35. } __attribute__ (( packed )) mlx_icmd ;
  36. typedef struct{
  37. mlx_pci *pci;
  38. mlx_pci_gw pci_gw;
  39. mlx_icmd icmd;
  40. void *lock;
  41. #ifdef DEVICE_CX3
  42. /* ACCESS to BAR0 */
  43. void *config;
  44. #endif
  45. } __attribute__ (( packed )) mlx_utils;
  46. mlx_status
  47. mlx_utils_init(
  48. IN mlx_utils *utils,
  49. IN mlx_pci *pci
  50. );
  51. mlx_status
  52. mlx_utils_teardown(
  53. IN mlx_utils *utils
  54. );
  55. mlx_status
  56. mlx_utils_delay_in_ms(
  57. IN mlx_uint32 msecs
  58. );
  59. mlx_status
  60. mlx_utils_delay_in_us(
  61. IN mlx_uint32 usecs
  62. );
  63. mlx_status
  64. mlx_utils_ilog2(
  65. IN mlx_uint32 i,
  66. OUT mlx_uint32 *log
  67. );
  68. mlx_status
  69. mlx_utils_init_lock(
  70. IN OUT mlx_utils *utils
  71. );
  72. mlx_status
  73. mlx_utils_free_lock(
  74. IN OUT mlx_utils *utils
  75. );
  76. mlx_status
  77. mlx_utils_acquire_lock (
  78. IN OUT mlx_utils *utils
  79. );
  80. mlx_status
  81. mlx_utils_release_lock (
  82. IN OUT mlx_utils *utils
  83. );
  84. mlx_status
  85. mlx_utils_rand (
  86. IN mlx_utils *utils,
  87. OUT mlx_uint32 *rand_num
  88. );
  89. #endif /* STUB_MLXUTILS_INCLUDE_PUBLIC_MLXUTILS_H_ */