forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/drivers/net/ethernet/aquantia/atlantic/aq_ring.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_ring.h: Declaration of functions for Rx/Tx rings. */
....@@ -17,13 +15,20 @@
1715 struct page;
1816 struct aq_nic_cfg_s;
1917
18
+struct aq_rxpage {
19
+ struct page *page;
20
+ dma_addr_t daddr;
21
+ unsigned int order;
22
+ unsigned int pg_off;
23
+};
24
+
2025 /* TxC SOP DX EOP
2126 * +----------+----------+----------+-----------
2227 * 8bytes|len l3,l4 | pa | pa | pa
2328 * +----------+----------+----------+-----------
2429 * 4/8bytes|len pkt |len pkt | | skb
2530 * +----------+----------+----------+-----------
26
- * 4/8bytes|is_txc |len,flags |len |len,is_eop
31
+ * 4/8bytes|is_gso |len,flags |len |len,is_eop
2732 * +----------+----------+----------+-----------
2833 *
2934 * This aq_ring_buff_s doesn't have endianness dependency.
....@@ -31,27 +36,21 @@
3136 */
3237 struct __packed aq_ring_buff_s {
3338 union {
39
+ /* RX/TX */
40
+ dma_addr_t pa;
3441 /* RX */
3542 struct {
3643 u32 rss_hash;
3744 u16 next;
3845 u8 is_hash_l4;
3946 u8 rsvd1;
40
- struct page *page;
47
+ struct aq_rxpage rxdata;
48
+ u16 vlan_rx_tag;
4149 };
4250 /* EOP */
4351 struct {
4452 dma_addr_t pa_eop;
4553 struct sk_buff *skb;
46
- };
47
- /* DX */
48
- struct {
49
- dma_addr_t pa;
50
- };
51
- /* SOP */
52
- struct {
53
- dma_addr_t pa_sop;
54
- u32 len_pkt_sop;
5554 };
5655 /* TxC */
5756 struct {
....@@ -62,22 +61,26 @@
6261 u8 is_ipv6:1;
6362 u8 rsvd2:7;
6463 u32 len_pkt;
64
+ u16 vlan_tx_tag;
6565 };
6666 };
6767 union {
6868 struct {
69
- u16 len;
69
+ u32 len:16;
7070 u32 is_ip_cso:1;
7171 u32 is_udp_cso:1;
7272 u32 is_tcp_cso:1;
7373 u32 is_cso_err:1;
7474 u32 is_sop:1;
7575 u32 is_eop:1;
76
- u32 is_txc:1;
76
+ u32 is_gso_tcp:1;
77
+ u32 is_gso_udp:1;
7778 u32 is_mapped:1;
7879 u32 is_cleaned:1;
7980 u32 is_error:1;
80
- u32 rsvd3:6;
81
+ u32 is_vlan:1;
82
+ u32 is_lro:1;
83
+ u32 rsvd3:3;
8184 u16 eop_index;
8285 u16 rsvd4;
8386 };
....@@ -86,14 +89,22 @@
8689 };
8790
8891 struct aq_ring_stats_rx_s {
92
+ struct u64_stats_sync syncp; /* must be first */
8993 u64 errors;
9094 u64 packets;
9195 u64 bytes;
9296 u64 lro_packets;
9397 u64 jumbo_packets;
98
+ u64 alloc_fails;
99
+ u64 skb_alloc_fails;
100
+ u64 polls;
101
+ u64 pg_losts;
102
+ u64 pg_flips;
103
+ u64 pg_reuses;
94104 };
95105
96106 struct aq_ring_stats_tx_s {
107
+ struct u64_stats_sync syncp; /* must be first */
97108 u64 errors;
98109 u64 packets;
99110 u64 bytes;
....@@ -103,6 +114,11 @@
103114 union aq_ring_stats_s {
104115 struct aq_ring_stats_rx_s rx;
105116 struct aq_ring_stats_tx_s tx;
117
+};
118
+
119
+enum atl_ring_type {
120
+ ATL_RING_TX,
121
+ ATL_RING_RX,
106122 };
107123
108124 struct aq_ring_s {
....@@ -116,8 +132,10 @@
116132 unsigned int size; /* descriptors number */
117133 unsigned int dx_size; /* TX or RX descriptor size, */
118134 /* stored here for fater math */
135
+ unsigned int page_order;
119136 union aq_ring_stats_s stats;
120137 dma_addr_t dx_ring_pa;
138
+ enum atl_ring_type ring_type;
121139 };
122140
123141 struct aq_ring_param_s {
....@@ -125,6 +143,16 @@
125143 unsigned int cpu;
126144 cpumask_t affinity_mask;
127145 };
146
+
147
+static inline void *aq_buf_vaddr(struct aq_rxpage *rxpage)
148
+{
149
+ return page_to_virt(rxpage->page) + rxpage->pg_off;
150
+}
151
+
152
+static inline dma_addr_t aq_buf_daddr(struct aq_rxpage *rxpage)
153
+{
154
+ return rxpage->daddr + rxpage->pg_off;
155
+}
128156
129157 static inline unsigned int aq_ring_next_dx(struct aq_ring_s *self,
130158 unsigned int dx)
....@@ -147,7 +175,7 @@
147175 struct aq_nic_s *aq_nic,
148176 unsigned int idx,
149177 struct aq_nic_cfg_s *aq_nic_cfg);
150
-int aq_ring_init(struct aq_ring_s *self);
178
+int aq_ring_init(struct aq_ring_s *self, const enum atl_ring_type ring_type);
151179 void aq_ring_rx_deinit(struct aq_ring_s *self);
152180 void aq_ring_free(struct aq_ring_s *self);
153181 void aq_ring_update_queue_state(struct aq_ring_s *ring);
....@@ -160,4 +188,11 @@
160188 int budget);
161189 int aq_ring_rx_fill(struct aq_ring_s *self);
162190
191
+struct aq_ring_s *aq_ring_hwts_rx_alloc(struct aq_ring_s *self,
192
+ struct aq_nic_s *aq_nic, unsigned int idx,
193
+ unsigned int size, unsigned int dx_size);
194
+void aq_ring_hwts_rx_clean(struct aq_ring_s *self, struct aq_nic_s *aq_nic);
195
+
196
+unsigned int aq_ring_fill_stats_data(struct aq_ring_s *self, u64 *data);
197
+
163198 #endif /* AQ_RING_H */