Commit | Line | Data |
---|---|---|
97bde5c4 DV |
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" | |
1a713f87 | 17 | #include "aq_hw.h" |
97bde5c4 DV |
18 | |
19 | struct aq_ring_s; | |
97bde5c4 | 20 | struct aq_hw_ops; |
db550615 IR |
21 | struct aq_fw_s; |
22 | struct aq_vec_s; | |
97bde5c4 | 23 | |
97bde5c4 | 24 | struct aq_nic_cfg_s { |
4cbc9f92 | 25 | const struct aq_hw_caps_s *aq_hw_caps; |
bbb67a44 | 26 | u64 features; |
97bde5c4 DV |
27 | u32 rxds; /* rx ring size, descriptors # */ |
28 | u32 txds; /* tx ring size, descriptors # */ | |
3dd3e236 IR |
29 | u32 vecs; /* allocated rx/tx vectors */ |
30 | u32 link_irq_vec; | |
97bde5c4 DV |
31 | u32 irq_type; |
32 | u32 itr; | |
b82ee71a IR |
33 | u16 rx_itr; |
34 | u16 tx_itr; | |
46f4c29d | 35 | u32 rxpageorder; |
97bde5c4 DV |
36 | u32 num_rss_queues; |
37 | u32 mtu; | |
97bde5c4 DV |
38 | u32 flow_control; |
39 | u32 link_speed_msk; | |
0e1a0dde | 40 | u32 wol; |
97bde5c4 DV |
41 | u16 is_mc_list_enabled; |
42 | u16 mc_list_count; | |
43 | bool is_autoneg; | |
97bde5c4 DV |
44 | bool is_polling; |
45 | bool is_rss; | |
46 | bool is_lro; | |
47 | u8 tcs; | |
48 | struct aq_rss_parameters aq_rss; | |
92ab6407 | 49 | u32 eee_speeds; |
97bde5c4 DV |
50 | }; |
51 | ||
52 | #define AQ_NIC_FLAG_STARTED 0x00000004U | |
53 | #define AQ_NIC_FLAG_STOPPING 0x00000008U | |
54 | #define AQ_NIC_FLAG_RESETTING 0x00000010U | |
55 | #define AQ_NIC_FLAG_CLOSING 0x00000020U | |
56 | #define AQ_NIC_LINK_DOWN 0x04000000U | |
57 | #define AQ_NIC_FLAG_ERR_UNPLUG 0x40000000U | |
58 | #define AQ_NIC_FLAG_ERR_HW 0x80000000U | |
59 | ||
0e1a0dde YE |
60 | #define AQ_NIC_WOL_ENABLED BIT(0) |
61 | ||
97bde5c4 DV |
62 | #define AQ_NIC_TCVEC2RING(_NIC_, _TC_, _VEC_) \ |
63 | ((_TC_) * AQ_CFG_TCS_MAX + (_VEC_)) | |
64 | ||
54bcb3d1 DB |
65 | struct aq_hw_rx_fl2 { |
66 | struct aq_rx_filter_vlan aq_vlans[AQ_VLAN_MAX_FILTERS]; | |
67 | }; | |
68 | ||
a6ed6f22 DB |
69 | struct aq_hw_rx_fl3l4 { |
70 | u8 active_ipv4; | |
71 | u8 active_ipv6:2; | |
72 | u8 is_ipv6; | |
73 | }; | |
74 | ||
8d0bcb01 DB |
75 | struct aq_hw_rx_fltrs_s { |
76 | struct hlist_head filter_list; | |
77 | u16 active_filters; | |
54bcb3d1 | 78 | struct aq_hw_rx_fl2 fl2; |
a6ed6f22 | 79 | struct aq_hw_rx_fl3l4 fl3l4; |
8d0bcb01 DB |
80 | }; |
81 | ||
db550615 IR |
82 | struct aq_nic_s { |
83 | atomic_t flags; | |
84 | struct aq_vec_s *aq_vec[AQ_CFG_VECS_MAX]; | |
85 | struct aq_ring_s *aq_ring_tx[AQ_CFG_VECS_MAX * AQ_CFG_TCS_MAX]; | |
86 | struct aq_hw_s *aq_hw; | |
87 | struct net_device *ndev; | |
db550615 IR |
88 | unsigned int aq_vecs; |
89 | unsigned int packet_filter; | |
90 | unsigned int power_state; | |
91 | u8 port; | |
8fcb98f4 | 92 | const struct aq_hw_ops *aq_hw_ops; |
0c58c35f | 93 | const struct aq_fw_ops *aq_fw_ops; |
db550615 IR |
94 | struct aq_nic_cfg_s aq_nic_cfg; |
95 | struct timer_list service_timer; | |
49544935 | 96 | struct work_struct service_task; |
db550615 IR |
97 | struct timer_list polling_timer; |
98 | struct aq_hw_link_status_s link_status; | |
99 | struct { | |
100 | u32 count; | |
94b3b542 | 101 | u8 ar[AQ_HW_MULTICAST_ADDRESS_MAX][ETH_ALEN]; |
db550615 | 102 | } mc_list; |
7975d2af DB |
103 | /* Bitmask of currently assigned vlans from linux */ |
104 | unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)]; | |
db550615 IR |
105 | |
106 | struct pci_dev *pdev; | |
107 | unsigned int msix_entry_mask; | |
a09bd81b | 108 | u32 irqvecs; |
f5dce08a ND |
109 | /* mutex to serialize FW interface access operations */ |
110 | struct mutex fwreq_mutex; | |
8d0bcb01 | 111 | struct aq_hw_rx_fltrs_s aq_hw_rx_fltrs; |
db550615 IR |
112 | }; |
113 | ||
114 | static inline struct device *aq_nic_get_dev(struct aq_nic_s *self) | |
115 | { | |
116 | return self->ndev->dev.parent; | |
117 | } | |
118 | ||
23ee07ad | 119 | void aq_nic_ndev_init(struct aq_nic_s *self); |
97bde5c4 DV |
120 | struct aq_nic_s *aq_nic_alloc_hot(struct net_device *ndev); |
121 | void aq_nic_set_tx_ring(struct aq_nic_s *self, unsigned int idx, | |
122 | struct aq_ring_s *ring); | |
97bde5c4 DV |
123 | struct net_device *aq_nic_get_ndev(struct aq_nic_s *self); |
124 | int aq_nic_init(struct aq_nic_s *self); | |
23ee07ad | 125 | void aq_nic_cfg_start(struct aq_nic_s *self); |
97bde5c4 | 126 | int aq_nic_ndev_register(struct aq_nic_s *self); |
97bde5c4 DV |
127 | void aq_nic_ndev_free(struct aq_nic_s *self); |
128 | int aq_nic_start(struct aq_nic_s *self); | |
129 | int aq_nic_xmit(struct aq_nic_s *self, struct sk_buff *skb); | |
130 | int aq_nic_get_regs(struct aq_nic_s *self, struct ethtool_regs *regs, void *p); | |
131 | int aq_nic_get_regs_count(struct aq_nic_s *self); | |
132 | void aq_nic_get_stats(struct aq_nic_s *self, u64 *data); | |
133 | int aq_nic_stop(struct aq_nic_s *self); | |
134 | void aq_nic_deinit(struct aq_nic_s *self); | |
135 | void aq_nic_free_hot_resources(struct aq_nic_s *self); | |
23ee07ad | 136 | void aq_nic_free_vectors(struct aq_nic_s *self); |
97bde5c4 DV |
137 | int aq_nic_set_mtu(struct aq_nic_s *self, int new_mtu); |
138 | int aq_nic_set_mac(struct aq_nic_s *self, struct net_device *ndev); | |
139 | int aq_nic_set_packet_filter(struct aq_nic_s *self, unsigned int flags); | |
140 | int aq_nic_set_multicast_list(struct aq_nic_s *self, struct net_device *ndev); | |
141 | unsigned int aq_nic_get_link_speed(struct aq_nic_s *self); | |
f8244ab5 PR |
142 | void aq_nic_get_link_ksettings(struct aq_nic_s *self, |
143 | struct ethtool_link_ksettings *cmd); | |
144 | int aq_nic_set_link_ksettings(struct aq_nic_s *self, | |
145 | const struct ethtool_link_ksettings *cmd); | |
97bde5c4 DV |
146 | struct aq_nic_cfg_s *aq_nic_get_cfg(struct aq_nic_s *self); |
147 | u32 aq_nic_get_fw_version(struct aq_nic_s *self); | |
148 | int aq_nic_change_pm_state(struct aq_nic_s *self, pm_message_t *pm_msg); | |
b82ee71a | 149 | int aq_nic_update_interrupt_moderation_settings(struct aq_nic_s *self); |
90869ddf | 150 | void aq_nic_shutdown(struct aq_nic_s *self); |
97bde5c4 DV |
151 | |
152 | #endif /* AQ_NIC_H */ |