1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * aQuantia Corporation Network Driver
4 * Copyright (C) 2014-2019 aQuantia Corporation. All rights reserved
7 /* File aq_nic.h: Declaration of common code for NIC. */
12 #include "aq_common.h"
21 enum aq_rx_filter_type;
24 const struct aq_hw_caps_s *aq_hw_caps;
26 u32 rxds; /* rx ring size, descriptors # */
27 u32 txds; /* tx ring size, descriptors # */
28 u32 vecs; /* allocated rx/tx vectors */
42 bool is_vlan_force_promisc;
43 u16 is_mc_list_enabled;
51 struct aq_rss_parameters aq_rss;
55 #define AQ_NIC_FLAG_STARTED 0x00000004U
56 #define AQ_NIC_FLAG_STOPPING 0x00000008U
57 #define AQ_NIC_FLAG_RESETTING 0x00000010U
58 #define AQ_NIC_FLAG_CLOSING 0x00000020U
59 #define AQ_NIC_PTP_DPATH_UP 0x02000000U
60 #define AQ_NIC_LINK_DOWN 0x04000000U
61 #define AQ_NIC_FLAG_ERR_UNPLUG 0x40000000U
62 #define AQ_NIC_FLAG_ERR_HW 0x80000000U
64 #define AQ_NIC_WOL_MODES (WAKE_MAGIC |\
67 #define AQ_NIC_TCVEC2RING(_NIC_, _TC_, _VEC_) \
68 ((_TC_) * AQ_CFG_TCS_MAX + (_VEC_))
71 struct aq_rx_filter_vlan aq_vlans[AQ_VLAN_MAX_FILTERS];
74 struct aq_hw_rx_fl3l4 {
81 struct aq_hw_rx_fltrs_s {
82 struct hlist_head filter_list;
84 struct aq_hw_rx_fl2 fl2;
85 struct aq_hw_rx_fl3l4 fl3l4;
86 /*filter ether type */
87 u8 fet_reserved_count;
93 struct aq_vec_s *aq_vec[AQ_CFG_VECS_MAX];
94 struct aq_ring_s *aq_ring_tx[AQ_CFG_VECS_MAX * AQ_CFG_TCS_MAX];
95 struct aq_hw_s *aq_hw;
96 struct net_device *ndev;
98 unsigned int packet_filter;
99 unsigned int power_state;
101 const struct aq_hw_ops *aq_hw_ops;
102 const struct aq_fw_ops *aq_fw_ops;
103 struct aq_nic_cfg_s aq_nic_cfg;
104 struct timer_list service_timer;
105 struct work_struct service_task;
106 struct timer_list polling_timer;
107 struct aq_hw_link_status_s link_status;
110 u8 ar[AQ_HW_MULTICAST_ADDRESS_MAX][ETH_ALEN];
112 /* Bitmask of currently assigned vlans from linux */
113 unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
115 struct pci_dev *pdev;
116 unsigned int msix_entry_mask;
118 /* mutex to serialize FW interface access operations */
119 struct mutex fwreq_mutex;
121 struct aq_ptp_s *aq_ptp;
122 struct aq_hw_rx_fltrs_s aq_hw_rx_fltrs;
125 static inline struct device *aq_nic_get_dev(struct aq_nic_s *self)
127 return self->ndev->dev.parent;
130 void aq_nic_ndev_init(struct aq_nic_s *self);
131 struct aq_nic_s *aq_nic_alloc_hot(struct net_device *ndev);
132 void aq_nic_set_tx_ring(struct aq_nic_s *self, unsigned int idx,
133 struct aq_ring_s *ring);
134 struct net_device *aq_nic_get_ndev(struct aq_nic_s *self);
135 int aq_nic_init(struct aq_nic_s *self);
136 void aq_nic_cfg_start(struct aq_nic_s *self);
137 int aq_nic_ndev_register(struct aq_nic_s *self);
138 void aq_nic_ndev_free(struct aq_nic_s *self);
139 int aq_nic_start(struct aq_nic_s *self);
140 unsigned int aq_nic_map_skb(struct aq_nic_s *self, struct sk_buff *skb,
141 struct aq_ring_s *ring);
142 int aq_nic_xmit(struct aq_nic_s *self, struct sk_buff *skb);
143 int aq_nic_get_regs(struct aq_nic_s *self, struct ethtool_regs *regs, void *p);
144 int aq_nic_get_regs_count(struct aq_nic_s *self);
145 void aq_nic_get_stats(struct aq_nic_s *self, u64 *data);
146 int aq_nic_stop(struct aq_nic_s *self);
147 void aq_nic_deinit(struct aq_nic_s *self, bool link_down);
148 void aq_nic_set_power(struct aq_nic_s *self);
149 void aq_nic_free_hot_resources(struct aq_nic_s *self);
150 void aq_nic_free_vectors(struct aq_nic_s *self);
151 int aq_nic_set_mtu(struct aq_nic_s *self, int new_mtu);
152 int aq_nic_set_mac(struct aq_nic_s *self, struct net_device *ndev);
153 int aq_nic_set_packet_filter(struct aq_nic_s *self, unsigned int flags);
154 int aq_nic_set_multicast_list(struct aq_nic_s *self, struct net_device *ndev);
155 unsigned int aq_nic_get_link_speed(struct aq_nic_s *self);
156 void aq_nic_get_link_ksettings(struct aq_nic_s *self,
157 struct ethtool_link_ksettings *cmd);
158 int aq_nic_set_link_ksettings(struct aq_nic_s *self,
159 const struct ethtool_link_ksettings *cmd);
160 struct aq_nic_cfg_s *aq_nic_get_cfg(struct aq_nic_s *self);
161 u32 aq_nic_get_fw_version(struct aq_nic_s *self);
162 int aq_nic_set_loopback(struct aq_nic_s *self);
163 int aq_nic_update_interrupt_moderation_settings(struct aq_nic_s *self);
164 void aq_nic_shutdown(struct aq_nic_s *self);
165 u8 aq_nic_reserve_filter(struct aq_nic_s *self, enum aq_rx_filter_type type);
166 void aq_nic_release_filter(struct aq_nic_s *self, enum aq_rx_filter_type type,
168 #endif /* AQ_NIC_H */