xref: /linux/drivers/net/ethernet/huawei/hinic3/hinic3_nic_dev.h (revision ab93e0dd72c37d378dd936f031ffb83ff2bd87ce)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved. */
3 
4 #ifndef _HINIC3_NIC_DEV_H_
5 #define _HINIC3_NIC_DEV_H_
6 
7 #include <linux/netdevice.h>
8 
9 #include "hinic3_hw_cfg.h"
10 #include "hinic3_mgmt_interface.h"
11 
12 enum hinic3_flags {
13 	HINIC3_RSS_ENABLE,
14 };
15 
16 enum hinic3_rss_hash_type {
17 	HINIC3_RSS_HASH_ENGINE_TYPE_XOR  = 0,
18 	HINIC3_RSS_HASH_ENGINE_TYPE_TOEP = 1,
19 };
20 
21 struct hinic3_rss_type {
22 	u8 tcp_ipv6_ext;
23 	u8 ipv6_ext;
24 	u8 tcp_ipv6;
25 	u8 ipv6;
26 	u8 tcp_ipv4;
27 	u8 ipv4;
28 	u8 udp_ipv6;
29 	u8 udp_ipv4;
30 };
31 
32 struct hinic3_irq_cfg {
33 	struct net_device  *netdev;
34 	u16                msix_entry_idx;
35 	/* provided by OS */
36 	u32                irq_id;
37 	char               irq_name[IFNAMSIZ + 16];
38 	struct napi_struct napi;
39 	cpumask_t          affinity_mask;
40 	struct hinic3_txq  *txq;
41 	struct hinic3_rxq  *rxq;
42 };
43 
44 struct hinic3_dyna_txrxq_params {
45 	u16                        num_qps;
46 	u32                        sq_depth;
47 	u32                        rq_depth;
48 
49 	struct hinic3_dyna_txq_res *txqs_res;
50 	struct hinic3_dyna_rxq_res *rxqs_res;
51 	struct hinic3_irq_cfg      *irq_cfg;
52 };
53 
54 struct hinic3_nic_dev {
55 	struct pci_dev                  *pdev;
56 	struct net_device               *netdev;
57 	struct hinic3_hwdev             *hwdev;
58 	struct hinic3_nic_io            *nic_io;
59 
60 	u16                             max_qps;
61 	u16                             rx_buf_len;
62 	u32                             lro_replenish_thld;
63 	unsigned long                   flags;
64 	struct hinic3_nic_service_cap   nic_svc_cap;
65 
66 	struct hinic3_dyna_txrxq_params q_params;
67 	struct hinic3_txq               *txqs;
68 	struct hinic3_rxq               *rxqs;
69 
70 	u16                             num_qp_irq;
71 	struct msix_entry               *qps_msix_entries;
72 
73 	bool                            link_status_up;
74 };
75 
76 void hinic3_set_netdev_ops(struct net_device *netdev);
77 
78 /* Temporary prototypes. Functions become static in later submission. */
79 void qp_add_napi(struct hinic3_irq_cfg *irq_cfg);
80 void qp_del_napi(struct hinic3_irq_cfg *irq_cfg);
81 
82 #endif
83