From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id ADB9B4318A for ; Tue, 17 Oct 2023 13:18:46 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A878D4029E; Tue, 17 Oct 2023 13:18:46 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 7470B40273; Tue, 17 Oct 2023 13:18:45 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39H5tuBN027249; Tue, 17 Oct 2023 04:18:44 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=+4OyIJxlJEAP/taOTecx5m9QYIWqnnGEmgVsbB/Sp84=; b=IBNHb+fg0sa4CWAevaZHdi3lVVMOtsl2gXwwL7e6B0vdm+dPVMvgl7TK7By1NVffOfEv fVXQ952obGzFq2mRiVSHS1w+soKD+iG423wj64hJ16Gcjq4AVNcxGbQvPC26uLl3VNpR JptDMnbjWiunM0SoOa6DkhZT11Uc//V0VMCJOAqk3utjHEul7TPdfjJ9VhAxjoMLaUWm 1GH1q3/FMZGgYmkS6DthcoaIbeb3IXDIbWtrM+5cZpS2iPajqHLIEpUXF/q8EZ4/wj2h XlYP7J2wAT7QzoVjS3Sg3GV/J51Oqux+HjyoWNGKqC1h5o9Itl2oJ93JBewD85ofIjLT og== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3tsmj511d4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 17 Oct 2023 04:18:44 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Tue, 17 Oct 2023 04:18:42 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Tue, 17 Oct 2023 04:18:42 -0700 Received: from localhost.localdomain (unknown [10.28.36.185]) by maili.marvell.com (Postfix) with ESMTP id 5E61B5B6944; Tue, 17 Oct 2023 04:18:40 -0700 (PDT) From: Ankur Dwivedi To: CC: , , , , , Ankur Dwivedi , Subject: [PATCH v1] common/cnxk: fix flow add in age flow list Date: Tue, 17 Oct 2023 16:48:37 +0530 Message-ID: <20231017111837.1434411-1-adwivedi@marvell.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: D263hkJMscM4-E9M5ur2RwQHOgfw6Ijh X-Proofpoint-GUID: D263hkJMscM4-E9M5ur2RwQHOgfw6Ijh X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-16_13,2023-10-17_01,2023-05-22_02 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org While adding flow in npc_flow_list, the flow can be added before the current flow iterator. The function returns after adding this flow. This prevents flow to be added in age flow list correctly. This patch moves the addition of age flow list before npc_flow_list add to prevent the error. Also the flow is added or deleted to/from age flow list if the flow has age action. Fixes: 357f5ebc8a24 ("common/cnxk: support flow aging") Cc: stable@dpdk.org Signed-off-by: Ankur Dwivedi --- drivers/common/cnxk/roc_npc.c | 9 ++++++--- drivers/common/cnxk/roc_npc.h | 1 + drivers/common/cnxk/roc_npc_aging.c | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c index f36f5e42c8..7593466bc1 100644 --- a/drivers/common/cnxk/roc_npc.c +++ b/drivers/common/cnxk/roc_npc.c @@ -1510,6 +1510,9 @@ roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, goto set_rss_failed; } + if (flow->has_age_action) + npc_age_flow_list_entry_add(roc_npc, flow); + if (flow->use_pre_alloc == 0) list = &npc->flow_list[flow->priority]; else @@ -1523,8 +1526,6 @@ roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, } TAILQ_INSERT_TAIL(list, flow, next); - npc_age_flow_list_entry_add(roc_npc, flow); - return flow; set_rss_failed: @@ -1622,7 +1623,9 @@ roc_npc_flow_destroy(struct roc_npc *roc_npc, struct roc_npc_flow *flow) npc_delete_prio_list_entry(npc, flow); - npc_age_flow_list_entry_delete(roc_npc, flow); + if (flow->has_age_action) + npc_age_flow_list_entry_delete(roc_npc, flow); + if (roc_npc->flow_age.age_flow_refcnt == 0 && plt_thread_is_valid(roc_npc->flow_age.aged_flows_poll_thread)) npc_aging_ctrl_thread_destroy(roc_npc); diff --git a/drivers/common/cnxk/roc_npc.h b/drivers/common/cnxk/roc_npc.h index cf7e6c9548..4b387f2a6b 100644 --- a/drivers/common/cnxk/roc_npc.h +++ b/drivers/common/cnxk/roc_npc.h @@ -320,6 +320,7 @@ struct roc_npc_flow { uint64_t timeout_cycles; void *age_context; uint32_t timeout; + bool has_age_action; TAILQ_ENTRY(roc_npc_flow) next; }; diff --git a/drivers/common/cnxk/roc_npc_aging.c b/drivers/common/cnxk/roc_npc_aging.c index 74543f227b..a456d2b893 100644 --- a/drivers/common/cnxk/roc_npc_aging.c +++ b/drivers/common/cnxk/roc_npc_aging.c @@ -273,6 +273,7 @@ npc_aging_ctrl_thread_create(struct roc_npc *roc_npc, flow->age_context = age->context == NULL ? flow : age->context; flow->timeout = age->timeout; flow->timeout_cycles = plt_tsc_cycles() + age->timeout * plt_tsc_hz(); + flow->has_age_action = true; if (flow_age->age_flow_refcnt == 0) { flow_age->aged_flows_get_thread_exit = false; -- 2.25.1