1 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
2 /* QLogic qed NIC Driver
3 * Copyright (c) 2015-2017 QLogic Corporation
4 * Copyright (c) 2019-2020 Marvell International Ltd.
9 #include <linux/types.h>
10 #include <linux/slab.h>
15 #include "qed_reg_addr.h"
17 #define DCBX_CONFIG_MAX_APP_PROTOCOL 4
19 enum qed_mib_read_type {
20 QED_DCBX_OPERATIONAL_MIB,
23 QED_DCBX_REMOTE_LLDP_MIB,
24 QED_DCBX_LOCAL_LLDP_MIB
27 struct qed_dcbx_app_data {
28 bool enable; /* DCB enabled */
29 u8 update; /* Update indication */
30 u8 priority; /* Priority */
31 u8 tc; /* Traffic Class */
32 bool dont_add_vlan0; /* Do not insert a vlan tag with id 0 */
35 #define QED_DCBX_VERSION_DISABLED 0
36 #define QED_DCBX_VERSION_IEEE 1
37 #define QED_DCBX_VERSION_CEE 2
40 #define QED_DCBX_OVERRIDE_STATE BIT(0)
41 #define QED_DCBX_OVERRIDE_PFC_CFG BIT(1)
42 #define QED_DCBX_OVERRIDE_ETS_CFG BIT(2)
43 #define QED_DCBX_OVERRIDE_APP_CFG BIT(3)
44 #define QED_DCBX_OVERRIDE_DSCP_CFG BIT(4)
47 struct qed_dcbx_admin_params config;
51 struct qed_dcbx_results {
54 struct qed_dcbx_app_data arr[DCBX_MAX_PROTOCOL_TYPE];
57 struct qed_dcbx_app_metadata {
58 enum dcbx_protocol_type id;
60 enum qed_pci_personality personality;
63 struct qed_dcbx_info {
64 struct lldp_status_params_s lldp_remote[LLDP_MAX_LLDP_AGENTS];
65 struct lldp_config_params_s lldp_local[LLDP_MAX_LLDP_AGENTS];
66 struct dcbx_local_params local_admin;
67 struct qed_dcbx_results results;
68 struct dcbx_mib operational;
69 struct dcbx_mib remote;
70 struct qed_dcbx_set set;
71 struct qed_dcbx_get get;
75 struct qed_dcbx_mib_meta_data {
76 struct lldp_config_params_s *lldp_local;
77 struct lldp_status_params_s *lldp_remote;
78 struct dcbx_local_params *local_admin;
84 extern const struct qed_eth_dcbnl_ops qed_dcbnl_ops_pass;
87 int qed_dcbx_get_config_params(struct qed_hwfn *, struct qed_dcbx_set *);
89 int qed_dcbx_config_params(struct qed_hwfn *,
90 struct qed_ptt *, struct qed_dcbx_set *, bool);
93 /* QED local interface routines */
95 qed_dcbx_mib_update_event(struct qed_hwfn *,
96 struct qed_ptt *, enum qed_mib_read_type);
98 int qed_dcbx_info_alloc(struct qed_hwfn *p_hwfn);
99 void qed_dcbx_info_free(struct qed_hwfn *p_hwfn);
100 void qed_dcbx_set_pf_update_params(struct qed_dcbx_results *p_src,
101 struct pf_update_ramrod_data *p_dest);
103 #define QED_DCBX_DEFAULT_TC 0
105 u8 qed_dcbx_get_priority_tc(struct qed_hwfn *p_hwfn, u8 pri);