summaryrefslogtreecommitdiffstats
path: root/src/include/gpxe
diff options
context:
space:
mode:
authorMichael Brown2008-11-07 09:39:40 +0100
committerMichael Brown2008-11-11 06:31:19 +0100
commit9e5fd8ec59cd44dc9ba349d4feee37830fca6a14 (patch)
treee2e7c3583f99c6414e1452171eca19c56ab3e532 /src/include/gpxe
parent[infiniband] Add a standalone subnet management agent (diff)
downloadipxe-9e5fd8ec59cd44dc9ba349d4feee37830fca6a14.tar.gz
ipxe-9e5fd8ec59cd44dc9ba349d4feee37830fca6a14.tar.xz
ipxe-9e5fd8ec59cd44dc9ba349d4feee37830fca6a14.zip
[infiniband] Add raw packet parser and constructor
This can be used with cards that require the driver to construct and parse packet headers manually. Headers are optionally handled out-of-line from the packet payload, since some such cards will split received headers into a separate ring buffer.
Diffstat (limited to 'src/include/gpxe')
-rw-r--r--src/include/gpxe/errfile.h1
-rw-r--r--src/include/gpxe/ib_packet.h35
-rw-r--r--src/include/gpxe/infiniband.h54
3 files changed, 62 insertions, 28 deletions
diff --git a/src/include/gpxe/errfile.h b/src/include/gpxe/errfile.h
index c314ceed8..109e6cd20 100644
--- a/src/include/gpxe/errfile.h
+++ b/src/include/gpxe/errfile.h
@@ -136,6 +136,7 @@
#define ERRFILE_dhcppkt ( ERRFILE_NET | 0x00150000 )
#define ERRFILE_slam ( ERRFILE_NET | 0x00160000 )
#define ERRFILE_ib_sma ( ERRFILE_NET | 0x00170000 )
+#define ERRFILE_ib_packet ( ERRFILE_NET | 0x00180000 )
#define ERRFILE_image ( ERRFILE_IMAGE | 0x00000000 )
#define ERRFILE_elf ( ERRFILE_IMAGE | 0x00010000 )
diff --git a/src/include/gpxe/ib_packet.h b/src/include/gpxe/ib_packet.h
index f9ef2f6ec..5374802c6 100644
--- a/src/include/gpxe/ib_packet.h
+++ b/src/include/gpxe/ib_packet.h
@@ -7,6 +7,11 @@
*
*/
+struct ib_device;
+struct ib_queue_pair;
+struct ib_address_vector;
+struct io_buffer;
+
/** Half of an Infiniband Global Identifier */
struct ib_gid_half {
uint8_t bytes[8];
@@ -53,6 +58,9 @@ enum ib_lnh {
/** Default Infiniband LID */
#define IB_LID_NONE 0xffff
+/** Test for multicast LID */
+#define IB_LID_MULTICAST( lid ) ( ( (lid) >= 0xc000 ) && ( (lid) <= 0xfffe ) )
+
/** An Infiniband Global Route Header */
struct ib_global_route_header {
/** IP version, traffic class, and flow label
@@ -76,7 +84,6 @@ struct ib_global_route_header {
#define IB_GRH_IPVER_IPv6 0x06
#define IB_GRH_NXTHDR_IBA 0x1b
-#define IB_GRH_HOPLMT_MAX 0xff
/** An Infiniband Base Transport Header */
struct ib_base_transport_header {
@@ -111,4 +118,30 @@ struct ib_datagram_extended_transport_header {
uint32_t src_qp;
} __attribute__ (( packed ));
+/** All known IB header formats */
+union ib_headers {
+ struct ib_local_route_header lrh;
+ struct {
+ struct ib_local_route_header lrh;
+ struct ib_global_route_header grh;
+ struct ib_base_transport_header bth;
+ struct ib_datagram_extended_transport_header deth;
+ } __attribute__ (( packed )) lrh__grh__bth__deth;
+ struct {
+ struct ib_local_route_header lrh;
+ struct ib_base_transport_header bth;
+ struct ib_datagram_extended_transport_header deth;
+ } __attribute__ (( packed )) lrh__bth__deth;
+} __attribute__ (( packed ));
+
+/** Maximum size required for IB headers */
+#define IB_MAX_HEADER_SIZE sizeof ( union ib_headers )
+
+extern int ib_push ( struct ib_device *ibdev, struct io_buffer *iobuf,
+ struct ib_queue_pair *qp, size_t payload_len,
+ const struct ib_address_vector *av );
+extern int ib_pull ( struct ib_device *ibdev, struct io_buffer *iobuf,
+ struct ib_queue_pair **qp, size_t *payload_len,
+ struct ib_address_vector *av );
+
#endif /* _GPXE_IB_PACKET_H */
diff --git a/src/include/gpxe/infiniband.h b/src/include/gpxe/infiniband.h
index 2691ffc95..1bb824019 100644
--- a/src/include/gpxe/infiniband.h
+++ b/src/include/gpxe/infiniband.h
@@ -55,8 +55,20 @@ struct ib_work_queue {
void *drv_priv;
};
+/** An Infiniband multicast GID */
+struct ib_multicast_gid {
+ /** List of multicast GIDs on this QP */
+ struct list_head list;
+ /** Multicast GID */
+ struct ib_gid gid;
+};
+
/** An Infiniband Queue Pair */
struct ib_queue_pair {
+ /** Containing Infiniband device */
+ struct ib_device *ibdev;
+ /** List of queue pairs on this Infiniband device */
+ struct list_head list;
/** Queue Pair Number */
unsigned long qpn;
/** Queue key */
@@ -65,6 +77,8 @@ struct ib_queue_pair {
struct ib_work_queue send;
/** Receive queue */
struct ib_work_queue recv;
+ /** List of multicast GIDs */
+ struct list_head mgids;
/** Driver private data */
void *drv_priv;
/** Queue owner private data */
@@ -286,6 +300,8 @@ struct ib_device {
struct list_head list;
/** Underlying device */
struct device *dev;
+ /** List of queue pairs */
+ struct list_head qps;
/** Infiniband operations */
struct ib_device_operations *op;
/** Port number */
@@ -308,6 +324,9 @@ struct ib_device {
/** Partition key */
uint16_t pkey;
+ /** Outbound packet sequence number */
+ uint32_t psn;
+
/** Driver private data */
void *drv_priv;
/** Owner private data */
@@ -327,6 +346,10 @@ extern int ib_modify_qp ( struct ib_device *ibdev, struct ib_queue_pair *qp,
unsigned long mod_list, unsigned long qkey );
extern void ib_destroy_qp ( struct ib_device *ibdev,
struct ib_queue_pair *qp );
+extern struct ib_queue_pair * ib_find_qp_qpn ( struct ib_device *ibdev,
+ unsigned long qpn );
+extern struct ib_queue_pair * ib_find_qp_mgid ( struct ib_device *ibdev,
+ struct ib_gid *gid );
extern struct ib_work_queue * ib_find_wq ( struct ib_completion_queue *cq,
unsigned long qpn, int is_send );
extern int ib_post_send ( struct ib_device *ibdev, struct ib_queue_pair *qp,
@@ -341,6 +364,10 @@ extern void ib_complete_recv ( struct ib_device *ibdev,
struct ib_queue_pair *qp,
struct ib_address_vector *av,
struct io_buffer *iobuf, int rc );
+extern int ib_mcast_attach ( struct ib_device *ibdev, struct ib_queue_pair *qp,
+ struct ib_gid *gid );
+extern void ib_mcast_detach ( struct ib_device *ibdev,
+ struct ib_queue_pair *qp, struct ib_gid *gid );
extern struct ib_device * alloc_ibdev ( size_t priv_size );
extern int register_ibdev ( struct ib_device *ibdev );
extern void unregister_ibdev ( struct ib_device *ibdev );
@@ -395,33 +422,6 @@ ib_link_ok ( struct ib_device *ibdev ) {
}
/**
- * Attach to multicast group
- *
- * @v ibdev Infiniband device
- * @v qp Queue pair
- * @v gid Multicast GID
- * @ret rc Return status code
- */
-static inline __always_inline int
-ib_mcast_attach ( struct ib_device *ibdev, struct ib_queue_pair *qp,
- struct ib_gid *gid ) {
- return ibdev->op->mcast_attach ( ibdev, qp, gid );
-}
-
-/**
- * Detach from multicast group
- *
- * @v ibdev Infiniband device
- * @v qp Queue pair
- * @v gid Multicast GID
- */
-static inline __always_inline void
-ib_mcast_detach ( struct ib_device *ibdev, struct ib_queue_pair *qp,
- struct ib_gid *gid ) {
- ibdev->op->mcast_detach ( ibdev, qp, gid );
-}
-
-/**
* Get reference to Infiniband device
*
* @v ibdev Infiniband device