xref: /dpdk/drivers/net/hns3/hns3_common.h (revision ac72aae60f71b8716f65d1e2daf531a5ca38c998)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(C) 2021 HiSilicon Limited
3  */
4 
5 #ifndef HNS3_COMMON_H
6 #define HNS3_COMMON_H
7 
8 #include <sys/time.h>
9 
10 #include "hns3_ethdev.h"
11 
12 #define HNS3_CONVERT_TO_DECIMAL 10
13 #define HNS3_CONVERT_TO_HEXADECIMAL 16
14 
15 enum {
16 	HNS3_IO_FUNC_HINT_NONE = 0,
17 	HNS3_IO_FUNC_HINT_VEC,
18 	HNS3_IO_FUNC_HINT_SVE,
19 	HNS3_IO_FUNC_HINT_SIMPLE,
20 	HNS3_IO_FUNC_HINT_COMMON
21 };
22 
23 #define HNS3_DEVARG_RX_FUNC_HINT	"rx_func_hint"
24 #define HNS3_DEVARG_TX_FUNC_HINT	"tx_func_hint"
25 
26 #define HNS3_DEVARG_DEV_CAPS_MASK	"dev_caps_mask"
27 
28 #define HNS3_DEVARG_MBX_TIME_LIMIT_MS	"mbx_time_limit_ms"
29 
30 #define HNS3_DEVARG_FDIR_VLAN_MATCH_MODE	"fdir_vlan_match_mode"
31 #define HNS3_DEVARG_FDIR_TUPLE_CONFIG	"fdir_tuple_config"
32 #define HNS3_DEVARG_FDIR_INDEX_CONFIG	"fdir_index_config"
33 
34 #define MSEC_PER_SEC              1000L
35 #define USEC_PER_MSEC             1000L
36 
37 int hns3_fw_version_get(struct rte_eth_dev *eth_dev, char *fw_version,
38 			size_t fw_size);
39 int hns3_dev_infos_get(struct rte_eth_dev *eth_dev,
40 		       struct rte_eth_dev_info *info);
41 
42 void hns3_clock_gettime(struct timeval *tv);
43 uint64_t hns3_clock_calctime_ms(struct timeval *tv);
44 uint64_t hns3_clock_gettime_ms(void);
45 
46 void hns3_parse_devargs(struct rte_eth_dev *dev);
47 
48 int hns3_configure_all_mc_mac_addr(struct hns3_adapter *hns, bool del);
49 int hns3_configure_all_mac_addr(struct hns3_adapter *hns, bool del);
50 int hns3_add_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr,
51 		      __rte_unused uint32_t idx, __rte_unused uint32_t pool);
52 
53 void hns3_remove_mac_addr(struct rte_eth_dev *dev, uint32_t idx);
54 int hns3_set_mc_mac_addr_list(struct rte_eth_dev *dev,
55 			      struct rte_ether_addr *mc_addr_set,
56 			      uint32_t nb_mc_addr);
57 void hns3_ether_format_addr(char *buf, uint16_t size,
58 			    const struct rte_ether_addr *ether_addr);
59 int hns3_init_mac_addrs(struct rte_eth_dev *dev);
60 
61 int hns3_init_ring_with_vector(struct hns3_hw *hw);
62 int hns3_map_rx_interrupt(struct rte_eth_dev *dev);
63 void hns3_unmap_rx_interrupt(struct rte_eth_dev *dev);
64 int hns3_restore_rx_interrupt(struct hns3_hw *hw);
65 
66 int hns3_get_pci_revision_id(struct hns3_hw *hw, uint8_t *revision_id);
67 void hns3_set_default_dev_specifications(struct hns3_hw *hw);
68 int hns3_query_dev_specifications(struct hns3_hw *hw);
69 
70 #endif /* HNS3_COMMON_H */
71