1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Huawei HiNIC PCI Express Linux driver
4  * Copyright(c) 2017 Huawei Technologies Co., Ltd
5  */
6 
7 #ifndef HINIC_DEV_H
8 #define HINIC_DEV_H
9 
10 #include <linux/netdevice.h>
11 #include <linux/types.h>
12 #include <linux/semaphore.h>
13 #include <linux/workqueue.h>
14 #include <linux/bitops.h>
15 
16 #include "hinic_hw_dev.h"
17 #include "hinic_tx.h"
18 #include "hinic_rx.h"
19 
20 #define HINIC_DRV_NAME          "hinic"
21 
22 enum hinic_flags {
23 	HINIC_LINK_UP = BIT(0),
24 	HINIC_INTF_UP = BIT(1),
25 	HINIC_RSS_ENABLE = BIT(2),
26 };
27 
28 struct hinic_rx_mode_work {
29 	struct work_struct      work;
30 	u32                     rx_mode;
31 };
32 
33 struct hinic_rss_type {
34 	u8 tcp_ipv6_ext;
35 	u8 ipv6_ext;
36 	u8 tcp_ipv6;
37 	u8 ipv6;
38 	u8 tcp_ipv4;
39 	u8 ipv4;
40 	u8 udp_ipv6;
41 	u8 udp_ipv4;
42 };
43 
44 enum hinic_rss_hash_type {
45 	HINIC_RSS_HASH_ENGINE_TYPE_XOR,
46 	HINIC_RSS_HASH_ENGINE_TYPE_TOEP,
47 	HINIC_RSS_HASH_ENGINE_TYPE_MAX,
48 };
49 
50 struct hinic_dev {
51 	struct net_device               *netdev;
52 	struct hinic_hwdev              *hwdev;
53 
54 	u32                             msg_enable;
55 	unsigned int                    tx_weight;
56 	unsigned int                    rx_weight;
57 	u16				num_qps;
58 	u16				max_qps;
59 
60 	unsigned int                    flags;
61 
62 	struct semaphore                mgmt_lock;
63 	unsigned long                   *vlan_bitmap;
64 
65 	struct hinic_rx_mode_work       rx_mode_work;
66 	struct workqueue_struct         *workq;
67 
68 	struct hinic_txq                *txqs;
69 	struct hinic_rxq                *rxqs;
70 
71 	struct hinic_txq_stats          tx_stats;
72 	struct hinic_rxq_stats          rx_stats;
73 
74 	u8				rss_tmpl_idx;
75 	u8				rss_hash_engine;
76 	u16				num_rss;
77 	u16				rss_limit;
78 	struct hinic_rss_type		rss_type;
79 	u8				*rss_hkey_user;
80 	s32				*rss_indir_user;
81 };
82 
83 #endif
84