iPXE
eoib.h
Go to the documentation of this file.
00001 #ifndef _IPXE_EOIB_H
00002 #define _IPXE_EOIB_H
00003 
00004 /** @file
00005  *
00006  * Ethernet over Infiniband
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00011 
00012 #include <stdint.h>
00013 #include <byteswap.h>
00014 #include <ipxe/netdevice.h>
00015 #include <ipxe/infiniband.h>
00016 #include <ipxe/ib_mcast.h>
00017 
00018 /** An EoIB header */
00019 struct eoib_header {
00020         /** Signature */
00021         uint16_t magic;
00022         /** Reserved */
00023         uint16_t reserved;
00024 } __attribute__ (( packed ));
00025 
00026 /** EoIB magic signature */
00027 #define EOIB_MAGIC 0x8919
00028 
00029 /** An EoIB device */
00030 struct eoib_device {
00031         /** Name */
00032         const char *name;
00033         /** Network device */
00034         struct net_device *netdev;
00035         /** Underlying Infiniband device */
00036         struct ib_device *ibdev;
00037         /** List of EoIB devices */
00038         struct list_head list;
00039         /** Broadcast address */
00040         struct ib_address_vector broadcast;
00041 
00042         /** Completion queue */
00043         struct ib_completion_queue *cq;
00044         /** Queue pair */
00045         struct ib_queue_pair *qp;
00046         /** Broadcast group membership */
00047         struct ib_mc_membership membership;
00048 
00049         /** Peer cache */
00050         struct list_head peers;
00051 
00052         /** Send duplicate packet to gateway (or NULL)
00053          *
00054          * @v eoib              EoIB device
00055          * @v original          Original I/O buffer
00056          */
00057         void ( * duplicate ) ( struct eoib_device *eoib,
00058                                struct io_buffer *original );
00059         /** Gateway (if any) */
00060         struct ib_address_vector gateway;
00061         /** Multicast group additional component mask */
00062         unsigned int mask;
00063 };
00064 
00065 /**
00066  * Check if EoIB device uses a gateway
00067  *
00068  * @v eoib              EoIB device
00069  * @v has_gw            EoIB device uses a gateway
00070  */
00071 static inline int eoib_has_gateway ( struct eoib_device *eoib ) {
00072 
00073         return ( eoib->duplicate != NULL );
00074 }
00075 
00076 /**
00077  * Force creation of multicast group
00078  *
00079  * @v eoib              EoIB device
00080  */
00081 static inline void eoib_force_group_creation ( struct eoib_device *eoib ) {
00082 
00083         /* Some dubious EoIB implementations require each endpoint to
00084          * force the creation of the multicast group.  Yes, this makes
00085          * it impossible for the group parameters (e.g. SL) to ever be
00086          * modified without breaking backwards compatiblity with every
00087          * existing driver.
00088          */
00089         eoib->mask = ( IB_SA_MCMEMBER_REC_PKEY | IB_SA_MCMEMBER_REC_QKEY |
00090                        IB_SA_MCMEMBER_REC_SL | IB_SA_MCMEMBER_REC_FLOW_LABEL |
00091                        IB_SA_MCMEMBER_REC_TRAFFIC_CLASS );
00092 }
00093 
00094 extern int eoib_create ( struct ib_device *ibdev, const uint8_t *hw_addr,
00095                          struct ib_address_vector *broadcast,
00096                          const char *name );
00097 extern struct eoib_device * eoib_find ( struct ib_device *ibdev,
00098                                         const uint8_t *hw_addr );
00099 extern void eoib_destroy ( struct eoib_device *eoib );
00100 extern void eoib_set_gateway ( struct eoib_device *eoib,
00101                                struct ib_address_vector *av );
00102 
00103 #endif /* _IPXE_EOIB_H */