Changeset 28830 in vbox for trunk/include/VBox
- Timestamp:
- Apr 27, 2010 2:05:25 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 60746
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/intnet.h
r28800 r28830 402 402 * set! 403 403 * 404 * @remarks Will only grab the switch table spinlock (interrupt safe). 404 * @remarks Will only grab the switch table spinlock (interrupt safe). May 405 * signal an event semaphore iff we're racing network cleanup. The 406 * caller must be busy when calling. 405 407 */ 406 408 DECLR0CALLBACKMEMBER(INTNETSWDECISION, pfnPreRecv,(PINTNETTRUNKSWPORT pSwitchPort, … … 411 413 * 412 414 * The frame may be modified when the trunk port on the switch is set to share 413 * the mac address of the host when hitting the wire. Currently rames containing 414 * ARP packets are subject to this, later other protocols like NDP/ICMPv6 may 415 * need editing as well when operating in this mode. 415 * the mac address of the host when hitting the wire. Currently frames 416 * containing ARP packets are subject to this, later other protocols like 417 * NDP/ICMPv6 may need editing as well when operating in this mode. The edited 418 * packet should be forwarded to the host/wire when @c false is returned. 416 419 * 417 420 * @returns true if we've handled it and it should be dropped. … … 419 422 * 420 423 * @param pSwitchPort Pointer to this structure. 421 * @param pSG The (scatter /) gather structure for the frame. 422 * This will only be use during the call, so a temporary one can 423 * be used. The Phys member will not be used. 424 * @param fSrc Where this frame comes from. Only one bit should be set! 425 * 426 * @remarks Will grab the network semaphore. 424 * @param pSG The (scatter /) gather structure for the frame. This 425 * will only be use during the call, so a temporary one can 426 * be used. The Phys member will not be used. 427 * @param fSrc Where this frame comes from. Exactly one bit shall be 428 * set! 429 * 430 * @remarks Will only grab the switch table spinlock (interrupt safe). Will 431 * signal event semaphores. The caller must be busy when calling. 427 432 * 428 433 * @remarks NAT and TAP will use this interface. 429 434 * 430 * @todo Do any of the host require notification before frame modifications? If so,431 * we'll add a callback to INTNETTRUNKIFPORT for this (pfnSGModifying) and432 * a SG flag.435 * @todo Do any of the host require notification before frame modifications? 436 * If so, we'll add a callback to INTNETTRUNKIFPORT for this 437 * (pfnSGModifying) and a SG flag. 433 438 */ 434 439 DECLR0CALLBACKMEMBER(bool, pfnRecv,(PINTNETTRUNKSWPORT pSwitchPort, PINTNETSG pSG, uint32_t fSrc)); … … 440 445 * @param pSG Pointer to the (scatter /) gather structure. 441 446 * 442 * @remarks Will not grab any locks. 447 * @remarks Will not grab any locks. The caller must be busy when calling. 443 448 */ 444 449 DECLR0CALLBACKMEMBER(void, pfnSGRetain,(PINTNETTRUNKSWPORT pSwitchPort, PINTNETSG pSG)); … … 447 452 * Release a SG. 448 453 * 449 * This is called by the pfnXmit code when done with a SG. This may safe454 * This is called by the pfnXmit code when done with a SG. This may safe 450 455 * be done in an asynchronous manner. 451 456 * … … 453 458 * @param pSG Pointer to the (scatter /) gather structure. 454 459 * 455 * @remarks Will grab the network semaphore. 460 * @remarks May signal an event semaphore later on, currently code won't though. 461 * The caller is busy when making this call. 456 462 */ 457 463 DECLR0CALLBACKMEMBER(void, pfnSGRelease,(PINTNETTRUNKSWPORT pSwitchPort, PINTNETSG pSG)); … … 462 468 * By enabling physical addresses in the scatter / gather segments it should 463 469 * be possible to save some unnecessary address translation and memory locking 464 * in the network stack. (Internal networking knows the physical address for465 * all the INTNETBUF data and that it's locked memory.) There is a negative470 * in the network stack. (Internal networking knows the physical address for 471 * all the INTNETBUF data and that it's locked memory.) There is a negative 466 472 * side effects though, frames that crosses page boundraries will require 467 473 * multiple scather / gather segments. … … 472 478 * @param fEnable Whether to enable or disable it. 473 479 * 474 * @remarks Will grab the network semaphore.480 * @remarks Will not grab any locks. The caller must be busy when calling. 475 481 */ 476 482 DECLR0CALLBACKMEMBER(bool, pfnSetSGPhys,(PINTNETTRUNKSWPORT pSwitchPort, bool fEnable)); … … 485 491 * @param pMacAddr The MAC address. 486 492 * 487 * @remarks May take a spinlock or two. 493 * @remarks May take a spinlock or two. The caller must be busy when calling. 488 494 */ 489 495 DECLR0CALLBACKMEMBER(void, pfnReportMacAddress,(PINTNETTRUNKSWPORT pSwitchPort, PCRTMAC pMacAddr)); … … 499 505 * promiscuous mode, false if not. 500 506 * 501 * @remarks May take a spinlock or two. 507 * @remarks May take a spinlock or two. The caller must be busy when calling. 502 508 */ 503 509 DECLR0CALLBACKMEMBER(void, pfnReportPromiscuousMode,(PINTNETTRUNKSWPORT pSwitchPort, bool fPromiscuous)); … … 515 521 * @param fDst The destination mask (INTNETTRUNKDIR_XXX). 516 522 * 517 * @remarks Does not take any locks. 523 * @remarks Does not take any locks. The caller must be busy when calling. 518 524 */ 519 525 DECLR0CALLBACKMEMBER(void, pfnReportGsoCapabilities,(PINTNETTRUNKSWPORT pSwitchPort, uint32_t fGsoCapabilities, uint32_t fDst)); … … 531 537 * @param fDst The destination mask (INTNETTRUNKDIR_XXX). 532 538 * 533 * @remarks Does not take any locks. 539 * @remarks Does not take any locks. The caller must be busy when calling. 534 540 */ 535 541 DECLR0CALLBACKMEMBER(void, pfnReportNoPreemptDsts,(PINTNETTRUNKSWPORT pSwitchPort, uint32_t fNoPreemptDsts)); … … 543 549 544 550 551 /** 552 * The trunk interface state used set by INTNETTRUNKIFPORT::pfnSetState. 553 */ 554 typedef enum INTNETTRUNKIFSTATE 555 { 556 /** The invalid zero entry. */ 557 INTNETTRUNKIFSTATE_INVALID = 0, 558 /** The trunk is inactive. No calls to INTNETTRUNKSWPORT::pfnRecv or 559 * INTNETTRUNKSWPORT::pfnPreRecv. Calling other methods is OK. */ 560 INTNETTRUNKIFSTATE_INACTIVE, 561 /** The trunk is active, no restrictions on methods or anything. */ 562 INTNETTRUNKIFSTATE_ACTIVE, 563 /** The trunk is about to be disconnected from the internal network. No 564 * calls to any INTNETRUNKSWPORT methods. */ 565 INTNETTRUNKIFSTATE_DISCONNECTING, 566 /** The end of the valid states. */ 567 INTNETTRUNKIFSTATE_END, 568 /** The usual 32-bit type blow up hack. */ 569 INTNETTRUNKIFSTATE_32BIT_HACK = 0x7fffffff 570 } INTNETTRUNKIFSTATE; 571 545 572 /** Pointer to the interface side of a trunk port. */ 546 573 typedef struct INTNETTRUNKIFPORT *PINTNETTRUNKIFPORT; 547 574 /** 548 * This is the port on the trunk interface, i.e. the driver 549 * side which theinternal network is connected to.575 * This is the port on the trunk interface, i.e. the driver side which the 576 * internal network is connected to. 550 577 * 551 578 * This is only used for the in-kernel trunk connections. 552 *553 * @remarks The internal network side is responsible for serializing all calls554 * to this interface. This is (assumed) to be implemented using a lock555 * that is only ever taken before a call to this interface. The lock556 * is referred to as the out-bound trunk port lock.557 579 */ 558 580 typedef struct INTNETTRUNKIFPORT … … 568 590 * @param pIfPort Pointer to this structure. 569 591 * 570 * @remarks The caller may own any locks or none at all, we don't care.592 * @remarks May own the big mutex, no spinlocks. 571 593 */ 572 594 DECLR0CALLBACKMEMBER(void, pfnRetain,(PINTNETTRUNKIFPORT pIfPort)); … … 580 602 * @param pIfPort Pointer to this structure. 581 603 * 582 * @remarks Only the out-bound trunk port lock, unless the caller is certain the 583 * call is not going to cause destruction (wont happen). 604 * @remarks May own the big mutex, no spinlocks. 584 605 */ 585 606 DECLR0CALLBACKMEMBER(void, pfnRelease,(PINTNETTRUNKIFPORT pIfPort)); … … 593 614 * @param pIfPort Pointer to this structure. 594 615 * 595 * @remarks Called holding the out-bound trunk port lock.616 * @remarks Owns the big mutex. 596 617 */ 597 618 DECLR0CALLBACKMEMBER(void, pfnDisconnectAndRelease,(PINTNETTRUNKIFPORT pIfPort)); 598 619 599 620 /** 600 * Changes the active state of the interface. 601 * 602 * The interface is created in the suspended (non-active) state and then activated 603 * when the VM/network is started. It may be suspended and re-activated later 604 * for various reasons. It will finally be suspended again before disconnecting 605 * the interface from the internal network, however, this might be done immediately 606 * before disconnecting and may leave an incoming frame waiting on the internal network 607 * semaphore. So, after the final suspend a pfnWaitForIdle is always called to make sure 608 * the interface is idle before pfnDisconnectAndRelease is called. 621 * Changes the state of the trunk interface. 622 * 623 * The interface is created in the inactive state (INTNETTRUNKIFSTATE_INACTIVE). 624 * When the first connect VM or service is activated, the internal network 625 * activates the trunk (INTNETTRUNKIFSTATE_ACTIVE). The state may then be set 626 * back and forth between INACTIVE and ACTIVE as VMs are paused, added and 627 * removed. 628 * 629 * Eventually though, the network is destroyed as a result of there being no 630 * more VMs left in it and the state is changed to disconnecting 631 * (INTNETTRUNKIFSTATE_DISCONNECTING) and pfnWaitForIdle is called to make sure 632 * there are no active calls in either direction when pfnDisconnectAndRelease is 633 * called. 609 634 * 610 635 * A typical operation to performed by this method is to enable/disable promiscuous 611 * mode on the host network interface. (This is the reason we cannot call this when 612 * owning any semaphores.) 636 * mode on the host network interface when entering/leaving the active state. 613 637 * 614 638 * @returns The previous state. 615 639 * 616 640 * @param pIfPort Pointer to this structure. 617 * @param fActive True if the new state is 'active', false if the new state is 'suspended'. 618 * 619 * @remarks Called holding the out-bound trunk port lock. 620 */ 621 DECLR0CALLBACKMEMBER(bool, pfnSetActive,(PINTNETTRUNKIFPORT pIfPort, bool fActive)); 641 * @param enmState The new state. 642 * 643 * @remarks Owns the big mutex. No racing pfnSetState, pfnWaitForIdle, 644 * pfnDisconnectAndRelease or INTNETTRUNKFACTORY::pfnCreateAndConnect 645 * calls. 646 */ 647 DECLR0CALLBACKMEMBER(INTNETTRUNKIFSTATE, pfnSetState,(PINTNETTRUNKIFPORT pIfPort, INTNETTRUNKIFSTATE enmState)); 622 648 623 649 /** 624 650 * Waits for the interface to become idle. 625 651 * 626 * This method must be called before disconnecting and releasing the 627 * o bject in order to prevent racing incoming/outgoing frames and device652 * This method must be called before disconnecting and releasing the object in 653 * order to prevent racing incoming/outgoing frames and device 628 654 * enabling/disabling. 629 655 * … … 634 660 * an indefinite wait. 635 661 * 636 * @remarks Called holding the out-bound trunk port lock.662 * @remarks Owns the big mutex. No racing pfnDisconnectAndRelease. 637 663 */ 638 664 DECLR0CALLBACKMEMBER(int, pfnWaitForIdle,(PINTNETTRUNKIFPORT pIfPort, uint32_t cMillies)); 639 640 /**641 * Gets the MAC address of the host network interface that we're attached to.642 *643 * @param pIfPort Pointer to this structure.644 * @param pMac Where to store the host MAC address.645 *646 * @remarks Called while owning the network and the out-bound trunk port semaphores.647 */648 DECLR0CALLBACKMEMBER(void, pfnGetMacAddress,(PINTNETTRUNKIFPORT pIfPort, PRTMAC pMac));649 650 /**651 * Tests whether the host is operating the interface is promiscuous mode.652 *653 * The default behavior of the internal networking 'switch' is to 'autodetect'654 * promiscuous mode on the trunk port, which is when this method is used.655 * For security reasons this default may of course be overridden so that the656 * host cannot sniff at what's going on.657 *658 * Note that this differs from operating the trunk port on the switch in659 * 'promiscuous' mode, because that relates to the bits going to the wire.660 *661 * @returns true / false.662 *663 * @param pIfPort Pointer to this structure.664 *665 * @remarks Usuaully called while owning the network and the out-bound trunk666 * port semaphores.667 */668 DECLR0CALLBACKMEMBER(bool, pfnIsPromiscuous,(PINTNETTRUNKIFPORT pIfPort));669 665 670 666 /** … … 679 675 * @param fDst The destination mask. At least one bit will be set. 680 676 * 681 * @remarks Called holding the out-bound trunk port lock. 682 * 683 * @remarks TAP and NAT will use this interface for all their traffic, see pfnIsHostMac. 684 * 685 * @todo 677 * @remarks No locks. May be called concurrently on several threads. 686 678 */ 687 679 DECLR0CALLBACKMEMBER(int, pfnXmit,(PINTNETTRUNKIFPORT pIfPort, PINTNETSG pSG, uint32_t fDst)); … … 743 735 744 736 /** The UUID for the (current) trunk factory. (case sensitive) */ 745 #define INTNETTRUNKFACTORY_UUID_STR " 5d347cb7-98e3-411f-916a-67c4becae09b"737 #define INTNETTRUNKFACTORY_UUID_STR "1849823d-33ed-4f23-a32f-ef7203ee2b9f" 746 738 747 739 /** @name INTNETTRUNKFACTORY::pfnCreateAndConnect flags.
Note:
See TracChangeset
for help on using the changeset viewer.