Upgrade HAL and add ENI metrics support
cover Upgrade HAL and add ENI metrics support
Hi,
this patchset contains upgrade of the of the HAL, which, beside some fixes, also adds possibility for reading ENI metrics from the device.
Those are further exposed to the DPDK applicaiton using xstats.
As it's an extra call to the admin queue during a PMD runtime, for multithread safet the locks had to be added around those functions.
Michal Krawczyk (20):
net/ena/base: use min/max macros with type conversion net/ena/base: specify operations of rte_delay net/ena/base: support 'resource busy' admin status net/ena/base: exponential delay in polling functions net/ena/base: fix release of wait event net/ena/base: remove MMIOWB_NOT_DEFINED ifdef net/ena/base: rework setup of accelerated LLQ mode net/ena/base: add ENI stats
net/ena/base: split RSS function and hash getters net/ena/base: do not use hardcoded RSS key buffer size net/ena/base: check for RSS key configuration support net/ena/base: minor style adjustments net/ena/base: add missing unlikely net/ena/base: store admin stats as u64 net/ena/base: add check for meta desc being NULL net/ena/base: convert values to u32 before shifting net/ena/base: simplify loop copying Rx descs net/ena/base: update generation date and commit net/ena: lock dynamic usages of the admin queue net/ena: expose ENI stats as additional xstats
drivers/net/ena/base/ena_com.c | 137 ++++++++++++------ drivers/net/ena/base/ena_com.h | 57 ++++++-- .../net/ena/base/ena_defs/ena_admin_defs.h | 56 ++++++- .../net/ena/base/ena_defs/ena_eth_io_defs.h | 3 +- drivers/net/ena/base/ena_defs/ena_gen_info.h | 5 +- drivers/net/ena/base/ena_defs/ena_regs_defs.h | 3 +- drivers/net/ena/base/ena_eth_com.c | 34 +++-- drivers/net/ena/base/ena_eth_com.h | 2 +- drivers/net/ena/base/ena_plat_dpdk.h | 19 ++- drivers/net/ena/ena_ethdev.c | 86 ++++++++++- drivers/net/ena/ena_ethdev.h | 34 +++++ 11 files changed, 344 insertions(+), 92 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/20 net/ena/base: use min/max macros with type conversion
Usage of RTE_MIN(MAX) in ENA_MIN32, ENA_MIN16, ENA_MIN8 (and same for the MAX), was not enough, as the HAL code is assuming that those macros will conver both arguments to the specified uintX_t type.
As RTE_MIN(MAX) is using 'typeof' operator, the behavior won't be the same, especially if arguments has different types (and it could cause compilation warnings).
To satisfy that, the ENA_MIN_T and ENA_MAX_T macros were added, which are converting both arguments to the type which is being passed as an argument.
--- drivers/net/ena/base/ena_plat_dpdk.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/net/ena/base/ena_plat_dpdk.h +8 -6
@@ -86,12 +86,14 @@ extern int ena_logtype_com; #define ENA_ASSERT(cond, format, arg...) do {} while (0)#endif -#define ENA_MAX32 (x, y) RTE_MAX((x), (y)) -#define ENA_MAX16 (x, y) RTE_MAX((x), (y)) -#define ENA_MAX8 (x, y) RTE_MAX((x), (y)) -#define ENA_MIN32 (x, y) RTE_MIN((x), (y)) -#define ENA_MIN16 (x, y) RTE_MIN((x), (y)) -#define ENA_MIN8 (x, y) RTE_MIN((x), (y)) +#define ENA_MAX_T (type, x, y) RTE_MAX((type)(x), (type)(y)) +#define ENA_MAX32 (x, y) ENA_MAX_T(uint32_t, (x), (y)) +#define ENA_MAX16 (x, y) ENA_MAX_T(uint16_t, (x), (y)) +#define ENA_MAX8 (x, y) ENA_MAX_T(uint8_t, (x), (y)) +#define ENA_MIN_T (type, x, y) RTE_MIN((type)(x), (type)(y)) +#define ENA_MIN32 (x, y) ENA_MIN_T(uint32_t, (x), (y)) +#define ENA_MIN16 (x, y) ENA_MIN_T(uint16_t, (x), (y)) +#define ENA_MIN8 (x, y) ENA_MIN_T(uint8_t, (x), (y))#define BITS_PER_LONG_LONG (__SIZEOF_LONG_LONG__ * 8)#define U64_C (x) x ## ULL
Signature · 1 line
2.25.1
PATCH 2/20 net/ena/base: specify operations of rte_delay
In reply to Michal KrawczykENA_MSLEEP() and ENA_UDELAY() were expecting different behavior - the first one is expecting driver to sleep, while the other, to busy wait.
For both cases, the rte_delay_(u|m)s() function was used, which could be either sleep or block, depending on the configuration.
To make the macros valid, the operations should be specified directly. Because of that, the rte_delay_us_sleep() and rte_delay_us_block() are now being used.
--- drivers/net/ena/base/ena_plat_dpdk.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ena/base/ena_plat_dpdk.h +2 -2
@@ -56,8 +56,8 @@ typedef uint64_t dma_addr_t;#define ENA_ABORT () abort() -#define ENA_MSLEEP (x) rte_delay_ms(x) -#define ENA_UDELAY (x) rte_delay_us(x) +#define ENA_MSLEEP (x) rte_delay_us_sleep(x * 1000) +#define ENA_UDELAY (x) rte_delay_us_block(x)#define ENA_TOUCH (x) ((void)(x))#define memcpy_toio memcpy
Signature · 1 line
2.25.1
PATCH 3/20 net/ena/base: support 'resource busy' admin status
In reply to Michal KrawczykThe admin command could return ENA_ADMIN_RESOURCE_BUSY status, which is meaning that currently the given resource cannot be used.
However, the request can be repeted, so it's being converted to the ENA_COM_TRY_AGAIN error code.
--- drivers/net/ena/base/ena_com.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ena/base/ena_com.c +2 -0
@@ -517,6 +517,8 @@ static int ena_com_comp_status_to_errno(u8 comp_status)case ENA_ADMIN_ILLEGAL_PARAMETER :case ENA_ADMIN_UNKNOWN_ERROR :return ENA_COM_INVAL ; +case ENA_ADMIN_RESOURCE_BUSY : +return ENA_COM_TRY_AGAIN ; }return ENA_COM_INVAL ;
Signature · 1 line
2.25.1
PATCH 4/20 net/ena/base: exponential delay in polling functions
In reply to Michal KrawczykInstead of the fixes, 5 ms delay in the polling functions, use values into given range (by default from 100 us 5000 us) and increase them exponentially each time, the operation isn't finished.
This change can improve responsiveness of the driver for the fast operations.
--- drivers/net/ena/base/ena_com.c | 35 ++++++++++++++++++++-------- drivers/net/ena/base/ena_com.h | 3 +++ drivers/net/ena/base/ena_plat_dpdk.h | 1 + 3 files changed, 29 insertions(+), 10 deletions(-)
drivers/net/ena/base/ena_com.c +25 -10
@@ -34,7 +34,9 @@#define ENA_REGS_ADMIN_INTR_MASK 1 -#define ENA_POLL_MS 5 +#define ENA_MIN_ADMIN_POLL_US 100 + +#define ENA_MAX_ADMIN_POLL_US 5000/*****************************************************************************/ /*****************************************************************************/
@@ -524,12 +526,20 @@ static int ena_com_comp_status_to_errno(u8 comp_status)return ENA_COM_INVAL ; } +static void ena_delay_exponential_backoff_us (u32 exp,u32 delay_us) +{ + delay_us =ENA_MAX32 (ENA_MIN_ADMIN_POLL_US , delay_us); + delay_us =ENA_MIN32 (delay_us * (1U << exp),ENA_MAX_ADMIN_POLL_US ); +ENA_USLEEP (delay_us); +} +static int ena_com_wait_and_process_admin_cq_polling (struct ena_comp_ctx *comp_ctx,struct ena_com_admin_queue *admin_queue) {unsigned long flags =0 ;ena_time_t timeout;int ret; +u32 exp =0 ; timeout =ENA_GET_SYSTEM_TIMEOUT (admin_queue->completion_timeout);
@@ -553,7 +563,8 @@ static int ena_com_wait_and_process_admin_cq_polling(struct ena_comp_ctx *comp_c goto err; } -ENA_MSLEEP (ENA_POLL_MS ); +ena_delay_exponential_backoff_us (exp++, + admin_queue->ena_dev->ena_min_poll_delay_us); }if (unlikely (comp_ctx->status ==ENA_CMD_ABORTED )) {
@@ -947,12 +958,13 @@ static void ena_com_io_queue_free(struct ena_com_dev *ena_dev,static int wait_for_reset_state (struct ena_com_dev *ena_dev,u32 timeout,u16 exp_state) { -u32 val, i; +u32 val, exp =0 ; +ena_time_t timeout_stamp; -/* Convert timeout from resolution of 100ms to ENA_POLL_MS */ - timeout = (timeout *100 ) /ENA_POLL_MS ; +/* Convert timeout from resolution of 100ms to us resolution. */ + timeout_stamp =ENA_GET_SYSTEM_TIMEOUT (100 *1000 * timeout); -for (i =0 ; i < timeout; i++) { +while (1 ) { val =ena_com_reg_bar_read32 (ena_dev,ENA_REGS_DEV_STS_OFF );if (unlikely (val ==ENA_MMIO_READ_TIMEOUT )) {
@@ -964,10 +976,11 @@ static int wait_for_reset_state(struct ena_com_dev *ena_dev, u32 timeout, exp_state)return 0 ; -ENA_MSLEEP (ENA_POLL_MS ); - } +if (ENA_TIME_EXPIRE (timeout_stamp)) +return ENA_COM_TIMER_EXPIRED ; -return ENA_COM_TIMER_EXPIRED ; +ena_delay_exponential_backoff_us (exp++, ena_dev->ena_min_poll_delay_us); + } } static bool ena_com_check_supported_feature_id(struct ena_com_dev *ena_dev,
@@ -1458,11 +1471,12 @@ void ena_com_wait_for_abort_completion(struct ena_com_dev *ena_dev) {struct ena_com_admin_queue *admin_queue = &ena_dev->admin_queue;unsigned long flags =0 ; +u32 exp =0 ;ENA_SPINLOCK_LOCK (admin_queue->q_lock, flags);while (ATOMIC32_READ (&admin_queue->outstanding_cmds) !=0 ) {ENA_SPINLOCK_UNLOCK (admin_queue->q_lock, flags); -ENA_MSLEEP (ENA_POLL_MS ); +ena_delay_exponential_backoff_us (exp++, ena_dev->ena_min_poll_delay_us);ENA_SPINLOCK_LOCK (admin_queue->q_lock, flags); }ENA_SPINLOCK_UNLOCK (admin_queue->q_lock, flags);
@@ -1827,6 +1841,7 @@ int ena_com_admin_init(struct ena_com_dev *ena_dev,if (ret) goto error; + admin_queue->ena_dev = ena_dev; admin_queue->running_state = true;return 0 ;
drivers/net/ena/base/ena_com.h +3 -0
@@ -202,6 +202,7 @@ struct ena_com_stats_admin {struct ena_com_admin_queue {void *q_dmadev;void *bus; +struct ena_com_dev *ena_dev;ena_spinlock_t q_lock;/* spinlock for the admin queue */ struct ena_comp_ctx *comp_ctx;
@@ -322,6 +323,8 @@ struct ena_com_dev {struct ena_intr_moder_entry *intr_moder_tbl;struct ena_com_llq_info llq_info; + +u32 ena_min_poll_delay_us; };struct ena_com_dev_get_features_ctx {
drivers/net/ena/base/ena_plat_dpdk.h +1 -0
@@ -57,6 +57,7 @@ typedef uint64_t dma_addr_t;#define ENA_ABORT () abort()#define ENA_MSLEEP (x) rte_delay_us_sleep(x * 1000) +#define ENA_USLEEP (x) rte_delay_us_sleep(x)#define ENA_UDELAY (x) rte_delay_us_block(x)#define ENA_TOUCH (x) ((void)(x))
Signature · 1 line
2.25.1
PATCH 5/20 net/ena/base: fix release of wait event
In reply to Michal KrawczykThe wait event is being accessed without making sure it the completion context exists. The check for that is just below, so it could be used for releasing wait even safely.
--- drivers/net/ena/base/ena_com.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ena/base/ena_com.c +4 -2
@@ -1655,11 +1655,13 @@ void ena_com_admin_destroy(struct ena_com_dev *ena_dev)struct ena_com_aenq *aenq = &ena_dev->aenq;u16 size; -ENA_WAIT_EVENT_DESTROY (admin_queue->comp_ctx->wait_event); -if (admin_queue->comp_ctx) +if (admin_queue->comp_ctx) { +ENA_WAIT_EVENT_DESTROY (admin_queue->comp_ctx->wait_event);ENA_MEM_FREE (ena_dev->dmadev, admin_queue->comp_ctx, (admin_queue->q_depth *sizeof (struct ena_comp_ctx ))); + } + admin_queue->comp_ctx =NULL ; size =ADMIN_SQ_SIZE (admin_queue->q_depth);if (sq->entries)
Signature · 1 line
2.25.1
PATCH 6/20 net/ena/base: remove MMIOWB_NOT_DEFINED ifdef
In reply to Michal KrawczykAs there is no replacment for mmiowb() and there is no need to use both versions in the DPDK, this ifdef was simply removed.
--- drivers/net/ena/base/ena_com.c | 2 -- 1 file changed, 2 deletions(-)
drivers/net/ena/base/ena_com.c +0 -2
@@ -2115,9 +2115,7 @@ void ena_com_aenq_intr_handler(struct ena_com_dev *dev, void *data)mb ();ENA_REG_WRITE32_RELAXED (dev->bus, (u32 )aenq->head, dev->reg_bar +ENA_REGS_AENQ_HEAD_DB_OFF ); -#ifndef MMIOWB_NOT_DEFINED mmiowb (); -#endif } int ena_com_dev_reset(struct ena_com_dev *ena_dev,
Signature · 1 line
2.25.1
PATCH 7/20 net/ena/base: rework setup of accelerated LLQ mode
In reply to Michal KrawczykThe purpose of this change is general code simplification and type safety improvement for the logical values.
--- drivers/net/ena/base/ena_com.c | 21 ++++++++++----------- drivers/net/ena/base/ena_eth_com.h | 2 +- 2 files changed, 11 insertions(+), 12 deletions(-)
drivers/net/ena/base/ena_com.c +10 -11
@@ -610,13 +610,9 @@ static int ena_com_set_llq(struct ena_com_dev *ena_dev) cmd.u.llq.desc_num_before_header_enabled = llq_info->descs_num_before_header; cmd.u.llq.descriptors_stride_ctrl_enabled = llq_info->desc_stride_ctrl; -if (llq_info->disable_meta_caching) - cmd.u.llq.accel_mode.u.set.enabled_flags |= -BIT (ENA_ADMIN_DISABLE_META_CACHING ); - -if (llq_info->max_entries_in_tx_burst) - cmd.u.llq.accel_mode.u.set.enabled_flags |= -BIT (ENA_ADMIN_LIMIT_TX_BURST ); + cmd.u.llq.accel_mode.u.set.enabled_flags = +BIT (ENA_ADMIN_DISABLE_META_CACHING ) | +BIT (ENA_ADMIN_LIMIT_TX_BURST ); ret = ena_com_execute_admin_command(admin_queue, (struct ena_admin_aq_entry *)&cmd,
@@ -635,6 +631,7 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev, struct ena_llq_configurations *llq_default_cfg) {struct ena_com_llq_info *llq_info = &ena_dev->llq_info; +struct ena_admin_accel_mode_get llq_accel_mode_get;u16 supported_feat;int rc;
@@ -738,13 +735,15 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev, llq_info->descs_num_before_header); }/* Check for accelerated queue supported */ + llq_accel_mode_get = llq_features->accel_mode.u.get; + llq_info->disable_meta_caching = - llq_features->accel_mode.u.get.supported_flags & -BIT (ENA_ADMIN_DISABLE_META_CACHING ); + !!(llq_accel_mode_get.supported_flags & +BIT (ENA_ADMIN_DISABLE_META_CACHING )); -if (llq_features->accel_mode.u.get.supported_flags &BIT (ENA_ADMIN_LIMIT_TX_BURST )) +if (llq_accel_mode_get.supported_flags &BIT (ENA_ADMIN_LIMIT_TX_BURST )) llq_info->max_entries_in_tx_burst = - llq_features->accel_mode.u.get.max_tx_burst_size / + llq_accel_mode_get.max_tx_burst_size / llq_default_cfg->llq_ring_entry_size_value; rc =ena_com_set_llq (ena_dev);
drivers/net/ena/base/ena_eth_com.h +1 -1
@@ -1,5 +1,5 @@/* SPDX-License-Identifier: BSD-3-Clause -* Copyright (c) 2015-2019 Amazon.com, Inc. or its affiliates. +* Copyright (c) 2015-2020 Amazon.com, Inc. or its affiliates. * All rights reserved. */
Signature · 1 line
2.25.1
PATCH 8/20 net/ena/base: add ENI stats
In reply to Michal KrawczykThe Elastic Netfwork Interface (ENI) stats can be acquired from the HW.
They can provide advanced values which can be further used by the application for better flow management.
It isn't available to the DPDK application, yet. The PMD must expose them directly.
--- drivers/net/ena/base/ena_com.c | 19 +++++++++- drivers/net/ena/base/ena_com.h | 9 +++++ .../net/ena/base/ena_defs/ena_admin_defs.h | 37 ++++++++++++++++++- 3 files changed, 62 insertions(+), 3 deletions(-)
drivers/net/ena/base/ena_com.c +17 -2
@@ -2206,6 +2206,21 @@ static int ena_get_dev_stats(struct ena_com_dev *ena_dev,return ret; } +int ena_com_get_eni_stats (struct ena_com_dev *ena_dev, +struct ena_admin_eni_stats *stats) +{ +struct ena_com_stats_ctx ctx; +int ret; + +memset (&ctx,0x0 ,sizeof (ctx)); + ret =ena_get_dev_stats (ena_dev, &ctx,ENA_ADMIN_GET_STATS_TYPE_ENI ); +if (likely (ret ==0 )) +memcpy (stats, &ctx.get_resp.u.eni_stats, +sizeof (ctx.get_resp.u.eni_stats)); + +return ret; +} +int ena_com_get_dev_basic_stats (struct ena_com_dev *ena_dev,struct ena_admin_basic_stats *stats) {
@@ -2215,8 +2230,8 @@ int ena_com_get_dev_basic_stats(struct ena_com_dev *ena_dev,memset (&ctx,0x0 ,sizeof (ctx)); ret =ena_get_dev_stats (ena_dev, &ctx,ENA_ADMIN_GET_STATS_TYPE_BASIC );if (likely (ret ==0 )) -memcpy (stats, &ctx.get_resp.basic_stats, -sizeof (ctx.get_resp.basic_stats)); +memcpy (stats, &ctx.get_resp.u.basic_stats, +sizeof (ctx.get_resp.u.basic_stats));return ret; }
drivers/net/ena/base/ena_com.h +9 -0
@@ -600,6 +600,15 @@ int ena_com_get_dev_attr_feat(struct ena_com_dev *ena_dev,int ena_com_get_dev_basic_stats (struct ena_com_dev *ena_dev,struct ena_admin_basic_stats *stats); +/* ena_com_get_eni_stats - Get extended network interface statistics +* @ena_dev: ENA communication layer struct +* @stats: stats return value +* +* @return: 0 on Success and negative value otherwise. +*/ +int ena_com_get_eni_stats (struct ena_com_dev *ena_dev, +struct ena_admin_eni_stats *stats); +/* ena_com_set_dev_mtu - Configure the device mtu. * @ena_dev: ENA communication layer struct * @mtu: mtu value
drivers/net/ena/base/ena_defs/ena_admin_defs.h +36 -1
@@ -95,6 +95,8 @@ enum ena_admin_completion_policy_type {enum ena_admin_get_stats_type {ENA_ADMIN_GET_STATS_TYPE_BASIC =0 ,ENA_ADMIN_GET_STATS_TYPE_EXTENDED =1 , +/* extra HW stats for specific network interface */ +ENA_ADMIN_GET_STATS_TYPE_ENI =2 , };enum ena_admin_get_stats_scope {
@@ -388,10 +390,43 @@ struct ena_admin_basic_stats {uint32_t tx_drops_high; }; +/* ENI Statistics Command. */ +struct ena_admin_eni_stats { +/* The number of packets shaped due to inbound aggregate BW +* allowance being exceeded +*/ +uint64_t bw_in_allowance_exceeded; + +/* The number of packets shaped due to outbound aggregate BW +* allowance being exceeded +*/ +uint64_t bw_out_allowance_exceeded; + +/* The number of packets shaped due to PPS allowance being exceeded */ +uint64_t pps_allowance_exceeded; + +/* The number of packets shaped due to connection tracking +* allowance being exceeded and leading to failure in establishment +* of new connections +*/ +uint64_t conntrack_allowance_exceeded; + +/* The number of packets shaped due to linklocal packet rate +* allowance being exceeded +*/ +uint64_t linklocal_allowance_exceeded; +}; +struct ena_admin_acq_get_stats_resp {struct ena_admin_acq_common_desc acq_common_desc; -struct ena_admin_basic_stats basic_stats; +union { +uint64_t raw[7 ]; + +struct ena_admin_basic_stats basic_stats; + +struct ena_admin_eni_stats eni_stats; + } u; };struct ena_admin_get_set_feature_common_desc {
Signature · 1 line
2.25.1
PATCH 9/20 net/ena/base: split RSS function and hash getters
In reply to Michal KrawczykThere is no need to keep single function for both hash function and the key. If the caller want's to get only single value, then it had to pass NULL as one of the values, making the API harder to use.
Except reading functions from the device, one can also use function ena_com_get_current_hash_function() to get the integer value, which is represeting current hash function stored in the ena_com layer.
--- drivers/net/ena/base/ena_com.c | 26 +++++++++++++++++++------- drivers/net/ena/base/ena_com.h | 31 ++++++++++++++++++++++++------- 2 files changed, 43 insertions(+), 14 deletions(-)
drivers/net/ena/base/ena_com.c +19 -7
@@ -1062,6 +1062,11 @@ static int ena_com_get_feature(struct ena_com_dev *ena_dev, feature_ver); } +int ena_com_get_current_hash_function (struct ena_com_dev *ena_dev) +{ +return ena_dev->rss.hash_func; +} +static void ena_com_hash_key_fill_default_key (struct ena_com_dev *ena_dev) { struct ena_admin_feature_rss_flow_hash_control *hash_key =
@@ -2408,15 +2413,15 @@ int ena_com_fill_hash_function(struct ena_com_dev *ena_dev, }int ena_com_get_hash_function (struct ena_com_dev *ena_dev, -enum ena_admin_hash_functions *func, -u8 *key) +enum ena_admin_hash_functions *func) {struct ena_rss *rss = &ena_dev->rss;struct ena_admin_get_feat_resp get_resp; -struct ena_admin_feature_rss_flow_hash_control *hash_key = - rss->hash_key;int rc; +if (unlikely (!func)) +return ENA_COM_INVAL ; + rc = ena_com_get_feature_ex(ena_dev, &get_resp, ENA_ADMIN_RSS_HASH_FUNCTION, rss->hash_key_dma_addr,
@@ -2424,13 +2429,20 @@ int ena_com_get_hash_function(struct ena_com_dev *ena_dev,if (unlikely (rc))return rc; -/* ENA_FFS returns 1 in case the lsb is set */ +/* ENA_FFS() returns 1 in case the lsb is set */ rss->hash_func =ENA_FFS (get_resp.u.flow_hash_func.selected_func);if (rss->hash_func) rss->hash_func--; -if (func) - *func = rss->hash_func; + *func = rss->hash_func; + +return 0 ; +} + +int ena_com_get_hash_key (struct ena_com_dev *ena_dev,u8 *key) +{ +struct ena_admin_feature_rss_flow_hash_control *hash_key = + ena_dev->rss.hash_key;if (key)memcpy (key, hash_key->key, (size_t )(hash_key->keys_num) <<2 );
drivers/net/ena/base/ena_com.h +24 -7
@@ -645,6 +645,14 @@ int ena_com_rss_init(struct ena_com_dev *ena_dev, u16 log_size);*/ void ena_com_rss_destroy (struct ena_com_dev *ena_dev); +/* ena_com_get_current_hash_function - Get RSS hash function +* @ena_dev: ENA communication layer struct +* +* Return the current hash function. +* @return: 0 or one of the ena_admin_hash_functions values. +*/ +int ena_com_get_current_hash_function (struct ena_com_dev *ena_dev); +/* ena_com_fill_hash_function - Fill RSS hash function * @ena_dev: ENA communication layer struct * @func: The hash function (Toeplitz or crc)
@@ -676,23 +684,32 @@ int ena_com_fill_hash_function(struct ena_com_dev *ena_dev,*/ int ena_com_set_hash_function (struct ena_com_dev *ena_dev); -/* ena_com_get_hash_function - Retrieve the hash function and the hash key -* from the device. +/* ena_com_get_hash_function - Retrieve the hash function from the device. * @ena_dev: ENA communication layer struct * @func: hash function -* @key: hash key * -* Retrieve the hash function and the hash key from the device. +* Retrieve the hash function from the device. * -* @note: If the caller called ena_com_fill_hash_function but didn't flash +* @note: If the caller called ena_com_fill_hash_function but didn't flush * it to the device, the new configuration will be lost. * * @return: 0 on Success and negative value otherwise. */ int ena_com_get_hash_function (struct ena_com_dev *ena_dev, -enum ena_admin_hash_functions *func, -u8 *key); +enum ena_admin_hash_functions *func); +/* ena_com_get_hash_key - Retrieve the hash key +* @ena_dev: ENA communication layer struct +* @key: hash key +* +* Retrieve the hash key. +* +* @note: If the caller called ena_com_fill_hash_key but didn't flush +* it to the device, the new configuration will be lost. +* +* @return: 0 on Success and negative value otherwise. +*/ +int ena_com_get_hash_key (struct ena_com_dev *ena_dev,u8 *key);/* ena_com_fill_hash_ctrl - Fill RSS hash control * @ena_dev: ENA communication layer struct. * @proto: The protocol to configure.
Signature · 1 line
2.25.1
PATCH 10/20 net/ena/base: do not use hardcoded RSS key buffer size
In reply to Michal KrawczykIt's well defined how the RSS key buffer looks from the device perspective, so the constant calue should be used instead of magic number. Also it doesn't has to be calculated dynamically.
--- drivers/net/ena/base/ena_com.c | 7 +++---- drivers/net/ena/base/ena_defs/ena_admin_defs.h | 4 +++- 2 files changed, 6 insertions(+), 5 deletions(-)
drivers/net/ena/base/ena_com.c +3 -4
@@ -1073,11 +1073,10 @@ static void ena_com_hash_key_fill_default_key(struct ena_com_dev *ena_dev) (ena_dev->rss).hash_key;ENA_RSS_FILL_KEY (&hash_key->key,sizeof (hash_key->key)); -/* The key is stored in the device in uint32_t array -* as well as the API requires the key to be passed in this -* format. Thus the size of our array should be divided by 4 +/* The key buffer is stored in the device in an array of +* uint32 elements. */ - hash_key->keys_num =sizeof (hash_key->key) /sizeof (uint32_t ); + hash_key->keys_num =ENA_ADMIN_RSS_KEY_PARTS ; }static int ena_com_hash_key_allocate (struct ena_com_dev *ena_dev)
drivers/net/ena/base/ena_defs/ena_admin_defs.h +3 -1
@@ -9,6 +9,8 @@#define ENA_ADMIN_EXTRA_PROPERTIES_STRING_LEN 32#define ENA_ADMIN_EXTRA_PROPERTIES_COUNT 32 +#define ENA_ADMIN_RSS_KEY_PARTS 10 +enum ena_admin_aq_opcode {ENA_ADMIN_CREATE_SQ =1 ,ENA_ADMIN_DESTROY_SQ =2 ,
@@ -732,7 +734,7 @@ struct ena_admin_feature_rss_flow_hash_control {uint32_t reserved; -uint32_t key[10 ]; +uint32_t key[ENA_ADMIN_RSS_KEY_PARTS ]; };struct ena_admin_feature_rss_flow_hash_function {
Signature · 1 line
2.25.1
PATCH 11/20 net/ena/base: check for RSS key configuration support
In reply to Michal KrawczykSetting RSS hash function could not be supported by the device. In that situation there is no need to fill in default hash key or even allocate hash key.
--- drivers/net/ena/base/ena_com.c | 13 ++++++++++--- drivers/net/ena/base/ena_defs/ena_admin_defs.h | 15 ++++++++++++++- 2 files changed, 24 insertions(+), 4 deletions(-)
drivers/net/ena/base/ena_com.c +10 -3
@@ -1083,6 +1083,9 @@ static int ena_com_hash_key_allocate(struct ena_com_dev *ena_dev) {struct ena_rss *rss = &ena_dev->rss; +if (!ena_com_check_supported_feature_id (ena_dev,ENA_ADMIN_RSS_HASH_FUNCTION )) +return ENA_COM_UNSUPPORTED ; + ENA_MEM_ALLOC_COHERENT(ena_dev->dmadev, sizeof(*rss->hash_key), rss->hash_key,
@@ -2719,12 +2722,16 @@ int ena_com_rss_init(struct ena_com_dev *ena_dev, u16 indr_tbl_log_size)if (unlikely (rc)) goto err_indr_tbl; +/* The following function might return unsupported in case the +* device doesn't support setting the key / hash function. We can safely +* ignore this error and have indirection table support only. +*/ rc =ena_com_hash_key_allocate (ena_dev); -if (unlikely (rc)) +if (likely (!rc)) +ena_com_hash_key_fill_default_key (ena_dev); +else if (rc !=ENA_COM_UNSUPPORTED ) goto err_hash_key; -ena_com_hash_key_fill_default_key (ena_dev); - rc =ena_com_hash_ctrl_init (ena_dev);if (unlikely (rc)) goto err_hash_ctrl;
drivers/net/ena/base/ena_defs/ena_admin_defs.h +14 -1
@@ -873,7 +873,8 @@ struct ena_admin_host_info {* 1 : rx_offset * 2 : interrupt_moderation * 3 : map_rx_buf_bidirectional -* 31:4 : reserved +* 4 : rss_configurable_function_key +* 31:5 : reserved */ uint32_t driver_supported_features; };
@@ -1198,6 +1199,8 @@ struct ena_admin_ena_mmio_req_read_less_resp {#define ENA_ADMIN_HOST_INFO_INTERRUPT_MODERATION_MASK BIT(2)#define ENA_ADMIN_HOST_INFO_MAP_RX_BUF_BIDIRECTIONAL_SHIFT 3#define ENA_ADMIN_HOST_INFO_MAP_RX_BUF_BIDIRECTIONAL_MASK BIT(3) +#define ENA_ADMIN_HOST_INFO_RSS_CONFIGURABLE_FUNCTION_KEY_SHIFT 4 +#define ENA_ADMIN_HOST_INFO_RSS_CONFIGURABLE_FUNCTION_KEY_MASK BIT(4)/* feature_rss_ind_table */ #define ENA_ADMIN_FEATURE_RSS_IND_TABLE_ONE_ENTRY_UPDATE_MASK BIT(0)
@@ -1659,6 +1662,16 @@ static inline void set_ena_admin_host_info_map_rx_buf_bidirectional(struct ena_a p->driver_supported_features |= (val <<ENA_ADMIN_HOST_INFO_MAP_RX_BUF_BIDIRECTIONAL_SHIFT ) &ENA_ADMIN_HOST_INFO_MAP_RX_BUF_BIDIRECTIONAL_MASK ; } +static inline uint32_t get_ena_admin_host_info_rss_configurable_function_key (const struct ena_admin_host_info *p) +{ +return (p->driver_supported_features &ENA_ADMIN_HOST_INFO_RSS_CONFIGURABLE_FUNCTION_KEY_MASK ) >>ENA_ADMIN_HOST_INFO_RSS_CONFIGURABLE_FUNCTION_KEY_SHIFT ; +} + +static inline void set_ena_admin_host_info_rss_configurable_function_key (struct ena_admin_host_info *p,uint32_t val) +{ + p->driver_supported_features |= (val <<ENA_ADMIN_HOST_INFO_RSS_CONFIGURABLE_FUNCTION_KEY_SHIFT ) &ENA_ADMIN_HOST_INFO_RSS_CONFIGURABLE_FUNCTION_KEY_MASK ; +} +static inline uint8_t get_ena_admin_feature_rss_ind_table_one_entry_update (const struct ena_admin_feature_rss_ind_table *p) {return p->flags &ENA_ADMIN_FEATURE_RSS_IND_TABLE_ONE_ENTRY_UPDATE_MASK ;
Signature · 1 line
2.25.1
PATCH 12/20 net/ena/base: minor style adjustments
In reply to Michal Krawczyk* Function argument style improvement (space after *)
* Align indentation of the define
* Typo fix in the documentation
* Remove extra empty line after license (aligned with other files)
* Extra alignment of one line was fixed
--- drivers/net/ena/base/ena_com.c | 4 ++-- drivers/net/ena/base/ena_com.h | 4 ++-- drivers/net/ena/base/ena_defs/ena_eth_io_defs.h | 3 +-- drivers/net/ena/base/ena_defs/ena_gen_info.h | 1 - drivers/net/ena/base/ena_defs/ena_regs_defs.h | 3 +-- drivers/net/ena/base/ena_eth_com.c | 4 ++-- 6 files changed, 8 insertions(+), 11 deletions(-)
drivers/net/ena/base/ena_com.c +2 -2
@@ -1701,7 +1701,7 @@ void ena_com_set_admin_polling_mode(struct ena_com_dev *ena_dev, bool polling) ena_dev->admin_queue.polling = polling; } -bool ena_com_get_admin_polling_mode (struct ena_com_dev * ena_dev) +bool ena_com_get_admin_polling_mode (struct ena_com_dev *ena_dev) {return ena_dev->admin_queue.polling; }
@@ -2958,8 +2958,8 @@ int ena_com_config_dev_mode(struct ena_com_dev *ena_dev,struct ena_admin_feature_llq_desc *llq_features, struct ena_llq_configurations *llq_default_cfg) { + struct ena_com_llq_info *llq_info = &ena_dev->llq_info;int rc; -struct ena_com_llq_info *llq_info = &(ena_dev->llq_info);;if (!llq_features->max_llq_num) { ena_dev->tx_mem_queue_type =ENA_ADMIN_PLACEMENT_POLICY_HOST ;
drivers/net/ena/base/ena_com.h +2 -2
@@ -31,7 +31,7 @@#define ENA_INTR_INITIAL_RX_INTERVAL_USECS 0#define ENA_DEFAULT_INTR_DELAY_RESOLUTION 1 -#define ENA_HASH_KEY_SIZE 40 +#define ENA_HASH_KEY_SIZE 40#define ENA_HW_HINTS_NO_TIMEOUT 0xFFFF
@@ -744,7 +744,7 @@ int ena_com_set_hash_ctrl(struct ena_com_dev *ena_dev);* * Retrieve the hash control from the device. * -* @note: If the caller called ena_com_fill_hash_ctrl but didn't flash +* @note: If the caller called ena_com_fill_hash_ctrl but didn't flush * it to the device, the new configuration will be lost. * * @return: 0 on Success and negative value otherwise.
drivers/net/ena/base/ena_defs/ena_eth_io_defs.h +1 -2
@@ -1,8 +1,7 @@/* SPDX-License-Identifier: BSD-3-Clause -* Copyright (c) 2015-2019 Amazon.com, Inc. or its affiliates. +* Copyright (c) 2015-2020 Amazon.com, Inc. or its affiliates. * All rights reserved. */ -#ifndef _ENA_ETH_IO_H_#define _ENA_ETH_IO_H_
drivers/net/ena/base/ena_defs/ena_gen_info.h +0 -1
@@ -2,6 +2,5 @@* Copyright (c) 2015-2020 Amazon.com, Inc. or its affiliates. * All rights reserved. */ -#define ENA_GEN_DATE "Wed Sep 25 11:32:57 UTC 2019"#define ENA_GEN_COMMIT "952697a9e0d3"
drivers/net/ena/base/ena_defs/ena_regs_defs.h +1 -2
@@ -1,8 +1,7 @@/* SPDX-License-Identifier: BSD-3-Clause -* Copyright (c) 2015-2019 Amazon.com, Inc. or its affiliates. +* Copyright (c) 2015-2020 Amazon.com, Inc. or its affiliates. * All rights reserved. */ -#ifndef _ENA_REGS_H_#define _ENA_REGS_H_
drivers/net/ena/base/ena_eth_com.c +2 -2
@@ -188,8 +188,8 @@ static int ena_com_sq_update_llq_tail(struct ena_com_io_sq *io_sq) pkt_ctrl->curr_bounce_buf =ena_com_get_next_bounce_buffer (&io_sq->bounce_buf_ctrl); -memset (io_sq->llq_buf_ctrl.curr_bounce_buf, -0x0 , llq_info->desc_list_entry_size); +memset (io_sq->llq_buf_ctrl.curr_bounce_buf, +0x0 , llq_info->desc_list_entry_size); pkt_ctrl->idx =0 ;if (unlikely (llq_info->desc_stride_ctrl ==ENA_ADMIN_SINGLE_DESC_PER_ENTRY ))
Signature · 1 line
2.25.1
PATCH 13/20 net/ena/base: add missing unlikely
In reply to Michal KrawczykTo align the error checking code with other parts of the ena_com, the conditional check is being tested for the error was wrapped inside unlikely().
--- drivers/net/ena/base/ena_com.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ena/base/ena_com.c +1 -1
@@ -2973,7 +2973,7 @@ int ena_com_config_dev_mode(struct ena_com_dev *ena_dev, ena_dev->tx_max_header_size = llq_info->desc_list_entry_size - (llq_info->descs_num_before_header *sizeof (struct ena_eth_io_tx_desc )); -if (ena_dev->tx_max_header_size ==0 ) { +if (unlikely (ena_dev->tx_max_header_size ==0 )) {ena_trc_err ("the size of the LLQ entry is smaller than needed\n" );return -EINVAL ; }
Signature · 1 line
2.25.1
PATCH 14/20 net/ena/base: store admin stats as u64
In reply to Michal KrawczykTo minimize chance of integer overflow, the type of admin statistics was changed from u32 to u64.
--- drivers/net/ena/base/ena_com.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/ena/base/ena_com.h +5 -5
@@ -192,11 +192,11 @@ struct ena_com_admin_sq { };struct ena_com_stats_admin { -u32 aborted_cmd; -u32 submitted_cmd; -u32 completed_cmd; -u32 out_of_space; -u32 no_completion; +u64 aborted_cmd; +u64 submitted_cmd; +u64 completed_cmd; +u64 out_of_space; +u64 no_completion; };struct ena_com_admin_queue {
Signature · 1 line
2.25.1
PATCH 15/20 net/ena/base: add check for meta desc being NULL
In reply to Michal KrawczykStatic code analysis showed up, that it's possible for meta_desc being NULL. To avoid dereference of the NULL pointer, extra check was added if the pointer is in fact valid.
--- drivers/net/ena/base/ena_eth_com.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ena/base/ena_eth_com.c +3 -0
@@ -268,6 +268,9 @@ static int ena_com_create_meta(struct ena_com_io_sq *io_sq,struct ena_eth_io_tx_meta_desc *meta_desc =NULL ; meta_desc =get_sq_desc (io_sq); +if (unlikely (!meta_desc)) +return ENA_COM_FAULT ; +memset (meta_desc,0x0 ,sizeof (struct ena_eth_io_tx_meta_desc )); meta_desc->len_ctrl |=ENA_ETH_IO_TX_META_DESC_META_DESC_MASK ;
Signature · 1 line
2.25.1
PATCH 16/20 net/ena/base: convert values to u32 before shifting
In reply to Michal KrawczykWhen filling out meta descriptor, all values should be converted to the desired type (u32 in case of the meta descriptor) to prevent losing the data.
For example, io_sq->phase is of type u8. If ENA_ETH_IO_TX_META_DESC_PHASE_SHIFT would be greater then 8, all data would be lost.
--- drivers/net/ena/base/ena_eth_com.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/net/ena/base/ena_eth_com.c +7 -7
@@ -278,7 +278,7 @@ static int ena_com_create_meta(struct ena_com_io_sq *io_sq, meta_desc->len_ctrl |=ENA_ETH_IO_TX_META_DESC_EXT_VALID_MASK ;/* bits 0-9 of the mss */ - meta_desc->word2 |= (ena_meta->mss << + meta_desc->word2 |= ((u32 )ena_meta->mss <<ENA_ETH_IO_TX_META_DESC_MSS_LO_SHIFT ) &ENA_ETH_IO_TX_META_DESC_MSS_LO_MASK ;/* bits 10-13 of the mss */
@@ -288,7 +288,7 @@ static int ena_com_create_meta(struct ena_com_io_sq *io_sq,/* Extended meta desc */ meta_desc->len_ctrl |=ENA_ETH_IO_TX_META_DESC_ETH_META_TYPE_MASK ; - meta_desc->len_ctrl |= (io_sq->phase << + meta_desc->len_ctrl |= ((u32 )io_sq->phase <<ENA_ETH_IO_TX_META_DESC_PHASE_SHIFT ) &ENA_ETH_IO_TX_META_DESC_PHASE_MASK ;
@@ -301,7 +301,7 @@ static int ena_com_create_meta(struct ena_com_io_sq *io_sq, ENA_ETH_IO_TX_META_DESC_L3_HDR_OFF_SHIFT) &ENA_ETH_IO_TX_META_DESC_L3_HDR_OFF_MASK ; - meta_desc->word2 |= (ena_meta->l4_hdr_len << + meta_desc->word2 |= ((u32 )ena_meta->l4_hdr_len <<ENA_ETH_IO_TX_META_DESC_L4_HDR_LEN_IN_WORDS_SHIFT ) &ENA_ETH_IO_TX_META_DESC_L4_HDR_LEN_IN_WORDS_MASK ;
@@ -434,16 +434,16 @@ int ena_com_prepare_tx(struct ena_com_io_sq *io_sq,if (!have_meta) desc->len_ctrl |=ENA_ETH_IO_TX_DESC_FIRST_MASK ; - desc->buff_addr_hi_hdr_sz |= (header_len << + desc->buff_addr_hi_hdr_sz |= ((u32 )header_len <<ENA_ETH_IO_TX_DESC_HEADER_LENGTH_SHIFT ) &ENA_ETH_IO_TX_DESC_HEADER_LENGTH_MASK ; - desc->len_ctrl |= (io_sq->phase <<ENA_ETH_IO_TX_DESC_PHASE_SHIFT ) & + desc->len_ctrl |= ((u32 )io_sq->phase <<ENA_ETH_IO_TX_DESC_PHASE_SHIFT ) &ENA_ETH_IO_TX_DESC_PHASE_MASK ; desc->len_ctrl |=ENA_ETH_IO_TX_DESC_COMP_REQ_MASK ;/* Bits 0-9 */ - desc->meta_ctrl |= (ena_tx_ctx->req_id << + desc->meta_ctrl |= ((u32 )ena_tx_ctx->req_id <<ENA_ETH_IO_TX_DESC_REQ_ID_LO_SHIFT ) &ENA_ETH_IO_TX_DESC_REQ_ID_LO_MASK ;
@@ -491,7 +491,7 @@ int ena_com_prepare_tx(struct ena_com_io_sq *io_sq,memset (desc,0x0 ,sizeof (struct ena_eth_io_tx_desc )); - desc->len_ctrl |= (io_sq->phase << + desc->len_ctrl |= ((u32 )io_sq->phase <<ENA_ETH_IO_TX_DESC_PHASE_SHIFT ) &ENA_ETH_IO_TX_DESC_PHASE_MASK ; }
Signature · 1 line
2.25.1
PATCH 17/20 net/ena/base: simplify loop copying Rx descs
In reply to Michal KrawczykChecking for the cdesc not being NULL doesn't have any sense if the idx argument is not 0, so it can be skipped, as the error won't be detected anyway.
To simplify that, only the 'i' value is being verified and the code is breaking from the infinite loop in case when all descriptors were copied into the buffer.
--- drivers/net/ena/base/ena_eth_com.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/net/ena/base/ena_eth_com.c +9 -4
@@ -557,10 +557,15 @@ int ena_com_rx_pkt(struct ena_com_io_cq *io_cq, ena_rx_ctx->pkt_offset = cdesc->offset;do { - ena_buf->len = cdesc->length; - ena_buf->req_id = cdesc->req_id; - ena_buf++; - }while ((++i < nb_hw_desc) && (cdesc =ena_com_rx_cdesc_idx_to_ptr (io_cq, cdesc_idx + i))); + ena_buf[i].len = cdesc->length; + ena_buf[i].req_id = cdesc->req_id; + +if (++i >= nb_hw_desc) +break ; + + cdesc =ena_com_rx_cdesc_idx_to_ptr (io_cq, cdesc_idx + i); + + }while (1 );/* Update SQ head ptr */ io_sq->next_to_comp += nb_hw_desc;
Signature · 1 line
2.25.1
PATCH 18/20 net/ena/base: update generation date and commit
In reply to Michal KrawczykThe current ena_com version was generated on 26.04.2020.
--- drivers/net/ena/base/ena_defs/ena_gen_info.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ena/base/ena_defs/ena_gen_info.h +2 -2
@@ -2,5 +2,5 @@* Copyright (c) 2015-2020 Amazon.com, Inc. or its affiliates. * All rights reserved. */ -#define ENA_GEN_DATE "Wed Sep 25 11:32:57 UTC 2019" -#define ENA_GEN_COMMIT "952697a9e0d3" +#define ENA_GEN_DATE "Sun Apr 26 13:45:21 DST 2020" +#define ENA_GEN_COMMIT "37aa7c3"
Signature · 1 line
2.25.1
PATCH 19/20 net/ena: lock dynamic usages of the admin queue
In reply to Michal KrawczykThere are some cases, where the admin queue commands after the configuration phase finished - for example, the application could ask for the driver statitics from multiple cores at once.
As by the design, the admin queue is not multithread safe, the spinlock was added to protect all usages of the admin queue after the configuration is done.
--- drivers/net/ena/ena_ethdev.c | 9 +++++++++ drivers/net/ena/ena_ethdev.h | 7 +++++++ 2 files changed, 16 insertions(+)
drivers/net/ena/ena_ethdev.c +9 -0
@@ -570,7 +570,9 @@ static int ena_rss_reta_update(struct rte_eth_dev *dev, } } +rte_spinlock_lock (&adapter->admin_lock); rc =ena_com_indirect_table_set (ena_dev); +rte_spinlock_unlock (&adapter->admin_lock);if (unlikely (rc && rc !=ENA_COM_UNSUPPORTED )) {PMD_DRV_LOG (ERR ,"Cannot flush the indirect table\n" );return rc;
@@ -599,7 +601,9 @@ static int ena_rss_reta_query(struct rte_eth_dev *dev, (reta_size > RTE_RETA_GROUP_SIZE && ((reta_conf + 1) == NULL)))return -EINVAL ; +rte_spinlock_lock (&adapter->admin_lock); rc =ena_com_indirect_table_get (ena_dev, indirect_table); +rte_spinlock_unlock (&adapter->admin_lock);if (unlikely (rc && rc !=ENA_COM_UNSUPPORTED )) {PMD_DRV_LOG (ERR ,"cannot get indirect table\n" );return -ENOTSUP ;
@@ -954,7 +958,10 @@ static int ena_stats_get(struct rte_eth_dev *dev,return -ENOTSUP ;memset (&ena_stats,0 ,sizeof (ena_stats)); + +rte_spinlock_lock (&adapter->admin_lock); rc =ena_com_get_dev_basic_stats (ena_dev, &ena_stats); +rte_spinlock_unlock (&adapter->admin_lock);if (unlikely (rc)) {PMD_DRV_LOG (ERR ,"Could not retrieve statistics from ENA\n" );return rc;
@@ -1876,6 +1883,8 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev) goto err_delete_debug_area; } +rte_spinlock_init (&adapter->admin_lock); +rte_intr_callback_register (intr_handle, ena_interrupt_handler_rte, adapter);
drivers/net/ena/ena_ethdev.h +7 -0
@@ -200,6 +200,13 @@ struct ena_adapter {u16 max_mtu;struct ena_offloads offloads; +/* The admin queue isn't protected by the lock and is used to +* retrieve statistics from the device. As there is no guarantee that +* application won't try to get statistics from multiple threads, it is +* safer to lock the queue to avoid admin queue failure. +*/ +rte_spinlock_t admin_lock; +int id_number;char name[ENA_NAME_MAX_LEN ];u8 mac_addr[RTE_ETHER_ADDR_LEN ];
Signature · 1 line
2.25.1
PATCH 20/20 net/ena: expose ENI stats as additional xstats
In reply to Michal KrawczykNew HAL allows driver to read extra ENI stats. Exact meaning of each of them can be found in base/ena_defs/ena_admin_defs.h file and structure ena_admin_eni_stats.
The ena_eni_stats structure is exactly the same as ena_admin_eni_stats, but it was required to be added for compatibility with xstats macros.
Reading ENI stats requires communication with the admin queue.
--- drivers/net/ena/ena_ethdev.c | 77 +++++++++++++++++++++++++++++++++++- drivers/net/ena/ena_ethdev.h | 27 +++++++++++++ 2 files changed, 102 insertions(+), 2 deletions(-)
drivers/net/ena/ena_ethdev.c +75 -2
@@ -72,6 +72,9 @@ struct ena_stats {#define ENA_STAT_TX_ENTRY (stat) \ ENA_STAT_ENTRY(stat, tx) +#define ENA_STAT_ENI_ENTRY (stat) \ + ENA_STAT_ENTRY(stat, eni) +#define ENA_STAT_GLOBAL_ENTRY (stat) \ ENA_STAT_ENTRY(stat, dev)
@@ -91,6 +94,14 @@ static const struct ena_stats ena_stats_global_strings[] = { ENA_STAT_GLOBAL_ENTRY(tx_drops), }; +static const struct ena_stats ena_stats_eni_strings[] = { +ENA_STAT_ENI_ENTRY (bw_in_allowance_exceeded), +ENA_STAT_ENI_ENTRY (bw_out_allowance_exceeded), +ENA_STAT_ENI_ENTRY (pps_allowance_exceeded), +ENA_STAT_ENI_ENTRY (conntrack_allowance_exceeded), +ENA_STAT_ENI_ENTRY (linklocal_allowance_exceeded), +}; +static const struct ena_stats ena_stats_tx_strings[] = {ENA_STAT_TX_ENTRY (cnt),ENA_STAT_TX_ENTRY (bytes),
@@ -114,6 +125,7 @@ static const struct ena_stats ena_stats_rx_strings[] = { };#define ENA_STATS_ARRAY_GLOBAL ARRAY_SIZE(ena_stats_global_strings) +#define ENA_STATS_ARRAY_ENI ARRAY_SIZE(ena_stats_eni_strings)#define ENA_STATS_ARRAY_TX ARRAY_SIZE(ena_stats_tx_strings)#define ENA_STATS_ARRAY_RX ARRAY_SIZE(ena_stats_rx_strings)
@@ -233,6 +245,7 @@ static int ena_process_bool_devarg(const char *key, void *opaque);static int ena_parse_devargs (struct ena_adapter *adapter,struct rte_devargs *devargs); +static int ena_copy_eni_stats (struct ena_adapter *adapter);static const struct eth_dev_ops ena_dev_ops = { .dev_configure = ena_dev_configure,
@@ -451,7 +464,7 @@ static void ena_config_host_info(struct ena_com_dev *ena_dev)/* This function calculates the number of xstats based on the current config */ static unsigned int ena_xstats_calc_num (struct rte_eth_dev *dev) { -return ENA_STATS_ARRAY_GLOBAL + +return ENA_STATS_ARRAY_GLOBAL +ENA_STATS_ARRAY_ENI + (dev->data->nb_tx_queues *ENA_STATS_ARRAY_TX ) + (dev->data->nb_rx_queues *ENA_STATS_ARRAY_RX ); }
@@ -2608,6 +2621,31 @@ static uint16_t eth_ena_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,return sent_idx; } +int ena_copy_eni_stats (struct ena_adapter *adapter) +{ +struct ena_admin_eni_stats admin_eni_stats; +int rc; + +rte_spinlock_lock (&adapter->admin_lock); + rc =ena_com_get_eni_stats (&adapter->ena_dev, &admin_eni_stats); +rte_spinlock_unlock (&adapter->admin_lock); +if (rc !=0 ) { +if (rc ==ENA_COM_UNSUPPORTED ) { +PMD_DRV_LOG (DEBUG , +"Retrieving ENI metrics is not supported.\n" ); + }else { +PMD_DRV_LOG (WARNING , +"Failed to get ENI metrics: %d\n" , rc); + } +return rc; + } + +rte_memcpy (&adapter->eni_stats, &admin_eni_stats, +sizeof (struct ena_stats_eni )); + +return 0 ; +} +/** * DPDK callback to retrieve names of extended device statistics *
@@ -2635,6 +2673,10 @@ static int ena_xstats_get_names(struct rte_eth_dev *dev,strcpy (xstats_names[count].name, ena_stats_global_strings[stat].name); +for (stat =0 ; stat <ENA_STATS_ARRAY_ENI ; stat++, count++) +strcpy (xstats_names[count].name, + ena_stats_eni_strings[stat].name); +for (stat =0 ; stat <ENA_STATS_ARRAY_RX ; stat++)for (i =0 ; i < dev->data->nb_rx_queues; i++, count++) snprintf(xstats_names[count].name,
@@ -2690,6 +2732,19 @@ static int ena_xstats_get(struct rte_eth_dev *dev, ((char *)stats_begin + stat_offset)); } +/* Even if the function below fails, we should copy previous (or initial +* values) to keep structure of rte_eth_xstat consistent. +*/ +ena_copy_eni_stats (adapter); +for (stat =0 ; stat <ENA_STATS_ARRAY_ENI ; stat++, count++) { + stat_offset = ena_stats_eni_strings[stat].stat_offset; + stats_begin = &adapter->eni_stats; + + xstats[count].id = count; + xstats[count].value = *((uint64_t *) + ((char *)stats_begin + stat_offset)); + } +for (stat =0 ; stat <ENA_STATS_ARRAY_RX ; stat++) {for (i =0 ; i < dev->data->nb_rx_queues; i++, count++) { stat_offset = ena_stats_rx_strings[stat].stat_offset;
@@ -2726,6 +2781,8 @@ static int ena_xstats_get_by_id(struct rte_eth_dev *dev,unsigned int i;int qid;int valid =0 ; +bool was_eni_copied = false; +for (i =0 ; i < n; ++i) { id = ids[i];/* Check if id belongs to global statistics */
@@ -2735,8 +2792,24 @@ static int ena_xstats_get_by_id(struct rte_eth_dev *dev,continue ; } -/* Check if id belongs to rx queue statistics */ +/* Check if id belongs to ENI statistics */ id -=ENA_STATS_ARRAY_GLOBAL ; +if (id <ENA_STATS_ARRAY_ENI ) { +/* Avoid reading ENI stats multiple times in a single +* function call, as it requires communication with the +* admin queue. +*/ +if (!was_eni_copied) { + was_eni_copied = true; +ena_copy_eni_stats (adapter); + } + values[i] = *((uint64_t *)&adapter->eni_stats + id); + ++valid; +continue ; + } + +/* Check if id belongs to rx queue statistics */ + id -=ENA_STATS_ARRAY_ENI ; rx_entries =ENA_STATS_ARRAY_RX * dev->data->nb_rx_queues;if (id < rx_entries) { qid = id % dev->data->nb_rx_queues;
drivers/net/ena/ena_ethdev.h +27 -0
@@ -171,6 +171,32 @@ struct ena_stats_dev {u64 tx_drops; }; +struct ena_stats_eni { +/* +* The number of packets shaped due to inbound aggregate BW +* allowance being exceeded +*/ +uint64_t bw_in_allowance_exceeded; +/* +* The number of packets shaped due to outbound aggregate BW +* allowance being exceeded +*/ +uint64_t bw_out_allowance_exceeded; +/* The number of packets shaped due to PPS allowance being exceeded */ +uint64_t pps_allowance_exceeded; +/* +* The number of packets shaped due to connection tracking +* allowance being exceeded and leading to failure in establishment +* of new connections +*/ +uint64_t conntrack_allowance_exceeded; +/* +* The number of packets shaped due to linklocal packet rate +* allowance being exceeded +*/ +uint64_t linklocal_allowance_exceeded; +}; +struct ena_offloads {bool tso4_supported;bool tx_csum_supported;
@@ -231,6 +257,7 @@ struct ena_adapter {uint64_t keep_alive_timeout;struct ena_stats_dev dev_stats; +struct ena_stats_eni eni_stats;bool trigger_reset;
Signature · 1 line
2.25.1
Quoted 32 lines · On Thu, 17 Sep 2020 07:30:15 +0200 Michal Krawczyk <[email protected]> wrote:
Hi,
this patchset contains upgrade of the of the HAL, which, beside some fixes, also adds possibility for reading ENI metrics from the device.
Those are further exposed to the DPDK applicaiton using xstats.
As it's an extra call to the admin queue during a PMD runtime, for multithread safet the locks had to be added around those functions.
Michal Krawczyk (20):
net/ena/base: use min/max macros with type conversionnet/ena/base: specify operations ofrte_delaynet/ena/base: support 'resource busy' admin statusnet/ena/base: exponential delay in polling functionsnet/ena/base: fix release of wait eventnet/ena/base: removeMMIOWB_NOT_DEFINEDifdefnet/ena/base: rework setup of accelerated LLQ modenet/ena/base: add ENI stats
net/ena/base: split RSS function and hash gettersnet/ena/base: do not use hardcoded RSS key buffer sizenet/ena/base: check for RSS key configuration supportnet/ena/base: minor style adjustmentsnet/ena/base: add missing unlikelynet/ena/base: store admin stats as u64net/ena/base: add check for meta desc being NULLnet/ena/base: convert values to u32 before shiftingnet/ena/base: simplify loop copying Rx descsnet/ena/base: update generation date and commit net/ena: lock dynamic usages of the admin queue net/ena: expose ENI stats as additional xstats
Quoted 13 lines
drivers/net/ena/base/ena_com.c | 137 ++++++++++++------ drivers/net/ena/base/ena_com.h | 57 ++++++-- .../net/ena/base/ena_defs/ena_admin_defs.h | 56 ++++++- .../net/ena/base/ena_defs/ena_eth_io_defs.h | 3 +- drivers/net/ena/base/ena_defs/ena_gen_info.h | 5 +- drivers/net/ena/base/ena_defs/ena_regs_defs.h | 3 +- drivers/net/ena/base/ena_eth_com.c | 34 +++-- drivers/net/ena/base/ena_eth_com.h | 2 +- drivers/net/ena/base/ena_plat_dpdk.h | 19 ++- drivers/net/ena/ena_ethdev.c | 86 ++++++++++- drivers/net/ena/ena_ethdev.h | 34 +++++ 11 files changed, 344 insertions(+), 92 deletions(-)
Looks good
Quoted 49 lines · Stephen Hemminger
Quoted 32 lines · On Thu, 17 Sep 2020 07:30:15 +0200 Michal Krawczyk <[email protected]> wrote:
Hi,
this patchset contains upgrade of the of the HAL, which, beside some fixes, also adds possibility for reading ENI metrics from the device.
Those are further exposed to the DPDK applicaiton using xstats.
As it's an extra call to the admin queue during a PMD runtime, for multithread safet the locks had to be added around those functions.
Michal Krawczyk (20):
net/ena/base: use min/max macros with type conversionnet/ena/base: specify operations ofrte_delaynet/ena/base: support 'resource busy' admin statusnet/ena/base: exponential delay in polling functionsnet/ena/base: fix release of wait eventnet/ena/base: removeMMIOWB_NOT_DEFINEDifdefnet/ena/base: rework setup of accelerated LLQ modenet/ena/base: add ENI stats
net/ena/base: split RSS function and hash gettersnet/ena/base: do not use hardcoded RSS key buffer sizenet/ena/base: check for RSS key configuration supportnet/ena/base: minor style adjustmentsnet/ena/base: add missing unlikelynet/ena/base: store admin stats as u64net/ena/base: add check for meta desc being NULLnet/ena/base: convert values to u32 before shiftingnet/ena/base: simplify loop copying Rx descsnet/ena/base: update generation date and commit net/ena: lock dynamic usages of the admin queue net/ena: expose ENI stats as additional xstatsQuoted 13 lines
drivers/net/ena/base/ena_com.c | 137 ++++++++++++------ drivers/net/ena/base/ena_com.h | 57 ++++++-- .../net/ena/base/ena_defs/ena_admin_defs.h | 56 ++++++- .../net/ena/base/ena_defs/ena_eth_io_defs.h | 3 +- drivers/net/ena/base/ena_defs/ena_gen_info.h | 5 +- drivers/net/ena/base/ena_defs/ena_regs_defs.h | 3 +- drivers/net/ena/base/ena_eth_com.c | 34 +++-- drivers/net/ena/base/ena_eth_com.h | 2 +- drivers/net/ena/base/ena_plat_dpdk.h | 19 ++- drivers/net/ena/ena_ethdev.c | 86 ++++++++++- drivers/net/ena/ena_ethdev.h | 34 +++++ 11 files changed, 344 insertions(+), 92 deletions(-)
Quoted 4 lines
Looks good
Reviewed-by Stephen Hemminger <[email protected]>
Series applied to dpdk-next-net/main, thanks.