18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */ 28c2ecf20Sopenharmony_ci/* QLogic qed NIC Driver 38c2ecf20Sopenharmony_ci * Copyright (c) 2015-2017 QLogic Corporation 48c2ecf20Sopenharmony_ci * Copyright (c) 2019-2020 Marvell International Ltd. 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#ifndef _QED_DCBX_H 88c2ecf20Sopenharmony_ci#define _QED_DCBX_H 98c2ecf20Sopenharmony_ci#include <linux/types.h> 108c2ecf20Sopenharmony_ci#include <linux/slab.h> 118c2ecf20Sopenharmony_ci#include "qed.h" 128c2ecf20Sopenharmony_ci#include "qed_hsi.h" 138c2ecf20Sopenharmony_ci#include "qed_hw.h" 148c2ecf20Sopenharmony_ci#include "qed_mcp.h" 158c2ecf20Sopenharmony_ci#include "qed_reg_addr.h" 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#define DCBX_CONFIG_MAX_APP_PROTOCOL 4 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_cienum qed_mib_read_type { 208c2ecf20Sopenharmony_ci QED_DCBX_OPERATIONAL_MIB, 218c2ecf20Sopenharmony_ci QED_DCBX_REMOTE_MIB, 228c2ecf20Sopenharmony_ci QED_DCBX_LOCAL_MIB, 238c2ecf20Sopenharmony_ci QED_DCBX_REMOTE_LLDP_MIB, 248c2ecf20Sopenharmony_ci QED_DCBX_LOCAL_LLDP_MIB 258c2ecf20Sopenharmony_ci}; 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_cistruct qed_dcbx_app_data { 288c2ecf20Sopenharmony_ci bool enable; /* DCB enabled */ 298c2ecf20Sopenharmony_ci u8 update; /* Update indication */ 308c2ecf20Sopenharmony_ci u8 priority; /* Priority */ 318c2ecf20Sopenharmony_ci u8 tc; /* Traffic Class */ 328c2ecf20Sopenharmony_ci bool dont_add_vlan0; /* Do not insert a vlan tag with id 0 */ 338c2ecf20Sopenharmony_ci}; 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci#define QED_DCBX_VERSION_DISABLED 0 368c2ecf20Sopenharmony_ci#define QED_DCBX_VERSION_IEEE 1 378c2ecf20Sopenharmony_ci#define QED_DCBX_VERSION_CEE 2 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_cistruct qed_dcbx_set { 408c2ecf20Sopenharmony_ci#define QED_DCBX_OVERRIDE_STATE BIT(0) 418c2ecf20Sopenharmony_ci#define QED_DCBX_OVERRIDE_PFC_CFG BIT(1) 428c2ecf20Sopenharmony_ci#define QED_DCBX_OVERRIDE_ETS_CFG BIT(2) 438c2ecf20Sopenharmony_ci#define QED_DCBX_OVERRIDE_APP_CFG BIT(3) 448c2ecf20Sopenharmony_ci#define QED_DCBX_OVERRIDE_DSCP_CFG BIT(4) 458c2ecf20Sopenharmony_ci u32 override_flags; 468c2ecf20Sopenharmony_ci bool enabled; 478c2ecf20Sopenharmony_ci struct qed_dcbx_admin_params config; 488c2ecf20Sopenharmony_ci u32 ver_num; 498c2ecf20Sopenharmony_ci}; 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_cistruct qed_dcbx_results { 528c2ecf20Sopenharmony_ci bool dcbx_enabled; 538c2ecf20Sopenharmony_ci u8 pf_id; 548c2ecf20Sopenharmony_ci struct qed_dcbx_app_data arr[DCBX_MAX_PROTOCOL_TYPE]; 558c2ecf20Sopenharmony_ci}; 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_cistruct qed_dcbx_app_metadata { 588c2ecf20Sopenharmony_ci enum dcbx_protocol_type id; 598c2ecf20Sopenharmony_ci char *name; 608c2ecf20Sopenharmony_ci enum qed_pci_personality personality; 618c2ecf20Sopenharmony_ci}; 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_cistruct qed_dcbx_info { 648c2ecf20Sopenharmony_ci struct lldp_status_params_s lldp_remote[LLDP_MAX_LLDP_AGENTS]; 658c2ecf20Sopenharmony_ci struct lldp_config_params_s lldp_local[LLDP_MAX_LLDP_AGENTS]; 668c2ecf20Sopenharmony_ci struct dcbx_local_params local_admin; 678c2ecf20Sopenharmony_ci struct qed_dcbx_results results; 688c2ecf20Sopenharmony_ci struct dcbx_mib operational; 698c2ecf20Sopenharmony_ci struct dcbx_mib remote; 708c2ecf20Sopenharmony_ci struct qed_dcbx_set set; 718c2ecf20Sopenharmony_ci struct qed_dcbx_get get; 728c2ecf20Sopenharmony_ci u8 dcbx_cap; 738c2ecf20Sopenharmony_ci}; 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_cistruct qed_dcbx_mib_meta_data { 768c2ecf20Sopenharmony_ci struct lldp_config_params_s *lldp_local; 778c2ecf20Sopenharmony_ci struct lldp_status_params_s *lldp_remote; 788c2ecf20Sopenharmony_ci struct dcbx_local_params *local_admin; 798c2ecf20Sopenharmony_ci struct dcbx_mib *mib; 808c2ecf20Sopenharmony_ci size_t size; 818c2ecf20Sopenharmony_ci u32 addr; 828c2ecf20Sopenharmony_ci}; 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ciextern const struct qed_eth_dcbnl_ops qed_dcbnl_ops_pass; 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ci#ifdef CONFIG_DCB 878c2ecf20Sopenharmony_ciint qed_dcbx_get_config_params(struct qed_hwfn *, struct qed_dcbx_set *); 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ciint qed_dcbx_config_params(struct qed_hwfn *, 908c2ecf20Sopenharmony_ci struct qed_ptt *, struct qed_dcbx_set *, bool); 918c2ecf20Sopenharmony_ci#endif 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci/* QED local interface routines */ 948c2ecf20Sopenharmony_ciint 958c2ecf20Sopenharmony_ciqed_dcbx_mib_update_event(struct qed_hwfn *, 968c2ecf20Sopenharmony_ci struct qed_ptt *, enum qed_mib_read_type); 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ciint qed_dcbx_info_alloc(struct qed_hwfn *p_hwfn); 998c2ecf20Sopenharmony_civoid qed_dcbx_info_free(struct qed_hwfn *p_hwfn); 1008c2ecf20Sopenharmony_civoid qed_dcbx_set_pf_update_params(struct qed_dcbx_results *p_src, 1018c2ecf20Sopenharmony_ci struct pf_update_ramrod_data *p_dest); 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci#define QED_DCBX_DEFAULT_TC 0 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ciu8 qed_dcbx_get_priority_tc(struct qed_hwfn *p_hwfn, u8 pri); 1068c2ecf20Sopenharmony_ci#endif 107