3232#endif
3333
3434#include "descs.h"
35+ #include "hwif.h"
3536#include "mmc.h"
3637
3738/* Synopsys Core versions */
@@ -377,197 +378,11 @@ struct dma_features {
377378
378379#define JUMBO_LEN 9000
379380
380- /* Descriptors helpers */
381- struct stmmac_desc_ops {
382- /* DMA RX descriptor ring initialization */
383- void (* init_rx_desc ) (struct dma_desc * p , int disable_rx_ic , int mode ,
384- int end );
385- /* DMA TX descriptor ring initialization */
386- void (* init_tx_desc ) (struct dma_desc * p , int mode , int end );
387-
388- /* Invoked by the xmit function to prepare the tx descriptor */
389- void (* prepare_tx_desc ) (struct dma_desc * p , int is_fs , int len ,
390- bool csum_flag , int mode , bool tx_own ,
391- bool ls , unsigned int tot_pkt_len );
392- void (* prepare_tso_tx_desc )(struct dma_desc * p , int is_fs , int len1 ,
393- int len2 , bool tx_own , bool ls ,
394- unsigned int tcphdrlen ,
395- unsigned int tcppayloadlen );
396- /* Set/get the owner of the descriptor */
397- void (* set_tx_owner ) (struct dma_desc * p );
398- int (* get_tx_owner ) (struct dma_desc * p );
399- /* Clean the tx descriptor as soon as the tx irq is received */
400- void (* release_tx_desc ) (struct dma_desc * p , int mode );
401- /* Clear interrupt on tx frame completion. When this bit is
402- * set an interrupt happens as soon as the frame is transmitted */
403- void (* set_tx_ic )(struct dma_desc * p );
404- /* Last tx segment reports the transmit status */
405- int (* get_tx_ls ) (struct dma_desc * p );
406- /* Return the transmit status looking at the TDES1 */
407- int (* tx_status ) (void * data , struct stmmac_extra_stats * x ,
408- struct dma_desc * p , void __iomem * ioaddr );
409- /* Get the buffer size from the descriptor */
410- int (* get_tx_len ) (struct dma_desc * p );
411- /* Handle extra events on specific interrupts hw dependent */
412- void (* set_rx_owner ) (struct dma_desc * p );
413- /* Get the receive frame size */
414- int (* get_rx_frame_len ) (struct dma_desc * p , int rx_coe_type );
415- /* Return the reception status looking at the RDES1 */
416- int (* rx_status ) (void * data , struct stmmac_extra_stats * x ,
417- struct dma_desc * p );
418- void (* rx_extended_status ) (void * data , struct stmmac_extra_stats * x ,
419- struct dma_extended_desc * p );
420- /* Set tx timestamp enable bit */
421- void (* enable_tx_timestamp ) (struct dma_desc * p );
422- /* get tx timestamp status */
423- int (* get_tx_timestamp_status ) (struct dma_desc * p );
424- /* get timestamp value */
425- u64 (* get_timestamp ) (void * desc , u32 ats );
426- /* get rx timestamp status */
427- int (* get_rx_timestamp_status )(void * desc , void * next_desc , u32 ats );
428- /* Display ring */
429- void (* display_ring )(void * head , unsigned int size , bool rx );
430- /* set MSS via context descriptor */
431- void (* set_mss )(struct dma_desc * p , unsigned int mss );
432- };
433-
434381extern const struct stmmac_desc_ops enh_desc_ops ;
435382extern const struct stmmac_desc_ops ndesc_ops ;
436383
437- /* Specific DMA helpers */
438- struct stmmac_dma_ops {
439- /* DMA core initialization */
440- int (* reset )(void __iomem * ioaddr );
441- void (* init )(void __iomem * ioaddr , struct stmmac_dma_cfg * dma_cfg ,
442- u32 dma_tx , u32 dma_rx , int atds );
443- void (* init_chan )(void __iomem * ioaddr ,
444- struct stmmac_dma_cfg * dma_cfg , u32 chan );
445- void (* init_rx_chan )(void __iomem * ioaddr ,
446- struct stmmac_dma_cfg * dma_cfg ,
447- u32 dma_rx_phy , u32 chan );
448- void (* init_tx_chan )(void __iomem * ioaddr ,
449- struct stmmac_dma_cfg * dma_cfg ,
450- u32 dma_tx_phy , u32 chan );
451- /* Configure the AXI Bus Mode Register */
452- void (* axi )(void __iomem * ioaddr , struct stmmac_axi * axi );
453- /* Dump DMA registers */
454- void (* dump_regs )(void __iomem * ioaddr , u32 * reg_space );
455- /* Set tx/rx threshold in the csr6 register
456- * An invalid value enables the store-and-forward mode */
457- void (* dma_mode )(void __iomem * ioaddr , int txmode , int rxmode ,
458- int rxfifosz );
459- void (* dma_rx_mode )(void __iomem * ioaddr , int mode , u32 channel ,
460- int fifosz , u8 qmode );
461- void (* dma_tx_mode )(void __iomem * ioaddr , int mode , u32 channel ,
462- int fifosz , u8 qmode );
463- /* To track extra statistic (if supported) */
464- void (* dma_diagnostic_fr ) (void * data , struct stmmac_extra_stats * x ,
465- void __iomem * ioaddr );
466- void (* enable_dma_transmission ) (void __iomem * ioaddr );
467- void (* enable_dma_irq )(void __iomem * ioaddr , u32 chan );
468- void (* disable_dma_irq )(void __iomem * ioaddr , u32 chan );
469- void (* start_tx )(void __iomem * ioaddr , u32 chan );
470- void (* stop_tx )(void __iomem * ioaddr , u32 chan );
471- void (* start_rx )(void __iomem * ioaddr , u32 chan );
472- void (* stop_rx )(void __iomem * ioaddr , u32 chan );
473- int (* dma_interrupt ) (void __iomem * ioaddr ,
474- struct stmmac_extra_stats * x , u32 chan );
475- /* If supported then get the optional core features */
476- void (* get_hw_feature )(void __iomem * ioaddr ,
477- struct dma_features * dma_cap );
478- /* Program the HW RX Watchdog */
479- void (* rx_watchdog )(void __iomem * ioaddr , u32 riwt , u32 number_chan );
480- void (* set_tx_ring_len )(void __iomem * ioaddr , u32 len , u32 chan );
481- void (* set_rx_ring_len )(void __iomem * ioaddr , u32 len , u32 chan );
482- void (* set_rx_tail_ptr )(void __iomem * ioaddr , u32 tail_ptr , u32 chan );
483- void (* set_tx_tail_ptr )(void __iomem * ioaddr , u32 tail_ptr , u32 chan );
484- void (* enable_tso )(void __iomem * ioaddr , bool en , u32 chan );
485- };
486-
487384struct mac_device_info ;
488385
489- /* Helpers to program the MAC core */
490- struct stmmac_ops {
491- /* MAC core initialization */
492- void (* core_init )(struct mac_device_info * hw , struct net_device * dev );
493- /* Enable the MAC RX/TX */
494- void (* set_mac )(void __iomem * ioaddr , bool enable );
495- /* Enable and verify that the IPC module is supported */
496- int (* rx_ipc )(struct mac_device_info * hw );
497- /* Enable RX Queues */
498- void (* rx_queue_enable )(struct mac_device_info * hw , u8 mode , u32 queue );
499- /* RX Queues Priority */
500- void (* rx_queue_prio )(struct mac_device_info * hw , u32 prio , u32 queue );
501- /* TX Queues Priority */
502- void (* tx_queue_prio )(struct mac_device_info * hw , u32 prio , u32 queue );
503- /* RX Queues Routing */
504- void (* rx_queue_routing )(struct mac_device_info * hw , u8 packet ,
505- u32 queue );
506- /* Program RX Algorithms */
507- void (* prog_mtl_rx_algorithms )(struct mac_device_info * hw , u32 rx_alg );
508- /* Program TX Algorithms */
509- void (* prog_mtl_tx_algorithms )(struct mac_device_info * hw , u32 tx_alg );
510- /* Set MTL TX queues weight */
511- void (* set_mtl_tx_queue_weight )(struct mac_device_info * hw ,
512- u32 weight , u32 queue );
513- /* RX MTL queue to RX dma mapping */
514- void (* map_mtl_to_dma )(struct mac_device_info * hw , u32 queue , u32 chan );
515- /* Configure AV Algorithm */
516- void (* config_cbs )(struct mac_device_info * hw , u32 send_slope ,
517- u32 idle_slope , u32 high_credit , u32 low_credit ,
518- u32 queue );
519- /* Dump MAC registers */
520- void (* dump_regs )(struct mac_device_info * hw , u32 * reg_space );
521- /* Handle extra events on specific interrupts hw dependent */
522- int (* host_irq_status )(struct mac_device_info * hw ,
523- struct stmmac_extra_stats * x );
524- /* Handle MTL interrupts */
525- int (* host_mtl_irq_status )(struct mac_device_info * hw , u32 chan );
526- /* Multicast filter setting */
527- void (* set_filter )(struct mac_device_info * hw , struct net_device * dev );
528- /* Flow control setting */
529- void (* flow_ctrl )(struct mac_device_info * hw , unsigned int duplex ,
530- unsigned int fc , unsigned int pause_time , u32 tx_cnt );
531- /* Set power management mode (e.g. magic frame) */
532- void (* pmt )(struct mac_device_info * hw , unsigned long mode );
533- /* Set/Get Unicast MAC addresses */
534- void (* set_umac_addr )(struct mac_device_info * hw , unsigned char * addr ,
535- unsigned int reg_n );
536- void (* get_umac_addr )(struct mac_device_info * hw , unsigned char * addr ,
537- unsigned int reg_n );
538- void (* set_eee_mode )(struct mac_device_info * hw ,
539- bool en_tx_lpi_clockgating );
540- void (* reset_eee_mode )(struct mac_device_info * hw );
541- void (* set_eee_timer )(struct mac_device_info * hw , int ls , int tw );
542- void (* set_eee_pls )(struct mac_device_info * hw , int link );
543- void (* debug )(void __iomem * ioaddr , struct stmmac_extra_stats * x ,
544- u32 rx_queues , u32 tx_queues );
545- /* PCS calls */
546- void (* pcs_ctrl_ane )(void __iomem * ioaddr , bool ane , bool srgmi_ral ,
547- bool loopback );
548- void (* pcs_rane )(void __iomem * ioaddr , bool restart );
549- void (* pcs_get_adv_lp )(void __iomem * ioaddr , struct rgmii_adv * adv );
550- /* Safety Features */
551- int (* safety_feat_config )(void __iomem * ioaddr , unsigned int asp );
552- bool (* safety_feat_irq_status )(struct net_device * ndev ,
553- void __iomem * ioaddr , unsigned int asp ,
554- struct stmmac_safety_stats * stats );
555- const char * (* safety_feat_dump )(struct stmmac_safety_stats * stats ,
556- int index , unsigned long * count );
557- };
558-
559- /* PTP and HW Timer helpers */
560- struct stmmac_hwtimestamp {
561- void (* config_hw_tstamping ) (void __iomem * ioaddr , u32 data );
562- u32 (* config_sub_second_increment )(void __iomem * ioaddr , u32 ptp_clock ,
563- int gmac4 );
564- int (* init_systime ) (void __iomem * ioaddr , u32 sec , u32 nsec );
565- int (* config_addend ) (void __iomem * ioaddr , u32 addend );
566- int (* adjust_systime ) (void __iomem * ioaddr , u32 sec , u32 nsec ,
567- int add_sub , int gmac4 );
568- u64 (* get_systime ) (void __iomem * ioaddr );
569- };
570-
571386extern const struct stmmac_hwtimestamp stmmac_ptp ;
572387extern const struct stmmac_mode_ops dwmac4_ring_mode_ops ;
573388
@@ -590,18 +405,6 @@ struct mii_regs {
590405 unsigned int clk_csr_mask ;
591406};
592407
593- /* Helpers to manage the descriptors for chain and ring modes */
594- struct stmmac_mode_ops {
595- void (* init ) (void * des , dma_addr_t phy_addr , unsigned int size ,
596- unsigned int extend_desc );
597- unsigned int (* is_jumbo_frm ) (int len , int ehn_desc );
598- int (* jumbo_frm )(void * priv , struct sk_buff * skb , int csum );
599- int (* set_16kib_bfsize )(int mtu );
600- void (* init_desc3 )(struct dma_desc * p );
601- void (* refill_desc3 ) (void * priv , struct dma_desc * p );
602- void (* clean_desc3 ) (void * priv , struct dma_desc * p );
603- };
604-
605408struct mac_device_info {
606409 const struct stmmac_ops * mac ;
607410 const struct stmmac_desc_ops * desc ;
0 commit comments