.. | .. |
---|
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 |
---|
4 | 3 | * |
---|
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. |
---|
8 | 6 | */ |
---|
9 | 7 | |
---|
10 | 8 | /* File aq_ring.h: Declaration of functions for Rx/Tx rings. */ |
---|
.. | .. |
---|
17 | 15 | struct page; |
---|
18 | 16 | struct aq_nic_cfg_s; |
---|
19 | 17 | |
---|
| 18 | +struct aq_rxpage { |
---|
| 19 | + struct page *page; |
---|
| 20 | + dma_addr_t daddr; |
---|
| 21 | + unsigned int order; |
---|
| 22 | + unsigned int pg_off; |
---|
| 23 | +}; |
---|
| 24 | + |
---|
20 | 25 | /* TxC SOP DX EOP |
---|
21 | 26 | * +----------+----------+----------+----------- |
---|
22 | 27 | * 8bytes|len l3,l4 | pa | pa | pa |
---|
23 | 28 | * +----------+----------+----------+----------- |
---|
24 | 29 | * 4/8bytes|len pkt |len pkt | | skb |
---|
25 | 30 | * +----------+----------+----------+----------- |
---|
26 | | - * 4/8bytes|is_txc |len,flags |len |len,is_eop |
---|
| 31 | + * 4/8bytes|is_gso |len,flags |len |len,is_eop |
---|
27 | 32 | * +----------+----------+----------+----------- |
---|
28 | 33 | * |
---|
29 | 34 | * This aq_ring_buff_s doesn't have endianness dependency. |
---|
.. | .. |
---|
31 | 36 | */ |
---|
32 | 37 | struct __packed aq_ring_buff_s { |
---|
33 | 38 | union { |
---|
| 39 | + /* RX/TX */ |
---|
| 40 | + dma_addr_t pa; |
---|
34 | 41 | /* RX */ |
---|
35 | 42 | struct { |
---|
36 | 43 | u32 rss_hash; |
---|
37 | 44 | u16 next; |
---|
38 | 45 | u8 is_hash_l4; |
---|
39 | 46 | u8 rsvd1; |
---|
40 | | - struct page *page; |
---|
| 47 | + struct aq_rxpage rxdata; |
---|
| 48 | + u16 vlan_rx_tag; |
---|
41 | 49 | }; |
---|
42 | 50 | /* EOP */ |
---|
43 | 51 | struct { |
---|
44 | 52 | dma_addr_t pa_eop; |
---|
45 | 53 | 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; |
---|
55 | 54 | }; |
---|
56 | 55 | /* TxC */ |
---|
57 | 56 | struct { |
---|
.. | .. |
---|
62 | 61 | u8 is_ipv6:1; |
---|
63 | 62 | u8 rsvd2:7; |
---|
64 | 63 | u32 len_pkt; |
---|
| 64 | + u16 vlan_tx_tag; |
---|
65 | 65 | }; |
---|
66 | 66 | }; |
---|
67 | 67 | union { |
---|
68 | 68 | struct { |
---|
69 | | - u16 len; |
---|
| 69 | + u32 len:16; |
---|
70 | 70 | u32 is_ip_cso:1; |
---|
71 | 71 | u32 is_udp_cso:1; |
---|
72 | 72 | u32 is_tcp_cso:1; |
---|
73 | 73 | u32 is_cso_err:1; |
---|
74 | 74 | u32 is_sop:1; |
---|
75 | 75 | u32 is_eop:1; |
---|
76 | | - u32 is_txc:1; |
---|
| 76 | + u32 is_gso_tcp:1; |
---|
| 77 | + u32 is_gso_udp:1; |
---|
77 | 78 | u32 is_mapped:1; |
---|
78 | 79 | u32 is_cleaned:1; |
---|
79 | 80 | u32 is_error:1; |
---|
80 | | - u32 rsvd3:6; |
---|
| 81 | + u32 is_vlan:1; |
---|
| 82 | + u32 is_lro:1; |
---|
| 83 | + u32 rsvd3:3; |
---|
81 | 84 | u16 eop_index; |
---|
82 | 85 | u16 rsvd4; |
---|
83 | 86 | }; |
---|
.. | .. |
---|
86 | 89 | }; |
---|
87 | 90 | |
---|
88 | 91 | struct aq_ring_stats_rx_s { |
---|
| 92 | + struct u64_stats_sync syncp; /* must be first */ |
---|
89 | 93 | u64 errors; |
---|
90 | 94 | u64 packets; |
---|
91 | 95 | u64 bytes; |
---|
92 | 96 | u64 lro_packets; |
---|
93 | 97 | 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; |
---|
94 | 104 | }; |
---|
95 | 105 | |
---|
96 | 106 | struct aq_ring_stats_tx_s { |
---|
| 107 | + struct u64_stats_sync syncp; /* must be first */ |
---|
97 | 108 | u64 errors; |
---|
98 | 109 | u64 packets; |
---|
99 | 110 | u64 bytes; |
---|
.. | .. |
---|
103 | 114 | union aq_ring_stats_s { |
---|
104 | 115 | struct aq_ring_stats_rx_s rx; |
---|
105 | 116 | struct aq_ring_stats_tx_s tx; |
---|
| 117 | +}; |
---|
| 118 | + |
---|
| 119 | +enum atl_ring_type { |
---|
| 120 | + ATL_RING_TX, |
---|
| 121 | + ATL_RING_RX, |
---|
106 | 122 | }; |
---|
107 | 123 | |
---|
108 | 124 | struct aq_ring_s { |
---|
.. | .. |
---|
116 | 132 | unsigned int size; /* descriptors number */ |
---|
117 | 133 | unsigned int dx_size; /* TX or RX descriptor size, */ |
---|
118 | 134 | /* stored here for fater math */ |
---|
| 135 | + unsigned int page_order; |
---|
119 | 136 | union aq_ring_stats_s stats; |
---|
120 | 137 | dma_addr_t dx_ring_pa; |
---|
| 138 | + enum atl_ring_type ring_type; |
---|
121 | 139 | }; |
---|
122 | 140 | |
---|
123 | 141 | struct aq_ring_param_s { |
---|
.. | .. |
---|
125 | 143 | unsigned int cpu; |
---|
126 | 144 | cpumask_t affinity_mask; |
---|
127 | 145 | }; |
---|
| 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 | +} |
---|
128 | 156 | |
---|
129 | 157 | static inline unsigned int aq_ring_next_dx(struct aq_ring_s *self, |
---|
130 | 158 | unsigned int dx) |
---|
.. | .. |
---|
147 | 175 | struct aq_nic_s *aq_nic, |
---|
148 | 176 | unsigned int idx, |
---|
149 | 177 | 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); |
---|
151 | 179 | void aq_ring_rx_deinit(struct aq_ring_s *self); |
---|
152 | 180 | void aq_ring_free(struct aq_ring_s *self); |
---|
153 | 181 | void aq_ring_update_queue_state(struct aq_ring_s *ring); |
---|
.. | .. |
---|
160 | 188 | int budget); |
---|
161 | 189 | int aq_ring_rx_fill(struct aq_ring_s *self); |
---|
162 | 190 | |
---|
| 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 | + |
---|
163 | 198 | #endif /* AQ_RING_H */ |
---|