mirror of https://gitee.com/openkylin/linux.git
net: mscc: ocelot: convert to use ocelot_port_add_txtstamp_skb()
Convert to use ocelot_port_add_txtstamp_skb() for adding skbs which require TX timestamp into list. Export it so that DSA Felix driver could reuse it too. Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
e23a7b3e8d
commit
400928bf92
|
@ -575,6 +575,32 @@ static int ocelot_gen_ifh(u32 *ifh, struct frame_info *info)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int ocelot_port_add_txtstamp_skb(struct ocelot_port *ocelot_port,
|
||||
struct sk_buff *skb)
|
||||
{
|
||||
struct skb_shared_info *shinfo = skb_shinfo(skb);
|
||||
struct ocelot *ocelot = ocelot_port->ocelot;
|
||||
|
||||
if (ocelot->ptp && shinfo->tx_flags & SKBTX_HW_TSTAMP &&
|
||||
ocelot_port->ptp_cmd == IFH_REW_OP_TWO_STEP_PTP) {
|
||||
struct ocelot_skb *oskb =
|
||||
kzalloc(sizeof(struct ocelot_skb), GFP_ATOMIC);
|
||||
|
||||
if (unlikely(!oskb))
|
||||
return -ENOMEM;
|
||||
|
||||
shinfo->tx_flags |= SKBTX_IN_PROGRESS;
|
||||
|
||||
oskb->skb = skb;
|
||||
oskb->id = ocelot_port->ts_id % 4;
|
||||
|
||||
list_add_tail(&oskb->head, &ocelot_port->skbs);
|
||||
return 0;
|
||||
}
|
||||
return -ENODATA;
|
||||
}
|
||||
EXPORT_SYMBOL(ocelot_port_add_txtstamp_skb);
|
||||
|
||||
static int ocelot_port_xmit(struct sk_buff *skb, struct net_device *dev)
|
||||
{
|
||||
struct ocelot_port_private *priv = netdev_priv(dev);
|
||||
|
@ -637,26 +663,11 @@ static int ocelot_port_xmit(struct sk_buff *skb, struct net_device *dev)
|
|||
dev->stats.tx_packets++;
|
||||
dev->stats.tx_bytes += skb->len;
|
||||
|
||||
if (ocelot->ptp && shinfo->tx_flags & SKBTX_HW_TSTAMP &&
|
||||
ocelot_port->ptp_cmd == IFH_REW_OP_TWO_STEP_PTP) {
|
||||
struct ocelot_skb *oskb =
|
||||
kzalloc(sizeof(struct ocelot_skb), GFP_ATOMIC);
|
||||
|
||||
if (unlikely(!oskb))
|
||||
goto out;
|
||||
|
||||
skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
|
||||
|
||||
oskb->skb = skb;
|
||||
oskb->id = ocelot_port->ts_id % 4;
|
||||
if (!ocelot_port_add_txtstamp_skb(ocelot_port, skb)) {
|
||||
ocelot_port->ts_id++;
|
||||
|
||||
list_add_tail(&oskb->head, &ocelot_port->skbs);
|
||||
|
||||
return NETDEV_TX_OK;
|
||||
}
|
||||
|
||||
out:
|
||||
dev_kfree_skb_any(skb);
|
||||
return NETDEV_TX_OK;
|
||||
}
|
||||
|
|
|
@ -543,6 +543,8 @@ int ocelot_vlan_del(struct ocelot *ocelot, int port, u16 vid);
|
|||
int ocelot_hwstamp_get(struct ocelot *ocelot, int port, struct ifreq *ifr);
|
||||
int ocelot_hwstamp_set(struct ocelot *ocelot, int port, struct ifreq *ifr);
|
||||
int ocelot_ptp_gettime64(struct ptp_clock_info *ptp, struct timespec64 *ts);
|
||||
int ocelot_port_add_txtstamp_skb(struct ocelot_port *ocelot_port,
|
||||
struct sk_buff *skb);
|
||||
void ocelot_get_txtstamp(struct ocelot *ocelot);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue