lkml.org 
[lkml]   [2020]   [Nov]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH net-next 3/4] dpaa2-eth: use enum ptp_msg_type
Date
Use new return type of ptp_get_msgtype(). Remove usage of magic numbers.

Signed-off-by: Christian Eggers <ceggers@arri.de>
Cc: Ioana Ciornei <ioana.ciornei@nxp.com>
Cc: Ioana Radulescu <ruxandra.radulescu@nxp.com>
Cc: Yangbo Lu <yangbo.lu@nxp.com>
---
drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
index cf9400a9886d..7e6084124f8f 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
@@ -617,7 +617,7 @@ static int dpaa2_eth_consume_frames(struct dpaa2_eth_channel *ch,
}

static int dpaa2_eth_ptp_parse(struct sk_buff *skb,
- u8 *msgtype, u8 *twostep, u8 *udp,
+ enum ptp_msg_type *msgtype, u8 *twostep, u8 *udp,
u16 *correction_offset,
u16 *origintimestamp_offset)
{
@@ -659,7 +659,7 @@ static void dpaa2_eth_enable_tx_tstamp(struct dpaa2_eth_priv *priv,
{
struct ptp_tstamp origin_timestamp;
struct dpni_single_step_cfg cfg;
- u8 msgtype, twostep, udp;
+ u8 twostep, udp;
struct dpaa2_faead *faead;
struct dpaa2_fas *fas;
struct timespec64 ts;
@@ -684,9 +684,11 @@ static void dpaa2_eth_enable_tx_tstamp(struct dpaa2_eth_priv *priv,
faead->ctrl = cpu_to_le32(ctrl);

if (skb->cb[0] == TX_TSTAMP_ONESTEP_SYNC) {
+ enum ptp_msg_type msgtype;
+
if (dpaa2_eth_ptp_parse(skb, &msgtype, &twostep, &udp,
&offset1, &offset2) ||
- msgtype != 0 || twostep) {
+ msgtype != PTP_MSGTYPE_SYNC || twostep) {
WARN_ONCE(1, "Bad packet for one-step timestamping\n");
return;
}
@@ -1195,7 +1197,7 @@ static void dpaa2_eth_tx_onestep_tstamp(struct work_struct *work)
static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, struct net_device *net_dev)
{
struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
- u8 msgtype, twostep, udp;
+ u8 twostep, udp;
u16 offset1, offset2;

/* Utilize skb->cb[0] for timestamping request per skb */
@@ -1210,9 +1212,11 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, struct net_device *net_dev)

/* TX for one-step timestamping PTP Sync packet */
if (skb->cb[0] == TX_TSTAMP_ONESTEP_SYNC) {
+ enum ptp_msg_type msgtype;
+
if (!dpaa2_eth_ptp_parse(skb, &msgtype, &twostep, &udp,
&offset1, &offset2))
- if (msgtype == 0 && twostep == 0) {
+ if (msgtype == PTP_MSGTYPE_SYNC && twostep == 0) {
skb_queue_tail(&priv->tx_skbs, skb);
queue_work(priv->dpaa2_ptp_wq,
&priv->tx_onestep_tstamp);
--
Christian Eggers
Embedded software developer
Arnold & Richter Cine Technik GmbH & Co. Betriebs KG
Sitz: Muenchen - Registergericht: Amtsgericht Muenchen - Handelsregisternummer: HRA 57918
Persoenlich haftender Gesellschafter: Arnold & Richter Cine Technik GmbH
Sitz: Muenchen - Registergericht: Amtsgericht Muenchen - Handelsregisternummer: HRB 54477
Geschaeftsfuehrer: Dr. Michael Neuhaeuser; Stephan Schenk; Walter Trauninger; Markus Zeiler

\
 
 \ /
  Last update: 2020-11-17 20:35    [W:0.166 / U:0.276 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site