On 10/13/21 11:45 AM, DENG Qingfang wrote: > On Tue, Oct 12, 2021 at 02:35:53PM +0200, Alvin Šipraga wrote: >> +static struct sk_buff *rtl8_4_tag_rcv(struct sk_buff *skb, >> + struct net_device *dev) >> +{ >> + __be16 *tag; >> + u16 etype; >> + u8 proto; >> + u8 port; >> + >> + if (unlikely(!pskb_may_pull(skb, RTL8_4_TAG_LEN))) >> + return NULL; >> + >> + tag = dsa_etype_header_pos_rx(skb); >> + >> + /* Parse Realtek EtherType */ >> + etype = ntohs(tag[0]); >> + if (unlikely(etype != ETH_P_REALTEK)) { >> + dev_warn_ratelimited(&dev->dev, >> + "non-realtek ethertype 0x%04x\n", etype); >> + return NULL; >> + } >> + >> + /* Parse Protocol */ >> + proto = ntohs(tag[1]) >> 8; >> + if (unlikely(proto != RTL8_4_PROTOCOL_RTL8365MB)) { >> + dev_warn_ratelimited(&dev->dev, >> + "unknown realtek protocol 0x%02x\n", >> + proto); >> + return NULL; >> + } >> + >> + /* Parse TX (switch->CPU) */ >> + port = ntohs(tag[3]) & 0xf; /* Port number is the LSB 4 bits */ >> + skb->dev = dsa_master_find_slave(dev, 0, port); >> + if (!skb->dev) { >> + dev_warn_ratelimited(&dev->dev, >> + "could not find slave for port %d\n", >> + port); >> + return NULL; >> + } >> + >> + /* Remove tag and recalculate checksum */ >> + skb_pull_rcsum(skb, RTL8_4_TAG_LEN); >> + >> + dsa_strip_etype_header(skb, RTL8_4_TAG_LEN); >> + >> + dsa_default_offload_fwd_mark(skb); > > This should not be set if the REASON is trapped to CPU. Thanks, you're right. Although with the current state of the driver, skb->offload_fwd_mark will never get set, because the bridge is not offloaded onto the HW. But I will fix this up in v2. > >> + >> + return skb; >> +}