0001
0002
0003
0004
0005
0006 #ifndef __HNS_ENET_H
0007 #define __HNS_ENET_H
0008
0009 #include <linux/netdevice.h>
0010 #include <linux/of_net.h>
0011 #include <linux/of_mdio.h>
0012 #include <linux/timer.h>
0013 #include <linux/workqueue.h>
0014
0015 #include "hnae.h"
0016
0017 #define HNS_DEBUG_OFFSET 6
0018 #define HNS_SRV_OFFSET 2
0019
0020 enum hns_nic_state {
0021 NIC_STATE_TESTING = 0,
0022 NIC_STATE_RESETTING,
0023 NIC_STATE_REINITING,
0024 NIC_STATE_DOWN,
0025 NIC_STATE_DISABLED,
0026 NIC_STATE_REMOVING,
0027 NIC_STATE_SERVICE_INITED,
0028 NIC_STATE_SERVICE_SCHED,
0029 NIC_STATE2_RESET_REQUESTED,
0030 NIC_STATE_MAX
0031 };
0032
0033 struct hns_nic_ring_data {
0034 struct hnae_ring *ring;
0035 struct napi_struct napi;
0036 cpumask_t mask;
0037 u32 queue_index;
0038 int (*poll_one)(struct hns_nic_ring_data *, int, void *);
0039 void (*ex_process)(struct hns_nic_ring_data *, struct sk_buff *);
0040 bool (*fini_process)(struct hns_nic_ring_data *);
0041 };
0042
0043
0044 struct hns_nic_ops {
0045 void (*fill_desc)(struct hnae_ring *ring, void *priv,
0046 int size, dma_addr_t dma, int frag_end,
0047 int buf_num, enum hns_desc_type type, int mtu);
0048 int (*maybe_stop_tx)(struct sk_buff **out_skb,
0049 int *bnum, struct hnae_ring *ring);
0050 void (*get_rxd_bnum)(u32 bnum_flag, int *out_bnum);
0051 };
0052
0053 struct hns_nic_priv {
0054 const struct fwnode_handle *fwnode;
0055 u32 enet_ver;
0056 u32 port_id;
0057 int phy_mode;
0058 int phy_led_val;
0059 struct net_device *netdev;
0060 struct device *dev;
0061 struct hnae_handle *ae_handle;
0062
0063 struct hns_nic_ops ops;
0064
0065
0066
0067
0068 struct hns_nic_ring_data *ring_data;
0069
0070
0071 int link;
0072 u64 tx_timeout_count;
0073
0074 unsigned long state;
0075
0076 struct timer_list service_timer;
0077
0078 struct work_struct service_task;
0079
0080 struct notifier_block notifier_block;
0081 };
0082
0083 #define tx_ring_data(priv, idx) ((priv)->ring_data[idx])
0084 #define rx_ring_data(priv, idx) \
0085 ((priv)->ring_data[(priv)->ae_handle->q_num + (idx)])
0086
0087 void hns_ethtool_set_ops(struct net_device *ndev);
0088 void hns_nic_net_reset(struct net_device *ndev);
0089 void hns_nic_net_reinit(struct net_device *netdev);
0090 int hns_nic_init_phy(struct net_device *ndev, struct hnae_handle *h);
0091 netdev_tx_t hns_nic_net_xmit_hw(struct net_device *ndev,
0092 struct sk_buff *skb,
0093 struct hns_nic_ring_data *ring_data);
0094
0095 #endif