Commit d63394ab authored by Tanmay Patil's avatar Tanmay Patil Committed by David S. Miller

net: ethernet: ti: am65-cpsw-qos: Add support to taprio for past base_time

If the base-time for taprio is in the past, start the schedule at the time
of the form "base_time + N*cycle_time" where N is the smallest possible
integer such that the above time is in the future.
Signed-off-by: default avatarTanmay Patil <t-patil@ti.com>
Signed-off-by: default avatarChintan Vankar <c-vankar@ti.com>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5c4c0edc
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/math.h> #include <linux/math.h>
#include <linux/math64.h>
#include <linux/time.h> #include <linux/time.h>
#include <linux/units.h> #include <linux/units.h>
#include <net/pkt_cls.h> #include <net/pkt_cls.h>
...@@ -837,6 +838,7 @@ static int am65_cpsw_taprio_replace(struct net_device *ndev, ...@@ -837,6 +838,7 @@ static int am65_cpsw_taprio_replace(struct net_device *ndev,
struct am65_cpsw_port *port = am65_ndev_to_port(ndev); struct am65_cpsw_port *port = am65_ndev_to_port(ndev);
struct am65_cpts *cpts = common->cpts; struct am65_cpts *cpts = common->cpts;
struct am65_cpsw_est *est_new; struct am65_cpsw_est *est_new;
u64 cur_time, n;
int ret, tact; int ret, tact;
if (!netif_running(ndev)) { if (!netif_running(ndev)) {
...@@ -888,13 +890,21 @@ static int am65_cpsw_taprio_replace(struct net_device *ndev, ...@@ -888,13 +890,21 @@ static int am65_cpsw_taprio_replace(struct net_device *ndev,
if (tact == TACT_PROG) if (tact == TACT_PROG)
am65_cpsw_timer_stop(ndev); am65_cpsw_timer_stop(ndev);
if (!est_new->taprio.base_time)
est_new->taprio.base_time = am65_cpts_ns_gettime(cpts);
am65_cpsw_port_est_get_buf_num(ndev, est_new); am65_cpsw_port_est_get_buf_num(ndev, est_new);
am65_cpsw_est_set_sched_list(ndev, est_new); am65_cpsw_est_set_sched_list(ndev, est_new);
am65_cpsw_port_est_assign_buf_num(ndev, est_new->buf); am65_cpsw_port_est_assign_buf_num(ndev, est_new->buf);
/* If the base-time is in the past, start schedule from the time:
* base_time + (N*cycle_time)
* where N is the smallest possible integer such that the above
* time is in the future.
*/
cur_time = am65_cpts_ns_gettime(cpts);
if (est_new->taprio.base_time < cur_time) {
n = div64_u64(cur_time - est_new->taprio.base_time, est_new->taprio.cycle_time);
est_new->taprio.base_time += (n + 1) * est_new->taprio.cycle_time;
}
am65_cpsw_est_set(ndev, 1); am65_cpsw_est_set(ndev, 1);
if (tact == TACT_PROG) { if (tact == TACT_PROG) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment