iPXE
ib_mi.h
Go to the documentation of this file.
00001 #ifndef _IPXE_IB_MI_H
00002 #define _IPXE_IB_MI_H
00003 
00004 /** @file
00005  *
00006  * Infiniband management interfaces
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00011 
00012 #include <ipxe/list.h>
00013 #include <ipxe/retry.h>
00014 #include <ipxe/tables.h>
00015 #include <ipxe/infiniband.h>
00016 
00017 struct ib_mad_interface;
00018 struct ib_mad_transaction;
00019 
00020 /** An Infiniband management agent */
00021 struct ib_mad_agent {
00022         /** Management class */
00023         uint8_t mgmt_class;
00024         /** Class version */
00025         uint8_t class_version;
00026         /** Attribute (in network byte order) */
00027         uint16_t attr_id;
00028         /** Handle MAD
00029          *
00030          * @v ibdev             Infiniband device
00031          * @v mi                Management interface
00032          * @v mad               Received MAD
00033          * @v av                Source address vector
00034          * @ret rc              Return status code
00035          */
00036         void ( * handle ) ( struct ib_device *ibdev,
00037                             struct ib_mad_interface *mi,
00038                             union ib_mad *mad,
00039                             struct ib_address_vector *av );
00040 };
00041 
00042 /** Infiniband management agents */
00043 #define IB_MAD_AGENTS __table ( struct ib_mad_agent, "ib_mad_agents" )
00044 
00045 /** Declare an Infiniband management agent */
00046 #define __ib_mad_agent __table_entry ( IB_MAD_AGENTS, 01 )
00047 
00048 /** Infiniband management transaction operations */
00049 struct ib_mad_transaction_operations {
00050         /** Handle transaction completion
00051          *
00052          * @v ibdev             Infiniband device
00053          * @v mi                Management interface
00054          * @v madx              Management transaction
00055          * @v rc                Status code
00056          * @v mad               Received MAD (or NULL on error)
00057          * @v av                Source address vector (or NULL on error)
00058          *
00059          * The completion handler should in most cases call
00060          * ib_destroy_madx() to free up the completed transaction.
00061          */
00062         void ( * complete ) ( struct ib_device *ibdev,
00063                               struct ib_mad_interface *mi,
00064                               struct ib_mad_transaction *madx,
00065                               int rc, union ib_mad *mad,
00066                               struct ib_address_vector *av );
00067 };
00068 
00069 /** An Infiniband management transaction */
00070 struct ib_mad_transaction {
00071         /** Associated management interface */
00072         struct ib_mad_interface *mi;
00073         /** List of transactions */
00074         struct list_head list;
00075         /** Retry timer */
00076         struct retry_timer timer;
00077         /** Destination address vector */
00078         struct ib_address_vector av;
00079         /** MAD being sent */
00080         union ib_mad mad;
00081         /** Transaction operations */
00082         struct ib_mad_transaction_operations *op;
00083         /** Owner private data */
00084         void *owner_priv;
00085 };
00086 
00087 /** An Infiniband management interface */
00088 struct ib_mad_interface {
00089         /** Infiniband device */
00090         struct ib_device *ibdev;
00091         /** Completion queue */
00092         struct ib_completion_queue *cq;
00093         /** Queue pair */
00094         struct ib_queue_pair *qp;
00095         /** List of management transactions */
00096         struct list_head madx;
00097 };
00098 
00099 /**
00100  * Set Infiniband management transaction owner-private data
00101  *
00102  * @v madx              Management transaction
00103  * @v priv              Private data
00104  */
00105 static inline __always_inline void
00106 ib_madx_set_ownerdata ( struct ib_mad_transaction *madx, void *priv ) {
00107         madx->owner_priv = priv;
00108 }
00109 
00110 /**
00111  * Get Infiniband management transaction owner-private data
00112  *
00113  * @v madx              Management transaction
00114  * @ret priv            Private data
00115  */
00116 static inline __always_inline void *
00117 ib_madx_get_ownerdata ( struct ib_mad_transaction *madx ) {
00118         return madx->owner_priv;
00119 }
00120 
00121 extern int ib_mi_send ( struct ib_device *ibdev, struct ib_mad_interface *mi,
00122                         union ib_mad *mad, struct ib_address_vector *av );
00123 extern struct ib_mad_transaction *
00124 ib_create_madx ( struct ib_device *ibdev, struct ib_mad_interface *mi,
00125                  union ib_mad *mad, struct ib_address_vector *av,
00126                  struct ib_mad_transaction_operations *op );
00127 extern void ib_destroy_madx ( struct ib_device *ibdev,
00128                               struct ib_mad_interface *mi,
00129                               struct ib_mad_transaction *madx );
00130 extern int ib_create_mi ( struct ib_device *ibdev,
00131                           enum ib_queue_pair_type type,
00132                           struct ib_mad_interface **new_mi );
00133 extern void ib_destroy_mi ( struct ib_device *ibdev,
00134                             struct ib_mad_interface *mi );
00135 
00136 #endif /* _IPXE_IB_MI_H */