1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2020 Intel Corporation
8 #include <ethdev_driver.h>
9 #include <rte_tm_driver.h>
11 #include <iavf_prototype.h>
12 #include <iavf_adminq_cmd.h>
13 #include <iavf_type.h>
15 #include "base/ice_type.h"
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)
24 struct dcf_virtchnl_cmd {
25 TAILQ_ENTRY(dcf_virtchnl_cmd) next;
27 enum virtchnl_ops v_op;
28 enum iavf_status v_ret;
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;
47 TAILQ_HEAD(ice_dcf_shaper_profile_list, ice_dcf_tm_shaper_profile);
49 /* Struct to store Traffic Manager node configuration. */
50 struct ice_dcf_tm_node {
51 TAILQ_ENTRY(ice_dcf_tm_node) node;
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;
62 TAILQ_HEAD(ice_dcf_tm_node_list, ice_dcf_tm_node);
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,
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 */
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 */
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);
111 uint16_t *vf_vsi_map;
114 struct ice_dcf_tm_conf tm_conf;
115 struct virtchnl_dcf_bw_cfg_list **qos_bw_cfg;
116 struct ice_aqc_port_ets_elem *ets_config;
117 struct virtchnl_version_info virtchnl_version;
118 struct virtchnl_vf_resource *vf_res; /* VF resource */
119 struct virtchnl_vsi_resource *vsi_res; /* LAN VSI */
122 struct rte_eth_dev *eth_dev;
125 uint64_t supported_rxdid;
126 uint16_t num_queue_pairs;
130 uint16_t rxq_map[16];
131 struct virtchnl_eth_stats eth_stats_offset;
140 int ice_dcf_execute_virtchnl_cmd(struct ice_dcf_hw *hw,
141 struct dcf_virtchnl_cmd *cmd);
142 int ice_dcf_send_aq_cmd(void *dcf_hw, struct ice_aq_desc *desc,
143 void *buf, uint16_t buf_size);
144 int ice_dcf_handle_vsi_update_event(struct ice_dcf_hw *hw);
145 int ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw);
146 void ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw);
147 int ice_dcf_configure_rss_key(struct ice_dcf_hw *hw);
148 int ice_dcf_configure_rss_lut(struct ice_dcf_hw *hw);
149 int ice_dcf_init_rss(struct ice_dcf_hw *hw);
150 int ice_dcf_configure_queues(struct ice_dcf_hw *hw);
151 int ice_dcf_config_irq_map(struct ice_dcf_hw *hw);
152 int ice_dcf_switch_queue(struct ice_dcf_hw *hw, uint16_t qid, bool rx, bool on);
153 int ice_dcf_disable_queues(struct ice_dcf_hw *hw);
154 int ice_dcf_query_stats(struct ice_dcf_hw *hw,
155 struct virtchnl_eth_stats *pstats);
156 int ice_dcf_add_del_all_mac_addr(struct ice_dcf_hw *hw,
157 struct rte_ether_addr *addr, bool add,
159 int ice_dcf_link_update(struct rte_eth_dev *dev,
160 __rte_unused int wait_to_complete);
161 void ice_dcf_tm_conf_init(struct rte_eth_dev *dev);
162 void ice_dcf_tm_conf_uninit(struct rte_eth_dev *dev);
163 int ice_dcf_replay_vf_bw(struct ice_dcf_hw *hw, uint16_t vf_id);
164 int ice_dcf_clear_bw(struct ice_dcf_hw *hw);
166 #endif /* _ICE_DCF_H_ */