iPXE
ib_packet.h
Go to the documentation of this file.
00001 #ifndef _IPXE_IB_PACKET_H
00002 #define _IPXE_IB_PACKET_H
00003 
00004 /** @file
00005  *
00006  * Infiniband packet format
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00011 
00012 struct ib_device;
00013 struct ib_queue_pair;
00014 struct ib_address_vector;
00015 struct io_buffer;
00016 
00017 /** An Infiniband Globally Unique Identifier */
00018 union ib_guid {
00019         uint8_t bytes[8];
00020         uint16_t words[4];
00021         uint32_t dwords[2];
00022         uint64_t qword;
00023 };
00024 
00025 /** Infiniband Globally Unique Identifier debug message format */
00026 #define IB_GUID_FMT "%08x:%08x"
00027 
00028 /** Infiniband Globally Unique Identifier debug message arguments */
00029 #define IB_GUID_ARGS( guid ) \
00030         ntohl ( (guid)->dwords[0] ), ntohl ( (guid)->dwords[1] )
00031 
00032 /** An Infiniband Global Identifier */
00033 union ib_gid {
00034         uint8_t bytes[16];
00035         uint16_t words[8];
00036         uint32_t dwords[4];
00037         uint64_t qwords[2];
00038         struct {
00039                 union ib_guid prefix;
00040                 union ib_guid guid;
00041         } s;
00042 };
00043 
00044 /** Infiniband Global Identifier debug message format */
00045 #define IB_GID_FMT IB_GUID_FMT ":" IB_GUID_FMT
00046 
00047 /** Infiniband Global Identifier debug message arguments */
00048 #define IB_GID_ARGS( gid ) \
00049         IB_GUID_ARGS ( &(gid)->s.prefix ), IB_GUID_ARGS ( &(gid)->s.guid )
00050 
00051 /** Test for multicast GID */
00052 #define IB_GID_MULTICAST( gid ) ( (gid)->bytes[0] == 0xff )
00053 
00054 /** An Infiniband Local Route Header */
00055 struct ib_local_route_header {
00056         /** Virtual lane and link version */
00057         uint8_t vl__lver;
00058         /** Service level and next link header */
00059         uint8_t sl__lnh;
00060         /** Destination LID */
00061         uint16_t dlid;
00062         /** Packet length */
00063         uint16_t length;
00064         /** Source LID */
00065         uint16_t slid;
00066 } __attribute__ (( packed ));
00067 
00068 /** Infiniband virtual lanes */
00069 enum ib_vl {
00070         IB_VL_DEFAULT = 0,
00071         IB_VL_SMP = 15,
00072 };
00073 
00074 /** An Infiniband Link Next Header value */
00075 enum ib_lnh {
00076         IB_LNH_RAW = 0,
00077         IB_LNH_IPv6 = 1,
00078         IB_LNH_BTH = 2,
00079         IB_LNH_GRH = 3
00080 };
00081 
00082 /** Default Infiniband LID */
00083 #define IB_LID_NONE 0xffff
00084 
00085 /** Test for multicast LID */
00086 #define IB_LID_MULTICAST( lid ) ( ( (lid) >= 0xc000 ) && ( (lid) <= 0xfffe ) )
00087 
00088 /** An Infiniband Global Route Header */
00089 struct ib_global_route_header {
00090         /** IP version, traffic class, and flow label
00091          *
00092          *  4 bits : Version of the GRH
00093          *  8 bits : Traffic class
00094          * 20 bits : Flow label
00095          */
00096         uint32_t ipver__tclass__flowlabel;
00097         /** Payload length */
00098         uint16_t paylen;
00099         /** Next header */
00100         uint8_t nxthdr;
00101         /** Hop limit */
00102         uint8_t hoplmt;
00103         /** Source GID */
00104         union ib_gid sgid;
00105         /** Destiniation GID */
00106         union ib_gid dgid;
00107 } __attribute__ (( packed ));
00108 
00109 #define IB_GRH_IPVER_IPv6 0x06
00110 #define IB_GRH_NXTHDR_IBA 0x1b
00111 
00112 /** An Infiniband Base Transport Header */
00113 struct ib_base_transport_header {
00114         /** Opcode */
00115         uint8_t opcode;
00116         /** Transport header version, pad count, migration and solicitation */
00117         uint8_t se__m__padcnt__tver;
00118         /** Partition key */
00119         uint16_t pkey;
00120         /** Destination queue pair */
00121         uint32_t dest_qp;
00122         /** Packet sequence number and acknowledge request */
00123         uint32_t ack__psn;
00124 } __attribute__ (( packed ));
00125 
00126 /** An Infiniband BTH opcode */
00127 enum ib_bth_opcode {
00128         BTH_OPCODE_UD_SEND = 0x64,
00129 };
00130 
00131 /** An Infiniband Datagram Extended Transport Header */
00132 struct ib_datagram_extended_transport_header {
00133         /** Queue key */
00134         uint32_t qkey;
00135         /** Source queue pair */
00136         uint32_t src_qp;
00137 } __attribute__ (( packed ));
00138 
00139 /** All known IB header formats */
00140 union ib_headers {
00141         struct ib_local_route_header lrh;
00142         struct {
00143                 struct ib_local_route_header lrh;
00144                 struct ib_global_route_header grh;
00145                 struct ib_base_transport_header bth;
00146                 struct ib_datagram_extended_transport_header deth;
00147         } __attribute__ (( packed )) lrh__grh__bth__deth;
00148         struct {
00149                 struct ib_local_route_header lrh;
00150                 struct ib_base_transport_header bth;
00151                 struct ib_datagram_extended_transport_header deth;
00152         } __attribute__ (( packed )) lrh__bth__deth;
00153 } __attribute__ (( packed ));
00154 
00155 /** Maximum size required for IB headers */
00156 #define IB_MAX_HEADER_SIZE sizeof ( union ib_headers )
00157 
00158 extern int ib_push ( struct ib_device *ibdev, struct io_buffer *iobuf,
00159                      struct ib_queue_pair *qp, size_t payload_len,
00160                      const struct ib_address_vector *dest );
00161 extern int ib_pull ( struct ib_device *ibdev, struct io_buffer *iobuf,
00162                      struct ib_queue_pair **qp, size_t *payload_len,
00163                      struct ib_address_vector *dest,
00164                      struct ib_address_vector *source );
00165 
00166 #endif /* _IPXE_IB_PACKET_H */