pkt.rx has dual use with different meaning on rx and tx path. Signed-off-by: Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx> --- net/can/j1939/j1939-priv.h | 1 + net/can/j1939/socket.c | 2 +- net/can/j1939/transport.c | 14 +++++++------- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/net/can/j1939/j1939-priv.h b/net/can/j1939/j1939-priv.h index 612ed17864d0..c9f1b0df4478 100644 --- a/net/can/j1939/j1939-priv.h +++ b/net/can/j1939/j1939-priv.h @@ -261,6 +261,7 @@ struct j1939_session { * this counter can be set back if responder node didn't * received all packets send by originator. */ unsigned int tx; + unsigned int tx_acked; /* rx - number of packets received */ unsigned int rx; /* block - amount of packets expected in one block */ diff --git a/net/can/j1939/socket.c b/net/can/j1939/socket.c index 0c5de3178e12..19e662574b5f 100644 --- a/net/can/j1939/socket.c +++ b/net/can/j1939/socket.c @@ -852,7 +852,7 @@ static struct sk_buff *j1939_sk_get_timestamping_opt_stats(struct j1939_session return NULL; nla_put_u32(stats, J1939_NLA_BYTES_ACKED, - min(session->pkt.rx * 7, session->total_message_size)); + min(session->pkt.tx_acked * 7, session->total_message_size)); return stats; } diff --git a/net/can/j1939/transport.c b/net/can/j1939/transport.c index e0c8fb469d96..858c4587af8f 100644 --- a/net/can/j1939/transport.c +++ b/net/can/j1939/transport.c @@ -301,7 +301,7 @@ static void j1939_session_skb_drop_old(struct j1939_session *session) if (skb_queue_len(&session->skb_queue) < 2) return; - offset_start = session->pkt.rx * 7; + offset_start = session->pkt.tx_acked * 7; spin_lock_irqsave(&session->skb_queue.lock, flags); do_skb = skb_peek(&session->skb_queue); @@ -712,9 +712,9 @@ static int j1939_tp_txnext(struct j1939_session *session) session->last_txcmd != J1939_ETP_CMD_DPO) { /* do dpo */ dat[0] = J1939_ETP_CMD_DPO; - session->pkt.dpo = session->pkt.rx; + session->pkt.dpo = session->pkt.tx_acked; pkt = session->pkt.dpo; - dat[1] = session->pkt.last - session->pkt.rx; + dat[1] = session->pkt.last - session->pkt.tx_acked; dat[2] = (pkt >> 0); dat[3] = (pkt >> 8); dat[4] = (pkt >> 16); @@ -723,7 +723,7 @@ static int j1939_tp_txnext(struct j1939_session *session) goto failed; session->last_txcmd = dat[0]; j1939_tp_set_rxtimeout(session, 1250); - session->pkt.tx = session->pkt.rx; + session->pkt.tx = session->pkt.tx_acked; } /* fallthrough */ case J1939_TP_CMD_CTS: /* fallthrough */ @@ -1090,14 +1090,14 @@ j1939_xtp_rx_cts(struct j1939_session *session, struct sk_buff *skb) goto out_session_unlock; } else { /* set packet counters only when not CTS(0) */ - session->pkt.rx = pkt - 1; + session->pkt.tx_acked = pkt - 1; j1939_session_skb_drop_old(session); - session->pkt.last = session->pkt.rx + dat[1]; + session->pkt.last = session->pkt.tx_acked + dat[1]; if (session->pkt.last > session->pkt.total) /* safety measure */ session->pkt.last = session->pkt.total; /* TODO: do not set tx here, do it in txtimer */ - session->pkt.tx = session->pkt.rx; + session->pkt.tx = session->pkt.tx_acked; } session->last_cmd = dat[0]; -- 2.20.1