datapath-windows/ovsext/Vport.c
/*
 * --------------------------------------------------------------------------
 * Functionality common to any port added from OVS userspace.
 *
 * Inserts the port into 'portNoHashArray', 'ovsPortNameHashArray' and in
 * 'tunnelVportsArray' if appropriate.
 * --------------------------------------------------------------------------
 */
Functionality common to any port added from OVS userspace.


Functionality common to any port added from OVS userspace .
NDIS_STATUS
InitOvsVportCommon(POVS_SWITCH_CONTEXT switchContext,
                   POVS_VPORT_ENTRY vport)
{
    UINT32 hash;
    switch(vport->ovsType) {
    case OVS_VPORT_TYPE_GRE:
    case OVS_VPORT_TYPE_VXLAN:
    case OVS_VPORT_TYPE_STT:
    case OVS_VPORT_TYPE_GENEVE:
    {
        UINT16 dstPort = GetPortFromPriv(vport);
        hash = OvsJhashBytes(&dstPort,
                             sizeof(dstPort),
                             OVS_HASH_BASIS);
        InsertHeadList(
            &gOvsSwitchContext->tunnelVportsArray[hash & OVS_VPORT_MASK],
            &vport->tunnelVportLink);
        switchContext->numNonHvVports++;
        break;
    }
    default:
        break;
    }
    hash = OvsJhashWords(&vport->portNo, 1, OVS_HASH_BASIS);
    InsertHeadList(&gOvsSwitchContext->portNoHashArray[hash & OVS_VPORT_MASK],
                   &vport->portNoLink);
    hash = OvsJhashBytes(vport->ovsName, strlen(vport->ovsName) + 1,
                         OVS_HASH_BASIS);
    InsertHeadList(
        &gOvsSwitchContext->ovsPortNameHashArray[hash & OVS_VPORT_MASK],
        &vport->ovsNameLink);
    return STATUS_SUCCESS;
}
NDIS_STATUS InitOvsVportCommon ( POVS_SWITCH_CONTEXT switchContext , POVS_VPORT_ENTRY vport ) { UINT32 hash ; switch ( vport -> ovsType ) { case OVS_VPORT_TYPE_GRE : case OVS_VPORT_TYPE_VXLAN : case OVS_VPORT_TYPE_STT : case OVS_VPORT_TYPE_GENEVE : { UINT16 dstPort = GetPortFromPriv ( vport ) ; hash = OvsJhashBytes ( & dstPort , sizeof ( dstPort ) , OVS_HASH_BASIS ) ; InsertHeadList ( & gOvsSwitchContext -> tunnelVportsArray [ hash & OVS_VPORT_MASK ] , & vport -> tunnelVportLink ) ; switchContext -> numNonHvVports ++ ; break ; } default : break ; } hash = OvsJhashWords ( & vport -> portNo , 1 , OVS_HASH_BASIS ) ; InsertHeadList ( & gOvsSwitchContext -> portNoHashArray [ hash & OVS_VPORT_MASK ] , & vport -> portNoLink ) ; hash = OvsJhashBytes ( vport -> ovsName , strlen ( vport -> ovsName ) + 1 , OVS_HASH_BASIS ) ; InsertHeadList ( & gOvsSwitchContext -> ovsPortNameHashArray [ hash & OVS_VPORT_MASK ] , & vport -> ovsNameLink ) ; return STATUS_SUCCESS ; }
Functionality common to any port added from OVS userspace.
Functionality common to any port added from OVS userspace .
/*
     * Insert the port into the hash array of ports: by port number and ovs
     * and ovs (datapath) port name.
     * NOTE: OvsJhashWords has portNo as "1" word. This is ok, because the
     * portNo is stored in 2 bytes only (max port number = MAXUINT16).
     */