Skip to content

Commit

Permalink
Fix build with --enable-dpdk-packet
Browse files Browse the repository at this point in the history
  • Loading branch information
tbarbette committed Jan 14, 2025
1 parent df0bcdd commit fd993f5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 20 deletions.
5 changes: 0 additions & 5 deletions include/click/fromfile.hh
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,7 @@ class FromFile { public:
int warning(ErrorHandler *, const char *format, ...) const;

private:
#if CLICK_PACKET_USE_DPDK

enum { BUFFER_SIZE = 2048 };
#else
enum { BUFFER_SIZE = 32768 };
#endif

int _fd;
uint32_t _pos;
Expand Down
2 changes: 1 addition & 1 deletion include/click/packet.hh
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class Packet { public:
uint32_t length, uint32_t tailroom, bool clear = true) CLICK_WARN_UNUSED_RESULT;
static inline WritablePacket *make(const void *data, uint32_t length) CLICK_WARN_UNUSED_RESULT;
static inline WritablePacket *make(uint32_t length) CLICK_WARN_UNUSED_RESULT;
#if HAVE_DPDK
#if HAVE_DPDK && !CLICK_PACKET_USE_DPDK
static WritablePacket *make_dpdk_packet(uint32_t headroom,
uint32_t length, uint32_t tailroom, bool clear) CLICK_WARN_UNUSED_RESULT;
#endif
Expand Down
18 changes: 7 additions & 11 deletions lib/fromfile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -433,9 +433,7 @@ FromFile::set_data(const String& data, ErrorHandler* errh)
int
FromFile::initialize(ErrorHandler *errh, bool allow_nonexistent)
{
#if CLICK_PACKET_USE_DPDK
assert(BUFFER_SIZE <= DPDKDevice::MBUF_DATA_SIZE);
#endif

// if set_data, initialize is noop
if (_fd == -2)
return 0;
Expand Down Expand Up @@ -592,10 +590,10 @@ FromFile::get_string(size_t size, ErrorHandler *errh)
Packet *
FromFile::get_packet(size_t size, uint32_t sec, uint32_t subsec, ErrorHandler *errh)
{
#if HAVE_DPDK
#if CLICK_PACKET_USE_DPDK
#elif HAVE_DPDK
if (_dpdk) {
WritablePacket *p = Packet::make_dpdk_packet(0, size, 0, 0);
//click_chatter("P %p, %d %d %d %d", p, p->length(), p->buffer_length(), p->headroom(), p->tailroom());
assert(DPDKDevice::is_dpdk_packet(p));
if (read(p->data(), size, errh) < (int)size) {
p->kill();
Expand All @@ -605,28 +603,26 @@ FromFile::get_packet(size_t size, uint32_t sec, uint32_t subsec, ErrorHandler *e
return p;
}
}
#endif
#if CLICK_PACKET_USE_DPDK
#else
if (_pos + size <= _len) {
#ifndef CLICK_NOINDIRECT
# ifndef CLICK_NOINDIRECT
if (Packet *p = _data_packet->clone()) {
p->shrink_data(_buffer + _pos, size);
p->timestamp_anno().assign(sec, subsec);
_pos += size;
return p;
}
#else
# else
if (Packet *p = Packet::make(_buffer + _pos, size)) {
p->timestamp_anno().assign(sec, subsec);
_pos += size;
return p;
}
#endif
# endif
} else
#endif
{
if (WritablePacket *p = Packet::make(0, 0, size, 0)) {
if (WritablePacket *p = Packet::make(0, 0, size, 0, 0)) {
if (read(p->data(), size, errh) < (int)size) {
p->kill();
return 0;
Expand Down
9 changes: 6 additions & 3 deletions lib/packet.cc
Original file line number Diff line number Diff line change
Expand Up @@ -838,9 +838,9 @@ void WritablePacket::pool_transfer(int from, int to) {
(void)to;
}

#if HAVE_DPDK
#if HAVE_DPDK && !CLICK_PACKET_USE_DPDK
/**
* @brief Make a Packet with a DPDK-backed buffer
* @brief Make a click Packet with a DPDK-backed buffer
*
* @param headroom
* @param data
Expand All @@ -857,8 +857,11 @@ Packet::make_dpdk_packet(uint32_t headroom, uint32_t length, uint32_t tailroom,
n = min_buffer_length;
}

#if HAVE_CLICK_PACKET_POOL
WritablePacket* p = WritablePacket::pool_allocate();

#else
WritablePacket* p = new WritablePacket;
#endif
unsigned char *d = 0;

struct rte_mbuf *mb = DPDKDevice::get_pkt();
Expand Down

0 comments on commit fd993f5

Please sign in to comment.