Skip to content

Commit

Permalink
nic: add defaults for sendq- and and rx buffer limits
Browse files Browse the repository at this point in the history
  • Loading branch information
Alfred Bratterud committed Oct 15, 2018
1 parent 9b77d68 commit 9f31b1f
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions api/hw/nic.hpp
Expand Up @@ -21,6 +21,9 @@
#include "mac_addr.hpp"
#include <net/inet_common.hpp>

#define NIC_SENDQ_LIMIT_DEFAULT 4096
#define NIC_BUFFER_LIMIT_DEFAULT 4096

namespace hw {

/**
Expand All @@ -31,6 +34,12 @@ namespace hw {
using upstream = delegate<void(net::Packet_ptr)>;
using downstream = net::downstream_link;

/** Maximum number of packets allowed in dynamic send queue **/
static constexpr uint32_t sendq_limit_default = NIC_SENDQ_LIMIT_DEFAULT;

/** Maximum number of packets that can be created during RX-ring refill **/
static constexpr uint32_t buffer_limit_default = NIC_BUFFER_LIMIT_DEFAULT;

enum class Proto {ETH, IEEE802111};

virtual Proto proto() const = 0;
Expand Down Expand Up @@ -106,7 +115,7 @@ namespace hw {
this->m_buffer_limit = new_limit;
}
uint32_t buffer_limit() const noexcept { return m_buffer_limit; }

/** Set new sendq limit, where 0 means infinite **/
void set_sendq_limit(uint32_t new_limit) {
this->m_sendq_limit = new_limit;
Expand Down Expand Up @@ -156,8 +165,8 @@ namespace hw {

private:
int N;
uint32_t m_buffer_limit = 0;
uint32_t m_sendq_limit = 0;
uint32_t m_buffer_limit = buffer_limit_default;
uint32_t m_sendq_limit = sendq_limit_default;
friend class Devices;
};

Expand Down

0 comments on commit 9f31b1f

Please sign in to comment.