ena_com_config_dev_mode() computes tx_max_header_size directly
into the ena_com_dev structure and only afterwards rejects the
result if it came out zero. The error path therefore leaves the
device with tx_max_header_size == 0, overwriting the value the
device reported in ena_com_get_dev_attr_feat().

The failure is not fatal to the caller: the PMD logs it, falls
back to host placement policy and continues, so the zeroed value
stays in effect. It is then copied into the per-ring field, which
sizes the Tx intermediate header buffer to zero and clamps
header_len to zero on every transmit.

Compute the value into a local variable, validate it there, and
store it into ena_dev only once it is known good, so a failed LLQ
configuration leaves the previously negotiated value untouched.

Fixes: b2b02edeb0d6 ("net/ena/base: upgrade HAL for new HW features")
Cc: [email protected]

Signed-off-by: Shai Brandes <[email protected]>
---
 drivers/net/ena/base/ena_com.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ena/base/ena_com.c b/drivers/net/ena/base/ena_com.c
index 7ec36b8814..9030b0f2c1 100644
--- a/drivers/net/ena/base/ena_com.c
+++ b/drivers/net/ena/base/ena_com.c
@@ -3581,6 +3581,7 @@ int ena_com_config_dev_mode(struct ena_com_dev *ena_dev,
                            struct ena_llq_configurations *llq_default_cfg)
 {
        struct ena_com_llq_info *llq_info = &ena_dev->llq_info;
+       u32 llq_max_header_size;
        int rc;
 
        if (!llq_features->max_llq_num) {
@@ -3592,14 +3593,15 @@ int ena_com_config_dev_mode(struct ena_com_dev *ena_dev,
        if (unlikely(rc))
                return rc;
 
-       ena_dev->tx_max_header_size = llq_info->common.desc_list_entry_size -
+       llq_max_header_size = llq_info->common.desc_list_entry_size -
                (llq_info->common.descs_num_before_header * sizeof(struct 
ena_eth_io_tx_desc));
 
-       if (unlikely(ena_dev->tx_max_header_size == 0)) {
+       if (unlikely(llq_max_header_size == 0)) {
                ena_trc_err(ena_dev, "The size of the LLQ entry is smaller than 
needed\n");
                return ENA_COM_INVAL;
        }
 
+       ena_dev->tx_max_header_size = llq_max_header_size;
        ena_dev->tx_mem_queue_type = ENA_ADMIN_PLACEMENT_POLICY_DEV;
 
        return 0;
-- 
2.17.1

Reply via email to