1 From c0c92f8d9a093faf64397b1874f074e071a5b4e2 Mon Sep 17 00:00:00 2001
2 From: Yangbo Lu <yangbo.lu@nxp.com>
3 Date: Wed, 20 Nov 2019 16:23:16 +0800
4 Subject: [PATCH] net: mscc: ocelot: convert to use
5 ocelot_port_add_txtstamp_skb()
7 Convert to use ocelot_port_add_txtstamp_skb() for adding skbs which
8 require TX timestamp into list. Export it so that DSA Felix driver
11 Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
12 Reviewed-by: Andrew Lunn <andrew@lunn.ch>
13 Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
14 Signed-off-by: David S. Miller <davem@davemloft.net>
16 drivers/net/ethernet/mscc/ocelot.c | 43 ++++++++++++++++++++++++--------------
17 include/soc/mscc/ocelot.h | 2 ++
18 2 files changed, 29 insertions(+), 16 deletions(-)
20 --- a/drivers/net/ethernet/mscc/ocelot.c
21 +++ b/drivers/net/ethernet/mscc/ocelot.c
22 @@ -575,6 +575,32 @@ static int ocelot_gen_ifh(u32 *ifh, stru
26 +int ocelot_port_add_txtstamp_skb(struct ocelot_port *ocelot_port,
27 + struct sk_buff *skb)
29 + struct skb_shared_info *shinfo = skb_shinfo(skb);
30 + struct ocelot *ocelot = ocelot_port->ocelot;
32 + if (ocelot->ptp && shinfo->tx_flags & SKBTX_HW_TSTAMP &&
33 + ocelot_port->ptp_cmd == IFH_REW_OP_TWO_STEP_PTP) {
34 + struct ocelot_skb *oskb =
35 + kzalloc(sizeof(struct ocelot_skb), GFP_ATOMIC);
37 + if (unlikely(!oskb))
40 + shinfo->tx_flags |= SKBTX_IN_PROGRESS;
43 + oskb->id = ocelot_port->ts_id % 4;
45 + list_add_tail(&oskb->head, &ocelot_port->skbs);
50 +EXPORT_SYMBOL(ocelot_port_add_txtstamp_skb);
52 static int ocelot_port_xmit(struct sk_buff *skb, struct net_device *dev)
54 struct ocelot_port_private *priv = netdev_priv(dev);
55 @@ -637,26 +663,11 @@ static int ocelot_port_xmit(struct sk_bu
56 dev->stats.tx_packets++;
57 dev->stats.tx_bytes += skb->len;
59 - if (ocelot->ptp && shinfo->tx_flags & SKBTX_HW_TSTAMP &&
60 - ocelot_port->ptp_cmd == IFH_REW_OP_TWO_STEP_PTP) {
61 - struct ocelot_skb *oskb =
62 - kzalloc(sizeof(struct ocelot_skb), GFP_ATOMIC);
64 - if (unlikely(!oskb))
67 - skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
70 - oskb->id = ocelot_port->ts_id % 4;
71 + if (!ocelot_port_add_txtstamp_skb(ocelot_port, skb)) {
74 - list_add_tail(&oskb->head, &ocelot_port->skbs);
80 dev_kfree_skb_any(skb);
83 --- a/include/soc/mscc/ocelot.h
84 +++ b/include/soc/mscc/ocelot.h
85 @@ -543,6 +543,8 @@ int ocelot_vlan_del(struct ocelot *ocelo
86 int ocelot_hwstamp_get(struct ocelot *ocelot, int port, struct ifreq *ifr);
87 int ocelot_hwstamp_set(struct ocelot *ocelot, int port, struct ifreq *ifr);
88 int ocelot_ptp_gettime64(struct ptp_clock_info *ptp, struct timespec64 *ts);
89 +int ocelot_port_add_txtstamp_skb(struct ocelot_port *ocelot_port,
90 + struct sk_buff *skb);
91 void ocelot_get_txtstamp(struct ocelot *ocelot);