diff options
| author | Bastien Curutchet (Schneider Electric) <bastien.curutchet@bootlin.com> | 2026-07-27 12:20:48 +0200 |
|---|---|---|
| committer | Jakub Kicinski <kuba@kernel.org> | 2026-07-31 16:29:56 -0700 |
| commit | e5a0c13163684a8a1c16636437e627535a7b82ab (patch) | |
| tree | f1885a76c9eabf7a5c5db64feef9306301b1900a | |
| parent | ac99cc6cd3f80308192e884547b3e384de9f6807 (diff) | |
net: dsa: tag_ksz: move the KSZ8795 tag handling below ksz_xmit_timestamp()
Upcoming patch reduces code duplication between KSZ8795 and KSZ9893 by
introducing a common xmit() function. This rework needs the KSZ8795
handlers to be implemented below ksz_defer_xmit().
Do the move now to reduce the noise in next patch.
No functionnal change is intended in this patch.
Signed-off-by: Bastien Curutchet (Schneider Electric) <bastien.curutchet@bootlin.com>
Link: https://patch.msgid.link/20260727-ksz-new-ptp-v3-6-caba39e680e3@bootlin.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
| -rw-r--r-- | net/dsa/tag_ksz.c | 132 |
1 files changed, 66 insertions, 66 deletions
diff --git a/net/dsa/tag_ksz.c b/net/dsa/tag_ksz.c index 67fa89f102e0..f58ce0f0e9e4 100644 --- a/net/dsa/tag_ksz.c +++ b/net/dsa/tag_ksz.c @@ -104,72 +104,6 @@ static struct sk_buff *ksz_common_rcv(struct sk_buff *skb, } /* - * For Ingress (Host -> KSZ8795), 1 byte is added before FCS. - * --------------------------------------------------------------------------- - * DA(6bytes)|SA(6bytes)|....|Data(nbytes)|tag(1byte)|FCS(4bytes) - * --------------------------------------------------------------------------- - * tag : each bit represents port (eg, 0x01=port1, 0x02=port2, 0x10=port5) - * - * For Egress (KSZ8795 -> Host), 1 byte is added before FCS. - * --------------------------------------------------------------------------- - * DA(6bytes)|SA(6bytes)|....|Data(nbytes)|tag0(1byte)|FCS(4bytes) - * --------------------------------------------------------------------------- - * tag0 : zero-based value represents port - * (eg, 0x0=port1, 0x2=port3, 0x3=port4) - */ - -#define KSZ8795_TAIL_TAG_EG_PORT_M GENMASK(1, 0) -#define KSZ8795_TAIL_TAG_OVERRIDE BIT(6) -#define KSZ8795_TAIL_TAG_LOOKUP BIT(7) - -static struct sk_buff *ksz8795_xmit(struct sk_buff *skb, struct net_device *dev) -{ - struct ethhdr *hdr; - u8 *tag; - - if (skb->ip_summed == CHECKSUM_PARTIAL && skb_checksum_help(skb)) { - kfree_skb(skb); - return NULL; - } - - /* Tag encoding */ - tag = skb_put(skb, KSZ_INGRESS_TAG_LEN); - hdr = skb_eth_hdr(skb); - - *tag = dsa_xmit_port_mask(skb, dev); - if (is_link_local_ether_addr(hdr->h_dest)) - *tag |= KSZ8795_TAIL_TAG_OVERRIDE; - - return skb; -} - -static struct sk_buff *ksz8795_rcv(struct sk_buff *skb, struct net_device *dev) -{ - u8 *tag; - - if (skb_linearize(skb)) { - kfree_skb(skb); - return NULL; - } - - tag = skb_tail_pointer(skb) - KSZ_EGRESS_TAG_LEN; - - return ksz_common_rcv(skb, dev, tag[0] & KSZ8795_TAIL_TAG_EG_PORT_M, - KSZ_EGRESS_TAG_LEN); -} - -static const struct dsa_device_ops ksz8795_netdev_ops = { - .name = KSZ8795_NAME, - .proto = DSA_TAG_PROTO_KSZ8795, - .xmit = ksz8795_xmit, - .rcv = ksz8795_rcv, - .needed_tailroom = KSZ_INGRESS_TAG_LEN, -}; - -DSA_TAG_DRIVER(ksz8795_netdev_ops); -MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_KSZ8795, KSZ8795_NAME); - -/* * For Ingress (Host -> KSZ9477), 2/6 bytes are added before FCS. * --------------------------------------------------------------------------- * DA(6bytes)|SA(6bytes)|....|Data(nbytes)|ts(4bytes)|tag0(1byte)|tag1(1byte)| @@ -353,6 +287,72 @@ static const struct dsa_device_ops ksz9477_netdev_ops = { DSA_TAG_DRIVER(ksz9477_netdev_ops); MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_KSZ9477, KSZ9477_NAME); +/* + * For Ingress (Host -> KSZ8795), 1 byte is added before FCS. + * --------------------------------------------------------------------------- + * DA(6bytes)|SA(6bytes)|....|Data(nbytes)|tag(1byte)|FCS(4bytes) + * --------------------------------------------------------------------------- + * tag : each bit represents port (eg, 0x01=port1, 0x02=port2, 0x10=port5) + * + * For Egress (KSZ8795 -> Host), 1 byte is added before FCS. + * --------------------------------------------------------------------------- + * DA(6bytes)|SA(6bytes)|....|Data(nbytes)|tag0(1byte)|FCS(4bytes) + * --------------------------------------------------------------------------- + * tag0 : zero-based value represents port + * (eg, 0x0=port1, 0x2=port3, 0x3=port4) + */ + +#define KSZ8795_TAIL_TAG_EG_PORT_M GENMASK(1, 0) +#define KSZ8795_TAIL_TAG_OVERRIDE BIT(6) +#define KSZ8795_TAIL_TAG_LOOKUP BIT(7) + +static struct sk_buff *ksz8795_xmit(struct sk_buff *skb, struct net_device *dev) +{ + struct ethhdr *hdr; + u8 *tag; + + if (skb->ip_summed == CHECKSUM_PARTIAL && skb_checksum_help(skb)) { + kfree_skb(skb); + return NULL; + } + + /* Tag encoding */ + tag = skb_put(skb, KSZ_INGRESS_TAG_LEN); + hdr = skb_eth_hdr(skb); + + *tag = dsa_xmit_port_mask(skb, dev); + if (is_link_local_ether_addr(hdr->h_dest)) + *tag |= KSZ8795_TAIL_TAG_OVERRIDE; + + return skb; +} + +static struct sk_buff *ksz8795_rcv(struct sk_buff *skb, struct net_device *dev) +{ + u8 *tag; + + if (skb_linearize(skb)) { + kfree_skb(skb); + return NULL; + } + + tag = skb_tail_pointer(skb) - KSZ_EGRESS_TAG_LEN; + + return ksz_common_rcv(skb, dev, tag[0] & KSZ8795_TAIL_TAG_EG_PORT_M, + KSZ_EGRESS_TAG_LEN); +} + +static const struct dsa_device_ops ksz8795_netdev_ops = { + .name = KSZ8795_NAME, + .proto = DSA_TAG_PROTO_KSZ8795, + .xmit = ksz8795_xmit, + .rcv = ksz8795_rcv, + .needed_tailroom = KSZ_INGRESS_TAG_LEN, +}; + +DSA_TAG_DRIVER(ksz8795_netdev_ops); +MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_KSZ8795, KSZ8795_NAME); + #define KSZ9893_TAIL_TAG_PRIO GENMASK(4, 3) #define KSZ9893_TAIL_TAG_OVERRIDE BIT(5) #define KSZ9893_TAIL_TAG_LOOKUP BIT(6) |
