| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
|---|
| 1 | 2 | /******************************************************************************* |
|---|
| 2 | 3 | STMMAC Common Header File |
|---|
| 3 | 4 | |
|---|
| 4 | 5 | Copyright (C) 2007-2009 STMicroelectronics Ltd |
|---|
| 5 | 6 | |
|---|
| 6 | | - This program is free software; you can redistribute it and/or modify it |
|---|
| 7 | | - under the terms and conditions of the GNU General Public License, |
|---|
| 8 | | - version 2, as published by the Free Software Foundation. |
|---|
| 9 | | - |
|---|
| 10 | | - This program is distributed in the hope it will be useful, but WITHOUT |
|---|
| 11 | | - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|---|
| 12 | | - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|---|
| 13 | | - more details. |
|---|
| 14 | | - |
|---|
| 15 | | - The full GNU General Public License is included in this distribution in |
|---|
| 16 | | - the file called "COPYING". |
|---|
| 17 | 7 | |
|---|
| 18 | 8 | Author: Giuseppe Cavallaro <peppe.cavallaro@st.com> |
|---|
| 19 | 9 | *******************************************************************************/ |
|---|
| .. | .. |
|---|
| 25 | 15 | #include <linux/netdevice.h> |
|---|
| 26 | 16 | #include <linux/stmmac.h> |
|---|
| 27 | 17 | #include <linux/phy.h> |
|---|
| 18 | +#include <linux/pcs/pcs-xpcs.h> |
|---|
| 28 | 19 | #include <linux/module.h> |
|---|
| 29 | 20 | #if IS_ENABLED(CONFIG_VLAN_8021Q) |
|---|
| 30 | 21 | #define STMMAC_VLAN_TAG_USED |
|---|
| .. | .. |
|---|
| 43 | 34 | #define DWMAC_CORE_5_00 0x50 |
|---|
| 44 | 35 | #define DWMAC_CORE_5_10 0x51 |
|---|
| 45 | 36 | #define DWXGMAC_CORE_2_10 0x21 |
|---|
| 37 | +#define DWXLGMAC_CORE_2_00 0x20 |
|---|
| 38 | + |
|---|
| 39 | +/* Device ID */ |
|---|
| 40 | +#define DWXGMAC_ID 0x76 |
|---|
| 41 | +#define DWXLGMAC_ID 0x27 |
|---|
| 46 | 42 | |
|---|
| 47 | 43 | #define STMMAC_CHAN0 0 /* Always supported and default for all chips */ |
|---|
| 48 | 44 | |
|---|
| 49 | | -/* These need to be power of two, and >= 4 */ |
|---|
| 50 | | -#define DMA_TX_SIZE 512 |
|---|
| 51 | | -#define DMA_RX_SIZE 512 |
|---|
| 45 | +/* TX and RX Descriptor Length, these need to be power of two. |
|---|
| 46 | + * TX descriptor length less than 64 may cause transmit queue timed out error. |
|---|
| 47 | + * RX descriptor length less than 64 may cause inconsistent Rx chain error. |
|---|
| 48 | + */ |
|---|
| 49 | +#define DMA_MIN_TX_SIZE 64 |
|---|
| 50 | +#define DMA_MAX_TX_SIZE 1024 |
|---|
| 51 | +#if IS_ENABLED(CONFIG_STMMAC_UIO) |
|---|
| 52 | +#define DMA_DEFAULT_TX_SIZE 1024 |
|---|
| 53 | +#else |
|---|
| 54 | +#define DMA_DEFAULT_TX_SIZE 512 |
|---|
| 55 | +#endif |
|---|
| 56 | +#define DMA_MIN_RX_SIZE 64 |
|---|
| 57 | +#define DMA_MAX_RX_SIZE 1024 |
|---|
| 58 | +#if IS_ENABLED(CONFIG_STMMAC_UIO) |
|---|
| 59 | +#define DMA_DEFAULT_RX_SIZE 1024 |
|---|
| 60 | +#else |
|---|
| 61 | +#define DMA_DEFAULT_RX_SIZE 512 |
|---|
| 62 | +#endif |
|---|
| 52 | 63 | #define STMMAC_GET_ENTRY(x, size) ((x + 1) & (size - 1)) |
|---|
| 53 | 64 | |
|---|
| 54 | 65 | #undef FRAME_FILTER_DEBUG |
|---|
| .. | .. |
|---|
| 85 | 96 | unsigned long rx_missed_cntr; |
|---|
| 86 | 97 | unsigned long rx_overflow_cntr; |
|---|
| 87 | 98 | unsigned long rx_vlan; |
|---|
| 99 | + unsigned long rx_split_hdr_pkt_n; |
|---|
| 88 | 100 | /* Tx/Rx IRQ error info */ |
|---|
| 89 | 101 | unsigned long tx_undeflow_irq; |
|---|
| 90 | 102 | unsigned long tx_process_stopped_irq; |
|---|
| .. | .. |
|---|
| 256 | 268 | |
|---|
| 257 | 269 | /* Max/Min RI Watchdog Timer count value */ |
|---|
| 258 | 270 | #define MAX_DMA_RIWT 0xff |
|---|
| 259 | | -#define MIN_DMA_RIWT 0x20 |
|---|
| 271 | +#define MIN_DMA_RIWT 0x10 |
|---|
| 272 | +#define DEF_DMA_RIWT 0xa0 |
|---|
| 260 | 273 | /* Tx coalesce parameters */ |
|---|
| 261 | 274 | #define STMMAC_COAL_TX_TIMER 1000 |
|---|
| 262 | 275 | #define STMMAC_MAX_COAL_TX_TICK 100000 |
|---|
| 263 | 276 | #define STMMAC_TX_MAX_FRAMES 256 |
|---|
| 264 | | -#define STMMAC_TX_FRAMES 1 |
|---|
| 277 | +#define STMMAC_TX_FRAMES 25 |
|---|
| 278 | +#define STMMAC_RX_FRAMES 0 |
|---|
| 265 | 279 | |
|---|
| 266 | 280 | /* Packets types */ |
|---|
| 267 | 281 | enum packets_types { |
|---|
| .. | .. |
|---|
| 335 | 349 | /* 802.3az - Energy-Efficient Ethernet (EEE) */ |
|---|
| 336 | 350 | unsigned int eee; |
|---|
| 337 | 351 | unsigned int av; |
|---|
| 352 | + unsigned int hash_tb_sz; |
|---|
| 338 | 353 | unsigned int tsoen; |
|---|
| 339 | 354 | /* TX and RX csum */ |
|---|
| 340 | 355 | unsigned int tx_coe; |
|---|
| .. | .. |
|---|
| 361 | 376 | unsigned int frpsel; |
|---|
| 362 | 377 | unsigned int frpbs; |
|---|
| 363 | 378 | unsigned int frpes; |
|---|
| 379 | + unsigned int addr64; |
|---|
| 380 | + unsigned int rssen; |
|---|
| 381 | + unsigned int vlhash; |
|---|
| 382 | + unsigned int sphen; |
|---|
| 383 | + unsigned int vlins; |
|---|
| 384 | + unsigned int dvlan; |
|---|
| 385 | + unsigned int l3l4fnum; |
|---|
| 386 | + unsigned int arpoffsel; |
|---|
| 387 | + /* TSN Features */ |
|---|
| 388 | + unsigned int estwid; |
|---|
| 389 | + unsigned int estdep; |
|---|
| 390 | + unsigned int estsel; |
|---|
| 391 | + unsigned int fpesel; |
|---|
| 392 | + unsigned int tbssel; |
|---|
| 364 | 393 | }; |
|---|
| 365 | 394 | |
|---|
| 366 | 395 | /* RX Buffer size must be multiple of 4/8/16 bytes */ |
|---|
| .. | .. |
|---|
| 387 | 416 | |
|---|
| 388 | 417 | #define JUMBO_LEN 9000 |
|---|
| 389 | 418 | |
|---|
| 419 | +/* Receive Side Scaling */ |
|---|
| 420 | +#define STMMAC_RSS_HASH_KEY_SIZE 40 |
|---|
| 421 | +#define STMMAC_RSS_MAX_TABLE_SIZE 256 |
|---|
| 422 | + |
|---|
| 423 | +/* VLAN */ |
|---|
| 424 | +#define STMMAC_VLAN_NONE 0x0 |
|---|
| 425 | +#define STMMAC_VLAN_REMOVE 0x1 |
|---|
| 426 | +#define STMMAC_VLAN_INSERT 0x2 |
|---|
| 427 | +#define STMMAC_VLAN_REPLACE 0x3 |
|---|
| 428 | + |
|---|
| 390 | 429 | extern const struct stmmac_desc_ops enh_desc_ops; |
|---|
| 391 | 430 | extern const struct stmmac_desc_ops ndesc_ops; |
|---|
| 392 | 431 | |
|---|
| .. | .. |
|---|
| 401 | 440 | u32 speed100; |
|---|
| 402 | 441 | u32 speed1000; |
|---|
| 403 | 442 | u32 speed2500; |
|---|
| 404 | | - u32 speed10000; |
|---|
| 405 | 443 | u32 duplex; |
|---|
| 444 | + struct { |
|---|
| 445 | + u32 speed2500; |
|---|
| 446 | + u32 speed5000; |
|---|
| 447 | + u32 speed10000; |
|---|
| 448 | + } xgmii; |
|---|
| 449 | + struct { |
|---|
| 450 | + u32 speed25000; |
|---|
| 451 | + u32 speed40000; |
|---|
| 452 | + u32 speed50000; |
|---|
| 453 | + u32 speed100000; |
|---|
| 454 | + } xlgmii; |
|---|
| 406 | 455 | }; |
|---|
| 407 | 456 | |
|---|
| 408 | 457 | struct mii_regs { |
|---|
| .. | .. |
|---|
| 423 | 472 | const struct stmmac_mode_ops *mode; |
|---|
| 424 | 473 | const struct stmmac_hwtimestamp *ptp; |
|---|
| 425 | 474 | const struct stmmac_tc_ops *tc; |
|---|
| 475 | + const struct stmmac_mmc_ops *mmc; |
|---|
| 476 | + const struct mdio_xpcs_ops *xpcs; |
|---|
| 477 | + struct mdio_xpcs_args xpcs_args; |
|---|
| 426 | 478 | struct mii_regs mii; /* MII register Addresses */ |
|---|
| 427 | 479 | struct mac_link link; |
|---|
| 428 | 480 | void __iomem *pcsr; /* vpointer to device CSRs */ |
|---|
| 429 | | - int multicast_filter_bins; |
|---|
| 430 | | - int unicast_filter_entries; |
|---|
| 431 | | - int mcast_bits_log2; |
|---|
| 481 | + unsigned int multicast_filter_bins; |
|---|
| 482 | + unsigned int unicast_filter_entries; |
|---|
| 483 | + unsigned int mcast_bits_log2; |
|---|
| 432 | 484 | unsigned int rx_csum; |
|---|
| 433 | 485 | unsigned int pcs; |
|---|
| 434 | 486 | unsigned int pmt; |
|---|
| 435 | 487 | unsigned int ps; |
|---|
| 488 | + unsigned int xlgmac; |
|---|
| 489 | + unsigned int num_vlan; |
|---|
| 490 | + u32 vlan_filter[32]; |
|---|
| 491 | + unsigned int promisc; |
|---|
| 492 | + bool vlan_fail_q_en; |
|---|
| 493 | + u8 vlan_fail_q; |
|---|
| 436 | 494 | }; |
|---|
| 437 | 495 | |
|---|
| 438 | 496 | struct stmmac_rx_routing { |
|---|
| .. | .. |
|---|
| 444 | 502 | int dwmac1000_setup(struct stmmac_priv *priv); |
|---|
| 445 | 503 | int dwmac4_setup(struct stmmac_priv *priv); |
|---|
| 446 | 504 | int dwxgmac2_setup(struct stmmac_priv *priv); |
|---|
| 505 | +int dwxlgmac2_setup(struct stmmac_priv *priv); |
|---|
| 447 | 506 | |
|---|
| 448 | 507 | void stmmac_set_mac_addr(void __iomem *ioaddr, u8 addr[6], |
|---|
| 449 | 508 | unsigned int high, unsigned int low); |
|---|