Commit 682eaad9 authored by Yangbo Lu's avatar Yangbo Lu Committed by David S. Miller

net: mscc: ocelot: convert to ocelot_port_txtstamp_request()

Convert to a common ocelot_port_txtstamp_request() for TX timestamp
request handling.
Signed-off-by: default avatarYangbo Lu <yangbo.lu@nxp.com>
Reviewed-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
Acked-by: default avatarRichard Cochran <richardcochran@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d150946e
...@@ -1399,17 +1399,16 @@ static void felix_txtstamp(struct dsa_switch *ds, int port, ...@@ -1399,17 +1399,16 @@ static void felix_txtstamp(struct dsa_switch *ds, int port,
struct sk_buff *skb) struct sk_buff *skb)
{ {
struct ocelot *ocelot = ds->priv; struct ocelot *ocelot = ds->priv;
struct ocelot_port *ocelot_port = ocelot->ports[port]; struct sk_buff *clone = NULL;
struct sk_buff *clone;
if (ocelot->ptp && ocelot_port->ptp_cmd == IFH_REW_OP_TWO_STEP_PTP) { if (!ocelot->ptp)
clone = skb_clone_sk(skb); return;
if (!clone)
return;
ocelot_port_add_txtstamp_skb(ocelot, port, clone); if (ocelot_port_txtstamp_request(ocelot, port, skb, &clone))
return;
if (clone)
OCELOT_SKB_CB(skb)->clone = clone; OCELOT_SKB_CB(skb)->clone = clone;
}
} }
static int felix_change_mtu(struct dsa_switch *ds, int port, int new_mtu) static int felix_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
......
...@@ -530,8 +530,8 @@ void ocelot_port_disable(struct ocelot *ocelot, int port) ...@@ -530,8 +530,8 @@ void ocelot_port_disable(struct ocelot *ocelot, int port)
} }
EXPORT_SYMBOL(ocelot_port_disable); EXPORT_SYMBOL(ocelot_port_disable);
void ocelot_port_add_txtstamp_skb(struct ocelot *ocelot, int port, static void ocelot_port_add_txtstamp_skb(struct ocelot *ocelot, int port,
struct sk_buff *clone) struct sk_buff *clone)
{ {
struct ocelot_port *ocelot_port = ocelot->ports[port]; struct ocelot_port *ocelot_port = ocelot->ports[port];
...@@ -545,7 +545,25 @@ void ocelot_port_add_txtstamp_skb(struct ocelot *ocelot, int port, ...@@ -545,7 +545,25 @@ void ocelot_port_add_txtstamp_skb(struct ocelot *ocelot, int port,
spin_unlock(&ocelot_port->ts_id_lock); spin_unlock(&ocelot_port->ts_id_lock);
} }
EXPORT_SYMBOL(ocelot_port_add_txtstamp_skb);
int ocelot_port_txtstamp_request(struct ocelot *ocelot, int port,
struct sk_buff *skb,
struct sk_buff **clone)
{
struct ocelot_port *ocelot_port = ocelot->ports[port];
u8 ptp_cmd = ocelot_port->ptp_cmd;
if (ptp_cmd == IFH_REW_OP_TWO_STEP_PTP) {
*clone = skb_clone_sk(skb);
if (!(*clone))
return -ENOMEM;
ocelot_port_add_txtstamp_skb(ocelot, port, *clone);
}
return 0;
}
EXPORT_SYMBOL(ocelot_port_txtstamp_request);
static void ocelot_get_hwtimestamp(struct ocelot *ocelot, static void ocelot_get_hwtimestamp(struct ocelot *ocelot,
struct timespec64 *ts) struct timespec64 *ts)
......
...@@ -507,19 +507,15 @@ static netdev_tx_t ocelot_port_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -507,19 +507,15 @@ static netdev_tx_t ocelot_port_xmit(struct sk_buff *skb, struct net_device *dev)
/* Check if timestamping is needed */ /* Check if timestamping is needed */
if (ocelot->ptp && (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)) { if (ocelot->ptp && (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)) {
rew_op = ocelot_port->ptp_cmd; struct sk_buff *clone = NULL;
if (ocelot_port->ptp_cmd == IFH_REW_OP_TWO_STEP_PTP) { if (ocelot_port_txtstamp_request(ocelot, port, skb, &clone)) {
struct sk_buff *clone; kfree_skb(skb);
return NETDEV_TX_OK;
clone = skb_clone_sk(skb); }
if (!clone) {
kfree_skb(skb);
return NETDEV_TX_OK;
}
ocelot_port_add_txtstamp_skb(ocelot, port, clone);
if (ocelot_port->ptp_cmd == IFH_REW_OP_TWO_STEP_PTP) {
rew_op = ocelot_port->ptp_cmd;
rew_op |= OCELOT_SKB_CB(clone)->ts_id << 3; rew_op |= OCELOT_SKB_CB(clone)->ts_id << 3;
} }
} }
......
...@@ -828,8 +828,9 @@ int ocelot_vlan_add(struct ocelot *ocelot, int port, u16 vid, bool pvid, ...@@ -828,8 +828,9 @@ int ocelot_vlan_add(struct ocelot *ocelot, int port, u16 vid, bool pvid,
int ocelot_vlan_del(struct ocelot *ocelot, int port, u16 vid); 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_get(struct ocelot *ocelot, int port, struct ifreq *ifr);
int ocelot_hwstamp_set(struct ocelot *ocelot, int port, struct ifreq *ifr); int ocelot_hwstamp_set(struct ocelot *ocelot, int port, struct ifreq *ifr);
void ocelot_port_add_txtstamp_skb(struct ocelot *ocelot, int port, int ocelot_port_txtstamp_request(struct ocelot *ocelot, int port,
struct sk_buff *clone); struct sk_buff *skb,
struct sk_buff **clone);
void ocelot_get_txtstamp(struct ocelot *ocelot); void ocelot_get_txtstamp(struct ocelot *ocelot);
void ocelot_port_set_maxlen(struct ocelot *ocelot, int port, size_t sdu); void ocelot_port_set_maxlen(struct ocelot *ocelot, int port, size_t sdu);
int ocelot_get_max_mtu(struct ocelot *ocelot, int port); int ocelot_get_max_mtu(struct ocelot *ocelot, int port);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment