Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Yangbo Lu <yangbo.lu@nxp.com>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Acked-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Yangbo Lu and committed by
David S. Miller
682eaad9 d150946e

+38 -24
+7 -8
drivers/net/dsa/ocelot/felix.c
··· 1399 1399 struct sk_buff *skb) 1400 1400 { 1401 1401 struct ocelot *ocelot = ds->priv; 1402 - struct ocelot_port *ocelot_port = ocelot->ports[port]; 1403 - struct sk_buff *clone; 1402 + struct sk_buff *clone = NULL; 1404 1403 1405 - if (ocelot->ptp && ocelot_port->ptp_cmd == IFH_REW_OP_TWO_STEP_PTP) { 1406 - clone = skb_clone_sk(skb); 1407 - if (!clone) 1408 - return; 1404 + if (!ocelot->ptp) 1405 + return; 1409 1406 1410 - ocelot_port_add_txtstamp_skb(ocelot, port, clone); 1407 + if (ocelot_port_txtstamp_request(ocelot, port, skb, &clone)) 1408 + return; 1409 + 1410 + if (clone) 1411 1411 OCELOT_SKB_CB(skb)->clone = clone; 1412 - } 1413 1412 } 1414 1413 1415 1414 static int felix_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
+21 -3
drivers/net/ethernet/mscc/ocelot.c
··· 530 530 } 531 531 EXPORT_SYMBOL(ocelot_port_disable); 532 532 533 - void ocelot_port_add_txtstamp_skb(struct ocelot *ocelot, int port, 534 - struct sk_buff *clone) 533 + static void ocelot_port_add_txtstamp_skb(struct ocelot *ocelot, int port, 534 + struct sk_buff *clone) 535 535 { 536 536 struct ocelot_port *ocelot_port = ocelot->ports[port]; 537 537 ··· 545 545 546 546 spin_unlock(&ocelot_port->ts_id_lock); 547 547 } 548 - EXPORT_SYMBOL(ocelot_port_add_txtstamp_skb); 548 + 549 + int ocelot_port_txtstamp_request(struct ocelot *ocelot, int port, 550 + struct sk_buff *skb, 551 + struct sk_buff **clone) 552 + { 553 + struct ocelot_port *ocelot_port = ocelot->ports[port]; 554 + u8 ptp_cmd = ocelot_port->ptp_cmd; 555 + 556 + if (ptp_cmd == IFH_REW_OP_TWO_STEP_PTP) { 557 + *clone = skb_clone_sk(skb); 558 + if (!(*clone)) 559 + return -ENOMEM; 560 + 561 + ocelot_port_add_txtstamp_skb(ocelot, port, *clone); 562 + } 563 + 564 + return 0; 565 + } 566 + EXPORT_SYMBOL(ocelot_port_txtstamp_request); 549 567 550 568 static void ocelot_get_hwtimestamp(struct ocelot *ocelot, 551 569 struct timespec64 *ts)
+7 -11
drivers/net/ethernet/mscc/ocelot_net.c
··· 507 507 508 508 /* Check if timestamping is needed */ 509 509 if (ocelot->ptp && (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)) { 510 - rew_op = ocelot_port->ptp_cmd; 510 + struct sk_buff *clone = NULL; 511 + 512 + if (ocelot_port_txtstamp_request(ocelot, port, skb, &clone)) { 513 + kfree_skb(skb); 514 + return NETDEV_TX_OK; 515 + } 511 516 512 517 if (ocelot_port->ptp_cmd == IFH_REW_OP_TWO_STEP_PTP) { 513 - struct sk_buff *clone; 514 - 515 - clone = skb_clone_sk(skb); 516 - if (!clone) { 517 - kfree_skb(skb); 518 - return NETDEV_TX_OK; 519 - } 520 - 521 - ocelot_port_add_txtstamp_skb(ocelot, port, clone); 522 - 518 + rew_op = ocelot_port->ptp_cmd; 523 519 rew_op |= OCELOT_SKB_CB(clone)->ts_id << 3; 524 520 } 525 521 }
+3 -2
include/soc/mscc/ocelot.h
··· 828 828 int ocelot_vlan_del(struct ocelot *ocelot, int port, u16 vid); 829 829 int ocelot_hwstamp_get(struct ocelot *ocelot, int port, struct ifreq *ifr); 830 830 int ocelot_hwstamp_set(struct ocelot *ocelot, int port, struct ifreq *ifr); 831 - void ocelot_port_add_txtstamp_skb(struct ocelot *ocelot, int port, 832 - struct sk_buff *clone); 831 + int ocelot_port_txtstamp_request(struct ocelot *ocelot, int port, 832 + struct sk_buff *skb, 833 + struct sk_buff **clone); 833 834 void ocelot_get_txtstamp(struct ocelot *ocelot); 834 835 void ocelot_port_set_maxlen(struct ocelot *ocelot, int port, size_t sdu); 835 836 int ocelot_get_max_mtu(struct ocelot *ocelot, int port);