linux/net/core/timestamping.c
<<
18.3.9"/spa"v3 .9"/formv3 .9"a 18.3.9 href="../linux+v3 1/net/core/timestamping.c">18.3.9"img src="../.static/gfx/right.png" alt=">>">18"/spa"v318"spa" class="lxr_search">18.318.3.9"input typ14.hidden" nam14.navtarget" v3.14.">18.3.9"input typ14.text" nam14.search" id4.search">18.3.9"butt> typ14.submit">Search v3 .9"/formv3 "/spa"v318"spa" class="lxr_prefs"v3 .9"a href="+prefs?return=net/core/timestamping.c"18.3.9 onclick="return ajax_prefs();">18.3.9Prefs3 .9"/a>18"/spa"v3.3.9 9"/divv3.3.9 9"form acue="="ajax+*" method="post" onsubmit="return false;">18"input typ14.hidden" nam14.ajax_lookup" id4.ajax_lookup" v3.14.">1.3.9 9"/formv31.3.9 9"div class="headingbott>m">3 "div id4.file_contents"v
9 91"/a>"spa" class="comment">/*"/spa"v39 92"/a>"spa" class="comment"> * PTP 1588 clock support - support for timestamping in PHY devices"/spa"v39 93"/a>"spa" class="comment"> *"/spa"v39 94"/a>"spa" class="comment"> * Copyright (C) 2010 OMICRON electronics GmbH"/spa"v39 95"/a>"spa" class="comment"> *"/spa"v39 96"/a>"spa" class="comment"> *  This program is free software; you ca" redistribute it and/or modify"/spa"v39 97"/a>"spa" class="comment"> *  it under the terms of the GNU General Public License as published by"/spa"v39 98"/a>"spa" class="comment"> *  the Free Software Foundaue="; either vers >
 2 of the License, or"/spa"v39 99"/a>"spa" class="comment"> *  (at your alue=") any later vers >
."/spa"v39 "spa" class="comment"> *"/spa"v39 11"/a>"spa" class="comment"> *  This program is distributed in the hope that it will be useful,"/spa"v39 12"/a>"spa" class="comment"> *  but WITHOUT ANY WARRANTY; without even the implied warranty of"/spa"v39 13"/a>"spa" class="comment"> *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the"/spa"v39 14"/a>"spa" class="comment"> *  GNU General Public License for more details."/spa"v39 15"/a>"spa" class="comment"> *"/spa"v39 16"/a>"spa" class="comment"> *  You should have received a copy of the GNU General Public License"/spa"v39 17"/a>"spa" class="comment"> *  along with this program; if not, write to the Free Software"/spa"v39 18"/a>"spa" class="comment"> *  Foundaue=", Inc., 675 Mass Ave, Cambridge, MA 02139, USA."/spa"v39 19"/a>"spa" class="comment"> */"/spa"v39 2opta>#include <linux/errqueue.hpta>>39 21pta>#include <linux/phy.hpta>>39 22pta>#include <linux/ptp_classify.hpta>>39 23pta>#include <linux/skbuff.hpta>>39 24pta>#include <linux/export.hpta>>39 25"/a>39 26"/a>static struct9"a href="+code=sock_filter" class="sref">sock_filter"/a>9"a href="+code=ptp_filter" class="sref">ptp_filter"/a>[] = {39 27"/a>        "a href="+code=PTP_FILTER" class="sref">PTP_FILTER"/a>39 28"/a>};39 29"/a>39 30"/a>static unsigned int9"a href="+code=classify" class="sref">classify"/a>(const struct9"a href="+code=sk_buff" class="sref">sk_buff"/a> *"a href="+code=skb" class="sref">skb"/a>)39 31pta>{39 32"/a>        if ("a href="+code=likely" class="sref">likely"/a>("a href="+code=skb" class="sref">skb"/a>->"a href="+code=dev" class="sref">dev"/a> &&39 33"/a>                   "a href="+code=skb" class="sref">skb"/a>->"a href="+code=dev" class="sref">dev"/a>->"a href="+code=phydev" class="sref">phydev"/a> &&39 34"/a>                   "a href="+code=skb" class="sref">skb"/a>->"a href="+code=dev" class="sref">dev"/a>->"a href="+code=phydev" class="sref">phydev"/a>->"a href="+code=drv" class="sref">drv"/a>))39 35"/a>                return "a href="+code=sk_run_filter" class="sref">sk_run_filter"/a>("a href="+code=skb" class="sref">skb"/a>,9"a href="+code=ptp_filter" class="sref">ptp_filter"/a>);39 36"/a>        else39 37"/a>                return "a href="+code=PTP_CLASS_NONE" class="sref">PTP_CLASS_NONE"/a>;39 38"/a>}39 39"/a>39 40"/a>void "a href="+code=skb_clone_tx_timestamp" class="sref">skb_clone_tx_timestamp"/a>(struct9"a href="+code=sk_buff" class="sref">sk_buff"/a> *"a href="+code=skb" class="sref">skb"/a>)39 41pta>{39 42"/a>        struct9"a href="+code=phy_device" class="sref">phy_device"/a> *"a href="+code=phydev" class="sref">phydev"/a>;39 43"/a>        struct9"a href="+code=sk_buff" class="sref">sk_buff"/a> *"a href="+code=clone" class="sref">clone"/a>;39 44"/a>        struct9"a href="+code=sock" class="sref">sock"/a> *"a href="+code=sk" class="sref">sk"/a> = "a href="+code=skb" class="sref">skb"/a>->"a href="+code=sk" class="sref">sk"/a>;39 45"/a>        unsigned int9"a href="+code=typ1" class="sref">typ1"/a>;39 46"/a>39 47"/a>        if (!"a href="+code=sk" class="sref">sk"/a>)39 48"/a>                return;39 49"/a>39 50"/a>        "a href="+code=typ1" class="sref">typ1"/a> = "a href="+code=classify" class="sref">classify"/a>("a href="+code=skb" class="sref">skb"/a>);39 51"/a>39 52"/a>        switch ("a href="+code=typ1" class="sref">typ1"/a>) {39 53"/a>        case "a href="+code=PTP_CLASS_V1_IPV4" class="sref">PTP_CLASS_V1_IPV4"/a>:39 54"/a>        case "a href="+code=PTP_CLASS_V1_IPV6" class="sref">PTP_CLASS_V1_IPV6"/a>:39 55"/a>        case "a href="+code=PTP_CLASS_V2_IPV4" class="sref">PTP_CLASS_V2_IPV4"/a>:39 56"/a>        case "a href="+code=PTP_CLASS_V2_IPV6" class="sref">PTP_CLASS_V2_IPV6"/a>:39 57"/a>        case "a href="+code=PTP_CLASS_V2_L2" class="sref">PTP_CLASS_V2_L2"/a>:39 58"/a>        case "a href="+code=PTP_CLASS_V2_VLAN" class="sref">PTP_CLASS_V2_VLAN"/a>:39 59"/a>                "a href="+code=phydev" class="sref">phydev"/a> = "a href="+code=skb" class="sref">skb"/a>->"a href="+code=dev" class="sref">dev"/a>->"a href="+code=phydev" class="sref">phydev"/a>;39 60"/a>                if ("a href="+code=likely" class="sref">likely"/a>("a href="+code=phydev" class="sref">phydev"/a>->"a href="+code=drv" class="sref">drv"/a>->"a href="+code=txtstamp" class="sref">txtstamp"/a>)) {39 61"/a>                        if (!"a href="+code=atomic_inc_not_zero" class="sref">atomic_inc_not_zero"/a>(&"a href="+code=sk" class="sref">sk"/a>->"a href="+code=sk_refcnt" class="sref">sk_refcnt"/a>))39 62"/a>                                return;39 63"/a>                        "a href="+code=clone" class="sref">clone"/a> = "a href="+code=skb_clone" class="sref">skb_clone"/a>("a href="+code=skb" class="sref">skb"/a>,9"a href="+code=GFP_ATOMIC" class="sref">GFP_ATOMIC"/a>);39 64"/a>                        if (!"a href="+code=clone" class="sref">clone"/a>) {39 65"/a>                                "a href="+code=sock_put" class="sref">sock_put"/a>("a href="+code=sk" class="sref">sk"/a>);39 66"/a>                                return;39 67"/a>                        }39 68"/a>                        "a href="+code=clone" class="sref">clone"/a>->"a href="+code=sk" class="sref">sk"/a> = "a href="+code=sk" class="sref">sk"/a>;39 69"/a>                        "a href="+code=phydev" class="sref">phydev"/a>->"a href="+code=drv" class="sref">drv"/a>->"a href="+code=txtstamp" class="sref">txtstamp"/a>("a href="+code=phydev" class="sref">phydev"/a>,9"a href="+code=clone" class="sref">clone"/a>,9"a href="+code=typ1" class="sref">typ1"/a>);39 70"/a>                }39 71"/a>                break;39 72"/a>        default:39 73"/a>                break;39 74"/a>        }39 75"/a>}39 76"/a>"a href="+code=EXPORT_SYMBOL_GPL" class="sref">EXPORT_SYMBOL_GPL"/a>("a href="+code=skb_clone_tx_timestamp" class="sref">skb_clone_tx_timestamp"/a>);39 77"/a>39 78"/a>void "a href="+code=skb_complete_tx_timestamp" class="sref">skb_complete_tx_timestamp"/a>(struct9"a href="+code=sk_buff" class="sref">sk_buff"/a> *"a href="+code=skb" class="sref">skb"/a>,39 79"/a>                               struct9"a href="+code=skb_shared_hwtstamps" class="sref">skb_shared_hwtstamps"/a> *"a href="+code=hwtstamps" class="sref">hwtstamps"/a>)39 80pta>{39 81"/a>        struct9"a href="+code=sock" class="sref">sock"/a> *"a href="+code=sk" class="sref">sk"/a> = "a href="+code=skb" class="sref">skb"/a>->"a href="+code=sk" class="sref">sk"/a>;39 82"/a>        struct9"a href="+code=sock_exterr_skb" class="sref">sock_exterr_skb"/a> *"a href="+code=serr" class="sref">serr"/a>;39 83"/a>        int9"a href="+code=err" class="sref">err"/a>;39 84"/a>39 85"/a>        if (!"a href="+code=hwtstamps" class="sref">hwtstamps"/a>) {39 86"/a>                "a href="+code=sock_put" class="sref">sock_put"/a>("a href="+code=sk" class="sref">sk"/a>);39 87"/a>                "a href="+code=kfree_skb" class="sref">kfree_skb"/a>("a href="+code=skb" class="sref">skb"/a>);39 88"/a>                return;39 89"/a>        }39 90"/a>39 91"/a>        *"a href="+code=skb_hwtstamps" class="sref">skb_hwtstamps"/a>("a href="+code=skb" class="sref">skb"/a>) = *"a href="+code=hwtstamps" class="sref">hwtstamps"/a>;39 92"/a>        "a href="+code=serr" class="sref">serr"/a> = "a href="+code=SKB_EXT_ERR" class="sref">SKB_EXT_ERR"/a>("a href="+code=skb" class="sref">skb"/a>);39 93"/a>        "a href="+code=memset" class="sref">memset"/a>("a href="+code=serr" class="sref">serr"/a>, 0, sizeof(*"a href="+code=serr" class="sref">serr"/a>));39 94"/a>        "a href="+code=serr" class="sref">serr"/a>->"a href="+code=e1" class="sref">e1"/a>."a href="+code=e1_errno" class="sref">e1_errno"/a> = "a href="+code=ENOMSG" class="sref">ENOMSG"/a>;39 95"/a>        "a href="+code=serr" class="sref">serr"/a>->"a href="+code=e1" class="sref">e1"/a>."a href="+code=e1_origin" class="sref">e1_origin"/a> = "a href="+code=SO_EE_ORIGIN_TIMESTAMPING" class="sref">SO_EE_ORIGIN_TIMESTAMPING"/a>;39 96"/a>        "a href="+code=skb" class="sref">skb"/a>->"a href="+code=sk" class="sref">sk"/a> = "a href="+code=NULL" class="sref">NULL"/a>;39 97"/a>        "a href="+code=err" class="sref">err"/a> = "a href="+code=sock_queue_err_skb" class="sref">sock_queue_err_skb"/a>("a href="+code=sk" class="sref">sk"/a>,9"a href="+code=skb" class="sref">skb"/a>);39 98"/a>        "a href="+code=sock_put" class="sref">sock_put"/a>("a href="+code=sk" class="sref">sk"/a>);39 99"/a>        if ("a href="+code=err" class="sref">err"/a>)39100"/a>                "a href="+code=kfree_skb" class="sref">kfree_skb"/a>("a href="+code=skb" class="sref">skb"/a>);39101"/a>}39102"/a>"a href="+code=EXPORT_SYMBOL_GPL" class="sref">EXPORT_SYMBOL_GPL"/a>("a href="+code=skb_complete_tx_timestamp" class="sref">skb_complete_tx_timestamp"/a>);39103"/a>39104"/a>"a href="+code=bool" class="sref">bool"/a> "a href="+code=skb_defer_rx_timestamp" class="sref">skb_defer_rx_timestamp"/a>(struct9"a href="+code=sk_buff" class="sref">sk_buff"/a> *"a href="+code=skb" class="sref">skb"/a>)39105pta>{39106"/a>        struct9"a href="+code=phy_device" class="sref">phy_device"/a> *"a href="+code=phydev" class="sref">phydev"/a>;39107"/a>        unsigned int9"a href="+code=typ1" class="sref">typ1"/a>;39108"/a>39109"/a>        if ("a href="+code=skb_headroom" class="sref">skb_headroom"/a>("a href="+code=skb" class="sref">skb"/a>) < "a href="+code=ETH_HLEN" class="sref">ETH_HLEN"/a>)39110"/a>                return "a href="+code=false" class="sref">false"/a>;39111"/a>        "a href="+code=__skb_push" class="sref">__skb_push"/a>("a href="+code=skb" class="sref">skb"/a>,9"a href="+code=ETH_HLEN" class="sref">ETH_HLEN"/a>);39112"/a>39113"/a>        "a href="+code=typ1" class="sref">typ1"/a> = "a href="+code=classify" class="sref">classify"/a>("a href="+code=skb" class="sref">skb"/a>);39114"/a>39115"/a>        "a href="+code=__skb_pull" class="sref">__skb_pull"/a>("a href="+code=skb" class="sref">skb"/a>,9"a href="+code=ETH_HLEN" class="sref">ETH_HLEN"/a>);39116"/a>39117"/a>        switch ("a href="+code=typ1" class="sref">typ1"/a>) {39118"/a>        case "a href="+code=PTP_CLASS_V1_IPV4" class="sref">PTP_CLASS_V1_IPV4"/a>:39119"/a>        case "a href="+code=PTP_CLASS_V1_IPV6" class="sref">PTP_CLASS_V1_IPV6"/a>:39120"/a>        case "a href="+code=PTP_CLASS_V2_IPV4" class="sref">PTP_CLASS_V2_IPV4"/a>:39121"/a>        case "a href="+code=PTP_CLASS_V2_IPV6" class="sref">PTP_CLASS_V2_IPV6"/a>:39122"/a>        case "a href="+code=PTP_CLASS_V2_L2" class="sref">PTP_CLASS_V2_L2"/a>:39123"/a>        case "a href="+code=PTP_CLASS_V2_VLAN" class="sref">PTP_CLASS_V2_VLAN"/a>:39124"/a>                "a href="+code=phydev" class="sref">phydev"/a> = "a href="+code=skb" class="sref">skb"/a>->"a href="+code=dev" class="sref">dev"/a>->"a href="+code=phydev" class="sref">phydev"/a>;39125"/a>                if ("a href="+code=likely" class="sref">likely"/a>("a href="+code=phydev" class="sref">phydev"/a>->"a href="+code=drv" class="sref">drv"/a>->"a href="+code=rxtstamp" class="sref">rxtstamp"/a>))39126"/a>                        return "a href="+code=phydev" class="sref">phydev"/a>->"a href="+code=drv" class="sref">drv"/a>->"a href="+code=rxtstamp" class="sref">rxtstamp"/a>("a href="+code=phydev" class="sref">phydev"/a>,9"a href="+code=skb" class="sref">skb"/a>,9"a href="+code=typ1" class="sref">typ1"/a>);39127"/a>                break;39128"/a>        default:39129"/a>                break;39130"/a>        }39131"/a>39132"/a>        return "a href="+code=false" class="sref">false"/a>;39133"/a>}39134"/a>"a href="+code=EXPORT_SYMBOL_GPL" class="sref">EXPORT_SYMBOL_GPL"/a>("a href="+code=skb_defer_rx_timestamp" class="sref">skb_defer_rx_timestamp"/a>);39135"/a>39136"/a>void "a href="+code=__init" class="sref">__init"/a> "a href="+code=skb_timestamping_init" class="sref">skb_timestamping_init"/a>(void)39137"/a>{39138"/a>        "a href="+code=BUG_ON" class="sref">BUG_ON"/a>("a href="+code=sk_chk_filter" class="sref">sk_chk_filter"/a>("a href="+code=ptp_filter" class="sref">ptp_filter"/a>,9"a href="+code=ARRAY_SIZE" class="sref">ARRAY_SIZE"/a>("a href="+code=ptp_filter" class="sref">ptp_filter"/a>)));39139"/a>}39140"/a>
The original LXR software by the LXR community"/a>,9this experimental vers > by lxr@linux.no"/a>. "/divv3"div class="subfooter"> lxr.linux.no kindly hosted by Redpill Linpro AS"/a>,9provider of Linux consulting and operaue="s services since 1995. "/divv3 "/bodyv3"/htmlv3