mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-30 15:43:08 -04:00
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>
This commit is contained in:
committed by
Jakub Kicinski
parent
ac99cc6cd3
commit
e5a0c13163
@@ -103,72 +103,6 @@ static struct sk_buff *ksz_common_rcv(struct sk_buff *skb,
|
||||
return 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.
|
||||
* ---------------------------------------------------------------------------
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user