/* QLogic (R)NIC Driver/Library * Copyright (c) 2015-2016 QLogic Corporation * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU * General Public License (GPL) Version 2, available from the file * COPYING in the main directory of this source tree, or the * OpenIB.org BSD license below: * * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the following * conditions are met: * * - Redistributions of source code must retain the above * copyright notice, this list of conditions and the following * disclaimer. * * - Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials * provided with the distribution. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #ifndef _QED_DCBX_H #define _QED_DCBX_H #include #include #include "qed.h" #include "qed_hsi.h" #include "qed_hw.h" #include "qed_mcp.h" #include "qed_reg_addr.h" #define DCBX_CONFIG_MAX_APP_PROTOCOL 4 enum qed_mib_read_type { QED_DCBX_OPERATIONAL_MIB, QED_DCBX_REMOTE_MIB, QED_DCBX_LOCAL_MIB, QED_DCBX_REMOTE_LLDP_MIB, QED_DCBX_LOCAL_LLDP_MIB, QED_DCBX_LLDP_TLVS }; struct qed_dcbx_app_data { bool enable; /* DCB enabled */ u8 update; /* Update indication */ u8 priority; /* Priority */ u8 tc; /* Traffic Class */ bool dscp_enable; /* DSCP enabled */ u8 dscp_val; /* DSCP value */ bool dont_add_vlan0; /* Do not insert a vlan tag with id 0 */ }; #define QED_DCBX_VERSION_DISABLED 0 #define QED_DCBX_VERSION_IEEE 1 #define QED_DCBX_VERSION_CEE 2 #define QED_DCBX_VERSION_DYNAMIC 3 struct qed_dcbx_set { #define QED_DCBX_OVERRIDE_STATE (1 << 0) #define QED_DCBX_OVERRIDE_PFC_CFG (1 << 1) #define QED_DCBX_OVERRIDE_ETS_CFG (1 << 2) #define QED_DCBX_OVERRIDE_APP_CFG (1 << 3) #define QED_DCBX_OVERRIDE_DSCP_CFG (1 << 4) u32 override_flags; bool enabled; struct qed_dcbx_admin_params config; u32 ver_num; struct qed_dcbx_dscp_params dscp; }; struct qed_dcbx_results { bool dcbx_enabled; u8 pf_id; struct qed_dcbx_app_data arr[DCBX_MAX_PROTOCOL_TYPE]; }; struct qed_dcbx_app_metadata { enum dcbx_protocol_type id; char *name; enum qed_pci_personality personality; }; enum qed_lldp_agent { QED_LLDP_NEAREST_BRIDGE = 0, QED_LLDP_NEAREST_NON_TPMR_BRIDGE, QED_LLDP_NEAREST_CUSTOMER_BRIDGE, QED_LLDP_MAX_AGENTS }; struct qed_lldp_config_params { enum qed_lldp_agent agent; u8 tx_interval; u8 tx_hold; u8 tx_credit; bool rx_enable; bool tx_enable; u32 chassis_id_tlv[QED_LLDP_CHASSIS_ID_STAT_LEN]; u32 port_id_tlv[QED_LLDP_PORT_ID_STAT_LEN]; }; #define QED_LLDP_SYS_TLV_SIZE 256 struct qed_lldp_sys_tlvs { bool discard_mandatory_tlv; u8 buf[QED_LLDP_SYS_TLV_SIZE]; u16 buf_size; }; struct qed_lldp_stats { enum qed_lldp_agent agent; u32 tx_frames; u32 rx_frames; u32 rx_discards; u32 rx_age_outs; }; int qed_dcbx_query_params(struct qed_hwfn *p_hwfn, struct qed_dcbx_get *p_get, enum qed_mib_read_type type); int qed_dcbx_get_config_params(struct qed_hwfn *p_hwfn, struct qed_dcbx_set *params); int qed_dcbx_config_params(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt, struct qed_dcbx_set *params, bool hw_commit); int qed_lldp_register_tlv(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt, enum qed_lldp_agent agent, u8 tlv_type); int qed_lldp_get_params(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt, struct qed_lldp_config_params *p_params); int qed_lldp_set_params(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt, struct qed_lldp_config_params *p_params); int qed_lldp_set_system_tlvs(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt, struct qed_lldp_sys_tlvs *p_params); /* Returns priority value for a given dscp index */ int qed_dcbx_get_dscp_priority(struct qed_hwfn *p_hwfn, u8 dscp_index, u8 * p_dscp_pri); /* Sets priority value for a given dscp index */ int qed_dcbx_set_dscp_priority(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt, u8 dscp_index, u8 pri_val); int qed_lldp_get_stats(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt, struct qed_lldp_stats *p_params); #define QED_DCBX_DSCP_DISABLED 0XFF struct qed_dcbx_info { struct lldp_status_params_s lldp_remote[LLDP_MAX_LLDP_AGENTS]; struct lldp_config_params_s lldp_local[LLDP_MAX_LLDP_AGENTS]; struct dcbx_local_params local_admin; struct qed_dcbx_results results; struct dcb_dscp_map dscp_map; bool dscp_nig_update; struct dcbx_mib operational; struct dcbx_mib remote; struct qed_dcbx_set set; struct qed_dcbx_get get; u8 dcbx_cap; u16 iwarp_port; }; struct qed_dcbx_mib_meta_data { struct lldp_config_params_s *lldp_local; struct lldp_status_params_s *lldp_remote; struct lldp_received_tlvs_s *lldp_tlvs; struct dcbx_local_params *local_admin; struct dcb_dscp_map *dscp_map; struct dcbx_mib *mib; size_t size; u32 addr; }; /* QED local interface routines */ int qed_dcbx_mib_update_event(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt, enum qed_mib_read_type type); int qed_dcbx_info_alloc(struct qed_hwfn *p_hwfn); void qed_dcbx_info_free(struct qed_hwfn *p_hwfn); void qed_dcbx_set_pf_update_params(struct qed_dcbx_results *p_src, struct pf_update_ramrod_data *p_dest); /* Returns TOS value for a given priority */ u8 qed_dcbx_get_dscp_value(struct qed_hwfn *p_hwfn, u8 pri); int qed_lldp_mib_update_event(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt); #endif