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.c 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * Copyright (C) 2015 Mellanox Technologies Ltd.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 of the
  7. * License, or any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  17. * 02110-1301, USA.
  18. */
  19. FILE_LICENCE ( GPL2_OR_LATER );
  20. #include <stddef.h>
  21. #include "../../include/private/mlx_utils_priv.h"
  22. #include "../../include/public/mlx_pci.h"
  23. #include "../../include/public/mlx_utils.h"
  24. mlx_status
  25. mlx_utils_init(
  26. IN mlx_utils *utils,
  27. IN mlx_pci *pci
  28. )
  29. {
  30. mlx_status status = MLX_SUCCESS;
  31. if( pci == NULL || utils == NULL ){
  32. status = MLX_INVALID_PARAMETER;
  33. goto bail;
  34. }
  35. utils->pci = pci;
  36. status = mlx_pci_init(utils);
  37. status = mlx_utils_init_lock(utils);
  38. bail:
  39. return status;
  40. }
  41. mlx_status
  42. mlx_utils_teardown(
  43. IN mlx_utils *utils __attribute__ ((unused))
  44. )
  45. {
  46. mlx_status status = MLX_SUCCESS;
  47. mlx_utils_free_lock(utils);
  48. return status;
  49. }
  50. mlx_status
  51. mlx_utils_delay_in_ms(
  52. IN mlx_uint32 msecs
  53. )
  54. {
  55. mlx_utils_delay_in_ms_priv(msecs);
  56. return MLX_SUCCESS;
  57. }
  58. mlx_status
  59. mlx_utils_delay_in_us(
  60. IN mlx_uint32 usecs
  61. )
  62. {
  63. mlx_utils_delay_in_us_priv(usecs);
  64. return MLX_SUCCESS;
  65. }
  66. mlx_status
  67. mlx_utils_ilog2(
  68. IN mlx_uint32 i,
  69. OUT mlx_uint32 *log
  70. )
  71. {
  72. mlx_utils_ilog2_priv(i, log);
  73. return MLX_SUCCESS;
  74. }
  75. mlx_status
  76. mlx_utils_init_lock(
  77. IN OUT mlx_utils *utils
  78. )
  79. {
  80. return mlx_utils_init_lock_priv(&(utils->lock));
  81. }
  82. mlx_status
  83. mlx_utils_free_lock(
  84. IN OUT mlx_utils *utils
  85. )
  86. {
  87. return mlx_utils_free_lock_priv(utils->lock);
  88. }
  89. mlx_status
  90. mlx_utils_acquire_lock (
  91. IN OUT mlx_utils *utils
  92. )
  93. {
  94. return mlx_utils_acquire_lock_priv(utils->lock);
  95. }
  96. mlx_status
  97. mlx_utils_release_lock (
  98. IN OUT mlx_utils *utils
  99. )
  100. {
  101. return mlx_utils_release_lock_priv(utils->lock);
  102. }
  103. mlx_status
  104. mlx_utils_rand (
  105. IN mlx_utils *utils,
  106. OUT mlx_uint32 *rand_num
  107. )
  108. {
  109. return mlx_utils_rand_priv(utils, rand_num);
  110. }