Last active
July 8, 2019 19:46
-
-
Save Warepire/cd7ec35d1d6c5eaaec0128cf2c50e33f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 5efa8297909ced297d138f0f5b1cc7f40e20546f Mon Sep 17 00:00:00 2001 | |
From: Warepire <[email protected]> | |
Date: Sat, 1 Jun 2019 21:46:20 +0200 | |
Subject: [PATCH] net: usb: smsc95xx: Use driver_priv instead of data[0] | |
General sanity cleanup, it also gets rid of a lot of casts and | |
ensures that the data type is always wide enough to hold the | |
entire pointer. | |
--- | |
drivers/net/usb/smsc95xx.c | 46 ++++++++++++++++++-------------------- | |
1 file changed, 22 insertions(+), 24 deletions(-) | |
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c | |
index 355be77f4241..1c4f8a379526 100644 | |
--- a/drivers/net/usb/smsc95xx.c | |
+++ b/drivers/net/usb/smsc95xx.c | |
@@ -455,7 +455,7 @@ static unsigned int smsc95xx_hash(char addr[ETH_ALEN]) | |
static void smsc95xx_set_multicast(struct net_device *netdev) | |
{ | |
struct usbnet *dev = netdev_priv(netdev); | |
- struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); | |
+ struct smsc95xx_priv *pdata = dev->driver_priv; | |
unsigned long flags; | |
int ret; | |
@@ -550,7 +550,7 @@ static int smsc95xx_phy_update_flowcontrol(struct usbnet *dev, u8 duplex, | |
static int smsc95xx_link_reset(struct usbnet *dev) | |
{ | |
- struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); | |
+ struct smsc95xx_priv *pdata = dev->driver_priv; | |
struct mii_if_info *mii = &dev->mii; | |
struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET }; | |
unsigned long flags; | |
@@ -618,7 +618,7 @@ static void smsc95xx_status(struct usbnet *dev, struct urb *urb) | |
static void set_carrier(struct usbnet *dev, bool link) | |
{ | |
- struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); | |
+ struct smsc95xx_priv *pdata = dev->driver_priv; | |
if (pdata->link_ok == link) | |
return; | |
@@ -747,7 +747,7 @@ static void smsc95xx_ethtool_get_wol(struct net_device *net, | |
struct ethtool_wolinfo *wolinfo) | |
{ | |
struct usbnet *dev = netdev_priv(net); | |
- struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); | |
+ struct smsc95xx_priv *pdata = dev->driver_priv; | |
wolinfo->supported = SUPPORTED_WAKE; | |
wolinfo->wolopts = pdata->wolopts; | |
@@ -757,7 +757,7 @@ static int smsc95xx_ethtool_set_wol(struct net_device *net, | |
struct ethtool_wolinfo *wolinfo) | |
{ | |
struct usbnet *dev = netdev_priv(net); | |
- struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); | |
+ struct smsc95xx_priv *pdata = dev->driver_priv; | |
int ret; | |
if (wolinfo->wolopts & ~SUPPORTED_WAKE) | |
@@ -796,7 +796,7 @@ static int get_mdix_status(struct net_device *net) | |
static void set_mdix_status(struct net_device *net, __u8 mdix_ctrl) | |
{ | |
struct usbnet *dev = netdev_priv(net); | |
- struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); | |
+ struct smsc95xx_priv *pdata = dev->driver_priv; | |
int buf; | |
if ((pdata->chip_id == ID_REV_CHIP_ID_9500A_) || | |
@@ -845,7 +845,7 @@ static int smsc95xx_get_link_ksettings(struct net_device *net, | |
struct ethtool_link_ksettings *cmd) | |
{ | |
struct usbnet *dev = netdev_priv(net); | |
- struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); | |
+ struct smsc95xx_priv *pdata = dev->driver_priv; | |
int retval; | |
retval = usbnet_get_link_ksettings(net, cmd); | |
@@ -860,7 +860,7 @@ static int smsc95xx_set_link_ksettings(struct net_device *net, | |
const struct ethtool_link_ksettings *cmd) | |
{ | |
struct usbnet *dev = netdev_priv(net); | |
- struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); | |
+ struct smsc95xx_priv *pdata = dev->driver_priv; | |
int retval; | |
if (pdata->mdix_ctrl != cmd->base.eth_tp_mdix_ctrl) | |
@@ -942,7 +942,7 @@ static int smsc95xx_set_mac_address(struct usbnet *dev) | |
/* starts the TX path */ | |
static int smsc95xx_start_tx_path(struct usbnet *dev) | |
{ | |
- struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); | |
+ struct smsc95xx_priv *pdata = dev->driver_priv; | |
unsigned long flags; | |
int ret; | |
@@ -962,7 +962,7 @@ static int smsc95xx_start_tx_path(struct usbnet *dev) | |
/* Starts the Receive path */ | |
static int smsc95xx_start_rx_path(struct usbnet *dev, int in_pm) | |
{ | |
- struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); | |
+ struct smsc95xx_priv *pdata = dev->driver_priv; | |
unsigned long flags; | |
spin_lock_irqsave(&pdata->mac_cr_lock, flags); | |
@@ -1019,7 +1019,7 @@ static int smsc95xx_phy_initialize(struct usbnet *dev) | |
static int smsc95xx_reset(struct usbnet *dev) | |
{ | |
- struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); | |
+ struct smsc95xx_priv *pdata = dev->driver_priv; | |
u32 read_buf, write_buf, burst_cap; | |
int ret = 0, timeout; | |
@@ -1259,10 +1259,9 @@ static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf) | |
return ret; | |
} | |
- dev->data[0] = (unsigned long)kzalloc(sizeof(struct smsc95xx_priv), | |
- GFP_KERNEL); | |
+ dev->driver_priv = kzalloc(sizeof(struct smsc95xx_priv), GFP_KERNEL); | |
- pdata = (struct smsc95xx_priv *)(dev->data[0]); | |
+ pdata = dev->driver_priv; | |
if (!pdata) | |
return -ENOMEM; | |
@@ -1321,14 +1320,13 @@ static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf) | |
static void smsc95xx_unbind(struct usbnet *dev, struct usb_interface *intf) | |
{ | |
- struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); | |
+ struct smsc95xx_priv *pdata = dev->driver_priv; | |
if (pdata) { | |
cancel_delayed_work(&pdata->carrier_check); | |
netif_dbg(dev, ifdown, dev->net, "free pdata\n"); | |
kfree(pdata); | |
pdata = NULL; | |
- dev->data[0] = 0; | |
} | |
} | |
@@ -1381,7 +1379,7 @@ static int smsc95xx_link_ok_nopm(struct usbnet *dev) | |
static int smsc95xx_enter_suspend0(struct usbnet *dev) | |
{ | |
- struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); | |
+ struct smsc95xx_priv *pdata = dev->driver_priv; | |
u32 val; | |
int ret; | |
@@ -1420,7 +1418,7 @@ static int smsc95xx_enter_suspend0(struct usbnet *dev) | |
static int smsc95xx_enter_suspend1(struct usbnet *dev) | |
{ | |
- struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); | |
+ struct smsc95xx_priv *pdata = dev->driver_priv; | |
struct mii_if_info *mii = &dev->mii; | |
u32 val; | |
int ret; | |
@@ -1468,7 +1466,7 @@ static int smsc95xx_enter_suspend1(struct usbnet *dev) | |
static int smsc95xx_enter_suspend2(struct usbnet *dev) | |
{ | |
- struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); | |
+ struct smsc95xx_priv *pdata = dev->driver_priv; | |
u32 val; | |
int ret; | |
@@ -1490,7 +1488,7 @@ static int smsc95xx_enter_suspend2(struct usbnet *dev) | |
static int smsc95xx_enter_suspend3(struct usbnet *dev) | |
{ | |
- struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); | |
+ struct smsc95xx_priv *pdata = dev->driver_priv; | |
u32 val; | |
int ret; | |
@@ -1529,7 +1527,7 @@ static int smsc95xx_enter_suspend3(struct usbnet *dev) | |
static int smsc95xx_autosuspend(struct usbnet *dev, u32 link_up) | |
{ | |
- struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); | |
+ struct smsc95xx_priv *pdata = dev->driver_priv; | |
int ret; | |
if (!netif_running(dev->net)) { | |
@@ -1577,7 +1575,7 @@ static int smsc95xx_autosuspend(struct usbnet *dev, u32 link_up) | |
static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message) | |
{ | |
struct usbnet *dev = usb_get_intfdata(intf); | |
- struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); | |
+ struct smsc95xx_priv *pdata = dev->driver_priv; | |
u32 val, link_up; | |
int ret; | |
@@ -1848,7 +1846,7 @@ static int smsc95xx_resume(struct usb_interface *intf) | |
u32 val; | |
BUG_ON(!dev); | |
- pdata = (struct smsc95xx_priv *)(dev->data[0]); | |
+ pdata = dev->driver_priv; | |
suspend_flags = pdata->suspend_flags; | |
netdev_dbg(dev->net, "resume suspend_flags=0x%02x\n", suspend_flags); | |
@@ -2068,7 +2066,7 @@ static struct sk_buff *smsc95xx_tx_fixup(struct usbnet *dev, | |
static int smsc95xx_manage_power(struct usbnet *dev, int on) | |
{ | |
- struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); | |
+ struct smsc95xx_priv *pdata = dev->driver_priv; | |
dev->intf->needs_remote_wakeup = on; | |
-- | |
2.21.0 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 9a3fb55534ed94208058d2311af9a47bb624e900 Mon Sep 17 00:00:00 2001 | |
From: Warepire <[email protected]> | |
Date: Sun, 19 May 2019 20:03:43 +0200 | |
Subject: [PATCH] net: usb: smsc95xx: Convert to use phylib | |
This device has an option to attach an external PHY, | |
the Technica-Engineering USB_100BaseT1 converter uses this with an | |
external T1 PHY. | |
Prepare the driver for supporting this USB device. | |
--- | |
drivers/net/usb/smsc95xx.c | 412 ++++++++++++++++++++++++------------- | |
1 file changed, 266 insertions(+), 146 deletions(-) | |
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c | |
index 1c4f8a379526..daca18402284 100644 | |
--- a/drivers/net/usb/smsc95xx.c | |
+++ b/drivers/net/usb/smsc95xx.c | |
@@ -11,6 +11,8 @@ | |
#include <linux/etherdevice.h> | |
#include <linux/ethtool.h> | |
#include <linux/mii.h> | |
+#include <linux/mdio.h> | |
+#include <linux/phy.h> | |
#include <linux/usb.h> | |
#include <linux/bitrev.h> | |
#include <linux/crc16.h> | |
@@ -32,7 +34,8 @@ | |
#define EEPROM_MAC_OFFSET (0x01) | |
#define DEFAULT_TX_CSUM_ENABLE (true) | |
#define DEFAULT_RX_CSUM_ENABLE (true) | |
-#define SMSC95XX_INTERNAL_PHY_ID (1) | |
+/* The MAC only allows for ID 0x1, both for internal and external */ | |
+#define SMSC95XX_PHY_ID (1) | |
#define SMSC95XX_TX_OVERHEAD (8) | |
#define SMSC95XX_TX_OVERHEAD_CSUM (12) | |
#define SUPPORTED_WAKE (WAKE_PHY | WAKE_UCAST | WAKE_BCAST | \ | |
@@ -64,6 +67,9 @@ struct smsc95xx_priv { | |
bool link_ok; | |
struct delayed_work carrier_check; | |
struct usbnet *dev; | |
+ struct mii_bus *mdio; | |
+ struct phy_device *phydev; | |
+ char phy_name[20]; | |
}; | |
static bool turbo_mode = true; | |
@@ -190,8 +196,8 @@ static int __smsc95xx_mdio_read(struct net_device *netdev, int phy_id, int idx, | |
} | |
/* set the address, index & direction (read from PHY) */ | |
- phy_id &= dev->mii.phy_id_mask; | |
- idx &= dev->mii.reg_num_mask; | |
+// phy_id &= dev->mii.phy_id_mask; | |
+// idx &= dev->mii.reg_num_mask; | |
addr = (phy_id << 11) | (idx << 6) | MII_READ_ | MII_BUSY_; | |
ret = __smsc95xx_write_reg(dev, MII_ADDR, addr, in_pm); | |
if (ret < 0) { | |
@@ -242,8 +248,8 @@ static void __smsc95xx_mdio_write(struct net_device *netdev, int phy_id, | |
} | |
/* set the address, index & direction (write to PHY) */ | |
- phy_id &= dev->mii.phy_id_mask; | |
- idx &= dev->mii.reg_num_mask; | |
+// phy_id &= dev->mii.phy_id_mask; | |
+// idx &= dev->mii.reg_num_mask; | |
addr = (phy_id << 11) | (idx << 6) | MII_WRITE_ | MII_BUSY_; | |
ret = __smsc95xx_write_reg(dev, MII_ADDR, addr, in_pm); | |
if (ret < 0) { | |
@@ -273,15 +279,18 @@ static void smsc95xx_mdio_write_nopm(struct net_device *netdev, int phy_id, | |
__smsc95xx_mdio_write(netdev, phy_id, idx, regval, 1); | |
} | |
-static int smsc95xx_mdio_read(struct net_device *netdev, int phy_id, int idx) | |
+static int smsc95xx_mdio_read(struct mii_bus *bus, int phy_id, int idx) | |
{ | |
+ struct net_device *netdev = ((struct usbnet*)bus->priv)->net; | |
return __smsc95xx_mdio_read(netdev, phy_id, idx, 0); | |
} | |
-static void smsc95xx_mdio_write(struct net_device *netdev, int phy_id, int idx, | |
- int regval) | |
+static int smsc95xx_mdio_write(struct mii_bus *bus, int phy_id, int idx, | |
+ u16 regval) | |
{ | |
+ struct net_device *netdev = ((struct usbnet*)bus->priv)->net; | |
__smsc95xx_mdio_write(netdev, phy_id, idx, regval, 0); | |
+ return 0; | |
} | |
static int __must_check smsc95xx_wait_eeprom(struct usbnet *dev) | |
@@ -511,16 +520,22 @@ static void smsc95xx_set_multicast(struct net_device *netdev) | |
netdev_warn(dev->net, "failed to initiate async write to MAC_CR\n"); | |
} | |
-static int smsc95xx_phy_update_flowcontrol(struct usbnet *dev, u8 duplex, | |
- u16 lcladv, u16 rmtadv) | |
+static int smsc95xx_phy_update_flowcontrol(struct usbnet *dev) | |
{ | |
+ struct smsc95xx_priv *priv = dev->driver_priv; | |
+ struct phy_device *phy = priv->phydev; | |
u32 flow = 0, afc_cfg; | |
int ret = smsc95xx_read_reg(dev, AFC_CFG, &afc_cfg); | |
if (ret < 0) | |
return ret; | |
- if (duplex == DUPLEX_FULL) { | |
+ if (phy->duplex == DUPLEX_FULL) { | |
+ u16 lcladv = linkmode_adv_to_lcl_adv_t(phy->advertising); | |
+ /* for the bits we care about, ADVERTISING and LPA are | |
+ * the same. | |
+ */ | |
+ u16 rmtadv = linkmode_adv_to_lcl_adv_t(phy->lp_advertising); | |
u8 cap = mii_resolve_flowctrl_fdx(lcladv, rmtadv); | |
if (cap & FLOW_CTRL_RX) | |
@@ -548,35 +563,22 @@ static int smsc95xx_phy_update_flowcontrol(struct usbnet *dev, u8 duplex, | |
return smsc95xx_write_reg(dev, AFC_CFG, afc_cfg); | |
} | |
-static int smsc95xx_link_reset(struct usbnet *dev) | |
+static int smsc95xx_adjust_link_internal(struct usbnet* dev) | |
{ | |
struct smsc95xx_priv *pdata = dev->driver_priv; | |
- struct mii_if_info *mii = &dev->mii; | |
- struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET }; | |
+ struct phy_device *phy = pdata->phydev; | |
unsigned long flags; | |
- u16 lcladv, rmtadv; | |
int ret; | |
- /* clear interrupt status */ | |
- ret = smsc95xx_mdio_read(dev->net, mii->phy_id, PHY_INT_SRC); | |
- if (ret < 0) | |
- return ret; | |
- | |
- ret = smsc95xx_write_reg(dev, INT_STS, INT_STS_CLEAR_ALL_); | |
- if (ret < 0) | |
- return ret; | |
- | |
- mii_check_media(mii, 1, 1); | |
- mii_ethtool_gset(&dev->mii, &ecmd); | |
- lcladv = smsc95xx_mdio_read(dev->net, mii->phy_id, MII_ADVERTISE); | |
- rmtadv = smsc95xx_mdio_read(dev->net, mii->phy_id, MII_LPA); | |
+ if (!phy) | |
+ return -ENODEV; | |
- netif_dbg(dev, link, dev->net, | |
- "speed: %u duplex: %d lcladv: %04x rmtadv: %04x\n", | |
- ethtool_cmd_speed(&ecmd), ecmd.duplex, lcladv, rmtadv); | |
+// netif_dbg(dev, link, dev->net, | |
+// "speed: %u duplex: %d lcladv: %04x rmtadv: %04x\n", | |
+// ethtool_cmd_speed(&ecmd), ecmd.duplex, lcladv, rmtadv); | |
spin_lock_irqsave(&pdata->mac_cr_lock, flags); | |
- if (ecmd.duplex != DUPLEX_FULL) { | |
+ if (phy->duplex != DUPLEX_FULL) { | |
pdata->mac_cr &= ~MAC_CR_FDPX_; | |
pdata->mac_cr |= MAC_CR_RCVOWN_; | |
} else { | |
@@ -589,13 +591,38 @@ static int smsc95xx_link_reset(struct usbnet *dev) | |
if (ret < 0) | |
return ret; | |
- ret = smsc95xx_phy_update_flowcontrol(dev, ecmd.duplex, lcladv, rmtadv); | |
+ ret = smsc95xx_phy_update_flowcontrol(dev); | |
if (ret < 0) | |
netdev_warn(dev->net, "Error updating PHY flow control\n"); | |
return ret; | |
} | |
+static int smsc95xx_link_reset(struct usbnet *dev) | |
+{ | |
+ struct smsc95xx_priv *pdata = dev->driver_priv; | |
+ struct phy_device *phy = pdata->phydev; | |
+ int ret; | |
+ | |
+ if (!phy) | |
+ return -ENODEV; | |
+ | |
+ /* clear interrupt status */ | |
+// ret = smsc95xx_mdio_read(dev->net, mii->phy_id, PHY_INT_SRC); | |
+// if (ret < 0) | |
+// return ret; | |
+ | |
+ ret = smsc95xx_write_reg(dev, INT_STS, INT_STS_CLEAR_ALL_); | |
+ if (ret < 0) | |
+ return ret; | |
+ | |
+ ret = smsc95xx_adjust_link_internal(dev); | |
+ if (ret < 0) | |
+ netdev_warn(dev->net, "Failed to update link during reset"); | |
+ | |
+ return ret; | |
+} | |
+ | |
static void smsc95xx_status(struct usbnet *dev, struct urb *urb) | |
{ | |
u32 intdata; | |
@@ -636,17 +663,17 @@ static void check_carrier(struct work_struct *work) | |
struct smsc95xx_priv *pdata = container_of(work, struct smsc95xx_priv, | |
carrier_check.work); | |
struct usbnet *dev = pdata->dev; | |
- int ret; | |
if (pdata->suspend_flags != 0) | |
return; | |
- ret = smsc95xx_mdio_read(dev->net, dev->mii.phy_id, MII_BMSR); | |
- if (ret < 0) { | |
- netdev_warn(dev->net, "Failed to read MII_BMSR\n"); | |
+ if (!pdata->phydev) | |
return; | |
- } | |
- if (ret & BMSR_LSTATUS) | |
+ | |
+ /* The PHY driver / state machine will ensure the link variable | |
+ * is set properly, so, just test it here. | |
+ */ | |
+ if (pdata->phydev->link) | |
set_carrier(dev, 1); | |
else | |
set_carrier(dev, 0); | |
@@ -778,7 +805,7 @@ static int get_mdix_status(struct net_device *net) | |
u32 val; | |
int buf; | |
- buf = smsc95xx_mdio_read(dev->net, dev->mii.phy_id, SPECIAL_CTRL_STS); | |
+// buf = smsc95xx_mdio_read(dev->net, dev->mii.phy_id, SPECIAL_CTRL_STS); | |
if (buf & SPECIAL_CTRL_STS_OVRRD_AMDIX_) { | |
if (buf & SPECIAL_CTRL_STS_AMDIX_ENABLE_) | |
return ETH_TP_MDI_AUTO; | |
@@ -793,67 +820,70 @@ static int get_mdix_status(struct net_device *net) | |
return ETH_TP_MDI; | |
} | |
-static void set_mdix_status(struct net_device *net, __u8 mdix_ctrl) | |
-{ | |
- struct usbnet *dev = netdev_priv(net); | |
- struct smsc95xx_priv *pdata = dev->driver_priv; | |
- int buf; | |
- | |
- if ((pdata->chip_id == ID_REV_CHIP_ID_9500A_) || | |
- (pdata->chip_id == ID_REV_CHIP_ID_9530_) || | |
- (pdata->chip_id == ID_REV_CHIP_ID_89530_) || | |
- (pdata->chip_id == ID_REV_CHIP_ID_9730_)) { | |
- /* Extend Manual AutoMDIX timer for 9500A/9500Ai */ | |
- buf = smsc95xx_mdio_read(dev->net, dev->mii.phy_id, | |
- PHY_EDPD_CONFIG); | |
- buf |= PHY_EDPD_CONFIG_EXT_CROSSOVER_; | |
- smsc95xx_mdio_write(dev->net, dev->mii.phy_id, | |
- PHY_EDPD_CONFIG, buf); | |
- } | |
- | |
- if (mdix_ctrl == ETH_TP_MDI) { | |
- buf = smsc95xx_mdio_read(dev->net, dev->mii.phy_id, | |
- SPECIAL_CTRL_STS); | |
- buf |= SPECIAL_CTRL_STS_OVRRD_AMDIX_; | |
- buf &= ~(SPECIAL_CTRL_STS_AMDIX_ENABLE_ | | |
- SPECIAL_CTRL_STS_AMDIX_STATE_); | |
- smsc95xx_mdio_write(dev->net, dev->mii.phy_id, | |
- SPECIAL_CTRL_STS, buf); | |
- } else if (mdix_ctrl == ETH_TP_MDI_X) { | |
- buf = smsc95xx_mdio_read(dev->net, dev->mii.phy_id, | |
- SPECIAL_CTRL_STS); | |
- buf |= SPECIAL_CTRL_STS_OVRRD_AMDIX_; | |
- buf &= ~(SPECIAL_CTRL_STS_AMDIX_ENABLE_ | | |
- SPECIAL_CTRL_STS_AMDIX_STATE_); | |
- buf |= SPECIAL_CTRL_STS_AMDIX_STATE_; | |
- smsc95xx_mdio_write(dev->net, dev->mii.phy_id, | |
- SPECIAL_CTRL_STS, buf); | |
- } else if (mdix_ctrl == ETH_TP_MDI_AUTO) { | |
- buf = smsc95xx_mdio_read(dev->net, dev->mii.phy_id, | |
- SPECIAL_CTRL_STS); | |
- buf &= ~SPECIAL_CTRL_STS_OVRRD_AMDIX_; | |
- buf &= ~(SPECIAL_CTRL_STS_AMDIX_ENABLE_ | | |
- SPECIAL_CTRL_STS_AMDIX_STATE_); | |
- buf |= SPECIAL_CTRL_STS_AMDIX_ENABLE_; | |
- smsc95xx_mdio_write(dev->net, dev->mii.phy_id, | |
- SPECIAL_CTRL_STS, buf); | |
- } | |
- pdata->mdix_ctrl = mdix_ctrl; | |
-} | |
+//static void set_mdix_status(struct net_device *net, __u8 mdix_ctrl) | |
+//{ | |
+// struct usbnet *dev = netdev_priv(net); | |
+// struct smsc95xx_priv *pdata = dev->driver_priv; | |
+// int buf; | |
+// | |
+// if ((pdata->chip_id == ID_REV_CHIP_ID_9500A_) || | |
+// (pdata->chip_id == ID_REV_CHIP_ID_9530_) || | |
+// (pdata->chip_id == ID_REV_CHIP_ID_89530_) || | |
+// (pdata->chip_id == ID_REV_CHIP_ID_9730_)) { | |
+// /* Extend Manual AutoMDIX timer for 9500A/9500Ai */ | |
+//// buf = smsc95xx_mdio_read(dev->net, dev->mii.phy_id, | |
+//// PHY_EDPD_CONFIG); | |
+// buf |= PHY_EDPD_CONFIG_EXT_CROSSOVER_; | |
+//// smsc95xx_mdio_write(dev->net, dev->mii.phy_id, | |
+//// PHY_EDPD_CONFIG, buf); | |
+// } | |
+// | |
+// if (mdix_ctrl == ETH_TP_MDI) { | |
+//// buf = smsc95xx_mdio_read(dev->net, dev->mii.phy_id, | |
+//// SPECIAL_CTRL_STS); | |
+// buf |= SPECIAL_CTRL_STS_OVRRD_AMDIX_; | |
+// buf &= ~(SPECIAL_CTRL_STS_AMDIX_ENABLE_ | | |
+// SPECIAL_CTRL_STS_AMDIX_STATE_); | |
+//// smsc95xx_mdio_write(dev->net, dev->mii.phy_id, | |
+//// SPECIAL_CTRL_STS, buf); | |
+// } else if (mdix_ctrl == ETH_TP_MDI_X) { | |
+//// buf = smsc95xx_mdio_read(dev->net, dev->mii.phy_id, | |
+//// SPECIAL_CTRL_STS); | |
+// buf |= SPECIAL_CTRL_STS_OVRRD_AMDIX_; | |
+// buf &= ~(SPECIAL_CTRL_STS_AMDIX_ENABLE_ | | |
+// SPECIAL_CTRL_STS_AMDIX_STATE_); | |
+// buf |= SPECIAL_CTRL_STS_AMDIX_STATE_; | |
+//// smsc95xx_mdio_write(dev->net, dev->mii.phy_id, | |
+//// SPECIAL_CTRL_STS, buf); | |
+// } else if (mdix_ctrl == ETH_TP_MDI_AUTO) { | |
+//// buf = smsc95xx_mdio_read(dev->net, dev->mii.phy_id, | |
+//// SPECIAL_CTRL_STS); | |
+// buf &= ~SPECIAL_CTRL_STS_OVRRD_AMDIX_; | |
+// buf &= ~(SPECIAL_CTRL_STS_AMDIX_ENABLE_ | | |
+// SPECIAL_CTRL_STS_AMDIX_STATE_); | |
+// buf |= SPECIAL_CTRL_STS_AMDIX_ENABLE_; | |
+//// smsc95xx_mdio_write(dev->net, dev->mii.phy_id, | |
+//// SPECIAL_CTRL_STS, buf); | |
+// } | |
+// pdata->mdix_ctrl = mdix_ctrl; | |
+//} | |
static int smsc95xx_get_link_ksettings(struct net_device *net, | |
struct ethtool_link_ksettings *cmd) | |
{ | |
struct usbnet *dev = netdev_priv(net); | |
struct smsc95xx_priv *pdata = dev->driver_priv; | |
- int retval; | |
- retval = usbnet_get_link_ksettings(net, cmd); | |
+ if (!pdata->phydev) | |
+ return -ENODEV; | |
+ | |
+ phy_ethtool_ksettings_get(pdata->phydev, cmd); | |
- cmd->base.eth_tp_mdix = pdata->mdix_ctrl; | |
- cmd->base.eth_tp_mdix_ctrl = pdata->mdix_ctrl; | |
+ // TODO: Keep? | |
+// cmd->base.eth_tp_mdix = pdata->mdix_ctrl; | |
+// cmd->base.eth_tp_mdix_ctrl = pdata->mdix_ctrl; | |
- return retval; | |
+ return 0; | |
} | |
static int smsc95xx_set_link_ksettings(struct net_device *net, | |
@@ -861,14 +891,14 @@ static int smsc95xx_set_link_ksettings(struct net_device *net, | |
{ | |
struct usbnet *dev = netdev_priv(net); | |
struct smsc95xx_priv *pdata = dev->driver_priv; | |
- int retval; | |
- if (pdata->mdix_ctrl != cmd->base.eth_tp_mdix_ctrl) | |
- set_mdix_status(net, cmd->base.eth_tp_mdix_ctrl); | |
+ if (!pdata->phydev) | |
+ return -ENODEV; | |
- retval = usbnet_set_link_ksettings(net, cmd); | |
+// if (pdata->mdix_ctrl != cmd->base.eth_tp_mdix_ctrl) | |
+// set_mdix_status(net, cmd->base.eth_tp_mdix_ctrl); | |
- return retval; | |
+ return phy_ethtool_ksettings_set(pdata->phydev, cmd); | |
} | |
static const struct ethtool_ops smsc95xx_ethtool_ops = { | |
@@ -899,6 +929,19 @@ static int smsc95xx_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd) | |
return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL); | |
} | |
+static void smsc95xx_adjust_link(struct net_device *netdev) | |
+{ | |
+ struct usbnet *dev = netdev_priv(netdev); | |
+ struct smsc95xx_priv *priv = dev->driver_priv; | |
+ struct phy_device *phydev = priv->phydev; | |
+ | |
+ if (phydev->link) { | |
+ int ret = smsc95xx_adjust_link_internal(dev); | |
+ if (ret < 0) | |
+ netdev_err(dev->net, "Failed to adjust link"); | |
+ } | |
+} | |
+ | |
static void smsc95xx_init_mac_address(struct usbnet *dev) | |
{ | |
const u8 *mac_addr; | |
@@ -972,50 +1015,74 @@ static int smsc95xx_start_rx_path(struct usbnet *dev, int in_pm) | |
return __smsc95xx_write_reg(dev, MAC_CR, pdata->mac_cr, in_pm); | |
} | |
-static int smsc95xx_phy_initialize(struct usbnet *dev) | |
+static int smsc95xx_mdio_initialize(struct usbnet *dev) | |
{ | |
- int bmcr, ret, timeout = 0; | |
- | |
- /* Initialize MII structure */ | |
- dev->mii.dev = dev->net; | |
- dev->mii.mdio_read = smsc95xx_mdio_read; | |
- dev->mii.mdio_write = smsc95xx_mdio_write; | |
- dev->mii.phy_id_mask = 0x1f; | |
- dev->mii.reg_num_mask = 0x1f; | |
- dev->mii.phy_id = SMSC95XX_INTERNAL_PHY_ID; | |
- | |
- /* reset phy and wait for reset to complete */ | |
- smsc95xx_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET); | |
- | |
- do { | |
- msleep(10); | |
- bmcr = smsc95xx_mdio_read(dev->net, dev->mii.phy_id, MII_BMCR); | |
- timeout++; | |
- } while ((bmcr & BMCR_RESET) && (timeout < 100)); | |
+ struct smsc95xx_priv *priv = dev->driver_priv; | |
+ int /*bmcr, */ret/*, timeout*/ = 0; | |
- if (timeout >= 100) { | |
- netdev_warn(dev->net, "timeout on PHY Reset"); | |
- return -EIO; | |
+ priv->mdio = mdiobus_alloc(); | |
+ if (!priv->mdio) { | |
+ netdev_err(dev->net, "Could not allocate MDIO bus\n"); | |
+ return -ENOMEM; | |
} | |
- smsc95xx_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE, | |
- ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP | | |
- ADVERTISE_PAUSE_ASYM); | |
- | |
- /* read to clear */ | |
- ret = smsc95xx_mdio_read(dev->net, dev->mii.phy_id, PHY_INT_SRC); | |
- if (ret < 0) { | |
- netdev_warn(dev->net, "Failed to read PHY_INT_SRC during init\n"); | |
- return ret; | |
+ /* Initialize MII structure */ | |
+ priv->mdio->priv = dev; | |
+ priv->mdio->read = &smsc95xx_mdio_read; | |
+ priv->mdio->write = &smsc95xx_mdio_write; | |
+ priv->mdio->name = SMSC_CHIPNAME " MDIO bus"; | |
+ snprintf(priv->mdio->id, MII_BUS_ID_SIZE, "usb-%03d:%03d", | |
+ dev->udev->bus->busnum, dev->udev->devnum); | |
+ | |
+ ret = mdiobus_register(priv->mdio); | |
+ if (ret) { | |
+ netdev_err(dev->net, "Could not register MDIO bus\n"); | |
+ goto mfree; | |
} | |
- smsc95xx_mdio_write(dev->net, dev->mii.phy_id, PHY_INT_MASK, | |
- PHY_INT_MASK_DEFAULT_); | |
- mii_nway_restart(&dev->mii); | |
- | |
- netif_dbg(dev, ifup, dev->net, "phy initialised successfully\n"); | |
+ netdev_info(dev->net, "Registered MDIO bus %s\n", priv->mdio->id); | |
return 0; | |
+ | |
+mfree: | |
+ mdiobus_free(priv->mdio); | |
+ return ret; | |
} | |
+// dev->mii.phy_id_mask = 0x1f; | |
+// dev->mii.reg_num_mask = 0x1f; | |
+// dev->mii.phy_id = SMSC95XX_INTERNAL_ID; | |
+// | |
+// /* reset phy and wait for reset to complete */ | |
+// smsc95xx_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET); | |
+// | |
+// do { | |
+// msleep(10); | |
+// bmcr = smsc95xx_mdio_read(dev->net, dev->mii.phy_id, MII_BMCR); | |
+// timeout++; | |
+// } while ((bmcr & BMCR_RESET) && (timeout < 100)); | |
+// | |
+// if (timeout >= 100) { | |
+// netdev_warn(dev->net, "timeout on PHY Reset"); | |
+// return -EIO; | |
+// } | |
+// | |
+// smsc95xx_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE, | |
+// ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP | | |
+// ADVERTISE_PAUSE_ASYM); | |
+// | |
+// /* read to clear */ | |
+// ret = smsc95xx_mdio_read(dev->net, dev->mii.phy_id, PHY_INT_SRC); | |
+// if (ret < 0) { | |
+// netdev_warn(dev->net, "Failed to read PHY_INT_SRC during init\n"); | |
+// return ret; | |
+// } | |
+// | |
+// smsc95xx_mdio_write(dev->net, dev->mii.phy_id, PHY_INT_MASK, | |
+// PHY_INT_MASK_DEFAULT_); | |
+// mii_nway_restart(&dev->mii); | |
+// | |
+// netif_dbg(dev, ifup, dev->net, "phy initialised successfully\n"); | |
+// return 0; | |
+//} | |
static int smsc95xx_reset(struct usbnet *dev) | |
{ | |
@@ -1025,6 +1092,7 @@ static int smsc95xx_reset(struct usbnet *dev) | |
netif_dbg(dev, ifup, dev->net, "entering smsc95xx_reset\n"); | |
+ // TODO: "Hard" software reset? this does not reset external PHY | |
ret = smsc95xx_write_reg(dev, HW_CFG, HW_CFG_LRST_); | |
if (ret < 0) | |
return ret; | |
@@ -1198,12 +1266,29 @@ static int smsc95xx_reset(struct usbnet *dev) | |
smsc95xx_set_multicast(dev->net); | |
- ret = smsc95xx_phy_initialize(dev); | |
- if (ret < 0) { | |
- netdev_warn(dev->net, "Failed to init PHY\n"); | |
+// ret = smsc95xx_phy_initialize(dev); | |
+// if (ret < 0) { | |
+// netdev_warn(dev->net, "Failed to init PHY\n"); | |
+// return ret; | |
+// } | |
+ /* Connect PHY */ | |
+ snprintf(pdata->phy_name, 20, PHY_ID_FMT, | |
+ pdata->mdio->id, SMSC95XX_PHY_ID); | |
+ pdata->phydev = phy_connect(dev->net, pdata->phy_name, | |
+ &smsc95xx_adjust_link, | |
+ PHY_INTERFACE_MODE_MII); | |
+ if (IS_ERR(pdata->phydev)) { | |
+ netdev_err(dev->net, "Could not connect to PHY device %s\n", | |
+ pdata->phy_name); | |
+ ret = PTR_ERR(pdata->phydev); | |
return ret; | |
} | |
+ netdev_info(dev->net, "Connected to PHY %s\n", pdata->phy_name); | |
+ | |
+ // TODO: resume PHY? | |
+ phy_start(pdata->phydev); | |
+ | |
ret = smsc95xx_read_reg(dev, INT_EP_CTL, &read_buf); | |
if (ret < 0) | |
return ret; | |
@@ -1284,8 +1369,12 @@ static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf) | |
smsc95xx_init_mac_address(dev); | |
- /* Init all registers */ | |
- ret = smsc95xx_reset(dev); | |
+ /* Init mdio bus */ | |
+ ret = smsc95xx_mdio_initialize(dev); | |
+ if (ret < 0) | |
+ return ret; | |
+ | |
+ // TODO: Get PHY SEL bit? | |
/* detect device revision as different features may be available */ | |
ret = smsc95xx_read_reg(dev, ID_REV, &val); | |
@@ -1318,18 +1407,46 @@ static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf) | |
return 0; | |
} | |
+static void smsc95xx_mdio_deinitialize(struct usbnet *dev) | |
+{ | |
+ struct smsc95xx_priv *priv = dev->driver_priv; | |
+ | |
+ netdev_info(dev->net, "Deregistering MDIO bus %s\n", priv->mdio->id); | |
+ mdiobus_unregister(priv->mdio); | |
+ mdiobus_free(priv->mdio); | |
+} | |
+ | |
static void smsc95xx_unbind(struct usbnet *dev, struct usb_interface *intf) | |
{ | |
struct smsc95xx_priv *pdata = dev->driver_priv; | |
if (pdata) { | |
cancel_delayed_work(&pdata->carrier_check); | |
+ | |
+ smsc95xx_mdio_deinitialize(dev); | |
+ | |
netif_dbg(dev, ifdown, dev->net, "free pdata\n"); | |
kfree(pdata); | |
pdata = NULL; | |
} | |
} | |
+static int smsc95xx_stop(struct usbnet *dev) | |
+{ | |
+ struct smsc95xx_priv *priv = dev->driver_priv; | |
+ | |
+ netdev_dbg(dev->net, "Stopping interface\n"); | |
+ | |
+ if (priv->phydev) { | |
+ netdev_info(dev->net, "Disconnecting from phy %s\n", | |
+ priv->phy_name); | |
+ phy_stop(priv->phydev); | |
+ phy_disconnect(priv->phydev); | |
+ } | |
+ | |
+ return 0; | |
+} | |
+ | |
static u32 smsc_crc(const u8 *buffer, size_t len, int filter) | |
{ | |
u32 crc = bitrev16(crc16(0xFFFF, buffer, len)); | |
@@ -1423,21 +1540,23 @@ static int smsc95xx_enter_suspend1(struct usbnet *dev) | |
u32 val; | |
int ret; | |
+// TODO: Probably should not do this with T1. | |
/* reconfigure link pulse detection timing for | |
* compatibility with non-standard link partners | |
*/ | |
- if (pdata->features & FEATURE_PHY_NLP_CROSSOVER) | |
- smsc95xx_mdio_write_nopm(dev->net, mii->phy_id, PHY_EDPD_CONFIG, | |
- PHY_EDPD_CONFIG_DEFAULT); | |
+// if (pdata->features & FEATURE_PHY_NLP_CROSSOVER) | |
+// smsc95xx_mdio_write_nopm(dev->net, mii->phy_id, PHY_EDPD_CONFIG, | |
+// PHY_EDPD_CONFIG_DEFAULT); | |
/* enable energy detect power-down mode */ | |
- ret = smsc95xx_mdio_read_nopm(dev->net, mii->phy_id, PHY_MODE_CTRL_STS); | |
- if (ret < 0) | |
- return ret; | |
+// ret = smsc95xx_mdio_read_nopm(dev->net, mii->phy_id, PHY_MODE_CTRL_STS); | |
+// if (ret < 0) | |
+// return ret; | |
- ret |= MODE_CTRL_STS_EDPWRDOWN_; | |
+// ret |= MODE_CTRL_STS_EDPWRDOWN_; | |
- smsc95xx_mdio_write_nopm(dev->net, mii->phy_id, PHY_MODE_CTRL_STS, ret); | |
+// smsc95xx_mdio_write_nopm(dev->net, mii->phy_id, PHY_MODE_CTRL_STS, ret); | |
+// END TODO | |
/* enter SUSPEND1 mode */ | |
ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val); | |
@@ -2088,6 +2207,7 @@ static const struct driver_info smsc95xx_info = { | |
.description = "smsc95xx USB 2.0 Ethernet", | |
.bind = smsc95xx_bind, | |
.unbind = smsc95xx_unbind, | |
+ .stop = smsc95xx_stop, | |
.link_reset = smsc95xx_link_reset, | |
.reset = smsc95xx_reset, | |
.rx_fixup = smsc95xx_rx_fixup, | |
-- | |
2.21.0 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ip link set eth0 up | |
[ 19.373431][ T979] smsc95xx 1-1:1.0 eth0: Connected to PHY usb-001:002:01 | |
[ 19.383090][ T979] smsc95xx 1-1:1.0 eth0: open: enable queueing (rx 4, tx 59) mtu 1500 simple framing | |
# ip addr add 10.0.0.1/24 dev eth0 | |
# tcpdump -vv -i eth0 & | |
[1] 981 | |
# [ 86.998890][ T981] device eth0 entered promiscuous mode | |
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes | |
ping 10.0.0.2 | |
PING 10.0.0.2 (10.0.0.2): 56 data bytes | |
12:56:15.317262 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 10.0.0.2 tell 10.0.0.1, length 28 | |
12:56:16.321660 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 10.0.0.2 tell 10.0.0.1, length 28 | |
12:56:17.343653 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 10.0.0.2 tell 10.0.0.1, length 28 | |
12:56:19.340910 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 10.0.0.2 tell 10.0.0.1, length 28 | |
12:56:20.352219 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 10.0.0.2 tell 10.0.0.1, length 28 | |
12:56:21.375757 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 10.0.0.2 tell 10.0.0.1, length 28 | |
12:56:23.353888 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 10.0.0.2 tell 10.0.0.1, length 28 | |
12:56:24.031822 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 10.0.0.1 tell 10.0.0.2, length 46 | |
12:56:24.034089 IP (tos 0x0, ttl 64, id 50491, offset 0, flags [DF], proto ICMP (1), length 84) | |
10.0.0.1 > 10.0.0.2: ICMP echo request, id 54787, seq 8, length 64 | |
12:56:24.034952 ARP, Ethernet (len 6), IPv4 (len 4), Reply 10.0.0.1 is-at 70:b3:d5:4c:08:1f (oui Unknown), length 28 | |
12:56:24.037128 IP (tos 0x0, ttl 64, id 58404, offset 0, flags [DF], proto ICMP (1), length 84) | |
64 bytes from 10.0.0.2: seq=8 ttl=64 time=695.232 ms | |
10.0.0.2 > 10.0.0.1: ICMP echo request, id 55043, seq 0, length 64 | |
12:56:24.040665 IP (tos 0x0, ttl 64, id 50528, offset 0, flags [none], proto ICMP (1), length 84) | |
10.0.0.1 > 10.0.0.2: ICMP echo reply, id 55043, seq 0, length 64 | |
12:56:24.041672 ARP, Ethernet (len 6), IPv4 (len 4), Reply 10.0.0.2 is-at 70:b3:d5:4c:01:37 (oui Unknown), length 46 | |
12:56:24.042093 ARP, Ethernet (len 6), IPv4 (len 4), Reply 10.0.0.2 is-at 70:b3:d5:4c:01:37 (oui Unknown), length 46 | |
12:56:24.042174 ARP, Ethernet (len 6), IPv4 (len 4), Reply 10.0.0.2 is-at 70:b3:d5:4c:01:37 (oui Unknown), length 46 | |
12:56:24.042241 ARP, Ethernet (len 6), IPv4 (len 4), Reply 10.0.0.2 is-at 70:b3:d5:4c:01:37 (oui Unknown), length 46 | |
12:56:24.042305 ARP, Ethernet (len 6), IPv4 (len 4), Reply 10.0.0.2 is-at 70:b3:d5:4c:01:37 (oui Unknown), length 46 | |
12:56:24.042369 ARP, Ethernet (len 6), IPv4 (len 4), Reply 10.0.0.2 is-at 70:b3:d5:4c:01:37 (oui Unknown), length 46 | |
12:56:24.042432 ARP, Ethernet (len 6), IPv4 (len 4), Reply 10.0.0.2 is-at 70:b3:d5:4c:01:37 (oui Unknown), length 46 | |
12:56:24.045069 IP (tos 0x0, ttl 64, id 58406, offset 0, flags [none], proto ICMP (1), length 84) | |
10.0.0.2 > 10.0.0.1: ICMP echo reply, id 54787, seq 8, length 64 | |
12:56:24.361605 IP (tos 0x0, ttl 64, id 50539, offset 0, flags [DF], proto ICMP (1), length 84) | |
10.0.0.1 > 10.0.0.2: ICMP echo request, id 54787, seq 9, length 64 | |
64 bytes from 10.0.0.2: seq=9 ttl=64 time=4.662 ms | |
12:56:24.365294 IP (tos 0x0, ttl 64, id 58444, offset 0, flags [none], proto ICMP (1), length 84) | |
10.0.0.2 > 10.0.0.1: ICMP echo reply, id 54787, seq 9, length 64 | |
12:56:25.057122 IP (tos 0x0, ttl 64, id 58481, offset 0, flags [DF], proto ICMP (1), length 84) | |
10.0.0.2 > 10.0.0.1: ICMP echo request, id 55043, seq 1, length 64 | |
12:56:25.057627 IP (tos 0x0, ttl 64, id 50709, offset 0, flags [none], proto ICMP (1), length 84) | |
10.0.0.1 > 10.0.0.2: ICMP echo reply, id 55043, seq 1, length 64 | |
12:56:25.363807 IP (tos 0x0, ttl 64, id 50783, offset 0, flags [DF], proto ICMP (1), length 84) | |
64 bytes from 10.0.0.2: seq=10 ttl=64 time=4.735 ms | |
10.0.0.1 > 10.0.0.2: ICMP echo request, id 54787, seq 10, length 64 | |
12:56:25.366083 IP (tos 0x0, ttl 64, id 58503, offset 0, flags [none], proto ICMP (1), length 84) | |
10.0.0.2 > 10.0.0.1: ICMP echo reply, id 54787, seq 10, length 64 | |
--- 10.0.0.2 ping statistics --- | |
11 packets transmitted, 3 packets received, 72% packet loss | |
round-trip min/avg/max = 4.662/234.876/695.232 ms | |
^C# # |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ip link set eth0 up | |
[ 41.339519][ T979] smsc95xx 1-1:1.0 eth0: Connected to PHY usb-001:002:01 | |
[ 41.352434][ T979] smsc95xx 1-1:1.0 eth0: open: enable queueing (rx 4, tx 59) mtu 1500 simple framing | |
# ethtool --set-phy-tunable eth0 master-slave slave | |
# ip addr add 10.0.0.2/24 dev eth0 | |
# tcpdump -vv -i eth0 & | |
[1] 982 | |
# [ 110.861784][ T982] device eth0 entered promiscuous mode | |
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes | |
ping 10.0.0.1 | |
PING 10.0.0.1 (10.0.0.1): 56 data bytes | |
64 bytes from 10.0.0.1: seq=0 ttl=64 time=34.296 ms | |
12:56:23.817787 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 10.0.0.1 tell 10.0.0.2, length 28 | |
12:56:23.822889 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 10.0.0.2 tell 10.0.0.1, length 46 | |
12:56:23.825433 IP (tos 0x0, ttl 64, id 58404, offset 0, flags [DF], proto ICMP (1), length 84) | |
10.0.0.2 > 10.0.0.1: ICMP echo request, id 55043, seq 0, length 64 | |
12:56:23.826613 ARP, Ethernet (len 6), IPv4 (len 4), Reply 10.0.0.2 is-at 70:b3:d5:4c:01:37 (oui Unknown), length 28 | |
12:56:23.827334 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 10.0.0.2 tell 10.0.0.1, length 46 | |
12:56:23.827539 ARP, Ethernet (len 6), IPv4 (len 4), Reply 10.0.0.2 is-at 70:b3:d5:4c:01:37 (oui Unknown), length 28 | |
12:56:23.827823 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 10.0.0.2 tell 10.0.0.1, length 46 | |
12:56:23.827948 ARP, Ethernet (len 6), IPv4 (len 4), Reply 10.0.0.2 is-at 70:b3:d5:4c:01:37 (oui Unknown), length 28 | |
12:56:23.828175 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 10.0.0.2 tell 10.0.0.1, length 46 | |
12:56:23.828286 ARP, Ethernet (len 6), IPv4 (len 4), Reply 10.0.0.2 is-at 70:b3:d5:4c:01:37 (oui Unknown), length 28 | |
12:56:23.828518 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 10.0.0.2 tell 10.0.0.1, length 46 | |
12:56:23.828637 ARP, Ethernet (len 6), IPv4 (len 4), Reply 10.0.0.2 is-at 70:b3:d5:4c:01:37 (oui Unknown), length 28 | |
12:56:23.828857 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 10.0.0.2 tell 10.0.0.1, length 46 | |
12:56:23.828983 ARP, Ethernet (len 6), IPv4 (len 4), Reply 10.0.0.2 is-at 70:b3:d5:4c:01:37 (oui Unknown), length 28 | |
12:56:23.829203 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 10.0.0.2 tell 10.0.0.1, length 46 | |
12:56:23.829313 ARP, Ethernet (len 6), IPv4 (len 4), Reply 10.0.0.2 is-at 70:b3:d5:4c:01:37 (oui Unknown), length 28 | |
12:56:23.830604 IP (tos 0x0, ttl 64, id 50491, offset 0, flags [DF], proto ICMP (1), length 84) | |
10.0.0.1 > 10.0.0.2: ICMP echo request, id 54787, seq 8, length 64 | |
12:56:23.833531 IP (tos 0x0, ttl 64, id 58406, offset 0, flags [none], proto ICMP (1), length 84) | |
10.0.0.2 > 10.0.0.1: ICMP echo reply, id 54787, seq 8, length 64 | |
12:56:23.834281 ARP, Ethernet (len 6), IPv4 (len 4), Reply 10.0.0.1 is-at 70:b3:d5:4c:08:1f (oui Unknown), length 46 | |
12:56:23.835011 IP (tos 0x0, ttl 64, id 50528, offset 0, flags [none], proto ICMP (1), length 84) | |
10.0.0.1 > 10.0.0.2: ICMP echo reply, id 55043, seq 0, length 64 | |
12:56:24.152036 IP (tos 0x0, ttl 64, id 50539, offset 0, flags [DF], proto ICMP (1), length 84) | |
10.0.0.1 > 10.0.0.2: ICMP echo request, id 54787, seq 9, length 64 | |
12:56:24.153409 IP (tos 0x0, ttl 64, id 58444, offset 0, flags [none], proto ICMP (1), length 84) | |
10.0.0.2 > 10.0.0.1: ICMP echo reply, id 54787, seq 9, length 64 | |
12:56:24.845381 IP (tos 0x0, ttl 64, id 58481, offset 0, flags [DF], proto ICMP (1), length 84) | |
64 bytes from 10.0.0.1: seq=1 ttl=64 time=3.531 ms | |
10.0.0.2 > 10.0.0.1: ICMP echo request, id 55043, seq 1, length 64 | |
12:56:24.847988 IP (tos 0x0, ttl 64, id 50709, offset 0, flags [none], proto ICMP (1), length 84) | |
10.0.0.1 > 10.0.0.2: ICMP echo reply, id 55043, seq 1, length 64 | |
^C | |
--- 10.0.0.1 ping statistics --- | |
2 packets transmitted, 2 packets received, 0% packet loss | |
round-trip min/avg/max = 3.531/18.913/34.296 ms | |
# 12:56:25.154053 IP (tos 0x0, ttl 64, id 50783, offset 0, flags [DF], proto ICMP (1), length 84) | |
10.0.0.1 > 10.0.0.2: ICMP echo request, id 54787, seq 10, length 64 | |
12:56:25.154424 IP (tos 0x0, ttl 64, id 58503, offset 0, flags [none], proto ICMP (1), length 84) | |
10.0.0.2 > 10.0.0.1: ICMP echo reply, id 54787, seq 10, length 64 | |
[ 244.110099][ C0] random: crng init done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment