mirror of https://github.com/ipxe/ipxe.git
[ipoib] Clarify new role of IPoIB peer cache as for MAC addresses only
Now that path record lookups are handled entirely via ib_resolve_path(), the only role of the IPoIB peer cache is as a lookup table for MAC addresses. Update the code structure and comments to reflect this.pull/1/head
parent
06ad481904
commit
8aa2591c06
|
@ -100,8 +100,12 @@ static struct ipoib_mac ipoib_broadcast = {
|
||||||
/**
|
/**
|
||||||
* IPoIB peer address
|
* IPoIB peer address
|
||||||
*
|
*
|
||||||
* This serves a similar role to the ARP cache for Ethernet. (ARP
|
* The IPoIB link-layer header is only four bytes long and so does not
|
||||||
* *is* used on IPoIB; we have two caches to maintain.)
|
* have sufficient room to store IPoIB MAC address(es). We therefore
|
||||||
|
* maintain a cache of MAC addresses identified by a single-byte key,
|
||||||
|
* and abuse the spare two bytes within the link-layer header to
|
||||||
|
* communicate these MAC addresses between the link-layer code and the
|
||||||
|
* netdevice driver.
|
||||||
*/
|
*/
|
||||||
struct ipoib_peer {
|
struct ipoib_peer {
|
||||||
/** Key */
|
/** Key */
|
||||||
|
@ -145,28 +149,6 @@ static struct ipoib_peer * ipoib_lookup_peer_by_key ( unsigned int key ) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Look up cached peer by GID
|
|
||||||
*
|
|
||||||
* @v gid Peer GID
|
|
||||||
* @ret peer Peer cache entry, or NULL
|
|
||||||
*/
|
|
||||||
static struct ipoib_peer *
|
|
||||||
ipoib_lookup_peer_by_gid ( const struct ib_gid *gid ) {
|
|
||||||
struct ipoib_peer *peer;
|
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
for ( i = 0 ; i < IPOIB_NUM_CACHED_PEERS ; i++ ) {
|
|
||||||
peer = &ipoib_peer_cache[i];
|
|
||||||
if ( memcmp ( &peer->mac.gid, gid,
|
|
||||||
sizeof ( peer->mac.gid) ) == 0 ) {
|
|
||||||
return peer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store GID and QPN in peer cache
|
* Store GID and QPN in peer cache
|
||||||
*
|
*
|
||||||
|
@ -174,15 +156,15 @@ ipoib_lookup_peer_by_gid ( const struct ib_gid *gid ) {
|
||||||
* @v qpn Peer QPN
|
* @v qpn Peer QPN
|
||||||
* @ret peer Peer cache entry
|
* @ret peer Peer cache entry
|
||||||
*/
|
*/
|
||||||
static struct ipoib_peer *
|
static struct ipoib_peer * ipoib_cache_peer ( const struct ipoib_mac *mac ) {
|
||||||
ipoib_cache_peer ( const struct ib_gid *gid, unsigned long qpn ) {
|
|
||||||
struct ipoib_peer *peer;
|
struct ipoib_peer *peer;
|
||||||
unsigned int key;
|
unsigned int key;
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
/* Look for existing cache entry */
|
/* Look for existing cache entry */
|
||||||
peer = ipoib_lookup_peer_by_gid ( gid );
|
for ( i = 0 ; i < IPOIB_NUM_CACHED_PEERS ; i++ ) {
|
||||||
if ( peer ) {
|
peer = &ipoib_peer_cache[i];
|
||||||
assert ( peer->mac.qpn = ntohl ( qpn ) );
|
if ( memcmp ( &peer->mac, mac, sizeof ( peer->mac ) ) == 0 )
|
||||||
return peer;
|
return peer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,12 +176,9 @@ ipoib_cache_peer ( const struct ib_gid *gid, unsigned long qpn ) {
|
||||||
|
|
||||||
memset ( peer, 0, sizeof ( *peer ) );
|
memset ( peer, 0, sizeof ( *peer ) );
|
||||||
peer->key = key;
|
peer->key = key;
|
||||||
peer->mac.qpn = htonl ( qpn );
|
memcpy ( &peer->mac, mac, sizeof ( peer->mac ) );
|
||||||
memcpy ( &peer->mac.gid, gid, sizeof ( peer->mac.gid ) );
|
DBG ( "IPoIB peer %x has MAC %s\n",
|
||||||
DBG ( "IPoIB peer %x has GID %08x:%08x:%08x:%08x and QPN %lx\n",
|
peer->key, ipoib_ntoa ( &peer->mac ) );
|
||||||
peer->key, htonl ( gid->u.dwords[0] ),
|
|
||||||
htonl ( gid->u.dwords[1] ), htonl ( gid->u.dwords[2] ),
|
|
||||||
htonl ( gid->u.dwords[3] ), qpn );
|
|
||||||
return peer;
|
return peer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,8 +210,8 @@ static int ipoib_push ( struct net_device *netdev __unused,
|
||||||
struct ipoib_peer *src;
|
struct ipoib_peer *src;
|
||||||
|
|
||||||
/* Add link-layer addresses to cache */
|
/* Add link-layer addresses to cache */
|
||||||
dest = ipoib_cache_peer ( &dest_mac->gid, ntohl ( dest_mac->qpn ) );
|
dest = ipoib_cache_peer ( dest_mac );
|
||||||
src = ipoib_cache_peer ( &src_mac->gid, ntohl ( src_mac->qpn ) );
|
src = ipoib_cache_peer ( src_mac );
|
||||||
|
|
||||||
/* Build IPoIB header */
|
/* Build IPoIB header */
|
||||||
ipoib_hdr->proto = net_proto;
|
ipoib_hdr->proto = net_proto;
|
||||||
|
@ -497,6 +476,7 @@ static void ipoib_data_complete_recv ( struct ib_device *ibdev __unused,
|
||||||
struct ipoib_device *ipoib = ib_qp_get_ownerdata ( qp );
|
struct ipoib_device *ipoib = ib_qp_get_ownerdata ( qp );
|
||||||
struct net_device *netdev = ipoib->netdev;
|
struct net_device *netdev = ipoib->netdev;
|
||||||
struct ipoib_hdr *ipoib_hdr;
|
struct ipoib_hdr *ipoib_hdr;
|
||||||
|
struct ipoib_mac ll_src;
|
||||||
struct ipoib_peer *src;
|
struct ipoib_peer *src;
|
||||||
|
|
||||||
if ( rc != 0 ) {
|
if ( rc != 0 ) {
|
||||||
|
@ -516,7 +496,9 @@ static void ipoib_data_complete_recv ( struct ib_device *ibdev __unused,
|
||||||
|
|
||||||
/* Parse source address */
|
/* Parse source address */
|
||||||
if ( av->gid_present ) {
|
if ( av->gid_present ) {
|
||||||
src = ipoib_cache_peer ( &av->gid, av->qpn );
|
ll_src.qpn = htonl ( av->qpn );
|
||||||
|
memcpy ( &ll_src.gid, &av->gid, sizeof ( ll_src.gid ) );
|
||||||
|
src = ipoib_cache_peer ( &ll_src );
|
||||||
ipoib_hdr->u.peer.src = src->key;
|
ipoib_hdr->u.peer.src = src->key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue