1 /* 2 * Copyright (c) 2014-2015 Hisilicon Limited. 3 * 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. 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 enum 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 34 struct 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 struct hns_nic_priv { 44 const char *ae_name; 45 u32 enet_ver; 46 u32 port_id; 47 int phy_mode; 48 int phy_led_val; 49 struct phy_device *phy; 50 struct net_device *netdev; 51 struct device *dev; 52 struct hnae_handle *ae_handle; 53 54 /* the cb for nic to manage the ring buffer, the first half of the 55 * array is for tx_ring and vice versa for the second half 56 */ 57 struct hns_nic_ring_data *ring_data; 58 59 /* The most recently read link state */ 60 int link; 61 u64 tx_timeout_count; 62 63 unsigned long state; 64 65 struct timer_list service_timer; 66 67 struct work_struct service_task; 68 69 struct notifier_block notifier_block; 70 }; 71 72 #define tx_ring_data(priv, idx) ((priv)->ring_data[idx]) 73 #define rx_ring_data(priv, idx) \ 74 ((priv)->ring_data[(priv)->ae_handle->q_num + (idx)]) 75 76 void hns_ethtool_set_ops(struct net_device *ndev); 77 void hns_nic_net_reset(struct net_device *ndev); 78 void hns_nic_net_reinit(struct net_device *netdev); 79 int hns_nic_init_phy(struct net_device *ndev, struct hnae_handle *h); 80 int hns_nic_net_xmit_hw(struct net_device *ndev, 81 struct sk_buff *skb, 82 struct hns_nic_ring_data *ring_data); 83 84 #endif /**__HNS_ENET_H */ 85