Skip to content

Commit

Permalink
[infiniband] Always create an SMA and a GMA
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Brown committed Jul 17, 2009
1 parent 80c41b9 commit 92cf240
Show file tree
Hide file tree
Showing 9 changed files with 299 additions and 390 deletions.
13 changes: 0 additions & 13 deletions src/drivers/infiniband/linda.c
Expand Up @@ -30,7 +30,6 @@ FILE_LICENCE ( GPL2_OR_LATER );
#include <gpxe/bitbash.h>
#include <gpxe/malloc.h>
#include <gpxe/iobuf.h>
#include <gpxe/ib_sma.h>
#include "linda.h"

/**
Expand Down Expand Up @@ -97,9 +96,6 @@ struct linda {
struct i2c_bit_basher i2c;
/** I2C serial EEPROM */
struct i2c_device eeprom;

/** Subnet management agent */
struct ib_sma sma;
};

/***************************************************************************
Expand Down Expand Up @@ -2335,12 +2331,6 @@ static int linda_probe ( struct pci_device *pci,
if ( ( rc = linda_init_ib_serdes ( linda ) ) != 0 )
goto err_init_ib_serdes;

/* Create the SMA */
if ( ( rc = ib_create_sma ( &linda->sma, ibdev ) ) != 0 )
goto err_create_sma;
/* If the SMA doesn't get context 0, we're screwed */
assert ( linda_qpn_to_ctx ( linda->sma.gma.qp->qpn ) == 0 );

/* Register Infiniband device */
if ( ( rc = register_ibdev ( ibdev ) ) != 0 ) {
DBGC ( linda, "Linda %p could not register IB "
Expand All @@ -2352,8 +2342,6 @@ static int linda_probe ( struct pci_device *pci,

unregister_ibdev ( ibdev );
err_register_ibdev:
ib_destroy_sma ( &linda->sma );
err_create_sma:
linda_fini_recv ( linda );
err_init_recv:
linda_fini_send ( linda );
Expand All @@ -2376,7 +2364,6 @@ static void linda_remove ( struct pci_device *pci ) {
struct linda *linda = ib_get_drvdata ( ibdev );

unregister_ibdev ( ibdev );
ib_destroy_sma ( &linda->sma );
linda_fini_recv ( linda );
linda_fini_send ( linda );
ibdev_put ( ibdev );
Expand Down
10 changes: 3 additions & 7 deletions src/include/gpxe/ib_gma.h
Expand Up @@ -12,13 +12,9 @@ FILE_LICENCE ( GPL2_OR_LATER );
#include <gpxe/list.h>
#include <gpxe/retry.h>
#include <gpxe/tables.h>
#include <gpxe/infiniband.h>

struct ib_device;
struct ib_completion_queue;
struct ib_queue_pair;
union ib_mad;
struct ib_gma;
enum ib_queue_pair_type;

/** A GMA attribute handler */
struct ib_gma_handler {
Expand Down Expand Up @@ -68,8 +64,8 @@ struct ib_gma {

extern int ib_gma_request ( struct ib_gma *gma, union ib_mad *mad,
struct ib_address_vector *av, int retry );
extern int ib_create_gma ( struct ib_gma *gma, struct ib_device *ibdev,
enum ib_queue_pair_type type );
extern struct ib_gma * ib_create_gma ( struct ib_device *ibdev,
enum ib_queue_pair_type type );
extern void ib_destroy_gma ( struct ib_gma *gma );

#endif /* _GPXE_IB_GMA_H */
24 changes: 0 additions & 24 deletions src/include/gpxe/ib_sma.h

This file was deleted.

6 changes: 4 additions & 2 deletions src/include/gpxe/infiniband.h
Expand Up @@ -14,7 +14,6 @@ FILE_LICENCE ( GPL2_OR_LATER );
#include <gpxe/device.h>
#include <gpxe/ib_packet.h>
#include <gpxe/ib_mad.h>
#include <gpxe/ib_gma.h>

/** Subnet management QPN */
#define IB_QPN_SMA 0
Expand Down Expand Up @@ -46,6 +45,7 @@ struct ib_device;
struct ib_queue_pair;
struct ib_address_vector;
struct ib_completion_queue;
struct ib_gma;

/** An Infiniband Work Queue */
struct ib_work_queue {
Expand Down Expand Up @@ -387,8 +387,10 @@ struct ib_device {
/** Outbound packet sequence number */
uint32_t psn;

/** Subnet management agent */
struct ib_gma *sma;
/** General management agent */
struct ib_gma gma;
struct ib_gma *gma;

/** Driver private data */
void *drv_priv;
Expand Down
33 changes: 23 additions & 10 deletions src/net/infiniband.c
Expand Up @@ -33,6 +33,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
#include <gpxe/ipoib.h>
#include <gpxe/process.h>
#include <gpxe/infiniband.h>
#include <gpxe/ib_gma.h>

/** @file
*
Expand Down Expand Up @@ -510,27 +511,38 @@ int ib_open ( struct ib_device *ibdev ) {
return 0;
}

/* Create subnet management agent */
ibdev->sma = ib_create_gma ( ibdev, IB_QPT_SMA );
if ( ! ibdev->sma ) {
DBGC ( ibdev, "IBDEV %p could not create SMA\n", ibdev );
rc = -ENOMEM;
goto err_create_sma;
}

/* Create general management agent */
ibdev->gma = ib_create_gma ( ibdev, IB_QPT_GMA );
if ( ! ibdev->gma ) {
DBGC ( ibdev, "IBDEV %p could not create GMA\n", ibdev );
rc = -ENOMEM;
goto err_create_gma;
}

/* Open device */
if ( ( rc = ibdev->op->open ( ibdev ) ) != 0 ) {
DBGC ( ibdev, "IBDEV %p could not open: %s\n",
ibdev, strerror ( rc ) );
goto err_open;
}

/* Create general management agent */
if ( ( rc = ib_create_gma ( &ibdev->gma, ibdev, IB_QPT_GMA ) ) != 0 ) {
DBGC ( ibdev, "IBDEV %p could not create GMA: %s\n",
ibdev, strerror ( rc ) );
goto err_create_gma;
}

assert ( ibdev->open_count == 1 );
return 0;

ib_destroy_gma ( &ibdev->gma );
err_create_gma:
ibdev->op->close ( ibdev );
err_open:
ib_destroy_gma ( ibdev->gma );
err_create_gma:
ib_destroy_gma ( ibdev->sma );
err_create_sma:
assert ( ibdev->open_count == 1 );
ibdev->open_count = 0;
return rc;
Expand All @@ -548,7 +560,8 @@ void ib_close ( struct ib_device *ibdev ) {

/* Close device if this was the last remaining requested opening */
if ( ibdev->open_count == 0 ) {
ib_destroy_gma ( &ibdev->gma );
ib_destroy_gma ( ibdev->gma );
ib_destroy_gma ( ibdev->sma );
ibdev->op->close ( ibdev );
}
}
Expand Down

0 comments on commit 92cf240

Please sign in to comment.