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 C5EA445B04; Thu, 10 Oct 2024 16:19:07 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2C2B440E0A; Thu, 10 Oct 2024 16:15:28 +0200 (CEST) Received: from egress-ip11b.ess.de.barracuda.com (egress-ip11b.ess.de.barracuda.com [18.185.115.215]) by mails.dpdk.org (Postfix) with ESMTP id D863A409FA for ; Thu, 10 Oct 2024 16:15:05 +0200 (CEST) Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02lp2235.outbound.protection.outlook.com [104.47.11.235]) by mx-outbound20-48.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 10 Oct 2024 14:15:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lhy5epdwRbDc0XKTYP5AtrYnAVTrV0gWDjlM7RMRE6j2VGPS4DuukOmWBsN6pG/BQkxanKW5N39TAXpnngz9gLzA7Nwv+0x6qqgyXHZgUJIyqp2yFE9eStHVr7dyPa+jJhgL2/lLvE+8MrFQTpZ2zXhktL9rtPHxR4wRDDcCINJQeHAxaLKv8yJBqrPawKG7F6fWcGUpa9clVTTlAXCxPhHO0ie6Lf31HCEA6gXWdU3JcNh5i/RkjWk+0nnI+qRq5lcW6M7zCIAv+we0mnnQC+efxlYOGl8LWvy7DMmnTsffJD1xr5U1ho5QwDR+ZiuoZCb9SeOdNNO365ufL5nO8g== 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=Yg6l+ZVRy3SX90vX+KNa5gz9/fPwFqKsUU8Eznljlno=; b=qf4O14xfEYBFGNU5Y+xLd7O2i9TWHGfhRytEc/ROetHNFWnf8TB42T/IJ3wgmaNk4M0wjzgKEkaVi7YV5ab0THA7nWVRmnvN5mnHvcRf8kvD/xD4I+DtPbvW/wN4/UExcj8g2v9OI6H9u+sKGBLnMXrElcYBgoEniShdHw1D532zBHnYfj3fy8R36vUaK/SzPeZGEnNevRngWxxs9O3wmkLtbHmo4TzcoHINXUwRwoTS0WlvjwupOL3laXuCagekSyc9dpkkuBT9UJU+RpKy/Bn3pGGNhUe78CmbmKXY93bkw26pWnu+XL6UMOQSAXYDRy07Wfz2oHCbVHR+UUVqcg== 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=Yg6l+ZVRy3SX90vX+KNa5gz9/fPwFqKsUU8Eznljlno=; b=XMjynUnRrj3bPohb1dzmc4mvwl58XYOLPZA2MZm+eVmUPcYrpVtDgOl0MCeqygIu8xkr/yuJa4A3ObGrp6FNHRR8ILEwsLmkWquqIw8i4CyrmNheDm8oex+2I/oV44TQqs3d7KiaVZlQxqA98Leeeauy8/sQ/ozUSu7At/BYTMI= Received: from DU2PR04CA0084.eurprd04.prod.outlook.com (2603:10a6:10:232::29) by DBAP190MB0997.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:1a8::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.18; Thu, 10 Oct 2024 14:15:00 +0000 Received: from DU6PEPF0000B61B.eurprd02.prod.outlook.com (2603:10a6:10:232:cafe::96) by DU2PR04CA0084.outlook.office365.com (2603:10a6:10:232::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.17 via Frontend Transport; Thu, 10 Oct 2024 14:15:00 +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 DU6PEPF0000B61B.mail.protection.outlook.com (10.167.8.132) with Microsoft SMTP Server id 15.20.8048.13 via Frontend Transport; Thu, 10 Oct 2024 14:14:59 +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, Danylo Vodopianov Subject: [PATCH v3 37/50] net/ntnic: add basic queue operations Date: Thu, 10 Oct 2024 16:13:52 +0200 Message-ID: <20241010141416.4063591-38-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241010141416.4063591-1-sil-plv@napatech.com> References: <20241006203728.330792-2-sil-plv@napatech.com> <20241010141416.4063591-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU6PEPF0000B61B:EE_|DBAP190MB0997:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 33b858c6-04a0-4a6d-3331-08dce935ed33 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|1800799024|82310400026|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?mR902J7/dGwosYI75GPDtmJ9FE4sMmmQH5gdh/eH6AYjX3ejWIzdzt4uUOFk?= =?us-ascii?Q?eJK3brw3N/JNKeRe+ZfgtgcTwY10axgX3I7QGFNlbdKRwqN+lXzUyT2uYKFY?= =?us-ascii?Q?sSGGyk1sSqkOvbv7H/jEjp4Uri5ZSXLCbO1wl6dYUnDygaVqXMxtF52EIx6M?= =?us-ascii?Q?T0d0I24Fuq/W/4CdCW4ARikvlW/K0lrzGRJrB2wOkSvk9c3Ihaz4lCjpzbeg?= =?us-ascii?Q?Sk+Ne2jUYiDGqOlcHZOCCdzUQsftTD/ZAAGbg9q7vaqy46JZPcoXdVp9E5yT?= =?us-ascii?Q?kMSy7ZlzA31E1muXnBupVEipFBpL0sF2O3O1li2HvIOXcDnCJRZ9xDKkFXYs?= =?us-ascii?Q?TXpmCnpo2HLVjFmcrveZX3bb2bkZwaNXGmd/cRFukF3YqPhV9FA86ReozVtO?= =?us-ascii?Q?rdONdzTiKleM/A6nZRzeOs8CPdl7/Wc2VHv8qdYzl/lpfEZnhwsWHmoXwFnC?= =?us-ascii?Q?Sf0n8aKG6NnmhfzPhfSEqaeJrxTkqQzsAONbhoBsi06y0Avqr8rIMJXQZ9QJ?= =?us-ascii?Q?t0YBEeEiZlys7BnvlgIZ641Ui/GTvlAlkJ2/dr1f9bax2Yv2bN4W1ycSY97g?= =?us-ascii?Q?x2d31egvSE9IQW0YwDf+ARzo3oAne4AwyZTdZrgWXPC2lR6f6g5fo9i7kHSQ?= =?us-ascii?Q?L4um32geyO/rYxq1IXzofDirdHVQmrCnAthwsAyrSV3dpnOLpPU6kKsHD9pl?= =?us-ascii?Q?yWDORBeo3TvHxq64AJYzOolytNmbS/EYvImOEksgxuzNj5Rh7V6VGSkjM92k?= =?us-ascii?Q?vyEBN5o0iPzYB6khXg/ea13BggemtW2XYB2sp2KPqdbEL76jyPfelgd5bWDR?= =?us-ascii?Q?fBQmUM74kW1Qo1Sn15+8bBdUC1qQzTLw1wDrpJmUn9QxAnETLlWMITpwnXOt?= =?us-ascii?Q?TGkRTsMxYP1PT77lSaX9/WDHjryHcQ37PYsCFdJWydJWYydlPd1I1H3mwMkk?= =?us-ascii?Q?u1mZwgI+R/kfnoMke/nT1isMquZa63VqxxBLtZHDcYNiTf0k08bQkWawbBpm?= =?us-ascii?Q?AAoyZU50bXvdhcvIqORppuz+oTs4OyWHOIncLQ5Q6lLG/WsXK4P8+HzEL0Vl?= =?us-ascii?Q?CyBG6kMAj6zGpaAm2FLvWyS3Y/2UdjQtVxVVw7ZrXlJXKx0h4XlDBZduv7a6?= =?us-ascii?Q?Qr/vO8ffizVhxDr8bUEOcvye2+tCQe/xMRXxDWlFRYTEvDwpRw0nFfSJL3W3?= =?us-ascii?Q?3xT7rB65ccQlip2tDvqCbidrXslnGZ7HtgQOMKV0CrOhS36h1tMHmf4F12RL?= =?us-ascii?Q?ogaSZ88oMco/wlgM6F3N+4FjX8jhm8ENMaMwzcGbSK6nerxiaYnqxG5ZHJ2P?= =?us-ascii?Q?RV+3eBL+rGe3jOtPhj020wAz6LBSMb/0Vgw6TtrLGS1pgXWsag+i02mUZC2C?= =?us-ascii?Q?FWu/mviNNxnd9aGnHuc3XmnQ1wCY?= 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)(36860700013)(1800799024)(82310400026)(376014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: CqOY9nN6MLpVE4EN3O3KCIJpwMsh/TfZCRdU3lZySMRECmAem3U6kvEjH1+QRbYoCUtaGW/YT7Kc/n9YeNVDf3AwO6IEPG7NQ4vCR77uk4Dm7lsapwNIcLiVjpsCMGG9Xx2cbATgFBkYj7OiALqWXO5Ah8jmpbisOqwGG8aHHeVyPLA8qarlxIxwRIary2HooWQ22tcsFznvoNrSO7t3tn0nu/8VT/73jNBxL9uwIpCP/x84fuwVeGXWbRBCJiTNQwqRzT1Pqbp8xse9PA/vCG5apfqY4ALZ+EhZDiw2rUEc2GwWeBUx1MvvqhRwAlw0kRTGsV+6yKvUHXWFRQFSVJuPKbb7yrYdZgJGuZnWU/shSoCwEUY/LTrBnBtLplQ5KfAXUZvN+8nzLh9cXOlayETnytsnqYEJXVzVCdUKSBtPYZK/dJ1UiR6B+M6D1ciBc75CjvmWG/cBNdy/zuTKz5hx7x6KjOna7WNYJUJGdxf+/GYGeaEmyoqCsDvt5ZFl3fGTj7jTDrh7MuxKgnJrRiv9jP/di/tRkKK6V0V9Pas2u9Vu8BbJgiTyKfsyuHPTJlWhjK3ysljobXMGHKza2x7bsNR1nFGAzwBeul5IQ1AOy2cuNAFwaSIYwObE3NFTo/LYhVVBS0knb2DGUb+I9omM7U2F7e1AK4ZulzOsP6w= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Oct 2024 14:14:59.9049 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 33b858c6-04a0-4a6d-3331-08dce935ed33 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: DU6PEPF0000B61B.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAP190MB0997 X-BESS-ID: 1728569703-305168-12628-25353-1 X-BESS-VER: 2019.1_20241004.2057 X-BESS-Apparent-Source-IP: 104.47.11.235 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoZGpuZGQGYGUDTRIjUxzdjcws QkycTA0DLZwjTJKMUk2TzV0iLNwMLSTKk2FgCRW0sGQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.259630 [from cloudscan10-73.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: Danylo Vodopianov Adds support for queue configure, start, stop, release. The internal macro and functions of ntnic were also added and initialized. Signed-off-by: Danylo Vodopianov --- v3 * Remove newline characters from logs. --- doc/guides/nics/features/ntnic.ini | 1 + drivers/net/ntnic/include/ntos_drv.h | 34 +++++ drivers/net/ntnic/ntnic_ethdev.c | 208 +++++++++++++++++++++++++++ drivers/net/ntnic/ntutil/nt_util.c | 10 ++ drivers/net/ntnic/ntutil/nt_util.h | 2 + 5 files changed, 255 insertions(+) diff --git a/doc/guides/nics/features/ntnic.ini b/doc/guides/nics/features/ntnic.ini index b6d92c7ee1..8b9b87bdfe 100644 --- a/doc/guides/nics/features/ntnic.ini +++ b/doc/guides/nics/features/ntnic.ini @@ -7,6 +7,7 @@ FW version = Y Speed capabilities = Y Link status = Y +Queue start/stop = Y Unicast MAC filter = Y Multicast MAC filter = Y Linux = Y diff --git a/drivers/net/ntnic/include/ntos_drv.h b/drivers/net/ntnic/include/ntos_drv.h index 67baf9fe0c..a77e6a0247 100644 --- a/drivers/net/ntnic/include/ntos_drv.h +++ b/drivers/net/ntnic/include/ntos_drv.h @@ -13,6 +13,7 @@ #include +#include "stream_binary_flow_api.h" #include "nthw_drv.h" #define NUM_MAC_ADDRS_PER_PORT (16U) @@ -21,6 +22,32 @@ #define NUM_ADAPTER_MAX (8) #define NUM_ADAPTER_PORTS_MAX (128) + +/* Max RSS queues */ +#define MAX_QUEUES 125 + +/* Structs: */ +struct __rte_cache_aligned ntnic_rx_queue { + struct flow_queue_id_s queue; /* queue info - user id and hw queue index */ + struct rte_mempool *mb_pool; /* mbuf memory pool */ + uint16_t buf_size; /* Size of data area in mbuf */ + int enabled; /* Enabling/disabling of this queue */ + + nt_meta_port_type_t type; + uint32_t port; /* Rx port for this queue */ + enum fpga_info_profile profile; /* Inline / Capture */ + +}; + +struct __rte_cache_aligned ntnic_tx_queue { + struct flow_queue_id_s queue; /* queue info - user id and hw queue index */ + nt_meta_port_type_t type; + + uint32_t port; /* Tx port for this queue */ + int enabled; /* Enabling/disabling of this queue */ + enum fpga_info_profile profile; /* Inline / Capture */ +}; + struct pmd_internals { const struct rte_pci_device *pci_dev; char name[20]; @@ -30,7 +57,14 @@ struct pmd_internals { unsigned int nb_tx_queues; /* Offset of the VF from the PF */ uint8_t vf_offset; + uint32_t port; nt_meta_port_type_t type; + struct flow_queue_id_s vpq[MAX_QUEUES]; + unsigned int vpq_nb_vq; + /* Array of Rx queues */ + struct ntnic_rx_queue rxq_scg[MAX_QUEUES]; + /* Array of Tx queues */ + struct ntnic_tx_queue txq_scg[MAX_QUEUES]; struct drv_s *p_drv; /* Ethernet (MAC) addresses. Element number zero denotes default address. */ struct rte_ether_addr eth_addrs[NUM_MAC_ADDRS_PER_PORT]; diff --git a/drivers/net/ntnic/ntnic_ethdev.c b/drivers/net/ntnic/ntnic_ethdev.c index b261444e8e..b45e25844a 100644 --- a/drivers/net/ntnic/ntnic_ethdev.c +++ b/drivers/net/ntnic/ntnic_ethdev.c @@ -3,12 +3,17 @@ * Copyright(c) 2023 Napatech A/S */ +#include + #include #include #include #include #include #include +#include + +#include #include "ntlog.h" #include "ntdrv_4ga.h" @@ -24,6 +29,23 @@ #define EXCEPTION_PATH_HID 0 +#define MAX_TOTAL_QUEUES 128 + +/* Max RSS queues */ +#define MAX_QUEUES 125 + +#define ETH_DEV_NTNIC_HELP_ARG "help" +#define ETH_DEV_NTHW_RXQUEUES_ARG "rxqs" +#define ETH_DEV_NTHW_TXQUEUES_ARG "txqs" + +static const char *const valid_arguments[] = { + ETH_DEV_NTNIC_HELP_ARG, + ETH_DEV_NTHW_RXQUEUES_ARG, + ETH_DEV_NTHW_TXQUEUES_ARG, + NULL, +}; + + static const struct rte_pci_id nthw_pci_id_map[] = { { RTE_PCI_DEVICE(NT_HW_PCI_VENDOR_ID, NT_HW_PCI_DEVICE_ID_NT200A02) }, { @@ -161,6 +183,58 @@ eth_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *dev_info return 0; } +static void eth_tx_queue_release(struct rte_eth_dev *eth_dev, uint16_t queue_id) +{ + (void)eth_dev; + (void)queue_id; +} + +static void eth_rx_queue_release(struct rte_eth_dev *eth_dev, uint16_t queue_id) +{ + (void)eth_dev; + (void)queue_id; +} + +static int num_queues_alloced; + +/* Returns num queue starting at returned queue num or -1 on fail */ +static int allocate_queue(int num) +{ + int next_free = num_queues_alloced; + NT_LOG_DBGX(DBG, NTNIC, "num_queues_alloced=%u, New queues=%u, Max queues=%u", + num_queues_alloced, num, MAX_TOTAL_QUEUES); + + if (num_queues_alloced + num > MAX_TOTAL_QUEUES) + return -1; + + num_queues_alloced += num; + return next_free; +} + +static int eth_rx_queue_start(struct rte_eth_dev *eth_dev, uint16_t rx_queue_id) +{ + eth_dev->data->rx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED; + return 0; +} + +static int eth_rx_queue_stop(struct rte_eth_dev *eth_dev, uint16_t rx_queue_id) +{ + eth_dev->data->rx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED; + return 0; +} + +static int eth_tx_queue_start(struct rte_eth_dev *eth_dev, uint16_t rx_queue_id) +{ + eth_dev->data->tx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED; + return 0; +} + +static int eth_tx_queue_stop(struct rte_eth_dev *eth_dev, uint16_t rx_queue_id) +{ + eth_dev->data->tx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED; + return 0; +} + static int eth_mac_addr_add(struct rte_eth_dev *eth_dev, struct rte_ether_addr *mac_addr, @@ -247,6 +321,15 @@ eth_dev_start(struct rte_eth_dev *eth_dev) NT_LOG_DBGX(DBG, NTNIC, "Port %u", internals->n_intf_no); + /* Start queues */ + uint q; + + for (q = 0; q < internals->nb_rx_queues; q++) + eth_rx_queue_start(eth_dev, q); + + for (q = 0; q < internals->nb_tx_queues; q++) + eth_tx_queue_start(eth_dev, q); + if (internals->type == PORT_TYPE_VIRTUAL || internals->type == PORT_TYPE_OVERRIDE) { eth_dev->data->dev_link.link_status = RTE_ETH_LINK_UP; @@ -296,6 +379,16 @@ eth_dev_stop(struct rte_eth_dev *eth_dev) NT_LOG_DBGX(DBG, NTNIC, "Port %u", internals->n_intf_no); + if (internals->type != PORT_TYPE_VIRTUAL) { + uint q; + + for (q = 0; q < internals->nb_rx_queues; q++) + eth_rx_queue_stop(eth_dev, q); + + for (q = 0; q < internals->nb_tx_queues; q++) + eth_tx_queue_stop(eth_dev, q); + } + eth_dev->data->dev_link.link_status = RTE_ETH_LINK_DOWN; return 0; } @@ -438,6 +531,12 @@ static const struct eth_dev_ops nthw_eth_dev_ops = { .link_update = eth_link_update, .dev_infos_get = eth_dev_infos_get, .fw_version_get = eth_fw_version_get, + .rx_queue_start = eth_rx_queue_start, + .rx_queue_stop = eth_rx_queue_stop, + .rx_queue_release = eth_rx_queue_release, + .tx_queue_start = eth_tx_queue_start, + .tx_queue_stop = eth_tx_queue_stop, + .tx_queue_release = eth_tx_queue_release, .mac_addr_add = eth_mac_addr_add, .mac_addr_set = eth_mac_addr_set, .set_mc_addr_list = eth_set_mc_addr_list, @@ -462,6 +561,7 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev) return -1; } + int res; struct drv_s *p_drv; ntdrv_4ga_t *p_nt_drv; hw_info_t *p_hw_info; @@ -469,6 +569,7 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev) uint32_t n_port_mask = -1; /* All ports enabled by default */ uint32_t nb_rx_queues = 1; uint32_t nb_tx_queues = 1; + struct flow_queue_id_s queue_ids[MAX_QUEUES]; int n_phy_ports; struct port_link_speed pls_mbps[NUM_ADAPTER_PORTS_MAX] = { 0 }; int num_port_speeds = 0; @@ -476,6 +577,81 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev) pci_dev->addr.function, pci_dev->addr.bus, pci_dev->addr.devid, pci_dev->addr.function); + /* + * Process options/arguments + */ + if (pci_dev->device.devargs && pci_dev->device.devargs->args) { + int kvargs_count; + struct rte_kvargs *kvlist = + rte_kvargs_parse(pci_dev->device.devargs->args, valid_arguments); + + if (kvlist == NULL) + return -1; + + /* + * Argument: help + * NOTE: this argument/option check should be the first as it will stop + * execution after producing its output + */ + { + if (rte_kvargs_get(kvlist, ETH_DEV_NTNIC_HELP_ARG)) { + size_t i; + + for (i = 0; i < RTE_DIM(valid_arguments); i++) + if (valid_arguments[i] == NULL) + break; + + exit(0); + } + } + + /* + * rxq option/argument + * The number of rxq (hostbuffers) allocated in memory. + * Default is 32 RX Hostbuffers + */ + kvargs_count = rte_kvargs_count(kvlist, ETH_DEV_NTHW_RXQUEUES_ARG); + + if (kvargs_count != 0) { + assert(kvargs_count == 1); + res = rte_kvargs_process(kvlist, ETH_DEV_NTHW_RXQUEUES_ARG, &string_to_u32, + &nb_rx_queues); + + if (res < 0) { + NT_LOG_DBGX(ERR, NTNIC, + "problem with command line arguments: res=%d", + res); + return -1; + } + + NT_LOG_DBGX(DBG, NTNIC, "devargs: %s=%u", + ETH_DEV_NTHW_RXQUEUES_ARG, nb_rx_queues); + } + + /* + * txq option/argument + * The number of txq (hostbuffers) allocated in memory. + * Default is 32 TX Hostbuffers + */ + kvargs_count = rte_kvargs_count(kvlist, ETH_DEV_NTHW_TXQUEUES_ARG); + + if (kvargs_count != 0) { + assert(kvargs_count == 1); + res = rte_kvargs_process(kvlist, ETH_DEV_NTHW_TXQUEUES_ARG, &string_to_u32, + &nb_tx_queues); + + if (res < 0) { + NT_LOG_DBGX(ERR, NTNIC, + "problem with command line arguments: res=%d", + res); + return -1; + } + + NT_LOG_DBGX(DBG, NTNIC, "devargs: %s=%u", + ETH_DEV_NTHW_TXQUEUES_ARG, nb_tx_queues); + } + } + /* alloc */ p_drv = rte_zmalloc_socket(pci_dev->name, sizeof(struct drv_s), RTE_CACHE_LINE_SIZE, @@ -581,6 +757,7 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev) struct pmd_internals *internals = NULL; struct rte_eth_dev *eth_dev = NULL; char name[32]; + int i; if ((1 << n_intf_no) & ~n_port_mask) { NT_LOG_DBGX(DBG, NTNIC, @@ -608,6 +785,10 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev) internals->nb_rx_queues = nb_rx_queues; internals->nb_tx_queues = nb_tx_queues; + /* Not used queue index as dest port in bypass - use 0x80 + port nr */ + for (i = 0; i < MAX_QUEUES; i++) + internals->vpq[i].hw_id = -1; + /* Setup queue_ids */ if (nb_rx_queues > 1) { @@ -622,6 +803,33 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev) internals->n_intf_no, nb_tx_queues); } + int max_num_queues = (nb_rx_queues > nb_tx_queues) ? nb_rx_queues : nb_tx_queues; + int start_queue = allocate_queue(max_num_queues); + + if (start_queue < 0) + return -1; + + for (i = 0; i < (int)max_num_queues; i++) { + queue_ids[i].id = i; + queue_ids[i].hw_id = start_queue + i; + + internals->rxq_scg[i].queue = queue_ids[i]; + /* use same index in Rx and Tx rings */ + internals->txq_scg[i].queue = queue_ids[i]; + internals->rxq_scg[i].enabled = 0; + internals->txq_scg[i].type = internals->type; + internals->rxq_scg[i].type = internals->type; + internals->rxq_scg[i].port = internals->port; + } + + /* no tx queues - tx data goes out on phy */ + internals->vpq_nb_vq = 0; + + for (i = 0; i < (int)nb_tx_queues; i++) { + internals->txq_scg[i].port = internals->port; + internals->txq_scg[i].enabled = 0; + } + /* Set MAC address (but only if the MAC address is permitted) */ if (n_intf_no < fpga_info->nthw_hw_info.vpd_info.mn_mac_addr_count) { const uint64_t mac = diff --git a/drivers/net/ntnic/ntutil/nt_util.c b/drivers/net/ntnic/ntutil/nt_util.c index 478b1b65be..694ab7a3b3 100644 --- a/drivers/net/ntnic/ntutil/nt_util.c +++ b/drivers/net/ntnic/ntutil/nt_util.c @@ -234,3 +234,13 @@ int nt_link_duplex_to_eth_duplex(enum nt_link_duplex_e nt_link_duplex) return eth_link_duplex; } + +int string_to_u32(const char *key_str __rte_unused, const char *value_str, void *extra_args) +{ + if (!value_str || !extra_args) + return -1; + + const uint32_t value = strtol(value_str, NULL, 0); + *(uint32_t *)extra_args = value; + return 0; +} diff --git a/drivers/net/ntnic/ntutil/nt_util.h b/drivers/net/ntnic/ntutil/nt_util.h index d82e6d3248..64947f5fbf 100644 --- a/drivers/net/ntnic/ntutil/nt_util.h +++ b/drivers/net/ntnic/ntutil/nt_util.h @@ -57,4 +57,6 @@ uint32_t nt_link_speed_capa_to_eth_speed_capa(int nt_link_speed_capa); nt_link_speed_t convert_link_speed(int link_speed_mbps); int nt_link_duplex_to_eth_duplex(enum nt_link_duplex_e nt_link_duplex); +int string_to_u32(const char *key_str __rte_unused, const char *value_str, void *extra_args); + #endif /* NTOSS_SYSTEM_NT_UTIL_H */ -- 2.45.0