gem5  v21.1.0.2
tcp_iface.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 ARM Limited
3  * All rights reserved
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions are
16  * met: redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer;
18  * redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution;
21  * neither the name of the copyright holders nor the names of its
22  * contributors may be used to endorse or promote products derived from
23  * this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37 
38 /* @file
39  * TCP stream socket based interface class for dist-gem5 runs.
40  *
41  * For a high level description about dist-gem5 see comments in
42  * header file dist_iface.hh.
43  *
44  * Each gem5 process connects to the server (another gem5 process which
45  * simulates a switch box) via a stream socket. The server process
46  * transfers messages and co-ordinates the synchronisation among the gem5
47  * peers.
48  */
49 #ifndef __DEV_NET_TCP_IFACE_HH__
50 #define __DEV_NET_TCP_IFACE_HH__
51 
52 
53 #include <string>
54 
55 #include "dev/net/dist_iface.hh"
56 
57 namespace gem5
58 {
59 
60 class EventManager;
61 
62 class TCPIface : public DistIface
63 {
64  private:
68  int sock;
69 
70  std::string serverName;
72 
73  bool isSwitch;
74 
75  bool listening;
76  static bool anyListening;
77  static int fdStatic;
78 
83  struct NodeInfo
84  {
85  unsigned rank;
86  unsigned distIfaceId;
87  unsigned distIfaceNum;
88  };
94 
95  private:
96 
104  void
105  sendTCP(int sock, const void *buf, unsigned length);
106 
114  bool recvTCP(int sock, void *buf, unsigned length);
115  bool listen(int port);
116  void accept();
117  void connect();
118  int getfdStatic() const { return fdStatic; }
119  bool islistening() const { return listening; }
120  bool anyislistening() const { return anyListening; }
121  void establishConnection();
122 
123  protected:
124 
125  void sendPacket(const Header &header,
126  const EthPacketPtr &packet) override;
127 
128  void sendCmd(const Header &header) override;
129 
130  bool recvHeader(Header &header) override;
131 
132  void recvPacket(const Header &header, EthPacketPtr &packet) override;
133 
134  void initTransport() override;
135 
136  public:
148  TCPIface(std::string server_name, unsigned server_port,
149  unsigned dist_rank, unsigned dist_size,
150  Tick sync_start, Tick sync_repeat, EventManager *em,
151  bool use_pseudo_op, bool is_switch, int num_nodes);
152 
153  ~TCPIface() override;
154 };
155 
156 } // namespace gem5
157 
158 #endif // __DEV_NET_TCP_IFACE_HH__
gem5::TCPIface::isSwitch
bool isSwitch
Definition: tcp_iface.hh:73
gem5::TCPIface::sock
int sock
The stream socket to connect to the server.
Definition: tcp_iface.hh:68
gem5::TCPIface::NodeInfo::distIfaceNum
unsigned distIfaceNum
Definition: tcp_iface.hh:87
gem5::TCPIface::sendPacket
void sendPacket(const Header &header, const EthPacketPtr &packet) override
Send out a data packet to the remote end.
Definition: tcp_iface.cc:300
gem5::TCPIface::NodeInfo::rank
unsigned rank
Definition: tcp_iface.hh:85
gem5::TCPIface::recvPacket
void recvPacket(const Header &header, EthPacketPtr &packet) override
Receive a packet from the remote end.
Definition: tcp_iface.cc:328
gem5::DistIface::Header
DistHeaderPkt::Header Header
Definition: dist_iface.hh:104
gem5::TCPIface::anyListening
static bool anyListening
Definition: tcp_iface.hh:76
gem5::TCPIface::listening
bool listening
Definition: tcp_iface.hh:75
gem5::TCPIface::getfdStatic
int getfdStatic() const
Definition: tcp_iface.hh:118
gem5::TCPIface::TCPIface
TCPIface(std::string server_name, unsigned server_port, unsigned dist_rank, unsigned dist_size, Tick sync_start, Tick sync_repeat, EventManager *em, bool use_pseudo_op, bool is_switch, int num_nodes)
The ctor creates and connects the stream socket to the server.
Definition: tcp_iface.cc:82
gem5::TCPIface::sendTCP
void sendTCP(int sock, const void *buf, unsigned length)
Send out a message through a TCP stream socket.
Definition: tcp_iface.cc:264
header
output header
Definition: nop.cc:36
std::vector
STL vector class.
Definition: stl.hh:37
gem5::TCPIface::fdStatic
static int fdStatic
Definition: tcp_iface.hh:77
gem5::TCPIface::connect
void connect()
Definition: tcp_iface.cc:222
gem5::TCPIface::recvTCP
bool recvTCP(int sock, void *buf, unsigned length)
Receive the next incoming message through a TCP stream socket.
Definition: tcp_iface.cc:281
gem5::TCPIface::serverPort
int serverPort
Definition: tcp_iface.hh:71
gem5::TCPIface::listen
bool listen(int port)
Definition: tcp_iface.cc:115
gem5::X86ISA::em
Bitfield< 2 > em
Definition: misc.hh:608
gem5::EventManager
Definition: eventq.hh:987
gem5::TCPIface::anyislistening
bool anyislistening() const
Definition: tcp_iface.hh:120
gem5::EthPacketPtr
std::shared_ptr< EthPacketData > EthPacketPtr
Definition: etherpkt.hh:90
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
dist_iface.hh
gem5::TCPIface::sockRegistry
static std::vector< int > sockRegistry
Storage for all opened sockets.
Definition: tcp_iface.hh:93
gem5::TCPIface::sendCmd
void sendCmd(const Header &header) override
Send out a control command to the remote end.
Definition: tcp_iface.cc:307
gem5::TCPIface
Definition: tcp_iface.hh:62
gem5::TCPIface::islistening
bool islistening() const
Definition: tcp_iface.hh:119
gem5::TCPIface::accept
void accept()
Definition: tcp_iface.cc:208
gem5::TCPIface::NodeInfo
Compute node info and storage for the very first connection from each node (used by the switch)
Definition: tcp_iface.hh:83
gem5::DistIface
The interface class to talk to peer gem5 processes.
Definition: dist_iface.hh:101
gem5::TCPIface::nodes
static std::vector< std::pair< NodeInfo, int > > nodes
Definition: tcp_iface.hh:89
gem5::TCPIface::recvHeader
bool recvHeader(Header &header) override
Receive a header (i.e.
Definition: tcp_iface.cc:319
gem5::TCPIface::serverName
std::string serverName
Definition: tcp_iface.hh:70
gem5::TCPIface::establishConnection
void establishConnection()
Definition: tcp_iface.cc:152
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::TCPIface::NodeInfo::distIfaceId
unsigned distIfaceId
Definition: tcp_iface.hh:86
gem5::TCPIface::~TCPIface
~TCPIface() override
Definition: tcp_iface.cc:255
gem5::TCPIface::initTransport
void initTransport() override
Init hook for the underlaying transport.
Definition: tcp_iface.cc:338

Generated on Tue Sep 21 2021 12:25:17 for gem5 by doxygen 1.8.17