Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable OF-compatible queue handling #79

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix a few typos and enforce guideline compliance
  • Loading branch information
eugene-che committed May 10, 2016
commit ca071f31c0bac44cc38d68748eb8cd85f6ea7b64
3 changes: 2 additions & 1 deletion mk/make_dpdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ edit_dpdk_config CONFIG_RTE_LIBRTE_PMD_PCAP=n $NEWCONFIG
edit_dpdk_config CONFIG_RTE_APP_TEST=n $NEWCONFIG
edit_dpdk_config CONFIG_RTE_TEST_PMD=n $NEWCONFIG
edit_dpdk_config CONFIG_RTE_IXGBE_INC_VECTOR=n $NEWCONFIG
eidt_dpdk_config CONFIG_RTE_SCHED_COLLECT_STATS=y $NEWCONFIG
edit_dpdk_config CONFIG_RTE_SCHED_COLLECT_STATS=y $NEWCONFIG
edit_dpdk_config CONFIG_RTE_SCHED_RED=y $NEWCONFIG

Copy link

@ynkjm ynkjm May 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By default in DPDK, RED-marked packet is not dropped so the following command seems necessary.

eidt_dpdk_config  CONFIG_RTE_SCHED_RED=y $NEWCONFIG

${MAKE} T=${NEW_TARGET} config && ${MAKE} && \
RTE_SDK="${TOPDIR}/${DPDKDIR}" \
Expand Down
2 changes: 1 addition & 1 deletion src/dataplane/dpdk/dpdk_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ app_lcore_io_tx_flush(struct app_lcore_params_io *lp, __UNUSED void *arg) {
lp->tx.mbuf_out[portid].array,
(uint16_t)n_mbufs);

DPRINTF("flus: sent %d pkts\n", n_pkts);
DPRINTF("flush: sent %d pkts\n", n_pkts);

if (unlikely(n_pkts < n_mbufs)) {
uint32_t k;
Expand Down
2 changes: 1 addition & 1 deletion src/dataplane/mgr/dp_apis.c
Original file line number Diff line number Diff line change
Expand Up @@ -1319,7 +1319,7 @@ dp_queue_create(const char *name,
goto out;
}

// TODO: Allow queeus with the same ids
// TODO: Allow queues with the same ids
// Switch should permit multiple queues with the same id
// while each of these queues belongs to a its own port.
// We should either enforce unique pairs <port, switch>,
Expand Down
63 changes: 47 additions & 16 deletions src/dataplane/mgr/queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ append_queue_config(struct interface *ifp, uint32_t qidx,
uint32_t port_speed;

queue = calloc(1, sizeof(struct packet_queue));
if (!queue) return LAGOPUS_RESULT_NO_MEMORY;
if (!queue) {
return LAGOPUS_RESULT_NO_MEMORY;
}

TAILQ_INSERT_TAIL(packet_queue_list, queue, entry);
queue->ofp.len = sizeof(struct ofp_packet_queue);
Expand All @@ -45,11 +47,17 @@ append_queue_config(struct interface *ifp, uint32_t qidx,
TAILQ_INIT(&queue->queue_property_list);

port_speed = ifp->port->ofp_port.curr_speed;
if (!port_speed) port_speed = ifp->port->ofp_port.max_speed;
if (!port_speed) return LAGOPUS_RESULT_OK;
if (!port_speed) {
port_speed = ifp->port->ofp_port.max_speed;
}
if (!port_speed) {
return LAGOPUS_RESULT_OK;
}

property = calloc(1, sizeof(struct queue_property));
if (!property) return LAGOPUS_RESULT_NO_MEMORY;
if (!property) {
return LAGOPUS_RESULT_NO_MEMORY;
}

TAILQ_INSERT_TAIL(&queue->queue_property_list, property, entry);
// rate is measured in 1/10 of a percent of a current port bandwidth
Expand All @@ -60,7 +68,9 @@ append_queue_config(struct interface *ifp, uint32_t qidx,
queue->ofp.len += property->ofp.len;

property = calloc(1, sizeof(struct queue_property));
if (!property) return LAGOPUS_RESULT_NO_MEMORY;
if (!property) {
return LAGOPUS_RESULT_NO_MEMORY;
}

TAILQ_INSERT_TAIL(&queue->queue_property_list, property, entry);
// rate is measured in 1/10 of a percent of a current port bandwidth
Expand All @@ -78,7 +88,9 @@ static lagopus_result_t
append_ifp_queue_config(struct interface *ifp, struct packet_queue_list *packet_queue_list) {
for(uint32_t i = 0; i < (uint32_t)ifp->ifqueue.nqueue; ++i) {
lagopus_result_t rv = append_queue_config(ifp, i, packet_queue_list);
if (rv != LAGOPUS_RESULT_OK) return rv;
if (rv != LAGOPUS_RESULT_OK) {
return rv;
}
}
return LAGOPUS_RESULT_OK;
}
Expand Down Expand Up @@ -112,8 +124,12 @@ ofp_packet_queue_get(uint64_t dpid,
(void) error;

bridge = dp_bridge_lookup_by_dpid(dpid);
if (!bridge) return LAGOPUS_RESULT_NOT_FOUND;
if (!queue_request) return LAGOPUS_RESULT_INVALID_ARGS;
if (!bridge) {
return LAGOPUS_RESULT_NOT_FOUND;
}
if (!queue_request) {
return LAGOPUS_RESULT_INVALID_ARGS;
}

if (queue_request->port == OFPP_ANY) {
rv = lagopus_hashmap_iterate(&bridge->ports, iterate_port_queue_config, packet_queue_list);
Expand Down Expand Up @@ -152,9 +168,11 @@ append_queue_stats(struct interface *ifp, uint32_t qidx,
#endif // HAVE_DPDK

stats = calloc(1, sizeof(struct queue_stats));
if (!stats) return LAGOPUS_RESULT_NO_MEMORY;
TAILQ_INSERT_TAIL(queue_stats_list, stats, entry);
if (!stats) {
return LAGOPUS_RESULT_NO_MEMORY;
}

TAILQ_INSERT_TAIL(queue_stats_list, stats, entry);
stats->ofp.port_no = ifp->port->ofp_port.port_no;
stats->ofp.queue_id = ifp->ifqueue.queues[qidx]->id;

Expand All @@ -180,12 +198,16 @@ struct queue_stats_context {

static lagopus_result_t
append_ifp_queue_stats(struct interface *ifp, struct queue_stats_context *queue_stats_context) {
if (!ifp->sched_port) return LAGOPUS_RESULT_NOT_FOUND;
if (!ifp->sched_port) {
return LAGOPUS_RESULT_NOT_FOUND;
}

if (queue_stats_context->ofp_queue_id == OFPQ_ALL) {
for(uint32_t i = 0; i < (uint32_t)ifp->ifqueue.nqueue; ++i) {
lagopus_result_t rv = append_queue_stats(ifp, i, queue_stats_context->queue_stats_list);
if (rv != LAGOPUS_RESULT_OK) return rv;
if (rv != LAGOPUS_RESULT_OK) {
return rv;
}
}
return LAGOPUS_RESULT_OK;
}
Expand All @@ -206,7 +228,10 @@ iterate_port_queue_stats(void *key, void *port,
(void) key;
(void) he;

if (!port || !((struct port*)port)->interface) return true;
if (!port || !((struct port*)port)->interface) {
return true;
}

switch (append_ifp_queue_stats(((struct port*)port)->interface, queue_stats_context)) {
// continue iteration when returned status is
case LAGOPUS_RESULT_OK: break;
Expand All @@ -233,8 +258,12 @@ ofp_queue_stats_request_get(uint64_t dpid,
(void) error;

bridge = dp_bridge_lookup_by_dpid(dpid);
if (!bridge) return LAGOPUS_RESULT_NOT_FOUND;
if (!queue_stats_request) return LAGOPUS_RESULT_INVALID_ARGS;
if (!bridge) {
return LAGOPUS_RESULT_NOT_FOUND;
}
if (!queue_stats_request) {
return LAGOPUS_RESULT_INVALID_ARGS;
}

// prepare request context to search queues on multiple ports
queue_stats_context.queue_stats_list = queue_stats_list;
Expand All @@ -244,7 +273,9 @@ ofp_queue_stats_request_get(uint64_t dpid,
rv = lagopus_hashmap_iterate(&bridge->ports, iterate_port_queue_stats, &queue_stats_context);
} else {
struct port *port = port_lookup(&bridge->ports, queue_stats_request->port_no);
if (!port || !port->interface) return LAGOPUS_RESULT_NOT_FOUND;
if (!port || !port->interface) {
return LAGOPUS_RESULT_NOT_FOUND;
}
rv = append_ifp_queue_stats(port->interface, &queue_stats_context);
}

Expand Down