| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * PTP 1588 clock support - support for timestamping in PHY devices |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2010 OMICRON electronics GmbH |
|---|
| 5 | | - * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 7 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 8 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 9 | | - * (at your option) any later version. |
|---|
| 10 | | - * |
|---|
| 11 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 12 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 | | - * GNU General Public License for more details. |
|---|
| 15 | | - * |
|---|
| 16 | | - * You should have received a copy of the GNU General Public License |
|---|
| 17 | | - * along with this program; if not, write to the Free Software |
|---|
| 18 | | - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|---|
| 19 | 6 | */ |
|---|
| 20 | 7 | #include <linux/errqueue.h> |
|---|
| 21 | 8 | #include <linux/phy.h> |
|---|
| .. | .. |
|---|
| 26 | 13 | static unsigned int classify(const struct sk_buff *skb) |
|---|
| 27 | 14 | { |
|---|
| 28 | 15 | if (likely(skb->dev && skb->dev->phydev && |
|---|
| 29 | | - skb->dev->phydev->drv)) |
|---|
| 16 | + skb->dev->phydev->mii_ts)) |
|---|
| 30 | 17 | return ptp_classify_raw(skb); |
|---|
| 31 | 18 | else |
|---|
| 32 | 19 | return PTP_CLASS_NONE; |
|---|
| .. | .. |
|---|
| 34 | 21 | |
|---|
| 35 | 22 | void skb_clone_tx_timestamp(struct sk_buff *skb) |
|---|
| 36 | 23 | { |
|---|
| 37 | | - struct phy_device *phydev; |
|---|
| 24 | + struct mii_timestamper *mii_ts; |
|---|
| 38 | 25 | struct sk_buff *clone; |
|---|
| 39 | 26 | unsigned int type; |
|---|
| 40 | 27 | |
|---|
| .. | .. |
|---|
| 45 | 32 | if (type == PTP_CLASS_NONE) |
|---|
| 46 | 33 | return; |
|---|
| 47 | 34 | |
|---|
| 48 | | - phydev = skb->dev->phydev; |
|---|
| 49 | | - if (likely(phydev->drv->txtstamp)) { |
|---|
| 35 | + mii_ts = skb->dev->phydev->mii_ts; |
|---|
| 36 | + if (likely(mii_ts->txtstamp)) { |
|---|
| 50 | 37 | clone = skb_clone_sk(skb); |
|---|
| 51 | 38 | if (!clone) |
|---|
| 52 | 39 | return; |
|---|
| 53 | | - phydev->drv->txtstamp(phydev, clone, type); |
|---|
| 40 | + mii_ts->txtstamp(mii_ts, clone, type); |
|---|
| 54 | 41 | } |
|---|
| 55 | 42 | } |
|---|
| 56 | 43 | EXPORT_SYMBOL_GPL(skb_clone_tx_timestamp); |
|---|
| 57 | 44 | |
|---|
| 58 | 45 | bool skb_defer_rx_timestamp(struct sk_buff *skb) |
|---|
| 59 | 46 | { |
|---|
| 60 | | - struct phy_device *phydev; |
|---|
| 47 | + struct mii_timestamper *mii_ts; |
|---|
| 61 | 48 | unsigned int type; |
|---|
| 62 | 49 | |
|---|
| 63 | | - if (!skb->dev || !skb->dev->phydev || !skb->dev->phydev->drv) |
|---|
| 50 | + if (!skb->dev || !skb->dev->phydev || !skb->dev->phydev->mii_ts) |
|---|
| 64 | 51 | return false; |
|---|
| 65 | 52 | |
|---|
| 66 | 53 | if (skb_headroom(skb) < ETH_HLEN) |
|---|
| .. | .. |
|---|
| 75 | 62 | if (type == PTP_CLASS_NONE) |
|---|
| 76 | 63 | return false; |
|---|
| 77 | 64 | |
|---|
| 78 | | - phydev = skb->dev->phydev; |
|---|
| 79 | | - if (likely(phydev->drv->rxtstamp)) |
|---|
| 80 | | - return phydev->drv->rxtstamp(phydev, skb, type); |
|---|
| 65 | + mii_ts = skb->dev->phydev->mii_ts; |
|---|
| 66 | + if (likely(mii_ts->rxtstamp)) |
|---|
| 67 | + return mii_ts->rxtstamp(mii_ts, skb, type); |
|---|
| 81 | 68 | |
|---|
| 82 | 69 | return false; |
|---|
| 83 | 70 | } |
|---|