Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

flexboot_nodnic.h 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. /*
  28. * If defined, use interrupts in NODNIC driver
  29. */
  30. #define NODNIC_IRQ_ENABLED
  31. #define FLEXBOOT_NODNIC_MAX_PORTS 2
  32. #define FLEXBOOT_NODNIC_PORT_BASE 1
  33. #define FLEXBOOT_NODNIC_OPCODE_SEND 0xa
  34. /* Port protocol */
  35. enum flexboot_nodnic_protocol {
  36. FLEXBOOT_NODNIC_PROT_IB_IPV6 = 0,
  37. FLEXBOOT_NODNIC_PROT_ETH,
  38. FLEXBOOT_NODNIC_PROT_IB_IPV4,
  39. FLEXBOOT_NODNIC_PROT_FCOE
  40. };
  41. /** A flexboot nodnic port */
  42. struct flexboot_nodnic_port {
  43. /** Infiniband device */
  44. struct ib_device *ibdev;
  45. /** Network device */
  46. struct net_device *netdev;
  47. /** nodic port */
  48. nodnic_port_priv port_priv;
  49. /** Port type */
  50. struct flexboot_nodnic_port_type *type;
  51. /** Ethernet completion queue */
  52. struct ib_completion_queue *eth_cq;
  53. /** Ethernet queue pair */
  54. struct ib_queue_pair *eth_qp;
  55. };
  56. /** A flexboot nodnic queue pair */
  57. struct flexboot_nodnic_queue_pair {
  58. nodnic_qp *nodnic_queue_pair;
  59. };
  60. /** A flexboot nodnic cq */
  61. struct flexboot_nodnic_completion_queue {
  62. nodnic_cq *nodnic_completion_queue;
  63. };
  64. /** A flexboot_nodnic device */
  65. struct flexboot_nodnic {
  66. /** PCI device */
  67. struct pci_device *pci;
  68. /** nic specific data*/
  69. struct flexboot_nodnic_callbacks *callbacks;
  70. /**nodnic device*/
  71. nodnic_device_priv device_priv;
  72. /**flexboot_nodnic ports*/
  73. struct flexboot_nodnic_port port[FLEXBOOT_NODNIC_MAX_PORTS];
  74. /** Device open request counter */
  75. unsigned int open_count;
  76. /** Port masking */
  77. u16 port_mask;
  78. /** device private data */
  79. void *priv_data;
  80. };
  81. /** A flexboot_nodnic port type */
  82. struct flexboot_nodnic_port_type {
  83. /** Register port
  84. *
  85. * @v flexboot_nodnic flexboot_nodnic device
  86. * @v port flexboot_nodnic port
  87. * @ret mlx_status Return status code
  88. */
  89. mlx_status ( * register_dev ) (
  90. struct flexboot_nodnic *flexboot_nodnic,
  91. struct flexboot_nodnic_port *port
  92. );
  93. /** Port state changed
  94. *
  95. * @v flexboot_nodnic flexboot_nodnic device
  96. * @v port flexboot_nodnic port
  97. * @v link_up Link is up
  98. */
  99. void ( * state_change ) (
  100. struct flexboot_nodnic *flexboot_nodnic,
  101. struct flexboot_nodnic_port *port,
  102. int link_up
  103. );
  104. /** Unregister port
  105. *
  106. * @v flexboot_nodnic flexboot_nodnic device
  107. * @v port flexboot_nodnic port
  108. */
  109. void ( * unregister_dev ) (
  110. struct flexboot_nodnic *flexboot_nodnic,
  111. struct flexboot_nodnic_port *port
  112. );
  113. };
  114. struct cqe_data{
  115. mlx_boolean owner;
  116. mlx_uint32 qpn;
  117. mlx_uint32 is_send;
  118. mlx_uint32 is_error;
  119. mlx_uint32 syndrome;
  120. mlx_uint32 vendor_err_syndrome;
  121. mlx_uint32 wqe_counter;
  122. mlx_uint32 byte_cnt;
  123. };
  124. struct flexboot_nodnic_callbacks {
  125. mlx_status ( * fill_completion ) ( void *cqe, struct cqe_data *cqe_data );
  126. mlx_status ( * cqe_set_owner ) ( void *cq, unsigned int num_cqes );
  127. mlx_size ( * get_cqe_size ) ();
  128. mlx_status ( * fill_send_wqe[5] ) (
  129. struct ib_device *ibdev,
  130. struct ib_queue_pair *qp,
  131. struct ib_address_vector *av,
  132. struct io_buffer *iobuf,
  133. struct nodnic_send_wqbb *wqbb,
  134. unsigned long wqe_idx
  135. );
  136. void ( * irq ) ( struct net_device *netdev, int enable );
  137. };
  138. int flexboot_nodnic_probe ( struct pci_device *pci,
  139. struct flexboot_nodnic_callbacks *callbacks,
  140. void *drv_priv );
  141. void flexboot_nodnic_remove ( struct pci_device *pci );
  142. void flexboot_nodnic_eth_irq ( struct net_device *netdev, int enable );
  143. int flexboot_nodnic_is_supported ( struct pci_device *pci );
  144. void flexboot_nodnic_copy_mac ( uint8_t mac_addr[], uint32_t low_byte,
  145. uint16_t high_byte );
  146. #endif /* SRC_DRIVERS_INFINIBAND_FLEXBOOT_NODNIC_FLEXBOOT_NODNIC_H_ */