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 AFE46A0524; Wed, 5 May 2021 11:51:33 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A10DA41122; Wed, 5 May 2021 11:50:48 +0200 (CEST) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2057.outbound.protection.outlook.com [40.107.244.57]) by mails.dpdk.org (Postfix) with ESMTP id 0D0DF4113C for ; Wed, 5 May 2021 11:50:47 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FgID5sLrSEc4bR27ET00PFrVixGBGFSTk/Jw2zplLC/LRW/dPWXa0b08RsYSPzICezrsgpPr92CPPipSGmwatYYZ6M0kiU+je3UqQG4SCZOFBkMBTyRGfjYREY1LcklSy4aNDH8OQdgfma7T6XQXCMzinsDWS839BHp/GfJ6HbBkWFYhJa25xEZ9LSYqZ6zEEKsCfQ2VqttyODQ9e0tU4Xbkf39lwaAIArU9e0Td5x991b0vap3SiZPXb3nD9HlvIEAbAltxULwIf4XRcDFjLOEpt5lwfXNKusOwHvr2Nb0LvKO23KTZm+Ly6cuyRsZOwXYFDUKIjcMVVOl+R9EEFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZxMXfxoCal1bR3GUs8kb1P/L4xa06+WeA69eHYJHJC0=; b=MD7zc+OddzVc/G2pHMi80I1Dsmyctyf/qNcJR4w192F3oLKrqGhnG5hmR7P+6QG3zXDkBvB3jNArE2t9XjtkmnoG50BtaU0Dz/pcssXZO03FDYr0qd3FxlECuiNfsspmbN/yr/XCsi2EA/mUFZj3TRqn1186mdUnhatvEu689xIslr8iNdVfPUcovETURBDzDr9nhBnmSnlmduUQsYU95YBQ0AnfzcLiRRB64a8T301i28p25Sj2MxOpzsCAY6sUnP2MYOjGBMitKXKDlS5EPGj+zOCtOKCPwaOaIf2wFQJ3zbEVXDGXeUNqQ1cd9Hmai0Bhe5k9C5P1uAMZ/dzOYg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZxMXfxoCal1bR3GUs8kb1P/L4xa06+WeA69eHYJHJC0=; b=biqXd4PN7iryu7FAHOkdeEqOZyH+6/jYCX8ECOton780+dv8cVb7yC73T8B4iZPqQFjLQeER9LGNzb1JEdUS1Ola4l3IelbK6Daik6HLEZRjjD0mW4nl75oncF3IX+GMtrE6/p/UUPmTFjKh4Eo5+smOhsdccW3ng212v3UwMi+OeJASQHf9sUMmS/MtJvpia/nIE1Jz5M1j4eZ/7OmcwwRTSIspqL944/mvquwMWzVXIMthIpqK2YDL95Scub40Fqfg32Zsq0UOodZfBX2MSw4NQPD/2+yFzQedTTA4pWb7tSyIoGaEPNMoHIH17JxPKPntFSwyNnKYAErJgsPvhQ== Received: from BN9PR03CA0527.namprd03.prod.outlook.com (2603:10b6:408:131::22) by DM6PR12MB2939.namprd12.prod.outlook.com (2603:10b6:5:18b::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.41; Wed, 5 May 2021 09:50:45 +0000 Received: from BN8NAM11FT067.eop-nam11.prod.protection.outlook.com (2603:10b6:408:131:cafe::41) by BN9PR03CA0527.outlook.office365.com (2603:10b6:408:131::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Wed, 5 May 2021 09:50:45 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by BN8NAM11FT067.mail.protection.outlook.com (10.13.177.159) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4108.25 via Frontend Transport; Wed, 5 May 2021 09:50:45 +0000 Received: from nvidia.com (172.20.145.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 5 May 2021 09:50:42 +0000 From: Bing Zhao To: , , CC: , , Date: Wed, 5 May 2021 12:50:01 +0300 Message-ID: <20210505095009.40250-10-bingz@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210505095009.40250-1-bingz@nvidia.com> References: <20210427153811.11554-1-bingz@nvidia.com> <20210505095009.40250-1-bingz@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.145.6] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c8229b7c-b394-4991-4735-08d90fab40ef X-MS-TrafficTypeDiagnostic: DM6PR12MB2939: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:112; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Hl2L4lBQFSBB0wVqBStW77/0oJwYSzKUgUnpjqtrGwV89nC4Z0Uv0rdd0WuF3do8YZyYLwmhlhOfUvs01qBW3niPjby2F2sC84QK4wijEb4V9DWlJd1yimbFXVQlAZ7+vpEq7znvetBCgEw7edsJNsNfTVd6ynm0F7ggq+nPLUkQqfjtXyFb3ZLRT8+e37H0QNQ7JH+EEEBQLBo04MQIweXVz5F884RXVkJDu9HTinwWEb1G07t8RnMCM/g8zYYlBBgnkTp8uUhuKeKownsJVqtIYeUzuuThMdcwpoJ5nyIuXDKmqAayI+1SV6hcaeBAXEcBONS270wYyPC2RZ39ICg0C4skJKQvVZHpei0kLr3VZPaL4mumlEbZZSMv2pHI2/VH6lRF33LPgahPx1H5pJ1jtgy1/+CGHxsvQaJHG8BPfodvWCUSi/QgaoaXOczmLWKHj2em0UvTPZs2YAfzD2rCdjysJwY236EAx6LIKX+tTFgn7aOZ6uOsM4A+dumrApd5qtzyiWY+9vTEsrJe4Bdroq9O/1Z6XcFPvnBn0cA6X/BwTPj2l1d7vperTIFdMxTrNzWtfG8aeZ7In40F/MkIKBKfyUre3vud6geX0uflXiTAmhr1qdr8o/kWO1haTbrYdD6kQi9lLXSxvWySEDh/Jz6y8V6DdSR80exiJLQ= X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(346002)(136003)(396003)(376002)(39860400002)(46966006)(36840700001)(356005)(7636003)(55016002)(8676002)(478600001)(36756003)(86362001)(83380400001)(30864003)(70206006)(70586007)(82310400003)(4326008)(54906003)(5660300002)(110136005)(316002)(82740400003)(6286002)(186003)(47076005)(426003)(107886003)(36860700001)(1076003)(16526019)(36906005)(8936002)(26005)(6666004)(7696005)(2616005)(336012)(2906002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2021 09:50:45.1134 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c8229b7c-b394-4991-4735-08d90fab40ef X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT067.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB2939 Subject: [dpdk-dev] [PATCH v6 09/17] net/mlx5: add ASO CT query implementation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" After the connection tracking context is created and being used by the flows, the context will be updated by the HW automatically after a packet passed the CT validation. E.g., the ACK, SEQ, window and state of CT can be updated with both direction traffic. In order to query the updated contents of this context, a WQE should be posted to the SQ with a return buffer. The data will be filled into the buffer. And the profile will be filled with specific value. During the execution of query command, the context may be updated. The result of the query command may not be the latest one. Signed-off-by: Bing Zhao --- drivers/net/mlx5/mlx5.h | 10 +- drivers/net/mlx5/mlx5_flow_aso.c | 245 +++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_flow_dv.c | 19 +++ 3 files changed, 273 insertions(+), 1 deletion(-) diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 0f2a26efc0..6d3f89519d 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -493,7 +493,10 @@ struct mlx5_aso_sq_elem { uint16_t burst_size; }; struct mlx5_aso_mtr *mtr; - struct mlx5_aso_ct_action *ct; + struct { + struct mlx5_aso_ct_action *ct; + char *query_data; + }; }; }; @@ -1707,5 +1710,10 @@ int mlx5_aso_mtr_wait(struct mlx5_dev_ctx_shared *sh, int mlx5_aso_ct_update_by_wqe(struct mlx5_dev_ctx_shared *sh, struct mlx5_aso_ct_action *ct, const struct rte_flow_action_conntrack *profile); +int mlx5_aso_ct_wait_ready(struct mlx5_dev_ctx_shared *sh, + struct mlx5_aso_ct_action *ct); +int mlx5_aso_ct_query_by_wqe(struct mlx5_dev_ctx_shared *sh, + struct mlx5_aso_ct_action *ct, + struct rte_flow_action_conntrack *profile); #endif /* RTE_PMD_MLX5_H_ */ diff --git a/drivers/net/mlx5/mlx5_flow_aso.c b/drivers/net/mlx5/mlx5_flow_aso.c index 37cb43147a..92fa9ede60 100644 --- a/drivers/net/mlx5/mlx5_flow_aso.c +++ b/drivers/net/mlx5/mlx5_flow_aso.c @@ -933,6 +933,7 @@ mlx5_aso_ct_sq_enqueue_single(struct mlx5_aso_ct_pools_mng *mng, /* Fill next WQE. */ MLX5_ASO_CT_UPDATE_STATE(ct, ASO_CONNTRACK_WAIT); sq->elts[sq->head & mask].ct = ct; + sq->elts[sq->head & mask].query_data = NULL; pool = container_of(ct, struct mlx5_aso_ct_pool, actions[ct->offset]); /* Each WQE will have a single CT object. */ wqe->general_cseg.misc = rte_cpu_to_be_32(pool->devx_obj->id + @@ -1048,9 +1049,95 @@ mlx5_aso_ct_status_update(struct mlx5_aso_sq *sq, uint16_t num) ct = sq->elts[idx].ct; MLX5_ASSERT(ct); MLX5_ASO_CT_UPDATE_STATE(ct, ASO_CONNTRACK_READY); + if (sq->elts[idx].query_data) + rte_memcpy(sq->elts[idx].query_data, + (char *)((uintptr_t)sq->mr.addr + idx * 64), + 64); } } +/* + * Post a WQE to the ASO CT SQ to query the current context. + * + * @param[in] mng + * Pointer to the CT pools management structure. + * @param[in] ct + * Pointer to the generic CT structure related to the context. + * @param[in] data + * Pointer to data area to be filled. + * + * @return + * 1 on success (WQE number), 0 on failure. + */ +static int +mlx5_aso_ct_sq_query_single(struct mlx5_aso_ct_pools_mng *mng, + struct mlx5_aso_ct_action *ct, char *data) +{ + volatile struct mlx5_aso_wqe *wqe = NULL; + struct mlx5_aso_sq *sq = &mng->aso_sq; + uint16_t size = 1 << sq->log_desc_n; + uint16_t mask = size - 1; + uint16_t res; + uint16_t wqe_idx; + struct mlx5_aso_ct_pool *pool; + enum mlx5_aso_ct_state state = + __atomic_load_n(&ct->state, __ATOMIC_RELAXED); + + if (state == ASO_CONNTRACK_FREE) { + DRV_LOG(ERR, "Fail: No context to query"); + return -1; + } else if (state == ASO_CONNTRACK_WAIT) { + return 0; + } + rte_spinlock_lock(&sq->sqsl); + res = size - (uint16_t)(sq->head - sq->tail); + if (unlikely(!res)) { + rte_spinlock_unlock(&sq->sqsl); + DRV_LOG(ERR, "Fail: SQ is full and no free WQE to send"); + return 0; + } + MLX5_ASO_CT_UPDATE_STATE(ct, ASO_CONNTRACK_QUERY); + wqe = &sq->sq_obj.aso_wqes[sq->head & mask]; + /* Confirm the location and address of the prefetch instruction. */ + rte_prefetch0(&sq->sq_obj.aso_wqes[(sq->head + 1) & mask]); + /* Fill next WQE. */ + wqe_idx = sq->head & mask; + sq->elts[wqe_idx].ct = ct; + sq->elts[wqe_idx].query_data = data; + pool = container_of(ct, struct mlx5_aso_ct_pool, actions[ct->offset]); + /* Each WQE will have a single CT object. */ + wqe->general_cseg.misc = rte_cpu_to_be_32(pool->devx_obj->id + + ct->offset); + wqe->general_cseg.opcode = rte_cpu_to_be_32(MLX5_OPCODE_ACCESS_ASO | + (ASO_OPC_MOD_CONNECTION_TRACKING << + WQE_CSEG_OPC_MOD_OFFSET) | + sq->pi << WQE_CSEG_WQE_INDEX_OFFSET); + /* + * There is no write request is required. + * ASO_OPER_LOGICAL_AND and ASO_OP_ALWAYS_FALSE are both 0. + * "BYTEWISE_64BYTE" is needed for a whole context. + * Set to 0 directly to reduce an endian swap. (Modify should rewrite.) + * "data_mask" is ignored. + * Buffer address was already filled during initialization. + */ + wqe->aso_cseg.operand_masks = rte_cpu_to_be_32(BYTEWISE_64BYTE << + ASO_CSEG_DATA_MASK_MODE_OFFSET); + wqe->aso_cseg.data_mask = 0; + sq->head++; + /* + * Each WQE contains 2 WQEBB's, even though + * data segment is not used in this case. + */ + sq->pi += 2; + rte_io_wmb(); + sq->sq_obj.db_rec[MLX5_SND_DBR] = rte_cpu_to_be_32(sq->pi); + rte_wmb(); + *sq->uar_addr = *(volatile uint64_t *)wqe; /* Assume 64 bit ARCH. */ + rte_wmb(); + rte_spinlock_unlock(&sq->sqsl); + return 1; +} + /* * Handle completions from WQEs sent to ASO CT. * @@ -1143,3 +1230,161 @@ mlx5_aso_ct_update_by_wqe(struct mlx5_dev_ctx_shared *sh, ct->offset, pool->index); return -1; } + +/* + * The routine is used to wait for WQE completion to continue with queried data. + * + * @param[in] sh + * Pointer to mlx5_dev_ctx_shared object. + * @param[in] ct + * Pointer to connection tracking offload object. + * + * @return + * 0 on success, -1 on failure. + */ +int +mlx5_aso_ct_wait_ready(struct mlx5_dev_ctx_shared *sh, + struct mlx5_aso_ct_action *ct) +{ + struct mlx5_aso_ct_pools_mng *mng = sh->ct_mng; + uint32_t poll_cqe_times = MLX5_CT_POLL_WQE_CQE_TIMES; + struct mlx5_aso_ct_pool *pool; + + if (__atomic_load_n(&ct->state, __ATOMIC_RELAXED) == + ASO_CONNTRACK_READY) + return 0; + do { + mlx5_aso_ct_completion_handle(mng); + if (__atomic_load_n(&ct->state, __ATOMIC_RELAXED) == + ASO_CONNTRACK_READY) + return 0; + /* Waiting for CQE ready, consider should block or sleep. */ + rte_delay_us_sleep(MLX5_ASO_WQE_CQE_RESPONSE_DELAY); + } while (--poll_cqe_times); + pool = container_of(ct, struct mlx5_aso_ct_pool, actions[ct->offset]); + DRV_LOG(ERR, "Fail to poll CQE for ASO CT %d in pool %d", + ct->offset, pool->index); + return -1; +} + +/* + * Convert the hardware conntrack data format into the profile. + * + * @param[in] profile + * Pointer to conntrack profile to be filled after query. + * @param[in] wdata + * Pointer to data fetched from hardware. + */ +static inline void +mlx5_aso_ct_obj_analyze(struct rte_flow_action_conntrack *profile, + char *wdata) +{ + void *o_dir = MLX5_ADDR_OF(conn_track_aso, wdata, original_dir); + void *r_dir = MLX5_ADDR_OF(conn_track_aso, wdata, reply_dir); + + /* MLX5_GET16 should be taken into consideration. */ + profile->state = (enum rte_flow_conntrack_state) + MLX5_GET(conn_track_aso, wdata, state); + profile->enable = !MLX5_GET(conn_track_aso, wdata, freeze_track); + profile->selective_ack = MLX5_GET(conn_track_aso, wdata, + sack_permitted); + profile->live_connection = MLX5_GET(conn_track_aso, wdata, + connection_assured); + profile->challenge_ack_passed = MLX5_GET(conn_track_aso, wdata, + challenged_acked); + profile->max_ack_window = MLX5_GET(conn_track_aso, wdata, + max_ack_window); + profile->retransmission_limit = MLX5_GET(conn_track_aso, wdata, + retranmission_limit); + profile->last_window = MLX5_GET(conn_track_aso, wdata, last_win); + profile->last_direction = MLX5_GET(conn_track_aso, wdata, last_dir); + profile->last_index = (enum rte_flow_conntrack_tcp_last_index) + MLX5_GET(conn_track_aso, wdata, last_index); + profile->last_seq = MLX5_GET(conn_track_aso, wdata, last_seq); + profile->last_ack = MLX5_GET(conn_track_aso, wdata, last_ack); + profile->last_end = MLX5_GET(conn_track_aso, wdata, last_end); + profile->liberal_mode = MLX5_GET(conn_track_aso, wdata, + reply_direction_tcp_liberal_enabled) | + MLX5_GET(conn_track_aso, wdata, + original_direction_tcp_liberal_enabled); + /* No liberal in the RTE structure profile. */ + profile->reply_dir.scale = MLX5_GET(conn_track_aso, wdata, + reply_direction_tcp_scale); + profile->reply_dir.close_initiated = MLX5_GET(conn_track_aso, wdata, + reply_direction_tcp_close_initiated); + profile->reply_dir.data_unacked = MLX5_GET(conn_track_aso, wdata, + reply_direction_tcp_data_unacked); + profile->reply_dir.last_ack_seen = MLX5_GET(conn_track_aso, wdata, + reply_direction_tcp_max_ack); + profile->reply_dir.sent_end = MLX5_GET(tcp_window_params, + r_dir, sent_end); + profile->reply_dir.reply_end = MLX5_GET(tcp_window_params, + r_dir, reply_end); + profile->reply_dir.max_win = MLX5_GET(tcp_window_params, + r_dir, max_win); + profile->reply_dir.max_ack = MLX5_GET(tcp_window_params, + r_dir, max_ack); + profile->original_dir.scale = MLX5_GET(conn_track_aso, wdata, + original_direction_tcp_scale); + profile->original_dir.close_initiated = MLX5_GET(conn_track_aso, wdata, + original_direction_tcp_close_initiated); + profile->original_dir.data_unacked = MLX5_GET(conn_track_aso, wdata, + original_direction_tcp_data_unacked); + profile->original_dir.last_ack_seen = MLX5_GET(conn_track_aso, wdata, + original_direction_tcp_max_ack); + profile->original_dir.sent_end = MLX5_GET(tcp_window_params, + o_dir, sent_end); + profile->original_dir.reply_end = MLX5_GET(tcp_window_params, + o_dir, reply_end); + profile->original_dir.max_win = MLX5_GET(tcp_window_params, + o_dir, max_win); + profile->original_dir.max_ack = MLX5_GET(tcp_window_params, + o_dir, max_ack); +} + +/* + * Query connection tracking information parameter by send WQE. + * + * @param[in] dev + * Pointer to Ethernet device. + * @param[in] ct + * Pointer to connection tracking offload object. + * @param[out] profile + * Pointer to connection tracking TCP information. + * + * @return + * 0 on success, -1 on failure. + */ +int +mlx5_aso_ct_query_by_wqe(struct mlx5_dev_ctx_shared *sh, + struct mlx5_aso_ct_action *ct, + struct rte_flow_action_conntrack *profile) +{ + struct mlx5_aso_ct_pools_mng *mng = sh->ct_mng; + uint32_t poll_wqe_times = MLX5_CT_POLL_WQE_CQE_TIMES; + struct mlx5_aso_ct_pool *pool; + char out_data[64 * 2]; + int ret; + + MLX5_ASSERT(ct); + do { + mlx5_aso_ct_completion_handle(mng); + ret = mlx5_aso_ct_sq_query_single(mng, ct, out_data); + if (ret < 0) + return ret; + else if (ret > 0) + goto data_handle; + /* Waiting for wqe resource or state. */ + else + rte_delay_us_sleep(10u); + } while (--poll_wqe_times); + pool = container_of(ct, struct mlx5_aso_ct_pool, actions[ct->offset]); + DRV_LOG(ERR, "Fail to send WQE for ASO CT %d in pool %d", + ct->offset, pool->index); + return -1; +data_handle: + ret = mlx5_aso_ct_wait_ready(sh, ct); + if (!ret) + mlx5_aso_ct_obj_analyze(profile, out_data); + return ret; +} diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index b3606e895c..1ef98da025 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -14809,6 +14809,8 @@ flow_dv_action_query(struct rte_eth_dev *dev, uint32_t act_idx = (uint32_t)(uintptr_t)handle; uint32_t type = act_idx >> MLX5_INDIRECT_ACTION_TYPE_OFFSET; uint32_t idx = act_idx & ((1u << MLX5_INDIRECT_ACTION_TYPE_OFFSET) - 1); + struct mlx5_priv *priv = dev->data->dev_private; + struct mlx5_aso_ct_action *ct; switch (type) { case MLX5_INDIRECT_ACTION_TYPE_AGE: @@ -14824,6 +14826,23 @@ flow_dv_action_query(struct rte_eth_dev *dev, return 0; case MLX5_INDIRECT_ACTION_TYPE_COUNT: return flow_dv_query_count(dev, idx, data, error); + case MLX5_INDIRECT_ACTION_TYPE_CT: + ct = flow_aso_ct_get_by_idx(dev, idx); + if (!ct->refcnt) + return rte_flow_error_set(error, EFAULT, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, + "CT object is inactive"); + ((struct rte_flow_action_conntrack *)data)->peer_port = + ct->peer; + ((struct rte_flow_action_conntrack *)data)->is_original_dir = + ct->is_original; + if (mlx5_aso_ct_query_by_wqe(priv->sh, ct, data)) + return rte_flow_error_set(error, EIO, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, + "Failed to query CT context"); + return 0; default: return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, NULL, -- 2.27.0