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.

flexboot_nodnic.h 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. #ifndef SRC_DRIVERS_INFINIBAND_FLEXBOOT_NODNIC_FLEXBOOT_NODNIC_H_
  2. #define SRC_DRIVERS_INFINIBAND_FLEXBOOT_NODNIC_FLEXBOOT_NODNIC_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_nodnic/include/mlx_nodnic_data_structures.h"
  23. #include "nodnic_prm.h"
  24. #include <ipxe/io.h>
  25. #include <ipxe/infiniband.h>
  26. #include <ipxe/netdevice.h>
  27. #include "mlx_utils/mlx_lib/mlx_nvconfig/mlx_nvconfig.h"
  28. /*
  29. * If defined, use interrupts in NODNIC driver
  30. */
  31. #define NODNIC_IRQ_ENABLED
  32. #define FLEXBOOT_NODNIC_MAX_PORTS 2
  33. #define FLEXBOOT_NODNIC_PORT_BASE 1
  34. #define FLEXBOOT_NODNIC_OPCODE_SEND 0xa
  35. #define FLEXBOOT_NODNIC_HCA_BAR PCI_BASE_ADDRESS_0 //BAR 0
  36. #define FLEXBOOT_NODNIC_PAGE_SHIFT 12
  37. #define FLEXBOOT_NODNIC_PAGE_SIZE (1 << FLEXBOOT_NODNIC_PAGE_SHIFT)
  38. #define FLEXBOOT_NODNIC_PAGE_MASK (FLEXBOOT_NODNIC_PAGE_SIZE - 1)
  39. #define EN_DEFAULT_ADMIN_MTU 1522
  40. /* Port protocol */
  41. enum flexboot_nodnic_protocol {
  42. FLEXBOOT_NODNIC_PROT_IB_IPV6 = 0,
  43. FLEXBOOT_NODNIC_PROT_ETH,
  44. FLEXBOOT_NODNIC_PROT_IB_IPV4,
  45. FLEXBOOT_NODNIC_PROT_FCOE
  46. };
  47. /** A flexboot nodnic port */
  48. struct flexboot_nodnic_port {
  49. /** Infiniband device */
  50. struct ib_device *ibdev;
  51. /** Network device */
  52. struct net_device *netdev;
  53. /** nodic port */
  54. nodnic_port_priv port_priv;
  55. /** Port type */
  56. struct flexboot_nodnic_port_type *type;
  57. /** Ethernet completion queue */
  58. struct ib_completion_queue *eth_cq;
  59. /** Ethernet queue pair */
  60. struct ib_queue_pair *eth_qp;
  61. mlx_uint8 cmdsn;
  62. };
  63. /** A flexboot nodnic queue pair */
  64. struct flexboot_nodnic_queue_pair {
  65. nodnic_qp *nodnic_queue_pair;
  66. };
  67. /** A flexboot nodnic cq */
  68. struct flexboot_nodnic_completion_queue {
  69. nodnic_cq *nodnic_completion_queue;
  70. };
  71. /** A flexboot_nodnic device */
  72. struct flexboot_nodnic {
  73. /** PCI device */
  74. struct pci_device *pci;
  75. /** nic specific data*/
  76. struct flexboot_nodnic_callbacks *callbacks;
  77. /**nodnic device*/
  78. nodnic_device_priv device_priv;
  79. /**flexboot_nodnic ports*/
  80. struct flexboot_nodnic_port port[FLEXBOOT_NODNIC_MAX_PORTS];
  81. /** Device open request counter */
  82. unsigned int open_count;
  83. /** Port masking */
  84. u16 port_mask;
  85. /** device private data */
  86. void *priv_data;
  87. };
  88. /** A flexboot_nodnic port type */
  89. struct flexboot_nodnic_port_type {
  90. /** Register port
  91. *
  92. * @v flexboot_nodnic flexboot_nodnic device
  93. * @v port flexboot_nodnic port
  94. * @ret mlx_status Return status code
  95. */
  96. mlx_status ( * register_dev ) (
  97. struct flexboot_nodnic *flexboot_nodnic,
  98. struct flexboot_nodnic_port *port
  99. );
  100. /** Port state changed
  101. *
  102. * @v flexboot_nodnic flexboot_nodnic device
  103. * @v port flexboot_nodnic port
  104. * @v link_up Link is up
  105. */
  106. void ( * state_change ) (
  107. struct flexboot_nodnic *flexboot_nodnic,
  108. struct flexboot_nodnic_port *port,
  109. int link_up
  110. );
  111. /** Unregister port
  112. *
  113. * @v flexboot_nodnic flexboot_nodnic device
  114. * @v port flexboot_nodnic port
  115. */
  116. void ( * unregister_dev ) (
  117. struct flexboot_nodnic *flexboot_nodnic,
  118. struct flexboot_nodnic_port *port
  119. );
  120. };
  121. struct cqe_data{
  122. mlx_boolean owner;
  123. mlx_uint32 qpn;
  124. mlx_uint32 is_send;
  125. mlx_uint32 is_error;
  126. mlx_uint32 syndrome;
  127. mlx_uint32 vendor_err_syndrome;
  128. mlx_uint32 wqe_counter;
  129. mlx_uint32 byte_cnt;
  130. };
  131. union arm_cq_uar {
  132. struct {
  133. //big endian
  134. mlx_uint32 reserved0 :2;
  135. mlx_uint32 cmdn :2;
  136. mlx_uint32 reserved1 :3;
  137. mlx_uint32 cmd :1;
  138. mlx_uint32 cq_ci :24;
  139. mlx_uint32 reserved2 :8;
  140. mlx_uint32 cq_n :24;
  141. };
  142. mlx_uint32 dword[2];
  143. mlx_uint64 qword;
  144. };
  145. struct flexboot_nodnic_callbacks {
  146. mlx_status ( * fill_completion ) ( void *cqe, struct cqe_data *cqe_data );
  147. mlx_status ( * cqe_set_owner ) ( void *cq, unsigned int num_cqes );
  148. mlx_size ( * get_cqe_size ) ();
  149. mlx_status ( * fill_send_wqe[5] ) (
  150. struct ib_device *ibdev,
  151. struct ib_queue_pair *qp,
  152. struct ib_address_vector *av,
  153. struct io_buffer *iobuf,
  154. struct nodnic_send_wqbb *wqbb,
  155. unsigned long wqe_idx
  156. );
  157. void ( * irq ) ( struct net_device *netdev, int enable );
  158. mlx_status ( * tx_uar_send_doorbell_fn ) (
  159. struct ib_device *ibdev,
  160. struct nodnic_send_wqbb *wqbb
  161. );
  162. };
  163. int flexboot_nodnic_probe ( struct pci_device *pci,
  164. struct flexboot_nodnic_callbacks *callbacks,
  165. void *drv_priv );
  166. void flexboot_nodnic_remove ( struct pci_device *pci );
  167. void flexboot_nodnic_eth_irq ( struct net_device *netdev, int enable );
  168. int flexboot_nodnic_is_supported ( struct pci_device *pci );
  169. void flexboot_nodnic_copy_mac ( uint8_t mac_addr[], uint32_t low_byte,
  170. uint16_t high_byte );
  171. int init_mlx_utils ( mlx_utils **utils, struct pci_device *pci );
  172. void free_mlx_utils ( mlx_utils **utils );
  173. #endif /* SRC_DRIVERS_INFINIBAND_FLEXBOOT_NODNIC_FLEXBOOT_NODNIC_H_ */