15433956dSTimothy McDaniel /* SPDX-License-Identifier: BSD-3-Clause 25433956dSTimothy McDaniel * Copyright(c) 2016-2020 Intel Corporation 35433956dSTimothy McDaniel */ 45433956dSTimothy McDaniel 55433956dSTimothy McDaniel #ifndef __DLB2_MAIN_H 65433956dSTimothy McDaniel #define __DLB2_MAIN_H 75433956dSTimothy McDaniel 85433956dSTimothy McDaniel #include <rte_debug.h> 95433956dSTimothy McDaniel #include <rte_log.h> 105433956dSTimothy McDaniel #include <rte_spinlock.h> 115433956dSTimothy McDaniel #include <rte_pci.h> 121f37cb2bSDavid Marchand #include <bus_pci_driver.h> 13924e6b76SThomas Monjalon #include <rte_eal_paging.h> 145433956dSTimothy McDaniel 155433956dSTimothy McDaniel #include "base/dlb2_hw_types.h" 165433956dSTimothy McDaniel #include "../dlb2_user.h" 175433956dSTimothy McDaniel 18*8d1d9070SAbdullah Sevincer #define DLB2_EAL_PROBE_CORE 2 19*8d1d9070SAbdullah Sevincer #define DLB2_NUM_PROBE_ENQS 1000 20*8d1d9070SAbdullah Sevincer #define DLB2_HCW_MEM_SIZE 8 21*8d1d9070SAbdullah Sevincer #define DLB2_HCW_64B_OFF 4 22*8d1d9070SAbdullah Sevincer #define DLB2_HCW_ALIGN_MASK 0x3F 235433956dSTimothy McDaniel 245433956dSTimothy McDaniel struct dlb2_dev; 255433956dSTimothy McDaniel 265433956dSTimothy McDaniel struct dlb2_port_memory { 275433956dSTimothy McDaniel struct dlb2_list_head list; 285433956dSTimothy McDaniel void *cq_base; 295433956dSTimothy McDaniel bool valid; 305433956dSTimothy McDaniel }; 315433956dSTimothy McDaniel 325433956dSTimothy McDaniel struct dlb2_dev { 335433956dSTimothy McDaniel struct rte_pci_device *pdev; 345433956dSTimothy McDaniel struct dlb2_hw hw; 355433956dSTimothy McDaniel /* struct list_head list; */ 365433956dSTimothy McDaniel struct device *dlb2_device; 375433956dSTimothy McDaniel bool domain_reset_failed; 38*8d1d9070SAbdullah Sevincer /* The enqueue_four function enqueues four HCWs (one cache-line worth) 39*8d1d9070SAbdullah Sevincer * to the HQM, using whichever mechanism is supported by the platform 40*8d1d9070SAbdullah Sevincer * on which this driver is running. 41*8d1d9070SAbdullah Sevincer */ 42*8d1d9070SAbdullah Sevincer void (*enqueue_four)(void *qe4, void *pp_addr); 435433956dSTimothy McDaniel /* The resource mutex serializes access to driver data structures and 445433956dSTimothy McDaniel * hardware registers. 455433956dSTimothy McDaniel */ 465433956dSTimothy McDaniel rte_spinlock_t resource_mutex; 475433956dSTimothy McDaniel bool worker_launched; 485433956dSTimothy McDaniel u8 revision; 49*8d1d9070SAbdullah Sevincer u8 version; 505433956dSTimothy McDaniel }; 515433956dSTimothy McDaniel 52*8d1d9070SAbdullah Sevincer struct dlb2_pp_thread_data { 53*8d1d9070SAbdullah Sevincer struct dlb2_hw *hw; 54*8d1d9070SAbdullah Sevincer int pp; 55*8d1d9070SAbdullah Sevincer bool is_ldb; 56*8d1d9070SAbdullah Sevincer int cycles; 57*8d1d9070SAbdullah Sevincer }; 58*8d1d9070SAbdullah Sevincer 59*8d1d9070SAbdullah Sevincer struct dlb2_dev *dlb2_probe(struct rte_pci_device *pdev, const void *probe_args); 60*8d1d9070SAbdullah Sevincer 615433956dSTimothy McDaniel 625433956dSTimothy McDaniel int dlb2_pf_reset(struct dlb2_dev *dlb2_dev); 635433956dSTimothy McDaniel int dlb2_pf_create_sched_domain(struct dlb2_hw *hw, 645433956dSTimothy McDaniel struct dlb2_create_sched_domain_args *args, 655433956dSTimothy McDaniel struct dlb2_cmd_response *resp); 665433956dSTimothy McDaniel int dlb2_pf_create_ldb_queue(struct dlb2_hw *hw, 675433956dSTimothy McDaniel u32 domain_id, 685433956dSTimothy McDaniel struct dlb2_create_ldb_queue_args *args, 695433956dSTimothy McDaniel struct dlb2_cmd_response *resp); 705433956dSTimothy McDaniel int dlb2_pf_create_dir_queue(struct dlb2_hw *hw, 715433956dSTimothy McDaniel u32 domain_id, 725433956dSTimothy McDaniel struct dlb2_create_dir_queue_args *args, 735433956dSTimothy McDaniel struct dlb2_cmd_response *resp); 745433956dSTimothy McDaniel int dlb2_pf_create_ldb_port(struct dlb2_hw *hw, 755433956dSTimothy McDaniel u32 domain_id, 765433956dSTimothy McDaniel struct dlb2_create_ldb_port_args *args, 775433956dSTimothy McDaniel uintptr_t cq_dma_base, 785433956dSTimothy McDaniel struct dlb2_cmd_response *resp); 795433956dSTimothy McDaniel int dlb2_pf_create_dir_port(struct dlb2_hw *hw, 805433956dSTimothy McDaniel u32 domain_id, 815433956dSTimothy McDaniel struct dlb2_create_dir_port_args *args, 825433956dSTimothy McDaniel uintptr_t cq_dma_base, 835433956dSTimothy McDaniel struct dlb2_cmd_response *resp); 845433956dSTimothy McDaniel int dlb2_pf_start_domain(struct dlb2_hw *hw, 855433956dSTimothy McDaniel u32 domain_id, 865433956dSTimothy McDaniel struct dlb2_start_domain_args *args, 875433956dSTimothy McDaniel struct dlb2_cmd_response *resp); 885433956dSTimothy McDaniel int dlb2_pf_enable_ldb_port(struct dlb2_hw *hw, 895433956dSTimothy McDaniel u32 domain_id, 905433956dSTimothy McDaniel struct dlb2_enable_ldb_port_args *args, 915433956dSTimothy McDaniel struct dlb2_cmd_response *resp); 925433956dSTimothy McDaniel int dlb2_pf_disable_ldb_port(struct dlb2_hw *hw, 935433956dSTimothy McDaniel u32 domain_id, 945433956dSTimothy McDaniel struct dlb2_disable_ldb_port_args *args, 955433956dSTimothy McDaniel struct dlb2_cmd_response *resp); 965433956dSTimothy McDaniel int dlb2_pf_enable_dir_port(struct dlb2_hw *hw, 975433956dSTimothy McDaniel u32 domain_id, 985433956dSTimothy McDaniel struct dlb2_enable_dir_port_args *args, 995433956dSTimothy McDaniel struct dlb2_cmd_response *resp); 1005433956dSTimothy McDaniel int dlb2_pf_disable_dir_port(struct dlb2_hw *hw, 1015433956dSTimothy McDaniel u32 domain_id, 1025433956dSTimothy McDaniel struct dlb2_disable_dir_port_args *args, 1035433956dSTimothy McDaniel struct dlb2_cmd_response *resp); 1045433956dSTimothy McDaniel int dlb2_pf_reset_domain(struct dlb2_hw *hw, u32 domain_id); 1055433956dSTimothy McDaniel int dlb2_pf_ldb_port_owned_by_domain(struct dlb2_hw *hw, 1065433956dSTimothy McDaniel u32 domain_id, 1075433956dSTimothy McDaniel u32 port_id); 1085433956dSTimothy McDaniel int dlb2_pf_dir_port_owned_by_domain(struct dlb2_hw *hw, 1095433956dSTimothy McDaniel u32 domain_id, 1105433956dSTimothy McDaniel u32 port_id); 1115433956dSTimothy McDaniel 1125433956dSTimothy McDaniel #endif /* __DLB2_MAIN_H */ 113