@@ -56,6 +56,16 @@ enum timer_act {
5656 TACT_SKIP_PROG , /* just buffer can be updated */
5757};
5858
59+ static u32
60+ am65_cpsw_qos_tx_rate_calc (u32 rate_mbps , unsigned long bus_freq )
61+ {
62+ u32 ir ;
63+
64+ bus_freq /= 1000000 ;
65+ ir = DIV_ROUND_UP (((u64 )rate_mbps * 32768 ), bus_freq );
66+ return ir ;
67+ }
68+
5969static int am65_cpsw_port_est_enabled (struct am65_cpsw_port * port )
6070{
6171 return port -> qos .est_oper || port -> qos .est_admin ;
@@ -772,49 +782,6 @@ static int am65_cpsw_qos_setup_tc_block(struct net_device *ndev, struct flow_blo
772782 port , port , true);
773783}
774784
775- int am65_cpsw_qos_ndo_setup_tc (struct net_device * ndev , enum tc_setup_type type ,
776- void * type_data )
777- {
778- switch (type ) {
779- case TC_QUERY_CAPS :
780- return am65_cpsw_tc_query_caps (ndev , type_data );
781- case TC_SETUP_QDISC_TAPRIO :
782- return am65_cpsw_setup_taprio (ndev , type_data );
783- case TC_SETUP_BLOCK :
784- return am65_cpsw_qos_setup_tc_block (ndev , type_data );
785- default :
786- return - EOPNOTSUPP ;
787- }
788- }
789-
790- void am65_cpsw_qos_link_up (struct net_device * ndev , int link_speed )
791- {
792- struct am65_cpsw_port * port = am65_ndev_to_port (ndev );
793-
794- am65_cpsw_est_link_up (ndev , link_speed );
795- port -> qos .link_down_time = 0 ;
796- }
797-
798- void am65_cpsw_qos_link_down (struct net_device * ndev )
799- {
800- struct am65_cpsw_port * port = am65_ndev_to_port (ndev );
801-
802- if (!port -> qos .link_down_time )
803- port -> qos .link_down_time = ktime_get ();
804-
805- port -> qos .link_speed = SPEED_UNKNOWN ;
806- }
807-
808- static u32
809- am65_cpsw_qos_tx_rate_calc (u32 rate_mbps , unsigned long bus_freq )
810- {
811- u32 ir ;
812-
813- bus_freq /= 1000000 ;
814- ir = DIV_ROUND_UP (((u64 )rate_mbps * 32768 ), bus_freq );
815- return ir ;
816- }
817-
818785static void
819786am65_cpsw_qos_tx_p0_rate_apply (struct am65_cpsw_common * common ,
820787 int tx_ch , u32 rate_mbps )
@@ -916,3 +883,36 @@ void am65_cpsw_qos_tx_p0_rate_init(struct am65_cpsw_common *common)
916883 host -> port_base + AM65_CPSW_PN_REG_PRI_CIR (tx_ch ));
917884 }
918885}
886+
887+ int am65_cpsw_qos_ndo_setup_tc (struct net_device * ndev , enum tc_setup_type type ,
888+ void * type_data )
889+ {
890+ switch (type ) {
891+ case TC_QUERY_CAPS :
892+ return am65_cpsw_tc_query_caps (ndev , type_data );
893+ case TC_SETUP_QDISC_TAPRIO :
894+ return am65_cpsw_setup_taprio (ndev , type_data );
895+ case TC_SETUP_BLOCK :
896+ return am65_cpsw_qos_setup_tc_block (ndev , type_data );
897+ default :
898+ return - EOPNOTSUPP ;
899+ }
900+ }
901+
902+ void am65_cpsw_qos_link_up (struct net_device * ndev , int link_speed )
903+ {
904+ struct am65_cpsw_port * port = am65_ndev_to_port (ndev );
905+
906+ am65_cpsw_est_link_up (ndev , link_speed );
907+ port -> qos .link_down_time = 0 ;
908+ }
909+
910+ void am65_cpsw_qos_link_down (struct net_device * ndev )
911+ {
912+ struct am65_cpsw_port * port = am65_ndev_to_port (ndev );
913+
914+ if (!port -> qos .link_down_time )
915+ port -> qos .link_down_time = ktime_get ();
916+
917+ port -> qos .link_speed = SPEED_UNKNOWN ;
918+ }
0 commit comments