xref: /linux/drivers/net/ethernet/aquantia/atlantic/aq_nic.h (revision e58e871becec2d3b04ed91c0c16fe8deac9c9dfa)
1 /*
2  * aQuantia Corporation Network Driver
3  * Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms and conditions of the GNU General Public License,
7  * version 2, as published by the Free Software Foundation.
8  */
9 
10 /* File aq_nic.h: Declaration of common code for NIC. */
11 
12 #ifndef AQ_NIC_H
13 #define AQ_NIC_H
14 
15 #include "aq_common.h"
16 #include "aq_rss.h"
17 
18 struct aq_ring_s;
19 struct aq_pci_func_s;
20 struct aq_hw_ops;
21 
22 #define AQ_NIC_FC_OFF    0U
23 #define AQ_NIC_FC_TX     1U
24 #define AQ_NIC_FC_RX     2U
25 #define AQ_NIC_FC_FULL   3U
26 #define AQ_NIC_FC_AUTO   4U
27 
28 #define AQ_NIC_RATE_10G        BIT(0)
29 #define AQ_NIC_RATE_5G         BIT(1)
30 #define AQ_NIC_RATE_5GSR       BIT(2)
31 #define AQ_NIC_RATE_2GS        BIT(3)
32 #define AQ_NIC_RATE_1G         BIT(4)
33 #define AQ_NIC_RATE_100M       BIT(5)
34 
35 struct aq_nic_cfg_s {
36 	struct aq_hw_caps_s *aq_hw_caps;
37 	u64 hw_features;
38 	u32 rxds;		/* rx ring size, descriptors # */
39 	u32 txds;		/* tx ring size, descriptors # */
40 	u32 vecs;		/* vecs==allocated irqs */
41 	u32 irq_type;
42 	u32 itr;
43 	u32 num_rss_queues;
44 	u32 mtu;
45 	u32 ucp_0x364;
46 	u32 flow_control;
47 	u32 link_speed_msk;
48 	u32 vlan_id;
49 	u16 is_mc_list_enabled;
50 	u16 mc_list_count;
51 	bool is_autoneg;
52 	bool is_interrupt_moderation;
53 	bool is_polling;
54 	bool is_rss;
55 	bool is_lro;
56 	u8  tcs;
57 	struct aq_rss_parameters aq_rss;
58 };
59 
60 #define AQ_NIC_FLAG_STARTED     0x00000004U
61 #define AQ_NIC_FLAG_STOPPING    0x00000008U
62 #define AQ_NIC_FLAG_RESETTING   0x00000010U
63 #define AQ_NIC_FLAG_CLOSING     0x00000020U
64 #define AQ_NIC_LINK_DOWN        0x04000000U
65 #define AQ_NIC_FLAG_ERR_UNPLUG  0x40000000U
66 #define AQ_NIC_FLAG_ERR_HW      0x80000000U
67 
68 #define AQ_NIC_TCVEC2RING(_NIC_, _TC_, _VEC_) \
69 	((_TC_) * AQ_CFG_TCS_MAX + (_VEC_))
70 
71 struct aq_nic_s *aq_nic_alloc_cold(const struct net_device_ops *ndev_ops,
72 				   const struct ethtool_ops *et_ops,
73 				   struct device *dev,
74 				   struct aq_pci_func_s *aq_pci_func,
75 				   unsigned int port,
76 				   const struct aq_hw_ops *aq_hw_ops);
77 int aq_nic_ndev_init(struct aq_nic_s *self);
78 struct aq_nic_s *aq_nic_alloc_hot(struct net_device *ndev);
79 void aq_nic_set_tx_ring(struct aq_nic_s *self, unsigned int idx,
80 			struct aq_ring_s *ring);
81 struct device *aq_nic_get_dev(struct aq_nic_s *self);
82 struct net_device *aq_nic_get_ndev(struct aq_nic_s *self);
83 int aq_nic_init(struct aq_nic_s *self);
84 int aq_nic_cfg_start(struct aq_nic_s *self);
85 int aq_nic_ndev_register(struct aq_nic_s *self);
86 void aq_nic_ndev_queue_start(struct aq_nic_s *self, unsigned int idx);
87 void aq_nic_ndev_queue_stop(struct aq_nic_s *self, unsigned int idx);
88 void aq_nic_ndev_free(struct aq_nic_s *self);
89 int aq_nic_start(struct aq_nic_s *self);
90 int aq_nic_xmit(struct aq_nic_s *self, struct sk_buff *skb);
91 int aq_nic_get_regs(struct aq_nic_s *self, struct ethtool_regs *regs, void *p);
92 int aq_nic_get_regs_count(struct aq_nic_s *self);
93 void aq_nic_get_stats(struct aq_nic_s *self, u64 *data);
94 int aq_nic_stop(struct aq_nic_s *self);
95 void aq_nic_deinit(struct aq_nic_s *self);
96 void aq_nic_free_hot_resources(struct aq_nic_s *self);
97 int aq_nic_set_mtu(struct aq_nic_s *self, int new_mtu);
98 int aq_nic_set_mac(struct aq_nic_s *self, struct net_device *ndev);
99 int aq_nic_set_packet_filter(struct aq_nic_s *self, unsigned int flags);
100 int aq_nic_set_multicast_list(struct aq_nic_s *self, struct net_device *ndev);
101 unsigned int aq_nic_get_link_speed(struct aq_nic_s *self);
102 void aq_nic_get_link_ksettings(struct aq_nic_s *self,
103 			       struct ethtool_link_ksettings *cmd);
104 int aq_nic_set_link_ksettings(struct aq_nic_s *self,
105 			      const struct ethtool_link_ksettings *cmd);
106 struct aq_nic_cfg_s *aq_nic_get_cfg(struct aq_nic_s *self);
107 u32 aq_nic_get_fw_version(struct aq_nic_s *self);
108 int aq_nic_change_pm_state(struct aq_nic_s *self, pm_message_t *pm_msg);
109 
110 #endif /* AQ_NIC_H */
111