Skip to content

Commit c1308dc

Browse files
committed
fixed copyrights and formatting issues
1 parent 23e6c28 commit c1308dc

25 files changed

+147
-129
lines changed

include/Homa/Driver.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ struct PacketSpec {
8383

8484
/// Number of bytes in the payload.
8585
int32_t length;
86-
} __attribute__((packed));
86+
} __attribute__((packed));
8787
static_assert(std::is_trivial<PacketSpec>());
8888

8989
/**
@@ -140,7 +140,7 @@ class Driver {
140140
* getHighestPacketPriority().
141141
*/
142142
virtual void sendPacket(Packet* packet, IpAddress destination,
143-
int priority) = 0;
143+
int priority) = 0;
144144

145145
/**
146146
* Request that the Driver enter the "corked" mode where outbound packets
@@ -170,12 +170,12 @@ class Driver {
170170
*
171171
* @param maxPackets
172172
* The maximum number of Packet objects that should be returned by
173-
* this method.
173+
* this method.
174174
* @param[out] receivedPackets
175175
* Received packets are appended to this array in order of arrival.
176176
* @param[out] sourceAddresses
177177
* Source IP addresses of the received packets are appended to this
178-
* array in order of arrival.
178+
* array in order of arrival.
179179
*
180180
* @return
181181
* Number of Packet objects being returned.

include/Homa/Drivers/Fake/FakeDriver.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ struct FakePacket {
6565
* FakePacket constructor.
6666
*/
6767
explicit FakePacket()
68-
: base{.payload = buf,
69-
.length = 0}
68+
: base{.payload = buf, .length = 0}
7069
, buf()
7170
, sourceIp()
7271
{}
@@ -75,8 +74,7 @@ struct FakePacket {
7574
* Copy constructor.
7675
*/
7776
FakePacket(const FakePacket& other)
78-
: base{.payload = buf,
79-
.length = other.base.length}
77+
: base{.payload = buf, .length = other.base.length}
8078
, buf()
8179
, sourceIp()
8280
{
@@ -112,7 +110,8 @@ class FakeDriver : public Driver {
112110
virtual ~FakeDriver();
113111

114112
virtual Packet* allocPacket();
115-
virtual void sendPacket(Packet* packet, IpAddress destination, int priority);
113+
virtual void sendPacket(Packet* packet, IpAddress destination,
114+
int priority);
116115
virtual uint32_t receivePackets(uint32_t maxPackets,
117116
Packet* receivedPackets[],
118117
IpAddress sourceAddresses[]);

include/Homa/Util.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2009-2018, Stanford University
1+
/* Copyright (c) 2009-2020, Stanford University
22
*
33
* Permission to use, copy, modify, and/or distribute this software for any
44
* purpose with or without fee is hereby granted, provided that the above
@@ -22,10 +22,11 @@
2222
#include <string>
2323

2424
/// Cast a member of a structure out to the containing structure.
25-
template<class P, class M>
26-
P* container_of(M* ptr, const M P::*member)
25+
template <class P, class M>
26+
P*
27+
container_of(M* ptr, const M P::*member)
2728
{
28-
return (P*)((char*) ptr - (size_t) &(reinterpret_cast<P*>(0)->*member));
29+
return (P*)((char*)ptr - (size_t) & (reinterpret_cast<P*>(0)->*member));
2930
}
3031

3132
namespace Homa {

src/ControlPacket.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2019, Stanford University
1+
/* Copyright (c) 2019-2020, Stanford University
22
*
33
* Permission to use, copy, modify, and/or distribute this software for any
44
* purpose with or without fee is hereby granted, provided that the above

src/Driver.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2018-2019, Stanford University
1+
/* Copyright (c) 2018-2020, Stanford University
22
*
33
* Permission to use, copy, modify, and/or distribute this software for any
44
* purpose with or without fee is hereby granted, provided that the above
@@ -23,8 +23,8 @@ std::string
2323
IpAddress::toString(IpAddress address)
2424
{
2525
uint32_t ip = address.addr;
26-
return StringUtil::format("%d.%d.%d.%d",
27-
(ip >> 24) & 0xff, (ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff);
26+
return StringUtil::format("%d.%d.%d.%d", (ip >> 24) & 0xff,
27+
(ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff);
2828
}
2929

3030
IpAddress

src/Drivers/DPDK/DpdkDriver.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ DpdkDriver::DpdkDriver(const char* ifname, int argc, char* argv[],
3030
: pImpl(new Impl(ifname, argc, argv, config))
3131
{}
3232

33-
DpdkDriver::DpdkDriver(const char* ifname, NoEalInit _, const Config* const config)
33+
DpdkDriver::DpdkDriver(const char* ifname, NoEalInit _,
34+
const Config* const config)
3435
: pImpl(new Impl(ifname, _, config))
3536
{}
3637

src/Drivers/DPDK/DpdkDriverImpl.cc

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@
1717
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1818
*/
1919

20-
#include <fstream>
21-
#include <sys/ioctl.h>
2220
#include <net/if.h>
2321
#include <netinet/in.h>
22+
#include <sys/ioctl.h>
2423
#include <unistd.h>
24+
#include <fstream>
2525

2626
#include "DpdkDriverImpl.h"
2727

2828
#include <rte_malloc.h>
2929

3030
#include "CodeLocation.h"
31-
#include "StringUtil.h"
3231
#include "Homa/Util.h"
32+
#include "StringUtil.h"
3333

3434
namespace Homa {
3535

@@ -51,8 +51,7 @@ const char* default_eal_argv[] = {"homa", NULL};
5151
* Memory location in the mbuf where the packet data should be stored.
5252
*/
5353
DpdkDriver::Impl::Packet::Packet(struct rte_mbuf* mbuf, void* data)
54-
: base {.payload = data,
55-
.length = 0}
54+
: base{.payload = data, .length = 0}
5655
, bufType(MBUF)
5756
, bufRef()
5857
{
@@ -66,8 +65,7 @@ DpdkDriver::Impl::Packet::Packet(struct rte_mbuf* mbuf, void* data)
6665
* Overflow buffer that holds this packet.
6766
*/
6867
DpdkDriver::Impl::Packet::Packet(OverflowBuffer* overflowBuf)
69-
: base {.payload = overflowBuf->data,
70-
.length = 0}
68+
: base{.payload = overflowBuf->data, .length = 0}
7169
, bufType(OVERFLOW_BUF)
7270
, bufRef()
7371
{
@@ -212,7 +210,8 @@ DpdkDriver::Impl::sendPacket(Driver::Packet* packet, IpAddress destination,
212210
numMbufsAvail, numMbufsInUse);
213211
return;
214212
}
215-
char* buf = rte_pktmbuf_append(mbuf,
213+
char* buf = rte_pktmbuf_append(
214+
mbuf,
216215
Homa::Util::downCast<uint16_t>(PACKET_HDR_LEN + pkt->base.length));
217216
if (unlikely(NULL == buf)) {
218217
WARNING("rte_pktmbuf_append call failed; dropping packet");
@@ -506,9 +505,10 @@ DpdkDriver::Impl::_init()
506505
char mask[100];
507506
char dev[100];
508507
int type, flags;
509-
int cols = sscanf(line.c_str(), "%s 0x%x 0x%x %99s %99s %99s\n",
510-
ip, &type, &flags, hwa, mask, dev);
511-
if (cols != 6) continue;
508+
int cols = sscanf(line.c_str(), "%s 0x%x 0x%x %99s %99s %99s\n", ip,
509+
&type, &flags, hwa, mask, dev);
510+
if (cols != 6)
511+
continue;
512512
arpTable.emplace(IpAddress::fromString(ip), hwa);
513513
}
514514

@@ -517,46 +517,51 @@ DpdkDriver::Impl::_init()
517517
ifname.copy(ifr.ifr_name, ifname.length());
518518
ifr.ifr_name[ifname.length() + 1] = 0;
519519
if (ifname.length() >= sizeof(ifr.ifr_name)) {
520-
throw DriverInitFailure(HERE_STR,
520+
throw DriverInitFailure(
521+
HERE_STR,
521522
StringUtil::format("Interface name %s too long", ifname.c_str()));
522523
}
523524

524525
int fd = socket(AF_INET, SOCK_DGRAM, 0);
525526
if (fd == -1) {
526-
throw DriverInitFailure(HERE_STR,
527+
throw DriverInitFailure(
528+
HERE_STR,
527529
StringUtil::format("Failed to create socket: %s", strerror(errno)));
528530
}
529531

530532
if (ioctl(fd, SIOCGIFADDR, &ifr) == -1) {
531533
char* error = strerror(errno);
532534
close(fd);
533-
throw DriverInitFailure(HERE_STR,
535+
throw DriverInitFailure(
536+
HERE_STR,
534537
StringUtil::format("Failed to obtain IP address: %s", error));
535538
}
536-
localIp = {be32toh(((struct sockaddr_in*) &ifr.ifr_addr)->sin_addr.s_addr)};
539+
localIp = {be32toh(((struct sockaddr_in*)&ifr.ifr_addr)->sin_addr.s_addr)};
537540

538541
if (ioctl(fd, SIOCGIFHWADDR, &ifr) == -1) {
539542
char* error = strerror(errno);
540543
close(fd);
541-
throw DriverInitFailure(HERE_STR,
544+
throw DriverInitFailure(
545+
HERE_STR,
542546
StringUtil::format("Failed to obtain MAC address: %s", error));
543547
}
544548
close(fd);
545549
memcpy(localMac.address, ifr.ifr_hwaddr.sa_data, 6);
546550

547551
// Iterate over ethernet devices to locate the port identifier.
548552
int p;
549-
RTE_ETH_FOREACH_DEV(p) {
553+
RTE_ETH_FOREACH_DEV(p)
554+
{
550555
struct ether_addr mac;
551556
rte_eth_macaddr_get(p, &mac);
552557
if (MacAddress(mac.addr_bytes) == localMac) {
553558
port = p;
554559
break;
555560
}
556561
}
557-
NOTICE("Using interface %s, ip %s, mac %s, port %u",
558-
ifname.c_str(), IpAddress::toString(localIp).c_str(),
559-
localMac.toString().c_str(), port);
562+
NOTICE("Using interface %s, ip %s, mac %s, port %u", ifname.c_str(),
563+
IpAddress::toString(localIp).c_str(), localMac.toString().c_str(),
564+
port);
560565

561566
std::string poolName = StringUtil::format("homa_mbuf_pool_%u", port);
562567
std::string ringName = StringUtil::format("homa_loopback_ring_%u", port);

src/Drivers/DPDK/MacAddress.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2011-2019, Stanford University
1+
/* Copyright (c) 2011-2020, Stanford University
22
*
33
* Permission to use, copy, modify, and/or distribute this software for any
44
* purpose with or without fee is hereby granted, provided that the above

src/Drivers/DPDK/MacAddress.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2011-2019, Stanford University
1+
/* Copyright (c) 2011-2020, Stanford University
22
*
33
* Permission to use, copy, modify, and/or distribute this software for any
44
* purpose with or without fee is hereby granted, provided that the above

src/Drivers/DPDK/MacAddressTest.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2011-2019, Stanford University
1+
/* Copyright (c) 2011-2020, Stanford University
22
*
33
* Permission to use, copy, modify, and/or distribute this software for any
44
* purpose with or without fee is hereby granted, provided that the above

0 commit comments

Comments
 (0)