diff options
author | Michael Brown | 2007-09-17 06:04:58 +0200 |
---|---|---|
committer | Michael Brown | 2007-09-17 06:04:58 +0200 |
commit | 4e78a53cf26b85736123eee29d23d637b4a3883f (patch) | |
tree | 319b933d03e9095460ff53ee22e5619f93f81a70 /src/include | |
parent | Read port GID directly using MAD IFC. (diff) | |
download | ipxe-4e78a53cf26b85736123eee29d23d637b4a3883f.tar.gz ipxe-4e78a53cf26b85736123eee29d23d637b4a3883f.tar.xz ipxe-4e78a53cf26b85736123eee29d23d637b4a3883f.zip |
IPoIB code separated out to ipoib.c.
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/gpxe/errfile.h | 2 | ||||
-rw-r--r-- | src/include/gpxe/infiniband.h | 149 | ||||
-rw-r--r-- | src/include/gpxe/ipoib.h | 78 |
3 files changed, 194 insertions, 35 deletions
diff --git a/src/include/gpxe/errfile.h b/src/include/gpxe/errfile.h index 3413f9cf..325d2387 100644 --- a/src/include/gpxe/errfile.h +++ b/src/include/gpxe/errfile.h @@ -101,6 +101,8 @@ #define ERRFILE_via_rhine ( ERRFILE_DRIVER | 0x00440000 ) #define ERRFILE_via_velocity ( ERRFILE_DRIVER | 0x00450000 ) #define ERRFILE_w89c840 ( ERRFILE_DRIVER | 0x00460000 ) +#define ERRFILE_ipoib ( ERRFILE_DRIVER | 0x00470000 ) +#define ERRFILE_mt25218 ( ERRFILE_DRIVER | 0x00480000 ) #define ERRFILE_scsi ( ERRFILE_DRIVER | 0x00700000 ) diff --git a/src/include/gpxe/infiniband.h b/src/include/gpxe/infiniband.h index 3f09808c..e9e0121d 100644 --- a/src/include/gpxe/infiniband.h +++ b/src/include/gpxe/infiniband.h @@ -8,34 +8,11 @@ */ #include <stdint.h> -#include <gpxe/netdevice.h> +#include <gpxe/device.h> -/** An Infiniband Global Identifier */ -struct ib_gid { - uint8_t bytes[16]; -}; -/** An Infiniband Global Route Header */ -struct ib_global_route_header { - /** IP version, traffic class, and flow label - * - * 4 bits : Version of the GRH - * 8 bits : Traffic class - * 20 bits : Flow label - */ - uint32_t ipver_tclass_flowlabel; - /** Payload length */ - uint16_t paylen; - /** Next header */ - uint8_t nxthdr; - /** Hop limit */ - uint8_t hoplmt; - /** Source GID */ - struct ib_gid sgid; - /** Destiniation GID */ - struct ib_gid dgid; -} __attribute__ (( packed )); +#if 0 /** Infiniband MAC address length */ #define IB_ALEN 20 @@ -60,9 +37,41 @@ struct ibhdr { /** Reserved, must be zero */ uint16_t reserved; } __attribute__ (( packed )); +#endif + + + + + +/** An Infiniband Global Identifier */ +struct ib_gid { + uint8_t bytes[16]; +}; + +/** An Infiniband Global Route Header */ +struct ib_global_route_header { + /** IP version, traffic class, and flow label + * + * 4 bits : Version of the GRH + * 8 bits : Traffic class + * 20 bits : Flow label + */ + uint32_t ipver_tclass_flowlabel; + /** Payload length */ + uint16_t paylen; + /** Next header */ + uint8_t nxthdr; + /** Hop limit */ + uint8_t hoplmt; + /** Source GID */ + struct ib_gid sgid; + /** Destiniation GID */ + struct ib_gid dgid; +} __attribute__ (( packed )); + struct ib_device; struct ib_queue_pair; struct ib_completion_queue; @@ -223,8 +232,7 @@ struct ib_device_operations { struct ib_queue_pair *qp, struct ib_address_vector *av, struct io_buffer *iobuf ); - /** - * Post receive work queue entry + /** Post receive work queue entry * * @v ibdev Infiniband device * @v qp Queue pair @@ -252,8 +260,7 @@ struct ib_device_operations { struct ib_completion_queue *cq, ib_completer_t complete_send, ib_completer_t complete_recv ); - /** - * Attach to multicast group + /** Attach to multicast group * * @v ibdev Infiniband device * @v qp Queue pair @@ -263,8 +270,7 @@ struct ib_device_operations { int ( * mcast_attach ) ( struct ib_device *ibdev, struct ib_queue_pair *qp, struct ib_gid *gid ); - /** - * Detach from multicast group + /** Detach from multicast group * * @v ibdev Infiniband device * @v qp Queue pair @@ -276,13 +282,19 @@ struct ib_device_operations { }; /** An Infiniband device */ -struct ib_device { +struct ib_device { /** Port GID */ struct ib_gid port_gid; + /** Broadcast GID */ + struct ib_gid broadcast_gid; + /** Underlying device */ + struct device *dev; /** Infiniband operations */ struct ib_device_operations *op; /** Device private data */ void *dev_priv; + /** Owner private data */ + void *owner_priv; }; extern struct ib_completion_queue * ib_create_cq ( struct ib_device *ibdev, @@ -297,6 +309,52 @@ extern void ib_destroy_qp ( struct ib_device *ibdev, struct ib_queue_pair *qp ); extern struct ib_work_queue * ib_find_wq ( struct ib_completion_queue *cq, unsigned long qpn, int is_send ); +extern struct ib_device * alloc_ibdev ( size_t priv_size ); +extern void free_ibdev ( struct ib_device *ibdev ); + +/** + * Post send work queue entry + * + * @v ibdev Infiniband device + * @v qp Queue pair + * @v av Address vector + * @v iobuf I/O buffer + * @ret rc Return status code + */ +static inline __attribute__ (( always_inline )) int +ib_post_send ( struct ib_device *ibdev, struct ib_queue_pair *qp, + struct ib_address_vector *av, struct io_buffer *iobuf ) { + return ibdev->op->post_send ( ibdev, qp, av, iobuf ); +} + +/** + * Post receive work queue entry + * + * @v ibdev Infiniband device + * @v qp Queue pair + * @v iobuf I/O buffer + * @ret rc Return status code + */ +static inline __attribute__ (( always_inline )) int +ib_post_recv ( struct ib_device *ibdev, struct ib_queue_pair *qp, + struct io_buffer *iobuf ) { + return ibdev->op->post_recv ( ibdev, qp, iobuf ); +} + +/** + * Poll completion queue + * + * @v ibdev Infiniband device + * @v cq Completion queue + * @v complete_send Send completion handler + * @v complete_recv Receive completion handler + */ +static inline __attribute__ (( always_inline )) void +ib_poll_cq ( struct ib_device *ibdev, struct ib_completion_queue *cq, + ib_completer_t complete_send, ib_completer_t complete_recv ) { + ibdev->op->poll_cq ( ibdev, cq, complete_send, complete_recv ); +} + /** * Attach to multicast group @@ -325,6 +383,27 @@ ib_mcast_detach ( struct ib_device *ibdev, struct ib_queue_pair *qp, ibdev->op->mcast_detach ( ibdev, qp, gid ); } +/** + * Set Infiniband owner-private data + * + * @v pci Infiniband device + * @v priv Private data + */ +static inline void ib_set_ownerdata ( struct ib_device *ibdev, + void *owner_priv ) { + ibdev->owner_priv = owner_priv; +} + +/** + * Get Infiniband owner-private data + * + * @v pci Infiniband device + * @ret priv Private data + */ +static inline void * ib_get_ownerdata ( struct ib_device *ibdev ) { + return ibdev->owner_priv; +} + /***************************************************************************** * * Management datagrams @@ -435,9 +514,7 @@ union ib_mad { - - - +#if 0 extern struct ll_protocol infiniband_protocol; @@ -459,4 +536,6 @@ static inline struct net_device * alloc_ibdev ( size_t priv_size ) { return netdev; } +#endif + #endif /* _GPXE_INFINIBAND_H */ diff --git a/src/include/gpxe/ipoib.h b/src/include/gpxe/ipoib.h new file mode 100644 index 00000000..0551687d --- /dev/null +++ b/src/include/gpxe/ipoib.h @@ -0,0 +1,78 @@ +#ifndef _GPXE_IPOIB_H +#define _GPXE_IPOIB_H + +/** @file + * + * IP over Infiniband + */ + +#include <gpxe/infiniband.h> + +/** IPoIB MAC address length */ +#define IPOIB_ALEN 20 + +/** An IPoIB MAC address */ +struct ipoib_mac { + /** Queue pair number + * + * MSB must be zero; QPNs are only 24-bit. + */ + uint32_t qpn; + /** Port GID */ + struct ib_gid gid; +} __attribute__ (( packed )); + +/** IPoIB link-layer header length */ +#define IPOIB_HLEN 24 + +/** + * IPoIB link-layer header pseudo portion + * + * This part doesn't actually exist on the wire, but it provides a + * convenient way to fit into the typical network device model. + */ +struct ipoib_pseudo_hdr { + /** Peer address */ + struct ipoib_mac peer; +} __attribute__ (( packed )); + +/** IPoIB link-layer header real portion */ +struct ipoib_real_hdr { + /** Network-layer protocol */ + uint16_t proto; + /** Reserved, must be zero */ + uint16_t reserved; +} __attribute__ (( packed )); + +/** An IPoIB link-layer header */ +struct ipoib_hdr { + /** Pseudo portion */ + struct ipoib_pseudo_hdr pseudo; + /** Real portion */ + struct ipoib_real_hdr real; +} __attribute__ (( packed )); + +extern struct ll_protocol ipoib_protocol; + +extern const char * ipoib_ntoa ( const void *ll_addr ); + +/** + * Allocate IPoIB device + * + * @v priv_size Size of driver private data + * @ret netdev Network device, or NULL + */ +static inline struct net_device * alloc_ipoibdev ( size_t priv_size ) { + struct net_device *netdev; + + netdev = alloc_netdev ( priv_size ); + if ( netdev ) { + netdev->ll_protocol = &ipoib_protocol; + } + return netdev; +} + +extern int ipoib_probe ( struct ib_device *ibdev ); +extern void ipoib_remove ( struct ib_device *ibdev ); + +#endif /* _GPXE_IPOIB_H */ |