Rakesh Nair | 9bcf260 | 2017-01-06 16:02:16 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2014 - 2017, The Linux Foundation. All rights reserved. |
| 3 | * |
| 4 | * Permission to use, copy, modify, and/or distribute this software for |
| 5 | * any purpose with or without fee is hereby granted, provided that the |
| 6 | * above copyright notice and this permission notice appear in all copies. |
| 7 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 8 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 9 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 10 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 11 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 12 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT |
| 13 | * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 14 | */ |
| 15 | |
| 16 | #ifndef _EDMA_H_ |
| 17 | #define _EDMA_H_ |
| 18 | |
| 19 | #include <linux/init.h> |
| 20 | #include <linux/interrupt.h> |
| 21 | #include <linux/types.h> |
| 22 | #include <linux/errno.h> |
| 23 | #include <linux/module.h> |
| 24 | #include <linux/netdevice.h> |
| 25 | #include <linux/etherdevice.h> |
| 26 | #include <linux/skbuff.h> |
| 27 | #include <linux/io.h> |
| 28 | #include <linux/vmalloc.h> |
| 29 | #include <linux/pagemap.h> |
| 30 | #include <linux/smp.h> |
| 31 | #include <linux/platform_device.h> |
| 32 | #include <linux/of.h> |
| 33 | #include <linux/of_device.h> |
| 34 | #include <linux/kernel.h> |
| 35 | #include <linux/device.h> |
| 36 | #include <linux/sysctl.h> |
| 37 | #include <linux/phy.h> |
| 38 | #include <linux/of_net.h> |
| 39 | #include <net/checksum.h> |
| 40 | #include <net/ip6_checksum.h> |
| 41 | #include <asm-generic/bug.h> |
| 42 | #include <linux/version.h> |
Rakesh Nair | 7e05353 | 2017-08-18 17:53:25 +0530 | [diff] [blame^] | 43 | #include <linux/ppp_defs.h> |
| 44 | #include <linux/if_pppox.h> |
Rakesh Nair | 9bcf260 | 2017-01-06 16:02:16 +0530 | [diff] [blame] | 45 | #include "ess_edma.h" |
| 46 | |
| 47 | #define EDMA_CPU_CORES_SUPPORTED 4 |
| 48 | #define EDMA_MAX_PORTID_SUPPORTED 5 |
| 49 | #define EDMA_MAX_VLAN_SUPPORTED EDMA_MAX_PORTID_SUPPORTED |
| 50 | #define EDMA_MAX_PORTID_BITMAP_INDEX (EDMA_MAX_PORTID_SUPPORTED + 1) |
| 51 | #define EDMA_MAX_PORTID_BITMAP_SUPPORTED 0x1f /* 0001_1111 = 0x1f */ |
| 52 | #define EDMA_MAX_NETDEV_PER_QUEUE 4 /* 3 Netdev per queue, 1 space for indexing */ |
| 53 | |
| 54 | #define EDMA_MAX_RECEIVE_QUEUE 8 |
| 55 | #define EDMA_MAX_TRANSMIT_QUEUE 16 |
| 56 | |
| 57 | /* WAN/LAN adapter number */ |
| 58 | #define EDMA_WAN 0 |
| 59 | #define EDMA_LAN 1 |
| 60 | |
| 61 | /* VLAN tag */ |
| 62 | #define EDMA_LAN_DEFAULT_VLAN 1 |
| 63 | #define EDMA_WAN_DEFAULT_VLAN 2 |
| 64 | |
| 65 | #define EDMA_DEFAULT_GROUP1_VLAN 2 |
| 66 | #define EDMA_DEFAULT_GROUP2_VLAN 1 |
| 67 | #define EDMA_DEFAULT_GROUP3_VLAN 3 |
| 68 | #define EDMA_DEFAULT_GROUP4_VLAN 4 |
| 69 | #define EDMA_DEFAULT_GROUP5_VLAN 5 |
| 70 | |
| 71 | #define EDMA_DEFAULT_GROUP1_BMP 0x20 |
| 72 | #define EDMA_DEFAULT_GROUP2_BMP 0x1e |
| 73 | |
| 74 | #define EDMA_DEFAULT_DISABLE_RSS 0 |
| 75 | #define EDMA_RSS_DISABLE 1 |
| 76 | #define EDMA_RSS_ENABLE 0 |
| 77 | |
| 78 | /* Queues exposed to linux kernel */ |
| 79 | #define EDMA_NETDEV_TX_QUEUE 4 |
| 80 | #define EDMA_NETDEV_RX_QUEUE 4 |
| 81 | |
| 82 | /* Number of queues per core */ |
| 83 | #define EDMA_NUM_TXQ_PER_CORE 4 |
| 84 | #define EDMA_NUM_RXQ_PER_CORE 2 |
| 85 | |
| 86 | #define EDMA_TPD_EOP_SHIFT 31 |
| 87 | |
| 88 | #define EDMA_PORT_ID_SHIFT 12 |
| 89 | #define EDMA_PORT_ID_MASK 0x7 |
| 90 | |
| 91 | /* tpd word 3 bit 18-28 */ |
| 92 | #define EDMA_TPD_PORT_BITMAP_SHIFT 18 |
| 93 | |
Rakesh Nair | 888af95 | 2017-06-30 18:41:58 +0530 | [diff] [blame] | 94 | /* tpd word 3 bit 29-31 */ |
| 95 | #define EDMA_TPD_PRIO_SHIFT 29 |
| 96 | |
Rakesh Nair | 9bcf260 | 2017-01-06 16:02:16 +0530 | [diff] [blame] | 97 | #define EDMA_TPD_FROM_CPU_SHIFT 25 |
| 98 | |
| 99 | #define EDMA_FROM_CPU_MASK 0x80 |
| 100 | #define EDMA_SKB_PRIORITY_MASK 0x38 |
| 101 | |
| 102 | /* TX/RX descriptor ring count */ |
| 103 | /* should be a power of 2 */ |
| 104 | #define EDMA_RX_RING_SIZE 512 |
| 105 | #define EDMA_TX_RING_SIZE 512 |
| 106 | |
| 107 | /* Flags used in paged/non paged mode */ |
| 108 | #define EDMA_RX_HEAD_BUFF_SIZE_JUMBO 256 |
| 109 | #define EDMA_RX_HEAD_BUFF_SIZE 1540 |
| 110 | |
| 111 | /* MAX frame size supported by switch */ |
| 112 | #define EDMA_MAX_JUMBO_FRAME_SIZE 9216 |
| 113 | |
| 114 | /* Configurations */ |
| 115 | #define EDMA_INTR_CLEAR_TYPE 0 |
| 116 | #define EDMA_INTR_SW_IDX_W_TYPE 0 |
| 117 | #define EDMA_FIFO_THRESH_TYPE 0 |
| 118 | #define EDMA_RSS_TYPE 0 |
| 119 | #define EDMA_RX_IMT 0x0020 |
| 120 | #define EDMA_TX_IMT 0x0050 |
| 121 | #define EDMA_TPD_BURST 5 |
| 122 | #define EDMA_TXF_BURST 0x100 |
| 123 | #define EDMA_RFD_BURST 8 |
| 124 | #define EDMA_RFD_THR 16 |
| 125 | #define EDMA_RFD_LTHR 0 |
| 126 | |
| 127 | /* RX/TX per CPU based mask/shift */ |
| 128 | #define EDMA_TX_PER_CPU_MASK 0xF |
| 129 | #define EDMA_RX_PER_CPU_MASK 0x3 |
| 130 | #define EDMA_TX_PER_CPU_MASK_SHIFT 0x2 |
| 131 | #define EDMA_RX_PER_CPU_MASK_SHIFT 0x1 |
| 132 | #define EDMA_TX_CPU_START_SHIFT 0x2 |
| 133 | #define EDMA_RX_CPU_START_SHIFT 0x1 |
| 134 | |
| 135 | /* FLags used in transmit direction */ |
| 136 | #define EDMA_HW_CHECKSUM 0x00000001 |
| 137 | #define EDMA_VLAN_TX_TAG_INSERT_FLAG 0x00000002 |
| 138 | #define EDMA_VLAN_TX_TAG_INSERT_DEFAULT_FLAG 0x00000004 |
| 139 | |
| 140 | #define EDMA_SW_DESC_FLAG_LAST 0x1 |
| 141 | #define EDMA_SW_DESC_FLAG_SKB_HEAD 0x2 |
| 142 | #define EDMA_SW_DESC_FLAG_SKB_FRAG 0x4 |
| 143 | #define EDMA_SW_DESC_FLAG_SKB_FRAGLIST 0x8 |
| 144 | #define EDMA_SW_DESC_FLAG_SKB_NONE 0x10 |
| 145 | #define EDMA_SW_DESC_FLAG_SKB_REUSE 0x20 |
| 146 | |
| 147 | |
| 148 | #define EDMA_MAX_SKB_FRAGS (MAX_SKB_FRAGS + 1) |
| 149 | |
| 150 | /* Ethtool specific list of EDMA supported features */ |
| 151 | #define EDMA_SUPPORTED_FEATURES (SUPPORTED_10baseT_Half \ |
| 152 | | SUPPORTED_10baseT_Full \ |
| 153 | | SUPPORTED_100baseT_Half \ |
| 154 | | SUPPORTED_100baseT_Full \ |
| 155 | | SUPPORTED_1000baseT_Full) |
| 156 | |
| 157 | /* Recevie side atheros Header */ |
| 158 | #define EDMA_RX_ATH_HDR_VERSION 0x2 |
| 159 | #define EDMA_RX_ATH_HDR_VERSION_SHIFT 14 |
| 160 | #define EDMA_RX_ATH_HDR_PRIORITY_SHIFT 11 |
| 161 | #define EDMA_RX_ATH_PORT_TYPE_SHIFT 6 |
| 162 | #define EDMA_RX_ATH_HDR_RSTP_PORT_TYPE 0x4 |
| 163 | |
| 164 | /* Transmit side atheros Header */ |
| 165 | #define EDMA_TX_ATH_HDR_PORT_BITMAP_MASK 0x7F |
| 166 | #define EDMA_TX_ATH_HDR_FROM_CPU_MASK 0x80 |
| 167 | #define EDMA_TX_ATH_HDR_FROM_CPU_SHIFT 7 |
| 168 | |
| 169 | #define EDMA_TXQ_START_CORE0 8 |
| 170 | #define EDMA_TXQ_START_CORE1 12 |
| 171 | #define EDMA_TXQ_START_CORE2 0 |
| 172 | #define EDMA_TXQ_START_CORE3 4 |
| 173 | |
| 174 | #define EDMA_TXQ_IRQ_MASK_CORE0 0x0F00 |
| 175 | #define EDMA_TXQ_IRQ_MASK_CORE1 0xF000 |
| 176 | #define EDMA_TXQ_IRQ_MASK_CORE2 0x000F |
| 177 | #define EDMA_TXQ_IRQ_MASK_CORE3 0x00F0 |
| 178 | |
| 179 | #define EDMA_ETH_HDR_LEN 12 |
| 180 | #define EDMA_ETH_TYPE_MASK 0xFFFF |
| 181 | |
| 182 | #define EDMA_RX_BUFFER_WRITE 16 |
| 183 | #define EDMA_RFD_AVAIL_THR 80 |
| 184 | |
| 185 | #define EDMA_GMAC_NO_MDIO_PHY PHY_MAX_ADDR |
| 186 | |
Rakesh Nair | 888af95 | 2017-06-30 18:41:58 +0530 | [diff] [blame] | 187 | #define EDMA_PRECEDENCE_MAX 8 |
| 188 | |
| 189 | #define EDMA_AC_BK 0 /* Access Category: Background */ |
| 190 | #define EDMA_AC_BE 1 /* Access Category: Best Effort */ |
| 191 | #define EDMA_AC_VI 2 /* Access Category: Video */ |
| 192 | #define EDMA_AC_VO 3 /* Access Category: Voice */ |
| 193 | #define EDMA_AC_MAX 4 |
| 194 | |
| 195 | #define EDMA_DSCP2AC_INPUT_PARAMS_MAX 2 |
| 196 | |
Rakesh Nair | 9bcf260 | 2017-01-06 16:02:16 +0530 | [diff] [blame] | 197 | extern int ssdk_rfs_ipct_rule_set(__be32 ip_src, __be32 ip_dst, |
| 198 | __be16 sport, __be16 dport, |
| 199 | uint8_t proto, u16 loadbalance, bool action); |
Rakesh Nair | 03824d5 | 2017-07-31 17:10:49 +0530 | [diff] [blame] | 200 | |
Rakesh Nair | 9bcf260 | 2017-01-06 16:02:16 +0530 | [diff] [blame] | 201 | struct edma_ethtool_statistics { |
Bhaskar Valaboju | e429bab | 2017-03-15 09:01:23 +0530 | [diff] [blame] | 202 | u64 tx_q0_pkt; |
| 203 | u64 tx_q1_pkt; |
| 204 | u64 tx_q2_pkt; |
| 205 | u64 tx_q3_pkt; |
| 206 | u64 tx_q4_pkt; |
| 207 | u64 tx_q5_pkt; |
| 208 | u64 tx_q6_pkt; |
| 209 | u64 tx_q7_pkt; |
| 210 | u64 tx_q8_pkt; |
| 211 | u64 tx_q9_pkt; |
| 212 | u64 tx_q10_pkt; |
| 213 | u64 tx_q11_pkt; |
| 214 | u64 tx_q12_pkt; |
| 215 | u64 tx_q13_pkt; |
| 216 | u64 tx_q14_pkt; |
| 217 | u64 tx_q15_pkt; |
| 218 | u64 tx_q0_byte; |
| 219 | u64 tx_q1_byte; |
| 220 | u64 tx_q2_byte; |
| 221 | u64 tx_q3_byte; |
| 222 | u64 tx_q4_byte; |
| 223 | u64 tx_q5_byte; |
| 224 | u64 tx_q6_byte; |
| 225 | u64 tx_q7_byte; |
| 226 | u64 tx_q8_byte; |
| 227 | u64 tx_q9_byte; |
| 228 | u64 tx_q10_byte; |
| 229 | u64 tx_q11_byte; |
| 230 | u64 tx_q12_byte; |
| 231 | u64 tx_q13_byte; |
| 232 | u64 tx_q14_byte; |
| 233 | u64 tx_q15_byte; |
| 234 | u64 rx_q0_pkt; |
| 235 | u64 rx_q1_pkt; |
| 236 | u64 rx_q2_pkt; |
| 237 | u64 rx_q3_pkt; |
| 238 | u64 rx_q4_pkt; |
| 239 | u64 rx_q5_pkt; |
| 240 | u64 rx_q6_pkt; |
| 241 | u64 rx_q7_pkt; |
| 242 | u64 rx_q0_byte; |
| 243 | u64 rx_q1_byte; |
| 244 | u64 rx_q2_byte; |
| 245 | u64 rx_q3_byte; |
| 246 | u64 rx_q4_byte; |
| 247 | u64 rx_q5_byte; |
| 248 | u64 rx_q6_byte; |
| 249 | u64 rx_q7_byte; |
| 250 | u64 tx_desc_error; |
Rakesh Nair | 03b586c | 2017-04-03 18:28:58 +0530 | [diff] [blame] | 251 | u64 rx_alloc_fail_ctr; |
Rakesh Nair | 888af95 | 2017-06-30 18:41:58 +0530 | [diff] [blame] | 252 | u64 tx_prec[EDMA_PRECEDENCE_MAX]; |
| 253 | u64 rx_prec[EDMA_PRECEDENCE_MAX]; |
| 254 | u64 rx_ac[EDMA_AC_MAX]; |
| 255 | u64 tx_ac[EDMA_AC_MAX]; |
Rakesh Nair | 9bcf260 | 2017-01-06 16:02:16 +0530 | [diff] [blame] | 256 | }; |
| 257 | |
| 258 | struct edma_mdio_data { |
| 259 | struct mii_bus *mii_bus; |
| 260 | void __iomem *membase; |
| 261 | int phy_irq[PHY_MAX_ADDR]; |
| 262 | }; |
| 263 | |
| 264 | /* EDMA LINK state */ |
| 265 | enum edma_link_state { |
| 266 | __EDMA_LINKUP, /* Indicate link is UP */ |
| 267 | __EDMA_LINKDOWN /* Indicate link is down */ |
| 268 | }; |
| 269 | |
| 270 | /* EDMA GMAC state */ |
| 271 | enum edma_gmac_state { |
| 272 | __EDMA_UP /* use to indicate GMAC is up */ |
| 273 | }; |
| 274 | |
| 275 | /* edma transmit descriptor */ |
| 276 | struct edma_tx_desc { |
| 277 | __le16 len; /* full packet including CRC */ |
| 278 | __le16 svlan_tag; /* vlan tag */ |
| 279 | __le32 word1; /* byte 4-7 */ |
| 280 | __le32 addr; /* address of buffer */ |
| 281 | __le32 word3; /* byte 12 */ |
| 282 | }; |
| 283 | |
| 284 | /* edma receive return descriptor */ |
| 285 | struct edma_rx_return_desc { |
| 286 | u16 rrd0; |
| 287 | u16 rrd1; |
| 288 | u16 rrd2; |
| 289 | u16 rrd3; |
| 290 | u16 rrd4; |
| 291 | u16 rrd5; |
| 292 | u16 rrd6; |
| 293 | u16 rrd7; |
| 294 | }; |
| 295 | |
| 296 | /* RFD descriptor */ |
| 297 | struct edma_rx_free_desc { |
| 298 | __le32 buffer_addr; /* buffer address */ |
| 299 | }; |
| 300 | |
| 301 | /* edma hw specific data */ |
| 302 | struct edma_hw { |
| 303 | u32 __iomem *hw_addr; /* inner register address */ |
| 304 | struct edma_adapter *adapter; /* netdevice adapter */ |
| 305 | u32 rx_intr_mask; /*rx interrupt mask */ |
| 306 | u32 tx_intr_mask; /* tx interrupt nask */ |
| 307 | u32 misc_intr_mask; /* misc interrupt mask */ |
| 308 | u32 wol_intr_mask; /* wake on lan interrupt mask */ |
| 309 | bool intr_clear_type; /* interrupt clear */ |
| 310 | bool intr_sw_idx_w; /* interrupt software index */ |
| 311 | u32 rx_head_buff_size; /* Rx buffer size */ |
| 312 | u8 rss_type; /* rss protocol type */ |
| 313 | }; |
| 314 | |
| 315 | /* edma_sw_desc stores software descriptor |
| 316 | * SW descriptor has 1:1 map with HW descriptor |
| 317 | */ |
| 318 | struct edma_sw_desc { |
| 319 | struct sk_buff *skb; |
| 320 | dma_addr_t dma; /* dma address */ |
| 321 | u16 length; /* Tx/Rx buffer length */ |
| 322 | u32 flags; |
| 323 | }; |
| 324 | |
| 325 | /* per core related information */ |
| 326 | struct edma_per_cpu_queues_info { |
| 327 | struct napi_struct napi; /* napi associated with the core */ |
| 328 | u32 tx_mask; /* tx interrupt mask */ |
| 329 | u32 rx_mask; /* rx interrupt mask */ |
| 330 | u32 tx_status; /* tx interrupt status */ |
| 331 | u32 rx_status; /* rx interrupt status */ |
| 332 | u32 tx_start; /* tx queue start */ |
| 333 | u32 rx_start; /* rx queue start */ |
| 334 | struct edma_common_info *edma_cinfo; /* edma common info */ |
| 335 | }; |
| 336 | |
| 337 | /* edma specific common info */ |
| 338 | struct edma_common_info { |
| 339 | struct edma_tx_desc_ring *tpd_ring[16]; /* 16 Tx queues */ |
| 340 | struct edma_rfd_desc_ring *rfd_ring[8]; /* 8 Rx queues */ |
| 341 | struct platform_device *pdev; /* device structure */ |
| 342 | struct net_device *netdev[EDMA_MAX_PORTID_SUPPORTED]; |
| 343 | struct net_device *portid_netdev_lookup_tbl[EDMA_MAX_PORTID_BITMAP_INDEX]; |
| 344 | struct ctl_table_header *edma_ctl_table_hdr; |
| 345 | int num_gmac; |
| 346 | struct edma_ethtool_statistics edma_ethstats; /* ethtool stats */ |
| 347 | u32 num_rx_queues; /* number of rx queue */ |
| 348 | u32 num_tx_queues; /* number of tx queue */ |
| 349 | u32 tx_irq[16]; /* number of tx irq */ |
| 350 | u32 rx_irq[8]; /* number of rx irq */ |
| 351 | u32 from_cpu; /* from CPU TPD field */ |
| 352 | u32 num_rxq_per_core; /* Rx queues per core */ |
| 353 | u32 num_txq_per_core; /* Tx queues per core */ |
| 354 | u16 tx_ring_count; /* Tx ring count */ |
| 355 | u16 rx_ring_count; /* Rx ring*/ |
| 356 | u16 rx_head_buffer_len; /* rx buffer length */ |
| 357 | u16 rx_page_buffer_len; /* rx buffer length */ |
| 358 | u32 page_mode; /* Jumbo frame supported flag */ |
| 359 | u32 fraglist_mode; /* fraglist supported flag */ |
| 360 | struct edma_hw hw; /* edma hw specific structure */ |
| 361 | struct edma_per_cpu_queues_info edma_percpu_info[CONFIG_NR_CPUS]; /* per cpu information */ |
| 362 | spinlock_t stats_lock; /* protect edma stats area for updation */ |
Rakesh Nair | 03824d5 | 2017-07-31 17:10:49 +0530 | [diff] [blame] | 363 | u32 num_cores; |
Rakesh Nair | 9bcf260 | 2017-01-06 16:02:16 +0530 | [diff] [blame] | 364 | }; |
| 365 | |
| 366 | /* transimit packet descriptor (tpd) ring */ |
| 367 | struct edma_tx_desc_ring { |
| 368 | struct netdev_queue *nq[EDMA_MAX_NETDEV_PER_QUEUE]; /* Linux queue index */ |
| 369 | struct net_device *netdev[EDMA_MAX_NETDEV_PER_QUEUE]; |
| 370 | /* Array of netdevs associated with the tpd ring */ |
| 371 | void *hw_desc; /* descriptor ring virtual address */ |
| 372 | struct edma_sw_desc *sw_desc; /* buffer associated with ring */ |
| 373 | int netdev_bmp; /* Bitmap for per-ring netdevs */ |
| 374 | u32 size; /* descriptor ring length in bytes */ |
| 375 | u16 count; /* number of descriptors in the ring */ |
| 376 | dma_addr_t dma; /* descriptor ring physical address */ |
| 377 | u16 sw_next_to_fill; /* next Tx descriptor to fill */ |
| 378 | u16 sw_next_to_clean; /* next Tx descriptor to clean */ |
| 379 | }; |
| 380 | |
| 381 | /* receive free descriptor (rfd) ring */ |
| 382 | struct edma_rfd_desc_ring { |
| 383 | struct edma_rx_free_desc *hw_desc; /* descriptor ring virtual address */ |
| 384 | struct edma_sw_desc *sw_desc; /* buffer associated with ring */ |
| 385 | u16 size; /* bytes allocated to sw_desc */ |
| 386 | u16 count; /* number of descriptors in the ring */ |
| 387 | dma_addr_t dma; /* descriptor ring physical address */ |
| 388 | u16 sw_next_to_fill; /* next descriptor to fill */ |
| 389 | u16 sw_next_to_clean; /* next descriptor to clean */ |
Rakesh Nair | 03b586c | 2017-04-03 18:28:58 +0530 | [diff] [blame] | 390 | u16 pending_fill; /* fill pending from previous iteration */ |
Rakesh Nair | 9bcf260 | 2017-01-06 16:02:16 +0530 | [diff] [blame] | 391 | }; |
| 392 | |
| 393 | /* edma_rfs_flter_node - rfs filter node in hash table */ |
| 394 | struct edma_rfs_filter_node { |
| 395 | struct flow_keys keys; |
| 396 | u32 flow_id; /* flow_id of filter provided by kernel */ |
| 397 | u16 filter_id; /* filter id of filter returned by adaptor */ |
| 398 | u16 rq_id; /* desired rq index */ |
| 399 | struct hlist_node node; /* edma rfs list node */ |
| 400 | }; |
| 401 | |
| 402 | /* edma_rfs_flow_tbl - rfs flow table */ |
| 403 | struct edma_rfs_flow_table { |
| 404 | u16 max_num_filter; /* Maximum number of filters edma supports */ |
| 405 | u16 hashtoclean; /* hash table index to clean next */ |
| 406 | int filter_available; /* Number of free filters available */ |
| 407 | struct hlist_head hlist_head[EDMA_RFS_FLOW_ENTRIES]; |
| 408 | spinlock_t rfs_ftab_lock; |
| 409 | struct timer_list expire_rfs; /* timer function for edma_rps_may_expire_flow */ |
| 410 | }; |
| 411 | |
| 412 | /* EDMA net device structure */ |
| 413 | struct edma_adapter { |
| 414 | struct net_device *netdev; /* netdevice */ |
| 415 | struct platform_device *pdev; /* platform device */ |
| 416 | struct edma_common_info *edma_cinfo; /* edma common info */ |
| 417 | struct phy_device *phydev; /* Phy device */ |
| 418 | struct edma_rfs_flow_table rfs; /* edma rfs flow table */ |
Bhaskar Valaboju | e429bab | 2017-03-15 09:01:23 +0530 | [diff] [blame] | 419 | struct rtnl_link_stats64 stats; /* netdev statistics */ |
Rakesh Nair | 9bcf260 | 2017-01-06 16:02:16 +0530 | [diff] [blame] | 420 | #ifdef CONFIG_RFS_ACCEL |
| 421 | set_rfs_filter_callback_t set_rfs_rule; |
| 422 | #endif |
| 423 | u32 flags;/* status flags */ |
| 424 | unsigned long state_flags; /* GMAC up/down flags */ |
| 425 | u32 forced_speed; /* link force speed */ |
| 426 | u32 forced_duplex; /* link force duplex */ |
| 427 | u32 link_state; /* phy link state */ |
| 428 | u32 phy_mdio_addr; /* PHY device address on MII interface */ |
| 429 | u32 poll_required; /* check if link polling is required */ |
| 430 | u32 poll_required_dynamic; /* dynamic polling flag */ |
| 431 | u32 tx_start_offset[CONFIG_NR_CPUS]; /* tx queue start */ |
| 432 | u32 default_vlan_tag; /* vlan tag */ |
| 433 | u32 dp_bitmap; |
| 434 | uint8_t phy_id[MII_BUS_ID_SIZE + 3]; |
Rakesh Nair | ed29f6b | 2017-04-04 15:48:08 +0530 | [diff] [blame] | 435 | struct mutex poll_mutex; /* Lock to protect polling flag change */ |
Rakesh Nair | 9bcf260 | 2017-01-06 16:02:16 +0530 | [diff] [blame] | 436 | }; |
| 437 | |
Rakesh Nair | 7e05353 | 2017-08-18 17:53:25 +0530 | [diff] [blame^] | 438 | /* PPPoE header info */ |
| 439 | struct pppoeh_proto { |
| 440 | struct pppoe_hdr hdr; |
| 441 | __be16 proto; |
| 442 | }; |
| 443 | |
Rakesh Nair | 9bcf260 | 2017-01-06 16:02:16 +0530 | [diff] [blame] | 444 | int edma_alloc_queues_tx(struct edma_common_info *edma_cinfo); |
| 445 | int edma_alloc_queues_rx(struct edma_common_info *edma_cinfo); |
| 446 | int edma_open(struct net_device *netdev); |
| 447 | int edma_close(struct net_device *netdev); |
| 448 | void edma_free_tx_resources(struct edma_common_info *edma_c_info); |
| 449 | void edma_free_rx_resources(struct edma_common_info *edma_c_info); |
| 450 | int edma_alloc_tx_rings(struct edma_common_info *edma_cinfo); |
| 451 | int edma_alloc_rx_rings(struct edma_common_info *edma_cinfo); |
| 452 | void edma_free_tx_rings(struct edma_common_info *edma_cinfo); |
| 453 | void edma_free_rx_rings(struct edma_common_info *edma_cinfo); |
| 454 | void edma_free_queues(struct edma_common_info *edma_cinfo); |
| 455 | void edma_irq_disable(struct edma_common_info *edma_cinfo); |
| 456 | int edma_reset(struct edma_common_info *edma_cinfo); |
| 457 | int edma_poll(struct napi_struct *napi, int budget); |
| 458 | netdev_tx_t edma_xmit(struct sk_buff *skb, |
| 459 | struct net_device *netdev); |
| 460 | int edma_configure(struct edma_common_info *edma_cinfo); |
| 461 | void edma_irq_enable(struct edma_common_info *edma_cinfo); |
| 462 | void edma_enable_tx_ctrl(struct edma_hw *hw); |
| 463 | void edma_enable_rx_ctrl(struct edma_hw *hw); |
| 464 | void edma_stop_rx_tx(struct edma_hw *hw); |
| 465 | void edma_free_irqs(struct edma_adapter *adapter); |
| 466 | irqreturn_t edma_interrupt(int irq, void *dev); |
| 467 | void edma_write_reg(u16 reg_addr, u32 reg_value); |
| 468 | void edma_read_reg(u16 reg_addr, volatile u32 *reg_value); |
Bhaskar Valaboju | e429bab | 2017-03-15 09:01:23 +0530 | [diff] [blame] | 469 | struct rtnl_link_stats64 *edma_get_stats64(struct net_device *dev, |
| 470 | struct rtnl_link_stats64 *stats); |
Rakesh Nair | 9bcf260 | 2017-01-06 16:02:16 +0530 | [diff] [blame] | 471 | int edma_set_mac_addr(struct net_device *netdev, void *p); |
| 472 | int edma_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb, |
| 473 | u16 rxq, u32 flow_id); |
| 474 | #ifdef CONFIG_RFS_ACCEL |
| 475 | int edma_register_rfs_filter(struct net_device *netdev, |
| 476 | set_rfs_filter_callback_t set_filter); |
| 477 | #endif |
| 478 | void edma_flow_may_expire(unsigned long data); |
| 479 | void edma_set_ethtool_ops(struct net_device *netdev); |
| 480 | int edma_change_mtu(struct net_device *netdev, int new_mtu); |
| 481 | void edma_set_stp_rstp(bool tag); |
| 482 | void edma_assign_ath_hdr_type(int tag); |
| 483 | int edma_get_default_vlan_tag(struct net_device *netdev); |
| 484 | void edma_adjust_link(struct net_device *netdev); |
| 485 | int edma_fill_netdev(struct edma_common_info *edma_cinfo, int qid, int num, int txq_id); |
| 486 | u16 edma_select_xps_queue(struct net_device *dev, struct sk_buff *skb, |
| 487 | void *accel_priv, select_queue_fallback_t fallback); |
| 488 | void edma_read_append_stats(struct edma_common_info *edma_cinfo); |
| 489 | void edma_change_tx_coalesce(int usecs); |
| 490 | void edma_change_rx_coalesce(int usecs); |
| 491 | void edma_get_tx_rx_coalesce(u32 *reg_val); |
| 492 | void edma_clear_irq_status(void); |
Rakesh Nair | 888af95 | 2017-06-30 18:41:58 +0530 | [diff] [blame] | 493 | |
| 494 | int edma_dscp2ac_mapping_update(struct ctl_table *table, int write, |
| 495 | void __user *buffer, size_t *lenp, |
| 496 | loff_t *ppos); |
| 497 | int edma_per_prec_stats_enable_handler(struct ctl_table *table, int write, |
| 498 | void __user *buffer, size_t *lenp, |
| 499 | loff_t *ppos); |
| 500 | int edma_prec_stats_reset_handler(struct ctl_table *table, int write, |
| 501 | void __user *buffer, size_t *lenp, |
| 502 | loff_t *ppos); |
Rakesh Nair | 9bcf260 | 2017-01-06 16:02:16 +0530 | [diff] [blame] | 503 | #endif /* _EDMA_H_ */ |