iPXE
flexboot_nodnic.h
Go to the documentation of this file.
00001 #ifndef SRC_DRIVERS_INFINIBAND_FLEXBOOT_NODNIC_FLEXBOOT_NODNIC_H_
00002 #define SRC_DRIVERS_INFINIBAND_FLEXBOOT_NODNIC_FLEXBOOT_NODNIC_H_
00003 
00004 /*
00005  * Copyright (C) 2015 Mellanox Technologies Ltd.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License as
00009  * published by the Free Software Foundation; either version 2 of the
00010  * License, or any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful, but
00013  * WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00020  * 02110-1301, USA.
00021  */
00022 
00023 FILE_LICENCE ( GPL2_OR_LATER );
00024 
00025 #include "mlx_nodnic/include/mlx_nodnic_data_structures.h"
00026 #include "nodnic_prm.h"
00027 #include <ipxe/io.h>
00028 #include <ipxe/infiniband.h>
00029 #include <ipxe/netdevice.h>
00030 #include "mlx_utils/mlx_lib/mlx_nvconfig/mlx_nvconfig.h"
00031 
00032 /*
00033  * If defined, use interrupts in NODNIC driver
00034  */
00035 #define NODNIC_IRQ_ENABLED
00036 
00037 #define FLEXBOOT_NODNIC_MAX_PORTS               2
00038 #define FLEXBOOT_NODNIC_PORT_BASE               1
00039 
00040 #define FLEXBOOT_NODNIC_OPCODE_SEND             0xa
00041 #define FLEXBOOT_NODNIC_HCA_BAR PCI_BASE_ADDRESS_0      //BAR 0
00042 #define FLEXBOOT_NODNIC_PAGE_SHIFT      12
00043 #define FLEXBOOT_NODNIC_PAGE_SIZE               (1 << FLEXBOOT_NODNIC_PAGE_SHIFT)
00044 #define FLEXBOOT_NODNIC_PAGE_MASK               (FLEXBOOT_NODNIC_PAGE_SIZE - 1)
00045 #define EN_DEFAULT_ADMIN_MTU 1522
00046 
00047 /* Port protocol */
00048 enum flexboot_nodnic_protocol {
00049         FLEXBOOT_NODNIC_PROT_IB_IPV6 = 0,
00050         FLEXBOOT_NODNIC_PROT_ETH,
00051         FLEXBOOT_NODNIC_PROT_IB_IPV4,
00052         FLEXBOOT_NODNIC_PROT_FCOE
00053 };
00054 
00055 /** A flexboot nodnic port */
00056 struct flexboot_nodnic_port {
00057         /** Infiniband device */
00058         struct ib_device *ibdev;
00059         /** Network device */
00060         struct net_device *netdev;
00061         /** nodic port */
00062         nodnic_port_priv port_priv;
00063         /** Port type */
00064         struct flexboot_nodnic_port_type *type;
00065         /** Ethernet completion queue */
00066         struct ib_completion_queue *eth_cq;
00067         /** Ethernet queue pair */
00068         struct ib_queue_pair *eth_qp;
00069         mlx_uint8 cmdsn;
00070 };
00071 
00072 
00073 /** A flexboot nodnic queue pair */
00074 struct flexboot_nodnic_queue_pair {
00075         nodnic_qp *nodnic_queue_pair;
00076 };
00077 
00078 /** A flexboot nodnic cq */
00079 struct flexboot_nodnic_completion_queue {
00080         nodnic_cq *nodnic_completion_queue;
00081 };
00082 
00083 /** A flexboot_nodnic device */
00084 struct flexboot_nodnic {
00085         /** PCI device */
00086         struct pci_device *pci;
00087         /** nic specific data*/
00088         struct flexboot_nodnic_callbacks *callbacks;
00089         /**nodnic device*/
00090         nodnic_device_priv device_priv;
00091         /**flexboot_nodnic ports*/
00092         struct flexboot_nodnic_port port[FLEXBOOT_NODNIC_MAX_PORTS];
00093         /** Device open request counter */
00094         unsigned int open_count;
00095         /** Port masking  */
00096         u16 port_mask;
00097         /** device private data */
00098         void *priv_data;
00099 };
00100 
00101 /** A flexboot_nodnic port type */
00102 struct flexboot_nodnic_port_type {
00103         /** Register port
00104          *
00105          * @v flexboot_nodnic           flexboot_nodnic device
00106          * @v port              flexboot_nodnic port
00107          * @ret mlx_status              Return status code
00108          */
00109         mlx_status ( * register_dev ) (
00110                         struct flexboot_nodnic *flexboot_nodnic,
00111                         struct flexboot_nodnic_port *port
00112                         );
00113         /** Port state changed
00114          *
00115          * @v flexboot_nodnic           flexboot_nodnic device
00116          * @v port              flexboot_nodnic port
00117          * @v link_up           Link is up
00118          */
00119         void ( * state_change ) (
00120                         struct flexboot_nodnic *flexboot_nodnic,
00121                                   struct flexboot_nodnic_port *port,
00122                                   int link_up
00123                                   );
00124         /** Unregister port
00125          *
00126          * @v flexboot_nodnic           flexboot_nodnic device
00127          * @v port              flexboot_nodnic port
00128          */
00129         void ( * unregister_dev ) (
00130                         struct flexboot_nodnic *flexboot_nodnic,
00131                         struct flexboot_nodnic_port *port
00132                         );
00133 };
00134 
00135 struct cqe_data{
00136         mlx_boolean owner;
00137         mlx_uint32 qpn;
00138         mlx_uint32 is_send;
00139         mlx_uint32 is_error;
00140         mlx_uint32 syndrome;
00141         mlx_uint32 vendor_err_syndrome;
00142         mlx_uint32 wqe_counter;
00143         mlx_uint32 byte_cnt;
00144 };
00145 
00146 union arm_cq_uar {
00147         struct {
00148                 //big endian
00149                 mlx_uint32 reserved0    :2;
00150                 mlx_uint32 cmdn                 :2;
00151                 mlx_uint32 reserved1    :3;
00152                 mlx_uint32 cmd                  :1;
00153                 mlx_uint32 cq_ci                :24;
00154                 mlx_uint32 reserved2    :8;
00155                 mlx_uint32 cq_n         :24;
00156         };
00157         mlx_uint32 dword[2];
00158         mlx_uint64 qword;
00159 };
00160 
00161 struct flexboot_nodnic_callbacks {
00162         mlx_status ( * fill_completion ) ( void *cqe, struct cqe_data *cqe_data );
00163         mlx_status ( * cqe_set_owner ) ( void *cq, unsigned int num_cqes );
00164         mlx_size ( * get_cqe_size ) ();
00165         mlx_status ( * fill_send_wqe[5] ) (
00166                                 struct ib_device *ibdev,
00167                                 struct ib_queue_pair *qp,
00168                                 struct ib_address_vector *av,
00169                                 struct io_buffer *iobuf,
00170                                 struct nodnic_send_wqbb *wqbb,
00171                                 unsigned long wqe_idx
00172                                 );
00173         void ( * irq ) ( struct net_device *netdev, int enable );
00174         mlx_status ( * tx_uar_send_doorbell_fn ) (
00175                                         struct ib_device *ibdev,
00176                                         struct nodnic_send_wqbb *wqbb
00177                                         );
00178 };
00179 
00180 int flexboot_nodnic_probe ( struct pci_device *pci,
00181                 struct flexboot_nodnic_callbacks *callbacks,
00182                 void *drv_priv );
00183 void flexboot_nodnic_remove ( struct pci_device *pci );
00184 void flexboot_nodnic_eth_irq ( struct net_device *netdev, int enable );
00185 int flexboot_nodnic_is_supported ( struct pci_device *pci );
00186 void flexboot_nodnic_copy_mac ( uint8_t mac_addr[], uint32_t low_byte,
00187                 uint16_t high_byte );
00188 int init_mlx_utils ( mlx_utils **utils, struct pci_device *pci );
00189 void free_mlx_utils ( mlx_utils **utils );
00190 #endif /* SRC_DRIVERS_INFINIBAND_FLEXBOOT_NODNIC_FLEXBOOT_NODNIC_H_ */