This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "".
The branch, master has been updated via 2fc98f7ba2fdcf7df0f04b171bc4bdd65b8cf980 (commit) via 39738abf195e2d3af75133f4ec418614b86e770c (commit) via c3f73eadd8eafb8e8167d5403d69527b896f9de6 (commit) via 7da43047a614ce4c030878ee8bef31725c7b71ef (commit) via bde29f1382ed76fa6b8450b67a249ab2c8c83323 (commit) via 41ab23c89799de4db4de5c3910b70e80f3a7d8f9 (commit) from 4cf18bb4f799e6601c20e54fafbdb58da538de89 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- commit 2fc98f7ba2fdcf7df0f04b171bc4bdd65b8cf980 Author: Petri Savolainen petri.savolainen@nokia.com Date: Wed Jun 15 13:44:20 2016 +0300
linux-gen: sched: add pktio_stop_finalize to scheduler interface
Added pktio_stop_finalize() and related STOP_PENDING and CLOSE_PENDING pktio states. When a scheduled pktio interface is stopped, it's moved into STOP_PENDING state until the scheduler responses with a stop_finalize call. While stop is pending, interface may be closed and thus moved into CLOSE_PENDING state.
Signed-off-by: Petri Savolainen petri.savolainen@nokia.com Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index 28610c1..bdf6316 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -125,11 +125,22 @@ struct pktio_entry { _ipc_pktio_t ipc; /**< IPC pktio data */ }; enum { - PKTIO_STATE_FREE = 0, /**< Not allocated */ - PKTIO_STATE_ALLOCATED, /**< Allocated, open in progress */ - PKTIO_STATE_OPENED, /**< Open completed */ - PKTIO_STATE_STARTED, /**< Start completed */ - PKTIO_STATE_STOPPED /**< Stop completed */ + /* Not allocated */ + PKTIO_STATE_FREE = 0, + /* Close pending on scheduler response. Next state after this + * is PKTIO_STATE_FREE. */ + PKTIO_STATE_CLOSE_PENDING, + /* Open in progress. + Marker for all active states following under. */ + PKTIO_STATE_ACTIVE, + /* Open completed */ + PKTIO_STATE_OPENED, + /* Start completed */ + PKTIO_STATE_STARTED, + /* Stop pending on scheduler response */ + PKTIO_STATE_STOP_PENDING, + /* Stop completed */ + PKTIO_STATE_STOPPED } state; odp_pktio_config_t config; /**< Device configuration */ classifier_t cls; /**< classifier linked with this pktio*/ diff --git a/platform/linux-generic/include/odp_schedule_if.h b/platform/linux-generic/include/odp_schedule_if.h index 029a767..13cdfb3 100644 --- a/platform/linux-generic/include/odp_schedule_if.h +++ b/platform/linux-generic/include/odp_schedule_if.h @@ -61,6 +61,7 @@ extern const schedule_fn_t *sched_fn;
/* Interface for the scheduler */ int sched_cb_pktin_poll(int pktio_index, int num_queue, int index[]); +void sched_cb_pktio_stop_finalize(int pktio_index); int sched_cb_num_pktio(void); int sched_cb_num_queues(void); int sched_cb_queue_prio(uint32_t queue_index); diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index 518b53e..90ecdac 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -163,7 +163,7 @@ static odp_pktio_t alloc_lock_pktio_entry(void) if (is_free(entry)) { odp_pktio_t hdl;
- entry->s.state = PKTIO_STATE_ALLOCATED; + entry->s.state = PKTIO_STATE_ACTIVE; init_pktio_entry(entry); hdl = _odp_cast_scalar(odp_pktio_t, i + 1); return hdl; /* return with entry locked! */ @@ -275,12 +275,22 @@ odp_pktio_t odp_pktio_open(const char *name, odp_pool_t pool, static int _pktio_close(pktio_entry_t *entry) { int ret; + int state = entry->s.state; + + if (state != PKTIO_STATE_OPENED && + state != PKTIO_STATE_STOPPED && + state != PKTIO_STATE_STOP_PENDING) + return -1;
ret = entry->s.ops->close(entry); if (ret) return -1;
- entry->s.state = PKTIO_STATE_FREE; + if (state == PKTIO_STATE_STOP_PENDING) + entry->s.state = PKTIO_STATE_CLOSE_PENDING; + else + entry->s.state = PKTIO_STATE_FREE; + return 0; }
@@ -346,6 +356,11 @@ int odp_pktio_close(odp_pktio_t hdl) if (entry == NULL) return -1;
+ if (entry->s.state == PKTIO_STATE_STARTED) { + ODP_DBG("Missing odp_pktio_stop() before close.\n"); + return -1; + } + if (entry->s.state == PKTIO_STATE_STOPPED) flush_in_queues(entry);
@@ -357,11 +372,10 @@ int odp_pktio_close(odp_pktio_t hdl) entry->s.num_in_queue = 0; entry->s.num_out_queue = 0;
- if (!is_free(entry)) { - res = _pktio_close(entry); - if (res) - ODP_ABORT("unable to close pktio\n"); - } + res = _pktio_close(entry); + if (res) + ODP_ABORT("unable to close pktio\n"); + unlock_entry(entry);
return 0; @@ -465,13 +479,20 @@ int odp_pktio_start(odp_pktio_t hdl) static int _pktio_stop(pktio_entry_t *entry) { int res = 0; + odp_pktin_mode_t mode = entry->s.param.in_mode;
if (entry->s.state != PKTIO_STATE_STARTED) return -1;
if (entry->s.ops->stop) res = entry->s.ops->stop(entry); - if (!res) + + if (res) + return -1; + + if (mode == ODP_PKTIN_MODE_SCHED) + entry->s.state = PKTIO_STATE_STOP_PENDING; + else entry->s.state = PKTIO_STATE_STOPPED;
return res; @@ -508,7 +529,7 @@ odp_pktio_t odp_pktio_lookup(const char *name)
lock_entry(entry);
- if (!is_free(entry) && + if (entry->s.state >= PKTIO_STATE_ACTIVE && strncmp(entry->s.name, name, sizeof(entry->s.name)) == 0) hdl = _odp_cast_scalar(odp_pktio_t, i + 1);
@@ -670,17 +691,13 @@ int sched_cb_pktin_poll(int pktio_index, int num_queue, int index[]) int num, idx; pktio_entry_t *entry; entry = pktio_entry_by_index(pktio_index); + int state = entry->s.state;
- if (odp_unlikely(is_free(entry))) { - ODP_ERR("Bad pktio entry\n"); - return -1; - } - - /* Temporarely needed for odp_pktio_inq_remdef() */ - if (odp_unlikely(entry->s.num_in_queue == 0)) - return -1; + if (odp_unlikely(state != PKTIO_STATE_STARTED)) { + if (state < PKTIO_STATE_ACTIVE || + state == PKTIO_STATE_STOP_PENDING) + return -1;
- if (entry->s.state != PKTIO_STATE_STARTED) { ODP_DBG("interface not started\n"); return 0; } @@ -708,6 +725,30 @@ int sched_cb_pktin_poll(int pktio_index, int num_queue, int index[]) return 0; }
+void sched_cb_pktio_stop_finalize(int pktio_index) +{ + int state; + pktio_entry_t *entry = pktio_entry_by_index(pktio_index); + + lock_entry(entry); + + state = entry->s.state; + + if (state != PKTIO_STATE_STOP_PENDING && + state != PKTIO_STATE_CLOSE_PENDING) { + unlock_entry(entry); + ODP_ERR("Not in a pending state %i\n", state); + return; + } + + if (state == PKTIO_STATE_STOP_PENDING) + entry->s.state = PKTIO_STATE_STOPPED; + else + entry->s.state = PKTIO_STATE_FREE; + + unlock_entry(entry); +} + int sched_cb_num_pktio(void) { return ODP_CONFIG_PKTIO_ENTRIES; @@ -977,8 +1018,10 @@ void odp_pktio_print(odp_pktio_t hdl) " state %s\n", entry->s.state == PKTIO_STATE_STARTED ? "start" : (entry->s.state == PKTIO_STATE_STOPPED ? "stop" : + (entry->s.state == PKTIO_STATE_STOP_PENDING ? + "stop pending" : (entry->s.state == PKTIO_STATE_OPENED ? "opened" : - "unknown"))); + "unknown")))); memset(addr, 0, sizeof(addr)); odp_pktio_mac_addr(hdl, addr, ETH_ALEN); len += snprintf(&str[len], n - len, diff --git a/platform/linux-generic/odp_schedule.c b/platform/linux-generic/odp_schedule.c index 3aaf696..8765f48 100644 --- a/platform/linux-generic/odp_schedule.c +++ b/platform/linux-generic/odp_schedule.c @@ -49,6 +49,9 @@ ODP_STATIC_ASSERT((ODP_SCHED_PRIO_NORMAL > 0) && /* Maximum number of packet input queues per command */ #define MAX_PKTIN 8
+/* Maximum number of packet IO interfaces */ +#define NUM_PKTIO ODP_CONFIG_PKTIO_ENTRIES + /* Mask of queues per priority */ typedef uint8_t pri_mask_t;
@@ -86,6 +89,10 @@ typedef struct { int prio; } queue[ODP_CONFIG_QUEUES];
+ struct { + int num; + } pktio[NUM_PKTIO]; + } sched_global_t;
/* Schedule command */ @@ -419,6 +426,8 @@ static void schedule_pktio_start(int pktio_index, int num_in_queue, if (num_in_queue > MAX_PKTIN) ODP_ABORT("Too many input queues for scheduler\n");
+ sched->pktio[pktio_index].num = num_in_queue; + /* Create a pktio poll command per queue */ for (i = 0; i < num_in_queue; i++) { buf = odp_buffer_alloc(sched->pool); @@ -445,14 +454,19 @@ static void schedule_pktio_start(int pktio_index, int num_in_queue, } }
-static void schedule_pktio_stop(sched_cmd_t *sched_cmd) +static int schedule_pktio_stop(sched_cmd_t *sched_cmd) { - int idx = poll_cmd_queue_idx(sched_cmd->pktio_index, - sched_cmd->index[0]); + int num; + int pktio_index = sched_cmd->pktio_index; + int idx = poll_cmd_queue_idx(pktio_index, sched_cmd->index[0]);
odp_spinlock_lock(&sched->poll_cmd_lock); sched->poll_cmd[idx].num--; + sched->pktio[pktio_index].num--; + num = sched->pktio[pktio_index].num; odp_spinlock_unlock(&sched->poll_cmd_lock); + + return num; }
static void schedule_release_atomic(void) @@ -643,6 +657,7 @@ static int do_schedule(odp_queue_t *out_queue, odp_event_t out_ev[],
for (i = 0; i < POLL_CMD_QUEUES; i++, id++) { odp_queue_t cmd_queue; + int pktio_index;
if (id == POLL_CMD_QUEUES) id = 0; @@ -662,12 +677,18 @@ static int do_schedule(odp_queue_t *out_queue, odp_event_t out_ev[], if (sched_cmd->cmd != SCHED_CMD_POLL_PKTIN) ODP_ABORT("Bad poll command\n");
+ pktio_index = sched_cmd->pktio_index; + /* Poll packet input */ - if (sched_cb_pktin_poll(sched_cmd->pktio_index, + if (sched_cb_pktin_poll(pktio_index, sched_cmd->num, sched_cmd->index)) { - /* Stop scheduling the pktio */ - schedule_pktio_stop(sched_cmd); + /* Pktio stopped or closed. Remove poll command and call + * stop_finalize when all commands of the pktio has + * been removed. */ + if (schedule_pktio_stop(sched_cmd) == 0) + sched_cb_pktio_stop_finalize(pktio_index); + odp_buffer_free(buf); } else { /* Continue scheduling the pktio */ diff --git a/platform/linux-generic/odp_schedule_sp.c b/platform/linux-generic/odp_schedule_sp.c index 0a21b2c..0973239 100644 --- a/platform/linux-generic/odp_schedule_sp.c +++ b/platform/linux-generic/odp_schedule_sp.c @@ -408,10 +408,15 @@ static int schedule_multi(odp_queue_t *from, uint64_t wait, cmd = sched_cmd(NUM_PRIO);
if (cmd && cmd->s.type == CMD_PKTIO) { - sched_cb_pktin_poll(cmd->s.index, cmd->s.num_pktin, - cmd->s.pktin_idx); + if (sched_cb_pktin_poll(cmd->s.index, cmd->s.num_pktin, + cmd->s.pktin_idx)) { + /* Pktio stopped or closed. */ + sched_cb_pktio_stop_finalize(cmd->s.index); + } else { + /* Continue polling pktio. */ + add_tail(cmd); + }
- add_tail(cmd); /* run wait parameter checks under */ cmd = NULL; }
commit 39738abf195e2d3af75133f4ec418614b86e770c Author: Petri Savolainen petri.savolainen@nokia.com Date: Wed Jun 15 13:44:19 2016 +0300
test: pktio: improve start_stop test
Added schedule call after pktio_stop/close to expose potential errors in a pending stop/close in scheduler.
Signed-off-by: Petri Savolainen petri.savolainen@nokia.com Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c index 4fa8b6f..5922ba5 100644 --- a/test/validation/pktio/pktio.c +++ b/test/validation/pktio/pktio.c @@ -336,7 +336,7 @@ static odp_pktio_t create_pktio(int iface_idx, odp_pktin_mode_t imode, pktio_param.out_mode = omode;
pktio = odp_pktio_open(iface, pool[iface_idx], &pktio_param); - CU_ASSERT(pktio != ODP_PKTIO_INVALID); + CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID); CU_ASSERT(odp_pktio_to_u64(pktio) != odp_pktio_to_u64(ODP_PKTIO_INVALID));
@@ -1510,6 +1510,7 @@ void pktio_test_statistics_counters(void) void pktio_test_start_stop(void) { odp_pktio_t pktio[MAX_NUM_IFACES]; + odp_pktio_t pktio_in; odp_packet_t pkt; odp_packet_t tx_pkt[1000]; uint32_t pkt_seq[1000]; @@ -1588,11 +1589,11 @@ void pktio_test_start_stop(void)
if (num_ifaces > 1) - alloc = create_packets(tx_pkt, pkt_seq, 1000, pktio[0], - pktio[1]); + pktio_in = pktio[1]; else - alloc = create_packets(tx_pkt, pkt_seq, 1000, pktio[0], - pktio[0]); + pktio_in = pktio[0]; + + alloc = create_packets(tx_pkt, pkt_seq, 1000, pktio[0], pktio_in);
/* send */ for (pkts = 0; pkts != alloc; ) { @@ -1622,6 +1623,13 @@ void pktio_test_start_stop(void) CU_ASSERT(odp_pktio_stop(pktio[i]) == 0); CU_ASSERT(odp_pktio_close(pktio[i]) == 0); } + + /* Verify that a schedule call after stop and close does not generate + errors. */ + ev = odp_schedule(NULL, wait); + CU_ASSERT(ev == ODP_EVENT_INVALID); + if (ev != ODP_EVENT_INVALID) + odp_event_free(ev); }
/*
commit c3f73eadd8eafb8e8167d5403d69527b896f9de6 Author: Petri Savolainen petri.savolainen@nokia.com Date: Wed Jun 15 13:44:18 2016 +0300
test: validation: add missing pktio_stop calls
When pktio_start has been called, pktio_stop must be called before pktio_close.
Signed-off-by: Petri Savolainen petri.savolainen@nokia.com Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c index 8f66880..4fa8b6f 100644 --- a/test/validation/pktio/pktio.c +++ b/test/validation/pktio/pktio.c @@ -1801,8 +1801,11 @@ void pktio_test_send_failure(void) odp_packet_free(pkt_tbl[i]); }
- if (pktio_rx != pktio_tx) + if (pktio_rx != pktio_tx) { + CU_ASSERT(odp_pktio_stop(pktio_rx) == 0); CU_ASSERT(odp_pktio_close(pktio_rx) == 0); + } + CU_ASSERT(odp_pktio_stop(pktio_tx) == 0); CU_ASSERT(odp_pktio_close(pktio_tx) == 0); CU_ASSERT(odp_pool_destroy(pkt_pool) == 0); } diff --git a/test/validation/traffic_mngr/traffic_mngr.c b/test/validation/traffic_mngr/traffic_mngr.c index ce9d038..0645370 100644 --- a/test/validation/traffic_mngr/traffic_mngr.c +++ b/test/validation/traffic_mngr/traffic_mngr.c @@ -2089,6 +2089,9 @@ int traffic_mngr_suite_term(void) if (odp_pool_destroy(pools[iface]) != 0) return -1;
+ if (odp_pktio_stop(pktios[iface]) != 0) + return -1; + if (odp_pktio_close(pktios[iface]) != 0) return -1; }
commit 7da43047a614ce4c030878ee8bef31725c7b71ef Author: Petri Savolainen petri.savolainen@nokia.com Date: Wed Jun 15 13:44:17 2016 +0300
linux-gen: sched: use pktio index in scheduler interface
Replaced pktio handle with pktio index in scheduler interface. Indexes are used in implementation internal interfaces for performance reasons.
Signed-off-by: Petri Savolainen petri.savolainen@nokia.com Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/include/odp_schedule_if.h b/platform/linux-generic/include/odp_schedule_if.h index 86a117f..029a767 100644 --- a/platform/linux-generic/include/odp_schedule_if.h +++ b/platform/linux-generic/include/odp_schedule_if.h @@ -12,7 +12,6 @@ extern "C" { #endif
#include <odp/api/queue.h> -#include <odp/api/packet_io.h> #include <odp/api/schedule.h>
/* Constants defined by the scheduler. These should be converted into interface @@ -21,7 +20,7 @@ extern "C" { /* Number of ordered locks per queue */ #define SCHEDULE_ORDERED_LOCKS_PER_QUEUE 2
-typedef void (*schedule_pktio_start_fn_t)(odp_pktio_t pktio, int num_in_queue, +typedef void (*schedule_pktio_start_fn_t)(int pktio_index, int num_in_queue, int in_queue_idx[]); typedef int (*schedule_thr_add_fn_t)(odp_schedule_group_t group, int thr); typedef int (*schedule_thr_rem_fn_t)(odp_schedule_group_t group, int thr); diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index 9dff9f6..518b53e 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -456,7 +456,7 @@ int odp_pktio_start(odp_pktio_t hdl) } }
- sched_fn->pktio_start(hdl, num, index); + sched_fn->pktio_start(pktio_to_id(hdl), num, index); }
return res; diff --git a/platform/linux-generic/odp_schedule.c b/platform/linux-generic/odp_schedule.c index f572468..3aaf696 100644 --- a/platform/linux-generic/odp_schedule.c +++ b/platform/linux-generic/odp_schedule.c @@ -98,7 +98,6 @@ typedef struct { };
struct { - odp_pktio_t pktio; int pktio_index; int num; int index[MAX_PKTIN]; @@ -404,12 +403,12 @@ static void schedule_destroy_queue(uint32_t queue_index) sched->queue[queue_index].prio = 0; }
-static int poll_cmd_queue_idx(odp_pktio_t pktio, int in_queue_idx) +static int poll_cmd_queue_idx(int pktio_index, int in_queue_idx) { - return (POLL_CMD_QUEUES - 1) & (odp_pktio_index(pktio) ^ in_queue_idx); + return (POLL_CMD_QUEUES - 1) & (pktio_index ^ in_queue_idx); }
-static void schedule_pktio_start(odp_pktio_t pktio, int num_in_queue, +static void schedule_pktio_start(int pktio_index, int num_in_queue, int in_queue_idx[]) { odp_buffer_t buf; @@ -429,12 +428,11 @@ static void schedule_pktio_start(odp_pktio_t pktio, int num_in_queue,
sched_cmd = odp_buffer_addr(buf); sched_cmd->cmd = SCHED_CMD_POLL_PKTIN; - sched_cmd->pktio = pktio; - sched_cmd->pktio_index = odp_pktio_index(pktio); + sched_cmd->pktio_index = pktio_index; sched_cmd->num = 1; sched_cmd->index[0] = in_queue_idx[i];
- idx = poll_cmd_queue_idx(pktio, in_queue_idx[i]); + idx = poll_cmd_queue_idx(pktio_index, in_queue_idx[i]);
odp_spinlock_lock(&sched->poll_cmd_lock); sched->poll_cmd[idx].num++; @@ -449,7 +447,8 @@ static void schedule_pktio_start(odp_pktio_t pktio, int num_in_queue,
static void schedule_pktio_stop(sched_cmd_t *sched_cmd) { - int idx = poll_cmd_queue_idx(sched_cmd->pktio, sched_cmd->index[0]); + int idx = poll_cmd_queue_idx(sched_cmd->pktio_index, + sched_cmd->index[0]);
odp_spinlock_lock(&sched->poll_cmd_lock); sched->poll_cmd[idx].num--; diff --git a/platform/linux-generic/odp_schedule_sp.c b/platform/linux-generic/odp_schedule_sp.c index 7162c7b..0a21b2c 100644 --- a/platform/linux-generic/odp_schedule_sp.c +++ b/platform/linux-generic/odp_schedule_sp.c @@ -7,6 +7,7 @@ #include <string.h> #include <odp/api/ticketlock.h> #include <odp/api/thread.h> +#include <odp/api/time.h> #include <odp/api/schedule.h> #include <odp_schedule_if.h> #include <odp_debug_internal.h> @@ -340,16 +341,15 @@ static int ord_enq_multi(uint32_t queue_index, void *buf_hdr[], int num, return 0; }
-static void pktio_start(odp_pktio_t pktio, int num, int pktin_idx[]) +static void pktio_start(int pktio_index, int num, int pktin_idx[]) { - int pi, i; + int i; sched_cmd_t *cmd;
- ODP_DBG("pktio:%" PRIu64 ", %i pktin queues %i\n", - odp_pktio_to_u64(pktio), num, pktin_idx[0]); + ODP_DBG("pktio index: %i, %i pktin queues %i\n", + pktio_index, num, pktin_idx[0]);
- pi = odp_pktio_index(pktio); - cmd = &sched_global.pktio_cmd[pi]; + cmd = &sched_global.pktio_cmd[pktio_index];
if (num > NUM_PKTIN) ODP_ABORT("Supports only %i pktin queues per interface\n",
commit bde29f1382ed76fa6b8450b67a249ab2c8c83323 Author: Petri Savolainen petri.savolainen@nokia.com Date: Wed Jun 15 13:44:16 2016 +0300
linux-gen: sched: call pktio_start only once
Pktio calls the scheduler interface function pktio_start once per odp_pktio_start(). Scheduler handles internally creation of multiple poll commands.
Signed-off-by: Petri Savolainen petri.savolainen@nokia.com Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index 0e47533..9dff9f6 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -444,17 +444,19 @@ int odp_pktio_start(odp_pktio_t hdl)
if (mode == ODP_PKTIN_MODE_SCHED) { unsigned i; + unsigned num = entry->s.num_in_queue; + int index[num];
- for (i = 0; i < entry->s.num_in_queue; i++) { - int index = i; + for (i = 0; i < num; i++) { + index[i] = i;
if (entry->s.in_queue[i].queue == ODP_QUEUE_INVALID) { ODP_ERR("No input queue\n"); return -1; } - - sched_fn->pktio_start(hdl, 1, &index); } + + sched_fn->pktio_start(hdl, num, index); }
return res; diff --git a/platform/linux-generic/odp_schedule.c b/platform/linux-generic/odp_schedule.c index 3b97909..f572468 100644 --- a/platform/linux-generic/odp_schedule.c +++ b/platform/linux-generic/odp_schedule.c @@ -417,33 +417,34 @@ static void schedule_pktio_start(odp_pktio_t pktio, int num_in_queue, odp_queue_t queue; int i, idx;
- buf = odp_buffer_alloc(sched->pool); - - if (buf == ODP_BUFFER_INVALID) - ODP_ABORT("Sched pool empty\n"); - - sched_cmd = odp_buffer_addr(buf); - sched_cmd->cmd = SCHED_CMD_POLL_PKTIN; - sched_cmd->pktio = pktio; - sched_cmd->pktio_index = odp_pktio_index(pktio); - sched_cmd->num = num_in_queue; - if (num_in_queue > MAX_PKTIN) ODP_ABORT("Too many input queues for scheduler\n");
- for (i = 0; i < num_in_queue; i++) - sched_cmd->index[i] = in_queue_idx[i]; + /* Create a pktio poll command per queue */ + for (i = 0; i < num_in_queue; i++) { + buf = odp_buffer_alloc(sched->pool);
- idx = poll_cmd_queue_idx(pktio, in_queue_idx[0]); + if (buf == ODP_BUFFER_INVALID) + ODP_ABORT("Sched pool empty\n");
- odp_spinlock_lock(&sched->poll_cmd_lock); - sched->poll_cmd[idx].num++; - odp_spinlock_unlock(&sched->poll_cmd_lock); + sched_cmd = odp_buffer_addr(buf); + sched_cmd->cmd = SCHED_CMD_POLL_PKTIN; + sched_cmd->pktio = pktio; + sched_cmd->pktio_index = odp_pktio_index(pktio); + sched_cmd->num = 1; + sched_cmd->index[0] = in_queue_idx[i]; + + idx = poll_cmd_queue_idx(pktio, in_queue_idx[i]);
- queue = sched->poll_cmd[idx].queue; + odp_spinlock_lock(&sched->poll_cmd_lock); + sched->poll_cmd[idx].num++; + odp_spinlock_unlock(&sched->poll_cmd_lock);
- if (odp_queue_enq(queue, odp_buffer_to_event(buf))) - ODP_ABORT("schedule_pktio_start failed\n"); + queue = sched->poll_cmd[idx].queue; + + if (odp_queue_enq(queue, odp_buffer_to_event(buf))) + ODP_ABORT("schedule_pktio_start failed\n"); + } }
static void schedule_pktio_stop(sched_cmd_t *sched_cmd)
commit 41ab23c89799de4db4de5c3910b70e80f3a7d8f9 Author: Petri Savolainen petri.savolainen@nokia.com Date: Wed Jun 15 13:44:15 2016 +0300
linux-gen: pktio: simplify state handling
Removed 'int taken', so that 'enum state' is the only variable which holds pktio entry state. Added PKTIO_ prefix for better name space protection and code readability.
Signed-off-by: Petri Savolainen petri.savolainen@nokia.com Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index 53683b3..28610c1 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -109,7 +109,6 @@ struct pktio_entry { /* These two locks together lock the whole pktio device */ odp_ticketlock_t rxl; /**< RX ticketlock */ odp_ticketlock_t txl; /**< TX ticketlock */ - int taken; /**< is entry taken(1) or free(0) */ int cls_enabled; /**< is classifier enabled */ odp_pktio_t handle; /**< pktio handle */ union { @@ -126,10 +125,11 @@ struct pktio_entry { _ipc_pktio_t ipc; /**< IPC pktio data */ }; enum { - STATE_OPENED = 0, /**< After open() */ - STATE_STARTED, /**< After start() */ - STATE_STOPPED /**< Same as OPENED, but only happens - after STARTED */ + PKTIO_STATE_FREE = 0, /**< Not allocated */ + PKTIO_STATE_ALLOCATED, /**< Allocated, open in progress */ + PKTIO_STATE_OPENED, /**< Open completed */ + PKTIO_STATE_STARTED, /**< Start completed */ + PKTIO_STATE_STOPPED /**< Stop completed */ } state; odp_pktio_config_t config; /**< Device configuration */ classifier_t cls; /**< classifier linked with this pktio*/ @@ -171,8 +171,6 @@ typedef struct { pktio_entry_t entries[ODP_CONFIG_PKTIO_ENTRIES]; } pktio_table_t;
-int is_free(pktio_entry_t *entry); - typedef struct pktio_if_ops { const char *name; void (*print)(pktio_entry_t *pktio_entry); diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index 8d88aa3..0e47533 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -104,19 +104,9 @@ int odp_pktio_init_local(void) return 0; }
-int is_free(pktio_entry_t *entry) +static inline int is_free(pktio_entry_t *entry) { - return (entry->s.taken == 0); -} - -static void set_free(pktio_entry_t *entry) -{ - entry->s.taken = 0; -} - -static void set_taken(pktio_entry_t *entry) -{ - entry->s.taken = 1; + return (entry->s.state == PKTIO_STATE_FREE); }
static void lock_entry(pktio_entry_t *entry) @@ -153,7 +143,6 @@ static void init_out_queues(pktio_entry_t *entry)
static void init_pktio_entry(pktio_entry_t *entry) { - set_taken(entry); pktio_cls_enabled_set(entry, 0);
init_in_queues(entry); @@ -174,6 +163,7 @@ static odp_pktio_t alloc_lock_pktio_entry(void) if (is_free(entry)) { odp_pktio_t hdl;
+ entry->s.state = PKTIO_STATE_ALLOCATED; init_pktio_entry(entry); hdl = _odp_cast_scalar(odp_pktio_t, i + 1); return hdl; /* return with entry locked! */ @@ -228,13 +218,13 @@ static odp_pktio_t setup_pktio_entry(const char *name, odp_pool_t pool, }
if (ret != 0) { - set_free(pktio_entry); + pktio_entry->s.state = PKTIO_STATE_FREE; hdl = ODP_PKTIO_INVALID; ODP_ERR("Unable to init any I/O type.\n"); } else { snprintf(pktio_entry->s.name, sizeof(pktio_entry->s.name), "%s", name); - pktio_entry->s.state = STATE_OPENED; + pktio_entry->s.state = PKTIO_STATE_OPENED; }
unlock_entry(pktio_entry); @@ -290,7 +280,7 @@ static int _pktio_close(pktio_entry_t *entry) if (ret) return -1;
- set_free(entry); + entry->s.state = PKTIO_STATE_FREE; return 0; }
@@ -356,7 +346,7 @@ int odp_pktio_close(odp_pktio_t hdl) if (entry == NULL) return -1;
- if (entry->s.state == STATE_STOPPED) + if (entry->s.state == PKTIO_STATE_STOPPED) flush_in_queues(entry);
lock_entry(entry); @@ -412,7 +402,7 @@ int odp_pktio_config(odp_pktio_t hdl, const odp_pktio_config_t *config) }
lock_entry(entry); - if (entry->s.state == STATE_STARTED) { + if (entry->s.state == PKTIO_STATE_STARTED) { unlock_entry(entry); ODP_DBG("pktio %s: not stopped\n", entry->s.name); return -1; @@ -439,14 +429,14 @@ int odp_pktio_start(odp_pktio_t hdl) return -1;
lock_entry(entry); - if (entry->s.state == STATE_STARTED) { + if (entry->s.state == PKTIO_STATE_STARTED) { unlock_entry(entry); return -1; } if (entry->s.ops->start) res = entry->s.ops->start(entry); if (!res) - entry->s.state = STATE_STARTED; + entry->s.state = PKTIO_STATE_STARTED;
unlock_entry(entry);
@@ -474,13 +464,13 @@ static int _pktio_stop(pktio_entry_t *entry) { int res = 0;
- if (entry->s.state != STATE_STARTED) + if (entry->s.state != PKTIO_STATE_STARTED) return -1;
if (entry->s.ops->stop) res = entry->s.ops->stop(entry); if (!res) - entry->s.state = STATE_STOPPED; + entry->s.state = PKTIO_STATE_STOPPED;
return res; } @@ -688,7 +678,7 @@ int sched_cb_pktin_poll(int pktio_index, int num_queue, int index[]) if (odp_unlikely(entry->s.num_in_queue == 0)) return -1;
- if (entry->s.state != STATE_STARTED) { + if (entry->s.state != PKTIO_STATE_STARTED) { ODP_DBG("interface not started\n"); return 0; } @@ -765,7 +755,7 @@ int odp_pktio_promisc_mode_set(odp_pktio_t hdl, odp_bool_t enable) ODP_DBG("already freed pktio\n"); return -1; } - if (entry->s.state == STATE_STARTED) { + if (entry->s.state == PKTIO_STATE_STARTED) { unlock_entry(entry); return -1; } @@ -983,10 +973,10 @@ void odp_pktio_print(odp_pktio_t hdl) " type %s\n", entry->s.ops->name); len += snprintf(&str[len], n - len, " state %s\n", - entry->s.state == STATE_STARTED ? "start" : - (entry->s.state == STATE_STOPPED ? "stop" : - (entry->s.state == STATE_OPENED ? "opened" : - "unknown"))); + entry->s.state == PKTIO_STATE_STARTED ? "start" : + (entry->s.state == PKTIO_STATE_STOPPED ? "stop" : + (entry->s.state == PKTIO_STATE_OPENED ? "opened" : + "unknown"))); memset(addr, 0, sizeof(addr)); odp_pktio_mac_addr(hdl, addr, ETH_ALEN); len += snprintf(&str[len], n - len, @@ -1031,7 +1021,7 @@ int odp_pktio_term_global(void) continue;
lock_entry(pktio_entry); - if (pktio_entry->s.state == STATE_STARTED) { + if (pktio_entry->s.state == PKTIO_STATE_STARTED) { ret = _pktio_stop(pktio_entry); if (ret) ODP_ABORT("unable to stop pktio %s\n", @@ -1155,7 +1145,7 @@ int odp_pktin_queue_config(odp_pktio_t pktio, return -1; }
- if (entry->s.state == STATE_STARTED) { + if (entry->s.state == PKTIO_STATE_STARTED) { ODP_DBG("pktio %s: not stopped\n", entry->s.name); return -1; } @@ -1268,7 +1258,7 @@ int odp_pktout_queue_config(odp_pktio_t pktio, return -1; }
- if (entry->s.state == STATE_STARTED) { + if (entry->s.state == PKTIO_STATE_STARTED) { ODP_DBG("pktio %s: not stopped\n", entry->s.name); return -1; } diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c index 2225dfe..85bb07c 100644 --- a/platform/linux-generic/pktio/dpdk.c +++ b/platform/linux-generic/pktio/dpdk.c @@ -349,7 +349,7 @@ static int dpdk_close(pktio_entry_t *pktio_entry) rte_pktmbuf_free(pkt_dpdk->rx_cache[i].s.pkt[idx++]); }
- if (pktio_entry->s.state != STATE_OPENED) + if (pktio_entry->s.state != PKTIO_STATE_OPENED) rte_eth_dev_close(pkt_dpdk->port_id);
return 0; @@ -814,7 +814,7 @@ static int dpdk_recv(pktio_entry_t *pktio_entry, int index, int i; unsigned cache_idx;
- if (odp_unlikely(pktio_entry->s.state != STATE_STARTED)) + if (odp_unlikely(pktio_entry->s.state != PKTIO_STATE_STARTED)) return 0;
if (!pkt_dpdk->lockless_rx) @@ -881,7 +881,7 @@ static int dpdk_send(pktio_entry_t *pktio_entry, int index, int i; int mbufs;
- if (odp_unlikely(pktio_entry->s.state != STATE_STARTED)) + if (odp_unlikely(pktio_entry->s.state != PKTIO_STATE_STARTED)) return 0;
if (!pktio_entry->s.pkt_dpdk.lockless_tx) diff --git a/platform/linux-generic/pktio/netmap.c b/platform/linux-generic/pktio/netmap.c index 4ea0d4a..457ea53 100644 --- a/platform/linux-generic/pktio/netmap.c +++ b/platform/linux-generic/pktio/netmap.c @@ -703,7 +703,7 @@ static int netmap_recv(pktio_entry_t *pktio_entry, int index, int max_fd = 0; fd_set empty_rings;
- if (odp_unlikely(pktio_entry->s.state != STATE_STARTED)) + if (odp_unlikely(pktio_entry->s.state != PKTIO_STATE_STARTED)) return 0;
FD_ZERO(&empty_rings); @@ -758,7 +758,7 @@ static int netmap_send(pktio_entry_t *pktio_entry, int index, unsigned slot_id; char *buf;
- if (odp_unlikely(pktio_entry->s.state != STATE_STARTED)) + if (odp_unlikely(pktio_entry->s.state != PKTIO_STATE_STARTED)) return 0;
/* Only one netmap tx ring per pktout queue */ diff --git a/platform/linux-generic/pktio/pcap.c b/platform/linux-generic/pktio/pcap.c index b719849..c967e70 100644 --- a/platform/linux-generic/pktio/pcap.c +++ b/platform/linux-generic/pktio/pcap.c @@ -216,7 +216,7 @@ static int pcapif_recv_pkt(pktio_entry_t *pktio_entry, int index ODP_UNUSED,
odp_ticketlock_lock(&pktio_entry->s.rxl);
- if (pktio_entry->s.state != STATE_STARTED || !pcap->rx) { + if (pktio_entry->s.state != PKTIO_STATE_STARTED || !pcap->rx) { odp_ticketlock_unlock(&pktio_entry->s.rxl); return 0; } @@ -311,7 +311,7 @@ static int pcapif_send_pkt(pktio_entry_t *pktio_entry, int index ODP_UNUSED,
odp_ticketlock_lock(&pktio_entry->s.txl);
- if (pktio_entry->s.state != STATE_STARTED) { + if (pktio_entry->s.state != PKTIO_STATE_STARTED) { odp_ticketlock_unlock(&pktio_entry->s.txl); return 0; }
-----------------------------------------------------------------------
Summary of changes: .../linux-generic/include/odp_packet_io_internal.h | 23 ++-- platform/linux-generic/include/odp_schedule_if.h | 4 +- platform/linux-generic/odp_packet_io.c | 135 +++++++++++++-------- platform/linux-generic/odp_schedule.c | 77 +++++++----- platform/linux-generic/odp_schedule_sp.c | 23 ++-- platform/linux-generic/pktio/dpdk.c | 6 +- platform/linux-generic/pktio/netmap.c | 4 +- platform/linux-generic/pktio/pcap.c | 4 +- test/validation/pktio/pktio.c | 23 +++- test/validation/traffic_mngr/traffic_mngr.c | 3 + 10 files changed, 193 insertions(+), 109 deletions(-)
hooks/post-receive