Linux-libre 4.9.86-gnu
[librecmc/linux-libre.git] / drivers / net / ethernet / qlogic / qed / qed_dcbx.h
1 /* QLogic qed NIC Driver
2  * Copyright (c) 2015 QLogic Corporation
3  *
4  * This software is available under the terms of the GNU General Public License
5  * (GPL) Version 2, available from the file COPYING in the main directory of
6  * this source tree.
7  */
8
9 #ifndef _QED_DCBX_H
10 #define _QED_DCBX_H
11 #include <linux/types.h>
12 #include <linux/slab.h>
13 #include "qed.h"
14 #include "qed_hsi.h"
15 #include "qed_hw.h"
16 #include "qed_mcp.h"
17 #include "qed_reg_addr.h"
18
19 #define DCBX_CONFIG_MAX_APP_PROTOCOL    4
20
21 enum qed_mib_read_type {
22         QED_DCBX_OPERATIONAL_MIB,
23         QED_DCBX_REMOTE_MIB,
24         QED_DCBX_LOCAL_MIB,
25         QED_DCBX_REMOTE_LLDP_MIB,
26         QED_DCBX_LOCAL_LLDP_MIB
27 };
28
29 struct qed_dcbx_app_data {
30         bool enable;            /* DCB enabled */
31         bool update;            /* Update indication */
32         u8 priority;            /* Priority */
33         u8 tc;                  /* Traffic Class */
34 };
35
36 #ifdef CONFIG_DCB
37 #define QED_DCBX_VERSION_DISABLED       0
38 #define QED_DCBX_VERSION_IEEE           1
39 #define QED_DCBX_VERSION_CEE            2
40
41 struct qed_dcbx_set {
42 #define QED_DCBX_OVERRIDE_STATE         BIT(0)
43 #define QED_DCBX_OVERRIDE_PFC_CFG       BIT(1)
44 #define QED_DCBX_OVERRIDE_ETS_CFG       BIT(2)
45 #define QED_DCBX_OVERRIDE_APP_CFG       BIT(3)
46 #define QED_DCBX_OVERRIDE_DSCP_CFG      BIT(4)
47         u32 override_flags;
48         bool enabled;
49         struct qed_dcbx_admin_params config;
50         u32 ver_num;
51 };
52 #endif
53
54 struct qed_dcbx_results {
55         bool dcbx_enabled;
56         u8 pf_id;
57         struct qed_dcbx_app_data arr[DCBX_MAX_PROTOCOL_TYPE];
58 };
59
60 struct qed_dcbx_app_metadata {
61         enum dcbx_protocol_type id;
62         char *name;
63         enum qed_pci_personality personality;
64 };
65
66 #define QED_MFW_GET_FIELD(name, field) \
67         (((name) & (field ## _MASK)) >> (field ## _SHIFT))
68
69 struct qed_dcbx_info {
70         struct lldp_status_params_s lldp_remote[LLDP_MAX_LLDP_AGENTS];
71         struct lldp_config_params_s lldp_local[LLDP_MAX_LLDP_AGENTS];
72         struct dcbx_local_params local_admin;
73         struct qed_dcbx_results results;
74         struct dcbx_mib operational;
75         struct dcbx_mib remote;
76 #ifdef CONFIG_DCB
77         struct qed_dcbx_set set;
78 #endif
79         u8 dcbx_cap;
80 };
81
82 struct qed_dcbx_mib_meta_data {
83         struct lldp_config_params_s *lldp_local;
84         struct lldp_status_params_s *lldp_remote;
85         struct dcbx_local_params *local_admin;
86         struct dcbx_mib *mib;
87         size_t size;
88         u32 addr;
89 };
90
91 #ifdef CONFIG_DCB
92 int qed_dcbx_get_config_params(struct qed_hwfn *, struct qed_dcbx_set *);
93
94 int qed_dcbx_config_params(struct qed_hwfn *,
95                            struct qed_ptt *, struct qed_dcbx_set *, bool);
96 #endif
97
98 /* QED local interface routines */
99 int
100 qed_dcbx_mib_update_event(struct qed_hwfn *,
101                           struct qed_ptt *, enum qed_mib_read_type);
102
103 int qed_dcbx_info_alloc(struct qed_hwfn *p_hwfn);
104 void qed_dcbx_info_free(struct qed_hwfn *, struct qed_dcbx_info *);
105 void qed_dcbx_set_pf_update_params(struct qed_dcbx_results *p_src,
106                                    struct pf_update_ramrod_data *p_dest);
107
108 #endif