Skip to contentSkip to conversation

dl2k: Add support for IP1000A-based cards

PATCH Superseded Ondrej Zary 3 participants 7 messages Nov 14, 2015 – Nov 15, 2015

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 dl2k: Add support for IP1000A-based cards

Add support for IP1000A chips to dl2k driver. IP1000A chip looks like a TC9020 with integrated PHY.

This allows IP1000A chips to work reliably because the ipg driver is buggy - it loses packets under load and then completely stops transmitting data.

Tested with Asus NX1101 v2.0 at 10, 100 and 1000Mbps. Also verified that it does not break D-Link DGE-550T.

---
 drivers/net/ethernet/dlink/Kconfig |    5 ++--
 drivers/net/ethernet/dlink/dl2k.c  |   51 +++++++++++++++++++++++++++++++++---
 drivers/net/ethernet/dlink/dl2k.h  |   15 ++++++++++-
 3 files changed, 65 insertions(+), 6 deletions(-)
drivers/net/ethernet/dlink/Kconfig +3 -2
index f6e858d..ebdc832 100644
@@ -17,15 +17,16 @@ config NET_VENDOR_DLINK
 if NET_VENDOR_DLINK
 
 config DL2K
-	tristate "DL2000/TC902x-based Gigabit Ethernet support"
+	tristate "DL2000/TC902x/IP1000A-based Gigabit Ethernet support"
 	depends on PCI
 	select CRC32
 	---help---
-	  This driver supports DL2000/TC902x-based Gigabit ethernet cards,
+	  This driver supports DL2000/TC902x/IP1000A-based Gigabit ethernet cards,
 	  which includes
 	  D-Link DGE-550T Gigabit Ethernet Adapter.
 	  D-Link DL2000-based Gigabit Ethernet Adapter.
 	  Sundance/Tamarack TC902x Gigabit Ethernet Adapter.
+	  ICPlus IP1000A-based cards
 
 	  To compile this driver as a module, choose M here: the
 	  module will be called dl2k.
drivers/net/ethernet/dlink/dl2k.c +48 -3

99 lines not on this page · raw message

drivers/net/ethernet/dlink/dl2k.h +14 -1
index 23c07b0..8f4f612 100644
@@ -211,6 +211,10 @@ enum ASICCtrl_HiWord_bits {
 	ResetBusy = 0x0400,
 };
 
+#define IPG_AC_LED_MODE		BIT(14)
+#define IPG_AC_LED_SPEED	BIT(27)
+#define IPG_AC_LED_MODE_BIT_1	BIT(29)
+
 /* Transmit Frame Control bits */
 enum TFC_bits {
 	DwordAlign = 0x00000000,
@@ -332,7 +336,10 @@ typedef struct t_SROM {
 	u16 asic_ctrl;		/* 0x02 */
 	u16 sub_vendor_id;	/* 0x04 */
 	u16 sub_system_id;	/* 0x06 */
-	u16 reserved1[12];	/* 0x08-0x1f */
+	u16 pci_base_1;		/* 0x08 (IP1000A only) */
+	u16 pci_base_2;		/* 0x0a (IP1000A only) */
+	u16 led_mode;		/* 0x0c (IP1000A only) */
+	u16 reserved1[9];	/* 0x0e-0x1f */
 	u8 mac_addr[6];		/* 0x20-0x25 */
 	u8 reserved2[10];	/* 0x26-0x2f */
 	u8 sib[204];		/* 0x30-0xfb */
@@ -397,6 +404,7 @@ struct netdev_private {
 	u16 advertising;	/* NWay media advertisement */
 	u16 negotiate;		/* Negotiated media */
 	int phy_addr;		/* PHY addresses. */
+	u16 led_mode;		/* LED mode read from EEPROM (IP1000A only) */
 };
 
 /* The station address location in the EEPROM. */
@@ -407,10 +415,15 @@ struct netdev_private {
         class_mask              of the class are honored during the comparison.
         driver_data             Data private to the driver.
 */
+#define CHIP_IP1000A	1
 
 static const struct pci_device_id rio_pci_tbl[] = {
 	{0x1186, 0x4000, PCI_ANY_ID, PCI_ANY_ID, },
 	{0x13f0, 0x1021, PCI_ANY_ID, PCI_ANY_ID, },
+	{ PCI_VDEVICE(SUNDANCE,	0x1023), CHIP_IP1000A },
+	{ PCI_VDEVICE(SUNDANCE,	0x2021), CHIP_IP1000A },
+	{ PCI_VDEVICE(DLINK,	0x9021), CHIP_IP1000A },
+	{ PCI_VDEVICE(DLINK,	0x4020), CHIP_IP1000A },
 	{ }
 };
 MODULE_DEVICE_TABLE (pci, rio_pci_tbl);
Signature · 1 line
Ondrej Zary
#1 lore raw

PATCH 2/2 ipg: Remove ipg driver

Now that IP1000A chips are supported by dl2k driver, the buggy ipg driver can be removed. The ipg driver loses packets under load and then completely stops transmitting data.

---
 MAINTAINERS                          |    7 -
 drivers/net/ethernet/Kconfig         |    1 -
 drivers/net/ethernet/Makefile        |    1 -
 drivers/net/ethernet/icplus/Kconfig  |   13 -
 drivers/net/ethernet/icplus/Makefile |    5 -
 drivers/net/ethernet/icplus/ipg.c    | 2300 ----------------------------------
 drivers/net/ethernet/icplus/ipg.h    |  748 -----------
 7 files changed, 3075 deletions(-)
 delete mode 100644 drivers/net/ethernet/icplus/Kconfig
 delete mode 100644 drivers/net/ethernet/icplus/Makefile
 delete mode 100644 drivers/net/ethernet/icplus/ipg.c
 delete mode 100644 drivers/net/ethernet/icplus/ipg.h
MAINTAINERS +0 -7
index 7ba7ab7..b683820 100644
@@ -5588,13 +5588,6 @@ M:	Juanjo Ciarlante <[email protected]>
 S:	Maintained
 F:	net/ipv4/netfilter/ipt_MASQUERADE.c
 
-IP1000A 10/100/1000 GIGABIT ETHERNET DRIVER
-M:	Francois Romieu <[email protected]>
-M:	Sorbica Shieh <[email protected]>
-L:	[email protected]
-S:	Maintained
-F:	drivers/net/ethernet/icplus/ipg.*
-
 IPATH DRIVER
 M:	Mike Marciniszyn <[email protected]>
 L:	[email protected]
drivers/net/ethernet/Kconfig +0 -1
index 05aa759..955d06b 100644
@@ -78,7 +78,6 @@ source "drivers/net/ethernet/ibm/Kconfig"
 source "drivers/net/ethernet/intel/Kconfig"
 source "drivers/net/ethernet/i825xx/Kconfig"
 source "drivers/net/ethernet/xscale/Kconfig"
-source "drivers/net/ethernet/icplus/Kconfig"
 
 config JME
 	tristate "JMicron(R) PCI-Express Gigabit Ethernet support"
drivers/net/ethernet/Makefile +0 -1
index ddfc808..4a2ee98 100644
@@ -41,7 +41,6 @@ obj-$(CONFIG_NET_VENDOR_IBM) += ibm/
 obj-$(CONFIG_NET_VENDOR_INTEL) += intel/
 obj-$(CONFIG_NET_VENDOR_I825XX) += i825xx/
 obj-$(CONFIG_NET_VENDOR_XSCALE) += xscale/
-obj-$(CONFIG_IP1000) += icplus/
 obj-$(CONFIG_JME) += jme.o
 obj-$(CONFIG_KORINA) += korina.o
 obj-$(CONFIG_LANTIQ_ETOP) += lantiq_etop.o
drivers/net/ethernet/icplus/Kconfig deleted +0 -13
deleted file mode 100644
index 14a66e9..0000000
@@ -1,13 +0,0 @@
-#
-# IC Plus device configuration
-#
-
-config IP1000
-	tristate "IP1000 Gigabit Ethernet support"
-	depends on PCI
-	select MII
-	---help---
-	  This driver supports IP1000 gigabit Ethernet cards.
-
-	  To compile this driver as a module, choose M here: the module
-	  will be called ipg.  This is recommended.
drivers/net/ethernet/icplus/Makefile deleted +0 -5
deleted file mode 100644
index 5bc87c1..0000000
@@ -1,5 +0,0 @@
-#
-# Makefile for the IC Plus device drivers
-#
-
-obj-$(CONFIG_IP1000) += ipg.o
drivers/net/ethernet/icplus/ipg.c deleted +0 -2300

2,300 lines not on this page · raw message

drivers/net/ethernet/icplus/ipg.h deleted +0 -748

655 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
Ondrej Zary

Part of the diff is not shown here. View the raw message.

#2 lore raw
In reply to Ondrej Zary
Quoted 11 lines · Ondrej Zary

Add support for IP1000A chips to dl2k driver. IP1000A chip looks like a TC9020 with integrated PHY.

This allows IP1000A chips to work reliably because the ipg driver is buggy - it loses packets under load and then completely stops transmitting data.

Tested with Asus NX1101 v2.0 at 10, 100 and 1000Mbps. Also verified that it does not break D-Link DGE-550T.

Nitpicks below.

Quoted 6 lines
drivers/net/ethernet/dlink/dl2k.c +0 -0
@@ -253,6 +253,18 @@ rio_probe1 (struct pci_dev *pdev, const struct pci_device_id *ent)
        if (err)
                goto err_out_unmap_rx;
 

drivers/net/ethernet/dlink/dl2k.c rio_probe1 (struct pci_dev *pdev, const struct pci_device_id *ent) · line 265

Quoted 10 lines
drivers/net/ethernet/dlink/dl2k.c +10 -0
+       if (np->chip_id == CHIP_IP1000A &&
+           (np->pdev->revision == 0x40 || np->pdev->revision == 0x41)) {
+               /* PHY magic taken from ipg driver */
+               mii_write(dev, np->phy_addr, 31, 0x0001);
+               mii_write(dev, np->phy_addr, 27, 0x01e0);
+               mii_write(dev, np->phy_addr, 31, 0x0002);
+               mii_write(dev, np->phy_addr, 27, 0xeb8e);
+               mii_write(dev, np->phy_addr, 31, 0x0000);
+               mii_write(dev, np->phy_addr, 30, 0x005e);
+               mii_write(dev, np->phy_addr, 9, 0x0700);

Isn't too many magic numbers?

Quoted 24 lines
drivers/net/ethernet/dlink/dl2k.c +10 -0
+       }
+
        /* Fiber device? */
        np->phy_media = (dr16(ASICCtrl) & PhyMedia) ? 1 : 0;
        np->link_status = 0;
@@ -361,6 +373,11 @@ parse_eeprom (struct net_device *dev)
        for (i = 0; i < 6; i++)
                dev->dev_addr[i] = psrom->mac_addr[i];
 
+       if (np->chip_id == CHIP_IP1000A) {
+               np->led_mode = psrom->led_mode;
+               return 0;
+       }
+
        if (np->pdev->vendor != PCI_VENDOR_ID_DLINK) {
                return 0;
        }
@@ -406,6 +423,28 @@ parse_eeprom (struct net_device *dev)
        return 0;
 }
 
+static void rio_set_led_mode(struct net_device *dev)
+{
+       struct netdev_private *np = netdev_priv(dev);

drivers/net/ethernet/dlink/dl2k.c parse_eeprom (struct net_device *dev) · line 438

Quoted 10 lines
drivers/net/ethernet/dlink/dl2k.c +10 -0
+       void __iomem *ioaddr = np->ioaddr;
+       u32 mode;
+
+       if (np->chip_id != CHIP_IP1000A)
+               return;
+
+       mode = dr32(ASICCtrl);
+       mode &= ~(IPG_AC_LED_MODE_BIT_1 | IPG_AC_LED_MODE | IPG_AC_LED_SPEED);
+
+       if ((np->led_mode & 0x03) > 1)

Isn't "& 0x03) > 1" the same as plain "& 0x02"?

drivers/net/ethernet/dlink/dl2k.c parse_eeprom (struct net_device *dev) · line 440

Quoted 2 lines
drivers/net/ethernet/dlink/dl2k.c +2 -0
+               mode |= IPG_AC_LED_MODE_BIT_1;
+       if ((np->led_mode & 0x01) == 1)

Hmm… Seems redundant == 1.

drivers/net/ethernet/dlink/dl2k.c parse_eeprom (struct net_device *dev) · line 442

Quoted 2 lines
drivers/net/ethernet/dlink/dl2k.c +2 -0
+               mode |= IPG_AC_LED_MODE;
+       if ((np->led_mode & 0x08) == 8)

Similar here.

Quoted 18 lines
drivers/net/ethernet/dlink/dl2k.c +7 -0
+               mode |= IPG_AC_LED_SPEED;
+
+       dw32(ASICCtrl, mode);
+}
+
 static int
 rio_open (struct net_device *dev)
 {
@@ -424,6 +463,8 @@ rio_open (struct net_device *dev)
             GlobalReset | DMAReset | FIFOReset | NetworkReset | HostReset);
        mdelay(10);
 
+       rio_set_led_mode(dev);
+
        /* DebugCtrl bit 4, 5, 9 must set */
        dw32(DebugCtrl, dr32(DebugCtrl) | 0x0230);
 

drivers/net/ethernet/dlink/dl2k.c rio_open (struct net_device *dev) · line 480

Quoted 10 lines
drivers/net/ethernet/dlink/dl2k.c +4 -3
@@ -433,9 +474,10 @@ rio_open (struct net_device *dev)
 
        alloc_list (dev);
 
-       /* Get station address */
-       for (i = 0; i < 6; i++)
-               dw8(StationAddr0 + i, dev->dev_addr[i]);
+       /* Set station address */
+       for (i = 0; i < 3; i++)
+               dw16(StationAddr0 + 2 * i,
+                    cpu_to_le16(((u16 *)dev->dev_addr)[i]));

Is it specific requirement for new HW? If not, may be another patch with micro optimizations.

Quoted 86 lines
drivers/net/ethernet/dlink/dl2k.c +3 -0
        set_multicast (dev);
        if (np->coalesce) {
@@ -780,6 +822,7 @@ tx_error (struct net_device *dev, int tx_status)
                                break;
                        mdelay (1);
                }
+               rio_set_led_mode(dev);
                rio_free_tx (dev, 1);
                /* Reset TFDListPtr */
                dw32(TFDListPtr0, np->tx_ring_dma +
@@ -799,6 +842,7 @@ tx_error (struct net_device *dev, int tx_status)
                                break;
                        mdelay (1);
                }
+               rio_set_led_mode(dev);
                /* Let TxStartThresh stay default value */
        }
        /* Maximum Collisions */
@@ -965,6 +1009,7 @@ rio_error (struct net_device *dev, int int_status)
                        dev->name, int_status);
                dw16(ASICCtrl + 2, GlobalReset | HostReset);
                mdelay (500);
+               rio_set_led_mode(dev);
        }
 }
 
drivers/net/ethernet/dlink/dl2k.h +14 -2
index 23c07b0..8f4f612 100644
@@ -211,6 +211,10 @@ enum ASICCtrl_HiWord_bits {
        ResetBusy = 0x0400,
 };
 
+#define IPG_AC_LED_MODE                BIT(14)
+#define IPG_AC_LED_SPEED       BIT(27)
+#define IPG_AC_LED_MODE_BIT_1  BIT(29)
+
 /* Transmit Frame Control bits */
 enum TFC_bits {
        DwordAlign = 0x00000000,
@@ -332,7 +336,10 @@ typedef struct t_SROM {
        u16 asic_ctrl;          /* 0x02 */
        u16 sub_vendor_id;      /* 0x04 */
        u16 sub_system_id;      /* 0x06 */
-       u16 reserved1[12];      /* 0x08-0x1f */
+       u16 pci_base_1;         /* 0x08 (IP1000A only) */
+       u16 pci_base_2;         /* 0x0a (IP1000A only) */
+       u16 led_mode;           /* 0x0c (IP1000A only) */
+       u16 reserved1[9];       /* 0x0e-0x1f */
        u8 mac_addr[6];         /* 0x20-0x25 */
        u8 reserved2[10];       /* 0x26-0x2f */
        u8 sib[204];            /* 0x30-0xfb */
@@ -397,6 +404,7 @@ struct netdev_private {
        u16 advertising;        /* NWay media advertisement */
        u16 negotiate;          /* Negotiated media */
        int phy_addr;           /* PHY addresses. */
+       u16 led_mode;           /* LED mode read from EEPROM (IP1000A only) */
 };
 
 /* The station address location in the EEPROM. */
@@ -407,10 +415,15 @@ struct netdev_private {
         class_mask              of the class are honored during the comparison.
         driver_data             Data private to the driver.
 */
+#define CHIP_IP1000A   1
 
 static const struct pci_device_id rio_pci_tbl[] = {
        {0x1186, 0x4000, PCI_ANY_ID, PCI_ANY_ID, },
        {0x13f0, 0x1021, PCI_ANY_ID, PCI_ANY_ID, },
+       { PCI_VDEVICE(SUNDANCE, 0x1023), CHIP_IP1000A },
+       { PCI_VDEVICE(SUNDANCE, 0x2021), CHIP_IP1000A },
+       { PCI_VDEVICE(DLINK,    0x9021), CHIP_IP1000A },
+       { PCI_VDEVICE(DLINK,    0x4020), CHIP_IP1000A },
        { }
 };
 MODULE_DEVICE_TABLE (pci, rio_pci_tbl);
--

Ondrej Zary

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw
Quoted 23 lines · On Sunday 15 November 2015 03:30:25 Andy Shevchenko wrote:

On Sun, Nov 15, 2015 at 12:05 AM, Ondrej Zary

Quoted 11 lines · <[email protected]> wrote:

Add support for IP1000A chips to dl2k driver. IP1000A chip looks like a TC9020 with integrated PHY.

This allows IP1000A chips to work reliably because the ipg driver is buggy - it loses packets under load and then completely stops transmitting data.

Tested with Asus NX1101 v2.0 at 10, 100 and 1000Mbps. Also verified that it does not break D-Link DGE-550T.

Nitpicks below.

Quoted 6 lines
drivers/net/ethernet/dlink/dl2k.c +0 -0
@@ -253,6 +253,18 @@ rio_probe1 (struct pci_dev *pdev, const struct
 pci_device_id *ent) if (err)
                goto err_out_unmap_rx;
 
Quoted 12 lines

drivers/net/ethernet/dlink/dl2k.c rio_probe1 (struct pci_dev *pdev, const struct pci_device_id *ent) · line 265

Quoted 10 lines
drivers/net/ethernet/dlink/dl2k.c +10 -0
+       if (np->chip_id == CHIP_IP1000A &&
+           (np->pdev->revision == 0x40 || np->pdev->revision == 0x41)) {
+               /* PHY magic taken from ipg driver */
+               mii_write(dev, np->phy_addr, 31, 0x0001);
+               mii_write(dev, np->phy_addr, 27, 0x01e0);
+               mii_write(dev, np->phy_addr, 31, 0x0002);
+               mii_write(dev, np->phy_addr, 27, 0xeb8e);
+               mii_write(dev, np->phy_addr, 31, 0x0000);
+               mii_write(dev, np->phy_addr, 30, 0x005e);
+               mii_write(dev, np->phy_addr, 9, 0x0700);

Isn't too many magic numbers?

It's taken from the ipg driver where it was even more cryptic. I'll try to decode the magic numbers to something readable.

Quoted 21 lines
Quoted 21 lines
drivers/net/ethernet/dlink/dl2k.c +7 -0
+       }
+
        /* Fiber device? */
        np->phy_media = (dr16(ASICCtrl) & PhyMedia) ? 1 : 0;
        np->link_status = 0;
@@ -361,6 +373,11 @@ parse_eeprom (struct net_device *dev)
        for (i = 0; i < 6; i++)
                dev->dev_addr[i] = psrom->mac_addr[i];
 
+       if (np->chip_id == CHIP_IP1000A) {
+               np->led_mode = psrom->led_mode;
+               return 0;
+       }
+
        if (np->pdev->vendor != PCI_VENDOR_ID_DLINK) {
                return 0;
        }
@@ -406,6 +423,28 @@ parse_eeprom (struct net_device *dev)
        return 0;
 }
 
Quoted 15 lines
Quoted 11 lines
drivers/net/ethernet/dlink/dl2k.c +11 -0
+static void rio_set_led_mode(struct net_device *dev)
+{
+       struct netdev_private *np = netdev_priv(dev);
+       void __iomem *ioaddr = np->ioaddr;
+       u32 mode;
+
+       if (np->chip_id != CHIP_IP1000A)
+               return;
+
+       mode = dr32(ASICCtrl);
+       mode &= ~(IPG_AC_LED_MODE_BIT_1 | IPG_AC_LED_MODE |
Quoted 2 lines

IPG_AC_LED_SPEED); +
+ if ((np->led_mode & 0x03) > 1)

Isn't "& 0x03) > 1" the same as plain "& 0x02"?

Yes, you're right. It's copied from the ipg driver. I'll fix it.

Quoted 31 lines

drivers/net/ethernet/dlink/dl2k.c parse_eeprom (struct net_device *dev) · line 440

Quoted 2 lines
drivers/net/ethernet/dlink/dl2k.c +2 -0
+               mode |= IPG_AC_LED_MODE_BIT_1;
+       if ((np->led_mode & 0x01) == 1)

Hmm… Seems redundant == 1.

drivers/net/ethernet/dlink/dl2k.c parse_eeprom (struct net_device *dev) · line 442

Quoted 2 lines
drivers/net/ethernet/dlink/dl2k.c +2 -0
+               mode |= IPG_AC_LED_MODE;
+       if ((np->led_mode & 0x08) == 8)

Similar here.

Quoted 21 lines
drivers/net/ethernet/dlink/dl2k.c +7 -0
+               mode |= IPG_AC_LED_SPEED;
+
+       dw32(ASICCtrl, mode);
+}
+
 static int
 rio_open (struct net_device *dev)
 {
@@ -424,6 +463,8 @@ rio_open (struct net_device *dev)
             GlobalReset | DMAReset | FIFOReset | NetworkReset |
 HostReset); mdelay(10);
 
+       rio_set_led_mode(dev);
+
        /* DebugCtrl bit 4, 5, 9 must set */
        dw32(DebugCtrl, dr32(DebugCtrl) | 0x0230);
 
@@ -433,9 +474,10 @@ rio_open (struct net_device *dev)
 
        alloc_list (dev);
 
Quoted 10 lines

drivers/net/ethernet/dlink/dl2k.c rio_open (struct net_device *dev) · line 480

Quoted 7 lines
drivers/net/ethernet/dlink/dl2k.c +4 -3
-       /* Get station address */
-       for (i = 0; i < 6; i++)
-               dw8(StationAddr0 + i, dev->dev_addr[i]);
+       /* Set station address */
+       for (i = 0; i < 3; i++)
+               dw16(StationAddr0 + 2 * i,
+                    cpu_to_le16(((u16 *)dev->dev_addr)[i]));

Is it specific requirement for new HW? If not, may be another patch with micro optimizations.

Yes, the old method does not work on IP1000A. In fact, even the TC9020 datasheet says: "Access Rule: Word, Double Word". So it was always wrong but worked anyway until now.

Quoted 85 lines
Quoted 85 lines
drivers/net/ethernet/dlink/dl2k.c +3 -0
        set_multicast (dev);
        if (np->coalesce) {
@@ -780,6 +822,7 @@ tx_error (struct net_device *dev, int tx_status)
                                break;
                        mdelay (1);
                }
+               rio_set_led_mode(dev);
                rio_free_tx (dev, 1);
                /* Reset TFDListPtr */
                dw32(TFDListPtr0, np->tx_ring_dma +
@@ -799,6 +842,7 @@ tx_error (struct net_device *dev, int tx_status)
                                break;
                        mdelay (1);
                }
+               rio_set_led_mode(dev);
                /* Let TxStartThresh stay default value */
        }
        /* Maximum Collisions */
@@ -965,6 +1009,7 @@ rio_error (struct net_device *dev, int int_status)
                        dev->name, int_status);
                dw16(ASICCtrl + 2, GlobalReset | HostReset);
                mdelay (500);
+               rio_set_led_mode(dev);
        }
 }
 
(quoted diff) +0 -0

b/drivers/net/ethernet/dlink/dl2k.h index 23c07b0..8f4f612 100644

drivers/net/ethernet/dlink/dl2k.h +9 -1
@@ -211,6 +211,10 @@ enum ASICCtrl_HiWord_bits {
        ResetBusy = 0x0400,
 };
 
+#define IPG_AC_LED_MODE                BIT(14)
+#define IPG_AC_LED_SPEED       BIT(27)
+#define IPG_AC_LED_MODE_BIT_1  BIT(29)
+
 /* Transmit Frame Control bits */
 enum TFC_bits {
        DwordAlign = 0x00000000,
@@ -332,7 +336,10 @@ typedef struct t_SROM {
        u16 asic_ctrl;          /* 0x02 */
        u16 sub_vendor_id;      /* 0x04 */
        u16 sub_system_id;      /* 0x06 */
-       u16 reserved1[12];      /* 0x08-0x1f */
+       u16 pci_base_1;         /* 0x08 (IP1000A only) */
+       u16 pci_base_2;         /* 0x0a (IP1000A only) */
+       u16 led_mode;           /* 0x0c (IP1000A only) */
+       u16 reserved1[9];       /* 0x0e-0x1f */
        u8 mac_addr[6];         /* 0x20-0x25 */
        u8 reserved2[10];       /* 0x26-0x2f */
        u8 sib[204];            /* 0x30-0xfb */
@@ -397,6 +404,7 @@ struct netdev_private {
        u16 advertising;        /* NWay media advertisement */
        u16 negotiate;          /* Negotiated media */
        int phy_addr;           /* PHY addresses. */
+       u16 led_mode;           /* LED mode read from EEPROM (IP1000A
 only) */ };
 
 /* The station address location in the EEPROM. */
@@ -407,10 +415,15 @@ struct netdev_private {
         class_mask              of the class are honored during the

comparison. driver_data Data private to the driver.
*/

drivers/net/ethernet/dlink/dl2k.h +5 -1
+#define CHIP_IP1000A   1
 
 static const struct pci_device_id rio_pci_tbl[] = {
        {0x1186, 0x4000, PCI_ANY_ID, PCI_ANY_ID, },
        {0x13f0, 0x1021, PCI_ANY_ID, PCI_ANY_ID, },
+       { PCI_VDEVICE(SUNDANCE, 0x1023), CHIP_IP1000A },
+       { PCI_VDEVICE(SUNDANCE, 0x2021), CHIP_IP1000A },
+       { PCI_VDEVICE(DLINK,    0x9021), CHIP_IP1000A },
+       { PCI_VDEVICE(DLINK,    0x4020), CHIP_IP1000A },
        { }
 };
 MODULE_DEVICE_TABLE (pci, rio_pci_tbl);
--

Ondrej Zary

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Signature · 1 line
Ondrej Zary
maintainer
#4 lore raw
In reply to Andy Shevchenko

From: Andy Shevchenko <[email protected]>
Date: Sun, 15 Nov 2015 04:30:25 +0200

Quoted 5 lines

On Sun, Nov 15, 2015 at 12:05 AM, Ondrej Zary

Quoted 4 lines
drivers/net/ethernet/dlink/dl2k.c +0 -0
@@ -433,9 +474,10 @@ rio_open (struct net_device *dev)
 
        alloc_list (dev);
 
Quoted 10 lines

drivers/net/ethernet/dlink/dl2k.c rio_open (struct net_device *dev) · line 480

Quoted 7 lines
drivers/net/ethernet/dlink/dl2k.c +4 -3
-       /* Get station address */
-       for (i = 0; i < 6; i++)
-               dw8(StationAddr0 + i, dev->dev_addr[i]);
+       /* Set station address */
+       for (i = 0; i < 3; i++)
+               dw16(StationAddr0 + 2 * i,
+                    cpu_to_le16(((u16 *)dev->dev_addr)[i]));

Is it specific requirement for new HW? If not, may be another patch with micro optimizations.

I absolutely agree, this definitely should not just be blindly copied over from the other driver.

And if it is a requirement:

1) It must be documented as per why, both in a comment above the loop and in the commit log message.

2) It must therefore be tested on dl2k chips that worked with the dl2k driver beforehand to prove that it doesn't break them.

#5 lore raw
Quoted 20 lines · On Sunday 15 November 2015 18:59:05 David Miller wrote:

From: Andy Shevchenko <[email protected]>
Date: Sun, 15 Nov 2015 04:30:25 +0200

Quoted 6 lines

On Sun, Nov 15, 2015 at 12:05 AM, Ondrej Zary

Quoted 4 lines
drivers/net/ethernet/dlink/dl2k.c +0 -0
@@ -433,9 +474,10 @@ rio_open (struct net_device *dev)
 
        alloc_list (dev);
 
Quoted 10 lines

drivers/net/ethernet/dlink/dl2k.c rio_open (struct net_device *dev) · line 480

Quoted 7 lines
drivers/net/ethernet/dlink/dl2k.c +4 -3
-       /* Get station address */
-       for (i = 0; i < 6; i++)
-               dw8(StationAddr0 + i, dev->dev_addr[i]);
+       /* Set station address */
+       for (i = 0; i < 3; i++)
+               dw16(StationAddr0 + 2 * i,
+                    cpu_to_le16(((u16 *)dev->dev_addr)[i]));

Is it specific requirement for new HW? If not, may be another patch with micro optimizations.

Quoted 4 lines

I absolutely agree, this definitely should not just be blindly copied over from the other driver.

And if it is a requirement:

Yes, it's required. The byte access does not work on IP1000A chips.

Quoted 2 lines

1) It must be documented as per why, both in a comment above the loop and in the commit log message.

OK.

Quoted 2 lines

2) It must therefore be tested on dl2k chips that worked with the dl2k driver beforehand to prove that it doesn't break them.

Tested it with D-Link DGE-550T (chip marked DL-2000, probably rebranded TC9020) and it works fine.
Even the TC9020 datasheet says: "Access Rule: Word, Double Word". So it was always wrong but worked anyway.

Signature · 1 line
Ondrej Zary
maintainer
#6 lore raw

From: Ondrej Zary <[email protected]>
Date: Sun, 15 Nov 2015 21:04:58 +0100

Quoted 4 lines

Tested it with D-Link DGE-550T (chip marked DL-2000, probably rebranded TC9020) and it works fine. Even the TC9020 datasheet
says: "Access Rule: Word, Double Word". So it was always wrong but worked anyway.

Great, thanks for the info.