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, caterpillar has been updated via 4d17f8ae64aba0e6f24877be30f86ae5880cef7e (commit) via 0b9b3c3ee67e11b798c41ac6ac8b71f80546f1d2 (commit) via 055516066c0a1104501cfd1050f0407fbec230c1 (commit) via a3f913fe4d0008641684b90d7209d23296a48767 (commit) via 2d0ddc0917fa97d4ee9d1ec7009fe1abb9c42085 (commit) via 9eebbe7d21f0b933190fd910c54c872eecfe180e (commit) from bbbe6c0ef65c16f6d7d327712f177fbf6740e96f (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 4d17f8ae64aba0e6f24877be30f86ae5880cef7e Author: Joyce Kong joyce.kong@arm.com Date: Thu Dec 7 14:19:15 2017 +0800
linux-generic: buffer: remove handle/index in metadata
Signed-off-by: Joyce Kong joyce.kong@arm.com Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Yi He yi.he@linaro.org
diff --git a/platform/linux-generic/buffer/generic.c b/platform/linux-generic/buffer/generic.c index cf99407c..543cc530 100644 --- a/platform/linux-generic/buffer/generic.c +++ b/platform/linux-generic/buffer/generic.c @@ -193,7 +193,7 @@ static inline void buffer_free_to_pool(pool_t *pool, ring = &pool->ring->hdr; mask = pool->ring_mask; for (i = 0; i < num; i++) - buf_index[i] = buf_hdr[i]->index; + buf_index[i] = buf_hdr_to_index(buf_hdr[i]);
ring_enq_multi(ring, mask, buf_index, num);
@@ -233,7 +233,7 @@ static inline void buffer_free_to_pool(pool_t *pool, }
for (i = 0; i < num; i++) - cache->buf_index[cache_num + i] = buf_hdr[i]->index; + cache->buf_index[cache_num + i] = buf_hdr_to_index(buf_hdr[i]);
cache->num = cache_num + num; } diff --git a/platform/linux-generic/include/odp_buffer_internal.h b/platform/linux-generic/include/odp_buffer_internal.h index 514e2479..b8e8c171 100644 --- a/platform/linux-generic/include/odp_buffer_internal.h +++ b/platform/linux-generic/include/odp_buffer_internal.h @@ -43,10 +43,6 @@ typedef struct seg_entry_t {
/* Common buffer header */ struct odp_buffer_hdr_t { - - /* Buffer index in the pool */ - uint32_t index; - /* Total segment count */ uint16_t segcount;
diff --git a/platform/linux-generic/include/odp_pool_internal.h b/platform/linux-generic/include/odp_pool_internal.h index a124697e..cf1a423f 100644 --- a/platform/linux-generic/include/odp_pool_internal.h +++ b/platform/linux-generic/include/odp_pool_internal.h @@ -139,6 +139,14 @@ static inline odp_buffer_hdr_t *buf_hdr_from_index(pool_t *pool, return buf_hdr; }
+static inline uint32_t buf_hdr_to_index(odp_buffer_hdr_t *buf_hdr) +{ + pool_t *pool = buf_hdr->pool_ptr; + uint32_t index = ((uint8_t *)buf_hdr - pool->base_addr) + / pool->block_size; + + return index; +} int buffer_alloc_multi(pool_t *pool, odp_buffer_hdr_t *buf_hdr[], int num); void buffer_free_multi(odp_buffer_hdr_t *buf_hdr[], int num_free);
diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 853d3baa..cb20eeda 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -10,6 +10,7 @@ #include <odp/api/packet.h> #include <odp_packet_internal.h> #include <odp_debug_internal.h> +#include <odp_pool_internal.h> #include <odp/api/hints.h> #include <odp/api/byteorder.h>
@@ -1796,7 +1797,8 @@ void odp_packet_print_data(odp_packet_t pkt, uint32_t offset, len += snprintf(&str[len], n - len, " pool index %" PRIu32 "\n", pool->pool_idx); len += snprintf(&str[len], n - len, - " buf index %" PRIu32 "\n", hdr->buf_hdr.index); + " buf index %" PRIu32 "\n", + buf_hdr_to_index(&hdr->buf_hdr)); len += snprintf(&str[len], n - len, " segcount %" PRIu16 "\n", hdr->buf_hdr.segcount); len += snprintf(&str[len], n - len, diff --git a/platform/linux-generic/pool/generic.c b/platform/linux-generic/pool/generic.c index 7a068472..4d5f5946 100644 --- a/platform/linux-generic/pool/generic.c +++ b/platform/linux-generic/pool/generic.c @@ -259,7 +259,6 @@ static void init_buffers(pool_t *pool) seg_size = pool->headroom + pool->seg_len + pool->tailroom;
/* Initialize buffer metadata */ - buf_hdr->index = i; buf_hdr->size = seg_size; buf_hdr->type = type; buf_hdr->event_type = type;
commit 0b9b3c3ee67e11b798c41ac6ac8b71f80546f1d2 Author: Joyce Kong joyce.kong@arm.com Date: Wed Dec 13 18:35:20 2017 +0800
linux-dpdk: buffer: remove handle/index in metadata
Signed-off-by: Joyce Kong joyce.kong@arm.com Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Yi He yi.he@linaro.org
diff --git a/platform/linux-dpdk/include/odp_buffer_internal.h b/platform/linux-dpdk/include/odp_buffer_internal.h index cc9c7d39..20fe5cb9 100644 --- a/platform/linux-dpdk/include/odp_buffer_internal.h +++ b/platform/linux-dpdk/include/odp_buffer_internal.h @@ -51,8 +51,6 @@ typedef union odp_buffer_bits_t { struct odp_buffer_hdr_t { /* Underlying DPDK rte_mbuf */ struct rte_mbuf mb; - /* Handle union */ - odp_buffer_bits_t handle;
/* ODP buffer type, not DPDK buf type */ int type; @@ -87,8 +85,6 @@ struct odp_buffer_hdr_t {
/* Total size of all allocated segs */ uint32_t totsize; - /* Index in the rte_mempool */ - uint32_t index; };
ODP_STATIC_ASSERT(BUFFER_BURST_SIZE < 256, "BUFFER_BURST_SIZE_TOO_LARGE"); diff --git a/platform/linux-dpdk/odp_packet.c b/platform/linux-dpdk/odp_packet.c index 54f34007..46e55b5f 100644 --- a/platform/linux-dpdk/odp_packet.c +++ b/platform/linux-dpdk/odp_packet.c @@ -74,7 +74,7 @@ ODP_STATIC_ASSERT(sizeof(dummy.ol_flags) == sizeof(uint64_t),
static inline odp_buffer_t buffer_handle(odp_packet_hdr_t *pkt_hdr) { - return pkt_hdr->buf_hdr.handle.handle; + return (odp_buffer_t)pkt_hdr; }
static inline odp_packet_hdr_t *buf_to_packet_hdr(odp_buffer_t buf) @@ -259,9 +259,6 @@ void *odp_packet_push_head(odp_packet_t pkt, uint32_t len) static void _copy_head_metadata(struct rte_mbuf *newhead, struct rte_mbuf *oldhead) { - odp_packet_t pkt = (odp_packet_t)newhead; - uint32_t saved_index = odp_packet_hdr(pkt)->buf_hdr.index; - rte_mbuf_refcnt_set(newhead, rte_mbuf_refcnt_read(oldhead)); newhead->port = oldhead->port; newhead->ol_flags = oldhead->ol_flags; @@ -274,9 +271,6 @@ static void _copy_head_metadata(struct rte_mbuf *newhead, memcpy(&newhead->tx_offload, &oldhead->tx_offload, sizeof(odp_packet_hdr_t) - offsetof(struct rte_mbuf, tx_offload)); - odp_packet_hdr(pkt)->buf_hdr.handle.handle = - (odp_buffer_t)newhead; - odp_packet_hdr(pkt)->buf_hdr.index = saved_index; }
int odp_packet_extend_head(odp_packet_t *pkt, uint32_t len, void **data_ptr, @@ -1119,8 +1113,6 @@ void odp_packet_print_data(odp_packet_t pkt, uint32_t offset, len += snprintf(&str[len], n - len, "Packet\n------\n"); len += snprintf(&str[len], n - len, " pool index %" PRIu32 "\n", pool_handle_to_index(pool)); - len += snprintf(&str[len], n - len, - " buf index %" PRIu32 "\n", hdr->buf_hdr.index); len += snprintf(&str[len], n - len, " data len %" PRIu32 "\n", data_len); len += snprintf(&str[len], n - len, diff --git a/platform/linux-dpdk/pool/dpdk.c b/platform/linux-dpdk/pool/dpdk.c index 94143dfe..d2f510c9 100644 --- a/platform/linux-dpdk/pool/dpdk.c +++ b/platform/linux-dpdk/pool/dpdk.c @@ -194,7 +194,7 @@ static void odp_dpdk_mbuf_ctor(struct rte_mempool *mp, void *opaque_arg, void *raw_mbuf, - unsigned i) + unsigned i ODP_UNUSED) { struct mbuf_ctor_arg *mb_ctor_arg; struct rte_mbuf *mb = raw_mbuf; @@ -231,10 +231,7 @@ odp_dpdk_mbuf_ctor(struct rte_mempool *mp, mb->pool = mp; mb->ol_flags = 0;
- /* Save index, might be useful for debugging purposes */ buf_hdr = (struct odp_buffer_hdr_t *)raw_mbuf; - buf_hdr->index = i; - buf_hdr->handle.handle = (odp_buffer_t)buf_hdr; buf_hdr->pool_hdl = mbp_ctor_arg->pool_hdl; buf_hdr->type = mb_ctor_arg->type; buf_hdr->event_type = mb_ctor_arg->type;
commit 055516066c0a1104501cfd1050f0407fbec230c1 Author: Mykyta Iziumtsev mykyta.iziumtsev@linaro.org Date: Wed Dec 20 18:14:15 2017 +0100
linux-gen: move common macros to odp_internal.h
Gather macros needed for upcoming mediated devices in one location. Fix signed vs. unsigned comparisons caused by incorrect MIN / MAX usage.
Signed-off-by: Mykyta Iziumtsev mykyta.iziumtsev@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Yi He yi.he@linaro.org
diff --git a/platform/linux-generic/include/odp_bitmap_internal.h b/platform/linux-generic/include/odp_bitmap_internal.h index 1be4d028..dd842903 100644 --- a/platform/linux-generic/include/odp_bitmap_internal.h +++ b/platform/linux-generic/include/odp_bitmap_internal.h @@ -21,14 +21,12 @@ extern "C" { #include <stdbool.h> #include <string.h> #include <odp/api/hints.h> +#include <odp_internal.h>
/* Generate unique identifier for instantiated class */ #define TOKENIZE(template, line) \ template ## _ ## line ## _ ## __COUNTER__
-/* Array size in general */ -#define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0])) - #define BITS_PER_BYTE (8) #define BITS_PER_LONG __WORDSIZE #define BYTES_PER_LONG (BITS_PER_LONG / BITS_PER_BYTE) diff --git a/platform/linux-generic/include/odp_internal.h b/platform/linux-generic/include/odp_internal.h index 6811d8d0..ece73635 100644 --- a/platform/linux-generic/include/odp_internal.h +++ b/platform/linux-generic/include/odp_internal.h @@ -161,6 +161,33 @@ uint64_t odp_cpu_hz_current(int id); uint64_t odp_cpu_arch_hz_current(int id); void sys_info_print_arch(void);
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) + +#define MIN(a, b) \ + ({ \ + __typeof__(a) tmp_a = (a); \ + __typeof__(b) tmp_b = (b); \ + tmp_a < tmp_b ? tmp_a : tmp_b; \ + }) +#define MAX(a, b) \ + ({ \ + __typeof__(a) tmp_a = (a); \ + __typeof__(b) tmp_b = (b); \ + tmp_a > tmp_b ? tmp_a : tmp_b; \ + }) + +#define odp_container_of(pointer, type, member) \ + ((type *)(void *)(((char *)pointer) - offsetof(type, member))) + +#define DIV_ROUND_UP(a, b) \ + ({ \ + __typeof__(a) tmp_a = (a); \ + __typeof__(b) tmp_b = (b); \ + ODP_STATIC_ASSERT(__builtin_constant_p(b), ""); \ + ODP_STATIC_ASSERT((((b) - 1) & (b)) == 0, ""); \ + (tmp_a + tmp_b - 1) >> __builtin_ctz(tmp_b); \ + }) + #ifdef __cplusplus } #endif diff --git a/platform/linux-generic/include/odp_traffic_mngr_internal.h b/platform/linux-generic/include/odp_traffic_mngr_internal.h index e8254f5e..2d1fc549 100644 --- a/platform/linux-generic/include/odp_traffic_mngr_internal.h +++ b/platform/linux-generic/include/odp_traffic_mngr_internal.h @@ -34,9 +34,6 @@ extern "C" {
typedef struct stat file_stat_t;
-#define MAX(a, b) (((a) > (b)) ? (a) : (b)) -#define MIN(a, b) (((a) < (b)) ? (a) : (b)) - #define INPUT_WORK_RING_SIZE (16 * 1024)
#define TM_QUEUE_MAGIC_NUM 0xBABEBABE diff --git a/platform/linux-generic/odp_name_table.c b/platform/linux-generic/odp_name_table.c index 3ff46b34..e2a0401b 100644 --- a/platform/linux-generic/odp_name_table.c +++ b/platform/linux-generic/odp_name_table.c @@ -14,9 +14,7 @@ #include <stdlib.h> #include <odp_name_table_internal.h> #include <odp_debug_internal.h> - -#define MAX(a, b) (((a) > (b)) ? (a) : (b)) -#define MIN(a, b) (((a) < (b)) ? (a) : (b)) +#include <odp_internal.h>
/* The following constants define some tunable parameters of this module. * They are set to fairly reasonable values (perhaps somewhat biased toward @@ -298,7 +296,7 @@ static int new_name_tbl_add(void) name_tbls_idx = name_tbls.num_name_tbls; num_entries = INITIAL_NAME_TBL_SIZE << name_tbls_idx; new_name_tbl = name_tbl_alloc(name_tbls_idx, num_entries); - name_tbl_free_list_add(new_name_tbl, MIN(num_entries, 256)); + name_tbl_free_list_add(new_name_tbl, MIN(num_entries, UINT32_C(256)));
name_tbls.tbls[name_tbls_idx] = new_name_tbl; name_tbls.avail_space_bit_mask |= 1 << name_tbls_idx; @@ -387,7 +385,7 @@ static hash_tbl_entry_t make_hash_tbl_entry(name_tbl_entry_t *name_tbl_entry, hash_tbl_entry_t hash_tbl_entry; uint32_t new_entry_cnt;
- new_entry_cnt = MIN(entry_cnt + 1, 0x3F); + new_entry_cnt = MIN(entry_cnt + 1, UINT32_C(0x3F)); hash_tbl_entry = (hash_tbl_entry_t)(uintptr_t)name_tbl_entry; hash_tbl_entry &= ~0x3F; hash_tbl_entry |= new_entry_cnt; @@ -1006,7 +1004,7 @@ static uint32_t level2_hash_histo(secondary_hash_tbl_t *hash_tbl, collisions = linked_list_len(name_tbl_entry); }
- level2_histo[MIN(collisions, 256)]++; + level2_histo[MIN(collisions, UINT32_C(256))]++; total_collisions += collisions; }
@@ -1038,7 +1036,7 @@ static uint32_t level1_hash_histo(secondary_hash_tbl_t *hash_tbl, level2_histo); }
- level1_histo[MIN(collisions, 256)]++; + level1_histo[MIN(collisions, UINT32_C(256))]++; total_collisions += collisions; }
@@ -1147,7 +1145,8 @@ void _odp_int_name_tbl_stats_print(void)
memset(primary_hash_histo, 0, sizeof(primary_hash_histo)); for (idx = 0; idx < PRIMARY_HASH_TBL_SIZE; idx++) { - collisions = MIN(name_hash_tbl.hash_collisions[idx], 256); + collisions = + MIN(name_hash_tbl.hash_collisions[idx], UINT32_C(256)); primary_hash_histo[collisions]++; }
diff --git a/platform/linux-generic/odp_pkt_queue.c b/platform/linux-generic/odp_pkt_queue.c index 4f6a1eb6..502203b7 100644 --- a/platform/linux-generic/odp_pkt_queue.c +++ b/platform/linux-generic/odp_pkt_queue.c @@ -16,9 +16,7 @@ #include <odp_api.h> #include <odp_pkt_queue_internal.h> #include <odp_debug_internal.h> - -#define MAX(a, b) (((a) > (b)) ? (a) : (b)) -#define MIN(a, b) (((a) < (b)) ? (a) : (b)) +#include <odp_internal.h>
#define NUM_PKTS 7
@@ -229,7 +227,7 @@ _odp_int_queue_pool_t _odp_queue_pool_create(uint32_t max_num_queues, /* Initialize the queue_blk_tbl_sizes array based upon the * max_queued_pkts. */ - max_queued_pkts = MAX(max_queued_pkts, 64 * 1024); + max_queued_pkts = MAX(max_queued_pkts, 64 * UINT32_C(1024)); queue_region_desc_init(pool, 0, max_queued_pkts / 4); queue_region_desc_init(pool, 1, max_queued_pkts / 64); queue_region_desc_init(pool, 2, max_queued_pkts / 64); @@ -241,7 +239,7 @@ _odp_int_queue_pool_t _odp_queue_pool_create(uint32_t max_num_queues, /* Now allocate the first queue_blk_tbl and add its blks to the free * list. Replenish the queue_blk_t free list. */ - initial_free_list_size = MIN(64 * 1024, max_queued_pkts / 4); + initial_free_list_size = MIN(64 * UINT32_C(1024), max_queued_pkts / 4); rc = pkt_queue_free_list_add(pool, initial_free_list_size); if (rc < 0) { free(pool->queue_num_tbl); diff --git a/platform/linux-generic/odp_timer_wheel.c b/platform/linux-generic/odp_timer_wheel.c index b37d269b..9b1e5383 100644 --- a/platform/linux-generic/odp_timer_wheel.c +++ b/platform/linux-generic/odp_timer_wheel.c @@ -627,7 +627,7 @@ static int timer_current_wheel_update(timer_wheels_t *timer_wheels, slot_idx = wheel_desc->slot_idx; num_slots = wheel_desc->num_slots; max_ticks = wheel_desc->max_ticks; - max_cnt = (uint32_t)MIN(elapsed_ticks, 32); + max_cnt = MIN(elapsed_ticks, UINT32_C(32)); current_wheel = timer_wheels->current_wheel; ret_code = 0; rc = -1; diff --git a/platform/linux-generic/odp_traffic_mngr.c b/platform/linux-generic/odp_traffic_mngr.c index ab06b3c0..20af537f 100644 --- a/platform/linux-generic/odp_traffic_mngr.c +++ b/platform/linux-generic/odp_traffic_mngr.c @@ -729,7 +729,8 @@ static uint64_t time_till_not_red(tm_shaper_params_t *shaper_params, commit_delay = (-shaper_obj->commit_cnt) / shaper_params->commit_rate;
- min_time_delay = MAX(shaper_obj->shaper_params->min_time_delta, 256); + min_time_delay = + MAX(shaper_obj->shaper_params->min_time_delta, UINT64_C(256)); commit_delay = MAX(commit_delay, min_time_delay); if (shaper_params->peak_rate == 0) return commit_delay; @@ -1668,7 +1669,7 @@ static odp_tm_percent_t tm_queue_fullness(tm_wred_params_t *wred_params, return 0;
fullness = (10000 * current_cnt) / max_cnt; - return (odp_tm_percent_t)MIN(fullness, 50000); + return (odp_tm_percent_t)MIN(fullness, UINT64_C(50000)); }
static odp_bool_t tm_local_random_drop(tm_system_t *tm_system, @@ -2499,7 +2500,7 @@ static void tm_system_capabilities_set(odp_tm_capabilities_t *cap_ptr, memset(cap_ptr, 0, sizeof(odp_tm_capabilities_t));
max_queues = MIN(req_ptr->max_tm_queues, - ODP_TM_MAX_NUM_TM_NODES); + (uint32_t)ODP_TM_MAX_NUM_TM_NODES); shaper_supported = req_ptr->tm_queue_shaper_needed; wred_supported = req_ptr->tm_queue_wred_needed; dual_slope = req_ptr->tm_queue_dual_slope_needed; @@ -2523,8 +2524,9 @@ static void tm_system_capabilities_set(odp_tm_capabilities_t *cap_ptr, per_level_req = &req_ptr->per_level[level_idx];
max_nodes = MIN(per_level_req->max_num_tm_nodes, - ODP_TM_MAX_NUM_TM_NODES); - max_fanin = MIN(per_level_req->max_fanin_per_node, 1024); + (uint32_t)ODP_TM_MAX_NUM_TM_NODES); + max_fanin = MIN(per_level_req->max_fanin_per_node, + UINT32_C(1024)); max_priority = MIN(per_level_req->max_priority, ODP_TM_MAX_PRIORITIES - 1); min_weight = MAX(per_level_req->min_weight, diff --git a/platform/linux-generic/queue/scalable.c b/platform/linux-generic/queue/scalable.c index f4f5efb8..566d75bd 100644 --- a/platform/linux-generic/queue/scalable.c +++ b/platform/linux-generic/queue/scalable.c @@ -33,13 +33,6 @@
#define NUM_INTERNAL_QUEUES 64
-#define MIN(a, b) \ - ({ \ - __typeof__(a) tmp_a = (a); \ - __typeof__(b) tmp_b = (b); \ - tmp_a < tmp_b ? tmp_a : tmp_b; \ - }) - #define LOCK(a) _odp_ticketlock_lock(a) #define UNLOCK(a) _odp_ticketlock_unlock(a) #define LOCK_INIT(a) odp_ticketlock_init(a) diff --git a/platform/linux-generic/schedule/scalable.c b/platform/linux-generic/schedule/scalable.c index de9c6528..3940e6f0 100644 --- a/platform/linux-generic/schedule/scalable.c +++ b/platform/linux-generic/schedule/scalable.c @@ -145,10 +145,6 @@ static void remove_schedq_from_list(sched_scalable_thread_state_t *ts, /******************************************************************************* * Scheduler queues ******************************************************************************/ -#ifndef odp_container_of -#define odp_container_of(pointer, type, member) \ - ((type *)(void *)(((char *)pointer) - offsetof(type, member))) -#endif
static inline void schedq_init(sched_queue_t *schedq, uint32_t prio) {
commit a3f913fe4d0008641684b90d7209d23296a48767 Author: Mykyta Iziumtsev mykyta.iziumtsev@linaro.org Date: Wed Dec 20 13:57:03 2017 +0100
linux-gen: extend sysfs parsing helper functions
Added char* and uint64_t sysfs attribute read functions to support upcoming native and mediated device drivers.
Updated sysfs_netif_stats() to take interface name as argument instead of pktio_entry, because pktio_entry->s.name is not necessarily recognisable Linux network interface name.
Signed-off-by: Mykyta Iziumtsev mykyta.iziumtsev@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Yi He yi.he@linaro.org
diff --git a/platform/linux-generic/pktio/common.c b/platform/linux-generic/pktio/common.c index 900dcbba..e6eb0990 100644 --- a/platform/linux-generic/pktio/common.c +++ b/platform/linux-generic/pktio/common.c @@ -45,7 +45,7 @@ int sock_stats_reset_fd(pktio_entry_t *pktio_entry, int fd) pktio_entry->s.name, &cur_stats); } else if (pktio_entry->s.stats_type == STATS_SYSFS) { - err = sysfs_stats(pktio_entry, &cur_stats); + err = sysfs_netif_stats(pktio_entry->s.name, &cur_stats); if (err != 0) ODP_ERR("stats error\n"); } @@ -78,7 +78,7 @@ int sock_stats_fd(pktio_entry_t *pktio_entry, pktio_entry->s.name, &cur_stats); } else if (pktio_entry->s.stats_type == STATS_SYSFS) { - sysfs_stats(pktio_entry, &cur_stats); + sysfs_netif_stats(pktio_entry->s.name, &cur_stats); }
stats->in_octets = cur_stats.in_octets - diff --git a/platform/linux-generic/pktio/socket.c b/platform/linux-generic/pktio/socket.c index 7e0485b9..320de973 100644 --- a/platform/linux-generic/pktio/socket.c +++ b/platform/linux-generic/pktio/socket.c @@ -204,7 +204,7 @@ static int sock_setup_pkt(pktio_entry_t *pktio_entry, const char *netdev, pktio_entry->s.name, &cur_stats); if (err != 0) { - err = sysfs_stats(pktio_entry, &cur_stats); + err = sysfs_netif_stats(pktio_entry->s.name, &cur_stats); if (err != 0) { pktio_entry->s.stats_type = STATS_UNSUPPORTED; ODP_DBG("pktio: %s unsupported stats\n", diff --git a/platform/linux-generic/pktio/socket_mmap.c b/platform/linux-generic/pktio/socket_mmap.c index 271c2f0f..26d0a295 100644 --- a/platform/linux-generic/pktio/socket_mmap.c +++ b/platform/linux-generic/pktio/socket_mmap.c @@ -593,7 +593,7 @@ static int sock_mmap_open(odp_pktio_t id ODP_UNUSED, pktio_entry->s.name, &cur_stats); if (ret != 0) { - ret = sysfs_stats(pktio_entry, &cur_stats); + ret = sysfs_netif_stats(pktio_entry->s.name, &cur_stats); if (ret != 0) { pktio_entry->s.stats_type = STATS_UNSUPPORTED; ODP_DBG("pktio: %s unsupported stats\n", diff --git a/platform/linux-generic/pktio/sysfs.c b/platform/linux-generic/pktio/sysfs.c index f674ac42..8bd7d4fb 100644 --- a/platform/linux-generic/pktio/sysfs.c +++ b/platform/linux-generic/pktio/sysfs.c @@ -7,74 +7,158 @@ #include "config.h"
#include <odp_api.h> -#include <odp_packet_io_internal.h> +#include <odp_errno_define.h> #include <pktio/sysfs.h> + #include <errno.h> #include <string.h> #include <inttypes.h> +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h>
-static int sysfs_get_val(const char *fname, uint64_t *val) +ODP_PRINTF_FORMAT(3, 0) +static int _sysfs_attr_raw_get(char *buf, size_t buf_size, const char *fmt, + va_list args) { - FILE *file; - char str[128]; - int ret = -1; + char path[256]; + FILE *file; + int ret;
- file = fopen(fname, "rt"); - if (file == NULL) { + ret = vsnprintf(path, sizeof(path), fmt, args); + + if (ret < 0) { __odp_errno = errno; - /* do not print debug err if sysfs is not supported by - * kernel driver. - */ - if (errno != ENOENT) - ODP_ERR("fopen %s: %s\n", fname, strerror(errno)); - return 0; + return -1; + } + + if (ret >= (ssize_t)sizeof(path)) { + __odp_errno = EINVAL; + return -1; }
- if (fgets(str, sizeof(str), file) != NULL) - ret = sscanf(str, "%" SCNx64, val); + file = fopen(path, "rt"); + if (file == NULL) { + __odp_errno = errno; + return -1; + }
+ buf = fgets(buf, buf_size, file); (void)fclose(file);
- if (ret != 1) { - ODP_ERR("read %s\n", fname); + if (buf == NULL) { + __odp_errno = errno; return -1; }
return 0; }
-int sysfs_stats(pktio_entry_t *pktio_entry, - odp_pktio_stats_t *stats) +ODP_PRINTF_FORMAT(3, 4) +int sysfs_attr_raw_get(char *buf, size_t buf_size, const char *fmt, ...) { - char fname[256]; - const char *dev = pktio_entry->s.name; - int ret = 0; + va_list args; + int ret;
- sprintf(fname, "/sys/class/net/%s/statistics/rx_bytes", dev); - ret -= sysfs_get_val(fname, &stats->in_octets); + va_start(args, fmt); + ret = _sysfs_attr_raw_get(buf, buf_size, fmt, args); + va_end(args);
- sprintf(fname, "/sys/class/net/%s/statistics/rx_packets", dev); - ret -= sysfs_get_val(fname, &stats->in_ucast_pkts); + return ret; +} + +ODP_PRINTF_FORMAT(2, 3) +int sysfs_attr_u64_get(uint64_t *value, const char *fmt, ...) +{ + char buf[20 + 1 + 1]; /* 20 digits (UINT64_MAX) + '\n' + '\0' */ + va_list args; + char *endptr; + int ret;
- sprintf(fname, "/sys/class/net/%s/statistics/rx_droppped", dev); - ret -= sysfs_get_val(fname, &stats->in_discards); + va_start(args, fmt); + ret = _sysfs_attr_raw_get(buf, sizeof(buf), fmt, args); + va_end(args);
- sprintf(fname, "/sys/class/net/%s/statistics/rx_errors", dev); - ret -= sysfs_get_val(fname, &stats->in_errors); + if (ret < 0) + return -1; + + if (buf[0] == '\0') { + __odp_errno = EINVAL; + return -1; + } + + *value = strtoull(buf, &endptr, 0); + + /* It is OK to have '\n' in sysfs */ + if (*endptr == '\n') + endptr++; + + if (*endptr != '\0') { + __odp_errno = EINVAL; + return -1; + } + + return 0; +} + +int sysfs_netif_stats(const char *netif_name, odp_pktio_stats_t *stats) +{ + int ret; + + /* + * Do not print debug err if sysfs is not supported by + * kernel driver. + */ + + ret = sysfs_attr_u64_get(&stats->in_octets, + "/sys/class/net/%s/statistics/rx_bytes", + netif_name); + if (ret < 0 && __odp_errno != ENOENT) + return -1; + + ret = sysfs_attr_u64_get(&stats->in_ucast_pkts, + "/sys/class/net/%s/statistics/rx_packets", + netif_name); + if (ret < 0 && __odp_errno != ENOENT) + return -1; + + ret = sysfs_attr_u64_get(&stats->in_discards, + "/sys/class/net/%s/statistics/rx_droppped", + netif_name); + if (ret < 0 && __odp_errno != ENOENT) + return -1; + + ret = sysfs_attr_u64_get(&stats->in_errors, + "/sys/class/net/%s/statistics/rx_errors", + netif_name); + if (ret < 0 && __odp_errno != ENOENT) + return -1;
/* stats->in_unknown_protos is not supported in sysfs */
- sprintf(fname, "/sys/class/net/%s/statistics/tx_bytes", dev); - ret -= sysfs_get_val(fname, &stats->out_octets); + ret = sysfs_attr_u64_get(&stats->out_octets, + "/sys/class/net/%s/statistics/tx_bytes", + netif_name); + if (ret < 0 && __odp_errno != ENOENT) + return -1;
- sprintf(fname, "/sys/class/net/%s/statistics/tx_packets", dev); - ret -= sysfs_get_val(fname, &stats->out_ucast_pkts); + ret = sysfs_attr_u64_get(&stats->out_ucast_pkts, + "/sys/class/net/%s/statistics/tx_packets", + netif_name); + if (ret < 0 && __odp_errno != ENOENT) + return -1;
- sprintf(fname, "/sys/class/net/%s/statistics/tx_dropped", dev); - ret -= sysfs_get_val(fname, &stats->out_discards); + ret = sysfs_attr_u64_get(&stats->out_discards, + "/sys/class/net/%s/statistics/tx_dropped", + netif_name); + if (ret < 0 && __odp_errno != ENOENT) + return -1;
- sprintf(fname, "/sys/class/net/%s/statistics/tx_errors", dev); - ret -= sysfs_get_val(fname, &stats->out_errors); + ret = sysfs_attr_u64_get(&stats->out_errors, + "/sys/class/net/%s/statistics/tx_errors", + netif_name); + if (ret < 0 && __odp_errno != ENOENT) + return -1;
- return ret; + return 0; } diff --git a/platform/linux-generic/pktio/sysfs.h b/platform/linux-generic/pktio/sysfs.h index f8fe3072..71ac4726 100644 --- a/platform/linux-generic/pktio/sysfs.h +++ b/platform/linux-generic/pktio/sysfs.h @@ -8,16 +8,39 @@ #define ODP_PKTIO_SYSFS_H_
/** - * Get statistics for a pktio entry + * Read an attribute from /sysfs as raw string * - * @param pktio_entry Packet IO entry - * @param stats[out] Output buffer for counters + * @param buf[out] Attribute value + * @param buf_size Maximum number of bytes to read (including '\0') + * @param fmt printf-like path to the attribute + * + * @retval 0 on success, buf[] is guaranteed to be '\0'-terminated + * @retval != 0 on failure + */ +ODP_PRINTF_FORMAT(3, 4) +int sysfs_attr_raw_get(char *buf, size_t buf_size, const char *fmt, ...); + +/** + * Read an attribute from /sysfs as uint64_t + * + * @param value[out] Attribute value + * @param fmt printf-like path to the attribute * * @retval 0 on success * @retval != 0 on failure */ +ODP_PRINTF_FORMAT(2, 3) +int sysfs_attr_u64_get(uint64_t *value, const char *fmt, ...);
-int sysfs_stats(pktio_entry_t *pktio_entry, - odp_pktio_stats_t *stats); +/** + * Get statistics for a network interface + * + * @param netif_name Network interface name + * @param stats[out] Output buffer for counters + * + * @retval 0 on success + * @retval != 0 on failure + */ +int sysfs_netif_stats(const char *netif_name, odp_pktio_stats_t *stats);
#endif /* ODP_PKTIO_SYSFS_H_ */
commit 2d0ddc0917fa97d4ee9d1ec7009fe1abb9c42085 Author: Mykyta Iziumtsev mykyta.iziumtsev@linaro.org Date: Wed Dec 20 14:44:51 2017 +0100
linux-gen: extend ethtool helper functions
Add helper function to query RX/TX queue lengths on network interface to facilitate upcoming native and mediated device drivers.
Signed-off-by: Mykyta Iziumtsev mykyta.iziumtsev@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Yi He yi.he@linaro.org
diff --git a/platform/linux-generic/pktio/ethtool.c b/platform/linux-generic/pktio/ethtool.c index b71666a3..119ad75a 100644 --- a/platform/linux-generic/pktio/ethtool.c +++ b/platform/linux-generic/pktio/ethtool.c @@ -159,12 +159,27 @@ static int ethtool_stats(int fd, struct ifreq *ifr, odp_pktio_stats_t *stats) return 0; }
-int ethtool_stats_get_fd(int fd, const char *name, odp_pktio_stats_t *stats) +int ethtool_stats_get_fd(int fd, const char *netif_name, + odp_pktio_stats_t *stats) { struct ifreq ifr;
memset(&ifr, 0, sizeof(ifr)); - snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", name); + snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", netif_name);
return ethtool_stats(fd, &ifr, stats); } + +int ethtool_ringparam_get_fd(int fd, const char *netif_name, + struct ethtool_ringparam *param) +{ + struct ifreq ifr; + + memset(&ifr, 0, sizeof(ifr)); + snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", netif_name); + + param->cmd = ETHTOOL_GRINGPARAM; + ifr.ifr_data = (void *)param; + + return ioctl(fd, SIOCETHTOOL, &ifr); +} diff --git a/platform/linux-generic/pktio/ethtool.h b/platform/linux-generic/pktio/ethtool.h index c5a81123..c330c2e3 100644 --- a/platform/linux-generic/pktio/ethtool.h +++ b/platform/linux-generic/pktio/ethtool.h @@ -7,9 +7,32 @@ #ifndef ODP_PKTIO_ETHTOOL_H_ #define ODP_PKTIO_ETHTOOL_H_
+#include <linux/ethtool.h> + +/** + * Get statistics for a network interface + * + * @param fd Arbitrary socket file descriptor + * @param netif_name Network interface name + * @param stats[out] Output buffer for counters + * + * @retval 0 on success + * @retval != 0 on failure + */ +int ethtool_stats_get_fd(int fd, const char *netif_name, + odp_pktio_stats_t *stats); + /** - * Get ethtool statistics of a packet socket + * Get RX/TX queue parameters for a network interface + * + * @param fd Arbitrary socket file descriptor + * @param netif_name Network interface name + * @param param[out] Output buffer for parameters + * + * @retval 0 on success + * @retval != 0 on failure */ -int ethtool_stats_get_fd(int fd, const char *name, odp_pktio_stats_t *stats); +int ethtool_ringparam_get_fd(int fd, const char *netif_name, + struct ethtool_ringparam *param);
#endif /*ODP_PKTIO_ETHTOOL_H_*/
commit 9eebbe7d21f0b933190fd910c54c872eecfe180e Author: Mykyta Iziumtsev mykyta.iziumtsev@linaro.org Date: Wed Dec 20 10:41:00 2017 +0100
linux-gen: add memory-mapped I/O access API
Signed-off-by: Mykyta Iziumtsev mykyta.iziumtsev@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Yi He yi.he@linaro.org
diff --git a/include/odp/drv/spec/mmio.h b/include/odp/drv/spec/mmio.h new file mode 100644 index 00000000..5174515f --- /dev/null +++ b/include/odp/drv/spec/mmio.h @@ -0,0 +1,131 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * API to access memory-mapped I/O. + * + */ + +#ifndef ODPDRV_MMIO_H_ +#define ODPDRV_MMIO_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/** @addtogroup odpdrv_mmio ODPDRV MMIO + * @{ + */ + +/** + * Write value to MMIO + * @param value cpu native 8-bit value to write to MMIO + * @param addr MMIO address to write at + */ +void odpdrv_mmio_u8_write(uint8_t value, volatile void *addr); + +/** + * Convert to little endian and write value to MMIO + * @param value cpu native 16-bit value to write to MMIO + * @param addr MMIO address to write at + */ +void odpdrv_mmio_u16le_write(uint16_t value, volatile void *addr); + +/** + * Convert to big endian and write value to MMIO + * @param value cpu native 16-bit value to write to MMIO + * @param addr MMIO address to write at + */ +void odpdrv_mmio_u16be_write(uint16_t value, volatile void *addr); + +/** + * Convert to little endian and write value to MMIO + * @param value cpu native 32-bit value to write to MMIO + * @param addr MMIO address to write at + */ +void odpdrv_mmio_u32le_write(uint32_t value, volatile void *addr); + +/** + * Convert to big endian and write value to MMIO + * @param value cpu native 32-bit value to write to MMIO + * @param addr MMIO address to write at + */ +void odpdrv_mmio_u32be_write(uint32_t value, volatile void *addr); + +/** + * Convert to little endian and write value to MMIO + * @param value cpu native 64-bit value to write to MMIO + * @param addr MMIO address to write at + */ +void odpdrv_mmio_u64le_write(uint64_t value, volatile void *addr); + +/** + * Convert to big endian and write value to MMIO + * @param value cpu native 64-bit value to write to MMIO + * @param addr MMIO address to write at + */ +void odpdrv_mmio_u64be_write(uint64_t value, volatile void *addr); + +/** + * Read from MMIO + * @param addr MMIO address to read at + * @return cpu native 8-bit value + */ +uint8_t odpdrv_mmio_u8_read(volatile void *addr); + +/** + * Read from MMIO and convert from little endian + * @param addr MMIO address to read at + * @return cpu native 16-bit value + */ +uint16_t odpdrv_mmio_u16le_read(volatile void *addr); + +/** + * Read from MMIO and convert from big endian + * @param addr MMIO address to read at + * @return cpu native 16-bit value + */ +uint16_t odpdrv_mmio_u16be_read(volatile void *addr); + +/** + * Read from MMIO and convert from little endian + * @param addr MMIO address to read at + * @return cpu native 32-bit value + */ +uint32_t odpdrv_mmio_u32le_read(volatile void *addr); + +/** + * Read from MMIO and convert from big endian + * @param addr MMIO address to read at + * @return cpu native 32-bit value + */ +uint32_t odpdrv_mmio_u32be_read(volatile void *addr); + +/** + * Read from MMIO and convert from little endian + * @param addr MMIO address to read at + * @return cpu native 64-bit value + */ +uint64_t odpdrv_mmio_u64le_read(volatile void *addr); + +/** + * Read from MMIO and convert from big endian + * @param addr MMIO address to read at + * @return cpu native 64-bit value + */ +uint64_t odpdrv_mmio_u64be_read(volatile void *addr); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/platform/linux-generic/include/odp/drv/mmio.h b/platform/linux-generic/include/odp/drv/mmio.h new file mode 100644 index 00000000..a3846ce1 --- /dev/null +++ b/platform/linux-generic/include/odp/drv/mmio.h @@ -0,0 +1,168 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * API to access memory-mapped I/O. + */ + +#ifndef ODPDRV_PLAT_MMIO_H_ +#define ODPDRV_PLAT_MMIO_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <odp/api/byteorder.h> +#include <odp/drv/byteorder.h> + +/** @ingroup odpdrv_mmio ODPDRV MMIO + * @{ + */ + +/* for use with type checkers such as sparse */ +#ifdef __CHECKER__ +/** @internal MMIO attribute */ +#define __odpdrv_mmio __attribute__((noderef, address_space(2))) +#else +/** @internal MMIO attribute */ +#define __odpdrv_mmio +#endif + +#define odpdrv_io_mb() __asm__ __volatile__("" ::: "memory") +#define odpdrv_io_rmb() __asm__ __volatile__("" ::: "memory") +#define odpdrv_io_wmb() __asm__ __volatile__("" ::: "memory") + +static inline void +odpdrv_mmio_u8_write(uint8_t value, volatile void __odpdrv_mmio *addr) +{ + odpdrv_io_wmb(); + *(__odp_force volatile uint8_t *)addr = value; +} + +static inline void +odpdrv_mmio_u16le_write(uint16_t value, volatile void __odpdrv_mmio *addr) +{ + odpdrv_io_wmb(); + *(__odp_force volatile odp_u16le_t *)addr = odpdrv_cpu_to_le_16(value); +} + +static inline void +odpdrv_mmio_u16be_write(uint16_t value, volatile void __odpdrv_mmio *addr) +{ + odpdrv_io_wmb(); + *(__odp_force volatile odp_u16be_t *)addr = odpdrv_cpu_to_be_16(value); +} + +static inline void +odpdrv_mmio_u32le_write(uint32_t value, volatile void __odpdrv_mmio *addr) +{ + odpdrv_io_wmb(); + *(__odp_force volatile odp_u32le_t *)addr = odpdrv_cpu_to_le_32(value); +} + +static inline void +odpdrv_mmio_u32be_write(uint32_t value, volatile void __odpdrv_mmio *addr) +{ + odpdrv_io_wmb(); + *(__odp_force volatile odp_u32be_t *)addr = odpdrv_cpu_to_be_32(value); +} + +static inline void +odpdrv_mmio_u64le_write(uint64_t value, volatile void __odpdrv_mmio *addr) +{ + odpdrv_io_wmb(); + *(__odp_force volatile odp_u64le_t *)addr = odpdrv_cpu_to_le_64(value); +} + +static inline void +odpdrv_mmio_u64be_write(uint64_t value, volatile void __odpdrv_mmio *addr) +{ + odpdrv_io_wmb(); + *(__odp_force volatile odp_u64be_t *)addr = odpdrv_cpu_to_be_64(value); +} + +static inline uint8_t +odpdrv_mmio_u8_read(volatile void __odpdrv_mmio *addr) +{ + uint8_t value = *(__odp_force volatile uint8_t *)addr; + + odpdrv_io_rmb(); + return value; +} + +static inline uint16_t +odpdrv_mmio_u16le_read(volatile void __odpdrv_mmio *addr) +{ + uint16_t value = + odpdrv_le_to_cpu_16(*(__odp_force volatile odp_u16le_t *)addr); + + odpdrv_io_rmb(); + return value; +} + +static inline uint16_t +odpdrv_mmio_u16be_read(volatile void __odpdrv_mmio *addr) +{ + uint16_t value = + odpdrv_be_to_cpu_16(*(__odp_force volatile odp_u16be_t *)addr); + + odpdrv_io_rmb(); + return value; +} + +static inline uint32_t +odpdrv_mmio_u32le_read(volatile void __odpdrv_mmio *addr) +{ + uint32_t value = + odpdrv_le_to_cpu_32(*(__odp_force volatile odp_u32le_t *)addr); + + odpdrv_io_rmb(); + return value; +} + +static inline uint32_t +odpdrv_mmio_u32be_read(volatile void __odpdrv_mmio *addr) +{ + uint32_t value = + odpdrv_be_to_cpu_32(*(__odp_force volatile odp_u32be_t *)addr); + + odpdrv_io_rmb(); + return value; +} + +static inline uint64_t +odpdrv_mmio_u64le_read(volatile void __odpdrv_mmio *addr) +{ + uint64_t value = + odpdrv_le_to_cpu_64(*(__odp_force volatile odp_u64le_t *)addr); + + odpdrv_io_rmb(); + return value; +} + +static inline uint64_t +odpdrv_mmio_u64be_read(volatile void __odpdrv_mmio *addr) +{ + uint64_t value = + odpdrv_be_to_cpu_64(*(__odp_force volatile odp_u64be_t *)addr); + + odpdrv_io_rmb(); + return value; +} + +/** + * @} + */ + +#include <odp/drv/spec/mmio.h> + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 16316b92..9c256e29 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -257,6 +257,7 @@ our $Sparse = qr{ __kernel| __force| __iomem| + __odpdrv_mmio| __must_check| __init_refok| __kprobes|
-----------------------------------------------------------------------
Summary of changes: include/odp/drv/spec/mmio.h | 131 ++++++++++++++++ platform/linux-dpdk/include/odp_buffer_internal.h | 4 - platform/linux-dpdk/odp_packet.c | 10 +- platform/linux-dpdk/pool/dpdk.c | 5 +- platform/linux-generic/buffer/generic.c | 4 +- platform/linux-generic/include/odp/drv/mmio.h | 168 +++++++++++++++++++++ .../linux-generic/include/odp_bitmap_internal.h | 4 +- .../linux-generic/include/odp_buffer_internal.h | 4 - platform/linux-generic/include/odp_internal.h | 27 ++++ platform/linux-generic/include/odp_pool_internal.h | 8 + .../include/odp_traffic_mngr_internal.h | 3 - platform/linux-generic/odp_name_table.c | 15 +- platform/linux-generic/odp_packet.c | 4 +- platform/linux-generic/odp_pkt_queue.c | 8 +- platform/linux-generic/odp_timer_wheel.c | 2 +- platform/linux-generic/odp_traffic_mngr.c | 12 +- platform/linux-generic/pktio/common.c | 4 +- platform/linux-generic/pktio/ethtool.c | 19 ++- platform/linux-generic/pktio/ethtool.h | 27 +++- platform/linux-generic/pktio/socket.c | 2 +- platform/linux-generic/pktio/socket_mmap.c | 2 +- platform/linux-generic/pktio/sysfs.c | 162 +++++++++++++++----- platform/linux-generic/pktio/sysfs.h | 33 +++- platform/linux-generic/pool/generic.c | 1 - platform/linux-generic/queue/scalable.c | 7 - platform/linux-generic/schedule/scalable.c | 4 - scripts/checkpatch.pl | 1 + 27 files changed, 558 insertions(+), 113 deletions(-) create mode 100644 include/odp/drv/spec/mmio.h create mode 100644 platform/linux-generic/include/odp/drv/mmio.h
hooks/post-receive