• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _GPXE_IB_MI_H
2 #define _GPXE_IB_MI_H
3 
4 /** @file
5  *
6  * Infiniband management interfaces
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER );
11 
12 #include <gpxe/list.h>
13 #include <gpxe/retry.h>
14 #include <gpxe/tables.h>
15 #include <gpxe/infiniband.h>
16 
17 struct ib_mad_interface;
18 struct ib_mad_transaction;
19 
20 /** An Infiniband management agent */
21 struct ib_mad_agent {
22 	/** Management class */
23 	uint8_t mgmt_class;
24 	/** Class version */
25 	uint8_t class_version;
26 	/** Attribute (in network byte order) */
27 	uint16_t attr_id;
28 	/** Handle MAD
29 	 *
30 	 * @v ibdev		Infiniband device
31 	 * @v mi		Management interface
32 	 * @v mad		Received MAD
33 	 * @v av		Source address vector
34 	 * @ret rc		Return status code
35 	 */
36 	void ( * handle ) ( struct ib_device *ibdev,
37 			    struct ib_mad_interface *mi,
38 			    union ib_mad *mad,
39 			    struct ib_address_vector *av );
40 };
41 
42 /** Infiniband management agents */
43 #define IB_MAD_AGENTS __table ( struct ib_mad_agent, "ib_mad_agents" )
44 
45 /** Declare an Infiniband management agent */
46 #define __ib_mad_agent __table_entry ( IB_MAD_AGENTS, 01 )
47 
48 /** Infiniband management transaction operations */
49 struct ib_mad_transaction_operations {
50 	/** Handle transaction completion
51 	 *
52 	 * @v ibdev		Infiniband device
53 	 * @v mi		Management interface
54 	 * @v madx		Management transaction
55 	 * @v rc		Status code
56 	 * @v mad		Received MAD (or NULL on error)
57 	 * @v av		Source address vector (or NULL on error)
58 	 *
59 	 * The completion handler should in most cases call
60 	 * ib_destroy_madx() to free up the completed transaction.
61 	 */
62 	void ( * complete ) ( struct ib_device *ibdev,
63 			      struct ib_mad_interface *mi,
64 			      struct ib_mad_transaction *madx,
65 			      int rc, union ib_mad *mad,
66 			      struct ib_address_vector *av );
67 };
68 
69 /** An Infiniband management transaction */
70 struct ib_mad_transaction {
71 	/** Associated management interface */
72 	struct ib_mad_interface *mi;
73 	/** List of transactions */
74 	struct list_head list;
75 	/** Retry timer */
76 	struct retry_timer timer;
77 	/** Destination address vector */
78 	struct ib_address_vector av;
79 	/** MAD being sent */
80 	union ib_mad mad;
81 	/** Transaction operations */
82 	struct ib_mad_transaction_operations *op;
83 	/** Owner private data */
84 	void *owner_priv;
85 };
86 
87 /** An Infiniband management interface */
88 struct ib_mad_interface {
89 	/** Infiniband device */
90 	struct ib_device *ibdev;
91 	/** Completion queue */
92 	struct ib_completion_queue *cq;
93 	/** Queue pair */
94 	struct ib_queue_pair *qp;
95 	/** List of management transactions */
96 	struct list_head madx;
97 };
98 
99 /**
100  * Set Infiniband management transaction owner-private data
101  *
102  * @v madx		Management transaction
103  * @v priv		Private data
104  */
105 static inline __always_inline void
ib_madx_set_ownerdata(struct ib_mad_transaction * madx,void * priv)106 ib_madx_set_ownerdata ( struct ib_mad_transaction *madx, void *priv ) {
107 	madx->owner_priv = priv;
108 }
109 
110 /**
111  * Get Infiniband management transaction owner-private data
112  *
113  * @v madx		Management transaction
114  * @ret priv		Private data
115  */
116 static inline __always_inline void *
ib_madx_get_ownerdata(struct ib_mad_transaction * madx)117 ib_madx_get_ownerdata ( struct ib_mad_transaction *madx ) {
118 	return madx->owner_priv;
119 }
120 
121 extern int ib_mi_send ( struct ib_device *ibdev, struct ib_mad_interface *mi,
122 			union ib_mad *mad, struct ib_address_vector *av );
123 extern struct ib_mad_transaction *
124 ib_create_madx ( struct ib_device *ibdev, struct ib_mad_interface *mi,
125 		 union ib_mad *mad, struct ib_address_vector *av,
126 		 struct ib_mad_transaction_operations *op );
127 extern void ib_destroy_madx ( struct ib_device *ibdev,
128 			      struct ib_mad_interface *mi,
129 			      struct ib_mad_transaction *madx );
130 extern struct ib_mad_interface * ib_create_mi ( struct ib_device *ibdev,
131 						enum ib_queue_pair_type type );
132 extern void ib_destroy_mi ( struct ib_device *ibdev,
133 			    struct ib_mad_interface *mi );
134 
135 #endif /* _GPXE_IB_MI_H */
136