• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) Huawei Technologies Co., Ltd. 2013-2015. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  * 3. The name of the author may not be used to endorse or promote
13  *    products derived from this software without specific prior
14  *    written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
17  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
22  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  * Description: This file provides information for ethtool. reference to linux kernel :include/uapi/linux/ethtool.h
29  * Author: none
30  * Create: 2013
31  */
32 
33 #ifndef __ETHTOOL_H
34 #define __ETHTOOL_H
35 
36 #include "lwip/opt.h"
37 
38 #if LWIP_NETIF_ETHTOOL /* don't build if not configured for use in lwipopts.h */
39 #include "lwip/netif.h"
40 #include "lwip/sockets.h"
41 #include "arch/cc.h"
42 #include "netif/ifaddrs.h"
43 #if LWIP_LITEOS_COMPAT && !LWIP_LINUX_COMPAT
44 #include <liteos/ethtool.h>
45 #endif
46 
47 #if LWIP_LITEOS_COMPAT && LWIP_LINUX_COMPAT
48 #include <linux/ethtool.h>
49 #endif
50 
51 #if defined (__cplusplus) && __cplusplus
52 extern "C" {
53 #endif
54 
55 #if !LWIP_LITEOS_COMPAT
56 #define ETHTOOL_GSET    0x00000001
57 #define ETHTOOL_SSET    0x00000002
58 #define ETHTOOL_GLINK   0x0000000a
59 
60 /** @brief This struct is to pass data for link control and status */
61 struct ethtool_cmd {
62   u32_t cmd;               /**< Command number = %ETHTOOL_GSET or %ETHTOOL_SSET */
63   u32_t supported;         /**< Bitmask of %SUPPORTED_* flags for the link modes, physical connectors and other link
64   features for which the interface supports autonegotiation or auto-detection. Read-only. */
65   u32_t advertising;       /**< Bitmask of %ADVERTISED_* flags for the link modes, physical connectors and other link
66   features that are advertised through autonegotiation or enabled for auto-detection. */
67   u16_t speed;             /**< Low bits of the speed, 1Mb units, 0 to INT_MAX or SPEED_UNKNOWN */
68   u8_t duplex;             /**< Duplex mode; one of %DUPLEX_* */
69   u8_t port;               /**< Physical connector type; one of %PORT_* */
70   u8_t phy_address;        /**< MDIO address of PHY (transceiver); 0 or 255 if not applicable. */
71   u8_t transceiver;        /**< Historically used to distinguish different possible PHY types, but not in a consistent
72   way.  Deprecated. */
73   u8_t autoneg;            /**< Enable/disable autonegotiation and auto-detection; either %AUTONEG_DISABLE or
74   %AUTONEG_ENABLE */
75   u8_t mdio_support;       /**< Bitmask of %ETH_MDIO_SUPPORTS_* flags for the MDIO protocols supported by the interface;
76   0 if unknown. Read-only. */
77   u32_t maxtxpkt;          /**< Historically used to report TX IRQ coalescing; Read-only; deprecated. */
78   u32_t maxrxpkt;          /**< Historically used to report RX IRQ coalescing; Read-only; deprecated. */
79   u16_t speed_hi;          /**< High bits of the speed, 1Mb units, 0 to INT_MAX or SPEED_UNKNOWN */
80   u8_t eth_tp_mdix;        /**< Ethernet twisted-pair MDI(-X) status; one of %ETH_TP_MDI_*. If the status is unknown or
81   not applicable, the value will be %ETH_TP_MDI_INVALID. Read-only. */
82   u8_t eth_tp_mdix_ctrl;   /**< Ethernet twisted pair MDI(-X) control; one of %ETH_TP_MDI_*.  If MDI(-X) control is not
83   implemented, reads yield %ETH_TP_MDI_INVALID and writes may be ignored or rejected. When written successfully, the
84   link should be renegotiated if necessary. */
85   u32_t lp_advertising;    /**< Bitmask of %ADVERTISED_* flags for the link modes and other link features that the link
86   partner advertised through autonegotiation; 0 if unknown or not applicable. Read-only. */
87   u32_t reserved[2];
88 };
89 
90 /** @brief This structure is for passing single values. */
91 struct ethtool_value {
92   u32_t cmd; /**< Indicates command. */
93   u32_t data; /**< Indicates data. */
94 };
95 #endif
96 
97 /**
98  * @brief  Provides optional netdev operations.
99  *
100  * All operations are optional (that is, the function pointer may be set
101  * to %NULL) and callers must take this into account.  Callers must
102  * hold the RTNL lock.
103  *
104  * See the structures used by these operations for further documentation.
105  *
106  * See &struct net_device and &struct net_device_ops for documentation
107  * of the generic netdev features interface.
108  */
109 struct ethtool_ops {
110   /**
111    * < Reports whether physical link is up. Will only be called if the netdev is up.
112    * Should usually be set to ethtool_op_get_link(), which usesnetif_carrier_ok().
113    */
114   s32_t (*get_link)(struct netif *netif);
115   s32_t (*get_settings)(struct netif *netif, struct ethtool_cmd *cmd); /**< Gets the current settings */
116   s32_t (*set_settings)(struct netif *netif, struct ethtool_cmd *cmd); /**< Configures settings */
117   /**< Function to be called before any other operation.  Returns a  negative error code or zero. */
118   int (*begin)(struct netif *netif);
119   /**
120    * < Function to be called after any other operation except @begin.
121    * Will be called even if the other operation failed.
122    */
123   void (*complete)(struct netif *netif);
124 };
125 
126 s32_t dev_ethtool(struct netif *netif, struct ifreq *ifr);
127 /* [VPPTECH-449] TCP_INFO support */
128 #if defined (__cplusplus) && __cplusplus
129 }
130 #endif
131 
132 #endif /* LWIP_NETIF_ETHTOOL */
133 
134 #endif /* __ETHTOOL_H */
135 
136