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
3434namespace 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 */
5353DpdkDriver::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 */
6867DpdkDriver::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);
0 commit comments