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 6CA5E45BA3; Tue, 22 Oct 2024 19:00:54 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 777C741132; Tue, 22 Oct 2024 18:57:03 +0200 (CEST) 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 7D9A140DDC for ; Tue, 22 Oct 2024 18:56:46 +0200 (CEST) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05lp2109.outbound.protection.outlook.com [104.47.18.109]) by mx-outbound15-54.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 22 Oct 2024 16:56:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kijhruIVJEVtwrAxCU8b8Bhvq/+T1aMRCWFlUz9S4+5MK4P1KLcEN3TKlQZ/WGYmrKqp0JPQZ7ch6eDVrAQjz1Waxejv5xepYtzy3FDh3tsc2o0K24b2QnyEItg0vqzJRbl9MppQxn/tkY+N3NQSq9/GCopqSVfzmFYDopoll6NVyzzGNyq8UJcEssYKQiExBISJqTnp8anZvgUpXkYQ2IgoLRdE6NA4XOB3PpFgxP8KDqkyqPiPT9kDLDCGBz2ySnLkYqE8adPZ5z8NraavORu+YrodpHK1E5hLM7b44zZdS4L1SaCDO/tfHMDwtd123wRHzI1mIEkavgU4l0Y8sQ== 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=uIJ9L00TW733aqj9asLqVUokyYZv39i8hhHHty9L/5c=; b=Cgey1wa21j5yQYwQQO8xx3RDdic6bCwDakLnYOcIjSonygpQ4BxvVRA3H2DehjcVNI+tWWsHw+iNAFU2muxBmyOLQJuYOdv8Y1dgoLIhFr4Ex6sAomgU1XYoc76bU/lJTH7W+N4N57+ZjZ8mcJIx+4ENR+3hB8lkMc1cMX/kL6b6+N2PizSO4EgpimHQzRT7vSQiFbIF8ljki2ux7MlMms2ERVYodqolblzHR1jlexhHnslyx+iugKIpNGLf79l7ZMSF5NPPGIKo2KRu3yQGTYLF+QjPD8VuKN5VhtkHWwyQ1g15aaNCBJJBev1M7kZ6ItJuErE148xkr8XFNdA7QA== 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=uIJ9L00TW733aqj9asLqVUokyYZv39i8hhHHty9L/5c=; b=d8Gon/qLB4ii+WnwCYmfxVMiBxqHqjKTgsiUnnU69S6w6QsJCY9542lkWpVwUo/DsuxK1J3v9JDTHDexb1weC7kNmIycl2MqBnzRjjA0mzwLWbbxjtoPNX60sA9Z6UaSwowPh8q//V5Surktc/OzGbXfpR2J/L0gArabUZM9zdc= Received: from DB9PR06CA0023.eurprd06.prod.outlook.com (2603:10a6:10:1db::28) by PR3P190MB0890.EURP190.PROD.OUTLOOK.COM (2603:10a6:102:93::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.26; Tue, 22 Oct 2024 16:56:39 +0000 Received: from DU2PEPF0001E9C2.eurprd03.prod.outlook.com (2603:10a6:10:1db:cafe::56) by DB9PR06CA0023.outlook.office365.com (2603:10a6:10:1db::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.16 via Frontend Transport; Tue, 22 Oct 2024 16:56:39 +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 DU2PEPF0001E9C2.mail.protection.outlook.com (10.167.8.71) with Microsoft SMTP Server id 15.20.8093.14 via Frontend Transport; Tue, 22 Oct 2024 16:56:38 +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 v2 37/73] net/ntnic: add flow dump feature Date: Tue, 22 Oct 2024 18:54:54 +0200 Message-ID: <20241022165541.3186140-38-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241022165541.3186140-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241022165541.3186140-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF0001E9C2:EE_|PR3P190MB0890:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 805aec5a-a6a7-48cf-4dfa-08dcf2ba7f38 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?5Ul5zYfLyH35eH8Lww6yzlxgl/2XQLEL2u0EF7BlsotPBC5nxo+RE8/rrRez?= =?us-ascii?Q?0aUNppDO0+CH8Oqn6dHSU6VR7TIKbgACll4irfb8l1Bvkvlkb2SlEI6aM4oX?= =?us-ascii?Q?Q7ET4RrDa9OuEAujpa+XXOYG7TICLjL4x+L2Uh7R4LyCGNvGW7GriutepJ2U?= =?us-ascii?Q?nUIywpzSQV0kUTqjDCyxUVIqhytBkPv1orH7kBuehj6Vk6354ljJ3+EiP9lm?= =?us-ascii?Q?X3OXpvAuzLK5yGp+e7r3nMLY7BypQITH+DZWftEijOcp0QNV+0XL4bAt7Kjr?= =?us-ascii?Q?CdwHSmS+Uzv8IjYvZNCe4g1bIsAo9G1nFowOunUucXxRCtIWJLOITQNmHZwT?= =?us-ascii?Q?GAq/C1xpwKk12pk3Sx5BN+2PuK5GOmnH274wluwJW+SWsIeDkW17iOETzb2L?= =?us-ascii?Q?fA+1c3m4xpzeDu6wLsGI3GatbLG0XZ3KWCcwPaPYQFzrBbQIy6hg1MyTKd+5?= =?us-ascii?Q?5FjKAooadn4Ntw666NQTMFJk+dYa+whQ0RfJVh9QZITSbyel+3W6FY4xb6WJ?= =?us-ascii?Q?Ue4ncrKB3EbTUHlrsOpmT/BI2LXJtWV8NLqRRd1h99WD58LOZb5RPOrMOkoA?= =?us-ascii?Q?0dqfYPtI1lnl3kdiPYCpS8eRhg0O7USVfRdgf3uNqxcWL5KPAPr14XMeWSa/?= =?us-ascii?Q?/FoZi0wqXdOnMumctjwJR9q8w27/X+WpJlmPEFaS/Te4jAui+ki4RWPAzyzn?= =?us-ascii?Q?w9dfi7eDM9IVqAo82ziTOCv2o3aANcLECnYhtjnVConBjW1wYWXVwpjBAkbe?= =?us-ascii?Q?mS+PnTW54PUcA6sh3t5xmC7544sewylmtYQgTIjaf63kFbjaxvKuB/2V0azn?= =?us-ascii?Q?qtmH7BLGqd908r0mfGPbw5fX96BmdhhWPxvMtEAsVsOmgENygrFcceed+j+D?= =?us-ascii?Q?DOaEbats/3XNFY5pyv/KS1y3orv68rTgIjAqXDvOpV9jtuFkxZSMUKKceCUA?= =?us-ascii?Q?BQfAyZFysGQ4d9STrLuosp2o7Uz9N/4Xo7pu9pN+MB5XqI6ZAcr+vGsMJ1nM?= =?us-ascii?Q?Oz3PQyK4Pjs40M/7DioL4azMrSGlo8XBxqfYu/cwk485ragpUOdo1lnyTP4W?= =?us-ascii?Q?DDDkuCbkNsN7hj/ViqniGnRBMqGRR5EmHwRceaqfJR9YbqpvQKHS/H84ajPn?= =?us-ascii?Q?firdExUsds52b/tBhrCNrMCvzc6RYB7pzYRMwQFznqbzOw/iu6bobP9IXJ2m?= =?us-ascii?Q?166o+7/gg6PXBkIJHGEZVsuk/67ejVueb/Aq2mjZZjA0y6WT1p7VBP1ZqhAb?= =?us-ascii?Q?ZMg5Fr157trrgFWTg55x3/1LsivBlu5FRxxghRB17UUiAGKm+RtKJM68Q1Id?= =?us-ascii?Q?HFSllZfNZkfu5N819v132UNIoa1jdtYkmje9LvUVj73dDc/j3MXqyhJcCc1v?= =?us-ascii?Q?9ygQ9Pq+vfppM9ecGqWLU0ji0nVWMbG5WDv88Xl3ZJDh4/tkfg=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)(376014)(82310400026)(36860700013)(1800799024); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: VWOo2KQ9sv+n9xtKQXsS1o0AYSALMQoWl0RmceTx5+Vqbnjsbv4GXr3iCzg7zLP/EygScRcs7EcWB5hBp9MccVPvdkLS1LRuJ3ftkVOuWOktO44f1BB0Txzh4mfj7ckAFVW/G8BSirXHraryiXPTO0lfDBTHwGL1SZZs0bVgRC/TUEIfB0sxZf/dA+m7Qq/p50Os6yHFfD9tAYvsMi4x5/WY/+Wotkp9XdqEZXWHxdZhcCjhdgOKjngCWTVgvTiTOQ3h0cb2a/V5rKqXJFwrvzAWpWBAzTJFOOwEsPAq8DB7sWbZ0CnvpJD8XLM1o5q1PSDyOTOEf3y+WvhLXQu2xb4JhmBpYHq0FM8iYgrggt4gMghPl0p4PNjBBmlVQ9ZRH3zwAQk2bifCYOQeSZ3J0f8QA7g2D/GUETe7THD1ZTDcXpbGFMp19Unag/OYxvepdX0xeCNxOzRIcXNIWAvjrc5RuTtm+mS1L9I0de9aGio96JCQQSbVcIg4zXF0FBeLynb7qHIeeHbJCTpsMnD35lpQ4vlaEr6pYCQ9b0jt81xT0p9EE+QU1l8MGzbeMNRRmdYxhOsj6UFJOSZeHrYitQ3+ewC3SWhV1STAi59+E78iSF+qknhasrk61PtG4Mb01stkxtE3GYFsIjy4HUA1iAW7e/UVfmzxPYSTt+YVqq4= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2024 16:56:38.8878 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 805aec5a-a6a7-48cf-4dfa-08dcf2ba7f38 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: DU2PEPF0001E9C2.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3P190MB0890 X-BESS-ID: 1729616202-303894-12665-13520-2 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.18.109 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoYW5kamQGYGUNTE3MTQ0ijJOC 3R3Ngo1TjZ0MjEzCTR0jzN1NAoycTCSKk2FgCrcmXYQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.259902 [from cloudscan10-0.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 ac29c59f26..e47ef37c6b 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 @@ -4301,6 +4301,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 = { /* @@ -4309,6 +4389,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 df391b6399..5505198148 100644 --- a/drivers/net/ntnic/ntnic_filter/ntnic_filter.c +++ b/drivers/net/ntnic/ntnic_filter/ntnic_filter.c @@ -569,9 +569,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