ib_pathrec.h File Reference

Infiniband path records. More...

#include <gpxe/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)
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.


Detailed Description

Infiniband path records.

Definition in file ib_pathrec.h.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER   ) 

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

Set Infiniband path owner-private data.

Parameters:
path Path
priv Private data

Definition at line 52 of file ib_pathrec.h.

References ib_path::owner_priv.

Referenced by ib_create_conn(), and ib_resolve_path().

00052                                                            {
00053         path->owner_priv = priv;
00054 }

static __always_inline void* ib_path_get_ownerdata ( struct ib_path path  )  [inline, static]

Get Infiniband path owner-private data.

Parameters:
path Path
Return values:
priv Private 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().

00063                                                {
00064         return path->owner_priv;
00065 }

struct ib_path* ib_create_path ( struct ib_device ibdev,
struct ib_address_vector av,
struct ib_path_operations op 
) [read]

Create path.

Parameters:
ibdev Infiniband device
av Address vector to complete
op Path operations
Return values:
path Path

Definition at line 100 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_device::gid, ib_address_vector::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, ib_sa_data::path_record, 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().

00101                                                  {
00102         struct ib_path *path;
00103         union ib_mad mad;
00104         struct ib_mad_sa *sa = &mad.sa;
00105 
00106         /* Allocate and initialise structure */
00107         path = zalloc ( sizeof ( *path ) );
00108         if ( ! path )
00109                 goto err_alloc_path;
00110         path->ibdev = ibdev;
00111         memcpy ( &path->av, av, sizeof ( path->av ) );
00112         path->op = op;
00113 
00114         /* Construct path request */
00115         memset ( sa, 0, sizeof ( *sa ) );
00116         sa->mad_hdr.mgmt_class = IB_MGMT_CLASS_SUBN_ADM;
00117         sa->mad_hdr.class_version = IB_SA_CLASS_VERSION;
00118         sa->mad_hdr.method = IB_MGMT_METHOD_GET;
00119         sa->mad_hdr.attr_id = htons ( IB_SA_ATTR_PATH_REC );
00120         sa->sa_hdr.comp_mask[1] =
00121                 htonl ( IB_SA_PATH_REC_DGID | IB_SA_PATH_REC_SGID );
00122         memcpy ( &sa->sa_data.path_record.dgid, &path->av.gid,
00123                  sizeof ( sa->sa_data.path_record.dgid ) );
00124         memcpy ( &sa->sa_data.path_record.sgid, &ibdev->gid,
00125                  sizeof ( sa->sa_data.path_record.sgid ) );
00126 
00127         /* Create management transaction */
00128         path->madx = ib_create_madx ( ibdev, ibdev->gsi, &mad, NULL,
00129                                       &ib_path_op );
00130         if ( ! path->madx )
00131                 goto err_create_madx;
00132         ib_madx_set_ownerdata ( path->madx, path );
00133 
00134         return path;
00135 
00136         ib_destroy_madx ( ibdev, ibdev->gsi, path->madx );
00137  err_create_madx:
00138         free ( path );
00139  err_alloc_path:
00140         return NULL;
00141 }

void ib_destroy_path ( struct ib_device ibdev,
struct ib_path path 
)

Destroy path.

Parameters:
ibdev Infiniband device
path Path

Definition at line 149 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().

00149                                                                        {
00150 
00151         if ( path->madx )
00152                 ib_destroy_madx ( ibdev, ibdev->gsi, path->madx );
00153         free ( path );
00154 }

int ib_resolve_path ( struct ib_device ibdev,
struct ib_address_vector av 
)

Resolve path.

Parameters:
ibdev Infiniband device
av Address vector to complete
Return values:
rc Return status code
This provides a non-transactional way to resolve a path, via a cache similar to ARP.

Definition at line 242 of file ib_pathrec.c.

References ib_path::av, DBGC, DBGC2, ib_gid::dwords, EINVAL, ENOENT, ENOMEM, ib_address_vector::gid, ib_address_vector::gid_present, htonl, ib_create_path(), ib_destroy_path(), ib_find_path_cache_entry(), IB_NUM_CACHED_PATHS, ib_path_cache, ib_path_cache_idx, ib_path_set_ownerdata(), ib_address_vector::lid, memset(), ib_cached_path::path, ib_address_vector::rate, ib_address_vector::sl, and ib_gid::u.

Referenced by ipoib_transmit().

00242                                                                               {
00243         struct ib_gid *gid = &av->gid;
00244         struct ib_cached_path *cached;
00245         unsigned int cache_idx;
00246 
00247         /* Sanity check */
00248         if ( ! av->gid_present ) {
00249                 DBGC ( ibdev, "IBDEV %p attempt to look up path "
00250                        "without GID\n", ibdev );
00251                 return -EINVAL;
00252         }
00253 
00254         /* Look in cache for a matching entry */
00255         cached = ib_find_path_cache_entry ( ibdev, gid );
00256         if ( cached && cached->path->av.lid ) {
00257                 /* Populated entry found */
00258                 av->lid = cached->path->av.lid;
00259                 av->rate = cached->path->av.rate;
00260                 av->sl = cached->path->av.sl;
00261                 DBGC2 ( ibdev, "IBDEV %p cache hit for %08x:%08x:%08x:%08x\n",
00262                         ibdev, htonl ( gid->u.dwords[0] ),
00263                         htonl ( gid->u.dwords[1] ), htonl ( gid->u.dwords[2] ),
00264                         htonl ( gid->u.dwords[3] ) );
00265                 return 0;
00266         }
00267         DBGC ( ibdev, "IBDEV %p cache miss for %08x:%08x:%08x:%08x%s\n",
00268                ibdev, htonl ( gid->u.dwords[0] ), htonl ( gid->u.dwords[1] ),
00269                htonl ( gid->u.dwords[2] ), htonl ( gid->u.dwords[3] ),
00270                ( cached ? " (in progress)" : "" ) );
00271 
00272         /* If lookup is already in progress, do nothing */
00273         if ( cached )
00274                 return -ENOENT;
00275 
00276         /* Locate a new cache entry to use */
00277         cache_idx = ( (ib_path_cache_idx++) % IB_NUM_CACHED_PATHS );
00278         cached = &ib_path_cache[cache_idx];
00279 
00280         /* Destroy the old cache entry */
00281         if ( cached->path )
00282                 ib_destroy_path ( ibdev, cached->path );
00283         memset ( cached, 0, sizeof ( *cached ) );
00284 
00285         /* Create new path */
00286         cached->path = ib_create_path ( ibdev, av, &ib_cached_path_op );
00287         if ( ! cached->path ) {
00288                 DBGC ( ibdev, "IBDEV %p could not create path\n",
00289                        ibdev );
00290                 return -ENOMEM;
00291         }
00292         ib_path_set_ownerdata ( cached->path, cached );
00293 
00294         /* Not found yet */
00295         return -ENOENT;
00296 }


Generated on Tue Apr 6 20:01:50 2010 for gPXE by  doxygen 1.5.7.1