net/ntnic: Add registers for NapaTech SmartNiC
Subsystems (2)
PATCH v4 12/23 net/ntnic: add support of the NT200A0X smartNIC
In reply to Serhii IliushykAdd 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 | 12 +++++ 8 files changed, 116 insertions(+) create mode 100644 drivers/net/ntnic/nthw/core/nt200a0x/nthw_fpga_nt200a0x.c
drivers/net/ntnic/adapter/nt4ga_adapter.c +6 -0
@@ -129,6 +129,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
@@ -30,6 +30,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
@@ -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
@@ -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
@@ -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
@@ -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 +12 -0
@@ -24,6 +24,16 @@/* Global static variables: */ static rte_spinlock_t hwlock =RTE_SPINLOCK_INITIALIZER ; +/* +* The set of PCI devices this driver supports +*/ +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 */ +}; +/* * Store and get adapter info */
@@ -514,10 +524,12 @@ static struct rte_pci_driver rte_nthw_pmd = { .name = "net_ntnic", }, + .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
PATCH v4 13/23 net/ntnic: add reset module for the NT200A0X smartNIC
In reply to Serhii IliushykAdd API for reset NT200 and FW 9563
--- .../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
@@ -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
@@ -31,10 +31,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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v4 14/23 net/ntnic: add clock profiles for the NT200A0X smartNIC
In reply to Serhii IliushykAdd API for control clock NT200 and FW 9563
--- .../ntnic/include/clock_profiles_structs.h | 35 + .../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, 1159 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 +35 -0
@@ -0,0 +1,35 @@ +/* +* 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_ */ + +/* EOF */
drivers/net/ntnic/include/ntnic_nthw_fpga_rst_nt200a0x.h +1 -0
@@ -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
@@ -30,6 +30,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',
@@ -38,6 +39,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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -147,6 +147,29 @@ int nthw_fpga_silabs_detect(nthw_fpga_t *p_fpga, const int n_instance_no, constreturn 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
@@ -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
@@ -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
PATCH v4 15/23 net/ntnic: add MAC and packet features
In reply to Serhii IliushykAdd basic control for MAC addresses packets and queues
--- drivers/net/ntnic/include/ntos_drv.h | 15 +++++++++++ drivers/net/ntnic/ntnic_ethdev.c | 39 ++++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 2 deletions(-)
drivers/net/ntnic/include/ntos_drv.h +15 -0
@@ -26,9 +26,24 @@ struct pmd_internals {char name[20 ];int n_intf_no;int if_index; +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/ntnic_ethdev.c +37 -2
@@ -19,6 +19,9 @@#include "ntnic_mod_reg.h" #include "nt_util.h" +#define HW_MAX_PKT_LEN (10000) +#define MAX_MTU (HW_MAX_PKT_LEN - RTE_ETHER_HDR_LEN - RTE_ETHER_CRC_LEN) +#define EXCEPTION_PATH_HID 0/* Global static variables: */
@@ -108,6 +111,16 @@ eth_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *dev_info dev_info->if_index = internals->if_index; dev_info->driver_name = internals->name; + dev_info->max_mac_addrs =NUM_MAC_ADDRS_PER_PORT ; + dev_info->max_rx_pktlen =HW_MAX_PKT_LEN ; + dev_info->max_mtu =MAX_MTU ; + +if (internals->p_drv) { + dev_info->max_rx_queues = internals->nb_rx_queues; + dev_info->max_tx_queues = internals->nb_tx_queues; + + dev_info->min_rx_bufsize =64 ; + }return 0 ; }
@@ -142,8 +155,8 @@ 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->if_index); +NT_LOG_DBGX (DEBUG ,NTNIC ,"Port %u, %u, type %u\n" , + internals->n_intf_no, internals->if_index, internals->type); eth_dev->data->dev_link.link_status =RTE_ETH_LINK_DOWN ;return 0 ;
@@ -212,6 +225,9 @@ 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; +if (internals->type ==PORT_TYPE_VIRTUAL || internals->type ==PORT_TYPE_OVERRIDE ) +return 0 ; +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,
@@ -384,6 +400,12 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev) internals->pci_dev = pci_dev; internals->n_intf_no = n_intf_no; internals->if_index = n_intf_no; + internals->min_tx_pkt_size =64 ; + internals->max_tx_pkt_size =10000 ; + internals->type =PORT_TYPE_PHYSICAL ; + internals->vhid =-1 ; + internals->nb_rx_queues = nb_rx_queues; + internals->nb_tx_queues = nb_tx_queues;/* Setup queue_ids */
@@ -399,6 +421,18 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev) 0 /*port*/, nb_tx_queues); } +/* Set MAC address (but only if the MAC address is permitted) */ +if (n_intf_no < fpga_info->nthw_hw_info.vpd_info.mn_mac_addr_count) { +const uint64_t mac = + fpga_info->nthw_hw_info.vpd_info.mn_mac_addr_value + n_intf_no; + internals->eth_addrs[0 ].addr_bytes[0 ] = (mac >>40 ) &0xFFu ; + internals->eth_addrs[0 ].addr_bytes[1 ] = (mac >>32 ) &0xFFu ; + internals->eth_addrs[0 ].addr_bytes[2 ] = (mac >>24 ) &0xFFu ; + internals->eth_addrs[0 ].addr_bytes[3 ] = (mac >>16 ) &0xFFu ; + internals->eth_addrs[0 ].addr_bytes[4 ] = (mac >>8 ) &0xFFu ; + internals->eth_addrs[0 ].addr_bytes[5 ] = (mac >>0 ) &0xFFu ; + } + eth_dev =rte_eth_dev_allocate (name);/* TODO: name */ if (!eth_dev) {
@@ -413,6 +447,7 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev)/* connect structs */ internals->p_drv = p_drv; eth_dev->data->dev_private = internals; + eth_dev->data->mac_addrs = internals->eth_addrs; internals->port_id = eth_dev->data->port_id;
Signature · 1 line
2.45.0
PATCH v4 16/23 net/ntnic: add link management module
In reply to Serhii IliushykAdd link control API
--- 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/link_mgmt/nt4ga_link.c | 176 +++++++++++++++ drivers/net/ntnic/meson.build | 1 + drivers/net/ntnic/ntnic_ethdev.c | 242 +++++++++++++++++++++ drivers/net/ntnic/ntnic_mod_reg.c | 14 ++ drivers/net/ntnic/ntnic_mod_reg.h | 50 ++++- drivers/net/ntnic/ntutil/include/nt_util.h | 11 + drivers/net/ntnic/ntutil/nt_util.c | 131 +++++++++++ 10 files changed, 718 insertions(+), 2 deletions(-) create mode 100644 drivers/net/ntnic/include/nt4ga_link.h create mode 100644 drivers/net/ntnic/link_mgmt/nt4ga_link.c
drivers/net/ntnic/adapter/nt4ga_adapter.c +6 -0
@@ -126,8 +126,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
@@ -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/link_mgmt/nt4ga_link.c new file +176 -0
176 lines not on this page · raw message
drivers/net/ntnic/meson.build +1 -0
@@ -27,6 +27,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 +242 -0
311 lines not on this page · raw message
drivers/net/ntnic/ntnic_mod_reg.c +14 -0
@@ -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/include/nt_util.h +11 -0
@@ -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 */
drivers/net/ntnic/ntutil/nt_util.c +131 -0
134 lines not on this page · raw message
Signature · 1 line
2.45.0
PATCH v4 17/23 net/ntnic: add link 100G module
In reply to Serhii IliushykAdd ntnic 100G link support.
--- 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
@@ -127,6 +127,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++) {
@@ -137,8 +138,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
@@ -27,6 +27,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
@@ -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
@@ -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
PATCH v4 18/23 net/ntnic: add NIM module
In reply to Serhii IliushykAdd API for control NIM
--- 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
@@ -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 ;
@@ -124,6 +154,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;
@@ -173,6 +205,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
@@ -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
@@ -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
@@ -12,6 +12,7 @@#include "ntnic_mod_reg.h" #include "nt4ga_link.h" +#include "i2c_nim.h" /* * port: speed capabilites
@@ -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
@@ -22,6 +22,7 @@ includes = [ include_directories('nthw'), include_directories('nthw/supported'), include_directories('nthw/model'), + include_directories('nim/'), ] # all sources
@@ -29,6 +30,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',
@@ -38,6 +40,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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v4 19/23 net/ntnic: add QSFP support
In reply to Serhii IliushykIncludes 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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v4 20/23 net/ntnic: add QSFP28 support
In reply to Serhii IliushykIncludes 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
@@ -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
@@ -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
@@ -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
PATCH v4 21/23 net/ntnic: add GPIO PHY module
In reply to Serhii IliushykAdd GPIO API for comunication with NIM
--- 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
@@ -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
@@ -39,6 +39,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
@@ -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
PATCH v4 22/23 net/ntnic: add MAC PCS register interface module
In reply to Serhii IliushykAdd API for MAC and PCS(Physical Coding Sublayer)
--- 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
@@ -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
@@ -43,6 +43,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
@@ -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
PATCH v4 23/23 net/ntnic: add GMF (Generic MAC Feeder) module
In reply to Serhii IliushykAdd API for Generic MAC Feeder
--- .../link_mgmt/link_100g/nt4ga_link_100g.c | 8 ++ drivers/net/ntnic/meson.build | 1 + .../net/ntnic/nthw/core/include/nthw_core.h | 1 + .../net/ntnic/nthw/core/include/nthw_gmf.h | 64 +++++++++ drivers/net/ntnic/nthw/core/nthw_gmf.c | 133 ++++++++++++++++++ 5 files changed, 207 insertions(+) create mode 100644 drivers/net/ntnic/nthw/core/include/nthw_gmf.h create mode 100644 drivers/net/ntnic/nthw/core/nthw_gmf.c
drivers/net/ntnic/link_mgmt/link_100g/nt4ga_link_100g.c +8 -0
@@ -404,6 +404,14 @@ static int _port_init(adapter_info_t *drv, nthw_fpga_t *fpga, int port)_enable_tx (drv, mac_pcs);_reset_rx (drv, mac_pcs); +/* 2.2) Nt4gaPort::setup() */ +if (nthw_gmf_init (NULL , fpga, port) ==0 ) { +nthw_gmf_t gmf; + +if (nthw_gmf_init (&gmf, fpga, port) ==0 ) +nthw_gmf_set_enable (&gmf, true); + } +/* Phase 3. Link state machine steps */ /* 3.1) Create NIM, ::createNim() */
drivers/net/ntnic/meson.build +1 -0
@@ -39,6 +39,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_gmf.c', 'nthw/core/nthw_gpio_phy.c', 'nthw/core/nthw_hif.c', 'nthw/core/nthw_i2cm.c',
drivers/net/ntnic/nthw/core/include/nthw_core.h +1 -0
@@ -17,6 +17,7 @@#include "nthw_iic.h" #include "nthw_i2cm.h" +#include "nthw_gmf.h" #include "nthw_gpio_phy.h" #include "nthw_mac_pcs.h" #include "nthw_sdc.h"
drivers/net/ntnic/nthw/core/include/nthw_gmf.h new file +64 -0
64 lines not on this page · raw message
drivers/net/ntnic/nthw/core/nthw_gmf.c new file +133 -0
133 lines not on this page · raw message
Signature · 1 line
2.45.0
PATCH v5 1/23 net/ntnic: add ethdev and makes PMD available
In reply to Serhii IliushykAdd ntnic ethdev base implementation
--- .mailmap | 1 + MAINTAINERS | 7 ++++ doc/guides/nics/features/ntnic.ini | 9 +++++ doc/guides/nics/index.rst | 1 + doc/guides/nics/ntnic.rst | 43 ++++++++++++++++++++++++ drivers/net/meson.build | 1 + drivers/net/ntnic/meson.build | 24 ++++++++++++++ drivers/net/ntnic/ntnic_ethdev.c | 53 ++++++++++++++++++++++++++++++ 8 files changed, 139 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
@@ -1289,6 +1289,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
@@ -857,6 +857,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 +9 -0
@@ -0,0 +1,9 @@ +; +; Supported features of the 'ntnic' network poll mode driver. +; +; Refer to default.ini for the full list of available PMD features. +; +[Features] +Link status = Y +Linux = Y +x86-64 = Y
doc/guides/nics/index.rst +1 -0
@@ -53,6 +53,7 @@ Network Interface Controller Drivers nfb nfp ngbe + ntnic null octeon_ep octeontx
doc/guides/nics/ntnic.rst new file +43 -0
43 lines not on this page · raw message
drivers/net/meson.build +1 -0
@@ -45,6 +45,7 @@ drivers = [ 'nfb', 'nfp', 'ngbe', + 'ntnic', 'null', 'octeontx', 'octeon_ep',
drivers/net/ntnic/meson.build new file +24 -0
@@ -0,0 +1,24 @@ +# 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 + +# cflags +cflags += [ + '-std=c11', +] + +# includes +includes = [ + include_directories('.'), +] + +# all sources +sources = files( + 'ntnic_ethdev.c', +) +# END
drivers/net/ntnic/ntnic_ethdev.c new file +53 -0
53 lines not on this page · raw message
Signature · 1 line
2.45.0
PATCH v5 2/23 net/ntnic: add logging implementation
Add ntnic specific implementation for logging
--- drivers/net/ntnic/meson.build | 2 + drivers/net/ntnic/ntlog/include/ntlog.h | 49 +++++++++++++++++++++++ drivers/net/ntnic/ntlog/ntlog.c | 53 +++++++++++++++++++++++++ drivers/net/ntnic/ntnic_ethdev.c | 2 + 4 files changed, 106 insertions(+) create mode 100644 drivers/net/ntnic/ntlog/include/ntlog.h create mode 100644 drivers/net/ntnic/ntlog/ntlog.c
drivers/net/ntnic/meson.build +2 -0
@@ -15,10 +15,12 @@ cflags += [ # includes includes = [ include_directories('.'), + include_directories('ntlog/include'), ] # all sources sources = files( + 'ntlog/ntlog.c', 'ntnic_ethdev.c', ) # END
drivers/net/ntnic/ntlog/include/ntlog.h new file +49 -0
49 lines not on this page · raw message
drivers/net/ntnic/ntlog/ntlog.c new file +53 -0
53 lines not on this page · raw message
drivers/net/ntnic/ntnic_ethdev.c +2 -0
@@ -12,6 +12,8 @@#include <rte_bus_pci.h> #include <ethdev_pci.h> +#include "ntlog.h" +/* Global static variables: */ static int
Signature · 1 line
2.45.0
Re: [PATCH v5 02/23] net/ntnic: add logging implementation
Quoted 17 lines · Serhii Iliushyk
Add ntnic specific implementation for logging
Signed-off-by Serhii Iliushyk <[email protected]>--- drivers/net/ntnic/meson.build | 2 + drivers/net/ntnic/ntlog/include/ntlog.h | 49 +++++++++++++++++++++++ drivers/net/ntnic/ntlog/ntlog.c | 53 +++++++++++++++++++++++++ drivers/net/ntnic/ntnic_ethdev.c | 2 + 4 files changed, 106 insertions(+) create mode 100644 drivers/net/ntnic/ntlog/include/ntlog.h create mode 100644 drivers/net/ntnic/ntlog/ntlog.cdrivers/net/ntnic/meson.build +0
-0
drivers/net/ntnic/meson.build cflags += [ · line 19
Quoted 5 lines
drivers/net/ntnic/meson.build +1
-0@@ -15,10 +15,12 @@ cflags += [ # includes includes = [ include_directories('.'), + include_directories('ntlog/include'),
Why have 'include' folder under 'ntlog', but not put log related headers directly under 'ntlog' folder?
Quoted 80 lines
drivers/net/ntnic/meson.build +1
-0] # all sources sources = files( + 'ntlog/ntlog.c', 'ntnic_ethdev.c', )# END
drivers/net/ntnic/ntlog/include/ntlog.h new file +49
-0@@ -0,0 +1,49 @@ +/* +* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2023 Napatech A/S +*/ + +#ifndef NTOSS_SYSTEM_NTLOG_H +#define NTOSS_SYSTEM_NTLOG_H + +#include <stdarg.h> +#include <stdint.h> +#include <rte_log.h> + +extern int nt_logtype; + +#define NT_DRIVER_NAME "ntnic" + +#define NT_PMD_DRV_LOG (level, ...) \ + rte_log(RTE_LOG_ ## level, nt_logtype, \ + RTE_FMT(NT_DRIVER_NAME ": " \ + RTE_FMT_HEAD(__VA_ARGS__, ""), \ + RTE_FMT_TAIL(__VA_ARGS__, ""))) + + +#define NT_LOG_ERR (...) NT_PMD_DRV_LOG(ERR, __VA_ARGS__) +#define NT_LOG_WRN (...) NT_PMD_DRV_LOG(WARNING, __VA_ARGS__) +#define NT_LOG_INF (...) NT_PMD_DRV_LOG(INFO, __VA_ARGS__) +#define NT_LOG_DBG (...) NT_PMD_DRV_LOG(DEBUG, __VA_ARGS__) + +#define NT_LOG (level, module, ...) \ + NT_LOG_##level(#module ": " #level ":" __VA_ARGS__) + +#define NT_LOG_DBGX (level, module, ...) \ + rte_log(RTE_LOG_ ##level, nt_logtype, \ + RTE_FMT(NT_DRIVER_NAME #module ": [%s:%u]" \ + RTE_FMT_HEAD(__VA_ARGS__, ""), __func__, __LINE__, \ + RTE_FMT_TAIL(__VA_ARGS__, ""))) +/* +* nt log helper functions +* to create a string for NT_LOG usage to output a one-liner log +* to use when one single function call to NT_LOG is not optimal - that is +* you do not know the number of parameters at programming time or it is variable +*/ +char *ntlog_helper_str_alloc (const char *sinit); + +void ntlog_helper_str_add (char *s,const char *format, ...); + +void ntlog_helper_str_free (char *s); + +#endif /* NTOSS_SYSTEM_NTLOG_H */ drivers/net/ntnic/ntlog/ntlog.c new file +10
-0@@ -0,0 +1,53 @@ +/* +* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2023 Napatech A/S +*/ + +#include "ntlog.h" + +#include <stdarg.h> +#include <stddef.h> +#include <string.h>
drivers/net/ntnic/ntlog/ntlog.c line 20
Quoted 10 lines
drivers/net/ntnic/ntlog/ntlog.c new file +10
-0+#include <stdlib.h> +#include <stdbool.h> + +#include <rte_log.h> +#include <rte_string_fns.h> + +#define NTLOG_HELPER_STR_SIZE_MAX (1024) + +RTE_LOG_REGISTER_DEFAULT (nt_logtype,INFO ) +
Mostly default log type is 'NOTICE' to reduce the noise. Unless there is justification, can you please set default log to notice for consistency.
drivers/net/ntnic/ntlog/ntlog.c line 30
Quoted 11 lines
drivers/net/ntnic/ntlog/ntlog.c new file +10
-0+char *ntlog_helper_str_alloc (const char *sinit) +{ +char *s =malloc (NTLOG_HELPER_STR_SIZE_MAX ); + +if (!s) +return NULL ; + +if (sinit) +snprintf (s,NTLOG_HELPER_STR_SIZE_MAX ,"%s" , sinit); +
Should it put a space after 'sinit'?
One sample of usage is like:
ntlog_helper_str_alloc("Register::read");
ntlog_helper_str_add(tmp_string, "(Dev: %s, ....
Won't this cause an output like:
"Register::read(Dev: ..."
Is this what intended, or is "Register::read (Dev: ..." intended?
<...>
PATCH v5 3/23 net/ntnic: add minimal initialization for PCI device
In reply to Serhii Iliushykadd implementation for probe/init and remove/deinit of the PCI device
--- drivers/net/ntnic/ntnic_ethdev.c | 104 ++++++++++++++++++++++++++++++- 1 file changed, 103 insertions(+), 1 deletion(-)
drivers/net/ntnic/ntnic_ethdev.c +103 -1
@@ -17,14 +17,63 @@/* Global static variables: */ 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);/* TODO: 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->data->numa_node = pci_dev->device.numa_node; + eth_dev->dev_ops =NULL ; + eth_dev->state =RTE_ETH_DEV_ATTACHED ; + +rte_eth_copy_pci_info (eth_dev, pci_dev); +/* performs rte_eth_copy_pci_info() */ +eth_dev_pci_specific_init (eth_dev, pci_dev); + +/* increase initialized ethernet devices - PF */ + } +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 ; }
@@ -33,13 +82,65 @@ nthw_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, struct rte_pci_device *pci_dev) {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_has_pci =rte_eal_has_pci (); +NT_LOG (DBG ,NTNIC ,"has_pci=%d\n" , n_rte_has_pci); + +if (n_rte_has_pci ==0 ) { +NT_LOG (ERR ,NTNIC ,"has_pci=%d: this PMD needs hugepages\n" , n_rte_has_pci); +return -1 ; + } + +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); + +if (n_rte_io_va_mode !=RTE_IOVA_PA ) { +NT_LOG (WRN ,NTNIC ,"iova mode (%d) should be PA for performance reasons\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" ,/* locstr */ + 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); }
@@ -48,6 +149,7 @@ static struct rte_pci_driver rte_nthw_pmd = { .name = "net_ntnic", }, + .drv_flags = RTE_PCI_DRV_NEED_MAPPING, .probe = nthw_pci_probe, .remove = nthw_pci_remove, };
Signature · 1 line
2.45.0
Re: [PATCH v5 03/23] net/ntnic: add minimal initialization for PCI device
Quoted 27 lines · Serhii Iliushyk
add implementation for probe/init and remove/deinit of the PCI device
Signed-off-by Serhii Iliushyk <[email protected]>--- drivers/net/ntnic/ntnic_ethdev.c | 104 ++++++++++++++++++++++++++++++- 1 file changed, 103 insertions(+), 1 deletion(-)drivers/net/ntnic/ntnic_ethdev.c +10
-1@@ -17,14 +17,63 @@/* Global static variables: */ 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++) {
drivers/net/ntnic/ntnic_ethdev.c line 40
Quoted 10 lines
drivers/net/ntnic/ntnic_ethdev.c +9
-0+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);/* TODO: name */
Is this TODO still valid?
Quoted 11 lines
drivers/net/ntnic/ntnic_ethdev.c +11
-0+ +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); + +
drivers/net/ntnic/ntnic_ethdev.c line 72
Quoted 10 lines
drivers/net/ntnic/ntnic_ethdev.c +9
-0+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->data->numa_node = pci_dev->device.numa_node;
rte_eth_copy_pci_info() should be setting numa_node, no need to duplicate here.
Please consider using 'rte_eth_dev_create()' to help these kind of boilerplate initialization. I did same comment below.
drivers/net/ntnic/ntnic_ethdev.c line 72
Quoted 3 lines
drivers/net/ntnic/ntnic_ethdev.c +2
-0+ eth_dev->dev_ops =NULL ; + eth_dev->state =RTE_ETH_DEV_ATTACHED ;
Shouldn't need to set state directly, please call 'rte_eth_dev_probing_finish()' as a last thing in probe(). This call will set the state, also will do some other required work.
drivers/net/ntnic/ntnic_ethdev.c line 72
Quoted 5 lines
drivers/net/ntnic/ntnic_ethdev.c +4
-0+ +rte_eth_copy_pci_info (eth_dev, pci_dev); +/* performs rte_eth_copy_pci_info() */ +eth_dev_pci_specific_init (eth_dev, pci_dev);
As comment says, 'eth_dev_pci_specific_init()' calls the 'rte_eth_copy_pci_info()', so why calling it twice, can clean the init and remove the comment.
drivers/net/ntnic/ntnic_ethdev.c line 72
Quoted 3 lines
drivers/net/ntnic/ntnic_ethdev.c +2
-0+ +/* increase initialized ethernet devices - PF */
Is this comment valid here?
Quoted 23 lines
drivers/net/ntnic/ntnic_ethdev.c +10
-0+ } +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 ; }@@ -33,13 +82,65 @@ nthw_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, struct rte_pci_device *pci_dev) {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" ));
drivers/net/ntnic/ntnic_ethdev.c nthw_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, · line 101
Quoted 10 lines
drivers/net/ntnic/ntnic_ethdev.c +9
-0+NT_LOG_DBGX (DEBUG ,NTNIC ,"devargs: data: '%s'\n" , + (pci_dev->device.devargs->data ? pci_dev->device.devargs->data :"NULL" )); + } + +const int n_rte_has_pci =rte_eal_has_pci (); +NT_LOG (DBG ,NTNIC ,"has_pci=%d\n" , n_rte_has_pci); + +if (n_rte_has_pci ==0 ) { +NT_LOG (ERR ,NTNIC ,"has_pci=%d: this PMD needs hugepages\n" , n_rte_has_pci);
It is checking PCI bus, but log is about hugepages.
drivers/net/ntnic/ntnic_ethdev.c line 72
Quoted 3 lines
drivers/net/ntnic/ntnic_ethdev.c +2
-0+return -1 ; + }
What is the intention here for the 'n_rte_has_pci' check?
If pci bus is disabled, this probe call should not be called at all, in that manner this check is useless.
Quoted 8 lines
drivers/net/ntnic/ntnic_ethdev.c +8
-0+ +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 ;
drivers/net/ntnic/ntnic_ethdev.c nthw_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, · line 138
Quoted 10 lines
drivers/net/ntnic/ntnic_ethdev.c +9
-0+ } + +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); + +if (n_rte_io_va_mode !=RTE_IOVA_PA ) { +NT_LOG (WRN ,NTNIC ,"iova mode (%d) should be PA for performance reasons\n" , + n_rte_io_va_mode); + }
Is this comment valid?
Won't iommu be used for address translation both IOVA_VA and IOVA_PA mode? How much performance improvement we are talking about?
Quoted 5 lines
drivers/net/ntnic/ntnic_ethdev.c +5
-0+ + 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,
drivers/net/ntnic/ntnic_ethdev.c nthw_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, · line 138
Quoted 10 lines
drivers/net/ntnic/ntnic_ethdev.c +8
-0+ 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" ,/* locstr */ + 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);
Instead of calling 'nthw_pci_dev_init()' directly, you can use 'rte_eth_dev_create()' and pass 'nthw_pci_dev_init()' as paramter, this helps on some set of boilerplate code.
drivers/net/ntnic/ntnic_ethdev.c nthw_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, · line 138
Quoted 4 lines
drivers/net/ntnic/ntnic_ethdev.c +2
-0+ +NT_LOG_DBGX (DEBUG ,NTNIC ,"leave: res=%d\n" , res);return res;
Doesn't really matter but mostly 'ret' is used as short version of "return value", what 'res' is?
Quoted 18 lines
drivers/net/ntnic/ntnic_ethdev.c +3
-0}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); }@@ -48,6 +149,7 @@ static struct rte_pci_driver rte_nthw_pmd = { .name = "net_ntnic", }, + .drv_flags = RTE_PCI_DRV_NEED_MAPPING, .probe = nthw_pci_probe, .remove = nthw_pci_remove, };
Re: [PATCH v5 03/23] net/ntnic: add minimal initialization for PCI device
Hi Ferruh,
Please find our explanation for your comment according to device initialization by function nthw_pci_dev_init.
Our NIC handles multiple ports within the same PCI Bus Device Function (BDF) - hence, we need to create several ETH devices during the probe init. Allocation of multiple eth devices is handled inside the nthw_pci_dev_init() function.
It appears to be similar to what the Octeontx driver does.
We believe the current implementation fits better for our PMD, so we would like to keep it as is, unless it is a blocking requirement for upstreaming. Please let us know.
BR,
Serhii
From: Ferruh Yigit <[email protected]>
Date: Friday, 5 July 2024 at 01:44
To: Serhii Iliushyk <[email protected]>, [email protected] <[email protected]>
Cc: Mykola Kostenok <[email protected]>, Christian Koue Muf <[email protected]>, [email protected] <[email protected]>
Subject: Re: [PATCH v5 03/23] net/ntnic: add minimal initialization for PCI device
Quoted 27 lines · Serhii Iliushyk
add implementation for probe/init and remove/deinit of the PCI device
Signed-off-by Serhii Iliushyk <[email protected]>--- drivers/net/ntnic/ntnic_ethdev.c | 104 ++++++++++++++++++++++++++++++- 1 file changed, 103 insertions(+), 1 deletion(-)drivers/net/ntnic/ntnic_ethdev.c +10
-1@@ -17,14 +17,63 @@/* Global static variables: */ 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++) {
drivers/net/ntnic/ntnic_ethdev.c line 40
Quoted 10 lines
drivers/net/ntnic/ntnic_ethdev.c +9
-0+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);/* TODO: name */
Is this TODO still valid?
Quoted 11 lines
drivers/net/ntnic/ntnic_ethdev.c +11
-0+ +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); + +
drivers/net/ntnic/ntnic_ethdev.c line 72
Quoted 10 lines
drivers/net/ntnic/ntnic_ethdev.c +9
-0+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->data->numa_node = pci_dev->device.numa_node;
rte_eth_copy_pci_info() should be setting numa_node, no need to duplicate here.
Please consider using 'rte_eth_dev_create()' to help these kind of boilerplate initialization. I did same comment below.
drivers/net/ntnic/ntnic_ethdev.c line 72
Quoted 3 lines
drivers/net/ntnic/ntnic_ethdev.c +2
-0+ eth_dev->dev_ops =NULL ; + eth_dev->state =RTE_ETH_DEV_ATTACHED ;
Shouldn't need to set state directly, please call 'rte_eth_dev_probing_finish()' as a last thing in probe(). This call will set the state, also will do some other required work.
drivers/net/ntnic/ntnic_ethdev.c line 72
Quoted 5 lines
drivers/net/ntnic/ntnic_ethdev.c +4
-0+ +rte_eth_copy_pci_info (eth_dev, pci_dev); +/* performs rte_eth_copy_pci_info() */ +eth_dev_pci_specific_init (eth_dev, pci_dev);
As comment says, 'eth_dev_pci_specific_init()' calls the 'rte_eth_copy_pci_info()', so why calling it twice, can clean the init and remove the comment.
drivers/net/ntnic/ntnic_ethdev.c line 72
Quoted 3 lines
drivers/net/ntnic/ntnic_ethdev.c +2
-0+ +/* increase initialized ethernet devices - PF */
Is this comment valid here?
Quoted 23 lines
drivers/net/ntnic/ntnic_ethdev.c +10
-0+ } +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 ; }@@ -33,13 +82,65 @@ nthw_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, struct rte_pci_device *pci_dev) {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->https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fdevice.name&c=E,1,V5OBhPhfiNSro_oj2bitVYkKYAABsPx-MKLgmN0q8g6JbMwgnOO1gKkhj3c3IxCQvEgNbC8ofBuQUVC8VRFgpnK79cZnIRMu2iT6BvGGlWlO-BxzlAK2eTwkKk9z&typo=1); + + 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"));
drivers/net/ntnic/ntnic_ethdev.c nthw_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, · line 101
Quoted 10 lines
drivers/net/ntnic/ntnic_ethdev.c +9
-0+NT_LOG_DBGX (DEBUG ,NTNIC ,"devargs: data: '%s'\n" , + (pci_dev->device.devargs->data ? pci_dev->device.devargs->data :"NULL" )); + } + +const int n_rte_has_pci =rte_eal_has_pci (); +NT_LOG (DBG ,NTNIC ,"has_pci=%d\n" , n_rte_has_pci); + +if (n_rte_has_pci ==0 ) { +NT_LOG (ERR ,NTNIC ,"has_pci=%d: this PMD needs hugepages\n" , n_rte_has_pci);
It is checking PCI bus, but log is about hugepages.
drivers/net/ntnic/ntnic_ethdev.c line 72
Quoted 3 lines
drivers/net/ntnic/ntnic_ethdev.c +2
-0+return -1 ; + }
What is the intention here for the 'n_rte_has_pci' check?
If pci bus is disabled, this probe call should not be called at all, in that manner this check is useless.
Quoted 8 lines
drivers/net/ntnic/ntnic_ethdev.c +8
-0+ +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 ;
drivers/net/ntnic/ntnic_ethdev.c nthw_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, · line 138
Quoted 10 lines
drivers/net/ntnic/ntnic_ethdev.c +9
-0+ } + +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); + +if (n_rte_io_va_mode !=RTE_IOVA_PA ) { +NT_LOG (WRN ,NTNIC ,"iova mode (%d) should be PA for performance reasons\n" , + n_rte_io_va_mode); + }
Is this comment valid?
Won't iommu be used for address translation both IOVA_VA and IOVA_PA mode? How much performance improvement we are talking about?
Quoted 5 lines
drivers/net/ntnic/ntnic_ethdev.c +5
-0+ + 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,
drivers/net/ntnic/ntnic_ethdev.c nthw_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, · line 138
Quoted 10 lines
drivers/net/ntnic/ntnic_ethdev.c +8
-0+ 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", /* locstr */ + pci_dev->device.numa_node, + pci_dev->driver->https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fdriver.name&c=E,1,5_F-hniqJt0w3GPG-nclekQA5nc17FmonNihbX6JRyTd2j6RA7sGlIJ9gBTq_T3p01-6DsO244rVP-3PFWsjaqFJ44V77omLRmCrWio_VmtBudxV30mhcou9&typo=1 ? pci_dev->driver->https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fdriver.name&c=E,1,frkLGUymGHY5ydpNKtk3f74kNLD7KupomSqM7BLD7aOyg83VIXzNCZfCJI9PDNuIjnexaqLnATwKsfczOq1DvmsNBhMbEgTT0QrJ7RKHxIw,&typo=1 : "NA", + pci_dev->driver->driver.alias ? pci_dev->driver->driver.alias : "NA"); + + res =nthw_pci_dev_init (pci_dev);
Instead of calling 'nthw_pci_dev_init()' directly, you can use 'rte_eth_dev_create()' and pass 'nthw_pci_dev_init()' as paramter, this helps on some set of boilerplate code.
drivers/net/ntnic/ntnic_ethdev.c nthw_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, · line 138
Quoted 4 lines
drivers/net/ntnic/ntnic_ethdev.c +2
-0+ +NT_LOG_DBGX (DEBUG ,NTNIC ,"leave: res=%d\n" , res);return res;
Doesn't really matter but mostly 'ret' is used as short version of "return value", what 'res' is?
Quoted 18 lines
drivers/net/ntnic/ntnic_ethdev.c +3
-0}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); }@@ -48,6 +149,7 @@ static struct rte_pci_driver rte_nthw_pmd = { .name = "net_ntnic", }, + .drv_flags = RTE_PCI_DRV_NEED_MAPPING, .probe = nthw_pci_probe, .remove = nthw_pci_remove, };
Re: [PATCH v5 03/23] net/ntnic: add minimal initialization for PCI device
Quoted 11 lines · Serhii Iliushyk
Hi Ferruh,
Please find our explanation for your comment according to device initializationby function
nthw_pci_dev_init.Our NIC handles multiple ports within the same PCI Bus Device Function (BDF) - hence, we need to create several ETH devices during the probe init. Allocation of multiple eth devices is handled inside the
nthw_pci_dev_init()function.
It appears to be similar to what the Octeontx driver does.
Quoted 6 lines
We believe the current implementation fits better for our PMD, so we would like to keep it as is, unless it is a blocking requirement for upstreaming.
Please let us know.
Hi Serhii,
Please don't top post, it makes very hard to follow a discussion this way, instead prefered way is to response inline just below where your comment is valid.
Like below there are bunch of comment, I am not sure which one you are reffering.
But from context, I assume you refer to the one that suggests using 'rte_eth_dev_create()', firstly this is not hard requirement but suggestion to help you, so it is up to you.
But initialisation is wrapped in that function, so it is helpful to use that function to handle boilerplate code correct.
Current logic is:
``` probe() init() get n_phy_ports; foreach i in n_phy_ports // do ethdev allocation & initialization ```
I suggest it can be done as:
``` probe() get n_phy_ports; foreach i in n_phy_ports rte_eth_dev_create(pci_init, init) init() // only ethdev initialization // ethdev alloc and common init already done at this point ```
I may be missing some details, if above doesn't make sense or doesn't help you, feel free to ignore it.
But please be sure basic ethdev allocation and initialization is done properly, as far as I remember I had some questions around it, that is why suggested to use the wrapper.
Quoted 218 lines
*From: *Ferruh Yigit <[email protected]>
*Date: *Friday, 5 July 2024 at 01:44
*To: *Serhii Iliushyk <[email protected]>, [email protected] <[email protected]> *Cc: *Mykola Kostenok <[email protected]>, Christian Koue Muf <[email protected]>, [email protected] <[email protected]>
*Subject: *Re: [PATCH v5 03/23] net/ntnic: add minimal initialization for PCI deviceQuoted 27 lines · Serhii Iliushyk
add implementation for probe/init and remove/deinit of the PCI device
Signed-off-by Serhii Iliushyk <[email protected]>---
drivers/net/ntnic/ntnic_ethdev.c| 104 ++++++++++++++++++++++++++++++-1 file changed, 103 insertions(+), 1 deletion(-)drivers/net/ntnic/ntnic_ethdev.c +0
-0@@ -17,14 +17,63 @@ /* Global static variables: */
static intdrivers/net/ntnic/ntnic_ethdev.c +1
-1-nthw_pci_dev_init(struct rte_pci_device *pci_dev __rte_unused) +nthw_pci_dev_init(struct rte_pci_device *pci_dev){
+uint32_tn_port_mask= -1; /* All ports enabled by default */ + intn_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);drivers/net/ntnic/ntnic_ethdev.c +3
-0+ + n_phy_ports = 0; +drivers/net/ntnic/ntnic_ethdev.c line 39
Quoted 10 lines
drivers/net/ntnic/ntnic_ethdev.c +10
-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); /* TODO: name */Is this TODO still valid?
Quoted 11 lines
drivers/net/ntnic/ntnic_ethdev.c +10
-0+ + 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); +drivers/net/ntnic/ntnic_ethdev.c line 59
Quoted 10 lines
drivers/net/ntnic/ntnic_ethdev.c +10
-0+ + 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->data->numa_node = pci_dev->device.numa_node;
rte_eth_copy_pci_info()should be settingnuma_node, no need to duplicate here.Please consider using '
rte_eth_dev_create()' to help these kind of boilerplate initialization. I did same comment below.Quoted 3 lines
+
eth_dev->dev_ops= NULL;
+eth_dev->state=RTE_ETH_DEV_ATTACHED;Shouldn't need to set state directly, please call '
rte_eth_dev_probing_finish()' as a last thing inprobe(). This call will set the state, also will do some other required work.Quoted 5 lines
+
+rte_eth_copy_pci_info(eth_dev, pci_dev); + /* performsrte_eth_copy_pci_info()*/ +eth_dev_pci_specific_init(eth_dev, pci_dev);As comment says, '
eth_dev_pci_specific_init()' calls the 'rte_eth_copy_pci_info()', so why calling it twice, can clean the init and remove the comment.Quoted 3 lines
+
+ /* increase initialized ethernet devices - PF */Is this comment valid here?
Quoted 23 lines
+ }
+
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;
}drivers/net/ntnic/ntnic_ethdev.c +7
-0@@ -33,13 +82,65 @@ nthw_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, struct rte_pci_device *pci_dev) { 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->https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fdevice.name&c=E,1,V5OBhPhfiNSro_oj2bitVYkKYAABsPx-MKLgmN0q8g6JbMwgnOO1gKkhj3c3IxCQvEgNbC8ofBuQUVC8VRFgpnK79cZnIRMu2iT6BvGGlWlO-BxzlAK2eTwkKk9z&typo=1); + + 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"));drivers/net/ntnic/ntnic_ethdev.c nthw_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, · line 101
Quoted 10 lines
drivers/net/ntnic/ntnic_ethdev.c +9
-0+ NT_LOG_DBGX(DEBUG, NTNIC, "devargs: data: '%s'\n", + (pci_dev->device.devargs->data ? pci_dev->device.devargs->data : "NULL")); + } + + const int n_rte_has_pci = rte_eal_has_pci(); + NT_LOG(DBG, NTNIC, "has_pci=%d\n", n_rte_has_pci); + + if (n_rte_has_pci == 0) { + NT_LOG(ERR, NTNIC, "has_pci=%d: this PMD needs hugepages\n", n_rte_has_pci);It is checking PCI bus, but log is about hugepages.
drivers/net/ntnic/ntnic_ethdev.c line 72
Quoted 3 lines
drivers/net/ntnic/ntnic_ethdev.c +2
-0+ return -1; + }What is the intention here for the '
n_rte_has_pci' check?
If pci bus is disabled, this probe call should not be called at all, in that manner this check is useless.Quoted 8 lines
drivers/net/ntnic/ntnic_ethdev.c +8
-0+ + 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;drivers/net/ntnic/ntnic_ethdev.c nthw_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, · line 138
Quoted 10 lines
drivers/net/ntnic/ntnic_ethdev.c +9
-0+ } + + 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); + + if (n_rte_io_va_mode != RTE_IOVA_PA) { + NT_LOG(WRN, NTNIC, "iova mode (%d) should be PA for performance reasons\n", + n_rte_io_va_mode); + }Is this comment valid?
Won't iommu be used for address translation bothIOVA_VAandIOVA_PAmode? How much performance improvement we are talking about?Quoted 5 lines
drivers/net/ntnic/ntnic_ethdev.c +5
-0+ + 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,drivers/net/ntnic/ntnic_ethdev.c nthw_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, · line 138
Quoted 10 lines
drivers/net/ntnic/ntnic_ethdev.c +8
-0+ 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", /* locstr */ + pci_dev->device.numa_node, + pci_dev->driver->https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fdriver.name&c=E,1,5_F-hniqJt0w3GPG-nclekQA5nc17FmonNihbX6JRyTd2j6RA7sGlIJ9gBTq_T3p01-6DsO244rVP-3PFWsjaqFJ44V77omLRmCrWio_VmtBudxV30mhcou9&typo=1 ? pci_dev->driver->https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fdriver.name&c=E,1,frkLGUymGHY5ydpNKtk3f74kNLD7KupomSqM7BLD7aOyg83VIXzNCZfCJI9PDNuIjnexaqLnATwKsfczOq1DvmsNBhMbEgTT0QrJ7RKHxIw,&typo=1 : "NA", + pci_dev->driver->driver.alias ? pci_dev->driver->driver.alias : "NA"); + + res = nthw_pci_dev_init(pci_dev);Instead of calling '
nthw_pci_dev_init()' directly, you can use 'rte_eth_dev_create()' and pass 'nthw_pci_dev_init()' as paramter, this helps on some set of boilerplate code.drivers/net/ntnic/ntnic_ethdev.c nthw_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, · line 138
Quoted 4 lines
drivers/net/ntnic/ntnic_ethdev.c +2
-0+ + NT_LOG_DBGX(DEBUG, NTNIC, "leave: res=%d\n", res); return res;Doesn't really matter but mostly 'ret' is used as short version of "return value", what 'res' is?
Quoted 18 lines
drivers/net/ntnic/ntnic_ethdev.c +0
-0}
static int
nthw_pci_remove(struct rte_pci_device *pci_dev)
{
+NT_LOG_DBGX(DEBUG, NTNIC);
+
returnrte_eth_dev_pci_generic_remove(pci_dev, nthw_pci_dev_deinit); }drivers/net/ntnic/ntnic_ethdev.c +0
-0@@ -48,6 +149,7 @@ static struct rte_pci_driver rte_nthw_pmd = { .name = "net_ntnic", },
+ .drv_flags =RTE_PCI_DRV_NEED_MAPPING,
.probe =nthw_pci_probe,
.remove =nthw_pci_remove,
};
PATCH v5 4/23 net/ntnic: add NT utilities implementation
In reply to Serhii IliushykAdd ntnic utilities.
--- drivers/net/ntnic/meson.build | 2 ++ drivers/net/ntnic/ntnic_ethdev.c | 2 ++ drivers/net/ntnic/ntutil/include/nt_util.h | 28 ++++++++++++++++++ drivers/net/ntnic/ntutil/nt_util.c | 33 ++++++++++++++++++++++ 4 files changed, 65 insertions(+) create mode 100644 drivers/net/ntnic/ntutil/include/nt_util.h create mode 100644 drivers/net/ntnic/ntutil/nt_util.c
drivers/net/ntnic/meson.build +2 -0
@@ -16,11 +16,13 @@ cflags += [ includes = [ include_directories('.'), include_directories('ntlog/include'), + include_directories('ntutil/include'), ] # all sources sources = files( 'ntlog/ntlog.c', + 'ntutil/nt_util.c', 'ntnic_ethdev.c', ) # END
drivers/net/ntnic/ntnic_ethdev.c +2 -0
@@ -14,6 +14,8 @@#include "ntlog.h" +#include "nt_util.h" +/* Global static variables: */ static int
drivers/net/ntnic/ntutil/include/nt_util.h new file +28 -0
@@ -0,0 +1,28 @@ +/* +* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2023 Napatech A/S +*/ + +#ifndef NTOSS_SYSTEM_NT_UTIL_H +#define NTOSS_SYSTEM_NT_UTIL_H + +#include <stdint.h> + +#ifndef ARRAY_SIZE +#define ARRAY_SIZE (arr) RTE_DIM(arr) +#endif + +#define PCIIDENT_TO_DOMAIN (pci_ident) ((uint16_t)(((unsigned int)(pci_ident) >> 16) & 0xFFFFU)) +#define PCIIDENT_TO_BUSNR (pci_ident) ((uint8_t)(((unsigned int)(pci_ident) >> 8) & 0xFFU)) +#define PCIIDENT_TO_DEVNR (pci_ident) ((uint8_t)(((unsigned int)(pci_ident) >> 3) & 0x1FU)) +#define PCIIDENT_TO_FUNCNR (pci_ident) ((uint8_t)(((unsigned int)(pci_ident) >> 0) & 0x7U)) +#define PCIIDENT_PRINT_STR "%04x:%02x:%02x.%x" +#define BDF_TO_PCIIDENT (dom, bus, dev, fnc) (((dom) << 16) | ((bus) << 8) | ((dev) << 3) | (fnc)) + +uint64_t nt_os_get_time_monotonic_counter (void ); +void nt_os_wait_usec (int val); + +uint64_t nt_util_align_size (uint64_t size); + + +#endif /* NTOSS_SYSTEM_NT_UTIL_H */
drivers/net/ntnic/ntutil/nt_util.c new file +33 -0
@@ -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); +}
Signature · 1 line
2.45.0
Re: [PATCH v5 04/23] net/ntnic: add NT utilities implementation
Quoted 17 lines · Serhii Iliushyk
Add ntnic utilities.
Signed-off-by Serhii Iliushyk <[email protected]>--- drivers/net/ntnic/meson.build | 2 ++ drivers/net/ntnic/ntnic_ethdev.c | 2 ++ drivers/net/ntnic/ntutil/include/nt_util.h | 28 ++++++++++++++++++ drivers/net/ntnic/ntutil/nt_util.c | 33 ++++++++++++++++++++++ 4 files changed, 65 insertions(+) create mode 100644 drivers/net/ntnic/ntutil/include/nt_util.h create mode 100644 drivers/net/ntnic/ntutil/nt_util.cdrivers/net/ntnic/meson.build +0
-0
drivers/net/ntnic/meson.build cflags += [ · line 20
Quoted 5 lines
drivers/net/ntnic/meson.build +1
-0@@ -16,11 +16,13 @@ cflags += [ includes = [ include_directories('.'), include_directories('ntlog/include'), + include_directories('ntutil/include'),
Similar to previous patch comment, why 'ntutil/include' folder instead of putting header directly under 'ntutil' folder. As it is single header file, it won't be noisy to keep both header and .c file under same folder.
PATCH v5 5/23 net/ntnic: add VFIO module
In reply to Serhii IliushykAdd ntnic VFIO functionality.
--- drivers/net/ntnic/meson.build | 1 + drivers/net/ntnic/ntnic_ethdev.c | 20 +- drivers/net/ntnic/ntnic_vfio.c | 235 +++++++++++++++++++++ drivers/net/ntnic/ntnic_vfio.h | 29 +++ drivers/net/ntnic/ntutil/include/nt_util.h | 15 ++ drivers/net/ntnic/ntutil/nt_util.c | 65 ++++++ 6 files changed, 362 insertions(+), 3 deletions(-) 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
@@ -23,6 +23,7 @@ includes = [ sources = files( 'ntlog/ntlog.c', 'ntutil/nt_util.c', + 'ntnic_vfio.c', 'ntnic_ethdev.c', ) # END
drivers/net/ntnic/ntnic_ethdev.c +17 -3
@@ -8,25 +8,37 @@#include <rte_eal.h> #include <rte_dev.h> #include <rte_vfio.h> -#include <rte_ethdev.h> -#include <rte_bus_pci.h> -#include <ethdev_pci.h> #include "ntlog.h" +#include "ntnic_vfio.h" #include "nt_util.h" +#define EXCEPTION_PATH_HID 0 +/* Global static variables: */ 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++) {
@@ -76,6 +88,7 @@ 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 ; }
@@ -157,3 +170,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
@@ -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/include/nt_util.h +15 -0
@@ -24,5 +24,20 @@ void nt_os_wait_usec(int val);uint64_t nt_util_align_size (uint64_t size); +struct nt_dma_s { +uint64_t iova; +uint64_t addr; +uint64_t size; +}; + +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); + +struct nt_util_vfio_impl { +int (*vfio_dma_map)(int vf_num,void *virt_addr,uint64_t *iova_addr,uint64_t size); +int (*vfio_dma_unmap)(int vf_num,void *virt_addr,uint64_t iova_addr,uint64_t size); +}; + +void nt_util_vfio_init (struct nt_util_vfio_impl *impl);#endif /* NTOSS_SYSTEM_NT_UTIL_H */
drivers/net/ntnic/ntutil/nt_util.c +65 -0
74 lines not on this page · raw message
Signature · 1 line
2.45.0
PATCH v5 6/23 net/ntnic: add NT NIC driver dependencies
In reply to Serhii IliushykAdd structures and interfaces specific for NT smartNiC
--- drivers/net/ntnic/include/ntdrv_4ga.h | 17 ++ drivers/net/ntnic/include/ntos_drv.h | 33 ++++ drivers/net/ntnic/include/ntos_system.h | 21 ++ drivers/net/ntnic/meson.build | 1 + drivers/net/ntnic/ntnic_ethdev.c | 243 +++++++++++++++++++++++- 5 files changed, 314 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
@@ -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 +33 -0
@@ -0,0 +1,33 @@ +/* +* 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; +int if_index; +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 +21 -0
@@ -0,0 +1,21 @@ +/* +* 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; +int probe_finished; +int setup_finished; +}; + +#endif /* __NTOS_SYSTEM_H__ */
drivers/net/ntnic/meson.build +1 -0
@@ -15,6 +15,7 @@ cflags += [ # includes includes = [ include_directories('.'), + include_directories('include'), include_directories('ntlog/include'), include_directories('ntutil/include'), ]
drivers/net/ntnic/ntnic_ethdev.c +242 -1
312 lines not on this page · raw message
Signature · 1 line
2.45.0
Re: [PATCH v5 06/23] net/ntnic: add NT NIC driver dependencies
Quoted 2 lines · Serhii Iliushyk
Add structures and interfaces specific for NT smartNiC
The commit log is not really descriptive, I can see patch improves driver with struct eth_dev_ops.
And patch adds global 'struct drv_s' structure, I assume, as one pci device can have multiple ethdev, this struct is common state for all these ethdevs. But can you please describe it more.
And it is better if you can escape from a global variable state, and keep state per device specific data if possible, and if make sense for your specific usecase.
Also can you please describe what are the driver dependencies mentioned in the patch title?
<...>
drivers/net/ntnic/ntnic_ethdev.c line 97
Quoted 7 lines
drivers/net/ntnic/ntnic_ethdev.c +6
-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->if_index;
if_index is used wrong, I commented same before.
As a physical driver, you can ignore if_index, it is used for virtual drivers that has backed by linux interface.
Quoted 5 lines
drivers/net/ntnic/ntnic_ethdev.c +4
-0+ dev_info->driver_name = internals->name; + +return 0 ; +}
drivers/net/ntnic/ntnic_ethdev.c line 111
Quoted 10 lines
drivers/net/ntnic/ntnic_ethdev.c +10
-0+ +static int +eth_dev_configure (struct rte_eth_dev *eth_dev) +{ +struct pmd_internals *internals = (struct pmd_internals *)eth_dev->data->dev_private; +struct drv_s *p_drv = internals->p_drv; + +NT_LOG_DBGX (DEBUG ,NTNIC ,"Called for eth_dev %p\n" , eth_dev); + + p_drv->probe_finished =1 ;
Why setting 'p_drv->probe_finished' in 'eth_dev_configure()'? And won't multiple ethdev can share same 'p_drv', if so why updating it per ethdev?
Quoted 27 lines
drivers/net/ntnic/ntnic_ethdev.c +26
-0+ +/* The device is ALWAYS running promiscuous mode. */ + eth_dev->data->promiscuous ^= ~eth_dev->data->promiscuous; +return 0 ; +} + +static int +eth_dev_start (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->if_index); + +return 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->if_index); + + eth_dev->data->dev_link.link_status =RTE_ETH_LINK_DOWN ; +return 0 ;
drivers/net/ntnic/ntnic_ethdev.c line 147
Quoted 10 lines
drivers/net/ntnic/ntnic_ethdev.c +10
-0+} + +static void +drv_deinit (struct drv_s *p_drv) +{ +if (p_drv ==NULL ) +return ; +/* +* Mark the global pdrv for cleared. Used by some threads to terminate. +* 1 second to give the threads a chance to see the termonation.
typo termonation.
drivers/net/ntnic/ntnic_ethdev.c line 154
Quoted 8 lines
drivers/net/ntnic/ntnic_ethdev.c +7
-0+*/ +clear_pdrv (p_drv); +nt_os_wait_usec (1000000 ); + +/* clean memory */ +rte_free (p_drv); + p_drv =NULL ;
Clearing local variable?
Quoted 7 lines
drivers/net/ntnic/ntnic_ethdev.c +6
-0+} + +static int +eth_dev_close (struct rte_eth_dev *eth_dev) +{ +struct pmd_internals *internals = (struct pmd_internals *)eth_dev->data->dev_private;
drivers/net/ntnic/ntnic_ethdev.c line 170
Quoted 10 lines
drivers/net/ntnic/ntnic_ethdev.c +10
-0+struct drv_s *p_drv = internals->p_drv; + + internals->p_drv =NULL ; + +rte_free (internals); + internals =NULL ; + eth_dev->data->dev_private =NULL ; + eth_dev->data->mac_addrs =NULL ; + +rte_eth_dev_release_port (eth_dev);
'rte_eth_dev_release_port()' clears dev_private and mac_addrs, and more. It is common to close() free driver specific resources, and remove() does call close() and 'rte_eth_dev_release_port()' later to free common resources.
Quoted 148 lines
drivers/net/ntnic/ntnic_ethdev.c +88
-1+ +/* decrease initialized ethernet devices */ + p_drv->n_eth_dev_init_count--; + +/* +* rte_pci_dev has no private member for p_drv +* wait until all rte_eth_dev's are closed - then close adapters via p_drv +*/ +if (!p_drv->n_eth_dev_init_count && p_drv) +drv_deinit (p_drv); + +return 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, +};static int nthw_pci_dev_init (struct rte_pci_device *pci_dev) {nt_vfio_init (); +struct drv_s *p_drv; +ntdrv_4ga_t *p_nt_drv;uint32_t n_port_mask =-1 ;/* All ports enabled by default */ +uint32_t nb_rx_queues =1 ; +uint32_t nb_tx_queues =1 ;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); +/* alloc */ + p_drv =rte_zmalloc_socket (pci_dev->name,sizeof (struct drv_s ),RTE_CACHE_LINE_SIZE , + pci_dev->device.numa_node); + +if (!p_drv) { +NT_LOG_DBGX (ERR ,NTNIC ,"%s: error %d\n" , + (pci_dev->name[0 ] ? pci_dev->name :"NA" ),-1 ); +return -1 ; + } +/* 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 ); +rte_free (p_drv);return -1 ; } +/* context */ + p_nt_drv = &p_drv->ntdrv; + + p_drv->p_dev = pci_dev; + +/* Set context for NtDrv */ + p_nt_drv->pciident =BDF_TO_PCIIDENT (pci_dev->addr.domain, pci_dev->addr.bus, + pci_dev->addr.devid, pci_dev->addr.function); + + + p_nt_drv->b_shutdown = false; + +/* store context */ +store_pdrv (p_drv); + n_phy_ports =0 ;for (int n_intf_no =0 ; n_intf_no < n_phy_ports; n_intf_no++) { +struct pmd_internals *internals =NULL ;struct rte_eth_dev *eth_dev =NULL ;char name[32 ];@@ -50,6 +253,33 @@ 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 ; + } + + internals->pci_dev = pci_dev; + internals->n_intf_no = n_intf_no; + internals->if_index = 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); + } + +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);/* TODO: name */ if (!eth_dev) {@@ -61,6 +291,11 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev)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); +/* connect structs */ + internals->p_drv = p_drv; + eth_dev->data->dev_private = internals; + + internals->port_id = eth_dev->data->port_id;struct rte_eth_link pmd_link; pmd_link.link_speed =RTE_ETH_SPEED_NUM_NONE ;@@ -71,7 +306,7 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev) eth_dev->device = &pci_dev->device; eth_dev->data->dev_link = pmd_link; eth_dev->data->numa_node = pci_dev->device.numa_node; - eth_dev->dev_ops =NULL ; + eth_dev->dev_ops = &nthw_eth_dev_ops; eth_dev->state =RTE_ETH_DEV_ATTACHED ;rte_eth_copy_pci_info (eth_dev, pci_dev);@@ -79,8 +314,11 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev)eth_dev_pci_specific_init (eth_dev, pci_dev);/* increase initialized ethernet devices - PF */ + p_drv->n_eth_dev_init_count++; } + p_drv->setup_finished =1 ; +return 0 ; }
drivers/net/ntnic/ntnic_ethdev.c nthw_pci_remove(struct rte_pci_device *pci_dev) · line 400
Quoted 7 lines
drivers/net/ntnic/ntnic_ethdev.c +3
-0@@ -156,6 +394,9 @@ nthw_pci_remove(struct rte_pci_device *pci_dev) {NT_LOG_DBGX (DEBUG ,NTNIC ); +struct drv_s *p_drv =get_pdrv_from_pci (pci_dev->addr); +drv_deinit (p_drv); +
You are not really removing the ethdevs, which should be done at this stage.
As one pci device has multiple ethdevs, need to figure them out in this stage. Normally it is possible to get ethdev via "rte_eth_dev_allocated(pci_dev->device.name)", but for your case this is not possible.
octeontx (octeontx_ethdev.c) has similar usage, please check it. It does iterates on names, for you this is "ntnic%d", and frees the valid ones.
<...>
PATCH v5 7/23 net/ntnic: add core platform functionality
In reply to Serhii IliushykAdd ntnic basic platform interfaces
--- 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
@@ -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
@@ -18,10 +18,12 @@ includes = [ include_directories('include'), include_directories('ntlog/include'), include_directories('ntutil/include'), + 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
@@ -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
@@ -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
PATCH v5 8/23 net/ntnic: add adapter initialization
In reply to Serhii IliushykAdd interfaces for initialize the adapter
--- 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 | 73 ++++++++++- drivers/net/ntnic/ntnic_mod_reg.c | 20 +++ drivers/net/ntnic/ntnic_mod_reg.h | 27 ++++ 7 files changed, 311 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 +148 -0
@@ -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
@@ -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
@@ -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
@@ -23,9 +23,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 +72 -1
130 lines not on this page · raw message
drivers/net/ntnic/ntnic_mod_reg.c new file +20 -0
@@ -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
@@ -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
PATCH v5 9/23 net/ntnic: add registers and FPGA model for NapaTech NIC
In reply to Serhii IliushykThe 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 | 104 ++ drivers/net/ntnic/meson.build | 4 + .../net/ntnic/nthw/model/nthw_fpga_model.c | 1194 ++++++++++++++++ .../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 | 1233 +++++++++++++++++ .../nthw/supported/nthw_fpga_instances.c | 6 + .../nthw/supported/nthw_fpga_instances.h | 7 + .../ntnic/nthw/supported/nthw_fpga_mod_defs.h | 36 + .../nthw/supported/nthw_fpga_mod_str_map.c | 21 + .../nthw/supported/nthw_fpga_mod_str_map.h | 11 + .../nthw/supported/nthw_fpga_param_defs.h | 232 ++++ .../ntnic/nthw/supported/nthw_fpga_reg_defs.h | 35 + .../nthw/supported/nthw_fpga_reg_defs_gfg.h | 126 ++ .../nthw/supported/nthw_fpga_reg_defs_gmf.h | 68 + .../supported/nthw_fpga_reg_defs_gpio_phy.h | 48 + .../nthw/supported/nthw_fpga_reg_defs_hif.h | 79 ++ .../nthw/supported/nthw_fpga_reg_defs_i2cm.h | 38 + .../nthw/supported/nthw_fpga_reg_defs_iic.h | 96 ++ .../supported/nthw_fpga_reg_defs_mac_pcs.h | 298 ++++ .../supported/nthw_fpga_reg_defs_pci_rd_tg.h | 37 + .../supported/nthw_fpga_reg_defs_pci_wr_tg.h | 40 + .../nthw/supported/nthw_fpga_reg_defs_pcie3.h | 281 ++++ .../nthw/supported/nthw_fpga_reg_defs_rac.h | 72 + .../supported/nthw_fpga_reg_defs_rst9563.h | 59 + .../nthw/supported/nthw_fpga_reg_defs_sdc.h | 44 + drivers/net/ntnic/ntnic_ethdev.c | 1 + 27 files changed, 4436 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 +104 -0
@@ -0,0 +1,104 @@ +/* +* 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_ */ + +/* EOF */
drivers/net/ntnic/meson.build +4 -0
@@ -19,11 +19,15 @@ includes = [ include_directories('ntlog/include'), include_directories('ntutil/include'), 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 +1194 -0
1,194 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
@@ -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 +1233 -0
1,233 lines not on this page · raw message
drivers/net/ntnic/nthw/supported/nthw_fpga_instances.c new file +6 -0
@@ -0,0 +1,6 @@ + + +#include "nthw_fpga_instances.h" +nthw_fpga_prod_init_s *nthw_fpga_instances[] = { &nthw_fpga_9563_055_039_0000,NULL }; + +/* EOF */
drivers/net/ntnic/nthw/supported/nthw_fpga_instances.h new file +7 -0
@@ -0,0 +1,7 @@ + + +#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; + +/* EOF */
drivers/net/ntnic/nthw/supported/nthw_fpga_mod_defs.h new file +36 -0
@@ -0,0 +1,36 @@ +/* +* 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_ */ + +/* +* Auto-generated file - do *NOT* edit +*/ + +/* +* EOF +*/
drivers/net/ntnic/nthw/supported/nthw_fpga_mod_str_map.c new file +21 -0
@@ -0,0 +1,21 @@ + + +#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 } +}; + +/* EOF */
drivers/net/ntnic/nthw/supported/nthw_fpga_mod_str_map.h new file +11 -0
@@ -0,0 +1,11 @@ + + +#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[]; + +/* EOF */
drivers/net/ntnic/nthw/supported/nthw_fpga_param_defs.h new file +232 -0
107 lines not on this page · raw message
drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs.h new file +35 -0
Lines of this file are not shown. View the raw message.
drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_gfg.h new file +126 -0
126 lines not on this page · raw message
drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_gmf.h new file +68 -0
68 lines not on this page · raw message
drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_gpio_phy.h new file +48 -0
48 lines not on this page · raw message
drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_hif.h new file +79 -0
79 lines not on this page · raw message
drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_i2cm.h new file +38 -0
Lines of this file are not shown. View the raw message.
drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_iic.h new file +96 -0
96 lines not on this page · raw message
drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_mac_pcs.h new file +298 -0
298 lines not on this page · raw message
drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_pci_rd_tg.h new file +37 -0
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 +40 -0
Lines of this file are not shown. View the raw message.
drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_pcie3.h new file +281 -0
281 lines not on this page · raw message
drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_rac.h new file +72 -0
72 lines not on this page · raw message
drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_rst9563.h new file +59 -0
59 lines not on this page · raw message
drivers/net/ntnic/nthw/supported/nthw_fpga_reg_defs_sdc.h new file +44 -0
44 lines not on this page · 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.
PATCH v5 10/23 net/ntnic: add core platform functionality
In reply to Serhii IliushykAdd ntnic platform interfaces for FPGA registers
--- 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 | 785 ++++++++++++++++++ drivers/net/ntnic/nthw/nthw_rac.h | 153 ++++ 11 files changed, 2401 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
@@ -18,6 +18,7 @@ includes = [ include_directories('include'), include_directories('ntlog/include'), include_directories('ntutil/include'), + 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
@@ -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
@@ -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 +785 -0
785 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
PATCH v5 11/23 net/ntnic: add FPGA initialization functionality
In reply to Serhii IliushykEnable FPGA initialization
---
v5
* Fix Typo/Spelling
--- 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 + 9 files changed, 345 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
drivers/net/ntnic/adapter/nt4ga_adapter.c +49 -3
@@ -6,7 +6,7 @@#include <rte_thread.h> #include "ntlog.h" -#include "nt_util.h" +#include "nthw_fpga.h" #include "ntnic_mod_reg.h" static int nt4ga_adapter_show_info (struct adapter_info_s *p_adapter_info,FILE *pfh)
@@ -15,6 +15,7 @@ static int nt4ga_adapter_show_info(struct adapter_info_s *p_adapter_info, FILE *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; +mcu_info_t *mcu_info = &p_adapter_info->fpga_info.mcu_info;char a_pci_ident_str[32 ]; snprintf(a_pci_ident_str, sizeof(a_pci_ident_str), PCIIDENT_PRINT_STR,
@@ -37,7 +38,8 @@ static int nt4ga_adapter_show_info(struct adapter_info_s *p_adapter_info, FILE *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); - +fprintf (pfh,"%s: HasMcu=%d McuType=%d McuDramSize=%d\n" , p_adapter_id_str, + mcu_info->mb_has_mcu, mcu_info->mn_mcu_type, mcu_info->mn_mcu_dram_size);return 0 ; }
@@ -49,6 +51,13 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info)fpga_info_t *fpga_info = &p_adapter_info->fpga_info;hw_info_t *p_hw_info = &p_adapter_info->hw_info; +/* +* IMPORTANT: Most variables cannot be determined before nthw fpga model is instantiated +* (nthw_fpga_init()) +*/ +int n_phy_ports =-1 ; +int res =-1 ; +nthw_fpga_t *p_fpga =NULL ; p_hw_info->n_nthw_adapter_id =nthw_platform_get_nthw_adapter_id (p_hw_info->pci_device_id);
@@ -102,6 +111,39 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info) } } + res =nthw_fpga_init (&p_adapter_info->fpga_info); + +if (res) { +NT_LOG_DBGX (ERR ,NTNIC ,"%s: %s: FPGA=%04d res=x%08X\n" , p_adapter_id_str, + p_dev_name, fpga_info->n_fpga_prod_id, res); +return res; + } + +assert (fpga_info); + p_fpga = fpga_info->mp_fpga; +assert (p_fpga); + n_phy_ports = fpga_info->n_phy_ports; +assert (n_phy_ports >=1 ); + + { +assert (fpga_info->n_fpga_prod_id >0 ); + +switch (fpga_info->n_fpga_prod_id) { +default : +NT_LOG (ERR ,NTNIC ,"Unsupported FPGA product: %04d\n" , + fpga_info->n_fpga_prod_id); + res =-1 ; +break ; + } + +if (res) { +NT_LOG_DBGX (ERR ,NTNIC ,"%s: %s: FPGA=%04d res=x%08X\n" , + p_adapter_id_str, p_dev_name, + fpga_info->n_fpga_prod_id, res); +return res; + } + } +return 0 ; }
@@ -109,8 +151,12 @@ 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 ; +int res; + +nthw_fpga_shutdown (&p_adapter_info->fpga_info); +/* Rac rab reset flip flop */ + res =nthw_rac_rab_reset (fpga_info->mp_nthw_rac);/* Free adapter port ident strings */ for (i =0 ; i < fpga_info->n_phy_ports; i++) {
drivers/net/ntnic/meson.build +7 -0
@@ -21,6 +21,7 @@ includes = [ include_directories('nthw/core/include'), include_directories('nthw'), include_directories('nthw/supported'), + include_directories('nthw/model'), ] # all sources
@@ -29,7 +30,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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -197,12 +197,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
@@ -219,6 +240,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 */
@@ -252,6 +274,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;
@@ -262,6 +285,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;
@@ -298,6 +326,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",
@@ -305,7 +342,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
@@ -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
Re: [PATCH v5 11/23] net/ntnic: add FPGA initialization functionality
Quoted 3 lines · Serhii Iliushyk
Enable FPGA initialization
Signed-off-by Serhii Iliushyk <[email protected]>
<...>
drivers/net/ntnic/ntnic_ethdev.c eth_dev_close(struct rte_eth_dev *eth_dev) · line 226
Quoted 8 lines
static struct
eth_dev_opsnthw_eth_dev_ops= {drivers/net/ntnic/ntnic_ethdev.c +1
-0.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,
Can you please update .ini file with each feature added, in the patch that adds feature?
Like for this case, 'FW version' feature needs to be marked as supported.
<...>
PATCH v5 12/23 net/ntnic: add support of the NT200A0X smartNIC
In reply to Serhii IliushykAdd 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 | 12 +++++ 8 files changed, 116 insertions(+) create mode 100644 drivers/net/ntnic/nthw/core/nt200a0x/nthw_fpga_nt200a0x.c
drivers/net/ntnic/adapter/nt4ga_adapter.c +6 -0
@@ -129,6 +129,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
@@ -30,6 +30,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
@@ -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
@@ -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
@@ -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
@@ -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 +12 -0
@@ -24,6 +24,16 @@/* Global static variables: */ static rte_spinlock_t hwlock =RTE_SPINLOCK_INITIALIZER ; +/* +* The set of PCI devices this driver supports +*/ +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 */ +}; +/* * Store and get adapter info */
@@ -514,10 +524,12 @@ static struct rte_pci_driver rte_nthw_pmd = { .name = "net_ntnic", }, + .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
PATCH v5 13/23 net/ntnic: add reset module for the NT200A0X smartNIC
In reply to Serhii IliushykAdd API for reset NT200 and FW 9563
---
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
@@ -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
@@ -31,10 +31,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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v5 14/23 net/ntnic: add clock profiles for the NT200A0X smartNIC
In reply to Serhii IliushykAdd API for control clock NT200 and FW 9563
--- .../ntnic/include/clock_profiles_structs.h | 35 + .../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, 1159 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 +35 -0
@@ -0,0 +1,35 @@ +/* +* 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_ */ + +/* EOF */
drivers/net/ntnic/include/ntnic_nthw_fpga_rst_nt200a0x.h +1 -0
@@ -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
@@ -30,6 +30,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',
@@ -38,6 +39,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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -147,6 +147,29 @@ int nthw_fpga_silabs_detect(nthw_fpga_t *p_fpga, const int n_instance_no, constreturn 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
@@ -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
@@ -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
PATCH v5 15/23 net/ntnic: add MAC and packet features
In reply to Serhii IliushykAdd basic control for MAC addresses packets and queues
--- drivers/net/ntnic/include/ntos_drv.h | 15 +++++++++++ drivers/net/ntnic/ntnic_ethdev.c | 39 ++++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 2 deletions(-)
drivers/net/ntnic/include/ntos_drv.h +15 -0
@@ -26,9 +26,24 @@ struct pmd_internals {char name[20 ];int n_intf_no;int if_index; +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/ntnic_ethdev.c +37 -2
@@ -19,6 +19,9 @@#include "ntnic_mod_reg.h" #include "nt_util.h" +#define HW_MAX_PKT_LEN (10000) +#define MAX_MTU (HW_MAX_PKT_LEN - RTE_ETHER_HDR_LEN - RTE_ETHER_CRC_LEN) +#define EXCEPTION_PATH_HID 0/* Global static variables: */
@@ -108,6 +111,16 @@ eth_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *dev_info dev_info->if_index = internals->if_index; dev_info->driver_name = internals->name; + dev_info->max_mac_addrs =NUM_MAC_ADDRS_PER_PORT ; + dev_info->max_rx_pktlen =HW_MAX_PKT_LEN ; + dev_info->max_mtu =MAX_MTU ; + +if (internals->p_drv) { + dev_info->max_rx_queues = internals->nb_rx_queues; + dev_info->max_tx_queues = internals->nb_tx_queues; + + dev_info->min_rx_bufsize =64 ; + }return 0 ; }
@@ -142,8 +155,8 @@ 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->if_index); +NT_LOG_DBGX (DEBUG ,NTNIC ,"Port %u, %u, type %u\n" , + internals->n_intf_no, internals->if_index, internals->type); eth_dev->data->dev_link.link_status =RTE_ETH_LINK_DOWN ;return 0 ;
@@ -212,6 +225,9 @@ 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; +if (internals->type ==PORT_TYPE_VIRTUAL || internals->type ==PORT_TYPE_OVERRIDE ) +return 0 ; +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,
@@ -384,6 +400,12 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev) internals->pci_dev = pci_dev; internals->n_intf_no = n_intf_no; internals->if_index = n_intf_no; + internals->min_tx_pkt_size =64 ; + internals->max_tx_pkt_size =10000 ; + internals->type =PORT_TYPE_PHYSICAL ; + internals->vhid =-1 ; + internals->nb_rx_queues = nb_rx_queues; + internals->nb_tx_queues = nb_tx_queues;/* Setup queue_ids */
@@ -399,6 +421,18 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev) 0 /*port*/, nb_tx_queues); } +/* Set MAC address (but only if the MAC address is permitted) */ +if (n_intf_no < fpga_info->nthw_hw_info.vpd_info.mn_mac_addr_count) { +const uint64_t mac = + fpga_info->nthw_hw_info.vpd_info.mn_mac_addr_value + n_intf_no; + internals->eth_addrs[0 ].addr_bytes[0 ] = (mac >>40 ) &0xFFu ; + internals->eth_addrs[0 ].addr_bytes[1 ] = (mac >>32 ) &0xFFu ; + internals->eth_addrs[0 ].addr_bytes[2 ] = (mac >>24 ) &0xFFu ; + internals->eth_addrs[0 ].addr_bytes[3 ] = (mac >>16 ) &0xFFu ; + internals->eth_addrs[0 ].addr_bytes[4 ] = (mac >>8 ) &0xFFu ; + internals->eth_addrs[0 ].addr_bytes[5 ] = (mac >>0 ) &0xFFu ; + } + eth_dev =rte_eth_dev_allocate (name);/* TODO: name */ if (!eth_dev) {
@@ -413,6 +447,7 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev)/* connect structs */ internals->p_drv = p_drv; eth_dev->data->dev_private = internals; + eth_dev->data->mac_addrs = internals->eth_addrs; internals->port_id = eth_dev->data->port_id;
Signature · 1 line
2.45.0
PATCH v5 16/23 net/ntnic: add link management module
In reply to Serhii IliushykAdd link control API
---
v5
* Fix Typo/Spelling
--- 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/link_mgmt/nt4ga_link.c | 176 +++++++++++++++ drivers/net/ntnic/meson.build | 1 + drivers/net/ntnic/ntnic_ethdev.c | 242 +++++++++++++++++++++ drivers/net/ntnic/ntnic_mod_reg.c | 14 ++ drivers/net/ntnic/ntnic_mod_reg.h | 50 ++++- drivers/net/ntnic/ntutil/include/nt_util.h | 11 + drivers/net/ntnic/ntutil/nt_util.c | 131 +++++++++++ 10 files changed, 718 insertions(+), 2 deletions(-) create mode 100644 drivers/net/ntnic/include/nt4ga_link.h create mode 100644 drivers/net/ntnic/link_mgmt/nt4ga_link.c
drivers/net/ntnic/adapter/nt4ga_adapter.c +6 -0
@@ -126,8 +126,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
@@ -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/link_mgmt/nt4ga_link.c new file +176 -0
176 lines not on this page · raw message
drivers/net/ntnic/meson.build +1 -0
@@ -27,6 +27,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 +242 -0
311 lines not on this page · raw message
drivers/net/ntnic/ntnic_mod_reg.c +14 -0
@@ -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/include/nt_util.h +11 -0
@@ -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 */
drivers/net/ntnic/ntutil/nt_util.c +131 -0
134 lines not on this page · raw message
Signature · 1 line
2.45.0
Re: [PATCH v5 16/23] net/ntnic: add link management module
Quoted 3 lines · Serhii Iliushyk
Add link control API
Signed-off-by Serhii Iliushyk <[email protected]>
<...>
Quoted 5 lines
static struct
eth_dev_opsnthw_eth_dev_ops= {drivers/net/ntnic/ntnic_ethdev.c +0
-0.dev_configure = eth_dev_configure, .dev_start = eth_dev_start, .dev_stop = eth_dev_stop,
drivers/net/ntnic/ntnic_ethdev.c eth_fw_version_get(struct rte_eth_dev *eth_dev, char *fw_version, size_t fw_size · line 480
Quoted 10 lines
drivers/net/ntnic/ntnic_ethdev.c +7
-0+ .dev_set_link_up = eth_dev_set_link_up, + .dev_set_link_down = eth_dev_set_link_down, .dev_close = eth_dev_close, + .link_update = eth_link_update, .dev_infos_get = eth_dev_infos_get, .fw_version_get = eth_fw_version_get, + .mac_addr_add = eth_mac_addr_add, + .mac_addr_set = eth_mac_addr_set, + .set_mc_addr_list = eth_set_mc_addr_list, + .promiscuous_enable = promiscuous_enable,
Does mac related ops fits better to previous patch?
<...>
PATCH v5 17/23 net/ntnic: add link 100G module
In reply to Serhii IliushykAdd ntnic 100G link support.
--- 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
@@ -127,6 +127,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++) {
@@ -137,8 +138,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
@@ -27,6 +27,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
@@ -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
@@ -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
PATCH v5 18/23 net/ntnic: add NIM module
In reply to Serhii IliushykAdd API for control NIM
--- 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
@@ -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 ;
@@ -124,6 +154,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;
@@ -173,6 +205,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
@@ -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
@@ -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
@@ -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
@@ -22,6 +22,7 @@ includes = [ include_directories('nthw'), include_directories('nthw/supported'), include_directories('nthw/model'), + include_directories('nim/'), ] # all sources
@@ -29,6 +30,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',
@@ -38,6 +40,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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v5 19/23 net/ntnic: add QSFP support
In reply to Serhii IliushykIncludes 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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v5 20/23 net/ntnic: add QSFP28 support
In reply to Serhii IliushykIncludes 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
@@ -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
@@ -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
@@ -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
PATCH v5 21/23 net/ntnic: add GPIO PHY module
In reply to Serhii IliushykAdd GPIO API for communication with NIM
---
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
@@ -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
@@ -39,6 +39,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
@@ -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
PATCH v5 22/23 net/ntnic: add MAC PCS register interface module
In reply to Serhii IliushykAdd API for MAC and PCS(Physical Coding Sublayer)
--- 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
@@ -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
@@ -43,6 +43,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
@@ -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
PATCH v5 23/23 net/ntnic: add GMF (Generic MAC Feeder) module
In reply to Serhii IliushykAdd API for Generic MAC Feeder
--- .../link_mgmt/link_100g/nt4ga_link_100g.c | 8 ++ drivers/net/ntnic/meson.build | 1 + .../net/ntnic/nthw/core/include/nthw_core.h | 1 + .../net/ntnic/nthw/core/include/nthw_gmf.h | 64 +++++++++ drivers/net/ntnic/nthw/core/nthw_gmf.c | 133 ++++++++++++++++++ 5 files changed, 207 insertions(+) create mode 100644 drivers/net/ntnic/nthw/core/include/nthw_gmf.h create mode 100644 drivers/net/ntnic/nthw/core/nthw_gmf.c
drivers/net/ntnic/link_mgmt/link_100g/nt4ga_link_100g.c +8 -0
@@ -404,6 +404,14 @@ static int _port_init(adapter_info_t *drv, nthw_fpga_t *fpga, int port)_enable_tx (drv, mac_pcs);_reset_rx (drv, mac_pcs); +/* 2.2) Nt4gaPort::setup() */ +if (nthw_gmf_init (NULL , fpga, port) ==0 ) { +nthw_gmf_t gmf; + +if (nthw_gmf_init (&gmf, fpga, port) ==0 ) +nthw_gmf_set_enable (&gmf, true); + } +/* Phase 3. Link state machine steps */ /* 3.1) Create NIM, ::createNim() */
drivers/net/ntnic/meson.build +1 -0
@@ -39,6 +39,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_gmf.c', 'nthw/core/nthw_gpio_phy.c', 'nthw/core/nthw_hif.c', 'nthw/core/nthw_i2cm.c',
drivers/net/ntnic/nthw/core/include/nthw_core.h +1 -0
@@ -17,6 +17,7 @@#include "nthw_iic.h" #include "nthw_i2cm.h" +#include "nthw_gmf.h" #include "nthw_gpio_phy.h" #include "nthw_mac_pcs.h" #include "nthw_sdc.h"
drivers/net/ntnic/nthw/core/include/nthw_gmf.h new file +64 -0
64 lines not on this page · raw message
drivers/net/ntnic/nthw/core/nthw_gmf.c new file +133 -0
133 lines not on this page · raw message
Signature · 1 line
2.45.0
Re: [PATCH v5 23/23] net/ntnic: add GMF (Generic MAC Feeder) module
Quoted 4 lines · Serhii Iliushyk
Add API for Generic MAC Feeder
Signed-off-by Serhii Iliushyk <[email protected]>
Overall commit logs are very terse, can you please add more details, comment is not specific to this commit, but for this commit like explaining what GMF is for etc.. can help
Re: [PATCH v5 01/23] net/ntnic: add ethdev and makes PMD available
In reply to Serhii IliushykQuoted 2 lines · Serhii Iliushyk
Add ntnic ethdev base implementation
Hi Serhii,
Thanks for the updated version, how driver constructed patch by patch is easier to grasp now.
<...>
Quoted 24 lines
doc/guides/nics/ntnic.rst new file +18
-0@@ -0,0 +1,43 @@ +.. 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
doc/guides/nics/ntnic.rst line 28
Quoted 10 lines
doc/guides/nics/ntnic.rst new file +10
-0+behind PF0 as DPDK port 0 and 1. + + +Supported NICs +-------------- + +- NT200A02 2x100G SmartNIC + + - FPGA ID 9563 (Inline Flow Management) +
Can you please provide some links for the product, so that whoever interested can access to the devices easier.
This is also good opportunity to advertise the product.
doc/guides/nics/ntnic.rst line 34
Quoted 6 lines
doc/guides/nics/ntnic.rst new file +6
-0+ +Features +-------- + +- Link state information. +
Even this feature is not available at this stage.
As far as I can see it is missing now, but need to update this file, and .ini file as new features enabled in the driver.
Quoted 31 lines
doc/guides/nics/ntnic.rst new file +9
-0+ +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.drivers/net/meson.build +1
-0@@ -45,6 +45,7 @@ drivers = [ 'nfb', 'nfp', 'ngbe', + 'ntnic', 'null', 'octeontx', 'octeon_ep',drivers/net/ntnic/meson.build new file +3
-0@@ -0,0 +1,24 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2020-2023 Napatech A/S +
drivers/net/ntnic/meson.build line 13
Quoted 10 lines
drivers/net/ntnic/meson.build new file +10
-0+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 + +# cflags +cflags += [ + '-std=c11', +]
Why this flag is explicitly required?
drivers/net/ntnic/meson.build line 18
Quoted 6 lines
drivers/net/ntnic/meson.build new file +5
-0+ +# includes +includes = [ + include_directories('.'), +]
I think this include also not required at this stage. And I don't think adding current folder '.' is required at all.
drivers/net/ntnic/meson.build line 24
Quoted 7 lines
drivers/net/ntnic/meson.build new file +6
-0+ +# all sources +sources = files( + 'ntnic_ethdev.c', +) +# END
There are EOF markers in various files, if this is part of your coding convention, it is OK to keep them in base files, but for the DPDK specific files, no need to mark the end of file. (Unless you can justify to have them.)
Quoted 7 lines
drivers/net/ntnic/ntnic_ethdev.c new file +0
-0
drivers/net/ntnic/ntnic_ethdev.c line 7
Quoted 7 lines
drivers/net/ntnic/ntnic_ethdev.c new file +7
-0@@ -0,0 +1,53 @@ +/* +* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2023 Napatech A/S +*/ + + +#include <rte_kvargs.h>
Some of the headers are not required at this stage, can you please include them when they are needed.
drivers/net/ntnic/ntnic_ethdev.c line 15
Quoted 9 lines
drivers/net/ntnic/ntnic_ethdev.c new file +8
-0+#include <rte_eal.h> +#include <rte_dev.h> +#include <rte_vfio.h> +#include <rte_ethdev.h> +#include <rte_bus_pci.h> +#include <ethdev_pci.h> + +/* Global static variables: */
Can drop comments not meaningful at this stage.
Quoted 23 lines
drivers/net/ntnic/ntnic_ethdev.c new file +22
-0+ +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 res; + res =nthw_pci_dev_init (pci_dev); +return res; +} +
drivers/net/ntnic/ntnic_ethdev.c line 47
Quoted 10 lines
drivers/net/ntnic/ntnic_ethdev.c new file +10
-0+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 = { + .driver = { + .name ="net_ntnic" , + },
No need to set 'name', as this is already done by 'RTE_PMD_REGISTER_PCI' macro.
drivers/net/ntnic/ntnic_ethdev.c line 50
Quoted 4 lines
drivers/net/ntnic/ntnic_ethdev.c new file +3
-0+ + .probe = nthw_pci_probe, + .remove = nthw_pci_remove,
May need to add '.id_table', even it is empty (all zeros), otherwise I expect this cause a crash during pci probe.
PATCH v6 1/21 net/ntnic: add ethdev and makes PMD available
In reply to Serhii IliushykAdd 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
--- .mailmap | 1 + MAINTAINERS | 7 +++++ doc/guides/nics/features/ntnic.ini | 12 ++++++++ doc/guides/nics/index.rst | 1 + doc/guides/nics/ntnic.rst | 49 ++++++++++++++++++++++++++++++ drivers/net/meson.build | 1 + drivers/net/ntnic/meson.build | 18 +++++++++++ drivers/net/ntnic/ntnic_ethdev.c | 49 ++++++++++++++++++++++++++++++ 8 files changed, 138 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
@@ -1289,6 +1289,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
@@ -857,6 +857,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 +12 -0
@@ -0,0 +1,12 @@ +; +; Supported features of the 'ntnic' network poll mode driver. +; +; Refer to default.ini for the full list of available PMD features. +; +[Features] +Speed capabilities = Y +FW version = Y +Unicast MAC filter = Y +Multicast MAC filter = Y +Linux = Y +x86-64 = Y
doc/guides/nics/index.rst +1 -0
@@ -53,6 +53,7 @@ Network Interface Controller Drivers nfb nfp ngbe + ntnic null octeon_ep octeontx
doc/guides/nics/ntnic.rst new file +49 -0
49 lines not on this page · raw message
drivers/net/meson.build +1 -0
@@ -45,6 +45,7 @@ drivers = [ 'nfb', 'nfp', 'ngbe', + 'ntnic', 'null', 'octeontx', 'octeon_ep',
drivers/net/ntnic/meson.build new file +18 -0
@@ -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
PATCH v6 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
@@ -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
@@ -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
PATCH v6 3/21 net/ntnic: add minimal initialization for PCI device
In reply to Serhii Iliushykadd 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
@@ -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
PATCH v6 4/21 net/ntnic: add NT utilities implementation
In reply to Serhii IliushykAdd 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
@@ -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
@@ -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
@@ -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
PATCH v6 5/21 net/ntnic: add VFIO module
In reply to Serhii IliushykAdds 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
@@ -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
@@ -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
@@ -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
PATCH v6 6/21 net/ntnic: add basic eth dev ops to ntnic
In reply to Serhii IliushykAdds 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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v6 7/21 net/ntnic: add core platform structures
In reply to Serhii IliushykAdds 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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v6 8/21 net/ntnic: add adapter initialization
In reply to Serhii IliushykAdd 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v6 9/21 net/ntnic: add registers and FPGA model for NapaTech NIC
In reply to Serhii IliushykThe 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
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
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
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
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
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
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.
PATCH v6 10/21 net/ntnic: add FPGA modules for initialization
In reply to Serhii IliushykNew 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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v6 11/21 net/ntnic: add FPGA initialization functionality
In reply to Serhii IliushykEnable FPGA initialization and adds ethdev fw_version_get.
---
v5
* Fix Typo/Spelling
--- 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 + 9 files changed, 345 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
drivers/net/ntnic/adapter/nt4ga_adapter.c +49 -3
@@ -6,7 +6,7 @@#include <rte_thread.h> #include "ntlog.h" -#include "nt_util.h" +#include "nthw_fpga.h" #include "ntnic_mod_reg.h" static int nt4ga_adapter_show_info (struct adapter_info_s *p_adapter_info,FILE *pfh)
@@ -15,6 +15,7 @@ static int nt4ga_adapter_show_info(struct adapter_info_s *p_adapter_info, FILE *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; +mcu_info_t *mcu_info = &p_adapter_info->fpga_info.mcu_info;char a_pci_ident_str[32 ]; snprintf(a_pci_ident_str, sizeof(a_pci_ident_str), PCIIDENT_PRINT_STR,
@@ -37,7 +38,8 @@ static int nt4ga_adapter_show_info(struct adapter_info_s *p_adapter_info, FILE *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); - +fprintf (pfh,"%s: HasMcu=%d McuType=%d McuDramSize=%d\n" , p_adapter_id_str, + mcu_info->mb_has_mcu, mcu_info->mn_mcu_type, mcu_info->mn_mcu_dram_size);return 0 ; }
@@ -49,6 +51,13 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info)fpga_info_t *fpga_info = &p_adapter_info->fpga_info;hw_info_t *p_hw_info = &p_adapter_info->hw_info; +/* +* IMPORTANT: Most variables cannot be determined before nthw fpga model is instantiated +* (nthw_fpga_init()) +*/ +int n_phy_ports =-1 ; +int res =-1 ; +nthw_fpga_t *p_fpga =NULL ; p_hw_info->n_nthw_adapter_id =nthw_platform_get_nthw_adapter_id (p_hw_info->pci_device_id);
@@ -100,6 +109,39 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info) } } + res =nthw_fpga_init (&p_adapter_info->fpga_info); + +if (res) { +NT_LOG_DBGX (ERR ,NTNIC ,"%s: %s: FPGA=%04d res=x%08X\n" , p_adapter_id_str, + p_dev_name, fpga_info->n_fpga_prod_id, res); +return res; + } + +assert (fpga_info); + p_fpga = fpga_info->mp_fpga; +assert (p_fpga); + n_phy_ports = fpga_info->n_phy_ports; +assert (n_phy_ports >=1 ); + + { +assert (fpga_info->n_fpga_prod_id >0 ); + +switch (fpga_info->n_fpga_prod_id) { +default : +NT_LOG (ERR ,NTNIC ,"Unsupported FPGA product: %04d\n" , + fpga_info->n_fpga_prod_id); + res =-1 ; +break ; + } + +if (res) { +NT_LOG_DBGX (ERR ,NTNIC ,"%s: %s: FPGA=%04d res=x%08X\n" , + p_adapter_id_str, p_dev_name, + fpga_info->n_fpga_prod_id, res); +return res; + } + } +return 0 ; }
@@ -107,8 +149,12 @@ 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 ; +int res; + +nthw_fpga_shutdown (&p_adapter_info->fpga_info); +/* Rac rab reset flip flop */ + res =nthw_rac_rab_reset (fpga_info->mp_nthw_rac);/* Free adapter port ident strings */ for (i =0 ; i < fpga_info->n_phy_ports; i++) {
drivers/net/ntnic/meson.build +7 -0
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v6 12/21 net/ntnic: add support of the NT200A0X smartNIC
In reply to Serhii IliushykAdd 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -26,6 +26,7 @@#define EXCEPTION_PATH_HID 0static 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
PATCH v6 13/21 net/ntnic: add startup and reset sequence for NT200A0X
In reply to Serhii IliushykAdds 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v6 14/21 net/ntnic: add clock profile for the NT200A0X smartNIC
In reply to Serhii IliushykBecause 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -147,6 +147,29 @@ int nthw_fpga_silabs_detect(nthw_fpga_t *p_fpga, const int n_instance_no, constreturn 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
@@ -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
@@ -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
PATCH v6 15/21 net/ntnic: add link management skeleton
In reply to Serhii IliushykAdd 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
--- 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 | 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 + 11 files changed, 770 insertions(+), 4 deletions(-) create mode 100644 drivers/net/ntnic/include/nt4ga_link.h create mode 100644 drivers/net/ntnic/link_mgmt/nt4ga_link.c
drivers/net/ntnic/adapter/nt4ga_adapter.c +6 -0
@@ -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
@@ -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
@@ -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
@@ -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 +279 -2
376 lines not on this page · raw message
drivers/net/ntnic/ntnic_mod_reg.c +14 -0
@@ -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
@@ -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
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v6 15/21] net/ntnic: add link management skeleton
drivers/net/ntnic/ntnic_ethdev.c nthw_pci_dev_init(struct rte_pci_device *pci_dev) · line 663
Quoted 7 lines · Serhii Iliushyk
drivers/net/ntnic/ntnic_ethdev.c +2
-0@@ -383,6 +658,8 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev)/* connect structs */ internals->p_drv = p_drv; eth_dev->data->dev_private = internals; + eth_dev->data->mac_addrs =rte_malloc (NULL ,RTE_ETHER_ADDR_LEN ,0 ); +rte_memcpy (eth_dev->data->mac_addrs, internals->eth_addrs,RTE_ETHER_ADDR_LEN );
This allocates room for 1 MAC address for 'mac_addrs', BUT in 'eth_dev_infos_get()',
"dev_info->max_mac_addrs = NUM_MAC_ADDRS_PER_PORT;" which is 16.
This will cause crash if user tries to add more than one MAC, need to increase size of the allocated memory.
PATCH v6 16/21 net/ntnic: add link 100G module ops
In reply to Serhii IliushykAs 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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v6 17/21 net/ntnic: add generic NIM and I2C modules
In reply to Serhii IliushykAs 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v6 18/21 net/ntnic: add QSFP support
In reply to Serhii IliushykIncludes 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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v6 19/21 net/ntnic: add QSFP28 support
In reply to Serhii IliushykIncludes 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
@@ -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
@@ -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
@@ -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
PATCH v6 20/21 net/ntnic: add GPIO communication for NIMs
In reply to Serhii IliushykFor 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
@@ -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
@@ -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
@@ -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
PATCH v6 21/21 net/ntnic: add physical layer control module
In reply to Serhii IliushykAdds 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
@@ -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
@@ -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
@@ -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
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v6 01/21] net/ntnic: add ethdev and makes PMD available
doc/guides/nics/features/ntnic.ini line 10
Quoted 13 lines · Serhii Iliushyk
+++ b/doc/guides/nics/features/ntnic.ini
doc/guides/nics/features/ntnic.ini new file +10
-0@@ -0,0 +1,12 @@ +; +; Supported features of the 'ntnic' network poll mode driver. +; +; Refer to default.ini for the full list of available PMD features. +; +[Features] +Speed capabilities = Y +FW version = Y +Unicast MAC filter = Y +Multicast MAC filter = Y
These features are not enabled in this patch, can you please distribute these updates to the patches that enables these features. Same for feature list in ntnic.rst
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v6 01/21] net/ntnic: add ethdev and makes PMD available
Quoted 5 lines · Serhii Iliushyk
Add initial ntnic ethdev skeleton and register PCI probe functions Update documentation: Device description and feature list
Signed-off-by Serhii Iliushyk <[email protected]>
Hi Serhii,
I put a few minor comments.
What is the latest testing status of the driver, as it doesn't have datapath support yet, I believe it is difficult to do functional testing. To set the expectation right for the users, do you think does it make sense to highlight this with some not in maintainers file update, something like:
"Napatech ntnic - Experimental"
And can you please add a release notes update with the first, skeleton, patch. You can give a little more detail about the status of the driver there.
PATCH v7 1/21 net/ntnic: add ethdev and makes PMD available
In reply to Serhii IliushykAdd 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -45,6 +45,7 @@ drivers = [ 'nfb', 'nfp', 'ngbe', + 'ntnic', 'null', 'octeontx', 'octeon_ep',
drivers/net/ntnic/meson.build new file +18 -0
@@ -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
PATCH v7 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
--- 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
@@ -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
@@ -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
PATCH v7 3/21 net/ntnic: add minimal initialization for PCI device
In reply to Serhii Iliushykadd implementation for probe/init and remove/deinit of the PCI device
--- drivers/net/ntnic/ntnic_ethdev.c | 109 +++++++++++++++++++++++++++++-- 1 file changed, 104 insertions(+), 5 deletions(-)
drivers/net/ntnic/ntnic_ethdev.c +104 -5
@@ -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
PATCH v7 4/21 net/ntnic: add NT utilities implementation
In reply to Serhii IliushykAdd ntnic utilities.
--- 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
@@ -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
@@ -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
@@ -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
PATCH v7 5/21 net/ntnic: add VFIO module
In reply to Serhii IliushykAdds 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
@@ -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
@@ -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
@@ -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
PATCH v7 6/21 net/ntnic: add basic eth dev ops to ntnic
In reply to Serhii IliushykAdds support for eth_dev configure, start, stop, close, and infos_get. The internal structs of ntnic is also added and initialized.
--- 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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v7 7/21 net/ntnic: add core platform structures
In reply to Serhii IliushykAdds 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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v7 8/21 net/ntnic: add adapter initialization
In reply to Serhii IliushykAdd interfaces for initialize the adapter
--- 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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