36c2d0965e95cabccdc965cc46d1101eff8c3de8
[dpdk.git] / drivers / net / ice / ice_dcf.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2020 Intel Corporation
3  */
4
5 #ifndef _ICE_DCF_H_
6 #define _ICE_DCF_H_
7
8 #include <ethdev_driver.h>
9 #include <rte_tm_driver.h>
10
11 #include <iavf_prototype.h>
12 #include <iavf_adminq_cmd.h>
13 #include <iavf_type.h>
14
15 #include "base/ice_type.h"
16 #include "ice_logs.h"
17
18 struct dcf_virtchnl_cmd {
19         TAILQ_ENTRY(dcf_virtchnl_cmd) next;
20
21         enum virtchnl_ops v_op;
22         enum iavf_status v_ret;
23
24         uint16_t req_msglen;
25         uint8_t *req_msg;
26
27         uint16_t rsp_msglen;
28         uint16_t rsp_buflen;
29         uint8_t *rsp_msgbuf;
30
31         volatile int pending;
32 };
33
34 struct ice_dcf_tm_shaper_profile {
35         TAILQ_ENTRY(ice_dcf_tm_shaper_profile) node;
36         uint32_t shaper_profile_id;
37         uint32_t reference_count;
38         struct rte_tm_shaper_params profile;
39 };
40
41 TAILQ_HEAD(ice_dcf_shaper_profile_list, ice_dcf_tm_shaper_profile);
42
43 /* Struct to store Traffic Manager node configuration. */
44 struct ice_dcf_tm_node {
45         TAILQ_ENTRY(ice_dcf_tm_node) node;
46         uint32_t id;
47         uint32_t tc;
48         uint32_t priority;
49         uint32_t weight;
50         uint32_t reference_count;
51         struct ice_dcf_tm_node *parent;
52         struct ice_dcf_tm_shaper_profile *shaper_profile;
53         struct rte_tm_node_params params;
54 };
55
56 TAILQ_HEAD(ice_dcf_tm_node_list, ice_dcf_tm_node);
57
58 /* node type of Traffic Manager */
59 enum ice_dcf_tm_node_type {
60         ICE_DCF_TM_NODE_TYPE_PORT,
61         ICE_DCF_TM_NODE_TYPE_TC,
62         ICE_DCF_TM_NODE_TYPE_VSI,
63         ICE_DCF_TM_NODE_TYPE_MAX,
64 };
65
66 /* Struct to store all the Traffic Manager configuration. */
67 struct ice_dcf_tm_conf {
68         struct ice_dcf_shaper_profile_list shaper_profile_list;
69         struct ice_dcf_tm_node *root; /* root node - port */
70         struct ice_dcf_tm_node_list tc_list; /* node list for all the TCs */
71         struct ice_dcf_tm_node_list vsi_list; /* node list for all the queues */
72         uint32_t nb_tc_node;
73         uint32_t nb_vsi_node;
74         bool committed;
75 };
76
77 struct ice_dcf_hw {
78         struct iavf_hw avf;
79
80         rte_spinlock_t vc_cmd_send_lock;
81         rte_spinlock_t vc_cmd_queue_lock;
82         TAILQ_HEAD(, dcf_virtchnl_cmd) vc_cmd_queue;
83         void (*vc_event_msg_cb)(struct ice_dcf_hw *dcf_hw,
84                                 uint8_t *msg, uint16_t msglen);
85
86         uint8_t *arq_buf;
87
88         uint16_t num_vfs;
89         uint16_t *vf_vsi_map;
90         uint16_t pf_vsi_id;
91
92         struct ice_dcf_tm_conf tm_conf;
93         struct virtchnl_dcf_bw_cfg_list **qos_bw_cfg;
94         struct ice_aqc_port_ets_elem *ets_config;
95         struct virtchnl_version_info virtchnl_version;
96         struct virtchnl_vf_resource *vf_res; /* VF resource */
97         struct virtchnl_vsi_resource *vsi_res; /* LAN VSI */
98         uint16_t vsi_id;
99
100         struct rte_eth_dev *eth_dev;
101         uint8_t *rss_lut;
102         uint8_t *rss_key;
103         uint64_t supported_rxdid;
104         uint16_t num_queue_pairs;
105
106         uint16_t msix_base;
107         uint16_t nb_msix;
108         uint16_t rxq_map[16];
109         struct virtchnl_eth_stats eth_stats_offset;
110
111         /* Link status */
112         bool link_up;
113         uint32_t link_speed;
114 };
115
116 int ice_dcf_execute_virtchnl_cmd(struct ice_dcf_hw *hw,
117                                  struct dcf_virtchnl_cmd *cmd);
118 int ice_dcf_send_aq_cmd(void *dcf_hw, struct ice_aq_desc *desc,
119                         void *buf, uint16_t buf_size);
120 int ice_dcf_handle_vsi_update_event(struct ice_dcf_hw *hw);
121 int ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw);
122 void ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw);
123 int ice_dcf_init_rss(struct ice_dcf_hw *hw);
124 int ice_dcf_configure_queues(struct ice_dcf_hw *hw);
125 int ice_dcf_config_irq_map(struct ice_dcf_hw *hw);
126 int ice_dcf_switch_queue(struct ice_dcf_hw *hw, uint16_t qid, bool rx, bool on);
127 int ice_dcf_disable_queues(struct ice_dcf_hw *hw);
128 int ice_dcf_query_stats(struct ice_dcf_hw *hw,
129                         struct virtchnl_eth_stats *pstats);
130 int ice_dcf_add_del_all_mac_addr(struct ice_dcf_hw *hw, bool add);
131 int ice_dcf_link_update(struct rte_eth_dev *dev,
132                     __rte_unused int wait_to_complete);
133 void ice_dcf_tm_conf_init(struct rte_eth_dev *dev);
134 void ice_dcf_tm_conf_uninit(struct rte_eth_dev *dev);
135 int ice_dcf_replay_vf_bw(struct ice_dcf_hw *hw, uint16_t vf_id);
136 int ice_dcf_clear_bw(struct ice_dcf_hw *hw);
137
138 #endif /* _ICE_DCF_H_ */