forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 95099d4622f8cb224d94e314c7a8e0df60b13f87
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,23 @@
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;
260276 };
261277
262278 enum QEDE_STATE {
263279 QEDE_STATE_CLOSED,
264280 QEDE_STATE_OPEN,
281
+ QEDE_STATE_RECOVERY,
265282 };
266283
267284 #define HILO_U64(hi, lo) ((((u64)(hi)) << 32) + (lo))
....@@ -366,28 +383,34 @@
366383 };
367384
368385 struct sw_tx_xdp {
369
- struct page *page;
370
- dma_addr_t mapping;
386
+ struct page *page;
387
+ struct xdp_frame *xdpf;
388
+ dma_addr_t mapping;
371389 };
372390
373391 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 */
392
+ u8 is_xdp;
393
+ bool is_legacy;
394
+ u16 sw_tx_cons;
395
+ u16 sw_tx_prod;
396
+ u16 num_tx_buffers; /* Slowpath only */
379397
380
- u64 xmit_pkts;
381
- u64 stopped_cnt;
398
+ u64 xmit_pkts;
399
+ u64 stopped_cnt;
400
+ u64 tx_mem_alloc_err;
382401
383
- __le16 *hw_cons_ptr;
402
+ __le16 *hw_cons_ptr;
384403
385404 /* Needed for the mapping of packets */
386
- struct device *dev;
405
+ struct device *dev;
387406
388
- void __iomem *doorbell_addr;
389
- union db_prod tx_db;
390
- int index; /* Slowpath only */
407
+ void __iomem *doorbell_addr;
408
+ union db_prod tx_db;
409
+
410
+ /* Spinlock for XDP queues in case of XDP_REDIRECT */
411
+ spinlock_t xdp_tx_lock;
412
+
413
+ int index; /* Slowpath only */
391414 #define QEDE_TXQ_XDP_TO_IDX(edev, txq) ((txq)->index - \
392415 QEDE_MAX_TSS_CNT(edev))
393416 #define QEDE_TXQ_IDX_TO_XDP(edev, idx) ((idx) + QEDE_MAX_TSS_CNT(edev))
....@@ -399,22 +422,22 @@
399422 #define QEDE_NDEV_TXQ_ID_TO_TXQ(edev, idx) \
400423 (&((edev)->fp_array[QEDE_NDEV_TXQ_ID_TO_FP_ID(edev, idx)].txq \
401424 [QEDE_NDEV_TXQ_ID_TO_TXQ_COS(edev, idx)]))
402
-#define QEDE_FP_TC0_TXQ(fp) (&((fp)->txq[0]))
425
+#define QEDE_FP_TC0_TXQ(fp) (&((fp)->txq[0]))
403426
404427 /* Regular Tx requires skb + metadata for release purpose,
405428 * while XDP requires the pages and the mapped address.
406429 */
407430 union {
408
- struct sw_tx_bd *skbs;
409
- struct sw_tx_xdp *xdp;
410
- } sw_tx_ring;
431
+ struct sw_tx_bd *skbs;
432
+ struct sw_tx_xdp *xdp;
433
+ } sw_tx_ring;
411434
412
- struct qed_chain tx_pbl;
435
+ struct qed_chain tx_pbl;
413436
414437 /* Slowpath; Should be kept in end [unless missing padding] */
415
- void *handle;
416
- u16 cos;
417
- u16 ndev_txq_id;
438
+ void *handle;
439
+ u16 cos;
440
+ u16 ndev_txq_id;
418441 };
419442
420443 #define BD_UNMAP_ADDR(bd) HILO_U64(le32_to_cpu((bd)->addr.hi), \
....@@ -428,43 +451,54 @@
428451 #define BD_UNMAP_LEN(bd) (le16_to_cpu((bd)->nbytes))
429452
430453 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;
454
+ struct qede_dev *edev;
444455
445
-#define VEC_NAME_SIZE (sizeof(((struct net_device *)0)->name) + 8)
446
- char name[VEC_NAME_SIZE];
456
+ u8 type;
457
+#define QEDE_FASTPATH_TX BIT(0)
458
+#define QEDE_FASTPATH_RX BIT(1)
459
+#define QEDE_FASTPATH_XDP BIT(2)
460
+#define QEDE_FASTPATH_COMBINED (QEDE_FASTPATH_TX | QEDE_FASTPATH_RX)
461
+
462
+ u8 id;
463
+
464
+ u8 xdp_xmit;
465
+#define QEDE_XDP_TX BIT(0)
466
+#define QEDE_XDP_REDIRECT BIT(1)
467
+
468
+ struct napi_struct napi;
469
+ struct qed_sb_info *sb_info;
470
+ struct qede_rx_queue *rxq;
471
+ struct qede_tx_queue *txq;
472
+ struct qede_tx_queue *xdp_tx;
473
+
474
+ char name[IFNAMSIZ + 8];
447475 };
448476
449477 /* Debug print definitions */
450
-#define DP_NAME(edev) ((edev)->ndev->name)
478
+#define DP_NAME(edev) netdev_name((edev)->ndev)
451479
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)
480
+#define XMIT_PLAIN 0
481
+#define XMIT_L4_CSUM BIT(0)
482
+#define XMIT_LSO BIT(1)
483
+#define XMIT_ENC BIT(2)
484
+#define XMIT_ENC_GSO_L4_CSUM BIT(3)
457485
458486 #define QEDE_CSUM_ERROR BIT(0)
459487 #define QEDE_CSUM_UNNECESSARY BIT(1)
460488 #define QEDE_TUNN_CSUM_UNNECESSARY BIT(2)
461489
490
+#define QEDE_SP_RECOVERY 0
462491 #define QEDE_SP_RX_MODE 1
492
+#define QEDE_SP_RSVD1 2
493
+#define QEDE_SP_RSVD2 3
494
+#define QEDE_SP_HW_ERR 4
495
+#define QEDE_SP_ARFS_CONFIG 5
496
+#define QEDE_SP_AER 7
497
+#define QEDE_SP_DISABLE 8
463498
464499 #ifdef CONFIG_RFS_ACCEL
465500 int qede_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb,
466501 u16 rxq_index, u32 flow_id);
467
-#define QEDE_SP_ARFS_CONFIG 4
468502 #define QEDE_SP_TASK_POLL_DELAY (5 * HZ)
469503 #endif
470504
....@@ -491,13 +525,13 @@
491525
492526 /* Datapath functions definition */
493527 netdev_tx_t qede_start_xmit(struct sk_buff *skb, struct net_device *ndev);
528
+int qede_xdp_transmit(struct net_device *dev, int n_frames,
529
+ struct xdp_frame **frames, u32 flags);
494530 u16 qede_select_queue(struct net_device *dev, struct sk_buff *skb,
495
- struct net_device *sb_dev,
496
- select_queue_fallback_t fallback);
531
+ struct net_device *sb_dev);
497532 netdev_features_t qede_features_check(struct sk_buff *skb,
498533 struct net_device *dev,
499534 netdev_features_t features);
500
-void qede_tx_log_print(struct qede_dev *edev, struct qede_fastpath *fp);
501535 int qede_alloc_rx_buffer(struct qede_rx_queue *rxq, bool allow_lazy);
502536 int qede_free_tx_pkt(struct qede_dev *edev,
503537 struct qede_tx_queue *txq, int *len);
....@@ -533,6 +567,7 @@
533567
534568 void qede_config_debug(uint debug, u32 *p_dp_module, u8 *p_dp_level);
535569 void qede_set_ethtool_ops(struct net_device *netdev);
570
+void qede_set_udp_tunnels(struct qede_dev *edev);
536571 void qede_reload(struct qede_dev *edev,
537572 struct qede_reload_args *args, bool is_locked);
538573 int qede_change_mtu(struct net_device *dev, int new_mtu);
....@@ -544,7 +579,9 @@
544579 void qede_recycle_rx_bd_ring(struct qede_rx_queue *rxq, u8 count);
545580 void qede_update_rx_prod(struct qede_dev *edev, struct qede_rx_queue *rxq);
546581 int qede_add_tc_flower_fltr(struct qede_dev *edev, __be16 proto,
547
- struct tc_cls_flower_offload *f);
582
+ struct flow_cls_offload *f);
583
+
584
+void qede_forced_speed_maps_init(void);
548585
549586 #define RX_RING_SIZE_POW 13
550587 #define RX_RING_SIZE ((u16)BIT(RX_RING_SIZE_POW))