xref: /dpdk/drivers/net/intel/ice/ice_dcf.h (revision c1d145834f287aa8cf53de914618a7312f2c360e)
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 /* ICE_DCF_DEV_PRIVATE_TO */
19 #define ICE_DCF_DEV_PRIVATE_TO_ADAPTER(adapter) \
20 	((struct ice_dcf_adapter *)adapter)
21 #define ICE_DCF_DEV_PRIVATE_TO_VF(adapter) \
22 	(&((struct ice_dcf_adapter *)adapter)->vf)
23 
24 struct dcf_virtchnl_cmd {
25 	TAILQ_ENTRY(dcf_virtchnl_cmd) next;
26 
27 	enum virtchnl_ops v_op;
28 	enum iavf_status v_ret;
29 
30 	uint16_t req_msglen;
31 	uint8_t *req_msg;
32 
33 	uint16_t rsp_msglen;
34 	uint16_t rsp_buflen;
35 	uint8_t *rsp_msgbuf;
36 
37 	volatile int pending;
38 };
39 
40 struct ice_dcf_tm_shaper_profile {
41 	TAILQ_ENTRY(ice_dcf_tm_shaper_profile) node;
42 	uint32_t shaper_profile_id;
43 	uint32_t reference_count;
44 	struct rte_tm_shaper_params profile;
45 };
46 
47 TAILQ_HEAD(ice_dcf_shaper_profile_list, ice_dcf_tm_shaper_profile);
48 
49 /* Struct to store Traffic Manager node configuration. */
50 struct ice_dcf_tm_node {
51 	TAILQ_ENTRY(ice_dcf_tm_node) node;
52 	uint32_t id;
53 	uint32_t tc;
54 	uint32_t priority;
55 	uint32_t weight;
56 	uint32_t reference_count;
57 	struct ice_dcf_tm_node *parent;
58 	struct ice_dcf_tm_shaper_profile *shaper_profile;
59 	struct rte_tm_node_params params;
60 };
61 
62 TAILQ_HEAD(ice_dcf_tm_node_list, ice_dcf_tm_node);
63 
64 /* node type of Traffic Manager */
65 enum ice_dcf_tm_node_type {
66 	ICE_DCF_TM_NODE_TYPE_PORT,
67 	ICE_DCF_TM_NODE_TYPE_TC,
68 	ICE_DCF_TM_NODE_TYPE_VSI,
69 	ICE_DCF_TM_NODE_TYPE_MAX,
70 };
71 
72 /* Struct to store all the Traffic Manager configuration. */
73 struct ice_dcf_tm_conf {
74 	struct ice_dcf_shaper_profile_list shaper_profile_list;
75 	struct ice_dcf_tm_node *root; /* root node - port */
76 	struct ice_dcf_tm_node_list tc_list; /* node list for all the TCs */
77 	struct ice_dcf_tm_node_list vsi_list; /* node list for all the queues */
78 	uint32_t nb_tc_node;
79 	uint32_t nb_vsi_node;
80 	bool committed;
81 };
82 
83 struct ice_dcf_eth_stats {
84 	u64 rx_bytes;			/* gorc */
85 	u64 rx_unicast;			/* uprc */
86 	u64 rx_multicast;		/* mprc */
87 	u64 rx_broadcast;		/* bprc */
88 	u64 rx_discards;		/* rdpc */
89 	u64 rx_unknown_protocol;	/* rupp */
90 	u64 tx_bytes;			/* gotc */
91 	u64 tx_unicast;			/* uptc */
92 	u64 tx_multicast;		/* mptc */
93 	u64 tx_broadcast;		/* bptc */
94 	u64 tx_discards;		/* tdpc */
95 	u64 tx_errors;			/* tepc */
96 	u64 rx_no_desc;			/* repc */
97 	u64 rx_errors;			/* repc */
98 };
99 struct ice_dcf_hw {
100 	struct iavf_hw avf;
101 
102 	rte_spinlock_t vc_cmd_send_lock;
103 	rte_spinlock_t vc_cmd_queue_lock;
104 	TAILQ_HEAD(, dcf_virtchnl_cmd) vc_cmd_queue;
105 	void (*vc_event_msg_cb)(struct ice_dcf_hw *dcf_hw,
106 				uint8_t *msg, uint16_t msglen);
107 
108 	RTE_ATOMIC(int) vsi_update_thread_num;
109 
110 	uint8_t *arq_buf;
111 
112 	uint16_t num_vfs;
113 	uint16_t *vf_vsi_map;
114 	uint16_t pf_vsi_id;
115 
116 	struct ice_dcf_tm_conf tm_conf;
117 	struct virtchnl_dcf_bw_cfg_list **qos_bw_cfg;
118 	struct ice_aqc_port_ets_elem *ets_config;
119 	struct virtchnl_version_info virtchnl_version;
120 	struct virtchnl_vf_resource *vf_res; /* VF resource */
121 	struct virtchnl_vsi_resource *vsi_res; /* LAN VSI */
122 	uint16_t vsi_id;
123 
124 	struct rte_eth_dev *eth_dev;
125 	uint8_t *rss_lut;
126 	uint8_t *rss_key;
127 	uint64_t supported_rxdid;
128 	uint16_t num_queue_pairs;
129 
130 	uint16_t msix_base;
131 	uint16_t nb_msix;
132 	uint16_t rxq_map[16];
133 	struct virtchnl_eth_stats eth_stats_offset;
134 	struct virtchnl_vlan_caps vlan_v2_caps;
135 
136 	/* Link status */
137 	bool link_up;
138 	uint32_t link_speed;
139 
140 	bool resetting;
141 };
142 
143 int ice_dcf_execute_virtchnl_cmd(struct ice_dcf_hw *hw,
144 				 struct dcf_virtchnl_cmd *cmd);
145 int ice_dcf_send_aq_cmd(void *dcf_hw, struct ice_aq_desc *desc,
146 			void *buf, uint16_t buf_size);
147 int ice_dcf_handle_vsi_update_event(struct ice_dcf_hw *hw);
148 int ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw);
149 void ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw);
150 int ice_dcf_configure_rss_key(struct ice_dcf_hw *hw);
151 int ice_dcf_configure_rss_lut(struct ice_dcf_hw *hw);
152 int ice_dcf_add_del_rss_cfg(struct ice_dcf_hw *hw,
153 		     struct virtchnl_rss_cfg *rss_cfg, bool add);
154 int ice_dcf_set_hena(struct ice_dcf_hw *hw, uint64_t hena);
155 int ice_dcf_rss_hash_set(struct ice_dcf_hw *hw, uint64_t rss_hf, bool add);
156 int ice_dcf_init_rss(struct ice_dcf_hw *hw);
157 int ice_dcf_configure_queues(struct ice_dcf_hw *hw);
158 int ice_dcf_config_irq_map(struct ice_dcf_hw *hw);
159 int ice_dcf_switch_queue(struct ice_dcf_hw *hw, uint16_t qid, bool rx, bool on);
160 int ice_dcf_disable_queues(struct ice_dcf_hw *hw);
161 int ice_dcf_query_stats(struct ice_dcf_hw *hw,
162 			struct virtchnl_eth_stats *pstats);
163 int ice_dcf_add_del_all_mac_addr(struct ice_dcf_hw *hw,
164 				 struct rte_ether_addr *addr, bool add,
165 				 uint8_t type);
166 int ice_dcf_link_update(struct rte_eth_dev *dev,
167 		    __rte_unused int wait_to_complete);
168 void ice_dcf_tm_conf_init(struct rte_eth_dev *dev);
169 void ice_dcf_tm_conf_uninit(struct rte_eth_dev *dev);
170 int ice_dcf_replay_vf_bw(struct ice_dcf_hw *hw, uint16_t vf_id);
171 int ice_dcf_clear_bw(struct ice_dcf_hw *hw);
172 
173 #endif /* _ICE_DCF_H_ */
174