Skip to content

Commit

Permalink
DPDK: More programmability
Browse files Browse the repository at this point in the history
Allow to set mempool name, default burst size, default ring size for all
devices
  • Loading branch information
Tom Barbette committed Aug 3, 2018
1 parent 029044e commit b230047
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 9 deletions.
4 changes: 3 additions & 1 deletion elements/userlevel/dpdkinfo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@ int DPDKInfo::configure(Vector<String> &conf, ErrorHandler *errh) {
instance = this;
if (Args(conf, this, errh)
.read_p("NB_MBUF", DPDKDevice::NB_MBUF)
.read("MBUF_SIZE", DPDKDevice::MBUF_SIZE)
.read("MBUF_SIZE", DPDKDevice::MBUF_DATA_SIZE)
.read("MBUF_CACHE_SIZE", DPDKDevice::MBUF_CACHE_SIZE)
.read("RX_PTHRESH", DPDKDevice::RX_PTHRESH)
.read("RX_HTHRESH", DPDKDevice::RX_HTHRESH)
.read("RX_WTHRESH", DPDKDevice::RX_WTHRESH)
.read("TX_PTHRESH", DPDKDevice::TX_PTHRESH)
.read("TX_HTHRESH", DPDKDevice::TX_HTHRESH)
.read("TX_WTHRESH", DPDKDevice::TX_WTHRESH)
.read("MEMPOOL_PREFIX", DPDKDevice::MEMPOOL_PREFIX)
.read("DEF_BURST_SIZE", DPDKDevice::DEF_BURST_SIZE)
.complete() < 0)
return -1;

Expand Down
14 changes: 12 additions & 2 deletions elements/userlevel/dpdkinfo.hh
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ Keyword arguments:
=item NB_MBUF
Integer. Number of message buffers to allocate. Defaults to 524288.
Integer. Number of message buffers to allocate. Defaults to 65536.
=item MBUF_SIZE
Integer. Size of a message buffer in bytes. Defaults to 2048 +
RTE_PKTMBUF_HEADROOM + sizeof (struct rte_mbuf).
RTE_PKTMBUF_HEADROOM.
=item MBUF_CACHE_SIZE
Expand Down Expand Up @@ -64,6 +64,16 @@ Integer. TX host threshold. Defaults to 0.
Integer. TX write-back threshold. Defaults to 0.
=item MEMPOOL_PREFIX
String. Prefix for the mempool name. Use this to get a predictable
mempool name and attach secondary processes.
=item DEF_BURST_SIZE
Integer. Number of frames to read/write from/to a DPDK device.
Defaults to 32.
=back
This element is only available at user level, when compiled with DPDK
Expand Down
6 changes: 4 additions & 2 deletions elements/userlevel/fromdpdkdevice.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@
CLICK_DECLS

FromDPDKDevice::FromDPDKDevice() :
_dev(0), _queue_id(0), _promisc(true), _burst_size(32),
_dev(0), _queue_id(0), _promisc(true),
_count(0), _active(true), _task(this)
{
_burst_size = DPDKDevice::DEF_BURST_SIZE;
}

FromDPDKDevice::~FromDPDKDevice()
Expand Down Expand Up @@ -63,7 +64,8 @@ int FromDPDKDevice::configure(Vector<String> &conf, ErrorHandler *errh)
return errh->error("%s : Unknown or invalid PORT", dev.c_str());
}

return _dev->add_rx_queue(_queue_id, _promisc, (n_desc > 0) ? n_desc : 256, errh);
return _dev->add_rx_queue(_queue_id, _promisc, (n_desc > 0) ?
n_desc : DPDKDevice::DEF_DEV_RXDESC, errh);
}

int FromDPDKDevice::initialize(ErrorHandler *errh)
Expand Down
5 changes: 3 additions & 2 deletions elements/userlevel/todpdkdevice.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ CLICK_DECLS

ToDPDKDevice::ToDPDKDevice() :
_iqueues(), _dev(0), _queue_id(0), _blocking(false),
_iqueue_size(1024), _burst_size(32), _timeout(0), _count(0),
_iqueue_size(1024), _timeout(0), _count(0),
_dropped(0), _congestion_warning_printed(false)
{
_burst_size = DPDKDevice::DEF_BURST_SIZE;
}

ToDPDKDevice::~ToDPDKDevice()
Expand Down Expand Up @@ -68,7 +69,7 @@ int ToDPDKDevice::configure(Vector<String> &conf, ErrorHandler *errh)
return errh->error("%s : Unknown or invalid PORT", dev.c_str());
}

return _dev->add_tx_queue(_queue_id, (n_desc > 0) ? n_desc : 1024, errh);
return _dev->add_tx_queue(_queue_id, (n_desc > 0) ? n_desc : DPDKDevice::DEF_DEV_TXDESC, errh);
}

int ToDPDKDevice::initialize(ErrorHandler *errh)
Expand Down
6 changes: 6 additions & 0 deletions include/click/dpdkdevice.hh
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ public:
static int TX_PTHRESH;
static int TX_HTHRESH;
static int TX_WTHRESH;
static String MEMPOOL_PREFIX;

static unsigned DEF_DEV_RXDESC;
static unsigned DEF_DEV_TXDESC;

static unsigned DEF_BURST_SIZE;

private:

Expand Down
14 changes: 12 additions & 2 deletions lib/dpdkdevice.cc
Original file line number Diff line number Diff line change
Expand Up @@ -379,16 +379,26 @@ DPDKDeviceArg::parse(
}

int DPDKDevice::NB_MBUF = 65536;
int DPDKDevice::MBUF_DATA_SIZE = 2048;
#ifdef RTE_MBUF_DEFAULT_BUF_SIZE
int DPDKDevice::MBUF_DATA_SIZE = RTE_MBUF_DEFAULT_BUF_SIZE;
#else
int DPDKDevice::MBUF_DATA_SIZE = 2048 + RTE_PKTMBUF_HEADROOM;
#endif
int DPDKDevice::MBUF_SIZE = MBUF_DATA_SIZE
+ sizeof (struct rte_mbuf) + RTE_PKTMBUF_HEADROOM;
+ sizeof (struct rte_mbuf);
int DPDKDevice::MBUF_CACHE_SIZE = 256;
int DPDKDevice::RX_PTHRESH = 8;
int DPDKDevice::RX_HTHRESH = 8;
int DPDKDevice::RX_WTHRESH = 4;
int DPDKDevice::TX_PTHRESH = 36;
int DPDKDevice::TX_HTHRESH = 0;
int DPDKDevice::TX_WTHRESH = 0;
String DPDKDevice::MEMPOOL_PREFIX = "click_mempool_";

unsigned DPDKDevice::DEF_DEV_RXDESC = 256;
unsigned DPDKDevice::DEF_DEV_TXDESC = 256;

unsigned DPDKDevice::DEF_BURST_SIZE = 32;

bool DPDKDevice::_is_initialized = false;
HashTable<portid_t, DPDKDevice> DPDKDevice::_devs;
Expand Down

0 comments on commit b230047

Please sign in to comment.