.. | .. |
---|
1 | | -// SPDX-License-Identifier: (GPL-2.0 OR MIT) |
---|
| 1 | +/* SPDX-License-Identifier: (GPL-2.0 OR MIT) */ |
---|
2 | 2 | // Copyright (c) 2018 Synopsys, Inc. and/or its affiliates. |
---|
3 | 3 | // stmmac HW Interface Callbacks |
---|
4 | 4 | |
---|
.. | .. |
---|
6 | 6 | #define __STMMAC_HWIF_H__ |
---|
7 | 7 | |
---|
8 | 8 | #include <linux/netdevice.h> |
---|
| 9 | +#include <linux/stmmac.h> |
---|
9 | 10 | |
---|
10 | 11 | #define stmmac_do_void_callback(__priv, __module, __cname, __arg0, __args...) \ |
---|
11 | 12 | ({ \ |
---|
.. | .. |
---|
28 | 29 | struct stmmac_safety_stats; |
---|
29 | 30 | struct dma_desc; |
---|
30 | 31 | struct dma_extended_desc; |
---|
| 32 | +struct dma_edesc; |
---|
31 | 33 | |
---|
32 | 34 | /* Descriptors helpers */ |
---|
33 | 35 | struct stmmac_desc_ops { |
---|
.. | .. |
---|
76 | 78 | /* get rx timestamp status */ |
---|
77 | 79 | int (*get_rx_timestamp_status)(void *desc, void *next_desc, u32 ats); |
---|
78 | 80 | /* Display ring */ |
---|
79 | | - void (*display_ring)(void *head, unsigned int size, bool rx); |
---|
| 81 | + void (*display_ring)(void *head, unsigned int size, bool rx, |
---|
| 82 | + dma_addr_t dma_rx_phy, unsigned int desc_size); |
---|
80 | 83 | /* set MSS via context descriptor */ |
---|
81 | 84 | void (*set_mss)(struct dma_desc *p, unsigned int mss); |
---|
82 | 85 | /* get descriptor skbuff address */ |
---|
.. | .. |
---|
85 | 88 | void (*set_addr)(struct dma_desc *p, dma_addr_t addr); |
---|
86 | 89 | /* clear descriptor */ |
---|
87 | 90 | void (*clear)(struct dma_desc *p); |
---|
| 91 | + /* RSS */ |
---|
| 92 | + int (*get_rx_hash)(struct dma_desc *p, u32 *hash, |
---|
| 93 | + enum pkt_hash_types *type); |
---|
| 94 | + void (*get_rx_header_len)(struct dma_desc *p, unsigned int *len); |
---|
| 95 | + void (*set_sec_addr)(struct dma_desc *p, dma_addr_t addr, bool buf2_valid); |
---|
| 96 | + void (*set_sarc)(struct dma_desc *p, u32 sarc_type); |
---|
| 97 | + void (*set_vlan_tag)(struct dma_desc *p, u16 tag, u16 inner_tag, |
---|
| 98 | + u32 inner_type); |
---|
| 99 | + void (*set_vlan)(struct dma_desc *p, u32 type); |
---|
| 100 | + void (*set_tbs)(struct dma_edesc *p, u32 sec, u32 nsec); |
---|
88 | 101 | }; |
---|
89 | 102 | |
---|
90 | 103 | #define stmmac_init_rx_desc(__priv, __args...) \ |
---|
.. | .. |
---|
135 | 148 | stmmac_do_void_callback(__priv, desc, set_addr, __args) |
---|
136 | 149 | #define stmmac_clear_desc(__priv, __args...) \ |
---|
137 | 150 | stmmac_do_void_callback(__priv, desc, clear, __args) |
---|
| 151 | +#define stmmac_get_rx_hash(__priv, __args...) \ |
---|
| 152 | + stmmac_do_callback(__priv, desc, get_rx_hash, __args) |
---|
| 153 | +#define stmmac_get_rx_header_len(__priv, __args...) \ |
---|
| 154 | + stmmac_do_void_callback(__priv, desc, get_rx_header_len, __args) |
---|
| 155 | +#define stmmac_set_desc_sec_addr(__priv, __args...) \ |
---|
| 156 | + stmmac_do_void_callback(__priv, desc, set_sec_addr, __args) |
---|
| 157 | +#define stmmac_set_desc_sarc(__priv, __args...) \ |
---|
| 158 | + stmmac_do_void_callback(__priv, desc, set_sarc, __args) |
---|
| 159 | +#define stmmac_set_desc_vlan_tag(__priv, __args...) \ |
---|
| 160 | + stmmac_do_void_callback(__priv, desc, set_vlan_tag, __args) |
---|
| 161 | +#define stmmac_set_desc_vlan(__priv, __args...) \ |
---|
| 162 | + stmmac_do_void_callback(__priv, desc, set_vlan, __args) |
---|
| 163 | +#define stmmac_set_desc_tbs(__priv, __args...) \ |
---|
| 164 | + stmmac_do_void_callback(__priv, desc, set_tbs, __args) |
---|
138 | 165 | |
---|
139 | 166 | struct stmmac_dma_cfg; |
---|
140 | 167 | struct dma_features; |
---|
.. | .. |
---|
149 | 176 | struct stmmac_dma_cfg *dma_cfg, u32 chan); |
---|
150 | 177 | void (*init_rx_chan)(void __iomem *ioaddr, |
---|
151 | 178 | struct stmmac_dma_cfg *dma_cfg, |
---|
152 | | - u32 dma_rx_phy, u32 chan); |
---|
| 179 | + dma_addr_t phy, u32 chan); |
---|
153 | 180 | void (*init_tx_chan)(void __iomem *ioaddr, |
---|
154 | 181 | struct stmmac_dma_cfg *dma_cfg, |
---|
155 | | - u32 dma_tx_phy, u32 chan); |
---|
| 182 | + dma_addr_t phy, u32 chan); |
---|
156 | 183 | /* Configure the AXI Bus Mode Register */ |
---|
157 | 184 | void (*axi)(void __iomem *ioaddr, struct stmmac_axi *axi); |
---|
158 | 185 | /* Dump DMA registers */ |
---|
.. | .. |
---|
165 | 192 | void (*dma_diagnostic_fr) (void *data, struct stmmac_extra_stats *x, |
---|
166 | 193 | void __iomem *ioaddr); |
---|
167 | 194 | void (*enable_dma_transmission) (void __iomem *ioaddr); |
---|
168 | | - void (*enable_dma_irq)(void __iomem *ioaddr, u32 chan); |
---|
169 | | - void (*disable_dma_irq)(void __iomem *ioaddr, u32 chan); |
---|
| 195 | + void (*enable_dma_irq)(void __iomem *ioaddr, u32 chan, |
---|
| 196 | + bool rx, bool tx); |
---|
| 197 | + void (*disable_dma_irq)(void __iomem *ioaddr, u32 chan, |
---|
| 198 | + bool rx, bool tx); |
---|
170 | 199 | void (*start_tx)(void __iomem *ioaddr, u32 chan); |
---|
171 | 200 | void (*stop_tx)(void __iomem *ioaddr, u32 chan); |
---|
172 | 201 | void (*start_rx)(void __iomem *ioaddr, u32 chan); |
---|
.. | .. |
---|
174 | 203 | int (*dma_interrupt) (void __iomem *ioaddr, |
---|
175 | 204 | struct stmmac_extra_stats *x, u32 chan); |
---|
176 | 205 | /* If supported then get the optional core features */ |
---|
177 | | - void (*get_hw_feature)(void __iomem *ioaddr, |
---|
178 | | - struct dma_features *dma_cap); |
---|
| 206 | + int (*get_hw_feature)(void __iomem *ioaddr, |
---|
| 207 | + struct dma_features *dma_cap); |
---|
179 | 208 | /* Program the HW RX Watchdog */ |
---|
180 | 209 | void (*rx_watchdog)(void __iomem *ioaddr, u32 riwt, u32 number_chan); |
---|
181 | 210 | void (*set_tx_ring_len)(void __iomem *ioaddr, u32 len, u32 chan); |
---|
.. | .. |
---|
185 | 214 | void (*enable_tso)(void __iomem *ioaddr, bool en, u32 chan); |
---|
186 | 215 | void (*qmode)(void __iomem *ioaddr, u32 channel, u8 qmode); |
---|
187 | 216 | void (*set_bfsize)(void __iomem *ioaddr, int bfsize, u32 chan); |
---|
| 217 | + void (*enable_sph)(void __iomem *ioaddr, bool en, u32 chan); |
---|
| 218 | + int (*enable_tbs)(void __iomem *ioaddr, bool en, u32 chan); |
---|
188 | 219 | }; |
---|
189 | 220 | |
---|
190 | 221 | #define stmmac_reset(__priv, __args...) \ |
---|
.. | .. |
---|
224 | 255 | #define stmmac_dma_interrupt_status(__priv, __args...) \ |
---|
225 | 256 | stmmac_do_callback(__priv, dma, dma_interrupt, __args) |
---|
226 | 257 | #define stmmac_get_hw_feature(__priv, __args...) \ |
---|
227 | | - stmmac_do_void_callback(__priv, dma, get_hw_feature, __args) |
---|
| 258 | + stmmac_do_callback(__priv, dma, get_hw_feature, __args) |
---|
228 | 259 | #define stmmac_rx_watchdog(__priv, __args...) \ |
---|
229 | 260 | stmmac_do_void_callback(__priv, dma, rx_watchdog, __args) |
---|
230 | 261 | #define stmmac_set_tx_ring_len(__priv, __args...) \ |
---|
.. | .. |
---|
241 | 272 | stmmac_do_void_callback(__priv, dma, qmode, __args) |
---|
242 | 273 | #define stmmac_set_dma_bfsize(__priv, __args...) \ |
---|
243 | 274 | stmmac_do_void_callback(__priv, dma, set_bfsize, __args) |
---|
| 275 | +#define stmmac_enable_sph(__priv, __args...) \ |
---|
| 276 | + stmmac_do_void_callback(__priv, dma, enable_sph, __args) |
---|
| 277 | +#define stmmac_enable_tbs(__priv, __args...) \ |
---|
| 278 | + stmmac_do_callback(__priv, dma, enable_tbs, __args) |
---|
244 | 279 | |
---|
245 | 280 | struct mac_device_info; |
---|
246 | 281 | struct net_device; |
---|
.. | .. |
---|
248 | 283 | struct stmmac_safety_stats; |
---|
249 | 284 | struct stmmac_tc_entry; |
---|
250 | 285 | struct stmmac_pps_cfg; |
---|
| 286 | +struct stmmac_rss; |
---|
| 287 | +struct stmmac_est; |
---|
251 | 288 | |
---|
252 | 289 | /* Helpers to program the MAC core */ |
---|
253 | 290 | struct stmmac_ops { |
---|
.. | .. |
---|
324 | 361 | int (*flex_pps_config)(void __iomem *ioaddr, int index, |
---|
325 | 362 | struct stmmac_pps_cfg *cfg, bool enable, |
---|
326 | 363 | u32 sub_second_inc, u32 systime_flags); |
---|
| 364 | + /* Loopback for selftests */ |
---|
| 365 | + void (*set_mac_loopback)(void __iomem *ioaddr, bool enable); |
---|
| 366 | + /* RSS */ |
---|
| 367 | + int (*rss_configure)(struct mac_device_info *hw, |
---|
| 368 | + struct stmmac_rss *cfg, u32 num_rxq); |
---|
| 369 | + /* VLAN */ |
---|
| 370 | + void (*update_vlan_hash)(struct mac_device_info *hw, u32 hash, |
---|
| 371 | + __le16 perfect_match, bool is_double); |
---|
| 372 | + void (*enable_vlan)(struct mac_device_info *hw, u32 type); |
---|
| 373 | + int (*add_hw_vlan_rx_fltr)(struct net_device *dev, |
---|
| 374 | + struct mac_device_info *hw, |
---|
| 375 | + __be16 proto, u16 vid); |
---|
| 376 | + int (*del_hw_vlan_rx_fltr)(struct net_device *dev, |
---|
| 377 | + struct mac_device_info *hw, |
---|
| 378 | + __be16 proto, u16 vid); |
---|
| 379 | + void (*restore_hw_vlan_rx_fltr)(struct net_device *dev, |
---|
| 380 | + struct mac_device_info *hw); |
---|
| 381 | + /* TX Timestamp */ |
---|
| 382 | + int (*get_mac_tx_timestamp)(struct mac_device_info *hw, u64 *ts); |
---|
| 383 | + /* Source Address Insertion / Replacement */ |
---|
| 384 | + void (*sarc_configure)(void __iomem *ioaddr, int val); |
---|
| 385 | + /* Filtering */ |
---|
| 386 | + int (*config_l3_filter)(struct mac_device_info *hw, u32 filter_no, |
---|
| 387 | + bool en, bool ipv6, bool sa, bool inv, |
---|
| 388 | + u32 match); |
---|
| 389 | + int (*config_l4_filter)(struct mac_device_info *hw, u32 filter_no, |
---|
| 390 | + bool en, bool udp, bool sa, bool inv, |
---|
| 391 | + u32 match); |
---|
| 392 | + void (*set_arp_offload)(struct mac_device_info *hw, bool en, u32 addr); |
---|
| 393 | + int (*est_configure)(void __iomem *ioaddr, struct stmmac_est *cfg, |
---|
| 394 | + unsigned int ptp_rate); |
---|
| 395 | + void (*fpe_configure)(void __iomem *ioaddr, u32 num_txq, u32 num_rxq, |
---|
| 396 | + bool enable); |
---|
327 | 397 | }; |
---|
328 | 398 | |
---|
329 | 399 | #define stmmac_core_init(__priv, __args...) \ |
---|
.. | .. |
---|
392 | 462 | stmmac_do_callback(__priv, mac, rxp_config, __args) |
---|
393 | 463 | #define stmmac_flex_pps_config(__priv, __args...) \ |
---|
394 | 464 | stmmac_do_callback(__priv, mac, flex_pps_config, __args) |
---|
| 465 | +#define stmmac_set_mac_loopback(__priv, __args...) \ |
---|
| 466 | + stmmac_do_void_callback(__priv, mac, set_mac_loopback, __args) |
---|
| 467 | +#define stmmac_rss_configure(__priv, __args...) \ |
---|
| 468 | + stmmac_do_callback(__priv, mac, rss_configure, __args) |
---|
| 469 | +#define stmmac_update_vlan_hash(__priv, __args...) \ |
---|
| 470 | + stmmac_do_void_callback(__priv, mac, update_vlan_hash, __args) |
---|
| 471 | +#define stmmac_enable_vlan(__priv, __args...) \ |
---|
| 472 | + stmmac_do_void_callback(__priv, mac, enable_vlan, __args) |
---|
| 473 | +#define stmmac_add_hw_vlan_rx_fltr(__priv, __args...) \ |
---|
| 474 | + stmmac_do_callback(__priv, mac, add_hw_vlan_rx_fltr, __args) |
---|
| 475 | +#define stmmac_del_hw_vlan_rx_fltr(__priv, __args...) \ |
---|
| 476 | + stmmac_do_callback(__priv, mac, del_hw_vlan_rx_fltr, __args) |
---|
| 477 | +#define stmmac_restore_hw_vlan_rx_fltr(__priv, __args...) \ |
---|
| 478 | + stmmac_do_void_callback(__priv, mac, restore_hw_vlan_rx_fltr, __args) |
---|
| 479 | +#define stmmac_get_mac_tx_timestamp(__priv, __args...) \ |
---|
| 480 | + stmmac_do_callback(__priv, mac, get_mac_tx_timestamp, __args) |
---|
| 481 | +#define stmmac_sarc_configure(__priv, __args...) \ |
---|
| 482 | + stmmac_do_void_callback(__priv, mac, sarc_configure, __args) |
---|
| 483 | +#define stmmac_config_l3_filter(__priv, __args...) \ |
---|
| 484 | + stmmac_do_callback(__priv, mac, config_l3_filter, __args) |
---|
| 485 | +#define stmmac_config_l4_filter(__priv, __args...) \ |
---|
| 486 | + stmmac_do_callback(__priv, mac, config_l4_filter, __args) |
---|
| 487 | +#define stmmac_set_arp_offload(__priv, __args...) \ |
---|
| 488 | + stmmac_do_void_callback(__priv, mac, set_arp_offload, __args) |
---|
| 489 | +#define stmmac_est_configure(__priv, __args...) \ |
---|
| 490 | + stmmac_do_callback(__priv, mac, est_configure, __args) |
---|
| 491 | +#define stmmac_fpe_configure(__priv, __args...) \ |
---|
| 492 | + stmmac_do_void_callback(__priv, mac, fpe_configure, __args) |
---|
395 | 493 | |
---|
396 | 494 | /* PTP and HW Timer helpers */ |
---|
397 | 495 | struct stmmac_hwtimestamp { |
---|
.. | .. |
---|
448 | 546 | struct stmmac_priv; |
---|
449 | 547 | struct tc_cls_u32_offload; |
---|
450 | 548 | struct tc_cbs_qopt_offload; |
---|
| 549 | +struct flow_cls_offload; |
---|
| 550 | +struct tc_taprio_qopt_offload; |
---|
| 551 | +struct tc_etf_qopt_offload; |
---|
451 | 552 | |
---|
452 | 553 | struct stmmac_tc_ops { |
---|
453 | 554 | int (*init)(struct stmmac_priv *priv); |
---|
.. | .. |
---|
455 | 556 | struct tc_cls_u32_offload *cls); |
---|
456 | 557 | int (*setup_cbs)(struct stmmac_priv *priv, |
---|
457 | 558 | struct tc_cbs_qopt_offload *qopt); |
---|
| 559 | + int (*setup_cls)(struct stmmac_priv *priv, |
---|
| 560 | + struct flow_cls_offload *cls); |
---|
| 561 | + int (*setup_taprio)(struct stmmac_priv *priv, |
---|
| 562 | + struct tc_taprio_qopt_offload *qopt); |
---|
| 563 | + int (*setup_etf)(struct stmmac_priv *priv, |
---|
| 564 | + struct tc_etf_qopt_offload *qopt); |
---|
458 | 565 | }; |
---|
459 | 566 | |
---|
460 | 567 | #define stmmac_tc_init(__priv, __args...) \ |
---|
.. | .. |
---|
463 | 570 | stmmac_do_callback(__priv, tc, setup_cls_u32, __args) |
---|
464 | 571 | #define stmmac_tc_setup_cbs(__priv, __args...) \ |
---|
465 | 572 | stmmac_do_callback(__priv, tc, setup_cbs, __args) |
---|
| 573 | +#define stmmac_tc_setup_cls(__priv, __args...) \ |
---|
| 574 | + stmmac_do_callback(__priv, tc, setup_cls, __args) |
---|
| 575 | +#define stmmac_tc_setup_taprio(__priv, __args...) \ |
---|
| 576 | + stmmac_do_callback(__priv, tc, setup_taprio, __args) |
---|
| 577 | +#define stmmac_tc_setup_etf(__priv, __args...) \ |
---|
| 578 | + stmmac_do_callback(__priv, tc, setup_etf, __args) |
---|
| 579 | + |
---|
| 580 | +struct stmmac_counters; |
---|
| 581 | + |
---|
| 582 | +struct stmmac_mmc_ops { |
---|
| 583 | + void (*ctrl)(void __iomem *ioaddr, unsigned int mode); |
---|
| 584 | + void (*intr_all_mask)(void __iomem *ioaddr); |
---|
| 585 | + void (*read)(void __iomem *ioaddr, struct stmmac_counters *mmc); |
---|
| 586 | +}; |
---|
| 587 | + |
---|
| 588 | +#define stmmac_mmc_ctrl(__priv, __args...) \ |
---|
| 589 | + stmmac_do_void_callback(__priv, mmc, ctrl, __args) |
---|
| 590 | +#define stmmac_mmc_intr_all_mask(__priv, __args...) \ |
---|
| 591 | + stmmac_do_void_callback(__priv, mmc, intr_all_mask, __args) |
---|
| 592 | +#define stmmac_mmc_read(__priv, __args...) \ |
---|
| 593 | + stmmac_do_void_callback(__priv, mmc, read, __args) |
---|
| 594 | + |
---|
| 595 | +/* XPCS callbacks */ |
---|
| 596 | +#define stmmac_xpcs_validate(__priv, __args...) \ |
---|
| 597 | + stmmac_do_callback(__priv, xpcs, validate, __args) |
---|
| 598 | +#define stmmac_xpcs_config(__priv, __args...) \ |
---|
| 599 | + stmmac_do_callback(__priv, xpcs, config, __args) |
---|
| 600 | +#define stmmac_xpcs_get_state(__priv, __args...) \ |
---|
| 601 | + stmmac_do_callback(__priv, xpcs, get_state, __args) |
---|
| 602 | +#define stmmac_xpcs_link_up(__priv, __args...) \ |
---|
| 603 | + stmmac_do_callback(__priv, xpcs, link_up, __args) |
---|
| 604 | +#define stmmac_xpcs_probe(__priv, __args...) \ |
---|
| 605 | + stmmac_do_callback(__priv, xpcs, probe, __args) |
---|
466 | 606 | |
---|
467 | 607 | struct stmmac_regs_off { |
---|
468 | 608 | u32 ptp_off; |
---|
.. | .. |
---|
480 | 620 | extern const struct stmmac_ops dwmac510_ops; |
---|
481 | 621 | extern const struct stmmac_tc_ops dwmac510_tc_ops; |
---|
482 | 622 | extern const struct stmmac_ops dwxgmac210_ops; |
---|
| 623 | +extern const struct stmmac_ops dwxlgmac2_ops; |
---|
483 | 624 | extern const struct stmmac_dma_ops dwxgmac210_dma_ops; |
---|
484 | 625 | extern const struct stmmac_desc_ops dwxgmac210_desc_ops; |
---|
| 626 | +extern const struct stmmac_mmc_ops dwmac_mmc_ops; |
---|
| 627 | +extern const struct stmmac_mmc_ops dwxgmac_mmc_ops; |
---|
485 | 628 | |
---|
486 | 629 | #define GMAC_VERSION 0x00000020 /* GMAC CORE Version */ |
---|
487 | 630 | #define GMAC4_VERSION 0x00000110 /* GMAC4+ CORE Version */ |
---|