iPXE
Data Structures | Functions | Variables
ib_pathrec.h File Reference

Infiniband path records. More...

#include <ipxe/infiniband.h>

Go to the source code of this file.

Data Structures

struct  ib_path_operations
 Infiniband path operations. More...
struct  ib_path
 An Infiniband path. More...

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
static __always_inline void ib_path_set_ownerdata (struct ib_path *path, void *priv)
 Set Infiniband path owner-private data.
static __always_inline void * ib_path_get_ownerdata (struct ib_path *path)
 Get Infiniband path owner-private data.
struct ib_pathib_create_path (struct ib_device *ibdev, struct ib_address_vector *av, struct ib_path_operations *op)
 Create path.
void ib_destroy_path (struct ib_device *ibdev, struct ib_path *path)
 Destroy path.
int ib_resolve_path (struct ib_device *ibdev, struct ib_address_vector *av)
 Resolve path.

Variables

struct ib_path_operations __attribute__

Detailed Description

Infiniband path records.

Definition in file ib_pathrec.h.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
static __always_inline void ib_path_set_ownerdata ( struct ib_path path,
void *  priv 
) [inline, static]

Set Infiniband path owner-private data.

Parameters:
pathPath
privPrivate data

Definition at line 52 of file ib_pathrec.h.

References ib_path::owner_priv, and priv.

Referenced by ib_create_conn(), and ib_resolve_path().

                                                           {
        path->owner_priv = priv;
}
static __always_inline void* ib_path_get_ownerdata ( struct ib_path path) [inline, static]

Get Infiniband path owner-private data.

Parameters:
pathPath
Return values:
privPrivate data

Definition at line 63 of file ib_pathrec.h.

References ib_path::owner_priv.

Referenced by ib_cached_path_complete(), and ib_cm_path_complete().

                                               {
        return path->owner_priv;
}
struct ib_path* ib_create_path ( struct ib_device ibdev,
struct ib_address_vector av,
struct ib_path_operations op 
) [read]

Create path.

Parameters:
ibdevInfiniband device
avAddress vector to complete
opPath operations
Return values:
pathPath

Definition at line 107 of file ib_pathrec.c.

References ib_mad_hdr::attr_id, ib_path::av, ib_mad_hdr::class_version, ib_sa_hdr::comp_mask, ib_path_record::dgid, free, ib_address_vector::gid, ib_device::gid, ib_device::gsi, htonl, htons, ib_create_madx(), ib_destroy_madx(), ib_madx_set_ownerdata(), IB_MGMT_CLASS_SUBN_ADM, IB_MGMT_METHOD_GET, IB_SA_ATTR_PATH_REC, IB_SA_CLASS_VERSION, IB_SA_PATH_REC_DGID, IB_SA_PATH_REC_SGID, ib_path::ibdev, ib_mad_sa::mad_hdr, ib_path::madx, memcpy(), memset(), ib_mad_hdr::method, ib_mad_hdr::mgmt_class, NULL, ib_path::op, op, ib_sa_data::path_record, sa, ib_mad::sa, ib_mad_sa::sa_data, ib_mad_sa::sa_hdr, ib_path_record::sgid, and zalloc().

Referenced by ib_create_conn(), and ib_resolve_path().

                                                 {
        struct ib_path *path;
        union ib_mad mad;
        struct ib_mad_sa *sa = &mad.sa;

        /* Allocate and initialise structure */
        path = zalloc ( sizeof ( *path ) );
        if ( ! path )
                goto err_alloc_path;
        path->ibdev = ibdev;
        memcpy ( &path->av, av, sizeof ( path->av ) );
        path->op = op;

        /* Construct path request */
        memset ( sa, 0, sizeof ( *sa ) );
        sa->mad_hdr.mgmt_class = IB_MGMT_CLASS_SUBN_ADM;
        sa->mad_hdr.class_version = IB_SA_CLASS_VERSION;
        sa->mad_hdr.method = IB_MGMT_METHOD_GET;
        sa->mad_hdr.attr_id = htons ( IB_SA_ATTR_PATH_REC );
        sa->sa_hdr.comp_mask[1] =
                htonl ( IB_SA_PATH_REC_DGID | IB_SA_PATH_REC_SGID );
        memcpy ( &sa->sa_data.path_record.dgid, &path->av.gid,
                 sizeof ( sa->sa_data.path_record.dgid ) );
        memcpy ( &sa->sa_data.path_record.sgid, &ibdev->gid,
                 sizeof ( sa->sa_data.path_record.sgid ) );

        /* Create management transaction */
        path->madx = ib_create_madx ( ibdev, ibdev->gsi, &mad, NULL,
                                      &ib_path_op );
        if ( ! path->madx )
                goto err_create_madx;
        ib_madx_set_ownerdata ( path->madx, path );

        return path;

        ib_destroy_madx ( ibdev, ibdev->gsi, path->madx );
 err_create_madx:
        free ( path );
 err_alloc_path:
        return NULL;
}
void ib_destroy_path ( struct ib_device ibdev,
struct ib_path path 
)

Destroy path.

Parameters:
ibdevInfiniband device
pathPath

Definition at line 156 of file ib_pathrec.c.

References free, ib_device::gsi, ib_destroy_madx(), and ib_path::madx.

Referenced by ib_cached_path_complete(), ib_cm_path_complete(), ib_create_conn(), ib_destroy_conn(), and ib_resolve_path().

                                                                       {

        if ( path->madx )
                ib_destroy_madx ( ibdev, ibdev->gsi, path->madx );
        free ( path );
}
int ib_resolve_path ( struct ib_device ibdev,
struct ib_address_vector av 
)

Resolve path.

Parameters:
ibdevInfiniband device
avAddress vector to complete
Return values:
rcReturn status code

This provides a non-transactional way to resolve a path, via a cache similar to ARP.

Definition at line 249 of file ib_pathrec.c.

References ib_path::av, DBGC, DBGC2, ENOENT, ENOMEM, ib_address_vector::gid, gid, ib_address_vector::gid_present, ib_create_path(), ib_destroy_path(), ib_find_path_cache_entry(), IB_GID_ARGS, IB_GID_FMT, IB_NUM_CACHED_PATHS, ib_path_cache, ib_path_cache_idx, ib_path_set_ownerdata(), ib_address_vector::lid, memset(), ib_device::name, ib_cached_path::path, ib_address_vector::rate, and ib_address_vector::sl.

Referenced by eoib_duplicate(), eoib_tx_av(), and ipoib_transmit().

                                                                              {
        union ib_gid *gid = &av->gid;
        struct ib_cached_path *cached;
        unsigned int cache_idx;

        /* Look in cache for a matching entry */
        cached = ib_find_path_cache_entry ( ibdev, gid );
        if ( cached && cached->path->av.lid ) {
                /* Populated entry found */
                av->lid = cached->path->av.lid;
                av->rate = cached->path->av.rate;
                av->sl = cached->path->av.sl;
                av->gid_present = cached->path->av.gid_present;
                DBGC2 ( ibdev, "IBDEV %s cache hit for " IB_GID_FMT "\n",
                        ibdev->name, IB_GID_ARGS ( gid ) );
                return 0;
        }
        DBGC ( ibdev, "IBDEV %s cache miss for " IB_GID_FMT "%s\n", ibdev->name,
               IB_GID_ARGS ( gid ), ( cached ? " (in progress)" : "" ) );

        /* If lookup is already in progress, do nothing */
        if ( cached )
                return -ENOENT;

        /* Locate a new cache entry to use */
        cache_idx = ( (ib_path_cache_idx++) % IB_NUM_CACHED_PATHS );
        cached = &ib_path_cache[cache_idx];

        /* Destroy the old cache entry */
        if ( cached->path )
                ib_destroy_path ( ibdev, cached->path );
        memset ( cached, 0, sizeof ( *cached ) );

        /* Create new path */
        cached->path = ib_create_path ( ibdev, av, &ib_cached_path_op );
        if ( ! cached->path ) {
                DBGC ( ibdev, "IBDEV %s could not create path\n",
                       ibdev->name );
                return -ENOMEM;
        }
        ib_path_set_ownerdata ( cached->path, cached );

        /* Not found yet */
        return -ENOENT;
}

Variable Documentation