VirtualBox

Changeset 26305 in vbox for trunk/include


Ignore:
Timestamp:
Feb 5, 2010 7:00:45 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
57374
Message:

pdmnetif.h & users: sketched out a new interface that is intended to be similar to the ring-0 and raw-mode context interfaces (working on driver allocated buffers during xmit).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/pdmnetifs.h

    r26300 r26305  
    4040 */
    4141
     42
     43/**
     44 * PDM scatter/gather buffer.
     45 *
     46 * @todo Promote this to VBox/types.h, VBox/pdmcommon.h or some such place.
     47 */
     48typedef struct PDMSCATTERGATHER
     49{
     50    /** Flags. */
     51    size_t          fFlags;
     52    /** The number of bytes used.
     53     * This is cleared on alloc and set by the user. */
     54    size_t          cbUsed;
     55    /** The number of bytes available.
     56     * This is set on alloc and not changed by the user. */
     57    size_t          cbAvailable;
     58    /** Private data member for the allocator side. */
     59    void           *pvAllocator;
     60    /** Private data member for the user side. */
     61    void           *pvUser;
     62    /** The number of segments
     63     * This is set on alloc and not changed by the user. */
     64    size_t          cSegs;
     65    /** Variable sized array of segments. */
     66    PDMDATASEG      aSegs[1];
     67} PDMSCATTERGATHER;
     68/** Pointer to a PDM scatter/gather buffer. */
     69typedef PDMSCATTERGATHER *PPDMSCATTERGATHER;
     70/** Pointer to a PDM scatter/gather buffer pointer. */
     71typedef PPDMSCATTERGATHER *PPPDMSCATTERGATHER;
     72
     73
     74/** @name PDMSCATTERGATHER::fFlags
     75 * @{  */
     76/** Magic value. */
     77#define PDMSCATTERGATHER_FLAGS_MAGIC        UINT32_C(0xb1b10000)
     78/** Magic mask. */
     79#define PDMSCATTERGATHER_FLAGS_MAGIC_MASK   UINT32_C(0xffff0000)
     80/** Owned by owner number 1. */
     81#define PDMSCATTERGATHER_FLAGS_OWNER_1      UINT32_C(0x00000001)
     82/** Owned by owner number 2. */
     83#define PDMSCATTERGATHER_FLAGS_OWNER_2      UINT32_C(0x00000002)
     84/** Owned by owner number 3. */
     85#define PDMSCATTERGATHER_FLAGS_OWNER_3      UINT32_C(0x00000002)
     86/** Owner mask. */
     87#define PDMSCATTERGATHER_FLAGS_OWNER_MASK   UINT32_C(0x00000003)
     88/** @} */
     89
     90
     91/**
     92 * Sets the owner of a scatter/gather buffer.
     93 *
     94 * @param   pSgBuf              .
     95 * @param   uNewOwner           The new owner.
     96 */
     97DECLINLINE(void) PDMScatterGatherSetOwner(PPDMSCATTERGATHER pSgBuf, uint32_t uNewOwner)
     98{
     99    pSgBuf->fFlags = (pSgBuf->fFlags & ~PDMSCATTERGATHER_FLAGS_OWNER_MASK) | uNewOwner;
     100}
     101
     102
     103
    42104/** Pointer to a network port interface */
    43 typedef struct PDMINETWORKPORT *PPDMINETWORKPORT;
     105typedef struct PDMINETWORKDOWN *PPDMINETWORKDOWN;
    44106/**
    45107 * Network port interface (down).
    46  * Pair with PDMINETWORKCONNECTOR.
    47  */
    48 typedef struct PDMINETWORKPORT
     108 * Pair with PDMINETWORKUP.
     109 */
     110typedef struct PDMINETWORKDOWN
    49111{
    50112    /**
     
    57119     * @param   pInterface      Pointer to the interface structure containing the called function pointer.
    58120     * @param   cMillies        Number of milliseconds to wait. 0 means return immediately.
    59      */
    60     DECLR3CALLBACKMEMBER(int, pfnWaitReceiveAvail,(PPDMINETWORKPORT pInterface, RTMSINTERVAL cMillies));
     121     *
     122     * @thread  Non-EMT.
     123     */
     124    DECLR3CALLBACKMEMBER(int, pfnWaitReceiveAvail,(PPDMINETWORKDOWN pInterface, RTMSINTERVAL cMillies));
    61125
    62126    /**
     
    67131     * @param   pvBuf           The available data.
    68132     * @param   cb              Number of bytes available in the buffer.
    69      * @thread  EMT
    70      */
    71     DECLR3CALLBACKMEMBER(int, pfnReceive,(PPDMINETWORKPORT pInterface, const void *pvBuf, size_t cb));
    72 
    73 } PDMINETWORKPORT;
    74 /** PDMINETWORKPORT inteface ID. */
    75 #define PDMINETWORKPORT_IID                     "eb66670b-7998-4470-8e72-886e30f6a9c3"
     133     *
     134     * @thread  Non-EMT.
     135     */
     136    DECLR3CALLBACKMEMBER(int, pfnReceive,(PPDMINETWORKDOWN pInterface, const void *pvBuf, size_t cb));
     137
     138
     139    /**
     140     * Called when there is a buffered of the required size available.
     141     *
     142     * When a PDMINETWORKUP::pfnAllocBuf call fails with VERR_TRY_AGAIN, the
     143     * driver will notify the device/driver up stream when a large enough buffer
     144     * becomes available via this method.
     145     *
     146     * @param   pInterface      Pointer to this interface.
     147     * @param   pSgBuf          Scatter/gather buffer of the size previously
     148     *                          requested.  Pass to PDMINETWORKUP::pfnSendBuf or
     149     *                          PDMINETWORKUP::pfnFreeBuf.
     150     *
     151     * @thread  Non-EMT.
     152     */
     153    DECLR3CALLBACKMEMBER(void, pfnNotifyBufAvailable,(PPDMINETWORKDOWN pInterface));
     154
     155} PDMINETWORKDOWN;
     156/** PDMINETWORKDOWN inteface ID. */
     157#define PDMINETWORKDOWN_IID                     "eb66670b-7998-4470-8e72-886e30f6a9c3"
    76158
    77159
     
    93175
    94176/** Pointer to a network connector interface */
    95 typedef struct PDMINETWORKCONNECTOR *PPDMINETWORKCONNECTOR;
     177typedef struct PDMINETWORKUP *PPDMINETWORKUP;
    96178/**
    97179 * Network connector interface (up).
    98  * Pair with PDMINETWORKPORT.
    99  */
    100 typedef struct PDMINETWORKCONNECTOR
    101 {
     180 * Pair with PDMINETWORKDOWN.
     181 */
     182typedef struct PDMINETWORKUP
     183{
     184    /**
     185     * Get a send buffer for passing to pfnSendBuf.
     186     *
     187     * @retval  VINF_SUCCESS on success.
     188     * @retval  VERR_TRY_AGAIN if temporarily out of buffer space.  After this
     189     *          happens, the driver will call PDMINETWORKDOWN::pfnNotifyBufAvailable
     190     *          when this is a buffer of the required size available.
     191     * @retval  VERR_NO_MEMORY if really out of buffer space.
     192     *
     193     * @param   pInterface      Pointer to the interface structure containing the called function pointer.
     194     * @param   cbMin           The minimum buffer size.
     195     * @param   ppSgBuf         Where to return the buffer.  The buffer will be
     196     *                          owned by the caller, designation owner number 1.
     197     *
     198     * @thread  Any, but normally EMT.
     199     */
     200    DECLR3CALLBACKMEMBER(int, pfnAllocBuf,(PPDMINETWORKUP pInterface, size_t cbMin, PPPDMSCATTERGATHER ppSgBuf));
     201
     202    /**
     203     * Frees an unused buffer.
     204     *
     205     * @retval  VINF_SUCCESS on success.
     206     * @retval  VERR_TRY_AGAIN if temporarily out of buffer space.  After this
     207     *          happens, the driver will call PDMINETWORKDOWN::pfnNotifyBufAvailable
     208     *          when this is a buffer of the required size available.
     209     * @retval  VERR_NO_MEMORY if really out of buffer space.
     210     *
     211     * @param   pInterface      Pointer to the interface structure containing the called function pointer.
     212     * @param   pSgBuf          A buffer from PDMINETWORKUP::pfnAllocBuf or
     213     *                          PDMINETWORKDOWN::pfnNotifyBufAvailable.  The buffer
     214     *                          ownership shall be 1.
     215     *
     216     * @thread  Any.
     217     */
     218    DECLR3CALLBACKMEMBER(int, pfnFreeBuf,(PPDMINETWORKUP pInterface, PPDMSCATTERGATHER pSgBuf));
     219
     220    /**
     221     * Send data to the network.
     222     *
     223     * @retval  VINF_SUCCESS on success.
     224     * @retval  VERR_NET_NO_NETWORK if the NIC is not connected to a network.
     225     *
     226     * @param   pInterface      Pointer to the interface structure containing the called function pointer.
     227     * @param   pSgBuf          The buffer containing the data to send.  The buffer
     228     *                          ownership shall be 1.  Upon sucessfull return the
     229     *                          buffer will be owned by the downstream driver and
     230     *                          have ownership set to 2.  The caller must not ever
     231     *                          touch it again.  On failure the buffer remains in
     232     *                          the callers ownership and it should be handed over
     233     *                          to PDMINETWORKUP::pfnFreeBuf.
     234     * @param   fOnWorkerThread Set if we're being called on a work thread.  Clear
     235     *                          if an EMT.
     236     *
     237     * @thread  Any.
     238     */
     239    DECLR3CALLBACKMEMBER(int, pfnSendBuf,(PPDMINETWORKUP pInterface, PPDMSCATTERGATHER pSgBuf, bool fOnWorkerThread));
     240
     241    /**
     242     * Set promiscuous mode.
     243     *
     244     * This is called when the promiscuous mode is set. This means that there doesn't have
     245     * to be a mode change when it's called.
     246     *
     247     * @param   pInterface      Pointer to the interface structure containing the called function pointer.
     248     * @param   fPromiscuous    Set if the adaptor is now in promiscuous mode. Clear if it is not.
     249     * @thread  EMT ??
     250     */
     251    DECLR3CALLBACKMEMBER(void, pfnSetPromiscuousMode,(PPDMINETWORKUP pInterface, bool fPromiscuous));
     252
     253    /**
     254     * Notification on link status changes.
     255     *
     256     * @param   pInterface      Pointer to the interface structure containing the called function pointer.
     257     * @param   enmLinkState    The new link state.
     258     * @thread  EMT ??
     259     */
     260    DECLR3CALLBACKMEMBER(void, pfnNotifyLinkChanged,(PPDMINETWORKUP pInterface, PDMNETWORKLINKSTATE enmLinkState));
     261
     262    /** @todo Add a callback that informs the driver chain about MAC address changes if we ever implement that.  */
     263
    102264    /**
    103265     * Send data to the network.
     
    107269     * @param   pvBuf           Data to send.
    108270     * @param   cb              Number of bytes to send.
    109      * @thread  EMT
    110      */
    111     DECLR3CALLBACKMEMBER(int, pfnSend,(PPDMINETWORKCONNECTOR pInterface, const void *pvBuf, size_t cb));
    112 
    113     /**
    114      * Set promiscuous mode.
    115      *
    116      * This is called when the promiscuous mode is set. This means that there doesn't have
    117      * to be a mode change when it's called.
    118      *
    119      * @param   pInterface      Pointer to the interface structure containing the called function pointer.
    120      * @param   fPromiscuous    Set if the adaptor is now in promiscuous mode. Clear if it is not.
    121      * @thread  EMT
    122      */
    123     DECLR3CALLBACKMEMBER(void, pfnSetPromiscuousMode,(PPDMINETWORKCONNECTOR pInterface, bool fPromiscuous));
    124 
    125     /**
    126      * Notification on link status changes.
    127      *
    128      * @param   pInterface      Pointer to the interface structure containing the called function pointer.
    129      * @param   enmLinkState    The new link state.
    130      * @thread  EMT
    131      */
    132     DECLR3CALLBACKMEMBER(void, pfnNotifyLinkChanged,(PPDMINETWORKCONNECTOR pInterface, PDMNETWORKLINKSTATE enmLinkState));
    133 
    134     /** @todo Add a callback that informs the driver chain about MAC address changes if we ever implement that.  */
    135 
    136 } PDMINETWORKCONNECTOR;
    137 /** PDMINETWORKCONNECTOR interface ID. */
    138 #define PDMINETWORKCONNECTOR_IID                "b4b6f850-50d0-4ddf-9efa-daee80194dca"
     271     * @thread  EMT ??
     272     * @deprecated
     273     */
     274    DECLR3CALLBACKMEMBER(int, pfnSendDeprecated,(PPDMINETWORKUP pInterface, const void *pvBuf, size_t cb));
     275
     276
     277} PDMINETWORKUP;
     278/** PDMINETWORKUP interface ID. */
     279#define PDMINETWORKUP_IID                       "f915243e-801a-4868-8979-b6b8594b09cc"
    139280
    140281
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette