ipath_layer.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /*
  2. * Copyright (c) 2006 QLogic, Inc. All rights reserved.
  3. * Copyright (c) 2003, 2004, 2005, 2006 PathScale, Inc. All rights reserved.
  4. *
  5. * This software is available to you under a choice of one of two
  6. * licenses. You may choose to be licensed under the terms of the GNU
  7. * General Public License (GPL) Version 2, available from the file
  8. * COPYING in the main directory of this source tree, or the
  9. * OpenIB.org BSD license below:
  10. *
  11. * Redistribution and use in source and binary forms, with or
  12. * without modification, are permitted provided that the following
  13. * conditions are met:
  14. *
  15. * - Redistributions of source code must retain the above
  16. * copyright notice, this list of conditions and the following
  17. * disclaimer.
  18. *
  19. * - Redistributions in binary form must reproduce the above
  20. * copyright notice, this list of conditions and the following
  21. * disclaimer in the documentation and/or other materials
  22. * provided with the distribution.
  23. *
  24. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  25. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  26. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  27. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  28. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  29. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  30. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  31. * SOFTWARE.
  32. */
  33. #ifndef _IPATH_LAYER_H
  34. #define _IPATH_LAYER_H
  35. /*
  36. * This header file is for symbols shared between the infinipath driver
  37. * and drivers layered upon it (such as ipath).
  38. */
  39. struct sk_buff;
  40. struct ipath_sge_state;
  41. struct ipath_devdata;
  42. struct ether_header;
  43. struct ipath_layer_counters {
  44. u64 symbol_error_counter;
  45. u64 link_error_recovery_counter;
  46. u64 link_downed_counter;
  47. u64 port_rcv_errors;
  48. u64 port_rcv_remphys_errors;
  49. u64 port_xmit_discards;
  50. u64 port_xmit_data;
  51. u64 port_rcv_data;
  52. u64 port_xmit_packets;
  53. u64 port_rcv_packets;
  54. u32 local_link_integrity_errors;
  55. u32 excessive_buffer_overrun_errors;
  56. };
  57. /*
  58. * A segment is a linear region of low physical memory.
  59. * XXX Maybe we should use phys addr here and kmap()/kunmap().
  60. * Used by the verbs layer.
  61. */
  62. struct ipath_seg {
  63. void *vaddr;
  64. size_t length;
  65. };
  66. /* The number of ipath_segs that fit in a page. */
  67. #define IPATH_SEGSZ (PAGE_SIZE / sizeof (struct ipath_seg))
  68. struct ipath_segarray {
  69. struct ipath_seg segs[IPATH_SEGSZ];
  70. };
  71. struct ipath_mregion {
  72. u64 user_base; /* User's address for this region */
  73. u64 iova; /* IB start address of this region */
  74. size_t length;
  75. u32 lkey;
  76. u32 offset; /* offset (bytes) to start of region */
  77. int access_flags;
  78. u32 max_segs; /* number of ipath_segs in all the arrays */
  79. u32 mapsz; /* size of the map array */
  80. struct ipath_segarray *map[0]; /* the segments */
  81. };
  82. /*
  83. * These keep track of the copy progress within a memory region.
  84. * Used by the verbs layer.
  85. */
  86. struct ipath_sge {
  87. struct ipath_mregion *mr;
  88. void *vaddr; /* current pointer into the segment */
  89. u32 sge_length; /* length of the SGE */
  90. u32 length; /* remaining length of the segment */
  91. u16 m; /* current index: mr->map[m] */
  92. u16 n; /* current index: mr->map[m]->segs[n] */
  93. };
  94. struct ipath_sge_state {
  95. struct ipath_sge *sg_list; /* next SGE to be used if any */
  96. struct ipath_sge sge; /* progress state for the current SGE */
  97. u8 num_sge;
  98. };
  99. int ipath_layer_register(void *(*l_add)(int, struct ipath_devdata *),
  100. void (*l_remove)(void *),
  101. int (*l_intr)(void *, u32),
  102. int (*l_rcv)(void *, void *,
  103. struct sk_buff *),
  104. u16 rcv_opcode,
  105. int (*l_rcv_lid)(void *, void *));
  106. int ipath_verbs_register(void *(*l_add)(int, struct ipath_devdata *),
  107. void (*l_remove)(void *arg),
  108. int (*l_piobufavail)(void *arg),
  109. void (*l_rcv)(void *arg, void *rhdr,
  110. void *data, u32 tlen),
  111. void (*l_timer_cb)(void *arg));
  112. void ipath_layer_unregister(void);
  113. void ipath_verbs_unregister(void);
  114. int ipath_layer_open(struct ipath_devdata *, u32 * pktmax);
  115. u16 ipath_layer_get_lid(struct ipath_devdata *dd);
  116. int ipath_layer_get_mac(struct ipath_devdata *dd, u8 *);
  117. u16 ipath_layer_get_bcast(struct ipath_devdata *dd);
  118. u32 ipath_layer_get_cr_errpkey(struct ipath_devdata *dd);
  119. int ipath_layer_set_linkstate(struct ipath_devdata *dd, u8 state);
  120. int ipath_layer_set_mtu(struct ipath_devdata *, u16);
  121. int ipath_set_lid(struct ipath_devdata *, u32, u8);
  122. int ipath_layer_send_hdr(struct ipath_devdata *dd,
  123. struct ether_header *hdr);
  124. int ipath_verbs_send(struct ipath_devdata *dd, u32 hdrwords,
  125. u32 * hdr, u32 len, struct ipath_sge_state *ss);
  126. int ipath_layer_set_piointbufavail_int(struct ipath_devdata *dd);
  127. int ipath_layer_get_boardname(struct ipath_devdata *dd, char *name,
  128. size_t namelen);
  129. int ipath_layer_snapshot_counters(struct ipath_devdata *dd, u64 *swords,
  130. u64 *rwords, u64 *spkts, u64 *rpkts,
  131. u64 *xmit_wait);
  132. int ipath_layer_get_counters(struct ipath_devdata *dd,
  133. struct ipath_layer_counters *cntrs);
  134. int ipath_layer_want_buffer(struct ipath_devdata *dd);
  135. int ipath_layer_set_guid(struct ipath_devdata *, __be64 guid);
  136. __be64 ipath_layer_get_guid(struct ipath_devdata *);
  137. u32 ipath_layer_get_nguid(struct ipath_devdata *);
  138. u32 ipath_layer_get_majrev(struct ipath_devdata *);
  139. u32 ipath_layer_get_minrev(struct ipath_devdata *);
  140. u32 ipath_layer_get_pcirev(struct ipath_devdata *);
  141. u32 ipath_layer_get_flags(struct ipath_devdata *dd);
  142. struct device *ipath_layer_get_device(struct ipath_devdata *dd);
  143. u16 ipath_layer_get_deviceid(struct ipath_devdata *dd);
  144. u32 ipath_layer_get_vendorid(struct ipath_devdata *);
  145. u64 ipath_layer_get_lastibcstat(struct ipath_devdata *dd);
  146. u32 ipath_layer_get_ibmtu(struct ipath_devdata *dd);
  147. int ipath_layer_enable_timer(struct ipath_devdata *dd);
  148. int ipath_layer_disable_timer(struct ipath_devdata *dd);
  149. int ipath_layer_set_verbs_flags(struct ipath_devdata *dd, unsigned flags);
  150. unsigned ipath_layer_get_npkeys(struct ipath_devdata *dd);
  151. unsigned ipath_layer_get_pkey(struct ipath_devdata *dd, unsigned index);
  152. int ipath_layer_get_pkeys(struct ipath_devdata *dd, u16 *pkeys);
  153. int ipath_layer_set_pkeys(struct ipath_devdata *dd, u16 *pkeys);
  154. int ipath_layer_get_linkdowndefaultstate(struct ipath_devdata *dd);
  155. int ipath_layer_set_linkdowndefaultstate(struct ipath_devdata *dd,
  156. int sleep);
  157. int ipath_layer_get_phyerrthreshold(struct ipath_devdata *dd);
  158. int ipath_layer_set_phyerrthreshold(struct ipath_devdata *dd, unsigned n);
  159. int ipath_layer_get_overrunthreshold(struct ipath_devdata *dd);
  160. int ipath_layer_set_overrunthreshold(struct ipath_devdata *dd, unsigned n);
  161. u32 ipath_layer_get_rcvhdrentsize(struct ipath_devdata *dd);
  162. /* ipath_ether interrupt values */
  163. #define IPATH_LAYER_INT_IF_UP 0x2
  164. #define IPATH_LAYER_INT_IF_DOWN 0x4
  165. #define IPATH_LAYER_INT_LID 0x8
  166. #define IPATH_LAYER_INT_SEND_CONTINUE 0x10
  167. #define IPATH_LAYER_INT_BCAST 0x40
  168. /* _verbs_layer.l_flags */
  169. #define IPATH_VERBS_KERNEL_SMA 0x1
  170. extern unsigned ipath_debug; /* debugging bit mask */
  171. #endif /* _IPATH_LAYER_H */