grukservices.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*
  2. * Copyright (c) 2008 Silicon Graphics, Inc. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. */
  18. #ifndef __GRU_KSERVICES_H_
  19. #define __GRU_KSERVICES_H_
  20. /*
  21. * Message queues using the GRU to send/receive messages.
  22. *
  23. * These function allow the user to create a message queue for
  24. * sending/receiving 1 or 2 cacheline messages using the GRU.
  25. *
  26. * Processes SENDING messages will use a kernel CBR/DSR to send
  27. * the message. This is transparent to the caller.
  28. *
  29. * The receiver does not use any GRU resources.
  30. *
  31. * The functions support:
  32. * - single receiver
  33. * - multiple senders
  34. * - cross partition message
  35. *
  36. * Missing features ZZZ:
  37. * - user options for dealing with timeouts, queue full, etc.
  38. * - gru_create_message_queue() needs interrupt vector info
  39. */
  40. /*
  41. * Initialize a user allocated chunk of memory to be used as
  42. * a message queue. The caller must ensure that the queue is
  43. * in contiguous physical memory and is cacheline aligned.
  44. *
  45. * Message queue size is the total number of bytes allocated
  46. * to the queue including a 2 cacheline header that is used
  47. * to manage the queue.
  48. *
  49. * Input:
  50. * p pointer to user allocated memory.
  51. * bytes size of message queue in bytes
  52. *
  53. * Errors:
  54. * 0 OK
  55. * >0 error
  56. */
  57. extern int gru_create_message_queue(void *p, unsigned int bytes);
  58. /*
  59. * Send a message to a message queue.
  60. *
  61. * Note: The message queue transport mechanism uses the first 32
  62. * bits of the message. Users should avoid using these bits.
  63. *
  64. *
  65. * Input:
  66. * xmq message queue - must be a UV global physical address
  67. * mesg pointer to message. Must be 64-bit aligned
  68. * bytes size of message in bytes
  69. *
  70. * Output:
  71. * 0 message sent
  72. * >0 Send failure - see error codes below
  73. *
  74. */
  75. extern int gru_send_message_gpa(unsigned long mq_gpa, void *mesg,
  76. unsigned int bytes);
  77. /* Status values for gru_send_message() */
  78. #define MQE_OK 0 /* message sent successfully */
  79. #define MQE_CONGESTION 1 /* temporary congestion, try again */
  80. #define MQE_QUEUE_FULL 2 /* queue is full */
  81. #define MQE_UNEXPECTED_CB_ERR 3 /* unexpected CB error */
  82. #define MQE_PAGE_OVERFLOW 10 /* BUG - queue overflowed a page */
  83. #define MQE_BUG_NO_RESOURCES 11 /* BUG - could not alloc GRU cb/dsr */
  84. /*
  85. * Advance the receive pointer for the message queue to the next message.
  86. * Note: current API requires messages to be gotten & freed in order. Future
  87. * API extensions may allow for out-of-order freeing.
  88. *
  89. * Input
  90. * mq message queue
  91. * mesq message being freed
  92. */
  93. extern void gru_free_message(void *mq, void *mesq);
  94. /*
  95. * Get next message from message queue. Returns pointer to
  96. * message OR NULL if no message present.
  97. * User must call gru_free_message() after message is processed
  98. * in order to move the queue pointers to next message.
  99. *
  100. * Input
  101. * mq message queue
  102. *
  103. * Output:
  104. * p pointer to message
  105. * NULL no message available
  106. */
  107. extern void *gru_get_next_message(void *mq);
  108. /*
  109. * Copy data using the GRU. Source or destination can be located in a remote
  110. * partition.
  111. *
  112. * Input:
  113. * dest_gpa destination global physical address
  114. * src_gpa source global physical address
  115. * bytes number of bytes to copy
  116. *
  117. * Output:
  118. * 0 OK
  119. * >0 error
  120. */
  121. extern int gru_copy_gpa(unsigned long dest_gpa, unsigned long src_gpa,
  122. unsigned int bytes);
  123. #endif /* __GRU_KSERVICES_H_ */