mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-28 07:04:00 +08:00
can: j1939: transport: add j1939_session_skb_find_by_offset() function
Sometimes it makes no sense to search the skb by pkt.dpo, since we need
next the skb within the transaction block. This may happen if we have an
ETP session with CTS set to less than 255 packets.
After this patch, we will be able to work with ETP sessions where the
block size (ETP.CM_CTS byte 2) is less than 255 packets.
Reported-by: Henrique Figueira <henrislip@gmail.com>
Reported-by: https://github.com/linux-can/can-utils/issues/228
Fixes: 9d71dd0c70
("can: add support of SAE J1939 protocol")
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Link: https://lore.kernel.org/r/20200807105200.26441-5-o.rempel@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
This commit is contained in:
parent
af804b7826
commit
840835c928
@ -352,17 +352,16 @@ void j1939_session_skb_queue(struct j1939_session *session,
|
||||
skb_queue_tail(&session->skb_queue, skb);
|
||||
}
|
||||
|
||||
static struct sk_buff *j1939_session_skb_find(struct j1939_session *session)
|
||||
static struct
|
||||
sk_buff *j1939_session_skb_find_by_offset(struct j1939_session *session,
|
||||
unsigned int offset_start)
|
||||
{
|
||||
struct j1939_priv *priv = session->priv;
|
||||
struct j1939_sk_buff_cb *do_skcb;
|
||||
struct sk_buff *skb = NULL;
|
||||
struct sk_buff *do_skb;
|
||||
struct j1939_sk_buff_cb *do_skcb;
|
||||
unsigned int offset_start;
|
||||
unsigned long flags;
|
||||
|
||||
offset_start = session->pkt.dpo * 7;
|
||||
|
||||
spin_lock_irqsave(&session->skb_queue.lock, flags);
|
||||
skb_queue_walk(&session->skb_queue, do_skb) {
|
||||
do_skcb = j1939_skb_to_cb(do_skb);
|
||||
@ -382,6 +381,14 @@ static struct sk_buff *j1939_session_skb_find(struct j1939_session *session)
|
||||
return skb;
|
||||
}
|
||||
|
||||
static struct sk_buff *j1939_session_skb_find(struct j1939_session *session)
|
||||
{
|
||||
unsigned int offset_start;
|
||||
|
||||
offset_start = session->pkt.dpo * 7;
|
||||
return j1939_session_skb_find_by_offset(session, offset_start);
|
||||
}
|
||||
|
||||
/* see if we are receiver
|
||||
* returns 0 for broadcasts, although we will receive them
|
||||
*/
|
||||
@ -766,7 +773,7 @@ static int j1939_session_tx_dat(struct j1939_session *session)
|
||||
int ret = 0;
|
||||
u8 dat[8];
|
||||
|
||||
se_skb = j1939_session_skb_find(session);
|
||||
se_skb = j1939_session_skb_find_by_offset(session, session->pkt.tx * 7);
|
||||
if (!se_skb)
|
||||
return -ENOBUFS;
|
||||
|
||||
@ -1765,7 +1772,8 @@ static void j1939_xtp_rx_dat_one(struct j1939_session *session,
|
||||
__func__, session);
|
||||
goto out_session_cancel;
|
||||
}
|
||||
se_skb = j1939_session_skb_find(session);
|
||||
|
||||
se_skb = j1939_session_skb_find_by_offset(session, packet * 7);
|
||||
if (!se_skb) {
|
||||
netdev_warn(priv->ndev, "%s: 0x%p: no skb found\n", __func__,
|
||||
session);
|
||||
|
Loading…
Reference in New Issue
Block a user