537d60de4e2ba21a72ddac1faec974ddd01ce535
[linux-2.6-microblaze.git] / drivers / net / ethernet / qlogic / qed / qed_dcbx.h
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  */
5
6 #ifndef _QED_DCBX_H
7 #define _QED_DCBX_H
8 #include <linux/types.h>
9 #include <linux/slab.h>
10 #include "qed.h"
11 #include "qed_hsi.h"
12 #include "qed_hw.h"
13 #include "qed_mcp.h"
14 #include "qed_reg_addr.h"
15
16 #define DCBX_CONFIG_MAX_APP_PROTOCOL    4
17
18 enum qed_mib_read_type {
19         QED_DCBX_OPERATIONAL_MIB,
20         QED_DCBX_REMOTE_MIB,
21         QED_DCBX_LOCAL_MIB,
22         QED_DCBX_REMOTE_LLDP_MIB,
23         QED_DCBX_LOCAL_LLDP_MIB
24 };
25
26 struct qed_dcbx_app_data {
27         bool enable;            /* DCB enabled */
28         u8 update;              /* Update indication */
29         u8 priority;            /* Priority */
30         u8 tc;                  /* Traffic Class */
31         bool dont_add_vlan0;    /* Do not insert a vlan tag with id 0 */
32 };
33
34 #define QED_DCBX_VERSION_DISABLED       0
35 #define QED_DCBX_VERSION_IEEE           1
36 #define QED_DCBX_VERSION_CEE            2
37
38 struct qed_dcbx_set {
39 #define QED_DCBX_OVERRIDE_STATE         BIT(0)
40 #define QED_DCBX_OVERRIDE_PFC_CFG       BIT(1)
41 #define QED_DCBX_OVERRIDE_ETS_CFG       BIT(2)
42 #define QED_DCBX_OVERRIDE_APP_CFG       BIT(3)
43 #define QED_DCBX_OVERRIDE_DSCP_CFG      BIT(4)
44         u32 override_flags;
45         bool enabled;
46         struct qed_dcbx_admin_params config;
47         u32 ver_num;
48 };
49
50 struct qed_dcbx_results {
51         bool dcbx_enabled;
52         u8 pf_id;
53         struct qed_dcbx_app_data arr[DCBX_MAX_PROTOCOL_TYPE];
54 };
55
56 struct qed_dcbx_app_metadata {
57         enum dcbx_protocol_type id;
58         char *name;
59         enum qed_pci_personality personality;
60 };
61
62 struct qed_dcbx_info {
63         struct lldp_status_params_s lldp_remote[LLDP_MAX_LLDP_AGENTS];
64         struct lldp_config_params_s lldp_local[LLDP_MAX_LLDP_AGENTS];
65         struct dcbx_local_params local_admin;
66         struct qed_dcbx_results results;
67         struct dcbx_mib operational;
68         struct dcbx_mib remote;
69         struct qed_dcbx_set set;
70         struct qed_dcbx_get get;
71         u8 dcbx_cap;
72 };
73
74 struct qed_dcbx_mib_meta_data {
75         struct lldp_config_params_s *lldp_local;
76         struct lldp_status_params_s *lldp_remote;
77         struct dcbx_local_params *local_admin;
78         struct dcbx_mib *mib;
79         size_t size;
80         u32 addr;
81 };
82
83 #ifdef CONFIG_DCB
84 int qed_dcbx_get_config_params(struct qed_hwfn *, struct qed_dcbx_set *);
85
86 int qed_dcbx_config_params(struct qed_hwfn *,
87                            struct qed_ptt *, struct qed_dcbx_set *, bool);
88 #endif
89
90 /* QED local interface routines */
91 int
92 qed_dcbx_mib_update_event(struct qed_hwfn *,
93                           struct qed_ptt *, enum qed_mib_read_type);
94
95 int qed_dcbx_info_alloc(struct qed_hwfn *p_hwfn);
96 void qed_dcbx_info_free(struct qed_hwfn *p_hwfn);
97 void qed_dcbx_set_pf_update_params(struct qed_dcbx_results *p_src,
98                                    struct pf_update_ramrod_data *p_dest);
99
100 #define QED_DCBX_DEFAULT_TC     0
101
102 u8 qed_dcbx_get_priority_tc(struct qed_hwfn *p_hwfn, u8 pri);
103 #endif