Skip to content

Commit

Permalink
Merge "Change tx-buffer length for pkt0 interface"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Apr 29, 2016
2 parents d335309 + 68776c9 commit 4c12770
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/vnsw/agent/cmn/agent.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ class Agent {
// Max number of threads
static const uint32_t kMaxTbbThreads = 8;
static const uint32_t kDefaultTbbKeepawakeTimeout = (20); //time-millisecs
// Default number of tx-buffers on pkt0 interface
static const uint32_t kPkt0TxBufferCount = 1000;

enum ForwardingMode {
NONE,
Expand Down
3 changes: 3 additions & 0 deletions src/vnsw/agent/contrail-vrouter-agent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ debug=0
# Category for logging. Default value is '*'
# log_category=

# Number of tx-buffers on pkt0 interface
# pkt0_tx_buffers=1000
#
# Local log file name
log_file=/var/log/contrail/contrail-vrouter-agent.log

Expand Down
20 changes: 20 additions & 0 deletions src/vnsw/agent/contrail/linux/pkt0_interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "base/logging.h"
#include "cmn/agent_cmn.h"
#include "init/agent_param.h"
#include "sandesh/sandesh_types.h"
#include "sandesh/sandesh.h"
#include "sandesh/sandesh_trace.h"
Expand Down Expand Up @@ -102,6 +103,25 @@ void Pkt0Interface::InitControlInterface() {
assert(0);
}

// Set tx-buffer count
memset(&ifr, 0, sizeof(ifr));
strncpy(ifr.ifr_name, name_.c_str(), IF_NAMESIZE);
if (ioctl(raw, SIOCGIFTXQLEN, (void *)&ifr) < 0) {
LOG(ERROR, "Packet Tap Error <" << errno << ": " << strerror(errno) <<
"> getting tx-buffer size");
assert(0);
}

uint32_t qlen = pkt_handler()->agent()->params()->pkt0_tx_buffer_count();
if (ifr.ifr_qlen < (int)qlen) {
ifr.ifr_qlen = qlen;
if (ioctl(raw, SIOCSIFTXQLEN, (void *)&ifr) < 0) {
LOG(ERROR, "Packet Tap Error <" << errno << ": "
<< strerror(errno) << "> setting tx-buffer size");
assert(0);
}
}

memset(&ifr, 0, sizeof(ifr));
strncpy(ifr.ifr_name, name_.data(), IF_NAMESIZE);
if (ioctl(raw, SIOCGIFFLAGS, (void *)&ifr) < 0) {
Expand Down
10 changes: 10 additions & 0 deletions src/vnsw/agent/init/agent_param.cc
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,11 @@ void AgentParam::ParseDefaultSection() {
"DEFAULT.mirror_client_port")) {
mirror_client_port_ = ContrailPorts::VrouterAgentMirrorClientUdpPort();
}

if (!GetValueFromTree<uint32_t>(pkt0_tx_buffer_count_,
"DEFAULT.pkt0_tx_buffers")) {
pkt0_tx_buffer_count_ = Agent::kPkt0TxBufferCount;
}
}

void AgentParam::ParseTaskSection() {
Expand Down Expand Up @@ -732,6 +737,8 @@ void AgentParam::ParseDefaultSectionArguments
"DEFAULT.subnet_hosts_resolvable");
GetOptValue<uint16_t>(var_map, mirror_client_port_,
"DEFAULT.mirror_client_port");
GetOptValue<uint32_t>(var_map, pkt0_tx_buffer_count_,
"DEFAULT.pkt0_tx_buffers");
}

void AgentParam::ParseTaskSectionArguments
Expand Down Expand Up @@ -1205,6 +1212,7 @@ AgentParam::AgentParam(bool enable_flow_options,
enable_hypervisor_options_(enable_hypervisor_options),
enable_service_options_(enable_service_options),
agent_mode_(agent_mode), vhost_(),
pkt0_tx_buffer_count_(Agent::kPkt0TxBufferCount),
agent_name_(), eth_port_(),
eth_port_no_arp_(false), eth_port_encap_type_(),
xmpp_instance_count_(),
Expand Down Expand Up @@ -1319,6 +1327,8 @@ AgentParam::AgentParam(bool enable_flow_options,
"Sandesh send rate limit in messages/sec")
("DEFAULT.subnet_hosts_resolvable",
opt::value<bool>()->default_value(true))
("DEFAULT.pkt0_tx_buffers", opt::value<uint32_t>(),
"Number of tx-buffers for pkt0 interface")
;
options_.add(generic);

Expand Down
6 changes: 6 additions & 0 deletions src/vnsw/agent/init/agent_param.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@ class AgentParam {
uint32_t tbb_schedule_delay() const { return tbb_schedule_delay_; }
uint32_t tbb_keepawake_timeout() const { return tbb_keepawake_timeout_; }

// pkt0 tx buffer
uint32_t pkt0_tx_buffer_count() const { return pkt0_tx_buffer_count_; }
void set_pkt0_tx_buffer_count(uint32_t val) { pkt0_tx_buffer_count_ = val; }
protected:
void set_hypervisor_mode(HypervisorMode m) { hypervisor_mode_ = m; }
virtual void InitFromSystem();
Expand Down Expand Up @@ -375,6 +378,9 @@ class AgentParam {

Agent *agent_;
PortInfo vhost_;
// Number of tx-buffers on pkt0 device
uint32_t pkt0_tx_buffer_count_;

std::string agent_name_;
std::string eth_port_;
bool eth_port_no_arp_;
Expand Down
3 changes: 3 additions & 0 deletions src/vnsw/agent/init/test/cfg.ini
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ agent_base_directory=/var/lib/contrail

mirror_client_port=8999

# pkt0 tx-buffer count
pkt0_tx_buffers=2000

[DISCOVERY]
# IP address and port of discovery server
# port=5998
Expand Down
7 changes: 6 additions & 1 deletion src/vnsw/agent/init/test/test_agent_init.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ TEST_F(FlowTest, Agent_Conf_file_1) {
EXPECT_STREQ(param.agent_base_dir().c_str(), "/var/lib/contrail");
EXPECT_EQ(param.subnet_hosts_resolvable(), true);
EXPECT_TRUE(param.debug());
EXPECT_EQ(param.pkt0_tx_buffer_count(), 2000);
}

TEST_F(FlowTest, Agent_Conf_file_2) {
Expand All @@ -89,6 +90,8 @@ TEST_F(FlowTest, Agent_Conf_file_2) {
EXPECT_EQ(param.metadata_proxy_port(), 8097);
EXPECT_EQ(param.dns_client_port(), 8098);
EXPECT_EQ(param.mirror_client_port(), 8097);
// Default value for pkt0_tx_buffer_count
EXPECT_EQ(param.pkt0_tx_buffer_count(), 1000);
}

TEST_F(FlowTest, Agent_Flows_Option_1) {
Expand Down Expand Up @@ -204,7 +207,7 @@ TEST_F(FlowTest, Agent_Conf_Xen_1) {
}

TEST_F(FlowTest, Agent_Param_1) {
int argc = 21;
int argc = 23;
char *argv[] = {
(char *) "",
(char *) "--config_file",
Expand All @@ -219,6 +222,7 @@ TEST_F(FlowTest, Agent_Param_1) {
(char *) "--DEFAULT.dhcp_relay_mode", (char *)"true",
(char *) "--DEFAULT.agent_base_directory", (char *)"/var/run/contrail",
(char *) "--DEFAULT.subnet_hosts_resolvable", (char *)"false",
(char *) "--DEFAULT.pkt0_tx_buffers", (char *)"3000",
};

AgentParam param;
Expand All @@ -238,6 +242,7 @@ TEST_F(FlowTest, Agent_Param_1) {
EXPECT_EQ(param.dhcp_relay_mode(), true);
EXPECT_STREQ(param.agent_base_dir().c_str(), "/var/run/contrail");
EXPECT_EQ(param.subnet_hosts_resolvable(), false);
EXPECT_EQ(param.pkt0_tx_buffer_count(), 3000);
}

TEST_F(FlowTest, Agent_Arg_Override_Config_1) {
Expand Down

0 comments on commit 4c12770

Please sign in to comment.