1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Copyright (c) 2014-2015 Hisilicon Limited.
9 #include <linux/netdevice.h>
10 #include <linux/of_net.h>
11 #include <linux/of_mdio.h>
12 #include <linux/timer.h>
13 #include <linux/workqueue.h>
17 #define HNS_DEBUG_OFFSET 6
18 #define HNS_SRV_OFFSET 2
21 NIC_STATE_TESTING = 0,
27 NIC_STATE_SERVICE_INITED,
28 NIC_STATE_SERVICE_SCHED,
29 NIC_STATE2_RESET_REQUESTED,
33 struct hns_nic_ring_data {
34 struct hnae_ring *ring;
35 struct napi_struct napi;
36 cpumask_t mask; /* affinity mask */
38 int (*poll_one)(struct hns_nic_ring_data *, int, void *);
39 void (*ex_process)(struct hns_nic_ring_data *, struct sk_buff *);
40 bool (*fini_process)(struct hns_nic_ring_data *);
43 /* compatible the difference between two versions */
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,
49 int (*maybe_stop_tx)(struct sk_buff **out_skb,
50 int *bnum, struct hnae_ring *ring);
51 void (*get_rxd_bnum)(u32 bnum_flag, int *out_bnum);
55 const struct fwnode_handle *fwnode;
60 struct net_device *netdev;
62 struct hnae_handle *ae_handle;
64 struct hns_nic_ops ops;
66 /* the cb for nic to manage the ring buffer, the first half of the
67 * array is for tx_ring and vice versa for the second half
69 struct hns_nic_ring_data *ring_data;
71 /* The most recently read link state */
77 struct timer_list service_timer;
79 struct work_struct service_task;
81 struct notifier_block notifier_block;
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)])
88 void hns_ethtool_set_ops(struct net_device *ndev);
89 void hns_nic_net_reset(struct net_device *ndev);
90 void hns_nic_net_reinit(struct net_device *netdev);
91 int hns_nic_init_phy(struct net_device *ndev, struct hnae_handle *h);
92 netdev_tx_t hns_nic_net_xmit_hw(struct net_device *ndev,
94 struct hns_nic_ring_data *ring_data);
96 #endif /**__HNS_ENET_H */