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
21enum hns_nic_state {
22 NIC_STATE_TESTING = 0,
23 NIC_STATE_RESETTING,
24 NIC_STATE_REINITING,
25 NIC_STATE_DOWN,
26 NIC_STATE_DISABLED,
27 NIC_STATE_REMOVING,
28 NIC_STATE_SERVICE_INITED,
29 NIC_STATE_SERVICE_SCHED,
30 NIC_STATE2_RESET_REQUESTED,
31 NIC_STATE_MAX
32};
33
34struct hns_nic_ring_data {
35 struct hnae_ring *ring;
36 struct napi_struct napi;
37 int queue_index;
38 int (*poll_one)(struct hns_nic_ring_data *, int, void *);
39 void (*ex_process)(struct hns_nic_ring_data *, struct sk_buff *);
40 void (*fini_process)(struct hns_nic_ring_data *);
41};
42
43
44struct hns_nic_ops {
45 void (*fill_desc)(struct hnae_ring *ring, void *priv,
46 int size, dma_addr_t dma, int frag_end,
47 int buf_num, enum hns_desc_type type, int mtu);
48 int (*maybe_stop_tx)(struct sk_buff **out_skb,
49 int *bnum, struct hnae_ring *ring);
50 void (*get_rxd_bnum)(u32 bnum_flag, int *out_bnum);
51};
52
53struct hns_nic_priv {
54 const struct device_node *ae_node;
55 u32 enet_ver;
56 u32 port_id;
57 int phy_mode;
58 int phy_led_val;
59 struct phy_device *phy;
60 struct net_device *netdev;
61 struct device *dev;
62 struct hnae_handle *ae_handle;
63
64 struct hns_nic_ops ops;
65
66
67
68
69 struct hns_nic_ring_data *ring_data;
70
71
72 int link;
73 u64 tx_timeout_count;
74
75 unsigned long state;
76
77 struct timer_list service_timer;
78
79 struct work_struct service_task;
80
81 struct notifier_block notifier_block;
82};
83
84#define tx_ring_data(priv, idx) ((priv)->ring_data[idx])
85#define rx_ring_data(priv, idx) \
86 ((priv)->ring_data[(priv)->ae_handle->q_num + (idx)])
87
88void hns_ethtool_set_ops(struct net_device *ndev);
89void hns_nic_net_reset(struct net_device *ndev);
90void hns_nic_net_reinit(struct net_device *netdev);
91int hns_nic_init_phy(struct net_device *ndev, struct hnae_handle *h);
92int hns_nic_net_xmit_hw(struct net_device *ndev,
93 struct sk_buff *skb,
94 struct hns_nic_ring_data *ring_data);
95
96#endif
97