diff --git a/repos/dde_linux/src/lib/lxip/include/packet_handler.h b/repos/dde_linux/src/lib/lxip/include/packet_handler.h index b3c6688e5a..a7eb5a9e0e 100644 --- a/repos/dde_linux/src/lib/lxip/include/packet_handler.h +++ b/repos/dde_linux/src/lib/lxip/include/packet_handler.h @@ -19,7 +19,12 @@ #include namespace Net { + class Packet_handler; + + using Nic::Packet_stream_sink; + using Nic::Packet_stream_source; + using Nic::Packet_descriptor; } diff --git a/repos/dde_linux/src/lib/lxip/nic_handler.cc b/repos/dde_linux/src/lib/lxip/nic_handler.cc index b9017e6880..37768ea063 100644 --- a/repos/dde_linux/src/lib/lxip/nic_handler.cc +++ b/repos/dde_linux/src/lib/lxip/nic_handler.cc @@ -133,8 +133,8 @@ void net_mac(void* mac, unsigned long size) int net_tx(void* addr, unsigned long len) { try { - Packet_descriptor packet = Net::Nic::n()->tx()->alloc_packet(len); - void* content = Net::Nic::n()->tx()->packet_content(packet); + Net::Packet_descriptor packet = Net::Nic::n()->tx()->alloc_packet(len); + void* content = Net::Nic::n()->tx()->packet_content(packet); Genode::memcpy((char *)content, addr, len); Net::Nic::n()->tx()->submit_packet(packet); diff --git a/repos/libports/src/lib/lwip/platform/nic.cc b/repos/libports/src/lib/lwip/platform/nic.cc index 3227e646f7..b3f449cefe 100644 --- a/repos/libports/src/lib/lwip/platform/nic.cc +++ b/repos/libports/src/lib/lwip/platform/nic.cc @@ -40,6 +40,8 @@ class Nic_receiver_thread : public Genode::Thread<8192> { private: + typedef Nic::Packet_descriptor Packet_descriptor; + Nic::Connection *_nic; /* nic-session */ Packet_descriptor _rx_packet; /* actual packet received */ struct netif *_netif; /* LwIP network interface structure */ @@ -119,8 +121,8 @@ extern "C" { #if ETH_PAD_SIZE pbuf_header(p, -ETH_PAD_SIZE); /* drop the padding word */ #endif - Packet_descriptor tx_packet = th->alloc_tx_packet(p->tot_len); - char *tx_content = th->content(tx_packet); + Nic::Packet_descriptor tx_packet = th->alloc_tx_packet(p->tot_len); + char *tx_content = th->content(tx_packet); /* * Iterate through all pbufs and @@ -154,11 +156,11 @@ extern "C" { static struct pbuf * low_level_input(struct netif *netif) { - Nic_receiver_thread *th = reinterpret_cast(netif->state); - Nic::Connection *nic = th->nic(); - Packet_descriptor rx_packet = th->rx_packet(); - char *rx_content = nic->rx()->packet_content(rx_packet); - u16_t len = rx_packet.size(); + Nic_receiver_thread *th = reinterpret_cast(netif->state); + Nic::Connection *nic = th->nic(); + Nic::Packet_descriptor rx_packet = th->rx_packet(); + char *rx_content = nic->rx()->packet_content(rx_packet); + u16_t len = rx_packet.size(); #if ETH_PAD_SIZE len += ETH_PAD_SIZE; /* allow room for Ethernet padding */ diff --git a/repos/os/include/block_session/block_session.h b/repos/os/include/block_session/block_session.h index 0980b04660..6650a47a4e 100644 --- a/repos/os/include/block_session/block_session.h +++ b/repos/os/include/block_session/block_session.h @@ -46,7 +46,7 @@ namespace Block { * the data read from or written to the block indicated by * its number. */ -class Block::Packet_descriptor : public ::Packet_descriptor +class Block::Packet_descriptor : public Genode::Packet_descriptor { public: @@ -65,18 +65,22 @@ class Block::Packet_descriptor : public ::Packet_descriptor /** * Constructor */ - Packet_descriptor(Genode::off_t offset=0, Genode::size_t size=0) - : ::Packet_descriptor(offset, size), - _op(READ), _block_number(0), _block_count(0), _success(false) { } + Packet_descriptor(Genode::off_t offset=0, Genode::size_t size = 0) + : + Genode::Packet_descriptor(offset, size), + _op(READ), _block_number(0), _block_count(0), _success(false) + { } /** * Constructor */ Packet_descriptor(Packet_descriptor p, Opcode op, sector_t blk_nr, Genode::size_t blk_count = 1) - : ::Packet_descriptor(p.offset(), p.size()), - _op(op), _block_number(blk_nr), - _block_count(blk_count), _success(false) { } + : + Genode::Packet_descriptor(p.offset(), p.size()), + _op(op), _block_number(blk_nr), + _block_count(blk_count), _success(false) + { } Opcode operation() const { return _op; } sector_t block_number() const { return _block_number; } @@ -113,9 +117,9 @@ struct Block::Session : public Genode::Session }; - typedef Packet_stream_policy Tx_policy; + typedef Genode::Packet_stream_policy Tx_policy; typedef Packet_stream_tx::Channel Tx; diff --git a/repos/os/include/file_system_session/file_system_session.h b/repos/os/include/file_system_session/file_system_session.h index 9c8f7b77cd..3c9e7c9c24 100644 --- a/repos/os/include/file_system_session/file_system_session.h +++ b/repos/os/include/file_system_session/file_system_session.h @@ -106,7 +106,7 @@ struct File_system::Symlink_handle : Node_handle }; -class File_system::Packet_descriptor : public ::Packet_descriptor +class File_system::Packet_descriptor : public Genode::Packet_descriptor { public: @@ -129,7 +129,7 @@ class File_system::Packet_descriptor : public ::Packet_descriptor */ Packet_descriptor(off_t offset = 0, size_t size = 0) : - ::Packet_descriptor(offset, size), _handle(-1), + Genode::Packet_descriptor(offset, size), _handle(-1), _op(READ), _position(0), _length(0), _success(false) { } /** @@ -141,7 +141,7 @@ class File_system::Packet_descriptor : public ::Packet_descriptor Node_handle handle, Opcode op, size_t length, seek_off_t position = ~0) : - ::Packet_descriptor(p.offset(), p.size()), + Genode::Packet_descriptor(p.offset(), p.size()), _handle(handle), _op(op), _position(position), _length(length), _success(false), _ref(ref) diff --git a/repos/os/include/nic/component.h b/repos/os/include/nic/component.h index f9470d2e02..b70a770cd7 100644 --- a/repos/os/include/nic/component.h +++ b/repos/os/include/nic/component.h @@ -47,7 +47,7 @@ class Nic::Session_component : public Genode::Allocator_avl, Driver &_driver; /* rx packet descriptor */ - Packet_descriptor _curr_rx_packet; + Genode::Packet_descriptor _curr_rx_packet; enum { TX_STACK_SIZE = 8*1024 }; class Tx_thread : public Genode::Thread @@ -155,7 +155,7 @@ class Nic::Session_component : public Genode::Allocator_avl, { /* check for acknowledgements from the client */ while (_rx.source()->ack_avail()) { - Packet_descriptor packet = _rx.source()->get_acked_packet(); + Genode::Packet_descriptor packet = _rx.source()->get_acked_packet(); /* free packet buffer */ _rx.source()->release_packet(packet); diff --git a/repos/os/include/nic_session/nic_session.h b/repos/os/include/nic_session/nic_session.h index 0b6aedb8dc..239f033a1e 100644 --- a/repos/os/include/nic_session/nic_session.h +++ b/repos/os/include/nic_session/nic_session.h @@ -37,6 +37,11 @@ namespace Nic { struct Mac_address; struct Session; + + using Genode::Packet_stream_sink; + using Genode::Packet_stream_source; + + typedef Genode::Packet_descriptor Packet_descriptor; } @@ -53,8 +58,8 @@ struct Nic::Session : Genode::Session * The acknowledgement queue has always the same size as the submit * queue. We access the packet content as a char pointer. */ - typedef Packet_stream_policy Policy; + typedef Genode::Packet_stream_policy Policy; typedef Packet_stream_tx::Channel Tx; typedef Packet_stream_rx::Channel Rx; diff --git a/repos/os/include/os/packet_stream.h b/repos/os/include/os/packet_stream.h index 61dd7b51cc..de5f5ce780 100644 --- a/repos/os/include/os/packet_stream.h +++ b/repos/os/include/os/packet_stream.h @@ -81,6 +81,32 @@ #include #include +namespace Genode { + + class Packet_descriptor; + + template class Packet_descriptor_queue; + template class Packet_descriptor_transmitter; + template class Packet_descriptor_receiver; + + class Packet_stream_base; + + template + struct Packet_stream_policy; + + /** + * Default configuration for packet-descriptor queues + */ + typedef Packet_stream_policy + Default_packet_stream_policy; + + template + class Packet_stream_source; + + template + class Packet_stream_sink; +} + /** * Default packet descriptor @@ -88,7 +114,7 @@ * A class used as 'PACKET_DESCRIPTOR' arguments to the 'Packet_stream_policy' * template must implement the interface of this class. */ -class Packet_descriptor +class Genode::Packet_descriptor { private: @@ -127,7 +153,7 @@ class Packet_descriptor * This class is private to the packet-stream interface. */ template -class Packet_descriptor_queue +class Genode::Packet_descriptor_queue { private: @@ -221,7 +247,7 @@ class Packet_descriptor_queue * This class is private to the packet-stream interface. */ template -class Packet_descriptor_transmitter +class Genode::Packet_descriptor_transmitter { private: @@ -310,7 +336,7 @@ class Packet_descriptor_transmitter * This class is private to the packet-stream interface. */ template -class Packet_descriptor_receiver +class Genode::Packet_descriptor_receiver { private: @@ -386,7 +412,7 @@ class Packet_descriptor_receiver * * This class is private to the packet-stream interface. */ -class Packet_stream_base +class Genode::Packet_stream_base { public: @@ -475,7 +501,7 @@ template -struct Packet_stream_policy +struct Genode::Packet_stream_policy { typedef CONTENT_TYPE Content_type; @@ -489,13 +515,6 @@ struct Packet_stream_policy }; -/** - * Default configuration for packet-descriptor queues - */ -typedef Packet_stream_policy - Default_packet_stream_policy; - - /** * Placement new operator for constructing packet-descriptor queues * @@ -504,14 +523,15 @@ typedef Packet_stream_policy * * This operator should not be used outside the packet-stream interface. */ -inline void *operator new(Genode::size_t size, void *addr, Packet_stream_base *) { return addr; } +inline void *operator new(Genode::size_t size, void *addr, + Genode::Packet_stream_base *) { return addr; } /** * Originator of a packet stream */ -template -class Packet_stream_source : private Packet_stream_base +template +class Genode::Packet_stream_source : private Packet_stream_base { public: @@ -694,8 +714,8 @@ class Packet_stream_source : private Packet_stream_base /** * Receiver of a packet stream */ -template -class Packet_stream_sink : private Packet_stream_base +template +class Genode::Packet_stream_sink : private Packet_stream_base { public: diff --git a/repos/os/include/packet_stream_rx/packet_stream_rx.h b/repos/os/include/packet_stream_rx/packet_stream_rx.h index b5a2167207..efd531af95 100644 --- a/repos/os/include/packet_stream_rx/packet_stream_rx.h +++ b/repos/os/include/packet_stream_rx/packet_stream_rx.h @@ -23,8 +23,8 @@ namespace Packet_stream_rx { template struct Channel; } template struct Packet_stream_rx::Channel { - typedef ::Packet_stream_source Source; - typedef ::Packet_stream_sink Sink; + typedef Genode::Packet_stream_source Source; + typedef Genode::Packet_stream_sink Sink; /** * Request reception interface diff --git a/repos/os/include/packet_stream_tx/packet_stream_tx.h b/repos/os/include/packet_stream_tx/packet_stream_tx.h index bc8ccf0ac3..2981ad0f8d 100644 --- a/repos/os/include/packet_stream_tx/packet_stream_tx.h +++ b/repos/os/include/packet_stream_tx/packet_stream_tx.h @@ -23,8 +23,8 @@ namespace Packet_stream_tx { template struct Channel; } template struct Packet_stream_tx::Channel { - typedef Packet_stream_source Source; - typedef Packet_stream_sink Sink; + typedef Genode::Packet_stream_source Source; + typedef Genode::Packet_stream_sink Sink; /** * Request transmission interface diff --git a/repos/os/include/usb_session/usb_session.h b/repos/os/include/usb_session/usb_session.h index 5b24efa81d..3ee1fd65b3 100644 --- a/repos/os/include/usb_session/usb_session.h +++ b/repos/os/include/usb_session/usb_session.h @@ -20,16 +20,18 @@ namespace Usb { + using namespace Genode; class Session; struct Packet_descriptor; struct Completion; } + /** * USB packet type */ -struct Usb::Packet_descriptor : ::Packet_descriptor +struct Usb::Packet_descriptor : Genode::Packet_descriptor { enum Type { STRING, CTRL, BULK, IRQ, ALT_SETTING, CONFIG, RELEASE_IF }; @@ -41,17 +43,17 @@ struct Usb::Packet_descriptor : ::Packet_descriptor { struct { - uint8_t index; - unsigned length; + uint8_t index; + unsigned length; } string; struct { - uint8_t request; - uint8_t request_type; - uint16_t value; - uint16_t index; - int timeout; + uint8_t request; + uint8_t request_type; + uint16_t value; + uint16_t index; + int timeout; } control; struct @@ -63,8 +65,8 @@ struct Usb::Packet_descriptor : ::Packet_descriptor struct { - uint8_t number; - uint8_t alt_setting; + uint8_t number; + uint8_t alt_setting; } interface; struct @@ -76,12 +78,13 @@ struct Usb::Packet_descriptor : ::Packet_descriptor bool is_read_transfer() { return transfer.ep & ENDPOINT_IN; } Packet_descriptor(off_t offset = 0, size_t size = 0) - : ::Packet_descriptor(offset, size) { } + : Genode::Packet_descriptor(offset, size) { } - Packet_descriptor(::Packet_descriptor p, Type type, Completion *completion = nullptr) - : ::Packet_descriptor(p.offset(), p.size()), type(type), completion(completion) { } + Packet_descriptor(Genode::Packet_descriptor p, Type type, Completion *completion = nullptr) + : Genode::Packet_descriptor(p.offset(), p.size()), type(type), completion(completion) { } }; + /** * Completion for asynchronous communication */ @@ -90,6 +93,7 @@ struct Usb::Completion virtual void complete(Usb::Packet_descriptor &p) = 0; }; + struct Usb::Session : public Genode::Session { /**************** diff --git a/repos/os/src/server/nic_bridge/packet_handler.h b/repos/os/src/server/nic_bridge/packet_handler.h index 441c9f9796..8e33afcdbe 100644 --- a/repos/os/src/server/nic_bridge/packet_handler.h +++ b/repos/os/src/server/nic_bridge/packet_handler.h @@ -22,7 +22,12 @@ #include namespace Net { + class Packet_handler; + + using ::Nic::Packet_stream_sink; + using ::Nic::Packet_stream_source; + typedef ::Nic::Packet_descriptor Packet_descriptor; } /** diff --git a/repos/os/src/test/packet_stream/main.cc b/repos/os/src/test/packet_stream/main.cc index ee3d6aedd8..b1c36fe57e 100644 --- a/repos/os/src/test/packet_stream/main.cc +++ b/repos/os/src/test/packet_stream/main.cc @@ -25,14 +25,14 @@ * Note that the ack queue size is smaller than the submit queue * size. */ -typedef Packet_stream_policy +typedef Genode::Packet_stream_policy Test_packet_stream_policy; enum { STACK_SIZE = 4096 }; -void Packet_stream_base::_debug_print_buffers() +void Genode::Packet_stream_base::_debug_print_buffers() { Genode::printf("_ds_local_base = 0x%p\n", _ds_local_base); Genode::printf("_submit_queue_offset = 0x%lx\n", _submit_queue_offset); @@ -47,7 +47,7 @@ void Packet_stream_base::_debug_print_buffers() */ class Source : private Genode::Thread, private Genode::Allocator_avl, - public Packet_stream_source + public Genode::Packet_stream_source { private: @@ -169,7 +169,7 @@ class Source : private Genode::Thread, class Sink : private Genode::Thread, - public Packet_stream_sink + public Genode::Packet_stream_sink { private: diff --git a/repos/ports-foc/src/lib/l4lx/genode_net.cc b/repos/ports-foc/src/lib/l4lx/genode_net.cc index 85038d5557..db54f740f7 100644 --- a/repos/ports-foc/src/lib/l4lx/genode_net.cc +++ b/repos/ports-foc/src/lib/l4lx/genode_net.cc @@ -180,8 +180,8 @@ extern "C" { static Counter counter; try { - Packet_descriptor packet = nic()->tx()->alloc_packet(len); - void* content = nic()->tx()->packet_content(packet); + Nic::Packet_descriptor packet = nic()->tx()->alloc_packet(len); + void* content = nic()->tx()->packet_content(packet); Genode::memcpy((char *)content, addr, len); nic()->tx()->submit_packet(packet); @@ -204,7 +204,7 @@ extern "C" { { Linux::Irq_guard guard; - Packet_descriptor packet = nic()->tx()->get_acked_packet(); + Nic::Packet_descriptor packet = nic()->tx()->get_acked_packet(); nic()->tx()->release_packet(packet); } @@ -216,7 +216,7 @@ extern "C" { if (nic()) { while(nic()->rx()->packet_avail()) { - Packet_descriptor p = nic()->rx()->get_packet(); + Nic::Packet_descriptor p = nic()->rx()->get_packet(); if (receive_packet && net_device) receive_packet(net_device, nic()->rx()->packet_content(p), p.size()); diff --git a/repos/ports/src/app/seoul/main.cc b/repos/ports/src/app/seoul/main.cc index 7ec1216abd..3a7beed639 100644 --- a/repos/ports/src/app/seoul/main.cc +++ b/repos/ports/src/app/seoul/main.cc @@ -1163,7 +1163,7 @@ class Machine : public StaticReceiver } /* allocate transmit packet */ - Packet_descriptor tx_packet; + Nic::Packet_descriptor tx_packet; try { tx_packet = _nic->tx()->alloc_packet(msg.len); } catch (Nic::Session::Tx::Source::Packet_alloc_failed) { @@ -1180,7 +1180,7 @@ class Machine : public StaticReceiver _nic->tx()->submit_packet(tx_packet); /* wait for acknowledgement */ - Packet_descriptor ack_tx_packet = _nic->tx()->get_acked_packet(); + Nic::Packet_descriptor ack_tx_packet = _nic->tx()->get_acked_packet(); if (ack_tx_packet.size() != tx_packet.size() || ack_tx_packet.offset() != tx_packet.offset()) { diff --git a/repos/ports/src/app/seoul/network.cc b/repos/ports/src/app/seoul/network.cc index d4f28d0063..ded3b3a960 100644 --- a/repos/ports/src/app/seoul/network.cc +++ b/repos/ports/src/app/seoul/network.cc @@ -34,7 +34,7 @@ Vancouver_network::Vancouver_network(Synced_motherboard &mb, Nic::Session *nic) void Vancouver_network::entry() { while (true) { - Packet_descriptor rx_packet = _nic->rx()->get_packet(); + Nic::Packet_descriptor rx_packet = _nic->rx()->get_packet(); /* send it to the network bus */ char * rx_content = _nic->rx()->packet_content(rx_packet); diff --git a/repos/ports/src/virtualbox/network.cpp b/repos/ports/src/virtualbox/network.cpp index 3684da5fb1..060798443f 100644 --- a/repos/ports/src/virtualbox/network.cpp +++ b/repos/ports/src/virtualbox/network.cpp @@ -81,7 +81,7 @@ typedef struct DRVTAP static int net_send_packet(void * packet, uint32_t packet_len, Nic::Session * nic) { /* allocate transmit packet */ - Packet_descriptor tx_packet; + Nic::Packet_descriptor tx_packet; try { tx_packet = nic->tx()->alloc_packet(packet_len); } catch (Nic::Session::Tx::Source::Packet_alloc_failed) { @@ -96,7 +96,7 @@ static int net_send_packet(void * packet, uint32_t packet_len, Nic::Session * ni nic->tx()->submit_packet(tx_packet); /* wait for acknowledgement */ - Packet_descriptor ack_tx_packet = nic->tx()->get_acked_packet(); + Nic::Packet_descriptor ack_tx_packet = nic->tx()->get_acked_packet(); if (ack_tx_packet.size() != tx_packet.size() || ack_tx_packet.offset() != tx_packet.offset()) @@ -292,17 +292,17 @@ static DECLCALLBACK(int) drvGetMac(PPDMINETWORKCONFIG pInterface, PRTMAC pMac) */ static DECLCALLBACK(int) drvTAPAsyncIoThread(PPDMDRVINS pDrvIns, PPDMTHREAD pThread) { - PDRVTAP pThis = PDMINS_2_DATA(pDrvIns, PDRVTAP); - LogFlow(("drvTAPAsyncIoThread: pThis=%p\n", pThis)); + PDRVTAP pThis = PDMINS_2_DATA(pDrvIns, PDRVTAP); + LogFlow(("drvTAPAsyncIoThread: pThis=%p\n", pThis)); - if (pThread->enmState == PDMTHREADSTATE_INITIALIZING) - return VINF_SUCCESS; + if (pThread->enmState == PDMTHREADSTATE_INITIALIZING) + return VINF_SUCCESS; Nic::Session * nic = pThis->nic_session; - while (pThread->enmState == PDMTHREADSTATE_RUNNING) + while (pThread->enmState == PDMTHREADSTATE_RUNNING) { - Packet_descriptor rx_packet = nic->rx()->get_packet(); + Nic::Packet_descriptor rx_packet = nic->rx()->get_packet(); /* send it to the network bus */ char * rx_content = nic->rx()->packet_content(rx_packet);