2 * Copyright (c) 2014-2015 Hisilicon Limited.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
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>
21 #define HNS_DEBUG_OFFSET 6
22 #define HNS_SRV_OFFSET 2
25 NIC_STATE_TESTING
= 0,
31 NIC_STATE_SERVICE_INITED
,
32 NIC_STATE_SERVICE_SCHED
,
33 NIC_STATE2_RESET_REQUESTED
,
37 struct hns_nic_ring_data
{
38 struct hnae_ring
*ring
;
39 struct napi_struct napi
;
40 cpumask_t mask
; /* affinity mask */
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
*);
47 /* compatible the difference between two versions */
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
);
58 const struct fwnode_handle
*fwnode
;
63 struct net_device
*netdev
;
65 struct hnae_handle
*ae_handle
;
67 struct hns_nic_ops ops
;
69 /* the cb for nic to manage the ring buffer, the first half of the
70 * array is for tx_ring and vice versa for the second half
72 struct hns_nic_ring_data
*ring_data
;
74 /* The most recently read link state */
80 struct timer_list service_timer
;
82 struct work_struct service_task
;
84 struct notifier_block notifier_block
;
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)])
91 void hns_ethtool_set_ops(struct net_device
*ndev
);
92 void hns_nic_net_reset(struct net_device
*ndev
);
93 void hns_nic_net_reinit(struct net_device
*netdev
);
94 int hns_nic_init_phy(struct net_device
*ndev
, struct hnae_handle
*h
);
95 netdev_tx_t
hns_nic_net_xmit_hw(struct net_device
*ndev
,
97 struct hns_nic_ring_data
*ring_data
);
99 #endif /**__HNS_ENET_H */