Skip to contentSkip to conversation

net/ntnic: Add registers for NapaTech SmartNiC

PATCH Superseded Serhii Iliushyk 6 participants 238 messages May 30, 2024 – Jul 23, 2024 3 messages not in the archive Page 5 of 6

Subsystems (2)
lore
Share & tools
lore
#146 lore raw

PATCH v7 9/21 net/ntnic: add registers and FPGA model for NapaTech NIC

In reply to Serhii Iliushyk

The NTNIC PMD does not rely on a kernel space Napatech driver, thus all defines related to the register layout is part of the PMD code, which will be added in later commits.

---
 drivers/net/ntnic/include/fpga_model.h        |  102 ++
 drivers/net/ntnic/meson.build                 |    4 +
 .../net/ntnic/nthw/model/nthw_fpga_model.c    | 1192 ++++++++++++++++
 .../net/ntnic/nthw/model/nthw_fpga_model.h    |  245 ++++
 drivers/net/ntnic/nthw/nthw_register.h        |   21 +
 .../supported/nthw_fpga_9563_055_039_0000.c   | 1225 +++++++++++++++++
 .../nthw/supported/nthw_fpga_instances.c      |    4 +
 .../nthw/supported/nthw_fpga_instances.h      |    5 +
 .../ntnic/nthw/supported/nthw_fpga_mod_defs.h |   28 +
 .../nthw/supported/nthw_fpga_mod_str_map.c    |   19 +
 .../nthw/supported/nthw_fpga_mod_str_map.h    |    9 +
 .../nthw/supported/nthw_fpga_param_defs.h     |  224 +++
 .../ntnic/nthw/supported/nthw_fpga_reg_defs.h |   27 +
 .../nthw/supported/nthw_fpga_reg_defs_gfg.h   |  118 ++
 .../nthw/supported/nthw_fpga_reg_defs_gmf.h   |   60 +
 .../supported/nthw_fpga_reg_defs_gpio_phy.h   |   40 +
 .../nthw/supported/nthw_fpga_reg_defs_hif.h   |   71 +
 .../nthw/supported/nthw_fpga_reg_defs_i2cm.h  |   30 +
 .../nthw/supported/nthw_fpga_reg_defs_iic.h   |   88 ++
 .../supported/nthw_fpga_reg_defs_mac_pcs.h    |  290 ++++
 .../supported/nthw_fpga_reg_defs_pci_rd_tg.h  |   29 +
 .../supported/nthw_fpga_reg_defs_pci_wr_tg.h  |   32 +
 .../nthw/supported/nthw_fpga_reg_defs_pcie3.h |  273 ++++
 .../nthw/supported/nthw_fpga_reg_defs_rac.h   |   64 +
 .../supported/nthw_fpga_reg_defs_rst9563.h    |   51 +
 .../nthw/supported/nthw_fpga_reg_defs_sdc.h   |   36 +
 drivers/net/ntnic/ntnic_ethdev.c              |    1 +
 27 files changed, 4288 insertions(+)
 create mode 100644 drivers/net/ntnic/include/fpga_model.h
 create mode 100644 drivers/net/ntnic/nthw/model/nthw_fpga_model.c
 create mode 100644 drivers/net/ntnic/nthw/model/nthw_fpga_model.h
 create mode 100644 drivers/net/ntnic/nthw/nthw_register.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_9563_055_039_0000.c
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_instances.c
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_instances.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_mod_defs.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_mod_str_map.c
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_mod_str_map.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_param_defs.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_gfg.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_gmf.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_gpio_phy.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_hif.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_i2cm.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_iic.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_mac_pcs.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_pci_rd_tg.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_pci_wr_tg.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_pcie3.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_rac.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_rst9563.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_sdc.h
drivers/net/ntnic/include/fpga_model.h new file +102 -0
new file mode 100644
index 0000000000..d73cf168ed
@@ -0,0 +1,102 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef _FPGA_MODEL_H_
+#define _FPGA_MODEL_H_
+
+#include <unistd.h>
+#include <stdint.h>
+#include <inttypes.h>
+
+typedef uint32_t nthw_id_t;
+
+enum nthw_fpga_bus_type {
+	NTHW_FPGA_BUS_TYPE_UNKNOWN =
+		0,	/* Unknown/uninitialized - keep this as the first enum element */
+	NTHW_FPGA_BUS_TYPE_BAR,
+	NTHW_FPGA_BUS_TYPE_PCI,
+	NTHW_FPGA_BUS_TYPE_CCIP,
+	NTHW_FPGA_BUS_TYPE_RAB0,
+	NTHW_FPGA_BUS_TYPE_RAB1,
+	NTHW_FPGA_BUS_TYPE_RAB2,
+	NTHW_FPGA_BUS_TYPE_NMB,
+	NTHW_FPGA_BUS_TYPE_NDM,
+	NTHW_FPGA_BUS_TYPE_SPI0,
+	NTHW_FPGA_BUS_TYPE_SPI = NTHW_FPGA_BUS_TYPE_SPI0,
+};
+
+typedef enum nthw_fpga_bus_type nthw_fpga_bus_type_e;
+
+enum nthw_fpga_register_type {
+	NTHW_FPGA_REG_TYPE_UNKNOWN =
+		0,	/* Unknown/uninitialized - keep this as the first enum element */
+	NTHW_FPGA_REG_TYPE_RW,
+	NTHW_FPGA_REG_TYPE_RO,
+	NTHW_FPGA_REG_TYPE_WO,
+	NTHW_FPGA_REG_TYPE_RC1,
+	NTHW_FPGA_REG_TYPE_MIXED,
+};
+
+typedef enum nthw_fpga_register_type nthw_fpga_register_type_e;
+
+struct nthw_fpga_field_init {
+	nthw_id_t id;
+	uint16_t bw;
+	uint16_t low;
+	uint64_t reset_val;
+};
+
+typedef struct nthw_fpga_field_init nthw_fpga_field_init_s;
+
+struct nthw_fpga_register_init {
+	nthw_id_t id;
+	uint32_t addr_rel;
+	uint16_t bw;
+	nthw_fpga_register_type_e type;
+	uint64_t reset_val;
+	int nb_fields;
+	struct nthw_fpga_field_init *fields;
+};
+
+typedef struct nthw_fpga_register_init nthw_fpga_register_init_s;
+
+struct nthw_fpga_module_init {
+	nthw_id_t id;
+	int instance;
+	nthw_id_t def_id;
+	int major_version;
+	int minor_version;
+	nthw_fpga_bus_type_e bus_id;
+	uint32_t addr_base;
+	int nb_registers;
+	struct nthw_fpga_register_init *registers;
+};
+
+typedef struct nthw_fpga_module_init nthw_fpga_module_init_s;
+
+struct nthw_fpga_prod_param {
+	const nthw_id_t id;
+	const int value;
+};
+
+typedef struct nthw_fpga_prod_param nthw_fpga_prod_param_s;
+
+struct nthw_fpga_prod_init {
+	int fpga_item_id;
+	int fpga_product_id;
+	int fpga_version;
+	int fpga_revision;
+	int fpga_patch_no;
+	int fpga_build_no;
+	uint32_t fpga_build_time;
+	int nb_prod_params;
+	struct nthw_fpga_prod_param *product_params;
+	int nb_modules;
+	struct nthw_fpga_module_init *modules;
+};
+
+typedef struct nthw_fpga_prod_init nthw_fpga_prod_init_s;
+
+#endif	/* _FPGA_MODEL_H_ */
drivers/net/ntnic/meson.build +4 -0
index 94f24e09e3..9d78e54470 100644
@@ -14,11 +14,15 @@ includes = [
     include_directories('ntlog'),
     include_directories('ntutil'),
     include_directories('nthw'),
+    include_directories('nthw/supported'),
 ]
 
 # all sources
 sources = files(
     'adapter/nt4ga_adapter.c',
+    'nthw/supported/nthw_fpga_9563_055_039_0000.c',
+    'nthw/supported/nthw_fpga_instances.c',
+    'nthw/supported/nthw_fpga_mod_str_map.c',
     'nthw/nthw_platform.c',
     'ntlog/ntlog.c',
     'ntutil/nt_util.c',
drivers/net/ntnic/nthw/model/nthw_fpga_model.c new file +1192 -0

1,192 lines not on this page · raw message

drivers/net/ntnic/nthw/model/nthw_fpga_model.h new file +245 -0

245 lines not on this page · raw message

drivers/net/ntnic/nthw/nthw_register.h new file +21 -0
new file mode 100644
index 0000000000..db006fcf72
@@ -0,0 +1,21 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef NTHW_REGISTER_H_
+#define NTHW_REGISTER_H_
+
+#include <unistd.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <inttypes.h>
+
+
+#include "fpga_model.h"
+
+#include "nthw_fpga_mod_defs.h"
+#include "nthw_fpga_param_defs.h"
+#include "nthw_fpga_reg_defs.h"
+
+#endif	/* NTHW_REGISTER_H_ */
drivers/net/ntnic/nthw/supported/nthw_fpga_9563_055_039_0000.c new file +1225 -0

1,225 lines not on this page · raw message

drivers/net/ntnic/nthw/supported/nthw_fpga_instances.c new file +4 -0
new file mode 100644
index 0000000000..ff6efc6e75
@@ -0,0 +1,4 @@
+
+
+#include "nthw_fpga_instances.h"
+nthw_fpga_prod_init_s *nthw_fpga_instances[] = { &nthw_fpga_9563_055_039_0000, NULL };
drivers/net/ntnic/nthw/supported/nthw_fpga_instances.h new file +5 -0
new file mode 100644
index 0000000000..05c0b94bbe
@@ -0,0 +1,5 @@
+
+
+#include "fpga_model.h"
+extern nthw_fpga_prod_init_s *nthw_fpga_instances[];
+extern nthw_fpga_prod_init_s nthw_fpga_9563_055_039_0000;
drivers/net/ntnic/nthw/supported/nthw_fpga_mod_defs.h new file +28 -0
new file mode 100644
index 0000000000..0c746f8f53
@@ -0,0 +1,28 @@
+/*
+ * nthw_fpga_mod_defs.h
+ *
+ * Auto-generated file - do *NOT* edit
+ *
+ */
+
+#ifndef _NTHW_FPGA_MOD_DEFS_H_
+#define _NTHW_FPGA_MOD_DEFS_H_
+
+#define MOD_UNKNOWN (0L)/* Unknown/uninitialized - keep this as the first element */
+#define MOD_GFG (0xfc423807UL)
+#define MOD_GMF (0x68b1d15aUL)
+#define MOD_GPIO_PHY (0xbbe81659UL)
+#define MOD_HIF (0x7815363UL)
+#define MOD_I2CM (0x93bc7780UL)
+#define MOD_IIC (0x7629cddbUL)
+#define MOD_MAC_PCS (0x7abe24c7UL)
+#define MOD_PCIE3 (0xfbc48c18UL)
+#define MOD_PCI_RD_TG (0x9ad9eed2UL)
+#define MOD_PCI_WR_TG (0x274b69e1UL)
+#define MOD_RAC (0xae830b42UL)
+#define MOD_RST9563 (0x385d6d1dUL)
+#define MOD_SDC (0xd2369530UL)
+#define MOD_IDX_COUNT (14)
+
+/* aliases - only aliases go below this point */
+#endif	/* _NTHW_FPGA_MOD_DEFS_H_ */
drivers/net/ntnic/nthw/supported/nthw_fpga_mod_str_map.c new file +19 -0
new file mode 100644
index 0000000000..d7bc686fe8
@@ -0,0 +1,19 @@
+
+
+#include "nthw_fpga_mod_str_map.h"
+const struct nthw_fpga_mod_str_s sa_nthw_fpga_mod_str_map[] = {
+	{ MOD_GFG, "GFG" },
+	{ MOD_GMF, "GMF" },
+	{ MOD_GPIO_PHY, "GPIO_PHY" },
+	{ MOD_HIF, "HIF" },
+	{ MOD_I2CM, "I2CM" },
+	{ MOD_IIC, "IIC" },
+	{ MOD_MAC_PCS, "MAC_PCS" },
+	{ MOD_PCIE3, "PCIE3" },
+	{ MOD_PCI_RD_TG, "PCI_RD_TG" },
+	{ MOD_PCI_WR_TG, "PCI_WR_TG" },
+	{ MOD_RAC, "RAC" },
+	{ MOD_RST9563, "RST9563" },
+	{ MOD_SDC, "SDC" },
+	{ 0UL, NULL }
+};
drivers/net/ntnic/nthw/supported/nthw_fpga_mod_str_map.h new file +9 -0
new file mode 100644
index 0000000000..13971d5d4e
@@ -0,0 +1,9 @@
+
+
+#include "nthw_fpga_mod_defs.h"
+#include "fpga_model.h"
+struct nthw_fpga_mod_str_s {
+	const nthw_id_t a;
+	const char *b;
+};
+extern const struct nthw_fpga_mod_str_s sa_nthw_fpga_mod_str_map[];
drivers/net/ntnic/nthw/supported/nthw_fpga_param_defs.h new file +224 -0

135 lines not on this page · raw message

drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs.h new file +27 -0
new file mode 100644
index 0000000000..aeb564349e

Lines of this file are not shown. View the raw message.

drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_gfg.h new file +118 -0

118 lines not on this page · raw message

drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_gmf.h new file +60 -0

60 lines not on this page · raw message

drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_gpio_phy.h new file +40 -0
new file mode 100644
index 0000000000..8d160af298

Lines of this file are not shown. View the raw message.

drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_hif.h new file +71 -0

71 lines not on this page · raw message

drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_i2cm.h new file +30 -0
new file mode 100644
index 0000000000..4ef618e2e1

Lines of this file are not shown. View the raw message.

drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_iic.h new file +88 -0

88 lines not on this page · raw message

drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_mac_pcs.h new file +290 -0

290 lines not on this page · raw message

drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_pci_rd_tg.h new file +29 -0
new file mode 100644
index 0000000000..4f8e41f261

Lines of this file are not shown. View the raw message.

drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_pci_wr_tg.h new file +32 -0
new file mode 100644
index 0000000000..59bb1b2613

Lines of this file are not shown. View the raw message.

drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_pcie3.h new file +273 -0

273 lines not on this page · raw message

drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_rac.h new file +64 -0

64 lines not on this page · raw message

drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_rst9563.h new file +51 -0

51 lines not on this page · raw message

drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_sdc.h new file +36 -0
new file mode 100644
index 0000000000..d9cfff4128

Lines of this file are not shown. View the raw message.

drivers/net/ntnic/ntnic_ethdev.c +1 -0
index c84321ed91..ab4b66f4a3 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.45.0

Part of the diff is not shown here. View the raw message.

#147 lore raw

PATCH v7 10/21 net/ntnic: add FPGA modules for initialization

In reply to Serhii Iliushyk

New ntnic FPGA modules:
- Host Interface (HIF): Basic FPGA info such as prod ID and build time.
- Inter-Integrated Circuit Controller (IIC): Use the FPGA to access the other integrated circuits on the ntnic.
- PCI Express Gen3 (PCIE3): The FPGA part of PCIe3 initialization, speed tests, and configuration.

---
 drivers/net/ntnic/adapter/nt4ga_adapter.c     |   2 -
 drivers/net/ntnic/meson.build                 |   1 +
 .../net/ntnic/nthw/core/include/nthw_core.h   |  16 +
 .../net/ntnic/nthw/core/include/nthw_hif.h    | 151 ++++
 .../net/ntnic/nthw/core/include/nthw_iic.h    | 100 +++
 .../net/ntnic/nthw/core/include/nthw_pcie3.h  |  96 +++
 drivers/net/ntnic/nthw/core/nthw_hif.c        | 312 +++++++
 drivers/net/ntnic/nthw/core/nthw_iic.c        | 527 ++++++++++++
 drivers/net/ntnic/nthw/core/nthw_pcie3.c      | 259 ++++++
 drivers/net/ntnic/nthw/nthw_drv.h             |   3 +-
 drivers/net/ntnic/nthw/nthw_rac.c             | 784 ++++++++++++++++++
 drivers/net/ntnic/nthw/nthw_rac.h             | 153 ++++
 12 files changed, 2400 insertions(+), 4 deletions(-)
 create mode 100644 drivers/net/ntnic/nthw/core/include/nthw_core.h
 create mode 100644 drivers/net/ntnic/nthw/core/include/nthw_hif.h
 create mode 100644 drivers/net/ntnic/nthw/core/include/nthw_iic.h
 create mode 100644 drivers/net/ntnic/nthw/core/include/nthw_pcie3.h
 create mode 100644 drivers/net/ntnic/nthw/core/nthw_hif.c
 create mode 100644 drivers/net/ntnic/nthw/core/nthw_iic.c
 create mode 100644 drivers/net/ntnic/nthw/core/nthw_pcie3.c
 create mode 100644 drivers/net/ntnic/nthw/nthw_rac.c
 create mode 100644 drivers/net/ntnic/nthw/nthw_rac.h
drivers/net/ntnic/adapter/nt4ga_adapter.c +0 -2
index 7cc3841ecf..c9f228a8ed 100644
@@ -60,7 +60,6 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info)
 	/* ref: DN-0060 section 9 */
 	p_hw_info->hw_reserved1 = (p_hw_info->pci_device_id >> 12) & 0x000f;
 
-	/* mp_dev_name */
 	p_adapter_info->p_dev_name = p_dev_name;
 
 	if (p_dev_name) {
@@ -73,7 +72,6 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info)
 			p_adapter_info->fpga_info.pciident);
 	}
 
-	/* mp_adapter_id_str */
 	p_adapter_info->mp_adapter_id_str = p_adapter_id_str;
 
 	p_adapter_info->fpga_info.mp_adapter_id_str = p_adapter_id_str;
drivers/net/ntnic/meson.build +1 -0
index 9d78e54470..5dd1beada2 100644
@@ -13,6 +13,7 @@ includes = [
     include_directories('include'),
     include_directories('ntlog'),
     include_directories('ntutil'),
+    include_directories('nthw/core/include'),
     include_directories('nthw'),
     include_directories('nthw/supported'),
 ]
drivers/net/ntnic/nthw/core/include/nthw_core.h new file +16 -0
new file mode 100644
index 0000000000..c2602e396f
@@ -0,0 +1,16 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef __NTHW_CORE_H__
+#define __NTHW_CORE_H__
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdint.h>
+
+#include "nthw_platform_drv.h"
+
+
+#endif	/* __NTHW_CORE_H__ */
drivers/net/ntnic/nthw/core/include/nthw_hif.h new file +151 -0

151 lines not on this page · raw message

drivers/net/ntnic/nthw/core/include/nthw_iic.h new file +100 -0

100 lines not on this page · raw message

drivers/net/ntnic/nthw/core/include/nthw_pcie3.h new file +96 -0

96 lines not on this page · raw message

drivers/net/ntnic/nthw/core/nthw_hif.c new file +312 -0

312 lines not on this page · raw message

drivers/net/ntnic/nthw/core/nthw_iic.c new file +527 -0

527 lines not on this page · raw message

drivers/net/ntnic/nthw/core/nthw_pcie3.c new file +259 -0

259 lines not on this page · raw message

drivers/net/ntnic/nthw/nthw_drv.h +1 -2
index 0b89a5c5a0..d7cd64bb1d 100644
@@ -6,8 +6,7 @@
 #ifndef __NTHW_DRV_H__
 #define __NTHW_DRV_H__
 
-#include <stddef.h>
-#include "nthw_platform_drv.h"
+#include "nthw_core.h"
 
 typedef enum nt_meta_port_type_e {
 	PORT_TYPE_PHYSICAL,
drivers/net/ntnic/nthw/nthw_rac.c new file +784 -0

784 lines not on this page · raw message

drivers/net/ntnic/nthw/nthw_rac.h new file +153 -0

153 lines not on this page · raw message

Signature · 1 line
2.45.0
#148 lore raw

PATCH v7 11/21 net/ntnic: add FPGA initialization functionality

In reply to Serhii Iliushyk

Enable FPGA initialization and adds ethdev fw_version_get.

---
 doc/guides/nics/features/ntnic.ini            |   1 +
 doc/guides/nics/ntnic.rst                     |   5 +
 drivers/net/ntnic/adapter/nt4ga_adapter.c     |  52 +++-
 drivers/net/ntnic/meson.build                 |   7 +
 .../net/ntnic/nthw/core/include/nthw_core.h   |   4 +
 .../net/ntnic/nthw/core/include/nthw_fpga.h   |  22 ++
 drivers/net/ntnic/nthw/core/nthw_fpga.c       | 222 ++++++++++++++++++
 drivers/net/ntnic/nthw/nthw_drv.h             |   1 +
 drivers/net/ntnic/nthw/nthw_register.h        |   1 +
 drivers/net/ntnic/ntnic_ethdev.c              |  39 ++-
 drivers/net/ntnic/ntnic_mod_reg.h             |   1 +
 11 files changed, 351 insertions(+), 4 deletions(-)
 create mode 100644 drivers/net/ntnic/nthw/core/include/nthw_fpga.h
 create mode 100644 drivers/net/ntnic/nthw/core/nthw_fpga.c
doc/guides/nics/features/ntnic.ini +1 -0
index 9ceb75a03b..03f4d5aac8 100644
@@ -4,5 +4,6 @@
 ; Refer to default.ini for the full list of available PMD features.
 ;
 [Features]
+FW version           = Y
 Linux                = Y
 x86-64               = Y
doc/guides/nics/ntnic.rst +5 -0
index 249d83d511..43caf3151d 100644
@@ -29,6 +29,11 @@ Supported NICs
 All information about NT200A02 can be found by link below:
 https://www.napatech.com/products/nt200a02-smartnic-inline/
 
+Features
+--------
+
+- FW version
+
 Limitations
 ~~~~~~~~~~~
 
drivers/net/ntnic/adapter/nt4ga_adapter.c +49 -3

89 lines not on this page · raw message

drivers/net/ntnic/meson.build +7 -0
index 5dd1beada2..78f31097ab 100644
@@ -16,6 +16,7 @@ includes = [
     include_directories('nthw/core/include'),
     include_directories('nthw'),
     include_directories('nthw/supported'),
+    include_directories('nthw/model'),
 ]
 
 # all sources
@@ -24,7 +25,13 @@ sources = files(
     'nthw/supported/nthw_fpga_9563_055_039_0000.c',
     'nthw/supported/nthw_fpga_instances.c',
     'nthw/supported/nthw_fpga_mod_str_map.c',
+    'nthw/core/nthw_fpga.c',
+    'nthw/core/nthw_hif.c',
+    'nthw/core/nthw_iic.c',
+    'nthw/core/nthw_pcie3.c',
+    'nthw/model/nthw_fpga_model.c',
     'nthw/nthw_platform.c',
+    'nthw/nthw_rac.c',
     'ntlog/ntlog.c',
     'ntutil/nt_util.c',
     'ntnic_mod_reg.c',
drivers/net/ntnic/nthw/core/include/nthw_core.h +4 -0
index c2602e396f..69af113816 100644
@@ -11,6 +11,10 @@
 #include <stdint.h>
 
 #include "nthw_platform_drv.h"
+#include "nthw_fpga_model.h"
+#include "nthw_hif.h"
+#include "nthw_pcie3.h"
+#include "nthw_iic.h"
 
 
 #endif	/* __NTHW_CORE_H__ */
drivers/net/ntnic/nthw/core/include/nthw_fpga.h new file +22 -0
new file mode 100644
index 0000000000..1943f6e225
@@ -0,0 +1,22 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef __NTHW_FPGA_H__
+#define __NTHW_FPGA_H__
+
+#include "nthw_drv.h"
+
+#include "nthw_fpga_model.h"
+
+#include "nthw_rac.h"
+#include "nthw_iic.h"
+
+int nthw_fpga_init(struct fpga_info_s *p_fpga_info);
+int nthw_fpga_shutdown(struct fpga_info_s *p_fpga_info);
+
+int nthw_fpga_get_param_info(struct fpga_info_s *p_fpga_info, nthw_fpga_t *p_fpga);
+
+
+#endif	/* __NTHW_FPGA_H__ */
drivers/net/ntnic/nthw/core/nthw_fpga.c new file +222 -0

222 lines not on this page · raw message

drivers/net/ntnic/nthw/nthw_drv.h +1 -0
index d7cd64bb1d..071618eb6e 100644
@@ -22,6 +22,7 @@ enum fpga_info_profile {
 };
 
 typedef struct mcu_info_s {
+	bool mb_has_mcu;
 	int mn_mcu_type;
 	int mn_mcu_dram_size;
 } mcu_info_t;
drivers/net/ntnic/nthw/nthw_register.h +1 -0
index db006fcf72..ecc661a656 100644
@@ -11,6 +11,7 @@
 #include <stdbool.h>
 #include <inttypes.h>
 
+#include "nthw_fpga_model.h"
 
 #include "fpga_model.h"
 
drivers/net/ntnic/ntnic_ethdev.c +38 -1
index ab4b66f4a3..10b3c803ae 100644
@@ -178,12 +178,33 @@ eth_dev_close(struct rte_eth_dev *eth_dev)
 	return 0;
 }
 
+static int
+eth_fw_version_get(struct rte_eth_dev *eth_dev, char *fw_version, size_t fw_size)
+{
+	struct pmd_internals *internals = (struct pmd_internals *)eth_dev->data->dev_private;
+
+	fpga_info_t *fpga_info = &internals->p_drv->ntdrv.adapter_info.fpga_info;
+	const int length = snprintf(fw_version, fw_size, "%03d-%04d-%02d-%02d",
+			fpga_info->n_fpga_type_id, fpga_info->n_fpga_prod_id,
+			fpga_info->n_fpga_ver_id, fpga_info->n_fpga_rev_id);
+
+	if ((size_t)length < fw_size) {
+		/* We have space for the version string */
+		return 0;
+
+	} else {
+		/* We do not have space for the version string -return the needed space */
+		return length + 1;
+	}
+}
+
 static struct eth_dev_ops nthw_eth_dev_ops = {
 	.dev_configure = eth_dev_configure,
 	.dev_start = eth_dev_start,
 	.dev_stop = eth_dev_stop,
 	.dev_close = eth_dev_close,
 	.dev_infos_get = eth_dev_infos_get,
+	.fw_version_get = eth_fw_version_get,
 };
 
 static int
@@ -200,6 +221,7 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev)
 
 	struct drv_s *p_drv;
 	ntdrv_4ga_t *p_nt_drv;
+	fpga_info_t *fpga_info;
 	hw_info_t *p_hw_info;
 	(void)p_hw_info;
 	uint32_t n_port_mask = -1;	/* All ports enabled by default */
@@ -233,6 +255,7 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev)
 
 	/* context */
 	p_nt_drv = &p_drv->ntdrv;
+	fpga_info = &p_nt_drv->adapter_info.fpga_info;
 	p_hw_info = &p_nt_drv->adapter_info.hw_info;
 
 	p_drv->p_dev = pci_dev;
@@ -243,6 +266,11 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev)
 	p_nt_drv->adapter_info.n_rx_host_buffers = nb_rx_queues;
 	p_nt_drv->adapter_info.n_tx_host_buffers = nb_tx_queues;
 
+	fpga_info->bar0_addr = (void *)pci_dev->mem_resource[0].addr;
+	fpga_info->bar0_size = pci_dev->mem_resource[0].len;
+	fpga_info->numa_node = pci_dev->device.numa_node;
+	fpga_info->pciident = p_nt_drv->pciident;
+	fpga_info->adapter_no = p_drv->adapter_no;
 
 	p_nt_drv->adapter_info.hw_info.pci_class_id = pci_dev->id.class_id;
 	p_nt_drv->adapter_info.hw_info.pci_vendor_id = pci_dev->id.vendor_id;
@@ -279,6 +307,15 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev)
 		/* mp_adapter_id_str is initialized after nt4ga_adapter_init(p_nt_drv) */
 		const char *const p_adapter_id_str = p_nt_drv->adapter_info.mp_adapter_id_str;
 		(void)p_adapter_id_str;
+		NT_LOG(DBG, NTNIC,
+			"%s: %s: AdapterPCI=" PCIIDENT_PRINT_STR " Hw=0x%02X_rev%d PhyPorts=%d\n",
+			(pci_dev->name[0] ? pci_dev->name : "NA"), p_adapter_id_str,
+			PCIIDENT_TO_DOMAIN(p_nt_drv->adapter_info.fpga_info.pciident),
+			PCIIDENT_TO_BUSNR(p_nt_drv->adapter_info.fpga_info.pciident),
+			PCIIDENT_TO_DEVNR(p_nt_drv->adapter_info.fpga_info.pciident),
+			PCIIDENT_TO_FUNCNR(p_nt_drv->adapter_info.fpga_info.pciident),
+			p_hw_info->hw_platform_id, fpga_info->nthw_hw_info.hw_id,
+			fpga_info->n_phy_ports);
 
 	} else {
 		NT_LOG_DBGX(ERR, NTNIC, "%s: error=%d\n",
@@ -286,7 +323,7 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev)
 		return -1;
 	}
 
-	n_phy_ports = 0;
+	n_phy_ports = fpga_info->n_phy_ports;
 
 	for (int n_intf_no = 0; n_intf_no < n_phy_ports; n_intf_no++) {
 		const char *const p_port_id_str = p_nt_drv->adapter_info.mp_port_id_str[n_intf_no];
drivers/net/ntnic/ntnic_mod_reg.h +1 -0
index 48a9f8f7b9..96fc829399 100644
@@ -7,6 +7,7 @@
 #define __NTNIC_MOD_REG_H__
 
 #include <stdint.h>
+#include "nthw_fpga_model.h"
 #include "nthw_platform_drv.h"
 #include "nthw_drv.h"
 #include "nt4ga_adapter.h"
Signature · 1 line
2.45.0
#149 lore raw

PATCH v7 12/21 net/ntnic: add support of the NT200A0X smartNIC

In reply to Serhii Iliushyk

Add ntnic support for NT200A0X NIC

---
 drivers/net/ntnic/adapter/nt4ga_adapter.c     |  6 +++
 drivers/net/ntnic/meson.build                 |  1 +
 .../net/ntnic/nthw/core/include/nthw_fpga.h   |  7 +++
 .../nthw/core/nt200a0x/nthw_fpga_nt200a0x.c   | 54 +++++++++++++++++++
 drivers/net/ntnic/nthw/core/nthw_fpga.c       | 31 +++++++++++
 drivers/net/ntnic/nthw/nthw_platform.c        |  3 ++
 drivers/net/ntnic/nthw/nthw_platform_drv.h    |  2 +
 drivers/net/ntnic/ntnic_ethdev.c              |  3 ++
 8 files changed, 107 insertions(+)
 create mode 100644 drivers/net/ntnic/nthw/core/nt200a0x/nthw_fpga_nt200a0x.c
drivers/net/ntnic/adapter/nt4ga_adapter.c +6 -0
index 3b113b9850..bdad2b1e21 100644
@@ -127,6 +127,12 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info)
 		assert(fpga_info->n_fpga_prod_id > 0);
 
 		switch (fpga_info->n_fpga_prod_id) {
+		/* NT200A01: 2x100G (Xilinx) */
+		case 9563:	/* NT200A02 (Cap) */
+			NT_LOG(ERR, NTNIC, "NT200A02 100G link module uninitialized\n");
+			res = -1;
+			break;
+
 		default:
 			NT_LOG(ERR, NTNIC, "Unsupported FPGA product: %04d\n",
 				fpga_info->n_fpga_prod_id);
drivers/net/ntnic/meson.build +1 -0
index 78f31097ab..e375c63bf8 100644
@@ -25,6 +25,7 @@ sources = files(
     'nthw/supported/nthw_fpga_9563_055_039_0000.c',
     'nthw/supported/nthw_fpga_instances.c',
     'nthw/supported/nthw_fpga_mod_str_map.c',
+    'nthw/core/nt200a0x/nthw_fpga_nt200a0x.c',
     'nthw/core/nthw_fpga.c',
     'nthw/core/nthw_hif.c',
     'nthw/core/nthw_iic.c',
drivers/net/ntnic/nthw/core/include/nthw_fpga.h +7 -0
index 1943f6e225..ba86b4d8d2 100644
@@ -18,5 +18,12 @@ int nthw_fpga_shutdown(struct fpga_info_s *p_fpga_info);
 
 int nthw_fpga_get_param_info(struct fpga_info_s *p_fpga_info, nthw_fpga_t *p_fpga);
 
+struct nt200a0x_ops {
+	int (*nthw_fpga_nt200a0x_init)(struct fpga_info_s *p_fpga_info);
+};
+
+void register_nt200a0x_ops(struct nt200a0x_ops *ops);
+struct nt200a0x_ops *get_nt200a0x_ops(void);
+void nt200a0x_ops_init(void);
 
 #endif	/* __NTHW_FPGA_H__ */
drivers/net/ntnic/nthw/core/nt200a0x/nthw_fpga_nt200a0x.c new file +54 -0

54 lines not on this page · raw message

drivers/net/ntnic/nthw/core/nthw_fpga.c +31 -0
index df238ec4ef..98d29744cb 100644
@@ -152,7 +152,18 @@ int nthw_fpga_init(struct fpga_info_s *p_fpga_info)
 	nthw_rac_rab_flush(p_nthw_rac);
 	p_fpga_info->mp_nthw_rac = p_nthw_rac;
 
+	bool included = true;
+	struct nt200a0x_ops *nt200a0x_ops = get_nt200a0x_ops();
+
 	switch (p_fpga_info->n_nthw_adapter_id) {
+	case NT_HW_ADAPTER_ID_NT200A02:
+		if (nt200a0x_ops != NULL)
+			res = nt200a0x_ops->nthw_fpga_nt200a0x_init(p_fpga_info);
+
+		else
+			included = false;
+
+		break;
 	default:
 		NT_LOG(ERR, NTHW, "%s: Unsupported HW product id: %d\n", p_adapter_id_str,
 			p_fpga_info->n_nthw_adapter_id);
@@ -160,6 +171,12 @@ int nthw_fpga_init(struct fpga_info_s *p_fpga_info)
 		break;
 	}
 
+	if (!included) {
+		NT_LOG(ERR, NTHW, "%s: NOT INCLUDED HW product: %d\n", p_adapter_id_str,
+			p_fpga_info->n_nthw_adapter_id);
+		res = -1;
+	}
+
 	if (res) {
 		NT_LOG(ERR, NTHW, "%s: status: 0x%08X\n", p_adapter_id_str, res);
 		return res;
@@ -220,3 +237,17 @@ int nthw_fpga_shutdown(struct fpga_info_s *p_fpga_info)
 
 	return res;
 }
+
+static struct nt200a0x_ops *nt200a0x_ops;
+
+void register_nt200a0x_ops(struct nt200a0x_ops *ops)
+{
+	nt200a0x_ops = ops;
+}
+
+struct nt200a0x_ops *get_nt200a0x_ops(void)
+{
+	if (nt200a0x_ops == NULL)
+		nt200a0x_ops_init();
+	return nt200a0x_ops;
+}
drivers/net/ntnic/nthw/nthw_platform.c +3 -0
index 181330dd37..33e18e549f 100644
@@ -8,6 +8,9 @@
 nthw_adapter_id_t nthw_platform_get_nthw_adapter_id(const uint16_t n_pci_device_id)
 {
 	switch (n_pci_device_id) {
+	case NT_HW_PCI_DEVICE_ID_NT200A02:
+		return NT_HW_ADAPTER_ID_NT200A02;
+
 	default:
 		return NT_HW_ADAPTER_ID_UNKNOWN;
 	}
drivers/net/ntnic/nthw/nthw_platform_drv.h +2 -0
index ab26d8149a..42eb0b8b05 100644
@@ -9,9 +9,11 @@
 #include <stdint.h>
 
 #define NT_HW_PCI_VENDOR_ID (0x18f4)
+#define NT_HW_PCI_DEVICE_ID_NT200A02 (0x1C5)
 
 enum nthw_adapter_id_e {
 	NT_HW_ADAPTER_ID_UNKNOWN = 0,
+	NT_HW_ADAPTER_ID_NT200A02,
 };
 
 typedef enum nthw_adapter_id_e nthw_adapter_id_t;
drivers/net/ntnic/ntnic_ethdev.c +3 -0
index 10b3c803ae..488c88c782 100644
@@ -26,6 +26,7 @@
 #define EXCEPTION_PATH_HID 0
 
 static const struct rte_pci_id nthw_pci_id_map[] = {
+	{ RTE_PCI_DEVICE(NT_HW_PCI_VENDOR_ID, NT_HW_PCI_DEVICE_ID_NT200A02) },
 	{
 		.vendor_id = 0,
 	},	/* sentinel */
@@ -486,9 +487,11 @@ nthw_pci_remove(struct rte_pci_device *pci_dev)
 
 static struct rte_pci_driver rte_nthw_pmd = {
 	.id_table = nthw_pci_id_map,
+	.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
 	.probe = nthw_pci_probe,
 	.remove = nthw_pci_remove,
 };
 
 RTE_PMD_REGISTER_PCI(net_ntnic, rte_nthw_pmd);
+RTE_PMD_REGISTER_PCI_TABLE(net_ntnic, nthw_pci_id_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_ntnic, "* vfio-pci");
Signature · 1 line
2.45.0
#150 lore raw

PATCH v7 13/21 net/ntnic: add startup and reset sequence for NT200A0X

In reply to Serhii Iliushyk

Adds reset (RST) module for FW 9563.
Also adds SDRAM Controller (SDC) module,
as it is part of the startup and reset sequence.

---
 .../include/ntnic_nthw_fpga_rst_nt200a0x.h    |  81 +++
 drivers/net/ntnic/meson.build                 |   3 +
 .../net/ntnic/nthw/core/include/nthw_core.h   |   2 +
 .../net/ntnic/nthw/core/include/nthw_fpga.h   |   6 +
 .../net/ntnic/nthw/core/include/nthw_sdc.h    |  42 ++
 .../nthw/core/nt200a0x/nthw_fpga_nt200a0x.c   |  24 +-
 .../core/nt200a0x/reset/nthw_fpga_rst9563.c   | 216 +++++++
 .../nt200a0x/reset/nthw_fpga_rst_nt200a0x.c   | 570 ++++++++++++++++++
 drivers/net/ntnic/nthw/core/nthw_fpga.c       |  82 +++
 drivers/net/ntnic/nthw/core/nthw_sdc.c        | 176 ++++++
 drivers/net/ntnic/ntnic_mod_reg.c             |  28 +
 drivers/net/ntnic/ntnic_mod_reg.h             |  20 +
 12 files changed, 1249 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/ntnic/include/ntnic_nthw_fpga_rst_nt200a0x.h
 create mode 100644 drivers/net/ntnic/nthw/core/include/nthw_sdc.h
 create mode 100644 drivers/net/ntnic/nthw/core/nt200a0x/reset/nthw_fpga_rst9563.c
 create mode 100644 drivers/net/ntnic/nthw/core/nt200a0x/reset/nthw_fpga_rst_nt200a0x.c
 create mode 100644 drivers/net/ntnic/nthw/core/nthw_sdc.c
drivers/net/ntnic/include/ntnic_nthw_fpga_rst_nt200a0x.h new file +81 -0
new file mode 100644
index 0000000000..6ceec93bac
@@ -0,0 +1,81 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2024 Napatech A/S
+ */
+
+#ifndef __NTNIC_NTHW_FPGA_RST_NT200A0X_H__
+#define __NTNIC_NTHW_FPGA_RST_NT200A0X_H__
+
+#include "nthw_drv.h"
+#include "nthw_fpga_model.h"
+
+struct nthw_fpga_rst_nt200a0x {
+	int mn_fpga_product_id;
+	int mn_fpga_version;
+	int mn_fpga_revision;
+
+	int mn_hw_id;
+
+	int mn_si_labs_clock_synth_model;
+
+	nthw_field_t *mp_fld_rst_sys;
+	nthw_field_t *mp_fld_rst_sys_mmcm;
+	nthw_field_t *mp_fld_rst_core_mmcm;
+	nthw_field_t *mp_fld_rst_rpp;
+	nthw_field_t *mp_fld_rst_ddr4;
+	nthw_field_t *mp_fld_rst_sdc;
+	nthw_field_t *mp_fld_rst_phy;
+	nthw_field_t *mp_fld_rst_serdes_rx;
+	nthw_field_t *mp_fld_rst_serdes_tx;
+	nthw_field_t *mp_fld_rst_serdes_rx_datapath;
+	nthw_field_t *mp_fld_rst_pcs_rx;
+	nthw_field_t *mp_fld_rst_mac_rx;
+	nthw_field_t *mp_fld_rst_mac_tx;
+	nthw_field_t *mp_fld_rst_ptp;
+	nthw_field_t *mp_fld_rst_ts;
+	nthw_field_t *mp_fld_rst_ptp_mmcm;
+	nthw_field_t *mp_fld_rst_ts_mmcm;
+	nthw_field_t *mp_fld_rst_periph;
+	nthw_field_t *mp_fld_rst_tsm_ref_mmcm;
+	nthw_field_t *mp_fld_rst_tmc;
+
+	/* CTRL register field pointers */
+	nthw_field_t *mp_fld_ctrl_ts_clk_sel_override;
+	nthw_field_t *mp_fld_ctrl_ts_clk_sel;
+	nthw_field_t *mp_fld_ctrl_ts_clk_sel_ref;
+	nthw_field_t *mp_fld_ctrl_ptp_mmcm_clk_sel;
+
+	/* STAT register field pointers */
+	nthw_field_t *mp_fld_stat_ddr4_mmcm_locked;
+	nthw_field_t *mp_fld_stat_sys_mmcm_locked;
+	nthw_field_t *mp_fld_stat_core_mmcm_locked;
+	nthw_field_t *mp_fld_stat_ddr4_pll_locked;
+	nthw_field_t *mp_fld_stat_ptp_mmcm_locked;
+	nthw_field_t *mp_fld_stat_ts_mmcm_locked;
+	nthw_field_t *mp_fld_stat_tsm_ref_mmcm_locked;
+
+	/* STICKY register field pointers */
+	nthw_field_t *mp_fld_sticky_ptp_mmcm_unlocked;
+	nthw_field_t *mp_fld_sticky_ts_mmcm_unlocked;
+	nthw_field_t *mp_fld_sticky_ddr4_mmcm_unlocked;
+	nthw_field_t *mp_fld_sticky_ddr4_pll_unlocked;
+	nthw_field_t *mp_fld_sticky_core_mmcm_unlocked;
+	nthw_field_t *mp_fld_sticky_pci_sys_mmcm_unlocked;
+	nthw_field_t *mp_fld_sticky_tsm_ref_mmcm_unlocked;
+
+	/* POWER register field pointers */
+	nthw_field_t *mp_fld_power_pu_phy;
+	nthw_field_t *mp_fld_power_pu_nseb;
+
+	void (*reset_serdes_rx)(struct nthw_fpga_rst_nt200a0x *p, uint32_t intf_no, uint32_t rst);
+	void (*pcs_rx_rst)(struct nthw_fpga_rst_nt200a0x *p, uint32_t intf_no, uint32_t rst);
+	void (*get_serdes_rx_rst)(struct nthw_fpga_rst_nt200a0x *p, uint32_t intf_no,
+		uint32_t *p_set);
+	void (*get_pcs_rx_rst)(struct nthw_fpga_rst_nt200a0x *p, uint32_t intf_no,
+		uint32_t *p_set);
+	bool (*is_rst_serdes_rx_datapath_implemented)(struct nthw_fpga_rst_nt200a0x *p);
+};
+
+typedef struct nthw_fpga_rst_nt200a0x nthw_fpga_rst_nt200a0x_t;
+
+#endif	/* __NTHW_FPGA_RST_NT200A0X_H__ */
drivers/net/ntnic/meson.build +3 -0
index e375c63bf8..d45a17526c 100644
@@ -26,10 +26,13 @@ sources = files(
     'nthw/supported/nthw_fpga_instances.c',
     'nthw/supported/nthw_fpga_mod_str_map.c',
     'nthw/core/nt200a0x/nthw_fpga_nt200a0x.c',
+    'nthw/core/nt200a0x/reset/nthw_fpga_rst9563.c',
+    'nthw/core/nt200a0x/reset/nthw_fpga_rst_nt200a0x.c',
     'nthw/core/nthw_fpga.c',
     'nthw/core/nthw_hif.c',
     'nthw/core/nthw_iic.c',
     'nthw/core/nthw_pcie3.c',
+    'nthw/core/nthw_sdc.c',
     'nthw/model/nthw_fpga_model.c',
     'nthw/nthw_platform.c',
     'nthw/nthw_rac.c',
drivers/net/ntnic/nthw/core/include/nthw_core.h +2 -0
index 69af113816..8bdf7ee01d 100644
@@ -16,5 +16,7 @@
 #include "nthw_pcie3.h"
 #include "nthw_iic.h"
 
+#include "nthw_sdc.h"
+
 
 #endif	/* __NTHW_CORE_H__ */
drivers/net/ntnic/nthw/core/include/nthw_fpga.h +6 -0
index ba86b4d8d2..1df1480109 100644
@@ -18,6 +18,12 @@ int nthw_fpga_shutdown(struct fpga_info_s *p_fpga_info);
 
 int nthw_fpga_get_param_info(struct fpga_info_s *p_fpga_info, nthw_fpga_t *p_fpga);
 
+int nthw_fpga_iic_scan(nthw_fpga_t *p_fpga, const int n_instance_no_begin,
+	const int n_instance_no_end);
+
+int nthw_fpga_silabs_detect(nthw_fpga_t *p_fpga, const int n_instance_no, const int n_dev_addr,
+	const int n_page_reg_addr);
+
 struct nt200a0x_ops {
 	int (*nthw_fpga_nt200a0x_init)(struct fpga_info_s *p_fpga_info);
 };
drivers/net/ntnic/nthw/core/include/nthw_sdc.h new file +42 -0

42 lines not on this page · raw message

drivers/net/ntnic/nthw/core/nt200a0x/nthw_fpga_nt200a0x.c +23 -1
index 7db6a03d88..3009e30670 100644
@@ -13,14 +13,36 @@ static int nthw_fpga_nt200a0x_init(struct fpga_info_s *p_fpga_info)
 	assert(p_fpga_info);
 
 	const char *const p_adapter_id_str = p_fpga_info->mp_adapter_id_str;
+	struct nthw_fpga_rst_nt200a0x rst;
 	int res = -1;
+	const struct rst_nt200a0x_ops *rst_nt200a0x_ops = get_rst_nt200a0x_ops();
+
+	if (rst_nt200a0x_ops == NULL) {
+		NT_LOG(ERR, NTHW, "RST NT200A0X NOT INCLUDED\n");
+		return -1;
+	}
+
+	/* reset common */
+	res = rst_nt200a0x_ops->nthw_fpga_rst_nt200a0x_init(p_fpga_info, &rst);
+
+	if (res) {
+		NT_LOG_DBGX(ERR, NTHW, "%s: FPGA=%04d res=%d\n", p_adapter_id_str,
+					p_fpga_info->n_fpga_prod_id, res);
+		return res;
+	}
 
 	bool included = true;
+	struct rst9563_ops *rst9563_ops = get_rst9563_ops();
 
 	/* reset specific */
 	switch (p_fpga_info->n_fpga_prod_id) {
 	case 9563:
-		included = false;
+		if (rst9563_ops != NULL)
+			res = rst9563_ops->nthw_fpga_rst9563_init(p_fpga_info, &rst);
+
+		else
+			included = false;
+
 		break;
 
 	default:
drivers/net/ntnic/nthw/core/nt200a0x/reset/nthw_fpga_rst9563.c new file +216 -0

216 lines not on this page · raw message

drivers/net/ntnic/nthw/core/nt200a0x/reset/nthw_fpga_rst_nt200a0x.c new file +570 -0

570 lines not on this page · raw message

drivers/net/ntnic/nthw/core/nthw_fpga.c +82 -0

88 lines not on this page · raw message

drivers/net/ntnic/nthw/core/nthw_sdc.c new file +176 -0

176 lines not on this page · raw message

drivers/net/ntnic/ntnic_mod_reg.c +28 -0
index 006221bbe3..bd0a966be2 100644
@@ -18,3 +18,31 @@ const struct adapter_ops *get_adapter_ops(void)
 		adapter_init();
 	return adapter_ops;
 }
+
+static struct rst_nt200a0x_ops *rst_nt200a0x_ops;
+
+void register_rst_nt200a0x_ops(struct rst_nt200a0x_ops *ops)
+{
+	rst_nt200a0x_ops = ops;
+}
+
+struct rst_nt200a0x_ops *get_rst_nt200a0x_ops(void)
+{
+	if (rst_nt200a0x_ops == NULL)
+		rst_nt200a0x_ops_init();
+	return rst_nt200a0x_ops;
+}
+
+static struct rst9563_ops *rst9563_ops;
+
+void register_rst9563_ops(struct rst9563_ops *ops)
+{
+	rst9563_ops = ops;
+}
+
+struct rst9563_ops *get_rst9563_ops(void)
+{
+	if (rst9563_ops == NULL)
+		rst9563_ops_init();
+	return rst9563_ops;
+}
drivers/net/ntnic/ntnic_mod_reg.h +20 -0
index 96fc829399..df8a8b9aca 100644
@@ -11,6 +11,7 @@
 #include "nthw_platform_drv.h"
 #include "nthw_drv.h"
 #include "nt4ga_adapter.h"
+#include "ntnic_nthw_fpga_rst_nt200a0x.h"
 #include "ntos_drv.h"
 
 struct adapter_ops {
@@ -24,5 +25,24 @@ void register_adapter_ops(const struct adapter_ops *ops);
 const struct adapter_ops *get_adapter_ops(void);
 void adapter_init(void);
 
+struct rst_nt200a0x_ops {
+	int (*nthw_fpga_rst_nt200a0x_init)(struct fpga_info_s *p_fpga_info,
+		struct nthw_fpga_rst_nt200a0x *p_rst);
+	int (*nthw_fpga_rst_nt200a0x_reset)(nthw_fpga_t *p_fpga,
+		const struct nthw_fpga_rst_nt200a0x *p);
+};
+
+void register_rst_nt200a0x_ops(struct rst_nt200a0x_ops *ops);
+struct rst_nt200a0x_ops *get_rst_nt200a0x_ops(void);
+void rst_nt200a0x_ops_init(void);
+
+struct rst9563_ops {
+	int (*nthw_fpga_rst9563_init)(struct fpga_info_s *p_fpga_info,
+		struct nthw_fpga_rst_nt200a0x *const p);
+};
+
+void register_rst9563_ops(struct rst9563_ops *ops);
+struct rst9563_ops *get_rst9563_ops(void);
+void rst9563_ops_init(void);
 
 #endif	/* __NTNIC_MOD_REG_H__ */
Signature · 1 line
2.45.0
#151 lore raw

PATCH v7 14/21 net/ntnic: add clock profile for the NT200A0X smartNIC

In reply to Serhii Iliushyk

Because the ntnic hardware supports multiple different FPGAs with different pipelines and port speeds,
the clock profile is not hardcoded into the product,
and need to be initialized from software.

The clock profile itself is an array of integers
that was generated by Silicon Labs ClockBuilder.

---
 .../ntnic/include/clock_profiles_structs.h    |  33 +
 .../include/ntnic_nthw_fpga_rst_nt200a0x.h    |   1 +
 drivers/net/ntnic/meson.build                 |   2 +
 .../net/ntnic/nthw/core/include/nthw_core.h   |   2 +
 .../net/ntnic/nthw/core/include/nthw_fpga.h   |   4 +
 .../net/ntnic/nthw/core/include/nthw_si5340.h |  33 +
 .../NT200A02_U23_Si5340_adr0_v5-Registers.h   | 753 ++++++++++++++++++
 .../clock_profiles/nthw_fpga_clk9563.c        |  47 ++
 .../core/nt200a0x/reset/nthw_fpga_rst9563.c   |  35 +
 .../nt200a0x/reset/nthw_fpga_rst_nt200a0x.c   |   3 +
 drivers/net/ntnic/nthw/core/nthw_fpga.c       |  23 +
 drivers/net/ntnic/nthw/core/nthw_si5340.c     | 198 +++++
 drivers/net/ntnic/ntnic_mod_reg.c             |  14 +
 drivers/net/ntnic/ntnic_mod_reg.h             |   9 +
 14 files changed, 1157 insertions(+)
 create mode 100644 drivers/net/ntnic/include/clock_profiles_structs.h
 create mode 100644 drivers/net/ntnic/nthw/core/include/nthw_si5340.h
 create mode 100644 drivers/net/ntnic/nthw/core/nt200a0x/clock_profiles/NT200A02_U23_Si5340_adr0_v5-Registers.h
 create mode 100644 drivers/net/ntnic/nthw/core/nt200a0x/clock_profiles/nthw_fpga_clk9563.c
 create mode 100644 drivers/net/ntnic/nthw/core/nthw_si5340.c
drivers/net/ntnic/include/clock_profiles_structs.h new file +33 -0
new file mode 100644
index 0000000000..28a582a5e7
@@ -0,0 +1,33 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef _NT_CLOCK_PROFILES_STRUCTS_H_
+#define _NT_CLOCK_PROFILES_STRUCTS_H_
+
+#include <stdint.h>
+
+#define clk_profile_size_error_msg "Size test failed"
+
+struct clk_profile_data_fmt1_s {
+	uint16_t reg_addr;
+	uint8_t reg_val;
+};
+
+struct clk_profile_data_fmt2_s {
+	unsigned int reg_addr;
+	unsigned char reg_val;
+};
+
+typedef struct clk_profile_data_fmt1_s clk_profile_data_fmt1_t;
+typedef struct clk_profile_data_fmt2_s clk_profile_data_fmt2_t;
+
+enum clk_profile_data_fmt_e {
+	clk_profile_data_fmt_1,
+	clk_profile_data_fmt_2,
+};
+
+typedef enum clk_profile_data_fmt_e clk_profile_data_fmt_t;
+
+#endif	/* _NT_CLOCK_PROFILES_STRUCTS_H_ */
drivers/net/ntnic/include/ntnic_nthw_fpga_rst_nt200a0x.h +1 -0
index 6ceec93bac..8b7ebdf1fd 100644
@@ -17,6 +17,7 @@ struct nthw_fpga_rst_nt200a0x {
 	int mn_hw_id;
 
 	int mn_si_labs_clock_synth_model;
+	uint8_t mn_si_labs_clock_synth_i2c_addr;
 
 	nthw_field_t *mp_fld_rst_sys;
 	nthw_field_t *mp_fld_rst_sys_mmcm;
drivers/net/ntnic/meson.build +2 -0
index d45a17526c..987768cb92 100644
@@ -25,6 +25,7 @@ sources = files(
     'nthw/supported/nthw_fpga_9563_055_039_0000.c',
     'nthw/supported/nthw_fpga_instances.c',
     'nthw/supported/nthw_fpga_mod_str_map.c',
+    'nthw/core/nt200a0x/clock_profiles/nthw_fpga_clk9563.c',
     'nthw/core/nt200a0x/nthw_fpga_nt200a0x.c',
     'nthw/core/nt200a0x/reset/nthw_fpga_rst9563.c',
     'nthw/core/nt200a0x/reset/nthw_fpga_rst_nt200a0x.c',
@@ -33,6 +34,7 @@ sources = files(
     'nthw/core/nthw_iic.c',
     'nthw/core/nthw_pcie3.c',
     'nthw/core/nthw_sdc.c',
+    'nthw/core/nthw_si5340.c',
     'nthw/model/nthw_fpga_model.c',
     'nthw/nthw_platform.c',
     'nthw/nthw_rac.c',
drivers/net/ntnic/nthw/core/include/nthw_core.h +2 -0
index 8bdf7ee01d..5648bd8983 100644
@@ -18,5 +18,7 @@
 
 #include "nthw_sdc.h"
 
+#include "nthw_si5340.h"
+
 
 #endif	/* __NTHW_CORE_H__ */
drivers/net/ntnic/nthw/core/include/nthw_fpga.h +4 -0
index 1df1480109..cee1d23090 100644
@@ -24,6 +24,10 @@ int nthw_fpga_iic_scan(nthw_fpga_t *p_fpga, const int n_instance_no_begin,
 int nthw_fpga_silabs_detect(nthw_fpga_t *p_fpga, const int n_instance_no, const int n_dev_addr,
 	const int n_page_reg_addr);
 
+int nthw_fpga_si5340_clock_synth_init_fmt2(nthw_fpga_t *p_fpga, const uint8_t n_iic_addr,
+	const clk_profile_data_fmt2_t *p_clk_profile,
+	const int n_clk_profile_rec_cnt);
+
 struct nt200a0x_ops {
 	int (*nthw_fpga_nt200a0x_init)(struct fpga_info_s *p_fpga_info);
 };
drivers/net/ntnic/nthw/core/include/nthw_si5340.h new file +33 -0
new file mode 100644
index 0000000000..f56883d99a
@@ -0,0 +1,33 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef __NTHW_SI5340_H__
+#define __NTHW_SI5340_H__
+
+#include "clock_profiles_structs.h"
+
+#define SI5340_SUCCESS (0)
+#define SI5340_FAILED (999)
+#define SI5340_TIMEOUT (666)
+
+struct nthw_si5340 {
+	uint8_t mn_iic_addr;
+	nthw_iic_t *mp_nthw_iic;
+	int mn_clk_cfg;
+	uint8_t m_si5340_page;
+};
+
+typedef struct nthw_si5340 nthw_si5340_t;
+
+nthw_si5340_t *nthw_si5340_new(void);
+int nthw_si5340_init(nthw_si5340_t *p, nthw_iic_t *p_nthw_iic, uint8_t n_iic_addr);
+void nthw_si5340_delete(nthw_si5340_t *p);
+
+int nthw_si5340_config(nthw_si5340_t *p, const void *p_data, int data_cnt,
+	clk_profile_data_fmt_t data_format);
+int nthw_si5340_config_fmt2(nthw_si5340_t *p, const clk_profile_data_fmt2_t *p_data,
+	const int data_cnt);
+
+#endif	/* __NTHW_SI5338_H__ */
drivers/net/ntnic/nthw/core/nt200a0x/clock_profiles/NT200A02_U23_Si5340_adr0_v5-Registers.h new file +753 -0

753 lines not on this page · raw message

drivers/net/ntnic/nthw/core/nt200a0x/clock_profiles/nthw_fpga_clk9563.c new file +47 -0

47 lines not on this page · raw message

drivers/net/ntnic/nthw/core/nt200a0x/reset/nthw_fpga_rst9563.c +35 -0
index a3b6511b06..380f877096 100644
@@ -164,6 +164,34 @@ static int nthw_fpga_rst9563_periph_reset(nthw_fpga_t *p_fpga)
 	return 0;
 }
 
+static int nthw_fpga_rst9563_clock_synth_init(nthw_fpga_t *p_fpga,
+	const int n_si_labs_clock_synth_model,
+	const uint8_t n_si_labs_clock_synth_i2c_addr)
+{
+	const char *const p_adapter_id_str = p_fpga->p_fpga_info->mp_adapter_id_str;
+	const int n_fpga_product_id = p_fpga->mn_product_id;
+	int res;
+	const struct clk9563_ops *clk9563_ops = get_clk9563_ops();
+
+	if (clk9563_ops == NULL) {
+		NT_LOG(INF, NTNIC, "CLK9563 module not included\n");
+		return -1;
+	}
+
+	if (n_si_labs_clock_synth_model == 5340) {
+		res = nthw_fpga_si5340_clock_synth_init_fmt2(p_fpga, n_si_labs_clock_synth_i2c_addr,
+				clk9563_ops->get_p_data_9563_si5340_nt200a02_u23_v5(),
+				*clk9563_ops->get_n_data_9563_si5340_nt200a02_u23_v5());
+
+	} else {
+		NT_LOG(ERR, NTHW, "%s: Fpga %d: Unsupported clock synth model (%d)\n",
+			p_adapter_id_str, n_fpga_product_id, n_si_labs_clock_synth_model);
+		res = -1;
+	}
+
+	return res;
+}
+
 static int nthw_fpga_rst9563_init(struct fpga_info_s *p_fpga_info,
 	struct nthw_fpga_rst_nt200a0x *p_rst)
 {
@@ -173,9 +201,13 @@ static int nthw_fpga_rst9563_init(struct fpga_info_s *p_fpga_info,
 	const char *const p_adapter_id_str = p_fpga_info->mp_adapter_id_str;
 	(void)p_adapter_id_str;
 	int res = -1;
+	int n_si_labs_clock_synth_model;
+	uint8_t n_si_labs_clock_synth_i2c_addr;
 	nthw_fpga_t *p_fpga = NULL;
 
 	p_fpga = p_fpga_info->mp_fpga;
+	n_si_labs_clock_synth_model = p_rst->mn_si_labs_clock_synth_model;
+	n_si_labs_clock_synth_i2c_addr = p_rst->mn_si_labs_clock_synth_i2c_addr;
 
 	res = nthw_fpga_rst9563_periph_reset(p_fpga);
 
@@ -184,6 +216,9 @@ static int nthw_fpga_rst9563_init(struct fpga_info_s *p_fpga_info,
 		return res;
 	}
 
+	res = nthw_fpga_rst9563_clock_synth_init(p_fpga, n_si_labs_clock_synth_model,
+			n_si_labs_clock_synth_i2c_addr);
+
 	if (res) {
 		NT_LOG_DBGX(DEBUG, NTHW, "%s: ERROR: res=%d\n", p_adapter_id_str, res);
 		return res;
drivers/net/ntnic/nthw/core/nt200a0x/reset/nthw_fpga_rst_nt200a0x.c +3 -0
index 84f13e8371..ea0276a90c 100644
@@ -552,7 +552,10 @@ static int nthw_fpga_rst_nt200a0x_init(struct fpga_info_s *p_fpga_info,
 	}
 
 	p_rst->mn_si_labs_clock_synth_model = n_si_labs_clock_synth_model;
+	p_rst->mn_si_labs_clock_synth_i2c_addr = n_si_labs_clock_synth_i2c_addr;
 	p_rst->mn_hw_id = p_fpga_info->nthw_hw_info.hw_id;
+	NT_LOG_DBGX(DEBUG, NTHW, "%s: Si%04d @ 0x%02x\n", p_adapter_id_str,
+		p_rst->mn_si_labs_clock_synth_model, p_rst->mn_si_labs_clock_synth_i2c_addr);
 
 	return res;
 }
drivers/net/ntnic/nthw/core/nthw_fpga.c +23 -0
index 1650bb8a5c..38169176a5 100644
@@ -147,6 +147,29 @@ int nthw_fpga_silabs_detect(nthw_fpga_t *p_fpga, const int n_instance_no, const
 	return res;
 }
 
+/*
+ * NT200A02, NT200A01-HWbuild2
+ */
+int nthw_fpga_si5340_clock_synth_init_fmt2(nthw_fpga_t *p_fpga, const uint8_t n_iic_addr,
+	const clk_profile_data_fmt2_t *p_clk_profile,
+	const int n_clk_profile_rec_cnt)
+{
+	int res;
+	nthw_iic_t *p_nthw_iic = nthw_iic_new();
+	nthw_si5340_t *p_nthw_si5340 = nthw_si5340_new();
+
+	assert(p_nthw_iic);
+	assert(p_nthw_si5340);
+	nthw_iic_init(p_nthw_iic, p_fpga, 0, 8);/* I2C cycle time 125Mhz ~ 8ns */
+
+	nthw_si5340_init(p_nthw_si5340, p_nthw_iic, n_iic_addr);/* si5340_u23_i2c_addr_7bit */
+	res = nthw_si5340_config_fmt2(p_nthw_si5340, p_clk_profile, n_clk_profile_rec_cnt);
+	nthw_si5340_delete(p_nthw_si5340);
+	p_nthw_si5340 = NULL;
+
+	return res;
+}
+
 int nthw_fpga_init(struct fpga_info_s *p_fpga_info)
 {
 	const char *const p_adapter_id_str = p_fpga_info->mp_adapter_id_str;
drivers/net/ntnic/nthw/core/nthw_si5340.c new file +198 -0

198 lines not on this page · raw message

drivers/net/ntnic/ntnic_mod_reg.c +14 -0
index bd0a966be2..3f03299a83 100644
@@ -19,6 +19,20 @@ const struct adapter_ops *get_adapter_ops(void)
 	return adapter_ops;
 }
 
+static struct clk9563_ops *clk9563_ops;
+
+void register_clk9563_ops(struct clk9563_ops *ops)
+{
+	clk9563_ops = ops;
+}
+
+struct clk9563_ops *get_clk9563_ops(void)
+{
+	if (clk9563_ops == NULL)
+		clk9563_ops_init();
+	return clk9563_ops;
+}
+
 static struct rst_nt200a0x_ops *rst_nt200a0x_ops;
 
 void register_rst_nt200a0x_ops(struct rst_nt200a0x_ops *ops)
drivers/net/ntnic/ntnic_mod_reg.h +9 -0
index df8a8b9aca..45f5632981 100644
@@ -25,6 +25,15 @@ void register_adapter_ops(const struct adapter_ops *ops);
 const struct adapter_ops *get_adapter_ops(void);
 void adapter_init(void);
 
+struct clk9563_ops {
+	const int *(*get_n_data_9563_si5340_nt200a02_u23_v5)(void);
+	const clk_profile_data_fmt2_t *(*get_p_data_9563_si5340_nt200a02_u23_v5)(void);
+};
+
+void register_clk9563_ops(struct clk9563_ops *ops);
+struct clk9563_ops *get_clk9563_ops(void);
+void clk9563_ops_init(void);
+
 struct rst_nt200a0x_ops {
 	int (*nthw_fpga_rst_nt200a0x_init)(struct fpga_info_s *p_fpga_info,
 		struct nthw_fpga_rst_nt200a0x *p_rst);
Signature · 1 line
2.45.0
#152 lore raw

PATCH v7 15/21 net/ntnic: add link management skeleton

In reply to Serhii Iliushyk

Add functionality to read and control the link-state of the ntnic. Note that must functions are not implemented yet.

Adds the following eth_dev_ops:
- dev_set_link_up
- dev_set_link_down
- link_update
- mac_addr_add
- mac_addr_set
- set_mc_addr_list
- promiscuous_enable

---
 doc/guides/nics/features/ntnic.ini        |   3 +
 doc/guides/nics/ntnic.rst                 |   5 +
 drivers/net/ntnic/adapter/nt4ga_adapter.c |   6 +
 drivers/net/ntnic/include/nt4ga_adapter.h |   5 +-
 drivers/net/ntnic/include/nt4ga_link.h    |  84 +++++++
 drivers/net/ntnic/include/ntos_drv.h      |  15 ++
 drivers/net/ntnic/link_mgmt/nt4ga_link.c  | 176 ++++++++++++++
 drivers/net/ntnic/meson.build             |   1 +
 drivers/net/ntnic/ntnic_ethdev.c          | 283 +++++++++++++++++++++-
 drivers/net/ntnic/ntnic_mod_reg.c         |  14 ++
 drivers/net/ntnic/ntnic_mod_reg.h         |  50 +++-
 drivers/net/ntnic/ntutil/nt_util.c        | 131 ++++++++++
 drivers/net/ntnic/ntutil/nt_util.h        |  11 +
 13 files changed, 780 insertions(+), 4 deletions(-)
 create mode 100644 drivers/net/ntnic/include/nt4ga_link.h
 create mode 100644 drivers/net/ntnic/link_mgmt/nt4ga_link.c
doc/guides/nics/features/ntnic.ini +3 -0
index 03f4d5aac8..0a74817fcf 100644
@@ -5,5 +5,8 @@
 ;
 [Features]
 FW version           = Y
+Speed capabilities   = Y
+Unicast MAC filter   = Y
+Multicast MAC filter = Y
 Linux                = Y
 x86-64               = Y
doc/guides/nics/ntnic.rst +5 -0
index 43caf3151d..25c74730fe 100644
@@ -33,6 +33,11 @@ Features
 --------
 
 - FW version
+- Speed capabilities
+- Link status (Link update only)
+- Unicast MAC filter
+- Multicast MAC filter
+- Promiscuous mode (Enable only. The device always run promiscuous mode)
 
 Limitations
 ~~~~~~~~~~~
drivers/net/ntnic/adapter/nt4ga_adapter.c +6 -0
index bdad2b1e21..e29fda7fbb 100644
@@ -124,8 +124,14 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info)
 	assert(n_phy_ports >= 1);
 
 	{
+		int i;
 		assert(fpga_info->n_fpga_prod_id > 0);
 
+		for (i = 0; i < NUM_ADAPTER_PORTS_MAX; i++) {
+			/* Disable all ports. Must be enabled later */
+			p_adapter_info->nt4ga_link.port_action[i].port_disable = true;
+		}
+
 		switch (fpga_info->n_fpga_prod_id) {
 		/* NT200A01: 2x100G (Xilinx) */
 		case 9563:	/* NT200A02 (Cap) */
drivers/net/ntnic/include/nt4ga_adapter.h +4 -1
index 2c72583caf..ed14936b38 100644
@@ -6,7 +6,8 @@
 #ifndef _NT4GA_ADAPTER_H_
 #define _NT4GA_ADAPTER_H_
 
-#include "ntos_drv.h"
+#include "nt4ga_link.h"
+
 typedef struct hw_info_s {
 	/* pciids */
 	uint16_t pci_vendor_id;
@@ -23,6 +24,8 @@ typedef struct hw_info_s {
 } hw_info_t;
 
 typedef struct adapter_info_s {
+	struct nt4ga_link_s nt4ga_link;
+
 	struct hw_info_s hw_info;
 	struct fpga_info_s fpga_info;
 
drivers/net/ntnic/include/nt4ga_link.h new file +84 -0

84 lines not on this page · raw message

drivers/net/ntnic/include/ntos_drv.h +15 -0
index e3d8ffb91c..43fac61257 100644
@@ -25,9 +25,24 @@ struct pmd_internals {
 	const struct rte_pci_device *pci_dev;
 	char name[20];
 	int n_intf_no;
+	int lpbk_mode;
+	uint8_t ts_multiplier;
+	uint16_t min_tx_pkt_size;
+	uint16_t max_tx_pkt_size;
+	unsigned int nb_rx_queues;
+	unsigned int nb_tx_queues;
 	uint32_t port;
 	uint32_t port_id;
+	/* Offset of the VF from the PF */
+	uint8_t vf_offset;
+	nt_meta_port_type_t type;
+	/* if a virtual port type - the vhid */
+	int vhid;
 	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];
+	/* Multicast ethernet (MAC) addresses. */
+	struct rte_ether_addr mc_addrs[NUM_MULTICAST_ADDRS_PER_PORT];
 	struct pmd_internals *next;
 };
 
drivers/net/ntnic/link_mgmt/nt4ga_link.c new file +176 -0

176 lines not on this page · raw message

drivers/net/ntnic/meson.build +1 -0
index 987768cb92..001c75963e 100644
@@ -22,6 +22,7 @@ includes = [
 # all sources
 sources = files(
     'adapter/nt4ga_adapter.c',
+    'link_mgmt/nt4ga_link.c',
     'nthw/supported/nthw_fpga_9563_055_039_0000.c',
     'nthw/supported/nthw_fpga_instances.c',
     'nthw/supported/nthw_fpga_mod_str_map.c',
drivers/net/ntnic/ntnic_ethdev.c +281 -2

378 lines not on this page · raw message

drivers/net/ntnic/ntnic_mod_reg.c +14 -0
index 3f03299a83..b79929c696 100644
@@ -5,6 +5,20 @@
 
 #include "ntnic_mod_reg.h"
 
+static const struct port_ops *port_ops;
+
+void register_port_ops(const struct port_ops *ops)
+{
+	port_ops = ops;
+}
+
+const struct port_ops *get_port_ops(void)
+{
+	if (port_ops == NULL)
+		port_init();
+	return port_ops;
+}
+
 static const struct adapter_ops *adapter_ops;
 
 void register_adapter_ops(const struct adapter_ops *ops)
drivers/net/ntnic/ntnic_mod_reg.h +49 -1

56 lines not on this page · raw message

drivers/net/ntnic/ntutil/nt_util.c +131 -0

134 lines not on this page · raw message

drivers/net/ntnic/ntutil/nt_util.h +11 -0
index 6dfd7428e1..ea91181a06 100644
@@ -7,6 +7,7 @@
 #define NTOSS_SYSTEM_NT_UTIL_H
 
 #include <stdint.h>
+#include "nt4ga_link.h"
 
 #ifndef ARRAY_SIZE
 #define ARRAY_SIZE(arr) RTE_DIM(arr)
@@ -30,6 +31,11 @@ struct nt_dma_s {
 	uint64_t size;
 };
 
+struct port_link_speed {
+	int port_id;
+	int link_speed;
+};
+
 struct nt_dma_s *nt_dma_alloc(uint64_t size, uint64_t align, int numa);
 void nt_dma_free(struct nt_dma_s *vfio_addr);
 
@@ -40,4 +46,9 @@ struct nt_util_vfio_impl {
 
 void nt_util_vfio_init(struct nt_util_vfio_impl *impl);
 
+int nt_link_speed_to_eth_speed_num(enum nt_link_speed_e nt_link_speed);
+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);
+
 #endif	/* NTOSS_SYSTEM_NT_UTIL_H */
Signature · 1 line
2.45.0
#153 lore raw

PATCH v7 16/21 net/ntnic: add link 100G module ops

In reply to Serhii Iliushyk

As the ntnic can support different speeds,
an abstraction layer for 100G speed is needed.

---
 drivers/net/ntnic/adapter/nt4ga_adapter.c     | 12 ++++-
 .../link_mgmt/link_100g/nt4ga_link_100g.c     | 49 +++++++++++++++++++
 drivers/net/ntnic/meson.build                 |  1 +
 drivers/net/ntnic/ntnic_mod_reg.c             | 14 ++++++
 drivers/net/ntnic/ntnic_mod_reg.h             |  8 +++
 5 files changed, 82 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/ntnic/link_mgmt/link_100g/nt4ga_link_100g.c
drivers/net/ntnic/adapter/nt4ga_adapter.c +10 -2
index e29fda7fbb..17fd8016dd 100644
@@ -125,6 +125,7 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info)
 
 	{
 		int i;
+		const struct link_ops_s *link_ops = NULL;
 		assert(fpga_info->n_fpga_prod_id > 0);
 
 		for (i = 0; i < NUM_ADAPTER_PORTS_MAX; i++) {
@@ -135,8 +136,15 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info)
 		switch (fpga_info->n_fpga_prod_id) {
 		/* NT200A01: 2x100G (Xilinx) */
 		case 9563:	/* NT200A02 (Cap) */
-			NT_LOG(ERR, NTNIC, "NT200A02 100G link module uninitialized\n");
-			res = -1;
+			link_ops = get_100g_link_ops();
+
+			if (link_ops == NULL) {
+				NT_LOG(ERR, NTNIC, "NT200A02 100G link module uninitialized\n");
+				res = -1;
+				break;
+			}
+
+			res = link_ops->link_init(p_adapter_info, p_fpga);
 			break;
 
 		default:
drivers/net/ntnic/link_mgmt/link_100g/nt4ga_link_100g.c new file +49 -0

49 lines not on this page · raw message

drivers/net/ntnic/meson.build +1 -0
index 001c75963e..32f955969f 100644
@@ -22,6 +22,7 @@ includes = [
 # all sources
 sources = files(
     'adapter/nt4ga_adapter.c',
+    'link_mgmt/link_100g/nt4ga_link_100g.c',
     'link_mgmt/nt4ga_link.c',
     'nthw/supported/nthw_fpga_9563_055_039_0000.c',
     'nthw/supported/nthw_fpga_instances.c',
drivers/net/ntnic/ntnic_mod_reg.c +14 -0
index b79929c696..40e22c60fa 100644
@@ -5,6 +5,20 @@
 
 #include "ntnic_mod_reg.h"
 
+static struct link_ops_s *link_100g_ops;
+
+void register_100g_link_ops(struct link_ops_s *ops)
+{
+	link_100g_ops = ops;
+}
+
+const struct link_ops_s *get_100g_link_ops(void)
+{
+	if (link_100g_ops == NULL)
+		link_100g_init();
+	return link_100g_ops;
+}
+
 static const struct port_ops *port_ops;
 
 void register_port_ops(const struct port_ops *ops)
drivers/net/ntnic/ntnic_mod_reg.h +8 -0
index 8d1971a9c4..68629412b7 100644
@@ -13,6 +13,14 @@
 #include "nt4ga_adapter.h"
 #include "ntnic_nthw_fpga_rst_nt200a0x.h"
 
+struct link_ops_s {
+	int (*link_init)(struct adapter_info_s *p_adapter_info, nthw_fpga_t *p_fpga);
+};
+
+void register_100g_link_ops(struct link_ops_s *ops);
+const struct link_ops_s *get_100g_link_ops(void);
+void link_100g_init(void);
+
 struct port_ops {
 	/*
 	 * port:s link mode
Signature · 1 line
2.45.0
#154 lore raw

PATCH v7 17/21 net/ntnic: add generic NIM and I2C modules

In reply to Serhii Iliushyk

As the ntnic can support different port speeds, it also needs to support different NIMs (Network Interface Module). This commit add the generic NIM support for ntnic, such that the specific modules,
such as QSFP28 can be added later.

The communication with NIMs is in the form of I2C, so support for such a module is added as well.

Additionally a thread is added to control the NIM stat machines.

---
 drivers/net/ntnic/adapter/nt4ga_adapter.c     |  34 +++
 drivers/net/ntnic/include/nt4ga_adapter.h     |   3 +
 drivers/net/ntnic/include/nt4ga_link.h        |  13 +
 drivers/net/ntnic/include/ntnic_nim.h         |  61 +++++
 .../link_mgmt/link_100g/nt4ga_link_100g.c     | 214 ++++++++++++++++-
 drivers/net/ntnic/link_mgmt/nt4ga_link.c      |  13 +
 drivers/net/ntnic/meson.build                 |   3 +
 drivers/net/ntnic/nim/i2c_nim.c               | 224 ++++++++++++++++++
 drivers/net/ntnic/nim/i2c_nim.h               |  24 ++
 drivers/net/ntnic/nim/nim_defines.h           |  29 +++
 .../net/ntnic/nthw/core/include/nthw_core.h   |   1 +
 .../net/ntnic/nthw/core/include/nthw_i2cm.h   |  50 ++++
 drivers/net/ntnic/nthw/core/nthw_fpga.c       |   3 +
 drivers/net/ntnic/nthw/core/nthw_i2cm.c       | 192 +++++++++++++++
 drivers/net/ntnic/nthw/nthw_drv.h             |   1 +
 drivers/net/ntnic/ntnic_mod_reg.h             |   7 +
 16 files changed, 871 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/ntnic/include/ntnic_nim.h
 create mode 100644 drivers/net/ntnic/nim/i2c_nim.c
 create mode 100644 drivers/net/ntnic/nim/i2c_nim.h
 create mode 100644 drivers/net/ntnic/nim/nim_defines.h
 create mode 100644 drivers/net/ntnic/nthw/core/include/nthw_i2cm.h
 create mode 100644 drivers/net/ntnic/nthw/core/nthw_i2cm.c
drivers/net/ntnic/adapter/nt4ga_adapter.c +34 -0
index 17fd8016dd..9f671dda78 100644
@@ -9,6 +9,32 @@
 #include "nthw_fpga.h"
 #include "ntnic_mod_reg.h"
 
+/*
+ * Global variables shared by NT adapter types
+ */
+rte_thread_t monitor_tasks[NUM_ADAPTER_MAX];
+volatile int monitor_task_is_running[NUM_ADAPTER_MAX];
+
+/*
+ * Signal-handler to stop all monitor threads
+ */
+static void stop_monitor_tasks(int signum)
+{
+	const size_t N = ARRAY_SIZE(monitor_task_is_running);
+	size_t i;
+
+	/* Stop all monitor tasks */
+	for (i = 0; i < N; i++) {
+		const int is_running = monitor_task_is_running[i];
+		monitor_task_is_running[i] = 0;
+
+		if (signum == -1 && is_running != 0) {
+			rte_thread_join(monitor_tasks[i], NULL);
+			memset(&monitor_tasks[i], 0, sizeof(monitor_tasks[0]));
+		}
+	}
+}
+
 static int nt4ga_adapter_show_info(struct adapter_info_s *p_adapter_info, FILE *pfh)
 {
 	const char *const p_dev_name = p_adapter_info->p_dev_name;
@@ -35,6 +61,9 @@ static int nt4ga_adapter_show_info(struct adapter_info_s *p_adapter_info, FILE *
 		p_fpga_info->n_fpga_ver_id, p_fpga_info->n_fpga_rev_id, p_fpga_info->n_fpga_ident,
 		p_fpga_info->n_fpga_build_time);
 	fprintf(pfh, "%s: FpgaDebugMode=0x%x\n", p_adapter_id_str, p_fpga_info->n_fpga_debug_mode);
+	fprintf(pfh, "%s: Nims=%d PhyPorts=%d PhyQuads=%d RxPorts=%d TxPorts=%d\n",
+		p_adapter_id_str, p_fpga_info->n_nims, p_fpga_info->n_phy_ports,
+		p_fpga_info->n_phy_quads, p_fpga_info->n_rx_ports, p_fpga_info->n_tx_ports);
 	fprintf(pfh, "%s: Hw=0x%02X_rev%d: %s\n", p_adapter_id_str, p_hw_info->hw_platform_id,
 		p_fpga_info->nthw_hw_info.hw_id, p_fpga_info->nthw_hw_info.hw_plat_id_str);
 	fprintf(pfh, "%s: MCU Details:\n", p_adapter_id_str);
@@ -56,6 +85,7 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info)
 	 * (nthw_fpga_init())
 	 */
 	int n_phy_ports = -1;
+	int n_nim_ports = -1;
 	int res = -1;
 	nthw_fpga_t *p_fpga = NULL;
 
@@ -122,6 +152,8 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info)
 	assert(p_fpga);
 	n_phy_ports = fpga_info->n_phy_ports;
 	assert(n_phy_ports >= 1);
+	n_nim_ports = fpga_info->n_nims;
+	assert(n_nim_ports >= 1);
 
 	{
 		int i;
@@ -171,6 +203,8 @@ static int nt4ga_adapter_deinit(struct adapter_info_s *p_adapter_info)
 	int i;
 	int res;
 
+	stop_monitor_tasks(-1);
+
 	nthw_fpga_shutdown(&p_adapter_info->fpga_info);
 
 	/* Rac rab reset flip flop */
drivers/net/ntnic/include/nt4ga_adapter.h +3 -0
index ed14936b38..4b204742a2 100644
@@ -39,5 +39,8 @@ typedef struct adapter_info_s {
 	int n_tx_host_buffers;
 } adapter_info_t;
 
+extern rte_thread_t monitor_tasks[NUM_ADAPTER_MAX];
+extern volatile int monitor_task_is_running[NUM_ADAPTER_MAX];
+
 
 #endif	/* _NT4GA_ADAPTER_H_ */
drivers/net/ntnic/include/nt4ga_link.h +13 -0
index 849261ce3a..0851057f81 100644
@@ -7,6 +7,7 @@
 #define NT4GA_LINK_H_
 
 #include "ntos_drv.h"
+#include "ntnic_nim.h"
 
 enum nt_link_state_e {
 	NT_LINK_STATE_UNKNOWN = 0,	/* The link state has not been read yet */
@@ -41,6 +42,8 @@ enum nt_link_auto_neg_e {
 
 typedef struct link_state_s {
 	bool link_disabled;
+	bool nim_present;
+	bool lh_nim_absent;
 	bool link_up;
 	enum nt_link_state_e link_state;
 	enum nt_link_state_e link_state_latched;
@@ -73,12 +76,22 @@ typedef struct port_action_s {
 	uint32_t port_lpbk_mode;
 } port_action_t;
 
+typedef struct adapter_100g_s {
+	nim_i2c_ctx_t nim_ctx[NUM_ADAPTER_PORTS_MAX];	/* Should be the first field */
+} adapter_100g_t;
+
+typedef union adapter_var_s {
+	nim_i2c_ctx_t nim_ctx[NUM_ADAPTER_PORTS_MAX];	/* First field in all the adapters type */
+	adapter_100g_t var100g;
+} adapter_var_u;
+
 typedef struct nt4ga_link_s {
 	link_state_t link_state[NUM_ADAPTER_PORTS_MAX];
 	link_info_t link_info[NUM_ADAPTER_PORTS_MAX];
 	port_action_t port_action[NUM_ADAPTER_PORTS_MAX];
 	uint32_t speed_capa;
 	bool variables_initialized;
+	adapter_var_u u;
 } nt4ga_link_t;
 
 #endif	/* NT4GA_LINK_H_ */
drivers/net/ntnic/include/ntnic_nim.h new file +61 -0

61 lines not on this page · raw message

drivers/net/ntnic/link_mgmt/link_100g/nt4ga_link_100g.c +213 -1

241 lines not on this page · raw message

drivers/net/ntnic/link_mgmt/nt4ga_link.c +13 -0
index ad23046aae..bc362776fc 100644
@@ -12,6 +12,7 @@
 #include "ntnic_mod_reg.h"
 
 #include "nt4ga_link.h"
+#include "i2c_nim.h"
 
 /*
  * port: speed capabilities
@@ -26,6 +27,16 @@ static uint32_t nt4ga_port_get_link_speed_capabilities(struct adapter_info_s *p,
 	return nt_link_speed_capa;
 }
 
+/*
+ * port: nim present
+ */
+static bool nt4ga_port_get_nim_present(struct adapter_info_s *p, int port)
+{
+	nt4ga_link_t *const p_link = &p->nt4ga_link;
+	const bool nim_present = p_link->link_state[port].nim_present;
+	return nim_present;
+}
+
 /*
  * port: link mode
  */
@@ -131,6 +142,8 @@ static uint32_t nt4ga_port_get_loopback_mode(struct adapter_info_s *p, int port)
 
 
 static const struct port_ops ops = {
+	.get_nim_present = nt4ga_port_get_nim_present,
+
 	/*
 	 * port:s link mode
 	 */
drivers/net/ntnic/meson.build +3 -0
index 32f955969f..efea37e61a 100644
@@ -17,6 +17,7 @@ includes = [
     include_directories('nthw'),
     include_directories('nthw/supported'),
     include_directories('nthw/model'),
+    include_directories('nim/'),
 ]
 
 # all sources
@@ -24,6 +25,7 @@ sources = files(
     'adapter/nt4ga_adapter.c',
     'link_mgmt/link_100g/nt4ga_link_100g.c',
     'link_mgmt/nt4ga_link.c',
+    'nim/i2c_nim.c',
     'nthw/supported/nthw_fpga_9563_055_039_0000.c',
     'nthw/supported/nthw_fpga_instances.c',
     'nthw/supported/nthw_fpga_mod_str_map.c',
@@ -33,6 +35,7 @@ sources = files(
     'nthw/core/nt200a0x/reset/nthw_fpga_rst_nt200a0x.c',
     'nthw/core/nthw_fpga.c',
     'nthw/core/nthw_hif.c',
+    'nthw/core/nthw_i2cm.c',
     'nthw/core/nthw_iic.c',
     'nthw/core/nthw_pcie3.c',
     'nthw/core/nthw_sdc.c',
drivers/net/ntnic/nim/i2c_nim.c new file +224 -0

224 lines not on this page · raw message

drivers/net/ntnic/nim/i2c_nim.h new file +24 -0
new file mode 100644
index 0000000000..e89ae47835
@@ -0,0 +1,24 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef I2C_NIM_H_
+#define I2C_NIM_H_
+
+#include "ntnic_nim.h"
+
+/*
+ * Returns a type name such as "SFP/SFP+" for a given NIM type identifier,
+ * or the string "ILLEGAL!".
+ */
+const char *nim_id_to_text(uint8_t nim_id);
+
+/*
+ * This function tries to classify NIM based on it's ID and some register reads
+ * and collects information into ctx structure. The @extra parameter could contain
+ * the initialization argument for specific type of NIMS.
+ */
+int construct_and_preinit_nim(nim_i2c_ctx_p ctx);
+
+#endif	/* I2C_NIM_H_ */
drivers/net/ntnic/nim/nim_defines.h new file +29 -0
new file mode 100644
index 0000000000..9ba861bb4f
@@ -0,0 +1,29 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef NIM_DEFINES_H_
+#define NIM_DEFINES_H_
+
+#define NIM_IDENTIFIER_ADDR 0	/* 1 byte */
+
+/* I2C addresses */
+#define NIM_I2C_0XA0 0xA0	/* Basic I2C address */
+#define NIM_I2C_0XA2 0xA2	/* Diagnostic monitoring */
+
+typedef enum {
+	NIM_OPTION_TX_DISABLE,
+	/* Indicates that the module should be checked for the two next FEC types */
+	NIM_OPTION_FEC,
+	NIM_OPTION_MEDIA_SIDE_FEC,
+	NIM_OPTION_HOST_SIDE_FEC,
+	NIM_OPTION_RX_ONLY
+} nim_option_t;
+
+enum nt_nim_identifier_e {
+	NT_NIM_UNKNOWN = 0x00,	/* Nim type is unknown */
+};
+typedef enum nt_nim_identifier_e nt_nim_identifier_t;
+
+#endif	/* NIM_DEFINES_H_ */
drivers/net/ntnic/nthw/core/include/nthw_core.h +1 -0
index 5648bd8983..8d9d78b86d 100644
@@ -15,6 +15,7 @@
 #include "nthw_hif.h"
 #include "nthw_pcie3.h"
 #include "nthw_iic.h"
+#include "nthw_i2cm.h"
 
 #include "nthw_sdc.h"
 
drivers/net/ntnic/nthw/core/include/nthw_i2cm.h new file +50 -0

50 lines not on this page · raw message

drivers/net/ntnic/nthw/core/nthw_fpga.c +3 -0
index 38169176a5..d70205e5e3 100644
@@ -19,12 +19,14 @@ int nthw_fpga_get_param_info(struct fpga_info_s *p_fpga_info, nthw_fpga_t *p_fpg
 {
 	mcu_info_t *p_mcu_info = &p_fpga_info->mcu_info;
 
+	const int n_nims = nthw_fpga_get_product_param(p_fpga, NT_NIMS, -1);
 	const int n_phy_ports = nthw_fpga_get_product_param(p_fpga, NT_PHY_PORTS, -1);
 	const int n_phy_quads = nthw_fpga_get_product_param(p_fpga, NT_PHY_QUADS, -1);
 	const int n_rx_ports = nthw_fpga_get_product_param(p_fpga, NT_RX_PORTS, -1);
 	const int n_tx_ports = nthw_fpga_get_product_param(p_fpga, NT_TX_PORTS, -1);
 	const int n_vf_offset = nthw_fpga_get_product_param(p_fpga, NT_HIF_VF_OFFSET, 4);
 
+	p_fpga_info->n_nims = n_nims;
 	p_fpga_info->n_phy_ports = n_phy_ports;
 	p_fpga_info->n_phy_quads = n_phy_quads;
 	p_fpga_info->n_rx_ports = n_rx_ports;
@@ -236,6 +238,7 @@ int nthw_fpga_init(struct fpga_info_s *p_fpga_info)
 	nthw_fpga_get_param_info(p_fpga_info, p_fpga);
 
 	/* debug: report params */
+	NT_LOG(DBG, NTHW, "%s: NT_NIMS=%d\n", p_adapter_id_str, p_fpga_info->n_nims);
 	NT_LOG(DBG, NTHW, "%s: NT_PHY_PORTS=%d\n", p_adapter_id_str, p_fpga_info->n_phy_ports);
 	NT_LOG(DBG, NTHW, "%s: NT_PHY_QUADS=%d\n", p_adapter_id_str, p_fpga_info->n_phy_quads);
 	NT_LOG(DBG, NTHW, "%s: NT_RX_PORTS=%d\n", p_adapter_id_str, p_fpga_info->n_rx_ports);
drivers/net/ntnic/nthw/core/nthw_i2cm.c new file +192 -0

192 lines not on this page · raw message

drivers/net/ntnic/nthw/nthw_drv.h +1 -0
index 071618eb6e..de60ae171e 100644
@@ -52,6 +52,7 @@ typedef struct fpga_info_s {
 
 	int n_fpga_debug_mode;
 
+	int n_nims;
 	int n_phy_ports;
 	int n_phy_quads;
 	int n_rx_ports;
drivers/net/ntnic/ntnic_mod_reg.h +7 -0
index 68629412b7..3189b04f33 100644
@@ -22,6 +22,8 @@ const struct link_ops_s *get_100g_link_ops(void);
 void link_100g_init(void);
 
 struct port_ops {
+	bool (*get_nim_present)(struct adapter_info_s *p, int port);
+
 	/*
 	 * port:s link mode
 	 */
@@ -60,6 +62,11 @@ struct port_ops {
 
 	uint32_t (*get_link_speed_capabilities)(struct adapter_info_s *p, int port);
 
+	/*
+	 * port: nim capabilities
+	 */
+	nim_i2c_ctx_t (*get_nim_capabilities)(struct adapter_info_s *p, int port);
+
 	/*
 	 * port: tx power
 	 */
Signature · 1 line
2.45.0
#155 lore raw

PATCH v7 18/21 net/ntnic: add QSFP support

In reply to Serhii Iliushyk

Includes support for QSFP and QSFP+.

---
 drivers/net/ntnic/include/ntnic_nim.h         |  10 +
 .../link_mgmt/link_100g/nt4ga_link_100g.c     |  12 +-
 drivers/net/ntnic/nim/i2c_nim.c               | 310 +++++++++++++++++-
 drivers/net/ntnic/nim/i2c_nim.h               |  14 +-
 drivers/net/ntnic/nim/nim_defines.h           |   3 +
 drivers/net/ntnic/nim/qsfp_registers.h        |  43 +++
 6 files changed, 389 insertions(+), 3 deletions(-)
 create mode 100644 drivers/net/ntnic/nim/qsfp_registers.h
drivers/net/ntnic/include/ntnic_nim.h +10 -0
index 263875a857..300842b570 100644
@@ -15,6 +15,8 @@ typedef enum i2c_type {
 enum nt_port_type_e {
 	NT_PORT_TYPE_NOT_AVAILABLE = 0,	/* The NIM/port type is not available (unknown) */
 	NT_PORT_TYPE_NOT_RECOGNISED,	/* The NIM/port type not recognized */
+	NT_PORT_TYPE_QSFP_PLUS_NOT_PRESENT,	/* QSFP type but slot is empty */
+	NT_PORT_TYPE_QSFP_PLUS,	/* QSFP type */
 };
 
 typedef enum nt_port_type_e nt_port_type_t, *nt_port_type_p;
@@ -51,6 +53,14 @@ typedef struct nim_i2c_ctx {
 	bool tx_disable;
 	bool dmi_supp;
 
+	union {
+		struct {
+			bool rx_only;
+			union {
+			} specific_u;
+		} qsfp;
+
+	} specific_u;
 } nim_i2c_ctx_t, *nim_i2c_ctx_p;
 
 struct nim_sensor_group {
drivers/net/ntnic/link_mgmt/link_100g/nt4ga_link_100g.c +11 -1
index 4a8d28af9c..69d0a5d24a 100644
@@ -18,6 +18,7 @@ static int _create_nim(adapter_info_t *drv, int port)
 	int res = 0;
 	const uint8_t valid_nim_id = 17U;
 	nim_i2c_ctx_t *nim_ctx;
+	sfp_nim_state_t nim;
 	nt4ga_link_t *link_info = &drv->nt4ga_link;
 
 	assert(port >= 0 && port < NUM_ADAPTER_PORTS_MAX);
@@ -31,11 +32,20 @@ static int _create_nim(adapter_info_t *drv, int port)
 	 */
 	nt_os_wait_usec(1000000);	/* pause 1.0s */
 
-	res = construct_and_preinit_nim(nim_ctx);
+	res = construct_and_preinit_nim(nim_ctx, NULL);
 
 	if (res)
 		return res;
 
+	res = nim_state_build(nim_ctx, &nim);
+
+	if (res)
+		return res;
+
+	NT_LOG(DBG, NTHW, "%s: NIM id = %u (%s), br = %u, vendor = '%s', pn = '%s', sn='%s'\n",
+		drv->mp_port_id_str[port], nim_ctx->nim_id, nim_id_to_text(nim_ctx->nim_id), nim.br,
+		nim_ctx->vendor_name, nim_ctx->prod_no, nim_ctx->serial_no);
+
 	/*
 	 * Does the driver support the NIM module type?
 	 */
drivers/net/ntnic/nim/i2c_nim.c +309 -1

347 lines not on this page · raw message

drivers/net/ntnic/nim/i2c_nim.h +13 -1
index e89ae47835..edb6dcf1b6 100644
@@ -8,17 +8,29 @@
 
 #include "ntnic_nim.h"
 
+typedef struct sfp_nim_state {
+	uint8_t br;	/* bit rate, units of 100 MBits/sec */
+} sfp_nim_state_t, *sfp_nim_state_p;
+
+/*
+ * Builds an nim state for the port implied by `ctx`, returns zero
+ * if successful, and non-zero otherwise. SFP and QSFP nims are supported
+ */
+int nim_state_build(nim_i2c_ctx_t *ctx, sfp_nim_state_t *state);
+
 /*
  * Returns a type name such as "SFP/SFP+" for a given NIM type identifier,
  * or the string "ILLEGAL!".
  */
 const char *nim_id_to_text(uint8_t nim_id);
 
+int nim_qsfp_plus_nim_set_tx_laser_disable(nim_i2c_ctx_t *ctx, bool disable, int lane_idx);
+
 /*
  * This function tries to classify NIM based on it's ID and some register reads
  * and collects information into ctx structure. The @extra parameter could contain
  * the initialization argument for specific type of NIMS.
  */
-int construct_and_preinit_nim(nim_i2c_ctx_p ctx);
+int construct_and_preinit_nim(nim_i2c_ctx_p ctx, void *extra);
 
 #endif	/* I2C_NIM_H_ */
drivers/net/ntnic/nim/nim_defines.h +3 -0
index 9ba861bb4f..e5a033a3d4 100644
@@ -7,6 +7,7 @@
 #define NIM_DEFINES_H_
 
 #define NIM_IDENTIFIER_ADDR 0	/* 1 byte */
+#define QSFP_EXTENDED_IDENTIFIER 129
 
 /* I2C addresses */
 #define NIM_I2C_0XA0 0xA0	/* Basic I2C address */
@@ -23,6 +24,8 @@ typedef enum {
 
 enum nt_nim_identifier_e {
 	NT_NIM_UNKNOWN = 0x00,	/* Nim type is unknown */
+	NT_NIM_QSFP = 0x0C,	/* Nim type = QSFP */
+	NT_NIM_QSFP_PLUS = 0x0D,/* Nim type = QSFP+ */
 };
 typedef enum nt_nim_identifier_e nt_nim_identifier_t;
 
drivers/net/ntnic/nim/qsfp_registers.h new file +43 -0

43 lines not on this page · raw message

Signature · 1 line
2.45.0
#156 lore raw

PATCH v7 19/21 net/ntnic: add QSFP28 support

In reply to Serhii Iliushyk

Includes support for QSFP28

---
 drivers/net/ntnic/include/ntnic_nim.h    |  21 ++
 drivers/net/ntnic/link_mgmt/nt4ga_link.c |  25 +++
 drivers/net/ntnic/nim/i2c_nim.c          | 267 ++++++++++++++++++++++-
 drivers/net/ntnic/nim/nim_defines.h      |   1 +
 4 files changed, 313 insertions(+), 1 deletion(-)
drivers/net/ntnic/include/ntnic_nim.h +21 -0
index 300842b570..f3bd159130 100644
@@ -17,6 +17,19 @@ enum nt_port_type_e {
 	NT_PORT_TYPE_NOT_RECOGNISED,	/* The NIM/port type not recognized */
 	NT_PORT_TYPE_QSFP_PLUS_NOT_PRESENT,	/* QSFP type but slot is empty */
 	NT_PORT_TYPE_QSFP_PLUS,	/* QSFP type */
+	NT_PORT_TYPE_QSFP28_NOT_PRESENT,/* QSFP28 type but slot is empty */
+	NT_PORT_TYPE_QSFP28,	/* QSFP28 type */
+	NT_PORT_TYPE_QSFP28_SR4,/* QSFP28-SR4 type */
+	NT_PORT_TYPE_QSFP28_LR4,/* QSFP28-LR4 type */
+	NT_PORT_TYPE_QSFP28_CR_CA_L,	/* QSFP28-CR-CA-L type */
+	NT_PORT_TYPE_QSFP28_CR_CA_S,	/* QSFP28-CR-CA-S type */
+	NT_PORT_TYPE_QSFP28_CR_CA_N,	/* QSFP28-CR-CA-N type */
+	/* QSFP28-FR type. Uses PAM4 modulation on one lane only */
+	NT_PORT_TYPE_QSFP28_FR,
+	/* QSFP28-DR type. Uses PAM4 modulation on one lane only */
+	NT_PORT_TYPE_QSFP28_DR,
+	/* QSFP28-LR type. Uses PAM4 modulation on one lane only */
+	NT_PORT_TYPE_QSFP28_LR,
 };
 
 typedef enum nt_port_type_e nt_port_type_t, *nt_port_type_p;
@@ -56,7 +69,15 @@ typedef struct nim_i2c_ctx {
 	union {
 		struct {
 			bool rx_only;
+			bool qsfp28;
 			union {
+				struct {
+					uint8_t rev_compliance;
+					bool media_side_fec_ctrl;
+					bool host_side_fec_ctrl;
+					bool media_side_fec_ena;
+					bool host_side_fec_ena;
+				} qsfp28;
 			} specific_u;
 		} qsfp;
 
drivers/net/ntnic/link_mgmt/nt4ga_link.c +25 -0
index bc362776fc..4dc1c3d467 100644
@@ -140,6 +140,26 @@ static uint32_t nt4ga_port_get_loopback_mode(struct adapter_info_s *p, int port)
 	return p_link->port_action[port].port_lpbk_mode;
 }
 
+/*
+ * port: tx power
+ */
+static int nt4ga_port_tx_power(struct adapter_info_s *p, int port, bool disable)
+{
+	nt4ga_link_t *link_info = &p->nt4ga_link;
+
+	if (link_info->u.nim_ctx[port].port_type == NT_PORT_TYPE_QSFP28_SR4 ||
+		link_info->u.nim_ctx[port].port_type == NT_PORT_TYPE_QSFP28 ||
+		link_info->u.nim_ctx[port].port_type == NT_PORT_TYPE_QSFP28_LR4) {
+		nim_i2c_ctx_t *nim_ctx = &link_info->u.var100g.nim_ctx[port];
+
+		if (!nim_ctx->specific_u.qsfp.rx_only) {
+			if (nim_qsfp_plus_nim_set_tx_laser_disable(nim_ctx, disable, -1) != 0)
+				return 1;
+		}
+	}
+
+	return 0;
+}
 
 static const struct port_ops ops = {
 	.get_nim_present = nt4ga_port_get_nim_present,
@@ -181,6 +201,11 @@ static const struct port_ops ops = {
 	.get_loopback_mode = nt4ga_port_get_loopback_mode,
 
 	.get_link_speed_capabilities = nt4ga_port_get_link_speed_capabilities,
+
+	/*
+	 * port: tx power
+	 */
+	.tx_power = nt4ga_port_tx_power,
 };
 
 void port_init(void)
drivers/net/ntnic/nim/i2c_nim.c +266 -1

316 lines not on this page · raw message

drivers/net/ntnic/nim/nim_defines.h +1 -0
index e5a033a3d4..8e17b263c5 100644
@@ -26,6 +26,7 @@ enum nt_nim_identifier_e {
 	NT_NIM_UNKNOWN = 0x00,	/* Nim type is unknown */
 	NT_NIM_QSFP = 0x0C,	/* Nim type = QSFP */
 	NT_NIM_QSFP_PLUS = 0x0D,/* Nim type = QSFP+ */
+	NT_NIM_QSFP28 = 0x11,	/* Nim type = QSFP28 */
 };
 typedef enum nt_nim_identifier_e nt_nim_identifier_t;
 
Signature · 1 line
2.45.0
#157 lore raw

PATCH v7 20/21 net/ntnic: add GPIO communication for NIMs

In reply to Serhii Iliushyk

For NIM reset sequence GPIO communication is used. After this commit the NIMs supported by ntnic
is able to start up and be controlled fully by the adapter.

---
 drivers/net/ntnic/include/nt4ga_link.h        |   1 +
 .../link_mgmt/link_100g/nt4ga_link_100g.c     |  71 ++++++++-
 drivers/net/ntnic/meson.build                 |   1 +
 .../net/ntnic/nthw/core/include/nthw_core.h   |   1 +
 .../ntnic/nthw/core/include/nthw_gpio_phy.h   |  48 ++++++
 drivers/net/ntnic/nthw/core/nthw_gpio_phy.c   | 145 ++++++++++++++++++
 6 files changed, 263 insertions(+), 4 deletions(-)
 create mode 100644 drivers/net/ntnic/nthw/core/include/nthw_gpio_phy.h
 create mode 100644 drivers/net/ntnic/nthw/core/nthw_gpio_phy.c
drivers/net/ntnic/include/nt4ga_link.h +1 -0
index 0851057f81..5a16afea2a 100644
@@ -78,6 +78,7 @@ typedef struct port_action_s {
 
 typedef struct adapter_100g_s {
 	nim_i2c_ctx_t nim_ctx[NUM_ADAPTER_PORTS_MAX];	/* Should be the first field */
+	nthw_gpio_phy_t gpio_phy[NUM_ADAPTER_PORTS_MAX];
 } adapter_100g_t;
 
 typedef union adapter_var_s {
drivers/net/ntnic/link_mgmt/link_100g/nt4ga_link_100g.c +67 -4

145 lines not on this page · raw message

drivers/net/ntnic/meson.build +1 -0
index efea37e61a..e995ed75b0 100644
@@ -34,6 +34,7 @@ sources = files(
     'nthw/core/nt200a0x/reset/nthw_fpga_rst9563.c',
     'nthw/core/nt200a0x/reset/nthw_fpga_rst_nt200a0x.c',
     'nthw/core/nthw_fpga.c',
+    'nthw/core/nthw_gpio_phy.c',
     'nthw/core/nthw_hif.c',
     'nthw/core/nthw_i2cm.c',
     'nthw/core/nthw_iic.c',
drivers/net/ntnic/nthw/core/include/nthw_core.h +1 -0
index 8d9d78b86d..5cce56e13f 100644
@@ -17,6 +17,7 @@
 #include "nthw_iic.h"
 #include "nthw_i2cm.h"
 
+#include "nthw_gpio_phy.h"
 #include "nthw_sdc.h"
 
 #include "nthw_si5340.h"
drivers/net/ntnic/nthw/core/include/nthw_gpio_phy.h new file +48 -0

48 lines not on this page · raw message

drivers/net/ntnic/nthw/core/nthw_gpio_phy.c new file +145 -0

145 lines not on this page · raw message

Signature · 1 line
2.45.0
#158 lore raw

PATCH v7 21/21 net/ntnic: add physical layer control module

In reply to Serhii Iliushyk

Adds functionality to control the physical layer of the OSI model. This takes the form of the module
MAC PCS (Media Access Control Physical Coding Sublayer).
The functionality is used by the 100G link functionality to establish link.

---
 drivers/net/ntnic/include/nt4ga_link.h        |   1 +
 .../link_mgmt/link_100g/nt4ga_link_100g.c     | 393 +++++++-
 drivers/net/ntnic/meson.build                 |   1 +
 .../net/ntnic/nthw/core/include/nthw_core.h   |   1 +
 .../ntnic/nthw/core/include/nthw_mac_pcs.h    | 250 +++++
 drivers/net/ntnic/nthw/core/nthw_mac_pcs.c    | 894 ++++++++++++++++++
 6 files changed, 1538 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/ntnic/nthw/core/include/nthw_mac_pcs.h
 create mode 100644 drivers/net/ntnic/nthw/core/nthw_mac_pcs.c
drivers/net/ntnic/include/nt4ga_link.h +1 -0
index 5a16afea2a..8366484830 100644
@@ -78,6 +78,7 @@ typedef struct port_action_s {
 
 typedef struct adapter_100g_s {
 	nim_i2c_ctx_t nim_ctx[NUM_ADAPTER_PORTS_MAX];	/* Should be the first field */
+	nthw_mac_pcs_t mac_pcs100g[NUM_ADAPTER_PORTS_MAX];
 	nthw_gpio_phy_t gpio_phy[NUM_ADAPTER_PORTS_MAX];
 } adapter_100g_t;
 
drivers/net/ntnic/link_mgmt/link_100g/nt4ga_link_100g.c +391 -2

499 lines not on this page · raw message

drivers/net/ntnic/meson.build +1 -0
index e995ed75b0..0a6308f6bb 100644
@@ -38,6 +38,7 @@ sources = files(
     'nthw/core/nthw_hif.c',
     'nthw/core/nthw_i2cm.c',
     'nthw/core/nthw_iic.c',
+    'nthw/core/nthw_mac_pcs.c',
     'nthw/core/nthw_pcie3.c',
     'nthw/core/nthw_sdc.c',
     'nthw/core/nthw_si5340.c',
drivers/net/ntnic/nthw/core/include/nthw_core.h +1 -0
index 5cce56e13f..fe32891712 100644
@@ -18,6 +18,7 @@
 #include "nthw_i2cm.h"
 
 #include "nthw_gpio_phy.h"
+#include "nthw_mac_pcs.h"
 #include "nthw_sdc.h"
 
 #include "nthw_si5340.h"
drivers/net/ntnic/nthw/core/include/nthw_mac_pcs.h new file +250 -0

250 lines not on this page · raw message

drivers/net/ntnic/nthw/core/nthw_mac_pcs.c new file +894 -0

894 lines not on this page · raw message

Signature · 1 line
2.45.0
#159 lore raw

Re: [PATCH v7 01/21] net/ntnic: add ethdev and makes PMD available

In reply to Serhii Iliushyk

Hello Zhoumin,

It looks like Loongarch CI failed to apply this patch, but it worked at the other labs and locally for Serhii when they were checked out to next-net.

Maybe your CI did not choose next-net, the right branch? I remember you saying your CI is based on a fork of the dpdk-ci repo. Perhaps the pw_maintainers_cli.py script for choosing the right branch to apply on, is outdated in your fork.
https://git.dpdk.org/tools/dpdk-ci/tree/tools/pw_maintainers_cli.py

Can you take a look? Thanks.

Quoted 237 lines · Serhii Iliushyk

Add initial ntnic ethdev skeleton and register PCI probe functions Update documentation: Device description and feature list

---
 .mailmap                               |  1 +
 MAINTAINERS                            |  7 ++++
 doc/guides/nics/features/ntnic.ini     |  8 +++++
 doc/guides/nics/index.rst              |  1 +
 doc/guides/nics/ntnic.rst              | 39 ++++++++++++++++++++
 doc/guides/rel_notes/release_24_07.rst | 10 ++++++
 drivers/net/meson.build                |  1 +
 drivers/net/ntnic/meson.build          | 18 ++++++++++
 drivers/net/ntnic/ntnic_ethdev.c       | 49 ++++++++++++++++++++++++++
 9 files changed, 134 insertions(+)
 create mode 100644 doc/guides/nics/features/ntnic.ini
 create mode 100644 doc/guides/nics/ntnic.rst
 create mode 100644 drivers/net/ntnic/meson.build
 create mode 100644 drivers/net/ntnic/ntnic_ethdev.c
.mailmap +1 -0
index 552d79eaa6..aad8c552f6 100644
@@ -1307,6 +1307,7 @@ Sergey Madaminov <[email protected]>
 Sergey Mironov <[email protected]>
 Sergey Temerkhanov <[email protected]>
 Sergio Gonzalez Monroy <[email protected]>
+Serhii Iliushyk <[email protected]>
 Seth Arnold <[email protected]>
 Seth Howell <[email protected]>
 Shachar Beiser <[email protected]>
MAINTAINERS +7 -0
index 533f707d5f..0359368981 100644
@@ -855,6 +855,13 @@ F: drivers/net/octeon_ep/
 F: doc/guides/nics/features/octeon_ep.ini
 F: doc/guides/nics/octeon_ep.rst
 
+Napatech ntnic
+M: Christian Koue Muf <[email protected]>
+M: Serhii Iliushyk <[email protected]>
+F: drivers/net/ntnic/
+F: doc/guides/nics/ntnic.rst
+F: doc/guides/nics/features/ntnic.ini
+
 NVIDIA mlx4
 M: Matan Azrad <[email protected]>
 M: Viacheslav Ovsiienko <[email protected]>
doc/guides/nics/features/ntnic.ini new file +8 -0
new file mode 100644
index 0000000000..9ceb75a03b
@@ -0,0 +1,8 @@
+;
+; Supported features of the 'ntnic' network poll mode driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+[Features]
+Linux                = Y
+x86-64               = Y
doc/guides/nics/index.rst +1 -0
index 7bfcac880f..c14bc7988a 100644
@@ -53,6 +53,7 @@ Network Interface Controller Drivers
     nfb
     nfp
     ngbe
+    ntnic
     null
     octeon_ep
     octeontx
doc/guides/nics/ntnic.rst new file +39 -0
new file mode 100644
index 0000000000..249d83d511
@@ -0,0 +1,39 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+    Copyright(c) 2023 Napatech A/S
+
+NTNIC Poll Mode Driver
+======================
+
+The NTNIC PMD provides poll mode driver support for Napatech smartNICs.
+
+
+Design
+------
+
+The NTNIC PMD is designed as a pure user-space driver, and requires no special
+Napatech kernel modules.
+
+The Napatech smartNIC presents one control PCI device (PF0). NTNIC PMD accesses
+smartNIC PF0 via vfio-pci kernel driver. Access to PF0 for all purposes is
+exclusive, so only one process should access it. The physical ports are located
+behind PF0 as DPDK port 0 and 1.
+
+
+Supported NICs
+--------------
+
+- NT200A02 2x100G SmartNIC
+
+    - FPGA ID 9563 (Inline Flow Management)
+
+All information about NT200A02 can be found by link below:
+https://www.napatech.com/products/nt200a02-smartnic-inline/
+
+Limitations
+~~~~~~~~~~~
+
+Kernel versions before 5.7 are not supported. Kernel version 5.7 added vfio-pci
+support for creating VFs from the PF which is required for the PMD to use
+vfio-pci on the PF. This support has been back-ported to older Linux
+distributions and they are also supported. If vfio-pci is not required kernel
+version 4.18 is supported.
doc/guides/rel_notes/release_24_07.rst +10 -0
index e50afed0d5..332a959618 100644
@@ -154,6 +154,16 @@ New Features
 
   Added an API that allows the user to reclaim the defer queue with RCU.
 
+* **Added Napatech ntnic experimental PMD driver.**
+
+  * Added the experimental PMD driver
+
+    - Ability to initialize the NIC (NT200A02)
+    - Supporting only one FPGA firmware (9563.55.39)
+    - Ability to bring up the 100G link
+    - Supporting QSFP/QSFP+/QSFP28 NIM
+    - Does not support datapath
+    - Does not support RTE flow API
 
 Removed Items
 -------------
drivers/net/meson.build +1 -0
index bd38b533c5..fb6d34b782 100644
@@ -45,6 +45,7 @@ drivers = [
         'nfb',
         'nfp',
         'ngbe',
+        'ntnic',
         'null',
         'octeontx',
         'octeon_ep',
drivers/net/ntnic/meson.build new file +18 -0
new file mode 100644
index 0000000000..194353230b
@@ -0,0 +1,18 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2020-2023 Napatech A/S
+
+if not is_linux or not dpdk_conf.has('RTE_ARCH_X86_64')
+    build = false
+    reason = 'only supported on x86_64 Linux'
+    subdir_done()
+endif
+
+# includes
+includes = [
+    include_directories('.'),
+]
+
+# all sources
+sources = files(
+    'ntnic_ethdev.c',
+)
drivers/net/ntnic/ntnic_ethdev.c new file +49 -1
new file mode 100644
index 0000000000..7e5231d2c1
@@ -0,0 +1,49 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#include <rte_ethdev.h>
+#include <rte_bus_pci.h>
+#include <ethdev_pci.h>
+
+static const struct rte_pci_id nthw_pci_id_map[] = {
+       {
+               .vendor_id = 0,
+       },      /* sentinel */
+};
+
+static int
+nthw_pci_dev_init(struct rte_pci_device *pci_dev __rte_unused)
+{
+       return 0;
+}
+
+static int
+nthw_pci_dev_deinit(struct rte_eth_dev *eth_dev __rte_unused)
+{
+       return 0;
+}
+
+static int
+nthw_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
+       struct rte_pci_device *pci_dev)
+{
+       int ret;
+       ret = nthw_pci_dev_init(pci_dev);
+       return ret;
+}
+
+static int
+nthw_pci_remove(struct rte_pci_device *pci_dev)
+{
+       return rte_eth_dev_pci_generic_remove(pci_dev, nthw_pci_dev_deinit);
+}
+
+static struct rte_pci_driver rte_nthw_pmd = {
+       .id_table = nthw_pci_id_map,
+       .probe = nthw_pci_probe,
+       .remove = nthw_pci_remove,
+};
+
+RTE_PMD_REGISTER_PCI(net_ntnic, rte_nthw_pmd);
--

2.45.0

#160 lore raw

Re: [PATCH v7 01/21] net/ntnic: add ethdev and makes PMD available

Hi Patrick,

Thanks for reminding me. The pw_maintainers_cli.py script indeed is outdated in my fork.

I have updated this script, but still failed to apply this patch. I saw all the other labs applied this patch based on commit of 'a6c3ec342ee105e322ffdb21e810cdfd38455c62', but I cannot find this commit id in the history of next-net-main and next-net-for-main from the latest update. Did I miss one there?

It seems that this series should rebase on the latest update of next-net (see below).

Quoted 142 lines · Patrick Robb

Hello Zhoumin,

It looks like Loongarch CI failed to apply this patch, but it worked at the other labs and locally for Serhii when they were checked out to next-net.

Maybe your CI did not choose next-net, the right branch? I remember you saying your CI is based on a fork of the dpdk-ci repo. Perhaps the pw_maintainers_cli.py script for choosing the right branch to apply on, is outdated in your fork.
https://git.dpdk.org/tools/dpdk-ci/tree/tools/pw_maintainers_cli.py

Can you take a look? Thanks.

Quoted 127 lines · Serhii Iliushyk

Add initial ntnic ethdev skeleton and register PCI probe functions Update documentation: Device description and feature list

---
  .mailmap                               |  1 +
  MAINTAINERS                            |  7 ++++
  doc/guides/nics/features/ntnic.ini     |  8 +++++
  doc/guides/nics/index.rst              |  1 +
  doc/guides/nics/ntnic.rst              | 39 ++++++++++++++++++++
  doc/guides/rel_notes/release_24_07.rst | 10 ++++++
  drivers/net/meson.build                |  1 +
  drivers/net/ntnic/meson.build          | 18 ++++++++++
  drivers/net/ntnic/ntnic_ethdev.c       | 49 ++++++++++++++++++++++++++
  9 files changed, 134 insertions(+)

create mode 100644 doc/guides/nics/features/ntnic.ini create mode 100644 doc/guides/nics/ntnic.rst create mode 100644 drivers/net/ntnic/meson.build create mode 100644 drivers/net/ntnic/ntnic_ethdev.c

.mailmap +1 -0
index 552d79eaa6..aad8c552f6 100644
@@ -1307,6 +1307,7 @@ Sergey Madaminov <[email protected]>
  Sergey Mironov <[email protected]>
  Sergey Temerkhanov <[email protected]>
  Sergio Gonzalez Monroy <[email protected]>
+Serhii Iliushyk <[email protected]>
  Seth Arnold <[email protected]>
  Seth Howell <[email protected]>
  Shachar Beiser <[email protected]>
MAINTAINERS +7 -0
index 533f707d5f..0359368981 100644
@@ -855,6 +855,13 @@ F: drivers/net/octeon_ep/
  F: doc/guides/nics/features/octeon_ep.ini
  F: doc/guides/nics/octeon_ep.rst
 
+Napatech ntnic
+M: Christian Koue Muf <[email protected]>
+M: Serhii Iliushyk <[email protected]>
+F: drivers/net/ntnic/
+F: doc/guides/nics/ntnic.rst
+F: doc/guides/nics/features/ntnic.ini
+
  NVIDIA mlx4
  M: Matan Azrad <[email protected]>
  M: Viacheslav Ovsiienko <[email protected]>
doc/guides/nics/features/ntnic.ini new file +8 -0
new file mode 100644
index 0000000000..9ceb75a03b
@@ -0,0 +1,8 @@
+;
+; Supported features of the 'ntnic' network poll mode driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+[Features]
+Linux                = Y
+x86-64               = Y
doc/guides/nics/index.rst +1 -0
index 7bfcac880f..c14bc7988a 100644
@@ -53,6 +53,7 @@ Network Interface Controller Drivers
      nfb
      nfp
      ngbe
+    ntnic
      null
      octeon_ep
      octeontx
doc/guides/nics/ntnic.rst new file +39 -0
new file mode 100644
index 0000000000..249d83d511
@@ -0,0 +1,39 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+    Copyright(c) 2023 Napatech A/S
+
+NTNIC Poll Mode Driver
+======================
+
+The NTNIC PMD provides poll mode driver support for Napatech smartNICs.
+
+
+Design
+------
+
+The NTNIC PMD is designed as a pure user-space driver, and requires no special
+Napatech kernel modules.
+
+The Napatech smartNIC presents one control PCI device (PF0). NTNIC PMD accesses
+smartNIC PF0 via vfio-pci kernel driver. Access to PF0 for all purposes is
+exclusive, so only one process should access it. The physical ports are located
+behind PF0 as DPDK port 0 and 1.
+
+
+Supported NICs
+--------------
+
+- NT200A02 2x100G SmartNIC
+
+    - FPGA ID 9563 (Inline Flow Management)
+
+All information about NT200A02 can be found by link below:
+https://www.napatech.com/products/nt200a02-smartnic-inline/
+
+Limitations
+~~~~~~~~~~~
+
+Kernel versions before 5.7 are not supported. Kernel version 5.7 added vfio-pci
+support for creating VFs from the PF which is required for the PMD to use
+vfio-pci on the PF. This support has been back-ported to older Linux
+distributions and they are also supported. If vfio-pci is not required kernel
+version 4.18 is supported.
doc/guides/rel_notes/release_24_07.rst +0 -0
index e50afed0d5..332a959618 100644
@@ -154,6 +154,16 @@ New Features
 
Quoted 1 line

doc/guides/rel_notes/release_24_07.rst New Features · line 155

Quoted 1 line
doc/guides/rel_notes/release_24_07.rst +0 -0
    Added an API that allows the user to reclaim the defer queue with RCU.

The above sentence had been modified in the commit of 'a40ac9bcd85c840aec776729f950663d3a61eaf5' as following:

-* **Added defer queue reclamation in the hash library.** +* **Updated the hash library.**

-  Added an API that allows the user to reclaim the defer queue with RCU. +  * Added defer queue reclamation via RCU.
+  * Added SVE support for bulk lookup.

Best regards,

Min Zhou

Quoted 107 lines
Quoted 107 lines
doc/guides/rel_notes/release_24_07.rst +10 -0
+* **Added Napatech ntnic experimental PMD driver.**
+
+  * Added the experimental PMD driver
+
+    - Ability to initialize the NIC (NT200A02)
+    - Supporting only one FPGA firmware (9563.55.39)
+    - Ability to bring up the 100G link
+    - Supporting QSFP/QSFP+/QSFP28 NIM
+    - Does not support datapath
+    - Does not support RTE flow API
 
  Removed Items
  -------------
drivers/net/meson.build +1 -0
index bd38b533c5..fb6d34b782 100644
@@ -45,6 +45,7 @@ drivers = [
          'nfb',
          'nfp',
          'ngbe',
+        'ntnic',
          'null',
          'octeontx',
          'octeon_ep',
drivers/net/ntnic/meson.build new file +18 -0
new file mode 100644
index 0000000000..194353230b
@@ -0,0 +1,18 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2020-2023 Napatech A/S
+
+if not is_linux or not dpdk_conf.has('RTE_ARCH_X86_64')
+    build = false
+    reason = 'only supported on x86_64 Linux'
+    subdir_done()
+endif
+
+# includes
+includes = [
+    include_directories('.'),
+]
+
+# all sources
+sources = files(
+    'ntnic_ethdev.c',
+)
drivers/net/ntnic/ntnic_ethdev.c new file +49 -1
new file mode 100644
index 0000000000..7e5231d2c1
@@ -0,0 +1,49 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#include <rte_ethdev.h>
+#include <rte_bus_pci.h>
+#include <ethdev_pci.h>
+
+static const struct rte_pci_id nthw_pci_id_map[] = {
+       {
+               .vendor_id = 0,
+       },      /* sentinel */
+};
+
+static int
+nthw_pci_dev_init(struct rte_pci_device *pci_dev __rte_unused)
+{
+       return 0;
+}
+
+static int
+nthw_pci_dev_deinit(struct rte_eth_dev *eth_dev __rte_unused)
+{
+       return 0;
+}
+
+static int
+nthw_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
+       struct rte_pci_device *pci_dev)
+{
+       int ret;
+       ret = nthw_pci_dev_init(pci_dev);
+       return ret;
+}
+
+static int
+nthw_pci_remove(struct rte_pci_device *pci_dev)
+{
+       return rte_eth_dev_pci_generic_remove(pci_dev, nthw_pci_dev_deinit);
+}
+
+static struct rte_pci_driver rte_nthw_pmd = {
+       .id_table = nthw_pci_id_map,
+       .probe = nthw_pci_probe,
+       .remove = nthw_pci_remove,
+};
+
+RTE_PMD_REGISTER_PCI(net_ntnic, rte_nthw_pmd);
--

2.45.0

#161 lore raw

Re: [PATCH v7 01/21] net/ntnic: add ethdev and makes PMD available

Hi Min Zhou,

I am seeing that commit for next-net:
https://git.dpdk.org/next/dpdk-next-net/commit/?id=a6c3ec342ee105e322ffdb21e810cdfd38455c62

If you try to manually apply it on next-net, does it work?

Pasting the logs from our apply process below for context:

```

 Trying to checkout branch: origin/next-net-for-main
 Checked out to next-net-for-main (a6c3ec342ee105e322ffdb21e810cdfd38455c62)
 Applying patch...

 Applying: net/ntnic: add ethdev and makes PMD available
 Applying: net/ntnic: add logging implementation
 Applying: net/ntnic: add minimal initialization for PCI device
 Applying: net/ntnic: add NT utilities implementation
 Applying: net/ntnic: add VFIO module
 Applying: net/ntnic: add basic eth dev ops to ntnic
 Applying: net/ntnic: add core platform structures
 Applying: net/ntnic: add adapter initialization
 Applying: net/ntnic: add registers and FPGA model for NapaTech NIC
 Applying: net/ntnic: add FPGA modules for initialization
 Applying: net/ntnic: add FPGA initialization functionality
 Applying: net/ntnic: add support of the NT200A0X smartNIC
 Applying: net/ntnic: add startup and reset sequence for NT200A0X
 Applying: net/ntnic: add clock profile for the NT200A0X smartNIC
 Applying: net/ntnic: add link management skeleton
 Applying: net/ntnic: add link 100G module ops
 Applying: net/ntnic: add generic NIM and I2C modules
 Applying: net/ntnic: add QSFP support
 Applying: net/ntnic: add QSFP28 support
 Applying: net/ntnic: add GPIO communication for NIMs
 Applying: net/ntnic: add physical layer control module


 Running test build...
 The Meson build system

```
#162 lore raw

Re: [PATCH v7 01/21] net/ntnic: add ethdev and makes PMD available

Hi Patrick,

Thanks for giving the link of commit a6c3ec342ee1.

However I cannot checkout this commit in the next-net repository because the commit ID is not exist in the history of next-net repository. Could you find it?

It seems that the commit a6c3ec342ee1 is nearly identical to the commit 62edcfd6ea3c except the minor change in the subjects as following:

https://git.dpdk.org/next/dpdk-next-net/commit/?id=62edcfd6ea3c61639df68e4a315046d09f462e8c

I'm able to checkout the commit 62edcfd6ea3c in the next-net repository but fail to apply this series, because this series conflicts with the commit a40ac9bcd85c.

Despite all this, I can apply this series successfully on the artifact of commit a6c3ec342ee1:

https://git.dpdk.org/next/dpdk-next-net/snapshot/dpdk-next-net-a6c3ec342ee105e322ffdb21e810cdfd38455c62.zip

Loongson lab always tries to update the local repository with the upstream before testing the series, and just applies the downloaded series to the local repository. So it's possible to skip some commits in Loongson lab when chooses the base for applying.

Best regards,

Min Zhou

Quoted 42 lines · Patrick Robb

Hi Min Zhou,

I am seeing that commit for next-net:
https://git.dpdk.org/next/dpdk-next-net/commit/?id=a6c3ec342ee105e322ffdb21e810cdfd38455c62

If you try to manually apply it on next-net, does it work?

Pasting the logs from our apply process below for context:

```

  Trying to checkout branch: origin/next-net-for-main
  Checked out to next-net-for-main (a6c3ec342ee105e322ffdb21e810cdfd38455c62)
  Applying patch...

  Applying: net/ntnic: add ethdev and makes PMD available
  Applying: net/ntnic: add logging implementation
  Applying: net/ntnic: add minimal initialization for PCI device
  Applying: net/ntnic: add NT utilities implementation
  Applying: net/ntnic: add VFIO module
  Applying: net/ntnic: add basic eth dev ops to ntnic
  Applying: net/ntnic: add core platform structures
  Applying: net/ntnic: add adapter initialization
  Applying: net/ntnic: add registers and FPGA model for NapaTech NIC
  Applying: net/ntnic: add FPGA modules for initialization
  Applying: net/ntnic: add FPGA initialization functionality
  Applying: net/ntnic: add support of the NT200A0X smartNIC
  Applying: net/ntnic: add startup and reset sequence for NT200A0X
  Applying: net/ntnic: add clock profile for the NT200A0X smartNIC
  Applying: net/ntnic: add link management skeleton
  Applying: net/ntnic: add link 100G module ops
  Applying: net/ntnic: add generic NIM and I2C modules
  Applying: net/ntnic: add QSFP support
  Applying: net/ntnic: add QSFP28 support
  Applying: net/ntnic: add GPIO communication for NIMs
  Applying: net/ntnic: add physical layer control module


  Running test build...
  The Meson build system

```
#163 lore raw

Re: [PATCH v7 01/21] net/ntnic: add ethdev and makes PMD available

Quoted 5 lines · zhoumin

Hi Patrick,

Thanks for giving the link of commit a6c3ec342ee1.

Quoted 9 lines

However I cannot checkout this commit in the next-net repository because the commit ID is not exist in the history of next-net repository. Could you find it?

It seems that the commit a6c3ec342ee1 is nearly identical to the commit 62edcfd6ea3c except the minor change in the subjects as following:

https://git.dpdk.org/next/dpdk-next-net/commit/?id=62edcfd6ea3c61639df68e4a315046d09f462e8c

Thanks Min Zhou, I see what you mean. I guess Ferruh amended a commit and force pushed to the next-net branch? Otherwise I'm not sure what happened.

In any case, it looks like for the v9 submission you checked out to a valid commit on next-net, so I think we're good.

Thanks for updating your dpdk-ci repo!

#164 lore raw

Re: [PATCH v7 01/21] net/ntnic: add ethdev and makes PMD available

Quoted 13 lines · Patrick Robb
Quoted 12 lines · zhoumin

Hi Patrick,

Thanks for giving the link of commit a6c3ec342ee1.

However I cannot checkout this commit in the next-net repository because the commit ID is not exist in the history of next-net repository. Could you find it?

It seems that the commit a6c3ec342ee1 is nearly identical to the commit 62edcfd6ea3c except the minor change in the subjects as following:

Quoted 7 lines
Quoted 2 lines

https://git.dpdk.org/next/dpdk-next-net/commit/?id=62edcfd6ea3c61639df68e4a315046d09f462e8c

Thanks Min Zhou, I see what you mean. I guess Ferruh amended a commit and force pushed to the next-net branch? Otherwise I'm not sure what happened.

I re-write next-net history a few times around -rc1, it must be the reason.

Quoted 5 lines

In any case, it looks like for the v9 submission you checked out to a valid commit on next-net, so I think we're good.

Thanks for updating your dpdk-ci repo!

loongarch build is fine now, thanks Min, Patrick for taking care of it.

#165 lore raw

PATCH v8 1/21 net/ntnic: add ethdev and makes PMD available

In reply to Serhii Iliushyk

Add initial ntnic ethdev skeleton and register PCI probe functions Update documentation: Device description and feature list

---
v6
* Remove unused includes
* Remove EOF markers
* Remove unnecesarry commpiller flags
* Update documentation INI and RST files
* Remove uncovered features
* Add features according to DPDK reqirements
* Add link on NT200A02 description
* Rename res(short for result) to ret(short for return)
* Fix unnecessary set of the driver name
* The driver name is set by macro RTE_PMD_REGISTER_PCI
* Set sentinel value for PCI id_table
* NULL value can lead to the crush on function rte_pci_match
* Remove unnecessary comments
v7
* Move features list to the dedicated patches
* Update release note file

---
 .mailmap                               |  1 +
 MAINTAINERS                            |  7 ++++
 doc/guides/nics/features/ntnic.ini     |  8 +++++
 doc/guides/nics/index.rst              |  1 +
 doc/guides/nics/ntnic.rst              | 39 ++++++++++++++++++++
 doc/guides/rel_notes/release_24_07.rst | 10 ++++++
 drivers/net/meson.build                |  1 +
 drivers/net/ntnic/meson.build          | 18 ++++++++++
 drivers/net/ntnic/ntnic_ethdev.c       | 49 ++++++++++++++++++++++++++
 9 files changed, 134 insertions(+)
 create mode 100644 doc/guides/nics/features/ntnic.ini
 create mode 100644 doc/guides/nics/ntnic.rst
 create mode 100644 drivers/net/ntnic/meson.build
 create mode 100644 drivers/net/ntnic/ntnic_ethdev.c
.mailmap +1 -0
index 552d79eaa6..aad8c552f6 100644
@@ -1307,6 +1307,7 @@ Sergey Madaminov <[email protected]>
 Sergey Mironov <[email protected]>
 Sergey Temerkhanov <[email protected]>
 Sergio Gonzalez Monroy <[email protected]>
+Serhii Iliushyk <[email protected]>
 Seth Arnold <[email protected]>
 Seth Howell <[email protected]>
 Shachar Beiser <[email protected]>
MAINTAINERS +7 -0
index 533f707d5f..0359368981 100644
@@ -855,6 +855,13 @@ F: drivers/net/octeon_ep/
 F: doc/guides/nics/features/octeon_ep.ini
 F: doc/guides/nics/octeon_ep.rst
 
+Napatech ntnic
+M: Christian Koue Muf <[email protected]>
+M: Serhii Iliushyk <[email protected]>
+F: drivers/net/ntnic/
+F: doc/guides/nics/ntnic.rst
+F: doc/guides/nics/features/ntnic.ini
+
 NVIDIA mlx4
 M: Matan Azrad <[email protected]>
 M: Viacheslav Ovsiienko <[email protected]>
doc/guides/nics/features/ntnic.ini new file +8 -0
new file mode 100644
index 0000000000..9ceb75a03b
@@ -0,0 +1,8 @@
+;
+; Supported features of the 'ntnic' network poll mode driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+[Features]
+Linux                = Y
+x86-64               = Y
doc/guides/nics/index.rst +1 -0
index 7bfcac880f..c14bc7988a 100644
@@ -53,6 +53,7 @@ Network Interface Controller Drivers
     nfb
     nfp
     ngbe
+    ntnic
     null
     octeon_ep
     octeontx
doc/guides/nics/ntnic.rst new file +39 -0
new file mode 100644
index 0000000000..249d83d511
@@ -0,0 +1,39 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+    Copyright(c) 2023 Napatech A/S
+
+NTNIC Poll Mode Driver
+======================
+
+The NTNIC PMD provides poll mode driver support for Napatech smartNICs.
+
+
+Design
+------
+
+The NTNIC PMD is designed as a pure user-space driver, and requires no special
+Napatech kernel modules.
+
+The Napatech smartNIC presents one control PCI device (PF0). NTNIC PMD accesses
+smartNIC PF0 via vfio-pci kernel driver. Access to PF0 for all purposes is
+exclusive, so only one process should access it. The physical ports are located
+behind PF0 as DPDK port 0 and 1.
+
+
+Supported NICs
+--------------
+
+- NT200A02 2x100G SmartNIC
+
+    - FPGA ID 9563 (Inline Flow Management)
+
+All information about NT200A02 can be found by link below:
+https://www.napatech.com/products/nt200a02-smartnic-inline/
+
+Limitations
+~~~~~~~~~~~
+
+Kernel versions before 5.7 are not supported. Kernel version 5.7 added vfio-pci
+support for creating VFs from the PF which is required for the PMD to use
+vfio-pci on the PF. This support has been back-ported to older Linux
+distributions and they are also supported. If vfio-pci is not required kernel
+version 4.18 is supported.
doc/guides/rel_notes/release_24_07.rst +10 -0
index e50afed0d5..332a959618 100644
@@ -154,6 +154,16 @@ New Features
 
   Added an API that allows the user to reclaim the defer queue with RCU.
 
+* **Added Napatech ntnic experimental PMD driver.**
+
+  * Added the experimental PMD driver
+
+    - Ability to initialize the NIC (NT200A02)
+    - Supporting only one FPGA firmware (9563.55.39)
+    - Ability to bring up the 100G link
+    - Supporting QSFP/QSFP+/QSFP28 NIM
+    - Does not support datapath
+    - Does not support RTE flow API
 
 Removed Items
 -------------
drivers/net/meson.build +1 -0
index bd38b533c5..fb6d34b782 100644
@@ -45,6 +45,7 @@ drivers = [
         'nfb',
         'nfp',
         'ngbe',
+        'ntnic',
         'null',
         'octeontx',
         'octeon_ep',
drivers/net/ntnic/meson.build new file +18 -0
new file mode 100644
index 0000000000..194353230b
@@ -0,0 +1,18 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2020-2023 Napatech A/S
+
+if not is_linux or not dpdk_conf.has('RTE_ARCH_X86_64')
+    build = false
+    reason = 'only supported on x86_64 Linux'
+    subdir_done()
+endif
+
+# includes
+includes = [
+    include_directories('.'),
+]
+
+# all sources
+sources = files(
+    'ntnic_ethdev.c',
+)
drivers/net/ntnic/ntnic_ethdev.c new file +49 -0

49 lines not on this page · raw message

Signature · 1 line
2.45.0
#166 lore raw

PATCH v8 2/21 net/ntnic: add logging implementation

Adds ntnic specific implementation for logging. NT NIC uses this logging abstraction layer
to ensure that FPGA module implementations function both within and outside in DPDK environment

---
v6
* Logging header file was moved
* Default log type was set to NOTICE

---
 drivers/net/ntnic/meson.build    |  2 ++
 drivers/net/ntnic/ntlog/ntlog.c  | 53 ++++++++++++++++++++++++++++++++
 drivers/net/ntnic/ntlog/ntlog.h  | 49 +++++++++++++++++++++++++++++
 drivers/net/ntnic/ntnic_ethdev.c |  2 ++
 4 files changed, 106 insertions(+)
 create mode 100644 drivers/net/ntnic/ntlog/ntlog.c
 create mode 100644 drivers/net/ntnic/ntlog/ntlog.h
drivers/net/ntnic/meson.build +2 -0
index 194353230b..80f0f3eecf 100644
@@ -10,9 +10,11 @@ endif
 # includes
 includes = [
     include_directories('.'),
+    include_directories('ntlog'),
 ]
 
 # all sources
 sources = files(
+    'ntlog/ntlog.c',
     'ntnic_ethdev.c',
 )
drivers/net/ntnic/ntlog/ntlog.c new file +53 -0

53 lines not on this page · raw message

drivers/net/ntnic/ntlog/ntlog.h new file +49 -0

49 lines not on this page · raw message

drivers/net/ntnic/ntnic_ethdev.c +2 -0
index 7e5231d2c1..68df9be2ff 100644
@@ -7,6 +7,8 @@
 #include <rte_bus_pci.h>
 #include <ethdev_pci.h>
 
+#include "ntlog.h"
+
 static const struct rte_pci_id nthw_pci_id_map[] = {
 	{
 		.vendor_id = 0,
Signature · 1 line
2.45.0
#167 lore raw

PATCH v8 3/21 net/ntnic: add minimal initialization for PCI device

In reply to Serhii Iliushyk

add implementation for probe/init and remove/deinit of the PCI device

---
v6
* Add driver deinitialization
* Add API rte_eth_dev_probing_finish
* Add correct API for finishing probing the device
* Remove duplicated calling 'rte_eth_copy_pci_info()' via 'eth_dev_pci_specific_init()
* Remove unnecessary comments
* Remove duplicatet initialization of the numa_node

---
 drivers/net/ntnic/ntnic_ethdev.c | 109 +++++++++++++++++++++++++++++--
 1 file changed, 104 insertions(+), 5 deletions(-)
drivers/net/ntnic/ntnic_ethdev.c +104 -5
index 68df9be2ff..a744f78adb 100644
@@ -3,6 +3,7 @@
  * Copyright(c) 2023 Napatech A/S
  */
 
+#include <rte_vfio.h>
 #include <rte_ethdev.h>
 #include <rte_bus_pci.h>
 #include <ethdev_pci.h>
@@ -16,29 +17,127 @@ static const struct rte_pci_id nthw_pci_id_map[] = {
 };
 
 static int
-nthw_pci_dev_init(struct rte_pci_device *pci_dev __rte_unused)
+nthw_pci_dev_init(struct rte_pci_device *pci_dev)
 {
+	uint32_t n_port_mask = -1;	/* All ports enabled by default */
+	int n_phy_ports;
+	NT_LOG_DBGX(DEBUG, NTNIC, "Dev %s PF #%i Init : %02x:%02x:%i\n", pci_dev->name,
+		pci_dev->addr.function, pci_dev->addr.bus, pci_dev->addr.devid,
+		pci_dev->addr.function);
+
+	n_phy_ports = 0;
+
+	for (int n_intf_no = 0; n_intf_no < n_phy_ports; n_intf_no++) {
+		struct rte_eth_dev *eth_dev = NULL;
+		char name[32];
+
+		if ((1 << n_intf_no) & ~n_port_mask)
+			continue;
+
+		snprintf(name, sizeof(name), "ntnic%d", n_intf_no);
+
+		eth_dev = rte_eth_dev_allocate(name);
+
+		if (!eth_dev) {
+			NT_LOG_DBGX(ERR, NTNIC, "%s: %s: error=%d\n",
+				(pci_dev->name[0] ? pci_dev->name : "NA"), name, -1);
+			return -1;
+		}
+
+		NT_LOG_DBGX(DEBUG, NTNIC, "eth_dev %p, port_id %u, if_index %u\n",
+					eth_dev, eth_dev->data->port_id, n_intf_no);
+
+
+		struct rte_eth_link pmd_link;
+		pmd_link.link_speed = RTE_ETH_SPEED_NUM_NONE;
+		pmd_link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX;
+		pmd_link.link_status = RTE_ETH_LINK_DOWN;
+		pmd_link.link_autoneg = RTE_ETH_LINK_AUTONEG;
+
+		eth_dev->device = &pci_dev->device;
+		eth_dev->data->dev_link = pmd_link;
+		eth_dev->dev_ops = NULL;
+
+		eth_dev_pci_specific_init(eth_dev, pci_dev);
+		rte_eth_dev_probing_finish(eth_dev);
+	}
+
 	return 0;
 }
 
 static int
 nthw_pci_dev_deinit(struct rte_eth_dev *eth_dev __rte_unused)
 {
-	return 0;
+		NT_LOG_DBGX(DEBUG, NTNIC, "PCI device deinitialization\n");
+
+		int i;
+		char name[32];
+
+		struct pmd_internals *internals = eth_dev->data->dev_private;
+		ntdrv_4ga_t *p_ntdrv = &internals->p_drv->ntdrv;
+		fpga_info_t *fpga_info = &p_ntdrv->adapter_info.fpga_info;
+		const int n_phy_ports = fpga_info->n_phy_ports;
+		for (i = 0; i < n_phy_ports; i++) {
+			sprintf(name, "ntnic%d", i);
+			eth_dev = rte_eth_dev_allocated(name);
+			if (eth_dev == NULL)
+				continue; /* port already released */
+			rte_eth_dev_release_port(eth_dev);
+		}
+		return 0;
 }
 
 static int
 nthw_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	struct rte_pci_device *pci_dev)
 {
-	int ret;
-	ret = nthw_pci_dev_init(pci_dev);
-	return ret;
+	int res;
+
+	NT_LOG_DBGX(DEBUG, NTNIC, "pcidev: name: '%s'\n", pci_dev->name);
+	NT_LOG_DBGX(DEBUG, NTNIC, "devargs: name: '%s'\n", pci_dev->device.name);
+
+	if (pci_dev->device.devargs) {
+		NT_LOG_DBGX(DEBUG, NTNIC, "devargs: args: '%s'\n",
+			(pci_dev->device.devargs->args ? pci_dev->device.devargs->args : "NULL"));
+		NT_LOG_DBGX(DEBUG, NTNIC, "devargs: data: '%s'\n",
+			(pci_dev->device.devargs->data ? pci_dev->device.devargs->data : "NULL"));
+	}
+
+	const int n_rte_vfio_no_io_mmu_enabled = rte_vfio_noiommu_is_enabled();
+	NT_LOG(DBG, NTNIC, "vfio_no_iommu_enabled=%d\n", n_rte_vfio_no_io_mmu_enabled);
+
+	if (n_rte_vfio_no_io_mmu_enabled) {
+		NT_LOG(ERR, NTNIC, "vfio_no_iommu_enabled=%d: this PMD needs VFIO IOMMU\n",
+			n_rte_vfio_no_io_mmu_enabled);
+		return -1;
+	}
+
+	const enum rte_iova_mode n_rte_io_va_mode = rte_eal_iova_mode();
+	NT_LOG(DBG, NTNIC, "iova mode=%d\n", n_rte_io_va_mode);
+
+	NT_LOG(DBG, NTNIC,
+		"busid=" PCI_PRI_FMT
+		" pciid=%04x:%04x_%04x:%04x locstr=%s @ numanode=%d: drv=%s drvalias=%s\n",
+		pci_dev->addr.domain, pci_dev->addr.bus, pci_dev->addr.devid,
+		pci_dev->addr.function, pci_dev->id.vendor_id, pci_dev->id.device_id,
+		pci_dev->id.subsystem_vendor_id, pci_dev->id.subsystem_device_id,
+		pci_dev->name[0] ? pci_dev->name : "NA",
+		pci_dev->device.numa_node,
+		pci_dev->driver->driver.name ? pci_dev->driver->driver.name : "NA",
+		pci_dev->driver->driver.alias ? pci_dev->driver->driver.alias : "NA");
+
+
+	res = nthw_pci_dev_init(pci_dev);
+
+	NT_LOG_DBGX(DEBUG, NTNIC, "leave: res=%d\n", res);
+	return res;
 }
 
 static int
 nthw_pci_remove(struct rte_pci_device *pci_dev)
 {
+	NT_LOG_DBGX(DEBUG, NTNIC);
+
 	return rte_eth_dev_pci_generic_remove(pci_dev, nthw_pci_dev_deinit);
 }
 
Signature · 1 line
2.45.0
#168 lore raw

Re: [PATCH v8 03/21] net/ntnic: add minimal initialization for PCI device

Quoted 3 lines · Serhii Iliushyk

add implementation for probe/init and remove/deinit of the PCI device

<...>

drivers/net/ntnic/ntnic_ethdev.c static const struct rte_pci_id nthw_pci_id_map[] = { · line 76

Quoted 12 lines

static int
nthw_pci_dev_deinit(struct rte_eth_dev *eth_dev __rte_unused) {

drivers/net/ntnic/ntnic_ethdev.c +6 -1
-	return 0;
+		NT_LOG_DBGX(DEBUG, NTNIC, "PCI device deinitialization\n");
+
+		int i;
+		char name[32];
+
+		struct pmd_internals *internals = eth_dev->data->dev_private;

At this stage "struct pmd_internals" is not declerad yet, so I expect this commit will fail to build.
Can you please test build with each patch, and make sure all builds?

drivers/net/ntnic/ntnic_ethdev.c static const struct rte_pci_id nthw_pci_id_map[] = { · line 87

Quoted 12 lines
drivers/net/ntnic/ntnic_ethdev.c +11 -0
+		ntdrv_4ga_t *p_ntdrv = &internals->p_drv->ntdrv;
+		fpga_info_t *fpga_info = &p_ntdrv->adapter_info.fpga_info;
+		const int n_phy_ports = fpga_info->n_phy_ports;
+		for (i = 0; i < n_phy_ports; i++) {
+			sprintf(name, "ntnic%d", i);
+			eth_dev = rte_eth_dev_allocated(name);
+			if (eth_dev == NULL)
+				continue; /* port already released */
+			rte_eth_dev_release_port(eth_dev);
+		}
+		return 0;

There is double tab, please reduce indentation one level.

#169 lore raw

PATCH v8 4/21 net/ntnic: add NT utilities implementation

In reply to Serhii Iliushyk

Add ntnic utilities.

---
v6
* NT utils header file was moved

---
 drivers/net/ntnic/meson.build      |  2 ++
 drivers/net/ntnic/ntnic_ethdev.c   |  2 ++
 drivers/net/ntnic/ntutil/nt_util.c | 33 +++++++++++++++++++++++
 drivers/net/ntnic/ntutil/nt_util.h | 43 ++++++++++++++++++++++++++++++
 4 files changed, 80 insertions(+)
 create mode 100644 drivers/net/ntnic/ntutil/nt_util.c
 create mode 100644 drivers/net/ntnic/ntutil/nt_util.h
drivers/net/ntnic/meson.build +2 -0
index 80f0f3eecf..c7f5a4efc7 100644
@@ -11,10 +11,12 @@ endif
 includes = [
     include_directories('.'),
     include_directories('ntlog'),
+    include_directories('ntutil'),
 ]
 
 # all sources
 sources = files(
     'ntlog/ntlog.c',
+    'ntutil/nt_util.c',
     'ntnic_ethdev.c',
 )
drivers/net/ntnic/ntnic_ethdev.c +2 -0
index a744f78adb..26700eba6c 100644
@@ -10,6 +10,8 @@
 
 #include "ntlog.h"
 
+#include "nt_util.h"
+
 static const struct rte_pci_id nthw_pci_id_map[] = {
 	{
 		.vendor_id = 0,
drivers/net/ntnic/ntutil/nt_util.c new file +33 -0
new file mode 100644
index 0000000000..5395bf6993
@@ -0,0 +1,33 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <inttypes.h>
+#include <assert.h>
+
+#include <rte_ethdev.h>
+#include <rte_malloc.h>
+
+#include "ntlog.h"
+#include "nt_util.h"
+
+/* uses usleep which schedules out the calling thread */
+void nt_os_wait_usec(int val)
+{
+	rte_delay_us_sleep(val);
+}
+
+uint64_t nt_os_get_time_monotonic_counter(void)
+{
+	return rte_get_timer_cycles();
+}
+
+/* Allocation size matching minimum alignment of specified size */
+uint64_t nt_util_align_size(uint64_t size)
+{
+	return 1 << rte_log2_u64(size);
+}
drivers/net/ntnic/ntutil/nt_util.h new file +43 -0

43 lines not on this page · raw message

Signature · 1 line
2.45.0
#170 lore raw

PATCH v8 5/21 net/ntnic: add VFIO module

In reply to Serhii Iliushyk

Adds VFIO functionality and the DMA it requires. The VFIO context is initialized during ntnic ethdev startup.

---
 drivers/net/ntnic/meson.build      |   1 +
 drivers/net/ntnic/ntnic_ethdev.c   |  23 +++
 drivers/net/ntnic/ntnic_vfio.c     | 235 +++++++++++++++++++++++++++++
 drivers/net/ntnic/ntnic_vfio.h     |  29 ++++
 drivers/net/ntnic/ntutil/nt_util.c |  65 ++++++++
 5 files changed, 353 insertions(+)
 create mode 100644 drivers/net/ntnic/ntnic_vfio.c
 create mode 100644 drivers/net/ntnic/ntnic_vfio.h
drivers/net/ntnic/meson.build +1 -0
index c7f5a4efc7..bf86a0a098 100644
@@ -18,5 +18,6 @@ includes = [
 sources = files(
     'ntlog/ntlog.c',
     'ntutil/nt_util.c',
+    'ntnic_vfio.c',
     'ntnic_ethdev.c',
 )
drivers/net/ntnic/ntnic_ethdev.c +23 -0
index 26700eba6c..184bb43d92 100644
@@ -8,10 +8,18 @@
 #include <rte_bus_pci.h>
 #include <ethdev_pci.h>
 
+#include <rte_kvargs.h>
+#include <rte_eal.h>
+#include <rte_dev.h>
+#include <rte_vfio.h>
+
 #include "ntlog.h"
 
+#include "ntnic_vfio.h"
 #include "nt_util.h"
 
+#define EXCEPTION_PATH_HID 0
+
 static const struct rte_pci_id nthw_pci_id_map[] = {
 	{
 		.vendor_id = 0,
@@ -21,12 +29,24 @@ static const struct rte_pci_id nthw_pci_id_map[] = {
 static int
 nthw_pci_dev_init(struct rte_pci_device *pci_dev)
 {
+	nt_vfio_init();
+
 	uint32_t n_port_mask = -1;	/* All ports enabled by default */
 	int n_phy_ports;
 	NT_LOG_DBGX(DEBUG, NTNIC, "Dev %s PF #%i Init : %02x:%02x:%i\n", pci_dev->name,
 		pci_dev->addr.function, pci_dev->addr.bus, pci_dev->addr.devid,
 		pci_dev->addr.function);
 
+
+	/* Setup VFIO context */
+	int vfio = nt_vfio_setup(pci_dev);
+
+	if (vfio < 0) {
+		NT_LOG_DBGX(ERR, TNIC, "%s: vfio_setup error %d\n",
+			(pci_dev->name[0] ? pci_dev->name : "NA"), -1);
+		return -1;
+	}
+
 	n_phy_ports = 0;
 
 	for (int n_intf_no = 0; n_intf_no < n_phy_ports; n_intf_no++) {
@@ -86,6 +106,8 @@ nthw_pci_dev_deinit(struct rte_eth_dev *eth_dev __rte_unused)
 				continue; /* port already released */
 			rte_eth_dev_release_port(eth_dev);
 		}
+
+		nt_vfio_remove(EXCEPTION_PATH_HID);
 		return 0;
 }
 
@@ -150,3 +172,4 @@ static struct rte_pci_driver rte_nthw_pmd = {
 };
 
 RTE_PMD_REGISTER_PCI(net_ntnic, rte_nthw_pmd);
+RTE_PMD_REGISTER_KMOD_DEP(net_ntnic, "* vfio-pci");
drivers/net/ntnic/ntnic_vfio.c new file +235 -0

235 lines not on this page · raw message

drivers/net/ntnic/ntnic_vfio.h new file +29 -0
new file mode 100644
index 0000000000..69fef7923d
@@ -0,0 +1,29 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef _NTNIC_VFIO_H_
+#define _NTNIC_VFIO_H_
+
+#include <rte_dev.h>
+#include <rte_bus_pci.h>
+#include <ethdev_pci.h>
+
+void
+nt_vfio_init(void);
+
+int
+nt_vfio_setup(struct rte_pci_device *dev);
+int
+nt_vfio_remove(int vf_num);
+
+int
+nt_vfio_dma_map(int vf_num, void *virt_addr, uint64_t *iova_addr, uint64_t size);
+int
+nt_vfio_dma_unmap(int vf_num, void *virt_addr, uint64_t iova_addr, uint64_t size);
+
+/* Find device (PF/VF) number from device address */
+int
+nt_vfio_vf_num(const struct rte_pci_device *dev);
+#endif	/* _NTNIC_VFIO_H_ */
drivers/net/ntnic/ntutil/nt_util.c +65 -0

74 lines not on this page · raw message

Signature · 1 line
2.45.0
#171 lore raw

PATCH v8 6/21 net/ntnic: add basic eth dev ops to ntnic

In reply to Serhii Iliushyk

Adds support for eth_dev configure, start, stop, close, and infos_get. The internal structs of ntnic is also added and initialized.

---
v6
* Replace if_index with n_intf_no
* Unnecessry resources free was fixed
* Fix typo
* Useless vars were removed

---
 drivers/net/ntnic/include/ntdrv_4ga.h   |  17 ++
 drivers/net/ntnic/include/ntos_drv.h    |  32 ++++
 drivers/net/ntnic/include/ntos_system.h |  19 ++
 drivers/net/ntnic/meson.build           |   1 +
 drivers/net/ntnic/ntnic_ethdev.c        | 232 +++++++++++++++++++++++-
 5 files changed, 299 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/ntnic/include/ntdrv_4ga.h
 create mode 100644 drivers/net/ntnic/include/ntos_drv.h
 create mode 100644 drivers/net/ntnic/include/ntos_system.h
drivers/net/ntnic/include/ntdrv_4ga.h new file +17 -0
new file mode 100644
index 0000000000..bcb7ddc242
@@ -0,0 +1,17 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef __NTDRV_4GA_H__
+#define __NTDRV_4GA_H__
+
+
+typedef struct ntdrv_4ga_s {
+	uint32_t pciident;
+	char *p_drv_name;
+
+	volatile bool b_shutdown;
+} ntdrv_4ga_t;
+
+#endif	/* __NTDRV_4GA_H__ */
drivers/net/ntnic/include/ntos_drv.h new file +32 -0
new file mode 100644
index 0000000000..fa12d8f328
@@ -0,0 +1,32 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef __NTOS_DRV_H__
+#define __NTOS_DRV_H__
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <inttypes.h>
+
+#include <rte_ether.h>
+
+#define NUM_MAC_ADDRS_PER_PORT (16U)
+#define NUM_MULTICAST_ADDRS_PER_PORT (16U)
+
+#define NUM_ADAPTER_MAX (8)
+#define NUM_ADAPTER_PORTS_MAX (128)
+
+struct pmd_internals {
+	const struct rte_pci_device *pci_dev;
+	char name[20];
+	int n_intf_no;
+	uint32_t port;
+	uint32_t port_id;
+	struct drv_s *p_drv;
+	struct pmd_internals *next;
+};
+
+#endif	/* __NTOS_DRV_H__ */
drivers/net/ntnic/include/ntos_system.h new file +19 -0
new file mode 100644
index 0000000000..01f1dc65f4
@@ -0,0 +1,19 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef __NTOS_SYSTEM_H__
+#define __NTOS_SYSTEM_H__
+
+#include "ntdrv_4ga.h"
+
+struct drv_s {
+	int adapter_no;
+	struct rte_pci_device *p_dev;
+	struct ntdrv_4ga_s ntdrv;
+
+	int n_eth_dev_init_count;
+};
+
+#endif	/* __NTOS_SYSTEM_H__ */
drivers/net/ntnic/meson.build +1 -0
index bf86a0a098..f372b0c3cf 100644
@@ -10,6 +10,7 @@ endif
 # includes
 includes = [
     include_directories('.'),
+    include_directories('include'),
     include_directories('ntlog'),
     include_directories('ntutil'),
 ]
drivers/net/ntnic/ntnic_ethdev.c +230 -2

294 lines not on this page · raw message

Signature · 1 line
2.45.0
#172 lore raw

Re: [PATCH v8 06/21] net/ntnic: add basic eth dev ops to ntnic

Quoted 10 lines · Serhii Iliushyk

Adds support for eth_dev configure, start, stop, close, and infos_get. The internal structs of ntnic is also added and initialized.

---
v6
* Replace if_index with n_intf_no
* Unnecessry resources free was fixed
* Fix typo
* Useless vars were removed

<...>

drivers/net/ntnic/ntnic_ethdev.c static const struct rte_pci_id nthw_pci_id_map[] = { · line 106

Quoted 8 lines
drivers/net/ntnic/ntnic_ethdev.c +7 -0
+
+static int
+eth_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *dev_info)
+{
+	struct pmd_internals *internals = (struct pmd_internals *)eth_dev->data->dev_private;
+
+	dev_info->if_index = internals->n_intf_no;

I commented on this before, but 'if_index' is not a valid field for physical devices, so it is wrong to set it.

What is the intention to set this value?

<...>

drivers/net/ntnic/ntnic_ethdev.c static const struct rte_pci_id nthw_pci_id_map[] = { · line 138

Quoted 8 lines
drivers/net/ntnic/ntnic_ethdev.c +7 -0
+static int
+eth_dev_stop(struct rte_eth_dev *eth_dev)
+{
+	struct pmd_internals *internals = (struct pmd_internals *)eth_dev->data->dev_private;
+
+	NT_LOG_DBGX(DEBUG, NTNIC, "Port %u, %u\n",
+		internals->n_intf_no, internals->n_intf_no);

Why same value, 'n_intf_no', logged twice?

Btw, log says "Port", and "struct pmd_internals" has 'port_id' field but it prints 'n_intf_no', is this intentionally?

"struct pmd_internals" has "int n_intf_no", "uint32_t port", "uint32_t port_id", are these redundant fields?

<...>

drivers/net/ntnic/ntnic_ethdev.c static const struct rte_pci_id nthw_pci_id_map[] = { · line 190

Quoted 9 lines
drivers/net/ntnic/ntnic_ethdev.c +8 -0
+
+static struct eth_dev_ops nthw_eth_dev_ops = {
+	.dev_configure = eth_dev_configure,
+	.dev_start = eth_dev_start,
+	.dev_stop = eth_dev_stop,
+	.dev_close = eth_dev_close,
+	.dev_infos_get = eth_dev_infos_get,
+};

This struct can be 'const'.

<...>

Quoted 12 lines
drivers/net/ntnic/ntnic_ethdev.c +8 -0
@@ -58,6 +252,31 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev)
 
 		snprintf(name, sizeof(name), "ntnic%d", n_intf_no);
 
+		internals = rte_zmalloc_socket(name, sizeof(struct pmd_internals),
+				RTE_CACHE_LINE_SIZE, pci_dev->device.numa_node);
+
+		if (!internals) {
+			NT_LOG_DBGX(ERR, NTNIC, "%s: %s: error=%d\n",
+				(pci_dev->name[0] ? pci_dev->name : "NA"), name, -1);
+			return -1;
+		}

drivers/net/ntnic/ntnic_ethdev.c nthw_pci_dev_init(struct rte_pci_device *pci_dev) · line 272

Quoted 10 lines
drivers/net/ntnic/ntnic_ethdev.c +9 -0
+
+		internals->pci_dev = pci_dev;
+		internals->n_intf_no = n_intf_no;
+
+		/* Setup queue_ids */
+		if (nb_rx_queues > 1) {
+			NT_LOG(DBG, NTNIC,
+				"(%i) NTNIC configured with Rx multi queues. %i queues\n",
+				0 /*port*/, nb_rx_queues);
 

What is hardcoded '0' for "(%i) NTNIC ..."

And normally number of Rx/Tx queues set by user via 'rte_eth_dev_configure()' API, this initialization has queue numbers hardcoded as '1'. I assume this is for this initial version wher configure support is missing, but just reminding here in any case.

Quoted 12 lines
drivers/net/ntnic/ntnic_ethdev.c +8 -0
+		}
+
+		if (nb_tx_queues > 1) {
+			NT_LOG(DBG, NTNIC,
+				"(%i) NTNIC configured with Tx multi queues. %i queues\n",
+				0 /*port*/, nb_tx_queues);
+		}
+
 		eth_dev = rte_eth_dev_allocate(name);
 
drivers/net/ntnic/ntnic_ethdev.c +0 -0
 		if (!eth_dev) {

drivers/net/ntnic/ntnic_ethdev.c nthw_pci_dev_init(struct rte_pci_device *pci_dev) · line 289

Quoted 6 lines
drivers/net/ntnic/ntnic_ethdev.c +1 -1
@@ -66,9 +285,14 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev)
 			return -1;
 		}
 
-		NT_LOG_DBGX(DEBUG, NTNIC, "eth_dev %p, port_id %u, if_index %u\n",
+		NT_LOG_DBGX(DEBUG, NTNIC, "eth_dev %p, port_id %u, n_intf_no %u\n",
 

Is above change intentional? Why not add the log correct at first place instead of updating it here?

#173 lore raw

PATCH v8 7/21 net/ntnic: add core platform structures

In reply to Serhii Iliushyk

Adds many of the high level structures needed by the ntnic FPGA modules and adapter control.
This is considered the first part of the skeleton of ntnic FPGA support

---
 drivers/net/ntnic/include/ntos_drv.h       |  2 +
 drivers/net/ntnic/meson.build              |  2 +
 drivers/net/ntnic/nthw/nthw_drv.h          | 88 ++++++++++++++++++++++
 drivers/net/ntnic/nthw/nthw_platform.c     | 14 ++++
 drivers/net/ntnic/nthw/nthw_platform_drv.h | 21 ++++++
 5 files changed, 127 insertions(+)
 create mode 100644 drivers/net/ntnic/nthw/nthw_drv.h
 create mode 100644 drivers/net/ntnic/nthw/nthw_platform.c
 create mode 100644 drivers/net/ntnic/nthw/nthw_platform_drv.h
drivers/net/ntnic/include/ntos_drv.h +2 -0
index fa12d8f328..e3d8ffb91c 100644
@@ -13,6 +13,8 @@
 
 #include <rte_ether.h>
 
+#include "nthw_drv.h"
+
 #define NUM_MAC_ADDRS_PER_PORT (16U)
 #define NUM_MULTICAST_ADDRS_PER_PORT (16U)
 
drivers/net/ntnic/meson.build +2 -0
index f372b0c3cf..73c4188da0 100644
@@ -13,10 +13,12 @@ includes = [
     include_directories('include'),
     include_directories('ntlog'),
     include_directories('ntutil'),
+    include_directories('nthw'),
 ]
 
 # all sources
 sources = files(
+    'nthw/nthw_platform.c',
     'ntlog/ntlog.c',
     'ntutil/nt_util.c',
     'ntnic_vfio.c',
drivers/net/ntnic/nthw/nthw_drv.h new file +88 -0

88 lines not on this page · raw message

drivers/net/ntnic/nthw/nthw_platform.c new file +14 -0
new file mode 100644
index 0000000000..181330dd37
@@ -0,0 +1,14 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#include "nthw_platform_drv.h"
+
+nthw_adapter_id_t nthw_platform_get_nthw_adapter_id(const uint16_t n_pci_device_id)
+{
+	switch (n_pci_device_id) {
+	default:
+		return NT_HW_ADAPTER_ID_UNKNOWN;
+	}
+}
drivers/net/ntnic/nthw/nthw_platform_drv.h new file +21 -0
new file mode 100644
index 0000000000..ab26d8149a
@@ -0,0 +1,21 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef __NTHW_PLATFORM_DRV_H__
+#define __NTHW_PLATFORM_DRV_H__
+
+#include <stdint.h>
+
+#define NT_HW_PCI_VENDOR_ID (0x18f4)
+
+enum nthw_adapter_id_e {
+	NT_HW_ADAPTER_ID_UNKNOWN = 0,
+};
+
+typedef enum nthw_adapter_id_e nthw_adapter_id_t;
+
+nthw_adapter_id_t nthw_platform_get_nthw_adapter_id(const uint16_t n_pci_device_id);
+
+#endif	/* __NTHW_PLATFORM_DRV_H__ */
Signature · 1 line
2.45.0
#174 lore raw

PATCH v8 8/21 net/ntnic: add adapter initialization

In reply to Serhii Iliushyk

Add interfaces for initialize the adapter

---
v6
* Function for global var clearing was removed

---
 drivers/net/ntnic/adapter/nt4ga_adapter.c | 148 ++++++++++++++++++++++
 drivers/net/ntnic/include/nt4ga_adapter.h |  40 ++++++
 drivers/net/ntnic/include/ntdrv_4ga.h     |   2 +
 drivers/net/ntnic/meson.build             |   2 +
 drivers/net/ntnic/ntnic_ethdev.c          |  89 ++++++++++---
 drivers/net/ntnic/ntnic_mod_reg.c         |  20 +++
 drivers/net/ntnic/ntnic_mod_reg.h         |  27 ++++
 7 files changed, 310 insertions(+), 18 deletions(-)
 create mode 100644 drivers/net/ntnic/adapter/nt4ga_adapter.c
 create mode 100644 drivers/net/ntnic/include/nt4ga_adapter.h
 create mode 100644 drivers/net/ntnic/ntnic_mod_reg.c
 create mode 100644 drivers/net/ntnic/ntnic_mod_reg.h
drivers/net/ntnic/adapter/nt4ga_adapter.c new file +148 -0
new file mode 100644
index 0000000000..7cc3841ecf
@@ -0,0 +1,148 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#include <rte_thread.h>
+
+#include "ntlog.h"
+#include "nt_util.h"
+#include "ntnic_mod_reg.h"
+
+static int nt4ga_adapter_show_info(struct adapter_info_s *p_adapter_info, FILE *pfh)
+{
+	const char *const p_dev_name = p_adapter_info->p_dev_name;
+	const char *const p_adapter_id_str = p_adapter_info->mp_adapter_id_str;
+	fpga_info_t *p_fpga_info = &p_adapter_info->fpga_info;
+	hw_info_t *p_hw_info = &p_adapter_info->hw_info;
+	char a_pci_ident_str[32];
+
+	snprintf(a_pci_ident_str, sizeof(a_pci_ident_str), PCIIDENT_PRINT_STR,
+		PCIIDENT_TO_DOMAIN(p_fpga_info->pciident),
+		PCIIDENT_TO_BUSNR(p_fpga_info->pciident),
+		PCIIDENT_TO_DEVNR(p_fpga_info->pciident),
+		PCIIDENT_TO_FUNCNR(p_fpga_info->pciident));
+
+	fprintf(pfh, "%s: DeviceName: %s\n", p_adapter_id_str, (p_dev_name ? p_dev_name : "NA"));
+	fprintf(pfh, "%s: PCI Details:\n", p_adapter_id_str);
+	fprintf(pfh, "%s: %s: %08X: %04X:%04X %04X:%04X\n", p_adapter_id_str, a_pci_ident_str,
+		p_fpga_info->pciident, p_hw_info->pci_vendor_id, p_hw_info->pci_device_id,
+		p_hw_info->pci_sub_vendor_id, p_hw_info->pci_sub_device_id);
+	fprintf(pfh, "%s: FPGA Details:\n", p_adapter_id_str);
+	fprintf(pfh, "%s: %03d-%04d-%02d-%02d [%016" PRIX64 "] (%08X)\n", p_adapter_id_str,
+		p_fpga_info->n_fpga_type_id, p_fpga_info->n_fpga_prod_id,
+		p_fpga_info->n_fpga_ver_id, p_fpga_info->n_fpga_rev_id, p_fpga_info->n_fpga_ident,
+		p_fpga_info->n_fpga_build_time);
+	fprintf(pfh, "%s: FpgaDebugMode=0x%x\n", p_adapter_id_str, p_fpga_info->n_fpga_debug_mode);
+	fprintf(pfh, "%s: Hw=0x%02X_rev%d: %s\n", p_adapter_id_str, p_hw_info->hw_platform_id,
+		p_fpga_info->nthw_hw_info.hw_id, p_fpga_info->nthw_hw_info.hw_plat_id_str);
+	fprintf(pfh, "%s: MCU Details:\n", p_adapter_id_str);
+
+
+	return 0;
+}
+
+static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info)
+{
+	char *const p_dev_name = malloc(24);
+	char *const p_adapter_id_str = malloc(24);
+	fpga_info_t *fpga_info = &p_adapter_info->fpga_info;
+	hw_info_t *p_hw_info = &p_adapter_info->hw_info;
+
+
+	p_hw_info->n_nthw_adapter_id = nthw_platform_get_nthw_adapter_id(p_hw_info->pci_device_id);
+
+	fpga_info->n_nthw_adapter_id = p_hw_info->n_nthw_adapter_id;
+	/* ref: DN-0060 section 9 */
+	p_hw_info->hw_product_type = p_hw_info->pci_device_id & 0x000f;
+	/* ref: DN-0060 section 9 */
+	p_hw_info->hw_platform_id = (p_hw_info->pci_device_id >> 4) & 0x00ff;
+	/* ref: DN-0060 section 9 */
+	p_hw_info->hw_reserved1 = (p_hw_info->pci_device_id >> 12) & 0x000f;
+
+	/* mp_dev_name */
+	p_adapter_info->p_dev_name = p_dev_name;
+
+	if (p_dev_name) {
+		snprintf(p_dev_name, 24, PCIIDENT_PRINT_STR,
+			PCIIDENT_TO_DOMAIN(p_adapter_info->fpga_info.pciident),
+			PCIIDENT_TO_BUSNR(p_adapter_info->fpga_info.pciident),
+			PCIIDENT_TO_DEVNR(p_adapter_info->fpga_info.pciident),
+			PCIIDENT_TO_FUNCNR(p_adapter_info->fpga_info.pciident));
+		NT_LOG(DBG, NTNIC, "%s: (0x%08X)\n", p_dev_name,
+			p_adapter_info->fpga_info.pciident);
+	}
+
+	/* mp_adapter_id_str */
+	p_adapter_info->mp_adapter_id_str = p_adapter_id_str;
+
+	p_adapter_info->fpga_info.mp_adapter_id_str = p_adapter_id_str;
+
+	if (p_adapter_id_str) {
+		snprintf(p_adapter_id_str, 24, "PCI:" PCIIDENT_PRINT_STR,
+			PCIIDENT_TO_DOMAIN(p_adapter_info->fpga_info.pciident),
+			PCIIDENT_TO_BUSNR(p_adapter_info->fpga_info.pciident),
+			PCIIDENT_TO_DEVNR(p_adapter_info->fpga_info.pciident),
+			PCIIDENT_TO_FUNCNR(p_adapter_info->fpga_info.pciident));
+		NT_LOG(DBG, NTNIC, "%s: %s\n", p_adapter_id_str, p_dev_name);
+	}
+
+	{
+		int i;
+
+		for (i = 0; i < (int)ARRAY_SIZE(p_adapter_info->mp_port_id_str); i++) {
+			char *p = malloc(32);
+
+			if (p) {
+				snprintf(p, 32, "%s:intf_%d",
+					(p_adapter_id_str ? p_adapter_id_str : "NA"), i);
+			}
+
+			p_adapter_info->mp_port_id_str[i] = p;
+		}
+	}
+
+	return 0;
+}
+
+static int nt4ga_adapter_deinit(struct adapter_info_s *p_adapter_info)
+{
+	fpga_info_t *fpga_info = &p_adapter_info->fpga_info;
+	int i;
+	int res = -1;
+
+
+	/* Free adapter port ident strings */
+	for (i = 0; i < fpga_info->n_phy_ports; i++) {
+		if (p_adapter_info->mp_port_id_str[i]) {
+			free(p_adapter_info->mp_port_id_str[i]);
+			p_adapter_info->mp_port_id_str[i] = NULL;
+		}
+	}
+
+	/* Free adapter ident string */
+	if (p_adapter_info->mp_adapter_id_str) {
+		free(p_adapter_info->mp_adapter_id_str);
+		p_adapter_info->mp_adapter_id_str = NULL;
+	}
+
+	/* Free devname ident string */
+	if (p_adapter_info->p_dev_name) {
+		free(p_adapter_info->p_dev_name);
+		p_adapter_info->p_dev_name = NULL;
+	}
+
+	return res;
+}
+
+static const struct adapter_ops ops = {
+	.init = nt4ga_adapter_init,
+	.deinit = nt4ga_adapter_deinit,
+
+	.show_info = nt4ga_adapter_show_info,
+};
+
+void adapter_init(void)
+{
+	register_adapter_ops(&ops);
+}
drivers/net/ntnic/include/nt4ga_adapter.h new file +40 -0
new file mode 100644
index 0000000000..2c72583caf
@@ -0,0 +1,40 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef _NT4GA_ADAPTER_H_
+#define _NT4GA_ADAPTER_H_
+
+#include "ntos_drv.h"
+typedef struct hw_info_s {
+	/* pciids */
+	uint16_t pci_vendor_id;
+	uint16_t pci_device_id;
+	uint16_t pci_sub_vendor_id;
+	uint16_t pci_sub_device_id;
+	uint16_t pci_class_id;
+
+	/* Derived from pciid */
+	nthw_adapter_id_t n_nthw_adapter_id;
+	int hw_platform_id;
+	int hw_product_type;
+	int hw_reserved1;
+} hw_info_t;
+
+typedef struct adapter_info_s {
+	struct hw_info_s hw_info;
+	struct fpga_info_s fpga_info;
+
+	char *mp_port_id_str[NUM_ADAPTER_PORTS_MAX];
+	char *mp_adapter_id_str;
+	char *p_dev_name;
+	volatile bool *pb_shutdown;
+
+	int adapter_no;
+	int n_rx_host_buffers;
+	int n_tx_host_buffers;
+} adapter_info_t;
+
+
+#endif	/* _NT4GA_ADAPTER_H_ */
drivers/net/ntnic/include/ntdrv_4ga.h +2 -0
index bcb7ddc242..8017aa4fc3 100644
@@ -6,9 +6,11 @@
 #ifndef __NTDRV_4GA_H__
 #define __NTDRV_4GA_H__
 
+#include "nt4ga_adapter.h"
 
 typedef struct ntdrv_4ga_s {
 	uint32_t pciident;
+	struct adapter_info_s adapter_info;
 	char *p_drv_name;
 
 	volatile bool b_shutdown;
drivers/net/ntnic/meson.build +2 -0
index 73c4188da0..94f24e09e3 100644
@@ -18,9 +18,11 @@ includes = [
 
 # all sources
 sources = files(
+    'adapter/nt4ga_adapter.c',
     'nthw/nthw_platform.c',
     'ntlog/ntlog.c',
     'ntutil/nt_util.c',
+    'ntnic_mod_reg.c',
     'ntnic_vfio.c',
     'ntnic_ethdev.c',
 )
drivers/net/ntnic/ntnic_ethdev.c +71 -18

146 lines not on this page · raw message

drivers/net/ntnic/ntnic_mod_reg.c new file +20 -0
new file mode 100644
index 0000000000..006221bbe3
@@ -0,0 +1,20 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#include "ntnic_mod_reg.h"
+
+static const struct adapter_ops *adapter_ops;
+
+void register_adapter_ops(const struct adapter_ops *ops)
+{
+	adapter_ops = ops;
+}
+
+const struct adapter_ops *get_adapter_ops(void)
+{
+	if (adapter_ops == NULL)
+		adapter_init();
+	return adapter_ops;
+}
drivers/net/ntnic/ntnic_mod_reg.h new file +27 -0
new file mode 100644
index 0000000000..48a9f8f7b9
@@ -0,0 +1,27 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef __NTNIC_MOD_REG_H__
+#define __NTNIC_MOD_REG_H__
+
+#include <stdint.h>
+#include "nthw_platform_drv.h"
+#include "nthw_drv.h"
+#include "nt4ga_adapter.h"
+#include "ntos_drv.h"
+
+struct adapter_ops {
+	int (*init)(struct adapter_info_s *p_adapter_info);
+	int (*deinit)(struct adapter_info_s *p_adapter_info);
+
+	int (*show_info)(struct adapter_info_s *p_adapter_info, FILE *pfh);
+};
+
+void register_adapter_ops(const struct adapter_ops *ops);
+const struct adapter_ops *get_adapter_ops(void);
+void adapter_init(void);
+
+
+#endif	/* __NTNIC_MOD_REG_H__ */
Signature · 1 line
2.45.0
#175 lore raw

PATCH v8 9/21 net/ntnic: add registers and FPGA model for NapaTech NIC

In reply to Serhii Iliushyk

The NTNIC PMD does not rely on a kernel space Napatech driver, thus all defines related to the register layout is part of the PMD code, which will be added in later commits.

---
v6
* Remove unnecessary comments
* Remove EOF markers and Auto-gen comments

---
 drivers/net/ntnic/include/fpga_model.h        |  102 ++
 drivers/net/ntnic/meson.build                 |    4 +
 .../net/ntnic/nthw/model/nthw_fpga_model.c    | 1192 ++++++++++++++++
 .../net/ntnic/nthw/model/nthw_fpga_model.h    |  245 ++++
 drivers/net/ntnic/nthw/nthw_register.h        |   21 +
 .../supported/nthw_fpga_9563_055_039_0000.c   | 1225 +++++++++++++++++
 .../nthw/supported/nthw_fpga_instances.c      |    4 +
 .../nthw/supported/nthw_fpga_instances.h      |    5 +
 .../ntnic/nthw/supported/nthw_fpga_mod_defs.h |   28 +
 .../nthw/supported/nthw_fpga_mod_str_map.c    |   19 +
 .../nthw/supported/nthw_fpga_mod_str_map.h    |    9 +
 .../nthw/supported/nthw_fpga_param_defs.h     |  224 +++
 .../ntnic/nthw/supported/nthw_fpga_reg_defs.h |   27 +
 .../nthw/supported/nthw_fpga_reg_defs_gfg.h   |  118 ++
 .../nthw/supported/nthw_fpga_reg_defs_gmf.h   |   60 +
 .../supported/nthw_fpga_reg_defs_gpio_phy.h   |   40 +
 .../nthw/supported/nthw_fpga_reg_defs_hif.h   |   71 +
 .../nthw/supported/nthw_fpga_reg_defs_i2cm.h  |   30 +
 .../nthw/supported/nthw_fpga_reg_defs_iic.h   |   88 ++
 .../supported/nthw_fpga_reg_defs_mac_pcs.h    |  290 ++++
 .../supported/nthw_fpga_reg_defs_pci_rd_tg.h  |   29 +
 .../supported/nthw_fpga_reg_defs_pci_wr_tg.h  |   32 +
 .../nthw/supported/nthw_fpga_reg_defs_pcie3.h |  273 ++++
 .../nthw/supported/nthw_fpga_reg_defs_rac.h   |   64 +
 .../supported/nthw_fpga_reg_defs_rst9563.h    |   51 +
 .../nthw/supported/nthw_fpga_reg_defs_sdc.h   |   36 +
 drivers/net/ntnic/ntnic_ethdev.c              |    1 +
 27 files changed, 4288 insertions(+)
 create mode 100644 drivers/net/ntnic/include/fpga_model.h
 create mode 100644 drivers/net/ntnic/nthw/model/nthw_fpga_model.c
 create mode 100644 drivers/net/ntnic/nthw/model/nthw_fpga_model.h
 create mode 100644 drivers/net/ntnic/nthw/nthw_register.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_9563_055_039_0000.c
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_instances.c
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_instances.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_mod_defs.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_mod_str_map.c
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_mod_str_map.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_param_defs.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_gfg.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_gmf.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_gpio_phy.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_hif.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_i2cm.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_iic.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_mac_pcs.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_pci_rd_tg.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_pci_wr_tg.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_pcie3.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_rac.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_rst9563.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_sdc.h
drivers/net/ntnic/include/fpga_model.h new file +102 -0
new file mode 100644
index 0000000000..d73cf168ed
@@ -0,0 +1,102 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef _FPGA_MODEL_H_
+#define _FPGA_MODEL_H_
+
+#include <unistd.h>
+#include <stdint.h>
+#include <inttypes.h>
+
+typedef uint32_t nthw_id_t;
+
+enum nthw_fpga_bus_type {
+	NTHW_FPGA_BUS_TYPE_UNKNOWN =
+		0,	/* Unknown/uninitialized - keep this as the first enum element */
+	NTHW_FPGA_BUS_TYPE_BAR,
+	NTHW_FPGA_BUS_TYPE_PCI,
+	NTHW_FPGA_BUS_TYPE_CCIP,
+	NTHW_FPGA_BUS_TYPE_RAB0,
+	NTHW_FPGA_BUS_TYPE_RAB1,
+	NTHW_FPGA_BUS_TYPE_RAB2,
+	NTHW_FPGA_BUS_TYPE_NMB,
+	NTHW_FPGA_BUS_TYPE_NDM,
+	NTHW_FPGA_BUS_TYPE_SPI0,
+	NTHW_FPGA_BUS_TYPE_SPI = NTHW_FPGA_BUS_TYPE_SPI0,
+};
+
+typedef enum nthw_fpga_bus_type nthw_fpga_bus_type_e;
+
+enum nthw_fpga_register_type {
+	NTHW_FPGA_REG_TYPE_UNKNOWN =
+		0,	/* Unknown/uninitialized - keep this as the first enum element */
+	NTHW_FPGA_REG_TYPE_RW,
+	NTHW_FPGA_REG_TYPE_RO,
+	NTHW_FPGA_REG_TYPE_WO,
+	NTHW_FPGA_REG_TYPE_RC1,
+	NTHW_FPGA_REG_TYPE_MIXED,
+};
+
+typedef enum nthw_fpga_register_type nthw_fpga_register_type_e;
+
+struct nthw_fpga_field_init {
+	nthw_id_t id;
+	uint16_t bw;
+	uint16_t low;
+	uint64_t reset_val;
+};
+
+typedef struct nthw_fpga_field_init nthw_fpga_field_init_s;
+
+struct nthw_fpga_register_init {
+	nthw_id_t id;
+	uint32_t addr_rel;
+	uint16_t bw;
+	nthw_fpga_register_type_e type;
+	uint64_t reset_val;
+	int nb_fields;
+	struct nthw_fpga_field_init *fields;
+};
+
+typedef struct nthw_fpga_register_init nthw_fpga_register_init_s;
+
+struct nthw_fpga_module_init {
+	nthw_id_t id;
+	int instance;
+	nthw_id_t def_id;
+	int major_version;
+	int minor_version;
+	nthw_fpga_bus_type_e bus_id;
+	uint32_t addr_base;
+	int nb_registers;
+	struct nthw_fpga_register_init *registers;
+};
+
+typedef struct nthw_fpga_module_init nthw_fpga_module_init_s;
+
+struct nthw_fpga_prod_param {
+	const nthw_id_t id;
+	const int value;
+};
+
+typedef struct nthw_fpga_prod_param nthw_fpga_prod_param_s;
+
+struct nthw_fpga_prod_init {
+	int fpga_item_id;
+	int fpga_product_id;
+	int fpga_version;
+	int fpga_revision;
+	int fpga_patch_no;
+	int fpga_build_no;
+	uint32_t fpga_build_time;
+	int nb_prod_params;
+	struct nthw_fpga_prod_param *product_params;
+	int nb_modules;
+	struct nthw_fpga_module_init *modules;
+};
+
+typedef struct nthw_fpga_prod_init nthw_fpga_prod_init_s;
+
+#endif	/* _FPGA_MODEL_H_ */
drivers/net/ntnic/meson.build +4 -0
index 94f24e09e3..9d78e54470 100644
@@ -14,11 +14,15 @@ includes = [
     include_directories('ntlog'),
     include_directories('ntutil'),
     include_directories('nthw'),
+    include_directories('nthw/supported'),
 ]
 
 # all sources
 sources = files(
     'adapter/nt4ga_adapter.c',
+    'nthw/supported/nthw_fpga_9563_055_039_0000.c',
+    'nthw/supported/nthw_fpga_instances.c',
+    'nthw/supported/nthw_fpga_mod_str_map.c',
     'nthw/nthw_platform.c',
     'ntlog/ntlog.c',
     'ntutil/nt_util.c',
drivers/net/ntnic/nthw/model/nthw_fpga_model.c new file +1192 -0

1,192 lines not on this page · raw message

drivers/net/ntnic/nthw/model/nthw_fpga_model.h new file +245 -0

245 lines not on this page · raw message

drivers/net/ntnic/nthw/nthw_register.h new file +21 -0
new file mode 100644
index 0000000000..db006fcf72
@@ -0,0 +1,21 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef NTHW_REGISTER_H_
+#define NTHW_REGISTER_H_
+
+#include <unistd.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <inttypes.h>
+
+
+#include "fpga_model.h"
+
+#include "nthw_fpga_mod_defs.h"
+#include "nthw_fpga_param_defs.h"
+#include "nthw_fpga_reg_defs.h"
+
+#endif	/* NTHW_REGISTER_H_ */
drivers/net/ntnic/nthw/supported/nthw_fpga_9563_055_039_0000.c new file +1225 -0

1,225 lines not on this page · raw message

drivers/net/ntnic/nthw/supported/nthw_fpga_instances.c new file +4 -0
new file mode 100644
index 0000000000..ff6efc6e75
@@ -0,0 +1,4 @@
+
+
+#include "nthw_fpga_instances.h"
+nthw_fpga_prod_init_s *nthw_fpga_instances[] = { &nthw_fpga_9563_055_039_0000, NULL };
drivers/net/ntnic/nthw/supported/nthw_fpga_instances.h new file +5 -0
new file mode 100644
index 0000000000..05c0b94bbe
@@ -0,0 +1,5 @@
+
+
+#include "fpga_model.h"
+extern nthw_fpga_prod_init_s *nthw_fpga_instances[];
+extern nthw_fpga_prod_init_s nthw_fpga_9563_055_039_0000;
drivers/net/ntnic/nthw/supported/nthw_fpga_mod_defs.h new file +28 -0
new file mode 100644
index 0000000000..0c746f8f53
@@ -0,0 +1,28 @@
+/*
+ * nthw_fpga_mod_defs.h
+ *
+ * Auto-generated file - do *NOT* edit
+ *
+ */
+
+#ifndef _NTHW_FPGA_MOD_DEFS_H_
+#define _NTHW_FPGA_MOD_DEFS_H_
+
+#define MOD_UNKNOWN (0L)/* Unknown/uninitialized - keep this as the first element */
+#define MOD_GFG (0xfc423807UL)
+#define MOD_GMF (0x68b1d15aUL)
+#define MOD_GPIO_PHY (0xbbe81659UL)
+#define MOD_HIF (0x7815363UL)
+#define MOD_I2CM (0x93bc7780UL)
+#define MOD_IIC (0x7629cddbUL)
+#define MOD_MAC_PCS (0x7abe24c7UL)
+#define MOD_PCIE3 (0xfbc48c18UL)
+#define MOD_PCI_RD_TG (0x9ad9eed2UL)
+#define MOD_PCI_WR_TG (0x274b69e1UL)
+#define MOD_RAC (0xae830b42UL)
+#define MOD_RST9563 (0x385d6d1dUL)
+#define MOD_SDC (0xd2369530UL)
+#define MOD_IDX_COUNT (14)
+
+/* aliases - only aliases go below this point */
+#endif	/* _NTHW_FPGA_MOD_DEFS_H_ */
drivers/net/ntnic/nthw/supported/nthw_fpga_mod_str_map.c new file +19 -0
new file mode 100644
index 0000000000..d7bc686fe8
@@ -0,0 +1,19 @@
+
+
+#include "nthw_fpga_mod_str_map.h"
+const struct nthw_fpga_mod_str_s sa_nthw_fpga_mod_str_map[] = {
+	{ MOD_GFG, "GFG" },
+	{ MOD_GMF, "GMF" },
+	{ MOD_GPIO_PHY, "GPIO_PHY" },
+	{ MOD_HIF, "HIF" },
+	{ MOD_I2CM, "I2CM" },
+	{ MOD_IIC, "IIC" },
+	{ MOD_MAC_PCS, "MAC_PCS" },
+	{ MOD_PCIE3, "PCIE3" },
+	{ MOD_PCI_RD_TG, "PCI_RD_TG" },
+	{ MOD_PCI_WR_TG, "PCI_WR_TG" },
+	{ MOD_RAC, "RAC" },
+	{ MOD_RST9563, "RST9563" },
+	{ MOD_SDC, "SDC" },
+	{ 0UL, NULL }
+};
drivers/net/ntnic/nthw/supported/nthw_fpga_mod_str_map.h new file +9 -0
new file mode 100644
index 0000000000..13971d5d4e
@@ -0,0 +1,9 @@
+
+
+#include "nthw_fpga_mod_defs.h"
+#include "fpga_model.h"
+struct nthw_fpga_mod_str_s {
+	const nthw_id_t a;
+	const char *b;
+};
+extern const struct nthw_fpga_mod_str_s sa_nthw_fpga_mod_str_map[];
drivers/net/ntnic/nthw/supported/nthw_fpga_param_defs.h new file +224 -0

135 lines not on this page · raw message

drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs.h new file +27 -0
new file mode 100644
index 0000000000..aeb564349e

Lines of this file are not shown. View the raw message.

drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_gfg.h new file +118 -0

118 lines not on this page · raw message

drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_gmf.h new file +60 -0

60 lines not on this page · raw message

drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_gpio_phy.h new file +40 -0
new file mode 100644
index 0000000000..8d160af298

Lines of this file are not shown. View the raw message.

drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_hif.h new file +71 -0

71 lines not on this page · raw message

drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_i2cm.h new file +30 -0
new file mode 100644
index 0000000000..4ef618e2e1

Lines of this file are not shown. View the raw message.

drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_iic.h new file +88 -0

88 lines not on this page · raw message

drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_mac_pcs.h new file +290 -0

290 lines not on this page · raw message

drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_pci_rd_tg.h new file +29 -0
new file mode 100644
index 0000000000..4f8e41f261

Lines of this file are not shown. View the raw message.

drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_pci_wr_tg.h new file +32 -0
new file mode 100644
index 0000000000..59bb1b2613

Lines of this file are not shown. View the raw message.

drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_pcie3.h new file +273 -0

273 lines not on this page · raw message

drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_rac.h new file +64 -0

64 lines not on this page · raw message

drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_rst9563.h new file +51 -0

51 lines not on this page · raw message

drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_sdc.h new file +36 -0
new file mode 100644
index 0000000000..d9cfff4128

Lines of this file are not shown. View the raw message.

drivers/net/ntnic/ntnic_ethdev.c +1 -0
index c84321ed91..ab4b66f4a3 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.45.0

Part of the diff is not shown here. View the raw message.

#176 lore raw

PATCH v8 10/21 net/ntnic: add FPGA modules for initialization

In reply to Serhii Iliushyk

New ntnic FPGA modules:
- Host Interface (HIF): Basic FPGA info such as prod ID and build time.
- Inter-Integrated Circuit Controller (IIC): Use the FPGA to access the other integrated circuits on the ntnic.
- PCI Express Gen3 (PCIE3): The FPGA part of PCIe3 initialization, speed tests, and configuration.

---
v6
* Remove unnecessary comments

DVO: Remove unnecessary comments

---
 drivers/net/ntnic/adapter/nt4ga_adapter.c     |   2 -
 drivers/net/ntnic/meson.build                 |   1 +
 .../net/ntnic/nthw/core/include/nthw_core.h   |  16 +
 .../net/ntnic/nthw/core/include/nthw_hif.h    | 151 ++++
 .../net/ntnic/nthw/core/include/nthw_iic.h    | 100 +++
 .../net/ntnic/nthw/core/include/nthw_pcie3.h  |  96 +++
 drivers/net/ntnic/nthw/core/nthw_hif.c        | 312 +++++++
 drivers/net/ntnic/nthw/core/nthw_iic.c        | 527 ++++++++++++
 drivers/net/ntnic/nthw/core/nthw_pcie3.c      | 259 ++++++
 drivers/net/ntnic/nthw/nthw_drv.h             |   3 +-
 drivers/net/ntnic/nthw/nthw_rac.c             | 784 ++++++++++++++++++
 drivers/net/ntnic/nthw/nthw_rac.h             | 153 ++++
 12 files changed, 2400 insertions(+), 4 deletions(-)
 create mode 100644 drivers/net/ntnic/nthw/core/include/nthw_core.h
 create mode 100644 drivers/net/ntnic/nthw/core/include/nthw_hif.h
 create mode 100644 drivers/net/ntnic/nthw/core/include/nthw_iic.h
 create mode 100644 drivers/net/ntnic/nthw/core/include/nthw_pcie3.h
 create mode 100644 drivers/net/ntnic/nthw/core/nthw_hif.c
 create mode 100644 drivers/net/ntnic/nthw/core/nthw_iic.c
 create mode 100644 drivers/net/ntnic/nthw/core/nthw_pcie3.c
 create mode 100644 drivers/net/ntnic/nthw/nthw_rac.c
 create mode 100644 drivers/net/ntnic/nthw/nthw_rac.h
drivers/net/ntnic/adapter/nt4ga_adapter.c +0 -2
index 7cc3841ecf..c9f228a8ed 100644
@@ -60,7 +60,6 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info)
 	/* ref: DN-0060 section 9 */
 	p_hw_info->hw_reserved1 = (p_hw_info->pci_device_id >> 12) & 0x000f;
 
-	/* mp_dev_name */
 	p_adapter_info->p_dev_name = p_dev_name;
 
 	if (p_dev_name) {
@@ -73,7 +72,6 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info)
 			p_adapter_info->fpga_info.pciident);
 	}
 
-	/* mp_adapter_id_str */
 	p_adapter_info->mp_adapter_id_str = p_adapter_id_str;
 
 	p_adapter_info->fpga_info.mp_adapter_id_str = p_adapter_id_str;
drivers/net/ntnic/meson.build +1 -0
index 9d78e54470..5dd1beada2 100644
@@ -13,6 +13,7 @@ includes = [
     include_directories('include'),
     include_directories('ntlog'),
     include_directories('ntutil'),
+    include_directories('nthw/core/include'),
     include_directories('nthw'),
     include_directories('nthw/supported'),
 ]
drivers/net/ntnic/nthw/core/include/nthw_core.h new file +16 -0
new file mode 100644
index 0000000000..c2602e396f
@@ -0,0 +1,16 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef __NTHW_CORE_H__
+#define __NTHW_CORE_H__
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdint.h>
+
+#include "nthw_platform_drv.h"
+
+
+#endif	/* __NTHW_CORE_H__ */
drivers/net/ntnic/nthw/core/include/nthw_hif.h new file +151 -0

151 lines not on this page · raw message

drivers/net/ntnic/nthw/core/include/nthw_iic.h new file +100 -0

100 lines not on this page · raw message

drivers/net/ntnic/nthw/core/include/nthw_pcie3.h new file +96 -0

96 lines not on this page · raw message

drivers/net/ntnic/nthw/core/nthw_hif.c new file +312 -0

312 lines not on this page · raw message

drivers/net/ntnic/nthw/core/nthw_iic.c new file +527 -0

527 lines not on this page · raw message

drivers/net/ntnic/nthw/core/nthw_pcie3.c new file +259 -0

259 lines not on this page · raw message

drivers/net/ntnic/nthw/nthw_drv.h +1 -2
index 0b89a5c5a0..d7cd64bb1d 100644
@@ -6,8 +6,7 @@
 #ifndef __NTHW_DRV_H__
 #define __NTHW_DRV_H__
 
-#include <stddef.h>
-#include "nthw_platform_drv.h"
+#include "nthw_core.h"
 
 typedef enum nt_meta_port_type_e {
 	PORT_TYPE_PHYSICAL,
drivers/net/ntnic/nthw/nthw_rac.c new file +784 -0

784 lines not on this page · raw message

drivers/net/ntnic/nthw/nthw_rac.h new file +153 -0

153 lines not on this page · raw message

Signature · 1 line
2.45.0
#177 lore raw

Re: [PATCH v8 10/21] net/ntnic: add FPGA modules for initialization

Quoted 8 lines · Serhii Iliushyk

New ntnic FPGA modules:
- Host Interface (HIF): Basic FPGA info such as prod ID and build time.
- Inter-Integrated Circuit Controller (IIC): Use the FPGA to access the other integrated circuits on the ntnic.
- PCI Express Gen3 (PCIE3): The FPGA part of PCIe3 initialization, speed tests, and configuration.

<...>

Quoted 13 lines
drivers/net/ntnic/adapter/nt4ga_adapter.c +0 -1
index 7cc3841ecf..c9f228a8ed 100644
@@ -60,7 +60,6 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info)
 	/* ref: DN-0060 section 9 */
 	p_hw_info->hw_reserved1 = (p_hw_info->pci_device_id >> 12) & 0x000f;
 
-	/* mp_dev_name */
 	p_adapter_info->p_dev_name = p_dev_name;
 
 	if (p_dev_name) {

drivers/net/ntnic/adapter/nt4ga_adapter.c static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info) · line 76

Quoted 6 lines
drivers/net/ntnic/adapter/nt4ga_adapter.c +0 -1
@@ -73,7 +72,6 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info)
 			p_adapter_info->fpga_info.pciident);
 	}
 
-	/* mp_adapter_id_str */
 	p_adapter_info->mp_adapter_id_str = p_adapter_id_str;
 

If above removed comments are not needed, what do you think to not add them at first place in previous commits?

#178 lore raw

PATCH v8 11/21 net/ntnic: add FPGA initialization functionality

In reply to Serhii Iliushyk

Enable FPGA initialization and adds ethdev fw_version_get.

---
v5
* Fix Typo/Spelling
v7
* Add FW update feature to documentation - INI and RST files

---
 doc/guides/nics/features/ntnic.ini            |   1 +
 doc/guides/nics/ntnic.rst                     |   5 +
 drivers/net/ntnic/adapter/nt4ga_adapter.c     |  52 +++-
 drivers/net/ntnic/meson.build                 |   7 +
 .../net/ntnic/nthw/core/include/nthw_core.h   |   4 +
 .../net/ntnic/nthw/core/include/nthw_fpga.h   |  22 ++
 drivers/net/ntnic/nthw/core/nthw_fpga.c       | 222 ++++++++++++++++++
 drivers/net/ntnic/nthw/nthw_drv.h             |   1 +
 drivers/net/ntnic/nthw/nthw_register.h        |   1 +
 drivers/net/ntnic/ntnic_ethdev.c              |  39 ++-
 drivers/net/ntnic/ntnic_mod_reg.h             |   1 +
 11 files changed, 351 insertions(+), 4 deletions(-)
 create mode 100644 drivers/net/ntnic/nthw/core/include/nthw_fpga.h
 create mode 100644 drivers/net/ntnic/nthw/core/nthw_fpga.c
doc/guides/nics/features/ntnic.ini +1 -0
index 9ceb75a03b..03f4d5aac8 100644
@@ -4,5 +4,6 @@
 ; Refer to default.ini for the full list of available PMD features.
 ;
 [Features]
+FW version           = Y
 Linux                = Y
 x86-64               = Y
doc/guides/nics/ntnic.rst +5 -0
index 249d83d511..43caf3151d 100644
@@ -29,6 +29,11 @@ Supported NICs
 All information about NT200A02 can be found by link below:
 https://www.napatech.com/products/nt200a02-smartnic-inline/
 
+Features
+--------
+
+- FW version
+
 Limitations
 ~~~~~~~~~~~
 
drivers/net/ntnic/adapter/nt4ga_adapter.c +49 -3

89 lines not on this page · raw message

drivers/net/ntnic/meson.build +7 -0
index 5dd1beada2..78f31097ab 100644
@@ -16,6 +16,7 @@ includes = [
     include_directories('nthw/core/include'),
     include_directories('nthw'),
     include_directories('nthw/supported'),
+    include_directories('nthw/model'),
 ]
 
 # all sources
@@ -24,7 +25,13 @@ sources = files(
     'nthw/supported/nthw_fpga_9563_055_039_0000.c',
     'nthw/supported/nthw_fpga_instances.c',
     'nthw/supported/nthw_fpga_mod_str_map.c',
+    'nthw/core/nthw_fpga.c',
+    'nthw/core/nthw_hif.c',
+    'nthw/core/nthw_iic.c',
+    'nthw/core/nthw_pcie3.c',
+    'nthw/model/nthw_fpga_model.c',
     'nthw/nthw_platform.c',
+    'nthw/nthw_rac.c',
     'ntlog/ntlog.c',
     'ntutil/nt_util.c',
     'ntnic_mod_reg.c',
drivers/net/ntnic/nthw/core/include/nthw_core.h +4 -0
index c2602e396f..69af113816 100644
@@ -11,6 +11,10 @@
 #include <stdint.h>
 
 #include "nthw_platform_drv.h"
+#include "nthw_fpga_model.h"
+#include "nthw_hif.h"
+#include "nthw_pcie3.h"
+#include "nthw_iic.h"
 
 
 #endif	/* __NTHW_CORE_H__ */
drivers/net/ntnic/nthw/core/include/nthw_fpga.h new file +22 -0
new file mode 100644
index 0000000000..1943f6e225
@@ -0,0 +1,22 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef __NTHW_FPGA_H__
+#define __NTHW_FPGA_H__
+
+#include "nthw_drv.h"
+
+#include "nthw_fpga_model.h"
+
+#include "nthw_rac.h"
+#include "nthw_iic.h"
+
+int nthw_fpga_init(struct fpga_info_s *p_fpga_info);
+int nthw_fpga_shutdown(struct fpga_info_s *p_fpga_info);
+
+int nthw_fpga_get_param_info(struct fpga_info_s *p_fpga_info, nthw_fpga_t *p_fpga);
+
+
+#endif	/* __NTHW_FPGA_H__ */
drivers/net/ntnic/nthw/core/nthw_fpga.c new file +222 -0

222 lines not on this page · raw message

drivers/net/ntnic/nthw/nthw_drv.h +1 -0
index d7cd64bb1d..071618eb6e 100644
@@ -22,6 +22,7 @@ enum fpga_info_profile {
 };
 
 typedef struct mcu_info_s {
+	bool mb_has_mcu;
 	int mn_mcu_type;
 	int mn_mcu_dram_size;
 } mcu_info_t;
drivers/net/ntnic/nthw/nthw_register.h +1 -0
index db006fcf72..ecc661a656 100644
@@ -11,6 +11,7 @@
 #include <stdbool.h>
 #include <inttypes.h>
 
+#include "nthw_fpga_model.h"
 
 #include "fpga_model.h"
 
drivers/net/ntnic/ntnic_ethdev.c +38 -1
index ab4b66f4a3..10b3c803ae 100644
@@ -178,12 +178,33 @@ eth_dev_close(struct rte_eth_dev *eth_dev)
 	return 0;
 }
 
+static int
+eth_fw_version_get(struct rte_eth_dev *eth_dev, char *fw_version, size_t fw_size)
+{
+	struct pmd_internals *internals = (struct pmd_internals *)eth_dev->data->dev_private;
+
+	fpga_info_t *fpga_info = &internals->p_drv->ntdrv.adapter_info.fpga_info;
+	const int length = snprintf(fw_version, fw_size, "%03d-%04d-%02d-%02d",
+			fpga_info->n_fpga_type_id, fpga_info->n_fpga_prod_id,
+			fpga_info->n_fpga_ver_id, fpga_info->n_fpga_rev_id);
+
+	if ((size_t)length < fw_size) {
+		/* We have space for the version string */
+		return 0;
+
+	} else {
+		/* We do not have space for the version string -return the needed space */
+		return length + 1;
+	}
+}
+
 static struct eth_dev_ops nthw_eth_dev_ops = {
 	.dev_configure = eth_dev_configure,
 	.dev_start = eth_dev_start,
 	.dev_stop = eth_dev_stop,
 	.dev_close = eth_dev_close,
 	.dev_infos_get = eth_dev_infos_get,
+	.fw_version_get = eth_fw_version_get,
 };
 
 static int
@@ -200,6 +221,7 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev)
 
 	struct drv_s *p_drv;
 	ntdrv_4ga_t *p_nt_drv;
+	fpga_info_t *fpga_info;
 	hw_info_t *p_hw_info;
 	(void)p_hw_info;
 	uint32_t n_port_mask = -1;	/* All ports enabled by default */
@@ -233,6 +255,7 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev)
 
 	/* context */
 	p_nt_drv = &p_drv->ntdrv;
+	fpga_info = &p_nt_drv->adapter_info.fpga_info;
 	p_hw_info = &p_nt_drv->adapter_info.hw_info;
 
 	p_drv->p_dev = pci_dev;
@@ -243,6 +266,11 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev)
 	p_nt_drv->adapter_info.n_rx_host_buffers = nb_rx_queues;
 	p_nt_drv->adapter_info.n_tx_host_buffers = nb_tx_queues;
 
+	fpga_info->bar0_addr = (void *)pci_dev->mem_resource[0].addr;
+	fpga_info->bar0_size = pci_dev->mem_resource[0].len;
+	fpga_info->numa_node = pci_dev->device.numa_node;
+	fpga_info->pciident = p_nt_drv->pciident;
+	fpga_info->adapter_no = p_drv->adapter_no;
 
 	p_nt_drv->adapter_info.hw_info.pci_class_id = pci_dev->id.class_id;
 	p_nt_drv->adapter_info.hw_info.pci_vendor_id = pci_dev->id.vendor_id;
@@ -279,6 +307,15 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev)
 		/* mp_adapter_id_str is initialized after nt4ga_adapter_init(p_nt_drv) */
 		const char *const p_adapter_id_str = p_nt_drv->adapter_info.mp_adapter_id_str;
 		(void)p_adapter_id_str;
+		NT_LOG(DBG, NTNIC,
+			"%s: %s: AdapterPCI=" PCIIDENT_PRINT_STR " Hw=0x%02X_rev%d PhyPorts=%d\n",
+			(pci_dev->name[0] ? pci_dev->name : "NA"), p_adapter_id_str,
+			PCIIDENT_TO_DOMAIN(p_nt_drv->adapter_info.fpga_info.pciident),
+			PCIIDENT_TO_BUSNR(p_nt_drv->adapter_info.fpga_info.pciident),
+			PCIIDENT_TO_DEVNR(p_nt_drv->adapter_info.fpga_info.pciident),
+			PCIIDENT_TO_FUNCNR(p_nt_drv->adapter_info.fpga_info.pciident),
+			p_hw_info->hw_platform_id, fpga_info->nthw_hw_info.hw_id,
+			fpga_info->n_phy_ports);
 
 	} else {
 		NT_LOG_DBGX(ERR, NTNIC, "%s: error=%d\n",
@@ -286,7 +323,7 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev)
 		return -1;
 	}
 
-	n_phy_ports = 0;
+	n_phy_ports = fpga_info->n_phy_ports;
 
 	for (int n_intf_no = 0; n_intf_no < n_phy_ports; n_intf_no++) {
 		const char *const p_port_id_str = p_nt_drv->adapter_info.mp_port_id_str[n_intf_no];
drivers/net/ntnic/ntnic_mod_reg.h +1 -0
index 48a9f8f7b9..96fc829399 100644
@@ -7,6 +7,7 @@
 #define __NTNIC_MOD_REG_H__
 
 #include <stdint.h>
+#include "nthw_fpga_model.h"
 #include "nthw_platform_drv.h"
 #include "nthw_drv.h"
 #include "nt4ga_adapter.h"
Signature · 1 line
2.45.0
#179 lore raw

PATCH v8 12/21 net/ntnic: add support of the NT200A0X smartNIC

In reply to Serhii Iliushyk

Add ntnic support for NT200A0X NIC

---
 drivers/net/ntnic/adapter/nt4ga_adapter.c     |  6 +++
 drivers/net/ntnic/meson.build                 |  1 +
 .../net/ntnic/nthw/core/include/nthw_fpga.h   |  7 +++
 .../nthw/core/nt200a0x/nthw_fpga_nt200a0x.c   | 54 +++++++++++++++++++
 drivers/net/ntnic/nthw/core/nthw_fpga.c       | 31 +++++++++++
 drivers/net/ntnic/nthw/nthw_platform.c        |  3 ++
 drivers/net/ntnic/nthw/nthw_platform_drv.h    |  2 +
 drivers/net/ntnic/ntnic_ethdev.c              |  3 ++
 8 files changed, 107 insertions(+)
 create mode 100644 drivers/net/ntnic/nthw/core/nt200a0x/nthw_fpga_nt200a0x.c
drivers/net/ntnic/adapter/nt4ga_adapter.c +6 -0
index 3b113b9850..bdad2b1e21 100644
@@ -127,6 +127,12 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info)
 		assert(fpga_info->n_fpga_prod_id > 0);
 
 		switch (fpga_info->n_fpga_prod_id) {
+		/* NT200A01: 2x100G (Xilinx) */
+		case 9563:	/* NT200A02 (Cap) */
+			NT_LOG(ERR, NTNIC, "NT200A02 100G link module uninitialized\n");
+			res = -1;
+			break;
+
 		default:
 			NT_LOG(ERR, NTNIC, "Unsupported FPGA product: %04d\n",
 				fpga_info->n_fpga_prod_id);
drivers/net/ntnic/meson.build +1 -0
index 78f31097ab..e375c63bf8 100644
@@ -25,6 +25,7 @@ sources = files(
     'nthw/supported/nthw_fpga_9563_055_039_0000.c',
     'nthw/supported/nthw_fpga_instances.c',
     'nthw/supported/nthw_fpga_mod_str_map.c',
+    'nthw/core/nt200a0x/nthw_fpga_nt200a0x.c',
     'nthw/core/nthw_fpga.c',
     'nthw/core/nthw_hif.c',
     'nthw/core/nthw_iic.c',
drivers/net/ntnic/nthw/core/include/nthw_fpga.h +7 -0
index 1943f6e225..ba86b4d8d2 100644
@@ -18,5 +18,12 @@ int nthw_fpga_shutdown(struct fpga_info_s *p_fpga_info);
 
 int nthw_fpga_get_param_info(struct fpga_info_s *p_fpga_info, nthw_fpga_t *p_fpga);
 
+struct nt200a0x_ops {
+	int (*nthw_fpga_nt200a0x_init)(struct fpga_info_s *p_fpga_info);
+};
+
+void register_nt200a0x_ops(struct nt200a0x_ops *ops);
+struct nt200a0x_ops *get_nt200a0x_ops(void);
+void nt200a0x_ops_init(void);
 
 #endif	/* __NTHW_FPGA_H__ */
drivers/net/ntnic/nthw/core/nt200a0x/nthw_fpga_nt200a0x.c new file +54 -0

54 lines not on this page · raw message

drivers/net/ntnic/nthw/core/nthw_fpga.c +31 -0
index df238ec4ef..98d29744cb 100644
@@ -152,7 +152,18 @@ int nthw_fpga_init(struct fpga_info_s *p_fpga_info)
 	nthw_rac_rab_flush(p_nthw_rac);
 	p_fpga_info->mp_nthw_rac = p_nthw_rac;
 
+	bool included = true;
+	struct nt200a0x_ops *nt200a0x_ops = get_nt200a0x_ops();
+
 	switch (p_fpga_info->n_nthw_adapter_id) {
+	case NT_HW_ADAPTER_ID_NT200A02:
+		if (nt200a0x_ops != NULL)
+			res = nt200a0x_ops->nthw_fpga_nt200a0x_init(p_fpga_info);
+
+		else
+			included = false;
+
+		break;
 	default:
 		NT_LOG(ERR, NTHW, "%s: Unsupported HW product id: %d\n", p_adapter_id_str,
 			p_fpga_info->n_nthw_adapter_id);
@@ -160,6 +171,12 @@ int nthw_fpga_init(struct fpga_info_s *p_fpga_info)
 		break;
 	}
 
+	if (!included) {
+		NT_LOG(ERR, NTHW, "%s: NOT INCLUDED HW product: %d\n", p_adapter_id_str,
+			p_fpga_info->n_nthw_adapter_id);
+		res = -1;
+	}
+
 	if (res) {
 		NT_LOG(ERR, NTHW, "%s: status: 0x%08X\n", p_adapter_id_str, res);
 		return res;
@@ -220,3 +237,17 @@ int nthw_fpga_shutdown(struct fpga_info_s *p_fpga_info)
 
 	return res;
 }
+
+static struct nt200a0x_ops *nt200a0x_ops;
+
+void register_nt200a0x_ops(struct nt200a0x_ops *ops)
+{
+	nt200a0x_ops = ops;
+}
+
+struct nt200a0x_ops *get_nt200a0x_ops(void)
+{
+	if (nt200a0x_ops == NULL)
+		nt200a0x_ops_init();
+	return nt200a0x_ops;
+}
drivers/net/ntnic/nthw/nthw_platform.c +3 -0
index 181330dd37..33e18e549f 100644
@@ -8,6 +8,9 @@
 nthw_adapter_id_t nthw_platform_get_nthw_adapter_id(const uint16_t n_pci_device_id)
 {
 	switch (n_pci_device_id) {
+	case NT_HW_PCI_DEVICE_ID_NT200A02:
+		return NT_HW_ADAPTER_ID_NT200A02;
+
 	default:
 		return NT_HW_ADAPTER_ID_UNKNOWN;
 	}
drivers/net/ntnic/nthw/nthw_platform_drv.h +2 -0
index ab26d8149a..42eb0b8b05 100644
@@ -9,9 +9,11 @@
 #include <stdint.h>
 
 #define NT_HW_PCI_VENDOR_ID (0x18f4)
+#define NT_HW_PCI_DEVICE_ID_NT200A02 (0x1C5)
 
 enum nthw_adapter_id_e {
 	NT_HW_ADAPTER_ID_UNKNOWN = 0,
+	NT_HW_ADAPTER_ID_NT200A02,
 };
 
 typedef enum nthw_adapter_id_e nthw_adapter_id_t;
drivers/net/ntnic/ntnic_ethdev.c +3 -0
index 10b3c803ae..488c88c782 100644
@@ -26,6 +26,7 @@
 #define EXCEPTION_PATH_HID 0
 
 static const struct rte_pci_id nthw_pci_id_map[] = {
+	{ RTE_PCI_DEVICE(NT_HW_PCI_VENDOR_ID, NT_HW_PCI_DEVICE_ID_NT200A02) },
 	{
 		.vendor_id = 0,
 	},	/* sentinel */
@@ -486,9 +487,11 @@ nthw_pci_remove(struct rte_pci_device *pci_dev)
 
 static struct rte_pci_driver rte_nthw_pmd = {
 	.id_table = nthw_pci_id_map,
+	.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
 	.probe = nthw_pci_probe,
 	.remove = nthw_pci_remove,
 };
 
 RTE_PMD_REGISTER_PCI(net_ntnic, rte_nthw_pmd);
+RTE_PMD_REGISTER_PCI_TABLE(net_ntnic, nthw_pci_id_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_ntnic, "* vfio-pci");
Signature · 1 line
2.45.0
#180 lore raw

PATCH v8 13/21 net/ntnic: add startup and reset sequence for NT200A0X

In reply to Serhii Iliushyk

Adds reset (RST) module for FW 9563.
Also adds SDRAM Controller (SDC) module,
as it is part of the startup and reset sequence.

---
v5
* Fix Typo/Spelling

---
 .../include/ntnic_nthw_fpga_rst_nt200a0x.h    |  81 +++
 drivers/net/ntnic/meson.build                 |   3 +
 .../net/ntnic/nthw/core/include/nthw_core.h   |   2 +
 .../net/ntnic/nthw/core/include/nthw_fpga.h   |   6 +
 .../net/ntnic/nthw/core/include/nthw_sdc.h    |  42 ++
 .../nthw/core/nt200a0x/nthw_fpga_nt200a0x.c   |  24 +-
 .../core/nt200a0x/reset/nthw_fpga_rst9563.c   | 216 +++++++
 .../nt200a0x/reset/nthw_fpga_rst_nt200a0x.c   | 570 ++++++++++++++++++
 drivers/net/ntnic/nthw/core/nthw_fpga.c       |  82 +++
 drivers/net/ntnic/nthw/core/nthw_sdc.c        | 176 ++++++
 drivers/net/ntnic/ntnic_mod_reg.c             |  28 +
 drivers/net/ntnic/ntnic_mod_reg.h             |  20 +
 12 files changed, 1249 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/ntnic/include/ntnic_nthw_fpga_rst_nt200a0x.h
 create mode 100644 drivers/net/ntnic/nthw/core/include/nthw_sdc.h
 create mode 100644 drivers/net/ntnic/nthw/core/nt200a0x/reset/nthw_fpga_rst9563.c
 create mode 100644 drivers/net/ntnic/nthw/core/nt200a0x/reset/nthw_fpga_rst_nt200a0x.c
 create mode 100644 drivers/net/ntnic/nthw/core/nthw_sdc.c
drivers/net/ntnic/include/ntnic_nthw_fpga_rst_nt200a0x.h new file +81 -0
new file mode 100644
index 0000000000..6ceec93bac
@@ -0,0 +1,81 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2024 Napatech A/S
+ */
+
+#ifndef __NTNIC_NTHW_FPGA_RST_NT200A0X_H__
+#define __NTNIC_NTHW_FPGA_RST_NT200A0X_H__
+
+#include "nthw_drv.h"
+#include "nthw_fpga_model.h"
+
+struct nthw_fpga_rst_nt200a0x {
+	int mn_fpga_product_id;
+	int mn_fpga_version;
+	int mn_fpga_revision;
+
+	int mn_hw_id;
+
+	int mn_si_labs_clock_synth_model;
+
+	nthw_field_t *mp_fld_rst_sys;
+	nthw_field_t *mp_fld_rst_sys_mmcm;
+	nthw_field_t *mp_fld_rst_core_mmcm;
+	nthw_field_t *mp_fld_rst_rpp;
+	nthw_field_t *mp_fld_rst_ddr4;
+	nthw_field_t *mp_fld_rst_sdc;
+	nthw_field_t *mp_fld_rst_phy;
+	nthw_field_t *mp_fld_rst_serdes_rx;
+	nthw_field_t *mp_fld_rst_serdes_tx;
+	nthw_field_t *mp_fld_rst_serdes_rx_datapath;
+	nthw_field_t *mp_fld_rst_pcs_rx;
+	nthw_field_t *mp_fld_rst_mac_rx;
+	nthw_field_t *mp_fld_rst_mac_tx;
+	nthw_field_t *mp_fld_rst_ptp;
+	nthw_field_t *mp_fld_rst_ts;
+	nthw_field_t *mp_fld_rst_ptp_mmcm;
+	nthw_field_t *mp_fld_rst_ts_mmcm;
+	nthw_field_t *mp_fld_rst_periph;
+	nthw_field_t *mp_fld_rst_tsm_ref_mmcm;
+	nthw_field_t *mp_fld_rst_tmc;
+
+	/* CTRL register field pointers */
+	nthw_field_t *mp_fld_ctrl_ts_clk_sel_override;
+	nthw_field_t *mp_fld_ctrl_ts_clk_sel;
+	nthw_field_t *mp_fld_ctrl_ts_clk_sel_ref;
+	nthw_field_t *mp_fld_ctrl_ptp_mmcm_clk_sel;
+
+	/* STAT register field pointers */
+	nthw_field_t *mp_fld_stat_ddr4_mmcm_locked;
+	nthw_field_t *mp_fld_stat_sys_mmcm_locked;
+	nthw_field_t *mp_fld_stat_core_mmcm_locked;
+	nthw_field_t *mp_fld_stat_ddr4_pll_locked;
+	nthw_field_t *mp_fld_stat_ptp_mmcm_locked;
+	nthw_field_t *mp_fld_stat_ts_mmcm_locked;
+	nthw_field_t *mp_fld_stat_tsm_ref_mmcm_locked;
+
+	/* STICKY register field pointers */
+	nthw_field_t *mp_fld_sticky_ptp_mmcm_unlocked;
+	nthw_field_t *mp_fld_sticky_ts_mmcm_unlocked;
+	nthw_field_t *mp_fld_sticky_ddr4_mmcm_unlocked;
+	nthw_field_t *mp_fld_sticky_ddr4_pll_unlocked;
+	nthw_field_t *mp_fld_sticky_core_mmcm_unlocked;
+	nthw_field_t *mp_fld_sticky_pci_sys_mmcm_unlocked;
+	nthw_field_t *mp_fld_sticky_tsm_ref_mmcm_unlocked;
+
+	/* POWER register field pointers */
+	nthw_field_t *mp_fld_power_pu_phy;
+	nthw_field_t *mp_fld_power_pu_nseb;
+
+	void (*reset_serdes_rx)(struct nthw_fpga_rst_nt200a0x *p, uint32_t intf_no, uint32_t rst);
+	void (*pcs_rx_rst)(struct nthw_fpga_rst_nt200a0x *p, uint32_t intf_no, uint32_t rst);
+	void (*get_serdes_rx_rst)(struct nthw_fpga_rst_nt200a0x *p, uint32_t intf_no,
+		uint32_t *p_set);
+	void (*get_pcs_rx_rst)(struct nthw_fpga_rst_nt200a0x *p, uint32_t intf_no,
+		uint32_t *p_set);
+	bool (*is_rst_serdes_rx_datapath_implemented)(struct nthw_fpga_rst_nt200a0x *p);
+};
+
+typedef struct nthw_fpga_rst_nt200a0x nthw_fpga_rst_nt200a0x_t;
+
+#endif	/* __NTHW_FPGA_RST_NT200A0X_H__ */
drivers/net/ntnic/meson.build +3 -0
index e375c63bf8..d45a17526c 100644
@@ -26,10 +26,13 @@ sources = files(
     'nthw/supported/nthw_fpga_instances.c',
     'nthw/supported/nthw_fpga_mod_str_map.c',
     'nthw/core/nt200a0x/nthw_fpga_nt200a0x.c',
+    'nthw/core/nt200a0x/reset/nthw_fpga_rst9563.c',
+    'nthw/core/nt200a0x/reset/nthw_fpga_rst_nt200a0x.c',
     'nthw/core/nthw_fpga.c',
     'nthw/core/nthw_hif.c',
     'nthw/core/nthw_iic.c',
     'nthw/core/nthw_pcie3.c',
+    'nthw/core/nthw_sdc.c',
     'nthw/model/nthw_fpga_model.c',
     'nthw/nthw_platform.c',
     'nthw/nthw_rac.c',
drivers/net/ntnic/nthw/core/include/nthw_core.h +2 -0
index 69af113816..8bdf7ee01d 100644
@@ -16,5 +16,7 @@
 #include "nthw_pcie3.h"
 #include "nthw_iic.h"
 
+#include "nthw_sdc.h"
+
 
 #endif	/* __NTHW_CORE_H__ */
drivers/net/ntnic/nthw/core/include/nthw_fpga.h +6 -0
index ba86b4d8d2..1df1480109 100644
@@ -18,6 +18,12 @@ int nthw_fpga_shutdown(struct fpga_info_s *p_fpga_info);
 
 int nthw_fpga_get_param_info(struct fpga_info_s *p_fpga_info, nthw_fpga_t *p_fpga);
 
+int nthw_fpga_iic_scan(nthw_fpga_t *p_fpga, const int n_instance_no_begin,
+	const int n_instance_no_end);
+
+int nthw_fpga_silabs_detect(nthw_fpga_t *p_fpga, const int n_instance_no, const int n_dev_addr,
+	const int n_page_reg_addr);
+
 struct nt200a0x_ops {
 	int (*nthw_fpga_nt200a0x_init)(struct fpga_info_s *p_fpga_info);
 };
drivers/net/ntnic/nthw/core/include/nthw_sdc.h new file +42 -0

42 lines not on this page · raw message

drivers/net/ntnic/nthw/core/nt200a0x/nthw_fpga_nt200a0x.c +23 -1
index 7db6a03d88..3009e30670 100644
@@ -13,14 +13,36 @@ static int nthw_fpga_nt200a0x_init(struct fpga_info_s *p_fpga_info)
 	assert(p_fpga_info);
 
 	const char *const p_adapter_id_str = p_fpga_info->mp_adapter_id_str;
+	struct nthw_fpga_rst_nt200a0x rst;
 	int res = -1;
+	const struct rst_nt200a0x_ops *rst_nt200a0x_ops = get_rst_nt200a0x_ops();
+
+	if (rst_nt200a0x_ops == NULL) {
+		NT_LOG(ERR, NTHW, "RST NT200A0X NOT INCLUDED\n");
+		return -1;
+	}
+
+	/* reset common */
+	res = rst_nt200a0x_ops->nthw_fpga_rst_nt200a0x_init(p_fpga_info, &rst);
+
+	if (res) {
+		NT_LOG_DBGX(ERR, NTHW, "%s: FPGA=%04d res=%d\n", p_adapter_id_str,
+					p_fpga_info->n_fpga_prod_id, res);
+		return res;
+	}
 
 	bool included = true;
+	struct rst9563_ops *rst9563_ops = get_rst9563_ops();
 
 	/* reset specific */
 	switch (p_fpga_info->n_fpga_prod_id) {
 	case 9563:
-		included = false;
+		if (rst9563_ops != NULL)
+			res = rst9563_ops->nthw_fpga_rst9563_init(p_fpga_info, &rst);
+
+		else
+			included = false;
+
 		break;
 
 	default:
drivers/net/ntnic/nthw/core/nt200a0x/reset/nthw_fpga_rst9563.c new file +216 -0

216 lines not on this page · raw message

drivers/net/ntnic/nthw/core/nt200a0x/reset/nthw_fpga_rst_nt200a0x.c new file +570 -0

570 lines not on this page · raw message

drivers/net/ntnic/nthw/core/nthw_fpga.c +82 -0

88 lines not on this page · raw message

drivers/net/ntnic/nthw/core/nthw_sdc.c new file +176 -0

176 lines not on this page · raw message

drivers/net/ntnic/ntnic_mod_reg.c +28 -0
index 006221bbe3..bd0a966be2 100644
@@ -18,3 +18,31 @@ const struct adapter_ops *get_adapter_ops(void)
 		adapter_init();
 	return adapter_ops;
 }
+
+static struct rst_nt200a0x_ops *rst_nt200a0x_ops;
+
+void register_rst_nt200a0x_ops(struct rst_nt200a0x_ops *ops)
+{
+	rst_nt200a0x_ops = ops;
+}
+
+struct rst_nt200a0x_ops *get_rst_nt200a0x_ops(void)
+{
+	if (rst_nt200a0x_ops == NULL)
+		rst_nt200a0x_ops_init();
+	return rst_nt200a0x_ops;
+}
+
+static struct rst9563_ops *rst9563_ops;
+
+void register_rst9563_ops(struct rst9563_ops *ops)
+{
+	rst9563_ops = ops;
+}
+
+struct rst9563_ops *get_rst9563_ops(void)
+{
+	if (rst9563_ops == NULL)
+		rst9563_ops_init();
+	return rst9563_ops;
+}
drivers/net/ntnic/ntnic_mod_reg.h +20 -0
index 96fc829399..df8a8b9aca 100644
@@ -11,6 +11,7 @@
 #include "nthw_platform_drv.h"
 #include "nthw_drv.h"
 #include "nt4ga_adapter.h"
+#include "ntnic_nthw_fpga_rst_nt200a0x.h"
 #include "ntos_drv.h"
 
 struct adapter_ops {
@@ -24,5 +25,24 @@ void register_adapter_ops(const struct adapter_ops *ops);
 const struct adapter_ops *get_adapter_ops(void);
 void adapter_init(void);
 
+struct rst_nt200a0x_ops {
+	int (*nthw_fpga_rst_nt200a0x_init)(struct fpga_info_s *p_fpga_info,
+		struct nthw_fpga_rst_nt200a0x *p_rst);
+	int (*nthw_fpga_rst_nt200a0x_reset)(nthw_fpga_t *p_fpga,
+		const struct nthw_fpga_rst_nt200a0x *p);
+};
+
+void register_rst_nt200a0x_ops(struct rst_nt200a0x_ops *ops);
+struct rst_nt200a0x_ops *get_rst_nt200a0x_ops(void);
+void rst_nt200a0x_ops_init(void);
+
+struct rst9563_ops {
+	int (*nthw_fpga_rst9563_init)(struct fpga_info_s *p_fpga_info,
+		struct nthw_fpga_rst_nt200a0x *const p);
+};
+
+void register_rst9563_ops(struct rst9563_ops *ops);
+struct rst9563_ops *get_rst9563_ops(void);
+void rst9563_ops_init(void);
 
 #endif	/* __NTNIC_MOD_REG_H__ */
Signature · 1 line
2.45.0
#181 lore raw

PATCH v8 14/21 net/ntnic: add clock profile for the NT200A0X smartNIC

In reply to Serhii Iliushyk

Because the ntnic hardware supports multiple different FPGAs with different pipelines and port speeds,
the clock profile is not hardcoded into the product,
and need to be initialized from software.

The clock profile itself is an array of integers
that was generated by Silicon Labs ClockBuilder.

---
v6
* EOF comment was removed

---
 .../ntnic/include/clock_profiles_structs.h    |  33 +
 .../include/ntnic_nthw_fpga_rst_nt200a0x.h    |   1 +
 drivers/net/ntnic/meson.build                 |   2 +
 .../net/ntnic/nthw/core/include/nthw_core.h   |   2 +
 .../net/ntnic/nthw/core/include/nthw_fpga.h   |   4 +
 .../net/ntnic/nthw/core/include/nthw_si5340.h |  33 +
 .../NT200A02_U23_Si5340_adr0_v5-Registers.h   | 753 ++++++++++++++++++
 .../clock_profiles/nthw_fpga_clk9563.c        |  47 ++
 .../core/nt200a0x/reset/nthw_fpga_rst9563.c   |  35 +
 .../nt200a0x/reset/nthw_fpga_rst_nt200a0x.c   |   3 +
 drivers/net/ntnic/nthw/core/nthw_fpga.c       |  23 +
 drivers/net/ntnic/nthw/core/nthw_si5340.c     | 198 +++++
 drivers/net/ntnic/ntnic_mod_reg.c             |  14 +
 drivers/net/ntnic/ntnic_mod_reg.h             |   9 +
 14 files changed, 1157 insertions(+)
 create mode 100644 drivers/net/ntnic/include/clock_profiles_structs.h
 create mode 100644 drivers/net/ntnic/nthw/core/include/nthw_si5340.h
 create mode 100644 drivers/net/ntnic/nthw/core/nt200a0x/clock_profiles/NT200A02_U23_Si5340_adr0_v5-Registers.h
 create mode 100644 drivers/net/ntnic/nthw/core/nt200a0x/clock_profiles/nthw_fpga_clk9563.c
 create mode 100644 drivers/net/ntnic/nthw/core/nthw_si5340.c
drivers/net/ntnic/include/clock_profiles_structs.h new file +33 -0
new file mode 100644
index 0000000000..28a582a5e7
@@ -0,0 +1,33 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef _NT_CLOCK_PROFILES_STRUCTS_H_
+#define _NT_CLOCK_PROFILES_STRUCTS_H_
+
+#include <stdint.h>
+
+#define clk_profile_size_error_msg "Size test failed"
+
+struct clk_profile_data_fmt1_s {
+	uint16_t reg_addr;
+	uint8_t reg_val;
+};
+
+struct clk_profile_data_fmt2_s {
+	unsigned int reg_addr;
+	unsigned char reg_val;
+};
+
+typedef struct clk_profile_data_fmt1_s clk_profile_data_fmt1_t;
+typedef struct clk_profile_data_fmt2_s clk_profile_data_fmt2_t;
+
+enum clk_profile_data_fmt_e {
+	clk_profile_data_fmt_1,
+	clk_profile_data_fmt_2,
+};
+
+typedef enum clk_profile_data_fmt_e clk_profile_data_fmt_t;
+
+#endif	/* _NT_CLOCK_PROFILES_STRUCTS_H_ */
drivers/net/ntnic/include/ntnic_nthw_fpga_rst_nt200a0x.h +1 -0
index 6ceec93bac..8b7ebdf1fd 100644
@@ -17,6 +17,7 @@ struct nthw_fpga_rst_nt200a0x {
 	int mn_hw_id;
 
 	int mn_si_labs_clock_synth_model;
+	uint8_t mn_si_labs_clock_synth_i2c_addr;
 
 	nthw_field_t *mp_fld_rst_sys;
 	nthw_field_t *mp_fld_rst_sys_mmcm;
drivers/net/ntnic/meson.build +2 -0
index d45a17526c..987768cb92 100644
@@ -25,6 +25,7 @@ sources = files(
     'nthw/supported/nthw_fpga_9563_055_039_0000.c',
     'nthw/supported/nthw_fpga_instances.c',
     'nthw/supported/nthw_fpga_mod_str_map.c',
+    'nthw/core/nt200a0x/clock_profiles/nthw_fpga_clk9563.c',
     'nthw/core/nt200a0x/nthw_fpga_nt200a0x.c',
     'nthw/core/nt200a0x/reset/nthw_fpga_rst9563.c',
     'nthw/core/nt200a0x/reset/nthw_fpga_rst_nt200a0x.c',
@@ -33,6 +34,7 @@ sources = files(
     'nthw/core/nthw_iic.c',
     'nthw/core/nthw_pcie3.c',
     'nthw/core/nthw_sdc.c',
+    'nthw/core/nthw_si5340.c',
     'nthw/model/nthw_fpga_model.c',
     'nthw/nthw_platform.c',
     'nthw/nthw_rac.c',
drivers/net/ntnic/nthw/core/include/nthw_core.h +2 -0
index 8bdf7ee01d..5648bd8983 100644
@@ -18,5 +18,7 @@
 
 #include "nthw_sdc.h"
 
+#include "nthw_si5340.h"
+
 
 #endif	/* __NTHW_CORE_H__ */
drivers/net/ntnic/nthw/core/include/nthw_fpga.h +4 -0
index 1df1480109..cee1d23090 100644
@@ -24,6 +24,10 @@ int nthw_fpga_iic_scan(nthw_fpga_t *p_fpga, const int n_instance_no_begin,
 int nthw_fpga_silabs_detect(nthw_fpga_t *p_fpga, const int n_instance_no, const int n_dev_addr,
 	const int n_page_reg_addr);
 
+int nthw_fpga_si5340_clock_synth_init_fmt2(nthw_fpga_t *p_fpga, const uint8_t n_iic_addr,
+	const clk_profile_data_fmt2_t *p_clk_profile,
+	const int n_clk_profile_rec_cnt);
+
 struct nt200a0x_ops {
 	int (*nthw_fpga_nt200a0x_init)(struct fpga_info_s *p_fpga_info);
 };
drivers/net/ntnic/nthw/core/include/nthw_si5340.h new file +33 -0
new file mode 100644
index 0000000000..f56883d99a
@@ -0,0 +1,33 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef __NTHW_SI5340_H__
+#define __NTHW_SI5340_H__
+
+#include "clock_profiles_structs.h"
+
+#define SI5340_SUCCESS (0)
+#define SI5340_FAILED (999)
+#define SI5340_TIMEOUT (666)
+
+struct nthw_si5340 {
+	uint8_t mn_iic_addr;
+	nthw_iic_t *mp_nthw_iic;
+	int mn_clk_cfg;
+	uint8_t m_si5340_page;
+};
+
+typedef struct nthw_si5340 nthw_si5340_t;
+
+nthw_si5340_t *nthw_si5340_new(void);
+int nthw_si5340_init(nthw_si5340_t *p, nthw_iic_t *p_nthw_iic, uint8_t n_iic_addr);
+void nthw_si5340_delete(nthw_si5340_t *p);
+
+int nthw_si5340_config(nthw_si5340_t *p, const void *p_data, int data_cnt,
+	clk_profile_data_fmt_t data_format);
+int nthw_si5340_config_fmt2(nthw_si5340_t *p, const clk_profile_data_fmt2_t *p_data,
+	const int data_cnt);
+
+#endif	/* __NTHW_SI5338_H__ */
drivers/net/ntnic/nthw/core/nt200a0x/clock_profiles/NT200A02_U23_Si5340_adr0_v5-Registers.h new file +753 -0

753 lines not on this page · raw message

drivers/net/ntnic/nthw/core/nt200a0x/clock_profiles/nthw_fpga_clk9563.c new file +47 -0

47 lines not on this page · raw message

drivers/net/ntnic/nthw/core/nt200a0x/reset/nthw_fpga_rst9563.c +35 -0
index a3b6511b06..380f877096 100644
@@ -164,6 +164,34 @@ static int nthw_fpga_rst9563_periph_reset(nthw_fpga_t *p_fpga)
 	return 0;
 }
 
+static int nthw_fpga_rst9563_clock_synth_init(nthw_fpga_t *p_fpga,
+	const int n_si_labs_clock_synth_model,
+	const uint8_t n_si_labs_clock_synth_i2c_addr)
+{
+	const char *const p_adapter_id_str = p_fpga->p_fpga_info->mp_adapter_id_str;
+	const int n_fpga_product_id = p_fpga->mn_product_id;
+	int res;
+	const struct clk9563_ops *clk9563_ops = get_clk9563_ops();
+
+	if (clk9563_ops == NULL) {
+		NT_LOG(INF, NTNIC, "CLK9563 module not included\n");
+		return -1;
+	}
+
+	if (n_si_labs_clock_synth_model == 5340) {
+		res = nthw_fpga_si5340_clock_synth_init_fmt2(p_fpga, n_si_labs_clock_synth_i2c_addr,
+				clk9563_ops->get_p_data_9563_si5340_nt200a02_u23_v5(),
+				*clk9563_ops->get_n_data_9563_si5340_nt200a02_u23_v5());
+
+	} else {
+		NT_LOG(ERR, NTHW, "%s: Fpga %d: Unsupported clock synth model (%d)\n",
+			p_adapter_id_str, n_fpga_product_id, n_si_labs_clock_synth_model);
+		res = -1;
+	}
+
+	return res;
+}
+
 static int nthw_fpga_rst9563_init(struct fpga_info_s *p_fpga_info,
 	struct nthw_fpga_rst_nt200a0x *p_rst)
 {
@@ -173,9 +201,13 @@ static int nthw_fpga_rst9563_init(struct fpga_info_s *p_fpga_info,
 	const char *const p_adapter_id_str = p_fpga_info->mp_adapter_id_str;
 	(void)p_adapter_id_str;
 	int res = -1;
+	int n_si_labs_clock_synth_model;
+	uint8_t n_si_labs_clock_synth_i2c_addr;
 	nthw_fpga_t *p_fpga = NULL;
 
 	p_fpga = p_fpga_info->mp_fpga;
+	n_si_labs_clock_synth_model = p_rst->mn_si_labs_clock_synth_model;
+	n_si_labs_clock_synth_i2c_addr = p_rst->mn_si_labs_clock_synth_i2c_addr;
 
 	res = nthw_fpga_rst9563_periph_reset(p_fpga);
 
@@ -184,6 +216,9 @@ static int nthw_fpga_rst9563_init(struct fpga_info_s *p_fpga_info,
 		return res;
 	}
 
+	res = nthw_fpga_rst9563_clock_synth_init(p_fpga, n_si_labs_clock_synth_model,
+			n_si_labs_clock_synth_i2c_addr);
+
 	if (res) {
 		NT_LOG_DBGX(DEBUG, NTHW, "%s: ERROR: res=%d\n", p_adapter_id_str, res);
 		return res;
drivers/net/ntnic/nthw/core/nt200a0x/reset/nthw_fpga_rst_nt200a0x.c +3 -0
index 84f13e8371..ea0276a90c 100644
@@ -552,7 +552,10 @@ static int nthw_fpga_rst_nt200a0x_init(struct fpga_info_s *p_fpga_info,
 	}
 
 	p_rst->mn_si_labs_clock_synth_model = n_si_labs_clock_synth_model;
+	p_rst->mn_si_labs_clock_synth_i2c_addr = n_si_labs_clock_synth_i2c_addr;
 	p_rst->mn_hw_id = p_fpga_info->nthw_hw_info.hw_id;
+	NT_LOG_DBGX(DEBUG, NTHW, "%s: Si%04d @ 0x%02x\n", p_adapter_id_str,
+		p_rst->mn_si_labs_clock_synth_model, p_rst->mn_si_labs_clock_synth_i2c_addr);
 
 	return res;
 }
drivers/net/ntnic/nthw/core/nthw_fpga.c +23 -0
index 1650bb8a5c..38169176a5 100644
@@ -147,6 +147,29 @@ int nthw_fpga_silabs_detect(nthw_fpga_t *p_fpga, const int n_instance_no, const
 	return res;
 }
 
+/*
+ * NT200A02, NT200A01-HWbuild2
+ */
+int nthw_fpga_si5340_clock_synth_init_fmt2(nthw_fpga_t *p_fpga, const uint8_t n_iic_addr,
+	const clk_profile_data_fmt2_t *p_clk_profile,
+	const int n_clk_profile_rec_cnt)
+{
+	int res;
+	nthw_iic_t *p_nthw_iic = nthw_iic_new();
+	nthw_si5340_t *p_nthw_si5340 = nthw_si5340_new();
+
+	assert(p_nthw_iic);
+	assert(p_nthw_si5340);
+	nthw_iic_init(p_nthw_iic, p_fpga, 0, 8);/* I2C cycle time 125Mhz ~ 8ns */
+
+	nthw_si5340_init(p_nthw_si5340, p_nthw_iic, n_iic_addr);/* si5340_u23_i2c_addr_7bit */
+	res = nthw_si5340_config_fmt2(p_nthw_si5340, p_clk_profile, n_clk_profile_rec_cnt);
+	nthw_si5340_delete(p_nthw_si5340);
+	p_nthw_si5340 = NULL;
+
+	return res;
+}
+
 int nthw_fpga_init(struct fpga_info_s *p_fpga_info)
 {
 	const char *const p_adapter_id_str = p_fpga_info->mp_adapter_id_str;
drivers/net/ntnic/nthw/core/nthw_si5340.c new file +198 -0

198 lines not on this page · raw message

drivers/net/ntnic/ntnic_mod_reg.c +14 -0
index bd0a966be2..3f03299a83 100644
@@ -19,6 +19,20 @@ const struct adapter_ops *get_adapter_ops(void)
 	return adapter_ops;
 }
 
+static struct clk9563_ops *clk9563_ops;
+
+void register_clk9563_ops(struct clk9563_ops *ops)
+{
+	clk9563_ops = ops;
+}
+
+struct clk9563_ops *get_clk9563_ops(void)
+{
+	if (clk9563_ops == NULL)
+		clk9563_ops_init();
+	return clk9563_ops;
+}
+
 static struct rst_nt200a0x_ops *rst_nt200a0x_ops;
 
 void register_rst_nt200a0x_ops(struct rst_nt200a0x_ops *ops)
drivers/net/ntnic/ntnic_mod_reg.h +9 -0
index df8a8b9aca..45f5632981 100644
@@ -25,6 +25,15 @@ void register_adapter_ops(const struct adapter_ops *ops);
 const struct adapter_ops *get_adapter_ops(void);
 void adapter_init(void);
 
+struct clk9563_ops {
+	const int *(*get_n_data_9563_si5340_nt200a02_u23_v5)(void);
+	const clk_profile_data_fmt2_t *(*get_p_data_9563_si5340_nt200a02_u23_v5)(void);
+};
+
+void register_clk9563_ops(struct clk9563_ops *ops);
+struct clk9563_ops *get_clk9563_ops(void);
+void clk9563_ops_init(void);
+
 struct rst_nt200a0x_ops {
 	int (*nthw_fpga_rst_nt200a0x_init)(struct fpga_info_s *p_fpga_info,
 		struct nthw_fpga_rst_nt200a0x *p_rst);
Signature · 1 line
2.45.0
#182 lore raw

PATCH v8 15/21 net/ntnic: add link management skeleton

In reply to Serhii Iliushyk

Add functionality to read and control the link-state of the ntnic. Note that must functions are not implemented yet.

Adds the following eth_dev_ops:
- dev_set_link_up
- dev_set_link_down
- link_update
- mac_addr_add
- mac_addr_set
- set_mc_addr_list
- promiscuous_enable

---
v5
* Fix Typo/Spelling
v6
* if_index was replaced with n_intf_no
* MAC addr assignment approach was reworked
v7
* Add relate features to documentation - INI and RST files

---
 doc/guides/nics/features/ntnic.ini        |   3 +
 doc/guides/nics/ntnic.rst                 |   5 +
 drivers/net/ntnic/adapter/nt4ga_adapter.c |   6 +
 drivers/net/ntnic/include/nt4ga_adapter.h |   5 +-
 drivers/net/ntnic/include/nt4ga_link.h    |  84 +++++++
 drivers/net/ntnic/include/ntos_drv.h      |  15 ++
 drivers/net/ntnic/link_mgmt/nt4ga_link.c  | 176 ++++++++++++++
 drivers/net/ntnic/meson.build             |   1 +
 drivers/net/ntnic/ntnic_ethdev.c          | 283 +++++++++++++++++++++-
 drivers/net/ntnic/ntnic_mod_reg.c         |  14 ++
 drivers/net/ntnic/ntnic_mod_reg.h         |  50 +++-
 drivers/net/ntnic/ntutil/nt_util.c        | 131 ++++++++++
 drivers/net/ntnic/ntutil/nt_util.h        |  11 +
 13 files changed, 780 insertions(+), 4 deletions(-)
 create mode 100644 drivers/net/ntnic/include/nt4ga_link.h
 create mode 100644 drivers/net/ntnic/link_mgmt/nt4ga_link.c
doc/guides/nics/features/ntnic.ini +3 -0
index 03f4d5aac8..0a74817fcf 100644
@@ -5,5 +5,8 @@
 ;
 [Features]
 FW version           = Y
+Speed capabilities   = Y
+Unicast MAC filter   = Y
+Multicast MAC filter = Y
 Linux                = Y
 x86-64               = Y
doc/guides/nics/ntnic.rst +5 -0
index 43caf3151d..25c74730fe 100644
@@ -33,6 +33,11 @@ Features
 --------
 
 - FW version
+- Speed capabilities
+- Link status (Link update only)
+- Unicast MAC filter
+- Multicast MAC filter
+- Promiscuous mode (Enable only. The device always run promiscuous mode)
 
 Limitations
 ~~~~~~~~~~~
drivers/net/ntnic/adapter/nt4ga_adapter.c +6 -0
index bdad2b1e21..e29fda7fbb 100644
@@ -124,8 +124,14 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info)
 	assert(n_phy_ports >= 1);
 
 	{
+		int i;
 		assert(fpga_info->n_fpga_prod_id > 0);
 
+		for (i = 0; i < NUM_ADAPTER_PORTS_MAX; i++) {
+			/* Disable all ports. Must be enabled later */
+			p_adapter_info->nt4ga_link.port_action[i].port_disable = true;
+		}
+
 		switch (fpga_info->n_fpga_prod_id) {
 		/* NT200A01: 2x100G (Xilinx) */
 		case 9563:	/* NT200A02 (Cap) */
drivers/net/ntnic/include/nt4ga_adapter.h +4 -1
index 2c72583caf..ed14936b38 100644
@@ -6,7 +6,8 @@
 #ifndef _NT4GA_ADAPTER_H_
 #define _NT4GA_ADAPTER_H_
 
-#include "ntos_drv.h"
+#include "nt4ga_link.h"
+
 typedef struct hw_info_s {
 	/* pciids */
 	uint16_t pci_vendor_id;
@@ -23,6 +24,8 @@ typedef struct hw_info_s {
 } hw_info_t;
 
 typedef struct adapter_info_s {
+	struct nt4ga_link_s nt4ga_link;
+
 	struct hw_info_s hw_info;
 	struct fpga_info_s fpga_info;
 
drivers/net/ntnic/include/nt4ga_link.h new file +84 -0

84 lines not on this page · raw message

drivers/net/ntnic/include/ntos_drv.h +15 -0
index e3d8ffb91c..43fac61257 100644
@@ -25,9 +25,24 @@ struct pmd_internals {
 	const struct rte_pci_device *pci_dev;
 	char name[20];
 	int n_intf_no;
+	int lpbk_mode;
+	uint8_t ts_multiplier;
+	uint16_t min_tx_pkt_size;
+	uint16_t max_tx_pkt_size;
+	unsigned int nb_rx_queues;
+	unsigned int nb_tx_queues;
 	uint32_t port;
 	uint32_t port_id;
+	/* Offset of the VF from the PF */
+	uint8_t vf_offset;
+	nt_meta_port_type_t type;
+	/* if a virtual port type - the vhid */
+	int vhid;
 	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];
+	/* Multicast ethernet (MAC) addresses. */
+	struct rte_ether_addr mc_addrs[NUM_MULTICAST_ADDRS_PER_PORT];
 	struct pmd_internals *next;
 };
 
drivers/net/ntnic/link_mgmt/nt4ga_link.c new file +176 -0

176 lines not on this page · raw message

drivers/net/ntnic/meson.build +1 -0
index 987768cb92..001c75963e 100644
@@ -22,6 +22,7 @@ includes = [
 # all sources
 sources = files(
     'adapter/nt4ga_adapter.c',
+    'link_mgmt/nt4ga_link.c',
     'nthw/supported/nthw_fpga_9563_055_039_0000.c',
     'nthw/supported/nthw_fpga_instances.c',
     'nthw/supported/nthw_fpga_mod_str_map.c',
drivers/net/ntnic/ntnic_ethdev.c +281 -2

378 lines not on this page · raw message

drivers/net/ntnic/ntnic_mod_reg.c +14 -0
index 3f03299a83..b79929c696 100644
@@ -5,6 +5,20 @@
 
 #include "ntnic_mod_reg.h"
 
+static const struct port_ops *port_ops;
+
+void register_port_ops(const struct port_ops *ops)
+{
+	port_ops = ops;
+}
+
+const struct port_ops *get_port_ops(void)
+{
+	if (port_ops == NULL)
+		port_init();
+	return port_ops;
+}
+
 static const struct adapter_ops *adapter_ops;
 
 void register_adapter_ops(const struct adapter_ops *ops)
drivers/net/ntnic/ntnic_mod_reg.h +49 -1

56 lines not on this page · raw message

drivers/net/ntnic/ntutil/nt_util.c +131 -0

134 lines not on this page · raw message

drivers/net/ntnic/ntutil/nt_util.h +11 -0
index 6dfd7428e1..ea91181a06 100644
@@ -7,6 +7,7 @@
 #define NTOSS_SYSTEM_NT_UTIL_H
 
 #include <stdint.h>
+#include "nt4ga_link.h"
 
 #ifndef ARRAY_SIZE
 #define ARRAY_SIZE(arr) RTE_DIM(arr)
@@ -30,6 +31,11 @@ struct nt_dma_s {
 	uint64_t size;
 };
 
+struct port_link_speed {
+	int port_id;
+	int link_speed;
+};
+
 struct nt_dma_s *nt_dma_alloc(uint64_t size, uint64_t align, int numa);
 void nt_dma_free(struct nt_dma_s *vfio_addr);
 
@@ -40,4 +46,9 @@ struct nt_util_vfio_impl {
 
 void nt_util_vfio_init(struct nt_util_vfio_impl *impl);
 
+int nt_link_speed_to_eth_speed_num(enum nt_link_speed_e nt_link_speed);
+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);
+
 #endif	/* NTOSS_SYSTEM_NT_UTIL_H */
Signature · 1 line
2.45.0
#183 lore raw

PATCH v8 16/21 net/ntnic: add link 100G module ops

In reply to Serhii Iliushyk

As the ntnic can support different speeds,
an abstraction layer for 100G speed is needed.

---
 drivers/net/ntnic/adapter/nt4ga_adapter.c     | 12 ++++-
 .../link_mgmt/link_100g/nt4ga_link_100g.c     | 49 +++++++++++++++++++
 drivers/net/ntnic/meson.build                 |  1 +
 drivers/net/ntnic/ntnic_mod_reg.c             | 14 ++++++
 drivers/net/ntnic/ntnic_mod_reg.h             |  8 +++
 5 files changed, 82 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/ntnic/link_mgmt/link_100g/nt4ga_link_100g.c
drivers/net/ntnic/adapter/nt4ga_adapter.c +10 -2
index e29fda7fbb..17fd8016dd 100644
@@ -125,6 +125,7 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info)
 
 	{
 		int i;
+		const struct link_ops_s *link_ops = NULL;
 		assert(fpga_info->n_fpga_prod_id > 0);
 
 		for (i = 0; i < NUM_ADAPTER_PORTS_MAX; i++) {
@@ -135,8 +136,15 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info)
 		switch (fpga_info->n_fpga_prod_id) {
 		/* NT200A01: 2x100G (Xilinx) */
 		case 9563:	/* NT200A02 (Cap) */
-			NT_LOG(ERR, NTNIC, "NT200A02 100G link module uninitialized\n");
-			res = -1;
+			link_ops = get_100g_link_ops();
+
+			if (link_ops == NULL) {
+				NT_LOG(ERR, NTNIC, "NT200A02 100G link module uninitialized\n");
+				res = -1;
+				break;
+			}
+
+			res = link_ops->link_init(p_adapter_info, p_fpga);
 			break;
 
 		default:
drivers/net/ntnic/link_mgmt/link_100g/nt4ga_link_100g.c new file +49 -0

49 lines not on this page · raw message

drivers/net/ntnic/meson.build +1 -0
index 001c75963e..32f955969f 100644
@@ -22,6 +22,7 @@ includes = [
 # all sources
 sources = files(
     'adapter/nt4ga_adapter.c',
+    'link_mgmt/link_100g/nt4ga_link_100g.c',
     'link_mgmt/nt4ga_link.c',
     'nthw/supported/nthw_fpga_9563_055_039_0000.c',
     'nthw/supported/nthw_fpga_instances.c',
drivers/net/ntnic/ntnic_mod_reg.c +14 -0
index b79929c696..40e22c60fa 100644
@@ -5,6 +5,20 @@
 
 #include "ntnic_mod_reg.h"
 
+static struct link_ops_s *link_100g_ops;
+
+void register_100g_link_ops(struct link_ops_s *ops)
+{
+	link_100g_ops = ops;
+}
+
+const struct link_ops_s *get_100g_link_ops(void)
+{
+	if (link_100g_ops == NULL)
+		link_100g_init();
+	return link_100g_ops;
+}
+
 static const struct port_ops *port_ops;
 
 void register_port_ops(const struct port_ops *ops)
drivers/net/ntnic/ntnic_mod_reg.h +8 -0
index 8d1971a9c4..68629412b7 100644
@@ -13,6 +13,14 @@
 #include "nt4ga_adapter.h"
 #include "ntnic_nthw_fpga_rst_nt200a0x.h"
 
+struct link_ops_s {
+	int (*link_init)(struct adapter_info_s *p_adapter_info, nthw_fpga_t *p_fpga);
+};
+
+void register_100g_link_ops(struct link_ops_s *ops);
+const struct link_ops_s *get_100g_link_ops(void);
+void link_100g_init(void);
+
 struct port_ops {
 	/*
 	 * port:s link mode
Signature · 1 line
2.45.0
#184 lore raw

PATCH v8 17/21 net/ntnic: add generic NIM and I2C modules

In reply to Serhii Iliushyk

As the ntnic can support different port speeds, it also needs to support different NIMs (Network Interface Module). This commit add the generic NIM support for ntnic, such that the specific modules,
such as QSFP28 can be added later.

The communication with NIMs is in the form of I2C, so support for such a module is added as well.

Additionally a thread is added to control the NIM stat machines.

---
v6
* Remove unnecessary comments

---
 drivers/net/ntnic/adapter/nt4ga_adapter.c     |  34 +++
 drivers/net/ntnic/include/nt4ga_adapter.h     |   3 +
 drivers/net/ntnic/include/nt4ga_link.h        |  13 +
 drivers/net/ntnic/include/ntnic_nim.h         |  61 +++++
 .../link_mgmt/link_100g/nt4ga_link_100g.c     | 214 ++++++++++++++++-
 drivers/net/ntnic/link_mgmt/nt4ga_link.c      |  13 +
 drivers/net/ntnic/meson.build                 |   3 +
 drivers/net/ntnic/nim/i2c_nim.c               | 224 ++++++++++++++++++
 drivers/net/ntnic/nim/i2c_nim.h               |  24 ++
 drivers/net/ntnic/nim/nim_defines.h           |  29 +++
 .../net/ntnic/nthw/core/include/nthw_core.h   |   1 +
 .../net/ntnic/nthw/core/include/nthw_i2cm.h   |  50 ++++
 drivers/net/ntnic/nthw/core/nthw_fpga.c       |   3 +
 drivers/net/ntnic/nthw/core/nthw_i2cm.c       | 192 +++++++++++++++
 drivers/net/ntnic/nthw/nthw_drv.h             |   1 +
 drivers/net/ntnic/ntnic_mod_reg.h             |   7 +
 16 files changed, 871 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/ntnic/include/ntnic_nim.h
 create mode 100644 drivers/net/ntnic/nim/i2c_nim.c
 create mode 100644 drivers/net/ntnic/nim/i2c_nim.h
 create mode 100644 drivers/net/ntnic/nim/nim_defines.h
 create mode 100644 drivers/net/ntnic/nthw/core/include/nthw_i2cm.h
 create mode 100644 drivers/net/ntnic/nthw/core/nthw_i2cm.c
drivers/net/ntnic/adapter/nt4ga_adapter.c +34 -0
index 17fd8016dd..9f671dda78 100644
@@ -9,6 +9,32 @@
 #include "nthw_fpga.h"
 #include "ntnic_mod_reg.h"
 
+/*
+ * Global variables shared by NT adapter types
+ */
+rte_thread_t monitor_tasks[NUM_ADAPTER_MAX];
+volatile int monitor_task_is_running[NUM_ADAPTER_MAX];
+
+/*
+ * Signal-handler to stop all monitor threads
+ */
+static void stop_monitor_tasks(int signum)
+{
+	const size_t N = ARRAY_SIZE(monitor_task_is_running);
+	size_t i;
+
+	/* Stop all monitor tasks */
+	for (i = 0; i < N; i++) {
+		const int is_running = monitor_task_is_running[i];
+		monitor_task_is_running[i] = 0;
+
+		if (signum == -1 && is_running != 0) {
+			rte_thread_join(monitor_tasks[i], NULL);
+			memset(&monitor_tasks[i], 0, sizeof(monitor_tasks[0]));
+		}
+	}
+}
+
 static int nt4ga_adapter_show_info(struct adapter_info_s *p_adapter_info, FILE *pfh)
 {
 	const char *const p_dev_name = p_adapter_info->p_dev_name;
@@ -35,6 +61,9 @@ static int nt4ga_adapter_show_info(struct adapter_info_s *p_adapter_info, FILE *
 		p_fpga_info->n_fpga_ver_id, p_fpga_info->n_fpga_rev_id, p_fpga_info->n_fpga_ident,
 		p_fpga_info->n_fpga_build_time);
 	fprintf(pfh, "%s: FpgaDebugMode=0x%x\n", p_adapter_id_str, p_fpga_info->n_fpga_debug_mode);
+	fprintf(pfh, "%s: Nims=%d PhyPorts=%d PhyQuads=%d RxPorts=%d TxPorts=%d\n",
+		p_adapter_id_str, p_fpga_info->n_nims, p_fpga_info->n_phy_ports,
+		p_fpga_info->n_phy_quads, p_fpga_info->n_rx_ports, p_fpga_info->n_tx_ports);
 	fprintf(pfh, "%s: Hw=0x%02X_rev%d: %s\n", p_adapter_id_str, p_hw_info->hw_platform_id,
 		p_fpga_info->nthw_hw_info.hw_id, p_fpga_info->nthw_hw_info.hw_plat_id_str);
 	fprintf(pfh, "%s: MCU Details:\n", p_adapter_id_str);
@@ -56,6 +85,7 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info)
 	 * (nthw_fpga_init())
 	 */
 	int n_phy_ports = -1;
+	int n_nim_ports = -1;
 	int res = -1;
 	nthw_fpga_t *p_fpga = NULL;
 
@@ -122,6 +152,8 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info)
 	assert(p_fpga);
 	n_phy_ports = fpga_info->n_phy_ports;
 	assert(n_phy_ports >= 1);
+	n_nim_ports = fpga_info->n_nims;
+	assert(n_nim_ports >= 1);
 
 	{
 		int i;
@@ -171,6 +203,8 @@ static int nt4ga_adapter_deinit(struct adapter_info_s *p_adapter_info)
 	int i;
 	int res;
 
+	stop_monitor_tasks(-1);
+
 	nthw_fpga_shutdown(&p_adapter_info->fpga_info);
 
 	/* Rac rab reset flip flop */
drivers/net/ntnic/include/nt4ga_adapter.h +3 -0
index ed14936b38..4b204742a2 100644
@@ -39,5 +39,8 @@ typedef struct adapter_info_s {
 	int n_tx_host_buffers;
 } adapter_info_t;
 
+extern rte_thread_t monitor_tasks[NUM_ADAPTER_MAX];
+extern volatile int monitor_task_is_running[NUM_ADAPTER_MAX];
+
 
 #endif	/* _NT4GA_ADAPTER_H_ */
drivers/net/ntnic/include/nt4ga_link.h +13 -0
index 849261ce3a..0851057f81 100644
@@ -7,6 +7,7 @@
 #define NT4GA_LINK_H_
 
 #include "ntos_drv.h"
+#include "ntnic_nim.h"
 
 enum nt_link_state_e {
 	NT_LINK_STATE_UNKNOWN = 0,	/* The link state has not been read yet */
@@ -41,6 +42,8 @@ enum nt_link_auto_neg_e {
 
 typedef struct link_state_s {
 	bool link_disabled;
+	bool nim_present;
+	bool lh_nim_absent;
 	bool link_up;
 	enum nt_link_state_e link_state;
 	enum nt_link_state_e link_state_latched;
@@ -73,12 +76,22 @@ typedef struct port_action_s {
 	uint32_t port_lpbk_mode;
 } port_action_t;
 
+typedef struct adapter_100g_s {
+	nim_i2c_ctx_t nim_ctx[NUM_ADAPTER_PORTS_MAX];	/* Should be the first field */
+} adapter_100g_t;
+
+typedef union adapter_var_s {
+	nim_i2c_ctx_t nim_ctx[NUM_ADAPTER_PORTS_MAX];	/* First field in all the adapters type */
+	adapter_100g_t var100g;
+} adapter_var_u;
+
 typedef struct nt4ga_link_s {
 	link_state_t link_state[NUM_ADAPTER_PORTS_MAX];
 	link_info_t link_info[NUM_ADAPTER_PORTS_MAX];
 	port_action_t port_action[NUM_ADAPTER_PORTS_MAX];
 	uint32_t speed_capa;
 	bool variables_initialized;
+	adapter_var_u u;
 } nt4ga_link_t;
 
 #endif	/* NT4GA_LINK_H_ */
drivers/net/ntnic/include/ntnic_nim.h new file +61 -0

61 lines not on this page · raw message

drivers/net/ntnic/link_mgmt/link_100g/nt4ga_link_100g.c +213 -1

241 lines not on this page · raw message

drivers/net/ntnic/link_mgmt/nt4ga_link.c +13 -0
index ad23046aae..bc362776fc 100644
@@ -12,6 +12,7 @@
 #include "ntnic_mod_reg.h"
 
 #include "nt4ga_link.h"
+#include "i2c_nim.h"
 
 /*
  * port: speed capabilities
@@ -26,6 +27,16 @@ static uint32_t nt4ga_port_get_link_speed_capabilities(struct adapter_info_s *p,
 	return nt_link_speed_capa;
 }
 
+/*
+ * port: nim present
+ */
+static bool nt4ga_port_get_nim_present(struct adapter_info_s *p, int port)
+{
+	nt4ga_link_t *const p_link = &p->nt4ga_link;
+	const bool nim_present = p_link->link_state[port].nim_present;
+	return nim_present;
+}
+
 /*
  * port: link mode
  */
@@ -131,6 +142,8 @@ static uint32_t nt4ga_port_get_loopback_mode(struct adapter_info_s *p, int port)
 
 
 static const struct port_ops ops = {
+	.get_nim_present = nt4ga_port_get_nim_present,
+
 	/*
 	 * port:s link mode
 	 */
drivers/net/ntnic/meson.build +3 -0
index 32f955969f..efea37e61a 100644
@@ -17,6 +17,7 @@ includes = [
     include_directories('nthw'),
     include_directories('nthw/supported'),
     include_directories('nthw/model'),
+    include_directories('nim/'),
 ]
 
 # all sources
@@ -24,6 +25,7 @@ sources = files(
     'adapter/nt4ga_adapter.c',
     'link_mgmt/link_100g/nt4ga_link_100g.c',
     'link_mgmt/nt4ga_link.c',
+    'nim/i2c_nim.c',
     'nthw/supported/nthw_fpga_9563_055_039_0000.c',
     'nthw/supported/nthw_fpga_instances.c',
     'nthw/supported/nthw_fpga_mod_str_map.c',
@@ -33,6 +35,7 @@ sources = files(
     'nthw/core/nt200a0x/reset/nthw_fpga_rst_nt200a0x.c',
     'nthw/core/nthw_fpga.c',
     'nthw/core/nthw_hif.c',
+    'nthw/core/nthw_i2cm.c',
     'nthw/core/nthw_iic.c',
     'nthw/core/nthw_pcie3.c',
     'nthw/core/nthw_sdc.c',
drivers/net/ntnic/nim/i2c_nim.c new file +224 -0

224 lines not on this page · raw message

drivers/net/ntnic/nim/i2c_nim.h new file +24 -0
new file mode 100644
index 0000000000..e89ae47835
@@ -0,0 +1,24 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef I2C_NIM_H_
+#define I2C_NIM_H_
+
+#include "ntnic_nim.h"
+
+/*
+ * Returns a type name such as "SFP/SFP+" for a given NIM type identifier,
+ * or the string "ILLEGAL!".
+ */
+const char *nim_id_to_text(uint8_t nim_id);
+
+/*
+ * This function tries to classify NIM based on it's ID and some register reads
+ * and collects information into ctx structure. The @extra parameter could contain
+ * the initialization argument for specific type of NIMS.
+ */
+int construct_and_preinit_nim(nim_i2c_ctx_p ctx);
+
+#endif	/* I2C_NIM_H_ */
drivers/net/ntnic/nim/nim_defines.h new file +29 -0
new file mode 100644
index 0000000000..9ba861bb4f
@@ -0,0 +1,29 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef NIM_DEFINES_H_
+#define NIM_DEFINES_H_
+
+#define NIM_IDENTIFIER_ADDR 0	/* 1 byte */
+
+/* I2C addresses */
+#define NIM_I2C_0XA0 0xA0	/* Basic I2C address */
+#define NIM_I2C_0XA2 0xA2	/* Diagnostic monitoring */
+
+typedef enum {
+	NIM_OPTION_TX_DISABLE,
+	/* Indicates that the module should be checked for the two next FEC types */
+	NIM_OPTION_FEC,
+	NIM_OPTION_MEDIA_SIDE_FEC,
+	NIM_OPTION_HOST_SIDE_FEC,
+	NIM_OPTION_RX_ONLY
+} nim_option_t;
+
+enum nt_nim_identifier_e {
+	NT_NIM_UNKNOWN = 0x00,	/* Nim type is unknown */
+};
+typedef enum nt_nim_identifier_e nt_nim_identifier_t;
+
+#endif	/* NIM_DEFINES_H_ */
drivers/net/ntnic/nthw/core/include/nthw_core.h +1 -0
index 5648bd8983..8d9d78b86d 100644
@@ -15,6 +15,7 @@
 #include "nthw_hif.h"
 #include "nthw_pcie3.h"
 #include "nthw_iic.h"
+#include "nthw_i2cm.h"
 
 #include "nthw_sdc.h"
 
drivers/net/ntnic/nthw/core/include/nthw_i2cm.h new file +50 -0

50 lines not on this page · raw message

drivers/net/ntnic/nthw/core/nthw_fpga.c +3 -0
index 38169176a5..d70205e5e3 100644
@@ -19,12 +19,14 @@ int nthw_fpga_get_param_info(struct fpga_info_s *p_fpga_info, nthw_fpga_t *p_fpg
 {
 	mcu_info_t *p_mcu_info = &p_fpga_info->mcu_info;
 
+	const int n_nims = nthw_fpga_get_product_param(p_fpga, NT_NIMS, -1);
 	const int n_phy_ports = nthw_fpga_get_product_param(p_fpga, NT_PHY_PORTS, -1);
 	const int n_phy_quads = nthw_fpga_get_product_param(p_fpga, NT_PHY_QUADS, -1);
 	const int n_rx_ports = nthw_fpga_get_product_param(p_fpga, NT_RX_PORTS, -1);
 	const int n_tx_ports = nthw_fpga_get_product_param(p_fpga, NT_TX_PORTS, -1);
 	const int n_vf_offset = nthw_fpga_get_product_param(p_fpga, NT_HIF_VF_OFFSET, 4);
 
+	p_fpga_info->n_nims = n_nims;
 	p_fpga_info->n_phy_ports = n_phy_ports;
 	p_fpga_info->n_phy_quads = n_phy_quads;
 	p_fpga_info->n_rx_ports = n_rx_ports;
@@ -236,6 +238,7 @@ int nthw_fpga_init(struct fpga_info_s *p_fpga_info)
 	nthw_fpga_get_param_info(p_fpga_info, p_fpga);
 
 	/* debug: report params */
+	NT_LOG(DBG, NTHW, "%s: NT_NIMS=%d\n", p_adapter_id_str, p_fpga_info->n_nims);
 	NT_LOG(DBG, NTHW, "%s: NT_PHY_PORTS=%d\n", p_adapter_id_str, p_fpga_info->n_phy_ports);
 	NT_LOG(DBG, NTHW, "%s: NT_PHY_QUADS=%d\n", p_adapter_id_str, p_fpga_info->n_phy_quads);
 	NT_LOG(DBG, NTHW, "%s: NT_RX_PORTS=%d\n", p_adapter_id_str, p_fpga_info->n_rx_ports);
drivers/net/ntnic/nthw/core/nthw_i2cm.c new file +192 -0

192 lines not on this page · raw message

drivers/net/ntnic/nthw/nthw_drv.h +1 -0
index 071618eb6e..de60ae171e 100644
@@ -52,6 +52,7 @@ typedef struct fpga_info_s {
 
 	int n_fpga_debug_mode;
 
+	int n_nims;
 	int n_phy_ports;
 	int n_phy_quads;
 	int n_rx_ports;
drivers/net/ntnic/ntnic_mod_reg.h +7 -0
index 68629412b7..3189b04f33 100644
@@ -22,6 +22,8 @@ const struct link_ops_s *get_100g_link_ops(void);
 void link_100g_init(void);
 
 struct port_ops {
+	bool (*get_nim_present)(struct adapter_info_s *p, int port);
+
 	/*
 	 * port:s link mode
 	 */
@@ -60,6 +62,11 @@ struct port_ops {
 
 	uint32_t (*get_link_speed_capabilities)(struct adapter_info_s *p, int port);
 
+	/*
+	 * port: nim capabilities
+	 */
+	nim_i2c_ctx_t (*get_nim_capabilities)(struct adapter_info_s *p, int port);
+
 	/*
 	 * port: tx power
 	 */
Signature · 1 line
2.45.0
#185 lore raw

PATCH v8 18/21 net/ntnic: add QSFP support

In reply to Serhii Iliushyk

Includes support for QSFP and QSFP+.

---
 drivers/net/ntnic/include/ntnic_nim.h         |  10 +
 .../link_mgmt/link_100g/nt4ga_link_100g.c     |  12 +-
 drivers/net/ntnic/nim/i2c_nim.c               | 310 +++++++++++++++++-
 drivers/net/ntnic/nim/i2c_nim.h               |  14 +-
 drivers/net/ntnic/nim/nim_defines.h           |   3 +
 drivers/net/ntnic/nim/qsfp_registers.h        |  43 +++
 6 files changed, 389 insertions(+), 3 deletions(-)
 create mode 100644 drivers/net/ntnic/nim/qsfp_registers.h
drivers/net/ntnic/include/ntnic_nim.h +10 -0
index 263875a857..300842b570 100644
@@ -15,6 +15,8 @@ typedef enum i2c_type {
 enum nt_port_type_e {
 	NT_PORT_TYPE_NOT_AVAILABLE = 0,	/* The NIM/port type is not available (unknown) */
 	NT_PORT_TYPE_NOT_RECOGNISED,	/* The NIM/port type not recognized */
+	NT_PORT_TYPE_QSFP_PLUS_NOT_PRESENT,	/* QSFP type but slot is empty */
+	NT_PORT_TYPE_QSFP_PLUS,	/* QSFP type */
 };
 
 typedef enum nt_port_type_e nt_port_type_t, *nt_port_type_p;
@@ -51,6 +53,14 @@ typedef struct nim_i2c_ctx {
 	bool tx_disable;
 	bool dmi_supp;
 
+	union {
+		struct {
+			bool rx_only;
+			union {
+			} specific_u;
+		} qsfp;
+
+	} specific_u;
 } nim_i2c_ctx_t, *nim_i2c_ctx_p;
 
 struct nim_sensor_group {
drivers/net/ntnic/link_mgmt/link_100g/nt4ga_link_100g.c +11 -1
index 4a8d28af9c..69d0a5d24a 100644
@@ -18,6 +18,7 @@ static int _create_nim(adapter_info_t *drv, int port)
 	int res = 0;
 	const uint8_t valid_nim_id = 17U;
 	nim_i2c_ctx_t *nim_ctx;
+	sfp_nim_state_t nim;
 	nt4ga_link_t *link_info = &drv->nt4ga_link;
 
 	assert(port >= 0 && port < NUM_ADAPTER_PORTS_MAX);
@@ -31,11 +32,20 @@ static int _create_nim(adapter_info_t *drv, int port)
 	 */
 	nt_os_wait_usec(1000000);	/* pause 1.0s */
 
-	res = construct_and_preinit_nim(nim_ctx);
+	res = construct_and_preinit_nim(nim_ctx, NULL);
 
 	if (res)
 		return res;
 
+	res = nim_state_build(nim_ctx, &nim);
+
+	if (res)
+		return res;
+
+	NT_LOG(DBG, NTHW, "%s: NIM id = %u (%s), br = %u, vendor = '%s', pn = '%s', sn='%s'\n",
+		drv->mp_port_id_str[port], nim_ctx->nim_id, nim_id_to_text(nim_ctx->nim_id), nim.br,
+		nim_ctx->vendor_name, nim_ctx->prod_no, nim_ctx->serial_no);
+
 	/*
 	 * Does the driver support the NIM module type?
 	 */
drivers/net/ntnic/nim/i2c_nim.c +309 -1

347 lines not on this page · raw message

drivers/net/ntnic/nim/i2c_nim.h +13 -1
index e89ae47835..edb6dcf1b6 100644
@@ -8,17 +8,29 @@
 
 #include "ntnic_nim.h"
 
+typedef struct sfp_nim_state {
+	uint8_t br;	/* bit rate, units of 100 MBits/sec */
+} sfp_nim_state_t, *sfp_nim_state_p;
+
+/*
+ * Builds an nim state for the port implied by `ctx`, returns zero
+ * if successful, and non-zero otherwise. SFP and QSFP nims are supported
+ */
+int nim_state_build(nim_i2c_ctx_t *ctx, sfp_nim_state_t *state);
+
 /*
  * Returns a type name such as "SFP/SFP+" for a given NIM type identifier,
  * or the string "ILLEGAL!".
  */
 const char *nim_id_to_text(uint8_t nim_id);
 
+int nim_qsfp_plus_nim_set_tx_laser_disable(nim_i2c_ctx_t *ctx, bool disable, int lane_idx);
+
 /*
  * This function tries to classify NIM based on it's ID and some register reads
  * and collects information into ctx structure. The @extra parameter could contain
  * the initialization argument for specific type of NIMS.
  */
-int construct_and_preinit_nim(nim_i2c_ctx_p ctx);
+int construct_and_preinit_nim(nim_i2c_ctx_p ctx, void *extra);
 
 #endif	/* I2C_NIM_H_ */
drivers/net/ntnic/nim/nim_defines.h +3 -0
index 9ba861bb4f..e5a033a3d4 100644
@@ -7,6 +7,7 @@
 #define NIM_DEFINES_H_
 
 #define NIM_IDENTIFIER_ADDR 0	/* 1 byte */
+#define QSFP_EXTENDED_IDENTIFIER 129
 
 /* I2C addresses */
 #define NIM_I2C_0XA0 0xA0	/* Basic I2C address */
@@ -23,6 +24,8 @@ typedef enum {
 
 enum nt_nim_identifier_e {
 	NT_NIM_UNKNOWN = 0x00,	/* Nim type is unknown */
+	NT_NIM_QSFP = 0x0C,	/* Nim type = QSFP */
+	NT_NIM_QSFP_PLUS = 0x0D,/* Nim type = QSFP+ */
 };
 typedef enum nt_nim_identifier_e nt_nim_identifier_t;
 
drivers/net/ntnic/nim/qsfp_registers.h new file +43 -0

43 lines not on this page · raw message

Signature · 1 line
2.45.0
#186 lore raw

PATCH v8 19/21 net/ntnic: add QSFP28 support

In reply to Serhii Iliushyk

Includes support for QSFP28

---
 drivers/net/ntnic/include/ntnic_nim.h    |  21 ++
 drivers/net/ntnic/link_mgmt/nt4ga_link.c |  25 +++
 drivers/net/ntnic/nim/i2c_nim.c          | 267 ++++++++++++++++++++++-
 drivers/net/ntnic/nim/nim_defines.h      |   1 +
 4 files changed, 313 insertions(+), 1 deletion(-)
drivers/net/ntnic/include/ntnic_nim.h +21 -0
index 300842b570..f3bd159130 100644
@@ -17,6 +17,19 @@ enum nt_port_type_e {
 	NT_PORT_TYPE_NOT_RECOGNISED,	/* The NIM/port type not recognized */
 	NT_PORT_TYPE_QSFP_PLUS_NOT_PRESENT,	/* QSFP type but slot is empty */
 	NT_PORT_TYPE_QSFP_PLUS,	/* QSFP type */
+	NT_PORT_TYPE_QSFP28_NOT_PRESENT,/* QSFP28 type but slot is empty */
+	NT_PORT_TYPE_QSFP28,	/* QSFP28 type */
+	NT_PORT_TYPE_QSFP28_SR4,/* QSFP28-SR4 type */
+	NT_PORT_TYPE_QSFP28_LR4,/* QSFP28-LR4 type */
+	NT_PORT_TYPE_QSFP28_CR_CA_L,	/* QSFP28-CR-CA-L type */
+	NT_PORT_TYPE_QSFP28_CR_CA_S,	/* QSFP28-CR-CA-S type */
+	NT_PORT_TYPE_QSFP28_CR_CA_N,	/* QSFP28-CR-CA-N type */
+	/* QSFP28-FR type. Uses PAM4 modulation on one lane only */
+	NT_PORT_TYPE_QSFP28_FR,
+	/* QSFP28-DR type. Uses PAM4 modulation on one lane only */
+	NT_PORT_TYPE_QSFP28_DR,
+	/* QSFP28-LR type. Uses PAM4 modulation on one lane only */
+	NT_PORT_TYPE_QSFP28_LR,
 };
 
 typedef enum nt_port_type_e nt_port_type_t, *nt_port_type_p;
@@ -56,7 +69,15 @@ typedef struct nim_i2c_ctx {
 	union {
 		struct {
 			bool rx_only;
+			bool qsfp28;
 			union {
+				struct {
+					uint8_t rev_compliance;
+					bool media_side_fec_ctrl;
+					bool host_side_fec_ctrl;
+					bool media_side_fec_ena;
+					bool host_side_fec_ena;
+				} qsfp28;
 			} specific_u;
 		} qsfp;
 
drivers/net/ntnic/link_mgmt/nt4ga_link.c +25 -0
index bc362776fc..4dc1c3d467 100644
@@ -140,6 +140,26 @@ static uint32_t nt4ga_port_get_loopback_mode(struct adapter_info_s *p, int port)
 	return p_link->port_action[port].port_lpbk_mode;
 }
 
+/*
+ * port: tx power
+ */
+static int nt4ga_port_tx_power(struct adapter_info_s *p, int port, bool disable)
+{
+	nt4ga_link_t *link_info = &p->nt4ga_link;
+
+	if (link_info->u.nim_ctx[port].port_type == NT_PORT_TYPE_QSFP28_SR4 ||
+		link_info->u.nim_ctx[port].port_type == NT_PORT_TYPE_QSFP28 ||
+		link_info->u.nim_ctx[port].port_type == NT_PORT_TYPE_QSFP28_LR4) {
+		nim_i2c_ctx_t *nim_ctx = &link_info->u.var100g.nim_ctx[port];
+
+		if (!nim_ctx->specific_u.qsfp.rx_only) {
+			if (nim_qsfp_plus_nim_set_tx_laser_disable(nim_ctx, disable, -1) != 0)
+				return 1;
+		}
+	}
+
+	return 0;
+}
 
 static const struct port_ops ops = {
 	.get_nim_present = nt4ga_port_get_nim_present,
@@ -181,6 +201,11 @@ static const struct port_ops ops = {
 	.get_loopback_mode = nt4ga_port_get_loopback_mode,
 
 	.get_link_speed_capabilities = nt4ga_port_get_link_speed_capabilities,
+
+	/*
+	 * port: tx power
+	 */
+	.tx_power = nt4ga_port_tx_power,
 };
 
 void port_init(void)
drivers/net/ntnic/nim/i2c_nim.c +266 -1

316 lines not on this page · raw message

drivers/net/ntnic/nim/nim_defines.h +1 -0
index e5a033a3d4..8e17b263c5 100644
@@ -26,6 +26,7 @@ enum nt_nim_identifier_e {
 	NT_NIM_UNKNOWN = 0x00,	/* Nim type is unknown */
 	NT_NIM_QSFP = 0x0C,	/* Nim type = QSFP */
 	NT_NIM_QSFP_PLUS = 0x0D,/* Nim type = QSFP+ */
+	NT_NIM_QSFP28 = 0x11,	/* Nim type = QSFP28 */
 };
 typedef enum nt_nim_identifier_e nt_nim_identifier_t;
 
Signature · 1 line
2.45.0
#187 lore raw

PATCH v8 20/21 net/ntnic: add GPIO communication for NIMs

In reply to Serhii Iliushyk

For NIM reset sequence GPIO communication is used. After this commit the NIMs supported by ntnic
is able to start up and be controlled fully by the adapter.

---
v5
* Fix Typo/Spelling

---
 drivers/net/ntnic/include/nt4ga_link.h        |   1 +
 .../link_mgmt/link_100g/nt4ga_link_100g.c     |  71 ++++++++-
 drivers/net/ntnic/meson.build                 |   1 +
 .../net/ntnic/nthw/core/include/nthw_core.h   |   1 +
 .../ntnic/nthw/core/include/nthw_gpio_phy.h   |  48 ++++++
 drivers/net/ntnic/nthw/core/nthw_gpio_phy.c   | 145 ++++++++++++++++++
 6 files changed, 263 insertions(+), 4 deletions(-)
 create mode 100644 drivers/net/ntnic/nthw/core/include/nthw_gpio_phy.h
 create mode 100644 drivers/net/ntnic/nthw/core/nthw_gpio_phy.c
drivers/net/ntnic/include/nt4ga_link.h +1 -0
index 0851057f81..5a16afea2a 100644
@@ -78,6 +78,7 @@ typedef struct port_action_s {
 
 typedef struct adapter_100g_s {
 	nim_i2c_ctx_t nim_ctx[NUM_ADAPTER_PORTS_MAX];	/* Should be the first field */
+	nthw_gpio_phy_t gpio_phy[NUM_ADAPTER_PORTS_MAX];
 } adapter_100g_t;
 
 typedef union adapter_var_s {
drivers/net/ntnic/link_mgmt/link_100g/nt4ga_link_100g.c +67 -4

145 lines not on this page · raw message

drivers/net/ntnic/meson.build +1 -0
index efea37e61a..e995ed75b0 100644
@@ -34,6 +34,7 @@ sources = files(
     'nthw/core/nt200a0x/reset/nthw_fpga_rst9563.c',
     'nthw/core/nt200a0x/reset/nthw_fpga_rst_nt200a0x.c',
     'nthw/core/nthw_fpga.c',
+    'nthw/core/nthw_gpio_phy.c',
     'nthw/core/nthw_hif.c',
     'nthw/core/nthw_i2cm.c',
     'nthw/core/nthw_iic.c',
drivers/net/ntnic/nthw/core/include/nthw_core.h +1 -0
index 8d9d78b86d..5cce56e13f 100644
@@ -17,6 +17,7 @@
 #include "nthw_iic.h"
 #include "nthw_i2cm.h"
 
+#include "nthw_gpio_phy.h"
 #include "nthw_sdc.h"
 
 #include "nthw_si5340.h"
drivers/net/ntnic/nthw/core/include/nthw_gpio_phy.h new file +48 -0

48 lines not on this page · raw message

drivers/net/ntnic/nthw/core/nthw_gpio_phy.c new file +145 -0

145 lines not on this page · raw message

Signature · 1 line
2.45.0
#188 lore raw

PATCH v8 21/21 net/ntnic: add physical layer control module

In reply to Serhii Iliushyk

Adds functionality to control the physical layer of the OSI model. This takes the form of the module
MAC PCS (Media Access Control Physical Coding Sublayer).
The functionality is used by the 100G link functionality to establish link.

---
 drivers/net/ntnic/include/nt4ga_link.h        |   1 +
 .../link_mgmt/link_100g/nt4ga_link_100g.c     | 393 +++++++-
 drivers/net/ntnic/meson.build                 |   1 +
 .../net/ntnic/nthw/core/include/nthw_core.h   |   1 +
 .../ntnic/nthw/core/include/nthw_mac_pcs.h    | 250 +++++
 drivers/net/ntnic/nthw/core/nthw_mac_pcs.c    | 894 ++++++++++++++++++
 6 files changed, 1538 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/ntnic/nthw/core/include/nthw_mac_pcs.h
 create mode 100644 drivers/net/ntnic/nthw/core/nthw_mac_pcs.c
drivers/net/ntnic/include/nt4ga_link.h +1 -0
index 5a16afea2a..8366484830 100644
@@ -78,6 +78,7 @@ typedef struct port_action_s {
 
 typedef struct adapter_100g_s {
 	nim_i2c_ctx_t nim_ctx[NUM_ADAPTER_PORTS_MAX];	/* Should be the first field */
+	nthw_mac_pcs_t mac_pcs100g[NUM_ADAPTER_PORTS_MAX];
 	nthw_gpio_phy_t gpio_phy[NUM_ADAPTER_PORTS_MAX];
 } adapter_100g_t;
 
drivers/net/ntnic/link_mgmt/link_100g/nt4ga_link_100g.c +391 -2

499 lines not on this page · raw message

drivers/net/ntnic/meson.build +1 -0
index e995ed75b0..0a6308f6bb 100644
@@ -38,6 +38,7 @@ sources = files(
     'nthw/core/nthw_hif.c',
     'nthw/core/nthw_i2cm.c',
     'nthw/core/nthw_iic.c',
+    'nthw/core/nthw_mac_pcs.c',
     'nthw/core/nthw_pcie3.c',
     'nthw/core/nthw_sdc.c',
     'nthw/core/nthw_si5340.c',
drivers/net/ntnic/nthw/core/include/nthw_core.h +1 -0
index 5cce56e13f..fe32891712 100644
@@ -18,6 +18,7 @@
 #include "nthw_i2cm.h"
 
 #include "nthw_gpio_phy.h"
+#include "nthw_mac_pcs.h"
 #include "nthw_sdc.h"
 
 #include "nthw_si5340.h"
drivers/net/ntnic/nthw/core/include/nthw_mac_pcs.h new file +250 -0

250 lines not on this page · raw message

drivers/net/ntnic/nthw/core/nthw_mac_pcs.c new file +894 -0

894 lines not on this page · raw message

Signature · 1 line
2.45.0
#189 lore raw

Re: [PATCH v8 01/21] net/ntnic: add ethdev and makes PMD available

In reply to Serhii Iliushyk
Quoted 38 lines · Serhii Iliushyk

Add initial ntnic ethdev skeleton and register PCI probe functions Update documentation: Device description and feature list

---
v6
* Remove unused includes
* Remove EOF markers
* Remove unnecesarry commpiller flags
* Update documentation INI and RST files
* Remove uncovered features
* Add features according to DPDK reqirements
* Add link on NT200A02 description
* Rename res(short for result) to ret(short for return)
* Fix unnecessary set of the driver name
* The driver name is set by macro RTE_PMD_REGISTER_PCI
* Set sentinel value for PCI id_table
* NULL value can lead to the crush on function rte_pci_match
* Remove unnecessary comments
v7
* Move features list to the dedicated patches
* Update release note file

---
 .mailmap                               |  1 +
 MAINTAINERS                            |  7 ++++
 doc/guides/nics/features/ntnic.ini     |  8 +++++
 doc/guides/nics/index.rst              |  1 +
 doc/guides/nics/ntnic.rst              | 39 ++++++++++++++++++++
 doc/guides/rel_notes/release_24_07.rst | 10 ++++++
 drivers/net/meson.build                |  1 +
 drivers/net/ntnic/meson.build          | 18 ++++++++++
 drivers/net/ntnic/ntnic_ethdev.c       | 49 ++++++++++++++++++++++++++
 9 files changed, 134 insertions(+)
 create mode 100644 doc/guides/nics/features/ntnic.ini
 create mode 100644 doc/guides/nics/ntnic.rst
 create mode 100644 drivers/net/ntnic/meson.build
 create mode 100644 drivers/net/ntnic/ntnic_ethdev.c

<...>

Quoted 6 lines
MAINTAINERS +0 -0
index 533f707d5f..0359368981 100644
@@ -855,6 +855,13 @@ F: drivers/net/octeon_ep/
 F: doc/guides/nics/features/octeon_ep.ini

MAINTAINERS F: drivers/net/octeon_ep/ · line 865

Quoted 10 lines
MAINTAINERS +7 -0
 F: doc/guides/nics/octeon_ep.rst
 
+Napatech ntnic
+M: Christian Koue Muf <[email protected]>
+M: Serhii Iliushyk <[email protected]>
+F: drivers/net/ntnic/
+F: doc/guides/nics/ntnic.rst
+F: doc/guides/nics/features/ntnic.ini
+
 

What about updating as "Napatech ntnic - EXPERIMENTAL", when basic functionality is upstreamed and tested, experimental tag can be removed.

<...>

doc/guides/rel_notes/release_24_07.rst New Features · line 158

Quoted 10 lines
doc/guides/rel_notes/release_24_07.rst +1 -0
index e50afed0d5..332a959618 100644
@@ -154,6 +154,16 @@ New Features
 
   Added an API that allows the user to reclaim the defer queue with RCU.
 
+* **Added Napatech ntnic experimental PMD driver.**
 

What do you think "Added Napatech ntnic net driver."?

doc/guides/rel_notes/release_24_07.rst New Features · line 167

Quoted 10 lines
doc/guides/rel_notes/release_24_07.rst +9 -0
+
+  * Added the experimental PMD driver
+
+    - Ability to initialize the NIC (NT200A02)
+    - Supporting only one FPGA firmware (9563.55.39)
+    - Ability to bring up the 100G link
+    - Supporting QSFP/QSFP+/QSFP28 NIM
+    - Does not support datapath
+    - Does not support RTE flow API
 

May drop flow API, as datapath being missing implies it.

Also release notes updates are grouped per device group, and alphabetically sorted withing group. For this can you please move above update just below "Marvell cnxk net driver"?

#190 lore raw

Re: [PATCH v8 01/21] net/ntnic: add ethdev and makes PMD available

In reply to Serhii Iliushyk
Quoted 5 lines · Serhii Iliushyk

Add initial ntnic ethdev skeleton and register PCI probe functions Update documentation: Device description and feature list

Hi Serhii,

I put some comments but main issue is build failure after each patch, can you please check?

Btw, -rc2 released today, before sending a new version please wait for next-net to be rebased on it, probably I will do it today. And driver can target -rc3.

Thanks,
ferruh

#191 lore raw

PATCH v9 1/21 net/ntnic: add ethdev and makes PMD available

In reply to Serhii Iliushyk

Add initial ntnic ethdev skeleton and register PCI probe functions Update documentation: Device description and feature list

---
v6
* Remove unused includes
* Remove EOF markers
* Remove unnecesarry commpiller flags
* Update documentation INI and RST files
* Remove uncovered features
* Add features according to DPDK reqirements
* Add link on NT200A02 description
* Rename res(short for result) to ret(short for return)
* Fix unnecessary set of the driver name
* The driver name is set by macro RTE_PMD_REGISTER_PCI
* Set sentinel value for PCI id_table
* NULL value can lead to the crush on function rte_pci_match
* Remove unnecessary comments
v7
* Move features list to the dedicated patches
* Update release note file
v9
* Marked driver features as Experimantal

---
 .mailmap                               |  1 +
 MAINTAINERS                            |  7 ++++
 doc/guides/nics/features/ntnic.ini     |  8 +++++
 doc/guides/nics/index.rst              |  1 +
 doc/guides/nics/ntnic.rst              | 39 ++++++++++++++++++++
 doc/guides/rel_notes/release_24_07.rst | 10 ++++++
 drivers/net/meson.build                |  1 +
 drivers/net/ntnic/meson.build          | 18 ++++++++++
 drivers/net/ntnic/ntnic_ethdev.c       | 49 ++++++++++++++++++++++++++
 9 files changed, 134 insertions(+)
 create mode 100644 doc/guides/nics/features/ntnic.ini
 create mode 100644 doc/guides/nics/ntnic.rst
 create mode 100644 drivers/net/ntnic/meson.build
 create mode 100644 drivers/net/ntnic/ntnic_ethdev.c
.mailmap +1 -0
index 3f3f0442e5..ee567cf16e 100644
@@ -1321,6 +1321,7 @@ Sergey Madaminov <[email protected]>
 Sergey Mironov <[email protected]>
 Sergey Temerkhanov <[email protected]>
 Sergio Gonzalez Monroy <[email protected]>
+Serhii Iliushyk <[email protected]>
 Seth Arnold <[email protected]>
 Seth Howell <[email protected]>
 Shachar Beiser <[email protected]>
MAINTAINERS +7 -0
index c71ca2a28e..3e6bf0f8ae 100644
@@ -856,6 +856,13 @@ F: drivers/net/octeon_ep/
 F: doc/guides/nics/features/octeon_ep.ini
 F: doc/guides/nics/octeon_ep.rst
 
+Napatech ntnic - EXPERIMENTAL
+M: Christian Koue Muf <[email protected]>
+M: Serhii Iliushyk <[email protected]>
+F: drivers/net/ntnic/
+F: doc/guides/nics/ntnic.rst
+F: doc/guides/nics/features/ntnic.ini
+
 NVIDIA mlx4
 M: Matan Azrad <[email protected]>
 M: Viacheslav Ovsiienko <[email protected]>
doc/guides/nics/features/ntnic.ini new file +8 -0
new file mode 100644
index 0000000000..9ceb75a03b
@@ -0,0 +1,8 @@
+;
+; Supported features of the 'ntnic' network poll mode driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+[Features]
+Linux                = Y
+x86-64               = Y
doc/guides/nics/index.rst +1 -0
index 7bfcac880f..c14bc7988a 100644
@@ -53,6 +53,7 @@ Network Interface Controller Drivers
     nfb
     nfp
     ngbe
+    ntnic
     null
     octeon_ep
     octeontx
doc/guides/nics/ntnic.rst new file +39 -0
new file mode 100644
index 0000000000..b150fe1481
@@ -0,0 +1,39 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+    Copyright(c) 2024 Napatech A/S
+
+NTNIC Poll Mode Driver
+======================
+
+The NTNIC PMD provides poll mode driver support for Napatech smartNICs.
+
+
+Design
+------
+
+The NTNIC PMD is designed as a pure user-space driver, and requires no special
+Napatech kernel modules.
+
+The Napatech smartNIC presents one control PCI device (PF0). NTNIC PMD accesses
+smartNIC PF0 via vfio-pci kernel driver. Access to PF0 for all purposes is
+exclusive, so only one process should access it. The physical ports are located
+behind PF0 as DPDK port 0 and 1.
+
+
+Supported NICs
+--------------
+
+- NT200A02 2x100G SmartNIC
+
+    - FPGA ID 9563 (Inline Flow Management)
+
+All information about NT200A02 can be found by link below:
+https://www.napatech.com/products/nt200a02-smartnic-inline/
+
+Limitations
+~~~~~~~~~~~
+
+Kernel versions before 5.7 are not supported. Kernel version 5.7 added vfio-pci
+support for creating VFs from the PF which is required for the PMD to use
+vfio-pci on the PF. This support has been back-ported to older Linux
+distributions and they are also supported. If vfio-pci is not required kernel
+version 4.18 is supported.
doc/guides/rel_notes/release_24_07.rst +10 -0
index cd4219efd2..058609b0f3 100644
@@ -104,6 +104,16 @@ New Features
 
   * Updated base code with E610 device family support.
 
+* **Added Napatech ntnic net driver [EXPERIMENTAL].**
+
+  * Added the PMD driver for Napatech smartNIC
+
+    - Ability to initialize the NIC (NT200A02)
+    - Supporting only one FPGA firmware (9563.55.39)
+    - Ability to bring up the 100G link
+    - Supporting QSFP/QSFP+/QSFP28 NIM
+    - Does not support datapath
+
 * **Updated Marvell cnxk net driver.**
 
   * Added support disabling custom meta aura
drivers/net/meson.build +1 -0
index bd38b533c5..fb6d34b782 100644
@@ -45,6 +45,7 @@ drivers = [
         'nfb',
         'nfp',
         'ngbe',
+        'ntnic',
         'null',
         'octeontx',
         'octeon_ep',
drivers/net/ntnic/meson.build new file +18 -0
new file mode 100644
index 0000000000..194353230b
@@ -0,0 +1,18 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2020-2023 Napatech A/S
+
+if not is_linux or not dpdk_conf.has('RTE_ARCH_X86_64')
+    build = false
+    reason = 'only supported on x86_64 Linux'
+    subdir_done()
+endif
+
+# includes
+includes = [
+    include_directories('.'),
+]
+
+# all sources
+sources = files(
+    'ntnic_ethdev.c',
+)
drivers/net/ntnic/ntnic_ethdev.c new file +49 -0

49 lines not on this page · raw message

Signature · 1 line
2.45.0
#192 lore raw

PATCH v9 2/21 net/ntnic: add logging implementation

Adds ntnic specific implementation for logging. NT NIC uses this logging abstraction layer
to ensure that FPGA module implementations function both within and outside in DPDK environment

---
v6
* Logging header file was moved
* Default log type was set to NOTICE

---
 drivers/net/ntnic/meson.build    |  2 ++
 drivers/net/ntnic/ntlog/ntlog.c  | 53 ++++++++++++++++++++++++++++++++
 drivers/net/ntnic/ntlog/ntlog.h  | 49 +++++++++++++++++++++++++++++
 drivers/net/ntnic/ntnic_ethdev.c |  2 ++
 4 files changed, 106 insertions(+)
 create mode 100644 drivers/net/ntnic/ntlog/ntlog.c
 create mode 100644 drivers/net/ntnic/ntlog/ntlog.h
drivers/net/ntnic/meson.build +2 -0
index 194353230b..80f0f3eecf 100644
@@ -10,9 +10,11 @@ endif
 # includes
 includes = [
     include_directories('.'),
+    include_directories('ntlog'),
 ]
 
 # all sources
 sources = files(
+    'ntlog/ntlog.c',
     'ntnic_ethdev.c',
 )
drivers/net/ntnic/ntlog/ntlog.c new file +53 -0

53 lines not on this page · raw message

drivers/net/ntnic/ntlog/ntlog.h new file +49 -0

49 lines not on this page · raw message

drivers/net/ntnic/ntnic_ethdev.c +2 -0
index 7e5231d2c1..68df9be2ff 100644
@@ -7,6 +7,8 @@
 #include <rte_bus_pci.h>
 #include <ethdev_pci.h>
 
+#include "ntlog.h"
+
 static const struct rte_pci_id nthw_pci_id_map[] = {
 	{
 		.vendor_id = 0,
Signature · 1 line
2.45.0
#193 lore raw

PATCH v9 3/21 net/ntnic: add minimal initialization for PCI device

In reply to Serhii Iliushyk

add implementation for probe/init and remove/deinit of the PCI device. proper device deinitialization will be added letter.

---
v6
* Add driver deinitialization
* Add API rte_eth_dev_probing_finish
* Add correct API for finishing probing the device
* Remove duplicated calling 'rte_eth_copy_pci_info()' via 'eth_dev_pci_specific_init()
* Remove unnecessary comments
* Remove duplicatet initialization of the numa_node v9
Fix logs

---
 drivers/net/ntnic/ntnic_ethdev.c | 82 +++++++++++++++++++++++++++++++-
 1 file changed, 81 insertions(+), 1 deletion(-)
drivers/net/ntnic/ntnic_ethdev.c +81 -1
index 68df9be2ff..d5983cd0f8 100644
@@ -3,6 +3,7 @@
  * Copyright(c) 2023 Napatech A/S
  */
 
+#include <rte_vfio.h>
 #include <rte_ethdev.h>
 #include <rte_bus_pci.h>
 #include <ethdev_pci.h>
@@ -16,14 +17,54 @@ static const struct rte_pci_id nthw_pci_id_map[] = {
 };
 
 static int
-nthw_pci_dev_init(struct rte_pci_device *pci_dev __rte_unused)
+nthw_pci_dev_init(struct rte_pci_device *pci_dev)
 {
+	uint32_t n_port_mask = -1;	/* All ports enabled by default */
+	int n_phy_ports;
+	NT_LOG_DBGX(DEBUG, NTNIC, "Dev %s PF #%i Init : %02x:%02x:%i\n", pci_dev->name,
+		pci_dev->addr.function, pci_dev->addr.bus, pci_dev->addr.devid,
+		pci_dev->addr.function);
+
+	n_phy_ports = 0;
+
+	for (int n_intf_no = 0; n_intf_no < n_phy_ports; n_intf_no++) {
+		struct rte_eth_dev *eth_dev = NULL;
+		char name[32];
+
+		if ((1 << n_intf_no) & ~n_port_mask)
+			continue;
+
+		snprintf(name, sizeof(name), "ntnic%d", n_intf_no);
+
+		eth_dev = rte_eth_dev_allocate(name);
+
+		if (!eth_dev) {
+			NT_LOG_DBGX(ERR, NTNIC, "%s: %s: error=%d\n",
+				(pci_dev->name[0] ? pci_dev->name : "NA"), name, -1);
+			return -1;
+		}
+
+		struct rte_eth_link pmd_link;
+		pmd_link.link_speed = RTE_ETH_SPEED_NUM_NONE;
+		pmd_link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX;
+		pmd_link.link_status = RTE_ETH_LINK_DOWN;
+		pmd_link.link_autoneg = RTE_ETH_LINK_AUTONEG;
+
+		eth_dev->device = &pci_dev->device;
+		eth_dev->data->dev_link = pmd_link;
+		eth_dev->dev_ops = NULL;
+
+		eth_dev_pci_specific_init(eth_dev, pci_dev);
+		rte_eth_dev_probing_finish(eth_dev);
+	}
+
 	return 0;
 }
 
 static int
 nthw_pci_dev_deinit(struct rte_eth_dev *eth_dev __rte_unused)
 {
+	NT_LOG_DBGX(DEBUG, NTNIC, "PCI device deinitialization\n");
 	return 0;
 }
 
@@ -32,13 +73,52 @@ nthw_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	struct rte_pci_device *pci_dev)
 {
 	int ret;
+
+	NT_LOG_DBGX(DEBUG, NTNIC, "pcidev: name: '%s'\n", pci_dev->name);
+	NT_LOG_DBGX(DEBUG, NTNIC, "devargs: name: '%s'\n", pci_dev->device.name);
+
+	if (pci_dev->device.devargs) {
+		NT_LOG_DBGX(DEBUG, NTNIC, "devargs: args: '%s'\n",
+			(pci_dev->device.devargs->args ? pci_dev->device.devargs->args : "NULL"));
+		NT_LOG_DBGX(DEBUG, NTNIC, "devargs: data: '%s'\n",
+			(pci_dev->device.devargs->data ? pci_dev->device.devargs->data : "NULL"));
+	}
+
+	const int n_rte_vfio_no_io_mmu_enabled = rte_vfio_noiommu_is_enabled();
+	NT_LOG(DBG, NTNIC, "vfio_no_iommu_enabled=%d\n", n_rte_vfio_no_io_mmu_enabled);
+
+	if (n_rte_vfio_no_io_mmu_enabled) {
+		NT_LOG(ERR, NTNIC, "vfio_no_iommu_enabled=%d: this PMD needs VFIO IOMMU\n",
+			n_rte_vfio_no_io_mmu_enabled);
+		return -1;
+	}
+
+	const enum rte_iova_mode n_rte_io_va_mode = rte_eal_iova_mode();
+	NT_LOG(DBG, NTNIC, "iova mode=%d\n", n_rte_io_va_mode);
+
+	NT_LOG(DBG, NTNIC,
+		"busid=" PCI_PRI_FMT
+		" pciid=%04x:%04x_%04x:%04x locstr=%s @ numanode=%d: drv=%s drvalias=%s\n",
+		pci_dev->addr.domain, pci_dev->addr.bus, pci_dev->addr.devid,
+		pci_dev->addr.function, pci_dev->id.vendor_id, pci_dev->id.device_id,
+		pci_dev->id.subsystem_vendor_id, pci_dev->id.subsystem_device_id,
+		pci_dev->name[0] ? pci_dev->name : "NA",
+		pci_dev->device.numa_node,
+		pci_dev->driver->driver.name ? pci_dev->driver->driver.name : "NA",
+		pci_dev->driver->driver.alias ? pci_dev->driver->driver.alias : "NA");
+
+
 	ret = nthw_pci_dev_init(pci_dev);
+
+	NT_LOG_DBGX(DEBUG, NTNIC, "leave: ret=%d\n", ret);
 	return ret;
 }
 
 static int
 nthw_pci_remove(struct rte_pci_device *pci_dev)
 {
+	NT_LOG_DBGX(DEBUG, NTNIC);
+
 	return rte_eth_dev_pci_generic_remove(pci_dev, nthw_pci_dev_deinit);
 }
 
Signature · 1 line
2.45.0
#194 lore raw

PATCH v9 4/21 net/ntnic: add NT utilities implementation

In reply to Serhii Iliushyk

Add ntnic utilities.

---
v6
* NT utils header file was moved

---
 drivers/net/ntnic/meson.build      |  2 ++
 drivers/net/ntnic/ntnic_ethdev.c   |  2 ++
 drivers/net/ntnic/ntutil/nt_util.c | 33 +++++++++++++++++++++++
 drivers/net/ntnic/ntutil/nt_util.h | 43 ++++++++++++++++++++++++++++++
 4 files changed, 80 insertions(+)
 create mode 100644 drivers/net/ntnic/ntutil/nt_util.c
 create mode 100644 drivers/net/ntnic/ntutil/nt_util.h
drivers/net/ntnic/meson.build +2 -0
index 80f0f3eecf..c7f5a4efc7 100644
@@ -11,10 +11,12 @@ endif
 includes = [
     include_directories('.'),
     include_directories('ntlog'),
+    include_directories('ntutil'),
 ]
 
 # all sources
 sources = files(
     'ntlog/ntlog.c',
+    'ntutil/nt_util.c',
     'ntnic_ethdev.c',
 )
drivers/net/ntnic/ntnic_ethdev.c +2 -0
index d5983cd0f8..02b55e2780 100644
@@ -10,6 +10,8 @@
 
 #include "ntlog.h"
 
+#include "nt_util.h"
+
 static const struct rte_pci_id nthw_pci_id_map[] = {
 	{
 		.vendor_id = 0,
drivers/net/ntnic/ntutil/nt_util.c new file +33 -0
new file mode 100644
index 0000000000..5395bf6993
@@ -0,0 +1,33 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <inttypes.h>
+#include <assert.h>
+
+#include <rte_ethdev.h>
+#include <rte_malloc.h>
+
+#include "ntlog.h"
+#include "nt_util.h"
+
+/* uses usleep which schedules out the calling thread */
+void nt_os_wait_usec(int val)
+{
+	rte_delay_us_sleep(val);
+}
+
+uint64_t nt_os_get_time_monotonic_counter(void)
+{
+	return rte_get_timer_cycles();
+}
+
+/* Allocation size matching minimum alignment of specified size */
+uint64_t nt_util_align_size(uint64_t size)
+{
+	return 1 << rte_log2_u64(size);
+}
drivers/net/ntnic/ntutil/nt_util.h new file +43 -0

43 lines not on this page · raw message

Signature · 1 line
2.45.0
#195 lore raw

PATCH v9 5/21 net/ntnic: add VFIO module

In reply to Serhii Iliushyk

Adds VFIO functionality and the DMA it requires. The VFIO context is initialized during ntnic ethdev startup.

---
 drivers/net/ntnic/meson.build      |   1 +
 drivers/net/ntnic/ntnic_ethdev.c   |  22 +++
 drivers/net/ntnic/ntnic_vfio.c     | 235 +++++++++++++++++++++++++++++
 drivers/net/ntnic/ntnic_vfio.h     |  29 ++++
 drivers/net/ntnic/ntutil/nt_util.c |  65 ++++++++
 5 files changed, 352 insertions(+)
 create mode 100644 drivers/net/ntnic/ntnic_vfio.c
 create mode 100644 drivers/net/ntnic/ntnic_vfio.h
drivers/net/ntnic/meson.build +1 -0
index c7f5a4efc7..bf86a0a098 100644
@@ -18,5 +18,6 @@ includes = [
 sources = files(
     'ntlog/ntlog.c',
     'ntutil/nt_util.c',
+    'ntnic_vfio.c',
     'ntnic_ethdev.c',
 )
drivers/net/ntnic/ntnic_ethdev.c +22 -0
index 02b55e2780..b838eb4d7a 100644
@@ -8,10 +8,17 @@
 #include <rte_bus_pci.h>
 #include <ethdev_pci.h>
 
+#include <rte_eal.h>
+#include <rte_dev.h>
+#include <rte_vfio.h>
+
 #include "ntlog.h"
 
+#include "ntnic_vfio.h"
 #include "nt_util.h"
 
+#define EXCEPTION_PATH_HID 0
+
 static const struct rte_pci_id nthw_pci_id_map[] = {
 	{
 		.vendor_id = 0,
@@ -21,12 +28,24 @@ static const struct rte_pci_id nthw_pci_id_map[] = {
 static int
 nthw_pci_dev_init(struct rte_pci_device *pci_dev)
 {
+	nt_vfio_init();
+
 	uint32_t n_port_mask = -1;	/* All ports enabled by default */
 	int n_phy_ports;
 	NT_LOG_DBGX(DEBUG, NTNIC, "Dev %s PF #%i Init : %02x:%02x:%i\n", pci_dev->name,
 		pci_dev->addr.function, pci_dev->addr.bus, pci_dev->addr.devid,
 		pci_dev->addr.function);
 
+
+	/* Setup VFIO context */
+	int vfio = nt_vfio_setup(pci_dev);
+
+	if (vfio < 0) {
+		NT_LOG_DBGX(ERR, TNIC, "%s: vfio_setup error %d\n",
+			(pci_dev->name[0] ? pci_dev->name : "NA"), -1);
+		return -1;
+	}
+
 	n_phy_ports = 0;
 
 	for (int n_intf_no = 0; n_intf_no < n_phy_ports; n_intf_no++) {
@@ -67,6 +86,8 @@ static int
 nthw_pci_dev_deinit(struct rte_eth_dev *eth_dev __rte_unused)
 {
 	NT_LOG_DBGX(DEBUG, NTNIC, "PCI device deinitialization\n");
+
+	nt_vfio_remove(EXCEPTION_PATH_HID);
 	return 0;
 }
 
@@ -131,3 +152,4 @@ static struct rte_pci_driver rte_nthw_pmd = {
 };
 
 RTE_PMD_REGISTER_PCI(net_ntnic, rte_nthw_pmd);
+RTE_PMD_REGISTER_KMOD_DEP(net_ntnic, "* vfio-pci");
drivers/net/ntnic/ntnic_vfio.c new file +235 -0

235 lines not on this page · raw message

drivers/net/ntnic/ntnic_vfio.h new file +29 -0
new file mode 100644
index 0000000000..69fef7923d
@@ -0,0 +1,29 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef _NTNIC_VFIO_H_
+#define _NTNIC_VFIO_H_
+
+#include <rte_dev.h>
+#include <rte_bus_pci.h>
+#include <ethdev_pci.h>
+
+void
+nt_vfio_init(void);
+
+int
+nt_vfio_setup(struct rte_pci_device *dev);
+int
+nt_vfio_remove(int vf_num);
+
+int
+nt_vfio_dma_map(int vf_num, void *virt_addr, uint64_t *iova_addr, uint64_t size);
+int
+nt_vfio_dma_unmap(int vf_num, void *virt_addr, uint64_t iova_addr, uint64_t size);
+
+/* Find device (PF/VF) number from device address */
+int
+nt_vfio_vf_num(const struct rte_pci_device *dev);
+#endif	/* _NTNIC_VFIO_H_ */
drivers/net/ntnic/ntutil/nt_util.c +65 -0

74 lines not on this page · raw message

Signature · 1 line
2.45.0
#196 lore raw

PATCH v9 6/21 net/ntnic: add basic eth dev ops to ntnic

In reply to Serhii Iliushyk

Adds support for eth_dev configure, start, stop, close, and infos_get. The internal structs of ntnic is also added and initialized.

---
v6
* Replace if_index with n_intf_no
* Unnecessry resources free was fixed
* Fix typo
* Useless vars were removed
v9
* Remove if_index usage to n_intf_no
* Make ops structure as const
* Fix logs
* Cleaup struct pmd_internals
* Move back dev init count increasing

---
 drivers/net/ntnic/include/ntdrv_4ga.h   |  17 ++
 drivers/net/ntnic/include/ntos_drv.h    |  30 ++++
 drivers/net/ntnic/include/ntos_system.h |  19 +++
 drivers/net/ntnic/meson.build           |   1 +
 drivers/net/ntnic/ntnic_ethdev.c        | 207 +++++++++++++++++++++++-
 5 files changed, 273 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/ntnic/include/ntdrv_4ga.h
 create mode 100644 drivers/net/ntnic/include/ntos_drv.h
 create mode 100644 drivers/net/ntnic/include/ntos_system.h
drivers/net/ntnic/include/ntdrv_4ga.h new file +17 -0
new file mode 100644
index 0000000000..bcb7ddc242
@@ -0,0 +1,17 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef __NTDRV_4GA_H__
+#define __NTDRV_4GA_H__
+
+
+typedef struct ntdrv_4ga_s {
+	uint32_t pciident;
+	char *p_drv_name;
+
+	volatile bool b_shutdown;
+} ntdrv_4ga_t;
+
+#endif	/* __NTDRV_4GA_H__ */
drivers/net/ntnic/include/ntos_drv.h new file +30 -0
new file mode 100644
index 0000000000..3c0a62cc85
@@ -0,0 +1,30 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef __NTOS_DRV_H__
+#define __NTOS_DRV_H__
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <inttypes.h>
+
+#include <rte_ether.h>
+
+#define NUM_MAC_ADDRS_PER_PORT (16U)
+#define NUM_MULTICAST_ADDRS_PER_PORT (16U)
+
+#define NUM_ADAPTER_MAX (8)
+#define NUM_ADAPTER_PORTS_MAX (128)
+
+struct pmd_internals {
+	const struct rte_pci_device *pci_dev;
+	char name[20];
+	int n_intf_no;
+	struct drv_s *p_drv;
+	struct pmd_internals *next;
+};
+
+#endif	/* __NTOS_DRV_H__ */
drivers/net/ntnic/include/ntos_system.h new file +19 -0
new file mode 100644
index 0000000000..01f1dc65f4
@@ -0,0 +1,19 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef __NTOS_SYSTEM_H__
+#define __NTOS_SYSTEM_H__
+
+#include "ntdrv_4ga.h"
+
+struct drv_s {
+	int adapter_no;
+	struct rte_pci_device *p_dev;
+	struct ntdrv_4ga_s ntdrv;
+
+	int n_eth_dev_init_count;
+};
+
+#endif	/* __NTOS_SYSTEM_H__ */
drivers/net/ntnic/meson.build +1 -0
index bf86a0a098..f372b0c3cf 100644
@@ -10,6 +10,7 @@ endif
 # includes
 includes = [
     include_directories('.'),
+    include_directories('include'),
     include_directories('ntlog'),
     include_directories('ntutil'),
 ]
drivers/net/ntnic/ntnic_ethdev.c +206 -1

264 lines not on this page · raw message

Signature · 1 line
2.45.0
#197 lore raw

PATCH v9 7/21 net/ntnic: add core platform structures

In reply to Serhii Iliushyk

Adds many of the high level structures needed by the ntnic FPGA modules and adapter control.
This is considered the first part of the skeleton of ntnic FPGA support

---
 drivers/net/ntnic/include/ntos_drv.h       |  2 +
 drivers/net/ntnic/meson.build              |  2 +
 drivers/net/ntnic/nthw/nthw_drv.h          | 88 ++++++++++++++++++++++
 drivers/net/ntnic/nthw/nthw_platform.c     | 14 ++++
 drivers/net/ntnic/nthw/nthw_platform_drv.h | 21 ++++++
 5 files changed, 127 insertions(+)
 create mode 100644 drivers/net/ntnic/nthw/nthw_drv.h
 create mode 100644 drivers/net/ntnic/nthw/nthw_platform.c
 create mode 100644 drivers/net/ntnic/nthw/nthw_platform_drv.h
drivers/net/ntnic/include/ntos_drv.h +2 -0
index 3c0a62cc85..3f621143d9 100644
@@ -13,6 +13,8 @@
 
 #include <rte_ether.h>
 
+#include "nthw_drv.h"
+
 #define NUM_MAC_ADDRS_PER_PORT (16U)
 #define NUM_MULTICAST_ADDRS_PER_PORT (16U)
 
drivers/net/ntnic/meson.build +2 -0
index f372b0c3cf..73c4188da0 100644
@@ -13,10 +13,12 @@ includes = [
     include_directories('include'),
     include_directories('ntlog'),
     include_directories('ntutil'),
+    include_directories('nthw'),
 ]
 
 # all sources
 sources = files(
+    'nthw/nthw_platform.c',
     'ntlog/ntlog.c',
     'ntutil/nt_util.c',
     'ntnic_vfio.c',
drivers/net/ntnic/nthw/nthw_drv.h new file +88 -0

88 lines not on this page · raw message

drivers/net/ntnic/nthw/nthw_platform.c new file +14 -0
new file mode 100644
index 0000000000..181330dd37
@@ -0,0 +1,14 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#include "nthw_platform_drv.h"
+
+nthw_adapter_id_t nthw_platform_get_nthw_adapter_id(const uint16_t n_pci_device_id)
+{
+	switch (n_pci_device_id) {
+	default:
+		return NT_HW_ADAPTER_ID_UNKNOWN;
+	}
+}
drivers/net/ntnic/nthw/nthw_platform_drv.h new file +21 -0
new file mode 100644
index 0000000000..ab26d8149a
@@ -0,0 +1,21 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef __NTHW_PLATFORM_DRV_H__
+#define __NTHW_PLATFORM_DRV_H__
+
+#include <stdint.h>
+
+#define NT_HW_PCI_VENDOR_ID (0x18f4)
+
+enum nthw_adapter_id_e {
+	NT_HW_ADAPTER_ID_UNKNOWN = 0,
+};
+
+typedef enum nthw_adapter_id_e nthw_adapter_id_t;
+
+nthw_adapter_id_t nthw_platform_get_nthw_adapter_id(const uint16_t n_pci_device_id);
+
+#endif	/* __NTHW_PLATFORM_DRV_H__ */
Signature · 1 line
2.45.0
#198 lore raw

PATCH v9 8/21 net/ntnic: add adapter initialization

In reply to Serhii Iliushyk

Add interfaces for initialize the adapter
Add proper PCI device deinitialization

---
v6
* Function for global var clearing was removed
v9
* Fix PCI devide deinitialization
* Fix p_hw_info usage

---
 drivers/net/ntnic/adapter/nt4ga_adapter.c | 145 ++++++++++++++++++++++
 drivers/net/ntnic/include/nt4ga_adapter.h |  40 ++++++
 drivers/net/ntnic/include/ntdrv_4ga.h     |   2 +
 drivers/net/ntnic/meson.build             |   2 +
 drivers/net/ntnic/ntnic_ethdev.c          |  85 ++++++++++++-
 drivers/net/ntnic/ntnic_mod_reg.c         |  20 +++
 drivers/net/ntnic/ntnic_mod_reg.h         |  27 ++++
 7 files changed, 320 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/ntnic/adapter/nt4ga_adapter.c
 create mode 100644 drivers/net/ntnic/include/nt4ga_adapter.h
 create mode 100644 drivers/net/ntnic/ntnic_mod_reg.c
 create mode 100644 drivers/net/ntnic/ntnic_mod_reg.h
drivers/net/ntnic/adapter/nt4ga_adapter.c new file +145 -0
new file mode 100644
index 0000000000..42b3a98d21
@@ -0,0 +1,145 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#include <rte_thread.h>
+
+#include "ntlog.h"
+#include "nt_util.h"
+#include "ntnic_mod_reg.h"
+
+static int nt4ga_adapter_show_info(struct adapter_info_s *p_adapter_info, FILE *pfh)
+{
+	const char *const p_dev_name = p_adapter_info->p_dev_name;
+	const char *const p_adapter_id_str = p_adapter_info->mp_adapter_id_str;
+	fpga_info_t *p_fpga_info = &p_adapter_info->fpga_info;
+	hw_info_t *p_hw_info = &p_adapter_info->hw_info;
+	char a_pci_ident_str[32];
+
+	snprintf(a_pci_ident_str, sizeof(a_pci_ident_str), PCIIDENT_PRINT_STR,
+		PCIIDENT_TO_DOMAIN(p_fpga_info->pciident),
+		PCIIDENT_TO_BUSNR(p_fpga_info->pciident),
+		PCIIDENT_TO_DEVNR(p_fpga_info->pciident),
+		PCIIDENT_TO_FUNCNR(p_fpga_info->pciident));
+
+	fprintf(pfh, "%s: DeviceName: %s\n", p_adapter_id_str, (p_dev_name ? p_dev_name : "NA"));
+	fprintf(pfh, "%s: PCI Details:\n", p_adapter_id_str);
+	fprintf(pfh, "%s: %s: %08X: %04X:%04X %04X:%04X\n", p_adapter_id_str, a_pci_ident_str,
+		p_fpga_info->pciident, p_hw_info->pci_vendor_id, p_hw_info->pci_device_id,
+		p_hw_info->pci_sub_vendor_id, p_hw_info->pci_sub_device_id);
+	fprintf(pfh, "%s: FPGA Details:\n", p_adapter_id_str);
+	fprintf(pfh, "%s: %03d-%04d-%02d-%02d [%016" PRIX64 "] (%08X)\n", p_adapter_id_str,
+		p_fpga_info->n_fpga_type_id, p_fpga_info->n_fpga_prod_id,
+		p_fpga_info->n_fpga_ver_id, p_fpga_info->n_fpga_rev_id, p_fpga_info->n_fpga_ident,
+		p_fpga_info->n_fpga_build_time);
+	fprintf(pfh, "%s: FpgaDebugMode=0x%x\n", p_adapter_id_str, p_fpga_info->n_fpga_debug_mode);
+	fprintf(pfh, "%s: Hw=0x%02X_rev%d: %s\n", p_adapter_id_str, p_hw_info->hw_platform_id,
+		p_fpga_info->nthw_hw_info.hw_id, p_fpga_info->nthw_hw_info.hw_plat_id_str);
+	fprintf(pfh, "%s: MCU Details:\n", p_adapter_id_str);
+
+	return 0;
+}
+
+static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info)
+{
+	char *const p_dev_name = malloc(24);
+	char *const p_adapter_id_str = malloc(24);
+	fpga_info_t *fpga_info = &p_adapter_info->fpga_info;
+	hw_info_t *p_hw_info = &p_adapter_info->hw_info;
+
+
+	p_hw_info->n_nthw_adapter_id = nthw_platform_get_nthw_adapter_id(p_hw_info->pci_device_id);
+
+	fpga_info->n_nthw_adapter_id = p_hw_info->n_nthw_adapter_id;
+	/* ref: DN-0060 section 9 */
+	p_hw_info->hw_product_type = p_hw_info->pci_device_id & 0x000f;
+	/* ref: DN-0060 section 9 */
+	p_hw_info->hw_platform_id = (p_hw_info->pci_device_id >> 4) & 0x00ff;
+	/* ref: DN-0060 section 9 */
+	p_hw_info->hw_reserved1 = (p_hw_info->pci_device_id >> 12) & 0x000f;
+
+	p_adapter_info->p_dev_name = p_dev_name;
+
+	if (p_dev_name) {
+		snprintf(p_dev_name, 24, PCIIDENT_PRINT_STR,
+			PCIIDENT_TO_DOMAIN(p_adapter_info->fpga_info.pciident),
+			PCIIDENT_TO_BUSNR(p_adapter_info->fpga_info.pciident),
+			PCIIDENT_TO_DEVNR(p_adapter_info->fpga_info.pciident),
+			PCIIDENT_TO_FUNCNR(p_adapter_info->fpga_info.pciident));
+		NT_LOG(DBG, NTNIC, "%s: (0x%08X)\n", p_dev_name,
+			p_adapter_info->fpga_info.pciident);
+	}
+
+	p_adapter_info->mp_adapter_id_str = p_adapter_id_str;
+
+	p_adapter_info->fpga_info.mp_adapter_id_str = p_adapter_id_str;
+
+	if (p_adapter_id_str) {
+		snprintf(p_adapter_id_str, 24, "PCI:" PCIIDENT_PRINT_STR,
+			PCIIDENT_TO_DOMAIN(p_adapter_info->fpga_info.pciident),
+			PCIIDENT_TO_BUSNR(p_adapter_info->fpga_info.pciident),
+			PCIIDENT_TO_DEVNR(p_adapter_info->fpga_info.pciident),
+			PCIIDENT_TO_FUNCNR(p_adapter_info->fpga_info.pciident));
+		NT_LOG(DBG, NTNIC, "%s: %s\n", p_adapter_id_str, p_dev_name);
+	}
+
+	{
+		int i;
+
+		for (i = 0; i < (int)ARRAY_SIZE(p_adapter_info->mp_port_id_str); i++) {
+			char *p = malloc(32);
+
+			if (p) {
+				snprintf(p, 32, "%s:intf_%d",
+					(p_adapter_id_str ? p_adapter_id_str : "NA"), i);
+			}
+
+			p_adapter_info->mp_port_id_str[i] = p;
+		}
+	}
+
+	return 0;
+}
+
+static int nt4ga_adapter_deinit(struct adapter_info_s *p_adapter_info)
+{
+	fpga_info_t *fpga_info = &p_adapter_info->fpga_info;
+	int i;
+	int res = -1;
+
+
+	/* Free adapter port ident strings */
+	for (i = 0; i < fpga_info->n_phy_ports; i++) {
+		if (p_adapter_info->mp_port_id_str[i]) {
+			free(p_adapter_info->mp_port_id_str[i]);
+			p_adapter_info->mp_port_id_str[i] = NULL;
+		}
+	}
+
+	/* Free adapter ident string */
+	if (p_adapter_info->mp_adapter_id_str) {
+		free(p_adapter_info->mp_adapter_id_str);
+		p_adapter_info->mp_adapter_id_str = NULL;
+	}
+
+	/* Free devname ident string */
+	if (p_adapter_info->p_dev_name) {
+		free(p_adapter_info->p_dev_name);
+		p_adapter_info->p_dev_name = NULL;
+	}
+
+	return res;
+}
+
+static const struct adapter_ops ops = {
+	.init = nt4ga_adapter_init,
+	.deinit = nt4ga_adapter_deinit,
+
+	.show_info = nt4ga_adapter_show_info,
+};
+
+void adapter_init(void)
+{
+	register_adapter_ops(&ops);
+}
drivers/net/ntnic/include/nt4ga_adapter.h new file +40 -0
new file mode 100644
index 0000000000..2c72583caf
@@ -0,0 +1,40 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef _NT4GA_ADAPTER_H_
+#define _NT4GA_ADAPTER_H_
+
+#include "ntos_drv.h"
+typedef struct hw_info_s {
+	/* pciids */
+	uint16_t pci_vendor_id;
+	uint16_t pci_device_id;
+	uint16_t pci_sub_vendor_id;
+	uint16_t pci_sub_device_id;
+	uint16_t pci_class_id;
+
+	/* Derived from pciid */
+	nthw_adapter_id_t n_nthw_adapter_id;
+	int hw_platform_id;
+	int hw_product_type;
+	int hw_reserved1;
+} hw_info_t;
+
+typedef struct adapter_info_s {
+	struct hw_info_s hw_info;
+	struct fpga_info_s fpga_info;
+
+	char *mp_port_id_str[NUM_ADAPTER_PORTS_MAX];
+	char *mp_adapter_id_str;
+	char *p_dev_name;
+	volatile bool *pb_shutdown;
+
+	int adapter_no;
+	int n_rx_host_buffers;
+	int n_tx_host_buffers;
+} adapter_info_t;
+
+
+#endif	/* _NT4GA_ADAPTER_H_ */
drivers/net/ntnic/include/ntdrv_4ga.h +2 -0
index bcb7ddc242..8017aa4fc3 100644
@@ -6,9 +6,11 @@
 #ifndef __NTDRV_4GA_H__
 #define __NTDRV_4GA_H__
 
+#include "nt4ga_adapter.h"
 
 typedef struct ntdrv_4ga_s {
 	uint32_t pciident;
+	struct adapter_info_s adapter_info;
 	char *p_drv_name;
 
 	volatile bool b_shutdown;
drivers/net/ntnic/meson.build +2 -0
index 73c4188da0..94f24e09e3 100644
@@ -18,9 +18,11 @@ includes = [
 
 # all sources
 sources = files(
+    'adapter/nt4ga_adapter.c',
     'nthw/nthw_platform.c',
     'ntlog/ntlog.c',
     'ntutil/nt_util.c',
+    'ntnic_mod_reg.c',
     'ntnic_vfio.c',
     'ntnic_ethdev.c',
 )
drivers/net/ntnic/ntnic_ethdev.c +84 -1

134 lines not on this page · raw message

drivers/net/ntnic/ntnic_mod_reg.c new file +20 -0
new file mode 100644
index 0000000000..006221bbe3
@@ -0,0 +1,20 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#include "ntnic_mod_reg.h"
+
+static const struct adapter_ops *adapter_ops;
+
+void register_adapter_ops(const struct adapter_ops *ops)
+{
+	adapter_ops = ops;
+}
+
+const struct adapter_ops *get_adapter_ops(void)
+{
+	if (adapter_ops == NULL)
+		adapter_init();
+	return adapter_ops;
+}
drivers/net/ntnic/ntnic_mod_reg.h new file +27 -0
new file mode 100644
index 0000000000..48a9f8f7b9
@@ -0,0 +1,27 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef __NTNIC_MOD_REG_H__
+#define __NTNIC_MOD_REG_H__
+
+#include <stdint.h>
+#include "nthw_platform_drv.h"
+#include "nthw_drv.h"
+#include "nt4ga_adapter.h"
+#include "ntos_drv.h"
+
+struct adapter_ops {
+	int (*init)(struct adapter_info_s *p_adapter_info);
+	int (*deinit)(struct adapter_info_s *p_adapter_info);
+
+	int (*show_info)(struct adapter_info_s *p_adapter_info, FILE *pfh);
+};
+
+void register_adapter_ops(const struct adapter_ops *ops);
+const struct adapter_ops *get_adapter_ops(void);
+void adapter_init(void);
+
+
+#endif	/* __NTNIC_MOD_REG_H__ */
Signature · 1 line
2.45.0
#199 lore raw

PATCH v9 9/21 net/ntnic: add registers and FPGA model for NapaTech NIC

In reply to Serhii Iliushyk

The NTNIC PMD does not rely on a kernel space Napatech driver, thus all defines related to the register layout is part of the PMD code, which will be added in later commits.

---
v6
* Remove unnecessary comments
* Remove EOF markers and Auto-gen comments

---
 drivers/net/ntnic/include/fpga_model.h        |  102 ++
 drivers/net/ntnic/meson.build                 |    4 +
 .../net/ntnic/nthw/model/nthw_fpga_model.c    | 1192 ++++++++++++++++
 .../net/ntnic/nthw/model/nthw_fpga_model.h    |  245 ++++
 drivers/net/ntnic/nthw/nthw_register.h        |   21 +
 .../supported/nthw_fpga_9563_055_039_0000.c   | 1225 +++++++++++++++++
 .../nthw/supported/nthw_fpga_instances.c      |    4 +
 .../nthw/supported/nthw_fpga_instances.h      |    5 +
 .../ntnic/nthw/supported/nthw_fpga_mod_defs.h |   28 +
 .../nthw/supported/nthw_fpga_mod_str_map.c    |   19 +
 .../nthw/supported/nthw_fpga_mod_str_map.h    |    9 +
 .../nthw/supported/nthw_fpga_param_defs.h     |  224 +++
 .../ntnic/nthw/supported/nthw_fpga_reg_defs.h |   27 +
 .../nthw/supported/nthw_fpga_reg_defs_gfg.h   |  118 ++
 .../nthw/supported/nthw_fpga_reg_defs_gmf.h   |   60 +
 .../supported/nthw_fpga_reg_defs_gpio_phy.h   |   40 +
 .../nthw/supported/nthw_fpga_reg_defs_hif.h   |   71 +
 .../nthw/supported/nthw_fpga_reg_defs_i2cm.h  |   30 +
 .../nthw/supported/nthw_fpga_reg_defs_iic.h   |   88 ++
 .../supported/nthw_fpga_reg_defs_mac_pcs.h    |  290 ++++
 .../supported/nthw_fpga_reg_defs_pci_rd_tg.h  |   29 +
 .../supported/nthw_fpga_reg_defs_pci_wr_tg.h  |   32 +
 .../nthw/supported/nthw_fpga_reg_defs_pcie3.h |  273 ++++
 .../nthw/supported/nthw_fpga_reg_defs_rac.h   |   64 +
 .../supported/nthw_fpga_reg_defs_rst9563.h    |   51 +
 .../nthw/supported/nthw_fpga_reg_defs_sdc.h   |   36 +
 drivers/net/ntnic/ntnic_ethdev.c              |    1 +
 27 files changed, 4288 insertions(+)
 create mode 100644 drivers/net/ntnic/include/fpga_model.h
 create mode 100644 drivers/net/ntnic/nthw/model/nthw_fpga_model.c
 create mode 100644 drivers/net/ntnic/nthw/model/nthw_fpga_model.h
 create mode 100644 drivers/net/ntnic/nthw/nthw_register.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_9563_055_039_0000.c
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_instances.c
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_instances.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_mod_defs.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_mod_str_map.c
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_mod_str_map.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_param_defs.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_gfg.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_gmf.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_gpio_phy.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_hif.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_i2cm.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_iic.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_mac_pcs.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_pci_rd_tg.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_pci_wr_tg.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_pcie3.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_rac.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_rst9563.h
 create mode 100644 drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_sdc.h
drivers/net/ntnic/include/fpga_model.h new file +102 -0
new file mode 100644
index 0000000000..d73cf168ed
@@ -0,0 +1,102 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef _FPGA_MODEL_H_
+#define _FPGA_MODEL_H_
+
+#include <unistd.h>
+#include <stdint.h>
+#include <inttypes.h>
+
+typedef uint32_t nthw_id_t;
+
+enum nthw_fpga_bus_type {
+	NTHW_FPGA_BUS_TYPE_UNKNOWN =
+		0,	/* Unknown/uninitialized - keep this as the first enum element */
+	NTHW_FPGA_BUS_TYPE_BAR,
+	NTHW_FPGA_BUS_TYPE_PCI,
+	NTHW_FPGA_BUS_TYPE_CCIP,
+	NTHW_FPGA_BUS_TYPE_RAB0,
+	NTHW_FPGA_BUS_TYPE_RAB1,
+	NTHW_FPGA_BUS_TYPE_RAB2,
+	NTHW_FPGA_BUS_TYPE_NMB,
+	NTHW_FPGA_BUS_TYPE_NDM,
+	NTHW_FPGA_BUS_TYPE_SPI0,
+	NTHW_FPGA_BUS_TYPE_SPI = NTHW_FPGA_BUS_TYPE_SPI0,
+};
+
+typedef enum nthw_fpga_bus_type nthw_fpga_bus_type_e;
+
+enum nthw_fpga_register_type {
+	NTHW_FPGA_REG_TYPE_UNKNOWN =
+		0,	/* Unknown/uninitialized - keep this as the first enum element */
+	NTHW_FPGA_REG_TYPE_RW,
+	NTHW_FPGA_REG_TYPE_RO,
+	NTHW_FPGA_REG_TYPE_WO,
+	NTHW_FPGA_REG_TYPE_RC1,
+	NTHW_FPGA_REG_TYPE_MIXED,
+};
+
+typedef enum nthw_fpga_register_type nthw_fpga_register_type_e;
+
+struct nthw_fpga_field_init {
+	nthw_id_t id;
+	uint16_t bw;
+	uint16_t low;
+	uint64_t reset_val;
+};
+
+typedef struct nthw_fpga_field_init nthw_fpga_field_init_s;
+
+struct nthw_fpga_register_init {
+	nthw_id_t id;
+	uint32_t addr_rel;
+	uint16_t bw;
+	nthw_fpga_register_type_e type;
+	uint64_t reset_val;
+	int nb_fields;
+	struct nthw_fpga_field_init *fields;
+};
+
+typedef struct nthw_fpga_register_init nthw_fpga_register_init_s;
+
+struct nthw_fpga_module_init {
+	nthw_id_t id;
+	int instance;
+	nthw_id_t def_id;
+	int major_version;
+	int minor_version;
+	nthw_fpga_bus_type_e bus_id;
+	uint32_t addr_base;
+	int nb_registers;
+	struct nthw_fpga_register_init *registers;
+};
+
+typedef struct nthw_fpga_module_init nthw_fpga_module_init_s;
+
+struct nthw_fpga_prod_param {
+	const nthw_id_t id;
+	const int value;
+};
+
+typedef struct nthw_fpga_prod_param nthw_fpga_prod_param_s;
+
+struct nthw_fpga_prod_init {
+	int fpga_item_id;
+	int fpga_product_id;
+	int fpga_version;
+	int fpga_revision;
+	int fpga_patch_no;
+	int fpga_build_no;
+	uint32_t fpga_build_time;
+	int nb_prod_params;
+	struct nthw_fpga_prod_param *product_params;
+	int nb_modules;
+	struct nthw_fpga_module_init *modules;
+};
+
+typedef struct nthw_fpga_prod_init nthw_fpga_prod_init_s;
+
+#endif	/* _FPGA_MODEL_H_ */
drivers/net/ntnic/meson.build +4 -0
index 94f24e09e3..9d78e54470 100644
@@ -14,11 +14,15 @@ includes = [
     include_directories('ntlog'),
     include_directories('ntutil'),
     include_directories('nthw'),
+    include_directories('nthw/supported'),
 ]
 
 # all sources
 sources = files(
     'adapter/nt4ga_adapter.c',
+    'nthw/supported/nthw_fpga_9563_055_039_0000.c',
+    'nthw/supported/nthw_fpga_instances.c',
+    'nthw/supported/nthw_fpga_mod_str_map.c',
     'nthw/nthw_platform.c',
     'ntlog/ntlog.c',
     'ntutil/nt_util.c',
drivers/net/ntnic/nthw/model/nthw_fpga_model.c new file +1192 -0

1,192 lines not on this page · raw message

drivers/net/ntnic/nthw/model/nthw_fpga_model.h new file +245 -0

245 lines not on this page · raw message

drivers/net/ntnic/nthw/nthw_register.h new file +21 -0
new file mode 100644
index 0000000000..db006fcf72
@@ -0,0 +1,21 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef NTHW_REGISTER_H_
+#define NTHW_REGISTER_H_
+
+#include <unistd.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <inttypes.h>
+
+
+#include "fpga_model.h"
+
+#include "nthw_fpga_mod_defs.h"
+#include "nthw_fpga_param_defs.h"
+#include "nthw_fpga_reg_defs.h"
+
+#endif	/* NTHW_REGISTER_H_ */
drivers/net/ntnic/nthw/supported/nthw_fpga_9563_055_039_0000.c new file +1225 -0

1,225 lines not on this page · raw message

drivers/net/ntnic/nthw/supported/nthw_fpga_instances.c new file +4 -0
new file mode 100644
index 0000000000..ff6efc6e75
@@ -0,0 +1,4 @@
+
+
+#include "nthw_fpga_instances.h"
+nthw_fpga_prod_init_s *nthw_fpga_instances[] = { &nthw_fpga_9563_055_039_0000, NULL };
drivers/net/ntnic/nthw/supported/nthw_fpga_instances.h new file +5 -0
new file mode 100644
index 0000000000..05c0b94bbe
@@ -0,0 +1,5 @@
+
+
+#include "fpga_model.h"
+extern nthw_fpga_prod_init_s *nthw_fpga_instances[];
+extern nthw_fpga_prod_init_s nthw_fpga_9563_055_039_0000;
drivers/net/ntnic/nthw/supported/nthw_fpga_mod_defs.h new file +28 -0
new file mode 100644
index 0000000000..0c746f8f53
@@ -0,0 +1,28 @@
+/*
+ * nthw_fpga_mod_defs.h
+ *
+ * Auto-generated file - do *NOT* edit
+ *
+ */
+
+#ifndef _NTHW_FPGA_MOD_DEFS_H_
+#define _NTHW_FPGA_MOD_DEFS_H_
+
+#define MOD_UNKNOWN (0L)/* Unknown/uninitialized - keep this as the first element */
+#define MOD_GFG (0xfc423807UL)
+#define MOD_GMF (0x68b1d15aUL)
+#define MOD_GPIO_PHY (0xbbe81659UL)
+#define MOD_HIF (0x7815363UL)
+#define MOD_I2CM (0x93bc7780UL)
+#define MOD_IIC (0x7629cddbUL)
+#define MOD_MAC_PCS (0x7abe24c7UL)
+#define MOD_PCIE3 (0xfbc48c18UL)
+#define MOD_PCI_RD_TG (0x9ad9eed2UL)
+#define MOD_PCI_WR_TG (0x274b69e1UL)
+#define MOD_RAC (0xae830b42UL)
+#define MOD_RST9563 (0x385d6d1dUL)
+#define MOD_SDC (0xd2369530UL)
+#define MOD_IDX_COUNT (14)
+
+/* aliases - only aliases go below this point */
+#endif	/* _NTHW_FPGA_MOD_DEFS_H_ */
drivers/net/ntnic/nthw/supported/nthw_fpga_mod_str_map.c new file +19 -0
new file mode 100644
index 0000000000..d7bc686fe8
@@ -0,0 +1,19 @@
+
+
+#include "nthw_fpga_mod_str_map.h"
+const struct nthw_fpga_mod_str_s sa_nthw_fpga_mod_str_map[] = {
+	{ MOD_GFG, "GFG" },
+	{ MOD_GMF, "GMF" },
+	{ MOD_GPIO_PHY, "GPIO_PHY" },
+	{ MOD_HIF, "HIF" },
+	{ MOD_I2CM, "I2CM" },
+	{ MOD_IIC, "IIC" },
+	{ MOD_MAC_PCS, "MAC_PCS" },
+	{ MOD_PCIE3, "PCIE3" },
+	{ MOD_PCI_RD_TG, "PCI_RD_TG" },
+	{ MOD_PCI_WR_TG, "PCI_WR_TG" },
+	{ MOD_RAC, "RAC" },
+	{ MOD_RST9563, "RST9563" },
+	{ MOD_SDC, "SDC" },
+	{ 0UL, NULL }
+};
drivers/net/ntnic/nthw/supported/nthw_fpga_mod_str_map.h new file +9 -0
new file mode 100644
index 0000000000..13971d5d4e
@@ -0,0 +1,9 @@
+
+
+#include "nthw_fpga_mod_defs.h"
+#include "fpga_model.h"
+struct nthw_fpga_mod_str_s {
+	const nthw_id_t a;
+	const char *b;
+};
+extern const struct nthw_fpga_mod_str_s sa_nthw_fpga_mod_str_map[];
drivers/net/ntnic/nthw/supported/nthw_fpga_param_defs.h new file +224 -0

135 lines not on this page · raw message

drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs.h new file +27 -0
new file mode 100644
index 0000000000..aeb564349e

Lines of this file are not shown. View the raw message.

drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_gfg.h new file +118 -0

118 lines not on this page · raw message

drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_gmf.h new file +60 -0

60 lines not on this page · raw message

drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_gpio_phy.h new file +40 -0
new file mode 100644
index 0000000000..8d160af298

Lines of this file are not shown. View the raw message.

drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_hif.h new file +71 -0

71 lines not on this page · raw message

drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_i2cm.h new file +30 -0
new file mode 100644
index 0000000000..4ef618e2e1

Lines of this file are not shown. View the raw message.

drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_iic.h new file +88 -0

88 lines not on this page · raw message

drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_mac_pcs.h new file +290 -0

290 lines not on this page · raw message

drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_pci_rd_tg.h new file +29 -0
new file mode 100644
index 0000000000..4f8e41f261

Lines of this file are not shown. View the raw message.

drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_pci_wr_tg.h new file +32 -0
new file mode 100644
index 0000000000..59bb1b2613

Lines of this file are not shown. View the raw message.

drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_pcie3.h new file +273 -0

273 lines not on this page · raw message

drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_rac.h new file +64 -0

64 lines not on this page · raw message

drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_rst9563.h new file +51 -0

51 lines not on this page · raw message

drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_sdc.h new file +36 -0
new file mode 100644
index 0000000000..d9cfff4128

Lines of this file are not shown. View the raw message.

drivers/net/ntnic/ntnic_ethdev.c +1 -0
index 42df15bd53..5d154c8e38 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.45.0

Part of the diff is not shown here. View the raw message.

#200 lore raw

Re: [PATCH v9 09/21] net/ntnic: add registers and FPGA model for NapaTech NIC

Quoted 6 lines · Serhii Iliushyk

The NTNIC PMD does not rely on a kernel space Napatech driver, thus all defines related to the register layout is part of the PMD code, which will be added in later commits.

In the commit log title, "net/ntnic: " already highlights that this commit is for Napatech NIC, so can drop "for NapaTech NIC" from the title.

Btw, as far as I can see rest of the driver refers company as 'Napatech', so I am not sure which one is correct 'Napatech' or 'NapaTech' but better to be consistent.

#201 lore raw

PATCH v9 10/21 net/ntnic: add FPGA modules for initialization

In reply to Serhii Iliushyk

New ntnic FPGA modules:
- Host Interface (HIF): Basic FPGA info such as prod ID and build time.
- Inter-Integrated Circuit Controller (IIC): Use the FPGA to access the other integrated circuits on the ntnic.
- PCI Express Gen3 (PCIE3): The FPGA part of PCIe3 initialization, speed tests, and configuration.

---
v6
* Remove unnecessary comments

DVO: Remove unnecessary comments

---
 drivers/net/ntnic/meson.build                 |   1 +
 .../net/ntnic/nthw/core/include/nthw_core.h   |  16 +
 .../net/ntnic/nthw/core/include/nthw_hif.h    | 151 ++++
 .../net/ntnic/nthw/core/include/nthw_iic.h    | 100 +++
 .../net/ntnic/nthw/core/include/nthw_pcie3.h  |  96 +++
 drivers/net/ntnic/nthw/core/nthw_hif.c        | 312 +++++++
 drivers/net/ntnic/nthw/core/nthw_iic.c        | 527 ++++++++++++
 drivers/net/ntnic/nthw/core/nthw_pcie3.c      | 259 ++++++
 drivers/net/ntnic/nthw/nthw_drv.h             |   3 +-
 drivers/net/ntnic/nthw/nthw_rac.c             | 784 ++++++++++++++++++
 drivers/net/ntnic/nthw/nthw_rac.h             | 153 ++++
 11 files changed, 2400 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/ntnic/nthw/core/include/nthw_core.h
 create mode 100644 drivers/net/ntnic/nthw/core/include/nthw_hif.h
 create mode 100644 drivers/net/ntnic/nthw/core/include/nthw_iic.h
 create mode 100644 drivers/net/ntnic/nthw/core/include/nthw_pcie3.h
 create mode 100644 drivers/net/ntnic/nthw/core/nthw_hif.c
 create mode 100644 drivers/net/ntnic/nthw/core/nthw_iic.c
 create mode 100644 drivers/net/ntnic/nthw/core/nthw_pcie3.c
 create mode 100644 drivers/net/ntnic/nthw/nthw_rac.c
 create mode 100644 drivers/net/ntnic/nthw/nthw_rac.h
drivers/net/ntnic/meson.build +1 -0
index 9d78e54470..5dd1beada2 100644
@@ -13,6 +13,7 @@ includes = [
     include_directories('include'),
     include_directories('ntlog'),
     include_directories('ntutil'),
+    include_directories('nthw/core/include'),
     include_directories('nthw'),
     include_directories('nthw/supported'),
 ]
drivers/net/ntnic/nthw/core/include/nthw_core.h new file +16 -0
new file mode 100644
index 0000000000..c2602e396f
@@ -0,0 +1,16 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef __NTHW_CORE_H__
+#define __NTHW_CORE_H__
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdint.h>
+
+#include "nthw_platform_drv.h"
+
+
+#endif	/* __NTHW_CORE_H__ */
drivers/net/ntnic/nthw/core/include/nthw_hif.h new file +151 -0

151 lines not on this page · raw message

drivers/net/ntnic/nthw/core/include/nthw_iic.h new file +100 -0

100 lines not on this page · raw message

drivers/net/ntnic/nthw/core/include/nthw_pcie3.h new file +96 -0

96 lines not on this page · raw message

drivers/net/ntnic/nthw/core/nthw_hif.c new file +312 -0

312 lines not on this page · raw message

drivers/net/ntnic/nthw/core/nthw_iic.c new file +527 -0

527 lines not on this page · raw message

drivers/net/ntnic/nthw/core/nthw_pcie3.c new file +259 -0

259 lines not on this page · raw message

drivers/net/ntnic/nthw/nthw_drv.h +1 -2
index 0b89a5c5a0..d7cd64bb1d 100644
@@ -6,8 +6,7 @@
 #ifndef __NTHW_DRV_H__
 #define __NTHW_DRV_H__
 
-#include <stddef.h>
-#include "nthw_platform_drv.h"
+#include "nthw_core.h"
 
 typedef enum nt_meta_port_type_e {
 	PORT_TYPE_PHYSICAL,
drivers/net/ntnic/nthw/nthw_rac.c new file +784 -0

784 lines not on this page · raw message

drivers/net/ntnic/nthw/nthw_rac.h new file +153 -0

153 lines not on this page · raw message

Signature · 1 line
2.45.0
#202 lore raw

PATCH v9 11/21 net/ntnic: add FPGA initialization functionality

In reply to Serhii Iliushyk

Enable FPGA initialization and adds ethdev fw_version_get.

---
v5
* Fix Typo/Spelling
v7
* Add FW update feature to documentation - INI and RST files

---
 doc/guides/nics/features/ntnic.ini            |   1 +
 doc/guides/nics/ntnic.rst                     |   5 +
 drivers/net/ntnic/adapter/nt4ga_adapter.c     |  49 +++-
 drivers/net/ntnic/meson.build                 |   7 +
 .../net/ntnic/nthw/core/include/nthw_core.h   |   4 +
 .../net/ntnic/nthw/core/include/nthw_fpga.h   |  22 ++
 drivers/net/ntnic/nthw/core/nthw_fpga.c       | 222 ++++++++++++++++++
 drivers/net/ntnic/nthw/nthw_drv.h             |   1 +
 drivers/net/ntnic/nthw/nthw_register.h        |   1 +
 drivers/net/ntnic/ntnic_ethdev.c              |  41 +++-
 drivers/net/ntnic/ntnic_mod_reg.h             |   1 +
 11 files changed, 352 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/ntnic/nthw/core/include/nthw_fpga.h
 create mode 100644 drivers/net/ntnic/nthw/core/nthw_fpga.c
doc/guides/nics/features/ntnic.ini +1 -0
index 9ceb75a03b..03f4d5aac8 100644
@@ -4,5 +4,6 @@
 ; Refer to default.ini for the full list of available PMD features.
 ;
 [Features]
+FW version           = Y
 Linux                = Y
 x86-64               = Y
doc/guides/nics/ntnic.rst +5 -0
index b150fe1481..db168e1686 100644
@@ -29,6 +29,11 @@ Supported NICs
 All information about NT200A02 can be found by link below:
 https://www.napatech.com/products/nt200a02-smartnic-inline/
 
+Features
+--------
+
+- FW version
+
 Limitations
 ~~~~~~~~~~~
 
drivers/net/ntnic/adapter/nt4ga_adapter.c +48 -1

85 lines not on this page · raw message

drivers/net/ntnic/meson.build +7 -0
index 5dd1beada2..78f31097ab 100644
@@ -16,6 +16,7 @@ includes = [
     include_directories('nthw/core/include'),
     include_directories('nthw'),
     include_directories('nthw/supported'),
+    include_directories('nthw/model'),
 ]
 
 # all sources
@@ -24,7 +25,13 @@ sources = files(
     'nthw/supported/nthw_fpga_9563_055_039_0000.c',
     'nthw/supported/nthw_fpga_instances.c',
     'nthw/supported/nthw_fpga_mod_str_map.c',
+    'nthw/core/nthw_fpga.c',
+    'nthw/core/nthw_hif.c',
+    'nthw/core/nthw_iic.c',
+    'nthw/core/nthw_pcie3.c',
+    'nthw/model/nthw_fpga_model.c',
     'nthw/nthw_platform.c',
+    'nthw/nthw_rac.c',
     'ntlog/ntlog.c',
     'ntutil/nt_util.c',
     'ntnic_mod_reg.c',
drivers/net/ntnic/nthw/core/include/nthw_core.h +4 -0
index c2602e396f..69af113816 100644
@@ -11,6 +11,10 @@
 #include <stdint.h>
 
 #include "nthw_platform_drv.h"
+#include "nthw_fpga_model.h"
+#include "nthw_hif.h"
+#include "nthw_pcie3.h"
+#include "nthw_iic.h"
 
 
 #endif	/* __NTHW_CORE_H__ */
drivers/net/ntnic/nthw/core/include/nthw_fpga.h new file +22 -0
new file mode 100644
index 0000000000..1943f6e225
@@ -0,0 +1,22 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef __NTHW_FPGA_H__
+#define __NTHW_FPGA_H__
+
+#include "nthw_drv.h"
+
+#include "nthw_fpga_model.h"
+
+#include "nthw_rac.h"
+#include "nthw_iic.h"
+
+int nthw_fpga_init(struct fpga_info_s *p_fpga_info);
+int nthw_fpga_shutdown(struct fpga_info_s *p_fpga_info);
+
+int nthw_fpga_get_param_info(struct fpga_info_s *p_fpga_info, nthw_fpga_t *p_fpga);
+
+
+#endif	/* __NTHW_FPGA_H__ */
drivers/net/ntnic/nthw/core/nthw_fpga.c new file +222 -0

222 lines not on this page · raw message

drivers/net/ntnic/nthw/nthw_drv.h +1 -0
index d7cd64bb1d..071618eb6e 100644
@@ -22,6 +22,7 @@ enum fpga_info_profile {
 };
 
 typedef struct mcu_info_s {
+	bool mb_has_mcu;
 	int mn_mcu_type;
 	int mn_mcu_dram_size;
 } mcu_info_t;
drivers/net/ntnic/nthw/nthw_register.h +1 -0
index db006fcf72..ecc661a656 100644
@@ -11,6 +11,7 @@
 #include <stdbool.h>
 #include <inttypes.h>
 
+#include "nthw_fpga_model.h"
 
 #include "fpga_model.h"
 
drivers/net/ntnic/ntnic_ethdev.c +40 -1

83 lines not on this page · raw message

drivers/net/ntnic/ntnic_mod_reg.h +1 -0
index 48a9f8f7b9..96fc829399 100644
@@ -7,6 +7,7 @@
 #define __NTNIC_MOD_REG_H__
 
 #include <stdint.h>
+#include "nthw_fpga_model.h"
 #include "nthw_platform_drv.h"
 #include "nthw_drv.h"
 #include "nt4ga_adapter.h"
Signature · 1 line
2.45.0
#203 lore raw

PATCH v9 12/21 net/ntnic: add support of the NT200A0X smartNIC

In reply to Serhii Iliushyk

Add ntnic support for NT200A0X NIC

---
 drivers/net/ntnic/adapter/nt4ga_adapter.c     |  6 +++
 drivers/net/ntnic/meson.build                 |  1 +
 .../net/ntnic/nthw/core/include/nthw_fpga.h   |  7 +++
 .../nthw/core/nt200a0x/nthw_fpga_nt200a0x.c   | 54 +++++++++++++++++++
 drivers/net/ntnic/nthw/core/nthw_fpga.c       | 31 +++++++++++
 drivers/net/ntnic/nthw/nthw_platform.c        |  3 ++
 drivers/net/ntnic/nthw/nthw_platform_drv.h    |  2 +
 drivers/net/ntnic/ntnic_ethdev.c              |  3 ++
 8 files changed, 107 insertions(+)
 create mode 100644 drivers/net/ntnic/nthw/core/nt200a0x/nthw_fpga_nt200a0x.c
drivers/net/ntnic/adapter/nt4ga_adapter.c +6 -0
index 381884349b..1bdd11f227 100644
@@ -127,6 +127,12 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info)
 		assert(fpga_info->n_fpga_prod_id > 0);
 
 		switch (fpga_info->n_fpga_prod_id) {
+		/* NT200A01: 2x100G (Xilinx) */
+		case 9563:	/* NT200A02 (Cap) */
+			NT_LOG(ERR, NTNIC, "NT200A02 100G link module uninitialized\n");
+			res = -1;
+			break;
+
 		default:
 			NT_LOG(ERR, NTNIC, "Unsupported FPGA product: %04d\n",
 				fpga_info->n_fpga_prod_id);
drivers/net/ntnic/meson.build +1 -0
index 78f31097ab..e375c63bf8 100644
@@ -25,6 +25,7 @@ sources = files(
     'nthw/supported/nthw_fpga_9563_055_039_0000.c',
     'nthw/supported/nthw_fpga_instances.c',
     'nthw/supported/nthw_fpga_mod_str_map.c',
+    'nthw/core/nt200a0x/nthw_fpga_nt200a0x.c',
     'nthw/core/nthw_fpga.c',
     'nthw/core/nthw_hif.c',
     'nthw/core/nthw_iic.c',
drivers/net/ntnic/nthw/core/include/nthw_fpga.h +7 -0
index 1943f6e225..ba86b4d8d2 100644
@@ -18,5 +18,12 @@ int nthw_fpga_shutdown(struct fpga_info_s *p_fpga_info);
 
 int nthw_fpga_get_param_info(struct fpga_info_s *p_fpga_info, nthw_fpga_t *p_fpga);
 
+struct nt200a0x_ops {
+	int (*nthw_fpga_nt200a0x_init)(struct fpga_info_s *p_fpga_info);
+};
+
+void register_nt200a0x_ops(struct nt200a0x_ops *ops);
+struct nt200a0x_ops *get_nt200a0x_ops(void);
+void nt200a0x_ops_init(void);
 
 #endif	/* __NTHW_FPGA_H__ */
drivers/net/ntnic/nthw/core/nt200a0x/nthw_fpga_nt200a0x.c new file +54 -0

54 lines not on this page · raw message

drivers/net/ntnic/nthw/core/nthw_fpga.c +31 -0
index df238ec4ef..98d29744cb 100644
@@ -152,7 +152,18 @@ int nthw_fpga_init(struct fpga_info_s *p_fpga_info)
 	nthw_rac_rab_flush(p_nthw_rac);
 	p_fpga_info->mp_nthw_rac = p_nthw_rac;
 
+	bool included = true;
+	struct nt200a0x_ops *nt200a0x_ops = get_nt200a0x_ops();
+
 	switch (p_fpga_info->n_nthw_adapter_id) {
+	case NT_HW_ADAPTER_ID_NT200A02:
+		if (nt200a0x_ops != NULL)
+			res = nt200a0x_ops->nthw_fpga_nt200a0x_init(p_fpga_info);
+
+		else
+			included = false;
+
+		break;
 	default:
 		NT_LOG(ERR, NTHW, "%s: Unsupported HW product id: %d\n", p_adapter_id_str,
 			p_fpga_info->n_nthw_adapter_id);
@@ -160,6 +171,12 @@ int nthw_fpga_init(struct fpga_info_s *p_fpga_info)
 		break;
 	}
 
+	if (!included) {
+		NT_LOG(ERR, NTHW, "%s: NOT INCLUDED HW product: %d\n", p_adapter_id_str,
+			p_fpga_info->n_nthw_adapter_id);
+		res = -1;
+	}
+
 	if (res) {
 		NT_LOG(ERR, NTHW, "%s: status: 0x%08X\n", p_adapter_id_str, res);
 		return res;
@@ -220,3 +237,17 @@ int nthw_fpga_shutdown(struct fpga_info_s *p_fpga_info)
 
 	return res;
 }
+
+static struct nt200a0x_ops *nt200a0x_ops;
+
+void register_nt200a0x_ops(struct nt200a0x_ops *ops)
+{
+	nt200a0x_ops = ops;
+}
+
+struct nt200a0x_ops *get_nt200a0x_ops(void)
+{
+	if (nt200a0x_ops == NULL)
+		nt200a0x_ops_init();
+	return nt200a0x_ops;
+}
drivers/net/ntnic/nthw/nthw_platform.c +3 -0
index 181330dd37..33e18e549f 100644
@@ -8,6 +8,9 @@
 nthw_adapter_id_t nthw_platform_get_nthw_adapter_id(const uint16_t n_pci_device_id)
 {
 	switch (n_pci_device_id) {
+	case NT_HW_PCI_DEVICE_ID_NT200A02:
+		return NT_HW_ADAPTER_ID_NT200A02;
+
 	default:
 		return NT_HW_ADAPTER_ID_UNKNOWN;
 	}
drivers/net/ntnic/nthw/nthw_platform_drv.h +2 -0
index ab26d8149a..42eb0b8b05 100644
@@ -9,9 +9,11 @@
 #include <stdint.h>
 
 #define NT_HW_PCI_VENDOR_ID (0x18f4)
+#define NT_HW_PCI_DEVICE_ID_NT200A02 (0x1C5)
 
 enum nthw_adapter_id_e {
 	NT_HW_ADAPTER_ID_UNKNOWN = 0,
+	NT_HW_ADAPTER_ID_NT200A02,
 };
 
 typedef enum nthw_adapter_id_e nthw_adapter_id_t;
drivers/net/ntnic/ntnic_ethdev.c +3 -0
index b68fcba25b..5d3da88c58 100644
@@ -25,6 +25,7 @@
 #define EXCEPTION_PATH_HID 0
 
 static const struct rte_pci_id nthw_pci_id_map[] = {
+	{ RTE_PCI_DEVICE(NT_HW_PCI_VENDOR_ID, NT_HW_PCI_DEVICE_ID_NT200A02) },
 	{
 		.vendor_id = 0,
 	},	/* sentinel */
@@ -475,9 +476,11 @@ nthw_pci_remove(struct rte_pci_device *pci_dev)
 
 static struct rte_pci_driver rte_nthw_pmd = {
 	.id_table = nthw_pci_id_map,
+	.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
 	.probe = nthw_pci_probe,
 	.remove = nthw_pci_remove,
 };
 
 RTE_PMD_REGISTER_PCI(net_ntnic, rte_nthw_pmd);
+RTE_PMD_REGISTER_PCI_TABLE(net_ntnic, nthw_pci_id_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_ntnic, "* vfio-pci");
Signature · 1 line
2.45.0
#204 lore raw

PATCH v9 13/21 net/ntnic: add startup and reset sequence for NT200A0X

In reply to Serhii Iliushyk

Adds reset (RST) module for FW 9563.
Also adds SDRAM Controller (SDC) module,
as it is part of the startup and reset sequence.

---
v5
* Fix Typo/Spelling

---
 .../include/ntnic_nthw_fpga_rst_nt200a0x.h    |  81 +++
 drivers/net/ntnic/meson.build                 |   3 +
 .../net/ntnic/nthw/core/include/nthw_core.h   |   2 +
 .../net/ntnic/nthw/core/include/nthw_fpga.h   |   6 +
 .../net/ntnic/nthw/core/include/nthw_sdc.h    |  42 ++
 .../nthw/core/nt200a0x/nthw_fpga_nt200a0x.c   |  24 +-
 .../core/nt200a0x/reset/nthw_fpga_rst9563.c   | 216 +++++++
 .../nt200a0x/reset/nthw_fpga_rst_nt200a0x.c   | 570 ++++++++++++++++++
 drivers/net/ntnic/nthw/core/nthw_fpga.c       |  82 +++
 drivers/net/ntnic/nthw/core/nthw_sdc.c        | 176 ++++++
 drivers/net/ntnic/ntnic_mod_reg.c             |  28 +
 drivers/net/ntnic/ntnic_mod_reg.h             |  20 +
 12 files changed, 1249 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/ntnic/include/ntnic_nthw_fpga_rst_nt200a0x.h
 create mode 100644 drivers/net/ntnic/nthw/core/include/nthw_sdc.h
 create mode 100644 drivers/net/ntnic/nthw/core/nt200a0x/reset/nthw_fpga_rst9563.c
 create mode 100644 drivers/net/ntnic/nthw/core/nt200a0x/reset/nthw_fpga_rst_nt200a0x.c
 create mode 100644 drivers/net/ntnic/nthw/core/nthw_sdc.c
drivers/net/ntnic/include/ntnic_nthw_fpga_rst_nt200a0x.h new file +81 -0
new file mode 100644
index 0000000000..8a0b3fae50
@@ -0,0 +1,81 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef __NTNIC_NTHW_FPGA_RST_NT200A0X_H__
+#define __NTNIC_NTHW_FPGA_RST_NT200A0X_H__
+
+#include "nthw_drv.h"
+#include "nthw_fpga_model.h"
+
+struct nthw_fpga_rst_nt200a0x {
+	int mn_fpga_product_id;
+	int mn_fpga_version;
+	int mn_fpga_revision;
+
+	int mn_hw_id;
+
+	int mn_si_labs_clock_synth_model;
+
+	nthw_field_t *mp_fld_rst_sys;
+	nthw_field_t *mp_fld_rst_sys_mmcm;
+	nthw_field_t *mp_fld_rst_core_mmcm;
+	nthw_field_t *mp_fld_rst_rpp;
+	nthw_field_t *mp_fld_rst_ddr4;
+	nthw_field_t *mp_fld_rst_sdc;
+	nthw_field_t *mp_fld_rst_phy;
+	nthw_field_t *mp_fld_rst_serdes_rx;
+	nthw_field_t *mp_fld_rst_serdes_tx;
+	nthw_field_t *mp_fld_rst_serdes_rx_datapath;
+	nthw_field_t *mp_fld_rst_pcs_rx;
+	nthw_field_t *mp_fld_rst_mac_rx;
+	nthw_field_t *mp_fld_rst_mac_tx;
+	nthw_field_t *mp_fld_rst_ptp;
+	nthw_field_t *mp_fld_rst_ts;
+	nthw_field_t *mp_fld_rst_ptp_mmcm;
+	nthw_field_t *mp_fld_rst_ts_mmcm;
+	nthw_field_t *mp_fld_rst_periph;
+	nthw_field_t *mp_fld_rst_tsm_ref_mmcm;
+	nthw_field_t *mp_fld_rst_tmc;
+
+	/* CTRL register field pointers */
+	nthw_field_t *mp_fld_ctrl_ts_clk_sel_override;
+	nthw_field_t *mp_fld_ctrl_ts_clk_sel;
+	nthw_field_t *mp_fld_ctrl_ts_clk_sel_ref;
+	nthw_field_t *mp_fld_ctrl_ptp_mmcm_clk_sel;
+
+	/* STAT register field pointers */
+	nthw_field_t *mp_fld_stat_ddr4_mmcm_locked;
+	nthw_field_t *mp_fld_stat_sys_mmcm_locked;
+	nthw_field_t *mp_fld_stat_core_mmcm_locked;
+	nthw_field_t *mp_fld_stat_ddr4_pll_locked;
+	nthw_field_t *mp_fld_stat_ptp_mmcm_locked;
+	nthw_field_t *mp_fld_stat_ts_mmcm_locked;
+	nthw_field_t *mp_fld_stat_tsm_ref_mmcm_locked;
+
+	/* STICKY register field pointers */
+	nthw_field_t *mp_fld_sticky_ptp_mmcm_unlocked;
+	nthw_field_t *mp_fld_sticky_ts_mmcm_unlocked;
+	nthw_field_t *mp_fld_sticky_ddr4_mmcm_unlocked;
+	nthw_field_t *mp_fld_sticky_ddr4_pll_unlocked;
+	nthw_field_t *mp_fld_sticky_core_mmcm_unlocked;
+	nthw_field_t *mp_fld_sticky_pci_sys_mmcm_unlocked;
+	nthw_field_t *mp_fld_sticky_tsm_ref_mmcm_unlocked;
+
+	/* POWER register field pointers */
+	nthw_field_t *mp_fld_power_pu_phy;
+	nthw_field_t *mp_fld_power_pu_nseb;
+
+	void (*reset_serdes_rx)(struct nthw_fpga_rst_nt200a0x *p, uint32_t intf_no, uint32_t rst);
+	void (*pcs_rx_rst)(struct nthw_fpga_rst_nt200a0x *p, uint32_t intf_no, uint32_t rst);
+	void (*get_serdes_rx_rst)(struct nthw_fpga_rst_nt200a0x *p, uint32_t intf_no,
+		uint32_t *p_set);
+	void (*get_pcs_rx_rst)(struct nthw_fpga_rst_nt200a0x *p, uint32_t intf_no,
+		uint32_t *p_set);
+	bool (*is_rst_serdes_rx_datapath_implemented)(struct nthw_fpga_rst_nt200a0x *p);
+};
+
+typedef struct nthw_fpga_rst_nt200a0x nthw_fpga_rst_nt200a0x_t;
+
+#endif	/* __NTHW_FPGA_RST_NT200A0X_H__ */
drivers/net/ntnic/meson.build +3 -0
index e375c63bf8..d45a17526c 100644
@@ -26,10 +26,13 @@ sources = files(
     'nthw/supported/nthw_fpga_instances.c',
     'nthw/supported/nthw_fpga_mod_str_map.c',
     'nthw/core/nt200a0x/nthw_fpga_nt200a0x.c',
+    'nthw/core/nt200a0x/reset/nthw_fpga_rst9563.c',
+    'nthw/core/nt200a0x/reset/nthw_fpga_rst_nt200a0x.c',
     'nthw/core/nthw_fpga.c',
     'nthw/core/nthw_hif.c',
     'nthw/core/nthw_iic.c',
     'nthw/core/nthw_pcie3.c',
+    'nthw/core/nthw_sdc.c',
     'nthw/model/nthw_fpga_model.c',
     'nthw/nthw_platform.c',
     'nthw/nthw_rac.c',
drivers/net/ntnic/nthw/core/include/nthw_core.h +2 -0
index 69af113816..8bdf7ee01d 100644
@@ -16,5 +16,7 @@
 #include "nthw_pcie3.h"
 #include "nthw_iic.h"
 
+#include "nthw_sdc.h"
+
 
 #endif	/* __NTHW_CORE_H__ */
drivers/net/ntnic/nthw/core/include/nthw_fpga.h +6 -0
index ba86b4d8d2..1df1480109 100644
@@ -18,6 +18,12 @@ int nthw_fpga_shutdown(struct fpga_info_s *p_fpga_info);
 
 int nthw_fpga_get_param_info(struct fpga_info_s *p_fpga_info, nthw_fpga_t *p_fpga);
 
+int nthw_fpga_iic_scan(nthw_fpga_t *p_fpga, const int n_instance_no_begin,
+	const int n_instance_no_end);
+
+int nthw_fpga_silabs_detect(nthw_fpga_t *p_fpga, const int n_instance_no, const int n_dev_addr,
+	const int n_page_reg_addr);
+
 struct nt200a0x_ops {
 	int (*nthw_fpga_nt200a0x_init)(struct fpga_info_s *p_fpga_info);
 };
drivers/net/ntnic/nthw/core/include/nthw_sdc.h new file +42 -0

42 lines not on this page · raw message

drivers/net/ntnic/nthw/core/nt200a0x/nthw_fpga_nt200a0x.c +23 -1
index 7db6a03d88..3009e30670 100644
@@ -13,14 +13,36 @@ static int nthw_fpga_nt200a0x_init(struct fpga_info_s *p_fpga_info)
 	assert(p_fpga_info);
 
 	const char *const p_adapter_id_str = p_fpga_info->mp_adapter_id_str;
+	struct nthw_fpga_rst_nt200a0x rst;
 	int res = -1;
+	const struct rst_nt200a0x_ops *rst_nt200a0x_ops = get_rst_nt200a0x_ops();
+
+	if (rst_nt200a0x_ops == NULL) {
+		NT_LOG(ERR, NTHW, "RST NT200A0X NOT INCLUDED\n");
+		return -1;
+	}
+
+	/* reset common */
+	res = rst_nt200a0x_ops->nthw_fpga_rst_nt200a0x_init(p_fpga_info, &rst);
+
+	if (res) {
+		NT_LOG_DBGX(ERR, NTHW, "%s: FPGA=%04d res=%d\n", p_adapter_id_str,
+					p_fpga_info->n_fpga_prod_id, res);
+		return res;
+	}
 
 	bool included = true;
+	struct rst9563_ops *rst9563_ops = get_rst9563_ops();
 
 	/* reset specific */
 	switch (p_fpga_info->n_fpga_prod_id) {
 	case 9563:
-		included = false;
+		if (rst9563_ops != NULL)
+			res = rst9563_ops->nthw_fpga_rst9563_init(p_fpga_info, &rst);
+
+		else
+			included = false;
+
 		break;
 
 	default:
drivers/net/ntnic/nthw/core/nt200a0x/reset/nthw_fpga_rst9563.c new file +216 -0

216 lines not on this page · raw message

drivers/net/ntnic/nthw/core/nt200a0x/reset/nthw_fpga_rst_nt200a0x.c new file +570 -0

570 lines not on this page · raw message

drivers/net/ntnic/nthw/core/nthw_fpga.c +82 -0

88 lines not on this page · raw message

drivers/net/ntnic/nthw/core/nthw_sdc.c new file +176 -0

176 lines not on this page · raw message

drivers/net/ntnic/ntnic_mod_reg.c +28 -0
index 006221bbe3..bd0a966be2 100644
@@ -18,3 +18,31 @@ const struct adapter_ops *get_adapter_ops(void)
 		adapter_init();
 	return adapter_ops;
 }
+
+static struct rst_nt200a0x_ops *rst_nt200a0x_ops;
+
+void register_rst_nt200a0x_ops(struct rst_nt200a0x_ops *ops)
+{
+	rst_nt200a0x_ops = ops;
+}
+
+struct rst_nt200a0x_ops *get_rst_nt200a0x_ops(void)
+{
+	if (rst_nt200a0x_ops == NULL)
+		rst_nt200a0x_ops_init();
+	return rst_nt200a0x_ops;
+}
+
+static struct rst9563_ops *rst9563_ops;
+
+void register_rst9563_ops(struct rst9563_ops *ops)
+{
+	rst9563_ops = ops;
+}
+
+struct rst9563_ops *get_rst9563_ops(void)
+{
+	if (rst9563_ops == NULL)
+		rst9563_ops_init();
+	return rst9563_ops;
+}
drivers/net/ntnic/ntnic_mod_reg.h +20 -0
index 96fc829399..df8a8b9aca 100644
@@ -11,6 +11,7 @@
 #include "nthw_platform_drv.h"
 #include "nthw_drv.h"
 #include "nt4ga_adapter.h"
+#include "ntnic_nthw_fpga_rst_nt200a0x.h"
 #include "ntos_drv.h"
 
 struct adapter_ops {
@@ -24,5 +25,24 @@ void register_adapter_ops(const struct adapter_ops *ops);
 const struct adapter_ops *get_adapter_ops(void);
 void adapter_init(void);
 
+struct rst_nt200a0x_ops {
+	int (*nthw_fpga_rst_nt200a0x_init)(struct fpga_info_s *p_fpga_info,
+		struct nthw_fpga_rst_nt200a0x *p_rst);
+	int (*nthw_fpga_rst_nt200a0x_reset)(nthw_fpga_t *p_fpga,
+		const struct nthw_fpga_rst_nt200a0x *p);
+};
+
+void register_rst_nt200a0x_ops(struct rst_nt200a0x_ops *ops);
+struct rst_nt200a0x_ops *get_rst_nt200a0x_ops(void);
+void rst_nt200a0x_ops_init(void);
+
+struct rst9563_ops {
+	int (*nthw_fpga_rst9563_init)(struct fpga_info_s *p_fpga_info,
+		struct nthw_fpga_rst_nt200a0x *const p);
+};
+
+void register_rst9563_ops(struct rst9563_ops *ops);
+struct rst9563_ops *get_rst9563_ops(void);
+void rst9563_ops_init(void);
 
 #endif	/* __NTNIC_MOD_REG_H__ */
Signature · 1 line
2.45.0
#205 lore raw

PATCH v9 14/21 net/ntnic: add clock profile for the NT200A0X smartNIC

In reply to Serhii Iliushyk

Because the ntnic hardware supports multiple different FPGAs with different pipelines and port speeds,
the clock profile is not hardcoded into the product,
and need to be initialized from software.

The clock profile itself is an array of integers
that was generated by Silicon Labs ClockBuilder.

---
v6
* EOF comment was removed

---
 .../ntnic/include/clock_profiles_structs.h    |  33 +
 .../include/ntnic_nthw_fpga_rst_nt200a0x.h    |   1 +
 drivers/net/ntnic/meson.build                 |   2 +
 .../net/ntnic/nthw/core/include/nthw_core.h   |   2 +
 .../net/ntnic/nthw/core/include/nthw_fpga.h   |   4 +
 .../net/ntnic/nthw/core/include/nthw_si5340.h |  33 +
 .../NT200A02_U23_Si5340_adr0_v5-Registers.h   | 753 ++++++++++++++++++
 .../clock_profiles/nthw_fpga_clk9563.c        |  47 ++
 .../core/nt200a0x/reset/nthw_fpga_rst9563.c   |  35 +
 .../nt200a0x/reset/nthw_fpga_rst_nt200a0x.c   |   3 +
 drivers/net/ntnic/nthw/core/nthw_fpga.c       |  23 +
 drivers/net/ntnic/nthw/core/nthw_si5340.c     | 198 +++++
 drivers/net/ntnic/ntnic_mod_reg.c             |  14 +
 drivers/net/ntnic/ntnic_mod_reg.h             |   9 +
 14 files changed, 1157 insertions(+)
 create mode 100644 drivers/net/ntnic/include/clock_profiles_structs.h
 create mode 100644 drivers/net/ntnic/nthw/core/include/nthw_si5340.h
 create mode 100644 drivers/net/ntnic/nthw/core/nt200a0x/clock_profiles/NT200A02_U23_Si5340_adr0_v5-Registers.h
 create mode 100644 drivers/net/ntnic/nthw/core/nt200a0x/clock_profiles/nthw_fpga_clk9563.c
 create mode 100644 drivers/net/ntnic/nthw/core/nthw_si5340.c
drivers/net/ntnic/include/clock_profiles_structs.h new file +33 -0
new file mode 100644
index 0000000000..28a582a5e7
@@ -0,0 +1,33 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef _NT_CLOCK_PROFILES_STRUCTS_H_
+#define _NT_CLOCK_PROFILES_STRUCTS_H_
+
+#include <stdint.h>
+
+#define clk_profile_size_error_msg "Size test failed"
+
+struct clk_profile_data_fmt1_s {
+	uint16_t reg_addr;
+	uint8_t reg_val;
+};
+
+struct clk_profile_data_fmt2_s {
+	unsigned int reg_addr;
+	unsigned char reg_val;
+};
+
+typedef struct clk_profile_data_fmt1_s clk_profile_data_fmt1_t;
+typedef struct clk_profile_data_fmt2_s clk_profile_data_fmt2_t;
+
+enum clk_profile_data_fmt_e {
+	clk_profile_data_fmt_1,
+	clk_profile_data_fmt_2,
+};
+
+typedef enum clk_profile_data_fmt_e clk_profile_data_fmt_t;
+
+#endif	/* _NT_CLOCK_PROFILES_STRUCTS_H_ */
drivers/net/ntnic/include/ntnic_nthw_fpga_rst_nt200a0x.h +1 -0
index 8a0b3fae50..a1ee618c26 100644
@@ -17,6 +17,7 @@ struct nthw_fpga_rst_nt200a0x {
 	int mn_hw_id;
 
 	int mn_si_labs_clock_synth_model;
+	uint8_t mn_si_labs_clock_synth_i2c_addr;
 
 	nthw_field_t *mp_fld_rst_sys;
 	nthw_field_t *mp_fld_rst_sys_mmcm;
drivers/net/ntnic/meson.build +2 -0
index d45a17526c..987768cb92 100644
@@ -25,6 +25,7 @@ sources = files(
     'nthw/supported/nthw_fpga_9563_055_039_0000.c',
     'nthw/supported/nthw_fpga_instances.c',
     'nthw/supported/nthw_fpga_mod_str_map.c',
+    'nthw/core/nt200a0x/clock_profiles/nthw_fpga_clk9563.c',
     'nthw/core/nt200a0x/nthw_fpga_nt200a0x.c',
     'nthw/core/nt200a0x/reset/nthw_fpga_rst9563.c',
     'nthw/core/nt200a0x/reset/nthw_fpga_rst_nt200a0x.c',
@@ -33,6 +34,7 @@ sources = files(
     'nthw/core/nthw_iic.c',
     'nthw/core/nthw_pcie3.c',
     'nthw/core/nthw_sdc.c',
+    'nthw/core/nthw_si5340.c',
     'nthw/model/nthw_fpga_model.c',
     'nthw/nthw_platform.c',
     'nthw/nthw_rac.c',
drivers/net/ntnic/nthw/core/include/nthw_core.h +2 -0
index 8bdf7ee01d..5648bd8983 100644
@@ -18,5 +18,7 @@
 
 #include "nthw_sdc.h"
 
+#include "nthw_si5340.h"
+
 
 #endif	/* __NTHW_CORE_H__ */
drivers/net/ntnic/nthw/core/include/nthw_fpga.h +4 -0
index 1df1480109..cee1d23090 100644
@@ -24,6 +24,10 @@ int nthw_fpga_iic_scan(nthw_fpga_t *p_fpga, const int n_instance_no_begin,
 int nthw_fpga_silabs_detect(nthw_fpga_t *p_fpga, const int n_instance_no, const int n_dev_addr,
 	const int n_page_reg_addr);
 
+int nthw_fpga_si5340_clock_synth_init_fmt2(nthw_fpga_t *p_fpga, const uint8_t n_iic_addr,
+	const clk_profile_data_fmt2_t *p_clk_profile,
+	const int n_clk_profile_rec_cnt);
+
 struct nt200a0x_ops {
 	int (*nthw_fpga_nt200a0x_init)(struct fpga_info_s *p_fpga_info);
 };
drivers/net/ntnic/nthw/core/include/nthw_si5340.h new file +33 -0
new file mode 100644
index 0000000000..f56883d99a
@@ -0,0 +1,33 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef __NTHW_SI5340_H__
+#define __NTHW_SI5340_H__
+
+#include "clock_profiles_structs.h"
+
+#define SI5340_SUCCESS (0)
+#define SI5340_FAILED (999)
+#define SI5340_TIMEOUT (666)
+
+struct nthw_si5340 {
+	uint8_t mn_iic_addr;
+	nthw_iic_t *mp_nthw_iic;
+	int mn_clk_cfg;
+	uint8_t m_si5340_page;
+};
+
+typedef struct nthw_si5340 nthw_si5340_t;
+
+nthw_si5340_t *nthw_si5340_new(void);
+int nthw_si5340_init(nthw_si5340_t *p, nthw_iic_t *p_nthw_iic, uint8_t n_iic_addr);
+void nthw_si5340_delete(nthw_si5340_t *p);
+
+int nthw_si5340_config(nthw_si5340_t *p, const void *p_data, int data_cnt,
+	clk_profile_data_fmt_t data_format);
+int nthw_si5340_config_fmt2(nthw_si5340_t *p, const clk_profile_data_fmt2_t *p_data,
+	const int data_cnt);
+
+#endif	/* __NTHW_SI5338_H__ */
drivers/net/ntnic/nthw/core/nt200a0x/clock_profiles/NT200A02_U23_Si5340_adr0_v5-Registers.h new file +753 -0

753 lines not on this page · raw message

drivers/net/ntnic/nthw/core/nt200a0x/clock_profiles/nthw_fpga_clk9563.c new file +47 -0

47 lines not on this page · raw message

drivers/net/ntnic/nthw/core/nt200a0x/reset/nthw_fpga_rst9563.c +35 -0
index a3b6511b06..380f877096 100644
@@ -164,6 +164,34 @@ static int nthw_fpga_rst9563_periph_reset(nthw_fpga_t *p_fpga)
 	return 0;
 }
 
+static int nthw_fpga_rst9563_clock_synth_init(nthw_fpga_t *p_fpga,
+	const int n_si_labs_clock_synth_model,
+	const uint8_t n_si_labs_clock_synth_i2c_addr)
+{
+	const char *const p_adapter_id_str = p_fpga->p_fpga_info->mp_adapter_id_str;
+	const int n_fpga_product_id = p_fpga->mn_product_id;
+	int res;
+	const struct clk9563_ops *clk9563_ops = get_clk9563_ops();
+
+	if (clk9563_ops == NULL) {
+		NT_LOG(INF, NTNIC, "CLK9563 module not included\n");
+		return -1;
+	}
+
+	if (n_si_labs_clock_synth_model == 5340) {
+		res = nthw_fpga_si5340_clock_synth_init_fmt2(p_fpga, n_si_labs_clock_synth_i2c_addr,
+				clk9563_ops->get_p_data_9563_si5340_nt200a02_u23_v5(),
+				*clk9563_ops->get_n_data_9563_si5340_nt200a02_u23_v5());
+
+	} else {
+		NT_LOG(ERR, NTHW, "%s: Fpga %d: Unsupported clock synth model (%d)\n",
+			p_adapter_id_str, n_fpga_product_id, n_si_labs_clock_synth_model);
+		res = -1;
+	}
+
+	return res;
+}
+
 static int nthw_fpga_rst9563_init(struct fpga_info_s *p_fpga_info,
 	struct nthw_fpga_rst_nt200a0x *p_rst)
 {
@@ -173,9 +201,13 @@ static int nthw_fpga_rst9563_init(struct fpga_info_s *p_fpga_info,
 	const char *const p_adapter_id_str = p_fpga_info->mp_adapter_id_str;
 	(void)p_adapter_id_str;
 	int res = -1;
+	int n_si_labs_clock_synth_model;
+	uint8_t n_si_labs_clock_synth_i2c_addr;
 	nthw_fpga_t *p_fpga = NULL;
 
 	p_fpga = p_fpga_info->mp_fpga;
+	n_si_labs_clock_synth_model = p_rst->mn_si_labs_clock_synth_model;
+	n_si_labs_clock_synth_i2c_addr = p_rst->mn_si_labs_clock_synth_i2c_addr;
 
 	res = nthw_fpga_rst9563_periph_reset(p_fpga);
 
@@ -184,6 +216,9 @@ static int nthw_fpga_rst9563_init(struct fpga_info_s *p_fpga_info,
 		return res;
 	}
 
+	res = nthw_fpga_rst9563_clock_synth_init(p_fpga, n_si_labs_clock_synth_model,
+			n_si_labs_clock_synth_i2c_addr);
+
 	if (res) {
 		NT_LOG_DBGX(DEBUG, NTHW, "%s: ERROR: res=%d\n", p_adapter_id_str, res);
 		return res;
drivers/net/ntnic/nthw/core/nt200a0x/reset/nthw_fpga_rst_nt200a0x.c +3 -0
index 84f13e8371..ea0276a90c 100644
@@ -552,7 +552,10 @@ static int nthw_fpga_rst_nt200a0x_init(struct fpga_info_s *p_fpga_info,
 	}
 
 	p_rst->mn_si_labs_clock_synth_model = n_si_labs_clock_synth_model;
+	p_rst->mn_si_labs_clock_synth_i2c_addr = n_si_labs_clock_synth_i2c_addr;
 	p_rst->mn_hw_id = p_fpga_info->nthw_hw_info.hw_id;
+	NT_LOG_DBGX(DEBUG, NTHW, "%s: Si%04d @ 0x%02x\n", p_adapter_id_str,
+		p_rst->mn_si_labs_clock_synth_model, p_rst->mn_si_labs_clock_synth_i2c_addr);
 
 	return res;
 }
drivers/net/ntnic/nthw/core/nthw_fpga.c +23 -0
index 1650bb8a5c..38169176a5 100644
@@ -147,6 +147,29 @@ int nthw_fpga_silabs_detect(nthw_fpga_t *p_fpga, const int n_instance_no, const
 	return res;
 }
 
+/*
+ * NT200A02, NT200A01-HWbuild2
+ */
+int nthw_fpga_si5340_clock_synth_init_fmt2(nthw_fpga_t *p_fpga, const uint8_t n_iic_addr,
+	const clk_profile_data_fmt2_t *p_clk_profile,
+	const int n_clk_profile_rec_cnt)
+{
+	int res;
+	nthw_iic_t *p_nthw_iic = nthw_iic_new();
+	nthw_si5340_t *p_nthw_si5340 = nthw_si5340_new();
+
+	assert(p_nthw_iic);
+	assert(p_nthw_si5340);
+	nthw_iic_init(p_nthw_iic, p_fpga, 0, 8);/* I2C cycle time 125Mhz ~ 8ns */
+
+	nthw_si5340_init(p_nthw_si5340, p_nthw_iic, n_iic_addr);/* si5340_u23_i2c_addr_7bit */
+	res = nthw_si5340_config_fmt2(p_nthw_si5340, p_clk_profile, n_clk_profile_rec_cnt);
+	nthw_si5340_delete(p_nthw_si5340);
+	p_nthw_si5340 = NULL;
+
+	return res;
+}
+
 int nthw_fpga_init(struct fpga_info_s *p_fpga_info)
 {
 	const char *const p_adapter_id_str = p_fpga_info->mp_adapter_id_str;
drivers/net/ntnic/nthw/core/nthw_si5340.c new file +198 -0

198 lines not on this page · raw message

drivers/net/ntnic/ntnic_mod_reg.c +14 -0
index bd0a966be2..3f03299a83 100644
@@ -19,6 +19,20 @@ const struct adapter_ops *get_adapter_ops(void)
 	return adapter_ops;
 }
 
+static struct clk9563_ops *clk9563_ops;
+
+void register_clk9563_ops(struct clk9563_ops *ops)
+{
+	clk9563_ops = ops;
+}
+
+struct clk9563_ops *get_clk9563_ops(void)
+{
+	if (clk9563_ops == NULL)
+		clk9563_ops_init();
+	return clk9563_ops;
+}
+
 static struct rst_nt200a0x_ops *rst_nt200a0x_ops;
 
 void register_rst_nt200a0x_ops(struct rst_nt200a0x_ops *ops)
drivers/net/ntnic/ntnic_mod_reg.h +9 -0
index df8a8b9aca..45f5632981 100644
@@ -25,6 +25,15 @@ void register_adapter_ops(const struct adapter_ops *ops);
 const struct adapter_ops *get_adapter_ops(void);
 void adapter_init(void);
 
+struct clk9563_ops {
+	const int *(*get_n_data_9563_si5340_nt200a02_u23_v5)(void);
+	const clk_profile_data_fmt2_t *(*get_p_data_9563_si5340_nt200a02_u23_v5)(void);
+};
+
+void register_clk9563_ops(struct clk9563_ops *ops);
+struct clk9563_ops *get_clk9563_ops(void);
+void clk9563_ops_init(void);
+
 struct rst_nt200a0x_ops {
 	int (*nthw_fpga_rst_nt200a0x_init)(struct fpga_info_s *p_fpga_info,
 		struct nthw_fpga_rst_nt200a0x *p_rst);
Signature · 1 line
2.45.0
#206 lore raw

Re: [PATCH v9 14/21] net/ntnic: add clock profile for the NT200A0X smartNIC

Quoted 14 lines · Serhii Iliushyk
drivers/net/ntnic/nthw/core/nt200a0x/clock_profiles/nthw_fpga_clk9563.c new file +7 -0
new file mode 100644
index 0000000000..a957581bf3
@@ -0,0 +1,47 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#include "ntnic_mod_reg.h"
+

drivers/net/ntnic/nthw/core/nt200a0x/clock_profiles/nthw_fpga_clk9563.c line 17

Quoted 10 lines
drivers/net/ntnic/nthw/core/nt200a0x/clock_profiles/nthw_fpga_clk9563.c new file +10 -0
+/*
+ * Clock profile for NT200A02 FPGA 9563
+ */
+#define si5340_revd_register_t type_9563_si5340_nt200a02_u23_v5
+#define si5340_revd_registers data_9563_si5340_nt200a02_u23_v5
+#include "NT200A02_U23_Si5340_adr0_v5-Registers.h"
+#ifdef __cplusplus
+static_assert(sizeof(type_9563_si5340_nt200a02_u23_v5) == sizeof(clk_profile_data_fmt2_t),
+	clk_profile_size_error_msg);
+#endif	/* __cplusplus */

As project compiled with C11 standard, C supports static assert, keyword by spec is '_Static_assert' but it is aliased to 'static_assert', please check 'rte_common.h', so it should be OK to use 'static_assert' directly without "#ifdef __cplusplus".

Or DPDK macro for it is 'RTE_BUILD_BUG_ON', both are OK, up to you.

#207 lore raw

PATCH v9 15/21 net/ntnic: add link management skeleton

In reply to Serhii Iliushyk

Add functionality to read and control the link-state of the ntnic. Note that must functions are not implemented yet.

Adds the following eth_dev_ops:
- dev_set_link_up
- dev_set_link_down
- link_update
- mac_addr_add
- mac_addr_set
- set_mc_addr_list
- promiscuous_enable

---
v5
* Fix Typo/Spelling
v6
* if_index was replaced with n_intf_no
* MAC addr assignment approach was reworked
v7
* Add relate features to documentation - INI and RST files

---
 doc/guides/nics/features/ntnic.ini        |   3 +
 doc/guides/nics/ntnic.rst                 |   5 +
 drivers/net/ntnic/adapter/nt4ga_adapter.c |   6 +
 drivers/net/ntnic/include/nt4ga_adapter.h |   5 +-
 drivers/net/ntnic/include/nt4ga_link.h    |  84 +++++++
 drivers/net/ntnic/include/ntos_drv.h      |  10 +
 drivers/net/ntnic/link_mgmt/nt4ga_link.c  | 176 ++++++++++++++
 drivers/net/ntnic/meson.build             |   1 +
 drivers/net/ntnic/ntnic_ethdev.c          | 281 ++++++++++++++++++++++
 drivers/net/ntnic/ntnic_mod_reg.c         |  14 ++
 drivers/net/ntnic/ntnic_mod_reg.h         |  50 +++-
 drivers/net/ntnic/ntutil/nt_util.c        | 131 ++++++++++
 drivers/net/ntnic/ntutil/nt_util.h        |  11 +
 13 files changed, 775 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/ntnic/include/nt4ga_link.h
 create mode 100644 drivers/net/ntnic/link_mgmt/nt4ga_link.c
doc/guides/nics/features/ntnic.ini +3 -0
index 03f4d5aac8..0a74817fcf 100644
@@ -5,5 +5,8 @@
 ;
 [Features]
 FW version           = Y
+Speed capabilities   = Y
+Unicast MAC filter   = Y
+Multicast MAC filter = Y
 Linux                = Y
 x86-64               = Y
doc/guides/nics/ntnic.rst +5 -0
index db168e1686..d612da53ee 100644
@@ -33,6 +33,11 @@ Features
 --------
 
 - FW version
+- Speed capabilities
+- Link status (Link update only)
+- Unicast MAC filter
+- Multicast MAC filter
+- Promiscuous mode (Enable only. The device always run promiscuous mode)
 
 Limitations
 ~~~~~~~~~~~
drivers/net/ntnic/adapter/nt4ga_adapter.c +6 -0
index 1bdd11f227..be98938cc3 100644
@@ -124,8 +124,14 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info)
 	assert(n_phy_ports >= 1);
 
 	{
+		int i;
 		assert(fpga_info->n_fpga_prod_id > 0);
 
+		for (i = 0; i < NUM_ADAPTER_PORTS_MAX; i++) {
+			/* Disable all ports. Must be enabled later */
+			p_adapter_info->nt4ga_link.port_action[i].port_disable = true;
+		}
+
 		switch (fpga_info->n_fpga_prod_id) {
 		/* NT200A01: 2x100G (Xilinx) */
 		case 9563:	/* NT200A02 (Cap) */
drivers/net/ntnic/include/nt4ga_adapter.h +4 -1
index 2c72583caf..ed14936b38 100644
@@ -6,7 +6,8 @@
 #ifndef _NT4GA_ADAPTER_H_
 #define _NT4GA_ADAPTER_H_
 
-#include "ntos_drv.h"
+#include "nt4ga_link.h"
+
 typedef struct hw_info_s {
 	/* pciids */
 	uint16_t pci_vendor_id;
@@ -23,6 +24,8 @@ typedef struct hw_info_s {
 } hw_info_t;
 
 typedef struct adapter_info_s {
+	struct nt4ga_link_s nt4ga_link;
+
 	struct hw_info_s hw_info;
 	struct fpga_info_s fpga_info;
 
drivers/net/ntnic/include/nt4ga_link.h new file +84 -0

84 lines not on this page · raw message

drivers/net/ntnic/include/ntos_drv.h +10 -0
index 3f621143d9..67baf9fe0c 100644
@@ -25,7 +25,17 @@ struct pmd_internals {
 	const struct rte_pci_device *pci_dev;
 	char name[20];
 	int n_intf_no;
+	int lpbk_mode;
+	unsigned int nb_rx_queues;
+	unsigned int nb_tx_queues;
+	/* Offset of the VF from the PF */
+	uint8_t vf_offset;
+	nt_meta_port_type_t type;
 	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];
+	/* Multicast ethernet (MAC) addresses. */
+	struct rte_ether_addr mc_addrs[NUM_MULTICAST_ADDRS_PER_PORT];
 	struct pmd_internals *next;
 };
 
drivers/net/ntnic/link_mgmt/nt4ga_link.c new file +176 -0

176 lines not on this page · raw message

drivers/net/ntnic/meson.build +1 -0
index 987768cb92..001c75963e 100644
@@ -22,6 +22,7 @@ includes = [
 # all sources
 sources = files(
     'adapter/nt4ga_adapter.c',
+    'link_mgmt/nt4ga_link.c',
     'nthw/supported/nthw_fpga_9563_055_039_0000.c',
     'nthw/supported/nthw_fpga_instances.c',
     'nthw/supported/nthw_fpga_mod_str_map.c',
drivers/net/ntnic/ntnic_ethdev.c +281 -0

370 lines not on this page · raw message

drivers/net/ntnic/ntnic_mod_reg.c +14 -0
index 3f03299a83..b79929c696 100644
@@ -5,6 +5,20 @@
 
 #include "ntnic_mod_reg.h"
 
+static const struct port_ops *port_ops;
+
+void register_port_ops(const struct port_ops *ops)
+{
+	port_ops = ops;
+}
+
+const struct port_ops *get_port_ops(void)
+{
+	if (port_ops == NULL)
+		port_init();
+	return port_ops;
+}
+
 static const struct adapter_ops *adapter_ops;
 
 void register_adapter_ops(const struct adapter_ops *ops)
drivers/net/ntnic/ntnic_mod_reg.h +49 -1

56 lines not on this page · raw message

drivers/net/ntnic/ntutil/nt_util.c +131 -0

134 lines not on this page · raw message

drivers/net/ntnic/ntutil/nt_util.h +11 -0
index 6dfd7428e1..ea91181a06 100644
@@ -7,6 +7,7 @@
 #define NTOSS_SYSTEM_NT_UTIL_H
 
 #include <stdint.h>
+#include "nt4ga_link.h"
 
 #ifndef ARRAY_SIZE
 #define ARRAY_SIZE(arr) RTE_DIM(arr)
@@ -30,6 +31,11 @@ struct nt_dma_s {
 	uint64_t size;
 };
 
+struct port_link_speed {
+	int port_id;
+	int link_speed;
+};
+
 struct nt_dma_s *nt_dma_alloc(uint64_t size, uint64_t align, int numa);
 void nt_dma_free(struct nt_dma_s *vfio_addr);
 
@@ -40,4 +46,9 @@ struct nt_util_vfio_impl {
 
 void nt_util_vfio_init(struct nt_util_vfio_impl *impl);
 
+int nt_link_speed_to_eth_speed_num(enum nt_link_speed_e nt_link_speed);
+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);
+
 #endif	/* NTOSS_SYSTEM_NT_UTIL_H */
Signature · 1 line
2.45.0
#208 lore raw

PATCH v9 16/21 net/ntnic: add link 100G module ops

In reply to Serhii Iliushyk

As the ntnic can support different speeds,
an abstraction layer for 100G speed is needed.

---
 drivers/net/ntnic/adapter/nt4ga_adapter.c     | 12 ++++-
 .../link_mgmt/link_100g/nt4ga_link_100g.c     | 49 +++++++++++++++++++
 drivers/net/ntnic/meson.build                 |  1 +
 drivers/net/ntnic/ntnic_mod_reg.c             | 14 ++++++
 drivers/net/ntnic/ntnic_mod_reg.h             |  8 +++
 5 files changed, 82 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/ntnic/link_mgmt/link_100g/nt4ga_link_100g.c
drivers/net/ntnic/adapter/nt4ga_adapter.c +10 -2
index be98938cc3..43bb566e33 100644
@@ -125,6 +125,7 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info)
 
 	{
 		int i;
+		const struct link_ops_s *link_ops = NULL;
 		assert(fpga_info->n_fpga_prod_id > 0);
 
 		for (i = 0; i < NUM_ADAPTER_PORTS_MAX; i++) {
@@ -135,8 +136,15 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info)
 		switch (fpga_info->n_fpga_prod_id) {
 		/* NT200A01: 2x100G (Xilinx) */
 		case 9563:	/* NT200A02 (Cap) */
-			NT_LOG(ERR, NTNIC, "NT200A02 100G link module uninitialized\n");
-			res = -1;
+			link_ops = get_100g_link_ops();
+
+			if (link_ops == NULL) {
+				NT_LOG(ERR, NTNIC, "NT200A02 100G link module uninitialized\n");
+				res = -1;
+				break;
+			}
+
+			res = link_ops->link_init(p_adapter_info, p_fpga);
 			break;
 
 		default:
drivers/net/ntnic/link_mgmt/link_100g/nt4ga_link_100g.c new file +49 -0

49 lines not on this page · raw message

drivers/net/ntnic/meson.build +1 -0
index 001c75963e..32f955969f 100644
@@ -22,6 +22,7 @@ includes = [
 # all sources
 sources = files(
     'adapter/nt4ga_adapter.c',
+    'link_mgmt/link_100g/nt4ga_link_100g.c',
     'link_mgmt/nt4ga_link.c',
     'nthw/supported/nthw_fpga_9563_055_039_0000.c',
     'nthw/supported/nthw_fpga_instances.c',
drivers/net/ntnic/ntnic_mod_reg.c +14 -0
index b79929c696..40e22c60fa 100644
@@ -5,6 +5,20 @@
 
 #include "ntnic_mod_reg.h"
 
+static struct link_ops_s *link_100g_ops;
+
+void register_100g_link_ops(struct link_ops_s *ops)
+{
+	link_100g_ops = ops;
+}
+
+const struct link_ops_s *get_100g_link_ops(void)
+{
+	if (link_100g_ops == NULL)
+		link_100g_init();
+	return link_100g_ops;
+}
+
 static const struct port_ops *port_ops;
 
 void register_port_ops(const struct port_ops *ops)
drivers/net/ntnic/ntnic_mod_reg.h +8 -0
index 8d1971a9c4..68629412b7 100644
@@ -13,6 +13,14 @@
 #include "nt4ga_adapter.h"
 #include "ntnic_nthw_fpga_rst_nt200a0x.h"
 
+struct link_ops_s {
+	int (*link_init)(struct adapter_info_s *p_adapter_info, nthw_fpga_t *p_fpga);
+};
+
+void register_100g_link_ops(struct link_ops_s *ops);
+const struct link_ops_s *get_100g_link_ops(void);
+void link_100g_init(void);
+
 struct port_ops {
 	/*
 	 * port:s link mode
Signature · 1 line
2.45.0
#209 lore raw

PATCH v9 17/21 net/ntnic: add generic NIM and I2C modules

In reply to Serhii Iliushyk

As the ntnic can support different port speeds, it also needs to support different NIMs (Network Interface Module). This commit add the generic NIM support for ntnic, such that the specific modules,
such as QSFP28 can be added later.

The communication with NIMs is in the form of I2C, so support for such a module is added as well.

Additionally a thread is added to control the NIM stat machines.

---
v6
* Remove unnecessary comments

---
 drivers/net/ntnic/adapter/nt4ga_adapter.c     |  34 +++
 drivers/net/ntnic/include/nt4ga_adapter.h     |   3 +
 drivers/net/ntnic/include/nt4ga_link.h        |  13 +
 drivers/net/ntnic/include/ntnic_nim.h         |  61 +++++
 .../link_mgmt/link_100g/nt4ga_link_100g.c     | 214 ++++++++++++++++-
 drivers/net/ntnic/link_mgmt/nt4ga_link.c      |  13 +
 drivers/net/ntnic/meson.build                 |   3 +
 drivers/net/ntnic/nim/i2c_nim.c               | 224 ++++++++++++++++++
 drivers/net/ntnic/nim/i2c_nim.h               |  24 ++
 drivers/net/ntnic/nim/nim_defines.h           |  29 +++
 .../net/ntnic/nthw/core/include/nthw_core.h   |   1 +
 .../net/ntnic/nthw/core/include/nthw_i2cm.h   |  50 ++++
 drivers/net/ntnic/nthw/core/nthw_fpga.c       |   3 +
 drivers/net/ntnic/nthw/core/nthw_i2cm.c       | 192 +++++++++++++++
 drivers/net/ntnic/nthw/nthw_drv.h             |   1 +
 drivers/net/ntnic/ntnic_mod_reg.h             |   7 +
 16 files changed, 871 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/ntnic/include/ntnic_nim.h
 create mode 100644 drivers/net/ntnic/nim/i2c_nim.c
 create mode 100644 drivers/net/ntnic/nim/i2c_nim.h
 create mode 100644 drivers/net/ntnic/nim/nim_defines.h
 create mode 100644 drivers/net/ntnic/nthw/core/include/nthw_i2cm.h
 create mode 100644 drivers/net/ntnic/nthw/core/nthw_i2cm.c
drivers/net/ntnic/adapter/nt4ga_adapter.c +34 -0
index 43bb566e33..b704a256c6 100644
@@ -9,6 +9,32 @@
 #include "nthw_fpga.h"
 #include "ntnic_mod_reg.h"
 
+/*
+ * Global variables shared by NT adapter types
+ */
+rte_thread_t monitor_tasks[NUM_ADAPTER_MAX];
+volatile int monitor_task_is_running[NUM_ADAPTER_MAX];
+
+/*
+ * Signal-handler to stop all monitor threads
+ */
+static void stop_monitor_tasks(int signum)
+{
+	const size_t N = ARRAY_SIZE(monitor_task_is_running);
+	size_t i;
+
+	/* Stop all monitor tasks */
+	for (i = 0; i < N; i++) {
+		const int is_running = monitor_task_is_running[i];
+		monitor_task_is_running[i] = 0;
+
+		if (signum == -1 && is_running != 0) {
+			rte_thread_join(monitor_tasks[i], NULL);
+			memset(&monitor_tasks[i], 0, sizeof(monitor_tasks[0]));
+		}
+	}
+}
+
 static int nt4ga_adapter_show_info(struct adapter_info_s *p_adapter_info, FILE *pfh)
 {
 	const char *const p_dev_name = p_adapter_info->p_dev_name;
@@ -35,6 +61,9 @@ static int nt4ga_adapter_show_info(struct adapter_info_s *p_adapter_info, FILE *
 		p_fpga_info->n_fpga_ver_id, p_fpga_info->n_fpga_rev_id, p_fpga_info->n_fpga_ident,
 		p_fpga_info->n_fpga_build_time);
 	fprintf(pfh, "%s: FpgaDebugMode=0x%x\n", p_adapter_id_str, p_fpga_info->n_fpga_debug_mode);
+	fprintf(pfh, "%s: Nims=%d PhyPorts=%d PhyQuads=%d RxPorts=%d TxPorts=%d\n",
+		p_adapter_id_str, p_fpga_info->n_nims, p_fpga_info->n_phy_ports,
+		p_fpga_info->n_phy_quads, p_fpga_info->n_rx_ports, p_fpga_info->n_tx_ports);
 	fprintf(pfh, "%s: Hw=0x%02X_rev%d: %s\n", p_adapter_id_str, p_hw_info->hw_platform_id,
 		p_fpga_info->nthw_hw_info.hw_id, p_fpga_info->nthw_hw_info.hw_plat_id_str);
 	fprintf(pfh, "%s: MCU Details:\n", p_adapter_id_str);
@@ -56,6 +85,7 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info)
 	 * (nthw_fpga_init())
 	 */
 	int n_phy_ports = -1;
+	int n_nim_ports = -1;
 	int res = -1;
 	nthw_fpga_t *p_fpga = NULL;
 
@@ -122,6 +152,8 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info)
 	assert(p_fpga);
 	n_phy_ports = fpga_info->n_phy_ports;
 	assert(n_phy_ports >= 1);
+	n_nim_ports = fpga_info->n_nims;
+	assert(n_nim_ports >= 1);
 
 	{
 		int i;
@@ -171,6 +203,8 @@ static int nt4ga_adapter_deinit(struct adapter_info_s *p_adapter_info)
 	int i;
 	int res = -1;
 
+	stop_monitor_tasks(-1);
+
 	nthw_fpga_shutdown(&p_adapter_info->fpga_info);
 
 	/* Rac rab reset flip flop */
drivers/net/ntnic/include/nt4ga_adapter.h +3 -0
index ed14936b38..4b204742a2 100644
@@ -39,5 +39,8 @@ typedef struct adapter_info_s {
 	int n_tx_host_buffers;
 } adapter_info_t;
 
+extern rte_thread_t monitor_tasks[NUM_ADAPTER_MAX];
+extern volatile int monitor_task_is_running[NUM_ADAPTER_MAX];
+
 
 #endif	/* _NT4GA_ADAPTER_H_ */
drivers/net/ntnic/include/nt4ga_link.h +13 -0
index 849261ce3a..0851057f81 100644
@@ -7,6 +7,7 @@
 #define NT4GA_LINK_H_
 
 #include "ntos_drv.h"
+#include "ntnic_nim.h"
 
 enum nt_link_state_e {
 	NT_LINK_STATE_UNKNOWN = 0,	/* The link state has not been read yet */
@@ -41,6 +42,8 @@ enum nt_link_auto_neg_e {
 
 typedef struct link_state_s {
 	bool link_disabled;
+	bool nim_present;
+	bool lh_nim_absent;
 	bool link_up;
 	enum nt_link_state_e link_state;
 	enum nt_link_state_e link_state_latched;
@@ -73,12 +76,22 @@ typedef struct port_action_s {
 	uint32_t port_lpbk_mode;
 } port_action_t;
 
+typedef struct adapter_100g_s {
+	nim_i2c_ctx_t nim_ctx[NUM_ADAPTER_PORTS_MAX];	/* Should be the first field */
+} adapter_100g_t;
+
+typedef union adapter_var_s {
+	nim_i2c_ctx_t nim_ctx[NUM_ADAPTER_PORTS_MAX];	/* First field in all the adapters type */
+	adapter_100g_t var100g;
+} adapter_var_u;
+
 typedef struct nt4ga_link_s {
 	link_state_t link_state[NUM_ADAPTER_PORTS_MAX];
 	link_info_t link_info[NUM_ADAPTER_PORTS_MAX];
 	port_action_t port_action[NUM_ADAPTER_PORTS_MAX];
 	uint32_t speed_capa;
 	bool variables_initialized;
+	adapter_var_u u;
 } nt4ga_link_t;
 
 #endif	/* NT4GA_LINK_H_ */
drivers/net/ntnic/include/ntnic_nim.h new file +61 -0

61 lines not on this page · raw message

drivers/net/ntnic/link_mgmt/link_100g/nt4ga_link_100g.c +213 -1

241 lines not on this page · raw message

drivers/net/ntnic/link_mgmt/nt4ga_link.c +13 -0
index ad23046aae..bc362776fc 100644
@@ -12,6 +12,7 @@
 #include "ntnic_mod_reg.h"
 
 #include "nt4ga_link.h"
+#include "i2c_nim.h"
 
 /*
  * port: speed capabilities
@@ -26,6 +27,16 @@ static uint32_t nt4ga_port_get_link_speed_capabilities(struct adapter_info_s *p,
 	return nt_link_speed_capa;
 }
 
+/*
+ * port: nim present
+ */
+static bool nt4ga_port_get_nim_present(struct adapter_info_s *p, int port)
+{
+	nt4ga_link_t *const p_link = &p->nt4ga_link;
+	const bool nim_present = p_link->link_state[port].nim_present;
+	return nim_present;
+}
+
 /*
  * port: link mode
  */
@@ -131,6 +142,8 @@ static uint32_t nt4ga_port_get_loopback_mode(struct adapter_info_s *p, int port)
 
 
 static const struct port_ops ops = {
+	.get_nim_present = nt4ga_port_get_nim_present,
+
 	/*
 	 * port:s link mode
 	 */
drivers/net/ntnic/meson.build +3 -0
index 32f955969f..efea37e61a 100644
@@ -17,6 +17,7 @@ includes = [
     include_directories('nthw'),
     include_directories('nthw/supported'),
     include_directories('nthw/model'),
+    include_directories('nim/'),
 ]
 
 # all sources
@@ -24,6 +25,7 @@ sources = files(
     'adapter/nt4ga_adapter.c',
     'link_mgmt/link_100g/nt4ga_link_100g.c',
     'link_mgmt/nt4ga_link.c',
+    'nim/i2c_nim.c',
     'nthw/supported/nthw_fpga_9563_055_039_0000.c',
     'nthw/supported/nthw_fpga_instances.c',
     'nthw/supported/nthw_fpga_mod_str_map.c',
@@ -33,6 +35,7 @@ sources = files(
     'nthw/core/nt200a0x/reset/nthw_fpga_rst_nt200a0x.c',
     'nthw/core/nthw_fpga.c',
     'nthw/core/nthw_hif.c',
+    'nthw/core/nthw_i2cm.c',
     'nthw/core/nthw_iic.c',
     'nthw/core/nthw_pcie3.c',
     'nthw/core/nthw_sdc.c',
drivers/net/ntnic/nim/i2c_nim.c new file +224 -0

224 lines not on this page · raw message

drivers/net/ntnic/nim/i2c_nim.h new file +24 -0
new file mode 100644
index 0000000000..e89ae47835
@@ -0,0 +1,24 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef I2C_NIM_H_
+#define I2C_NIM_H_
+
+#include "ntnic_nim.h"
+
+/*
+ * Returns a type name such as "SFP/SFP+" for a given NIM type identifier,
+ * or the string "ILLEGAL!".
+ */
+const char *nim_id_to_text(uint8_t nim_id);
+
+/*
+ * This function tries to classify NIM based on it's ID and some register reads
+ * and collects information into ctx structure. The @extra parameter could contain
+ * the initialization argument for specific type of NIMS.
+ */
+int construct_and_preinit_nim(nim_i2c_ctx_p ctx);
+
+#endif	/* I2C_NIM_H_ */
drivers/net/ntnic/nim/nim_defines.h new file +29 -0
new file mode 100644
index 0000000000..9ba861bb4f
@@ -0,0 +1,29 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef NIM_DEFINES_H_
+#define NIM_DEFINES_H_
+
+#define NIM_IDENTIFIER_ADDR 0	/* 1 byte */
+
+/* I2C addresses */
+#define NIM_I2C_0XA0 0xA0	/* Basic I2C address */
+#define NIM_I2C_0XA2 0xA2	/* Diagnostic monitoring */
+
+typedef enum {
+	NIM_OPTION_TX_DISABLE,
+	/* Indicates that the module should be checked for the two next FEC types */
+	NIM_OPTION_FEC,
+	NIM_OPTION_MEDIA_SIDE_FEC,
+	NIM_OPTION_HOST_SIDE_FEC,
+	NIM_OPTION_RX_ONLY
+} nim_option_t;
+
+enum nt_nim_identifier_e {
+	NT_NIM_UNKNOWN = 0x00,	/* Nim type is unknown */
+};
+typedef enum nt_nim_identifier_e nt_nim_identifier_t;
+
+#endif	/* NIM_DEFINES_H_ */
drivers/net/ntnic/nthw/core/include/nthw_core.h +1 -0
index 5648bd8983..8d9d78b86d 100644
@@ -15,6 +15,7 @@
 #include "nthw_hif.h"
 #include "nthw_pcie3.h"
 #include "nthw_iic.h"
+#include "nthw_i2cm.h"
 
 #include "nthw_sdc.h"
 
drivers/net/ntnic/nthw/core/include/nthw_i2cm.h new file +50 -0

50 lines not on this page · raw message

drivers/net/ntnic/nthw/core/nthw_fpga.c +3 -0
index 38169176a5..d70205e5e3 100644
@@ -19,12 +19,14 @@ int nthw_fpga_get_param_info(struct fpga_info_s *p_fpga_info, nthw_fpga_t *p_fpg
 {
 	mcu_info_t *p_mcu_info = &p_fpga_info->mcu_info;
 
+	const int n_nims = nthw_fpga_get_product_param(p_fpga, NT_NIMS, -1);
 	const int n_phy_ports = nthw_fpga_get_product_param(p_fpga, NT_PHY_PORTS, -1);
 	const int n_phy_quads = nthw_fpga_get_product_param(p_fpga, NT_PHY_QUADS, -1);
 	const int n_rx_ports = nthw_fpga_get_product_param(p_fpga, NT_RX_PORTS, -1);
 	const int n_tx_ports = nthw_fpga_get_product_param(p_fpga, NT_TX_PORTS, -1);
 	const int n_vf_offset = nthw_fpga_get_product_param(p_fpga, NT_HIF_VF_OFFSET, 4);
 
+	p_fpga_info->n_nims = n_nims;
 	p_fpga_info->n_phy_ports = n_phy_ports;
 	p_fpga_info->n_phy_quads = n_phy_quads;
 	p_fpga_info->n_rx_ports = n_rx_ports;
@@ -236,6 +238,7 @@ int nthw_fpga_init(struct fpga_info_s *p_fpga_info)
 	nthw_fpga_get_param_info(p_fpga_info, p_fpga);
 
 	/* debug: report params */
+	NT_LOG(DBG, NTHW, "%s: NT_NIMS=%d\n", p_adapter_id_str, p_fpga_info->n_nims);
 	NT_LOG(DBG, NTHW, "%s: NT_PHY_PORTS=%d\n", p_adapter_id_str, p_fpga_info->n_phy_ports);
 	NT_LOG(DBG, NTHW, "%s: NT_PHY_QUADS=%d\n", p_adapter_id_str, p_fpga_info->n_phy_quads);
 	NT_LOG(DBG, NTHW, "%s: NT_RX_PORTS=%d\n", p_adapter_id_str, p_fpga_info->n_rx_ports);
drivers/net/ntnic/nthw/core/nthw_i2cm.c new file +192 -0

192 lines not on this page · raw message

drivers/net/ntnic/nthw/nthw_drv.h +1 -0
index 071618eb6e..de60ae171e 100644
@@ -52,6 +52,7 @@ typedef struct fpga_info_s {
 
 	int n_fpga_debug_mode;
 
+	int n_nims;
 	int n_phy_ports;
 	int n_phy_quads;
 	int n_rx_ports;
drivers/net/ntnic/ntnic_mod_reg.h +7 -0
index 68629412b7..3189b04f33 100644
@@ -22,6 +22,8 @@ const struct link_ops_s *get_100g_link_ops(void);
 void link_100g_init(void);
 
 struct port_ops {
+	bool (*get_nim_present)(struct adapter_info_s *p, int port);
+
 	/*
 	 * port:s link mode
 	 */
@@ -60,6 +62,11 @@ struct port_ops {
 
 	uint32_t (*get_link_speed_capabilities)(struct adapter_info_s *p, int port);
 
+	/*
+	 * port: nim capabilities
+	 */
+	nim_i2c_ctx_t (*get_nim_capabilities)(struct adapter_info_s *p, int port);
+
 	/*
 	 * port: tx power
 	 */
Signature · 1 line
2.45.0
#210 lore raw

PATCH v9 18/21 net/ntnic: add QSFP support

In reply to Serhii Iliushyk

Includes support for QSFP and QSFP+.

---
 drivers/net/ntnic/include/ntnic_nim.h         |  10 +
 .../link_mgmt/link_100g/nt4ga_link_100g.c     |  12 +-
 drivers/net/ntnic/nim/i2c_nim.c               | 310 +++++++++++++++++-
 drivers/net/ntnic/nim/i2c_nim.h               |  14 +-
 drivers/net/ntnic/nim/nim_defines.h           |   3 +
 drivers/net/ntnic/nim/qsfp_registers.h        |  43 +++
 6 files changed, 389 insertions(+), 3 deletions(-)
 create mode 100644 drivers/net/ntnic/nim/qsfp_registers.h
drivers/net/ntnic/include/ntnic_nim.h +10 -0
index fd4a915811..216930af76 100644
@@ -15,6 +15,8 @@ typedef enum i2c_type {
 enum nt_port_type_e {
 	NT_PORT_TYPE_NOT_AVAILABLE = 0,	/* The NIM/port type is not available (unknown) */
 	NT_PORT_TYPE_NOT_RECOGNISED,	/* The NIM/port type not recognized */
+	NT_PORT_TYPE_QSFP_PLUS_NOT_PRESENT,	/* QSFP type but slot is empty */
+	NT_PORT_TYPE_QSFP_PLUS,	/* QSFP type */
 };
 
 typedef enum nt_port_type_e nt_port_type_t, *nt_port_type_p;
@@ -51,6 +53,14 @@ typedef struct nim_i2c_ctx {
 	bool tx_disable;
 	bool dmi_supp;
 
+	union {
+		struct {
+			bool rx_only;
+			union {
+			} specific_u;
+		} qsfp;
+
+	} specific_u;
 } nim_i2c_ctx_t, *nim_i2c_ctx_p;
 
 struct nim_sensor_group {
drivers/net/ntnic/link_mgmt/link_100g/nt4ga_link_100g.c +11 -1
index 4a8d28af9c..69d0a5d24a 100644
@@ -18,6 +18,7 @@ static int _create_nim(adapter_info_t *drv, int port)
 	int res = 0;
 	const uint8_t valid_nim_id = 17U;
 	nim_i2c_ctx_t *nim_ctx;
+	sfp_nim_state_t nim;
 	nt4ga_link_t *link_info = &drv->nt4ga_link;
 
 	assert(port >= 0 && port < NUM_ADAPTER_PORTS_MAX);
@@ -31,11 +32,20 @@ static int _create_nim(adapter_info_t *drv, int port)
 	 */
 	nt_os_wait_usec(1000000);	/* pause 1.0s */
 
-	res = construct_and_preinit_nim(nim_ctx);
+	res = construct_and_preinit_nim(nim_ctx, NULL);
 
 	if (res)
 		return res;
 
+	res = nim_state_build(nim_ctx, &nim);
+
+	if (res)
+		return res;
+
+	NT_LOG(DBG, NTHW, "%s: NIM id = %u (%s), br = %u, vendor = '%s', pn = '%s', sn='%s'\n",
+		drv->mp_port_id_str[port], nim_ctx->nim_id, nim_id_to_text(nim_ctx->nim_id), nim.br,
+		nim_ctx->vendor_name, nim_ctx->prod_no, nim_ctx->serial_no);
+
 	/*
 	 * Does the driver support the NIM module type?
 	 */
drivers/net/ntnic/nim/i2c_nim.c +309 -1

347 lines not on this page · raw message

drivers/net/ntnic/nim/i2c_nim.h +13 -1
index e89ae47835..edb6dcf1b6 100644
@@ -8,17 +8,29 @@
 
 #include "ntnic_nim.h"
 
+typedef struct sfp_nim_state {
+	uint8_t br;	/* bit rate, units of 100 MBits/sec */
+} sfp_nim_state_t, *sfp_nim_state_p;
+
+/*
+ * Builds an nim state for the port implied by `ctx`, returns zero
+ * if successful, and non-zero otherwise. SFP and QSFP nims are supported
+ */
+int nim_state_build(nim_i2c_ctx_t *ctx, sfp_nim_state_t *state);
+
 /*
  * Returns a type name such as "SFP/SFP+" for a given NIM type identifier,
  * or the string "ILLEGAL!".
  */
 const char *nim_id_to_text(uint8_t nim_id);
 
+int nim_qsfp_plus_nim_set_tx_laser_disable(nim_i2c_ctx_t *ctx, bool disable, int lane_idx);
+
 /*
  * This function tries to classify NIM based on it's ID and some register reads
  * and collects information into ctx structure. The @extra parameter could contain
  * the initialization argument for specific type of NIMS.
  */
-int construct_and_preinit_nim(nim_i2c_ctx_p ctx);
+int construct_and_preinit_nim(nim_i2c_ctx_p ctx, void *extra);
 
 #endif	/* I2C_NIM_H_ */
drivers/net/ntnic/nim/nim_defines.h +3 -0
index 9ba861bb4f..e5a033a3d4 100644
@@ -7,6 +7,7 @@
 #define NIM_DEFINES_H_
 
 #define NIM_IDENTIFIER_ADDR 0	/* 1 byte */
+#define QSFP_EXTENDED_IDENTIFIER 129
 
 /* I2C addresses */
 #define NIM_I2C_0XA0 0xA0	/* Basic I2C address */
@@ -23,6 +24,8 @@ typedef enum {
 
 enum nt_nim_identifier_e {
 	NT_NIM_UNKNOWN = 0x00,	/* Nim type is unknown */
+	NT_NIM_QSFP = 0x0C,	/* Nim type = QSFP */
+	NT_NIM_QSFP_PLUS = 0x0D,/* Nim type = QSFP+ */
 };
 typedef enum nt_nim_identifier_e nt_nim_identifier_t;
 
drivers/net/ntnic/nim/qsfp_registers.h new file +43 -0

43 lines not on this page · raw message

Signature · 1 line
2.45.0
#211 lore raw

PATCH v9 19/21 net/ntnic: add QSFP28 support

In reply to Serhii Iliushyk

Includes support for QSFP28

---
 drivers/net/ntnic/include/ntnic_nim.h    |  21 ++
 drivers/net/ntnic/link_mgmt/nt4ga_link.c |  25 +++
 drivers/net/ntnic/nim/i2c_nim.c          | 267 ++++++++++++++++++++++-
 drivers/net/ntnic/nim/nim_defines.h      |   1 +
 4 files changed, 313 insertions(+), 1 deletion(-)
drivers/net/ntnic/include/ntnic_nim.h +21 -0
index 216930af76..58daa8435f 100644
@@ -17,6 +17,19 @@ enum nt_port_type_e {
 	NT_PORT_TYPE_NOT_RECOGNISED,	/* The NIM/port type not recognized */
 	NT_PORT_TYPE_QSFP_PLUS_NOT_PRESENT,	/* QSFP type but slot is empty */
 	NT_PORT_TYPE_QSFP_PLUS,	/* QSFP type */
+	NT_PORT_TYPE_QSFP28_NOT_PRESENT,/* QSFP28 type but slot is empty */
+	NT_PORT_TYPE_QSFP28,	/* QSFP28 type */
+	NT_PORT_TYPE_QSFP28_SR4,/* QSFP28-SR4 type */
+	NT_PORT_TYPE_QSFP28_LR4,/* QSFP28-LR4 type */
+	NT_PORT_TYPE_QSFP28_CR_CA_L,	/* QSFP28-CR-CA-L type */
+	NT_PORT_TYPE_QSFP28_CR_CA_S,	/* QSFP28-CR-CA-S type */
+	NT_PORT_TYPE_QSFP28_CR_CA_N,	/* QSFP28-CR-CA-N type */
+	/* QSFP28-FR type. Uses PAM4 modulation on one lane only */
+	NT_PORT_TYPE_QSFP28_FR,
+	/* QSFP28-DR type. Uses PAM4 modulation on one lane only */
+	NT_PORT_TYPE_QSFP28_DR,
+	/* QSFP28-LR type. Uses PAM4 modulation on one lane only */
+	NT_PORT_TYPE_QSFP28_LR,
 };
 
 typedef enum nt_port_type_e nt_port_type_t, *nt_port_type_p;
@@ -56,7 +69,15 @@ typedef struct nim_i2c_ctx {
 	union {
 		struct {
 			bool rx_only;
+			bool qsfp28;
 			union {
+				struct {
+					uint8_t rev_compliance;
+					bool media_side_fec_ctrl;
+					bool host_side_fec_ctrl;
+					bool media_side_fec_ena;
+					bool host_side_fec_ena;
+				} qsfp28;
 			} specific_u;
 		} qsfp;
 
drivers/net/ntnic/link_mgmt/nt4ga_link.c +25 -0
index bc362776fc..4dc1c3d467 100644
@@ -140,6 +140,26 @@ static uint32_t nt4ga_port_get_loopback_mode(struct adapter_info_s *p, int port)
 	return p_link->port_action[port].port_lpbk_mode;
 }
 
+/*
+ * port: tx power
+ */
+static int nt4ga_port_tx_power(struct adapter_info_s *p, int port, bool disable)
+{
+	nt4ga_link_t *link_info = &p->nt4ga_link;
+
+	if (link_info->u.nim_ctx[port].port_type == NT_PORT_TYPE_QSFP28_SR4 ||
+		link_info->u.nim_ctx[port].port_type == NT_PORT_TYPE_QSFP28 ||
+		link_info->u.nim_ctx[port].port_type == NT_PORT_TYPE_QSFP28_LR4) {
+		nim_i2c_ctx_t *nim_ctx = &link_info->u.var100g.nim_ctx[port];
+
+		if (!nim_ctx->specific_u.qsfp.rx_only) {
+			if (nim_qsfp_plus_nim_set_tx_laser_disable(nim_ctx, disable, -1) != 0)
+				return 1;
+		}
+	}
+
+	return 0;
+}
 
 static const struct port_ops ops = {
 	.get_nim_present = nt4ga_port_get_nim_present,
@@ -181,6 +201,11 @@ static const struct port_ops ops = {
 	.get_loopback_mode = nt4ga_port_get_loopback_mode,
 
 	.get_link_speed_capabilities = nt4ga_port_get_link_speed_capabilities,
+
+	/*
+	 * port: tx power
+	 */
+	.tx_power = nt4ga_port_tx_power,
 };
 
 void port_init(void)
drivers/net/ntnic/nim/i2c_nim.c +266 -1

316 lines not on this page · raw message

drivers/net/ntnic/nim/nim_defines.h +1 -0
index e5a033a3d4..8e17b263c5 100644
@@ -26,6 +26,7 @@ enum nt_nim_identifier_e {
 	NT_NIM_UNKNOWN = 0x00,	/* Nim type is unknown */
 	NT_NIM_QSFP = 0x0C,	/* Nim type = QSFP */
 	NT_NIM_QSFP_PLUS = 0x0D,/* Nim type = QSFP+ */
+	NT_NIM_QSFP28 = 0x11,	/* Nim type = QSFP28 */
 };
 typedef enum nt_nim_identifier_e nt_nim_identifier_t;
 
Signature · 1 line
2.45.0
#212 lore raw

PATCH v9 20/21 net/ntnic: add GPIO communication for NIMs

In reply to Serhii Iliushyk

For NIM reset sequence GPIO communication is used. After this commit the NIMs supported by ntnic
is able to start up and be controlled fully by the adapter.

---
v5
* Fix Typo/Spelling

---
 drivers/net/ntnic/include/nt4ga_link.h        |   1 +
 .../link_mgmt/link_100g/nt4ga_link_100g.c     |  71 ++++++++-
 drivers/net/ntnic/meson.build                 |   1 +
 .../net/ntnic/nthw/core/include/nthw_core.h   |   1 +
 .../ntnic/nthw/core/include/nthw_gpio_phy.h   |  48 ++++++
 drivers/net/ntnic/nthw/core/nthw_gpio_phy.c   | 145 ++++++++++++++++++
 6 files changed, 263 insertions(+), 4 deletions(-)
 create mode 100644 drivers/net/ntnic/nthw/core/include/nthw_gpio_phy.h
 create mode 100644 drivers/net/ntnic/nthw/core/nthw_gpio_phy.c
drivers/net/ntnic/include/nt4ga_link.h +1 -0
index 0851057f81..5a16afea2a 100644
@@ -78,6 +78,7 @@ typedef struct port_action_s {
 
 typedef struct adapter_100g_s {
 	nim_i2c_ctx_t nim_ctx[NUM_ADAPTER_PORTS_MAX];	/* Should be the first field */
+	nthw_gpio_phy_t gpio_phy[NUM_ADAPTER_PORTS_MAX];
 } adapter_100g_t;
 
 typedef union adapter_var_s {
drivers/net/ntnic/link_mgmt/link_100g/nt4ga_link_100g.c +67 -4

145 lines not on this page · raw message

drivers/net/ntnic/meson.build +1 -0
index efea37e61a..e995ed75b0 100644
@@ -34,6 +34,7 @@ sources = files(
     'nthw/core/nt200a0x/reset/nthw_fpga_rst9563.c',
     'nthw/core/nt200a0x/reset/nthw_fpga_rst_nt200a0x.c',
     'nthw/core/nthw_fpga.c',
+    'nthw/core/nthw_gpio_phy.c',
     'nthw/core/nthw_hif.c',
     'nthw/core/nthw_i2cm.c',
     'nthw/core/nthw_iic.c',
drivers/net/ntnic/nthw/core/include/nthw_core.h +1 -0
index 8d9d78b86d..5cce56e13f 100644
@@ -17,6 +17,7 @@
 #include "nthw_iic.h"
 #include "nthw_i2cm.h"
 
+#include "nthw_gpio_phy.h"
 #include "nthw_sdc.h"
 
 #include "nthw_si5340.h"
drivers/net/ntnic/nthw/core/include/nthw_gpio_phy.h new file +48 -0

48 lines not on this page · raw message

drivers/net/ntnic/nthw/core/nthw_gpio_phy.c new file +145 -0

145 lines not on this page · raw message

Signature · 1 line
2.45.0
#213 lore raw

PATCH v9 21/21 net/ntnic: add physical layer control module

In reply to Serhii Iliushyk

Adds functionality to control the physical layer of the OSI model. This takes the form of the module
MAC PCS (Media Access Control Physical Coding Sublayer).
The functionality is used by the 100G link functionality to establish link.

---
 drivers/net/ntnic/include/nt4ga_link.h        |   1 +
 .../link_mgmt/link_100g/nt4ga_link_100g.c     | 393 +++++++-
 drivers/net/ntnic/meson.build                 |   1 +
 .../net/ntnic/nthw/core/include/nthw_core.h   |   1 +
 .../ntnic/nthw/core/include/nthw_mac_pcs.h    | 250 +++++
 drivers/net/ntnic/nthw/core/nthw_mac_pcs.c    | 894 ++++++++++++++++++
 6 files changed, 1538 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/ntnic/nthw/core/include/nthw_mac_pcs.h
 create mode 100644 drivers/net/ntnic/nthw/core/nthw_mac_pcs.c
drivers/net/ntnic/include/nt4ga_link.h +1 -0
index 5a16afea2a..8366484830 100644
@@ -78,6 +78,7 @@ typedef struct port_action_s {
 
 typedef struct adapter_100g_s {
 	nim_i2c_ctx_t nim_ctx[NUM_ADAPTER_PORTS_MAX];	/* Should be the first field */
+	nthw_mac_pcs_t mac_pcs100g[NUM_ADAPTER_PORTS_MAX];
 	nthw_gpio_phy_t gpio_phy[NUM_ADAPTER_PORTS_MAX];
 } adapter_100g_t;
 
drivers/net/ntnic/link_mgmt/link_100g/nt4ga_link_100g.c +391 -2

499 lines not on this page · raw message

drivers/net/ntnic/meson.build +1 -0
index e995ed75b0..0a6308f6bb 100644
@@ -38,6 +38,7 @@ sources = files(
     'nthw/core/nthw_hif.c',
     'nthw/core/nthw_i2cm.c',
     'nthw/core/nthw_iic.c',
+    'nthw/core/nthw_mac_pcs.c',
     'nthw/core/nthw_pcie3.c',
     'nthw/core/nthw_sdc.c',
     'nthw/core/nthw_si5340.c',
drivers/net/ntnic/nthw/core/include/nthw_core.h +1 -0
index 5cce56e13f..fe32891712 100644
@@ -18,6 +18,7 @@
 #include "nthw_i2cm.h"
 
 #include "nthw_gpio_phy.h"
+#include "nthw_mac_pcs.h"
 #include "nthw_sdc.h"
 
 #include "nthw_si5340.h"
drivers/net/ntnic/nthw/core/include/nthw_mac_pcs.h new file +250 -0

250 lines not on this page · raw message

drivers/net/ntnic/nthw/core/nthw_mac_pcs.c new file +894 -0

894 lines not on this page · raw message

Signature · 1 line
2.45.0
#214 lore raw

Re: [PATCH v9 21/21] net/ntnic: add physical layer control module

Quoted 20 lines · Serhii Iliushyk
drivers/net/ntnic/nthw/core/nthw_mac_pcs.c new file +19 -0
+		/* GTY_RX_BUF_STAT */
+#ifdef RXBUFSTAT
+		p->mp_reg_gty_rx_buf_stat =
+			nthw_module_get_register(p->mp_mod_mac_pcs, MAC_PCS_GTY_RX_BUF_STAT);
+		p->mp_field_gty_rx_buf_stat_rx_buf_stat0 =
+			nthw_register_get_field(p->mp_reg_gty_rx_buf_stat,
+				MAC_PCS_GTY_RX_BUF_STAT_RX_BUF_STAT_0);
+		p->mp_field_gty_rx_buf_stat_rx_buf_stat1 =
+			nthw_register_get_field(p->mp_reg_gty_rx_buf_stat,
+				MAC_PCS_GTY_RX_BUF_STAT_RX_BUF_STAT_1);
+		p->mp_field_gty_rx_buf_stat_rx_buf_stat2 =
+			nthw_register_get_field(p->mp_reg_gty_rx_buf_stat,
+				MAC_PCS_GTY_RX_BUF_STAT_RX_BUF_STAT_2);
+		p->mp_field_gty_rx_buf_stat_rx_buf_stat3 =
+			nthw_register_get_field(p->mp_reg_gty_rx_buf_stat,
+				MAC_PCS_GTY_RX_BUF_STAT_RX_BUF_STAT_3);
+		p->mp_field_gty_rx_buf_stat_rx_buf_stat_changed0 =
+			nthw_register_get_field(p->mp_reg_gty_rx_buf_stat,
+				MAC_PCS_GTY_RX_BUF_STAT_RX_BUF_STAT_CHANGED_0);

drivers/net/ntnic/nthw/core/nthw_mac_pcs.c line 290

Quoted 10 lines
drivers/net/ntnic/nthw/core/nthw_mac_pcs.c new file +10 -0
+		p->mp_field_gty_rx_buf_stat_rx_buf_stat_changed1 =
+			nthw_register_get_field(p->mp_reg_gty_rx_buf_stat,
+				MAC_PCS_GTY_RX_BUF_STAT_RX_BUF_STAT_CHANGED_1);
+		p->mp_field_gty_rx_buf_stat_rx_buf_stat_changed2 =
+			nthw_register_get_field(p->mp_reg_gty_rx_buf_stat,
+				MAC_PCS_GTY_RX_BUF_STAT_RX_BUF_STAT_CHANGED_2);
+		p->mp_field_gty_rx_buf_stat_rx_buf_stat_changed3 =
+			nthw_register_get_field(p->mp_reg_gty_rx_buf_stat,
+				MAC_PCS_GTY_RX_BUF_STAT_RX_BUF_STAT_CHANGED_3);
+#endif

These compile time macros require to update source code to change behavior, it is very easy to create test gaps by time. Better to convert it devargs to configure them dynamically if they are required, but as far as I can see these fields not used at, so perhaps above code can be removed, up to you.

#215 lore raw

Re: [PATCH v9 01/21] net/ntnic: add ethdev and makes PMD available

In reply to Serhii Iliushyk
Quoted 16 lines · Serhii Iliushyk

Add initial ntnic ethdev skeleton and register PCI probe functions Update documentation: Device description and feature list

---
v6
* Remove unused includes
* Remove EOF markers
* Remove unnecesarry commpiller flags
* Update documentation INI and RST files
* Remove uncovered features
* Add features according to DPDK reqirements
* Add link on NT200A02 description
* Rename res(short for result) to ret(short for return)
* Fix unnecessary set of the driver name
* The driver name is set by macro RTE_PMD_REGISTER_PCI

Quoted 9 lines

* Set sentinel value for PCI id_table
* NULL value can lead to the crush on function rte_pci_match
* Remove unnecessary comments
v7
* Move features list to the dedicated patches
* Update release note file
v9
* Marked driver features as Experimantal

Hi Serhii,

Driver is almost there, I put minor comments to a few patches, but mainly I recognized './devtools/check-meson.py' is giving some warnings, can you please check them?

Probably not required to reminder but instead of fixing meson issues as separate commit, please fix issues where they are introduced at first place.

#216 lore raw

PATCH v10 1/21 net/ntnic: add ethdev and makes PMD available

In reply to Serhii Iliushyk

Add initial ntnic ethdev skeleton and register PCI probe functions Update documentation: Device description and feature list

---
v6
* Remove unused includes
* Remove EOF markers
* Remove unnecesarry commpiller flags
* Update documentation INI and RST files
* Remove uncovered features
* Add features according to DPDK reqirements
* Add link on NT200A02 description
* Rename res(short for result) to ret(short for return)
* Fix unnecessary set of the driver name
* The driver name is set by macro RTE_PMD_REGISTER_PCI
* Set sentinel value for PCI id_table
* NULL value can lead to the crush on function rte_pci_match
* Remove unnecessary comments
v7
* Move features list to the dedicated patches
* Update release note file
v9
* Marked driver features as Experimantal
v10
* Use 8 spaces as indentation in meson

---
 .mailmap                               |  1 +
 MAINTAINERS                            |  7 ++++
 doc/guides/nics/features/ntnic.ini     |  8 +++++
 doc/guides/nics/index.rst              |  1 +
 doc/guides/nics/ntnic.rst              | 39 ++++++++++++++++++++
 doc/guides/rel_notes/release_24_07.rst | 10 ++++++
 drivers/net/meson.build                |  1 +
 drivers/net/ntnic/meson.build          | 18 ++++++++++
 drivers/net/ntnic/ntnic_ethdev.c       | 49 ++++++++++++++++++++++++++
 9 files changed, 134 insertions(+)
 create mode 100644 doc/guides/nics/features/ntnic.ini
 create mode 100644 doc/guides/nics/ntnic.rst
 create mode 100644 drivers/net/ntnic/meson.build
 create mode 100644 drivers/net/ntnic/ntnic_ethdev.c
.mailmap +1 -0
index 3f3f0442e5..ee567cf16e 100644
@@ -1321,6 +1321,7 @@ Sergey Madaminov <[email protected]>
 Sergey Mironov <[email protected]>
 Sergey Temerkhanov <[email protected]>
 Sergio Gonzalez Monroy <[email protected]>
+Serhii Iliushyk <[email protected]>
 Seth Arnold <[email protected]>
 Seth Howell <[email protected]>
 Shachar Beiser <[email protected]>
MAINTAINERS +7 -0
index c71ca2a28e..3e6bf0f8ae 100644
@@ -856,6 +856,13 @@ F: drivers/net/octeon_ep/
 F: doc/guides/nics/features/octeon_ep.ini
 F: doc/guides/nics/octeon_ep.rst
 
+Napatech ntnic - EXPERIMENTAL
+M: Christian Koue Muf <[email protected]>
+M: Serhii Iliushyk <[email protected]>
+F: drivers/net/ntnic/
+F: doc/guides/nics/ntnic.rst
+F: doc/guides/nics/features/ntnic.ini
+
 NVIDIA mlx4
 M: Matan Azrad <[email protected]>
 M: Viacheslav Ovsiienko <[email protected]>
doc/guides/nics/features/ntnic.ini new file +8 -0
new file mode 100644
index 0000000000..9ceb75a03b
@@ -0,0 +1,8 @@
+;
+; Supported features of the 'ntnic' network poll mode driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+[Features]
+Linux                = Y
+x86-64               = Y
doc/guides/nics/index.rst +1 -0
index 7bfcac880f..c14bc7988a 100644
@@ -53,6 +53,7 @@ Network Interface Controller Drivers
     nfb
     nfp
     ngbe
+    ntnic
     null
     octeon_ep
     octeontx
doc/guides/nics/ntnic.rst new file +39 -0
new file mode 100644
index 0000000000..b150fe1481
@@ -0,0 +1,39 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+    Copyright(c) 2024 Napatech A/S
+
+NTNIC Poll Mode Driver
+======================
+
+The NTNIC PMD provides poll mode driver support for Napatech smartNICs.
+
+
+Design
+------
+
+The NTNIC PMD is designed as a pure user-space driver, and requires no special
+Napatech kernel modules.
+
+The Napatech smartNIC presents one control PCI device (PF0). NTNIC PMD accesses
+smartNIC PF0 via vfio-pci kernel driver. Access to PF0 for all purposes is
+exclusive, so only one process should access it. The physical ports are located
+behind PF0 as DPDK port 0 and 1.
+
+
+Supported NICs
+--------------
+
+- NT200A02 2x100G SmartNIC
+
+    - FPGA ID 9563 (Inline Flow Management)
+
+All information about NT200A02 can be found by link below:
+https://www.napatech.com/products/nt200a02-smartnic-inline/
+
+Limitations
+~~~~~~~~~~~
+
+Kernel versions before 5.7 are not supported. Kernel version 5.7 added vfio-pci
+support for creating VFs from the PF which is required for the PMD to use
+vfio-pci on the PF. This support has been back-ported to older Linux
+distributions and they are also supported. If vfio-pci is not required kernel
+version 4.18 is supported.
doc/guides/rel_notes/release_24_07.rst +10 -0
index cd4219efd2..058609b0f3 100644
@@ -104,6 +104,16 @@ New Features
 
   * Updated base code with E610 device family support.
 
+* **Added Napatech ntnic net driver [EXPERIMENTAL].**
+
+  * Added the PMD driver for Napatech smartNIC
+
+    - Ability to initialize the NIC (NT200A02)
+    - Supporting only one FPGA firmware (9563.55.39)
+    - Ability to bring up the 100G link
+    - Supporting QSFP/QSFP+/QSFP28 NIM
+    - Does not support datapath
+
 * **Updated Marvell cnxk net driver.**
 
   * Added support disabling custom meta aura
drivers/net/meson.build +1 -0
index bd38b533c5..fb6d34b782 100644
@@ -45,6 +45,7 @@ drivers = [
         'nfb',
         'nfp',
         'ngbe',
+        'ntnic',
         'null',
         'octeontx',
         'octeon_ep',
drivers/net/ntnic/meson.build new file +18 -0
new file mode 100644
index 0000000000..368fffa81b
@@ -0,0 +1,18 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2020-2023 Napatech A/S
+
+if not is_linux or not dpdk_conf.has('RTE_ARCH_X86_64')
+        build = false
+        reason = 'only supported on x86_64 Linux'
+        subdir_done()
+endif
+
+# includes
+includes = [
+        include_directories('.'),
+]
+
+# all sources
+sources = files(
+        'ntnic_ethdev.c',
+)
drivers/net/ntnic/ntnic_ethdev.c new file +49 -0

49 lines not on this page · raw message

Signature · 1 line
2.43.0
#217 lore raw

PATCH v10 2/21 net/ntnic: add logging implementation

Adds ntnic specific implementation for logging. NT NIC uses this logging abstraction layer
to ensure that FPGA module implementations function both within and outside in DPDK environment

---
v6
* Logging header file was moved
* Default log type was set to NOTICE
v10
* Use 8 spaces as indentation in meson

---
 drivers/net/ntnic/meson.build    |  2 ++
 drivers/net/ntnic/ntlog/ntlog.c  | 53 ++++++++++++++++++++++++++++++++
 drivers/net/ntnic/ntlog/ntlog.h  | 49 +++++++++++++++++++++++++++++
 drivers/net/ntnic/ntnic_ethdev.c |  2 ++
 4 files changed, 106 insertions(+)
 create mode 100644 drivers/net/ntnic/ntlog/ntlog.c
 create mode 100644 drivers/net/ntnic/ntlog/ntlog.h
drivers/net/ntnic/meson.build +2 -0
index 368fffa81b..44d59c34ae 100644
@@ -10,9 +10,11 @@ endif
 # includes
 includes = [
         include_directories('.'),
+        include_directories('ntlog'),
 ]
 
 # all sources
 sources = files(
+        'ntlog/ntlog.c',
         'ntnic_ethdev.c',
 )
drivers/net/ntnic/ntlog/ntlog.c new file +53 -0

53 lines not on this page · raw message

drivers/net/ntnic/ntlog/ntlog.h new file +49 -0

49 lines not on this page · raw message

drivers/net/ntnic/ntnic_ethdev.c +2 -0
index 7e5231d2c1..68df9be2ff 100644
@@ -7,6 +7,8 @@
 #include <rte_bus_pci.h>
 #include <ethdev_pci.h>
 
+#include "ntlog.h"
+
 static const struct rte_pci_id nthw_pci_id_map[] = {
 	{
 		.vendor_id = 0,
Signature · 1 line
2.43.0
#218 lore raw

PATCH v10 3/21 net/ntnic: add minimal initialization for PCI device

In reply to Serhii Iliushyk

add implementation for probe/init and remove/deinit of the PCI device. proper device deinitialization will be added letter.

---
v6
* Add driver deinitialization
* Add API rte_eth_dev_probing_finish
* Add correct API for finishing probing the device
* Remove duplicated calling 'rte_eth_copy_pci_info()' via 'eth_dev_pci_specific_init()
* Remove unnecessary comments
* Remove duplicatet initialization of the numa_node v9
Fix logs

---
 drivers/net/ntnic/ntnic_ethdev.c | 82 +++++++++++++++++++++++++++++++-
 1 file changed, 81 insertions(+), 1 deletion(-)
drivers/net/ntnic/ntnic_ethdev.c +81 -1
index 68df9be2ff..d5983cd0f8 100644
@@ -3,6 +3,7 @@
  * Copyright(c) 2023 Napatech A/S
  */
 
+#include <rte_vfio.h>
 #include <rte_ethdev.h>
 #include <rte_bus_pci.h>
 #include <ethdev_pci.h>
@@ -16,14 +17,54 @@ static const struct rte_pci_id nthw_pci_id_map[] = {
 };
 
 static int
-nthw_pci_dev_init(struct rte_pci_device *pci_dev __rte_unused)
+nthw_pci_dev_init(struct rte_pci_device *pci_dev)
 {
+	uint32_t n_port_mask = -1;	/* All ports enabled by default */
+	int n_phy_ports;
+	NT_LOG_DBGX(DEBUG, NTNIC, "Dev %s PF #%i Init : %02x:%02x:%i\n", pci_dev->name,
+		pci_dev->addr.function, pci_dev->addr.bus, pci_dev->addr.devid,
+		pci_dev->addr.function);
+
+	n_phy_ports = 0;
+
+	for (int n_intf_no = 0; n_intf_no < n_phy_ports; n_intf_no++) {
+		struct rte_eth_dev *eth_dev = NULL;
+		char name[32];
+
+		if ((1 << n_intf_no) & ~n_port_mask)
+			continue;
+
+		snprintf(name, sizeof(name), "ntnic%d", n_intf_no);
+
+		eth_dev = rte_eth_dev_allocate(name);
+
+		if (!eth_dev) {
+			NT_LOG_DBGX(ERR, NTNIC, "%s: %s: error=%d\n",
+				(pci_dev->name[0] ? pci_dev->name : "NA"), name, -1);
+			return -1;
+		}
+
+		struct rte_eth_link pmd_link;
+		pmd_link.link_speed = RTE_ETH_SPEED_NUM_NONE;
+		pmd_link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX;
+		pmd_link.link_status = RTE_ETH_LINK_DOWN;
+		pmd_link.link_autoneg = RTE_ETH_LINK_AUTONEG;
+
+		eth_dev->device = &pci_dev->device;
+		eth_dev->data->dev_link = pmd_link;
+		eth_dev->dev_ops = NULL;
+
+		eth_dev_pci_specific_init(eth_dev, pci_dev);
+		rte_eth_dev_probing_finish(eth_dev);
+	}
+
 	return 0;
 }
 
 static int
 nthw_pci_dev_deinit(struct rte_eth_dev *eth_dev __rte_unused)
 {
+	NT_LOG_DBGX(DEBUG, NTNIC, "PCI device deinitialization\n");
 	return 0;
 }
 
@@ -32,13 +73,52 @@ nthw_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	struct rte_pci_device *pci_dev)
 {
 	int ret;
+
+	NT_LOG_DBGX(DEBUG, NTNIC, "pcidev: name: '%s'\n", pci_dev->name);
+	NT_LOG_DBGX(DEBUG, NTNIC, "devargs: name: '%s'\n", pci_dev->device.name);
+
+	if (pci_dev->device.devargs) {
+		NT_LOG_DBGX(DEBUG, NTNIC, "devargs: args: '%s'\n",
+			(pci_dev->device.devargs->args ? pci_dev->device.devargs->args : "NULL"));
+		NT_LOG_DBGX(DEBUG, NTNIC, "devargs: data: '%s'\n",
+			(pci_dev->device.devargs->data ? pci_dev->device.devargs->data : "NULL"));
+	}
+
+	const int n_rte_vfio_no_io_mmu_enabled = rte_vfio_noiommu_is_enabled();
+	NT_LOG(DBG, NTNIC, "vfio_no_iommu_enabled=%d\n", n_rte_vfio_no_io_mmu_enabled);
+
+	if (n_rte_vfio_no_io_mmu_enabled) {
+		NT_LOG(ERR, NTNIC, "vfio_no_iommu_enabled=%d: this PMD needs VFIO IOMMU\n",
+			n_rte_vfio_no_io_mmu_enabled);
+		return -1;
+	}
+
+	const enum rte_iova_mode n_rte_io_va_mode = rte_eal_iova_mode();
+	NT_LOG(DBG, NTNIC, "iova mode=%d\n", n_rte_io_va_mode);
+
+	NT_LOG(DBG, NTNIC,
+		"busid=" PCI_PRI_FMT
+		" pciid=%04x:%04x_%04x:%04x locstr=%s @ numanode=%d: drv=%s drvalias=%s\n",
+		pci_dev->addr.domain, pci_dev->addr.bus, pci_dev->addr.devid,
+		pci_dev->addr.function, pci_dev->id.vendor_id, pci_dev->id.device_id,
+		pci_dev->id.subsystem_vendor_id, pci_dev->id.subsystem_device_id,
+		pci_dev->name[0] ? pci_dev->name : "NA",
+		pci_dev->device.numa_node,
+		pci_dev->driver->driver.name ? pci_dev->driver->driver.name : "NA",
+		pci_dev->driver->driver.alias ? pci_dev->driver->driver.alias : "NA");
+
+
 	ret = nthw_pci_dev_init(pci_dev);
+
+	NT_LOG_DBGX(DEBUG, NTNIC, "leave: ret=%d\n", ret);
 	return ret;
 }
 
 static int
 nthw_pci_remove(struct rte_pci_device *pci_dev)
 {
+	NT_LOG_DBGX(DEBUG, NTNIC);
+
 	return rte_eth_dev_pci_generic_remove(pci_dev, nthw_pci_dev_deinit);
 }
 
Signature · 1 line
2.43.0
#219 lore raw

PATCH v10 4/21 net/ntnic: add utilities implementation

In reply to Serhii Iliushyk

Add ntnic utilities.

---
v6
* NT utils header file was moved
v10
* Remove "NT" from the commit message title
* Use 8 spaces as indentation in meson

---
 drivers/net/ntnic/meson.build      |  2 ++
 drivers/net/ntnic/ntnic_ethdev.c   |  2 ++
 drivers/net/ntnic/ntutil/nt_util.c | 33 +++++++++++++++++++++++
 drivers/net/ntnic/ntutil/nt_util.h | 43 ++++++++++++++++++++++++++++++
 4 files changed, 80 insertions(+)
 create mode 100644 drivers/net/ntnic/ntutil/nt_util.c
 create mode 100644 drivers/net/ntnic/ntutil/nt_util.h
drivers/net/ntnic/meson.build +2 -0
index 44d59c34ae..6f645320b9 100644
@@ -11,10 +11,12 @@ endif
 includes = [
         include_directories('.'),
         include_directories('ntlog'),
+        include_directories('ntutil'),
 ]
 
 # all sources
 sources = files(
         'ntlog/ntlog.c',
+        'ntutil/nt_util.c',
         'ntnic_ethdev.c',
 )
drivers/net/ntnic/ntnic_ethdev.c +2 -0
index d5983cd0f8..02b55e2780 100644
@@ -10,6 +10,8 @@
 
 #include "ntlog.h"
 
+#include "nt_util.h"
+
 static const struct rte_pci_id nthw_pci_id_map[] = {
 	{
 		.vendor_id = 0,
drivers/net/ntnic/ntutil/nt_util.c new file +33 -0
new file mode 100644
index 0000000000..5395bf6993
@@ -0,0 +1,33 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <inttypes.h>
+#include <assert.h>
+
+#include <rte_ethdev.h>
+#include <rte_malloc.h>
+
+#include "ntlog.h"
+#include "nt_util.h"
+
+/* uses usleep which schedules out the calling thread */
+void nt_os_wait_usec(int val)
+{
+	rte_delay_us_sleep(val);
+}
+
+uint64_t nt_os_get_time_monotonic_counter(void)
+{
+	return rte_get_timer_cycles();
+}
+
+/* Allocation size matching minimum alignment of specified size */
+uint64_t nt_util_align_size(uint64_t size)
+{
+	return 1 << rte_log2_u64(size);
+}
drivers/net/ntnic/ntutil/nt_util.h new file +43 -0

43 lines not on this page · raw message

Signature · 1 line
2.43.0
#220 lore raw

PATCH v10 5/21 net/ntnic: add VFIO module

In reply to Serhii Iliushyk

Adds VFIO functionality and the DMA it requires. The VFIO context is initialized during ntnic ethdev startup.

---
v10
* Use 8 spaces as indentation in meson

---
 drivers/net/ntnic/meson.build      |   1 +
 drivers/net/ntnic/ntnic_ethdev.c   |  22 +++
 drivers/net/ntnic/ntnic_vfio.c     | 235 +++++++++++++++++++++++++++++
 drivers/net/ntnic/ntnic_vfio.h     |  29 ++++
 drivers/net/ntnic/ntutil/nt_util.c |  65 ++++++++
 5 files changed, 352 insertions(+)
 create mode 100644 drivers/net/ntnic/ntnic_vfio.c
 create mode 100644 drivers/net/ntnic/ntnic_vfio.h
drivers/net/ntnic/meson.build +1 -0
index 6f645320b9..deeb0aca09 100644
@@ -18,5 +18,6 @@ includes = [
 sources = files(
         'ntlog/ntlog.c',
         'ntutil/nt_util.c',
+        'ntnic_vfio.c',
         'ntnic_ethdev.c',
 )
drivers/net/ntnic/ntnic_ethdev.c +22 -0
index 02b55e2780..b838eb4d7a 100644
@@ -8,10 +8,17 @@
 #include <rte_bus_pci.h>
 #include <ethdev_pci.h>
 
+#include <rte_eal.h>
+#include <rte_dev.h>
+#include <rte_vfio.h>
+
 #include "ntlog.h"
 
+#include "ntnic_vfio.h"
 #include "nt_util.h"
 
+#define EXCEPTION_PATH_HID 0
+
 static const struct rte_pci_id nthw_pci_id_map[] = {
 	{
 		.vendor_id = 0,
@@ -21,12 +28,24 @@ static const struct rte_pci_id nthw_pci_id_map[] = {
 static int
 nthw_pci_dev_init(struct rte_pci_device *pci_dev)
 {
+	nt_vfio_init();
+
 	uint32_t n_port_mask = -1;	/* All ports enabled by default */
 	int n_phy_ports;
 	NT_LOG_DBGX(DEBUG, NTNIC, "Dev %s PF #%i Init : %02x:%02x:%i\n", pci_dev->name,
 		pci_dev->addr.function, pci_dev->addr.bus, pci_dev->addr.devid,
 		pci_dev->addr.function);
 
+
+	/* Setup VFIO context */
+	int vfio = nt_vfio_setup(pci_dev);
+
+	if (vfio < 0) {
+		NT_LOG_DBGX(ERR, TNIC, "%s: vfio_setup error %d\n",
+			(pci_dev->name[0] ? pci_dev->name : "NA"), -1);
+		return -1;
+	}
+
 	n_phy_ports = 0;
 
 	for (int n_intf_no = 0; n_intf_no < n_phy_ports; n_intf_no++) {
@@ -67,6 +86,8 @@ static int
 nthw_pci_dev_deinit(struct rte_eth_dev *eth_dev __rte_unused)
 {
 	NT_LOG_DBGX(DEBUG, NTNIC, "PCI device deinitialization\n");
+
+	nt_vfio_remove(EXCEPTION_PATH_HID);
 	return 0;
 }
 
@@ -131,3 +152,4 @@ static struct rte_pci_driver rte_nthw_pmd = {
 };
 
 RTE_PMD_REGISTER_PCI(net_ntnic, rte_nthw_pmd);
+RTE_PMD_REGISTER_KMOD_DEP(net_ntnic, "* vfio-pci");
drivers/net/ntnic/ntnic_vfio.c new file +235 -0

235 lines not on this page · raw message

drivers/net/ntnic/ntnic_vfio.h new file +29 -0
new file mode 100644
index 0000000000..69fef7923d
@@ -0,0 +1,29 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef _NTNIC_VFIO_H_
+#define _NTNIC_VFIO_H_
+
+#include <rte_dev.h>
+#include <rte_bus_pci.h>
+#include <ethdev_pci.h>
+
+void
+nt_vfio_init(void);
+
+int
+nt_vfio_setup(struct rte_pci_device *dev);
+int
+nt_vfio_remove(int vf_num);
+
+int
+nt_vfio_dma_map(int vf_num, void *virt_addr, uint64_t *iova_addr, uint64_t size);
+int
+nt_vfio_dma_unmap(int vf_num, void *virt_addr, uint64_t iova_addr, uint64_t size);
+
+/* Find device (PF/VF) number from device address */
+int
+nt_vfio_vf_num(const struct rte_pci_device *dev);
+#endif	/* _NTNIC_VFIO_H_ */
drivers/net/ntnic/ntutil/nt_util.c +65 -0

74 lines not on this page · raw message

Signature · 1 line
2.43.0
#221 lore raw

PATCH v10 6/21 net/ntnic: add basic eth dev ops

In reply to Serhii Iliushyk

Adds support for eth_dev configure, start, stop, close, and infos_get. The internal structs of ntnic is also added and initialized.

---
v6
* Replace if_index with n_intf_no
* Unnecessry resources free was fixed
* Fix typo
* Useless vars were removed
v9
* Remove if_index usage to n_intf_no
* Make ops structure as const
* Fix logs
* Cleaup struct pmd_internals
* Move back dev init count increasing
v10
* Remove "to ntnic" from the commit message title
* Use 8 spaces as indentation in meson

---
 drivers/net/ntnic/include/ntdrv_4ga.h   |  17 ++
 drivers/net/ntnic/include/ntos_drv.h    |  30 ++++
 drivers/net/ntnic/include/ntos_system.h |  19 +++
 drivers/net/ntnic/meson.build           |   1 +
 drivers/net/ntnic/ntnic_ethdev.c        | 207 +++++++++++++++++++++++-
 5 files changed, 273 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/ntnic/include/ntdrv_4ga.h
 create mode 100644 drivers/net/ntnic/include/ntos_drv.h
 create mode 100644 drivers/net/ntnic/include/ntos_system.h
drivers/net/ntnic/include/ntdrv_4ga.h new file +17 -0
new file mode 100644
index 0000000000..bcb7ddc242
@@ -0,0 +1,17 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef __NTDRV_4GA_H__
+#define __NTDRV_4GA_H__
+
+
+typedef struct ntdrv_4ga_s {
+	uint32_t pciident;
+	char *p_drv_name;
+
+	volatile bool b_shutdown;
+} ntdrv_4ga_t;
+
+#endif	/* __NTDRV_4GA_H__ */
drivers/net/ntnic/include/ntos_drv.h new file +30 -0
new file mode 100644
index 0000000000..3c0a62cc85
@@ -0,0 +1,30 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef __NTOS_DRV_H__
+#define __NTOS_DRV_H__
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <inttypes.h>
+
+#include <rte_ether.h>
+
+#define NUM_MAC_ADDRS_PER_PORT (16U)
+#define NUM_MULTICAST_ADDRS_PER_PORT (16U)
+
+#define NUM_ADAPTER_MAX (8)
+#define NUM_ADAPTER_PORTS_MAX (128)
+
+struct pmd_internals {
+	const struct rte_pci_device *pci_dev;
+	char name[20];
+	int n_intf_no;
+	struct drv_s *p_drv;
+	struct pmd_internals *next;
+};
+
+#endif	/* __NTOS_DRV_H__ */
drivers/net/ntnic/include/ntos_system.h new file +19 -0
new file mode 100644
index 0000000000..01f1dc65f4
@@ -0,0 +1,19 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef __NTOS_SYSTEM_H__
+#define __NTOS_SYSTEM_H__
+
+#include "ntdrv_4ga.h"
+
+struct drv_s {
+	int adapter_no;
+	struct rte_pci_device *p_dev;
+	struct ntdrv_4ga_s ntdrv;
+
+	int n_eth_dev_init_count;
+};
+
+#endif	/* __NTOS_SYSTEM_H__ */
drivers/net/ntnic/meson.build +1 -0
index deeb0aca09..47c4b6357a 100644
@@ -10,6 +10,7 @@ endif
 # includes
 includes = [
         include_directories('.'),
+        include_directories('include'),
         include_directories('ntlog'),
         include_directories('ntutil'),
 ]
drivers/net/ntnic/ntnic_ethdev.c +206 -1

264 lines not on this page · raw message

Signature · 1 line
2.43.0
#222 lore raw

PATCH v10 7/21 net/ntnic: add core platform structures

In reply to Serhii Iliushyk

Adds many of the high level structures needed by the ntnic FPGA modules and adapter control.
This is considered the first part of the skeleton of ntnic FPGA support

---
v10
* Use 8 spaces as indentation in meson

---
 drivers/net/ntnic/include/ntos_drv.h       |  2 +
 drivers/net/ntnic/meson.build              |  2 +
 drivers/net/ntnic/nthw/nthw_drv.h          | 88 ++++++++++++++++++++++
 drivers/net/ntnic/nthw/nthw_platform.c     | 14 ++++
 drivers/net/ntnic/nthw/nthw_platform_drv.h | 21 ++++++
 5 files changed, 127 insertions(+)
 create mode 100644 drivers/net/ntnic/nthw/nthw_drv.h
 create mode 100644 drivers/net/ntnic/nthw/nthw_platform.c
 create mode 100644 drivers/net/ntnic/nthw/nthw_platform_drv.h
drivers/net/ntnic/include/ntos_drv.h +2 -0
index 3c0a62cc85..3f621143d9 100644
@@ -13,6 +13,8 @@
 
 #include <rte_ether.h>
 
+#include "nthw_drv.h"
+
 #define NUM_MAC_ADDRS_PER_PORT (16U)
 #define NUM_MULTICAST_ADDRS_PER_PORT (16U)
 
drivers/net/ntnic/meson.build +2 -0
index 47c4b6357a..04e31b4729 100644
@@ -13,10 +13,12 @@ includes = [
         include_directories('include'),
         include_directories('ntlog'),
         include_directories('ntutil'),
+        include_directories('nthw'),
 ]
 
 # all sources
 sources = files(
+        'nthw/nthw_platform.c',
         'ntlog/ntlog.c',
         'ntutil/nt_util.c',
         'ntnic_vfio.c',
drivers/net/ntnic/nthw/nthw_drv.h new file +88 -0

88 lines not on this page · raw message

drivers/net/ntnic/nthw/nthw_platform.c new file +14 -0
new file mode 100644
index 0000000000..181330dd37
@@ -0,0 +1,14 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#include "nthw_platform_drv.h"
+
+nthw_adapter_id_t nthw_platform_get_nthw_adapter_id(const uint16_t n_pci_device_id)
+{
+	switch (n_pci_device_id) {
+	default:
+		return NT_HW_ADAPTER_ID_UNKNOWN;
+	}
+}
drivers/net/ntnic/nthw/nthw_platform_drv.h new file +21 -0
new file mode 100644
index 0000000000..ab26d8149a
@@ -0,0 +1,21 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef __NTHW_PLATFORM_DRV_H__
+#define __NTHW_PLATFORM_DRV_H__
+
+#include <stdint.h>
+
+#define NT_HW_PCI_VENDOR_ID (0x18f4)
+
+enum nthw_adapter_id_e {
+	NT_HW_ADAPTER_ID_UNKNOWN = 0,
+};
+
+typedef enum nthw_adapter_id_e nthw_adapter_id_t;
+
+nthw_adapter_id_t nthw_platform_get_nthw_adapter_id(const uint16_t n_pci_device_id);
+
+#endif	/* __NTHW_PLATFORM_DRV_H__ */
Signature · 1 line
2.43.0