forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-10-16 50a212ec906f7524620675f0c57357691c26c81f
kernel/drivers/net/ethernet/qlogic/qede/qede.h
....@@ -1,34 +1,9 @@
1
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
12 /* QLogic qede NIC Driver
23 * Copyright (c) 2015-2017 QLogic Corporation
3
- *
4
- * This software is available to you under a choice of one of two
5
- * licenses. You may choose to be licensed under the terms of the GNU
6
- * General Public License (GPL) Version 2, available from the file
7
- * COPYING in the main directory of this source tree, or the
8
- * OpenIB.org BSD license below:
9
- *
10
- * Redistribution and use in source and binary forms, with or
11
- * without modification, are permitted provided that the following
12
- * conditions are met:
13
- *
14
- * - Redistributions of source code must retain the above
15
- * copyright notice, this list of conditions and the following
16
- * disclaimer.
17
- *
18
- * - Redistributions in binary form must reproduce the above
19
- * copyright notice, this list of conditions and the following
20
- * disclaimer in the documentation and /or other materials
21
- * provided with the distribution.
22
- *
23
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
- * SOFTWARE.
4
+ * Copyright (c) 2019-2020 Marvell International Ltd.
315 */
6
+
327 #ifndef _QEDE_H_
338 #define _QEDE_H_
349 #include <linux/compiler.h>
....@@ -56,7 +31,7 @@
5631 #include <net/tc_act/tc_gact.h>
5732
5833 #define QEDE_MAJOR_VERSION 8
59
-#define QEDE_MINOR_VERSION 33
34
+#define QEDE_MINOR_VERSION 37
6035 #define QEDE_REVISION_VERSION 0
6136 #define QEDE_ENGINEERING_VERSION 20
6237 #define DRV_MODULE_VERSION __stringify(QEDE_MAJOR_VERSION) "." \
....@@ -92,6 +67,7 @@
9267 u64 non_coalesced_pkts;
9368 u64 coalesced_bytes;
9469 u64 link_change_count;
70
+ u64 ptp_skip_txts;
9571
9672 /* port */
9773 u64 rx_64_byte_packets;
....@@ -164,32 +140,54 @@
164140 struct workqueue_struct *rdma_wq;
165141 struct kref refcnt;
166142 struct completion event_comp;
143
+ bool exp_recovery;
167144 };
168145
169146 struct qede_ptp;
170147
171148 #define QEDE_RFS_MAX_FLTR 256
172149
150
+enum qede_flags_bit {
151
+ QEDE_FLAGS_IS_VF = 0,
152
+ QEDE_FLAGS_LINK_REQUESTED,
153
+ QEDE_FLAGS_PTP_TX_IN_PRORGESS,
154
+ QEDE_FLAGS_TX_TIMESTAMPING_EN
155
+};
156
+
157
+#define QEDE_DUMP_MAX_ARGS 4
158
+enum qede_dump_cmd {
159
+ QEDE_DUMP_CMD_NONE = 0,
160
+ QEDE_DUMP_CMD_NVM_CFG,
161
+ QEDE_DUMP_CMD_GRCDUMP,
162
+ QEDE_DUMP_CMD_MAX
163
+};
164
+
165
+struct qede_dump_info {
166
+ enum qede_dump_cmd cmd;
167
+ u8 num_args;
168
+ u32 args[QEDE_DUMP_MAX_ARGS];
169
+};
170
+
173171 struct qede_dev {
174172 struct qed_dev *cdev;
175173 struct net_device *ndev;
176174 struct pci_dev *pdev;
175
+ struct devlink *devlink;
177176
178177 u32 dp_module;
179178 u8 dp_level;
180179
181
- unsigned long flags;
182
-#define QEDE_FLAG_IS_VF BIT(0)
183
-#define IS_VF(edev) (!!((edev)->flags & QEDE_FLAG_IS_VF))
184
-#define QEDE_TX_TIMESTAMPING_EN BIT(1)
185
-#define QEDE_FLAGS_PTP_TX_IN_PRORGESS BIT(2)
180
+ unsigned long flags;
181
+#define IS_VF(edev) test_bit(QEDE_FLAGS_IS_VF, \
182
+ &(edev)->flags)
186183
187184 const struct qed_eth_ops *ops;
188185 struct qede_ptp *ptp;
186
+ u64 ptp_skip_txts;
189187
190
- struct qed_dev_eth_info dev_info;
191
-#define QEDE_MAX_RSS_CNT(edev) ((edev)->dev_info.num_queues)
192
-#define QEDE_MAX_TSS_CNT(edev) ((edev)->dev_info.num_queues)
188
+ struct qed_dev_eth_info dev_info;
189
+#define QEDE_MAX_RSS_CNT(edev) ((edev)->dev_info.num_queues)
190
+#define QEDE_MAX_TSS_CNT(edev) ((edev)->dev_info.num_queues)
193191 #define QEDE_IS_BB(edev) \
194192 ((edev)->dev_info.common.dev_type == QED_DEV_TYPE_BB)
195193 #define QEDE_IS_AH(edev) \
....@@ -202,14 +200,16 @@
202200 u8 fp_num_rx;
203201 u16 req_queues;
204202 u16 num_queues;
205
-#define QEDE_QUEUE_CNT(edev) ((edev)->num_queues)
206
-#define QEDE_RSS_COUNT(edev) ((edev)->num_queues - (edev)->fp_num_tx)
203
+ u16 total_xdp_queues;
204
+
205
+#define QEDE_QUEUE_CNT(edev) ((edev)->num_queues)
206
+#define QEDE_RSS_COUNT(edev) ((edev)->num_queues - (edev)->fp_num_tx)
207207 #define QEDE_RX_QUEUE_IDX(edev, i) (i)
208
-#define QEDE_TSS_COUNT(edev) ((edev)->num_queues - (edev)->fp_num_rx)
208
+#define QEDE_TSS_COUNT(edev) ((edev)->num_queues - (edev)->fp_num_rx)
209209
210210 struct qed_int_info int_info;
211211
212
- /* Smaller private varaiant of the RTNL lock */
212
+ /* Smaller private variant of the RTNL lock */
213213 struct mutex qede_lock;
214214 u32 state; /* Protected by qede_lock */
215215 u16 rx_buf_size;
....@@ -230,22 +230,28 @@
230230 SKB_DATA_ALIGN(sizeof(struct skb_shared_info)))
231231
232232 struct qede_stats stats;
233
-#define QEDE_RSS_INDIR_INITED BIT(0)
234
-#define QEDE_RSS_KEY_INITED BIT(1)
235
-#define QEDE_RSS_CAPS_INITED BIT(2)
236
- u32 rss_params_inited; /* bit-field to track initialized rss params */
237
- u16 rss_ind_table[128];
238
- u32 rss_key[10];
239
- u8 rss_caps;
240233
241
- u16 q_num_rx_buffers; /* Must be a power of two */
242
- u16 q_num_tx_buffers; /* Must be a power of two */
234
+ /* Bitfield to track initialized RSS params */
235
+ u32 rss_params_inited;
236
+#define QEDE_RSS_INDIR_INITED BIT(0)
237
+#define QEDE_RSS_KEY_INITED BIT(1)
238
+#define QEDE_RSS_CAPS_INITED BIT(2)
243239
244
- bool gro_disable;
245
- struct list_head vlan_list;
246
- u16 configured_vlans;
247
- u16 non_configured_vlans;
248
- bool accept_any_vlan;
240
+ u16 rss_ind_table[128];
241
+ u32 rss_key[10];
242
+ u8 rss_caps;
243
+
244
+ /* Both must be a power of two */
245
+ u16 q_num_rx_buffers;
246
+ u16 q_num_tx_buffers;
247
+
248
+ bool gro_disable;
249
+
250
+ struct list_head vlan_list;
251
+ u16 configured_vlans;
252
+ u16 non_configured_vlans;
253
+ bool accept_any_vlan;
254
+
249255 struct delayed_work sp_task;
250256 unsigned long sp_flags;
251257 u16 vxlan_dst_port;
....@@ -256,12 +262,27 @@
256262
257263 struct qede_rdma_dev rdma_info;
258264
259
- struct bpf_prog *xdp_prog;
265
+ struct bpf_prog *xdp_prog;
266
+
267
+ enum qed_hw_err_type last_err_type;
268
+ unsigned long err_flags;
269
+#define QEDE_ERR_IS_HANDLED 31
270
+#define QEDE_ERR_ATTN_CLR_EN 0
271
+#define QEDE_ERR_GET_DBG_INFO 1
272
+#define QEDE_ERR_IS_RECOVERABLE 2
273
+#define QEDE_ERR_WARN 3
274
+
275
+ struct qede_dump_info dump_info;
276
+ struct delayed_work periodic_task;
277
+ unsigned long stats_coal_ticks;
278
+ u32 stats_coal_usecs;
279
+ spinlock_t stats_lock; /* lock for vport stats access */
260280 };
261281
262282 enum QEDE_STATE {
263283 QEDE_STATE_CLOSED,
264284 QEDE_STATE_OPEN,
285
+ QEDE_STATE_RECOVERY,
265286 };
266287
267288 #define HILO_U64(hi, lo) ((((u64)(hi)) << 32) + (lo))
....@@ -366,28 +387,34 @@
366387 };
367388
368389 struct sw_tx_xdp {
369
- struct page *page;
370
- dma_addr_t mapping;
390
+ struct page *page;
391
+ struct xdp_frame *xdpf;
392
+ dma_addr_t mapping;
371393 };
372394
373395 struct qede_tx_queue {
374
- u8 is_xdp;
375
- bool is_legacy;
376
- u16 sw_tx_cons;
377
- u16 sw_tx_prod;
378
- u16 num_tx_buffers; /* Slowpath only */
396
+ u8 is_xdp;
397
+ bool is_legacy;
398
+ u16 sw_tx_cons;
399
+ u16 sw_tx_prod;
400
+ u16 num_tx_buffers; /* Slowpath only */
379401
380
- u64 xmit_pkts;
381
- u64 stopped_cnt;
402
+ u64 xmit_pkts;
403
+ u64 stopped_cnt;
404
+ u64 tx_mem_alloc_err;
382405
383
- __le16 *hw_cons_ptr;
406
+ __le16 *hw_cons_ptr;
384407
385408 /* Needed for the mapping of packets */
386
- struct device *dev;
409
+ struct device *dev;
387410
388
- void __iomem *doorbell_addr;
389
- union db_prod tx_db;
390
- int index; /* Slowpath only */
411
+ void __iomem *doorbell_addr;
412
+ union db_prod tx_db;
413
+
414
+ /* Spinlock for XDP queues in case of XDP_REDIRECT */
415
+ spinlock_t xdp_tx_lock;
416
+
417
+ int index; /* Slowpath only */
391418 #define QEDE_TXQ_XDP_TO_IDX(edev, txq) ((txq)->index - \
392419 QEDE_MAX_TSS_CNT(edev))
393420 #define QEDE_TXQ_IDX_TO_XDP(edev, idx) ((idx) + QEDE_MAX_TSS_CNT(edev))
....@@ -399,22 +426,22 @@
399426 #define QEDE_NDEV_TXQ_ID_TO_TXQ(edev, idx) \
400427 (&((edev)->fp_array[QEDE_NDEV_TXQ_ID_TO_FP_ID(edev, idx)].txq \
401428 [QEDE_NDEV_TXQ_ID_TO_TXQ_COS(edev, idx)]))
402
-#define QEDE_FP_TC0_TXQ(fp) (&((fp)->txq[0]))
429
+#define QEDE_FP_TC0_TXQ(fp) (&((fp)->txq[0]))
403430
404431 /* Regular Tx requires skb + metadata for release purpose,
405432 * while XDP requires the pages and the mapped address.
406433 */
407434 union {
408
- struct sw_tx_bd *skbs;
409
- struct sw_tx_xdp *xdp;
410
- } sw_tx_ring;
435
+ struct sw_tx_bd *skbs;
436
+ struct sw_tx_xdp *xdp;
437
+ } sw_tx_ring;
411438
412
- struct qed_chain tx_pbl;
439
+ struct qed_chain tx_pbl;
413440
414441 /* Slowpath; Should be kept in end [unless missing padding] */
415
- void *handle;
416
- u16 cos;
417
- u16 ndev_txq_id;
442
+ void *handle;
443
+ u16 cos;
444
+ u16 ndev_txq_id;
418445 };
419446
420447 #define BD_UNMAP_ADDR(bd) HILO_U64(le32_to_cpu((bd)->addr.hi), \
....@@ -428,43 +455,54 @@
428455 #define BD_UNMAP_LEN(bd) (le16_to_cpu((bd)->nbytes))
429456
430457 struct qede_fastpath {
431
- struct qede_dev *edev;
432
-#define QEDE_FASTPATH_TX BIT(0)
433
-#define QEDE_FASTPATH_RX BIT(1)
434
-#define QEDE_FASTPATH_XDP BIT(2)
435
-#define QEDE_FASTPATH_COMBINED (QEDE_FASTPATH_TX | QEDE_FASTPATH_RX)
436
- u8 type;
437
- u8 id;
438
- u8 xdp_xmit;
439
- struct napi_struct napi;
440
- struct qed_sb_info *sb_info;
441
- struct qede_rx_queue *rxq;
442
- struct qede_tx_queue *txq;
443
- struct qede_tx_queue *xdp_tx;
458
+ struct qede_dev *edev;
444459
445
-#define VEC_NAME_SIZE (sizeof(((struct net_device *)0)->name) + 8)
446
- char name[VEC_NAME_SIZE];
460
+ u8 type;
461
+#define QEDE_FASTPATH_TX BIT(0)
462
+#define QEDE_FASTPATH_RX BIT(1)
463
+#define QEDE_FASTPATH_XDP BIT(2)
464
+#define QEDE_FASTPATH_COMBINED (QEDE_FASTPATH_TX | QEDE_FASTPATH_RX)
465
+
466
+ u8 id;
467
+
468
+ u8 xdp_xmit;
469
+#define QEDE_XDP_TX BIT(0)
470
+#define QEDE_XDP_REDIRECT BIT(1)
471
+
472
+ struct napi_struct napi;
473
+ struct qed_sb_info *sb_info;
474
+ struct qede_rx_queue *rxq;
475
+ struct qede_tx_queue *txq;
476
+ struct qede_tx_queue *xdp_tx;
477
+
478
+ char name[IFNAMSIZ + 8];
447479 };
448480
449481 /* Debug print definitions */
450
-#define DP_NAME(edev) ((edev)->ndev->name)
482
+#define DP_NAME(edev) netdev_name((edev)->ndev)
451483
452
-#define XMIT_PLAIN 0
453
-#define XMIT_L4_CSUM BIT(0)
454
-#define XMIT_LSO BIT(1)
455
-#define XMIT_ENC BIT(2)
456
-#define XMIT_ENC_GSO_L4_CSUM BIT(3)
484
+#define XMIT_PLAIN 0
485
+#define XMIT_L4_CSUM BIT(0)
486
+#define XMIT_LSO BIT(1)
487
+#define XMIT_ENC BIT(2)
488
+#define XMIT_ENC_GSO_L4_CSUM BIT(3)
457489
458490 #define QEDE_CSUM_ERROR BIT(0)
459491 #define QEDE_CSUM_UNNECESSARY BIT(1)
460492 #define QEDE_TUNN_CSUM_UNNECESSARY BIT(2)
461493
494
+#define QEDE_SP_RECOVERY 0
462495 #define QEDE_SP_RX_MODE 1
496
+#define QEDE_SP_RSVD1 2
497
+#define QEDE_SP_RSVD2 3
498
+#define QEDE_SP_HW_ERR 4
499
+#define QEDE_SP_ARFS_CONFIG 5
500
+#define QEDE_SP_AER 7
501
+#define QEDE_SP_DISABLE 8
463502
464503 #ifdef CONFIG_RFS_ACCEL
465504 int qede_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb,
466505 u16 rxq_index, u32 flow_id);
467
-#define QEDE_SP_ARFS_CONFIG 4
468506 #define QEDE_SP_TASK_POLL_DELAY (5 * HZ)
469507 #endif
470508
....@@ -491,13 +529,13 @@
491529
492530 /* Datapath functions definition */
493531 netdev_tx_t qede_start_xmit(struct sk_buff *skb, struct net_device *ndev);
532
+int qede_xdp_transmit(struct net_device *dev, int n_frames,
533
+ struct xdp_frame **frames, u32 flags);
494534 u16 qede_select_queue(struct net_device *dev, struct sk_buff *skb,
495
- struct net_device *sb_dev,
496
- select_queue_fallback_t fallback);
535
+ struct net_device *sb_dev);
497536 netdev_features_t qede_features_check(struct sk_buff *skb,
498537 struct net_device *dev,
499538 netdev_features_t features);
500
-void qede_tx_log_print(struct qede_dev *edev, struct qede_fastpath *fp);
501539 int qede_alloc_rx_buffer(struct qede_rx_queue *rxq, bool allow_lazy);
502540 int qede_free_tx_pkt(struct qede_dev *edev,
503541 struct qede_tx_queue *txq, int *len);
....@@ -533,6 +571,7 @@
533571
534572 void qede_config_debug(uint debug, u32 *p_dp_module, u8 *p_dp_level);
535573 void qede_set_ethtool_ops(struct net_device *netdev);
574
+void qede_set_udp_tunnels(struct qede_dev *edev);
536575 void qede_reload(struct qede_dev *edev,
537576 struct qede_reload_args *args, bool is_locked);
538577 int qede_change_mtu(struct net_device *dev, int new_mtu);
....@@ -544,7 +583,9 @@
544583 void qede_recycle_rx_bd_ring(struct qede_rx_queue *rxq, u8 count);
545584 void qede_update_rx_prod(struct qede_dev *edev, struct qede_rx_queue *rxq);
546585 int qede_add_tc_flower_fltr(struct qede_dev *edev, __be16 proto,
547
- struct tc_cls_flower_offload *f);
586
+ struct flow_cls_offload *f);
587
+
588
+void qede_forced_speed_maps_init(void);
548589
549590 #define RX_RING_SIZE_POW 13
550591 #define RX_RING_SIZE ((u16)BIT(RX_RING_SIZE_POW))