1
2
3
4
5
6
7
8
9
10#ifndef __HNS_ENET_H
11#define __HNS_ENET_H
12
13#include <linux/netdevice.h>
14#include <linux/of_net.h>
15#include <linux/of_mdio.h>
16#include <linux/timer.h>
17#include <linux/workqueue.h>
18
19#include "hnae.h"
20
21#define HNS_DEBUG_OFFSET 6
22#define HNS_SRV_OFFSET 2
23
24enum hns_nic_state {
25 NIC_STATE_TESTING = 0,
26 NIC_STATE_RESETTING,
27 NIC_STATE_REINITING,
28 NIC_STATE_DOWN,
29 NIC_STATE_DISABLED,
30 NIC_STATE_REMOVING,
31 NIC_STATE_SERVICE_INITED,
32 NIC_STATE_SERVICE_SCHED,
33 NIC_STATE2_RESET_REQUESTED,
34 NIC_STATE_MAX
35};
36
37struct hns_nic_ring_data {
38 struct hnae_ring *ring;
39 struct napi_struct napi;
40 cpumask_t mask;
41 int queue_index;
42 int (*poll_one)(struct hns_nic_ring_data *, int, void *);
43 void (*ex_process)(struct hns_nic_ring_data *, struct sk_buff *);
44 bool (*fini_process)(struct hns_nic_ring_data *);
45};
46
47
48struct hns_nic_ops {
49 void (*fill_desc)(struct hnae_ring *ring, void *priv,
50 int size, dma_addr_t dma, int frag_end,
51 int buf_num, enum hns_desc_type type, int mtu);
52 int (*maybe_stop_tx)(struct sk_buff **out_skb,
53 int *bnum, struct hnae_ring *ring);
54 void (*get_rxd_bnum)(u32 bnum_flag, int *out_bnum);
55};
56
57struct hns_nic_priv {
58 const struct fwnode_handle *fwnode;
59 u32 enet_ver;
60 u32 port_id;
61 int phy_mode;
62 int phy_led_val;
63 struct net_device *netdev;
64 struct device *dev;
65 struct hnae_handle *ae_handle;
66
67 struct hns_nic_ops ops;
68
69
70
71
72 struct hns_nic_ring_data *ring_data;
73
74
75 int link;
76 u64 tx_timeout_count;
77
78 unsigned long state;
79
80 struct timer_list service_timer;
81
82 struct work_struct service_task;
83
84 struct notifier_block notifier_block;
85};
86
87#define tx_ring_data(priv, idx) ((priv)->ring_data[idx])
88#define rx_ring_data(priv, idx) \
89 ((priv)->ring_data[(priv)->ae_handle->q_num + (idx)])
90
91void hns_ethtool_set_ops(struct net_device *ndev);
92void hns_nic_net_reset(struct net_device *ndev);
93void hns_nic_net_reinit(struct net_device *netdev);
94int hns_nic_init_phy(struct net_device *ndev, struct hnae_handle *h);
95int hns_nic_net_xmit_hw(struct net_device *ndev,
96 struct sk_buff *skb,
97 struct hns_nic_ring_data *ring_data);
98
99#endif
100