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 9850A45BC0; Tue, 29 Oct 2024 17:48:34 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 31E1842FE3; Tue, 29 Oct 2024 17:44:28 +0100 (CET) Received: from egress-ip11a.ess.de.barracuda.com (egress-ip11a.ess.de.barracuda.com [18.184.203.234]) by mails.dpdk.org (Postfix) with ESMTP id C933042F0B for ; Tue, 29 Oct 2024 17:43:36 +0100 (CET) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05lp2104.outbound.protection.outlook.com [104.47.18.104]) by mx-outbound12-25.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 29 Oct 2024 16:43:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Rja0Oss8QlCkeUkrqk6miSKq2Up0+hKKsnghwN3CCM3zjK6a5Th9CdWwNEzvHS+1p9FcrHdWaJB0S6EdxOUQE5tpIXTTeWQyBLv0tfb5BTd4MWZHtPh4i452Um97o+qHAIW1XkY3GB0zbXvfyFOoFXhBTO2g1pRLtOLNp11Hsyvi4b2lwm2wSmSNIwq0EFsgc6hRXeOeOT5QIkV3wqqXA/xgU8+aTCG/L2zINwtIouvn/tUVBvFOATdx6q1fO+EjL44vbVeaX4Tc7nklseBKRLfZjmcTT5j5IPqZlSN66muS3zmqqeZbcowoo3nrbbWqVp3scWOm0NySBJgzLVHnOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5lHSS1bxv7C5lfy3vJh0MtCdcrw1CfKIBjzVFLaPBCs=; b=h/xMQoh2GEEMvkm4nUEmD9vcFFx14PfdrDPH0sL+2quzFJn18cMhh/VfruDBV5nyojsD4WAD7ollKtlftctmRLfcikujxrCiDyLbHgBcX1j2Ym72bMuYkoamYOXdT1avsOxzNR9IiOsD9VJ8vMHttsnGMTzYLTGbNVDNLbZY/iA+ji2rBjC/ubZf4YQp3ICxxtYIyAIY1rUA3xMdaWAqQT9RzLfcdX6PaBh/jLk7GiJCaexk///7u4rZ/ukJV4YK5py9lf+jix5lZRX1W+Vg5Nk4LXfyubWU6dNIa9kf+MEDxP0py8kk4lPk7t1lR10zULBWRKICGmyPCv5Q/nSnXA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=fail (sender ip is 178.72.21.4) smtp.rcpttodomain=dpdk.org smtp.mailfrom=napatech.com; dmarc=fail (p=reject sp=reject pct=100) action=oreject header.from=napatech.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=napatech.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5lHSS1bxv7C5lfy3vJh0MtCdcrw1CfKIBjzVFLaPBCs=; b=GHgV87jnIn/lKGgpAHDLqgJsF8xGlTp/aDK2tw8yIwtik5DNY+ttSKh+wSvQks2RrsdBhHOtIgvQ/8/f01VV0I2zJ0rJL/6fp8h3nHDoo7WYfPtM/6Yo5Sxr5eOTKvU/8FHKUdb7AX2pt2KSbI/Kb+0i3hjB6pijYHNNVpiqrXU= Received: from DUZPR01CA0189.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::7) by AS8P190MB1936.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:521::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Tue, 29 Oct 2024 16:43:29 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::6b) by DUZPR01CA0189.outlook.office365.com (2603:10a6:10:4b6::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.29 via Frontend Transport; Tue, 29 Oct 2024 16:43:29 +0000 X-MS-Exchange-Authentication-Results: spf=fail (sender IP is 178.72.21.4) smtp.mailfrom=napatech.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=napatech.com; Received-SPF: Fail (protection.outlook.com: domain of napatech.com does not designate 178.72.21.4 as permitted sender) receiver=protection.outlook.com; client-ip=178.72.21.4; helo=localhost.localdomain; Received: from localhost.localdomain (178.72.21.4) by DU2PEPF00028D06.mail.protection.outlook.com (10.167.242.166) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Tue, 29 Oct 2024 16:43:28 +0000 From: Serhii Iliushyk To: dev@dpdk.org Cc: mko-plv@napatech.com, sil-plv@napatech.com, ckm@napatech.com, andrew.rybchenko@oktetlabs.ru, ferruh.yigit@amd.com, stephen@networkplumber.org, Oleksandr Kolomeiets Subject: [PATCH v4 37/86] net/ntnic: add flow dump feature Date: Tue, 29 Oct 2024 17:41:41 +0100 Message-ID: <20241029164243.1648775-38-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241029164243.1648775-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241029164243.1648775-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|AS8P190MB1936:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: aee81c6a-7cc9-493f-13c5-08dcf838d143 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?PdX1YRqfURCvhy/IRjcwiSd1izGWSI4vT62mpTkTc8w72Q0/Mc56NS45HUWn?= =?us-ascii?Q?dkpxVtni2GO6LZ3SOGFZ+3npv+83CvYNACW5HLm0VgcYb1eoalM9t74mR5lB?= =?us-ascii?Q?ZG99yetAM3CoYVh5Ht9S0O/tMuBTH1Tt3lJ1BdrTZkqaiP3prp6lWlaVhAWs?= =?us-ascii?Q?zngbg4WYtrdVOFUC3tjXAZLNvtXNV8dF5zbLboe6GKTcA1i/u9kxDO/dn8Bo?= =?us-ascii?Q?3S6Ao1cxCg1z59XFPX7e+QYmcZ3268TNzsPmM/gU28FkBG0I9IE0ST3lMcR2?= =?us-ascii?Q?czey4oMFUnKjH0/MxCKvTK15sieMXu+hGT6oOuQjFTD461qH7eOS5FvHNSwv?= =?us-ascii?Q?phKVMfic+0SWsJhUnBSgGRgzDCLJ7j9f2F03proXz9iC58iJlh4UkKwXSP9g?= =?us-ascii?Q?5hXjIIGgY7q84LVz0Vv4KnV1Ld991JP05g3RKgppYENOyarEaT2etNehW3/Y?= =?us-ascii?Q?Yy1cctxBky5ZGj8S0/PeRHrkdcHrau252tEOVgX9yp/2ajIK/z0cm6UdGQTs?= =?us-ascii?Q?4zFLdKRMHefTHU+XK8uxAKA5YaTZv33wcT3q4Vcy8HucL2AGuZaovOfAyypw?= =?us-ascii?Q?v5e+UywvrfhLF6Au+0WRApMy7fhRBrDWakP1ebBBHchazOFLUYnsDdY+NZw0?= =?us-ascii?Q?25j4b9rOGJ/yY6O6NJhKACy3HHzY/Lw5neyajvBseZtzA7XGojYxI7QrPrsC?= =?us-ascii?Q?VDt0D5fvJveXzbz8tVqQ/PWiKGw1XDLQkvhM/X6ZVXE19rE/WDdezDdYrS0l?= =?us-ascii?Q?hKHO3wdO+ZTSJRryt4+ZgTnuCoaGn1Jji2opFE9JGXcX3KU3Tpp727dX9D3R?= =?us-ascii?Q?fL+qRzcgRJ1c4euLKYaZmMwbY9Lysd1Jn9gLps9dvwMZVwZlKAuxjMiICIBP?= =?us-ascii?Q?82dDblkpjSra0QhCyFVZ/c1+yx668/mf/SDkd8Zrw89zUOqieac6t8yUTEgB?= =?us-ascii?Q?qEAQ92G5rNOjCHm9yt5hDdbintfGJIDH5W04jP4lA7gv1/qZjn+X2XtZ2xEE?= =?us-ascii?Q?l3GT7kzjhH3Qk8MdkEakftyfOey/mHiOnAW3nBEQdr6tan7+EI34yV5/x8Hk?= =?us-ascii?Q?OJTrxoJ0IxY4xlsx2sJL3Y21vWfOr2GPgkh5AXIuiia0y7aYmBUrJW+jPiBG?= =?us-ascii?Q?/EAcYpqYFgyrHpSQ7nkkvUM83B3Li1ZfqCppUUOoyyArvSftsME3B+oPs5aJ?= =?us-ascii?Q?ZHvoOxo87fyL3DvoZHpi0D2DR9pPX3MWjRxA1uQY2u/8zGGes+sFksPtvEj8?= =?us-ascii?Q?+zE/BrIiRj3psC8iUG5TWLp3b28zy6ZOQNK/YJ/4P9d3GTzpMkSiGAzGo4q3?= =?us-ascii?Q?w/cu+Cp+miEEoROc6pAgq8Rxaa2tFRDdzAk2Q7g7uGCeRoSM622rImR4IdfT?= =?us-ascii?Q?FwfT7XkMEMSHC25/WnBy+jcBzgq1e7nIoJ5YiiCRXkS5Vb8atQ=3D=3D?= X-Forefront-Antispam-Report: CIP:178.72.21.4; CTRY:DK; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:localhost.localdomain; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(1800799024)(376014)(36860700013)(82310400026); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 6K/3KoUePn+i0HU2WUhh2fEni9qM2mR1lwBHVDwLZn8xlDnYyIEbNiHGgMPDi4nx9TrBvDnKh/JOP/ygMzl7Ca0eIqrQokvLqZg+7ym4r86mEbbDWo1jR2qmmzO1OiEjN5C+b2JxRRjlcjeK3KBQZ8BrTUA78eyN8V45TRfLss71B3qaphBJGejgsGKcyKygUNMz2z8+2WM6+hmghq/oHyapanuo157n++tBNldid+cB3k092SgGYseEcQJEeGiVabmtFPWf6GITAav47gPNNFDcQ++grBHsEC+TCELc3oEJOZuu/H7KXEypEJt3nRcIGtwUm1NbSGpBhAY7jnrCWWG9n5P4HbT0McGjcXe6JYY2ASjUcibm+ttsu3fpmop3zeI1UgmEdCxTAvejESSEJzE61FtT+dFDwJoz7XBPhwh9XM1PioXBdjUE4YqsMAPiOrjz0TcIsJzbQzLXN+r+txhEy2OiVWmWO/nnUsvHoWS62MwFuHm4pJghxALVwvTYNhDbNcqgHjJEoidqAY3TexqrnJtXCEcQgU81jSXvtwSwzQwpO+Hs+4NywwEKll+qFPVnE9Y57FZuHro23nN2fCqKqdH/aDkbmV7qemc7yti5f3uMgFdI1LT7VS5VIUbUOLv5sxiWRAtsakEZcc7OXNiZMAPrbtYOr/jxjuYC1Ns= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:43:28.9490 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aee81c6a-7cc9-493f-13c5-08dcf838d143 X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D06.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P190MB1936 X-BESS-ID: 1730220211-303097-12767-29328-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.18.104 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoYW5kamQGYGUDQxLSkxxdLSKM XS1Cw51dLcLMncKNE4zTwp2SDFyMLQQqk2FgCUPqSxQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan14-117.eu-central-1a.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.00 using account:ESS113687 scores of KILL_LEVEL=7.0 tests=BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 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 From: Oleksandr Kolomeiets Add posibilyty to dump flow in human readable format Signed-off-by: Oleksandr Kolomeiets --- drivers/net/ntnic/include/flow_api_engine.h | 2 + drivers/net/ntnic/nthw/flow_api/flow_api.c | 17 ++ .../profile_inline/flow_api_hw_db_inline.c | 264 ++++++++++++++++++ .../profile_inline/flow_api_hw_db_inline.h | 3 + .../profile_inline/flow_api_profile_inline.c | 81 ++++++ .../profile_inline/flow_api_profile_inline.h | 6 + drivers/net/ntnic/ntnic_filter/ntnic_filter.c | 29 ++ drivers/net/ntnic/ntnic_mod_reg.h | 11 + 8 files changed, 413 insertions(+) diff --git a/drivers/net/ntnic/include/flow_api_engine.h b/drivers/net/ntnic/include/flow_api_engine.h index e52363f04e..155a9e1fd6 100644 --- a/drivers/net/ntnic/include/flow_api_engine.h +++ b/drivers/net/ntnic/include/flow_api_engine.h @@ -281,6 +281,8 @@ struct flow_handle { struct flow_handle *next; struct flow_handle *prev; + /* Flow specific pointer to application data stored during action creation. */ + void *context; void *user_data; union { diff --git a/drivers/net/ntnic/nthw/flow_api/flow_api.c b/drivers/net/ntnic/nthw/flow_api/flow_api.c index 043e4244fc..7f1e311988 100644 --- a/drivers/net/ntnic/nthw/flow_api/flow_api.c +++ b/drivers/net/ntnic/nthw/flow_api/flow_api.c @@ -1006,6 +1006,22 @@ int flow_nic_set_hasher(struct flow_nic_dev *ndev, int hsh_idx, enum flow_nic_ha return 0; } +static int flow_dev_dump(struct flow_eth_dev *dev, + struct flow_handle *flow, + uint16_t caller_id, + FILE *file, + struct rte_flow_error *error) +{ + const struct profile_inline_ops *profile_inline_ops = get_profile_inline_ops(); + + if (profile_inline_ops == NULL) { + NT_LOG(ERR, FILTER, "%s: profile_inline module uninitialized", __func__); + return -1; + } + + return profile_inline_ops->flow_dev_dump_profile_inline(dev, flow, caller_id, file, error); +} + int flow_nic_set_hasher_fields(struct flow_nic_dev *ndev, int hsh_idx, struct nt_eth_rss_conf rss_conf) { @@ -1031,6 +1047,7 @@ static const struct flow_filter_ops ops = { */ .flow_create = flow_create, .flow_destroy = flow_destroy, + .flow_dev_dump = flow_dev_dump, }; void init_flow_filter(void) diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c index 52f85b65af..b5fee67e67 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c @@ -372,6 +372,270 @@ void hw_db_inline_deref_idxs(struct flow_nic_dev *ndev, void *db_handle, struct } } +void hw_db_inline_dump(struct flow_nic_dev *ndev, void *db_handle, const struct hw_db_idx *idxs, + uint32_t size, FILE *file) +{ + (void)ndev; + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + char str_buffer[4096]; + uint16_t rss_buffer_len = sizeof(str_buffer); + + for (uint32_t i = 0; i < size; ++i) { + switch (idxs[i].type) { + case HW_DB_IDX_TYPE_NONE: + break; + + case HW_DB_IDX_TYPE_MATCH_SET: { + const struct hw_db_inline_match_set_data *data = + &db->match_set[idxs[i].ids].data; + fprintf(file, " MATCH_SET %d, priority %d\n", idxs[i].ids, + (int)data->priority); + fprintf(file, " CAT id %d, KM id %d, KM_FT id %d, ACTION_SET id %d\n", + data->cat.ids, data->km.id1, data->km_ft.id1, + data->action_set.ids); + + if (data->jump) + fprintf(file, " Jumps to %d\n", data->jump); + + break; + } + + case HW_DB_IDX_TYPE_ACTION_SET: { + const struct hw_db_inline_action_set_data *data = + &db->action_set[idxs[i].ids].data; + fprintf(file, " ACTION_SET %d\n", idxs[i].ids); + + if (data->contains_jump) + fprintf(file, " Jumps to %d\n", data->jump); + + else + fprintf(file, + " COT id %d, QSL id %d, SLC_LR id %d, TPE id %d, HSH id %d\n", + data->cot.ids, data->qsl.ids, data->slc_lr.ids, + data->tpe.ids, data->hsh.ids); + + break; + } + + case HW_DB_IDX_TYPE_CAT: { + const struct hw_db_inline_cat_data *data = &db->cat[idxs[i].ids].data; + fprintf(file, " CAT %d\n", idxs[i].ids); + fprintf(file, " Port msk 0x%02x, VLAN msk 0x%02x\n", + (int)data->mac_port_mask, (int)data->vlan_mask); + fprintf(file, + " Proto msks: Frag 0x%02x, l2 0x%02x, l3 0x%02x, l4 0x%02x, l3t 0x%02x, l4t 0x%02x\n", + (int)data->ptc_mask_frag, (int)data->ptc_mask_l2, + (int)data->ptc_mask_l3, (int)data->ptc_mask_l4, + (int)data->ptc_mask_l3_tunnel, (int)data->ptc_mask_l4_tunnel); + fprintf(file, " IP protocol: pn %u pnt %u\n", data->ip_prot, + data->ip_prot_tunnel); + break; + } + + case HW_DB_IDX_TYPE_QSL: { + const struct hw_db_inline_qsl_data *data = &db->qsl[idxs[i].ids].data; + fprintf(file, " QSL %d\n", idxs[i].ids); + + if (data->discard) { + fprintf(file, " Discard\n"); + break; + } + + if (data->drop) { + fprintf(file, " Drop\n"); + break; + } + + fprintf(file, " Table size %d\n", data->table_size); + + for (uint32_t i = 0; + i < data->table_size && i < HW_DB_INLINE_MAX_QST_PER_QSL; ++i) { + fprintf(file, " %u: Queue %d, TX port %d\n", i, + (data->table[i].queue_en ? (int)data->table[i].queue : -1), + (data->table[i].tx_port_en ? (int)data->table[i].tx_port + : -1)); + } + + break; + } + + case HW_DB_IDX_TYPE_COT: { + const struct hw_db_inline_cot_data *data = &db->cot[idxs[i].ids].data; + fprintf(file, " COT %d\n", idxs[i].ids); + fprintf(file, " Color contrib %d, frag rcp %d\n", + (int)data->matcher_color_contrib, (int)data->frag_rcp); + break; + } + + case HW_DB_IDX_TYPE_SLC_LR: { + const struct hw_db_inline_slc_lr_data *data = + &db->slc_lr[idxs[i].ids].data; + fprintf(file, " SLC_LR %d\n", idxs[i].ids); + fprintf(file, " Enable %u, dyn %u, ofs %u\n", data->head_slice_en, + data->head_slice_dyn, data->head_slice_ofs); + break; + } + + case HW_DB_IDX_TYPE_TPE: { + const struct hw_db_inline_tpe_data *data = &db->tpe[idxs[i].ids].data; + fprintf(file, " TPE %d\n", idxs[i].ids); + fprintf(file, " Insert len %u, new outer %u, calc eth %u\n", + data->insert_len, data->new_outer, + data->calc_eth_type_from_inner_ip); + fprintf(file, " TTL enable %u, dyn %u, ofs %u\n", data->ttl_en, + data->ttl_dyn, data->ttl_ofs); + fprintf(file, + " Len A enable %u, pos dyn %u, pos ofs %u, add dyn %u, add ofs %u, sub dyn %u\n", + data->len_a_en, data->len_a_pos_dyn, data->len_a_pos_ofs, + data->len_a_add_dyn, data->len_a_add_ofs, data->len_a_sub_dyn); + fprintf(file, + " Len B enable %u, pos dyn %u, pos ofs %u, add dyn %u, add ofs %u, sub dyn %u\n", + data->len_b_en, data->len_b_pos_dyn, data->len_b_pos_ofs, + data->len_b_add_dyn, data->len_b_add_ofs, data->len_b_sub_dyn); + fprintf(file, + " Len C enable %u, pos dyn %u, pos ofs %u, add dyn %u, add ofs %u, sub dyn %u\n", + data->len_c_en, data->len_c_pos_dyn, data->len_c_pos_ofs, + data->len_c_add_dyn, data->len_c_add_ofs, data->len_c_sub_dyn); + + for (uint32_t i = 0; i < 6; ++i) + if (data->writer[i].en) + fprintf(file, + " Writer %i: Reader %u, dyn %u, ofs %u, len %u\n", + i, data->writer[i].reader_select, + data->writer[i].dyn, data->writer[i].ofs, + data->writer[i].len); + + break; + } + + case HW_DB_IDX_TYPE_TPE_EXT: { + const struct hw_db_inline_tpe_ext_data *data = + &db->tpe_ext[idxs[i].ids].data; + const int rpl_rpl_length = ((int)data->size + 15) / 16; + fprintf(file, " TPE_EXT %d\n", idxs[i].ids); + fprintf(file, " Encap data, size %u\n", data->size); + + for (int i = 0; i < rpl_rpl_length; ++i) { + fprintf(file, " "); + + for (int n = 15; n >= 0; --n) + fprintf(file, " %02x%s", data->hdr8[i * 16 + n], + n == 8 ? " " : ""); + + fprintf(file, "\n"); + } + + break; + } + + case HW_DB_IDX_TYPE_FLM_RCP: { + const struct hw_db_inline_flm_rcp_data *data = &db->flm[idxs[i].id1].data; + fprintf(file, " FLM_RCP %d\n", idxs[i].id1); + fprintf(file, " QW0 dyn %u, ofs %u, QW4 dyn %u, ofs %u\n", + data->qw0_dyn, data->qw0_ofs, data->qw4_dyn, data->qw4_ofs); + fprintf(file, " SW8 dyn %u, ofs %u, SW9 dyn %u, ofs %u\n", + data->sw8_dyn, data->sw8_ofs, data->sw9_dyn, data->sw9_ofs); + fprintf(file, " Outer prot %u, inner prot %u\n", data->outer_prot, + data->inner_prot); + fprintf(file, " Mask:\n"); + fprintf(file, " %08x %08x %08x %08x %08x\n", data->mask[0], + data->mask[1], data->mask[2], data->mask[3], data->mask[4]); + fprintf(file, " %08x %08x %08x %08x %08x\n", data->mask[5], + data->mask[6], data->mask[7], data->mask[8], data->mask[9]); + break; + } + + case HW_DB_IDX_TYPE_FLM_FT: { + const struct hw_db_inline_flm_ft_data *data = + &db->flm[idxs[i].id2].ft[idxs[i].id1].data; + fprintf(file, " FLM_FT %d\n", idxs[i].id1); + + if (data->is_group_zero) + fprintf(file, " Jump to %d\n", data->jump); + + else + fprintf(file, " Group %d\n", data->group); + + fprintf(file, " ACTION_SET id %d\n", data->action_set.ids); + break; + } + + case HW_DB_IDX_TYPE_KM_RCP: { + const struct hw_db_inline_km_rcp_data *data = &db->km[idxs[i].id1].data; + fprintf(file, " KM_RCP %d\n", idxs[i].id1); + fprintf(file, " HW id %u\n", data->rcp); + break; + } + + case HW_DB_IDX_TYPE_KM_FT: { + const struct hw_db_inline_km_ft_data *data = + &db->km[idxs[i].id2].ft[idxs[i].id1].data; + fprintf(file, " KM_FT %d\n", idxs[i].id1); + fprintf(file, " ACTION_SET id %d\n", data->action_set.ids); + fprintf(file, " KM_RCP id %d\n", data->km.ids); + fprintf(file, " CAT id %d\n", data->cat.ids); + break; + } + + case HW_DB_IDX_TYPE_HSH: { + const struct hw_db_inline_hsh_data *data = &db->hsh[idxs[i].ids].data; + fprintf(file, " HSH %d\n", idxs[i].ids); + + switch (data->func) { + case RTE_ETH_HASH_FUNCTION_DEFAULT: + fprintf(file, " Func: NTH10\n"); + break; + + case RTE_ETH_HASH_FUNCTION_TOEPLITZ: + fprintf(file, " Func: Toeplitz\n"); + fprintf(file, " Key:"); + + for (uint8_t i = 0; i < MAX_RSS_KEY_LEN; i++) { + if (i % 10 == 0) + fprintf(file, "\n "); + + fprintf(file, " %02x", data->key[i]); + } + + fprintf(file, "\n"); + break; + + default: + fprintf(file, " Func: %u\n", data->func); + } + + fprintf(file, " Hash mask hex:\n"); + fprintf(file, " %016lx\n", data->hash_mask); + + /* convert hash mask to human readable RTE_ETH_RSS_* form if possible */ + if (sprint_nt_rss_mask(str_buffer, rss_buffer_len, "\n ", + data->hash_mask) == 0) { + fprintf(file, " Hash mask flags:%s\n", str_buffer); + } + + break; + } + + default: { + fprintf(file, " Unknown item. Type %u\n", idxs[i].type); + break; + } + } + } +} + +void hw_db_inline_dump_cfn(struct flow_nic_dev *ndev, void *db_handle, FILE *file) +{ + (void)ndev; + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + + fprintf(file, "CFN status:\n"); + + for (uint32_t id = 0; id < db->nb_cat; ++id) + if (db->cfn[id].cfn_hw) + fprintf(file, " ID %d, HW id %d, priority 0x%" PRIx64 "\n", (int)id, + db->cfn[id].cfn_hw, db->cfn[id].priority); +} const void *hw_db_inline_find_data(struct flow_nic_dev *ndev, void *db_handle, enum hw_db_idx_type type, struct hw_db_idx *idxs, uint32_t size) diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h index 33de674b72..a9d31c86ea 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h @@ -276,6 +276,9 @@ void hw_db_inline_deref_idxs(struct flow_nic_dev *ndev, void *db_handle, struct uint32_t size); const void *hw_db_inline_find_data(struct flow_nic_dev *ndev, void *db_handle, enum hw_db_idx_type type, struct hw_db_idx *idxs, uint32_t size); +void hw_db_inline_dump(struct flow_nic_dev *ndev, void *db_handle, const struct hw_db_idx *idxs, + uint32_t size, FILE *file); +void hw_db_inline_dump_cfn(struct flow_nic_dev *ndev, void *db_handle, FILE *file); /**/ diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c index 2afc7447d4..9727a28d45 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c @@ -4300,6 +4300,86 @@ int flow_nic_set_hasher_fields_inline(struct flow_nic_dev *ndev, int hsh_idx, return res; } +static void dump_flm_data(const uint32_t *data, FILE *file) +{ + for (unsigned int i = 0; i < 10; ++i) { + fprintf(file, "%s%02X %02X %02X %02X%s", i % 2 ? "" : " ", + (data[i] >> 24) & 0xff, (data[i] >> 16) & 0xff, (data[i] >> 8) & 0xff, + data[i] & 0xff, i % 2 ? "\n" : " "); + } +} + +int flow_dev_dump_profile_inline(struct flow_eth_dev *dev, + struct flow_handle *flow, + uint16_t caller_id, + FILE *file, + struct rte_flow_error *error) +{ + flow_nic_set_error(ERR_SUCCESS, error); + + pthread_mutex_lock(&dev->ndev->mtx); + + if (flow != NULL) { + if (flow->type == FLOW_HANDLE_TYPE_FLM) { + fprintf(file, "Port %d, caller %d, flow type FLM\n", (int)dev->port_id, + (int)flow->caller_id); + fprintf(file, " FLM_DATA:\n"); + dump_flm_data(flow->flm_data, file); + hw_db_inline_dump(dev->ndev, dev->ndev->hw_db_handle, + (struct hw_db_idx *)flow->flm_db_idxs, + flow->flm_db_idx_counter, file); + fprintf(file, " Context: %p\n", flow->context); + + } else { + fprintf(file, "Port %d, caller %d, flow type FLOW\n", (int)dev->port_id, + (int)flow->caller_id); + hw_db_inline_dump(dev->ndev, dev->ndev->hw_db_handle, + (struct hw_db_idx *)flow->db_idxs, flow->db_idx_counter, + file); + } + + } else { + int max_flm_count = 1000; + + hw_db_inline_dump_cfn(dev->ndev, dev->ndev->hw_db_handle, file); + + flow = dev->ndev->flow_base; + + while (flow) { + if (flow->caller_id == caller_id) { + fprintf(file, "Port %d, caller %d, flow type FLOW\n", + (int)dev->port_id, (int)flow->caller_id); + hw_db_inline_dump(dev->ndev, dev->ndev->hw_db_handle, + (struct hw_db_idx *)flow->db_idxs, + flow->db_idx_counter, file); + } + + flow = flow->next; + } + + flow = dev->ndev->flow_base_flm; + + while (flow && max_flm_count >= 0) { + if (flow->caller_id == caller_id) { + fprintf(file, "Port %d, caller %d, flow type FLM\n", + (int)dev->port_id, (int)flow->caller_id); + fprintf(file, " FLM_DATA:\n"); + dump_flm_data(flow->flm_data, file); + hw_db_inline_dump(dev->ndev, dev->ndev->hw_db_handle, + (struct hw_db_idx *)flow->flm_db_idxs, + flow->flm_db_idx_counter, file); + fprintf(file, " Context: %p\n", flow->context); + max_flm_count -= 1; + } + + flow = flow->next; + } + } + + pthread_mutex_unlock(&dev->ndev->mtx); + + return 0; +} static const struct profile_inline_ops ops = { /* @@ -4308,6 +4388,7 @@ static const struct profile_inline_ops ops = { .done_flow_management_of_ndev_profile_inline = done_flow_management_of_ndev_profile_inline, .initialize_flow_management_of_ndev_profile_inline = initialize_flow_management_of_ndev_profile_inline, + .flow_dev_dump_profile_inline = flow_dev_dump_profile_inline, /* * Flow functionality */ diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.h b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.h index e623bb2352..2c76a2c023 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.h +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.h @@ -38,6 +38,12 @@ int flow_destroy_profile_inline(struct flow_eth_dev *dev, struct flow_handle *flow, struct rte_flow_error *error); +int flow_dev_dump_profile_inline(struct flow_eth_dev *dev, + struct flow_handle *flow, + uint16_t caller_id, + FILE *file, + struct rte_flow_error *error); + int flow_nic_set_hasher_fields_inline(struct flow_nic_dev *ndev, int hsh_idx, struct nt_eth_rss_conf rss_conf); diff --git a/drivers/net/ntnic/ntnic_filter/ntnic_filter.c b/drivers/net/ntnic/ntnic_filter/ntnic_filter.c index 20b5cb2835..67a24a00f1 100644 --- a/drivers/net/ntnic/ntnic_filter/ntnic_filter.c +++ b/drivers/net/ntnic/ntnic_filter/ntnic_filter.c @@ -582,9 +582,38 @@ static struct rte_flow *eth_flow_create(struct rte_eth_dev *eth_dev, return flow; } +static int eth_flow_dev_dump(struct rte_eth_dev *eth_dev, + struct rte_flow *flow, + FILE *file, + struct rte_flow_error *error) +{ + const struct flow_filter_ops *flow_filter_ops = get_flow_filter_ops(); + + if (flow_filter_ops == NULL) { + NT_LOG(ERR, NTNIC, "%s: flow_filter module uninitialized", __func__); + return -1; + } + + struct pmd_internals *internals = (struct pmd_internals *)eth_dev->data->dev_private; + + static struct rte_flow_error flow_error = { + .type = RTE_FLOW_ERROR_TYPE_NONE, .message = "none" }; + + uint16_t caller_id = get_caller_id(eth_dev->data->port_id); + + int res = flow_filter_ops->flow_dev_dump(internals->flw_dev, + is_flow_handle_typecast(flow) ? (void *)flow + : flow->flw_hdl, + caller_id, file, &flow_error); + + convert_error(error, &flow_error); + return res; +} + static const struct rte_flow_ops dev_flow_ops = { .create = eth_flow_create, .destroy = eth_flow_destroy, + .dev_dump = eth_flow_dev_dump, }; void dev_flow_init(void) diff --git a/drivers/net/ntnic/ntnic_mod_reg.h b/drivers/net/ntnic/ntnic_mod_reg.h index 27d6cbef01..cef655c5e0 100644 --- a/drivers/net/ntnic/ntnic_mod_reg.h +++ b/drivers/net/ntnic/ntnic_mod_reg.h @@ -253,6 +253,12 @@ struct profile_inline_ops { struct flow_handle *flow, struct rte_flow_error *error); + int (*flow_dev_dump_profile_inline)(struct flow_eth_dev *dev, + struct flow_handle *flow, + uint16_t caller_id, + FILE *file, + struct rte_flow_error *error); + int (*flow_nic_set_hasher_fields_inline)(struct flow_nic_dev *ndev, int hsh_idx, struct nt_eth_rss_conf rss_conf); @@ -284,6 +290,11 @@ struct flow_filter_ops { int *rss_target_id, enum flow_eth_dev_profile flow_profile, uint32_t exception_path); + int (*flow_dev_dump)(struct flow_eth_dev *dev, + struct flow_handle *flow, + uint16_t caller_id, + FILE *file, + struct rte_flow_error *error); /* * NT Flow API */ -- 2.45.0