hc
2023-12-06 08f87f769b595151be1afeff53e144f543faa614
kernel/drivers/net/ethernet/aquantia/atlantic/aq_nic.h
....@@ -1,10 +1,8 @@
1
-/*
2
- * aQuantia Corporation Network Driver
3
- * Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved
1
+/* SPDX-License-Identifier: GPL-2.0-only */
2
+/* Atlantic Network Driver
43 *
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.
4
+ * Copyright (C) 2014-2019 aQuantia Corporation
5
+ * Copyright (C) 2019-2020 Marvell International Ltd.
86 */
97
108 /* File aq_nic.h: Declaration of common code for NIC. */
....@@ -20,47 +18,113 @@
2018 struct aq_hw_ops;
2119 struct aq_fw_s;
2220 struct aq_vec_s;
21
+struct aq_macsec_cfg;
22
+struct aq_ptp_s;
23
+enum aq_rx_filter_type;
24
+
25
+enum aq_fc_mode {
26
+ AQ_NIC_FC_OFF = 0,
27
+ AQ_NIC_FC_TX,
28
+ AQ_NIC_FC_RX,
29
+ AQ_NIC_FC_FULL,
30
+};
31
+
32
+struct aq_fc_info {
33
+ enum aq_fc_mode req;
34
+ enum aq_fc_mode cur;
35
+};
2336
2437 struct aq_nic_cfg_s {
2538 const struct aq_hw_caps_s *aq_hw_caps;
26
- u64 hw_features;
39
+ u64 features;
2740 u32 rxds; /* rx ring size, descriptors # */
2841 u32 txds; /* tx ring size, descriptors # */
29
- u32 vecs; /* vecs==allocated irqs */
42
+ u32 vecs; /* allocated rx/tx vectors */
43
+ u32 link_irq_vec;
3044 u32 irq_type;
3145 u32 itr;
3246 u16 rx_itr;
3347 u16 tx_itr;
48
+ u32 rxpageorder;
3449 u32 num_rss_queues;
3550 u32 mtu;
36
- u32 flow_control;
51
+ struct aq_fc_info fc;
3752 u32 link_speed_msk;
38
- u32 vlan_id;
53
+ u32 wol;
54
+ u8 is_vlan_rx_strip;
55
+ u8 is_vlan_tx_insert;
56
+ bool is_vlan_force_promisc;
3957 u16 is_mc_list_enabled;
4058 u16 mc_list_count;
4159 bool is_autoneg;
4260 bool is_polling;
4361 bool is_rss;
4462 bool is_lro;
63
+ bool is_qos;
64
+ bool is_ptp;
65
+ bool is_media_detect;
66
+ int downshift_counter;
67
+ enum aq_tc_mode tc_mode;
68
+ u32 priv_flags;
4569 u8 tcs;
70
+ u8 prio_tc_map[8];
71
+ u32 tc_max_rate[AQ_CFG_TCS_MAX];
72
+ unsigned long tc_min_rate_msk;
73
+ u32 tc_min_rate[AQ_CFG_TCS_MAX];
4674 struct aq_rss_parameters aq_rss;
75
+ u32 eee_speeds;
4776 };
4877
4978 #define AQ_NIC_FLAG_STARTED 0x00000004U
5079 #define AQ_NIC_FLAG_STOPPING 0x00000008U
5180 #define AQ_NIC_FLAG_RESETTING 0x00000010U
5281 #define AQ_NIC_FLAG_CLOSING 0x00000020U
82
+#define AQ_NIC_PTP_DPATH_UP 0x02000000U
5383 #define AQ_NIC_LINK_DOWN 0x04000000U
5484 #define AQ_NIC_FLAG_ERR_UNPLUG 0x40000000U
5585 #define AQ_NIC_FLAG_ERR_HW 0x80000000U
5686
57
-#define AQ_NIC_TCVEC2RING(_NIC_, _TC_, _VEC_) \
58
- ((_TC_) * AQ_CFG_TCS_MAX + (_VEC_))
87
+#define AQ_NIC_QUIRK_BAD_PTP BIT(0)
88
+
89
+#define AQ_NIC_WOL_MODES (WAKE_MAGIC |\
90
+ WAKE_PHY)
91
+
92
+#define AQ_NIC_CFG_RING_PER_TC(_NIC_CFG_) \
93
+ (((_NIC_CFG_)->tc_mode == AQ_TC_MODE_4TCS) ? 8 : 4)
94
+
95
+#define AQ_NIC_CFG_TCVEC2RING(_NIC_CFG_, _TC_, _VEC_) \
96
+ ((_TC_) * AQ_NIC_CFG_RING_PER_TC(_NIC_CFG_) + (_VEC_))
97
+
98
+#define AQ_NIC_RING2QMAP(_NIC_, _ID_) \
99
+ ((_ID_) / AQ_NIC_CFG_RING_PER_TC(&(_NIC_)->aq_nic_cfg) * \
100
+ (_NIC_)->aq_vecs + \
101
+ ((_ID_) % AQ_NIC_CFG_RING_PER_TC(&(_NIC_)->aq_nic_cfg)))
102
+
103
+struct aq_hw_rx_fl2 {
104
+ struct aq_rx_filter_vlan aq_vlans[AQ_VLAN_MAX_FILTERS];
105
+};
106
+
107
+struct aq_hw_rx_fl3l4 {
108
+ u8 active_ipv4;
109
+ u8 active_ipv6:2;
110
+ u8 is_ipv6;
111
+ u8 reserved_count;
112
+};
113
+
114
+struct aq_hw_rx_fltrs_s {
115
+ struct hlist_head filter_list;
116
+ u16 active_filters;
117
+ struct aq_hw_rx_fl2 fl2;
118
+ struct aq_hw_rx_fl3l4 fl3l4;
119
+ /* filter ether type */
120
+ u8 fet_reserved_count;
121
+};
59122
60123 struct aq_nic_s {
61124 atomic_t flags;
125
+ u32 msg_enable;
62126 struct aq_vec_s *aq_vec[AQ_CFG_VECS_MAX];
63
- struct aq_ring_s *aq_ring_tx[AQ_CFG_VECS_MAX * AQ_CFG_TCS_MAX];
127
+ struct aq_ring_s *aq_ring_tx[AQ_HW_QUEUES_MAX];
64128 struct aq_hw_s *aq_hw;
65129 struct net_device *ndev;
66130 unsigned int aq_vecs;
....@@ -71,16 +135,29 @@
71135 const struct aq_fw_ops *aq_fw_ops;
72136 struct aq_nic_cfg_s aq_nic_cfg;
73137 struct timer_list service_timer;
138
+ struct work_struct service_task;
74139 struct timer_list polling_timer;
75140 struct aq_hw_link_status_s link_status;
76141 struct {
77142 u32 count;
78143 u8 ar[AQ_HW_MULTICAST_ADDRESS_MAX][ETH_ALEN];
79144 } mc_list;
145
+ /* Bitmask of currently assigned vlans from linux */
146
+ unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
80147
81148 struct pci_dev *pdev;
82149 unsigned int msix_entry_mask;
83150 u32 irqvecs;
151
+ /* mutex to serialize FW interface access operations */
152
+ struct mutex fwreq_mutex;
153
+#if IS_ENABLED(CONFIG_MACSEC)
154
+ struct aq_macsec_cfg *macsec_cfg;
155
+ /* mutex to protect data in macsec_cfg */
156
+ struct mutex macsec_mutex;
157
+#endif
158
+ /* PTP support */
159
+ struct aq_ptp_s *aq_ptp;
160
+ struct aq_hw_rx_fltrs_s aq_hw_rx_fltrs;
84161 };
85162
86163 static inline struct device *aq_nic_get_dev(struct aq_nic_s *self)
....@@ -98,14 +175,18 @@
98175 int aq_nic_ndev_register(struct aq_nic_s *self);
99176 void aq_nic_ndev_free(struct aq_nic_s *self);
100177 int aq_nic_start(struct aq_nic_s *self);
178
+unsigned int aq_nic_map_skb(struct aq_nic_s *self, struct sk_buff *skb,
179
+ struct aq_ring_s *ring);
101180 int aq_nic_xmit(struct aq_nic_s *self, struct sk_buff *skb);
102181 int aq_nic_get_regs(struct aq_nic_s *self, struct ethtool_regs *regs, void *p);
103182 int aq_nic_get_regs_count(struct aq_nic_s *self);
104
-void aq_nic_get_stats(struct aq_nic_s *self, u64 *data);
183
+u64 *aq_nic_get_stats(struct aq_nic_s *self, u64 *data);
105184 int aq_nic_stop(struct aq_nic_s *self);
106
-void aq_nic_deinit(struct aq_nic_s *self);
185
+void aq_nic_deinit(struct aq_nic_s *self, bool link_down);
186
+void aq_nic_set_power(struct aq_nic_s *self);
107187 void aq_nic_free_hot_resources(struct aq_nic_s *self);
108188 void aq_nic_free_vectors(struct aq_nic_s *self);
189
+int aq_nic_realloc_vectors(struct aq_nic_s *self);
109190 int aq_nic_set_mtu(struct aq_nic_s *self, int new_mtu);
110191 int aq_nic_set_mac(struct aq_nic_s *self, struct net_device *ndev);
111192 int aq_nic_set_packet_filter(struct aq_nic_s *self, unsigned int flags);
....@@ -117,8 +198,17 @@
117198 const struct ethtool_link_ksettings *cmd);
118199 struct aq_nic_cfg_s *aq_nic_get_cfg(struct aq_nic_s *self);
119200 u32 aq_nic_get_fw_version(struct aq_nic_s *self);
120
-int aq_nic_change_pm_state(struct aq_nic_s *self, pm_message_t *pm_msg);
201
+int aq_nic_set_loopback(struct aq_nic_s *self);
202
+int aq_nic_set_downshift(struct aq_nic_s *self, int val);
203
+int aq_nic_set_media_detect(struct aq_nic_s *self, int val);
121204 int aq_nic_update_interrupt_moderation_settings(struct aq_nic_s *self);
122205 void aq_nic_shutdown(struct aq_nic_s *self);
123
-
206
+u8 aq_nic_reserve_filter(struct aq_nic_s *self, enum aq_rx_filter_type type);
207
+void aq_nic_release_filter(struct aq_nic_s *self, enum aq_rx_filter_type type,
208
+ u32 location);
209
+int aq_nic_setup_tc_mqprio(struct aq_nic_s *self, u32 tcs, u8 *prio_tc_map);
210
+int aq_nic_setup_tc_max_rate(struct aq_nic_s *self, const unsigned int tc,
211
+ const u32 max_rate);
212
+int aq_nic_setup_tc_min_rate(struct aq_nic_s *self, const unsigned int tc,
213
+ const u32 min_rate);
124214 #endif /* AQ_NIC_H */